summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>1993-07-30 20:16:54 +0000
committercvs2svn <cvs2svn@FreeBSD.org>1993-07-30 20:16:54 +0000
commit4c6599b12882858dff92d2ae55f6683ca070bea5 (patch)
tree9ca97530aa31f1b27cf6847235f74abda80a9f75 /gnu
parent5e0c8d9ee2600d5f7d5c710e34249ae51db60ba7 (diff)
downloadFreeBSD-src-4c6599b12882858dff92d2ae55f6683ca070bea5.zip
FreeBSD-src-4c6599b12882858dff92d2ae55f6683ca070bea5.tar.gz
This commit was manufactured by cvs2svn to create branch
'VENDOR-libregex'.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/COPYING339
-rw-r--r--gnu/COPYING.LIB481
-rw-r--r--gnu/Makefile6
-rw-r--r--gnu/Makefile.inc4
-rw-r--r--gnu/games/chess/DOCUMENTATION/ARTICLE66
-rw-r--r--gnu/games/chess/DOCUMENTATION/ARTICLE.2123
-rw-r--r--gnu/games/chess/DOCUMENTATION/CHANGES362
-rw-r--r--gnu/games/chess/DOCUMENTATION/COPYING123
-rw-r--r--gnu/games/chess/DOCUMENTATION/GENERAL34
-rw-r--r--gnu/games/chess/DOCUMENTATION/HEURISTICS122
-rw-r--r--gnu/games/chess/DOCUMENTATION/MAN-PAGE161
-rw-r--r--gnu/games/chess/Makefile15
-rw-r--r--gnu/games/chess/Xchess/COPYING124
-rw-r--r--gnu/games/chess/Xchess/Makefile136
-rw-r--r--gnu/games/chess/Xchess/ScrollText34
-rw-r--r--gnu/games/chess/Xchess/XCircle.c162
-rw-r--r--gnu/games/chess/Xchess/bishop.bitmap71
-rw-r--r--gnu/games/chess/Xchess/bishop_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/bishop_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/bishop_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/bishop_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/board.c179
-rw-r--r--gnu/games/chess/Xchess/button.c337
-rw-r--r--gnu/games/chess/Xchess/clock.c291
-rw-r--r--gnu/games/chess/Xchess/control.c515
-rw-r--r--gnu/games/chess/Xchess/jail.c327
-rw-r--r--gnu/games/chess/Xchess/king.bitmap71
-rw-r--r--gnu/games/chess/Xchess/king_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/king_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/king_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/king_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/knight.bitmap71
-rw-r--r--gnu/games/chess/Xchess/knight_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/knight_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/knight_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/knight_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/message.c101
-rw-r--r--gnu/games/chess/Xchess/parse.c386
-rw-r--r--gnu/games/chess/Xchess/pawn.bitmap71
-rw-r--r--gnu/games/chess/Xchess/pawn_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/pawn_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/pawn_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/pawn_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/popup.c112
-rw-r--r--gnu/games/chess/Xchess/program.c200
-rw-r--r--gnu/games/chess/Xchess/queen.bitmap71
-rw-r--r--gnu/games/chess/Xchess/queen_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/queen_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/queen_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/queen_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/record.c315
-rw-r--r--gnu/games/chess/Xchess/rook.bitmap71
-rw-r--r--gnu/games/chess/Xchess/rook_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/rook_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/rook_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/rook_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/scrollText.c1858
-rw-r--r--gnu/games/chess/Xchess/scrollText.h32
-rw-r--r--gnu/games/chess/Xchess/scrollText/scrollText.c1858
-rw-r--r--gnu/games/chess/Xchess/scrollText/scrollText.h32
-rw-r--r--gnu/games/chess/Xchess/shade.bitmap71
-rw-r--r--gnu/games/chess/Xchess/std.c425
-rw-r--r--gnu/games/chess/Xchess/std.h105
-rw-r--r--gnu/games/chess/Xchess/valid.c264
-rw-r--r--gnu/games/chess/Xchess/window.c952
-rw-r--r--gnu/games/chess/Xchess/window.c.bm928
-rw-r--r--gnu/games/chess/Xchess/xchess.1217
-rw-r--r--gnu/games/chess/Xchess/xchess.c205
-rw-r--r--gnu/games/chess/Xchess/xchess.c.150197
-rw-r--r--gnu/games/chess/Xchess/xchess.cur9
-rw-r--r--gnu/games/chess/Xchess/xchess.game8
-rw-r--r--gnu/games/chess/Xchess/xchess.h301
-rw-r--r--gnu/games/chess/Xchess/xchess.icon28
-rw-r--r--gnu/games/chess/Xchess/xchess_mask.cur7
-rw-r--r--gnu/games/chess/chess.6161
-rw-r--r--gnu/games/chess/gnuchess.book3878
-rw-r--r--gnu/games/chess/gnuchess.c2307
-rw-r--r--gnu/games/chess/gnuchess.h97
-rw-r--r--gnu/games/chess/move.c357
-rw-r--r--gnu/games/chess/move.h81
-rw-r--r--gnu/games/chess/nondsp.c791
-rw-r--r--gnu/games/chess/pathnames.h36
-rw-r--r--gnu/games/chess/uxdsp.c933
-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/Makefile12
-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/Makefile93
-rw-r--r--gnu/lib/libregex/doc/Makefile.in92
-rw-r--r--gnu/lib/libregex/doc/include.awk19
-rw-r--r--gnu/lib/libregex/doc/regex.aux136
-rw-r--r--gnu/lib/libregex/doc/regex.cps152
-rw-r--r--gnu/lib/libregex/doc/regex.info2836
-rw-r--r--gnu/lib/libregex/doc/regex.texi3138
-rw-r--r--gnu/lib/libregex/doc/xregex.texi3021
-rw-r--r--gnu/lib/libregex/test/ChangeLog77
-rw-r--r--gnu/lib/libregex/test/Makefile169
-rw-r--r--gnu/lib/libregex/test/Makefile.in168
-rw-r--r--gnu/lib/libregex/test/TAGS373
-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/usr.bin/as/COPYING249
-rw-r--r--gnu/usr.bin/as/ChangeLog917
-rw-r--r--gnu/usr.bin/as/Makefile15
-rw-r--r--gnu/usr.bin/as/Makefile.gnu356
-rw-r--r--gnu/usr.bin/as/NOTES35
-rw-r--r--gnu/usr.bin/as/README.gnu133
-rw-r--r--gnu/usr.bin/as/app.c392
-rw-r--r--gnu/usr.bin/as/append.c37
-rw-r--r--gnu/usr.bin/as/as.10
-rw-r--r--gnu/usr.bin/as/as.1aout0
-rw-r--r--gnu/usr.bin/as/as.c324
-rw-r--r--gnu/usr.bin/as/as.h292
-rw-r--r--gnu/usr.bin/as/atof-generic.c526
-rw-r--r--gnu/usr.bin/as/bignum-copy.c75
-rw-r--r--gnu/usr.bin/as/bignum.h48
-rw-r--r--gnu/usr.bin/as/config/Makefile.i3864
-rw-r--r--gnu/usr.bin/as/config/a.out.gnu.h261
-rw-r--r--gnu/usr.bin/as/config/atof-ieee.c505
-rw-r--r--gnu/usr.bin/as/config/i386-opcode.h806
-rw-r--r--gnu/usr.bin/as/config/i386.c1946
-rw-r--r--gnu/usr.bin/as/config/i386.h296
-rw-r--r--gnu/usr.bin/as/expr.c980
-rw-r--r--gnu/usr.bin/as/expr.h69
-rw-r--r--gnu/usr.bin/as/flonum-const.c157
-rw-r--r--gnu/usr.bin/as/flonum-copy.c76
-rw-r--r--gnu/usr.bin/as/flonum-mult.c200
-rw-r--r--gnu/usr.bin/as/flonum.h111
-rw-r--r--gnu/usr.bin/as/frags.c292
-rw-r--r--gnu/usr.bin/as/frags.h41
-rw-r--r--gnu/usr.bin/as/hash.c981
-rw-r--r--gnu/usr.bin/as/hash.h59
-rw-r--r--gnu/usr.bin/as/hex-value.c55
-rw-r--r--gnu/usr.bin/as/input-file.c306
-rw-r--r--gnu/usr.bin/as/input-file.h57
-rw-r--r--gnu/usr.bin/as/input-scrub.c427
-rw-r--r--gnu/usr.bin/as/md.h57
-rw-r--r--gnu/usr.bin/as/messages.c238
-rw-r--r--gnu/usr.bin/as/objrecdef.h255
-rw-r--r--gnu/usr.bin/as/obstack.c337
-rw-r--r--gnu/usr.bin/as/obstack.h418
-rw-r--r--gnu/usr.bin/as/output-file.c81
-rw-r--r--gnu/usr.bin/as/read.c2188
-rw-r--r--gnu/usr.bin/as/read.h47
-rw-r--r--gnu/usr.bin/as/struc-symbol.h72
-rw-r--r--gnu/usr.bin/as/subsegs.c292
-rw-r--r--gnu/usr.bin/as/subsegs.h65
-rw-r--r--gnu/usr.bin/as/symbols.c438
-rw-r--r--gnu/usr.bin/as/symbols.h42
-rw-r--r--gnu/usr.bin/as/version.c23
-rw-r--r--gnu/usr.bin/as/write.c1259
-rw-r--r--gnu/usr.bin/as/write.h77
-rw-r--r--gnu/usr.bin/as/xmalloc.c60
-rw-r--r--gnu/usr.bin/as/xrealloc.c61
-rw-r--r--gnu/usr.bin/awk/ACKNOWLEDGMENT21
-rw-r--r--gnu/usr.bin/awk/COPYING340
-rw-r--r--gnu/usr.bin/awk/FUTURES120
-rw-r--r--gnu/usr.bin/awk/LIMITATIONS14
-rw-r--r--gnu/usr.bin/awk/Makefile13
-rw-r--r--gnu/usr.bin/awk/NEWS1295
-rw-r--r--gnu/usr.bin/awk/PORTS32
-rw-r--r--gnu/usr.bin/awk/POSIX95
-rw-r--r--gnu/usr.bin/awk/PROBLEMS6
-rw-r--r--gnu/usr.bin/awk/README116
-rw-r--r--gnu/usr.bin/awk/array.c293
-rw-r--r--gnu/usr.bin/awk/awk.11873
-rw-r--r--gnu/usr.bin/awk/awk.h763
-rw-r--r--gnu/usr.bin/awk/awk.y1804
-rw-r--r--gnu/usr.bin/awk/builtin.c1133
-rw-r--r--gnu/usr.bin/awk/config.h272
-rw-r--r--gnu/usr.bin/awk/dfa.c2291
-rw-r--r--gnu/usr.bin/awk/dfa.h543
-rw-r--r--gnu/usr.bin/awk/eval.c1225
-rw-r--r--gnu/usr.bin/awk/field.c645
-rw-r--r--gnu/usr.bin/awk/gawk.texi11270
-rw-r--r--gnu/usr.bin/awk/getopt.c662
-rw-r--r--gnu/usr.bin/awk/getopt.h128
-rw-r--r--gnu/usr.bin/awk/getopt1.c160
-rw-r--r--gnu/usr.bin/awk/io.c1207
-rw-r--r--gnu/usr.bin/awk/iop.c318
-rw-r--r--gnu/usr.bin/awk/main.c731
-rw-r--r--gnu/usr.bin/awk/msg.c106
-rw-r--r--gnu/usr.bin/awk/node.c429
-rw-r--r--gnu/usr.bin/awk/patchlevel.h1
-rw-r--r--gnu/usr.bin/awk/protos.h115
-rw-r--r--gnu/usr.bin/awk/re.c208
-rw-r--r--gnu/usr.bin/awk/regex.c2854
-rw-r--r--gnu/usr.bin/awk/regex.h260
-rw-r--r--gnu/usr.bin/awk/version.c46
-rw-r--r--gnu/usr.bin/bc/COPYING341
-rw-r--r--gnu/usr.bin/bc/Makefile6
-rw-r--r--gnu/usr.bin/bc/bc.1730
-rw-r--r--gnu/usr.bin/bc/bc.c1369
-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.h87
-rw-r--r--gnu/usr.bin/bc/execute.c783
-rw-r--r--gnu/usr.bin/bc/global.c42
-rw-r--r--gnu/usr.bin/bc/global.h108
-rw-r--r--gnu/usr.bin/bc/libmath.b255
-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.c1405
-rw-r--r--gnu/usr.bin/bc/number.h60
-rw-r--r--gnu/usr.bin/bc/proto.h165
-rw-r--r--gnu/usr.bin/bc/scan.c1368
-rw-r--r--gnu/usr.bin/bc/storage.c967
-rw-r--r--gnu/usr.bin/bc/util.c794
-rw-r--r--gnu/usr.bin/bc/version.h3
-rw-r--r--gnu/usr.bin/bc/y.tab.h40
-rw-r--r--gnu/usr.bin/cvs/Makefile3
-rw-r--r--gnu/usr.bin/cvs/contrib/README68
-rw-r--r--gnu/usr.bin/cvs/contrib/cln_hist.pl91
-rw-r--r--gnu/usr.bin/cvs/contrib/commit_prep.pl168
-rw-r--r--gnu/usr.bin/cvs/contrib/cvs_acls.pl142
-rw-r--r--gnu/usr.bin/cvs/contrib/cvscheck84
-rw-r--r--gnu/usr.bin/cvs/contrib/cvscheck.man53
-rw-r--r--gnu/usr.bin/cvs/contrib/cvshelp.man562
-rw-r--r--gnu/usr.bin/cvs/contrib/descend116
-rw-r--r--gnu/usr.bin/cvs/contrib/descend.man115
-rw-r--r--gnu/usr.bin/cvs/contrib/dirfns481
-rw-r--r--gnu/usr.bin/cvs/contrib/log.pl104
-rw-r--r--gnu/usr.bin/cvs/contrib/log_accum.pl331
-rw-r--r--gnu/usr.bin/cvs/contrib/mfpipe.pl87
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog119
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL83
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile78
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/README14
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el52
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/cookie.el884
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll-debug.el298
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll.el386
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/elib-node.el89
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el6
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el1476
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info1367
-rw-r--r--gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo1437
-rw-r--r--gnu/usr.bin/cvs/contrib/rcs-to-cvs208
-rw-r--r--gnu/usr.bin/cvs/contrib/rcslock.pl234
-rw-r--r--gnu/usr.bin/cvs/contrib/sccs2rcs277
-rw-r--r--gnu/usr.bin/cvs/cvs/Makefile25
-rw-r--r--gnu/usr.bin/cvs/cvs/add.c447
-rw-r--r--gnu/usr.bin/cvs/cvs/admin.c124
-rw-r--r--gnu/usr.bin/cvs/cvs/checkin.c135
-rw-r--r--gnu/usr.bin/cvs/cvs/checkout.c718
-rw-r--r--gnu/usr.bin/cvs/cvs/classify.c380
-rw-r--r--gnu/usr.bin/cvs/cvs/commit.c1229
-rw-r--r--gnu/usr.bin/cvs/cvs/config.h217
-rw-r--r--gnu/usr.bin/cvs/cvs/create_adm.c100
-rw-r--r--gnu/usr.bin/cvs/cvs/cvs.11991
-rw-r--r--gnu/usr.bin/cvs/cvs/cvs.5326
-rw-r--r--gnu/usr.bin/cvs/cvs/cvs.h438
-rw-r--r--gnu/usr.bin/cvs/cvs/diff.c407
-rw-r--r--gnu/usr.bin/cvs/cvs/entries.c488
-rw-r--r--gnu/usr.bin/cvs/cvs/find_names.c272
-rw-r--r--gnu/usr.bin/cvs/cvs/history.c1373
-rw-r--r--gnu/usr.bin/cvs/cvs/ignore.c227
-rw-r--r--gnu/usr.bin/cvs/cvs/import.c1007
-rw-r--r--gnu/usr.bin/cvs/cvs/lock.c522
-rw-r--r--gnu/usr.bin/cvs/cvs/log.c132
-rw-r--r--gnu/usr.bin/cvs/cvs/logmsg.c449
-rw-r--r--gnu/usr.bin/cvs/cvs/main.c444
-rw-r--r--gnu/usr.bin/cvs/cvs/modules.c810
-rw-r--r--gnu/usr.bin/cvs/cvs/no_diff.c85
-rw-r--r--gnu/usr.bin/cvs/cvs/parseinfo.c147
-rw-r--r--gnu/usr.bin/cvs/cvs/patch.c523
-rw-r--r--gnu/usr.bin/cvs/cvs/patchlevel.h1
-rw-r--r--gnu/usr.bin/cvs/cvs/rcs.c1449
-rw-r--r--gnu/usr.bin/cvs/cvs/rcs.h102
-rw-r--r--gnu/usr.bin/cvs/cvs/recurse.c535
-rw-r--r--gnu/usr.bin/cvs/cvs/release.c219
-rw-r--r--gnu/usr.bin/cvs/cvs/remove.c176
-rw-r--r--gnu/usr.bin/cvs/cvs/repos.c169
-rw-r--r--gnu/usr.bin/cvs/cvs/rtag.c403
-rw-r--r--gnu/usr.bin/cvs/cvs/status.c230
-rw-r--r--gnu/usr.bin/cvs/cvs/tag.c263
-rw-r--r--gnu/usr.bin/cvs/cvs/update.c1059
-rw-r--r--gnu/usr.bin/cvs/cvs/vers_ts.c224
-rw-r--r--gnu/usr.bin/cvs/cvs/version.c11
-rw-r--r--gnu/usr.bin/cvs/doc/cvs.ms1073
-rw-r--r--gnu/usr.bin/cvs/examples/commitinfo21
-rw-r--r--gnu/usr.bin/cvs/examples/editinfo30
-rw-r--r--gnu/usr.bin/cvs/examples/loginfo20
-rw-r--r--gnu/usr.bin/cvs/examples/modules566
-rw-r--r--gnu/usr.bin/cvs/examples/rcsinfo18
-rw-r--r--gnu/usr.bin/cvs/lib/Makefile13
-rw-r--r--gnu/usr.bin/cvs/lib/Makefile.in91
-rw-r--r--gnu/usr.bin/cvs/lib/alloca.c191
-rw-r--r--gnu/usr.bin/cvs/lib/argmatch.c83
-rw-r--r--gnu/usr.bin/cvs/lib/dup2.c36
-rw-r--r--gnu/usr.bin/cvs/lib/error.c193
-rw-r--r--gnu/usr.bin/cvs/lib/fnmatch.c183
-rw-r--r--gnu/usr.bin/cvs/lib/fnmatch.h45
-rw-r--r--gnu/usr.bin/cvs/lib/ftruncate.c72
-rw-r--r--gnu/usr.bin/cvs/lib/getdate.y889
-rw-r--r--gnu/usr.bin/cvs/lib/getopt.c604
-rw-r--r--gnu/usr.bin/cvs/lib/getopt.h102
-rw-r--r--gnu/usr.bin/cvs/lib/getopt1.c166
-rw-r--r--gnu/usr.bin/cvs/lib/getwd.c31
-rw-r--r--gnu/usr.bin/cvs/lib/hash.c338
-rw-r--r--gnu/usr.bin/cvs/lib/hash.h77
-rw-r--r--gnu/usr.bin/cvs/lib/mkdir.c125
-rw-r--r--gnu/usr.bin/cvs/lib/myndbm.c212
-rw-r--r--gnu/usr.bin/cvs/lib/myndbm.h44
-rw-r--r--gnu/usr.bin/cvs/lib/regex.c4867
-rw-r--r--gnu/usr.bin/cvs/lib/regex.h479
-rw-r--r--gnu/usr.bin/cvs/lib/rename.c68
-rw-r--r--gnu/usr.bin/cvs/lib/sighandle.c412
-rw-r--r--gnu/usr.bin/cvs/lib/strdup.c39
-rw-r--r--gnu/usr.bin/cvs/lib/strippath.c74
-rw-r--r--gnu/usr.bin/cvs/lib/stripslash.c35
-rw-r--r--gnu/usr.bin/cvs/lib/subr.c912
-rw-r--r--gnu/usr.bin/cvs/lib/system.h223
-rw-r--r--gnu/usr.bin/cvs/lib/wait.h29
-rw-r--r--gnu/usr.bin/cvs/lib/y.tab.h18
-rw-r--r--gnu/usr.bin/cvs/lib/yesno.c37
-rw-r--r--gnu/usr.bin/cvs/mkmodules/Makefile12
-rw-r--r--gnu/usr.bin/cvs/mkmodules/mkmodules.165
-rw-r--r--gnu/usr.bin/cvs/mkmodules/mkmodules.c395
-rw-r--r--gnu/usr.bin/cvs/mkmodules/xxx5320
-rw-r--r--gnu/usr.bin/diff/COPYING339
-rw-r--r--gnu/usr.bin/diff/Makefile11
-rw-r--r--gnu/usr.bin/diff/analyze.c944
-rw-r--r--gnu/usr.bin/diff/context.c462
-rw-r--r--gnu/usr.bin/diff/diff.c927
-rw-r--r--gnu/usr.bin/diff/diff.h335
-rw-r--r--gnu/usr.bin/diff/diff3.c1693
-rw-r--r--gnu/usr.bin/diff/dir.c213
-rw-r--r--gnu/usr.bin/diff/ed.c205
-rw-r--r--gnu/usr.bin/diff/fnmatch.h62
-rw-r--r--gnu/usr.bin/diff/getopt.c731
-rw-r--r--gnu/usr.bin/diff/getopt.h129
-rw-r--r--gnu/usr.bin/diff/getopt1.c176
-rw-r--r--gnu/usr.bin/diff/ifdef.c183
-rw-r--r--gnu/usr.bin/diff/io.c700
-rw-r--r--gnu/usr.bin/diff/normal.c74
-rw-r--r--gnu/usr.bin/diff/regex.c4987
-rw-r--r--gnu/usr.bin/diff/regex.h490
-rw-r--r--gnu/usr.bin/diff/sdiff.c1067
-rw-r--r--gnu/usr.bin/diff/side.c283
-rw-r--r--gnu/usr.bin/diff/system.h159
-rw-r--r--gnu/usr.bin/diff/util.c703
-rw-r--r--gnu/usr.bin/diff/version.c3
-rw-r--r--gnu/usr.bin/diff3/COPYING339
-rw-r--r--gnu/usr.bin/diff3/Makefile11
-rw-r--r--gnu/usr.bin/diff3/diff3.c1693
-rw-r--r--gnu/usr.bin/diff3/getopt.c731
-rw-r--r--gnu/usr.bin/diff3/getopt.h129
-rw-r--r--gnu/usr.bin/diff3/getopt1.c176
-rw-r--r--gnu/usr.bin/diff3/system.h159
-rw-r--r--gnu/usr.bin/diff3/version.c3
-rw-r--r--gnu/usr.bin/gdb/COPYING249
-rw-r--r--gnu/usr.bin/gdb/ChangeLog4887
-rw-r--r--gnu/usr.bin/gdb/Gdbinit15
-rw-r--r--gnu/usr.bin/gdb/Makefile38
-rw-r--r--gnu/usr.bin/gdb/Makefile.dist371
-rw-r--r--gnu/usr.bin/gdb/Projects114
-rw-r--r--gnu/usr.bin/gdb/README.gnu142
-rw-r--r--gnu/usr.bin/gdb/XGdbinit.samp15
-rw-r--r--gnu/usr.bin/gdb/Xgdb.ad8
-rw-r--r--gnu/usr.bin/gdb/blockframe.c622
-rw-r--r--gnu/usr.bin/gdb/breakpoint.c1383
-rw-r--r--gnu/usr.bin/gdb/command.c856
-rw-r--r--gnu/usr.bin/gdb/command.h77
-rw-r--r--gnu/usr.bin/gdb/config/Makefile.i3866
-rw-r--r--gnu/usr.bin/gdb/config/default-dep.c585
-rw-r--r--gnu/usr.bin/gdb/config/i386-dep.c1275
-rw-r--r--gnu/usr.bin/gdb/config/i386-pinsn.c1812
-rw-r--r--gnu/usr.bin/gdb/config/i386bsd-dep.c1884
-rw-r--r--gnu/usr.bin/gdb/config/m-i386-sv32.h28
-rw-r--r--gnu/usr.bin/gdb/config/m-i386.h394
-rw-r--r--gnu/usr.bin/gdb/config/m-i386bsd.h375
-rw-r--r--gnu/usr.bin/gdb/config/m-i386g-sv32.h28
-rw-r--r--gnu/usr.bin/gdb/config/m-i386gas.h37
-rw-r--r--gnu/usr.bin/gdb/copying.c215
-rw-r--r--gnu/usr.bin/gdb/core.c581
-rw-r--r--gnu/usr.bin/gdb/cplus-dem.c996
-rw-r--r--gnu/usr.bin/gdb/dbxread.c5727
-rw-r--r--gnu/usr.bin/gdb/defs.h122
-rw-r--r--gnu/usr.bin/gdb/environ.c185
-rw-r--r--gnu/usr.bin/gdb/environ.h39
-rw-r--r--gnu/usr.bin/gdb/eval.c1065
-rw-r--r--gnu/usr.bin/gdb/expprint.c324
-rw-r--r--gnu/usr.bin/gdb/expread.y1782
-rw-r--r--gnu/usr.bin/gdb/expression.h191
-rw-r--r--gnu/usr.bin/gdb/findvar.c579
-rw-r--r--gnu/usr.bin/gdb/frame.h115
-rw-r--r--gnu/usr.bin/gdb/gdb.13
-rw-r--r--gnu/usr.bin/gdb/getpagesize.h25
-rw-r--r--gnu/usr.bin/gdb/infcmd.c1204
-rw-r--r--gnu/usr.bin/gdb/inferior.h142
-rw-r--r--gnu/usr.bin/gdb/inflow.c569
-rw-r--r--gnu/usr.bin/gdb/infrun.c1459
-rw-r--r--gnu/usr.bin/gdb/kgdb_proto.h63
-rw-r--r--gnu/usr.bin/gdb/main.c2241
-rw-r--r--gnu/usr.bin/gdb/ngdb.i386/Makefile27
-rw-r--r--gnu/usr.bin/gdb/obstack.c313
-rw-r--r--gnu/usr.bin/gdb/obstack.h372
-rw-r--r--gnu/usr.bin/gdb/printcmd.c1867
-rw-r--r--gnu/usr.bin/gdb/readline/ChangeLog98
-rw-r--r--gnu/usr.bin/gdb/readline/Makefile.gnu114
-rw-r--r--gnu/usr.bin/gdb/readline/chardefs.h50
-rw-r--r--gnu/usr.bin/gdb/readline/emacs_keymap.c472
-rw-r--r--gnu/usr.bin/gdb/readline/funmap.c217
-rw-r--r--gnu/usr.bin/gdb/readline/history.c1462
-rw-r--r--gnu/usr.bin/gdb/readline/history.h108
-rw-r--r--gnu/usr.bin/gdb/readline/keymaps.c172
-rw-r--r--gnu/usr.bin/gdb/readline/keymaps.h53
-rw-r--r--gnu/usr.bin/gdb/readline/readline.c5557
-rw-r--r--gnu/usr.bin/gdb/readline/readline.h161
-rw-r--r--gnu/usr.bin/gdb/readline/vi_keymap.c484
-rw-r--r--gnu/usr.bin/gdb/readline/vi_mode.c875
-rw-r--r--gnu/usr.bin/gdb/regex.c1738
-rw-r--r--gnu/usr.bin/gdb/regex.h185
-rw-r--r--gnu/usr.bin/gdb/remote-sl.c10
-rw-r--r--gnu/usr.bin/gdb/remote.c626
-rw-r--r--gnu/usr.bin/gdb/source.c1166
-rw-r--r--gnu/usr.bin/gdb/stab.def115
-rw-r--r--gnu/usr.bin/gdb/stack.c960
-rw-r--r--gnu/usr.bin/gdb/symmisc.c584
-rw-r--r--gnu/usr.bin/gdb/symseg.h523
-rw-r--r--gnu/usr.bin/gdb/symtab.c2473
-rw-r--r--gnu/usr.bin/gdb/symtab.h384
-rw-r--r--gnu/usr.bin/gdb/utils.c1096
-rw-r--r--gnu/usr.bin/gdb/valarith.c690
-rw-r--r--gnu/usr.bin/gdb/valops.c1418
-rw-r--r--gnu/usr.bin/gdb/valprint.c1430
-rw-r--r--gnu/usr.bin/gdb/value.h212
-rw-r--r--gnu/usr.bin/gdb/values.c1059
-rw-r--r--gnu/usr.bin/gdb/version.c20
-rw-r--r--gnu/usr.bin/gdb/wait.h81
-rw-r--r--gnu/usr.bin/gdb/xgdb/Makefile33
-rw-r--r--gnu/usr.bin/gdb/xgdb/xgdb.c700
-rw-r--r--gnu/usr.bin/grep/AUTHORS29
-rw-r--r--gnu/usr.bin/grep/COPYING339
-rw-r--r--gnu/usr.bin/grep/Makefile14
-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.c2525
-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.1375
-rw-r--r--gnu/usr.bin/grep/grep.c826
-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/regex.c4987
-rw-r--r--gnu/usr.bin/grep/regex.h490
-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/regress.sh30
-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/gzip/COPYING339
-rw-r--r--gnu/usr.bin/gzip/ChangeLog526
-rw-r--r--gnu/usr.bin/gzip/Makefile25
-rw-r--r--gnu/usr.bin/gzip/NEWS196
-rw-r--r--gnu/usr.bin/gzip/README159
-rw-r--r--gnu/usr.bin/gzip/THANKS226
-rw-r--r--gnu/usr.bin/gzip/TODO53
-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.c716
-rw-r--r--gnu/usr.bin/gzip/getopt.h126
-rw-r--r--gnu/usr.bin/gzip/gzexe150
-rw-r--r--gnu/usr.bin/gzip/gzexe.143
-rw-r--r--gnu/usr.bin/gzip/gzexe.in151
-rw-r--r--gnu/usr.bin/gzip/gzip.1439
-rw-r--r--gnu/usr.bin/gzip/gzip.c1679
-rw-r--r--gnu/usr.bin/gzip/gzip.h315
-rw-r--r--gnu/usr.bin/gzip/inflate.c953
-rw-r--r--gnu/usr.bin/gzip/lzw.c25
-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.h300
-rw-r--r--gnu/usr.bin/gzip/trees.c1075
-rw-r--r--gnu/usr.bin/gzip/unlzh.c385
-rw-r--r--gnu/usr.bin/gzip/unlzw.c374
-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.c462
-rw-r--r--gnu/usr.bin/gzip/zcmp67
-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/zip.c117
-rw-r--r--gnu/usr.bin/gzip/zmore47
-rw-r--r--gnu/usr.bin/gzip/zmore.1145
-rw-r--r--gnu/usr.bin/gzip/znew153
-rw-r--r--gnu/usr.bin/gzip/znew.137
-rw-r--r--gnu/usr.bin/ld/Makefile8
-rw-r--r--gnu/usr.bin/ld/cplus-dem.c974
-rw-r--r--gnu/usr.bin/ld/ld.c4716
-rw-r--r--gnu/usr.bin/ld/symseg.h358
-rw-r--r--gnu/usr.bin/man/COPYING339
-rw-r--r--gnu/usr.bin/man/Makefile10
-rw-r--r--gnu/usr.bin/man/Makefile.inc34
-rw-r--r--gnu/usr.bin/man/README134
-rw-r--r--gnu/usr.bin/man/TODO123
-rw-r--r--gnu/usr.bin/man/apropos/Makefile37
-rw-r--r--gnu/usr.bin/man/apropos/apropos64
-rw-r--r--gnu/usr.bin/man/apropos/apropos.127
-rw-r--r--gnu/usr.bin/man/apropos/apropos.man27
-rw-r--r--gnu/usr.bin/man/apropos/apropos.sh64
-rw-r--r--gnu/usr.bin/man/catman/Makefile7
-rw-r--r--gnu/usr.bin/man/catman/catman36
-rw-r--r--gnu/usr.bin/man/lib/Makefile30
-rw-r--r--gnu/usr.bin/man/lib/config.h216
-rw-r--r--gnu/usr.bin/man/lib/config.h_dist216
-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.c150
-rw-r--r--gnu/usr.bin/man/makewhatis/Makefile24
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis79
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.sh113
-rw-r--r--gnu/usr.bin/man/man/Makefile29
-rw-r--r--gnu/usr.bin/man/man/glob.c680
-rw-r--r--gnu/usr.bin/man/man/man.1132
-rw-r--r--gnu/usr.bin/man/man/man.c1431
-rw-r--r--gnu/usr.bin/man/man/man.man132
-rw-r--r--gnu/usr.bin/man/man/manpath.c520
-rw-r--r--gnu/usr.bin/man/man/manpath.h26
-rw-r--r--gnu/usr.bin/man/man/ndir.h51
-rw-r--r--gnu/usr.bin/man/man/strdup.c39
-rw-r--r--gnu/usr.bin/man/man/version.h17
-rw-r--r--gnu/usr.bin/man/manpath/Makefile30
-rw-r--r--gnu/usr.bin/man/manpath/manpath.c520
-rw-r--r--gnu/usr.bin/man/manpath/manpath.config30
-rw-r--r--gnu/usr.bin/man/manpath/manpath.h26
-rw-r--r--gnu/usr.bin/man/manpath/manpath.man56
-rw-r--r--gnu/usr.bin/man/whatis/Makefile37
-rw-r--r--gnu/usr.bin/man/whatis/whatis66
-rw-r--r--gnu/usr.bin/man/whatis/whatis.127
-rw-r--r--gnu/usr.bin/man/whatis/whatis.man27
-rw-r--r--gnu/usr.bin/man/whatis/whatis.sh66
-rw-r--r--gnu/usr.bin/patch/EXTERN.h21
-rw-r--r--gnu/usr.bin/patch/INTERN.h19
-rw-r--r--gnu/usr.bin/patch/Makefile6
-rw-r--r--gnu/usr.bin/patch/backupfile.c402
-rw-r--r--gnu/usr.bin/patch/backupfile.h46
-rw-r--r--gnu/usr.bin/patch/common.h190
-rw-r--r--gnu/usr.bin/patch/config.h81
-rw-r--r--gnu/usr.bin/patch/getopt.c731
-rw-r--r--gnu/usr.bin/patch/getopt.h129
-rw-r--r--gnu/usr.bin/patch/getopt1.c176
-rw-r--r--gnu/usr.bin/patch/inp.c369
-rw-r--r--gnu/usr.bin/patch/inp.h18
-rw-r--r--gnu/usr.bin/patch/patch.1570
-rw-r--r--gnu/usr.bin/patch/patch.c945
-rw-r--r--gnu/usr.bin/patch/patchlevel.h1
-rw-r--r--gnu/usr.bin/patch/pch.c1305
-rw-r--r--gnu/usr.bin/patch/pch.h36
-rw-r--r--gnu/usr.bin/patch/util.c433
-rw-r--r--gnu/usr.bin/patch/util.h88
-rw-r--r--gnu/usr.bin/patch/version.c25
-rw-r--r--gnu/usr.bin/patch/version.h9
-rw-r--r--gnu/usr.bin/pr/COPYING339
-rw-r--r--gnu/usr.bin/pr/Makefile7
-rw-r--r--gnu/usr.bin/pr/error.c106
-rw-r--r--gnu/usr.bin/pr/getopt.c731
-rw-r--r--gnu/usr.bin/pr/getopt.h129
-rw-r--r--gnu/usr.bin/pr/getopt1.c176
-rw-r--r--gnu/usr.bin/pr/pr.1103
-rw-r--r--gnu/usr.bin/pr/pr.c1875
-rw-r--r--gnu/usr.bin/pr/system.h168
-rw-r--r--gnu/usr.bin/pr/version.c2
-rw-r--r--gnu/usr.bin/pr/version.h1
-rw-r--r--gnu/usr.bin/pr/xmalloc.c65
-rw-r--r--gnu/usr.bin/rcs/Makefile3
-rw-r--r--gnu/usr.bin/rcs/Makefile.inc7
-rw-r--r--gnu/usr.bin/rcs/ci/Makefile8
-rw-r--r--gnu/usr.bin/rcs/ci/ci.1772
-rw-r--r--gnu/usr.bin/rcs/ci/ci.c1165
-rw-r--r--gnu/usr.bin/rcs/co/Makefile8
-rw-r--r--gnu/usr.bin/rcs/co/co.1569
-rw-r--r--gnu/usr.bin/rcs/co/co.c769
-rw-r--r--gnu/usr.bin/rcs/doc/rcs.ms1524
-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.176
-rw-r--r--gnu/usr.bin/rcs/ident/ident.c214
-rw-r--r--gnu/usr.bin/rcs/lib/Makefile14
-rw-r--r--gnu/usr.bin/rcs/lib/conf.h495
-rw-r--r--gnu/usr.bin/rcs/lib/maketime.c344
-rw-r--r--gnu/usr.bin/rcs/lib/merger.c139
-rw-r--r--gnu/usr.bin/rcs/lib/partime.c639
-rw-r--r--gnu/usr.bin/rcs/lib/rcsbase.h677
-rw-r--r--gnu/usr.bin/rcs/lib/rcsedit.c1656
-rw-r--r--gnu/usr.bin/rcs/lib/rcsfcmp.c321
-rw-r--r--gnu/usr.bin/rcs/lib/rcsfnms.c1088
-rw-r--r--gnu/usr.bin/rcs/lib/rcsgen.c432
-rw-r--r--gnu/usr.bin/rcs/lib/rcskeep.c422
-rw-r--r--gnu/usr.bin/rcs/lib/rcskeys.c102
-rw-r--r--gnu/usr.bin/rcs/lib/rcslex.c1250
-rw-r--r--gnu/usr.bin/rcs/lib/rcsmap.c68
-rw-r--r--gnu/usr.bin/rcs/lib/rcsrev.c790
-rw-r--r--gnu/usr.bin/rcs/lib/rcssyn.c857
-rw-r--r--gnu/usr.bin/rcs/lib/rcsutil.c994
-rw-r--r--gnu/usr.bin/rcs/merge/Makefile8
-rw-r--r--gnu/usr.bin/rcs/merge/merge.1102
-rw-r--r--gnu/usr.bin/rcs/merge/merge.c97
-rw-r--r--gnu/usr.bin/rcs/rcs/Makefile11
-rw-r--r--gnu/usr.bin/rcs/rcs/rcs.1397
-rw-r--r--gnu/usr.bin/rcs/rcs/rcs.c1554
-rw-r--r--gnu/usr.bin/rcs/rcs/rcsfile.5224
-rw-r--r--gnu/usr.bin/rcs/rcs/rcsintro.1292
-rw-r--r--gnu/usr.bin/rcs/rcsclean/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rcsclean/rcsclean.1177
-rw-r--r--gnu/usr.bin/rcs/rcsclean/rcsclean.c297
-rw-r--r--gnu/usr.bin/rcs/rcsdiff/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rcsdiff/rcsdiff.1152
-rw-r--r--gnu/usr.bin/rcs/rcsdiff/rcsdiff.c422
-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.sh100
-rw-r--r--gnu/usr.bin/rcs/rcsmerge/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rcsmerge/rcsmerge.1140
-rw-r--r--gnu/usr.bin/rcs/rcsmerge/rcsmerge.c252
-rwxr-xr-xgnu/usr.bin/rcs/rcstest397
-rw-r--r--gnu/usr.bin/rcs/rlog/Makefile8
-rw-r--r--gnu/usr.bin/rcs/rlog/rlog.1260
-rw-r--r--gnu/usr.bin/rcs/rlog/rlog.c1204
-rw-r--r--gnu/usr.bin/sdiff/Makefile11
-rw-r--r--gnu/usr.bin/sort/COPYING339
-rw-r--r--gnu/usr.bin/sort/Makefile5
-rw-r--r--gnu/usr.bin/sort/error.c106
-rw-r--r--gnu/usr.bin/sort/sort.1218
-rw-r--r--gnu/usr.bin/sort/sort.c1774
-rw-r--r--gnu/usr.bin/sort/system.h168
-rw-r--r--gnu/usr.bin/tar/COPYING339
-rw-r--r--gnu/usr.bin/tar/ChangeLog1732
-rw-r--r--gnu/usr.bin/tar/Makefile15
-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.c1454
-rw-r--r--gnu/usr.bin/tar/diffarch.c759
-rw-r--r--gnu/usr.bin/tar/extract.c907
-rw-r--r--gnu/usr.bin/tar/fnmatch.c173
-rw-r--r--gnu/usr.bin/tar/fnmatch.h62
-rw-r--r--gnu/usr.bin/tar/getdate.y969
-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.c881
-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/regex.c4932
-rw-r--r--gnu/usr.bin/tar/regex.h490
-rw-r--r--gnu/usr.bin/tar/rmt.h98
-rw-r--r--gnu/usr.bin/tar/rtapelib.c582
-rw-r--r--gnu/usr.bin/tar/tar.c1504
-rw-r--r--gnu/usr.bin/tar/tar.h291
-rw-r--r--gnu/usr.bin/tar/update.c585
-rw-r--r--gnu/usr.bin/tar/version.c1
-rw-r--r--gnu/usr.bin/tar/y.tab.h18
711 files changed, 0 insertions, 319507 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 1919997..0000000
--- a/gnu/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# @(#)Makefile 5.33.1.1 (Berkeley) 5/6/91
-
-SUBDIR= bc cvs diff diff3 gas gawk gcc1 gcc2 gdb grep groff gzip \
- ld man patch pr rcs sdiff sort tar
-
-.include <bsd.subdir.mk>
diff --git a/gnu/Makefile.inc b/gnu/Makefile.inc
deleted file mode 100644
index 8eb90e8..0000000
--- a/gnu/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-# @(#)Makefile.inc 5.1 (Berkeley) 5/11/90
-
-BINDIR?= /usr/bin
-LIBDIR?= /usr/lib
diff --git a/gnu/games/chess/DOCUMENTATION/ARTICLE b/gnu/games/chess/DOCUMENTATION/ARTICLE
deleted file mode 100644
index b2ab331..0000000
--- a/gnu/games/chess/DOCUMENTATION/ARTICLE
+++ /dev/null
@@ -1,66 +0,0 @@
-[This article was reproduced from a GNU Bulletin.]
-
- GNU Chess
- by Stuart Cracraft
- copyright 1987 Stuart Cracraft
-
-
- GNU Chess is a communal chess program. Contributors donate their
-time and effort in order to make it a stronger, better, sleeker program.
-Contributions take many forms: interfaces to high-resolution displays,
-opening book treatises, speedups of the underlying algorithms, additions
-of extra heuristics. These contributions are then distributed to the
-large user-base so that all may enjoy the fruits of our labor. The
-original and continuing purpose of this project is to permanently end
-the rampant hoarding of computer chess software that has been the
-case for the past 20 years.
-
- Many people have contributed to GNU Chess. Their contributions have
-improved the program from being a patzer (weak program) to being a
-grandpatzer (decently strong program). In its growth since initial
-release, GNU Chess has gone from approximately class D to expert
-strength. It beats the Fidelity Excel commercial unit rather handily.
-
- GNU Chess's structure is a hybrid of the Shannon Type-A and
-Type-B methods. It conducts a full-width search to a fixed-depth
-and then continues with a quiescence search for many more ply.
-This quiescence search helps the program find positions which
-can be safely evaluated and which are not too turbulent. If
-a terminal position is too turbulent, the evaluation will be
-highly inaccurate. Additional searching by investigating series
-of captures, checks, and other potentially imbalance-producing
-moves is quite helpful.
-
- GNU Chess will sacrifice pieces in order to reach known winning
-endings. Also, it uses a trade-down bonus to encourage the stronger
-side to trade off certain types of pieces thus reaching a more
-simplified and therefore ostensibly "clearer" position.
-
- GNU Chess has certain types of knowledge regarding easier endgames.
-This allows it to play these endings somewhat better than might be
-expected.
-
- GNU Chess has time heuristics that it uses to improve its handling
-of time-controls and hasten its making of "obvious" moves.
-
- GNU Chess is interfaced to the SUN Windows and X Windows
-display protocols and can display its pieces in elaborate format,
-similar to chess diagrams.
-
- GNU Chess has an opening book which consists of many variations
-from MCO (Modern Chess Openings).
-
- For comparison purposes, GNU Chess running on a VAX 8650 is
-stronger than the famous Chess 4.5 running on a CDC 6400.
-
- We wish to acknowledge the contributions of the following
-individuals: (in alphabetical order) Jim Aspnes, Wayne Christopher,
-Steve Dougherty, David Goldberg, Richard Greenblatt, David Kittinger,
-Richard Stallman, John Stanback, and Ken Thompson.
-
- Contact information: The author may be reached by a variety of
-methods. Via U.S. mail: Stuart Cracraft, 5 Via Amistosa, Suite G,
-Rancho Santa Margarita, Ca. 92688 USA.
- By Internet: 'cracraft at wheaties.ai.mit.edu'
-The author may also be contacted via the Free Software Foundation, Inc.
-675 Massachusetts Ave.,Cambridge MA 02139.
diff --git a/gnu/games/chess/DOCUMENTATION/ARTICLE.2 b/gnu/games/chess/DOCUMENTATION/ARTICLE.2
deleted file mode 100644
index 031ae18..0000000
--- a/gnu/games/chess/DOCUMENTATION/ARTICLE.2
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
- GNU Chess: Experiences Learned
- with Communal Sharing
- by Stuart Cracraft
- (and contributors to the GNU Project)
-
-
-Limited sharing has characterized the computer chess community
-for the past two decades. Occasional research articles give hints
-and suggestions for useful features, but rarely reveal the real
-details of the critically important advances. We will here
-describe an effort underway (titled "GNU Chess") to create a more
-open and friendly environment of sharing.
-
-GNU Chess is part of Project GNU, a large-scale effort in which
-the philosophical goals are far-reaching. We will not go into any
-great depth about these goals as they relate to the larger pro-
-ject, because these are described elsewhere [1]. However, we will
-mention the basic issues and the changes we hope to encourage.
-
-The start of the GNU Chess project was a natural result of the
-experiences gleaned in writing a chess program. While the author
-was at a progressive academic location [2], he was able to con-
-ceive the idea of a communal chess program only after much heart-
-ache. During the period of writing the initial version (which
-has since undergone many improvements and whole revisions), it
-became clear that the best features and most useful hints, the
-very best of the heuristics, were hidden and difficult to find in
-the literature.
-
-Sprinkled across many books, research papers, magazine articles,
-accumulated in the community, during the past 25 years, there was
-literally a void of true, empirical programs. Locating usable
-programs was difficult. Many programs were the result of academic
-work in "ivory towers", and hence were inaccessible to the common
-man. Other programs were sequestered in research think-tanks. Na-
-turally, developers of commercial programs carefully guarded
-their source in order to protect their investment. On the other
-hand, a few chess program source listings had actually been pub-
-lished, but these were not really very strong, often written in a
-non-general language, and frequently more pedantic than practi-
-cal.
-
-The idea of a reasonably strong communal program solidified.
-When we refer to a communal program, we do not regard this as
-public-domain software. Rather, we refer to a program which is
-under the shared authority of a number of individuals, the prin-
-cipal contributors. These individuals have experienced and real-
-ized the positive results of a sharing community and the rapid
-improvements that come through contributing in such a community.
-Further, these individuals devote time and energy to coordinating
-the contributions of other individuals. While they exercise a
-certain editorial right, this is usually not exercised arbitrari-
-ly; instead, a discussion is often undertaken.
-
-Eventually, a working C program that played chess was available.
-The coordinating institution for Project GNU [3], accepted our
-suggestion of inclusion of a chess program in the GNU distribu-
-tion. Initial distribution of GNU Chess commenced in October of
-1986. Interest in the project increased rapidly.
-
-Contributions came in from many places and people. Interfaces to
-X-windows and SUN-windows were donated, thus allowing very fancy
-chess fonts on bit-mapped screens. Also, contributions involving
-large portions of opening books such as MCO and collections of
-master games were added to the distribution. Additionally,
-tree-search modifications and heuristics were provided, and occa-
-sionally even entire rewrites.
-
-The program advanced in strength by several USCF class intervals
-during a period of less than one year. During this time, many
-unusual features and enhancements were added to the program, usu-
-ally under the coordination of two or more people, with one work-
-ing in a distant-advisory capacity to the other. Frequently, gra-
-duate students would give up significant time from their thesis
-work to devote energy to contributing. Their corporate counter-
-parts would often give up project time to make their donation.
-
-Contributors would often enter the project in a very forceful way
-and then having made their contribution, learn the viability of
-communal sharing once others had stepped in and contributed to
-them, thus providing considerable reinforcement. Frequently, con-
-tributors would then go into "hibernation" for a long period of
-time, but most of them remained open to contributing and were
-helpful when asked to reprogram their particular contribution in
-a more recent version.
-
-GNU Chess has made great strides in relatively little time. It
-has run on many different hardware architectures and has been
-compiled by a number of C compilers [4]. A sampling of the com-
-puters on which the program has run is: National 32032, Vax
-11/750, 8550, 8600, 8650, Motorola 68020, CCI 5/32, CCI 6/32
-(tahoe), Cray XMP.
-
-It is our belief that GNU Chess will stimulate graduate research
-in computer chess theory and practice. When students are able to
-easily obtain a state-of-the-art program in order to test out
-their ideas, they will no longer need to reinvent the wheel. The
-students will be able to investigate their research areas much
-more thoroughly, because they will spend more time on the specif-
-ic research areas they are concerned about. Basically, GNU Chess
-"frees up" time in order to get on to more fundamental issues.
-
-We also feel that as other researchers gain trust in the GNU
-Chess project, they will be more likely to release their results
-directly and rapidly, through journal articles, or directly to
-the GNU project, and in fact become contributors and join the
-present list [5]. At the very least, a communal, ever-growing
-program will encourage the few "closeted" researchers to be some-
-what more open in their approach to disseminating advances.
-
-In whatever form it takes, the progress toward elaboration of
-machine chess is ongoing, and we hope that GNU chess will be
-helpful to the community. Copies of GNU Chess source and "book",
-as well as additional experimental code are available from the
-Free Software Foundation [3] or the author [6].
-
-
-[1] The GNU Manifesto, Richard Stallman, Free Software Foundation, Inc.
-
-[2] University of Southern California, Information Sciences Institute.
-
diff --git a/gnu/games/chess/DOCUMENTATION/CHANGES b/gnu/games/chess/DOCUMENTATION/CHANGES
deleted file mode 100644
index 9866075..0000000
--- a/gnu/games/chess/DOCUMENTATION/CHANGES
+++ /dev/null
@@ -1,362 +0,0 @@
- GNU CHESS HISTORY
- (#include "../version.h")
-
-August 1, 1989 -- Jay Scott
-He proofread the opening book and made
-corrections.
-
-June 21, 1989 -- Hes @log-se.sv
-He contributed new move generation routines (move.c move.h) to speedup
-move generation and the overall program, by about 15-30%
-
-June 9, 1989 -- Tim Radzy (unet!nplab4!radz@ames.arc.nasa.gov)
-He fixed a bug in xchess/board.c. In a post-game new-game situation,
-castling wouldn't be permitted under circumstances. Tim made
-it possible to castle again.
-
-May 12, 1989 -- Joe Garbarini (garbarini%kegger@circus.llnl.gov)
-Recommended changes to documentation vis a vis chesstool usage.
-
-May 5, 1989 -- Jouko Holopainen (jhol@tolsun.oulu.fi)
-Wrote code to support underpromotion.
-Changed interface to accept ECO/Informator style moves.
-
-April 30, 1989 -- Various GNU contributors
-setlinebuf() modification for xchess/chesstool.
-check for zero division in time printout.
-
-January 17, 1989 -- Anders Thulin
-Provided extensive addition to the opening book for his
-favorite opening the Vienna Game. This was drawn from ECO.
-
-November 23, 1988 -- Stuart Cracraft
-Installed new version of Xchess that is better debugged, works on
-the next version of X. Thanks to Wayne Christopher and Arturo Perez.
-
-August 28, 1988 -- Stuart Cracraft
-Removed a sacrifice line from the Giuoco Piano entry in the opening
-book; the program didn't seem to like the positions it got from this line.
-
-December 30, 1987 -- John Stanback
-Wrote a short blurb on the heuristics contained in GNU Chess. It resides
-in the subdirectory DOCUMENTATION as the file HEURISTICS.
-
-December 17, 1987 -- John Stanback
-Modified criteria for positional evaluation in quiescence search
-to include positions in which the estimated score lies within
-the alpha-beta window; fixed a bug in the king proximity to pawns heuristic;
-fixed a bug involving passed pawn heuristics;
-
-December 16, 1987 -- Stuart Cracraft
-Added automatic 'list' upon exit (both in display, non-display, and
-chesstool mode); command-line setting of tournament time controls
-bug fixed.
-
-December 14, 1987 -- John Stanback
-GNU defeated the commercial product 'Fidelity Excellence' 5.5-4.5 in
-a 10-game match. It was running at about 500 nodes per second (typical
-of its speed on a VAX 8650) and this would indicate its strength
-would be about USCF 1875-1900.
-
-December 4, 1987 -- John Stanback
-Man page added. Command line arguments now specify regular clock
-settings if so desired (useful for SUN players). Thinking
-on opponent's time is now disabled by default. Estimated
-rating is 1850 at 500 nodes per second.
-
-October 20, 1987 -- Stuart Cracraft
-Fixed GNU/SUN interaction. Chesstool and its features now
-seem to fully work.
-
-October 5, 1987 -- Ken Thompson
-GNU beat Belle (actually drew due to a bug, but
-Ken kept GNU playing through to the win) while
-running on a Cray XMP-48. In this 3-1 time handicap game
-Belle outsearched Cray GNU by 10-1 (even with the handicap).
-
-September 26, 1987 -- John Stanback at HP
-Hash table functioning. Thinking on opponent's
-time functioning.
-
-August 20, 1987 -- Mike Meyer at Berkeley
-Mike ran GNU Chess on a Cray 1 supercomputer.
-The system was very heavily loaded, so the
-program was not as speedy as with the Cray below.
-
-August 16, 1987 -- David Goldberg at SUN
-He added "chesstool" support so that this
-version of GNU Chess can run under the
-display manager "chesstool".
-
-August 15, 1987 -- John Stanback at HP
-Hash tables, more heuristics, a modified
-search which is more efficient. He also
-discovered a bug in the piece-exchanger. This
-would cause the program to exchange pieces suboptimally.
-With this fix, the program should play much
-more strongly.
-
-August 13, 1987 -- Ken Thompson at Bell Labs
-Ken ran GNU Chess on a Cray XMP supercomputer
- (among other processors). The program got
- about 3000-4000 chess positions per second
- which is comprable to today's fastest bit-slice
- commercial machines. Also, he had GNU Chess
- play two games against Belle.
-
-July 19, 1987 -- Jay Scott & John Stanback
- Many positional heuristics have been added.
-
-July 18, 1987 -- Stuart Cracraft
- Improvements have been made to the opening
- book. It is mostly an MCO book, containing
- major variations from many of the major openings
- and particularly in-depth on Sicilian.
-
-May 11, 1987 -- John Stanback at HP
- He donated his chess program, a fairly mature
- and strong program.
-
-May 1, 1987 -- Stuart Cracraft
- He added several bug fixes various people
- had reported. He also changed makemove() so that
- the calling syntax is makemove(movelist,index,board)
- rather than makemove(move,board). Having the latter
- tickled a bug in at least one manufacturer's C-compiler,
- so rather than write fancy code, we simplified it.
-
-April 25, 1987-- Jim Aspnes at MIT
-He added all sorts of useful capabilities,
-including positional evaluation in the tree
-search using a table-driven algorithm,
-modifying transposition table code in order
-to work properly, though it doesn't improve
-speed too much, checkmates/stalemates detected
-in the search, en passant captures allowed,
-detect repeated positions, iterative deepening,
-quicker quiescence search, tournament time controls,
-sqattacked sped up by a factor of 4, compile-time
-debugging options.
-
-January 2, 1987 -- Stuart Cracraft
- He added a few more Tal games to the collection.
-
-January 2, 1987 -- Jim Aspnes at MIT
- He contributed MCO variations for the Catalan,
- Queen's Indian, and Reti openings.
-
-December 29, 1986 -- Jim Aspnes at MIT
- He contributed all MCO variations of the Najdorf
- to the opening book. He also contributed a LISP
- macro (written in GNU Emacs Lisp) to convert
- xchess game formats to GNU Chess opening book
- format.
-
-December 14, 1986 -- Ken Thompson at Bell Labs
- He contributed almost 200 games by Tal to
- our collection of Tal-games, bringing the
- total number of Tal positions in the book
- to 10,692. Total book positions now 13,207.
- These reside in bookin, bookin.bdg, bookin.tal.
- Note that presently, only bookin and bookin.tal
- can be used. The new Tal positions came in a
- slightly different format, which we have chosen
- to adopt as our standard format. All book
- games in bookin and bookin.bdg will gradually
- change into the new standard format.
-
-December 11, 1986 -- Stuart Cracraft
- Added "averages" for node-count per move,
- cpu per move, rate per move to list_history
- and write_history.
- New version of Xchess installed.
- Started typing in Tal games into "bookin.tal".
- Added "total book positions" printout to "book"
- and "enter" statistics printout.
-
-December 10, 1986 -- Stuart Cracraft
- Implemented aspiration search in normal
- alpha-beta search. Speedups of 3% to 40%
- have been noticed in most positions.
- Occasionally a slower search will result,
- but it is thought these are worth the
- usual speedups.
-
-December 9, 1986 -- Stuart Cracraft
- Fixed minor bug in write_history()
- Added another Tal game, 2nd game of 1st world
- championship match with Botvinnik, a Benoni.
-
-December 9, 1986 -- Stuart Cracraft
- Enhanced parallelism. All parallel processors
- now communicate via a shared data file and
- are kept running (in idle loops watching the
- shared data file). This saves us a few seconds
- on each move since the 'rsh' need not be invoked
- more than once (at the beginning). Since the
- shared data file is now implemented, we will
- next work towards a "parallel anarchy" in which
- any processor can use any other processor in
- order to reduce its search. The current scheme
- with the program being only as fast as its slowest
- processor, is quite inefficient.
-
-December 1, 1986 -- Jim Aspnes at MIT
- Added a couple of Master games from
- Modern Chess Openings 12 (a Fischer game,
- and a Matanovic game).
-
-November 30, 1986 -- Stuart Cracraft
- Added parallelism. Can now handle multiple
- processors (sharing same disk). Later we will
- add the capability to use processors not sharing
- the same disk. Modified README and MAN-PAGE.
-
-November 26, 1986 -- Stuart Cracraft
- Fixed a few bugs in book-mailing mechanism.
- Fixed a bug regarding situations where only
- one move is available.
- Fixed a bug in read_history() that caused
- Black queenside castles to be mishandled.
-
-November 25, 1986 -- Stuart Cracraft
- Added two pawn heuristics. Reward pawns moving into
- a phalanx of pawns. A phalanx is two or more
- horizontally-connected pawns. Likewise, penalize
- pawns leaving a phalanx of pawns. The penalty for
- leaving is a little more than the reward for
- entering.
-
-November 24, 1986 -- Stuart Cracraft
- A user reported an unbelievable bug. Investigation
- of this bug led to the discovery that GNU Chess was
- not picking the move judged best by the tree search
- in all cases. This resulted in the bug showing
- itself which further showed that the program was
- selecting an inferior move. This may result in an
- improvement to the program's play.
-
-November 24, 1986 -- Stuart Cracraft
- Added two heuristics. Penalize king moves if
- the king hasn't castled yet. Also, penalize pawn
- moves which produce doubled pawns. Should
- probably have something for isolated pawns
- too.
-
-November 23, 1986 -- Wayne Christopher at Berkeley
- New version of X chess display front-end.
- Fixed bugs include multiple pieces, runs
- on SUNS & Bobcats, loads saved games.
-
-November 23, 1986 -- Stuart Cracraft
- Cleaned up some minor bugs regarding history.
- Added "Illegal command" error message at Wayne's
- request.
-
-November 22, 1986 -- David Goldberg at SUN Microsystems
- He complained that GNU Chess was memory-hungry.
- A few minor modifications to hash.c reduced
- uninitialized data space 87% and text space
- 12%. This should make it easier for GNU Chess
- to run on small computers.
-
-November 22, 1986 -- Stuart Cracraft
- "read" command was working, but needed
- additional tweaking so that history
- array would be printed by list_history().
-
-November 19, 1986 -- Stuart Cracraft
- Added "read" command which reads a history
- file (game listing) and restores the board
- to as if the person was still playing that.
- particular game. Generally cleaned up
- history mechanism, made it more orthogonal.
- Revised README. Added doc to MAN-PAGE.
-
-November 16, 1986 -- Stuart Cracraft
- More opening book bugs found and fixed.
- Added capability to accept abbreviated-algebraic notation
- for entering "book" games from files.
- Added approximately 2500 new positions to
- opening book from games involving the
- opening called Blackmar-Diemer Gambit,
- a hoary line developed by Diemer in
- Germany years ago.
-
-November 15, 1986 -- Wayne Christopher at Berkeley
- He modified the move generator, resulting in
- a 28% speedup.
-
-November 14, 1986 -- Stuart Cracraft
- He documented a lot of the GNU Chess modules
- with brief comments for each function. More
- extensive internal documentation may go in
- later.
-
-November 14, 1986 -- Wayne Christopher at Berkeley
- He created the Xchess interface for
- GNU Chess to have windowing with X windows.
-
-November 14, 1986 -- Stuart Cracraft
- He added a "randomization" feature to
- the opening book. This will cause the
- program to select randomly from alternate
- variations whenever -DBEST is removed
- from Makefile's CFLAGS. If this is not
- removed, the opening play selects the
- first move found in the book as it appears
- "in order" in the human-readable book.
-
-November 14, 1986 -- David Goldberg at SUN Microsystems
- He responded to a query about dbm(3) which
- eventually resulted in the fixing of a subtle
- bug in the book code which was causing the
- program to sometimes hash to the incorrect
- address and thereby produce a book move which
- didn't even exist in the book. Thanks David!
-
-November 14, 1986 -- Stuart Cracraft
- He added the "oboard" routine in util.c. This
- is the reverse of the already extant "iboard"
- (same module). These two routines translate
- between GNU Chess internal format and
- Forsythe notation.
-
-November 10, 1986 -- Stuart Cracraft
- He added the "enter" command. This causes
- the current game to be entered in the book.
- Then, GNU Chess tries to mail this new entry
- to the book maintainers (for inclusion in
- the master copy of the book).
-
-November 9, 1986 -- Stuart Cracraft
-He added code for an opening book. MAN-PAGE
-and README were modified accordingly.
-
-November 8, 1986 -- Stuart Cracraft
-Checks and mates are now noticed at ply-1.
-This is a more complete fix to the Oct 31 fix.
-
-October 31, 1986 -- Stuart Cracraft
-First attempt at fix to bug which causes
-program to check human's king when program
-itself is in check.
-
-October 31, 1986 -- Mly at MIT
-Reported a bug which caused program to crash
-when an illegal human move was played. Fixed.
-Also, program was unable to play as White. Fixed.
-
-October 22, 1986 -- Stuart Cracraft
-Pps now rewards moves which liberate bishops.
-
-October 19, 1986 -- Stuart Cracraft
-Added bitmapper routines to distribution.
-Added version notice.
-
-October 19, 1986 -- David Goldberg at SUN Microsystems
-Interfaced GNU Chess with SUN's chesstool.
-
-October 18, 1986 -- Initial release date.
-
-
diff --git a/gnu/games/chess/DOCUMENTATION/COPYING b/gnu/games/chess/DOCUMENTATION/COPYING
deleted file mode 100644
index 17847b7..0000000
--- a/gnu/games/chess/DOCUMENTATION/COPYING
+++ /dev/null
@@ -1,123 +0,0 @@
- GNU CHESS GENERAL PUBLIC LICENSE
-
- Copyright (C) 1986,1987 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license, but changing it is not allowed.
-
- The license agreements of most software companies keep you at the
-mercy of those companies. By contrast, our general public license is
-intended to give everyone the right to share GNU Chess. To make
-sure that you get the rights we want you to have, we need to make
-restrictions that forbid anyone to deny you these rights or to ask you
-to surrender the rights. Hence this license agreement.
-
- Specifically, we want to make sure that you have the right to give
-away copies of GNU Chess, that you receive source code or else can get it
-if you want it, that you can change GNU Chess or use pieces of it 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 GNU Chess, 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 GNU Chess. If GNU Chess is
-modified by someone else and passed on, we want its 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.
-
- Therefore the Free Software Foundation, Inc. makes the following
-terms which say what you must do to be allowed to distribute or change
-GNU Chess.
-
- COPYING POLICIES
-
- 1. You may copy and distribute verbatim copies of GNU Chess source
-code as you receive it, in any medium, provided that you conspicuously
-and appropriately publish on each file a valid copyright notice
-"Copyright (C) 1986,1987 Free Software Foundation, Inc.", containing the
-year of last change for the file in question; keep intact the notices
-on all files that refer to this License Agreement and to the absence
-of any warranty; and give any other recipients of the GNU Chess
-program a copy of this License Agreement along with the program.
-
- 2. You may modify your copy or copies of GNU Chess source code 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
- who last changed such 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 or is a derivative of GNU Chess
- or any part thereof, to be freely distributed
- and licensed to all third parties on terms identical to those
- contained in this License Agreement (except that you may choose
- to grant more extensive warranty protection to third parties,
- at your option).
-
- c) if the modified program serves as a text editor, cause it
- when started running in the simplest and usual way, to print
- an announcement including a valid copyright notice ("Copyright
- (C)", the year of authorship, and all copyright owners' names),
- saying 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 Agreement.
-
- 3. You may copy and distribute GNU Chess or any portion of it in
-compiled, executable or object code form under the terms of Paragraphs
-1 and 2 above provided that you do the following:
-
- a) cause each such copy of GNU Chess to be accompanied by the
- corresponding machine-readable source code; or
-
- b) cause each such copy of GNU Chess to be accompanied by a
- written offer, with no time limit, to give any third party
- free (except for a nominal shipping charge) machine readable
- copy of the corresponding source code; or
-
- c) in the case of a recipient of GNU Chess in compiled, executable
- or object code form (without the corresponding source code) you
- shall cause copies you distribute to be accompanied by a copy
- of the written offer of source code which you received along
- with the copy of GNU Chess.
-
- 4. You may not copy, sublicense, distribute or transfer GNU Chess
-except as expressly provided under this License Agreement. Any attempt
-otherwise to copy, sublicense, distribute or transfer GNU Chess is void and
-your rights to use GNU Chess under this License agreement shall be
-automatically terminated. However, parties who have received computer
-software programs from you with this License Agreement will not have
-their licenses terminated so long as such parties remain in full compliance.
-
-Your comments and suggestions about our licensing policies and our
-software are welcome! Please contact the Free Software Foundation, Inc.,
-1000 Mass Ave, Cambridge, MA 02138, or call (617) 876-3296.
-
- NO WARRANTY
-
- BECAUSE GNU CHESS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
-NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
-WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
-AND/OR OTHER PARTIES PROVIDE GNU CHESS "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 GNU CHESS PROGRAM PROVE DEFECTIVE,
-YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FREE SOFTWARE
-FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND
-REDISTRIBUTE GNU CHESS AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
-DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
-INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
-INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
-BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
-FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
-FREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
-OTHER PARTY.
-======================================================================
diff --git a/gnu/games/chess/DOCUMENTATION/GENERAL b/gnu/games/chess/DOCUMENTATION/GENERAL
deleted file mode 100644
index aafb7ed..0000000
--- a/gnu/games/chess/DOCUMENTATION/GENERAL
+++ /dev/null
@@ -1,34 +0,0 @@
- GNU Chess
-
-Copyright (C) 1987 Stuart Cracraft
- (Copying permission notice at the end.)
-
-GNU Chess is your program (as long as you follow the copyright and
-licensing rules listed in the file COPYING). Your contributioinspire current and future software
-developers.
-
-This document
--------------
-This document is not meant to be a an introduction to computer chess.
-The following books are excellent introductions and treatises.
-They are listed in order of difficulty:
-
- Computer Chess (2nd edition), by David Welsh and Boris Bazcynski
- The Joy of Computer Chess, by David Levy
- Chess Skill in Man and Machine (2nd edition), by Peter Frey
-
-
-Current Distribution
---------------------
-The most recent distribution of GNU Chess contains the following
-main-level files and directories:
-
- Filename Purpose
- ------------------------------------------------------
- README Pointer to main README below.
- gnuchess.c Most recent version of GNU Chess
- nondsp.c Non-display interface, and chesstool/xchess interface
- uxdsp.c Unix (curses) display interface
- ansidsp.c ANSI display interface
- gnuchess.book Most recent version of opening book
-
diff --git a/gnu/games/chess/DOCUMENTATION/HEURISTICS b/gnu/games/chess/DOCUMENTATION/HEURISTICS
deleted file mode 100644
index 254b344..0000000
--- a/gnu/games/chess/DOCUMENTATION/HEURISTICS
+++ /dev/null
@@ -1,122 +0,0 @@
-This file contains a description of GNU's heuristics.
- Copyright (C) 1986, 1987 Free Software Foundation, Inc.
-
-This file is part of CHESS.
-
-CHESS 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 CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-CHESS, but only under the conditions described in the
-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with CHESS 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. */
-
- -- requested by main author
-Heuristic descriptions for CHESS.
-
-Revision: 12-16-87
-
-Copyright (c) 1987 by John Stanback
-
- Here is a brief description of the heuristics used in the positional
- evaluator of the GNU Chess program. Many heuristics are functions of the
- stage of the game which is based on the total non-pawn material remaining
- for both sides.
-
-
-PAWNS
- The material value of a pawn is 100 points. Isolated pawns get a
- penalty depending on which file they occupy:
- (12,14,16,20,20,16,14,12) for files (a..h).
- Doubled pawns (which are not also isolated) get a penalty of 12
- points. Backward pawns (defined simply as not being defended by a
- pawn with the square in front also not defended by a a pawn) are
- penalized 6 points. A 4 point penalty is also invoked for each attack
- by the opponent to a backward pawn and for a backward pawn on a
- half-open file. Pawn Advancement in the centre is given a bonus of
- about 4 points per rank in the opening increasing to about 8 points
- per rank in the ending. Advancement on the edges is given a lower
- bonus. Pawns on the e and d files and on the 2nd rank are given a 10
- point penalty. An additional penalty of 15 points is invoked if these
- pawns are also blocked. Pawns within 2 squares of the king are given
- a 10 point bonus. Passed pawns are given a bonus for increasing rank
- which is a function of stage of the game and of whether the opponent
- blocks or attacks one or more squares in front of the pawn or if the
- opponents king is in the square of the pawn. This bonus ranges from
- about 15 points for a pawn on the second rank up to about 300 points
- for a passed pawn on the 7th rank which can't be stopped from
- queening.
-
-
-KNIGHTS
- The material value of a knight is 330 points. The main heuristic for
- knights is a bonus for proximity to the centre. This varies from 0
- points in the corners to 30 points in the centre. Knights are also
- given a bonus for being within 2 squares of each enemy piece. This
- bonus is a function of the stage of the game, equalling 4 points in
- the end game. A penalty of 1 point per square is given for distance
- from either king. A bonus of up to 8 points (depends on stage) is
- given for knights which can't be driven away by enemy pawns.
-
-
-BISHOPS
- The material value of a bishop is 330 points. Bishops are given a
- bonus as material falls off the board equalling 10 points in the end
- game. Bishops get a bonus for mobility and Xray mobility thru pieces
- but not pawns. This bonus ranges from -4 points for a totally blocked
- bishop up to 18 points for a bishop attacking 12 or more squares.
- Xray attacks on an enemy R,Q,K or any undefended piece are given an 8
- point bonus. Bishops are given a bonus of 14 points if they lie on
- the edge of the board up to 22 points if the lie in the centre. A
- bishop is given a bonus of up to 5 points for each attack to a square
- adjacent to the enemy king.
-
-
-ROOKS
- The material value of a rook is 520 points. Rook mobility is handled
- similiarly to bishops with a bonus of 0 points if blocked up to 20
- points if attacking 12 squares or more. A bonus of 8 points for Xray
- attacks is handled as it is for bishops. Rooks are given a bonus of
- 10 points for occupying a file with no friendly pawns and a bonus of
- 4 points if no enemy pawns lie on that file. After the opening Rooks
- are penalized slightly depending on "taxicab" distance to the enemy
- king.
-
-
-QUEENS
- The material value of a queen is 980 points. The only heuristic for a
- queen is that after the opening it is penalized slightly for
- "taxicab" distance to the enemy king.
-
-
-KINGS
- Kings are given a penalty for proximity to the centre in the opening
- and a bonus for proximity to the centre in the endgame. The penalty
- is about 24 points for being in the centre in the opening with a
- bonus of about 36 points for being in the centre in the endgame.
- Kings are penalized for lying on an open or half-open file or if the
- adjacent file closest to the corner is open or half-open. This
- penalty is up to 23 points in the opening and goes to zero in the end
- game. The King is penalized up to 8 points if there are no pawns
- immediately adjacent. A penalty is invoked depending on the number of
- "safe" checks available by the opponent. This penalty ranges from 6
- points for one such check to 50 points for 4 or more. Depending on
- game stage, Kings are given up to 10 points for castling and a
- penalty of up to 40 points for moving before castling.
-
-
-SPECIAL
- If more than one piece is "hung" (attacked and not defended or
- attacked by an enemy piece of lower value) an extra penalty of 10
- points is invoked for that side and the search may be extended one
- ply. Pinned or trapped pieces are treated similarly. A special mating
- routine is used if one side has only a king and the other has mating
- material.
-
diff --git a/gnu/games/chess/DOCUMENTATION/MAN-PAGE b/gnu/games/chess/DOCUMENTATION/MAN-PAGE
deleted file mode 100644
index bbf0aa4..0000000
--- a/gnu/games/chess/DOCUMENTATION/MAN-PAGE
+++ /dev/null
@@ -1,161 +0,0 @@
-.TH Chess GNU
-.SH NAME
-Chess \- GNU Chess
-.SH SYNOPSIS
-.B Chess
-[
-.B arg1 arg2
-]
-.SH DESCRIPTION
-.I Chess
-plays a game of chess against the user or it plays against itself.
-.PP
-.I Chess
-has a simple alpha-numeric board display or it can be compiled for
-use with the CHESSTOOL program on a SUN workstation.
-The program gets its opening moves from the file gnuchess.book which
-should be located in the same directory as gnuchess.
-To invoke the prgram, type 'gnuchess' or type 'chesstool gnuchess'
-on a SUN workstation where 'CHESSTOOL' is installed.
-The 'gnuchess' command can be followed by up to 2 command line arguments.
-If one argument is given it determines the programs search time in
-seconds. If two arguments are given, they will be used to set tournament
-time controls with the first argument being the number of moves and the second
-being the total clock time in minutes. Thus, entering 'chess 60 5' will set
-the clocks for 5 minutes (300 seconds) for the first 60 moves.
-If no argument is given the program will prompt the user for level of
-play.
-For use with CHESSTOOL, see the documentation on that program.
-.PP
-Once
-.I Chess
-is invoked, the program will display the board and prompt the user
-for a move. To enter a move, use the notation 'e2e4' where the first
-letter-number pair indicates the origination square
-and the second letter-number pair indicates the destination square.
-An alternative is to use the notation 'nf3' where
-the first letter indicates the piece type (p,n,b,r,q,k).
-To castle, type the origin and destination squares
-of the king just as you would do for a regular move, or type
-"o-o" for kingside castling and "o-o-o" for queenside.
-.SH COMMANDS
-.PP
-In addition to legal moves, the following commands are available as responses.
-.PP
-.I beep
--- causes the program to beep after each move.
-.PP
-.I bd
--- updates the current board position on the display.
-.PP
-.I book
--- turns off use of the opening library.
-.PP
-.I both
--- causes the computer to play both sides of a chess game.
-.PP
-.I black
--- causes the computer to take the black pieces with the move
-and begin searching.
-.PP
-.I level
--- allows the user to set time controls such as
-60 moves in 5 minutes etc. In tournament mode, the program will
-vary the time it takes for each
-move depending on the situation. If easy mode is disabled (using
-the 'easy' command), the program
-will often respond with its move immediately, saving time on
-its clock for use later on.
-.PP
-.I depth
--- allows the user to change the
-search depth of the program. The maximum depth is 29 ply.
-Normally the depth is set to 29 and the computer terminates
-its search based on elapsed time rather than depth.
-Using the depth command allows setting depth to say
-4 ply and setting response time to a large number such as
-9999 seconds. The program will then search until all moves
-have been examined to a depth of 4 ply (with extensions up
-to 11 additional ply for sequences of checks and captures).
-.PP
-.I easy
--- toggles easy mode (thinking on opponents time)
-on and off. The default is easy mode ON. If easy mode is disabled,
-the user must enter a 'break' or '^C' to get the programs
-attention before entering each move.
-.PP
-.I edit
--- allows the user to set up a board position.
-In this mode, the '#' command will clear the board, the 'c'
-command will toggle piece color, and the '.' command will exit
-setup mode. Pieces are entered by typing a letter (p,n,b,r,q,k) for
-the piece followed by the coordinate. For example "pb3" would
-place a pawn on square b3.
-.PP
-.I force
--- allows the user to enter moves for both
-sides. To get the program to play after a sequence of moves
-has been entered use the 'white' or 'black' commands.
-.PP
-.I get
--- retrieves a game from disk. The program will
-prompt the user for a file name.
-.PP
-.I help
--- displays a short description of the commands.
-.PP
-.I hint
--- causes the program to supply the user with
-its predicted move.
-.PP
-.I list
--- writes the game moves and some statistics
-on search depth, nodes, and time to the file 'chess.lst'.
-.PP
-.I new
--- starts a new game.
-.PP
-.I post
--- causes the program to display the principle
-variation and the score during the search. A score of
-100 is equivalent to a 1 pawn advantage for the computer.
-.PP
-.I random
--- causes the program to randomize its move
-selection slightly.
-.PP
-.I reverse
--- causes the board display to be reversed. That
-is, the white pieces will now appear at the top of the board.
-.PP
-.I quit
--- exits the game.
-.PP
-.I save
--- saves a game to disk. The program will prompt
-the user for a file name.
-.PP
-.I switch
--- causes the program to switch places with
-the opponent and begin searching.
-.PP
-.I undo
--- undoes the last move whether it was the computer's
-or the human's. You may also type "remove". This is equivalent
-to two "undo's" (e.g. retract one move for each side).
-.PP
-.I white
--- causes the computer to take the white pieces
-with the move and begin searching.
-.SH BUGS
-.PP
-Pawn promotion to pieces other than a queen is not allowed.
-En-Passant does not work properly with CHESSTOOOL.
-The transposition table may not work properly in some
-positions so the default is to turn this off.
-.fi
-.SH SEE ALSO
-.nf
-chesstool(6)
-.fi
-
diff --git a/gnu/games/chess/Makefile b/gnu/games/chess/Makefile
deleted file mode 100644
index 7a084cb..0000000
--- a/gnu/games/chess/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# @(#)Makefile 5.4 (Berkeley) 5/11/90
-
-PROG= chess
-SRCS= gnuchess.c uxdsp.c move.c
-CFLAGS+=-DNEWMOVE=12
-MAN6= chess.6
-DPADD= ${LIBCURSES} ${LIBTERM}
-LDADD= -lcurses -ltermlib
-HIDEGAME=hidegame
-
-beforeinstall:
- install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/gnuchess.book \
- ${DESTDIR}/usr/share/games
-
-.include <bsd.prog.mk>
diff --git a/gnu/games/chess/Xchess/COPYING b/gnu/games/chess/Xchess/COPYING
deleted file mode 100644
index 5905c32..0000000
--- a/gnu/games/chess/Xchess/COPYING
+++ /dev/null
@@ -1,124 +0,0 @@
-
- GNU X-CHESS GENERAL PUBLIC LICENSE
-
- Copyright (C) 1986 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license, but changing it is not allowed.
-
- The license agreements of most software companies keep you at the
-mercy of those companies. By contrast, our general public license is
-intended to give everyone the right to share GNU X-Chess. To make
-sure that you get the rights we want you to have, we need to make
-restrictions that forbid anyone to deny you these rights or to ask you
-to surrender the rights. Hence this license agreement.
-
- Specifically, we want to make sure that you have the right to give
-away copies of GNU X-Chess, that you receive source code or else can get it
-if you want it, that you can change GNU X-Chess or use pieces of it 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 GNU X-Chess, 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 GNU X-Chess. If GNU X-Chess is
-modified by someone else and passed on, we want its 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.
-
- Therefore the Free Software Foundation, Inc. makes the following
-terms which say what you must do to be allowed to distribute or change
-GNU X-Chess.
-
- COPYING POLICIES
-
- 1. You may copy and distribute verbatim copies of GNU X-Chess source
-code as you receive it, in any medium, provided that you conspicuously
-and appropriately publish on each file a valid copyright notice
-"Copyright (C) 1986 Free Software Foundation, Inc.", containing the
-year of last change for the file in question; keep intact the notices
-on all files that refer to this License Agreement and to the absence
-of any warranty; and give any other recipients of the GNU X-Chess
-program a copy of this License Agreement along with the program.
-
- 2. You may modify your copy or copies of GNU X-Chess source code 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
- who last changed such 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 or is a derivative of GNU X-Chess
- or any part thereof, to be freely distributed
- and licensed to all third parties on terms identical to those
- contained in this License Agreement (except that you may choose
- to grant more extensive warranty protection to third parties,
- at your option).
-
- c) if the modified program serves as a text editor, cause it
- when started running in the simplest and usual way, to print
- an announcement including a valid copyright notice ("Copyright
- (C)", the year of authorship, and all copyright owners' names),
- saying 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 Agreement.
-
- 3. You may copy and distribute GNU X-Chess or any portion of it in
-compiled, executable or object code form under the terms of Paragraphs
-1 and 2 above provided that you do the following:
-
- a) cause each such copy of GNU X-Chess to be accompanied by the
- corresponding machine-readable source code; or
-
- b) cause each such copy of GNU X-Chess to be accompanied by a
- written offer, with no time limit, to give any third party
- free (except for a nominal shipping charge) machine readable
- copy of the corresponding source code; or
-
- c) in the case of a recipient of GNU X-Chess in compiled, executable
- or object code form (without the corresponding source code) you
- shall cause copies you distribute to be accompanied by a copy
- of the written offer of source code which you received along
- with the copy of GNU X-Chess.
-
- 4. You may not copy, sublicense, distribute or transfer GNU X-Chess
-except as expressly provided under this License Agreement. Any attempt
-otherwise to copy, sublicense, distribute or transfer GNU X-Chess is void and
-your rights to use GNU X-Chess under this License agreement shall be
-automatically terminated. However, parties who have received computer
-software programs from you with this License Agreement will not have
-their licenses terminated so long as such parties remain in full compliance.
-
-Your comments and suggestions about our licensing policies and our
-software are welcome! Please contact the Free Software Foundation, Inc.,
-1000 Mass Ave, Cambridge, MA 02138, or call (617) 876-3296.
-
- NO WARRANTY
-
- BECAUSE GNU X-CHESS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
-NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
-WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
-AND/OR OTHER PARTIES PROVIDE GNU X-CHESS "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 GNU X-CHESS PROGRAM PROVE DEFECTIVE,
-YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FREE SOFTWARE
-FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND
-REDISTRIBUTE GNU X-CHESS AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
-DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
-INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
-INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
-BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
-FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
-FREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
-OTHER PARTY.
-======================================================================
diff --git a/gnu/games/chess/Xchess/Makefile b/gnu/games/chess/Xchess/Makefile
deleted file mode 100644
index c6afd8f..0000000
--- a/gnu/games/chess/Xchess/Makefile
+++ /dev/null
@@ -1,136 +0,0 @@
-# RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:09:19 $
-# $Source: /users/faustus/xchess/RCS/Makefile,v $
-# Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
-#
-# Makefile for xchess.
-
-#CC = cc -O -m68010 -L/pub.MC68010/lib -L/usr.MC68010/lib
-CC = cc -O
-
-CFILES =\
- board.c\
- button.c\
- clock.c\
- control.c\
- jail.c\
- message.c\
- parse.c\
- popup.c\
- program.c\
- record.c\
- std.c\
- valid.c\
- window.c\
- XCircle.c
-
-COBJS =\
- board.o\
- button.o\
- clock.o\
- control.o\
- jail.o\
- message.o\
- parse.o\
- popup.o\
- program.o\
- record.o\
- std.o\
- valid.o\
- window.o\
- XCircle.o
-
-HFILES =\
- std.h\
- xchess.h
-
-SOURCE = $(CFILES)
-
-ALLFILES = $(SOURCE) $(HFILES)
-
-INCLUDE = -I.
-
-DEFINES = -DDEF_PROGRAM=\"gnuchess\"
-
-CFLAGS = $(DEFINES) $(INCLUDE)
-LINTFLAGS = -u -z -lc -DLINT $(DEFINES) $(INCLUDE)
-LINTLIB = ../lib/llib-lX.ln
-#LDFLAGS = -L/usr2/X/lib -z -lX -lm
-LDFLAGS = -loldX -lX11 -z -lX -lm
-GPLDFLAGS = -z -loldX -lX11 -lXMenu_p -lX -lm_p -g -pg
-
-.c.o: $*.c
- $(CC) $(CFLAGS) -c $*.c
-.s.o: $*.s
- $(CC) $(CFLAGS) -c $*.s
-
-all: xchess scrollText.o
- @echo "All done."
-
-everything: all tags depend lint wc
- @echo "All done."
-
-xchess: xchess.o $(COBJS) scrollText.o
- $(CC) -o xchess xchess.o $(COBJS) scrollText.o \
- $(LDFLAGS)
-
-scrollText.o: scrollText.h scrollText.c
-
-gpxchess: xchess.o $(COBJS)
- $(CC) -o gpxchess xchess.o $(COBJS) scrollText/libScroll.a \
- $(GPLDFLAGS)
-
-lint: $(SOURCE)
- lint $(LINTFLAGS) $(SOURCE) $(LINTLIB) | \
- grep -v "multiply declared"
-
-qgrind: $(ALLFILES)
- qgrind -lc $(ALLFILES)
-
-vgrind: $(ALLFILES)
- vgrind -lc $(ALLFILES)
-
-opt: all
-
-reopt: all
-
-install: all
-
-source: $(SOURCE)
-
-tags: $(ALLFILES)
- ctags -w -t *.c *.h > /dev/null 2>&1
-
-wc: $(ALLFILES)
- @wc $(ALLFILES)
-
-print: $(ALLFILES)
- @pr $(ALLFILES)
-
-clean:
- rm -f *.o *.a *.out xchess tags foo tmp
-
-tar:
- tar -cf xchess.tar Makefile *.h *.c *.bitmap *.icon *.cur *.1\
- scrollText/Makefile scrollText/*.h scrollText/*.c scrollText/*.1\
- scrollText/*.3
-
-$(ALLFILES):
- co $@
-
-depend: $(SOURCE)
- cc -M $(CFLAGS) $(CFILES) > makedep
- echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
- echo '$$r makedep' >>eddep
- echo 'w' >>eddep
- ed - Makefile < eddep
- rm eddep makedep
- echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
- echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
- echo '# see make depend above' >> Makefile
-
-#-----------------------------------------------------------------
-# DO NOT DELETE THIS LINE -- make depend uses it
-# DEPENDENCIES MUST END AT END OF FILE
-
-xchess.o $(COBJS): $(HFILES)
-
diff --git a/gnu/games/chess/Xchess/ScrollText b/gnu/games/chess/Xchess/ScrollText
deleted file mode 100644
index 782a54f..0000000
--- a/gnu/games/chess/Xchess/ScrollText
+++ /dev/null
@@ -1,34 +0,0 @@
-Subject: File: scrollText.h
-
-/*
- * Scrollable Text Window Header File
- *
- * David Harrison
- * University of California, Berkeley
- * 1986
- *
- * This file contains definitions for a scrollable text window
- * with scroll bar support.
- */
-
-int TxtGrab();
- /* Take hold of a previously created window */
-
-#define TXT_NO_COLOR -1
-
-int TxtAddFont();
- /* Loads a new font for use later */
-int TxtWinP();
- /* Returns non-zero value if the window is text window */
-int TxtClear();
- /* Clears text window and resets text buffer */
-
-int TxtWriteStr();
- /* Writes a string to window with immediate update */
-int TxtJamStr();
- /* Write a string without causing update to screen */
-
-int TxtRepaint();
- /* Repaints entire scrollable text window */
-int TxtFilter();
- /* Handles events related to text window */
diff --git a/gnu/games/chess/Xchess/XCircle.c b/gnu/games/chess/Xchess/XCircle.c
deleted file mode 100644
index d2144bc..0000000
--- a/gnu/games/chess/Xchess/XCircle.c
+++ /dev/null
@@ -1,162 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:17:04 $
- * $Source: /users/faustus/xchess/RCS/XCircle.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- */
-
-#include <stdio.h>
-#include <X11/Xlib.h>
-#include <X11/X10.h>
-#include <math.h>
-
-#define PI 3.1415926535897932384
-
-#define MAXVERTS 1000
-
-void
-XCircle(win, x, y, rad, start, end, width, height, pixel, func, planes)
- Window win;
- int x, y, rad;
- double start, end;
- int pixel;
- int width, height;
- int func, planes;
-{
- Vertex verts[MAXVERTS];
- double xp, yp, ang;
- int lx, ly, xpt, ypt, i;
- double gradincr = 2 / (double) rad;
- int bk = 0;
-
- while (end >= PI * 2)
- end -= PI * 2;
- while (start >= PI * 2)
- start -= PI * 2;
- while (end < 0)
- end += PI * 2;
- while (start < 0)
- start += PI * 2;
- if (end == start) {
- if (end < gradincr)
- end = end + PI * 2 - gradincr / 2;
- else
- end -= gradincr / 2;
- }
- for (ang = start, i = 0; i < MAXVERTS; ) {
-
- xp = x + rad * cos(ang);
- yp = y + rad * sin(ang);
-
- xpt = xp;
- ypt = yp;
-
- if (!i || (lx != xpt) || (ly != ypt)) {
- verts[i].x = xpt;
- verts[i].y = ypt;
- verts[i].flags = 0;
- i++;
- }
- lx = xpt;
- ly = ypt;
- if (bk)
- break;
- if (((ang < end) && (ang + gradincr > end)) || ((end < start)
- && (ang + gradincr > 2 * PI)
- && (ang + gradincr - 2 * PI > end))) {
- ang = end;
- bk = 1;
- } else if (ang == end) {
- break;
- } else {
- ang += gradincr;
- }
- if (ang >= PI * 2)
- ang -= PI * 2;
- }
-
- /* Now draw the thing.. */
- XDraw(win, verts, i, width, height, pixel, func, planes);
-
- return;
-}
-
-#ifdef notdef VertexCurved is screwed up
-
-void
-XCircle(win, x, y, rad, start, end, width, height, pixel, func, planes)
- Window win;
- int x, y, rad;
- double start, end;
- int pixel;
- int width, height;
- int func, planes;
-{
- Vertex verts[7];
- int i, j, sv, ev;
- int dp = 0;
-
- for (i = j = 0 ; i < 4; i++) {
- verts[j].x = x + rad * cos((double) (PI * i / 2));
- verts[j].y = y + rad * sin((double) (PI * i / 2));
- verts[j].flags = VertexCurved;
- if ((start >= PI * i / 2) && (start < PI * (i + 1) / 2) &&
- (start != end)) {
- j++;
- verts[j].x = x + rad * cos(start);
- verts[j].y = y + rad * sin(start);
- verts[j].flags = VertexCurved;
- sv = j;
- } else if ((end >= PI * i / 2) && (end < PI * (i + 1) / 2)
- && (start != end)) {
- j++;
- verts[j].x = x + rad * cos(end);
- verts[j].y = y + rad * sin(end);
- verts[j].flags = VertexCurved;
- ev = j;
- }
- j++;
- }
- verts[0].flags |= VertexStartClosed;
- verts[j].x = verts[0].x;
- verts[j].y = verts[0].y;
- verts[j].flags = (verts[0].flags & ~VertexStartClosed) |
- VertexEndClosed;
- for (i = 0; i < 15; i++) {
- if (dp)
- verts[i % 7].flags |= VertexDontDraw;
- if (i % 7 == ev)
- dp = 1;
- else if (i % 7 == sv)
- dp = 0;
- }
- XDraw(win, verts, j + 1, width, height, pixel, func, planes);
-
- return;
-}
-
-#endif notdef
-
diff --git a/gnu/games/chess/Xchess/bishop.bitmap b/gnu/games/chess/Xchess/bishop.bitmap
deleted file mode 100644
index dc068dd..0000000
--- a/gnu/games/chess/Xchess/bishop.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define bishop_width 80
-#define bishop_height 80
-static char bishop_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f,
- 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x0f, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x9f,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x10, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0xff, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfc, 0xff, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
- 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x23, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x67, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0xff, 0xf8, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0x1f, 0xc0, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0xc0,
- 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0xc0, 0x5f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xe0, 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
- 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xf8,
- 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xf8, 0x7f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xf8, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
- 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfe, 0xfd, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0xf8,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x70, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x70, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfa, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0xfd, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f,
- 0xfc, 0xfd, 0xc1, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xfd,
- 0xff, 0xff, 0x07, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80,
- 0x0f, 0xf0, 0x0f, 0xc0, 0x7f, 0x00, 0x1f, 0x00, 0x00, 0xc0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_mask.bitmap b/gnu/games/chess/Xchess/bishop_mask.bitmap
deleted file mode 100644
index ca17bb3..0000000
--- a/gnu/games/chess/Xchess/bishop_mask.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define bishop_mask_width 80
-#define bishop_mask_height 80
-static char bishop_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf,
- 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
- 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x3f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff,
- 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
- 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
- 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
- 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfc, 0x3f, 0xfc, 0xff, 0xe3, 0xff, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x01, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0x01,
- 0x00, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0x01, 0x00, 0xe0,
- 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0xf8,
- 0x1f, 0xe0, 0xff, 0x80, 0xff, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_outline.bitmap b/gnu/games/chess/Xchess/bishop_outline.bitmap
deleted file mode 100644
index 9772328..0000000
--- a/gnu/games/chess/Xchess/bishop_outline.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define bishop_outline_width 80
-#define bishop_outline_height 80
-static char bishop_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8d,
- 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x88, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8d, 0x0d, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x0f, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x98,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x70, 0x10, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x18, 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x08, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0c, 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80,
- 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x22, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x66, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x01, 0x05, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0xe0, 0x3d, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x20,
- 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xe0, 0x3d, 0x50, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x70, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x20, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x20, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
- 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05,
- 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x05, 0x40, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xc0, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
- 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8d, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8d, 0x03, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x02, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x18, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f,
- 0x0c, 0x85, 0xc1, 0xff, 0x01, 0x00, 0x00, 0x00, 0x0e, 0xf0, 0x87, 0x0d,
- 0x7f, 0x00, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x08, 0x00, 0x00,
- 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00, 0xe0, 0x18, 0x00, 0x00, 0xe0, 0x00,
- 0x00, 0xc0, 0xf8, 0x1f, 0x38, 0x70, 0xc0, 0xff, 0x31, 0x00, 0x00, 0x80,
- 0x0f, 0xf0, 0x0f, 0xc0, 0x7f, 0x00, 0x1f, 0x00, 0x00, 0xc0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_small.bitmap b/gnu/games/chess/Xchess/bishop_small.bitmap
deleted file mode 100644
index 5525ecd..0000000
--- a/gnu/games/chess/Xchess/bishop_small.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define bishop_small_width 32
-#define bishop_small_height 32
-static char bishop_small_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x70, 0x1c, 0x00,
- 0x00, 0x70, 0x1c, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x60, 0x16, 0x00,
- 0x00, 0x60, 0x22, 0x00, 0x00, 0xf0, 0x23, 0x00, 0x00, 0xf0, 0x21, 0x00,
- 0x00, 0xf8, 0x21, 0x00, 0x00, 0xf8, 0x23, 0x00, 0x00, 0xf8, 0x23, 0x00,
- 0x00, 0xf8, 0x27, 0x00, 0x00, 0x38, 0x27, 0x00, 0x00, 0x3c, 0x2f, 0x00,
- 0x00, 0x0c, 0x2c, 0x00, 0x00, 0x0e, 0x3c, 0x00, 0x00, 0x3e, 0x3f, 0x00,
- 0x00, 0x3e, 0x3f, 0x00, 0x00, 0x3e, 0x3f, 0x00, 0x00, 0x3e, 0x3f, 0x00,
- 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00,
- 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00,
- 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_small_outline.bitmap b/gnu/games/chess/Xchess/bishop_small_outline.bitmap
deleted file mode 100644
index 8d29a81..0000000
--- a/gnu/games/chess/Xchess/bishop_small_outline.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define bishop_small_outline_width 32
-#define bishop_small_outline_height 32
-static char bishop_small_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x50, 0x14, 0x00,
- 0x00, 0x70, 0x1c, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x60, 0x16, 0x00,
- 0x00, 0x60, 0x22, 0x00, 0x00, 0xf0, 0x23, 0x00, 0x00, 0x10, 0x21, 0x00,
- 0x00, 0x18, 0x21, 0x00, 0x00, 0x08, 0x23, 0x00, 0x00, 0x08, 0x22, 0x00,
- 0x00, 0x08, 0x26, 0x00, 0x00, 0x08, 0x24, 0x00, 0x00, 0xcc, 0x2c, 0x00,
- 0x00, 0xc4, 0x28, 0x00, 0x00, 0xf6, 0x3b, 0x00, 0x00, 0xf2, 0x23, 0x00,
- 0x00, 0xc2, 0x20, 0x00, 0x00, 0xc2, 0x20, 0x00, 0x00, 0xc2, 0x20, 0x00,
- 0x00, 0xc2, 0x60, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00,
- 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00,
- 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0xe0, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/board.c b/gnu/games/chess/Xchess/board.c
deleted file mode 100644
index 4c5b934..0000000
--- a/gnu/games/chess/Xchess/board.c
+++ /dev/null
@@ -1,179 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/23 17:17:15 $
- * $Source: /users/faustus/xchess/RCS/board.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Stuff to deal with the board.
- */
-
-#include "xchess.h"
-
-board *chessboard;
-
-void
-board_setup()
-{
- chessboard = alloc(board);
- board_init(chessboard);
- return;
-}
-
-void
-board_init(b)
- board *b;
-{
- int i, j;
-
- for (i = 0; i < 2; i++)
- for (j = 0; j < SIZE; j++)
- b->square[i][j].color = BLACK;
- for (i = 2; i < 6; i++)
- for (j = 0; j < SIZE; j++)
- b->square[i][j].color = NONE;
- for (i = 6; i < 8; i++)
- for (j = 0; j < SIZE; j++)
- b->square[i][j].color = WHITE;
- for (i = 0; i < SIZE; i++)
- b->square[1][i].type = b->square[6][i].type =
- PAWN;
- b->square[0][0].type = b->square[7][0].type = ROOK;
- b->square[0][1].type = b->square[7][1].type = KNIGHT;
- b->square[0][2].type = b->square[7][2].type = BISHOP;
- b->square[0][3].type = b->square[7][3].type = QUEEN;
- b->square[0][4].type = b->square[7][4].type = KING;
- b->square[0][5].type = b->square[7][5].type = BISHOP;
- b->square[0][6].type = b->square[7][6].type = KNIGHT;
- b->square[0][7].type = b->square[7][7].type = ROOK;
- b->black_cant_castle_k = false;
- b->black_cant_castle_q = false;
- b->white_cant_castle_k = false;
- b->white_cant_castle_q = false;
-
- return;
-}
-
-void
-board_drawall()
-{
- int i, j;
-
- for (i = 0; i < SIZE; i++)
- for (j = 0; j < SIZE; j++)
- if (chessboard->square[i][j].color != NONE) {
- win_drawpiece(&chessboard->square[i][j], i,
- j, WHITE);
- if (!oneboard)
- win_drawpiece(&chessboard->square[i][j],
- i, j, BLACK);
- }
- return;
-}
-
-void
-board_move(b, m)
- board *b;
- move *m;
-{
- switch (m->type) {
-
- case MOVE:
- case CAPTURE:
- b->square[m->fromy][m->fromx].color = NONE;
- b->square[m->toy][m->tox].color = m->piece.color;
- b->square[m->toy][m->tox].type = m->piece.type;
- if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) &&
- (m->toy == 7)) || ((m->piece.color == WHITE) &&
- (m->toy == 0))))
- b->square[m->toy][m->tox].type = QUEEN;
- if (m->enpassant)
- b->square[m->toy + ((m->piece.color == WHITE) ? 1 :
- -1)][m->tox].color = NONE;
- break;
-
- case KCASTLE:
- if (m->piece.color == WHITE) {
- b->square[7][5].color = m->piece.color;
- b->square[7][5].type = ROOK;
- b->square[7][6].color = m->piece.color;
- b->square[7][6].type = KING;
- b->square[7][4].color = NONE;
- b->square[7][7].color = NONE;
- } else {
- b->square[0][5].color = m->piece.color;
- b->square[0][5].type = ROOK;
- b->square[0][6].color = m->piece.color;
- b->square[0][6].type = KING;
- b->square[0][4].color = NONE;
- b->square[0][7].color = NONE;
- }
- break;
-
- case QCASTLE:
- if (m->piece.color == WHITE) {
- b->square[7][3].color = m->piece.color;
- b->square[7][3].type = ROOK;
- b->square[7][2].color = m->piece.color;
- b->square[7][2].type = KING;
- b->square[7][4].color = NONE;
- b->square[7][0].color = NONE;
- } else {
- b->square[0][3].color = m->piece.color;
- b->square[0][3].type = ROOK;
- b->square[0][2].color = m->piece.color;
- b->square[0][2].type = KING;
- b->square[0][4].color = NONE;
- b->square[0][0].color = NONE;
- }
- break;
-
- default:
- fprintf(stderr, "Bad move type %d\n", m->type);
- }
-
- if (m->piece.type == KING) {
- if (m->piece.color == WHITE)
- b->white_cant_castle_q =
- b->white_cant_castle_k= true;
- else
- b->black_cant_castle_q =
- b->black_cant_castle_k= true;
- } else if (m->piece.type == ROOK) {
- if (m->piece.color == WHITE) {
- if (m->fromx == 0)
- b->white_cant_castle_q = true;
- else if (m->fromx == 7)
- b->white_cant_castle_k = true;
- } else {
- if (m->fromx == 0)
- b->black_cant_castle_q = true;
- else if (m->fromx == 7)
- b->black_cant_castle_k = true;
- }
- }
-
- return;
-}
-
diff --git a/gnu/games/chess/Xchess/button.c b/gnu/games/chess/Xchess/button.c
deleted file mode 100644
index 67bf3c8..0000000
--- a/gnu/games/chess/Xchess/button.c
+++ /dev/null
@@ -1,337 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/26 12:09:41 $
- * $Source: /users/faustus/xchess/RCS/button.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Do stuff with the buttons.
- * The configuration we're using is: Draw Back Pause
- * Resign Fwd Flip
- * Reset Save Easy (Switch)
- */
-
-#include "xchess.h"
-
-typedef enum choice { NOCHOICE, DRAW, RESIGN, REPLAY, SWITCH, FORE, SAVE,
- STOP, FLIP, RESTART, EASY } choice;
-
-static struct but {
- char *label;
- int x, y;
- int width, height;
- choice which;
-} buts[] = {
- { "Draw", 0, 20, 108, 29, DRAW } ,
- { "Back", 109, 20, 108, 29, REPLAY } ,
- { "Pause", 219, 20, 108, 29, STOP } ,
- { "Resign", 0, 50, 108, 29, RESIGN } ,
- { "Fwd", 109, 50, 108, 29, FORE } ,
- { "Flip", 219, 50, 108, 29, FLIP } ,
- { "Reset", 0, 80, 108, 29, RESTART } ,
- { "Save", 109, 80, 108, 29, SAVE } ,
-#define EASY_OFFSET 8
- { "Switch", 219, 80, 108, 29, SWITCH }
-/* { "NoEasy", 219, 80, 108, 29, EASY }*/
-} ;
-static int easy = 1;
-
-void
-button_draw(win)
- windata *win;
-{
- int i, x, numbuts = sizeof (buts) / sizeof (struct but);
-
- XSetState(win->display, DefaultGC(win->display, 0),
- win->border.pixel, WhitePixel(win->display, 0),
- GXcopy, AllPlanes);
- XSetLineAttributes(win->display, DefaultGC(win->display, 0),
- BORDER_WIDTH, LineSolid, CapButt,
- JoinMiter);
-
- XDrawLine(win->display, win->buttonwin,
- DefaultGC(win->display, 0),
- 0, 29, BUTTON_WIDTH, 29);
- XDrawLine(win->display, win->buttonwin,
- DefaultGC(win->display, 0),
- 0, 60, BUTTON_WIDTH, 60);
- XDrawLine(win->display, win->buttonwin,
- DefaultGC(win->display, 0),
- 108, 0, 108, BUTTON_HEIGHT);
- XDrawLine(win->display, win->buttonwin,
- DefaultGC(win->display, 0),
- 219, 0, 219, BUTTON_HEIGHT);
-
- XSetFont(win->display, DefaultGC(win->display, 0), win->large->fid);
- XSetForeground(win->display, DefaultGC(win->display, 0),
- win->textcolor.pixel);
- XSetBackground(win->display, DefaultGC(win->display, 0),
- win->textback.pixel);
-
- for (i = 0; i < numbuts; i++) {
- x = (buts[i].width -
- XTextWidth(win->large, buts[i].label,
- strlen(buts[i].label))) / 2;
-
- XDrawImageString(win->display, win->buttonwin,
- DefaultGC(win->display, 0),
- buts[i].x + x, buts[i].y, buts[i].label,
- strlen(buts[i].label));
- }
- return;
-}
-
-void
-button_service(win, event)
- windata *win;
- XEvent *event;
-{
- XKeyEvent *ev = &event->xkey;
- choice c;
- int i, numbuts = sizeof (buts) / sizeof (struct but);
- char *s;
-
- ev->y += 15;
- for (i = 0; i < numbuts; i++)
- if ((ev->x >= buts[i].x) && (ev->x <= buts[i].x +
- buts[i].width) && (ev->y >= buts[i].y) &&
- (ev->y <= buts[i].y + buts[i].height)) {
- c = buts[i].which;
- break;
- }
- if ((i == numbuts) || (c == NOCHOICE)) {
- message_add(win, "Bad choice.\n", true);
- return;
- }
-
- if (loading_flag && (c != STOP)) {
- message_add(win, "You can only use PAUSE now\n", true);
- return;
- }
-
- switch (c) {
- case DRAW:
- if (!oneboard) {
- message_add(win, "Just a sec...\n", false);
- if (!pop_question(((win == win1) ? win2 : win1),
-"The other player wants\nto call the game a draw.\nDo you agree?\n")) {
- message_add(win,
- "The other player declines the draw\n", false);
- return;
- }
- }
- message_add(win1, "Draw agreed.\n", false);
- if (!oneboard)
- message_add(win2, "Draw agreed.\n", false);
- cleanup("Draw agreed.");
- break;
-
- case RESIGN:
- if (!pop_question(win, "Are you sure\nyou want to resign?"))
- return;
- if ((oneboard && !progflag) || (nexttomove == win->color)) {
- if (nexttomove == WHITE)
- s = "White resigns.";
- else
- s = "Black resigns.";
- if (oneboard) {
- message_add(win, s, false);
- message_add(win, "\n", false);
- } else {
- message_add(win1, s, false);
- message_add(win, "\n", false);
- message_add(win2, s, false);
- message_add(win, "\n", false);
- }
- sleep(5);
- cleanup(s);
- } else {
- message_add(win, "It's not your turn.\n", true);
- }
- break;
-
- case REPLAY:
- if (!oneboard) {
- message_add(win, "Just a sec...\n", false);
- if (!pop_question(((win == win1) ? win2 : win1),
-"The other player wants\nto take back his last move.\nDo you let him?\n")) {
- message_add(win,
- "The other player refuses...\n", false);
- return;
- }
- }
- if (!moves) {
- message_add(win, "Can't back up...\n", true);
- break;
- }
- message_add(win1, "Replaying...\n", false);
- if (!oneboard)
- message_add(win2, "Replaying...\n", false);
- replay();
- if (progflag)
- replay();
- break;
-
- case FORE:
- if (!oneboard) {
- message_add(win, "Just a sec...\n", false);
- if (!pop_question(((win == win1) ? win2 : win1),
-"The other player wants\nto do a 'fore'.\nIs that ok with you?\n")) {
- message_add(win,
- "The other player refuses...\n", false);
- return;
- }
- }
- if (!foremoves) {
- message_add(win, "Can't go forward...\n", true);
- break;
- }
- message_add(win1, "Moving forward...\n", false);
- if (!oneboard)
- message_add(win2, "Moving forward...\n", false);
- forward();
- break;
-
- case SWITCH:
- message_add(win, "You can't switch yet.\n", false);
- break;
-
- case SAVE:
- if (saveflag) {
- message_add(win,
- "Game is already being logged in file '", true);
- message_add(win, record_file, true);
- message_add(win, "'.\n", true);
- } else {
- message_add(win, "Saving game to file '", false);
- message_add(win, record_file, false);
- message_add(win, "'.\n", false);
- record_save();
- }
- break;
-
- case STOP:
- if (loading_flag) {
- loading_paused = (loading_paused ? false : true);
- message_add(win, loading_paused ?
- "Stopped.\nHit 'Pause' again to restart.\n" :
- "Restarted.\n", false);
- } else if (clock_started) {
- if (!oneboard) {
- message_add(win, "Just a sec...\n", false);
- if (!pop_question(((win == win1) ? win2 : win1),
-"The other player wants\nto stop the clock.\nDo you let him?\n")) {
- message_add(win,
- "The other player refuses to pause.\n",
- false);
- return;
- }
- }
- message_add(win1,
- "Clock stopped.\nHit 'Pause' again to restart.\n",
- false);
- if (!oneboard)
- message_add(win2,
- "Clock stopped.\nHit 'Pause' again to restart.\n",
- false);
- clock_started = false;
- } else {
- if (!oneboard) {
- message_add(win, "Just a sec...\n", false);
- if (!pop_question(((win == win1) ? win2 : win1),
-"The other player wants\nto start the clock again.\nIs that ok?\n")) {
- message_add(win,
- "The other player refuses to resume.\n",
- false);
- return;
- }
- }
- message_add(win1, "Clock restarted.\n", false);
- if (!oneboard)
- message_add(win2, "Clock restarted.\n", false);
- clock_started = true;
- }
- break;
-
- case FLIP:
- message_add(win, "Flipping window...\n", false);
- win->flipped = win->flipped ? false : true;
- win_redraw(win, (XEvent *) NULL);
- break;
-
- case RESTART:
- if (!oneboard) {
- message_add(win, "Just a sec...\n", false);
- if (!pop_question(((win == win1) ? win2 : win1),
-"The other player wants\nto restart the game.\nDo you agree?\n")) {
- message_add(win,
- "The other player refuses to reset\n", false);
- return;
- }
- }
- message_add(win, "Restarting game.\n", false);
- restart();
- break;
- case EASY:
- if (oneboard) {
- int x;
- if (easy)
- easy = 0;
- else
- easy = 1;
-
- if (easy)
- buts[EASY_OFFSET].label = " Easy ";
- else
- buts[EASY_OFFSET].label = "NoEasy";
-
- program_easy(easy);
-
- x = (buts[EASY_OFFSET].width -
- XTextWidth(win->large,
- buts[EASY_OFFSET].label,
- strlen(buts[EASY_OFFSET].label))) / 2;
-
- XSetFont(win->display, DefaultGC(win->display,
- 0), win->large->fid);
- XSetForeground(win->display,
- DefaultGC(win->display, 0),
- win->textcolor.pixel);
- XSetBackground(win->display,
- DefaultGC(win->display, 0),
- win->textback.pixel);
-
- XDrawImageString(win->display,
- win->buttonwin,
- DefaultGC(win->display, 0),
- buts[EASY_OFFSET].x + x,
- buts[EASY_OFFSET].y,
- buts[EASY_OFFSET].label,
- strlen(buts[EASY_OFFSET].label));
- }
- break;
- }
- return;
-}
-
diff --git a/gnu/games/chess/Xchess/clock.c b/gnu/games/chess/Xchess/clock.c
deleted file mode 100644
index a7b3c32..0000000
--- a/gnu/games/chess/Xchess/clock.c
+++ /dev/null
@@ -1,291 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/26 12:09:47 $
- * $Source: /users/faustus/xchess/RCS/clock.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Do stuff with the clocks. The way things work is as follows. We call
- * clock_init to draw the clocks initially, but they don't actually start
- * running until we call clock_switch for the first time.
- */
-
-#include "xchess.h"
-
-int movesperunit = 0;
-int timeunit = 0;
-bool clock_started = false;
-int whiteseconds, blackseconds;
-
-static bool white_running = true;
-static long lastwhite, lastblack;
-static bool firstmove = true;
-
-extern void dohands(), hilight();
-
-#define PI 3.1415926535897932384
-
-void
-clock_draw(win, col)
- windata *win;
- color col;
-{
- int i;
- char buf[BSIZE];
- int x = CLOCK_WIDTH / 2, y = CLOCK_WIDTH / 2;
- int xp, yp;
- int rad = CLOCK_WIDTH / 2 - 10;
- Window w = ((col == WHITE) ? win->wclockwin : win->bclockwin);
-
- /* Draw a clock face and the hands. */
- XCircle(w, x, y, rad, 0.0, 0.0, 1, 1, win->textcolor.pixel, GXcopy,
- AllPlanes);
- rad -= 8;
-
- XSetFont(win->display, DefaultGC(win->display, 0),
- win->small->fid);
- XSetForeground(win->display, DefaultGC(win->display, 0),
- win->textcolor.pixel);
- XSetBackground(win->display, DefaultGC(win->display, 0),
- win->textback.pixel);
- for (i = 1; i <= 12; i++) {
- xp = x + rad * cos(PI * 3 / 2 + i * PI / 6) - 4;
- yp = y + rad * sin(PI * 3 / 2 + i * PI / 6) - 5;
- sprintf(buf, "%d", i);
- XDrawString(win->display, w, DefaultGC(win->display, 0),
- xp, yp, buf, strlen(buf));
- }
-
- dohands(win, col);
-
- if (white_running) {
- hilight(win, WHITE, true);
- hilight(win, BLACK, false);
- } else {
- hilight(win, WHITE, false);
- hilight(win, BLACK, true);
- }
- return;
-}
-
-void
-clock_init(win, col)
- windata *win;
- color col;
-{
- whiteseconds = blackseconds = 0;
- clock_started = false;
- firstmove = true;
- clock_draw(win, col);
-
- return;
-}
-
-void
-clock_update()
-{
- int now = time((long *) NULL);
- int i;
-
- if (!clock_started) {
- lastwhite = lastblack = now;
- return;
- }
-
- if (white_running) {
- whiteseconds += now - lastwhite;
- lastwhite = now;
- dohands(win1, WHITE);
- if (!oneboard)
- dohands(win2, WHITE);
- if (timeunit) {
- i = whiteseconds / timeunit;
- if ((i > 0) && (whiteseconds > i * timeunit) &&
- (whiteseconds < i * timeunit + 10) &&
- (movesperunit * i > movenum)) {
- message_add(win1,
- "White has exceeded his time limit\n",
- true);
- if (!oneboard) {
- message_add(win2,
- "White has exceeded his time limit\n",
- true);
- }
- timeunit = 0;
- }
- }
- } else {
- blackseconds += now - lastblack;
- lastblack = now;
- dohands(win1, BLACK);
- if (!oneboard)
- dohands(win2, BLACK);
- if (timeunit) {
- i = blackseconds / timeunit;
- if ((i > 0) && (blackseconds > i * timeunit) &&
- (blackseconds < i * timeunit + 10) &&
- (movesperunit * i > movenum)) {
- message_add(win1,
- "Black has exceeded his time limit\n",
- true);
- if (!oneboard) {
- message_add(win2,
- "Black has exceeded his time limit\n",
- true);
- }
- timeunit = 0;
- }
- }
- }
- return;
-}
-
-void
-clock_switch()
-{
- if (firstmove) {
- clock_started = true;
- firstmove = false;
- lastwhite = lastblack = time((long *) NULL);
- }
- if (white_running) {
- white_running = false;
- lastblack = time((long *) NULL);
- hilight(win1, WHITE, false);
- hilight(win1, BLACK, true);
- if (!oneboard) {
- hilight(win2, WHITE, false);
- hilight(win2, BLACK, true);
- }
- } else {
- white_running = true;
- lastwhite = time((long *) NULL);
- hilight(win1, WHITE, true);
- hilight(win1, BLACK, false);
- if (!oneboard) {
- hilight(win2, WHITE, true);
- hilight(win2, BLACK, false);
- }
- }
- return;
-}
-
-static void
-dohands(win, col)
- windata *win;
- color col;
-{
- int cx = CLOCK_WIDTH / 2, cy = CLOCK_WIDTH / 2;
- double *h = (col == WHITE) ? win->whitehands : win->blackhands;
- Window w = (col == WHITE) ? win->wclockwin : win->bclockwin;
- long secs = (col == WHITE) ? whiteseconds : blackseconds;
- int rad, x, y, i;
-
- /* First erase the old hands. */
- XSetState(win->display, DefaultGC(win->display, 0),
- win->textback.pixel, win->textback.pixel,
- GXcopy, AllPlanes);
-
- rad = CLOCK_WIDTH / 2 - 30;
- for (i = 0; i < 3; i++) {
- x = cx + rad * sin(PI - h[i]);
- y = cy + rad * cos(PI - h[i]);
- XSetLineAttributes(win->display,
- DefaultGC(win->display, 0),
- i, LineSolid, 0, 0);
- XDrawLine(win->display, w, DefaultGC(win->display, 0),
- cx, cy, x, y);
- rad -= 8;
- }
-
- h[0] = (secs % 60) * 2 * PI / 60;
- h[1] = ((secs / 60) % 60) * 2 * PI / 60;
- h[2] = ((secs / 3600) % 12) * 2 * PI / 12;
-
- /* Now draw the new ones. */
-
- XSetState(win->display, DefaultGC(win->display, 0),
- win->textcolor.pixel, win->textback.pixel,
- GXcopy, AllPlanes);
-
- rad = CLOCK_WIDTH / 2 - 30;
- for (i = 0; i < 3; i++) {
- x = cx + rad * sin(PI - h[i]);
- y = cy + rad * cos(PI - h[i]);
- XSetLineAttributes(win->display,
- DefaultGC(win->display, 0),
- i, LineSolid, 0, 0);
- XDrawLine(win->display, w, DefaultGC(win->display, 0),
- cx, cy, x, y);
- rad -= 8;
- }
- XFlush(win->display);
- return;
-}
-
-static void
-hilight(win, col, on)
- windata *win;
- color col;
- bool on;
-{
- Window w = (col == WHITE) ? win->wclockwin : win->bclockwin;
- char *s = (col == WHITE) ? " WHITE " : " BLACK ";
- int x;
-
-
- x = XTextWidth(win->large, s, strlen(s));
- if (on)
- XSetState(win->display, DefaultGC(win->display, 0),
- win->textback.pixel,
- win->textcolor.pixel,
- GXcopy,
- AllPlanes);
- else
- XSetState(win->display, DefaultGC(win->display, 0),
- win->textcolor.pixel,
- win->textback.pixel,
- GXcopy, AllPlanes);
-
- XSetLineAttributes(win->display, DefaultGC(win->display, 0),
- BORDER_WIDTH, LineSolid, CapButt, JoinMiter);
- XSetFont(win->display, DefaultGC(win->display, 0),
- win->large->fid);
-
- XDrawLine(win->display, w, DefaultGC(win->display, 0),
- 0, CLOCK_HEIGHT - 26,
- CLOCK_WIDTH, CLOCK_HEIGHT - 26);
-
- XDrawImageString(win->display, w, DefaultGC(win->display, 0),
- (CLOCK_WIDTH - x) / 2, CLOCK_HEIGHT,
- s, strlen(s));
-
- if (on)
- XSetState(win->display, DefaultGC(win->display, 0),
- win->textcolor.pixel,
- win->textback.pixel,
- GXcopy, AllPlanes);
- return;
-}
-
diff --git a/gnu/games/chess/Xchess/control.c b/gnu/games/chess/Xchess/control.c
deleted file mode 100644
index ad2e1d7..0000000
--- a/gnu/games/chess/Xchess/control.c
+++ /dev/null
@@ -1,515 +0,0 @@
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/23 17:17:32 $
- * $Source: /users/faustus/xchess/RCS/control.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Deal with input from the user.
- */
-
-#include "xchess.h"
-
-move *moves;
-move *foremoves;
-color nexttomove = WHITE;
-bool noisyflag = false;
-
-move *lastmove;
-static move *thismove;
-
-static void screen_move();
-
-void
-button_pressed(event, win)
- XEvent *event;
- windata *win;
-{
- int x, y;
- XKeyEvent *ev = (XKeyEvent *) event;
-
- if (!oneboard && (win->color != nexttomove)) {
- message_add(win, "Wrong player!\n", true);
- return;
- }
- if (progflag && (nexttomove == (blackflag ? WHITE : BLACK))) {
- message_add(win, "Wait for the computer...\n", true);
- return;
- }
- if (loading_flag) {
- message_add(win, "You'd better not do that now...\n", true);
- return;
- }
-
- /* Figure out what piece he is pointing at. */
- x = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
- y = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
-
- if (win->flipped) {
- y = SIZE - y - 1;
- x = SIZE - x - 1;
- }
-
- if ((x < 0) || (x >= SIZE) || (y < 0) || (y >= SIZE)) {
- fprintf(stderr, "Bad coords (%d, %d)\n", x, y);
- return;
- }
-
- if (oneboard && (chessboard->square[y][x].color != nexttomove)) {
- message_add(win, "Wrong player!\n", true);
- return;
- } else if (!oneboard && (chessboard->square[y][x].color !=
- win->color)) {
- message_add(win, "Can't move that\n", true);
- return;
- }
-
- thismove = alloc(move);
- thismove->fromx = x;
- thismove->fromy = y;
- thismove->piece.color = chessboard->square[y][x].color;
- thismove->piece.type = chessboard->square[y][x].type;
-
- if (debug)
- fprintf(stderr, "%s selected his %s at (%d, %d)...\n",
- colornames[(int) thismove->piece.color],
- piecenames[(int) thismove->piece.type],
- thismove->fromy, thismove->fromx);
- return;
-}
-
-void
-button_released(event, win)
- XEvent *event;
- windata *win;
-{
- int x, y;
- XKeyEvent *ev = (XKeyEvent *) event;
-
- if (!thismove) {
- /* fprintf(stderr, "Error: button hasn't been pressed\n"); */
- return;
- }
- if (loading_flag)
- return;
-
- /* Figure out what piece he is pointing at. */
- x = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
- y = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
-
- if (win->flipped) {
- y = SIZE - y - 1;
- x = SIZE - x - 1;
- }
-
- if ((x < 0) || (x >= SIZE) || (y < 0) || (y >= SIZE)) {
- fprintf(stderr, "Bad coords (%d, %d)\n", x, y);
- return;
- }
-
- if ((thismove->fromx == x) && (thismove->fromy == y)) {
- message_add(win, "Hey, you touch it, you move it, buddy.\n",
- true);
- return;
- }
- if (chessboard->square[y][x].color == thismove->piece.color) {
- message_add(win, "Can't put one piece on top of another\n",
- true);
- return;
- }
-
- thismove->tox = x;
- thismove->toy = y;
- thismove->taken.color = chessboard->square[y][x].color;
- thismove->taken.type = chessboard->square[y][x].type;
- if (thismove->taken.color != NONE)
- thismove->type = CAPTURE;
- else if ((thismove->piece.type == KING) && (thismove->fromx == 4) &&
- (thismove->tox == 6) &&
- (thismove->toy == thismove->fromy))
- thismove->type = KCASTLE;
- else if ((thismove->piece.type == KING) && (thismove->tox == 2) &&
- (thismove->fromx == 4) &&
- (thismove->toy == thismove->fromy))
- thismove->type = QCASTLE;
- else
- thismove->type = MOVE;
-
- /* Now check the en-passant case... */
- if ((thismove->type == MOVE) && ((thismove->tox == thismove->fromx + 1)
- || (thismove->tox == thismove->fromx - 1)) &&
- (thismove->piece.type == PAWN) && lastmove &&
- (lastmove->tox == lastmove->fromx) && (lastmove->fromx
- == thismove->tox) && ((lastmove->fromy + lastmove->toy)
- / 2 == thismove->toy)) {
- thismove->type = CAPTURE;
- thismove->enpassant = true;
- thismove->taken = lastmove->piece;
- }
-
- if (!valid_move(thismove, chessboard)) {
- message_add(win, "Invalid move.\n", true);
- return;
- }
-
- if (debug)
- fprintf(stderr, "\t... and moved it to (%d, %d), type %s\n",
- thismove->toy, thismove->tox,
- movetypenames[(int) thismove->type]);
- move_piece(thismove);
-
- if (thismove->check) {
- message_add(win1, "Check.\n", true);
- if (!oneboard) {
- message_add(win2, "Check.\n", true);
- }
- }
-
- if (!moves)
- moves = lastmove = thismove;
- else
- lastmove = lastmove->next = thismove;
-
- if (progflag)
- program_send(thismove);
-
- thismove = NULL;
- nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE);
- clock_switch();
-
- return;
-}
-
-void
-prog_move(m)
- move *m;
-{
- if (debug)
- fprintf(stderr, "program moves from (%d, %d) to (%d, %d)\n",
- m->fromy, m->fromx, m->toy, m->tox);
- move_piece(m);
-
- if (!moves)
- moves = lastmove = m;
- else
- lastmove = lastmove->next = m;
-
- nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE);
- clock_switch();
-
- return;
-}
-
-void
-move_piece(m)
- move *m;
-{
- /* Update the screen... */
- screen_move(m);
-
- /* Move the piece on the board... */
- board_move(chessboard, m);
-
- /* And record it... */
- record_move(m);
-
- if (noisyflag) {
- XBell(win1->display, 50);
- XBell(win2->display, 50);
- }
- return;
-}
-
-static void
-screen_move(m)
- move *m;
-{
- piece pp;
-
- switch (m->type) {
- case CAPTURE:
- jail_add(&m->taken);
- /* FALLTHRU */
-
- case MOVE:
- win_erasepiece(m->fromy, m->fromx, WHITE);
- if (win_flashmove)
- win_flash(m, WHITE);
- win_drawpiece(&m->piece, m->toy, m->tox, WHITE);
- if (m->enpassant)
- win_erasepiece(m->toy + ((m->piece.color == WHITE) ?
- 1 : -1), m->tox, WHITE);
- if (!oneboard) {
- win_erasepiece(m->fromy, m->fromx, BLACK);
- if (win_flashmove)
- win_flash(m, BLACK);
- win_drawpiece(&m->piece, m->toy, m->tox, BLACK);
- if (m->enpassant)
- win_erasepiece(m->toy + ((m->piece.color ==
- WHITE) ? 1 : -1), m->tox, WHITE);
- }
- if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) &&
- (m->toy == 7)) || ((m->piece.color == WHITE) &&
- (m->toy == 0)))) {
- pp.color = m->piece.color;
- pp.type = QUEEN;
- win_drawpiece(&pp, m->toy, m->tox, WHITE);
- if (!oneboard)
- win_drawpiece(&m->piece, m->toy, m->tox, BLACK);
- }
- break;
-
- case KCASTLE:
- if (m->piece.color == WHITE) {
- win_erasepiece(7, 4, WHITE);
- win_erasepiece(7, 7, WHITE);
- if (win_flashmove)
- win_flash(m, WHITE);
- win_drawpiece(&m->piece, 7, 6, WHITE);
- win_drawpiece(&chessboard->square[7][7], 7, 5, WHITE);
- if (!oneboard) {
- win_erasepiece(7, 4, BLACK);
- win_erasepiece(7, 7, BLACK);
- if (win_flashmove)
- win_flash(m, BLACK);
- win_drawpiece(&m->piece, 7, 6, BLACK);
- win_drawpiece(&chessboard->square[7][7], 7, 5,
- BLACK);
- }
- } else {
- win_erasepiece(0, 4, WHITE);
- win_erasepiece(0, 7, WHITE);
- if (win_flashmove)
- win_flash(m, WHITE);
- win_drawpiece(&m->piece, 0, 6, WHITE);
- win_drawpiece(&chessboard->square[0][7], 0, 5, WHITE);
- if (!oneboard) {
- win_erasepiece(0, 4, BLACK);
- win_erasepiece(0, 7, BLACK);
- if (win_flashmove)
- win_flash(m, BLACK);
- win_drawpiece(&m->piece, 0, 6, BLACK);
- win_drawpiece(&chessboard->square[0][7], 0, 5,
- BLACK);
- }
- }
- break;
-
- case QCASTLE:
- if (m->piece.color == WHITE) {
- win_erasepiece(7, 4, WHITE);
- win_erasepiece(7, 0, WHITE);
- if (win_flashmove)
- win_flash(m, WHITE);
- win_drawpiece(&m->piece, 7, 2, WHITE);
- win_drawpiece(&chessboard->square[7][0], 7, 3, WHITE);
- if (!oneboard) {
- win_erasepiece(7, 4, BLACK);
- win_erasepiece(7, 0, BLACK);
- if (win_flashmove)
- win_flash(m, BLACK);
- win_drawpiece(&m->piece, 7, 2, BLACK);
- win_drawpiece(&chessboard->square[7][7], 7, 3,
- BLACK);
- }
- } else {
- win_erasepiece(0, 4, WHITE);
- win_erasepiece(0, 0, WHITE);
- if (win_flashmove)
- win_flash(m, WHITE);
- win_drawpiece(&m->piece, 0, 2, WHITE);
- win_drawpiece(&chessboard->square[0][0], 0, 3, WHITE);
- if (!oneboard) {
- win_erasepiece(0, 4, BLACK);
- win_erasepiece(0, 0, BLACK);
- if (win_flashmove)
- win_flash(m, BLACK);
- win_drawpiece(&m->piece, 0, 2, BLACK);
- win_drawpiece(&chessboard->square[0][7], 0, 3,
- BLACK);
- }
- }
- break;
-
- default:
- fprintf(stderr, "Bad move type %d\n", m->type);
- }
- return;
-}
-
-/* Retract the last move made... */
-
-void
-replay()
-{
- move *m = lastmove, bm;
-
- memset(&bm, 0, sizeof(bm));
- switch (m->type) {
- case MOVE:
- bm.type = MOVE;
- bm.piece = m->piece;
- bm.fromx = m->tox;
- bm.fromy = m->toy;
- bm.tox = m->fromx;
- bm.toy = m->fromy;
- board_move(chessboard, &bm);
- screen_move(&bm);
- break;
-
- case CAPTURE:
- bm.type = MOVE;
- bm.piece = m->piece;
- bm.fromx = m->tox;
- bm.fromy = m->toy;
- bm.tox = m->fromx;
- bm.toy = m->fromy;
- board_move(chessboard, &bm);
- screen_move(&bm);
- chessboard->square[m->toy][m->tox] = m->taken;
- bm.piece = m->taken;
- bm.fromx = bm.tox = m->tox;
- bm.fromy = bm.toy = m->toy;
- screen_move(&bm);
- jail_remove(&m->taken);
- break;
-
- case KCASTLE:
- bm.type = MOVE;
- bm.piece.type = KING;
- bm.piece.color = m->piece.color;
- bm.fromx = 6;
- bm.tox = 4;
- bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
- board_move(chessboard, &bm);
- screen_move(&bm);
- bm.type = MOVE;
- bm.piece.type = ROOK;
- bm.piece.color = m->piece.color;
- bm.fromx = 5;
- bm.tox = 7;
- bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
- board_move(chessboard, &bm);
- screen_move(&bm);
- if (m->piece.color == WHITE)
- chessboard->white_cant_castle_k = false;
- else
- chessboard->black_cant_castle_k = false;
- break;
-
- case QCASTLE:
- bm.type = MOVE;
- bm.piece.type = KING;
- bm.piece.color = m->piece.color;
- bm.fromx = 2;
- bm.tox = 4;
- bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
- board_move(chessboard, &bm);
- screen_move(&bm);
- bm.type = MOVE;
- bm.piece.type = ROOK;
- bm.piece.color = m->piece.color;
- bm.fromx = 3;
- bm.tox = 0;
- bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
- board_move(chessboard, &bm);
- screen_move(&bm);
- if (m->piece.color == WHITE)
- chessboard->white_cant_castle_q = false;
- else
- chessboard->black_cant_castle_q = false;
- break;
- }
- record_back();
-
- nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE);
- clock_switch();
-
- if (!moves->next) {
- moves->next = foremoves;
- foremoves = moves;
- moves = lastmove = NULL;
- } else {
- for (m = moves; m->next; m = m->next)
- lastmove = m;
- lastmove->next->next = foremoves;
- foremoves = lastmove->next;
- lastmove->next = NULL;
- }
-
- if (progflag)
- program_undo();
-
- return;
-}
-
-/* Put back the last move undone. */
-
-void
-forward()
-{
- prog_move(foremoves);
- foremoves = foremoves->next;
- return;
-}
-
-/* End the game. */
-
-void
-cleanup(s)
- char *s;
-{
- if (progflag)
- program_end();
- record_end(s);
- XSync(win1->display, 0);
- if (!oneboard) {
- XSync(win2->display, 0);
- }
- exit(0);
-}
-
-void
-restart()
-{
- moves = lastmove = thismove = NULL;
- nexttomove = WHITE;
-
- clock_init(win1, WHITE);
- clock_init(win1, BLACK);
- jail_init(win1);
- if (!oneboard) {
- clock_init(win2, WHITE);
- clock_init(win2, BLACK);
- jail_init(win2);
- }
- board_init(chessboard);
- win_restart();
- record_reset();
- if (progflag) {
- program_end();
- program_init(progname);
- }
- return;
-}
-
diff --git a/gnu/games/chess/Xchess/jail.c b/gnu/games/chess/Xchess/jail.c
deleted file mode 100644
index e5e6064..0000000
--- a/gnu/games/chess/Xchess/jail.c
+++ /dev/null
@@ -1,327 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.3 $ on $Date: 86/11/26 12:09:54 $
- * $Source: /users/faustus/xchess/RCS/jail.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- */
-
-#include "xchess.h"
-
-#include "pawn_small.bitmap"
-#include "rook_small.bitmap"
-#include "knight_small.bitmap"
-#include "bishop_small.bitmap"
-#include "queen_small.bitmap"
-#include "king_small.bitmap"
-
-#include "pawn_small_outline.bitmap"
-#include "rook_small_outline.bitmap"
-#include "knight_small_outline.bitmap"
-#include "bishop_small_outline.bitmap"
-#include "queen_small_outline.bitmap"
-#include "king_small_outline.bitmap"
-
-static bool pos[32];
-
-static piecetype pcs[] = { KING, QUEEN, ROOK, ROOK, BISHOP, BISHOP, KNIGHT,
- KNIGHT, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN } ;
-
-extern int piecepos();
-extern char *bitsget();
-
-void
-jail_init(win)
- windata *win;
-{
- int i;
-
- for (i = 0; i < 32; i++)
- pos[i] = false;
- jail_draw(win);
- return;
-}
-
-#define JAIL_HEADER "Captured Pieces"
-
-void
-jail_draw(win)
- windata *win;
-{
- int i;
- char *bits;
- Pixmap tmpPM;
- piece p;
-
- i = XTextWidth(win->large, JAIL_HEADER, strlen(JAIL_HEADER));
- XSetFont(win->display, DefaultGC(win->display, 0),
- win->large->fid);
- XSetForeground(win->display, DefaultGC(win->display, 0),
- win->textcolor.pixel);
- XSetBackground(win->display, DefaultGC(win->display, 0),
- win->textback.pixel);
-
- XDrawImageString(win->display, win->jailwin,
- DefaultGC(win->display, 0),
- (JAIL_WIDTH - i) / 2, 20, JAIL_HEADER,
- strlen(JAIL_HEADER));
-
- XSetForeground(win->display, DefaultGC(win->display, 0),
- win->blackpiece.pixel);
- XSetBackground(win->display, DefaultGC(win->display, 0),
- win->textback.pixel);
- XSetFillStyle(win->display, DefaultGC(win->display, 0),
- FillSolid);
- XSetFunction(win->display, DefaultGC(win->display, 0),
- GXcopy);
-
- for (i = 0; i < 16; i++)
- if (pos[i]) {
- p.color = WHITE;
- p.type = pcs[i];
- bits = bitsget(&p);
- tmpPM = XCreateBitmapFromData(win->display,
- win->jailwin, bits,
- 32, 32);
-
- XCopyPlane(win->display, tmpPM, win->jailwin,
- DefaultGC(win->display, 0),
- 0, 0, 32, 32,
- 5 + (i % 8) * 32, 25 + (i / 8) * 32,
- 1);
- XFreePixmap(win->display, tmpPM);
- } else {
- XFillRectangle(win->display, win->jailwin,
- DefaultGC(win->display, 0),
- 5 + (i % 8) * 32,
- 25 + (i / 8) * 32,
- 32, 32);
- }
- for (i = 0; i < 16; i++)
- if (pos[i + 16]) {
- p.color = BLACK;
- p.type = pcs[i];
- bits = bitsget(&p);
- tmpPM = XCreateBitmapFromData(win->display,
- win->jailwin, bits,
- 32, 32);
-
- XCopyPlane(win->display, tmpPM, win->jailwin,
- DefaultGC(win->display, 0),
- 0, 0, 32, 32,
- 5 + (i % 8) * 32, 94 + (i / 8) * 32,
- 1);
- XFreePixmap(win->display, tmpPM);
- } else {
- XFillRectangle(win->display, win->jailwin,
- DefaultGC(win->display, 0),
- 5 + (i % 8) * 32, 94 + (i / 8) * 32,
- 32, 32);
- }
-
- return;
-}
-
-void
-jail_add(p)
- piece *p;
-{
- int i = piecepos(p, false);
- char *bits;
- Pixmap tmpPM;
-
- pos[i] = true;
-
- bits = bitsget(p);
-
- XSetState(win1->display, DefaultGC(win1->display, 0),
- win1->blackpiece.pixel,
- win1->textback.pixel,
- GXcopy,
- AllPlanes);
-
- tmpPM = XCreateBitmapFromData(win1->display,
- win1->jailwin, bits,
- 32, 32);
-
- XCopyPlane(win1->display, tmpPM, win1->jailwin,
- DefaultGC(win1->display, 0),
- 0, 0, 32, 32,
- 5 + (i % 8) * 32, ((i >= 16) ? 30 : 25) + (i / 8) * 32,
- 1);
- XFreePixmap(win1->display, tmpPM);
-
- if (!oneboard) {
- XSetState(win2->display, DefaultGC(win2->display, 0),
- win2->blackpiece.pixel,
- win2->textback.pixel,
- GXcopy,
- AllPlanes);
-
-
- tmpPM = XCreateBitmapFromData(win2->display,
- win2->jailwin, bits,
- 32, 32);
-
- XCopyPlane(win2->display, tmpPM, win2->jailwin,
- DefaultGC(win2->display, 0),
- 0, 0, 32, 32,
- 5 + (i % 8) * 32, ((i >= 16) ? 30 : 25) + (i / 8) * 32,
- 1);
- XFreePixmap(win2->display, tmpPM);
- }
-
- return;
-}
-
-void
-jail_remove(p)
- piece *p;
-{
- int i = piecepos(p, true);
-
- pos[i] = false;
-
-
- XSetForeground(win1->display,
- DefaultGC(win1->display, 0),
- win1->blackpiece.pixel);
- XSetBackground(win1->display,
- DefaultGC(win1->display, 0),
- win1->textback.pixel);
- XSetFillStyle(win1->display,
- DefaultGC(win1->display, 0),
- FillSolid);
-
- XFillRectangle(win1->display, win1->jailwin,
- DefaultGC(win1->display, 0),
- 5 + (i % 8) * 32,
- ((i >= 16) ? 30 : 25) + (i / 8) * 32,
- 32, 32);
-
- if (!oneboard) {
- XSetForeground(win2->display,
- DefaultGC(win2->display, 0),
- win2->blackpiece.pixel);
- XSetBackground(win2->display,
- DefaultGC(win2->display, 0),
- win2->textback.pixel);
- XSetFillStyle(win2->display,
- DefaultGC(win2->display, 0),
- FillSolid);
-
- XFillRectangle(win2->display, win2->jailwin,
- DefaultGC(win2->display, 0),
- 5 + (i % 8) * 32,
- ((i >= 16) ? 30 : 25) + (i / 8) * 32,
- 32, 32);
- }
-
- return;
-}
-
-static char *bitsget(p)
- piece *p;
-{
- char *bits;
-
- switch (p->type) {
- case PAWN:
- bits = (p->color == WHITE) ? pawn_small_outline_bits :
- pawn_small_bits;
- break;
-
- case ROOK:
- bits = (p->color == WHITE) ? rook_small_outline_bits :
- rook_small_bits;
- break;
-
- case KNIGHT:
- bits = (p->color == WHITE) ? knight_small_outline_bits :
- knight_small_bits;
- break;
-
- case BISHOP:
- bits = (p->color == WHITE) ? bishop_small_outline_bits :
- bishop_small_bits;
- break;
-
- case QUEEN:
- bits = (p->color == WHITE) ? queen_small_outline_bits :
- queen_small_bits;
- break;
-
- case KING:
- bits = (p->color == WHITE) ? king_small_outline_bits :
- king_small_bits;
- break;
- }
- return (bits);
-}
-
-static int
-piecepos(p, there)
- piece *p;
- bool there;
-{
- int i, base = (p->color == WHITE) ? 0 : 16;
-
- switch (p->type) {
- case PAWN:
- for (i = base + 8; (i < base + 15) && pos[i]; i++)
- ;
- if (there && !pos[i])
- i--;
- break;
-
- case KING:
- /* Hmm... */
- i = base;
- break;
-
- case QUEEN:
- i = base + 1;
- break;
-
- case ROOK:
- i = base + 2;
- if ((there && pos[i + 1]) || (!there && pos[i]))
- i++;
- break;
-
- case BISHOP:
- i = base + 4;
- if ((there && pos[i + 1]) || (!there && pos[i]))
- i++;
- break;
-
- case KNIGHT:
- i = base + 6;
- if ((there && pos[i + 1]) || (!there && pos[i]))
- i++;
- break;
- }
- return (i);
-}
diff --git a/gnu/games/chess/Xchess/king.bitmap b/gnu/games/chess/Xchess/king.bitmap
deleted file mode 100644
index dd9178a..0000000
--- a/gnu/games/chess/Xchess/king.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define king_width 80
-#define king_height 80
-static char king_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x30, 0x18, 0x00, 0xfc, 0x1f, 0x00,
- 0x00, 0xfe, 0x7f, 0x00, 0xb8, 0x3b, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff,
- 0xff, 0x00, 0xb8, 0x3b, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x03,
- 0xb8, 0x3b, 0xe0, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x0f, 0xb8, 0x3b,
- 0xf0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x1f, 0xb8, 0x3b, 0xf8, 0xff,
- 0xf8, 0x07, 0xe0, 0x1f, 0xc0, 0x3f, 0xb8, 0x3b, 0xfc, 0x07, 0xe2, 0x07,
- 0xf0, 0xcf, 0x9f, 0x7f, 0x30, 0x18, 0xfe, 0xf3, 0xcf, 0x0f, 0xf0, 0xe7,
- 0x3f, 0xfe, 0xf0, 0x1f, 0x7e, 0xfc, 0xdf, 0x0f, 0xf0, 0xf3, 0xff, 0xfc,
- 0xf1, 0x1f, 0x3f, 0xff, 0x9f, 0x0f, 0xf8, 0xfb, 0xff, 0xfd, 0xf3, 0x9f,
- 0xbf, 0xff, 0xbf, 0x1f, 0xf8, 0xf9, 0xff, 0xf9, 0xe3, 0x8f, 0xdf, 0xff,
- 0x3f, 0x1f, 0xf8, 0xfd, 0xff, 0xf3, 0xef, 0xcf, 0xcf, 0xff, 0x7f, 0x1f,
- 0xf8, 0xfd, 0xff, 0xe7, 0xef, 0xef, 0xef, 0xff, 0x7f, 0x1f, 0xfc, 0xfd,
- 0xff, 0xcf, 0xff, 0xff, 0xe7, 0x3f, 0x7c, 0x3f, 0xfc, 0x3c, 0xfc, 0xdf,
- 0xff, 0xfe, 0xf3, 0x3d, 0x7c, 0x3f, 0xfc, 0x3e, 0xfc, 0x9e, 0x7f, 0xfc,
- 0xf9, 0x39, 0x7c, 0x3f, 0xfc, 0x3e, 0x7c, 0xbe, 0x3f, 0xf8, 0xf9, 0x3b,
- 0x7c, 0x3f, 0xfc, 0x3e, 0x78, 0x3f, 0x7f, 0xfc, 0xfc, 0x3b, 0x7f, 0x3f,
- 0xfc, 0xfe, 0x7b, 0x7f, 0xff, 0xfe, 0xfe, 0x9b, 0x7f, 0x3f, 0xf8, 0xfe,
- 0xbb, 0x7f, 0xfe, 0x7f, 0xfe, 0xdb, 0x79, 0x1f, 0xf8, 0xfe, 0xb3, 0xff,
- 0xfe, 0x7f, 0xff, 0xcb, 0x7c, 0x1f, 0xf8, 0x9e, 0xb7, 0xff, 0xfe, 0x7f,
- 0xff, 0x2b, 0x3e, 0x1f, 0xf8, 0x3e, 0xa6, 0xff, 0xfc, 0x7f, 0xff, 0xa3,
- 0xbf, 0x1f, 0xf8, 0xfe, 0xa8, 0xff, 0xfd, 0x3e, 0xff, 0xd3, 0xbf, 0x1f,
- 0xf8, 0xfd, 0x83, 0xff, 0x7d, 0xbc, 0xff, 0xc3, 0xbf, 0x1f, 0xf0, 0xfd,
- 0x8f, 0xff, 0x39, 0xb8, 0xff, 0xe3, 0xbf, 0x1f, 0xf0, 0xfd, 0x9f, 0xff,
- 0x7b, 0xbc, 0xff, 0xf1, 0x9f, 0x0f, 0xf0, 0xf9, 0xbf, 0xff, 0xfb, 0xbe,
- 0xff, 0xfd, 0xdf, 0x0f, 0xf0, 0xfb, 0x3f, 0xff, 0xf3, 0x9f, 0xff, 0xfd,
- 0xdf, 0x0f, 0xf0, 0xf3, 0x7f, 0xff, 0xf7, 0xdf, 0xff, 0xfc, 0xdf, 0x0f,
- 0xe0, 0xf7, 0x7f, 0xfe, 0xf7, 0xdf, 0xff, 0xfe, 0xdf, 0x07, 0xe0, 0xf7,
- 0xff, 0xfe, 0xf7, 0xdf, 0x7f, 0xfe, 0xcf, 0x07, 0xe0, 0xe7, 0xff, 0xfe,
- 0xf7, 0xdf, 0x7f, 0xff, 0xef, 0x07, 0xc0, 0xef, 0xff, 0xfc, 0xef, 0xee,
- 0x7f, 0xff, 0xe7, 0x03, 0xc0, 0xcf, 0xff, 0xfd, 0x6f, 0xec, 0x3f, 0xff,
- 0xf7, 0x03, 0x80, 0xdf, 0xff, 0xf9, 0xef, 0xee, 0xbf, 0xff, 0xf3, 0x01,
- 0x80, 0x9f, 0xff, 0xfb, 0xef, 0xef, 0x9f, 0xff, 0xfb, 0x01, 0x00, 0xbf,
- 0xff, 0xfb, 0xef, 0xef, 0xdf, 0xff, 0xf9, 0x00, 0x00, 0x7e, 0xff, 0xf3,
- 0xef, 0xef, 0xdf, 0xff, 0x7e, 0x00, 0x00, 0x7e, 0xfe, 0xff, 0xef, 0xef,
- 0xff, 0x7f, 0x7e, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0xef, 0xef, 0xff, 0x7f,
- 0x3f, 0x00, 0x00, 0xfc, 0xf9, 0xff, 0xef, 0xef, 0xff, 0x3f, 0x1f, 0x00,
- 0x00, 0xf8, 0xfb, 0x03, 0xe0, 0x0f, 0x00, 0x9f, 0x1f, 0x00, 0x00, 0xf0,
- 0x03, 0xf8, 0xff, 0xff, 0x7f, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xbf,
- 0xf7, 0xde, 0xfb, 0xff, 0x07, 0x00, 0x00, 0xc0, 0xff, 0x1d, 0x63, 0x8c,
- 0x71, 0xff, 0x03, 0x00, 0x00, 0x80, 0xef, 0xb8, 0xf7, 0xde, 0x3b, 0xee,
- 0x01, 0x00, 0x00, 0x00, 0xc7, 0xfd, 0xff, 0xff, 0x7f, 0xc7, 0x00, 0x00,
- 0x00, 0x00, 0xee, 0xff, 0x00, 0x00, 0xfc, 0x6f, 0x00, 0x00, 0x00, 0x00,
- 0xfe, 0x03, 0xfe, 0xff, 0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8,
- 0x7f, 0xfc, 0x7f, 0x60, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x1f, 0xf0,
- 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xff, 0x07, 0xc0, 0xff, 0x63,
- 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x1f, 0xf0, 0xff, 0x60, 0x00, 0x00,
- 0x00, 0x00, 0x06, 0xfc, 0x7f, 0xfc, 0x3f, 0x60, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0xff, 0xff, 0xff, 0xff, 0x60, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xff,
- 0x00, 0x00, 0xfc, 0x63, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x03, 0xfe, 0xff,
- 0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8, 0xff, 0xff, 0x7f, 0x60,
- 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_mask.bitmap b/gnu/games/chess/Xchess/king_mask.bitmap
deleted file mode 100644
index e1bb523..0000000
--- a/gnu/games/chess/Xchess/king_mask.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define king_mask_width 80
-#define king_mask_height 80
-static char king_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0xf8, 0x3f, 0x00, 0xfe,
- 0x3f, 0x00, 0x00, 0xff, 0xff, 0x00, 0xfc, 0x3f, 0x80, 0xff, 0x7f, 0x00,
- 0x80, 0xff, 0xff, 0x01, 0xfc, 0x7f, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff,
- 0xff, 0x07, 0xfc, 0x7f, 0xe0, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0x1f,
- 0xfc, 0x7f, 0xf8, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x3f, 0xfc, 0x7f,
- 0xfc, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x7f, 0xfc, 0x7f, 0xfe, 0xff,
- 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0x1f,
- 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
- 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
- 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07,
- 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
- 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
- 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_outline.bitmap b/gnu/games/chess/Xchess/king_outline.bitmap
deleted file mode 100644
index 173651c..0000000
--- a/gnu/games/chess/Xchess/king_outline.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define king_outline_width 80
-#define king_outline_height 80
-static char king_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3c,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x0c, 0x60, 0x00, 0xfc, 0x1f, 0x00,
- 0x00, 0x0e, 0x70, 0x00, 0x84, 0x43, 0x00, 0x07, 0x70, 0x00, 0x00, 0x03,
- 0xc0, 0x00, 0xc4, 0x46, 0x80, 0x01, 0xc0, 0x00, 0x80, 0x01, 0x80, 0x03,
- 0x44, 0x44, 0xe0, 0x00, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x0e, 0x44, 0x44,
- 0x30, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x18, 0x44, 0x44, 0x18, 0x00,
- 0x07, 0x06, 0x20, 0xe0, 0x3f, 0x30, 0xc4, 0x46, 0x0c, 0xf8, 0x1d, 0x04,
- 0x30, 0x30, 0x60, 0x60, 0x8c, 0x63, 0x06, 0x0c, 0x30, 0x0c, 0x10, 0x18,
- 0xc0, 0xc1, 0x08, 0x20, 0x82, 0x03, 0x20, 0x0c, 0x10, 0x0c, 0x00, 0x83,
- 0x09, 0x20, 0xc3, 0x00, 0x60, 0x08, 0x18, 0x04, 0x00, 0x02, 0x8b, 0xa3,
- 0x41, 0x00, 0x40, 0x18, 0x08, 0x06, 0x00, 0x06, 0x7a, 0xb6, 0x20, 0x00,
- 0xc0, 0x10, 0x08, 0x02, 0x00, 0x0c, 0x3e, 0x7c, 0x30, 0x00, 0x80, 0x10,
- 0x08, 0x02, 0x00, 0x18, 0x18, 0x18, 0x10, 0x00, 0x80, 0x10, 0x0c, 0x02,
- 0x00, 0x30, 0x00, 0x00, 0x18, 0xc0, 0x83, 0x30, 0x04, 0xc3, 0x03, 0x20,
- 0x00, 0x01, 0x0c, 0xc2, 0x83, 0x20, 0x04, 0xc1, 0x03, 0x61, 0x80, 0x03,
- 0x06, 0xc6, 0x83, 0x20, 0x04, 0xc1, 0x83, 0x41, 0xc0, 0x07, 0x06, 0xc4,
- 0x83, 0x20, 0x04, 0xc1, 0x87, 0xc0, 0x80, 0x03, 0x03, 0xc4, 0x80, 0x20,
- 0x0c, 0x01, 0x84, 0x80, 0x00, 0x01, 0x01, 0x64, 0x80, 0x30, 0x08, 0x01,
- 0x44, 0x80, 0x01, 0x80, 0x01, 0x24, 0x86, 0x10, 0x08, 0x01, 0x4c, 0x00,
- 0x01, 0x80, 0x00, 0x34, 0x83, 0x10, 0x08, 0x61, 0x48, 0x00, 0x01, 0x80,
- 0x00, 0xd4, 0xc1, 0x10, 0x08, 0xc1, 0x59, 0x00, 0x03, 0x80, 0x00, 0x5c,
- 0x40, 0x10, 0x08, 0x01, 0x57, 0x00, 0x02, 0xc1, 0x00, 0x2c, 0x40, 0x10,
- 0x18, 0x02, 0x7c, 0x00, 0x82, 0x43, 0x00, 0x3c, 0x40, 0x18, 0x10, 0x02,
- 0x70, 0x00, 0xc6, 0x47, 0x00, 0x1c, 0x40, 0x18, 0x10, 0x02, 0x60, 0x00,
- 0x84, 0x43, 0x00, 0x0e, 0x60, 0x08, 0x10, 0x06, 0x40, 0x00, 0x04, 0x41,
- 0x00, 0x02, 0x20, 0x08, 0x10, 0x04, 0xc0, 0x00, 0x0c, 0x60, 0x00, 0x02,
- 0x20, 0x0c, 0x30, 0x0c, 0x80, 0x00, 0x08, 0x20, 0x00, 0x03, 0x20, 0x0c,
- 0x20, 0x08, 0x80, 0x01, 0x08, 0x20, 0x00, 0x01, 0x20, 0x04, 0x20, 0x08,
- 0x00, 0x01, 0x08, 0x20, 0x80, 0x01, 0x30, 0x04, 0x60, 0x18, 0x00, 0x01,
- 0x08, 0x20, 0x80, 0x00, 0x10, 0x06, 0x40, 0x10, 0x00, 0x03, 0x10, 0x11,
- 0x80, 0x00, 0x18, 0x02, 0xc0, 0x30, 0x00, 0x02, 0x90, 0x13, 0xc0, 0x00,
- 0x08, 0x03, 0x80, 0x20, 0x00, 0x06, 0x10, 0x11, 0x40, 0x00, 0x04, 0x01,
- 0x80, 0x61, 0x00, 0x04, 0x10, 0x10, 0x60, 0x00, 0x84, 0x01, 0x00, 0x41,
- 0x00, 0x04, 0x10, 0x10, 0x20, 0x00, 0xc6, 0x00, 0x00, 0x83, 0x00, 0x0c,
- 0x10, 0x10, 0x20, 0x00, 0x41, 0x00, 0x00, 0x82, 0x01, 0x00, 0x10, 0x10,
- 0x00, 0x80, 0x61, 0x00, 0x00, 0x06, 0x01, 0x00, 0x10, 0x10, 0x00, 0x80,
- 0x30, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x10, 0x10, 0x00, 0xc0, 0x10, 0x00,
- 0x00, 0x18, 0x02, 0xff, 0x1f, 0xf0, 0xff, 0x60, 0x18, 0x00, 0x00, 0x30,
- 0xfe, 0x01, 0x00, 0x00, 0x80, 0x3f, 0x0c, 0x00, 0x00, 0x20, 0x00, 0x40,
- 0x08, 0x21, 0x04, 0x00, 0x06, 0x00, 0x00, 0xc0, 0x00, 0xe2, 0x9c, 0x73,
- 0x8e, 0x00, 0x03, 0x00, 0x00, 0x80, 0x11, 0x47, 0x08, 0x21, 0xc4, 0x11,
- 0x01, 0x00, 0x00, 0x00, 0x3b, 0x02, 0x00, 0x00, 0x80, 0xb8, 0x00, 0x00,
- 0x00, 0x00, 0x12, 0x00, 0xff, 0xff, 0x03, 0x90, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0xfc, 0x01, 0x00, 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x07,
- 0x80, 0x03, 0x80, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xe0, 0x0f,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0xf8, 0x3f, 0x00, 0x5c,
- 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0xe0, 0x0f, 0x00, 0x5f, 0x00, 0x00,
- 0x00, 0x00, 0xfa, 0x03, 0x80, 0x03, 0xc0, 0x5f, 0x00, 0x00, 0x00, 0x00,
- 0xfa, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00,
- 0xff, 0xff, 0x03, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfc, 0x01, 0x00,
- 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x07, 0x00, 0x00, 0x80, 0x5f,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_small.bitmap b/gnu/games/chess/Xchess/king_small.bitmap
deleted file mode 100644
index 38bb2b7..0000000
--- a/gnu/games/chess/Xchess/king_small.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define king_small_width 32
-#define king_small_height 32
-static char king_small_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0x00, 0x00, 0x80, 0x9f, 0x00, 0x00, 0x70, 0x20, 0x00,
- 0x00, 0x0c, 0x40, 0x00, 0x00, 0x02, 0x80, 0x01, 0x80, 0x01, 0x00, 0x03,
- 0x40, 0x00, 0x00, 0x06, 0x40, 0x60, 0x30, 0x08, 0x20, 0x60, 0x30, 0x10,
- 0x20, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x80,
- 0x10, 0x00, 0x02, 0x80, 0x10, 0x00, 0x01, 0x80, 0x10, 0x01, 0x01, 0x80,
- 0x10, 0x03, 0x1f, 0x84, 0x10, 0x02, 0x00, 0x84, 0x10, 0x06, 0x00, 0x86,
- 0x20, 0x1c, 0x00, 0x42, 0x20, 0xf0, 0xff, 0x43, 0x20, 0x00, 0x00, 0x40,
- 0x40, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x20, 0x80, 0x01, 0x00, 0x18,
- 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_small_outline.bitmap b/gnu/games/chess/Xchess/king_small_outline.bitmap
deleted file mode 100644
index 18d569e..0000000
--- a/gnu/games/chess/Xchess/king_small_outline.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define king_small_outline_width 32
-#define king_small_outline_height 32
-static char king_small_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x90, 0x00, 0x06, 0x10, 0xb1, 0x00,
- 0x22, 0x12, 0xe1, 0x00, 0x24, 0x92, 0x9f, 0x00, 0x40, 0x72, 0xa0, 0x50,
- 0x04, 0x0e, 0x40, 0x50, 0x40, 0x02, 0x80, 0x71, 0xc8, 0x01, 0x00, 0x73,
- 0xd8, 0x00, 0x00, 0x46, 0xd8, 0x60, 0x30, 0x08, 0xa0, 0x60, 0x30, 0x10,
- 0x20, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x80,
- 0x10, 0x00, 0x02, 0x80, 0x10, 0x00, 0x01, 0x80, 0x10, 0x01, 0x01, 0x80,
- 0x10, 0x03, 0x1f, 0x84, 0x10, 0x02, 0x00, 0x84, 0x10, 0x06, 0x00, 0x86,
- 0x20, 0x1c, 0x00, 0x42, 0x20, 0xf0, 0xff, 0x43, 0x20, 0x00, 0x00, 0x40,
- 0x40, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x20, 0x80, 0x01, 0x00, 0x18,
- 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight.bitmap b/gnu/games/chess/Xchess/knight.bitmap
deleted file mode 100644
index c5b1de1..0000000
--- a/gnu/games/chess/Xchess/knight.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define knight_width 80
-#define knight_height 80
-static char knight_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x18, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
- 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xbf, 0xff,
- 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0xfe, 0x0f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xf8, 0xff, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0x0f, 0xfc, 0xe3, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf0, 0xe1, 0xf3, 0xcf, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfd,
- 0xff, 0x1f, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0xfe, 0x7f,
- 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xff, 0x1f, 0xfe, 0xff, 0xfc, 0x07,
- 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x7f, 0x00, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x1f, 0x00, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff,
- 0xff, 0xff, 0x9f, 0x3f, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
- 0x3f, 0xff, 0x07, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe,
- 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0x07, 0x00,
- 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xfd, 0x01, 0x00, 0x00, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0xff, 0xfb, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff,
- 0xff, 0xbf, 0xff, 0xf3, 0x03, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x9f,
- 0xff, 0xf7, 0x3f, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xef,
- 0x07, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0xf3, 0xff, 0xcf, 0x7f, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0x1f, 0xfd, 0xff, 0xdf, 0x07, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0x83, 0xff, 0xf3, 0x9f, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x7f,
- 0x80, 0xff, 0xf9, 0xbf, 0x0f, 0x00, 0xf0, 0xff, 0xff, 0x00, 0x80, 0x7f,
- 0xfc, 0x7f, 0xff, 0x01, 0xf8, 0x3f, 0x7f, 0x00, 0x80, 0x81, 0xff, 0x7f,
- 0x1e, 0x00, 0x18, 0x9f, 0x3f, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0xfe, 0x07,
- 0x98, 0x8f, 0x1f, 0x00, 0xc0, 0xff, 0xcf, 0x7f, 0x3e, 0x00, 0xf8, 0x87,
- 0x0f, 0x00, 0xe0, 0xff, 0xe3, 0xff, 0xfe, 0x07, 0xf0, 0xc3, 0x07, 0x00,
- 0xf0, 0x1f, 0xfc, 0xff, 0x3c, 0x00, 0xf0, 0xe1, 0x03, 0x00, 0xf0, 0xc0,
- 0xff, 0xff, 0xfc, 0x0f, 0x60, 0xe0, 0x01, 0x00, 0xf8, 0xff, 0xff, 0xff,
- 0x7c, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0x0f,
- 0x00, 0x70, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xf9, 0x0f, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
- 0xff, 0xff, 0xf9, 0x0f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
- 0xf9, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x1f,
- 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x01, 0x00, 0x00,
- 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x3f, 0x00, 0x00, 0x00, 0xf0,
- 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
- 0xf3, 0x01, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
- 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00,
- 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x00, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xf3, 0x01, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
- 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xf3, 0x01, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
- 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00,
- 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xfc, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xf3, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_mask.bitmap b/gnu/games/chess/Xchess/knight_mask.bitmap
deleted file mode 100644
index 97d288c..0000000
--- a/gnu/games/chess/Xchess/knight_mask.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define knight_mask_width 80
-#define knight_mask_height 80
-static char knight_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x0f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x7f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00,
- 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfc, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
- 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x7f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
- 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf8, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf8, 0xff, 0xff, 0xff,
- 0xc7, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfc, 0xff, 0xff, 0xff, 0xc1, 0xff,
- 0xff, 0xff, 0xff, 0x03, 0xfc, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0xff,
- 0xff, 0x0f, 0xfc, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x0f,
- 0xfc, 0xff, 0x7f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xdf,
- 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xef, 0x1f, 0x00,
- 0xf8, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xf7, 0x0f, 0x00, 0xfc, 0xff,
- 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xfb, 0x07, 0x00, 0xfc, 0xff, 0xff, 0xff,
- 0xff, 0x1f, 0xf0, 0xf9, 0x03, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0x00, 0xf8, 0x01, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xf8,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x1f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
- 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfc,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
- 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
- 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
- 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
- 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
- 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_outline.bitmap b/gnu/games/chess/Xchess/knight_outline.bitmap
deleted file mode 100644
index a1ab938..0000000
--- a/gnu/games/chess/Xchess/knight_outline.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define knight_outline_width 80
-#define knight_outline_height 80
-static char knight_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x18, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
- 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf9, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x0f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x20, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x20, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
- 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x80,
- 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xf0, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x30, 0x58, 0x07, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x18, 0x4c,
- 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x78, 0x07, 0x00,
- 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x23, 0xe0, 0x01, 0x00, 0x00, 0x04,
- 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00,
- 0x00, 0xc0, 0x08, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x60,
- 0x04, 0x00, 0x00, 0x40, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x30, 0x02, 0x00,
- 0x00, 0x60, 0x00, 0x20, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x20,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80,
- 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80, 0x07, 0x00,
- 0x00, 0x26, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x13,
- 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x1f, 0x00, 0x00, 0x09, 0x40, 0x00,
- 0x00, 0x18, 0x08, 0x00, 0x02, 0x00, 0x80, 0x05, 0xc0, 0x00, 0x00, 0x0c,
- 0x0c, 0x00, 0x3e, 0x00, 0x80, 0x00, 0x80, 0x00, 0xc0, 0x03, 0x06, 0x00,
- 0x04, 0x00, 0xc0, 0x00, 0x80, 0x01, 0x70, 0x01, 0xc3, 0x00, 0x7c, 0x00,
- 0x60, 0x00, 0x00, 0x03, 0x1e, 0x81, 0x41, 0x00, 0x04, 0x00, 0x20, 0x00,
- 0x00, 0xce, 0x83, 0x61, 0x60, 0x00, 0xfc, 0x00, 0x30, 0x00, 0x80, 0x7f,
- 0x80, 0x1c, 0x30, 0x00, 0x08, 0x00, 0x10, 0xe0, 0xc1, 0x00, 0x80, 0x07,
- 0x10, 0x00, 0xf8, 0x01, 0x18, 0x30, 0x61, 0x00, 0x80, 0x00, 0x08, 0x00,
- 0x10, 0x00, 0x08, 0x98, 0x31, 0x00, 0xc0, 0x00, 0x0c, 0x00, 0xf0, 0x07,
- 0x08, 0x8c, 0x18, 0x00, 0x40, 0x00, 0x03, 0x00, 0x20, 0x00, 0x18, 0x86,
- 0x0c, 0x00, 0x60, 0xc0, 0x01, 0x00, 0xe0, 0x07, 0x10, 0xc3, 0x06, 0x00,
- 0x30, 0x30, 0x00, 0x00, 0x20, 0x00, 0xf0, 0x61, 0x02, 0x00, 0x10, 0x1e,
- 0x00, 0x00, 0xe0, 0x0f, 0x60, 0x30, 0x02, 0x00, 0x98, 0x03, 0x00, 0x00,
- 0x40, 0x00, 0x00, 0x10, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0x0f,
- 0x00, 0xb0, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xc0,
- 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
- 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f,
- 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x30,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
- 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
- 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x20, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
- 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_small.bitmap b/gnu/games/chess/Xchess/knight_small.bitmap
deleted file mode 100644
index 77c7451..0000000
--- a/gnu/games/chess/Xchess/knight_small.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define knight_small_width 32
-#define knight_small_height 32
-static char knight_small_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0xee, 0x7f, 0x02,
- 0x00, 0xfe, 0x7f, 0x01, 0x00, 0xff, 0xff, 0x04, 0x00, 0xff, 0xff, 0x02,
- 0x80, 0xff, 0xff, 0x09, 0xc0, 0xfc, 0xff, 0x07, 0xe0, 0xfc, 0xff, 0x11,
- 0xe0, 0xff, 0xff, 0x0d, 0xe0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x3f,
- 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x07,
- 0xfc, 0xc7, 0xff, 0x7f, 0xfe, 0xc1, 0xff, 0x07, 0xfa, 0xc1, 0xff, 0x7f,
- 0xce, 0xc0, 0xff, 0x07, 0x6c, 0xc0, 0xff, 0x7f, 0x28, 0xe0, 0xff, 0x07,
- 0x00, 0xe0, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x7f,
- 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x7f, 0x00, 0xf8, 0xff, 0x0f,
- 0x00, 0xf8, 0xff, 0x7f, 0x00, 0xfc, 0xff, 0x0f, 0x00, 0xff, 0xff, 0x7f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_small_outline.bitmap b/gnu/games/chess/Xchess/knight_small_outline.bitmap
deleted file mode 100644
index c0e738c..0000000
--- a/gnu/games/chess/Xchess/knight_small_outline.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define knight_small_outline_width 32
-#define knight_small_outline_height 32
-static char knight_small_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0xee, 0x7f, 0x02,
- 0x00, 0x3a, 0x40, 0x01, 0x00, 0x03, 0xc0, 0x04, 0x00, 0x01, 0x80, 0x02,
- 0x80, 0x01, 0x80, 0x09, 0xc0, 0x0c, 0x00, 0x07, 0x60, 0x0c, 0x00, 0x11,
- 0x20, 0x00, 0x00, 0x0d, 0x20, 0x00, 0x00, 0x03, 0x30, 0x00, 0x00, 0x3e,
- 0x10, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x7e, 0x18, 0x7c, 0x00, 0x04,
- 0x0c, 0x47, 0x00, 0x7c, 0x06, 0x41, 0x00, 0x04, 0xf2, 0x41, 0x00, 0x7c,
- 0xde, 0x40, 0x00, 0x04, 0x6c, 0x40, 0x00, 0x7c, 0x28, 0x60, 0x00, 0x04,
- 0x00, 0x20, 0x00, 0x7c, 0x00, 0x20, 0x00, 0x08, 0x00, 0x30, 0x00, 0x78,
- 0x00, 0x10, 0x00, 0x08, 0x00, 0x10, 0x00, 0x78, 0x00, 0x18, 0x00, 0x08,
- 0x00, 0x08, 0x00, 0x78, 0x00, 0x0c, 0x00, 0x08, 0x00, 0xff, 0xff, 0x7f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/message.c b/gnu/games/chess/Xchess/message.c
deleted file mode 100644
index 8b85e9c..0000000
--- a/gnu/games/chess/Xchess/message.c
+++ /dev/null
@@ -1,101 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/26 12:10:22 $
- * $Source: /users/faustus/xchess/RCS/message.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Do stuff with the message window. Font 0 is the normal font, font 1
- * is large, and font 2 is normal red.
- */
-
-#include "xchess.h"
-
-#define MESSAGE_HEADER "\n1 XChess Messages0\n"
-
-void
-message_init(win)
- windata *win;
-{
- TxtGrab(win->display, win->messagewin, "xchess", win->medium,
- win->textback.pixel, win->textcolor.pixel,
- win->cursorcolor.pixel);
- TxtAddFont(win->display, win->messagewin, 1, win->large, win->textcolor.pixel);
- TxtAddFont(win->display, win->messagewin, 2, win->medium, win->errortext.pixel);
- TxtAddFont(win->display, win->messagewin, 3, win->medium, win->playertext.pixel);
-
- TxtWriteStr(win->display, win->messagewin, MESSAGE_HEADER);
- return;
-}
-
-void
-message_add(win, string, err)
- windata *win;
- char *string;
- bool err;
-{
- if (err) {
- TxtWriteStr(win->display, win->messagewin, "2");
- TxtWriteStr(win->display, win->messagewin, string);
- TxtWriteStr(win->display, win->messagewin, "0");
- XBell(win->display, 50);
- } else
- TxtWriteStr(win->display, win->messagewin, string);
-
- XSync(win->display, 0);
- return;
-}
-
-void
-message_send(win, event)
- windata *win;
- XEvent *event;
-{
- XKeyEvent *ev = &event->xkey;
- KeySym keysym;
- windata *ow = (win == win1) ? win2 : win1;
- char buf[BSIZE], *s;
- int i;
-
- i = XLookupString(ev, buf, sizeof(buf) - 1, &keysym, &s);
- buf[i] = '\0';
- for (s = buf; *s; s++)
- if (*s == '\r')
- *s = '\n';
- else if (*s == '\177')
- *s = '';
-
- TxtWriteStr(win->display, win->messagewin, "3");
- TxtWriteStr(win->display, win->messagewin, buf);
- TxtWriteStr(win->display, win->messagewin, "0");
- XSync(win->display, 0);
- if (ow) {
- TxtWriteStr(ow->display, ow->messagewin, "3");
- TxtWriteStr(ow->display, ow->messagewin, buf);
- TxtWriteStr(ow->display, ow->messagewin, "0");
- XSync(ow->display, 0);
- }
- return;
-}
-
diff --git a/gnu/games/chess/Xchess/parse.c b/gnu/games/chess/Xchess/parse.c
deleted file mode 100644
index c66cc38..0000000
--- a/gnu/games/chess/Xchess/parse.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:17:59 $
- * $Source: /users/faustus/xchess/RCS/parse.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Parse a sequence of chess moves...
- */
-
-#include "xchess.h"
-
-bool loading_flag = false;
-bool loading_paused = false;
-
-static char *line;
-
-/* Load a record file in. This returns a number of things -- the board, the
- * list of moves, and whose turn it is.
- */
-
-void
-load_game(file)
- char *file;
-{
- FILE *fp;
- char buf[BSIZE];
- bool eflag;
- move *m;
- board *tmpboard = alloc(board);
-
- if (eq(file, "xchess.game") && saveflag) {
- message_add(win1,
- "Oops, I just overwrote the\nfile xchess.game...\n",
- true);
- message_add(win1, "I hope you had another copy.\n", true);
- return;
- }
- if (!(fp = fopen(file, "r"))) {
- perror(file);
- return;
- }
-
- /* Get a few lines... */
- fgets(buf, BSIZE, fp);
- message_add(win1, buf, false);
- if (!oneboard)
- message_add(win2, buf, false);
-
- fgets(buf, BSIZE, fp);
- message_add(win1, buf, false);
- if (!oneboard)
- message_add(win2, buf, false);
-
- fgets(buf, BSIZE, fp);
- if (eq(buf, "\tenglish\n"))
- eflag = true;
- else if (eq(buf, "\talgebraic\n"))
- eflag = false;
- else {
- fprintf(stderr, "Can't decide whether this is english...\n");
- return;
- }
-
- board_init(tmpboard);
- line = NULL;
- m = parse_file(fp, tmpboard, eflag);
- tfree(tmpboard);
-
- /* Now apply these moves to the board we were given... */
- loading_flag = true;
- while (m) {
- if (!quickflag)
- XSync(win1->display, 0);
- win_process(true);
- if (!quickflag)
- sleep(1);
- if (!loading_paused) {
- prog_move(m);
- m = m->next;
- }
- }
- loading_flag = false;
- if (line)
- message_add(win1, line, false);
-
- while (fgets(buf, BSIZE, fp))
- message_add(win1, buf, false);
-
- fclose(fp);
-
- return;
-}
-
-/* Given a starting position (usually the beginning board configuration),
- * read in a file of moves.
- */
-
-move *
-parse_file(fp, b, english)
- FILE *fp;
- board *b;
- bool english;
-{
- move *mvs = NULL, *end = NULL;
- char buf[BSIZE], *s, *t;
-
- while (fgets(buf, BSIZE, fp)) {
- if (*buf == '#')
- continue;
- s = buf;
-
- /* The move number... */
- if (!(t = gettok(&s)))
- break;
- if (!isdigit(*t)) {
- line = copy(buf);
- break;
- }
-
- if (!(t = gettok(&s)))
- break;
- if (end)
- end = end->next = (english ? parse_move(b, t, WHITE) :
- parse_imove(b, t, WHITE));
- else
- mvs = end = (english ? parse_move(b, t, WHITE) :
- parse_imove(b, t, WHITE));
- if (!end) {
- fprintf(stderr, "Can't parse %s\n", buf);
- return (NULL);
- }
- board_move(b, end);
-
- if (!(t = gettok(&s)))
- break;
- if (end)
- end = end->next = (english ? parse_move(b, t, BLACK) :
- parse_imove(b, t, BLACK));
- else
- mvs = end = (english ? parse_move(b, t, BLACK) :
- parse_imove(b, t, BLACK));
- if (!end) {
- fprintf(stderr, "Can't parse %s\n", buf);
- return (NULL);
- }
- board_move(b, end);
- }
-
- return (mvs);
-}
-
-/* Parse a move. The move format accepted is as follows -
- * move: spec-spec
- * capture: specxspec
- * kcastle: 2 o's
- * qcastle: 3 o's
- * A spec is either piece/pos, piece, or just pos. A pos consists of a column
- * name followed by a row number. If the column name is kr, kn, kb, k, q,
- * qb, qn, or qr, then the row number is according to the english system,
- * or if it is a-h then it is according to the international system.
- *
- *** As of now the spec must include the position.
- */
-
-move *
-parse_move(b, str, w)
- board *b;
- char *str;
- color w;
-{
- move *m = alloc(move);
- char *s;
- char spec1[16], spec2[16];
- int i, j;
-
-if (debug) fprintf(stderr, "parsing %s\n", str);
-
- /* Check for castles. */
- for (s = str, i = 0; *s; s++)
- if ((*s == 'o') || (*s == 'O'))
- i++;
- if (i == 2) {
- m->type = KCASTLE;
- m->piece.type = KING;
- m->piece.color = w;
- return (m);
- } else if (i == 3) {
- m->type = QCASTLE;
- m->piece.type = KING;
- m->piece.color = w;
- return (m);
- }
- if (index(str, '-'))
- m->type = MOVE;
- else if (index(str, 'x'))
- m->type = CAPTURE;
- else
- return (NULL);
- for (i = 0; str[i]; i++)
- if ((str[i] == 'x') || (str[i] == '-'))
- break;
- else
- spec1[i] = str[i];
- spec1[i] = '\0';
- for (i++, j = 0; str[i]; i++, j++)
- if ((str[i] == 'x') || (str[i] == '-'))
- break;
- else
- spec2[j] = str[i];
- spec2[j] = '\0';
-
- /* Now decode the specifications. */
- s = spec1;
- switch (*s) {
- case 'p': case 'P':
- m->piece.type = PAWN; break;
- case 'r': case 'R':
- m->piece.type = ROOK; break;
- case 'n': case 'N':
- m->piece.type = KNIGHT; break;
- case 'b': case 'B':
- m->piece.type = BISHOP; break;
- case 'q': case 'Q':
- m->piece.type = QUEEN; break;
- case 'k': case 'K':
- m->piece.type = KING; break;
- default:
- return (NULL);
- }
- m->piece.color = w;
- s += 2;
-
- /* Now get the {q,k}{,b,n,r}n string... */
- if ((s[0] == 'q') && (s[1] == 'r'))
- m->fromx = 0, s += 2;
- else if ((s[0] == 'q') && (s[1] == 'n'))
- m->fromx = 1, s += 2;
- else if ((s[0] == 'q') && (s[1] == 'b'))
- m->fromx = 2, s += 2;
- else if ((s[0] == 'q') && isdigit(s[1]))
- m->fromx = 3, s += 1;
- else if ((s[0] == 'k') && isdigit(s[1]))
- m->fromx = 4, s += 1;
- else if ((s[0] == 'k') && (s[1] == 'b'))
- m->fromx = 5, s += 2;
- else if ((s[0] == 'k') && (s[1] == 'n'))
- m->fromx = 6, s += 2;
- else if ((s[0] == 'k') && (s[1] == 'r'))
- m->fromx = 7, s += 2;
- m->fromy = ((w == WHITE) ? (SIZE - atoi(s)) : (atoi(s) - 1));
-
- if ((b->square[m->fromy][m->fromx].color != w) ||
- (b->square[m->fromy][m->fromx].type != m->piece.type)) {
- fprintf(stderr, "Error: bad stuff\n");
- return (NULL);
- }
-
- s = spec2;
- if (m->type == CAPTURE) {
- switch (*s) {
- case 'p': case 'P':
- m->taken.type = PAWN; break;
- case 'r': case 'R':
- m->taken.type = ROOK; break;
- case 'n': case 'N':
- m->taken.type = KNIGHT; break;
- case 'b': case 'B':
- m->taken.type = BISHOP; break;
- case 'q': case 'Q':
- m->taken.type = QUEEN; break;
- case 'k': case 'K':
- m->taken.type = KING; break;
- default:
- return (NULL);
- }
- m->taken.color = ((w == WHITE) ? BLACK : WHITE);
- s += 2;
- }
-
- /* Now get the {q,k}{,b,n,r}n string... */
- if ((s[0] == 'q') && (s[1] == 'r'))
- m->tox = 0, s += 2;
- else if ((s[0] == 'q') && (s[1] == 'n'))
- m->tox = 1, s += 2;
- else if ((s[0] == 'q') && (s[1] == 'b'))
- m->tox = 2, s += 2;
- else if ((s[0] == 'q') && isdigit(s[1]))
- m->tox = 3, s += 1;
- else if ((s[0] == 'k') && isdigit(s[1]))
- m->tox = 4, s += 1;
- else if ((s[0] == 'k') && (s[1] == 'b'))
- m->tox = 5, s += 2;
- else if ((s[0] == 'k') && (s[1] == 'n'))
- m->tox = 6, s += 2;
- else if ((s[0] == 'k') && (s[1] == 'r'))
- m->tox = 7, s += 2;
- m->toy = ((w == WHITE) ? (SIZE - atoi(s)) : (atoi(s) - 1));
-
- if ((m->type == CAPTURE) && ((b->square[m->toy][m->tox].color !=
- m->taken.color) || (b->square[m->toy][m->tox].type !=
- m->taken.type))) {
- fprintf(stderr, "Error: bad stuff\n");
- return (NULL);
- }
-
- return (m);
-}
-
-/* Parse an algebraic notation move. This is a lot easier... */
-
-move *
-parse_imove(b, buf, w)
- board *b;
- char *buf;
- color w;
-{
- char *s;
- move *m = alloc(move);
- int n;
-
-if (debug) fprintf(stderr, "(alg) parsing %s\n", buf);
-
- for (s = buf, n = 0; *s; s++)
- if ((*s == 'o') || (*s == 'O'))
- n++;
- s = buf;
-
- if (n == 2)
- m->type = KCASTLE;
- else if (n == 3)
- m->type = QCASTLE;
- else {
- m->fromx = *s++ - 'a';
- m->fromy = SIZE - (*s++ - '0');
- m->tox = *s++ - 'a';
- m->toy = SIZE - (*s++ - '0');
- m->piece = b->square[m->fromy][m->fromx];
- m->taken = b->square[m->toy][m->tox];
- if (m->taken.color == NONE)
- m->type = MOVE;
- else
- m->type = CAPTURE;
- /* for pawns we must account for en passant */
- if (m->piece.type == PAWN) {
- if (m->type == MOVE && m->fromx != m->tox) {
- m->enpassant = 1;
- m->type = CAPTURE;
- }
- }
- }
-
- if (m->piece.color != w) {
- fprintf(stderr, "Error: parse_imove: piece of wrong color!\n");
- return (NULL);
- }
- if ((m->piece.type == KING) && (m->fromy == m->toy) && (m->fromx == 4)
- && (m->tox == 6))
- m->type = KCASTLE;
- else if ((m->piece.type == KING) && (m->fromy == m->toy) &&
- (m->fromx == 4) && (m->tox == 2))
- m->type = QCASTLE;
-
- return (m);
-}
-
diff --git a/gnu/games/chess/Xchess/pawn.bitmap b/gnu/games/chess/Xchess/pawn.bitmap
deleted file mode 100644
index 5c3ff76..0000000
--- a/gnu/games/chess/Xchess/pawn.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define pawn_width 80
-#define pawn_height 80
-static char pawn_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
- 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
- 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
- 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00,
- 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00,
- 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x1f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_mask.bitmap b/gnu/games/chess/Xchess/pawn_mask.bitmap
deleted file mode 100644
index 724875c..0000000
--- a/gnu/games/chess/Xchess/pawn_mask.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define pawn_mask_width 80
-#define pawn_mask_height 80
-static char pawn_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff,
- 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
- 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
- 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff,
- 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
- 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
- 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x0f,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf0, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_outline.bitmap b/gnu/games/chess/Xchess/pawn_outline.bitmap
deleted file mode 100644
index 0c4a3a1..0000000
--- a/gnu/games/chess/Xchess/pawn_outline.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define pawn_outline_width 80
-#define pawn_outline_height 80
-static char pawn_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
- 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x78, 0xc0, 0x81, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x07, 0xc0, 0x7f, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
- 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
- 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x18, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_small.bitmap b/gnu/games/chess/Xchess/pawn_small.bitmap
deleted file mode 100644
index 88ff7bb..0000000
--- a/gnu/games/chess/Xchess/pawn_small.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define pawn_small_width 32
-#define pawn_small_height 32
-static char pawn_small_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x0f, 0x00,
- 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00,
- 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf0, 0x0f, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x80, 0xff, 0xff, 0x01,
- 0x80, 0xff, 0xff, 0x01, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xfc, 0x3f, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x0f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_small_outline.bitmap b/gnu/games/chess/Xchess/pawn_small_outline.bitmap
deleted file mode 100644
index e860f43..0000000
--- a/gnu/games/chess/Xchess/pawn_small_outline.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define pawn_small_outline_width 32
-#define pawn_small_outline_height 32
-static char pawn_small_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x30, 0x0c, 0x00,
- 0x00, 0x18, 0x18, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00,
- 0x00, 0x08, 0x10, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x30, 0x0c, 0x00,
- 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x80, 0x3f, 0xfc, 0x01,
- 0x80, 0x3f, 0xfc, 0x01, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
- 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
- 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
- 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
- 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x0c, 0x30, 0x00,
- 0x00, 0x07, 0xe0, 0x00, 0xe0, 0x01, 0x80, 0x07, 0xf0, 0xff, 0xff, 0x0f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/popup.c b/gnu/games/chess/Xchess/popup.c
deleted file mode 100644
index 2e19ee5..0000000
--- a/gnu/games/chess/Xchess/popup.c
+++ /dev/null
@@ -1,112 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/26 12:10:38 $
- * $Source: /users/faustus/xchess/RCS/popup.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * faustus@cad.berkeley.edu, ucbvax!faustus
- * Permission is granted to modify and re-distribute this code in any manner
- * as long as this notice is preserved. All standard disclaimers apply.
- *
- * A simple pop-up menu system.
- */
-
-#include "xchess.h"
-
-/* Open a small window with some text in it and two buttons -- yes and no.
- * Use black and white pixel, and the medium font.
- */
-
-bool
-pop_question(win, text)
- windata *win;
- char *text;
-{
- char *s, *t;
- int nlines = 1, ncols = 0, i = 0, j;
- int x, y;
- Window w;
- bool ch;
- XEvent ev;
-
- for (s = text; *s; s++) {
- if ((*s == '\n') && s[1])
- nlines++;
- if ((*s == '\n') || !s[1]) {
- if (i > ncols)
- ncols = i;
- i = 0;
- } else
- i++;
- }
-
- if (ncols < 12)
- ncols = 12;
- nlines += 4;
- ncols += 4;
-
- x = (BASE_WIDTH - ncols * win->medium->max_bounds.width) / 2;
- y = (BASE_HEIGHT - nlines * win->medium->max_bounds.ascent) / 2;
-
- w = XCreateSimpleWindow(win->display, win->basewin,
- x, y, ncols * win->medium->max_bounds.width,
- nlines * win->medium->ascent,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- XMapRaised(win->display, w);
- XSetFont(win->display, DefaultGC(win->display, 0),
- win->medium->fid);
-
- for (i = 0, s = text; i < nlines - 4; i++) {
- for (t = s, j = 0; *t && (*t != '\n'); t++, j++)
- ;
- XDrawString(win->display, w, DefaultGC(win->display, 0),
- (ncols - j) / 2 * win->medium->max_bounds.width,
- (i + 1) * win->medium->ascent,
- s, j);
- s = t + 1;
- }
- XDrawString(win->display, w, DefaultGC(win->display, 0),
- (ncols - 8) * win->medium->max_bounds.width / 4,
- (nlines - 2) * win->medium->ascent,
- "YES", 3);
- XDrawString(win->display, w, DefaultGC(win->display, 0),
- (ncols - 4) * win->medium->max_bounds.width * 3 / 4,
- (nlines - 2) * win->medium->ascent,
- "NO", 2);
-
- XSync(win->display, 0);
- XSelectInput(win->display, w, ButtonPressMask);
- XWindowEvent(win->display, w, ButtonPressMask, &ev);
- x = ev.xkey.x;
- y = ev.xkey.y;
-
- if (x > ncols * win->medium->max_bounds.width / 2)
- ch = false;
- else
- ch = true;
-
- XDestroyWindow(win->display, w);
- XSync(win->display, 0);
- return (ch);
-}
-
diff --git a/gnu/games/chess/Xchess/program.c b/gnu/games/chess/Xchess/program.c
deleted file mode 100644
index 876f29c..0000000
--- a/gnu/games/chess/Xchess/program.c
+++ /dev/null
@@ -1,200 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:18:10 $
- * $Source: /users/faustus/xchess/RCS/program.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * The interface to whichever chess playing program we are using...
- */
-
-#include "xchess.h"
-#include <signal.h>
-#include <sys/time.h>
-
-static int pid;
-static FILE *from;
-static FILE *to;
-static bool easy = 1;
-
-bool
-program_init(name)
- char *name;
-{
- int toprog[2], fromprog[2];
- char buf[BSIZE];
- char time[10];
- char moves[10];
-
- pipe(toprog);
- pipe(fromprog);
-
- if (!(pid = fork())) {
- /* Start up the program. */
- dup2(toprog[0], 0);
- dup2(fromprog[1], 1);
- close(toprog[0]);
- close(toprog[1]);
- close(fromprog[0]);
- close(fromprog[1]);
- sprintf (time, "%d", timeunit/60);
- sprintf (moves, "%d", movesperunit);
- if (proghost)
- execl("/usr/ucb/rsh", "rsh", proghost, name,
- moves, time,
- (char *) NULL);
- else
- execl(name, name, moves, time, (char *) NULL);
- perror(name);
- exit(1);
- }
-
- close(toprog[0]);
- close(fromprog[1]);
-
- from = fdopen(fromprog[0], "r");
- setbuf(from, NULL);
- to = fdopen(toprog[1], "w");
- setbuf(to, NULL);
-
- /* Get the first line... */
- fgets(buf, BSIZE, from);
- if (debug)
- fprintf(stderr, "program says %s", buf);
- if (blackflag) {
- fputs("switch\n", to);
- fflush(to);
- fgets(buf, BSIZE, from);
- if (debug)
- fprintf(stderr, "program says %s", buf);
- message_add(win1, "GNU Chess playing white\n", false);
- } else
- message_add(win1, "GNU Chess playing black\n", false);
-
- return (true);
-}
-
-void
-program_end()
-{
- fclose(from);
- fclose(to);
- kill(pid, SIGTERM);
- return;
-}
-
-void
-program_send(m)
- move *m;
-{
- char buf[BSIZE];
-
- if ((m->type == MOVE) || (m->type == CAPTURE))
- sprintf(buf, "%c%d%c%d\n", 'a' + m->fromx, SIZE - m->fromy,
- 'a' + m->tox, SIZE - m->toy);
- else if (m->type == KCASTLE)
- strcpy(buf, (m->piece.color == WHITE) ? "e1g1\n" : "e8g8\n");
- else if (m->type == QCASTLE)
- strcpy(buf, (m->piece.color == WHITE) ? "e1c1\n" : "e8c8\n");
-
- if (debug)
- fprintf(stderr, "sending program %s", buf);
- if (!easy)
- kill (pid, SIGINT);
-
- fputs(buf, to);
- fflush(to);
-
- /* One junk line... */
- fgets(buf, BSIZE, from);
- if (debug)
- fprintf(stderr, "program says %s", buf);
- return;
-}
-
-move *
-program_get()
-{
- int rfd = (1 << fileno(from)), wfd = 0, xfd = 0;
- static struct timeval notime = { 0, 0 };
- char buf[BSIZE], *s;
- move *m;
- int i;
-
- /* Do a poll... */
-
- if (!(i = select(32, &rfd, &wfd, &xfd, &notime)) &&
- !from->_cnt) { /* Bad stuff... */
- if (debug)
- fprintf(stderr, "poll: nothing\n");
- return (NULL);
- }
- if (i == -1) {
- perror("select");
- return (NULL);
- }
-
- fgets(buf, BSIZE, from);
- if (*buf == '\n' || *buf == '\0') {
- message_add(win1, "program died", false);
- return (NULL);
- }
-
- if (debug)
- fprintf(stderr, "got from program %s", buf);
-
- for (s = buf; !isalpha(*s); s++)
- ;
- m = parse_imove(chessboard, s, nexttomove);
- if (m == NULL)
- return (NULL);
-
- if (!valid_move(m, chessboard)) {
- fprintf(stderr, "Error: move %s is invalid!!\n", buf);
- return (NULL);
- }
-
- /*
- fgets(buf, BSIZE, from);
- if (debug)
- fprintf(stderr, "program says %s", buf);
- */
- message_add(win1, buf, false);
- return (m);
-}
-
-void
-program_undo()
-{
- fputs("undo\n", to);
- return;
-}
-void
-program_easy (mode)
- bool mode;
-
-{
- fputs("easy\n", to);
- easy = mode;
-}
diff --git a/gnu/games/chess/Xchess/queen.bitmap b/gnu/games/chess/Xchess/queen.bitmap
deleted file mode 100644
index ab3817a..0000000
--- a/gnu/games/chess/Xchess/queen.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define queen_width 80
-#define queen_height 80
-static char queen_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x80, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x80, 0x01, 0x00, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x80, 0x01, 0x80, 0x0f, 0x00, 0x00,
- 0x00, 0x00, 0xf0, 0x01, 0xc0, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0x00, 0xc0, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0xc0, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x01, 0xc0, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
- 0xe0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe0, 0x07,
- 0xc0, 0x03, 0x00, 0x00, 0x1c, 0x00, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03,
- 0x00, 0x00, 0x3e, 0x00, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03, 0x00, 0x0e,
- 0x3e, 0x00, 0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x3e, 0x00,
- 0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x3c, 0x00, 0xc0, 0x07,
- 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x70, 0x00, 0xc0, 0x0f, 0xe0, 0x07,
- 0xf0, 0x03, 0x00, 0x0e, 0x60, 0x00, 0xc0, 0x0f, 0xe0, 0x07, 0xf0, 0x03,
- 0x00, 0x03, 0xe0, 0x00, 0xc0, 0x0f, 0xf0, 0x0f, 0xf0, 0x03, 0x80, 0x03,
- 0xc0, 0x01, 0xc0, 0x1f, 0xf0, 0x0f, 0xf8, 0x03, 0x80, 0x01, 0xc0, 0x01,
- 0xc0, 0x1f, 0xf0, 0x0f, 0xf8, 0x03, 0xc0, 0x01, 0xc0, 0x03, 0xc0, 0x1f,
- 0xf0, 0x0f, 0xf8, 0x03, 0xe0, 0x01, 0xc0, 0x07, 0xc0, 0x1f, 0xf0, 0x0f,
- 0xf8, 0x03, 0xe0, 0x01, 0xc0, 0x07, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03,
- 0xf0, 0x01, 0xc0, 0x0f, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03, 0xf8, 0x01,
- 0x80, 0x1f, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03, 0xf8, 0x01, 0x80, 0x1f,
- 0xc0, 0x7f, 0xf0, 0x0f, 0xfe, 0x03, 0xfc, 0x01, 0x80, 0x3f, 0xc0, 0x7f,
- 0xf8, 0x1f, 0xfe, 0x03, 0xfc, 0x00, 0x80, 0x3f, 0xc0, 0x7f, 0xf8, 0x1f,
- 0xfe, 0x03, 0xfe, 0x00, 0x80, 0x7f, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x03,
- 0xff, 0x00, 0x80, 0xff, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x03, 0xff, 0x00,
- 0x00, 0xff, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x83, 0xff, 0x00, 0x00, 0xff,
- 0xc1, 0xff, 0xf9, 0x9f, 0xff, 0x83, 0xff, 0x00, 0x00, 0xff, 0xc3, 0xff,
- 0xf9, 0x9f, 0xff, 0xc3, 0xff, 0x00, 0x00, 0xff, 0xc3, 0xff, 0xf9, 0x9f,
- 0xff, 0xe3, 0x7f, 0x00, 0x00, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xe3,
- 0x7f, 0x00, 0x00, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x7f, 0x00,
- 0x00, 0xfe, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x7f, 0x00, 0x00, 0xfe,
- 0xdf, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01, 0x80,
- 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf8, 0xff, 0x03, 0xfc, 0x3f, 0xc0, 0xff,
- 0x1f, 0x00, 0x00, 0xf0, 0x01, 0xf8, 0x7f, 0xfe, 0x1f, 0x80, 0x1f, 0x00,
- 0x00, 0x30, 0xfc, 0xff, 0x1f, 0xf8, 0xff, 0x3f, 0x0c, 0x00, 0x00, 0xe0,
- 0xe7, 0xff, 0x07, 0xe0, 0xff, 0xe7, 0x07, 0x00, 0x00, 0xc0, 0x81, 0xff,
- 0x1f, 0xf8, 0xff, 0x81, 0x03, 0x00, 0x00, 0x80, 0x00, 0xfe, 0x7f, 0xfe,
- 0x7f, 0x00, 0x03, 0x00, 0x00, 0x80, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81,
- 0x01, 0x00, 0x00, 0x00, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xe7, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0x03, 0xfc, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x80,
- 0x01, 0xf8, 0xff, 0xff, 0x1f, 0x80, 0x01, 0x00, 0x00, 0x80, 0xfc, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x01, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_mask.bitmap b/gnu/games/chess/Xchess/queen_mask.bitmap
deleted file mode 100644
index 76a5904..0000000
--- a/gnu/games/chess/Xchess/queen_mask.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define queen_mask_width 80
-#define queen_mask_height 80
-static char queen_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x60, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01,
- 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03,
- 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, 0xc0, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xf8, 0x01, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01,
- 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xe0, 0x07,
- 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xe0, 0x07, 0x80, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0xe0, 0x07, 0x80, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0x03, 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0x07, 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
- 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x7e, 0x00, 0xe0, 0x07, 0xf0, 0x0f,
- 0xe0, 0x07, 0x00, 0x00, 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xe0, 0x07,
- 0x00, 0x1f, 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xe0, 0x07, 0x80, 0x3f,
- 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0x7f, 0x00,
- 0xe0, 0x0f, 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0xff, 0x00, 0xe0, 0x1f,
- 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0xfe, 0x00, 0xe0, 0x1f, 0xf0, 0x0f,
- 0xf8, 0x07, 0x80, 0x1f, 0xfc, 0x01, 0xe0, 0x1f, 0xf8, 0x1f, 0xf8, 0x07,
- 0x80, 0x1f, 0xf0, 0x03, 0xe0, 0x3f, 0xf8, 0x1f, 0xf8, 0x07, 0xc0, 0x0f,
- 0xf0, 0x07, 0xe0, 0x3f, 0xf8, 0x1f, 0xfc, 0x07, 0xe0, 0x03, 0xe0, 0x07,
- 0xe0, 0x3f, 0xf8, 0x1f, 0xfc, 0x07, 0xf0, 0x03, 0xe0, 0x0f, 0xe0, 0x7f,
- 0xf8, 0x1f, 0xfc, 0x07, 0xf0, 0x03, 0xe0, 0x1f, 0xe0, 0x7f, 0xf8, 0x1f,
- 0xfc, 0x07, 0xf8, 0x03, 0xe0, 0x1f, 0xe0, 0x7f, 0xf8, 0x1f, 0xfe, 0x07,
- 0xf8, 0x03, 0xe0, 0x3f, 0xe0, 0x7f, 0xf8, 0x1f, 0xfe, 0x07, 0xfc, 0x03,
- 0xe0, 0x3f, 0xe0, 0xff, 0xf8, 0x1f, 0xfe, 0x07, 0xfe, 0x03, 0xc0, 0x7f,
- 0xe0, 0xff, 0xfc, 0x3f, 0xff, 0x07, 0xfe, 0x03, 0xc0, 0xff, 0xe0, 0xff,
- 0xfd, 0x3f, 0xff, 0x07, 0xff, 0x03, 0xc0, 0xff, 0xe1, 0xff, 0xfd, 0xff,
- 0xff, 0x87, 0xff, 0x03, 0xc0, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0x87,
- 0xff, 0x01, 0xc0, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0x01,
- 0xc0, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0x01, 0x80, 0xff,
- 0xef, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xf7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
- 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
- 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf8,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x07, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
- 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_outline.bitmap b/gnu/games/chess/Xchess/queen_outline.bitmap
deleted file mode 100644
index 2527216..0000000
--- a/gnu/games/chess/Xchess/queen_outline.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define queen_outline_width 80
-#define queen_outline_height 80
-static char queen_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x80, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x80, 0x01, 0x00, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x80, 0x01, 0x80, 0x0d, 0x00, 0x00,
- 0x00, 0x00, 0xb0, 0x01, 0xc0, 0x03, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0x00, 0x40, 0x02, 0x80, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0x40, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0x01, 0x40, 0x02, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x01, 0x40, 0x02, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01,
- 0x60, 0x06, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x03, 0x20, 0x04,
- 0xc0, 0x02, 0x00, 0x00, 0x1c, 0x00, 0x40, 0x02, 0x20, 0x04, 0x40, 0x02,
- 0x00, 0x00, 0x36, 0x00, 0x40, 0x02, 0x20, 0x04, 0x40, 0x02, 0x00, 0x0e,
- 0x22, 0x00, 0x40, 0x06, 0x20, 0x04, 0x60, 0x02, 0x00, 0x1b, 0x36, 0x00,
- 0x40, 0x04, 0x20, 0x04, 0x20, 0x02, 0x00, 0x11, 0x3c, 0x00, 0x40, 0x04,
- 0x20, 0x04, 0x20, 0x02, 0x00, 0x1b, 0x70, 0x00, 0x40, 0x0c, 0x20, 0x04,
- 0x30, 0x02, 0x00, 0x0e, 0x60, 0x00, 0x40, 0x08, 0x20, 0x04, 0x10, 0x02,
- 0x00, 0x03, 0xe0, 0x00, 0x40, 0x08, 0x30, 0x0c, 0x10, 0x02, 0x80, 0x03,
- 0xc0, 0x01, 0x40, 0x18, 0x10, 0x08, 0x18, 0x02, 0x80, 0x01, 0x40, 0x01,
- 0x40, 0x10, 0x10, 0x08, 0x08, 0x02, 0xc0, 0x01, 0x40, 0x03, 0x40, 0x10,
- 0x10, 0x08, 0x08, 0x02, 0x60, 0x01, 0x40, 0x06, 0x40, 0x10, 0x10, 0x08,
- 0x08, 0x02, 0x20, 0x01, 0x40, 0x04, 0x40, 0x30, 0x10, 0x08, 0x0c, 0x02,
- 0x30, 0x01, 0xc0, 0x0c, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x18, 0x01,
- 0x80, 0x18, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x08, 0x01, 0x80, 0x10,
- 0x40, 0x60, 0x10, 0x08, 0x06, 0x02, 0x8c, 0x01, 0x80, 0x30, 0x40, 0x40,
- 0x18, 0x18, 0x02, 0x02, 0x84, 0x00, 0x80, 0x20, 0x40, 0x40, 0x08, 0x10,
- 0x02, 0x02, 0x86, 0x00, 0x80, 0x60, 0x40, 0xc0, 0x08, 0x10, 0x03, 0x02,
- 0x83, 0x00, 0x80, 0xc1, 0x40, 0x80, 0x08, 0x10, 0x01, 0x02, 0x81, 0x00,
- 0x00, 0x81, 0x40, 0x80, 0x08, 0x10, 0x01, 0x82, 0x81, 0x00, 0x00, 0x81,
- 0x41, 0x80, 0x09, 0x90, 0x01, 0x82, 0x80, 0x00, 0x00, 0x01, 0x43, 0x00,
- 0x09, 0x90, 0x00, 0xc2, 0xc0, 0x00, 0x00, 0x01, 0x42, 0x00, 0x09, 0x90,
- 0x00, 0x62, 0x40, 0x00, 0x00, 0x01, 0x46, 0x00, 0x0f, 0xf0, 0x00, 0x22,
- 0x40, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x32, 0x40, 0x00,
- 0x00, 0x02, 0x48, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x40, 0x00, 0x00, 0x02,
- 0x58, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x40, 0x00, 0x00, 0x02, 0x70, 0x00,
- 0x00, 0x00, 0x00, 0x0e, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x60, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0xfe, 0x7f,
- 0x00, 0x00, 0x30, 0x00, 0x00, 0x18, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00,
- 0x10, 0x00, 0x00, 0x10, 0xfe, 0x07, 0x80, 0x01, 0xe0, 0x7f, 0x18, 0x00,
- 0x00, 0x30, 0x03, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x60,
- 0x18, 0x00, 0xf8, 0x1f, 0x00, 0x18, 0x06, 0x00, 0x00, 0x40, 0x7e, 0x00,
- 0xe0, 0x07, 0x00, 0x7e, 0x02, 0x00, 0x00, 0x40, 0xff, 0x01, 0x80, 0x01,
- 0x80, 0xff, 0x02, 0x00, 0x00, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
- 0x02, 0x00, 0x00, 0xc0, 0x18, 0x00, 0xfe, 0x7f, 0x00, 0x18, 0x03, 0x00,
- 0x00, 0x80, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00, 0x01, 0x00, 0x00, 0x80,
- 0xfe, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x60,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xe0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_small.bitmap b/gnu/games/chess/Xchess/queen_small.bitmap
deleted file mode 100644
index d7ee50e..0000000
--- a/gnu/games/chess/Xchess/queen_small.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define queen_small_width 32
-#define queen_small_height 32
-static char queen_small_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00,
- 0x80, 0x81, 0xc0, 0x00, 0x80, 0x81, 0xc0, 0x00, 0x00, 0xc1, 0x41, 0x00,
- 0x00, 0xc1, 0x41, 0x00, 0x02, 0xc3, 0x61, 0x20, 0x06, 0xc3, 0x61, 0x30,
- 0x04, 0xc3, 0x61, 0x10, 0x0c, 0xc3, 0x61, 0x18, 0x08, 0xc7, 0x71, 0x08,
- 0x18, 0xc6, 0x31, 0x0c, 0x38, 0xc6, 0x31, 0x0e, 0x30, 0xce, 0x39, 0x06,
- 0x70, 0xce, 0x39, 0x07, 0x60, 0xee, 0x3b, 0x03, 0xe0, 0xee, 0xbb, 0x03,
- 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x01,
- 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0xff, 0x7f, 0x00,
- 0x80, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_small_outline.bitmap b/gnu/games/chess/Xchess/queen_small_outline.bitmap
deleted file mode 100644
index 0b624b9..0000000
--- a/gnu/games/chess/Xchess/queen_small_outline.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define queen_small_outline_width 32
-#define queen_small_outline_height 32
-static char queen_small_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00,
- 0x80, 0x81, 0xc0, 0x00, 0x80, 0x81, 0xc0, 0x00, 0x00, 0xc1, 0x41, 0x00,
- 0x00, 0x41, 0x41, 0x00, 0x02, 0x43, 0x61, 0x20, 0x06, 0x43, 0x61, 0x30,
- 0x04, 0x43, 0x61, 0x10, 0x0c, 0x43, 0x61, 0x18, 0x08, 0x47, 0x71, 0x08,
- 0x18, 0x46, 0x31, 0x0c, 0x38, 0x46, 0x31, 0x0e, 0x30, 0x4e, 0x39, 0x06,
- 0x70, 0x4e, 0x29, 0x07, 0x60, 0x6a, 0x2b, 0x03, 0xe0, 0x2a, 0xab, 0x03,
- 0xe0, 0x3b, 0xee, 0x03, 0x40, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x80, 0x01,
- 0x80, 0xfc, 0x9f, 0x00, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x01, 0x40, 0x00,
- 0x80, 0xfd, 0xdf, 0x00, 0xf0, 0x00, 0x80, 0x07, 0xf0, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/record.c b/gnu/games/chess/Xchess/record.c
deleted file mode 100644
index d9459b3..0000000
--- a/gnu/games/chess/Xchess/record.c
+++ /dev/null
@@ -1,315 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/23 17:18:20 $
- * $Source: /users/faustus/xchess/RCS/record.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Deal with recording moves.
- */
-
-#include "xchess.h"
-
-#undef smartass
-
-bool record_english = true;
-char *record_file = DEF_RECORD_FILE;
-int movenum = 0;
-bool saveflag = false;
-
-static char *colnames[] = { "qr", "qn", "qb", "q", "k", "kb", "kn", "kr" } ;
-static char *pcnames[] = { "P", "R", "N", "B", "Q", "K" } ;
-
-static char *movestring();
-static char *tstring();
-static FILE *backup;
-
-#define RECORD_HEADER "\n1 XChess Game Record0\n"
-
-void
-record_init(win)
- windata *win;
-{
- int i;
-
- i = XTextWidth(win->medium, RECORD_HEADER,
- sizeof(RECORD_HEADER) - 1);
- i = (40 * win->small->max_bounds.width - i *
- win->medium->max_bounds.width) /
- win->medium->max_bounds.width / 2;
- TxtGrab(win->display, win->recwin, "xchess", win->small, win->textback.pixel,
- win->textcolor.pixel, win->cursorcolor.pixel);
- TxtAddFont(win->display, win->recwin, 1, win->medium, win->textcolor.pixel);
- for (; i > 0; i++)
- TxtWriteStr(win->display, win->recwin, " ");
- TxtWriteStr(win->display, win->recwin, RECORD_HEADER);
-
- if (saveflag) {
- if (!(backup = fopen(record_file, "w"))) {
- perror(record_file);
- saveflag = false;
- } else {
- fprintf(backup, "X Chess -- %s\n", datestring());
- if (dispname2)
- fprintf(backup, "\tWhite on %s, black on %s\n",
- dispname1, dispname2);
- else
- fprintf(backup, "\tGame played on %s\n",
- dispname1);
- fprintf(backup, "\t%s\n", record_english ? "english" :
- "algebraic");
- fflush(backup);
- }
- }
-
- movenum = 0;
- return;
-}
-
-void
-record_reset()
-{
- TxtWriteStr(win1->display, win1->recwin, "\n\n1 New Game0\n\n");
- if (!oneboard) {
- TxtWriteStr(win2->display, win2->recwin, "\n\n1 New Game0\n\n");
- }
- movenum = 0;
- if (saveflag) {
- fprintf(backup, "\n\nNew Game\n\n");
- fflush(backup);
- }
- return;
-}
-
-void
-record_end(s)
- char *s;
-{
- char buf[BSIZE];
-
- sprintf(buf, "\n%s\n", s);
- TxtWriteStr(win1->display, win1->recwin, s);
- if (!oneboard) {
- TxtWriteStr(win2->display, win2->recwin, s);
- }
- if (saveflag) {
- fprintf(backup, "\n%s\n", s);
- fprintf(backup, "Time: white: %s, ", tstring(whiteseconds));
- fprintf(backup, "black: %s\n", tstring(blackseconds));
- fclose(backup);
- }
- return;
-}
-
-void
-record_save()
-{
- move *m;
- FILE *fp;
- int i;
- char *s;
-
- if (!(fp = fopen(record_file, "w"))) {
- perror(record_file);
- return;
- }
- fprintf(fp, "X Chess -- %s\n", datestring());
- if (dispname2)
- fprintf(fp, "\tWhite on %s, black on %s\n",
- dispname1, dispname2);
- else
- fprintf(fp, "\tGame played on %s\n", dispname1);
- fprintf(fp, "\t%s\n", record_english ? "english" : "algebraic");
-
- for (m = moves, i = 1; m; i++) {
- s = movestring(m);
- fprintf(fp, "%2d. %-16s ", i, s);
- m = m->next;
- if (m)
- s = movestring(m);
- else
- s = "";
- fprintf(fp, "%s\n", s);
- if (m)
- m = m->next;
- }
- fclose(fp);
- return;
-}
-
-void
-record_move(m)
- move *m;
-{
- char *s, buf[BSIZE];
-
- s = movestring(m);
-
- if (m->piece.color == WHITE) {
- movenum++;
- sprintf(buf, "%2d. %-16s ", movenum, s);
- } else {
- sprintf(buf, "%s\n", s);
- }
- TxtWriteStr(win1->display, win1->recwin, buf);
- if (!oneboard) {
- TxtWriteStr(win2->display, win2->recwin, buf);
- }
- if (saveflag) {
- fprintf(backup, "%s", buf);
- fflush(backup);
- }
-
- return;
-}
-
-void
-record_back()
-{
- extern move *lastmove;
- move *m = lastmove;
- char *s = movestring(m);
- char buf[BSIZE];
- long i;
-
- if (m->piece.color == WHITE) {
- sprintf(buf, "%2d. %-16s ", movenum, s);
- } else {
- sprintf(buf, "%s\n", s);
- }
- s = buf;
- for (i = 0; *s != '\0'; i++)
- *s++ = ''; /* control H, backspace */
-
- TxtWriteStr(win1->display, win1->recwin, buf);
- if (!oneboard) {
- TxtWriteStr(win2->display, win2->recwin, buf);
- }
-
- if (nexttomove == BLACK)
- movenum--;
- if (saveflag) {
- fseek(backup, -i, 1);
- fflush(backup);
- }
-
- return;
-}
-
-static char *
-movestring(m)
- move *m;
-{
- int fy, ty;
- static char buf[BSIZE];
-
- if (!record_english || (m->piece.color == WHITE)) {
- fy = SIZE - m->fromy;
- ty = SIZE - m->toy;
- } else {
- fy = m->fromy + 1;
- ty = m->toy + 1;
- }
-
- switch (m->type) {
- case MOVE:
- if (record_english)
- sprintf(buf, "%s/%s%d-%s%d%s", pcnames[(int) m->piece.
- type], colnames[m->fromx], fy,
- colnames[m->tox], ty, m->check ? "+" :
- "");
- else
- sprintf(buf, "%c%d%c%d", 'a' + m->fromx, fy, 'a' +
- m->tox, ty);
- break;
- case CAPTURE:
- if (record_english)
- sprintf(buf, "%s/%s%dx%s/%s%d%s%s",
- pcnames[(int) m->piece.type],
- colnames[m->fromx], fy,
- pcnames[(int) m->taken.type],
- colnames[m->tox], ty,
- m->enpassant ? "e.p." : "",
- m->check ? "+" : "");
- else
- sprintf(buf, "%c%d%c%d", 'a' + m->fromx, fy, 'a' +
- m->tox, ty);
- break;
-
- case KCASTLE:
- if (record_english)
- sprintf(buf, "O-O%s", m->check ? "ch" : "");
- else if (m->piece.color == WHITE)
- strcpy(buf, "e1g1");
- else
- strcpy(buf, "e8g8");
- break;
-
- case QCASTLE:
- if (record_english)
- sprintf(buf, "O-O-O%s", m->check ? "ch" : "");
- else if (m->piece.color == WHITE)
- strcpy(buf, "e1c1");
- else
- strcpy(buf, "e8c8");
- break;
-
- default:
- sprintf(buf, "something strange");
- break;
- }
- if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) &&
- (m->toy == 7)) || ((m->piece.color == WHITE) &&
- (m->toy == 0))))
- strcat(buf, "(Q)");
-
-#ifdef smartass
- if (!(random() % 50))
- strcat(buf, "?");
- else if (!(random() % 50))
- strcat(buf, "!");
- else if (!(random() % 500))
- strcat(buf, "???");
- else if (!(random() % 500))
- strcat(buf, "!!!");
-#endif smartass
-
- return (buf);
-}
-
-static char *
-tstring(s)
- int s;
-{
- static char buf[64];
-
- if (s > 3600)
- sprintf(buf, "%dh %dm %ds", s / 3600, (s % 3600) / 60, s % 60);
- else if (s > 60)
- sprintf(buf, "%dm %ds", (s % 3600) / 60, s % 60);
- else
- sprintf(buf, "%ds", s);
- return (buf);
-}
-
diff --git a/gnu/games/chess/Xchess/rook.bitmap b/gnu/games/chess/Xchess/rook.bitmap
deleted file mode 100644
index f274614..0000000
--- a/gnu/games/chess/Xchess/rook.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define rook_width 80
-#define rook_height 80
-static char rook_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xf8, 0xff, 0x00, 0x3c,
- 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x0f, 0x00,
- 0x00, 0xc0, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0,
- 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x01,
- 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x01, 0xff, 0xff,
- 0x07, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0x01, 0x00, 0xfc, 0xfd,
- 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x07, 0xfc, 0xff, 0x01, 0xff, 0x1f, 0x00,
- 0x00, 0xc0, 0x1f, 0xf0, 0xff, 0xff, 0x7f, 0xc0, 0x1f, 0x00, 0x00, 0x40,
- 0xc0, 0xff, 0x07, 0x00, 0xff, 0x1f, 0x10, 0x00, 0x00, 0xc0, 0xff, 0x1f,
- 0xf0, 0x7f, 0xc0, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0x7f, 0xc0, 0xfd, 0xff,
- 0x1d, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff,
- 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0xff, 0xfe, 0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe,
- 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe,
- 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0x0f, 0x80, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xe0, 0x3f,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff,
- 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd,
- 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd,
- 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x07, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
- 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x20, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_mask.bitmap b/gnu/games/chess/Xchess/rook_mask.bitmap
deleted file mode 100644
index c044416..0000000
--- a/gnu/games/chess/Xchess/rook_mask.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define rook_mask_width 80
-#define rook_mask_height 80
-static char rook_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xfc, 0xff,
- 0x01, 0x7e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe,
- 0x1f, 0x00, 0x00, 0xe0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe, 0x3f, 0x00,
- 0x00, 0xe0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe, 0x3f, 0x00, 0x00, 0xe0,
- 0xff, 0x03, 0xfc, 0xff, 0x1f, 0xfe, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0x83,
- 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
- 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
- 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
- 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
- 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_outline.bitmap b/gnu/games/chess/Xchess/rook_outline.bitmap
deleted file mode 100644
index f30107a..0000000
--- a/gnu/games/chess/Xchess/rook_outline.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define rook_outline_width 80
-#define rook_outline_height 80
-static char rook_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x80,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x08, 0x80, 0x00, 0x3c,
- 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x08, 0x80, 0x00, 0xe4, 0x0f, 0x00,
- 0x00, 0xc0, 0x00, 0x01, 0x08, 0x80, 0x00, 0x04, 0x18, 0x00, 0x00, 0x40,
- 0x00, 0x01, 0x08, 0x80, 0x00, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0x01,
- 0x08, 0x80, 0x00, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0x01, 0x0f, 0x80,
- 0x07, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0xfd, 0x01, 0x00, 0xfc, 0x05,
- 0x10, 0x00, 0x00, 0x40, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x10, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x10, 0x00, 0x00, 0x40,
- 0x00, 0xf0, 0x07, 0x00, 0x7f, 0x00, 0x10, 0x00, 0x00, 0x40, 0xc0, 0x1f,
- 0x00, 0x00, 0xc0, 0x1f, 0x10, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x02, 0x00,
- 0x02, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00,
- 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x80, 0xff, 0xff, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
- 0x00, 0x01, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0xf0, 0x7f, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x1f, 0xc0,
- 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00,
- 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff,
- 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
- 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
- 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x07, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
- 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x20, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_small.bitmap b/gnu/games/chess/Xchess/rook_small.bitmap
deleted file mode 100644
index ddee756..0000000
--- a/gnu/games/chess/Xchess/rook_small.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define rook_small_width 32
-#define rook_small_height 32
-static char rook_small_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x73, 0xce, 0x03, 0xc0, 0x73, 0xce, 0x03, 0xc0, 0x73, 0xce, 0x03,
- 0xc0, 0x73, 0xce, 0x03, 0xc0, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_small_outline.bitmap b/gnu/games/chess/Xchess/rook_small_outline.bitmap
deleted file mode 100644
index 523521b..0000000
--- a/gnu/games/chess/Xchess/rook_small_outline.bitmap
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#define rook_small_outline_width 32
-#define rook_small_outline_height 32
-static char rook_small_outline_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x73, 0xce, 0x03, 0x40, 0x52, 0x4a, 0x02, 0x40, 0x52, 0x4a, 0x02,
- 0x40, 0x52, 0x4a, 0x02, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x01, 0x80, 0x00,
- 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
- 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
- 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
- 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
- 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
- 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
- 0xe0, 0xff, 0xff, 0x07, 0x20, 0x00, 0x00, 0x04, 0xe0, 0xff, 0xff, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/scrollText.c b/gnu/games/chess/Xchess/scrollText.c
deleted file mode 100644
index 4320710..0000000
--- a/gnu/games/chess/Xchess/scrollText.c
+++ /dev/null
@@ -1,1858 +0,0 @@
-/*
- * A Scrollable Text Output Window
- *
- * David Harrison
- * University of California, Berkeley
- * 1986
- *
- * The following is an implementation for a scrollable text output
- * system. It handles exposure events only (other interactions are
- * under user control). For scrolling, a always present scroll bar
- * is implemented. It detects size changes and compensates accordingly.
- */
-
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/X10.h>
-#include <sys/types.h>
-#include "scrollText.h"
-
-extern char *malloc();
-extern char *realloc();
-#define alloc(type) (type *) malloc(sizeof(type))
-#define numalloc(type, num) (type *) malloc((unsigned) (num * sizeof(type)))
-#define MAXINT 2147483647
-
-extern XAssocTable *XCreateAssocTable();
-extern caddr_t XLookUpAssoc();
-
-static XAssocTable *textWindows = (XAssocTable *) 0;
-
-#define NOOPTION -1 /* Option hasn't been set yet */
-#define NORMSCROLL 0 /* Smooth scroll on LineToTop and TopToHere */
-#define JUMPSCROLL 1 /* Jump scrolling on LineToTop and TopToHere */
-
-static int ScrollOption = NOOPTION;
-
-typedef char *Generic;
-
-#define DEFAULT_GC textInfo->fontGC[textInfo->curFont]
-
-#define BARSIZE 15
-#define BARBORDER 1
-#define MAXFONTS 8
-#define INITBUFSIZE 1024
-#define INITLINES 50
-#define INITEXPARY 50
-#define XPADDING 2
-#define YPADDING 2
-#define INTERLINE 5
-#define INTERSPACE 1
-#define CURSORWIDTH 2
-#define EXPANDPERCENT 40
-#define BUFSIZE 1024
-#define CUROFFSET 1
-#define MAXFOREIGN 250
-#define NOINDEX -1
-
-/* The wrap line indicator */
-#define WRAPINDSIZE 7
-#define STEMOFFSET 5
-#define arrow_width 7
-#define arrow_height 5
-static char arrow_bits[] = {
- 0x24, 0x26, 0x3f, 0x06, 0x04};
-
-#define NEWLINE '\n'
-#define BACKSPACE '\010'
-#define NEWFONT '\006'
-#define LOWCHAR '\040'
-#define HIGHCHAR '\176'
-
-#define CHARMASK 0x00ff /* Character mask */
-#define FONTMASK 0x0700 /* Character font */
-#define FONTSHIFT 8 /* Shift amount */
-
-#define WRAPFLAG 0x01 /* Line wrap flag */
-
-/*
- * Lines are represented by a pointer into the overall array of
- * 16-bit characters. The lower eight bits is used to indicate the character
- * (in ASCII), and the next two bits are used to indicate the font
- * the character should be drawn in.
- */
-
-typedef struct txtLine {
- int lineLength; /* Current line length */
- int lineHeight; /* Full height of line in pixels */
- int lineBaseLine; /* Current baseline of the line */
- int lineWidth; /* Drawing position at end of line */
- int lineText; /* Offset into master buffer */
- int lineFlags; /* Line wrap flag is here */
-};
-
-
-/*
- * For ExposeCopy events, we queue up the redraw requests collapsing
- * them into line redraw requests until the CopyExpose event arrives.
- * The queue is represented as a dynamic array of the following
- * structure:
- */
-
-typedef struct expEvent {
- int lineIndex; /* Index of line to redraw */
- int ypos; /* Drawing position of line */
-};
-
-
-/*
- * The text buffer is represented using a dynamic counted array
- * of 16-bit quantities. This array expands as needed.
- * For the screen representation, a dynamic counted array
- * of line structures is used. This array points into the
- * text buffer to denote the start of each line and its parameters.
- * The windows are configured as one overall window which contains
- * the scroll bar as a sub-window along its right edge. Thus,
- * the text drawing space is actually w-BARSIZE.
- */
-
-#define NOTATBOTTOM 0x01 /* Need to scroll to bottom before appending */
-#define FONTNUMWAIT 0x02 /* Waiting for font number */
-#define COPYEXPOSE 0x04 /* Need to process a copy expose event */
-#define SCREENWRONG 0x08 /* TxtJamStr has invalidated screen contents */
-
-typedef struct txtWin {
- /* Basic text buffer */
- int bufAlloc; /* Allocated size of buffer */
- int bufSpot; /* Current writing position in buffer */
- short *mainBuffer; /* Main buffer of text */
-
- /* Line information */
- int numLines; /* Number of display lines in buffer */
- int allocLines; /* Number of lines allocated */
- struct txtLine **txtBuffer; /* Dynamic array of lines */
-
- /* Current Window display information */
- Window mainWindow; /* Text display window */
- Window scrollBar; /* Subwindow for scroll bar */
- Pixmap arrowMap; /* line wrap indicator */
- int bgPix, fgPix; /* Background and cursor */
- GC CursorGC; /* gc for the cursor */
- GC bgGC; /* gc for erasing things */
- GC fontGC[MAXFONTS]; /* gc for doing fonts */
- XFontStruct theFonts[MAXFONTS];/* Display fonts */
- int theColors[MAXFONTS]; /* foregrounds of the fonts */
- int curFont; /* current font for tracking */
- int w, h; /* Current size */
- int startLine; /* Top line in display */
- int endLine; /* Bottom line in display */
- int bottomSpace; /* Space at bottom of screen */
- int flagWord; /* If non-zero, not at end */
-
- /* For handling ExposeCopy events */
- int exposeSize; /* Current size of array */
- int exposeAlloc; /* Allocated size */
- struct expEvent **exposeAry;/* Array of line indices */
-
- /* Drawing position information */
- int curLine; /* Current line in buffer */
- int curX; /* Current horizontal positi */
- int curY; /* Current vertical drawing */
-};
-
-/* Flags for the various basic character handling functions */
-
-#define DODISP 0x01 /* Update the display */
-#define NONEWLINE 0x02 /* Dont append newline */
-
-
-
-static int InitLine(newLine)
-struct txtLine *newLine; /* Newly created line structure */
-/*
- * This routine initializes a newly created line structure.
- */
-{
- newLine->lineLength = 0;
- newLine->lineHeight = 0;
- newLine->lineBaseLine = 0;
- newLine->lineWidth = XPADDING;
- newLine->lineText = NOINDEX;
- newLine->lineFlags = 0;
- return 1;
-}
-
-
-
-
-int TxtGrab(display, txtWin, program, mainFont, bg, fg, cur)
-Display *display; /* display window is on */
-Window txtWin; /* Window to take over as scrollable text */
-char *program; /* Program name for Xdefaults */
-XFontStruct *mainFont; /* Primary text font */
-int bg, fg, cur; /* Background, foreground, and cursor colors */
-/*
- * This routine takes control of 'txtWin' and makes it into a scrollable
- * text output window. It will create a sub-window for the scroll bar
- * with a background of 'bg' and an bar with color 'fg'. Both fixed width
- * and variable width fonts are supported. Additional fonts can be loaded
- * using 'TxtAddFont'. Returns 0 if there were problems, non-zero if
- * everything went ok.
- */
-{
- struct txtWin *newWin; /* Text package specific information */
- XWindowAttributes winInfo; /* Window information */
- int index;
- XGCValues gc_val;
-
- if (textWindows == (XAssocTable *) 0) {
- textWindows = XCreateAssocTable(32);
- if (textWindows == (XAssocTable *) 0) return(0);
- }
- if (XGetWindowAttributes(display, txtWin, &winInfo) == 0) return 0;
-
- if (ScrollOption == NOOPTION) {
- /* Read to see if the user wants jump scrolling or not */
- if (XGetDefault(display, program, "JumpScroll")) {
- ScrollOption = JUMPSCROLL;
- } else {
- ScrollOption = NORMSCROLL;
- }
- }
-
- /* Initialize local structure */
- newWin = alloc(struct txtWin);
-
- /* Initialize arrow pixmap */
- newWin->arrowMap = XCreatePixmapFromBitmapData(display, txtWin,
- arrow_bits,
- arrow_width, arrow_height,
- cur, bg,
- DisplayPlanes(display, 0));
-
- newWin->bufAlloc = INITBUFSIZE;
- newWin->bufSpot = 0;
- newWin->mainBuffer = numalloc(short, INITBUFSIZE);
-
- newWin->numLines = 1;
- newWin->allocLines = INITLINES;
- newWin->txtBuffer = numalloc(struct txtLine *, INITLINES);
- for (index = 0; index < INITLINES; index++) {
- newWin->txtBuffer[index] = alloc(struct txtLine);
- InitLine(newWin->txtBuffer[index]);
- }
-
- /* Window display information */
- newWin->mainWindow = txtWin;
- newWin->w = winInfo.width;
- newWin->h = winInfo.height;
- newWin->startLine = 0;
- newWin->endLine = 0;
- newWin->bottomSpace = winInfo.height
- - YPADDING - mainFont->ascent - mainFont->descent - INTERLINE;
- newWin->flagWord = 0;
- newWin->bgPix = bg;
- newWin->fgPix = fg;
-
- /* Scroll Bar Creation */
- newWin->scrollBar = XCreateSimpleWindow(display, txtWin,
- winInfo.width - BARSIZE,
- 0, BARSIZE - (2*BARBORDER),
- winInfo.height - (2*BARBORDER),
- BARBORDER,
- fg, bg);
- XSelectInput(display, newWin->scrollBar, ExposureMask|ButtonReleaseMask);
- XMapRaised(display, newWin->scrollBar);
-
- /* Font and Color Initialization */
- newWin->theFonts[0] = *mainFont;
- newWin->theColors[0] = fg;
- gc_val.function = GXcopy;
- gc_val.plane_mask = AllPlanes;
- gc_val.foreground = fg;
- gc_val.background = bg;
- gc_val.graphics_exposures = 1;
- gc_val.font = mainFont->fid;
- gc_val.line_width = 1;
- gc_val.line_style = LineSolid;
-
- newWin->fontGC[0] = XCreateGC(display, txtWin,
- GCFunction | GCPlaneMask |
- GCForeground | GCBackground |
- GCGraphicsExposures | GCFont,
- &gc_val);
-
- gc_val.foreground = cur;
- newWin->CursorGC = XCreateGC(display, txtWin,
- GCFunction | GCPlaneMask |
- GCForeground | GCBackground |
- GCLineStyle | GCLineWidth,
- &gc_val);
-
- gc_val.foreground = bg;
- newWin->bgGC = XCreateGC(display, txtWin,
- GCFunction | GCPlaneMask |
- GCForeground | GCBackground |
- GCGraphicsExposures | GCFont,
- &gc_val);
-
-
- for (index = 1; index < MAXFONTS; index++) {
- newWin->theFonts[index].fid = 0;
- newWin->fontGC[index] = 0;
- }
-
-
- /* Initialize size of first line */
- newWin->txtBuffer[0]->lineHeight = newWin->theFonts[0].ascent +
- newWin->theFonts[0].descent;
- newWin->txtBuffer[0]->lineText = 0;
-
- /* ExposeCopy array initialization */
- newWin->exposeSize = 0;
- newWin->exposeAlloc = INITEXPARY;
- newWin->exposeAry = numalloc(struct expEvent *, INITEXPARY);
- for (index = 0; index < newWin->exposeAlloc; index++)
- newWin->exposeAry[index] = alloc(struct expEvent);
- /* Put plus infinity in last slot for sorting purposes */
- newWin->exposeAry[0]->lineIndex = MAXINT;
-
- /* Drawing Position Information */
- newWin->curLine = 0;
- newWin->curX = 0;
- newWin->curY = YPADDING + mainFont->ascent + mainFont->descent;
-
- /* Attach it to both windows */
- XMakeAssoc(display, textWindows, (XID) txtWin, (caddr_t) newWin);
- XMakeAssoc(display, textWindows, (XID) newWin->scrollBar, (caddr_t) newWin);
- return 1;
-}
-
-
-int TxtRelease(display, w)
-Display *display;
-Window w; /* Window to release */
-/*
- * This routine releases all resources associated with the
- * specified window which are consumed by the text
- * window package. This includes the entire text buffer, line start
- * array, and the scroll bar window. However, the window
- * itself is NOT destroyed. The routine will return zero if
- * the window is not owned by the text window package.
- */
-{
- struct txtWin *textInfo;
- int index;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display,
- textWindows, (XID) w)) == 0)
- return 0;
-
- for (index = 0; index < MAXFONTS; index++)
- if (textInfo->fontGC[index] != 0)
- XFreeGC(display, textInfo->fontGC[index]);
-
- free((Generic) textInfo->mainBuffer);
- for (index = 0; index < textInfo->numLines; index++) {
- free((Generic) textInfo->txtBuffer[index]);
- }
- free((Generic) textInfo->txtBuffer);
- XDestroyWindow(display, textInfo->scrollBar);
- for (index = 0; index < textInfo->exposeSize; index++) {
- free((Generic) textInfo->exposeAry[index]);
- }
- free((Generic) textInfo->exposeAry);
- XDeleteAssoc(display, textWindows, (XID) w);
- free((Generic) textInfo);
- return 1;
-}
-
-
-
-static int RecompBuffer(textInfo)
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine recomputes all line breaks in a buffer after
- * a change in window size or font. This is done by throwing
- * away the old line start array and recomputing it. Although
- * a lot of this work is also done elsewhere, it has been included
- * inline here for efficiency.
- */
-{
- int startPos, endSize, linenum;
- register int index, chsize, curfont;
- register short *bufptr;
- register XFontStruct *fontptr;
- register struct txtLine *lineptr;
- char theChar;
-
- /* Record the old position so we can come back to it */
- for (startPos = textInfo->txtBuffer[textInfo->startLine]->lineText;
- (startPos > 0) && (textInfo->mainBuffer[startPos] != '\n');
- startPos--)
- /* null loop body */;
-
- /* Clear out the old line start array */
- for (index = 0; index < textInfo->numLines; index++) {
- InitLine(textInfo->txtBuffer[index]);
- }
-
- /* Initialize first line */
- textInfo->txtBuffer[0]->lineHeight =
- textInfo->theFonts[0].ascent + textInfo->theFonts[0].descent;
- textInfo->txtBuffer[0]->lineText = 0;
-
- /* Process the text back into lines */
- endSize = textInfo->w - BARSIZE - WRAPINDSIZE;
- bufptr = textInfo->mainBuffer;
- lineptr = textInfo->txtBuffer[0];
- linenum = 0;
- fontptr = &(textInfo->theFonts[0]);
- curfont = 0;
- for (index = 0; index < textInfo->bufSpot; index++) {
- theChar = bufptr[index] & CHARMASK;
-
- if ((bufptr[index] & FONTMASK) != curfont) {
- int newFontNum, heightDiff;
-
- /* Switch fonts */
- newFontNum = (bufptr[index] & FONTMASK) >> FONTSHIFT;
- if (textInfo->theFonts[newFontNum].fid != 0) {
- /* Valid font */
- curfont = bufptr[index] & FONTMASK;
- fontptr = &(textInfo->theFonts[newFontNum]);
- heightDiff = (fontptr->ascent + fontptr->descent) -
- lineptr->lineHeight;
- if (heightDiff < 0) heightDiff = 0;
- lineptr->lineHeight += heightDiff;
- }
- }
- if (theChar == '\n') {
- /* Handle new line */
- if (linenum >= textInfo->allocLines-1)
- /* Expand number of lines */
- ExpandLines(textInfo);
- linenum++;
- lineptr = textInfo->txtBuffer[linenum];
- /* Initialize next line */
- lineptr->lineHeight = fontptr->ascent + fontptr->descent;
- lineptr->lineText = index+1;
- /* Check to see if its the starting line */
- if (index == startPos) textInfo->startLine = linenum;
- } else {
- /* Handle normal character */
- chsize = CharSize(textInfo, linenum, index);
- if (lineptr->lineWidth + chsize > endSize) {
- /* Handle line wrap */
- lineptr->lineFlags |= WRAPFLAG;
- if (linenum >= textInfo->allocLines-1)
- /* Expand number of lines */
- ExpandLines(textInfo);
- linenum++;
- lineptr = textInfo->txtBuffer[linenum];
- /* Initialize next line */
- lineptr->lineHeight = fontptr->ascent + fontptr->descent;
- lineptr->lineText = index;
- lineptr->lineLength = 1;
- lineptr->lineWidth += chsize;
- } else {
- /* Handle normal addition of character */
- lineptr->lineLength += 1;
- lineptr->lineWidth += chsize;
- }
- }
- }
- /* We now have a valid line array. Let's clean up some other fields. */
- textInfo->numLines = linenum+1;
- if (startPos == 0) {
- textInfo->startLine = 0;
- }
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- textInfo->curLine = linenum;
- /* Check to see if we are at the bottom */
- if (textInfo->endLine >= textInfo->numLines-1) {
- textInfo->curY = textInfo->h - textInfo->bottomSpace -
- lineptr->lineHeight;
- textInfo->flagWord &= (~NOTATBOTTOM);
- } else {
- textInfo->flagWord |= NOTATBOTTOM;
- }
- return 1;
-}
-
-
-
-
-int TxtAddFont(display, textWin, fontNumber, newFont, newColor)
-Display *display;
-Window textWin; /* Scrollable text window */
-int fontNumber; /* Place to add font (0-7) */
-XFontStruct *newFont; /* Font to add */
-int newColor; /* Color of font */
-/*
- * This routine loads a new font so that it can be used in a previously
- * created text window. There are eight font slots numbered 0 through 7.
- * If there is already a font in the specified slot, it will be replaced
- * and an automatic redraw of the window will take place. See TxtWriteStr
- * for details on using alternate fonts. The color specifies the foreground
- * color of the text. The default foreground color is used if this
- * parameter is TXT_NO_COLOR. Returns a non-zero value if
- * everything went well.
- */
-{
- struct txtWin *textInfo;
- int redrawFlag;
- XGCValues gc_val;
-
- if ((fontNumber < 0) || (fontNumber >= MAXFONTS)) return 0;
- if ((textInfo = (struct txtWin *)
- XLookUpAssoc(display, textWindows, (XID) textWin)) == 0)
- return 0;
- if (newColor == TXT_NO_COLOR) {
- newColor = textInfo->fgPix;
- }
-
- gc_val.font = newFont->fid;
- gc_val.foreground = newColor;
- gc_val.background = textInfo->bgPix;
- gc_val.plane_mask = AllPlanes;
- gc_val.graphics_exposures = 1;
- gc_val.function = GXcopy;
-
- if (textInfo->fontGC[fontNumber] != 0)
- {
- XChangeGC(display, textInfo->fontGC[fontNumber],
- GCFont | GCForeground, &gc_val);
- }
- else
- textInfo->fontGC[fontNumber] = XCreateGC(display, textWin,
- GCFont |
- GCForeground |
- GCBackground |
- GCFunction |
- GCPlaneMask |
- GCGraphicsExposures,
- &gc_val);
-
-
- redrawFlag = (textInfo->theFonts[fontNumber].fid != 0) &&
- (((newFont) && (newFont->fid != textInfo->theFonts[fontNumber].fid)) ||
- (newColor != textInfo->theColors[fontNumber]));
- if (newFont) {
- textInfo->theFonts[fontNumber] = *newFont;
- }
- textInfo->theColors[fontNumber] = newColor;
-
- if (redrawFlag) {
- RecompBuffer(textInfo);
- XClearWindow(display, textWin);
- TxtRepaint(display, textWin);
- }
- return 1;
-}
-
-
-
-int TxtWinP(display, w)
-Display *display;
-Window w;
-/*
- * Returns a non-zero value if the window has been previously grabbed
- * using TxtGrab and 0 if it has not.
- */
-{
- if (XLookUpAssoc(display, textWindows, (XID) w))
- return(1);
- else return(0);
-}
-
-
-
-static int FindEndLine(textInfo, botSpace)
-struct txtWin *textInfo;
-int *botSpace;
-/*
- * Given the starting line in 'textInfo->startLine', this routine
- * determines the index of the last line that can be drawn given the
- * current size of the screen. If there are not enough lines to
- * fill the screen, the index of the last line will be returned.
- * The amount of empty bottom space is returned in 'botSpace'.
- */
-{
- int index, height, lineHeight;
-
- height = YPADDING;
- index = textInfo->startLine;
- while (index < textInfo->numLines) {
- lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
- if (height + lineHeight > textInfo->h) break;
- height += lineHeight;
- index++;
- }
- if (botSpace) {
- *botSpace = textInfo->h - height;
- }
- return index - 1;
-}
-
-
-
-static int UpdateScroll(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine computes the current extent of the scroll bar
- * indicator and repaints the bar with the correct information.
- */
-{
- int top, bottom;
-
- if (textInfo->numLines > 1) {
- top = textInfo->startLine * (textInfo->h - 2*BARBORDER) /
- (textInfo->numLines - 1);
- bottom = textInfo->endLine * (textInfo->h - 2*BARBORDER) /
- (textInfo->numLines - 1);
- } else {
- top = 0;
- bottom = textInfo->h - (2*BARBORDER);
- }
-
- /* Draw it - make sure there is a little padding */
- if (top == 0) top++;
- if (bottom == textInfo->h-(2*BARBORDER)) bottom--;
-
- XFillRectangle(display, textInfo->scrollBar,
- textInfo->bgGC,
- 0, 0, BARSIZE, top-1);
- XFillRectangle(display, textInfo->scrollBar,
- DEFAULT_GC, top, BARSIZE - (2*BARBORDER) - 2,
- bottom - top);
- XFillRectangle(display, textInfo->scrollBar, DEFAULT_GC,
- 0, bottom+1, BARSIZE,
- textInfo->h - (2 * BARBORDER) - bottom);
-
- return 1;
-}
-
-
-
-
-int TxtClear(display, w)
-Display *display;
-Window w;
-/*
- * This routine clears a scrollable text window. It resets the current
- * writing position to the upper left hand corner of the screen.
- * NOTE: THIS ALSO CLEARS THE CONTENTS OF THE TEXT WINDOW BUFFER AND
- * RESETS THE SCROLL BAR. Returns 0 if the window is not a text window.
- * This should be used *instead* of XClear.
- */
-{
- struct txtWin *textInfo;
- int index;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
- return 0;
-
- /* Zero out the arrays */
- textInfo->bufSpot = 0;
- for (index = 0; index < textInfo->numLines; index++) {
- InitLine(textInfo->txtBuffer[index]);
- }
- textInfo->txtBuffer[0]->lineHeight =
- textInfo->theFonts[textInfo->curFont].ascent +
- textInfo->theFonts[textInfo->curFont].descent;
-
- textInfo->numLines = 1;
- textInfo->startLine = 0;
- textInfo->endLine = 0;
- textInfo->curLine = 0;
- textInfo->curX = 0;
- textInfo->curY = YPADDING + textInfo->theFonts[textInfo->curFont].ascent
- + textInfo->theFonts[textInfo->curFont].descent;
-
- textInfo->bottomSpace = textInfo->h - YPADDING -
- textInfo->theFonts[textInfo->curFont].ascent - INTERLINE -
- textInfo->theFonts[textInfo->curFont].descent;
- /* Actually clear the window */
- XClearWindow(display, w);
-
- /* Draw the current cursor */
- XFillRectangle(display, w, textInfo->CursorGC,
- XPADDING + CUROFFSET, textInfo->curY,
- CURSORWIDTH,
- textInfo->theFonts[textInfo->curFont].ascent +
- textInfo->theFonts[textInfo->curFont].descent);
-
- /* Update the scroll bar */
- UpdateScroll(display, textInfo);
- return 1;
-}
-
-
-static int WarpToBottom(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text Information */
-/*
- * This routine causes the specified text window to display its
- * last screen of information. It updates the scroll bar
- * to the appropriate spot. The implementation scans backward
- * through the buffer to find an appropriate starting spot for
- * the window.
- */
-{
- int index, height, lineHeight;
-
- index = textInfo->numLines-1;
- height = 0;
- while (index >= 0) {
- lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
- if (height + lineHeight > textInfo->h) break;
- height += lineHeight;
- index--;
- }
- textInfo->startLine = index + 1;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- textInfo->curY = textInfo->h - textInfo->bottomSpace -
- textInfo->txtBuffer[textInfo->endLine]->lineHeight;
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- return 1;
-}
-
-
-
-static int UpdateExposures(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * Before a new scrolling action occurs, the text window package
- * must handle all COPYEXPOSE events generated by the last scrolling
- * action. This routine is called to do this. Foreign events (those
- * not handled by TxtFilter) are queued up and replaced on the queue
- * after the processing of the exposure events is complete.
- */
-{
-#if 0
- XEvent foreignQueue[MAXFOREIGN];
- int index, lastItem = 0;
-
- while (textInfo->flagWord & COPYEXPOSE) {
- XNextEvent(display, &(foreignQueue[lastItem]));
- if (!TxtFilter(display, &(foreignQueue[lastItem])))
- lastItem++;
- if (lastItem >= MAXFOREIGN) {
- printf("Too many foreign events to queue!\n");
- textInfo->flagWord &= (~COPYEXPOSE);
- }
- }
- for (index = 0; index < lastItem; index++) {
- XPutBackEvent(display, &(foreignQueue[index]));
- }
-#endif
- return 1;
-}
-
-
-static int ScrollDown(display,textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine scrolls the indicated text window down by one
- * line. The line below the current line must exist. The window
- * is scrolled so that the line below the last line is fully
- * displayed. This may cause many lines to scroll off the top.
- * Scrolling is done using XCopyArea. The exposure events should
- * be caught using ExposeCopy.
- */
-{
- int lineSum, index, targetSpace, freeSpace, updateFlag;
-
- lineSum = 0;
- if (textInfo->endLine + 1 >= textInfo->numLines) return 0;
- targetSpace = textInfo->txtBuffer[textInfo->endLine+1]->lineHeight +
- INTERLINE;
- if (textInfo->bottomSpace < targetSpace) {
- index = textInfo->startLine;
- while (index < textInfo->endLine) {
- lineSum += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
- if (textInfo->bottomSpace + lineSum >= targetSpace) break;
- index++;
- }
-
- /* Must move upward by 'lineSum' pixels */
- XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
- DEFAULT_GC, 0, lineSum,
- textInfo->w - BARSIZE, textInfo->h,
- 0, 0);
-
- textInfo->flagWord |= COPYEXPOSE;
- /* Repair the damage to the structures */
- textInfo->startLine = index + 1;
- updateFlag = 1;
- } else {
- updateFlag = 0;
- }
- /* More lines might be able to fit. Let's check. */
- freeSpace = textInfo->bottomSpace + lineSum - targetSpace;
- index = textInfo->endLine + 1;
- while (index < textInfo->numLines-1) {
- if (freeSpace - textInfo->txtBuffer[index+1]->lineHeight - INTERLINE < 0)
- break;
- freeSpace -= (textInfo->txtBuffer[index+1]->lineHeight + INTERLINE);
- index++;
- }
- textInfo->endLine = index;
- textInfo->bottomSpace = freeSpace;
- if (updateFlag) {
- UpdateExposures(display, textInfo);
- }
- UpdateScroll(display, textInfo);
- return 1;
-}
-
-
-
-
-static int ExpandLines(textInfo)
-struct txtWin *textInfo; /* Text Information */
-/*
- * This routine allocates and initializes additional space in
- * the line start array (txtBuffer). The new space
- * is allocated using realloc. The expansion factor is a percentage
- * given by EXPANDPERCENT.
- */
-{
- int newSize, index;
-
- newSize = textInfo->allocLines;
- newSize += (newSize * EXPANDPERCENT) / 100;
-
- textInfo->txtBuffer = (struct txtLine **)
- realloc((char *) textInfo->txtBuffer,
- (unsigned) (newSize * sizeof(struct txtLine *)));
- for (index = textInfo->allocLines; index < newSize; index++) {
- textInfo->txtBuffer[index] = alloc(struct txtLine);
- InitLine(textInfo->txtBuffer[index]);
- }
- textInfo->allocLines = newSize;
- return 1;
-}
-
-static int ExpandBuffer(textInfo)
-struct txtWin *textInfo; /* Text information */
-/*
- * Expands the basic character buffer using realloc. The expansion
- * factor is a percentage given by EXPANDPERCENT.
- */
-{
- int newSize;
-
- newSize = textInfo->bufAlloc + (textInfo->bufAlloc * EXPANDPERCENT) / 100;
- textInfo->mainBuffer = (short *)
- realloc((char *) textInfo->mainBuffer, (unsigned) newSize * sizeof(short));
- textInfo->bufAlloc = newSize;
- return 1;
-}
-
-
-
-static int HandleNewLine(display, textInfo, flagWord)
-Display *display;
-struct txtWin *textInfo; /* Text Information */
-int flagWord; /* DODISP or NONEWLINE or both */
-/*
- * This routine initializes the next line for drawing by setting
- * its height to the current font height, scrolls the screen down
- * one line, and updates the current drawing position to the
- * left edge of the newly cleared line. If DODISP is specified,
- * the screen will be updated (otherwise not). If NONEWLINE is
- * specified, no newline character will be added to the text buffer
- * (this is for line wrap).
- */
-{
- struct txtLine *curLine, *nextLine;
-
- /* Check to see if a new line must be allocated */
- if (textInfo->curLine >= textInfo->allocLines-1)
- /* Expand the number of lines */
- ExpandLines(textInfo);
- textInfo->numLines += 1;
-
- /* Then we initialize the next line */
- nextLine = textInfo->txtBuffer[textInfo->numLines-1];
- nextLine->lineHeight =
- textInfo->theFonts[textInfo->curFont].ascent +
- textInfo->theFonts[textInfo->curFont].descent;
-
- curLine = textInfo->txtBuffer[textInfo->curLine];
- if (flagWord & DODISP) {
- /* Scroll down a line if required */
- if ((textInfo->curY + curLine->lineHeight +
- nextLine->lineHeight + (INTERLINE * 2)) > textInfo->h)
- {
- ScrollDown(display, textInfo);
- }
- else
- {
- /* Update the bottom space appropriately */
- textInfo->bottomSpace -= (nextLine->lineHeight + INTERLINE);
- textInfo->endLine += 1;
- }
- /* Update drawing position */
- textInfo->curY = textInfo->h -
- (textInfo->bottomSpace + nextLine->lineHeight);
- }
-
- /* Move down a line */
- textInfo->curLine += 1;
- if (!(flagWord & NONEWLINE)) {
- /* Append end-of-line to text buffer */
- if (textInfo->bufSpot >= textInfo->bufAlloc) {
- /* Allocate more space in main text buffer */
- ExpandBuffer(textInfo);
- }
- textInfo->mainBuffer[(textInfo->bufSpot)++] =
- (textInfo->curFont << FONTSHIFT) | '\n';
- }
- nextLine->lineText = textInfo->bufSpot;
- textInfo->curX = 0;
- return 1;
-}
-
-
-
-static int CharSize(textInfo, lineNum, charNum)
-struct txtWin *textInfo; /* Current Text Information */
-int lineNum; /* Line in buffer */
-int charNum; /* Character in line */
-/*
- * This routine determines the size of the specified character.
- * It takes in account the font of the character and whether its
- * fixed or variable. The size includes INTERSPACE spacing between
- * the characters.
- */
-{
- register XFontStruct *charFont;
- register short *theLine;
- register short theChar;
-
- theLine = &(textInfo->mainBuffer[textInfo->txtBuffer[lineNum]->lineText]);
- theChar = theLine[charNum] & CHARMASK;
- charFont = &(textInfo->theFonts[(theChar & FONTMASK) >> FONTSHIFT]);
- if (theChar <= charFont->min_char_or_byte2 ||
- theChar >= charFont->max_char_or_byte2 ||
- charFont->per_char == 0)
- return charFont->max_bounds.width + 1;
- else
- return charFont->per_char[theChar].width + 1;
-}
-
-
-
-
-
-static int HandleBackspace(display, textInfo, flagWord)
-Display *display;
-struct txtWin *textInfo; /* Text Information */
-int flagWord; /* DODISP or nothing */
-/*
- * This routine handles a backspace found in the input stream. The
- * character before the current writing position will be erased and
- * the drawing position will move back one character. If the writing
- * position is at the left margin, the drawing position will move
- * up to the previous line. If it is a line that has been wrapped,
- * the character at the end of the previous line will be erased.
- */
-{
- struct txtLine *thisLine, *prevLine;
- int chSize;
-
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- /* First, determine whether we need to go back a line */
- if (thisLine->lineLength == 0) {
- /* Bleep if at top of buffer */
- if (textInfo->curLine == 0) {
- XBell(display, 50);
- return 0;
- }
-
- /* See if we have to scroll in the other direction */
- if ((flagWord & DODISP) && (textInfo->curY <= YPADDING)) {
- /* This will display the last lines of the buffer */
- WarpToBottom(display, textInfo);
- }
-
- /* Set drawing position at end of previous line */
- textInfo->curLine -= 1;
- prevLine = textInfo->txtBuffer[textInfo->curLine];
- textInfo->numLines -= 1;
- if (flagWord & DODISP) {
- textInfo->curY -= (prevLine->lineHeight + INTERLINE);
- textInfo->bottomSpace += (thisLine->lineHeight + INTERLINE);
- textInfo->endLine -= 1;
- }
-
- /* We are unlinewrapping if the previous line has flag set */
- if (prevLine->lineFlags & WRAPFLAG) {
- /* Get rid of line wrap indicator */
- if (flagWord & DODISP) {
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- textInfo->w - BARSIZE - WRAPINDSIZE,
- textInfo->curY, WRAPINDSIZE,
- prevLine->lineHeight);
- }
- prevLine->lineFlags &= (~WRAPFLAG);
- /* Call recursively to wipe out the ending character */
- HandleBackspace(display, textInfo, flagWord);
- } else {
- /* Delete the end-of-line in the primary buffer */
- textInfo->bufSpot -= 1;
- }
- } else {
- /* Normal deletion of character */
- chSize =
- CharSize(textInfo, textInfo->curLine,
- textInfo->txtBuffer[textInfo->curLine]->lineLength - 1);
- /* Move back appropriate amount and wipe it out */
- thisLine->lineWidth -= chSize;
- if (flagWord & DODISP) {
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- thisLine->lineWidth, textInfo->curY,
- chSize, thisLine->lineHeight);
- }
- /* Delete from buffer */
- textInfo->txtBuffer[textInfo->curLine]->lineLength -= 1;
- textInfo->bufSpot -= 1;
- }
- return 1;
-}
-
-
-
-static int DrawLineWrap(display, win, x, y, h, col)
-Display *display;
-Window win; /* What window to draw it in */
-int x, y; /* Position of upper left corner */
-int h; /* Height of indicator */
-int col; /* Color of indicator */
-/*
- * This routine draws a line wrap indicator at the end of a line.
- * Visually, it is an arrow of the specified height directly against
- * the scroll bar border. The bitmap used for the arrow is stored
- * in 'arrowMap' with size 'arrow_width' and 'arrow_height'.
- */
-{
- struct txtWin *textInfo;
-
- textInfo = (struct txtWin *)XLookUpAssoc(display, textWindows,
- (XID) win);
-
- /* First, draw the arrow */
- XCopyArea(display, textInfo->arrowMap, textInfo->mainWindow,
- textInfo->CursorGC,
- 0, 0, arrow_width, arrow_height,
- x, y + h - arrow_height, 1);
-
- /* Then draw the stem */
- XDrawLine(display, textInfo->mainWindow, textInfo->CursorGC,
- x + STEMOFFSET, y,
- x + STEMOFFSET, y + h - arrow_height);
- return 1;
-}
-
-
-
-
-static int DrawLine(display, textInfo, lineIndex, ypos)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int lineIndex; /* Index of line to draw */
-int ypos; /* Y position for line */
-/*
- * This routine destructively draws the indicated line in the
- * indicated window at the indicated position. It does not
- * clear to end of line however. It draws a line wrap indicator
- * if needed but does not draw a cursor.
- */
-{
- int index, startPos, curFont, theColor, curX, saveX, fontIndex;
- struct txtLine *someLine;
- char lineBuffer[BUFSIZE], *glyph;
- short *linePointer;
- XFontStruct *theFont;
- XGCValues gc;
-
- /* First, we draw the text */
- index = 0;
- curX = XPADDING;
- someLine = textInfo->txtBuffer[lineIndex];
- linePointer = &(textInfo->mainBuffer[someLine->lineText]);
- while (index < someLine->lineLength) {
- startPos = index;
- saveX = curX;
- curFont = linePointer[index] & FONTMASK;
- fontIndex = curFont >> FONTSHIFT;
- theFont = &(textInfo->theFonts[fontIndex]);
- theColor = textInfo->theColors[fontIndex];
- glyph = &(lineBuffer[0]);
- while ((index < someLine->lineLength) &&
- ((linePointer[index] & FONTMASK) == curFont))
- {
- *glyph = linePointer[index] & CHARMASK;
- index++;
- curX += CharSize(textInfo, lineIndex, index);
- glyph++;
- }
-
- /* Flush out the glyphs */
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- saveX, ypos,
- textInfo->w - BARSIZE,
- someLine->lineHeight + YPADDING + INTERLINE);
-
- XDrawString(display, textInfo->mainWindow,
- textInfo->fontGC[fontIndex],
- saveX, ypos,
- lineBuffer, someLine->lineLength);
- }
- /* Then the line wrap indicator (if needed) */
- if (someLine->lineFlags & WRAPFLAG) {
- DrawLineWrap(display, textInfo->mainWindow,
- textInfo->w - BARSIZE - WRAPINDSIZE,
- ypos, someLine->lineHeight,
- textInfo->fgPix);
- }
- return 1;
-}
-
-
-
-
-static int HandleNewFont(display, fontNum, textInfo, flagWord)
-Display *display;
-int fontNum; /* Font number */
-struct txtWin *textInfo; /* Text information */
-int flagWord; /* DODISP or nothing */
-/*
- * This routine handles a new font request. These requests take
- * the form "^F<digit>". The parsing is done in TxtWriteStr.
- * This routine is called only if the form is valid. It may return
- * a failure (0 status) if the requested font is not loaded.
- * If the new font is larger than any of the current
- * fonts on the line, it will change the line height and redisplay
- * the line.
- */
-{
- struct txtLine *thisLine;
- int heightDiff, baseDiff, redrawFlag;
-
- if (textInfo->theFonts[fontNum].fid == 0) {
- return 0;
- } else {
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- textInfo->curFont = fontNum;
- redrawFlag = 0;
- heightDiff = textInfo->theFonts[fontNum].ascent +
- textInfo->theFonts[fontNum].descent -
- thisLine->lineHeight;
-
- if (heightDiff > 0) {
- redrawFlag = 1;
- } else {
- heightDiff = 0;
- }
-
- if (redrawFlag) {
- if (flagWord & DODISP) {
- /* Clear current line */
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- 0, textInfo->curY, textInfo->w,
- thisLine->lineHeight);
-
- /* Check to see if it requires scrolling */
- if ((textInfo->curY + thisLine->lineHeight + heightDiff +
- INTERLINE) > textInfo->h)
- {
- /*
- * General approach: "unscroll" the last line up
- * and then call ScrollDown to do the right thing.
- */
- textInfo->endLine -= 1;
- textInfo->bottomSpace += thisLine->lineHeight +
- INTERLINE;
-
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- 0, textInfo->h - textInfo->bottomSpace,
- textInfo->w, textInfo->bottomSpace);
-
- thisLine->lineHeight += heightDiff;
- ScrollDown(display, textInfo);
- textInfo->curY = textInfo->h -
- (textInfo->bottomSpace + INTERLINE +
- thisLine->lineHeight);
- }
- else
- {
- /* Just update bottom space */
- textInfo->bottomSpace -= heightDiff;
- thisLine->lineHeight += heightDiff;
- }
- /* Redraw the current line */
- DrawLine(display, textInfo, textInfo->curLine, textInfo->curY);
- } else {
- /* Just update line height */
- thisLine->lineHeight += heightDiff;
- }
- }
- return 1;
- }
-}
-
-
-
-int TxtWriteStr(display, w, str)
-Display *display;
-Window w; /* Text window */
-register char *str; /* 0 terminated string */
-/*
- * This routine writes a string to the specified text window.
- * The following notes apply:
- * - Text is always appended to the end of the text buffer.
- * - If the scroll bar is positioned such that the end of the
- * text is not visible, an automatic scroll to the bottom
- * will be done before the appending of text.
- * - Non-printable ASCII characters are not displayed.
- * - The '\n' character causes the current text position to
- * advance one line and start at the left.
- * - Tabs are not supported.
- * - Lines too long for the screen will be wrapped and a line wrap
- * indication will be drawn.
- * - Backspace clears the previous character. It will do the right
- * thing if asked to backspace past a wrapped line.
- * - A new font can be chosen using the sequence '^F<digit>' where
- * <digit> is 0-7. The directive will be ignored if
- * there is no font in the specified slot.
- * Returns 0 if something went wrong.
- */
-{
- register int fontIndex;
- register struct txtWin *textInfo;
- register struct txtLine *thisLine;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
- return 0;
-
- /* See if screen needs to be updated */
- if (textInfo->flagWord & SCREENWRONG) {
- TxtRepaint(display, textInfo->mainWindow);
- }
-
- /* See if we have to scroll down to the bottom */
- if (textInfo->flagWord & NOTATBOTTOM) {
- WarpToBottom(display, textInfo);
- textInfo->flagWord &= (~NOTATBOTTOM);
- }
-
- /* Undraw the current cursor */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
-
- XFillRectangle(display, w, textInfo->bgGC,
- thisLine->lineWidth + CUROFFSET,
- textInfo->curY,
- CURSORWIDTH,
- thisLine->lineHeight);
-
- for ( /* str is ok */ ; (*str != 0) ; str++) {
- /* Check to see if we are waiting on a font */
- if (textInfo->flagWord & FONTNUMWAIT) {
- textInfo->flagWord &= (~FONTNUMWAIT);
- fontIndex = *str - '0';
- if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
- /* Handle font -- go get next character */
- if (HandleNewFont(display, fontIndex, textInfo, DODISP))
- continue;
- }
- }
-
- /* Inline code for handling normal character case */
- if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
- register XFontStruct *thisFont;
- register struct txtLine *thisLine;
- register int charWidth;
- int thisColor;
-
- /* Determine size of character */
- thisFont = &(textInfo->theFonts[textInfo->curFont]);
- thisColor = textInfo->theColors[textInfo->curFont];
- if (*str <= thisFont->min_char_or_byte2 ||
- *str >= thisFont->max_char_or_byte2 ||
- thisFont->per_char == 0)
- charWidth = thisFont->max_bounds.width + 1;
- else
- charWidth = thisFont->per_char[*str].width + 1;
-
- /* Check to see if line wrap is required */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- if (thisLine->lineWidth + charWidth >
- (textInfo->w-BARSIZE-WRAPINDSIZE))
- {
- DrawLineWrap(display, textInfo->mainWindow,
- textInfo->w-BARSIZE-WRAPINDSIZE,
- textInfo->curY, thisLine->lineHeight,
- textInfo->fgPix);
- thisLine->lineFlags |= WRAPFLAG;
- /* Handle the spacing problem the same way as a newline */
- HandleNewLine(display, textInfo, DODISP | NONEWLINE);
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- }
-
- /* Ready to draw character */
- XDrawString(display, textInfo->mainWindow,
- DEFAULT_GC,
- textInfo->curX += charWidth,
- textInfo->curY + thisLine->lineHeight,
- str, 1);
-
- /* Append character onto main buffer */
- if (textInfo->bufSpot >= textInfo->bufAlloc)
- /* Make room for more characters */
- ExpandBuffer(textInfo);
- textInfo->mainBuffer[(textInfo->bufSpot)++] =
- (textInfo->curFont << FONTSHIFT) | (*str);
-
- /* Update the line start array */
- thisLine->lineLength += 1;
- thisLine->lineWidth += charWidth;
- } else if (*str == NEWLINE) {
- HandleNewLine(display, textInfo, DODISP);
- } else if (*str == NEWFONT) {
- /* Go into waiting for font number mode */
- textInfo->flagWord |= FONTNUMWAIT;
- } else if (*str == BACKSPACE) {
- HandleBackspace(display, textInfo, DODISP);
- } else {
- /* Ignore all others */
- }
- }
- /* Draw the cursor in its new position */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
-
- XFillRectangle(display, w, textInfo->CursorGC,
- thisLine->lineWidth + CUROFFSET,
- textInfo->curY /* + thisLine->lineHeight */,
- CURSORWIDTH, thisLine->lineHeight);
-
- return 1;
-}
-
-
-
-int TxtJamStr(display, w, str)
-Display *display;
-Window w; /* Text window */
-register char *str; /* NULL terminated string */
-/*
- * This is the same as TxtWriteStr except the screen is NOT updated.
- * After a call to this routine, TxtRepaint should be called to
- * update the screen. This routine is meant to be used to load
- * a text buffer with information and then allow the user to
- * scroll through it at will.
- */
-{
- register int fontIndex;
- register struct txtWin *textInfo;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
- ) == 0)
- return 0;
-
- for ( /* str is ok */ ; (*str != 0) ; str++) {
- /* Check to see if we are waiting on a font */
- if (textInfo->flagWord & FONTNUMWAIT) {
- textInfo->flagWord &= (~FONTNUMWAIT);
- fontIndex = *str - '0';
- if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
- if (HandleNewFont(display, fontIndex, textInfo, 0)) {
- /* Handled font -- go get next character */
- continue;
- }
- }
- }
- /* Inline code for handling normal character case */
- if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
- register XFontStruct *thisFont;
- register struct txtLine *thisLine;
- register int charWidth;
-
- /* Determine size of character */
- thisFont = &(textInfo->theFonts[textInfo->curFont]);
-
- if (*str <= thisFont->min_char_or_byte2 ||
- *str >= thisFont->max_char_or_byte2 ||
- thisFont->per_char == 0)
- charWidth = thisFont->max_bounds.width + 1;
- else
- charWidth = thisFont->per_char[*str].width + 1;
-
- /* Check to see if line wrap is required */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- if (thisLine->lineWidth + charWidth >
- (textInfo->w-BARSIZE-WRAPINDSIZE))
- {
- thisLine->lineFlags |= WRAPFLAG;
- /* Handle the spacing problem the same way as a newline */
- HandleNewLine(display, textInfo, NONEWLINE);
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- }
- /* Append character onto main buffer */
- if (textInfo->bufSpot >= textInfo->bufAlloc)
- /* Make room for more characters */
- ExpandBuffer(textInfo);
- textInfo->mainBuffer[(textInfo->bufSpot)++] =
- (textInfo->curFont << FONTSHIFT) | (*str);
-
- /* Update the line start array */
- thisLine->lineLength += 1;
- thisLine->lineWidth += charWidth;
- } else if (*str == NEWLINE) {
- HandleNewLine(display, textInfo, 0);
- } else if (*str == NEWFONT) {
- /* Go into waiting for font number mode */
- textInfo->flagWord |= FONTNUMWAIT;
- } else if (*str == BACKSPACE) {
- HandleBackspace(display, textInfo, 0);
- } else {
- /* Ignore all others */
- }
- }
- textInfo->flagWord |= SCREENWRONG;
- return 1;
-}
-
-
-
-int TxtRepaint(display,w)
-Display *display;
-Window w;
-/*
- * Repaints the given scrollable text window. The routine repaints
- * the entire window. For handling exposure events, the TxtFilter
- * routine should be used.
- */
-{
- struct txtWin *textInfo;
- int index, ypos;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
- ) == 0)
- return 0;
-
- /* Check to see if the screen is up to date */
- if (textInfo->flagWord & SCREENWRONG) {
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- textInfo->flagWord &= (~SCREENWRONG);
- }
-
- ypos = YPADDING;
- index = textInfo->startLine;
- for (;;) {
- DrawLine(display, textInfo, index, ypos);
- if (index >= textInfo->endLine) break;
- ypos += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
- index++;
- }
- /* Draw the cursor (if on screen) */
- if (textInfo->endLine == textInfo->curLine) {
- XFillRectangle(display, w, textInfo->CursorGC,
- textInfo->txtBuffer[index]->lineWidth + CUROFFSET,
- ypos /* + textInfo->txtBuffer[index]->lineHeight */,
- CURSORWIDTH, textInfo->txtBuffer[index]->lineHeight);
-
- }
- /* Update the scroll bar */
- UpdateScroll(display, textInfo);
- return 1;
-}
-
-
-
-static int InsertIndex(textInfo, thisIndex, ypos)
-struct txtWin *textInfo; /* Text Window Information */
-int thisIndex; /* Line index of exposed line */
-int ypos; /* Drawing position of line */
-/*
- * This routine inserts the supplied line index into the copy
- * exposure array for 'textInfo'. The array is kept sorted
- * from lowest to highest using insertion sort. The array
- * is dynamically expanded if needed.
- */
-{
- struct expEvent *newItem;
- int newSize, index, downIndex;
-
- /* Check to see if we need to expand it */
- if ((textInfo->exposeSize + 3) >= textInfo->exposeAlloc) {
- newSize = textInfo->exposeAlloc +
- (textInfo->exposeAlloc * EXPANDPERCENT / 100);
- textInfo->exposeAry = (struct expEvent **)
- realloc((char *) textInfo->exposeAry,
- (unsigned) (newSize * sizeof(struct expEvent *)));
- for (index = textInfo->exposeAlloc; index < newSize; index++)
- textInfo->exposeAry[index] = alloc(struct expEvent);
- textInfo->exposeAlloc = newSize;
- }
- /* Find spot for insertion. NOTE: last spot has big number */
- for (index = 0; index <= textInfo->exposeSize; index++) {
- if (textInfo->exposeAry[index]->lineIndex >= thisIndex) {
- if (textInfo->exposeAry[index]->lineIndex > thisIndex) {
- /* Insert before this entry */
- newItem = textInfo->exposeAry[textInfo->exposeSize+1];
- for (downIndex = textInfo->exposeSize;
- downIndex >= index;
- downIndex--)
- {
- textInfo->exposeAry[downIndex+1] =
- textInfo->exposeAry[downIndex];
- }
- /* Put a free structure at this spot */
- textInfo->exposeAry[index] = newItem;
- /* Fill it in */
- textInfo->exposeAry[index]->lineIndex = thisIndex;
- textInfo->exposeAry[index]->ypos = ypos;
- /* Break out of loop */
- textInfo->exposeSize += 1;
- }
- break;
- }
- }
- return 1;
-}
-
-
-
-static int ScrollUp(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine scrolls the indicated text window up by one
- * line. The line above the current line must exist. The
- * window is scrolled so that the line above the start line
- * is displayed at the top of the screen. This may cause
- * many lines to scroll off the bottom. The scrolling is
- * done using XCopyArea. The exposure events should be caught
- * by ExposeCopy.
- */
-{
- int targetSpace;
-
- /* Make sure all exposures have been handled by now */
- if (textInfo->startLine == 0) return 0;
- targetSpace = textInfo->txtBuffer[textInfo->startLine-1]->lineHeight +
- INTERLINE;
- /* Move the area downward by the target amount */
- XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
- DEFAULT_GC,
- 0, YPADDING, textInfo->w - BARSIZE,
- textInfo->h, 0, targetSpace);
-
- textInfo->flagWord |= COPYEXPOSE;
- /* Update the text window parameters */
- textInfo->startLine -= 1;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
-
- /* Clear out bottom space region */
- XClearArea(display, textInfo->mainWindow,
- 0, textInfo->h - textInfo->bottomSpace,
- textInfo->w, textInfo->bottomSpace);
-
- UpdateExposures(display, textInfo);
- UpdateScroll(display, textInfo);
-
- return 1;
-}
-
-
-static int ScrollToSpot(display, textInfo, ySpot)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int ySpot; /* Button position in scroll window */
-/*
- * This routine scrolls the specified text window relative to the
- * position of the mouse in the scroll bar. The center of the screen
- * will be positioned to correspond to the mouse position.
- */
-{
- int targetLine, aboveLines;
-
- targetLine = textInfo->numLines * ySpot / textInfo->h;
- textInfo->startLine = targetLine;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- aboveLines = 0;
- /* Make the target line the *center* of the window */
- while ((textInfo->startLine > 0) &&
- (aboveLines < textInfo->endLine - targetLine))
- {
- textInfo->startLine -= 1;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- aboveLines++;
- }
- if (textInfo->endLine == textInfo->numLines-1) {
- WarpToBottom(display, textInfo);
- } else {
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- }
- return 1;
-}
-
-
-
-static int LineToTop(display, textInfo, pos)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int pos; /* Y position of mouse */
-/*
- * This routine scrolls the screen down until the line at the
- * mouse position is at the top of the screen. It stops
- * if it can't scroll the buffer down that far. If the
- * global 'ScrollOption' is NORMSCROLL, a smooth scroll
- * is used. Otherwise, it jumps to the right position
- * and repaints the screen.
- */
-{
- int index, sum;
-
- /* First, we find the current line */
- sum = 0;
- for (index = textInfo->startLine; index <= textInfo->endLine; index++) {
- if (sum + textInfo->txtBuffer[index]->lineHeight + INTERLINE> pos) break;
- sum += textInfo->txtBuffer[index]->lineHeight + INTERLINE;
- }
- /* We always want to scroll down at least one line */
- if (index == textInfo->startLine) index++;
- if (ScrollOption == NORMSCROLL) {
- /* Scroll down until 'index' is the starting line */
- while ((textInfo->startLine < index) && ScrollDown(display, textInfo))
- {
- /* Empty Loop Body */
- }
- } else {
- /* Immediately jump to correct spot */
- textInfo->startLine = index;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- if (textInfo->endLine == textInfo->numLines-1) {
- WarpToBottom(display, textInfo);
- } else {
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- }
- }
- /* Check to see if at end of buffer */
- if (textInfo->endLine >= textInfo->numLines-1) {
- textInfo->flagWord &= (~NOTATBOTTOM);
- }
- return 1;
-}
-
-
-
-static int TopToHere(display, textInfo, pos)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int pos; /* Y position of mouse */
-/*
- * This routine scrolls the screen up until the top line of
- * the screen is at the current Y position of the mouse. Again,
- * it will stop if it can't scroll that far. If the global
- * 'ScrollOption' is NORMSCROLL, a smooth scroll is used.
- * If it's not, it will simply redraw the screen at the
- * correct spot.
- */
-{
- int sum, target, linesup, index;
-
- target = pos - textInfo->txtBuffer[textInfo->startLine]->lineHeight;
- /* We always want to scroll up at least one line */
- if (target <= 0) target = 1;
- sum = 0;
- linesup = 0;
- /* Check to see if we are at the top anyway */
- if (textInfo->startLine == 0) return 0;
- if (ScrollOption == NORMSCROLL) {
- /* Scroll up until sum of new top lines greater than target */
- while ((sum < target) && ScrollUp(display, textInfo)) {
- sum += textInfo->txtBuffer[textInfo->startLine]->lineHeight;
- linesup++;
- }
- } else {
- /* Search backward to find index */
- index = textInfo->startLine - 1;
- while ((index > 0) && (sum < target)) {
- sum += textInfo->txtBuffer[index]->lineHeight;
- linesup++;
- index--;
- }
- /* Go directly to the index */
- textInfo->startLine = index;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- }
- /* If we scrolled, assert we are not at bottom of buffer */
- if (linesup > 0) {
- textInfo->flagWord |= NOTATBOTTOM;
- }
- return 1;
-}
-
-
-
-int TxtFilter(display, evt)
-Display *display;
-XEvent *evt;
-/*
- * This routine handles events associated with scrollable text windows.
- * It will handle all exposure events and any button released events
- * in the scroll bar of a text window. It does NOT handle any other
- * events. If it cannot handle the event, it will return 0.
- */
-{
- XExposeEvent *expose = &evt->xexpose;
- XButtonEvent *btEvt = &evt->xbutton;
- XGraphicsExposeEvent *gexpose = &evt->xgraphicsexpose;
- XNoExposeEvent *noexpose = &evt->xnoexpose;
- struct txtWin *textInfo;
- int index, ypos;
- Window w, sw;
-
- if (textWindows == (XAssocTable *) 0) {
- textWindows = XCreateAssocTable(32);
- if (textWindows == (XAssocTable *) 0) return(0);
- }
- if (evt->type == Expose) {
- w = expose->window;
- sw = 0;
- }
- else if (evt->type == GraphicsExpose) {
- w = gexpose->drawable;
- sw = 0;
- }
- else if (evt->type == NoExpose) {
- w = noexpose->drawable;
- sw = 0;
- }
- else if (evt->type == ButtonRelease) {
- w = btEvt->window;
- sw = btEvt->subwindow;
- }
- else
- return 0;
-
- if ((textInfo = (struct txtWin *)
- XLookUpAssoc(display, textWindows, (XID) w)) == 0)
- return 0;
-
- /* Determine whether it's main window or not */
- if ((w == textInfo->mainWindow) && (sw == 0)) {
- /* Main Window - handle exposures */
- switch (evt->type) {
- case Expose:
- ypos = 0 /*YPADDING*/;
- for (index = textInfo->startLine;
- index <= textInfo->endLine;
- index++)
- {
- int lh = textInfo->txtBuffer[index]->lineHeight;
-
- if (((ypos + lh) >= expose->y) &&
- (ypos <= (expose->y + expose->height)))
- {
- /* Intersection region */
- /* Draw line immediately */
- DrawLine(display, textInfo, index, ypos);
- /* And possibly draw cursor */
- if (textInfo->curLine == index) {
- XFillRectangle(display, w, textInfo->CursorGC,
- textInfo->txtBuffer[index]->lineWidth +
- CUROFFSET,
- ypos,
- CURSORWIDTH,
- lh);
- }
- }
- ypos += lh + INTERLINE;
- }
- break;
- case GraphicsExpose:
- ypos = 0 /*YPADDING*/;
- for (index = textInfo->startLine;
- index <= textInfo->endLine;
- index++)
- {
- int lh = textInfo->txtBuffer[index]->lineHeight;
-
- if (((ypos + lh) >= gexpose->y) &&
- (ypos <= (gexpose->y + gexpose->height)))
- {
- /* Intersection region */
- /* Draw line immediately */
- DrawLine(display, textInfo, index, ypos);
- /* And possibly draw cursor */
- if (textInfo->curLine == index) {
- XFillRectangle(display, w, textInfo->CursorGC,
- textInfo->txtBuffer[index]->lineWidth +
- CUROFFSET,
- ypos,
- CURSORWIDTH,
- lh);
- }
- }
- ypos += lh + INTERLINE;
- }
- break;
- case NoExpose:
- break;
- default:
- /* Not one of our events */
- return 0;
- }
- } else {
- switch (evt->type) {
- case Expose:
- UpdateScroll(display, textInfo);
- break;
- case ButtonRelease:
- /* Find out which button */
- switch (btEvt->button) {
- case Button1:
- /* Scroll up until top line is at mouse position */
- TopToHere(display, textInfo, btEvt->y);
- break;
- case Button2:
- /* Scroll to spot relative to position */
- ScrollToSpot(display, textInfo, btEvt->y);
- if (textInfo->endLine >= textInfo->numLines-1) {
- textInfo->flagWord &= (~NOTATBOTTOM);
- } else {
- textInfo->flagWord |= NOTATBOTTOM;
- }
- break;
- case Button3:
- /* Scroll down until pointed line is at top */
- LineToTop(display, textInfo, btEvt->y);
- break;
- }
- break;
- default:
- /* Not one of our events */
- return 0;
- }
- }
- return 1;
-}
diff --git a/gnu/games/chess/Xchess/scrollText.h b/gnu/games/chess/Xchess/scrollText.h
deleted file mode 100644
index d9d05b0..0000000
--- a/gnu/games/chess/Xchess/scrollText.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Scrollable Text Window Header File
- *
- * David Harrison
- * University of California, Berkeley
- * 1986
- *
- * This file contains definitions for a scrollable text window
- * with scroll bar support.
- */
-
-int TxtGrab();
- /* Take hold of a previously created window */
-
-#define TXT_NO_COLOR -1
-
-int TxtAddFont();
- /* Loads a new font for use later */
-int TxtWinP();
- /* Returns non-zero value if the window is text window */
-int TxtClear();
- /* Clears text window and resets text buffer */
-
-int TxtWriteStr();
- /* Writes a string to window with immediate update */
-int TxtJamStr();
- /* Write a string without causing update to screen */
-
-int TxtRepaint();
- /* Repaints entire scrollable text window */
-int TxtFilter();
- /* Handles events related to text window */
diff --git a/gnu/games/chess/Xchess/scrollText/scrollText.c b/gnu/games/chess/Xchess/scrollText/scrollText.c
deleted file mode 100644
index 4320710..0000000
--- a/gnu/games/chess/Xchess/scrollText/scrollText.c
+++ /dev/null
@@ -1,1858 +0,0 @@
-/*
- * A Scrollable Text Output Window
- *
- * David Harrison
- * University of California, Berkeley
- * 1986
- *
- * The following is an implementation for a scrollable text output
- * system. It handles exposure events only (other interactions are
- * under user control). For scrolling, a always present scroll bar
- * is implemented. It detects size changes and compensates accordingly.
- */
-
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/X10.h>
-#include <sys/types.h>
-#include "scrollText.h"
-
-extern char *malloc();
-extern char *realloc();
-#define alloc(type) (type *) malloc(sizeof(type))
-#define numalloc(type, num) (type *) malloc((unsigned) (num * sizeof(type)))
-#define MAXINT 2147483647
-
-extern XAssocTable *XCreateAssocTable();
-extern caddr_t XLookUpAssoc();
-
-static XAssocTable *textWindows = (XAssocTable *) 0;
-
-#define NOOPTION -1 /* Option hasn't been set yet */
-#define NORMSCROLL 0 /* Smooth scroll on LineToTop and TopToHere */
-#define JUMPSCROLL 1 /* Jump scrolling on LineToTop and TopToHere */
-
-static int ScrollOption = NOOPTION;
-
-typedef char *Generic;
-
-#define DEFAULT_GC textInfo->fontGC[textInfo->curFont]
-
-#define BARSIZE 15
-#define BARBORDER 1
-#define MAXFONTS 8
-#define INITBUFSIZE 1024
-#define INITLINES 50
-#define INITEXPARY 50
-#define XPADDING 2
-#define YPADDING 2
-#define INTERLINE 5
-#define INTERSPACE 1
-#define CURSORWIDTH 2
-#define EXPANDPERCENT 40
-#define BUFSIZE 1024
-#define CUROFFSET 1
-#define MAXFOREIGN 250
-#define NOINDEX -1
-
-/* The wrap line indicator */
-#define WRAPINDSIZE 7
-#define STEMOFFSET 5
-#define arrow_width 7
-#define arrow_height 5
-static char arrow_bits[] = {
- 0x24, 0x26, 0x3f, 0x06, 0x04};
-
-#define NEWLINE '\n'
-#define BACKSPACE '\010'
-#define NEWFONT '\006'
-#define LOWCHAR '\040'
-#define HIGHCHAR '\176'
-
-#define CHARMASK 0x00ff /* Character mask */
-#define FONTMASK 0x0700 /* Character font */
-#define FONTSHIFT 8 /* Shift amount */
-
-#define WRAPFLAG 0x01 /* Line wrap flag */
-
-/*
- * Lines are represented by a pointer into the overall array of
- * 16-bit characters. The lower eight bits is used to indicate the character
- * (in ASCII), and the next two bits are used to indicate the font
- * the character should be drawn in.
- */
-
-typedef struct txtLine {
- int lineLength; /* Current line length */
- int lineHeight; /* Full height of line in pixels */
- int lineBaseLine; /* Current baseline of the line */
- int lineWidth; /* Drawing position at end of line */
- int lineText; /* Offset into master buffer */
- int lineFlags; /* Line wrap flag is here */
-};
-
-
-/*
- * For ExposeCopy events, we queue up the redraw requests collapsing
- * them into line redraw requests until the CopyExpose event arrives.
- * The queue is represented as a dynamic array of the following
- * structure:
- */
-
-typedef struct expEvent {
- int lineIndex; /* Index of line to redraw */
- int ypos; /* Drawing position of line */
-};
-
-
-/*
- * The text buffer is represented using a dynamic counted array
- * of 16-bit quantities. This array expands as needed.
- * For the screen representation, a dynamic counted array
- * of line structures is used. This array points into the
- * text buffer to denote the start of each line and its parameters.
- * The windows are configured as one overall window which contains
- * the scroll bar as a sub-window along its right edge. Thus,
- * the text drawing space is actually w-BARSIZE.
- */
-
-#define NOTATBOTTOM 0x01 /* Need to scroll to bottom before appending */
-#define FONTNUMWAIT 0x02 /* Waiting for font number */
-#define COPYEXPOSE 0x04 /* Need to process a copy expose event */
-#define SCREENWRONG 0x08 /* TxtJamStr has invalidated screen contents */
-
-typedef struct txtWin {
- /* Basic text buffer */
- int bufAlloc; /* Allocated size of buffer */
- int bufSpot; /* Current writing position in buffer */
- short *mainBuffer; /* Main buffer of text */
-
- /* Line information */
- int numLines; /* Number of display lines in buffer */
- int allocLines; /* Number of lines allocated */
- struct txtLine **txtBuffer; /* Dynamic array of lines */
-
- /* Current Window display information */
- Window mainWindow; /* Text display window */
- Window scrollBar; /* Subwindow for scroll bar */
- Pixmap arrowMap; /* line wrap indicator */
- int bgPix, fgPix; /* Background and cursor */
- GC CursorGC; /* gc for the cursor */
- GC bgGC; /* gc for erasing things */
- GC fontGC[MAXFONTS]; /* gc for doing fonts */
- XFontStruct theFonts[MAXFONTS];/* Display fonts */
- int theColors[MAXFONTS]; /* foregrounds of the fonts */
- int curFont; /* current font for tracking */
- int w, h; /* Current size */
- int startLine; /* Top line in display */
- int endLine; /* Bottom line in display */
- int bottomSpace; /* Space at bottom of screen */
- int flagWord; /* If non-zero, not at end */
-
- /* For handling ExposeCopy events */
- int exposeSize; /* Current size of array */
- int exposeAlloc; /* Allocated size */
- struct expEvent **exposeAry;/* Array of line indices */
-
- /* Drawing position information */
- int curLine; /* Current line in buffer */
- int curX; /* Current horizontal positi */
- int curY; /* Current vertical drawing */
-};
-
-/* Flags for the various basic character handling functions */
-
-#define DODISP 0x01 /* Update the display */
-#define NONEWLINE 0x02 /* Dont append newline */
-
-
-
-static int InitLine(newLine)
-struct txtLine *newLine; /* Newly created line structure */
-/*
- * This routine initializes a newly created line structure.
- */
-{
- newLine->lineLength = 0;
- newLine->lineHeight = 0;
- newLine->lineBaseLine = 0;
- newLine->lineWidth = XPADDING;
- newLine->lineText = NOINDEX;
- newLine->lineFlags = 0;
- return 1;
-}
-
-
-
-
-int TxtGrab(display, txtWin, program, mainFont, bg, fg, cur)
-Display *display; /* display window is on */
-Window txtWin; /* Window to take over as scrollable text */
-char *program; /* Program name for Xdefaults */
-XFontStruct *mainFont; /* Primary text font */
-int bg, fg, cur; /* Background, foreground, and cursor colors */
-/*
- * This routine takes control of 'txtWin' and makes it into a scrollable
- * text output window. It will create a sub-window for the scroll bar
- * with a background of 'bg' and an bar with color 'fg'. Both fixed width
- * and variable width fonts are supported. Additional fonts can be loaded
- * using 'TxtAddFont'. Returns 0 if there were problems, non-zero if
- * everything went ok.
- */
-{
- struct txtWin *newWin; /* Text package specific information */
- XWindowAttributes winInfo; /* Window information */
- int index;
- XGCValues gc_val;
-
- if (textWindows == (XAssocTable *) 0) {
- textWindows = XCreateAssocTable(32);
- if (textWindows == (XAssocTable *) 0) return(0);
- }
- if (XGetWindowAttributes(display, txtWin, &winInfo) == 0) return 0;
-
- if (ScrollOption == NOOPTION) {
- /* Read to see if the user wants jump scrolling or not */
- if (XGetDefault(display, program, "JumpScroll")) {
- ScrollOption = JUMPSCROLL;
- } else {
- ScrollOption = NORMSCROLL;
- }
- }
-
- /* Initialize local structure */
- newWin = alloc(struct txtWin);
-
- /* Initialize arrow pixmap */
- newWin->arrowMap = XCreatePixmapFromBitmapData(display, txtWin,
- arrow_bits,
- arrow_width, arrow_height,
- cur, bg,
- DisplayPlanes(display, 0));
-
- newWin->bufAlloc = INITBUFSIZE;
- newWin->bufSpot = 0;
- newWin->mainBuffer = numalloc(short, INITBUFSIZE);
-
- newWin->numLines = 1;
- newWin->allocLines = INITLINES;
- newWin->txtBuffer = numalloc(struct txtLine *, INITLINES);
- for (index = 0; index < INITLINES; index++) {
- newWin->txtBuffer[index] = alloc(struct txtLine);
- InitLine(newWin->txtBuffer[index]);
- }
-
- /* Window display information */
- newWin->mainWindow = txtWin;
- newWin->w = winInfo.width;
- newWin->h = winInfo.height;
- newWin->startLine = 0;
- newWin->endLine = 0;
- newWin->bottomSpace = winInfo.height
- - YPADDING - mainFont->ascent - mainFont->descent - INTERLINE;
- newWin->flagWord = 0;
- newWin->bgPix = bg;
- newWin->fgPix = fg;
-
- /* Scroll Bar Creation */
- newWin->scrollBar = XCreateSimpleWindow(display, txtWin,
- winInfo.width - BARSIZE,
- 0, BARSIZE - (2*BARBORDER),
- winInfo.height - (2*BARBORDER),
- BARBORDER,
- fg, bg);
- XSelectInput(display, newWin->scrollBar, ExposureMask|ButtonReleaseMask);
- XMapRaised(display, newWin->scrollBar);
-
- /* Font and Color Initialization */
- newWin->theFonts[0] = *mainFont;
- newWin->theColors[0] = fg;
- gc_val.function = GXcopy;
- gc_val.plane_mask = AllPlanes;
- gc_val.foreground = fg;
- gc_val.background = bg;
- gc_val.graphics_exposures = 1;
- gc_val.font = mainFont->fid;
- gc_val.line_width = 1;
- gc_val.line_style = LineSolid;
-
- newWin->fontGC[0] = XCreateGC(display, txtWin,
- GCFunction | GCPlaneMask |
- GCForeground | GCBackground |
- GCGraphicsExposures | GCFont,
- &gc_val);
-
- gc_val.foreground = cur;
- newWin->CursorGC = XCreateGC(display, txtWin,
- GCFunction | GCPlaneMask |
- GCForeground | GCBackground |
- GCLineStyle | GCLineWidth,
- &gc_val);
-
- gc_val.foreground = bg;
- newWin->bgGC = XCreateGC(display, txtWin,
- GCFunction | GCPlaneMask |
- GCForeground | GCBackground |
- GCGraphicsExposures | GCFont,
- &gc_val);
-
-
- for (index = 1; index < MAXFONTS; index++) {
- newWin->theFonts[index].fid = 0;
- newWin->fontGC[index] = 0;
- }
-
-
- /* Initialize size of first line */
- newWin->txtBuffer[0]->lineHeight = newWin->theFonts[0].ascent +
- newWin->theFonts[0].descent;
- newWin->txtBuffer[0]->lineText = 0;
-
- /* ExposeCopy array initialization */
- newWin->exposeSize = 0;
- newWin->exposeAlloc = INITEXPARY;
- newWin->exposeAry = numalloc(struct expEvent *, INITEXPARY);
- for (index = 0; index < newWin->exposeAlloc; index++)
- newWin->exposeAry[index] = alloc(struct expEvent);
- /* Put plus infinity in last slot for sorting purposes */
- newWin->exposeAry[0]->lineIndex = MAXINT;
-
- /* Drawing Position Information */
- newWin->curLine = 0;
- newWin->curX = 0;
- newWin->curY = YPADDING + mainFont->ascent + mainFont->descent;
-
- /* Attach it to both windows */
- XMakeAssoc(display, textWindows, (XID) txtWin, (caddr_t) newWin);
- XMakeAssoc(display, textWindows, (XID) newWin->scrollBar, (caddr_t) newWin);
- return 1;
-}
-
-
-int TxtRelease(display, w)
-Display *display;
-Window w; /* Window to release */
-/*
- * This routine releases all resources associated with the
- * specified window which are consumed by the text
- * window package. This includes the entire text buffer, line start
- * array, and the scroll bar window. However, the window
- * itself is NOT destroyed. The routine will return zero if
- * the window is not owned by the text window package.
- */
-{
- struct txtWin *textInfo;
- int index;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display,
- textWindows, (XID) w)) == 0)
- return 0;
-
- for (index = 0; index < MAXFONTS; index++)
- if (textInfo->fontGC[index] != 0)
- XFreeGC(display, textInfo->fontGC[index]);
-
- free((Generic) textInfo->mainBuffer);
- for (index = 0; index < textInfo->numLines; index++) {
- free((Generic) textInfo->txtBuffer[index]);
- }
- free((Generic) textInfo->txtBuffer);
- XDestroyWindow(display, textInfo->scrollBar);
- for (index = 0; index < textInfo->exposeSize; index++) {
- free((Generic) textInfo->exposeAry[index]);
- }
- free((Generic) textInfo->exposeAry);
- XDeleteAssoc(display, textWindows, (XID) w);
- free((Generic) textInfo);
- return 1;
-}
-
-
-
-static int RecompBuffer(textInfo)
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine recomputes all line breaks in a buffer after
- * a change in window size or font. This is done by throwing
- * away the old line start array and recomputing it. Although
- * a lot of this work is also done elsewhere, it has been included
- * inline here for efficiency.
- */
-{
- int startPos, endSize, linenum;
- register int index, chsize, curfont;
- register short *bufptr;
- register XFontStruct *fontptr;
- register struct txtLine *lineptr;
- char theChar;
-
- /* Record the old position so we can come back to it */
- for (startPos = textInfo->txtBuffer[textInfo->startLine]->lineText;
- (startPos > 0) && (textInfo->mainBuffer[startPos] != '\n');
- startPos--)
- /* null loop body */;
-
- /* Clear out the old line start array */
- for (index = 0; index < textInfo->numLines; index++) {
- InitLine(textInfo->txtBuffer[index]);
- }
-
- /* Initialize first line */
- textInfo->txtBuffer[0]->lineHeight =
- textInfo->theFonts[0].ascent + textInfo->theFonts[0].descent;
- textInfo->txtBuffer[0]->lineText = 0;
-
- /* Process the text back into lines */
- endSize = textInfo->w - BARSIZE - WRAPINDSIZE;
- bufptr = textInfo->mainBuffer;
- lineptr = textInfo->txtBuffer[0];
- linenum = 0;
- fontptr = &(textInfo->theFonts[0]);
- curfont = 0;
- for (index = 0; index < textInfo->bufSpot; index++) {
- theChar = bufptr[index] & CHARMASK;
-
- if ((bufptr[index] & FONTMASK) != curfont) {
- int newFontNum, heightDiff;
-
- /* Switch fonts */
- newFontNum = (bufptr[index] & FONTMASK) >> FONTSHIFT;
- if (textInfo->theFonts[newFontNum].fid != 0) {
- /* Valid font */
- curfont = bufptr[index] & FONTMASK;
- fontptr = &(textInfo->theFonts[newFontNum]);
- heightDiff = (fontptr->ascent + fontptr->descent) -
- lineptr->lineHeight;
- if (heightDiff < 0) heightDiff = 0;
- lineptr->lineHeight += heightDiff;
- }
- }
- if (theChar == '\n') {
- /* Handle new line */
- if (linenum >= textInfo->allocLines-1)
- /* Expand number of lines */
- ExpandLines(textInfo);
- linenum++;
- lineptr = textInfo->txtBuffer[linenum];
- /* Initialize next line */
- lineptr->lineHeight = fontptr->ascent + fontptr->descent;
- lineptr->lineText = index+1;
- /* Check to see if its the starting line */
- if (index == startPos) textInfo->startLine = linenum;
- } else {
- /* Handle normal character */
- chsize = CharSize(textInfo, linenum, index);
- if (lineptr->lineWidth + chsize > endSize) {
- /* Handle line wrap */
- lineptr->lineFlags |= WRAPFLAG;
- if (linenum >= textInfo->allocLines-1)
- /* Expand number of lines */
- ExpandLines(textInfo);
- linenum++;
- lineptr = textInfo->txtBuffer[linenum];
- /* Initialize next line */
- lineptr->lineHeight = fontptr->ascent + fontptr->descent;
- lineptr->lineText = index;
- lineptr->lineLength = 1;
- lineptr->lineWidth += chsize;
- } else {
- /* Handle normal addition of character */
- lineptr->lineLength += 1;
- lineptr->lineWidth += chsize;
- }
- }
- }
- /* We now have a valid line array. Let's clean up some other fields. */
- textInfo->numLines = linenum+1;
- if (startPos == 0) {
- textInfo->startLine = 0;
- }
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- textInfo->curLine = linenum;
- /* Check to see if we are at the bottom */
- if (textInfo->endLine >= textInfo->numLines-1) {
- textInfo->curY = textInfo->h - textInfo->bottomSpace -
- lineptr->lineHeight;
- textInfo->flagWord &= (~NOTATBOTTOM);
- } else {
- textInfo->flagWord |= NOTATBOTTOM;
- }
- return 1;
-}
-
-
-
-
-int TxtAddFont(display, textWin, fontNumber, newFont, newColor)
-Display *display;
-Window textWin; /* Scrollable text window */
-int fontNumber; /* Place to add font (0-7) */
-XFontStruct *newFont; /* Font to add */
-int newColor; /* Color of font */
-/*
- * This routine loads a new font so that it can be used in a previously
- * created text window. There are eight font slots numbered 0 through 7.
- * If there is already a font in the specified slot, it will be replaced
- * and an automatic redraw of the window will take place. See TxtWriteStr
- * for details on using alternate fonts. The color specifies the foreground
- * color of the text. The default foreground color is used if this
- * parameter is TXT_NO_COLOR. Returns a non-zero value if
- * everything went well.
- */
-{
- struct txtWin *textInfo;
- int redrawFlag;
- XGCValues gc_val;
-
- if ((fontNumber < 0) || (fontNumber >= MAXFONTS)) return 0;
- if ((textInfo = (struct txtWin *)
- XLookUpAssoc(display, textWindows, (XID) textWin)) == 0)
- return 0;
- if (newColor == TXT_NO_COLOR) {
- newColor = textInfo->fgPix;
- }
-
- gc_val.font = newFont->fid;
- gc_val.foreground = newColor;
- gc_val.background = textInfo->bgPix;
- gc_val.plane_mask = AllPlanes;
- gc_val.graphics_exposures = 1;
- gc_val.function = GXcopy;
-
- if (textInfo->fontGC[fontNumber] != 0)
- {
- XChangeGC(display, textInfo->fontGC[fontNumber],
- GCFont | GCForeground, &gc_val);
- }
- else
- textInfo->fontGC[fontNumber] = XCreateGC(display, textWin,
- GCFont |
- GCForeground |
- GCBackground |
- GCFunction |
- GCPlaneMask |
- GCGraphicsExposures,
- &gc_val);
-
-
- redrawFlag = (textInfo->theFonts[fontNumber].fid != 0) &&
- (((newFont) && (newFont->fid != textInfo->theFonts[fontNumber].fid)) ||
- (newColor != textInfo->theColors[fontNumber]));
- if (newFont) {
- textInfo->theFonts[fontNumber] = *newFont;
- }
- textInfo->theColors[fontNumber] = newColor;
-
- if (redrawFlag) {
- RecompBuffer(textInfo);
- XClearWindow(display, textWin);
- TxtRepaint(display, textWin);
- }
- return 1;
-}
-
-
-
-int TxtWinP(display, w)
-Display *display;
-Window w;
-/*
- * Returns a non-zero value if the window has been previously grabbed
- * using TxtGrab and 0 if it has not.
- */
-{
- if (XLookUpAssoc(display, textWindows, (XID) w))
- return(1);
- else return(0);
-}
-
-
-
-static int FindEndLine(textInfo, botSpace)
-struct txtWin *textInfo;
-int *botSpace;
-/*
- * Given the starting line in 'textInfo->startLine', this routine
- * determines the index of the last line that can be drawn given the
- * current size of the screen. If there are not enough lines to
- * fill the screen, the index of the last line will be returned.
- * The amount of empty bottom space is returned in 'botSpace'.
- */
-{
- int index, height, lineHeight;
-
- height = YPADDING;
- index = textInfo->startLine;
- while (index < textInfo->numLines) {
- lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
- if (height + lineHeight > textInfo->h) break;
- height += lineHeight;
- index++;
- }
- if (botSpace) {
- *botSpace = textInfo->h - height;
- }
- return index - 1;
-}
-
-
-
-static int UpdateScroll(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine computes the current extent of the scroll bar
- * indicator and repaints the bar with the correct information.
- */
-{
- int top, bottom;
-
- if (textInfo->numLines > 1) {
- top = textInfo->startLine * (textInfo->h - 2*BARBORDER) /
- (textInfo->numLines - 1);
- bottom = textInfo->endLine * (textInfo->h - 2*BARBORDER) /
- (textInfo->numLines - 1);
- } else {
- top = 0;
- bottom = textInfo->h - (2*BARBORDER);
- }
-
- /* Draw it - make sure there is a little padding */
- if (top == 0) top++;
- if (bottom == textInfo->h-(2*BARBORDER)) bottom--;
-
- XFillRectangle(display, textInfo->scrollBar,
- textInfo->bgGC,
- 0, 0, BARSIZE, top-1);
- XFillRectangle(display, textInfo->scrollBar,
- DEFAULT_GC, top, BARSIZE - (2*BARBORDER) - 2,
- bottom - top);
- XFillRectangle(display, textInfo->scrollBar, DEFAULT_GC,
- 0, bottom+1, BARSIZE,
- textInfo->h - (2 * BARBORDER) - bottom);
-
- return 1;
-}
-
-
-
-
-int TxtClear(display, w)
-Display *display;
-Window w;
-/*
- * This routine clears a scrollable text window. It resets the current
- * writing position to the upper left hand corner of the screen.
- * NOTE: THIS ALSO CLEARS THE CONTENTS OF THE TEXT WINDOW BUFFER AND
- * RESETS THE SCROLL BAR. Returns 0 if the window is not a text window.
- * This should be used *instead* of XClear.
- */
-{
- struct txtWin *textInfo;
- int index;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
- return 0;
-
- /* Zero out the arrays */
- textInfo->bufSpot = 0;
- for (index = 0; index < textInfo->numLines; index++) {
- InitLine(textInfo->txtBuffer[index]);
- }
- textInfo->txtBuffer[0]->lineHeight =
- textInfo->theFonts[textInfo->curFont].ascent +
- textInfo->theFonts[textInfo->curFont].descent;
-
- textInfo->numLines = 1;
- textInfo->startLine = 0;
- textInfo->endLine = 0;
- textInfo->curLine = 0;
- textInfo->curX = 0;
- textInfo->curY = YPADDING + textInfo->theFonts[textInfo->curFont].ascent
- + textInfo->theFonts[textInfo->curFont].descent;
-
- textInfo->bottomSpace = textInfo->h - YPADDING -
- textInfo->theFonts[textInfo->curFont].ascent - INTERLINE -
- textInfo->theFonts[textInfo->curFont].descent;
- /* Actually clear the window */
- XClearWindow(display, w);
-
- /* Draw the current cursor */
- XFillRectangle(display, w, textInfo->CursorGC,
- XPADDING + CUROFFSET, textInfo->curY,
- CURSORWIDTH,
- textInfo->theFonts[textInfo->curFont].ascent +
- textInfo->theFonts[textInfo->curFont].descent);
-
- /* Update the scroll bar */
- UpdateScroll(display, textInfo);
- return 1;
-}
-
-
-static int WarpToBottom(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text Information */
-/*
- * This routine causes the specified text window to display its
- * last screen of information. It updates the scroll bar
- * to the appropriate spot. The implementation scans backward
- * through the buffer to find an appropriate starting spot for
- * the window.
- */
-{
- int index, height, lineHeight;
-
- index = textInfo->numLines-1;
- height = 0;
- while (index >= 0) {
- lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
- if (height + lineHeight > textInfo->h) break;
- height += lineHeight;
- index--;
- }
- textInfo->startLine = index + 1;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- textInfo->curY = textInfo->h - textInfo->bottomSpace -
- textInfo->txtBuffer[textInfo->endLine]->lineHeight;
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- return 1;
-}
-
-
-
-static int UpdateExposures(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * Before a new scrolling action occurs, the text window package
- * must handle all COPYEXPOSE events generated by the last scrolling
- * action. This routine is called to do this. Foreign events (those
- * not handled by TxtFilter) are queued up and replaced on the queue
- * after the processing of the exposure events is complete.
- */
-{
-#if 0
- XEvent foreignQueue[MAXFOREIGN];
- int index, lastItem = 0;
-
- while (textInfo->flagWord & COPYEXPOSE) {
- XNextEvent(display, &(foreignQueue[lastItem]));
- if (!TxtFilter(display, &(foreignQueue[lastItem])))
- lastItem++;
- if (lastItem >= MAXFOREIGN) {
- printf("Too many foreign events to queue!\n");
- textInfo->flagWord &= (~COPYEXPOSE);
- }
- }
- for (index = 0; index < lastItem; index++) {
- XPutBackEvent(display, &(foreignQueue[index]));
- }
-#endif
- return 1;
-}
-
-
-static int ScrollDown(display,textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine scrolls the indicated text window down by one
- * line. The line below the current line must exist. The window
- * is scrolled so that the line below the last line is fully
- * displayed. This may cause many lines to scroll off the top.
- * Scrolling is done using XCopyArea. The exposure events should
- * be caught using ExposeCopy.
- */
-{
- int lineSum, index, targetSpace, freeSpace, updateFlag;
-
- lineSum = 0;
- if (textInfo->endLine + 1 >= textInfo->numLines) return 0;
- targetSpace = textInfo->txtBuffer[textInfo->endLine+1]->lineHeight +
- INTERLINE;
- if (textInfo->bottomSpace < targetSpace) {
- index = textInfo->startLine;
- while (index < textInfo->endLine) {
- lineSum += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
- if (textInfo->bottomSpace + lineSum >= targetSpace) break;
- index++;
- }
-
- /* Must move upward by 'lineSum' pixels */
- XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
- DEFAULT_GC, 0, lineSum,
- textInfo->w - BARSIZE, textInfo->h,
- 0, 0);
-
- textInfo->flagWord |= COPYEXPOSE;
- /* Repair the damage to the structures */
- textInfo->startLine = index + 1;
- updateFlag = 1;
- } else {
- updateFlag = 0;
- }
- /* More lines might be able to fit. Let's check. */
- freeSpace = textInfo->bottomSpace + lineSum - targetSpace;
- index = textInfo->endLine + 1;
- while (index < textInfo->numLines-1) {
- if (freeSpace - textInfo->txtBuffer[index+1]->lineHeight - INTERLINE < 0)
- break;
- freeSpace -= (textInfo->txtBuffer[index+1]->lineHeight + INTERLINE);
- index++;
- }
- textInfo->endLine = index;
- textInfo->bottomSpace = freeSpace;
- if (updateFlag) {
- UpdateExposures(display, textInfo);
- }
- UpdateScroll(display, textInfo);
- return 1;
-}
-
-
-
-
-static int ExpandLines(textInfo)
-struct txtWin *textInfo; /* Text Information */
-/*
- * This routine allocates and initializes additional space in
- * the line start array (txtBuffer). The new space
- * is allocated using realloc. The expansion factor is a percentage
- * given by EXPANDPERCENT.
- */
-{
- int newSize, index;
-
- newSize = textInfo->allocLines;
- newSize += (newSize * EXPANDPERCENT) / 100;
-
- textInfo->txtBuffer = (struct txtLine **)
- realloc((char *) textInfo->txtBuffer,
- (unsigned) (newSize * sizeof(struct txtLine *)));
- for (index = textInfo->allocLines; index < newSize; index++) {
- textInfo->txtBuffer[index] = alloc(struct txtLine);
- InitLine(textInfo->txtBuffer[index]);
- }
- textInfo->allocLines = newSize;
- return 1;
-}
-
-static int ExpandBuffer(textInfo)
-struct txtWin *textInfo; /* Text information */
-/*
- * Expands the basic character buffer using realloc. The expansion
- * factor is a percentage given by EXPANDPERCENT.
- */
-{
- int newSize;
-
- newSize = textInfo->bufAlloc + (textInfo->bufAlloc * EXPANDPERCENT) / 100;
- textInfo->mainBuffer = (short *)
- realloc((char *) textInfo->mainBuffer, (unsigned) newSize * sizeof(short));
- textInfo->bufAlloc = newSize;
- return 1;
-}
-
-
-
-static int HandleNewLine(display, textInfo, flagWord)
-Display *display;
-struct txtWin *textInfo; /* Text Information */
-int flagWord; /* DODISP or NONEWLINE or both */
-/*
- * This routine initializes the next line for drawing by setting
- * its height to the current font height, scrolls the screen down
- * one line, and updates the current drawing position to the
- * left edge of the newly cleared line. If DODISP is specified,
- * the screen will be updated (otherwise not). If NONEWLINE is
- * specified, no newline character will be added to the text buffer
- * (this is for line wrap).
- */
-{
- struct txtLine *curLine, *nextLine;
-
- /* Check to see if a new line must be allocated */
- if (textInfo->curLine >= textInfo->allocLines-1)
- /* Expand the number of lines */
- ExpandLines(textInfo);
- textInfo->numLines += 1;
-
- /* Then we initialize the next line */
- nextLine = textInfo->txtBuffer[textInfo->numLines-1];
- nextLine->lineHeight =
- textInfo->theFonts[textInfo->curFont].ascent +
- textInfo->theFonts[textInfo->curFont].descent;
-
- curLine = textInfo->txtBuffer[textInfo->curLine];
- if (flagWord & DODISP) {
- /* Scroll down a line if required */
- if ((textInfo->curY + curLine->lineHeight +
- nextLine->lineHeight + (INTERLINE * 2)) > textInfo->h)
- {
- ScrollDown(display, textInfo);
- }
- else
- {
- /* Update the bottom space appropriately */
- textInfo->bottomSpace -= (nextLine->lineHeight + INTERLINE);
- textInfo->endLine += 1;
- }
- /* Update drawing position */
- textInfo->curY = textInfo->h -
- (textInfo->bottomSpace + nextLine->lineHeight);
- }
-
- /* Move down a line */
- textInfo->curLine += 1;
- if (!(flagWord & NONEWLINE)) {
- /* Append end-of-line to text buffer */
- if (textInfo->bufSpot >= textInfo->bufAlloc) {
- /* Allocate more space in main text buffer */
- ExpandBuffer(textInfo);
- }
- textInfo->mainBuffer[(textInfo->bufSpot)++] =
- (textInfo->curFont << FONTSHIFT) | '\n';
- }
- nextLine->lineText = textInfo->bufSpot;
- textInfo->curX = 0;
- return 1;
-}
-
-
-
-static int CharSize(textInfo, lineNum, charNum)
-struct txtWin *textInfo; /* Current Text Information */
-int lineNum; /* Line in buffer */
-int charNum; /* Character in line */
-/*
- * This routine determines the size of the specified character.
- * It takes in account the font of the character and whether its
- * fixed or variable. The size includes INTERSPACE spacing between
- * the characters.
- */
-{
- register XFontStruct *charFont;
- register short *theLine;
- register short theChar;
-
- theLine = &(textInfo->mainBuffer[textInfo->txtBuffer[lineNum]->lineText]);
- theChar = theLine[charNum] & CHARMASK;
- charFont = &(textInfo->theFonts[(theChar & FONTMASK) >> FONTSHIFT]);
- if (theChar <= charFont->min_char_or_byte2 ||
- theChar >= charFont->max_char_or_byte2 ||
- charFont->per_char == 0)
- return charFont->max_bounds.width + 1;
- else
- return charFont->per_char[theChar].width + 1;
-}
-
-
-
-
-
-static int HandleBackspace(display, textInfo, flagWord)
-Display *display;
-struct txtWin *textInfo; /* Text Information */
-int flagWord; /* DODISP or nothing */
-/*
- * This routine handles a backspace found in the input stream. The
- * character before the current writing position will be erased and
- * the drawing position will move back one character. If the writing
- * position is at the left margin, the drawing position will move
- * up to the previous line. If it is a line that has been wrapped,
- * the character at the end of the previous line will be erased.
- */
-{
- struct txtLine *thisLine, *prevLine;
- int chSize;
-
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- /* First, determine whether we need to go back a line */
- if (thisLine->lineLength == 0) {
- /* Bleep if at top of buffer */
- if (textInfo->curLine == 0) {
- XBell(display, 50);
- return 0;
- }
-
- /* See if we have to scroll in the other direction */
- if ((flagWord & DODISP) && (textInfo->curY <= YPADDING)) {
- /* This will display the last lines of the buffer */
- WarpToBottom(display, textInfo);
- }
-
- /* Set drawing position at end of previous line */
- textInfo->curLine -= 1;
- prevLine = textInfo->txtBuffer[textInfo->curLine];
- textInfo->numLines -= 1;
- if (flagWord & DODISP) {
- textInfo->curY -= (prevLine->lineHeight + INTERLINE);
- textInfo->bottomSpace += (thisLine->lineHeight + INTERLINE);
- textInfo->endLine -= 1;
- }
-
- /* We are unlinewrapping if the previous line has flag set */
- if (prevLine->lineFlags & WRAPFLAG) {
- /* Get rid of line wrap indicator */
- if (flagWord & DODISP) {
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- textInfo->w - BARSIZE - WRAPINDSIZE,
- textInfo->curY, WRAPINDSIZE,
- prevLine->lineHeight);
- }
- prevLine->lineFlags &= (~WRAPFLAG);
- /* Call recursively to wipe out the ending character */
- HandleBackspace(display, textInfo, flagWord);
- } else {
- /* Delete the end-of-line in the primary buffer */
- textInfo->bufSpot -= 1;
- }
- } else {
- /* Normal deletion of character */
- chSize =
- CharSize(textInfo, textInfo->curLine,
- textInfo->txtBuffer[textInfo->curLine]->lineLength - 1);
- /* Move back appropriate amount and wipe it out */
- thisLine->lineWidth -= chSize;
- if (flagWord & DODISP) {
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- thisLine->lineWidth, textInfo->curY,
- chSize, thisLine->lineHeight);
- }
- /* Delete from buffer */
- textInfo->txtBuffer[textInfo->curLine]->lineLength -= 1;
- textInfo->bufSpot -= 1;
- }
- return 1;
-}
-
-
-
-static int DrawLineWrap(display, win, x, y, h, col)
-Display *display;
-Window win; /* What window to draw it in */
-int x, y; /* Position of upper left corner */
-int h; /* Height of indicator */
-int col; /* Color of indicator */
-/*
- * This routine draws a line wrap indicator at the end of a line.
- * Visually, it is an arrow of the specified height directly against
- * the scroll bar border. The bitmap used for the arrow is stored
- * in 'arrowMap' with size 'arrow_width' and 'arrow_height'.
- */
-{
- struct txtWin *textInfo;
-
- textInfo = (struct txtWin *)XLookUpAssoc(display, textWindows,
- (XID) win);
-
- /* First, draw the arrow */
- XCopyArea(display, textInfo->arrowMap, textInfo->mainWindow,
- textInfo->CursorGC,
- 0, 0, arrow_width, arrow_height,
- x, y + h - arrow_height, 1);
-
- /* Then draw the stem */
- XDrawLine(display, textInfo->mainWindow, textInfo->CursorGC,
- x + STEMOFFSET, y,
- x + STEMOFFSET, y + h - arrow_height);
- return 1;
-}
-
-
-
-
-static int DrawLine(display, textInfo, lineIndex, ypos)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int lineIndex; /* Index of line to draw */
-int ypos; /* Y position for line */
-/*
- * This routine destructively draws the indicated line in the
- * indicated window at the indicated position. It does not
- * clear to end of line however. It draws a line wrap indicator
- * if needed but does not draw a cursor.
- */
-{
- int index, startPos, curFont, theColor, curX, saveX, fontIndex;
- struct txtLine *someLine;
- char lineBuffer[BUFSIZE], *glyph;
- short *linePointer;
- XFontStruct *theFont;
- XGCValues gc;
-
- /* First, we draw the text */
- index = 0;
- curX = XPADDING;
- someLine = textInfo->txtBuffer[lineIndex];
- linePointer = &(textInfo->mainBuffer[someLine->lineText]);
- while (index < someLine->lineLength) {
- startPos = index;
- saveX = curX;
- curFont = linePointer[index] & FONTMASK;
- fontIndex = curFont >> FONTSHIFT;
- theFont = &(textInfo->theFonts[fontIndex]);
- theColor = textInfo->theColors[fontIndex];
- glyph = &(lineBuffer[0]);
- while ((index < someLine->lineLength) &&
- ((linePointer[index] & FONTMASK) == curFont))
- {
- *glyph = linePointer[index] & CHARMASK;
- index++;
- curX += CharSize(textInfo, lineIndex, index);
- glyph++;
- }
-
- /* Flush out the glyphs */
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- saveX, ypos,
- textInfo->w - BARSIZE,
- someLine->lineHeight + YPADDING + INTERLINE);
-
- XDrawString(display, textInfo->mainWindow,
- textInfo->fontGC[fontIndex],
- saveX, ypos,
- lineBuffer, someLine->lineLength);
- }
- /* Then the line wrap indicator (if needed) */
- if (someLine->lineFlags & WRAPFLAG) {
- DrawLineWrap(display, textInfo->mainWindow,
- textInfo->w - BARSIZE - WRAPINDSIZE,
- ypos, someLine->lineHeight,
- textInfo->fgPix);
- }
- return 1;
-}
-
-
-
-
-static int HandleNewFont(display, fontNum, textInfo, flagWord)
-Display *display;
-int fontNum; /* Font number */
-struct txtWin *textInfo; /* Text information */
-int flagWord; /* DODISP or nothing */
-/*
- * This routine handles a new font request. These requests take
- * the form "^F<digit>". The parsing is done in TxtWriteStr.
- * This routine is called only if the form is valid. It may return
- * a failure (0 status) if the requested font is not loaded.
- * If the new font is larger than any of the current
- * fonts on the line, it will change the line height and redisplay
- * the line.
- */
-{
- struct txtLine *thisLine;
- int heightDiff, baseDiff, redrawFlag;
-
- if (textInfo->theFonts[fontNum].fid == 0) {
- return 0;
- } else {
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- textInfo->curFont = fontNum;
- redrawFlag = 0;
- heightDiff = textInfo->theFonts[fontNum].ascent +
- textInfo->theFonts[fontNum].descent -
- thisLine->lineHeight;
-
- if (heightDiff > 0) {
- redrawFlag = 1;
- } else {
- heightDiff = 0;
- }
-
- if (redrawFlag) {
- if (flagWord & DODISP) {
- /* Clear current line */
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- 0, textInfo->curY, textInfo->w,
- thisLine->lineHeight);
-
- /* Check to see if it requires scrolling */
- if ((textInfo->curY + thisLine->lineHeight + heightDiff +
- INTERLINE) > textInfo->h)
- {
- /*
- * General approach: "unscroll" the last line up
- * and then call ScrollDown to do the right thing.
- */
- textInfo->endLine -= 1;
- textInfo->bottomSpace += thisLine->lineHeight +
- INTERLINE;
-
- XFillRectangle(display, textInfo->mainWindow,
- textInfo->bgGC,
- 0, textInfo->h - textInfo->bottomSpace,
- textInfo->w, textInfo->bottomSpace);
-
- thisLine->lineHeight += heightDiff;
- ScrollDown(display, textInfo);
- textInfo->curY = textInfo->h -
- (textInfo->bottomSpace + INTERLINE +
- thisLine->lineHeight);
- }
- else
- {
- /* Just update bottom space */
- textInfo->bottomSpace -= heightDiff;
- thisLine->lineHeight += heightDiff;
- }
- /* Redraw the current line */
- DrawLine(display, textInfo, textInfo->curLine, textInfo->curY);
- } else {
- /* Just update line height */
- thisLine->lineHeight += heightDiff;
- }
- }
- return 1;
- }
-}
-
-
-
-int TxtWriteStr(display, w, str)
-Display *display;
-Window w; /* Text window */
-register char *str; /* 0 terminated string */
-/*
- * This routine writes a string to the specified text window.
- * The following notes apply:
- * - Text is always appended to the end of the text buffer.
- * - If the scroll bar is positioned such that the end of the
- * text is not visible, an automatic scroll to the bottom
- * will be done before the appending of text.
- * - Non-printable ASCII characters are not displayed.
- * - The '\n' character causes the current text position to
- * advance one line and start at the left.
- * - Tabs are not supported.
- * - Lines too long for the screen will be wrapped and a line wrap
- * indication will be drawn.
- * - Backspace clears the previous character. It will do the right
- * thing if asked to backspace past a wrapped line.
- * - A new font can be chosen using the sequence '^F<digit>' where
- * <digit> is 0-7. The directive will be ignored if
- * there is no font in the specified slot.
- * Returns 0 if something went wrong.
- */
-{
- register int fontIndex;
- register struct txtWin *textInfo;
- register struct txtLine *thisLine;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
- return 0;
-
- /* See if screen needs to be updated */
- if (textInfo->flagWord & SCREENWRONG) {
- TxtRepaint(display, textInfo->mainWindow);
- }
-
- /* See if we have to scroll down to the bottom */
- if (textInfo->flagWord & NOTATBOTTOM) {
- WarpToBottom(display, textInfo);
- textInfo->flagWord &= (~NOTATBOTTOM);
- }
-
- /* Undraw the current cursor */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
-
- XFillRectangle(display, w, textInfo->bgGC,
- thisLine->lineWidth + CUROFFSET,
- textInfo->curY,
- CURSORWIDTH,
- thisLine->lineHeight);
-
- for ( /* str is ok */ ; (*str != 0) ; str++) {
- /* Check to see if we are waiting on a font */
- if (textInfo->flagWord & FONTNUMWAIT) {
- textInfo->flagWord &= (~FONTNUMWAIT);
- fontIndex = *str - '0';
- if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
- /* Handle font -- go get next character */
- if (HandleNewFont(display, fontIndex, textInfo, DODISP))
- continue;
- }
- }
-
- /* Inline code for handling normal character case */
- if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
- register XFontStruct *thisFont;
- register struct txtLine *thisLine;
- register int charWidth;
- int thisColor;
-
- /* Determine size of character */
- thisFont = &(textInfo->theFonts[textInfo->curFont]);
- thisColor = textInfo->theColors[textInfo->curFont];
- if (*str <= thisFont->min_char_or_byte2 ||
- *str >= thisFont->max_char_or_byte2 ||
- thisFont->per_char == 0)
- charWidth = thisFont->max_bounds.width + 1;
- else
- charWidth = thisFont->per_char[*str].width + 1;
-
- /* Check to see if line wrap is required */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- if (thisLine->lineWidth + charWidth >
- (textInfo->w-BARSIZE-WRAPINDSIZE))
- {
- DrawLineWrap(display, textInfo->mainWindow,
- textInfo->w-BARSIZE-WRAPINDSIZE,
- textInfo->curY, thisLine->lineHeight,
- textInfo->fgPix);
- thisLine->lineFlags |= WRAPFLAG;
- /* Handle the spacing problem the same way as a newline */
- HandleNewLine(display, textInfo, DODISP | NONEWLINE);
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- }
-
- /* Ready to draw character */
- XDrawString(display, textInfo->mainWindow,
- DEFAULT_GC,
- textInfo->curX += charWidth,
- textInfo->curY + thisLine->lineHeight,
- str, 1);
-
- /* Append character onto main buffer */
- if (textInfo->bufSpot >= textInfo->bufAlloc)
- /* Make room for more characters */
- ExpandBuffer(textInfo);
- textInfo->mainBuffer[(textInfo->bufSpot)++] =
- (textInfo->curFont << FONTSHIFT) | (*str);
-
- /* Update the line start array */
- thisLine->lineLength += 1;
- thisLine->lineWidth += charWidth;
- } else if (*str == NEWLINE) {
- HandleNewLine(display, textInfo, DODISP);
- } else if (*str == NEWFONT) {
- /* Go into waiting for font number mode */
- textInfo->flagWord |= FONTNUMWAIT;
- } else if (*str == BACKSPACE) {
- HandleBackspace(display, textInfo, DODISP);
- } else {
- /* Ignore all others */
- }
- }
- /* Draw the cursor in its new position */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
-
- XFillRectangle(display, w, textInfo->CursorGC,
- thisLine->lineWidth + CUROFFSET,
- textInfo->curY /* + thisLine->lineHeight */,
- CURSORWIDTH, thisLine->lineHeight);
-
- return 1;
-}
-
-
-
-int TxtJamStr(display, w, str)
-Display *display;
-Window w; /* Text window */
-register char *str; /* NULL terminated string */
-/*
- * This is the same as TxtWriteStr except the screen is NOT updated.
- * After a call to this routine, TxtRepaint should be called to
- * update the screen. This routine is meant to be used to load
- * a text buffer with information and then allow the user to
- * scroll through it at will.
- */
-{
- register int fontIndex;
- register struct txtWin *textInfo;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
- ) == 0)
- return 0;
-
- for ( /* str is ok */ ; (*str != 0) ; str++) {
- /* Check to see if we are waiting on a font */
- if (textInfo->flagWord & FONTNUMWAIT) {
- textInfo->flagWord &= (~FONTNUMWAIT);
- fontIndex = *str - '0';
- if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
- if (HandleNewFont(display, fontIndex, textInfo, 0)) {
- /* Handled font -- go get next character */
- continue;
- }
- }
- }
- /* Inline code for handling normal character case */
- if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
- register XFontStruct *thisFont;
- register struct txtLine *thisLine;
- register int charWidth;
-
- /* Determine size of character */
- thisFont = &(textInfo->theFonts[textInfo->curFont]);
-
- if (*str <= thisFont->min_char_or_byte2 ||
- *str >= thisFont->max_char_or_byte2 ||
- thisFont->per_char == 0)
- charWidth = thisFont->max_bounds.width + 1;
- else
- charWidth = thisFont->per_char[*str].width + 1;
-
- /* Check to see if line wrap is required */
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- if (thisLine->lineWidth + charWidth >
- (textInfo->w-BARSIZE-WRAPINDSIZE))
- {
- thisLine->lineFlags |= WRAPFLAG;
- /* Handle the spacing problem the same way as a newline */
- HandleNewLine(display, textInfo, NONEWLINE);
- thisLine = textInfo->txtBuffer[textInfo->curLine];
- }
- /* Append character onto main buffer */
- if (textInfo->bufSpot >= textInfo->bufAlloc)
- /* Make room for more characters */
- ExpandBuffer(textInfo);
- textInfo->mainBuffer[(textInfo->bufSpot)++] =
- (textInfo->curFont << FONTSHIFT) | (*str);
-
- /* Update the line start array */
- thisLine->lineLength += 1;
- thisLine->lineWidth += charWidth;
- } else if (*str == NEWLINE) {
- HandleNewLine(display, textInfo, 0);
- } else if (*str == NEWFONT) {
- /* Go into waiting for font number mode */
- textInfo->flagWord |= FONTNUMWAIT;
- } else if (*str == BACKSPACE) {
- HandleBackspace(display, textInfo, 0);
- } else {
- /* Ignore all others */
- }
- }
- textInfo->flagWord |= SCREENWRONG;
- return 1;
-}
-
-
-
-int TxtRepaint(display,w)
-Display *display;
-Window w;
-/*
- * Repaints the given scrollable text window. The routine repaints
- * the entire window. For handling exposure events, the TxtFilter
- * routine should be used.
- */
-{
- struct txtWin *textInfo;
- int index, ypos;
-
- if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
- ) == 0)
- return 0;
-
- /* Check to see if the screen is up to date */
- if (textInfo->flagWord & SCREENWRONG) {
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- textInfo->flagWord &= (~SCREENWRONG);
- }
-
- ypos = YPADDING;
- index = textInfo->startLine;
- for (;;) {
- DrawLine(display, textInfo, index, ypos);
- if (index >= textInfo->endLine) break;
- ypos += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
- index++;
- }
- /* Draw the cursor (if on screen) */
- if (textInfo->endLine == textInfo->curLine) {
- XFillRectangle(display, w, textInfo->CursorGC,
- textInfo->txtBuffer[index]->lineWidth + CUROFFSET,
- ypos /* + textInfo->txtBuffer[index]->lineHeight */,
- CURSORWIDTH, textInfo->txtBuffer[index]->lineHeight);
-
- }
- /* Update the scroll bar */
- UpdateScroll(display, textInfo);
- return 1;
-}
-
-
-
-static int InsertIndex(textInfo, thisIndex, ypos)
-struct txtWin *textInfo; /* Text Window Information */
-int thisIndex; /* Line index of exposed line */
-int ypos; /* Drawing position of line */
-/*
- * This routine inserts the supplied line index into the copy
- * exposure array for 'textInfo'. The array is kept sorted
- * from lowest to highest using insertion sort. The array
- * is dynamically expanded if needed.
- */
-{
- struct expEvent *newItem;
- int newSize, index, downIndex;
-
- /* Check to see if we need to expand it */
- if ((textInfo->exposeSize + 3) >= textInfo->exposeAlloc) {
- newSize = textInfo->exposeAlloc +
- (textInfo->exposeAlloc * EXPANDPERCENT / 100);
- textInfo->exposeAry = (struct expEvent **)
- realloc((char *) textInfo->exposeAry,
- (unsigned) (newSize * sizeof(struct expEvent *)));
- for (index = textInfo->exposeAlloc; index < newSize; index++)
- textInfo->exposeAry[index] = alloc(struct expEvent);
- textInfo->exposeAlloc = newSize;
- }
- /* Find spot for insertion. NOTE: last spot has big number */
- for (index = 0; index <= textInfo->exposeSize; index++) {
- if (textInfo->exposeAry[index]->lineIndex >= thisIndex) {
- if (textInfo->exposeAry[index]->lineIndex > thisIndex) {
- /* Insert before this entry */
- newItem = textInfo->exposeAry[textInfo->exposeSize+1];
- for (downIndex = textInfo->exposeSize;
- downIndex >= index;
- downIndex--)
- {
- textInfo->exposeAry[downIndex+1] =
- textInfo->exposeAry[downIndex];
- }
- /* Put a free structure at this spot */
- textInfo->exposeAry[index] = newItem;
- /* Fill it in */
- textInfo->exposeAry[index]->lineIndex = thisIndex;
- textInfo->exposeAry[index]->ypos = ypos;
- /* Break out of loop */
- textInfo->exposeSize += 1;
- }
- break;
- }
- }
- return 1;
-}
-
-
-
-static int ScrollUp(display, textInfo)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-/*
- * This routine scrolls the indicated text window up by one
- * line. The line above the current line must exist. The
- * window is scrolled so that the line above the start line
- * is displayed at the top of the screen. This may cause
- * many lines to scroll off the bottom. The scrolling is
- * done using XCopyArea. The exposure events should be caught
- * by ExposeCopy.
- */
-{
- int targetSpace;
-
- /* Make sure all exposures have been handled by now */
- if (textInfo->startLine == 0) return 0;
- targetSpace = textInfo->txtBuffer[textInfo->startLine-1]->lineHeight +
- INTERLINE;
- /* Move the area downward by the target amount */
- XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
- DEFAULT_GC,
- 0, YPADDING, textInfo->w - BARSIZE,
- textInfo->h, 0, targetSpace);
-
- textInfo->flagWord |= COPYEXPOSE;
- /* Update the text window parameters */
- textInfo->startLine -= 1;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
-
- /* Clear out bottom space region */
- XClearArea(display, textInfo->mainWindow,
- 0, textInfo->h - textInfo->bottomSpace,
- textInfo->w, textInfo->bottomSpace);
-
- UpdateExposures(display, textInfo);
- UpdateScroll(display, textInfo);
-
- return 1;
-}
-
-
-static int ScrollToSpot(display, textInfo, ySpot)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int ySpot; /* Button position in scroll window */
-/*
- * This routine scrolls the specified text window relative to the
- * position of the mouse in the scroll bar. The center of the screen
- * will be positioned to correspond to the mouse position.
- */
-{
- int targetLine, aboveLines;
-
- targetLine = textInfo->numLines * ySpot / textInfo->h;
- textInfo->startLine = targetLine;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- aboveLines = 0;
- /* Make the target line the *center* of the window */
- while ((textInfo->startLine > 0) &&
- (aboveLines < textInfo->endLine - targetLine))
- {
- textInfo->startLine -= 1;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- aboveLines++;
- }
- if (textInfo->endLine == textInfo->numLines-1) {
- WarpToBottom(display, textInfo);
- } else {
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- }
- return 1;
-}
-
-
-
-static int LineToTop(display, textInfo, pos)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int pos; /* Y position of mouse */
-/*
- * This routine scrolls the screen down until the line at the
- * mouse position is at the top of the screen. It stops
- * if it can't scroll the buffer down that far. If the
- * global 'ScrollOption' is NORMSCROLL, a smooth scroll
- * is used. Otherwise, it jumps to the right position
- * and repaints the screen.
- */
-{
- int index, sum;
-
- /* First, we find the current line */
- sum = 0;
- for (index = textInfo->startLine; index <= textInfo->endLine; index++) {
- if (sum + textInfo->txtBuffer[index]->lineHeight + INTERLINE> pos) break;
- sum += textInfo->txtBuffer[index]->lineHeight + INTERLINE;
- }
- /* We always want to scroll down at least one line */
- if (index == textInfo->startLine) index++;
- if (ScrollOption == NORMSCROLL) {
- /* Scroll down until 'index' is the starting line */
- while ((textInfo->startLine < index) && ScrollDown(display, textInfo))
- {
- /* Empty Loop Body */
- }
- } else {
- /* Immediately jump to correct spot */
- textInfo->startLine = index;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- if (textInfo->endLine == textInfo->numLines-1) {
- WarpToBottom(display, textInfo);
- } else {
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- }
- }
- /* Check to see if at end of buffer */
- if (textInfo->endLine >= textInfo->numLines-1) {
- textInfo->flagWord &= (~NOTATBOTTOM);
- }
- return 1;
-}
-
-
-
-static int TopToHere(display, textInfo, pos)
-Display *display;
-struct txtWin *textInfo; /* Text window information */
-int pos; /* Y position of mouse */
-/*
- * This routine scrolls the screen up until the top line of
- * the screen is at the current Y position of the mouse. Again,
- * it will stop if it can't scroll that far. If the global
- * 'ScrollOption' is NORMSCROLL, a smooth scroll is used.
- * If it's not, it will simply redraw the screen at the
- * correct spot.
- */
-{
- int sum, target, linesup, index;
-
- target = pos - textInfo->txtBuffer[textInfo->startLine]->lineHeight;
- /* We always want to scroll up at least one line */
- if (target <= 0) target = 1;
- sum = 0;
- linesup = 0;
- /* Check to see if we are at the top anyway */
- if (textInfo->startLine == 0) return 0;
- if (ScrollOption == NORMSCROLL) {
- /* Scroll up until sum of new top lines greater than target */
- while ((sum < target) && ScrollUp(display, textInfo)) {
- sum += textInfo->txtBuffer[textInfo->startLine]->lineHeight;
- linesup++;
- }
- } else {
- /* Search backward to find index */
- index = textInfo->startLine - 1;
- while ((index > 0) && (sum < target)) {
- sum += textInfo->txtBuffer[index]->lineHeight;
- linesup++;
- index--;
- }
- /* Go directly to the index */
- textInfo->startLine = index;
- textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
- XClearWindow(display, textInfo->mainWindow);
- TxtRepaint(display, textInfo->mainWindow);
- }
- /* If we scrolled, assert we are not at bottom of buffer */
- if (linesup > 0) {
- textInfo->flagWord |= NOTATBOTTOM;
- }
- return 1;
-}
-
-
-
-int TxtFilter(display, evt)
-Display *display;
-XEvent *evt;
-/*
- * This routine handles events associated with scrollable text windows.
- * It will handle all exposure events and any button released events
- * in the scroll bar of a text window. It does NOT handle any other
- * events. If it cannot handle the event, it will return 0.
- */
-{
- XExposeEvent *expose = &evt->xexpose;
- XButtonEvent *btEvt = &evt->xbutton;
- XGraphicsExposeEvent *gexpose = &evt->xgraphicsexpose;
- XNoExposeEvent *noexpose = &evt->xnoexpose;
- struct txtWin *textInfo;
- int index, ypos;
- Window w, sw;
-
- if (textWindows == (XAssocTable *) 0) {
- textWindows = XCreateAssocTable(32);
- if (textWindows == (XAssocTable *) 0) return(0);
- }
- if (evt->type == Expose) {
- w = expose->window;
- sw = 0;
- }
- else if (evt->type == GraphicsExpose) {
- w = gexpose->drawable;
- sw = 0;
- }
- else if (evt->type == NoExpose) {
- w = noexpose->drawable;
- sw = 0;
- }
- else if (evt->type == ButtonRelease) {
- w = btEvt->window;
- sw = btEvt->subwindow;
- }
- else
- return 0;
-
- if ((textInfo = (struct txtWin *)
- XLookUpAssoc(display, textWindows, (XID) w)) == 0)
- return 0;
-
- /* Determine whether it's main window or not */
- if ((w == textInfo->mainWindow) && (sw == 0)) {
- /* Main Window - handle exposures */
- switch (evt->type) {
- case Expose:
- ypos = 0 /*YPADDING*/;
- for (index = textInfo->startLine;
- index <= textInfo->endLine;
- index++)
- {
- int lh = textInfo->txtBuffer[index]->lineHeight;
-
- if (((ypos + lh) >= expose->y) &&
- (ypos <= (expose->y + expose->height)))
- {
- /* Intersection region */
- /* Draw line immediately */
- DrawLine(display, textInfo, index, ypos);
- /* And possibly draw cursor */
- if (textInfo->curLine == index) {
- XFillRectangle(display, w, textInfo->CursorGC,
- textInfo->txtBuffer[index]->lineWidth +
- CUROFFSET,
- ypos,
- CURSORWIDTH,
- lh);
- }
- }
- ypos += lh + INTERLINE;
- }
- break;
- case GraphicsExpose:
- ypos = 0 /*YPADDING*/;
- for (index = textInfo->startLine;
- index <= textInfo->endLine;
- index++)
- {
- int lh = textInfo->txtBuffer[index]->lineHeight;
-
- if (((ypos + lh) >= gexpose->y) &&
- (ypos <= (gexpose->y + gexpose->height)))
- {
- /* Intersection region */
- /* Draw line immediately */
- DrawLine(display, textInfo, index, ypos);
- /* And possibly draw cursor */
- if (textInfo->curLine == index) {
- XFillRectangle(display, w, textInfo->CursorGC,
- textInfo->txtBuffer[index]->lineWidth +
- CUROFFSET,
- ypos,
- CURSORWIDTH,
- lh);
- }
- }
- ypos += lh + INTERLINE;
- }
- break;
- case NoExpose:
- break;
- default:
- /* Not one of our events */
- return 0;
- }
- } else {
- switch (evt->type) {
- case Expose:
- UpdateScroll(display, textInfo);
- break;
- case ButtonRelease:
- /* Find out which button */
- switch (btEvt->button) {
- case Button1:
- /* Scroll up until top line is at mouse position */
- TopToHere(display, textInfo, btEvt->y);
- break;
- case Button2:
- /* Scroll to spot relative to position */
- ScrollToSpot(display, textInfo, btEvt->y);
- if (textInfo->endLine >= textInfo->numLines-1) {
- textInfo->flagWord &= (~NOTATBOTTOM);
- } else {
- textInfo->flagWord |= NOTATBOTTOM;
- }
- break;
- case Button3:
- /* Scroll down until pointed line is at top */
- LineToTop(display, textInfo, btEvt->y);
- break;
- }
- break;
- default:
- /* Not one of our events */
- return 0;
- }
- }
- return 1;
-}
diff --git a/gnu/games/chess/Xchess/scrollText/scrollText.h b/gnu/games/chess/Xchess/scrollText/scrollText.h
deleted file mode 100644
index d9d05b0..0000000
--- a/gnu/games/chess/Xchess/scrollText/scrollText.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Scrollable Text Window Header File
- *
- * David Harrison
- * University of California, Berkeley
- * 1986
- *
- * This file contains definitions for a scrollable text window
- * with scroll bar support.
- */
-
-int TxtGrab();
- /* Take hold of a previously created window */
-
-#define TXT_NO_COLOR -1
-
-int TxtAddFont();
- /* Loads a new font for use later */
-int TxtWinP();
- /* Returns non-zero value if the window is text window */
-int TxtClear();
- /* Clears text window and resets text buffer */
-
-int TxtWriteStr();
- /* Writes a string to window with immediate update */
-int TxtJamStr();
- /* Write a string without causing update to screen */
-
-int TxtRepaint();
- /* Repaints entire scrollable text window */
-int TxtFilter();
- /* Handles events related to text window */
diff --git a/gnu/games/chess/Xchess/shade.bitmap b/gnu/games/chess/Xchess/shade.bitmap
deleted file mode 100644
index a32ac80..0000000
--- a/gnu/games/chess/Xchess/shade.bitmap
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#define shade_width 80
-#define shade_height 80
-static char shade_bits[] = {
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
- 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88};
diff --git a/gnu/games/chess/Xchess/std.c b/gnu/games/chess/Xchess/std.c
deleted file mode 100644
index c839b91..0000000
--- a/gnu/games/chess/Xchess/std.c
+++ /dev/null
@@ -1,425 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.1 $ on $Date: 86/11/01 17:08:40 $
- * $Source: /users/faustus/xchess/RCS/std.c,v $
- * Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
- *
- * Utility routines.
- */
-
-#include "std.h"
-
-#ifndef IBMPC
-#include <sys/types.h>
-#endif not IBMPC
-#ifdef UNIX
-#include <signal.h>
-#include <pwd.h>
-#endif UNIX
-#ifdef BSD
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif BSD
-
-extern char **environ;
-
-bool
-prefix(p, s)
- register char *p, *s;
-{
- while (*p && (*p == *s))
- p++, s++;
- if (!*p)
- return (true);
- else
- return (false);
-}
-
-/* Create a copy of a string. */
-
-char *
-copy(str)
- char *str;
-{
- char *p, *tmalloc();
-
- p = tmalloc(strlen(str) + 1);
- strcpy(p, str);
- return(p);
-}
-
-/* Determine whether sub is a substring of str. */
-
-bool
-substring(sub, str)
- register char *str, *sub;
-{
- register char *s;
-
- while(*str) {
- if(*str == *sub) {
- for(s = sub; *s; s++)
- if(*s != *str++)
- break;
- if(*s == '\0')
- return (true);
- }
- str++;
- }
- return (false);
-}
-
-/* Malloc num bytes and initialize to zero. Fatal error if the space can't
- * be malloc'd.
- */
-
-char *
-tmalloc(num)
- register int num;
-{
- register char *s;
- char *malloc();
-
- s = malloc((unsigned) num);
- if (!s) {
- fatal("malloc: can't allocate %d bytes", num);
- }
- bzero(s, num);
- return(s);
-}
-
-char *
-trealloc(ptr, num)
- char *ptr;
- int num;
-{
- register char *s;
- char *realloc();
-
- s = realloc(ptr, (unsigned) num);
- if (!s) {
- fatal("realloc: can't allocate %d bytes", num);
- }
- /* Well, this won't be zeroed... Too bad... */
- return(s);
-}
-
-/* Append one character to a string. Don't check for overflow. */
-
-void
-appendc(s, c)
- char *s, c;
-{
- while (*s)
- s++;
- *s++ = c;
- *s = '\0';
- return;
-}
-
-int
-scannum(str)
- char *str;
-{
- int i = 0;
-
- while(isdigit(*str))
- i = i * 10 + *(str++) - '0';
- return(i);
-}
-
-/* Case insensitive prefix. */
-
-bool
-ciprefix(p, s)
- register char *p, *s;
-{
- while (*p) {
- if ((isupper(*p) ? tolower(*p) : *p) !=
- (isupper(*s) ? tolower(*s) : *s))
- return(false);
- p++;
- s++;
- }
- return (true);
-}
-
-/* Case insensitive strcmp... */
-
-bool
-cieq(p, s)
- register char *p, *s;
-{
- while (*p) {
- if ((isupper(*p) ? tolower(*p) : *p) !=
- (isupper(*s) ? tolower(*s) : *s))
- return(false);
- p++;
- s++;
- }
- return (!*s);
-}
-
-#ifdef BSD
-
-/* Return the date. Return value is static data. */
-
-char *
-datestring()
-{
- register char *tzn;
- struct tm *tp;
- static char tbuf[40];
- char *ap;
- struct timeval tv;
- struct timezone tz;
- char *timezone(), *asctime();
- int i;
- struct tm *localtime();
-
- (void) gettimeofday(&tv, &tz);
- tp = localtime((time_t *) &tv.tv_sec);
- ap = asctime(tp);
- tzn = timezone(tz.tz_minuteswest, tp->tm_isdst);
- sprintf(tbuf, "%.20s", ap);
- if (tzn)
- strcat(tbuf, tzn);
- strcat(tbuf, ap + 19);
- i = strlen(tbuf);
- tbuf[i - 1] = '\0';
- return (tbuf);
-}
-
-#else BSD
-
-/* Give it a try... */
-
-char *
-datestring()
-{
- long i;
- static char buf[64];
-
- i = time(0);
- strcpy(buf, ctime(&i));
- buf[strlen(buf) - 1] = '\0'; /* Kill the nl. */
- return (buf);
-}
-
-#endif
-
-/* How many seconds have elapsed in running time. */
-
-int
-seconds()
-{
-#ifdef BSD
- struct rusage ruse;
-
- getrusage(RUSAGE_SELF, &ruse);
- return (ruse.ru_utime.tv_sec);
-#else BSD
-#endif BSD
-}
-
-/* A few things that may not exist on non-unix systems. */
-
-#ifndef BSD
-
-#ifndef index
-
-char *
-index(s, c)
- register char *s;
- register char c;
-{
- while ((*s != c) && (*s != '\0'))
- s++;
- if (*s == '\0')
- return ((char *) 0);
- else
- return (s);
-}
-
-#endif not index
-
-#ifndef rindex
-
-char *
-rindex(s, c)
- register char *s;
- register char c;
-{
- register char *t;
-
- for (t = s; *t != '\0'; t++);
- while ((*t != c) && (t != s))
- t--;
- if (t == s)
- return ((char *) 0);
- else
- return (t);
-}
-
-#endif not rindex
-
-#ifndef bcopy
-
-void
-bcopy(from, to, num)
- register char *from, *to;
- register int num;
-{
- while (num-- > 0)
- *to++ = *from++;
- return;
-}
-
-#endif not bcopy
-
-#ifndef bzero
-
-void
-bzero(ptr, num)
- register char *ptr;
- register int num;
-{
- while (num-- > 0)
- *ptr++ = '\0';
- return;
-}
-
-#endif not bzero
-
-/* This might not be around... If not then forget about sorting... */
-
-void qsort() {}
-
-#endif BSD
-
-char *
-gettok(s)
- char **s;
-{
- char buf[BSIZE];
- int i = 0;
-
- while (isspace(**s))
- (*s)++;
- if (!**s)
- return (NULL);
- while (**s && !isspace(**s))
- buf[i++] = *(*s)++;
- buf[i] = '\0';
- while (isspace(**s))
- (*s)++;
- return (copy(buf));
-}
-
-/* Die horribly. */
-
-/* VARARGS1 */
-void
-fatal(s, args)
- char *s;
-{
- fputs("Internal Error: ", stderr);
- _doprnt(s, &args, stderr);
- putc('\n', stderr);
-
- kill(getpid(), SIGIOT);
- /* NOTREACHED */
-}
-
-void
-setenv(name, value)
- char *name, *value;
-{
- int i;
- char **xx, *s;
-
- s = tmalloc(strlen(name) + 2);
- sprintf(s, "%s=", name);
-
- /* Copy the old environment... */
- for (i = 0; environ[i]; i++)
- if (prefix(s, environ[i]))
- break;
- if (!environ[i]) {
- xx = (char **) tmalloc((i + 2) * sizeof (char *));
- for (i = 0; environ[i]; i++)
- xx[i] = environ[i];
- xx[i + 1] = NULL;
- environ = xx;
- } else
- xx = environ;
-
- xx[i] = tmalloc(strlen(name) + strlen(value) + 2);
- sprintf(xx[i], "%s=%s", name, value);
- return;
-}
-
-char *
-getusername()
-{
- int i = getuid();
- struct passwd *pw = getpwuid(i);
-
- return (pw ? pw->pw_name : NULL);
-}
-
-char *
-gethome()
-{
- int i = getuid();
- struct passwd *pw = getpwuid(i);
-
- return (pw ? pw->pw_dir : "/strange");
-}
-
-char *
-tildexpand(s)
- char *s;
-{
- struct passwd *pw;
- char *n, buf[64];
- int i;
-
- if (*s != '~')
- return (copy(s));
-
- for (s++, i = 0; *s != '/'; s++, i++)
- buf[i] = *s;
- buf[i] = '\0';
- if (!i)
- pw = getpwuid(getuid());
- else
- pw = getpwnam(buf);
- if (!pw)
- return (s);
- n = tmalloc(strlen(s) + strlen(pw->pw_dir) + 1);
- strcpy(n, pw->pw_dir);
- strcat(n, s);
- return (n);
-}
-
diff --git a/gnu/games/chess/Xchess/std.h b/gnu/games/chess/Xchess/std.h
deleted file mode 100644
index fc8fa64..0000000
--- a/gnu/games/chess/Xchess/std.h
+++ /dev/null
@@ -1,105 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:18:32 $
- * $Source: /users/faustus/xchess/RCS/std.h,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- *
- * Standard definitions.
- */
-
-#define UNIX
-#define BSD
-
-#ifndef FILE
-#include <stdio.h>
-#endif
-#ifndef isalpha
-#include <ctype.h>
-#endif
-#ifndef HUGE
-#include <math.h>
-#endif
-#include <strings.h>
-
-typedef int bool;
-
-#define false 0
-#define true 1
-
-/* Externs defined in std.c */
-
-extern char *tmalloc();
-extern char *trealloc();
-extern char *copy();
-extern char *datestring();
-extern char *getusername();
-extern char *gethome();
-extern char *gettok();
-extern char *tildexpand();
-extern void fatal();
-extern void setenv();
-extern void appendc();
-extern int scannum();
-extern int seconds();
-extern bool prefix();
-extern bool ciprefix();
-extern bool cieq();
-extern bool substring();
-
-/* Externs from libc */
-
-extern char *getenv();
-extern int errno;
-extern char *sys_errlist[];
-
-/* Should use BSIZE instead of BUFSIZ... */
-
-#define BSIZE 512
-
-/* Some standard macros. */
-
-#define eq(a,b) (!strcmp((a), (b)))
-#define isalphanum(c) (isalpha(c) || isdigit(c))
-#define alloc(strname) ((struct strname *) tmalloc(sizeof(struct strname)))
-#define tfree(ptr) { if (ptr) free((char *) ptr); ptr = 0; }
-#define hexnum(c) ((((c) >= '0') && ((c) <= '9')) ? ((c) - '0') : ((((c) >= \
- 'a') && ((c) <= 'f')) ? ((c) - 'a' + 10) : ((((c) >= 'A') && \
- ((c) <= 'F')) ? ((c) - 'A' + 10) : 0)))
-
-#ifndef BSD
-#define random rand
-#define srandom srand
-#endif BSD
-
-#ifdef VMS
-
-#define EXIT_NORMAL 1
-#define EXIT_BAD 0
-
-#else VMS
-
-#define EXIT_NORMAL 0
-#define EXIT_BAD 1
-
-#endif VMS
-
diff --git a/gnu/games/chess/Xchess/valid.c b/gnu/games/chess/Xchess/valid.c
deleted file mode 100644
index 3dcdb00..0000000
--- a/gnu/games/chess/Xchess/valid.c
+++ /dev/null
@@ -1,264 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.3 $ on $Date: 86/11/23 17:18:35 $
- * $Source: /users/faustus/xchess/RCS/valid.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Validate a move.
- */
-
-#include "xchess.h"
-
-extern bool ischeck(), couldmove();
-
-bool
-valid_move(m, b)
- move *m;
- board *b;
-{
- board tb;
-
- /* First check that the piece can make the move at all... */
- if (!couldmove(m, b))
- return (false);
-
- /* Now see if the king is in check now. */
- bcopy((char *) b, (char *) &tb, sizeof (board));
- board_move(&tb, m);
- if (ischeck(&tb, m->piece.color))
- return (false);
-
- if (ischeck(&tb, ((m->piece.color == WHITE) ? BLACK : WHITE)))
- m->check = true;
-
- return (true);
-}
-
-static bool
-couldmove(m, b)
- move *m;
- board *b;
-{
- int x, y;
-
- switch (m->type) {
- case KCASTLE:
- if ((m->piece.color == WHITE) && (b->white_cant_castle_k) ||
- (m->piece.color == BLACK) &&
- (b->black_cant_castle_k))
- return (false);
- if ((b->square[m->fromy][5].color != NONE) ||
- (b->square[m->fromy][6].color != NONE))
- return (false);
- if (ischeck(b, m->piece.color))
- return (false);
- break;
-
- case QCASTLE:
- if ((m->piece.color == WHITE) && (b->white_cant_castle_q) ||
- (m->piece.color == BLACK) &&
- (b->black_cant_castle_q))
- return (false);
- if ((b->square[m->fromy][1].color != NONE) ||
- (b->square[m->fromy][2].color != NONE) ||
- (b->square[m->fromy][3].color != NONE))
- return (false);
- if (ischeck(b, m->piece.color))
- return (false);
- break;
-
- case MOVE:
- case CAPTURE:
- /* There is one special case here, that of taking a pawn
- * en passant. In this case we change the move field to
- * CAPTURE if it's ok.
- */
- switch (m->piece.type) {
- case PAWN:
- if ((m->type == MOVE) && (m->fromx == m->tox)) {
- /* A normal move. */
- if ((m->piece.color == WHITE) && (m->fromy ==
- m->toy + 1))
- break;
- if ((m->piece.color == WHITE) && (m->fromy ==
- 6) && (m->toy == 4) &&
- (b->square[5][m->fromx].color
- == NONE))
- break;
- if ((m->piece.color == BLACK) && (m->fromy ==
- m->toy - 1))
- break;
- if ((m->piece.color == BLACK) && (m->fromy ==
- 1) && (m->toy == 3) &&
- (b->square[2][m->fromx].color
- == NONE))
- break;
- return (false);
- } else if (m->type == CAPTURE) {
- if ((((m->piece.color == WHITE) && (m->fromy ==
- m->toy + 1)) || ((m->piece.color ==
- BLACK) && (m->fromy == m->toy -
- 1))) && ((m->fromx == m->tox + 1) ||
- (m->fromx == m->tox - 1)))
- break;
- /* Now maybe it's enpassant... We've already
- * checked for some of these things in the
- * calling routine.
- */
- if (m->enpassant) {
- if (b->square[(m->piece.color == WHITE)
- ? 3 : 4][m->tox].color ==
- ((m->piece.color == WHITE) ?
- BLACK : WHITE))
- break;
- }
- return (false);
- }
- return (false);
-
- case ROOK:
- if (m->fromx == m->tox) {
- for (y = m->fromy + ((m->fromy > m->toy) ? -1 :
- 1); y != m->toy; y += ((m->fromy
- > m->toy) ? -1 : 1))
- if (b->square[y][m->tox].color != NONE)
- return (false);
- break;
- }
- if (m->fromy == m->toy) {
- for (x = m->fromx + ((m->fromx > m->tox) ? -1 :
- 1); x != m->tox; x += ((m->fromx
- > m->tox) ? -1 : 1))
- if (b->square[m->toy][x].color != NONE)
- return (false);
- break;
- }
- return (false);
-
- case KNIGHT:
- x = m->fromx - m->tox;
- y = m->fromy - m->toy;
- if ((((x == 2) || (x == -2)) &&
- ((y == 1) || (y == -1))) ||
- (((x == 1) || (x == -1)) &&
- ((y == 2) || (y == -2))))
- break;
- return (false);
-
- case BISHOP:
- x = m->fromx - m->tox;
- y = m->fromy - m->toy;
- if ((x != y) && (x != - y))
- return (false);
- for (x = m->fromx + ((m->fromx > m->tox) ? -1 : 1), y =
- m->fromy + ((m->fromy > m->toy) ? -1 :
- 1); x != m->tox;
- x += ((m->fromx > m->tox) ? -1 : 1),
- y += ((m->fromy > m->toy) ? -1 : 1))
- if (b->square[y][x].color != NONE)
- return (false);
- break;
-
- case QUEEN:
- if (m->fromx == m->tox) {
- for (y = m->fromy + ((m->fromy > m->toy) ? -1 :
- 1); y != m->toy; y += ((m->fromy
- > m->toy) ? -1 : 1))
- if (b->square[y][m->tox].color != NONE)
- return (false);
- break;
- }
- if (m->fromy == m->toy) {
- for (x = m->fromx + ((m->fromx > m->tox) ? -1 :
- 1); x != m->tox; x += ((m->fromx
- > m->tox) ? -1 : 1))
- if (b->square[m->toy][x].color != NONE)
- return (false);
- break;
- }
- x = m->fromx - m->tox;
- y = m->fromy - m->toy;
- if ((x != y) && (x != - y))
- return (false);
- for (x = m->fromx + ((m->fromx > m->tox) ? -1 : 1), y =
- m->fromy + ((m->fromy > m->toy) ? -1 :
- 1); x != m->tox;
- x += ((m->fromx > m->tox) ? -1 : 1),
- y += ((m->fromy > m->toy) ? -1 : 1))
- if (b->square[y][x].color != NONE)
- return (false);
- break;
-
- case KING:
- x = m->fromx - m->tox;
- y = m->fromy - m->toy;
- if ((x >= -1) && (x <= 1) && (y >= -1) && (y <= 1))
- break;
- return (false);
- }
- break;
- }
- return (true);
-}
-
-/* Say whether either king is in check... If move is non-NULL, say whether he
- * in in check after the move takes place. We do this in a rather stupid way.
- */
-
-static bool
-ischeck(b, col)
- board *b;
- color col;
-{
- int x, y, kx, ky;
- move ch;
-
- for (x = 0; x < SIZE; x++)
- for (y = 0; y < SIZE; y++)
- if ((b->square[y][x].color == col) &&
- (b->square[y][x].type == KING)) {
- kx = x;
- ky = y;
- }
-
- for (x = 0; x < SIZE; x++)
- for (y = 0; y < SIZE; y++)
- if (b->square[y][x].color == ((col == WHITE) ?
- BLACK : WHITE)) {
- ch.type = CAPTURE;
- ch.piece.color = b->square[y][x].color;
- ch.piece.type = b->square[y][x].type;
- ch.fromx = x;
- ch.fromy = y;
- ch.tox = kx;
- ch.toy = ky;
- ch.enpassant = false;
- if (couldmove(&ch, b))
- return (true);
- }
-
- return (false);
-}
-
diff --git a/gnu/games/chess/Xchess/window.c b/gnu/games/chess/Xchess/window.c
deleted file mode 100644
index 4aae06d..0000000
--- a/gnu/games/chess/Xchess/window.c
+++ /dev/null
@@ -1,952 +0,0 @@
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:15 $
- * $Source: /users/faustus/xchess/RCS/window.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Deal with the two (or one) windows.
- */
-
-#include "xchess.h"
-#include <X11/Xutil.h>
-#include <sys/time.h>
-
-#include "pawn.bitmap"
-#include "rook.bitmap"
-#include "knight.bitmap"
-#include "bishop.bitmap"
-#include "queen.bitmap"
-#include "king.bitmap"
-
-#include "pawn_outline.bitmap"
-#include "rook_outline.bitmap"
-#include "knight_outline.bitmap"
-#include "bishop_outline.bitmap"
-#include "queen_outline.bitmap"
-#include "king_outline.bitmap"
-
-#include "pawn_mask.bitmap"
-#include "rook_mask.bitmap"
-#include "knight_mask.bitmap"
-#include "bishop_mask.bitmap"
-#include "queen_mask.bitmap"
-#include "king_mask.bitmap"
-
-#include "shade.bitmap"
-
-#include "xchess.cur"
-#include "xchess_mask.cur"
-
-#include "xchess.icon"
-
-windata *win1, *win2;
-bool win_flashmove = false;
-
-extern bool setup();
-extern void service(), drawgrid(), icon_refresh();
-
-bool
-win_setup(disp1, disp2)
- char *disp1, *disp2;
-{
- win1 = alloc(windata);
- if (!oneboard)
- win2 = alloc(windata);
-
- if (!setup(disp1, win1) || (!oneboard && !setup(disp2, win2)))
- return (false);
-
- if (blackflag) {
- win1->color = BLACK;
- win1->flipped = true;
- } else
- win1->color = WHITE;
- win_drawboard(win1);
-
- if (!oneboard) {
- win2->color = BLACK;
- win2->flipped = true;
- win_drawboard(win2);
- }
-
- return(true);
-}
-
-/* Draw the chess board... */
-
-void
-win_drawboard(win)
- windata *win;
-{
- int i, j;
-
- drawgrid(win);
-
- /* Now toss on the squares... */
- for (i = 0; i < SIZE; i++)
- for (j = 0; j < SIZE; j++)
- win_erasepiece(j, i, win->color);
-
- return;
-}
-
-/* Draw one piece. */
-
-void
-win_drawpiece(p, y, x, wnum)
- piece *p;
- int y, x;
- color wnum;
-{
- char *bits, *maskbits, *outline;
- windata *win;
- char buf[BSIZE];
- XImage *tmpImage;
- Pixmap tmpPM, maskPM;
- XGCValues gc;
-
- if (oneboard || (wnum == win1->color))
- win = win1;
- else
- win = win2;
-
- if (win->flipped) {
- y = SIZE - y - 1;
- x = SIZE - x - 1;
- }
-
- /*
- if (debug)
- fprintf(stderr, "draw a %s at (%d, %d) on board %d\n",
- piecenames[(int) p->type], y, x, wnum);
- */
-
- if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
-
- switch (p->type) {
- case PAWN:
- bits = pawn_bits;
- maskbits = pawn_mask_bits;
- outline = pawn_outline_bits;
- break;
-
- case ROOK:
- bits = rook_bits;
- maskbits = rook_mask_bits;
- outline = rook_outline_bits;
- break;
-
- case KNIGHT:
- bits = knight_bits;
- maskbits = knight_mask_bits;
- outline = knight_outline_bits;
- break;
-
- case BISHOP:
- bits = bishop_bits;
- maskbits = bishop_mask_bits;
- outline = bishop_outline_bits;
- break;
-
- case QUEEN:
- bits = queen_bits;
- maskbits = queen_mask_bits;
- outline = queen_outline_bits;
- break;
-
- case KING:
- bits = king_bits;
- maskbits = king_mask_bits;
- outline = king_outline_bits;
- break;
-
- default:
- fprintf(stderr,
- "Internal Error: win_drawpiece: bad piece type %d\n",
- p->type);
- }
-
- /* There are two things we can do... If this is a black and white
- * display, we have to shade the square and use an outline if the piece
- * is white. We also have to use a mask... Since we don't want
- * to use up too many bitmaps, create the mask bitmap, put the bits,
- * and then destroy it.
- */
- if (win->bnw && (p->color == WHITE))
- bits = outline;
- if (win->bnw && !iswhite(win, x, y)) {
- XSetState(win->display, DefaultGC(win->display, 0),
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0), GXcopy, AllPlanes);
-
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
-
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
-
- XFreePixmap(win->display, tmpPM);
-
- XSetFunction(win->display, DefaultGC(win->display, 0),
- GXandInverted);
- maskPM = XCreateBitmapFromData(win->display, win->boardwin,
- maskbits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, maskPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, maskPM);
-
- XSetFunction(win->display, DefaultGC(win->display, 0),
- GXor);
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- bits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, tmpPM);
-
- XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy);
-
- } else if (win->bnw){
- XSetState(win->display, DefaultGC(win->display, 0),
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0), GXcopy, AllPlanes);
-
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- bits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, tmpPM);
- } else {
- XSetState(win->display, DefaultGC(win->display, 0),
- ((p->color == WHITE) ? win->whitepiece.pixel :
- win->blackpiece.pixel),
- (iswhite(win, x, y) ? win->whitesquare.pixel :
- win->blacksquare.pixel),
- GXcopy, AllPlanes);
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- bits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, tmpPM);
- }
-
- if (!record_english) {
- gc.foreground = win->textcolor.pixel;
- if (iswhite(win, x, y) || win->bnw)
- gc.background = win->whitesquare.pixel;
- else
- gc.background = win->blacksquare.pixel;
-
- gc.font = win->small->fid;
-
- XChangeGC(win->display, DefaultGC(win->display, 0),
- GCForeground | GCBackground | GCFont, &gc);
-
- if (!x) {
- sprintf(buf, " %d", SIZE - y);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- 1, (y + 1) * (SQUARE_HEIGHT +
- BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 2);
- }
- if (y == SIZE - 1) {
- sprintf(buf, "%c", 'A' + x);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
- SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 1);
- }
- }
- return;
-}
-
-void
-win_erasepiece(y, x, wnum)
- int y, x;
- color wnum;
-{
- windata *win;
- char buf[BSIZE];
- XGCValues gc;
- Pixmap tmpPM;
-
- if (oneboard || (wnum == win1->color))
- win = win1;
- else
- win = win2;
-
- if (win->flipped) {
- y = SIZE - y - 1;
- x = SIZE - x - 1;
- }
-
- /*
- if (debug)
- fprintf(stderr, "erase square (%d, %d) on board %d\n", y, x,
- wnum);
- */
-
- if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
-
- if (win->bnw && !iswhite(win, x, y)) {
- XSetState(win->display, DefaultGC(win->display, 0),
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0), GXcopy, AllPlanes);
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
-
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
-
- XFreePixmap(win->display, tmpPM);
- } else {
- XSetFillStyle(win->display, DefaultGC(win->display, 0),
- FillSolid);
- XSetForeground(win->display, DefaultGC(win->display, 0),
- iswhite(win, x, y) ? win->whitesquare.pixel :
- win->blacksquare.pixel);
- XFillRectangle(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH),
- SQUARE_WIDTH, SQUARE_HEIGHT);
- }
-
- if (!record_english) {
- gc.foreground = win->textcolor.pixel;
- if (iswhite(win, x, y) || win->bnw)
- gc.background = win->whitesquare.pixel;
- else
- gc.background = win->blacksquare.pixel;
-
- gc.font = win->small->fid;
-
- XChangeGC(win->display, DefaultGC(win->display, 0),
- GCForeground | GCBackground | GCFont, &gc);
-
- if (!x) {
- sprintf(buf, " %d", SIZE - y);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- 1, (y + 1) * (SQUARE_HEIGHT +
- BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 2);
- }
- if (y == SIZE - 1) {
- sprintf(buf, "%c", 'A' + x);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
- SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 1);
- }
- }
-
-
- return;
-}
-
-void
-win_flash(m, wnum)
- move *m;
- color wnum;
-{
- windata *win;
- int sx, sy, ex, ey, i;
-
- if (oneboard || (wnum == win1->color))
- win = win1;
- else
- win = win2;
-
- if (win->flipped) {
- sx = SIZE - m->fromx - 1;
- sy = SIZE - m->fromy - 1;
- ex = SIZE - m->tox - 1;
- ey = SIZE - m->toy - 1;
- } else {
- sx = m->fromx;
- sy = m->fromy;
- ex = m->tox;
- ey = m->toy;
- }
- sx = sx * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
- sy = sy * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
- ex = ex * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
- ey = ey * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
-
- XSetFunction(win->display, DefaultGC(win->display, 0), GXinvert);
- XSetLineAttributes(win->display, DefaultGC(win->display, 0),
- 0, LineSolid, 0, 0);
- for (i = 0; i < num_flashes * 2; i++) {
- XDrawLine(win->display,win->boardwin,
- DefaultGC(win->display, 0),
- sx, sy, ex, ey);
- }
-
- XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy);
- return;
-}
-
-/* Handle input from the players. */
-
-void
-win_process(quick)
- bool quick;
-{
- int i, rfd = 0, wfd = 0, xfd = 0;
- struct timeval timeout;
-
- timeout.tv_sec = 0;
- timeout.tv_usec = (quick ? 0 : 500000);
-
- if (XPending(win1->display))
- service(win1);
- if (!oneboard) {
- if (XPending(win1->display))
- service(win2);
- }
-
- if (oneboard)
- rfd = 1 << win1->display->fd;
- else
- rfd = (1 << win1->display->fd) | (1 << win2->display->fd);
- if (!(i = select(32, &rfd, &wfd, &xfd, &timeout)))
- return;
- if (i == -1) {
- perror("select");
- exit(1);
- }
- if (rfd & (1 << win1->display->fd))
- service(win1);
- if (!oneboard && (rfd & (1 << win2->display->fd)))
- service(win2);
-
- return;
-}
-
-static void
-service(win)
- windata *win;
-{
- XEvent ev;
-
- while(XPending(win->display)) {
- XNextEvent(win->display, &ev);
- if (TxtFilter(win->display, &ev))
- continue;
-
- if (ev.xany.window == win->boardwin) {
- switch (ev.type) {
- case ButtonPress:
- button_pressed(&ev, win);
- break;
-
- case ButtonRelease:
- button_released(&ev, win);
- break;
-
- case Expose:
- /* Redraw... */
- win_redraw(win, &ev);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->wclockwin) {
- switch (ev.type) {
- case Expose:
- clock_draw(win, WHITE);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->bclockwin) {
- switch (ev.type) {
- case Expose:
- clock_draw(win, BLACK);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->jailwin) {
- switch (ev.type) {
- case Expose:
- jail_draw(win);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->buttonwin) {
- switch (ev.type) {
- case ButtonPress:
- button_service(win, &ev);
- break;
-
- case Expose:
- button_draw(win);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->icon) {
- icon_refresh(win);
- } else if (ev.xany.window == win->basewin) {
- message_send(win, &ev);
- } else {
- fprintf(stderr, "Internal Error: service: bad win\n");
- fprintf(stderr, "window = %d, event = %d\n", ev.xany.window,
- ev.type);
- }
- }
- return;
-}
-
-void
-win_redraw(win, event)
- windata *win;
- XEvent *event;
-{
- XExposeEvent *ev = &event->xexpose;
- int x1, y1, x2, y2, i, j;
-
- drawgrid(win);
- if (ev) {
- x1 = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
- y1 = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
- x2 = (ev->x + ev->width) / (SQUARE_WIDTH + BORDER_WIDTH);
- y2 = (ev->y + ev->height) / (SQUARE_HEIGHT + BORDER_WIDTH);
- } else {
- x1 = 0;
- y1 = 0;
- x2 = SIZE - 1;
- y2 = SIZE - 1;
- }
-
- if (x1 < 0) x1 = 0;
- if (y1 < 0) y1 = 0;
- if (x2 < 0) x2 = 0;
- if (y2 < 0) y2 = 0;
- if (x1 > SIZE - 1) x1 = SIZE - 1;
- if (y1 > SIZE - 1) y1 = SIZE - 1;
- if (x2 > SIZE - 1) x2 = SIZE - 1;
- if (y2 > SIZE - 1) y2 = SIZE - 1;
-
- if (win->flipped) {
- y1 = SIZE - y2 - 1;
- y2 = SIZE - y1 - 1;
- x1 = SIZE - x2 - 1;
- x2 = SIZE - x1 - 1;
- }
-
- for (i = x1; i <= x2; i++)
- for (j = y1; j <= y2; j++) {
- if (chessboard->square[j][i].color == NONE)
- win_erasepiece(j, i, WHITE);
- else
- win_drawpiece(&chessboard->square[j][i], j, i,
- WHITE);
- if (!oneboard) {
- if (chessboard->square[j][i].color == NONE)
- win_erasepiece(j, i, BLACK);
- else
- win_drawpiece(&chessboard->square[j][i],
- j, i, BLACK);
- }
- }
-
- return;
-}
-
-static bool
-setup(dispname, win)
- char *dispname;
- windata *win;
-{
- char buf[BSIZE], *s;
- Pixmap bm, bmask;
- Cursor cur;
- extern char *program, *recfile;
- XSizeHints xsizes;
-
-
- if (!(win->display = XOpenDisplay(dispname)))
- return (false);
-
-
- /* Now get boolean defaults... */
- if ((s = XGetDefault(win->display, program, "noisy")) && eq(s, "on"))
- noisyflag = true;
- if ((s = XGetDefault(win->display, program, "savemoves")) && eq(s, "on"))
- saveflag = true;
- if ((s = XGetDefault(win->display, program, "algebraic")) && eq(s, "on"))
- record_english = false;
- if ((s = XGetDefault(win->display, program, "blackandwhite")) && eq(s, "on"))
- bnwflag = true;
- if ((s = XGetDefault(win->display, program, "quickrestore")) && eq(s, "on"))
- quickflag = true;
- if ((s = XGetDefault(win->display, program, "flash")) && eq(s, "on"))
- win_flashmove = true;
-
- /* ... numeric variables ... */
- if (s = XGetDefault(win->display, program, "numflashes"))
- num_flashes = atoi(s);
- if (s = XGetDefault(win->display, program, "flashsize"))
- flash_size = atoi(s);
-
- /* ... and strings. */
- if (s = XGetDefault(win->display, program, "progname"))
- progname = s;
- if (s = XGetDefault(win->display, program, "proghost"))
- proghost = s;
- if (s = XGetDefault(win->display, program, "recordfile"))
- recfile = s;
- if (s = XGetDefault(win->display, program, "blackpiece"))
- black_piece_color = s;
- if (s = XGetDefault(win->display, program, "whitepiece"))
- white_piece_color = s;
- if (s = XGetDefault(win->display, program, "blacksquare"))
- black_square_color = s;
- if (s = XGetDefault(win->display, program, "whitesquare"))
- white_square_color = s;
- if (s = XGetDefault(win->display, program, "bordercolor"))
- border_color = s;
- if (s = XGetDefault(win->display, program, "textcolor"))
- text_color = s;
- if (s = XGetDefault(win->display, program, "textback"))
- text_back = s;
- if (s = XGetDefault(win->display, program, "errortext"))
- error_text = s;
- if (s = XGetDefault(win->display, program, "playertext"))
- player_text = s;
- if (s = XGetDefault(win->display, program, "cursorcolor"))
- cursor_color = s;
-
- if ((DisplayPlanes(win->display, 0) == 1) || bnwflag)
- win->bnw = true;
-
- /* Allocate colors... */
- if (win->bnw) {
- win->blackpiece.pixel = BlackPixel (win->display, 0);
- win->whitepiece.pixel = WhitePixel (win->display, 0);
- win->blacksquare.pixel = BlackPixel (win->display, 0);
- win->whitesquare.pixel = WhitePixel (win->display, 0);
- win->border.pixel = BlackPixel (win->display, 0);
- win->textcolor.pixel = BlackPixel (win->display, 0);
- win->textback.pixel = WhitePixel (win->display, 0);
- win->playertext.pixel = BlackPixel (win->display, 0);
- win->errortext.pixel = BlackPixel (win->display, 0);
- win->cursorcolor.pixel = BlackPixel (win->display, 0) ;
- } else {
- if (!XParseColor(win->display,
- DefaultColormap(win->display, 0),
- black_piece_color, &win->blackpiece) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- white_piece_color, &win->whitepiece) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- black_square_color, &win->blacksquare) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- white_square_color, &win->whitesquare) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- border_color, &win->border) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- text_color, &win->textcolor) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- text_back, &win->textback) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- error_text, &win->errortext) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- player_text, &win->playertext) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- cursor_color, &win->cursorcolor) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->blackpiece) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->whitepiece) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->blacksquare) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->whitesquare) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->border) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->textcolor) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->textback) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->errortext) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->playertext) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->cursorcolor))
- fprintf(stderr, "Can't get colors...\n");
- }
-
- /* Get fonts... */
- if ((win->small = XLoadQueryFont(win->display,SMALL_FONT)) ==
- NULL)
- fprintf(stderr, "Can't get small font...\n");
-
- if ((win->medium = XLoadQueryFont(win->display,MEDIUM_FONT))
- == NULL)
- fprintf(stderr, "Can't get medium font...\n");
-
- if ((win->large = XLoadQueryFont(win->display,LARGE_FONT)) ==
- NULL)
- fprintf(stderr, "Can't get large font...\n");
-
-
- /* Create the windows... */
-
- win->basewin =
- XCreateSimpleWindow(win->display,DefaultRootWindow(win->display),
- BASE_XPOS, BASE_YPOS,
- BASE_WIDTH, BASE_HEIGHT, 0,
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0));
- win->boardwin = XCreateSimpleWindow(win->display,win->basewin,
- BOARD_XPOS, BOARD_YPOS,
- BOARD_WIDTH, BOARD_HEIGHT,
- BORDER_WIDTH,
- win->border.pixel,
- WhitePixel(win->display, 0));
- win->recwin = XCreateSimpleWindow(win->display,win->basewin,
- RECORD_XPOS, RECORD_YPOS,
- RECORD_WIDTH, RECORD_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->jailwin = XCreateSimpleWindow(win->display,win->basewin,
- JAIL_XPOS, JAIL_YPOS,
- JAIL_WIDTH, JAIL_HEIGHT,
- BORDER_WIDTH,
- win->border.pixel,
- win->textback.pixel);
- win->wclockwin = XCreateSimpleWindow(win->display,win->basewin,
- WCLOCK_XPOS, WCLOCK_YPOS,
- CLOCK_WIDTH, CLOCK_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->bclockwin = XCreateSimpleWindow(win->display,win->basewin,
- BCLOCK_XPOS, BCLOCK_YPOS,
- CLOCK_WIDTH, CLOCK_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->messagewin = XCreateSimpleWindow(win->display,win->basewin,
- MESS_XPOS, MESS_YPOS,
- MESS_WIDTH, MESS_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->buttonwin = XCreateSimpleWindow(win->display,win->basewin,
- BUTTON_XPOS, BUTTON_YPOS,
- BUTTON_WIDTH, BUTTON_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
-
- /* Let's define an icon... */
- win->iconpixmap = XCreatePixmapFromBitmapData(win->display,
- win->basewin, icon_bits,
- icon_width, icon_height,
- win->blacksquare.pixel,
- win->whitesquare.pixel,
- 1);
- xsizes.flags = PSize | PMinSize | PPosition;
- xsizes.min_width = BASE_WIDTH;
- xsizes.min_height = BASE_HEIGHT;
- xsizes.x = BASE_XPOS;
- xsizes.y = BASE_YPOS;
- XSetStandardProperties(win->display, win->basewin,
- program, program, win->iconpixmap,
- 0, NULL, &xsizes);
-
- bm = XCreateBitmapFromData(win->display,
- win->basewin, xchess_bits,
- xchess_width, xchess_height);
- bmask = XCreateBitmapFromData(win->display,
- win->basewin, xchess_mask_bits,
- xchess_width, xchess_height);
- cur = XCreatePixmapCursor(win->display, bm, bmask,
- &win->cursorcolor,
- &WhitePixel(win->display, 0),
- xchess_x_hot, xchess_y_hot);
- XFreePixmap(win->display, bm);
- XFreePixmap(win->display, bmask);
-
- XDefineCursor(win->display,win->basewin, cur);
-
- XMapSubwindows(win->display,win->basewin);
- XMapRaised(win->display,win->basewin);
-
- XSelectInput(win->display,win->basewin, KeyPressMask);
- XSelectInput(win->display,win->boardwin,
- ButtonPressMask | ButtonReleaseMask | ExposureMask);
- XSelectInput(win->display,win->recwin,
- ButtonReleaseMask | ExposureMask);
- XSelectInput(win->display,win->jailwin, ExposureMask);
- XSelectInput(win->display,win->wclockwin, ExposureMask);
- XSelectInput(win->display,win->bclockwin, ExposureMask);
- XSelectInput(win->display,win->messagewin,
- ButtonReleaseMask | ExposureMask);
- XSelectInput(win->display,win->buttonwin,
- ButtonPressMask | ExposureMask);
-
- message_init(win);
- record_init(win);
- button_draw(win);
- jail_init(win);
- clock_init(win, WHITE);
- clock_init(win, BLACK);
- if (timeunit) {
- if (timeunit > 1800)
- sprintf(buf, "%d moves every %.2lg hours.\n",
- movesperunit, ((double) timeunit) / 3600);
- else if (timeunit > 30)
- sprintf(buf, "%d moves every %.2lg minutes.\n",
- movesperunit, ((double) timeunit) / 60);
- else
- sprintf(buf, "%d moves every %d seconds.\n",
- movesperunit, timeunit);
- message_add(win, buf, false);
- }
- return (true);
-}
-
-static void
-drawgrid(win)
- windata *win;
-{
- int i;
- XGCValues gc;
-
- gc.function = GXcopy;
- gc.plane_mask = AllPlanes;
- gc.foreground = win->border.pixel;
- gc.line_width = 0;
- gc.line_style = LineSolid;
-
- XChangeGC(win->display,
- DefaultGC(win->display, 0),
- GCFunction | GCPlaneMask | GCForeground |
- GCLineWidth | GCLineStyle, &gc);
-
- /* Draw the lines... horizontal, */
- for (i = 1; i < SIZE; i++)
- XDrawLine(win->display, win->boardwin,
- DefaultGC(win->display, 0), 0,
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2,
- SIZE * (SQUARE_WIDTH + BORDER_WIDTH),
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2);
-
- /* and vertical... */
- for (i = 1; i < SIZE; i++)
- XDrawLine(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2, 0,
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2,
- SIZE * (SQUARE_WIDTH + BORDER_WIDTH));
- return;
-}
-
-void
-win_restart()
-{
- win1->flipped = false;
- win_redraw(win1, (XEvent *) NULL);
- if (!oneboard) {
- win2->flipped = true;
- win_redraw(win2, (XEvent *) NULL);
- }
- return;
-}
-
-static void
-icon_refresh(win)
- windata *win;
-{
- XCopyArea(win->display, win->iconpixmap, win->icon,
- DefaultGC(win->display, 0),
- 0, 0, icon_width, icon_height, 0, 0);
- return;
-}
-
diff --git a/gnu/games/chess/Xchess/window.c.bm b/gnu/games/chess/Xchess/window.c.bm
deleted file mode 100644
index 19134d0..0000000
--- a/gnu/games/chess/Xchess/window.c.bm
+++ /dev/null
@@ -1,928 +0,0 @@
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:15 $
- * $Source: /users/faustus/xchess/RCS/window.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Deal with the two (or one) windows.
- */
-
-#include "xchess.h"
-#include <sys/time.h>
-
-#include "pawn.bitmap"
-#include "rook.bitmap"
-#include "knight.bitmap"
-#include "bishop.bitmap"
-#include "queen.bitmap"
-#include "king.bitmap"
-
-#include "pawn_outline.bitmap"
-#include "rook_outline.bitmap"
-#include "knight_outline.bitmap"
-#include "bishop_outline.bitmap"
-#include "queen_outline.bitmap"
-#include "king_outline.bitmap"
-
-#include "pawn_mask.bitmap"
-#include "rook_mask.bitmap"
-#include "knight_mask.bitmap"
-#include "bishop_mask.bitmap"
-#include "queen_mask.bitmap"
-#include "king_mask.bitmap"
-
-#include "shade.bitmap"
-
-#include "xchess.cur"
-#include "xchess_mask.cur"
-
-#include "xchess.icon"
-
-windata *win1, *win2;
-bool win_flashmove = false;
-
-extern bool setup();
-extern void service(), drawgrid(), icon_refresh();
-
-bool
-win_setup(disp1, disp2)
- char *disp1, *disp2;
-{
- win1 = alloc(windata);
- if (!oneboard)
- win2 = alloc(windata);
-
- if (!setup(disp1, win1) || (!oneboard && !setup(disp2, win2)))
- return (false);
-
- if (blackflag) {
- win1->color = BLACK;
- win1->flipped = true;
- } else
- win1->color = WHITE;
- win_drawboard(win1);
-
- if (!oneboard) {
- win2->color = BLACK;
- win2->flipped = true;
- win_drawboard(win2);
- }
-
- return(true);
-}
-
-/* Draw the chess board... */
-
-void
-win_drawboard(win)
- windata *win;
-{
- int i, j;
-
- drawgrid(win);
-
- /* Now toss on the squares... */
- for (i = 0; i < SIZE; i++)
- for (j = 0; j < SIZE; j++)
- win_erasepiece(j, i, win->color);
-
- return;
-}
-
-/* Draw one piece. */
-
-void
-win_drawpiece(p, y, x, wnum)
- piece *p;
- int y, x;
- color wnum;
-{
- char *bits, *maskbits, *outline;
- windata *win;
- char buf[BSIZE];
- XImage *tmpImage;
- Pixmap tmpPM, maskPM;
- XGCValues gc;
-
- if (oneboard || (wnum == win1->color))
- win = win1;
- else
- win = win2;
-
- if (win->flipped) {
- y = SIZE - y - 1;
- x = SIZE - x - 1;
- }
-
- /*
- if (debug)
- fprintf(stderr, "draw a %s at (%d, %d) on board %d\n",
- piecenames[(int) p->type], y, x, wnum);
- */
-
- if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
-
- switch (p->type) {
- case PAWN:
- bits = pawn_bits;
- maskbits = pawn_mask_bits;
- outline = pawn_outline_bits;
- break;
-
- case ROOK:
- bits = rook_bits;
- maskbits = rook_mask_bits;
- outline = rook_outline_bits;
- break;
-
- case KNIGHT:
- bits = knight_bits;
- maskbits = knight_mask_bits;
- outline = knight_outline_bits;
- break;
-
- case BISHOP:
- bits = bishop_bits;
- maskbits = bishop_mask_bits;
- outline = bishop_outline_bits;
- break;
-
- case QUEEN:
- bits = queen_bits;
- maskbits = queen_mask_bits;
- outline = queen_outline_bits;
- break;
-
- case KING:
- bits = king_bits;
- maskbits = king_mask_bits;
- outline = king_outline_bits;
- break;
-
- default:
- fprintf(stderr,
- "Internal Error: win_drawpiece: bad piece type %d\n",
- p->type);
- }
-
- /* There are two things we can do... If this is a black and white
- * display, we have to shade the square and use an outline if the piece
- * is white. We also have to use a mask... Since we don't want
- * to use up too many bitmaps, create the mask bitmap, put the bits,
- * and then destroy it.
- */
- if (win->bnw && (p->color == WHITE))
- bits = outline;
- if (win->bnw && !iswhite(win, x, y)) {
- XSetState(win->display, DefaultGC(win->display, 0),
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0), GXcopy, AllPlanes);
-
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
-
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
-
- XFreePixmap(win->display, tmpPM);
-
- XSetFunction(win->display, DefaultGC(win->display, 0),
- GXandInverted);
- maskPM = XCreateBitmapFromData(win->display, win->boardwin,
- maskbits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, maskPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, maskPM);
-
- XSetFunction(win->display, DefaultGC(win->display, 0),
- GXor);
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- bits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, tmpPM);
-
- XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy);
-
- } else if (win->bnw){
- XSetState(win->display, DefaultGC(win->display, 0),
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0), GXcopy, AllPlanes);
-
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- bits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, tmpPM);
- } else {
- XSetState(win->display, DefaultGC(win->display, 0),
- ((p->color == WHITE) ? win->whitepiece.pixel :
- win->blackpiece.pixel),
- (iswhite(win, x, y) ? win->whitesquare.pixel :
- win->blacksquare.pixel),
- GXcopy, AllPlanes);
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- bits, SQUARE_WIDTH, SQUARE_HEIGHT);
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
- XFreePixmap(win->display, tmpPM);
- }
-
- if (!record_english) {
- gc.foreground = win->textcolor.pixel;
- if (iswhite(win, x, y) || win->bnw)
- gc.background = win->whitesquare.pixel;
- else
- gc.background = win->blacksquare.pixel;
-
- gc.font = win->small->fid;
-
- XChangeGC(win->display, DefaultGC(win->display, 0),
- GCForeground | GCBackground | GCFont, &gc);
-
- if (!x) {
- sprintf(buf, " %d", SIZE - y);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- 1, (y + 1) * (SQUARE_HEIGHT +
- BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 2);
- }
- if (y == SIZE - 1) {
- sprintf(buf, "%c", 'A' + x);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
- SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 1);
- }
- }
- return;
-}
-
-void
-win_erasepiece(y, x, wnum)
- int y, x;
- color wnum;
-{
- windata *win;
- char buf[BSIZE];
- XGCValues gc;
- Pixmap tmpPM;
-
- if (oneboard || (wnum == win1->color))
- win = win1;
- else
- win = win2;
-
- if (win->flipped) {
- y = SIZE - y - 1;
- x = SIZE - x - 1;
- }
-
- /*
- if (debug)
- fprintf(stderr, "erase square (%d, %d) on board %d\n", y, x,
- wnum);
- */
-
- if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
-
- if (win->bnw && !iswhite(win, x, y)) {
- XSetState(win->display, DefaultGC(win->display, 0),
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0), GXcopy, AllPlanes);
- tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
- shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
-
- XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
- 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
-
- XFreePixmap(win->display, tmpPM);
- } else {
- XSetFillStyle(win->display, DefaultGC(win->display, 0),
- FillSolid);
- XSetForeground(win->display, DefaultGC(win->display, 0),
- iswhite(win, x, y) ? win->whitesquare.pixel :
- win->blacksquare.pixel);
- XFillRectangle(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- x * (SQUARE_WIDTH + BORDER_WIDTH),
- y * (SQUARE_HEIGHT + BORDER_WIDTH),
- SQUARE_WIDTH, SQUARE_HEIGHT);
- }
-
- if (!record_english) {
- gc.foreground = win->textcolor.pixel;
- if (iswhite(win, x, y) || win->bnw)
- gc.background = win->whitesquare.pixel;
- else
- gc.background = win->blacksquare.pixel;
-
- gc.font = win->small->fid;
-
- XChangeGC(win->display, DefaultGC(win->display, 0),
- GCForeground | GCBackground | GCFont, &gc);
-
- if (!x) {
- sprintf(buf, " %d", SIZE - y);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- 1, (y + 1) * (SQUARE_HEIGHT +
- BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 2);
- }
- if (y == SIZE - 1) {
- sprintf(buf, "%c", 'A' + x);
- XDrawImageString(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
- SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
- win->small->max_bounds.ascent - 1, buf, 1);
- }
- }
-
-
- return;
-}
-
-void
-win_flash(m, wnum)
- move *m;
- color wnum;
-{
- windata *win;
- int sx, sy, ex, ey, i;
-
- if (oneboard || (wnum == win1->color))
- win = win1;
- else
- win = win2;
-
- if (win->flipped) {
- sx = SIZE - m->fromx - 1;
- sy = SIZE - m->fromy - 1;
- ex = SIZE - m->tox - 1;
- ey = SIZE - m->toy - 1;
- } else {
- sx = m->fromx;
- sy = m->fromy;
- ex = m->tox;
- ey = m->toy;
- }
- sx = sx * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
- sy = sy * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
- ex = ex * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
- ey = ey * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
-
- for (i = 0; i < num_flashes * 2; i++)
- XDrawLine(win->display,win->boardwin,
- DefaultGC(win->display, 0),
- sx, sy, ex, ey);
- return;
-}
-
-/* Handle input from the players. */
-
-void
-win_process(quick)
- bool quick;
-{
- int i, rfd = 0, wfd = 0, xfd = 0;
- struct timeval timeout;
-
- timeout.tv_sec = 0;
- timeout.tv_usec = (quick ? 0 : 500000);
-
- if (XPending(win1->display))
- service(win1);
- if (!oneboard) {
- if (XPending(win1->display))
- service(win2);
- }
-
- if (oneboard)
- rfd = 1 << win1->display->fd;
- else
- rfd = (1 << win1->display->fd) | (1 << win2->display->fd);
- if (!(i = select(32, &rfd, &wfd, &xfd, &timeout)))
- return;
- if (i == -1) {
- perror("select");
- exit(1);
- }
- if (rfd & (1 << win1->display->fd))
- service(win1);
- if (!oneboard && (rfd & (1 << win2->display->fd)))
- service(win2);
-
- return;
-}
-
-static void
-service(win)
- windata *win;
-{
- XEvent ev;
-
- while(XPending(win->display)) {
- XNextEvent(win->display, &ev);
- if (TxtFilter(win->display, &ev))
- continue;
-
- if (ev.xany.window == win->boardwin) {
- switch (ev.type) {
- case ButtonPress:
- button_pressed(&ev, win);
- break;
-
- case ButtonRelease:
- button_released(&ev, win);
- break;
-
- case Expose:
- /* Redraw... */
- win_redraw(win, &ev);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->wclockwin) {
- switch (ev.type) {
- case Expose:
- clock_draw(win, WHITE);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->bclockwin) {
- switch (ev.type) {
- case Expose:
- clock_draw(win, BLACK);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->jailwin) {
- switch (ev.type) {
- case Expose:
- jail_draw(win);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->buttonwin) {
- switch (ev.type) {
- case ButtonPress:
- button_service(win, &ev);
- break;
-
- case Expose:
- button_draw(win);
- break;
-
- case 0:
- case NoExpose:
- break;
- default:
- fprintf(stderr, "Bad event type %d\n", ev.type);
- exit(1);
- }
- } else if (ev.xany.window == win->icon) {
- icon_refresh(win);
- } else if (ev.xany.window == win->basewin) {
- message_send(win, &ev);
- } else {
- fprintf(stderr, "Internal Error: service: bad win\n");
- fprintf(stderr, "window = %d, event = %d\n", ev.xany.window,
- ev.type);
- }
- }
- return;
-}
-
-void
-win_redraw(win, event)
- windata *win;
- XEvent *event;
-{
- XExposeEvent *ev = &event->xexpose;
- int x1, y1, x2, y2, i, j;
-
- drawgrid(win);
- if (ev) {
- x1 = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
- y1 = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
- x2 = (ev->x + ev->width) / (SQUARE_WIDTH + BORDER_WIDTH);
- y2 = (ev->y + ev->height) / (SQUARE_HEIGHT + BORDER_WIDTH);
- } else {
- x1 = 0;
- y1 = 0;
- x2 = SIZE - 1;
- y2 = SIZE - 1;
- }
-
- if (x1 < 0) x1 = 0;
- if (y1 < 0) y1 = 0;
- if (x2 < 0) x2 = 0;
- if (y2 < 0) y2 = 0;
- if (x1 > SIZE - 1) x1 = SIZE - 1;
- if (y1 > SIZE - 1) y1 = SIZE - 1;
- if (x2 > SIZE - 1) x2 = SIZE - 1;
- if (y2 > SIZE - 1) y2 = SIZE - 1;
-
- if (win->flipped) {
- y1 = SIZE - y2 - 1;
- y2 = SIZE - y1 - 1;
- x1 = SIZE - x2 - 1;
- x2 = SIZE - x1 - 1;
- }
-
- for (i = x1; i <= x2; i++)
- for (j = y1; j <= y2; j++) {
- if (chessboard->square[j][i].color == NONE)
- win_erasepiece(j, i, WHITE);
- else
- win_drawpiece(&chessboard->square[j][i], j, i,
- WHITE);
- if (!oneboard) {
- if (chessboard->square[j][i].color == NONE)
- win_erasepiece(j, i, BLACK);
- else
- win_drawpiece(&chessboard->square[j][i],
- j, i, BLACK);
- }
- }
-
- return;
-}
-
-static bool
-setup(dispname, win)
- char *dispname;
- windata *win;
-{
- char buf[BSIZE], *s;
- Pixmap bm, bmask;
- Cursor cur;
- extern char *program, *recfile;
-
-
- if (!(win->display = XOpenDisplay(dispname)))
- return (false);
-
-
- /* Now get boolean defaults... */
- if ((s = XGetDefault(win->display, program, "noisy")) && eq(s, "on"))
- noisyflag = true;
- if ((s = XGetDefault(win->display, program, "savemoves")) && eq(s, "on"))
- saveflag = true;
- if ((s = XGetDefault(win->display, program, "algebraic")) && eq(s, "on"))
- record_english = false;
- if ((s = XGetDefault(win->display, program, "blackandwhite")) && eq(s, "on"))
- bnwflag = true;
- if ((s = XGetDefault(win->display, program, "quickrestore")) && eq(s, "on"))
- quickflag = true;
- if ((s = XGetDefault(win->display, program, "flash")) && eq(s, "on"))
- win_flashmove = true;
-
- /* ... numeric variables ... */
- if (s = XGetDefault(win->display, program, "numflashes"))
- num_flashes = atoi(s);
- if (s = XGetDefault(win->display, program, "flashsize"))
- flash_size = atoi(s);
-
- /* ... and strings. */
- if (s = XGetDefault(win->display, program, "progname"))
- progname = s;
- if (s = XGetDefault(win->display, program, "proghost"))
- proghost = s;
- if (s = XGetDefault(win->display, program, "recordfile"))
- recfile = s;
- if (s = XGetDefault(win->display, program, "blackpiece"))
- black_piece_color = s;
- if (s = XGetDefault(win->display, program, "whitepiece"))
- white_piece_color = s;
- if (s = XGetDefault(win->display, program, "blacksquare"))
- black_square_color = s;
- if (s = XGetDefault(win->display, program, "whitesquare"))
- white_square_color = s;
- if (s = XGetDefault(win->display, program, "bordercolor"))
- border_color = s;
- if (s = XGetDefault(win->display, program, "textcolor"))
- text_color = s;
- if (s = XGetDefault(win->display, program, "textback"))
- text_back = s;
- if (s = XGetDefault(win->display, program, "errortext"))
- error_text = s;
- if (s = XGetDefault(win->display, program, "playertext"))
- player_text = s;
- if (s = XGetDefault(win->display, program, "cursorcolor"))
- cursor_color = s;
-
- if ((DisplayPlanes(win->display, 0) == 1) || bnwflag)
- win->bnw = true;
-
- /* Allocate colors... */
- if (win->bnw) {
- win->blackpiece.pixel = BlackPixel (win->display, 0);
- win->whitepiece.pixel = WhitePixel (win->display, 0);
- win->blacksquare.pixel = BlackPixel (win->display, 0);
- win->whitesquare.pixel = WhitePixel (win->display, 0);
- win->border.pixel = BlackPixel (win->display, 0);
- win->textcolor.pixel = BlackPixel (win->display, 0);
- win->textback.pixel = WhitePixel (win->display, 0);
- win->playertext.pixel = BlackPixel (win->display, 0);
- win->errortext.pixel = BlackPixel (win->display, 0);
- win->cursorcolor.pixel = BlackPixel (win->display, 0) ;
- } else {
- if (!XParseColor(win->display,
- DefaultColormap(win->display, 0),
- black_piece_color, &win->blackpiece) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- white_piece_color, &win->whitepiece) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- black_square_color, &win->blacksquare) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- white_square_color, &win->whitesquare) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- border_color, &win->border) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- text_color, &win->textcolor) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- text_back, &win->textback) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- error_text, &win->errortext) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- player_text, &win->playertext) ||
- !XParseColor(win->display,
- DefaultColormap(win->display, 0),
- cursor_color, &win->cursorcolor) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->blackpiece) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->whitepiece) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->blacksquare) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->whitesquare) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->border) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->textcolor) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->textback) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->errortext) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->playertext) ||
- !XAllocColor(win->display,
- DefaultColormap(win->display, 0),
- &win->cursorcolor))
- fprintf(stderr, "Can't get color...\n");
- }
-
- /* Get fonts... */
- win->small = XLoadQueryFont(win->display,SMALL_FONT);
- win->medium = XLoadQueryFont(win->display,MEDIUM_FONT);
- win->large = XLoadQueryFont(win->display,LARGE_FONT);
-
- /* Create the windows... */
-
- win->basewin =
- XCreateSimpleWindow(win->display,DefaultRootWindow(win->display),
- BASE_XPOS, BASE_YPOS,
- BASE_WIDTH, BASE_HEIGHT, 0,
- BlackPixel(win->display, 0),
- WhitePixel(win->display, 0));
- win->boardwin = XCreateSimpleWindow(win->display,win->basewin,
- BOARD_XPOS, BOARD_YPOS,
- BOARD_WIDTH, BOARD_HEIGHT,
- BORDER_WIDTH,
- win->border.pixel,
- WhitePixel(win->display, 0));
- win->recwin = XCreateSimpleWindow(win->display,win->basewin,
- RECORD_XPOS, RECORD_YPOS,
- RECORD_WIDTH, RECORD_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->jailwin = XCreateSimpleWindow(win->display,win->basewin,
- JAIL_XPOS, JAIL_YPOS,
- JAIL_WIDTH, JAIL_HEIGHT,
- BORDER_WIDTH,
- win->border.pixel,
- win->textback.pixel);
- win->wclockwin = XCreateSimpleWindow(win->display,win->basewin,
- WCLOCK_XPOS, WCLOCK_YPOS,
- CLOCK_WIDTH, CLOCK_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->bclockwin = XCreateSimpleWindow(win->display,win->basewin,
- BCLOCK_XPOS, BCLOCK_YPOS,
- CLOCK_WIDTH, CLOCK_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->messagewin = XCreateSimpleWindow(win->display,win->basewin,
- MESS_XPOS, MESS_YPOS,
- MESS_WIDTH, MESS_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
- win->buttonwin = XCreateSimpleWindow(win->display,win->basewin,
- BUTTON_XPOS, BUTTON_YPOS,
- BUTTON_WIDTH, BUTTON_HEIGHT,
- BORDER_WIDTH, win->border.pixel,
- win->textback.pixel);
-
- /* Let's define an icon... */
- win->iconpixmap = XCreatePixmapFromBitmapData(win->display,
- win->basewin, icon_bits,
- icon_width, icon_height,
- win->blacksquare.pixel,
- win->whitesquare.pixel,
- 1);
-
- bm = XCreateBitmapFromData(win->display,
- win->basewin, xchess_bits,
- xchess_width, xchess_height);
- bmask = XCreateBitmapFromData(win->display,
- win->basewin, xchess_mask_bits,
- xchess_width, xchess_height);
- cur = XCreatePixmapCursor(win->display, bm, bmask,
- &win->cursorcolor,
- &WhitePixel(win->display, 0),
- xchess_x_hot, xchess_y_hot);
- XFreePixmap(win->display, bm);
- XFreePixmap(win->display, bmask);
-
- XDefineCursor(win->display,win->basewin, cur);
-
- XMapSubwindows(win->display,win->basewin);
- XMapRaised(win->display,win->basewin);
-
- XSelectInput(win->display,win->basewin, KeyPressMask);
- XSelectInput(win->display,win->boardwin,
- ButtonPressMask | ButtonReleaseMask | ExposureMask);
- XSelectInput(win->display,win->recwin,
- ButtonReleaseMask | ExposureMask);
- XSelectInput(win->display,win->jailwin, ExposureMask);
- XSelectInput(win->display,win->wclockwin, ExposureMask);
- XSelectInput(win->display,win->bclockwin, ExposureMask);
- XSelectInput(win->display,win->messagewin,
- ButtonReleaseMask | ExposureMask);
- XSelectInput(win->display,win->buttonwin,
- ButtonPressMask | ExposureMask);
-
- message_init(win);
- record_init(win);
- button_draw(win);
- jail_init(win);
- clock_init(win, WHITE);
- clock_init(win, BLACK);
- if (timeunit) {
- if (timeunit > 1800)
- sprintf(buf, "%d moves every %.2lg hours.\n",
- movesperunit, ((double) timeunit) / 3600);
- else if (timeunit > 30)
- sprintf(buf, "%d moves every %.2lg minutes.\n",
- movesperunit, ((double) timeunit) / 60);
- else
- sprintf(buf, "%d moves every %d seconds.\n",
- movesperunit, timeunit);
- message_add(win, buf, false);
- }
-
- return (true);
-}
-
-static void
-drawgrid(win)
- windata *win;
-{
- int i;
- XGCValues gc;
-
- gc.function = GXcopy;
- gc.plane_mask = AllPlanes;
- gc.foreground = win->border.pixel;
- gc.line_width = 0;
- gc.line_style = LineSolid;
-
- XChangeGC(win->display,
- DefaultGC(win->display, 0),
- GCFunction | GCPlaneMask | GCForeground |
- GCLineWidth | GCLineStyle, &gc);
-
- /* Draw the lines... horizontal, */
- for (i = 1; i < SIZE; i++)
- XDrawLine(win->display, win->boardwin,
- DefaultGC(win->display, 0), 0,
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2,
- SIZE * (SQUARE_WIDTH + BORDER_WIDTH),
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2);
-
- /* and vertical... */
- for (i = 1; i < SIZE; i++)
- XDrawLine(win->display, win->boardwin,
- DefaultGC(win->display, 0),
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2, 0,
- i * (SQUARE_WIDTH + BORDER_WIDTH) -
- BORDER_WIDTH / 2,
- SIZE * (SQUARE_WIDTH + BORDER_WIDTH));
- return;
-}
-
-void
-win_restart()
-{
- win1->flipped = false;
- win_redraw(win1, (XEvent *) NULL);
- if (!oneboard) {
- win2->flipped = true;
- win_redraw(win2, (XEvent *) NULL);
- }
- return;
-}
-
-static void
-icon_refresh(win)
- windata *win;
-{
- XCopyArea(win->display, win->iconpixmap, win->icon,
- DefaultGC(win->display, 0),
- 0, 0, icon_width, icon_height, 0, 0);
- return;
-}
-
diff --git a/gnu/games/chess/Xchess/xchess.1 b/gnu/games/chess/Xchess/xchess.1
deleted file mode 100644
index e687513..0000000
--- a/gnu/games/chess/Xchess/xchess.1
+++ /dev/null
@@ -1,217 +0,0 @@
-
-.TH XCHESS 1 "14 Nov 1986" "X Version 10"
-.SH NAME
-xchess \- X chess display
-.SH SYNOPSIS
-.B xchess
-[ option ... ] [ white-display ] [ black-display ]
-.SH DESCRIPTION
-.PP
-.B xchess
-is a chess display program which allows players to play a game on either
-one or two displays, or play a chess-playing program. It uses the
-.B X
-window system. If one or no display names are given, it will open up one
-window and both black and white at the same board. If two displays are
-given,
-.B xchess
-will accept moves from each player in his turn. Black's board will be drawn
-with his pieces at the bottom.
-.PP
-.B xchess
-will not allow a player to make an illegal move. It accepts all legal moves,
-including castling and pawn capture \fIen passant\fR.
-.SH OPTIONS
-.TP 8
-.B -d
-Turn on debugging.
-.TP 8
-.B -f record-file
-Use \fBrecord-file\fR for saving the game when the \fBSave\fR button is
-selected, or if the \fB-s\fR flag is given. The default is "xchess.game".
-.TP 8
-.B -r saved-game
-Start with the position at the end of the saved game in the named file.
-This file may be the result of the \fBSave\fR command, and may be in
-either English or International format. When reading moves, one move
-it made per second.
-.TP 8
-.B -q
-Don't pause for a second every time a move is made when a game is being
-restored.
-.TP 8
-.B -v
-Whenever a piece is moved, outline the path with a "lightning bolt".
-This option and the \fB-n\fR option are useful if you don't want to miss
-an opponent's move when he makes it.
-.TP 8
-.B -i
-Use International format for recording moves (squares numbered 1-8, a-h)
-as opposed to English (e.g, \fIp/k4xp/q5\fR).
-.TP 8
-.B -t moves/timeunit
-Allows \fBtimeunit\fR seconds for every \fBmoves\fR moves. If either player
-exceeds this allowance both recieve a message saying informing them of
-this fact.
-.TP 8
-.B -c
-Play the computer.
-.B xchess
-will start up a chess-playing program (currently the only one it knows
-how to talk to is \fBGNU Chess\fR).
-.TP 8
-.B -p program
-The name of the program to use if the \fB-c\fR option is given. The
-default is "/usr/public/gnuchess". Note that \fBgnuchess\fR must be
-compiled with the \fIcompat\fR flag (in the file "main.c") set to 1.
-.TP 8
-.B -b
-If the \fB-c\fR flag was given, have the computer play white.
-.TP 8
-.B -bnw
-If the display has more than one display plane (i.e, is color), pretend
-it's black and white.
-.TP 8
-.B -s
-Save the moves in the record file as they are made. This is useful if
-you don't want your game to be lost when \fBxchess\fR core dumps.
-.TP 8
-.B -n
-Be noisy \- beep after every move is made.
-.TP 8
-.B -h host
-Run GNU Chess on the specified \fBhost\fR.
-.TP 8
-.B -R
-Randomly chose who plays white and who plays black, if two displays are
-given.
-.SH CONTROLS
-.PP
-The window is divided up into several sub-windows. The pieces are moved by
-pushing down any mouse button on top of the piece, moving to the destination
-square, and releasing it. Castling is done by moving the king to the
-right square. If you push down on a piece and then let the button
-up without moving it, you must move that piece. ("Touch it, move it.")
-.PP
-The progress of the game is listed in the "Game Record" window. Error
-messages and such things are printed in the "Message" window. Both these
-windows have scroll bars that you can use to move around.
-There are also windows for clocks and for a record of the pieces captured.
-.PP
-If you type any keys in the window, the text will go into the message
-window of both players. This provides a simple communication facility.
-.PP
-There are 9 buttons in the control window. They are as follows:
-.TP 8
-.B Draw
-Both players must push this button to agree on a draw (just one is ok
-if only one display is being used).
-.TP 8
-.B Resign
-The player whose turn it is to move resigns.
-.TP 8
-.B Reset
-Start over from the beginning.
-.TP 8
-.B Back
-Retract a move. If two displays are being used the other player will be
-asked to confirm this.
-.TP 8
-.B Fwd
-This will re-play the most recently retracted move. This button in conjunction
-with \fBBack\fR is useful for "scrolling around" in a saved game.
-.TP 8
-.B Save
-Save the game in the record file.
-.TP 8
-.B Flip
-Rotate the board so that Black will have his pieces at the bottom.
-.TP 8
-.B Switch
-Change the mapping of boards to players.
-.TP 8
-.B Pause
-This button has two functions. When a game is being restored, pieces will
-be moved once a second. Hitting \fBPause\fR will stop this process, and
-hitting it again will restart it. During the time that it is stopped no
-other action can be made except restarting it. While a game is being played,
-\fBPause\fR will stop the clock and restart it.
-.SH DEFAULTS
-.PP
-\fBxchess\fR uses the following \fI.Xdefaults\fR:
-.TP 8
-.B Noisy
-The -n flag.
-.TP 8
-.B SaveMoves
-The -s flag.
-.TP 8
-.B Algebraic
-The -i flag.
-.TP 8
-.B BlackAndWhite
-The -bnw flag.
-.TP 8
-.B QuickRestore
-The -q flag.
-.TP 8
-.B Flash
-The -v flag.
-.TP 8
-.B NumFlashes
-How many times to flash the move. The default is 5.
-.TP 8
-.B FlashWidth
-How big to make the lightning bolt. The default is 10 pixels.
-.TP 8
-.B ProgName
-The -p option. This may also be changed in the Makefile (-DDEF_PROG_NAME).
-.TP 8
-.B ProgHost
-The -h option.
-.TP 8
-.B RecordFile
-The -f option.
-.TP 8
-.B BlackPiece
-The color of the black pieces.
-.TP 8
-.B WhitePiece
-The color of the white pieces.
-.TP 8
-.B BorderColor
-The color of the borders.
-.TP 8
-.B BlackSquare
-The color of the black squares.
-.TP 8
-.B WhiteSquare
-The color of the white squares.
-.TP 8
-.B TextColor
-The color of routine messages and the move record text.
-.TP 8
-.B ErrorText
-The color of error messages.
-.TP 8
-.B PlayerText
-The color of player-entered text.
-.TP 8
-.B TextBack
-The background color for the two text windows.
-.TP 8
-.B CursorColor
-The color of the mouse and the text cursors.
-.SH "SEE ALSO"
-X(8), gnuchess(1), chess(5)
-.SH AUTHOR
-Wayne A. Christopher (faustus@ic.berkeley.edu)
-.SH BUGS
-.PP
-Checkmate and stalemate are not detected, so the appropriate player must resign
-or agree to a draw respectively.
-.PP
-\fBSwitch\fR doesn't work.
-.PP
-If you are playing \fBgnuchess\fR, and you select Undo a few times so that it
-is \fBgnuchess\fR's turn to move, it won't do anything.
diff --git a/gnu/games/chess/Xchess/xchess.c b/gnu/games/chess/Xchess/xchess.c
deleted file mode 100644
index 6de6502..0000000
--- a/gnu/games/chess/Xchess/xchess.c
+++ /dev/null
@@ -1,205 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.2 $ on $Date: 89/04/28 08:44:02 $
- * $Source: /usr/local/src/source/X.V11R3/contrib/games/xchess/Xchess/RCS/xchess.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- */
-
-#define USAGE "xchess [ -d ] [ -f recordfile ] [ -r savedfile ] [ -i ]\n\
-\t[ -t moves/timeunit ] [ -c ] [ -p program ] [ -b ] [ -bnw ] [ -s ]\n\
-\t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ]"
-
-#include <signal.h>
-#include "xchess.h"
-
-bool debug = false;
-bool oneboard = false;
-bool bnwflag = false;
-bool progflag = false;
-bool blackflag = false;
-bool quickflag = false;
-
-char *progname = DEF_PROGRAM;
-char *proghost = NULL;
-char *piecenames[] = { "pawn", "rook", "knight", "bishop", "queen", "king" } ;
-char *colornames[] = { "white", "black", "none" } ;
-char *movetypenames[] = { "move", "qcastle", "kcastle", "capture" } ;
-char *dispname1 = NULL, *dispname2 = NULL;
-
-char *black_piece_color = BLACK_PIECE_COLOR;
-char *white_piece_color = WHITE_PIECE_COLOR;
-char *black_square_color = BLACK_SQUARE_COLOR;
-char *white_square_color = WHITE_SQUARE_COLOR;
-char *border_color = BORDER_COLOR;
-char *text_color = TEXT_COLOR;
-char *text_back = TEXT_BACK;
-char *error_text = ERROR_TEXT;
-char *player_text = PLAYER_TEXT;
-char *cursor_color = CURSOR_COLOR;
-
-int num_flashes = NUM_FLASHES;
-int flash_size = FLASH_SIZE;
-char *program;
-char *recfile = NULL;
-
-#ifdef notdef
-/*
- * Serves no purpose.
- */
-die () {
-fprintf(stderr, "child proc changed status?!\n");
-}
-#endif
-
-void
-main(ac, av)
- char **av;
-{
- bool randflag = false;
- move *m;
- char *s;
-
- program = av[0];
-
-#ifdef notdef
- signal(SIGCHLD, die);
-#endif
-
- /* Process args. */
- av++; ac--;
- while (ac > 0 && **av == '-') {
- if (eq(*av, "-d")) {
- debug = true;
- } else if (eq(*av, "-f")) {
- av++; ac--;
- if (*av)
- record_file = *av;
- else
- goto usage;
- } else if (eq(*av, "-r")) {
- av++; ac--;
- if (*av)
- recfile = *av;
- else
- goto usage;
- } else if (eq(*av, "-i")) {
- record_english = false;
- } else if (eq(*av, "-R")) {
- randflag = true;
- } else if (eq(*av, "-v")) {
- win_flashmove = true;
- } else if (eq(*av, "-q")) {
- quickflag = true;
- } else if (eq(*av, "-t")) {
- av++; ac--;
- if (*av) {
- movesperunit = atoi(*av);
- if (s = index(*av, '/'))
- timeunit = atoi(s + 1) * 60;
- else
- timeunit = 60;
- } else
- goto usage;
- } else if (eq(*av, "-p")) {
- av++; ac--;
- if (*av)
- progname = *av;
- else
- goto usage;
- } else if (eq(*av, "-h")) {
- av++; ac--;
- if (*av)
- proghost = *av;
- else
- goto usage;
- } else if (eq(*av, "-b")) {
- blackflag = true;
- } else if (eq(*av, "-c")) {
- progflag = true;
- } else if (eq(*av, "-bnw")) {
- bnwflag = true;
- } else if (eq(*av, "-s")) {
- saveflag = true;
- } else if (eq(*av, "-n")) {
- noisyflag = true;
- } else
- goto usage;
- av++; ac--;
- }
- if (ac > 0)
- dispname1 = av[0];
- if (ac > 1)
- dispname2 = av[1];
- if (ac > 2)
- goto usage;
-
- if (!dispname2)
- oneboard = true;
-
- srandom(getpid());
-
- if (!oneboard && randflag && (random() % 2)) {
- s = dispname1;
- dispname1 = dispname2;
- dispname2 = s;
- }
-
- if (!dispname1)
- dispname1 = getenv("DISPLAY");
-
- /* Set up the board. */
- board_setup();
-
- /* Create the windows. */
- win_setup(dispname1, dispname2);
-
- board_drawall();
-
- /* Start the program if necessary. */
- if (progflag)
- if (!program_init(progname))
- exit(1);
-
- if (recfile)
- load_game(recfile);
-
- /* Go into a loop of prompting players alternately for moves, checking
- * them, and updating things.
- */
- for (;;) {
- win_process(false);
- clock_update();
- if (progflag && ((!blackflag && (nexttomove == BLACK)) ||
- (blackflag && (nexttomove == WHITE)))) {
- m = program_get();
- if (m)
- prog_move(m);
- }
- }
-
-usage: fprintf(stderr, "Usage: %s\n", USAGE);
- exit(1);
-}
-
diff --git a/gnu/games/chess/Xchess/xchess.c.150 b/gnu/games/chess/Xchess/xchess.c.150
deleted file mode 100644
index 2c17906..0000000
--- a/gnu/games/chess/Xchess/xchess.c.150
+++ /dev/null
@@ -1,197 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:32 $
- * $Source: /users/faustus/xchess/RCS/xchess.c,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- */
-
-#define USAGE "xchess [ -d ] [ -f recordfile ] [ -r savedfile ] [ -i ]\n\
-\t[ -t moves/timeunit ] [ -c ] [ -p program ] [ -b ] [ -bnw ] [ -s ]\n\
-\t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ]"
-
-#include <signal.h>
-#include "xchess.h"
-
-bool debug = false;
-bool oneboard = false;
-bool bnwflag = false;
-bool progflag = false;
-bool blackflag = false;
-bool quickflag = false;
-
-char *progname = DEF_PROGRAM;
-char *proghost = NULL;
-char *piecenames[] = { "pawn", "rook", "knight", "bishop", "queen", "king" } ;
-char *colornames[] = { "white", "black", "none" } ;
-char *movetypenames[] = { "move", "qcastle", "kcastle", "capture" } ;
-char *dispname1 = NULL, *dispname2 = NULL;
-
-char *black_piece_color = BLACK_PIECE_COLOR;
-char *white_piece_color = WHITE_PIECE_COLOR;
-char *black_square_color = BLACK_SQUARE_COLOR;
-char *white_square_color = WHITE_SQUARE_COLOR;
-char *border_color = BORDER_COLOR;
-char *text_color = TEXT_COLOR;
-char *text_back = TEXT_BACK;
-char *error_text = ERROR_TEXT;
-char *player_text = PLAYER_TEXT;
-char *cursor_color = CURSOR_COLOR;
-
-int num_flashes = NUM_FLASHES;
-int flash_size = FLASH_SIZE;
-char *program;
-char *recfile = NULL;
-
-die () {
-fprintf(stderr, "child proc changed status?!\n");
-}
-
-void
-main(ac, av)
- char **av;
-{
- bool randflag = false;
- move *m;
- char *s;
-
- program = av[0];
-
- signal(SIGCHLD, die);
- /* Process args. */
- av++; ac--;
- while (ac > 0 && **av == '-') {
- if (eq(*av, "-d")) {
- debug = true;
- } else if (eq(*av, "-f")) {
- av++; ac--;
- if (*av)
- record_file = *av;
- else
- goto usage;
- } else if (eq(*av, "-r")) {
- av++; ac--;
- if (*av)
- recfile = *av;
- else
- goto usage;
- } else if (eq(*av, "-i")) {
- record_english = false;
- } else if (eq(*av, "-R")) {
- randflag = true;
- } else if (eq(*av, "-v")) {
- win_flashmove = true;
- } else if (eq(*av, "-q")) {
- quickflag = true;
- } else if (eq(*av, "-t")) {
- av++; ac--;
- if (*av) {
- movesperunit = atoi(*av);
- if (s = index(*av, '/'))
- timeunit = atoi(s + 1) * 60;
- else
- timeunit = 60;
- } else
- goto usage;
- } else if (eq(*av, "-p")) {
- av++; ac--;
- if (*av)
- progname = *av;
- else
- goto usage;
- } else if (eq(*av, "-h")) {
- av++; ac--;
- if (*av)
- proghost = *av;
- else
- goto usage;
- } else if (eq(*av, "-b")) {
- blackflag = true;
- } else if (eq(*av, "-c")) {
- progflag = true;
- } else if (eq(*av, "-bnw")) {
- bnwflag = true;
- } else if (eq(*av, "-s")) {
- saveflag = true;
- } else if (eq(*av, "-n")) {
- noisyflag = true;
- } else
- goto usage;
- av++; ac--;
- }
- if (ac > 0)
- dispname1 = av[0];
- if (ac > 1)
- dispname2 = av[1];
- if (ac > 2)
- goto usage;
-
- if (!dispname2)
- oneboard = true;
-
- srandom(getpid());
-
- if (!oneboard && randflag && (random() % 2)) {
- s = dispname1;
- dispname1 = dispname2;
- dispname2 = s;
- }
-
- if (!dispname1)
- dispname1 = getenv("DISPLAY");
-
- /* Set up the board. */
- board_setup();
-
- /* Create the windows. */
- win_setup(dispname1, dispname2);
-
- board_drawall();
-
- /* Start the program if necessary. */
- if (progflag)
- if (!program_init(progname))
- exit(1);
-
- if (recfile)
- load_game(recfile);
-
- /* Go into a loop of prompting players alternately for moves, checking
- * them, and updating things.
- */
- for (;;) {
- win_process(false);
- clock_update();
- if (progflag && ((!blackflag && (nexttomove == BLACK)) ||
- (blackflag && (nexttomove == WHITE)))) {
- m = program_get();
- if (m)
- prog_move(m);
- }
- }
-
-usage: fprintf(stderr, "Usage: %s\n", USAGE);
- exit(1);
-}
-
diff --git a/gnu/games/chess/Xchess/xchess.cur b/gnu/games/chess/Xchess/xchess.cur
deleted file mode 100644
index ef3750d..0000000
--- a/gnu/games/chess/Xchess/xchess.cur
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#define xchess_width 16
-#define xchess_height 16
-#define xchess_x_hot 9
-#define xchess_y_hot 8
-static char xchess_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0xff,
- 0xc0, 0xff, 0x60, 0xff, 0xb0, 0xfd, 0xd8, 0x66, 0x6c, 0x3b, 0x76, 0x1d,
- 0x98, 0x1d, 0xcc, 0x0c, 0x60, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/xchess.game b/gnu/games/chess/Xchess/xchess.game
deleted file mode 100644
index 2302334..0000000
--- a/gnu/games/chess/Xchess/xchess.game
+++ /dev/null
@@ -1,8 +0,0 @@
-
-X Chess -- Sun Sep 18 18:01:17 EDT 1988
- Game played on pitcairn:0
- english
- 1. P/kb2-kb4 P/k2-k3
- 2. P/k2-k4
-Draw agreed.
-Time: white: 6s, black: 43s
diff --git a/gnu/games/chess/Xchess/xchess.h b/gnu/games/chess/Xchess/xchess.h
deleted file mode 100644
index 355731d..0000000
--- a/gnu/games/chess/Xchess/xchess.h
+++ /dev/null
@@ -1,301 +0,0 @@
-
-/* This file contains code for X-CHESS.
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of X-CHESS.
-
-X-CHESS 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 X-CHESS General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-X-CHESS, but only under the conditions described in the
-X-CHESS General Public License. A copy of this license is
-supposed to have been given to you along with X-CHESS 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. */
-
-
-/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:39 $
- * $Source: /users/faustus/xchess/RCS/xchess.h,v $
- * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
- * Permission is granted to do anything with this code except sell it
- * or remove this message.
- *
- * Definitions for the X chess program.
- */
-
-#include "std.h"
-#include <X11/Xlib.h>
-#include "scrollText/scrollText.h"
-
-#define SIZE 8
-
-typedef enum piecetype { PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING } piecetype;
-typedef enum movetype { MOVE, QCASTLE, KCASTLE, CAPTURE } movetype;
-typedef enum color { WHITE, BLACK, NONE } color;
-
-typedef struct piece {
- enum piecetype type;
- enum color color;
-} piece;
-
-/* The board has y=0 and black at the top... This probably isn't the best
- * place to keep track of who can castle, but it's part of the game state...
- */
-
-typedef struct board {
- piece square[SIZE][SIZE];
- bool white_cant_castle_k;
- bool white_cant_castle_q;
- bool black_cant_castle_k;
- bool black_cant_castle_q;
-} board;
-
-typedef struct move {
- movetype type;
- piece piece;
- piece taken;
- int fromx, fromy;
- int tox, toy;
- struct move *next;
- bool enpassant;
- bool check;
-} move;
-
-#define iswhite(win, i, j) (!(((i) + (j)) % 2))
-
-/* Stuff for the display. */
-
-typedef struct windata {
- Display *display;
- Window basewin;
- Window boardwin;
- Window recwin;
- Window wclockwin;
- Window bclockwin;
- Window messagewin;
- Window buttonwin;
- Window jailwin;
- Window icon;
- Pixmap iconpixmap;
- XColor blackpiece;
- XColor whitepiece;
- XColor blacksquare;
- XColor whitesquare;
- XColor border;
- XColor textcolor;
- XColor textback;
- XColor errortext;
- XColor playertext;
- XColor cursorcolor;
- XFontStruct *small;
- XFontStruct *medium;
- XFontStruct *large;
- bool bnw;
- color color;
- bool flipped;
- double whitehands[3];
- double blackhands[3];
- char *txtassoc;
-} windata;
-
-#define SMALL_FONT "6x10"
-#define MEDIUM_FONT "8x13"
-#define LARGE_FONT "9x15"
-#define JAIL_FONT "6x10"
-
-#define SQUARE_WIDTH 80
-#define SQUARE_HEIGHT 80
-
-#define BORDER_WIDTH 3
-
-#define BOARD_WIDTH 8 * SQUARE_WIDTH + 7 * BORDER_WIDTH
-#define BOARD_HEIGHT 8 * SQUARE_HEIGHT + 7 * BORDER_WIDTH
-#define BOARD_XPOS 0
-#define BOARD_YPOS 0
-
-#define RECORD_WIDTH 265 /* 40 chars * 6 pixels / character. */
-#define RECORD_HEIGHT 433
-#define RECORD_XPOS BOARD_WIDTH + BORDER_WIDTH
-#define RECORD_YPOS 0
-
-#define JAIL_WIDTH RECORD_WIDTH
-#define JAIL_HEIGHT 163
-#define JAIL_XPOS RECORD_XPOS
-#define JAIL_YPOS RECORD_YPOS + RECORD_HEIGHT + BORDER_WIDTH
-
-#define CLOCK_WIDTH 131
-#define CLOCK_HEIGHT 131 + BORDER_WIDTH + 20
-#define WCLOCK_XPOS RECORD_XPOS
-#define WCLOCK_YPOS RECORD_HEIGHT + JAIL_HEIGHT + BORDER_WIDTH * 2
-#define BCLOCK_XPOS WCLOCK_XPOS + CLOCK_WIDTH + BORDER_WIDTH
-#define BCLOCK_YPOS WCLOCK_YPOS
-
-#define MESS_WIDTH 329
-#define MESS_HEIGHT 92
-#define MESS_XPOS 0
-#define MESS_YPOS BOARD_HEIGHT + BORDER_WIDTH
-
-#define BUTTON_WIDTH MESS_WIDTH
-#define BUTTON_HEIGHT MESS_HEIGHT
-#define BUTTON_XPOS MESS_WIDTH + BORDER_WIDTH
-#define BUTTON_YPOS MESS_YPOS
-
-#define BASE_WIDTH BOARD_WIDTH + RECORD_WIDTH + BORDER_WIDTH * 3
-#define BASE_HEIGHT BOARD_HEIGHT + MESS_HEIGHT + BORDER_WIDTH * 3
-
-#define BASE_XPOS 50
-#define BASE_YPOS 50
-
-#define BLACK_PIECE_COLOR "#202020"
-#define WHITE_PIECE_COLOR "#FFFFCC"
-#define BLACK_SQUARE_COLOR "#77A26D"
-#define WHITE_SQUARE_COLOR "#C8C365"
-#define BORDER_COLOR "#902E39"
-#define TEXT_COLOR "#006D6D"
-#define TEXT_BACK "#FFFFDD"
-#define ERROR_TEXT "Red"
-#define PLAYER_TEXT "Blue"
-#define CURSOR_COLOR "#FF606F"
-
-#define DEF_RECORD_FILE "xchess.game"
-
-#define NUM_FLASHES 5
-#define FLASH_SIZE 10
-
-/* xchess.c */
-
-extern void main();
-extern bool debug;
-extern char *progname;
-extern char *proghost;
-extern char *piecenames[];
-extern char *colornames[];
-extern char *movetypenames[];
-extern char *dispname1, *dispname2;
-extern bool oneboard;
-extern bool bnwflag;
-extern bool progflag;
-extern bool blackflag;
-extern bool quickflag;
-extern int num_flashes;
-extern int flash_size;
-extern char *black_piece_color;
-extern char *white_piece_color;
-extern char *black_square_color;
-extern char *white_square_color;
-extern char *border_color;
-extern char *text_color;
-extern char *text_back;
-extern char *error_text;
-extern char *player_text;
-extern char *cursor_color;
-
-/* board.c */
-
-extern void board_setup();
-extern void board_drawall();
-extern void board_move();
-extern board *chessboard;
-extern void board_init();
-
-/* window.c */
-
-extern bool win_setup();
-extern void win_redraw();
-extern void win_restart();
-extern void win_drawboard();
-extern void win_drawpiece();
-extern void win_erasepiece();
-extern void win_process();
-extern void win_flash();
-extern windata *win1, *win2;
-extern bool win_flashmove;
-
-/* control.c */
-
-extern void button_pressed();
-extern void button_released();
-extern void move_piece();
-extern void prog_move();
-extern move *moves;
-extern move *foremoves;
-extern color nexttomove;
-extern void replay();
-extern void forward();
-extern void cleanup();
-extern void restart();
-extern bool noisyflag;
-
-/* valid.c */
-
-extern bool valid_move();
-
-/* record.c */
-
-extern void record_move();
-extern void record_reset();
-extern void record_save();
-extern void record_back();
-extern void record_init();
-extern void record_end();
-extern bool record_english;
-extern char *record_file;
-extern int movenum;
-extern bool saveflag;
-
-/* message.c */
-
-extern void message_init();
-extern void message_add();
-extern void message_send();
-
-/* clock.c */
-
-extern void clock_init();
-extern void clock_draw();
-extern void clock_update();
-extern void clock_switch();
-extern bool clock_started;
-extern int movesperunit;
-extern int timeunit;
-extern int whiteseconds;
-extern int blackseconds;
-
-/* button.c */
-
-extern void button_draw();
-extern void button_service();
-
-/* jail.c */
-
-extern void jail_init();
-extern void jail_draw();
-extern void jail_add();
-extern void jail_remove();
-
-/* program.c */
-extern bool program_init();
-extern void program_end();
-extern void program_send();
-extern void program_undo();
-extern move *program_get();
-
-/* parse.c */
-
-extern void load_game();
-extern move *parse_file();
-extern move *parse_move();
-extern move *parse_imove();
-extern bool loading_flag;
-extern bool loading_paused;
-
-/* popup.c */
-
-extern bool pop_question();
-
diff --git a/gnu/games/chess/Xchess/xchess.icon b/gnu/games/chess/Xchess/xchess.icon
deleted file mode 100644
index 78c68f1..0000000
--- a/gnu/games/chess/Xchess/xchess.icon
+++ /dev/null
@@ -1,28 +0,0 @@
-
-#define icon_width 48
-#define icon_height 48
-static char icon_bits[] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0xc1, 0xff, 0xff, 0xff, 0xff, 0x83, 0x41, 0x00, 0x00, 0x00, 0x00, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
- 0x41, 0x00, 0x00, 0x00, 0x00, 0x82, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x83,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x41, 0xc4, 0x89, 0x3c, 0xcf, 0x83,
- 0x41, 0x24, 0x88, 0x04, 0x41, 0x80, 0x81, 0x22, 0x88, 0x04, 0x41, 0x80,
- 0x01, 0x21, 0xf8, 0x1c, 0xcf, 0x83, 0x81, 0x22, 0x88, 0x04, 0x08, 0x82,
- 0x41, 0x24, 0x88, 0x04, 0x08, 0x82, 0x41, 0xc4, 0x89, 0x3c, 0xcf, 0x83,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
diff --git a/gnu/games/chess/Xchess/xchess_mask.cur b/gnu/games/chess/Xchess/xchess_mask.cur
deleted file mode 100644
index 6408b7e..0000000
--- a/gnu/games/chess/Xchess/xchess_mask.cur
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#define xchess_mask_width 16
-#define xchess_mask_height 16
-static char xchess_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0xff,
- 0xc0, 0xff, 0x60, 0xff, 0xb0, 0xfd, 0xd8, 0x66, 0x6c, 0x3b, 0x76, 0x1d,
- 0x98, 0x1d, 0xcc, 0x0c, 0x60, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/chess.6 b/gnu/games/chess/chess.6
deleted file mode 100644
index bbf0aa4..0000000
--- a/gnu/games/chess/chess.6
+++ /dev/null
@@ -1,161 +0,0 @@
-.TH Chess GNU
-.SH NAME
-Chess \- GNU Chess
-.SH SYNOPSIS
-.B Chess
-[
-.B arg1 arg2
-]
-.SH DESCRIPTION
-.I Chess
-plays a game of chess against the user or it plays against itself.
-.PP
-.I Chess
-has a simple alpha-numeric board display or it can be compiled for
-use with the CHESSTOOL program on a SUN workstation.
-The program gets its opening moves from the file gnuchess.book which
-should be located in the same directory as gnuchess.
-To invoke the prgram, type 'gnuchess' or type 'chesstool gnuchess'
-on a SUN workstation where 'CHESSTOOL' is installed.
-The 'gnuchess' command can be followed by up to 2 command line arguments.
-If one argument is given it determines the programs search time in
-seconds. If two arguments are given, they will be used to set tournament
-time controls with the first argument being the number of moves and the second
-being the total clock time in minutes. Thus, entering 'chess 60 5' will set
-the clocks for 5 minutes (300 seconds) for the first 60 moves.
-If no argument is given the program will prompt the user for level of
-play.
-For use with CHESSTOOL, see the documentation on that program.
-.PP
-Once
-.I Chess
-is invoked, the program will display the board and prompt the user
-for a move. To enter a move, use the notation 'e2e4' where the first
-letter-number pair indicates the origination square
-and the second letter-number pair indicates the destination square.
-An alternative is to use the notation 'nf3' where
-the first letter indicates the piece type (p,n,b,r,q,k).
-To castle, type the origin and destination squares
-of the king just as you would do for a regular move, or type
-"o-o" for kingside castling and "o-o-o" for queenside.
-.SH COMMANDS
-.PP
-In addition to legal moves, the following commands are available as responses.
-.PP
-.I beep
--- causes the program to beep after each move.
-.PP
-.I bd
--- updates the current board position on the display.
-.PP
-.I book
--- turns off use of the opening library.
-.PP
-.I both
--- causes the computer to play both sides of a chess game.
-.PP
-.I black
--- causes the computer to take the black pieces with the move
-and begin searching.
-.PP
-.I level
--- allows the user to set time controls such as
-60 moves in 5 minutes etc. In tournament mode, the program will
-vary the time it takes for each
-move depending on the situation. If easy mode is disabled (using
-the 'easy' command), the program
-will often respond with its move immediately, saving time on
-its clock for use later on.
-.PP
-.I depth
--- allows the user to change the
-search depth of the program. The maximum depth is 29 ply.
-Normally the depth is set to 29 and the computer terminates
-its search based on elapsed time rather than depth.
-Using the depth command allows setting depth to say
-4 ply and setting response time to a large number such as
-9999 seconds. The program will then search until all moves
-have been examined to a depth of 4 ply (with extensions up
-to 11 additional ply for sequences of checks and captures).
-.PP
-.I easy
--- toggles easy mode (thinking on opponents time)
-on and off. The default is easy mode ON. If easy mode is disabled,
-the user must enter a 'break' or '^C' to get the programs
-attention before entering each move.
-.PP
-.I edit
--- allows the user to set up a board position.
-In this mode, the '#' command will clear the board, the 'c'
-command will toggle piece color, and the '.' command will exit
-setup mode. Pieces are entered by typing a letter (p,n,b,r,q,k) for
-the piece followed by the coordinate. For example "pb3" would
-place a pawn on square b3.
-.PP
-.I force
--- allows the user to enter moves for both
-sides. To get the program to play after a sequence of moves
-has been entered use the 'white' or 'black' commands.
-.PP
-.I get
--- retrieves a game from disk. The program will
-prompt the user for a file name.
-.PP
-.I help
--- displays a short description of the commands.
-.PP
-.I hint
--- causes the program to supply the user with
-its predicted move.
-.PP
-.I list
--- writes the game moves and some statistics
-on search depth, nodes, and time to the file 'chess.lst'.
-.PP
-.I new
--- starts a new game.
-.PP
-.I post
--- causes the program to display the principle
-variation and the score during the search. A score of
-100 is equivalent to a 1 pawn advantage for the computer.
-.PP
-.I random
--- causes the program to randomize its move
-selection slightly.
-.PP
-.I reverse
--- causes the board display to be reversed. That
-is, the white pieces will now appear at the top of the board.
-.PP
-.I quit
--- exits the game.
-.PP
-.I save
--- saves a game to disk. The program will prompt
-the user for a file name.
-.PP
-.I switch
--- causes the program to switch places with
-the opponent and begin searching.
-.PP
-.I undo
--- undoes the last move whether it was the computer's
-or the human's. You may also type "remove". This is equivalent
-to two "undo's" (e.g. retract one move for each side).
-.PP
-.I white
--- causes the computer to take the white pieces
-with the move and begin searching.
-.SH BUGS
-.PP
-Pawn promotion to pieces other than a queen is not allowed.
-En-Passant does not work properly with CHESSTOOOL.
-The transposition table may not work properly in some
-positions so the default is to turn this off.
-.fi
-.SH SEE ALSO
-.nf
-chesstool(6)
-.fi
-
diff --git a/gnu/games/chess/gnuchess.book b/gnu/games/chess/gnuchess.book
deleted file mode 100644
index 7e8a3b5..0000000
--- a/gnu/games/chess/gnuchess.book
+++ /dev/null
@@ -1,3878 +0,0 @@
-!
-! Opening Library for CHESS
-!
-! Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
-! Copyright (c) 1987 by Stuart Cracraft and John Stanback
-!
-! This file is part of CHESS.
-!
-! CHESS 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 CHESS General Public
-! License for full details.
-!
-! Everyone is granted permission to copy, modify and redistribute
-! CHESS, but only under the conditions described in the
-! CHESS General Public License. A copy of this license is
-! supposed to have been given to you along with CHESS 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.
-!
-!
-!
-! Four Knight's Game
-e2e4 e7e5
-g1f3 b8c6
-b1c3 g8f6
-f1b5 f8b4
-o-o o-o
-d2d3 b4c3
-b2c3 d7d6
-c1g5 d8e7
-f1e1 c6d8
-d3d4 d8e6
-! Giuoco Piano
-e2e4 e7e5
-g1f3 b8c6
-f1c4 f8c5
-d2d3 g8f6
-b1c3 d7d6
-c1g5 h7h6
-g5f6 d8f6
-c3d5 f6d8
-! Two Knights Defence
-e2e4 e7e5
-g1f3 b8c6
-f1c4 g8f6
-f3g5 d7d5
-e4d5 c6a5
-c4b5 c7c6
-d5c6 b7c6
-b5e2 h7h6
-! Two Knights Defence -- Max Lange Attack
-e2e4 e7e5
-g1f3 b8c6
-f1c4 g8f6
-d2d4 e5d4
-o-o f8c5
-e4e5 d7d5
-e5f6 d5c4
-f6g7 h8g8
-! Petrov's Defence
-e2e4 e7e5
-g1f3 g8f6
-f3e5 d7d6
-e5f3 f6e4
-d2d4 d6d5
-f1d3 f8d6
-o-o o-o
-c2c4 c8g4
-c4d5 f7f5
-b1c3 b8d7
-! Petrov's Defence
-e2e4 e7e5
-g1f3 g8f6
-d2d4 e5d4
-e4e5 f6e4
-d1d4 d7d5
-!
-! Vienna Game
-e2e4 e7e5
-b1c3 f8c5
-g1f3 d7d6
-d2d4 e5d4
-f3d4 g8f6
-c1g5 h7h6
-g5h4 b1c3
-!
-e2e4 e7e5
-b1c3 b8c6
-g1f3 g7g6
-d2d4 e5d4
-c3d5 f8g7
-c1g5 c6e7
-f3d4 c7c6
-d5c3 h7h6
-! - - - - - -
-! ECO C25/1-2
-e2e4 e7e5
-b1c3 f8c5
-f1c4 d7d6
-d2d3 c8e6
-c4e6 f7f6
-d1h5 e7d7
-c1e3 c5b6
-g1e2 b8c6
-o-o g8f6
-h5h3 d8e8
-!
-e2e4 e7e5
-b1c3 f8c5
-g1f3 d7d6
-d2d4 e5d4
-f3d4 g8f6
-c1g5 h7h6
-g5h4 b8c6
-d4c6 b7c6
-f1d3 e8e7
-o-o g7g5
-! ECO C25/3-9
-e2e4 e7e5
-b1c3 b8c6
-f2f4 e5f4
-g1f3 g7g5
-h2h4 g5g4
-f3g5 h7h6
-g5f7 e7f7
-d2d4 d7d5
-c1f4 f8b4
-f1e2 b4c3
-b2c3 g8f6
-!
-e2e4 e7e5
-b1c3 b8c6
-f2f4 e5f4
-g1f3 g7g5
-d2d4 g5g4
-f1c4 g4f3
-o-o d7d5
-e4d5 c8g4
-d1d2 c6e7
-d2f4 g8h6
-!
-e2e4 e7e5
-b1c3 b8c6
-f2f4 e5f4
-d2d4 d8h4
-e1e2 d7d5
-e4d5 c8g4
-g1f3 o-o-o
-d5c6 f8c5
-d1e1 h4h5
-c6b7 e8b8
-e2d2 g4f3
-!
-e2e4 e7e5
-b1c3 b8c6
-f2f4 e5f4
-d2d4 d8h4
-e1e2 d7d6
-g1f3 c8g4
-c1f4 o-o-o
-e2e3 h4h5
-f1e2 g7g5
-f3g5 f7f5
-h2h3 g4e2
-!
-e2e4 e7e5
-b1c3 b8c6
-g2g3 f8c5
-f1g2 a7a6
-g1e2 d7d6
-d1d3 c8g4
-h2h3 g4e6
-o-o g8e7
-c3d5 o-o
-c2c3 c5a7
-g1h2 f7f6
-!
-e2e4 e7e5
-b1c3 b8c6
-g2g3 f8c5
-f1g2 d7d6
-c3a4 g8e7
-a4c5 d6c5
-d2d3 o-o
-g2e3 b7b6
-d1d2 c8e6
-g1e2 d8d7
-o-o a8d8
-!
-e2e4 e7e5
-b1c3 b8c6
-f1c4 f8c5
-d1g4 g7g6
-d4f3 g8f6
-g1e2 d7d6
-d2d3 c8g4
-f3g3 h7h6
-f2f4 d7e7
-c3d5 f6d5
-g3g4 d5e3
-! ECO C26/1-10
-e2e4 e7e5
-b1c3 g8f6
-g2g3 c7c6
-f1g2 d7d6
-g1e2 b7b5
-o-o b8d7
-h2h3 d8c7
-g3g4 b5b4
-c3b1 a7a5
-a2a3 c8a6
-a3b4 a5b4
-!
-e2e4 e7e5
-b1c3 g8f6
-g2g3 d7d5
-e4d5 f6d5
-f1g2 c8e6
-g1f3 b8c6
-o-o f8e7
-f1e1 e7f6
-c3e4 o-o
-d2d3 f6e7
-a2a3 d5b6
-!
-e2e4 e7e5
-b1c3 g8f6
-g2g3 d7d5
-e4d5 f6d5
-f1g2 d5c3
-b2c3 f8d6
-g1f3 o-o
-o-o b8d7
-d2d3 a1b8
-a2a4 b7b6
-a4a5 c8b7
-!
-e2e4 e7e5
-b1c3 g8f6
-g2g3 f8b4
-f1g2 c7c6
-g1e2 o-o
-o-o d7d5
-e4d5 c6d5
-d2d4 e5d4
-e2d4 b8c6
-c1g5 b4e7
-f1e1 h7h6
-!
-e2e4 e7e5
-b1c3 g8f6
-g2g3 f8c5
-f1g2 b8c6
-g1e2 d7d6
-o-o o-o
-d2d3 c8e6
-c3d5 e6d5
-e4d5 c6e7
-c1g5 f6d7
-d3d4 e5d4
-!
-e2e4 e7e5
-b1c3 g8f6
-g2g3 f8c5
-f1g2 b8c6
-g1f3 d7d6
-d2d3 a7a6
-o-o o-o
-c1g5 h7h6
-g5e3 c5e3
-f2e3 d6d5
-e4d5 f6d5
-!
-e2e4 e7e5
-b1c3 g8f6
-g2g3 f8c5
-f1g2 o-o
-d2d3 f8e8
-g1e2 c7c6
-o-o d7d5
-e5d5 f6d5
-g1h1 c8g4
-h2h3 g4e6
-c3e4 c5e7
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f8b4
-g1e2 o-o
-d2d3 c7c6
-o-o d7d5
-c4b3 d5e4
-c3e4 b8d7
-e2g3 f6e4
-d3e4 d7c5
-d1h5 c5b3
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f8c5
-d2d3 d7d6
-c1g5 c8e6
-d1d2 b8d7
-g1e2 e6c4
-d3c4 h7h6
-g5e3 d8e7
-e2g3 c5e3
-f2e3 g7g6
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f8c5
-d2d3 d7d6
-f2f4 b8c6
-f4f5 b6d4
-g1f3 c7c6
-f3d4 c5d4
-d1f3 b7b5
-c4b3 a7a5
-a2a3 a5a4
-! ECO C27/1-2
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f6e4
-d1h5 e4d6
-h5e5 d8e7
-e5e7 f8e7
-c4b3 d6f5
-c3d5 e7d8
-d5e3 f5d4
-b3c4 c7c6
-g1e2 d4e2
-c4e2 d7d5
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f6e4
-d1h5 e4d6
-c4b3 b8c6
-c3b5 g7g6
-h5f3 f7f6
-b5c7 d8c7
-f3f6 b7b6
-g1f3 c8a6
-f3e5 c6e5
-f6e5 e8d8
-! ECO C27/3-5
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f6e4
-d1h5 e4d6
-c4b3 b8c6
-c3b5 g7g6
-h5f3 f7f5
-f3d5 d8e7
-b5c7 e8d8
-c7a8 b7b6
-d2d3 c8b7
-h2h4 f5f4
-d5f3 f8h6
-b3d5 b7a8
-f3g4 h8f8
-g1e2 e5e4
-c1f4 h6f4
-e2f4 e7e5
-g4g5 e5g5
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f6e4
-d1h5 e4d6
-c4b3 b8c6
-c3b5 g7g6
-h5f3 f7f5
-f3d5 d8e7
-b5c7 e8d8
-c7a8 b7b6
-g1f3 c8b7
-d3d4 c6d4
-c1g5 d4f3
-d5f3 e7g5
-b3d5 e5e4
-f3b3 b7a6
-b3a4 f8h6
-a4d4 h8e8
-g2g3 g5g4
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f6e4
-d1h5 e4d6
-c4b3 b8c6
-c3b5 g7g6
-h5f3 f7f5
-f3d5 d8e7
-b5c7 e8d8
-c7a8 b7b6
-a8b6 a7b6
-d5f3 c8b7
-d2d3 c6d4
-f3h3 e5e4
-c1e3 e4d3
-o-o-o d4c2
-e3b6 d8e8
-h3d3 f8h6
-c1b1 b7e4
-! ECO C27/6-7
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f6e4
-d1h5 e4d6
-c4b3 f8e7
-g1f3 b8c6
-f3e5 o-o
-o-o c6d4
-c3d5 d4b3
-a2b3 d6e8
-h5e2 e8f6
-e5c6 d7c6
-d5e7 g8h8
-e7c8 d8c8
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 f6e4
-d1h5 e4d6
-c4b3 f8e7
-g1f3 o-o
-h2h4 b8c6
-f3g5 h7h6
-h5g6 e7g5
-h4g5 d8g5
-d2d3 d6f5
-c1g5 c6d4
-c3d5 d4b3
-! ECO C28/1-7
-e2e4 e7e5
-b1c3 g8f6
-f1c4 b8c6
-f2f3 f6e4
-g1f3 e4c3
-d2c3 d8e7
-b2b4 d7d6
-o-o c8e6
-c4e6 e7e6
-b4b5 c6d8
-f4e5 d6e5
-f3e5 f8d6
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 b8c6
-d2d3 c6a5
-g1e2 a5c4
-d3c4 d7d6
-o-o c8e6
-b2b3 c7c6
-e2g3 g7g6
-h2h3 h7h5
-d1d3 f8e7
-c1e3 d8d7
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 b8c6
-d2d3 f8c5
-c1g5 h7h6
-g5h4 d7d6
-c3a4 c8e6
-a4c5 d6c5
-b2b3 e6c4
-b3c4 d8d6
-g1e2 c6d4
-h4f6
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 b8c6
-d2d3 f8b4
-g1e2 d7d5
-e4d5 f6d5
-c4d5 d8d5
-o-o d5d8
-f2f4 e5f4
-c1f4 o-o
-d1e1 b4d6
-e1g3 b6f4
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 b8c6
-d2d3 f8b4
-c1g5 d7d6
-g1e2 c8e6
-o-o h7h6
-g5f6 d8f6
-c3d5 e6d5
-c4d5 b4c5
-c2c3 o-o
-g1h1 c6e7
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 b8c6
-d2d3 f8b4
-c1g5 h7h6
-g5f6 b4c3
-b2c3 d8f6
-g1e2 d7d6
-d1d2 c1e6
-c4b5 f6g5
-e2g3 o-o
-b5c6 b7c6
-!
-e2e4 e7e5
-b1c3 g8f6
-f1c4 b8c6
-d2d3 f8b4
-g1f3 d7d6
-o-o b4c3
-b2c3 c6a5
-c4b3 a5b3
-a2b3 o-o
-c3c4 b7b6
-d1e2 f6d7
-c1g5 f7f6
-! ECO C29/1
-e2e4 e7e5
-b1c3 g8f6
-f1f4 d7d5
-d2d3 e5f4
-e4d5 f6d5
-c3d5 d8d5
-c1f4 f8d6
-f4d6 d5d6
-d1d2 o-o
-g1f3 c8g4
-f1e2 g4f3
-! ECO C29/2-12
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-d1f3 b8c6
-f1b5 e4c3
-b2c3 f8e7
-d2d4 o-o
-b5d3 f7f6
-f3h5 g7g6
-d3g6 h7g6
-h5g6 g8h8
-g6h6 h8g8
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-d1f3 f7f5
-d2d3 e4c3
-b2c3 d5d4
-f3g3 b8c6
-f1e2 c8e6
-e2f3 d8d7
-g1e2 f8c5
-c3c4 o-o
-o-o e6c4
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-d2d3 d8h4
-g2g3 e4g3
-g1f3 h4h5
-c3d5 c8g4
-f1g2 g3h1
-d5c7 e8d7
-c7h8 b8c6
-c1e3 f7f6
-d3d4 f6e5
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-d2d3 f1b4
-d3e4 d8h4
-e1e2 b8c6
-g1f3 c8g4
-c3d5 o-o-o
-c2c3 f7f5
-e5f6 h8e8
-c3b4 e8e4
-c1e3 g7f6
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-d2d3 e4c3
-b2c3 d5d4
-g1f3 b8c6
-c3d4 f8b4
-c1d2 b4d2
-d1d2 c6d4
-c2c3 d4f3
-g2f3 d8h4
-d2f2 h4f2
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-g1f3 f1b4
-d1e2 b4c3
-b2c3 o-o
-e2e3 b8c6
-f1d3 f7f5
-o-o c8e6
-c1a3 f8e8
-a1b1 a8b8
-a3b5 e6d7
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-g1f3 b8c6
-f1b5 f8c5
-d2d4 c5b4
-c1d2 b4c3
-b2c3 o-o
-o-o c1g4
-d1e1 f7f6
-d2e3 g4d7
-e5f6 d8f6
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-g1f3 f8c5
-d1e2 c5f2
-e1d1 e4c3
-d2c3 f2b6
-c3g5 d8d7
-d1d2 o-o
-a1d1 d7a4
-a2a3 c7c5
-d2c1 c8e6
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-g1f3 c8g4
-d1e2 e4g5
-h2h4 g5f3
-g2f3 g4e6
-d2d4 b8c6
-c1e3 f8e7
-e2f2 d8d7
-o-o-o o-o-o
-f1b5 a7a6
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-g1f3 f8e7
-d1e2 e4c3
-d2c3 o-o
-c1f4 c7c5
-o-o-o d8a5
-c1b1 b8c6
-a4b5 c8e6
-b5a5 f3g5
-!
-e2e4 e7e5
-b1c3 g8f6
-f2f4 d7d5
-f4e5 f6e4
-g1f3 f8e7
-d2d4 o-o
-f1d3 f7f6
-e5f6 e7f6
-o-o b8c6
-c3e4 d5e4
-d3e4 c6d4
-f3g5 c8f5
-c2c3 f7g5
-!
-! Vienna Game
-e2e4 e7e5
-b1c3 f8c5
-g1f3 d7d6
-d2d4 e5d4
-f3d4 g8f6
-c1g5 h7h6
-g5h4 b1c3
-! Three Knights Game
-e2e4 e7e5
-b1c3 b8c6
-g1f3 g7g6
-d2d4 e5d4
-c3d5 f8g7
-c1g5 c6e7
-f3d4 c7c6
-d5c3 h7h6
-! Bishop's Opening
-e2e4 e7e5
-f1c4 g8f6
-d2d4 e5d4
-g1f3 f6e4
-d1d4 e4c5
-o-o c5e6
-f1e1 c7c6
-b1c3 d7d5
-c4d3 f8e7
-! Ruy Lopez -- Classical Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 f8c5
-c2c3 g8f6
-d2d4 e5d4
-e4e5 f6e4
-o-o d7d5
-! Ruy Lopez -- Birds Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 c6d4
-b5a4 f8c5
-o-o d4f3
-d1f3 g8e7
-d2d3 o-o
-c1e3 c5b6
-b1c3 d7d6
-! Ruy Lopez -- Schliemann Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 f7f5
-b1c3 f5e4
-c3e4 d7d5
-f3e5 d5e4
-e5c6 d8d5
-c2c4 d5d6
-c6a7 c8d7
-! Ruy Lopez -- Old Steinitz Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 d7d6
-d2d4 c8d7
-b1c3 g8f6
-o-o f8e7
-f1e1 e5d4
-f3d4 o-o
-d4f5 f8e8
-! Ruy Lopez -- Old Steinitz Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 d7d6
-d2d4 c8d7
-b1c3 g8f6
-b5c6 d7c6
-d1d3 e5d4
-f3d4 f8e7
-c1g5 c6d7
-! Ruy Lopez -- Modern Steinitz Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 a7a6
-b5a4 d7d6
-d2d4 b7b5
-a4b3 c6d4
-f3d4 e5d4
-c2c3 d4c3
-b1c3 c8b7
-! Ruy Lopez -- Open Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 a7a6
-b5a4 g8f6
-o-o f6e4
-d2d4 b7b5
-a4b3 d7d5
-d4e5 c8e6
-c2c3 f8c5
-b1d2 o-o
-! Ruy Lopez -- Open Defence
-e2e4 e7e5
-g1f3 b8c6
-f1b5 a7a6
-b5a4 g8f6
-o-o f8e7
-f1e1 b7b5
-a4b3 d7d6
-c2c3 o-o
-h2h3 c6a5
-b3c2 c2c4
-d2d4 d8c7
-! Ruy Lopez
-e2e4 e7e5
-g1f3 b8c6
-f1b5 a7a6
-b5c6 d7c6
-d2d4 e5d4
-d1d4 d8d4
-f3d4 c8d7
-c1e3 o-o-o
-b1d2 g8e7
-! Scotch Game
-e2e4 e7e5
-g1f3 b8c6
-d2d4 e5d4
-f3d4 f8c5
-c1e3 d8f6
-c2c3 g8e7
-b1d2 d7d6
-e3c5 d6c5
-! Philidor's Defence
-e2e4 e7e5
-g1f3 d7d6
-d2d4 g8f6
-b8c6 b1d2
-f8c5 f1e2
-o-o o-o
-d1e2 c7c6
-! Alekhine's Defence
-e2e4 g8f6
-e4e5 f6d5
-c2c4 d5b6
-d2d4 d7d6
-f2f4 d6e5
-f4e5 b8c6
-c1e3 c8f5
-b1c3 e7e6
-g1f3 f8e7
-! Alekhine's Defence
-e2e4 g8f6
-e4e5 f6d5
-d2d4 d7d6
-g1f3 c8g4
-f1e2 e7e6
-o-o f8e7
-h2h3 g4h5
-c2c4 d5b6
-! Kings Gambit Accepted
-e2e4 e7e5
-f2f4 e5f4
-g1f3 d7d6
-f1c4 h7h6
-d2d4 g7g5
-o-o f8g7
-c2c3 b8c6
-d1b3 d8e7
-! Ponziani's Opening
-e2e4 e7e5
-g1f3 b8c6
-c2c3 d7d5
-d1a4 g8f6
-f3e5 f8d6
-e5c6 b7c6
-d2d3 o-o
-c1g5 h7h6
-! Caro-Kann Defence
-e2e4 c7c6
-d2d4 d7d5
-e4d5 c6d5
-c2c4 g8f6
-b1c3 b8c6
-c1g5 e7e6
-c4c5 f8e7
-f1b5 o-o
-g1f3 f6e4
-! Caro-Kann Defence
-e2e4 c7c6
-d2d4 d7d5
-e4e5 c8f5
-f1d3 f5d3
-d1d3 e7e6
-b1c3 d8b6
-b1d2 c6c5
-d4c5 f8c5
-! Caro-Kann Defence
-e2e4 c7c6
-b1c3 d7d5
-g1f3 c8g4
-h2h3 g4f3
-d1f3 e7e6
-d2d4 g8f6
-f1d3 d5e4
-c3e4 d8d4
-c2c3 d4d8
-! French Defence -- Classical
-e2e4 e7e6
-d2d4 d7d5
-b1c3 g8f6
-c1g5 f8e7
-e4e5 f6d7
-g5e7 d8e7
-d1d2 o-o
-f2f4 c7c5
-g1f3 b8c6
-o-o-o c5c4
-! French Defence -- MacCutcheon
-e2e4 e7e6
-d2d4 d7d5
-b1c3 g8f6
-c1g5 c8g4
-e4e5 h7h6
-g5d2 g4f3
-g2f3 f6e4
-d1g4 e8f8
-h2h4 c7c5
-! French Defence -- Rubenstein
-e2e4 e7e6
-d2d4 d7d5
-b1c3 d5e4
-c3e4 b8d7
-g1f3 g8f6
-e4f6 d7f6
-f1d3 b7b6
-d1e2 c8b7
-c1g5 f8e7
-! French Defence -- Winawer
-e2e4 e7e6
-d2d4 d7d5
-b1c3 f8b4
-e4e5 c7c5
-a2a3 b4c3
-b2c3 b8d7
-d1g4 o-o
-g1f3 b8c6
-f1e3 f7f5
-! French Defence -- Tarrasch
-e2e4 e7e6
-d2d4 d7d5
-b1d2 b8c6
-g1f3 g8f6
-e4e5 f6d7
-d2b3 f7f6
-f1b5 f8e7
-c1f4 o-o
-! Sicilian Defence -- Dragon Variation
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-f1e2 g7g6
-c1e3 f8g7
-o-o o-o
-d4b3 c8e6
-f2f4 c6a5
-f4f5 e6c4
-! Sicilian Defence -- Dragon Variation
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g7g6
-b1c3 f8g7
-c1e3 g8f6
-f1c4 o-o
-! Sicilian Defence -- Boleslavsky Variation
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-f1e2 e7e5
-d4b3 f8e7
-o-o o-o
-c1e3 c8e6
-! Sicilian Defence -- Najdorf
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o o-o
-! Sicilian Defence -- Najdorf
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-f1e2 e7e5
-d4b3 f8e7
-o-o o-o
-f2f4 b7b5
-a2a3 c8b7
-! Sicilian Defence -- Najdorf
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-g2g3 e7e5
-d4e2 c8e6
-f1g2 b7b5
-o-o b8d7
-! Sicilian Defence -- Closed
-e2e4 c7c5
-b1c3 b8c6
-g2g3 g7g6
-f1g2 f8g7
-d2d3 e7e6
-c1e3 d7d6
-g1e2 c6d4
-d1d2 d8h4
-o-o g8d7
-! Nimzowitsch Defence
-e2e4 b8c6
-d2d4 d7d5
-e4e5 f7f6
-g1f3 c1g4
-f1e2 e7e6
-e5f6 g8f6
-c2c3 f8d6
-c1g5 d8d7
-! Queens Gambit Accepted
-d2d4 d7d5
-c2c4 d5c4
-g1f3 g8f6
-e2e3 e7e6
-f1c4 c7c5
-o-o a7a6
-d1e2 b7b5
-c4d3 c5d4
-e3d4 b8c6
-! Queens Gambit -- Catalan
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 f8e7
-f1g2 o-o
-o-o f6d7
-d1c2 c7c6
-b1d2 b7b6
-e2e4 c8b7
-b2b3 a8c8
-! Queens Gambit Declined -- Orthodox
-d2d4 d7d5
-c2c4 e7e6
-b1c3 g8f6
-c1g5 f8e7
-e2e3 o-o
-g1f3 b8d7
-a1c1 c7c6
-f8d3 d5c4
-f1c4 f6d5
-! Queens Gambit Declined -- Cambridge Springs
-d2d4 d7d5
-c2c4 e7e6
-b1c3 g8f6
-c1g5 b8d7
-e2e3 c7c6
-g1f3 d8a5
-f3d2 f8b4
-d1c2 o-o
-g5h4 c6c5
-! Queens Gambit Declined -- Exchange Var.
-d2d4 d7d5
-c2c4 e7e6
-b1c3 g8f6
-c1g5 b8d7
-c4d5 e6d5
-e2e3 c7c6
-f1d3 f8e7
-d1c2 o-o
-g1e2 f8e8
-! Queens Gambit Declined -- Semi-Tarrasch
-d2d4 d7d5
-c2c4 e7e6
-b1c3 g8f6
-g1f3 c7c5
-c4d5 c5d4
-d1d4 e6d5
-e2e4 b8c6
-f1b5 f6e4
-! Queens Gambit Declined -- Tarrasch
-d2d4 d7d5
-c2c4 e7e6
-b1c3 c7c5
-c4d5 e6d5
-g1f3 b8c6
-g2g3 g8f6
-f1g2 f8e7
-o-o o-o
-! Queens Gambit Declined -- Vienna
-d2d4 d7d5
-c2c4 e7e6
-g1f3 g8f6
-f1b5 f8b4
-b1c3 d5c4
-e2e4 c7c5
-e4e5 c5d4
-d1a4 b8c6
-o-o-o c1d2
-! Queens Gambit Declined -- Slav (Marshall Gambit)
-d2d4 d7d5
-c2c4 c7c6
-b1c3 e7e6
-e2e4 d4e4
-c3e4 f8b4
-c1d2 d8d4
-d2b4 d4e4
-f1e2 b8a6
-b4d6 b7b6
-! Queens Gambit --Slav (Krause)
-d2d4 d7d5
-c2c4 c7c6
-g1f3 g8f6
-b1c3 d5c4
-a2a4 c8f5
-f3e5 e7e6
-f2f3 f8b4
-c1g5 h7h6
-g5f6 d8f6
-e2e4 f5h7
-! Modern Benoni Counter Gambit
-d2d4 g8f6
-c2c4 c7c5
-d4d5 e7e6
-b1c3 e6d5
-c4d5 d7d6
-e2e4 g7g6
-f1d3 f8g7
-g1e2 o-o
-o-o a7a6
-a2a4 d8c7
-! Queens Pawn Game
-d2d4 d7d5
-g1f3 g8f6
-c1f4 c7c5
-e2e3 b8c6
-c2c3 d8b6
-d1c1 c8f5
-d4c5 b6c5
-b1d2 a8c8
-f3d4 c6d4
-e3d4 c5b6
-! Pirc-Robatsch Defence
-d2d4 d7d6
-e2e4 g8f6
-b1c3 g7g6
-c1g5 f8g7
-d1d2 b8d7
-o-o-o e7e5
-d4e5 d6e5
-g1f3 h7h6
-g5h4 g6g5
-h4g3 d8e7
-! Pirc-Robatsch Defence
-d2d4 d7d6
-e2e4 g8f6
-b1c3 g7g6
-f1c4 c7c6
-d1e2 f8g7
-g1f3 o-o
-c1g5 b7b5
-c4d3 d8c7
-! Queens Indian Defence
-d2d4 g8f6
-c2c4 e7e6
-g1f3 b7b6
-g2g3 c8b7
-f1g2 f8e7
-o-o o-o
-b1c3 f6e4
-d1c2 e4c3
-c2c3 d7d6
-c3c2 f7f5
-! Queens Indian Defence
-d2d4 g8f6
-c2c4 e7e6
-g1f3 b7b6
-e2e3 c8b7
-f1d3 f8e7
-b1c3 d7d5
-o-o o-o
-d1e2 b8d7
-! Nimzo-Indian Defence
-d2d4 g8f6
-c2c4 e7e6
-b1c3 f8b4
-d1c2 d7d5
-a2a3 b4c3
-c2c3 b8c6
-g1f3 f6e4
-c3b3 c6a5
-b3a4 c7c6
-! Nimzo-Indian Defence (Rubenstein)
-d2d4 g8f6
-c2c4 e7e6
-b1c3 f8b4
-e2e3 o-o
-f1d3 d7d5
-g1f3 c7c5
-o-o b8c6
-a2a3 b4c3
-b2c3 d5c4
-d3c4 d8c7
-! Nimzo-Indian Defence -- Samisch
-d2d4 g8f6
-c2c4 e7e6
-b1c3 f8b4
-a2a3 b4c3
-b2c3 o-o
-f2f3 d7d5
-c4d5 e6d5
-e2e3 c8f5
-g1e2 b8d7
-e2g3 f5g6
-! Nimzo-Indian Defence
-d2d4 g8f6
-c2c4 e7e6
-b1c3 f8b4
-c1d2 o-o
-e2e3 d7d5
-g1f3 c7c5
-a2a3 b4c3
-d2c3 f6e4
-a1c1 e4c3
-c1c3 c5d4
-! Grunfeld Defence
-d2d4 g8f6
-c2c4 g7g6
-b1c3 d7d5
-c4d5 f6d5
-e2e4 d5c3
-b2c3 c7c5
-f1c4 f8g7
-g1e2 o-o
-o-o c5d4
-c3d4 b8c6
-! Grunfeld Defence -- Smyslov
-d2d4 g8f6
-c2c4 g7g6
-b1c3 d7d5
-g1f3 f8g7
-d1b3 d5c4
-b3c4 o-o
-e2e4 c8g4
-c1e3 f6d7
-o-o-o b8c6
-! Grunfeld Defence
-d2d4 g8f6
-c2c4 g7g6
-b1c3 d7d5
-c1f4 f8g7
-d2d3 o-o
-c4d5 f6d5
-c3d5 d8d5
-f4c7 b8c6
-! Kings Indian Defence -- Classical
-d2d4 g8f6
-c2c4 g7g6
-b1c3 f8g7
-e2e4 d7d6
-g1f3 o-o
-f1e2 e7e5
-o-o b8c6
-c1e3 f8e8
-d4e5 d6e5
-! Kings Indian Defence -- 4 pawns attack
-d2d4 g8f6
-c2c4 g7g6
-b1c3 f8g7
-e2e4 d7d6
-f2f4 c7c5
-g1f3 o-o
-d4d5 e7e6
-f1d3 e6d5
-c4d5 d8b6
-! Kings Indian Defence -- Samisch
-d2d4 g8f6
-c2c4 g7g6
-b1c3 f8g7
-e2e4 d7d6
-f2f3 o-o
-c1e3 e7e5
-d4d5 c7c6
-g1e2 c6d5
-c3d5 f6d5
-! Kings Indian Defence -- Main Line
-d2d4 g8f6
-c2c4 g7g6
-g2g3 f8g7
-f1g2 o-o
-b1c3 d7d6
-g1f3 b8d7
-o-o e7e5
-e2e4 c7c6
-h2h3 d8b6
-! Kings Indian Defence
-d2d4 g8f6
-c2c4 g7g6
-b1c3 f8g7
-g1f3 o-o
-c1f4 d7d6
-h2h3 b8d7
-e2e3 c7c6
-! Dutch Defence
-d2d4 f7f5
-g2g3 e7e6
-f1g2 g8f6
-g1f3 f8e7
-o-o o-o
-c2c4 d7d6
-b1c3 d8e8
-d1c2 e8h5
-b2b3 b8c6
-c1a3 a7a5
-! English Opening
-c2c4 e7e5
-b1c3 g8f6
-g1f3 b8c6
-e2e4 f8b4
-d2d3 d7d6
-f1e2 o-o
-o-o b4c3
-b2c3 d8e7
-! English Opening
-c2c4 g8f6
-b1c3 d7d5
-c4d5 f6d5
-e2e4 d5f4
-f1c4 c8e6
-c4e6 f7e6
-! English Opening
-c2c4 e7e5
-b1c3 g8f6
-g1f3 b8c6
-g2g3 d7d5
-c4d5 f6d5
-f1g2 d5b6
-o-o f8e7
-d2d3 o-o
-c1e3 f7f5
-! Reti -- Accepted
-g1f3 d7d5
-c2c4 d5c4
-e2e3 c7c5
-f1c4 e7e6
-o-o g8f6
-b2b3 b8c6
-c1b2 a7a6
-a2a4 f8e7
-! Reti -- Neo Catalan
-g1f3 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 f8e7
-o-o o-o
-b2b3 c7c5
-c4d5 f6d5
-c1b2 b8c6
-d2d4 b7b6
-b1c3 d5c3
-! Reti -- Barcza
-g1f3 d7d5
-g2g3 g8f6
-f1g2 g7g6
-o-o f8g7
-d2d3 o-o
-b1d2 b8c6
-e2e4 e7e5
-c2c3 a7a5
-f1e1 d5e4
-d3e4 f6d7
-! Sicilian Najdorf
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-a1b1 b2a3
-e4e5 d6e5
-f4e5 f6d7
-c3e4 h7h6
-g5h4 a3a2
-b1b3 b8c6
-d4c6 b7c6
-e4d6 f8d6
-e5d6 a6a5
-f1e2 a5a4
-b3c3 a2a1
-e2d1 a4a3
-o-o a3a2
-d2e3 o-o
-! # Sicilian Defense col. 2f p. 176 MCO 12. (Incomplete game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-a1b1 b2a3
-e4e5 d6e5
-f4e5 f6d7
-f1c4 f8b4
-b1b3 a3a5
-o-o o-o
-g5f6 d7f6
-e5f6 f8d8
-b3b4 a5b4
-d2g5 g7g6
-f1f4 b7b6
-f4h4 b4f8
-g1f1 a8a7
-! # Sicilian Defense col. 3g p. 176 MCO (Incomplete Game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-a1b1 b2a3
-e4e5 d6e5
-f4e5 f6d7
-f1c4 a3a5
-c4e6 f7e6
-d4e6 d7e5
-c3d5 a5d2
-e1d2 e8d7
-e6c7 a8a7
-h1e1 e5c4
-! # Parma vs. Fischer, Havana 1965. Sicilian Defense col. 4j p. 176
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-a1b1 b2a3
-g5f6 g7f6
-f1e2 f8g7
-o-o f6f5
-f1d1 b8c6
-d4c6 g7c3
-d2e3 b7c6
-b1b3 a3c5
-e3c5 d6c5
-b3c3 f5e4
-c3c5 c8d7
-c5e5 f7f5
-g2g4 h8g8
-g1g2 f5g4
-e5e4 h7h5
-g2g3 e8e7
-! # Matanovic, Sicilian Defense col. 5k p. 176 MCO (partial game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-a1b1 b2a3
-g5f6 g7f6
-f1e2 b8c6
-d4c6 b7c6
-o-o a3a5
-g1h1 f8e7
-f4f5 e6f5
-e4f5 c8f5
-e2a6 a5a6
-f1f5 d6d5
-b1e1 a6b7
-d2h6 o-o-o
-h6h3 b7d7
-c3a4
-! # col. 6a
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-a1b1 b2a3
-f4f5 b8c6
-f5e6 f7e6
-d4c6 b7c6
-e4e5 d6e5
-g5f6 g7f6
-c3e4 f8e7
-f1e2 h7h6
-c2c4 f6f5
-b1b3 a3a4
-o-o f5e4
-g1h1 c6c5
-d2c3 a4c6
-c3e5 h8f8
-! # col. 7d
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-a1b1 b2a3
-f4f5 b8c6
-f5e6 f7e6
-d4c6 b7c6
-e4e5 f6d5
-c3d5 c6d5
-f1e2 d6e5
-o-o a8a7
-g1h1 a3c5
-c2c4 d5d4
-e2h5 g7g6
-h5d1 f8e7
-d1a4 e8d8
-f1f7 h7h6
-g5h6 e5e4
-! # col. 8
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-d4b3 b8d7
-g5f6 g7f6
-f1e2 h7h5
-o-o b2a3
-a1d1 f8e7
-g1h1 d7c5
-e2f3 a8a7
-b3c5 a3c5
-! # col. 9g; Minic-Barczay, Varna 1967 (partial game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-d4b3 b8c6
-f1d3 d6d5
-g5f6 g7f6
-c3a4 b2a3
-a4b6 d5d4
-o-o a8b8
-f4f5 a3b4
-d2b4 f8b4
-b6c8 b8c8
-f5e6 f7e6
-f1f6 e8e7
-a1f1 c6e5
-! # col. 10i; Matulovic-Kavalek, Sousse 1967
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d1d2 b6b2
-d4b3 b8c6
-a1b1 b2a3
-g5f6 g7f6
-f1d3 f8g7
-o-o o-o
-f1f3 g8h8
-f3h3 c6e7
-f4f5 e6f5
-e4f5 c8f5
-d3f5 e7f5
-c3d5
-! # col. 11b; Joppen-Bronstein, Belgrade 1954 (partial game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d4b3 b6e3
-d1e2 e3e2
-f1e2 b8d7
-a2a4 f8e7
-o-o-o h7h6
-g5h4 e6e5
-f4f5 b7b6
-e2f3 c8b7
-! # col. 12e; Rajkovic-Udovcic, Yugoslav Chp. 1962 (partial game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 d8b6
-d4b3 b8d7
-d1f3 f8e7
-o-o-o b6c7
-f1d3 h7h6
-g5h4 g7g5
-f4g5 d7e5
-f3e2 f6g4
-b3d4 h6g5
-h4g3 c8d7
-d4f3 c7c5
-! # col. 13i; Fischer-Vukovic (partial game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 f8e7
-d1f3 d8c7
-o-o-o b8d7
-g2g4 b7b5
-g5f6 d7f6
-g4g5 f6d7
-a2a3 a8b8
-h2h4 b5b4
-a3b4 b8b4
-f1h3 o-o
-d4e6 f7e6
-h3e6 g8h8
-c3d5 c7c4
-e6f5 f8f5
-e4f5 c8b7
-h1e1 e7f8
-! # col. 14m Parma-Tatai, Athens 1968 (partial game)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 b7b5
-e4e5 d6e5
-f4e5 d8c7
-e5f6 c7e5
-f1e2 e5g5
-d1d3 a8a7
-c3e4 g5e5
-d4f3 e5b2
-o-o a7d7
-d3e3 c8b7
-a1b1 b2c2
-f3g5 c2c6
-f6g7 f8g7
-! # col. 15; slight advantage for white.
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-f2f4 h7h6
-g5h4 d8b6
-d1d3 b6b2
-a1b1 b2a3
-e4e5 f6d5
-c3d5 a3d3
-f1d3 e6d5
-e5e6
-! # col. 16c; Fichtl-Dolezal, CSSR 1954
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-d1f3 b8d7
-o-o-o d8c7
-f3g3 b7b5
-f1b5 a6b5
-d4b5 c7b8
-b5d6 f8d6
-g3d6 b8d6
-d1d6 h7h6
-g5f6 d7f6
-h1d1 c8b7
-f2f3
-! # col. 17e; Vasyukov-Zukharov, USSR 1960
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 e7e6
-d1d2 b8c6
-o-o-o h7h6
-g5h4 f6e4
-d2f4 e4g5
-d4c6 b7c6
-f4a4 d8b6
-f2f4 g5h7
-f4f5 a8b8
-f5e6 c8e6
-f1c4
-! # col. 18g (somewhat questionable)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1g5 b8d7
-f1c4 d8a5
-d1d2 e7e6
-o-o-o b7b5
-c4b3 c8b7
-h1e1 a8c8
-e4e5 d7e5
-d4e6 f7e6
-e1e5 d6e5
-g5f6
-! # col. 19m; Yanofsky-Bolbochan, Stockholm 1962
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-f1e2 e7e5
-d4b3 f8e7
-o-o o-o
-f2f4 b7b5
-a2a3 c8b7
-e2f3 b8d7
-g2g3 a8c8
-d1e1 d7b6
-g1h1 b6c4
-b3d2 d8d7
-d2c4 c8c4
-c1d2 d6d5
-! # col. 20p
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-f1e2 e7e5
-d4b3 f8e7
-o-o o-o
-c1e3 b8d7
-a2a4 b7b6
-d1d2 c8b7
-f2f3 d8c7
-f1d1 f8c8
-b3c1
-! # col. 21b
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-g2g3 e7e5
-d4e2 f8e7
-f1g2 o-o
-o-o b7b5
-h2h3 c8b7
-c3d5 f6d5
-e4d5 b8d7
-a2a4 d7c5
-e2c3 d8d7
-a4b5 a6b5
-a1a8 f8a8
-! # col. 22
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-f2f4 e7e6
-d1f3 d8b6
-d4b3 b8c6
-f1d3 f8e7
-c1e3 b6c7
-o-o o-o
-a1e1 c6b4
-! # col. 23f
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-c1e3 e7e5
-d4b3 c8e6
-d1d2 b8d7
-f2f3 f8e7
-g2g4 b7b5
-g4g5 f6h5
-o-o-o o-o
-h1g1 a8c8
-c3e2
-! # col. 24k; Kotkov-Polugayevski, USSR 1959
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-f1c4 e7e6
-o-o f8e7
-c4b3 o-o
-f2f4 b7b5
-a2a3 c8b7
-f4f5 e6e5
-d4e2 b8d7
-e2g3 d7c5
-b3d5 b7d5
-e4d5 a8c8
-c1g5 c5d7
-g5f6 d7f6
-c3e4 c8c4
-! # col. 25o; Ciocaltea-Minic, Bucharest 1966
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 a7a6
-f1c4 e7e6
-c4b3 b7b5
-f2f4 c8b7
-f4f5 e6e5
-d4e2 b8d7
-o-o f8e7
-e2g3 a8c8
-c1g5 o-o
-! # col. 26e
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-c1e3 f8g7
-f2f3 o-o
-d1d2 b8c6
-o-o-o d6d5
-e4d5 f6d5
-d4c6 b7c6
-c3d5 c6d5
-d2d5 d8c7
-d5a8 c8f5
-a8f8 g8f8
-d1d2 h7h5
-f1e2 f8g8
-a2a3 c7b8
-! # col. 27i; Bikhovski-Gik, Moscow 1968
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-c1e3 f8g7
-f2f3 o-o
-d1d2 b8c6
-f1c4 c8d7
-o-o-o d8a5
-c4b3 f8c8
-g2g4 c6e5
-h2h4 e5c4
-b3c4 c8c4
-d4b3 a5a6
-h4h5 c4c3
-b2c3 d7e6
-c1b1 a8c8
-e3d4 c8c4
-h5g6 h7g6
-! # col. 28k
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-c1e3 f8g7
-f2f3 o-o
-d1d2 b8c6
-f1c4 c8d7
-o-o-o d8a5
-c4b3 f8c8
-h2h4 c6e5
-h4h5 f6h5
-e3h6 e5d3
-c1b1 d3b2
-b1b2 g7h6
-d2h6 c8c3
-g2g4 h5f6
-g4g5 f6h5
-! # col. 29m; Ostojic-Honfi, Monte Carlo 1968
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-c1e3 f8g7
-f2f3 o-o
-d1d2 b8c6
-f1c4 c8d7
-o-o-o d8a5
-c4b3 f8c8
-c1b1 c6e5
-h2h4 e5c4
-b3c4 c8c4
-d4b3 a5c7
-h4h5 c4c3
-d2c3 c7c3
-b2c3 f6h5
-e3d4 d7e6
-h1e1 h5f6
-e4e5 d6e5
-d4e5 f6d5
-b1b2 a8c8
-! # col. 30p; Karpov-Korchnoi, 2nd match game 1974.
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-c1e3 f8g7
-f2f3 o-o
-d1d2 b8c6
-f1c4 c8d7
-h2h4 a8c8
-c4b3 c6e5
-h4h5 f6h5
-o-o-o e5c4
-b3c4 c8c4
-g2g4 h5f6
-d4e2 d8a5
-e3h6 g7h6
-d2h6 f8c8
-d1d3 c4c5
-g4g5 c5g5
-d3d5 g5d5
-c3d5 c8e8
-e2c3 d7c6
-e4e5 c6d5
-e5f6 e7f6
-h6h7 g8f8
-h7h8 f8e7
-c3d5
-! # col. 31
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-g2g3 b8c6
-f1g2 c6d4
-d1d4 f8g7
-o-o o-o
-d4d3 c8e6
-c3d5 f6d5
-e4d5 e6f5
-! # col. 32c; Pulsen-Cortlever, Buenos Aires 1939.
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-c1g5 f8g7
-d1d2 b8c6
-o-o-o o-o
-d4b3 f8e8
-f2f3 a7a6
-c1b1 b7b5
-h2h4 c8e6
-g2g4 c6e5
-! # col. 33h
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f2f4 b8c6
-d4c6 b7c6
-e4e5 d6e5
-d1d8 e8d8
-f4e5 f6g4
-c1f4 c8e6
-c3e4 f8g7
-e4g5 g7e5
-o-o-o d8c7
-g5e6 f7e6
-f4e5 g4e5
-d1e1 c7d6
-g2g3 e5g4
-f1c4 e6e5
-e1e2
-! # col. 34j
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f2f4 b8c6
-f1b5 d8c7
-c3d5 f6d5
-e4d5 a7a6
-b5c6 b7c6
-d4c6 c8b7
-c1e3 f8g7
-e3d4 g7d4
-d1d4 o-o
-o-o b7c6
-! # col. 35l
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f2f4 b8d7
-f1e2 f8g7
-c1e3 o-o
-e2f3 d7b6
-d1e2 e7e5
-d4b3 f6g4
-f3g4 d8h4
-g2g3 h4g4
-e2g4 c8g4
-! # col. 36a
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-o-o o-o
-d4b3 c8e6
-f2f4 c6a5
-f4f5 e6c4
-b3a5 c4e2
-d1e2 d8a5
-g2g4 a8c8
-g4g5 c8c3
-g5f6 c3e3
-e2e3 g7f6
-c2c3 f8c8
-a2a3 c8c4
-a1e1 b7b5
-! # col. 37c; Domnitz-Kraidman, Tel Aviv 1964
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-o-o o-o
-d4b3 c8e6
-f2f4 d8c8
-d1e1 f6g4
-e2g4 e6g4
-f4f5 g6f5
-h2h3 g4h3
-g2h3 f5e4
-e1h4 f7f5
-g1h1 f8f7
-f1g1 c6e5
-c3d5 c8d7
-b3d4 e5g6
-g1g6 h7g6
-a1g1 e7e5
-g1g6 d7d8
-e3g5 d8a5
-d5f6 g8f8
-d4e6
-! # col. 38f; Unzicker-Geller, W. Germany-USSR 1960 (drawn)
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-o-o o-o
-d1d2 f6g4
-e2g4 c8g4
-f2f4 c6d4
-e3d4 e7e5
-d4e3 e5f4
-f1f4 g4e6
-f4f2 g7e5
-e3d4 a8c8
-a1d1 d8a5
-a2a3 c8c4
-c3e2 a5d2
-d1d2
-! # col. 39
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-o-o o-o
-f2f4 d8b6
-d1d3 f6g4
-c3d5 g7d4
-e2g4 d4e3
-d3e3 b6b2
-g4c8 a8c8
-a1b1 b2a2
-b1b7 e7e6
-! # col. 40h
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-o-o o-o
-f2f4 d8b6
-e4e5 d6e5
-f4e5 c6e5
-d4f5 b6b2
-f5e7 g8h8
-e3d4 b2b4
-d4e5 b4e7
-d1d4 f6e8
-e5g7 e8g7
-e2d3 c8e6
-! # col. 41b; Smyslov-Botvinnik, match 1958
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-h2h4 h7h5
-f2f3 o-o
-d1d2 d6d5
-d4c6 b7c6
-e4e5 f6e8
-f3f4 f7f6
-o-o-o f6e5
-f4e5 g7e5
-g2g4 c8g4
-e2g4 h5g4
-h4h5 g6g5
-! # col. 42d; Van den Burg-Rajkovic, Orebro 1966
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-d4b3 o-o
-f2f4 c6a5
-g2g4 b7b6
-g4g5 f6d7
-o-o c8b7
-e2d3 a8c8
-b3a5 b6a5
-d1e1 d7c5
-f4f5 g7e5
-e1h4 e7e6
-f5f6 h7h5
-d3e2 g8h7
-e2h5 f8h8
-! # col. 43f
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-c1e3 b8c6
-d4b3 o-o
-f2f4 c6a5
-g2g4 c8e6
-g4g5 f6d7
-e3d4 f7f6
-h2h4 f6g5
-d4g7 g8g7
-b3d4 e6g8
-f4f5 d8b6
-! # col. 44
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-o-o b8c6
-d4b3 o-o
-f2f4 b7b5
-e2f3 b5b4
-c3d5 f6d5
-e4d5 c6a5
-b3a5 d8a5
-f1e1 f8e8
-! # col. 45i; Smyslov-Korchnoi, Moscow 1960
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 g7g6
-f1e2 f8g7
-d4b3 b8c6
-g2g4 b7b6
-f2f4 c8b7
-e2f3 o-o
-h2h4 a7a5
-a2a4 c6b4
-h4h5 d6d5
-e4e5 f6g4
-b3d4 g4h6
-h5g6 f7g6
-d4e6 d8d7
-e6f8 a8f8
-c3b5 d5d4
-! # col. 46
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-f3d4 g8f6
-f2f3 e7e5
-f1b5 c8d7
-b5d7 b8d7
-d4f5 d6d5
-e4d5 d8a5
-b1c3 d7b6
-! # col. 47h; Schweber-Najdorf, Buenos Aires 1970
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-d1d4 b8c6
-f1b5 c8d7
-b5c6 d7c6
-c2c4 g8f6
-b1c3 e7e6
-c1g5 f8e7
-o-o o-o
-f1e1 h7h6
-g5h4 a7a6
-a1d1 d8a5
-d4d2 a5b6
-f3d4 a8c8
-e1e3 f8e8
-! # col. 48i
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-d1d4 a7a6
-c1e3 g8f6
-b1c3 b8c6
-d4b6 d8b6
-e3b6 g7g6
-o-o-o f8h6
-c1b1 o-o
-f3d4 c8d7
-f2f3 c6e5
-d4b3 f8c8
-b3a5 d7c6
-c3d5 c6d5
-e4d5 f6d7
-b6d4 b7b6
-! # col. 49m; Fischer-Korchnoi, Buenos-Aires 1960
-e2e4 c7c5
-g1f3 d7d6
-d2d4 c5d4
-c2c3 d4c3
-b1c3 b8c6
-f1c4 e7e6
-o-o a7a6
-d1e2 g8f6
-f1d1 d8c7
-c1g5 f8e7
-a1c1 o-o
-c4b3 h7h6
-g5f4 e6e5
-f4e3 c7d8
-c3d5 f6d5
-b3d5 c8d7
-! # col. 50
-e2e4 c7c5
-g1f3 d7d6
-d2d4 g8f6
-d4c5 f6e4
-c5d6 e7e6
-d1d3 e4d6
-b1c3 b8c6
-c1f4 f7f6
-o-o-o e6e5
-c3b5
-! # col. 51c; Pfeiffer-Kottnauer, Helsinki 1952
-e2e4 c7c5
-g1f3 d7d6
-c2c3 g8f6
-f1d3 b8c6
-d3c2 c8g4
-h2h3 g4h5
-d2d3 d6d5
-d1e2 e7e6
-b1d2 f8e7
-d2f1 d8a5
-! # col. 52d; Brasket-Evans, U.S. Open Chp. 1960
-e2e4 c7c5
-g1f3 d7d6
-c2c3 g8f6
-d2d3 g7g6
-g2g3 f8g7
-b1d2 o-o
-f1g2 e7e5
-o-o b8c6
-a2a4 h7h6
-d2b1 d8a5
-! # col. 53h; Ciocaltea-Fischer, Varna 1962
-e2e4 c7c5
-g1f3 d7d6
-g2g3 g7g6
-f1g2 f8g7
-o-o b8c6
-c2c3 e7e5
-d2d3 g8e7
-f3h4 o-o
-f2f4 e5f4
-g3f4 f7f5
-b1d2 g8h8
-d2f3
-! # col. 54k; Tarjan-Mednis, U.S. Chp. 1973
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 e7e6
-f1e2 g7g6
-d4b3
-! e2e4 c7c5
-g1f3 d7d6
-b1c3 g8f6
-e4e5 d6e5
-f3e5 a7a6
-f1e2 e7e6
-o-o d8c7
-e5c4 b7b5
-c4e3 f8d6
-h2h3 b8c6
-a2a4 b5b4
-c3b1 c8b7
-d2d3 c6d4
-b1d2 o-o
-d2f3 d4e2
-d1e2 f8e8
-e3c4 e6e5
-f3g5 e5e4
-c4d6 c7d6
-g5e4 f6e4
-d3e4 b7e4
-c1e3 d6c6
-! # col. 55o; Medina-Pomar, Santander 1947
-e2e4 c7c5
-g1f3 d7d6
-b2b4 c5b4
-d2d4 g8f6
-f1d3 d6d5
-b1d2 d5e4
-d2e4 b8d7
-e4g5 d8c7
-c2c4 h7h6
-g5h3 g7g5
-h3g1 f8g7
-g1e2 e7e5
-e2g3 e5e4
-d1e2 o-o
-! # col. 56e; del Corral-Benko, Mallorca 1968
-e2e4 c7c5
-g1f3 d7d6
-f1b5 c8d7
-b5d7 d8d7
-o-o b8c6
-f1e1 g8f6
-c2c3 e7e6
-d2d3 f8e7
-a2a4 o-o
-b1d2 d7c7
-! # col. 57g; Radovich-Lombardy, Leipzig 1960
-e2e4 c7c5
-g1f3 d7d6
-f1b5 b8c6
-o-o a7a6
-b5c6 b7c6
-d2d4 c5d4
-d1d4 e7e5
-d4d3 f7f6
-c2c4 c8e6
-b1c3 d8c7
-! # col. 58j; Gurgenidze-Osnos, Alma Ata 1969
-e2e4 c7c5
-g1f3 b8c6
-f1b5 e7e6
-b1c3 g8e7
-o-o a7a6
-b5c6 e7c6
-d2d4 c5d4
-f3d4 d7d6
-d4c6 b7c6
-d1g4 g7g6
-e4e5 d6d5
-c1g5 f8e7
-! # col. 59m
-e2e4 c7c5
-g1f3 b8c6
-f1b5 g7g6
-o-o f8g7
-c2c3 g8f6
-f1e1 o-o
-d2d4 c5d4
-c3d4 d7d5
-e4e5 f6e4
-b1c3 e4c3
-b2c3 c6a5
-c1g5 c8f5
-f3d2 f8e8
-! # col. 60o
-e2e4 c7c5
-g1f3 b8c6
-f1b5 g7g6
-o-o f8g7
-f1e1 e7e5
-f1e1 o-o
-d2d4 c5d4
-c3d4 d7d5
-e4e5 f6e4
-b1c3 e4c3
-b2c3 c6a5
-c1g5 c8f5
-f3d2 f8e8
-! # col. 61c; Barczay-Szilagyi, Hungarian Chp. 1969
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-g5f6 g7f6
-d4b3 h8g8
-g2g3 f6f5
-d1d2 f8g7
-e4f5 d7f5
-f1g2 d8d7
-o-o g7c3
-b2c3 f5h3
-g2h3 d7h3
-! # col. 62e
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d4b3 h7h6
-g5h4 a8c8
-f1e2 g7g5
-h4g3 h6h5
-h2h4 g5g4
-g3f4 c6e5
-d1d4 e5g6
-f4g5 f8g7
-o-o
-! # col. 63g; Matulovic-Masic, Sombor 1968
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-f2f4 d8b6
-d4b3 f6g4
-d1e2 c6d4
-c3d5 d4e2
-d5b6 a7b6
-e1e2 h7h6
-g5h4 g7g5
-h4g3 g5f4
-g3f4 f8g7
-c2c3 d7c6
-! # col. 64j; Liberzo-Stein, USSR Chp. 1969-70. Complete game (draw).
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d3 c6d4
-d3d4 d8a5
-f2f4 e7e5
-d4d3 f8e7
-o-o-o d7c6
-c1b1 e5f4
-g5f4 o-o
-f1e2 f8e8
-e2f3 e7f8
-c3d5 f6d7
-d3d2 a5d2
-d1d2 a8c8
-h1d1 d7e5
-b2b3
-! # col. 65m; Bronstein-Stein, USSR 1969
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d3 c6d4
-d3d4 d8a5
-f1e2 e7e5
-d4d3 a5c7
-e2g4 f8e7
-g5f6 e7f6
-o-o-o f6e7
-c3b5 d7b5
-d3b5 c7c6
-b5d5 c6d5
-d1d5
-! # col. 66b; Benko-R. Byrne, US Open Chp. 1968
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d2 a8c8
-o-o-o c6d4
-d2d4 d8a5
-g5d2 a7a6
-f1c4 a5c5
-d4c5 c8c5
-c4b3 g7g6
-d2e3 c5c8
-e3d4 f8g7
-c3d5 f6h5
-d4g7 h5g7
-e4e5 c8c6
-d5b4 c6b6
-! # col. 66b alternate; Polgar-Nagy, Hungarian Chp. 1972
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d2 a8c8
-o-o-o c6d4
-d2d4 d8a5
-g5d2 e7e5
-d4d3 a7a6
-c1b1 h7h6
-f2f3 a5c7
-g2g3 f8e7
-h2h4 b7b5
-! # col. 67c; Suetin-Gheorghiu, Hastings 1967/8. Draw.
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d2 a8c8
-o-o-o c6d4
-d2d4 d8a5
-g5e3 a7a6
-f2f3 e7e6
-d4b6 a5b6
-e3b6 d7c6
-f1c4 c6e4
-c4e6 f7e6
-c3e4 f6e4
-f3e4 f8e7
-h1f1 e7g5
-c1b1 e8e7
-c2c3 h8f8
-b1c2 f8f1
-d1f1 c8f8
-! # col. 68d
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d2 a8c8
-o-o-o c6d4
-d2d4 d8a5
-f2f4 e7e6
-e4e5 d6e5
-f4e5 c8c3
-g5d2 a5a2
-d2c3 g7g6
-! # col. 69fA1; Janosevic-Larsen, Belgrade 1964
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d2 a8c8
-o-o-o c6d4
-d2d4 d8a5
-f2f4 c8c3
-b2c3 e7e5
-d4b4 a5b4
-c3b4 f6e4
-f1c4 b7b5
-c4d5 e4c3
-f4e5 h7h6
-g5h4 g7g5
-h4g3 c3e2
-c1b2 e2g3
-h2g3 f8g7
-! # col. 70g; Bednarski-Simagin, Polanica Zdroj 1968
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 c8d7
-d1d2 a8c8
-o-o-o c6d4
-d2d4 c8c3
-d4c3 f6e4
-c3e3 e4g5
-e3g5 d8b6
-f1c4 e7e6
-g5g3 g7g6
-c4b3 f8e7
-h2h4 h7h5
-h1e1 b6b4
-g3e3 a7a5
-e3d4
-! # col. 71d
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o c6d4
-d2d4 o-o
-f2f4 h7h6
-g5h4 d8a5
-f1c4 e6e5
-f4e5 d6e5
-d4d3 a5c5
-h4f6 e7f6
-! # col. 72g
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o c6d4
-d2d4 o-o
-f2f4 d8a5
-f1c4 c8d7
-c4b3 d7c6
-h1f1 b7b5
-g5f6 e7f6
-d4d6 f6c3
-d6c6 a8c8
-c6d7 c8d8
-d7e7 c3d2
-c1b1 d2f4
-d1d8 a5d8
-! # col. 73i
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o o-o
-d4b3 d8b6
-f2f3 a7a6
-g2g4 f8d8
-g5e3 b6c7
-h2h4 b7b5
-g4g5 f6d7
-g5g6 f7g6
-h4h5 g6h5
-h1h5 d7f6
-h5g5 c6e5
-d2g2 e7f8
-f3f4 e5c4
-f1c4 b5c4
-b3d4 a8b8
-d1g1 b8b7
-! # col. 74; Tal-Larsen, match 1969
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o o-o
-d4b3 a7a6
-g5f6 g7f6
-f1e2 g8h8
-e2h5 c8d7
-f2f4 b7b5
-c1b1
-! # col. 75k
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o o-o
-d4b5 d8a5
-g5f6 e7f6
-b5d6 f8d8
-f2f4 e6e5
-d2d5 a5c7
-f4f5 c6d4
-d6b5 c7a5
-d5c4 c8f5
-b2b4 a5a6
-! # col. 76b; Spasski-Larsen, Santa Monica 1966
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o o-o
-f2f4 h7h6
-g5h4 e6e5
-d4f5 c8f5
-e4f5 d8a5
-c1b1 a8d8
-h4f6 e7f6
-c3d5 a5d2
-d5f6 g7f6
-d1d2 e5f4
-! # col. 77e; Kujpers-Minev, Halle 1967
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 f8e7
-o-o-o o-o
-f2f4 d6d5
-e4e5 f6d7
-h2h4 d7b6
-d2e3 c8d7
-g5e7 d8e7
-h4h5 c6a5
-d4b3 a5c4
-e3d4 f8c8
-c1b1 a7a5
-f4f5 a5a4
-f5f6 e7f8
-h1h3 c4b2
-b1b2 b6c4
-f1c4 c8c4
-d4d2
-! # col. 78h
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 a7a6
-o-o-o c8d7
-f2f4 h7h6
-g5h4 f6e4
-d2e1 e4f6
-d4f5 d8a5
-f5d6 f8d6
-d1d6 o-o-o
-d6d1 e6e5
-f1c4 e5f4
-c3e4 d7e6
-c4e6 f7e6
-e4d6 c8b8
-e1e6 h8f8
-! # col. 79j; O'Kelly-Simagin corr. 1964
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 a7a6
-o-o-o h7h6
-g5h4 f6e4
-d2f4 e4g5
-d4c6 b7c6
-f4a4 d8b6
-f2f4 g5h7
-f4f5 f8e7
-c3e4 a8b8
-a4a3 b6b5
-! # col. 80k; Di Camillo-R. Byrne, US Open Chp. 1958
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d2 h7h6
-g5f6 g7f6
-o-o-o a7a6
-f2f4 c8d7
-f1e2 h6h5
-c1b1 d8b6
-d4b3 o-o-o
-h1f1 f8e7
-c3a4 b6a7
-c2c4 c6d4
-! # col. 81b
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d4c6 b7c6
-e4e5 d6e5
-d1f3 f8e7
-f3c6 c8d7
-c6f3 e5e4
-c3e4 f6e4
-g5e7 d8a5
-! # col. 82e
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1g5 e7e6
-d1d3 f8e7
-a1d1 o-o
-f1e2 c8d7
-o-o c6d4
-d3d4 d7c6
-g1h1 d8a5
-f2f4 f8e8
-! # col. 83
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-h2h3 g7g6
-c1e3 f8g7
-d1d2 o-o
-o-o-o c6d4
-e3d4 d8a5
-c1b1 e7e5
-d4e3 c8e6
-! # BAD! -- col. 84i; Karaklajic-Taimanov, Yugoslavia-USSR, match 1956
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-c1e3 f6g4
-f1b5 g4e3
-f2e3 c8d7
-o-o e7e6
-5c6 b7c6
-e4e5 f8e7
-d1h5 o-o
-e5d6 e7d6
-c3e4 d6e7
-a1d1 d8c7
-d4b3 h7h6
-! # col. 85
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-d4e2 e7e6
-g2g3 d6d5
-e4d5 f6d5
-f1g2 d5c3
-d1d8 e8d8
-e2c3 c8d7
-c1d2 f8e7
-! # col. 86c; Carcia-Pomar, Havana 1969
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-f1c4 e7e5
-d4e2 c8e6
-c4e6 f7e6
-o-o f8e7
-f2f4 o-o
-e2g3 e5f4
-f1f4 d8b6
-g1h1 a8d8
-b2b3 d6d5
-e4d5 f6d5
-f4f8 e7f8
-c3d5 d8d5
-d1e1 c6d4
-c1e3 f8c5
-! # col. 87
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-f1c4 d8b6
-d4b3 e7e6
-o-o f8e7
-c1e3 b6c7
-f2f4 o-o
-c4d3 a7a6
-d1f3
-! # col. 88
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-f1c4 e7e6
-c1e3 d8c7
-d1e2 a7a6
-c4b3 c6a5
-g2g4 b7b5
-g4g5 f6d7
-o-o-o d7c5
-! # col. 89mA; Spasjevic-Ostojic, Belgrade 1966 (draw)
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-f1c4 e7e6
-c1e3 f8e7
-d1e2 a7a6
-o-o-o o-o
-c4b3 d8c7
-g2g4 c6d4
-d1d4 e6e5
-d4c4 c7d8
-g4g5 f6e8
-h1g1 c8d7
-c3d5 d7b5
-e3b6 d8d7
-e2g4 e7d8
-g4d7 b5d7
-c4c3 d7e6
-b6d8 a8d8
-d5e3 d8d7
-b3a4 d7c7
-! # col. 90o; Bogdanovic-Shamkovich, Sarajevo 1963
-e2e4 c7c5
-g1f3 b8c6
-d2d4 c5d4
-f3d4 g8f6
-b1c3 d7d6
-f1c4 e7e6
-c1e3 f8e7
-d1e2 o-o
-o-o-o c6d4
-e3d4 d8a5
-e4e5 d6e5
-d4e5 b7b6
-c3b5 c8a6
-e5c3 a5a4
-d1d4 a6b5
-c4b5 a4a2
-h1d1 f8d8
-d4a4 d8d1
-e2d1 a2d5
-d1d5 f6d5
-c3d4 e7g5
-c1b1 h7h5
-b5c6 a8d8
-a4a7 d5b4
-c6d7 b4c6
-! # Queen's Catalan, col. 1c; Kramer-Fichtl, Varna Olympics 1962
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 f8e7
-f1g2 o-o
-o-o b8d7
-b1c3 c7c6
-b2b3 b7b6
-c1b2 c8b7
-d1c2 a8c8
-a1d1 d8c7
-e2e4 d5e4
-c3e4 f6e4
-c2e4 c6c5
-d4d5 e7f6
-e4c2 e6d5
-c4d5 f6b2
-c2b2 c8d8
-! # col. 2f
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 f8e7
-f1g2 o-o
-o-o b8d7
-b1c3 d5c4
-e2e4 c7c6
-a2a4 a7a5
-d1e2 d7b6
-f1d1 e7b4
-f3e5 d8e7
-c1e3 c8d7
-e5c4 b6c4
-e2c4 e6e5
-d4e5 f6g4
-! # col. 3i; Geller-Medina, Beverwijk 1965
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 f8e7
-f1g2 o-o
-o-o b8d7
-d1c2 b7b6
-c4d5 f6d5
-b1c3 c8b7
-c3d5 b7d5
-e2e4 d5b7
-f1d1 c7c5
-d4d5 e6d5
-e4d5 e7f6
-h2h4 h7h6
-! # col. 4k; Geller-Bisguier, Bled 1961
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 f8e7
-f1g2 o-o
-o-o b8d7
-d1c2 c7c6
-b2b3 b7b6
-c1b2 c8b7
-b1c3 a8c8
-a1d1 b6b5
-c4c5 b5b4
-c3b1 f6e4
-f3e1 f7f5
-e1d3 a7a5
-d3f4 f8f6
-f2f3 e4g5
-! # col. 5m; Benko-Pachman, Budapest 1948
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 f8e7
-f1g2 o-o
-o-o b8d7
-d1c2 c7c6
-b1d2 b7b6
-e2e4 c8b7
-b2b3 a8c8
-f1d1 d8c7
-c1b2 f8d8
-a1c1 c7b8
-c2b1 a7a5
-f3e5 b8a8
-! # col. 6
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 f8e7
-f1g2 o-o
-o-o c7c6
-b1c3 b7b6
-f3e5 a7a5
-d1c2 c8a6
-f1d1 b6b5
-! # col. 7d; Evans-Poschel, US Jr. Chp. 1947
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 c7c5
-c4d5 f6d5
-f1g2 c5d4
-o-o f8c5
-f3d4 o-o
-a2a3 b8c6
-d4c6 b7c6
-b2b4 c5e7
-c1b2 e7f6
-d1c2 f6b2
-c2b2 a7a5
-! # col. 8g; O'Kelly-Euwe, New York 1951
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 d5c4
-f1g2 c7c5
-o-o b8c6
-d1a4 f6d7
-d4c5 f8c5
-a4c4 o-o
-b1c3 a7a6
-c3e4 c5e7
-c1e3 d7b6
-c4b3 b6d5
-f1d1 d8c7
-! # col. 9
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 d5c4
-f1g2 b7b5
-a2a4 c7c6
-o-o c8b7
-f3e5 d8c8
-b2b3 c4b3
-d1b3 b5b4
-a4a5 f6d7
-! # col. 10l; Keres-Korchnoi, Curacao 1962
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-g1f3 d5c4
-d1a4 b8d7
-f1g2 a7a6
-a4c4 c7c5
-d4c5 f8c5
-o-o b7b5
-c4h4 c8b7
-b1d2 c5e7
-d2b3 a8c8
-h4d4 o-o
-c1d2 d7c5
-! # col. -- Accelerated Catalan
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 d5c4
-d1a4 b8d7
-b1d2 c7c6
-a4c4 e6e5
-g1f3 d7b6
-c4d3 e5d4
-f3d4 f8e7
-o-o o-o
-! # col. 12e; Muller-Ratzek, Vienna 1951
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 d5c4
-d1a4 c8d7
-a4c4 d7c6
-g1f3 c6d5
-c4d3 c7c5
-b1c3 d5c6
-o-o b8d7
-f1d1 d8b6
-e2e4 c5d4
-f3d4 f8c5
-d4c6 c5f2
-g1f1 b7c6
-c3a4 b6a5
-f1f2 a5a4
-d3d6
-! # col. 13f; Smyslov-Kere, USSR Chp. 1948
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 d5c4
-d1a4 c8d7
-a4c4 d7c6
-g1f3 b8d7
-b1c3 d7b6
-c4d3 f8b4
-o-o o-o
-f1d1 h7h6
-c1d2 d8e7
-a2a3 b4c3
-d3c3 f8d8
-! # col. 14g
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-b1c3 d5c4
-d1a4 b8c6
-f1g2 c8d7
-a4c4 c6b4
-c4b3 c7c5
-g1f3 c5d4
-f3d4 e6e5
-d4f3 d7e6
-b3a4 e6d7
-! # col. 15; Stoltz-Vidmar, Groningen 1946
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-b1c3 f8e7
-f1g2 o-o
-g1f3 d5c4
-d1a4 a7a6
-a4c4 b7b5
-c4d3 c8b7
-! # col. 16
-d2d4 d7d5
-c2c4 e7e6
-g2g3 g8f6
-b1d2 c7c5
-d4c5 f8c5
-f1g2 b8c6
-g1f3 o-o
-o-o a7a5
-c4d5 e6d5
-d2b3 c5b6
-! # col. 17d; Mikenas-Aronin, USSR Chp. 1963
-d2d4 d7d5
-c2c4 e7e6
-g2g3 c7c5
-c4d5 e6d5
-g1f3 b8c6
-f1g2 g8f6
-o-o f8e7
-d4c5 e7c5
-b1d2 o-o
-d2b3 c5b6
-b3d4 f8e8
-b2b3 c6d4
-f3d4 b6d4
-d1d4 e8e2
-! # col. 18e
-d2d4 d7d5
-c2c4 e7e6
-g2g3 d5c4
-d1a4 c8d7
-a4c4 c7c5
-d4c5 d7c6
-g1f3 b8d7
-c1e3 g8f6
-f1g2 d8c7
-o-o c6d5
-c4a4 f8c5
-e3c5 c7c5
-b1c3 d5c6
-! # col. 19
-d2d4 d7d5
-c2c4 e7e6
-g2g3 f8b4
-c1d2 b4d2
-d1d2 g8f6
-g1f3 o-o
-f1g2 d8e7
-o-o b8c6
-f1c1
-! # col. 20
-d2d4 d7d5
-c2c4 e7e6
-g2g3 f8b4
-c1d2 b4e7
-f1g2 g8f6
-g1f3 o-o
-d1b3 b7b6
-c4d5 e6d5
-b1c3 c8b7
-o-o
-! # col. 21
-d2d4 g8f6
-c2c4 e7e6
-g2g3 e6e5
-g1f3 e5d4
-f3d4 d7d5
-f1g2 d5c4
-d1a4 c7c6
-a4c4 f8e7
-o-o o-o
-f1d1
-! # col. 22
-d2d4 g8f6
-c2c4 e7e6
-g2g3 c7c5
-g1f3 c5d4
-f3d4 d7d5
-f1g2 e6e5
-d4f3 d5d4
-o-o b8c6
-e2e3 f8e7
-e3d4 e5d4
-! # col. 23g
-d2d4 g8f6
-c2c4 e7e6
-g2g3 c7c5
-g1f3 c5d4
-f3d4 b8c6
-f1g2 d8b6
-d4c2 f8c5
-e2e3 o-o
-b1c3 b6a6
-d1d2 f8d8
-a2a3 d7d5
-b2b4 d5d4
-c3e4
-! # col. 24j; Smyslov-Petrosian, Moscow 1967
-d2d4 g8f6
-c2c4 e7e6
-g2g3 f8b4
-b1d2 c7c5
-d4c5 b4c5
-f1g2 b8c6
-g1f3 b7b6
-o-o c8b7
-a2a3 o-o
-b2b4 c5e7
-c1b2 a8c8
-d1b1
-! # col. 25
-d2d4 g8f6
-c2c4 e7e6
-g2g3 f8b4
-c1d2 b4d2
-d1d2 f6e4
-d2c2 f7f5
-f2f3 e4f6
-e2e4 f5e4
-f3e4 e6e5
-! # Alternate openings leading to the Catalan, line C
-g1f3 d7d5
-c2c4 e7e6
-g2g3 g8f6
-d2d4
-! # line D
-c2c4 g8f6
-d2d4 e7e6
-g2g3 d7d5
-! # line E
-d2d4 g8f6
-c2c4 e7e6
-g2g3 d7d5
-! # The Reti Opening, col. 1c; Muller-Lilenthal, Budapest 1933
-g1f3 d7d5
-c2c4 c7c6
-b2b3 g8f6
-g2g3 c8f5
-c1b2 e7e6
-f1g2 b8d7
-o-o f8d6
-d2d3 o-o
-b1c3 d8e7
-f1e1 e6e5
-c4d5 c6d5
-e2e4 d5e4
-d3e4 f5g6
-! # col. 2g; Bilek-Geller, Sousse 1967
-g1f3 d7d5
-c2c4 c7c6
-b2b3 g8f6
-g2g3 c8g4
-f1g2 e7e6
-c1b2 b8d7
-o-o f8e7
-d2d3 o-o
-b1d2 a7a5
-a2a3 d8b6
-d1c2 h7h6
-b2c3 f8c8
-f1e1 b6d8
-e2e4 d8f8
-! # col. 3k; Botvinnik-Fine, Nottingham 1936
-g1f3 d7d5
-c2c4 d5c4
-b1a3 c7c5
-a3c4 b8c6
-g2g3 e7e5
-f1g2 f7f6
-b2b3 g8e7
-c1b2 e7d5
-o-o f8e7
-f3h4 o-o
-d1b1 f8f7
-h4f5 c8e6
-f2f4 e5f4
-g3f4 d5b6
-g2e4 e6c4
-! # col. 4n; Katetov-Alekhin, Prague 1943
-g1f3 d7d5
-c2c4 d5d4
-e2e3 b8c6
-e3d4 c6d4
-f3d4 d8d4
-b1c3 e7e5
-d2d3 f8c5
-c1e3 d4d6
-c3b5 d6e7
-e3c5 e7c5
-d3d4 e5d4
-d1d4 c5d4
-b5d4 c8g4
-! # col. 5o
-g1f3 d7d5
-c2c4 d5d4
-e2e3 c7c5
-e3d4 c5d4
-g2g3 b8c6
-f1g2 g7g6
-d2d3 f8g7
-o-o e7e5
-f1e1 f7f6
-b2b4 c6b4
-d1a4 b4c6
-f3d4 d8d4
-g2c6 c8d7
-! # col. 6
-g1f3 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 f8e7
-o-o o-o
-b2b3 c7c5
-c4d5 f6d5
-c1b2 b8c6
-d2d4 d5b4
-a2a3 b4a6
-d4c5 d8d1
-! # col. 7
-g1f3 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 f8e7
-b1c3 o-o
-b2b3 c7c5
-c1b2 b8c6
-c4d5 e6d5
-a1c1 c8e6
-o-o a8c8
-d2d4 f8e8
-! # col. 8g; Kashdan-Horowitz, New York 1931
-g1f3 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 b8d7
-b2b3 c7c6
-o-o f8d6
-c1b2 o-o
-b1c3 b7b6
-d2d3 c8b7
-e2e4 d5e4
-d3e4 d8c7
-d1e2 f8d8
-f1d1
-! # col. 9h; Abroshin-Krykov corr. 1960
-g1f3 d7d5
-c2c4 e7e6
-g2g3 g8f6
-f1g2 d5c4
-d1a4 c8d7
-a4c4 d7c6
-o-o c6d5
-c4a4 d8d7
-a4c2 b8c6
-b1c3 d5f3
-g2f3 c6d4
-c2d3 c7c6
-! # col. 10m; Teti-Tartakover, Semmering 1926
-g1f3 d7d5
-c2c4 e7e6
-g2g3 d5c4
-d1a4 c8d7
-a4c4 c7c5
-f3e5 b8c6
-e5d7 d8d7
-f1g2 g8f6
-d2d3 f8e7
-o-o c6d4
-b1c3 a8d8
-a2a4 f6d5
-! # Barcza System, col. 11
-g1f3 d7d5
-g2g3 g8f6
-f1g2 c8f5
-o-o c7c6
-c2c4 d5c4
-b1a3 e7e5
-a3c4 e5e4
-f3e1 f8c5
-d2d3 o-o
-c1e3 b8d7
-! # col. 12d; Benko-Petrosian, Curacao 1962
-g1f3 d7d5
-g2g3 g8f6
-f1g2 c8f5
-o-o c7c6
-d2d3 b8d7
-b1d2 h7h6
-d1e1 e7e6
-e2e4 f5h7
-e1e2 f8e7
-e4e5 f6g8
-d2b3 e7f8
-c2c4 g8e7
-b3d4 e7f5
-d4f5 h7f5
-c4d5 c6d5
-d3d4 a7a5
-c1e3 f8e7
-f1c1 o-o
-! # col. 13f; Bronstein-O'Kelly, Beverwijk 1963
-g1f3 d7d5
-g2g3 g8f6
-f1g2 c7c5
-o-o e7e6
-d2d3 b8c6
-b1d2 f8e7
-e2e4 o-o
-f1e1 d8c7
-e4e5 f6d7
-d1e2 b7b5
-h2h4 a7a5
-d2f1 c8a6
-f1h2 c6b4
-h4h5
-! # col. 14i; Evans-Olafsson, Dallas 1957
-g1f3 d7d5
-g2g3 g8f6
-f1g2 g7g6
-o-o f8g7
-d2d3 o-o
-b1d2 b8c6
-e2e4 e7e5
-c2c3 a7a5
-f1e1 d5e4
-d3e4 f6d7
-d1e2 b7b6
-d2c4 c8a6
-g2f1 d8f6
-! # col. 15
-g1f3 d7d5
-g2g3 g8f6
-f1g2 g7g6
-d2d4 f8g7
-o-o c7c6
-b2b3 b8d7
-c1b2 e7e5
-d4e5 f6g4
-b1d2 d7e5
-f3e5 g4e5
-! # col. 16d; Larsen-Mecking, Mallorca 1969
-g1f3 d7d5
-g2g3 c7c5
-f1g2 b8c6
-o-o e7e6
-d2d3 g7g6
-b1c3 f8g7
-a2a3 g8e7
-a1b1 o-o
-c1d2 a8b8
-b2b4 c5b4
-a3b4 b7b5
-e2e4 a7a5
-! # col. 17h; Benko-Bisguier, US Chp. 1963
-g1f3 d7d5
-g2g3 c8g4
-f1g2 b8d7
-c2c4 c7c6
-c4d5 c6d5
-b1c3 e7e6
-d1b3 d8b6
-b3b6 d7b6
-d2d3 a8c8
-c1e3 f8d6
-c3b5 d6b8
-o-o g8e7
-f1c1 c8c1
-a1c1 e7c6
-f3d4 e8d7
-! # col. 18j; Keene-Basman, Hastings 1966-7
-g1f3 d7d5
-g2g3 c8g4
-f1g2 g8f6
-c2c4 c7c6
-c4d5 g4f3
-g2f3 c6d5
-d1b3 d8d7
-b1c3 e7e6
-o-o b8c6
-f3g2 f8e7
-d2d3 o-o
-! # col. 19k
-g1f3 d7d5
-g2g3 c8g4
-f1g2 g8f6
-c2c4 c7c6
-d1c2 e7e6
-o-o f8e7
-b2b3 b8d7
-c1b2 o-o
-d2d3 a7a5
-b1d2 a5a4
-b2c3 a4b3
-a2b3 d8b6
-! # col. 20m
-g1f3 d7d5
-g2g3 c8g4
-f1g2 g8f6
-o-o c7c6
-c2c4 e7e6
-c4d5 g4f3
-g2f3 c6d5
-b1c3 b8c6
-d2d3 f8e7
-f3g2
-! # col. 21b; Savon-Aronin, USSR 1963
-g1f3 d7d5
-g2g3 b8c6
-d2d4 c8f5
-f1g2 c6b4
-b1a3 e7e6
-o-o g8f6
-f3h4 f5g4
-c2c4 c7c6
-a3c2 b4c2
-d1c2 f8e7
-h2h3 g4h5
-f2f3 h5g6
-h4g6 h7g6
-! # col. 22d; Fischer-Ivkov, Santa Monica 1966
-g1f3 d7d5
-g2g3 e7e6
-f1g2 c7c5
-o-o b8c6
-d2d3 f8d6
-e2e4 g8e7
-b1d2 o-o
-f3h4 b7b6
-f2f4 d5e4
-d3e4 c8a6
-f1e1 c5c4
-c2c3
-! # col. 23
-g1f3 d7d5
-g2g3 b8d7
-c2c4 e7e6
-f1g2 g8f6
-b1c3 f8e7
-o-o o-o
-d2d3 c7c5
-c4d5 e6d5
-c1g5 b7b6
-! # col. 24g; Benko-Bisguier, US Chp. 1976-7
-g1f3 d7d5
-g2g3 g8f6
-f1g2 b7b6
-c2c4 e7e6
-c4d5 e6d5
-o-o f8d6
-d2d4 o-o
-b1c3 c7c6
-f3e5 c8b7
-c1g5 h7h6
-g5f6 d8f6
-f2f4 f8d8
-e2e4
-! # col. 25; Rabinovich-Rauser, Moscow 1934
-g1f3 d7d5
-b2b3 c8g4
-c1b2 b8d7
-c2c4 e7e6
-e2e3 g8f6
-f1e2 c7c6
-f3d4 g4e2
-d1e2 f8d6
-f2f4 o-o
-! # col. 26e; Evans-Najdorf, Dallas 1967
-g1f3 c7c5
-g2g3 b8c6
-f1g2 g7g6
-o-o f8g7
-e2e4 d7d6
-c2c3 e7e5
-d2d3 g8h6
-f3e1 o-o
-f2f4 e5f4
-c1f4 h6g4
-b1a3 g4e5
-g1h1 d8b6
-d1d2 c8e6
-! # col. 27h; Van den Pol-Barden, Holland v. England 1960
-g1f3 f7f5
-g2g3 g8f6
-f1g2 g7g6
-d2d3 f8g7
-b1d2 d7d6
-e2e4 e7e5
-d2c4 o-o
-e4f5 g6f5
-c1e3 b8c6
-d3d4 e5e4
-! # col. 28m; Gufeld-Bokuchava, USSR Chp. prelims 1968
-g1f3 f7f5
-g2g3 g8f6
-f1g2 e7e6
-c2c4 f8e7
-o-o o-o
-d2d3 d7d6
-b1c3 b8c6
-a1b1 a7a5
-a2a3 d8e8
-b2b4 a5b4
-a3b4 e6e5
-! # col. 29p; Lundin-Tartakover, Groningen 1946
-g1f3 f7f5
-g2g3 g8f6
-f1g2 e7e6
-c2c4 f8e7
-o-o o-o
-b2b3 c7c5
-c1b2 b8c6
-b1c3 e6e5
-e2e3 d7d6
-d2d4
-! # col. 30
-g1f3 g7g6
-g2g3 f8g7
-f1g2 e7e5
-d2d3 b8c6
-e2e4 d7d6
-b1c3 g8e7
-c1e3 o-o
-d1d2 c6d4
-o-o
-! # King's Indian attack, col. 31a
-g1f3 g8f6
-g2g3 b7b5
-h2h4 b5b4
-d2d3 c8b7
-e2e4 d7d6
-f1g2 b8d7
-o-o e7e6
-h4h5 a8b8
-b1d2 f8e7
-d2c4 o-o
-! # col. 32d
-g1f3 g8f6
-g2g3 g7g6
-b2b4 f8g7
-c1b2 o-o
-f1g2 d7d5
-o-o c8g4
-c2c4 c7c6
-b1a3 b8d7
-a1c1 a7a5
-b4b5 a5a4
-d2d3 e7e5
-! # col. 33e; Olafsson-Kavalek, Wijik aan Zee 1969
-g1f3 g8f6
-g2g3 g7g6
-b2b3 f8g7
-c1b2 o-o
-f1g2 d7d6
-d2d4 f6d7
-b1c3 e7e5
-d1d2 f8e8
-d4e5 d7e5
-f3e5 g7e5
-! # col. 34h
-g1f3 g8f6
-g2g3 g7g6
-c2c4 d7d6
-f1g2 f8g7
-o-o o-o
-b1c3 b8d7
-d2d3 e7e5
-c1d2 d7c5
-b2b4 c5e6
-a1b1 f6e8
-a2a4 c7c6
-a4a5 e8c7
-! # col. 35
-g1f3 g8f6
-c2c4 g7g6
-b2b3 f8g7
-c1b2 o-o
-e2e3 d7d6
-f1e2 e7e5
-o-o f8e8
-b1c3 b8d7
-d2d3 c7c6
-! # col. 36d
-g1f3 g8f6
-c2c4 g7g6
-b1c3 d7d5
-c4d5 f6d5
-d1a4 c8d7
-a4b3 d5b6
-d2d4 f8g7
-c1f4 d7e6
-b3c2 b8c6
-a1d1
-! # col. 37f
-g1f3 g8f6
-c2c4 b7b6
-g2g3 c8b7
-f1g2 c7c5
-o-o g7g6
-b2b3 f8g7
-c1b2 o-o
-b1c3 d7d5
-c3d5 f6d5
-b2g7 g8g7
-c4d5 d8d5
-d2d4 b8a6
-! # col. 38h; Geller-Kholmov, Moscow 1969
-g1f3 g8f6
-c2c4 b7b6
-g2g3 c8b7
-f1g2 e7e6
-o-o f8e7
-b2b3 o-o
-c1b2 d7d5
-e2e3 b8d7
-b1c3 f6e4
-c4d5 e4c3
-b2c3 e6d5
-! # col. 39
-g1f3 g8f6
-b2b3 g7g6
-c2c4 f8g7
-c1b2 o-o
-g2g3 c7c5
-f1g2 b7b6
-o-o c8b7
-b1c3 e7e6
-a1b1 d8e7
-! # col. 40o; Lombardy-Burger, US Chp. 1969-70
-g1f3 g8f6
-b2b3 d7d5
-c1b2 e7e6
-e2e3 f8e7
-c2c4 o-o
-d2d4 b7b6
-f1d3 c8b7
-o-o b8d7
-b1d2 c7c5
-d1e2 f6e4
-a1c1 a8c8
-!
diff --git a/gnu/games/chess/gnuchess.c b/gnu/games/chess/gnuchess.c
deleted file mode 100644
index ac62953..0000000
--- a/gnu/games/chess/gnuchess.c
+++ /dev/null
@@ -1,2307 +0,0 @@
-/*
- C source for CHESS
-
- Revision: 4-25-88
-
- Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
- Copyright (c) 1988 John Stanback
-
- This file is part of CHESS.
-
- CHESS 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 CHESS General Public
- License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- CHESS, but only under the conditions described in the
- CHESS General Public License. A copy of this license is
- supposed to have been given to you along with CHESS 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.
-*/
-
-
-#include <stdio.h>
-#include <ctype.h>
-
-#ifdef MSDOS
-#include <stdlib.h>
-#include <time.h>
-#include <alloc.h>
-#define ttblsz 4096
-#else
-#include <sys/param.h>
-#include <sys/times.h>
-#define ttblsz 16384
-#define huge
-#endif MSDOS
-
-#include "move.h"
-
-#define neutral 2
-#define white 0
-#define black 1
-#define no_piece 0
-#define pawn 1
-#define knight 2
-#define bishop 3
-#define rook 4
-#define queen 5
-#define king 6
-#define valueP 100
-#define valueN 350
-#define valueB 355
-#define valueR 550
-#define valueQ 1100
-#define valueK 1200
-#define ctlP 0x4000
-#define ctlN 0x2800
-#define ctlB 0x1800
-#define ctlR 0x0400
-#define ctlQ 0x0200
-#define ctlK 0x0100
-#define ctlBQ 0x1200
-#define ctlRQ 0x0600
-#define ctlNN 0x2000
-#define pxx " PNBRQK"
-#define qxx " pnbrqk"
-#define rxx "12345678"
-#define cxx "abcdefgh"
-#define check 0x0001
-#define capture 0x0002
-#define draw 0x0004
-#define promote 0x0008
-#define cstlmask 0x0010
-#define epmask 0x0020
-#define exact 0x0040
-#define pwnthrt 0x0080
-#define truescore 0x0001
-#define lowerbound 0x0002
-#define upperbound 0x0004
-#define maxdepth 30
-#define true 1
-#define false 0
-#define absv(x) ((x) < 0 ? -(x) : (x))
-#if (NEWMOVE < 1)
-#define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b]))
-#endif
-struct leaf
- {
- short f,t,score,reply;
- unsigned short flags;
- };
-struct GameRec
- {
- unsigned short gmove;
- short score,depth,time,piece,color;
- long nodes;
- };
-struct TimeControlRec
- {
- short moves[2];
- long clock[2];
- };
-struct BookEntry
- {
- struct BookEntry *next;
- unsigned short *mv;
- };
-struct hashval
- {
- unsigned long bd;
- unsigned short key;
- };
-struct hashentry
- {
- unsigned long hashbd;
- unsigned short mv,flags;
- short score,depth;
- };
-
-char mvstr1[5],mvstr2[5];
-struct leaf Tree[2000],*root;
-short TrPnt[maxdepth],board[64],color[64];
-short row[64],column[64],locn[8][8],Pindex[64],svalue[64];
-short PieceList[2][16],PieceCnt[2],atak[2][64],PawnCnt[2][8];
-short castld[2],kingmoved[2],mtl[2],pmtl[2],emtl[2],hung[2];
-short c1,c2,*atk1,*atk2,*PC1,*PC2,EnemyKing;
-short mate,post,opponent,computer,Sdepth,Awindow,Bwindow,dither;
-long ResponseTime,ExtraTime,Level,et,et0,time0,cputimer,ft;
-long NodeCnt,evrate,ETnodes,EvalNodes,HashCnt;
-short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beep;
-short wking,bking,FROMsquare,TOsquare,timeout,Zscore,zwndw,xwndw,slk;
-short INCscore;
-short HasPawn[2],HasKnight[2],HasBishop[2],HasRook[2],HasQueen[2];
-short ChkFlag[maxdepth],CptrFlag[maxdepth],PawnThreat[maxdepth];
-short Pscore[maxdepth],Tscore[maxdepth],Threat[maxdepth];
-struct GameRec GameList[240];
-short GameCnt,Game50,epsquare,lpost,rcptr,contempt;
-short MaxSearchDepth;
-struct BookEntry *Book;
-struct TimeControlRec TimeControl;
-short TCflag,TCmoves,TCminutes,OperatorTime;
-short otherside[3]={1,0,2};
-short rank7[3]={6,1,0};
-short map[64]=
- {0,1,2,3,4,5,6,7,
- 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
- 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
- 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,
- 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,
- 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,
- 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,
- 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77};
-short unmap[120]=
- {0,1,2,3,4,5,6,7,-1,-1,-1,-1,-1,-1,-1,-1,
- 8,9,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,
- 16,17,18,19,20,21,22,23,-1,-1,-1,-1,-1,-1,-1,-1,
- 24,25,26,27,28,29,30,31,-1,-1,-1,-1,-1,-1,-1,-1,
- 32,33,34,35,36,37,38,39,-1,-1,-1,-1,-1,-1,-1,-1,
- 40,41,42,43,44,45,46,47,-1,-1,-1,-1,-1,-1,-1,-1,
- 48,49,50,51,52,53,54,55,-1,-1,-1,-1,-1,-1,-1,-1,
- 56,57,58,59,60,61,62,63};
-short Dcode[120]=
- {0,1,1,1,1,1,1,1,0,0,0,0,0,0,0x0E,0x0F,
- 0x10,0x11,0x12,0,0,0,0,0,0,0,0,0,0,0,0x0F,0x1F,
- 0x10,0x21,0x11,0,0,0,0,0,0,0,0,0,0,0x0F,0,0,
- 0x10,0,0,0x11,0,0,0,0,0,0,0,0,0x0F,0,0,0,
- 0x10,0,0,0,0x11,0,0,0,0,0,0,0x0F,0,0,0,0,
- 0x10,0,0,0,0,0x11,0,0,0,0,0x0F,0,0,0,0,0,
- 0x10,0,0,0,0,0,0x11,0,0,0x0F,0,0,0,0,0,0,
- 0x10,0,0,0,0,0,0,0x11};
-short Stboard[64]=
- {rook,knight,bishop,queen,king,bishop,knight,rook,
- pawn,pawn,pawn,pawn,pawn,pawn,pawn,pawn,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- pawn,pawn,pawn,pawn,pawn,pawn,pawn,pawn,
- rook,knight,bishop,queen,king,bishop,knight,rook};
-short Stcolor[64]=
- {white,white,white,white,white,white,white,white,
- white,white,white,white,white,white,white,white,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- black,black,black,black,black,black,black,black,
- black,black,black,black,black,black,black,black};
-short sweep[7]= {false,false,false,true,true,true,false};
-short Dpwn[3]={4,6,0};
-short Dstart[7]={6,4,8,4,0,0,0};
-short Dstop[7]={7,5,15,7,3,7,7};
-short Dir[16]={1,0x10,-1,-0x10,0x0F,0x11,-0x0F,-0x11,
- 0x0E,-0x0E,0x12,-0x12,0x1F,-0x1F,0x21,-0x21};
-short Pdir[34]={0,0x38,0,0,0,0,0,0,0,0,0,0,0,0,0x02,0x35,
- 0x38,0x35,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0x02,
- 0,0x02};
-short pbit[7]={0,0x01,0x02,0x04,0x08,0x10,0x20};
-unsigned short killr0[maxdepth],killr1[maxdepth],killr2[maxdepth];
-unsigned short killr3[maxdepth],PrVar[maxdepth];
-unsigned short PV,hint,Swag0,Swag1,Swag2,Swag3,Swag4;
-unsigned short hashkey;
-unsigned long hashbd;
-struct hashval hashcode[2][7][64];
-struct hashentry huge *ttable,*ptbl;
-unsigned char history[8192];
-
-short Mwpawn[64],Mbpawn[64],Mknight[2][64],Mbishop[2][64];
-short Mking[2][64],Kfield[2][64];
-short value[7]={0,valueP,valueN,valueB,valueR,valueQ,valueK};
-short control[7]={0,ctlP,ctlN,ctlB,ctlR,ctlQ,ctlK};
-short PassedPawn0[8]={0,60,80,120,200,360,600,800};
-short PassedPawn1[8]={0,30,40,60,100,180,300,800};
-short PassedPawn2[8]={0,15,25,35,50,90,140,800};
-short PassedPawn3[8]={0,5,10,15,20,30,140,800};
-short ISOLANI[8] = {-12,-16,-20,-24,-24,-20,-16,-12};
-short BACKWARD[8] = {-6,-10,-15,-21,-28,-28,-28,-28};
-short BMBLTY[14] = {-2,0,2,4,6,8,10,12,13,14,15,16,16,16};
-short RMBLTY[14] = {0,2,4,6,8,10,11,12,13,14,14,14,14,14};
-short Kthreat[16] = {0,-8,-20,-36,-52,-68,-80,-80,-80,-80,-80,-80,
- -80,-80,-80,-80};
-short KNIGHTPOST,KNIGHTSTRONG,BISHOPSTRONG,KATAK,KBNKsq;
-short PEDRNK2B,PWEAKH,PADVNCM,PADVNCI,PAWNSHIELD,PDOUBLED,PBLOK;
-short RHOPN,RHOPNX,KHOPN,KHOPNX,KSFTY;
-short ATAKD,HUNGP,HUNGX,KCASTLD,KMOVD,XRAY,PINVAL;
-short stage,stage2,Zwmtl,Zbmtl,Developed[2],PawnStorm;
-short PawnBonus,BishopBonus,RookBonus;
-short KingOpening[64]=
- { 0, 0, -4,-10,-10, -4, 0, 0,
- -4, -4, -8,-12,-12, -8, -4, -4,
- -12,-16,-20,-20,-20,-20,-16,-12,
- -16,-20,-24,-24,-24,-24,-20,-16,
- -16,-20,-24,-24,-24,-24,-20,-16,
- -12,-16,-20,-20,-20,-20,-16,-12,
- -4, -4, -8,-12,-12, -8, -4, -4,
- 0, 0, -4,-10,-10, -4, 0, 0};
-short KingEnding[64]=
- { 0, 6,12,18,18,12, 6, 0,
- 6,12,18,24,24,18,12, 6,
- 12,18,24,30,30,24,18,12,
- 18,24,30,36,36,30,24,18,
- 18,24,30,36,36,30,24,18,
- 12,18,24,30,30,24,18,12,
- 6,12,18,24,24,18,12, 6,
- 0, 6,12,18,18,12, 6, 0};
-short DyingKing[64]=
- { 0, 8,16,24,24,16, 8, 0,
- 8,32,40,48,48,40,32, 8,
- 16,40,56,64,64,56,40,16,
- 24,48,64,72,72,64,48,24,
- 24,48,64,72,72,64,48,24,
- 16,40,56,64,64,56,40,16,
- 8,32,40,48,48,40,32, 8,
- 0, 8,16,24,24,16, 8, 0};
-short KBNK[64]=
- {99,90,80,70,60,50,40,40,
- 90,80,60,50,40,30,20,40,
- 80,60,40,30,20,10,30,50,
- 70,50,30,10, 0,20,40,60,
- 60,40,20, 0,10,30,50,70,
- 50,30,10,20,30,40,60,80,
- 40,20,30,40,50,60,80,90,
- 40,40,50,60,70,80,90,99};
-short pknight[64]=
- { 0, 4, 8,10,10, 8, 4, 0,
- 4, 8,16,20,20,16, 8, 4,
- 8,16,24,28,28,24,16, 8,
- 10,20,28,32,32,28,20,10,
- 10,20,28,32,32,28,20,10,
- 8,16,24,28,28,24,16, 8,
- 4, 8,16,20,20,16, 8, 4,
- 0, 4, 8,10,10, 8, 4, 0};
-short pbishop[64]=
- {14,14,14,14,14,14,14,14,
- 14,22,18,18,18,18,22,14,
- 14,18,22,22,22,22,18,14,
- 14,18,22,22,22,22,18,14,
- 14,18,22,22,22,22,18,14,
- 14,18,22,22,22,22,18,14,
- 14,22,18,18,18,18,22,14,
- 14,14,14,14,14,14,14,14};
-short PawnAdvance[64]=
- { 0, 0, 0, 0, 0, 0, 0, 0,
- 4, 4, 4, 0, 0, 4, 4, 4,
- 6, 8, 2,10,10, 2, 8, 6,
- 6, 8,12,16,16,12, 8, 6,
- 8,12,16,24,24,16,12, 8,
- 12,16,24,32,32,24,16,12,
- 12,16,24,32,32,24,16,12,
- 0, 0, 0, 0, 0, 0, 0, 0};
-
-
-main(argc,argv)
-int argc; char *argv[];
-{
-#ifdef MSDOS
- ttable = (struct hashentry huge *)farmalloc(ttblsz *
- (unsigned long)sizeof(struct hashentry));
-#else
- ttable = (struct hashentry *)malloc(ttblsz *
- (unsigned long)sizeof(struct hashentry));
-#endif
- Level = 0; TCflag = false; OperatorTime = 0;
- if (argc == 2) Level = atoi(argv[1]);
- if (argc == 3)
- {
- TCmoves = atoi(argv[1]); TCminutes = atoi(argv[2]); TCflag = true;
- }
- Initialize();
- NewGame();
-#if (NEWMOVE > 0)
- Initialize_dist();
-#if (NEWMOVE > 1)
- Initialize_moves();
-#endif
-#endif
- while (!(quit))
- {
- if (bothsides && !mate) SelectMove(opponent,1); else InputCommand();
- if (!(quit || mate || force)) SelectMove(computer,1);
- }
- ExitChess();
-}
-
-
-
-/* ............ INTERFACE ROUTINES ........................... */
-
-int VerifyMove(s,iop,mv)
-char s[];
-short iop;
-unsigned short *mv;
-
-/*
- Compare the string 's' to the list of legal moves available for the
- opponent. If a match is found, make the move on the board.
-*/
-
-{
-static short pnt,tempb,tempc,tempsf,tempst,cnt;
-static struct leaf xnode;
-struct leaf *node;
-
- *mv = 0;
- if (iop == 2)
- {
- UnmakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst);
- return(false);
- }
- cnt = 0;
- MoveList(opponent,2);
- pnt = TrPnt[2];
- while (pnt < TrPnt[3])
- {
- node = &Tree[pnt++];
- algbr(node->f,node->t,(short) node->flags & cstlmask);
- if (strcmp(s,mvstr1) == 0 || strcmp(s,mvstr2) == 0)
- {
- cnt++; xnode = *node;
- }
- }
- if (cnt == 1)
- {
- MakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst);
- if (SqAtakd(PieceList[opponent][0],computer))
- {
- UnmakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst);
- ShowMessage("Illegal Move!!");
- return(false);
- }
- else
- {
- if (iop == 1) return(true);
- if (xnode.flags & epmask) UpdateDisplay(0,0,1,0);
- else UpdateDisplay(xnode.f,xnode.t,0,xnode.flags & cstlmask);
- if (xnode.flags & cstlmask) Game50 = GameCnt;
- else if (board[xnode.t] == pawn || (xnode.flags & capture))
- Game50 = GameCnt;
- GameList[GameCnt].depth = GameList[GameCnt].score = 0;
- GameList[GameCnt].nodes = 0;
- ElapsedTime(1);
- GameList[GameCnt].time = (short)et;
- TimeControl.clock[opponent] -= et;
- --TimeControl.moves[opponent];
- *mv = (xnode.f << 8) + xnode.t;
- algbr(xnode.f,xnode.t,false);
- return(true);
- }
- }
- if (cnt > 1) ShowMessage("Ambiguous Move!");
- return(false);
-}
-
-
-NewGame()
-
-/*
- Reset the board and other variables to start a new game.
-*/
-
-{
-short l,r,c,p;
-
- mate = quit = reverse = bothsides = post = false;
- hashflag = force = PawnStorm = false;
- beep = rcptr = easy = true;
- lpost = NodeCnt = epsquare = et0 = 0;
- dither = 0;
- Awindow = 90;
- Bwindow = 90;
- xwndw = 90;
- MaxSearchDepth = 29;
- contempt = 0;
- GameCnt = -1; Game50 = 0;
- Zwmtl = Zbmtl = 0;
- Developed[white] = Developed[black] = false;
- castld[white] = castld[black] = false;
- kingmoved[white] = kingmoved[black] = 0;
- PawnThreat[0] = CptrFlag[0] = Threat[0] = false;
- Pscore[0] = 12000; Tscore[0] = 12000;
- opponent = white; computer = black;
- for (r = 0; r < 8; r++)
- for (c = 0; c < 8; c++)
- {
- l = 8*r+c; locn[r][c] = l;
- row[l] = r; column[l] = c;
- board[l] = Stboard[l]; color[l] = Stcolor[l];
- }
- for (c = white; c <= black; c++)
- for (p = pawn; p <= king; p++)
- for (l = 0; l < 64; l++)
- {
- hashcode[c][p][l].key = (unsigned short)rand();
- hashcode[c][p][l].bd = ((unsigned long)rand() << 16) +
- (unsigned long)rand();
- }
- ClrScreen();
- if (TCflag) SetTimeControl();
- else if (Level == 0) SelectLevel();
- UpdateDisplay(0,0,1,0);
- InitializeStats();
- time0 = time((long *)0);
- ElapsedTime(1);
- GetOpenings();
-}
-
-
-algbr(f,t,iscastle)
-short f,t,iscastle;
-{
- mvstr1[0] = cxx[column[f]]; mvstr1[1] = rxx[row[f]];
- mvstr1[2] = cxx[column[t]]; mvstr1[3] = rxx[row[t]];
- mvstr2[0] = qxx[board[f]];
- mvstr2[1] = mvstr1[2]; mvstr2[2] = mvstr1[3];
- mvstr1[4] = '\0'; mvstr2[3] = '\0';
- if (iscastle)
- if (t > f) strcpy(mvstr2,"o-o");
- else strcpy(mvstr2,"o-o-o");
-}
-
-
-/* ............ MOVE GENERATION & SEARCH ROUTINES .............. */
-
-SelectMove(side,iop)
-short side,iop;
-
-/*
- Select a move by calling function search() at progressively deeper
- ply until time is up or a mate or draw is reached. An alpha-beta
- window of -90 to +90 points is set around the score returned from the
- previous iteration. If Sdepth != 0 then the program has correctly
- predicted the opponents move and the search will start at a depth of
- Sdepth+1 rather than a depth of 1.
-*/
-
-{
-static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
-
- timeout = false;
- xside = otherside[side];
- if (iop != 2) player = side;
- if (TCflag)
- {
- if (((TimeControl.moves[side] + 3) - OperatorTime) != 0)
- ResponseTime = (TimeControl.clock[side]) /
- (TimeControl.moves[side] + 3) -
- OperatorTime;
- else ResponseTime = 0;
- ResponseTime += (ResponseTime*TimeControl.moves[side])/(2*TCmoves+1);
- }
- else ResponseTime = Level;
- if (iop == 2) ResponseTime = 999;
- if (Sdepth > 0 && root->score > Zscore-zwndw) ResponseTime -= ft;
- else if (ResponseTime < 1) ResponseTime = 1;
- ExtraTime = 0;
- ExaminePosition();
- ScorePosition(side,&score);
- ShowSidetomove();
-
- if (Sdepth == 0)
- {
- ZeroTTable();
- SearchStartStuff(side);
- for (i = 0; i < 8192; i++) history[i] = 0;
- FROMsquare = TOsquare = -1;
- PV = 0;
- if (iop != 2) hint = 0;
- for (i = 0; i < maxdepth; i++)
- PrVar[i] = killr0[i] = killr1[i] = killr2[i] = killr3[i] = 0;
- alpha = score-90; beta = score+90;
- rpt = 0;
- TrPnt[1] = 0; root = &Tree[0];
- MoveList(side,1);
- for (i = TrPnt[1]; i < TrPnt[2]; i++) pick(i,TrPnt[2]-1);
- if (Book != NULL) OpeningBook();
- if (Book != NULL) timeout = true;
- NodeCnt = ETnodes = EvalNodes = HashCnt = 0;
- Zscore = 0; zwndw = 20;
- }
-
- while (!timeout && Sdepth < MaxSearchDepth)
- {
- Sdepth++;
- ShowDepth(' ');
- score = search(side,1,Sdepth,alpha,beta,PrVar,&rpt);
- for (i = 1; i <= Sdepth; i++) killr0[i] = PrVar[i];
- if (score < alpha)
- {
- ShowDepth('-');
- ExtraTime = 10*ResponseTime;
- ZeroTTable();
- score = search(side,1,Sdepth,-9000,beta,PrVar,&rpt);
- }
- if (score > beta && !(root->flags & exact))
- {
- ShowDepth('+');
- ExtraTime = 0;
- ZeroTTable();
- score = search(side,1,Sdepth,alpha,9000,PrVar,&rpt);
- }
- score = root->score;
- if (!timeout)
- for (i = TrPnt[1]+1; i < TrPnt[2]; i++) pick(i,TrPnt[2]-1);
- ShowResults(score,PrVar,'.');
- for (i = 1; i <= Sdepth; i++) killr0[i] = PrVar[i];
- if (score > Zscore-zwndw && score > Tree[1].score+250) ExtraTime = 0;
- else if (score > Zscore-3*zwndw) ExtraTime = ResponseTime;
- else ExtraTime = 3*ResponseTime;
- if (root->flags & exact) timeout = true;
- if (Tree[1].score < -9000) timeout = true;
- if (4*et > 2*ResponseTime + ExtraTime) timeout = true;
- if (!timeout)
- {
- Tscore[0] = score;
- if (Zscore == 0) Zscore = score;
- else Zscore = (Zscore+score)/2;
- }
- zwndw = 20+abs(Zscore/12);
- beta = score + Bwindow;
- if (Zscore < score) alpha = Zscore - Awindow - zwndw;
- else alpha = score - Awindow - zwndw;
- }
-
- score = root->score;
- if (rpt >= 2 || score < -12000) root->flags |= draw;
- if (iop == 2) return(0);
- if (Book == NULL) hint = PrVar[2];
- ElapsedTime(1);
-
- if (score > -9999 && rpt <= 2)
- {
- MakeMove(side,root,&tempb,&tempc,&tempsf,&tempst);
- algbr(root->f,root->t,(short) root->flags & cstlmask);
- }
- else mvstr1[0] = '\0';
- OutputMove();
- if (score == -9999 || score == 9998) mate = true;
- if (mate) hint = 0;
- if (root->flags & cstlmask) Game50 = GameCnt;
- else if (board[root->t] == pawn || (root->flags & capture))
- Game50 = GameCnt;
- GameList[GameCnt].score = score;
- GameList[GameCnt].nodes = NodeCnt;
- GameList[GameCnt].time = (short)et;
- GameList[GameCnt].depth = Sdepth;
- if (TCflag)
- {
- TimeControl.clock[side] -= (et + OperatorTime);
- if (--TimeControl.moves[side] == 0) SetTimeControl();
- }
- if ((root->flags & draw) && bothsides) quit = true;
- if (GameCnt > 238) quit = true;
- player = xside;
- Sdepth = 0;
- fflush(stdin);
- return(0);
-}
-
-
-OpeningBook()
-
-/*
- Go thru each of the opening lines of play and check for a match with
- the current game listing. If a match occurs, generate a random number.
- If this number is the largest generated so far then the next move in
- this line becomes the current "candidate". After all lines are
- checked, the candidate move is put at the top of the Tree[] array and
- will be played by the program. Note that the program does not handle
- book transpositions.
-*/
-
-{
-short j,pnt;
-unsigned short m,*mp;
-unsigned r,r0;
-struct BookEntry *p;
-
- srand((unsigned)time0);
- r0 = m = 0;
- p = Book;
- while (p != NULL)
- {
- mp = p->mv;
- for (j = 0; j <= GameCnt; j++)
- if (GameList[j].gmove != *(mp++)) break;
- if (j > GameCnt)
- if ((r=rand()) > r0)
- {
- r0 = r; m = *mp;
- hint = *(++mp);
- }
- p = p->next;
- }
-
- for (pnt = TrPnt[1]; pnt < TrPnt[2]; pnt++)
- if ((Tree[pnt].f<<8) + Tree[pnt].t == m) Tree[pnt].score = 0;
- pick(TrPnt[1],TrPnt[2]-1);
- if (Tree[TrPnt[1]].score < 0) Book = NULL;
-}
-
-
-#define UpdateSearchStatus\
-{\
- if (post) ShowCurrentMove(pnt,node->f,node->t);\
- if (pnt > TrPnt[1])\
- {\
- d = best-Zscore; e = best-node->score;\
- if (best < alpha) ExtraTime = 10*ResponseTime;\
- else if (d > -zwndw && e > 4*zwndw) ExtraTime = -ResponseTime/3;\
- else if (d > -zwndw) ExtraTime = 0;\
- else if (d > -3*zwndw) ExtraTime = ResponseTime;\
- else if (d > -9*zwndw) ExtraTime = 3*ResponseTime;\
- else ExtraTime = 5*ResponseTime;\
- }\
-}
-
-int search(side,ply,depth,alpha,beta,bstline,rpt)
-short side,ply,depth,alpha,beta,*rpt;
-unsigned short bstline[];
-
-/*
- Perform an alpha-beta search to determine the score for the current
- board position. If depth <= 0 only capturing moves, pawn promotions
- and responses to check are generated and searched, otherwise all
- moves are processed. The search depth is modified for check evasions,
- certain re-captures and threats. Extensions may continue for up to 11
- ply beyond the nominal search depth.
-*/
-
-#define prune (cf && score+node->score < alpha)
-#define ReCapture (rcptr && score > alpha && score < beta &&\
- ply > 2 && CptrFlag[ply-1] && CptrFlag[ply-2])
-#define MateThreat (ply < Sdepth+4 && ply > 4 &&\
- ChkFlag[ply-2] && ChkFlag[ply-4] &&\
- ChkFlag[ply-2] != ChkFlag[ply-4])
-
-{
-register short j,pnt;
-short best,tempb,tempc,tempsf,tempst;
-short xside,pbst,d,e,cf,score,rcnt;
-unsigned short mv,nxtline[maxdepth];
-struct leaf *node,tmp;
-
- NodeCnt++;
- xside = otherside[side];
- if (depth < 0) depth = 0;
-
- if (ply <= Sdepth+3) repetition(rpt); else *rpt = 0;
- if (*rpt >= 2) return(0);
-
- score = evaluate(side,xside,ply,alpha,beta);
- if (score > 9000)
- {
- bstline[ply] = 0;
- return(score);
- }
-
- if (depth > 0)
- {
- if (InChk || PawnThreat[ply-1] || ReCapture) ++depth;
- }
- else
- {
- if (score >= alpha &&
- (InChk || PawnThreat[ply-1] || Threat[ply-1])) ++depth;
- else if (score <= beta && MateThreat) ++depth;
- }
-
- if (depth > 0 && hashflag && ply > 1)
- {
- ProbeTTable(side,depth,&alpha,&beta,&score);
- bstline[ply] = PV;
- bstline[ply+1] = 0;
- if (beta == -20000) return(score);
- if (alpha > beta) return(alpha);
- }
-
- if (Sdepth == 1) d = 7; else d = 11;
- if (ply > Sdepth+d || (depth < 1 && score > beta)) return(score);
-
- if (ply > 1)
- if (depth > 0) MoveList(side,ply);
- else CaptureList(side,xside,ply);
-
- if (TrPnt[ply] == TrPnt[ply+1]) return(score);
-
- cf = (depth < 1 && ply > Sdepth+1 && !ChkFlag[ply-2] && !slk);
-
- if (depth > 0) best = -12000; else best = score;
- if (best > alpha) alpha = best;
-
- for (pnt = pbst = TrPnt[ply];
- pnt < TrPnt[ply+1] && best <= beta;
- pnt++)
- {
- if (ply > 1) pick(pnt,TrPnt[ply+1]-1);
- node = &Tree[pnt];
- mv = (node->f << 8) + node->t;
- nxtline[ply+1] = 0;
-
- if (prune) break;
- if (ply == 1) UpdateSearchStatus;
-
- if (!(node->flags & exact))
- {
- MakeMove(side,node,&tempb,&tempc,&tempsf,&tempst);
- CptrFlag[ply] = (node->flags & capture);
- PawnThreat[ply] = (node->flags & pwnthrt);
- Tscore[ply] = node->score;
- PV = node->reply;
- node->score = -search(xside,ply+1,depth-1,-beta,-alpha,
- nxtline,&rcnt);
- if (abs(node->score) > 9000) node->flags |= exact;
- else if (rcnt == 1) node->score /= 2;
- if (rcnt >= 2 || GameCnt-Game50 > 99 ||
- (node->score == 9999-ply && !ChkFlag[ply]))
- {
- node->flags |= draw; node->flags |= exact;
- if (side == computer) node->score = contempt;
- else node->score = -contempt;
- }
- node->reply = nxtline[ply+1];
- UnmakeMove(side,node,&tempb,&tempc,&tempsf,&tempst);
- }
- if (node->score > best && !timeout)
- {
- if (depth > 0)
- if (node->score > alpha && !(node->flags & exact))
- node->score += depth;
- best = node->score; pbst = pnt;
- if (best > alpha) alpha = best;
- for (j = ply+1; nxtline[j] > 0; j++) bstline[j] = nxtline[j];
- bstline[j] = 0;
- bstline[ply] = mv;
- if (ply == 1)
- {
- if (best == alpha)
- {
- tmp = Tree[pnt];
- for (j = pnt-1; j >= 0; j--) Tree[j+1] = Tree[j];
- Tree[0] = tmp;
- pbst = 0;
- }
- if (Sdepth > 2)
- if (best > beta) ShowResults(best,bstline,'+');
- else if (best < alpha) ShowResults(best,bstline,'-');
- else ShowResults(best,bstline,'&');
- }
- }
- if (NodeCnt > ETnodes) ElapsedTime(0);
- if (timeout) return(-Tscore[ply-1]);
- }
-
- node = &Tree[pbst];
- mv = (node->f<<8) + node->t;
- if (hashflag && ply <= Sdepth && *rpt == 0 && best == alpha)
- PutInTTable(side,best,depth,alpha,beta,mv);
- if (depth > 0)
- {
- j = (node->f<<6) + node->t; if (side == black) j |= 0x1000;
- if (history[j] < 150) history[j] += 2*depth;
- if (node->t != (GameList[GameCnt].gmove & 0xFF))
- if (best <= beta) killr3[ply] = mv;
- else if (mv != killr1[ply])
- {
- killr2[ply] = killr1[ply];
- killr1[ply] = mv;
- }
- if (best > 9000) killr0[ply] = mv; else killr0[ply] = 0;
- }
- return(best);
-}
-
-
-evaluate(side,xside,ply,alpha,beta)
-short side,xside,ply,alpha,beta;
-
-/*
- Compute an estimate of the score by adding the positional score from
- the previous ply to the material difference. If this score falls
- inside a window which is 180 points wider than the alpha-beta window
- (or within a 50 point window during quiescence search) call
- ScorePosition() to determine a score, otherwise return the estimated
- score. If one side has only a king and the other either has no pawns
- or no pieces then the function ScoreLoneKing() is called.
-*/
-
-{
-short s,evflag;
-
- hung[white] = hung[black] = 0;
- slk = ((mtl[white] == valueK && (pmtl[black] == 0 || emtl[black] == 0)) ||
- (mtl[black] == valueK && (pmtl[white] == 0 || emtl[white] == 0)));
- s = -Pscore[ply-1] + mtl[side] - mtl[xside];
- s -= INCscore;
-
- if (slk) evflag = false;
- else evflag =
- (ply == 1 || ply < Sdepth ||
- ((ply == Sdepth+1 || ply == Sdepth+2) &&
- (s > alpha-xwndw && s < beta+xwndw)) ||
- (ply > Sdepth+2 && s >= alpha-25 && s <= beta+25));
-
- if (evflag)
- {
- EvalNodes++;
- ataks(side,atak[side]);
- if (atak[side][PieceList[xside][0]] > 0) return(10001-ply);
- ataks(xside,atak[xside]);
- InChk = (atak[xside][PieceList[side][0]] > 0);
- ScorePosition(side,&s);
- }
- else
- {
- if (SqAtakd(PieceList[xside][0],side)) return(10001-ply);
- InChk = SqAtakd(PieceList[side][0],xside);
- if (slk) ScoreLoneKing(side,&s);
- }
-
- Pscore[ply] = s - mtl[side] + mtl[xside];
- if (InChk) ChkFlag[ply-1] = Pindex[TOsquare];
- else ChkFlag[ply-1] = 0;
- Threat[ply-1] = (hung[side] > 1 && ply == Sdepth+1);
- return(s);
-}
-
-
-ProbeTTable(side,depth,alpha,beta,score)
-short side,depth,*alpha,*beta,*score;
-
-/*
- Look for the current board position in the transposition table.
-*/
-
-{
-short hindx;
- if (side == white) hashkey |= 1; else hashkey &= 0xFFFE;
- hindx = (hashkey & (ttblsz-1));
- ptbl = (ttable + hindx);
- if (ptbl->depth >= depth && ptbl->hashbd == hashbd)
- {
- HashCnt++;
- PV = ptbl->mv;
- if (ptbl->flags & truescore)
- {
- *score = ptbl->score;
- *beta = -20000;
- return(true);
- }
-/*
- else if (ptbl->flags & upperbound)
- {
- if (ptbl->score < *beta) *beta = ptbl->score+1;
- }
-*/
- else if (ptbl->flags & lowerbound)
- {
- if (ptbl->score > *alpha) *alpha = ptbl->score-1;
- }
- }
- return(false);
-}
-
-
-PutInTTable(side,score,depth,alpha,beta,mv)
-short side,score,depth,alpha,beta;
-unsigned short mv;
-
-/*
- Store the current board position in the transposition table.
-*/
-
-{
-short hindx;
- if (side == white) hashkey |= 1; else hashkey &= 0xFFFE;
- hindx = (hashkey & (ttblsz-1));
- ptbl = (ttable + hindx);
- ptbl->hashbd = hashbd;
- ptbl->depth = depth;
- ptbl->score = score;
- ptbl->mv = mv;
- ptbl->flags = 0;
- if (score < alpha) ptbl->flags |= upperbound;
- else if (score > beta) ptbl->flags |= lowerbound;
- else ptbl->flags |= truescore;
-}
-
-
-ZeroTTable()
-{
-int i;
- if (hashflag)
- for (i = 0; i < ttblsz; i++)
- {
- ptbl = (ttable + i);
- ptbl->depth = 0;
- }
-}
-
-
-MoveList(side,ply)
-short side,ply;
-
-/*
- Fill the array Tree[] with all available moves for side to play. Array
- TrPnt[ply] contains the index into Tree[] of the first move at a ply.
-*/
-
-{
-register short i;
-short xside,f;
-
- xside = otherside[side];
- if (PV == 0) Swag0 = killr0[ply]; else Swag0 = PV;
- Swag1 = killr1[ply]; Swag2 = killr2[ply];
- Swag3 = killr3[ply]; Swag4 = 0;
- if (ply > 2) Swag4 = killr1[ply-2];
- TrPnt[ply+1] = TrPnt[ply];
- Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
- for (i = PieceCnt[side]; i >= 0; i--)
- GenMoves(ply,PieceList[side][i],side,xside);
- if (kingmoved[side] == 0 && !castld[side])
- {
- f = PieceList[side][0];
- if (castle(side,f,f+2,0))
- {
- LinkMove(ply,f,f+2,xside);
- Tree[TrPnt[ply+1]-1].flags |= cstlmask;
- }
- if (castle(side,f,f-2,0))
- {
- LinkMove(ply,f,f-2,xside);
- Tree[TrPnt[ply+1]-1].flags |= cstlmask;
- }
- }
-}
-
-#if (NEWMOVE < 11)
-GenMoves(ply,sq,side,xside)
-short ply,sq,side,xside;
-
-/*
- Generate moves for a piece. The from square is mapped onto a special
- board and offsets (taken from array Dir[]) are added to the mapped
- location. The newly generated square is tested to see if it falls off
- the board by ANDing the square with 88 HEX. Legal moves are linked
- into the tree.
-*/
-
-{
-register short m,u,d;
-short i,m0,piece;
-
- piece = board[sq]; m0 = map[sq];
- if (sweep[piece])
- for (i = Dstart[piece]; i <= Dstop[piece]; i++)
- {
- d = Dir[i]; m = m0+d;
- while (!(m & 0x88))
- {
- u = unmap[m];
- if (color[u] == neutral)
- {
- LinkMove(ply,sq,u,xside);
- m += d;
- }
- else if (color[u] == xside)
- {
- LinkMove(ply,sq,u,xside);
- break;
- }
- else break;
- }
- }
- else if (piece == pawn)
- {
- if (side == white && color[sq+8] == neutral)
- {
- LinkMove(ply,sq,sq+8,xside);
- if (row[sq] == 1)
- if (color[sq+16] == neutral)
- LinkMove(ply,sq,sq+16,xside);
- }
- else if (side == black && color[sq-8] == neutral)
- {
- LinkMove(ply,sq,sq-8,xside);
- if (row[sq] == 6)
- if (color[sq-16] == neutral)
- LinkMove(ply,sq,sq-16,xside);
- }
- for (i = Dstart[piece]; i <= Dstop[piece]; i++)
- if (!((m = m0+Dir[i]) & 0x88))
- {
- u = unmap[m];
- if (color[u] == xside || u == epsquare)
- LinkMove(ply,sq,u,xside);
- }
- }
- else
- {
- for (i = Dstart[piece]; i <= Dstop[piece]; i++)
- if (!((m = m0+Dir[i]) & 0x88))
- {
- u = unmap[m];
- if (color[u] != side) LinkMove(ply,sq,u,xside);
- }
- }
-}
-#endif
-
-LinkMove(ply,f,t,xside)
-short ply,f,t,xside;
-
-/*
- Add a move to the tree. Assign a bonus to order the moves
- as follows:
- 1. Principle variation
- 2. Capture of last moved piece
- 3. Other captures (major pieces first)
- 4. Killer moves
- 5. "history" killers
-*/
-
-{
-register short s,z;
-unsigned short mv;
-struct leaf *node;
-
- node = &Tree[TrPnt[ply+1]];
- ++TrPnt[ply+1];
- node->flags = node->reply = 0;
- node->f = f; node->t = t;
- mv = (f<<8) + t;
- s = 0;
- if (mv == Swag0) s = 2000;
- else if (mv == Swag1) s = 60;
- else if (mv == Swag2) s = 50;
- else if (mv == Swag3) s = 40;
- else if (mv == Swag4) s = 30;
- if (color[t] != neutral)
- {
- node->flags |= capture;
- if (t == TOsquare) s += 500;
- s += value[board[t]] - board[f];
- }
- if (board[f] == pawn)
- if (row[t] == 0 || row[t] == 7)
- {
- node->flags |= promote;
- s += 800;
- }
- else if (row[t] == 1 || row[t] == 6)
- {
- node->flags |= pwnthrt;
- s += 600;
- }
- else if (t == epsquare) node->flags |= epmask;
- z = (f<<6) + t; if (xside == white) z |= 0x1000;
- s += history[z];
- node->score = s - 20000;
-}
-
-#if (NEWMOVE < 10)
-CaptureList(side,xside,ply)
-short side,xside,ply;
-
-/*
- Generate captures and Pawn promotions only.
-*/
-
-#define LinkCapture\
-{\
- node->f = sq; node->t = u;\
- node->reply = 0;\
- node->flags = capture;\
- node->score = value[board[u]] + svalue[board[u]] - piece;\
- if (piece == pawn && (u < 8 || u > 55))\
- {\
- node->flags |= promote;\
- node->score = valueQ;\
- }\
- ++node;\
- ++TrPnt[ply+1];\
-}
-
-{
-register short m,u;
-short d,sq,i,j,j1,j2,m0,r7,d0,piece,*PL;
-struct leaf *node;
-
- TrPnt[ply+1] = TrPnt[ply];
- node = &Tree[TrPnt[ply]];
- Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
- if (side == white)
- {
- r7 = 6; d0 = 8;
- }
- else
- {
- r7 = 1; d0 = -8;
- }
- PL = PieceList[side];
- for (i = 0; i <= PieceCnt[side]; i++)
- {
- sq = PL[i];
- m0 = map[sq]; piece = board[sq];
- j1 = Dstart[piece]; j2 = Dstop[piece];
- if (sweep[piece])
- for (j = j1; j <= j2; j++)
- {
- d = Dir[j]; m = m0+d;
- while (!(m & 0x88))
- {
- u = unmap[m];
- if (color[u] == neutral) m += d;
- else
- {
- if (color[u] == xside) LinkCapture;
- break;
- }
- }
- }
- else
- {
- for (j = j1; j <= j2; j++)
- if (!((m = m0+Dir[j]) & 0x88))
- {
- u = unmap[m];
- if (color[u] == xside) LinkCapture;
- }
- if (piece == pawn && row[sq] == r7)
- {
- u = sq+d0;
- if (color[u] == neutral) LinkCapture;
- }
- }
- }
-}
-#endif
-
-int castle(side,kf,kt,iop)
-short side,kf,kt,iop;
-
-/*
- Make or Unmake a castling move.
-*/
-
-{
-short rf,rt,d,t0,xside;
-
- xside = otherside[side];
- if (kt > kf)
- {
- rf = kf+3; rt = kt-1; d = 1;
- }
- else
- {
- rf = kf-4; rt = kt+1; d = -1;
- }
- if (iop == 0)
- {
- if (board[kf] != king || board[rf] != rook || color[rf] != side)
- return(false);
- if (color[kt] != neutral || color[rt] != neutral) return(false);
- if (d == -1 && color[kt+d] != neutral) return(false);
- if (SqAtakd(kf,xside)) return(false);
- if (SqAtakd(kt,xside)) return(false);
- if (SqAtakd(kf+d,xside)) return(false);
- }
- else
- {
- if (iop == 1) castld[side] = true; else castld[side] = false;
- if (iop == 2)
- {
- t0 = kt; kt = kf; kf = t0;
- t0 = rt; rt = rf; rf = t0;
- }
- board[kt] = king; color[kt] = side; Pindex[kt] = 0;
- board[kf] = no_piece; color[kf] = neutral;
- board[rt] = rook; color[rt] = side; Pindex[rt] = Pindex[rf];
- board[rf] = no_piece; color[rf] = neutral;
- PieceList[side][Pindex[kt]] = kt;
- PieceList[side][Pindex[rt]] = rt;
- if (hashflag)
- {
- UpdateHashbd(side,king,kf,kt);
- UpdateHashbd(side,rook,rf,rt);
- }
- }
- return(true);
-}
-
-
-EnPassant(xside,f,t,iop)
-short xside,f,t,iop;
-
-/*
- Make or unmake an en passant move.
-*/
-
-{
-short l;
- if (t > f) l = t-8; else l = t+8;
- if (iop == 1)
- {
- board[l] = no_piece; color[l] = neutral;
- }
- else
- {
- board[l] = pawn; color[l] = xside;
- }
- InitializeStats();
-}
-
-
-MakeMove(side,node,tempb,tempc,tempsf,tempst)
-short side,*tempc,*tempb,*tempsf,*tempst;
-struct leaf *node;
-
-/*
- Update Arrays board[], color[], and Pindex[] to reflect the new board
- position obtained after making the move pointed to by node. Also
- update miscellaneous stuff that changes when a move is made.
-*/
-
-{
-register short f,t;
-short xside,ct,cf;
-
- xside = otherside[side];
- f = node->f; t = node->t; epsquare = -1;
- FROMsquare = f; TOsquare = t;
- INCscore = 0;
- GameList[++GameCnt].gmove = (f<<8) + t;
- if (node->flags & cstlmask)
- {
- GameList[GameCnt].piece = no_piece;
- GameList[GameCnt].color = side;
- castle(side,f,t,1);
- }
- else
- {
- *tempc = color[t]; *tempb = board[t];
- *tempsf = svalue[f]; *tempst = svalue[t];
- GameList[GameCnt].piece = *tempb;
- GameList[GameCnt].color = *tempc;
- if (*tempc != neutral)
- {
- UpdatePieceList(*tempc,t,1);
- if (*tempb == pawn) --PawnCnt[*tempc][column[t]];
- if (board[f] == pawn)
- {
- --PawnCnt[side][column[f]];
- ++PawnCnt[side][column[t]];
- cf = column[f]; ct = column[t];
- if (PawnCnt[side][ct] > 1+PawnCnt[side][cf])
- INCscore -= 15;
- else if (PawnCnt[side][ct] < 1+PawnCnt[side][cf])
- INCscore += 15;
- else if (ct == 0 || ct == 7 || PawnCnt[side][ct+ct-cf] == 0)
- INCscore -= 15;
- }
- mtl[xside] -= value[*tempb];
- if (*tempb == pawn) pmtl[xside] -= valueP;
- if (hashflag) UpdateHashbd(xside,*tempb,-1,t);
- INCscore += *tempst;
- }
- color[t] = color[f]; board[t] = board[f]; svalue[t] = svalue[f];
- Pindex[t] = Pindex[f]; PieceList[side][Pindex[t]] = t;
- color[f] = neutral; board[f] = no_piece;
- if (board[t] == pawn)
- if (t-f == 16) epsquare = f+8;
- else if (f-t == 16) epsquare = f-8;
- if (node->flags & promote)
- {
- board[t] = queen;
- --PawnCnt[side][column[t]];
- mtl[side] += valueQ - valueP;
- pmtl[side] -= valueP;
- HasQueen[side] = true;
- if (hashflag)
- {
- UpdateHashbd(side,pawn,f,-1);
- UpdateHashbd(side,queen,f,-1);
- }
- INCscore -= *tempsf;
- }
- if (board[t] == king) ++kingmoved[side];
- if (node->flags & epmask) EnPassant(xside,f,t,1);
- else if (hashflag) UpdateHashbd(side,board[t],f,t);
- }
-}
-
-
-UnmakeMove(side,node,tempb,tempc,tempsf,tempst)
-short side,*tempc,*tempb,*tempsf,*tempst;
-struct leaf *node;
-
-/*
- Take back a move.
-*/
-
-{
-register short f,t;
-short xside;
-
- xside = otherside[side];
- f = node->f; t = node->t; epsquare = -1;
- GameCnt--;
- if (node->flags & cstlmask) castle(side,f,t,2);
- else
- {
- color[f] = color[t]; board[f] = board[t]; svalue[f] = *tempsf;
- Pindex[f] = Pindex[t]; PieceList[side][Pindex[f]] = f;
- color[t] = *tempc; board[t] = *tempb; svalue[t] = *tempst;
- if (node->flags & promote)
- {
- board[f] = pawn;
- ++PawnCnt[side][column[t]];
- mtl[side] += valueP - valueQ;
- pmtl[side] += valueP;
- if (hashflag)
- {
- UpdateHashbd(side,queen,-1,t);
- UpdateHashbd(side,pawn,-1,t);
- }
- }
- if (*tempc != neutral)
- {
- UpdatePieceList(*tempc,t,2);
- if (*tempb == pawn) ++PawnCnt[*tempc][column[t]];
- if (board[f] == pawn)
- {
- --PawnCnt[side][column[t]];
- ++PawnCnt[side][column[f]];
- }
- mtl[xside] += value[*tempb];
- if (*tempb == pawn) pmtl[xside] += valueP;
- if (hashflag) UpdateHashbd(xside,*tempb,-1,t);
- }
- if (board[f] == king) --kingmoved[side];
- if (node->flags & epmask) EnPassant(xside,f,t,2);
- else if (hashflag) UpdateHashbd(side,board[f],f,t);
- }
-}
-
-
-UpdateHashbd(side,piece,f,t)
-short side,piece,f,t;
-
-/*
- hashbd contains a 32 bit "signature" of the board position. hashkey
- contains a 16 bit code used to address the hash table. When a move is
- made, XOR'ing the hashcode of moved piece on the from and to squares
- with the hashbd and hashkey values keeps things current.
-*/
-
-{
- if (f >= 0)
- {
- hashbd ^= hashcode[side][piece][f].bd;
- hashkey ^= hashcode[side][piece][f].key;
- }
- if (t >= 0)
- {
- hashbd ^= hashcode[side][piece][t].bd;
- hashkey ^= hashcode[side][piece][t].key;
- }
-}
-
-
-UpdatePieceList(side,sq,iop)
-short side,sq,iop;
-
-/*
- Update the PieceList and Pindex arrays when a piece is captured or
- when a capture is unmade.
-*/
-
-{
-register short i;
- if (iop == 1)
- {
- PieceCnt[side]--;
- for (i = Pindex[sq]; i <= PieceCnt[side]; i++)
- {
- PieceList[side][i] = PieceList[side][i+1];
- Pindex[PieceList[side][i]] = i;
- }
- }
- else
- {
- PieceCnt[side]++;
- PieceList[side][PieceCnt[side]] = sq;
- Pindex[sq] = PieceCnt[side];
- }
-}
-
-
-InitializeStats()
-
-/*
- Scan thru the board seeing what's on each square. If a piece is found,
- update the variables PieceCnt, PawnCnt, Pindex and PieceList. Also
- determine the material for each side and set the hashkey and hashbd
- variables to represent the current board position. Array
- PieceList[side][indx] contains the location of all the pieces of
- either side. Array Pindex[sq] contains the indx into PieceList for a
- given square.
-*/
-
-{
-register short i,sq;
- epsquare = -1;
- for (i = 0; i < 8; i++)
- PawnCnt[white][i] = PawnCnt[black][i] = 0;
- mtl[white] = mtl[black] = pmtl[white] = pmtl[black] = 0;
- PieceCnt[white] = PieceCnt[black] = 0;
- hashbd = hashkey = 0;
- for (sq = 0; sq < 64; sq++)
- if (color[sq] != neutral)
- {
- mtl[color[sq]] += value[board[sq]];
- if (board[sq] == pawn)
- {
- pmtl[color[sq]] += valueP;
- ++PawnCnt[color[sq]][column[sq]];
- }
- if (board[sq] == king) Pindex[sq] = 0;
- else Pindex[sq] = ++PieceCnt[color[sq]];
- PieceList[color[sq]][Pindex[sq]] = sq;
- hashbd ^= hashcode[color[sq]][board[sq]][sq].bd;
- hashkey ^= hashcode[color[sq]][board[sq]][sq].key;
- }
-}
-
-
-pick(p1,p2)
-short p1,p2;
-
-/*
- Find the best move in the tree between indexes p1 and p2. Swap the
- best move into the p1 element.
-*/
-
-{
-register short p,s;
-short p0,s0;
-struct leaf temp;
-
- s0 = Tree[p1].score; p0 = p1;
- for (p = p1+1; p <= p2; p++)
- if ((s = Tree[p].score) > s0)
- {
- s0 = s; p0 = p;
- }
- if (p0 != p1)
- {
- temp = Tree[p1]; Tree[p1] = Tree[p0]; Tree[p0] = temp;
- }
-}
-
-
-repetition(cnt)
-short *cnt;
-
-/*
- Check for draw by threefold repetition.
-*/
-
-{
-register short i,c;
-short f,t,b[64];
-unsigned short m;
- *cnt = c = 0;
- if (GameCnt > Game50+3)
- {
-/*
- memset((char *)b,0,64*sizeof(short));
-*/
- for (i = 0; i < 64; b[i++] = 0);
- for (i = GameCnt; i > Game50; i--)
- {
- m = GameList[i].gmove; f = m>>8; t = m & 0xFF;
- if (++b[f] == 0) c--; else c++;
- if (--b[t] == 0) c--; else c++;
- if (c == 0) (*cnt)++;
- }
- }
-}
-
-#if (NEWMOVE < 3)
-int SqAtakd(sq,side)
-short sq,side;
-
-/*
- See if any piece with color 'side' ataks sq. First check for pawns
- or king, then try other pieces. Array Dcode is used to check for
- knight attacks or R,B,Q co-linearity.
-*/
-
-{
-register short m,d;
-short i,m0,m1,loc,piece,*PL;
-
- m1 = map[sq];
- if (side == white) m = m1-0x0F; else m = m1+0x0F;
- if (!(m & 0x88))
- if (board[unmap[m]] == pawn && color[unmap[m]] == side) return(true);
- if (side == white) m = m1-0x11; else m = m1+0x11;
- if (!(m & 0x88))
- if (board[unmap[m]] == pawn && color[unmap[m]] == side) return(true);
- if (distance(sq,PieceList[side][0]) == 1) return(true);
-
- PL = PieceList[side];
- for (i = 1; i <= PieceCnt[side]; i++)
- {
- loc = PL[i]; piece = board[loc];
- if (piece == pawn) continue;
- m0 = map[loc]; d = Dcode[abs(m1-m0)];
- if (d == 0 || (Pdir[d] & pbit[piece]) == 0) continue;
- if (piece == knight) return(true);
- else
- {
- if (m1 < m0) d = -d;
- for (m = m0+d; m != m1; m += d)
- if (color[unmap[m]] != neutral) break;
- if (m == m1) return(true);
- }
- }
- return(false);
-}
-#endif
-
-#if (NEWMOVE < 2)
-ataks(side,a)
-short side,*a;
-
-/*
- Fill array atak[][] with info about ataks to a square. Bits 8-15
- are set if the piece (king..pawn) ataks the square. Bits 0-7
- contain a count of total ataks to the square.
-*/
-
-{
-register short u,m;
-short d,c,j,j1,j2,piece,i,m0,sq,*PL;
-
-/*
- memset((char *)a,0,64*sizeof(short));
-*/
- for (u = 0; u < 64; a[u++] = 0);
- Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
- PL = PieceList[side];
- for (i = 0; i <= PieceCnt[side]; i++)
- {
- sq = PL[i];
- m0 = map[sq];
- piece = board[sq];
- c = control[piece]; j1 = Dstart[piece]; j2 = Dstop[piece];
- if (sweep[piece])
- for (j = j1; j <= j2; j++)
- {
- d = Dir[j]; m = m0+d;
- while (!(m & 0x88))
- {
- u = unmap[m];
- a[u] = ++a[u] | c;
- if (color[u] == neutral) m += d;
- else break;
- }
- }
- else
- for (j = j1; j <= j2; j++)
- if (!((m = m0+Dir[j]) & 0x88))
- {
- u = unmap[m];
- a[u] = ++a[u] | c;
- }
- }
-}
-#endif
-
-/* ............ POSITIONAL EVALUATION ROUTINES ............ */
-
-ScorePosition(side,score)
-short side,*score;
-
-/*
- Perform normal static evaluation of board position. A score is
- generated for each piece and these are summed to get a score for each
- side.
-*/
-
-{
-register short sq,s;
-short i,xside,pscore[3];
-
- wking = PieceList[white][0]; bking = PieceList[black][0];
- UpdateWeights();
- xside = otherside[side];
- pscore[white] = pscore[black] = 0;
-
- for (c1 = white; c1 <= black; c1++)
- {
- c2 = otherside[c1];
- if (c1 == white) EnemyKing = bking; else EnemyKing = wking;
- atk1 = atak[c1]; atk2 = atak[c2];
- PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
- for (i = 0; i <= PieceCnt[c1]; i++)
- {
- sq = PieceList[c1][i];
- s = SqValue(sq,side);
- pscore[c1] += s;
- svalue[sq] = s;
- }
- }
- if (hung[side] > 1) pscore[side] += HUNGX;
- if (hung[xside] > 1) pscore[xside] += HUNGX;
-
- *score = mtl[side] - mtl[xside] + pscore[side] - pscore[xside] + 10;
- if (dither) *score += rand() % dither;
-
- if (*score > 0 && pmtl[side] == 0)
- if (emtl[side] < valueR) *score = 0;
- else if (*score < valueR) *score /= 2;
- if (*score < 0 && pmtl[xside] == 0)
- if (emtl[xside] < valueR) *score = 0;
- else if (-*score < valueR) *score /= 2;
-
- if (mtl[xside] == valueK && emtl[side] > valueB) *score += 200;
- if (mtl[side] == valueK && emtl[xside] > valueB) *score -= 200;
-}
-
-
-ScoreLoneKing(side,score)
-short side,*score;
-
-/*
- Static evaluation when loser has only a king and winner has no pawns
- or no pieces.
-*/
-
-{
-short winner,loser,king1,king2,s,i;
-
- UpdateWeights();
- if (mtl[white] > mtl[black]) winner = white; else winner = black;
- loser = otherside[winner];
- king1 = PieceList[winner][0]; king2 = PieceList[loser][0];
-
- s = 0;
-
- if (pmtl[winner] > 0)
- for (i = 1; i <= PieceCnt[winner]; i++)
- s += ScoreKPK(side,winner,loser,king1,king2,PieceList[winner][i]);
-
- else if (emtl[winner] == valueB+valueN)
- s = ScoreKBNK(winner,king1,king2);
-
- else if (emtl[winner] > valueB)
- s = 500 + emtl[winner] - DyingKing[king2] - 2*distance(king1,king2);
-
- if (side == winner) *score = s; else *score = -s;
-}
-
-
-int ScoreKPK(side,winner,loser,king1,king2,sq)
-short side,winner,loser,king1,king2,sq;
-
-/*
- Score King and Pawns versus King endings.
-*/
-
-{
-short s,r;
-
- if (PieceCnt[winner] == 1) s = 50; else s = 120;
- if (winner == white)
- {
- if (side == loser) r = row[sq]-1; else r = row[sq];
- if (row[king2] >= r && distance(sq,king2) < 8-r) s += 10*row[sq];
- else s = 500+50*row[sq];
- if (row[sq] < 6) sq += 16; else sq += 8;
- }
- else
- {
- if (side == loser) r = row[sq]+1; else r = row[sq];
- if (row[king2] <= r && distance(sq,king2) < r+1) s += 10*(7-row[sq]);
- else s = 500+50*(7-row[sq]);
- if (row[sq] > 1) sq -= 16; else sq -= 8;
- }
- s += 8*(taxicab(king2,sq) - taxicab(king1,sq));
- return(s);
-}
-
-
-int ScoreKBNK(winner,king1,king2)
-short winner,king1,king2;
-
-/*
- Score King+Bishop+Knight versus King endings.
- This doesn't work all that well but it's better than nothing.
-*/
-
-{
-short s;
- s = emtl[winner] - 300;
- if (KBNKsq == 0) s += KBNK[king2];
- else s += KBNK[locn[row[king2]][7-column[king2]]];
- s -= taxicab(king1,king2);
- s -= distance(PieceList[winner][1],king2);
- s -= distance(PieceList[winner][2],king2);
- return(s);
-}
-
-
-SqValue(sq,side)
-short sq,side;
-
-/*
- Calculate the positional value for the piece on 'sq'.
-*/
-
-{
-register short j,fyle,rank;
-short s,piece,a1,a2,in_square,r,mob,e,c;
-
- piece = board[sq];
- a1 = (atk1[sq] & 0x4FFF); a2 = (atk2[sq] & 0x4FFF);
- rank = row[sq]; fyle = column[sq];
- s = 0;
- if (piece == pawn && c1 == white)
- {
- s = Mwpawn[sq];
- if (sq == 11 || sq == 12)
- if (color[sq+8] != neutral) s += PEDRNK2B;
- if ((fyle == 0 || PC1[fyle-1] == 0) &&
- (fyle == 7 || PC1[fyle+1] == 0))
- s += ISOLANI[fyle];
- else if (PC1[fyle] > 1) s += PDOUBLED;
- if (a1 < ctlP && atk1[sq+8] < ctlP)
- {
- s += BACKWARD[a2 & 0xFF];
- if (PC2[fyle] == 0) s += PWEAKH;
- if (color[sq+8] != neutral) s += PBLOK;
- }
- if (PC2[fyle] == 0)
- {
- if (side == black) r = rank-1; else r = rank;
- in_square = (row[bking] >= r && distance(sq,bking) < 8-r);
- if (a2 == 0 || side == white) e = 0; else e = 1;
- for (j = sq+8; j < 64; j += 8)
- if (atk2[j] >= ctlP) { e = 2; break; }
- else if (atk2[j] > 0 || color[j] != neutral) e = 1;
- if (e == 2) s += (stage*PassedPawn3[rank]) / 10;
- else if (in_square || e == 1) s += (stage*PassedPawn2[rank]) / 10;
- else if (emtl[black] > 0) s += (stage*PassedPawn1[rank]) / 10;
- else s += PassedPawn0[rank];
- }
- }
- else if (piece == pawn && c1 == black)
- {
- s = Mbpawn[sq];
- if (sq == 51 || sq == 52)
- if (color[sq-8] != neutral) s += PEDRNK2B;
- if ((fyle == 0 || PC1[fyle-1] == 0) &&
- (fyle == 7 || PC1[fyle+1] == 0))
- s += ISOLANI[fyle];
- else if (PC1[fyle] > 1) s += PDOUBLED;
- if (a1 < ctlP && atk1[sq-8] < ctlP)
- {
- s += BACKWARD[a2 & 0xFF];
- if (PC2[fyle] == 0) s += PWEAKH;
- if (color[sq-8] != neutral) s += PBLOK;
- }
- if (PC2[fyle] == 0)
- {
- if (side == white) r = rank+1; else r = rank;
- in_square = (row[wking] <= r && distance(sq,wking) < r+1);
- if (a2 == 0 || side == black) e = 0; else e = 1;
- for (j = sq-8; j >= 0; j -= 8)
- if (atk2[j] >= ctlP) { e = 2; break; }
- else if (atk2[j] > 0 || color[j] != neutral) e = 1;
- if (e == 2) s += (stage*PassedPawn3[7-rank]) / 10;
- else if (in_square || e == 1) s += (stage*PassedPawn2[7-rank]) / 10;
- else if (emtl[white] > 0) s += (stage*PassedPawn1[7-rank]) / 10;
- else s += PassedPawn0[7-rank];
- }
- }
- else if (piece == knight)
- {
- s = Mknight[c1][sq];
- }
- else if (piece == bishop)
- {
- s = Mbishop[c1][sq];
- BRscan(sq,&s,&mob);
- s += BMBLTY[mob];
- }
- else if (piece == rook)
- {
- s += RookBonus;
- BRscan(sq,&s,&mob);
- s += RMBLTY[mob];
- if (PC1[fyle] == 0) s += RHOPN;
- if (PC2[fyle] == 0) s += RHOPNX;
- if (rank == rank7[c1] && pmtl[c2] > 100) s += 10;
- if (stage > 2) s += 14 - taxicab(sq,EnemyKing);
- }
- else if (piece == queen)
- {
- if (stage > 2) s += 14 - taxicab(sq,EnemyKing);
- if (distance(sq,EnemyKing) < 3) s += 12;
- }
- else if (piece == king)
- {
- s = Mking[c1][sq];
- if (KSFTY > 0)
- if (Developed[c2] || stage > 0) KingScan(sq,&s);
- if (castld[c1]) s += KCASTLD;
- else if (kingmoved[c1]) s += KMOVD;
-
- if (PC1[fyle] == 0) s += KHOPN;
- if (PC2[fyle] == 0) s += KHOPNX;
- if (fyle == 1 || fyle == 2 || fyle == 3 || fyle == 7)
- {
- if (PC1[fyle-1] == 0) s += KHOPN;
- if (PC2[fyle-1] == 0) s += KHOPNX;
- }
- if (fyle == 4 || fyle == 5 || fyle == 6 || fyle == 0)
- {
- if (PC1[fyle+1] == 0) s += KHOPN;
- if (PC2[fyle+1] == 0) s += KHOPNX;
- }
- if (fyle == 2)
- {
- if (PC1[0] == 0) s += KHOPN;
- if (PC2[0] == 0) s += KHOPNX;
- }
- if (fyle == 5)
- {
- if (PC1[7] == 0) s += KHOPN;
- if (PC2[7] == 0) s += KHOPNX;
- }
- }
-
- if (a2 > 0)
- {
- c = (control[piece] & 0x4FFF);
- if (a1 == 0 || a2 > c+1)
- {
- s += HUNGP;
- ++hung[c1];
- if (piece != king && trapped(sq,piece)) ++hung[c1];
- }
- else if (piece != pawn || a2 > a1)
- if (a2 >= c || a1 < ctlP) s += ATAKD;
- }
- return(s);
-}
-
-#if (NEWMOVE > 6)
-KingScan(sq,s)
-short sq,*s;
-
-/*
- Assign penalties if king can be threatened by checks, if squares
- near the king are controlled by the enemy (especially the queen),
- or if there are no pawns near the king.
-*/
-
-#define ScoreThreat\
- if (color[u] != c2)\
- if (atk1[u] == 0 || (atk2[u] & 0xFF) > 1) ++cnt;\
- else *s -= 3
-
-{
-register short m,u;
-short d,i,m0,cnt,ok;
-
- cnt = 0;
- m0 = map[sq];
- if (HasBishop[c2] || HasQueen[c2])
- for (i = Dstart[bishop]; i <= Dstop[bishop]; i++)
- {
- d = Dir[i]; m = m0+d;
- while (!(m & 0x88))
- {
- u = unmap[m];
- if (atk2[u] & ctlBQ) ScoreThreat;
- if (color[u] != neutral) break;
- m += d;
- }
- }
- if (HasRook[c2] || HasQueen[c2])
- for (i = Dstart[rook]; i <= Dstop[rook]; i++)
- {
- d = Dir[i]; m = m0+d;
- while (!(m & 0x88))
- {
- u = unmap[m];
- if (atk2[u] & ctlRQ) ScoreThreat;
- if (color[u] != neutral) break;
- m += d;
- }
- }
- if (HasKnight[c2])
- for (i = Dstart[knight]; i <= Dstop[knight]; i++)
- if (!((m = m0+Dir[i]) & 0x88))
- {
- u = unmap[m];
- if (atk2[u] & ctlNN) ScoreThreat;
- }
- *s += (KSFTY*Kthreat[cnt]) / 16;
-
- cnt = 0; ok = false;
- m0 = map[sq];
- for (i = Dstart[king]; i <= Dstop[king]; i++)
- if (!((m = m0+Dir[i]) & 0x88))
- {
- u = unmap[m];
- if (board[u] == pawn) ok = true;
- if (atk2[u] > atk1[u])
- {
- ++cnt;
- if (atk2[u] & ctlQ)
- if (atk2[u] > ctlQ+1 && atk1[u] < ctlQ) *s -= 4*KSFTY;
- }
- }
- if (!ok) *s -= KSFTY;
- if (cnt > 1) *s -= KSFTY;
-}
-#endif
-
-#if (NEWMOVE < 4)
-BRscan(sq,s,mob)
-short sq,*s,*mob;
-
-/*
- Find Bishop and Rook mobility, XRAY attacks, and pins. Increment the
- hung[] array if a pin is found.
-*/
-
-{
-register short m,u;
-short d,j,m0,piece,pin,*Kf;
-
- Kf = Kfield[c1];
- *mob = 0;
- m0 = map[sq]; piece = board[sq];
- for (j = Dstart[piece]; j <= Dstop[piece]; j++)
- {
- pin = -1;
- d = Dir[j]; m = m0+d;
- while (!(m & 0x88))
- {
- u = unmap[m]; *s += Kf[u];
- if (color[u] == neutral)
- {
- (*mob)++;
- m += d;
- }
- else if (pin < 0)
- {
- if (board[u] == pawn || board[u] == king) break;
- pin = u;
- m += d;
- }
- else if (color[u] == c2 && (board[u] > piece || atk2[u] == 0))
- {
- if (color[pin] == c2)
- {
- *s += PINVAL;
- if (atk2[pin] == 0 ||
- atk1[pin] > control[board[pin]]+1)
- ++hung[c2];
- }
- else *s += XRAY;
- break;
- }
- else break;
- }
- }
-}
-#endif
-
-#if (NEWMOVE > 5)
-int trapped(sq,piece)
-short sq,piece;
-
-/*
- See if the attacked piece has unattacked squares to move to.
-*/
-
-{
-register short u,m,d;
-short i,m0;
-
- m0 = map[sq];
- if (sweep[piece])
- for (i = Dstart[piece]; i <= Dstop[piece]; i++)
- {
- d = Dir[i]; m = m0+d;
- while (!(m & 0x88))
- {
- u = unmap[m];
- if (color[u] == c1) break;
- if (atk2[u] == 0 || board[u] >= piece) return(false);
- if (color[u] == c2) break;
- m += d;
- }
- }
- else if (piece == pawn)
- {
- if (c1 == white) u = sq+8; else u = sq-8;
- if (color[u] == neutral && atk1[u] >= atk2[u])
- return(false);
- if (!((m = m0+Dir[Dpwn[c1]]) & 0x88))
- if (color[unmap[m]] == c2) return(false);
- if (!((m = m0+Dir[Dpwn[c1]+1]) & 0x88))
- if (color[unmap[m]] == c2) return(false);
- }
- else
- {
- for (i = Dstart[piece]; i <= Dstop[piece]; i++)
- if (!((m = m0+Dir[i]) & 0x88))
- {
- u = unmap[m];
- if (color[u] != c1)
- if (atk2[u] == 0 || board[u] >= piece) return(false);
- }
- }
- return(true);
-}
-#endif
-
-ExaminePosition()
-
-/*
- This is done one time before the search is started. Set up arrays
- Mwpawn, Mbpawn, Mknight, Mbishop, Mking which are used in the
- SqValue() function to determine the positional value of each piece.
-*/
-
-{
-register short i,sq;
-short wpadv,bpadv,wstrong,bstrong,z,side,pp,j,val,Pd,fyle,rank;
-
- wking = PieceList[white][0]; bking = PieceList[black][0];
- ataks(white,atak[white]); ataks(black,atak[black]);
- Zwmtl = Zbmtl = 0;
- UpdateWeights();
- HasPawn[white] = HasPawn[black] = 0;
- HasKnight[white] = HasKnight[black] = 0;
- HasBishop[white] = HasBishop[black] = 0;
- HasRook[white] = HasRook[black] = 0;
- HasQueen[white] = HasQueen[black] = 0;
- for (side = white; side <= black; side++)
- for (i = 0; i <= PieceCnt[side]; i++)
- switch (board[PieceList[side][i]])
- {
- case pawn : ++HasPawn[side]; break;
- case knight : ++HasKnight[side]; break;
- case bishop : ++HasBishop[side]; break;
- case rook : ++HasRook[side]; break;
- case queen : ++HasQueen[side]; break;
- }
- if (!Developed[white])
- Developed[white] = (board[1] != knight && board[2] != bishop &&
- board[5] != bishop && board[6] != knight);
- if (!Developed[black])
- Developed[black] = (board[57] != knight && board[58] != bishop &&
- board[61] != bishop && board[62] != knight);
- if (!PawnStorm && stage < 5)
- PawnStorm = ((column[wking] < 3 && column[bking] > 4) ||
- (column[wking] > 4 && column[bking] < 3));
-
- CopyBoard(pknight,Mknight[white]);
- CopyBoard(pknight,Mknight[black]);
- CopyBoard(pbishop,Mbishop[white]);
- CopyBoard(pbishop,Mbishop[black]);
- BlendBoard(KingOpening,KingEnding,Mking[white]);
- BlendBoard(KingOpening,KingEnding,Mking[black]);
-
- for (sq = 0; sq < 64; sq++)
- {
- fyle = column[sq]; rank = row[sq];
- wstrong = bstrong = true;
- for (i = sq; i < 64; i += 8)
- if (atak[black][i] >= ctlP) wstrong = false;
- for (i = sq; i >= 0; i -= 8)
- if (atak[white][i] >= ctlP) bstrong = false;
- wpadv = bpadv = PADVNCM;
- if ((fyle == 0 || PawnCnt[white][fyle-1] == 0) &&
- (fyle == 7 || PawnCnt[white][fyle+1] == 0)) wpadv = PADVNCI;
- if ((fyle == 0 || PawnCnt[black][fyle-1] == 0) &&
- (fyle == 7 || PawnCnt[black][fyle+1] == 0)) bpadv = PADVNCI;
- Mwpawn[sq] = (wpadv*PawnAdvance[sq]) / 10;
- Mbpawn[sq] = (bpadv*PawnAdvance[63-sq]) / 10;
- Mwpawn[sq] += PawnBonus; Mbpawn[sq] += PawnBonus;
- if (castld[white] || kingmoved[white])
- {
- if ((fyle < 3 || fyle > 4) && distance(sq,wking) < 3)
- Mwpawn[sq] += PAWNSHIELD;
- }
- else if (rank < 3 && (fyle < 2 || fyle > 5))
- Mwpawn[sq] += PAWNSHIELD / 2;
- if (castld[black] || kingmoved[black])
- {
- if ((fyle < 3 || fyle > 4) && distance(sq,bking) < 3)
- Mbpawn[sq] += PAWNSHIELD;
- }
- else if (rank > 4 && (fyle < 2 || fyle > 5))
- Mbpawn[sq] += PAWNSHIELD / 2;
- if (PawnStorm)
- {
- if ((column[wking] < 4 && fyle > 4) ||
- (column[wking] > 3 && fyle < 3)) Mwpawn[sq] += 3*rank - 21;
- if ((column[bking] < 4 && fyle > 4) ||
- (column[bking] > 3 && fyle < 3)) Mbpawn[sq] -= 3*rank;
- }
-
- Mknight[white][sq] += 5 - distance(sq,bking);
- Mknight[white][sq] += 5 - distance(sq,wking);
- Mknight[black][sq] += 5 - distance(sq,wking);
- Mknight[black][sq] += 5 - distance(sq,bking);
- Mbishop[white][sq] += BishopBonus;
- Mbishop[black][sq] += BishopBonus;
- for (i = 0; i <= PieceCnt[black]; i++)
- if (distance(sq,PieceList[black][i]) < 3)
- Mknight[white][sq] += KNIGHTPOST;
- for (i = 0; i <= PieceCnt[white]; i++)
- if (distance(sq,PieceList[white][i]) < 3)
- Mknight[black][sq] += KNIGHTPOST;
- if (wstrong) Mknight[white][sq] += KNIGHTSTRONG;
- if (bstrong) Mknight[black][sq] += KNIGHTSTRONG;
- if (wstrong) Mbishop[white][sq] += BISHOPSTRONG;
- if (bstrong) Mbishop[black][sq] += BISHOPSTRONG;
-
- if (HasBishop[white] == 2) Mbishop[white][sq] += 8;
- if (HasBishop[black] == 2) Mbishop[black][sq] += 8;
- if (HasKnight[white] == 2) Mknight[white][sq] += 5;
- if (HasKnight[black] == 2) Mknight[black][sq] += 5;
-
- if (board[sq] == bishop)
- if (rank % 2 == fyle % 2) KBNKsq = 0; else KBNKsq = 7;
-
- Kfield[white][sq] = Kfield[black][sq] = 0;
- if (distance(sq,wking) == 1) Kfield[black][sq] = KATAK;
- if (distance(sq,bking) == 1) Kfield[white][sq] = KATAK;
-
- Pd = 0;
- for (i = 0; i < 64; i++)
- if (board[i] == pawn)
- {
- if (color[i] == white)
- {
- pp = true;
- if (row[i] == 6) z = i+8; else z = i+16;
- for (j = i+8; j < 64; j += 8)
- if (atak[black][j] > ctlP || board[j] == pawn) pp = false;
- }
- else
- {
- pp = true;
- if (row[i] == 1) z = i-8; else z = i-16;
- for (j = i-8; j >= 0; j -= 8)
- if (atak[white][j] > ctlP || board[j] == pawn) pp = false;
- }
- if (pp) Pd += 5*taxicab(sq,z); else Pd += taxicab(sq,z);
- }
- if (Pd != 0)
- {
- val = (Pd*stage2) / 10;
- Mking[white][sq] -= val;
- Mking[black][sq] -= val;
- }
- }
-}
-
-
-UpdateWeights()
-
-/*
- If material balance has changed, determine the values for the
- positional evaluation terms.
-*/
-
-{
-short tmtl;
-
- if (mtl[white] != Zwmtl || mtl[black] != Zbmtl)
- {
- Zwmtl = mtl[white]; Zbmtl = mtl[black];
- emtl[white] = Zwmtl - pmtl[white] - valueK;
- emtl[black] = Zbmtl - pmtl[black] - valueK;
- tmtl = emtl[white] + emtl[black];
- if (tmtl > 6600) stage = 0;
- else if (tmtl < 1400) stage = 10;
- else stage = (6600-tmtl) / 520;
- if (tmtl > 3600) stage2 = 0;
- else if (tmtl < 1400) stage2 = 10;
- else stage2 = (3600-tmtl) / 220;
-
- PEDRNK2B = -15; /* centre pawn on 2nd rank & blocked */
- PBLOK = -4; /* blocked backward pawn */
- PDOUBLED = -14; /* doubled pawn */
- PWEAKH = -4; /* weak pawn on half open file */
- PAWNSHIELD = 10-stage; /* pawn near friendly king */
- PADVNCM = 10; /* advanced pawn multiplier */
- PADVNCI = 7; /* muliplier for isolated pawn */
- PawnBonus = stage;
-
- KNIGHTPOST = (stage+2)/3; /* knight near enemy pieces */
- KNIGHTSTRONG = (stage+6)/2; /* occupies pawn hole */
-
- BISHOPSTRONG = (stage+6)/2; /* occupies pawn hole */
- BishopBonus = 2*stage;
-
- RHOPN = 10; /* rook on half open file */
- RHOPNX = 4;
- RookBonus = 6*stage;
-
- XRAY = 8; /* Xray attack on piece */
- PINVAL = 10; /* Pin */
-
- KHOPN = (3*stage-30) / 2; /* king on half open file */
- KHOPNX = KHOPN / 2;
- KCASTLD = 10 - stage;
- KMOVD = -40 / (stage+1); /* king moved before castling */
- KATAK = (10-stage) / 2; /* B,R attacks near enemy king */
- if (stage < 8) KSFTY = 16-2*stage; else KSFTY = 0;
-
- ATAKD = -6; /* defender > attacker */
- HUNGP = -8; /* each hung piece */
- HUNGX = -12; /* extra for >1 hung piece */
- }
-}
-
-#if (NEWMOVE < 1)
-int distance(a,b)
-short a,b;
-{
-register short d1,d2;
-
- d1 = abs(column[a]-column[b]);
- d2 = abs(row[a]-row[b]);
- return(d1 > d2 ? d1 : d2);
-}
-#endif
-
-BlendBoard(a,b,c)
-short a[64],b[64],c[64];
-{
-register int sq;
- for (sq = 0; sq < 64; sq++)
- c[sq] = (a[sq]*(10-stage) + b[sq]*stage) / 10;
-}
-
-
-CopyBoard(a,b)
-short a[64],b[64];
-{
-register int sq;
- for (sq = 0; sq < 64; sq++)
- b[sq] = a[sq];
-}
diff --git a/gnu/games/chess/gnuchess.h b/gnu/games/chess/gnuchess.h
deleted file mode 100644
index 6e9c74b..0000000
--- a/gnu/games/chess/gnuchess.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- This file contains code for CHESS.
- Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
-
- This file is part of CHESS.
-
- CHESS 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 CHESS General Public
- License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- CHESS, but only under the conditions described in the
- CHESS General Public License. A copy of this license is
- supposed to have been given to you along with CHESS 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.
-*/
-
-
-/* Header file for GNU CHESS */
-
-#define neutral 2
-#define white 0
-#define black 1
-#define no_piece 0
-#define pawn 1
-#define knight 2
-#define bishop 3
-#define rook 4
-#define queen 5
-#define king 6
-#define pxx " PNBRQK"
-#define qxx " pnbrqk"
-#define rxx "12345678"
-#define cxx "abcdefgh"
-#define check 0x0001
-#define capture 0x0002
-#define draw 0x0004
-#define promote 0x0008
-#define cstlmask 0x0010
-#define epmask 0x0020
-#define exact 0x0040
-#define pwnthrt 0x0080
-#define maxdepth 30
-#define true 1
-#define false 0
-
-struct leaf
- {
- short f,t,score,reply;
- unsigned short flags;
- };
-struct GameRec
- {
- unsigned short gmove;
- short score,depth,time,piece,color;
- long nodes;
- };
-struct TimeControlRec
- {
- short moves[2];
- long clock[2];
- };
-struct BookEntry
- {
- struct BookEntry *next;
- unsigned short *mv;
- };
-
-extern char mvstr1[5],mvstr2[5];
-extern struct leaf Tree[2000],*root;
-extern short TrPnt[maxdepth],board[64],color[64];
-extern short row[64],column[64],locn[8][8];
-extern short atak[2][64],PawnCnt[2][8];
-extern short castld[2],kingmoved[2];
-extern short c1,c2,*atk1,*atk2,*PC1,*PC2;
-extern short mate,post,opponent,computer,Sdepth,Awindow,Bwindow,dither;
-extern long ResponseTime,ExtraTime,Level,et,et0,time0,cputimer,ft;
-extern long NodeCnt,evrate,ETnodes,EvalNodes,HashCnt;
-extern short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beep,meter;
-extern short timeout,xwndw;
-extern struct GameRec GameList[240];
-extern short GameCnt,Game50,epsquare,lpost,rcptr,contempt;
-extern short MaxSearchDepth;
-extern struct BookEntry *Book;
-extern struct TimeControlRec TimeControl;
-extern short TCflag,TCmoves,TCminutes,OperatorTime;
-extern short otherside[3];
-extern short Stboard[64];
-extern short Stcolor[64];
-extern unsigned short hint,PrVar[maxdepth];
-
-#define HZ 60
diff --git a/gnu/games/chess/move.c b/gnu/games/chess/move.c
deleted file mode 100644
index 4ce686c..0000000
--- a/gnu/games/chess/move.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* move generator hes@log-sv.se 890318
- Modified: 890606 NEWMOVE Levels 1-6 for easier debugging */
-#include "move.h"
-#include "gnuchess.h"
-
-short distdata[64][64];
-short taxidata[64][64];
-
-void Initialize_dist() {
-register short a,b,d,di;
-
- /* init taxi and dist data */
- for(a=0;a<64;a++)
- for(b=0;b<64;b++) {
- d = abs(column[a]-column[b]);
- di = abs(row[a]-row[b]);
- taxidata[a][b] = d + di;
- distdata[a][b] = (d > di ? d : di);
- };
-}
-
-#if (NEWMOVE > 1)
-struct sqdata posdata[3][8][64][64];
-
-static short direc[8][8] = {
- 0, 0, 0, 0, 0, 0, 0, 0, /* no_piece = 0 */
- -10,-11, -9, 0, 0, 0, 0, 0, /* wpawn = 1 */
- -21,-19,-12, -8, 21, 19, 12, 8, /* knight = 2 */
- -11, -9, 11, 9, 0, 0, 0, 0, /* bishop = 3 */
- -10, -1, 10, 1, 0, 0, 0, 0, /* rook = 4 */
- -11, -9,-10, -1, 11, 9, 10, 1, /* queen = 5 */
- -11, -9,-10, -1, 11, 9, 10, 1, /* king = 6 */
- 0, 0, 0, 0, 0, 0, 0, 0};/* no_piece = 7 */
-
-static short dc[3] = {-1,1,0};
-
-static short max_steps [8] = {0,2,1,7,7,7,1,0};
-
-static short unmap[120] = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1, 0, 1, 2, 3, 4, 5, 6, 7,-1,
- -1, 8, 9,10,11,12,13,14,15,-1,
- -1,16,17,18,19,20,21,22,23,-1,
- -1,24,25,26,27,28,29,30,31,-1,
- -1,32,33,34,35,36,37,38,39,-1,
- -1,40,41,42,43,44,45,46,47,-1,
- -1,48,49,50,51,52,53,54,55,-1,
- -1,56,57,58,59,60,61,62,63,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
-
-void Initialize_moves() {
- short c,ptyp,po,p0,d,di,s;
- struct sqdata *p;
- short dest[8][8];
- short steps[8];
- short sorted[8];
-
- /* init posdata */
- for(c=0;c<3;c++)
- for(ptyp=0;ptyp<8;ptyp++)
- for(po=0;po<64;po++)
- for(p0=0;p0<64;p0++) {
- posdata[c][ptyp][po][p0].nextpos = po;
- posdata[c][ptyp][po][p0].nextdir = po;
- };
- /* dest is a function of dir and step */
- for(c=0;c<2;c++)
- for(ptyp=1;ptyp<7;ptyp++)
- for(po=21;po<99;po++)
- if (unmap[po] >= 0) {
- p = posdata[c][ptyp][unmap[po]];
- for(d=0;d<8;d++) {
- dest[d][0] = unmap[po];
- if (dc[c]*direc[ptyp][d] != 0) {
- p0=po;
- for(s=0;s<max_steps[ptyp];s++) {
- p0 = p0 + dc[c]*direc[ptyp][d];
- /* break if (off board) or
- (pawns move two steps from home square) */
- if (unmap[p0] < 0 ||
- (ptyp == pawn && s>0 && (d>0 || Stboard[unmap[po]] != ptyp)))
- break;
- else
- dest[d][s] = unmap[p0];
- }
- }
- else s=0;
- /* sort dest in number of steps order */
- steps[d] = s;
- for(di=d;di>0;di--)
- if (steps[sorted[di-1]] < s)
- sorted[di] = sorted[di-1];
- else
- break;
- sorted[di] = d;
- }
- /* update posdata, pawns have two threads (capture and no capture) */
- p0=unmap[po];
- if (ptyp == pawn) {
- for(s=0;s<steps[0];s++) {
- p[p0].nextpos = dest[0][s];
- p0 = dest[0][s];
- }
- p0=unmap[po];
- for(d=1;d<3;d++) {
- p[p0].nextdir = dest[d][0];
- p0 = dest[d][0];
- }
- }
- else {
- p[p0].nextdir = dest[sorted[0]][0];
- for(d=0;d<8;d++)
- for(s=0;s<steps[sorted[d]];s++) {
- p[p0].nextpos = dest[sorted[d]][s];
- p0 = dest[sorted[d]][s];
- if (d < 7)
- p[p0].nextdir = dest[sorted[d+1]][0];
- /* else is already initialised */
- }
- }
-#ifdef DEBUG
- printf("Ptyp:%d Position:%d\n{",ptyp,unmap[po]);
- for(p0=0;p0<63;p0++) printf("%d,",p[p0].nextpos);
- printf("%d};\n",p[63].nextpos);
- for(p0=0;p0<63;p0++) printf("%d,",p[p0].nextdir);
- printf("%d};\n",p[63].nextdir);
-#endif DEBUG
- }
-}
-#endif
-
-
-#if (NEWMOVE > 2)
-int SqAtakd(sq,side)
-short sq,side;
-
-/*
- See if any piece with color 'side' ataks sq. First check pawns
- Then Queen, Bishop, Rook and King and last Knight.
-*/
-
-{
- register short u;
- register struct sqdata *p;
-
- p = posdata[1-side][pawn][sq];
- u = p[sq].nextdir; /* follow captures thread */
- while (u != sq) {
- if (board[u] == pawn && color[u] == side) return(true);
- u = p[u].nextdir;
- }
- /* king capture */
- if (distance(sq,PieceList[side][0]) == 1) return(true);
- /* try a queen bishop capture */
- p = posdata[side][bishop][sq];
- u = p[sq].nextpos;
- while (u != sq) {
- if (color[u] == neutral) {
- u = p[u].nextpos;
- }
- else {
- if (color[u] == side &&
- (board[u] == queen || board[u] == bishop))
- return(true);
- u = p[u].nextdir;
- }
- }
- /* try a queen rook capture */
- p = posdata[side][rook][sq];
- u = p[sq].nextpos;
- while (u != sq) {
- if (color[u] == neutral) {
- u = p[u].nextpos;
- }
- else {
- if (color[u] == side &&
- (board[u] == queen || board[u] == rook))
- return(true);
- u = p[u].nextdir;
- }
- }
- /* try a knight capture */
- p = posdata[side][knight][sq];
- u = p[sq].nextpos;
- while (u != sq) {
- if (color[u] == neutral) {
- u = p[u].nextpos;
- }
- else {
- if (color[u] == side && board[u] == knight) return(true);
- u = p[u].nextdir;
- }
- }
- return(false);
-}
-#endif
-
-#if (NEWMOVE > 3)
-BRscan(sq,s,mob)
-short sq,*s,*mob;
-/*
- Find Bishop and Rook mobility, XRAY attacks, and pins. Increment the
- hung[] array if a pin is found.
-*/
-{
- register short u,piece,pin;
- register struct sqdata *p;
- short *Kf;
-
- Kf = Kfield[c1];
- *mob = 0;
- piece = board[sq];
- p = posdata[color[sq]][piece][sq];
- u = p[sq].nextpos;
- pin = -1; /* start new direction */
- while (u != sq) {
- *s += Kf[u];
- if (color[u] == neutral) {
- (*mob)++;
- if (p[u].nextpos == p[u].nextdir) pin = -1; /* oops new direction */
- u = p[u].nextpos;
- }
- else if (pin < 0) {
- if (board[u] == pawn || board[u] == king)
- u = p[u].nextdir;
- else {
- if (p[u].nextpos != p[u].nextdir)
- pin = u; /* not on the edge and on to find a pin */
- u = p[u].nextpos;
- }
- }
- else if (color[u] == c2 && (board[u] > piece || atk2[u] == 0))
- {
- if (color[pin] == c2)
- {
- *s += PINVAL;
- if (atk2[pin] == 0 ||
- atk1[pin] > control[board[pin]]+1)
- ++hung[c2];
- }
- else *s += XRAY;
- pin = -1; /* new direction */
- u = p[u].nextdir;
- }
- else {
- pin = -1; /* new direction */
- u = p[u].nextdir;
- }
- }
-}
-#endif
-
-#if (NEWMOVE >= 5)
-CaptureList(side,xside,ply)
-short side,xside,ply;
-{
- register short u,sq;
- register struct sqdata *p;
- short i,piece,*PL;
- struct leaf *node;
-
- TrPnt[ply+1] = TrPnt[ply];
- node = &Tree[TrPnt[ply]];
- PL = PieceList[side];
- for (i = 0; i <= PieceCnt[side]; i++)
- {
- sq = PL[i];
- piece = board[sq];
- p = posdata[side][piece][sq];
- if (piece == pawn) {
- u = p[sq].nextdir; /* follow captures thread */
- while (u != sq) {
- if (color[u] == xside) {
- node->f = sq; node->t = u;
- node->flags = capture;
- if (u < 8 || u > 55)
- {
- node->flags |= promote;
- node->score = valueQ;
- }
- else
- node->score = value[board[u]] + svalue[board[u]] - piece;
- ++node;
- ++TrPnt[ply+1];
- }
- u = p[u].nextdir;
- }
- }
- else {
- u = p[sq].nextpos;
- while (u != sq) {
- if (color[u] == neutral)
- u = p[u].nextpos;
- else {
- if (color[u] == xside) {
- node->f = sq; node->t = u;
- node->flags = capture;
- node->score = value[board[u]] + svalue[board[u]] - piece;
- ++node;
- ++TrPnt[ply+1];
- }
- u = p[u].nextdir;
- }
- }
- }
- }
-}
-#endif
-
-#if (NEWMOVE > 5)
-GenMoves(ply,sq,side,xside)
- short ply,sq,side,xside;
-
-/*
- Generate moves for a piece. The moves are taken from the
- precalulated array posdata. If the board is free, next move
- is choosen from nextpos else from nextdir.
-*/
-
-{
- register short u,piece;
- register struct sqdata *p;
-
- piece = board[sq];
- p = posdata[side][piece][sq];
- if (piece == pawn) {
- u = p[sq].nextdir; /* follow captures thread */
- while (u != sq) {
- if (color[u] == xside) LinkMove(ply,sq,u,xside);
- u = p[u].nextdir;
- }
- u = p[sq].nextpos; /* and follow no captures thread */
- while (u != sq) {
- if (color[u] == neutral && (u != sq+16 || color[u-8] == neutral)
- && (u != sq-16 || color[u+8] == neutral)) {
- LinkMove(ply,sq,u,xside);
- }
- u = p[u].nextpos;
- }
- }
- else {
- u = p[sq].nextpos;
- while (u != sq) {
- if (color[u] == neutral) {
- LinkMove(ply,sq,u,xside);
- u = p[u].nextpos;
- }
- else {
- if (color[u] == xside) LinkMove(ply,sq,u,xside);
- u = p[u].nextdir;
- }
- }
- }
-}
-#endif
diff --git a/gnu/games/chess/move.h b/gnu/games/chess/move.h
deleted file mode 100644
index 2f32830..0000000
--- a/gnu/games/chess/move.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* header file for move generator hes 890318
- Modified: 890510 minor bug fixed in Newataks
- 890606 NEWMOVE levels 1-6 */
-
-#if (NEWMOVE >= 1)
-extern short distdata[64][64];
-extern short taxidata[64][64];
-
-#define taxicab(a,b) taxidata[a][b]
-#define distance(a,b) distdata[a][b]
-
-extern void Initialize_dist();
-#endif
-
-#if (NEWMOVE >= 2)
-struct sqdata {
- short nextpos;
- short nextdir;
-};
-extern struct sqdata posdata[3][8][64][64];
-
-extern void Initialize_moves();
-
-#define ataks(side,a)\
-{\
- register short u,c,sq;\
- register struct sqdata *p;\
- short i,piece,*PL;\
- \
- for (u = 64; u; a[--u] = 0); \
- PL = PieceList[side];\
- for (i = 0; i <= PieceCnt[side]; i++)\
- {\
- sq = PL[i];\
- piece = board[sq];\
- c = control[piece];\
- p = posdata[side][piece][sq];\
- if (piece == pawn) {\
- u = p[sq].nextdir; /* follow captures thread */\
- while (u != sq) {\
- a[u] = ++a[u] | c;\
- u = p[u].nextdir;\
- }\
- }\
- else {\
- u = p[sq].nextpos;\
- while (u != sq) {\
- a[u] = ++a[u] | c;\
- if (color[u] == neutral)\
- u = p[u].nextpos;\
- else\
- u = p[u].nextdir;\
- }\
- }\
- }\
-}
-#endif
-
-#if (NEWMOVE >= 3)
-extern short PieceList[2][16];
-
-extern int Sqatakd();
-#endif
-
-#if (NEWMOVE > 3)
-extern short Kfield[2][64],PINVAL,control[7],hung[2],XRAY;
-
-extern BRscan();
-#endif
-
-#if (NEWMOVE > 4)
-#define valueQ 1100
-
-extern short PieceCnt[2],value[7],svalue[64];
-
-extern CaptureList();
-#endif
-
-#if (NEWMOVE > 5)
-extern GenMoves();
-#endif
diff --git a/gnu/games/chess/nondsp.c b/gnu/games/chess/nondsp.c
deleted file mode 100644
index 0b29ad5..0000000
--- a/gnu/games/chess/nondsp.c
+++ /dev/null
@@ -1,791 +0,0 @@
-/*
- UNIX & MSDOS NON-DISPLAY, AND CHESSTOOL interface for Chess
-
- Revision: 4-25-88
-
- Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
- Copyright (c) 1988 John Stanback
-
- This file is part of CHESS.
-
- CHESS 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 CHESS General Public
- License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- CHESS, but only under the conditions described in the
- CHESS General Public License. A copy of this license is
- supposed to have been given to you along with CHESS 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.
-*/
-
-
-#include <stdio.h>
-#include <ctype.h>
-#ifdef MSDOS
-#include <dos.h>
-#include <stdlib.h>
-#include <time.h>
-#else
-#include <sys/param.h>
-#include <sys/times.h>
-#include <sys/file.h>
-struct tms tmbuf1,tmbuf2;
-int TerminateSearch(),Die();
-#endif MSDOS
-
-#include "gnuchess.h"
-#ifdef NEWMOVE
-#include "move.h"
-#endif
-
-#define printz printf
-#define scanz scanf
-int mycnt1,mycnt2;
-
-
-Initialize()
-{
- mycnt1 = mycnt2 = 0;
-#ifndef MSDOS
-#endif
-#ifdef CHESSTOOL
- setlinebuf(stdout);
-/*
- setvbuf(stdout,NULL,_IOLBF,BUFSIZ);
-*/
- printf("Chess\n");
- if (Level == 0 && !TCflag) Level = 15;
-#endif CHESSTOOL
-}
-
-ExitChess()
-{
- ListGame();
- exit(0);
-}
-
-#ifndef MSDOS
-Die()
-{
-char s[80];
- printz("Abort? ");
- scanz("%s",s);
- if (strcmp(s,"yes") == 0) ExitChess();
-}
-
-TerminateSearch()
-{
- timeout = true;
- bothsides = false;
-}
-#endif MSDOS
-
-
-InputCommand()
-
-/*
- Process the users command. If easy mode is OFF (the computer is
- thinking on opponents time) and the program is out of book, then make
- the 'hint' move on the board and call SelectMove() to find a response.
- The user terminates the search by entering ^C (quit siqnal) before
- entering a command. If the opponent does not make the hint move, then
- set Sdepth to zero.
-*/
-
-{
-int i;
-short ok,tmp;
-long cnt,rate,t1,t2;
-unsigned short mv;
-char s[80];
-
- ok = quit = false;
- player = opponent;
- ft = 0;
- if (hint > 0 && !easy && Book == NULL)
- {
- fflush(stdout);
- time0 = time((long *)0);
- algbr(hint>>8,hint & 0xFF,false);
- strcpy(s,mvstr1);
- tmp = epsquare;
- if (VerifyMove(s,1,&mv))
- {
- SelectMove(computer,2);
- VerifyMove(mvstr1,2,&mv);
- if (Sdepth > 0) Sdepth--;
- }
- ft = time((long *)0) - time0;
- epsquare = tmp;
- }
-
-#ifndef MSDOS
-#endif
- while (!(ok || quit))
- {
- PromptForMove();
- i = scanz("%s",s);
- if (i == EOF || s[0] == 0) ExitChess();
- player = opponent;
- ok = VerifyMove(s,0,&mv);
- if (ok && mv != hint)
- {
- Sdepth = 0;
- ft = 0;
- }
-
- if (strcmp(s,"bd") == 0)
- {
- ClrScreen();
- UpdateDisplay(0,0,1,0);
- }
- if (strcmp(s,"quit") == 0) quit = true;
- if (strcmp(s,"post") == 0) post = !post;
- if (strcmp(s,"set") == 0) EditBoard();
- if (strcmp(s,"go") == 0) ok = true;
- if (strcmp(s,"help") == 0) help();
- if (strcmp(s,"force") == 0) force = !force;
- if (strcmp(s,"book") == 0) Book = NULL;
- if (strcmp(s,"new") == 0) NewGame();
- if (strcmp(s,"list") == 0) ListGame();
- if (strcmp(s,"level") == 0) SelectLevel();
- if (strcmp(s,"hash") == 0) hashflag = !hashflag;
- if (strcmp(s,"beep") == 0) beep = !beep;
- if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
- if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
- if (strcmp(s,"rcptr") == 0) rcptr = !rcptr;
- if (strcmp(s,"hint") == 0) GiveHint();
- if (strcmp(s,"zero") == 0) ZeroTTable();
- if (strcmp(s,"both") == 0)
- {
- bothsides = !bothsides;
- Sdepth = 0;
- SelectMove(opponent,1);
- ok = true;
- }
- if (strcmp(s,"reverse") == 0)
- {
- reverse = !reverse;
- ClrScreen();
- UpdateDisplay(0,0,1,0);
- }
- if (strcmp(s,"switch") == 0)
- {
- computer = otherside[computer];
- opponent = otherside[opponent];
- force = false;
- Sdepth = 0;
- ok = true;
- }
- if (strcmp(s,"white") == 0)
- {
- computer = white; opponent = black;
- ok = true; force = false;
- Sdepth = 0;
- }
- if (strcmp(s,"black") == 0)
- {
- computer = black; opponent = white;
- ok = true; force = false;
- Sdepth = 0;
- }
- if (strcmp(s,"undo") == 0 && GameCnt >= 0) Undo();
- if (strcmp(s,"remove") == 0 && GameCnt >= 1)
- {
- Undo(); Undo();
- }
- if (strcmp(s,"get") == 0) GetGame();
- if (strcmp(s,"save") == 0) SaveGame();
- if (strcmp(s,"depth") == 0) ChangeSearchDepth();
- if (strcmp(s,"random") == 0) dither = 6;
- if (strcmp(s,"easy") == 0) easy = !easy;
- if (strcmp(s,"contempt") == 0) SetContempt();
- if (strcmp(s,"xwndw") == 0) ChangeXwindow();
- if (strcmp(s,"test") == 0)
- {
- t1 = time(0);
- cnt = 0;
- for (i = 0; i < 10000; i++)
- {
- MoveList(opponent,2);
- cnt += TrPnt[3] - TrPnt[2];
- }
- t2 = time(0);
- rate = cnt / (t2-t1);
- printz("cnt= %ld rate= %ld\n",cnt,rate);
- }
- }
-
- ElapsedTime(1);
- if (force)
- {
- computer = opponent; opponent = otherside[computer];
- }
-#ifndef MSDOS
- (void) times(&tmbuf1);
-#ifdef CHESSTOOL
- printf("%d. %s\n",++mycnt2,s);
-#endif CHESSTOOL
-#endif MSDOS
-}
-
-
-help()
-{
- ClrScreen();
- printz("CHESS command summary\n");
- printz("g1f3 move from g1 to f3\n");
- printz("nf3 move knight to f3\n");
- printz("o-o castle king side\n");
- printz("o-o-o castle queen side\n");
- printz("set edit board\n");
- printz("switch sides with computer\n");
- printz("white computer plays white\n");
- printz("black computer plays black\n");
- printz("reverse board display\n");
- printz("both computer match\n");
- printz("random randomize play\n");
- printz("undo undo last move\n");
- printz("time change level\n");
- printz("depth set search depth\n");
- printz("post principle variation\n");
- printz("hint suggest a move\n");
- printz("bd redraw board\n");
- printz("clock set time control\n");
- printz("force enter game moves\n");
- printz("list game to chess.lst\n");
- printz("save game to file\n");
- printz("get game from file\n");
- printz("new start new game\n");
- printz("quit exit CHESS\n");
- printz("Computer: ");
- if (computer == white) printz("WHITE\n"); else printz("BLACK\n");
- printz("Opponent: ");
- if (opponent == white) printz("WHITE\n"); else printz("BLACK\n");
- printz("Response time: %ld",Level," sec.\n");
- printz("Easy mode: ");
- if (easy) printz("ON\n"); else printz("OFF\n");
- printz("Depth: %d\n",MaxSearchDepth);
- printz("Random: ");
- if (dither) printz("ON\n"); else printz("OFF\n");
- printz("Transposition table: ");
- if (hashflag) printz("ON\n"); else printz("OFF\n");
- UpdateDisplay(0,0,1,0);
-}
-
-
-EditBoard()
-
-/*
- Set up a board position. Pieces are entered by typing the piece
- followed by the location. For example, Nf3 will place a knight on
- square f3.
-*/
-
-{
-short a,r,c,sq;
-char s[80];
-
- ClrScreen();
- UpdateDisplay(0,0,1,0);
- printz(". exit to main\n");
- printz("# clear board\n");
- printz("enter piece & location: \n");
-
- a = white;
- do
- {
- scanz("%s",s);
- if (s[0] == '#')
- {
- for (sq = 0; sq < 64; sq++)
- {
- board[sq] = no_piece; color[sq] = neutral;
- }
- UpdateDisplay(0,0,1,0);
- }
- if (s[0] == 'c' || s[0] == 'C') a = otherside[a];
- c = s[1]-'a'; r = s[2]-'1';
- if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
- {
- sq = locn[r][c];
- color[sq] = a;
- if (s[0] == 'p') board[sq] = pawn;
- else if (s[0] == 'n') board[sq] = knight;
- else if (s[0] == 'b') board[sq] = bishop;
- else if (s[0] == 'r') board[sq] = rook;
- else if (s[0] == 'q') board[sq] = queen;
- else if (s[0] == 'k') board[sq] = king;
- else { board[sq] = no_piece; color[sq] = neutral; }
- }
- }
- while (s[0] != '.');
- if (board[4] != king) kingmoved[white] = 10;
- if (board[60] != king) kingmoved[black] = 10;
- GameCnt = -1; Game50 = 0; Sdepth = 0;
- InitializeStats();
- ClrScreen();
- UpdateDisplay(0,0,1,0);
-}
-
-
-ShowDepth(ch)
-char ch;
-{
-}
-
-ShowResults(score,bstline,ch)
-short score;
-unsigned short bstline[];
-char ch;
-{
-#ifndef CHESSTOOL
-register int i;
- printz("%2d%c %5d %4ld %7ld ",Sdepth,ch,score,et,NodeCnt);
- for (i = 1; bstline[i] > 0; i++)
- {
- algbr((short)(bstline[i] >> 8),(short)(bstline[i] & 0xFF),false);
- if (i == 9 || i == 17) printz("\n ");
- printz("%5s ",mvstr1);
- }
- printz("\n");
-#endif
-}
-
-
-SearchStartStuff(side)
-short side;
-{
-#ifndef MSDOS
-#endif
-#ifndef CHESSTOOL
- printz("\nMove# %d Target= %ld Clock: %ld\n",
- TCmoves-TimeControl.moves[side]+1,
- ResponseTime,TimeControl.clock[side]);
-#endif
-}
-
-
-OutputMove()
-{
-#ifdef CHESSTOOL
- printz("%d. ... %s\n",++mycnt1,mvstr1);
- if (root->flags & draw)
- {
- printz("Draw\n");
- ListGame();
- exit(0);
- }
- if (root->score == -9999)
- {
- if (opponent == white) printz("White\n"); else printz("Black\n");
- ListGame();
- exit(0);
- }
- if (root->score == 9998)
- {
- if (computer == white) printz("White\n"); else printz("Black\n");
- ListGame();
- exit(0);
- }
-#else
- printz("Nodes= %ld Eval= %ld Hash= %ld Rate= %ld ",
- NodeCnt,EvalNodes,HashCnt,evrate);
- printz("CPU= %.2ld:%.2ld.%.2ld\n\n",
- cputimer/6000,(cputimer % 6000)/100,cputimer % 100);
-
- if (root->flags & epmask) UpdateDisplay(0,0,1,0);
- else UpdateDisplay(root->f,root->t,0,root->flags & cstlmask);
- printz("My move is: %s\n\n",mvstr1);
- if (beep) printz("%c",7);
-
- if (root->flags & draw) printz("Draw game!\n");
- else if (root->score == -9999) printz("opponent mates!\n");
- else if (root->score == 9998) printz("computer mates!\n");
- else if (root->score < -9000) printz("opponent will soon mate!\n");
- else if (root->score > 9000) printz("computer will soon mate!\n");
-#endif CHESSTOOL
-}
-
-
-ElapsedTime(iop)
-short iop;
-
-/*
- Determine the time that has passed since the search was started. If
- the elapsed time exceeds the target (ResponseTime+ExtraTime) then set
- timeout to true which will terminate the search.
-*/
-
-{
- et = time((long *)0) - time0;
- if (et < 0) et = 0;
- ETnodes += 50;
- if (et > et0 || iop == 1)
- {
- if (et > ResponseTime+ExtraTime && Sdepth > 1) timeout = true;
- et0 = et;
- if (iop == 1)
- {
- time0 = time((long *)0); et0 = 0;
- }
-#ifdef MSDOS
- cputimer = 100*et;
- if (et > 0) evrate = NodeCnt/(et+ft); else evrate = 0;
- if (kbhit() && Sdepth > 1)
- {
- timeout = true;
- bothsides = false;
- }
-#else
- (void) times(&tmbuf2);
- cputimer = 100*(tmbuf2.tms_utime - tmbuf1.tms_utime) / HZ;
- if (cputimer > 0) evrate = (100*NodeCnt)/(cputimer+100*ft);
- else evrate = 0;
-#endif MSDOS
- ETnodes = NodeCnt + 50;
- }
-}
-
-
-SetTimeControl()
-{
- if (TCflag)
- {
- TimeControl.moves[white] = TimeControl.moves[black] = TCmoves;
- TimeControl.clock[white] = TimeControl.clock[black] = 60*(long)TCminutes;
- }
- else
- {
- TimeControl.moves[white] = TimeControl.moves[black] = 0;
- TimeControl.clock[white] = TimeControl.clock[black] = 0;
- Level = 60*(long)TCminutes;
- }
- et = 0;
- ElapsedTime(1);
-}
-
-
-ClrScreen()
-{
-#ifndef CHESSTOOL
- printz("\n");
-#endif
-}
-
-
-UpdateDisplay(f,t,flag,iscastle)
-short f,t,flag,iscastle;
-{
-#ifndef CHESSTOOL
-short r,c,l;
- if (flag)
- {
- printz("\n");
- for (r = 7; r >= 0; r--)
- {
- for (c = 0; c <= 7; c++)
- {
- if (reverse) l = locn[7-r][7-c]; else l = locn[r][c];
- if (color[l] == neutral) printz(" -");
- else if (color[l] == white) printz(" %c",qxx[board[l]]);
- else printz(" %c",pxx[board[l]]);
- }
- printz("\n");
- }
- printz("\n");
- }
-#endif CHESSTOOL
-}
-
-
-GetOpenings()
-
-/*
- Read in the Opening Book file and parse the algebraic notation for a
- move into an unsigned integer format indicating the from and to
- square. Create a linked list of opening lines of play, with
- entry->next pointing to the next line and entry->move pointing to a
- chunk of memory containing the moves. More Opening lines of up to 256
- half moves may be added to gnuchess.book.
-*/
-
-{
-FILE *fd;
-int c,i,j,side;
-char buffr[2048];
-struct BookEntry *entry;
-unsigned short mv,*mp,tmp[100];
-
- if ((fd = fopen("gnuchess.book","r")) != NULL)
- {
-/*
- setvbuf(fd,buffr,_IOFBF,2048);
-*/
- Book = NULL;
- i = 0; side = white;
- while ((c = parse(fd,&mv,side)) >= 0)
- if (c == 1)
- {
- tmp[++i] = mv;
- side = otherside[side];
- }
- else if (c == 0 && i > 0)
- {
- entry = (struct BookEntry *)malloc(sizeof(struct BookEntry));
- mp = (unsigned short *)malloc((i+1)*sizeof(unsigned short));
- entry->mv = mp;
- entry->next = Book;
- Book = entry;
- for (j = 1; j <= i; j++) *(mp++) = tmp[j];
- *mp = 0;
- i = 0; side = white;
- }
- fclose(fd);
- }
-}
-
-
-int parse(fd,mv,side)
-FILE *fd;
-unsigned short *mv;
-short side;
-{
-int c,i,r1,r2,c1,c2;
-char s[100];
- while ((c = getc(fd)) == ' ');
- i = 0; s[0] = c;
- while (c != ' ' && c != '\n' && c != EOF) s[++i] = c = getc(fd);
- s[++i] = '\0';
- if (c == EOF) return(-1);
- if (s[0] == '!' || i < 3)
- {
- while (c != '\n' && c != EOF) c = getc(fd);
- return(0);
- }
- if (s[4] == 'o')
- if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
- else if (s[0] == 'o')
- if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
- else
- {
- c1 = s[0] - 'a'; r1 = s[1] - '1';
- c2 = s[2] - 'a'; r2 = s[3] - '1';
- *mv = (locn[r1][c1]<<8) + locn[r2][c2];
- }
- return(1);
-}
-
-
-GetGame()
-{
-FILE *fd;
-char fname[40];
-int c;
-short sq;
-unsigned short m;
-
- printz("Enter file name: ");
- scanz("%s",fname);
- if (fname[0] == '\0') strcpy(fname,"chess.000");
- if ((fd = fopen(fname,"r")) != NULL)
- {
- fscanf(fd,"%hd%hd%hd",&computer,&opponent,&Game50);
- fscanf(fd,"%hd%hd%hd%hd",
- &castld[white],&castld[black],
- &kingmoved[white],&kingmoved[black]);
- fscanf(fd,"%hd%hd",&TCflag,&OperatorTime);
- fscanf(fd,"%ld%ld%hd%hd",
- &TimeControl.clock[white],&TimeControl.clock[black],
- &TimeControl.moves[white],&TimeControl.moves[black]);
- for (sq = 0; sq < 64; sq++)
- {
- fscanf(fd,"%hd",&m);
- board[sq] = (m >> 8); color[sq] = (m & 0xFF);
- if (color[sq] == 0) color[sq] = neutral; else --color[sq];
- }
- GameCnt = -1; c = '?';
- while (c != EOF)
- {
- ++GameCnt;
- c = fscanf(fd,"%hd%hd%hd%ld%hd%hd%hd",&GameList[GameCnt].gmove,
- &GameList[GameCnt].score,&GameList[GameCnt].depth,
- &GameList[GameCnt].nodes,&GameList[GameCnt].time,
- &GameList[GameCnt].piece,&GameList[GameCnt].color);
- if (GameList[GameCnt].color == 0) GameList[GameCnt].color = neutral;
- else --GameList[GameCnt].color;
- }
- GameCnt--;
- if (TimeControl.clock[white] > 0) TCflag = true;
- computer--; opponent--;
- }
- fclose(fd);
- InitializeStats();
- UpdateDisplay(0,0,1,0);
- Sdepth = 0;
-}
-
-
-SaveGame()
-{
-FILE *fd;
-char fname[40];
-short sq,i,c;
-
- printz("Enter file name: ");
- scanz("%s",fname);
-
- if (fname[0] == '\0' || access(fname,W_OK) == -1) strcpy(fname,"chess.000");
- fd = fopen(fname,"w");
- fprintf(fd,"%d %d %d\n",computer+1,opponent+1,Game50);
- fprintf(fd,"%d %d %d %d\n",
- castld[white],castld[black],kingmoved[white],kingmoved[black]);
- fprintf(fd,"%d %d\n",TCflag,OperatorTime);
- fprintf(fd,"%ld %ld %d %d\n",
- TimeControl.clock[white],TimeControl.clock[black],
- TimeControl.moves[white],TimeControl.moves[black]);
- for (sq = 0; sq < 64; sq++)
- {
- if (color[sq] == neutral) c = 0; else c = color[sq]+1;
- fprintf(fd,"%d\n",256*board[sq] + c);
- }
- for (i = 0; i <= GameCnt; i++)
- {
- if (GameList[i].color == neutral) c = 0;
- else c = GameList[i].color + 1;
- fprintf(fd,"%d %d %d %ld %d %d %d\n",
- GameList[i].gmove,GameList[i].score,GameList[i].depth,
- GameList[i].nodes,GameList[i].time,
- GameList[i].piece,c);
- }
- fclose(fd);
-}
-
-
-ListGame()
-{
-FILE *fd;
-short i,f,t;
- fd = fopen("chess.lst","w");
- fprintf(fd,"\n");
- fprintf(fd," score depth nodes time ");
- fprintf(fd," score depth nodes time\n");
- for (i = 0; i <= GameCnt; i++)
- {
- f = GameList[i].gmove>>8; t = (GameList[i].gmove & 0xFF);
- algbr(f,t,false);
- if ((i % 2) == 0) fprintf(fd,"\n"); else fprintf(fd," ");
- fprintf(fd,"%5s %5d %2d %6ld %5d",mvstr1,
- GameList[i].score,GameList[i].depth,
- GameList[i].nodes,GameList[i].time);
- }
- fprintf(fd,"\n\n");
- fclose(fd);
-}
-
-
-Undo()
-
-/*
- Undo the most recent half-move.
-*/
-
-{
-short f,t;
- f = GameList[GameCnt].gmove>>8;
- t = GameList[GameCnt].gmove & 0xFF;
- if (board[t] == king && distance(t,f) > 1)
- castle(GameList[GameCnt].color,f,t,2);
- else
- {
- board[f] = board[t]; color[f] = color[t];
- board[t] = GameList[GameCnt].piece;
- color[t] = GameList[GameCnt].color;
- if (board[f] == king) --kingmoved[color[f]];
- }
- if (TCflag) ++TimeControl.moves[color[f]];
- GameCnt--; mate = false; Sdepth = 0;
- UpdateDisplay(0,0,1,0);
- InitializeStats();
-}
-
-
-ShowMessage(s)
-char *s;
-{
-#ifndef CHESSTOOL
- printz("%s\n");
-#endif CHESSTOOL
-}
-
-ShowSidetomove()
-{
-}
-
-PromptForMove()
-{
-#ifndef CHESSTOOL
- printz("\nYour move is? ");
-#endif CHESSTOOL
-}
-
-
-ShowCurrentMove(pnt,f,t)
-short pnt,f,t;
-{
-}
-
-ChangeAlphaWindow()
-{
- printz("window: ");
- scanz("%hd",&Awindow);
-}
-
-ChangeBetaWindow()
-{
- printz("window: ");
- scanz("%hd",&Bwindow);
-}
-
-GiveHint()
-{
- algbr((short)(hint>>8),(short)(hint & 0xFF),false);
- printz("try %s\n",mvstr1);
-}
-
-
-SelectLevel()
-{
- OperatorTime = 30000;
- printz("Enter #moves #minutes: ");
- scanz("%hd %hd",&TCmoves,&TCminutes);
- printz("Operator time= ");
- scanz("%hd",&OperatorTime);
- TCflag = (TCmoves > 1);
- SetTimeControl();
-}
-
-
-ChangeSearchDepth()
-{
- printz("depth= ");
- scanz("%hd",&MaxSearchDepth);
-}
-
-SetContempt()
-{
- printz("contempt= ");
- scanz("%hd",&contempt);
-}
-
-ChangeXwindow()
-{
- printz("xwndw= ");
- scanz("%hd",&xwndw);
-}
diff --git a/gnu/games/chess/pathnames.h b/gnu/games/chess/pathnames.h
deleted file mode 100644
index b70a0f0..0000000
--- a/gnu/games/chess/pathnames.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pathnames.h 5.1 (Berkeley) 5/2/90
- */
-
-#define _PATH_CHESSBOOK "/usr/share/games/gnuchess.book"
diff --git a/gnu/games/chess/uxdsp.c b/gnu/games/chess/uxdsp.c
deleted file mode 100644
index d584738..0000000
--- a/gnu/games/chess/uxdsp.c
+++ /dev/null
@@ -1,933 +0,0 @@
-/*
- ALPHA interface for CHESS
-
- Revision: 4-25-88
-
- Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
- Copyright (c) 1988 John Stanback
-
- This file is part of CHESS.
-
- CHESS 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 CHESS General Public
- License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- CHESS, but only under the conditions described in the
- CHESS General Public License. A copy of this license is
- supposed to have been given to you along with CHESS 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.
-*/
-
-
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/param.h>
-#include <sys/times.h>
-#include <sys/file.h>
-#include <curses.h>
-#include <signal.h>
-#include "gnuchess.h"
-#ifdef NEWMOVE
-#include "move.h"
-#endif
-#include "pathnames.h"
-
-struct tms tmbuf1,tmbuf2;
-void TerminateSearch(),Die();
-
-#define scanz fflush(stdout),scanw
-#define printz printw
-
-
-Initialize()
-{
- signal(SIGINT,Die); signal(SIGQUIT,Die);
- initscr();
- crmode();
-}
-
-
-ExitChess()
-{
- nocrmode();
- endwin();
- exit(0);
-}
-
-
-void
-Die()
-{
-char s[80];
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
- ShowMessage("Abort? ");
- scanz("%s",s);
- if (strcmp(s,"yes") == 0) ExitChess();
- signal(SIGINT,Die); signal(SIGQUIT,Die);
-}
-
-
-void
-TerminateSearch()
-{
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
- timeout = true;
- bothsides = false;
- signal(SIGINT,Die); signal(SIGQUIT,Die);
-}
-
-
-InputCommand()
-
-/*
- Process the users command. If easy mode is OFF (the computer is
- thinking on opponents time) and the program is out of book, then make
- the 'hint' move on the board and call SelectMove() to find a response.
- The user terminates the search by entering ^C (quit siqnal) before
- entering a command. If the opponent does not make the hint move, then
- set Sdepth to zero.
-*/
-
-{
-short ok,i,tmp;
-long cnt,rate,t1,t2;
-unsigned short mv;
-char s[80];
-
- ok = quit = false;
- player = opponent;
- ShowSidetomove();
- ft = 0;
- if (hint > 0 && !easy && Book == NULL)
- {
- fflush(stdout);
- time0 = time((long *)0);
- algbr(hint>>8,hint & 0xFF,false);
- strcpy(s,mvstr1);
- tmp = epsquare;
- if (VerifyMove(s,1,&mv))
- {
- PromptForMove();
- SelectMove(computer,2);
- VerifyMove(mvstr1,2,&mv);
- if (Sdepth > 0) Sdepth--;
- }
- ft = time((time_t *)0) - time0;
- epsquare = tmp;
- }
-
- signal(SIGINT,Die); signal(SIGQUIT,Die);
- while (!(ok || quit))
- {
- PromptForMove();
- scanz("%s",s);
- player = opponent;
- ok = VerifyMove(s,0,&mv);
- if (ok && mv != hint)
- {
- Sdepth = 0;
- ft = 0;
- }
-
- if (strcmp(s,"bd") == 0)
- {
- ClrScreen();
- UpdateDisplay(0,0,1,0);
- }
- if (strcmp(s,"quit") == 0) quit = true;
- if (strcmp(s,"post") == 0) post = !post;
- if (strcmp(s,"edit") == 0) EditBoard();
- if (strcmp(s,"go") == 0) ok = true;
- if (strcmp(s,"help") == 0) help();
- if (strcmp(s,"force") == 0) force = !force;
- if (strcmp(s,"book") == 0) Book = NULL;
- if (strcmp(s,"undo") == 0 && GameCnt >= 0) Undo();
- if (strcmp(s,"new") == 0) NewGame();
- if (strcmp(s,"list") == 0) ListGame();
- if (strcmp(s,"level") == 0) SelectLevel();
- if (strcmp(s,"hash") == 0) hashflag = !hashflag;
- if (strcmp(s,"beep") == 0) beep = !beep;
- if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
- if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
- if (strcmp(s,"hint") == 0) GiveHint();
- if (strcmp(s,"both") == 0)
- {
- bothsides = !bothsides;
- Sdepth = 0;
- SelectMove(opponent,1);
- ok = true;
- }
- if (strcmp(s,"reverse") == 0)
- {
- reverse = !reverse;
- ClrScreen();
- UpdateDisplay(0,0,1,0);
- }
- if (strcmp(s,"switch") == 0)
- {
- computer = otherside[computer];
- opponent = otherside[opponent];
- force = false;
- Sdepth = 0;
- ok = true;
- }
- if (strcmp(s,"white") == 0)
- {
- computer = white; opponent = black;
- ok = true; force = false;
- Sdepth = 0;
- }
- if (strcmp(s,"black") == 0)
- {
- computer = black; opponent = white;
- ok = true; force = false;
- Sdepth = 0;
- }
- if (strcmp(s,"remove") == 0 && GameCnt >= 1)
- {
- Undo(); Undo();
- }
- if (strcmp(s,"get") == 0) GetGame();
- if (strcmp(s,"save") == 0) SaveGame();
- if (strcmp(s,"depth") == 0) ChangeSearchDepth();
- if (strcmp(s,"random") == 0) dither = 6;
- if (strcmp(s,"easy") == 0) easy = !easy;
- if (strcmp(s,"contempt") == 0) SetContempt();
- if (strcmp(s,"xwndw") == 0) ChangeXwindow();
- if (strcmp(s,"test") == 0)
- {
- t1 = time(0);
- cnt = 0;
- for (i = 0; i < 10000; i++)
- {
- MoveList(opponent,2);
- cnt += TrPnt[3] - TrPnt[2];
- }
- t2 = time(0);
- rate = cnt / (t2-t1);
- gotoXY(50,24);
- printz("cnt= %ld rate= %ld",cnt,rate);
- ClrEoln();
- }
- if (strcmp(s,"p") == 0) ShowPostnValues();
- if (strcmp(s,"debug") == 0) DoDebug();
- }
-
- ClearMessage();
- ElapsedTime(1);
- if (force)
- {
- computer = opponent; opponent = otherside[computer];
- }
- (void) times(&tmbuf1);
- signal(SIGINT,TerminateSearch); signal(SIGQUIT,TerminateSearch);
-}
-
-
-EditBoard()
-
-/*
- Set up a board position. Pieces are entered by typing the piece
- followed by the location. For example, Nf3 will place a knight on
- square f3.
-*/
-
-{
-short a,r,c,sq;
-char s[80];
-
- ClrScreen();
- UpdateDisplay(0,0,1,0);
- gotoXY(50,2); printz(". Exit to main");
- gotoXY(50,3); printz("# Clear board");
- gotoXY(49,5); printz("Enter piece & location: ");
- a = white;
- do
- {
- gotoXY(73,5); ClrEoln(); scanz("%s",s);
- if (s[0] == '#')
- {
- for (sq = 0; sq < 64; sq++)
- {
- board[sq] = no_piece; color[sq] = neutral;
- }
- UpdateDisplay(0,0,1,0);
- }
- if (s[0] == 'c' || s[0] == 'C') a = otherside[a];
- c = s[1]-'a'; r = s[2]-'1';
- if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
- {
- sq = locn[r][c];
- color[sq] = a;
- if (s[0] == 'p') board[sq] = pawn;
- else if (s[0] == 'n') board[sq] = knight;
- else if (s[0] == 'b') board[sq] = bishop;
- else if (s[0] == 'r') board[sq] = rook;
- else if (s[0] == 'q') board[sq] = queen;
- else if (s[0] == 'k') board[sq] = king;
- else { board[sq] = no_piece; color[sq] = neutral; }
- DrawPiece(sq);
- }
- }
- while (s[0] != '.');
- if (board[4] != king) kingmoved[white] = 10;
- if (board[60] != king) kingmoved[black] = 10;
- GameCnt = -1; Game50 = 0; Sdepth = 0;
- InitializeStats();
- ClrScreen();
- UpdateDisplay(0,0,1,0);
-}
-
-
-help()
-{
- ClrScreen();
- gotoXY(28,1); printz("CHESS command summary");
- gotoXY(1,3); printz("g1f3 move from g1 to f3");
- gotoXY(1,4); printz("nf3 move knight to f3");
- gotoXY(1,5); printz("o-o castle king side");
- gotoXY(1,6); printz("o-o-o castle queen side");
- gotoXY(1,7); printz("edit edit board");
- gotoXY(1,8); printz("switch sides with computer");
- gotoXY(1,9); printz("white computer plays white");
- gotoXY(1,10); printz("black computer plays black");
- gotoXY(1,11); printz("reverse board display");
- gotoXY(1,12); printz("both computer match");
- gotoXY(1,13); printz("random randomize play");
- gotoXY(1,14); printz("undo undo last move");
- gotoXY(42,3); printz("level change level");
- gotoXY(42,4); printz("depth set search depth");
- gotoXY(42,5); printz("post principle variation");
- gotoXY(42,6); printz("hint suggest a move");
- gotoXY(42,7); printz("bd redraw board");
- gotoXY(42,8); printz("force enter game moves");
- gotoXY(42,9); printz("list game to chess.lst");
- gotoXY(42,10); printz("save game to file");
- gotoXY(42,11); printz("get game from file");
- gotoXY(42,12); printz("new start new game");
- gotoXY(42,13); printz("quit exit CHESS");
- gotoXY(10,21); printz("Computer: ");
- if (computer == white) printz("WHITE"); else printz("BLACK");
- gotoXY(10,22); printz("Opponent: ");
- if (opponent == white) printz("WHITE"); else printz("BLACK");
- gotoXY(10,23); printz("Level: %ld",Level," sec.");
- gotoXY(10,24); printz("Easy mode: ");
- if (easy) printz("ON"); else printz("OFF");
- gotoXY(40,21); printz("Depth: %d",MaxSearchDepth);
- gotoXY(40,22); printz("Random: ");
- if (dither) printz("ON"); else printz("OFF");
- gotoXY(40,23); printz("Transposition table: ");
- if (hashflag) printz("ON"); else printz("OFF");
- refresh();
- while (getchar() != 27);
- ClrScreen();
- UpdateDisplay(0,0,1,0);
-}
-
-
-ShowDepth(ch)
-char ch;
-{
- gotoXY(50,4); printz("Depth= %d%c ",Sdepth,ch); ClrEoln();
-}
-
-
-ShowResults(score,bstline,ch)
-short score;
-unsigned short bstline[];
-char ch;
-{
-short d,e,ply;
- if (post && player == computer)
- {
- e = lpost;
- gotoXY(50,5); printz("Score= %d",score); ClrEoln();
- d = 8; gotoXY(50,d); ClrEoln();
- for (ply = 1; bstline[ply] > 0; ply++)
- {
- algbr(bstline[ply] >> 8,bstline[ply] & 0xFF,false);
- if (ply == 5 || ply == 9 || ply == 13 || ply == 17)
- {
- gotoXY(50,++d); ClrEoln();
- }
- printz("%5s ",mvstr1);
- }
- ClrEoln();
- lpost = d;
- while (++d <= e)
- {
- gotoXY(50,d); ClrEoln();
- }
- }
-}
-
-
-SearchStartStuff(side)
-short side;
-{
-short i;
- signal(SIGINT,TerminateSearch); signal(SIGQUIT,TerminateSearch);
- if (player == computer)
- for (i = 5; i < 14; i++)
- {
- gotoXY(50,i); ClrEoln();
- }
-}
-
-
-OutputMove()
-{
- if (root->flags & epmask) UpdateDisplay(0,0,1,0);
- else UpdateDisplay(root->f,root->t,0,root->flags & cstlmask);
- gotoXY(50,17); printz("My move is: %s",mvstr1);
- if (beep) putchar(7);
- ClrEoln();
-
- gotoXY(50,24);
- if (root->flags & draw) printz("Draw game!");
- else if (root->score == -9999) printz("opponent mates!");
- else if (root->score == 9998) printz("computer mates!");
- else if (root->score < -9000) printz("opponent will soon mate!");
- else if (root->score > 9000) printz("computer will soon mate!");
- ClrEoln();
-
- if (post)
- {
- gotoXY(50,22); printz("Nodes= %6ld",NodeCnt); ClrEoln();
- gotoXY(50,23); printz("Nodes/Sec= %4ld",evrate); ClrEoln();
- }
-}
-
-
-ElapsedTime(iop)
-
-/*
- Determine the time that has passed since the search was started. If
- the elapsed time exceeds the target (ResponseTime+ExtraTime) then set
- timeout to true which will terminate the search.
-*/
-
-short iop;
-{
- et = time((time_t *)0) - time0;
- if (et < 0) et = 0;
- ETnodes += 50;
- if (et > et0 || iop == 1)
- {
- if (et > ResponseTime+ExtraTime && Sdepth > 1) timeout = true;
- et0 = et;
- if (iop == 1)
- {
- time0 = time((time_t *)0); et0 = 0;
- }
- (void) times(&tmbuf2);
- cputimer = 100*(tmbuf2.tms_utime - tmbuf1.tms_utime) / HZ;
- if (cputimer > 0) evrate = (100*NodeCnt)/(cputimer+100*ft);
- else evrate = 0;
- ETnodes = NodeCnt + 50;
- UpdateClocks();
- }
-}
-
-
-UpdateClocks()
-{
-short m,s;
- m = et/60; s = (et - 60*m);
- if (TCflag)
- {
- m = (TimeControl.clock[player] - et) / 60;
- s = TimeControl.clock[player] - et - 60*m;
- }
- if (m < 0) m = 0;
- if (s < 0) s = 0;
- if (player == white)
- if (reverse) gotoXY(20,2); else gotoXY(20,23);
- else
- if (reverse) gotoXY(20,23); else gotoXY(20,2);
- printz("%d:%2d ",m,s);
- if (post)
- {
- gotoXY(50,22); printz("Nodes= %6ld",NodeCnt);
- gotoXY(50,23); printz("Nodes/Sec= %4ld",evrate);
- }
- refresh();
-}
-
-
-
-SetTimeControl()
-{
- if (TCflag)
- {
- TimeControl.moves[white] = TimeControl.moves[black] = TCmoves;
- TimeControl.clock[white] = TimeControl.clock[black] = 60*(long)TCminutes;
- }
- else
- {
- TimeControl.moves[white] = TimeControl.moves[black] = 0;
- TimeControl.clock[white] = TimeControl.clock[black] = 0;
- Level = 60*(long)TCminutes;
- }
- et = 0;
- ElapsedTime(1);
-}
-
-
-gotoXY(x,y)
-short x,y;
-{
- move(y-1,x-1);
-}
-
-
-ClrScreen()
-{
- clear(); refresh();
-}
-
-
-ClrEoln()
-{
- clrtoeol(); refresh();
-}
-
-
-DrawPiece(sq)
-short sq;
-{
-short r,c; char x;
- if (reverse) r = 7-row[sq]; else r = row[sq];
- if (reverse) c = 7-column[sq]; else c = column[sq];
- if (color[sq] == black) x = '*'; else x = ' ';
- gotoXY(5+5*c,5+2*(7-r)); printz("%c%c ",x,pxx[board[sq]]);
-}
-
-
-UpdateDisplay(f,t,flag,iscastle)
-short f,t,flag,iscastle;
-{
-short i,l,z;
- if (flag)
- {
- gotoXY(56,2); printz("CHESS");
- i = 3;
- gotoXY(3,++i);
- printz("|----|----|----|----|----|----|----|----|");
- while (i<19)
- {
- gotoXY(1,++i);
- if (reverse) z = (i/2)-1; else z = 10-(i/2);
- printz("%d | | | | | | | | |",z);
- gotoXY(3,++i);
- if (i < 19)
- printz("+----+----+----+----+----+----+----+----+");
- }
- printz("|----|----|----|----|----|----|----|----|");
- gotoXY(3,21);
- if (reverse) printz(" h g f e d c b a");
- else printz(" a b c d e f g h");
- if (reverse) gotoXY(5,23); else gotoXY(5,2);
- if (computer == black) printz("Computer"); else printz("Human ");
- if (reverse) gotoXY(5,2); else gotoXY(5,23);
- if (computer == white) printz("Computer"); else printz("Human ");
- for (l = 0; l < 64; l++) DrawPiece(l);
- }
- else
- {
- DrawPiece(f); DrawPiece(t);
- if (iscastle)
- if (t > f)
- { DrawPiece(f+3); DrawPiece(t-1); }
- else
- { DrawPiece(f-4); DrawPiece(t+1); }
- }
- refresh();
-}
-
-
-GetOpenings()
-
-/*
- Read in the Opening Book file and parse the algebraic notation for a
- move into an unsigned integer format indicating the from and to
- square. Create a linked list of opening lines of play, with
- entry->next pointing to the next line and entry->move pointing to a
- chunk of memory containing the moves. More Opening lines of up to 256
- half moves may be added to gnuchess.book.
-*/
-
-{
-FILE *fd;
-int c,i,j,side;
-struct BookEntry *entry;
-unsigned short mv,*mp,tmp[100];
-
- if ((fd = fopen(_PATH_CHESSBOOK,"r")) != NULL)
- {
- Book = NULL;
- i = 0; side = white;
- while ((c = parse(fd,&mv,side)) >= 0)
- if (c == 1)
- {
- tmp[++i] = mv;
- side = otherside[side];
- }
- else if (c == 0 && i > 0)
- {
- entry = (struct BookEntry *)malloc(sizeof(struct BookEntry));
- mp = (unsigned short *)malloc((i+1)*sizeof(unsigned short));
- entry->mv = mp;
- entry->next = Book;
- Book = entry;
- for (j = 1; j <= i; j++) *(mp++) = tmp[j];
- *mp = 0;
- i = 0; side = white;
- }
- fclose(fd);
- }
- else
- {
- fprintf(stderr, "\nchess: can't read %s.\n", _PATH_CHESSBOOK);
- exit(1);
- }
-}
-
-
-int parse(fd,mv,side)
-FILE *fd;
-unsigned short *mv;
-short side;
-{
-int c,i,r1,r2,c1,c2;
-char s[100];
- while ((c = getc(fd)) == ' ');
- i = 0; s[0] = c;
- while (c != ' ' && c != '\n' && c != EOF) s[++i] = c = getc(fd);
- s[++i] = '\0';
- if (c == EOF) return(-1);
- if (s[0] == '!' || i < 3)
- {
- while (c != '\n' && c != EOF) c = getc(fd);
- return(0);
- }
- if (s[4] == 'o')
- if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
- else if (s[0] == 'o')
- if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
- else
- {
- c1 = s[0] - 'a'; r1 = s[1] - '1';
- c2 = s[2] - 'a'; r2 = s[3] - '1';
- *mv = (locn[r1][c1]<<8) + locn[r2][c2];
- }
- return(1);
-}
-
-
-GetGame()
-{
-FILE *fd;
-char fname[40];
-int c;
-short sq;
-unsigned short m;
-
- ShowMessage("File name: ");
- scanz("%s",fname);
- if (fname[0] == '\0') strcpy(fname,"chess.000");
- if ((fd = fopen(fname,"r")) != NULL)
- {
- fscanf(fd,"%hd%hd%hd",&computer,&opponent,&Game50);
- fscanf(fd,"%hd%hd%hd%hd",
- &castld[white],&castld[black],
- &kingmoved[white],&kingmoved[black]);
- fscanf(fd,"%hd%hd",&TCflag,&OperatorTime);
- fscanf(fd,"%ld%ld%hd%hd",
- &TimeControl.clock[white],&TimeControl.clock[black],
- &TimeControl.moves[white],&TimeControl.moves[black]);
- for (sq = 0; sq < 64; sq++)
- {
- fscanf(fd,"%hd",&m);
- board[sq] = (m >> 8); color[sq] = (m & 0xFF);
- if (color[sq] == 0) color[sq] = neutral; else --color[sq];
- }
- GameCnt = -1; c = '?';
- while (c != EOF)
- {
- ++GameCnt;
- c = fscanf(fd,"%hd%hd%hd%ld%hd%hd%hd",&GameList[GameCnt].gmove,
- &GameList[GameCnt].score,&GameList[GameCnt].depth,
- &GameList[GameCnt].nodes,&GameList[GameCnt].time,
- &GameList[GameCnt].piece,&GameList[GameCnt].color);
- if (GameList[GameCnt].color == 0) GameList[GameCnt].color = neutral;
- else --GameList[GameCnt].color;
- }
- GameCnt--;
- if (TimeControl.clock[white] > 0) TCflag = true;
- computer--; opponent--;
- }
- fclose(fd);
- InitializeStats();
- UpdateDisplay(0,0,1,0);
- Sdepth = 0;
-}
-
-
-SaveGame()
-{
-FILE *fd;
-char fname[40];
-short sq,i,c;
-
- ShowMessage("File name: ");
- scanz("%s",fname);
-
- if (fname[0] == '\0' || access(fname,W_OK) == -1) strcpy(fname,"chess.000");
- fd = fopen(fname,"w");
- fprintf(fd,"%d %d %d\n",computer+1,opponent+1,Game50);
- fprintf(fd,"%d %d %d %d\n",
- castld[white],castld[black],kingmoved[white],kingmoved[black]);
- fprintf(fd,"%d %d\n",TCflag,OperatorTime);
- fprintf(fd,"%ld %ld %d %d\n",
- TimeControl.clock[white],TimeControl.clock[black],
- TimeControl.moves[white],TimeControl.moves[black]);
- for (sq = 0; sq < 64; sq++)
- {
- if (color[sq] == neutral) c = 0; else c = color[sq]+1;
- fprintf(fd,"%d\n",256*board[sq] + c);
- }
- for (i = 0; i <= GameCnt; i++)
- {
- if (GameList[i].color == neutral) c = 0;
- else c = GameList[i].color + 1;
- fprintf(fd,"%d %d %d %ld %d %d %d\n",
- GameList[i].gmove,GameList[i].score,GameList[i].depth,
- GameList[i].nodes,GameList[i].time,
- GameList[i].piece,c);
- }
- fclose(fd);
-}
-
-
-ListGame()
-{
-FILE *fd;
-short i,f,t;
- fd = fopen("chess.lst","w");
- fprintf(fd,"\n");
- fprintf(fd," score depth nodes time ");
- fprintf(fd," score depth nodes time\n");
- for (i = 0; i <= GameCnt; i++)
- {
- f = GameList[i].gmove>>8; t = (GameList[i].gmove & 0xFF);
- algbr(f,t,false);
- if ((i % 2) == 0) fprintf(fd,"\n"); else fprintf(fd," ");
- fprintf(fd,"%5s %5d %2d %6ld %5d",mvstr1,
- GameList[i].score,GameList[i].depth,
- GameList[i].nodes,GameList[i].time);
- }
- fprintf(fd,"\n\n");
- fclose(fd);
-}
-
-
-Undo()
-
-/*
- Undo the most recent half-move.
-*/
-
-{
-short f,t;
- f = GameList[GameCnt].gmove>>8;
- t = GameList[GameCnt].gmove & 0xFF;
- if (board[t] == king && distance(t,f) > 1)
- castle(GameList[GameCnt].color,f,t,2);
- else
- {
- board[f] = board[t]; color[f] = color[t];
- board[t] = GameList[GameCnt].piece;
- color[t] = GameList[GameCnt].color;
- if (board[f] == king) --kingmoved[color[f]];
- }
- if (TCflag) ++TimeControl.moves[color[f]];
- GameCnt--; mate = false; Sdepth = 0;
- UpdateDisplay(0,0,1,0);
- InitializeStats();
-}
-
-
-ShowMessage(s)
-char *s;
-{
- gotoXY(50,24); printz("%s",s); ClrEoln();
-}
-
-ClearMessage()
-{
- gotoXY(50,24); ClrEoln();
-}
-
-ShowSidetomove()
-{
- gotoXY(50,14);
- if (player == white) printz("%2d: WHITE",1+(GameCnt+1)/2);
- else printz("%2d: BLACK",1+(GameCnt+1)/2);
- ClrEoln();
-}
-
-PromptForMove()
-{
- gotoXY(50,19); printz("Your move is? "); ClrEoln();
-}
-
-ShowCurrentMove(pnt,f,t)
-short pnt,f,t;
-{
- algbr(f,t,false);
- gotoXY(50,7); printz("(%2d) %4s",pnt,mvstr1);
-}
-
-ChangeAlphaWindow()
-{
- ShowMessage("window: ");
- scanz("%hd",&Awindow);
-}
-
-ChangeBetaWindow()
-{
- ShowMessage("window: ");
- scanz("%hd",&Bwindow);
-}
-
-GiveHint()
-{
-char s[40];
- algbr((short)(hint>>8),(short)(hint & 0xFF),false);
- strcpy(s,"try ");
- strcat(s,mvstr1);
- ShowMessage(s);
-}
-
-ChangeSearchDepth()
-{
- ShowMessage("depth= ");
- scanz("%hd",&MaxSearchDepth);
-}
-
-SetContempt()
-{
- ShowMessage("contempt= ");
- scanz("%hd",&contempt);
-}
-
-ChangeXwindow()
-{
- ShowMessage("xwndw= ");
- scanz("%hd",&xwndw);
-}
-
-
-SelectLevel()
-{
- ClrScreen();
- gotoXY(32,2); printz("CHESS");
- gotoXY(20,4); printz(" 1. 60 moves in 5 minutes");
- gotoXY(20,5); printz(" 2. 60 moves in 15 minutes");
- gotoXY(20,6); printz(" 3. 60 moves in 30 minutes");
- gotoXY(20,7); printz(" 4. 40 moves in 30 minutes");
- gotoXY(20,8); printz(" 5. 40 moves in 60 minutes");
- gotoXY(20,9); printz(" 6. 40 moves in 120 minutes");
- gotoXY(20,10); printz(" 7. 40 moves in 240 minutes");
- gotoXY(20,11); printz(" 8. 1 move in 15 minutes");
- gotoXY(20,12); printz(" 9. 1 move in 60 minutes");
- gotoXY(20,13); printz("10. 1 move in 600 minutes");
-
- OperatorTime = 0; TCmoves = 60; TCminutes = 5;
-
- gotoXY(20,17); printz("Enter Level: ");
- refresh();
- scanz("%ld",&Level);
- switch (Level)
- {
- case 1 : TCmoves = 60; TCminutes = 5; break;
- case 2 : TCmoves = 60; TCminutes = 15; break;
- case 3 : TCmoves = 60; TCminutes = 30; break;
- case 4 : TCmoves = 40; TCminutes = 30; break;
- case 5 : TCmoves = 40; TCminutes = 60; break;
- case 6 : TCmoves = 40; TCminutes = 120; break;
- case 7 : TCmoves = 40; TCminutes = 240; break;
- case 8 : TCmoves = 1; TCminutes = 15; break;
- case 9 : TCmoves = 1; TCminutes = 60; break;
- case 10 : TCmoves = 1; TCminutes = 600; break;
- }
-
- TCflag = (TCmoves > 1);
- SetTimeControl();
- ClrScreen();
- UpdateDisplay(0,0,1,0);
-}
-
-
-ShowPostnValues()
-{
-short i,r,c;
- ExaminePosition();
- for (i = 0; i < 64; i++)
- {
- if (reverse) r = 7-row[i]; else r = row[i];
- if (reverse) c = 7-column[i]; else c = column[i];
- gotoXY(4+5*c,5+2*(7-r));
- c1 = color[i]; c2 = otherside[c1];
- PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
- atk1 = atak[c1]; atk2 = atak[c2];
- if (color[i] == neutral) printz(" ");
- else printz("%3d ",SqValue(i,opponent));
- }
- ScorePosition(opponent,&i);
- gotoXY(50,24);
- printz("Score= %d",i); ClrEoln();
-}
-
-
-DoDebug()
-{
-short k,p,i,r,c,tp,tc;
-char s[40];
- ExaminePosition();
- ShowMessage("Enter piece: ");
- scanz("%s",s);
- if (s[0] == 'w') k = white; else k = black;
- if (s[1] == 'p') p = pawn;
- else if (s[1] == 'n') p = knight;
- else if (s[1] == 'b') p = bishop;
- else if (s[1] == 'r') p = rook;
- else if (s[1] == 'q') p = queen;
- else if (s[1] == 'k') p = king;
- else p = no_piece;
- for (i = 0; i < 64; i++)
- {
- if (reverse) r = 7-row[i]; else r = row[i];
- if (reverse) c = 7-column[i]; else c = column[i];
- gotoXY(4+5*c,5+2*(7-r));
- tp = board[i]; tc = color[i];
- board[i] = p; color[i] = k;
- c1 = k; c2 = otherside[c1];
- PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
- atk1 = atak[c1]; atk2 = atak[c2];
- printz("%3d ",SqValue(i,opponent));
- board[i] = tp; color[i] = tc;
- }
- ScorePosition(opponent,&i);
- gotoXY(50,24);
- printz("Score= %d",i); ClrEoln();
-}
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 560e61b..0000000
--- a/gnu/lib/libregex/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# $Header: /b/source/CVS/src/gnu/lib/libregex/Makefile,v 1.2 1993/04/10 15:24:44 cgd Exp $
-
-LIB= gnuregex
-CFLAGS+=-DHAVE_STRING_H=1
-SRCS= regex.c
-NOMAN= noman
-
-afterinstall:
- install -c -o root -g wheel -m 444 ${.CURDIR}/regex.h \
- ${DESTDIR}/usr/include
-
-.include <bsd.lib.mk>
diff --git a/gnu/lib/libregex/Makefile.gnu b/gnu/lib/libregex/Makefile.gnu
deleted file mode 100644
index 0976aa8..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 836e6de..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 13753ae..0000000
--- a/gnu/lib/libregex/doc/Makefile
+++ /dev/null
@@ -1,93 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-# Makefile for regex documentation.
-#
-# 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.
-
-# Installation directories.
-prefix = /usr
-infodir = $(prefix)/info
-
-srcdir = .
-VPATH = .:../.
-
-INSTALL = /usr/bin/install -c
-INSTALL_DATA = $(INSTALL) -m 644
-
-MAKEINFO = makeinfo --no-split
-SHELL = /bin/sh
-TEX = tex
-TEXINDEX = texindex
-
-default all: regex.info regex.dvi
-.PHONY: default all
-
-# We need to include some code from regex.h.
-regex.texi: xregex.texi
- rm -f $@
- gawk -f include.awk -vsource=../$(srcdir)/regex.h \
- <../$(srcdir)/doc/xregex.texi \
- | expand >$@
- chmod a-w $@
-
-regex.dvi: regex.cps
- $(TEX) regex.texi
-regex.cps: regex.cp
- $(TEXINDEX) regex.??
-regex.cp: regex.texi
- $(TEX) ../$(srcdir)/doc/regex.texi
-
-regex.info: regex.texi
- $(MAKEINFO) ../$(srcdir)/doc/regex.texi
-
-# I know of no way to make a good TAGS file from Texinfo source.
-TAGS:
-
-check:
-.PHONY: check
-
-install: regex.info
- -mkdir $(prefix) $(infodir)
- for i in *.info*; do $(INSTALL_DATA) $$i $(infodir)/$$i; done
-.PHONY: install
-
-clean mostlyclean:
- rm -f regex.?? *.dvi *.log *.toc
-
-distclean: clean
- rm -f Makefile
- for f in regex.??s; do if test -z "`cat $$f`"; then rm -f $$f; fi; done
-
-realclean: distclean
- rm -f *.info* regex.??? regex.texi TAGS
-
-extraclean: distclean
- rm -f patch* *~* *\#* *.orig *.rej *.bak core a.out
-.PHONY: mostlyclean clean distclean realclean extraclean
-
-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 = Makefile.in *.texi texinfo.tex include.awk \
- regex.info* regex.aux regex.cps
-dist: Makefile regex.info regex.cps
- mkdir $(distdir)
- ln $(distfiles) $(distdir)
-.PHONY: dist
diff --git a/gnu/lib/libregex/doc/Makefile.in b/gnu/lib/libregex/doc/Makefile.in
deleted file mode 100644
index 2f5d382..0000000
--- a/gnu/lib/libregex/doc/Makefile.in
+++ /dev/null
@@ -1,92 +0,0 @@
-# Makefile for regex documentation.
-#
-# 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.
-
-# Installation directories.
-prefix = /usr/local
-infodir = $(prefix)/info
-
-srcdir = @srcdir@
-VPATH = @srcdir@:../@srcdir@
-
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-
-MAKEINFO = makeinfo --no-split
-SHELL = /bin/sh
-TEX = tex
-TEXINDEX = texindex
-
-default all: regex.info regex.dvi
-.PHONY: default all
-
-# We need to include some code from regex.h.
-regex.texi: xregex.texi
- rm -f $@
- gawk -f include.awk -vsource=../$(srcdir)/regex.h \
- <../$(srcdir)/doc/xregex.texi \
- | expand >$@
- chmod a-w $@
-
-regex.dvi: regex.cps
- $(TEX) regex.texi
-regex.cps: regex.cp
- $(TEXINDEX) regex.??
-regex.cp: regex.texi
- $(TEX) ../$(srcdir)/doc/regex.texi
-
-regex.info: regex.texi
- $(MAKEINFO) ../$(srcdir)/doc/regex.texi
-
-# I know of no way to make a good TAGS file from Texinfo source.
-TAGS:
-
-check:
-.PHONY: check
-
-install: regex.info
- -mkdir $(prefix) $(infodir)
- for i in *.info*; do $(INSTALL_DATA) $$i $(infodir)/$$i; done
-.PHONY: install
-
-clean mostlyclean:
- rm -f regex.?? *.dvi *.log *.toc
-
-distclean: clean
- rm -f Makefile
- for f in regex.??s; do if test -z "`cat $$f`"; then rm -f $$f; fi; done
-
-realclean: distclean
- rm -f *.info* regex.??? regex.texi TAGS
-
-extraclean: distclean
- rm -f patch* *~* *\#* *.orig *.rej *.bak core a.out
-.PHONY: mostlyclean clean distclean realclean extraclean
-
-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 = Makefile.in *.texi texinfo.tex include.awk \
- regex.info* regex.aux regex.cps
-dist: Makefile regex.info regex.cps
- mkdir $(distdir)
- ln $(distfiles) $(distdir)
-.PHONY: dist
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/regex.aux b/gnu/lib/libregex/doc/regex.aux
deleted file mode 100644
index fd6a245..0000000
--- a/gnu/lib/libregex/doc/regex.aux
+++ /dev/null
@@ -1,136 +0,0 @@
-'xrdef {Overview-pg}{1}
-'xrdef {Overview-snt}{Chapter'tie1}
-'xrdef {Regular Expression Syntax-pg}{2}
-'xrdef {Regular Expression Syntax-snt}{Chapter'tie2}
-'xrdef {Syntax Bits-pg}{2}
-'xrdef {Syntax Bits-snt}{Section'tie2.1}
-'xrdef {Predefined Syntaxes-pg}{5}
-'xrdef {Predefined Syntaxes-snt}{Section'tie2.2}
-'xrdef {Collating Elements vs. Characters-pg}{6}
-'xrdef {Collating Elements vs. Characters-snt}{Section'tie2.3}
-'xrdef {The Backslash Character-pg}{7}
-'xrdef {The Backslash Character-snt}{Section'tie2.4}
-'xrdef {Common Operators-pg}{9}
-'xrdef {Common Operators-snt}{Chapter'tie3}
-'xrdef {Match-self Operator-pg}{9}
-'xrdef {Match-self Operator-snt}{Section'tie3.1}
-'xrdef {Match-any-character Operator-pg}{9}
-'xrdef {Match-any-character Operator-snt}{Section'tie3.2}
-'xrdef {Concatenation Operator-pg}{10}
-'xrdef {Concatenation Operator-snt}{Section'tie3.3}
-'xrdef {Repetition Operators-pg}{10}
-'xrdef {Repetition Operators-snt}{Section'tie3.4}
-'xrdef {Match-zero-or-more Operator-pg}{10}
-'xrdef {Match-zero-or-more Operator-snt}{Section'tie3.4.1}
-'xrdef {Match-one-or-more Operator-pg}{11}
-'xrdef {Match-one-or-more Operator-snt}{Section'tie3.4.2}
-'xrdef {Match-zero-or-one Operator-pg}{11}
-'xrdef {Match-zero-or-one Operator-snt}{Section'tie3.4.3}
-'xrdef {Interval Operators-pg}{12}
-'xrdef {Interval Operators-snt}{Section'tie3.4.4}
-'xrdef {Alternation Operator-pg}{13}
-'xrdef {Alternation Operator-snt}{Section'tie3.5}
-'xrdef {List Operators-pg}{13}
-'xrdef {List Operators-snt}{Section'tie3.6}
-'xrdef {Character Class Operators-pg}{14}
-'xrdef {Character Class Operators-snt}{Section'tie3.6.1}
-'xrdef {Range Operator-pg}{15}
-'xrdef {Range Operator-snt}{Section'tie3.6.2}
-'xrdef {Grouping Operators-pg}{16}
-'xrdef {Grouping Operators-snt}{Section'tie3.7}
-'xrdef {Back-reference Operator-pg}{17}
-'xrdef {Back-reference Operator-snt}{Section'tie3.8}
-'xrdef {Anchoring Operators-pg}{18}
-'xrdef {Anchoring Operators-snt}{Section'tie3.9}
-'xrdef {Match-beginning-of-line Operator-pg}{18}
-'xrdef {Match-beginning-of-line Operator-snt}{Section'tie3.9.1}
-'xrdef {Match-end-of-line Operator-pg}{18}
-'xrdef {Match-end-of-line Operator-snt}{Section'tie3.9.2}
-'xrdef {GNU Operators-pg}{20}
-'xrdef {GNU Operators-snt}{Chapter'tie4}
-'xrdef {Word Operators-pg}{20}
-'xrdef {Word Operators-snt}{Section'tie4.1}
-'xrdef {Non-Emacs Syntax Tables-pg}{20}
-'xrdef {Non-Emacs Syntax Tables-snt}{Section'tie4.1.1}
-'xrdef {Match-word-boundary Operator-pg}{20}
-'xrdef {Match-word-boundary Operator-snt}{Section'tie4.1.2}
-'xrdef {Match-within-word Operator-pg}{20}
-'xrdef {Match-within-word Operator-snt}{Section'tie4.1.3}
-'xrdef {Match-beginning-of-word Operator-pg}{21}
-'xrdef {Match-beginning-of-word Operator-snt}{Section'tie4.1.4}
-'xrdef {Match-end-of-word Operator-pg}{21}
-'xrdef {Match-end-of-word Operator-snt}{Section'tie4.1.5}
-'xrdef {Match-word-constituent Operator-pg}{21}
-'xrdef {Match-word-constituent Operator-snt}{Section'tie4.1.6}
-'xrdef {Match-non-word-constituent Operator-pg}{21}
-'xrdef {Match-non-word-constituent Operator-snt}{Section'tie4.1.7}
-'xrdef {Buffer Operators-pg}{21}
-'xrdef {Buffer Operators-snt}{Section'tie4.2}
-'xrdef {Match-beginning-of-buffer Operator-pg}{21}
-'xrdef {Match-beginning-of-buffer Operator-snt}{Section'tie4.2.1}
-'xrdef {Match-end-of-buffer Operator-pg}{21}
-'xrdef {Match-end-of-buffer Operator-snt}{Section'tie4.2.2}
-'xrdef {GNU Emacs Operators-pg}{22}
-'xrdef {GNU Emacs Operators-snt}{Chapter'tie5}
-'xrdef {Syntactic Class Operators-pg}{22}
-'xrdef {Syntactic Class Operators-snt}{Section'tie5.1}
-'xrdef {Emacs Syntax Tables-pg}{22}
-'xrdef {Emacs Syntax Tables-snt}{Section'tie5.1.1}
-'xrdef {Match-syntactic-class Operator-pg}{22}
-'xrdef {Match-syntactic-class Operator-snt}{Section'tie5.1.2}
-'xrdef {Match-not-syntactic-class Operator-pg}{22}
-'xrdef {Match-not-syntactic-class Operator-snt}{Section'tie5.1.3}
-'xrdef {What Gets Matched?-pg}{23}
-'xrdef {What Gets Matched?-snt}{Chapter'tie6}
-'xrdef {Programming with Regex-pg}{24}
-'xrdef {Programming with Regex-snt}{Chapter'tie7}
-'xrdef {GNU Regex Functions-pg}{24}
-'xrdef {GNU Regex Functions-snt}{Section'tie7.1}
-'xrdef {GNU Pattern Buffers-pg}{24}
-'xrdef {GNU Pattern Buffers-snt}{Section'tie7.1.1}
-'xrdef {GNU Regular Expression Compiling-pg}{26}
-'xrdef {GNU Regular Expression Compiling-snt}{Section'tie7.1.2}
-'xrdef {GNU Matching-pg}{27}
-'xrdef {GNU Matching-snt}{Section'tie7.1.3}
-'xrdef {GNU Searching-pg}{28}
-'xrdef {GNU Searching-snt}{Section'tie7.1.4}
-'xrdef {Matching/Searching with Split Data-pg}{29}
-'xrdef {Matching/Searching with Split Data-snt}{Section'tie7.1.5}
-'xrdef {Searching with Fastmaps-pg}{30}
-'xrdef {Searching with Fastmaps-snt}{Section'tie7.1.6}
-'xrdef {GNU Translate Tables-pg}{31}
-'xrdef {GNU Translate Tables-snt}{Section'tie7.1.7}
-'xrdef {Using Registers-pg}{32}
-'xrdef {Using Registers-snt}{Section'tie7.1.8}
-'xrdef {Freeing GNU Pattern Buffers-pg}{34}
-'xrdef {Freeing GNU Pattern Buffers-snt}{Section'tie7.1.9}
-'xrdef {POSIX Regex Functions-pg}{35}
-'xrdef {POSIX Regex Functions-snt}{Section'tie7.2}
-'xrdef {POSIX Pattern Buffers-pg}{35}
-'xrdef {POSIX Pattern Buffers-snt}{Section'tie7.2.1}
-'xrdef {POSIX Regular Expression Compiling-pg}{35}
-'xrdef {POSIX Regular Expression Compiling-snt}{Section'tie7.2.2}
-'xrdef {POSIX Matching-pg}{37}
-'xrdef {POSIX Matching-snt}{Section'tie7.2.3}
-'xrdef {Reporting Errors-pg}{38}
-'xrdef {Reporting Errors-snt}{Section'tie7.2.4}
-'xrdef {Using Byte Offsets-pg}{39}
-'xrdef {Using Byte Offsets-snt}{Section'tie7.2.5}
-'xrdef {Freeing POSIX Pattern Buffers-pg}{39}
-'xrdef {Freeing POSIX Pattern Buffers-snt}{Section'tie7.2.6}
-'xrdef {BSD Regex Functions-pg}{40}
-'xrdef {BSD Regex Functions-snt}{Section'tie7.3}
-'xrdef {BSD Regular Expression Compiling-pg}{40}
-'xrdef {BSD Regular Expression Compiling-snt}{Section'tie7.3.1}
-'xrdef {BSD Searching-pg}{40}
-'xrdef {BSD Searching-snt}{Section'tie7.3.2}
-'xrdef {Copying-pg}{42}
-'xrdef {Copying-snt}{Appendix'tie'char65{}}
-'xrdef {Copying-pg}{42}
-'xrdef {Copying-snt}{}
-'xrdef {Copying-pg}{43}
-'xrdef {Copying-snt}{}
-'xrdef {Copying-pg}{48}
-'xrdef {Copying-snt}{}
-'xrdef {Index-pg}{50}
-'xrdef {Index-snt}{}
diff --git a/gnu/lib/libregex/doc/regex.cps b/gnu/lib/libregex/doc/regex.cps
deleted file mode 100644
index 8b2e57c..0000000
--- a/gnu/lib/libregex/doc/regex.cps
+++ /dev/null
@@ -1,152 +0,0 @@
-\initial {$}
-\entry {\code {$}}{18}
-\initial {(}
-\entry {\code {(}}{16}
-\initial {)}
-\entry {\code {)}}{16}
-\initial {*}
-\entry {\samp {*}}{10}
-\initial {-}
-\entry {\samp {-}}{13}
-\initial {.}
-\entry {\samp {.}}{9}
-\initial {:}
-\entry {\samp {:]} in regex}{14}
-\initial {?}
-\entry {\samp {?}}{11}
-\initial {[}
-\entry {\samp {[}}{13}
-\entry {\samp {[:} in regex}{14}
-\entry {\samp {[{\tt\hat}}}{13}
-\initial {]}
-\entry {\samp {]}}{13}
-\initial {{\tt\char'173}}
-\entry {\samp {{\tt\char'173}}}{12}
-\initial {{\tt\char'174}}
-\entry {\code {{\tt\char'174}}}{13}
-\initial {{\tt\char'175}}
-\entry {\samp {{\tt\char'175}}}{12}
-\initial {{\tt\char43}}
-\entry {\samp {{\tt\char43}}}{11}
-\initial {{\tt\hat}}
-\entry {\samp {{\tt\hat}}}{13}
-\entry {\code {{\tt\hat}}}{18}
-\initial {{\tt\indexbackslash }}
-\entry {{\tt\indexbackslash }}{7}
-\entry {\samp {{\tt\indexbackslash }}}{13}
-\entry {\samp {{\tt\indexbackslash }'}}{21}
-\entry {\code {{\tt\indexbackslash }(}}{16}
-\entry {\code {{\tt\indexbackslash })}}{16}
-\entry {\samp {{\tt\indexbackslash }`}}{21}
-\entry {\samp {{\tt\indexbackslash }{\tt\char'173}}}{12}
-\entry {\code {{\tt\indexbackslash }{\tt\char'174}}}{13}
-\entry {\samp {{\tt\indexbackslash }{\tt\char'175}}}{12}
-\entry {\samp {{\tt\indexbackslash }{\tt\gtr}}}{21}
-\entry {\samp {{\tt\indexbackslash }{\tt\less}}}{21}
-\entry {\samp {{\tt\indexbackslash }b}}{20}
-\entry {\samp {{\tt\indexbackslash }B}}{20}
-\entry {\samp {{\tt\indexbackslash }s}}{22}
-\entry {\samp {{\tt\indexbackslash }S}}{22}
-\entry {\samp {{\tt\indexbackslash }w}}{21}
-\entry {\samp {{\tt\indexbackslash }W}}{21}
-\initial {A}
-\entry {\code {allocated \r {initialization}}}{26}
-\entry {alternation operator}{13}
-\entry {alternation operator and \samp {{\tt\hat}}}{18}
-\entry {anchoring}{18}
-\entry {anchors}{18}
-\entry {Awk}{5}
-\initial {B}
-\entry {back references}{17}
-\entry {backtracking}{10, 13}
-\entry {beginning-of-line operator}{18}
-\entry {bracket expression}{13}
-\entry {\code {buffer \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
-\entry {\code {buffer \r {initialization}}}{26}
-\initial {C}
-\entry {character classes}{14}
-\initial {E}
-\entry {Egrep}{5}
-\entry {Emacs}{5}
-\entry {end-of-line operator}{18}
-\entry {\code {end\penalty 10000{\spaceskip = 0pt{} }\r {in\penalty 10000{\spaceskip = 0pt{} }\code {struct\penalty 10000{\spaceskip = 0pt{} }re_registers}}}}{32}
-\initial {F}
-\entry {\code {fastmap \r {initialization}}}{26}
-\entry {\code {fastmap{\_}accurate \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
-\entry {fastmaps}{30}
-\initial {G}
-\entry {Grep}{5}
-\entry {grouping}{16}
-\initial {I}
-\entry {ignoring case}{35}
-\entry {interval expression}{12}
-\initial {M}
-\entry {matching list}{13}
-\entry {matching newline}{13}
-\entry {matching with GNU functions}{27}
-\initial {N}
-\entry {\code {newline{\_}anchor \r {field in pattern buffer}}}{18}
-\entry {nonmatching list}{13}
-\entry {\code {not{\_}bol \r {field in pattern buffer}}}{18}
-\entry {\code {num_regs\penalty 10000{\spaceskip = 0pt{} }\r {in\penalty 10000{\spaceskip = 0pt{} }\code {struct\penalty 10000{\spaceskip = 0pt{} }re_registers}}}}{32}
-\initial {O}
-\entry {open-group operator and \samp {{\tt\hat}}}{18}
-\entry {or operator}{13}
-\initial {P}
-\entry {parenthesizing}{16}
-\entry {pattern buffer initialization}{26}
-\entry {pattern buffer, definition of}{24}
-\entry {POSIX Awk}{5}
-\initial {R}
-\entry {\code {range \r {argument to \code {re{\_}search}}}}{28}
-\entry {\code {re_registers}}{32}
-\entry {\code {RE{\_}BACKSLASH{\_}ESCAPE{\_}IN{\_}LIST}}{3}
-\entry {\code {RE{\_}BK{\_}PLUS{\_}QM}}{3}
-\entry {\code {RE{\_}CHAR{\_}CLASSES}}{3}
-\entry {\code {RE{\_}CONTEXT{\_}INDEP{\_}ANCHORS}}{3}
-\entry {\code {RE{\_}CONTEXT{\_}INDEP{\_}ANCHORS \r {(and \samp {{\tt\hat}})}}}{18}
-\entry {\code {RE{\_}CONTEXT{\_}INDEP{\_}OPS}}{3}
-\entry {\code {RE{\_}CONTEXT{\_}INVALID{\_}OPS}}{3}
-\entry {\code {RE{\_}DOT{\_}NEWLINE}}{3}
-\entry {\code {RE{\_}DOT{\_}NOT{\_}NULL}}{4}
-\entry {\code {RE{\_}INTERVALS}}{4}
-\entry {\code {RE{\_}LIMITED{\_}OPS}}{4}
-\entry {\code {RE{\_}NEWLINE{\_}ALT}}{4}
-\entry {\code {RE{\_}NO{\_}BK{\_}BRACES}}{4}
-\entry {\code {RE{\_}NO{\_}BK{\_}PARENS}}{4}
-\entry {\code {RE{\_}NO{\_}BK{\_}REFS}}{4}
-\entry {\code {RE{\_}NO{\_}BK{\_}VBAR}}{4}
-\entry {\code {RE{\_}NO{\_}EMPTY{\_}RANGES}}{4}
-\entry {\code {re{\_}nsub \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
-\entry {\code {re{\_}pattern{\_}buffer \r {definition}}}{24}
-\entry {\code {re{\_}syntax{\_}options \r {initialization}}}{26}
-\entry {\code {RE{\_}UNMATCHED{\_}RIGHT{\_}PAREN{\_}ORD}}{4}
-\entry {\code {REG{\_}EXTENDED}}{35}
-\entry {\code {REG{\_}ICASE}}{35}
-\entry {\code {REG{\_}NEWLINE}}{36}
-\entry {\code {REG{\_}NOSUB}}{35}
-\entry {\code {regex.c}}{1}
-\entry {\code {regex.h}}{1}
-\entry {regexp anchoring}{18}
-\entry {\code {regmatch{\_}t}}{39}
-\entry {\code {regs{\_}allocated}}{32}
-\entry {\code {REGS{\_}FIXED}}{33}
-\entry {\code {REGS{\_}REALLOCATE}}{32}
-\entry {\code {REGS{\_}UNALLOCATED}}{32}
-\entry {regular expressions, syntax of}{2}
-\initial {S}
-\entry {searching with GNU functions}{28}
-\entry {\code {start \r {argument to \code {re{\_}search}}}}{28}
-\entry {\code {start\penalty 10000{\spaceskip = 0pt{} }\r {in\penalty 10000{\spaceskip = 0pt{} }\code {struct\penalty 10000{\spaceskip = 0pt{} }re_registers}}}}{32}
-\entry {\code {struct re{\_}pattern{\_}buffer \r {definition}}}{24}
-\entry {subexpressions}{16}
-\entry {syntax bits}{2}
-\entry {\code {syntax \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
-\entry {syntax initialization}{26}
-\entry {syntax of regular expressions}{2}
-\initial {T}
-\entry {\code {translate \r {initialization}}}{26}
-\initial {U}
-\entry {\code {used \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
-\initial {W}
-\entry {word boundaries, matching}{20}
diff --git a/gnu/lib/libregex/doc/regex.info b/gnu/lib/libregex/doc/regex.info
deleted file mode 100644
index 90deede..0000000
--- a/gnu/lib/libregex/doc/regex.info
+++ /dev/null
@@ -1,2836 +0,0 @@
-This is Info file regex.info, produced by Makeinfo-1.52 from the input
-file .././doc/regex.texi.
-
- 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.
-
- 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.
-
-
-File: regex.info, Node: Top, Next: Overview, Prev: (dir), Up: (dir)
-
-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 (`[' ... `]' and `[^' ... `]')
-
-* 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 ()
-
-
-File: regex.info, Node: Overview, Next: Regular Expression Syntax, Prev: Top, Up: Top
-
-Overview
-********
-
- A "regular expression" (or "regexp", or "pattern") is a text string
-that describes some (mathematical) set of strings. A regexp R
-"matches" a string S if S is in the set of strings described by R.
-
- Using the Regex library, you can:
-
- * see if a string matches a specified pattern as a whole, and
-
- * search within a string for a substring matching a specified
- pattern.
-
- Some regular expressions match only one string, i.e., the set they
-describe has only one member. For example, the regular expression
-`foo' matches the string `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 `f*' matches
-the set of strings made up of any number (including zero) of `f's. As
-you can see, some characters in regular expressions match themselves
-(such as `f') and some don't (such as `*'); 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 "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: `regex.h' and
-`regex.c'. Regex provides three groups of functions with which you can
-operate on regular expressions. One group--the GNU group--is more
-powerful but not completely compatible with the other two, namely the
-POSIX and Berkeley UNIX groups; its interface was designed specifically
-for GNU. The other groups have the same interfaces as do the regular
-expression functions in POSIX and Berkeley 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.
-
-
-File: regex.info, Node: Regular Expression Syntax, Next: Common Operators, Prev: Overview, Up: Top
-
-Regular Expression Syntax
-*************************
-
- "Characters" are things you can type. "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 "ordinary". Other
-characters represent either all or parts of fancier operators; e.g.,
-`.' represents what we call the match-any-character operator (which, no
-surprise, matches (almost) any character); we call these characters
-"special". Two different things determine what characters represent
-what operators:
-
- 1. the regular expression syntax your program has told the Regex
- library to recognize, and
-
- 2. the context of the character in the regular expression.
-
- In the following sections, we describe these things in more detail.
-
-* Menu:
-
-* Syntax Bits::
-* Predefined Syntaxes::
-* Collating Elements vs. Characters::
-* The Backslash Character::
-
-
-File: regex.info, Node: Syntax Bits, Next: Predefined Syntaxes, Up: Regular Expression Syntax
-
-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 `syntax' field of the
-pattern buffer of that regular expression.
-
- You get a pattern buffer by compiling a regular expression. *Note
-GNU Pattern Buffers::, and *Note POSIX Pattern Buffers::, for more
-information on pattern buffers. *Note GNU Regular Expression
-Compiling::, *Note POSIX Regular Expression Compiling::, and *Note BSD
-Regular Expression Compiling::, for more information on compiling.
-
- Regex considers the value of the `syntax' field to be a collection of
-bits; we refer to these bits as "syntax bits". In most cases, they
-affect what characters represent what operators. We describe the
-meanings of the operators to which we refer in *Note Common Operators::,
-*Note GNU Operators::, and *Note GNU Emacs Operators::.
-
- For reference, here is the complete list of syntax bits, in
-alphabetical order:
-
-`RE_BACKSLASH_ESCAPE_IN_LISTS'
- If this bit is set, then `\' inside a list (*note List Operators::.
- quotes (makes ordinary, if it's special) the following character;
- if this bit isn't set, then `\' is an ordinary character inside
- lists. (*Note The Backslash Character::, for what `\' does
- outside of lists.)
-
-`RE_BK_PLUS_QM'
- If this bit is set, then `\+' represents the match-one-or-more
- operator and `\?' represents the match-zero-or-more operator; if
- this bit isn't set, then `+' represents the match-one-or-more
- operator and `?' represents the match-zero-or-one operator. This
- bit is irrelevant if `RE_LIMITED_OPS' is set.
-
-`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.
-
-`RE_CONTEXT_INDEP_ANCHORS'
- If this bit is set, then `^' and `$' are special anywhere outside
- a list; if this bit isn't set, then these characters are special
- only in certain contexts. *Note Match-beginning-of-line
- Operator::, and *Note Match-end-of-line Operator::.
-
-`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 `*', and (if the syntax
- bit `RE_LIMITED_OPS' isn't set) `+' and `?' (or `\+' and `\?',
- depending on the syntax bit `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 `{' (or `\{', depending on the syntax bit `RE_NO_BK_BRACES') if
- it is the beginning of a valid interval and the syntax bit
- `RE_INTERVALS' is set.
-
-`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:
-
- * a repetition operator first in the regular expression or just
- after a match-beginning-of-line, open-group, or alternation
- operator; or
-
- * 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.
-
- 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.
-
-`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.
-
-`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.
-
-`RE_INTERVALS'
- If this bit is set, then Regex recognizes interval operators; if
- this bit isn't set, then it doesn't.
-
-`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.
-
-`RE_NEWLINE_ALT'
- If this bit is set, then newline represents the alternation
- operator; if this bit isn't set, then newline is ordinary.
-
-`RE_NO_BK_BRACES'
- If this bit is set, then `{' represents the open-interval operator
- and `}' represents the close-interval operator; if this bit isn't
- set, then `\{' represents the open-interval operator and `\}'
- represents the close-interval operator. This bit is relevant only
- if `RE_INTERVALS' is set.
-
-`RE_NO_BK_PARENS'
- If this bit is set, then `(' represents the open-group operator and
- `)' represents the close-group operator; if this bit isn't set,
- then `\(' represents the open-group operator and `\)' represents
- the close-group operator.
-
-`RE_NO_BK_REFS'
- If this bit is set, then Regex doesn't recognize `\'DIGIT as the
- back reference operator; if this bit isn't set, then it does.
-
-`RE_NO_BK_VBAR'
- If this bit is set, then `|' represents the alternation operator;
- if this bit isn't set, then `\|' represents the alternation
- operator. This bit is irrelevant if `RE_LIMITED_OPS' is set.
-
-`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.
-
-`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 `RE_NO_BK_PARENS' is set) to
- match `)'.
-
-
-File: regex.info, Node: Predefined Syntaxes, Next: Collating Elements vs. Characters, Prev: Syntax Bits, Up: Regular Expression Syntax
-
-Predefined Syntaxes
-===================
-
- If you're programming with Regex, you can set a pattern buffer's
-(*note GNU Pattern Buffers::., and *Note POSIX Pattern Buffers::)
-`syntax' field either to an arbitrary combination of syntax bits (*note
-Syntax Bits::.) or else to the configurations defined by Regex. These
-configurations define the syntaxes used by certain programs--GNU Emacs,
-POSIX Awk, traditional Awk, Grep, Egrep--in addition to syntaxes for
-POSIX basic and extended regular expressions.
-
- The predefined syntaxes-taken directly from `regex.h'--are:
-
- #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_UNMATCHED_RIGHT_PAREN_ORD)
-
- #define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
-
- #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)
-
-
-File: regex.info, Node: Collating Elements vs. Characters, Next: The Backslash Character, Prev: Predefined Syntaxes, Up: Regular Expression Syntax
-
-Collating Elements vs. Characters
-=================================
-
- POSIX generalizes the notion of a character to that of a collating
-element. It defines a "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 "es-zet" collates as the collating element `s'
-followed by another collating element `s'. Second, two or more
-characters can map into one collating element. For example, the
-Spanish `ll' collates after `l' and before `m'.
-
- Since POSIX's "collating element" preserves the essential idea of a
-"character," we use the latter, more familiar, term in this document.
-
-
-File: regex.info, Node: The Backslash Character, Prev: Collating Elements vs. Characters, Up: Regular Expression Syntax
-
-The Backslash Character
-=======================
-
- The `\' character has one of four different meanings, depending on
-the context in which you use it and what syntax bits are set (*note
-Syntax Bits::.). It can: 1) stand for itself, 2) quote the next
-character, 3) introduce an operator, or 4) do nothing.
-
- 1. It stands for itself inside a list (*note List Operators::.) if
- the syntax bit `RE_BACKSLASH_ESCAPE_IN_LISTS' is not set. For
- example, `[\]' would match `\'.
-
- 2. It quotes (makes ordinary, if it's special) the next character
- when you use it either:
-
- * outside a list,(1) or
-
- * inside a list and the syntax bit
- `RE_BACKSLASH_ESCAPE_IN_LISTS' is set.
-
- 3. It introduces an operator when followed by certain ordinary
- characters--sometimes only when certain syntax bits are set. See
- the cases `RE_BK_PLUS_QM', `RE_NO_BK_BRACES', `RE_NO_BK_VAR',
- `RE_NO_BK_PARENS', `RE_NO_BK_REF' in *Note Syntax Bits::. Also:
-
- * `\b' represents the match-word-boundary operator (*note
- Match-word-boundary Operator::.).
-
- * `\B' represents the match-within-word operator (*note
- Match-within-word Operator::.).
-
- * `\<' represents the match-beginning-of-word operator
- (*note Match-beginning-of-word Operator::.).
-
- * `\>' represents the match-end-of-word operator (*note
- Match-end-of-word Operator::.).
-
- * `\w' represents the match-word-constituent operator (*note
- Match-word-constituent Operator::.).
-
- * `\W' represents the match-non-word-constituent operator
- (*note Match-non-word-constituent Operator::.).
-
- * `\`' represents the match-beginning-of-buffer operator and
- `\'' represents the match-end-of-buffer operator (*note
- Buffer Operators::.).
-
- * If Regex was compiled with the C preprocessor symbol `emacs'
- defined, then `\sCLASS' represents the match-syntactic-class
- operator and `\SCLASS' represents the
- match-not-syntactic-class operator (*note Syntactic Class
- Operators::.).
-
- 4. In all other cases, Regex ignores `\'. For example, `\n' matches
- `n'.
-
-
- ---------- Footnotes ----------
-
- (1) 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 (*note List Operators::.). In addition, if the
-syntax bits `RE_CONTEXT_INVALID_OPS' and `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 `*') matches itself in the regular expression
-`*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.
-
-
-File: regex.info, Node: Common Operators, Next: GNU Operators, Prev: Regular Expression Syntax, Up: Top
-
-Common Operators
-****************
-
- You compose regular expressions from operators. In the following
-sections, we describe the regular expression operators specified by
-POSIX; GNU also uses these. Most operators have more than one
-representation as characters. *Note 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 `\'. For example, either `(' or `\(' represents the
-open-group operator. Which one does depends on the setting of a syntax
-bit, in this case `RE_NO_BK_PARENS'. Why is this so? Historical
-reasons dictate some of the varying representations, while POSIX
-dictates others.
-
- Finally, almost all characters lose any special meaning inside a list
-(*note 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:: ^ $
-
-
-File: regex.info, Node: Match-self Operator, Next: Match-any-character Operator, Up: Common Operators
-
-The Match-self Operator (ORDINARY CHARACTER)
-============================================
-
- This operator matches the character itself. All ordinary characters
-(*note Regular Expression Syntax::.) represent this operator. For
-example, `f' is always an ordinary character, so the regular expression
-`f' matches only the string `f'. In particular, it does *not* match
-the string `ff'.
-
-
-File: regex.info, Node: Match-any-character Operator, Next: Concatenation Operator, Prev: Match-self Operator, Up: Common Operators
-
-The Match-any-character Operator (`.')
-======================================
-
- This operator matches any single printing or nonprinting character
-except it won't match a:
-
-newline
- if the syntax bit `RE_DOT_NEWLINE' isn't set.
-
-null
- if the syntax bit `RE_DOT_NOT_NULL' is set.
-
- The `.' (period) character represents this operator. For example,
-`a.b' matches any three-character string beginning with `a' and ending
-with `b'.
-
-
-File: regex.info, Node: Concatenation Operator, Next: Repetition Operators, Prev: Match-any-character Operator, Up: Common Operators
-
-The Concatenation Operator
-==========================
-
- This operator concatenates two regular expressions A and B. No
-character represents this operator; you simply put B after A. The
-result is a regular expression that will match a string if A matches
-its first part and B matches the rest. For example, `xy' (two
-match-self operators) matches `xy'.
-
-
-File: regex.info, Node: Repetition Operators, Next: Alternation Operator, Prev: Concatenation Operator, Up: Common Operators
-
-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:: {}
-
-
-File: regex.info, Node: Match-zero-or-more Operator, Next: Match-one-or-more Operator, Up: Repetition Operators
-
-The Match-zero-or-more Operator (`*')
--------------------------------------
-
- This operator repeats the smallest possible preceding regular
-expression as many times as necessary (including zero) to match the
-pattern. `*' represents this operator. For example, `o*' matches any
-string made up of zero or more `o's. Since this operator operates on
-the smallest preceding regular expression, `fo*' has a repeating `o',
-not a repeating `fo'. So, `fo*' matches `f', `fo', `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:
-
- * is first in a regular expression, or
-
- * follows a match-beginning-of-line, open-group, or alternation
- operator.
-
-Three different things can happen in these cases:
-
- 1. If the syntax bit `RE_CONTEXT_INVALID_OPS' is set, then the
- regular expression is invalid.
-
- 2. If `RE_CONTEXT_INVALID_OPS' isn't set, but `RE_CONTEXT_INDEP_OPS'
- is, then `*' represents the match-zero-or-more operator (which
- then operates on the empty string).
-
- 3. Otherwise, `*' is ordinary.
-
-
- 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 `ca*ar' against `caaar', the matcher
-first matches all three `a's of the string with the `a*' of the regular
-expression. However, it cannot then match the final `ar' of the
-regular expression against the final `r' of the string. So it
-backtracks, discarding the match of the last `a' in the string. It can
-then match the remaining `ar'.
-
-
-File: regex.info, Node: Match-one-or-more Operator, Next: Match-zero-or-one Operator, Prev: Match-zero-or-more Operator, Up: Repetition Operators
-
-The Match-one-or-more Operator (`+' or `\+')
---------------------------------------------
-
- If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't
-recognize this operator. Otherwise, if the syntax bit `RE_BK_PLUS_QM'
-isn't set, then `+' represents this operator; if it is, then `\+' does.
-
- This operator is similar to the match-zero-or-more operator except
-that it repeats the preceding regular expression at least once; *note
-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 `+' represents the match-one-or-more
-operator; then `ca+r' matches, e.g., `car' and `caaaar', but not `cr'.
-
-
-File: regex.info, Node: Match-zero-or-one Operator, Next: Interval Operators, Prev: Match-one-or-more Operator, Up: Repetition Operators
-
-The Match-zero-or-one Operator (`?' or `\?')
---------------------------------------------
-
- If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't
-recognize this operator. Otherwise, if the syntax bit `RE_BK_PLUS_QM'
-isn't set, then `?' represents this operator; if it is, then `\?' 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;
-*note 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 `?' represents the match-zero-or-one
-operator; then `ca?r' matches both `car' and `cr', but nothing else.
-
-
-File: regex.info, Node: Interval Operators, Prev: Match-zero-or-one Operator, Up: Repetition Operators
-
-Interval Operators (`{' ... `}' or `\{' ... `\}')
--------------------------------------------------
-
- If the syntax bit `RE_INTERVALS' is set, then Regex recognizes
-"interval expressions". They repeat the smallest possible preceding
-regular expression a specified number of times.
-
- If the syntax bit `RE_NO_BK_BRACES' is set, `{' represents the
-"open-interval operator" and `}' represents the "close-interval
-operator" ; otherwise, `\{' and `\}' do.
-
- Specifically, supposing that `{' and `}' represent the open-interval
-and close-interval operators; then:
-
-`{COUNT}'
- matches exactly COUNT occurrences of the preceding regular
- expression.
-
-`{MIN,}'
- matches MIN or more occurrences of the preceding regular
- expression.
-
-`{MIN, MAX}'
- matches at least MIN but no more than MAX occurrences of the
- preceding regular expression.
-
- The interval expression (but not necessarily the regular expression
-that contains it) is invalid if:
-
- * MIN is greater than MAX, or
-
- * any of COUNT, MIN, or MAX are outside the range zero to
- `RE_DUP_MAX' (which symbol `regex.h' defines).
-
- If the interval expression is invalid and the syntax bit
-`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
-`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.
-
-
-File: regex.info, Node: Alternation Operator, Next: List Operators, Prev: Repetition Operators, Up: Common Operators
-
-The Alternation Operator (`|' or `\|')
-======================================
-
- If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't
-recognize this operator. Otherwise, if the syntax bit `RE_NO_BK_VBAR'
-is set, then `|' represents this operator; otherwise, `\|' 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 A and B, the result matches the union of the
-strings that A and B match. For example, supposing that `|' is the
-alternation operator, then `foo|bar|quux' would match any of `foo',
-`bar' or `quux'.
-
- The alternation operator operates on the *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 `(' and
-`)' are the open and close-group operators, then `fo(o|b)ar' would
-match either `fooar' or `fobar'. (`foo|bar' would match `foo' or
-`bar'.)
-
- The matcher usually tries all combinations of alternatives so as to
-match the longest possible string. For example, when matching
-`(fooq|foo)*(qbarquux|bar)' against `fooqbarquux', it cannot take, say,
-the first ("depth-first") combination it could match, since then it
-would be content to match just `fooqbar'.
-
-
-File: regex.info, Node: List Operators, Next: Grouping Operators, Prev: Alternation Operator, Up: Common Operators
-
-List Operators (`[' ... `]' and `[^' ... `]')
-=============================================
-
- "Lists", also called "bracket expressions", are a set of one or more
-items. An "item" is a character, 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 "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 "open-matching-list operator" (represented by `[') and a
-"close-list operator" (represented by `]').
-
- For example, `[ab]' matches either `a' or `b'. `[ad]*' matches the
-empty string and any string composed of just `a's and `d's in any
-order. Regex considers invalid a regular expression with a `[' but no
-matching `]'.
-
- "Nonmatching lists" are similar to matching lists except that they
-match a single character *not* represented by one of the list items.
-You use an "open-nonmatching-list operator" (represented by `[^'(1))
-instead of an open-matching-list operator to start a nonmatching list.
-
- For example, `[^ab]' matches any character except `a' or `b'.
-
- If the `posix_newline' field in the pattern buffer (*note 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.
-
-`]'
- ends the list if it's not the first list item. So, if you want to
- make the `]' character a list item, you must put it first.
-
-`\'
- quotes the next character if the syntax bit
- `RE_BACKSLASH_ESCAPE_IN_LISTS' is set.
-
-`[:'
- represents the open-character-class operator (*note Character
- Class Operators::.) if the syntax bit `RE_CHAR_CLASSES' is set and
- what follows is a valid character class expression.
-
-`:]'
- represents the close-character-class operator if the syntax bit
- `RE_CHAR_CLASSES' is set and what precedes it is an
- open-character-class operator followed by a valid character class
- name.
-
-`-'
- represents the range operator (*note Range Operator::.) if it's
- not first or last in a list or the ending point of a range.
-
-All other characters are ordinary. For example, `[.*]' matches `.' and
-`*'.
-
-* Menu:
-
-* Character Class Operators:: [:class:]
-* Range Operator:: start-end
-
- ---------- Footnotes ----------
-
- (1) Regex therefore doesn't consider the `^' to be the first
-character in the list. If you put a `^' character first in (what you
-think is) a matching list, you'll turn it into a nonmatching list.
-
-
-File: regex.info, Node: Character Class Operators, Next: Range Operator, Up: List Operators
-
-Character Class Operators (`[:' ... `:]')
------------------------------------------
-
- If the syntax bit `RE_CHARACTER_CLASSES' is set, then Regex
-recognizes character class expressions inside lists. A "character
-class expression" matches one character from a given class. You form a
-character class expression by putting a character class name between an
-"open-character-class operator" (represented by `[:') and a
-"close-character-class operator" (represented by `:]'). The character
-class names and their meanings are:
-
-`alnum'
- letters and digits
-
-`alpha'
- letters
-
-`blank'
- system-dependent; for GNU, a space or tab
-
-`cntrl'
- control characters (in the ASCII encoding, code 0177 and codes
- less than 040)
-
-`digit'
- digits
-
-`graph'
- same as `print' except omits space
-
-`lower'
- lowercase letters
-
-`print'
- printable characters (in the ASCII encoding, space tilde--codes
- 040 through 0176)
-
-`punct'
- neither control nor alphanumeric characters
-
-`space'
- space, carriage return, newline, vertical tab, and form feed
-
-`upper'
- uppercase letters
-
-`xdigit'
- hexadecimal digits: `0'-`9', `a'-`f', `A'-`F'
-
-These correspond to the definitions in the C library's `<ctype.h>'
-facility. For example, `[:alpha:]' corresponds to the standard
-facility `isalpha'. Regex recognizes character class expressions only
-inside of lists; so `[[:alpha:]]' matches any letter, but `[:alpha:]'
-outside of a bracket expression and not followed by a repetition
-operator matches just itself.
-
-
-File: regex.info, Node: Range Operator, Prev: Character Class Operators, Up: List Operators
-
-The Range Operator (`-')
-------------------------
-
- Regex recognizes "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 "range
-operator" between two characters.(1) `-' represents the range operator.
-For example, `a-f' within a list represents all the characters from `a'
-through `f' inclusively.
-
- If the syntax bit `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 `[z-a]' would be invalid. If this bit isn't set, then Regex
-considers such a range to be empty.
-
- Since `-' represents the range operator, if you want to make a `-'
-character itself a list item, you must do one of the following:
-
- * Put the `-' either first or last in the list.
-
- * Include a range whose starting point collates strictly lower than
- `-' and whose ending point collates equal or higher. Unless a
- range is the first item in a list, a `-' can't be its starting
- point, but *can* be its ending point. That is because Regex
- considers `-' to be the range operator unless it is preceded by
- another `-'. For example, in the ASCII encoding, `)', `*', `+',
- `,', `-', `.', and `/' are contiguous characters in the collating
- sequence. You might think that `[)-+--/]' has two ranges: `)-+'
- and `--/'. Rather, it has the ranges `)-+' and `+--', plus the
- character `/', so it matches, e.g., `,', not `.'.
-
- * Put a range whose starting point is `-' first in the list.
-
- For example, `[-a-z]' matches a lowercase letter or a hyphen (in
-English, in ASCII).
-
- ---------- Footnotes ----------
-
- (1) 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.
-
-
-File: regex.info, Node: Grouping Operators, Next: Back-reference Operator, Prev: List Operators, Up: Common Operators
-
-Grouping Operators (`(' ... `)' or `\(' ... `\)')
-=================================================
-
- A "group", also known as a "subexpression", consists of an
-"open-group operator", any number of other operators, and a
-"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 "groups", you can:
-
- * delimit the argument(s) to an alternation operator (*note
- Alternation Operator::.) or a repetition operator (*note
- Repetition Operators::.).
-
- * keep track of the indices of the substring that matched a given
- group. *Note Using Registers::, for a precise explanation. This
- lets you:
-
- * use the back-reference operator (*note Back-reference
- Operator::.).
-
- * use registers (*note Using Registers::.).
-
- If the syntax bit `RE_NO_BK_PARENS' is set, then `(' represents the
-open-group operator and `)' represents the close-group operator;
-otherwise, `\(' and `\)' do.
-
- If the syntax bit `RE_UNMATCHED_RIGHT_PAREN_ORD' is set and a
-close-group operator has no matching open-group operator, then Regex
-considers it to match `)'.
-
-
-File: regex.info, Node: Back-reference Operator, Next: Anchoring Operators, Prev: Grouping Operators, Up: Common Operators
-
-The Back-reference Operator ("\"DIGIT)
-======================================
-
- If the syntax bit `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 `\DIGIT' anywhere after
-the end of a regular expression's DIGIT-th group (*note Grouping
-Operators::.).
-
- DIGIT must be between `1' and `9'. The matcher assigns numbers 1
-through 9 to the first nine groups it encounters. By using one of `\1'
-through `\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, `(' represents the open-group, `)' the close-group, `{' the
-open-interval and `}' the close-interval operator):
-
- * If the group matches a substring, the back reference matches an
- identical substring. For example, `(a)\1' matches `aa' and
- `(bana)na\1bo\1' matches `bananabanabobana'. Likewise, `(.*)\1'
- matches any (newline-free if the syntax bit `RE_DOT_NEWLINE' isn't
- set) string that is composed of two identical halves; the `(.*)'
- matches the first half and the `\1' matches the second half.
-
- * 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 *last* matched. For example, `((a*)b)*\1\2'
- matches `aabababa'; first group 1 (the outer one) matches `aab'
- and group 2 (the inner one) matches `aa'. Then group 1 matches
- `ab' and group 2 matches `a'. So, `\1' matches `ab' and `\2'
- matches `a'.
-
- * 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, `(one()|two())-and-(three\2|four\3)' matches
- `one-and-three' and `two-and-four', but not `one-and-four' or
- `two-and-three'. For example, if the pattern matches `one-and-',
- then its group 2 matches the empty string and its group 3 doesn't
- participate in the match. So, if it then matches `four', then
- when it tries to back reference group 3--which it will attempt to
- do because `\3' follows the `four'--the match will fail because
- group 3 didn't participate in the match.
-
- You can use a back reference as an argument to a repetition operator.
-For example, `(a(b))\2*' matches `a' followed by two or more `b's.
-Similarly, `(a(b))\2{3}' matches `abbbb'.
-
- If there is no preceding DIGIT-th subexpression, the regular
-expression is invalid.
-
-
-File: regex.info, Node: Anchoring Operators, Prev: Back-reference Operator, Up: Common Operators
-
-Anchoring Operators
-===================
-
- 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:: $
-
-
-File: regex.info, Node: Match-beginning-of-line Operator, Next: Match-end-of-line Operator, Up: Anchoring Operators
-
-The Match-beginning-of-line Operator (`^')
-------------------------------------------
-
- This operator can match the empty string either at the beginning of
-the string or after a newline character. Thus, it is said to "anchor"
-the pattern to the beginning of a line.
-
- In the cases following, `^' represents this operator. (Otherwise,
-`^' is ordinary.)
-
- * It (the `^') is first in the pattern, as in `^foo'.
-
- * The syntax bit `RE_CONTEXT_INDEP_ANCHORS' is set, and it is outside
- a bracket expression.
-
- * It follows an open-group or alternation operator, as in `a\(^b\)'
- and `a\|^b'. *Note Grouping Operators::, and *Note Alternation
- Operator::.
-
- These rules imply that some valid patterns containing `^' cannot be
-matched; for example, `foo^bar' if `RE_CONTEXT_INDEP_ANCHORS' is set.
-
- If the `not_bol' field is set in the pattern buffer (*note GNU
-Pattern Buffers::.), then `^' fails to match at the beginning of the
-string. *Note POSIX Matching::, for when you might find this useful.
-
- If the `newline_anchor' field is set in the pattern buffer, then `^'
-fails to match after a newline. This is useful when you do not regard
-the string to be matched as broken into lines.
-
-
-File: regex.info, Node: Match-end-of-line Operator, Prev: Match-beginning-of-line Operator, Up: Anchoring Operators
-
-The Match-end-of-line Operator (`$')
-------------------------------------
-
- 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 "anchor" the pattern to the end of a line.
-
- It is always represented by `$'. For example, `foo$' usually
-matches, e.g., `foo' and, e.g., the first three characters of
-`foo\nbar'.
-
- Its interaction with the syntax bits and pattern buffer fields is
-exactly the dual of `^''s; see the previous section. (That is,
-"beginning" becomes "end", "next" becomes "previous", and "after"
-becomes "before".)
-
-
-File: regex.info, Node: GNU Operators, Next: GNU Emacs Operators, Prev: Common Operators, Up: Top
-
-GNU Operators
-*************
-
- Following are operators that GNU defines (and POSIX doesn't).
-
-* Menu:
-
-* Word Operators::
-* Buffer Operators::
-
-
-File: regex.info, Node: Word Operators, Next: Buffer Operators, Up: GNU Operators
-
-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
-"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
-
-
-File: regex.info, Node: Non-Emacs Syntax Tables, Next: Match-word-boundary Operator, Up: Word Operators
-
-Non-Emacs Syntax Tables
------------------------
-
- A "syntax table" is an array indexed by the characters in your
-character set. In the ASCII encoding, therefore, a syntax table has
-256 elements. Regex always uses a `char *' variable `re_syntax_table'
-as its syntax table. In some cases, it initializes this variable and
-in others it expects you to initialize it.
-
- * If Regex is compiled with the preprocessor symbols `emacs' and
- `SYNTAX_TABLE' both undefined, then Regex allocates
- `re_syntax_table' and initializes an element I either to `Sword'
- (which it defines) if I is a letter, number, or `_', or to zero if
- it's not.
-
- * If Regex is compiled with `emacs' undefined but `SYNTAX_TABLE'
- defined, then Regex expects you to define a `char *' variable
- `re_syntax_table' to be a valid syntax table.
-
- * *Note Emacs Syntax Tables::, for what happens when Regex is
- compiled with the preprocessor symbol `emacs' defined.
-
-
-File: regex.info, Node: Match-word-boundary Operator, Next: Match-within-word Operator, Prev: Non-Emacs Syntax Tables, Up: Word Operators
-
-The Match-word-boundary Operator (`\b')
----------------------------------------
-
- This operator (represented by `\b') matches the empty string at
-either the beginning or the end of a word. For example, `\brat\b'
-matches the separate word `rat'.
-
-
-File: regex.info, Node: Match-within-word Operator, Next: Match-beginning-of-word Operator, Prev: Match-word-boundary Operator, Up: Word Operators
-
-The Match-within-word Operator (`\B')
--------------------------------------
-
- This operator (represented by `\B') matches the empty string within a
-word. For example, `c\Brat\Be' matches `crate', but `dirty \Brat'
-doesn't match `dirty rat'.
-
-
-File: regex.info, Node: Match-beginning-of-word Operator, Next: Match-end-of-word Operator, Prev: Match-within-word Operator, Up: Word Operators
-
-The Match-beginning-of-word Operator (`\<')
--------------------------------------------
-
- This operator (represented by `\<') matches the empty string at the
-beginning of a word.
-
-
-File: regex.info, Node: Match-end-of-word Operator, Next: Match-word-constituent Operator, Prev: Match-beginning-of-word Operator, Up: Word Operators
-
-The Match-end-of-word Operator (`\>')
--------------------------------------
-
- This operator (represented by `\>') matches the empty string at the
-end of a word.
-
-
-File: regex.info, Node: Match-word-constituent Operator, Next: Match-non-word-constituent Operator, Prev: Match-end-of-word Operator, Up: Word Operators
-
-The Match-word-constituent Operator (`\w')
-------------------------------------------
-
- This operator (represented by `\w') matches any word-constituent
-character.
-
-
-File: regex.info, Node: Match-non-word-constituent Operator, Prev: Match-word-constituent Operator, Up: Word Operators
-
-The Match-non-word-constituent Operator (`\W')
-----------------------------------------------
-
- This operator (represented by `\W') matches any character that is not
-word-constituent.
-
-
-File: regex.info, Node: Buffer Operators, Prev: Word Operators, Up: GNU Operators
-
-Buffer Operators
-================
-
- Following are operators which work on buffers. In Emacs, a "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:: \'
-
-
-File: regex.info, Node: Match-beginning-of-buffer Operator, Next: Match-end-of-buffer Operator, Up: Buffer Operators
-
-The Match-beginning-of-buffer Operator (`\`')
----------------------------------------------
-
- This operator (represented by `\`') matches the empty string at the
-beginning of the buffer.
-
-
-File: regex.info, Node: Match-end-of-buffer Operator, Prev: Match-beginning-of-buffer Operator, Up: Buffer Operators
-
-The Match-end-of-buffer Operator (`\'')
----------------------------------------
-
- This operator (represented by `\'') matches the empty string at the
-end of the buffer.
-
-
-File: regex.info, Node: GNU Emacs Operators, Next: What Gets Matched?, Prev: GNU Operators, Up: Top
-
-GNU Emacs Operators
-*******************
-
- Following are operators that GNU defines (and POSIX doesn't) that you
-can use only when Regex is compiled with the preprocessor symbol
-`emacs' defined.
-
-* Menu:
-
-* Syntactic Class Operators::
-
-
-File: regex.info, Node: Syntactic Class Operators, Up: GNU Emacs Operators
-
-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
-
-
-File: regex.info, Node: Emacs Syntax Tables, Next: Match-syntactic-class Operator, Up: Syntactic Class Operators
-
-Emacs Syntax Tables
--------------------
-
- A "syntax table" is an array indexed by the characters in your
-character set. In the ASCII encoding, therefore, a syntax table has
-256 elements.
-
- If Regex is compiled with the preprocessor symbol `emacs' defined,
-then Regex expects you to define and initialize the variable
-`re_syntax_table' to be an Emacs syntax table. Emacs' syntax tables
-are more complicated than Regex's own (*note Non-Emacs Syntax
-Tables::.). *Note Syntax: (emacs)Syntax, for a description of Emacs'
-syntax tables.
-
-
-File: regex.info, Node: Match-syntactic-class Operator, Next: Match-not-syntactic-class Operator, Prev: Emacs Syntax Tables, Up: Syntactic Class Operators
-
-The Match-syntactic-class Operator (`\s'CLASS)
-----------------------------------------------
-
- This operator matches any character whose syntactic class is
-represented by a specified character. `\sCLASS' represents this
-operator where CLASS is the character representing the syntactic class
-you want. For example, `w' represents the syntactic class of
-word-constituent characters, so `\sw' matches any word-constituent
-character.
-
-
-File: regex.info, Node: Match-not-syntactic-class Operator, Prev: Match-syntactic-class Operator, Up: Syntactic Class Operators
-
-The Match-not-syntactic-class Operator (`\S'CLASS)
---------------------------------------------------
-
- This operator is similar to the match-syntactic-class operator except
-that it matches any character whose syntactic class is *not*
-represented by the specified character. `\SCLASS' represents this
-operator. For example, `w' represents the syntactic class of
-word-constituent characters, so `\Sw' matches any character that is not
-word-constituent.
-
-
-File: regex.info, Node: What Gets Matched?, Next: Programming with Regex, Prev: GNU Emacs Operators, Up: Top
-
-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, `(ac*)(c*d[ac]*)\1' matches `acdacaaa', not `acdac', as
-it would if it were to choose the longest match for the first
-subexpression.
-
-
-File: regex.info, Node: Programming with Regex, Next: Copying, Prev: What Gets Matched?, Up: Top
-
-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 GNU, one
-compatible with POSIX and one compatible with Berkeley UNIX.
-
-* Menu:
-
-* GNU Regex Functions::
-* POSIX Regex Functions::
-* BSD Regex Functions::
-
-
-File: regex.info, Node: GNU Regex Functions, Next: POSIX Regex Functions, Up: Programming with Regex
-
-GNU Regex Functions
-===================
-
- If you're writing code that doesn't need to be compatible with either
-POSIX or Berkeley 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 ()
-
-
-File: regex.info, Node: GNU Pattern Buffers, Next: GNU Regular Expression Compiling, Up: GNU Regex Functions
-
-GNU Pattern Buffers
--------------------
-
- To compile, match, or search for a given regular expression, you must
-supply a pattern buffer. A "pattern buffer" holds one compiled regular
-expression.(1)
-
- You can have several different pattern buffers simultaneously, each
-holding a compiled pattern for a different regular expression.
-
- `regex.h' defines the pattern buffer `struct' as follows:
-
- /* 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;
-
- ---------- Footnotes ----------
-
- (1) Regular expressions are also referred to as "patterns," hence
-the name "pattern buffer."
-
-
-File: regex.info, Node: GNU Regular Expression Compiling, Next: GNU Matching, Prev: GNU Pattern Buffers, Up: GNU Regex Functions
-
-GNU Regular Expression Compiling
---------------------------------
-
- In GNU, you can both match and search for a given regular expression.
-To do either, you must first compile it in a pattern buffer (*note GNU
-Pattern Buffers::.).
-
- Regular expressions match according to the syntax with which they were
-compiled; with GNU, you indicate what syntax you want by setting the
-variable `re_syntax_options' (declared in `regex.h' and defined in
-`regex.c') before calling the compiling function, `re_compile_pattern'
-(see below). *Note Syntax Bits::, and *Note Predefined Syntaxes::.
-
- You can change the value of `re_syntax_options' at any time.
-Usually, however, you set its value once and then never change it.
-
- `re_compile_pattern' takes a pattern buffer as an argument. You must
-initialize the following fields:
-
-`translate initialization'
-`translate'
- Initialize this to point to a translate table if you want one, or
- to zero if you don't. We explain translate tables in *Note GNU
- Translate Tables::.
-
-`fastmap'
- Initialize this to nonzero if you want a fastmap, or to zero if you
- don't.
-
-`buffer'
-`allocated'
- If you want `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 `malloc') you want Regex
- to use, set `buffer' to its address and `allocated' to its size (in
- bytes).
-
- `re_compile_pattern' uses `realloc' to extend the space for the
- compiled pattern as necessary.
-
- To compile a pattern buffer, use:
-
- char *
- re_compile_pattern (const char *REGEX, const int REGEX_SIZE,
- struct re_pattern_buffer *PATTERN_BUFFER)
-
-REGEX is the regular expression's address, REGEX_SIZE is its length,
-and PATTERN_BUFFER is the pattern buffer's address.
-
- If `re_compile_pattern' successfully compiles the regular expression,
-it returns zero and sets `*PATTERN_BUFFER' to the compiled pattern. It
-sets the pattern buffer's fields as follows:
-
-`buffer'
- to the compiled pattern.
-
-`used'
- to the number of bytes the compiled pattern in `buffer' occupies.
-
-`syntax'
- to the current value of `re_syntax_options'.
-
-`re_nsub'
- to the number of subexpressions in REGEX.
-
-`fastmap_accurate'
- to zero on the theory that the pattern you're compiling is
- different than the one previously compiled into `buffer'; in that
- case (since you can't make a fastmap without a compiled pattern),
- `fastmap' would either contain an incompatible fastmap, or nothing
- at all.
-
- If `re_compile_pattern' can't compile REGEX, it returns an error
-string corresponding to one of the errors listed in *Note POSIX Regular
-Expression Compiling::.
-
-
-File: regex.info, Node: GNU Matching, Next: GNU Searching, Prev: GNU Regular Expression Compiling, Up: GNU Regex Functions
-
-GNU Matching
-------------
-
- Matching the 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 (*note GNU Regular Expression
-Compiling::.), you can ask the matcher to match that pattern against a
-string using:
-
- int
- re_match (struct re_pattern_buffer *PATTERN_BUFFER,
- const char *STRING, const int SIZE,
- const int START, struct re_registers *REGS)
-
-PATTERN_BUFFER is the address of a pattern buffer containing a compiled
-pattern. STRING is the string you want to match; it can contain
-newline and null characters. SIZE is the length of that string. START
-is the string index at which you want to begin matching; the first
-character of STRING is at index zero. *Note Using Registers::, for a
-explanation of REGS; you can safely pass zero.
-
- `re_match' matches the regular expression in PATTERN_BUFFER against
-the string STRING according to the syntax in PATTERN_BUFFERS's `syntax'
-field. (*Note GNU Regular Expression Compiling::, for how to set it.)
-The function returns -1 if the compiled pattern does not match any part
-of STRING and -2 if an internal error happens; otherwise, it returns
-how many (possibly zero) characters of STRING the pattern matched.
-
- An example: suppose PATTERN_BUFFER points to a pattern buffer
-containing the compiled pattern for `a*', and STRING points to `aaaaab'
-(whereupon SIZE should be 6). Then if START is 2, `re_match' returns 3,
-i.e., `a*' would have matched the last three `a's in STRING. If START
-is 0, `re_match' returns 5, i.e., `a*' would have matched all the `a's
-in STRING. If START is either 5 or 6, it returns zero.
-
- If START is not between zero and SIZE, then `re_match' returns -1.
-
-
-File: regex.info, Node: GNU Searching, Next: Matching/Searching with Split Data, Prev: GNU Matching, Up: GNU Regex Functions
-
-GNU Searching
--------------
-
- "Searching" means trying to match starting at successive positions
-within a string. The function `re_search' does this.
-
- Before calling `re_search', you must compile your regular expression.
-*Note GNU Regular Expression Compiling::.
-
- Here is the function declaration:
-
- int
- re_search (struct re_pattern_buffer *PATTERN_BUFFER,
- const char *STRING, const int SIZE,
- const int START, const int RANGE,
- struct re_registers *REGS)
-
-whose arguments are the same as those to `re_match' (*note GNU
-Matching::.) except that the two arguments START and RANGE replace
-`re_match''s argument START.
-
- If RANGE is positive, then `re_search' attempts a match starting
-first at index START, then at START + 1 if that fails, and so on, up to
-START + RANGE; if RANGE is negative, then it attempts a match starting
-first at index START, then at START -1 if that fails, and so on.
-
- If START is not between zero and SIZE, then `re_search' returns -1.
-When RANGE is positive, `re_search' adjusts RANGE so that START + RANGE
-- 1 is between zero and SIZE, if necessary; that way it won't search
-outside of STRING. Similarly, when RANGE is negative, `re_search'
-adjusts RANGE so that START + RANGE + 1 is between zero and SIZE, if
-necessary.
-
- If the `fastmap' field of PATTERN_BUFFER is zero, `re_search' matches
-starting at consecutive positions; otherwise, it uses `fastmap' to make
-the search more efficient. *Note Searching with Fastmaps::.
-
- If no match is found, `re_search' returns -1. If a match is found,
-it returns the index where the match began. If an internal error
-happens, it returns -2.
-
-
-File: regex.info, Node: Matching/Searching with Split Data, Next: Searching with Fastmaps, Prev: GNU Searching, Up: GNU Regex Functions
-
-Matching and Searching with Split Data
---------------------------------------
-
- Using the functions `re_match_2' and `re_search_2', you can match or
-search in data that is divided into two strings.
-
- The function:
-
- int
- re_match_2 (struct re_pattern_buffer *BUFFER,
- const char *STRING1, const int SIZE1,
- const char *STRING2, const int SIZE2,
- const int START,
- struct re_registers *REGS,
- const int STOP)
-
-is similar to `re_match' (*note GNU Matching::.) except that you pass
-*two* data strings and sizes, and an index STOP beyond which you don't
-want the matcher to try matching. As with `re_match', if it succeeds,
-`re_match_2' returns how many characters of STRING it matched. Regard
-STRING1 and STRING2 as concatenated when you set the arguments START and
-STOP and use the contents of REGS; `re_match_2' never returns a value
-larger than SIZE1 + SIZE2.
-
- The function:
-
- int
- re_search_2 (struct re_pattern_buffer *BUFFER,
- const char *STRING1, const int SIZE1,
- const char *STRING2, const int SIZE2,
- const int START, const int RANGE,
- struct re_registers *REGS,
- const int STOP)
-
-is similarly related to `re_search'.
-
-
-File: regex.info, Node: Searching with Fastmaps, Next: GNU Translate Tables, Prev: Matching/Searching with Split Data, Up: GNU Regex Functions
-
-Searching with 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 "fastmap" is such a
-table.
-
- More specifically, a fastmap is an array indexed by the characters in
-your character set. Under the 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 `fastmap' field. You either can
-compile the fastmap yourself or have `re_search' do it for you; when
-`fastmap' is nonzero, it automatically compiles a fastmap the first
-time you search using a particular compiled pattern.
-
- To compile a fastmap yourself, use:
-
- int
- re_compile_fastmap (struct re_pattern_buffer *PATTERN_BUFFER)
-
-PATTERN_BUFFER is the address of a pattern buffer. If the character C
-could start a match for the pattern, `re_compile_fastmap' makes
-`PATTERN_BUFFER->fastmap[C]' nonzero. It returns 0 if it can compile a
-fastmap and -2 if there is an internal error. For example, if `|' is
-the alternation operator and PATTERN_BUFFER holds the compiled pattern
-for `a|b', then `re_compile_fastmap' sets `fastmap['a']' and
-`fastmap['b']' (and no others).
-
- `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, `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 `re_search' to use a fastmap, store zero in the
-`fastmap' field of the pattern buffer before calling `re_search'.
-
- Once you've initialized a pattern buffer's `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. `re_search' will still either do nothing if `fastmap' is null
-or, if it isn't, compile a new fastmap for the new pattern.
-
-
-File: regex.info, Node: GNU Translate Tables, Next: Using Registers, Prev: Searching with Fastmaps, Up: GNU Regex Functions
-
-GNU Translate Tables
---------------------
-
- If you set the `translate' field of a pattern buffer to a translate
-table, then the 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 "translate table" is an array indexed by the characters in your
-character set. Under the 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 C, they use
-`translate[C]' in its place, with one exception: the character after a
-`\' is not translated. (This ensures that, the operators, e.g., `\B'
-and `\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.(1) Such a table would map all characters except
-lowercase letters to themselves, and lowercase letters to the
-corresponding uppercase ones. Under the ASCII encoding, here's how you
-could initialize such a table (we'll call it `case_fold'):
-
- for (i = 0; i < 256; i++)
- case_fold[i] = i;
- for (i = 'a'; i <= 'z'; i++)
- case_fold[i] = i - ('a' - 'A');
-
- You tell Regex to use a translate table on a given pattern buffer by
-assigning that table's address to the `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.
-
- ---------- Footnotes ----------
-
- (1) A table that maps all uppercase letters to the corresponding
-lowercase ones would work just as well for this purpose.
-
-
-File: regex.info, Node: Using Registers, Next: Freeing GNU Pattern Buffers, Prev: GNU Translate Tables, Up: GNU Regex Functions
-
-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 REGS argument to a GNU
-matching or searching function (*note GNU Matching::. and *Note GNU
-Searching::), i.e., the address of a structure of this type, as defined
-in `regex.h':
-
- struct re_registers
- {
- unsigned num_regs;
- regoff_t *start;
- regoff_t *end;
- };
-
- Except for (possibly) the NUM_REGS'th element (see below), the Ith
-element of the `start' and `end' arrays records information about the
-Ith 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 `start' and `end' arrays are allocated in various ways, depending
-on the value of the `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 `regs_allocated' is `REGS_UNALLOCATED', the
-matcher allocates 1 + RE_NSUB (another field in the pattern buffer;
-*note GNU Pattern Buffers::.). The extra element is set to -1, and
-sets `regs_allocated' to `REGS_REALLOCATE'. Then on subsequent calls
-with the same pattern buffer and REGS arguments, the matcher
-reallocates more space if necessary.
-
- It would perhaps be more logical to make the `regs_allocated' field
-part of the `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.
-
- `re_compile_pattern' sets `regs_allocated' to `REGS_UNALLOCATED', so
-if you use the GNU regular expression functions, you get this behavior
-by default.
-
- xx document re_set_registers
-
- 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 `regs_allocated' is `REGS_FIXED' the matcher simply fills
-that array.
-
- The following examples illustrate the information recorded in the
-`re_registers' structure. (In all of them, `(' represents the
-open-group and `)' the close-group operator. The first character in
-the string STRING is at index 0.)
-
- * If the regular expression has an I-th group not contained within
- another group that matches a substring of STRING, then the
- function sets `REGS->start[I]' to the index in STRING where the
- substring matched by the I-th group begins, and `REGS->end[I]' to
- the index just beyond that substring's end. The function sets
- `REGS->start[0]' and `REGS->end[0]' to analogous information about
- the entire pattern.
-
- For example, when you match `((a)(b))' against `ab', you get:
-
- * 0 in `REGS->start[0]' and 2 in `REGS->end[0]'
-
- * 0 in `REGS->start[1]' and 2 in `REGS->end[1]'
-
- * 0 in `REGS->start[2]' and 1 in `REGS->end[2]'
-
- * 1 in `REGS->start[3]' and 2 in `REGS->end[3]'
-
- * 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 *last* matched.
-
- For example, when you match the pattern `(a)*' against the string
- `aa', you get:
-
- * 0 in `REGS->start[0]' and 2 in `REGS->end[0]'
-
- * 1 in `REGS->start[1]' and 2 in `REGS->end[1]'
-
- * If the 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
- `REGS->start[I]' and `REGS->end[I]' to -1.
-
- For example, when you match the pattern `(a)*b' against the string
- `b', you get:
-
- * 0 in `REGS->start[0]' and 1 in `REGS->end[0]'
-
- * -1 in `REGS->start[1]' and -1 in `REGS->end[1]'
-
- * If the I-th group matches a zero-length string, then the function
- sets `REGS->start[I]' and `REGS->end[I]' to the index just beyond
- that zero-length string.
-
- For example, when you match the pattern `(a*)b' against the string
- `b', you get:
-
- * 0 in `REGS->start[0]' and 1 in `REGS->end[0]'
-
- * 0 in `REGS->start[1]' and 0 in `REGS->end[1]'
-
- * If an I-th group contains a J-th group in turn not contained
- within any other group within group I and the function reports a
- match of the I-th group, then it records in `REGS->start[J]' and
- `REGS->end[J]' the last match (if it matched) of the J-th group.
-
- For example, when you match the pattern `((a*)b)*' against the
- string `abb', group 2 last matches the empty string, so you get
- what it previously matched:
-
- * 0 in `REGS->start[0]' and 3 in `REGS->end[0]'
-
- * 2 in `REGS->start[1]' and 3 in `REGS->end[1]'
-
- * 2 in `REGS->start[2]' and 2 in `REGS->end[2]'
-
- When you match the pattern `((a)*b)*' against the string `abb',
- group 2 doesn't participate in the last match, so you get:
-
- * 0 in `REGS->start[0]' and 3 in `REGS->end[0]'
-
- * 2 in `REGS->start[1]' and 3 in `REGS->end[1]'
-
- * 0 in `REGS->start[2]' and 1 in `REGS->end[2]'
-
- * If an I-th group contains a J-th group in turn not contained
- within any other group within group I and the function sets
- `REGS->start[I]' and `REGS->end[I]' to -1, then it also sets
- `REGS->start[J]' and `REGS->end[J]' to -1.
-
- For example, when you match the pattern `((a)*b)*c' against the
- string `c', you get:
-
- * 0 in `REGS->start[0]' and 1 in `REGS->end[0]'
-
- * -1 in `REGS->start[1]' and -1 in `REGS->end[1]'
-
- * -1 in `REGS->start[2]' and -1 in `REGS->end[2]'
-
-
-File: regex.info, Node: Freeing GNU Pattern Buffers, Prev: Using Registers, Up: GNU Regex Functions
-
-Freeing GNU Pattern Buffers
----------------------------
-
- To free any allocated fields of a pattern buffer, you can use the
-POSIX function described in *Note Freeing POSIX Pattern Buffers::,
-since the type `regex_t'--the type for POSIX pattern buffers--is
-equivalent to the type `re_pattern_buffer'. After freeing a pattern
-buffer, you need to again compile a regular expression in it (*note GNU
-Regular Expression Compiling::.) before passing it to a matching or
-searching function.
-
-
-File: regex.info, Node: POSIX Regex Functions, Next: BSD Regex Functions, Prev: GNU Regex Functions, Up: Programming with Regex
-
-POSIX Regex Functions
-=====================
-
- If you're writing code that has to be POSIX compatible, you'll need
-to use these functions. Their interfaces are as specified by 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 ()
-
-
-File: regex.info, Node: POSIX Pattern Buffers, Next: POSIX Regular Expression Compiling, Up: POSIX Regex Functions
-
-POSIX Pattern Buffers
----------------------
-
- To compile or match a given regular expression the POSIX way, you
-must supply a pattern buffer exactly the way you do for GNU (*note GNU
-Pattern Buffers::.). POSIX pattern buffers have type `regex_t', which
-is equivalent to the GNU pattern buffer type `re_pattern_buffer'.
-
-
-File: regex.info, Node: POSIX Regular Expression Compiling, Next: POSIX Matching, Prev: POSIX Pattern Buffers, Up: POSIX Regex Functions
-
-POSIX Regular Expression Compiling
-----------------------------------
-
- With 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 `regcomp'.
-
- To compile a pattern buffer, use:
-
- int
- regcomp (regex_t *PREG, const char *REGEX, int CFLAGS)
-
-PREG is the initialized pattern buffer's address, REGEX is the regular
-expression's address, and CFLAGS is the compilation flags, which Regex
-considers as a collection of bits. Here are the valid bits, as defined
-in `regex.h':
-
-`REG_EXTENDED'
- says to use POSIX Extended Regular Expression syntax; if this isn't
- set, then says to use POSIX Basic Regular Expression syntax.
- `regcomp' sets PREG's `syntax' field accordingly.
-
-`REG_ICASE'
- says to ignore case; `regcomp' sets PREG's `translate' field to a
- translate table which ignores case, replacing anything you've put
- there before.
-
-`REG_NOSUB'
- says to set PREG's `no_sub' field; *note POSIX Matching::., for
- what this means.
-
-`REG_NEWLINE'
- says that a:
-
- * match-any-character operator (*note Match-any-character
- Operator::.) doesn't match a newline.
-
- * nonmatching list not containing a newline (*note List
- Operators::.) matches a newline.
-
- * match-beginning-of-line operator (*note
- Match-beginning-of-line Operator::.) matches the empty string
- immediately after a newline, regardless of how `REG_NOTBOL'
- is set (*note POSIX Matching::., for an explanation of
- `REG_NOTBOL').
-
- * match-end-of-line operator (*note Match-beginning-of-line
- Operator::.) matches the empty string immediately before a
- newline, regardless of how `REG_NOTEOL' is set (*note POSIX
- Matching::., for an explanation of `REG_NOTEOL').
-
- If `regcomp' successfully compiles the regular expression, it returns
-zero and sets `*PATTERN_BUFFER' to the compiled pattern. Except for
-`syntax' (which it sets as explained above), it also sets the same
-fields the same way as does the GNU compiling function (*note GNU
-Regular Expression Compiling::.).
-
- If `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.)
-
-`REG_BADRPT'
- For example, the consecutive repetition operators `**' in `a**'
- are invalid. As another example, if the syntax is extended
- regular expression syntax, then the repetition operator `*' with
- nothing on which to operate in `*' is invalid.
-
-`REG_BADBR'
- For example, the COUNT `-1' in `a\{-1' is invalid.
-
-`REG_EBRACE'
- For example, `a\{1' is missing a close-interval operator.
-
-`REG_EBRACK'
- For example, `[a' is missing a close-list operator.
-
-`REG_ERANGE'
- For example, the range ending point `z' that collates lower than
- does its starting point `a' in `[z-a]' is invalid. Also, the
- range with the character class `[:alpha:]' as its starting point in
- `[[:alpha:]-|]'.
-
-`REG_ECTYPE'
- For example, the character class name `foo' in `[[:foo:]' is
- invalid.
-
-`REG_EPAREN'
- For example, `a\)' is missing an open-group operator and `\(a' is
- missing a close-group operator.
-
-`REG_ESUBREG'
- For example, the back reference `\2' that refers to a nonexistent
- subexpression in `\(a\)\2' is invalid.
-
-`REG_EEND'
- Returned when a regular expression causes no other more specific
- error.
-
-`REG_EESCAPE'
- For example, the trailing backslash `\' in `a\' is invalid, as is
- the one in `\'.
-
-`REG_BADPAT'
- For example, in the extended regular expression syntax, the empty
- group `()' in `a()b' is invalid.
-
-`REG_ESIZE'
- Returned when a regular expression needs a pattern buffer larger
- than 65536 bytes.
-
-`REG_ESPACE'
- Returned when a regular expression makes Regex to run out of
- memory.
-
-
-File: regex.info, Node: POSIX Matching, Next: Reporting Errors, Prev: POSIX Regular Expression Compiling, Up: POSIX Regex Functions
-
-POSIX Matching
---------------
-
- Matching the 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 (*note POSIX Regular Expression Compiling::.), you can
-ask the matcher to match that pattern against a string using:
-
- int
- regexec (const regex_t *PREG, const char *STRING,
- size_t NMATCH, regmatch_t PMATCH[], int EFLAGS)
-
-PREG is the address of a pattern buffer for a compiled pattern. STRING
-is the string you want to match.
-
- *Note Using Byte Offsets::, for an explanation of PMATCH. If you
-pass zero for NMATCH or you compiled PREG with the compilation flag
-`REG_NOSUB' set, then `regexec' will ignore PMATCH; otherwise, you must
-allocate it to have at least NMATCH elements. `regexec' will record
-NMATCH byte offsets in PMATCH, and set to -1 any unused elements up to
-PMATCH`[NMATCH]' - 1.
-
- EFLAGS specifies "execution flags"--namely, the two bits `REG_NOTBOL'
-and `REG_NOTEOL' (defined in `regex.h'). If you set `REG_NOTBOL', then
-the match-beginning-of-line operator (*note 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.
-`REG_NOTEOL' works analogously for the match-end-of-line operator
-(*note Match-end-of-line Operator::.); it exists for symmetry.
-
- `regexec' tries to find a match for PREG in STRING according to the
-syntax in PREG's `syntax' field. (*Note POSIX Regular Expression
-Compiling::, for how to set it.) The function returns zero if the
-compiled pattern matches STRING and `REG_NOMATCH' (defined in
-`regex.h') if it doesn't.
-
-
-File: regex.info, Node: Reporting Errors, Next: Using Byte Offsets, Prev: POSIX Matching, Up: POSIX Regex Functions
-
-Reporting Errors
-----------------
-
- If either `regcomp' or `regexec' fail, they return a nonzero error
-code, the possibilities for which are defined in `regex.h'. *Note
-POSIX Regular Expression Compiling::, and *Note POSIX Matching::, for
-what these codes mean. To get an error string corresponding to these
-codes, you can use:
-
- size_t
- regerror (int ERRCODE,
- const regex_t *PREG,
- char *ERRBUF,
- size_t ERRBUF_SIZE)
-
-ERRCODE is an error code, PREG is the address of the pattern buffer
-which provoked the error, ERRBUF is the error buffer, and ERRBUF_SIZE
-is ERRBUF's size.
-
- `regerror' returns the size in bytes of the error string
-corresponding to ERRCODE (including its terminating null). If ERRBUF
-and ERRBUF_SIZE are nonzero, it also returns in ERRBUF the first
-ERRBUF_SIZE - 1 characters of the error string, followed by a null.
-eRRBUF_SIZE must be a nonnegative number less than or equal to the size
-in bytes of ERRBUF.
-
- You can call `regerror' with a null ERRBUF and a zero ERRBUF_SIZE to
-determine how large ERRBUF need be to accommodate `regerror''s error
-string.
-
-
-File: regex.info, Node: Using Byte Offsets, Next: Freeing POSIX Pattern Buffers, Prev: Reporting Errors, Up: POSIX Regex Functions
-
-Using Byte Offsets
-------------------
-
- In POSIX, variables of type `regmatch_t' hold analogous information,
-but are not identical to, GNU's registers (*note Using Registers::.).
-To get information about registers in POSIX, pass to `regexec' a
-nonzero PMATCH of type `regmatch_t', i.e., the address of a structure
-of this type, defined in `regex.h':
-
- typedef struct
- {
- regoff_t rm_so;
- regoff_t rm_eo;
- } regmatch_t;
-
- When reading in *Note Using Registers::, about how the matching
-function stores the information into the registers, substitute PMATCH
-for REGS, `PMATCH[I]->rm_so' for `REGS->start[I]' and
-`PMATCH[I]->rm_eo' for `REGS->end[I]'.
-
-
-File: regex.info, Node: Freeing POSIX Pattern Buffers, Prev: Using Byte Offsets, Up: POSIX Regex Functions
-
-Freeing POSIX Pattern Buffers
------------------------------
-
- To free any allocated fields of a pattern buffer, use:
-
- void
- regfree (regex_t *PREG)
-
-PREG is the pattern buffer whose allocated fields you want freed.
-`regfree' also sets PREG's `allocated' and `used' fields to zero.
-After freeing a pattern buffer, you need to again compile a regular
-expression in it (*note POSIX Regular Expression Compiling::.) before
-passing it to the matching function (*note POSIX Matching::.).
-
-
-File: regex.info, Node: BSD Regex Functions, Prev: POSIX Regex Functions, Up: Programming with Regex
-
-BSD Regex Functions
-===================
-
- If you're writing code that has to be Berkeley UNIX compatible,
-you'll need to use these functions whose interfaces are the same as
-those in Berkeley UNIX.
-
-* Menu:
-
-* BSD Regular Expression Compiling:: re_comp ()
-* BSD Searching:: re_exec ()
-
-
-File: regex.info, Node: BSD Regular Expression Compiling, Next: BSD Searching, Up: BSD Regex Functions
-
-BSD Regular Expression Compiling
---------------------------------
-
- With Berkeley 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 `re_syntax_options' (declared in `regex.h' to some syntax
-(*note Regular Expression Syntax::.).
-
- To compile a regular expression use:
-
- char *
- re_comp (char *REGEX)
-
-REGEX is the address of a null-terminated regular expression.
-`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
-`re_comp' with the null string (*not* the empty string) as the
-argument, it doesn't change the contents of the pattern buffer.
-
- If `re_comp' successfully compiles the regular expression, it returns
-zero. If it can't compile the regular expression, it returns an error
-string. `re_comp''s error messages are identical to those of
-`re_compile_pattern' (*note GNU Regular Expression Compiling::.).
-
-
-File: regex.info, Node: BSD Searching, Prev: BSD Regular Expression Compiling, Up: BSD Regex Functions
-
-BSD Searching
--------------
-
- Searching the Berkeley 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 `re_comp' (*note
-BSD Regular Expression Compiling::.), you can ask Regex to search for
-that pattern in a string using:
-
- int
- re_exec (char *STRING)
-
-STRING is the address of the null-terminated string in which you want
-to search.
-
- `re_exec' returns either 1 for success or 0 for failure. It
-automatically uses a GNU fastmap (*note Searching with Fastmaps::.).
-
-
-File: regex.info, Node: Copying, Next: Index, Prev: Programming with Regex, Up: Top
-
-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.
-
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 1. 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.
-
- 2. 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.
-
- 3. 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.
-
- 4. 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.
-
- 5. 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.
-
- 6. 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.
-
- 7. 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.
-
- 8. 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.
-
- 9. 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.
-
- 10. 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.
-
- 11. 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
-
- 12. 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.
-
- 13. 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.
-
-
-File: regex.info, Node: Index, Prev: Copying, Up: Top
-
-Index
-*****
-
-* Menu:
-
-* $: Match-end-of-line Operator.
-* (: Grouping Operators.
-* ): Grouping Operators.
-* *: Match-zero-or-more Operator.
-* +: Match-one-or-more Operator.
-* -: List Operators.
-* .: Match-any-character Operator.
-* :] in regex: Character Class Operators.
-* ?: Match-zero-or-one Operator.
-* {: Interval Operators.
-* }: Interval Operators.
-* [: in regex: Character Class Operators.
-* [^: List Operators.
-* [: List Operators.
-* \': Match-end-of-buffer Operator.
-* \<: Match-beginning-of-word Operator.
-* \>: Match-end-of-word Operator.
-* \{: Interval Operators.
-* \}: Interval Operators.
-* \b: Match-word-boundary Operator.
-* \B: Match-within-word Operator.
-* \s: Match-syntactic-class Operator.
-* \S: Match-not-syntactic-class Operator.
-* \w: Match-word-constituent Operator.
-* \W: Match-non-word-constituent Operator.
-* \`: Match-beginning-of-buffer Operator.
-* \: List Operators.
-* ]: List Operators.
-* ^: List Operators.
-* allocated initialization: GNU Regular Expression Compiling.
-* alternation operator: Alternation Operator.
-* alternation operator and ^: Match-beginning-of-line Operator.
-* anchoring: Anchoring Operators.
-* anchors: Match-end-of-line Operator.
-* anchors: Match-beginning-of-line Operator.
-* Awk: Predefined Syntaxes.
-* back references: Back-reference Operator.
-* backtracking: Match-zero-or-more Operator.
-* backtracking: Alternation Operator.
-* beginning-of-line operator: Match-beginning-of-line Operator.
-* bracket expression: List Operators.
-* buffer field, set by re_compile_pattern: GNU Regular Expression Compiling.
-* buffer initialization: GNU Regular Expression Compiling.
-* character classes: Character Class Operators.
-* Egrep: Predefined Syntaxes.
-* Emacs: Predefined Syntaxes.
-* end in struct re_registers: Using Registers.
-* end-of-line operator: Match-end-of-line Operator.
-* fastmap initialization: GNU Regular Expression Compiling.
-* fastmaps: Searching with Fastmaps.
-* fastmap_accurate field, set by re_compile_pattern: GNU Regular Expression Compiling.
-* Grep: Predefined Syntaxes.
-* grouping: Grouping Operators.
-* ignoring case: POSIX Regular Expression Compiling.
-* interval expression: Interval Operators.
-* matching list: List Operators.
-* matching newline: List Operators.
-* matching with GNU functions: GNU Matching.
-* newline_anchor field in pattern buffer: Match-beginning-of-line Operator.
-* nonmatching list: List Operators.
-* not_bol field in pattern buffer: Match-beginning-of-line Operator.
-* num_regs in struct re_registers: Using Registers.
-* open-group operator and ^: Match-beginning-of-line Operator.
-* or operator: Alternation Operator.
-* parenthesizing: Grouping Operators.
-* pattern buffer initialization: GNU Regular Expression Compiling.
-* pattern buffer, definition of: GNU Pattern Buffers.
-* POSIX Awk: Predefined Syntaxes.
-* range argument to re_search: GNU Searching.
-* regex.c: Overview.
-* regex.h: Overview.
-* regexp anchoring: Anchoring Operators.
-* regmatch_t: Using Byte Offsets.
-* regs_allocated: Using Registers.
-* REGS_FIXED: Using Registers.
-* REGS_REALLOCATE: Using Registers.
-* REGS_UNALLOCATED: Using Registers.
-* regular expressions, syntax of: Regular Expression Syntax.
-* REG_EXTENDED: POSIX Regular Expression Compiling.
-* REG_ICASE: POSIX Regular Expression Compiling.
-* REG_NEWLINE: POSIX Regular Expression Compiling.
-* REG_NOSUB: POSIX Regular Expression Compiling.
-* RE_BACKSLASH_ESCAPE_IN_LIST: Syntax Bits.
-* RE_BK_PLUS_QM: Syntax Bits.
-* RE_CHAR_CLASSES: Syntax Bits.
-* RE_CONTEXT_INDEP_ANCHORS: Syntax Bits.
-* RE_CONTEXT_INDEP_ANCHORS (and ^): Match-beginning-of-line Operator.
-* RE_CONTEXT_INDEP_OPS: Syntax Bits.
-* RE_CONTEXT_INVALID_OPS: Syntax Bits.
-* RE_DOT_NEWLINE: Syntax Bits.
-* RE_DOT_NOT_NULL: Syntax Bits.
-* RE_INTERVALS: Syntax Bits.
-* RE_LIMITED_OPS: Syntax Bits.
-* RE_NEWLINE_ALT: Syntax Bits.
-* RE_NO_BK_BRACES: Syntax Bits.
-* RE_NO_BK_PARENS: Syntax Bits.
-* RE_NO_BK_REFS: Syntax Bits.
-* RE_NO_BK_VBAR: Syntax Bits.
-* RE_NO_EMPTY_RANGES: Syntax Bits.
-* re_nsub field, set by re_compile_pattern: GNU Regular Expression Compiling.
-* re_pattern_buffer definition: GNU Pattern Buffers.
-* re_registers: Using Registers.
-* re_syntax_options initialization: GNU Regular Expression Compiling.
-* RE_UNMATCHED_RIGHT_PAREN_ORD: Syntax Bits.
-* searching with GNU functions: GNU Searching.
-* start argument to re_search: GNU Searching.
-* start in struct re_registers: Using Registers.
-* struct re_pattern_buffer definition: GNU Pattern Buffers.
-* subexpressions: Grouping Operators.
-* syntax field, set by re_compile_pattern: GNU Regular Expression Compiling.
-* syntax bits: Syntax Bits.
-* syntax initialization: GNU Regular Expression Compiling.
-* syntax of regular expressions: Regular Expression Syntax.
-* translate initialization: GNU Regular Expression Compiling.
-* used field, set by re_compile_pattern: GNU Regular Expression Compiling.
-* word boundaries, matching: Match-word-boundary Operator.
-* \: The Backslash Character.
-* \(: Grouping Operators.
-* \): Grouping Operators.
-* \|: Alternation Operator.
-* ^: Match-beginning-of-line Operator.
-* |: Alternation Operator.
-
-
-
-Tag Table:
-Node: Top1064
-Node: Overview4562
-Node: Regular Expression Syntax6746
-Node: Syntax Bits7916
-Node: Predefined Syntaxes14018
-Node: Collating Elements vs. Characters17872
-Node: The Backslash Character18835
-Node: Common Operators21992
-Node: Match-self Operator23445
-Node: Match-any-character Operator23941
-Node: Concatenation Operator24520
-Node: Repetition Operators25017
-Node: Match-zero-or-more Operator25436
-Node: Match-one-or-more Operator27483
-Node: Match-zero-or-one Operator28341
-Node: Interval Operators29196
-Node: Alternation Operator30991
-Node: List Operators32489
-Node: Character Class Operators35272
-Node: Range Operator36901
-Node: Grouping Operators38930
-Node: Back-reference Operator40251
-Node: Anchoring Operators43073
-Node: Match-beginning-of-line Operator43447
-Node: Match-end-of-line Operator44779
-Node: GNU Operators45518
-Node: Word Operators45767
-Node: Non-Emacs Syntax Tables46391
-Node: Match-word-boundary Operator47465
-Node: Match-within-word Operator47858
-Node: Match-beginning-of-word Operator48255
-Node: Match-end-of-word Operator48588
-Node: Match-word-constituent Operator48908
-Node: Match-non-word-constituent Operator49234
-Node: Buffer Operators49545
-Node: Match-beginning-of-buffer Operator49952
-Node: Match-end-of-buffer Operator50264
-Node: GNU Emacs Operators50558
-Node: Syntactic Class Operators50901
-Node: Emacs Syntax Tables51307
-Node: Match-syntactic-class Operator51963
-Node: Match-not-syntactic-class Operator52560
-Node: What Gets Matched?53150
-Node: Programming with Regex53799
-Node: GNU Regex Functions54237
-Node: GNU Pattern Buffers55078
-Node: GNU Regular Expression Compiling58303
-Node: GNU Matching61181
-Node: GNU Searching63101
-Node: Matching/Searching with Split Data64913
-Node: Searching with Fastmaps66369
-Node: GNU Translate Tables68921
-Node: Using Registers70892
-Node: Freeing GNU Pattern Buffers77000
-Node: POSIX Regex Functions77593
-Node: POSIX Pattern Buffers78266
-Node: POSIX Regular Expression Compiling78709
-Node: POSIX Matching82836
-Node: Reporting Errors84791
-Node: Using Byte Offsets86048
-Node: Freeing POSIX Pattern Buffers86861
-Node: BSD Regex Functions87467
-Node: BSD Regular Expression Compiling87886
-Node: BSD Searching89258
-Node: Copying89960
-Node: Index109122
-
-End Tag Table
diff --git a/gnu/lib/libregex/doc/regex.texi b/gnu/lib/libregex/doc/regex.texi
deleted file mode 100644
index d93953e..0000000
--- a/gnu/lib/libregex/doc/regex.texi
+++ /dev/null
@@ -1,3138 +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
-#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_UNMATCHED_RIGHT_PAREN_ORD)
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
-
-#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 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
- /* 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 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
-@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
-@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
-@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
-@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
-@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
-@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
-@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
-@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/doc/xregex.texi b/gnu/lib/libregex/doc/xregex.texi
deleted file mode 100644
index 9292b35..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
-@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
-@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
-@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
-@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
-@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
-@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
-@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
-@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/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 5a8656a..0000000
--- a/gnu/lib/libregex/test/Makefile
+++ /dev/null
@@ -1,169 +0,0 @@
-# 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 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 b6a4133..0000000
--- a/gnu/lib/libregex/test/Makefile.in
+++ /dev/null
@@ -1,168 +0,0 @@
-# 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 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/TAGS b/gnu/lib/libregex/test/TAGS
deleted file mode 100644
index d3aad75..0000000
--- a/gnu/lib/libregex/test/TAGS
+++ /dev/null
@@ -1,373 +0,0 @@
-
-.././regex.c,4137
-#define AT_STRINGS_BEG(3078,98376
-#define AT_STRINGS_END(3079,98449
-#define AT_WORD_BOUNDARY(3093,99002
-#define BUF_PUSH(887,24995
-#define BUF_PUSH_2(895,25208
-#define BUF_PUSH_3(904,25437
-#define DEBUG_POP(2336,74614
-#define DEBUG_PRINT1(471,14296
-#define DEBUG_PRINT1(785,21263
-#define DEBUG_PRINT2(472,14342
-#define DEBUG_PRINT3(473,14398
-#define DEBUG_PRINT3(787,21316
-#define DEBUG_PRINT4(474,14462
-#define DEBUG_PRINT_COMPILED_PATTERN(475,14534
-#define DEBUG_PRINT_COMPILED_PATTERN(789,21386
-#define DEBUG_PRINT_DOUBLE_STRING(477,14637
-#define DEBUG_PUSH(2338,74684
-#define DEBUG_STATEMENT(470,14267
-#define DOUBLE_FAIL_STACK(2299,73230
-#define EVER_MATCHED_SOMETHING(3028,96680
-#define EXTEND_BUFFER(941,26834
-#define EXTRACT_NUMBER(403,12499
-#define EXTRACT_NUMBER(422,12960
-#define EXTRACT_NUMBER_AND_INCR(430,13181
-#define EXTRACT_NUMBER_AND_INCR(448,13583
-#define FAIL_STACK_EMPTY(2271,72289
-#define FAIL_STACK_FULL(2273,72404
-#define FAIL_STACK_PTR_EMPTY(2272,72344
-#define FAIL_STACK_TOP(2274,72473
-#define FIRST_STRING_P(221,5848
-#define FREE_VAR(3100,99186
-#define FREE_VARIABLES(3101,99240
-#define FREE_VARIABLES(3116,99751
-#define GET_BUFFER_SPACE(882,24802
-#define GET_UNSIGNED_NUMBER(1017,29312
-#define INIT_FAIL_STACK(2279,72612
-#define INSERT_JUMP(923,26079
-#define INSERT_JUMP2(927,26236
-#define ISALNUM(147,3407
-#define ISALPHA(148,3455
-#define ISBLANK(135,3062
-#define ISBLANK(137,3116
-#define ISCNTRL(149,3503
-#define ISDIGIT(146,3359
-#define ISGRAPH(140,3185
-#define ISGRAPH(142,3239
-#define ISLOWER(150,3551
-#define ISPRINT(145,3311
-#define ISPUNCT(151,3599
-#define ISSPACE(152,3647
-#define ISUPPER(153,3695
-#define ISXDIGIT(154,3743
-#define IS_ACTIVE(3026,96578
-#define IS_CHAR_CLASS(1035,29793
-#define MATCHED_SOMETHING(3027,96621
-#define MAX(233,6292
-#define MIN(234,6334
-#define PATFETCH(852,23769
-#define PATFETCH_RAW(860,24020
-#define POINTER_TO_OFFSET(3050,97433
-#define POP_FAILURE_ITEM(2331,74426
-#define POP_FAILURE_POINT(2461,79538
-#define PREFETCH(3064,97916
-#define PUSH_FAILURE_ITEM(2327,74253
-#define PUSH_FAILURE_POINT(2352,75048
-#define PUSH_PATTERN_OP(2317,73841
-#define REGEX_REALLOCATE(185,4875
-#define REGEX_REALLOCATE(210,5495
-#define REGEX_TALLOC(227,6137
-#define REG_MATCH_NULL_STRING_P(3025,96511
-#define REG_UNSET(3055,97649
-#define RETALLOC(226,6058
-#define SET_LIST_BIT(1011,29089
-#define SET_REGS_MATCHED(3034,96936
-#define SIGN_EXTEND_CHAR(166,4109
-#define SIGN_EXTEND_CHAR(169,4217
-#define STORE_JUMP(915,25800
-#define STORE_JUMP2(919,25917
-#define STORE_NUMBER(384,11919
-#define STORE_NUMBER_AND_INCR(394,12242
-#define STREQ(231,6244
-#define SYNTAX(120,2790
-#define TALLOC(225,6003
-#define TRANSLATE(873,24503
-#define WORDCHAR_P(3086,98755
-alt_match_null_string_p 4466,149039
-#define assert(782,21217
-at_begline_loc_p 2131,67979
-at_endline_loc_p 2150,68557
-#define bcmp(54,1656
-bcmp_translate 4591,151831
-#define bcopy(57,1726
-typedef char boolean;236,6377
-#define bzero(60,1793
-common_op_match_null_string_p 4503,149895
-compile_range 2200,69997
-} compile_stack_elt_t;990,28602
-} compile_stack_type;998,28748
-extract_number 411,12714
-extract_number_and_incr 438,13370
-} fail_stack_type;2269,72269
-group_in_compile_stack 2172,69174
-group_match_null_string_p 4357,145267
-init_syntax_once 94,2365
-insert_op1 2091,67107
-insert_op2 2110,67475
-#define isascii(131,3018
-typedef int pattern_offset_t;981,28388
-print_compiled_pattern 726,19792
-print_double_string 753,20605
-print_fastmap 486,14835
-print_partial_compiled_pattern 518,15475
-re_comp 4650,153479
-re_compile_fastmap 2532,82428
-re_compile_pattern 4617,152520
-re_exec 4688,154373
-re_match 3136,100557
-re_match_2 3161,101399
-} re_opcode_t;378,11781
-re_search 2844,90872
-re_search_2 2877,91998
-re_set_registers 2817,90247
-re_set_syntax 808,22087
-regcomp 4736,155972
-regerror 4876,160188
-regex_compile 1062,30922
-regexec 4811,158371
-regfree 4920,161247
-} register_info_type;3023,96488
-typedef unsigned regnum_t;974,28172
-store_op1 2063,66535
-store_op2 2076,66768
-typedef const unsigned 2262,72103
-
-.././regex.h,230
-#define _RE_ARGS(394,14981
-#define _RE_ARGS(398,15036
-} reg_errcode_t;270,10874
-typedef unsigned reg_syntax_t;38,1503
-typedef struct re_pattern_buffer regex_t;346,13556
-} regmatch_t;382,14634
-typedef int regoff_t;354,13814
-
-getpagesize.h,84
-#define getpagesize(12,137
-#define getpagesize(15,191
-#define getpagesize(20,302
-
-test.h,436
-#define BRACES_TO_OPS(107,3169
-#define INVALID_PATTERN(110,3328
-#define MATCH_SELF(114,3429
-#define PARENS_TO_OPS(108,3248
-#define SAFE_STRLEN(14,201
-#define TEST_POSITIONED_MATCH(116,3470
-#define TEST_REGISTERS(104,3011
-#define TEST_REGISTERS_2(97,2703
-#define TEST_SEARCH(127,3875
-#define TEST_SEARCH_2(123,3720
-#define TEST_TRUNCATED_MATCH(120,3608
-typedef enum { false = 0, true = 1 } boolean;16,255
-} test_type;33,572
-
-alloca.c,128
-alloca 141,3996
-find_stack_direction 85,2553
-} header;127,3538
-typedef void *pointer;51,1721
-typedef char *pointer;53,1778
-
-bsd-interf.c,51
-test_berk_search 8,106
-test_bsd_interface 33,738
-
-debugmalloc.c,395
-#define TRACE(8,143
-#define TRACE1(9,197
-#define TRACE2(10,254
-#define TRACE3(11,319
-#define TRACE4(12,392
-#define USER_ALLOC(61,1440
-typedef char *address;15,480
-} *chunk;54,1225
-chunk_delete 115,2778
-chunk_insert 96,2294
-chunk_to_mem 79,1916
-free 261,5604
-free_list_available 175,3947
-malloc 203,4343
-mem_to_chunk 68,1703
-realloc 242,5309
-validate_list 153,3478
-xsbrk 21,545
-
-emacsmalloc.c,574
-#define ASSERT(178,5884
-#define ASSERT(181,5985
-#define CHAIN(166,5430
-#define bcmp(73,2821
-#define bcopy(72,2777
-#define bzero(74,2868
-calloc 603,15983
-free 484,13255
-get_lim_data 736,18517
-get_lim_data 752,18767
-get_lim_data 759,18860
-getpool 374,10263
-malloc 413,11133
-malloc_init 218,6863
-malloc_mem_free 707,17940
-malloc_mem_used 688,17683
-malloc_stats 663,17320
-malloc_usable_size 233,7147
-memalign 618,16164
-morecore 244,7380
-realloc 541,14424
-#define start_of_data(110,3486
-#define start_of_data(115,3546
-sys_sbrk 815,20804
-valloc 645,17031
-
-fileregex.c,13
-main 11,156
-
-g++malloc.c,1543
-#define UPDATE_STATS(33,1090
-#define UPDATE_STATS(35,1131
-static inline int aligned_OK(343,11189
-void* calloc(1039,28692
-void cfree(1048,28894
-static inline void* chunk2mem(619,19336
-#define clear_inuse(592,18767
-static inline void consollink(716,21398
-static void do_free_stats(544,18016
-static void do_malloc_stats(534,17741
-766,22304
-extern 762,22235
- for 1260,34165
-void free(1028,28553
-static inline void frontlink(732,21717
-static unsigned int gcd(557,18251
- if 1212,32427
- if 1216,32582
- if 1220,32737
- if 1224,32880
- if 1229,33094
- if 1233,33251
- if 1238,33463
- if 1242,33609
- if 1247,33739
-#define inuse(590,18680
-static inline unsigned int lcm(580,18540
-void* malloc(939,26370
-static mchunkptr malloc_find_space(858,24561
-void malloc_stats(1201,32256
-unsigned int malloc_usable_size(1054,28936
-static volatile void malloc_user_error(286,9757
-static void malloc_user_error(288,9804
-typedef struct malloc_bin* mbinptr;320,10636
-typedef struct malloc_chunk* mchunkptr;309,10247
-static inline mchunkptr mem2chunk(643,19759
-void* memalign(1118,30363
-#define next_chunk(600,18910
-#define prev_chunk(604,19023
-void* realloc(1071,29263
-static inline unsigned int request2size(335,10993
-mchunkptr sanity_check(628,19486
-#define set_inuse(591,18723
-static inline void set_size(609,19149
-static inline mbinptr size2bin(499,16914
-static inline void split(685,20463
-static 768,22312
-static inline void unlink(671,20263
-void* valloc(1194,32107
-typedef volatile void 760,22184
-764,22271
-
-iregex.c,54
-main 20,390
-print_regs 141,2638
-scanstring 87,1839
-
-main.c,13
-main 12,242
-
-malloc-test.c,112
-#define BITS_BLOCK(12,168
-#define BITS_MASK(13,228
-} bits_list_type;6,56
-init_bits_list 16,311
-main(32,621
-
-other.c,18
-test_others 6,96
-
-printchar.c,15
-printchar 2,5
-
-psx-basic.c,23
-test_posix_basic 7,84
-
-psx-extend.c,26
-test_posix_extended 7,88
-
-psx-generic.c,26
-test_posix_generic 8,117
-
-psx-group.c,20
-test_grouping 7,92
-
-psx-interf.c,416
-fill_pmatch 174,4802
-get_error_string 18,260
-init_pattern_buffer 49,1434
-test_compile 67,1925
-test_eflags 245,6876
-test_error_code_allocation 562,16619
-test_error_code_message 524,15247
-test_ignore_case 303,8525
-test_newline 330,9199
-test_nsub 117,3319
-test_pmatch 188,5121
-test_posix_interface 614,18719
-test_posix_match 359,9938
-test_regcomp 138,3725
-test_regerror 592,17621
-test_regexec 394,10783
-
-psx-interv.c,21
-test_intervals 6,93
-
-test.c,607
-#define SET_FASTMAP(447,13999
-#define bcmp(18,362
-#define bcopy(19,415
-#define bzero(20,473
-compile_and_print_pattern 666,19653
-concat 97,2673
-delimiters_to_ops 571,17477
-general_test 115,2996
-invalid_pattern 542,16821
-#define memcmp(26,611
-#define memcpy(27,660
-print_pattern_info 635,18998
-set_all_registers 58,1390
-test_all_registers 506,15567
-test_case_fold 682,19993
-test_fastmap 460,14363
-test_fastmap_search 474,14668
-test_match 776,22235
-test_match_2 766,22040
-test_match_n_times 715,20798
-test_search_return 408,13011
-valid_nonposix_pattern 646,19239
-valid_pattern 557,17182
-
-tregress.c,208
-#define SIMPLE_MATCH(74,1463
-#define SIMPLE_NONMATCH(75,1528
-do_match 78,1599
-itoa 10,199
-simple_compile 44,882
-simple_fail 21,353
-simple_fastmap 55,1115
-simple_search 100,2020
-test_regress 124,2513
-
-upcase.c,0
-
-xmalloc.c,14
-xmalloc 9,87
diff --git a/gnu/lib/libregex/test/alloca.c b/gnu/lib/libregex/test/alloca.c
deleted file mode 100644
index c1ff222..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 56f9e2a..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 5c468e2..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 6eee1fa..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 2c27a0f..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 d55ce45..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 2346d44..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 28ae315..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 d2ceb38..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 52535b6..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 6f02d67..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 340e938..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 8312d5e..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 6725c38..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 a8de23e..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 fb67126..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 7858cac..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 5147b81..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 88be1a6..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/usr.bin/as/COPYING b/gnu/usr.bin/as/COPYING
deleted file mode 100644
index 9a17037..0000000
--- a/gnu/usr.bin/as/COPYING
+++ /dev/null
@@ -1,249 +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/as/ChangeLog b/gnu/usr.bin/as/ChangeLog
deleted file mode 100644
index 3e0e64f..0000000
--- a/gnu/usr.bin/as/ChangeLog
+++ /dev/null
@@ -1,917 +0,0 @@
-Fri Jan 4 12:48:22 EST 1991 Jay Fenlason (hack@ai.mit.edu)
-
- * messages.c Moved as_perror from input-scrub.c Modified the
- error messages to look better.
-
- * output-file.c Don't call as_fatal, just call exit()
-
- expr.c Slightly improve checking for foo-foo case in
- clean_up_expression(). Detect foo: bar: ... foo-bar...
-
-Tue Dec 4 16:29:20 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * m68k.c Fixed an obscure bug involving AOFF mode with a
- large constant displacement (Was forgetting to output the
- extension word.)
-
- make-gas.com Added a three line patch from Eric Youngdale that
- makes it possible to submit make-gas.com to a batch queue.
-
-Wed Nov 21 15:07:51 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * vms.c (VMS_TBT_Routine_END) Add a four line patch from
- Eric Youngdale.
-
-Tue Nov 13 14:02:15 EST 1990 Jay Fenlason (hack@ai.mti.edu)
-
- * vms-dbg.c (VMS_DBG_record()) Another one character patch from
- Eric Youngdale.
-
-Mon Oct 29 15:49:21 EST 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * read.c Replace some as_warn calls with as_bad.
-
-Fri Oct 26 15:21:15 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * i386.c, i860.c, ns32k.c Add const changes.
-
-Mon Oct 22 14:04:26 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * sparc.c Add const changes.
-
- * make-gas.com define const= for VMS, since many older versions of
- GCC don't work correctly with const under VMS.
-
-Thu Oct 18 12:44:11 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * i860.c i860-opcode.h Added patches from rgb@mcc.com
-
- * read.c, symbols.c, vms.c, + new_file vms-dbg-module.c
- Added Eric Youngdale's <YOUNGDALE@v6550c.nrl.navy.mil> VMS debugging
- patches, so debugging GCC output now works.
-
- * hash.c (hash_grow) Remember to blank out the wall entry in the new
- hash table. This is important on systems where malloc() returns
- non-zero storage. . .
-
-Tue Oct 16 10:11:35 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * output-file.c (output_file_create) if output filename is given as
- '-', write to stdout.
-
- * m68k.c Finally get the PCREL code to work right. Add relaxation of
- PCREL stuff This small fix from Ken Woodland
- (kenny%datacube.uucp@uunet.uu.net).
-
- * m68k.c Added some const declarations to constants. (md_relax_table,
- md_pseudo_table, etc. . .)
-
-Thu Oct 11 11:15:10 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * Makefile, read.c, write.c Include the i860 port.
- (New files i860.c i860-opcode.h i860.h)
-
- * m68k.c Fix some addressing modes, (AOFF, AINDEX, etc) to work in
- PC relative mode.
-
- * (all over) Raeburn's const hacking. This reduces the data-space size by
- declaring many tables, etc, as 'const'.
-
-Thu Sep 27 13:43:49 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * m68k.c (get_num) Fix so that 1:w is treated properly.
-
- * Makefile Replace references to a.out.h with a.out.gnu.h
-
-Tue Sep 25 15:50:36 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * sparc.c (md_number_to_imm) Fix so that RELOC_32 locations contain
- zero, so that it will work with some sparc loaders which don't assume
- that the locations in question do. A xix line patch from Michael Bloom
- (usc!srhqla!quad1!psivax!ttidca!mb@zaphod.mps.ohio-state.edu)
-
-Mon Sep 24 11:43:15 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * as.c #include <sys/types.h> if _POSIX_SOURCE defined. This because
- <signal.h> uses pid_t that's defined in it.
-
- * m68k.c reverse the sense of -l option, and allow :w and :l to
- override the default size of AOFF indexes.
-
- Also, allow -l to shorten branches to unknown labels from LONG to WORD.
-
-Thu Sep 13 17:05:09 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * vax.c (md_parse_option) Don't print a warning msg if given -J
-
-Wed Sep 5 14:26:14 EDT 1990 Jay Fenlason
-
- * expr.c (operand) Don't get garbaged high-order bits when given a
- lot of leading zeroes.
-
-Tue Sep 4 11:40:21 EDT 1990 Jay Fenlason
-
- * read.c (pseudo_set) Compain if we're setting the symbol to the
- difference of two symbols which are in different frags. (We can't
- find out how far apart they are.)
-
-Wed Aug 15 12:18:58 EDT 1990 Jay Fenlason
-
- * m68k.c (m68k_ip_op) Dyke out the code that deals with parsing
- :[wl] at the end of expressions since it is handled in get_num()
- and this was putting the result in the wrong place anyway.
- Corrected a couple of other references to ->isiz instead of con?->e_siz
-
-Mon Aug 13 15:53:46 EDT 1990 Jay Fenlason
-
- * read.c Handle .align specially on the sparc, or any other machine
- where OTHER_ALIGN is defined. Added option and comments about it
- to Makefile.
-
-Fri Aug 10 12:24:33 EDT 1990 Jay Fenlason
-
- * m68k.c (get_num) Handle SEG_PASS1 expressions.
-
-Mon Aug 6 16:32:29 EDT 1990 Jay Fenlason
-
- * write.c (fixup_segment) Added two patches for the NS32k
- and SEQUENT A six line patch from Ian Dall
- (asgard!aegir!hugin!augean!sibyl!ian@munnari.oz.au)
-
-Wed Aug 1 13:30:48 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * m68k.c Include REGISTER_PREFIX ifdefs.
-
- * write.c Include LOCAL_LABEL() and DOT_LABEL_PREFIX feature.
-
- * vax.c (md_parse_option) Accept -H option.
-
- * vms.c New version of case hasher, etc. These from Eric Youngdale
- <YOUNGDALE@v6550c.nrl.navy.mil>
-
-Fri Jul 20 13:39:02 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * README Added README.APOLLO and README.COFF stuff
-
-Wed Jul 18 16:29:22 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * Makefile Added option for SEQUENT_COMPATABILITY
-
- * ns32k.c Add configurable syntax feature from
- ian@sibyl.eleceng.ua.oz@augean.ua.oz.au
- and SEQUENT_COMPATABILITY
-
- * ns32k-opcode.h Add configurable syntax feature.
-
-Mon Jul 16 11:44:14 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * write.c (relax_segment) On ns32k, add fragP->fr_pcrel_adjust to
- aim.
- (fixup_segment) On ns32k, don't subtract size from
- add_number on pcrel external symbols.
-
- * ns32k.c (md_relax_table) Use correct max displacements.
- This is a six-line patch from ian@sibyl.eleceng.ua.oz.au
-
- * ns32k.c (md_atof, convert_iif) Emit floating point numbers in
- the correct byte order. A seven line patch from
- ian@sibyl.eleceng.ua.oz.au
-
- * ns32k.c (all over) Some lint fixes.
-
-Mon Jul 9 13:17:00 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * app.c (do_scrub_next_char) If a comment is #{whitespace}
- don't treat the next line as comment also.
-
- * m68k.c (...) Accept apc@(num:[wl]), etc.
-
- * i386.c (md_assemble) Get bitfields correct when doing cross
- assembly to 386. A two line patch from Michael Bloom.
- (usc!srhqla!quad1!ttidca!mb@zaphod.mps.ohio-state.edu).
-
- * README.APOLLO a new file with vasta@apollo's name, address
- and phone # in it.
-
- * make-gas.com Deleted references to gdb source files.
-
-Fri Jul 6 14:34:27 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * i386.c Ignore the .optim directive
-
- * input-file.c Change from _IOLBF to _IOFBF in setbuffer emulation
- for SYSV.
-
-Mon Jun 18 15:36:49 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * sparc.c #ifdef DONTDEF s_sparc_align, since it isn't called from
- anywhere.
-
-Fri Jun 15 15:53:30 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * vax.c (md_parse_option) make the code agree with the documentation
- on the behaviour of the -d option.
-
-Thu Jun 7 14:23:54 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * atof-ieee.c (gen_to_words) Assemble 0r-0 correctly.
-
- * Makefile Remove last references to gdb*.c files.
-
- * version.c New version 1.36
-
-Tue May 22 13:22:26 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
-
- * Makefile Mention a work-around for a possible problem with HPUX7.0
-
-Mon May 21 14:06:04 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * sparc.c (sparc_ip): Change error message from "not in hash table"
- to "unknown opcode".
-
-Wed May 16 15:33:14 EDT 1990 hack@wookumz
-
- * i386.c (i386_operand) Print error msg if given an operand like
- 4(mumble) which we can't parse.
-
- * m68k.c (md_assemble) Add '3' to the list of operand-places that
- can be found in 'symbol-dependent info'. Also change
- 'confusing width' diagnostic to something more meaningful.
-
-Fri May 11 12:09:21 EDT 1990 hack@wookumz
-
- app.c (do_scrub_next_char) Don't flush the line after a line
- consisting of a single '/' A one-line patch from Mike Kupfer
- (kupfer@orc.olivetti.com)
-
- * i386.c (md_assemble) Call frag_wane() before calling frag_new()
- A one line patch from Steve Bleazard (steve@robobar.co.uk
-
-Tue May 8 12:56:25 EDT 1990 hack@wookumz
-
- * atof-generic.c (atof-generic) Modified the Infinity detection code
- to accept 0rinfinity and 0r-infinity as well as 0rinf and 0r-inf
-
-Thu Apr 26 15:17:31 EDT 1990 hack@wookumz
-
- * atof-ieee.c Change value of NaNs to 0x7fff ffff (float) and
- 0x7fff ffff ffff ffff (double) If you want some other value for
- NaN, use .long and spell it out yourself.
-
- atof-generic.c (atof_generic) Cleaned up code that detects NaN
- and Inf.
-
- vax.c (md_assemble) print a useful error message if expression()
- returns SEG_PASS1 or SEG_DIFFERENCE and we can't deal with those.
-
-Thu Apr 19 10:30:47 EDT 1990 hack@wookumz
-
- * input-scrub.c (AFTER_STRING) Make AFTER_STRING contain a null
- so that the strstr() call when looking for "#NO_APP" after a "#APP"
- will work. A two character patch from Bruce Robertson
- (bruce@heather.pooh.com)
-
- * Makefile, i386.c Use atof-ieee.c instead of atof-i386.c
-
-Mon Apr 16 16:20:55 EDT 1990 hack@wookumz
-
- * m68k.c (md_relax_table) Many of the offsets were off by two.
- Fixed some generic spacing problems thoughout the file.
-
-Thu Apr 12 12:22:35 EDT 1990 hack@wookumz
-
- * sparc.c (md_ri_to_chars) Handle little-endian cross assembly.
-
- * write.c (relax_segment) Compare addresses correctly to avoid
- accidentally relaxing a branch that we don't have to.
- These small changes from John Gilmore (gnu@toad.com)
-
-Fri Apr 6 12:52:15 EDT 1990 hack@wookumz
-
- * Makefile, expr.c symbols.c Correctly document the SUN_ASM_SYNTAX
- option, and make it work.
-
-Tue Mar 20 12:46:59 EST 1990
-
- * as.c (main) Only trap SIGHUP, SIGINT, SIGPIPE, and SIGTERM,
- and only if they aren't being ignored. A three line patch
- from Paul Eggert (eggert@twinsun.com)
-
- * write.c (relax_segment) Correct typo 'growth - ' should have been
- growth =
-
- * atof-vax.c (next_bits, flonum_gen2vax) Clean up by sharing some
- variables. While we're at it, fix next_bits so that it
- doesn't use littlenums that don't exist. . .
-
-Tue Mar 13 16:23:21 EST 1990 hack@wookumz
-
- * Rename atof-m68k.c atof-ieee.c
-
- * Delete atof-ns32k.c
-
- * m68k.c sparc.c ns32k.c atof-ieee.c Call atof-ieee instead of
- atof-m68k or atof-ns32k
-
- * Makefile Compile with atof-ieee.c instead of atof-ns32k.c or
- atof-m68k.c
-
-Mon Mar 12 14:06:55 EST 1990 hack@wookumz
-
- * as.c If the signal handler gets called twice, exit immediatly.
-
- * ns32k.c Call gen_to_words with a pointer of the proper type, and
- call md_number_to_chars to put the results in the proper byte-order.
- Whoever wrote this code was *sloppy*!
-
- * Makefile ns32k.o depends on ns32k.c
-
- * vax.c (md_parse_option) If VMS, accept -+ and -h options.
-
- * vms.c (VMS_Case_Hack_Symbol) Replace #if NO_CASE_HACKING
- with references to the -h option. These small VMS patches
- from Angel Li (angel@flipper.miami.edu).
-
-Thu Mar 8 19:18:59 EST 1990 hack@wookumz
- * vms.c Some trivial patches from Eric Youngdale
- (YOUNGDALE@v6550c.nrl.navy.mil)
-
-Wed Mar 7 17:12:09 EST 1990 hack@wookumz
- * make-gas.com (Define error as as_fatal when compiling vax.c and vms.c
- A two line patch from Eric Youngdale
- (YOUNGDALE@v6550c.nrl.navy.mil)
-
-Tue Mar 6 16:01:09 EST 1990 hack@wookumz
-
- * Makefile Include ns32k options in makefile. A small patch from
- David Taylor (taylor@think.com).
-
- * as.c read.c write.c Makefile #ifdef DONTDEF out all the gdb
- symbol stuff, since it isn't used anymore and it doesn't work.
-
-Mon Mar 5 14:51:04 EST 1990 hack@wookumz
-
- * i386.c (md_assemble) Replace memchr() with index().
-
- * as.c Trap signals 1 through NSIG, print an error msg, and don't
- produce an object file.
-
- * m68k.c Added a hack so that fsincosx fpx,fpy:fpz works.
-
- * messages.c New function: as_bad This is like as_warn, except
- -W doesn't disable it, and calling it inhibits production of an
- object file and causes a non-zero exit code.
-
-Tue Feb 13 14:25:53 EST 1990 hack@wookumz
- * Makefile Include G0 and LOADLIBES for Sequent Symmetry.
- Based on a small patch from Johan Widen (jw@sics.se)
-
-Thu Feb 1 14:08:58 EST 1990 hack@wookumz
- * m68k.c Replace 'abort' with 'abort()' which will work.
-
-Wed Jan 24 17:15:08 EST 1990 hack@ai.mit.edu
-
- * read.c (ignore_rest_of_line) Have it print the first junk char
- in both decimal and %c form.
-
- (read_a_source_file) On bad pseudo-op, print out the unknown
- pseudo-op's name.
-
-Tue Jan 23 13:12:48 EST 1990 hack@ai.mit.edu
-
- * read.c (pseudo_set) If the symbol is external, have it remain
- external.
-
- * i386-opcode.h Allow jc as a synonym for jb and jnc as a syn for jnb.
-
-
-Wed Jan 3 09:35:31 EST 1990 hack@ai.mit.edu
-
- * ns32k.c [cpureg_032] Change register id of psr from 0x0b to 0x0d
- * ns32k-opcode.h Change shift-counts for lsh and lshd
- to one byte instead of 2 and 4.
- A Trivial patch from John F. Peters (think!ames!practic.com!jfp@eddie)
-
-Tue Dec 5 16:37:44 EST 1989 hack@ai.mit.edu
-
- * ns32k.c (md_create_{long,short}_jump) Six line patch from
- John F Peters (think!ames!vine!practice.com!jfp) to use the
- correct addressing mode and byte-order for broken-word stuff.
-
- * write.c (write_object_file) One line patch to call fix_new_ns32k
- with the correct # of args.
-
-Fri Dec 1 16:44:21 EST 1989 hack@ai.mit.edu
-
- * atof-generic.c, flonum-mult.c A real fix for the trailing-zeroes
- problem from Georg Feil (ghfeil@white.toronto.edu) (two line change)
-
-Mon Nov 27 15:30:46 EST 1989 hack@ai.mit.edu
-
- * i386-opcode.h Fixed opcode-table entry for ljmp. A one char
- patch from eliot@mgm.mit.edu
-
-Mon Nov 20 12:41:28 EST 1989 hack@ai.mit.edu
-
- * expr.c Replace the generic_buffer hack with a more portable one */
-
- * atof-generic.c (atof_generic) Ignore trailing zeroes after a decimal
- point. For some reason trailing zeroes (but not trailing nonzeroes) were
- causing loss of precision. I don't know why. . .
-
- * vms.c Change copyright notice. Install changes from Kenneth Adelman
- (adelman@tgv.com) for c++? (A dozen lines or so)
-
-Mon Nov 13 11:48:44 EST 1989 hack@ai.mit.edu
-
- * Makefile Add BINDIR and use it to control where the executable is
- installed.
-
- * i386.c Use __builtin_alloca if possible (trivial patch from
- Marco S. Hyman pacbell!dumbcat!marc)
-
-Mon Nov 6 18:24:47 EST 1989 hack@ai.mit.edu
-
- * version.c New version: 1.35 will be distributed with the
- 1.36 gcc release.
-
-Mon Oct 30 10:38:11 EST 1989 hack@ai.mit.edu
-
- * atof-m68k.c (atof_m68k) Don't put the bits[] array on the stack,
- since it may be pointed to after atof-m68k exits.
-
-Tue Oct 24 11:15:57 EDT 1989 hack@ai.mit.edu
-
- * atof-m68k.c Added #define for bcopy on USG systems.
- #ifdef TEST the print_gen() function.
-
- * a.out.h if USE_HP_INC_HDR then use ../binutils/hp-include/a.out.h
-
-Fri Oct 13 14:36:48 EDT 1989 hack@ai.mit.edu
-
- * vax.c (all) Ran vax through indent -gnu to make it readable.
-
- vax.c (vip_op) Correctly assemble code like jmp $*0x11223344
- by setting vip_nbytes to 4 when using an immediate address.
- I hope this works!
-
- m68k.c (s_proc (new)) Added s_proc no-op pseudo-op.
-
- Makefile Added instructions for compiling on Sequent Symmetry
- and HP 9000/300.
-
- a.out.h Modified to compile on Sequent and HP above. (HP port
- based on a msg from asjl@comp.vuw.ac.nz (real name unknown)).
-
-Tue Oct 10 14:39:44 EDT 1989 hack@ai.mit.edu
- * vax.c (vip_op) Fixed a typo in an error msg and cleaned
- up some spacing stuff.
-
-Wed Sep 27 19:07:12 EDT 1989 hack@ai.mit.edu
-
- * app.c (do_scrub_next_char) Fixed parsing of
- # <line> "file" garbage
- text so that it'll work again? (8 line patch from Mike Hibler
- (mike@cs.utah.edu))
-
-Mon Sep 18 16:26:01 EDT 1989 hack@ai.mit.edu
-
- * app.c (do_scrub_next_char): Modify parsing of /* ... */ to work
- on the text /* ****/
-
- * sparc.c (sparc_ip): Don't abort on insns that use the Alternate
- Spaces. Try to assemble them correctly.
-
-Thu Sep 14 11:42:44 EDT 1989 hack@ai.mit.edu
-
- * sparc.c (md_number_to_imm) Dozen line patch from jkp@sauna.hut.fi
- (Jyrki Kuoppala) so that gas output will work with shared libraries.
-
- * ns32k.c Include <string.h> instead of <strings.h> if USG defined.
-
- (md_end) free(freeptr_static) instead of free(freeptr) .
-
- * atof-ns32k.c Include as.h so that sysV stuff (bzero) will be
- defined if needed. These ns32k changes from
- nixbur!mollers.pad@seismo.css.gov (Josef Moellers)
-
-Fri Sep 1 11:39:52 EDT 1989 hack@ai.mit.edu
-
- * atof-m68k.c (gen_to_words) Get the sign right on negative
- floating-point numbers.
-
-Wed Aug 30 13:59:57 EDT 1989 hack@ai.mit.edu
-
- * Makefile Remove the rest of the $< entries that kill sun make
-
-Fri Aug 25 15:00:30 EDT 1989 Nobody You Know (hack@ai.mit.edu)
-
- * atof-m68k.c (gen_to_words) deal with denormalized floating-point
- numbers.
-
-Tue Aug 22 02:03:05 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * Makefile (gas-dist.tar): Put ChangeLog in the tar file.
-
- * version.c: Added comment telling Jay Fenl--I mean people--not to put
- changes in version.c, but to use ChangeLog instead.
-
- * version.c (version_string): Put "GNU" in all-caps.
-
- * version.c: Moved all comments about changes to ChangeLog (this file).
- Many anonymous entries have been attributed to Jay Fenlason (hack).
-
-Thu Aug 17 15:53:57 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu)
-
- * Makefile: Removed $< references that seem
- to choke some versions of make.
-
- * frags.c (frag_grow): Fixed to deal with requests for very
- large frags (larger than frags.chunk_size).
-
- * app.c (do_scrub_next_char): Have it ignore any characters
- after the filename in a # line "filename".
-
- * sparc.c (s_common): On an error, don't print out
- input_line_pointer past the end of the line where the error is.
-
- * atof-generic.c (atof_generic): Accept any case for
- inf and nan.
-
- * m68k.c (m68_ip): Don't use PC-relative mode for alterable
- addressing modes.
-
-Tue Aug 15 04:58:36 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu)
-
- * sparc.c (md_begin): Rewrote this function to perform consistency
- checks with the new opcode table.
-
-Fri Aug 11 16:01:16 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu)
-
- * sparc-opcode.h (struct sparc_opcode): Replaced `mask' field with
- `lose'; removed `last' field. Updated all opcodes accordingly.
- Fixed several opcodes that generated the wrong instructions.
- sparc.c (md_begin, sparc_ip): Changed to use new struct sparc_opcode.
-
-Thu Aug 3 14:44:24 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu)
-
- * Makefile (a32k): Use read- and write-ns32k.o
- * ns32k.c (encode_operand): Make sure pcrel_adjust starts out zeroed.
- * read.c (cons): Call fix_new_ns32k() if NS32K is defined.
- * write.c (write_object_file): Ditto.
- These so that .word sym-sym (etc) will produce values with
- the proper byte-order.
-
-Wed Aug 2 12:55:?? 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu)
-
- * sparc.c (comment_chars[]): Removed '|' because it was causing
- problems. Probably not the best fix, since I suspect other
- assemblers (68020) may get | in .stabs also, and the 68020 needs
- the '|' comment character.
-
-Mon Jul 31 09:22:28 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu)
-
- * sparc.c (sparc_ip): Allow the characters [0123] in opcodes.
-
-Tue Jul 25 16:32:12 1989 Jay Fenlason (hack)
-
- * atof-generic.c (atof_generic): Tried to keep
- size_of_digits_in_littlenum from going negative.
-
- * sparc-opcode.h: Added duplicate [i+1] entries to go with
- the [1+i] entries already there. A kludgy fix, but it works.
-
-Mon Jul 24 17:20:03 1989 Jay Fenlason (hack)
-
- * write.c (relax_segment): Modified rs_org code so it won't
- occasionally dump core.
-
- * write.c (pseudo_set): Modified SEG_DIFFERENCE to (perhaps)
- allow one to set a symbol to the difference of two other symbols.
-
- * ns32k.c (convert_iif): Moved size_so_far+=size and size=0 inside
- the check for a valid type.
-
- * sparc-opcode.h: Modified the entries for std "q,[1+i]", "D,[1+i]",
- and "Q,[1+i]".
-
-(In version 1.34) Jay Fenlason (hack)
-
- * Makefile: Reorganized, added stuff to make asparc.
-
- * sparc.c, sparc-opcode.h, sparc.h: Sparc port.
-
- * write.c: Set the size of text and bss segments to a multiple of eight
- bytes.
-
- * m68k.c: Moved .single pseudo-op to machine independent part.
-
- * atof-generic.c: Fixed type in #ifdef __GNUC__.
-
- * sparc-opcode.h: Handle "mov REG, %y".
-
- * make-gas.com: Know that error.c no longer exists.
-
- * sparc.c: Handle [expr+reg].
- Don't call getExpression when looking for an immediate and getting
- something that starts with % and isn't %hi or %lo.
-
- * Teach the 68k about long conditional branches.
-
-(In version 1.33) Jay Fenlason (hack)
-
- * Use __builtin_alloca if available.
-
- * README: Added more instructions for reporting bugs.
-
- * ns32k-opcode.h: Changed the acbb, acbw, and acbd insns.
-
- * vax.c: Replaced instances of LENGTH[STRING] with STRING[LENGTH].
-
- * ns32k.c (encode_operand): Increased max size of bit field for exts
- and inss instructions from 31 to 32 bits.
-
- * flonum-mult.c (flonum_multip): Fixed typo.
-
- * m68kc.: Allow #32 to be the same as #0 for bit-field ops.
-
- * make-gas.com, version.c, hex-value.c, flonum-const.c: VMS fixes.
-
- * ns32k.c, ns32k-opcode.h: More fixes from taylor@think.com.
- Mostly typos in comments, etc.
-
- * ns32k-opcode.h: Fixed size of immediate operands to andw and andd
- instructions.
-
-(In version 1.32) Jay Fenlason (hack)
-
- * read.c (s_set): Fixed misnamed variable.
-
- * as.c: Don't hang if given an invalid option.
-
- * m68k.c: Fixed bug in creating absolute long addresses for branches.
-
- * ns3k*: Some small ns32k patches.
-
- * m68k.c: Recognize 0rnan, 0rinf, 0r-inf.
-
- * app.c: Don't dump core on unterminated strings.
-
- * symbols.c: Give reasonable error messages.
-
- * ns32k*: Allow -m32032 and -m32532 options.
-
- * atof-*.c: Added support for NaN, Inf, and -Inf in atof_generic and
- the various descriptions.
-
- * m68k.c (add_fix): Replace occurrences of "width==" with
- "(width)==". This correct a precedence problem.
-
- * write.c, struc-symbol.h, m68k-opcode.h, m-hpux.h, Makefile: Changes
- for HP-UX from Chris Hanson (cph@kleph.ai.mit.edu).
-
- * m68k-opcode.h: Reorder movem insns so gdb will see the ones using the
- register list syntax first.
-
- * symbols.c (colon): Give more useful error messages when something was
- defined as a .comm and is now trying to be defined locally.
- Also, redefining a symbol is a fatal, not a warning.
-
- * m68k.c: Fixed a bug in using bignums as literal bit patterns for
- floating-point numbers.
-
-(In version 1.31) Jay Fenlason (hack)
-
- * i386*: More patches.
-
- * Moved machine-dependent option parsing into the machine-dependent
- source files.
-
-(In version 1.30) Jay Fenlason (hack)
-
- * i386*: New new version.
-
- * atof-m68k.c: Changed to be smaller, with somewhat better modularity.
- Also fixed an obscure bug wherein next_bits would return random bits.
-
- * m68k.c: Be more careful about creating PC-relative addressing modes
- on the 68000 and 68010.
-
- * frags.c (frag_new): Zero out the new frag.
-
- * Don't choke on "foo= bar" or on formfeeds.
-
- * read.c: Allow Sun-syntax local labels #ifdef SUN_ASM_SYNTAX.
- * m-sun3.h: Defined SUN_ASM_SYNTAX.
-
-(In version 1.29) Jay Fenlason (hack)
-
- * i386.c: Newer version that fixes a bug wherein a jump instruction
- would be split between two frags.
-
- * i386*: New version.
-
- * m68k.c: #ifdef M_SUN and -m68010, produce Sun-2 executables.
-
-(In version 1.28) Jay Fenlason (hack)
-
- * m68k.c: Added .single pseudo-op.
-
- * Made ". = X" and ".set .,X" equivalent to ".org X".
- The pseudo-symbol "." has the value of the location the assembler is
- currently assembling to.
-
-(In version 1.27) Jay Fenlason (hack)
-
- * Merged ns32k and i386 support.
-
-(In version 1.26) Jay Fenlason (hack)
-
- * Added partial ns32k support.
-
- * Added RMS's evil .word misfeature. Invented the -k (kludge) option
- to warn that this misfeature was used.
-
- * Modified some files to get rid of warnings from GCC.
-
- * Added fix so that / can also be a comment character by itself.
-
-(In version 1.25) Jay Fenlason (hack)
-
- * Installed patches for VMS.
-
- * as.h (SIZEOF_STRUCT_FRAG): Added space before backslash-newline.
-
- * messages.c: Fixed typo.
-
- * app.c: Handle : correctly.
-
- * error.c: Removed; no longer used.
-
- * m68k-opcode.h: Added fnop.
- Fixed to correctly handle fmovem with a register list and
- non-predecriment addressing mode.
-
- * m68k-opcode.h: Fixed to know about long form of FBcc insns.
-
- * write.c: Warn if a fixup ended up being wider than its field width.
-
-(In version 1.24) Jay Fenlason (hack)
-
- * Accept and ignore -mc68010 and -m68010 switches.
-
- * Correctly assemble long subroutine calls on the 68000 without using a
- 68020-specific instruction.
-
- * When calling with no filenames, read stdin.
-
-(In version 1.23) Jay Fenlason (hack)
-
- * app.c: Rewritten.
-
- * xmalloc.c, xrealloc.c: Replaced to work with GCC.
-
-(In version 1.22) Jay Fenlason (hack)
-
- * write.c: Fixed a VMS bug.
-
- * m68k.c: Fixed a bug having to do with turning absolute into
- PC-relative.
-
- * atof-m68k.c (atof_m68k, gen_to_words): Try to avoid a problem with
- running off the end of the LITTLENUMS.
-
- * vax.c: Fixed so parenthesized expressions work.
-
- * atof-generic.c: Added a cast that fixes problems with some C
- compilers.
-
-(In version 1.21)
-
- * Changes for VMS support and correct bitfield order for
- cross-assembly.
-
-(In version 1.20)
-
- * m68k*: Fixed "fmovel #N, fpcr". Added fpcr and fpsr to the list of
- registers.
-
-(In version 1.19)
-
- * m68k.c? (md_convert_frag): Don't put the fixups for absolute long to
- PC-relative in the data segment.
-
- * atof-generic.c: #include <alloca.h> #ifdef sparc.
-
-(In version 1.18)
-
- * Re-fixed _vfprintf stuff (?).
-
- * Made "movem REG, ADDR" work.
-
- * Improved preprocessing, without temporary files.
-
-(In version 1.17)
-
- * Don't produce an undefined empty symbol for ".globl foo," (a line
- ending with a comma).
-
- * Fixed a bug wherein ".long X" became ".long 0" on the Sparc.
-
- * Fixed a bug which caused many "#APP" "#NO_APP" pairs to dump core.
-
- * Fixed calls to _doprnt to call _vfprintf #ifndef NO_VARARGS.
-
-(In version 1.16)
-
- * Merged HP-UX changes from Chris Hanson (cph@zurich.ai.mit.edu).
-
- * flonum-multip.c: Renamed to flonum-mult.c.
-
- * m-hpux.h: Created.
-
- * m68k.c (bcopy): Fixed.
-
-(In version 1.15)
-
- * struct-symbol.h: Renamed to struc-symbol.h.
-
-(In version 1.14)
-
- * vax.c: Added a quick fix for the offset of fixed-width branches not
- fitting in the field given.
-
- * gdb-lines.c, read.c: Added support for .gdline and .gdbline
- pseudo-ops.
-
-(In version 1.13)
-
- * read.c, atof-generic.c: Fixed bugs in reading in floating-point
- numbers.
-
- * m68k-opcode.h: Made "fmovep a0@, fp0" work.
-
-(In version 1.12)
-
- * write.c: Fixed an obscure bug in relaction that would occasionally
- cause the assembler to stop relaxing when it really had at least one
- more pass to do.
-
-(In version 1.11)
-
- * m68k*: Allow register lists in fmovem.
-
- * Added more floating-point exponents.
-
- * Print an error message on exponent overflow.
-
-(In version 1.10)
-
- * Fixed floating point bugs that made it generate incorrect numbers for
- values over 10^16 or so.
-
-(In version 1.09)
-
- * Fixed bug wherein you couldn't forward reference local label 0.
-
-(In version 1.08)
-
- * m68k.c, m68k-opcode.h: Added support for fmovem with register lists.
-
- * Fixed an obscure bug having to do with generating PC-relative
- addressing mode for things in the middle of the instruction instead of
- at the end.
-
-Wed Mar 1 15:29:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * *.*: Modified copyright notices to reflect new General Public
- License.
-
- * Makefile: Added copyright notice.
-
-Fri Feb 17 09:42:01 1989 Jay Fenlason (hack at spiff)
-
- * Patched frags.c so that new frags start out bzero()ed.
-
-Thu Jan 26 14:23:44 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu)
-
- * Added patches from pace to files as.h i386.c i386-opcode.h
- imull foo,%eax no longer gets assembled into the 32-64 bit
- multiply, which clobbers %edx behind gcc's back
-
- jcxz/jecxz were backwards
-
- There was a bug when using %ebp as a base register with no
- displacement
-
- Instructions like andb $0xffffff, %al used to put out too many
- immediate bytes
-
- The splitting jump instructions across frags could happen when
- obstack_room()==6 too.
-
-Local Variables:
-mode: indented-text
-left-margin: 8
-version-control: never
-End:
diff --git a/gnu/usr.bin/as/Makefile b/gnu/usr.bin/as/Makefile
deleted file mode 100644
index e75351b6..0000000
--- a/gnu/usr.bin/as/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# @(#)Makefile 6.1 (Berkeley) 3/3/91
-
-PROG= as
-SRCS= app.c append.c as.c atof-generic.c bignum-copy.c \
- expr.c flonum-const.c flonum-copy.c flonum-mult.c \
- frags.c hash.c hex-value.c input-file.c input-scrub.c \
- messages.c obstack.c output-file.c read.c subsegs.c \
- symbols.c version.c write.c xmalloc.c xrealloc.c
-CFLAGS+= -I$(.CURDIR) -I$(.CURDIR)/config \
- -DSIGTY=void -Derror=as_fatal
-.PATH: $(.CURDIR)/config
-
-.include "config/Makefile.$(MACHINE)"
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/as/Makefile.gnu b/gnu/usr.bin/as/Makefile.gnu
deleted file mode 100644
index 4b81b0c..0000000
--- a/gnu/usr.bin/as/Makefile.gnu
+++ /dev/null
@@ -1,356 +0,0 @@
-# Makefile for GAS.
-# Copyright (C) 1989, 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.
-
-# This makefile may be used to make the VAX, 68020, 80386,
-# SPARC, ns32k, or i860 assembler(s).
-
-BINDIR = /usr/local/bin
-#CC=gcc
-
-# If you are on a BSD system, un-comment the next two lines, and comment out
-# the lines for SystemV and HPUX below
-G0 = -g -I. #-O -Wall
-LDFLAGS = $(CFLAGS)
-#
-# To compile gas on a System Five machine, comment out the two lines above
-# and un-comment out the next three lines
-# Comment out the -lPW on the LOADLIBES line if you are using GCC.
-# G0 = -g -I. -DUSG
-# LDFLAGS = $(CFLAGS)
-# LOADLIBES = -lmalloc -lPW
-#
-# To compile gas for HPUX, link m-hpux.h to m68k.h , and un-comment the
-# next two lines. (If you are using GCC, comment out the alloca.o part)
-# (Get alloca from the emacs distribution, or use GCC.)
-# HPUX 7.0 may have a bug in setvbuf. gas gives an error message like
-# 1:"Unknown operator" -- Statement 'NO_APP' ignored
-# if setvbuf is broken. Re-compile input-file.c (and only input-file.c
-# with -DVMS and the problem should go away.
-#
-# G0 = -g -I. -DUSG
-# LOADLIBES = alloca.o
-#
-# To compile gas for a Sequent Symmetry, comment out all the above lines,
-# and un-comment the next two lines.
-# G0 = -g -I. -DUSE_SYSTEM_HDR -DEXEC_VERSION=1
-# LOADLIBES = -lc /usr/att/lib/libc.a
-
-# If you just want to compile the vax assembler, type 'make avax'
-
-# If you just want to compile the i386 assembler, type 'make a386'
-
-# If you just want to compile the ns32k assembler, type 'make a32k'
-
-# If you just want to compile the sparc assembler, type 'make asparc'
-
-# If you just want to compile the mc68020 assembler, make sure m68k.h
-# is correctly set up, and type type 'make a68' (Except on HPUX machines,
-# where you will have to make the changes marked below before typing
-# 'make a68'
-# m68k.h should be a symbolic or hard-link to one of
-# m-sun3.h , m-hpux.h or m-generic.h
-# depending on which machine you want to compile the 68020 assembler for.
-#
-# If you want the 68k assembler to be completely compatable with the the
-# SUN one, un-comment the -DSUN_ASM_SYNTAX line below.
-#
-# If you machine does not have vfprintf, but does have _doprnt(),
-# remove the # from the -DNO_VARARGS line below.
-#
-# If the return-type of a signal-hander is void (instead of int),
-# remove the # from the -DSIGTY line below.
-#
-# To include the mc68851 mmu coprocessor instructions in the 68020 assembler,
-# remove the # from the -Dm68851 line below.
-#
-# If you want the 68020 assembler use a register prefix character, un-comment
-# the REGISTER_PREFIX line, and (maybe) change the '%' to the appropriate
-# character.
-#
-# If you want the assembler to treat .L* or ..* symbols as local, instead of
-# the usual L* symbols, un-comment the DOT_LABEL_PREFIX line.
-#
-# If you want the 80386 assembler to correctly handle fsub/fsubr and fdiv/fdivr
-# opcodes (unlike most 80386 assemblers), remove the # from
-# the -DNON_BROKEN_WORDS line below.
-#
-# To compile 80386 Gas for the Sequent Symmetry, un-comment the -DEXEC_VERSION
-# and the -DUSE_SYSTEM_HDR lines below.
-#
-# To compile gas for the HP 9000/300 un-comment the -DUSE_HP_HDR line below.
-#
-# For the ns32k, the options are 32532 or 32032 CPU and 32381 or 32081 FPU.
-# To select the NS32532, remove the # from the -DNS32532 line below.
-# To compile in tne NS32381 opcodes in addition to the NS32081 opcodes
-# (the 32381 is a superset of the 32081), remove the # from the -DNS32381
-# line below.
-#
-# For the ns32k on a Sequent, uncomment the SEQUENT_COMPATABILITY line below.
-#
-# If you want the .align N directive to align to the next N byte boundry,
-# instead of the next 1<<N boundry, un-comment the OTHER_ALIGN line below.
-# (This option is automatically enabled when building the sparc assembler.
-#
-
-O1 = -DNO_VARARGS
-O2 = # -DNON_BROKEN_WORDS
-O3 = # -Dm68851
-O4 = # -DEXEC_VERSION=1
-O5 = # -DSIGTY=void
-O6 = # -DNS32532
-O6 = # -DNS32381
-O7 = # -DDOT_LABEL_PREFIX
-O8 = # -DSEQUENT_COMPATABILITY
-O9 = # -DREGISTER_PREFIX=\'%\'
-O10= # -DOTHER_ALIGN
-
-G1 = # -DUSE_SYSTEM_HDR
-G2 = # -DUSE_HP_HDR
-G3 = # -DSUN_ASM_SYNTAX
-
-OPTIONS = $(O1) $(O2) $(O3) $(O4) $(O5) $(O6) $(O7) $(O8) $(O9) $(O10)
-
-CFLAGS = $(G0) $(G1) $(G2) $(G3) $(G4)
-
-#
-# To make the 68020 assembler compile as the default, un-comment the next
-# line, and comment out all the other lines that start with DEFAULT_GAS
-DEFAULT_GAS=a68
-#
-# To make the VAX assembler compile as the default, un-comment the next
-# line and commment out all the other lines that start with DEFAULT_GAS
-#DEFAULT_GAS=avax
-#
-# To make the 80386 assembler compile as the default, un-comment the next
-# line and commment out all the other lines that start with DEFAULT_GAS
-#DEFAULT_GAS=a386
-#
-# To make the ns32k assembler compile as the default, un-comment the next
-# line and commment out all the other lines that start with DEFAULT_GAS
-#DEFAULT_GAS=a32k
-#
-# To make the sparc assembler compile as the default, un-comment the next
-# line and commment out all the other lines that start with DEFAULT_GAS
-#DEFAULT_GAS=asparc
-#
-# To make the i860 assembler compile as the default, un-comment the next
-# line and comment out all the other lines that start with DEFAULT_GAS
-#DEFAULT_GAS=a860
-
-# Global Sources -------------------------------------------------------------
-
-a =\
-as.o xrealloc.o xmalloc.o hash.o hex-value.o \
-atof-generic.o append.o messages.o expr.o app.o \
-frags.o input-file.o input-scrub.o output-file.o \
-subsegs.o symbols.o version.o \
-flonum-const.o flonum-copy.o flonum-mult.o strstr.o bignum-copy.o \
-obstack.o
-#gdb.o gdb-file.o gdb-symbols.o gdb-blocks.o gdb-lines.o
-
-a: $(DEFAULT_GAS)
- @rm -f a
- @ln $(DEFAULT_GAS) a
-
-# I860 GAS ------------------------------------------------------------------
-u = i860.o atof-ieee.o write-i860.o read-i860.o
-
-U = i860.c i860.h i860-opcode.h
-
-i860.o: i860.c i860.h i860-opcode.h as.h frags.h struc-symbol.h
-i860.o: flonum.h expr.h hash.h md.h write.h read.h symbols.h
- $(CC) -c $(CFLAGS) -DI860 i860.c
-
-atof-ieee.o: flonum.h
-
-write-i860.o: write.c i860.h
- $(CC) -c -DI860 $(CFLAGS) write.c
- mv write.o write-i860.o
-
-read-i860.o: read.c i860.h
- $(CC) -c -DI860 $(CFLAGS) read.c
- mv read.o read-i860.o
-
-a860: $a $u
- $(CC) -o a860 $(LDFLAGS) $a $u $(LOADLIBES)
-
-# SPARC GAS ------------------------------------------------------------------
-v = sparc.o atof-ieee.o write-sparc.o read-sparc.o
-
-V = sparc.c sparc.h sparc-opcode.h
-
-atof-ieee.o: flonum.h
-sparc.o: sparc.c sparc.h sparc-opcode.h as.h frags.h struc-symbol.h
-sparc.o: flonum.h expr.h hash.h md.h write.h read.h symbols.h
- $(CC) -c $(CFLAGS) -DSPARC sparc.c
-
-write-sparc.o: write.c
- $(CC) -c -DSPARC $(CFLAGS) write.c
- mv write.o write-sparc.o
-
-read-sparc.o: read.c
- $(CC) -c -DSPARC $(CFLAGS) read.c
- mv read.o read-sparc.o
-
-asparc: $a $v
- $(CC) -o asparc $(LDFLAGS) $a $v $(LOADLIBES)
-
-# NS32K GAS ------------------------------------------------------------------
-w = ns32k.o atof-ieee.o write-ns32k.o read-ns32k.o
-
-W = ns32k.c ns32k-opcode.h
-
-atof-ieee.o: flonum.h
-ns32k.o: as.h frags.h struc-symbol.h flonum.h expr.h md.h hash.h
-ns32k.o: write.h symbols.h ns32k-opcode.h ns32k.c
- $(CC) $(CFLAGS) $(OPTIONS) -c ns32k.c
-
-write-ns32k.o: write.c
- $(CC) -c -DNS32K $(CFLAGS) write.c
- mv write.o write-ns32k.o
-
-read-ns32k.o:
- $(CC) -c -DNS32K $(CFLAGS) read.c
- mv read.o read-ns32k.o
-
-a32k: $a $w
- $(CC) -o a32k $(LDFLAGS) $a $w $(LOADLIBES)
-
-# 80386 GAS ------------------------------------------------------------------
-x = i386.o atof-ieee.o write.o read.o
-
-X = i386.c i386.h i386-opcode.h
-
-i386.o: i386.c as.h read.h flonum.h frags.h struc-symbol.h expr.h
-i386.o: symbols.h hash.h md.h i386.h i386-opcode.h
- $(CC) $(CFLAGS) $(OPTIONS) -c i386.c
-
-atof-ieee.o: flonum.h
-
-a386: $a $x
- $(CC) -o a386 $(LDFLAGS) $a $x $(LOADLIBES)
-
-# 68020 GAS ------------------------------------------------------------------
-y = m68k.o atof-ieee.o write.o read.o
-
-Y = m68k.c atof-ieee.c m68k-opcode.h m-hpux.h m-sun3.h m-generic.h
-
-atof-ieee.o: flonum.h
-
-m68k.o: m68k.c a.out.gnu.h as.h expr.h flonum.h frags.h hash.h
-m68k.o: m68k-opcode.h m68k.h md.h obstack.h struc-symbol.h
- $(CC) $(CFLAGS) $(OPTIONS) -c m68k.c
-
-a68: $a $y
- $(CC) -o a68 $(LDFLAGS) $a $y $(LOADLIBES)
-
-# VAX GAS --------------------------------------------------------------------
-z = vax.o atof-vax.o write.o read.o
-
-Z = vax.c atof-vax.c vax-opcode.h vax-inst.h \
- make-gas.com objrecdef.h vms.c vms-dbg.c README-vms-dbg
-
-vax.o: vax.c a.out.gnu.h as.h expr.h flonum.h frags.h md.h obstack.h
-vax.o: read.h struc-symbol.h symbols.h vax-inst.h vax-opcode.h
-atof-vax.o: as.h flonum.h read.h
-
-avax: $a $z
- $(CC) -o avax $(LDFLAGS) $a $z $(LOADLIBES)
-
-# global files ---------------------------------------------------------------
-
-as.o: as.c
- $(CC) $(CFLAGS) $(OPTIONS) -c as.c
-
-messages.o: messages.c
- $(CC) $(CFLAGS) $(OPTIONS) -c messages.c
-
-hash.o: hash.c
- $(CC) $(CFLAGS) -Derror=as_fatal -c hash.c
-
-xmalloc.o: xmalloc.c
- $(CC) $(CFLAGS) -Derror=as_fatal -c xmalloc.c
-
-xrealloc.o: xrealloc.c
- $(CC) $(CFLAGS) -Derror=as_fatal -c xrealloc.c
-
-A =\
-as.c xrealloc.c xmalloc.c hash.c hex-value.c \
-atof-generic.c append.c messages.c expr.c bignum-copy.c \
-frags.c input-file.c input-scrub.c output-file.c read.c \
-subsegs.c symbols.c write.c strstr.c \
-flonum-const.c flonum-copy.c flonum-mult.c app.c version.c \
-obstack.c \
-#gdb.c gdb-file.c gdb-symbols.c gdb-blocks.c \
-#gdb-lines.c
-
-H = \
-a.out.gnu.h as.h bignum.h expr.h flonum.h \
-frags.h hash.h input-file.h md.h \
-obstack.h read.h struc-symbol.h subsegs.h \
-symbols.h write.h
-
-dist: COPYING README ChangeLog $A $H $Z $Y $X $W $V $U Makefile
- echo gas-`sed -n -e '/ version /s/[^0-9.]*\([0-9.]*\).*/\1/p' < version.c` > .fname
- mkdir `cat .fname`
-
- ln COPYING README ChangeLog $A $H $Z $Y $X $W $V $U Makefile `cat .fname`
- tar cvhZf `cat .fname`.tar.Z `cat .fname`
- -rm -r `cat .fname`
- -rm .fname
-
-clean:
- rm -f a avax a68 a386 a32k asparc $a $v $w $x $y $z a core gmon.out bugs a.out
-
-install: a
- cp a $(BINDIR)/gas
-
-
-# General .o-->.h dependencies
-
-app.o: as.h
-as.o: a.out.gnu.h as.h read.h struc-symbol.h write.h
-atof-generic.o: flonum.h
-bignum-copy.o: bignum.h
-expr.o: a.out.gnu.h as.h expr.h flonum.h obstack.h read.h struc-symbol.h
-expr.o: symbols.h
-flonum-const.o: flonum.h
-flonum-copy.o: flonum.h
-flonum-mult.o: flonum.h
-flonum-normal.o:flonum.h
-flonum-print.o: flonum.h
-frags.o: a.out.gnu.h as.h frags.h obstack.h struc-symbol.h subsegs.h
-#gdb.o: as.h
-#gdb-blocks.o: as.h
-#gdb-lines.o: as.h frags.h obstack.h
-#gdb-symbols.o: a.out.gnu.h as.h struc-symbol.h
-hash.o: hash.h
-input-file.o: input-file.h
-input-scrub.o: as.h input-file.h read.h
-messages.o: as.h
-obstack.o: obstack.h
-read.o: a.out.gnu.h as.h expr.h flonum.h frags.h hash.h md.h obstack.h
-read.o: read.h struc-symbol.h symbols.h
-subsegs.o: a.out.gnu.h as.h frags.h obstack.h struc-symbol.h subsegs.h write.h
-symbols.o: a.out.gnu.h as.h frags.h hash.h obstack.h struc-symbol.h symbols.h
-write.o: a.out.gnu.h as.h md.h obstack.h struc-symbol.h subsegs.h
-write.o: symbols.h write.h
-
-flonum.h: bignum.h
-
diff --git a/gnu/usr.bin/as/NOTES b/gnu/usr.bin/as/NOTES
deleted file mode 100644
index b3f3f92..0000000
--- a/gnu/usr.bin/as/NOTES
+++ /dev/null
@@ -1,35 +0,0 @@
-gdb debugging of assembly sources:
- write a function linestab() that generates a .stabd symbol
- independently of the input
- write a function filestab() to generate a .stabs symbol
- we need to take especial care with #line directives
- since we want to handle locore, and locore is passed thru cpp
- this could be tough
- outline of a solution:
- cpp sends us lines of the form
- # logical-line "logical-file" trash
- these lines are interpreted ahead of the gas preprocess pass
- in the starting state, the logical filename is the same
- as the real filename (in case there're no #lines)
- the initial logical line number is 1
- every time we're ready to process a new instruction line,
- if the source file has changed,
- emit a .stabs for the logical file
- emit a .stabd for the logical line
- bump the logical line number
- can gas eat multiple actual lines in one insn?
-
-i386 nits:
- jmp *$foo produces a short relative branch
- string quotes in comments
- Bill says gas eats text across newlines to find matches
- works fine for me
- I think it's most likely due to cpp
- make / no longer be a comment char
- it's now like the VAX: # is the only comment char
- incorrectly assembles lcall, int3, into, bsr/f instructions
- constant expressions fail if more than a few terms
- gives (low+2)*3+4*5 as an example
- works fine for me
- cpp seems to think $ is a valid literal
- use -$ in /usr/bin/cpp
diff --git a/gnu/usr.bin/as/README.gnu b/gnu/usr.bin/as/README.gnu
deleted file mode 100644
index 46f135fc..0000000
--- a/gnu/usr.bin/as/README.gnu
+++ /dev/null
@@ -1,133 +0,0 @@
-This is the beta-test version of the GNU assembler. (Probably
-around Version 1.35, but check version.c which gets updated more
-often than this readme.)
-
-The assembler has been modified to support a feature that is
-potentially useful when assembling compiler output, but which may
-confuse assembly language programmers. If assembler encounters a
-.word pseudo-op of the form symbol1-symbol2 (the difference of two
-symbols), and the difference of those two symbols will not fit in 16
-bits, the assembler will create a branch around a long jump to
-symbol1, and insert this into the output directly before the next
-label: The .word will (instead of containing garbage, or giving an
-error message) contain (the address of the long jump)-symbol2. This
-allows the assembler to assemble jump tables that jump to locations
-very far away into code that works properly. If the next label is
-more than 32K away from the .word, you lose (silently) RMS claims
-this will never happen. If the -k option is given, you will get a
-warning message when this happens.
-
-These files are currently set up to allow you to compile all of the
-versions of the assembler (68020, VAX, ns32k, and i386) on the same
-machine. To compile the 68020 version, type 'make a68'. To compile
-the VAX version, type 'make avax'. To compile the ns32k version,
-type 'make a32k'. To compile the Intel 80386 version, type 'make
-a386'. The Makefile contains instructions on how to make one of the
-assemblers compile as the default.
-
-Before you can compile the 68020 version of the assembler, you must
-make m68k.h be a link to m-sun3.h , m-hpux.h or m-generic.h . If
-you are on a SUN-3 (or other machine that uses a magic number of
-(2 << 16) | OMAGIC type 'ln -s m-sun3.h m68k.h' else if you are on a
-machine running HP-UX, type 'ln m-hpux.h m689k.h' else type
-'ln -s m-generic.h m68k.h' If your machine does not support symbolic
-links, omit the '-s'.
-
-See the instructions in the Makefile for compiling gas for the Sequent
-Symmetry (dynix 3.0.12 + others?) or for the HP 9000/300
-
-If your machine does not have both varargs.h and vfprintf(), but does have
-_doprnt() add -DNO_VARARGS to the CFLAGS line in the makefile. If your
-machine has neither vfprintf() or _doprnt(), you will have to change
-messages.c in order to get readable error messages from the assembler.
-
-
- REPORTING BUGS IN GAS
-
-Bugs in gas should be reported to bug-gnu-utils@prep.ai.mit.edu If you can't
-get through to prep, try hack@gnu.ai.mit.edu or hack@media-lab.media.mit.edu
-
-If you report a bug in GAS, please remember to include:
-
-A description of exactly what went wrong.
-
-The type of machine GAS was running on (VAX, 68020, etc),
-
-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.
-
------------------------------- README.APOLLO ---------------------------------
-
-The changes required to get the GNU C compiler running on
-Apollo 68K platforms are available via anonymous ftp from
-labrea.stanford.edu (36.8.0.47) in the form of a compressed
-tar file named "/pub/gnu/apollo-gcc-1.37.tar.Z".
-The size of the file is 84145 bytes.
-
-To build GCC for the Apollo you'll need the virgin FSF
-distributions of bison-1.03, gas-1.34, and gcc-1.37. They
-are also on labrea.stanford.edu as well as prep.ai.mit.edu.
-My changes are to enable gas to produce Apollo COFF object
-files and allow gcc to parse some of the syntax extensions
-which appear in Apollo C header files. Note that the
-COFF encapsulation technique cannot be used on the Apollo.
-
-The tar file should be unpacked in the directory containing
-the gas-1.34 and gcc-1.37 directories; a few files will be overlaid,
-and an APOLLO-GCC-README file will appear in the top directory.
-This file contains detailed instructions on how to proceed.
-
-These changes will only work for SR10.1 or later systems, using
-the 6.6 or later version of the Apollo C compiler.
-
-If you do not have ftp access, I can mail you the changes in the
-form of diffs; they are approximately 40K in length. If you request
-them, be sure to give me a voice phone number so I can contact you
-in case I can't send you mail; I've had several requests in the
-past from people I can't contact.
-
-By the way, I'm working on getting the GNU C++ compiler running;
-there are a couple problems to solve. I hope to be able to announce
-the Apollo version shortly after the 1.37 version is released.
-
-John Vasta Hewlett-Packard Apollo Systems Division
-vasta@apollo.hp.com M.S. CHA-01-LT
-(508) 256-6600 x6362 300 Apollo Drive, Chelmsford, MA 01824
-UUCP: {decwrl!decvax, mit-eddie, attunix}!apollo!vasta
-
-------------------------------------
-
-You might refer others who are interested in a similar thing.
-
-Kevin Buchs buchs@mayo.edu
-
-
------------------------------- README.COFF -----------------------------------
-
-If you have a COFF system, you may wish to aquire
-
- UUCP: osu-cis!~/gnu/coff/gnu-coff.tar.Z
- or
- FTP: tut.cis.ohio-state.edu:/pub/gnu/coff/gnu-coff.tar.Z
-
-These contain patches for gas that will make it produce COFF output.
-I have never seen these patches, so I don't know how well they work.
diff --git a/gnu/usr.bin/as/app.c b/gnu/usr.bin/as/app.c
deleted file mode 100644
index a0ec8a2..0000000
--- a/gnu/usr.bin/as/app.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/* This is the Assembler Pre-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. */
-
-/* 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>;.file <filename> pair.
- This needs better error-handling.
- */
-#include <stdio.h>
-#ifdef USG
-#define bzero(s,n) memset(s,0,n)
-#endif
-#if !defined(__STDC__) && !defined(const)
-#define const /* Nothing */
-#endif
-
-static char lex [256];
-static const char symbol_chars[] =
- "$._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-
-extern const char comment_chars[];
-extern const char line_comment_chars[];
-
-#define LEX_IS_SYMBOL_COMPONENT (1)
-#define LEX_IS_WHITESPACE (2)
-#define LEX_IS_LINE_SEPERATOR (4)
-#define LEX_IS_COMMENT_START (8) /* JF added these two */
-#define LEX_IS_LINE_COMMENT_START (16)
-#define IS_SYMBOL_COMPONENT(c) (lex [c] & LEX_IS_SYMBOL_COMPONENT)
-#define IS_WHITESPACE(c) (lex [c] & LEX_IS_WHITESPACE)
-#define IS_LINE_SEPERATOR(c) (lex [c] & LEX_IS_LINE_SEPERATOR)
-#define IS_COMMENT(c) (lex [c] & LEX_IS_COMMENT_START)
-#define IS_LINE_COMMENT(c) (lex [c] & LEX_IS_LINE_COMMENT_START)
-
-void
-do_scrub_begin()
-{
- const char *p;
-
- bzero (lex, sizeof(lex)); /* Trust NOBODY! */
- lex [' '] |= LEX_IS_WHITESPACE;
- lex ['\t'] |= LEX_IS_WHITESPACE;
- for (p =symbol_chars;*p;++p)
- lex [*p] |= LEX_IS_SYMBOL_COMPONENT;
- lex ['\n'] |= LEX_IS_LINE_SEPERATOR;
-#ifdef DONTDEF
- lex [':'] |= LEX_IS_LINE_SEPERATOR;
-#endif
- lex [';'] |= LEX_IS_LINE_SEPERATOR;
- for (p=comment_chars;*p;p++)
- lex[*p] |= LEX_IS_COMMENT_START;
- for (p=line_comment_chars;*p;p++)
- lex[*p] |= LEX_IS_LINE_COMMENT_START;
-}
-
-FILE *scrub_file;
-
-int
-scrub_from_file()
-{
- return getc(scrub_file);
-}
-
-void
-scrub_to_file(ch)
-int ch;
-{
- ungetc(ch,scrub_file);
-}
-
-char *scrub_string;
-char *scrub_last_string;
-
-int
-scrub_from_string()
-{
- return scrub_string == scrub_last_string ? EOF : *scrub_string++;
-}
-
-void
-scrub_to_string(ch)
-int ch;
-{
- *--scrub_string=ch;
-}
-
-int
-do_scrub_next_char(get,unget)
-int (*get)();
-void (*unget)();
-/* FILE *fp; */
-{
- /* State 0: beginning of normal line
- 1: After first whitespace on normal line (flush more white)
- 2: After first non-white on normal line (keep 1white)
- 3: after second white on normal line (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 .file, put out string.
- 8: After putting out a .file string, flush until newline.
- -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
- */
-
- static state;
- static old_state;
- static char *out_string;
- static char out_buf[20];
- static add_newlines;
- int ch;
-
- if(state==-1) {
- ch= *out_string++;
- if(*out_string==0) {
- state=old_state;
- old_state=3;
- }
- return ch;
- }
- if(state==-2) {
- for(;;) {
- do ch=(*get)();
- while(ch!=EOF && ch!='\n' && ch!='*');
- if(ch=='\n' || ch==EOF)
- return ch;
- ch=(*get)();
- if(ch==EOF || ch=='/')
- break;
- (*unget)(ch);
- }
- state=old_state;
- return ' ';
- }
- if(state==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="; .file ";
- old_state=7;
- state= -1;
- return *out_string++;
- } else {
- while(ch!=EOF && ch!='\n')
- ch=(*get)();
- return ch;
- }
- }
- }
- if(state==5) {
- ch=(*get)();
- if(ch=='"') {
- state=old_state;
- return '"';
- } else if(ch=='\\') {
- state=6;
- return ch;
- } else if(ch==EOF) {
- as_warn("End of file in string: inserted '\"'");
- state=old_state;
- (*unget)('\n');
- return '"';
- } else {
- return ch;
- }
- }
- if(state==6) {
- state=5;
- ch=(*get)();
- switch(ch) {
- /* This is neet. Turn "string
- more string" into "string\n more string"
- */
- case '\n':
- (*unget)('n');
- add_newlines++;
- return '\\';
-
- case '"':
- case '\\':
- case 'b':
- case 'f':
- case 'n':
- case 'r':
- case 't':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- break;
- default:
- as_warn("Unknown escape '\\%c' in string: Ignored",ch);
- break;
-
- case EOF:
- as_warn("End of file in string: '\"' inserted");
- return '"';
- }
- return ch;
- }
-
- if(state==7) {
- ch=(*get)();
- state=5;
- old_state=8;
- return ch;
- }
-
- if(state==8) {
- do ch= (*get)();
- while(ch!='\n');
- state=0;
- return ch;
- }
-
- flushchar:
- ch=(*get)();
- switch(ch) {
- case ' ':
- case '\t':
- do 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_SEPERATOR(ch)) {
- (*unget)(ch);
- goto flushchar;
- }
- (*unget)(ch);
- if(state==0 || state==2) {
- state++;
- return ' ';
- } else goto flushchar;
-
- case '/':
- ch=(*get)();
- if(ch=='*') {
- for(;;) {
- do {
- ch=(*get)();
- if(ch=='\n')
- add_newlines++;
- } while(ch!=EOF && ch!='*');
- ch=(*get)();
- if(ch==EOF || ch=='/')
- break;
- (*unget)(ch);
- }
- if(ch==EOF)
- as_warn("End of file in '/' '*' string: */ inserted");
-
- (*unget)(' ');
- goto flushchar;
- } else {
- if(IS_COMMENT('/') || (state==0 && IS_LINE_COMMENT('/'))) {
- (*unget)(ch);
- ch='/';
- goto deal_misc;
- }
- if(ch!=EOF)
- (*unget)(ch);
- return '/';
- }
- break;
-
- case '"':
- old_state=state;
- state=5;
- return '"';
- break;
-
- case '\'':
- ch=(*get)();
- if(ch==EOF) {
- as_warn("End-of-file after a ': \000 inserted");
- ch=0;
- }
- sprintf(out_buf,"(%d)",ch&0xff);
- old_state=state;
- state= -1;
- out_string=out_buf;
- return *out_string++;
-
- case ':':
- if(state!=3)
- state=0;
- return ch;
-
- case '\n':
- if(add_newlines) {
- --add_newlines;
- (*unget)(ch);
- }
- case ';':
- state=0;
- return ch;
-
- default:
- deal_misc:
- if(state==0 && IS_LINE_COMMENT(ch)) {
- 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') {
- while(ch!=EOF && ch!='\n')
- ch=(*get)();
- if(ch==EOF)
- as_warn("EOF in Comment: Newline inserted");
- state=0;
- return '\n';
- }
- (*unget)(ch);
- old_state=4;
- state= -1;
- out_string=".line ";
- return *out_string++;
-
- } else if(IS_COMMENT(ch)) {
- do ch=(*get)();
- while(ch!=EOF && ch!='\n');
- if(ch==EOF)
- as_warn("EOF in comment: Newline inserted");
- state=0;
- return '\n';
-
- } else if(state==0) {
- state=2;
- return ch;
- } else if(state==1) {
- state=2;
- return ch;
- } else {
- return ch;
-
- }
- case EOF:
- if(state==0)
- return ch;
- as_warn("End-of-File not at end of a line");
- }
- return -1;
-}
-
-#ifdef TEST
-
-char comment_chars[] = "|";
-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
diff --git a/gnu/usr.bin/as/append.c b/gnu/usr.bin/as/append.c
deleted file mode 100644
index d51a27f..0000000
--- a/gnu/usr.bin/as/append.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Append a string ontp another string
- 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. */
-
-/* JF: This is silly. Why not stuff this in some other file? */
-#ifdef USG
-#define bcopy(from,to,n) memcpy(to,from,n)
-#endif
-
-void
-append (charPP, fromP, length)
-char **charPP;
-char *fromP;
-unsigned long length;
-{
- if (length) { /* Don't trust bcopy() of 0 chars. */
- bcopy (fromP, * charPP,(int) length);
- *charPP += length;
- }
-}
-
-/* end: append.c */
diff --git a/gnu/usr.bin/as/as.1 b/gnu/usr.bin/as/as.1
deleted file mode 100644
index e69de29..0000000
--- a/gnu/usr.bin/as/as.1
+++ /dev/null
diff --git a/gnu/usr.bin/as/as.1aout b/gnu/usr.bin/as/as.1aout
deleted file mode 100644
index e69de29..0000000
--- a/gnu/usr.bin/as/as.1aout
+++ /dev/null
diff --git a/gnu/usr.bin/as/as.c b/gnu/usr.bin/as/as.c
deleted file mode 100644
index db85525..0000000
--- a/gnu/usr.bin/as/as.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)as.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* as.c - GAS main program.
- 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. */
-
-/*
- * 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.
- *
- */
-
-#ifdef _POSIX_SOURCE
-#include <sys/types.h> /* For pid_t in signal.h */
-#endif
-#include <signal.h>
-
-#define COMMON
-#include "as.h"
-#include "struc-symbol.h"
-#include "write.h"
- /* Warning! This may have some slightly strange side effects
- if you try to compile two or more assemblers in the same
- directory!
- */
-
-#ifndef SIGTY
-#define SIGTY int
-#endif
-
-SIGTY got_sig();
-
-#ifdef DONTDEF
-static char * gdb_symbol_file_name;
-long int gdb_begin();
-#endif
-
-char *myname; /* argv[0] */
-extern char version_string[];
-
-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};
-
- extern int bad_error; /* Did we hit a bad error ? */
-
- char *stralloc(); /* Make a (safe) copy of a string. */
- void symbol_begin();
- void read_begin();
- void write_object_file();
-
- for(a=0;sig[a]!=0;a++)
- if(signal(sig[a], SIG_IGN) != SIG_IGN)
- signal(sig[a], got_sig);
-
- myname=argv[0];
- bzero (flagseen, sizeof(flagseen)); /* aint seen nothing yet */
- out_file_name = "a.out"; /* default .o file */
- 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.
- */
- 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) {/* scan all the 1-char flags */
- arg ++; /* arg -> after letter. */
- a &= 0x7F; /* ascii only please */
- if (flagseen[a])
- as_warn("%s: Flag option -%c has already been seen!",myname,a);
- flagseen[a] = TRUE;
- switch (a) {
- 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
-
-#ifndef WORKING_DOT_WORD
- case 'k':
- break;
-#endif
-
- 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 VMS
- {
- extern char *compiler_version_string;
- compiler_version_string = arg;
- }
-#else /* not VMS */
- fprintf(stderr,version_string);
- if(*arg && strcmp(arg,"ersion"))
- as_warn("Unknown -v option ignored");
-#endif
- while(*arg) arg++; /* Skip the rest */
- break;
-
- case 'W':
- /* -W means don't warn about things */
- break;
-
- case 'g':
- /*
- * -g asks gas to produce gdb/dbx line number
- * and file name stabs so that an assembly
- * file can be handled by a source debugger.
- */
- 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 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. */
- if (seen_at_least_1_file() && !bad_error)
- write_object_file();/* relax() addresses then emit object file */
- input_scrub_end();
- md_end(); /* MACHINE.c */
-#ifndef VMS
- exit(bad_error); /* WIN */
-#else /* VMS */
- exit(!bad_error); /* WIN */
-#endif /* VMS */
-}
-
-
-/* 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.
- */
-perform_an_assembly_pass (argc, argv)
-int argc;
-char ** argv;
-{
- char * buffer; /* Where each bufferful of lines will start. */
- void read_a_source_file();
- int saw_a_file = 0;
-
- text_fix_root = NULL;
- data_fix_root = NULL;
- need_pass_2 = FALSE;
-
- argv++; /* skip argv[0] */
- argc--; /* skip argv[0] */
- while (argc--) {
- if (*argv) { /* Is it a file-name argument? */
- /* argv -> "" if stdin desired, else -> filename */
- if (buffer = input_scrub_new_file (*argv) ) {
- saw_a_file++;
- read_a_source_file(buffer);
- }
- }
- argv++; /* completed that argv */
- }
- if(!saw_a_file)
- if(buffer = input_scrub_new_file("") )
- read_a_source_file(buffer);
-}
-
-/*
- * 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.
- */
-
-char *
-stralloc (str)
-char * str;
-{
- register char * retval;
- register long int len;
-
- len = strlen (str) + 1;
- retval = xmalloc (len);
- (void)strcpy (retval, str);
- return (retval);
-}
-
-lose()
-{
- as_fatal( "%s: 2nd pass not implemented - get your code from random(3)",myname );
-}
-
-SIGTY
-got_sig(sig)
-int sig;
-{
- static here_before = 0;
-
- as_bad("Interrupted by signal %d",sig);
- if(here_before++)
- exit(1);
-}
-
-/* end: as.c */
diff --git a/gnu/usr.bin/as/as.h b/gnu/usr.bin/as/as.h
deleted file mode 100644
index 8de4052..0000000
--- a/gnu/usr.bin/as/as.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/* as.h - global header file
- 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. */
-
-#ifndef asH
-#define asH /* Don't declare things twice. */
-
-#if !defined(__STDC__) && !defined(const)
-#define const /* ignore */
-#endif
-
-#ifdef USG
-#define index strchr
-#define bzero(s,n) memset((s),0,(n))
-#define bcopy(from,to,n) memcpy((to),(from),(n))
-#define setbuffer(a,b,c)
-#endif
-
-/*
- * 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 SUSPECT when debugging.
- * #define DUMP to include data-structure dumpers.
- * #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 */
-/* #define DUMP */
-#define NDEBUG /* JF disable asserts */
-/* These #includes are for type definitions etc. */
-
-/* #include "style.h" */
-#include <stdio.h>
-#include <assert.h>
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free xfree
-
-/* These defines are potentially useful */
-#define FALSE (0)
-#define TRUE (!FALSE)
-#define ASSERT assert
-#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 */
-
-#ifdef SUSPECT
-#define register /* no registers: helps debugging */
-#define know(p) ASSERT(p) /* know() is less ugly than #ifdef SUSPECT/ */
- /* assert()/#endif. */
-#else
-#define know(p) /* know() checks are no-op.ed */
-#endif /* #ifdef SUSPECT */
-
-
-char *xmalloc(); /* keep C compilers happy */
-char *xrealloc(); /* " */
-void free(); /* " */
-#define xfree free
-
-/* input_scrub.c */
-
-/*
- * Supplies sanitised buffers to read.c.
- * Also understands printing line-number part of error messages.
- */
-
- /* Line number things. */
-int seen_at_least_1_file();
-void bump_line_counters();
-void new_logical_line();
-void as_where();
-void as_perror();
-void as_howmuch();
- /* Sanitising things. */
-void input_scrub_begin();
-void input_scrub_end();
-char *input_scrub_new_file();
-char *input_scrub_next_buffer();
-
-/* 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_NONE 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
- *
- * 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).
- */
-
-typedef enum
-{
- SEG_ABSOLUTE,
- SEG_TEXT,
- SEG_DATA,
- SEG_BSS,
- SEG_UNKNOWN,
- SEG_NONE, /* Mythical Segment: 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. */
-} segT;
-#define SEG_MAXIMUM_ORDINAL (SEG_DIFFERENCE)
-
-typedef unsigned char 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 const int seg_N_TYPE[];
-extern const segT N_TYPE_seg[];
-void subsegs_begin();
-void subseg_change();
-void subseg_new();
-
-/* relax() */
-
-typedef enum
-{
- 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 int relax_substateT;
-
-typedef unsigned long int 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 out.
-
-
- */
-struct frag /* a code fragment */
-{
- long unsigned int fr_address; /* Object file address. */
- struct frag *fr_next; /* Chain forward; ascending address order. */
- /* Rooted in frch_root. */
-
- long int fr_fix; /* (Fixed) number of chars we know we have. */
- /* May be 0. */
- long int fr_var; /* (Variable) number of chars after above. */
- /* May be 0. */
- struct symbol *fr_symbol; /* For variable-length tail. */
- long int 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;
- 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. */
-
-void frag_new();
-char * frag_more();
-char * frag_var();
-void frag_wane();
-void frag_align();
-
-
-/* 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. */
-
-
-#endif /* #ifdef asH */
-
-/* end: 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 4975410..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 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. */
-
-#include <ctype.h>
-#include "flonum.h"
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#ifdef sparc
-#include <alloca.h>
-#endif
-#endif
-
-#ifdef USG
-#define bzero(s,n) memset(s,0,n)
-#define index strchr
-#endif
-
-#define FALSE (0)
-#define TRUE (1)
-
-char *index();
-
-/***********************************************************************\
-* *
-* 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 int *
-* *
-\***********************************************************************/
-
-/*
-
- 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 int 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;
- }
- 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;
- }
-
- number_of_digits_before_decimal = 0;
- number_of_digits_after_decimal = 0;
- decimal_exponent = 0;
- seen_significant_digit = FALSE;
- for (p = first_digit;
- (c = * p)
- && (!c || ! index (string_of_decimal_marks, c) )
- && (!c || ! index (string_of_decimal_exponent_marks, c) );
- p ++)
- {
- if (isdigit(c))
- {
- if (seen_significant_digit || c > '0')
- {
- number_of_digits_before_decimal ++;
- seen_significant_digit = TRUE;
- }
- else
- {
- first_digit++;
- }
- }
- else
- {
- break; /* p -> char after pre-decimal digits. */
- }
- } /* For each digit before decimal mark. */
- if (c && index (string_of_decimal_marks, c))
- {
- for (p ++;
- (c = * p)
- && (!c || ! index (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 */
-
- if (c && index (string_of_decimal_exponent_marks, c) )
- {
- char digits_exponent_sign_char;
-
- c = * ++ p;
- if (c && index ("+-",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
- {
- 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);
- bzero ((char *)digits_binary_low, 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
- */
-
- char * p;
- char c;
- int count; /* Number of useful digits left to scan. */
-
- 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 int 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 int 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.
- */
- abort(); /* 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 );
- bzero ((char *)power_binary_low, 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: 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 2640121..0000000
--- a/gnu/usr.bin/as/bignum-copy.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* bignum_copy.c - copy a bignum
- 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. */
-
-#include "bignum.h"
-
-#ifdef USG
-#define bzero(s,n) memset(s,0,n)
-#define bcopy(from,to,n) memcpy(to,from,n)
-#endif
-
-/*
- * 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 bcopy() 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 */
-{
- register int significant_littlenums_dropped;
-
- if (out_length < in_length)
- {
- register LITTLENUM_TYPE * p; /* -> most significant (non-zero) input littlenum. */
-
- bcopy ((char *)in, (char *)out, 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
- {
- bcopy ((char *)in, (char *)out, in_length << LITTLENUM_SHIFT);
- if (out_length > in_length)
- {
- bzero ((char *)(out + out_length), (out_length - in_length) << LITTLENUM_SHIFT);
- }
- significant_littlenums_dropped = 0;
- }
- return (significant_littlenums_dropped);
-}
-
-/* end: bignum_copy.c */
diff --git a/gnu/usr.bin/as/bignum.h b/gnu/usr.bin/as/bignum.h
deleted file mode 100644
index dbc95a3..0000000
--- a/gnu/usr.bin/as/bignum.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* bignum.h-arbitrary precision integers
- 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. */
-
-/***********************************************************************\
-* *
-* 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 int 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! */
-
-/* end: bignum.h */
diff --git a/gnu/usr.bin/as/config/Makefile.i386 b/gnu/usr.bin/as/config/Makefile.i386
deleted file mode 100644
index 945246b..0000000
--- a/gnu/usr.bin/as/config/Makefile.i386
+++ /dev/null
@@ -1,4 +0,0 @@
-# @(#)Makefile.i386 6.1 (Berkeley) 3/3/91
-
-CFLAGS+= -DNON_BROKEN_WORDS
-SRCS+= i386.c atof-ieee.c
diff --git a/gnu/usr.bin/as/config/a.out.gnu.h b/gnu/usr.bin/as/config/a.out.gnu.h
deleted file mode 100644
index 71b09a0..0000000
--- a/gnu/usr.bin/as/config/a.out.gnu.h
+++ /dev/null
@@ -1,261 +0,0 @@
-#ifndef __A_OUT_GNU_H__
-#define __A_OUT_GNU_H__
-
-#define __GNU_EXEC_MACROS__
-
-#ifndef __STRUCT_EXEC_OVERRIDE__
-
-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 */
-enum machine_type {
-#if defined (M_OLDSUN2)
- M__OLDSUN2 = M_OLDSUN2,
-#else
- M_OLDSUN2 = 0,
-#endif
-#if defined (M_68010)
- M__68010 = M_68010,
-#else
- M_68010 = 1,
-#endif
-#if defined (M_68020)
- M__68020 = M_68020,
-#else
- M_68020 = 2,
-#endif
-#if defined (M_SPARC)
- M__SPARC = M_SPARC,
-#else
- M_SPARC = 3,
-#endif
- /* skip a bunch so we don't run into any of sun's numbers */
- M_386 = 100,
-};
-
-#if !defined (N_MAGIC)
-#define N_MAGIC(exec) ((exec).a_info & 0xffff)
-#endif
-#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
-
-#if !defined (N_BADMAG)
-#define N_BADMAG(x) \
- (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
- && N_MAGIC(x) != ZMAGIC)
-#endif
-
-#define _N_BADMAG(x) \
- (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
- && N_MAGIC(x) != ZMAGIC)
-
-#define _N_HDROFF(x) (1024 - sizeof (struct exec))
-
-#if !defined (N_TXTOFF)
-#define N_TXTOFF(x) \
- (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
-#endif
-
-#if !defined (N_DATOFF)
-#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
-#endif
-
-#if !defined (N_TRELOFF)
-#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
-#endif
-
-#if !defined (N_DRELOFF)
-#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
-#endif
-
-#if !defined (N_SYMOFF)
-#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
-#endif
-
-#if !defined (N_STROFF)
-#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
-#endif
-
-/* Address of text segment in memory after it is loaded. */
-#if !defined (N_TXTADDR)
-#define N_TXTADDR(x) 0
-#endif
-
-/* Address of data segment in memory after it is loaded.
- Note that it is up to you to define SEGMENT_SIZE
- on machines not listed here. */
-#if defined(vax) || defined(hp300) || defined(pyr)
-#define SEGMENT_SIZE page_size
-#endif
-#ifdef sony
-#define SEGMENT_SIZE 0x2000
-#endif /* Sony. */
-#ifdef is68k
-#define SEGMENT_SIZE 0x20000
-#endif
-#if defined(m68k) && defined(PORTAR)
-#define PAGE_SIZE 0x400
-#define SEGMENT_SIZE PAGE_SIZE
-#endif
-
-#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
-
-#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
-
-#ifndef N_DATADDR
-#define N_DATADDR(x) \
- (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
- : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
-#endif
-
-/* Address of bss segment in memory after it is loaded. */
-#if !defined (N_BSSADDR)
-#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
-#endif
-
-#if !defined (N_NLIST_DECLARED)
-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;
-};
-#endif /* no N_NLIST_DECLARED. */
-
-#if !defined (N_UNDF)
-#define N_UNDF 0
-#endif
-#if !defined (N_ABS)
-#define N_ABS 2
-#endif
-#if !defined (N_TEXT)
-#define N_TEXT 4
-#endif
-#if !defined (N_DATA)
-#define N_DATA 6
-#endif
-#if !defined (N_BSS)
-#define N_BSS 8
-#endif
-#if !defined (N_FN)
-#define N_FN 15
-#endif
-
-#if !defined (N_EXT)
-#define N_EXT 1
-#endif
-#if !defined (N_TYPE)
-#define N_TYPE 036
-#endif
-#if !defined (N_STAB)
-#define N_STAB 0340
-#endif
-
-/* 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 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. */
-
-#if !defined (N_RELOCATION_INFO_DECLARED)
-/* 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. */
-
-struct relocation_info
-{
- /* Address (within segment) to be relocated. */
- int r_address;
- /* The meaning of r_symbolnum depends on r_extern. */
- unsigned int r_symbolnum:24;
- /* 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;
- /* Four bits that aren't used, but when writing an object file
- it is desirable to clear them. */
-#ifdef NS32K
- unsigned r_bsr:1;
- unsigned r_disp:1;
- unsigned r_pad:2;
-#else
- unsigned int r_pad:4;
-#endif
-};
-#endif /* no N_RELOCATION_INFO_DECLARED. */
-
-
-#endif /* __A_OUT_GNU_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 6ff45c8..0000000
--- a/gnu/usr.bin/as/config/atof-ieee.c
+++ /dev/null
@@ -1,505 +0,0 @@
-/* atof_ieee.c - turn a Flonum into an IEEE 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. */
-
-#include "flonum.h"
-#ifdef USG
-#define bzero(s,n) memset(s,0,n)
-#define bcopy(from,to,n) memcpy((to),(from),(n))
-#endif
-
-extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */
-#define NULL (0)
-
-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 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 --;
- 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 int
-unget_bits(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_warn("cannot create floating-point number");
- words[0]= ((unsigned)-1)>>1; /* Zero the leftmost bit */
- words[1]= -1;
- words[2]= -1;
- words[3]= -1;
- words[4]= -1;
- words[5]= -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 int exponent_bits;
-
- 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 = NULL;
- 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. */
-
- bzero (bits, 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_warn("Error converting floating point number (Exponent overflow?)"); */
- make_invalid_floating_point_number (words);
- return NULL;
- }
- gen_to_words(words, precision, exponent_bits);
- return return_value;
-}
-
-/* Turn generic_floating_point_number into a real float/double/extended */
-gen_to_words(words,precision,exponent_bits)
-LITTLENUM_TYPE *words;
-long int exponent_bits;
-int precision;
-{
- 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. */
- if(generic_floating_point_number.sign=='+')
- words[0]=0x0000;
- else
- words[0]=0x8000;
- bzero (&words[1], 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 int 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 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.
- */
- *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_warn("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);
- bcopy(&arr[0],&dv,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);
- bcopy(&arr[0],&fv,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
diff --git a/gnu/usr.bin/as/config/i386-opcode.h b/gnu/usr.bin/as/config/i386-opcode.h
deleted file mode 100644
index 35c86c3..0000000
--- a/gnu/usr.bin/as/config/i386-opcode.h
+++ /dev/null
@@ -1,806 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- *
- * @(#)i386-opcode.h 6.3 (Berkeley) 5/8/91
- */
-
-/* i386-opcode.h -- Intel 80386 opcode table
- Copyright (C) 1989, 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. */
-
-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, Reg16|Mem16, 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, 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 },
-
-/* 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, Imm32, 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},
-
-{"setb", 1, 0x0f92, 0, Modrm, Reg8|Mem, 0, 0},
-{"setnae", 1, 0x0f92, 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},
-{"ins", 0, 0x6c, _, W|NoModrm, 0, 0, 0},
-{"outs", 0, 0x6e, _, W|NoModrm, 0, 0, 0},
-{"lods", 0, 0xac, _, W|NoModrm, 0, 0, 0},
-{"movs", 0, 0xa4, _, W|NoModrm, 0, 0, 0},
-{"scas", 0, 0xae, _, W|NoModrm, 0, 0, 0},
-{"stos", 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, 0xdac0, _, 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, 0xdae0, _, ShortForm, FloatReg, 0, 0},
-{"fsubp", 2, 0xdae0, _, 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, 0xdae8, _, ShortForm, FloatReg, 0, 0},
-{"fsubrp", 2, 0xdae8, _, 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, 0xdac8, _, ShortForm, FloatReg, 0, 0},
-{"fmulp", 2, 0xdac8, _, 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, 0xdaf0, _, ShortForm, FloatReg, 0, 0},
-{"fdivp", 2, 0xdaf0, _, 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, 0xdaf8, _, ShortForm, FloatReg, 0, 0},
-{"fdivrp", 2, 0xdaf8, _, 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},
-{"word", 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},
-
-{"", 0, 0, 0, 0, 0, 0, 0} /* sentinal */
-};
-#undef _
-
-template *i386_optab_end
- = i386_optab + sizeof (i386_optab)/sizeof(i386_optab[0]);
-
-/* 386 register table */
-
-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},
- /* debug registers */
- {"db0", Debug, 0}, {"db1", Debug, 1}, {"db2", Debug, 2},
- {"db3", Debug, 3}, {"db6", Debug, 6}, {"db7", Debug, 7},
- /* test registers */
- {"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 */
-
-reg_entry *i386_regtab_end
- = i386_regtab + sizeof(i386_regtab)/sizeof(i386_regtab[0]);
-
-/* segment stuff */
-seg_entry cs = { "cs", 0x2e };
-seg_entry ds = { "ds", 0x3e };
-seg_entry ss = { "ss", 0x36 };
-seg_entry es = { "es", 0x26 };
-seg_entry fs = { "fs", 0x64 };
-seg_entry gs = { "gs", 0x65 };
-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;
-*/
-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 */
-};
-
-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 */
-};
-
-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 }, /* repeat string instructions */
- { "repne", 0xf2 }
-};
-
-prefix_entry *i386_prefixtab_end
- = i386_prefixtab + sizeof(i386_prefixtab)/sizeof(i386_prefixtab[0]);
-
diff --git a/gnu/usr.bin/as/config/i386.c b/gnu/usr.bin/as/config/i386.c
deleted file mode 100644
index 2281acd..0000000
--- a/gnu/usr.bin/as/config/i386.c
+++ /dev/null
@@ -1,1946 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)i386.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* i386.c -- Assemble code for the Intel 80386
- Copyright (C) 1989, 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. */
-
-/*
- 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.
-*/
-
-#include <stdio.h>
-#include <varargs.h>
-#include <ctype.h>
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-extern char *alloca();
-#endif
-#ifdef USG
-#define index strchr
-#endif
-
-#include "as.h"
-#include "read.h"
-#include "flonum.h"
-#include "obstack.h"
-#include "frags.h"
-#include "struc-symbol.h"
-#include "expr.h"
-#include "symbols.h"
-#include "hash.h"
-#include "md.h"
-#include "i386.h"
-#include "i386-opcode.h"
-
-long omagic = OMAGIC;
-char FLT_CHARS[] = "fFdDxX";
-char EXP_CHARS[] = "eE";
-char line_comment_chars[] = "#";
-char comment_chars[] = "#";
-
-/* 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},
-
-};
-
-void float_cons (), cons ();
-
-/* 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[] = {
- { "ffloat", float_cons, 'f' },
- { "dfloat", float_cons, 'd' },
- { "tfloat", float_cons, 'x' },
- { "value", cons, 2 },
- { "ident", dummy, 0 }, /* ignore these directives */
- { "def", dummy, 0 },
- { "optim", dummy, 0 }, /* For sun386i cc */
- { "version", dummy, 0 },
- { "ln", dummy, 0 },
- { 0, 0, 0 }
-};
-
-/* for interface with expression () */
-extern char * input_line_pointer;
-char * index ();
-
-char * output_invalid ();
-reg_entry * parse_register ();
-
-/* 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 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 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 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;
-
- bzero (opcode_chars, sizeof(opcode_chars));
- bzero (operand_chars, sizeof(operand_chars));
- bzero (space_chars, sizeof(space_chars));
- bzero (identifier_chars, sizeof(identifier_chars));
- bzero (digit_chars, 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 && index(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. */
-
-
-#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");
- }
-}
-
-char *seg_names[] = {
-"SEG_ABSOLUTE", "SEG_TEXT", "SEG_DATA", "SEG_BSS", "SEG_UNKNOWN",
-"SEG_NONE", "SEG_PASS1", "SEG_GOOF", "SEG_BIG", "SEG_DIFFERENCE" };
-
-static void pe (e)
- expressionS *e;
-{
- fprintf (stdout, " segment %s\n", seg_names[(int) 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");
- }
-}
-
-#define SYMBOL_TYPE(t) \
- (((t&N_TYPE) == N_UNDF) ? "UNDEFINED" : \
- (((t&N_TYPE) == N_ABS) ? "ABSOLUTE" : \
- (((t&N_TYPE) == N_TEXT) ? "TEXT" : \
- (((t&N_TYPE) == N_DATA) ? "DATA" : \
- (((t&N_TYPE) == N_BSS) ? "BSS" : "Bad n_type!")))))
-
-static void ps (s)
- symbolS *s;
-{
- fprintf (stdout, "%s type %s%s",
- s->sy_nlist.n_un.n_name,
- (s->sy_nlist.n_type&N_EXT) ? "EXTERNAL " : "",
- SYMBOL_TYPE (s->sy_nlist.n_type));
-}
-
-struct type_name {
- uint 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)
- uint 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. */
- bzero (&i, sizeof(i));
- bzero (disp_expressions, sizeof(disp_expressions));
- bzero (im_expressions, 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. */
-
- /* TRUE if operand is pending after ','. */
- uint expecting_operand = 0;
- /* TRUE if we found a prefix only acceptable with string insns. */
- uint expecting_string_instruction = 0;
- /* Non-zero if operand parens not balenced. */
- uint 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 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 = TRUE;
- /* 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)) {
- 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 */
- uint 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 = TRUE;
- }
- } 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 uint overlap0, overlap1;
- expressionS * exp;
- uint overlap2;
- uint 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!). */
- bcopy (t, &i.tm, 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) {
- uint 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) {
- uint first_reg_operand = (i.types[0] & Reg) ? 0 : 1;
- uint 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. */
- uint 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) {
- uint 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) {
- uint fake_zero_displacement = FALSE;
- uint 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 = TRUE;
- /* 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 = TRUE; /* 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 = TRUE;
- 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) {
- uint seg_index;
- 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) {
- uint 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,
- ((uchar) *p == JUMP_PC_RELATIVE
- ? ENCODE_RELAX_STATE (UNCOND_JUMP, BYTE)
- : ENCODE_RELAX_STATE (COND_JUMP, BYTE)),
- i.disps[0]->X_add_symbol,
- n, p);
- 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);
- 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);
- 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. */
- register char *q;
-
- /* First the prefix bytes. */
- for (q = i.prefix; q < i.prefix + i.prefixes; q++) {
- p = frag_more (1);
- md_number_to_chars (p, (uint) *q, 1);
- }
-
- /* Now the opcode; be careful about word order here! */
- if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) {
- FRAG_APPEND_1_CHAR (t->base_opcode);
- } else if (FITS_IN_UNSIGNED_WORD(t->base_opcode)) {
- p = frag_more (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);
- *p++ = (t->base_opcode >> 24) & 0xff;
- } else p = frag_more (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);
- /* 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);
- /* 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 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) */
- p = frag_more (4);
- 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);
- }
- }
- }
- } /* end displacement output */
-
- /* output immediate */
- if (i.imm_operands) {
- register 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 ... */
- 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);
- 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);
- }
- }
- }
- } /* 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. */
-
-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 = 0;
- char * displacement_string_end;
-
- /* 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 = &es; break;
- case 1:
- i.seg = &cs; break;
- case 2:
- i.seg = &ss; break;
- case 3:
- i.seg = &ds; break;
- case 4:
- i.seg = &fs; break;
- case 5:
- i.seg = &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;
- register expressionS *exp;
- segT exp_seg;
- 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;
- input_line_pointer = ++op_string; /* must advance op_string! */
- exp_seg = expression (exp);
- input_line_pointer = save_input_line_pointer;
- switch (exp_seg) {
- case SEG_NONE: /* 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:
- 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;
- uint 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 = FALSE;
- if (*base_string == ')') {
- uint 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 = TRUE;
- }
-
- /* 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;
- char * save_input_line_pointer;
- exp = &disp_expressions[i.disp_operands];
- i.disps [this_operand] = exp;
- i.disp_operands++;
- save_input_line_pointer = input_line_pointer;
- input_line_pointer = displacement_string_start;
- END_STRING_AND_SAVE (displacement_string_end);
- exp_seg = expression (exp);
- 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_NONE:
- /* missing expr becomes absolute 0 */
- as_bad ("missing or invalid displacement '%s' taken as 0",
- operand_string);
- 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;
- break;
- case SEG_ABSOLUTE:
- i.types[this_operand] |= SMALLEST_DISP_TYPE (exp->X_add_number);
- break;
- case SEG_TEXT: case SEG_DATA: case SEG_BSS:
- case SEG_UNKNOWN: /* must be 32 bit displacement (i.e. address) */
- i.types[this_operand] |= Disp32;
- 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;
- }
- 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_type)
- register fragS * fragP;
- register int segment_type; /* N_DATA or N_TEXT. */
-{
- register uchar * opcode;
- register int old_fr_fix;
-
- old_fr_fix = fragP -> fr_fix;
- opcode = (uchar *) fragP -> fr_opcode;
- /* We've already got fragP->fr_subtype right; all we have to do is check
- for un-relaxable symbols. */
- if ((fragP -> fr_symbol -> sy_type & N_TYPE) != segment_type) {
- /* 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);
- 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);
- 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 (fragP)
- register fragS * fragP;
-{
- register uchar * opcode;
- uchar * where_to_put_displacement;
- uint target_address, opcode_address;
- uint extension;
- int displacement_from_opcode_start;
-
- opcode = (uchar *) fragP -> fr_opcode;
-
- /* Address we want to reach in file space. */
- target_address = fragP->fr_symbol->sy_value + 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 (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 */
-
-void md_create_short_jump(ptr, from_addr, to_addr)
- char *ptr;
- long from_addr, to_addr;
-{
- 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 - to_symbol->sy_value;
- 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 int) 0, 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;
-{
- return 1;
-}
-
-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. */
-{
- 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);
- }
-}
-
-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. */
-{
- char * answer = alloca (nbytes);
- register char * p = answer;
-
- switch (nbytes) {
- 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 (nbytes);
- }
- bcopy (answer, con, nbytes);
-}
-
-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. */
-{
- char * answer = alloca (nbytes);
- register char * p = answer;
-
- switch (nbytes) {
- 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 (nbytes);
- }
- bcopy (answer, con, 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. */
-{
- char * answer = alloca (nbytes);
- register char * p = answer;
-
- switch (nbytes) {
- 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 (nbytes);
- }
- bcopy (answer, con, nbytes);
-}
-
-long int /* 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 int retval;
- for (retval=0, con+=nbytes-1; nbytes--; con--)
- {
- retval <<= BITS_PER_CHAR;
- retval |= *con;
- }
- return retval;
-}
-
-void md_ri_to_chars(ri_p, ri)
- struct relocation_info *ri_p, ri;
-{
- unsigned char the_bytes[8];
-
- /* 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;
- /* now put it back where you found it */
- bcopy (the_bytes, (char *)ri_p, sizeof(struct relocation_info));
-}
-
-
-#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;
- char *atof_ieee();
-
- 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];
-
-char * output_invalid (c)
- char c;
-{
- if (isprint(c)) sprintf (output_invalid_buf, "'%c'", c);
- else sprintf (output_invalid_buf, "(0x%x)", c);
- return output_invalid_buf;
-}
-
-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);
-}
-
diff --git a/gnu/usr.bin/as/config/i386.h b/gnu/usr.bin/as/config/i386.h
deleted file mode 100644
index c569c1c..0000000
--- a/gnu/usr.bin/as/config/i386.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/* i386.h -- Header file for i386.c
- Copyright (C) 1989, 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. */
-
-#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
-
-/* 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 MODE_FROM_DISP_SIZE(t) \
- ((t&(Disp8)) ? 1 : \
- ((t&(Disp32)) ? 2 : 0))
-
-#define Byte (Reg8|Imm8|Imm8S)
-#define Word (Reg16|Imm16)
-#define DWord (Reg32|Imm32)
-
-/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */
-#define OPCODE_SUFFIX_TO_TYPE(s) \
- (s == BYTE_OPCODE_SUFFIX ? Byte : \
- (s == WORD_OPCODE_SUFFIX ? Word : DWord))
-
-#define FITS_IN_SIGNED_BYTE(num) ((num) >= -128 && (num) <= 127)
-#define FITS_IN_UNSIGNED_BYTE(num) ((num) >= 0 && (num) <= 255)
-#define FITS_IN_UNSIGNED_WORD(num) ((num) >= 0 && (num) <= 65535)
-#define FITS_IN_SIGNED_WORD(num) ((num) >= -32768 && (num) <= 32767)
-
-#define SMALLEST_DISP_TYPE(num) \
- FITS_IN_SIGNED_BYTE(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
-
-#define SMALLEST_IMM_TYPE(num) \
- (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)
-
-typedef unsigned char uchar;
-typedef unsigned int uint;
-
-typedef struct {
- /* instruction name sans width suffix ("mov" for movl insns) */
- char *name;
-
- /* how many operands */
- uint operands;
-
- /* base_opcode is the fundamental opcode byte with a optional prefix(es). */
- uint 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 */
- uchar 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 */
- uint 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 */
- uint 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;
- uint reg_type;
- uint reg_num;
-} reg_entry;
-
-typedef struct {
- char * seg_name;
- uint seg_prefix;
-} seg_entry;
-
-/* these are for prefix name --> prefix code hash lookup */
-typedef struct {
- char * prefix_name;
- uchar 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;
-
-/* '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. */
- uint operands;
-
- /* REG_OPERANDS, DISP_OPERANDS, MEM_OPERANDS, IMM_OPERANDS give the number of
- given register, displacement, memory operands and immediate operands. */
- uint 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. */
- uint types [MAX_OPERANDS];
-
- /* Displacements (if given) for each operand. */
- expressionS * disps [MAX_OPERANDS];
-
- /* 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;
- uint log2_scale_factor;
-
- /* SEG gives the seg_entry of this insn. It is equal to zero unless
- an explicit segment override is given. */
- seg_entry * seg; /* segment for memory operands (if given) */
-
- /* PREFIX holds all the given prefix opcodes (usually null).
- PREFIXES is the size of PREFIX. */
- char prefix [MAX_PREFIXES];
- uint 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;
diff --git a/gnu/usr.bin/as/expr.c b/gnu/usr.bin/as/expr.c
deleted file mode 100644
index f3a377d..0000000
--- a/gnu/usr.bin/as/expr.c
+++ /dev/null
@@ -1,980 +0,0 @@
-/* expr.c -operands, expressions-
- 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 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.
- */
-
-#include <ctype.h>
-#include "as.h"
-#include "flonum.h"
-#include "read.h"
-#include "struc-symbol.h"
-#include "expr.h"
-#include "obstack.h"
-#include "symbols.h"
-
-static void clean_up_expression(); /* Internal. */
-extern const char EXP_CHARS[]; /* JF hide MD floating pt stuff all the same place */
-extern const char FLT_CHARS[];
-
-#ifdef SUN_ASM_SYNTAX
-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_NONE.
- * 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 struct symbol * symbolP; /* Points to symbol */
-
- extern char hex_value[]; /* In hex_value.c */
- char *local_label_name();
-
- SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */
- c = * input_line_pointer ++; /* Input_line_pointer -> past char in c. */
- if (isdigit(c))
- {
- 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; /* 8, 10 or 16 */
- /* 0 means we saw start of a floating- */
- /* point constant. */
- register short int maxdig;/* Highest permitted digit value. */
- register int too_many_digits; /* 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=='0')
- { /* non-decimal radix */
- if ((c = * input_line_pointer ++)=='x' || c=='X')
- {
- c = * input_line_pointer ++; /* read past "0x" or "0X" */
- 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 */
- if(c=='f' && (! *input_line_pointer ||
- (!index("+-.0123456789",*input_line_pointer) &&
- !index(EXP_CHARS,*input_line_pointer))))
- {
- maxdig = radix = 10;
- too_many_digits = 11;
- c='0';
- input_line_pointer-=2;
- }
- else if (c && index (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 = 8;
- maxdig = 10; /* Un*x sux. Compatibility. */
- too_many_digits = 11;
- }
- }
- /* c == char after "0" or "0x" or "0X" or "0e" etc.*/
- }
- else
- {
- maxdig = radix = 10;
- too_many_digits = 11;
- }
- 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 int 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 int 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( BITS_PER_INT == 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 = TRUE;
- }
- 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)
- {
-#ifdef SUN_ASM_SYNTAX
- if (c=='b' || (c=='$' && local_label_defined[number]))
-#else
- if (c=='b')
-#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_table_lookup(name)) /* seen before */
- && (symbolP -> sy_type & N_TYPE) != N_UNDF /* symbol is defined: OK */
- )
- { /* Expected path: symbol defined. */
- /* Local labels are never absolute. Don't waste time checking absoluteness. */
- know( (symbolP -> sy_type & N_TYPE) == N_DATA
- || (symbolP -> sy_type & N_TYPE) == N_TEXT );
- expressionP -> X_add_symbol = symbolP;
- expressionP -> X_add_number = 0;
- expressionP -> X_seg = N_TYPE_seg [symbolP -> sy_type];
- }
- else
- { /* Either not seen or not defined. */
- as_warn( "Backw. ref to unknown label \"%d:\", 0 assumed.",
- number
- );
- expressionP -> X_add_number = 0;
- expressionP -> X_seg = SEG_ABSOLUTE;
- }
- }
- else
- {
-#ifdef SUN_ASM_SYNTAX
- if (c=='f' || (c=='$' && !local_label_defined[number]))
-#else
- if (c=='f')
-#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);
- if ( symbolP = symbol_table_lookup( name ))
- {
- /* We have no need to check symbol properties. */
- know( (symbolP -> sy_type & N_TYPE) == N_UNDF
- || (symbolP -> sy_type & N_TYPE) == N_DATA
- || (symbolP -> sy_type & N_TYPE) == N_TEXT);
- }
- else
- {
- symbolP = symbol_new (name, N_UNDF, 0,0,0, & zero_address_frag);
- symbol_table_insert (symbolP);
- }
- 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_warn( "Bad floating-point constant: exponent overflow, probably assembling junk" );
- }
- else
- {
- as_warn( "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("L0\001",
- (unsigned char)(seg_N_TYPE[(int)now_seg]),
- 0,
- 0,
- (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;
- c = get_symbol_end();
- symbolP = symbol_table_lookup(name);
- if (symbolP)
- {
- /*
- * If we have an absolute symbol, then we know it's value now.
- */
- register segT seg;
-
- seg = N_TYPE_seg [(int) symbolP -> sy_type & N_TYPE];
- if ((expressionP -> X_seg = seg) == SEG_ABSOLUTE )
- {
- expressionP -> X_add_number = symbolP -> sy_value;
- }
- else
- {
- expressionP -> X_add_number = 0;
- expressionP -> X_add_symbol = symbolP;
- }
- }
- else
- {
- expressionP -> X_add_symbol
- = symbolP
- = symbol_new (name, N_UNDF, 0,0,0, & zero_address_frag);
-
- expressionP -> X_add_number = 0;
- expressionP -> X_seg = SEG_UNKNOWN;
- symbol_table_insert (symbolP);
- }
- * input_line_pointer = c;
- expressionP -> X_subtract_symbol = NULL;
- }
- else if (c=='(')/* didn't begin with digit & not a name */
- {
- (void)expression( expressionP );
- /* Expression() will pass trailing whitespace */
- if ( * input_line_pointer ++ != ')' )
- {
- as_warn( "Missing ')' assumed");
- input_line_pointer --;
- }
- /* here with input_line_pointer -> char after "(...)" */
- }
- else if ( 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
- {
- expressionP -> X_add_number = ~ expressionP -> X_add_number;
- }
- break;
-
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- 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;
- }
- default: /* unary on non-absolute is unsuported */
- as_warn("Unary operator %c ignored because bad operand follows", c);
- 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_NONE;
- input_line_pointer --;
- }
-/*
- * 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_NONE.
- * 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_NONE:
- 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_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- 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
- && expressionP->X_subtract_symbol->sy_value==expressionP->X_add_symbol->sy_value))
- {
- expressionP -> X_subtract_symbol = NULL;
- expressionP -> X_add_symbol = NULL;
- expressionP -> X_seg = SEG_ABSOLUTE;
- }
- break;
-
- default:
- BAD_CASE( expressionP -> X_seg);
- break;
- }
-}
-
-/*
- * 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)
- struct symbol ** symbol_1_PP;
- struct symbol * symbol_2_P;
-{
- segT return_value;
-
- know( (* symbol_1_PP) == NULL
- || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_TEXT
- || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_DATA
- || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_BSS
- || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_UNDF
- );
- know( symbol_2_P == NULL
- || (symbol_2_P -> sy_type & N_TYPE) == N_TEXT
- || (symbol_2_P -> sy_type & N_TYPE) == N_DATA
- || (symbol_2_P -> sy_type & N_TYPE) == N_BSS
- || (symbol_2_P -> sy_type & N_TYPE) == N_UNDF
- );
- if (* symbol_1_PP)
- {
- if (((* symbol_1_PP) -> sy_type & N_TYPE) == N_UNDF)
- {
- if (symbol_2_P)
- {
- return_value = SEG_PASS1;
- * symbol_1_PP = NULL;
- }
- else
- {
- know( ((* symbol_1_PP) -> sy_type & N_TYPE) == N_UNDF)
- return_value = SEG_UNKNOWN;
- }
- }
- else
- {
- if (symbol_2_P)
- {
- if ((symbol_2_P -> sy_type & N_TYPE) == N_UNDF)
- {
- * symbol_1_PP = NULL;
- return_value = SEG_PASS1;
- }
- else
- {
- /* {seg1} - {seg2} */
- as_warn( "Expression too complex, 2 symbols forgotten: \"%s\" \"%s\"",
- (* symbol_1_PP) -> sy_name, symbol_2_P -> sy_name );
- * symbol_1_PP = NULL;
- return_value = SEG_ABSOLUTE;
- }
- }
- else
- {
- return_value = N_TYPE_seg [(* symbol_1_PP) -> sy_type & N_TYPE];
- }
- }
- }
- else
- { /* (* symbol_1_PP) == NULL */
- if (symbol_2_P)
- {
- * symbol_1_PP = symbol_2_P;
- return_value = N_TYPE_seg [(symbol_2_P) -> sy_type & N_TYPE];
- }
- else
- {
- * symbol_1_PP = NULL;
- return_value = SEG_ABSOLUTE;
- }
- }
- 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
- );
- know( (* symbol_1_PP) == NULL
- || ((* symbol_1_PP) -> sy_type & N_TYPE) == seg_N_TYPE [(int) return_value] );
- return (return_value);
-} /* expr_part() */
-
-/* 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 * / % < >
- */
-typedef char operator_rankT;
-static const operator_rankT
-op_rank [] = { 0, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1 };
-
-segT /* Return resultP -> X_seg. */
-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_NONE == 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 struct symbol * 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;
-
- 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
- );
-
- clean_up_expression (& right);
- clean_up_expression (resultP);
-
- seg1 = expr_part (& resultP -> X_add_symbol, right . X_add_symbol);
- seg2 = expr_part (& resultP -> X_subtract_symbol, right . X_subtract_symbol);
- if (seg1 == SEG_PASS1 || seg2 == SEG_PASS1) {
- need_pass_2 = TRUE;
- 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 );
-
- know( seg1 == SEG_TEXT || seg1 == SEG_DATA || seg1== SEG_BSS );
- know( seg2 == SEG_TEXT || seg2 == SEG_DATA || seg2== SEG_BSS );
- know( resultP -> X_add_symbol );
- know( resultP -> X_subtract_symbol );
- as_warn("Expression too complex: forgetting %s - %s",
- resultP -> X_add_symbol -> sy_name,
- resultP -> X_subtract_symbol -> sy_name);
- 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 = TRUE;
- }
- 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_warn( "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);
-}
-
-/*
- * 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);
-}
-
-/* end: expr.c */
diff --git a/gnu/usr.bin/as/expr.h b/gnu/usr.bin/as/expr.h
deleted file mode 100644
index 964d3b9..0000000
--- a/gnu/usr.bin/as/expr.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* expr.h -> header file for expr.c
- 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. */
-
-/*
- * 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 */
- long int 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. */
-
-
-segT expr();
-char get_symbol_end();
-
-/* end: expr.h */
diff --git a/gnu/usr.bin/as/flonum-const.c b/gnu/usr.bin/as/flonum-const.c
deleted file mode 100644
index 617e585..0000000
--- a/gnu/usr.bin/as/flonum-const.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* flonum_const.c - Useful Flonum constants
- 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. */
-
-#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 VMS
-dummy1()
-{
-}
-#endif
-/* end: flonum_const.c */
diff --git a/gnu/usr.bin/as/flonum-copy.c b/gnu/usr.bin/as/flonum-copy.c
deleted file mode 100644
index 3a51f06..0000000
--- a/gnu/usr.bin/as/flonum-copy.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* flonum_copy.c - copy a flonum
- 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. */
-
-#include "flonum.h"
-#ifdef USG
-#define bzero(s,n) memset(s,0,n)
-#define bcopy(from,to,n) memcpy(to,from,n)
-#endif
-
-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)
- {
- bzero ((char *)(out->low + in_length + 1), out_length - in_length);
- }
- }
- bcopy ((char *)(in->low), (char *)(out->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 ! */
- bcopy ((char *)(in->low + shorten),(char *)( out->low), (int)((out_length + 1) * sizeof(LITTLENUM_TYPE)));
- out -> leader = out -> high;
- out -> exponent = in -> exponent + shorten;
- }
- } /* if any significant bits */
-}
-
-/* end: 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 1b7b5ea..0000000
--- a/gnu/usr.bin/as/flonum-mult.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/* flonum_multip.c - multiply two flonums
- 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. */
-
-#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)
- FLONUM_TYPE * a,
- * b,
- * 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 int work;
- unsigned long int carry;
- long int exponent;
- LITTLENUM_TYPE * q;
- long int 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: flonum_multip.c */
diff --git a/gnu/usr.bin/as/flonum.h b/gnu/usr.bin/as/flonum.h
deleted file mode 100644
index b2e841a..0000000
--- a/gnu/usr.bin/as/flonum.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* flonum.h - Floating point package
- 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. */
-
-/***********************************************************************\
-* *
-* 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 !defined(__STDC__) && !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 int 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. *
-* *
-\***********************************************************************/
-
-void flonum_multip();
-void flonum_copy();
-void flonum_print();
-char * flonum_get(); /* Returns "" or error string. */
-void flonum_normal();
-
-int atof_generic();
-
-
-/***********************************************************************\
-* *
-* Declare error codes. *
-* *
-\***********************************************************************/
-
-#define ERROR_EXPONENT_OVERFLOW (2)
-
-/* end: flonum.h */
diff --git a/gnu/usr.bin/as/frags.c b/gnu/usr.bin/as/frags.c
deleted file mode 100644
index ee10321..0000000
--- a/gnu/usr.bin/as/frags.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/* frags.c - manage frags -
- 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. */
-
-#include "as.h"
-#include "subsegs.h"
-#include "obstack.h"
-#include "frags.h"
-#include "struc-symbol.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)
-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_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 */
- bzero(frag_now, 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;
- 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 int 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 int offset;
- char *opcode;
- char 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;
-}
-
-/* end: frags.c */
diff --git a/gnu/usr.bin/as/frags.h b/gnu/usr.bin/as/frags.h
deleted file mode 100644
index 6d7310b..0000000
--- a/gnu/usr.bin/as/frags.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* frags.h - Header file for the frag concept.
- 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. */
-
-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 ); \
-}
-
-
-/* end: frags.h */
diff --git a/gnu/usr.bin/as/hash.c b/gnu/usr.bin/as/hash.c
deleted file mode 100644
index 21f0cc0..0000000
--- a/gnu/usr.bin/as/hash.c
+++ /dev/null
@@ -1,981 +0,0 @@
-/* hash.c - hash table lookup strings -
- 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. */
-
-/*
- * 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!)
- *
- */
-
-#include <stdio.h>
-#define TRUE (1)
-#define FALSE (0)
-#include <ctype.h>
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
-#include "hash.h"
-char *xmalloc();
-
-#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;
- char * malloc();
- 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) ) )
- /* +1 for the wall entry */
- {
- if ( retval = (struct hash_control *) malloc(sizeof(struct hash_control)) )
- {
- 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))))
- /* +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) && 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) && s!=DELETED )
- {
- for(string1=string;;) {
- if(!(c= *s++)) {
- 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) && 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 int h; /* hash code built here */
- register long int c; /* each character lands here */
- register int n; /* Amount to shift h by */
-
- n = (handle->hash_sizelog - 3);
- h = 0;
- while (c = *string++)
- {
- 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: ");
- gets(answer);
- 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);
- gets(answer);
- /* 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);
- gets(answer);
- 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: hash.c */
diff --git a/gnu/usr.bin/as/hash.h b/gnu/usr.bin/as/hash.h
deleted file mode 100644
index fb68fd3..0000000
--- a/gnu/usr.bin/as/hash.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* hash.h - for hash.c
- 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. */
-
-#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 */
-};
-
-
-/* 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: hash.c */
diff --git a/gnu/usr.bin/as/hex-value.c b/gnu/usr.bin/as/hex-value.c
deleted file mode 100644
index f97c2ab3..0000000
--- a/gnu/usr.bin/as/hex-value.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* hex_value.c - char=>radix-value -
- 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. */
-
-/*
- * Export: Hex_value[]. Converts digits to their radix-values.
- * As distributed assumes 8 bits per char (256 entries) and ASCII.
- */
-
-#define __ (42) /* blatently illegal digit value */
- /* exceeds any normal radix */
-#if !defined(__STDC__) && !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 VMS
-dummy2()
-{
-}
-#endif
-/* end: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 8de1dcf..0000000
--- a/gnu/usr.bin/as/input-file.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)input-file.c 6.2 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* input_file.c - Deal with Input Files -
- 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. */
-
-/*
- * 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!
- */
-
-#define NDEBUG /* JF remove asserts */
-
-#ifdef USG
-#define index strchr
-/* JF: What's the difference between _IOLBF and _IOFBF ? */
-#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOFBF, (size))
-#endif
-
-#include <stdio.h>
-#include <assert.h>
-/* #include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/wait.h> */
-
-/* #include "style.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;
-
-void as_perror();
-
-/*
- * 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)
-
-static char in_buf[BUFFER_SIZE];
-
-/*
- * We use static data: the data area is not sharable.
- */
-
-FILE *f_in; /* JF do things the RIGHT way */
-/* static JF remove static so app.c can use file_name */
-char * file_name;
-
-/* These hooks accomodate most operating systems. */
-
-void
-input_file_begin ()
-{
- /* file_handle = -1; */
- f_in = (FILE *)0;
-}
-
-void
-input_file_end ()
-{
-}
-
-int /* Return BUFFER_SIZE. */
-input_file_buffer_size ()
-{
- return (BUFFER_SIZE);
-}
-
-int
-input_file_is_open ()
-{
- /* return (file_handle >= 0); */
- return f_in!=(FILE *)0;
-}
-
-#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;
- char *mktemp();
-
- (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_warn( "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 VMS
- setbuffer(f_in,in_buf,BUFFER_SIZE);
-#endif /* 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(!index(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];
- char *mktemp();
- 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
-
-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.
- */
- /* size = read (file_handle, where, BUFFER_SIZE); */
- if(preprocess) {
- char *p;
- int n;
- int ch;
- extern FILE *scrub_file;
- int scrub_from_file();
- void scrub_to_file();
- int do_scrub_next_char();
-
- 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: 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 42f490a..0000000
--- a/gnu/usr.bin/as/input-file.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* input_file.h header for input-file.c
- 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. */
-
-/*"input_file.c":Operating-system dependant functions to read source files.*/
-
-
-/*
- * 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.
- *
- * 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.
- */
-
-void input_file_begin();
-void input_file_end();
-int input_file_buffer_size();
-int input_file_is_open();
-void input_file_open();
-char * input_file_give_next_buffer();
-
-/* end: 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 71af8a0..0000000
--- a/gnu/usr.bin/as/input-scrub.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)input-scrub.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* input_scrub.c - layer between app and the rest of the world
- 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. */
-
-#include "as.h"
-#include "read.h"
-#include "input-file.h"
-
-/*
- * O/S independent module to supply buffers of sanitised source code
- * to rest of assembler. We get raw input data of some length.
- * Also looks after line numbers, for e.g. error messages.
- * This module used to do the sanitising, but now a pre-processor program
- * (app) does that job so this module is degenerate.
- * Now input is pre-sanitised, so we only worry about finding the
- * last partial line. A buffer of full lines is returned to 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. The last character before AFTER_STRING is a newline.
- */
-
-/*
- * We expect 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") /* bcopy 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 int buffer_length; /* What is the largest size buffer that */
- /* input_file_give_next_buffer() could */
- /* return to us? */
-
-static void as_1_char ();
-
-/*
-We never have more than one source file open at once.
-We may, however, read more than 1 source file in an assembly.
-NULL means we have no file open right now.
-*/
-
-
-/*
-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,
- * 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,
- logical_input_line;
-
-void
-input_scrub_begin ()
-{
- know( strlen(BEFORE_STRING) == BEFORE_SIZE );
- know( strlen( AFTER_STRING) == AFTER_SIZE );
-
- input_file_begin ();
-
- buffer_length = input_file_buffer_size ();
-
- buffer_start = xmalloc ((long)(BEFORE_SIZE + buffer_length + buffer_length + AFTER_SIZE));
- bcopy (BEFORE_STRING, buffer_start, (int)BEFORE_SIZE);
-
- /* Line number things. */
- logical_input_line = 0;
- logical_input_file = (char *)NULL;
- physical_input_file = NULL; /* No file read yet. */
- do_scrub_begin();
-}
-
-void
-input_scrub_end ()
-{
- input_file_end ();
-}
-
-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);
-}
-
-char *
-input_scrub_next_buffer (bufp)
-char **bufp;
-{
- register char * limit; /* -> just after last char of buffer. */
-
-#ifdef DONTDEF
- if(preprocess) {
- if(save_buffer) {
- *bufp = save_buffer;
- save_buffer = 0;
- }
- limit = input_file_give_next_buffer(buffer_start+BEFORE_SIZE);
- if (!limit) {
- partial_where = 0;
- if(partial_size)
- as_warn("Partial line at end of file ignored");
- return partial_where;
- }
-
- if(partial_size)
- bcopy(save_source, partial_where,(int)AFTER_SIZE);
- do_scrub(partial_where,partial_size,buffer_start+BEFORE_SIZE,limit-(buffer_start+BEFORE_SIZE),&out_string,&out_length);
- limit=out_string + out_length;
- for(p=limit;*--p!='\n';)
- ;
- p++;
- if(p<=buffer_start+BEFORE_SIZE)
- as_fatal("Source line too long. Please change file '%s' and re-make the assembler.",__FILE__);
-
- partial_where = p;
- partial_size = limit-p;
- bcopy(partial_where, save_source,(int)AFTER_SIZE);
- bcopy(AFTER_STRING, partial_where, (int)AFTER_SIZE);
-
- save_buffer = *bufp;
- *bufp = out_string;
-
- return partial_where;
- }
-
- /* We're not preprocessing. Do the right thing */
-#endif
- if (partial_size)
- {
- bcopy (partial_where, buffer_start + BEFORE_SIZE, (int)partial_size);
- bcopy (save_source, buffer_start + BEFORE_SIZE, (int)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;
- bcopy (partial_where, save_source, (int)AFTER_SIZE);
- bcopy (AFTER_STRING, partial_where, (int)AFTER_SIZE);
- }
- else
- {
- partial_where = 0;
- if (partial_size > 0)
- {
- as_warn( "Partial line at end of file ignored" );
- }
- }
- return (partial_where);
-}
-
-/*
- * 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;
- ++ logical_input_line;
-}
-
-/*
- * new_logical_line()
- *
- * Tells us what the new logical line number and file are.
- * If the line_number is <0, we don't change the current logical line number.
- * 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 ( line_number >= 0 )
- {
- logical_input_line = line_number;
- }
-}
-
-/*
- * a s _ w h e r e ( )
- *
- * Write a line to stderr locating where we are in reading
- * input source files.
- * As a sop to the debugger of AS, pretty-print the offending line.
- */
-void
-as_where()
-{
- char *p;
- line_numberT line;
-
- if (physical_input_file)
- { /* we tried to read SOME source */
- if (input_file_is_open())
- { /* we can still read lines from source */
-#ifdef DONTDEF
- fprintf (stderr," @ physical line %ld., file \"%s\"",
- (long) physical_input_line, physical_input_file);
- fprintf (stderr," @ logical line %ld., file \"%s\"\n",
- (long) logical_input_line, logical_input_file);
- (void)putc(' ', stderr);
- as_howmuch (stderr);
- (void)putc('\n', stderr);
-#else
- p = logical_input_file ? logical_input_file : physical_input_file;
- line = logical_input_line ? logical_input_line : physical_input_line;
- fprintf(stderr,"%s:%u:", p, line);
-#endif
- }
- else
- {
-#ifdef DONTDEF
- fprintf (stderr," After reading source.\n");
-#else
- p = logical_input_file ? logical_input_file : physical_input_file;
- line = logical_input_line ? logical_input_line : physical_input_line;
- fprintf (stderr,"%s:unknown:", p);
-#endif
- }
- }
- else
- {
-#ifdef DONTDEF
- fprintf (stderr," Before reading source.\n");
-#else
-#endif
- }
-}
-
-/*
- * Support for source file debugging. These functions handle
- * logical lines and logical files.
- */
-static char *saved_file;
-static int saved_len;
-static line_numberT saved_line;
-
-void
-filestab()
-{
- char *file;
- int len;
-
- if (!physical_input_file ||
- !input_file_is_open())
- return;
-
- file = logical_input_file ? logical_input_file : physical_input_file;
-
- if (saved_file == 0 || strcmp(file, saved_file) != 0)
- {
- stabs(file);
- len = strlen(file) + 1;
- if (len > saved_len)
- {
- if (saved_file == 0)
- saved_file = xmalloc(len);
- else
- saved_file = xrealloc(saved_file, len);
- memcpy(saved_file, file, len);
- saved_len = len;
- }
- else
- strcpy(saved_file, file);
- saved_line = 0;
- }
-}
-
-void
-funcstab(func)
- char *func;
-{
- if (now_seg != SEG_TEXT)
- return;
-
- filestab();
- stabf(func);
-}
-
-void
-linestab()
-{
- line_numberT line;
-
- if (now_seg != SEG_TEXT)
- return;
-
- filestab();
-
- line = logical_input_line ? logical_input_line : physical_input_line;
-
- if (saved_line == 0 || line != saved_line)
- {
- stabd(line);
- saved_line = line;
- }
-}
-
-/*
- * 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 (*p, stream);
- }
-}
-
-static void
-as_1_char (c,stream)
- unsigned char c;
- FILE * stream;
-{
- if ( c > 127 )
- {
- (void)putc( '%', stream);
- c -= 128;
- }
- if ( c < 32 )
- {
- (void)putc( '^', stream);
- c += '@';
- }
- (void)putc( c, stream);
-}
-
-/* end: input_scrub.c */
diff --git a/gnu/usr.bin/as/md.h b/gnu/usr.bin/as/md.h
deleted file mode 100644
index 681d027..0000000
--- a/gnu/usr.bin/as/md.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* md.h -machine dependent- */
-
-/* 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. */
-
-/* In theory (mine, at least!) the machine dependent part of the assembler
- should only have to include one file. This one. -- JF */
-
-/* JF added this here */
-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;
-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 */
-
-char * md_atof();
-void md_assemble();
-void md_begin();
-void md_convert_frag();
-void md_end();
-int md_estimate_size_before_relax();
-void md_number_to_chars();
-
-/* end: md.h */
diff --git a/gnu/usr.bin/as/messages.c b/gnu/usr.bin/as/messages.c
deleted file mode 100644
index a7b1205..0000000
--- a/gnu/usr.bin/as/messages.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/* messages.c - error reporter -
- 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. */
-
-#include <stdio.h> /* define stderr */
-#ifdef VMS
-#include <errno.h> /* Need this to make errno declaration right */
-#include <perror.h> /* Need this to make sys_errlist/sys_nerr right */
-#endif /* VMS */
-
-#include "as.h"
-
-#ifndef NO_VARARGS
-#include <varargs.h>
-#endif
-
-/*
- ERRORS
-
- JF: this is now bogus. We now print more standard error messages
- that try to look like everyone else's.
-
- We print the error message 1st, beginning in column 1.
- All ancillary info starts in column 2 on lines after the
- key error text.
- We try to print a location in logical and physical file
- just after the main error text.
- Caller then prints any appendices after that, begining all
- lines with at least 1 space.
-
- Optionally, we may die.
- There is no need for a trailing '\n' in your error text format
- because we supply one.
-
-as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere().
-
-as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
-
-*/
-
-
-/* Nonzero if we've hit a 'bad error', and should not write an obj file,
- and exit with a nonzero error code */
-
-int bad_error = 0;
-
-
-/*
- * a s _ p e r r o r
- *
- * Like perror(3), but with more info.
- */
-/* JF moved from input-scrub.c to here. */
-void
-as_perror(gripe, filename)
- char * gripe; /* Unpunctuated error theme. */
- char * filename;
-{
- extern int errno; /* See perror(3) for details. */
- extern int sys_nerr;
- extern char * sys_errlist[];
-
- as_where();
- fprintf (stderr,gripe,filename);
- if (errno > sys_nerr)
- fprintf (stderr, "Unknown error #%d.\n", errno);
- else
- fprintf (stderr, "%s.\n", sys_errlist [errno]);
- errno = 0; /* After reporting, clear it. */
-}
-
-/*
- * a s _ w a r n ( )
- *
- * Send to stderr a string (with bell) (JF: Bell is obnoxious!) 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.
- */
-
-#ifdef NO_VARARGS
-/*VARARGS1*/
-as_warn(Format,args)
-char *Format;
-{
- if ( ! flagseen ['W']) /* -W supresses warning messages. */
- {
- as_where();
- _doprnt (Format, &args, stderr);
- (void)putc ('\n', stderr);
- /* as_where(); */
- }
-}
-#else
-void
-as_warn(Format,va_alist)
-char *Format;
-va_dcl
-{
- va_list args;
-
- if( ! flagseen['W'])
- {
- as_where();
- va_start(args);
- vfprintf(stderr, Format, args);
- va_end(args);
- (void) putc('\n', stderr);
- }
-}
-#endif
-#ifdef DONTDEF
-void
-as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
-char *format;
-{
- if(!flagseen['W']) {
- as_where();
- fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
- (void)putc('\n',stderr);
- }
-}
-#endif
-/*
- * a s _ b a d ( )
- *
- * Send to stderr a string (with bell) (JF: Bell is obnoxious!) 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.
- */
-
-#ifdef NO_VARARGS
-/*VARARGS1*/
-as_bad(Format,args)
-char *Format;
-{
- bad_error=1;
- as_where();
- _doprnt (Format, &args, stderr);
- (void)putc ('\n', stderr);
- /* as_where(); */
-}
-#else
-void
-as_bad(Format,va_alist)
-char *Format;
-va_dcl
-{
- va_list args;
-
- bad_error=1;
- as_where();
- va_start(args);
- vfprintf(stderr, Format, args);
- va_end(args);
- (void) putc('\n', stderr);
-}
-#endif
-#ifdef DONTDEF
-void
-as_bad(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
-char *format;
-{
- as_where();
- bad_error=1;
- fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
- (void)putc('\n',stderr);
-}
-#endif
-/*
- * a s _ f a t a l ( )
- *
- * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
- * message, and locate stdsource in input file(s).
- * Please only use this for when we DON'T have some recovery action.
- * It exit()s with a warning status.
- */
-
-#ifdef NO_VARARGS
-/*VARARGS1*/
-as_fatal (Format, args)
-char *Format;
-{
- as_where();
- fprintf(stderr,"FATAL:");
- _doprnt (Format, &args, stderr);
- (void)putc ('\n', stderr);
- /* as_where(); */
- exit(42); /* What is a good exit status? */
-}
-#else
-void
-as_fatal(Format,va_alist)
-char *Format;
-va_dcl
-{
- va_list args;
-
- as_where();
- va_start(args);
- fprintf (stderr, "FATAL:");
- vfprintf(stderr, Format, args);
- (void) putc('\n', stderr);
- va_end(args);
- exit(42);
-}
-#endif
-#ifdef DONTDEF
-void
-as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
-char *Format;
-{
- as_where();
- fprintf (stderr, "FATAL:");
- fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
- (void) putc('\n', stderr);
- exit(42);
-}
-#endif
-
-/* end: messages.c */
diff --git a/gnu/usr.bin/as/objrecdef.h b/gnu/usr.bin/as/objrecdef.h
deleted file mode 100644
index fca8af4..0000000
--- a/gnu/usr.bin/as/objrecdef.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- *
- * $OBJRECDEF
- * Generated automatically by "vms_struct Version 1.00"
- * Created from VMS definition file "objrecdef.mar"
- * Mon Oct 14 14:01:29 1985
- *
- */
-struct OBJREC {
- unsigned char obj$b_rectyp;
- unsigned char obj$b_subtyp;
- unsigned char obj$b_mhd_strlv;
- unsigned char obj$b_mhd_recsz[2];
- unsigned char obj$t_mhd_name[1];
- };
-
-#define OBJ$C_HDR 0
-#define OBJ$C_HDR_MHD 0
-#define OBJ$C_HDR_LNM 1
-#define OBJ$C_HDR_SRC 2
-#define OBJ$C_HDR_TTL 3
-#define OBJ$C_HDR_CPR 4
-#define OBJ$C_HDR_MTC 5
-#define OBJ$C_HDR_GTX 6
-#define OBJ$C_GSD 1
-#define OBJ$C_GSD_PSC 0
-#define OBJ$C_GSD_SYM 1
-#define OBJ$C_GSD_EPM 2
-#define OBJ$C_GSD_PRO 3
-#define OBJ$C_GSD_SYMW 4
-#define OBJ$C_GSD_EPMW 5
-#define OBJ$C_GSD_PROW 6
-#define OBJ$C_GSD_IDC 7
-#define OBJ$C_GSD_ENV 8
-#define OBJ$C_GSD_LSY 9
-#define OBJ$C_GSD_LEPM 10
-#define OBJ$C_GSD_LPRO 11
-#define OBJ$C_GSD_SPSC 12
-#define OBJ$C_TIR 2
-#define OBJ$C_EOM 3
-#define OBJ$C_DBG 4
-#define OBJ$C_TBT 5
-#define OBJ$C_LNK 6
-#define OBJ$C_EOMW 7
-#define OBJ$C_MAXRECTYP 7
-#define OBJ$K_SUBTYP 1
-#define OBJ$C_SUBTYP 1
-#define OBJ$C_MAXRECSIZ 2048
-#define OBJ$C_STRLVL 0
-#define OBJ$C_SYMSIZ 31
-#define OBJ$C_STOREPLIM -1
-#define OBJ$C_PSCALILIM 9
-
-#define MHD$C_MHD 0
-#define MHD$C_LNM 1
-#define MHD$C_SRC 2
-#define MHD$C_TTL 3
-#define MHD$C_CPR 4
-#define MHD$C_MTC 5
-#define MHD$C_GTX 6
-#define MHD$C_MAXHDRTYP 6
-
-#define GSD$K_ENTRIES 1
-#define GSD$C_ENTRIES 1
-#define GSD$C_PSC 0
-#define GSD$C_SYM 1
-#define GSD$C_EPM 2
-#define GSD$C_PRO 3
-#define GSD$C_SYMW 4
-#define GSD$C_EPMW 5
-#define GSD$C_PROW 6
-#define GSD$C_IDC 7
-#define GSD$C_ENV 8
-#define GSD$C_LSY 9
-#define GSD$C_LEPM 10
-#define GSD$C_LPRO 11
-#define GSD$C_SPSC 12
-#define GSD$C_SYMV 13
-#define GSD$C_EPMV 14
-#define GSD$C_PROV 15
-#define GSD$C_MAXRECTYP 15
-
-#define GSY$M_WEAK 1
-#define GSY$M_DEF 2
-#define GSY$M_UNI 4
-#define GSY$M_REL 8
-
-#define GPS$M_PIC 1
-#define GPS$M_LIB 2
-#define GPS$M_OVR 4
-#define GPS$M_REL 8
-#define GPS$M_GBL 16
-#define GPS$M_SHR 32
-#define GPS$M_EXE 64
-#define GPS$M_RD 128
-#define GPS$M_WRT 256
-#define GPS$M_VEC 512
-#define GPS$K_NAME 9
-#define GPS$C_NAME 9
-
-#define TIR$C_STA_GBL 0
-#define TIR$C_STA_SB 1
-#define TIR$C_STA_SW 2
-#define TIR$C_STA_LW 3
-#define TIR$C_STA_PB 4
-#define TIR$C_STA_PW 5
-#define TIR$C_STA_PL 6
-#define TIR$C_STA_UB 7
-#define TIR$C_STA_UW 8
-#define TIR$C_STA_BFI 9
-#define TIR$C_STA_WFI 10
-#define TIR$C_STA_LFI 11
-#define TIR$C_STA_EPM 12
-#define TIR$C_STA_CKARG 13
-#define TIR$C_STA_WPB 14
-#define TIR$C_STA_WPW 15
-#define TIR$C_STA_WPL 16
-#define TIR$C_STA_LSY 17
-#define TIR$C_STA_LIT 18
-#define TIR$C_STA_LEPM 19
-#define TIR$C_MAXSTACOD 19
-#define TIR$C_MINSTOCOD 20
-#define TIR$C_STO_SB 20
-#define TIR$C_STO_SW 21
-#define TIR$C_STO_L 22
-#define TIR$C_STO_BD 23
-#define TIR$C_STO_WD 24
-#define TIR$C_STO_LD 25
-#define TIR$C_STO_LI 26
-#define TIR$C_STO_PIDR 27
-#define TIR$C_STO_PICR 28
-#define TIR$C_STO_RSB 29
-#define TIR$C_STO_RSW 30
-#define TIR$C_STO_RL 31
-#define TIR$C_STO_VPS 32
-#define TIR$C_STO_USB 33
-#define TIR$C_STO_USW 34
-#define TIR$C_STO_RUB 35
-#define TIR$C_STO_RUW 36
-#define TIR$C_STO_B 37
-#define TIR$C_STO_W 38
-#define TIR$C_STO_RB 39
-#define TIR$C_STO_RW 40
-#define TIR$C_STO_RIVB 41
-#define TIR$C_STO_PIRR 42
-#define TIR$C_MAXSTOCOD 42
-#define TIR$C_MINOPRCOD 50
-#define TIR$C_OPR_NOP 50
-#define TIR$C_OPR_ADD 51
-#define TIR$C_OPR_SUB 52
-#define TIR$C_OPR_MUL 53
-#define TIR$C_OPR_DIV 54
-#define TIR$C_OPR_AND 55
-#define TIR$C_OPR_IOR 56
-#define TIR$C_OPR_EOR 57
-#define TIR$C_OPR_NEG 58
-#define TIR$C_OPR_COM 59
-#define TIR$C_OPR_INSV 60
-#define TIR$C_OPR_ASH 61
-#define TIR$C_OPR_USH 62
-#define TIR$C_OPR_ROT 63
-#define TIR$C_OPR_SEL 64
-#define TIR$C_OPR_REDEF 65
-#define TIR$C_OPR_DFLIT 66
-#define TIR$C_MAXOPRCOD 66
-#define TIR$C_MINCTLCOD 80
-#define TIR$C_CTL_SETRB 80
-#define TIR$C_CTL_AUGRB 81
-#define TIR$C_CTL_DFLOC 82
-#define TIR$C_CTL_STLOC 83
-#define TIR$C_CTL_STKDL 84
-#define TIR$C_MAXCTLCOD 84
-
-/*
- * Debugger symbol definitions: These are done by hand, as no
- * machine-readable version seems
- * to be available.
- */
-#define DST$C_C 7 /* Language == "C" */
-#define DST$C_VERSION 153
-#define DST$C_SOURCE 155 /* Source file */
-#define DST$C_PROLOG 162
-#define DST$C_BLKBEG 176 /* Beginning of block */
-#define DST$C_BLKEND 177 /* End of block */
-#define DST$C_ENTRY 181
-#define DST$C_PSECT 184
-#define DST$C_LINE_NUM 185 /* Line Number */
-#define DST$C_LBLORLIT 186
-#define DST$C_LABEL 187
-#define DST$C_MODBEG 188 /* Beginning of module */
-#define DST$C_MODEND 189 /* End of module */
-#define DST$C_RTNBEG 190 /* Beginning of routine */
-#define DST$C_RTNEND 191 /* End of routine */
-#define DST$C_DELTA_PC_W 1 /* Incr PC */
-#define DST$C_INCR_LINUM 2 /* Incr Line # */
-#define DST$C_INCR_LINUM_W 3 /* Incr Line # */
-#define DST$C_SET_LINUM_INCR 4
-#define DST$C_SET_LINUM_INCR_W 5
-#define DST$C_RESET_LINUM_INCR 6
-#define DST$C_BEG_STMT_MODE 7
-#define DST$C_END_STMT_MODE 8
-#define DST$C_SET_LINE_NUM 9 /* Set Line # */
-#define DST$C_SET_PC 10
-#define DST$C_SET_PC_W 11
-#define DST$C_SET_PC_L 12
-#define DST$C_SET_STMTNUM 13
-#define DST$C_TERM 14 /* End of lines */
-#define DST$C_TERM_W 15 /* End of lines */
-#define DST$C_SET_ABS_PC 16 /* Set PC */
-#define DST$C_DELTA_PC_L 17 /* Incr PC */
-#define DST$C_INCR_LINUM_L 18 /* Incr Line # */
-#define DST$C_SET_LINUM_B 19 /* Set Line # */
-#define DST$C_SET_LINUM_L 20 /* Set Line # */
-#define DST$C_TERM_L 21 /* End of lines */
-/* these are used with DST$C_SOURCE */
-#define DST$C_SRC_FORMFEED 16 /* ^L counts */
-#define DST$C_SRC_DECLFILE 1 /* Declare file */
-#define DST$C_SRC_SETFILE 2 /* Set file */
-#define DST$C_SRC_SETREC_L 3 /* Set record */
-#define DST$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$C_UCHAR 0x02
-#define DBG$C_USINT 0x03
-#define DBG$C_ULINT 0x04
-#define DBG$C_SCHAR 0x06
-#define DBG$C_SSINT 0x07
-#define DBG$C_SLINT 0x08
-#define DBG$C_REAL4 0x0a
-#define DBG$C_REAL8 0x0b
-#define DBG$C_FUNCTION_ADDR 0x17
-#define DBG$C_ADVANCED_TYPE 0xa3
-/* These are the codes that are used to generate the definitions of struct
- * union and enum records
- */
-#define DBG$C_ENUM_ITEM 0xa4
-#define DBG$C_ENUM_START 0xa5
-#define DBG$C_ENUM_END 0xa6
-#define DBG$C_STRUCT_START 0xab
-#define DBG$C_STRUCT_ITEM 0xff
-#define DBG$C_STRUCT_END 0xac
-/* These are the codes that are used in the suffix records to determine the
- * actual data type
- */
-#define DBG$C_BASIC 0x01
-#define DBG$C_BASIC_ARRAY 0x02
-#define DBG$C_STRUCT 0x03
-#define DBG$C_POINTER 0x04
-#define DBG$C_VOID 0x05
-#define DBG$C_COMPLEX_ARRAY 0x07
-/* These codes are used in the generation of the symbol definition records
- */
-#define DBG$C_FUNCTION_PARAMETER 0xc9
-#define DBG$C_LOCAL_SYM 0xd9
diff --git a/gnu/usr.bin/as/obstack.c b/gnu/usr.bin/as/obstack.c
deleted file mode 100644
index c9cf561..0000000
--- a/gnu/usr.bin/as/obstack.c
+++ /dev/null
@@ -1,337 +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 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#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;
-}
-
-/* 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. */
- if (h->object_base == old_chunk->contents)
- {
- new_chunk->prev = old_chunk->prev;
- (*h->freefun) (old_chunk);
- }
-
- h->object_base = new_chunk->contents;
- h->next_free = h->object_base + obj_size;
-}
-
-/* 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;
- 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. */
-
-void
-#ifdef __STDC__
-#undef obstack_free
-obstack_free (struct obstack *h, POINTER obj)
-#else
-_obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-#endif
-{
- 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 (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 ();
-}
-
-/* Let same .o link with output of gcc and other compilers. */
-
-#ifdef __STDC__
-void
-_obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- obstack_free (h, obj);
-}
-#endif
-
-#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 fd779c4..0000000
--- a/gnu/usr.bin/as/obstack.h
+++ /dev/null
@@ -1,418 +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 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, 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' 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. */
-};
-
-/* 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, obstack_chunk_free)
-
-#define obstack_begin(h, size) \
- _obstack_begin ((h), (size), 0, \
- (void *(*) ()) obstack_chunk_alloc, 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__)
-
-/* 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) \
- ({ struct obstack *__o = (OBSTACK); \
- (unsigned) (__o->next_free - __o->object_base); })
-
-#define obstack_room(OBSTACK) \
- ({ 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) \
-({ 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) \
-({ 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) \
-({ 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) \
-({ 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) \
-({ 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) \
-({ 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) \
-({ struct obstack *__h = (OBSTACK); \
- obstack_blank (__h, (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy(OBSTACK,where,length) \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow (__h, (where), (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy0(OBSTACK,where,length) \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow0 (__h, (where), (length)); \
- obstack_finish (__h); })
-
-#define obstack_finish(OBSTACK) \
-({ struct obstack *__o = (OBSTACK); \
- void *value = (void *) __o->object_base; \
- __o->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\
- & ~ (__o->alignment_mask)); \
- ((__o->next_free - (char *)__o->chunk \
- > __o->chunk_limit - (char *)__o->chunk) \
- ? (__o->next_free = __o->chunk_limit) : 0); \
- __o->object_base = __o->next_free; \
- value; })
-
-#define obstack_free(OBSTACK, OBJ) \
-({ 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)->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/output-file.c b/gnu/usr.bin/as/output-file.c
deleted file mode 100644
index ff71f40..0000000
--- a/gnu/usr.bin/as/output-file.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* output-file.c - Deal with the output file
- 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. */
-
-/*
- * 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!
- */
-
-/* #include "style.h" */
-#include <stdio.h>
-
-void as_perror();
-
-static FILE *
-stdoutput;
-
-void
-output_file_create (name)
- char * name;
-{
- if(name[0]=='-' && name[1]=='\0')
- stdoutput=stdout;
- else if ( ! (stdoutput = fopen( name, "w" )) )
- {
- as_perror ("FATAL: Can't create %s", name);
- exit(42);
- }
-}
-
-
-
-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! */
-}
-
-void
-output_file_append (where, length, filename)
- char * where;
- long int 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");
- }
- }
-}
-
-/* end: output-file.c */
diff --git a/gnu/usr.bin/as/read.c b/gnu/usr.bin/as/read.c
deleted file mode 100644
index 8357107..0000000
--- a/gnu/usr.bin/as/read.c
+++ /dev/null
@@ -1,2188 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)read.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* read.c - read a source file -
- Copyright (C) 1986,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. */
-
-#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 <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "as.h"
-#include "read.h"
-#include "md.h"
-#include "hash.h"
-#include "obstack.h"
-#include "frags.h"
-#include "flonum.h"
-#include "struc-symbol.h"
-#include "expr.h"
-#include "symbols.h"
-
-#ifdef SPARC
-#include "sparc.h"
-#define OTHER_ALIGN
-#endif
-#ifdef I860
-#include "i860.h"
-#endif
-
-char * input_line_pointer; /* -> next char of source file to parse. */
-
-
-#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
-
-const 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:;<=>? */
- 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, 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: TRUE if this character ends a line.
- */
-#define _ (0)
-const char is_end_of_line [256] = {
- _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, _, /* @abcdefghijklmno */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, /* 0123456789:;<=>? */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ /* */
-};
-#undef _
-
- /* Functions private to this file. */
-void equals();
-void big_cons();
-void cons();
-static char* demand_copy_C_string();
-static char* demand_copy_string();
-void demand_empty_rest_of_line();
-void float_cons();
-long int get_absolute_expression();
-static char get_absolute_expression_and_terminator();
-static segT get_known_segmented_expression();
-void ignore_rest_of_line();
-static int is_it_end_of_statement();
-static void pobegin();
-static void pseudo_set();
-static void stab();
-static void stringer();
-
-extern char line_comment_chars[];
-
-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;
-
-#ifndef WORKING_DOT_WORD
-struct broken_word *broken_words;
-int new_broken_words = 0;
-#endif
-
-static void grow_bignum ();
-static int next_char_of_string ();
-
-void
-read_begin()
-{
- pobegin();
- obstack_begin( &notes, 5000 );
-#define BIGNUM_BEGIN_SIZE (16)
- bignum_low = xmalloc((long)BIGNUM_BEGIN_SIZE);
- bignum_limit = bignum_low + BIGNUM_BEGIN_SIZE;
-}
-
-/* set up pseudo-op tables */
-
-static struct hash_control *
-po_hash = NULL; /* use before set up: NULL-> address error */
-
-
-void s_abort(), s_align(), s_comm(), s_data();
-void s_desc(), s_even(), s_file(), s_fill();
-void s_globl(), s_lcomm(), s_line(), s_lsym();
-void s_org(), s_set(), s_space(), s_text();
-#ifdef VMS
-char const_flag = 0;
-void s_const();
-#endif
-
-#ifdef DONTDEF
-void s_gdbline(), s_gdblinetab();
-void s_gdbbeg(), s_gdbblock(), s_gdbend(), s_gdbsym();
-#endif
-
-void stringer();
-void cons();
-void float_cons();
-void big_cons();
-void stab();
-
-static const pseudo_typeS
-potable[] =
-{
- { "abort", s_abort, 0 },
- { "align", s_align, 0 },
- { "ascii", stringer, 0 },
- { "asciz", stringer, 1 },
- { "byte", cons, 1 },
- { "comm", s_comm, 0 },
-#ifdef VMS
- { "const", s_const, 0 },
-#endif
- { "data", s_data, 0 },
- { "desc", s_desc, 0 },
- { "double", float_cons, 'd' },
- { "file", s_file, 0 },
- { "fill", s_fill, 0 },
- { "float", float_cons, 'f' },
-#ifdef DONTDEF
- { "gdbbeg", s_gdbbeg, 0 },
- { "gdbblock", s_gdbblock, 0 },
- { "gdbend", s_gdbend, 0 },
- { "gdbsym", s_gdbsym, 0 },
- { "gdbline", s_gdbline, 0 },
- { "gdblinetab",s_gdblinetab, 0 },
-#endif
- { "globl", s_globl, 0 },
- { "int", cons, 4 },
- { "lcomm", s_lcomm, 0 },
- { "line", s_line, 0 },
- { "long", cons, 4 },
- { "lsym", s_lsym, 0 },
- { "octa", big_cons, 16 },
- { "org", s_org, 0 },
- { "quad", big_cons, 8 },
- { "set", s_set, 0 },
- { "short", cons, 2 },
- { "single", float_cons, 'f' },
- { "space", s_space, 0 },
- { "stabd", stab, 'd' },
- { "stabn", stab, 'n' },
- { "stabs", stab, 's' },
- { "text", s_text, 0 },
-#ifndef SPARC
- { "word", cons, 2 },
-#endif
- { NULL} /* end sentinel */
-};
-
-static void
-pobegin()
-{
- char * errtxt; /* error text */
- const pseudo_typeS * pop;
-
- po_hash = hash_new();
- errtxt = ""; /* OK so far */
- for (pop=potable; pop->poc_name && !*errtxt; pop++)
- {
- errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop);
- }
-
- for(pop=md_pseudo_table; pop->poc_name && !*errtxt; pop++)
- errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop);
-
- if (*errtxt)
- {
- as_fatal ("error constructing pseudo-op table");
- }
-} /* pobegin() */
-
-/* read_a_source_file()
- *
- * File has already been opened, and will be closed by our caller.
- *
- * We read the file, putting things into a web that
- * represents what we have been reading.
- */
-void
-read_a_source_file (buffer)
- char * buffer; /* 1st character of each buffer of lines is here. */
-{
- register char c;
- register char * s; /* string of symbol, '\0' appended */
- register int temp;
- /* register struct frag * fragP; JF unused */ /* a frag we just made */
- pseudo_typeS *pop;
-#ifdef DONTDEF
- void gdb_block_beg();
- void gdb_block_position();
- void gdb_block_end();
- void gdb_symbols_fixup();
-#endif
-
- subseg_new (SEG_TEXT, 0);
- while ( buffer_limit = input_scrub_next_buffer (&buffer) )
- { /* We have another line to parse. */
- know( buffer_limit [-1] == '\n' ); /* Must have a sentinel. */
- input_line_pointer = buffer;
- 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 ();
- }
- /*
- * 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 = * input_line_pointer ++;
- }
- know( c != ' ' ); /* No further leading whitespace. */
- /*
- * 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 */
- s = -- input_line_pointer;
- 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 == ':' )
- {
- if (flagseen['g'])
- /* set line number for function definition */
- funcstab(s);
- 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=='.' )
- {
- /*
- * 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 '.'.
- */
-
- 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);
-
- /* 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 seperates keyword from operands. */
- if ( c == ' ' || c == '\t' )
- { /* Skip seperator after keyword. */
- input_line_pointer ++;
- }
- /*
- * 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);
- }
- else
- { /* machine instruction */
- /* If source file debugging, emit a stab. */
- if (flagseen['g'])
- linestab();
-
- /* 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] )
- { /* empty statement */
- continue;
- }
-
- if ( isdigit(c) )
- { /* local label ("4:") */
- temp = c - '0';
-#ifdef SUN_ASM_SYNTAX
- 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;
- }
- if(c && index(line_comment_chars,c)) { /* Its a comment. Better say APP or NO_APP */
- char *ends;
- char *strstr();
- char *new_buf;
- char *new_tmp;
- int new_length;
- char *tmp_buf = 0;
- extern char *scrub_string,*scrub_last_string;
- int scrub_from_string();
- void scrub_to_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);
- bcopy(s,tmp_buf,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);
- bcopy(buffer,tmp_buf+tmp_len,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;
- }
-
- as_bad("Junk character %d.",c);
- ignore_rest_of_line();
- } /* while (input_line_pointer<buffer_limit )*/
- if(old_buffer) {
- bump_line_counters();
- if(old_input == 0)
- return;
- buffer=old_buffer;
- input_line_pointer=old_input;
- buffer_limit=old_limit;
- old_buffer = 0;
- goto contin;
- }
- } /* while (more bufrers to scan) */
-} /* read_a_source_file() */
-
-void
-s_abort()
-{
- as_fatal(".abort detected. Abandoning ship.");
-}
-
-#ifdef OTHER_ALIGN
-static void
-s_align()
-{
- register unsigned int temp;
- register long int temp_fill;
- unsigned int i;
-
- temp = get_absolute_expression ();
-#define MAX_ALIGNMENT (1 << 15)
- 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 = 0;
- }
- /* Only make a frag if we HAVE to. . . */
- if (temp && ! need_pass_2)
- frag_align (temp, (int)temp_fill);
-
- demand_empty_rest_of_line();
-}
-#else
-
-void
-s_align()
-{
- register int temp;
- register long int temp_fill;
-
- temp = get_absolute_expression ();
-#define MAX_ALIGNMENT (15)
- 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 = 0;
- /* Only make a frag if we HAVE to. . . */
- if ( temp && ! need_pass_2 )
- frag_align (temp, (int)temp_fill);
- demand_empty_rest_of_line();
-}
-#endif
-
-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");
- 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 ( (symbolP -> sy_type & N_TYPE) != N_UNDF ||
- symbolP -> sy_other != 0 || symbolP -> sy_desc != 0) {
- as_warn( "Ignoring attempt to re-define symbol");
- ignore_rest_of_line();
- return;
- }
- if (symbolP -> sy_value) {
- if (symbolP -> sy_value != temp)
- as_warn( "Length of .comm \"%s\" is already %d. Not changed to %d.",
- symbolP -> sy_name, symbolP -> sy_value, temp);
- } else {
- symbolP -> sy_value = temp;
- symbolP -> sy_type |= N_EXT;
- }
-#ifdef VMS
- if(!temp)
- symbolP->sy_other = const_flag;
-#endif
- know( symbolP -> sy_frag == &zero_address_frag );
- demand_empty_rest_of_line();
-}
-
-#ifdef VMS
-void
-s_const()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- subseg_new (SEG_DATA, (subsegT)temp);
- const_flag = 1;
- demand_empty_rest_of_line();
-}
-#endif
-
-void
-s_data()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- subseg_new (SEG_DATA, (subsegT)temp);
-#ifdef VMS
- const_flag = 0;
-#endif
- demand_empty_rest_of_line();
-}
-
-void
-s_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;
- symbolP = symbol_table_lookup (name);
- * 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;
- symbolP -> sy_desc = temp;
- }
- demand_empty_rest_of_line();
-}
-
-void
-s_file()
-{
- register char *s;
- int length;
-
- /* Some assemblers tolerate immediately following '"' */
- if ( s = demand_copy_string( & length ) ) {
- new_logical_line (s, -1);
- demand_empty_rest_of_line();
- }
-}
-
-void
-s_fill()
-{
- long int temp_repeat;
- long int temp_size;
- register long int temp_fill;
- char *p;
-
- if ( get_absolute_expression_and_terminator(& temp_repeat) != ',' ) {
- input_line_pointer --; /* Backup over what was not a ','. */
- as_warn("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_warn("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);
- bzero (p, (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();
-}
-
-#ifdef DONTDEF
-void
-s_gdbbeg()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- if (temp < 0)
- as_warn( "Block number <0. Ignored." );
- else if (flagseen ['G'])
- gdb_block_beg ( (long int) temp, frag_now, (long int)(obstack_next_free(& frags) - frag_now -> fr_literal));
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbblock()
-{
- register int position;
- int temp;
-
- if (get_absolute_expression_and_terminator (&temp) != ',') {
- as_warn( "expected comma before position in .gdbblock");
- --input_line_pointer;
- ignore_rest_of_line ();
- return;
- }
- position = get_absolute_expression ();
- if (flagseen ['G'])
- gdb_block_position ((long int) temp, (long int) position);
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbend()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- if (temp < 0)
- as_warn( "Block number <0. Ignored." );
- else if (flagseen ['G'])
- gdb_block_end ( (long int) temp, frag_now, (long int)(obstack_next_free(& frags) - frag_now -> fr_literal));
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbsym()
-{
- register char *name,
- *p;
- register char c;
- register symbolS * symbolP;
- register int temp;
-
- name = input_line_pointer;
- c = get_symbol_end();
- p = input_line_pointer;
- symbolP = symbol_find_or_make (name);
- *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("Bad GDB symbol file offset (%d.) <0! Ignored.", temp);
- ignore_rest_of_line();
- return;
- }
- if (flagseen ['G'])
- gdb_symbols_fixup (symbolP, (long int)temp);
- demand_empty_rest_of_line ();
-}
-
-void
-s_gdbline()
-{
- int file_number,
- lineno;
-
- if(get_absolute_expression_and_terminator(&file_number) != ',') {
- as_warn("expected comman after filenum in .gdbline");
- ignore_rest_of_line();
- return;
- }
- lineno=get_absolute_expression();
- if(flagseen['G'])
- gdb_line(file_number,lineno);
- demand_empty_rest_of_line();
-}
-
-
-void
-s_gdblinetab()
-{
- int file_number,
- offset;
-
- if(get_absolute_expression_and_terminator(&file_number) != ',') {
- as_warn("expected comman after filenum in .gdblinetab");
- ignore_rest_of_line();
- return;
- }
- offset=get_absolute_expression();
- if(flagseen['G'])
- gdb_line_tab(file_number,offset);
- demand_empty_rest_of_line();
-}
-#endif
-
-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();
- symbolP -> sy_type |= N_EXT;
- if(c==',') {
- input_line_pointer++;
- SKIP_WHITESPACE();
- if(*input_line_pointer=='\n')
- c='\n';
- }
- } while(c==',');
- demand_empty_rest_of_line();
-}
-
-void
-s_lcomm()
-{
- register char *name;
- register char c;
- register char *p;
- register int temp;
- register symbolS * symbolP;
-
- 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 ( symbolP -> sy_other == 0
- && symbolP -> sy_desc == 0
- && ( ( symbolP -> sy_type == N_BSS
- && symbolP -> sy_value == local_bss_counter)
- || ( (symbolP -> sy_type & N_TYPE) == N_UNDF
- && symbolP -> sy_value == 0))) {
- symbolP -> sy_value = local_bss_counter;
- symbolP -> sy_type = N_BSS;
- symbolP -> sy_frag = & bss_address_frag;
- local_bss_counter += temp;
- } else
- as_warn( "Ignoring attempt to re-define symbol from %d. to %d.",
- symbolP -> sy_value, local_bss_counter );
- demand_empty_rest_of_line();
-}
-
-void
-s_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();
-}
-
-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 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_warn("Expected comma after name \"%s\"", name);
- *p = c;
- ignore_rest_of_line();
- return;
- }
- input_line_pointer ++;
- segment = expression (& exp);
- if ( segment != SEG_ABSOLUTE && segment != SEG_DATA &&
- segment != SEG_TEXT && segment != SEG_BSS) {
- as_bad("Bad expression: %s", seg_name [(int)segment]);
- ignore_rest_of_line();
- return;
- }
- know( segment == SEG_ABSOLUTE || segment == SEG_DATA || segment == SEG_TEXT || segment == SEG_BSS );
- *p = 0;
- symbolP = symbol_new (name,(unsigned char)(seg_N_TYPE [(int) segment]),
- 0, 0, (valueT)(exp . X_add_number), & zero_address_frag);
- *p = c;
- demand_empty_rest_of_line();
-}
-
-void
-s_org()
-{
- register segT segment;
- expressionS exp;
- register long int 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==TRUE.
- */
- 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_warn("Illegal segment \"%s\". Segment \"%s\" assumed.",
- seg_name [(int) segment], seg_name [(int) 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();
-}
-
-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_warn("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_warn("Illegal segment \"%s\". Segment \"%s\" assumed.",
- seg_name [(int) segment], seg_name [(int) 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;
- }
- symbolP = symbol_find_or_make (name);
- *end_name = delim;
- pseudo_set (symbolP);
- demand_empty_rest_of_line ();
-}
-
-void
-s_space()
-{
- long int temp_repeat;
- register long int 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();
-}
-
-void
-s_text()
-{
- register int temp;
-
- temp = get_absolute_expression ();
- subseg_new (SEG_TEXT, (subsegT)temp);
- demand_empty_rest_of_line();
-}
-
-
-/*( 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])
- {
- as_warn("Rest of line ignored. 1st junk character valued %d (%c)."
- , * input_line_pointer, *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]] );
-}
-
-/*
- * 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
-stab (what)
-int what;
-{
- register symbolS * symbolP;
- register char * string;
- int saved_type;
- int length;
- int goof; /* TRUE if we have aborted. */
- long int longint;
-
-/*
- * Enter with input_line_pointer pointing past .stabX and any following
- * whitespace.
- */
- goof = FALSE; /* JF who forgot this?? */
- if (what == 's') {
- string = demand_copy_C_string (& length);
- SKIP_WHITESPACE();
- if (* input_line_pointer == ',')
- input_line_pointer ++;
- else {
- as_warn( "I need a comma after symbol's name" );
- goof = TRUE;
- }
- } else
- string = "";
-
-/*
- * Input_line_pointer->after ','. String -> symbol name.
- */
- if (! goof) {
- symbolP = symbol_new (string, 0,0,0,0,(struct frag *)0);
- switch (what) {
- case 'd':
- symbolP->sy_name = NULL; /* .stabd feature. */
- symbolP->sy_value = 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_type = saved_type = longint;
- else {
- as_warn( "I want a comma after the n_type expression" );
- goof = TRUE;
- input_line_pointer --; /* Backup over a non-',' char. */
- }
- }
- if (! goof) {
- if (get_absolute_expression_and_terminator (& longint) == ',')
- symbolP->sy_other = longint;
- else {
- as_warn( "I want a comma after the n_other expression" );
- goof = TRUE;
- input_line_pointer --; /* Backup over a non-',' char. */
- }
- }
- if (! goof) {
- symbolP->sy_desc = get_absolute_expression ();
- if (what == 's' || what == 'n') {
- if (* input_line_pointer != ',') {
- as_warn( "I want a comma after the n_desc expression" );
- goof = TRUE;
- } else {
- input_line_pointer ++;
- }
- }
- }
- if ((! goof) && (what=='s' || what=='n')) {
- pseudo_set (symbolP);
- symbolP->sy_type = saved_type;
- }
- if (goof)
- ignore_rest_of_line ();
- else
- demand_empty_rest_of_line ();
-}
-
-/*
- * 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 sy_type, sy_value, sy_frag;
- * May set need_pass_2 == TRUE.
- */
-static void
-pseudo_set (symbolP)
- symbolS * symbolP;
-{
- expressionS exp;
- register segT segment;
- int ext;
-
- know( symbolP ); /* NULL pointer is logic error. */
- ext=(symbolP->sy_type&N_EXT);
- if ((segment = expression( & exp )) == SEG_NONE)
- {
- as_warn( "Missing expression: absolute 0 assumed" );
- exp . X_seg = SEG_ABSOLUTE;
- exp . X_add_number = 0;
- }
- switch (segment)
- {
- case SEG_BIG:
- as_warn( "%s number illegal. Absolute 0 assumed.",
- exp . X_add_number > 0 ? "Bignum" : "Floating-Point" );
- symbolP -> sy_type = N_ABS | ext;
- symbolP -> sy_value = 0;
- symbolP -> sy_frag = & zero_address_frag;
- break;
-
- case SEG_NONE:
- as_warn("No expression: Using absolute 0");
- symbolP -> sy_type = N_ABS | ext;
- symbolP -> sy_value = 0;
- symbolP -> sy_frag = & zero_address_frag;
- break;
-
- case SEG_DIFFERENCE:
- if (exp.X_add_symbol && exp.X_subtract_symbol
- && (exp.X_add_symbol->sy_type & N_TYPE)
- == (exp.X_subtract_symbol->sy_type & N_TYPE)) {
- 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.",exp.X_add_symbol->sy_name, exp.X_subtract_symbol->sy_name);
- need_pass_2++;
- }
- exp.X_add_number+=exp.X_add_symbol->sy_value - exp.X_subtract_symbol->sy_value;
- } else
- as_warn( "Complex expression. Absolute segment assumed." );
- case SEG_ABSOLUTE:
- symbolP -> sy_type = N_ABS | ext;
- symbolP -> sy_value = exp . X_add_number;
- symbolP -> sy_frag = & zero_address_frag;
- break;
-
- case SEG_DATA:
- case SEG_TEXT:
- case SEG_BSS:
- symbolP -> sy_type = seg_N_TYPE [(int) segment] | ext;
- symbolP -> sy_value= exp . X_add_number + exp . X_add_symbol -> sy_value;
- symbolP -> sy_frag = exp . X_add_symbol -> sy_frag;
- break;
-
- case SEG_PASS1: /* Not an error. Just try another pass. */
- symbolP->sy_forward=exp.X_add_symbol;
- as_warn("Unknown expression");
- know( need_pass_2 == TRUE );
- break;
-
- case SEG_UNKNOWN:
- symbolP->sy_forward=exp.X_add_symbol;
- /* as_warn("unknown symbol"); */
- /* need_pass_2 = TRUE; */
- break;
-
- default:
- BAD_CASE( segment );
- break;
- }
-}
-
-/*
- * stabs(file), stabf(func) and stabd(line) -- for the purpose of
- * source file debugging of assembly files, generate file,
- * function and line number stabs, respectively.
- * These functions have corresponding functions named
- * filestab(), funcstab() and linestab() in input-scrub.c,
- * where logical files and logical line numbers are handled.
- */
-
-#include <stab.h>
-
-stabs(file)
- char *file;
-{
- /* .stabs "file",100,0,0,. */
- (void) symbol_new(file,
- N_SO,
- 0,
- 0,
- obstack_next_free(& frags) - frag_now->fr_literal,
- frag_now);
-}
-
-stabf(func)
- char *func;
-{
- symbolS *symbolP;
- static int void_undefined = 1;
-
- /* crudely filter uninteresting labels: require an initial '_' */
- if (*func++ != '_')
- return;
-
- /* assembly functions are assumed to have void type */
- if (void_undefined)
- {
- /* .stabs "void:t15=15",128,0,0,0 */
- (void) symbol_new("void:t1=1",
- N_LSYM,
- 0,
- 0,
- 0,
- &zero_address_frag);
- void_undefined = 0;
- }
-
- /* .stabs "func:F1",36,0,0,. */
- symbolP = symbol_new((char *) 0,
- N_FUN,
- 0,
- 0,
- obstack_next_free(& frags) - frag_now->fr_literal,
- frag_now);
- obstack_grow(&notes, func, strlen(func));
- obstack_1grow(&notes, ':');
- obstack_1grow(&notes, 'F');
- obstack_1grow(&notes, '1');
- obstack_1grow(&notes, '\0');
- symbolP->sy_name = obstack_finish(&notes);
-}
-
-stabd(line)
- unsigned line;
-{
- /* .stabd 68,0,line */
- (void) symbol_new((char *)0,
- N_SLINE,
- 0,
- line,
- obstack_next_free(& frags) - frag_now->fr_literal,
- frag_now);
-}
-
-/*
- * cons()
- *
- * CONStruct more frag of .bytes, or .words etc.
- * Should need_pass_2 be TRUE 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.
- */
-void
-cons(nbytes) /* worker to do .byte etc statements */
- /* clobbers input_line_pointer, checks */
- /* end-of-line. */
- register int nbytes; /* 1=.byte, 2=.word, 4=.long */
-{
- register char c;
- register long int mask; /* High-order bits we will left-truncate, */
- /* but includes sign bit also. */
- register long int get; /* what we get */
- register long int use; /* get after truncation. */
- register long int unmask; /* what bits we will store */
- register char * p;
- register segT segment;
- expressionS exp;
-#ifdef NS32K
- void fix_new_ns32k();
-#else
- void fix_new();
-#endif
-
- /*
- * 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 int))
- mask = 0;
- else
- mask = ~0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */
- 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 = ','; /* Do loop. */
- while ( c == ',' )
- {
- segment = expression( &exp ); /* At least scan over the expression. */
- 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_warn( "Subtracting symbol \"%s\"(segment\"%s\") is too hard. Absolute segment assumed.",
- exp . X_subtract_symbol -> sy_name,
- seg_name [(int) N_TYPE_seg [exp . X_subtract_symbol -> sy_type & N_TYPE]]);
- segment = SEG_ABSOLUTE;
- /* Leave exp . X_add_number alone. */
- }
- p = frag_more (nbytes);
- switch (segment)
- {
- case SEG_BIG:
- as_warn( "%s number illegal. Absolute 0 assumed.",
- exp . X_add_number > 0 ? "Bignum" : "Floating-Point");
- md_number_to_chars (p, (long)0, nbytes);
- break;
-
- case SEG_NONE:
- 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 x%x truncated to x%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
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_TEXT:
- case SEG_DATA:
-#if defined(SPARC) || defined(I860)
- 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
-#ifdef 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);
-#endif
-#if !defined(SPARC) && !defined(NS32K) && !defined(I860)
- fix_new (frag_now, p - frag_now -> fr_literal, nbytes,
- exp . X_add_symbol, exp . X_subtract_symbol,
- exp . X_add_number, 0);
-#endif
- break;
-
- default:
- BAD_CASE( segment );
- 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 == TRUE, 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"...
- */
-void
-big_cons(nbytes) /* worker to do .quad etc statements */
- /* clobbers input_line_pointer, checks */
- /* end-of-line. */
- register int nbytes; /* 8=.quad 16=.octa ... */
-{
- register char c; /* input_line_pointer -> c. */
- register int radix;
- register long int 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 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_warn( "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 int leading_zeroes;
-
- for(leading_zeroes = nbytes - length;
- leading_zeroes;
- leading_zeroes --)
- {
- grow_bignum();
- * bignum_high = 0;
- }
- }
- if (! need_pass_2)
- {
- p = frag_more (nbytes);
- bcopy (bignum_low, p, (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() */
-
-static void
-grow_bignum() /* Extend bignum by 1 char. */
-{
- register long int 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 == TRUE, 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 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_warn( "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);
- bcopy (temp, p, 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()
- *
- * We read 0 or more ',' seperated, double-quoted strings.
- *
- * Caller should have checked need_pass_2 is FALSE because we don't check it.
- */
-static void
-stringer(append_zero) /* Worker to do .ascii etc statements. */
- /* Checks end-of-line. */
- register int append_zero; /* 0: don't append '\0', else 1 */
-{
- /* register char * p; JF unused */
- /* register int length; JF unused */ /* Length of string we read, excluding */
- /* trailing '\0' implied by closing quote. */
- /* register char * where; JF unused */
- /* register fragS * fragP; JF unused */
- register 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. */
- }
- for ( ; c == ','; c = *input_line_pointer ++)
- {
- SKIP_WHITESPACE();
- if (* input_line_pointer == '\"')
- {
- ++ input_line_pointer; /* -> 1st char of string. */
- while ( (c = next_char_of_string()) >= 0)
- {
- FRAG_APPEND_1_CHAR( c );
- }
- if (append_zero)
- {
- FRAG_APPEND_1_CHAR( 0 );
- }
- know( input_line_pointer [-1] == '\"' );
- }
- else
- {
- as_warn( "Expected \"-ed string" );
- }
- SKIP_WHITESPACE();
- }
- -- input_line_pointer;
- demand_empty_rest_of_line();
-} /* stringer() */
-
-static int
-next_char_of_string ()
-{
- register int c;
-
- c = * input_line_pointer ++;
- switch (c)
- {
- case '\"':
- c = -1;
- 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;
-
- 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 int number;
-
- for (number = 0; isdigit(c); c = * input_line_pointer ++)
- {
- number = number * 8 + c - '0';
- }
- c = number;
- }
- -- input_line_pointer;
- break;
-
- case '\n':
-/* as_fatal( "Unterminated string - use app!" ); */
-/* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
- c = '\n';
- break;
-
- default:
- as_warn( "Bad escaped character in string, '?' assumed" );
- c = '?';
- break;
- }
- break;
-
- default:
- break;
- }
- return (c);
-}
-
-static segT
-get_segmented_expression ( expP )
- register expressionS * expP;
-{
- register segT retval;
-
- if ( (retval = expression( expP )) == SEG_PASS1 || retval == SEG_NONE || retval == SEG_BIG )
- {
- as_warn("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 ? expP -> X_add_symbol -> sy_name : "";
- name2 = expP -> X_subtract_symbol ? expP -> X_subtract_symbol -> sy_name : "";
- 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;
- }
- know( retval == SEG_ABSOLUTE || retval == SEG_DATA || retval == SEG_TEXT || retval == SEG_BSS || retval == SEG_DIFFERENCE );
- return (retval);
-} /* get_known_segmented_expression() */
-
-
-
-/* static */ long int /* 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_NONE )
- {
- as_warn( "Bad Absolute Expression, absolute 0 assumed.");
- }
- exp . X_add_number = 0;
- }
- return (exp . X_add_number);
-}
-
-static char /* return terminator */
-get_absolute_expression_and_terminator( val_pointer)
- long int * 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.
- */
-static char *
-demand_copy_C_string (len_pointer)
- int * len_pointer;
-{
- register char * s;
-
- if (s = demand_copy_string (len_pointer))
- {
- register int len;
-
- for (len = * len_pointer;
- len > 0;
- len--)
- {
- if (* s == 0)
- {
- s = 0;
- len = 1;
- * len_pointer = 0;
- as_warn( "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 int c;
- register int len;
- char * retval;
-
- len = 0;
- SKIP_WHITESPACE();
- if (* input_line_pointer == '\"')
- {
- input_line_pointer ++; /* Skip opening quote. */
- while ( (c = next_char_of_string()) >= 0 ) {
- 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);
-}
-
-/*
- * is_it_end_of_statement()
- *
- * In: Input_line_pointer -> next character.
- *
- * Do: Skip input_line_pointer over all whitespace.
- *
- * Out: TRUE if input_line_pointer -> end-of-line.
- */
-static int
-is_it_end_of_statement()
-{
- SKIP_WHITESPACE();
- return (is_end_of_line [* input_line_pointer]);
-}
-
-void
-equals(sym_name)
-char *sym_name;
-{
- register struct symbol * 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.",
- seg_name [(int) segment], seg_name [(int) 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);
- }
-}
-
-/* end: read.c */
diff --git a/gnu/usr.bin/as/read.h b/gnu/usr.bin/as/read.h
deleted file mode 100644
index 6b46e8f..0000000
--- a/gnu/usr.bin/as/read.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* read.h - of read.c
- Copyright (C) 1986 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. */
-
-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() ASSERT( * 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 )
-
-extern const char lex_type[];
-
-void read_begin();
-void read_end();
-void read_a_source_file();
-
-/* end: 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 11eab6b..0000000
--- a/gnu/usr.bin/as/struc-symbol.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* struct_symbol.h - Internal symbol structure
- 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. */
-
-#ifndef VMS
-#include "a.out.gnu.h" /* Needed to define struct nlist. Sigh. */
-#else
-#include "a_out.h"
-#endif
-
-struct symbol /* our version of an nlist node */
-{
- struct nlist sy_nlist; /* what we write in .o file (if permitted) */
- long unsigned 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 int sy_number; /* 24 bit symbol number. */
- /* Symbol numbers start at 0 and are */
- /* unsigned. */
- struct symbol * sy_next; /* forward chain, or NULL */
- struct frag * sy_frag; /* NULL or -> frag this symbol attaches to. */
- struct symbol *sy_forward; /* value is really that of this other symbol */
-};
-
-typedef struct symbol symbolS;
-
-#define sy_name sy_nlist .n_un. n_name
- /* Name field always points to a string. */
- /* 0 means .stabd-like anonymous symbol. */
-#define sy_type sy_nlist. n_type
-#define sy_other sy_nlist. n_other
-#define sy_desc sy_nlist. n_desc
-#define sy_value sy_nlist. n_value
- /* Value of symbol is this value + object */
- /* file address of sy_frag. */
-
-typedef unsigned valueT; /* The type of n_value. Helps casting. */
-
-/* end: struct_symbol.h */
-#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
diff --git a/gnu/usr.bin/as/subsegs.c b/gnu/usr.bin/as/subsegs.c
deleted file mode 100644
index c9eea3d..0000000
--- a/gnu/usr.bin/as/subsegs.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/* subsegs.c - subsegments -
- 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. */
-
-/*
- * Segments & sub-segments.
- */
-
-#include "as.h"
-#include "subsegs.h"
-#include "obstack.h"
-#include "frags.h"
-#include "struc-symbol.h"
-#include "write.h"
-
-frchainS* frchain_root,
- * frchain_now, /* Commented in "subsegs.h". */
- * data0_frchainP;
-
-
-const int /* in: segT out: N_TYPE bits */
-seg_N_TYPE[] = {
- N_ABS,
- N_TEXT,
- N_DATA,
- N_BSS,
- N_UNDF,
- N_UNDF,
- N_UNDF,
- N_UNDF,
- N_UNDF,
- N_UNDF
-};
-
-
-char * const /* in: segT out: char* */
-seg_name[] = {
- "absolute",
- "text",
- "data",
- "bss",
- "unknown",
- "absent",
- "pass1",
- "ASSEMBLER-INTERNAL-LOGIC-ERROR!",
- "bignum/flonum",
- "difference",
- ""
- }; /* Used by error reporters, dumpers etc. */
-
-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_GOOF, SEG_GOOF
-};
-
-void
-subsegs_begin()
-{
- /* Check table(s) seg_name[], seg_N_TYPE[] is in correct order */
- know( SEG_ABSOLUTE ==0 );
- know( SEG_TEXT ==1 );
- know( SEG_DATA ==2 );
- know( SEG_BSS ==3 );
- know( SEG_UNKNOWN ==4 );
- know( SEG_NONE ==5 );
- know( SEG_PASS1 ==6 );
- know( SEG_GOOF ==7 );
- know( SEG_BIG ==8 );
- know( SEG_DIFFERENCE ==9 );
- know( SEG_MAXIMUM_ORDINAL == SEG_DIFFERENCE );
- know( seg_name [(int) SEG_MAXIMUM_ORDINAL + 1] [0] == 0 );
-
- 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);
- /* obstack_1blank( &frags, SIZEOF_STRUCT_FRAG, & frag_now ); */
- /* 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. */
- subseg_new (SEG_DATA, 0); /* .data 0 */
- data0_frchainP = frchain_now;
-}
-
-/*
- * 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;
- if (seg == SEG_DATA)
- {
- seg_fix_rootP = & data_fix_root;
- }
- else
- {
- know (seg == SEG_TEXT);
- seg_fix_rootP = & text_fix_root;
- }
-}
-
-/*
- * 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 == SEG_DATA || seg == SEG_TEXT );
-
- 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));
- /* obstack_1blank( &frags, sizeof(frchainS), &newP); */
- /* 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() */
-
-/* end: subsegs.c */
diff --git a/gnu/usr.bin/as/subsegs.h b/gnu/usr.bin/as/subsegs.h
deleted file mode 100644
index b8dbaf7..0000000
--- a/gnu/usr.bin/as/subsegs.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* subsegs.h -> subsegs.c
- 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. */
-
-/*
- * 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. */
-
-extern frchainS * data0_frchainP;
- /* Sentinel for frchain crawling. */
- /* Points to the 1st data-segment frchain. */
- /* (Which is pointed to by the last text- */
- /* segment frchain.) */
-
-/* end: subsegs.h */
diff --git a/gnu/usr.bin/as/symbols.c b/gnu/usr.bin/as/symbols.c
deleted file mode 100644
index ce7197a..0000000
--- a/gnu/usr.bin/as/symbols.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/* symbols.c -symbol table-
- 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. */
-
-
-#include "as.h"
-#include "hash.h"
-#include "obstack.h" /* For "symbols.h" */
-#include "struc-symbol.h"
-#include "symbols.h"
-#include "frags.h"
-
-#ifndef WORKING_DOT_WORD
-extern int new_broken_words;
-#endif
-#ifdef VMS
-extern char const_flag;
-#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;
-struct obstack notes;
-
-
-
-symbolS * symbol_find(); /* Keep C compiler happy. */
-
-/*
- * 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 SUN_ASM_SYNTAX
-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();
- bzero ((char *)(& abs_symbol), sizeof(abs_symbol));
- abs_symbol . sy_type = N_ABS; /* Can't initialise a union. Sigh. */
- bzero ((char *)(local_label_counter), 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 ++ = 'L';
- * p ++ = n + '0'; /* Make into ASCII */
- * p ++ = 1; /* ^A */
- 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 )
- {
- }
- /* The label, as a '\0' ended string, starts at symbol_name_build. */
- return (symbol_name_build);
-}
-
-
-void
-local_colon (n)
- int n; /* just saw "n:" */
-{
- local_label_counter [n] ++;
-#ifdef SUN_ASM_SYNTAX
- 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.
- */
-
-symbolS *
-symbol_new (name, type, other, desc, value, frag)
- char * name; /* We copy this: OK to alter your copy. */
- unsigned char type; /* As in <a.out.h>. */
- char other; /* As in <a.out.h>. */
- short int desc; /* As in <a.out.h>. */
- valueT value; /* As in <a.out.h>, often an address. */
- /* Often used as offset from frag address. */
- struct frag * frag; /* For sy_frag. */
-{
- register symbolS * symbolP;
- register char * preserved_copy_of_name;
- register unsigned int name_length;
- char * p;
-
- name_length = strlen(name) + 1;
- obstack_grow(&notes,name,name_length);
- p=obstack_finish(&notes);
- /* obstack_1done( &notes, name, name_length, &p ); */
- preserved_copy_of_name = p;
- p=obstack_alloc(&notes,sizeof(struct symbol));
- /* obstack_1blank( &notes, sizeof(struct symbol), &p ); */
- symbolP = (symbolS *) p;
- symbolP -> sy_name = preserved_copy_of_name;
- symbolP -> sy_type = type;
- symbolP -> sy_other = other;
- symbolP -> sy_desc = desc;
- symbolP -> sy_value = value;
- symbolP -> sy_frag = frag;
- symbolP -> sy_next = NULL; /* End of chain. */
- symbolP -> sy_forward = NULL; /* JF */
-#ifdef SUSPECT
- symbolP -> sy_name_offset = ~ 0; /* Impossible offset catches errors. */
- symbolP -> sy_number = ~ 0; /* Ditto. */
-#endif
- /*
- * Link to end of symbol chain.
- */
- if (symbol_lastP)
- {
- symbol_lastP -> sy_next = symbolP;
- }
- else
- {
- symbol_rootP = symbolP;
- }
- symbol_lastP = symbolP;
-
- return (symbolP);
-}
-
-/*
- * 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 struct symbol * symbolP; /* symbol we are working with */
-
-#ifdef SUN_ASM_SYNTAX
- /* Sun local labes go out of scope whenever a non-local symbol is
- defined. */
-
- if(*sym_name !='L')
- bzero((void *)local_label_defined,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 md_short_jump_size;
- extern 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,(long int)0,(char *)0);
-
- /* 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_table_lookup( sym_name ))
- {
-#ifdef 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 ((seg_N_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 ((symbolP -> sy_type == (N_UNDF | N_EXT)) &&
- (symbolP->sy_value == 0)) {
- symbolP -> sy_frag = frag_now;
- symbolP -> sy_other = const_flag;
- symbolP -> sy_value = obstack_next_free(& frags) - frag_now -> fr_literal;
- symbolP -> sy_type |= seg_N_TYPE [(int) now_seg]; /* keep N_EXT bit */
- return;
- }
-#endif /* VMS */
- /*
- * Now check for undefined symbols
- */
- if ((symbolP -> sy_type & N_TYPE) == N_UNDF)
- {
- if( symbolP -> sy_other == 0
- && symbolP -> sy_desc == 0
- && symbolP -> sy_value == 0)
- {
- symbolP -> sy_frag = frag_now;
-#ifdef VMS
- symbolP -> sy_other = const_flag;
-#endif
- symbolP -> sy_value = obstack_next_free(& frags) - frag_now -> fr_literal;
- know( N_UNDF == 0 );
- symbolP -> sy_type |= seg_N_TYPE [(int) now_seg]; /* keep N_EXT bit */
- }
- else
- {
-#ifdef VMS
- /*
- * 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
- */
- char New_Type = seg_N_TYPE [(int) now_seg];
- if (((symbolP->sy_type == (N_UNDF | N_EXT)) ||
- (symbolP->sy_type == N_BSS)) &&
- (((New_Type & ~N_EXT) == N_DATA) ||
- (New_Type == symbolP->sy_type))) {
- /*
- * Select which of the 2 cases this is
- */
- if (New_Type == symbolP->sy_type) {
- /*
- * If the new size is larger we just
- * change its value. If the new size
- * is smaller, we ignore this symbol
- */
- if (symbolP->sy_value <
- (obstack_next_free(& frags) -
- frag_now -> fr_literal)) {
- symbolP -> sy_value =
- obstack_next_free(& frags) -
- frag_now -> fr_literal;
- }
- } else {
- /*
- * It is a .comm/.lcomm being converted
- * to initialized data.
- */
- symbolP -> sy_frag = frag_now;
- symbolP -> sy_other = const_flag;
- symbolP -> sy_value = obstack_next_free(& frags) - frag_now -> fr_literal;
- symbolP -> sy_type |= seg_N_TYPE [(int) now_seg]; /* keep N_EXT bit */
- }
- } else {
-#endif /* VMS */
- as_fatal( "Symbol \"%s\" is already defined as \"%s\"/%d.%d.%d.",
- sym_name,
- seg_name [(int) N_TYPE_seg [symbolP -> sy_type & N_TYPE]],
- symbolP -> sy_other, symbolP -> sy_desc,
- symbolP -> sy_value);
-#ifdef VMS
- }
-#endif /* VMS */
- }
- }
- else
- {
- as_fatal("Symbol %s already defined.",sym_name);
- }
- }
- else
- {
- symbolP = symbol_new (sym_name,
- (unsigned char)(seg_N_TYPE [(int) now_seg]),
-#ifdef VMS
- const_flag,
-#else
- 0,
-#endif
- 0,
- (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
- frag_now);
- symbol_table_insert (symbolP);
- }
-}
-
-
-/*
- * symbol_table_insert()
- *
- * Die if we can't insert the symbol.
- *
- */
-
-void
-symbol_table_insert (symbolP)
- struct symbol * symbolP;
-{
- register char * error_string;
-
- know( symbolP );
- know( symbolP -> sy_name );
- if ( * (error_string = hash_jam (sy_hash, symbolP -> sy_name, (char *)symbolP)))
- {
- as_fatal( "Inserting \"%s\" into symbol table failed: %s",
- symbolP -> sy_name, error_string);
- }
-}
-
-/*
- * 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_table_lookup (name);
- if (symbolP == NULL)
- {
- symbolP = symbol_new (name, N_UNDF, 0, 0, 0, & zero_address_frag);
- symbol_table_insert (symbolP);
- }
- return (symbolP);
-}
-
-/*
- * 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;
-{
- return ( (symbolS *) hash_find( sy_hash, name ));
-}
-
-
-/* end: symbols.c */
diff --git a/gnu/usr.bin/as/symbols.h b/gnu/usr.bin/as/symbols.h
deleted file mode 100644
index 5a52790..0000000
--- a/gnu/usr.bin/as/symbols.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* symbols.h -
- 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. */
-
-extern struct obstack notes; /* eg FixS live here. */
-
-#define symbol_table_lookup(name) ((symbolS *)(symbol_find (name)))
-
-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;
-
-symbolS * symbol_find();
-void symbol_begin();
-char * local_label_name();
-void local_colon();
-symbolS * symbol_new();
-void colon();
-void symbol_table_insert();
-symbolS * symbol_find_or_make();
-
-/* end: symbols.h */
diff --git a/gnu/usr.bin/as/version.c b/gnu/usr.bin/as/version.c
deleted file mode 100644
index f94d3f4..0000000
--- a/gnu/usr.bin/as/version.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#if defined(__STDC__) || defined(const)
-const
-#endif
-char version_string[] = "GNU assembler version 1.38\n";
-
-/* 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.
-*/
-
-#ifdef VMS
-dummy3()
-{
-}
-#endif
diff --git a/gnu/usr.bin/as/write.c b/gnu/usr.bin/as/write.c
deleted file mode 100644
index a850555..0000000
--- a/gnu/usr.bin/as/write.c
+++ /dev/null
@@ -1,1259 +0,0 @@
-/* write.c - emit .o file - Copyright(C)1986 Free Software Foundation, Inc.
- Copyright (C) 1986,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. */
-
-/*
-
- Umm, with real good luck, this thing should be set up to do byteordering
- correctly, but I may have managed to miss a place or two. Treat a.out
- very carefully until you're SURE that it works. . .
-
- In order to cross-assemble the target machine must have an a.out header
- similar to the one in a.out.h on THIS machine. Byteorder doesn't matter;
- we take special care of it, but the numbers must be the same SIZE (# of
- bytes) and in the same PLACE. If this is not true, you will have some
- trouble.
- */
-
-#include "as.h"
-#include "md.h"
-#include "subsegs.h"
-#include "obstack.h"
-#include "struc-symbol.h"
-#include "write.h"
-#include "symbols.h"
-
-#ifdef SPARC
-#include "sparc.h"
-#endif
-#ifdef I860
-#include "i860.h"
-#endif
-
-void append();
-
-#ifdef hpux
-#define EXEC_MACHINE_TYPE HP9000S200_ID
-#endif
-
-#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 */
-
-/*
- * 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
- };
-
-
-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. */
-
-static struct exec the_exec;
-
-static long int string_byte_count;
-
-static char * the_object_file;
-
-#if !defined(SPARC) && !defined(I860)
-static
-#endif
-char * next_object_file_charP; /* Tracks object file bytes. */
-
-static long int size_of_the_object_file; /* # bytes in object file. */
-
-/* static long int length; JF unused */ /* String length, including trailing '\0'. */
-
-static void relax_segment();
-void emit_segment();
-static relax_addressT relax_align();
-static long int fixup_segment();
-#if !defined(SPARC) && !defined(I860)
-static void emit_relocations();
-#endif
- /*
- * fix_new()
- *
- * Create a fixS in obstack 'notes'.
- */
-void
-#if defined(SPARC) || defined(I860)
-fix_new (frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type)
-#else
-fix_new (frag, where, size, add_symbol, sub_symbol, offset, pcrel)
-#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. */
- long int offset; /* X_add_number. */
- int pcrel; /* TRUE if PC-relative relocation. */
-#if defined(SPARC) || defined(I860)
- int r_type;
-#endif
-{
- register 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;
- fixP -> fx_offset = offset;
- fixP -> fx_pcrel = pcrel;
- fixP -> fx_next = * seg_fix_rootP;
-
- /* 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;
-
-#if defined(SPARC) || defined(I860)
- fixP->fx_r_type = r_type;
-#endif
-
- * seg_fix_rootP = fixP;
-}
-
-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;
- register symbolS * symbolP;
- register symbolS ** symbolPP;
- /* register fixS * fixP; JF unused */
- unsigned
- text_siz,
- data_siz,
- syms_siz,
- tr_siz,
- dr_siz;
- void output_file_create();
- void output_file_append();
- void output_file_close();
-#ifdef DONTDEF
- void gdb_emit();
- void gdb_end();
-#endif
- extern long omagic; /* JF magic # to write out. Is different for
- Suns and Vaxen and other boxes */
-
-#ifdef 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 /* 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.
- */
-#define SUB_SEGMENT_ALIGN (2)
- for ( frchainP=frchain_root; frchainP; frchainP=frchainP->frch_next )
- {
-#ifdef 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 /* VMS */
- subseg_new (frchainP -> frch_seg, frchainP -> frch_subseg);
- frag_align (SUB_SEGMENT_ALIGN, 0);
- /* 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. */
- }
-
- /*
- * 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;
- }
- }
- } /* for(each struct frchain) */
-
- /*
- * 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 );
- text_siz=text_last_frag->fr_address;
-#ifdef SPARC
- text_siz= (text_siz+7)&(~7);
- text_last_frag->fr_address=text_siz;
-#endif
- md_number_to_chars((char *)&the_exec.a_text,text_siz, sizeof(the_exec.a_text));
- /* the_exec . a_text = text_last_frag -> fr_address; */
-
- /*
- * 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 );
- data_siz=data_last_frag->fr_address;
-#ifdef SPARC
- data_siz += (8 - (data_siz % 8)) % 8;
- data_last_frag->fr_address = data_siz;
-#endif
- md_number_to_chars((char *)&the_exec.a_data,data_siz,sizeof(the_exec.a_data));
- /* the_exec . a_data = data_last_frag -> fr_address; */
- slide = text_siz; /* Address in file of the data segment. */
- for (fragP = data_frag_root;
- fragP;
- fragP = fragP -> fr_next)
- {
- fragP -> fr_address += slide;
- }
- know( text_last_frag );
- text_last_frag -> fr_next = data_frag_root;
- }
- else {
- md_number_to_chars((char *)&the_exec.a_data,0,sizeof(the_exec.a_data));
- data_siz = 0;
- }
-
- bss_address_frag . fr_address = text_siz + data_siz;
-#ifdef SPARC
- local_bss_counter=(local_bss_counter+7)&(~7);
-#endif
- md_number_to_chars((char *)&the_exec.a_bss,local_bss_counter,sizeof(the_exec.a_bss));
-
-
- /*
- *
- * 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.
- *
- * Count the (length of the nlists of the) (remaining) symbols.
- * Assign a symbol number to each symbol.
- * Count the number of string-table chars we will emit.
- *
- */
- know( zero_address_frag . fr_address == 0 );
- string_byte_count = sizeof( string_byte_count );
-
- /* JF deal with forward references first. . . */
- for(symbolP=symbol_rootP;symbolP;symbolP=symbolP->sy_next) {
- if(symbolP->sy_forward) {
- symbolP->sy_value+=symbolP->sy_forward->sy_value+symbolP->sy_forward->sy_frag->fr_address;
- symbolP->sy_forward=0;
- }
- }
- symbolPP = & symbol_rootP; /* -> last symbol chain link. */
- {
- register long int symbol_number;
-
- symbol_number = 0;
- while (symbolP = * symbolPP)
- {
- name = symbolP -> sy_name;
- if(flagseen['R'] && (symbolP->sy_nlist.n_type&N_DATA)) {
- symbolP->sy_nlist.n_type&= ~N_DATA;
- symbolP->sy_nlist.n_type|= N_TEXT;
- }
- /* if(symbolP->sy_forward) {
- symbolP->sy_value += symbolP->sy_forward->sy_value + symbolP->sy_forward->sy_frag->fr_address;
- } */
-
- symbolP -> sy_value += symbolP -> sy_frag -> fr_address;
- /* JF the 128 bit is a hack so stabs like
- "LET_STMT:23. . ." don't go away */
- /* CPH: 128 bit hack is moby loser. N_SO for file "Lower.c"
- fell through the cracks. I think that N_STAB should be
- used instead of 128. */
- /* JF the \001 bit is to make sure that local labels
- ( 1: - 9: don't make it into the symtable either */
-#ifndef VMS /* Under VMS we need to keep local symbols */
- if ( !name || (symbolP->sy_nlist.n_type&N_STAB)
- || (name[2]!='\001' && (flagseen ['L'] || ! LOCAL_LABEL(name) )))
-#endif /* not VMS */
- {
- symbolP -> sy_number = symbol_number ++;
-#ifndef VMS
- if (name)
- { /* Ordinary case. */
- symbolP -> sy_name_offset = string_byte_count;
- string_byte_count += strlen (symbolP -> sy_name) + 1;
- }
- else /* .Stabd case. */
-#endif /* not VMS */
- symbolP -> sy_name_offset = 0;
- symbolPP = & (symbolP -> sy_next);
- }
-#ifndef VMS
- else
- * symbolPP = symbolP -> sy_next;
-#endif /* not VMS */
- } /* for each symbol */
-
- syms_siz = sizeof( struct nlist) * symbol_number;
- md_number_to_chars((char *)&the_exec.a_syms,syms_siz,sizeof(the_exec.a_syms));
- /* the_exec . a_syms = sizeof( struct nlist) * symbol_number; */
- }
-
- /*
- * 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 );
- 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 (fragP);
- /*
- * 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;
- extern md_short_jump_size;
- extern md_long_jump_size;
-
- 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) */
- } /* 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) {
-#if defined(SPARC) || defined(I860)
- fix_new( lie->frag, lie->word_goes_here - lie->frag->fr_literal,
- 2, lie->add,
- lie->sub, lie->addnum,
- 0, NO_RELOC);
-#endif
-#ifdef 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);
-#endif
-#if !defined(SPARC) && !defined(NS32K) && !defined(I860)
- fix_new( lie->frag, lie->word_goes_here - lie->frag->fr_literal,
- 2, lie->add,
- lie->sub, lie->addnum,
- 0);
-#endif
- /* md_number_to_chars(lie->word_goes_here,
- lie->add->sy_value
- + lie->addnum
- - (lie->sub->sy_value),
- 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;
-
- extern md_short_jump_size;
- extern md_long_jump_size;
- void md_create_short_jump();
- void md_create_long_jump();
-
-
-
- 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
- - (lie->sub->sy_value);
- 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=lie->add->sy_value+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
-#ifndef VMS
- /*
- * Scan every FixS performing fixups. We had to wait until now to do
- * this because md_convert_frag() may have made some fixSs.
- */
- /* the_exec . a_trsize
- = sizeof(struct relocation_info) * fixup_segment (text_fix_root, N_TEXT);
- the_exec . a_drsize
- = sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA); */
-
- tr_siz=sizeof(struct relocation_info) * fixup_segment (text_fix_root, N_TEXT);
- md_number_to_chars((char *)&the_exec.a_trsize, tr_siz ,sizeof(the_exec.a_trsize));
- dr_siz=sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA);
- md_number_to_chars((char *)&the_exec.a_drsize, dr_siz, sizeof(the_exec.a_drsize));
- md_number_to_chars((char *)&the_exec.a_info,omagic,sizeof(the_exec.a_info));
- md_number_to_chars((char *)&the_exec.a_entry,0,sizeof(the_exec.a_entry));
-
-#ifdef EXEC_MACHINE_TYPE
- md_number_to_chars((char *)&the_exec.a_machtype, EXEC_MACHINE_TYPE, sizeof(the_exec.a_machtype));
-#endif
-#ifdef EXEC_VERSION
- md_number_to_chars((char *)&the_exec.a_version,EXEC_VERSION,sizeof(the_exec.a_version));
-#endif
-
- /* the_exec . a_entry = 0; */
-
- size_of_the_object_file =
- sizeof( the_exec ) +
- text_siz +
- data_siz +
- syms_siz +
- tr_siz +
- dr_siz +
- string_byte_count;
-
- next_object_file_charP
- = the_object_file
- = xmalloc ( size_of_the_object_file );
-
- output_file_create (out_file_name);
-
- append (& next_object_file_charP, (char *)(&the_exec), (unsigned long)sizeof(the_exec));
-
- /*
- * Emit code.
- */
- for (fragP = text_frag_root; fragP; fragP = fragP -> fr_next)
- {
- register long int count;
- register char * fill_literal;
- register long int 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 code frag. */
-
- /*
- * Emit relocations.
- */
- emit_relocations (text_fix_root, (relax_addressT)0);
- emit_relocations (data_fix_root, text_last_frag -> fr_address);
- /*
- * Emit all symbols left in the symbol chain.
- * Any symbol still undefined is made N_EXT.
- */
- for ( symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next )
- {
- register char * temp;
-
- temp = symbolP -> sy_nlist . n_un . n_name;
- /* JF fix the numbers up. Call by value RULES! */
- md_number_to_chars((char *)&(symbolP -> sy_nlist . n_un . n_strx ),symbolP -> sy_name_offset,sizeof(symbolP -> sy_nlist . n_un . n_strx ));
- md_number_to_chars((char *)&(symbolP->sy_nlist.n_desc),symbolP->sy_nlist.n_desc,sizeof(symbolP -> sy_nlist . n_desc));
- md_number_to_chars((char *)&(symbolP->sy_nlist.n_value),symbolP->sy_nlist.n_value,sizeof(symbolP->sy_nlist.n_value));
- /* symbolP -> sy_nlist . n_un . n_strx = symbolP -> sy_name_offset; JF replaced by md above */
- if (symbolP -> sy_type == N_UNDF)
- symbolP -> sy_type |= N_EXT; /* Any undefined symbols become N_EXT. */
- append (& next_object_file_charP, (char *)(& symbolP -> sy_nlist),
- (unsigned long)sizeof(struct nlist));
- symbolP -> sy_nlist . n_un . n_name = temp;
- } /* for each symbol */
-
- /*
- * next_object_file_charP -> slot for next object byte.
- * Emit strings.
- * Find strings by crawling along symbol table chain.
- */
-/* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars((char *)&string_byte_count, string_byte_count, sizeof(string_byte_count));
-
- append (& next_object_file_charP, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count));
- for ( symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next )
- {
- if (symbolP -> sy_name)
- { /* Ordinary case: not .stabd. */
- append (& next_object_file_charP, symbolP -> sy_name,
- (unsigned long)(strlen (symbolP -> sy_name) + 1));
- }
- } /* for each symbol */
-
- know( next_object_file_charP == the_object_file + size_of_the_object_file );
-
- output_file_append (the_object_file, size_of_the_object_file, out_file_name);
-
-#ifdef DONTDEF
- if (flagseen['G']) /* GDB symbol file to be appended? */
- {
- gdb_emit (out_file_name);
- gdb_end ();
- }
-#endif
-
- output_file_close (out_file_name);
-#else /* VMS */
- /*
- * Now do the VMS-dependent part of writing the object file
- */
- VMS_write_object_file(text_siz, data_siz, text_frag_root, data_frag_root);
-#endif /* VMS */
-} /* write_object_file() */
-
-/*
- * 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.
- */
-#ifndef VMS
-static
-#endif /* not VMS */
-void
-relax_segment (segment_frag_root, segment_type)
- struct frag * segment_frag_root;
- segT segment_type; /* N_DATA or N_TEXT */
-{
- register struct frag * fragP;
- register relax_addressT address;
- /* register relax_addressT old_address; JF unused */
- /* register relax_addressT new_address; JF unused */
-
- know( segment_type == SEG_DATA || segment_type == SEG_TEXT );
-
- /* In case md_estimate_size_before_relax() wants to make fixSs. */
- subseg_change (segment_type, 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, seg_N_TYPE [(int) segment_type]);
- 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 int 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 int 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 int growth;
- register long int was_address;
- /* register long int var; */
- register long int offset;
- register symbolS * symbolP;
- register long int target;
- register long int after;
- register long int aim;
-
- was_address = fragP -> fr_address;
- address = fragP -> fr_address += stretch;
- symbolP = fragP -> fr_symbol;
- offset = fragP -> fr_offset;
- /* var = fragP -> fr_var; */
- 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;
- extern int md_short_jump_size;
- extern int md_long_jump_size;
-
- /* 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+lie->add->sy_value + lie->addnum -
- (lie->sub->sy_frag->fr_address+lie->sub->sy_value);
- if(offset<=-32768 || offset>=32767) {
- if(flagseen['k'])
- as_warn(".word %s-%s+%ld didn't fit",lie->add->sy_name,lie->sub->sy_name,lie->addnum);
- 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 && untruth->add->sy_value==lie->add->sy_value) {
- untruth->added=2;
- untruth->use_jump=lie;
- }
- growth+=md_long_jump_size;
- }
- }
- }
- break;
-#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)
- {
- know( ((symbolP -> sy_type & N_TYPE) == N_ABS) || ((symbolP -> sy_type & N_TYPE) == N_DATA) || ((symbolP -> sy_type & N_TYPE) == N_TEXT));
- know( symbolP -> sy_frag );
- know( (symbolP->sy_type&N_TYPE)!=N_ABS || symbolP->sy_frag==&zero_address_frag );
- target +=
- symbolP -> sy_value
- + symbolP -> sy_frag -> fr_address;
- }
- 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)
- {
- know( ((symbolP -> sy_type & N_TYPE) == N_ABS) || ((symbolP -> sy_type &
- N_TYPE) == N_DATA) || ((symbolP -> sy_type & N_TYPE) == N_TEXT));
- know( symbolP -> sy_frag );
- know( (symbolP->sy_type&N_TYPE)!=N_ABS || symbolP->sy_frag==&zero_address_frag );
- target +=
- symbolP -> sy_value
- + 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;
-
- }
- 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 NS32K
- aim += fragP->fr_pcrel_adjust;
-#endif
-
- 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
-/* 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)
- fragP -> fr_subtype = this_state;
- }
- break;
-
- 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. */
- }
-
- /*
- * 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.
- */
-
-static relax_addressT /* How many addresses does the .align take? */
-relax_align (address, alignment)
- register relax_addressT address; /* Address now. */
- register long int alignment; /* Alignment (binary). */
-{
- relax_addressT mask;
- relax_addressT new_address;
-
- mask = ~ ( (~0) << alignment );
- new_address = (address + mask) & (~ mask);
- return (new_address - address);
-}
-
-/*
- * fixup_segment()
- */
-static long int
-fixup_segment (fixP, this_segment_type)
- register fixS * fixP;
- int this_segment_type; /* N_TYPE bits for segment. */
-{
- register long int seg_reloc_count;
- /* JF these all used to be local to the for loop, but GDB doesn't seem to be able to deal with them there, so I moved them here for a bit. */
- register symbolS * add_symbolP;
- register symbolS * sub_symbolP;
- register long int add_number;
- register int size;
- register char * place;
- register long int where;
- register char pcrel;
- register fragS * fragP;
- register int add_symbol_N_TYPE;
-
-
- 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;
- sub_symbolP = fixP -> fx_subsy;
- add_number = fixP -> fx_offset;
- pcrel = fixP -> fx_pcrel;
- if(add_symbolP)
- add_symbol_N_TYPE = add_symbolP -> sy_type & N_TYPE;
- if (sub_symbolP)
- {
- if(!add_symbolP) /* Its just -sym */
- {
- if(sub_symbolP->sy_type!=N_ABS)
- as_warn("Negative of non-absolute symbol %s", sub_symbolP->sy_name);
- add_number-=sub_symbolP->sy_value;
- }
- else if ( ((sub_symbolP -> sy_type ^ add_symbol_N_TYPE) & N_TYPE) == 0
- && ( add_symbol_N_TYPE == N_DATA
- || add_symbol_N_TYPE == N_TEXT
- || add_symbol_N_TYPE == N_BSS
- || add_symbol_N_TYPE == N_ABS))
- {
- /* Difference of 2 symbols from same segment. */
- /* Can't make difference of 2 undefineds: 'value' means */
- /* something different for N_UNDF. */
- add_number += add_symbolP -> sy_value - sub_symbolP -> sy_value;
- add_symbolP = NULL;
- fixP -> fx_addsy = NULL;
- }
- else
- {
- /* Different segments in subtraction. */
- know( sub_symbolP -> sy_type != (N_ABS | N_EXT))
- if (sub_symbolP -> sy_type == N_ABS)
- add_number -= sub_symbolP -> sy_value;
- else
- {
- as_warn("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
- seg_name[(int)N_TYPE_seg[sub_symbolP->sy_type&N_TYPE]],
- sub_symbolP -> sy_name, fragP -> fr_address + where);
- }
- }
- }
- if (add_symbolP)
- {
- if (add_symbol_N_TYPE == 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.
- */
- add_number += add_symbolP -> sy_value;
- add_number -=
-#ifndef NS32K
- size +
-#endif
- where + fragP -> fr_address;
-#if defined(NS32K) && defined(SEQUENT_COMPATABILITY)
- if (fragP->fr_bsr)
- add_number -= 0x12; /* FOO Kludge alert! */
-#endif
- /* Kenny thinks this needs *
- /* add_number +=size-2; */
- pcrel = 0; /* Lie. Don't want further pcrel processing. */
- fixP -> fx_addsy = NULL; /* No relocations please. */
- /*
- * It would be nice to check that the address does not overflow.
- * I didn't do this check because:
- * + It is machine dependent in the general case (eg 32032)
- * + Compiler output will never need this checking, so why
- * slow down the usual case?
- */
- }
- else
- {
- switch (add_symbol_N_TYPE)
- {
- case N_ABS:
- add_number += add_symbolP -> sy_value;
- fixP -> fx_addsy = NULL;
- add_symbolP = NULL;
- break;
-
- case N_BSS:
- case N_DATA:
- case N_TEXT:
- seg_reloc_count ++;
- add_number += add_symbolP -> sy_value;
- break;
-
- case N_UNDF:
- seg_reloc_count ++;
- break;
-
- default:
- BAD_CASE( add_symbol_N_TYPE );
- break;
- } /* switch on symbol seg */
- } /* if not in local seg */
- } /* if there was a + symbol */
- if (pcrel)
- {
- add_number -=
-#ifndef NS32K
- size +
-#endif
- where + fragP -> fr_address;
- if (add_symbolP == 0)
- {
- fixP -> fx_addsy = & abs_symbol;
- seg_reloc_count ++;
- }
- }
- /* OVE added fx_im_disp for ns32k and others */
- if (!fixP->fx_bit_fixP) {
- /* JF I hope this works . . . */
- if((size==1 && (add_number& ~0xFF) && (add_number&~0xFF!=(-1&~0xFF))) ||
- (size==2 && (add_number& ~0xFFFF) && (add_number&~0xFFFF!=(-1&~0xFFFF))))
- as_warn("Fixup of %d too large for field width of %d",add_number, size);
-
- switch (fixP->fx_im_disp) {
- case 0:
-#if defined(SPARC) || defined(I860)
- fixP->fx_addnumber = add_number;
- md_number_to_imm(place, add_number, size, fixP, this_segment_type);
-#else
- md_number_to_imm (place, add_number, size);
- /* OVE: the immediates, like disps, have lsb at lowest address */
-#endif
- break;
- case 1:
- md_number_to_disp (place,
- fixP->fx_pcrel ? add_number+fixP->fx_pcrel_adjust:add_number,
- size);
- break;
- case 2: /* fix requested for .long .word etc */
- md_number_to_chars (place, add_number, size);
- break;
- default:
- as_fatal("Internal error in write.c in fixup_segment");
- } /* OVE: maybe one ought to put _imm _disp _chars in one md-func */
- } else {
- md_number_to_field (place, add_number, fixP->fx_bit_fixP);
- }
- } /* For each fixS in this segment. */
- return (seg_reloc_count);
-} /* fixup_segment() */
-
-
-/* The sparc needs its own emit_relocations() */
-#if !defined(SPARC) && !defined(I860)
-/*
- * emit_relocations()
- *
- * Crawl along a fixS chain. Emit the segment's relocations.
- */
-static void
-emit_relocations (fixP, segment_address_in_file)
- register fixS * fixP; /* Fixup chain for this segment. */
- relax_addressT segment_address_in_file;
-{
- struct relocation_info ri;
- register symbolS * symbolP;
-
- /* JF this is for paranoia */
- bzero((char *)&ri,sizeof(ri));
- for ( ; fixP; fixP = fixP -> fx_next)
- {
- if (symbolP = fixP -> fx_addsy)
- {
-
-#ifdef NS32K
- /* These two 'cuz of NS32K */
- ri . r_bsr = fixP -> fx_bsr;
- ri . r_disp = fixP -> fx_im_disp;
-#endif
-
- 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 ((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;
- }
-
- /*
- The 68k machines assign bit-fields from higher bits to
- lower bits ("left-to-right") within the int. VAXen assign
- bit-fields from lower bits to higher bits ("right-to-left").
- Both handle multi-byte numbers in their usual fashion
- (Big-endian and little-endian stuff).
- Thus we need a machine dependent routine to make
- sure the structure is written out correctly. FUN!
- */
- md_ri_to_chars((char *) &ri, ri);
- append (&next_object_file_charP, (char *)& ri, (unsigned long)sizeof(ri));
- }
- }
-
-}
-#endif
-
-int
-is_dnrange(f1,f2)
-struct frag *f1,*f2;
-{
- while(f1) {
- if(f1->fr_next==f2)
- return 1;
- f1=f1->fr_next;
- }
- return 0;
-}
-/* End: as-write.c */
diff --git a/gnu/usr.bin/as/write.h b/gnu/usr.bin/as/write.h
deleted file mode 100644
index 7327690..0000000
--- a/gnu/usr.bin/as/write.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* write.h -> write.c
- 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. */
-
-/* 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)
- */
-
-
-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;
-/*
- * FixSs may be built up in any order.
- */
-
-struct fix
-{
- fragS * fx_frag; /* Which frag? */
- long int 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. */
- long int 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 */
-#if defined(SPARC) || defined(I860)
- char fx_r_type; /* Sparc hacks */
- long fx_addnumber;
-#endif
-};
-
-typedef struct fix fixS;
-
-
-COMMON fixS * text_fix_root; /* Chains fixSs. */
-COMMON fixS * data_fix_root; /* Chains fixSs. */
-COMMON fixS ** seg_fix_rootP; /* -> one of above. */
-
-bit_fixS *bit_fix_new();
-/* end: write.h */
-
diff --git a/gnu/usr.bin/as/xmalloc.c b/gnu/usr.bin/as/xmalloc.c
deleted file mode 100644
index 78c8c7f..0000000
--- a/gnu/usr.bin/as/xmalloc.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* xmalloc.c - get memory or bust
- 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. */
-
-/*
-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()
-
-*/
-#ifdef USG
-#include <malloc.h>
-#endif
-
-char * xmalloc(n)
- long n;
-{
- char * retval;
- char * malloc();
- void error();
-
- if ( ! (retval = malloc ((unsigned)n)) )
- {
- error("virtual memory exceeded");
- }
- return (retval);
-}
-
-/* end: xmalloc.c */
diff --git a/gnu/usr.bin/as/xrealloc.c b/gnu/usr.bin/as/xrealloc.c
deleted file mode 100644
index a5010bc..0000000
--- a/gnu/usr.bin/as/xrealloc.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* xrealloc.c -new memory or bust-
- 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. */
-
-
-/*
-
-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 ()
-*/
-
-#ifdef USG
-#include <malloc.h>
-#endif
-
-char *
-xrealloc (ptr, n)
-register char *ptr;
-long n;
-{
- char *realloc ();
- void error();
-
- if ((ptr = realloc (ptr, (unsigned)n)) == 0)
- error ("virtual memory exceeded");
- return (ptr);
-}
-
-/* end: xrealloc.c */
diff --git a/gnu/usr.bin/awk/ACKNOWLEDGMENT b/gnu/usr.bin/awk/ACKNOWLEDGMENT
deleted file mode 100644
index b6c3b0b..0000000
--- a/gnu/usr.bin/awk/ACKNOWLEDGMENT
+++ /dev/null
@@ -1,21 +0,0 @@
-The current developers of Gawk would like to thank and acknowledge the
-many people who have contributed to the development through bug reports
-and fixes and suggestions. Unfortunately, we have not been organized
-enough to keep track of all the names -- for that we apologize.
-
-Another group of people have assisted even more by porting Gawk to new
-platforms and providing a great deal of feedback. They are:
-
- Hal Peterson <hrp@pecan.cray.com> (Cray)
- Pat Rankin <gawk.rankin@EQL.Caltech.Edu> (VMS)
- Michal Jaegermann <NTOMCZAK@vm.ucs.UAlberta.CA> (Atari, NeXT, DEC 3100)
- Mike Lijewski <mjlx@eagle.cnsf.cornell.edu> (IBM RS6000)
- Scott Deifik <scottd@amgen.com> (MSDOS 2.14)
- Kent Williams (MSDOS 2.11)
- Conrad Kwok (MSDOS earlier versions)
- Scott Garfinkle (MSDOS earlier versions)
-
-Last, but far from least, we would like to thank Brian Kernighan who
-has helped to clear up many dark corners of the language and provided a
-restraining touch when we have been overly tempted by "feeping
-creaturism".
diff --git a/gnu/usr.bin/awk/COPYING b/gnu/usr.bin/awk/COPYING
deleted file mode 100644
index 3358a7b..0000000
--- a/gnu/usr.bin/awk/COPYING
+++ /dev/null
@@ -1,340 +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/awk/FUTURES b/gnu/usr.bin/awk/FUTURES
deleted file mode 100644
index b096560..0000000
--- a/gnu/usr.bin/awk/FUTURES
+++ /dev/null
@@ -1,120 +0,0 @@
-This file lists future projects and enhancements for gawk. Items are listed
-in roughly the order they will be done for a given release. This file is
-mainly for use by the developers to help keep themselves on track, please
-don't bug us too much about schedules or what all this really means.
-
-For 2.16
-========
-David:
- Move to autoconf-based configure system.
-
- Allow RS to be a regexp.
-
- RT variable to hold text of record terminator
-
- RECLEN variable for fixed length records
-
- Feedback alloca.s changes to FSF
-
- Extensible hashing in memory of awk arrays
-
- Split() with null string as third arg to split up strings
-
- Analogously, setting FS="" would split the input record into individual
- characters.
-
-Arnold:
- Generalize IGNORECASE
- any value makes it work, not just numeric non-zero
- make it apply to *all* string comparisons
-
- Fix FILENAME to have an initial value of "", not "-"
-
- Clean up code by isolating system-specific functions in separate files.
-
- Undertake significant directory reorganization.
-
- Extensive manual cleanup:
- Use of texinfo 2.0 features
- Lots more examples
- Document all of the above.
-
-In 2.17
-=======
-David:
-
- Incorporate newer dfa.c and regex.c (go to POSIX regexps)
-
- Make regex + dfa less dependant on gawk header file includes
-
- General sub functions:
- edit(line, pat, sub) and gedit(line, pat, sub)
- that return the substituted strings and allow \1 etc. in the sub string.
-
-Arnold:
- DBM storage of awk arrays. Try to allow multiple dbm packages
-
- ? Have strftime() pay attention to the value of ENVIRON["TZ"]
-
- Additional manual features:
- Document posix regexps
- Document use of dbm arrays
- ? Add an error messages section to the manual
- ? A section on where gawk is bounded
- regex
- i/o
- sun fp conversions
-
-For 2.18
-========
-
-Arnold:
- Add chdir and stat built-in functions.
-
- Add function pointers as valid variable types.
-
- Add an `ftw' built-in function that takes a function pointer.
-
-David:
-
- Do an optimization pass over parse tree?
-
-For 2.19 or later:
-==================
-Add variables similar to C's __FILE__ and __LINE__ for better diagnostics
-from within awk programs.
-
-Add an explicit concatenation operator and assignment version.
-
-? Add a switch statement
-
-Add the ability to seek on an open file and retrieve the current file position.
-
-Add lint checking everywhere, including check for use of builtin vars.
-only in new awk.
-
-"restart" keyword
-
-Add |&
-
-Make awk '/foo/' files... run at egrep speeds
-
-Do a reference card
-
-Allow OFMT to be other than a floating point format.
-
-Allow redefining of builtin functions?
-
-Make it faster and smaller.
-
-For 3.x:
-========
-
-Create a gawk compiler?
-
-Create a gawk-to-C translator? (or C++??)
-
-Provide awk profiling and debugging.
-
-
-
diff --git a/gnu/usr.bin/awk/LIMITATIONS b/gnu/usr.bin/awk/LIMITATIONS
deleted file mode 100644
index 5877197..0000000
--- a/gnu/usr.bin/awk/LIMITATIONS
+++ /dev/null
@@ -1,14 +0,0 @@
-This file describes limits of gawk on a Unix system (although it
-is variable even then). Non-Unix systems may have other limits.
-
-# of fields in a record: MAX_INT
-Length of input record: MAX_INT
-Length of output record: unlimited
-Size of a field: MAX_INT
-Size of a printf string: MAX_INT
-Size of a literal string: MAX_INT
-Characters in a character class: 2^(# of bits per byte)
-# of file redirections: unlimited
-# of pipe redirections: min(# of processes per user, # of open files)
-double-precision floating point
-Length of source line: unlimited
diff --git a/gnu/usr.bin/awk/Makefile b/gnu/usr.bin/awk/Makefile
deleted file mode 100644
index 3ef9894..0000000
--- a/gnu/usr.bin/awk/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-PROG= awk
-SRCS= main.c eval.c builtin.c msg.c iop.c io.c field.c array.c \
- node.c version.c re.c awk.c regex.c dfa.c \
- getopt.c getopt1.c
-CFLAGS+= -DGAWK
-LDADD= -lm
-DPADD= ${LIBM}
-CLEANFILES+= awk.c y.tab.h
-
-MAN1= awk.1
-
-.include <bsd.prog.mk>
-.include "../../usr.bin/Makefile.inc"
diff --git a/gnu/usr.bin/awk/NEWS b/gnu/usr.bin/awk/NEWS
deleted file mode 100644
index 6711373..0000000
--- a/gnu/usr.bin/awk/NEWS
+++ /dev/null
@@ -1,1295 +0,0 @@
-Changes from 2.15.1 to 2.15.2
----------------------------
-
-Additions to the FUTURES file.
-
-Document undefined order of output when using both standard output
- and /dev/stdout or any of the /dev output files that gawk emulates in
- the absence of OS support.
-
-Clean up the distribution generation in Makefile.in: the info files are
- now included, the distributed files are marked read-only and patched
- distributions are now unpacked in a directory named with the patch level.
-
-
-Changes from 2.15 to 2.15.1
----------------------------
-
-Close stdout and stderr before all redirections on program exit. This allows
- detection of write errors and also fixes the messages test on Solaris 2.x.
-
-Removed YYMAXDEPTH define in awk.y which was limiting the parser stack depth.
-
-Changes to config/bsd44, Makefile.bsd44 and configure to bring it into line
- with the BSD4.4 release.
-
-Changed Makefile to use prefix, exec_prefix, bindir etc.
-
-make install now installs info files.
-
-make install now sets permissions on installed files.
-
-Make targets added: uninstall, distclean, mostlyclean and realclean.
-
-Added config.h to cleaner and clobber make targets.
-
-Changes to config/{hpux8x,sysv3,sysv4,ultrix41} to deal with alloca().
-
-Change to getopt.h for portability.
-
-Added more special cases to the getpgrp() call.
-
-Added README.ibmrt-aos and config/ibmrt-aos.
-
-Changes from 2.14 to 2.15
----------------------------
-
-Command-line source can now be mixed with library functions.
-
-ARGIND variable tracks index in ARGV of FILENAME.
-
-GNU style long options in addition to short options.
-
-Plan 9 style special files interpreted by gawk:
- /dev/pid
- /dev/ppid
- /dev/pgrpid
- /dev/user
- $1 = getuid
- $2 = geteuid
- $3 = getgid
- $4 = getegid
- $5 ... $NF = getgroups if supported
-
-ERRNO variable contains error string if getline or close fails.
-
-Very old options -a and -e have gone away.
-
-Inftest has been removed from the default target in test/Makefile -- the
- results were too machine specific and resulted in too many false alarms.
-
-A README.amiga has been added.
-
-The "too many arguments supplied for format string" warning message is only
- in effect under the lint option.
-
-Code improvements in dfa.c.
-
-Fixed all reported bugs:
-
- Writes are checked for failure (such as full filesystem).
-
- Stopped (at least some) runaway error messages.
-
- gsub(/^/, "x") does the right thing for $0 of 0, 1, or more length.
-
- close() on a command being piped to a getline now works properly.
-
- The input record will no longer be freed upon an explicit close()
- of the input file.
-
- A NUL character in FS now works.
-
- In a substitute, \\& now means a literal backslash followed by what
- was matched.
-
- Integer overflow of substring length in substr() is caught.
-
- An input record without a newline termination is handled properly.
-
- In io.c, check is against only EMFILE so that system file table
- is not filled.
-
- Renamed all files with names longer than 14 characters.
-
- Escaped characters in regular expressions were being lost when
- IGNORECASE was used.
-
- Long source lines were not being handled properly.
-
- Sourcefiles that ended in a tab but no newline were bombing.
-
- Patterns that could match zero characters in split() were not working
- properly.
-
- The parsedebug option was not working.
-
- The grammar was being a bit too lenient, allowing some very dubious
- programs to pass.
-
- Compilation with DEBUG defined now works.
-
- A variable read in with getline was not being treated as a potential
- number.
-
- Array subscripts were not always of string type.
-
-
-Changes from 2.13.2 to 2.14
----------------------------
-
-Updated manual!
-
-Added "next file" to skip efficiently to the next input file.
-
-Fixed potential of overflowing buffer in do_sprintf().
-
-Plugged small memory leak in sub_common().
-
-EOF on a redirect is now "sticky" -- it can only be cleared by close()ing
- the pipe or file.
-
-Now works if used via a #! /bin/gawk line at the top of an executable file
- when that line ends with whitespace.
-
-Added some checks to the grammar to catch redefinition of builtin functions.
- This could eventually be the basis for an extension to allow redefining
- functions, but in the mean time it's a good error catching facility.
-
-Negative integer exponents now work.
-
-Modified do_system() to make sure it had a non-null string to be passed
- to system(3). Thus, system("") will flush any pending output but not go
- through the overhead of forking an un-needed shell.
-
-A fix to floating point comparisons so that NaNs compare right on IEEE systems.
-
-Added code to make sure we're not opening directories for reading and such.
-
-Added code to do better diagnoses of weird or null file names.
-
-Allow continue outside of a loop, unless in strict posix mode. Lint option
- will issue warning.
-
-New missing/strftime.c. There has been one chage that affects gawk. Posix
- now defines a %V conversion so the vms conversion has been changed to %v.
- If this version is used with gawk -Wlint and they use %V in a call to
- strftime, they'll get a warning.
-
-Error messages now conform to GNU standard (I hope).
-
-Changed comparisons to conform to the description found in the file POSIX.
- This is inconsistent with the current POSIX draft, but that is broken.
- Hopefully the final POSIX standard will conform to this version.
- (Alas, this will have to wait for 1003.2b, which will be a revision to
- the 1003.2 standard. That standard has been frozen with the broken
- comparison rules.)
-
-The length of a string was a short and now is a size_t.
-
-Updated VMS help.
-
-Added quite a few new tests to the test suite and deleted many due to lack of
- written releases. Test output is only removed if it is identical to the
- "good" output.
-
-Fixed a couple of bugs for reference to $0 when $0 is "" -- particularly in
- a BEGIN block.
-
-Fixed premature freeing in construct "$0 = $0".
-
-Removed the call to wait_any() in gawk_popen(), since on at least some systems,
- if gawk's input was from a pipe, the predecssor process in the pipe was a
- child of gawk and this caused a deadlock.
-
-Regexp can (once again) match a newline, if given explicitly.
-
-nextopen() makes sure file name is null terminated.
-
-Fixed VMS pipe simulation. Improved VMS I/O performance.
-
-Catch . used in variable names.
-
-Fixed bug in getline without redirect from a file -- it was quitting after the
- first EOF, rather than trying the next file.
-
-Fixed bug in treatment of backslash at the end of a string -- it was bombing
- rather than doing something sensible. It is not clear what this should mean,
- but for now I issue a warning and take it as a literal backslash.
-
-Moved setting of regexp syntax to before the option parsing in main(), to
- handle things like -v FS='[.,;]'
-
-Fixed bug when NF is set by user -- fields_arr must be expanded if necessary
- and "new" fields must be initialized.
-
-Fixed several bugs in [g]sub() for no match found or the match is 0-length.
-
-Fixed bug where in gsub() a pattern anchorred at the beginning would still
- substitute throughout the string.
-
-make test does not assume the . is in PATH.
-
-Fixed bug when a field beyond the end of the record was requested after
- $0 was altered (directly or indirectly).
-
-Fixed bug for assignment to field beyond end of record -- the assigned value
- was not found on subsequent reference to that field.
-
-Fixed bug for FS a regexp and it matches at the end of a record.
-
-Fixed memory leak for an array local to a function.
-
-Fixed hanging of pipe redirection to getline
-
-Fixed coredump on access to $0 inside BEGIN block.
-
-Fixed treatment of RS = "". It now parses the fields correctly and strips
- leading whitspace from a record if FS is a space.
-
-Fixed faking of /dev/stdin.
-
-Fixed problem with x += x
-
-Use of scalar as array and vice versa is now detected.
-
-IGNORECASE now obeyed for FS (even if FS is a single alphabetic character).
-
-Switch to GPL version 2.
-
-Renamed awk.tab.c to awktab.c for MSDOS and VMS tar programs.
-
-Renamed this file (CHANGES) to NEWS.
-
-Use fmod() instead of modf() and provide FMOD_MISSING #define to undo
- this change.
-
-Correct the volatile declarations in eval.c.
-
-Avoid errant closing of the file descriptors for stdin, stdout and stderr.
-
-Be more flexible about where semi-colons can occur in programs.
-
-Check for write errors on all output, not just on close().
-
-Eliminate the need for missing/{strtol.c,vprintf.c}.
-
-Use GNU getopt and eliminate missing/getopt.c.
-
-More "lint" checking.
-
-
-Changes from 2.13.1 to 2.13.2
------------------------------
-
-Toward conformity with GNU standards, configure is a link to mkconf, the latter
- to disappear in the next major release.
-
-Update to config/bsd43.
-
-Added config/apollo, config/msc60, config/cray2-50, config/interactive2.2
-
-sgi33.cc added for compilation using cc ratther than gcc.
-
-Ultrix41 now propagates to config.h properly -- as part of a general
- mechanism in configure for kludges -- #define anything from a config file
- just gets tacked onto the end of config.h -- to be used sparingly.
-
-Got rid of an unnecessary and troublesome declaration of vprintf().
-
-Small improvement in locality of error messages.
-
-Try to diagnose use of array as scalar and vice versa -- to be improved in
- the future.
-
-Fix for last bug fix for Cray division code--sigh.
-
-More changes to test suite to explicitly use sh. Also get rid of
- a few generated files.
-
-Fixed off-by-one bug in string concatenation code.
-
-Fix for use of array that is passed in from a previous function parameter.
- Addition to test suite for above.
-
-A number of changes associated with changing NF and access to fields
- beyond the end of the current record.
-
-Change to missing/memcmp.c to avoid seg. fault on zero length input.
-
-Updates to test suite (including some inadvertently left out of the last patch)
- to invoke sh explicitly (rather than rely on #!/bin/sh) and remove some
- junk files. test/chem/good updated to correspond to bug fixes.
-
-Changes from 2.13.0 to 2.13.1
------------------------------
-
-More configs and PORTS.
-
-Fixed bug wherein a simple division produced an erroneous FPE, caused by
- the Cray division workaround -- that code is now #ifdef'd only for
- Cray *and* fixed.
-
-Fixed bug in modulus implementation -- it was very close to the above
- code, so I noticed it.
-
-Fixed portability problem with limits.h in missing.c
-
-Fixed portability problem with tzname and daylight -- define TZNAME_MISSING
- if strftime() is missing and tzname is also.
-
-Better support for Latin-1 character set.
-
-Fixed portability problem in test Makefile.
-
-Updated PROBLEMS file.
-
-=============================== gawk-2.13 released =========================
-Changes from 2.12.42 to 2.12.43
--------------------------------
-
-Typo in awk.y
-
-Fixed up strftime.3 and added doc. for %V.
-
-Changes from 2.12.41 to 2.12.42
--------------------------------
-
-Fixed bug in devopen() -- if you had write permission in /dev,
- it would just create /dev/stdout etc.!!
-
-Final (?) VMS update.
-
-Make NeXT use GFMT_WORKAROUND
-
-Fixed bug in sub_common() for substitute on zero-length match. Improved the
- code a bit while I was at it.
-
-Fixed grammar so that $i++ parses as ($i)++
-
-Put support/* back in the distribution (didn't I already do this?!)
-
-Changes from 2.12.40 to 2.12.41
--------------------------------
-
-VMS workaround for broken %g format.
-
-Changes from 2.12.39 to 2.12.40
--------------------------------
-
-Minor man page update.
-
-Fixed latent bug in redirect().
-
-Changes from 2.12.38 to 2.12.39
--------------------------------
-
-Updates to test suite -- remove dependence on changing gawk.1 man page.
-
-Changes from 2.12.37 to 2.12.38
--------------------------------
-
-Fixed bug in use of *= without whitespace following.
-
-VMS update.
-
-Updates to man page.
-
-Option handling updates in main.c
-
-test/manyfiles redone and added to bigtest.
-
-Fixed latent (on Sun) bug in handling of save_fs.
-
-Changes from 2.12.36 to 2.12.37
--------------------------------
-
-Update REL in Makefile-dist. Incorporate test suite into main distribution.
-
-Minor fix in regtest.
-
-Changes from 2.12.35 to 2.12.36
--------------------------------
-
-Release takes on dual personality -- 2.12.36 and 2.13.0 -- any further
- patches before public release won't count for 2.13, although they will for
- 2.12 -- be careful to avoid confusion! patchlevel.h will be the last thing
- to change.
-
-Cray updates to deal with arithmetic problems.
-
-Minor test suite updates.
-
-Fixed latent bug in parser (freeing memory).
-
-Changes from 2.12.34 to 2.12.35
--------------------------------
-
-VMS updates.
-
-Flush stdout at top of err() and stderr at bottom.
-
-Fixed bug in eval_condition() -- it wasn't testing for MAYBE_NUM and
- doing the force_number().
-
-Included the missing manyfiles.awk and a new test to catch the above bug which
- I am amazed wasn't already caught by the test suite -- it's pretty basic.
-
-Changes from 2.12.33 to 2.12.34
--------------------------------
-
-Atari updates -- including bug fix.
-
-More VMS updates -- also nuke vms/version.com.
-
-Fixed bug in handling of large numbers of redirections -- it was probably never
- tested before (blush!).
-
-Minor rearrangement of code in r_force_number().
-
-Made chem and regtest tests a bit more portable (Ultrix again).
-
-Added another test -- manyfiles -- not invoked under any other test -- very Unix
- specific.
-
-Rough beginning of LIMITATIONS file -- need my AWK book to complete it.
-
-Changes from 2.12.32 to 2.12.33
--------------------------------
-
-Expunge debug.? from various files.
-
-Remove vestiges of Floor and Ceil kludge.
-
-Special case integer division -- mainly for Cray, but maybe someone else
- will benefit.
-
-Workaround for iop_close closing an output pipe descriptor on Cray --
- not conditional since I think it may fix a bug on SGI as well and I don't
- think it can hurt elsewhere.
-
-Fixed memory leak in assoc_lookup().
-
-Small cleanup in test suite.
-
-Changes from 2.12.31 to 2.12.32
--------------------------------
-
-Nuked debug.c and debugging flag -- there are better ways.
-
-Nuked version.sh and version.c in subdirectories.
-
-Fixed bug in handling of IGNORECASE.
-
-Fixed bug when FIELDWIDTHS was set via -v option.
-
-Fixed (obscure) bug when $0 is assigned a numerical value.
-
-Fixed so that escape sequences in command-line assignments work (as it already
- said in the comment).
-
-Added a few cases to test suite.
-
-Moved support/* back into distribution.
-
-VMS updates.
-
-Changes from 2.12.30 to 2.12.31
--------------------------------
-
-Cosmetic manual page changes.
-
-Updated sunos3 config.
-
-Small changes in test suite including renaming files over 14 chars. in length.
-
-Changes from 2.12.29 to 2.12.30
--------------------------------
-
-Bug fix for many string concatenations in a row.
-
-Changes from 2.12.28 to 2.12.29
--------------------------------
-
-Minor cleanup in awk.y
-
-Minor VMS update.
-
-Minor atari update.
-
-Changes from 2.12.27 to 2.12.28
--------------------------------
-
-Got rid of the debugging goop in eval.c -- there are better ways.
-
-Sequent port.
-
-VMS changes left out of the last patch -- sigh! config/vms.h renamed
- to config/vms-conf.h.
-
-Fixed missing/tzset.c
-
-Removed use of gcvt() and GCVT_MISSING -- turns out it was no faster than
- sprintf("%g") and caused all sorts of portability headaches.
-
-Tuned get_field() -- it was unnecessarily parsing the whole record on reference
- to $0.
-
-Tuned interpret() a bit in the rule_node loop.
-
-In r_force_number(), worked around bug in Uglix strtod() and got rid of
- ugly do{}while(0) at Michal's urging.
-
-Replaced do_deref() and deref with unref(node) -- much cleaner and a bit faster.
-
-Got rid of assign_number() -- contrary to comment, it was no faster than
- just making a new node and freeing the old one.
-
-Replaced make_number() and tmp_number() with macros that call mk_number().
-
-Changed freenode() and newnode() into macros -- the latter is getnode()
- which calls more_nodes() as necessary.
-
-Changes from 2.12.26 to 2.12.27
--------------------------------
-
-Completion of Cray 2 port (includes a kludge for floor() and ceil()
- that may go or be changed -- I think that it may just be working around
- a bug in chem that is being tweaked on the Cray).
-
-More VMS updates.
-
-Moved kludge over yacc's insertion of malloc and realloc declarations
- from protos.h to the Makefile.
-
-Added a lisp interpreter in awk to the test suite. (Invoked under
- bigtest.)
-
-Cleanup in r_force_number() -- I had never gotten around to a thorough
- profile of the cache code and it turns out to be not worth it.
-
-Performance boost -- do lazy force_number()'ing for fields etc. i.e.
- flag them (MAYBE_NUM) and call force_number only as necessary.
-
-Changes from 2.12.25 to 2.12.26
--------------------------------
-
-Rework of regexp stuff so that dynamic regexps have reasonable
- performance -- string used for compiled regexp is stored and
- compared to new string -- if same, no recompilation is necessary.
- Also, very dynamic regexps cause dfa-based searching to be turned
- off.
-
-Code in dev_open() is back to returning fileno(std*) rather than
- dup()ing it. This will be documented. Sorry for the run-around
- on this.
-
-Minor atari updates.
-
-Minor vms update.
-
-Missing file from MSDOS port.
-
-Added warning (under lint) if third arg. of [g]sub is a constant and
- handle it properly in the code (i.e. return how many matches).
-
-Changes from 2.12.24 to 2.12.25
--------------------------------
-
-MSDOS port.
-
-Non-consequential changes to regexp variables in preparation for
- a more serious change to fix a serious performance problem.
-
-Changes from 2.12.23 to 2.12.24
--------------------------------
-
-Fixed bug in output flushing introduced a few patches back. This caused
- serious performance losses.
-
-Changes from 2.12.22 to 2.12.23
--------------------------------
-
-Accidently left config/cray2-60 out of last patch.
-
-Added some missing dependencies to Makefile.
-
-Cleaned up mkconf a bit; made yacc the default parser (no alloca needed,
- right?); added rs6000 hook for signed characters.
-
-Made regex.c with NO_ALLOCA undefined work.
-
-Fixed bug in dfa.c for systems where free(NULL) bombs.
-
-Deleted a few cant_happen()'s that *really* can't hapen.
-
-Changes from 2.12.21 to 2.12.22
--------------------------------
-
-Added to config stuff the ability to choose YACC rather than bison.
-
-Fixed CHAR_UNSIGNED in config.h-dist.
-
-Second arg. of strtod() is char ** rather than const char **.
-
-stackb is now initially malloc()'ed since it may be realloc()'ed.
-
-VMS updates.
-
-Added SIZE_T_MISSING to config stuff and a default typedef to awk.h.
- (Maybe it is not needed on any current systems??)
-
-re_compile_pattern()'s size is now size_t unconditionally.
-
-Changes from 2.12.20 to 2.12.21
--------------------------------
-
-Corrected missing/gcvt.c.
-
-Got rid of use of dup2() and thus DUP_MISSING.
-
-Updated config/sgi33.
-
-Turned on (and fixed) in cmp_nodes() the behaviour that I *hope* will be in
- POSIX 1003.2 for relational comparisons.
-
-Small updates to test suite.
-
-Changes from 2.12.19 to 2.12.20
--------------------------------
-
-Sloppy, sloppy, sloppy!! I didn't even try to compile the last two
- patches. This one fixes goofs in regex.c.
-
-Changes from 2.12.18 to 2.12.19
--------------------------------
-
-Cleanup of last patch.
-
-Changes from 2.12.17 to 2.12.18
--------------------------------
-
-Makefile renamed to Makefile-dist.
-
-Added alloca() configuration to mkconf. (A bit kludgey.) Just
- add a single line containing ALLOCA_PW, ALLOCA_S or ALLOCA_C
- to the appropriate config file to have Makefile-dist edited
- accordingly.
-
-Reorganized output flushing to correspond with new semantics of
- devopen() on "/dev/std*" etc.
-
-Fixed rest of last goof!!
-
-Save and restore errno in do_pathopen().
-
-Miscellaneous atari updates.
-
-Get rid of the trailing comma in the NODETYPE definition (Cray
- compiler won't take it).
-
-Try to make the use of `const' consistent since Cray compiler is
- fussy about that. See the changes to `basename' and `myname'.
-
-It turns out that, according to section 3.8.3 (Macro Replacement)
- of the ANSI Standard: ``If there are sequences of preprocessing
- tokens within the list of arguments that would otherwise act as
- preprocessing directives, the behavior is undefined.'' That means
- that you cannot count on the behavior of the declaration of
- re_compile_pattern in awk.h, and indeed the Cray compiler chokes on it.
-
-Replaced alloca with malloc/realloc/free in regex.c. It was much simpler
- than expected. (Inside NO_ALLOCA for now -- by default no alloca.)
-
-Added a configuration file, config/cray60, for Unicos-6.0.
-
-Changes from 2.12.16 to 2.12.17
--------------------------------
-
-Ooops. Goofed signal use in last patch.
-
-Changes from 2.12.15 to 2.12.16
--------------------------------
-
-RENAMED *_dir to just * (e.g. missing_dir).
-
-Numerous VMS changes.
-
-Proper inclusion of atari and vms files.
-
-Added experimental (ifdef'd out) RELAXED_CONTINUATION and DEFAULT_FILETYPE
- -- please comment on these!
-
-Moved pathopen() to io.c (sigh).
-
-Put local directory ahead in default AWKPATH.
-
-Added facility in mkconf to echo comments on stdout: lines beginning
- with "#echo " will have the remainder of the line echoed when mkconf is run.
- Any lines starting with "#" will otherwise be treated as comments. The
- intent is to be able to say:
- "#echo Make sure you uncomment alloca.c in the Makefile"
- or the like.
-
-Prototype fix for V.4
-
-Fixed version_string to not print leading @(#).
-
-Fixed FIELDWIDTHS to work with strict (turned out to be easy).
-
-Fixed conf for V.2.
-
-Changed semantics of /dev/fd/n to be like on real /dev/fd.
-
-Several configuration and updates in the makefile.
-
-Updated manpage.
-
-Include tzset.c and system.c from missing_dir that were accidently left out of
- the last patch.
-
-Fixed bug in cmdline variable assignment -- arg was getting freed(!) in
- call to variable.
-
-Backed out of parse-time constant folding for now, until I can figure out
- how to do it right.
-
-Fixed devopen() so that getline <"-" works.
-
-Changes from 2.12.14 to 2.12.15
--------------------------------
-
-Changed config/* to a condensed form that can be used with mkconf to generate
- a config.h from config.h-dist -- much easier to maintain. Please chaeck
- carefully against what you had before for a particular system and report
- any problems. vms.h remains separate since the stuff at the bottom
- didn't quite fit the mkconf model -- hopefully cleared up later.
-
-Fixed bug in grammar -- didn't allow function definition to be separated from
- other rules by a semi-colon.
-
-VMS fix to #includes in missing.c -- should we just be including awk.h?
-
-Updated README for texinfo.tex version.
-
-Updating of copyright in all .[chy] files.
-
-Added but commented out Michal's fix to strftime.
-
-Added tzset() emulation based on Rick Adams' code. Added TZSET_MISSING to
- config.h-dist.
-
-Added strftime.3 man page for missing_dir
-
-More posix: func, **, **= don't work in -W posix
-
-More lint: ^, ^= not in old awk
-
-gawk.1: removed ref to -DNO_DEV_FD, other minor updating.
-
-Style change: pushbak becomes pushback() in yylex().
-
-Changes from 2.12.13 to 2.12.14
--------------------------------
-
-Better (?) organization of awk.h -- attempt to keep all system dependencies
- near the top and move some of the non-general things out of the config.h
- files.
-
-Change to handling of SYSTEM_MISSING.
-
-Small change to ultrix config.
-
-Do "/dev/fd/*" etc. checking at runtime.
-
-First pass at VMS port.
-
-Improvements to error handling (when lexeme spans buffers).
-
-Fixed backslash handling -- why didn't I notice this sooner?
-
-Added programs from book to test suite and new target "bigtest" to Makefile.
-
-Changes from 2.12.12 to 2.12.13
--------------------------------
-
-Recognize OFS and ORS specially so that OFS = 9 works without efficiency hit.
- Took advantage of opportunity to tune do_print*() for about 10% win on a
- print with 5 args (i.e. small but significant).
-
-Somewhat pervasive changes to reconcile CONVFMT vs. OFMT.
-
-Better initialization of builtin vars.
-
-Make config/* consistent wrt STRTOL_MISSING.
-
-Small portability improvement to alloca.s
-
-Improvements to lint code in awk.y
-
-Replaced strtol() with a better one by Chris Torek.
-
-Changes from 2.12.11 to 2.12.12
--------------------------------
-
-Added PORTS file to record successful ports.
-
-Added #define const to nothing if not STDC and added const to strtod() header.
-
-Added * to printf capabilities and partially implemented ' ' and '+' (has an
- effect for %d only, silently ignored for other formats). I'm afraid that's
- as far as I want to go before I look at a complete replacement for
- do_sprintf().
-
-Added warning for /regexp/ on LHS of MATCHOP.
-
-Changes from 2.12.10 to 2.12.11
--------------------------------
-
-Small Makefile improvements.
-
-Some remaining nits from the NeXT port.
-
-Got rid of bcopy() define in awk.h -- not needed anymore (??)
-
-Changed private in builtin.c -- it is special on Sequent.
-
-Added subset implementation of strtol() and STRTOL_MISSING.
-
-A little bit of cleanup in debug.c, dfa.c.
-
-Changes from 2.12.9 to 2.12.10
-------------------------------
-
-Redid compatability checking and checking for # of args.
-
-Removed all references to variables[] from outside awk.y, in preparation
- for a more abstract interface to the symbol table.
-
-Got rid of a remaining use of bcopy() in regex.c.
-
-Changes from 2.12.8 to 2.12.9
------------------------------
-
-Portability improvements for atari, next and decstation.
-
-Bug fix in substr() -- wasn't handling 3rd arg. of -1 properly.
-
-Manpage updates.
-
-Moved support from src release to doc release.
-
-Updated FUTURES file.
-
-Added some "lint" warnings.
-
-Changes from 2.12.7 to 2.12.8
------------------------------
-
-Changed time() to systime().
-
-Changed warning() in snode() to fatal().
-
-strftime() now defaults second arg. to current time.
-
-Changes from 2.12.6 to 2.12.7
------------------------------
-
-Fixed bug in sub_common() involving inadequate allocation of a buffer.
-
-Added some missing files to the Makefile.
-
-Changes from 2.12.5 to 2.12.6
------------------------------
-
-Fixed bug wherein non-redirected getline could call iop_close() just
- prior to a call from do_input().
-
-Fixed bug in handling of /dev/stdout and /dev/stderr.
-
-Changes from 2.12.4 to 2.12.5
------------------------------
-
-Updated README and support directory.
-
-Changes from 2.12.3 to 2.12.4
------------------------------
-
-Updated CHANGES and TODO (should have been done in previous 2 patches).
-
-Changes from 2.12.2 to 2.12.3
------------------------------
-
-Brought regex.c and alloca.s into line with current FSF versions.
-
-Changes from 2.12.1 to 2.12.2
------------------------------
-
-Portability improvements; mostly moving system prototypes out of awk.h
-
-Introduction of strftime.
-
-Use of CONVFMT.
-
-Changes from 2.12 to 2.12.1
------------------------------
-
-Consolidated treatment of command-line assignments (thus correcting the
--v treatment).
-
-Rationalized builtin-variable handling into a table-driven process, thus
-simplifying variable() and eliminating spc_var().
-
-Fixed bug in handling of command-line source that ended in a newline.
-
-Simplified install() and lookup().
-
-Did away with double-mallocing of identifiers and now free second and later
-instances of a name, after the first gets installed into the symbol table.
-
-Treat IGNORECASE specially, simplifying a lot of code, and allowing
-checking against strict conformance only on setting it, rather than on each
-pattern match.
-
-Fixed regexp matching when IGNORECASE is non-zero (broken when dfa.c was
-added).
-
-Fixed bug where $0 was not being marked as valid, even after it was rebuilt.
-This caused mangling of $0.
-
-
-Changes from 2.11.1 to 2.12
------------------------------
-
-Makefile:
-
-Portability improvements in Makefile.
-Move configuration stuff into config.h
-
-FSF files:
-
-Synchronized alloca.[cs] and regex.[ch] with FSF.
-
-array.c:
-
-Rationalized hash routines into one with a different algorithm.
-delete() now works if the array is a local variable.
-Changed interface of assoc_next() and avoided dereferencing past the end of the
- array.
-
-awk.h:
-
-Merged non-prototype and prototype declarations in awk.h.
-Expanded tree_eval #define to short-circuit more calls of r_tree_eval().
-
-awk.y:
-
-Delinted some of the code in the grammar.
-Fixed and improved some of the error message printing.
-Changed to accomodate unlimited length source lines.
-Line continuation now works as advertised.
-Source lines can be arbitrarily long.
-Refined grammar hacks so that /= assignment works. Regular expressions
- starting with /= are recognized at the beginning of a line, after && or ||
- and after ~ or !~. More contexts can be added if necessary.
-Fixed IGNORECASE (multiple scans for backslash).
-Condensed expression_lists in array references.
-Detect and warn for correct # args in builtin functions -- call most of them
- with a fixed number (i.e. fill in defaults at parse-time rather than at
- run-time).
-Load ENVIRON only if it is referenced (detected at parse-time).
-Treat NF, FS, RS, NR, FNR specially at parse time, to improve run time.
-Fold constant expressions at parse time.
-Do make_regexp() on third arg. of split() at parse tiem if it is a constant.
-
-builtin.c:
-
-srand() returns 0 the first time called.
-Replaced alloca() with malloc() in do_sprintf().
-Fixed setting of RSTART and RLENGTH in do_match().
-Got rid of get_{one,two,three} and allowance for variable # of args. at
- run-time -- this is now done at parse-time.
-Fixed latent bug in [g]sub whereby changes to $0 would never get made.
-Rewrote much of sub_common() for simplicity and performance.
-Added ctime() and time() builtin functions (unless -DSTRICT). ctime() returns
- a time string like the C function, given the number of seconds since the epoch
- and time() returns the current time in seconds.
-do_sprintf() now checks for mismatch between format string and number of
- arguments supplied.
-
-dfa.c
-
-This is borrowed (almost unmodified) from GNU grep to provide faster searches.
-
-eval.c
-
-Node_var, Node_var_array and Node_param_list handled from macro rather
- than in r_tree_eval().
-Changed cmp_nodes() to not do a force_number() -- this, combined with a
- force_number() on ARGV[] and ENVIRON[] brings it into line with other awks
-Greatly simplified cmp_nodes().
-Separated out Node_NF, Node_FS, Node_RS, Node_NR and Node_FNR in get_lhs().
-All adjacent string concatenations now done at once.
-
-field.c
-
-Added support for FIELDWIDTHS.
-Fixed bug in get_field() whereby changes to a field were not always
- properly reflected in $0.
-Reordered tests in parse_field() so that reference off the end of the buffer
- doesn't happen.
-set_FS() now sets *parse_field i.e. routine to call depending on type of FS.
-It also does make_regexp() for FS if needed. get_field() passes FS_regexp
- to re_parse_field(), as does do_split().
-Changes to set_field() and set_record() to avoid malloc'ing and free'ing the
- field nodes repeatedly. The fields now just point into $0 unless they are
- assigned to another variable or changed. force_number() on the field is
- *only* done when the field is needed.
-
-gawk.1
-
-Fixed troff formatting problem on .TP lines.
-
-io.c
-
-Moved some code out into iop.c.
-Output from pipes and system() calls is properly synchronized.
-Status from pipe close properly returned.
-Bug in getline with no redirect fixed.
-
-iop.c
-
-This file contains a totally revamped get_a_record and associated code.
-
-main.c
-
-Command line programs no longer use a temporary file.
-Therefore, tmpnam() no longer required.
-Deprecated -a and -e options -- they will go away in the next release,
- but for now they cause a warning.
-Moved -C, -V, -c options to -W ala posix.
-Added -W posix option: throw out \x
-Added -W lint option.
-
-
-node.c
-
-force_number() now allows pure numerics to have leading whitespace.
-Added make_string facility to optimize case of adding an already malloc'd
- string.
-Cleaned up and simplified do_deref().
-Fixed bug in handling of stref==255 in do_deref().
-
-re.c
-
-contains the interface to regexp code
-
-Changes from 2.11.1 to FSF version of same
-------------------------------------------
-Thu Jan 4 14:19:30 1990 Jim Kingdon (kingdon at albert)
-
- * Makefile (YACC): Add -y to bison part.
-
- * missing.c: Add #include <stdio.h>.
-
-Sun Dec 24 16:16:05 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu)
-
- * * Makefile: Add (commented out) default defines for Sony News.
-
- * awk.h: Move declaration of vprintf so it will compile when
- -DVPRINTF_MISSING is defined.
-
-Mon Nov 13 18:54:08 1989 Robert J. Chassell (bob at apple-gunkies.ai.mit.edu)
-
- * gawk.texinfo: changed @-commands that are not part of the
- standard, currently released texinfmt.el to those that are.
- Otherwise, only people with the as-yet unreleased makeinfo.c can
- format this file.
-
-Changes from 2.11beta to 2.11.1 (production)
---------------------------------------------
-
-Went from "beta" to production status!!!
-
-Now flushes stdout before closing pipes or redirected files to
-synchonize output.
-
-MS-DOS changes added in.
-
-Signal handler return type parameterized in Makefile and awk.h and
-some lint removed. debug.c cleaned up.
-
-Fixed FS splitting to never match null strings, per book.
-
-Correction to the manual's description of FS.
-
-Some compilers break on char *foo = "string" + 4 so fixed version.sh and
-main.c.
-
-Changes from 2.10beta to 2.11beta
----------------------------------
-
-This release fixes all reported bugs that we could reproduce. Probably
-some of the changes are not documented here.
-
-The next release will probably not be a beta release!
-
-The most important change is the addition of the -nostalgia option. :-)
-
-The documentation has been improved and brought up-to-date.
-
-There has been a lot of general cleaning up of the code that is not otherwise
-documented here. There has been a movement toward using standard-conforming
-library routines and providing them (in missing.d) for systems lacking them.
-Improved (hopefully) configuration through Makfile modifications and missing.c.
-In particular, straightened out confusion over vprintf #defines, declarations
-etc.
-
-Deleted RCS log comments from source, to reduce source size by about one third.
-Most of them were horribly out-of-date, anyway.
-
-Renamed source files to reflect (for the most part) their contents.
-
-More and improved error messages. Cleanup and fixes to yyerror().
-String constants are not altered in input buffer, so error messages come out
-better. Fixed usage message. Make use of ANSI C strerror() function
-(provided).
-
-Plugged many more memory leaks. The memory consumption is now quite
-reasonable over a wide range of programs.
-
-Uses volatile declaration if STDC > 0 to avoid problems due to longjmp.
-
-New -a and -e options to use awk or egrep style regexps, respectively,
-since POSIX says awk should use egrep regexps. Default is -a.
-
-Added -v option for setting variables before the first file is encountered.
-Version information now uses -V and copyleft uses -C.
-
-Added a patchlevel.h file and its use for -V and -C.
-
-Append_right() optimized for major improvement to programs with a *lot*
-of statements.
-
-Operator precedence has been corrected to match draft Posix.
-
-Tightened up grammar for builtin functions so that only length
-may be called without arguments or parentheses.
-
-/regex/ is now a normal expression that can appear in any expression
-context.
-
-Allow /= to begin a regexp. Allow ..[../..].. in a regexp.
-
-Allow empty compound statements ({}).
-
-Made return and next illegal outside a function and in BEGIN/END respectively.
-
-Division by zero is now illegal and causes a fatal error.
-
-Fixed exponentiation so that x ^ 0 and x ^= 0 both return 1.
-
-Fixed do_sqrt, do_log, and do_exp to do argument/return checking and
-print an error message, per the manual.
-
-Fixed main to catch SIGSEGV to get source and data file line numbers.
-
-Fixed yyerror to print the ^ at the beginning of the bad token, not the end.
-
-Fix to substr() builtin: it was failing if the arguments
-weren't already strings.
-
-Added new node value flag NUMERIC to indicate that a variable is
-purely a number as opposed to type NUM which indicates that
-the node's numeric value is valid. This is set in make_number(),
-tmp_number and r_force_number() when appropriate and used in
-cmp_nodes(). This fixed a bug in comparison of variables that had
-numeric prefixes. The new code uses strtod() and eliminates is_a_number().
-A simple strtod() is provided for systems lacking one. It does no
-overflow checking, so could be improved.
-
-Simplification and efficiency improvement in force_string.
-
-Added performance tweak in r_force_number().
-
-Fixed a bug with nested loops and break/continue in functions.
-
-Fixed inconsistency in handling of empty fields when $0 has to be rebuilt.
-Happens to simplify rebuild_record().
-
-Cleaned up the code associated with opening a pipe for reading. Gawk
-now has its own popen routine (gawk_popen) that allocates an IOBUF
-and keeps track of the pid of the child process. gawk_pclose
-marks the appropriate child as defunct in the right struct redirect.
-
-Cleaned up and fixed close_redir().
-
-Fixed an obscure bug to do with redirection. Intermingled ">" and ">>"
-redirects did not output in a predictable order.
-
-Improved handling of output bufferring: now all print[f]s redirected to a tty
-or pipe are flushed immediately and non-redirected output to a tty is flushed
-before the next input record is read.
-
-Fixed a bug in get_a_record() where bcopy() could have copied over
-a random pointer.
-
-Fixed a bug when RS="" and records separated by multiple blank lines.
-
-Got rid of SLOWIO code which was out-of-date anyway.
-
-Fix in get_field() for case where $0 is changed and then $(n) are
-changed and then $0 is used.
-
-Fixed infinite loop on failure to open file for reading from getline.
-Now handles redirect file open failures properly.
-
-Filenames such as /dev/stdin now allowed on the command line as well as
-in redirects.
-
-Fixed so that gawk '$1' where $1 is a zero tests false.
-
-Fixed parsing so that `RLENGTH -1' parses the same as `RLENGTH - 1',
-for example.
-
-The return from a user-defined function now defaults to the Null node.
-This fixes a core-dump-causing bug when the return value of a function
-is used and that function returns no value.
-
-Now catches floating point exceptions to avoid core dumps.
-
-Bug fix for deleting elements of an array -- under some conditions, it was
-deleting more than one element at a time.
-
-Fix in AWKPATH code for running off the end of the string.
-
-Fixed handling of precision in *printf calls. %0.2d now works properly,
-as does %c. [s]printf now recognizes %i and %X.
-
-Fixed a bug in printing of very large (>240) strings.
-
-Cleaned up erroneous behaviour for RS == "".
-
-Added IGNORECASE support to index().
-
-Simplified and fixed newnode/freenode.
-
-Fixed reference to $(anything) in a BEGIN block.
-
-Eliminated use of USG rand48().
-
-Bug fix in force_string for machines with 16-bit ints.
-
-Replaced use of mktemp() with tmpnam() and provided a partial implementation of
-the latter for systems that don't have it.
-
-Added a portability check for includes in io.c.
-
-Minor portability fix in alloc.c plus addition of xmalloc().
-
-Portability fix: on UMAX4.2, st_blksize is zero for a pipe, thus breaking
-iop_alloc() -- fixed.
-
-Workaround for compiler bug on Sun386i in do_sprintf.
-
-More and improved prototypes in awk.h.
-
-Consolidated C escape parsing code into one place.
-
-strict flag is now turned on only when invoked with compatability option.
-It now applies to fewer things.
-
-Changed cast of f._ptr in vprintf.c from (unsigned char *) to (char *).
-Hopefully this is right for the systems that use this code (I don't).
-
-Support for pipes under MSDOS added.
diff --git a/gnu/usr.bin/awk/PORTS b/gnu/usr.bin/awk/PORTS
deleted file mode 100644
index 95e133f..0000000
--- a/gnu/usr.bin/awk/PORTS
+++ /dev/null
@@ -1,32 +0,0 @@
-A recent version of gawk has been successfully compiled and run "make test"
-on the following:
-
-Sun 4/490 running 4.1
-NeXT running 2.0
-DECstation 3100 running Ultrix 4.0 or Ultrix 3.1 (different config)
-AtariST (16-bit ints, gcc compiler, byacc, running under TOS)
-ESIX V.3.2 Rev D (== System V Release 3.2), the 386. compiler was gcc + bison
-IBM RS/6000 (see README.rs6000)
-486 running SVR4, using cc and bison
-SGI running IRIX 3.3 using gcc (fails with cc)
-Sequent Balance running Dynix V3.1
-Cray Y-MP8 running Unicos 6.0.11
-Cray 2 running Unicos 6.1 (modulo trailing zeroes in chem)
-VAX/VMS V5.x (should also work on 4.6 and 4.7)
-VMS POSIX V1.0, V1.1
-OpenVMS AXP V1.0
-MSDOS - Microsoft C 5.1, compiles and runs very simple testing
-BSD 4.4alpha
-
-From: ghazi@caip.rutgers.edu (Kaveh R. Ghazi):
-
-arch configured as:
----- --------------
-Hpux 9.0 hpux8x
-NeXTStep 2.0 next20
-Sgi Irix 4.0.5 (/bin/cc) sgi405.cc (new file)
-Stardent Titan 1500 OSv2.5 sysv3
-Stardent Vistra (i860) SVR4 sysv4
-SunOS 4.1.2 sunos41
-Tektronix XD88 (UTekV 3.2e) sysv3
-Ultrix 4.2 ultrix41
diff --git a/gnu/usr.bin/awk/POSIX b/gnu/usr.bin/awk/POSIX
deleted file mode 100644
index f240542..0000000
--- a/gnu/usr.bin/awk/POSIX
+++ /dev/null
@@ -1,95 +0,0 @@
-Right now, the numeric vs. string comparisons are screwed up in draft
-11.2. What prompted me to check it out was the note in gnu.bug.utils
-which observed that gawk was doing the comparison $1 == "000"
-numerically. I think that we can agree that intuitively, this should
-be done as a string comparison. Version 2.13.2 of gawk follows the
-current POSIX draft. Following is how I (now) think this
-stuff should be done.
-
-1. A numeric literal or the result of a numeric operation has the NUMERIC
- attribute.
-
-2. A string literal or the result of a string operation has the STRING
- attribute.
-
-3. Fields, getline input, FILENAME, ARGV elements, ENVIRON elements and the
- elements of an array created by split() that are numeric strings
- have the STRNUM attribute. Otherwise, they have the STRING attribute.
- Uninitialized variables also have the STRNUM attribute.
-
-4. Attributes propagate across assignments, but are not changed by
- any use. (Although a use may cause the entity to acquire an additional
- value such that it has both a numeric and string value -- this leaves the
- attribute unchanged.)
-
-When two operands are compared, either string comparison or numeric comparison
-may be used, depending on the attributes of the operands, according to the
-following (symmetric) matrix:
-
- +----------------------------------------------
- | STRING NUMERIC STRNUM
---------+----------------------------------------------
- |
-STRING | string string string
- |
-NUMERIC | string numeric numeric
- |
-STRNUM | string numeric numeric
---------+----------------------------------------------
-
-So, the following program should print all OKs.
-
-echo '0e2 0a 0 0b
-0e2 0a 0 0b' |
-$AWK '
-NR == 1 {
- num = 0
- str = "0e2"
-
- print ++test ": " ( (str == "0e2") ? "OK" : "OOPS" )
- print ++test ": " ( ("0e2" != 0) ? "OK" : "OOPS" )
- print ++test ": " ( ("0" != $2) ? "OK" : "OOPS" )
- print ++test ": " ( ("0e2" == $1) ? "OK" : "OOPS" )
-
- print ++test ": " ( (0 == "0") ? "OK" : "OOPS" )
- print ++test ": " ( (0 == num) ? "OK" : "OOPS" )
- print ++test ": " ( (0 != $2) ? "OK" : "OOPS" )
- print ++test ": " ( (0 == $1) ? "OK" : "OOPS" )
-
- print ++test ": " ( ($1 != "0") ? "OK" : "OOPS" )
- print ++test ": " ( ($1 == num) ? "OK" : "OOPS" )
- print ++test ": " ( ($2 != 0) ? "OK" : "OOPS" )
- print ++test ": " ( ($2 != $1) ? "OK" : "OOPS" )
- print ++test ": " ( ($3 == 0) ? "OK" : "OOPS" )
- print ++test ": " ( ($3 == $1) ? "OK" : "OOPS" )
- print ++test ": " ( ($2 != $4) ? "OK" : "OOPS" ) # 15
-}
-{
- a = "+2"
- b = 2
- if (NR % 2)
- c = a + b
- print ++test ": " ( (a != b) ? "OK" : "OOPS" ) # 16 and 22
-
- d = "2a"
- b = 2
- if (NR % 2)
- c = d + b
- print ++test ": " ( (d != b) ? "OK" : "OOPS" )
-
- print ++test ": " ( (d + 0 == b) ? "OK" : "OOPS" )
-
- e = "2"
- print ++test ": " ( (e == b "") ? "OK" : "OOPS" )
-
- a = "2.13"
- print ++test ": " ( (a == 2.13) ? "OK" : "OOPS" )
-
- a = "2.130000"
- print ++test ": " ( (a != 2.13) ? "OK" : "OOPS" )
-
- if (NR == 2) {
- CONVFMT = "%.6f"
- print ++test ": " ( (a == 2.13) ? "OK" : "OOPS" )
- }
-}'
diff --git a/gnu/usr.bin/awk/PROBLEMS b/gnu/usr.bin/awk/PROBLEMS
deleted file mode 100644
index 3b7c514..0000000
--- a/gnu/usr.bin/awk/PROBLEMS
+++ /dev/null
@@ -1,6 +0,0 @@
-This is a list of known problems in gawk 2.15.
-Hopefully they will all be fixed in the next major release of gawk.
-
-Please keep in mind that the code is still undergoing significant evolution.
-
-1. Gawk's printf is probably still not POSIX compliant.
diff --git a/gnu/usr.bin/awk/README b/gnu/usr.bin/awk/README
deleted file mode 100644
index f4bd3df..0000000
--- a/gnu/usr.bin/awk/README
+++ /dev/null
@@ -1,116 +0,0 @@
-README:
-
-This is GNU Awk 2.15. It should be upwardly compatible with the
-System V Release 4 awk. It is almost completely compliant with draft 11.3
-of POSIX 1003.2.
-
-This release adds new features -- see NEWS for details.
-
-See the installation instructions, below.
-
-Known problems are given in the PROBLEMS file. Work to be done is
-described briefly in the FUTURES file. Verified ports are listed in
-the PORTS file. Changes in this version are summarized in the CHANGES file.
-Please read the LIMITATIONS and ACKNOWLEDGMENT files.
-
-Read the file POSIX for a discussion of how the standard says comparisons
-should be done vs. how they really should be done and how gawk does them.
-
-To format the documentation with TeX, you must use texinfo.tex 2.53
-or later. Otherwise footnotes look unacceptable.
-
-If you wish to remake the Info files, you should use makeinfo. The 2.15
-version of makeinfo works with no errors.
-
-The man page is up to date.
-
-INSTALLATION:
-
-Check whether there is a system-specific README file for your system.
-
-Makefile.in may need some tailoring. The only changes necessary should
-be to change installation targets or to change compiler flags.
-The changes to make in Makefile.in are commented and should be obvious.
-
-All other changes should be made in a config file. Samples for
-various systems are included in the config directory. Starting with
-2.11, our intent has been to make the code conform to standards (ANSI,
-POSIX, SVID, in that order) whenever possible, and to not penalize
-standard conforming systems. We have included substitute versions of
-routines not universally available. Simply add the appropriate define
-for the missing feature(s) on your system.
-
-If you have neither bison nor yacc, use the awktab.c file here. It was
-generated with bison, and should have no AT&T code in it. (Note that
-modifying awk.y without bison or yacc will be difficult, at best. You might
-want to get a copy of bison from the FSF too.)
-
-If no config file is included for your system, start by copying one
-for a similar system. One way of determining the defines needed is to
-try to load gawk with nothing defined and see what routines are
-unresolved by the loader. This should give you a good idea of how to
-proceed.
-
-The next release will use the FSF autoconfig program, so we are no longer
-soliciting new config files.
-
-If you have an MS-DOS system, use the stuff in the pc directory.
-For an Atari there is an atari directory and similarly one for VMS.
-
-Chapter 16 of The GAWK Manual discusses configuration in detail.
-
-After successful compilation, do 'make test' to run a small test
-suite. There should be no output from the 'cmp' invocations except in
-the cases where there are small differences in floating point values.
-If there are other differences, please investigate and report the
-problem.
-
-PRINTING THE MANUAL
-
-The 'support' directory contains texinfo.tex 2.65, which will be necessary
-for printing the manual, and the texindex.c program from the texinfo
-distribution which is also necessary. See the makefile for the steps needed
-to get a DVI file from the manual.
-
-CAVEATS
-
-The existence of a patchlevel.h file does *N*O*T* imply a commitment on
-our part to issue bug fixes or patches. It is there in case we should
-decide to do so.
-
-BUG REPORTS AND FIXES (Un*x systems):
-
-Please coordinate changes through David Trueman and/or Arnold Robbins.
-
-David Trueman
-Department of Mathematics, Statistics and Computing Science,
-Dalhousie University, Halifax, Nova Scotia, Canada
-
-UUCP: {uunet utai watmath}!dalcs!david
-INTERNET: david@cs.dal.ca
-
-Arnold Robbins
-1736 Reindeer Drive
-Atlanta, GA, 30329, USA
-
-INTERNET: arnold@skeeve.atl.ga.us
-UUCP: { gatech, emory, emoryu1 }!skeeve!arnold
-
-BUG REPORTS AND FIXES (non-Unix ports):
-
-MS-DOS:
- Scott Deifik
- AMGEN Inc.
- Amgen Center, Bldg.17-Dept.393
- Thousand Oaks, CA 91320-1789
- Tel-805-499-5725 ext.4677
- Fax-805-498-0358
- scottd@amgen.com
-
-VMS:
- Pat Rankin
- rankin@eql.caltech.edu (e-mail only)
-
-Atari ST:
- Michal Jaegermann
- NTOMCZAK@vm.ucs.UAlberta.CA (e-mail only)
diff --git a/gnu/usr.bin/awk/array.c b/gnu/usr.bin/awk/array.c
deleted file mode 100644
index 59be340..0000000
--- a/gnu/usr.bin/awk/array.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * array.c - routines for associative arrays.
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-static NODE *assoc_find P((NODE *symbol, NODE *subs, int hash1));
-
-NODE *
-concat_exp(tree)
-register NODE *tree;
-{
- register NODE *r;
- char *str;
- char *s;
- unsigned len;
- int offset;
- int subseplen;
- char *subsep;
-
- if (tree->type != Node_expression_list)
- return force_string(tree_eval(tree));
- r = force_string(tree_eval(tree->lnode));
- if (tree->rnode == NULL)
- return r;
- subseplen = SUBSEP_node->lnode->stlen;
- subsep = SUBSEP_node->lnode->stptr;
- len = r->stlen + subseplen + 2;
- emalloc(str, char *, len, "concat_exp");
- memcpy(str, r->stptr, r->stlen+1);
- s = str + r->stlen;
- free_temp(r);
- tree = tree->rnode;
- while (tree) {
- if (subseplen == 1)
- *s++ = *subsep;
- else {
- memcpy(s, subsep, subseplen+1);
- s += subseplen;
- }
- r = force_string(tree_eval(tree->lnode));
- len += r->stlen + subseplen;
- offset = s - str;
- erealloc(str, char *, len, "concat_exp");
- s = str + offset;
- memcpy(s, r->stptr, r->stlen+1);
- s += r->stlen;
- free_temp(r);
- tree = tree->rnode;
- }
- r = make_str_node(str, s - str, ALREADY_MALLOCED);
- r->flags |= TEMP;
- return r;
-}
-
-/* Flush all the values in symbol[] before doing a split() */
-void
-assoc_clear(symbol)
-NODE *symbol;
-{
- int i;
- NODE *bucket, *next;
-
- if (symbol->var_array == 0)
- return;
- for (i = 0; i < HASHSIZE; i++) {
- for (bucket = symbol->var_array[i]; bucket; bucket = next) {
- next = bucket->ahnext;
- unref(bucket->ahname);
- unref(bucket->ahvalue);
- freenode(bucket);
- }
- symbol->var_array[i] = 0;
- }
-}
-
-/*
- * calculate the hash function of the string in subs
- */
-unsigned int
-hash(s, len)
-register char *s;
-register int len;
-{
- register unsigned long h = 0, g;
-
- while (len--) {
- h = (h << 4) + *s++;
- g = (h & 0xf0000000);
- if (g) {
- h = h ^ (g >> 24);
- h = h ^ g;
- }
- }
- if (h < HASHSIZE)
- return h;
- else
- return h%HASHSIZE;
-}
-
-/*
- * locate symbol[subs]
- */
-static NODE * /* NULL if not found */
-assoc_find(symbol, subs, hash1)
-NODE *symbol;
-register NODE *subs;
-int hash1;
-{
- register NODE *bucket, *prev = 0;
-
- for (bucket = symbol->var_array[hash1]; bucket; bucket = bucket->ahnext) {
- if (cmp_nodes(bucket->ahname, subs) == 0) {
- if (prev) { /* move found to front of chain */
- prev->ahnext = bucket->ahnext;
- bucket->ahnext = symbol->var_array[hash1];
- symbol->var_array[hash1] = bucket;
- }
- return bucket;
- } else
- prev = bucket; /* save previous list entry */
- }
- return NULL;
-}
-
-/*
- * test whether the array element symbol[subs] exists or not
- */
-int
-in_array(symbol, subs)
-NODE *symbol, *subs;
-{
- register int hash1;
-
- if (symbol->type == Node_param_list)
- symbol = stack_ptr[symbol->param_cnt];
- if (symbol->var_array == 0)
- return 0;
- subs = concat_exp(subs); /* concat_exp returns a string node */
- hash1 = hash(subs->stptr, subs->stlen);
- if (assoc_find(symbol, subs, hash1) == NULL) {
- free_temp(subs);
- return 0;
- } else {
- free_temp(subs);
- return 1;
- }
-}
-
-/*
- * SYMBOL is the address of the node (or other pointer) being dereferenced.
- * SUBS is a number or string used as the subscript.
- *
- * Find SYMBOL[SUBS] in the assoc array. Install it with value "" if it
- * isn't there. Returns a pointer ala get_lhs to where its value is stored
- */
-NODE **
-assoc_lookup(symbol, subs)
-NODE *symbol, *subs;
-{
- register int hash1;
- register NODE *bucket;
-
- (void) force_string(subs);
- hash1 = hash(subs->stptr, subs->stlen);
-
- if (symbol->var_array == 0) { /* this table really should grow
- * dynamically */
- unsigned size;
-
- size = sizeof(NODE *) * HASHSIZE;
- emalloc(symbol->var_array, NODE **, size, "assoc_lookup");
- memset((char *)symbol->var_array, 0, size);
- symbol->type = Node_var_array;
- } else {
- bucket = assoc_find(symbol, subs, hash1);
- if (bucket != NULL) {
- free_temp(subs);
- return &(bucket->ahvalue);
- }
- }
-
- /* It's not there, install it. */
- if (do_lint && subs->stlen == 0)
- warning("subscript of array `%s' is null string",
- symbol->vname);
- getnode(bucket);
- bucket->type = Node_ahash;
- if (subs->flags & TEMP)
- bucket->ahname = dupnode(subs);
- else {
- unsigned int saveflags = subs->flags;
-
- subs->flags &= ~MALLOC;
- bucket->ahname = dupnode(subs);
- subs->flags = saveflags;
- }
- free_temp(subs);
-
- /* array subscripts are strings */
- bucket->ahname->flags &= ~NUMBER;
- bucket->ahname->flags |= STRING;
- bucket->ahvalue = Nnull_string;
- bucket->ahnext = symbol->var_array[hash1];
- symbol->var_array[hash1] = bucket;
- return &(bucket->ahvalue);
-}
-
-void
-do_delete(symbol, tree)
-NODE *symbol, *tree;
-{
- register int hash1;
- register NODE *bucket, *last;
- NODE *subs;
-
- if (symbol->type == Node_param_list)
- symbol = stack_ptr[symbol->param_cnt];
- if (symbol->var_array == 0)
- return;
- subs = concat_exp(tree); /* concat_exp returns string node */
- hash1 = hash(subs->stptr, subs->stlen);
-
- last = NULL;
- for (bucket = symbol->var_array[hash1]; bucket; last = bucket, bucket = bucket->ahnext)
- if (cmp_nodes(bucket->ahname, subs) == 0)
- break;
- free_temp(subs);
- if (bucket == NULL)
- return;
- if (last)
- last->ahnext = bucket->ahnext;
- else
- symbol->var_array[hash1] = bucket->ahnext;
- unref(bucket->ahname);
- unref(bucket->ahvalue);
- freenode(bucket);
-}
-
-void
-assoc_scan(symbol, lookat)
-NODE *symbol;
-struct search *lookat;
-{
- if (!symbol->var_array) {
- lookat->retval = NULL;
- return;
- }
- lookat->arr_ptr = symbol->var_array;
- lookat->arr_end = lookat->arr_ptr + HASHSIZE; /* added */
- lookat->bucket = symbol->var_array[0];
- assoc_next(lookat);
-}
-
-void
-assoc_next(lookat)
-struct search *lookat;
-{
- while (lookat->arr_ptr < lookat->arr_end) {
- if (lookat->bucket != 0) {
- lookat->retval = lookat->bucket->ahname;
- lookat->bucket = lookat->bucket->ahnext;
- return;
- }
- lookat->arr_ptr++;
- if (lookat->arr_ptr < lookat->arr_end)
- lookat->bucket = *(lookat->arr_ptr);
- else
- lookat->retval = NULL;
- }
- return;
-}
diff --git a/gnu/usr.bin/awk/awk.1 b/gnu/usr.bin/awk/awk.1
deleted file mode 100644
index 0338485..0000000
--- a/gnu/usr.bin/awk/awk.1
+++ /dev/null
@@ -1,1873 +0,0 @@
-.ds PX \s-1POSIX\s+1
-.ds UX \s-1UNIX\s+1
-.ds AN \s-1ANSI\s+1
-.TH GAWK 1 "Apr 15 1993" "Free Software Foundation" "Utility Commands"
-.SH NAME
-gawk \- pattern scanning and processing language
-.SH SYNOPSIS
-.B gawk
-[ POSIX or GNU style options ]
-.B \-f
-.I program-file
-[
-.B \-\^\-
-] file .\^.\^.
-.br
-.B gawk
-[ POSIX or GNU style options ]
-[
-.B \-\^\-
-]
-.I program-text
-file .\^.\^.
-.SH DESCRIPTION
-.I Gawk
-is the GNU Project's implementation of the AWK programming language.
-It conforms to the definition of the language in
-the \*(PX 1003.2 Command Language And Utilities Standard.
-This version in turn is based on the description in
-.IR "The AWK Programming Language" ,
-by Aho, Kernighan, and Weinberger,
-with the additional features defined in the System V Release 4 version
-of \*(UX
-.IR awk .
-.I Gawk
-also provides some GNU-specific extensions.
-.PP
-The command line consists of options to
-.I gawk
-itself, the AWK program text (if not supplied via the
-.B \-f
-or
-.B \-\^\-file
-options), and values to be made
-available in the
-.B ARGC
-and
-.B ARGV
-pre-defined AWK variables.
-.SH OPTIONS
-.PP
-.I Gawk
-options may be either the traditional \*(PX one letter options,
-or the GNU style long options. \*(PX style options start with a single ``\-'',
-while GNU long options start with ``\-\^\-''.
-GNU style long options are provided for both GNU-specific features and
-for \*(PX mandated features. Other implementations of the AWK language
-are likely to only accept the traditional one letter options.
-.PP
-Following the \*(PX standard,
-.IR gawk -specific
-options are supplied via arguments to the
-.B \-W
-option. Multiple
-.B \-W
-options may be supplied, or multiple arguments may be supplied together
-if they are separated by commas, or enclosed in quotes and separated
-by white space.
-Case is ignored in arguments to the
-.B \-W
-option.
-Each
-.B \-W
-option has a corresponding GNU style long option, as detailed below.
-.PP
-.I Gawk
-accepts the following options.
-.TP
-.PD 0
-.BI \-F " fs"
-.TP
-.PD
-.BI \-\^\-field-separator= fs
-Use
-.I fs
-for the input field separator (the value of the
-.B FS
-predefined
-variable).
-.TP
-.PD 0
-\fB\-v\fI var\fB\^=\^\fIval\fR
-.TP
-.PD
-\fB\-\^\-assign=\fIvar\fB\^=\^\fIval\fR
-Assign the value
-.IR val ,
-to the variable
-.IR var ,
-before execution of the program begins.
-Such variable values are available to the
-.B BEGIN
-block of an AWK program.
-.TP
-.PD 0
-.BI \-f " program-file"
-.TP
-.PD
-.BI \-\^\-file= program-file
-Read the AWK program source from the file
-.IR program-file ,
-instead of from the first command line argument.
-Multiple
-.B \-f
-(or
-.BR \-\^\-file )
-options may be used.
-.TP \w'\fB\-\^\-copyright\fR'u+1n
-.PD 0
-.B "\-W compat"
-.TP
-.PD
-.B \-\^\-compat
-Run in
-.I compatibility
-mode. In compatibility mode,
-.I gawk
-behaves identically to \*(UX
-.IR awk ;
-none of the GNU-specific extensions are recognized.
-See
-.BR "GNU EXTENSIONS" ,
-below, for more information.
-.TP
-.PD 0
-.B "\-W copyleft"
-.TP
-.PD 0
-.B "\-W copyright"
-.TP
-.PD 0
-.B \-\^\-copyleft
-.TP
-.PD
-.B \-\^\-copyright
-Print the short version of the GNU copyright information message on
-the error output.
-.TP
-.PD 0
-.B "\-W help"
-.TP
-.PD 0
-.B "\-W usage"
-.TP
-.PD 0
-.B \-\^\-help
-.TP
-.PD
-.B \-\^\-usage
-Print a relatively short summary of the available options on
-the error output.
-.TP
-.PD 0
-.B "\-W lint"
-.TP
-.PD 0
-.B \-\^\-lint
-Provide warnings about constructs that are
-dubious or non-portable to other AWK implementations.
-.ig
-.\" This option is left undocumented, on purpose.
-.TP
-.PD 0
-.B "\-W nostalgia"
-.TP
-.PD
-.B \-\^\-nostalgia
-Provide a moment of nostalgia for long time
-.I awk
-users.
-..
-.TP
-.PD 0
-.B "\-W posix"
-.TP
-.PD
-.B \-\^\-posix
-This turns on
-.I compatibility
-mode, with the following additional restrictions:
-.RS
-.TP \w'\(bu'u+1n
-\(bu
-.B \ex
-escape sequences are not recognized.
-.TP
-\(bu
-The synonym
-.B func
-for the keyword
-.B function
-is not recognized.
-.TP
-\(bu
-The operators
-.B **
-and
-.B **=
-cannot be used in place of
-.B ^
-and
-.BR ^= .
-.RE
-.TP
-.PD 0
-.BI "\-W source=" program-text
-.TP
-.PD
-.BI \-\^\-source= program-text
-Use
-.I program-text
-as AWK program source code.
-This option allows the easy intermixing of library functions (used via the
-.B \-f
-and
-.B \-\^\-file
-options) with source code entered on the command line.
-It is intended primarily for medium to large size AWK programs used
-in shell scripts.
-.sp .5
-The
-.B "\-W source="
-form of this option uses the rest of the command line argument for
-.IR program-text ;
-no other options to
-.B \-W
-will be recognized in the same argument.
-.TP
-.PD 0
-.B "\-W version"
-.TP
-.PD
-.B \-\^\-version
-Print version information for this particular copy of
-.I gawk
-on the error output.
-This is useful mainly for knowing if the current copy of
-.I gawk
-on your system
-is up to date with respect to whatever the Free Software Foundation
-is distributing.
-.TP
-.B \-\^\-
-Signal the end of options. This is useful to allow further arguments to the
-AWK program itself to start with a ``\-''.
-This is mainly for consistency with the argument parsing convention used
-by most other \*(PX programs.
-.PP
-Any other options are flagged as illegal, but are otherwise ignored.
-.SH AWK PROGRAM EXECUTION
-.PP
-An AWK program consists of a sequence of pattern-action statements
-and optional function definitions.
-.RS
-.PP
-\fIpattern\fB { \fIaction statements\fB }\fR
-.br
-\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR
-.RE
-.PP
-.I Gawk
-first reads the program source from the
-.IR program-file (s)
-if specified, or from the first non-option argument on the command line.
-The
-.B \-f
-option may be used multiple times on the command line.
-.I Gawk
-will read the program text as if all the
-.IR program-file s
-had been concatenated together. This is useful for building libraries
-of AWK functions, without having to include them in each new AWK
-program that uses them. To use a library function in a file from a
-program typed in on the command line, specify
-.B /dev/tty
-as one of the
-.IR program-file s,
-type your program, and end it with a
-.B ^D
-(control-d).
-.PP
-The environment variable
-.B AWKPATH
-specifies a search path to use when finding source files named with
-the
-.B \-f
-option. If this variable does not exist, the default path is
-\fB".:/usr/lib/awk:/usr/local/lib/awk"\fR.
-If a file name given to the
-.B \-f
-option contains a ``/'' character, no path search is performed.
-.PP
-.I Gawk
-executes AWK programs in the following order.
-First,
-.I gawk
-compiles the program into an internal form.
-Next, all variable assignments specified via the
-.B \-v
-option are performed. Then,
-.I gawk
-executes the code in the
-.B BEGIN
-block(s) (if any),
-and then proceeds to read
-each file named in the
-.B ARGV
-array.
-If there are no files named on the command line,
-.I gawk
-reads the standard input.
-.PP
-If a filename on the command line has the form
-.IB var = val
-it is treated as a variable assignment. The variable
-.I var
-will be assigned the value
-.IR val .
-(This happens after any
-.B BEGIN
-block(s) have been run.)
-Command line variable assignment
-is most useful for dynamically assigning values to the variables
-AWK uses to control how input is broken into fields and records. It
-is also useful for controlling state if multiple passes are needed over
-a single data file.
-.PP
-If the value of a particular element of
-.B ARGV
-is empty (\fB""\fR),
-.I gawk
-skips over it.
-.PP
-For each line in the input,
-.I gawk
-tests to see if it matches any
-.I pattern
-in the AWK program.
-For each pattern that the line matches, the associated
-.I action
-is executed.
-The patterns are tested in the order they occur in the program.
-.PP
-Finally, after all the input is exhausted,
-.I gawk
-executes the code in the
-.B END
-block(s) (if any).
-.SH VARIABLES AND FIELDS
-AWK variables are dynamic; they come into existence when they are
-first used. Their values are either floating-point numbers or strings,
-or both,
-depending upon how they are used. AWK also has one dimension
-arrays; multiply dimensioned arrays may be simulated.
-Several pre-defined variables are set as a program
-runs; these will be described as needed and summarized below.
-.SS Fields
-.PP
-As each input line is read,
-.I gawk
-splits the line into
-.IR fields ,
-using the value of the
-.B FS
-variable as the field separator.
-If
-.B FS
-is a single character, fields are separated by that character.
-Otherwise,
-.B FS
-is expected to be a full regular expression.
-In the special case that
-.B FS
-is a single blank, fields are separated
-by runs of blanks and/or tabs.
-Note that the value of
-.B IGNORECASE
-(see below) will also affect how fields are split when
-.B FS
-is a regular expression.
-.PP
-If the
-.B FIELDWIDTHS
-variable is set to a space separated list of numbers, each field is
-expected to have fixed width, and
-.I gawk
-will split up the record using the specified widths. The value of
-.B FS
-is ignored.
-Assigning a new value to
-.B FS
-overrides the use of
-.BR FIELDWIDTHS ,
-and restores the default behavior.
-.PP
-Each field in the input line may be referenced by its position,
-.BR $1 ,
-.BR $2 ,
-and so on.
-.B $0
-is the whole line. The value of a field may be assigned to as well.
-Fields need not be referenced by constants:
-.RS
-.PP
-.ft B
-n = 5
-.br
-print $n
-.ft R
-.RE
-.PP
-prints the fifth field in the input line.
-The variable
-.B NF
-is set to the total number of fields in the input line.
-.PP
-References to non-existent fields (i.e. fields after
-.BR $NF )
-produce the null-string. However, assigning to a non-existent field
-(e.g.,
-.BR "$(NF+2) = 5" )
-will increase the value of
-.BR NF ,
-create any intervening fields with the null string as their value, and
-cause the value of
-.B $0
-to be recomputed, with the fields being separated by the value of
-.BR OFS .
-.SS Built-in Variables
-.PP
-AWK's built-in variables are:
-.PP
-.TP \w'\fBFIELDWIDTHS\fR'u+1n
-.B ARGC
-The number of command line arguments (does not include options to
-.IR gawk ,
-or the program source).
-.TP
-.B ARGIND
-The index in
-.B ARGV
-of the current file being processed.
-.TP
-.B ARGV
-Array of command line arguments. The array is indexed from
-0 to
-.B ARGC
-\- 1.
-Dynamically changing the contents of
-.B ARGV
-can control the files used for data.
-.TP
-.B CONVFMT
-The conversion format for numbers, \fB"%.6g"\fR, by default.
-.TP
-.B ENVIRON
-An array containing the values of the current environment.
-The array is indexed by the environment variables, each element being
-the value of that variable (e.g., \fBENVIRON["HOME"]\fP might be
-.BR /u/arnold ).
-Changing this array does not affect the environment seen by programs which
-.I gawk
-spawns via redirection or the
-.B system()
-function.
-(This may change in a future version of
-.IR gawk .)
-.\" but don't hold your breath...
-.TP
-.B ERRNO
-If a system error occurs either doing a redirection for
-.BR getline ,
-during a read for
-.BR getline ,
-or during a
-.BR close ,
-then
-.B ERRNO
-will contain
-a string describing the error.
-.TP
-.B FIELDWIDTHS
-A white-space separated list of fieldwidths. When set,
-.I gawk
-parses the input into fields of fixed width, instead of using the
-value of the
-.B FS
-variable as the field separator.
-The fixed field width facility is still experimental; expect the
-semantics to change as
-.I gawk
-evolves over time.
-.TP
-.B FILENAME
-The name of the current input file.
-If no files are specified on the command line, the value of
-.B FILENAME
-is ``\-''.
-.TP
-.B FNR
-The input record number in the current input file.
-.TP
-.B FS
-The input field separator, a blank by default.
-.TP
-.B IGNORECASE
-Controls the case-sensitivity of all regular expression operations. If
-.B IGNORECASE
-has a non-zero value, then pattern matching in rules,
-field splitting with
-.BR FS ,
-regular expression
-matching with
-.B ~
-and
-.BR !~ ,
-and the
-.BR gsub() ,
-.BR index() ,
-.BR match() ,
-.BR split() ,
-and
-.B sub()
-pre-defined functions will all ignore case when doing regular expression
-operations. Thus, if
-.B IGNORECASE
-is not equal to zero,
-.B /aB/
-matches all of the strings \fB"ab"\fP, \fB"aB"\fP, \fB"Ab"\fP,
-and \fB"AB"\fP.
-As with all AWK variables, the initial value of
-.B IGNORECASE
-is zero, so all regular expression operations are normally case-sensitive.
-.TP
-.B NF
-The number of fields in the current input record.
-.TP
-.B NR
-The total number of input records seen so far.
-.TP
-.B OFMT
-The output format for numbers, \fB"%.6g"\fR, by default.
-.TP
-.B OFS
-The output field separator, a blank by default.
-.TP
-.B ORS
-The output record separator, by default a newline.
-.TP
-.B RS
-The input record separator, by default a newline.
-.B RS
-is exceptional in that only the first character of its string
-value is used for separating records.
-(This will probably change in a future release of
-.IR gawk .)
-If
-.B RS
-is set to the null string, then records are separated by
-blank lines.
-When
-.B RS
-is set to the null string, then the newline character always acts as
-a field separator, in addition to whatever value
-.B FS
-may have.
-.TP
-.B RSTART
-The index of the first character matched by
-.BR match() ;
-0 if no match.
-.TP
-.B RLENGTH
-The length of the string matched by
-.BR match() ;
-\-1 if no match.
-.TP
-.B SUBSEP
-The character used to separate multiple subscripts in array
-elements, by default \fB"\e034"\fR.
-.SS Arrays
-.PP
-Arrays are subscripted with an expression between square brackets
-.RB ( [ " and " ] ).
-If the expression is an expression list
-.RI ( expr ", " expr " ...)"
-then the array subscript is a string consisting of the
-concatenation of the (string) value of each expression,
-separated by the value of the
-.B SUBSEP
-variable.
-This facility is used to simulate multiply dimensioned
-arrays. For example:
-.PP
-.RS
-.ft B
-i = "A" ;\^ j = "B" ;\^ k = "C"
-.br
-x[i, j, k] = "hello, world\en"
-.ft R
-.RE
-.PP
-assigns the string \fB"hello, world\en"\fR to the element of the array
-.B x
-which is indexed by the string \fB"A\e034B\e034C"\fR. All arrays in AWK
-are associative, i.e. indexed by string values.
-.PP
-The special operator
-.B in
-may be used in an
-.B if
-or
-.B while
-statement to see if an array has an index consisting of a particular
-value.
-.PP
-.RS
-.ft B
-.nf
-if (val in array)
- print array[val]
-.fi
-.ft
-.RE
-.PP
-If the array has multiple subscripts, use
-.BR "(i, j) in array" .
-.PP
-The
-.B in
-construct may also be used in a
-.B for
-loop to iterate over all the elements of an array.
-.PP
-An element may be deleted from an array using the
-.B delete
-statement.
-.SS Variable Typing And Conversion
-.PP
-Variables and fields
-may be (floating point) numbers, or strings, or both. How the
-value of a variable is interpreted depends upon its context. If used in
-a numeric expression, it will be treated as a number, if used as a string
-it will be treated as a string.
-.PP
-To force a variable to be treated as a number, add 0 to it; to force it
-to be treated as a string, concatenate it with the null string.
-.PP
-When a string must be converted to a number, the conversion is accomplished
-using
-.IR atof (3).
-A number is converted to a string by using the value of
-.B CONVFMT
-as a format string for
-.IR sprintf (3),
-with the numeric value of the variable as the argument.
-However, even though all numbers in AWK are floating-point,
-integral values are
-.I always
-converted as integers. Thus, given
-.PP
-.RS
-.ft B
-.nf
-CONVFMT = "%2.2f"
-a = 12
-b = a ""
-.fi
-.ft R
-.RE
-.PP
-the variable
-.B b
-has a value of \fB"12"\fR and not \fB"12.00"\fR.
-.PP
-.I Gawk
-performs comparisons as follows:
-If two variables are numeric, they are compared numerically.
-If one value is numeric and the other has a string value that is a
-``numeric string,'' then comparisons are also done numerically.
-Otherwise, the numeric value is converted to a string and a string
-comparison is performed.
-Two strings are compared, of course, as strings.
-According to the \*(PX standard, even if two strings are
-numeric strings, a numeric comparison is performed. However, this is
-clearly incorrect, and
-.I gawk
-does not do this.
-.PP
-Uninitialized variables have the numeric value 0 and the string value ""
-(the null, or empty, string).
-.SH PATTERNS AND ACTIONS
-AWK is a line oriented language. The pattern comes first, and then the
-action. Action statements are enclosed in
-.B {
-and
-.BR } .
-Either the pattern may be missing, or the action may be missing, but,
-of course, not both. If the pattern is missing, the action will be
-executed for every single line of input.
-A missing action is equivalent to
-.RS
-.PP
-.B "{ print }"
-.RE
-.PP
-which prints the entire line.
-.PP
-Comments begin with the ``#'' character, and continue until the
-end of the line.
-Blank lines may be used to separate statements.
-Normally, a statement ends with a newline, however, this is not the
-case for lines ending in
-a ``,'', ``{'', ``?'', ``:'', ``&&'', or ``||''.
-Lines ending in
-.B do
-or
-.B else
-also have their statements automatically continued on the following line.
-In other cases, a line can be continued by ending it with a ``\e'',
-in which case the newline will be ignored.
-.PP
-Multiple statements may
-be put on one line by separating them with a ``;''.
-This applies to both the statements within the action part of a
-pattern-action pair (the usual case),
-and to the pattern-action statements themselves.
-.SS Patterns
-AWK patterns may be one of the following:
-.PP
-.RS
-.nf
-.B BEGIN
-.B END
-.BI / "regular expression" /
-.I "relational expression"
-.IB pattern " && " pattern
-.IB pattern " || " pattern
-.IB pattern " ? " pattern " : " pattern
-.BI ( pattern )
-.BI ! " pattern"
-.IB pattern1 ", " pattern2
-.fi
-.RE
-.PP
-.B BEGIN
-and
-.B END
-are two special kinds of patterns which are not tested against
-the input.
-The action parts of all
-.B BEGIN
-patterns are merged as if all the statements had
-been written in a single
-.B BEGIN
-block. They are executed before any
-of the input is read. Similarly, all the
-.B END
-blocks are merged,
-and executed when all the input is exhausted (or when an
-.B exit
-statement is executed).
-.B BEGIN
-and
-.B END
-patterns cannot be combined with other patterns in pattern expressions.
-.B BEGIN
-and
-.B END
-patterns cannot have missing action parts.
-.PP
-For
-.BI / "regular expression" /
-patterns, the associated statement is executed for each input line that matches
-the regular expression.
-Regular expressions are the same as those in
-.IR egrep (1),
-and are summarized below.
-.PP
-A
-.I "relational expression"
-may use any of the operators defined below in the section on actions.
-These generally test whether certain fields match certain regular expressions.
-.PP
-The
-.BR && ,
-.BR || ,
-and
-.B !
-operators are logical AND, logical OR, and logical NOT, respectively, as in C.
-They do short-circuit evaluation, also as in C, and are used for combining
-more primitive pattern expressions. As in most languages, parentheses
-may be used to change the order of evaluation.
-.PP
-The
-.B ?\^:
-operator is like the same operator in C. If the first pattern is true
-then the pattern used for testing is the second pattern, otherwise it is
-the third. Only one of the second and third patterns is evaluated.
-.PP
-The
-.IB pattern1 ", " pattern2
-form of an expression is called a range pattern.
-It matches all input records starting with a line that matches
-.IR pattern1 ,
-and continuing until a record that matches
-.IR pattern2 ,
-inclusive. It does not combine with any other sort of pattern expression.
-.SS Regular Expressions
-Regular expressions are the extended kind found in
-.IR egrep .
-They are composed of characters as follows:
-.TP \w'\fB[^\fIabc...\fB]\fR'u+2n
-.I c
-matches the non-metacharacter
-.IR c .
-.TP
-.I \ec
-matches the literal character
-.IR c .
-.TP
-.B .
-matches any character except newline.
-.TP
-.B ^
-matches the beginning of a line or a string.
-.TP
-.B $
-matches the end of a line or a string.
-.TP
-.BI [ abc... ]
-character class, matches any of the characters
-.IR abc... .
-.TP
-.BI [^ abc... ]
-negated character class, matches any character except
-.I abc...
-and newline.
-.TP
-.IB r1 | r2
-alternation: matches either
-.I r1
-or
-.IR r2 .
-.TP
-.I r1r2
-concatenation: matches
-.IR r1 ,
-and then
-.IR r2 .
-.TP
-.IB r +
-matches one or more
-.IR r 's.
-.TP
-.IB r *
-matches zero or more
-.IR r 's.
-.TP
-.IB r ?
-matches zero or one
-.IR r 's.
-.TP
-.BI ( r )
-grouping: matches
-.IR r .
-.PP
-The escape sequences that are valid in string constants (see below)
-are also legal in regular expressions.
-.SS Actions
-Action statements are enclosed in braces,
-.B {
-and
-.BR } .
-Action statements consist of the usual assignment, conditional, and looping
-statements found in most languages. The operators, control statements,
-and input/output statements
-available are patterned after those in C.
-.SS Operators
-.PP
-The operators in AWK, in order of increasing precedence, are
-.PP
-.TP "\w'\fB*= /= %= ^=\fR'u+1n"
-.PD 0
-.B "= += \-="
-.TP
-.PD
-.B "*= /= %= ^="
-Assignment. Both absolute assignment
-.BI ( var " = " value )
-and operator-assignment (the other forms) are supported.
-.TP
-.B ?:
-The C conditional expression. This has the form
-.IB expr1 " ? " expr2 " : " expr3\c
-\&. If
-.I expr1
-is true, the value of the expression is
-.IR expr2 ,
-otherwise it is
-.IR expr3 .
-Only one of
-.I expr2
-and
-.I expr3
-is evaluated.
-.TP
-.B ||
-Logical OR.
-.TP
-.B &&
-Logical AND.
-.TP
-.B "~ !~"
-Regular expression match, negated match.
-.B NOTE:
-Do not use a constant regular expression
-.RB ( /foo/ )
-on the left-hand side of a
-.B ~
-or
-.BR !~ .
-Only use one on the right-hand side. The expression
-.BI "/foo/ ~ " exp
-has the same meaning as \fB(($0 ~ /foo/) ~ \fIexp\fB)\fR.
-This is usually
-.I not
-what was intended.
-.TP
-.PD 0
-.B "< >"
-.TP
-.PD 0
-.B "<= >="
-.TP
-.PD
-.B "!= =="
-The regular relational operators.
-.TP
-.I blank
-String concatenation.
-.TP
-.B "+ \-"
-Addition and subtraction.
-.TP
-.B "* / %"
-Multiplication, division, and modulus.
-.TP
-.B "+ \- !"
-Unary plus, unary minus, and logical negation.
-.TP
-.B ^
-Exponentiation (\fB**\fR may also be used, and \fB**=\fR for
-the assignment operator).
-.TP
-.B "++ \-\^\-"
-Increment and decrement, both prefix and postfix.
-.TP
-.B $
-Field reference.
-.SS Control Statements
-.PP
-The control statements are
-as follows:
-.PP
-.RS
-.nf
-\fBif (\fIcondition\fB) \fIstatement\fR [ \fBelse\fI statement \fR]
-\fBwhile (\fIcondition\fB) \fIstatement \fR
-\fBdo \fIstatement \fBwhile (\fIcondition\fB)\fR
-\fBfor (\fIexpr1\fB; \fIexpr2\fB; \fIexpr3\fB) \fIstatement\fR
-\fBfor (\fIvar \fBin\fI array\fB) \fIstatement\fR
-\fBbreak\fR
-\fBcontinue\fR
-\fBdelete \fIarray\^\fB[\^\fIindex\^\fB]\fR
-\fBexit\fR [ \fIexpression\fR ]
-\fB{ \fIstatements \fB}
-.fi
-.RE
-.SS "I/O Statements"
-.PP
-The input/output statements are as follows:
-.PP
-.TP "\w'\fBprintf \fIfmt, expr-list\fR'u+1n"
-.BI close( filename )
-Close file (or pipe, see below).
-.TP
-.B getline
-Set
-.B $0
-from next input record; set
-.BR NF ,
-.BR NR ,
-.BR FNR .
-.TP
-.BI "getline <" file
-Set
-.B $0
-from next record of
-.IR file ;
-set
-.BR NF .
-.TP
-.BI getline " var"
-Set
-.I var
-from next input record; set
-.BR NF ,
-.BR FNR .
-.TP
-.BI getline " var" " <" file
-Set
-.I var
-from next record of
-.IR file .
-.TP
-.B next
-Stop processing the current input record. The next input record
-is read and processing starts over with the first pattern in the
-AWK program. If the end of the input data is reached, the
-.B END
-block(s), if any, are executed.
-.TP
-.B "next file"
-Stop processing the current input file. The next input record read
-comes from the next input file.
-.B FILENAME
-is updated,
-.B FNR
-is reset to 1, and processing starts over with the first pattern in the
-AWK program. If the end of the input data is reached, the
-.B END
-block(s), if any, are executed.
-.TP
-.B print
-Prints the current record.
-.TP
-.BI print " expr-list"
-Prints expressions.
-.TP
-.BI print " expr-list" " >" file
-Prints expressions on
-.IR file .
-.TP
-.BI printf " fmt, expr-list"
-Format and print.
-.TP
-.BI printf " fmt, expr-list" " >" file
-Format and print on
-.IR file .
-.TP
-.BI system( cmd-line )
-Execute the command
-.IR cmd-line ,
-and return the exit status.
-(This may not be available on non-\*(PX systems.)
-.PP
-Other input/output redirections are also allowed. For
-.B print
-and
-.BR printf ,
-.BI >> file
-appends output to the
-.IR file ,
-while
-.BI | " command"
-writes on a pipe.
-In a similar fashion,
-.IB command " | getline"
-pipes into
-.BR getline .
-.BR Getline
-will return 0 on end of file, and \-1 on an error.
-.SS The \fIprintf\fP\^ Statement
-.PP
-The AWK versions of the
-.B printf
-statement and
-.B sprintf()
-function
-(see below)
-accept the following conversion specification formats:
-.TP
-.B %c
-An \s-1ASCII\s+1 character.
-If the argument used for
-.B %c
-is numeric, it is treated as a character and printed.
-Otherwise, the argument is assumed to be a string, and the only first
-character of that string is printed.
-.TP
-.B %d
-A decimal number (the integer part).
-.TP
-.B %i
-Just like
-.BR %d .
-.TP
-.B %e
-A floating point number of the form
-.BR [\-]d.ddddddE[+\^\-]dd .
-.TP
-.B %f
-A floating point number of the form
-.BR [\-]ddd.dddddd .
-.TP
-.B %g
-Use
-.B e
-or
-.B f
-conversion, whichever is shorter, with nonsignificant zeros suppressed.
-.TP
-.B %o
-An unsigned octal number (again, an integer).
-.TP
-.B %s
-A character string.
-.TP
-.B %x
-An unsigned hexadecimal number (an integer).
-.TP
-.B %X
-Like
-.BR %x ,
-but using
-.B ABCDEF
-instead of
-.BR abcdef .
-.TP
-.B %%
-A single
-.B %
-character; no argument is converted.
-.PP
-There are optional, additional parameters that may lie between the
-.B %
-and the control letter:
-.TP
-.B \-
-The expression should be left-justified within its field.
-.TP
-.I width
-The field should be padded to this width. If the number has a leading
-zero, then the field will be padded with zeros.
-Otherwise it is padded with blanks.
-.TP
-.BI . prec
-A number indicating the maximum width of strings or digits to the right
-of the decimal point.
-.PP
-The dynamic
-.I width
-and
-.I prec
-capabilities of the \*(AN C
-.B printf()
-routines are supported.
-A
-.B *
-in place of either the
-.B width
-or
-.B prec
-specifications will cause their values to be taken from
-the argument list to
-.B printf
-or
-.BR sprintf() .
-.SS Special File Names
-.PP
-When doing I/O redirection from either
-.B print
-or
-.B printf
-into a file,
-or via
-.B getline
-from a file,
-.I gawk
-recognizes certain special filenames internally. These filenames
-allow access to open file descriptors inherited from
-.IR gawk 's
-parent process (usually the shell).
-Other special filenames provide access information about the running
-.B gawk
-process.
-The filenames are:
-.TP \w'\fB/dev/stdout\fR'u+1n
-.B /dev/pid
-Reading this file returns the process ID of the current process,
-in decimal, terminated with a newline.
-.TP
-.B /dev/ppid
-Reading this file returns the parent process ID of the current process,
-in decimal, terminated with a newline.
-.TP
-.B /dev/pgrpid
-Reading this file returns the process group ID of the current process,
-in decimal, terminated with a newline.
-.TP
-.B /dev/user
-Reading this file returns a single record terminated with a newline.
-The fields are separated with blanks.
-.B $1
-is the value of the
-.IR getuid (2)
-system call,
-.B $2
-is the value of the
-.IR geteuid (2)
-system call,
-.B $3
-is the value of the
-.IR getgid (2)
-system call, and
-.B $4
-is the value of the
-.IR getegid (2)
-system call.
-If there are any additional fields, they are the group IDs returned by
-.IR getgroups (2).
-(Multiple groups may not be supported on all systems.)
-.TP
-.B /dev/stdin
-The standard input.
-.TP
-.B /dev/stdout
-The standard output.
-.TP
-.B /dev/stderr
-The standard error output.
-.TP
-.BI /dev/fd/\^ n
-The file associated with the open file descriptor
-.IR n .
-.PP
-These are particularly useful for error messages. For example:
-.PP
-.RS
-.ft B
-print "You blew it!" > "/dev/stderr"
-.ft R
-.RE
-.PP
-whereas you would otherwise have to use
-.PP
-.RS
-.ft B
-print "You blew it!" | "cat 1>&2"
-.ft R
-.RE
-.PP
-These file names may also be used on the command line to name data files.
-.SS Numeric Functions
-.PP
-AWK has the following pre-defined arithmetic functions:
-.PP
-.TP \w'\fBsrand(\^\fIexpr\^\fB)\fR'u+1n
-.BI atan2( y , " x" )
-returns the arctangent of
-.I y/x
-in radians.
-.TP
-.BI cos( expr )
-returns the cosine in radians.
-.TP
-.BI exp( expr )
-the exponential function.
-.TP
-.BI int( expr )
-truncates to integer.
-.TP
-.BI log( expr )
-the natural logarithm function.
-.TP
-.B rand()
-returns a random number between 0 and 1.
-.TP
-.BI sin( expr )
-returns the sine in radians.
-.TP
-.BI sqrt( expr )
-the square root function.
-.TP
-.BI srand( expr )
-use
-.I expr
-as a new seed for the random number generator. If no
-.I expr
-is provided, the time of day will be used.
-The return value is the previous seed for the random
-number generator.
-.SS String Functions
-.PP
-AWK has the following pre-defined string functions:
-.PP
-.TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n"
-\fBgsub(\fIr\fB, \fIs\fB, \fIt\fB)\fR
-for each substring matching the regular expression
-.I r
-in the string
-.IR t ,
-substitute the string
-.IR s ,
-and return the number of substitutions.
-If
-.I t
-is not supplied, use
-.BR $0 .
-.TP
-.BI index( s , " t" )
-returns the index of the string
-.I t
-in the string
-.IR s ,
-or 0 if
-.I t
-is not present.
-.TP
-.BI length( s )
-returns the length of the string
-.IR s ,
-or the length of
-.B $0
-if
-.I s
-is not supplied.
-.TP
-.BI match( s , " r" )
-returns the position in
-.I s
-where the regular expression
-.I r
-occurs, or 0 if
-.I r
-is not present, and sets the values of
-.B RSTART
-and
-.BR RLENGTH .
-.TP
-\fBsplit(\fIs\fB, \fIa\fB, \fIr\fB)\fR
-splits the string
-.I s
-into the array
-.I a
-on the regular expression
-.IR r ,
-and returns the number of fields. If
-.I r
-is omitted,
-.B FS
-is used instead.
-.TP
-.BI sprintf( fmt , " expr-list" )
-prints
-.I expr-list
-according to
-.IR fmt ,
-and returns the resulting string.
-.TP
-\fBsub(\fIr\fB, \fIs\fB, \fIt\fB)\fR
-just like
-.BR gsub() ,
-but only the first matching substring is replaced.
-.TP
-\fBsubstr(\fIs\fB, \fIi\fB, \fIn\fB)\fR
-returns the
-.IR n -character
-substring of
-.I s
-starting at
-.IR i .
-If
-.I n
-is omitted, the rest of
-.I s
-is used.
-.TP
-.BI tolower( str )
-returns a copy of the string
-.IR str ,
-with all the upper-case characters in
-.I str
-translated to their corresponding lower-case counterparts.
-Non-alphabetic characters are left unchanged.
-.TP
-.BI toupper( str )
-returns a copy of the string
-.IR str ,
-with all the lower-case characters in
-.I str
-translated to their corresponding upper-case counterparts.
-Non-alphabetic characters are left unchanged.
-.SS Time Functions
-.PP
-Since one of the primary uses of AWK programs is processing log files
-that contain time stamp information,
-.I gawk
-provides the following two functions for obtaining time stamps and
-formatting them.
-.PP
-.TP "\w'\fBsystime()\fR'u+1n"
-.B systime()
-returns the current time of day as the number of seconds since the Epoch
-(Midnight UTC, January 1, 1970 on \*(PX systems).
-.TP
-\fBstrftime(\fIformat\fR, \fItimestamp\fB)\fR
-formats
-.I timestamp
-according to the specification in
-.IR format.
-The
-.I timestamp
-should be of the same form as returned by
-.BR systime() .
-If
-.I timestamp
-is missing, the current time of day is used.
-See the specification for the
-.B strftime()
-function in \*(AN C for the format conversions that are
-guaranteed to be available.
-A public-domain version of
-.IR strftime (3)
-and a man page for it are shipped with
-.IR gawk ;
-if that version was used to build
-.IR gawk ,
-then all of the conversions described in that man page are available to
-.IR gawk.
-.SS String Constants
-.PP
-String constants in AWK are sequences of characters enclosed
-between double quotes (\fB"\fR). Within strings, certain
-.I "escape sequences"
-are recognized, as in C. These are:
-.PP
-.TP \w'\fB\e\^\fIddd\fR'u+1n
-.B \e\e
-A literal backslash.
-.TP
-.B \ea
-The ``alert'' character; usually the \s-1ASCII\s+1 \s-1BEL\s+1 character.
-.TP
-.B \eb
-backspace.
-.TP
-.B \ef
-form-feed.
-.TP
-.B \en
-new line.
-.TP
-.B \er
-carriage return.
-.TP
-.B \et
-horizontal tab.
-.TP
-.B \ev
-vertical tab.
-.TP
-.BI \ex "\^hex digits"
-The character represented by the string of hexadecimal digits following
-the
-.BR \ex .
-As in \*(AN C, all following hexadecimal digits are considered part of
-the escape sequence.
-(This feature should tell us something about language design by committee.)
-E.g., "\ex1B" is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character.
-.TP
-.BI \e ddd
-The character represented by the 1-, 2-, or 3-digit sequence of octal
-digits. E.g. "\e033" is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character.
-.TP
-.BI \e c
-The literal character
-.IR c\^ .
-.PP
-The escape sequences may also be used inside constant regular expressions
-(e.g.,
-.B "/[\ \et\ef\en\er\ev]/"
-matches whitespace characters).
-.SH FUNCTIONS
-Functions in AWK are defined as follows:
-.PP
-.RS
-\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements \fB}\fR
-.RE
-.PP
-Functions are executed when called from within the action parts of regular
-pattern-action statements. Actual parameters supplied in the function
-call are used to instantiate the formal parameters declared in the function.
-Arrays are passed by reference, other variables are passed by value.
-.PP
-Since functions were not originally part of the AWK language, the provision
-for local variables is rather clumsy: They are declared as extra parameters
-in the parameter list. The convention is to separate local variables from
-real parameters by extra spaces in the parameter list. For example:
-.PP
-.RS
-.ft B
-.nf
-function f(p, q, a, b) { # a & b are local
- ..... }
-
-/abc/ { ... ; f(1, 2) ; ... }
-.fi
-.ft R
-.RE
-.PP
-The left parenthesis in a function call is required
-to immediately follow the function name,
-without any intervening white space.
-This is to avoid a syntactic ambiguity with the concatenation operator.
-This restriction does not apply to the built-in functions listed above.
-.PP
-Functions may call each other and may be recursive.
-Function parameters used as local variables are initialized
-to the null string and the number zero upon function invocation.
-.PP
-The word
-.B func
-may be used in place of
-.BR function .
-.SH EXAMPLES
-.nf
-Print and sort the login names of all users:
-
-.ft B
- BEGIN { FS = ":" }
- { print $1 | "sort" }
-
-.ft R
-Count lines in a file:
-
-.ft B
- { nlines++ }
- END { print nlines }
-
-.ft R
-Precede each line by its number in the file:
-
-.ft B
- { print FNR, $0 }
-
-.ft R
-Concatenate and line number (a variation on a theme):
-
-.ft B
- { print NR, $0 }
-.ft R
-.fi
-.SH SEE ALSO
-.IR egrep (1)
-.PP
-.IR "The AWK Programming Language" ,
-Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger,
-Addison-Wesley, 1988. ISBN 0-201-07981-X.
-.PP
-.IR "The GAWK Manual" ,
-Edition 0.15, published by the Free Software Foundation, 1993.
-.SH POSIX COMPATIBILITY
-A primary goal for
-.I gawk
-is compatibility with the \*(PX standard, as well as with the
-latest version of \*(UX
-.IR awk .
-To this end,
-.I gawk
-incorporates the following user visible
-features which are not described in the AWK book,
-but are part of
-.I awk
-in System V Release 4, and are in the \*(PX standard.
-.PP
-The
-.B \-v
-option for assigning variables before program execution starts is new.
-The book indicates that command line variable assignment happens when
-.I awk
-would otherwise open the argument as a file, which is after the
-.B BEGIN
-block is executed. However, in earlier implementations, when such an
-assignment appeared before any file names, the assignment would happen
-.I before
-the
-.B BEGIN
-block was run. Applications came to depend on this ``feature.''
-When
-.I awk
-was changed to match its documentation, this option was added to
-accomodate applications that depended upon the old behavior.
-(This feature was agreed upon by both the AT&T and GNU developers.)
-.PP
-The
-.B \-W
-option for implementation specific features is from the \*(PX standard.
-.PP
-When processing arguments,
-.I gawk
-uses the special option ``\fB\-\^\-\fP'' to signal the end of
-arguments, and warns about, but otherwise ignores, undefined options.
-.PP
-The AWK book does not define the return value of
-.BR srand() .
-The System V Release 4 version of \*(UX
-.I awk
-(and the \*(PX standard)
-has it return the seed it was using, to allow keeping track
-of random number sequences. Therefore
-.B srand()
-in
-.I gawk
-also returns its current seed.
-.PP
-Other new features are:
-The use of multiple
-.B \-f
-options (from MKS
-.IR awk );
-the
-.B ENVIRON
-array; the
-.BR \ea ,
-and
-.BR \ev
-escape sequences (done originally in
-.I gawk
-and fed back into AT&T's); the
-.B tolower()
-and
-.B toupper()
-built-in functions (from AT&T); and the \*(AN C conversion specifications in
-.B printf
-(done first in AT&T's version).
-.SH GNU EXTENSIONS
-.I Gawk
-has some extensions to \*(PX
-.IR awk .
-They are described in this section. All the extensions described here
-can be disabled by
-invoking
-.I gawk
-with the
-.B "\-W compat"
-option.
-.PP
-The following features of
-.I gawk
-are not available in
-\*(PX
-.IR awk .
-.RS
-.TP \w'\(bu'u+1n
-\(bu
-The
-.B \ex
-escape sequence.
-.TP
-\(bu
-The
-.B systime()
-and
-.B strftime()
-functions.
-.TP
-\(bu
-The special file names available for I/O redirection are not recognized.
-.TP
-\(bu
-The
-.B ARGIND
-and
-.B ERRNO
-variables are not special.
-.TP
-\(bu
-The
-.B IGNORECASE
-variable and its side-effects are not available.
-.TP
-\(bu
-The
-.B FIELDWIDTHS
-variable and fixed width field splitting.
-.TP
-\(bu
-No path search is performed for files named via the
-.B \-f
-option. Therefore the
-.B AWKPATH
-environment variable is not special.
-.TP
-\(bu
-The use of
-.B "next file"
-to abandon processing of the current input file.
-.RE
-.PP
-The AWK book does not define the return value of the
-.B close()
-function.
-.IR Gawk\^ 's
-.B close()
-returns the value from
-.IR fclose (3),
-or
-.IR pclose (3),
-when closing a file or pipe, respectively.
-.PP
-When
-.I gawk
-is invoked with the
-.B "\-W compat"
-option,
-if the
-.I fs
-argument to the
-.B \-F
-option is ``t'', then
-.B FS
-will be set to the tab character.
-Since this is a rather ugly special case, it is not the default behavior.
-This behavior also does not occur if
-.B \-Wposix
-has been specified.
-.ig
-.PP
-If
-.I gawk
-was compiled for debugging, it will
-accept the following additional options:
-.TP
-.PD 0
-.B \-Wparsedebug
-.TP
-.PD
-.B \-\^\-parsedebug
-Turn on
-.IR yacc (1)
-or
-.IR bison (1)
-debugging output during program parsing.
-This option should only be of interest to the
-.I gawk
-maintainers, and may not even be compiled into
-.IR gawk .
-..
-.SH HISTORICAL FEATURES
-There are two features of historical AWK implementations that
-.I gawk
-supports.
-First, it is possible to call the
-.B length()
-built-in function not only with no argument, but even without parentheses!
-Thus,
-.RS
-.PP
-.ft B
-a = length
-.ft R
-.RE
-.PP
-is the same as either of
-.RS
-.PP
-.ft B
-a = length()
-.br
-a = length($0)
-.ft R
-.RE
-.PP
-This feature is marked as ``deprecated'' in the \*(PX standard, and
-.I gawk
-will issue a warning about its use if
-.B \-Wlint
-is specified on the command line.
-.PP
-The other feature is the use of the
-.B continue
-statement outside the body of a
-.BR while ,
-.BR for ,
-or
-.B do
-loop. Traditional AWK implementations have treated such usage as
-equivalent to the
-.B next
-statement.
-.I Gawk
-will support this usage if
-.B \-Wposix
-has not been specified.
-.SH BUGS
-The
-.B \-F
-option is not necessary given the command line variable assignment feature;
-it remains only for backwards compatibility.
-.PP
-If your system actually has support for
-.B /dev/fd
-and the associated
-.BR /dev/stdin ,
-.BR /dev/stdout ,
-and
-.B /dev/stderr
-files, you may get different output from
-.I gawk
-than you would get on a system without those files. When
-.I gawk
-interprets these files internally, it synchronizes output to the standard
-output with output to
-.BR /dev/stdout ,
-while on a system with those files, the output is actually to different
-open files.
-Caveat Emptor.
-.SH VERSION INFORMATION
-This man page documents
-.IR gawk ,
-version 2.15.
-.PP
-Starting with the 2.15 version of
-.IR gawk ,
-the
-.BR \-c ,
-.BR \-V ,
-.BR \-C ,
-.ig
-.BR \-D ,
-..
-.BR \-a ,
-and
-.B \-e
-options of the 2.11 version are no longer recognized.
-.SH AUTHORS
-The original version of \*(UX
-.I awk
-was designed and implemented by Alfred Aho,
-Peter Weinberger, and Brian Kernighan of AT&T Bell Labs. Brian Kernighan
-continues to maintain and enhance it.
-.PP
-Paul Rubin and Jay Fenlason,
-of the Free Software Foundation, wrote
-.IR gawk ,
-to be compatible with the original version of
-.I awk
-distributed in Seventh Edition \*(UX.
-John Woods contributed a number of bug fixes.
-David Trueman, with contributions
-from Arnold Robbins, made
-.I gawk
-compatible with the new version of \*(UX
-.IR awk .
-.PP
-The initial DOS port was done by Conrad Kwok and Scott Garfinkle.
-Scott Deifik is the current DOS maintainer. Pat Rankin did the
-port to VMS, and Michal Jaegermann did the port to the Atari ST.
-.SH ACKNOWLEDGEMENTS
-Brian Kernighan of Bell Labs
-provided valuable assistance during testing and debugging.
-We thank him.
diff --git a/gnu/usr.bin/awk/awk.h b/gnu/usr.bin/awk/awk.h
deleted file mode 100644
index ca3997f..0000000
--- a/gnu/usr.bin/awk/awk.h
+++ /dev/null
@@ -1,763 +0,0 @@
-/*
- * awk.h -- Definitions for gawk.
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* ------------------------------ Includes ------------------------------ */
-#include <stdio.h>
-#include <limits.h>
-#include <ctype.h>
-#include <setjmp.h>
-#include <varargs.h>
-#include <time.h>
-#include <errno.h>
-#if !defined(errno) && !defined(MSDOS)
-extern int errno;
-#endif
-#ifdef __GNU_LIBRARY__
-#ifndef linux
-#include <signum.h>
-#endif
-#endif
-
-/* ----------------- System dependencies (with more includes) -----------*/
-
-#if !defined(VMS) || (!defined(VAXC) && !defined(__DECC))
-#include <sys/types.h>
-#include <sys/stat.h>
-#else /* VMS w/ VAXC or DECC */
-#include <types.h>
-#include <stat.h>
-#include <file.h> /* avoid <fcntl.h> in io.c */
-#endif
-
-#include <signal.h>
-
-#include "config.h"
-
-#ifdef __STDC__
-#define P(s) s
-#define MALLOC_ARG_T size_t
-#else
-#define P(s) ()
-#define MALLOC_ARG_T unsigned
-#define volatile
-#define const
-#endif
-
-#ifndef SIGTYPE
-#define SIGTYPE void
-#endif
-
-#ifdef SIZE_T_MISSING
-typedef unsigned int size_t;
-#endif
-
-#ifndef SZTC
-#define SZTC
-#define INTC
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#include <string.h>
-#ifdef NeXT
-#include <libc.h>
-#undef atof
-#else
-#if defined(atarist) || defined(VMS)
-#include <unixlib.h>
-#else /* atarist || VMS */
-#ifndef MSDOS
-#include <unistd.h>
-#endif /* MSDOS */
-#endif /* atarist || VMS */
-#endif /* Next */
-#else /* STDC_HEADERS */
-#include "protos.h"
-#endif /* STDC_HEADERS */
-
-#if defined(ultrix) && !defined(Ultrix41)
-extern char * getenv P((char *name));
-extern double atof P((char *s));
-#endif
-
-#ifndef __GNUC__
-#ifdef sparc
-/* nasty nasty SunOS-ism */
-#include <alloca.h>
-#ifdef lint
-extern char *alloca();
-#endif
-#else /* not sparc */
-#if !defined(alloca) && !defined(ALLOCA_PROTO)
-extern char *alloca();
-#endif
-#endif /* sparc */
-#endif /* __GNUC__ */
-
-#ifdef HAVE_UNDERSCORE_SETJMP
-/* nasty nasty berkelixm */
-#define setjmp _setjmp
-#define longjmp _longjmp
-#endif
-
-/*
- * if you don't have vprintf, try this and cross your fingers.
- */
-#if defined(VPRINTF_MISSING)
-#define vfprintf(fp,fmt,arg) _doprnt((fmt), (arg), (fp))
-#endif
-
-#ifdef VMS
-/* some macros to redirect to code in vms/vms_misc.c */
-#define exit vms_exit
-#define open vms_open
-#define strerror vms_strerror
-#define strdup vms_strdup
-extern void exit P((int));
-extern int open P((const char *,int,...));
-extern char *strerror P((int));
-extern char *strdup P((const char *str));
-extern int vms_devopen P((const char *,int));
-# ifndef NO_TTY_FWRITE
-#define fwrite tty_fwrite
-#define fclose tty_fclose
-extern size_t fwrite P((const void *,size_t,size_t,FILE *));
-extern int fclose P((FILE *));
-# endif
-extern FILE *popen P((const char *,const char *));
-extern int pclose P((FILE *));
-extern void vms_arg_fixup P((int *,char ***));
-/* some things not in STDC_HEADERS */
-extern int gnu_strftime P((char *,size_t,const char *,const struct tm *));
-extern int unlink P((const char *));
-extern int getopt P((int,char **,char *));
-extern int isatty P((int));
-#ifndef fileno
-extern int fileno P((FILE *));
-#endif
-extern int close(), dup(), dup2(), fstat(), read(), stat();
-#endif /*VMS*/
-
-#ifdef MSDOS
-#include <io.h>
-extern FILE *popen P((char *, char *));
-extern int pclose P((FILE *));
-#endif
-
-#define GNU_REGEX
-#ifdef GNU_REGEX
-#include "regex.h"
-#include "dfa.h"
-typedef struct Regexp {
- struct re_pattern_buffer pat;
- struct re_registers regs;
- struct regexp dfareg;
- int dfa;
-} Regexp;
-#define RESTART(rp,s) (rp)->regs.start[0]
-#define REEND(rp,s) (rp)->regs.end[0]
-#else /* GNU_REGEX */
-#endif /* GNU_REGEX */
-
-#ifdef atarist
-#define read _text_read /* we do not want all these CR's to mess our input */
-extern int _text_read (int, char *, int);
-#endif
-
-#ifndef DEFPATH
-#define DEFPATH ".:/usr/local/lib/awk:/usr/lib/awk"
-#endif
-
-#ifndef ENVSEP
-#define ENVSEP ':'
-#endif
-
-/* ------------------ Constants, Structures, Typedefs ------------------ */
-#define AWKNUM double
-
-typedef enum {
- /* illegal entry == 0 */
- Node_illegal,
-
- /* binary operators lnode and rnode are the expressions to work on */
- Node_times,
- Node_quotient,
- Node_mod,
- Node_plus,
- Node_minus,
- Node_cond_pair, /* conditional pair (see Node_line_range) */
- Node_subscript,
- Node_concat,
- Node_exp,
-
- /* unary operators subnode is the expression to work on */
-/*10*/ Node_preincrement,
- Node_predecrement,
- Node_postincrement,
- Node_postdecrement,
- Node_unary_minus,
- Node_field_spec,
-
- /* assignments lnode is the var to assign to, rnode is the exp */
- Node_assign,
- Node_assign_times,
- Node_assign_quotient,
- Node_assign_mod,
-/*20*/ Node_assign_plus,
- Node_assign_minus,
- Node_assign_exp,
-
- /* boolean binaries lnode and rnode are expressions */
- Node_and,
- Node_or,
-
- /* binary relationals compares lnode and rnode */
- Node_equal,
- Node_notequal,
- Node_less,
- Node_greater,
- Node_leq,
-/*30*/ Node_geq,
- Node_match,
- Node_nomatch,
-
- /* unary relationals works on subnode */
- Node_not,
-
- /* program structures */
- Node_rule_list, /* lnode is a rule, rnode is rest of list */
- Node_rule_node, /* lnode is pattern, rnode is statement */
- Node_statement_list, /* lnode is statement, rnode is more list */
- Node_if_branches, /* lnode is to run on true, rnode on false */
- Node_expression_list, /* lnode is an exp, rnode is more list */
- Node_param_list, /* lnode is a variable, rnode is more list */
-
- /* keywords */
-/*40*/ Node_K_if, /* lnode is conditonal, rnode is if_branches */
- Node_K_while, /* lnode is condtional, rnode is stuff to run */
- Node_K_for, /* lnode is for_struct, rnode is stuff to run */
- Node_K_arrayfor, /* lnode is for_struct, rnode is stuff to run */
- Node_K_break, /* no subs */
- Node_K_continue, /* no stuff */
- Node_K_print, /* lnode is exp_list, rnode is redirect */
- Node_K_printf, /* lnode is exp_list, rnode is redirect */
- Node_K_next, /* no subs */
- Node_K_exit, /* subnode is return value, or NULL */
-/*50*/ Node_K_do, /* lnode is conditional, rnode stuff to run */
- Node_K_return,
- Node_K_delete,
- Node_K_getline,
- Node_K_function, /* lnode is statement list, rnode is params */
-
- /* I/O redirection for print statements */
- Node_redirect_output, /* subnode is where to redirect */
- Node_redirect_append, /* subnode is where to redirect */
- Node_redirect_pipe, /* subnode is where to redirect */
- Node_redirect_pipein, /* subnode is where to redirect */
- Node_redirect_input, /* subnode is where to redirect */
-
- /* Variables */
-/*60*/ Node_var, /* rnode is value, lnode is array stuff */
- Node_var_array, /* array is ptr to elements, asize num of
- * eles */
- Node_val, /* node is a value - type in flags */
-
- /* Builtins subnode is explist to work on, proc is func to call */
- Node_builtin,
-
- /*
- * pattern: conditional ',' conditional ; lnode of Node_line_range
- * is the two conditionals (Node_cond_pair), other word (rnode place)
- * is a flag indicating whether or not this range has been entered.
- */
- Node_line_range,
-
- /*
- * boolean test of membership in array lnode is string-valued
- * expression rnode is array name
- */
- Node_in_array,
-
- Node_func, /* lnode is param. list, rnode is body */
- Node_func_call, /* lnode is name, rnode is argument list */
-
- Node_cond_exp, /* lnode is conditonal, rnode is if_branches */
- Node_regex,
-/*70*/ Node_hashnode,
- Node_ahash,
- Node_NF,
- Node_NR,
- Node_FNR,
- Node_FS,
- Node_RS,
- Node_FIELDWIDTHS,
- Node_IGNORECASE,
- Node_OFS,
- Node_ORS,
- Node_OFMT,
- Node_CONVFMT,
- Node_K_nextfile
-} NODETYPE;
-
-/*
- * NOTE - this struct is a rather kludgey -- it is packed to minimize
- * space usage, at the expense of cleanliness. Alter at own risk.
- */
-typedef struct exp_node {
- union {
- struct {
- union {
- struct exp_node *lptr;
- char *param_name;
- } l;
- union {
- struct exp_node *rptr;
- struct exp_node *(*pptr) ();
- Regexp *preg;
- struct for_loop_header *hd;
- struct exp_node **av;
- int r_ent; /* range entered */
- } r;
- union {
- char *name;
- struct exp_node *extra;
- } x;
- short number;
- unsigned char reflags;
-# define CASE 1
-# define CONST 2
-# define FS_DFLT 4
- } nodep;
- struct {
- AWKNUM fltnum; /* this is here for optimal packing of
- * the structure on many machines
- */
- char *sp;
- size_t slen;
- unsigned char sref;
- char idx;
- } val;
- struct {
- struct exp_node *next;
- char *name;
- int length;
- struct exp_node *value;
- } hash;
-#define hnext sub.hash.next
-#define hname sub.hash.name
-#define hlength sub.hash.length
-#define hvalue sub.hash.value
- struct {
- struct exp_node *next;
- struct exp_node *name;
- struct exp_node *value;
- } ahash;
-#define ahnext sub.ahash.next
-#define ahname sub.ahash.name
-#define ahvalue sub.ahash.value
- } sub;
- NODETYPE type;
- unsigned short flags;
-# define MALLOC 1 /* can be free'd */
-# define TEMP 2 /* should be free'd */
-# define PERM 4 /* can't be free'd */
-# define STRING 8 /* assigned as string */
-# define STR 16 /* string value is current */
-# define NUM 32 /* numeric value is current */
-# define NUMBER 64 /* assigned as number */
-# define MAYBE_NUM 128 /* user input: if NUMERIC then
- * a NUMBER
- */
- char *vname; /* variable's name */
-} NODE;
-
-#define lnode sub.nodep.l.lptr
-#define nextp sub.nodep.l.lptr
-#define rnode sub.nodep.r.rptr
-#define source_file sub.nodep.x.name
-#define source_line sub.nodep.number
-#define param_cnt sub.nodep.number
-#define param sub.nodep.l.param_name
-
-#define subnode lnode
-#define proc sub.nodep.r.pptr
-
-#define re_reg sub.nodep.r.preg
-#define re_flags sub.nodep.reflags
-#define re_text lnode
-#define re_exp sub.nodep.x.extra
-#define re_cnt sub.nodep.number
-
-#define forsub lnode
-#define forloop rnode->sub.nodep.r.hd
-
-#define stptr sub.val.sp
-#define stlen sub.val.slen
-#define stref sub.val.sref
-#define stfmt sub.val.idx
-
-#define numbr sub.val.fltnum
-
-#define var_value lnode
-#define var_array sub.nodep.r.av
-
-#define condpair lnode
-#define triggered sub.nodep.r.r_ent
-
-#ifdef DONTDEF
-int primes[] = {31, 61, 127, 257, 509, 1021, 2053, 4099, 8191, 16381};
-#endif
-/* a quick profile suggests that the following is a good value */
-#define HASHSIZE 127
-
-typedef struct for_loop_header {
- NODE *init;
- NODE *cond;
- NODE *incr;
-} FOR_LOOP_HEADER;
-
-/* for "for(iggy in foo) {" */
-struct search {
- NODE **arr_ptr;
- NODE **arr_end;
- NODE *bucket;
- NODE *retval;
-};
-
-/* for faster input, bypass stdio */
-typedef struct iobuf {
- int fd;
- char *buf;
- char *off;
- char *end;
- size_t size; /* this will be determined by an fstat() call */
- int cnt;
- long secsiz;
- int flag;
-# define IOP_IS_TTY 1
-# define IOP_IS_INTERNAL 2
-# define IOP_NO_FREE 4
-} IOBUF;
-
-typedef void (*Func_ptr)();
-
-/*
- * structure used to dynamically maintain a linked-list of open files/pipes
- */
-struct redirect {
- unsigned int flag;
-# define RED_FILE 1
-# define RED_PIPE 2
-# define RED_READ 4
-# define RED_WRITE 8
-# define RED_APPEND 16
-# define RED_NOBUF 32
-# define RED_USED 64
-# define RED_EOF 128
- char *value;
- FILE *fp;
- IOBUF *iop;
- int pid;
- int status;
- struct redirect *prev;
- struct redirect *next;
-};
-
-/* structure for our source, either a command line string or a source file */
-struct src {
- enum srctype { CMDLINE = 1, SOURCEFILE } stype;
- char *val;
-};
-
-/* longjmp return codes, must be nonzero */
-/* Continue means either for loop/while continue, or next input record */
-#define TAG_CONTINUE 1
-/* Break means either for/while break, or stop reading input */
-#define TAG_BREAK 2
-/* Return means return from a function call; leave value in ret_node */
-#define TAG_RETURN 3
-
-#define HUGE INT_MAX
-
-/* -------------------------- External variables -------------------------- */
-/* gawk builtin variables */
-extern int NF;
-extern int NR;
-extern int FNR;
-extern int IGNORECASE;
-extern char *RS;
-extern char *OFS;
-extern int OFSlen;
-extern char *ORS;
-extern int ORSlen;
-extern char *OFMT;
-extern char *CONVFMT;
-extern int CONVFMTidx;
-extern int OFMTidx;
-extern NODE *FS_node, *NF_node, *RS_node, *NR_node;
-extern NODE *FILENAME_node, *OFS_node, *ORS_node, *OFMT_node;
-extern NODE *CONVFMT_node;
-extern NODE *FNR_node, *RLENGTH_node, *RSTART_node, *SUBSEP_node;
-extern NODE *IGNORECASE_node;
-extern NODE *FIELDWIDTHS_node;
-
-extern NODE **stack_ptr;
-extern NODE *Nnull_string;
-extern NODE **fields_arr;
-extern int sourceline;
-extern char *source;
-extern NODE *expression_value;
-
-extern NODE *_t; /* used as temporary in tree_eval */
-
-extern const char *myname;
-
-extern NODE *nextfree;
-extern int field0_valid;
-extern int do_unix;
-extern int do_posix;
-extern int do_lint;
-extern int in_begin_rule;
-extern int in_end_rule;
-
-/* ------------------------- Pseudo-functions ------------------------- */
-
-#define is_identchar(c) (isalnum(c) || (c) == '_')
-
-
-#ifndef MPROF
-#define getnode(n) if (nextfree) n = nextfree, nextfree = nextfree->nextp;\
- else n = more_nodes()
-#define freenode(n) ((n)->nextp = nextfree, nextfree = (n))
-#else
-#define getnode(n) emalloc(n, NODE *, sizeof(NODE), "getnode")
-#define freenode(n) free(n)
-#endif
-
-#ifdef DEBUG
-#define tree_eval(t) r_tree_eval(t)
-#else
-#define tree_eval(t) (_t = (t),(_t) == NULL ? Nnull_string : \
- ((_t)->type == Node_val ? (_t) : \
- ((_t)->type == Node_var ? (_t)->var_value : \
- ((_t)->type == Node_param_list ? \
- (stack_ptr[(_t)->param_cnt])->var_value : \
- r_tree_eval((_t))))))
-#endif
-
-#define make_number(x) mk_number((x), (MALLOC|NUM|NUMBER))
-#define tmp_number(x) mk_number((x), (MALLOC|TEMP|NUM|NUMBER))
-
-#define free_temp(n) do {if ((n)->flags&TEMP) { unref(n); }} while (0)
-#define make_string(s,l) make_str_node((s), SZTC (l),0)
-#define SCAN 1
-#define ALREADY_MALLOCED 2
-
-#define cant_happen() fatal("internal error line %d, file: %s", \
- __LINE__, __FILE__);
-
-#if defined(__STDC__) && !defined(NO_TOKEN_PASTING)
-#define emalloc(var,ty,x,str) (void)((var=(ty)malloc((MALLOC_ARG_T)(x))) ||\
- (fatal("%s: %s: can't allocate memory (%s)",\
- (str), #var, strerror(errno)),0))
-#define erealloc(var,ty,x,str) (void)((var=(ty)realloc((char *)var,\
- (MALLOC_ARG_T)(x))) ||\
- (fatal("%s: %s: can't allocate memory (%s)",\
- (str), #var, strerror(errno)),0))
-#else /* __STDC__ */
-#define emalloc(var,ty,x,str) (void)((var=(ty)malloc((MALLOC_ARG_T)(x))) ||\
- (fatal("%s: %s: can't allocate memory (%s)",\
- (str), "var", strerror(errno)),0))
-#define erealloc(var,ty,x,str) (void)((var=(ty)realloc((char *)var,\
- (MALLOC_ARG_T)(x))) ||\
- (fatal("%s: %s: can't allocate memory (%s)",\
- (str), "var", strerror(errno)),0))
-#endif /* __STDC__ */
-
-#ifdef DEBUG
-#define force_number r_force_number
-#define force_string r_force_string
-#else /* not DEBUG */
-#ifdef lint
-extern AWKNUM force_number();
-#endif
-#ifdef MSDOS
-extern double _msc51bug;
-#define force_number(n) (_msc51bug=(_t = (n),(_t->flags & NUM) ? _t->numbr : r_force_number(_t)))
-#else /* not MSDOS */
-#define force_number(n) (_t = (n),(_t->flags & NUM) ? _t->numbr : r_force_number(_t))
-#endif /* MSDOS */
-#define force_string(s) (_t = (s),(_t->flags & STR) ? _t : r_force_string(_t))
-#endif /* not DEBUG */
-
-#define STREQ(a,b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-#define STREQN(a,b,n) ((n)&& *(a)== *(b) && strncmp((a), (b), SZTC (n)) == 0)
-
-/* ------------- Function prototypes or defs (as appropriate) ------------- */
-
-/* array.c */
-extern NODE *concat_exp P((NODE *tree));
-extern void assoc_clear P((NODE *symbol));
-extern unsigned int hash P((char *s, int len));
-extern int in_array P((NODE *symbol, NODE *subs));
-extern NODE **assoc_lookup P((NODE *symbol, NODE *subs));
-extern void do_delete P((NODE *symbol, NODE *tree));
-extern void assoc_scan P((NODE *symbol, struct search *lookat));
-extern void assoc_next P((struct search *lookat));
-/* awk.tab.c */
-extern char *tokexpand P((void));
-extern char nextc P((void));
-extern NODE *node P((NODE *left, NODETYPE op, NODE *right));
-extern NODE *install P((char *name, NODE *value));
-extern NODE *lookup P((char *name));
-extern NODE *variable P((char *name, int can_free));
-extern int yyparse P((void));
-/* builtin.c */
-extern NODE *do_exp P((NODE *tree));
-extern NODE *do_index P((NODE *tree));
-extern NODE *do_int P((NODE *tree));
-extern NODE *do_length P((NODE *tree));
-extern NODE *do_log P((NODE *tree));
-extern NODE *do_sprintf P((NODE *tree));
-extern void do_printf P((NODE *tree));
-extern void print_simple P((NODE *tree, FILE *fp));
-extern NODE *do_sqrt P((NODE *tree));
-extern NODE *do_substr P((NODE *tree));
-extern NODE *do_strftime P((NODE *tree));
-extern NODE *do_systime P((NODE *tree));
-extern NODE *do_system P((NODE *tree));
-extern void do_print P((NODE *tree));
-extern NODE *do_tolower P((NODE *tree));
-extern NODE *do_toupper P((NODE *tree));
-extern NODE *do_atan2 P((NODE *tree));
-extern NODE *do_sin P((NODE *tree));
-extern NODE *do_cos P((NODE *tree));
-extern NODE *do_rand P((NODE *tree));
-extern NODE *do_srand P((NODE *tree));
-extern NODE *do_match P((NODE *tree));
-extern NODE *do_gsub P((NODE *tree));
-extern NODE *do_sub P((NODE *tree));
-/* eval.c */
-extern int interpret P((NODE *volatile tree));
-extern NODE *r_tree_eval P((NODE *tree));
-extern int cmp_nodes P((NODE *t1, NODE *t2));
-extern NODE **get_lhs P((NODE *ptr, Func_ptr *assign));
-extern void set_IGNORECASE P((void));
-void set_OFS P((void));
-void set_ORS P((void));
-void set_OFMT P((void));
-void set_CONVFMT P((void));
-/* field.c */
-extern void init_fields P((void));
-extern void set_record P((char *buf, int cnt, int freeold));
-extern void reset_record P((void));
-extern void set_NF P((void));
-extern NODE **get_field P((int num, Func_ptr *assign));
-extern NODE *do_split P((NODE *tree));
-extern void set_FS P((void));
-extern void set_RS P((void));
-extern void set_FIELDWIDTHS P((void));
-/* io.c */
-extern void set_FNR P((void));
-extern void set_NR P((void));
-extern void do_input P((void));
-extern struct redirect *redirect P((NODE *tree, int *errflg));
-extern NODE *do_close P((NODE *tree));
-extern int flush_io P((void));
-extern int close_io P((void));
-extern int devopen P((char *name, char *mode));
-extern int pathopen P((char *file));
-extern NODE *do_getline P((NODE *tree));
-extern void do_nextfile P((void));
-/* iop.c */
-extern int optimal_bufsize P((int fd));
-extern IOBUF *iop_alloc P((int fd));
-extern int get_a_record P((char **out, IOBUF *iop, int rs, int *errcode));
-/* main.c */
-extern int main P((int argc, char **argv));
-extern Regexp *mk_re_parse P((char *s, int ignorecase));
-extern void load_environ P((void));
-extern char *arg_assign P((char *arg));
-extern SIGTYPE catchsig P((int sig, int code));
-/* msg.c */
-#ifdef MSDOS
-extern void err P((char *s, char *emsg, char *va_list, ...));
-extern void msg P((char *va_alist, ...));
-extern void warning P((char *va_alist, ...));
-extern void fatal P((char *va_alist, ...));
-#else
-extern void err ();
-extern void msg ();
-extern void warning ();
-extern void fatal ();
-#endif
-/* node.c */
-extern AWKNUM r_force_number P((NODE *n));
-extern NODE *r_force_string P((NODE *s));
-extern NODE *dupnode P((NODE *n));
-extern NODE *mk_number P((AWKNUM x, unsigned int flags));
-extern NODE *make_str_node P((char *s, size_t len, int scan ));
-extern NODE *tmp_string P((char *s, size_t len ));
-extern NODE *more_nodes P((void));
-#ifdef DEBUG
-extern void freenode P((NODE *it));
-#endif
-extern void unref P((NODE *tmp));
-extern int parse_escape P((char **string_ptr));
-/* re.c */
-extern Regexp *make_regexp P((char *s, int len, int ignorecase, int dfa));
-extern int research P((Regexp *rp, char *str, int start, int len, int need_start));
-extern void refree P((Regexp *rp));
-extern void reg_error P((const char *s));
-extern Regexp *re_update P((NODE *t));
-extern void resyntax P((int syntax));
-extern void resetup P((void));
-
-/* strcase.c */
-extern int strcasecmp P((const char *s1, const char *s2));
-extern int strncasecmp P((const char *s1, const char *s2, register size_t n));
-
-#ifdef atarist
-/* atari/tmpnam.c */
-extern char *tmpnam P((char *buf));
-extern char *tempnam P((const char *path, const char *base));
-#endif
-
-/* Figure out what '\a' really is. */
-#ifdef __STDC__
-#define BELL '\a' /* sure makes life easy, don't it? */
-#else
-# if 'z' - 'a' == 25 /* ascii */
-# if 'a' != 97 /* machine is dumb enough to use mark parity */
-# define BELL '\207'
-# else
-# define BELL '\07'
-# endif
-# else
-# define BELL '\057'
-# endif
-#endif
-
-extern char casetable[]; /* for case-independent regexp matching */
diff --git a/gnu/usr.bin/awk/awk.y b/gnu/usr.bin/awk/awk.y
deleted file mode 100644
index 6e87f1c..0000000
--- a/gnu/usr.bin/awk/awk.y
+++ /dev/null
@@ -1,1804 +0,0 @@
-/*
- * awk.y --- yacc/bison parser
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-%{
-#ifdef DEBUG
-#define YYDEBUG 12
-#endif
-
-#include "awk.h"
-
-static void yyerror (); /* va_alist */
-static char *get_src_buf P((void));
-static int yylex P((void));
-static NODE *node_common P((NODETYPE op));
-static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
-static NODE *mkrangenode P((NODE *cpair));
-static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
-static NODE *append_right P((NODE *list, NODE *new));
-static void func_install P((NODE *params, NODE *def));
-static void pop_var P((NODE *np, int freeit));
-static void pop_params P((NODE *params));
-static NODE *make_param P((char *name));
-static NODE *mk_rexp P((NODE *exp));
-
-static int want_assign; /* lexical scanning kludge */
-static int want_regexp; /* lexical scanning kludge */
-static int can_return; /* lexical scanning kludge */
-static int io_allowed = 1; /* lexical scanning kludge */
-static char *lexptr; /* pointer to next char during parsing */
-static char *lexend;
-static char *lexptr_begin; /* keep track of where we were for error msgs */
-static char *lexeme; /* beginning of lexeme for debugging */
-static char *thisline = NULL;
-#define YYDEBUG_LEXER_TEXT (lexeme)
-static int param_counter;
-static char *tokstart = NULL;
-static char *token = NULL;
-static char *tokend;
-
-NODE *variables[HASHSIZE];
-
-extern char *source;
-extern int sourceline;
-extern struct src *srcfiles;
-extern int numfiles;
-extern int errcount;
-extern NODE *begin_block;
-extern NODE *end_block;
-%}
-
-%union {
- long lval;
- AWKNUM fval;
- NODE *nodeval;
- NODETYPE nodetypeval;
- char *sval;
- NODE *(*ptrval)();
-}
-
-%type <nodeval> function_prologue function_body
-%type <nodeval> rexp exp start program rule simp_exp
-%type <nodeval> non_post_simp_exp
-%type <nodeval> pattern
-%type <nodeval> action variable param_list
-%type <nodeval> rexpression_list opt_rexpression_list
-%type <nodeval> expression_list opt_expression_list
-%type <nodeval> statements statement if_statement opt_param_list
-%type <nodeval> opt_exp opt_variable regexp
-%type <nodeval> input_redir output_redir
-%type <nodetypeval> print
-%type <sval> func_name
-%type <lval> lex_builtin
-
-%token <sval> FUNC_CALL NAME REGEXP
-%token <lval> ERROR
-%token <nodeval> YNUMBER YSTRING
-%token <nodetypeval> RELOP APPEND_OP
-%token <nodetypeval> ASSIGNOP MATCHOP NEWLINE CONCAT_OP
-%token <nodetypeval> LEX_BEGIN LEX_END LEX_IF LEX_ELSE LEX_RETURN LEX_DELETE
-%token <nodetypeval> LEX_WHILE LEX_DO LEX_FOR LEX_BREAK LEX_CONTINUE
-%token <nodetypeval> LEX_PRINT LEX_PRINTF LEX_NEXT LEX_EXIT LEX_FUNCTION
-%token <nodetypeval> LEX_GETLINE
-%token <nodetypeval> LEX_IN
-%token <lval> LEX_AND LEX_OR INCREMENT DECREMENT
-%token <lval> LEX_BUILTIN LEX_LENGTH
-
-/* these are just yylval numbers */
-
-/* Lowest to highest */
-%right ASSIGNOP
-%right '?' ':'
-%left LEX_OR
-%left LEX_AND
-%left LEX_GETLINE
-%nonassoc LEX_IN
-%left FUNC_CALL LEX_BUILTIN LEX_LENGTH
-%nonassoc MATCHOP
-%nonassoc RELOP '<' '>' '|' APPEND_OP
-%left CONCAT_OP
-%left YSTRING YNUMBER
-%left '+' '-'
-%left '*' '/' '%'
-%right '!' UNARY
-%right '^'
-%left INCREMENT DECREMENT
-%left '$'
-%left '(' ')'
-%%
-
-start
- : opt_nls program opt_nls
- { expression_value = $2; }
- ;
-
-program
- : rule
- {
- if ($1 != NULL)
- $$ = $1;
- else
- $$ = NULL;
- yyerrok;
- }
- | program rule
- /* add the rule to the tail of list */
- {
- if ($2 == NULL)
- $$ = $1;
- else if ($1 == NULL)
- $$ = $2;
- else {
- if ($1->type != Node_rule_list)
- $1 = node($1, Node_rule_list,
- (NODE*)NULL);
- $$ = append_right ($1,
- node($2, Node_rule_list,(NODE *) NULL));
- }
- yyerrok;
- }
- | error { $$ = NULL; }
- | program error { $$ = NULL; }
- ;
-
-rule
- : LEX_BEGIN { io_allowed = 0; }
- action
- {
- if (begin_block) {
- if (begin_block->type != Node_rule_list)
- begin_block = node(begin_block, Node_rule_list,
- (NODE *)NULL);
- (void) append_right (begin_block, node(
- node((NODE *)NULL, Node_rule_node, $3),
- Node_rule_list, (NODE *)NULL) );
- } else
- begin_block = node((NODE *)NULL, Node_rule_node, $3);
- $$ = NULL;
- io_allowed = 1;
- yyerrok;
- }
- | LEX_END { io_allowed = 0; }
- action
- {
- if (end_block) {
- if (end_block->type != Node_rule_list)
- end_block = node(end_block, Node_rule_list,
- (NODE *)NULL);
- (void) append_right (end_block, node(
- node((NODE *)NULL, Node_rule_node, $3),
- Node_rule_list, (NODE *)NULL));
- } else
- end_block = node((NODE *)NULL, Node_rule_node, $3);
- $$ = NULL;
- io_allowed = 1;
- yyerrok;
- }
- | LEX_BEGIN statement_term
- {
- warning("BEGIN blocks must have an action part");
- errcount++;
- yyerrok;
- }
- | LEX_END statement_term
- {
- warning("END blocks must have an action part");
- errcount++;
- yyerrok;
- }
- | pattern action
- { $$ = node ($1, Node_rule_node, $2); yyerrok; }
- | action
- { $$ = node ((NODE *)NULL, Node_rule_node, $1); yyerrok; }
- | pattern statement_term
- {
- $$ = node ($1,
- Node_rule_node,
- node(node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_expression_list,
- (NODE *) NULL),
- Node_K_print,
- (NODE *) NULL));
- yyerrok;
- }
- | function_prologue function_body
- {
- func_install($1, $2);
- $$ = NULL;
- yyerrok;
- }
- ;
-
-func_name
- : NAME
- { $$ = $1; }
- | FUNC_CALL
- { $$ = $1; }
- | lex_builtin
- {
- yyerror("%s() is a built-in function, it cannot be redefined",
- tokstart);
- errcount++;
- /* yyerrok; */
- }
- ;
-
-lex_builtin
- : LEX_BUILTIN
- | LEX_LENGTH
- ;
-
-function_prologue
- : LEX_FUNCTION
- {
- param_counter = 0;
- }
- func_name '(' opt_param_list r_paren opt_nls
- {
- $$ = append_right(make_param($3), $5);
- can_return = 1;
- }
- ;
-
-function_body
- : l_brace statements r_brace opt_semi
- {
- $$ = $2;
- can_return = 0;
- }
- ;
-
-
-pattern
- : exp
- { $$ = $1; }
- | exp comma exp
- { $$ = mkrangenode ( node($1, Node_cond_pair, $3) ); }
- ;
-
-regexp
- /*
- * In this rule, want_regexp tells yylex that the next thing
- * is a regexp so it should read up to the closing slash.
- */
- : '/'
- { ++want_regexp; }
- REGEXP '/'
- {
- NODE *n;
- int len;
-
- getnode(n);
- n->type = Node_regex;
- len = strlen($3);
- n->re_exp = make_string($3, len);
- n->re_reg = make_regexp($3, len, 0, 1);
- n->re_text = NULL;
- n->re_flags = CONST;
- n->re_cnt = 1;
- $$ = n;
- }
- ;
-
-action
- : l_brace statements r_brace opt_semi opt_nls
- { $$ = $2 ; }
- | l_brace r_brace opt_semi opt_nls
- { $$ = NULL; }
- ;
-
-statements
- : statement
- { $$ = $1; }
- | statements statement
- {
- if ($1 == NULL || $1->type != Node_statement_list)
- $1 = node($1, Node_statement_list,(NODE *)NULL);
- $$ = append_right($1,
- node( $2, Node_statement_list, (NODE *)NULL));
- yyerrok;
- }
- | error
- { $$ = NULL; }
- | statements error
- { $$ = NULL; }
- ;
-
-statement_term
- : nls
- | semi opt_nls
- ;
-
-statement
- : semi opt_nls
- { $$ = NULL; }
- | l_brace r_brace
- { $$ = NULL; }
- | l_brace statements r_brace
- { $$ = $2; }
- | if_statement
- { $$ = $1; }
- | LEX_WHILE '(' exp r_paren opt_nls statement
- { $$ = node ($3, Node_K_while, $6); }
- | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls
- { $$ = node ($6, Node_K_do, $3); }
- | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement
- {
- $$ = node ($8, Node_K_arrayfor, make_for_loop(variable($3,1),
- (NODE *)NULL, variable($5,1)));
- }
- | LEX_FOR '(' opt_exp semi exp semi opt_exp r_paren opt_nls statement
- {
- $$ = node($10, Node_K_for, (NODE *)make_for_loop($3, $5, $7));
- }
- | LEX_FOR '(' opt_exp semi semi opt_exp r_paren opt_nls statement
- {
- $$ = node ($9, Node_K_for,
- (NODE *)make_for_loop($3, (NODE *)NULL, $6));
- }
- | LEX_BREAK statement_term
- /* for break, maybe we'll have to remember where to break to */
- { $$ = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); }
- | LEX_CONTINUE statement_term
- /* similarly */
- { $$ = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); }
- | print '(' expression_list r_paren output_redir statement_term
- { $$ = node ($3, $1, $5); }
- | print opt_rexpression_list output_redir statement_term
- {
- if ($1 == Node_K_print && $2 == NULL)
- $2 = node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_expression_list,
- (NODE *) NULL);
-
- $$ = node ($2, $1, $3);
- }
- | LEX_NEXT opt_exp statement_term
- { NODETYPE type;
-
- if ($2 && $2 == lookup("file")) {
- if (do_lint)
- warning("`next file' is a gawk extension");
- else if (do_unix || do_posix)
- yyerror("`next file' is a gawk extension");
- else if (! io_allowed)
- yyerror("`next file' used in BEGIN or END action");
- type = Node_K_nextfile;
- } else {
- if (! io_allowed)
- yyerror("next used in BEGIN or END action");
- type = Node_K_next;
- }
- $$ = node ((NODE *)NULL, type, (NODE *)NULL);
- }
- | LEX_EXIT opt_exp statement_term
- { $$ = node ($2, Node_K_exit, (NODE *)NULL); }
- | LEX_RETURN
- { if (! can_return) yyerror("return used outside function context"); }
- opt_exp statement_term
- { $$ = node ($3, Node_K_return, (NODE *)NULL); }
- | LEX_DELETE NAME '[' expression_list ']' statement_term
- { $$ = node (variable($2,1), Node_K_delete, $4); }
- | exp statement_term
- { $$ = $1; }
- ;
-
-print
- : LEX_PRINT
- { $$ = $1; }
- | LEX_PRINTF
- { $$ = $1; }
- ;
-
-if_statement
- : LEX_IF '(' exp r_paren opt_nls statement
- {
- $$ = node($3, Node_K_if,
- node($6, Node_if_branches, (NODE *)NULL));
- }
- | LEX_IF '(' exp r_paren opt_nls statement
- LEX_ELSE opt_nls statement
- { $$ = node ($3, Node_K_if,
- node ($6, Node_if_branches, $9)); }
- ;
-
-nls
- : NEWLINE
- { want_assign = 0; }
- | nls NEWLINE
- ;
-
-opt_nls
- : /* empty */
- | nls
- ;
-
-input_redir
- : /* empty */
- { $$ = NULL; }
- | '<' simp_exp
- { $$ = node ($2, Node_redirect_input, (NODE *)NULL); }
- ;
-
-output_redir
- : /* empty */
- { $$ = NULL; }
- | '>' exp
- { $$ = node ($2, Node_redirect_output, (NODE *)NULL); }
- | APPEND_OP exp
- { $$ = node ($2, Node_redirect_append, (NODE *)NULL); }
- | '|' exp
- { $$ = node ($2, Node_redirect_pipe, (NODE *)NULL); }
- ;
-
-opt_param_list
- : /* empty */
- { $$ = NULL; }
- | param_list
- { $$ = $1; }
- ;
-
-param_list
- : NAME
- { $$ = make_param($1); }
- | param_list comma NAME
- { $$ = append_right($1, make_param($3)); yyerrok; }
- | error
- { $$ = NULL; }
- | param_list error
- { $$ = NULL; }
- | param_list comma error
- { $$ = NULL; }
- ;
-
-/* optional expression, as in for loop */
-opt_exp
- : /* empty */
- { $$ = NULL; }
- | exp
- { $$ = $1; }
- ;
-
-opt_rexpression_list
- : /* empty */
- { $$ = NULL; }
- | rexpression_list
- { $$ = $1; }
- ;
-
-rexpression_list
- : rexp
- { $$ = node ($1, Node_expression_list, (NODE *)NULL); }
- | rexpression_list comma rexp
- {
- $$ = append_right($1,
- node( $3, Node_expression_list, (NODE *)NULL));
- yyerrok;
- }
- | error
- { $$ = NULL; }
- | rexpression_list error
- { $$ = NULL; }
- | rexpression_list error rexp
- { $$ = NULL; }
- | rexpression_list comma error
- { $$ = NULL; }
- ;
-
-opt_expression_list
- : /* empty */
- { $$ = NULL; }
- | expression_list
- { $$ = $1; }
- ;
-
-expression_list
- : exp
- { $$ = node ($1, Node_expression_list, (NODE *)NULL); }
- | expression_list comma exp
- {
- $$ = append_right($1,
- node( $3, Node_expression_list, (NODE *)NULL));
- yyerrok;
- }
- | error
- { $$ = NULL; }
- | expression_list error
- { $$ = NULL; }
- | expression_list error exp
- { $$ = NULL; }
- | expression_list comma error
- { $$ = NULL; }
- ;
-
-/* Expressions, not including the comma operator. */
-exp : variable ASSIGNOP
- { want_assign = 0; }
- exp
- {
- if (do_lint && $4->type == Node_regex)
- warning("Regular expression on left of assignment.");
- $$ = node ($1, $2, $4);
- }
- | '(' expression_list r_paren LEX_IN NAME
- { $$ = node (variable($5,1), Node_in_array, $2); }
- | exp '|' LEX_GETLINE opt_variable
- {
- $$ = node ($4, Node_K_getline,
- node ($1, Node_redirect_pipein, (NODE *)NULL));
- }
- | LEX_GETLINE opt_variable input_redir
- {
- if (do_lint && ! io_allowed && $3 == NULL)
- warning("non-redirected getline undefined inside BEGIN or END action");
- $$ = node ($2, Node_K_getline, $3);
- }
- | exp LEX_AND exp
- { $$ = node ($1, Node_and, $3); }
- | exp LEX_OR exp
- { $$ = node ($1, Node_or, $3); }
- | exp MATCHOP exp
- {
- if ($1->type == Node_regex)
- warning("Regular expression on left of MATCH operator.");
- $$ = node ($1, $2, mk_rexp($3));
- }
- | regexp
- { $$ = $1; }
- | '!' regexp %prec UNARY
- {
- $$ = node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_nomatch,
- $2);
- }
- | exp LEX_IN NAME
- { $$ = node (variable($3,1), Node_in_array, $1); }
- | exp RELOP exp
- {
- if (do_lint && $3->type == Node_regex)
- warning("Regular expression on left of comparison.");
- $$ = node ($1, $2, $3);
- }
- | exp '<' exp
- { $$ = node ($1, Node_less, $3); }
- | exp '>' exp
- { $$ = node ($1, Node_greater, $3); }
- | exp '?' exp ':' exp
- { $$ = node($1, Node_cond_exp, node($3, Node_if_branches, $5));}
- | simp_exp
- { $$ = $1; }
- | exp simp_exp %prec CONCAT_OP
- { $$ = node ($1, Node_concat, $2); }
- ;
-
-rexp
- : variable ASSIGNOP
- { want_assign = 0; }
- rexp
- { $$ = node ($1, $2, $4); }
- | rexp LEX_AND rexp
- { $$ = node ($1, Node_and, $3); }
- | rexp LEX_OR rexp
- { $$ = node ($1, Node_or, $3); }
- | LEX_GETLINE opt_variable input_redir
- {
- if (do_lint && ! io_allowed && $3 == NULL)
- warning("non-redirected getline undefined inside BEGIN or END action");
- $$ = node ($2, Node_K_getline, $3);
- }
- | regexp
- { $$ = $1; }
- | '!' regexp %prec UNARY
- { $$ = node((NODE *) NULL, Node_nomatch, $2); }
- | rexp MATCHOP rexp
- { $$ = node ($1, $2, mk_rexp($3)); }
- | rexp LEX_IN NAME
- { $$ = node (variable($3,1), Node_in_array, $1); }
- | rexp RELOP rexp
- { $$ = node ($1, $2, $3); }
- | rexp '?' rexp ':' rexp
- { $$ = node($1, Node_cond_exp, node($3, Node_if_branches, $5));}
- | simp_exp
- { $$ = $1; }
- | rexp simp_exp %prec CONCAT_OP
- { $$ = node ($1, Node_concat, $2); }
- ;
-
-simp_exp
- : non_post_simp_exp
- /* Binary operators in order of decreasing precedence. */
- | simp_exp '^' simp_exp
- { $$ = node ($1, Node_exp, $3); }
- | simp_exp '*' simp_exp
- { $$ = node ($1, Node_times, $3); }
- | simp_exp '/' simp_exp
- { $$ = node ($1, Node_quotient, $3); }
- | simp_exp '%' simp_exp
- { $$ = node ($1, Node_mod, $3); }
- | simp_exp '+' simp_exp
- { $$ = node ($1, Node_plus, $3); }
- | simp_exp '-' simp_exp
- { $$ = node ($1, Node_minus, $3); }
- | variable INCREMENT
- { $$ = node ($1, Node_postincrement, (NODE *)NULL); }
- | variable DECREMENT
- { $$ = node ($1, Node_postdecrement, (NODE *)NULL); }
- ;
-
-non_post_simp_exp
- : '!' simp_exp %prec UNARY
- { $$ = node ($2, Node_not,(NODE *) NULL); }
- | '(' exp r_paren
- { $$ = $2; }
- | LEX_BUILTIN
- '(' opt_expression_list r_paren
- { $$ = snode ($3, Node_builtin, (int) $1); }
- | LEX_LENGTH '(' opt_expression_list r_paren
- { $$ = snode ($3, Node_builtin, (int) $1); }
- | LEX_LENGTH
- {
- if (do_lint)
- warning("call of `length' without parentheses is not portable");
- $$ = snode ((NODE *)NULL, Node_builtin, (int) $1);
- if (do_posix)
- warning( "call of `length' without parentheses is deprecated by POSIX");
- }
- | FUNC_CALL '(' opt_expression_list r_paren
- {
- $$ = node ($3, Node_func_call, make_string($1, strlen($1)));
- }
- | variable
- | INCREMENT variable
- { $$ = node ($2, Node_preincrement, (NODE *)NULL); }
- | DECREMENT variable
- { $$ = node ($2, Node_predecrement, (NODE *)NULL); }
- | YNUMBER
- { $$ = $1; }
- | YSTRING
- { $$ = $1; }
-
- | '-' simp_exp %prec UNARY
- { if ($2->type == Node_val) {
- $2->numbr = -(force_number($2));
- $$ = $2;
- } else
- $$ = node ($2, Node_unary_minus, (NODE *)NULL);
- }
- | '+' simp_exp %prec UNARY
- { $$ = $2; }
- ;
-
-opt_variable
- : /* empty */
- { $$ = NULL; }
- | variable
- { $$ = $1; }
- ;
-
-variable
- : NAME
- { $$ = variable($1,1); }
- | NAME '[' expression_list ']'
- {
- if ($3->rnode == NULL) {
- $$ = node (variable($1,1), Node_subscript, $3->lnode);
- freenode($3);
- } else
- $$ = node (variable($1,1), Node_subscript, $3);
- }
- | '$' non_post_simp_exp
- { $$ = node ($2, Node_field_spec, (NODE *)NULL); }
- ;
-
-l_brace
- : '{' opt_nls
- ;
-
-r_brace
- : '}' opt_nls { yyerrok; }
- ;
-
-r_paren
- : ')' { yyerrok; }
- ;
-
-opt_semi
- : /* empty */
- | semi
- ;
-
-semi
- : ';' { yyerrok; want_assign = 0; }
- ;
-
-comma : ',' opt_nls { yyerrok; }
- ;
-
-%%
-
-struct token {
- char *operator; /* text to match */
- NODETYPE value; /* node type */
- int class; /* lexical class */
- unsigned flags; /* # of args. allowed and compatability */
-# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */
-# define A(n) (1<<(n))
-# define VERSION 0xFF00 /* old awk is zero */
-# define NOT_OLD 0x0100 /* feature not in old awk */
-# define NOT_POSIX 0x0200 /* feature not in POSIX */
-# define GAWKX 0x0400 /* gawk extension */
- NODE *(*ptr) (); /* function that implements this keyword */
-};
-
-extern NODE
- *do_exp(), *do_getline(), *do_index(), *do_length(),
- *do_sqrt(), *do_log(), *do_sprintf(), *do_substr(),
- *do_split(), *do_system(), *do_int(), *do_close(),
- *do_atan2(), *do_sin(), *do_cos(), *do_rand(),
- *do_srand(), *do_match(), *do_tolower(), *do_toupper(),
- *do_sub(), *do_gsub(), *do_strftime(), *do_systime();
-
-/* Tokentab is sorted ascii ascending order, so it can be binary searched. */
-
-static struct token tokentab[] = {
-{"BEGIN", Node_illegal, LEX_BEGIN, 0, 0},
-{"END", Node_illegal, LEX_END, 0, 0},
-{"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2},
-{"break", Node_K_break, LEX_BREAK, 0, 0},
-{"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close},
-{"continue", Node_K_continue, LEX_CONTINUE, 0, 0},
-{"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos},
-{"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0},
-{"do", Node_K_do, LEX_DO, NOT_OLD, 0},
-{"else", Node_illegal, LEX_ELSE, 0, 0},
-{"exit", Node_K_exit, LEX_EXIT, 0, 0},
-{"exp", Node_builtin, LEX_BUILTIN, A(1), do_exp},
-{"for", Node_K_for, LEX_FOR, 0, 0},
-{"func", Node_K_function, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0},
-{"function", Node_K_function, LEX_FUNCTION, NOT_OLD, 0},
-{"getline", Node_K_getline, LEX_GETLINE, NOT_OLD, 0},
-{"gsub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_gsub},
-{"if", Node_K_if, LEX_IF, 0, 0},
-{"in", Node_illegal, LEX_IN, 0, 0},
-{"index", Node_builtin, LEX_BUILTIN, A(2), do_index},
-{"int", Node_builtin, LEX_BUILTIN, A(1), do_int},
-{"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length},
-{"log", Node_builtin, LEX_BUILTIN, A(1), do_log},
-{"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match},
-{"next", Node_K_next, LEX_NEXT, 0, 0},
-{"print", Node_K_print, LEX_PRINT, 0, 0},
-{"printf", Node_K_printf, LEX_PRINTF, 0, 0},
-{"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand},
-{"return", Node_K_return, LEX_RETURN, NOT_OLD, 0},
-{"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin},
-{"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split},
-{"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf},
-{"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt},
-{"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand},
-{"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_strftime},
-{"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub},
-{"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr},
-{"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system},
-{"systime", Node_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime},
-{"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower},
-{"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper},
-{"while", Node_K_while, LEX_WHILE, 0, 0},
-};
-
-/* VARARGS0 */
-static void
-yyerror(va_alist)
-va_dcl
-{
- va_list args;
- char *mesg = NULL;
- register char *bp, *cp;
- char *scan;
- char buf[120];
-
- errcount++;
- /* Find the current line in the input file */
- if (lexptr) {
- if (!thisline) {
- cp = lexeme;
- if (*cp == '\n') {
- cp--;
- mesg = "unexpected newline";
- }
- for ( ; cp != lexptr_begin && *cp != '\n'; --cp)
- ;
- if (*cp == '\n')
- cp++;
- thisline = cp;
- }
- /* NL isn't guaranteed */
- bp = lexeme;
- while (bp < lexend && *bp && *bp != '\n')
- bp++;
- } else {
- thisline = "(END OF FILE)";
- bp = thisline + 13;
- }
- msg("%.*s", (int) (bp - thisline), thisline);
- bp = buf;
- cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */
- if (lexptr) {
- scan = thisline;
- while (bp < cp && scan < lexeme)
- if (*scan++ == '\t')
- *bp++ = '\t';
- else
- *bp++ = ' ';
- *bp++ = '^';
- *bp++ = ' ';
- }
- va_start(args);
- if (mesg == NULL)
- mesg = va_arg(args, char *);
- strcpy(bp, mesg);
- err("", buf, args);
- va_end(args);
- exit(2);
-}
-
-static char *
-get_src_buf()
-{
- static int samefile = 0;
- static int nextfile = 0;
- static char *buf = NULL;
- static int fd;
- int n;
- register char *scan;
- static int len = 0;
- static int did_newline = 0;
-# define SLOP 128 /* enough space to hold most source lines */
-
- if (nextfile > numfiles)
- return NULL;
-
- if (srcfiles[nextfile].stype == CMDLINE) {
- if (len == 0) {
- len = strlen(srcfiles[nextfile].val);
- sourceline = 1;
- lexptr = lexptr_begin = srcfiles[nextfile].val;
- lexend = lexptr + len;
- } else if (!did_newline && *(lexptr-1) != '\n') {
- /*
- * The following goop is to ensure that the source
- * ends with a newline and that the entire current
- * line is available for error messages.
- */
- int offset;
-
- did_newline = 1;
- offset = lexptr - lexeme;
- for (scan = lexeme; scan > lexptr_begin; scan--)
- if (*scan == '\n') {
- scan++;
- break;
- }
- len = lexptr - scan;
- emalloc(buf, char *, len+1, "get_src_buf");
- memcpy(buf, scan, len);
- thisline = buf;
- lexptr = buf + len;
- *lexptr = '\n';
- lexeme = lexptr - offset;
- lexptr_begin = buf;
- lexend = lexptr + 1;
- } else {
- len = 0;
- lexeme = lexptr = lexptr_begin = NULL;
- }
- if (lexptr == NULL && ++nextfile <= numfiles)
- return get_src_buf();
- return lexptr;
- }
- if (!samefile) {
- source = srcfiles[nextfile].val;
- if (source == NULL) {
- if (buf) {
- free(buf);
- buf = NULL;
- }
- len = 0;
- return lexeme = lexptr = lexptr_begin = NULL;
- }
- fd = pathopen(source);
- if (fd == -1)
- fatal("can't open source file \"%s\" for reading (%s)",
- source, strerror(errno));
- len = optimal_bufsize(fd);
- if (buf)
- free(buf);
- emalloc(buf, char *, len + SLOP, "get_src_buf");
- lexptr_begin = buf + SLOP;
- samefile = 1;
- sourceline = 1;
- } else {
- /*
- * Here, we retain the current source line (up to length SLOP)
- * in the beginning of the buffer that was overallocated above
- */
- int offset;
- int linelen;
-
- offset = lexptr - lexeme;
- for (scan = lexeme; scan > lexptr_begin; scan--)
- if (*scan == '\n') {
- scan++;
- break;
- }
- linelen = lexptr - scan;
- if (linelen > SLOP)
- linelen = SLOP;
- thisline = buf + SLOP - linelen;
- memcpy(thisline, scan, linelen);
- lexeme = buf + SLOP - offset;
- lexptr_begin = thisline;
- }
- n = read(fd, buf + SLOP, len);
- if (n == -1)
- fatal("can't read sourcefile \"%s\" (%s)",
- source, strerror(errno));
- if (n == 0) {
- samefile = 0;
- nextfile++;
- len = 0;
- return get_src_buf();
- }
- lexptr = buf + SLOP;
- lexend = lexptr + n;
- return buf;
-}
-
-#define tokadd(x) (*token++ = (x), token == tokend ? tokexpand() : token)
-
-char *
-tokexpand()
-{
- static int toksize = 60;
- int tokoffset;
-
- tokoffset = token - tokstart;
- toksize *= 2;
- if (tokstart)
- erealloc(tokstart, char *, toksize, "tokexpand");
- else
- emalloc(tokstart, char *, toksize, "tokexpand");
- tokend = tokstart + toksize;
- token = tokstart + tokoffset;
- return token;
-}
-
-#if DEBUG
-char
-nextc() {
- if (lexptr && lexptr < lexend)
- return *lexptr++;
- else if (get_src_buf())
- return *lexptr++;
- else
- return '\0';
-}
-#else
-#define nextc() ((lexptr && lexptr < lexend) ? \
- *lexptr++ : \
- (get_src_buf() ? *lexptr++ : '\0') \
- )
-#endif
-#define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
-
-/*
- * Read the input and turn it into tokens.
- */
-
-static int
-yylex()
-{
- register int c;
- int seen_e = 0; /* These are for numbers */
- int seen_point = 0;
- int esc_seen; /* for literal strings */
- int low, mid, high;
- static int did_newline = 0;
- char *tokkey;
-
- if (!nextc())
- return 0;
- pushback();
- lexeme = lexptr;
- thisline = NULL;
- if (want_regexp) {
- int in_brack = 0;
-
- want_regexp = 0;
- token = tokstart;
- while ((c = nextc()) != 0) {
- switch (c) {
- case '[':
- in_brack = 1;
- break;
- case ']':
- in_brack = 0;
- break;
- case '\\':
- if ((c = nextc()) == '\0') {
- yyerror("unterminated regexp ends with \\ at end of file");
- } else if (c == '\n') {
- sourceline++;
- continue;
- } else
- tokadd('\\');
- break;
- case '/': /* end of the regexp */
- if (in_brack)
- break;
-
- pushback();
- tokadd('\0');
- yylval.sval = tokstart;
- return REGEXP;
- case '\n':
- pushback();
- yyerror("unterminated regexp");
- case '\0':
- yyerror("unterminated regexp at end of file");
- }
- tokadd(c);
- }
- }
-retry:
- while ((c = nextc()) == ' ' || c == '\t')
- ;
-
- lexeme = lexptr ? lexptr - 1 : lexptr;
- thisline = NULL;
- token = tokstart;
- yylval.nodetypeval = Node_illegal;
-
- switch (c) {
- case 0:
- return 0;
-
- case '\n':
- sourceline++;
- return NEWLINE;
-
- case '#': /* it's a comment */
- while ((c = nextc()) != '\n') {
- if (c == '\0')
- return 0;
- }
- sourceline++;
- return NEWLINE;
-
- case '\\':
-#ifdef RELAXED_CONTINUATION
- if (!do_unix) { /* strip trailing white-space and/or comment */
- while ((c = nextc()) == ' ' || c == '\t') continue;
- if (c == '#')
- while ((c = nextc()) != '\n') if (!c) break;
- pushback();
- }
-#endif /*RELAXED_CONTINUATION*/
- if (nextc() == '\n') {
- sourceline++;
- goto retry;
- } else
- yyerror("inappropriate use of backslash");
- break;
-
- case '$':
- want_assign = 1;
- return '$';
-
- case ')':
- case ']':
- case '(':
- case '[':
- case ';':
- case ':':
- case '?':
- case '{':
- case ',':
- return c;
-
- case '*':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_assign_times;
- return ASSIGNOP;
- } else if (do_posix) {
- pushback();
- return '*';
- } else if (c == '*') {
- /* make ** and **= aliases for ^ and ^= */
- static int did_warn_op = 0, did_warn_assgn = 0;
-
- if (nextc() == '=') {
- if (do_lint && ! did_warn_assgn) {
- did_warn_assgn = 1;
- warning("**= is not allowed by POSIX");
- }
- yylval.nodetypeval = Node_assign_exp;
- return ASSIGNOP;
- } else {
- pushback();
- if (do_lint && ! did_warn_op) {
- did_warn_op = 1;
- warning("** is not allowed by POSIX");
- }
- return '^';
- }
- }
- pushback();
- return '*';
-
- case '/':
- if (want_assign) {
- if (nextc() == '=') {
- yylval.nodetypeval = Node_assign_quotient;
- return ASSIGNOP;
- }
- pushback();
- }
- return '/';
-
- case '%':
- if (nextc() == '=') {
- yylval.nodetypeval = Node_assign_mod;
- return ASSIGNOP;
- }
- pushback();
- return '%';
-
- case '^':
- {
- static int did_warn_op = 0, did_warn_assgn = 0;
-
- if (nextc() == '=') {
-
- if (do_lint && ! did_warn_assgn) {
- did_warn_assgn = 1;
- warning("operator `^=' is not supported in old awk");
- }
- yylval.nodetypeval = Node_assign_exp;
- return ASSIGNOP;
- }
- pushback();
- if (do_lint && ! did_warn_op) {
- did_warn_op = 1;
- warning("operator `^' is not supported in old awk");
- }
- return '^';
- }
-
- case '+':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_assign_plus;
- return ASSIGNOP;
- }
- if (c == '+')
- return INCREMENT;
- pushback();
- return '+';
-
- case '!':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_notequal;
- return RELOP;
- }
- if (c == '~') {
- yylval.nodetypeval = Node_nomatch;
- want_assign = 0;
- return MATCHOP;
- }
- pushback();
- return '!';
-
- case '<':
- if (nextc() == '=') {
- yylval.nodetypeval = Node_leq;
- return RELOP;
- }
- yylval.nodetypeval = Node_less;
- pushback();
- return '<';
-
- case '=':
- if (nextc() == '=') {
- yylval.nodetypeval = Node_equal;
- return RELOP;
- }
- yylval.nodetypeval = Node_assign;
- pushback();
- return ASSIGNOP;
-
- case '>':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_geq;
- return RELOP;
- } else if (c == '>') {
- yylval.nodetypeval = Node_redirect_append;
- return APPEND_OP;
- }
- yylval.nodetypeval = Node_greater;
- pushback();
- return '>';
-
- case '~':
- yylval.nodetypeval = Node_match;
- want_assign = 0;
- return MATCHOP;
-
- case '}':
- /*
- * Added did newline stuff. Easier than
- * hacking the grammar
- */
- if (did_newline) {
- did_newline = 0;
- return c;
- }
- did_newline++;
- --lexptr; /* pick up } next time */
- return NEWLINE;
-
- case '"':
- esc_seen = 0;
- while ((c = nextc()) != '"') {
- if (c == '\n') {
- pushback();
- yyerror("unterminated string");
- }
- if (c == '\\') {
- c = nextc();
- if (c == '\n') {
- sourceline++;
- continue;
- }
- esc_seen = 1;
- tokadd('\\');
- }
- if (c == '\0') {
- pushback();
- yyerror("unterminated string");
- }
- tokadd(c);
- }
- yylval.nodeval = make_str_node(tokstart,
- token - tokstart, esc_seen ? SCAN : 0);
- yylval.nodeval->flags |= PERM;
- return YSTRING;
-
- case '-':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_assign_minus;
- return ASSIGNOP;
- }
- if (c == '-')
- return DECREMENT;
- pushback();
- return '-';
-
- case '.':
- c = nextc();
- pushback();
- if (!isdigit(c))
- return '.';
- else
- c = '.'; /* FALL THROUGH */
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- /* It's a number */
- for (;;) {
- int gotnumber = 0;
-
- tokadd(c);
- switch (c) {
- case '.':
- if (seen_point) {
- gotnumber++;
- break;
- }
- ++seen_point;
- break;
- case 'e':
- case 'E':
- if (seen_e) {
- gotnumber++;
- break;
- }
- ++seen_e;
- if ((c = nextc()) == '-' || c == '+')
- tokadd(c);
- else
- pushback();
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- break;
- default:
- gotnumber++;
- }
- if (gotnumber)
- break;
- c = nextc();
- }
- pushback();
- yylval.nodeval = make_number(atof(tokstart));
- yylval.nodeval->flags |= PERM;
- return YNUMBER;
-
- case '&':
- if ((c = nextc()) == '&') {
- yylval.nodetypeval = Node_and;
- for (;;) {
- c = nextc();
- if (c == '\0')
- break;
- if (c == '#') {
- while ((c = nextc()) != '\n' && c != '\0')
- ;
- if (c == '\0')
- break;
- }
- if (c == '\n')
- sourceline++;
- if (! isspace(c)) {
- pushback();
- break;
- }
- }
- want_assign = 0;
- return LEX_AND;
- }
- pushback();
- return '&';
-
- case '|':
- if ((c = nextc()) == '|') {
- yylval.nodetypeval = Node_or;
- for (;;) {
- c = nextc();
- if (c == '\0')
- break;
- if (c == '#') {
- while ((c = nextc()) != '\n' && c != '\0')
- ;
- if (c == '\0')
- break;
- }
- if (c == '\n')
- sourceline++;
- if (! isspace(c)) {
- pushback();
- break;
- }
- }
- want_assign = 0;
- return LEX_OR;
- }
- pushback();
- return '|';
- }
-
- if (c != '_' && ! isalpha(c))
- yyerror("Invalid char '%c' in expression\n", c);
-
- /* it's some type of name-type-thing. Find its length */
- token = tokstart;
- while (is_identchar(c)) {
- tokadd(c);
- c = nextc();
- }
- tokadd('\0');
- emalloc(tokkey, char *, token - tokstart, "yylex");
- memcpy(tokkey, tokstart, token - tokstart);
- pushback();
-
- /* See if it is a special token. */
- low = 0;
- high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
- while (low <= high) {
- int i/* , c */;
-
- mid = (low + high) / 2;
- c = *tokstart - tokentab[mid].operator[0];
- i = c ? c : strcmp (tokstart, tokentab[mid].operator);
-
- if (i < 0) { /* token < mid */
- high = mid - 1;
- } else if (i > 0) { /* token > mid */
- low = mid + 1;
- } else {
- if (do_lint) {
- if (tokentab[mid].flags & GAWKX)
- warning("%s() is a gawk extension",
- tokentab[mid].operator);
- if (tokentab[mid].flags & NOT_POSIX)
- warning("POSIX does not allow %s",
- tokentab[mid].operator);
- if (tokentab[mid].flags & NOT_OLD)
- warning("%s is not supported in old awk",
- tokentab[mid].operator);
- }
- if ((do_unix && (tokentab[mid].flags & GAWKX))
- || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
- break;
- if (tokentab[mid].class == LEX_BUILTIN
- || tokentab[mid].class == LEX_LENGTH
- )
- yylval.lval = mid;
- else
- yylval.nodetypeval = tokentab[mid].value;
-
- return tokentab[mid].class;
- }
- }
-
- yylval.sval = tokkey;
- if (*lexptr == '(')
- return FUNC_CALL;
- else {
- want_assign = 1;
- return NAME;
- }
-}
-
-static NODE *
-node_common(op)
-NODETYPE op;
-{
- register NODE *r;
-
- getnode(r);
- r->type = op;
- r->flags = MALLOC;
- /* if lookahead is NL, lineno is 1 too high */
- if (lexeme && *lexeme == '\n')
- r->source_line = sourceline - 1;
- else
- r->source_line = sourceline;
- r->source_file = source;
- return r;
-}
-
-/*
- * This allocates a node with defined lnode and rnode.
- */
-NODE *
-node(left, op, right)
-NODE *left, *right;
-NODETYPE op;
-{
- register NODE *r;
-
- r = node_common(op);
- r->lnode = left;
- r->rnode = right;
- return r;
-}
-
-/*
- * This allocates a node with defined subnode and proc for builtin functions
- * Checks for arg. count and supplies defaults where possible.
- */
-static NODE *
-snode(subn, op, idx)
-NODETYPE op;
-int idx;
-NODE *subn;
-{
- register NODE *r;
- register NODE *n;
- int nexp = 0;
- int args_allowed;
-
- r = node_common(op);
-
- /* traverse expression list to see how many args. given */
- for (n= subn; n; n= n->rnode) {
- nexp++;
- if (nexp > 3)
- break;
- }
-
- /* check against how many args. are allowed for this builtin */
- args_allowed = tokentab[idx].flags & ARGS;
- if (args_allowed && !(args_allowed & A(nexp)))
- fatal("%s() cannot have %d argument%c",
- tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
-
- r->proc = tokentab[idx].ptr;
-
- /* special case processing for a few builtins */
- if (nexp == 0 && r->proc == do_length) {
- subn = node(node(make_number(0.0),Node_field_spec,(NODE *)NULL),
- Node_expression_list,
- (NODE *) NULL);
- } else if (r->proc == do_match) {
- if (subn->rnode->lnode->type != Node_regex)
- subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
- } else if (r->proc == do_sub || r->proc == do_gsub) {
- if (subn->lnode->type != Node_regex)
- subn->lnode = mk_rexp(subn->lnode);
- if (nexp == 2)
- append_right(subn, node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_expression_list,
- (NODE *) NULL));
- else if (do_lint && subn->rnode->rnode->lnode->type == Node_val)
- warning("string literal as last arg of substitute");
- } else if (r->proc == do_split) {
- if (nexp == 2)
- append_right(subn,
- node(FS_node, Node_expression_list, (NODE *) NULL));
- n = subn->rnode->rnode->lnode;
- if (n->type != Node_regex)
- subn->rnode->rnode->lnode = mk_rexp(n);
- if (nexp == 2)
- subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
- }
-
- r->subnode = subn;
- return r;
-}
-
-/*
- * This allocates a Node_line_range node with defined condpair and
- * zeroes the trigger word to avoid the temptation of assuming that calling
- * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'.
- */
-/* Otherwise like node() */
-static NODE *
-mkrangenode(cpair)
-NODE *cpair;
-{
- register NODE *r;
-
- getnode(r);
- r->type = Node_line_range;
- r->condpair = cpair;
- r->triggered = 0;
- return r;
-}
-
-/* Build a for loop */
-static NODE *
-make_for_loop(init, cond, incr)
-NODE *init, *cond, *incr;
-{
- register FOR_LOOP_HEADER *r;
- NODE *n;
-
- emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
- getnode(n);
- n->type = Node_illegal;
- r->init = init;
- r->cond = cond;
- r->incr = incr;
- n->sub.nodep.r.hd = r;
- return n;
-}
-
-/*
- * Install a name in the symbol table, even if it is already there.
- * Caller must check against redefinition if that is desired.
- */
-NODE *
-install(name, value)
-char *name;
-NODE *value;
-{
- register NODE *hp;
- register int len, bucket;
-
- len = strlen(name);
- bucket = hash(name, len);
- getnode(hp);
- hp->type = Node_hashnode;
- hp->hnext = variables[bucket];
- variables[bucket] = hp;
- hp->hlength = len;
- hp->hvalue = value;
- hp->hname = name;
- hp->hvalue->vname = name;
- return hp->hvalue;
-}
-
-/* find the most recent hash node for name installed by install */
-NODE *
-lookup(name)
-char *name;
-{
- register NODE *bucket;
- register int len;
-
- len = strlen(name);
- bucket = variables[hash(name, len)];
- while (bucket) {
- if (bucket->hlength == len && STREQN(bucket->hname, name, len))
- return bucket->hvalue;
- bucket = bucket->hnext;
- }
- return NULL;
-}
-
-/*
- * Add new to the rightmost branch of LIST. This uses n^2 time, so we make
- * a simple attempt at optimizing it.
- */
-static NODE *
-append_right(list, new)
-NODE *list, *new;
-{
- register NODE *oldlist;
- static NODE *savefront = NULL, *savetail = NULL;
-
- oldlist = list;
- if (savefront == oldlist) {
- savetail = savetail->rnode = new;
- return oldlist;
- } else
- savefront = oldlist;
- while (list->rnode != NULL)
- list = list->rnode;
- savetail = list->rnode = new;
- return oldlist;
-}
-
-/*
- * check if name is already installed; if so, it had better have Null value,
- * in which case def is added as the value. Otherwise, install name with def
- * as value.
- */
-static void
-func_install(params, def)
-NODE *params;
-NODE *def;
-{
- NODE *r;
-
- pop_params(params->rnode);
- pop_var(params, 0);
- r = lookup(params->param);
- if (r != NULL) {
- fatal("function name `%s' previously defined", params->param);
- } else
- (void) install(params->param, node(params, Node_func, def));
-}
-
-static void
-pop_var(np, freeit)
-NODE *np;
-int freeit;
-{
- register NODE *bucket, **save;
- register int len;
- char *name;
-
- name = np->param;
- len = strlen(name);
- save = &(variables[hash(name, len)]);
- for (bucket = *save; bucket; bucket = bucket->hnext) {
- if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
- *save = bucket->hnext;
- freenode(bucket);
- if (freeit)
- free(np->param);
- return;
- }
- save = &(bucket->hnext);
- }
-}
-
-static void
-pop_params(params)
-NODE *params;
-{
- register NODE *np;
-
- for (np = params; np != NULL; np = np->rnode)
- pop_var(np, 1);
-}
-
-static NODE *
-make_param(name)
-char *name;
-{
- NODE *r;
-
- getnode(r);
- r->type = Node_param_list;
- r->rnode = NULL;
- r->param = name;
- r->param_cnt = param_counter++;
- return (install(name, r));
-}
-
-/* Name points to a variable name. Make sure its in the symbol table */
-NODE *
-variable(name, can_free)
-char *name;
-int can_free;
-{
- register NODE *r;
- static int env_loaded = 0;
-
- if (!env_loaded && STREQ(name, "ENVIRON")) {
- load_environ();
- env_loaded = 1;
- }
- if ((r = lookup(name)) == NULL)
- r = install(name, node(Nnull_string, Node_var, (NODE *) NULL));
- else if (can_free)
- free(name);
- return r;
-}
-
-static NODE *
-mk_rexp(exp)
-NODE *exp;
-{
- if (exp->type == Node_regex)
- return exp;
- else {
- NODE *n;
-
- getnode(n);
- n->type = Node_regex;
- n->re_exp = exp;
- n->re_text = NULL;
- n->re_reg = NULL;
- n->re_flags = 0;
- n->re_cnt = 1;
- return n;
- }
-}
diff --git a/gnu/usr.bin/awk/builtin.c b/gnu/usr.bin/awk/builtin.c
deleted file mode 100644
index 9d5e3b3..0000000
--- a/gnu/usr.bin/awk/builtin.c
+++ /dev/null
@@ -1,1133 +0,0 @@
-/*
- * builtin.c - Builtin functions and various utility procedures
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#include "awk.h"
-
-
-#ifndef SRANDOM_PROTO
-extern void srandom P((int seed));
-#endif
-#ifndef linux
-extern char *initstate P((unsigned seed, char *state, int n));
-extern char *setstate P((char *state));
-extern long random P((void));
-#endif
-
-extern NODE **fields_arr;
-extern int output_is_tty;
-
-static NODE *sub_common P((NODE *tree, int global));
-
-#ifdef GFMT_WORKAROUND
-char *gfmt P((double g, int prec, char *buf));
-#endif
-
-#ifdef _CRAY
-/* Work around a problem in conversion of doubles to exact integers. */
-#include <float.h>
-#define Floor(n) floor((n) * (1.0 + DBL_EPSILON))
-#define Ceil(n) ceil((n) * (1.0 + DBL_EPSILON))
-
-/* Force the standard C compiler to use the library math functions. */
-extern double exp(double);
-double (*Exp)() = exp;
-#define exp(x) (*Exp)(x)
-extern double log(double);
-double (*Log)() = log;
-#define log(x) (*Log)(x)
-#else
-#define Floor(n) floor(n)
-#define Ceil(n) ceil(n)
-#endif
-
-static void
-efwrite(ptr, size, count, fp, from, rp, flush)
-void *ptr;
-unsigned size, count;
-FILE *fp;
-char *from;
-struct redirect *rp;
-int flush;
-{
- errno = 0;
- if (fwrite(ptr, size, count, fp) != count)
- goto wrerror;
- if (flush
- && ((fp == stdout && output_is_tty)
- || (rp && (rp->flag & RED_NOBUF)))) {
- fflush(fp);
- if (ferror(fp))
- goto wrerror;
- }
- return;
-
- wrerror:
- fatal("%s to \"%s\" failed (%s)", from,
- rp ? rp->value : "standard output",
- errno ? strerror(errno) : "reason unknown");
-}
-
-/* Builtin functions */
-NODE *
-do_exp(tree)
-NODE *tree;
-{
- NODE *tmp;
- double d, res;
-#ifndef exp
- double exp P((double));
-#endif
-
- tmp= tree_eval(tree->lnode);
- d = force_number(tmp);
- free_temp(tmp);
- errno = 0;
- res = exp(d);
- if (errno == ERANGE)
- warning("exp argument %g is out of range", d);
- return tmp_number((AWKNUM) res);
-}
-
-NODE *
-do_index(tree)
-NODE *tree;
-{
- NODE *s1, *s2;
- register char *p1, *p2;
- register int l1, l2;
- long ret;
-
-
- s1 = tree_eval(tree->lnode);
- s2 = tree_eval(tree->rnode->lnode);
- force_string(s1);
- force_string(s2);
- p1 = s1->stptr;
- p2 = s2->stptr;
- l1 = s1->stlen;
- l2 = s2->stlen;
- ret = 0;
- if (IGNORECASE) {
- while (l1) {
- if (l2 > l1)
- break;
- if (casetable[(int)*p1] == casetable[(int)*p2]
- && (l2 == 1 || strncasecmp(p1, p2, l2) == 0)) {
- ret = 1 + s1->stlen - l1;
- break;
- }
- l1--;
- p1++;
- }
- } else {
- while (l1) {
- if (l2 > l1)
- break;
- if (*p1 == *p2
- && (l2 == 1 || STREQN(p1, p2, l2))) {
- ret = 1 + s1->stlen - l1;
- break;
- }
- l1--;
- p1++;
- }
- }
- free_temp(s1);
- free_temp(s2);
- return tmp_number((AWKNUM) ret);
-}
-
-NODE *
-do_int(tree)
-NODE *tree;
-{
- NODE *tmp;
- double floor P((double));
- double ceil P((double));
- double d;
-
- tmp = tree_eval(tree->lnode);
- d = force_number(tmp);
- if (d >= 0)
- d = Floor(d);
- else
- d = Ceil(d);
- free_temp(tmp);
- return tmp_number((AWKNUM) d);
-}
-
-NODE *
-do_length(tree)
-NODE *tree;
-{
- NODE *tmp;
- int len;
-
- tmp = tree_eval(tree->lnode);
- len = force_string(tmp)->stlen;
- free_temp(tmp);
- return tmp_number((AWKNUM) len);
-}
-
-NODE *
-do_log(tree)
-NODE *tree;
-{
- NODE *tmp;
-#ifndef log
- double log P((double));
-#endif
- double d, arg;
-
- tmp = tree_eval(tree->lnode);
- arg = (double) force_number(tmp);
- if (arg < 0.0)
- warning("log called with negative argument %g", arg);
- d = log(arg);
- free_temp(tmp);
- return tmp_number((AWKNUM) d);
-}
-
-/* %e and %f formats are not properly implemented. Someone should fix them */
-/* Actually, this whole thing should be reimplemented. */
-
-NODE *
-do_sprintf(tree)
-NODE *tree;
-{
-#define bchunk(s,l) if(l) {\
- while((l)>ofre) {\
- erealloc(obuf, char *, osiz*2, "do_sprintf");\
- ofre+=osiz;\
- osiz*=2;\
- }\
- memcpy(obuf+olen,s,(l));\
- olen+=(l);\
- ofre-=(l);\
- }
-
- /* Is there space for something L big in the buffer? */
-#define chksize(l) if((l)>ofre) {\
- erealloc(obuf, char *, osiz*2, "do_sprintf");\
- ofre+=osiz;\
- osiz*=2;\
- }
-
- /*
- * Get the next arg to be formatted. If we've run out of args,
- * return "" (Null string)
- */
-#define parse_next_arg() {\
- if(!carg) { toofew = 1; break; }\
- else {\
- arg=tree_eval(carg->lnode);\
- carg=carg->rnode;\
- }\
- }
-
- NODE *r;
- int toofew = 0;
- char *obuf;
- int osiz, ofre, olen;
- static char chbuf[] = "0123456789abcdef";
- static char sp[] = " ";
- char *s0, *s1;
- int n0;
- NODE *sfmt, *arg;
- register NODE *carg;
- long fw, prec, lj, alt, big;
- long *cur;
- long val;
-#ifdef sun386 /* Can't cast unsigned (int/long) from ptr->value */
- long tmp_uval; /* on 386i 4.0.1 C compiler -- it just hangs */
-#endif
- unsigned long uval;
- int sgn;
- int base;
- char cpbuf[30]; /* if we have numbers bigger than 30 */
- char *cend = &cpbuf[30];/* chars, we lose, but seems unlikely */
- char *cp;
- char *fill;
- double tmpval;
- char *pr_str;
- int ucasehex = 0;
- char signchar = 0;
- int len;
-
-
- emalloc(obuf, char *, 120, "do_sprintf");
- osiz = 120;
- ofre = osiz - 1;
- olen = 0;
- sfmt = tree_eval(tree->lnode);
- sfmt = force_string(sfmt);
- carg = tree->rnode;
- for (s0 = s1 = sfmt->stptr, n0 = sfmt->stlen; n0-- > 0;) {
- if (*s1 != '%') {
- s1++;
- continue;
- }
- bchunk(s0, s1 - s0);
- s0 = s1;
- cur = &fw;
- fw = 0;
- prec = 0;
- lj = alt = big = 0;
- fill = sp;
- cp = cend;
- s1++;
-
-retry:
- --n0;
- switch (*s1++) {
- case '%':
- bchunk("%", 1);
- s0 = s1;
- break;
-
- case '0':
- if (fill != sp || lj)
- goto lose;
- if (cur == &fw)
- fill = "0"; /* FALL through */
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (cur == 0)
- goto lose;
- *cur = s1[-1] - '0';
- while (n0 > 0 && *s1 >= '0' && *s1 <= '9') {
- --n0;
- *cur = *cur * 10 + *s1++ - '0';
- }
- goto retry;
- case '*':
- if (cur == 0)
- goto lose;
- parse_next_arg();
- *cur = force_number(arg);
- free_temp(arg);
- goto retry;
- case ' ': /* print ' ' or '-' */
- case '+': /* print '+' or '-' */
- signchar = *(s1-1);
- goto retry;
- case '-':
- if (lj || fill != sp)
- goto lose;
- lj++;
- goto retry;
- case '.':
- if (cur != &fw)
- goto lose;
- cur = &prec;
- goto retry;
- case '#':
- if (alt)
- goto lose;
- alt++;
- goto retry;
- case 'l':
- if (big)
- goto lose;
- big++;
- goto retry;
- case 'c':
- parse_next_arg();
- if (arg->flags & NUMBER) {
-#ifdef sun386
- tmp_uval = arg->numbr;
- uval= (unsigned long) tmp_uval;
-#else
- uval = (unsigned long) arg->numbr;
-#endif
- cpbuf[0] = uval;
- prec = 1;
- pr_str = cpbuf;
- goto dopr_string;
- }
- if (! prec)
- prec = 1;
- else if (prec > arg->stlen)
- prec = arg->stlen;
- pr_str = arg->stptr;
- goto dopr_string;
- case 's':
- parse_next_arg();
- arg = force_string(arg);
- if (!prec || prec > arg->stlen)
- prec = arg->stlen;
- pr_str = arg->stptr;
-
- dopr_string:
- if (fw > prec && !lj) {
- while (fw > prec) {
- bchunk(sp, 1);
- fw--;
- }
- }
- bchunk(pr_str, (int) prec);
- if (fw > prec) {
- while (fw > prec) {
- bchunk(sp, 1);
- fw--;
- }
- }
- s0 = s1;
- free_temp(arg);
- break;
- case 'd':
- case 'i':
- parse_next_arg();
- val = (long) force_number(arg);
- free_temp(arg);
- if (val < 0) {
- sgn = 1;
- val = -val;
- } else
- sgn = 0;
- do {
- *--cp = '0' + val % 10;
- val /= 10;
- } while (val);
- if (sgn)
- *--cp = '-';
- else if (signchar)
- *--cp = signchar;
- if (prec > fw)
- fw = prec;
- prec = cend - cp;
- if (fw > prec && !lj) {
- if (fill != sp && (*cp == '-' || signchar)) {
- bchunk(cp, 1);
- cp++;
- prec--;
- fw--;
- }
- while (fw > prec) {
- bchunk(fill, 1);
- fw--;
- }
- }
- bchunk(cp, (int) prec);
- if (fw > prec) {
- while (fw > prec) {
- bchunk(fill, 1);
- fw--;
- }
- }
- s0 = s1;
- break;
- case 'u':
- base = 10;
- goto pr_unsigned;
- case 'o':
- base = 8;
- goto pr_unsigned;
- case 'X':
- ucasehex = 1;
- case 'x':
- base = 16;
- goto pr_unsigned;
- pr_unsigned:
- parse_next_arg();
- uval = (unsigned long) force_number(arg);
- free_temp(arg);
- do {
- *--cp = chbuf[uval % base];
- if (ucasehex && isalpha(*cp))
- *cp = toupper(*cp);
- uval /= base;
- } while (uval);
- if (alt && (base == 8 || base == 16)) {
- if (base == 16) {
- if (ucasehex)
- *--cp = 'X';
- else
- *--cp = 'x';
- }
- *--cp = '0';
- }
- prec = cend - cp;
- if (fw > prec && !lj) {
- while (fw > prec) {
- bchunk(fill, 1);
- fw--;
- }
- }
- bchunk(cp, (int) prec);
- if (fw > prec) {
- while (fw > prec) {
- bchunk(fill, 1);
- fw--;
- }
- }
- s0 = s1;
- break;
- case 'g':
- parse_next_arg();
- tmpval = force_number(arg);
- free_temp(arg);
- chksize(fw + prec + 9); /* 9==slop */
-
- cp = cpbuf;
- *cp++ = '%';
- if (lj)
- *cp++ = '-';
- if (fill != sp)
- *cp++ = '0';
-#ifndef GFMT_WORKAROUND
- if (cur != &fw) {
- (void) strcpy(cp, "*.*g");
- (void) sprintf(obuf + olen, cpbuf, (int) fw, (int) prec, (double) tmpval);
- } else {
- (void) strcpy(cp, "*g");
- (void) sprintf(obuf + olen, cpbuf, (int) fw, (double) tmpval);
- }
-#else /* GFMT_WORKAROUND */
- {
- char *gptr, gbuf[120];
-#define DEFAULT_G_PRECISION 6
- if (fw + prec + 9 > sizeof gbuf) { /* 9==slop */
- emalloc(gptr, char *, fw+prec+9, "do_sprintf(gfmt)");
- } else
- gptr = gbuf;
- (void) gfmt((double) tmpval, cur != &fw ?
- (int) prec : DEFAULT_G_PRECISION, gptr);
- *cp++ = '*', *cp++ = 's', *cp = '\0';
- (void) sprintf(obuf + olen, cpbuf, (int) fw, gptr);
- if (fill != sp && *gptr == ' ') {
- char *p = gptr;
- do { *p++ = '0'; } while (*p == ' ');
- }
- if (gptr != gbuf) free(gptr);
- }
-#endif /* GFMT_WORKAROUND */
- len = strlen(obuf + olen);
- ofre -= len;
- olen += len;
- s0 = s1;
- break;
-
- case 'f':
- parse_next_arg();
- tmpval = force_number(arg);
- free_temp(arg);
- chksize(fw + prec + 9); /* 9==slop */
-
- cp = cpbuf;
- *cp++ = '%';
- if (lj)
- *cp++ = '-';
- if (fill != sp)
- *cp++ = '0';
- if (cur != &fw) {
- (void) strcpy(cp, "*.*f");
- (void) sprintf(obuf + olen, cpbuf, (int) fw, (int) prec, (double) tmpval);
- } else {
- (void) strcpy(cp, "*f");
- (void) sprintf(obuf + olen, cpbuf, (int) fw, (double) tmpval);
- }
- len = strlen(obuf + olen);
- ofre -= len;
- olen += len;
- s0 = s1;
- break;
- case 'e':
- parse_next_arg();
- tmpval = force_number(arg);
- free_temp(arg);
- chksize(fw + prec + 9); /* 9==slop */
- cp = cpbuf;
- *cp++ = '%';
- if (lj)
- *cp++ = '-';
- if (fill != sp)
- *cp++ = '0';
- if (cur != &fw) {
- (void) strcpy(cp, "*.*e");
- (void) sprintf(obuf + olen, cpbuf, (int) fw, (int) prec, (double) tmpval);
- } else {
- (void) strcpy(cp, "*e");
- (void) sprintf(obuf + olen, cpbuf, (int) fw, (double) tmpval);
- }
- len = strlen(obuf + olen);
- ofre -= len;
- olen += len;
- s0 = s1;
- break;
-
- default:
- lose:
- break;
- }
- if (toofew)
- fatal("%s\n\t%s\n\t%*s%s",
- "not enough arguments to satisfy format string",
- sfmt->stptr, s1 - sfmt->stptr - 2, "",
- "^ ran out for this one"
- );
- }
- if (do_lint && carg != NULL)
- warning("too many arguments supplied for format string");
- bchunk(s0, s1 - s0);
- free_temp(sfmt);
- r = make_str_node(obuf, olen, ALREADY_MALLOCED);
- r->flags |= TEMP;
- return r;
-}
-
-void
-do_printf(tree)
-register NODE *tree;
-{
- struct redirect *rp = NULL;
- register FILE *fp;
-
- if (tree->rnode) {
- int errflg; /* not used, sigh */
-
- rp = redirect(tree->rnode, &errflg);
- if (rp) {
- fp = rp->fp;
- if (!fp)
- return;
- } else
- return;
- } else
- fp = stdout;
- tree = do_sprintf(tree->lnode);
- efwrite(tree->stptr, sizeof(char), tree->stlen, fp, "printf", rp , 1);
- free_temp(tree);
-}
-
-NODE *
-do_sqrt(tree)
-NODE *tree;
-{
- NODE *tmp;
- double arg;
- extern double sqrt P((double));
-
- tmp = tree_eval(tree->lnode);
- arg = (double) force_number(tmp);
- free_temp(tmp);
- if (arg < 0.0)
- warning("sqrt called with negative argument %g", arg);
- return tmp_number((AWKNUM) sqrt(arg));
-}
-
-NODE *
-do_substr(tree)
-NODE *tree;
-{
- NODE *t1, *t2, *t3;
- NODE *r;
- register int indx;
- size_t length;
-
- t1 = tree_eval(tree->lnode);
- t2 = tree_eval(tree->rnode->lnode);
- if (tree->rnode->rnode == NULL) /* third arg. missing */
- length = t1->stlen;
- else {
- t3 = tree_eval(tree->rnode->rnode->lnode);
- length = (size_t) force_number(t3);
- free_temp(t3);
- }
- indx = (int) force_number(t2) - 1;
- free_temp(t2);
- t1 = force_string(t1);
- if (indx < 0)
- indx = 0;
- if (indx >= t1->stlen || length <= 0) {
- free_temp(t1);
- return Nnull_string;
- }
- if (indx + length > t1->stlen || LONG_MAX - indx < length)
- length = t1->stlen - indx;
- r = tmp_string(t1->stptr + indx, length);
- free_temp(t1);
- return r;
-}
-
-NODE *
-do_strftime(tree)
-NODE *tree;
-{
- NODE *t1, *t2;
- struct tm *tm;
- time_t fclock;
- char buf[100];
- int ret;
-
- t1 = force_string(tree_eval(tree->lnode));
-
- if (tree->rnode == NULL) /* second arg. missing, default */
- (void) time(&fclock);
- else {
- t2 = tree_eval(tree->rnode->lnode);
- fclock = (time_t) force_number(t2);
- free_temp(t2);
- }
- tm = localtime(&fclock);
-
- ret = strftime(buf, 100, t1->stptr, tm);
-
- return tmp_string(buf, ret);
-}
-
-NODE *
-do_systime(tree)
-NODE *tree;
-{
- time_t lclock;
-
- (void) time(&lclock);
- return tmp_number((AWKNUM) lclock);
-}
-
-NODE *
-do_system(tree)
-NODE *tree;
-{
- NODE *tmp;
- int ret = 0;
- char *cmd;
-
- (void) flush_io (); /* so output is synchronous with gawk's */
- tmp = tree_eval(tree->lnode);
- cmd = force_string(tmp)->stptr;
- if (cmd && *cmd) {
- ret = system(cmd);
- ret = (ret >> 8) & 0xff;
- }
- free_temp(tmp);
- return tmp_number((AWKNUM) ret);
-}
-
-void
-do_print(tree)
-register NODE *tree;
-{
- register NODE *t1;
- struct redirect *rp = NULL;
- register FILE *fp;
- register char *s;
-
- if (tree->rnode) {
- int errflg; /* not used, sigh */
-
- rp = redirect(tree->rnode, &errflg);
- if (rp) {
- fp = rp->fp;
- if (!fp)
- return;
- } else
- return;
- } else
- fp = stdout;
- tree = tree->lnode;
- while (tree) {
- t1 = tree_eval(tree->lnode);
- if (t1->flags & NUMBER) {
- if (OFMTidx == CONVFMTidx)
- (void) force_string(t1);
- else {
- char buf[100];
-
- sprintf(buf, OFMT, t1->numbr);
- t1 = tmp_string(buf, strlen(buf));
- }
- }
- efwrite(t1->stptr, sizeof(char), t1->stlen, fp, "print", rp, 0);
- free_temp(t1);
- tree = tree->rnode;
- if (tree) {
- s = OFS;
- if (OFSlen)
- efwrite(s, sizeof(char), OFSlen, fp, "print", rp, 0);
- }
- }
- s = ORS;
- if (ORSlen)
- efwrite(s, sizeof(char), ORSlen, fp, "print", rp, 1);
-}
-
-NODE *
-do_tolower(tree)
-NODE *tree;
-{
- NODE *t1, *t2;
- register char *cp, *cp2;
-
- t1 = tree_eval(tree->lnode);
- t1 = force_string(t1);
- t2 = tmp_string(t1->stptr, t1->stlen);
- for (cp = t2->stptr, cp2 = t2->stptr + t2->stlen; cp < cp2; cp++)
- if (isupper(*cp))
- *cp = tolower(*cp);
- free_temp(t1);
- return t2;
-}
-
-NODE *
-do_toupper(tree)
-NODE *tree;
-{
- NODE *t1, *t2;
- register char *cp;
-
- t1 = tree_eval(tree->lnode);
- t1 = force_string(t1);
- t2 = tmp_string(t1->stptr, t1->stlen);
- for (cp = t2->stptr; cp < t2->stptr + t2->stlen; cp++)
- if (islower(*cp))
- *cp = toupper(*cp);
- free_temp(t1);
- return t2;
-}
-
-NODE *
-do_atan2(tree)
-NODE *tree;
-{
- NODE *t1, *t2;
- extern double atan2 P((double, double));
- double d1, d2;
-
- t1 = tree_eval(tree->lnode);
- t2 = tree_eval(tree->rnode->lnode);
- d1 = force_number(t1);
- d2 = force_number(t2);
- free_temp(t1);
- free_temp(t2);
- return tmp_number((AWKNUM) atan2(d1, d2));
-}
-
-NODE *
-do_sin(tree)
-NODE *tree;
-{
- NODE *tmp;
- extern double sin P((double));
- double d;
-
- tmp = tree_eval(tree->lnode);
- d = sin((double)force_number(tmp));
- free_temp(tmp);
- return tmp_number((AWKNUM) d);
-}
-
-NODE *
-do_cos(tree)
-NODE *tree;
-{
- NODE *tmp;
- extern double cos P((double));
- double d;
-
- tmp = tree_eval(tree->lnode);
- d = cos((double)force_number(tmp));
- free_temp(tmp);
- return tmp_number((AWKNUM) d);
-}
-
-static int firstrand = 1;
-static char state[256];
-
-/* ARGSUSED */
-NODE *
-do_rand(tree)
-NODE *tree;
-{
- if (firstrand) {
- (void) initstate((unsigned) 1, state, sizeof state);
- srandom(1);
- firstrand = 0;
- }
- return tmp_number((AWKNUM) random() / LONG_MAX);
-}
-
-NODE *
-do_srand(tree)
-NODE *tree;
-{
- NODE *tmp;
- static long save_seed = 0;
- long ret = save_seed; /* SVR4 awk srand returns previous seed */
-
- if (firstrand)
- (void) initstate((unsigned) 1, state, sizeof state);
- else
- (void) setstate(state);
-
- if (!tree)
- srandom((int) (save_seed = (long) time((time_t *) 0)));
- else {
- tmp = tree_eval(tree->lnode);
- srandom((int) (save_seed = (long) force_number(tmp)));
- free_temp(tmp);
- }
- firstrand = 0;
- return tmp_number((AWKNUM) ret);
-}
-
-NODE *
-do_match(tree)
-NODE *tree;
-{
- NODE *t1;
- int rstart;
- AWKNUM rlength;
- Regexp *rp;
-
- t1 = force_string(tree_eval(tree->lnode));
- tree = tree->rnode->lnode;
- rp = re_update(tree);
- rstart = research(rp, t1->stptr, 0, t1->stlen, 1);
- if (rstart >= 0) { /* match succeded */
- rstart++; /* 1-based indexing */
- rlength = REEND(rp, t1->stptr) - RESTART(rp, t1->stptr);
- } else { /* match failed */
- rstart = 0;
- rlength = -1.0;
- }
- free_temp(t1);
- unref(RSTART_node->var_value);
- RSTART_node->var_value = make_number((AWKNUM) rstart);
- unref(RLENGTH_node->var_value);
- RLENGTH_node->var_value = make_number(rlength);
- return tmp_number((AWKNUM) rstart);
-}
-
-static NODE *
-sub_common(tree, global)
-NODE *tree;
-int global;
-{
- register char *scan;
- register char *bp, *cp;
- char *buf;
- int buflen;
- register char *matchend;
- register int len;
- char *matchstart;
- char *text;
- int textlen;
- char *repl;
- char *replend;
- int repllen;
- int sofar;
- int ampersands;
- int matches = 0;
- Regexp *rp;
- NODE *s; /* subst. pattern */
- NODE *t; /* string to make sub. in; $0 if none given */
- NODE *tmp;
- NODE **lhs = &tree; /* value not used -- just different from NULL */
- int priv = 0;
- Func_ptr after_assign = NULL;
-
- tmp = tree->lnode;
- rp = re_update(tmp);
-
- tree = tree->rnode;
- s = tree->lnode;
-
- tree = tree->rnode;
- tmp = tree->lnode;
- t = force_string(tree_eval(tmp));
-
- /* do the search early to avoid work on non-match */
- if (research(rp, t->stptr, 0, t->stlen, 1) == -1 ||
- (RESTART(rp, t->stptr) > t->stlen) && (matches = 1)) {
- free_temp(t);
- return tmp_number((AWKNUM) matches);
- }
-
- if (tmp->type == Node_val)
- lhs = NULL;
- else
- lhs = get_lhs(tmp, &after_assign);
- t->flags |= STRING;
- /*
- * create a private copy of the string
- */
- if (t->stref > 1 || (t->flags & PERM)) {
- unsigned int saveflags;
-
- saveflags = t->flags;
- t->flags &= ~MALLOC;
- tmp = dupnode(t);
- t->flags = saveflags;
- t = tmp;
- priv = 1;
- }
- text = t->stptr;
- textlen = t->stlen;
- buflen = textlen + 2;
-
- s = force_string(tree_eval(s));
- repl = s->stptr;
- replend = repl + s->stlen;
- repllen = replend - repl;
- emalloc(buf, char *, buflen, "do_sub");
- ampersands = 0;
- for (scan = repl; scan < replend; scan++) {
- if (*scan == '&') {
- repllen--;
- ampersands++;
- } else if (*scan == '\\' && (*(scan+1) == '&' || *(scan+1) == '\\')) {
- repllen--;
- scan++;
- }
- }
-
- bp = buf;
- for (;;) {
- matches++;
- matchstart = t->stptr + RESTART(rp, t->stptr);
- matchend = t->stptr + REEND(rp, t->stptr);
-
- /*
- * create the result, copying in parts of the original
- * string
- */
- len = matchstart - text + repllen
- + ampersands * (matchend - matchstart);
- sofar = bp - buf;
- while (buflen - sofar - len - 1 < 0) {
- buflen *= 2;
- erealloc(buf, char *, buflen, "do_sub");
- bp = buf + sofar;
- }
- for (scan = text; scan < matchstart; scan++)
- *bp++ = *scan;
- for (scan = repl; scan < replend; scan++)
- if (*scan == '&')
- for (cp = matchstart; cp < matchend; cp++)
- *bp++ = *cp;
- else if (*scan == '\\' && (*(scan+1) == '&' || *(scan+1) == '\\')) {
- scan++;
- *bp++ = *scan;
- } else
- *bp++ = *scan;
- if (global && matchstart == matchend && matchend < text + textlen) {
- *bp++ = *matchend;
- matchend++;
- }
- textlen = text + textlen - matchend;
- text = matchend;
- if (!global || textlen <= 0 ||
- research(rp, t->stptr, text-t->stptr, textlen, 1) == -1)
- break;
- }
- sofar = bp - buf;
- if (buflen - sofar - textlen - 1) {
- buflen = sofar + textlen + 2;
- erealloc(buf, char *, buflen, "do_sub");
- bp = buf + sofar;
- }
- for (scan = matchend; scan < text + textlen; scan++)
- *bp++ = *scan;
- textlen = bp - buf;
- free(t->stptr);
- t->stptr = buf;
- t->stlen = textlen;
-
- free_temp(s);
- if (matches > 0 && lhs) {
- if (priv) {
- unref(*lhs);
- *lhs = t;
- }
- if (after_assign)
- (*after_assign)();
- t->flags &= ~(NUM|NUMBER);
- }
- return tmp_number((AWKNUM) matches);
-}
-
-NODE *
-do_gsub(tree)
-NODE *tree;
-{
- return sub_common(tree, 1);
-}
-
-NODE *
-do_sub(tree)
-NODE *tree;
-{
- return sub_common(tree, 0);
-}
-
-#ifdef GFMT_WORKAROUND
- /*
- * printf's %g format [can't rely on gcvt()]
- * caveat: don't use as argument to *printf()!
- */
-char *
-gfmt(g, prec, buf)
-double g; /* value to format */
-int prec; /* indicates desired significant digits, not decimal places */
-char *buf; /* return buffer; assumed big enough to hold result */
-{
- if (g == 0.0) {
- (void) strcpy(buf, "0"); /* easy special case */
- } else {
- register char *d, *e, *p;
-
- /* start with 'e' format (it'll provide nice exponent) */
- if (prec < 1) prec = 1; /* at least 1 significant digit */
- (void) sprintf(buf, "%.*e", prec - 1, g);
- if ((e = strchr(buf, 'e')) != 0) { /* find exponent */
- int exp = atoi(e+1); /* fetch exponent */
- if (exp >= -4 && exp < prec) { /* per K&R2, B1.2 */
- /* switch to 'f' format and re-do */
- prec -= (exp + 1); /* decimal precision */
- (void) sprintf(buf, "%.*f", prec, g);
- e = buf + strlen(buf);
- }
- if ((d = strchr(buf, '.')) != 0) {
- /* remove trailing zeroes and decimal point */
- for (p = e; p > d && *--p == '0'; ) continue;
- if (*p == '.') --p;
- if (++p < e) /* copy exponent and NUL */
- while ((*p++ = *e++) != '\0') continue;
- }
- }
- }
- return buf;
-}
-#endif /* GFMT_WORKAROUND */
diff --git a/gnu/usr.bin/awk/config.h b/gnu/usr.bin/awk/config.h
deleted file mode 100644
index 8c20953..0000000
--- a/gnu/usr.bin/awk/config.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * config.h -- configuration definitions for gawk.
- *
- * For generic 4.4 alpha
- */
-
-/*
- * Copyright (C) 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
- * This file isolates configuration dependencies for gnu awk.
- * You should know something about your system, perhaps by having
- * a manual handy, when you edit this file. You should copy config.h-dist
- * to config.h, and edit config.h. Do not modify config.h-dist, so that
- * it will be easy to apply any patches that may be distributed.
- *
- * The general idea is that systems conforming to the various standards
- * should need to do the least amount of changing. Definining the various
- * items in ths file usually means that your system is missing that
- * particular feature.
- *
- * The order of preference in standard conformance is ANSI C, POSIX,
- * and the SVID.
- *
- * If you have no clue as to what's going on with your system, try
- * compiling gawk without editing this file and see what shows up
- * missing in the link stage. From there, you can probably figure out
- * which defines to turn on.
- */
-
-/**************************/
-/* Miscellanious features */
-/**************************/
-
-/*
- * BLKSIZE_MISSING
- *
- * Check your /usr/include/sys/stat.h file. If the stat structure
- * does not have a member named st_blksize, define this. (This will
- * most likely be the case on most System V systems prior to V.4.)
- */
-/* #define BLKSIZE_MISSING 1 */
-
-/*
- * SIGTYPE
- *
- * The return type of the routines passed to the signal function.
- * Modern systems use `void', older systems use `int'.
- * If left undefined, it will default to void.
- */
-/* #define SIGTYPE int */
-
-/*
- * SIZE_T_MISSING
- *
- * If your system has no typedef for size_t, define this to get a default
- */
-/* #define SIZE_T_MISSING 1 */
-
-/*
- * CHAR_UNSIGNED
- *
- * If your machine uses unsigned characters (IBM RT and RS/6000 and others)
- * then define this for use in regex.c
- */
-/* #define CHAR_UNSIGNED 1 */
-
-/*
- * HAVE_UNDERSCORE_SETJMP
- *
- * Check in your /usr/include/setjmp.h file. If there are routines
- * there named _setjmp and _longjmp, then you should define this.
- * Typically only systems derived from Berkeley Unix have this.
- */
-#define HAVE_UNDERSCORE_SETJMP 1
-
-/***********************************************/
-/* Missing library subroutines or system calls */
-/***********************************************/
-
-/*
- * MEMCMP_MISSING
- * MEMCPY_MISSING
- * MEMSET_MISSING
- *
- * These three routines are for manipulating blocks of memory. Most
- * likely they will either all three be present or all three be missing,
- * so they're grouped together.
- */
-/* #define MEMCMP_MISSING 1 */
-/* #define MEMCPY_MISSING 1 */
-/* #define MEMSET_MISSING 1 */
-
-/*
- * RANDOM_MISSING
- *
- * Your system does not have the random(3) suite of random number
- * generating routines. These are different than the old rand(3)
- * routines!
- */
-/* #define RANDOM_MISSING 1 */
-
-/*
- * STRCASE_MISSING
- *
- * Your system does not have the strcasemp() and strncasecmp()
- * routines that originated in Berkeley Unix.
- */
-/* #define STRCASE_MISSING 1 */
-
-/*
- * STRCHR_MISSING
- *
- * Your system does not have the strchr() and strrchr() functions.
- */
-/* #define STRCHR_MISSING 1 */
-
-/*
- * STRERROR_MISSING
- *
- * Your system lacks the ANSI C strerror() routine for returning the
- * strings associated with errno values.
- */
-/* #define STRERROR_MISSING 1 */
-
-/*
- * STRTOD_MISSING
- *
- * Your system does not have the strtod() routine for converting
- * strings to double precision floating point values.
- */
-/* #define STRTOD_MISSING 1 */
-
-/*
- * STRFTIME_MISSING
- *
- * Your system lacks the ANSI C strftime() routine for formatting
- * broken down time values.
- */
-/* #define STRFTIME_MISSING 1 */
-
-/*
- * TZSET_MISSING
- *
- * If you have a 4.2 BSD vintage system, then the strftime() routine
- * supplied in the missing directory won't be enough, because it relies on the
- * tzset() routine from System V / Posix. Fortunately, there is an
- * emulation for tzset() too that should do the trick. If you don't
- * have tzset(), define this.
- */
-/* #define TZSET_MISSING 1 */
-
-/*
- * TZNAME_MISSING
- *
- * Some systems do not support the external variables tzname and daylight.
- * If this is the case *and* strftime() is missing, define this.
- */
-/* #define TZNAME_MISSING 1 */
-
-/*
- * STDC_HEADERS
- *
- * If your system does have ANSI compliant header files that
- * provide prototypes for library routines, then define this.
- */
-#define STDC_HEADERS 1
-
-/*
- * NO_TOKEN_PASTING
- *
- * If your compiler define's __STDC__ but does not support token
- * pasting (tok##tok), then define this.
- */
-/* #define NO_TOKEN_PASTING 1 */
-
-/*****************************************************************/
-/* Stuff related to the Standard I/O Library. */
-/*****************************************************************/
-/* Much of this is (still, unfortunately) black magic in nature. */
-/* You may have to use some or all of these together to get gawk */
-/* to work correctly. */
-/*****************************************************************/
-
-/*
- * NON_STD_SPRINTF
- *
- * Look in your /usr/include/stdio.h file. If the return type of the
- * sprintf() function is NOT `int', define this.
- */
-/* #define NON_STD_SPRINTF 1 */
-
-/*
- * VPRINTF_MISSING
- *
- * Define this if your system lacks vprintf() and the other routines
- * that go with it. This will trigger an attempt to use _doprnt().
- * If you don't have that, this attempt will fail and you are on your own.
- */
-/* #define VPRINTF_MISSING 1 */
-
-/*
- * Casts from size_t to int and back. These will become unnecessary
- * at some point in the future, but for now are required where the
- * two types are a different representation.
- */
-/* #define SZTC */
-/* #define INTC */
-
-/*
- * SYSTEM_MISSING
- *
- * Define this if your library does not provide a system function
- * or you are not entirely happy with it and would rather use
- * a provided replacement (atari only).
- */
-/* #define SYSTEM_MISSING 1 */
-
-/*
- * FMOD_MISSING
- *
- * Define this if your system lacks the fmod() function and modf() will
- * be used instead.
- */
-/* #define FMOD_MISSING 1 */
-
-
-/*******************************/
-/* Gawk configuration options. */
-/*******************************/
-
-/*
- * DEFPATH
- *
- * The default search path for the -f option of gawk. It is used
- * if the AWKPATH environment variable is undefined. The default
- * definition is provided here. Most likely you should not change
- * this.
- */
-
-/* #define DEFPATH ".:/usr/lib/awk:/usr/local/lib/awk" */
-/* #define ENVSEP ':' */
-
-/*
- * alloca already has a prototype defined - don't redefine it
- */
-#define ALLOCA_PROTO 1
-
-/*
- * srandom already has a prototype defined - don't redefine it
- */
-#define SRANDOM_PROTO 1
-
-/* anything that follows is for system-specific short-term kludges */
diff --git a/gnu/usr.bin/awk/dfa.c b/gnu/usr.bin/awk/dfa.c
deleted file mode 100644
index 5293c75..0000000
--- a/gnu/usr.bin/awk/dfa.c
+++ /dev/null
@@ -1,2291 +0,0 @@
-/* dfa.c - determinisitic extended regexp routines for GNU
- Copyright (C) 1988 Free Software Foundation, Inc.
- Written June, 1988 by Mike Haertel
- Modified July, 1988 by Arthur David Olson
- to assist BMG speedups
-
- NO WARRANTY
-
- BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
-NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
-WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
-RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS 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.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
-STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
-WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
-LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
-OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
-DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
-A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
-PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
-
- GENERAL PUBLIC LICENSE TO COPY
-
- 1. You may copy and distribute verbatim copies of this source file
-as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy a valid copyright notice "Copyright
- (C) 1988 Free Software Foundation, Inc."; and include following the
-copyright notice a verbatim copy of the above disclaimer of warranty
-and of this License. You may charge a distribution fee for the
-physical act of transferring a copy.
-
- 2. You may modify your copy or copies of this source file 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 or is a derivative of this
- program or any part thereof, to be licensed at no charge to all
- third parties on terms identical to those contained in this
- License Agreement (except that you may choose to grant more extensive
- warranty protection to some or all third parties, at your option).
-
- c) You may charge a distribution 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 unrelated program with this program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other program under the scope of these terms.
-
- 3. You may copy and distribute this program or any portion of it in
-compiled, executable or object code form under the terms of Paragraphs
-1 and 2 above provided that you do 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
- shipping charge) 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.)
-
-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.
-
- 4. You may not copy, sublicense, distribute or transfer this program
-except as expressly provided under this License Agreement. Any attempt
-otherwise to copy, sublicense, distribute or transfer this program is void and
-your rights to use the program under this License agreement shall be
-automatically terminated. However, parties who have received computer
-software programs from you with this License Agreement will not have
-their licenses terminated so long as such parties remain in full compliance.
-
- 5. If you wish to incorporate parts of this program into other free
-programs whose distribution conditions are different, write to the Free
-Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet
-worked out a simple rule that can be stated here, but we will often permit
-this. We will be guided by the two goals of preserving the free status of
-all derivatives our free software and of promoting the sharing and reuse of
-software.
-
-
-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! */
-
-#include "awk.h"
-#include <assert.h>
-
-#ifdef setbit /* surprise - setbit and clrbit are macros on NeXT */
-#undef setbit
-#endif
-#ifdef clrbit
-#undef clrbit
-#endif
-
-#ifdef __STDC__
-typedef void *ptr_t;
-#else
-typedef char *ptr_t;
-#endif
-
-typedef struct {
- char ** in;
- char * left;
- char * right;
- char * is;
-} must;
-
-static ptr_t xcalloc P((int n, size_t s));
-static ptr_t xmalloc P((size_t n));
-static ptr_t xrealloc P((ptr_t p, size_t n));
-static int tstbit P((int b, _charset c));
-static void setbit P((int b, _charset c));
-static void clrbit P((int b, _charset c));
-static void copyset P((const _charset src, _charset dst));
-static void zeroset P((_charset s));
-static void notset P((_charset s));
-static int equal P((const _charset s1, const _charset s2));
-static int charset_index P((const _charset s));
-static _token lex P((void));
-static void addtok P((_token t));
-static void atom P((void));
-static void closure P((void));
-static void branch P((void));
-static void regexp P((void));
-static void copy P((const _position_set *src, _position_set *dst));
-static void insert P((_position p, _position_set *s));
-static void merge P((_position_set *s1, _position_set *s2, _position_set *m));
-static void delete P((_position p, _position_set *s));
-static int state_index P((struct regexp *r, _position_set *s,
- int newline, int letter));
-static void epsclosure P((_position_set *s, struct regexp *r));
-static void build_state P((int s, struct regexp *r));
-static void build_state_zero P((struct regexp *r));
-static char *icatalloc P((char *old, const char *new));
-static char *icpyalloc P((const char *string));
-static char *istrstr P((char *lookin, char *lookfor));
-static void ifree P((char *cp));
-static void freelist P((char **cpp));
-static char **enlist P((char **cpp, char *new, size_t len));
-static char **comsubs P((char *left, char *right));
-static char **addlists P((char **old, char **new));
-static char **inboth P((char **left, char **right));
-static void resetmust P((must *mp));
-static void regmust P((struct regexp *r));
-
-#undef P
-
-static ptr_t
-xcalloc(n, s)
- int n;
- size_t s;
-{
- ptr_t r = calloc(n, s);
-
- if (NULL == r)
- reg_error("Memory exhausted"); /* reg_error does not return */
- return r;
-}
-
-static ptr_t
-xmalloc(n)
- size_t n;
-{
- ptr_t r = malloc(n);
-
- assert(n != 0);
- if (NULL == r)
- reg_error("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 (NULL == r)
- reg_error("Memory exhausted");
- return r;
-}
-
-#define CALLOC(p, t, n) ((p) = (t *) xcalloc((n), sizeof (t)))
-#undef MALLOC
-#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); \
- }
-
-/* Stuff pertaining to charsets. */
-
-static int
-tstbit(b, c)
- int b;
- _charset c;
-{
- return c[b / INTBITS] & 1 << b % INTBITS;
-}
-
-static void
-setbit(b, c)
- int b;
- _charset c;
-{
- c[b / INTBITS] |= 1 << b % INTBITS;
-}
-
-static void
-clrbit(b, c)
- int b;
- _charset c;
-{
- c[b / INTBITS] &= ~(1 << b % INTBITS);
-}
-
-static void
-copyset(src, dst)
- const _charset src;
- _charset dst;
-{
- int i;
-
- for (i = 0; i < _CHARSET_INTS; ++i)
- dst[i] = src[i];
-}
-
-static void
-zeroset(s)
- _charset s;
-{
- int i;
-
- for (i = 0; i < _CHARSET_INTS; ++i)
- s[i] = 0;
-}
-
-static void
-notset(s)
- _charset s;
-{
- int i;
-
- for (i = 0; i < _CHARSET_INTS; ++i)
- s[i] = ~s[i];
-}
-
-static int
-equal(s1, s2)
- const _charset s1;
- const _charset s2;
-{
- int i;
-
- for (i = 0; i < _CHARSET_INTS; ++i)
- if (s1[i] != s2[i])
- return 0;
- return 1;
-}
-
-/* A pointer to the current regexp is kept here during parsing. */
-static struct regexp *reg;
-
-/* Find the index of charset s in reg->charsets, or allocate a new charset. */
-static int
-charset_index(s)
- const _charset s;
-{
- int i;
-
- for (i = 0; i < reg->cindex; ++i)
- if (equal(s, reg->charsets[i]))
- return i;
- REALLOC_IF_NECESSARY(reg->charsets, _charset, reg->calloc, reg->cindex);
- ++reg->cindex;
- copyset(s, reg->charsets[i]);
- return i;
-}
-
-/* Syntax bits controlling the behavior of the lexical analyzer. */
-static syntax_bits, syntax_bits_set;
-
-/* Flag for case-folding letters into sets. */
-static case_fold;
-
-/* Entry point to set syntax options. */
-void
-regsyntax(bits, fold)
- long bits;
- int fold;
-{
- syntax_bits_set = 1;
- syntax_bits = bits;
- case_fold = fold;
-}
-
-/* Lexical analyzer. */
-static const char *lexstart; /* Pointer to beginning of input string. */
-static const char *lexptr; /* Pointer to next input character. */
-static lexleft; /* Number of characters remaining. */
-static caret_allowed; /* True if backward context allows ^
- (meaningful only if RE_CONTEXT_INDEP_OPS
- is turned off). */
-static closure_allowed; /* True if backward context allows closures
- (meaningful only if RE_CONTEXT_INDEP_OPS
- is turned off). */
-
-/* Note that characters become unsigned here. */
-#define FETCH(c, eoferr) \
- { \
- if (! lexleft) \
- if (eoferr != NULL) \
- reg_error(eoferr); \
- else \
- return _END; \
- (c) = (unsigned char) *lexptr++; \
- --lexleft; \
- }
-
-static _token
-lex()
-{
- _token c, c2;
- int invert;
- _charset cset;
-
- FETCH(c, (char *) 0);
- switch (c)
- {
- case '^':
- if (! (syntax_bits & RE_CONTEXT_INDEP_OPS)
- && (!caret_allowed ||
- ((syntax_bits & RE_TIGHT_VBAR) && lexptr - 1 != lexstart)))
- goto normal_char;
- caret_allowed = 0;
- return syntax_bits & RE_TIGHT_VBAR ? _ALLBEGLINE : _BEGLINE;
-
- case '$':
- if (syntax_bits & RE_CONTEXT_INDEP_OPS || !lexleft
- || (! (syntax_bits & RE_TIGHT_VBAR)
- && ((syntax_bits & RE_NO_BK_PARENS
- ? lexleft > 0 && *lexptr == ')'
- : lexleft > 1 && *lexptr == '\\' && lexptr[1] == ')')
- || (syntax_bits & RE_NO_BK_VBAR
- ? lexleft > 0 && *lexptr == '|'
- : lexleft > 1 && *lexptr == '\\' && lexptr[1] == '|'))))
- return syntax_bits & RE_TIGHT_VBAR ? _ALLENDLINE : _ENDLINE;
- goto normal_char;
-
- case '\\':
- FETCH(c, "Unfinished \\ quote");
- switch (c)
- {
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- caret_allowed = 0;
- closure_allowed = 1;
- return _BACKREF;
-
- case '<':
- caret_allowed = 0;
- return _BEGWORD;
-
- case '>':
- caret_allowed = 0;
- return _ENDWORD;
-
- case 'b':
- caret_allowed = 0;
- return _LIMWORD;
-
- case 'B':
- caret_allowed = 0;
- return _NOTLIMWORD;
-
- case 'w':
- case 'W':
- zeroset(cset);
- for (c2 = 0; c2 < _NOTCHAR; ++c2)
- if (ISALNUM(c2))
- setbit(c2, cset);
- if (c == 'W')
- notset(cset);
- caret_allowed = 0;
- closure_allowed = 1;
- return _SET + charset_index(cset);
-
- case '?':
- if (syntax_bits & RE_BK_PLUS_QM)
- goto qmark;
- goto normal_char;
-
- case '+':
- if (syntax_bits & RE_BK_PLUS_QM)
- goto plus;
- goto normal_char;
-
- case '|':
- if (! (syntax_bits & RE_NO_BK_VBAR))
- goto or;
- goto normal_char;
-
- case '(':
- if (! (syntax_bits & RE_NO_BK_PARENS))
- goto lparen;
- goto normal_char;
-
- case ')':
- if (! (syntax_bits & RE_NO_BK_PARENS))
- goto rparen;
- goto normal_char;
-
- default:
- goto normal_char;
- }
-
- case '?':
- if (syntax_bits & RE_BK_PLUS_QM)
- goto normal_char;
- qmark:
- if (! (syntax_bits & RE_CONTEXT_INDEP_OPS) && !closure_allowed)
- goto normal_char;
- return _QMARK;
-
- case '*':
- if (! (syntax_bits & RE_CONTEXT_INDEP_OPS) && !closure_allowed)
- goto normal_char;
- return _STAR;
-
- case '+':
- if (syntax_bits & RE_BK_PLUS_QM)
- goto normal_char;
- plus:
- if (! (syntax_bits & RE_CONTEXT_INDEP_OPS) && !closure_allowed)
- goto normal_char;
- return _PLUS;
-
- case '|':
- if (! (syntax_bits & RE_NO_BK_VBAR))
- goto normal_char;
- or:
- caret_allowed = 1;
- closure_allowed = 0;
- return _OR;
-
- case '\n':
- if (! (syntax_bits & RE_NEWLINE_OR))
- goto normal_char;
- goto or;
-
- case '(':
- if (! (syntax_bits & RE_NO_BK_PARENS))
- goto normal_char;
- lparen:
- caret_allowed = 1;
- closure_allowed = 0;
- return _LPAREN;
-
- case ')':
- if (! (syntax_bits & RE_NO_BK_PARENS))
- goto normal_char;
- rparen:
- caret_allowed = 0;
- closure_allowed = 1;
- return _RPAREN;
-
- case '.':
- zeroset(cset);
- notset(cset);
- clrbit('\n', cset);
- caret_allowed = 0;
- closure_allowed = 1;
- return _SET + charset_index(cset);
-
- case '[':
- zeroset(cset);
- FETCH(c, "Unbalanced [");
- if (c == '^')
- {
- FETCH(c, "Unbalanced [");
- invert = 1;
- }
- else
- invert = 0;
- do
- {
- FETCH(c2, "Unbalanced [");
- if ((syntax_bits & RE_AWK_CLASS_HACK) && c == '\\')
- {
- c = c2;
- FETCH(c2, "Unbalanced [");
- }
- if (c2 == '-')
- {
- FETCH(c2, "Unbalanced [");
- if (c2 == ']' && (syntax_bits & RE_AWK_CLASS_HACK))
- {
- setbit(c, cset);
- setbit('-', cset);
- break;
- }
- while (c <= c2)
- setbit(c++, cset);
- FETCH(c, "Unbalanced [");
- }
- else
- {
- setbit(c, cset);
- c = c2;
- }
- }
- while (c != ']');
- if (invert)
- notset(cset);
- caret_allowed = 0;
- closure_allowed = 1;
- return _SET + charset_index(cset);
-
- default:
- normal_char:
- caret_allowed = 0;
- closure_allowed = 1;
- if (case_fold && ISALPHA(c))
- {
- zeroset(cset);
- if (isupper(c))
- c = tolower(c);
- setbit(c, cset);
- setbit(toupper(c), cset);
- return _SET + charset_index(cset);
- }
- return c;
- }
-}
-
-/* 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
- reganalyze(). */
-
-/* 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(reg->tokens, _token, reg->talloc, reg->tindex);
- reg->tokens[reg->tindex++] = t;
-
- switch (t)
- {
- case _QMARK:
- case _STAR:
- case _PLUS:
- break;
-
- case _CAT:
- case _OR:
- --depth;
- break;
-
- default:
- ++reg->nleaves;
- case _EMPTY:
- ++depth;
- break;
- }
- if (depth > reg->depth)
- reg->depth = depth;
-}
-
-/* The grammar understood by the parser is as follows.
-
- start:
- regexp
- _ALLBEGLINE regexp
- regexp _ALLENDLINE
- _ALLBEGLINE regexp _ALLENDLINE
-
- regexp:
- regexp _OR branch
- branch
-
- branch:
- branch closure
- closure
-
- closure:
- closure _QMARK
- closure _STAR
- closure _PLUS
- atom
-
- atom:
- <normal character>
- _SET
- _BACKREF
- _BEGLINE
- _ENDLINE
- _BEGWORD
- _ENDWORD
- _LIMWORD
- _NOTLIMWORD
- <empty>
-
- The parser builds a parse tree in postfix form in an array of tokens. */
-
-#ifdef __STDC__
-static void regexp(void);
-#else
-static void regexp();
-#endif
-
-static void
-atom()
-{
- if (tok >= 0 && (tok < _NOTCHAR || tok >= _SET || 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();
- if (tok != _RPAREN)
- reg_error("Unbalanced (");
- tok = lex();
- }
- else
- addtok(_EMPTY);
-}
-
-static void
-closure()
-{
- atom();
- while (tok == _QMARK || tok == _STAR || tok == _PLUS)
- {
- addtok(tok);
- tok = lex();
- }
-}
-
-static void
-branch()
-{
- closure();
- while (tok != _RPAREN && tok != _OR && tok != _ALLENDLINE && tok >= 0)
- {
- closure();
- addtok(_CAT);
- }
-}
-
-static void
-regexp()
-{
- branch();
- while (tok == _OR)
- {
- tok = lex();
- branch();
- 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. R is a pointer to
- the struct regexp to parse into. */
-void
-regparse(s, len, r)
- const char *s;
- size_t len;
- struct regexp *r;
-{
- reg = r;
- lexstart = lexptr = s;
- lexleft = len;
- caret_allowed = 1;
- closure_allowed = 0;
-
- if (! syntax_bits_set)
- reg_error("No syntax specified");
-
- tok = lex();
- depth = r->depth;
-
- if (tok == _ALLBEGLINE)
- {
- addtok(_BEGLINE);
- tok = lex();
- regexp();
- addtok(_CAT);
- }
- else
- regexp();
-
- if (tok == _ALLENDLINE)
- {
- addtok(_ENDLINE);
- addtok(_CAT);
- tok = lex();
- }
-
- if (tok != _END)
- reg_error("Unbalanced )");
-
- addtok(_END - r->nregexps);
- addtok(_CAT);
-
- if (r->nregexps)
- addtok(_OR);
-
- ++r->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)
- const _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(r, s, newline, letter)
- struct regexp *r;
- _position_set *s;
- int newline;
- int letter;
-{
- int lhash = 0;
- int constraint;
- int i, j;
-
- newline = newline ? 1 : 0;
- letter = letter ? 1 : 0;
-
- for (i = 0; i < s->nelem; ++i)
- lhash ^= s->elems[i].index + s->elems[i].constraint;
-
- /* Try to find a state that exactly matches the proposed one. */
- for (i = 0; i < r->sindex; ++i)
- {
- if (lhash != r->states[i].hash || s->nelem != r->states[i].elems.nelem
- || newline != r->states[i].newline || letter != r->states[i].letter)
- continue;
- for (j = 0; j < s->nelem; ++j)
- if (s->elems[j].constraint
- != r->states[i].elems.elems[j].constraint
- || s->elems[j].index != r->states[i].elems.elems[j].index)
- break;
- if (j == s->nelem)
- return i;
- }
-
- /* We'll have to create a new state. */
- REALLOC_IF_NECESSARY(r->states, _dfa_state, r->salloc, r->sindex);
- r->states[i].hash = lhash;
- MALLOC(r->states[i].elems.elems, _position, s->nelem);
- copy(s, &r->states[i].elems);
- r->states[i].newline = newline;
- r->states[i].letter = letter;
- r->states[i].backref = 0;
- r->states[i].constraint = 0;
- r->states[i].first_end = 0;
- for (j = 0; j < s->nelem; ++j)
- if (r->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))
- r->states[i].constraint |= constraint;
- if (! r->states[i].first_end)
- r->states[i].first_end = r->tokens[s->elems[j].index];
- }
- else if (r->tokens[s->elems[j].index] == _BACKREF)
- {
- r->states[i].constraint = _NO_CONSTRAINT;
- r->states[i].backref = 1;
- }
-
- ++r->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. */
-static void
-epsclosure(s, r)
- _position_set *s;
- struct regexp *r;
-{
- int i, j;
- int *visited;
- _position p, old;
-
- MALLOC(visited, int, r->tindex);
- for (i = 0; i < r->tindex; ++i)
- visited[i] = 0;
-
- for (i = 0; i < s->nelem; ++i)
- if (r->tokens[s->elems[i].index] >= _NOTCHAR
- && r->tokens[s->elems[i].index] != _BACKREF
- && r->tokens[s->elems[i].index] < _SET)
- {
- old = s->elems[i];
- p.constraint = old.constraint;
- delete(s->elems[i], s);
- if (visited[old.index])
- {
- --i;
- continue;
- }
- visited[old.index] = 1;
- switch (r->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 &= _ENDWORD_CONSTRAINT;
- break;
- case _NOTLIMWORD:
- p.constraint &= _NOTLIMWORD_CONSTRAINT;
- break;
- default:
- break;
- }
- for (j = 0; j < r->follows[old.index].nelem; ++j)
- {
- p.index = r->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
-reganalyze(r, searchflag)
- struct regexp *r;
- 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;
-
- r->searchflag = searchflag;
-
- MALLOC(nullable, int, r->depth);
- o_nullable = nullable;
- MALLOC(nfirstpos, int, r->depth);
- o_nfirst = nfirstpos;
- MALLOC(firstpos, _position, r->nleaves);
- o_firstpos = firstpos, firstpos += r->nleaves;
- MALLOC(nlastpos, int, r->depth);
- o_nlast = nlastpos;
- MALLOC(lastpos, _position, r->nleaves);
- o_lastpos = lastpos, lastpos += r->nleaves;
- MALLOC(nalloc, int, r->tindex);
- for (i = 0; i < r->tindex; ++i)
- nalloc[i] = 0;
- MALLOC(merged.elems, _position, r->nleaves);
-
- CALLOC(r->follows, _position_set, r->tindex);
-
- for (i = 0; i < r->tindex; ++i)
- switch (r->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, &r->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(r->follows[pos[j].index].elems, _position,
- nalloc[pos[j].index], merged.nelem - 1);
- copy(&merged, &r->follows[pos[j].index]);
- }
-
- case _QMARK:
- /* A _QMARK or _STAR node is automatically nullable. */
- if (r->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, &r->follows[pos[j].index], &merged);
- REALLOC_IF_NECESSARY(r->follows[pos[j].index].elems, _position,
- nalloc[pos[j].index], merged.nelem - 1);
- copy(&merged, &r->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:
- /* 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++ = r->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(r->follows[i].elems, _position, nalloc[i]);
- break;
- }
-
- /* For each follow set that is the follow set of a real position, replace
- it with its epsilon closure. */
- for (i = 0; i < r->tindex; ++i)
- if (r->tokens[i] < _NOTCHAR || r->tokens[i] == _BACKREF
- || r->tokens[i] >= _SET)
- {
- copy(&r->follows[i], &merged);
- epsclosure(&merged, r);
- if (r->follows[i].nelem < merged.nelem)
- REALLOC(r->follows[i].elems, _position, merged.nelem);
- copy(&merged, &r->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, r);
-
- /* 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. */
- r->salloc = 1;
- r->sindex = 0;
- MALLOC(r->states, _dfa_state, r->salloc);
- state_index(r, &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 r, 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
-regstate(s, r, trans)
- int s;
- struct regexp *r;
- int trans[];
-{
- _position_set grps[_NOTCHAR]; /* As many as will ever be needed. */
- _charset labels[_NOTCHAR]; /* Labels corresponding to the groups. */
- int ngrps = 0; /* Number of groups actually used. */
- _position pos; /* Current position being considered. */
- _charset matches; /* Set of matching characters. */
- int matchesf; /* True if matches is nonempty. */
- _charset intersect; /* Intersection with some label set. */
- int intersectf; /* True if intersect is nonempty. */
- _charset leftovers; /* Stuff in the label that didn't match. */
- int leftoversf; /* True if leftovers is nonempty. */
- static _charset letters; /* Set of characters considered letters. */
- static _charset 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 < r->states[s].elems.nelem; ++i)
- {
- pos = r->states[s].elems.elems[i];
- if (r->tokens[pos.index] >= 0 && r->tokens[pos.index] < _NOTCHAR)
- setbit(r->tokens[pos.index], matches);
- else if (r->tokens[pos.index] >= _SET)
- copyset(r->charsets[r->tokens[pos.index] - _SET], matches);
- else
- continue;
-
- /* Some characters may need to be climinated from matches because
- they fail in the current context. */
- if (pos.constraint != 0xff)
- {
- if (! _MATCHES_NEWLINE_CONTEXT(pos.constraint,
- r->states[s].newline, 1))
- clrbit('\n', matches);
- if (! _MATCHES_NEWLINE_CONTEXT(pos.constraint,
- r->states[s].newline, 0))
- for (j = 0; j < _CHARSET_INTS; ++j)
- matches[j] &= newline[j];
- if (! _MATCHES_LETTER_CONTEXT(pos.constraint,
- r->states[s].letter, 1))
- for (j = 0; j < _CHARSET_INTS; ++j)
- matches[j] &= ~letters[j];
- if (! _MATCHES_LETTER_CONTEXT(pos.constraint,
- r->states[s].letter, 0))
- for (j = 0; j < _CHARSET_INTS; ++j)
- matches[j] &= letters[j];
-
- /* If there are no characters left, there's no point in going on. */
- for (j = 0; j < _CHARSET_INTS && !matches[j]; ++j)
- ;
- if (j == _CHARSET_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 (r->tokens[pos.index] >= 0 && r->tokens[pos.index] < _NOTCHAR
- && !tstbit(r->tokens[pos.index], labels[j]))
- continue;
-
- /* Check if this group's label has a nonempty intersection with
- matches. */
- intersectf = 0;
- for (k = 0; k < _CHARSET_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 < _CHARSET_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, r->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, r->nleaves);
- grps[ngrps].nelem = 1;
- grps[ngrps].elems[0] = pos;
- ++ngrps;
- }
- }
-
- MALLOC(follows.elems, _position, r->nleaves);
- MALLOC(tmp.elems, _position, r->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 (r->searchflag)
- {
- wants_newline = 0;
- wants_letter = 0;
- for (i = 0; i < r->states[0].elems.nelem; ++i)
- {
- if (_PREV_NEWLINE_DEPENDENT(r->states[0].elems.elems[i].constraint))
- wants_newline = 1;
- if (_PREV_LETTER_DEPENDENT(r->states[0].elems.elems[i].constraint))
- wants_letter = 1;
- }
- copy(&r->states[0].elems, &follows);
- state = state_index(r, &follows, 0, 0);
- if (wants_newline)
- state_newline = state_index(r, &follows, 1, 0);
- else
- state_newline = state;
- if (wants_letter)
- state_letter = state_index(r, &follows, 0, 1);
- else
- state_letter = state;
- for (i = 0; i < _NOTCHAR; ++i)
- trans[i] = (ISALNUM(i)) ? state_letter : state ;
- trans['\n'] = state_newline;
- }
- 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 < r->follows[grps[i].elems[j].index].nelem; ++k)
- insert(r->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 (r->searchflag)
- for (j = 0; j < r->states[0].elems.nelem; ++j)
- insert(r->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 < _CHARSET_INTS; ++j)
- if (labels[i][j] & letters[j])
- break;
- if (j < _CHARSET_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(r, &follows, 0, 0);
- if (wants_newline)
- state_newline = state_index(r, &follows, 1, 0);
- else
- state_newline = state;
- if (wants_letter)
- state_letter = state_index(r, &follows, 0, 1);
- else
- state_letter = state;
-
- /* Set the transitions for each character in the current label. */
- for (j = 0; j < _CHARSET_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 regexp's transition tables.
- Each state may or may not have a transition table; if it does, and it
- is a non-accepting state, then r->trans[state] points to its table.
- If it is an accepting state then r->fails[state] points to its table.
- If it has no table at all, then r->trans[state] is NULL.
- TODO: Improve this comment, get rid of the unnecessary redundancy. */
-
-static void
-build_state(s, r)
- int s;
- struct regexp *r;
-{
- 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 (r->trcount >= 1024)
- {
- for (i = 0; i < r->tralloc; ++i)
- if (r->trans[i])
- {
- free((ptr_t) r->trans[i]);
- r->trans[i] = NULL;
- }
- else if (r->fails[i])
- {
- free((ptr_t) r->fails[i]);
- r->fails[i] = NULL;
- }
- r->trcount = 0;
- }
-
- ++r->trcount;
-
- /* Set up the success bits for this state. */
- r->success[s] = 0;
- if (ACCEPTS_IN_CONTEXT(r->states[s].newline, 1, r->states[s].letter, 0,
- s, *r))
- r->success[s] |= 4;
- if (ACCEPTS_IN_CONTEXT(r->states[s].newline, 0, r->states[s].letter, 1,
- s, *r))
- r->success[s] |= 2;
- if (ACCEPTS_IN_CONTEXT(r->states[s].newline, 0, r->states[s].letter, 0,
- s, *r))
- r->success[s] |= 1;
-
- MALLOC(trans, int, _NOTCHAR);
- regstate(s, r, 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] >= r->tralloc)
- {
- int oldalloc = r->tralloc;
-
- while (trans[i] >= r->tralloc)
- r->tralloc *= 2;
- REALLOC(r->realtrans, int *, r->tralloc + 1);
- r->trans = r->realtrans + 1;
- REALLOC(r->fails, int *, r->tralloc);
- REALLOC(r->success, int, r->tralloc);
- REALLOC(r->newlines, int, r->tralloc);
- while (oldalloc < r->tralloc)
- {
- r->trans[oldalloc] = NULL;
- r->fails[oldalloc++] = NULL;
- }
- }
-
- /* Keep the newline transition in a special place so we can use it as
- a sentinel. */
- r->newlines[s] = trans['\n'];
- trans['\n'] = -1;
-
- if (ACCEPTING(s, *r))
- r->fails[s] = trans;
- else
- r->trans[s] = trans;
-}
-
-static void
-build_state_zero(r)
- struct regexp *r;
-{
- r->tralloc = 1;
- r->trcount = 0;
- CALLOC(r->realtrans, int *, r->tralloc + 1);
- r->trans = r->realtrans + 1;
- CALLOC(r->fails, int *, r->tralloc);
- MALLOC(r->success, int, r->tralloc);
- MALLOC(r->newlines, int, r->tralloc);
- build_state(0, r);
-}
-
-/* Search through a buffer looking for a match to the given struct regexp.
- 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 *
-regexecute(r, begin, end, newline, count, backref)
- struct regexp *r;
- 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 r->trans so it can be optimized
- into a register. */
- static sbit[_NOTCHAR]; /* Table for anding with r->success. */
- static sbit_init;
-
- if (! sbit_init)
- {
- int i;
-
- sbit_init = 1;
- for (i = 0; i < _NOTCHAR; ++i)
- sbit[i] = (ISALNUM(i)) ? 2 : 1;
- sbit['\n'] = 4;
- }
-
- if (! r->tralloc)
- build_state_zero(r);
-
- s = s1 = 0;
- p = (unsigned char *) begin;
- trans = r->trans;
- *end = '\n';
-
- for (;;)
- {
- while ((t = trans[s]) != 0) { /* hand-optimized loop */
- s1 = t[*p++];
- if ((t = trans[s1]) == 0) {
- tmp = s ; s = s1 ; s1 = tmp ; /* swap */
- break;
- }
- s = t[*p++];
- }
-
- if (s >= 0 && p <= (unsigned char *) end && r->fails[s])
- {
- if (r->success[s] & sbit[*p])
- {
- if (backref)
- *backref = (r->states[s].backref != 0);
- return (char *) p;
- }
-
- s1 = s;
- s = r->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, r);
- trans = r->trans;
- continue;
- }
-
- if (p[-1] == '\n' && newline)
- {
- s = r->newlines[s1];
- continue;
- }
-
- s = 0;
- }
-}
-
-/* Initialize the components of a regexp that the other routines don't
- initialize for themselves. */
-void
-reginit(r)
- struct regexp *r;
-{
- r->calloc = 1;
- MALLOC(r->charsets, _charset, r->calloc);
- r->cindex = 0;
-
- r->talloc = 1;
- MALLOC(r->tokens, _token, r->talloc);
- r->tindex = r->depth = r->nleaves = r->nregexps = 0;
-
- r->searchflag = 0;
- r->tralloc = 0;
-}
-
-/* Parse and analyze a single string of the given length. */
-void
-regcompile(s, len, r, searchflag)
- const char *s;
- size_t len;
- struct regexp *r;
- int searchflag;
-{
- if (case_fold) /* dummy folding in service of regmust() */
- {
- char *regcopy;
- int i;
-
- regcopy = malloc(len);
- if (!regcopy)
- reg_error("out of memory");
-
- /* This is a complete kludge and could potentially break
- \<letter> escapes . . . */
- case_fold = 0;
- for (i = 0; i < len; ++i)
- if (ISUPPER(s[i]))
- regcopy[i] = tolower(s[i]);
- else
- regcopy[i] = s[i];
-
- reginit(r);
- r->mustn = 0;
- r->must[0] = '\0';
- regparse(regcopy, len, r);
- free(regcopy);
- regmust(r);
- reganalyze(r, searchflag);
- case_fold = 1;
- reginit(r);
- regparse(s, len, r);
- reganalyze(r, searchflag);
- }
- else
- {
- reginit(r);
- regparse(s, len, r);
- regmust(r);
- reganalyze(r, searchflag);
- }
-}
-
-/* Free the storage held by the components of a regexp. */
-void
-reg_free(r)
- struct regexp *r;
-{
- int i;
-
- free((ptr_t) r->charsets);
- free((ptr_t) r->tokens);
- for (i = 0; i < r->sindex; ++i)
- free((ptr_t) r->states[i].elems.elems);
- free((ptr_t) r->states);
- for (i = 0; i < r->tindex; ++i)
- if (r->follows[i].elems)
- free((ptr_t) r->follows[i].elems);
- free((ptr_t) r->follows);
- for (i = 0; i < r->tralloc; ++i)
- if (r->trans[i])
- free((ptr_t) r->trans[i]);
- else if (r->fails[i])
- free((ptr_t) r->fails[i]);
- if (r->realtrans)
- free((ptr_t) r->realtrans);
- if (r->fails)
- free((ptr_t) r->fails);
- if (r->newlines)
- free((ptr_t) r->newlines);
-}
-
-/*
-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
-r->must (where "r" is the single argument passed to "regmust");
-the length of the sequence is returned in r->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
-
-SET 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;
-const char * new;
-{
- register char * result;
- register 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)
-const char * string;
-{
- return icatalloc((char *) NULL, string);
-}
-
-static char *
-istrstr(lookin, lookfor)
-char * lookin;
-register char * lookfor;
-{
- register char * cp;
- register 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)
-register char ** cpp;
-{
- register 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)
-register char ** cpp;
-register char * new;
-#ifdef __STDC__
-size_t len;
-#else
-int len;
-#endif
-{
- register 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];
- }
- /*
- ** 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;
-{
- register char ** cpp;
- register char * lcp;
- register char * rcp;
- register 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 = strchr(right, *lcp);
- while (rcp != NULL) {
- for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i)
- ;
- if (i > len)
- len = i;
- rcp = strchr(rcp + 1, *lcp);
- }
- if (len == 0)
- continue;
-#ifdef __STDC__
- if ((cpp = enlist(cpp, lcp, (size_t)len)) == NULL)
-#else
- if ((cpp = enlist(cpp, lcp, len)) == NULL)
-#endif
- break;
- }
- return cpp;
-}
-
-static char **
-addlists(old, new)
-char ** old;
-char ** new;
-{
- register 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;
-{
- register char ** both;
- register char ** temp;
- register 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)
-register must * mp;
-{
- mp->left[0] = mp->right[0] = mp->is[0] = '\0';
- freelist(mp->in);
-}
-
-static void
-regmust(r)
-register struct regexp * r;
-{
- register must * musts;
- register must * mp;
- register char * result = "";
- register int ri;
- register int i;
- register _token t;
- static must must0;
-
- reg->mustn = 0;
- reg->must[0] = '\0';
- musts = (must *) malloc((reg->tindex + 1) * sizeof *musts);
- if (musts == NULL)
- return;
- mp = musts;
- for (i = 0; i <= reg->tindex; ++i)
- mp[i] = must0;
- for (i = 0; i <= reg->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;
- }
- for (ri = 0; ri < reg->tindex; ++ri) {
- switch (t = reg->tokens[ri]) {
- case _ALLBEGLINE:
- case _ALLENDLINE:
- 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:
- if (mp < &musts[2])
- goto done; /* "cannot happen" */
- {
- register char ** new;
- register must * lmp;
- register must * rmp;
- register 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];
- goto done;
- case _CAT:
- if (mp < &musts[2])
- goto done; /* "cannot happen" */
- {
- register must * lmp;
- register 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') {
- register 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;
- }
- }
- break;
- default:
- if (t < _END) {
- /* "cannot happen" */
- goto done;
- } else if (t == '\0') {
- /* not on *my* shift */
- goto done;
- } else if (t >= _SET) {
- /* 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;
- }
- ++mp;
- }
-done:
- (void) strncpy(reg->must, result, MUST_MAX - 1);
- reg->must[MUST_MAX - 1] = '\0';
- reg->mustn = strlen(reg->must);
- mp = musts;
- for (i = 0; i <= reg->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/awk/dfa.h b/gnu/usr.bin/awk/dfa.h
deleted file mode 100644
index 65fc495..0000000
--- a/gnu/usr.bin/awk/dfa.h
+++ /dev/null
@@ -1,543 +0,0 @@
-/* dfa.h - declarations for GNU deterministic regexp compiler
- Copyright (C) 1988 Free Software Foundation, Inc.
- Written June, 1988 by Mike Haertel
-
- NO WARRANTY
-
- BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
-NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
-WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
-RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS 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.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
-STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
-WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
-LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
-OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
-DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
-A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
-PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
-
- GENERAL PUBLIC LICENSE TO COPY
-
- 1. You may copy and distribute verbatim copies of this source file
-as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy a valid copyright notice "Copyright
- (C) 1988 Free Software Foundation, Inc."; and include following the
-copyright notice a verbatim copy of the above disclaimer of warranty
-and of this License. You may charge a distribution fee for the
-physical act of transferring a copy.
-
- 2. You may modify your copy or copies of this source file 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 or is a derivative of this
- program or any part thereof, to be licensed at no charge to all
- third parties on terms identical to those contained in this
- License Agreement (except that you may choose to grant more extensive
- warranty protection to some or all third parties, at your option).
-
- c) You may charge a distribution 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 unrelated program with this program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other program under the scope of these terms.
-
- 3. You may copy and distribute this program or any portion of it in
-compiled, executable or object code form under the terms of Paragraphs
-1 and 2 above provided that you do 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
- shipping charge) 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.)
-
-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.
-
- 4. You may not copy, sublicense, distribute or transfer this program
-except as expressly provided under this License Agreement. Any attempt
-otherwise to copy, sublicense, distribute or transfer this program is void and
-your rights to use the program under this License agreement shall be
-automatically terminated. However, parties who have received computer
-software programs from you with this License Agreement will not have
-their licenses terminated so long as such parties remain in full compliance.
-
- 5. If you wish to incorporate parts of this program into other free
-programs whose distribution conditions are different, write to the Free
-Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet
-worked out a simple rule that can be stated here, but we will often permit
-this. We will be guided by the two goals of preserving the free status of
-all derivatives our free software and of promoting the sharing and reuse of
-software.
-
-
-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! */
-
-#ifdef __STDC__
-
-#ifdef SOMEDAY
-#define ISALNUM(c) isalnum(c)
-#define ISALPHA(c) isalpha(c)
-#define ISUPPER(c) isupper(c)
-#else
-#define ISALNUM(c) (isascii(c) && isalnum(c))
-#define ISALPHA(c) (isascii(c) && isalpha(c))
-#define ISUPPER(c) (isascii(c) && isupper(c))
-#endif
-
-#else /* ! __STDC__ */
-
-#define const
-
-#define ISALNUM(c) (isascii(c) && isalnum(c))
-#define ISALPHA(c) (isascii(c) && isalpha(c))
-#define ISUPPER(c) (isascii(c) && isupper(c))
-
-#endif /* ! __STDC__ */
-
-/* 1 means plain parentheses serve as grouping, and backslash
- parentheses are needed for literal searching.
- 0 means backslash-parentheses are grouping, and plain parentheses
- are for literal searching. */
-#define RE_NO_BK_PARENS 1L
-
-/* 1 means plain | serves as the "or"-operator, and \| is a literal.
- 0 means \| serves as the "or"-operator, and | is a literal. */
-#define RE_NO_BK_VBAR (1L << 1)
-
-/* 0 means plain + or ? serves as an operator, and \+, \? are literals.
- 1 means \+, \? are operators and plain +, ? are literals. */
-#define RE_BK_PLUS_QM (1L << 2)
-
-/* 1 means | binds tighter than ^ or $.
- 0 means the contrary. */
-#define RE_TIGHT_VBAR (1L << 3)
-
-/* 1 means treat \n as an _OR operator
- 0 means treat it as a normal character */
-#define RE_NEWLINE_OR (1L << 4)
-
-/* 0 means that a special characters (such as *, ^, and $) always have
- their special meaning regardless of the surrounding context.
- 1 means that special characters may act as normal characters in some
- contexts. Specifically, this applies to:
- ^ - only special at the beginning, or after ( or |
- $ - only special at the end, or before ) or |
- *, +, ? - only special when not after the beginning, (, or | */
-#define RE_CONTEXT_INDEP_OPS (1L << 5)
-
-/* 1 means that \ in a character class escapes the next character (typically
- a hyphen. It also is overloaded to mean that hyphen at the end of the range
- is allowable and means that the hyphen is to be taken literally. */
-#define RE_AWK_CLASS_HACK (1L << 6)
-
-/* Now define combinations of bits for the standard possibilities. */
-#ifdef notdef
-#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
-#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
-#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
-#define RE_SYNTAX_EMACS 0
-#endif
-
-/* The NULL pointer. */
-#ifndef NULL
-#define NULL 0
-#endif
-
-/* Number of bits in an unsigned char. */
-#ifndef CHARBITS
-#define CHARBITS 8
-#endif
-
-/* First integer value that is greater than any character code. */
-#define _NOTCHAR (1 << CHARBITS)
-
-/* INTBITS need not be exact, just a lower bound. */
-#ifndef INTBITS
-#define INTBITS (CHARBITS * sizeof (int))
-#endif
-
-/* Number of ints required to hold a bit for every character. */
-#define _CHARSET_INTS ((_NOTCHAR + INTBITS - 1) / INTBITS)
-
-/* Sets of unsigned characters are stored as bit vectors in arrays of ints. */
-typedef int _charset[_CHARSET_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. */
-#ifdef __STDC__
-
-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. */
-
- _ALLBEGLINE, /* _ALLBEGLINE is a terminal symbol that
- matches the empty string if it is at the
- beginning of a line; _ALLBEGLINE applies
- to the entire regexp and can only occur
- as the first token thereof. _ALLBEGLINE
- never appears in the parse tree; a _BEGLINE
- is prepended with _CAT to the entire
- regexp instead. */
-
- _ENDLINE, /* _ENDLINE is a terminal symbol that matches
- the empty string if it is at the end of
- a line. */
-
- _ALLENDLINE, /* _ALLENDLINE is to _ENDLINE as _ALLBEGLINE
- is to _BEGLINE. */
-
- _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. */
-
- _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. */
-
- _LPAREN, /* _LPAREN never appears in the parse tree,
- it is only a lexeme. */
-
- _RPAREN, /* _RPAREN never appears in the parse tree. */
-
- _SET /* _SET and (and any value greater) is a
- terminal symbol that matches any of a
- class of characters. */
-} _token;
-
-#else /* ! __STDC__ */
-
-typedef short _token;
-
-#define _END -1
-#define _EMPTY _NOTCHAR
-#define _BACKREF (_EMPTY + 1)
-#define _BEGLINE (_EMPTY + 2)
-#define _ALLBEGLINE (_EMPTY + 3)
-#define _ENDLINE (_EMPTY + 4)
-#define _ALLENDLINE (_EMPTY + 5)
-#define _BEGWORD (_EMPTY + 6)
-#define _ENDWORD (_EMPTY + 7)
-#define _LIMWORD (_EMPTY + 8)
-#define _NOTLIMWORD (_EMPTY + 9)
-#define _QMARK (_EMPTY + 10)
-#define _STAR (_EMPTY + 11)
-#define _PLUS (_EMPTY + 12)
-#define _CAT (_EMPTY + 13)
-#define _OR (_EMPTY + 14)
-#define _LPAREN (_EMPTY + 15)
-#define _RPAREN (_EMPTY + 16)
-#define _SET (_EMPTY + 17)
-
-#endif /* ! __STDC__ */
-
-/* Sets are stored in an array in the compiled regexp; the index of the
- array corresponding to a given set token is given by _SET_INDEX(t). */
-#define _SET_INDEX(t) ((t) - _SET)
-
-/* 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 regexp 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;
-
-/* If an r.e. is at most MUST_MAX characters long, we look for a string which
- must appear in it; whatever's found is dropped into the struct reg. */
-
-#define MUST_MAX 50
-
-/* A compiled regular expression. */
-struct regexp
-{
- /* Stuff built by the scanner. */
- _charset *charsets; /* Array of character sets for _SET tokens. */
- int cindex; /* Index for adding new charsets. */
- int calloc; /* Number of charsets 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 regparse(). */
-
- /* Stuff owned by the state builder. */
- _dfa_state *states; /* States of the regexp. */
- 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
- regexecute 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. */
- char must[MUST_MAX];
- int mustn;
-};
-
-/* Some macros for user access to regexp 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, reg) \
- _SUCCEEDS_IN_CONTEXT((reg).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, reg) (-(reg).states[state].first_end)
-
-/* Entry points. */
-
-#ifdef __STDC__
-
-/* Regsyntax() takes two arguments; the first sets the syntax bits described
- earlier in this file, and the second sets the case-folding flag. */
-extern void regsyntax(long, int);
-
-/* Compile the given string of the given length into the given struct regexp.
- Final argument is a flag specifying whether to build a searching or an
- exact matcher. */
-extern void regcompile(const char *, size_t, struct regexp *, int);
-
-/* Execute the given struct regexp 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 *regexecute(struct regexp *, char *, char *, int, int *, int *);
-
-/* Free the storage held by the components of a struct regexp. */
-extern void reg_free(struct regexp *);
-
-/* Entry points for people who know what they're doing. */
-
-/* Initialize the components of a struct regexp. */
-extern void reginit(struct regexp *);
-
-/* Incrementally parse a string of given length into a struct regexp. */
-extern void regparse(const char *, size_t, struct regexp *);
-
-/* Analyze a parsed regexp; second argument tells whether to build a searching
- or an exact matcher. */
-extern void reganalyze(struct regexp *, int);
-
-/* Compute, for each possible character, the transitions out of a given
- state, storing them in an array of integers. */
-extern void regstate(int, struct regexp *, int []);
-
-/* Error handling. */
-
-/* Regerror() is called by the regexp routines whenever an error occurs. It
- takes a single argument, a NUL-terminated string describing the error.
- The default reg_error() prints the error message to stderr and exits.
- The user can provide a different reg_free() if so desired. */
-extern void reg_error(const char *);
-
-#else /* ! __STDC__ */
-extern void regsyntax(), regcompile(), reg_free(), reginit(), regparse();
-extern void reganalyze(), regstate(), reg_error();
-extern char *regexecute();
-#endif
diff --git a/gnu/usr.bin/awk/eval.c b/gnu/usr.bin/awk/eval.c
deleted file mode 100644
index f640f37..0000000
--- a/gnu/usr.bin/awk/eval.c
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
- * eval.c - gawk parse tree interpreter
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-extern double pow P((double x, double y));
-extern double modf P((double x, double *yp));
-extern double fmod P((double x, double y));
-
-static int eval_condition P((NODE *tree));
-static NODE *op_assign P((NODE *tree));
-static NODE *func_call P((NODE *name, NODE *arg_list));
-static NODE *match_op P((NODE *tree));
-
-NODE *_t; /* used as a temporary in macros */
-#ifdef MSDOS
-double _msc51bug; /* to get around a bug in MSC 5.1 */
-#endif
-NODE *ret_node;
-int OFSlen;
-int ORSlen;
-int OFMTidx;
-int CONVFMTidx;
-
-/* Macros and variables to save and restore function and loop bindings */
-/*
- * the val variable allows return/continue/break-out-of-context to be
- * caught and diagnosed
- */
-#define PUSH_BINDING(stack, x, val) (memcpy ((char *)(stack), (char *)(x), sizeof (jmp_buf)), val++)
-#define RESTORE_BINDING(stack, x, val) (memcpy ((char *)(x), (char *)(stack), sizeof (jmp_buf)), val--)
-
-static jmp_buf loop_tag; /* always the current binding */
-static int loop_tag_valid = 0; /* nonzero when loop_tag valid */
-static int func_tag_valid = 0;
-static jmp_buf func_tag;
-extern int exiting, exit_val;
-
-/*
- * This table is used by the regexp routines to do case independant
- * matching. Basically, every ascii character maps to itself, except
- * uppercase letters map to lower case ones. This table has 256
- * entries, which may be overkill. Note also that if the system this
- * is compiled on doesn't use 7-bit ascii, casetable[] should not be
- * defined to the linker, so gawk should not load.
- *
- * Do NOT make this array static, it is used in several spots, not
- * just in this file.
- */
-#if 'a' == 97 /* it's ascii */
-char casetable[] = {
- '\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',
- /* '0' '1' '2' '3' '4' '5' '6' '7' */
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- /* '8' '9' ':' ';' '<' '=' '>' '?' */
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- /* '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' */
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- /* 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' */
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- /* 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' */
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- /* 'X' 'Y' 'Z' '[' '\' ']' '^' '_' */
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- /* '`' 'a' 'b' 'c' 'd' 'e' 'f' 'g' */
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- /* 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' */
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- /* 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' */
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- /* 'x' 'y' 'z' '{' '|' '}' '~' */
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
- '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
- '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
- '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
-};
-#else
-#include "You lose. You will need a translation table for your character set."
-#endif
-
-/*
- * Tree is a bunch of rules to run. Returns zero if it hit an exit()
- * statement
- */
-int
-interpret(tree)
-register NODE *volatile tree;
-{
- jmp_buf volatile loop_tag_stack; /* shallow binding stack for loop_tag */
- static jmp_buf rule_tag; /* tag the rule currently being run, for NEXT
- * and EXIT statements. It is static because
- * there are no nested rules */
- register NODE *volatile t = NULL; /* temporary */
- NODE **volatile lhs; /* lhs == Left Hand Side for assigns, etc */
- NODE *volatile stable_tree;
- int volatile traverse = 1; /* True => loop thru tree (Node_rule_list) */
-
- if (tree == NULL)
- return 1;
- sourceline = tree->source_line;
- source = tree->source_file;
- switch (tree->type) {
- case Node_rule_node:
- traverse = 0; /* False => one for-loop iteration only */
- /* FALL THROUGH */
- case Node_rule_list:
- for (t = tree; t != NULL; t = t->rnode) {
- if (traverse)
- tree = t->lnode;
- sourceline = tree->source_line;
- source = tree->source_file;
- switch (setjmp(rule_tag)) {
- case 0: /* normal non-jump */
- /* test pattern, if any */
- if (tree->lnode == NULL ||
- eval_condition(tree->lnode))
- (void) interpret(tree->rnode);
- break;
- case TAG_CONTINUE: /* NEXT statement */
- return 1;
- case TAG_BREAK:
- return 0;
- default:
- cant_happen();
- }
- if (!traverse) /* case Node_rule_node */
- break; /* don't loop */
- }
- break;
-
- case Node_statement_list:
- for (t = tree; t != NULL; t = t->rnode)
- (void) interpret(t->lnode);
- break;
-
- case Node_K_if:
- if (eval_condition(tree->lnode)) {
- (void) interpret(tree->rnode->lnode);
- } else {
- (void) interpret(tree->rnode->rnode);
- }
- break;
-
- case Node_K_while:
- PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
-
- stable_tree = tree;
- while (eval_condition(stable_tree->lnode)) {
- switch (setjmp(loop_tag)) {
- case 0: /* normal non-jump */
- (void) interpret(stable_tree->rnode);
- break;
- case TAG_CONTINUE: /* continue statement */
- break;
- case TAG_BREAK: /* break statement */
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- return 1;
- default:
- cant_happen();
- }
- }
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- break;
-
- case Node_K_do:
- PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- stable_tree = tree;
- do {
- switch (setjmp(loop_tag)) {
- case 0: /* normal non-jump */
- (void) interpret(stable_tree->rnode);
- break;
- case TAG_CONTINUE: /* continue statement */
- break;
- case TAG_BREAK: /* break statement */
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- return 1;
- default:
- cant_happen();
- }
- } while (eval_condition(stable_tree->lnode));
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- break;
-
- case Node_K_for:
- PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- (void) interpret(tree->forloop->init);
- stable_tree = tree;
- while (eval_condition(stable_tree->forloop->cond)) {
- switch (setjmp(loop_tag)) {
- case 0: /* normal non-jump */
- (void) interpret(stable_tree->lnode);
- /* fall through */
- case TAG_CONTINUE: /* continue statement */
- (void) interpret(stable_tree->forloop->incr);
- break;
- case TAG_BREAK: /* break statement */
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- return 1;
- default:
- cant_happen();
- }
- }
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- break;
-
- case Node_K_arrayfor:
- {
- volatile struct search l; /* For array_for */
- Func_ptr after_assign = NULL;
-
-#define hakvar forloop->init
-#define arrvar forloop->incr
- PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- lhs = get_lhs(tree->hakvar, &after_assign);
- t = tree->arrvar;
- if (t->type == Node_param_list)
- t = stack_ptr[t->param_cnt];
- stable_tree = tree;
- for (assoc_scan(t, (struct search *)&l);
- l.retval;
- assoc_next((struct search *)&l)) {
- unref(*((NODE **) lhs));
- *lhs = dupnode(l.retval);
- if (after_assign)
- (*after_assign)();
- switch (setjmp(loop_tag)) {
- case 0:
- (void) interpret(stable_tree->lnode);
- case TAG_CONTINUE:
- break;
-
- case TAG_BREAK:
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- return 1;
- default:
- cant_happen();
- }
- }
- RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
- break;
- }
-
- case Node_K_break:
- if (loop_tag_valid == 0)
- fatal("unexpected break");
- longjmp(loop_tag, TAG_BREAK);
- break;
-
- case Node_K_continue:
- if (loop_tag_valid == 0) {
- /*
- * AT&T nawk treats continue outside of loops like
- * next. Allow it if not posix, and complain if
- * lint.
- */
- static int warned = 0;
-
- if (do_lint && ! warned) {
- warning("use of `continue' outside of loop is not portable");
- warned = 1;
- }
- if (do_posix)
- fatal("use of `continue' outside of loop is not allowed");
- longjmp(rule_tag, TAG_CONTINUE);
- } else
- longjmp(loop_tag, TAG_CONTINUE);
- break;
-
- case Node_K_print:
- do_print(tree);
- break;
-
- case Node_K_printf:
- do_printf(tree);
- break;
-
- case Node_K_delete:
- do_delete(tree->lnode, tree->rnode);
- break;
-
- case Node_K_next:
- longjmp(rule_tag, TAG_CONTINUE);
- break;
-
- case Node_K_nextfile:
- do_nextfile();
- break;
-
- case Node_K_exit:
- /*
- * In A,K,&W, p. 49, it says that an exit statement "...
- * causes the program to behave as if the end of input had
- * occurred; no more input is read, and the END actions, if
- * any are executed." This implies that the rest of the rules
- * are not done. So we immediately break out of the main loop.
- */
- exiting = 1;
- if (tree) {
- t = tree_eval(tree->lnode);
- exit_val = (int) force_number(t);
- }
- free_temp(t);
- longjmp(rule_tag, TAG_BREAK);
- break;
-
- case Node_K_return:
- t = tree_eval(tree->lnode);
- ret_node = dupnode(t);
- free_temp(t);
- longjmp(func_tag, TAG_RETURN);
- break;
-
- default:
- /*
- * Appears to be an expression statement. Throw away the
- * value.
- */
- if (do_lint && tree->type == Node_var)
- warning("statement has no effect");
- t = tree_eval(tree);
- free_temp(t);
- break;
- }
- return 1;
-}
-
-/* evaluate a subtree */
-
-NODE *
-r_tree_eval(tree)
-register NODE *tree;
-{
- register NODE *r, *t1, *t2; /* return value & temporary subtrees */
- register NODE **lhs;
- register int di;
- AWKNUM x, x1, x2;
- long lx;
-#ifdef CRAY
- long lx2;
-#endif
-
-#ifdef DEBUG
- if (tree == NULL)
- return Nnull_string;
- if (tree->type == Node_val) {
- if (tree->stref <= 0) cant_happen();
- return tree;
- }
- if (tree->type == Node_var) {
- if (tree->var_value->stref <= 0) cant_happen();
- return tree->var_value;
- }
- if (tree->type == Node_param_list) {
- if (stack_ptr[tree->param_cnt] == NULL)
- return Nnull_string;
- else
- return stack_ptr[tree->param_cnt]->var_value;
- }
-#endif
- switch (tree->type) {
- case Node_and:
- return tmp_number((AWKNUM) (eval_condition(tree->lnode)
- && eval_condition(tree->rnode)));
-
- case Node_or:
- return tmp_number((AWKNUM) (eval_condition(tree->lnode)
- || eval_condition(tree->rnode)));
-
- case Node_not:
- return tmp_number((AWKNUM) ! eval_condition(tree->lnode));
-
- /* Builtins */
- case Node_builtin:
- return ((*tree->proc) (tree->subnode));
-
- case Node_K_getline:
- return (do_getline(tree));
-
- case Node_in_array:
- return tmp_number((AWKNUM) in_array(tree->lnode, tree->rnode));
-
- case Node_func_call:
- return func_call(tree->rnode, tree->lnode);
-
- /* unary operations */
- case Node_NR:
- case Node_FNR:
- case Node_NF:
- case Node_FIELDWIDTHS:
- case Node_FS:
- case Node_RS:
- case Node_field_spec:
- case Node_subscript:
- case Node_IGNORECASE:
- case Node_OFS:
- case Node_ORS:
- case Node_OFMT:
- case Node_CONVFMT:
- lhs = get_lhs(tree, (Func_ptr *)0);
- return *lhs;
-
- case Node_var_array:
- fatal("attempt to use an array in a scalar context");
-
- case Node_unary_minus:
- t1 = tree_eval(tree->subnode);
- x = -force_number(t1);
- free_temp(t1);
- return tmp_number(x);
-
- case Node_cond_exp:
- if (eval_condition(tree->lnode))
- return tree_eval(tree->rnode->lnode);
- return tree_eval(tree->rnode->rnode);
-
- case Node_match:
- case Node_nomatch:
- case Node_regex:
- return match_op(tree);
-
- case Node_func:
- fatal("function `%s' called with space between name and (,\n%s",
- tree->lnode->param,
- "or used in other expression context");
-
- /* assignments */
- case Node_assign:
- {
- Func_ptr after_assign = NULL;
-
- r = tree_eval(tree->rnode);
- lhs = get_lhs(tree->lnode, &after_assign);
- if (r != *lhs) {
- NODE *save;
-
- save = *lhs;
- *lhs = dupnode(r);
- unref(save);
- }
- free_temp(r);
- if (after_assign)
- (*after_assign)();
- return *lhs;
- }
-
- case Node_concat:
- {
-#define STACKSIZE 10
- NODE *stack[STACKSIZE];
- register NODE **sp;
- register int len;
- char *str;
- register char *dest;
-
- sp = stack;
- len = 0;
- while (tree->type == Node_concat) {
- *sp = force_string(tree_eval(tree->lnode));
- tree = tree->rnode;
- len += (*sp)->stlen;
- if (++sp == &stack[STACKSIZE-2]) /* one more and NULL */
- break;
- }
- *sp = force_string(tree_eval(tree));
- len += (*sp)->stlen;
- *++sp = NULL;
- emalloc(str, char *, len+2, "tree_eval");
- dest = str;
- sp = stack;
- while (*sp) {
- memcpy(dest, (*sp)->stptr, (*sp)->stlen);
- dest += (*sp)->stlen;
- free_temp(*sp);
- sp++;
- }
- r = make_str_node(str, len, ALREADY_MALLOCED);
- r->flags |= TEMP;
- }
- return r;
-
- /* other assignment types are easier because they are numeric */
- case Node_preincrement:
- case Node_predecrement:
- case Node_postincrement:
- case Node_postdecrement:
- case Node_assign_exp:
- case Node_assign_times:
- case Node_assign_quotient:
- case Node_assign_mod:
- case Node_assign_plus:
- case Node_assign_minus:
- return op_assign(tree);
- default:
- break; /* handled below */
- }
-
- /* evaluate subtrees in order to do binary operation, then keep going */
- t1 = tree_eval(tree->lnode);
- t2 = tree_eval(tree->rnode);
-
- switch (tree->type) {
- case Node_geq:
- case Node_leq:
- case Node_greater:
- case Node_less:
- case Node_notequal:
- case Node_equal:
- di = cmp_nodes(t1, t2);
- free_temp(t1);
- free_temp(t2);
- switch (tree->type) {
- case Node_equal:
- return tmp_number((AWKNUM) (di == 0));
- case Node_notequal:
- return tmp_number((AWKNUM) (di != 0));
- case Node_less:
- return tmp_number((AWKNUM) (di < 0));
- case Node_greater:
- return tmp_number((AWKNUM) (di > 0));
- case Node_leq:
- return tmp_number((AWKNUM) (di <= 0));
- case Node_geq:
- return tmp_number((AWKNUM) (di >= 0));
- default:
- cant_happen();
- }
- break;
- default:
- break; /* handled below */
- }
-
- x1 = force_number(t1);
- free_temp(t1);
- x2 = force_number(t2);
- free_temp(t2);
- switch (tree->type) {
- case Node_exp:
- if ((lx = x2) == x2 && lx >= 0) { /* integer exponent */
- if (lx == 0)
- x = 1;
- else if (lx == 1)
- x = x1;
- else {
- /* doing it this way should be more precise */
- for (x = x1; --lx; )
- x *= x1;
- }
- } else
- x = pow((double) x1, (double) x2);
- return tmp_number(x);
-
- case Node_times:
- return tmp_number(x1 * x2);
-
- case Node_quotient:
- if (x2 == 0)
- fatal("division by zero attempted");
-#ifdef _CRAY
- /*
- * special case for integer division, put in for Cray
- */
- lx2 = x2;
- if (lx2 == 0)
- return tmp_number(x1 / x2);
- lx = (long) x1 / lx2;
- if (lx * x2 == x1)
- return tmp_number((AWKNUM) lx);
- else
-#endif
- return tmp_number(x1 / x2);
-
- case Node_mod:
- if (x2 == 0)
- fatal("division by zero attempted in mod");
-#ifndef FMOD_MISSING
- return tmp_number(fmod (x1, x2));
-#else
- (void) modf(x1 / x2, &x);
- return tmp_number(x1 - x * x2);
-#endif
-
- case Node_plus:
- return tmp_number(x1 + x2);
-
- case Node_minus:
- return tmp_number(x1 - x2);
-
- case Node_var_array:
- fatal("attempt to use an array in a scalar context");
-
- default:
- fatal("illegal type (%d) in tree_eval", tree->type);
- }
- return 0;
-}
-
-/* Is TREE true or false? Returns 0==false, non-zero==true */
-static int
-eval_condition(tree)
-register NODE *tree;
-{
- register NODE *t1;
- register int ret;
-
- if (tree == NULL) /* Null trees are the easiest kinds */
- return 1;
- if (tree->type == Node_line_range) {
- /*
- * Node_line_range is kind of like Node_match, EXCEPT: the
- * lnode field (more properly, the condpair field) is a node
- * of a Node_cond_pair; whether we evaluate the lnode of that
- * node or the rnode depends on the triggered word. More
- * precisely: if we are not yet triggered, we tree_eval the
- * lnode; if that returns true, we set the triggered word.
- * If we are triggered (not ELSE IF, note), we tree_eval the
- * rnode, clear triggered if it succeeds, and perform our
- * action (regardless of success or failure). We want to be
- * able to begin and end on a single input record, so this
- * isn't an ELSE IF, as noted above.
- */
- if (!tree->triggered)
- if (!eval_condition(tree->condpair->lnode))
- return 0;
- else
- tree->triggered = 1;
- /* Else we are triggered */
- if (eval_condition(tree->condpair->rnode))
- tree->triggered = 0;
- return 1;
- }
-
- /*
- * Could just be J.random expression. in which case, null and 0 are
- * false, anything else is true
- */
-
- t1 = tree_eval(tree);
- if (t1->flags & MAYBE_NUM)
- (void) force_number(t1);
- if (t1->flags & NUMBER)
- ret = t1->numbr != 0.0;
- else
- ret = t1->stlen != 0;
- free_temp(t1);
- return ret;
-}
-
-/*
- * compare two nodes, returning negative, 0, positive
- */
-int
-cmp_nodes(t1, t2)
-register NODE *t1, *t2;
-{
- register int ret;
- register int len1, len2;
-
- if (t1 == t2)
- return 0;
- if (t1->flags & MAYBE_NUM)
- (void) force_number(t1);
- if (t2->flags & MAYBE_NUM)
- (void) force_number(t2);
- if ((t1->flags & NUMBER) && (t2->flags & NUMBER)) {
- if (t1->numbr == t2->numbr) return 0;
- else if (t1->numbr - t2->numbr < 0) return -1;
- else return 1;
- }
- (void) force_string(t1);
- (void) force_string(t2);
- len1 = t1->stlen;
- len2 = t2->stlen;
- if (len1 == 0 || len2 == 0)
- return len1 - len2;
- ret = memcmp(t1->stptr, t2->stptr, len1 <= len2 ? len1 : len2);
- return ret == 0 ? len1-len2 : ret;
-}
-
-static NODE *
-op_assign(tree)
-register NODE *tree;
-{
- AWKNUM rval, lval;
- NODE **lhs;
- AWKNUM t1, t2;
- long ltemp;
- NODE *tmp;
- Func_ptr after_assign = NULL;
-
- lhs = get_lhs(tree->lnode, &after_assign);
- lval = force_number(*lhs);
-
- /*
- * Can't unref *lhs until we know the type; doing so
- * too early breaks x += x sorts of things.
- */
- switch(tree->type) {
- case Node_preincrement:
- case Node_predecrement:
- unref(*lhs);
- *lhs = make_number(lval +
- (tree->type == Node_preincrement ? 1.0 : -1.0));
- if (after_assign)
- (*after_assign)();
- return *lhs;
-
- case Node_postincrement:
- case Node_postdecrement:
- unref(*lhs);
- *lhs = make_number(lval +
- (tree->type == Node_postincrement ? 1.0 : -1.0));
- if (after_assign)
- (*after_assign)();
- return tmp_number(lval);
- default:
- break; /* handled below */
- }
-
- tmp = tree_eval(tree->rnode);
- rval = force_number(tmp);
- free_temp(tmp);
- unref(*lhs);
- switch(tree->type) {
- case Node_assign_exp:
- if ((ltemp = rval) == rval) { /* integer exponent */
- if (ltemp == 0)
- *lhs = make_number((AWKNUM) 1);
- else if (ltemp == 1)
- *lhs = make_number(lval);
- else {
- /* doing it this way should be more precise */
- for (t1 = t2 = lval; --ltemp; )
- t1 *= t2;
- *lhs = make_number(t1);
- }
- } else
- *lhs = make_number((AWKNUM) pow((double) lval, (double) rval));
- break;
-
- case Node_assign_times:
- *lhs = make_number(lval * rval);
- break;
-
- case Node_assign_quotient:
- if (rval == (AWKNUM) 0)
- fatal("division by zero attempted in /=");
-#ifdef _CRAY
- /*
- * special case for integer division, put in for Cray
- */
- ltemp = rval;
- if (ltemp == 0) {
- *lhs = make_number(lval / rval);
- break;
- }
- ltemp = (long) lval / ltemp;
- if (ltemp * lval == rval)
- *lhs = make_number((AWKNUM) ltemp);
- else
-#endif
- *lhs = make_number(lval / rval);
- break;
-
- case Node_assign_mod:
- if (rval == (AWKNUM) 0)
- fatal("division by zero attempted in %=");
-#ifndef FMOD_MISSING
- *lhs = make_number(fmod(lval, rval));
-#else
- (void) modf(lval / rval, &t1);
- t2 = lval - rval * t1;
- *lhs = make_number(t2);
-#endif
- break;
-
- case Node_assign_plus:
- *lhs = make_number(lval + rval);
- break;
-
- case Node_assign_minus:
- *lhs = make_number(lval - rval);
- break;
- default:
- cant_happen();
- }
- if (after_assign)
- (*after_assign)();
- return *lhs;
-}
-
-NODE **stack_ptr;
-
-static NODE *
-func_call(name, arg_list)
-NODE *name; /* name is a Node_val giving function name */
-NODE *arg_list; /* Node_expression_list of calling args. */
-{
- register NODE *arg, *argp, *r;
- NODE *n, *f;
- jmp_buf volatile func_tag_stack;
- jmp_buf volatile loop_tag_stack;
- int volatile save_loop_tag_valid = 0;
- NODE **volatile save_stack, *save_ret_node;
- NODE **volatile local_stack = NULL, **sp;
- int count;
- extern NODE *ret_node;
-
- /*
- * retrieve function definition node
- */
- f = lookup(name->stptr);
- if (!f || f->type != Node_func)
- fatal("function `%s' not defined", name->stptr);
-#ifdef FUNC_TRACE
- fprintf(stderr, "function %s called\n", name->stptr);
-#endif
- count = f->lnode->param_cnt;
- if (count)
- emalloc(local_stack, NODE **, count*sizeof(NODE *), "func_call");
- sp = local_stack;
-
- /*
- * for each calling arg. add NODE * on stack
- */
- for (argp = arg_list; count && argp != NULL; argp = argp->rnode) {
- arg = argp->lnode;
- getnode(r);
- r->type = Node_var;
- /*
- * call by reference for arrays; see below also
- */
- if (arg->type == Node_param_list)
- arg = stack_ptr[arg->param_cnt];
- if (arg->type == Node_var_array)
- *r = *arg;
- else {
- n = tree_eval(arg);
- r->lnode = dupnode(n);
- r->rnode = (NODE *) NULL;
- free_temp(n);
- }
- *sp++ = r;
- count--;
- }
- if (argp != NULL) /* left over calling args. */
- warning(
- "function `%s' called with more arguments than declared",
- name->stptr);
- /*
- * add remaining params. on stack with null value
- */
- while (count-- > 0) {
- getnode(r);
- r->type = Node_var;
- r->lnode = Nnull_string;
- r->rnode = (NODE *) NULL;
- *sp++ = r;
- }
-
- /*
- * Execute function body, saving context, as a return statement
- * will longjmp back here.
- *
- * Have to save and restore the loop_tag stuff so that a return
- * inside a loop in a function body doesn't scrog any loops going
- * on in the main program. We save the necessary info in variables
- * local to this function so that function nesting works OK.
- * We also only bother to save the loop stuff if we're in a loop
- * when the function is called.
- */
- if (loop_tag_valid) {
- int junk = 0;
-
- save_loop_tag_valid = (volatile int) loop_tag_valid;
- PUSH_BINDING(loop_tag_stack, loop_tag, junk);
- loop_tag_valid = 0;
- }
- save_stack = stack_ptr;
- stack_ptr = local_stack;
- PUSH_BINDING(func_tag_stack, func_tag, func_tag_valid);
- save_ret_node = ret_node;
- ret_node = Nnull_string; /* default return value */
- if (setjmp(func_tag) == 0)
- (void) interpret(f->rnode);
-
- r = ret_node;
- ret_node = (NODE *) save_ret_node;
- RESTORE_BINDING(func_tag_stack, func_tag, func_tag_valid);
- stack_ptr = (NODE **) save_stack;
-
- /*
- * here, we pop each parameter and check whether
- * it was an array. If so, and if the arg. passed in was
- * a simple variable, then the value should be copied back.
- * This achieves "call-by-reference" for arrays.
- */
- sp = local_stack;
- count = f->lnode->param_cnt;
- for (argp = arg_list; count > 0 && argp != NULL; argp = argp->rnode) {
- arg = argp->lnode;
- if (arg->type == Node_param_list)
- arg = stack_ptr[arg->param_cnt];
- n = *sp++;
- if (arg->type == Node_var && n->type == Node_var_array) {
- /* should we free arg->var_value ? */
- arg->var_array = n->var_array;
- arg->type = Node_var_array;
- }
- unref(n->lnode);
- freenode(n);
- count--;
- }
- while (count-- > 0) {
- n = *sp++;
- /* if n is an (local) array, all the elements should be freed */
- if (n->type == Node_var_array) {
- assoc_clear(n);
- free(n->var_array);
- }
- unref(n->lnode);
- freenode(n);
- }
- if (local_stack)
- free((char *) local_stack);
-
- /* Restore the loop_tag stuff if necessary. */
- if (save_loop_tag_valid) {
- int junk = 0;
-
- loop_tag_valid = (int) save_loop_tag_valid;
- RESTORE_BINDING(loop_tag_stack, loop_tag, junk);
- }
-
- if (!(r->flags & PERM))
- r->flags |= TEMP;
- return r;
-}
-
-/*
- * This returns a POINTER to a node pointer. get_lhs(ptr) is the current
- * value of the var, or where to store the var's new value
- */
-
-NODE **
-get_lhs(ptr, assign)
-register NODE *ptr;
-Func_ptr *assign;
-{
- register NODE **aptr = NULL;
- register NODE *n;
-
- switch (ptr->type) {
- case Node_var_array:
- fatal("attempt to use an array in a scalar context");
- case Node_var:
- aptr = &(ptr->var_value);
-#ifdef DEBUG
- if (ptr->var_value->stref <= 0)
- cant_happen();
-#endif
- break;
-
- case Node_FIELDWIDTHS:
- aptr = &(FIELDWIDTHS_node->var_value);
- if (assign)
- *assign = set_FIELDWIDTHS;
- break;
-
- case Node_RS:
- aptr = &(RS_node->var_value);
- if (assign)
- *assign = set_RS;
- break;
-
- case Node_FS:
- aptr = &(FS_node->var_value);
- if (assign)
- *assign = set_FS;
- break;
-
- case Node_FNR:
- unref(FNR_node->var_value);
- FNR_node->var_value = make_number((AWKNUM) FNR);
- aptr = &(FNR_node->var_value);
- if (assign)
- *assign = set_FNR;
- break;
-
- case Node_NR:
- unref(NR_node->var_value);
- NR_node->var_value = make_number((AWKNUM) NR);
- aptr = &(NR_node->var_value);
- if (assign)
- *assign = set_NR;
- break;
-
- case Node_NF:
- if (NF == -1)
- (void) get_field(HUGE-1, assign); /* parse record */
- unref(NF_node->var_value);
- NF_node->var_value = make_number((AWKNUM) NF);
- aptr = &(NF_node->var_value);
- if (assign)
- *assign = set_NF;
- break;
-
- case Node_IGNORECASE:
- unref(IGNORECASE_node->var_value);
- IGNORECASE_node->var_value = make_number((AWKNUM) IGNORECASE);
- aptr = &(IGNORECASE_node->var_value);
- if (assign)
- *assign = set_IGNORECASE;
- break;
-
- case Node_OFMT:
- aptr = &(OFMT_node->var_value);
- if (assign)
- *assign = set_OFMT;
- break;
-
- case Node_CONVFMT:
- aptr = &(CONVFMT_node->var_value);
- if (assign)
- *assign = set_CONVFMT;
- break;
-
- case Node_ORS:
- aptr = &(ORS_node->var_value);
- if (assign)
- *assign = set_ORS;
- break;
-
- case Node_OFS:
- aptr = &(OFS_node->var_value);
- if (assign)
- *assign = set_OFS;
- break;
-
- case Node_param_list:
- aptr = &(stack_ptr[ptr->param_cnt]->var_value);
- break;
-
- case Node_field_spec:
- {
- int field_num;
-
- n = tree_eval(ptr->lnode);
- field_num = (int) force_number(n);
- free_temp(n);
- if (field_num < 0)
- fatal("attempt to access field %d", field_num);
- if (field_num == 0 && field0_valid) { /* short circuit */
- aptr = &fields_arr[0];
- if (assign)
- *assign = reset_record;
- break;
- }
- aptr = get_field(field_num, assign);
- break;
- }
- case Node_subscript:
- n = ptr->lnode;
- if (n->type == Node_param_list)
- n = stack_ptr[n->param_cnt];
- aptr = assoc_lookup(n, concat_exp(ptr->rnode));
- break;
-
- case Node_func:
- fatal ("`%s' is a function, assignment is not allowed",
- ptr->lnode->param);
- default:
- cant_happen();
- }
- return aptr;
-}
-
-static NODE *
-match_op(tree)
-register NODE *tree;
-{
- register NODE *t1;
- register Regexp *rp;
- int i;
- int match = 1;
-
- if (tree->type == Node_nomatch)
- match = 0;
- if (tree->type == Node_regex)
- t1 = *get_field(0, (Func_ptr *) 0);
- else {
- t1 = force_string(tree_eval(tree->lnode));
- tree = tree->rnode;
- }
- rp = re_update(tree);
- i = research(rp, t1->stptr, 0, t1->stlen, 0);
- i = (i == -1) ^ (match == 1);
- free_temp(t1);
- return tmp_number((AWKNUM) i);
-}
-
-void
-set_IGNORECASE()
-{
- static int warned = 0;
-
- if ((do_lint || do_unix) && ! warned) {
- warned = 1;
- warning("IGNORECASE not supported in compatibility mode");
- }
- IGNORECASE = (force_number(IGNORECASE_node->var_value) != 0.0);
- set_FS();
-}
-
-void
-set_OFS()
-{
- OFS = force_string(OFS_node->var_value)->stptr;
- OFSlen = OFS_node->var_value->stlen;
- OFS[OFSlen] = '\0';
-}
-
-void
-set_ORS()
-{
- ORS = force_string(ORS_node->var_value)->stptr;
- ORSlen = ORS_node->var_value->stlen;
- ORS[ORSlen] = '\0';
-}
-
-static NODE **fmt_list = NULL;
-static int fmt_ok P((NODE *n));
-static int fmt_index P((NODE *n));
-
-static int
-fmt_ok(n)
-NODE *n;
-{
- /* to be done later */
- return 1;
-}
-
-static int
-fmt_index(n)
-NODE *n;
-{
- register int ix = 0;
- static int fmt_num = 4;
- static int fmt_hiwater = 0;
-
- if (fmt_list == NULL)
- emalloc(fmt_list, NODE **, fmt_num*sizeof(*fmt_list), "fmt_index");
- (void) force_string(n);
- while (ix < fmt_hiwater) {
- if (cmp_nodes(fmt_list[ix], n) == 0)
- return ix;
- ix++;
- }
- /* not found */
- n->stptr[n->stlen] = '\0';
- if (!fmt_ok(n))
- warning("bad FMT specification");
- if (fmt_hiwater >= fmt_num) {
- fmt_num *= 2;
- emalloc(fmt_list, NODE **, fmt_num, "fmt_index");
- }
- fmt_list[fmt_hiwater] = dupnode(n);
- return fmt_hiwater++;
-}
-
-void
-set_OFMT()
-{
- OFMTidx = fmt_index(OFMT_node->var_value);
- OFMT = fmt_list[OFMTidx]->stptr;
-}
-
-void
-set_CONVFMT()
-{
- CONVFMTidx = fmt_index(CONVFMT_node->var_value);
- CONVFMT = fmt_list[CONVFMTidx]->stptr;
-}
diff --git a/gnu/usr.bin/awk/field.c b/gnu/usr.bin/awk/field.c
deleted file mode 100644
index d8f9a54..0000000
--- a/gnu/usr.bin/awk/field.c
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- * field.c - routines for dealing with fields and record parsing
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-static int (*parse_field) P((int, char **, int, NODE *,
- Regexp *, void (*)(), NODE *));
-static void rebuild_record P((void));
-static int re_parse_field P((int, char **, int, NODE *,
- Regexp *, void (*)(), NODE *));
-static int def_parse_field P((int, char **, int, NODE *,
- Regexp *, void (*)(), NODE *));
-static int sc_parse_field P((int, char **, int, NODE *,
- Regexp *, void (*)(), NODE *));
-static int fw_parse_field P((int, char **, int, NODE *,
- Regexp *, void (*)(), NODE *));
-static void set_element P((int, char *, int, NODE *));
-static void grow_fields_arr P((int num));
-static void set_field P((int num, char *str, int len, NODE *dummy));
-
-
-static Regexp *FS_regexp = NULL;
-static char *parse_extent; /* marks where to restart parse of record */
-static int parse_high_water=0; /* field number that we have parsed so far */
-static int nf_high_water = 0; /* size of fields_arr */
-static int resave_fs;
-static NODE *save_FS; /* save current value of FS when line is read,
- * to be used in deferred parsing
- */
-
-NODE **fields_arr; /* array of pointers to the field nodes */
-int field0_valid; /* $(>0) has not been changed yet */
-int default_FS;
-static NODE **nodes; /* permanent repository of field nodes */
-static int *FIELDWIDTHS = NULL;
-
-void
-init_fields()
-{
- NODE *n;
-
- emalloc(fields_arr, NODE **, sizeof(NODE *), "init_fields");
- emalloc(nodes, NODE **, sizeof(NODE *), "init_fields");
- getnode(n);
- *n = *Nnull_string;
- fields_arr[0] = nodes[0] = n;
- parse_extent = fields_arr[0]->stptr;
- save_FS = dupnode(FS_node->var_value);
- field0_valid = 1;
-}
-
-
-static void
-grow_fields_arr(num)
-int num;
-{
- register int t;
- register NODE *n;
-
- erealloc(fields_arr, NODE **, (num + 1) * sizeof(NODE *), "set_field");
- erealloc(nodes, NODE **, (num+1) * sizeof(NODE *), "set_field");
- for (t = nf_high_water+1; t <= num; t++) {
- getnode(n);
- *n = *Nnull_string;
- fields_arr[t] = nodes[t] = n;
- }
- nf_high_water = num;
-}
-
-/*ARGSUSED*/
-static void
-set_field(num, str, len, dummy)
-int num;
-char *str;
-int len;
-NODE *dummy; /* not used -- just to make interface same as set_element */
-{
- register NODE *n;
-
- if (num > nf_high_water)
- grow_fields_arr(num);
- n = nodes[num];
- n->stptr = str;
- n->stlen = len;
- n->flags = (PERM|STR|STRING|MAYBE_NUM);
- fields_arr[num] = n;
-}
-
-/* Someone assigned a value to $(something). Fix up $0 to be right */
-static void
-rebuild_record()
-{
- register int tlen;
- register NODE *tmp;
- NODE *ofs;
- char *ops;
- register char *cops;
- register NODE **ptr;
- register int ofslen;
-
- tlen = 0;
- ofs = force_string(OFS_node->var_value);
- ofslen = ofs->stlen;
- ptr = &fields_arr[NF];
- while (ptr > &fields_arr[0]) {
- tmp = force_string(*ptr);
- tlen += tmp->stlen;
- ptr--;
- }
- tlen += (NF - 1) * ofslen;
- if (tlen < 0)
- tlen = 0;
- emalloc(ops, char *, tlen + 2, "fix_fields");
- cops = ops;
- ops[0] = '\0';
- for (ptr = &fields_arr[1]; ptr <= &fields_arr[NF]; ptr++) {
- tmp = *ptr;
- if (tmp->stlen == 1)
- *cops++ = tmp->stptr[0];
- else if (tmp->stlen != 0) {
- memcpy(cops, tmp->stptr, tmp->stlen);
- cops += tmp->stlen;
- }
- if (ptr != &fields_arr[NF]) {
- if (ofslen == 1)
- *cops++ = ofs->stptr[0];
- else if (ofslen != 0) {
- memcpy(cops, ofs->stptr, ofslen);
- cops += ofslen;
- }
- }
- }
- tmp = make_str_node(ops, tlen, ALREADY_MALLOCED);
- unref(fields_arr[0]);
- fields_arr[0] = tmp;
- field0_valid = 1;
-}
-
-/*
- * setup $0, but defer parsing rest of line until reference is made to $(>0)
- * or to NF. At that point, parse only as much as necessary.
- */
-void
-set_record(buf, cnt, freeold)
-char *buf;
-int cnt;
-int freeold;
-{
- register int i;
-
- NF = -1;
- for (i = 1; i <= parse_high_water; i++) {
- unref(fields_arr[i]);
- }
- parse_high_water = 0;
- if (freeold) {
- unref(fields_arr[0]);
- if (resave_fs) {
- resave_fs = 0;
- unref(save_FS);
- save_FS = dupnode(FS_node->var_value);
- }
- nodes[0]->stptr = buf;
- nodes[0]->stlen = cnt;
- nodes[0]->stref = 1;
- nodes[0]->flags = (STRING|STR|PERM|MAYBE_NUM);
- fields_arr[0] = nodes[0];
- }
- fields_arr[0]->flags |= MAYBE_NUM;
- field0_valid = 1;
-}
-
-void
-reset_record()
-{
- (void) force_string(fields_arr[0]);
- set_record(fields_arr[0]->stptr, fields_arr[0]->stlen, 0);
-}
-
-void
-set_NF()
-{
- register int i;
-
- NF = (int) force_number(NF_node->var_value);
- if (NF > nf_high_water)
- grow_fields_arr(NF);
- for (i = parse_high_water + 1; i <= NF; i++) {
- unref(fields_arr[i]);
- fields_arr[i] = Nnull_string;
- }
- field0_valid = 0;
-}
-
-/*
- * this is called both from get_field() and from do_split()
- * via (*parse_field)(). This variation is for when FS is a regular
- * expression -- either user-defined or because RS=="" and FS==" "
- */
-static int
-re_parse_field(up_to, buf, len, fs, rp, set, n)
-int up_to; /* parse only up to this field number */
-char **buf; /* on input: string to parse; on output: point to start next */
-int len;
-NODE *fs;
-Regexp *rp;
-void (*set) (); /* routine to set the value of the parsed field */
-NODE *n;
-{
- register char *scan = *buf;
- register int nf = parse_high_water;
- register char *field;
- register char *end = scan + len;
-
- if (up_to == HUGE)
- nf = 0;
- if (len == 0)
- return nf;
-
- if (*RS == 0 && default_FS)
- while (scan < end && isspace(*scan))
- scan++;
- field = scan;
- while (scan < end
- && research(rp, scan, 0, (int)(end - scan), 1) != -1
- && nf < up_to) {
- if (REEND(rp, scan) == RESTART(rp, scan)) { /* null match */
- scan++;
- if (scan == end) {
- (*set)(++nf, field, scan - field, n);
- up_to = nf;
- break;
- }
- continue;
- }
- (*set)(++nf, field, scan + RESTART(rp, scan) - field, n);
- scan += REEND(rp, scan);
- field = scan;
- if (scan == end) /* FS at end of record */
- (*set)(++nf, field, 0, n);
- }
- if (nf != up_to && scan < end) {
- (*set)(++nf, scan, (int)(end - scan), n);
- scan = end;
- }
- *buf = scan;
- return (nf);
-}
-
-/*
- * this is called both from get_field() and from do_split()
- * via (*parse_field)(). This variation is for when FS is a single space
- * character.
- */
-static int
-def_parse_field(up_to, buf, len, fs, rp, set, n)
-int up_to; /* parse only up to this field number */
-char **buf; /* on input: string to parse; on output: point to start next */
-int len;
-NODE *fs;
-Regexp *rp;
-void (*set) (); /* routine to set the value of the parsed field */
-NODE *n;
-{
- register char *scan = *buf;
- register int nf = parse_high_water;
- register char *field;
- register char *end = scan + len;
- char sav;
-
- if (up_to == HUGE)
- nf = 0;
- if (len == 0)
- return nf;
-
- /* before doing anything save the char at *end */
- sav = *end;
- /* because it will be destroyed now: */
-
- *end = ' '; /* sentinel character */
- for (; nf < up_to; scan++) {
- /*
- * special case: fs is single space, strip leading whitespace
- */
- while (scan < end && (*scan == ' ' || *scan == '\t'))
- scan++;
- if (scan >= end)
- break;
- field = scan;
- while (*scan != ' ' && *scan != '\t')
- scan++;
- (*set)(++nf, field, (int)(scan - field), n);
- if (scan == end)
- break;
- }
-
- /* everything done, restore original char at *end */
- *end = sav;
-
- *buf = scan;
- return nf;
-}
-
-/*
- * this is called both from get_field() and from do_split()
- * via (*parse_field)(). This variation is for when FS is a single character
- * other than space.
- */
-static int
-sc_parse_field(up_to, buf, len, fs, rp, set, n)
-int up_to; /* parse only up to this field number */
-char **buf; /* on input: string to parse; on output: point to start next */
-int len;
-NODE *fs;
-Regexp *rp;
-void (*set) (); /* routine to set the value of the parsed field */
-NODE *n;
-{
- register char *scan = *buf;
- register char fschar;
- register int nf = parse_high_water;
- register char *field;
- register char *end = scan + len;
- char sav;
-
- if (up_to == HUGE)
- nf = 0;
- if (len == 0)
- return nf;
-
- if (*RS == 0 && fs->stlen == 0)
- fschar = '\n';
- else
- fschar = fs->stptr[0];
-
- /* before doing anything save the char at *end */
- sav = *end;
- /* because it will be destroyed now: */
- *end = fschar; /* sentinel character */
-
- for (; nf < up_to; scan++) {
- field = scan;
- while (*scan++ != fschar)
- ;
- scan--;
- (*set)(++nf, field, (int)(scan - field), n);
- if (scan == end)
- break;
- }
-
- /* everything done, restore original char at *end */
- *end = sav;
-
- *buf = scan;
- return nf;
-}
-
-/*
- * this is called both from get_field() and from do_split()
- * via (*parse_field)(). This variation is for fields are fixed widths.
- */
-static int
-fw_parse_field(up_to, buf, len, fs, rp, set, n)
-int up_to; /* parse only up to this field number */
-char **buf; /* on input: string to parse; on output: point to start next */
-int len;
-NODE *fs;
-Regexp *rp;
-void (*set) (); /* routine to set the value of the parsed field */
-NODE *n;
-{
- register char *scan = *buf;
- register int nf = parse_high_water;
- register char *end = scan + len;
-
- if (up_to == HUGE)
- nf = 0;
- if (len == 0)
- return nf;
- for (; nf < up_to && (len = FIELDWIDTHS[nf+1]) != -1; ) {
- if (len > end - scan)
- len = end - scan;
- (*set)(++nf, scan, len, n);
- scan += len;
- }
- if (len == -1)
- *buf = end;
- else
- *buf = scan;
- return nf;
-}
-
-NODE **
-get_field(requested, assign)
-register int requested;
-Func_ptr *assign; /* this field is on the LHS of an assign */
-{
- /*
- * if requesting whole line but some other field has been altered,
- * then the whole line must be rebuilt
- */
- if (requested == 0) {
- if (!field0_valid) {
- /* first, parse remainder of input record */
- if (NF == -1) {
- NF = (*parse_field)(HUGE-1, &parse_extent,
- fields_arr[0]->stlen -
- (parse_extent - fields_arr[0]->stptr),
- save_FS, FS_regexp, set_field,
- (NODE *)NULL);
- parse_high_water = NF;
- }
- rebuild_record();
- }
- if (assign)
- *assign = reset_record;
- return &fields_arr[0];
- }
-
- /* assert(requested > 0); */
-
- if (assign)
- field0_valid = 0; /* $0 needs reconstruction */
-
- if (requested <= parse_high_water) /* already parsed this field */
- return &fields_arr[requested];
-
- if (NF == -1) { /* have not yet parsed to end of record */
- /*
- * parse up to requested fields, calling set_field() for each,
- * saving in parse_extent the point where the parse left off
- */
- if (parse_high_water == 0) /* starting at the beginning */
- parse_extent = fields_arr[0]->stptr;
- parse_high_water = (*parse_field)(requested, &parse_extent,
- fields_arr[0]->stlen - (parse_extent-fields_arr[0]->stptr),
- save_FS, FS_regexp, set_field, (NODE *)NULL);
-
- /*
- * if we reached the end of the record, set NF to the number of
- * fields so far. Note that requested might actually refer to
- * a field that is beyond the end of the record, but we won't
- * set NF to that value at this point, since this is only a
- * reference to the field and NF only gets set if the field
- * is assigned to -- this case is handled below
- */
- if (parse_extent == fields_arr[0]->stptr + fields_arr[0]->stlen)
- NF = parse_high_water;
- if (requested == HUGE-1) /* HUGE-1 means set NF */
- requested = parse_high_water;
- }
- if (parse_high_water < requested) { /* requested beyond end of record */
- if (assign) { /* expand record */
- register int i;
-
- if (requested > nf_high_water)
- grow_fields_arr(requested);
-
- /* fill in fields that don't exist */
- for (i = parse_high_water + 1; i <= requested; i++)
- fields_arr[i] = Nnull_string;
-
- NF = requested;
- parse_high_water = requested;
- } else
- return &Nnull_string;
- }
-
- return &fields_arr[requested];
-}
-
-static void
-set_element(num, s, len, n)
-int num;
-char *s;
-int len;
-NODE *n;
-{
- register NODE *it;
-
- it = make_string(s, len);
- it->flags |= MAYBE_NUM;
- *assoc_lookup(n, tmp_number((AWKNUM) (num))) = it;
-}
-
-NODE *
-do_split(tree)
-NODE *tree;
-{
- NODE *t1, *t2, *t3, *tmp;
- NODE *fs;
- char *s;
- int (*parseit)P((int, char **, int, NODE *,
- Regexp *, void (*)(), NODE *));
- Regexp *rp = NULL;
-
- t1 = tree_eval(tree->lnode);
- t2 = tree->rnode->lnode;
- t3 = tree->rnode->rnode->lnode;
-
- (void) force_string(t1);
-
- if (t2->type == Node_param_list)
- t2 = stack_ptr[t2->param_cnt];
- if (t2->type != Node_var && t2->type != Node_var_array)
- fatal("second argument of split is not a variable");
- assoc_clear(t2);
-
- if (t3->re_flags & FS_DFLT) {
- parseit = parse_field;
- fs = force_string(FS_node->var_value);
- rp = FS_regexp;
- } else {
- tmp = force_string(tree_eval(t3->re_exp));
- if (tmp->stlen == 1) {
- if (tmp->stptr[0] == ' ')
- parseit = def_parse_field;
- else
- parseit = sc_parse_field;
- } else {
- parseit = re_parse_field;
- rp = re_update(t3);
- }
- fs = tmp;
- }
-
- s = t1->stptr;
- tmp = tmp_number((AWKNUM) (*parseit)(HUGE, &s, (int)t1->stlen,
- fs, rp, set_element, t2));
- free_temp(t1);
- free_temp(t3);
- return tmp;
-}
-
-void
-set_FS()
-{
- NODE *tmp = NULL;
- char buf[10];
- NODE *fs;
-
- buf[0] = '\0';
- default_FS = 0;
- if (FS_regexp) {
- refree(FS_regexp);
- FS_regexp = NULL;
- }
- fs = force_string(FS_node->var_value);
- if (fs->stlen > 1)
- parse_field = re_parse_field;
- else if (*RS == 0) {
- parse_field = sc_parse_field;
- if (fs->stlen == 1) {
- if (fs->stptr[0] == ' ') {
- default_FS = 1;
- strcpy(buf, "[ \t\n]+");
- } else if (fs->stptr[0] != '\n')
- sprintf(buf, "[%c\n]", fs->stptr[0]);
- }
- } else {
- parse_field = def_parse_field;
- if (fs->stptr[0] == ' ' && fs->stlen == 1)
- default_FS = 1;
- else if (fs->stptr[0] != ' ' && fs->stlen == 1) {
- if (IGNORECASE == 0)
- parse_field = sc_parse_field;
- else
- sprintf(buf, "[%c]", fs->stptr[0]);
- }
- }
- if (buf[0]) {
- FS_regexp = make_regexp(buf, strlen(buf), IGNORECASE, 1);
- parse_field = re_parse_field;
- } else if (parse_field == re_parse_field) {
- FS_regexp = make_regexp(fs->stptr, fs->stlen, IGNORECASE, 1);
- } else
- FS_regexp = NULL;
- resave_fs = 1;
-}
-
-void
-set_RS()
-{
- (void) force_string(RS_node->var_value);
- RS = RS_node->var_value->stptr;
- set_FS();
-}
-
-void
-set_FIELDWIDTHS()
-{
- register char *scan;
- char *end;
- register int i;
- static int fw_alloc = 1;
- static int warned = 0;
- extern double strtod();
-
- if (do_lint && ! warned) {
- warned = 1;
- warning("use of FIELDWIDTHS is a gawk extension");
- }
- if (do_unix) /* quick and dirty, does the trick */
- return;
-
- parse_field = fw_parse_field;
- scan = force_string(FIELDWIDTHS_node->var_value)->stptr;
- end = scan + 1;
- if (FIELDWIDTHS == NULL)
- emalloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS");
- FIELDWIDTHS[0] = 0;
- for (i = 1; ; i++) {
- if (i >= fw_alloc) {
- fw_alloc *= 2;
- erealloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS");
- }
- FIELDWIDTHS[i] = (int) strtod(scan, &end);
- if (end == scan)
- break;
- scan = end;
- }
- FIELDWIDTHS[i] = -1;
-}
diff --git a/gnu/usr.bin/awk/gawk.texi b/gnu/usr.bin/awk/gawk.texi
deleted file mode 100644
index b280262..0000000
--- a/gnu/usr.bin/awk/gawk.texi
+++ /dev/null
@@ -1,11270 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@c %**start of header (This is for running Texinfo on a region.)
-@setfilename gawk.info
-@settitle The GAWK Manual
-@c @smallbook
-@c %**end of header (This is for running Texinfo on a region.)
-
-@ifinfo
-@synindex fn cp
-@synindex vr cp
-@end ifinfo
-@iftex
-@syncodeindex fn cp
-@syncodeindex vr cp
-@end iftex
-
-@c If "finalout" is commented out, the printed output will show
-@c black boxes that mark lines that are too long. Thus, it is
-@c unwise to comment it out when running a master in case there are
-@c overfulls which are deemed okay.
-
-@iftex
-@finalout
-@end iftex
-
-@c ===> NOTE! <==
-@c Determine the edition number in *four* places by hand:
-@c 1. First ifinfo section 2. title page 3. copyright page 4. top node
-@c To find the locations, search for !!set
-
-@ifinfo
-This file documents @code{awk}, a program that you can use to select
-particular records in a file and perform operations upon them.
-
-This is Edition 0.15 of @cite{The GAWK Manual}, @*
-for the 2.15 version of the GNU implementation @*
-of AWK.
-
-Copyright (C) 1989, 1991, 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 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 odd
-
-@c !!set edition, date, version
-@titlepage
-@title The GAWK Manual
-@subtitle Edition 0.15
-@subtitle April 1993
-@author Diane Barlow Close
-@author Arnold D. Robbins
-@author Paul H. Rubin
-@author Richard Stallman
-
-@c Include the Distribution inside the titlepage environment so
-@c that headings are turned off. Headings on and off do not work.
-
-@page
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
-@sp 2
-
-@c !!set edition, date, version
-This is Edition 0.15 of @cite{The GAWK Manual}, @*
-for the 2.15 version of the GNU implementation @*
-of AWK.
-
-@sp 2
-Published by the Free Software Foundation @*
-675 Massachusetts Avenue @*
-Cambridge, MA 02139 USA @*
-Printed copies are available for $20 each.
-
-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
-
-@ifinfo
-@node Top, Preface, (dir), (dir)
-@comment node-name, next, previous, up
-@top General Introduction
-@c Preface or Licensing nodes should come right after the Top
-@c node, in `unnumbered' sections, then the chapter, `What is gawk'.
-
-This file documents @code{awk}, a program that you can use to select
-particular records in a file and perform operations upon them.
-
-@c !!set edition, date, version
-This is Edition 0.15 of @cite{The GAWK Manual}, @*
-for the 2.15 version of the GNU implementation @*
-of AWK.
-
-@end ifinfo
-
-@menu
-* Preface:: What you can do with @code{awk}; brief history
- and acknowledgements.
-* Copying:: Your right to copy and distribute @code{gawk}.
-* This Manual:: Using this manual.
- Includes sample input files that you can use.
-* Getting Started:: A basic introduction to using @code{awk}.
- How to run an @code{awk} program.
- Command line syntax.
-* Reading Files:: How to read files and manipulate fields.
-* Printing:: How to print using @code{awk}. Describes the
- @code{print} and @code{printf} statements.
- Also describes redirection of output.
-* One-liners:: Short, sample @code{awk} programs.
-* Patterns:: The various types of patterns
- explained in detail.
-* Actions:: The various types of actions are
- introduced here. Describes
- expressions and the various operators in
- detail. Also describes comparison expressions.
-* Expressions:: Expressions are the basic building
- blocks of statements.
-* Statements:: The various control statements are
- described in detail.
-* Arrays:: The description and use of arrays.
- Also includes array-oriented control
- statements.
-* Built-in:: The built-in functions are summarized here.
-* User-defined:: User-defined functions are described in detail.
-* Built-in Variables:: Built-in Variables
-* Command Line:: How to run @code{gawk}.
-* Language History:: The evolution of the @code{awk} language.
-* Installation:: Installing @code{gawk} under
- various operating systems.
-* Gawk Summary:: @code{gawk} Options and Language Summary.
-* Sample Program:: A sample @code{awk} program with a
- complete explanation.
-* Bugs:: Reporting Problems and Bugs.
-* Notes:: Something about the
- implementation of @code{gawk}.
-* Glossary:: An explanation of some unfamiliar terms.
-* Index::
-@end menu
-
-@node Preface, Copying, Top, Top
-@comment node-name, next, previous, up
-@unnumbered Preface
-
-@iftex
-@cindex what is @code{awk}
-@end iftex
-If you are like many computer users, you would frequently like to make
-changes in various text files wherever certain patterns appear, or
-extract data from parts of certain lines while discarding the rest. To
-write a program to do this in a language such as C or Pascal is a
-time-consuming inconvenience that may take many lines of code. The job
-may be easier with @code{awk}.
-
-The @code{awk} utility interprets a special-purpose programming language
-that makes it possible to handle simple data-reformatting jobs easily
-with just a few lines of code.
-
-The GNU implementation of @code{awk} is called @code{gawk}; it is fully
-upward compatible with the System V Release 4 version of
-@code{awk}. @code{gawk} is also upward compatible with the @sc{posix}
-(draft) specification of the @code{awk} language. This means that all
-properly written @code{awk} programs should work with @code{gawk}.
-Thus, we usually don't distinguish between @code{gawk} and other @code{awk}
-implementations in this manual.@refill
-
-@cindex uses of @code{awk}
-This manual teaches you what @code{awk} does and how you can use
-@code{awk} effectively. You should already be familiar with basic
-system commands such as @code{ls}. Using @code{awk} you can: @refill
-
-@itemize @bullet
-@item
-manage small, personal databases
-
-@item
-generate reports
-
-@item
-validate data
-@item
-produce indexes, and perform other document preparation tasks
-
-@item
-even experiment with algorithms that can be adapted later to other computer
-languages
-@end itemize
-
-@iftex
-This manual has the difficult task of being both tutorial and reference.
-If you are a novice, feel free to skip over details that seem too complex.
-You should also ignore the many cross references; they are for the
-expert user, and for the on-line Info version of the manual.
-@end iftex
-
-@menu
-* History:: The history of @code{gawk} and
- @code{awk}. Acknowledgements.
-@end menu
-
-@node History, , Preface, Preface
-@comment node-name, next, previous, up
-@unnumberedsec History of @code{awk} and @code{gawk}
-
-@cindex acronym
-@cindex history of @code{awk}
-The name @code{awk} comes from the initials of its designers: Alfred V.
-Aho, Peter J. Weinberger, and Brian W. Kernighan. The original version of
-@code{awk} was written in 1977. In 1985 a new version made the programming
-language more powerful, introducing user-defined functions, multiple input
-streams, and computed regular expressions.
-This new version became generally available with System V Release 3.1.
-The version in System V Release 4 added some new features and also cleaned
-up the behavior in some of the ``dark corners'' of the language.
-The specification for @code{awk} in the @sc{posix} Command Language
-and Utilities standard further clarified the language based on feedback
-from both the @code{gawk} designers, and the original @code{awk}
-designers.@refill
-
-The GNU implementation, @code{gawk}, was written in 1986 by Paul Rubin
-and Jay Fenlason, with advice from Richard Stallman. John Woods
-contributed parts of the code as well. In 1988 and 1989, David Trueman, with
-help from Arnold Robbins, thoroughly reworked @code{gawk} for compatibility
-with the newer @code{awk}. Current development (1992) focuses on bug fixes,
-performance improvements, and standards compliance.
-
-We need to thank many people for their assistance in producing this
-manual. Jay Fenlason contributed many ideas and sample programs. Richard
-Mlynarik and Robert J. Chassell gave helpful comments on early drafts of this
-manual. The paper @cite{A Supplemental Document for @code{awk}} by John W.
-Pierce of the Chemistry Department at UC San Diego, pinpointed several
-issues relevant both to @code{awk} implementation and to this manual, that
-would otherwise have escaped us. David Trueman, Pat Rankin, and Michal
-Jaegermann also contributed sections of the manual.@refill
-
-The following people provided many helpful comments on this edition of
-the manual: Rick Adams, Michael Brennan, Rich Burridge, Diane Close,
-Christopher (``Topher'') Eliot, Michael Lijewski, Pat Rankin, Miriam Robbins,
-and Michal Jaegermann. Robert J. Chassell provided much valuable advice on
-the use of Texinfo.
-
-Finally, we would like to thank Brian Kernighan of Bell Labs for invaluable
-assistance during the testing and debugging of @code{gawk}, and for
-help in clarifying numerous points about the language.@refill
-
-@node Copying, This Manual, Preface, Top
-@unnumbered 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
-
-@c fakenode --- for prepinfo
-@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
-@c fakenode --- for prepinfo
-@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
-@c fakenode --- for prepinfo
-@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
-@c fakenode --- for prepinfo
-@heading END OF TERMS AND CONDITIONS
-@end iftex
-@ifinfo
-@center END OF TERMS AND CONDITIONS
-@end ifinfo
-
-@page
-@c fakenode --- for prepinfo
-@unnumberedsec 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:
-
-@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 This Manual, Getting Started, Copying, Top
-@chapter Using this Manual
-@cindex manual, using this
-@cindex using this manual
-@cindex language, @code{awk}
-@cindex program, @code{awk}
-@cindex @code{awk} language
-@cindex @code{awk} program
-
-The term @code{awk} refers to a particular program, and to the language you
-use to tell this program what to do. When we need to be careful, we call
-the program ``the @code{awk} utility'' and the language ``the @code{awk}
-language.'' The term @code{gawk} refers to a version of @code{awk} developed
-as part the GNU project. The purpose of this manual is to explain
-both the
-@code{awk} language and how to run the @code{awk} utility.@refill
-
-While concentrating on the features of @code{gawk}, the manual will also
-attempt to describe important differences between @code{gawk} and other
-@code{awk} implementations. In particular, any features that are not
-in the @sc{posix} standard for @code{awk} will be noted. @refill
-
-The term @dfn{@code{awk} program} refers to a program written by you in
-the @code{awk} programming language.@refill
-
-@xref{Getting Started, ,Getting Started with @code{awk}}, for the bare
-essentials you need to know to start using @code{awk}.
-
-Some useful ``one-liners'' are included to give you a feel for the
-@code{awk} language (@pxref{One-liners, ,Useful ``One-liners''}).
-
-@ignore
-@strong{I deleted four paragraphs here because they would confuse the
-beginner more than help him. They mention terms such as ``field,''
-``pattern,'' ``action,'' ``built-in function'' which the beginner
-doesn't know.}
-
-@strong{If you can find a way to introduce several of these concepts here,
-enough to give the reader a map of what is to follow, that might
-be useful. I'm not sure that can be done without taking up more
-space than ought to be used here. There may be no way to win.}
-
-@strong{ADR: I'd like to tackle this in phase 2 of my editing.}
-@end ignore
-
-A sample @code{awk} program has been provided for you
-(@pxref{Sample Program}).@refill
-
-If you find terms that you aren't familiar with, try looking them
-up in the glossary (@pxref{Glossary}).@refill
-
-The entire @code{awk} language is summarized for quick reference in
-@ref{Gawk Summary, ,@code{gawk} Summary}. Look there if you just need
-to refresh your memory about a particular feature.@refill
-
-Most of the time complete @code{awk} programs are used as examples, but in
-some of the more advanced sections, only the part of the @code{awk} program
-that illustrates the concept being described is shown.@refill
-
-@menu
-* Sample Data Files:: Sample data files for use in the @code{awk}
- programs illustrated in this manual.
-@end menu
-
-@node Sample Data Files, , This Manual, This Manual
-@section Data Files for the Examples
-
-@cindex input file, sample
-@cindex sample input file
-@cindex @file{BBS-list} file
-Many of the examples in this manual take their input from two sample
-data files. The first, called @file{BBS-list}, represents a list of
-computer bulletin board systems together with information about those systems.
-The second data file, called @file{inventory-shipped}, contains
-information about shipments on a monthly basis. Each line of these
-files is one @dfn{record}.
-
-In the file @file{BBS-list}, each record contains the name of a computer
-bulletin board, its phone number, the board's baud rate, and a code for
-the number of hours it is operational. An @samp{A} in the last column
-means the board operates 24 hours a day. A @samp{B} in the last
-column means the board operates evening and weekend hours, only. A
-@samp{C} means the board operates only on weekends.
-
-@example
-aardvark 555-5553 1200/300 B
-alpo-net 555-3412 2400/1200/300 A
-barfly 555-7685 1200/300 A
-bites 555-1675 2400/1200/300 A
-camelot 555-0542 300 C
-core 555-2912 1200/300 C
-fooey 555-1234 2400/1200/300 B
-foot 555-6699 1200/300 B
-macfoo 555-6480 1200/300 A
-sdace 555-3430 2400/1200/300 A
-sabafoo 555-2127 1200/300 C
-@end example
-
-@cindex @file{inventory-shipped} file
-The second data file, called @file{inventory-shipped}, represents
-information about shipments during the year.
-Each record contains the month of the year, the number
-of green crates shipped, the number of red boxes shipped, the number of
-orange bags shipped, and the number of blue packages shipped,
-respectively. There are 16 entries, covering the 12 months of one year
-and 4 months of the next year.@refill
-
-@example
-Jan 13 25 15 115
-Feb 15 32 24 226
-Mar 15 24 34 228
-Apr 31 52 63 420
-May 16 34 29 208
-Jun 31 42 75 492
-Jul 24 34 67 436
-Aug 15 34 47 316
-Sep 13 55 37 277
-Oct 29 54 68 525
-Nov 20 87 82 577
-Dec 17 35 61 401
-
-Jan 21 36 64 620
-Feb 26 58 80 652
-Mar 24 75 70 495
-Apr 21 70 74 514
-@end example
-
-@ifinfo
-If you are reading this in GNU Emacs using Info, you can copy the regions
-of text showing these sample files into your own test files. This way you
-can try out the examples shown in the remainder of this document. You do
-this by using the command @kbd{M-x write-region} to copy text from the Info
-file into a file for use with @code{awk}
-(@xref{Misc File Ops, , , emacs, GNU Emacs Manual},
-for more information). Using this information, create your own
-@file{BBS-list} and @file{inventory-shipped} files, and practice what you
-learn in this manual.
-@end ifinfo
-
-@node Getting Started, Reading Files, This Manual, Top
-@chapter Getting Started with @code{awk}
-@cindex script, definition of
-@cindex rule, definition of
-@cindex program, definition of
-@cindex basic function of @code{gawk}
-
-The basic function of @code{awk} is to search files for lines (or other
-units of text) that contain certain patterns. When a line matches one
-of the patterns, @code{awk} performs specified actions on that line.
-@code{awk} keeps processing input lines in this way until the end of the
-input file is reached.@refill
-
-When you run @code{awk}, you specify an @code{awk} @dfn{program} which
-tells @code{awk} what to do. The program consists of a series of
-@dfn{rules}. (It may also contain @dfn{function definitions}, but that
-is an advanced feature, so we will ignore it for now.
-@xref{User-defined, ,User-defined Functions}.) Each rule specifies one
-pattern to search for, and one action to perform when that pattern is found.
-
-Syntactically, a rule consists of a pattern followed by an action. The
-action is enclosed in curly braces to separate it from the pattern.
-Rules are usually separated by newlines. Therefore, an @code{awk}
-program looks like this:
-
-@example
-@var{pattern} @{ @var{action} @}
-@var{pattern} @{ @var{action} @}
-@dots{}
-@end example
-
-@menu
-* Very Simple:: A very simple example.
-* Two Rules:: A less simple one-line example with two rules.
-* More Complex:: A more complex example.
-* Running gawk:: How to run @code{gawk} programs;
- includes command line syntax.
-* Comments:: Adding documentation to @code{gawk} programs.
-* Statements/Lines:: Subdividing or combining statements into lines.
-* When:: When to use @code{gawk} and
- when to use other things.
-@end menu
-
-@node Very Simple, Two Rules, Getting Started, Getting Started
-@section A Very Simple Example
-
-@cindex @samp{print $0}
-The following command runs a simple @code{awk} program that searches the
-input file @file{BBS-list} for the string of characters: @samp{foo}. (A
-string of characters is usually called, a @dfn{string}.
-The term @dfn{string} is perhaps based on similar usage in English, such
-as ``a string of pearls,'' or, ``a string of cars in a train.'')
-
-@example
-awk '/foo/ @{ print $0 @}' BBS-list
-@end example
-
-@noindent
-When lines containing @samp{foo} are found, they are printed, because
-@w{@samp{print $0}} means print the current line. (Just @samp{print} by
-itself means the same thing, so we could have written that
-instead.)
-
-You will notice that slashes, @samp{/}, surround the string @samp{foo}
-in the actual @code{awk} program. The slashes indicate that @samp{foo}
-is a pattern to search for. This type of pattern is called a
-@dfn{regular expression}, and is covered in more detail later
-(@pxref{Regexp, ,Regular Expressions as Patterns}). There are
-single-quotes around the @code{awk} program so that the shell won't
-interpret any of it as special shell characters.@refill
-
-Here is what this program prints:
-
-@example
-@group
-fooey 555-1234 2400/1200/300 B
-foot 555-6699 1200/300 B
-macfoo 555-6480 1200/300 A
-sabafoo 555-2127 1200/300 C
-@end group
-@end example
-
-@cindex action, default
-@cindex pattern, default
-@cindex default action
-@cindex default pattern
-In an @code{awk} rule, either the pattern or the action can be omitted,
-but not both. If the pattern is omitted, then the action is performed
-for @emph{every} input line. If the action is omitted, the default
-action is to print all lines that match the pattern.
-
-Thus, we could leave out the action (the @code{print} statement and the curly
-braces) in the above example, and the result would be the same: all
-lines matching the pattern @samp{foo} would be printed. By comparison,
-omitting the @code{print} statement but retaining the curly braces makes an
-empty action that does nothing; then no lines would be printed.
-
-@node Two Rules, More Complex, Very Simple, Getting Started
-@section An Example with Two Rules
-@cindex how @code{awk} works
-
-The @code{awk} utility reads the input files one line at a
-time. For each line, @code{awk} tries the patterns of each of the rules.
-If several patterns match then several actions are run, in the order in
-which they appear in the @code{awk} program. If no patterns match, then
-no actions are run.
-
-After processing all the rules (perhaps none) that match the line,
-@code{awk} reads the next line (however,
-@pxref{Next Statement, ,The @code{next} Statement}). This continues
-until the end of the file is reached.@refill
-
-For example, the @code{awk} program:
-
-@example
-/12/ @{ print $0 @}
-/21/ @{ print $0 @}
-@end example
-
-@noindent
-contains two rules. The first rule has the string @samp{12} as the
-pattern and @samp{print $0} as the action. The second rule has the
-string @samp{21} as the pattern and also has @samp{print $0} as the
-action. Each rule's action is enclosed in its own pair of braces.
-
-This @code{awk} program prints every line that contains the string
-@samp{12} @emph{or} the string @samp{21}. If a line contains both
-strings, it is printed twice, once by each rule.
-
-If we run this program on our two sample data files, @file{BBS-list} and
-@file{inventory-shipped}, as shown here:
-
-@example
-awk '/12/ @{ print $0 @}
- /21/ @{ print $0 @}' BBS-list inventory-shipped
-@end example
-
-@noindent
-we get the following output:
-
-@example
-aardvark 555-5553 1200/300 B
-alpo-net 555-3412 2400/1200/300 A
-barfly 555-7685 1200/300 A
-bites 555-1675 2400/1200/300 A
-core 555-2912 1200/300 C
-fooey 555-1234 2400/1200/300 B
-foot 555-6699 1200/300 B
-macfoo 555-6480 1200/300 A
-sdace 555-3430 2400/1200/300 A
-sabafoo 555-2127 1200/300 C
-sabafoo 555-2127 1200/300 C
-Jan 21 36 64 620
-Apr 21 70 74 514
-@end example
-
-@noindent
-Note how the line in @file{BBS-list} beginning with @samp{sabafoo}
-was printed twice, once for each rule.
-
-@node More Complex, Running gawk, Two Rules, Getting Started
-@comment node-name, next, previous, up
-@section A More Complex Example
-
-Here is an example to give you an idea of what typical @code{awk}
-programs do. This example shows how @code{awk} can be used to
-summarize, select, and rearrange the output of another utility. It uses
-features that haven't been covered yet, so don't worry if you don't
-understand all the details.
-
-@example
-ls -l | awk '$5 == "Nov" @{ sum += $4 @}
- END @{ print sum @}'
-@end example
-
-This command prints the total number of bytes in all the files in the
-current directory that were last modified in November (of any year).
-(In the C shell you would need to type a semicolon and then a backslash
-at the end of the first line; in a @sc{posix}-compliant shell, such as the
-Bourne shell or the Bourne-Again shell, you can type the example as shown.)
-
-The @w{@samp{ls -l}} part of this example is a command that gives you a
-listing of the files in a directory, including file size and date.
-Its output looks like this:@refill
-
-@example
--rw-r--r-- 1 close 1933 Nov 7 13:05 Makefile
--rw-r--r-- 1 close 10809 Nov 7 13:03 gawk.h
--rw-r--r-- 1 close 983 Apr 13 12:14 gawk.tab.h
--rw-r--r-- 1 close 31869 Jun 15 12:20 gawk.y
--rw-r--r-- 1 close 22414 Nov 7 13:03 gawk1.c
--rw-r--r-- 1 close 37455 Nov 7 13:03 gawk2.c
--rw-r--r-- 1 close 27511 Dec 9 13:07 gawk3.c
--rw-r--r-- 1 close 7989 Nov 7 13:03 gawk4.c
-@end example
-
-@noindent
-The first field contains read-write permissions, the second field contains
-the number of links to the file, and the third field identifies the owner of
-the file. The fourth field contains the size of the file in bytes. The
-fifth, sixth, and seventh fields contain the month, day, and time,
-respectively, that the file was last modified. Finally, the eighth field
-contains the name of the file.
-
-The @code{$5 == "Nov"} in our @code{awk} program is an expression that
-tests whether the fifth field of the output from @w{@samp{ls -l}}
-matches the string @samp{Nov}. Each time a line has the string
-@samp{Nov} in its fifth field, the action @samp{@{ sum += $4 @}} is
-performed. This adds the fourth field (the file size) to the variable
-@code{sum}. As a result, when @code{awk} has finished reading all the
-input lines, @code{sum} is the sum of the sizes of files whose
-lines matched the pattern. (This works because @code{awk} variables
-are automatically initialized to zero.)@refill
-
-After the last line of output from @code{ls} has been processed, the
-@code{END} rule is executed, and the value of @code{sum} is
-printed. In this example, the value of @code{sum} would be 80600.@refill
-
-These more advanced @code{awk} techniques are covered in later sections
-(@pxref{Actions, ,Overview of Actions}). Before you can move on to more
-advanced @code{awk} programming, you have to know how @code{awk} interprets
-your input and displays your output. By manipulating fields and using
-@code{print} statements, you can produce some very useful and spectacular
-looking reports.@refill
-
-@node Running gawk, Comments, More Complex, Getting Started
-@section How to Run @code{awk} Programs
-
-@ignore
-Date: Mon, 26 Aug 91 09:48:10 +0200
-From: gatech!vsoc07.cern.ch!matheys (Jean-Pol Matheys (CERN - ECP Division))
-To: uunet.UU.NET!skeeve!arnold
-Subject: RE: status check
-
-The introduction of Chapter 2 (i.e. before 2.1) should include
-the whole of section 2.4 - it's better to tell people how to run awk programs
-before giving any examples
-
-ADR --- he's right. but for now, don't do this because the rest of the
-chapter would need some rewriting.
-@end ignore
-
-@cindex command line formats
-@cindex running @code{awk} programs
-There are several ways to run an @code{awk} program. If the program is
-short, it is easiest to include it in the command that runs @code{awk},
-like this:
-
-@example
-awk '@var{program}' @var{input-file1} @var{input-file2} @dots{}
-@end example
-
-@noindent
-where @var{program} consists of a series of patterns and actions, as
-described earlier.
-
-When the program is long, it is usually more convenient to put it in a file
-and run it with a command like this:
-
-@example
-awk -f @var{program-file} @var{input-file1} @var{input-file2} @dots{}
-@end example
-
-@menu
-* One-shot:: Running a short throw-away @code{awk} program.
-* Read Terminal:: Using no input files (input from
- terminal instead).
-* Long:: Putting permanent @code{awk} programs in files.
-* Executable Scripts:: Making self-contained @code{awk} programs.
-@end menu
-
-@node One-shot, Read Terminal, Running gawk, Running gawk
-@subsection One-shot Throw-away @code{awk} Programs
-
-Once you are familiar with @code{awk}, you will often type simple
-programs at the moment you want to use them. Then you can write the
-program as the first argument of the @code{awk} command, like this:
-
-@example
-awk '@var{program}' @var{input-file1} @var{input-file2} @dots{}
-@end example
-
-@noindent
-where @var{program} consists of a series of @var{patterns} and
-@var{actions}, as described earlier.
-
-@cindex single quotes, why needed
-This command format instructs the shell to start @code{awk} and use the
-@var{program} to process records in the input file(s). There are single
-quotes around @var{program} so that the shell doesn't interpret any
-@code{awk} characters as special shell characters. They also cause the
-shell to treat all of @var{program} as a single argument for
-@code{awk} and allow @var{program} to be more than one line long.@refill
-
-This format is also useful for running short or medium-sized @code{awk}
-programs from shell scripts, because it avoids the need for a separate
-file for the @code{awk} program. A self-contained shell script is more
-reliable since there are no other files to misplace.
-
-@node Read Terminal, Long, One-shot, Running gawk
-@subsection Running @code{awk} without Input Files
-
-@cindex standard input
-@cindex input, standard
-You can also run @code{awk} without any input files. If you type the
-command line:@refill
-
-@example
-awk '@var{program}'
-@end example
-
-@noindent
-then @code{awk} applies the @var{program} to the @dfn{standard input},
-which usually means whatever you type on the terminal. This continues
-until you indicate end-of-file by typing @kbd{Control-d}.
-
-For example, if you execute this command:
-
-@example
-awk '/th/'
-@end example
-
-@noindent
-whatever you type next is taken as data for that @code{awk}
-program. If you go on to type the following data:
-
-@example
-Kathy
-Ben
-Tom
-Beth
-Seth
-Karen
-Thomas
-@kbd{Control-d}
-@end example
-
-@noindent
-then @code{awk} prints this output:
-
-@example
-Kathy
-Beth
-Seth
-@end example
-
-@noindent
-@cindex case sensitivity
-@cindex pattern, case sensitive
-as matching the pattern @samp{th}. Notice that it did not recognize
-@samp{Thomas} as matching the pattern. The @code{awk} language is
-@dfn{case sensitive}, and matches patterns exactly. (However, you can
-override this with the variable @code{IGNORECASE}.
-@xref{Case-sensitivity, ,Case-sensitivity in Matching}.)
-
-@node Long, Executable Scripts, Read Terminal, Running gawk
-@subsection Running Long Programs
-
-@cindex running long programs
-@cindex @samp{-f} option
-@cindex program file
-@cindex file, @code{awk} program
-Sometimes your @code{awk} programs can be very long. In this case it is
-more convenient to put the program into a separate file. To tell
-@code{awk} to use that file for its program, you type:@refill
-
-@example
-awk -f @var{source-file} @var{input-file1} @var{input-file2} @dots{}
-@end example
-
-The @samp{-f} instructs the @code{awk} utility to get the @code{awk} program
-from the file @var{source-file}. Any file name can be used for
-@var{source-file}. For example, you could put the program:@refill
-
-@example
-/th/
-@end example
-
-@noindent
-into the file @file{th-prog}. Then this command:
-
-@example
-awk -f th-prog
-@end example
-
-@noindent
-does the same thing as this one:
-
-@example
-awk '/th/'
-@end example
-
-@noindent
-which was explained earlier (@pxref{Read Terminal, ,Running @code{awk} without Input Files}).
-Note that you don't usually need single quotes around the file name that you
-specify with @samp{-f}, because most file names don't contain any of the shell's
-special characters. Notice that in @file{th-prog}, the @code{awk}
-program did not have single quotes around it. The quotes are only needed
-for programs that are provided on the @code{awk} command line.
-
-If you want to identify your @code{awk} program files clearly as such,
-you can add the extension @file{.awk} to the file name. This doesn't
-affect the execution of the @code{awk} program, but it does make
-``housekeeping'' easier.
-
-@node Executable Scripts, , Long, Running gawk
-@c node-name, next, previous, up
-@subsection Executable @code{awk} Programs
-@cindex executable scripts
-@cindex scripts, executable
-@cindex self contained programs
-@cindex program, self contained
-@cindex @samp{#!}
-
-Once you have learned @code{awk}, you may want to write self-contained
-@code{awk} scripts, using the @samp{#!} script mechanism. You can do
-this on many Unix systems @footnote{The @samp{#!} mechanism works on
-Unix systems derived from Berkeley Unix, System V Release 4, and some System
-V Release 3 systems.} (and someday on GNU).@refill
-
-For example, you could create a text file named @file{hello}, containing
-the following (where @samp{BEGIN} is a feature we have not yet
-discussed):
-
-@example
-#! /bin/awk -f
-
-# a sample awk program
-BEGIN @{ print "hello, world" @}
-@end example
-
-@noindent
-After making this file executable (with the @code{chmod} command), you
-can simply type:
-
-@example
-hello
-@end example
-
-@noindent
-at the shell, and the system will arrange to run @code{awk} @footnote{The
-line beginning with @samp{#!} lists the full pathname of an interpreter
-to be run, and an optional initial command line argument to pass to that
-interpreter. The operating system then runs the interpreter with the given
-argument and the full argument list of the executed program. The first argument
-in the list is the full pathname of the @code{awk} program. The rest of the
-argument list will either be options to @code{awk}, or data files,
-or both.} as if you had typed:@refill
-
-@example
-awk -f hello
-@end example
-
-@noindent
-Self-contained @code{awk} scripts are useful when you want to write a
-program which users can invoke without knowing that the program is
-written in @code{awk}.
-
-@cindex shell scripts
-@cindex scripts, shell
-If your system does not support the @samp{#!} mechanism, you can get a
-similar effect using a regular shell script. It would look something
-like this:
-
-@example
-: The colon makes sure this script is executed by the Bourne shell.
-awk '@var{program}' "$@@"
-@end example
-
-Using this technique, it is @emph{vital} to enclose the @var{program} in
-single quotes to protect it from interpretation by the shell. If you
-omit the quotes, only a shell wizard can predict the results.
-
-The @samp{"$@@"} causes the shell to forward all the command line
-arguments to the @code{awk} program, without interpretation. The first
-line, which starts with a colon, is used so that this shell script will
-work even if invoked by a user who uses the C shell.
-@c Someday: (See @cite{The Bourne Again Shell}, by ??.)
-
-@node Comments, Statements/Lines, Running gawk, Getting Started
-@section Comments in @code{awk} Programs
-@cindex @samp{#}
-@cindex comments
-@cindex use of comments
-@cindex documenting @code{awk} programs
-@cindex programs, documenting
-
-A @dfn{comment} is some text that is included in a program for the sake
-of human readers, and that is not really part of the program. Comments
-can explain what the program does, and how it works. Nearly all
-programming languages have provisions for comments, because programs are
-typically hard to understand without their extra help.
-
-In the @code{awk} language, a comment starts with the sharp sign
-character, @samp{#}, and continues to the end of the line. The
-@code{awk} language ignores the rest of a line following a sharp sign.
-For example, we could have put the following into @file{th-prog}:@refill
-
-@smallexample
-# This program finds records containing the pattern @samp{th}. This is how
-# you continue comments on additional lines.
-/th/
-@end smallexample
-
-You can put comment lines into keyboard-composed throw-away @code{awk}
-programs also, but this usually isn't very useful; the purpose of a
-comment is to help you or another person understand the program at
-a later time.@refill
-
-@node Statements/Lines, When, Comments, Getting Started
-@section @code{awk} Statements versus Lines
-
-Most often, each line in an @code{awk} program is a separate statement or
-separate rule, like this:
-
-@example
-awk '/12/ @{ print $0 @}
- /21/ @{ print $0 @}' BBS-list inventory-shipped
-@end example
-
-But sometimes statements can be more than one line, and lines can
-contain several statements. You can split a statement into multiple
-lines by inserting a newline after any of the following:@refill
-
-@example
-, @{ ? : || && do else
-@end example
-
-@noindent
-A newline at any other point is considered the end of the statement.
-(Splitting lines after @samp{?} and @samp{:} is a minor @code{gawk}
-extension. The @samp{?} and @samp{:} referred to here is the
-three operand conditional expression described in
-@ref{Conditional Exp, ,Conditional Expressions}.)@refill
-
-@cindex backslash continuation
-@cindex continuation of lines
-If you would like to split a single statement into two lines at a point
-where a newline would terminate it, you can @dfn{continue} it by ending the
-first line with a backslash character, @samp{\}. This is allowed
-absolutely anywhere in the statement, even in the middle of a string or
-regular expression. For example:
-
-@example
-awk '/This program is too long, so continue it\
- on the next line/ @{ print $1 @}'
-@end example
-
-@noindent
-We have generally not used backslash continuation in the sample programs in
-this manual. Since in @code{gawk} there is no limit on the length of a line,
-it is never strictly necessary; it just makes programs prettier. We have
-preferred to make them even more pretty by keeping the statements short.
-Backslash continuation is most useful when your @code{awk} program is in a
-separate source file, instead of typed in on the command line. You should
-also note that many @code{awk} implementations are more picky about where
-you may use backslash continuation. For maximal portability of your @code{awk}
-programs, it is best not to split your lines in the middle of a regular
-expression or a string.@refill
-
-@strong{Warning: backslash continuation does not work as described above
-with the C shell.} Continuation with backslash works for @code{awk}
-programs in files, and also for one-shot programs @emph{provided} you
-are using a @sc{posix}-compliant shell, such as the Bourne shell or the
-Bourne-again shell. But the C shell used on Berkeley Unix behaves
-differently! There, you must use two backslashes in a row, followed by
-a newline.@refill
-
-@cindex multiple statements on one line
-When @code{awk} statements within one rule are short, you might want to put
-more than one of them on a line. You do this by separating the statements
-with a semicolon, @samp{;}.
-This also applies to the rules themselves.
-Thus, the previous program could have been written:@refill
-
-@example
-/12/ @{ print $0 @} ; /21/ @{ print $0 @}
-@end example
-
-@noindent
-@strong{Note:} the requirement that rules on the same line must be
-separated with a semicolon is a recent change in the @code{awk}
-language; it was done for consistency with the treatment of statements
-within an action.
-
-@node When, , Statements/Lines, Getting Started
-@section When to Use @code{awk}
-
-@cindex when to use @code{awk}
-@cindex applications of @code{awk}
-You might wonder how @code{awk} might be useful for you. Using additional
-utility programs, more advanced patterns, field separators, arithmetic
-statements, and other selection criteria, you can produce much more
-complex output. The @code{awk} language is very useful for producing
-reports from large amounts of raw data, such as summarizing information
-from the output of other utility programs like @code{ls}.
-(@xref{More Complex, ,A More Complex Example}.)
-
-Programs written with @code{awk} are usually much smaller than they would
-be in other languages. This makes @code{awk} programs easy to compose and
-use. Often @code{awk} programs can be quickly composed at your terminal,
-used once, and thrown away. Since @code{awk} programs are interpreted, you
-can avoid the usually lengthy edit-compile-test-debug cycle of software
-development.
-
-Complex programs have been written in @code{awk}, including a complete
-retargetable assembler for 8-bit microprocessors (@pxref{Glossary}, for
-more information) and a microcode assembler for a special purpose Prolog
-computer. However, @code{awk}'s capabilities are strained by tasks of
-such complexity.
-
-If you find yourself writing @code{awk} scripts of more than, say, a few
-hundred lines, you might consider using a different programming
-language. Emacs Lisp is a good choice if you need sophisticated string
-or pattern matching capabilities. The shell is also good at string and
-pattern matching; in addition, it allows powerful use of the system
-utilities. More conventional languages, such as C, C++, and Lisp, offer
-better facilities for system programming and for managing the complexity
-of large programs. Programs in these languages may require more lines
-of source code than the equivalent @code{awk} programs, but they are
-easier to maintain and usually run more efficiently.@refill
-
-@node Reading Files, Printing, Getting Started, Top
-@chapter Reading Input Files
-
-@cindex reading files
-@cindex input
-@cindex standard input
-@vindex FILENAME
-In the typical @code{awk} program, all input is read either from the
-standard input (by default the keyboard, but often a pipe from another
-command) or from files whose names you specify on the @code{awk} command
-line. If you specify input files, @code{awk} reads them in order, reading
-all the data from one before going on to the next. The name of the current
-input file can be found in the built-in variable @code{FILENAME}
-(@pxref{Built-in Variables}).@refill
-
-The input is read in units called records, and processed by the
-rules one record at a time. By default, each record is one line. Each
-record is split automatically into fields, to make it more
-convenient for a rule to work on its parts.
-
-On rare occasions you will need to use the @code{getline} command,
-which can do explicit input from any number of files
-(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill
-
-@menu
-* Records:: Controlling how data is split into records.
-* Fields:: An introduction to fields.
-* Non-Constant Fields:: Non-constant Field Numbers.
-* Changing Fields:: Changing the Contents of a Field.
-* Field Separators:: The field separator and how to change it.
-* Constant Size:: Reading constant width data.
-* Multiple Line:: Reading multi-line records.
-* Getline:: Reading files under explicit program control
- using the @code{getline} function.
-* Close Input:: Closing an input file (so you can read from
- the beginning once more).
-@end menu
-
-@node Records, Fields, Reading Files, Reading Files
-@section How Input is Split into Records
-
-@cindex record separator
-The @code{awk} language divides its input into records and fields.
-Records are separated by a character called the @dfn{record separator}.
-By default, the record separator is the newline character, defining
-a record to be a single line of text.@refill
-
-@iftex
-@cindex changing the record separator
-@end iftex
-@vindex RS
-Sometimes you may want to use a different character to separate your
-records. You can use a different character by changing the built-in
-variable @code{RS}. The value of @code{RS} is a string that says how
-to separate records; the default value is @code{"\n"}, the string containing
-just a newline character. This is why records are, by default, single lines.
-
-@code{RS} can have any string as its value, but only the first character
-of the string is used as the record separator. The other characters are
-ignored. @code{RS} is exceptional in this regard; @code{awk} uses the
-full value of all its other built-in variables.@refill
-
-@ignore
-Someday this should be true!
-
-The value of @code{RS} is not limited to a one-character string. It can
-be any regular expression (@pxref{Regexp, ,Regular Expressions as Patterns}).
-In general, each record
-ends at the next string that matches the regular expression; the next
-record starts at the end of the matching string. This general rule is
-actually at work in the usual case, where @code{RS} contains just a
-newline: a record ends at the beginning of the next matching string (the
-next newline in the input) and the following record starts just after
-the end of this string (at the first character of the following line).
-The newline, since it matches @code{RS}, is not part of either record.@refill
-@end ignore
-
-You can change the value of @code{RS} in the @code{awk} program with the
-assignment operator, @samp{=} (@pxref{Assignment Ops, ,Assignment Expressions}).
-The new record-separator character should be enclosed in quotation marks to make
-a string constant. Often the right time to do this is at the beginning
-of execution, before any input has been processed, so that the very
-first record will be read with the proper separator. To do this, use
-the special @code{BEGIN} pattern
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}). For
-example:@refill
-
-@example
-awk 'BEGIN @{ RS = "/" @} ; @{ print $0 @}' BBS-list
-@end example
-
-@noindent
-changes the value of @code{RS} to @code{"/"}, before reading any input.
-This is a string whose first character is a slash; as a result, records
-are separated by slashes. Then the input file is read, and the second
-rule in the @code{awk} program (the action with no pattern) prints each
-record. Since each @code{print} statement adds a newline at the end of
-its output, the effect of this @code{awk} program is to copy the input
-with each slash changed to a newline.
-
-Another way to change the record separator is on the command line,
-using the variable-assignment feature
-(@pxref{Command Line, ,Invoking @code{awk}}).@refill
-
-@example
-awk '@{ print $0 @}' RS="/" BBS-list
-@end example
-
-@noindent
-This sets @code{RS} to @samp{/} before processing @file{BBS-list}.
-
-Reaching the end of an input file terminates the current input record,
-even if the last character in the file is not the character in @code{RS}.
-
-@ignore
-@c merge the preceding paragraph and this stuff into one paragraph
-@c and put it in an `expert info' section.
-This produces correct behavior in the vast majority of cases, although
-the following (extreme) pipeline prints a surprising @samp{1}. (There
-is one field, consisting of a newline.)
-
-@example
-echo | awk 'BEGIN @{ RS = "a" @} ; @{ print NF @}'
-@end example
-
-@end ignore
-
-The empty string, @code{""} (a string of no characters), has a special meaning
-as the value of @code{RS}: it means that records are separated only
-by blank lines. @xref{Multiple Line, ,Multiple-Line Records}, for more details.
-
-@cindex number of records, @code{NR} or @code{FNR}
-@vindex NR
-@vindex FNR
-The @code{awk} utility keeps track of the number of records that have
-been read so far from the current input file. This value is stored in a
-built-in variable called @code{FNR}. It is reset to zero when a new
-file is started. Another built-in variable, @code{NR}, is the total
-number of input records read so far from all files. It starts at zero
-but is never automatically reset to zero.
-
-If you change the value of @code{RS} in the middle of an @code{awk} run,
-the new value is used to delimit subsequent records, but the record
-currently being processed (and records already processed) are not
-affected.
-
-@node Fields, Non-Constant Fields, Records, Reading Files
-@section Examining Fields
-
-@cindex examining fields
-@cindex fields
-@cindex accessing fields
-When @code{awk} reads an input record, the record is
-automatically separated or @dfn{parsed} by the interpreter into chunks
-called @dfn{fields}. By default, fields are separated by whitespace,
-like words in a line.
-Whitespace in @code{awk} means any string of one or more spaces and/or
-tabs; other characters such as newline, formfeed, and so on, that are
-considered whitespace by other languages are @emph{not} considered
-whitespace by @code{awk}.@refill
-
-The purpose of fields is to make it more convenient for you to refer to
-these pieces of the record. You don't have to use them---you can
-operate on the whole record if you wish---but fields are what make
-simple @code{awk} programs so powerful.
-
-@cindex @code{$} (field operator)
-@cindex operators, @code{$}
-To refer to a field in an @code{awk} program, you use a dollar-sign,
-@samp{$}, followed by the number of the field you want. Thus, @code{$1}
-refers to the first field, @code{$2} to the second, and so on. For
-example, suppose the following is a line of input:@refill
-
-@example
-This seems like a pretty nice example.
-@end example
-
-@noindent
-Here the first field, or @code{$1}, is @samp{This}; the second field, or
-@code{$2}, is @samp{seems}; and so on. Note that the last field,
-@code{$7}, is @samp{example.}. Because there is no space between the
-@samp{e} and the @samp{.}, the period is considered part of the seventh
-field.@refill
-
-No matter how many fields there are, the last field in a record can be
-represented by @code{$NF}. So, in the example above, @code{$NF} would
-be the same as @code{$7}, which is @samp{example.}. Why this works is
-explained below (@pxref{Non-Constant Fields, ,Non-constant Field Numbers}).
-If you try to refer to a field beyond the last one, such as @code{$8}
-when the record has only 7 fields, you get the empty string.@refill
-
-@vindex NF
-@cindex number of fields, @code{NF}
-Plain @code{NF}, with no @samp{$}, is a built-in variable whose value
-is the number of fields in the current record.
-
-@code{$0}, which looks like an attempt to refer to the zeroth field, is
-a special case: it represents the whole input record. This is what you
-would use if you weren't interested in fields.
-
-Here are some more examples:
-
-@example
-awk '$1 ~ /foo/ @{ print $0 @}' BBS-list
-@end example
-
-@noindent
-This example prints each record in the file @file{BBS-list} whose first
-field contains the string @samp{foo}. The operator @samp{~} is called a
-@dfn{matching operator} (@pxref{Comparison Ops, ,Comparison Expressions});
-it tests whether a string (here, the field @code{$1}) matches a given regular
-expression.@refill
-
-By contrast, the following example:
-
-@example
-awk '/foo/ @{ print $1, $NF @}' BBS-list
-@end example
-
-@noindent
-looks for @samp{foo} in @emph{the entire record} and prints the first
-field and the last field for each input record containing a
-match.@refill
-
-@node Non-Constant Fields, Changing Fields, Fields, Reading Files
-@section Non-constant Field Numbers
-
-The number of a field does not need to be a constant. Any expression in
-the @code{awk} language can be used after a @samp{$} to refer to a
-field. The value of the expression specifies the field number. If the
-value is a string, rather than a number, it is converted to a number.
-Consider this example:@refill
-
-@example
-awk '@{ print $NR @}'
-@end example
-
-@noindent
-Recall that @code{NR} is the number of records read so far: 1 in the
-first record, 2 in the second, etc. So this example prints the first
-field of the first record, the second field of the second record, and so
-on. For the twentieth record, field number 20 is printed; most likely,
-the record has fewer than 20 fields, so this prints a blank line.
-
-Here is another example of using expressions as field numbers:
-
-@example
-awk '@{ print $(2*2) @}' BBS-list
-@end example
-
-The @code{awk} language must evaluate the expression @code{(2*2)} and use
-its value as the number of the field to print. The @samp{*} sign
-represents multiplication, so the expression @code{2*2} evaluates to 4.
-The parentheses are used so that the multiplication is done before the
-@samp{$} operation; they are necessary whenever there is a binary
-operator in the field-number expression. This example, then, prints the
-hours of operation (the fourth field) for every line of the file
-@file{BBS-list}.@refill
-
-If the field number you compute is zero, you get the entire record.
-Thus, @code{$(2-2)} has the same value as @code{$0}. Negative field
-numbers are not allowed.
-
-The number of fields in the current record is stored in the built-in
-variable @code{NF} (@pxref{Built-in Variables}). The expression
-@code{$NF} is not a special feature: it is the direct consequence of
-evaluating @code{NF} and using its value as a field number.
-
-@node Changing Fields, Field Separators, Non-Constant Fields, Reading Files
-@section Changing the Contents of a Field
-
-@cindex field, changing contents of
-@cindex changing contents of a field
-@cindex assignment to fields
-You can change the contents of a field as seen by @code{awk} within an
-@code{awk} program; this changes what @code{awk} perceives as the
-current input record. (The actual input is untouched: @code{awk} never
-modifies the input file.)
-
-Consider this example:
-
-@smallexample
-awk '@{ $3 = $2 - 10; print $2, $3 @}' inventory-shipped
-@end smallexample
-
-@noindent
-The @samp{-} sign represents subtraction, so this program reassigns
-field three, @code{$3}, to be the value of field two minus ten,
-@code{$2 - 10}. (@xref{Arithmetic Ops, ,Arithmetic Operators}.)
-Then field two, and the new value for field three, are printed.
-
-In order for this to work, the text in field @code{$2} must make sense
-as a number; the string of characters must be converted to a number in
-order for the computer to do arithmetic on it. The number resulting
-from the subtraction is converted back to a string of characters which
-then becomes field three.
-@xref{Conversion, ,Conversion of Strings and Numbers}.@refill
-
-When you change the value of a field (as perceived by @code{awk}), the
-text of the input record is recalculated to contain the new field where
-the old one was. Therefore, @code{$0} changes to reflect the altered
-field. Thus,
-
-@smallexample
-awk '@{ $2 = $2 - 10; print $0 @}' inventory-shipped
-@end smallexample
-
-@noindent
-prints a copy of the input file, with 10 subtracted from the second
-field of each line.
-
-You can also assign contents to fields that are out of range. For
-example:
-
-@smallexample
-awk '@{ $6 = ($5 + $4 + $3 + $2) ; print $6 @}' inventory-shipped
-@end smallexample
-
-@noindent
-We've just created @code{$6}, whose value is the sum of fields
-@code{$2}, @code{$3}, @code{$4}, and @code{$5}. The @samp{+} sign
-represents addition. For the file @file{inventory-shipped}, @code{$6}
-represents the total number of parcels shipped for a particular month.
-
-Creating a new field changes the internal @code{awk} copy of the current
-input record---the value of @code{$0}. Thus, if you do @samp{print $0}
-after adding a field, the record printed includes the new field, with
-the appropriate number of field separators between it and the previously
-existing fields.
-
-This recomputation affects and is affected by several features not yet
-discussed, in particular, the @dfn{output field separator}, @code{OFS},
-which is used to separate the fields (@pxref{Output Separators}), and
-@code{NF} (the number of fields; @pxref{Fields, ,Examining Fields}).
-For example, the value of @code{NF} is set to the number of the highest
-field you create.@refill
-
-Note, however, that merely @emph{referencing} an out-of-range field
-does @emph{not} change the value of either @code{$0} or @code{NF}.
-Referencing an out-of-range field merely produces a null string. For
-example:@refill
-
-@smallexample
-if ($(NF+1) != "")
- print "can't happen"
-else
- print "everything is normal"
-@end smallexample
-
-@noindent
-should print @samp{everything is normal}, because @code{NF+1} is certain
-to be out of range. (@xref{If Statement, ,The @code{if} Statement},
-for more information about @code{awk}'s @code{if-else} statements.)@refill
-
-It is important to note that assigning to a field will change the
-value of @code{$0}, but will not change the value of @code{NF},
-even when you assign the null string to a field. For example:
-
-@smallexample
-echo a b c d | awk '@{ OFS = ":"; $2 = "" ; print ; print NF @}'
-@end smallexample
-
-@noindent
-prints
-
-@smallexample
-a::c:d
-4
-@end smallexample
-
-@noindent
-The field is still there, it just has an empty value. You can tell
-because there are two colons in a row.
-
-@node Field Separators, Constant Size, Changing Fields, Reading Files
-@section Specifying how Fields are Separated
-@vindex FS
-@cindex fields, separating
-@cindex field separator, @code{FS}
-@cindex @samp{-F} option
-
-(This section is rather long; it describes one of the most fundamental
-operations in @code{awk}. If you are a novice with @code{awk}, we
-recommend that you re-read this section after you have studied the
-section on regular expressions, @ref{Regexp, ,Regular Expressions as Patterns}.)
-
-The way @code{awk} splits an input record into fields is controlled by
-the @dfn{field separator}, which is a single character or a regular
-expression. @code{awk} scans the input record for matches for the
-separator; the fields themselves are the text between the matches. For
-example, if the field separator is @samp{oo}, then the following line:
-
-@smallexample
-moo goo gai pan
-@end smallexample
-
-@noindent
-would be split into three fields: @samp{m}, @samp{@ g} and @samp{@ gai@
-pan}.
-
-The field separator is represented by the built-in variable @code{FS}.
-Shell programmers take note! @code{awk} does not use the name @code{IFS}
-which is used by the shell.@refill
-
-You can change the value of @code{FS} in the @code{awk} program with the
-assignment operator, @samp{=} (@pxref{Assignment Ops, ,Assignment Expressions}).
-Often the right time to do this is at the beginning of execution,
-before any input has been processed, so that the very first record
-will be read with the proper separator. To do this, use the special
-@code{BEGIN} pattern
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}).
-For example, here we set the value of @code{FS} to the string
-@code{","}:@refill
-
-@smallexample
-awk 'BEGIN @{ FS = "," @} ; @{ print $2 @}'
-@end smallexample
-
-@noindent
-Given the input line,
-
-@smallexample
-John Q. Smith, 29 Oak St., Walamazoo, MI 42139
-@end smallexample
-
-@noindent
-this @code{awk} program extracts the string @samp{@ 29 Oak St.}.
-
-@cindex field separator, choice of
-@cindex regular expressions as field separators
-Sometimes your input data will contain separator characters that don't
-separate fields the way you thought they would. For instance, the
-person's name in the example we've been using might have a title or
-suffix attached, such as @samp{John Q. Smith, LXIX}. From input
-containing such a name:
-
-@smallexample
-John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139
-@end smallexample
-
-@noindent
-the previous sample program would extract @samp{@ LXIX}, instead of
-@samp{@ 29 Oak St.}. If you were expecting the program to print the
-address, you would be surprised. So choose your data layout and
-separator characters carefully to prevent such problems.
-
-As you know, by default, fields are separated by whitespace sequences
-(spaces and tabs), not by single spaces: two spaces in a row do not
-delimit an empty field. The default value of the field separator is a
-string @w{@code{" "}} containing a single space. If this value were
-interpreted in the usual way, each space character would separate
-fields, so two spaces in a row would make an empty field between them.
-The reason this does not happen is that a single space as the value of
-@code{FS} is a special case: it is taken to specify the default manner
-of delimiting fields.
-
-If @code{FS} is any other single character, such as @code{","}, then
-each occurrence of that character separates two fields. Two consecutive
-occurrences delimit an empty field. If the character occurs at the
-beginning or the end of the line, that too delimits an empty field. The
-space character is the only single character which does not follow these
-rules.
-
-More generally, the value of @code{FS} may be a string containing any
-regular expression. Then each match in the record for the regular
-expression separates fields. For example, the assignment:@refill
-
-@smallexample
-FS = ", \t"
-@end smallexample
-
-@noindent
-makes every area of an input line that consists of a comma followed by a
-space and a tab, into a field separator. (@samp{\t} stands for a
-tab.)@refill
-
-For a less trivial example of a regular expression, suppose you want
-single spaces to separate fields the way single commas were used above.
-You can set @code{FS} to @w{@code{"[@ ]"}}. This regular expression
-matches a single space and nothing else.
-
-@c the following index entry is an overfull hbox. --mew 30jan1992
-@cindex field separator: on command line
-@cindex command line, setting @code{FS} on
-@code{FS} can be set on the command line. You use the @samp{-F} argument to
-do so. For example:
-
-@smallexample
-awk -F, '@var{program}' @var{input-files}
-@end smallexample
-
-@noindent
-sets @code{FS} to be the @samp{,} character. Notice that the argument uses
-a capital @samp{F}. Contrast this with @samp{-f}, which specifies a file
-containing an @code{awk} program. Case is significant in command options:
-the @samp{-F} and @samp{-f} options have nothing to do with each other.
-You can use both options at the same time to set the @code{FS} argument
-@emph{and} get an @code{awk} program from a file.@refill
-
-@c begin expert info
-The value used for the argument to @samp{-F} is processed in exactly the
-same way as assignments to the built-in variable @code{FS}. This means that
-if the field separator contains special characters, they must be escaped
-appropriately. For example, to use a @samp{\} as the field separator, you
-would have to type:
-
-@smallexample
-# same as FS = "\\"
-awk -F\\\\ '@dots{}' files @dots{}
-@end smallexample
-
-@noindent
-Since @samp{\} is used for quoting in the shell, @code{awk} will see
-@samp{-F\\}. Then @code{awk} processes the @samp{\\} for escape
-characters (@pxref{Constants, ,Constant Expressions}), finally yielding
-a single @samp{\} to be used for the field separator.
-@c end expert info
-
-As a special case, in compatibility mode
-(@pxref{Command Line, ,Invoking @code{awk}}), if the
-argument to @samp{-F} is @samp{t}, then @code{FS} is set to the tab
-character. (This is because if you type @samp{-F\t}, without the quotes,
-at the shell, the @samp{\} gets deleted, so @code{awk} figures that you
-really want your fields to be separated with tabs, and not @samp{t}s.
-Use @samp{-v FS="t"} on the command line if you really do want to separate
-your fields with @samp{t}s.)@refill
-
-For example, let's use an @code{awk} program file called @file{baud.awk}
-that contains the pattern @code{/300/}, and the action @samp{print $1}.
-Here is the program:
-
-@smallexample
-/300/ @{ print $1 @}
-@end smallexample
-
-Let's also set @code{FS} to be the @samp{-} character, and run the
-program on the file @file{BBS-list}. The following command prints a
-list of the names of the bulletin boards that operate at 300 baud and
-the first three digits of their phone numbers:@refill
-
-@smallexample
-awk -F- -f baud.awk BBS-list
-@end smallexample
-
-@noindent
-It produces this output:
-
-@smallexample
-aardvark 555
-alpo
-barfly 555
-bites 555
-camelot 555
-core 555
-fooey 555
-foot 555
-macfoo 555
-sdace 555
-sabafoo 555
-@end smallexample
-
-@noindent
-Note the second line of output. If you check the original file, you will
-see that the second line looked like this:
-
-@smallexample
-alpo-net 555-3412 2400/1200/300 A
-@end smallexample
-
-The @samp{-} as part of the system's name was used as the field
-separator, instead of the @samp{-} in the phone number that was
-originally intended. This demonstrates why you have to be careful in
-choosing your field and record separators.
-
-The following program searches the system password file, and prints
-the entries for users who have no password:
-
-@smallexample
-awk -F: '$2 == ""' /etc/passwd
-@end smallexample
-
-@noindent
-Here we use the @samp{-F} option on the command line to set the field
-separator. Note that fields in @file{/etc/passwd} are separated by
-colons. The second field represents a user's encrypted password, but if
-the field is empty, that user has no password.
-
-@c begin expert info
-According to the @sc{posix} standard, @code{awk} is supposed to behave
-as if each record is split into fields at the time that it is read.
-In particular, this means that you can change the value of @code{FS}
-after a record is read, but before any of the fields are referenced.
-The value of the fields (i.e. how they were split) should reflect the
-old value of @code{FS}, not the new one.
-
-However, many implementations of @code{awk} do not do this. Instead,
-they defer splitting the fields until a field reference actually happens,
-using the @emph{current} value of @code{FS}! This behavior can be difficult
-to diagnose. The following example illustrates the results of the two methods.
-(The @code{sed} command prints just the first line of @file{/etc/passwd}.)
-
-@smallexample
-sed 1q /etc/passwd | awk '@{ FS = ":" ; print $1 @}'
-@end smallexample
-
-@noindent
-will usually print
-
-@smallexample
-root
-@end smallexample
-
-@noindent
-on an incorrect implementation of @code{awk}, while @code{gawk}
-will print something like
-
-@smallexample
-root:nSijPlPhZZwgE:0:0:Root:/:
-@end smallexample
-@c end expert info
-
-@c begin expert info
-There is an important difference between the two cases of @samp{FS = @w{" "}}
-(a single blank) and @samp{FS = @w{"[ \t]+"}} (which is a regular expression
-matching one or more blanks or tabs). For both values of @code{FS}, fields
-are separated by runs of blanks and/or tabs. However, when the value of
-@code{FS} is @code{" "}, @code{awk} will strip leading and trailing whitespace
-from the record, and then decide where the fields are.
-
-For example, the following expression prints @samp{b}:
-
-@smallexample
-echo ' a b c d ' | awk '@{ print $2 @}'
-@end smallexample
-
-@noindent
-However, the following prints @samp{a}:
-
-@smallexample
-echo ' a b c d ' | awk 'BEGIN @{ FS = "[ \t]+" @} ; @{ print $2 @}'
-@end smallexample
-
-@noindent
-In this case, the first field is null.
-
-The stripping of leading and trailing whitespace also comes into
-play whenever @code{$0} is recomputed. For instance, this pipeline
-
-@smallexample
-echo ' a b c d' | awk '@{ print; $2 = $2; print @}'
-@end smallexample
-
-@noindent
-produces this output:
-
-@smallexample
- a b c d
-a b c d
-@end smallexample
-
-@noindent
-The first @code{print} statement prints the record as it was read,
-with leading whitespace intact. The assignment to @code{$2} rebuilds
-@code{$0} by concatenating @code{$1} through @code{$NF} together,
-separated by the value of @code{OFS}. Since the leading whitespace
-was ignored when finding @code{$1}, it is not part of the new @code{$0}.
-Finally, the last @code{print} statement prints the new @code{$0}.
-@c end expert info
-
-The following table summarizes how fields are split, based on the
-value of @code{FS}.
-
-@table @code
-@item FS == " "
-Fields are separated by runs of whitespace. Leading and trailing
-whitespace are ignored. This is the default.
-
-@item FS == @var{any single character}
-Fields are separated by each occurrence of the character. Multiple
-successive occurrences delimit empty fields, as do leading and
-trailing occurrences.
-
-@item FS == @var{regexp}
-Fields are separated by occurrences of characters that match @var{regexp}.
-Leading and trailing matches of @var{regexp} delimit empty fields.
-@end table
-
-@node Constant Size, Multiple Line, Field Separators, Reading Files
-@section Reading Fixed-width Data
-
-(This section discusses an advanced, experimental feature. If you are
-a novice @code{awk} user, you may wish to skip it on the first reading.)
-
-@code{gawk} 2.13 introduced a new facility for dealing with fixed-width fields
-with no distinctive field separator. Data of this nature arises typically
-in one of at least two ways: the input for old FORTRAN programs where
-numbers are run together, and the output of programs that did not anticipate
-the use of their output as input for other programs.
-
-An example of the latter is a table where all the columns are lined up by
-the use of a variable number of spaces and @emph{empty fields are just
-spaces}. Clearly, @code{awk}'s normal field splitting based on @code{FS}
-will not work well in this case. (Although a portable @code{awk} program
-can use a series of @code{substr} calls on @code{$0}, this is awkward and
-inefficient for a large number of fields.)@refill
-
-The splitting of an input record into fixed-width fields is specified by
-assigning a string containing space-separated numbers to the built-in
-variable @code{FIELDWIDTHS}. Each number specifies the width of the field
-@emph{including} columns between fields. If you want to ignore the columns
-between fields, you can specify the width as a separate field that is
-subsequently ignored.
-
-The following data is the output of the @code{w} utility. It is useful
-to illustrate the use of @code{FIELDWIDTHS}.
-
-@smallexample
- 10:06pm up 21 days, 14:04, 23 users
-User tty login@ idle JCPU PCPU what
-hzuo ttyV0 8:58pm 9 5 vi p24.tex
-hzang ttyV3 6:37pm 50 -csh
-eklye ttyV5 9:53pm 7 1 em thes.tex
-dportein ttyV6 8:17pm 1:47 -csh
-gierd ttyD3 10:00pm 1 elm
-dave ttyD4 9:47pm 4 4 w
-brent ttyp0 26Jun91 4:46 26:46 4:41 bash
-dave ttyq4 26Jun9115days 46 46 wnewmail
-@end smallexample
-
-The following program takes the above input, converts the idle time to
-number of seconds and prints out the first two fields and the calculated
-idle time. (This program uses a number of @code{awk} features that
-haven't been introduced yet.)@refill
-
-@smallexample
-BEGIN @{ FIELDWIDTHS = "9 6 10 6 7 7 35" @}
-NR > 2 @{
- idle = $4
- sub(/^ */, "", idle) # strip leading spaces
- if (idle == "") idle = 0
- if (idle ~ /:/) @{ split(idle, t, ":"); idle = t[1] * 60 + t[2] @}
- if (idle ~ /days/) @{ idle *= 24 * 60 * 60 @}
-
- print $1, $2, idle
-@}
-@end smallexample
-
-Here is the result of running the program on the data:
-
-@smallexample
-hzuo ttyV0 0
-hzang ttyV3 50
-eklye ttyV5 0
-dportein ttyV6 107
-gierd ttyD3 1
-dave ttyD4 0
-brent ttyp0 286
-dave ttyq4 1296000
-@end smallexample
-
-Another (possibly more practical) example of fixed-width input data
-would be the input from a deck of balloting cards. In some parts of
-the United States, voters make their choices by punching holes in computer
-cards. These cards are then processed to count the votes for any particular
-candidate or on any particular issue. Since a voter may choose not to
-vote on some issue, any column on the card may be empty. An @code{awk}
-program for processing such data could use the @code{FIELDWIDTHS} feature
-to simplify reading the data.@refill
-
-@c of course, getting gawk to run on a system with card readers is
-@c another story!
-
-This feature is still experimental, and will likely evolve over time.
-
-@node Multiple Line, Getline, Constant Size, Reading Files
-@section Multiple-Line Records
-
-@cindex multiple line records
-@cindex input, multiple line records
-@cindex reading files, multiple line records
-@cindex records, multiple line
-In some data bases, a single line cannot conveniently hold all the
-information in one entry. In such cases, you can use multi-line
-records.
-
-The first step in doing this is to choose your data format: when records
-are not defined as single lines, how do you want to define them?
-What should separate records?
-
-One technique is to use an unusual character or string to separate
-records. For example, you could use the formfeed character (written
-@code{\f} in @code{awk}, as in C) to separate them, making each record
-a page of the file. To do this, just set the variable @code{RS} to
-@code{"\f"} (a string containing the formfeed character). Any
-other character could equally well be used, as long as it won't be part
-of the data in a record.@refill
-
-@ignore
-Another technique is to have blank lines separate records. The string
-@code{"^\n+"} is a regular expression that matches any sequence of
-newlines starting at the beginning of a line---in other words, it
-matches a sequence of blank lines. If you set @code{RS} to this string,
-a record always ends at the first blank line encountered. In
-addition, a regular expression always matches the longest possible
-sequence when there is a choice. So the next record doesn't start until
-the first nonblank line that follows---no matter how many blank lines
-appear in a row, they are considered one record-separator.
-@end ignore
-
-Another technique is to have blank lines separate records. By a special
-dispensation, a null string as the value of @code{RS} indicates that
-records are separated by one or more blank lines. If you set @code{RS}
-to the null string, a record always ends at the first blank line
-encountered. And the next record doesn't start until the first nonblank
-line that follows---no matter how many blank lines appear in a row, they
-are considered one record-separator. (End of file is also considered
-a record separator.)@refill
-@c !!! This use of `end of file' is confusing. Needs to be clarified.
-
-The second step is to separate the fields in the record. One way to do
-this is to put each field on a separate line: to do this, just set the
-variable @code{FS} to the string @code{"\n"}. (This simple regular
-expression matches a single newline.)
-
-Another way to separate fields is to divide each of the lines into fields
-in the normal manner. This happens by default as a result of a special
-feature: when @code{RS} is set to the null string, the newline character
-@emph{always} acts as a field separator. This is in addition to whatever
-field separations result from @code{FS}.
-
-The original motivation for this special exception was probably so that
-you get useful behavior in the default case (i.e., @w{@code{FS == " "}}).
-This feature can be a problem if you really don't want the
-newline character to separate fields, since there is no way to
-prevent it. However, you can work around this by using the @code{split}
-function to break up the record manually
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill
-
-@ignore
-Here are two ways to use records separated by blank lines and break each
-line into fields normally:
-
-@example
-awk 'BEGIN @{ RS = ""; FS = "[ \t\n]+" @} @{ print $1 @}' BBS-list
-
-@exdent @r{or}
-
-awk 'BEGIN @{ RS = "^\n+"; FS = "[ \t\n]+" @} @{ print $1 @}' BBS-list
-@end example
-@end ignore
-
-@ignore
-Here is how to use records separated by blank lines and break each
-line into fields normally:
-
-@example
-awk 'BEGIN @{ RS = ""; FS = "[ \t\n]+" @} ; @{ print $1 @}' BBS-list
-@end example
-@end ignore
-
-@node Getline, Close Input, Multiple Line, Reading Files
-@section Explicit Input with @code{getline}
-
-@findex getline
-@cindex input, explicit
-@cindex explicit input
-@cindex input, @code{getline} command
-@cindex reading files, @code{getline} command
-So far we have been getting our input files from @code{awk}'s main
-input stream---either the standard input (usually your terminal) or the
-files specified on the command line. The @code{awk} language has a
-special built-in command called @code{getline} that
-can be used to read input under your explicit control.@refill
-
-This command is quite complex and should @emph{not} be used by
-beginners. It is covered here because this is the chapter on input.
-The examples that follow the explanation of the @code{getline} command
-include material that has not been covered yet. Therefore, come back
-and study the @code{getline} command @emph{after} you have reviewed the
-rest of this manual and have a good knowledge of how @code{awk} works.
-
-@vindex ERRNO
-@cindex differences: @code{gawk} and @code{awk}
-@code{getline} returns 1 if it finds a record, and 0 if the end of the
-file is encountered. If there is some error in getting a record, such
-as a file that cannot be opened, then @code{getline} returns @minus{}1.
-In this case, @code{gawk} sets the variable @code{ERRNO} to a string
-describing the error that occurred.
-
-In the following examples, @var{command} stands for a string value that
-represents a shell command.
-
-@table @code
-@item getline
-The @code{getline} command can be used without arguments to read input
-from the current input file. All it does in this case is read the next
-input record and split it up into fields. This is useful if you've
-finished processing the current record, but you want to do some special
-processing @emph{right now} on the next record. Here's an
-example:@refill
-
-@example
-awk '@{
- if (t = index($0, "/*")) @{
- if (t > 1)
- tmp = substr($0, 1, t - 1)
- else
- tmp = ""
- u = index(substr($0, t + 2), "*/")
- while (u == 0) @{
- getline
- t = -1
- u = index($0, "*/")
- @}
- if (u <= length($0) - 2)
- $0 = tmp substr($0, t + u + 3)
- else
- $0 = tmp
- @}
- print $0
-@}'
-@end example
-
-This @code{awk} program deletes all C-style comments, @samp{/* @dots{}
-*/}, from the input. By replacing the @samp{print $0} with other
-statements, you could perform more complicated processing on the
-decommented input, like searching for matches of a regular
-expression. (This program has a subtle problem---can you spot it?)
-
-@c the program to remove comments doesn't work if one
-@c comment ends and another begins on the same line. (Your
-@c idea for restart would be useful here). --- brennan@boeing.com
-
-This form of the @code{getline} command sets @code{NF} (the number of
-fields; @pxref{Fields, ,Examining Fields}), @code{NR} (the number of
-records read so far; @pxref{Records, ,How Input is Split into Records}),
-@code{FNR} (the number of records read from this input file), and the
-value of @code{$0}.
-
-@strong{Note:} the new value of @code{$0} is used in testing
-the patterns of any subsequent rules. The original value
-of @code{$0} that triggered the rule which executed @code{getline}
-is lost. By contrast, the @code{next} statement reads a new record
-but immediately begins processing it normally, starting with the first
-rule in the program. @xref{Next Statement, ,The @code{next} Statement}.
-
-@item getline @var{var}
-This form of @code{getline} reads a record into the variable @var{var}.
-This is useful when you want your program to read the next record from
-the current input file, but you don't want to subject the record to the
-normal input processing.
-
-For example, suppose the next line is a comment, or a special string,
-and you want to read it, but you must make certain that it won't trigger
-any rules. This version of @code{getline} allows you to read that line
-and store it in a variable so that the main
-read-a-line-and-check-each-rule loop of @code{awk} never sees it.
-
-The following example swaps every two lines of input. For example, given:
-
-@example
-wan
-tew
-free
-phore
-@end example
-
-@noindent
-it outputs:
-
-@example
-tew
-wan
-phore
-free
-@end example
-
-@noindent
-Here's the program:
-
-@example
-@group
-awk '@{
- if ((getline tmp) > 0) @{
- print tmp
- print $0
- @} else
- print $0
-@}'
-@end group
-@end example
-
-The @code{getline} function used in this way sets only the variables
-@code{NR} and @code{FNR} (and of course, @var{var}). The record is not
-split into fields, so the values of the fields (including @code{$0}) and
-the value of @code{NF} do not change.@refill
-
-@item getline < @var{file}
-@cindex input redirection
-@cindex redirection of input
-This form of the @code{getline} function takes its input from the file
-@var{file}. Here @var{file} is a string-valued expression that
-specifies the file name. @samp{< @var{file}} is called a @dfn{redirection}
-since it directs input to come from a different place.
-
-This form is useful if you want to read your input from a particular
-file, instead of from the main input stream. For example, the following
-program reads its input record from the file @file{foo.input} when it
-encounters a first field with a value equal to 10 in the current input
-file.@refill
-
-@example
-awk '@{
- if ($1 == 10) @{
- getline < "foo.input"
- print
- @} else
- print
-@}'
-@end example
-
-Since the main input stream is not used, the values of @code{NR} and
-@code{FNR} are not changed. But the record read is split into fields in
-the normal manner, so the values of @code{$0} and other fields are
-changed. So is the value of @code{NF}.
-
-This does not cause the record to be tested against all the patterns
-in the @code{awk} program, in the way that would happen if the record
-were read normally by the main processing loop of @code{awk}. However
-the new record is tested against any subsequent rules, just as when
-@code{getline} is used without a redirection.
-
-@item getline @var{var} < @var{file}
-This form of the @code{getline} function takes its input from the file
-@var{file} and puts it in the variable @var{var}. As above, @var{file}
-is a string-valued expression that specifies the file from which to read.
-
-In this version of @code{getline}, none of the built-in variables are
-changed, and the record is not split into fields. The only variable
-changed is @var{var}.
-
-For example, the following program copies all the input files to the
-output, except for records that say @w{@samp{@@include @var{filename}}}.
-Such a record is replaced by the contents of the file
-@var{filename}.@refill
-
-@example
-awk '@{
- if (NF == 2 && $1 == "@@include") @{
- while ((getline line < $2) > 0)
- print line
- close($2)
- @} else
- print
-@}'
-@end example
-
-Note here how the name of the extra input file is not built into
-the program; it is taken from the data, from the second field on
-the @samp{@@include} line.@refill
-
-The @code{close} function is called to ensure that if two identical
-@samp{@@include} lines appear in the input, the entire specified file is
-included twice. @xref{Close Input, ,Closing Input Files and Pipes}.@refill
-
-One deficiency of this program is that it does not process nested
-@samp{@@include} statements the way a true macro preprocessor would.
-
-@item @var{command} | getline
-You can @dfn{pipe} the output of a command into @code{getline}. A pipe is
-simply a way to link the output of one program to the input of another. In
-this case, the string @var{command} is run as a shell command and its output
-is piped into @code{awk} to be used as input. This form of @code{getline}
-reads one record from the pipe.
-
-For example, the following program copies input to output, except for lines
-that begin with @samp{@@execute}, which are replaced by the output produced by
-running the rest of the line as a shell command:
-
-@example
-awk '@{
- if ($1 == "@@execute") @{
- tmp = substr($0, 10)
- while ((tmp | getline) > 0)
- print
- close(tmp)
- @} else
- print
-@}'
-@end example
-
-@noindent
-The @code{close} function is called to ensure that if two identical
-@samp{@@execute} lines appear in the input, the command is run for
-each one. @xref{Close Input, ,Closing Input Files and Pipes}.
-
-Given the input:
-
-@example
-foo
-bar
-baz
-@@execute who
-bletch
-@end example
-
-@noindent
-the program might produce:
-
-@example
-foo
-bar
-baz
-hack ttyv0 Jul 13 14:22
-hack ttyp0 Jul 13 14:23 (gnu:0)
-hack ttyp1 Jul 13 14:23 (gnu:0)
-hack ttyp2 Jul 13 14:23 (gnu:0)
-hack ttyp3 Jul 13 14:23 (gnu:0)
-bletch
-@end example
-
-@noindent
-Notice that this program ran the command @code{who} and printed the result.
-(If you try this program yourself, you will get different results, showing
-you who is logged in on your system.)
-
-This variation of @code{getline} splits the record into fields, sets the
-value of @code{NF} and recomputes the value of @code{$0}. The values of
-@code{NR} and @code{FNR} are not changed.
-
-@item @var{command} | getline @var{var}
-The output of the command @var{command} is sent through a pipe to
-@code{getline} and into the variable @var{var}. For example, the
-following program reads the current date and time into the variable
-@code{current_time}, using the @code{date} utility, and then
-prints it.@refill
-
-@example
-awk 'BEGIN @{
- "date" | getline current_time
- close("date")
- print "Report printed on " current_time
-@}'
-@end example
-
-In this version of @code{getline}, none of the built-in variables are
-changed, and the record is not split into fields.
-@end table
-
-@node Close Input, , Getline, Reading Files
-@section Closing Input Files and Pipes
-@cindex closing input files and pipes
-@findex close
-
-If the same file name or the same shell command is used with
-@code{getline} more than once during the execution of an @code{awk}
-program, the file is opened (or the command is executed) only the first time.
-At that time, the first record of input is read from that file or command.
-The next time the same file or command is used in @code{getline}, another
-record is read from it, and so on.
-
-This implies that if you want to start reading the same file again from
-the beginning, or if you want to rerun a shell command (rather than
-reading more output from the command), you must take special steps.
-What you must do is use the @code{close} function, as follows:
-
-@example
-close(@var{filename})
-@end example
-
-@noindent
-or
-
-@example
-close(@var{command})
-@end example
-
-The argument @var{filename} or @var{command} can be any expression. Its
-value must exactly equal the string that was used to open the file or
-start the command---for example, if you open a pipe with this:
-
-@example
-"sort -r names" | getline foo
-@end example
-
-@noindent
-then you must close it with this:
-
-@example
-close("sort -r names")
-@end example
-
-Once this function call is executed, the next @code{getline} from that
-file or command will reopen the file or rerun the command.
-
-@iftex
-@vindex ERRNO
-@cindex differences: @code{gawk} and @code{awk}
-@end iftex
-@code{close} returns a value of zero if the close succeeded.
-Otherwise, the value will be non-zero.
-In this case, @code{gawk} sets the variable @code{ERRNO} to a string
-describing the error that occurred.
-
-@node Printing, One-liners, Reading Files, Top
-@chapter Printing Output
-
-@cindex printing
-@cindex output
-One of the most common things that actions do is to output or @dfn{print}
-some or all of the input. For simple output, use the @code{print}
-statement. For fancier formatting use the @code{printf} statement.
-Both are described in this chapter.
-
-@menu
-* Print:: The @code{print} statement.
-* Print Examples:: Simple examples of @code{print} statements.
-* Output Separators:: The output separators and how to change them.
-* OFMT:: Controlling Numeric Output With @code{print}.
-* Printf:: The @code{printf} statement.
-* Redirection:: How to redirect output to multiple
- files and pipes.
-* Special Files:: File name interpretation in @code{gawk}.
- @code{gawk} allows access to
- inherited file descriptors.
-@end menu
-
-@node Print, Print Examples, Printing, Printing
-@section The @code{print} Statement
-@cindex @code{print} statement
-
-The @code{print} statement does output with simple, standardized
-formatting. You specify only the strings or numbers to be printed, in a
-list separated by commas. They are output, separated by single spaces,
-followed by a newline. The statement looks like this:
-
-@example
-print @var{item1}, @var{item2}, @dots{}
-@end example
-
-@noindent
-The entire list of items may optionally be enclosed in parentheses. The
-parentheses are necessary if any of the item expressions uses a
-relational operator; otherwise it could be confused with a redirection
-(@pxref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}).
-The relational operators are @samp{==},
-@samp{!=}, @samp{<}, @samp{>}, @samp{>=}, @samp{<=}, @samp{~} and
-@samp{!~} (@pxref{Comparison Ops, ,Comparison Expressions}).@refill
-
-The items printed can be constant strings or numbers, fields of the
-current record (such as @code{$1}), variables, or any @code{awk}
-expressions. The @code{print} statement is completely general for
-computing @emph{what} values to print. With two exceptions,
-you cannot specify @emph{how} to print them---how many
-columns, whether to use exponential notation or not, and so on.
-(@xref{Output Separators}, and
-@ref{OFMT, ,Controlling Numeric Output with @code{print}}.)
-For that, you need the @code{printf} statement
-(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill
-
-The simple statement @samp{print} with no items is equivalent to
-@samp{print $0}: it prints the entire current record. To print a blank
-line, use @samp{print ""}, where @code{""} is the null, or empty,
-string.
-
-To print a fixed piece of text, use a string constant such as
-@w{@code{"Hello there"}} as one item. If you forget to use the
-double-quote characters, your text will be taken as an @code{awk}
-expression, and you will probably get an error. Keep in mind that a
-space is printed between any two items.
-
-Most often, each @code{print} statement makes one line of output. But it
-isn't limited to one line. If an item value is a string that contains a
-newline, the newline is output along with the rest of the string. A
-single @code{print} can make any number of lines this way.
-
-@node Print Examples, Output Separators, Print, Printing
-@section Examples of @code{print} Statements
-
-Here is an example of printing a string that contains embedded newlines:
-
-@example
-awk 'BEGIN @{ print "line one\nline two\nline three" @}'
-@end example
-
-@noindent
-produces output like this:
-
-@example
-line one
-line two
-line three
-@end example
-
-Here is an example that prints the first two fields of each input record,
-with a space between them:
-
-@example
-awk '@{ print $1, $2 @}' inventory-shipped
-@end example
-
-@noindent
-Its output looks like this:
-
-@example
-Jan 13
-Feb 15
-Mar 15
-@dots{}
-@end example
-
-A common mistake in using the @code{print} statement is to omit the comma
-between two items. This often has the effect of making the items run
-together in the output, with no space. The reason for this is that
-juxtaposing two string expressions in @code{awk} means to concatenate
-them. For example, without the comma:
-
-@example
-awk '@{ print $1 $2 @}' inventory-shipped
-@end example
-
-@noindent
-prints:
-
-@example
-@group
-Jan13
-Feb15
-Mar15
-@dots{}
-@end group
-@end example
-
-Neither example's output makes much sense to someone unfamiliar with the
-file @file{inventory-shipped}. A heading line at the beginning would make
-it clearer. Let's add some headings to our table of months (@code{$1}) and
-green crates shipped (@code{$2}). We do this using the @code{BEGIN} pattern
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}) to force the headings to be printed only once:
-
-@example
-awk 'BEGIN @{ print "Month Crates"
- print "----- ------" @}
- @{ print $1, $2 @}' inventory-shipped
-@end example
-
-@noindent
-Did you already guess what happens? This program prints the following:
-
-@example
-@group
-Month Crates
------ ------
-Jan 13
-Feb 15
-Mar 15
-@dots{}
-@end group
-@end example
-
-@noindent
-The headings and the table data don't line up! We can fix this by printing
-some spaces between the two fields:
-
-@example
-awk 'BEGIN @{ print "Month Crates"
- print "----- ------" @}
- @{ print $1, " ", $2 @}' inventory-shipped
-@end example
-
-You can imagine that this way of lining up columns can get pretty
-complicated when you have many columns to fix. Counting spaces for two
-or three columns can be simple, but more than this and you can get
-``lost'' quite easily. This is why the @code{printf} statement was
-created (@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing});
-one of its specialties is lining up columns of data.@refill
-
-@node Output Separators, OFMT, Print Examples, Printing
-@section Output Separators
-
-@cindex output field separator, @code{OFS}
-@vindex OFS
-@vindex ORS
-@cindex output record separator, @code{ORS}
-As mentioned previously, a @code{print} statement contains a list
-of items, separated by commas. In the output, the items are normally
-separated by single spaces. But they do not have to be spaces; a
-single space is only the default. You can specify any string of
-characters to use as the @dfn{output field separator} by setting the
-built-in variable @code{OFS}. The initial value of this variable
-is the string @w{@code{" "}}, that is, just a single space.@refill
-
-The output from an entire @code{print} statement is called an
-@dfn{output record}. Each @code{print} statement outputs one output
-record and then outputs a string called the @dfn{output record separator}.
-The built-in variable @code{ORS} specifies this string. The initial
-value of the variable is the string @code{"\n"} containing a newline
-character; thus, normally each @code{print} statement makes a separate line.
-
-You can change how output fields and records are separated by assigning
-new values to the variables @code{OFS} and/or @code{ORS}. The usual
-place to do this is in the @code{BEGIN} rule
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}), so
-that it happens before any input is processed. You may also do this
-with assignments on the command line, before the names of your input
-files.@refill
-
-The following example prints the first and second fields of each input
-record separated by a semicolon, with a blank line added after each
-line:@refill
-
-@example
-@group
-awk 'BEGIN @{ OFS = ";"; ORS = "\n\n" @}
- @{ print $1, $2 @}' BBS-list
-@end group
-@end example
-
-If the value of @code{ORS} does not contain a newline, all your output
-will be run together on a single line, unless you output newlines some
-other way.
-
-@node OFMT, Printf, Output Separators, Printing
-@section Controlling Numeric Output with @code{print}
-@vindex OFMT
-When you use the @code{print} statement to print numeric values,
-@code{awk} internally converts the number to a string of characters,
-and prints that string. @code{awk} uses the @code{sprintf} function
-to do this conversion. For now, it suffices to say that the @code{sprintf}
-function accepts a @dfn{format specification} that tells it how to format
-numbers (or strings), and that there are a number of different ways that
-numbers can be formatted. The different format specifications are discussed
-more fully in
-@ref{Printf, ,Using @code{printf} Statements for Fancier Printing}.@refill
-
-The built-in variable @code{OFMT} contains the default format specification
-that @code{print} uses with @code{sprintf} when it wants to convert a
-number to a string for printing. By supplying different format specifications
-as the value of @code{OFMT}, you can change how @code{print} will print
-your numbers. As a brief example:
-
-@example
-@group
-awk 'BEGIN @{ OFMT = "%d" # print numbers as integers
- print 17.23 @}'
-@end group
-@end example
-
-@noindent
-will print @samp{17}.
-
-@node Printf, Redirection, OFMT, Printing
-@section Using @code{printf} Statements for Fancier Printing
-@cindex formatted output
-@cindex output, formatted
-
-If you want more precise control over the output format than
-@code{print} gives you, use @code{printf}. With @code{printf} you can
-specify the width to use for each item, and you can specify various
-stylistic choices for numbers (such as what radix to use, whether to
-print an exponent, whether to print a sign, and how many digits to print
-after the decimal point). You do this by specifying a string, called
-the @dfn{format string}, which controls how and where to print the other
-arguments.
-
-@menu
-* Basic Printf:: Syntax of the @code{printf} statement.
-* Control Letters:: Format-control letters.
-* Format Modifiers:: Format-specification modifiers.
-* Printf Examples:: Several examples.
-@end menu
-
-@node Basic Printf, Control Letters, Printf, Printf
-@subsection Introduction to the @code{printf} Statement
-
-@cindex @code{printf} statement, syntax of
-The @code{printf} statement looks like this:@refill
-
-@example
-printf @var{format}, @var{item1}, @var{item2}, @dots{}
-@end example
-
-@noindent
-The entire list of arguments may optionally be enclosed in parentheses. The
-parentheses are necessary if any of the item expressions uses a
-relational operator; otherwise it could be confused with a redirection
-(@pxref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}).
-The relational operators are @samp{==},
-@samp{!=}, @samp{<}, @samp{>}, @samp{>=}, @samp{<=}, @samp{~} and
-@samp{!~} (@pxref{Comparison Ops, ,Comparison Expressions}).@refill
-
-@cindex format string
-The difference between @code{printf} and @code{print} is the argument
-@var{format}. This is an expression whose value is taken as a string; it
-specifies how to output each of the other arguments. It is called
-the @dfn{format string}.
-
-The format string is the same as in the @sc{ansi} C library function
-@code{printf}. Most of @var{format} is text to be output verbatim.
-Scattered among this text are @dfn{format specifiers}, one per item.
-Each format specifier says to output the next item at that place in the
-format.@refill
-
-The @code{printf} statement does not automatically append a newline to its
-output. It outputs only what the format specifies. So if you want
-a newline, you must include one in the format. The output separator
-variables @code{OFS} and @code{ORS} have no effect on @code{printf}
-statements.@refill
-
-@node Control Letters, Format Modifiers, Basic Printf, Printf
-@subsection Format-Control Letters
-@cindex @code{printf}, format-control characters
-@cindex format specifier
-
-A format specifier starts with the character @samp{%} and ends with a
-@dfn{format-control letter}; it tells the @code{printf} statement how
-to output one item. (If you actually want to output a @samp{%}, write
-@samp{%%}.) The format-control letter specifies what kind of value to
-print. The rest of the format specifier is made up of optional
-@dfn{modifiers} which are parameters such as the field width to use.@refill
-
-Here is a list of the format-control letters:
-
-@table @samp
-@item c
-This prints a number as an ASCII character. Thus, @samp{printf "%c",
-65} outputs the letter @samp{A}. The output for a string value is
-the first character of the string.
-
-@item d
-This prints a decimal integer.
-
-@item i
-This also prints a decimal integer.
-
-@item e
-This prints a number in scientific (exponential) notation.
-For example,
-
-@example
-printf "%4.3e", 1950
-@end example
-
-@noindent
-prints @samp{1.950e+03}, with a total of four significant figures of
-which three follow the decimal point. The @samp{4.3} are @dfn{modifiers},
-discussed below.
-
-@item f
-This prints a number in floating point notation.
-
-@item g
-This prints a number in either scientific notation or floating point
-notation, whichever uses fewer characters.
-@ignore
-From: gatech!ames!elroy!cit-vax!EQL.Caltech.Edu!rankin (Pat Rankin)
-
-In the description of printf formats (p.43), the information for %g
-is incorrect (mainly, it's too much of an oversimplification). It's
-wrong in the AWK book too, and in the gawk man page. I suggested to
-David Trueman before 2.13 was released that the latter be revised, so
-that it matched gawk's behavior (rather than trying to change gawk to
-match the docs ;-). The documented description is nice and simple, but
-it doesn't match the actual underlying behavior of %g in the various C
-run-time libraries that gawk relies on. The precision value for g format
-is different than for f and e formats, so it's inaccurate to say 'g' is
-the shorter of 'e' or 'f'. For 'g', precision represents the number of
-significant digits rather than the number of decimal places, and it has
-special rules about how to format numbers with range between 10E-1 and
-10E-4. All in all, it's pretty messy, and I had to add that clumsy
-GFMT_WORKAROUND code because the VMS run-time library doesn't conform to
-the ANSI-C specifications.
-@end ignore
-
-@item o
-This prints an unsigned octal integer.
-
-@item s
-This prints a string.
-
-@item x
-This prints an unsigned hexadecimal integer.
-
-@item X
-This prints an unsigned hexadecimal integer. However, for the values 10
-through 15, it uses the letters @samp{A} through @samp{F} instead of
-@samp{a} through @samp{f}.
-
-@item %
-This isn't really a format-control letter, but it does have a meaning
-when used after a @samp{%}: the sequence @samp{%%} outputs one
-@samp{%}. It does not consume an argument.
-@end table
-
-@node Format Modifiers, Printf Examples, Control Letters, Printf
-@subsection Modifiers for @code{printf} Formats
-
-@cindex @code{printf}, modifiers
-@cindex modifiers (in format specifiers)
-A format specification can also include @dfn{modifiers} that can control
-how much of the item's value is printed and how much space it gets. The
-modifiers come between the @samp{%} and the format-control letter. Here
-are the possible modifiers, in the order in which they may appear:
-
-@table @samp
-@item -
-The minus sign, used before the width modifier, says to left-justify
-the argument within its specified width. Normally the argument
-is printed right-justified in the specified width. Thus,
-
-@example
-printf "%-4s", "foo"
-@end example
-
-@noindent
-prints @samp{foo }.
-
-@item @var{width}
-This is a number representing the desired width of a field. Inserting any
-number between the @samp{%} sign and the format control character forces the
-field to be expanded to this width. The default way to do this is to
-pad with spaces on the left. For example,
-
-@example
-printf "%4s", "foo"
-@end example
-
-@noindent
-prints @samp{ foo}.
-
-The value of @var{width} is a minimum width, not a maximum. If the item
-value requires more than @var{width} characters, it can be as wide as
-necessary. Thus,
-
-@example
-printf "%4s", "foobar"
-@end example
-
-@noindent
-prints @samp{foobar}.
-
-Preceding the @var{width} with a minus sign causes the output to be
-padded with spaces on the right, instead of on the left.
-
-@item .@var{prec}
-This is a number that specifies the precision to use when printing.
-This specifies the number of digits you want printed to the right of the
-decimal point. For a string, it specifies the maximum number of
-characters from the string that should be printed.
-@end table
-
-The C library @code{printf}'s dynamic @var{width} and @var{prec}
-capability (for example, @code{"%*.*s"}) is supported. Instead of
-supplying explicit @var{width} and/or @var{prec} values in the format
-string, you pass them in the argument list. For example:@refill
-
-@example
-w = 5
-p = 3
-s = "abcdefg"
-printf "<%*.*s>\n", w, p, s
-@end example
-
-@noindent
-is exactly equivalent to
-
-@example
-s = "abcdefg"
-printf "<%5.3s>\n", s
-@end example
-
-@noindent
-Both programs output @samp{@w{<@bullet{}@bullet{}abc>}}. (We have
-used the bullet symbol ``@bullet{}'' to represent a space, to clearly
-show you that there are two spaces in the output.)@refill
-
-Earlier versions of @code{awk} did not support this capability. You may
-simulate it by using concatenation to build up the format string,
-like so:@refill
-
-@example
-w = 5
-p = 3
-s = "abcdefg"
-printf "<%" w "." p "s>\n", s
-@end example
-
-@noindent
-This is not particularly easy to read, however.
-
-@node Printf Examples, , Format Modifiers, Printf
-@subsection Examples of Using @code{printf}
-
-Here is how to use @code{printf} to make an aligned table:
-
-@example
-awk '@{ printf "%-10s %s\n", $1, $2 @}' BBS-list
-@end example
-
-@noindent
-prints the names of bulletin boards (@code{$1}) of the file
-@file{BBS-list} as a string of 10 characters, left justified. It also
-prints the phone numbers (@code{$2}) afterward on the line. This
-produces an aligned two-column table of names and phone numbers:@refill
-
-@example
-@group
-aardvark 555-5553
-alpo-net 555-3412
-barfly 555-7685
-bites 555-1675
-camelot 555-0542
-core 555-2912
-fooey 555-1234
-foot 555-6699
-macfoo 555-6480
-sdace 555-3430
-sabafoo 555-2127
-@end group
-@end example
-
-Did you notice that we did not specify that the phone numbers be printed
-as numbers? They had to be printed as strings because the numbers are
-separated by a dash. This dash would be interpreted as a minus sign if
-we had tried to print the phone numbers as numbers. This would have led
-to some pretty confusing results.
-
-We did not specify a width for the phone numbers because they are the
-last things on their lines. We don't need to put spaces after them.
-
-We could make our table look even nicer by adding headings to the tops
-of the columns. To do this, use the @code{BEGIN} pattern
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns})
-to force the header to be printed only once, at the beginning of
-the @code{awk} program:@refill
-
-@example
-@group
-awk 'BEGIN @{ print "Name Number"
- print "---- ------" @}
- @{ printf "%-10s %s\n", $1, $2 @}' BBS-list
-@end group
-@end example
-
-Did you notice that we mixed @code{print} and @code{printf} statements in
-the above example? We could have used just @code{printf} statements to get
-the same results:
-
-@example
-@group
-awk 'BEGIN @{ printf "%-10s %s\n", "Name", "Number"
- printf "%-10s %s\n", "----", "------" @}
- @{ printf "%-10s %s\n", $1, $2 @}' BBS-list
-@end group
-@end example
-
-@noindent
-By outputting each column heading with the same format specification
-used for the elements of the column, we have made sure that the headings
-are aligned just like the columns.
-
-The fact that the same format specification is used three times can be
-emphasized by storing it in a variable, like this:
-
-@example
-awk 'BEGIN @{ format = "%-10s %s\n"
- printf format, "Name", "Number"
- printf format, "----", "------" @}
- @{ printf format, $1, $2 @}' BBS-list
-@end example
-
-See if you can use the @code{printf} statement to line up the headings and
-table data for our @file{inventory-shipped} example covered earlier in the
-section on the @code{print} statement
-(@pxref{Print, ,The @code{print} Statement}).@refill
-
-@node Redirection, Special Files, Printf, Printing
-@section Redirecting Output of @code{print} and @code{printf}
-
-@cindex output redirection
-@cindex redirection of output
-So far we have been dealing only with output that prints to the standard
-output, usually your terminal. Both @code{print} and @code{printf} can
-also send their output to other places.
-This is called @dfn{redirection}.@refill
-
-A redirection appears after the @code{print} or @code{printf} statement.
-Redirections in @code{awk} are written just like redirections in shell
-commands, except that they are written inside the @code{awk} program.
-
-@menu
-* File/Pipe Redirection:: Redirecting Output to Files and Pipes.
-* Close Output:: How to close output files and pipes.
-@end menu
-
-@node File/Pipe Redirection, Close Output, Redirection, Redirection
-@subsection Redirecting Output to Files and Pipes
-
-Here are the three forms of output redirection. They are all shown for
-the @code{print} statement, but they work identically for @code{printf}
-also.@refill
-
-@table @code
-@item print @var{items} > @var{output-file}
-This type of redirection prints the items onto the output file
-@var{output-file}. The file name @var{output-file} can be any
-expression. Its value is changed to a string and then used as a
-file name (@pxref{Expressions, ,Expressions as Action Statements}).@refill
-
-When this type of redirection is used, the @var{output-file} is erased
-before the first output is written to it. Subsequent writes do not
-erase @var{output-file}, but append to it. If @var{output-file} does
-not exist, then it is created.@refill
-
-For example, here is how one @code{awk} program can write a list of
-BBS names to a file @file{name-list} and a list of phone numbers to a
-file @file{phone-list}. Each output file contains one name or number
-per line.
-
-@smallexample
-awk '@{ print $2 > "phone-list"
- print $1 > "name-list" @}' BBS-list
-@end smallexample
-
-@item print @var{items} >> @var{output-file}
-This type of redirection prints the items onto the output file
-@var{output-file}. The difference between this and the
-single-@samp{>} redirection is that the old contents (if any) of
-@var{output-file} are not erased. Instead, the @code{awk} output is
-appended to the file.
-
-@cindex pipes for output
-@cindex output, piping
-@item print @var{items} | @var{command}
-It is also possible to send output through a @dfn{pipe} instead of into a
-file. This type of redirection opens a pipe to @var{command} and writes
-the values of @var{items} through this pipe, to another process created
-to execute @var{command}.@refill
-
-The redirection argument @var{command} is actually an @code{awk}
-expression. Its value is converted to a string, whose contents give the
-shell command to be run.
-
-For example, this produces two files, one unsorted list of BBS names
-and one list sorted in reverse alphabetical order:
-
-@smallexample
-awk '@{ print $1 > "names.unsorted"
- print $1 | "sort -r > names.sorted" @}' BBS-list
-@end smallexample
-
-Here the unsorted list is written with an ordinary redirection while
-the sorted list is written by piping through the @code{sort} utility.
-
-Here is an example that uses redirection to mail a message to a mailing
-list @samp{bug-system}. This might be useful when trouble is encountered
-in an @code{awk} script run periodically for system maintenance.
-
-@smallexample
-report = "mail bug-system"
-print "Awk script failed:", $0 | report
-print "at record number", FNR, "of", FILENAME | report
-close(report)
-@end smallexample
-
-We call the @code{close} function here because it's a good idea to close
-the pipe as soon as all the intended output has been sent to it.
-@xref{Close Output, ,Closing Output Files and Pipes}, for more information
-on this. This example also illustrates the use of a variable to represent
-a @var{file} or @var{command}: it is not necessary to always
-use a string constant. Using a variable is generally a good idea,
-since @code{awk} requires you to spell the string value identically
-every time.
-@end table
-
-Redirecting output using @samp{>}, @samp{>>}, or @samp{|} asks the system
-to open a file or pipe only if the particular @var{file} or @var{command}
-you've specified has not already been written to by your program, or if
-it has been closed since it was last written to.@refill
-
-@node Close Output, , File/Pipe Redirection, Redirection
-@subsection Closing Output Files and Pipes
-@cindex closing output files and pipes
-@findex close
-
-When a file or pipe is opened, the file name or command associated with
-it is remembered by @code{awk} and subsequent writes to the same file or
-command are appended to the previous writes. The file or pipe stays
-open until @code{awk} exits. This is usually convenient.
-
-Sometimes there is a reason to close an output file or pipe earlier
-than that. To do this, use the @code{close} function, as follows:
-
-@example
-close(@var{filename})
-@end example
-
-@noindent
-or
-
-@example
-close(@var{command})
-@end example
-
-The argument @var{filename} or @var{command} can be any expression.
-Its value must exactly equal the string used to open the file or pipe
-to begin with---for example, if you open a pipe with this:
-
-@example
-print $1 | "sort -r > names.sorted"
-@end example
-
-@noindent
-then you must close it with this:
-
-@example
-close("sort -r > names.sorted")
-@end example
-
-Here are some reasons why you might need to close an output file:
-
-@itemize @bullet
-@item
-To write a file and read it back later on in the same @code{awk}
-program. Close the file when you are finished writing it; then
-you can start reading it with @code{getline}
-(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill
-
-@item
-To write numerous files, successively, in the same @code{awk}
-program. If you don't close the files, eventually you may exceed a
-system limit on the number of open files in one process. So close
-each one when you are finished writing it.
-
-@item
-To make a command finish. When you redirect output through a pipe,
-the command reading the pipe normally continues to try to read input
-as long as the pipe is open. Often this means the command cannot
-really do its work until the pipe is closed. For example, if you
-redirect output to the @code{mail} program, the message is not
-actually sent until the pipe is closed.
-
-@item
-To run the same program a second time, with the same arguments.
-This is not the same thing as giving more input to the first run!
-
-For example, suppose you pipe output to the @code{mail} program. If you
-output several lines redirected to this pipe without closing it, they make
-a single message of several lines. By contrast, if you close the pipe
-after each line of output, then each line makes a separate message.
-@end itemize
-
-@iftex
-@vindex ERRNO
-@cindex differences: @code{gawk} and @code{awk}
-@end iftex
-@code{close} returns a value of zero if the close succeeded.
-Otherwise, the value will be non-zero.
-In this case, @code{gawk} sets the variable @code{ERRNO} to a string
-describing the error that occurred.
-
-@node Special Files, , Redirection, Printing
-@section Standard I/O Streams
-@cindex standard input
-@cindex standard output
-@cindex standard error output
-@cindex file descriptors
-
-Running programs conventionally have three input and output streams
-already available to them for reading and writing. These are known as
-the @dfn{standard input}, @dfn{standard output}, and @dfn{standard error
-output}. These streams are, by default, terminal input and output, but
-they are often redirected with the shell, via the @samp{<}, @samp{<<},
-@samp{>}, @samp{>>}, @samp{>&} and @samp{|} operators. Standard error
-is used only for writing error messages; the reason we have two separate
-streams, standard output and standard error, is so that they can be
-redirected separately.
-
-@iftex
-@cindex differences: @code{gawk} and @code{awk}
-@end iftex
-In other implementations of @code{awk}, the only way to write an error
-message to standard error in an @code{awk} program is as follows:
-
-@smallexample
-print "Serious error detected!\n" | "cat 1>&2"
-@end smallexample
-
-@noindent
-This works by opening a pipeline to a shell command which can access the
-standard error stream which it inherits from the @code{awk} process.
-This is far from elegant, and is also inefficient, since it requires a
-separate process. So people writing @code{awk} programs have often
-neglected to do this. Instead, they have sent the error messages to the
-terminal, like this:
-
-@smallexample
-@group
-NF != 4 @{
- printf("line %d skipped: doesn't have 4 fields\n", FNR) > "/dev/tty"
-@}
-@end group
-@end smallexample
-
-@noindent
-This has the same effect most of the time, but not always: although the
-standard error stream is usually the terminal, it can be redirected, and
-when that happens, writing to the terminal is not correct. In fact, if
-@code{awk} is run from a background job, it may not have a terminal at all.
-Then opening @file{/dev/tty} will fail.
-
-@code{gawk} provides special file names for accessing the three standard
-streams. When you redirect input or output in @code{gawk}, if the file name
-matches one of these special names, then @code{gawk} directly uses the
-stream it stands for.
-
-@cindex @file{/dev/stdin}
-@cindex @file{/dev/stdout}
-@cindex @file{/dev/stderr}
-@cindex @file{/dev/fd/}
-@table @file
-@item /dev/stdin
-The standard input (file descriptor 0).
-
-@item /dev/stdout
-The standard output (file descriptor 1).
-
-@item /dev/stderr
-The standard error output (file descriptor 2).
-
-@item /dev/fd/@var{N}
-The file associated with file descriptor @var{N}. Such a file must have
-been opened by the program initiating the @code{awk} execution (typically
-the shell). Unless you take special pains, only descriptors 0, 1 and 2
-are available.
-@end table
-
-The file names @file{/dev/stdin}, @file{/dev/stdout}, and @file{/dev/stderr}
-are aliases for @file{/dev/fd/0}, @file{/dev/fd/1}, and @file{/dev/fd/2},
-respectively, but they are more self-explanatory.
-
-The proper way to write an error message in a @code{gawk} program
-is to use @file{/dev/stderr}, like this:
-
-@smallexample
-NF != 4 @{
- printf("line %d skipped: doesn't have 4 fields\n", FNR) > "/dev/stderr"
-@}
-@end smallexample
-
-@code{gawk} also provides special file names that give access to information
-about the running @code{gawk} process. Each of these ``files'' provides
-a single record of information. To read them more than once, you must
-first close them with the @code{close} function
-(@pxref{Close Input, ,Closing Input Files and Pipes}).
-The filenames are:
-
-@cindex @file{/dev/pid}
-@cindex @file{/dev/pgrpid}
-@cindex @file{/dev/ppid}
-@cindex @file{/dev/user}
-@table @file
-@item /dev/pid
-Reading this file returns the process ID of the current process,
-in decimal, terminated with a newline.
-
-@item /dev/ppid
-Reading this file returns the parent process ID of the current process,
-in decimal, terminated with a newline.
-
-@item /dev/pgrpid
-Reading this file returns the process group ID of the current process,
-in decimal, terminated with a newline.
-
-@item /dev/user
-Reading this file returns a single record terminated with a newline.
-The fields are separated with blanks. The fields represent the
-following information:
-
-@table @code
-@item $1
-The value of the @code{getuid} system call.
-
-@item $2
-The value of the @code{geteuid} system call.
-
-@item $3
-The value of the @code{getgid} system call.
-
-@item $4
-The value of the @code{getegid} system call.
-@end table
-
-If there are any additional fields, they are the group IDs returned by
-@code{getgroups} system call.
-(Multiple groups may not be supported on all systems.)@refill
-@end table
-
-These special file names may be used on the command line as data
-files, as well as for I/O redirections within an @code{awk} program.
-They may not be used as source files with the @samp{-f} option.
-
-Recognition of these special file names is disabled if @code{gawk} is in
-compatibility mode (@pxref{Command Line, ,Invoking @code{awk}}).
-
-@quotation
-@strong{Caution}: Unless your system actually has a @file{/dev/fd} directory
-(or any of the other above listed special files),
-the interpretation of these file names is done by @code{gawk} itself.
-For example, using @samp{/dev/fd/4} for output will actually write on
-file descriptor 4, and not on a new file descriptor that was @code{dup}'ed
-from file descriptor 4. Most of the time this does not matter; however, it
-is important to @emph{not} close any of the files related to file descriptors
-0, 1, and 2. If you do close one of these files, unpredictable behavior
-will result.
-@end quotation
-
-@node One-liners, Patterns, Printing, Top
-@chapter Useful ``One-liners''
-
-@cindex one-liners
-Useful @code{awk} programs are often short, just a line or two. Here is a
-collection of useful, short programs to get you started. Some of these
-programs contain constructs that haven't been covered yet. The description
-of the program will give you a good idea of what is going on, but please
-read the rest of the manual to become an @code{awk} expert!
-
-@c Per suggestions from Michal Jaegermann
-@ifinfo
-Since you are reading this in Info, each line of the example code is
-enclosed in quotes, to represent text that you would type literally.
-The examples themselves represent shell commands that use single quotes
-to keep the shell from interpreting the contents of the program.
-When reading the examples, focus on the text between the open and close
-quotes.
-@end ifinfo
-
-@table @code
-@item awk '@{ if (NF > max) max = NF @}
-@itemx @ @ @ @ @ END @{ print max @}'
-This program prints the maximum number of fields on any input line.
-
-@item awk 'length($0) > 80'
-This program prints every line longer than 80 characters. The sole
-rule has a relational expression as its pattern, and has no action (so the
-default action, printing the record, is used).
-
-@item awk 'NF > 0'
-This program prints every line that has at least one field. This is an
-easy way to delete blank lines from a file (or rather, to create a new
-file similar to the old file but from which the blank lines have been
-deleted).
-
-@item awk '@{ if (NF > 0) print @}'
-This program also prints every line that has at least one field. Here we
-allow the rule to match every line, then decide in the action whether
-to print.
-
-@item awk@ 'BEGIN@ @{@ for (i = 1; i <= 7; i++)
-@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ print int(101 * rand()) @}'
-This program prints 7 random numbers from 0 to 100, inclusive.
-
-@item ls -l @var{files} | awk '@{ x += $4 @} ; END @{ print "total bytes: " x @}'
-This program prints the total number of bytes used by @var{files}.
-
-@item expand@ @var{file}@ |@ awk@ '@{ if (x < length()) x = length() @}
-@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ END @{ print "maximum line length is " x @}'
-This program prints the maximum line length of @var{file}. The input
-is piped through the @code{expand} program to change tabs into spaces,
-so the widths compared are actually the right-margin columns.
-
-@item awk 'BEGIN @{ FS = ":" @}
-@itemx @ @ @ @ @ @{ print $1 | "sort" @}' /etc/passwd
-This program prints a sorted list of the login names of all users.
-
-@item awk '@{ nlines++ @}
-@itemx @ @ @ @ @ END@ @{ print nlines @}'
-This programs counts lines in a file.
-
-@item awk 'END @{ print NR @}'
-This program also counts lines in a file, but lets @code{awk} do the work.
-
-@item awk '@{ print NR, $0 @}'
-This program adds line numbers to all its input files,
-similar to @samp{cat -n}.
-@end table
-
-@node Patterns, Actions, One-liners, Top
-@chapter Patterns
-@cindex pattern, definition of
-
-Patterns in @code{awk} control the execution of rules: a rule is
-executed when its pattern matches the current input record. This
-chapter tells all about how to write patterns.
-
-@menu
-* Kinds of Patterns:: A list of all kinds of patterns.
- The following subsections describe
- them in detail.
-* Regexp:: Regular expressions such as @samp{/foo/}.
-* Comparison Patterns:: Comparison expressions such as @code{$1 > 10}.
-* Boolean Patterns:: Combining comparison expressions.
-* Expression Patterns:: Any expression can be used as a pattern.
-* Ranges:: Pairs of patterns specify record ranges.
-* BEGIN/END:: Specifying initialization and cleanup rules.
-* Empty:: The empty pattern, which matches every record.
-@end menu
-
-@node Kinds of Patterns, Regexp, Patterns, Patterns
-@section Kinds of Patterns
-@cindex patterns, types of
-
-Here is a summary of the types of patterns supported in @code{awk}.
-@c At the next rewrite, check to see that this order matches the
-@c order in the text. It might not matter to a reader, but it's good
-@c style. Also, it might be nice to mention all the topics of sections
-@c that follow in this list; that way people can scan and know when to
-@c expect a specific topic. Specifically please also make an entry
-@c for Boolean operators as patterns in the right place. --mew
-
-@table @code
-@item /@var{regular expression}/
-A regular expression as a pattern. It matches when the text of the
-input record fits the regular expression.
-(@xref{Regexp, ,Regular Expressions as Patterns}.)@refill
-
-@item @var{expression}
-A single expression. It matches when its value, converted to a number,
-is nonzero (if a number) or nonnull (if a string).
-(@xref{Expression Patterns, ,Expressions as Patterns}.)@refill
-
-@item @var{pat1}, @var{pat2}
-A pair of patterns separated by a comma, specifying a range of records.
-(@xref{Ranges, ,Specifying Record Ranges with Patterns}.)
-
-@item BEGIN
-@itemx END
-Special patterns to supply start-up or clean-up information to
-@code{awk}. (@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}.)
-
-@item @var{null}
-The empty pattern matches every input record.
-(@xref{Empty, ,The Empty Pattern}.)@refill
-@end table
-
-
-@node Regexp, Comparison Patterns, Kinds of Patterns, Patterns
-@section Regular Expressions as Patterns
-@cindex pattern, regular expressions
-@cindex regexp
-@cindex regular expressions as patterns
-
-A @dfn{regular expression}, or @dfn{regexp}, is a way of describing a
-class of strings. A regular expression enclosed in slashes (@samp{/})
-is an @code{awk} pattern that matches every input record whose text
-belongs to that class.
-
-The simplest regular expression is a sequence of letters, numbers, or
-both. Such a regexp matches any string that contains that sequence.
-Thus, the regexp @samp{foo} matches any string containing @samp{foo}.
-Therefore, the pattern @code{/foo/} matches any input record containing
-@samp{foo}. Other kinds of regexps let you specify more complicated
-classes of strings.
-
-@menu
-* Regexp Usage:: How to Use Regular Expressions
-* Regexp Operators:: Regular Expression Operators
-* Case-sensitivity:: How to do case-insensitive matching.
-@end menu
-
-@node Regexp Usage, Regexp Operators, Regexp, Regexp
-@subsection How to Use Regular Expressions
-
-A regular expression can be used as a pattern by enclosing it in
-slashes. Then the regular expression is matched against the
-entire text of each record. (Normally, it only needs
-to match some part of the text in order to succeed.) For example, this
-prints the second field of each record that contains @samp{foo} anywhere:
-
-@example
-awk '/foo/ @{ print $2 @}' BBS-list
-@end example
-
-@cindex regular expression matching operators
-@cindex string-matching operators
-@cindex operators, string-matching
-@cindex operators, regexp matching
-@cindex regexp search operators
-Regular expressions can also be used in comparison expressions. Then
-you can specify the string to match against; it need not be the entire
-current input record. These comparison expressions can be used as
-patterns or in @code{if}, @code{while}, @code{for}, and @code{do} statements.
-
-@table @code
-@item @var{exp} ~ /@var{regexp}/
-This is true if the expression @var{exp} (taken as a character string)
-is matched by @var{regexp}. The following example matches, or selects,
-all input records with the upper-case letter @samp{J} somewhere in the
-first field:@refill
-
-@example
-awk '$1 ~ /J/' inventory-shipped
-@end example
-
-So does this:
-
-@example
-awk '@{ if ($1 ~ /J/) print @}' inventory-shipped
-@end example
-
-@item @var{exp} !~ /@var{regexp}/
-This is true if the expression @var{exp} (taken as a character string)
-is @emph{not} matched by @var{regexp}. The following example matches,
-or selects, all input records whose first field @emph{does not} contain
-the upper-case letter @samp{J}:@refill
-
-@example
-awk '$1 !~ /J/' inventory-shipped
-@end example
-@end table
-
-@cindex computed regular expressions
-@cindex regular expressions, computed
-@cindex dynamic regular expressions
-The right hand side of a @samp{~} or @samp{!~} operator need not be a
-constant regexp (i.e., a string of characters between slashes). It may
-be any expression. The expression is evaluated, and converted if
-necessary to a string; the contents of the string are used as the
-regexp. A regexp that is computed in this way is called a @dfn{dynamic
-regexp}. For example:
-
-@example
-identifier_regexp = "[A-Za-z_][A-Za-z_0-9]+"
-$0 ~ identifier_regexp
-@end example
-
-@noindent
-sets @code{identifier_regexp} to a regexp that describes @code{awk}
-variable names, and tests if the input record matches this regexp.
-
-@node Regexp Operators, Case-sensitivity, Regexp Usage, Regexp
-@subsection Regular Expression Operators
-@cindex metacharacters
-@cindex regular expression metacharacters
-
-You can combine regular expressions with the following characters,
-called @dfn{regular expression operators}, or @dfn{metacharacters}, to
-increase the power and versatility of regular expressions.
-
-Here is a table of metacharacters. All characters not listed in the
-table stand for themselves.
-
-@table @code
-@item ^
-This matches the beginning of the string or the beginning of a line
-within the string. For example:
-
-@example
-^@@chapter
-@end example
-
-@noindent
-matches the @samp{@@chapter} at the beginning of a string, and can be used
-to identify chapter beginnings in Texinfo source files.
-
-@item $
-This is similar to @samp{^}, but it matches only at the end of a string
-or the end of a line within the string. For example:
-
-@example
-p$
-@end example
-
-@noindent
-matches a record that ends with a @samp{p}.
-
-@item .
-This matches any single character except a newline. For example:
-
-@example
-.P
-@end example
-
-@noindent
-matches any single character followed by a @samp{P} in a string. Using
-concatenation we can make regular expressions like @samp{U.A}, which
-matches any three-character sequence that begins with @samp{U} and ends
-with @samp{A}.
-
-@item [@dots{}]
-This is called a @dfn{character set}. It matches any one of the
-characters that are enclosed in the square brackets. For example:
-
-@example
-[MVX]
-@end example
-
-@noindent
-matches any one of the characters @samp{M}, @samp{V}, or @samp{X} in a
-string.@refill
-
-Ranges of characters are indicated by using a hyphen between the beginning
-and ending characters, and enclosing the whole thing in brackets. For
-example:@refill
-
-@example
-[0-9]
-@end example
-
-@noindent
-matches any digit.
-
-To include the character @samp{\}, @samp{]}, @samp{-} or @samp{^} in a
-character set, put a @samp{\} in front of it. For example:
-
-@example
-[d\]]
-@end example
-
-@noindent
-matches either @samp{d}, or @samp{]}.@refill
-
-This treatment of @samp{\} is compatible with other @code{awk}
-implementations, and is also mandated by the @sc{posix} Command Language
-and Utilities standard. The regular expressions in @code{awk} are a superset
-of the @sc{posix} specification for Extended Regular Expressions (EREs).
-@sc{posix} EREs are based on the regular expressions accepted by the
-traditional @code{egrep} utility.
-
-In @code{egrep} syntax, backslash is not syntactically special within
-square brackets. This means that special tricks have to be used to
-represent the characters @samp{]}, @samp{-} and @samp{^} as members of a
-character set.
-
-In @code{egrep} syntax, to match @samp{-}, write it as @samp{---},
-which is a range containing only @w{@samp{-}.} You may also give @samp{-}
-as the first or last character in the set. To match @samp{^}, put it
-anywhere except as the first character of a set. To match a @samp{]},
-make it the first character in the set. For example:@refill
-
-@example
-[]d^]
-@end example
-
-@noindent
-matches either @samp{]}, @samp{d} or @samp{^}.@refill
-
-@item [^ @dots{}]
-This is a @dfn{complemented character set}. The first character after
-the @samp{[} @emph{must} be a @samp{^}. It matches any characters
-@emph{except} those in the square brackets (or newline). For example:
-
-@example
-[^0-9]
-@end example
-
-@noindent
-matches any character that is not a digit.
-
-@item |
-This is the @dfn{alternation operator} and it is used to specify
-alternatives. For example:
-
-@example
-^P|[0-9]
-@end example
-
-@noindent
-matches any string that matches either @samp{^P} or @samp{[0-9]}. This
-means it matches any string that contains a digit or starts with @samp{P}.
-
-The alternation applies to the largest possible regexps on either side.
-@item (@dots{})
-Parentheses are used for grouping in regular expressions as in
-arithmetic. They can be used to concatenate regular expressions
-containing the alternation operator, @samp{|}.
-
-@item *
-This symbol means that the preceding regular expression is to be
-repeated as many times as possible to find a match. For example:
-
-@example
-ph*
-@end example
-
-@noindent
-applies the @samp{*} symbol to the preceding @samp{h} and looks for matches
-to one @samp{p} followed by any number of @samp{h}s. This will also match
-just @samp{p} if no @samp{h}s are present.
-
-The @samp{*} repeats the @emph{smallest} possible preceding expression.
-(Use parentheses if you wish to repeat a larger expression.) It finds
-as many repetitions as possible. For example:
-
-@example
-awk '/\(c[ad][ad]*r x\)/ @{ print @}' sample
-@end example
-
-@noindent
-prints every record in the input containing a string of the form
-@samp{(car x)}, @samp{(cdr x)}, @samp{(cadr x)}, and so on.@refill
-
-@item +
-This symbol is similar to @samp{*}, but the preceding expression must be
-matched at least once. This means that:
-
-@example
-wh+y
-@end example
-
-@noindent
-would match @samp{why} and @samp{whhy} but not @samp{wy}, whereas
-@samp{wh*y} would match all three of these strings. This is a simpler
-way of writing the last @samp{*} example:
-
-@example
-awk '/\(c[ad]+r x\)/ @{ print @}' sample
-@end example
-
-@item ?
-This symbol is similar to @samp{*}, but the preceding expression can be
-matched once or not at all. For example:
-
-@example
-fe?d
-@end example
-
-@noindent
-will match @samp{fed} and @samp{fd}, but nothing else.@refill
-
-@item \
-This is used to suppress the special meaning of a character when
-matching. For example:
-
-@example
-\$
-@end example
-
-@noindent
-matches the character @samp{$}.
-
-The escape sequences used for string constants
-(@pxref{Constants, ,Constant Expressions}) are
-valid in regular expressions as well; they are also introduced by a
-@samp{\}.@refill
-@end table
-
-In regular expressions, the @samp{*}, @samp{+}, and @samp{?} operators have
-the highest precedence, followed by concatenation, and finally by @samp{|}.
-As in arithmetic, parentheses can change how operators are grouped.@refill
-
-@node Case-sensitivity, , Regexp Operators, Regexp
-@subsection Case-sensitivity in Matching
-
-Case is normally significant in regular expressions, both when matching
-ordinary characters (i.e., not metacharacters), and inside character
-sets. Thus a @samp{w} in a regular expression matches only a lower case
-@samp{w} and not an upper case @samp{W}.
-
-The simplest way to do a case-independent match is to use a character
-set: @samp{[Ww]}. However, this can be cumbersome if you need to use it
-often; and it can make the regular expressions harder for humans to
-read. There are two other alternatives that you might prefer.
-
-One way to do a case-insensitive match at a particular point in the
-program is to convert the data to a single case, using the
-@code{tolower} or @code{toupper} built-in string functions (which we
-haven't discussed yet;
-@pxref{String Functions, ,Built-in Functions for String Manipulation}).
-For example:@refill
-
-@example
-tolower($1) ~ /foo/ @{ @dots{} @}
-@end example
-
-@noindent
-converts the first field to lower case before matching against it.
-
-Another method is to set the variable @code{IGNORECASE} to a nonzero
-value (@pxref{Built-in Variables}). When @code{IGNORECASE} is not zero,
-@emph{all} regexp operations ignore case. Changing the value of
-@code{IGNORECASE} dynamically controls the case sensitivity of your
-program as it runs. Case is significant by default because
-@code{IGNORECASE} (like most variables) is initialized to zero.
-
-@example
-x = "aB"
-if (x ~ /ab/) @dots{} # this test will fail
-
-IGNORECASE = 1
-if (x ~ /ab/) @dots{} # now it will succeed
-@end example
-
-In general, you cannot use @code{IGNORECASE} to make certain rules
-case-insensitive and other rules case-sensitive, because there is no way
-to set @code{IGNORECASE} just for the pattern of a particular rule. To
-do this, you must use character sets or @code{tolower}. However, one
-thing you can do only with @code{IGNORECASE} is turn case-sensitivity on
-or off dynamically for all the rules at once.@refill
-
-@code{IGNORECASE} can be set on the command line, or in a @code{BEGIN}
-rule. Setting @code{IGNORECASE} from the command line is a way to make
-a program case-insensitive without having to edit it.
-
-The value of @code{IGNORECASE} has no effect if @code{gawk} is in
-compatibility mode (@pxref{Command Line, ,Invoking @code{awk}}).
-Case is always significant in compatibility mode.@refill
-
-@node Comparison Patterns, Boolean Patterns, Regexp, Patterns
-@section Comparison Expressions as Patterns
-@cindex comparison expressions as patterns
-@cindex pattern, comparison expressions
-@cindex relational operators
-@cindex operators, relational
-
-@dfn{Comparison patterns} test relationships such as equality between
-two strings or numbers. They are a special case of expression patterns
-(@pxref{Expression Patterns, ,Expressions as Patterns}). They are written
-with @dfn{relational operators}, which are a superset of those in C.
-Here is a table of them:@refill
-
-@table @code
-@item @var{x} < @var{y}
-True if @var{x} is less than @var{y}.
-
-@item @var{x} <= @var{y}
-True if @var{x} is less than or equal to @var{y}.
-
-@item @var{x} > @var{y}
-True if @var{x} is greater than @var{y}.
-
-@item @var{x} >= @var{y}
-True if @var{x} is greater than or equal to @var{y}.
-
-@item @var{x} == @var{y}
-True if @var{x} is equal to @var{y}.
-
-@item @var{x} != @var{y}
-True if @var{x} is not equal to @var{y}.
-
-@item @var{x} ~ @var{y}
-True if @var{x} matches the regular expression described by @var{y}.
-
-@item @var{x} !~ @var{y}
-True if @var{x} does not match the regular expression described by @var{y}.
-@end table
-
-The operands of a relational operator are compared as numbers if they
-are both numbers. Otherwise they are converted to, and compared as,
-strings (@pxref{Conversion, ,Conversion of Strings and Numbers},
-for the detailed rules). Strings are compared by comparing the first
-character of each, then the second character of each,
-and so on, until there is a difference. If the two strings are equal until
-the shorter one runs out, the shorter one is considered to be less than the
-longer one. Thus, @code{"10"} is less than @code{"9"}, and @code{"abc"}
-is less than @code{"abcd"}.@refill
-
-The left operand of the @samp{~} and @samp{!~} operators is a string.
-The right operand is either a constant regular expression enclosed in
-slashes (@code{/@var{regexp}/}), or any expression, whose string value
-is used as a dynamic regular expression
-(@pxref{Regexp Usage, ,How to Use Regular Expressions}).@refill
-
-The following example prints the second field of each input record
-whose first field is precisely @samp{foo}.
-
-@example
-awk '$1 == "foo" @{ print $2 @}' BBS-list
-@end example
-
-@noindent
-Contrast this with the following regular expression match, which would
-accept any record with a first field that contains @samp{foo}:
-
-@example
-awk '$1 ~ "foo" @{ print $2 @}' BBS-list
-@end example
-
-@noindent
-or, equivalently, this one:
-
-@example
-awk '$1 ~ /foo/ @{ print $2 @}' BBS-list
-@end example
-
-@node Boolean Patterns, Expression Patterns, Comparison Patterns, Patterns
-@section Boolean Operators and Patterns
-@cindex patterns, boolean
-@cindex boolean patterns
-
-A @dfn{boolean pattern} is an expression which combines other patterns
-using the @dfn{boolean operators} ``or'' (@samp{||}), ``and''
-(@samp{&&}), and ``not'' (@samp{!}). Whether the boolean pattern
-matches an input record depends on whether its subpatterns match.
-
-For example, the following command prints all records in the input file
-@file{BBS-list} that contain both @samp{2400} and @samp{foo}.@refill
-
-@example
-awk '/2400/ && /foo/' BBS-list
-@end example
-
-The following command prints all records in the input file
-@file{BBS-list} that contain @emph{either} @samp{2400} or @samp{foo}, or
-both.@refill
-
-@example
-awk '/2400/ || /foo/' BBS-list
-@end example
-
-The following command prints all records in the input file
-@file{BBS-list} that do @emph{not} contain the string @samp{foo}.
-
-@example
-awk '! /foo/' BBS-list
-@end example
-
-Note that boolean patterns are a special case of expression patterns
-(@pxref{Expression Patterns, ,Expressions as Patterns}); they are
-expressions that use the boolean operators.
-@xref{Boolean Ops, ,Boolean Expressions}, for complete information
-on the boolean operators.@refill
-
-The subpatterns of a boolean pattern can be constant regular
-expressions, comparisons, or any other @code{awk} expressions. Range
-patterns are not expressions, so they cannot appear inside boolean
-patterns. Likewise, the special patterns @code{BEGIN} and @code{END},
-which never match any input record, are not expressions and cannot
-appear inside boolean patterns.
-
-@node Expression Patterns, Ranges, Boolean Patterns, Patterns
-@section Expressions as Patterns
-
-Any @code{awk} expression is also valid as an @code{awk} pattern.
-Then the pattern ``matches'' if the expression's value is nonzero (if a
-number) or nonnull (if a string).
-
-The expression is reevaluated each time the rule is tested against a new
-input record. If the expression uses fields such as @code{$1}, the
-value depends directly on the new input record's text; otherwise, it
-depends only on what has happened so far in the execution of the
-@code{awk} program, but that may still be useful.
-
-Comparison patterns are actually a special case of this. For
-example, the expression @code{$5 == "foo"} has the value 1 when the
-value of @code{$5} equals @code{"foo"}, and 0 otherwise; therefore, this
-expression as a pattern matches when the two values are equal.
-
-Boolean patterns are also special cases of expression patterns.
-
-A constant regexp as a pattern is also a special case of an expression
-pattern. @code{/foo/} as an expression has the value 1 if @samp{foo}
-appears in the current input record; thus, as a pattern, @code{/foo/}
-matches any record containing @samp{foo}.
-
-Other implementations of @code{awk} that are not yet @sc{posix} compliant
-are less general than @code{gawk}: they allow comparison expressions, and
-boolean combinations thereof (optionally with parentheses), but not
-necessarily other kinds of expressions.
-
-@node Ranges, BEGIN/END, Expression Patterns, Patterns
-@section Specifying Record Ranges with Patterns
-
-@cindex range pattern
-@cindex patterns, range
-A @dfn{range pattern} is made of two patterns separated by a comma, of
-the form @code{@var{begpat}, @var{endpat}}. It matches ranges of
-consecutive input records. The first pattern @var{begpat} controls
-where the range begins, and the second one @var{endpat} controls where
-it ends. For example,@refill
-
-@example
-awk '$1 == "on", $1 == "off"'
-@end example
-
-@noindent
-prints every record between @samp{on}/@samp{off} pairs, inclusive.
-
-A range pattern starts out by matching @var{begpat}
-against every input record; when a record matches @var{begpat}, the
-range pattern becomes @dfn{turned on}. The range pattern matches this
-record. As long as it stays turned on, it automatically matches every
-input record read. It also matches @var{endpat} against
-every input record; when that succeeds, the range pattern is turned
-off again for the following record. Now it goes back to checking
-@var{begpat} against each record.
-
-The record that turns on the range pattern and the one that turns it
-off both match the range pattern. If you don't want to operate on
-these records, you can write @code{if} statements in the rule's action
-to distinguish them.
-
-It is possible for a pattern to be turned both on and off by the same
-record, if both conditions are satisfied by that record. Then the action is
-executed for just that record.
-
-@node BEGIN/END, Empty, Ranges, Patterns
-@section @code{BEGIN} and @code{END} Special Patterns
-
-@cindex @code{BEGIN} special pattern
-@cindex patterns, @code{BEGIN}
-@cindex @code{END} special pattern
-@cindex patterns, @code{END}
-@code{BEGIN} and @code{END} are special patterns. They are not used to
-match input records. Rather, they are used for supplying start-up or
-clean-up information to your @code{awk} script. A @code{BEGIN} rule is
-executed, once, before the first input record has been read. An @code{END}
-rule is executed, once, after all the input has been read. For
-example:@refill
-
-@example
-awk 'BEGIN @{ print "Analysis of `foo'" @}
- /foo/ @{ ++foobar @}
- END @{ print "`foo' appears " foobar " times." @}' BBS-list
-@end example
-
-This program finds the number of records in the input file @file{BBS-list}
-that contain the string @samp{foo}. The @code{BEGIN} rule prints a title
-for the report. There is no need to use the @code{BEGIN} rule to
-initialize the counter @code{foobar} to zero, as @code{awk} does this
-for us automatically (@pxref{Variables}).
-
-The second rule increments the variable @code{foobar} every time a
-record containing the pattern @samp{foo} is read. The @code{END} rule
-prints the value of @code{foobar} at the end of the run.@refill
-
-The special patterns @code{BEGIN} and @code{END} cannot be used in ranges
-or with boolean operators (indeed, they cannot be used with any operators).
-
-An @code{awk} program may have multiple @code{BEGIN} and/or @code{END}
-rules. They are executed in the order they appear, all the @code{BEGIN}
-rules at start-up and all the @code{END} rules at termination.
-
-Multiple @code{BEGIN} and @code{END} sections are useful for writing
-library functions, since each library can have its own @code{BEGIN} or
-@code{END} rule to do its own initialization and/or cleanup. Note that
-the order in which library functions are named on the command line
-controls the order in which their @code{BEGIN} and @code{END} rules are
-executed. Therefore you have to be careful to write such rules in
-library files so that the order in which they are executed doesn't matter.
-@xref{Command Line, ,Invoking @code{awk}}, for more information on
-using library functions.
-
-If an @code{awk} program only has a @code{BEGIN} rule, and no other
-rules, then the program exits after the @code{BEGIN} rule has been run.
-(Older versions of @code{awk} used to keep reading and ignoring input
-until end of file was seen.) However, if an @code{END} rule exists as
-well, then the input will be read, even if there are no other rules in
-the program. This is necessary in case the @code{END} rule checks the
-@code{NR} variable.
-
-@code{BEGIN} and @code{END} rules must have actions; there is no default
-action for these rules since there is no current record when they run.
-
-@node Empty, , BEGIN/END, Patterns
-@comment node-name, next, previous, up
-@section The Empty Pattern
-
-@cindex empty pattern
-@cindex pattern, empty
-An empty pattern is considered to match @emph{every} input record. For
-example, the program:@refill
-
-@example
-awk '@{ print $1 @}' BBS-list
-@end example
-
-@noindent
-prints the first field of every record.
-
-@node Actions, Expressions, Patterns, Top
-@chapter Overview of Actions
-@cindex action, definition of
-@cindex curly braces
-@cindex action, curly braces
-@cindex action, separating statements
-
-An @code{awk} program or script consists of a series of
-rules and function definitions, interspersed. (Functions are
-described later. @xref{User-defined, ,User-defined Functions}.)
-
-A rule contains a pattern and an action, either of which may be
-omitted. The purpose of the @dfn{action} is to tell @code{awk} what to do
-once a match for the pattern is found. Thus, the entire program
-looks somewhat like this:
-
-@example
-@r{[}@var{pattern}@r{]} @r{[}@{ @var{action} @}@r{]}
-@r{[}@var{pattern}@r{]} @r{[}@{ @var{action} @}@r{]}
-@dots{}
-function @var{name} (@var{args}) @{ @dots{} @}
-@dots{}
-@end example
-
-An action consists of one or more @code{awk} @dfn{statements}, enclosed
-in curly braces (@samp{@{} and @samp{@}}). Each statement specifies one
-thing to be done. The statements are separated by newlines or
-semicolons.
-
-The curly braces around an action must be used even if the action
-contains only one statement, or even if it contains no statements at
-all. However, if you omit the action entirely, omit the curly braces as
-well. (An omitted action is equivalent to @samp{@{ print $0 @}}.)
-
-Here are the kinds of statements supported in @code{awk}:
-
-@itemize @bullet
-@item
-Expressions, which can call functions or assign values to variables
-(@pxref{Expressions, ,Expressions as Action Statements}). Executing
-this kind of statement simply computes the value of the expression and
-then ignores it. This is useful when the expression has side effects
-(@pxref{Assignment Ops, ,Assignment Expressions}).@refill
-
-@item
-Control statements, which specify the control flow of @code{awk}
-programs. The @code{awk} language gives you C-like constructs
-(@code{if}, @code{for}, @code{while}, and so on) as well as a few
-special ones (@pxref{Statements, ,Control Statements in Actions}).@refill
-
-@item
-Compound statements, which consist of one or more statements enclosed in
-curly braces. A compound statement is used in order to put several
-statements together in the body of an @code{if}, @code{while}, @code{do}
-or @code{for} statement.
-
-@item
-Input control, using the @code{getline} command
-(@pxref{Getline, ,Explicit Input with @code{getline}}), and the @code{next}
-statement (@pxref{Next Statement, ,The @code{next} Statement}).
-
-@item
-Output statements, @code{print} and @code{printf}.
-@xref{Printing, ,Printing Output}.@refill
-
-@item
-Deletion statements, for deleting array elements.
-@xref{Delete, ,The @code{delete} Statement}.@refill
-@end itemize
-
-@iftex
-The next two chapters cover in detail expressions and control
-statements, respectively. We go on to treat arrays and built-in
-functions, both of which are used in expressions. Then we proceed
-to discuss how to define your own functions.
-@end iftex
-
-@node Expressions, Statements, Actions, Top
-@chapter Expressions as Action Statements
-@cindex expression
-
-Expressions are the basic building block of @code{awk} actions. An
-expression evaluates to a value, which you can print, test, store in a
-variable or pass to a function. But beyond that, an expression can assign a new value to a variable
-or a field, with an assignment operator.
-
-An expression can serve as a statement on its own. Most other kinds of
-statements contain one or more expressions which specify data to be
-operated on. As in other languages, expressions in @code{awk} include
-variables, array references, constants, and function calls, as well as
-combinations of these with various operators.
-
-@menu
-* Constants:: String, numeric, and regexp constants.
-* Variables:: Variables give names to values for later use.
-* Arithmetic Ops:: Arithmetic operations (@samp{+}, @samp{-}, etc.)
-* Concatenation:: Concatenating strings.
-* Comparison Ops:: Comparison of numbers and strings
- with @samp{<}, etc.
-* Boolean Ops:: Combining comparison expressions
- using boolean operators
- @samp{||} (``or''), @samp{&&} (``and'') and @samp{!} (``not'').
-
-* Assignment Ops:: Changing the value of a variable or a field.
-* Increment Ops:: Incrementing the numeric value of a variable.
-
-* Conversion:: The conversion of strings to numbers
- and vice versa.
-* Values:: The whole truth about numbers and strings.
-* Conditional Exp:: Conditional expressions select
- between two subexpressions under control
- of a third subexpression.
-* Function Calls:: A function call is an expression.
-* Precedence:: How various operators nest.
-@end menu
-
-@node Constants, Variables, Expressions, Expressions
-@section Constant Expressions
-@cindex constants, types of
-@cindex string constants
-
-The simplest type of expression is the @dfn{constant}, which always has
-the same value. There are three types of constants: numeric constants,
-string constants, and regular expression constants.
-
-@cindex numeric constant
-@cindex numeric value
-A @dfn{numeric constant} stands for a number. This number can be an
-integer, a decimal fraction, or a number in scientific (exponential)
-notation. Note that all numeric values are represented within
-@code{awk} in double-precision floating point. Here are some examples
-of numeric constants, which all have the same value:
-
-@example
-105
-1.05e+2
-1050e-1
-@end example
-
-A string constant consists of a sequence of characters enclosed in
-double-quote marks. For example:
-
-@example
-"parrot"
-@end example
-
-@noindent
-@iftex
-@cindex differences between @code{gawk} and @code{awk}
-@end iftex
-represents the string whose contents are @samp{parrot}. Strings in
-@code{gawk} can be of any length and they can contain all the possible
-8-bit ASCII characters including ASCII NUL. Other @code{awk}
-implementations may have difficulty with some character codes.@refill
-
-@cindex escape sequence notation
-Some characters cannot be included literally in a string constant. You
-represent them instead with @dfn{escape sequences}, which are character
-sequences beginning with a backslash (@samp{\}).
-
-One use of an escape sequence is to include a double-quote character in
-a string constant. Since a plain double-quote would end the string, you
-must use @samp{\"} to represent a single double-quote character as a
-part of the string.
-The
-backslash character itself is another character that cannot be
-included normally; you write @samp{\\} to put one backslash in the
-string. Thus, the string whose contents are the two characters
-@samp{"\} must be written @code{"\"\\"}.
-
-Another use of backslash is to represent unprintable characters
-such as newline. While there is nothing to stop you from writing most
-of these characters directly in a string constant, they may look ugly.
-
-Here is a table of all the escape sequences used in @code{awk}:
-
-@table @code
-@item \\
-Represents a literal backslash, @samp{\}.
-
-@item \a
-Represents the ``alert'' character, control-g, ASCII code 7.
-
-@item \b
-Represents a backspace, control-h, ASCII code 8.
-
-@item \f
-Represents a formfeed, control-l, ASCII code 12.
-
-@item \n
-Represents a newline, control-j, ASCII code 10.
-
-@item \r
-Represents a carriage return, control-m, ASCII code 13.
-
-@item \t
-Represents a horizontal tab, control-i, ASCII code 9.
-
-@item \v
-Represents a vertical tab, control-k, ASCII code 11.
-
-@item \@var{nnn}
-Represents the octal value @var{nnn}, where @var{nnn} are one to three
-digits between 0 and 7. For example, the code for the ASCII ESC
-(escape) character is @samp{\033}.@refill
-
-@item \x@var{hh}@dots{}
-Represents the hexadecimal value @var{hh}, where @var{hh} are hexadecimal
-digits (@samp{0} through @samp{9} and either @samp{A} through @samp{F} or
-@samp{a} through @samp{f}). Like the same construct in @sc{ansi} C, the escape
-sequence continues until the first non-hexadecimal digit is seen. However,
-using more than two hexadecimal digits produces undefined results. (The
-@samp{\x} escape sequence is not allowed in @sc{posix} @code{awk}.)@refill
-@end table
-
-A @dfn{constant regexp} is a regular expression description enclosed in
-slashes, such as @code{/^beginning and end$/}. Most regexps used in
-@code{awk} programs are constant, but the @samp{~} and @samp{!~}
-operators can also match computed or ``dynamic'' regexps
-(@pxref{Regexp Usage, ,How to Use Regular Expressions}).@refill
-
-Constant regexps may be used like simple expressions. When a
-constant regexp is not on the right hand side of the @samp{~} or
-@samp{!~} operators, it has the same meaning as if it appeared
-in a pattern, i.e. @samp{($0 ~ /foo/)}
-(@pxref{Expression Patterns, ,Expressions as Patterns}).
-This means that the two code segments,@refill
-
-@example
-if ($0 ~ /barfly/ || $0 ~ /camelot/)
- print "found"
-@end example
-
-@noindent
-and
-
-@example
-if (/barfly/ || /camelot/)
- print "found"
-@end example
-
-@noindent
-are exactly equivalent. One rather bizarre consequence of this rule is
-that the following boolean expression is legal, but does not do what the user
-intended:@refill
-
-@example
-if (/foo/ ~ $1) print "found foo"
-@end example
-
-This code is ``obviously'' testing @code{$1} for a match against the regexp
-@code{/foo/}. But in fact, the expression @code{(/foo/ ~ $1)} actually means
-@code{(($0 ~ /foo/) ~ $1)}. In other words, first match the input record
-against the regexp @code{/foo/}. The result will be either a 0 or a 1,
-depending upon the success or failure of the match. Then match that result
-against the first field in the record.@refill
-
-Since it is unlikely that you would ever really wish to make this kind of
-test, @code{gawk} will issue a warning when it sees this construct in
-a program.@refill
-
-Another consequence of this rule is that the assignment statement
-
-@example
-matches = /foo/
-@end example
-
-@noindent
-will assign either 0 or 1 to the variable @code{matches}, depending
-upon the contents of the current input record.
-
-Constant regular expressions are also used as the first argument for
-the @code{sub} and @code{gsub} functions
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill
-
-This feature of the language was never well documented until the
-@sc{posix} specification.
-
-You may be wondering, when is
-
-@example
-$1 ~ /foo/ @{ @dots{} @}
-@end example
-
-@noindent
-preferable to
-
-@example
-$1 ~ "foo" @{ @dots{} @}
-@end example
-
-Since the right-hand sides of both @samp{~} operators are constants,
-it is more efficient to use the @samp{/foo/} form: @code{awk} can note
-that you have supplied a regexp and store it internally in a form that
-makes pattern matching more efficient. In the second form, @code{awk}
-must first convert the string into this internal form, and then perform
-the pattern matching. The first form is also better style; it shows
-clearly that you intend a regexp match.
-
-@node Variables, Arithmetic Ops, Constants, Expressions
-@section Variables
-@cindex variables, user-defined
-@cindex user-defined variables
-@c there should be more than one subsection, ideally. Not a big deal.
-@c But usually there are supposed to be at least two. One way to get
-@c around this is to write the info in the subsection as the info in the
-@c section itself and not have any subsections.. --mew
-
-Variables let you give names to values and refer to them later. You have
-already seen variables in many of the examples. The name of a variable
-must be a sequence of letters, digits and underscores, but it may not begin
-with a digit. Case is significant in variable names; @code{a} and @code{A}
-are distinct variables.
-
-A variable name is a valid expression by itself; it represents the
-variable's current value. Variables are given new values with
-@dfn{assignment operators} and @dfn{increment operators}.
-@xref{Assignment Ops, ,Assignment Expressions}.
-
-A few variables have special built-in meanings, such as @code{FS}, the
-field separator, and @code{NF}, the number of fields in the current
-input record. @xref{Built-in Variables}, for a list of them. These
-built-in variables can be used and assigned just like all other
-variables, but their values are also used or changed automatically by
-@code{awk}. Each built-in variable's name is made entirely of upper case
-letters.
-
-Variables in @code{awk} can be assigned either numeric or string
-values. By default, variables are initialized to the null string, which
-is effectively zero if converted to a number. There is no need to
-``initialize'' each variable explicitly in @code{awk}, the way you would in C or most other traditional languages.
-
-@menu
-* Assignment Options:: Setting variables on the command line
- and a summary of command line syntax.
- This is an advanced method of input.
-@end menu
-
-@node Assignment Options, , Variables, Variables
-@subsection Assigning Variables on the Command Line
-
-You can set any @code{awk} variable by including a @dfn{variable assignment}
-among the arguments on the command line when you invoke @code{awk}
-(@pxref{Command Line, ,Invoking @code{awk}}). Such an assignment has
-this form:@refill
-
-@example
-@var{variable}=@var{text}
-@end example
-
-@noindent
-With it, you can set a variable either at the beginning of the
-@code{awk} run or in between input files.
-
-If you precede the assignment with the @samp{-v} option, like this:
-
-@example
--v @var{variable}=@var{text}
-@end example
-
-@noindent
-then the variable is set at the very beginning, before even the
-@code{BEGIN} rules are run. The @samp{-v} option and its assignment
-must precede all the file name arguments, as well as the program text.
-
-Otherwise, the variable assignment is performed at a time determined by
-its position among the input file arguments: after the processing of the
-preceding input file argument. For example:
-
-@example
-awk '@{ print $n @}' n=4 inventory-shipped n=2 BBS-list
-@end example
-
-@noindent
-prints the value of field number @code{n} for all input records. Before
-the first file is read, the command line sets the variable @code{n}
-equal to 4. This causes the fourth field to be printed in lines from
-the file @file{inventory-shipped}. After the first file has finished,
-but before the second file is started, @code{n} is set to 2, so that the
-second field is printed in lines from @file{BBS-list}.
-
-Command line arguments are made available for explicit examination by
-the @code{awk} program in an array named @code{ARGV}
-(@pxref{Built-in Variables}).@refill
-
-@code{awk} processes the values of command line assignments for escape
-sequences (@pxref{Constants, ,Constant Expressions}).
-
-@node Arithmetic Ops, Concatenation, Variables, Expressions
-@section Arithmetic Operators
-@cindex arithmetic operators
-@cindex operators, arithmetic
-@cindex addition
-@cindex subtraction
-@cindex multiplication
-@cindex division
-@cindex remainder
-@cindex quotient
-@cindex exponentiation
-
-The @code{awk} language uses the common arithmetic operators when
-evaluating expressions. All of these arithmetic operators follow normal
-precedence rules, and work as you would expect them to. This example
-divides field three by field four, adds field two, stores the result
-into field one, and prints the resulting altered input record:
-
-@example
-awk '@{ $1 = $2 + $3 / $4; print @}' inventory-shipped
-@end example
-
-The arithmetic operators in @code{awk} are:
-
-@table @code
-@item @var{x} + @var{y}
-Addition.
-
-@item @var{x} - @var{y}
-Subtraction.
-
-@item - @var{x}
-Negation.
-
-@item + @var{x}
-Unary plus. No real effect on the expression.
-
-@item @var{x} * @var{y}
-Multiplication.
-
-@item @var{x} / @var{y}
-Division. Since all numbers in @code{awk} are double-precision
-floating point, the result is not rounded to an integer: @code{3 / 4}
-has the value 0.75.
-
-@item @var{x} % @var{y}
-@iftex
-@cindex differences between @code{gawk} and @code{awk}
-@end iftex
-Remainder. The quotient is rounded toward zero to an integer,
-multiplied by @var{y} and this result is subtracted from @var{x}.
-This operation is sometimes known as ``trunc-mod.'' The following
-relation always holds:
-
-@example
-b * int(a / b) + (a % b) == a
-@end example
-
-One possibly undesirable effect of this definition of remainder is that
-@code{@var{x} % @var{y}} is negative if @var{x} is negative. Thus,
-
-@example
--17 % 8 = -1
-@end example
-
-In other @code{awk} implementations, the signedness of the remainder
-may be machine dependent.
-
-@item @var{x} ^ @var{y}
-@itemx @var{x} ** @var{y}
-Exponentiation: @var{x} raised to the @var{y} power. @code{2 ^ 3} has
-the value 8. The character sequence @samp{**} is equivalent to
-@samp{^}. (The @sc{posix} standard only specifies the use of @samp{^}
-for exponentiation.)
-@end table
-
-@node Concatenation, Comparison Ops, Arithmetic Ops, Expressions
-@section String Concatenation
-
-@cindex string operators
-@cindex operators, string
-@cindex concatenation
-There is only one string operation: concatenation. It does not have a
-specific operator to represent it. Instead, concatenation is performed by
-writing expressions next to one another, with no operator. For example:
-
-@example
-awk '@{ print "Field number one: " $1 @}' BBS-list
-@end example
-
-@noindent
-produces, for the first record in @file{BBS-list}:
-
-@example
-Field number one: aardvark
-@end example
-
-Without the space in the string constant after the @samp{:}, the line
-would run together. For example:
-
-@example
-awk '@{ print "Field number one:" $1 @}' BBS-list
-@end example
-
-@noindent
-produces, for the first record in @file{BBS-list}:
-
-@example
-Field number one:aardvark
-@end example
-
-Since string concatenation does not have an explicit operator, it is
-often necessary to insure that it happens where you want it to by
-enclosing the items to be concatenated in parentheses. For example, the
-following code fragment does not concatenate @code{file} and @code{name}
-as you might expect:
-
-@example
-file = "file"
-name = "name"
-print "something meaningful" > file name
-@end example
-
-@noindent
-It is necessary to use the following:
-
-@example
-print "something meaningful" > (file name)
-@end example
-
-We recommend you use parentheses around concatenation in all but the
-most common contexts (such as in the right-hand operand of @samp{=}).
-
-@ignore
-@code{gawk} actually now allows a concatenation on the right hand
-side of a @code{>} redirection, but other @code{awk}s don't. So for
-now we won't mention that fact.
-@end ignore
-
-@node Comparison Ops, Boolean Ops, Concatenation, Expressions
-@section Comparison Expressions
-@cindex comparison expressions
-@cindex expressions, comparison
-@cindex relational operators
-@cindex operators, relational
-@cindex regexp operators
-
-@dfn{Comparison expressions} compare strings or numbers for
-relationships such as equality. They are written using @dfn{relational
-operators}, which are a superset of those in C. Here is a table of
-them:
-
-@table @code
-@item @var{x} < @var{y}
-True if @var{x} is less than @var{y}.
-
-@item @var{x} <= @var{y}
-True if @var{x} is less than or equal to @var{y}.
-
-@item @var{x} > @var{y}
-True if @var{x} is greater than @var{y}.
-
-@item @var{x} >= @var{y}
-True if @var{x} is greater than or equal to @var{y}.
-
-@item @var{x} == @var{y}
-True if @var{x} is equal to @var{y}.
-
-@item @var{x} != @var{y}
-True if @var{x} is not equal to @var{y}.
-
-@item @var{x} ~ @var{y}
-True if the string @var{x} matches the regexp denoted by @var{y}.
-
-@item @var{x} !~ @var{y}
-True if the string @var{x} does not match the regexp denoted by @var{y}.
-
-@item @var{subscript} in @var{array}
-True if array @var{array} has an element with the subscript @var{subscript}.
-@end table
-
-Comparison expressions have the value 1 if true and 0 if false.
-
-The rules @code{gawk} uses for performing comparisons are based on those
-in draft 11.2 of the @sc{posix} standard. The @sc{posix} standard introduced
-the concept of a @dfn{numeric string}, which is simply a string that looks
-like a number, for example, @code{@w{" +2"}}.
-
-@vindex CONVFMT
-When performing a relational operation, @code{gawk} considers the type of an
-operand to be the type it received on its last @emph{assignment}, rather
-than the type of its last @emph{use}
-(@pxref{Values, ,Numeric and String Values}).
-This type is @emph{unknown} when the operand is from an ``external'' source:
-field variables, command line arguments, array elements resulting from a
-@code{split} operation, and the value of an @code{ENVIRON} element.
-In this case only, if the operand is a numeric string, then it is
-considered to be of both string type and numeric type. If at least one
-operand of a comparison is of string type only, then a string
-comparison is performed. Any numeric operand will be converted to a
-string using the value of @code{CONVFMT}
-(@pxref{Conversion, ,Conversion of Strings and Numbers}).
-If one operand of a comparison is numeric, and the other operand is
-either numeric or both numeric and string, then @code{gawk} does a
-numeric comparison. If both operands have both types, then the
-comparison is numeric. Strings are compared
-by comparing the first character of each, then the second character of each,
-and so on. Thus @code{"10"} is less than @code{"9"}. If there are two
-strings where one is a prefix of the other, the shorter string is less than
-the longer one. Thus @code{"abc"} is less than @code{"abcd"}.@refill
-
-Here are some sample expressions, how @code{gawk} compares them, and what
-the result of the comparison is.
-
-@table @code
-@item 1.5 <= 2.0
-numeric comparison (true)
-
-@item "abc" >= "xyz"
-string comparison (false)
-
-@item 1.5 != " +2"
-string comparison (true)
-
-@item "1e2" < "3"
-string comparison (true)
-
-@item a = 2; b = "2"
-@itemx a == b
-string comparison (true)
-@end table
-
-@example
-echo 1e2 3 | awk '@{ print ($1 < $2) ? "true" : "false" @}'
-@end example
-
-@noindent
-prints @samp{false} since both @code{$1} and @code{$2} are numeric
-strings and thus have both string and numeric types, thus dictating
-a numeric comparison.
-
-The purpose of the comparison rules and the use of numeric strings is
-to attempt to produce the behavior that is ``least surprising,'' while
-still ``doing the right thing.''
-
-String comparisons and regular expression comparisons are very different.
-For example,
-
-@example
-$1 == "foo"
-@end example
-
-@noindent
-has the value of 1, or is true, if the first field of the current input
-record is precisely @samp{foo}. By contrast,
-
-@example
-$1 ~ /foo/
-@end example
-
-@noindent
-has the value 1 if the first field contains @samp{foo}, such as @samp{foobar}.
-
-The right hand operand of the @samp{~} and @samp{!~} operators may be
-either a constant regexp (@code{/@dots{}/}), or it may be an ordinary
-expression, in which case the value of the expression as a string is a
-dynamic regexp (@pxref{Regexp Usage, ,How to Use Regular Expressions}).
-
-@cindex regexp as expression
-In very recent implementations of @code{awk}, a constant regular
-expression in slashes by itself is also an expression. The regexp
-@code{/@var{regexp}/} is an abbreviation for this comparison expression:
-
-@example
-$0 ~ /@var{regexp}/
-@end example
-
-In some contexts it may be necessary to write parentheses around the
-regexp to avoid confusing the @code{gawk} parser. For example,
-@code{(/x/ - /y/) > threshold} is not allowed, but @code{((/x/) - (/y/))
-> threshold} parses properly.
-
-One special place where @code{/foo/} is @emph{not} an abbreviation for
-@code{$0 ~ /foo/} is when it is the right-hand operand of @samp{~} or
-@samp{!~}! @xref{Constants, ,Constant Expressions}, where this is
-discussed in more detail.
-
-@node Boolean Ops, Assignment Ops, Comparison Ops, Expressions
-@section Boolean Expressions
-@cindex expressions, boolean
-@cindex boolean expressions
-@cindex operators, boolean
-@cindex boolean operators
-@cindex logical operations
-@cindex and operator
-@cindex or operator
-@cindex not operator
-
-A @dfn{boolean expression} is a combination of comparison expressions or
-matching expressions, using the boolean operators ``or''
-(@samp{||}), ``and'' (@samp{&&}), and ``not'' (@samp{!}), along with
-parentheses to control nesting. The truth of the boolean expression is
-computed by combining the truth values of the component expressions.
-
-Boolean expressions can be used wherever comparison and matching
-expressions can be used. They can be used in @code{if}, @code{while}
-@code{do} and @code{for} statements. They have numeric values (1 if true,
-0 if false), which come into play if the result of the boolean expression
-is stored in a variable, or used in arithmetic.@refill
-
-In addition, every boolean expression is also a valid boolean pattern, so
-you can use it as a pattern to control the execution of rules.
-
-Here are descriptions of the three boolean operators, with an example of
-each. It may be instructive to compare these examples with the
-analogous examples of boolean patterns
-(@pxref{Boolean Patterns, ,Boolean Operators and Patterns}), which
-use the same boolean operators in patterns instead of expressions.@refill
-
-@table @code
-@item @var{boolean1} && @var{boolean2}
-True if both @var{boolean1} and @var{boolean2} are true. For example,
-the following statement prints the current input record if it contains
-both @samp{2400} and @samp{foo}.@refill
-
-@smallexample
-if ($0 ~ /2400/ && $0 ~ /foo/) print
-@end smallexample
-
-The subexpression @var{boolean2} is evaluated only if @var{boolean1}
-is true. This can make a difference when @var{boolean2} contains
-expressions that have side effects: in the case of @code{$0 ~ /foo/ &&
-($2 == bar++)}, the variable @code{bar} is not incremented if there is
-no @samp{foo} in the record.
-
-@item @var{boolean1} || @var{boolean2}
-True if at least one of @var{boolean1} or @var{boolean2} is true.
-For example, the following command prints all records in the input
-file @file{BBS-list} that contain @emph{either} @samp{2400} or
-@samp{foo}, or both.@refill
-
-@smallexample
-awk '@{ if ($0 ~ /2400/ || $0 ~ /foo/) print @}' BBS-list
-@end smallexample
-
-The subexpression @var{boolean2} is evaluated only if @var{boolean1}
-is false. This can make a difference when @var{boolean2} contains
-expressions that have side effects.
-
-@item !@var{boolean}
-True if @var{boolean} is false. For example, the following program prints
-all records in the input file @file{BBS-list} that do @emph{not} contain the
-string @samp{foo}.
-
-@smallexample
-awk '@{ if (! ($0 ~ /foo/)) print @}' BBS-list
-@end smallexample
-@end table
-
-@node Assignment Ops, Increment Ops, Boolean Ops, Expressions
-@section Assignment Expressions
-@cindex assignment operators
-@cindex operators, assignment
-@cindex expressions, assignment
-
-An @dfn{assignment} is an expression that stores a new value into a
-variable. For example, let's assign the value 1 to the variable
-@code{z}:@refill
-
-@example
-z = 1
-@end example
-
-After this expression is executed, the variable @code{z} has the value 1.
-Whatever old value @code{z} had before the assignment is forgotten.
-
-Assignments can store string values also. For example, this would store
-the value @code{"this food is good"} in the variable @code{message}:
-
-@example
-thing = "food"
-predicate = "good"
-message = "this " thing " is " predicate
-@end example
-
-@noindent
-(This also illustrates concatenation of strings.)
-
-The @samp{=} sign is called an @dfn{assignment operator}. It is the
-simplest assignment operator because the value of the right-hand
-operand is stored unchanged.
-
-@cindex side effect
-Most operators (addition, concatenation, and so on) have no effect
-except to compute a value. If you ignore the value, you might as well
-not use the operator. An assignment operator is different; it does
-produce a value, but even if you ignore the value, the assignment still
-makes itself felt through the alteration of the variable. We call this
-a @dfn{side effect}.
-
-@cindex lvalue
-The left-hand operand of an assignment need not be a variable
-(@pxref{Variables}); it can also be a field
-(@pxref{Changing Fields, ,Changing the Contents of a Field}) or
-an array element (@pxref{Arrays, ,Arrays in @code{awk}}).
-These are all called @dfn{lvalues},
-which means they can appear on the left-hand side of an assignment operator.
-The right-hand operand may be any expression; it produces the new value
-which the assignment stores in the specified variable, field or array
-element.@refill
-
-It is important to note that variables do @emph{not} have permanent types.
-The type of a variable is simply the type of whatever value it happens
-to hold at the moment. In the following program fragment, the variable
-@code{foo} has a numeric value at first, and a string value later on:
-
-@example
-foo = 1
-print foo
-foo = "bar"
-print foo
-@end example
-
-@noindent
-When the second assignment gives @code{foo} a string value, the fact that
-it previously had a numeric value is forgotten.
-
-An assignment is an expression, so it has a value: the same value that
-is assigned. Thus, @code{z = 1} as an expression has the value 1.
-One consequence of this is that you can write multiple assignments together:
-
-@example
-x = y = z = 0
-@end example
-
-@noindent
-stores the value 0 in all three variables. It does this because the
-value of @code{z = 0}, which is 0, is stored into @code{y}, and then
-the value of @code{y = z = 0}, which is 0, is stored into @code{x}.
-
-You can use an assignment anywhere an expression is called for. For
-example, it is valid to write @code{x != (y = 1)} to set @code{y} to 1
-and then test whether @code{x} equals 1. But this style tends to make
-programs hard to read; except in a one-shot program, you should
-rewrite it to get rid of such nesting of assignments. This is never very
-hard.
-
-Aside from @samp{=}, there are several other assignment operators that
-do arithmetic with the old value of the variable. For example, the
-operator @samp{+=} computes a new value by adding the right-hand value
-to the old value of the variable. Thus, the following assignment adds
-5 to the value of @code{foo}:
-
-@example
-foo += 5
-@end example
-
-@noindent
-This is precisely equivalent to the following:
-
-@example
-foo = foo + 5
-@end example
-
-@noindent
-Use whichever one makes the meaning of your program clearer.
-
-Here is a table of the arithmetic assignment operators. In each
-case, the right-hand operand is an expression whose value is converted
-to a number.
-
-@table @code
-@item @var{lvalue} += @var{increment}
-Adds @var{increment} to the value of @var{lvalue} to make the new value
-of @var{lvalue}.
-
-@item @var{lvalue} -= @var{decrement}
-Subtracts @var{decrement} from the value of @var{lvalue}.
-
-@item @var{lvalue} *= @var{coefficient}
-Multiplies the value of @var{lvalue} by @var{coefficient}.
-
-@item @var{lvalue} /= @var{quotient}
-Divides the value of @var{lvalue} by @var{quotient}.
-
-@item @var{lvalue} %= @var{modulus}
-Sets @var{lvalue} to its remainder by @var{modulus}.
-
-@item @var{lvalue} ^= @var{power}
-@itemx @var{lvalue} **= @var{power}
-Raises @var{lvalue} to the power @var{power}.
-(Only the @code{^=} operator is specified by @sc{posix}.)
-@end table
-
-@ignore
-From: gatech!ames!elroy!cit-vax!EQL.Caltech.Edu!rankin (Pat Rankin)
- In the discussion of assignment operators, it states that
-``foo += 5'' "is precisely equivalent to" ``foo = foo + 5'' (p.77). That
-may be true for simple variables, but it's not true for expressions with
-side effects, like array references. For proof, try
- BEGIN {
- foo[rand()] += 5; for (x in foo) print x, foo[x]
- bar[rand()] = bar[rand()] + 5; for (x in bar) print x, bar[x]
- }
-I suspect that the original statement is simply untrue--that '+=' is more
-efficient in all cases.
-
-ADR --- Try to add something about this here for the next go 'round.
-@end ignore
-
-@node Increment Ops, Conversion, Assignment Ops, Expressions
-@section Increment Operators
-
-@cindex increment operators
-@cindex operators, increment
-@dfn{Increment operators} increase or decrease the value of a variable
-by 1. You could do the same thing with an assignment operator, so
-the increment operators add no power to the @code{awk} language; but they
-are convenient abbreviations for something very common.
-
-The operator to add 1 is written @samp{++}. It can be used to increment
-a variable either before or after taking its value.
-
-To pre-increment a variable @var{v}, write @code{++@var{v}}. This adds
-1 to the value of @var{v} and that new value is also the value of this
-expression. The assignment expression @code{@var{v} += 1} is completely
-equivalent.
-
-Writing the @samp{++} after the variable specifies post-increment. This
-increments the variable value just the same; the difference is that the
-value of the increment expression itself is the variable's @emph{old}
-value. Thus, if @code{foo} has the value 4, then the expression @code{foo++}
-has the value 4, but it changes the value of @code{foo} to 5.
-
-The post-increment @code{foo++} is nearly equivalent to writing @code{(foo
-+= 1) - 1}. It is not perfectly equivalent because all numbers in
-@code{awk} are floating point: in floating point, @code{foo + 1 - 1} does
-not necessarily equal @code{foo}. But the difference is minute as
-long as you stick to numbers that are fairly small (less than a trillion).
-
-Any lvalue can be incremented. Fields and array elements are incremented
-just like variables. (Use @samp{$(i++)} when you wish to do a field reference
-and a variable increment at the same time. The parentheses are necessary
-because of the precedence of the field reference operator, @samp{$}.)
-@c expert information in the last parenthetical remark
-
-The decrement operator @samp{--} works just like @samp{++} except that
-it subtracts 1 instead of adding. Like @samp{++}, it can be used before
-the lvalue to pre-decrement or after it to post-decrement.
-
-Here is a summary of increment and decrement expressions.
-
-@table @code
-@item ++@var{lvalue}
-This expression increments @var{lvalue} and the new value becomes the
-value of this expression.
-
-@item @var{lvalue}++
-This expression causes the contents of @var{lvalue} to be incremented.
-The value of the expression is the @emph{old} value of @var{lvalue}.
-
-@item --@var{lvalue}
-Like @code{++@var{lvalue}}, but instead of adding, it subtracts. It
-decrements @var{lvalue} and delivers the value that results.
-
-@item @var{lvalue}--
-Like @code{@var{lvalue}++}, but instead of adding, it subtracts. It
-decrements @var{lvalue}. The value of the expression is the @emph{old}
-value of @var{lvalue}.
-@end table
-
-@node Conversion, Values, Increment Ops, Expressions
-@section Conversion of Strings and Numbers
-
-@cindex conversion of strings and numbers
-Strings are converted to numbers, and numbers to strings, if the context
-of the @code{awk} program demands it. For example, if the value of
-either @code{foo} or @code{bar} in the expression @code{foo + bar}
-happens to be a string, it is converted to a number before the addition
-is performed. If numeric values appear in string concatenation, they
-are converted to strings. Consider this:@refill
-
-@example
-two = 2; three = 3
-print (two three) + 4
-@end example
-
-@noindent
-This eventually prints the (numeric) value 27. The numeric values of
-the variables @code{two} and @code{three} are converted to strings and
-concatenated together, and the resulting string is converted back to the
-number 23, to which 4 is then added.
-
-If, for some reason, you need to force a number to be converted to a
-string, concatenate the null string with that number. To force a string
-to be converted to a number, add zero to that string.
-
-A string is converted to a number by interpreting a numeric prefix
-of the string as numerals:
-@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1000, and @code{"25fix"}
-has a numeric value of 25.
-Strings that can't be interpreted as valid numbers are converted to
-zero.
-
-@vindex CONVFMT
-The exact manner in which numbers are converted into strings is controlled
-by the @code{awk} built-in variable @code{CONVFMT} (@pxref{Built-in Variables}).
-Numbers are converted using a special version of the @code{sprintf} function
-(@pxref{Built-in, ,Built-in Functions}) with @code{CONVFMT} as the format
-specifier.@refill
-
-@code{CONVFMT}'s default value is @code{"%.6g"}, which prints a value with
-at least six significant digits. For some applications you will want to
-change it to specify more precision. Double precision on most modern
-machines gives you 16 or 17 decimal digits of precision.
-
-Strange results can happen if you set @code{CONVFMT} to a string that doesn't
-tell @code{sprintf} how to format floating point numbers in a useful way.
-For example, if you forget the @samp{%} in the format, all numbers will be
-converted to the same constant string.@refill
-
-As a special case, if a number is an integer, then the result of converting
-it to a string is @emph{always} an integer, no matter what the value of
-@code{CONVFMT} may be. Given the following code fragment:
-
-@example
-CONVFMT = "%2.2f"
-a = 12
-b = a ""
-@end example
-
-@noindent
-@code{b} has the value @code{"12"}, not @code{"12.00"}.
-
-@ignore
-For the 2.14 version, describe the ``stickyness'' of conversions. Right now
-the manual assumes everywhere that variables are either numbers or strings;
-in fact both kinds of values may be valid. If both happen to be valid, a
-conversion isn't necessary and isn't done. Revising the manual to be
-consistent with this, though, is too big a job to tackle at the moment.
-
-7/92: This has sort of been done, only the section isn't completely right!
- What to do?
-7/92: Pretty much fixed, at least for the short term, thanks to text
- from David.
-@end ignore
-
-@vindex OFMT
-Prior to the @sc{posix} standard, @code{awk} specified that the value
-of @code{OFMT} was used for converting numbers to strings. @code{OFMT}
-specifies the output format to use when printing numbers with @code{print}.
-@code{CONVFMT} was introduced in order to separate the semantics of
-conversions from the semantics of printing. Both @code{CONVFMT} and
-@code{OFMT} have the same default value: @code{"%.6g"}. In the vast majority
-of cases, old @code{awk} programs will not change their behavior.
-However, this use of @code{OFMT} is something to keep in mind if you must
-port your program to other implementations of @code{awk}; we recommend
-that instead of changing your programs, you just port @code{gawk} itself!@refill
-
-@node Values, Conditional Exp, Conversion, Expressions
-@section Numeric and String Values
-@cindex conversion of strings and numbers
-
-Through most of this manual, we present @code{awk} values (such as constants,
-fields, or variables) as @emph{either} numbers @emph{or} strings. This is
-a convenient way to think about them, since typically they are used in only
-one way, or the other.
-
-In truth though, @code{awk} values can be @emph{both} string and
-numeric, at the same time. Internally, @code{awk} represents values
-with a string, a (floating point) number, and an indication that one,
-the other, or both representations of the value are valid.
-
-Keeping track of both kinds of values is important for execution
-efficiency: a variable can acquire a string value the first time it
-is used as a string, and then that string value can be used until the
-variable is assigned a new value. Thus, if a variable with only a numeric
-value is used in several concatenations in a row, it only has to be given
-a string representation once. The numeric value remains valid, so that
-no conversion back to a number is necessary if the variable is later used
-in an arithmetic expression.
-
-Tracking both kinds of values is also important for precise numerical
-calculations. Consider the following:
-
-@smallexample
-a = 123.321
-CONVFMT = "%3.1f"
-b = a " is a number"
-c = a + 1.654
-@end smallexample
-
-@noindent
-The variable @code{a} receives a string value in the concatenation and
-assignment to @code{b}. The string value of @code{a} is @code{"123.3"}.
-If the numeric value was lost when it was converted to a string, then the
-numeric use of @code{a} in the last statement would lose information.
-@code{c} would be assigned the value 124.954 instead of 124.975.
-Such errors accumulate rapidly, and very adversely affect numeric
-computations.@refill
-
-Once a numeric value acquires a corresponding string value, it stays valid
-until a new assignment is made. If @code{CONVFMT}
-(@pxref{Conversion, ,Conversion of Strings and Numbers}) changes in the
-meantime, the old string value will still be used. For example:@refill
-
-@smallexample
-BEGIN @{
- CONVFMT = "%2.2f"
- a = 123.456
- b = a "" # force `a' to have string value too
- printf "a = %s\n", a
- CONVFMT = "%.6g"
- printf "a = %s\n", a
- a += 0 # make `a' numeric only again
- printf "a = %s\n", a # use `a' as string
-@}
-@end smallexample
-
-@noindent
-This program prints @samp{a = 123.46} twice, and then prints
-@samp{a = 123.456}.
-
-@xref{Conversion, ,Conversion of Strings and Numbers}, for the rules that
-specify how string values are made from numeric values.
-
-@node Conditional Exp, Function Calls, Values, Expressions
-@section Conditional Expressions
-@cindex conditional expression
-@cindex expression, conditional
-
-A @dfn{conditional expression} is a special kind of expression with
-three operands. It allows you to use one expression's value to select
-one of two other expressions.
-
-The conditional expression looks the same as in the C language:
-
-@example
-@var{selector} ? @var{if-true-exp} : @var{if-false-exp}
-@end example
-
-@noindent
-There are three subexpressions. The first, @var{selector}, is always
-computed first. If it is ``true'' (not zero and not null) then
-@var{if-true-exp} is computed next and its value becomes the value of
-the whole expression. Otherwise, @var{if-false-exp} is computed next
-and its value becomes the value of the whole expression.@refill
-
-For example, this expression produces the absolute value of @code{x}:
-
-@example
-x > 0 ? x : -x
-@end example
-
-Each time the conditional expression is computed, exactly one of
-@var{if-true-exp} and @var{if-false-exp} is computed; the other is ignored.
-This is important when the expressions contain side effects. For example,
-this conditional expression examines element @code{i} of either array
-@code{a} or array @code{b}, and increments @code{i}.
-
-@example
-x == y ? a[i++] : b[i++]
-@end example
-
-@noindent
-This is guaranteed to increment @code{i} exactly once, because each time
-one or the other of the two increment expressions is executed,
-and the other is not.
-
-@node Function Calls, Precedence, Conditional Exp, Expressions
-@section Function Calls
-@cindex function call
-@cindex calling a function
-
-A @dfn{function} is a name for a particular calculation. Because it has
-a name, you can ask for it by name at any point in the program. For
-example, the function @code{sqrt} computes the square root of a number.
-
-A fixed set of functions are @dfn{built-in}, which means they are
-available in every @code{awk} program. The @code{sqrt} function is one
-of these. @xref{Built-in, ,Built-in Functions}, for a list of built-in
-functions and their descriptions. In addition, you can define your own
-functions in the program for use elsewhere in the same program.
-@xref{User-defined, ,User-defined Functions}, for how to do this.@refill
-
-@cindex arguments in function call
-The way to use a function is with a @dfn{function call} expression,
-which consists of the function name followed by a list of
-@dfn{arguments} in parentheses. The arguments are expressions which
-give the raw materials for the calculation that the function will do.
-When there is more than one argument, they are separated by commas. If
-there are no arguments, write just @samp{()} after the function name.
-Here are some examples:
-
-@example
-sqrt(x^2 + y^2) # @r{One argument}
-atan2(y, x) # @r{Two arguments}
-rand() # @r{No arguments}
-@end example
-
-@strong{Do not put any space between the function name and the
-open-parenthesis!} A user-defined function name looks just like the name of
-a variable, and space would make the expression look like concatenation
-of a variable with an expression inside parentheses. Space before the
-parenthesis is harmless with built-in functions, but it is best not to get
-into the habit of using space to avoid mistakes with user-defined
-functions.
-
-Each function expects a particular number of arguments. For example, the
-@code{sqrt} function must be called with a single argument, the number
-to take the square root of:
-
-@example
-sqrt(@var{argument})
-@end example
-
-Some of the built-in functions allow you to omit the final argument.
-If you do so, they use a reasonable default.
-@xref{Built-in, ,Built-in Functions}, for full details. If arguments
-are omitted in calls to user-defined functions, then those arguments are
-treated as local variables, initialized to the null string
-(@pxref{User-defined, ,User-defined Functions}).@refill
-
-Like every other expression, the function call has a value, which is
-computed by the function based on the arguments you give it. In this
-example, the value of @code{sqrt(@var{argument})} is the square root of the
-argument. A function can also have side effects, such as assigning the
-values of certain variables or doing I/O.
-
-Here is a command to read numbers, one number per line, and print the
-square root of each one:
-
-@example
-awk '@{ print "The square root of", $1, "is", sqrt($1) @}'
-@end example
-
-@node Precedence, , Function Calls, Expressions
-@section Operator Precedence (How Operators Nest)
-@cindex precedence
-@cindex operator precedence
-
-@dfn{Operator precedence} determines how operators are grouped, when
-different operators appear close by in one expression. For example,
-@samp{*} has higher precedence than @samp{+}; thus, @code{a + b * c}
-means to multiply @code{b} and @code{c}, and then add @code{a} to the
-product (i.e., @code{a + (b * c)}).
-
-You can overrule the precedence of the operators by using parentheses.
-You can think of the precedence rules as saying where the
-parentheses are assumed if you do not write parentheses yourself. In
-fact, it is wise to always use parentheses whenever you have an unusual
-combination of operators, because other people who read the program may
-not remember what the precedence is in this case. You might forget,
-too; then you could make a mistake. Explicit parentheses will help prevent
-any such mistake.
-
-When operators of equal precedence are used together, the leftmost
-operator groups first, except for the assignment, conditional and
-exponentiation operators, which group in the opposite order.
-Thus, @code{a - b + c} groups as @code{(a - b) + c};
-@code{a = b = c} groups as @code{a = (b = c)}.@refill
-
-The precedence of prefix unary operators does not matter as long as only
-unary operators are involved, because there is only one way to parse
-them---innermost first. Thus, @code{$++i} means @code{$(++i)} and
-@code{++$x} means @code{++($x)}. However, when another operator follows
-the operand, then the precedence of the unary operators can matter.
-Thus, @code{$x^2} means @code{($x)^2}, but @code{-x^2} means
-@code{-(x^2)}, because @samp{-} has lower precedence than @samp{^}
-while @samp{$} has higher precedence.
-
-Here is a table of the operators of @code{awk}, in order of increasing
-precedence:
-
-@table @asis
-@item assignment
-@samp{=}, @samp{+=}, @samp{-=}, @samp{*=}, @samp{/=}, @samp{%=},
-@samp{^=}, @samp{**=}. These operators group right-to-left.
-(The @samp{**=} operator is not specified by @sc{posix}.)
-
-@item conditional
-@samp{?:}. This operator groups right-to-left.
-
-@item logical ``or''.
-@samp{||}.
-
-@item logical ``and''.
-@samp{&&}.
-
-@item array membership
-@samp{in}.
-
-@item matching
-@samp{~}, @samp{!~}.
-
-@item relational, and redirection
-The relational operators and the redirections have the same precedence
-level. Characters such as @samp{>} serve both as relationals and as
-redirections; the context distinguishes between the two meanings.
-
-The relational operators are @samp{<}, @samp{<=}, @samp{==}, @samp{!=},
-@samp{>=} and @samp{>}.
-
-The I/O redirection operators are @samp{<}, @samp{>}, @samp{>>} and
-@samp{|}.
-
-Note that I/O redirection operators in @code{print} and @code{printf}
-statements belong to the statement level, not to expressions. The
-redirection does not produce an expression which could be the operand of
-another operator. As a result, it does not make sense to use a
-redirection operator near another operator of lower precedence, without
-parentheses. Such combinations, for example @samp{print foo > a ? b :
-c}, result in syntax errors.
-
-@item concatenation
-No special token is used to indicate concatenation.
-The operands are simply written side by side.
-
-@item add, subtract
-@samp{+}, @samp{-}.
-
-@item multiply, divide, mod
-@samp{*}, @samp{/}, @samp{%}.
-
-@item unary plus, minus, ``not''
-@samp{+}, @samp{-}, @samp{!}.
-
-@item exponentiation
-@samp{^}, @samp{**}. These operators group right-to-left.
-(The @samp{**} operator is not specified by @sc{posix}.)
-
-@item increment, decrement
-@samp{++}, @samp{--}.
-
-@item field
-@samp{$}.
-@end table
-
-@node Statements, Arrays, Expressions, Top
-@chapter Control Statements in Actions
-@cindex control statement
-
-@dfn{Control statements} such as @code{if}, @code{while}, and so on
-control the flow of execution in @code{awk} programs. Most of the
-control statements in @code{awk} are patterned on similar statements in
-C.
-
-All the control statements start with special keywords such as @code{if}
-and @code{while}, to distinguish them from simple expressions.
-
-Many control statements contain other statements; for example, the
-@code{if} statement contains another statement which may or may not be
-executed. The contained statement is called the @dfn{body}. If you
-want to include more than one statement in the body, group them into a
-single compound statement with curly braces, separating them with
-newlines or semicolons.
-
-@menu
-* If Statement:: Conditionally execute
- some @code{awk} statements.
-* While Statement:: Loop until some condition is satisfied.
-* Do Statement:: Do specified action while looping until some
- condition is satisfied.
-* For Statement:: Another looping statement, that provides
- initialization and increment clauses.
-* Break Statement:: Immediately exit the innermost enclosing loop.
-* Continue Statement:: Skip to the end of the innermost
- enclosing loop.
-* Next Statement:: Stop processing the current input record.
-* Next File Statement:: Stop processing the current file.
-* Exit Statement:: Stop execution of @code{awk}.
-@end menu
-
-@node If Statement, While Statement, Statements, Statements
-@section The @code{if} Statement
-
-@cindex @code{if} statement
-The @code{if}-@code{else} statement is @code{awk}'s decision-making
-statement. It looks like this:@refill
-
-@example
-if (@var{condition}) @var{then-body} @r{[}else @var{else-body}@r{]}
-@end example
-
-@noindent
-@var{condition} is an expression that controls what the rest of the
-statement will do. If @var{condition} is true, @var{then-body} is
-executed; otherwise, @var{else-body} is executed (assuming that the
-@code{else} clause is present). The @code{else} part of the statement is
-optional. The condition is considered false if its value is zero or
-the null string, and true otherwise.@refill
-
-Here is an example:
-
-@example
-if (x % 2 == 0)
- print "x is even"
-else
- print "x is odd"
-@end example
-
-In this example, if the expression @code{x % 2 == 0} is true (that is,
-the value of @code{x} is divisible by 2), then the first @code{print}
-statement is executed, otherwise the second @code{print} statement is
-performed.@refill
-
-If the @code{else} appears on the same line as @var{then-body}, and
-@var{then-body} is not a compound statement (i.e., not surrounded by
-curly braces), then a semicolon must separate @var{then-body} from
-@code{else}. To illustrate this, let's rewrite the previous example:
-
-@example
-awk '@{ if (x % 2 == 0) print "x is even"; else
- print "x is odd" @}'
-@end example
-
-@noindent
-If you forget the @samp{;}, @code{awk} won't be able to parse the
-statement, and you will get a syntax error.
-
-We would not actually write this example this way, because a human
-reader might fail to see the @code{else} if it were not the first thing
-on its line.
-
-@node While Statement, Do Statement, If Statement, Statements
-@section The @code{while} Statement
-@cindex @code{while} statement
-@cindex loop
-@cindex body of a loop
-
-In programming, a @dfn{loop} means a part of a program that is (or at least can
-be) executed two or more times in succession.
-
-The @code{while} statement is the simplest looping statement in
-@code{awk}. It repeatedly executes a statement as long as a condition is
-true. It looks like this:
-
-@example
-while (@var{condition})
- @var{body}
-@end example
-
-@noindent
-Here @var{body} is a statement that we call the @dfn{body} of the loop,
-and @var{condition} is an expression that controls how long the loop
-keeps running.
-
-The first thing the @code{while} statement does is test @var{condition}.
-If @var{condition} is true, it executes the statement @var{body}.
-(@var{condition} is true when the value
-is not zero and not a null string.) After @var{body} has been executed,
-@var{condition} is tested again, and if it is still true, @var{body} is
-executed again. This process repeats until @var{condition} is no longer
-true. If @var{condition} is initially false, the body of the loop is
-never executed.@refill
-
-This example prints the first three fields of each record, one per line.
-
-@example
-awk '@{ i = 1
- while (i <= 3) @{
- print $i
- i++
- @}
-@}'
-@end example
-
-@noindent
-Here the body of the loop is a compound statement enclosed in braces,
-containing two statements.
-
-The loop works like this: first, the value of @code{i} is set to 1.
-Then, the @code{while} tests whether @code{i} is less than or equal to
-three. This is the case when @code{i} equals one, so the @code{i}-th
-field is printed. Then the @code{i++} increments the value of @code{i}
-and the loop repeats. The loop terminates when @code{i} reaches 4.
-
-As you can see, a newline is not required between the condition and the
-body; but using one makes the program clearer unless the body is a
-compound statement or is very simple. The newline after the open-brace
-that begins the compound statement is not required either, but the
-program would be hard to read without it.
-
-@node Do Statement, For Statement, While Statement, Statements
-@section The @code{do}-@code{while} Statement
-
-The @code{do} loop is a variation of the @code{while} looping statement.
-The @code{do} loop executes the @var{body} once, then repeats @var{body}
-as long as @var{condition} is true. It looks like this:
-
-@example
-do
- @var{body}
-while (@var{condition})
-@end example
-
-Even if @var{condition} is false at the start, @var{body} is executed at
-least once (and only once, unless executing @var{body} makes
-@var{condition} true). Contrast this with the corresponding
-@code{while} statement:
-
-@example
-while (@var{condition})
- @var{body}
-@end example
-
-@noindent
-This statement does not execute @var{body} even once if @var{condition}
-is false to begin with.
-
-Here is an example of a @code{do} statement:
-
-@example
-awk '@{ i = 1
- do @{
- print $0
- i++
- @} while (i <= 10)
-@}'
-@end example
-
-@noindent
-prints each input record ten times. It isn't a very realistic example,
-since in this case an ordinary @code{while} would do just as well. But
-this reflects actual experience; there is only occasionally a real use
-for a @code{do} statement.@refill
-
-@node For Statement, Break Statement, Do Statement, Statements
-@section The @code{for} Statement
-@cindex @code{for} statement
-
-The @code{for} statement makes it more convenient to count iterations of a
-loop. The general form of the @code{for} statement looks like this:@refill
-
-@example
-for (@var{initialization}; @var{condition}; @var{increment})
- @var{body}
-@end example
-
-@noindent
-This statement starts by executing @var{initialization}. Then, as long
-as @var{condition} is true, it repeatedly executes @var{body} and then
-@var{increment}. Typically @var{initialization} sets a variable to
-either zero or one, @var{increment} adds 1 to it, and @var{condition}
-compares it against the desired number of iterations.
-
-Here is an example of a @code{for} statement:
-
-@example
-@group
-awk '@{ for (i = 1; i <= 3; i++)
- print $i
-@}'
-@end group
-@end example
-
-@noindent
-This prints the first three fields of each input record, one field per
-line.
-
-In the @code{for} statement, @var{body} stands for any statement, but
-@var{initialization}, @var{condition} and @var{increment} are just
-expressions. You cannot set more than one variable in the
-@var{initialization} part unless you use a multiple assignment statement
-such as @code{x = y = 0}, which is possible only if all the initial values
-are equal. (But you can initialize additional variables by writing
-their assignments as separate statements preceding the @code{for} loop.)
-
-The same is true of the @var{increment} part; to increment additional
-variables, you must write separate statements at the end of the loop.
-The C compound expression, using C's comma operator, would be useful in
-this context, but it is not supported in @code{awk}.
-
-Most often, @var{increment} is an increment expression, as in the
-example above. But this is not required; it can be any expression
-whatever. For example, this statement prints all the powers of 2
-between 1 and 100:
-
-@example
-for (i = 1; i <= 100; i *= 2)
- print i
-@end example
-
-Any of the three expressions in the parentheses following the @code{for} may
-be omitted if there is nothing to be done there. Thus, @w{@samp{for (;x
-> 0;)}} is equivalent to @w{@samp{while (x > 0)}}. If the
-@var{condition} is omitted, it is treated as @var{true}, effectively
-yielding an @dfn{infinite loop} (i.e., a loop that will never
-terminate).@refill
-
-In most cases, a @code{for} loop is an abbreviation for a @code{while}
-loop, as shown here:
-
-@example
-@var{initialization}
-while (@var{condition}) @{
- @var{body}
- @var{increment}
-@}
-@end example
-
-@noindent
-The only exception is when the @code{continue} statement
-(@pxref{Continue Statement, ,The @code{continue} Statement}) is used
-inside the loop; changing a @code{for} statement to a @code{while}
-statement in this way can change the effect of the @code{continue}
-statement inside the loop.@refill
-
-There is an alternate version of the @code{for} loop, for iterating over
-all the indices of an array:
-
-@example
-for (i in array)
- @var{do something with} array[i]
-@end example
-
-@noindent
-@xref{Arrays, ,Arrays in @code{awk}}, for more information on this
-version of the @code{for} loop.
-
-The @code{awk} language has a @code{for} statement in addition to a
-@code{while} statement because often a @code{for} loop is both less work to
-type and more natural to think of. Counting the number of iterations is
-very common in loops. It can be easier to think of this counting as part
-of looping rather than as something to do inside the loop.
-
-The next section has more complicated examples of @code{for} loops.
-
-@node Break Statement, Continue Statement, For Statement, Statements
-@section The @code{break} Statement
-@cindex @code{break} statement
-@cindex loops, exiting
-
-The @code{break} statement jumps out of the innermost @code{for},
-@code{while}, or @code{do}-@code{while} loop that encloses it. The
-following example finds the smallest divisor of any integer, and also
-identifies prime numbers:@refill
-
-@smallexample
-awk '# find smallest divisor of num
- @{ num = $1
- for (div = 2; div*div <= num; div++)
- if (num % div == 0)
- break
- if (num % div == 0)
- printf "Smallest divisor of %d is %d\n", num, div
- else
- printf "%d is prime\n", num @}'
-@end smallexample
-
-When the remainder is zero in the first @code{if} statement, @code{awk}
-immediately @dfn{breaks out} of the containing @code{for} loop. This means
-that @code{awk} proceeds immediately to the statement following the loop
-and continues processing. (This is very different from the @code{exit}
-statement which stops the entire @code{awk} program.
-@xref{Exit Statement, ,The @code{exit} Statement}.)@refill
-
-Here is another program equivalent to the previous one. It illustrates how
-the @var{condition} of a @code{for} or @code{while} could just as well be
-replaced with a @code{break} inside an @code{if}:
-
-@smallexample
-@group
-awk '# find smallest divisor of num
- @{ num = $1
- for (div = 2; ; div++) @{
- if (num % div == 0) @{
- printf "Smallest divisor of %d is %d\n", num, div
- break
- @}
- if (div*div > num) @{
- printf "%d is prime\n", num
- break
- @}
- @}
-@}'
-@end group
-@end smallexample
-
-@node Continue Statement, Next Statement, Break Statement, Statements
-@section The @code{continue} Statement
-
-@cindex @code{continue} statement
-The @code{continue} statement, like @code{break}, is used only inside
-@code{for}, @code{while}, and @code{do}-@code{while} loops. It skips
-over the rest of the loop body, causing the next cycle around the loop
-to begin immediately. Contrast this with @code{break}, which jumps out
-of the loop altogether. Here is an example:@refill
-
-@example
-# print names that don't contain the string "ignore"
-
-# first, save the text of each line
-@{ names[NR] = $0 @}
-
-# print what we're interested in
-END @{
- for (x in names) @{
- if (names[x] ~ /ignore/)
- continue
- print names[x]
- @}
-@}
-@end example
-
-If one of the input records contains the string @samp{ignore}, this
-example skips the print statement for that record, and continues back to
-the first statement in the loop.
-
-This is not a practical example of @code{continue}, since it would be
-just as easy to write the loop like this:
-
-@example
-for (x in names)
- if (names[x] !~ /ignore/)
- print names[x]
-@end example
-
-@ignore
-from brennan@boeing.com:
-
-page 90, section 9.6. The example is too artificial as
-the one line program
-
- !/ignore/
-
-does the same thing.
-@end ignore
-@c ADR --- he's right, but don't worry about this for now
-
-The @code{continue} statement in a @code{for} loop directs @code{awk} to
-skip the rest of the body of the loop, and resume execution with the
-increment-expression of the @code{for} statement. The following program
-illustrates this fact:@refill
-
-@example
-awk 'BEGIN @{
- for (x = 0; x <= 20; x++) @{
- if (x == 5)
- continue
- printf ("%d ", x)
- @}
- print ""
-@}'
-@end example
-
-@noindent
-This program prints all the numbers from 0 to 20, except for 5, for
-which the @code{printf} is skipped. Since the increment @code{x++}
-is not skipped, @code{x} does not remain stuck at 5. Contrast the
-@code{for} loop above with the @code{while} loop:
-
-@example
-awk 'BEGIN @{
- x = 0
- while (x <= 20) @{
- if (x == 5)
- continue
- printf ("%d ", x)
- x++
- @}
- print ""
-@}'
-@end example
-
-@noindent
-This program loops forever once @code{x} gets to 5.
-
-As described above, the @code{continue} statement has no meaning when
-used outside the body of a loop. However, although it was never documented,
-historical implementations of @code{awk} have treated the @code{continue}
-statement outside of a loop as if it were a @code{next} statement
-(@pxref{Next Statement, ,The @code{next} Statement}).
-By default, @code{gawk} silently supports this usage. However, if
-@samp{-W posix} has been specified on the command line
-(@pxref{Command Line, ,Invoking @code{awk}}),
-it will be treated as an error, since the @sc{posix} standard specifies
-that @code{continue} should only be used inside the body of a loop.@refill
-
-@node Next Statement, Next File Statement, Continue Statement, Statements
-@section The @code{next} Statement
-@cindex @code{next} statement
-
-The @code{next} statement forces @code{awk} to immediately stop processing
-the current record and go on to the next record. This means that no
-further rules are executed for the current record. The rest of the
-current rule's action is not executed either.
-
-Contrast this with the effect of the @code{getline} function
-(@pxref{Getline, ,Explicit Input with @code{getline}}). That too causes
-@code{awk} to read the next record immediately, but it does not alter the
-flow of control in any way. So the rest of the current action executes
-with a new input record.
-
-At the highest level, @code{awk} program execution is a loop that reads
-an input record and then tests each rule's pattern against it. If you
-think of this loop as a @code{for} statement whose body contains the
-rules, then the @code{next} statement is analogous to a @code{continue}
-statement: it skips to the end of the body of this implicit loop, and
-executes the increment (which reads another record).
-
-For example, if your @code{awk} program works only on records with four
-fields, and you don't want it to fail when given bad input, you might
-use this rule near the beginning of the program:
-
-@smallexample
-NF != 4 @{
- printf("line %d skipped: doesn't have 4 fields", FNR) > "/dev/stderr"
- next
-@}
-@end smallexample
-
-@noindent
-so that the following rules will not see the bad record. The error
-message is redirected to the standard error output stream, as error
-messages should be. @xref{Special Files, ,Standard I/O Streams}.
-
-According to the @sc{posix} standard, the behavior is undefined if
-the @code{next} statement is used in a @code{BEGIN} or @code{END} rule.
-@code{gawk} will treat it as a syntax error.
-
-If the @code{next} statement causes the end of the input to be reached,
-then the code in the @code{END} rules, if any, will be executed.
-@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}.
-
-@node Next File Statement, Exit Statement, Next Statement, Statements
-@section The @code{next file} Statement
-
-@cindex @code{next file} statement
-The @code{next file} statement is similar to the @code{next} statement.
-However, instead of abandoning processing of the current record, the
-@code{next file} statement instructs @code{awk} to stop processing the
-current data file.
-
-Upon execution of the @code{next file} statement, @code{FILENAME} is
-updated to the name of the next data file listed on the command line,
-@code{FNR} is reset to 1, and processing starts over with the first
-rule in the progam. @xref{Built-in Variables}.
-
-If the @code{next file} statement causes the end of the input to be reached,
-then the code in the @code{END} rules, if any, will be executed.
-@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}.
-
-The @code{next file} statement is a @code{gawk} extension; it is not
-(currently) available in any other @code{awk} implementation. You can
-simulate its behavior by creating a library file named @file{nextfile.awk},
-with the following contents. (This sample program uses user-defined
-functions, a feature that has not been presented yet.
-@xref{User-defined, ,User-defined Functions},
-for more information.)@refill
-
-@smallexample
-# nextfile --- function to skip remaining records in current file
-
-# this should be read in before the "main" awk program
-
-function nextfile() @{ _abandon_ = FILENAME; next @}
-
-_abandon_ == FILENAME && FNR > 1 @{ next @}
-_abandon_ == FILENAME && FNR == 1 @{ _abandon_ = "" @}
-@end smallexample
-
-The @code{nextfile} function simply sets a ``private'' variable@footnote{Since
-all variables in @code{awk} are global, this program uses the common
-practice of prefixing the variable name with an underscore. In fact, it
-also suffixes the variable name with an underscore, as extra insurance
-against using a variable name that might be used in some other library
-file.} to the name of the current data file, and then retrieves the next
-record. Since this file is read before the main @code{awk} program,
-the rules that follows the function definition will be executed before the
-rules in the main program. The first rule continues to skip records as long as
-the name of the input file has not changed, and this is not the first
-record in the file. This rule is sufficient most of the time. But what if
-the @emph{same} data file is named twice in a row on the command line?
-This rule would not process the data file the second time. The second rule
-catches this case: If the data file name is what was being skipped, but
-@code{FNR} is 1, then this is the second time the file is being processed,
-and it should not be skipped.
-
-The @code{next file} statement would be useful if you have many data
-files to process, and due to the nature of the data, you expect that you
-would not want to process every record in the file. In order to move on to
-the next data file, you would have to continue scanning the unwanted
-records (as described above). The @code{next file} statement accomplishes
-this much more efficiently.
-
-@ignore
-Would it make sense down the road to nuke `next file' in favor of
-semantics that would make this work?
-
- function nextfile() { ARGIND++ ; next }
-@end ignore
-
-@node Exit Statement, , Next File Statement, Statements
-@section The @code{exit} Statement
-
-@cindex @code{exit} statement
-The @code{exit} statement causes @code{awk} to immediately stop
-executing the current rule and to stop processing input; any remaining input
-is ignored.@refill
-
-If an @code{exit} statement is executed from a @code{BEGIN} rule the
-program stops processing everything immediately. No input records are
-read. However, if an @code{END} rule is present, it is executed
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}).
-
-If @code{exit} is used as part of an @code{END} rule, it causes
-the program to stop immediately.
-
-An @code{exit} statement that is part of an ordinary rule (that is, not part
-of a @code{BEGIN} or @code{END} rule) stops the execution of any further
-automatic rules, but the @code{END} rule is executed if there is one.
-If you do not want the @code{END} rule to do its job in this case, you
-can set a variable to nonzero before the @code{exit} statement, and check
-that variable in the @code{END} rule.
-
-If an argument is supplied to @code{exit}, its value is used as the exit
-status code for the @code{awk} process. If no argument is supplied,
-@code{exit} returns status zero (success).@refill
-
-For example, let's say you've discovered an error condition you really
-don't know how to handle. Conventionally, programs report this by
-exiting with a nonzero status. Your @code{awk} program can do this
-using an @code{exit} statement with a nonzero argument. Here's an
-example of this:@refill
-
-@example
-@group
-BEGIN @{
- if (("date" | getline date_now) < 0) @{
- print "Can't get system date" > "/dev/stderr"
- exit 4
- @}
-@}
-@end group
-@end example
-
-@node Arrays, Built-in, Statements, Top
-@chapter Arrays in @code{awk}
-
-An @dfn{array} is a table of values, called @dfn{elements}. The
-elements of an array are distinguished by their indices. @dfn{Indices}
-may be either numbers or strings. Each array has a name, which looks
-like a variable name, but must not be in use as a variable name in the
-same @code{awk} program.
-
-@menu
-* Array Intro:: Introduction to Arrays
-* Reference to Elements:: How to examine one element of an array.
-* Assigning Elements:: How to change an element of an array.
-* Array Example:: Basic Example of an Array
-* Scanning an Array:: A variation of the @code{for} statement.
- It loops through the indices of
- an array's existing elements.
-* Delete:: The @code{delete} statement removes
- an element from an array.
-* Numeric Array Subscripts:: How to use numbers as subscripts in @code{awk}.
-* Multi-dimensional:: Emulating multi-dimensional arrays in @code{awk}.
-* Multi-scanning:: Scanning multi-dimensional arrays.
-@end menu
-
-@node Array Intro, Reference to Elements, Arrays, Arrays
-@section Introduction to Arrays
-
-@cindex arrays
-The @code{awk} language has one-dimensional @dfn{arrays} for storing groups
-of related strings or numbers.
-
-Every @code{awk} array must have a name. Array names have the same
-syntax as variable names; any valid variable name would also be a valid
-array name. But you cannot use one name in both ways (as an array and
-as a variable) in one @code{awk} program.
-
-Arrays in @code{awk} superficially resemble arrays in other programming
-languages; but there are fundamental differences. In @code{awk}, you
-don't need to specify the size of an array before you start to use it.
-Additionally, any number or string in @code{awk} may be used as an
-array index.
-
-In most other languages, you have to @dfn{declare} an array and specify
-how many elements or components it contains. In such languages, the
-declaration causes a contiguous block of memory to be allocated for that
-many elements. An index in the array must be a positive integer; for
-example, the index 0 specifies the first element in the array, which is
-actually stored at the beginning of the block of memory. Index 1
-specifies the second element, which is stored in memory right after the
-first element, and so on. It is impossible to add more elements to the
-array, because it has room for only as many elements as you declared.
-
-A contiguous array of four elements might look like this,
-conceptually, if the element values are @code{8}, @code{"foo"},
-@code{""} and @code{30}:@refill
-
-@example
-+---------+---------+--------+---------+
-| 8 | "foo" | "" | 30 | @r{value}
-+---------+---------+--------+---------+
- 0 1 2 3 @r{index}
-@end example
-
-@noindent
-Only the values are stored; the indices are implicit from the order of
-the values. @code{8} is the value at index 0, because @code{8} appears in the
-position with 0 elements before it.
-
-@cindex arrays, definition of
-@cindex associative arrays
-Arrays in @code{awk} are different: they are @dfn{associative}. This means
-that each array is a collection of pairs: an index, and its corresponding
-array element value:
-
-@example
-@r{Element} 4 @r{Value} 30
-@r{Element} 2 @r{Value} "foo"
-@r{Element} 1 @r{Value} 8
-@r{Element} 3 @r{Value} ""
-@end example
-
-@noindent
-We have shown the pairs in jumbled order because their order is irrelevant.
-
-One advantage of an associative array is that new pairs can be added
-at any time. For example, suppose we add to the above array a tenth element
-whose value is @w{@code{"number ten"}}. The result is this:
-
-@example
-@r{Element} 10 @r{Value} "number ten"
-@r{Element} 4 @r{Value} 30
-@r{Element} 2 @r{Value} "foo"
-@r{Element} 1 @r{Value} 8
-@r{Element} 3 @r{Value} ""
-@end example
-
-@noindent
-Now the array is @dfn{sparse} (i.e., some indices are missing): it has
-elements 1--4 and 10, but doesn't have elements 5, 6, 7, 8, or 9.@refill
-
-Another consequence of associative arrays is that the indices don't
-have to be positive integers. Any number, or even a string, can be
-an index. For example, here is an array which translates words from
-English into French:
-
-@example
-@r{Element} "dog" @r{Value} "chien"
-@r{Element} "cat" @r{Value} "chat"
-@r{Element} "one" @r{Value} "un"
-@r{Element} 1 @r{Value} "un"
-@end example
-
-@noindent
-Here we decided to translate the number 1 in both spelled-out and
-numeric form---thus illustrating that a single array can have both
-numbers and strings as indices.
-
-When @code{awk} creates an array for you, e.g., with the @code{split}
-built-in function,
-that array's indices are consecutive integers starting at 1.
-(@xref{String Functions, ,Built-in Functions for String Manipulation}.)
-
-@node Reference to Elements, Assigning Elements, Array Intro, Arrays
-@section Referring to an Array Element
-@cindex array reference
-@cindex element of array
-@cindex reference to array
-
-The principal way of using an array is to refer to one of its elements.
-An array reference is an expression which looks like this:
-
-@example
-@var{array}[@var{index}]
-@end example
-
-@noindent
-Here, @var{array} is the name of an array. The expression @var{index} is
-the index of the element of the array that you want.
-
-The value of the array reference is the current value of that array
-element. For example, @code{foo[4.3]} is an expression for the element
-of array @code{foo} at index 4.3.
-
-If you refer to an array element that has no recorded value, the value
-of the reference is @code{""}, the null string. This includes elements
-to which you have not assigned any value, and elements that have been
-deleted (@pxref{Delete, ,The @code{delete} Statement}). Such a reference
-automatically creates that array element, with the null string as its value.
-(In some cases, this is unfortunate, because it might waste memory inside
-@code{awk}).
-
-@cindex arrays, presence of elements
-You can find out if an element exists in an array at a certain index with
-the expression:
-
-@example
-@var{index} in @var{array}
-@end example
-
-@noindent
-This expression tests whether or not the particular index exists,
-without the side effect of creating that element if it is not present.
-The expression has the value 1 (true) if @code{@var{array}[@var{index}]}
-exists, and 0 (false) if it does not exist.@refill
-
-For example, to test whether the array @code{frequencies} contains the
-index @code{"2"}, you could write this statement:@refill
-
-@smallexample
-if ("2" in frequencies) print "Subscript \"2\" is present."
-@end smallexample
-
-Note that this is @emph{not} a test of whether or not the array
-@code{frequencies} contains an element whose @emph{value} is @code{"2"}.
-(There is no way to do that except to scan all the elements.) Also, this
-@emph{does not} create @code{frequencies["2"]}, while the following
-(incorrect) alternative would do so:@refill
-
-@smallexample
-if (frequencies["2"] != "") print "Subscript \"2\" is present."
-@end smallexample
-
-@node Assigning Elements, Array Example, Reference to Elements, Arrays
-@section Assigning Array Elements
-@cindex array assignment
-@cindex element assignment
-
-Array elements are lvalues: they can be assigned values just like
-@code{awk} variables:
-
-@example
-@var{array}[@var{subscript}] = @var{value}
-@end example
-
-@noindent
-Here @var{array} is the name of your array. The expression
-@var{subscript} is the index of the element of the array that you want
-to assign a value. The expression @var{value} is the value you are
-assigning to that element of the array.@refill
-
-@node Array Example, Scanning an Array, Assigning Elements, Arrays
-@section Basic Example of an Array
-
-The following program takes a list of lines, each beginning with a line
-number, and prints them out in order of line number. The line numbers are
-not in order, however, when they are first read: they are scrambled. This
-program sorts the lines by making an array using the line numbers as
-subscripts. It then prints out the lines in sorted order of their numbers.
-It is a very simple program, and gets confused if it encounters repeated
-numbers, gaps, or lines that don't begin with a number.@refill
-
-@example
-@{
- if ($1 > max)
- max = $1
- arr[$1] = $0
-@}
-
-END @{
- for (x = 1; x <= max; x++)
- print arr[x]
-@}
-@end example
-
-The first rule keeps track of the largest line number seen so far;
-it also stores each line into the array @code{arr}, at an index that
-is the line's number.
-
-The second rule runs after all the input has been read, to print out
-all the lines.
-
-When this program is run with the following input:
-
-@example
-5 I am the Five man
-2 Who are you? The new number two!
-4 . . . And four on the floor
-1 Who is number one?
-3 I three you.
-@end example
-
-@noindent
-its output is this:
-
-@example
-1 Who is number one?
-2 Who are you? The new number two!
-3 I three you.
-4 . . . And four on the floor
-5 I am the Five man
-@end example
-
-If a line number is repeated, the last line with a given number overrides
-the others.
-
-Gaps in the line numbers can be handled with an easy improvement to the
-program's @code{END} rule:
-
-@example
-END @{
- for (x = 1; x <= max; x++)
- if (x in arr)
- print arr[x]
-@}
-@end example
-
-@node Scanning an Array, Delete, Array Example, Arrays
-@section Scanning all Elements of an Array
-@cindex @code{for (x in @dots{})}
-@cindex arrays, special @code{for} statement
-@cindex scanning an array
-
-In programs that use arrays, often you need a loop that executes
-once for each element of an array. In other languages, where arrays are
-contiguous and indices are limited to positive integers, this is
-easy: the largest index is one less than the length of the array, and you can
-find all the valid indices by counting from zero up to that value. This
-technique won't do the job in @code{awk}, since any number or string
-may be an array index. So @code{awk} has a special kind of @code{for}
-statement for scanning an array:
-
-@example
-for (@var{var} in @var{array})
- @var{body}
-@end example
-
-@noindent
-This loop executes @var{body} once for each different value that your
-program has previously used as an index in @var{array}, with the
-variable @var{var} set to that index.@refill
-
-Here is a program that uses this form of the @code{for} statement. The
-first rule scans the input records and notes which words appear (at
-least once) in the input, by storing a 1 into the array @code{used} with
-the word as index. The second rule scans the elements of @code{used} to
-find all the distinct words that appear in the input. It prints each
-word that is more than 10 characters long, and also prints the number of
-such words. @xref{Built-in, ,Built-in Functions}, for more information
-on the built-in function @code{length}.
-
-@smallexample
-# Record a 1 for each word that is used at least once.
-@{
- for (i = 1; i <= NF; i++)
- used[$i] = 1
-@}
-
-# Find number of distinct words more than 10 characters long.
-END @{
- for (x in used)
- if (length(x) > 10) @{
- ++num_long_words
- print x
- @}
- print num_long_words, "words longer than 10 characters"
-@}
-@end smallexample
-
-@noindent
-@xref{Sample Program}, for a more detailed example of this type.
-
-The order in which elements of the array are accessed by this statement
-is determined by the internal arrangement of the array elements within
-@code{awk} and cannot be controlled or changed. This can lead to
-problems if new elements are added to @var{array} by statements in
-@var{body}; you cannot predict whether or not the @code{for} loop will
-reach them. Similarly, changing @var{var} inside the loop can produce
-strange results. It is best to avoid such things.@refill
-
-@node Delete, Numeric Array Subscripts, Scanning an Array, Arrays
-@section The @code{delete} Statement
-@cindex @code{delete} statement
-@cindex deleting elements of arrays
-@cindex removing elements of arrays
-@cindex arrays, deleting an element
-
-You can remove an individual element of an array using the @code{delete}
-statement:
-
-@example
-delete @var{array}[@var{index}]
-@end example
-
-You can not refer to an array element after it has been deleted;
-it is as if you had never referred
-to it and had never given it any value. You can no longer obtain any
-value the element once had.
-
-Here is an example of deleting elements in an array:
-
-@example
-for (i in frequencies)
- delete frequencies[i]
-@end example
-
-@noindent
-This example removes all the elements from the array @code{frequencies}.
-
-If you delete an element, a subsequent @code{for} statement to scan the array
-will not report that element, and the @code{in} operator to check for
-the presence of that element will return 0:
-
-@example
-delete foo[4]
-if (4 in foo)
- print "This will never be printed"
-@end example
-
-It is not an error to delete an element which does not exist.
-
-@node Numeric Array Subscripts, Multi-dimensional, Delete, Arrays
-@section Using Numbers to Subscript Arrays
-
-An important aspect of arrays to remember is that array subscripts
-are @emph{always} strings. If you use a numeric value as a subscript,
-it will be converted to a string value before it is used for subscripting
-(@pxref{Conversion, ,Conversion of Strings and Numbers}).
-
-@cindex conversions, during subscripting
-@cindex numbers, used as subscripts
-@vindex CONVFMT
-This means that the value of the @code{CONVFMT} can potentially
-affect how your program accesses elements of an array. For example:
-
-@example
-a = b = 12.153
-data[a] = 1
-CONVFMT = "%2.2f"
-if (b in data)
- printf "%s is in data", b
-else
- printf "%s is not in data", b
-@end example
-
-@noindent
-should print @samp{12.15 is not in data}. The first statement gives
-both @code{a} and @code{b} the same numeric value. Assigning to
-@code{data[a]} first gives @code{a} the string value @code{"12.153"}
-(using the default conversion value of @code{CONVFMT}, @code{"%.6g"}),
-and then assigns 1 to @code{data["12.153"]}. The program then changes
-the value of @code{CONVFMT}. The test @samp{(b in data)} forces @code{b}
-to be converted to a string, this time @code{"12.15"}, since the value of
-@code{CONVFMT} only allows two significant digits. This test fails,
-since @code{"12.15"} is a different string from @code{"12.153"}.@refill
-
-According to the rules for conversions
-(@pxref{Conversion, ,Conversion of Strings and Numbers}), integer
-values are always converted to strings as integers, no matter what the
-value of @code{CONVFMT} may happen to be. So the usual case of@refill
-
-@example
-for (i = 1; i <= maxsub; i++)
- @i{do something with} array[i]
-@end example
-
-@noindent
-will work, no matter what the value of @code{CONVFMT}.
-
-Like many things in @code{awk}, the majority of the time things work
-as you would expect them to work. But it is useful to have a precise
-knowledge of the actual rules, since sometimes they can have a subtle
-effect on your programs.
-
-@node Multi-dimensional, Multi-scanning, Numeric Array Subscripts, Arrays
-@section Multi-dimensional Arrays
-
-@c the following index entry is an overfull hbox. --mew 30jan1992
-@cindex subscripts in arrays
-@cindex arrays, multi-dimensional subscripts
-@cindex multi-dimensional subscripts
-A multi-dimensional array is an array in which an element is identified
-by a sequence of indices, not a single index. For example, a
-two-dimensional array requires two indices. The usual way (in most
-languages, including @code{awk}) to refer to an element of a
-two-dimensional array named @code{grid} is with
-@code{grid[@var{x},@var{y}]}.
-
-@vindex SUBSEP
-Multi-dimensional arrays are supported in @code{awk} through
-concatenation of indices into one string. What happens is that
-@code{awk} converts the indices into strings
-(@pxref{Conversion, ,Conversion of Strings and Numbers}) and
-concatenates them together, with a separator between them. This creates
-a single string that describes the values of the separate indices. The
-combined string is used as a single index into an ordinary,
-one-dimensional array. The separator used is the value of the built-in
-variable @code{SUBSEP}.@refill
-
-For example, suppose we evaluate the expression @code{foo[5,12]="value"}
-when the value of @code{SUBSEP} is @code{"@@"}. The numbers 5 and 12 are
-converted to strings and
-concatenated with an @samp{@@} between them, yielding @code{"5@@12"}; thus,
-the array element @code{foo["5@@12"]} is set to @code{"value"}.@refill
-
-Once the element's value is stored, @code{awk} has no record of whether
-it was stored with a single index or a sequence of indices. The two
-expressions @code{foo[5,12]} and @w{@code{foo[5 SUBSEP 12]}} always have
-the same value.
-
-The default value of @code{SUBSEP} is the string @code{"\034"},
-which contains a nonprinting character that is unlikely to appear in an
-@code{awk} program or in the input data.
-
-The usefulness of choosing an unlikely character comes from the fact
-that index values that contain a string matching @code{SUBSEP} lead to
-combined strings that are ambiguous. Suppose that @code{SUBSEP} were
-@code{"@@"}; then @w{@code{foo["a@@b", "c"]}} and @w{@code{foo["a",
-"b@@c"]}} would be indistinguishable because both would actually be
-stored as @code{foo["a@@b@@c"]}. Because @code{SUBSEP} is
-@code{"\034"}, such confusion can arise only when an index
-contains the character with ASCII code 034, which is a rare
-event.@refill
-
-You can test whether a particular index-sequence exists in a
-``multi-dimensional'' array with the same operator @code{in} used for single
-dimensional arrays. Instead of a single index as the left-hand operand,
-write the whole sequence of indices, separated by commas, in
-parentheses:@refill
-
-@example
-(@var{subscript1}, @var{subscript2}, @dots{}) in @var{array}
-@end example
-
-The following example treats its input as a two-dimensional array of
-fields; it rotates this array 90 degrees clockwise and prints the
-result. It assumes that all lines have the same number of
-elements.
-
-@example
-awk '@{
- if (max_nf < NF)
- max_nf = NF
- max_nr = NR
- for (x = 1; x <= NF; x++)
- vector[x, NR] = $x
-@}
-
-END @{
- for (x = 1; x <= max_nf; x++) @{
- for (y = max_nr; y >= 1; --y)
- printf("%s ", vector[x, y])
- printf("\n")
- @}
-@}'
-@end example
-
-@noindent
-When given the input:
-
-@example
-@group
-1 2 3 4 5 6
-2 3 4 5 6 1
-3 4 5 6 1 2
-4 5 6 1 2 3
-@end group
-@end example
-
-@noindent
-it produces:
-
-@example
-@group
-4 3 2 1
-5 4 3 2
-6 5 4 3
-1 6 5 4
-2 1 6 5
-3 2 1 6
-@end group
-@end example
-
-@node Multi-scanning, , Multi-dimensional, Arrays
-@section Scanning Multi-dimensional Arrays
-
-There is no special @code{for} statement for scanning a
-``multi-dimensional'' array; there cannot be one, because in truth there
-are no multi-dimensional arrays or elements; there is only a
-multi-dimensional @emph{way of accessing} an array.
-
-However, if your program has an array that is always accessed as
-multi-dimensional, you can get the effect of scanning it by combining
-the scanning @code{for} statement
-(@pxref{Scanning an Array, ,Scanning all Elements of an Array}) with the
-@code{split} built-in function
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).
-It works like this:@refill
-
-@example
-for (combined in @var{array}) @{
- split(combined, separate, SUBSEP)
- @dots{}
-@}
-@end example
-
-@noindent
-This finds each concatenated, combined index in the array, and splits it
-into the individual indices by breaking it apart where the value of
-@code{SUBSEP} appears. The split-out indices become the elements of
-the array @code{separate}.
-
-Thus, suppose you have previously stored in @code{@var{array}[1,
-"foo"]}; then an element with index @code{"1\034foo"} exists in
-@var{array}. (Recall that the default value of @code{SUBSEP} contains
-the character with code 034.) Sooner or later the @code{for} statement
-will find that index and do an iteration with @code{combined} set to
-@code{"1\034foo"}. Then the @code{split} function is called as
-follows:
-
-@example
-split("1\034foo", separate, "\034")
-@end example
-
-@noindent
-The result of this is to set @code{separate[1]} to 1 and @code{separate[2]}
-to @code{"foo"}. Presto, the original sequence of separate indices has
-been recovered.
-
-@node Built-in, User-defined, Arrays, Top
-@chapter Built-in Functions
-
-@cindex built-in functions
-@dfn{Built-in} functions are functions that are always available for
-your @code{awk} program to call. This chapter defines all the built-in
-functions in @code{awk}; some of them are mentioned in other sections,
-but they are summarized here for your convenience. (You can also define
-new functions yourself. @xref{User-defined, ,User-defined Functions}.)
-
-@menu
-* Calling Built-in:: How to call built-in functions.
-* Numeric Functions:: Functions that work with numbers,
- including @code{int}, @code{sin} and @code{rand}.
-* String Functions:: Functions for string manipulation,
- such as @code{split}, @code{match}, and @code{sprintf}.
-* I/O Functions:: Functions for files and shell commands.
-* Time Functions:: Functions for dealing with time stamps.
-@end menu
-
-@node Calling Built-in, Numeric Functions, Built-in, Built-in
-@section Calling Built-in Functions
-
-To call a built-in function, write the name of the function followed
-by arguments in parentheses. For example, @code{atan2(y + z, 1)}
-is a call to the function @code{atan2}, with two arguments.
-
-Whitespace is ignored between the built-in function name and the
-open-parenthesis, but we recommend that you avoid using whitespace
-there. User-defined functions do not permit whitespace in this way, and
-you will find it easier to avoid mistakes by following a simple
-convention which always works: no whitespace after a function name.
-
-Each built-in function accepts a certain number of arguments. In most
-cases, any extra arguments given to built-in functions are ignored. The
-defaults for omitted arguments vary from function to function and are
-described under the individual functions.
-
-When a function is called, expressions that create the function's actual
-parameters are evaluated completely before the function call is performed.
-For example, in the code fragment:
-
-@example
-i = 4
-j = sqrt(i++)
-@end example
-
-@noindent
-the variable @code{i} is set to 5 before @code{sqrt} is called
-with a value of 4 for its actual parameter.
-
-@node Numeric Functions, String Functions, Calling Built-in, Built-in
-@section Numeric Built-in Functions
-@c I didn't make all the examples small because a couple of them were
-@c short already. --mew 29jan1992
-
-Here is a full list of built-in functions that work with numbers:
-
-@table @code
-@item int(@var{x})
-This gives you the integer part of @var{x}, truncated toward 0. This
-produces the nearest integer to @var{x}, located between @var{x} and 0.
-
-For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)}
-is @minus{}3, and @code{int(-3)} is @minus{}3 as well.@refill
-
-@item sqrt(@var{x})
-This gives you the positive square root of @var{x}. It reports an error
-if @var{x} is negative. Thus, @code{sqrt(4)} is 2.@refill
-
-@item exp(@var{x})
-This gives you the exponential of @var{x}, or reports an error if
-@var{x} is out of range. The range of values @var{x} can have depends
-on your machine's floating point representation.@refill
-
-@item log(@var{x})
-This gives you the natural logarithm of @var{x}, if @var{x} is positive;
-otherwise, it reports an error.@refill
-
-@item sin(@var{x})
-This gives you the sine of @var{x}, with @var{x} in radians.
-
-@item cos(@var{x})
-This gives you the cosine of @var{x}, with @var{x} in radians.
-
-@item atan2(@var{y}, @var{x})
-This gives you the arctangent of @code{@var{y} / @var{x}} in radians.
-
-@item rand()
-This gives you a random number. The values of @code{rand} are
-uniformly-distributed between 0 and 1. The value is never 0 and never
-1.
-
-Often you want random integers instead. Here is a user-defined function
-you can use to obtain a random nonnegative integer less than @var{n}:
-
-@example
-function randint(n) @{
- return int(n * rand())
-@}
-@end example
-
-@noindent
-The multiplication produces a random real number greater than 0 and less
-than @var{n}. We then make it an integer (using @code{int}) between 0
-and @code{@var{n} @minus{} 1}.
-
-Here is an example where a similar function is used to produce
-random integers between 1 and @var{n}. Note that this program will
-print a new random number for each input record.
-
-@smallexample
-awk '
-# Function to roll a simulated die.
-function roll(n) @{ return 1 + int(rand() * n) @}
-
-# Roll 3 six-sided dice and print total number of points.
-@{
- printf("%d points\n", roll(6)+roll(6)+roll(6))
-@}'
-@end smallexample
-
-@strong{Note:} @code{rand} starts generating numbers from the same
-point, or @dfn{seed}, each time you run @code{awk}. This means that
-a program will produce the same results each time you run it.
-The numbers are random within one @code{awk} run, but predictable
-from run to run. This is convenient for debugging, but if you want
-a program to do different things each time it is used, you must change
-the seed to a value that will be different in each run. To do this,
-use @code{srand}.
-
-@item srand(@var{x})
-The function @code{srand} sets the starting point, or @dfn{seed},
-for generating random numbers to the value @var{x}.
-
-Each seed value leads to a particular sequence of ``random'' numbers.
-Thus, if you set the seed to the same value a second time, you will get
-the same sequence of ``random'' numbers again.
-
-If you omit the argument @var{x}, as in @code{srand()}, then the current
-date and time of day are used for a seed. This is the way to get random
-numbers that are truly unpredictable.
-
-The return value of @code{srand} is the previous seed. This makes it
-easy to keep track of the seeds for use in consistently reproducing
-sequences of random numbers.
-@end table
-
-@node String Functions, I/O Functions, Numeric Functions, Built-in
-@section Built-in Functions for String Manipulation
-
-The functions in this section look at or change the text of one or more
-strings.
-
-@table @code
-@item index(@var{in}, @var{find})
-@findex match
-This searches the string @var{in} for the first occurrence of the string
-@var{find}, and returns the position in characters where that occurrence
-begins in the string @var{in}. For example:@refill
-
-@smallexample
-awk 'BEGIN @{ print index("peanut", "an") @}'
-@end smallexample
-
-@noindent
-prints @samp{3}. If @var{find} is not found, @code{index} returns 0.
-(Remember that string indices in @code{awk} start at 1.)
-
-@item length(@var{string})
-@findex length
-This gives you the number of characters in @var{string}. If
-@var{string} is a number, the length of the digit string representing
-that number is returned. For example, @code{length("abcde")} is 5. By
-contrast, @code{length(15 * 35)} works out to 3. How? Well, 15 * 35 =
-525, and 525 is then converted to the string @samp{"525"}, which has
-three characters.
-
-If no argument is supplied, @code{length} returns the length of @code{$0}.
-
-In older versions of @code{awk}, you could call the @code{length} function
-without any parentheses. Doing so is marked as ``deprecated'' in the
-@sc{posix} standard. This means that while you can do this in your
-programs, it is a feature that can eventually be removed from a future
-version of the standard. Therefore, for maximal portability of your
-@code{awk} programs you should always supply the parentheses.
-
-@item match(@var{string}, @var{regexp})
-@findex match
-The @code{match} function searches the string, @var{string}, for the
-longest, leftmost substring matched by the regular expression,
-@var{regexp}. It returns the character position, or @dfn{index}, of
-where that substring begins (1, if it starts at the beginning of
-@var{string}). If no match if found, it returns 0.
-
-@vindex RSTART
-@vindex RLENGTH
-The @code{match} function sets the built-in variable @code{RSTART} to
-the index. It also sets the built-in variable @code{RLENGTH} to the
-length in characters of the matched substring. If no match is found,
-@code{RSTART} is set to 0, and @code{RLENGTH} to @minus{}1.
-
-For example:
-
-@smallexample
-awk '@{
- if ($1 == "FIND")
- regex = $2
- else @{
- where = match($0, regex)
- if (where)
- print "Match of", regex, "found at", where, "in", $0
- @}
-@}'
-@end smallexample
-
-@noindent
-This program looks for lines that match the regular expression stored in
-the variable @code{regex}. This regular expression can be changed. If the
-first word on a line is @samp{FIND}, @code{regex} is changed to be the
-second word on that line. Therefore, given:
-
-@smallexample
-FIND fo*bar
-My program was a foobar
-But none of it would doobar
-FIND Melvin
-JF+KM
-This line is property of The Reality Engineering Co.
-This file created by Melvin.
-@end smallexample
-
-@noindent
-@code{awk} prints:
-
-@smallexample
-Match of fo*bar found at 18 in My program was a foobar
-Match of Melvin found at 26 in This file created by Melvin.
-@end smallexample
-
-@item split(@var{string}, @var{array}, @var{fieldsep})
-@findex split
-This divides @var{string} into pieces separated by @var{fieldsep},
-and stores the pieces in @var{array}. The first piece is stored in
-@code{@var{array}[1]}, the second piece in @code{@var{array}[2]}, and so
-forth. The string value of the third argument, @var{fieldsep}, is
-a regexp describing where to split @var{string} (much as @code{FS} can
-be a regexp describing where to split input records). If
-the @var{fieldsep} is omitted, the value of @code{FS} is used.
-@code{split} returns the number of elements created.@refill
-
-The @code{split} function, then, splits strings into pieces in a
-manner similar to the way input lines are split into fields. For example:
-
-@smallexample
-split("auto-da-fe", a, "-")
-@end smallexample
-
-@noindent
-splits the string @samp{auto-da-fe} into three fields using @samp{-} as the
-separator. It sets the contents of the array @code{a} as follows:
-
-@smallexample
-a[1] = "auto"
-a[2] = "da"
-a[3] = "fe"
-@end smallexample
-
-@noindent
-The value returned by this call to @code{split} is 3.
-
-As with input field-splitting, when the value of @var{fieldsep} is
-@code{" "}, leading and trailing whitespace is ignored, and the elements
-are separated by runs of whitespace.
-
-@item sprintf(@var{format}, @var{expression1},@dots{})
-@findex sprintf
-This returns (without printing) the string that @code{printf} would
-have printed out with the same arguments
-(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).
-For example:@refill
-
-@smallexample
-sprintf("pi = %.2f (approx.)", 22/7)
-@end smallexample
-
-@noindent
-returns the string @w{@code{"pi = 3.14 (approx.)"}}.
-
-@item sub(@var{regexp}, @var{replacement}, @var{target})
-@findex sub
-The @code{sub} function alters the value of @var{target}.
-It searches this value, which should be a string, for the
-leftmost substring matched by the regular expression, @var{regexp},
-extending this match as far as possible. Then the entire string is
-changed by replacing the matched text with @var{replacement}.
-The modified string becomes the new value of @var{target}.
-
-This function is peculiar because @var{target} is not simply
-used to compute a value, and not just any expression will do: it
-must be a variable, field or array reference, so that @code{sub} can
-store a modified value there. If this argument is omitted, then the
-default is to use and alter @code{$0}.
-
-For example:@refill
-
-@smallexample
-str = "water, water, everywhere"
-sub(/at/, "ith", str)
-@end smallexample
-
-@noindent
-sets @code{str} to @w{@code{"wither, water, everywhere"}}, by replacing the
-leftmost, longest occurrence of @samp{at} with @samp{ith}.
-
-The @code{sub} function returns the number of substitutions made (either
-one or zero).
-
-If the special character @samp{&} appears in @var{replacement}, it
-stands for the precise substring that was matched by @var{regexp}. (If
-the regexp can match more than one string, then this precise substring
-may vary.) For example:@refill
-
-@smallexample
-awk '@{ sub(/candidate/, "& and his wife"); print @}'
-@end smallexample
-
-@noindent
-changes the first occurrence of @samp{candidate} to @samp{candidate
-and his wife} on each input line.
-
-Here is another example:
-
-@smallexample
-awk 'BEGIN @{
- str = "daabaaa"
- sub(/a*/, "c&c", str)
- print str
-@}'
-@end smallexample
-
-@noindent
-prints @samp{dcaacbaaa}. This show how @samp{&} can represent a non-constant
-string, and also illustrates the ``leftmost, longest'' rule.
-
-The effect of this special character (@samp{&}) can be turned off by putting a
-backslash before it in the string. As usual, to insert one backslash in
-the string, you must write two backslashes. Therefore, write @samp{\\&}
-in a string constant to include a literal @samp{&} in the replacement.
-For example, here is how to replace the first @samp{|} on each line with
-an @samp{&}:@refill
-
-@smallexample
-awk '@{ sub(/\|/, "\\&"); print @}'
-@end smallexample
-
-@strong{Note:} as mentioned above, the third argument to @code{sub} must
-be an lvalue. Some versions of @code{awk} allow the third argument to
-be an expression which is not an lvalue. In such a case, @code{sub}
-would still search for the pattern and return 0 or 1, but the result of
-the substitution (if any) would be thrown away because there is no place
-to put it. Such versions of @code{awk} accept expressions like
-this:@refill
-
-@smallexample
-sub(/USA/, "United States", "the USA and Canada")
-@end smallexample
-
-@noindent
-But that is considered erroneous in @code{gawk}.
-
-@item gsub(@var{regexp}, @var{replacement}, @var{target})
-@findex gsub
-This is similar to the @code{sub} function, except @code{gsub} replaces
-@emph{all} of the longest, leftmost, @emph{nonoverlapping} matching
-substrings it can find. The @samp{g} in @code{gsub} stands for
-``global,'' which means replace everywhere. For example:@refill
-
-@smallexample
-awk '@{ gsub(/Britain/, "United Kingdom"); print @}'
-@end smallexample
-
-@noindent
-replaces all occurrences of the string @samp{Britain} with @samp{United
-Kingdom} for all input records.@refill
-
-The @code{gsub} function returns the number of substitutions made. If
-the variable to be searched and altered, @var{target}, is
-omitted, then the entire input record, @code{$0}, is used.@refill
-
-As in @code{sub}, the characters @samp{&} and @samp{\} are special, and
-the third argument must be an lvalue.
-
-@item substr(@var{string}, @var{start}, @var{length})
-@findex substr
-This returns a @var{length}-character-long substring of @var{string},
-starting at character number @var{start}. The first character of a
-string is character number one. For example,
-@code{substr("washington", 5, 3)} returns @code{"ing"}.@refill
-
-If @var{length} is not present, this function returns the whole suffix of
-@var{string} that begins at character number @var{start}. For example,
-@code{substr("washington", 5)} returns @code{"ington"}. This is also
-the case if @var{length} is greater than the number of characters remaining
-in the string, counting from character number @var{start}.
-
-@item tolower(@var{string})
-@findex tolower
-This returns a copy of @var{string}, with each upper-case character
-in the string replaced with its corresponding lower-case character.
-Nonalphabetic characters are left unchanged. For example,
-@code{tolower("MiXeD cAsE 123")} returns @code{"mixed case 123"}.
-
-@item toupper(@var{string})
-@findex toupper
-This returns a copy of @var{string}, with each lower-case character
-in the string replaced with its corresponding upper-case character.
-Nonalphabetic characters are left unchanged. For example,
-@code{toupper("MiXeD cAsE 123")} returns @code{"MIXED CASE 123"}.
-@end table
-
-@node I/O Functions, Time Functions, String Functions, Built-in
-@section Built-in Functions for Input/Output
-
-@table @code
-@item close(@var{filename})
-Close the file @var{filename}, for input or output. The argument may
-alternatively be a shell command that was used for redirecting to or
-from a pipe; then the pipe is closed.
-
-@xref{Close Input, ,Closing Input Files and Pipes}, regarding closing
-input files and pipes. @xref{Close Output, ,Closing Output Files and Pipes},
-regarding closing output files and pipes.@refill
-
-@item system(@var{command})
-@findex system
-@c the following index entry is an overfull hbox. --mew 30jan1992
-@cindex interaction, @code{awk} and other programs
-The system function allows the user to execute operating system commands
-and then return to the @code{awk} program. The @code{system} function
-executes the command given by the string @var{command}. It returns, as
-its value, the status returned by the command that was executed.
-
-For example, if the following fragment of code is put in your @code{awk}
-program:
-
-@smallexample
-END @{
- system("mail -s 'awk run done' operator < /dev/null")
-@}
-@end smallexample
-
-@noindent
-the system operator will be sent mail when the @code{awk} program
-finishes processing input and begins its end-of-input processing.
-
-Note that much the same result can be obtained by redirecting
-@code{print} or @code{printf} into a pipe. However, if your @code{awk}
-program is interactive, @code{system} is useful for cranking up large
-self-contained programs, such as a shell or an editor.@refill
-
-Some operating systems cannot implement the @code{system} function.
-@code{system} causes a fatal error if it is not supported.
-@end table
-
-@c fakenode --- for prepinfo
-@subheading Controlling Output Buffering with @code{system}
-@cindex flushing buffers
-@cindex buffers, flushing
-@cindex buffering output
-@cindex output, buffering
-
-Many utility programs will @dfn{buffer} their output; they save information
-to be written to a disk file or terminal in memory, until there is enough
-to be written in one operation. This is often more efficient than writing
-every little bit of information as soon as it is ready. However, sometimes
-it is necessary to force a program to @dfn{flush} its buffers; that is,
-write the information to its destination, even if a buffer is not full.
-You can do this from your @code{awk} program by calling @code{system}
-with a null string as its argument:
-
-@example
-system("") # flush output
-@end example
-
-@noindent
-@code{gawk} treats this use of the @code{system} function as a special
-case, and is smart enough not to run a shell (or other command
-interpreter) with the empty command. Therefore, with @code{gawk}, this
-idiom is not only useful, it is efficient. While this idiom should work
-with other @code{awk} implementations, it will not necessarily avoid
-starting an unnecessary shell.
-@ignore
-Need a better explanation, perhaps in a separate paragraph. Explain that
-for
-
-awk 'BEGIN { print "hi"
- system("echo hello")
- print "howdy" }'
-
-that the output had better be
-
- hi
- hello
- howdy
-
-and not
-
- hello
- hi
- howdy
-
-which it would be if awk did not flush its buffers before calling system.
-@end ignore
-
-@node Time Functions, , I/O Functions, Built-in
-@section Functions for Dealing with Time Stamps
-
-@cindex time stamps
-@cindex time of day
-A common use for @code{awk} programs is the processing of log files.
-Log files often contain time stamp information, indicating when a
-particular log record was written. Many programs log their time stamp
-in the form returned by the @code{time} system call, which is the
-number of seconds since a particular epoch. On @sc{posix} systems,
-it is the number of seconds since Midnight, January 1, 1970, @sc{utc}.
-
-In order to make it easier to process such log files, and to easily produce
-useful reports, @code{gawk} provides two functions for working with time
-stamps. Both of these are @code{gawk} extensions; they are not specified
-in the @sc{posix} standard, nor are they in any other known version
-of @code{awk}.
-
-@table @code
-@item systime()
-@findex systime
-This function returns the current time as the number of seconds since
-the system epoch. On @sc{posix} systems, this is the number of seconds
-since Midnight, January 1, 1970, @sc{utc}. It may be a different number on
-other systems.
-
-@item strftime(@var{format}, @var{timestamp})
-@findex strftime
-This function returns a string. It is similar to the function of the
-same name in the @sc{ansi} C standard library. The time specified by
-@var{timestamp} is used to produce a string, based on the contents
-of the @var{format} string.
-@end table
-
-The @code{systime} function allows you to compare a time stamp from a
-log file with the current time of day. In particular, it is easy to
-determine how long ago a particular record was logged. It also allows
-you to produce log records using the ``seconds since the epoch'' format.
-
-The @code{strftime} function allows you to easily turn a time stamp
-into human-readable information. It is similar in nature to the @code{sprintf}
-function, copying non-format specification characters verbatim to the
-returned string, and substituting date and time values for format
-specifications in the @var{format} string. If no @var{timestamp} argument
-is supplied, @code{gawk} will use the current time of day as the
-time stamp.@refill
-
-@code{strftime} is guaranteed by the @sc{ansi} C standard to support
-the following date format specifications:
-
-@table @code
-@item %a
-The locale's abbreviated weekday name.
-
-@item %A
-The locale's full weekday name.
-
-@item %b
-The locale's abbreviated month name.
-
-@item %B
-The locale's full month name.
-
-@item %c
-The locale's ``appropriate'' date and time representation.
-
-@item %d
-The day of the month as a decimal number (01--31).
-
-@item %H
-The hour (24-hour clock) as a decimal number (00--23).
-
-@item %I
-The hour (12-hour clock) as a decimal number (01--12).
-
-@item %j
-The day of the year as a decimal number (001--366).
-
-@item %m
-The month as a decimal number (01--12).
-
-@item %M
-The minute as a decimal number (00--59).
-
-@item %p
-The locale's equivalent of the AM/PM designations associated
-with a 12-hour clock.
-
-@item %S
-The second as a decimal number (00--61). (Occasionally there are
-minutes in a year with one or two leap seconds, which is why the
-seconds can go from 0 all the way to 61.)
-
-@item %U
-The week number of the year (the first Sunday as the first day of week 1)
-as a decimal number (00--53).
-
-@item %w
-The weekday as a decimal number (0--6). Sunday is day 0.
-
-@item %W
-The week number of the year (the first Monday as the first day of week 1)
-as a decimal number (00--53).
-
-@item %x
-The locale's ``appropriate'' date representation.
-
-@item %X
-The locale's ``appropriate'' time representation.
-
-@item %y
-The year without century as a decimal number (00--99).
-
-@item %Y
-The year with century as a decimal number.
-
-@item %Z
-The time zone name or abbreviation, or no characters if
-no time zone is determinable.
-
-@item %%
-A literal @samp{%}.
-@end table
-
-@c The parenthetical remark here should really be a footnote, but
-@c it gave formatting problems at the FSF. So for now put it in
-@c parentheses.
-If a conversion specifier is not one of the above, the behavior is
-undefined. (This is because the @sc{ansi} standard for C leaves the
-behavior of the C version of @code{strftime} undefined, and @code{gawk}
-will use the system's version of @code{strftime} if it's there.
-Typically, the conversion specifier will either not appear in the
-returned string, or it will appear literally.)
-
-Informally, a @dfn{locale} is the geographic place in which a program
-is meant to run. For example, a common way to abbreviate the date
-September 4, 1991 in the United States would be ``9/4/91''.
-In many countries in Europe, however, it would be abbreviated ``4.9.91''.
-Thus, the @samp{%x} specification in a @code{"US"} locale might produce
-@samp{9/4/91}, while in a @code{"EUROPE"} locale, it might produce
-@samp{4.9.91}. The @sc{ansi} C standard defines a default @code{"C"}
-locale, which is an environment that is typical of what most C programmers
-are used to.
-
-A public-domain C version of @code{strftime} is shipped with @code{gawk}
-for systems that are not yet fully @sc{ansi}-compliant. If that version is
-used to compile @code{gawk} (@pxref{Installation, ,Installing @code{gawk}}),
-then the following additional format specifications are available:@refill
-
-@table @code
-@item %D
-Equivalent to specifying @samp{%m/%d/%y}.
-
-@item %e
-The day of the month, padded with a blank if it is only one digit.
-
-@item %h
-Equivalent to @samp{%b}, above.
-
-@item %n
-A newline character (ASCII LF).
-
-@item %r
-Equivalent to specifying @samp{%I:%M:%S %p}.
-
-@item %R
-Equivalent to specifying @samp{%H:%M}.
-
-@item %T
-Equivalent to specifying @samp{%H:%M:%S}.
-
-@item %t
-A TAB character.
-
-@item %k
-is replaced by the hour (24-hour clock) as a decimal number (0-23).
-Single digit numbers are padded with a blank.
-
-@item %l
-is replaced by the hour (12-hour clock) as a decimal number (1-12).
-Single digit numbers are padded with a blank.
-
-@item %C
-The century, as a number between 00 and 99.
-
-@item %u
-is replaced by the weekday as a decimal number
-[1 (Monday)--7].
-
-@item %V
-is replaced by the week number of the year (the first Monday as the first
-day of week 1) as a decimal number (01--53).
-The method for determining the week number is as specified by ISO 8601
-(to wit: if the week containing January 1 has four or more days in the
-new year, then it is week 1, otherwise it is week 53 of the previous year
-and the next week is week 1).@refill
-
-@item %Ec %EC %Ex %Ey %EY %Od %Oe %OH %OI
-@itemx %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy
-These are ``alternate representations'' for the specifications
-that use only the second letter (@samp{%c}, @samp{%C}, and so on).
-They are recognized, but their normal representations are used.
-(These facilitate compliance with the @sc{posix} @code{date}
-utility.)@refill
-
-@item %v
-The date in VMS format (e.g. 20-JUN-1991).
-@end table
-
-Here are two examples that use @code{strftime}. The first is an
-@code{awk} version of the C @code{ctime} function. (This is a
-user defined function, which we have not discussed yet.
-@xref{User-defined, ,User-defined Functions}, for more information.)
-
-@smallexample
-# ctime.awk
-#
-# awk version of C ctime(3) function
-
-function ctime(ts, format)
-@{
- format = "%a %b %e %H:%M:%S %Z %Y"
- if (ts == 0)
- ts = systime() # use current time as default
- return strftime(format, ts)
-@}
-@end smallexample
-
-This next example is an @code{awk} implementation of the @sc{posix}
-@code{date} utility. Normally, the @code{date} utility prints the
-current date and time of day in a well known format. However, if you
-provide an argument to it that begins with a @samp{+}, @code{date}
-will copy non-format specifier characters to the standard output, and
-will interpret the current time according to the format specifiers in
-the string. For example:
-
-@smallexample
-date '+Today is %A, %B %d, %Y.'
-@end smallexample
-
-@noindent
-might print
-
-@smallexample
-Today is Thursday, July 11, 1991.
-@end smallexample
-
-Here is the @code{awk} version of the @code{date} utility.
-
-@smallexample
-#! /usr/bin/gawk -f
-#
-# date --- implement the P1003.2 Draft 11 'date' command
-#
-# Bug: does not recognize the -u argument.
-
-BEGIN \
-@{
- format = "%a %b %e %H:%M:%S %Z %Y"
- exitval = 0
-
- if (ARGC > 2)
- exitval = 1
- else if (ARGC == 2) @{
- format = ARGV[1]
- if (format ~ /^\+/)
- format = substr(format, 2) # remove leading +
- @}
- print strftime(format)
- exit exitval
-@}
-@end smallexample
-
-@node User-defined, Built-in Variables, Built-in, Top
-@chapter User-defined Functions
-
-@cindex user-defined functions
-@cindex functions, user-defined
-Complicated @code{awk} programs can often be simplified by defining
-your own functions. User-defined functions can be called just like
-built-in ones (@pxref{Function Calls}), but it is up to you to define
-them---to tell @code{awk} what they should do.
-
-@menu
-* Definition Syntax:: How to write definitions and what they mean.
-* Function Example:: An example function definition and
- what it does.
-* Function Caveats:: Things to watch out for.
-* Return Statement:: Specifying the value a function returns.
-@end menu
-
-@node Definition Syntax, Function Example, User-defined, User-defined
-@section Syntax of Function Definitions
-@cindex defining functions
-@cindex function definition
-
-Definitions of functions can appear anywhere between the rules of the
-@code{awk} program. Thus, the general form of an @code{awk} program is
-extended to include sequences of rules @emph{and} user-defined function
-definitions.
-
-The definition of a function named @var{name} looks like this:
-
-@example
-function @var{name} (@var{parameter-list}) @{
- @var{body-of-function}
-@}
-@end example
-
-@noindent
-@var{name} is the name of the function to be defined. A valid function
-name is like a valid variable name: a sequence of letters, digits and
-underscores, not starting with a digit. Functions share the same pool
-of names as variables and arrays.
-
-@var{parameter-list} is a list of the function's arguments and local
-variable names, separated by commas. When the function is called,
-the argument names are used to hold the argument values given in
-the call. The local variables are initialized to the null string.
-
-The @var{body-of-function} consists of @code{awk} statements. It is the
-most important part of the definition, because it says what the function
-should actually @emph{do}. The argument names exist to give the body a
-way to talk about the arguments; local variables, to give the body
-places to keep temporary values.
-
-Argument names are not distinguished syntactically from local variable
-names; instead, the number of arguments supplied when the function is
-called determines how many argument variables there are. Thus, if three
-argument values are given, the first three names in @var{parameter-list}
-are arguments, and the rest are local variables.
-
-It follows that if the number of arguments is not the same in all calls
-to the function, some of the names in @var{parameter-list} may be
-arguments on some occasions and local variables on others. Another
-way to think of this is that omitted arguments default to the
-null string.
-
-Usually when you write a function you know how many names you intend to
-use for arguments and how many you intend to use as locals. By
-convention, you should write an extra space between the arguments and
-the locals, so other people can follow how your function is
-supposed to be used.
-
-During execution of the function body, the arguments and local variable
-values hide or @dfn{shadow} any variables of the same names used in the
-rest of the program. The shadowed variables are not accessible in the
-function definition, because there is no way to name them while their
-names have been taken away for the local variables. All other variables
-used in the @code{awk} program can be referenced or set normally in the
-function definition.
-
-The arguments and local variables last only as long as the function body
-is executing. Once the body finishes, the shadowed variables come back.
-
-The function body can contain expressions which call functions. They
-can even call this function, either directly or by way of another
-function. When this happens, we say the function is @dfn{recursive}.
-
-There is no need in @code{awk} to put the definition of a function
-before all uses of the function. This is because @code{awk} reads the
-entire program before starting to execute any of it.
-
-In many @code{awk} implementations, the keyword @code{function} may be
-abbreviated @code{func}. However, @sc{posix} only specifies the use of
-the keyword @code{function}. This actually has some practical implications.
-If @code{gawk} is in @sc{posix}-compatibility mode
-(@pxref{Command Line, ,Invoking @code{awk}}), then the following
-statement will @emph{not} define a function:@refill
-
-@example
-func foo() @{ a = sqrt($1) ; print a @}
-@end example
-
-@noindent
-Instead it defines a rule that, for each record, concatenates the value
-of the variable @samp{func} with the return value of the function @samp{foo},
-and based on the truth value of the result, executes the corresponding action.
-This is probably not what was desired. (@code{awk} accepts this input as
-syntactically valid, since functions may be used before they are defined
-in @code{awk} programs.)
-
-@node Function Example, Function Caveats, Definition Syntax, User-defined
-@section Function Definition Example
-
-Here is an example of a user-defined function, called @code{myprint}, that
-takes a number and prints it in a specific format.
-
-@example
-function myprint(num)
-@{
- printf "%6.3g\n", num
-@}
-@end example
-
-@noindent
-To illustrate, here is an @code{awk} rule which uses our @code{myprint}
-function:
-
-@example
-$3 > 0 @{ myprint($3) @}
-@end example
-
-@noindent
-This program prints, in our special format, all the third fields that
-contain a positive number in our input. Therefore, when given:
-
-@example
- 1.2 3.4 5.6 7.8
- 9.10 11.12 -13.14 15.16
-17.18 19.20 21.22 23.24
-@end example
-
-@noindent
-this program, using our function to format the results, prints:
-
-@example
- 5.6
- 21.2
-@end example
-
-Here is a rather contrived example of a recursive function. It prints a
-string backwards:
-
-@example
-function rev (str, len) @{
- if (len == 0) @{
- printf "\n"
- return
- @}
- printf "%c", substr(str, len, 1)
- rev(str, len - 1)
-@}
-@end example
-
-@node Function Caveats, Return Statement, Function Example, User-defined
-@section Calling User-defined Functions
-
-@dfn{Calling a function} means causing the function to run and do its job.
-A function call is an expression, and its value is the value returned by
-the function.
-
-A function call consists of the function name followed by the arguments
-in parentheses. What you write in the call for the arguments are
-@code{awk} expressions; each time the call is executed, these
-expressions are evaluated, and the values are the actual arguments. For
-example, here is a call to @code{foo} with three arguments (the first
-being a string concatenation):
-
-@example
-foo(x y, "lose", 4 * z)
-@end example
-
-@quotation
-@strong{Caution:} whitespace characters (spaces and tabs) are not allowed
-between the function name and the open-parenthesis of the argument list.
-If you write whitespace by mistake, @code{awk} might think that you mean
-to concatenate a variable with an expression in parentheses. However, it
-notices that you used a function name and not a variable name, and reports
-an error.
-@end quotation
-
-@cindex call by value
-When a function is called, it is given a @emph{copy} of the values of
-its arguments. This is called @dfn{call by value}. The caller may use
-a variable as the expression for the argument, but the called function
-does not know this: it only knows what value the argument had. For
-example, if you write this code:
-
-@example
-foo = "bar"
-z = myfunc(foo)
-@end example
-
-@noindent
-then you should not think of the argument to @code{myfunc} as being
-``the variable @code{foo}.'' Instead, think of the argument as the
-string value, @code{"bar"}.
-
-If the function @code{myfunc} alters the values of its local variables,
-this has no effect on any other variables. In particular, if @code{myfunc}
-does this:
-
-@example
-function myfunc (win) @{
- print win
- win = "zzz"
- print win
-@}
-@end example
-
-@noindent
-to change its first argument variable @code{win}, this @emph{does not}
-change the value of @code{foo} in the caller. The role of @code{foo} in
-calling @code{myfunc} ended when its value, @code{"bar"}, was computed.
-If @code{win} also exists outside of @code{myfunc}, the function body
-cannot alter this outer value, because it is shadowed during the
-execution of @code{myfunc} and cannot be seen or changed from there.
-
-@cindex call by reference
-However, when arrays are the parameters to functions, they are @emph{not}
-copied. Instead, the array itself is made available for direct manipulation
-by the function. This is usually called @dfn{call by reference}.
-Changes made to an array parameter inside the body of a function @emph{are}
-visible outside that function.
-@ifinfo
-This can be @strong{very} dangerous if you do not watch what you are
-doing. For example:@refill
-@end ifinfo
-@iftex
-@emph{This can be very dangerous if you do not watch what you are
-doing.} For example:@refill
-@end iftex
-
-@example
-function changeit (array, ind, nvalue) @{
- array[ind] = nvalue
-@}
-
-BEGIN @{
- a[1] = 1 ; a[2] = 2 ; a[3] = 3
- changeit(a, 2, "two")
- printf "a[1] = %s, a[2] = %s, a[3] = %s\n", a[1], a[2], a[3]
- @}
-@end example
-
-@noindent
-prints @samp{a[1] = 1, a[2] = two, a[3] = 3}, because calling
-@code{changeit} stores @code{"two"} in the second element of @code{a}.
-
-@node Return Statement, , Function Caveats, User-defined
-@section The @code{return} Statement
-@cindex @code{return} statement
-
-The body of a user-defined function can contain a @code{return} statement.
-This statement returns control to the rest of the @code{awk} program. It
-can also be used to return a value for use in the rest of the @code{awk}
-program. It looks like this:@refill
-
-@example
-return @var{expression}
-@end example
-
-The @var{expression} part is optional. If it is omitted, then the returned
-value is undefined and, therefore, unpredictable.
-
-A @code{return} statement with no value expression is assumed at the end of
-every function definition. So if control reaches the end of the function
-body, then the function returns an unpredictable value. @code{awk}
-will not warn you if you use the return value of such a function; you will
-simply get unpredictable or unexpected results.
-
-Here is an example of a user-defined function that returns a value
-for the largest number among the elements of an array:@refill
-
-@example
-@group
-function maxelt (vec, i, ret) @{
- for (i in vec) @{
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- @}
- return ret
-@}
-@end group
-@end example
-
-@noindent
-You call @code{maxelt} with one argument, which is an array name. The local
-variables @code{i} and @code{ret} are not intended to be arguments;
-while there is nothing to stop you from passing two or three arguments
-to @code{maxelt}, the results would be strange. The extra space before
-@code{i} in the function parameter list is to indicate that @code{i} and
-@code{ret} are not supposed to be arguments. This is a convention which
-you should follow when you define functions.
-
-Here is a program that uses our @code{maxelt} function. It loads an
-array, calls @code{maxelt}, and then reports the maximum number in that
-array:@refill
-
-@example
-@group
-awk '
-function maxelt (vec, i, ret) @{
- for (i in vec) @{
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- @}
- return ret
-@}
-@end group
-
-@group
-# Load all fields of each record into nums.
-@{
- for(i = 1; i <= NF; i++)
- nums[NR, i] = $i
-@}
-
-END @{
- print maxelt(nums)
-@}'
-@end group
-@end example
-
-Given the following input:
-
-@example
-@group
- 1 5 23 8 16
-44 3 5 2 8 26
-256 291 1396 2962 100
--6 467 998 1101
-99385 11 0 225
-@end group
-@end example
-
-@noindent
-our program tells us (predictably) that:
-
-@example
-99385
-@end example
-
-@noindent
-is the largest number in our array.
-
-@node Built-in Variables, Command Line, User-defined, Top
-@chapter Built-in Variables
-@cindex built-in variables
-
-Most @code{awk} variables are available for you to use for your own
-purposes; they never change except when your program assigns values to
-them, and never affect anything except when your program examines them.
-
-A few variables have special built-in meanings. Some of them @code{awk}
-examines automatically, so that they enable you to tell @code{awk} how
-to do certain things. Others are set automatically by @code{awk}, so
-that they carry information from the internal workings of @code{awk} to
-your program.
-
-This chapter documents all the built-in variables of @code{gawk}. Most
-of them are also documented in the chapters where their areas of
-activity are described.
-
-@menu
-* User-modified:: Built-in variables that you change
- to control @code{awk}.
-* Auto-set:: Built-in variables where @code{awk}
- gives you information.
-@end menu
-
-@node User-modified, Auto-set, Built-in Variables, Built-in Variables
-@section Built-in Variables that Control @code{awk}
-@cindex built-in variables, user modifiable
-
-This is a list of the variables which you can change to control how
-@code{awk} does certain things.
-
-@table @code
-@iftex
-@vindex CONVFMT
-@end iftex
-@item CONVFMT
-This string is used by @code{awk} to control conversion of numbers to
-strings (@pxref{Conversion, ,Conversion of Strings and Numbers}).
-It works by being passed, in effect, as the first argument to the
-@code{sprintf} function. Its default value is @code{"%.6g"}.
-@code{CONVFMT} was introduced by the @sc{posix} standard.@refill
-
-@iftex
-@vindex FIELDWIDTHS
-@end iftex
-@item FIELDWIDTHS
-This is a space separated list of columns that tells @code{gawk}
-how to manage input with fixed, columnar boundaries. It is an
-experimental feature that is still evolving. Assigning to @code{FIELDWIDTHS}
-overrides the use of @code{FS} for field splitting.
-@xref{Constant Size, ,Reading Fixed-width Data}, for more information.@refill
-
-If @code{gawk} is in compatibility mode
-(@pxref{Command Line, ,Invoking @code{awk}}), then @code{FIELDWIDTHS}
-has no special meaning, and field splitting operations are done based
-exclusively on the value of @code{FS}.@refill
-
-@iftex
-@vindex FS
-@end iftex
-@item FS
-@code{FS} is the input field separator
-(@pxref{Field Separators, ,Specifying how Fields are Separated}).
-The value is a single-character string or a multi-character regular
-expression that matches the separations between fields in an input
-record.@refill
-
-The default value is @w{@code{" "}}, a string consisting of a single
-space. As a special exception, this value actually means that any
-sequence of spaces and tabs is a single separator. It also causes
-spaces and tabs at the beginning or end of a line to be ignored.
-
-You can set the value of @code{FS} on the command line using the
-@samp{-F} option:
-
-@example
-awk -F, '@var{program}' @var{input-files}
-@end example
-
-If @code{gawk} is using @code{FIELDWIDTHS} for field-splitting,
-assigning a value to @code{FS} will cause @code{gawk} to return to
-the normal, regexp-based, field splitting.
-
-@item IGNORECASE
-@iftex
-@vindex IGNORECASE
-@end iftex
-If @code{IGNORECASE} is nonzero, then @emph{all} regular expression
-matching is done in a case-independent fashion. In particular, regexp
-matching with @samp{~} and @samp{!~}, and the @code{gsub} @code{index},
-@code{match}, @code{split} and @code{sub} functions all ignore case when
-doing their particular regexp operations. @strong{Note:} since field
-splitting with the value of the @code{FS} variable is also a regular
-expression operation, that too is done with case ignored.
-@xref{Case-sensitivity, ,Case-sensitivity in Matching}.
-
-If @code{gawk} is in compatibility mode
-(@pxref{Command Line, ,Invoking @code{awk}}), then @code{IGNORECASE} has
-no special meaning, and regexp operations are always case-sensitive.@refill
-
-@item OFMT
-@iftex
-@vindex OFMT
-@end iftex
-This string is used by @code{awk} to control conversion of numbers to
-strings (@pxref{Conversion, ,Conversion of Strings and Numbers}) for
-printing with the @code{print} statement.
-It works by being passed, in effect, as the first argument to the
-@code{sprintf} function. Its default value is @code{"%.6g"}.
-Earlier versions of @code{awk} also used @code{OFMT} to specify the
-format for converting numbers to strings in general expressions; this
-has been taken over by @code{CONVFMT}.@refill
-
-@item OFS
-@iftex
-@vindex OFS
-@end iftex
-This is the output field separator (@pxref{Output Separators}). It is
-output between the fields output by a @code{print} statement. Its
-default value is @w{@code{" "}}, a string consisting of a single space.
-
-@item ORS
-@iftex
-@vindex ORS
-@end iftex
-This is the output record separator. It is output at the end of every
-@code{print} statement. Its default value is a string containing a
-single newline character, which could be written as @code{"\n"}.
-(@xref{Output Separators}.)@refill
-
-@item RS
-@iftex
-@vindex RS
-@end iftex
-This is @code{awk}'s input record separator. Its default value is a string
-containing a single newline character, which means that an input record
-consists of a single line of text.
-(@xref{Records, ,How Input is Split into Records}.)@refill
-
-@item SUBSEP
-@iftex
-@vindex SUBSEP
-@end iftex
-@code{SUBSEP} is the subscript separator. It has the default value of
-@code{"\034"}, and is used to separate the parts of the name of a
-multi-dimensional array. Thus, if you access @code{foo[12,3]}, it
-really accesses @code{foo["12\0343"]}
-(@pxref{Multi-dimensional, ,Multi-dimensional Arrays}).@refill
-@end table
-
-@node Auto-set, , User-modified, Built-in Variables
-@section Built-in Variables that Convey Information
-
-This is a list of the variables that are set automatically by @code{awk}
-on certain occasions so as to provide information to your program.
-
-@table @code
-@item ARGC
-@itemx ARGV
-@iftex
-@vindex ARGC
-@vindex ARGV
-@end iftex
-The command-line arguments available to @code{awk} programs are stored in
-an array called @code{ARGV}. @code{ARGC} is the number of command-line
-arguments present. @xref{Command Line, ,Invoking @code{awk}}.
-@code{ARGV} is indexed from zero to @w{@code{ARGC - 1}}. For example:@refill
-
-@example
-awk 'BEGIN @{
- for (i = 0; i < ARGC; i++)
- print ARGV[i]
- @}' inventory-shipped BBS-list
-@end example
-
-@noindent
-In this example, @code{ARGV[0]} contains @code{"awk"}, @code{ARGV[1]}
-contains @code{"inventory-shipped"}, and @code{ARGV[2]} contains
-@code{"BBS-list"}. The value of @code{ARGC} is 3, one more than the
-index of the last element in @code{ARGV} since the elements are numbered
-from zero.@refill
-
-The names @code{ARGC} and @code{ARGV}, as well the convention of indexing
-the array from 0 to @w{@code{ARGC - 1}}, are derived from the C language's
-method of accessing command line arguments.@refill
-
-Notice that the @code{awk} program is not entered in @code{ARGV}. The
-other special command line options, with their arguments, are also not
-entered. But variable assignments on the command line @emph{are}
-treated as arguments, and do show up in the @code{ARGV} array.
-
-Your program can alter @code{ARGC} and the elements of @code{ARGV}.
-Each time @code{awk} reaches the end of an input file, it uses the next
-element of @code{ARGV} as the name of the next input file. By storing a
-different string there, your program can change which files are read.
-You can use @code{"-"} to represent the standard input. By storing
-additional elements and incrementing @code{ARGC} you can cause
-additional files to be read.
-
-If you decrease the value of @code{ARGC}, that eliminates input files
-from the end of the list. By recording the old value of @code{ARGC}
-elsewhere, your program can treat the eliminated arguments as
-something other than file names.
-
-To eliminate a file from the middle of the list, store the null string
-(@code{""}) into @code{ARGV} in place of the file's name. As a
-special feature, @code{awk} ignores file names that have been
-replaced with the null string.
-
-@ignore
-see getopt.awk in the examples...
-@end ignore
-
-@item ARGIND
-@vindex ARGIND
-The index in @code{ARGV} of the current file being processed.
-Every time @code{gawk} opens a new data file for processing, it sets
-@code{ARGIND} to the index in @code{ARGV} of the file name. Thus, the
-condition @samp{FILENAME == ARGV[ARGIND]} is always true.
-
-This variable is useful in file processing; it allows you to tell how far
-along you are in the list of data files, and to distinguish between
-multiple successive instances of the same filename on the command line.
-
-While you can change the value of @code{ARGIND} within your @code{awk}
-program, @code{gawk} will automatically set it to a new value when the
-next file is opened.
-
-This variable is a @code{gawk} extension; in other @code{awk} implementations
-it is not special.
-
-@item ENVIRON
-@vindex ENVIRON
-This is an array that contains the values of the environment. The array
-indices are the environment variable names; the values are the values of
-the particular environment variables. For example,
-@code{ENVIRON["HOME"]} might be @file{/u/close}. Changing this array
-does not affect the environment passed on to any programs that
-@code{awk} may spawn via redirection or the @code{system} function.
-(In a future version of @code{gawk}, it may do so.)
-
-Some operating systems may not have environment variables.
-On such systems, the array @code{ENVIRON} is empty.
-
-@item ERRNO
-@iftex
-@vindex ERRNO
-@end iftex
-If a system error occurs either doing a redirection for @code{getline},
-during a read for @code{getline}, or during a @code{close} operation,
-then @code{ERRNO} will contain a string describing the error.
-
-This variable is a @code{gawk} extension; in other @code{awk} implementations
-it is not special.
-
-@item FILENAME
-@iftex
-@vindex FILENAME
-@end iftex
-This is the name of the file that @code{awk} is currently reading.
-If @code{awk} is reading from the standard input (in other words,
-there are no files listed on the command line),
-@code{FILENAME} is set to @code{"-"}.
-@code{FILENAME} is changed each time a new file is read
-(@pxref{Reading Files, ,Reading Input Files}).@refill
-
-@item FNR
-@iftex
-@vindex FNR
-@end iftex
-@code{FNR} is the current record number in the current file. @code{FNR} is
-incremented each time a new record is read
-(@pxref{Getline, ,Explicit Input with @code{getline}}). It is reinitialized
-to 0 each time a new input file is started.@refill
-
-@item NF
-@iftex
-@vindex NF
-@end iftex
-@code{NF} is the number of fields in the current input record.
-@code{NF} is set each time a new record is read, when a new field is
-created, or when @code{$0} changes (@pxref{Fields, ,Examining Fields}).@refill
-
-@item NR
-@iftex
-@vindex NR
-@end iftex
-This is the number of input records @code{awk} has processed since
-the beginning of the program's execution.
-(@pxref{Records, ,How Input is Split into Records}).
-@code{NR} is set each time a new record is read.@refill
-
-@item RLENGTH
-@iftex
-@vindex RLENGTH
-@end iftex
-@code{RLENGTH} is the length of the substring matched by the
-@code{match} function
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).
-@code{RLENGTH} is set by invoking the @code{match} function. Its value
-is the length of the matched string, or @minus{}1 if no match was found.@refill
-
-@item RSTART
-@iftex
-@vindex RSTART
-@end iftex
-@code{RSTART} is the start-index in characters of the substring matched by the
-@code{match} function
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).
-@code{RSTART} is set by invoking the @code{match} function. Its value
-is the position of the string where the matched substring starts, or 0
-if no match was found.@refill
-@end table
-
-@node Command Line, Language History, Built-in Variables, Top
-@c node-name, next, previous, up
-@chapter Invoking @code{awk}
-@cindex command line
-@cindex invocation of @code{gawk}
-@cindex arguments, command line
-@cindex options, command line
-@cindex long options
-@cindex options, long
-
-There are two ways to run @code{awk}: with an explicit program, or with
-one or more program files. Here are templates for both of them; items
-enclosed in @samp{@r{[}@dots{}@r{]}} in these templates are optional.
-
-Besides traditional one-letter @sc{posix}-style options, @code{gawk} also
-supports GNU long named options.
-
-@example
-awk @r{[@var{POSIX or GNU style options}]} -f progfile @r{[@code{--}]} @var{file} @dots{}
-awk @r{[@var{POSIX or GNU style options}]} @r{[@code{--}]} '@var{program}' @var{file} @dots{}
-@end example
-
-@menu
-* Options:: Command line options and their meanings.
-* Other Arguments:: Input file names and variable assignments.
-* AWKPATH Variable:: Searching directories for @code{awk} programs.
-* Obsolete:: Obsolete Options and/or features.
-* Undocumented:: Undocumented Options and Features.
-@end menu
-
-@node Options, Other Arguments, Command Line, Command Line
-@section Command Line Options
-
-Options begin with a minus sign, and consist of a single character.
-GNU style long named options consist of two minus signs and
-a keyword that can be abbreviated if the abbreviation allows the option
-to be uniquely identified. If the option takes an argument, then the
-keyword is immediately followed by an equals sign (@samp{=}) and the
-argument's value. For brevity, the discussion below only refers to the
-traditional short options; however the long and short options are
-interchangeable in all contexts.
-
-Each long named option for @code{gawk} has a corresponding
-@sc{posix}-style option. The options and their meanings are as follows:
-
-@table @code
-@item -F @var{fs}
-@itemx --field-separator=@var{fs}
-@iftex
-@cindex @code{-F} option
-@end iftex
-@cindex @code{--field-separator} option
-Sets the @code{FS} variable to @var{fs}
-(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill
-
-@item -f @var{source-file}
-@itemx --file=@var{source-file}
-@iftex
-@cindex @code{-f} option
-@end iftex
-@cindex @code{--file} option
-Indicates that the @code{awk} program is to be found in @var{source-file}
-instead of in the first non-option argument.
-
-@item -v @var{var}=@var{val}
-@itemx --assign=@var{var}=@var{val}
-@cindex @samp{-v} option
-@cindex @code{--assign} option
-Sets the variable @var{var} to the value @var{val} @emph{before}
-execution of the program begins. Such variable values are available
-inside the @code{BEGIN} rule (see below for a fuller explanation).
-
-The @samp{-v} option can only set one variable, but you can use
-it more than once, setting another variable each time, like this:
-@samp{@w{-v foo=1} @w{-v bar=2}}.
-
-@item -W @var{gawk-opt}
-@cindex @samp{-W} option
-Following the @sc{posix} standard, options that are implementation
-specific are supplied as arguments to the @samp{-W} option. With @code{gawk},
-these arguments may be separated by commas, or quoted and separated by
-whitespace. Case is ignored when processing these options. These options
-also have corresponding GNU style long named options. The following
-@code{gawk}-specific options are available:
-
-@table @code
-@item -W compat
-@itemx --compat
-@cindex @code{--compat} option
-Specifies @dfn{compatibility mode}, in which the GNU extensions in
-@code{gawk} are disabled, so that @code{gawk} behaves just like Unix
-@code{awk}.
-@xref{POSIX/GNU, ,Extensions in @code{gawk} not in POSIX @code{awk}},
-which summarizes the extensions. Also see
-@ref{Compatibility Mode, ,Downward Compatibility and Debugging}.@refill
-
-@item -W copyleft
-@itemx -W copyright
-@itemx --copyleft
-@itemx --copyright
-@cindex @code{--copyleft} option
-@cindex @code{--copyright} option
-Print the short version of the General Public License.
-This option may disappear in a future version of @code{gawk}.
-
-@item -W help
-@itemx -W usage
-@itemx --help
-@itemx --usage
-@cindex @code{--help} option
-@cindex @code{--usage} option
-Print a ``usage'' message summarizing the short and long style options
-that @code{gawk} accepts, and then exit.
-
-@item -W lint
-@itemx --lint
-@cindex @code{--lint} option
-Provide warnings about constructs that are dubious or non-portable to
-other @code{awk} implementations.
-Some warnings are issued when @code{gawk} first reads your program. Others
-are issued at run-time, as your program executes.
-
-@item -W posix
-@itemx --posix
-@cindex @code{--posix} option
-Operate in strict @sc{posix} mode. This disables all @code{gawk}
-extensions (just like @code{-W compat}), and adds the following additional
-restrictions:
-
-@itemize @bullet{}
-@item
-@code{\x} escape sequences are not recognized
-(@pxref{Constants, ,Constant Expressions}).@refill
-
-@item
-The synonym @code{func} for the keyword @code{function} is not
-recognized (@pxref{Definition Syntax, ,Syntax of Function Definitions}).
-
-@item
-The operators @samp{**} and @samp{**=} cannot be used in
-place of @samp{^} and @samp{^=} (@pxref{Arithmetic Ops, ,Arithmetic Operators},
-and also @pxref{Assignment Ops, ,Assignment Expressions}).@refill
-
-@item
-Specifying @samp{-Ft} on the command line does not set the value
-of @code{FS} to be a single tab character
-(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill
-@end itemize
-
-Although you can supply both @samp{-W compat} and @samp{-W posix} on the
-command line, @samp{-W posix} will take precedence.
-
-@item -W source=@var{program-text}
-@itemx --source=@var{program-text}
-@cindex @code{--source} option
-Program source code is taken from the @var{program-text}. This option
-allows you to mix @code{awk} source code in files with program source
-code that you would enter on the command line. This is particularly useful
-when you have library functions that you wish to use from your command line
-programs (@pxref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}).
-
-@item -W version
-@itemx --version
-@cindex @code{--version} option
-Prints version information for this particular copy of @code{gawk}.
-This is so you can determine if your copy of @code{gawk} is up to date
-with respect to whatever the Free Software Foundation is currently
-distributing. This option may disappear in a future version of @code{gawk}.
-@end table
-
-@item --
-Signals the end of the command line options. The following arguments
-are not treated as options even if they begin with @samp{-}. This
-interpretation of @samp{--} follows the @sc{posix} argument parsing
-conventions.
-
-This is useful if you have file names that start with @samp{-},
-or in shell scripts, if you have file names that will be specified
-by the user which could start with @samp{-}.
-@end table
-
-Any other options are flagged as invalid with a warning message, but
-are otherwise ignored.
-
-In compatibility mode, as a special case, if the value of @var{fs} supplied
-to the @samp{-F} option is @samp{t}, then @code{FS} is set to the tab
-character (@code{"\t"}). This is only true for @samp{-W compat}, and not
-for @samp{-W posix}
-(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill
-
-If the @samp{-f} option is @emph{not} used, then the first non-option
-command line argument is expected to be the program text.
-
-The @samp{-f} option may be used more than once on the command line.
-If it is, @code{awk} reads its program source from all of the named files, as
-if they had been concatenated together into one big file. This is
-useful for creating libraries of @code{awk} functions. Useful functions
-can be written once, and then retrieved from a standard place, instead
-of having to be included into each individual program. You can still
-type in a program at the terminal and use library functions, by specifying
-@samp{-f /dev/tty}. @code{awk} will read a file from the terminal
-to use as part of the @code{awk} program. After typing your program,
-type @kbd{Control-d} (the end-of-file character) to terminate it.
-(You may also use @samp{-f -} to read program source from the standard
-input, but then you will not be able to also use the standard input as a
-source of data.)
-
-Because it is clumsy using the standard @code{awk} mechanisms to mix source
-file and command line @code{awk} programs, @code{gawk} provides the
-@samp{--source} option. This does not require you to pre-empt the standard
-input for your source code, and allows you to easily mix command line
-and library source code
-(@pxref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}).
-
-If no @samp{-f} or @samp{--source} option is specified, then @code{gawk}
-will use the first non-option command line argument as the text of the
-program source code.
-
-@node Other Arguments, AWKPATH Variable, Options, Command Line
-@section Other Command Line Arguments
-
-Any additional arguments on the command line are normally treated as
-input files to be processed in the order specified. However, an
-argument that has the form @code{@var{var}=@var{value}}, means to assign
-the value @var{value} to the variable @var{var}---it does not specify a
-file at all.
-
-@vindex ARGV
-All these arguments are made available to your @code{awk} program in the
-@code{ARGV} array (@pxref{Built-in Variables}). Command line options
-and the program text (if present) are omitted from the @code{ARGV}
-array. All other arguments, including variable assignments, are
-included.
-
-The distinction between file name arguments and variable-assignment
-arguments is made when @code{awk} is about to open the next input file.
-At that point in execution, it checks the ``file name'' to see whether
-it is really a variable assignment; if so, @code{awk} sets the variable
-instead of reading a file.
-
-Therefore, the variables actually receive the specified values after all
-previously specified files have been read. In particular, the values of
-variables assigned in this fashion are @emph{not} available inside a
-@code{BEGIN} rule
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}),
-since such rules are run before @code{awk} begins scanning the argument list.
-The values given on the command line are processed for escape sequences
-(@pxref{Constants, ,Constant Expressions}).@refill
-
-In some earlier implementations of @code{awk}, when a variable assignment
-occurred before any file names, the assignment would happen @emph{before}
-the @code{BEGIN} rule was executed. Some applications came to depend
-upon this ``feature.'' When @code{awk} was changed to be more consistent,
-the @samp{-v} option was added to accommodate applications that depended
-upon this old behavior.
-
-The variable assignment feature is most useful for assigning to variables
-such as @code{RS}, @code{OFS}, and @code{ORS}, which control input and
-output formats, before scanning the data files. It is also useful for
-controlling state if multiple passes are needed over a data file. For
-example:@refill
-
-@cindex multiple passes over data
-@cindex passes, multiple
-@smallexample
-awk 'pass == 1 @{ @var{pass 1 stuff} @}
- pass == 2 @{ @var{pass 2 stuff} @}' pass=1 datafile pass=2 datafile
-@end smallexample
-
-Given the variable assignment feature, the @samp{-F} option is not
-strictly necessary. It remains for historical compatibility.
-
-@node AWKPATH Variable, Obsolete, Other Arguments, Command Line
-@section The @code{AWKPATH} Environment Variable
-@cindex @code{AWKPATH} environment variable
-@cindex search path
-@cindex directory search
-@cindex path, search
-@iftex
-@cindex differences between @code{gawk} and @code{awk}
-@end iftex
-
-The previous section described how @code{awk} program files can be named
-on the command line with the @samp{-f} option. In some @code{awk}
-implementations, you must supply a precise path name for each program
-file, unless the file is in the current directory.
-
-But in @code{gawk}, if the file name supplied in the @samp{-f} option
-does not contain a @samp{/}, then @code{gawk} searches a list of
-directories (called the @dfn{search path}), one by one, looking for a
-file with the specified name.
-
-The search path is actually a string consisting of directory names
-separated by colons. @code{gawk} gets its search path from the
-@code{AWKPATH} environment variable. If that variable does not exist,
-@code{gawk} uses the default path, which is
-@samp{.:/usr/lib/awk:/usr/local/lib/awk}. (Programs written by
-system administrators should use an @code{AWKPATH} variable that
-does not include the current directory, @samp{.}.)@refill
-
-The search path feature is particularly useful for building up libraries
-of useful @code{awk} functions. The library files can be placed in a
-standard directory that is in the default path, and then specified on
-the command line with a short file name. Otherwise, the full file name
-would have to be typed for each file.
-
-By combining the @samp{--source} and @samp{-f} options, your command line
-@code{awk} programs can use facilities in @code{awk} library files.
-
-Path searching is not done if @code{gawk} is in compatibility mode.
-This is true for both @samp{-W compat} and @samp{-W posix}.
-@xref{Options, ,Command Line Options}.
-
-@strong{Note:} if you want files in the current directory to be found,
-you must include the current directory in the path, either by writing
-@file{.} as an entry in the path, or by writing a null entry in the
-path. (A null entry is indicated by starting or ending the path with a
-colon, or by placing two colons next to each other (@samp{::}).) If the
-current directory is not included in the path, then files cannot be
-found in the current directory. This path search mechanism is identical
-to the shell's.
-@c someday, @cite{The Bourne Again Shell}....
-
-@node Obsolete, Undocumented, AWKPATH Variable, Command Line
-@section Obsolete Options and/or Features
-
-@cindex deprecated options
-@cindex obsolete options
-@cindex deprecated features
-@cindex obsolete features
-This section describes features and/or command line options from the
-previous release of @code{gawk} that are either not available in the
-current version, or that are still supported but deprecated (meaning that
-they will @emph{not} be in the next release).
-
-@c update this section for each release!
-
-For version 2.15 of @code{gawk}, the following command line options
-from version 2.11.1 are no longer recognized.
-
-@table @samp
-@ignore
-@item -nostalgia
-Use @samp{-W nostalgia} instead.
-@end ignore
-
-@item -c
-Use @samp{-W compat} instead.
-
-@item -V
-Use @samp{-W version} instead.
-
-@item -C
-Use @samp{-W copyright} instead.
-
-@item -a
-@itemx -e
-These options produce an ``unrecognized option'' error message but have
-no effect on the execution of @code{gawk}. The @sc{posix} standard now
-specifies traditional @code{awk} regular expressions for the @code{awk} utility.
-@end table
-
-The public-domain version of @code{strftime} that is distributed with
-@code{gawk} changed for the 2.14 release. The @samp{%V} conversion specifier
-that used to generate the date in VMS format was changed to @samp{%v}.
-This is because the @sc{posix} standard for the @code{date} utility now
-specifies a @samp{%V} conversion specifier.
-@xref{Time Functions, ,Functions for Dealing with Time Stamps}, for details.
-
-@node Undocumented, , Obsolete, Command Line
-@section Undocumented Options and Features
-
-This section intentionally left blank.
-
-@c Read The Source, Luke!
-
-@ignore
-@c If these came out in the Info file or TeX manual, then they wouldn't
-@c be undocumented, would they?
-
-@code{gawk} has one undocumented option:
-
-@table @samp
-@item -W nostalgia
-Print the message @code{"awk: bailing out near line 1"} and dump core.
-This option was inspired by the common behavior of very early versions of
-Unix @code{awk}, and by a t--shirt.
-@end table
-
-Early versions of @code{awk} used to not require any separator (either
-a newline or @samp{;}) between the rules in @code{awk} programs. Thus,
-it was common to see one-line programs like:
-
-@example
-awk '@{ sum += $1 @} END @{ print sum @}'
-@end example
-
-@code{gawk} actually supports this, but it is purposely undocumented
-since it is considered bad style. The correct way to write such a program
-is either
-
-@example
-awk '@{ sum += $1 @} ; END @{ print sum @}'
-@end example
-
-@noindent
-or
-
-@example
-awk '@{ sum += $1 @}
- END @{ print sum @}' data
-@end example
-
-@noindent
-@xref{Statements/Lines, ,@code{awk} Statements versus Lines}, for a fuller
-explanation.@refill
-
-As an accident of the implementation of the original Unix @code{awk}, if
-a built-in function used @code{$0} as its default argument, it was possible
-to call that function without the parentheses. In particular, it was
-common practice to use the @code{length} function in this fashion.
-For example, the pipeline:
-
-@example
-echo abcdef | awk '@{ print length @}'
-@end example
-
-@noindent
-would print @samp{6}.
-
-For backwards compatibility with old programs, @code{gawk} supports
-this usage, but only for the @code{length} function. New programs should
-@emph{not} call the @code{length} function this way. In particular,
-this usage will not be portable to other @sc{posix} compliant versions
-of @code{awk}. It is also poor style.
-
-@end ignore
-
-@node Language History, Installation, Command Line, Top
-@chapter The Evolution of the @code{awk} Language
-
-This manual describes the GNU implementation of @code{awk}, which is patterned
-after the @sc{posix} specification. Many @code{awk} users are only familiar
-with the original @code{awk} implementation in Version 7 Unix, which is also
-the basis for the version in Berkeley Unix (through 4.3--Reno). This chapter
-briefly describes the evolution of the @code{awk} language.
-
-@menu
-* V7/S5R3.1:: The major changes between V7 and
- System V Release 3.1.
-* S5R4:: Minor changes between System V
- Releases 3.1 and 4.
-* POSIX:: New features from the @sc{posix} standard.
-* POSIX/GNU:: The extensions in @code{gawk}
- not in @sc{posix} @code{awk}.
-@end menu
-
-@node V7/S5R3.1, S5R4, Language History, Language History
-@section Major Changes between V7 and S5R3.1
-
-The @code{awk} language evolved considerably between the release of
-Version 7 Unix (1978) and the new version first made widely available in
-System V Release 3.1 (1987). This section summarizes the changes, with
-cross-references to further details.
-
-@itemize @bullet
-@item
-The requirement for @samp{;} to separate rules on a line
-(@pxref{Statements/Lines, ,@code{awk} Statements versus Lines}).
-
-@item
-User-defined functions, and the @code{return} statement
-(@pxref{User-defined, ,User-defined Functions}).
-
-@item
-The @code{delete} statement (@pxref{Delete, ,The @code{delete} Statement}).
-
-@item
-The @code{do}-@code{while} statement
-(@pxref{Do Statement, ,The @code{do}-@code{while} Statement}).@refill
-
-@item
-The built-in functions @code{atan2}, @code{cos}, @code{sin}, @code{rand} and
-@code{srand} (@pxref{Numeric Functions, ,Numeric Built-in Functions}).
-
-@item
-The built-in functions @code{gsub}, @code{sub}, and @code{match}
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).
-
-@item
-The built-in functions @code{close}, which closes an open file, and
-@code{system}, which allows the user to execute operating system
-commands (@pxref{I/O Functions, ,Built-in Functions for Input/Output}).@refill
-@c Does the above verbiage prevents an overfull hbox? --mew, rjc 24jan1992
-
-@item
-The @code{ARGC}, @code{ARGV}, @code{FNR}, @code{RLENGTH}, @code{RSTART},
-and @code{SUBSEP} built-in variables (@pxref{Built-in Variables}).
-
-@item
-The conditional expression using the operators @samp{?} and @samp{:}
-(@pxref{Conditional Exp, ,Conditional Expressions}).@refill
-
-@item
-The exponentiation operator @samp{^}
-(@pxref{Arithmetic Ops, ,Arithmetic Operators}) and its assignment operator
-form @samp{^=} (@pxref{Assignment Ops, ,Assignment Expressions}).@refill
-
-@item
-C-compatible operator precedence, which breaks some old @code{awk}
-programs (@pxref{Precedence, ,Operator Precedence (How Operators Nest)}).
-
-@item
-Regexps as the value of @code{FS}
-(@pxref{Field Separators, ,Specifying how Fields are Separated}), and as the
-third argument to the @code{split} function
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill
-
-@item
-Dynamic regexps as operands of the @samp{~} and @samp{!~} operators
-(@pxref{Regexp Usage, ,How to Use Regular Expressions}).
-
-@item
-Escape sequences (@pxref{Constants, ,Constant Expressions}) in regexps.@refill
-
-@item
-The escape sequences @samp{\b}, @samp{\f}, and @samp{\r}
-(@pxref{Constants, ,Constant Expressions}).
-
-@item
-Redirection of input for the @code{getline} function
-(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill
-
-@item
-Multiple @code{BEGIN} and @code{END} rules
-(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}).@refill
-
-@item
-Simulated multi-dimensional arrays
-(@pxref{Multi-dimensional, ,Multi-dimensional Arrays}).@refill
-@end itemize
-
-@node S5R4, POSIX, V7/S5R3.1, Language History
-@section Changes between S5R3.1 and S5R4
-
-The System V Release 4 version of Unix @code{awk} added these features
-(some of which originated in @code{gawk}):
-
-@itemize @bullet
-@item
-The @code{ENVIRON} variable (@pxref{Built-in Variables}).
-
-@item
-Multiple @samp{-f} options on the command line
-(@pxref{Command Line, ,Invoking @code{awk}}).@refill
-
-@item
-The @samp{-v} option for assigning variables before program execution begins
-(@pxref{Command Line, ,Invoking @code{awk}}).@refill
-
-@item
-The @samp{--} option for terminating command line options.
-
-@item
-The @samp{\a}, @samp{\v}, and @samp{\x} escape sequences
-(@pxref{Constants, ,Constant Expressions}).@refill
-
-@item
-A defined return value for the @code{srand} built-in function
-(@pxref{Numeric Functions, ,Numeric Built-in Functions}).
-
-@item
-The @code{toupper} and @code{tolower} built-in string functions
-for case translation
-(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill
-
-@item
-A cleaner specification for the @samp{%c} format-control letter in the
-@code{printf} function
-(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill
-
-@item
-The ability to dynamically pass the field width and precision (@code{"%*.*d"})
-in the argument list of the @code{printf} function
-(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill
-
-@item
-The use of constant regexps such as @code{/foo/} as expressions, where
-they are equivalent to use of the matching operator, as in @code{$0 ~
-/foo/} (@pxref{Constants, ,Constant Expressions}).
-@end itemize
-
-@node POSIX, POSIX/GNU, S5R4, Language History
-@section Changes between S5R4 and POSIX @code{awk}
-
-The @sc{posix} Command Language and Utilities standard for @code{awk}
-introduced the following changes into the language:
-
-@itemize @bullet{}
-@item
-The use of @samp{-W} for implementation-specific options.
-
-@item
-The use of @code{CONVFMT} for controlling the conversion of numbers
-to strings (@pxref{Conversion, ,Conversion of Strings and Numbers}).
-
-@item
-The concept of a numeric string, and tighter comparison rules to go
-with it (@pxref{Comparison Ops, ,Comparison Expressions}).
-
-@item
-More complete documentation of many of the previously undocumented
-features of the language.
-@end itemize
-
-@node POSIX/GNU, , POSIX, Language History
-@section Extensions in @code{gawk} not in POSIX @code{awk}
-
-The GNU implementation, @code{gawk}, adds these features:
-
-@itemize @bullet
-@item
-The @code{AWKPATH} environment variable for specifying a path search for
-the @samp{-f} command line option
-(@pxref{Command Line, ,Invoking @code{awk}}).@refill
-
-@item
-The various @code{gawk} specific features available via the @samp{-W}
-command line option (@pxref{Command Line, ,Invoking @code{awk}}).
-
-@item
-The @code{ARGIND} variable, that tracks the movement of @code{FILENAME}
-through @code{ARGV}. (@pxref{Built-in Variables}).
-
-@item
-The @code{ERRNO} variable, that contains the system error message when
-@code{getline} returns @minus{}1, or when @code{close} fails.
-(@pxref{Built-in Variables}).
-
-@item
-The @code{IGNORECASE} variable and its effects
-(@pxref{Case-sensitivity, ,Case-sensitivity in Matching}).@refill
-
-@item
-The @code{FIELDWIDTHS} variable and its effects
-(@pxref{Constant Size, ,Reading Fixed-width Data}).@refill
-
-@item
-The @code{next file} statement for skipping to the next data file
-(@pxref{Next File Statement, ,The @code{next file} Statement}).@refill
-
-@item
-The @code{systime} and @code{strftime} built-in functions for obtaining
-and printing time stamps
-(@pxref{Time Functions, ,Functions for Dealing with Time Stamps}).@refill
-
-@item
-The @file{/dev/stdin}, @file{/dev/stdout}, @file{/dev/stderr}, and
-@file{/dev/fd/@var{n}} file name interpretation
-(@pxref{Special Files, ,Standard I/O Streams}).@refill
-
-@item
-The @samp{-W compat} option to turn off these extensions
-(@pxref{Command Line, ,Invoking @code{awk}}).@refill
-
-@item
-The @samp{-W posix} option for full @sc{posix} compliance
-(@pxref{Command Line, ,Invoking @code{awk}}).@refill
-
-@end itemize
-
-@node Installation, Gawk Summary, Language History, Top
-@chapter Installing @code{gawk}
-
-This chapter provides instructions for installing @code{gawk} on the
-various platforms that are supported by the developers. The primary
-developers support Unix (and one day, GNU), while the other ports were
-contributed. The file @file{ACKNOWLEDGMENT} in the @code{gawk}
-distribution lists the electronic mail addresses of the people who did
-the respective ports.@refill
-
-@menu
-* Gawk Distribution:: What is in the @code{gawk} distribution.
-* Unix Installation:: Installing @code{gawk} under various versions
- of Unix.
-* VMS Installation:: Installing @code{gawk} on VMS.
-* MS-DOS Installation:: Installing @code{gawk} on MS-DOS.
-* Atari Installation:: Installing @code{gawk} on the Atari ST.
-@end menu
-
-@node Gawk Distribution, Unix Installation, Installation, Installation
-@section The @code{gawk} Distribution
-
-This section first describes how to get and extract the @code{gawk}
-distribution, and then discusses what is in the various files and
-subdirectories.
-
-@menu
-* Extracting:: How to get and extract the distribution.
-* Distribution contents:: What is in the distribution.
-@end menu
-
-@node Extracting, Distribution contents, Gawk Distribution, Gawk Distribution
-@subsection Getting the @code{gawk} Distribution
-
-@cindex getting gawk
-@cindex anonymous ftp
-@cindex anonymous uucp
-@cindex ftp, anonymous
-@cindex uucp, anonymous
-@code{gawk} is distributed as a @code{tar} file compressed with the
-GNU Zip program, @code{gzip}. You can
-get it via anonymous @code{ftp} to the Internet host @code{prep.ai.mit.edu}.
-Like all GNU software, it will be archived at other well known systems,
-from which it will be possible to use some sort of anonymous @code{uucp} to
-obtain the distribution as well.
-You can also order @code{gawk} on tape or CD-ROM directly from the
-Free Software Foundation. (The address is on the copyright page.)
-Doing so directly contributes to the support of the foundation and to
-the production of more free software.
-
-Once you have the distribution (for example,
-@file{gawk-2.15.0.tar.z}), first use @code{gzip} to expand the
-file, and then use @code{tar} to extract it. You can use the following
-pipeline to produce the @code{gawk} distribution:
-
-@example
-# Under System V, add 'o' to the tar flags
-gzip -d -c gawk-2.15.0.tar.z | tar -xvpf -
-@end example
-
-@noindent
-This will create a directory named @file{gawk-2.15} in the current
-directory.
-
-The distribution file name is of the form @file{gawk-2.15.@var{n}.tar.Z}.
-The @var{n} represents a @dfn{patchlevel}, meaning that minor bugs have
-been fixed in the major release. The current patchlevel is 0, but when
-retrieving distributions, you should get the version with the highest
-patchlevel.@refill
-
-If you are not on a Unix system, you will need to make other arrangements
-for getting and extracting the @code{gawk} distribution. You should consult
-a local expert.
-
-@node Distribution contents, , Extracting, Gawk Distribution
-@subsection Contents of the @code{gawk} Distribution
-
-@code{gawk} has a number of C source files, documentation files,
-subdirectories and files related to the configuration process
-(@pxref{Unix Installation, ,Compiling and Installing @code{gawk} on Unix}),
-and several subdirectories related to different, non-Unix,
-operating systems.@refill
-
-@table @asis
-@item various @samp{.c}, @samp{.y}, and @samp{.h} files
-
-The C and YACC source files are the actual @code{gawk} source code.
-@end table
-
-@table @file
-@item README
-@itemx README.VMS
-@itemx README.dos
-@itemx README.rs6000
-@itemx README.ultrix
-Descriptive files: @file{README} for @code{gawk} under Unix, and the
-rest for the various hardware and software combinations.
-
-@item PORTS
-A list of systems to which @code{gawk} has been ported, and which
-have successfully run the test suite.
-
-@item ACKNOWLEDGMENT
-A list of the people who contributed major parts of the code or documentation.
-
-@item NEWS
-A list of changes to @code{gawk} since the last release or patch.
-
-@item COPYING
-The GNU General Public License.
-
-@item FUTURES
-A brief list of features and/or changes being contemplated for future
-releases, with some indication of the time frame for the feature, based
-on its difficulty.
-
-@item LIMITATIONS
-A list of those factors that limit @code{gawk}'s performance.
-Most of these depend on the hardware or operating system software, and
-are not limits in @code{gawk} itself.@refill
-
-@item PROBLEMS
-A file describing known problems with the current release.
-
-@item gawk.1
-The @code{troff} source for a manual page describing @code{gawk}.
-
-@item gawk.texinfo
-@ifinfo
-The @code{texinfo} source file for this Info file.
-It should be processed with @TeX{} to produce a printed manual, and
-with @code{makeinfo} to produce the Info file.@refill
-@end ifinfo
-@iftex
-The @code{texinfo} source file for this manual.
-It should be processed with @TeX{} to produce a printed manual, and
-with @code{makeinfo} to produce the Info file.@refill
-@end iftex
-
-@item Makefile.in
-@itemx config
-@itemx config.in
-@itemx configure
-@itemx missing
-@itemx mungeconf
-These files and subdirectories are used when configuring @code{gawk}
-for various Unix systems. They are explained in detail in
-@ref{Unix Installation, ,Compiling and Installing @code{gawk} on Unix}.@refill
-
-@item atari
-Files needed for building @code{gawk} on an Atari ST.
-@xref{Atari Installation, ,Installing @code{gawk} on the Atari ST}, for details.
-
-@item pc
-Files needed for building @code{gawk} under MS-DOS.
-@xref{MS-DOS Installation, ,Installing @code{gawk} on MS-DOS}, for details.
-
-@item vms
-Files needed for building @code{gawk} under VMS.
-@xref{VMS Installation, ,Compiling Installing and Running @code{gawk} on VMS}, for details.
-
-@item test
-Many interesting @code{awk} programs, provided as a test suite for
-@code{gawk}. You can use @samp{make test} from the top level @code{gawk}
-directory to run your version of @code{gawk} against the test suite.
-@c There are many programs here that are useful in their own right.
-If @code{gawk} successfully passes @samp{make test} then you can
-be confident of a successful port.@refill
-@end table
-
-@node Unix Installation, VMS Installation, Gawk Distribution, Installation
-@section Compiling and Installing @code{gawk} on Unix
-
-Often, you can compile and install @code{gawk} by typing only two
-commands. However, if you do not use a supported system, you may need
-to configure @code{gawk} for your system yourself.
-
-@menu
-* Quick Installation:: Compiling @code{gawk} on a
- supported Unix version.
-* Configuration Philosophy:: How it's all supposed to work.
-* New Configurations:: What to do if there is no supplied
- configuration for your system.
-@end menu
-
-@node Quick Installation, Configuration Philosophy, Unix Installation, Unix Installation
-@subsection Compiling @code{gawk} for a Supported Unix Version
-
-@cindex installation, unix
-After you have extracted the @code{gawk} distribution, @code{cd}
-to @file{gawk-2.15}. Look in the @file{config} subdirectory for a
-file that matches your hardware/software combination. In general,
-only the software is relevant; for example @code{sunos41} is used
-for SunOS 4.1, on both Sun 3 and Sun 4 hardware.@refill
-
-If you find such a file, run the command:
-
-@example
-# assume you have SunOS 4.1
-./configure sunos41
-@end example
-
-This produces a @file{Makefile} and @file{config.h} tailored to your
-system. You may wish to edit the @file{Makefile} to use a different
-C compiler, such as @code{gcc}, the GNU C compiler, if you have it.
-You may also wish to change the @code{CFLAGS} variable, which controls
-the command line options that are passed to the C compiler (such as
-optimization levels, or compiling for debugging).@refill
-
-After you have configured @file{Makefile} and @file{config.h}, type:
-
-@example
-make
-@end example
-
-@noindent
-and shortly thereafter, you should have an executable version of @code{gawk}.
-That's all there is to it!
-
-@node Configuration Philosophy, New Configurations, Quick Installation, Unix Installation
-@subsection The Configuration Process
-
-(This section is of interest only if you know something about using the
-C language and the Unix operating system.)
-
-The source code for @code{gawk} generally attempts to adhere to industry
-standards wherever possible. This means that @code{gawk} uses library
-routines that are specified by the @sc{ansi} C standard and by the @sc{posix}
-operating system interface standard. When using an @sc{ansi} C compiler,
-function prototypes are provided to help improve the compile-time checking.
-
-Many older Unix systems do not support all of either the @sc{ansi} or the
-@sc{posix} standards. The @file{missing} subdirectory in the @code{gawk}
-distribution contains replacement versions of those subroutines that are
-most likely to be missing.
-
-The @file{config.h} file that is created by the @code{configure} program
-contains definitions that describe features of the particular operating
-system where you are attempting to compile @code{gawk}. For the most
-part, it lists which standard subroutines are @emph{not} available.
-For example, if your system lacks the @samp{getopt} routine, then
-@samp{GETOPT_MISSING} would be defined.
-
-@file{config.h} also defines constants that describe facts about your
-variant of Unix. For example, there may not be an @samp{st_blksize}
-element in the @code{stat} structure. In this case @samp{BLKSIZE_MISSING}
-would be defined.
-
-Based on the list in @file{config.h} of standard subroutines that are
-missing, @file{missing.c} will do a @samp{#include} of the appropriate
-file(s) from the @file{missing} subdirectory.@refill
-
-Conditionally compiled code in the other source files relies on the
-other definitions in the @file{config.h} file.
-
-Besides creating @file{config.h}, @code{configure} produces a @file{Makefile}
-from @file{Makefile.in}. There are a number of lines in @file{Makefile.in}
-that are system or feature specific. For example, there is line that begins
-with @samp{##MAKE_ALLOCA_C##}. This is normally a comment line, since
-it starts with @samp{#}. If a configuration file has @samp{MAKE_ALLOCA_C}
-in it, then @code{configure} will delete the @samp{##MAKE_ALLOCA_C##}
-from the beginning of the line. This will enable the rules in the
-@file{Makefile} that use a C version of @samp{alloca}. There are several
-similar features that work in this fashion.@refill
-
-@node New Configurations, , Configuration Philosophy, Unix Installation
-@subsection Configuring @code{gawk} for a New System
-
-(This section is of interest only if you know something about using the
-C language and the Unix operating system, and if you have to install
-@code{gawk} on a system that is not supported by the @code{gawk} distribution.
-If you are a C or Unix novice, get help from a local expert.)
-
-If you need to configure @code{gawk} for a Unix system that is not
-supported in the distribution, first see
-@ref{Configuration Philosophy, ,The Configuration Process}.
-Then, copy @file{config.in} to @file{config.h}, and copy
-@file{Makefile.in} to @file{Makefile}.@refill
-
-Next, edit both files. Both files are liberally commented, and the
-necessary changes should be straightforward.
-
-While editing @file{config.h}, you need to determine what library
-routines you do or do not have by consulting your system documentation, or
-by perusing your actual libraries using the @code{ar} or @code{nm} utilities.
-In the worst case, simply do not define @emph{any} of the macros for missing
-subroutines. When you compile @code{gawk}, the final link-editing step
-will fail. The link editor will provide you with a list of unresolved external
-references---these are the missing subroutines. Edit @file{config.h} again
-and recompile, and you should be set.@refill
-
-Editing the @file{Makefile} should also be straightforward. Enable or
-disable the lines that begin with @samp{##MAKE_@var{whatever}##}, as
-appropriate. Select the correct C compiler and @code{CFLAGS} for it.
-Then run @code{make}.
-
-Getting a correct configuration is likely to be an iterative process.
-Do not be discouraged if it takes you several tries. If you have no
-luck whatsoever, please report your system type, and the steps you took.
-Once you do have a working configuration, please send it to the maintainers
-so that support for your system can be added to the official release.
-
-@xref{Bugs, ,Reporting Problems and Bugs}, for information on how to report
-problems in configuring @code{gawk}. You may also use the same mechanisms
-for sending in new configurations.@refill
-
-@node VMS Installation, MS-DOS Installation, Unix Installation, Installation
-@section Compiling, Installing, and Running @code{gawk} on VMS
-
-@c based on material from
-@c Pat Rankin <rankin@eql.caltech.edu>
-
-@cindex installation, vms
-This section describes how to compile and install @code{gawk} under VMS.
-
-@menu
-* VMS Compilation:: How to compile @code{gawk} under VMS.
-* VMS Installation Details:: How to install @code{gawk} under VMS.
-* VMS Running:: How to run @code{gawk} under VMS.
-* VMS POSIX:: Alternate instructions for VMS POSIX.
-@end menu
-
-@node VMS Compilation, VMS Installation Details, VMS Installation, VMS Installation
-@subsection Compiling @code{gawk} under VMS
-
-To compile @code{gawk} under VMS, there is a @code{DCL} command procedure that
-will issue all the necessary @code{CC} and @code{LINK} commands, and there is
-also a @file{Makefile} for use with the @code{MMS} utility. From the source
-directory, use either
-
-@smallexample
-$ @@[.VMS]VMSBUILD.COM
-@end smallexample
-
-@noindent
-or
-
-@smallexample
-$ MMS/DESCRIPTION=[.VMS]DECSRIP.MMS GAWK
-@end smallexample
-
-Depending upon which C compiler you are using, follow one of the sets
-of instructions in this table:
-
-@table @asis
-@item VAX C V3.x
-Use either @file{vmsbuild.com} or @file{descrip.mms} as is. These use
-@code{CC/OPTIMIZE=NOLINE}, which is essential for Version 3.0.
-
-@item VAX C V2.x
-You must have Version 2.3 or 2.4; older ones won't work. Edit either
-@file{vmsbuild.com} or @file{descrip.mms} according to the comments in them.
-For @file{vmsbuild.com}, this just entails removing two @samp{!} delimiters.
-Also edit @file{config.h} (which is a copy of file @file{[.config]vms-conf.h})
-and comment out or delete the two lines @samp{#define __STDC__ 0} and
-@samp{#define VAXC_BUILTINS} near the end.@refill
-
-@item GNU C
-Edit @file{vmsbuild.com} or @file{descrip.mms}; the changes are different
-from those for VAX C V2.x, but equally straightforward. No changes to
-@file{config.h} should be needed.
-
-@item DEC C
-Edit @file{vmsbuild.com} or @file{descrip.mms} according to their comments.
-No changes to @file{config.h} should be needed.
-@end table
-
-@code{gawk} 2.15 has been tested under VAX/VMS 5.5-1 using VAX C V3.2,
-GNU C 1.40 and 2.3. It should work without modifications for VMS V4.6 and up.
-
-@node VMS Installation Details, VMS Running, VMS Compilation, VMS Installation
-@subsection Installing @code{gawk} on VMS
-
-To install @code{gawk}, all you need is a ``foreign'' command, which is
-a @code{DCL} symbol whose value begins with a dollar sign.
-
-@smallexample
-$ GAWK :== $device:[directory]GAWK
-@end smallexample
-
-@noindent
-(Substitute the actual location of @code{gawk.exe} for
-@samp{device:[directory]}.) The symbol should be placed in the
-@file{login.com} of any user who wishes to run @code{gawk},
-so that it will be defined every time the user logs on.
-Alternatively, the symbol may be placed in the system-wide
-@file{sylogin.com} procedure, which will allow all users
-to run @code{gawk}.@refill
-
-Optionally, the help entry can be loaded into a VMS help library:
-
-@smallexample
-$ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP
-@end smallexample
-
-@noindent
-(You may want to substitute a site-specific help library rather than
-the standard VMS library @samp{HELPLIB}.) After loading the help text,
-
-@c this is so tiny, but `should' be smallexample for consistency sake...
-@c I didn't because it was so short. --mew 29jan1992
-@example
-$ HELP GAWK
-@end example
-
-@noindent
-will provide information about both the @code{gawk} implementation and the
-@code{awk} programming language.
-
-The logical name @samp{AWK_LIBRARY} can designate a default location
-for @code{awk} program files. For the @samp{-f} option, if the specified
-filename has no device or directory path information in it, @code{gawk}
-will look in the current directory first, then in the directory specified
-by the translation of @samp{AWK_LIBRARY} if the file was not found.
-If after searching in both directories, the file still is not found,
-then @code{gawk} appends the suffix @samp{.awk} to the filename and the
-file search will be re-tried. If @samp{AWK_LIBRARY} is not defined, that
-portion of the file search will fail benignly.@refill
-
-@node VMS Running, VMS POSIX, VMS Installation Details, VMS Installation
-@subsection Running @code{gawk} on VMS
-
-Command line parsing and quoting conventions are significantly different
-on VMS, so examples in this manual or from other sources often need minor
-changes. They @emph{are} minor though, and all @code{awk} programs
-should run correctly.
-
-Here are a couple of trivial tests:
-
-@smallexample
-$ gawk -- "BEGIN @{print ""Hello, World!""@}"
-$ gawk -"W" version ! could also be -"W version" or "-W version"
-@end smallexample
-
-@noindent
-Note that upper-case and mixed-case text must be quoted.
-
-The VMS port of @code{gawk} includes a @code{DCL}-style interface in addition
-to the original shell-style interface (see the help entry for details).
-One side-effect of dual command line parsing is that if there is only a
-single parameter (as in the quoted string program above), the command
-becomes ambiguous. To work around this, the normally optional @samp{--}
-flag is required to force Unix style rather than @code{DCL} parsing. If any
-other dash-type options (or multiple parameters such as data files to be
-processed) are present, there is no ambiguity and @samp{--} can be omitted.
-
-The default search path when looking for @code{awk} program files specified
-by the @samp{-f} option is @code{"SYS$DISK:[],AWK_LIBRARY:"}. The logical
-name @samp{AWKPATH} can be used to override this default. The format
-of @samp{AWKPATH} is a comma-separated list of directory specifications.
-When defining it, the value should be quoted so that it retains a single
-translation, and not a multi-translation @code{RMS} searchlist.
-
-@node VMS POSIX, , VMS Running, VMS Installation
-@subsection Building and using @code{gawk} under VMS POSIX
-
-Ignore the instructions above, although @file{vms/gawk.hlp} should still
-be made available in a help library. Make sure that the two scripts,
-@file{configure} and @file{mungeconf}, are executable; use @samp{chmod +x}
-on them if necessary. Then execute the following commands:
-
-@smallexample
-$ POSIX
-psx> configure vms-posix
-psx> make awktab.c gawk
-@end smallexample
-
-@noindent
-The first command will construct files @file{config.h} and @file{Makefile}
-out of templates. The second command will compile and link @code{gawk}.
-Due to a @code{make} bug in VMS POSIX V1.0 and V1.1,
-the file @file{awktab.c} must be given as an explicit target or it will
-not be built and the final link step will fail. Ignore the warning
-@samp{"Could not find lib m in lib list"}; it is harmless, caused by the
-explicit use of @samp{-lm} as a linker option which is not needed
-under VMS POSIX. Under V1.1 (but not V1.0) a problem with the @code{yacc}
-skeleton @file{/etc/yyparse.c} will cause a compiler warning for
-@file{awktab.c}, followed by a linker warning about compilation warnings
-in the resulting object module. These warnings can be ignored.@refill
-
-Once built, @code{gawk} will work like any other shell utility. Unlike
-the normal VMS port of @code{gawk}, no special command line manipulation is
-needed in the VMS POSIX environment.
-
-@node MS-DOS Installation, Atari Installation, VMS Installation, Installation
-@section Installing @code{gawk} on MS-DOS
-
-@cindex installation, ms-dos
-The first step is to get all the files in the @code{gawk} distribution
-onto your PC. Move all the files from the @file{pc} directory into
-the main directory where the other files are. Edit the file
-@file{make.bat} so that it will be an acceptable MS-DOS batch file.
-This means making sure that all lines are terminated with the ASCII
-carriage return and line feed characters.
-restrictions.
-
-@code{gawk} has only been compiled with version 5.1 of the Microsoft
-C compiler. The file @file{make.bat} from the @file{pc} directory
-assumes that you have this compiler.
-
-Copy the file @file{setargv.obj} from the library directory where it
-resides to the @code{gawk} source code directory.
-
-Run @file{make.bat}. This will compile @code{gawk} for you, and link it.
-That's all there is to it!
-
-@node Atari Installation, , MS-DOS Installation, Installation
-@section Installing @code{gawk} on the Atari ST
-
-@c based on material from
-@c Michal Jaegermann <ntomczak@vm.ucs.ualberta.ca>
-
-@cindex installation, atari
-This section assumes that you are running TOS. It applies to other Atari
-models (STe, TT) as well.
-
-In order to use @code{gawk}, you need to have a shell, either text or
-graphics, that does not map all the characters of a command line to
-upper case. Maintaining case distinction in option flags is very
-important (@pxref{Command Line, ,Invoking @code{awk}}). Popular shells
-like @code{gulam} or @code{gemini} will work, as will newer versions of
-@code{desktop}. Support for I/O redirection is necessary to make it easy
-to import @code{awk} programs from other environments. Pipes are nice to have,
-but not vital.
-
-If you have received an executable version of @code{gawk}, place it,
-as usual, anywhere in your @code{PATH} where your shell will find it.
-
-While executing, @code{gawk} creates a number of temporary files.
-@code{gawk} looks for either of the environment variables @code{TEMP}
-or @code{TMPDIR}, in that order. If either one is found, its value
-is assumed to be a directory for temporary files. This directory
-must exist, and if you can spare the memory, it is a good idea to
-put it on a @sc{ram} drive. If neither @code{TEMP} nor @code{TMPDIR}
-are found, then @code{gawk} uses the current directory for its
-temporary files.
-
-The ST version of @code{gawk} searches for its program files as
-described in @ref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}.
-On the ST, the default value for the @code{AWKPATH} variable is
-@code{@w{".,c:\lib\awk,c:\gnu\lib\awk"}}.
-The search path can be modified by explicitly setting @code{AWKPATH} to
-whatever you wish. Note that colons cannot be used on the ST to separate
-elements in the @code{AWKPATH} variable, since they have another, reserved,
-meaning. Instead, you must use a comma to separate elements in the path.
-If you are recompiling @code{gawk} on the ST, then you can choose a new
-default search path, by setting the value of @samp{DEFPATH} in the file
-@file{...\config\atari}. You may choose a different separator character
-by setting the value of @samp{ENVSEP} in the same file. The new values will
-be used when creating the header file @file{config.h}.@refill
-
-@ignore
-As a last resort, small
-adjustments can be made directly on the executable version of @code{gawk}
-using a binary editor.@refill
-@end ignore
-
-Although @code{awk} allows great flexibility in doing I/O redirections
-from within a program, this facility should be used with care on the ST.
-In some circumstances the OS routines for file handle pool processing
-lose track of certain events, causing the computer to crash, and requiring
-a reboot. Often a warm reboot is sufficient. Fortunately, this happens
-infrequently, and in rather esoteric situations. In particular, avoid
-having one part of an @code{awk} program using @code{print}
-statements explicitly redirected to @code{"/dev/stdout"}, while other
-@code{print} statements use the default standard output, and a
-calling shell has redirected standard output to a file.@refill
-@c whew!
-
-When @code{gawk} is compiled with the ST version of @code{gcc} and its
-usual libraries, it will accept both @samp{/} and @samp{\} as path separators.
-While this is convenient, it should be remembered that this removes one,
-technically legal, character (@samp{/}) from your file names, and that
-it may create problems for external programs, called via the @code{system()}
-function, which may not support this convention. Whenever it is possible
-that a file created by @code{gawk} will be used by some other program,
-use only backslashes. Also remember that in @code{awk}, backslashes in
-strings have to be doubled in order to get literal backslashes.
-
-The initial port of @code{gawk} to the ST was done with @code{gcc}.
-If you wish to recompile @code{gawk} from scratch, you will need to use
-a compiler that accepts @sc{ansi} standard C (such as @code{gcc}, Turbo C,
-or Prospero C). If @code{sizeof(int) != @w{sizeof(int *)}}, the correctness
-of the generated code depends heavily on the fact that all function calls
-have function prototypes in the current scope. If your compiler does
-not accept function prototypes, you will probably have to add a
-number of casts to the code.@refill
-
-If you are using @code{gcc}, make sure that you have up-to-date libraries.
-Older versions have problems with some library functions (@code{atan2()},
-@code{strftime()}, the @samp{%g} conversion in @code{sprintf()}) which
-may affect the operation of @code{gawk}.
-
-In the @file{atari} subdirectory of the @code{gawk} distribution is
-a version of the @code{system()} function that has been tested with
-@code{gulam} and @code{msh}; it should work with other shells as well.
-With @code{gulam}, it passes the string to be executed without spawning
-an extra copy of a shell. It is possible to replace this version of
-@code{system()} with a similar function from a library or from some other
-source if that version would be a better choice for the shell you prefer.
-
-The files needed to recompile @code{gawk} on the ST can be found in
-the @file{atari} directory. The provided files and instructions below
-assume that you have the GNU C compiler (@code{gcc}), the @code{gulam} shell,
-and an ST version of @code{sed}. The @file{Makefile} is set up to use
-@file{byacc} as a @file{yacc} replacement. With a different set of tools some
-adjustments and/or editing will be needed.@refill
-
-@code{cd} to the @file{atari} directory. Copy @file{Makefile.st} to
-@file{makefile} in the source (parent) directory. Possibly adjust
-@file{../config/atari} to suit your system. Execute the script @file{mkconf.g}
-which will create the header file @file{../config.h}. Go back to the source
-directory. If you are not using @code{gcc}, check the file @file{missing.c}.
-It may be necessary to change forward slashes in the references to files
-from the @file{atari} subdirectory into backslashes. Type @code{make} and
-enjoy.@refill
-
-Compilation with @code{gcc} of some of the bigger modules, like
-@file{awk_tab.c}, may require a full four megabytes of memory. On smaller
-machines you would need to cut down on optimizations, or you would have to
-switch to another, less memory hungry, compiler.@refill
-
-@node Gawk Summary, Sample Program, Installation, Top
-@appendix @code{gawk} Summary
-
-This appendix provides a brief summary of the @code{gawk} command line and the
-@code{awk} language. It is designed to serve as ``quick reference.'' It is
-therefore terse, but complete.
-
-@menu
-* Command Line Summary:: Recapitulation of the command line.
-* Language Summary:: A terse review of the language.
-* Variables/Fields:: Variables, fields, and arrays.
-* Rules Summary:: Patterns and Actions, and their
- component parts.
-* Functions Summary:: Defining and calling functions.
-* Historical Features:: Some undocumented but supported ``features''.
-@end menu
-
-@node Command Line Summary, Language Summary, Gawk Summary, Gawk Summary
-@appendixsec Command Line Options Summary
-
-The command line consists of options to @code{gawk} itself, the
-@code{awk} program text (if not supplied via the @samp{-f} option), and
-values to be made available in the @code{ARGC} and @code{ARGV}
-predefined @code{awk} variables:
-
-@example
-awk @r{[@var{POSIX or GNU style options}]} -f source-file @r{[@code{--}]} @var{file} @dots{}
-awk @r{[@var{POSIX or GNU style options}]} @r{[@code{--}]} '@var{program}' @var{file} @dots{}
-@end example
-
-The options that @code{gawk} accepts are:
-
-@table @code
-@item -F @var{fs}
-@itemx --field-separator=@var{fs}
-Use @var{fs} for the input field separator (the value of the @code{FS}
-predefined variable).
-
-@item -f @var{program-file}
-@itemx --file=@var{program-file}
-Read the @code{awk} program source from the file @var{program-file}, instead
-of from the first command line argument.
-
-@item -v @var{var}=@var{val}
-@itemx --assign=@var{var}=@var{val}
-Assign the variable @var{var} the value @var{val} before program execution
-begins.
-
-@item -W compat
-@itemx --compat
-Specifies compatibility mode, in which @code{gawk} extensions are turned
-off.
-
-@item -W copyleft
-@itemx -W copyright
-@itemx --copyleft
-@itemx --copyright
-Print the short version of the General Public License on the error
-output. This option may disappear in a future version of @code{gawk}.
-
-@item -W help
-@itemx -W usage
-@itemx --help
-@itemx --usage
-Print a relatively short summary of the available options on the error output.
-
-@item -W lint
-@itemx --lint
-Give warnings about dubious or non-portable @code{awk} constructs.
-
-@item -W posix
-@itemx --posix
-Specifies @sc{posix} compatibility mode, in which @code{gawk} extensions
-are turned off and additional restrictions apply.
-
-@item -W source=@var{program-text}
-@itemx --source=@var{program-text}
-Use @var{program-text} as @code{awk} program source code. This option allows
-mixing command line source code with source code from files, and is
-particularly useful for mixing command line programs with library functions.
-
-@item -W version
-@itemx --version
-Print version information for this particular copy of @code{gawk} on the error
-output. This option may disappear in a future version of @code{gawk}.
-
-@item --
-Signal the end of options. This is useful to allow further arguments to the
-@code{awk} program itself to start with a @samp{-}. This is mainly for
-consistency with the argument parsing conventions of @sc{posix}.
-@end table
-
-Any other options are flagged as invalid, but are otherwise ignored.
-@xref{Command Line, ,Invoking @code{awk}}, for more details.
-
-@node Language Summary, Variables/Fields, Command Line Summary, Gawk Summary
-@appendixsec Language Summary
-
-An @code{awk} program consists of a sequence of pattern-action statements
-and optional function definitions.
-
-@example
-@var{pattern} @{ @var{action statements} @}
-
-function @var{name}(@var{parameter list}) @{ @var{action statements} @}
-@end example
-
-@code{gawk} first reads the program source from the
-@var{program-file}(s) if specified, or from the first non-option
-argument on the command line. The @samp{-f} option may be used multiple
-times on the command line. @code{gawk} reads the program text from all
-the @var{program-file} files, effectively concatenating them in the
-order they are specified. This is useful for building libraries of
-@code{awk} functions, without having to include them in each new
-@code{awk} program that uses them. To use a library function in a file
-from a program typed in on the command line, specify @samp{-f /dev/tty};
-then type your program, and end it with a @kbd{Control-d}.
-@xref{Command Line, ,Invoking @code{awk}}.@refill
-
-The environment variable @code{AWKPATH} specifies a search path to use
-when finding source files named with the @samp{-f} option. The default
-path, which is
-@samp{.:/usr/lib/awk:/usr/local/lib/awk} is used if @code{AWKPATH} is not set.
-If a file name given to the @samp{-f} option contains a @samp{/} character,
-no path search is performed.
-@xref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable},
-for a full description of the @code{AWKPATH} environment variable.@refill
-
-@code{gawk} compiles the program into an internal form, and then proceeds to
-read each file named in the @code{ARGV} array. If there are no files named
-on the command line, @code{gawk} reads the standard input.
-
-If a ``file'' named on the command line has the form
-@samp{@var{var}=@var{val}}, it is treated as a variable assignment: the
-variable @var{var} is assigned the value @var{val}.
-If any of the files have a value that is the null string, that
-element in the list is skipped.@refill
-
-For each line in the input, @code{gawk} tests to see if it matches any
-@var{pattern} in the @code{awk} program. For each pattern that the line
-matches, the associated @var{action} is executed.
-
-@node Variables/Fields, Rules Summary, Language Summary, Gawk Summary
-@appendixsec Variables and Fields
-
-@code{awk} variables are dynamic; they come into existence when they are
-first used. Their values are either floating-point numbers or strings.
-@code{awk} also has one-dimension arrays; multiple-dimensional arrays
-may be simulated. There are several predefined variables that
-@code{awk} sets as a program runs; these are summarized below.
-
-@menu
-* Fields Summary:: Input field splitting.
-* Built-in Summary:: @code{awk}'s built-in variables.
-* Arrays Summary:: Using arrays.
-* Data Type Summary:: Values in @code{awk} are numbers or strings.
-@end menu
-
-@node Fields Summary, Built-in Summary, Variables/Fields, Variables/Fields
-@appendixsubsec Fields
-
-As each input line is read, @code{gawk} splits the line into
-@var{fields}, using the value of the @code{FS} variable as the field
-separator. If @code{FS} is a single character, fields are separated by
-that character. Otherwise, @code{FS} is expected to be a full regular
-expression. In the special case that @code{FS} is a single blank,
-fields are separated by runs of blanks and/or tabs. Note that the value
-of @code{IGNORECASE} (@pxref{Case-sensitivity, ,Case-sensitivity in Matching})
-also affects how fields are split when @code{FS} is a regular expression.@refill
-
-Each field in the input line may be referenced by its position, @code{$1},
-@code{$2}, and so on. @code{$0} is the whole line. The value of a field may
-be assigned to as well. Field numbers need not be constants:
-
-@example
-n = 5
-print $n
-@end example
-
-@noindent
-prints the fifth field in the input line. The variable @code{NF} is set to
-the total number of fields in the input line.
-
-References to nonexistent fields (i.e., fields after @code{$NF}) return
-the null-string. However, assigning to a nonexistent field (e.g.,
-@code{$(NF+2) = 5}) increases the value of @code{NF}, creates any
-intervening fields with the null string as their value, and causes the
-value of @code{$0} to be recomputed, with the fields being separated by
-the value of @code{OFS}.@refill
-
-@xref{Reading Files, ,Reading Input Files}, for a full description of the
-way @code{awk} defines and uses fields.
-
-@node Built-in Summary, Arrays Summary, Fields Summary, Variables/Fields
-@appendixsubsec Built-in Variables
-
-@code{awk}'s built-in variables are:
-
-@table @code
-@item ARGC
-The number of command line arguments (not including options or the
-@code{awk} program itself).
-
-@item ARGIND
-The index in @code{ARGV} of the current file being processed.
-It is always true that @samp{FILENAME == ARGV[ARGIND]}.
-
-@item ARGV
-The array of command line arguments. The array is indexed from 0 to
-@code{ARGC} @minus{} 1. Dynamically changing the contents of @code{ARGV}
-can control the files used for data.@refill
-
-@item CONVFMT
-The conversion format to use when converting numbers to strings.
-
-@item FIELDWIDTHS
-A space separated list of numbers describing the fixed-width input data.
-
-@item ENVIRON
-An array containing the values of the environment variables. The array
-is indexed by variable name, each element being the value of that
-variable. Thus, the environment variable @code{HOME} would be in
-@code{ENVIRON["HOME"]}. Its value might be @file{/u/close}.
-
-Changing this array does not affect the environment seen by programs
-which @code{gawk} spawns via redirection or the @code{system} function.
-(This may change in a future version of @code{gawk}.)
-
-Some operating systems do not have environment variables.
-The array @code{ENVIRON} is empty when running on these systems.
-
-@item ERRNO
-The system error message when an error occurs using @code{getline}
-or @code{close}.
-
-@item FILENAME
-The name of the current input file. If no files are specified on the command
-line, the value of @code{FILENAME} is @samp{-}.
-
-@item FNR
-The input record number in the current input file.
-
-@item FS
-The input field separator, a blank by default.
-
-@item IGNORECASE
-The case-sensitivity flag for regular expression operations. If
-@code{IGNORECASE} has a nonzero value, then pattern matching in rules,
-field splitting with @code{FS}, regular expression matching with
-@samp{~} and @samp{!~}, and the @code{gsub}, @code{index}, @code{match},
-@code{split} and @code{sub} predefined functions all ignore case
-when doing regular expression operations.@refill
-
-@item NF
-The number of fields in the current input record.
-
-@item NR
-The total number of input records seen so far.
-
-@item OFMT
-The output format for numbers for the @code{print} statement,
-@code{"%.6g"} by default.
-
-@item OFS
-The output field separator, a blank by default.
-
-@item ORS
-The output record separator, by default a newline.
-
-@item RS
-The input record separator, by default a newline. @code{RS} is exceptional
-in that only the first character of its string value is used for separating
-records. If @code{RS} is set to the null string, then records are separated by
-blank lines. When @code{RS} is set to the null string, then the newline
-character always acts as a field separator, in addition to whatever value
-@code{FS} may have.@refill
-
-@item RSTART
-The index of the first character matched by @code{match}; 0 if no match.
-
-@item RLENGTH
-The length of the string matched by @code{match}; @minus{}1 if no match.
-
-@item SUBSEP
-The string used to separate multiple subscripts in array elements, by
-default @code{"\034"}.
-@end table
-
-@xref{Built-in Variables}, for more information.
-
-@node Arrays Summary, Data Type Summary, Built-in Summary, Variables/Fields
-@appendixsubsec Arrays
-
-Arrays are subscripted with an expression between square brackets
-(@samp{[} and @samp{]}). Array subscripts are @emph{always} strings;
-numbers are converted to strings as necessary, following the standard
-conversion rules
-(@pxref{Conversion, ,Conversion of Strings and Numbers}).@refill
-
-If you use multiple expressions separated by commas inside the square
-brackets, then the array subscript is a string consisting of the
-concatenation of the individual subscript values, converted to strings,
-separated by the subscript separator (the value of @code{SUBSEP}).
-
-The special operator @code{in} may be used in an @code{if} or
-@code{while} statement to see if an array has an index consisting of a
-particular value.
-
-@example
-if (val in array)
- print array[val]
-@end example
-
-If the array has multiple subscripts, use @code{(i, j, @dots{}) in array}
-to test for existence of an element.
-
-The @code{in} construct may also be used in a @code{for} loop to iterate
-over all the elements of an array.
-@xref{Scanning an Array, ,Scanning all Elements of an Array}.@refill
-
-An element may be deleted from an array using the @code{delete} statement.
-
-@xref{Arrays, ,Arrays in @code{awk}}, for more detailed information.
-
-@node Data Type Summary, , Arrays Summary, Variables/Fields
-@appendixsubsec Data Types
-
-The value of an @code{awk} expression is always either a number
-or a string.
-
-Certain contexts (such as arithmetic operators) require numeric
-values. They convert strings to numbers by interpreting the text
-of the string as a numeral. If the string does not look like a
-numeral, it converts to 0.
-
-Certain contexts (such as concatenation) require string values.
-They convert numbers to strings by effectively printing them
-with @code{sprintf}.
-@xref{Conversion, ,Conversion of Strings and Numbers}, for the details.@refill
-
-To force conversion of a string value to a number, simply add 0
-to it. If the value you start with is already a number, this
-does not change it.
-
-To force conversion of a numeric value to a string, concatenate it with
-the null string.
-
-The @code{awk} language defines comparisons as being done numerically if
-both operands are numeric, or if one is numeric and the other is a numeric
-string. Otherwise one or both operands are converted to strings and a
-string comparison is performed.
-
-Uninitialized variables have the string value @code{""} (the null, or
-empty, string). In contexts where a number is required, this is
-equivalent to 0.
-
-@xref{Variables}, for more information on variable naming and initialization;
-@pxref{Conversion, ,Conversion of Strings and Numbers}, for more information
-on how variable values are interpreted.@refill
-
-@node Rules Summary, Functions Summary, Variables/Fields, Gawk Summary
-@appendixsec Patterns and Actions
-
-@menu
-* Pattern Summary:: Quick overview of patterns.
-* Regexp Summary:: Quick overview of regular expressions.
-* Actions Summary:: Quick overview of actions.
-@end menu
-
-An @code{awk} program is mostly composed of rules, each consisting of a
-pattern followed by an action. The action is enclosed in @samp{@{} and
-@samp{@}}. Either the pattern may be missing, or the action may be
-missing, but, of course, not both. If the pattern is missing, the
-action is executed for every single line of input. A missing action is
-equivalent to this action,
-
-@example
-@{ print @}
-@end example
-
-@noindent
-which prints the entire line.
-
-Comments begin with the @samp{#} character, and continue until the end of the
-line. Blank lines may be used to separate statements. Normally, a statement
-ends with a newline, however, this is not the case for lines ending in a
-@samp{,}, @samp{@{}, @samp{?}, @samp{:}, @samp{&&}, or @samp{||}. Lines
-ending in @code{do} or @code{else} also have their statements automatically
-continued on the following line. In other cases, a line can be continued by
-ending it with a @samp{\}, in which case the newline is ignored.@refill
-
-Multiple statements may be put on one line by separating them with a @samp{;}.
-This applies to both the statements within the action part of a rule (the
-usual case), and to the rule statements.
-
-@xref{Comments, ,Comments in @code{awk} Programs}, for information on
-@code{awk}'s commenting convention;
-@pxref{Statements/Lines, ,@code{awk} Statements versus Lines}, for a
-description of the line continuation mechanism in @code{awk}.@refill
-
-@node Pattern Summary, Regexp Summary, Rules Summary, Rules Summary
-@appendixsubsec Patterns
-
-@code{awk} patterns may be one of the following:
-
-@example
-/@var{regular expression}/
-@var{relational expression}
-@var{pattern} && @var{pattern}
-@var{pattern} || @var{pattern}
-@var{pattern} ? @var{pattern} : @var{pattern}
-(@var{pattern})
-! @var{pattern}
-@var{pattern1}, @var{pattern2}
-BEGIN
-END
-@end example
-
-@code{BEGIN} and @code{END} are two special kinds of patterns that are not
-tested against the input. The action parts of all @code{BEGIN} rules are
-merged as if all the statements had been written in a single @code{BEGIN}
-rule. They are executed before any of the input is read. Similarly, all the
-@code{END} rules are merged, and executed when all the input is exhausted (or
-when an @code{exit} statement is executed). @code{BEGIN} and @code{END}
-patterns cannot be combined with other patterns in pattern expressions.
-@code{BEGIN} and @code{END} rules cannot have missing action parts.@refill
-
-For @samp{/@var{regular-expression}/} patterns, the associated statement is
-executed for each input line that matches the regular expression. Regular
-expressions are extensions of those in @code{egrep}, and are summarized below.
-
-A @var{relational expression} may use any of the operators defined below in
-the section on actions. These generally test whether certain fields match
-certain regular expressions.
-
-The @samp{&&}, @samp{||}, and @samp{!} operators are logical ``and,''
-logical ``or,'' and logical ``not,'' respectively, as in C. They do
-short-circuit evaluation, also as in C, and are used for combining more
-primitive pattern expressions. As in most languages, parentheses may be
-used to change the order of evaluation.
-
-The @samp{?:} operator is like the same operator in C. If the first
-pattern matches, then the second pattern is matched against the input
-record; otherwise, the third is matched. Only one of the second and
-third patterns is matched.
-
-The @samp{@var{pattern1}, @var{pattern2}} form of a pattern is called a
-range pattern. It matches all input lines starting with a line that
-matches @var{pattern1}, and continuing until a line that matches
-@var{pattern2}, inclusive. A range pattern cannot be used as an operand
-to any of the pattern operators.
-
-@xref{Patterns}, for a full description of the pattern part of @code{awk}
-rules.
-
-@node Regexp Summary, Actions Summary, Pattern Summary, Rules Summary
-@appendixsubsec Regular Expressions
-
-Regular expressions are the extended kind found in @code{egrep}.
-They are composed of characters as follows:
-
-@table @code
-@item @var{c}
-matches the character @var{c} (assuming @var{c} is a character with no
-special meaning in regexps).
-
-@item \@var{c}
-matches the literal character @var{c}.
-
-@item .
-matches any character except newline.
-
-@item ^
-matches the beginning of a line or a string.
-
-@item $
-matches the end of a line or a string.
-
-@item [@var{abc}@dots{}]
-matches any of the characters @var{abc}@dots{} (character class).
-
-@item [^@var{abc}@dots{}]
-matches any character except @var{abc}@dots{} and newline (negated
-character class).
-
-@item @var{r1}|@var{r2}
-matches either @var{r1} or @var{r2} (alternation).
-
-@item @var{r1r2}
-matches @var{r1}, and then @var{r2} (concatenation).
-
-@item @var{r}+
-matches one or more @var{r}'s.
-
-@item @var{r}*
-matches zero or more @var{r}'s.
-
-@item @var{r}?
-matches zero or one @var{r}'s.
-
-@item (@var{r})
-matches @var{r} (grouping).
-@end table
-
-@xref{Regexp, ,Regular Expressions as Patterns}, for a more detailed
-explanation of regular expressions.
-
-The escape sequences allowed in string constants are also valid in
-regular expressions (@pxref{Constants, ,Constant Expressions}).
-
-@node Actions Summary, , Regexp Summary, Rules Summary
-@appendixsubsec Actions
-
-Action statements are enclosed in braces, @samp{@{} and @samp{@}}.
-Action statements consist of the usual assignment, conditional, and looping
-statements found in most languages. The operators, control statements,
-and input/output statements available are patterned after those in C.
-
-@menu
-* Operator Summary:: @code{awk} operators.
-* Control Flow Summary:: The control statements.
-* I/O Summary:: The I/O statements.
-* Printf Summary:: A summary of @code{printf}.
-* Special File Summary:: Special file names interpreted internally.
-* Numeric Functions Summary:: Built-in numeric functions.
-* String Functions Summary:: Built-in string functions.
-* Time Functions Summary:: Built-in time functions.
-* String Constants Summary:: Escape sequences in strings.
-@end menu
-
-@node Operator Summary, Control Flow Summary, Actions Summary, Actions Summary
-@appendixsubsubsec Operators
-
-The operators in @code{awk}, in order of increasing precedence, are:
-
-@table @code
-@item = += -= *= /= %= ^=
-Assignment. Both absolute assignment (@code{@var{var}=@var{value}})
-and operator assignment (the other forms) are supported.
-
-@item ?:
-A conditional expression, as in C. This has the form @code{@var{expr1} ?
-@var{expr2} : @var{expr3}}. If @var{expr1} is true, the value of the
-expression is @var{expr2}; otherwise it is @var{expr3}. Only one of
-@var{expr2} and @var{expr3} is evaluated.@refill
-
-@item ||
-Logical ``or''.
-
-@item &&
-Logical ``and''.
-
-@item ~ !~
-Regular expression match, negated match.
-
-@item < <= > >= != ==
-The usual relational operators.
-
-@item @var{blank}
-String concatenation.
-
-@item + -
-Addition and subtraction.
-
-@item * / %
-Multiplication, division, and modulus.
-
-@item + - !
-Unary plus, unary minus, and logical negation.
-
-@item ^
-Exponentiation (@samp{**} may also be used, and @samp{**=} for the assignment
-operator, but they are not specified in the @sc{posix} standard).
-
-@item ++ --
-Increment and decrement, both prefix and postfix.
-
-@item $
-Field reference.
-@end table
-
-@xref{Expressions, ,Expressions as Action Statements}, for a full
-description of all the operators listed above.
-@xref{Fields, ,Examining Fields}, for a description of the field
-reference operator.@refill
-
-@node Control Flow Summary, I/O Summary, Operator Summary, Actions Summary
-@appendixsubsubsec Control Statements
-
-The control statements are as follows:
-
-@example
-if (@var{condition}) @var{statement} @r{[} else @var{statement} @r{]}
-while (@var{condition}) @var{statement}
-do @var{statement} while (@var{condition})
-for (@var{expr1}; @var{expr2}; @var{expr3}) @var{statement}
-for (@var{var} in @var{array}) @var{statement}
-break
-continue
-delete @var{array}[@var{index}]
-exit @r{[} @var{expression} @r{]}
-@{ @var{statements} @}
-@end example
-
-@xref{Statements, ,Control Statements in Actions}, for a full description
-of all the control statements listed above.
-
-@node I/O Summary, Printf Summary, Control Flow Summary, Actions Summary
-@appendixsubsubsec I/O Statements
-
-The input/output statements are as follows:
-
-@table @code
-@item getline
-Set @code{$0} from next input record; set @code{NF}, @code{NR}, @code{FNR}.
-
-@item getline <@var{file}
-Set @code{$0} from next record of @var{file}; set @code{NF}.
-
-@item getline @var{var}
-Set @var{var} from next input record; set @code{NF}, @code{FNR}.
-
-@item getline @var{var} <@var{file}
-Set @var{var} from next record of @var{file}.
-
-@item next
-Stop processing the current input record. The next input record is read and
-processing starts over with the first pattern in the @code{awk} program.
-If the end of the input data is reached, the @code{END} rule(s), if any,
-are executed.
-
-@item next file
-Stop processing the current input file. The next input record read comes
-from the next input file. @code{FILENAME} is updated, @code{FNR} is set to 1,
-and processing starts over with the first pattern in the @code{awk} program.
-If the end of the input data is reached, the @code{END} rule(s), if any,
-are executed.
-
-@item print
-Prints the current record.
-
-@item print @var{expr-list}
-Prints expressions.
-
-@item print @var{expr-list} > @var{file}
-Prints expressions on @var{file}.
-
-@item printf @var{fmt, expr-list}
-Format and print.
-
-@item printf @var{fmt, expr-list} > file
-Format and print on @var{file}.
-@end table
-
-Other input/output redirections are also allowed. For @code{print} and
-@code{printf}, @samp{>> @var{file}} appends output to the @var{file},
-and @samp{| @var{command}} writes on a pipe. In a similar fashion,
-@samp{@var{command} | getline} pipes input into @code{getline}.
-@code{getline} returns 0 on end of file, and @minus{}1 on an error.@refill
-
-@xref{Getline, ,Explicit Input with @code{getline}}, for a full description
-of the @code{getline} statement.
-@xref{Printing, ,Printing Output}, for a full description of @code{print} and
-@code{printf}. Finally, @pxref{Next Statement, ,The @code{next} Statement},
-for a description of how the @code{next} statement works.@refill
-
-@node Printf Summary, Special File Summary, I/O Summary, Actions Summary
-@appendixsubsubsec @code{printf} Summary
-
-The @code{awk} @code{printf} statement and @code{sprintf} function
-accept the following conversion specification formats:
-
-@table @code
-@item %c
-An ASCII character. If the argument used for @samp{%c} is numeric, it is
-treated as a character and printed. Otherwise, the argument is assumed to
-be a string, and the only first character of that string is printed.
-
-@item %d
-@itemx %i
-A decimal number (the integer part).
-
-@item %e
-A floating point number of the form
-@samp{@r{[}-@r{]}d.ddddddE@r{[}+-@r{]}dd}.@refill
-
-@item %f
-A floating point number of the form
-@r{[}@code{-}@r{]}@code{ddd.dddddd}.
-
-@item %g
-Use @samp{%e} or @samp{%f} conversion, whichever produces a shorter string,
-with nonsignificant zeros suppressed.
-
-@item %o
-An unsigned octal number (again, an integer).
-
-@item %s
-A character string.
-
-@item %x
-An unsigned hexadecimal number (an integer).
-
-@item %X
-Like @samp{%x}, except use @samp{A} through @samp{F} instead of @samp{a}
-through @samp{f} for decimal 10 through 15.@refill
-
-@item %%
-A single @samp{%} character; no argument is converted.
-@end table
-
-There are optional, additional parameters that may lie between the @samp{%}
-and the control letter:
-
-@table @code
-@item -
-The expression should be left-justified within its field.
-
-@item @var{width}
-The field should be padded to this width. If @var{width} has a leading zero,
-then the field is padded with zeros. Otherwise it is padded with blanks.
-
-@item .@var{prec}
-A number indicating the maximum width of strings or digits to the right
-of the decimal point.
-@end table
-
-Either or both of the @var{width} and @var{prec} values may be specified
-as @samp{*}. In that case, the particular value is taken from the argument
-list.
-
-@xref{Printf, ,Using @code{printf} Statements for Fancier Printing}, for
-examples and for a more detailed description.
-
-@node Special File Summary, Numeric Functions Summary, Printf Summary, Actions Summary
-@appendixsubsubsec Special File Names
-
-When doing I/O redirection from either @code{print} or @code{printf} into a
-file, or via @code{getline} from a file, @code{gawk} recognizes certain special
-file names internally. These file names allow access to open file descriptors
-inherited from @code{gawk}'s parent process (usually the shell). The
-file names are:
-
-@table @file
-@item /dev/stdin
-The standard input.
-
-@item /dev/stdout
-The standard output.
-
-@item /dev/stderr
-The standard error output.
-
-@item /dev/fd/@var{n}
-The file denoted by the open file descriptor @var{n}.
-@end table
-
-In addition the following files provide process related information
-about the running @code{gawk} program.
-
-@table @file
-@item /dev/pid
-Reading this file returns the process ID of the current process,
-in decimal, terminated with a newline.
-
-@item /dev/ppid
-Reading this file returns the parent process ID of the current process,
-in decimal, terminated with a newline.
-
-@item /dev/pgrpid
-Reading this file returns the process group ID of the current process,
-in decimal, terminated with a newline.
-
-@item /dev/user
-Reading this file returns a single record terminated with a newline.
-The fields are separated with blanks. The fields represent the
-following information:
-
-@table @code
-@item $1
-The value of the @code{getuid} system call.
-
-@item $2
-The value of the @code{geteuid} system call.
-
-@item $3
-The value of the @code{getgid} system call.
-
-@item $4
-The value of the @code{getegid} system call.
-@end table
-
-If there are any additional fields, they are the group IDs returned by
-@code{getgroups} system call.
-(Multiple groups may not be supported on all systems.)@refill
-@end table
-
-@noindent
-These file names may also be used on the command line to name data files.
-These file names are only recognized internally if you do not
-actually have files by these names on your system.
-
-@xref{Special Files, ,Standard I/O Streams}, for a longer description that
-provides the motivation for this feature.
-
-@node Numeric Functions Summary, String Functions Summary, Special File Summary, Actions Summary
-@appendixsubsubsec Numeric Functions
-
-@code{awk} has the following predefined arithmetic functions:
-
-@table @code
-@item atan2(@var{y}, @var{x})
-returns the arctangent of @var{y/x} in radians.
-
-@item cos(@var{expr})
-returns the cosine in radians.
-
-@item exp(@var{expr})
-the exponential function.
-
-@item int(@var{expr})
-truncates to integer.
-
-@item log(@var{expr})
-the natural logarithm function.
-
-@item rand()
-returns a random number between 0 and 1.
-
-@item sin(@var{expr})
-returns the sine in radians.
-
-@item sqrt(@var{expr})
-the square root function.
-
-@item srand(@var{expr})
-use @var{expr} as a new seed for the random number generator. If no @var{expr}
-is provided, the time of day is used. The return value is the previous
-seed for the random number generator.
-@end table
-
-@node String Functions Summary, Time Functions Summary, Numeric Functions Summary, Actions Summary
-@appendixsubsubsec String Functions
-
-@code{awk} has the following predefined string functions:
-
-@table @code
-@item gsub(@var{r}, @var{s}, @var{t})
-for each substring matching the regular expression @var{r} in the string
-@var{t}, substitute the string @var{s}, and return the number of substitutions.
-If @var{t} is not supplied, use @code{$0}.
-
-@item index(@var{s}, @var{t})
-returns the index of the string @var{t} in the string @var{s}, or 0 if
-@var{t} is not present.
-
-@item length(@var{s})
-returns the length of the string @var{s}. The length of @code{$0}
-is returned if no argument is supplied.
-
-@item match(@var{s}, @var{r})
-returns the position in @var{s} where the regular expression @var{r}
-occurs, or 0 if @var{r} is not present, and sets the values of @code{RSTART}
-and @code{RLENGTH}.
-
-@item split(@var{s}, @var{a}, @var{r})
-splits the string @var{s} into the array @var{a} on the regular expression
-@var{r}, and returns the number of fields. If @var{r} is omitted, @code{FS}
-is used instead.
-
-@item sprintf(@var{fmt}, @var{expr-list})
-prints @var{expr-list} according to @var{fmt}, and returns the resulting string.
-
-@item sub(@var{r}, @var{s}, @var{t})
-this is just like @code{gsub}, but only the first matching substring is
-replaced.
-
-@item substr(@var{s}, @var{i}, @var{n})
-returns the @var{n}-character substring of @var{s} starting at @var{i}.
-If @var{n} is omitted, the rest of @var{s} is used.
-
-@item tolower(@var{str})
-returns a copy of the string @var{str}, with all the upper-case characters in
-@var{str} translated to their corresponding lower-case counterparts.
-Nonalphabetic characters are left unchanged.
-
-@item toupper(@var{str})
-returns a copy of the string @var{str}, with all the lower-case characters in
-@var{str} translated to their corresponding upper-case counterparts.
-Nonalphabetic characters are left unchanged.
-
-@item system(@var{cmd-line})
-Execute the command @var{cmd-line}, and return the exit status.
-@end table
-
-@node Time Functions Summary, String Constants Summary, String Functions Summary, Actions Summary
-@appendixsubsubsec Built-in time functions
-
-The following two functions are available for getting the current
-time of day, and for formatting time stamps.
-
-@table @code
-@item systime()
-returns the current time of day as the number of seconds since a particular
-epoch (Midnight, January 1, 1970 @sc{utc}, on @sc{posix} systems).
-
-@item strftime(@var{format}, @var{timestamp})
-formats @var{timestamp} according to the specification in @var{format}.
-The current time of day is used if no @var{timestamp} is supplied.
-@xref{Time Functions, ,Functions for Dealing with Time Stamps}, for the
-details on the conversion specifiers that @code{strftime} accepts.@refill
-@end table
-
-@iftex
-@xref{Built-in, ,Built-in Functions}, for a description of all of
-@code{awk}'s built-in functions.
-@end iftex
-
-@node String Constants Summary, , Time Functions Summary, Actions Summary
-@appendixsubsubsec String Constants
-
-String constants in @code{awk} are sequences of characters enclosed
-between double quotes (@code{"}). Within strings, certain @dfn{escape sequences}
-are recognized, as in C. These are:
-
-@table @code
-@item \\
-A literal backslash.
-
-@item \a
-The ``alert'' character; usually the ASCII BEL character.
-
-@item \b
-Backspace.
-
-@item \f
-Formfeed.
-
-@item \n
-Newline.
-
-@item \r
-Carriage return.
-
-@item \t
-Horizontal tab.
-
-@item \v
-Vertical tab.
-
-@item \x@var{hex digits}
-The character represented by the string of hexadecimal digits following
-the @samp{\x}. As in @sc{ansi} C, all following hexadecimal digits are
-considered part of the escape sequence. (This feature should tell us
-something about language design by committee.) E.g., @code{"\x1B"} is a
-string containing the ASCII ESC (escape) character. (The @samp{\x}
-escape sequence is not in @sc{posix} @code{awk}.)
-
-@item \@var{ddd}
-The character represented by the 1-, 2-, or 3-digit sequence of octal
-digits. Thus, @code{"\033"} is also a string containing the ASCII ESC
-(escape) character.
-
-@item \@var{c}
-The literal character @var{c}.
-@end table
-
-The escape sequences may also be used inside constant regular expressions
-(e.g., the regexp @code{@w{/[@ \t\f\n\r\v]/}} matches whitespace
-characters).@refill
-
-@xref{Constants, ,Constant Expressions}.
-
-@node Functions Summary, Historical Features, Rules Summary, Gawk Summary
-@appendixsec Functions
-
-Functions in @code{awk} are defined as follows:
-
-@example
-function @var{name}(@var{parameter list}) @{ @var{statements} @}
-@end example
-
-Actual parameters supplied in the function call are used to instantiate
-the formal parameters declared in the function. Arrays are passed by
-reference, other variables are passed by value.
-
-If there are fewer arguments passed than there are names in @var{parameter-list},
-the extra names are given the null string as value. Extra names have the
-effect of local variables.
-
-The open-parenthesis in a function call of a user-defined function must
-immediately follow the function name, without any intervening white space.
-This is to avoid a syntactic ambiguity with the concatenation operator.
-
-The word @code{func} may be used in place of @code{function} (but not in
-@sc{posix} @code{awk}).
-
-Use the @code{return} statement to return a value from a function.
-
-@xref{User-defined, ,User-defined Functions}, for a more complete description.
-
-@node Historical Features, , Functions Summary, Gawk Summary
-@appendixsec Historical Features
-
-There are two features of historical @code{awk} implementations that
-@code{gawk} supports. First, it is possible to call the @code{length}
-built-in function not only with no arguments, but even without parentheses!
-
-@example
-a = length
-@end example
-
-@noindent
-is the same as either of
-
-@example
-a = length()
-a = length($0)
-@end example
-
-@noindent
-This feature is marked as ``deprecated'' in the @sc{posix} standard, and
-@code{gawk} will issue a warning about its use if @samp{-W lint} is
-specified on the command line.
-
-The other feature is the use of the @code{continue} statement outside the
-body of a @code{while}, @code{for}, or @code{do} loop. Traditional
-@code{awk} implementations have treated such usage as equivalent to the
-@code{next} statement. @code{gawk} will support this usage if @samp{-W posix}
-has not been specified.
-
-@node Sample Program, Bugs, Gawk Summary, Top
-@appendix Sample Program
-
-The following example is a complete @code{awk} program, which prints
-the number of occurrences of each word in its input. It illustrates the
-associative nature of @code{awk} arrays by using strings as subscripts. It
-also demonstrates the @samp{for @var{x} in @var{array}} construction.
-Finally, it shows how @code{awk} can be used in conjunction with other
-utility programs to do a useful task of some complexity with a minimum of
-effort. Some explanations follow the program listing.@refill
-
-@example
-awk '
-# Print list of word frequencies
-@{
- for (i = 1; i <= NF; i++)
- freq[$i]++
-@}
-
-END @{
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
-@}'
-@end example
-
-The first thing to notice about this program is that it has two rules. The
-first rule, because it has an empty pattern, is executed on every line of
-the input. It uses @code{awk}'s field-accessing mechanism
-(@pxref{Fields, ,Examining Fields}) to pick out the individual words from
-the line, and the built-in variable @code{NF} (@pxref{Built-in Variables})
-to know how many fields are available.@refill
-
-For each input word, an element of the array @code{freq} is incremented to
-reflect that the word has been seen an additional time.@refill
-
-The second rule, because it has the pattern @code{END}, is not executed
-until the input has been exhausted. It prints out the contents of the
-@code{freq} table that has been built up inside the first action.@refill
-
-Note that this program has several problems that would prevent it from being
-useful by itself on real text files:@refill
-
-@itemize @bullet
-@item
-Words are detected using the @code{awk} convention that fields are
-separated by whitespace and that other characters in the input (except
-newlines) don't have any special meaning to @code{awk}. This means that
-punctuation characters count as part of words.@refill
-
-@item
-The @code{awk} language considers upper and lower case characters to be
-distinct. Therefore, @samp{foo} and @samp{Foo} are not treated by this
-program as the same word. This is undesirable since in normal text, words
-are capitalized if they begin sentences, and a frequency analyzer should not
-be sensitive to that.@refill
-
-@item
-The output does not come out in any useful order. You're more likely to be
-interested in which words occur most frequently, or having an alphabetized
-table of how frequently each word occurs.@refill
-@end itemize
-
-The way to solve these problems is to use some of the more advanced
-features of the @code{awk} language. First, we use @code{tolower} to remove
-case distinctions. Next, we use @code{gsub} to remove punctuation
-characters. Finally, we use the system @code{sort} utility to process the
-output of the @code{awk} script. First, here is the new version of
-the program:@refill
-
-@example
-awk '
-# Print list of word frequencies
-@{
- $0 = tolower($0) # remove case distinctions
- gsub(/[^a-z0-9_ \t]/, "", $0) # remove punctuation
- for (i = 1; i <= NF; i++)
- freq[$i]++
-@}
-
-END @{
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
-@}'
-@end example
-
-Assuming we have saved this program in a file named @file{frequency.awk},
-and that the data is in @file{file1}, the following pipeline
-
-@example
-awk -f frequency.awk file1 | sort +1 -nr
-@end example
-
-@noindent
-produces a table of the words appearing in @file{file1} in order of
-decreasing frequency.
-
-The @code{awk} program suitably massages the data and produces a word
-frequency table, which is not ordered.
-
-The @code{awk} script's output is then sorted by the @code{sort} command and
-printed on the terminal. The options given to @code{sort} in this example
-specify to sort using the second field of each input line (skipping one field),
-that the sort keys should be treated as numeric quantities (otherwise
-@samp{15} would come before @samp{5}), and that the sorting should be done
-in descending (reverse) order.@refill
-
-We could have even done the @code{sort} from within the program, by
-changing the @code{END} action to:
-
-@example
-END @{
- sort = "sort +1 -nr"
- for (word in freq)
- printf "%s\t%d\n", word, freq[word] | sort
- close(sort)
-@}'
-@end example
-
-See the general operating system documentation for more information on how
-to use the @code{sort} command.@refill
-
-@ignore
-@strong{ADR: I have some more substantial programs courtesy of Rick Adams
-at UUNET. I am planning on incorporating those either in addition to or
-instead of this program.}
-
-@strong{I would also like to incorporate the general @code{translate}
-function that I have written.}
-
-@strong{I have a ton of other sample programs to include too.}
-@end ignore
-
-@node Bugs, Notes, Sample Program, Top
-@appendix Reporting Problems and Bugs
-
-@c This chapter stolen shamelessly from the GNU m4 manual.
-@c This chapter has been unshamelessly altered to emulate changes made to
-@c make.texi from whence it was originally shamelessly stolen! :-} --mew
-
-If you have problems with @code{gawk} or think that you have found a bug,
-please report it to the developers; we cannot promise to do anything
-but we might well want to fix it.
-
-Before reporting a bug, make sure you have actually found a real bug.
-Carefully reread the documentation and see if it really says you can do
-what you're trying to do. If it's not clear whether you should be able
-to do something or not, report that too; it's a bug in the documentation!
-
-Before reporting a bug or trying to fix it yourself, try to isolate it
-to the smallest possible @code{awk} program and input data file that
-reproduces the problem. Then send us the program and data file,
-some idea of what kind of Unix system you're using, and the exact results
-@code{gawk} gave you. Also say what you expected to occur; this will help
-us decide whether the problem was really in the documentation.
-
-Once you have a precise problem, send e-mail to (Internet)
-@samp{bug-gnu-utils@@prep.ai.mit.edu} or (UUCP)
-@samp{mit-eddie!prep.ai.mit.edu!bug-gnu-utils}. Please include the
-version number of @code{gawk} you are using. You can get this information
-with the command @samp{gawk -W version '@{@}' /dev/null}.
-You should send carbon copies of your mail to David Trueman at
-@samp{david@@cs.dal.ca}, and to Arnold Robbins, who can be reached at
-@samp{arnold@@skeeve.atl.ga.us}. David is most likely to fix code
-problems, while Arnold is most likely to fix documentation problems.@refill
-
-Non-bug suggestions are always welcome as well. If you have questions
-about things that are unclear in the documentation or are just obscure
-features, ask Arnold Robbins; he will try to help you out, although he
-may not have the time to fix the problem. You can send him electronic mail at the Internet address
-above.
-
-If you find bugs in one of the non-Unix ports of @code{gawk}, please send
-an electronic mail message to the person who maintains that port. They
-are listed below, and also in the @file{README} file in the @code{gawk}
-distribution. Information in the @code{README} file should be considered
-authoritative if it conflicts with this manual.
-
-The people maintaining the non-Unix ports of @code{gawk} are:
-
-@table @asis
-@item MS-DOS
-The port to MS-DOS is maintained by Scott Deifik.
-His electronic mail address is @samp{scottd@@amgen.com}.
-
-@item VMS
-The port to VAX VMS is maintained by Pat Rankin.
-His electronic mail address is @samp{rankin@@eql.caltech.edu}.
-
-@item Atari ST
-The port to the Atari ST is maintained by Michal Jaegermann.
-His electronic mail address is @samp{ntomczak@@vm.ucs.ualberta.ca}.
-
-@end table
-
-If your bug is also reproducible under Unix, please send copies of your
-report to the general GNU bug list, as well as to Arnold Robbins and David
-Trueman, at the addresses listed above.
-
-@node Notes, Glossary, Bugs, Top
-@appendix Implementation Notes
-
-This appendix contains information mainly of interest to implementors and
-maintainers of @code{gawk}. Everything in it applies specifically to
-@code{gawk}, and not to other implementations.
-
-@menu
-* Compatibility Mode:: How to disable certain @code{gawk} extensions.
-* Future Extensions:: New features we may implement soon.
-* Improvements:: Suggestions for improvements by volunteers.
-@end menu
-
-@node Compatibility Mode, Future Extensions, Notes, Notes
-@appendixsec Downward Compatibility and Debugging
-
-@xref{POSIX/GNU, ,Extensions in @code{gawk} not in POSIX @code{awk}},
-for a summary of the GNU extensions to the @code{awk} language and program.
-All of these features can be turned off by invoking @code{gawk} with the
-@samp{-W compat} option, or with the @samp{-W posix} option.@refill
-
-If @code{gawk} is compiled for debugging with @samp{-DDEBUG}, then there
-is one more option available on the command line:
-
-@table @samp
-@item -W parsedebug
-Print out the parse stack information as the program is being parsed.
-@end table
-
-This option is intended only for serious @code{gawk} developers,
-and not for the casual user. It probably has not even been compiled into
-your version of @code{gawk}, since it slows down execution.
-
-@node Future Extensions, Improvements, Compatibility Mode, Notes
-@appendixsec Probable Future Extensions
-
-This section briefly lists extensions that indicate the directions we are
-currently considering for @code{gawk}. The file @file{FUTURES} in the
-@code{gawk} distributions lists these extensions, as well as several others.
-
-@table @asis
-@item @code{RS} as a regexp
-The meaning of @code{RS} may be generalized along the lines of @code{FS}.
-
-@item Control of subprocess environment
-Changes made in @code{gawk} to the array @code{ENVIRON} may be
-propagated to subprocesses run by @code{gawk}.
-
-@item Databases
-It may be possible to map a GDBM/NDBM/SDBM file into an @code{awk} array.
-
-@item Single-character fields
-The null string, @code{""}, as a field separator, will cause field
-splitting and the @code{split} function to separate individual characters.
-Thus, @code{split(a, "abcd", "")} would yield @code{a[1] == "a"},
-@code{a[2] == "b"}, and so on.
-
-@item More @code{lint} warnings
-There are more things that could be checked for portability.
-
-@item @code{RECLEN} variable for fixed length records
-Along with @code{FIELDWIDTHS}, this would speed up the processing of
-fixed-length records.
-
-@item @code{RT} variable to hold the record terminator
-It is occasionally useful to have access to the actual string of
-characters that matched the @code{RS} variable. The @code{RT}
-variable would hold these characters.
-
-@item A @code{restart} keyword
-After modifying @code{$0}, @code{restart} would restart the pattern
-matching loop, without reading a new record from the input.
-
-@item A @samp{|&} redirection
-The @samp{|&} redirection, in place of @samp{|}, would open a two-way
-pipeline for communication with a sub-process (via @code{getline} and
-@code{print} and @code{printf}).
-
-@item @code{IGNORECASE} affecting all comparisons
-The effects of the @code{IGNORECASE} variable may be generalized to
-all string comparisons, and not just regular expression operations.
-
-@item A way to mix command line source code and library files
-There may be a new option that would make it possible to easily use library
-functions from a program entered on the command line.
-@c probably a @samp{-s} option...
-
-@item GNU-style long options
-We will add GNU-style long options
-to @code{gawk} for compatibility with other GNU programs.
-(For example, @samp{--field-separator=:} would be equivalent to
-@samp{-F:}.)@refill
-
-@c this is @emph{very} long term --- not worth including right now.
-@ignore
-@item The C Comma Operator
-We may add the C comma operator, which takes the form
-@code{@var{expr1},@var{expr2}}. The first expression is evaluated, and the
-result is thrown away. The value of the full expression is the value of
-@var{expr2}.@refill
-@end ignore
-@end table
-
-@node Improvements, , Future Extensions, Notes
-@appendixsec Suggestions for Improvements
-
-Here are some projects that would-be @code{gawk} hackers might like to take
-on. They vary in size from a few days to a few weeks of programming,
-depending on which one you choose and how fast a programmer you are. Please
-send any improvements you write to the maintainers at the GNU
-project.@refill
-
-@enumerate
-@item
-Compilation of @code{awk} programs: @code{gawk} uses a Bison (YACC-like)
-parser to convert the script given it into a syntax tree; the syntax
-tree is then executed by a simple recursive evaluator. This method incurs
-a lot of overhead, since the recursive evaluator performs many procedure
-calls to do even the simplest things.@refill
-
-It should be possible for @code{gawk} to convert the script's parse tree
-into a C program which the user would then compile, using the normal
-C compiler and a special @code{gawk} library to provide all the needed
-functions (regexps, fields, associative arrays, type coercion, and so
-on).@refill
-
-An easier possibility might be for an intermediate phase of @code{awk} to
-convert the parse tree into a linear byte code form like the one used
-in GNU Emacs Lisp. The recursive evaluator would then be replaced by
-a straight line byte code interpreter that would be intermediate in speed
-between running a compiled program and doing what @code{gawk} does
-now.@refill
-
-This may actually happen for the 3.0 version of @code{gawk}.
-
-@item
-An error message section has not been included in this version of the
-manual. Perhaps some nice beta testers will document some of the messages
-for the future.
-
-@item
-The programs in the test suite could use documenting in this manual.
-
-@item
-The programs and data files in the manual should be available in
-separate files to facilitate experimentation.
-
-@item
-See the @file{FUTURES} file for more ideas. Contact us if you would
-seriously like to tackle any of the items listed there.
-@end enumerate
-
-@node Glossary, Index, Notes, Top
-@appendix Glossary
-
-@table @asis
-@item Action
-A series of @code{awk} statements attached to a rule. If the rule's
-pattern matches an input record, the @code{awk} language executes the
-rule's action. Actions are always enclosed in curly braces.
-@xref{Actions, ,Overview of Actions}.@refill
-
-@item Amazing @code{awk} Assembler
-Henry Spencer at the University of Toronto wrote a retargetable assembler
-completely as @code{awk} scripts. It is thousands of lines long, including
-machine descriptions for several 8-bit microcomputers.
-@c It is distributed with @code{gawk} (as part of the test suite) and
-It is a good example of a
-program that would have been better written in another language.@refill
-
-@item @sc{ansi}
-The American National Standards Institute. This organization produces
-many standards, among them the standard for the C programming language.
-
-@item Assignment
-An @code{awk} expression that changes the value of some @code{awk}
-variable or data object. An object that you can assign to is called an
-@dfn{lvalue}. @xref{Assignment Ops, ,Assignment Expressions}.@refill
-
-@item @code{awk} Language
-The language in which @code{awk} programs are written.
-
-@item @code{awk} Program
-An @code{awk} program consists of a series of @dfn{patterns} and
-@dfn{actions}, collectively known as @dfn{rules}. For each input record
-given to the program, the program's rules are all processed in turn.
-@code{awk} programs may also contain function definitions.@refill
-
-@item @code{awk} Script
-Another name for an @code{awk} program.
-
-@item Built-in Function
-The @code{awk} language provides built-in functions that perform various
-numerical, time stamp related, and string computations. Examples are
-@code{sqrt} (for the square root of a number) and @code{substr} (for a
-substring of a string). @xref{Built-in, ,Built-in Functions}.@refill
-
-@item Built-in Variable
-@code{ARGC}, @code{ARGIND}, @code{ARGV}, @code{CONVFMT}, @code{ENVIRON},
-@code{ERRNO}, @code{FIELDWIDTHS}, @code{FILENAME}, @code{FNR}, @code{FS},
-@code{IGNORECASE}, @code{NF}, @code{NR}, @code{OFMT}, @code{OFS}, @code{ORS},
-@code{RLENGTH}, @code{RSTART}, @code{RS}, and @code{SUBSEP},
-are the variables that have special
-meaning to @code{awk}. Changing some of them affects @code{awk}'s running
-environment. @xref{Built-in Variables}.@refill
-
-@item Braces
-See ``Curly Braces.''
-
-@item C
-The system programming language that most GNU software is written in. The
-@code{awk} programming language has C-like syntax, and this manual
-points out similarities between @code{awk} and C when appropriate.@refill
-
-@item CHEM
-A preprocessor for @code{pic} that reads descriptions of molecules
-and produces @code{pic} input for drawing them. It was written by
-Brian Kernighan, and is available from @code{netlib@@research.att.com}.@refill
-
-@item Compound Statement
-A series of @code{awk} statements, enclosed in curly braces. Compound
-statements may be nested.
-@xref{Statements, ,Control Statements in Actions}.@refill
-
-@item Concatenation
-Concatenating two strings means sticking them together, one after another,
-giving a new string. For example, the string @samp{foo} concatenated with
-the string @samp{bar} gives the string @samp{foobar}.
-@xref{Concatenation, ,String Concatenation}.@refill
-
-@item Conditional Expression
-An expression using the @samp{?:} ternary operator, such as
-@code{@var{expr1} ? @var{expr2} : @var{expr3}}. The expression
-@var{expr1} is evaluated; if the result is true, the value of the whole
-expression is the value of @var{expr2} otherwise the value is
-@var{expr3}. In either case, only one of @var{expr2} and @var{expr3}
-is evaluated. @xref{Conditional Exp, ,Conditional Expressions}.@refill
-
-@item Constant Regular Expression
-A constant regular expression is a regular expression written within
-slashes, such as @samp{/foo/}. This regular expression is chosen
-when you write the @code{awk} program, and cannot be changed doing
-its execution. @xref{Regexp Usage, ,How to Use Regular Expressions}.
-
-@item Comparison Expression
-A relation that is either true or false, such as @code{(a < b)}.
-Comparison expressions are used in @code{if}, @code{while}, and @code{for}
-statements, and in patterns to select which input records to process.
-@xref{Comparison Ops, ,Comparison Expressions}.@refill
-
-@item Curly Braces
-The characters @samp{@{} and @samp{@}}. Curly braces are used in
-@code{awk} for delimiting actions, compound statements, and function
-bodies.@refill
-
-@item Data Objects
-These are numbers and strings of characters. Numbers are converted into
-strings and vice versa, as needed.
-@xref{Conversion, ,Conversion of Strings and Numbers}.@refill
-
-@item Dynamic Regular Expression
-A dynamic regular expression is a regular expression written as an
-ordinary expression. It could be a string constant, such as
-@code{"foo"}, but it may also be an expression whose value may vary.
-@xref{Regexp Usage, ,How to Use Regular Expressions}.
-
-@item Escape Sequences
-A special sequence of characters used for describing nonprinting
-characters, such as @samp{\n} for newline, or @samp{\033} for the ASCII
-ESC (escape) character. @xref{Constants, ,Constant Expressions}.
-
-@item Field
-When @code{awk} reads an input record, it splits the record into pieces
-separated by whitespace (or by a separator regexp which you can
-change by setting the built-in variable @code{FS}). Such pieces are
-called fields. If the pieces are of fixed length, you can use the built-in
-variable @code{FIELDWIDTHS} to describe their lengths.
-@xref{Records, ,How Input is Split into Records}.@refill
-
-@item Format
-Format strings are used to control the appearance of output in the
-@code{printf} statement. Also, data conversions from numbers to strings
-are controlled by the format string contained in the built-in variable
-@code{CONVFMT}. @xref{Control Letters, ,Format-Control Letters}.@refill
-
-@item Function
-A specialized group of statements often used to encapsulate general
-or program-specific tasks. @code{awk} has a number of built-in
-functions, and also allows you to define your own.
-@xref{Built-in, ,Built-in Functions}.
-Also, see @ref{User-defined, ,User-defined Functions}.@refill
-
-@item @code{gawk}
-The GNU implementation of @code{awk}.
-
-@item GNU
-``GNU's not Unix''. An on-going project of the Free Software Foundation
-to create a complete, freely distributable, @sc{posix}-compliant computing
-environment.
-
-@item Input Record
-A single chunk of data read in by @code{awk}. Usually, an @code{awk} input
-record consists of one line of text.
-@xref{Records, ,How Input is Split into Records}.@refill
-
-@item Keyword
-In the @code{awk} language, a keyword is a word that has special
-meaning. Keywords are reserved and may not be used as variable names.
-
-@code{awk}'s keywords are:
-@code{if},
-@code{else},
-@code{while},
-@code{do@dots{}while},
-@code{for},
-@code{for@dots{}in},
-@code{break},
-@code{continue},
-@code{delete},
-@code{next},
-@code{function},
-@code{func},
-and @code{exit}.@refill
-
-@item Lvalue
-An expression that can appear on the left side of an assignment
-operator. In most languages, lvalues can be variables or array
-elements. In @code{awk}, a field designator can also be used as an
-lvalue.@refill
-
-@item Number
-A numeric valued data object. The @code{gawk} implementation uses double
-precision floating point to represent numbers.@refill
-
-@item Pattern
-Patterns tell @code{awk} which input records are interesting to which
-rules.
-
-A pattern is an arbitrary conditional expression against which input is
-tested. If the condition is satisfied, the pattern is said to @dfn{match}
-the input record. A typical pattern might compare the input record against
-a regular expression. @xref{Patterns}.@refill
-
-@item @sc{posix}
-The name for a series of standards being developed by the @sc{ieee}
-that specify a Portable Operating System interface. The ``IX'' denotes
-the Unix heritage of these standards. The main standard of interest for
-@code{awk} users is P1003.2, the Command Language and Utilities standard.
-
-@item Range (of input lines)
-A sequence of consecutive lines from the input file. A pattern
-can specify ranges of input lines for @code{awk} to process, or it can
-specify single lines. @xref{Patterns}.@refill
-
-@item Recursion
-When a function calls itself, either directly or indirectly.
-If this isn't clear, refer to the entry for ``recursion.''
-
-@item Redirection
-Redirection means performing input from other than the standard input
-stream, or output to other than the standard output stream.
-
-You can redirect the output of the @code{print} and @code{printf} statements
-to a file or a system command, using the @samp{>}, @samp{>>}, and @samp{|}
-operators. You can redirect input to the @code{getline} statement using
-the @samp{<} and @samp{|} operators.
-@xref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}.@refill
-
-@item Regular Expression
-See ``regexp.''
-
-@item Regexp
-Short for @dfn{regular expression}. A regexp is a pattern that denotes a
-set of strings, possibly an infinite set. For example, the regexp
-@samp{R.*xp} matches any string starting with the letter @samp{R}
-and ending with the letters @samp{xp}. In @code{awk}, regexps are
-used in patterns and in conditional expressions. Regexps may contain
-escape sequences. @xref{Regexp, ,Regular Expressions as Patterns}.@refill
-
-@item Rule
-A segment of an @code{awk} program, that specifies how to process single
-input records. A rule consists of a @dfn{pattern} and an @dfn{action}.
-@code{awk} reads an input record; then, for each rule, if the input record
-satisfies the rule's pattern, @code{awk} executes the rule's action.
-Otherwise, the rule does nothing for that input record.@refill
-
-@item Side Effect
-A side effect occurs when an expression has an effect aside from merely
-producing a value. Assignment expressions, increment expressions and
-function calls have side effects. @xref{Assignment Ops, ,Assignment Expressions}.
-
-@item Special File
-A file name interpreted internally by @code{gawk}, instead of being handed
-directly to the underlying operating system. For example, @file{/dev/stdin}.
-@xref{Special Files, ,Standard I/O Streams}.
-
-@item Stream Editor
-A program that reads records from an input stream and processes them one
-or more at a time. This is in contrast with batch programs, which may
-expect to read their input files in entirety before starting to do
-anything, and with interactive programs, which require input from the
-user.@refill
-
-@item String
-A datum consisting of a sequence of characters, such as @samp{I am a
-string}. Constant strings are written with double-quotes in the
-@code{awk} language, and may contain escape sequences.
-@xref{Constants, ,Constant Expressions}.
-
-@item Whitespace
-A sequence of blank or tab characters occurring inside an input record or a
-string.@refill
-@end table
-
-@node Index, , Glossary, Top
-@unnumbered Index
-@printindex cp
-
-@summarycontents
-@contents
-@bye
-
-Unresolved Issues:
-------------------
-1. From: ntomczak@vm.ucs.ualberta.ca (Michal Jaegermann)
- Examples of usage tend to suggest that /../ and ".." delimiters
- can be used for regular expressions, even if definition is consistently
- using /../. I am not sure what the real rules are and in particular
- what of the following is a bug and what is a feature:
- # This program matches everything
- '"\(" { print }'
- # This one complains about mismatched parenthesis
- '$0 ~ "\(" { print }'
- # This one behaves in an expected manner
- '/\(/ { print }'
- You may also try to use "\(" as an argument to match() to see what
- will happen.
-
-2. From ADR.
-
- The posix (and original Unix!) notion of awk values as both number
- and string values needs to be put into the manual. This involves
- major and minor rewrites of most of the manual, but should help in
- clarifying many of the weirder points of the language.
-
-3. From ADR.
-
- The manual should be reorganized. Expressions should be introduced
- early, building up to regexps as expressions, and from there to their
- use as patterns and then in actions. Built-in vars should come earlier
- in the manual too. The 'expert info' sections marked with comments
- should get their own sections or subsections with nodes and titles.
- The manual should be gone over thoroughly for indexing.
-
-4. From ADR.
-
- Robert J. Chassell points out that awk programs should have some indication
- of how to use them. It would be useful to perhaps have a "programming
- style" section of the manual that would include this and other tips.
-
-5. From ADR in response to moraes@uunet.ca
- (This would make the beginnings of a good "puzzles" section...)
-
- Date: Mon, 2 Dec 91 10:08:05 EST
- From: gatech!cc!arnold (Arnold Robbins)
- To: cs.dal.ca!david, uunet.ca!moraes
- Subject: redirecting to /dev/stderr
- Cc: skeeve!arnold, boeing.com!brennan, research.att.com!bwk
-
- In 2.13.3 the following program no longer dumps core:
-
- BEGIN { print "hello" > /dev/stderr ; exit(1) }
-
- Instead, it creates a file named `0' with the word `hello' in it. AWK
- semantics strikes again. The meaning of the statement is
-
- print "hello" > (($0 ~ /dev/) stderr)
-
- /dev/ tests $0 for the pattern `dev'. This yields a 0. The variable stderr,
- having never been used, has a null string in it. The concatenation yields
- a string value of "0" which is used as the file name. Sigh.
-
- I think with some more time I can come up with a decent fix, but it will
- probably only print a diagnostic with -Wlint.
-
- Arnold
-
diff --git a/gnu/usr.bin/awk/getopt.c b/gnu/usr.bin/awk/getopt.c
deleted file mode 100644
index bbf345c..0000000
--- a/gnu/usr.bin/awk/getopt.c
+++ /dev/null
@@ -1,662 +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 Library 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 Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef GAWK
-#include "config.h"
-#endif
-
-#include <stdio.h>
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#include <stdlib.h>
-#include <string.h>
-#endif /* GNU C library. */
-
-
-#ifndef __STDC__
-#define const
-#endif
-
-/* 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. */
-
-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;
-
-#ifdef __GNU_LIBRARY__
-#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 **) malloc (nonopts_size);
-
- /* Interchange the two blocks of data in ARGV. */
-
- my_bcopy (&argv[first_nonopt], temp, nonopts_size);
- my_bcopy (&argv[last_nonopt], &argv[first_nonopt],
- (optind - last_nonopt) * sizeof (char *));
- my_bcopy (temp, &argv[first_nonopt + optind - last_nonopt], nonopts_size);
-
- free(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;
- extern int strncmp();
-
- 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 '?';
- }
- }
- 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], 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/usr.bin/awk/getopt.h b/gnu/usr.bin/awk/getopt.h
deleted file mode 100644
index de02743..0000000
--- a/gnu/usr.bin/awk/getopt.h
+++ /dev/null
@@ -1,128 +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 Library 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 Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 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'. */
-
-enum _argtype
-{
- no_argument,
- required_argument,
- optional_argument
-};
-
-#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/awk/getopt1.c b/gnu/usr.bin/awk/getopt1.c
deleted file mode 100644
index e2127cd..0000000
--- a/gnu/usr.bin/awk/getopt1.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Getopt for GNU.
- Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
-
-This file is part of the libiberty library.
-Libiberty 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.
-
-Libiberty is distributed in the hope that 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 libiberty; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#ifdef LIBC
-/* For when compiled as part of the GNU C library. */
-#include <ansidecl.h>
-#endif
-
-#include "getopt.h"
-
-#ifndef __STDC__
-#define const
-#endif
-
-#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) || defined (LIBC)
-#include <stdlib.h>
-#else /* STDC_HEADERS or __GNU_LIBRARY__ */
-char *getenv ();
-#endif /* STDC_HEADERS or __GNU_LIBRARY__ */
-
-#if !defined (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/awk/io.c b/gnu/usr.bin/awk/io.c
deleted file mode 100644
index 7004aed..0000000
--- a/gnu/usr.bin/awk/io.c
+++ /dev/null
@@ -1,1207 +0,0 @@
-/*
- * io.c --- routines for dealing with input and output and records
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-#ifndef O_RDONLY
-#include <fcntl.h>
-#endif
-
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
-
-#ifndef atarist
-#define INVALID_HANDLE (-1)
-#else
-#define INVALID_HANDLE (__SMALLEST_VALID_HANDLE - 1)
-#endif
-
-#if defined(MSDOS) || defined(atarist)
-#define PIPES_SIMULATED
-#endif
-
-static IOBUF *nextfile P((int skipping));
-static int inrec P((IOBUF *iop));
-static int iop_close P((IOBUF *iop));
-struct redirect *redirect P((NODE *tree, int *errflg));
-static void close_one P((void));
-static int close_redir P((struct redirect *rp));
-#ifndef PIPES_SIMULATED
-static int wait_any P((int interesting));
-#endif
-static IOBUF *gawk_popen P((char *cmd, struct redirect *rp));
-static IOBUF *iop_open P((char *file, char *how));
-static int gawk_pclose P((struct redirect *rp));
-static int do_pathopen P((char *file));
-
-extern FILE *fdopen();
-extern FILE *popen();
-
-static struct redirect *red_head = NULL;
-
-extern int output_is_tty;
-extern NODE *ARGC_node;
-extern NODE *ARGV_node;
-extern NODE *ARGIND_node;
-extern NODE *ERRNO_node;
-extern NODE **fields_arr;
-
-static jmp_buf filebuf; /* for do_nextfile() */
-
-/* do_nextfile --- implement gawk "next file" extension */
-
-void
-do_nextfile()
-{
- (void) nextfile(1);
- longjmp(filebuf, 1);
-}
-
-static IOBUF *
-nextfile(skipping)
-int skipping;
-{
- static int i = 1;
- static int files = 0;
- NODE *arg;
- int fd = INVALID_HANDLE;
- static IOBUF *curfile = NULL;
-
- if (skipping) {
- if (curfile != NULL)
- iop_close(curfile);
- curfile = NULL;
- return NULL;
- }
- if (curfile != NULL) {
- if (curfile->cnt == EOF) {
- (void) iop_close(curfile);
- curfile = NULL;
- } else
- return curfile;
- }
- for (; i < (int) (ARGC_node->lnode->numbr); i++) {
- arg = *assoc_lookup(ARGV_node, tmp_number((AWKNUM) i));
- if (arg->stptr[0] == '\0')
- continue;
- arg->stptr[arg->stlen] = '\0';
- if (! do_unix) {
- ARGIND_node->var_value->numbr = i;
- ARGIND_node->var_value->flags = NUM|NUMBER;
- }
- if (!arg_assign(arg->stptr)) {
- files++;
- curfile = iop_open(arg->stptr, "r");
- if (curfile == NULL)
- fatal("cannot open file `%s' for reading (%s)",
- arg->stptr, strerror(errno));
- /* NOTREACHED */
- /* This is a kludge. */
- unref(FILENAME_node->var_value);
- FILENAME_node->var_value =
- dupnode(arg);
- FNR = 0;
- i++;
- break;
- }
- }
- if (files == 0) {
- files++;
- /* no args. -- use stdin */
- /* FILENAME is init'ed to "-" */
- /* FNR is init'ed to 0 */
- curfile = iop_alloc(fileno(stdin));
- }
- return curfile;
-}
-
-void
-set_FNR()
-{
- FNR = (int) FNR_node->var_value->numbr;
-}
-
-void
-set_NR()
-{
- NR = (int) NR_node->var_value->numbr;
-}
-
-/*
- * This reads in a record from the input file
- */
-static int
-inrec(iop)
-IOBUF *iop;
-{
- char *begin;
- register int cnt;
- int retval = 0;
-
- cnt = get_a_record(&begin, iop, *RS, NULL);
- if (cnt == EOF) {
- cnt = 0;
- retval = 1;
- } else {
- NR += 1;
- FNR += 1;
- }
- set_record(begin, cnt, 1);
-
- return retval;
-}
-
-static int
-iop_close(iop)
-IOBUF *iop;
-{
- int ret;
-
- if (iop == NULL)
- return 0;
- errno = 0;
-
-#ifdef _CRAY
- /* Work around bug in UNICOS popen */
- if (iop->fd < 3)
- ret = 0;
- else
-#endif
- /* save these for re-use; don't free the storage */
- if ((iop->flag & IOP_IS_INTERNAL) != 0) {
- iop->off = iop->buf;
- iop->end = iop->buf + strlen(iop->buf);
- iop->cnt = 0;
- iop->secsiz = 0;
- return 0;
- }
-
- /* Don't close standard files or else crufty code elsewhere will lose */
- if (iop->fd == fileno(stdin) ||
- iop->fd == fileno(stdout) ||
- iop->fd == fileno(stderr))
- ret = 0;
- else
- ret = close(iop->fd);
- if (ret == -1)
- warning("close of fd %d failed (%s)", iop->fd, strerror(errno));
- if ((iop->flag & IOP_NO_FREE) == 0) {
- /*
- * be careful -- $0 may still reference the buffer even though
- * an explicit close is being done; in the future, maybe we
- * can do this a bit better
- */
- if (iop->buf) {
- if ((fields_arr[0]->stptr >= iop->buf)
- && (fields_arr[0]->stptr < iop->end)) {
- NODE *t;
-
- t = make_string(fields_arr[0]->stptr,
- fields_arr[0]->stlen);
- unref(fields_arr[0]);
- fields_arr [0] = t;
- reset_record ();
- }
- free(iop->buf);
- }
- free((char *)iop);
- }
- return ret == -1 ? 1 : 0;
-}
-
-void
-do_input()
-{
- IOBUF *iop;
- extern int exiting;
-
- if (setjmp(filebuf) != 0) {
- }
- while ((iop = nextfile(0)) != NULL) {
- if (inrec(iop) == 0)
- while (interpret(expression_value) && inrec(iop) == 0)
- ;
- if (exiting)
- break;
- }
-}
-
-/* Redirection for printf and print commands */
-struct redirect *
-redirect(tree, errflg)
-NODE *tree;
-int *errflg;
-{
- register NODE *tmp;
- register struct redirect *rp;
- register char *str;
- int tflag = 0;
- int outflag = 0;
- char *direction = "to";
- char *mode;
- int fd;
- char *what = NULL;
-
- switch (tree->type) {
- case Node_redirect_append:
- tflag = RED_APPEND;
- /* FALL THROUGH */
- case Node_redirect_output:
- outflag = (RED_FILE|RED_WRITE);
- tflag |= outflag;
- if (tree->type == Node_redirect_output)
- what = ">";
- else
- what = ">>";
- break;
- case Node_redirect_pipe:
- tflag = (RED_PIPE|RED_WRITE);
- what = "|";
- break;
- case Node_redirect_pipein:
- tflag = (RED_PIPE|RED_READ);
- what = "|";
- break;
- case Node_redirect_input:
- tflag = (RED_FILE|RED_READ);
- what = "<";
- break;
- default:
- fatal ("invalid tree type %d in redirect()", tree->type);
- break;
- }
- tmp = tree_eval(tree->subnode);
- if (do_lint && ! (tmp->flags & STR))
- warning("expression in `%s' redirection only has numeric value",
- what);
- tmp = force_string(tmp);
- str = tmp->stptr;
- if (str == NULL || *str == '\0')
- fatal("expression for `%s' redirection has null string value",
- what);
- if (do_lint
- && (STREQN(str, "0", tmp->stlen) || STREQN(str, "1", tmp->stlen)))
- warning("filename `%s' for `%s' redirection may be result of logical expression", str, what);
- for (rp = red_head; rp != NULL; rp = rp->next)
- if (strlen(rp->value) == tmp->stlen
- && STREQN(rp->value, str, tmp->stlen)
- && ((rp->flag & ~(RED_NOBUF|RED_EOF)) == tflag
- || (outflag
- && (rp->flag & (RED_FILE|RED_WRITE)) == outflag)))
- break;
- if (rp == NULL) {
- emalloc(rp, struct redirect *, sizeof(struct redirect),
- "redirect");
- emalloc(str, char *, tmp->stlen+1, "redirect");
- memcpy(str, tmp->stptr, tmp->stlen);
- str[tmp->stlen] = '\0';
- rp->value = str;
- rp->flag = tflag;
- rp->fp = NULL;
- rp->iop = NULL;
- rp->pid = 0; /* unlikely that we're worried about init */
- rp->status = 0;
- /* maintain list in most-recently-used first order */
- if (red_head)
- red_head->prev = rp;
- rp->prev = NULL;
- rp->next = red_head;
- red_head = rp;
- }
- while (rp->fp == NULL && rp->iop == NULL) {
- if (rp->flag & RED_EOF)
- /* encountered EOF on file or pipe -- must be cleared
- * by explicit close() before reading more
- */
- return rp;
- mode = NULL;
- errno = 0;
- switch (tree->type) {
- case Node_redirect_output:
- mode = "w";
- if (rp->flag & RED_USED)
- mode = "a";
- break;
- case Node_redirect_append:
- mode = "a";
- break;
- case Node_redirect_pipe:
- if ((rp->fp = popen(str, "w")) == NULL)
- fatal("can't open pipe (\"%s\") for output (%s)",
- str, strerror(errno));
- rp->flag |= RED_NOBUF;
- break;
- case Node_redirect_pipein:
- direction = "from";
- if (gawk_popen(str, rp) == NULL)
- fatal("can't open pipe (\"%s\") for input (%s)",
- str, strerror(errno));
- break;
- case Node_redirect_input:
- direction = "from";
- rp->iop = iop_open(str, "r");
- break;
- default:
- cant_happen();
- }
- if (mode != NULL) {
- fd = devopen(str, mode);
- if (fd > INVALID_HANDLE) {
- if (fd == fileno(stdin))
- rp->fp = stdin;
- else if (fd == fileno(stdout))
- rp->fp = stdout;
- else if (fd == fileno(stderr))
- rp->fp = stderr;
- else
- rp->fp = fdopen(fd, mode);
- if (isatty(fd))
- rp->flag |= RED_NOBUF;
- }
- }
- if (rp->fp == NULL && rp->iop == NULL) {
- /* too many files open -- close one and try again */
- if (errno == EMFILE)
- close_one();
- else {
- /*
- * Some other reason for failure.
- *
- * On redirection of input from a file,
- * just return an error, so e.g. getline
- * can return -1. For output to file,
- * complain. The shell will complain on
- * a bad command to a pipe.
- */
- *errflg = errno;
- if (tree->type == Node_redirect_output
- || tree->type == Node_redirect_append)
- fatal("can't redirect %s `%s' (%s)",
- direction, str, strerror(errno));
- else {
- free_temp(tmp);
- return NULL;
- }
- }
- }
- }
- free_temp(tmp);
- return rp;
-}
-
-static void
-close_one()
-{
- register struct redirect *rp;
- register struct redirect *rplast = NULL;
-
- /* go to end of list first, to pick up least recently used entry */
- for (rp = red_head; rp != NULL; rp = rp->next)
- rplast = rp;
- /* now work back up through the list */
- for (rp = rplast; rp != NULL; rp = rp->prev)
- if (rp->fp && (rp->flag & RED_FILE)) {
- rp->flag |= RED_USED;
- errno = 0;
- if (fclose(rp->fp))
- warning("close of \"%s\" failed (%s).",
- rp->value, strerror(errno));
- rp->fp = NULL;
- break;
- }
- if (rp == NULL)
- /* surely this is the only reason ??? */
- fatal("too many pipes or input files open");
-}
-
-NODE *
-do_close(tree)
-NODE *tree;
-{
- NODE *tmp;
- register struct redirect *rp;
-
- tmp = force_string(tree_eval(tree->subnode));
- for (rp = red_head; rp != NULL; rp = rp->next) {
- if (strlen(rp->value) == tmp->stlen
- && STREQN(rp->value, tmp->stptr, tmp->stlen))
- break;
- }
- free_temp(tmp);
- if (rp == NULL) /* no match */
- return tmp_number((AWKNUM) 0.0);
- fflush(stdout); /* synchronize regular output */
- tmp = tmp_number((AWKNUM)close_redir(rp));
- rp = NULL;
- return tmp;
-}
-
-static int
-close_redir(rp)
-register struct redirect *rp;
-{
- int status = 0;
-
- if (rp == NULL)
- return 0;
- if (rp->fp == stdout || rp->fp == stderr)
- return 0;
- errno = 0;
- if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE))
- status = pclose(rp->fp);
- else if (rp->fp)
- status = fclose(rp->fp);
- else if (rp->iop) {
- if (rp->flag & RED_PIPE)
- status = gawk_pclose(rp);
- else {
- status = iop_close(rp->iop);
- rp->iop = NULL;
- }
- }
- /* SVR4 awk checks and warns about status of close */
- if (status) {
- char *s = strerror(errno);
-
- warning("failure status (%d) on %s close of \"%s\" (%s).",
- status,
- (rp->flag & RED_PIPE) ? "pipe" :
- "file", rp->value, s);
-
- if (! do_unix) {
- /* set ERRNO too so that program can get at it */
- unref(ERRNO_node->var_value);
- ERRNO_node->var_value = make_string(s, strlen(s));
- }
- }
- if (rp->next)
- rp->next->prev = rp->prev;
- if (rp->prev)
- rp->prev->next = rp->next;
- else
- red_head = rp->next;
- free(rp->value);
- free((char *)rp);
- return status;
-}
-
-int
-flush_io ()
-{
- register struct redirect *rp;
- int status = 0;
-
- errno = 0;
- if (fflush(stdout)) {
- warning("error writing standard output (%s).", strerror(errno));
- status++;
- }
- if (fflush(stderr)) {
- warning("error writing standard error (%s).", strerror(errno));
- status++;
- }
- for (rp = red_head; rp != NULL; rp = rp->next)
- /* flush both files and pipes, what the heck */
- if ((rp->flag & RED_WRITE) && rp->fp != NULL) {
- if (fflush(rp->fp)) {
- warning("%s flush of \"%s\" failed (%s).",
- (rp->flag & RED_PIPE) ? "pipe" :
- "file", rp->value, strerror(errno));
- status++;
- }
- }
- return status;
-}
-
-int
-close_io ()
-{
- register struct redirect *rp;
- register struct redirect *next;
- int status = 0;
-
- errno = 0;
- if (fclose(stdout)) {
- warning("error writing standard output (%s).", strerror(errno));
- status++;
- }
- if (fclose(stderr)) {
- warning("error writing standard error (%s).", strerror(errno));
- status++;
- }
- for (rp = red_head; rp != NULL; rp = next) {
- next = rp->next;
- if (close_redir(rp))
- status++;
- rp = NULL;
- }
- return status;
-}
-
-/* str2mode --- convert a string mode to an integer mode */
-
-static int
-str2mode(mode)
-char *mode;
-{
- int ret;
-
- switch(mode[0]) {
- case 'r':
- ret = O_RDONLY;
- break;
-
- case 'w':
- ret = O_WRONLY|O_CREAT|O_TRUNC;
- break;
-
- case 'a':
- ret = O_WRONLY|O_APPEND|O_CREAT;
- break;
- default:
- cant_happen();
- }
- return ret;
-}
-
-/* devopen --- handle /dev/std{in,out,err}, /dev/fd/N, regular files */
-
-/*
- * This separate version is still needed for output, since file and pipe
- * output is done with stdio. iop_open() handles input with IOBUFs of
- * more "special" files. Those files are not handled here since it makes
- * no sense to use them for output.
- */
-
-int
-devopen(name, mode)
-char *name, *mode;
-{
- int openfd = INVALID_HANDLE;
- char *cp, *ptr;
- int flag = 0;
- struct stat buf;
- extern double strtod();
-
- flag = str2mode(mode);
-
- if (do_unix)
- goto strictopen;
-
-#ifdef VMS
- if ((openfd = vms_devopen(name, flag)) >= 0)
- return openfd;
-#endif /* VMS */
-
- if (STREQ(name, "-"))
- openfd = fileno(stdin);
- else if (STREQN(name, "/dev/", 5) && stat(name, &buf) == -1) {
- cp = name + 5;
-
- if (STREQ(cp, "stdin") && (flag & O_RDONLY) == O_RDONLY)
- openfd = fileno(stdin);
- else if (STREQ(cp, "stdout") && (flag & O_WRONLY) == O_WRONLY)
- openfd = fileno(stdout);
- else if (STREQ(cp, "stderr") && (flag & O_WRONLY) == O_WRONLY)
- openfd = fileno(stderr);
- else if (STREQN(cp, "fd/", 3)) {
- cp += 3;
- openfd = (int)strtod(cp, &ptr);
- if (openfd <= INVALID_HANDLE || ptr == cp)
- openfd = INVALID_HANDLE;
- }
- }
-
-strictopen:
- if (openfd == INVALID_HANDLE)
- openfd = open(name, flag, 0666);
- if (openfd != INVALID_HANDLE && fstat(openfd, &buf) > 0)
- if (S_ISDIR(buf.st_mode))
- fatal("file `%s' is a directory", name);
- return openfd;
-}
-
-
-/* spec_setup --- setup an IOBUF for a special internal file */
-
-void
-spec_setup(iop, len, allocate)
-IOBUF *iop;
-int len;
-int allocate;
-{
- char *cp;
-
- if (allocate) {
- emalloc(cp, char *, len+2, "spec_setup");
- iop->buf = cp;
- } else {
- len = strlen(iop->buf);
- iop->buf[len++] = '\n'; /* get_a_record clobbered it */
- iop->buf[len] = '\0'; /* just in case */
- }
- iop->off = iop->buf;
- iop->cnt = 0;
- iop->secsiz = 0;
- iop->size = len;
- iop->end = iop->buf + len;
- iop->fd = -1;
- iop->flag = IOP_IS_INTERNAL;
-}
-
-/* specfdopen --- open a fd special file */
-
-int
-specfdopen(iop, name, mode)
-IOBUF *iop;
-char *name, *mode;
-{
- int fd;
- IOBUF *tp;
-
- fd = devopen(name, mode);
- if (fd == INVALID_HANDLE)
- return INVALID_HANDLE;
- tp = iop_alloc(fd);
- if (tp == NULL)
- return INVALID_HANDLE;
- *iop = *tp;
- iop->flag |= IOP_NO_FREE;
- free(tp);
- return 0;
-}
-
-/* pidopen --- "open" /dev/pid, /dev/ppid, and /dev/pgrpid */
-
-int
-pidopen(iop, name, mode)
-IOBUF *iop;
-char *name, *mode;
-{
- char tbuf[BUFSIZ];
- int i;
-
- if (name[6] == 'g')
-/* following #if will improve in 2.16 */
-#if defined(__svr4__) || defined(i860) || defined(_AIX) || defined(BSD4_4) || defined(__386BSD__)
- sprintf(tbuf, "%d\n", getpgrp());
-#else
- sprintf(tbuf, "%d\n", getpgrp(getpid()));
-#endif
- else if (name[6] == 'i')
- sprintf(tbuf, "%d\n", getpid());
- else
- sprintf(tbuf, "%d\n", getppid());
- i = strlen(tbuf);
- spec_setup(iop, i, 1);
- strcpy(iop->buf, tbuf);
- return 0;
-}
-
-/* useropen --- "open" /dev/user */
-
-/*
- * /dev/user creates a record as follows:
- * $1 = getuid()
- * $2 = geteuid()
- * $3 = getgid()
- * $4 = getegid()
- * If multiple groups are supported, the $5 through $NF are the
- * supplementary group set.
- */
-
-int
-useropen(iop, name, mode)
-IOBUF *iop;
-char *name, *mode;
-{
- char tbuf[BUFSIZ], *cp;
- int i;
-#if defined(NGROUPS_MAX) && NGROUPS_MAX > 0
- int groupset[NGROUPS_MAX];
- int ngroups;
-#endif
-
- sprintf(tbuf, "%d %d %d %d", getuid(), geteuid(), getgid(), getegid());
-
- cp = tbuf + strlen(tbuf);
-#if defined(NGROUPS_MAX) && NGROUPS_MAX > 0
- ngroups = getgroups(NGROUPS_MAX, groupset);
- if (ngroups == -1)
- fatal("could not find groups: %s", strerror(errno));
-
- for (i = 0; i < ngroups; i++) {
- *cp++ = ' ';
- sprintf(cp, "%d", groupset[i]);
- cp += strlen(cp);
- }
-#endif
- *cp++ = '\n';
- *cp++ = '\0';
-
-
- i = strlen(tbuf);
- spec_setup(iop, i, 1);
- strcpy(iop->buf, tbuf);
- return 0;
-}
-
-/* iop_open --- handle special and regular files for input */
-
-static IOBUF *
-iop_open(name, mode)
-char *name, *mode;
-{
- int openfd = INVALID_HANDLE;
- char *cp, *ptr;
- int flag = 0;
- int i;
- struct stat buf;
- IOBUF *iop;
- static struct internal {
- char *name;
- int compare;
- int (*fp)();
- IOBUF iob;
- } table[] = {
- { "/dev/fd/", 8, specfdopen },
- { "/dev/stdin", 10, specfdopen },
- { "/dev/stdout", 11, specfdopen },
- { "/dev/stderr", 11, specfdopen },
- { "/dev/pid", 8, pidopen },
- { "/dev/ppid", 9, pidopen },
- { "/dev/pgrpid", 11, pidopen },
- { "/dev/user", 9, useropen },
- };
- int devcount = sizeof(table) / sizeof(table[0]);
-
- flag = str2mode(mode);
-
- if (do_unix)
- goto strictopen;
-
- if (STREQ(name, "-"))
- openfd = fileno(stdin);
- else if (STREQN(name, "/dev/", 5) && stat(name, &buf) == -1) {
- int i;
-
- for (i = 0; i < devcount; i++) {
- if (STREQN(name, table[i].name, table[i].compare)) {
- IOBUF *iop = & table[i].iob;
-
- if (iop->buf != NULL) {
- spec_setup(iop, 0, 0);
- return iop;
- } else if ((*table[i].fp)(iop, name, mode) == 0)
- return iop;
- else {
- warning("could not open %s, mode `%s'",
- name, mode);
- return NULL;
- }
- }
- }
- }
-
-strictopen:
- if (openfd == INVALID_HANDLE)
- openfd = open(name, flag, 0666);
- if (openfd != INVALID_HANDLE && fstat(openfd, &buf) > 0)
- if ((buf.st_mode & S_IFMT) == S_IFDIR)
- fatal("file `%s' is a directory", name);
- iop = iop_alloc(openfd);
- return iop;
-}
-
-#ifndef PIPES_SIMULATED
- /* real pipes */
-static int
-wait_any(interesting)
-int interesting; /* pid of interest, if any */
-{
- SIGTYPE (*hstat)(), (*istat)(), (*qstat)();
- int pid;
- int status = 0;
- struct redirect *redp;
- extern int errno;
-
- hstat = signal(SIGHUP, SIG_IGN);
- istat = signal(SIGINT, SIG_IGN);
- qstat = signal(SIGQUIT, SIG_IGN);
- for (;;) {
-#ifdef NeXT
- pid = wait((union wait *)&status);
-#else
- pid = wait(&status);
-#endif /* NeXT */
- if (interesting && pid == interesting) {
- break;
- } else if (pid != -1) {
- for (redp = red_head; redp != NULL; redp = redp->next)
- if (pid == redp->pid) {
- redp->pid = -1;
- redp->status = status;
- if (redp->fp) {
- pclose(redp->fp);
- redp->fp = 0;
- }
- if (redp->iop) {
- (void) iop_close(redp->iop);
- redp->iop = 0;
- }
- break;
- }
- }
- if (pid == -1 && errno == ECHILD)
- break;
- }
- signal(SIGHUP, hstat);
- signal(SIGINT, istat);
- signal(SIGQUIT, qstat);
- return(status);
-}
-
-static IOBUF *
-gawk_popen(cmd, rp)
-char *cmd;
-struct redirect *rp;
-{
- int p[2];
- register int pid;
-
- /* used to wait for any children to synchronize input and output,
- * but this could cause gawk to hang when it is started in a pipeline
- * and thus has a child process feeding it input (shell dependant)
- */
- /*(void) wait_any(0);*/ /* wait for outstanding processes */
-
- if (pipe(p) < 0)
- fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
- if ((pid = fork()) == 0) {
- if (close(1) == -1)
- fatal("close of stdout in child failed (%s)",
- strerror(errno));
- if (dup(p[1]) != 1)
- fatal("dup of pipe failed (%s)", strerror(errno));
- if (close(p[0]) == -1 || close(p[1]) == -1)
- fatal("close of pipe failed (%s)", strerror(errno));
- if (close(0) == -1)
- fatal("close of stdin in child failed (%s)",
- strerror(errno));
- execl("/bin/sh", "sh", "-c", cmd, 0);
- _exit(127);
- }
- if (pid == -1)
- fatal("cannot fork for \"%s\" (%s)", cmd, strerror(errno));
- rp->pid = pid;
- if (close(p[1]) == -1)
- fatal("close of pipe failed (%s)", strerror(errno));
- return (rp->iop = iop_alloc(p[0]));
-}
-
-static int
-gawk_pclose(rp)
-struct redirect *rp;
-{
- (void) iop_close(rp->iop);
- rp->iop = NULL;
-
- /* process previously found, return stored status */
- if (rp->pid == -1)
- return (rp->status >> 8) & 0xFF;
- rp->status = wait_any(rp->pid);
- rp->pid = -1;
- return (rp->status >> 8) & 0xFF;
-}
-
-#else /* PIPES_SIMULATED */
- /* use temporary file rather than pipe */
-
-#ifdef VMS
-static IOBUF *
-gawk_popen(cmd, rp)
-char *cmd;
-struct redirect *rp;
-{
- FILE *current;
-
- if ((current = popen(cmd, "r")) == NULL)
- return NULL;
- return (rp->iop = iop_alloc(fileno(current)));
-}
-
-static int
-gawk_pclose(rp)
-struct redirect *rp;
-{
- int rval, aval, fd = rp->iop->fd;
- FILE *kludge = fdopen(fd, "r"); /* pclose needs FILE* w/ right fileno */
-
- rp->iop->fd = dup(fd); /* kludge to allow close() + pclose() */
- rval = iop_close(rp->iop);
- rp->iop = NULL;
- aval = pclose(kludge);
- return (rval < 0 ? rval : aval);
-}
-#else /* VMS */
-
-static
-struct {
- char *command;
- char *name;
-} pipes[_NFILE];
-
-static IOBUF *
-gawk_popen(cmd, rp)
-char *cmd;
-struct redirect *rp;
-{
- extern char *strdup(const char *);
- int current;
- char *name;
- static char cmdbuf[256];
-
- /* get a name to use. */
- if ((name = tempnam(".", "pip")) == NULL)
- return NULL;
- sprintf(cmdbuf,"%s > %s", cmd, name);
- system(cmdbuf);
- if ((current = open(name,O_RDONLY)) == INVALID_HANDLE)
- return NULL;
- pipes[current].name = name;
- pipes[current].command = strdup(cmd);
- rp->iop = iop_alloc(current);
- return (rp->iop = iop_alloc(current));
-}
-
-static int
-gawk_pclose(rp)
-struct redirect *rp;
-{
- int cur = rp->iop->fd;
- int rval;
-
- rval = iop_close(rp->iop);
- rp->iop = NULL;
-
- /* check for an open file */
- if (pipes[cur].name == NULL)
- return -1;
- unlink(pipes[cur].name);
- free(pipes[cur].name);
- pipes[cur].name = NULL;
- free(pipes[cur].command);
- return rval;
-}
-#endif /* VMS */
-
-#endif /* PIPES_SIMULATED */
-
-NODE *
-do_getline(tree)
-NODE *tree;
-{
- struct redirect *rp = NULL;
- IOBUF *iop;
- int cnt = EOF;
- char *s = NULL;
- int errcode;
-
- while (cnt == EOF) {
- if (tree->rnode == NULL) { /* no redirection */
- iop = nextfile(0);
- if (iop == NULL) /* end of input */
- return tmp_number((AWKNUM) 0.0);
- } else {
- int redir_error = 0;
-
- rp = redirect(tree->rnode, &redir_error);
- if (rp == NULL && redir_error) { /* failed redirect */
- if (! do_unix) {
- char *s = strerror(redir_error);
-
- unref(ERRNO_node->var_value);
- ERRNO_node->var_value =
- make_string(s, strlen(s));
- }
- return tmp_number((AWKNUM) -1.0);
- }
- iop = rp->iop;
- if (iop == NULL) /* end of input */
- return tmp_number((AWKNUM) 0.0);
- }
- errcode = 0;
- cnt = get_a_record(&s, iop, *RS, & errcode);
- if (! do_unix && errcode != 0) {
- char *s = strerror(errcode);
-
- unref(ERRNO_node->var_value);
- ERRNO_node->var_value = make_string(s, strlen(s));
- return tmp_number((AWKNUM) -1.0);
- }
- if (cnt == EOF) {
- if (rp) {
- /*
- * Don't do iop_close() here if we are
- * reading from a pipe; otherwise
- * gawk_pclose will not be called.
- */
- if (!(rp->flag & RED_PIPE)) {
- (void) iop_close(iop);
- rp->iop = NULL;
- }
- rp->flag |= RED_EOF; /* sticky EOF */
- return tmp_number((AWKNUM) 0.0);
- } else
- continue; /* try another file */
- }
- if (!rp) {
- NR += 1;
- FNR += 1;
- }
- if (tree->lnode == NULL) /* no optional var. */
- set_record(s, cnt, 1);
- else { /* assignment to variable */
- Func_ptr after_assign = NULL;
- NODE **lhs;
-
- lhs = get_lhs(tree->lnode, &after_assign);
- unref(*lhs);
- *lhs = make_string(s, strlen(s));
- (*lhs)->flags |= MAYBE_NUM;
- /* we may have to regenerate $0 here! */
- if (after_assign)
- (*after_assign)();
- }
- }
- return tmp_number((AWKNUM) 1.0);
-}
-
-int
-pathopen (file)
-char *file;
-{
- int fd = do_pathopen(file);
-
-#ifdef DEFAULT_FILETYPE
- if (! do_unix && fd <= INVALID_HANDLE) {
- char *file_awk;
- int save = errno;
-#ifdef VMS
- int vms_save = vaxc$errno;
-#endif
-
- /* append ".awk" and try again */
- emalloc(file_awk, char *, strlen(file) +
- sizeof(DEFAULT_FILETYPE) + 1, "pathopen");
- sprintf(file_awk, "%s%s", file, DEFAULT_FILETYPE);
- fd = do_pathopen(file_awk);
- free(file_awk);
- if (fd <= INVALID_HANDLE) {
- errno = save;
-#ifdef VMS
- vaxc$errno = vms_save;
-#endif
- }
- }
-#endif /*DEFAULT_FILETYPE*/
-
- return fd;
-}
-
-static int
-do_pathopen (file)
-char *file;
-{
- static char *savepath = DEFPATH; /* defined in config.h */
- static int first = 1;
- char *awkpath, *cp;
- char trypath[BUFSIZ];
- int fd;
-
- if (STREQ(file, "-"))
- return (0);
-
- if (do_unix)
- return (devopen(file, "r"));
-
- if (first) {
- first = 0;
- if ((awkpath = getenv ("AWKPATH")) != NULL && *awkpath)
- savepath = awkpath; /* used for restarting */
- }
- awkpath = savepath;
-
- /* some kind of path name, no search */
-#ifdef VMS /* (strchr not equal implies either or both not NULL) */
- if (strchr(file, ':') != strchr(file, ']')
- || strchr(file, '>') != strchr(file, '/'))
-#else /*!VMS*/
-#ifdef MSDOS
- if (strchr(file, '/') != strchr(file, '\\')
- || strchr(file, ':') != NULL)
-#else
- if (strchr(file, '/') != NULL)
-#endif /*MSDOS*/
-#endif /*VMS*/
- return (devopen(file, "r"));
-
- do {
- trypath[0] = '\0';
- /* this should take into account limits on size of trypath */
- for (cp = trypath; *awkpath && *awkpath != ENVSEP; )
- *cp++ = *awkpath++;
-
- if (cp != trypath) { /* nun-null element in path */
- /* add directory punctuation only if needed */
-#ifdef VMS
- if (strchr(":]>/", *(cp-1)) == NULL)
-#else
-#ifdef MSDOS
- if (strchr(":\\/", *(cp-1)) == NULL)
-#else
- if (*(cp-1) != '/')
-#endif
-#endif
- *cp++ = '/';
- /* append filename */
- strcpy (cp, file);
- } else
- strcpy (trypath, file);
- if ((fd = devopen(trypath, "r")) >= 0)
- return (fd);
-
- /* no luck, keep going */
- if(*awkpath == ENVSEP && awkpath[1] != '\0')
- awkpath++; /* skip colon */
- } while (*awkpath);
- /*
- * You might have one of the awk
- * paths defined, WITHOUT the current working directory in it.
- * Therefore try to open the file in the current directory.
- */
- return (devopen(file, "r"));
-}
diff --git a/gnu/usr.bin/awk/iop.c b/gnu/usr.bin/awk/iop.c
deleted file mode 100644
index 0d7af12..0000000
--- a/gnu/usr.bin/awk/iop.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * iop.c - do i/o related things.
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-#ifndef atarist
-#define INVALID_HANDLE (-1)
-#else
-#include <stddef.h>
-#include <fcntl.h>
-#define INVALID_HANDLE (__SMALLEST_VALID_HANDLE - 1)
-#endif /* atarist */
-
-
-#ifdef TEST
-int bufsize = 8192;
-
-void
-fatal(s)
-char *s;
-{
- printf("%s\n", s);
- exit(1);
-}
-#endif
-
-int
-optimal_bufsize(fd)
-int fd;
-{
- struct stat stb;
-
-#ifdef VMS
- /*
- * These values correspond with the RMS multi-block count used by
- * vms_open() in vms/vms_misc.c.
- */
- if (isatty(fd) > 0)
- return BUFSIZ;
- else if (fstat(fd, &stb) < 0)
- return 8*512; /* conservative in case of DECnet access */
- else
- return 24*512;
-
-#else
- /*
- * System V doesn't have the file system block size in the
- * stat structure. So we have to make some sort of reasonable
- * guess. We use stdio's BUFSIZ, since that is what it was
- * meant for in the first place.
- */
-#ifdef BLKSIZE_MISSING
-#define DEFBLKSIZE BUFSIZ
-#else
-#define DEFBLKSIZE (stb.st_blksize ? stb.st_blksize : BUFSIZ)
-#endif
-
-#ifdef TEST
- return bufsize;
-#else
-#ifndef atarist
- if (isatty(fd))
-#else
- /*
- * On ST redirected stdin does not have a name attached
- * (this could be hard to do to) and fstat would fail
- */
- if (0 == fd || isatty(fd))
-#endif /*atarist */
- return BUFSIZ;
-#ifndef BLKSIZE_MISSING
- /* VMS POSIX 1.0: st_blksize is never assigned a value, so zero it */
- stb.st_blksize = 0;
-#endif
- if (fstat(fd, &stb) == -1)
- fatal("can't stat fd %d (%s)", fd, strerror(errno));
- if (lseek(fd, (off_t)0, 0) == -1)
- return DEFBLKSIZE;
- return ((int) (stb.st_size < DEFBLKSIZE ? stb.st_size : DEFBLKSIZE));
-#endif /*! TEST */
-#endif /*! VMS */
-}
-
-IOBUF *
-iop_alloc(fd)
-int fd;
-{
- IOBUF *iop;
-
- if (fd == INVALID_HANDLE)
- return NULL;
- emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
- iop->flag = 0;
- if (isatty(fd))
- iop->flag |= IOP_IS_TTY;
- iop->size = optimal_bufsize(fd);
- iop->secsiz = -2;
- errno = 0;
- iop->fd = fd;
- iop->off = iop->buf = NULL;
- iop->cnt = 0;
- return iop;
-}
-
-/*
- * Get the next record. Uses a "split buffer" where the latter part is
- * the normal read buffer and the head part is an "overflow" area that is used
- * when a record spans the end of the normal buffer, in which case the first
- * part of the record is copied into the overflow area just before the
- * normal buffer. Thus, the eventual full record can be returned as a
- * contiguous area of memory with a minimum of copying. The overflow area
- * is expanded as needed, so that records are unlimited in length.
- * We also mark both the end of the buffer and the end of the read() with
- * a sentinel character (the current record separator) so that the inside
- * loop can run as a single test.
- */
-int
-get_a_record(out, iop, grRS, errcode)
-char **out;
-IOBUF *iop;
-register int grRS;
-int *errcode;
-{
- register char *bp = iop->off;
- char *bufend;
- char *start = iop->off; /* beginning of record */
- int saw_newline;
- char rs;
- int eat_whitespace;
-
- if (iop->cnt == EOF) /* previous read hit EOF */
- return EOF;
-
- if (grRS == 0) { /* special case: grRS == "" */
- rs = '\n';
- eat_whitespace = 0;
- saw_newline = 0;
- } else
- rs = (char) grRS;
-
- /* set up sentinel */
- if (iop->buf) {
- bufend = iop->buf + iop->size + iop->secsiz;
- *bufend = rs;
- } else
- bufend = NULL;
-
- for (;;) { /* break on end of record, read error or EOF */
-
- /* Following code is entered on the first call of this routine
- * for a new iop, or when we scan to the end of the buffer.
- * In the latter case, we copy the current partial record to
- * the space preceding the normal read buffer. If necessary,
- * we expand this space. This is done so that we can return
- * the record as a contiguous area of memory.
- */
- if ((iop->flag & IOP_IS_INTERNAL) == 0 && bp >= bufend) {
- char *oldbuf = NULL;
- char *oldsplit = iop->buf + iop->secsiz;
- long len; /* record length so far */
-
- if ((iop->flag & IOP_IS_INTERNAL) != 0)
- cant_happen();
-
- len = bp - start;
- if (len > iop->secsiz) {
- /* expand secondary buffer */
- if (iop->secsiz == -2)
- iop->secsiz = 256;
- while (len > iop->secsiz)
- iop->secsiz *= 2;
- oldbuf = iop->buf;
- emalloc(iop->buf, char *,
- iop->size+iop->secsiz+2, "get_a_record");
- bufend = iop->buf + iop->size + iop->secsiz;
- *bufend = rs;
- }
- if (len > 0) {
- char *newsplit = iop->buf + iop->secsiz;
-
- if (start < oldsplit) {
- memcpy(newsplit - len, start,
- oldsplit - start);
- memcpy(newsplit - (bp - oldsplit),
- oldsplit, bp - oldsplit);
- } else
- memcpy(newsplit - len, start, len);
- }
- bp = iop->end = iop->off = iop->buf + iop->secsiz;
- start = bp - len;
- if (oldbuf) {
- free(oldbuf);
- oldbuf = NULL;
- }
- }
- /* Following code is entered whenever we have no more data to
- * scan. In most cases this will read into the beginning of
- * the main buffer, but in some cases (terminal, pipe etc.)
- * we may be doing smallish reads into more advanced positions.
- */
- if (bp >= iop->end) {
- if ((iop->flag & IOP_IS_INTERNAL) != 0) {
- iop->cnt = EOF;
- break;
- }
- iop->cnt = read(iop->fd, iop->end, bufend - iop->end);
- if (iop->cnt == -1) {
- if (! do_unix && errcode != NULL) {
- *errcode = errno;
- iop->cnt = EOF;
- break;
- } else
- fatal("error reading input: %s",
- strerror(errno));
- } else if (iop->cnt == 0) {
- iop->cnt = EOF;
- break;
- }
- iop->end += iop->cnt;
- *iop->end = rs;
- }
- if (grRS == 0) {
- extern int default_FS;
-
- if (default_FS && (bp == start || eat_whitespace)) {
- while (bp < iop->end && isspace(*bp))
- bp++;
- if (bp == iop->end) {
- eat_whitespace = 1;
- continue;
- } else
- eat_whitespace = 0;
- }
- if (saw_newline && *bp == rs) {
- bp++;
- break;
- }
- saw_newline = 0;
- }
-
- while (*bp++ != rs)
- ;
-
- if (bp <= iop->end) {
- if (grRS == 0)
- saw_newline = 1;
- else
- break;
- } else
- bp--;
-
- if ((iop->flag & IOP_IS_INTERNAL) != 0)
- iop->cnt = bp - start;
- }
- if (iop->cnt == EOF
- && (((iop->flag & IOP_IS_INTERNAL) != 0) || start == bp))
- return EOF;
-
- iop->off = bp;
- bp--;
- if (*bp != rs)
- bp++;
- *bp = '\0';
- if (grRS == 0) {
- if (*--bp == rs)
- *bp = '\0';
- else
- bp++;
- }
-
- *out = start;
- return bp - start;
-}
-
-#ifdef TEST
-main(argc, argv)
-int argc;
-char *argv[];
-{
- IOBUF *iop;
- char *out;
- int cnt;
- char rs[2];
-
- rs[0] = 0;
- if (argc > 1)
- bufsize = atoi(argv[1]);
- if (argc > 2)
- rs[0] = *argv[2];
- iop = iop_alloc(0);
- while ((cnt = get_a_record(&out, iop, rs[0], NULL)) > 0) {
- fwrite(out, 1, cnt, stdout);
- fwrite(rs, 1, 1, stdout);
- }
-}
-#endif
diff --git a/gnu/usr.bin/awk/main.c b/gnu/usr.bin/awk/main.c
deleted file mode 100644
index 77d0bf7..0000000
--- a/gnu/usr.bin/awk/main.c
+++ /dev/null
@@ -1,731 +0,0 @@
-/*
- * main.c -- Expression tree constructors and main program for gawk.
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "getopt.h"
-#include "awk.h"
-#include "patchlevel.h"
-
-static void usage P((int exitval));
-static void copyleft P((void));
-static void cmdline_fs P((char *str));
-static void init_args P((int argc0, int argc, char *argv0, char **argv));
-static void init_vars P((void));
-static void pre_assign P((char *v));
-SIGTYPE catchsig P((int sig, int code));
-static void gawk_option P((char *optstr));
-static void nostalgia P((void));
-static void version P((void));
-char *gawk_name P((char *filespec));
-
-#ifdef MSDOS
-extern int isatty P((int));
-#endif
-
-extern void resetup P((void));
-
-/* These nodes store all the special variables AWK uses */
-NODE *FS_node, *NF_node, *RS_node, *NR_node;
-NODE *FILENAME_node, *OFS_node, *ORS_node, *OFMT_node;
-NODE *CONVFMT_node;
-NODE *ERRNO_node;
-NODE *FNR_node, *RLENGTH_node, *RSTART_node, *SUBSEP_node;
-NODE *ENVIRON_node, *IGNORECASE_node;
-NODE *ARGC_node, *ARGV_node, *ARGIND_node;
-NODE *FIELDWIDTHS_node;
-
-int NF;
-int NR;
-int FNR;
-int IGNORECASE;
-char *RS;
-char *OFS;
-char *ORS;
-char *OFMT;
-char *CONVFMT;
-
-/*
- * The parse tree and field nodes are stored here. Parse_end is a dummy item
- * used to free up unneeded fields without freeing the program being run
- */
-int errcount = 0; /* error counter, used by yyerror() */
-
-/* The global null string */
-NODE *Nnull_string;
-
-/* The name the program was invoked under, for error messages */
-const char *myname;
-
-/* A block of AWK code to be run before running the program */
-NODE *begin_block = 0;
-
-/* A block of AWK code to be run after the last input file */
-NODE *end_block = 0;
-
-int exiting = 0; /* Was an "exit" statement executed? */
-int exit_val = 0; /* optional exit value */
-
-#if defined(YYDEBUG) || defined(DEBUG)
-extern int yydebug;
-#endif
-
-struct src *srcfiles = NULL; /* source file name(s) */
-int numfiles = -1; /* how many source files */
-
-int do_unix = 0; /* turn off gnu extensions */
-int do_posix = 0; /* turn off gnu and unix extensions */
-int do_lint = 0; /* provide warnings about questionable stuff */
-int do_nostalgia = 0; /* provide a blast from the past */
-
-int in_begin_rule = 0; /* we're in a BEGIN rule */
-int in_end_rule = 0; /* we're in a END rule */
-
-int output_is_tty = 0; /* control flushing of output */
-
-extern char *version_string; /* current version, for printing */
-
-NODE *expression_value;
-
-static struct option optab[] = {
- { "compat", no_argument, & do_unix, 1 },
- { "lint", no_argument, & do_lint, 1 },
- { "posix", no_argument, & do_posix, 1 },
- { "nostalgia", no_argument, & do_nostalgia, 1 },
- { "copyleft", no_argument, NULL, 'C' },
- { "copyright", no_argument, NULL, 'C' },
- { "field-separator", required_argument, NULL, 'F' },
- { "file", required_argument, NULL, 'f' },
- { "assign", required_argument, NULL, 'v' },
- { "version", no_argument, NULL, 'V' },
- { "usage", no_argument, NULL, 'u' },
- { "help", no_argument, NULL, 'u' },
- { "source", required_argument, NULL, 's' },
-#ifdef DEBUG
- { "parsedebug", no_argument, NULL, 'D' },
-#endif
- { 0, 0, 0, 0 }
-};
-
-int
-main(argc, argv)
-int argc;
-char **argv;
-{
- int c;
- char *scan;
- extern int optind;
- extern int opterr;
- extern char *optarg;
- int i;
-
- (void) signal(SIGFPE, (SIGTYPE (*) P((int))) catchsig);
- (void) signal(SIGSEGV, (SIGTYPE (*) P((int))) catchsig);
-#ifdef SIGBUS
- (void) signal(SIGBUS, (SIGTYPE (*) P((int))) catchsig);
-#endif
-
- myname = gawk_name(argv[0]);
- argv[0] = (char *)myname;
-#ifdef VMS
- vms_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */
-#endif
-
- /* remove sccs gunk */
- if (strncmp(version_string, "@(#)", 4) == 0)
- version_string += 4;
-
- if (argc < 2)
- usage(1);
-
- /* initialize the null string */
- Nnull_string = make_string("", 0);
- Nnull_string->numbr = 0.0;
- Nnull_string->type = Node_val;
- Nnull_string->flags = (PERM|STR|STRING|NUM|NUMBER);
-
- /* Set up the special variables */
-
- /*
- * Note that this must be done BEFORE arg parsing else -F
- * breaks horribly
- */
- init_vars();
-
- /* worst case */
- emalloc(srcfiles, struct src *, argc * sizeof(struct src), "main");
- memset(srcfiles, '\0', argc * sizeof(struct src));
-
- /* Tell the regex routines how they should work. . . */
- resetup();
-
- /* we do error messages ourselves on invalid options */
- opterr = 0;
-
- /* the + on the front tells GNU getopt not to rearrange argv */
- while ((c = getopt_long(argc, argv, "+F:f:v:W:", optab, NULL)) != EOF) {
- if (do_posix)
- opterr = 1;
- switch (c) {
- case 'F':
- cmdline_fs(optarg);
- break;
-
- case 'f':
- /*
- * a la MKS awk, allow multiple -f options.
- * this makes function libraries real easy.
- * most of the magic is in the scanner.
- */
- /* The following is to allow for whitespace at the end
- * of a #! /bin/gawk line in an executable file
- */
- scan = optarg;
- while (isspace(*scan))
- scan++;
- ++numfiles;
- srcfiles[numfiles].stype = SOURCEFILE;
- if (*scan == '\0')
- srcfiles[numfiles].val = argv[optind++];
- else
- srcfiles[numfiles].val = optarg;
- break;
-
- case 'v':
- pre_assign(optarg);
- break;
-
- case 'W': /* gawk specific options */
- gawk_option(optarg);
- break;
-
- /* These can only come from long form options */
- case 'V':
- version();
- break;
-
- case 'C':
- copyleft();
- break;
-
- case 'u':
- usage(0);
- break;
-
- case 's':
- if (strlen(optarg) == 0)
- warning("empty argument to --source ignored");
- else {
- srcfiles[++numfiles].stype = CMDLINE;
- srcfiles[numfiles].val = optarg;
- }
- break;
-
-#ifdef DEBUG
- case 'D':
- yydebug = 2;
- break;
-#endif
-
- case '?':
- default:
- /*
- * New behavior. If not posix, an unrecognized
- * option stops argument processing so that it can
- * go into ARGV for the awk program to see. This
- * makes use of ``#! /bin/gawk -f'' easier.
- */
- if (! do_posix)
- goto out;
- /* else
- let getopt print error message for us */
- break;
- }
- }
-out:
-
- if (do_nostalgia)
- nostalgia();
-
- /* POSIX compliance also implies no Unix extensions either */
- if (do_posix)
- do_unix = 1;
-
-#ifdef DEBUG
- setbuf(stdout, (char *) NULL); /* make debugging easier */
-#endif
- if (isatty(fileno(stdout)))
- output_is_tty = 1;
- /* No -f or --source options, use next arg */
- if (numfiles == -1) {
- if (optind > argc - 1) /* no args left */
- usage(1);
- srcfiles[++numfiles].stype = CMDLINE;
- srcfiles[numfiles].val = argv[optind];
- optind++;
- }
- init_args(optind, argc, (char *) myname, argv);
- (void) tokexpand();
-
- /* Read in the program */
- if (yyparse() || errcount)
- exit(1);
-
- /* Set up the field variables */
- init_fields();
-
- if (begin_block) {
- in_begin_rule = 1;
- (void) interpret(begin_block);
- }
- in_begin_rule = 0;
- if (!exiting && (expression_value || end_block))
- do_input();
- if (end_block) {
- in_end_rule = 1;
- (void) interpret(end_block);
- }
- in_end_rule = 0;
- if (close_io() != 0 && exit_val == 0)
- exit_val = 1;
- exit(exit_val); /* more portable */
- return exit_val; /* to suppress warnings */
-}
-
-/* usage --- print usage information and exit */
-
-static void
-usage(exitval)
-int exitval;
-{
- char *opt1 = " -f progfile [--]";
- char *opt2 = " [--] 'program'";
- char *regops = " [POSIX or GNU style options]";
-
- version();
- fprintf(stderr, "usage: %s%s%s file ...\n %s%s%s file ...\n",
- myname, regops, opt1, myname, regops, opt2);
-
- /* GNU long options info. Gack. */
- fputs("\nPOSIX options:\t\tGNU long options:\n", stderr);
- fputs("\t-f progfile\t\t--file=progfile\n", stderr);
- fputs("\t-F fs\t\t\t--field-separator=fs\n", stderr);
- fputs("\t-v var=val\t\t--assign=var=val\n", stderr);
- fputs("\t-W compat\t\t--compat\n", stderr);
- fputs("\t-W copyleft\t\t--copyleft\n", stderr);
- fputs("\t-W copyright\t\t--copyright\n", stderr);
- fputs("\t-W help\t\t\t--help\n", stderr);
- fputs("\t-W lint\t\t\t--lint\n", stderr);
-#if 0
- fputs("\t-W nostalgia\t\t--nostalgia\n", stderr);
-#endif
-#ifdef DEBUG
- fputs("\t-W parsedebug\t\t--parsedebug\n", stderr);
-#endif
- fputs("\t-W posix\t\t--posix\n", stderr);
- fputs("\t-W source=program-text\t--source=program-text\n", stderr);
- fputs("\t-W usage\t\t--usage\n", stderr);
- fputs("\t-W version\t\t--version\n", stderr);
- exit(exitval);
-}
-
-static void
-copyleft ()
-{
- static char blurb_part1[] =
-"Copyright (C) 1989, 1991, 1992, Free Software Foundation.\n\
-\n\
-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";
- static char blurb_part2[] =
-"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";
- static char blurb_part3[] =
-"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";
-
- version();
- fputs(blurb_part1, stderr);
- fputs(blurb_part2, stderr);
- fputs(blurb_part3, stderr);
- fflush(stderr);
-}
-
-static void
-cmdline_fs(str)
-char *str;
-{
- register NODE **tmp;
- int len = strlen(str);
-
- tmp = get_lhs(FS_node, (Func_ptr *) 0);
- unref(*tmp);
- /*
- * Only if in full compatibility mode check for the stupid special
- * case so -F\t works as documented in awk even though the shell
- * hands us -Ft. Bleah!
- *
- * Thankfully, Posix didn't propogate this "feature".
- */
- if (str[0] == 't' && str[1] == '\0') {
- if (do_lint)
- warning("-Ft does not set FS to tab in POSIX awk");
- if (do_unix && ! do_posix)
- str[0] = '\t';
- }
- *tmp = make_str_node(str, len, SCAN); /* do process escapes */
- set_FS();
-}
-
-static void
-init_args(argc0, argc, argv0, argv)
-int argc0, argc;
-char *argv0;
-char **argv;
-{
- int i, j;
- NODE **aptr;
-
- ARGV_node = install("ARGV", node(Nnull_string, Node_var, (NODE *)NULL));
- aptr = assoc_lookup(ARGV_node, tmp_number(0.0));
- *aptr = make_string(argv0, strlen(argv0));
- (*aptr)->flags |= MAYBE_NUM;
- for (i = argc0, j = 1; i < argc; i++) {
- aptr = assoc_lookup(ARGV_node, tmp_number((AWKNUM) j));
- *aptr = make_string(argv[i], strlen(argv[i]));
- (*aptr)->flags |= MAYBE_NUM;
- j++;
- }
- ARGC_node = install("ARGC",
- node(make_number((AWKNUM) j), Node_var, (NODE *) NULL));
-}
-
-/*
- * Set all the special variables to their initial values.
- */
-struct varinit {
- NODE **spec;
- char *name;
- NODETYPE type;
- char *strval;
- AWKNUM numval;
- Func_ptr assign;
-};
-static struct varinit varinit[] = {
-{&NF_node, "NF", Node_NF, 0, -1, set_NF },
-{&FIELDWIDTHS_node, "FIELDWIDTHS", Node_FIELDWIDTHS, "", 0, 0 },
-{&NR_node, "NR", Node_NR, 0, 0, set_NR },
-{&FNR_node, "FNR", Node_FNR, 0, 0, set_FNR },
-{&FS_node, "FS", Node_FS, " ", 0, 0 },
-{&RS_node, "RS", Node_RS, "\n", 0, set_RS },
-{&IGNORECASE_node, "IGNORECASE", Node_IGNORECASE, 0, 0, set_IGNORECASE },
-{&FILENAME_node, "FILENAME", Node_var, "-", 0, 0 },
-{&OFS_node, "OFS", Node_OFS, " ", 0, set_OFS },
-{&ORS_node, "ORS", Node_ORS, "\n", 0, set_ORS },
-{&OFMT_node, "OFMT", Node_OFMT, "%.6g", 0, set_OFMT },
-{&CONVFMT_node, "CONVFMT", Node_CONVFMT, "%.6g", 0, set_CONVFMT },
-{&RLENGTH_node, "RLENGTH", Node_var, 0, 0, 0 },
-{&RSTART_node, "RSTART", Node_var, 0, 0, 0 },
-{&SUBSEP_node, "SUBSEP", Node_var, "\034", 0, 0 },
-{&ARGIND_node, "ARGIND", Node_var, 0, 0, 0 },
-{&ERRNO_node, "ERRNO", Node_var, 0, 0, 0 },
-{0, 0, Node_illegal, 0, 0, 0 },
-};
-
-static void
-init_vars()
-{
- register struct varinit *vp;
-
- for (vp = varinit; vp->name; vp++) {
- *(vp->spec) = install(vp->name,
- node(vp->strval == 0 ? make_number(vp->numval)
- : make_string(vp->strval, strlen(vp->strval)),
- vp->type, (NODE *) NULL));
- if (vp->assign)
- (*(vp->assign))();
- }
-}
-
-void
-load_environ()
-{
-#if !defined(MSDOS) && !(defined(VMS) && defined(__DECC))
- extern char **environ;
-#endif
- register char *var, *val;
- NODE **aptr;
- register int i;
-
- ENVIRON_node = install("ENVIRON",
- node(Nnull_string, Node_var, (NODE *) NULL));
- for (i = 0; environ[i]; i++) {
- static char nullstr[] = "";
-
- var = environ[i];
- val = strchr(var, '=');
- if (val)
- *val++ = '\0';
- else
- val = nullstr;
- aptr = assoc_lookup(ENVIRON_node, tmp_string(var, strlen (var)));
- *aptr = make_string(val, strlen (val));
- (*aptr)->flags |= MAYBE_NUM;
-
- /* restore '=' so that system() gets a valid environment */
- if (val != nullstr)
- *--val = '=';
- }
-}
-
-/* Process a command-line assignment */
-char *
-arg_assign(arg)
-char *arg;
-{
- char *cp;
- Func_ptr after_assign = NULL;
- NODE *var;
- NODE *it;
- NODE **lhs;
-
- cp = strchr(arg, '=');
- if (cp != NULL) {
- *cp++ = '\0';
- /*
- * Recent versions of nawk expand escapes inside assignments.
- * This makes sense, so we do it too.
- */
- it = make_str_node(cp, strlen(cp), SCAN);
- it->flags |= MAYBE_NUM;
- var = variable(arg, 0);
- lhs = get_lhs(var, &after_assign);
- unref(*lhs);
- *lhs = it;
- if (after_assign)
- (*after_assign)();
- *--cp = '='; /* restore original text of ARGV */
- }
- return cp;
-}
-
-static void
-pre_assign(v)
-char *v;
-{
- if (!arg_assign(v)) {
- fprintf (stderr,
- "%s: '%s' argument to -v not in 'var=value' form\n",
- myname, v);
- usage(1);
- }
-}
-
-SIGTYPE
-catchsig(sig, code)
-int sig, code;
-{
-#ifdef lint
- code = 0; sig = code; code = sig;
-#endif
- if (sig == SIGFPE) {
- fatal("floating point exception");
- } else if (sig == SIGSEGV
-#ifdef SIGBUS
- || sig == SIGBUS
-#endif
- ) {
- msg("fatal error: internal error");
- /* fatal won't abort() if not compiled for debugging */
- abort();
- } else
- cant_happen();
- /* NOTREACHED */
-}
-
-/* gawk_option --- do gawk specific things */
-
-static void
-gawk_option(optstr)
-char *optstr;
-{
- char *cp;
-
- for (cp = optstr; *cp; cp++) {
- switch (*cp) {
- case ' ':
- case '\t':
- case ',':
- break;
- case 'v':
- case 'V':
- /* print version */
- if (strncasecmp(cp, "version", 7) != 0)
- goto unknown;
- else
- cp += 6;
- version();
- break;
- case 'c':
- case 'C':
- if (strncasecmp(cp, "copyright", 9) == 0) {
- cp += 8;
- copyleft();
- } else if (strncasecmp(cp, "copyleft", 8) == 0) {
- cp += 7;
- copyleft();
- } else if (strncasecmp(cp, "compat", 6) == 0) {
- cp += 5;
- do_unix = 1;
- } else
- goto unknown;
- break;
- case 'n':
- case 'N':
- /*
- * Undocumented feature,
- * inspired by nostalgia, and a T-shirt
- */
- if (strncasecmp(cp, "nostalgia", 9) != 0)
- goto unknown;
- nostalgia();
- break;
- case 'p':
- case 'P':
-#ifdef DEBUG
- if (strncasecmp(cp, "parsedebug", 10) == 0) {
- cp += 9;
- yydebug = 2;
- break;
- }
-#endif
- if (strncasecmp(cp, "posix", 5) != 0)
- goto unknown;
- cp += 4;
- do_posix = do_unix = 1;
- break;
- case 'l':
- case 'L':
- if (strncasecmp(cp, "lint", 4) != 0)
- goto unknown;
- cp += 3;
- do_lint = 1;
- break;
- case 'H':
- case 'h':
- if (strncasecmp(cp, "help", 4) != 0)
- goto unknown;
- cp += 3;
- usage(0);
- break;
- case 'U':
- case 'u':
- if (strncasecmp(cp, "usage", 5) != 0)
- goto unknown;
- cp += 4;
- usage(0);
- break;
- case 's':
- case 'S':
- if (strncasecmp(cp, "source=", 7) != 0)
- goto unknown;
- cp += 7;
- if (strlen(cp) == 0)
- warning("empty argument to -Wsource ignored");
- else {
- srcfiles[++numfiles].stype = CMDLINE;
- srcfiles[numfiles].val = cp;
- return;
- }
- break;
- default:
- unknown:
- fprintf(stderr, "'%c' -- unknown option, ignored\n",
- *cp);
- break;
- }
- }
-}
-
-/* nostalgia --- print the famous error message and die */
-
-static void
-nostalgia()
-{
- fprintf(stderr, "awk: bailing out near line 1\n");
- abort();
-}
-
-/* version --- print version message */
-
-static void
-version()
-{
- fprintf(stderr, "%s, patchlevel %d\n", version_string, PATCHLEVEL);
-}
-
-/* static */
-char *
-gawk_name(filespec)
-char *filespec;
-{
- char *p;
-
-#ifdef VMS /* "device:[root.][directory.subdir]GAWK.EXE;n" -> "GAWK" */
- char *q;
-
- p = strrchr(filespec, ']'); /* directory punctuation */
- q = strrchr(filespec, '>'); /* alternate <international> punct */
-
- if (p == NULL || q > p) p = q;
- p = strdup(p == NULL ? filespec : (p + 1));
- if ((q = strrchr(p, '.')) != NULL) *q = '\0'; /* strip .typ;vers */
-
- return p;
-#endif /*VMS*/
-
-#if defined(MSDOS) || defined(atarist)
- char *q;
-
- p = filespec;
-
- if (q = strrchr(p, '\\'))
- p = q + 1;
- if (q = strchr(p, '.'))
- *q = '\0';
- strlwr(p);
-
- return (p == NULL ? filespec : p);
-#endif /* MSDOS || atarist */
-
- /* "path/name" -> "name" */
- p = strrchr(filespec, '/');
- return (p == NULL ? filespec : p + 1);
-}
diff --git a/gnu/usr.bin/awk/msg.c b/gnu/usr.bin/awk/msg.c
deleted file mode 100644
index b60fe9d..0000000
--- a/gnu/usr.bin/awk/msg.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * msg.c - routines for error messages
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-int sourceline = 0;
-char *source = NULL;
-
-/* VARARGS2 */
-void
-err(s, emsg, argp)
-char *s;
-char *emsg;
-va_list argp;
-{
- char *file;
-
- (void) fflush(stdout);
- (void) fprintf(stderr, "%s: ", myname);
- if (sourceline) {
- if (source)
- (void) fprintf(stderr, "%s:", source);
- else
- (void) fprintf(stderr, "cmd. line:");
-
- (void) fprintf(stderr, "%d: ", sourceline);
- }
- if (FNR) {
- file = FILENAME_node->var_value->stptr;
- if (file)
- (void) fprintf(stderr, "(FILENAME=%s ", file);
- (void) fprintf(stderr, "FNR=%d) ", FNR);
- }
- (void) fprintf(stderr, s);
- vfprintf(stderr, emsg, argp);
- (void) fprintf(stderr, "\n");
- (void) fflush(stderr);
-}
-
-/*VARARGS0*/
-void
-msg(va_alist)
-va_dcl
-{
- va_list args;
- char *mesg;
-
- va_start(args);
- mesg = va_arg(args, char *);
- err("", mesg, args);
- va_end(args);
-}
-
-/*VARARGS0*/
-void
-warning(va_alist)
-va_dcl
-{
- va_list args;
- char *mesg;
-
- va_start(args);
- mesg = va_arg(args, char *);
- err("warning: ", mesg, args);
- va_end(args);
-}
-
-/*VARARGS0*/
-void
-fatal(va_alist)
-va_dcl
-{
- va_list args;
- char *mesg;
-
- va_start(args);
- mesg = va_arg(args, char *);
- err("fatal: ", mesg, args);
- va_end(args);
-#ifdef DEBUG
- abort();
-#endif
- exit(2);
-}
diff --git a/gnu/usr.bin/awk/node.c b/gnu/usr.bin/awk/node.c
deleted file mode 100644
index 65ecb0e..0000000
--- a/gnu/usr.bin/awk/node.c
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * node.c -- routines for node management
- */
-
-/*
- * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-extern double strtod();
-
-AWKNUM
-r_force_number(n)
-register NODE *n;
-{
- register char *cp;
- register char *cpend;
- char save;
- char *ptr;
- unsigned int newflags = 0;
-
-#ifdef DEBUG
- if (n == NULL)
- cant_happen();
- if (n->type != Node_val)
- cant_happen();
- if(n->flags == 0)
- cant_happen();
- if (n->flags & NUM)
- return n->numbr;
-#endif
-
- /* all the conditionals are an attempt to avoid the expensive strtod */
-
- n->numbr = 0.0;
- n->flags |= NUM;
-
- if (n->stlen == 0)
- return 0.0;
-
- cp = n->stptr;
- if (isalpha(*cp))
- return 0.0;
-
- cpend = cp + n->stlen;
- while (cp < cpend && isspace(*cp))
- cp++;
- if (cp == cpend || isalpha(*cp))
- return 0.0;
-
- if (n->flags & MAYBE_NUM) {
- newflags = NUMBER;
- n->flags &= ~MAYBE_NUM;
- }
- if (cpend - cp == 1) {
- if (isdigit(*cp)) {
- n->numbr = (AWKNUM)(*cp - '0');
- n->flags |= newflags;
- }
- return n->numbr;
- }
-
- errno = 0;
- save = *cpend;
- *cpend = '\0';
- n->numbr = (AWKNUM) strtod((const char *)cp, &ptr);
-
- /* POSIX says trailing space is OK for NUMBER */
- while (isspace(*ptr))
- ptr++;
- *cpend = save;
- /* the >= should be ==, but for SunOS 3.5 strtod() */
- if (errno == 0 && ptr >= cpend)
- n->flags |= newflags;
- else
- errno = 0;
-
- return n->numbr;
-}
-
-/*
- * the following lookup table is used as an optimization in force_string
- * (more complicated) variations on this theme didn't seem to pay off, but
- * systematic testing might be in order at some point
- */
-static char *values[] = {
- "0",
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
-};
-#define NVAL (sizeof(values)/sizeof(values[0]))
-
-NODE *
-r_force_string(s)
-register NODE *s;
-{
- char buf[128];
- register char *sp = buf;
- register long num = 0;
-
-#ifdef DEBUG
- if (s == NULL) cant_happen();
- if (s->type != Node_val) cant_happen();
- if (s->flags & STR) return s;
- if (!(s->flags & NUM)) cant_happen();
- if (s->stref != 0) ; /*cant_happen();*/
-#endif
-
- /* avoids floating point exception in DOS*/
- if ( s->numbr <= LONG_MAX && s->numbr >= -LONG_MAX)
- num = (long)s->numbr;
- if ((AWKNUM) num == s->numbr) { /* integral value */
- if (num < NVAL && num >= 0) {
- sp = values[num];
- s->stlen = 1;
- } else {
- (void) sprintf(sp, "%ld", num);
- s->stlen = strlen(sp);
- }
- s->stfmt = -1;
- } else {
- (void) sprintf(sp, CONVFMT, s->numbr);
- s->stlen = strlen(sp);
- s->stfmt = (char)CONVFMTidx;
- }
- s->stref = 1;
- emalloc(s->stptr, char *, s->stlen + 2, "force_string");
- memcpy(s->stptr, sp, s->stlen+1);
- s->flags |= STR;
- return s;
-}
-
-/*
- * Duplicate a node. (For strings, "duplicate" means crank up the
- * reference count.)
- */
-NODE *
-dupnode(n)
-NODE *n;
-{
- register NODE *r;
-
- if (n->flags & TEMP) {
- n->flags &= ~TEMP;
- n->flags |= MALLOC;
- return n;
- }
- if ((n->flags & (MALLOC|STR)) == (MALLOC|STR)) {
- if (n->stref < 255)
- n->stref++;
- return n;
- }
- getnode(r);
- *r = *n;
- r->flags &= ~(PERM|TEMP);
- r->flags |= MALLOC;
- if (n->type == Node_val && (n->flags & STR)) {
- r->stref = 1;
- emalloc(r->stptr, char *, r->stlen + 2, "dupnode");
- memcpy(r->stptr, n->stptr, r->stlen+1);
- }
- return r;
-}
-
-/* this allocates a node with defined numbr */
-NODE *
-mk_number(x, flags)
-AWKNUM x;
-unsigned int flags;
-{
- register NODE *r;
-
- getnode(r);
- r->type = Node_val;
- r->numbr = x;
- r->flags = flags;
-#ifdef DEBUG
- r->stref = 1;
- r->stptr = 0;
- r->stlen = 0;
-#endif
- return r;
-}
-
-/*
- * Make a string node.
- */
-NODE *
-make_str_node(s, len, flags)
-char *s;
-size_t len;
-int flags;
-{
- register NODE *r;
-
- getnode(r);
- r->type = Node_val;
- r->flags = (STRING|STR|MALLOC);
- if (flags & ALREADY_MALLOCED)
- r->stptr = s;
- else {
- emalloc(r->stptr, char *, len + 2, s);
- memcpy(r->stptr, s, len);
- }
- r->stptr[len] = '\0';
-
- if (flags & SCAN) { /* scan for escape sequences */
- char *pf;
- register char *ptm;
- register int c;
- register char *end;
-
- end = &(r->stptr[len]);
- for (pf = ptm = r->stptr; pf < end;) {
- c = *pf++;
- if (c == '\\') {
- c = parse_escape(&pf);
- if (c < 0) {
- if (do_lint)
- warning("backslash at end of string");
- c = '\\';
- }
- *ptm++ = c;
- } else
- *ptm++ = c;
- }
- len = ptm - r->stptr;
- erealloc(r->stptr, char *, len + 1, "make_str_node");
- r->stptr[len] = '\0';
- r->flags |= PERM;
- }
- r->stlen = len;
- r->stref = 1;
- r->stfmt = -1;
-
- return r;
-}
-
-NODE *
-tmp_string(s, len)
-char *s;
-size_t len;
-{
- register NODE *r;
-
- r = make_string(s, len);
- r->flags |= TEMP;
- return r;
-}
-
-
-#define NODECHUNK 100
-
-NODE *nextfree = NULL;
-
-NODE *
-more_nodes()
-{
- register NODE *np;
-
- /* get more nodes and initialize list */
- emalloc(nextfree, NODE *, NODECHUNK * sizeof(NODE), "newnode");
- for (np = nextfree; np < &nextfree[NODECHUNK - 1]; np++)
- np->nextp = np + 1;
- np->nextp = NULL;
- np = nextfree;
- nextfree = nextfree->nextp;
- return np;
-}
-
-#ifdef DEBUG
-void
-freenode(it)
-NODE *it;
-{
-#ifdef MPROF
- it->stref = 0;
- free((char *) it);
-#else /* not MPROF */
- /* add it to head of freelist */
- it->nextp = nextfree;
- nextfree = it;
-#endif /* not MPROF */
-}
-#endif /* DEBUG */
-
-void
-unref(tmp)
-register NODE *tmp;
-{
- if (tmp == NULL)
- return;
- if (tmp->flags & PERM)
- return;
- if (tmp->flags & (MALLOC|TEMP)) {
- tmp->flags &= ~TEMP;
- if (tmp->flags & STR) {
- if (tmp->stref > 1) {
- if (tmp->stref != 255)
- tmp->stref--;
- return;
- }
- free(tmp->stptr);
- }
- freenode(tmp);
- }
-}
-
-/*
- * Parse a C escape sequence. STRING_PTR points to a variable containing a
- * pointer to the string to parse. That pointer is updated past the
- * characters we use. The value of the escape sequence is returned.
- *
- * A negative value means the sequence \ newline was seen, which is supposed to
- * be equivalent to nothing at all.
- *
- * If \ is followed by a null character, we return a negative value and leave
- * the string pointer pointing at the null character.
- *
- * If \ is followed by 000, we return 0 and leave the string pointer after the
- * zeros. A value of 0 does not mean end of string.
- *
- * Posix doesn't allow \x.
- */
-
-int
-parse_escape(string_ptr)
-char **string_ptr;
-{
- register int c = *(*string_ptr)++;
- register int i;
- register int count;
-
- switch (c) {
- case 'a':
- return BELL;
- case 'b':
- return '\b';
- case 'f':
- return '\f';
- case 'n':
- return '\n';
- case 'r':
- return '\r';
- case 't':
- return '\t';
- case 'v':
- return '\v';
- case '\n':
- return -2;
- case 0:
- (*string_ptr)--;
- return -1;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- i = c - '0';
- count = 0;
- while (++count < 3) {
- if ((c = *(*string_ptr)++) >= '0' && c <= '7') {
- i *= 8;
- i += c - '0';
- } else {
- (*string_ptr)--;
- break;
- }
- }
- return i;
- case 'x':
- if (do_lint) {
- static int didwarn;
-
- if (! didwarn) {
- didwarn = 1;
- warning("Posix does not allow \"\\x\" escapes");
- }
- }
- if (do_posix)
- return ('x');
- i = 0;
- while (1) {
- if (isxdigit((c = *(*string_ptr)++))) {
- i *= 16;
- if (isdigit(c))
- i += c - '0';
- else if (isupper(c))
- i += c - 'A' + 10;
- else
- i += c - 'a' + 10;
- } else {
- (*string_ptr)--;
- break;
- }
- }
- return i;
- default:
- return c;
- }
-}
diff --git a/gnu/usr.bin/awk/patchlevel.h b/gnu/usr.bin/awk/patchlevel.h
deleted file mode 100644
index c6161a1..0000000
--- a/gnu/usr.bin/awk/patchlevel.h
+++ /dev/null
@@ -1 +0,0 @@
-#define PATCHLEVEL 2
diff --git a/gnu/usr.bin/awk/protos.h b/gnu/usr.bin/awk/protos.h
deleted file mode 100644
index 25af321..0000000
--- a/gnu/usr.bin/awk/protos.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * protos.h -- function prototypes for when the headers don't have them.
- */
-
-/*
- * Copyright (C) 1991, 1992, the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifdef __STDC__
-#define aptr_t void * /* arbitrary pointer type */
-#else
-#define aptr_t char *
-#endif
-extern aptr_t malloc P((MALLOC_ARG_T));
-extern aptr_t realloc P((aptr_t, MALLOC_ARG_T));
-extern aptr_t calloc P((MALLOC_ARG_T, MALLOC_ARG_T));
-
-extern void free P((aptr_t));
-extern char *getenv P((char *));
-
-extern char *strcpy P((char *, const char *));
-extern char *strcat P((char *, const char *));
-extern char *strncpy P((char *, const char *, int));
-extern int strcmp P((const char *, const char *));
-extern int strncmp P((const char *, const char *, int));
-#ifndef VMS
-extern char *strerror P((int));
-#else
-extern char *strerror P((int,...));
-#endif
-extern char *strchr P((const char *, int));
-extern char *strrchr P((const char *, int));
-extern char *strstr P((const char *s1, const char *s2));
-extern int strlen P((const char *));
-extern long strtol P((const char *, char **, int));
-#if !defined(_MSC_VER) && !defined(__GNU_LIBRARY__)
-extern int strftime P((char *, int, const char *, const struct tm *));
-#endif
-extern time_t time P((time_t *));
-extern aptr_t memset P((aptr_t, int, size_t));
-extern aptr_t memcpy P((aptr_t, const aptr_t, size_t));
-extern aptr_t memmove P((aptr_t, const aptr_t, size_t));
-extern aptr_t memchr P((const aptr_t, int, size_t));
-extern int memcmp P((const aptr_t, const aptr_t, size_t));
-
-/* extern int fprintf P((FILE *, char *, ...)); */
-extern int fprintf P(());
-#if !defined(MSDOS) && !defined(__GNU_LIBRARY__)
-extern int fwrite P((const char *, int, int, FILE *));
-extern int fputs P((const char *, FILE *));
-extern int unlink P((const char *));
-#endif
-extern int fflush P((FILE *));
-extern int fclose P((FILE *));
-extern FILE *popen P((const char *, const char *));
-extern int pclose P((FILE *));
-extern void abort P(());
-extern int isatty P((int));
-extern void exit P((int));
-extern int system P((const char *));
-extern int sscanf P((/* char *, char *, ... */));
-#ifndef toupper
-extern int toupper P((int));
-#endif
-#ifndef tolower
-extern int tolower P((int));
-#endif
-
-extern double pow P((double x, double y));
-extern double atof P((char *));
-extern double strtod P((const char *, char **));
-extern int fstat P((int, struct stat *));
-extern int stat P((const char *, struct stat *));
-extern off_t lseek P((int, off_t, int));
-extern int fseek P((FILE *, long, int));
-extern int close P((int));
-extern int creat P(());
-extern int open P(());
-extern int pipe P((int *));
-extern int dup P((int));
-extern int dup2 P((int,int));
-extern int fork P(());
-extern int execl P((/* char *, char *, ... */));
-extern int read P((int, char *, int));
-extern int wait P((int *));
-extern void _exit P((int));
-
-#ifndef __STDC__
-extern long time P((long *));
-#endif
-
-#ifdef NON_STD_SPRINTF
-extern char *sprintf();
-#else
-extern int sprintf();
-#endif /* SPRINTF_INT */
-
-#undef aptr_t
diff --git a/gnu/usr.bin/awk/re.c b/gnu/usr.bin/awk/re.c
deleted file mode 100644
index 495b096..0000000
--- a/gnu/usr.bin/awk/re.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * re.c - compile regular expressions.
- */
-
-/*
- * Copyright (C) 1991, 1992 the Free Software Foundation, Inc.
- *
- * This file is part of GAWK, the GNU implementation of the
- * AWK Progamming Language.
- *
- * GAWK is free software; you can redistribute 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.
- *
- * GAWK is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GAWK; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "awk.h"
-
-/* Generate compiled regular expressions */
-
-Regexp *
-make_regexp(s, len, ignorecase, dfa)
-char *s;
-int len;
-int ignorecase;
-int dfa;
-{
- Regexp *rp;
- char *err;
- char *src = s;
- char *temp;
- char *end = s + len;
- register char *dest;
- register int c;
-
- /* Handle escaped characters first. */
-
- /* Build a copy of the string (in dest) with the
- escaped characters translated, and generate the regex
- from that.
- */
- emalloc(dest, char *, len + 2, "make_regexp");
- temp = dest;
-
- while (src < end) {
- if (*src == '\\') {
- c = *++src;
- switch (c) {
- case 'a':
- case 'b':
- case 'f':
- case 'n':
- case 'r':
- case 't':
- case 'v':
- case 'x':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- c = parse_escape(&src);
- if (c < 0)
- cant_happen();
- *dest++ = (char)c;
- break;
- default:
- *dest++ = '\\';
- *dest++ = (char)c;
- src++;
- break;
- } /* switch */
- } else {
- *dest++ = *src++; /* not '\\' */
- }
- } /* for */
-
- *dest = '\0' ; /* Only necessary if we print dest ? */
- emalloc(rp, Regexp *, sizeof(*rp), "make_regexp");
- memset((char *) rp, 0, sizeof(*rp));
- emalloc(rp->pat.buffer, char *, 16, "make_regexp");
- rp->pat.allocated = 16;
- emalloc(rp->pat.fastmap, char *, 256, "make_regexp");
-
- if (ignorecase)
- rp->pat.translate = casetable;
- else
- rp->pat.translate = NULL;
- len = dest - temp;
- if ((err = re_compile_pattern(temp, (size_t) len, &(rp->pat))) != NULL)
- fatal("%s: /%s/", err, temp);
- if (dfa && !ignorecase) {
- regcompile(temp, len, &(rp->dfareg), 1);
- rp->dfa = 1;
- } else
- rp->dfa = 0;
- free(temp);
- return rp;
-}
-
-int
-research(rp, str, start, len, need_start)
-Regexp *rp;
-register char *str;
-int start;
-register int len;
-int need_start;
-{
- char *ret = str;
-
- if (rp->dfa) {
- char save1;
- char save2;
- int count = 0;
- int try_backref;
-
- save1 = str[start+len];
- str[start+len] = '\n';
- save2 = str[start+len+1];
- ret = regexecute(&(rp->dfareg), str+start, str+start+len+1, 1,
- &count, &try_backref);
- str[start+len] = save1;
- str[start+len+1] = save2;
- }
- if (ret) {
- if (need_start || rp->dfa == 0)
- return re_search(&(rp->pat), str, start+len, start,
- len, &(rp->regs));
- else
- return 1;
- } else
- return -1;
-}
-
-void
-refree(rp)
-Regexp *rp;
-{
- free(rp->pat.buffer);
- free(rp->pat.fastmap);
- if (rp->dfa)
- reg_free(&(rp->dfareg));
- free(rp);
-}
-
-void
-reg_error(s)
-const char *s;
-{
- fatal(s);
-}
-
-Regexp *
-re_update(t)
-NODE *t;
-{
- NODE *t1;
-
-# define CASE 1
- if ((t->re_flags & CASE) == IGNORECASE) {
- if (t->re_flags & CONST)
- return t->re_reg;
- t1 = force_string(tree_eval(t->re_exp));
- if (t->re_text) {
- if (cmp_nodes(t->re_text, t1) == 0) {
- free_temp(t1);
- return t->re_reg;
- }
- unref(t->re_text);
- }
- t->re_text = dupnode(t1);
- free_temp(t1);
- }
- if (t->re_reg)
- refree(t->re_reg);
- if (t->re_cnt)
- t->re_cnt++;
- if (t->re_cnt > 10)
- t->re_cnt = 0;
- if (!t->re_text) {
- t1 = force_string(tree_eval(t->re_exp));
- t->re_text = dupnode(t1);
- free_temp(t1);
- }
- t->re_reg = make_regexp(t->re_text->stptr, t->re_text->stlen, IGNORECASE, t->re_cnt);
- t->re_flags &= ~CASE;
- t->re_flags |= IGNORECASE;
- return t->re_reg;
-}
-
-void
-resetup()
-{
- (void) re_set_syntax(RE_SYNTAX_AWK);
- regsyntax(RE_SYNTAX_AWK, 0);
-}
diff --git a/gnu/usr.bin/awk/regex.c b/gnu/usr.bin/awk/regex.c
deleted file mode 100644
index f4dd4c2..0000000
--- a/gnu/usr.bin/awk/regex.c
+++ /dev/null
@@ -1,2854 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 1985, 1989-90 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 test, compile with -Dtest. This Dtestable feature turns this into
- a self-contained program which reads a pattern, describes how it
- compiles, then reads a string and searches for it.
-
- On the other hand, if you compile with both -Dtest and -Dcanned you
- can run some tests we've already thought of. */
-
-
-#ifdef emacs
-
-/* The `emacs' switch turns on certain special matching commands
- that make sense only in emacs. */
-
-#include "lisp.h"
-#include "buffer.h"
-#include "syntax.h"
-
-/* We write fatal error messages on standard error. */
-#include <stdio.h>
-
-/* isalpha(3) etc. are used for the character classes. */
-#include <ctype.h>
-
-#else /* not emacs */
-
-#include "awk.h"
-
-#define NO_ALLOCA /* try it out for now */
-#ifndef NO_ALLOCA
-/* Make alloca work the best possible way. */
-#ifdef __GNUC__
-#ifndef atarist
-#ifndef alloca
-#define alloca __builtin_alloca
-#endif
-#endif /* atarist */
-#else
-#if defined(sparc) && !defined(__GNUC__)
-#include <alloca.h>
-#else
-char *alloca ();
-#endif
-#endif /* __GNUC__ */
-
-#define FREE_AND_RETURN_VOID(stackb) return
-#define FREE_AND_RETURN(stackb,val) return(val)
-#define DOUBLE_STACK(stackx,stackb,len) \
- (stackx = (unsigned char **) alloca (2 * len \
- * sizeof (unsigned char *)),\
- /* Only copy what is in use. */ \
- (unsigned char **) memcpy (stackx, stackb, len * sizeof (char *)))
-#else /* NO_ALLOCA defined */
-#define FREE_AND_RETURN_VOID(stackb) free(stackb);return
-#define FREE_AND_RETURN(stackb,val) free(stackb);return(val)
-#define DOUBLE_STACK(stackx,stackb,len) \
- (unsigned char **) realloc (stackb, 2 * len * sizeof (unsigned char *))
-#endif /* NO_ALLOCA */
-
-static void store_jump P((char *, int, char *));
-static void insert_jump P((int, char *, char *, char *));
-static void store_jump_n P((char *, int, char *, unsigned));
-static void insert_jump_n P((int, char *, char *, char *, unsigned));
-static void insert_op_2 P((int, char *, char *, int, int ));
-static int memcmp_translate P((unsigned char *, unsigned char *,
- int, unsigned char *));
-long re_set_syntax P((long));
-
-/* Define the syntax stuff, so we can do the \<, \>, etc. */
-
-/* This must be nonzero for the wordchar and notwordchar pattern
- commands in re_match_2. */
-#ifndef Sword
-#define Sword 1
-#endif
-
-#define SYNTAX(c) re_syntax_table[c]
-
-
-#ifdef SYNTAX_TABLE
-
-char *re_syntax_table;
-
-#else /* not SYNTAX_TABLE */
-
-static char re_syntax_table[256];
-static void init_syntax_once P((void));
-
-
-static void
-init_syntax_once ()
-{
- register int c;
- static int done = 0;
-
- if (done)
- return;
-
- memset (re_syntax_table, 0, 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;
-
- /* Add specific syntax for ISO Latin-1. */
- for (c = 0300; c <= 0377; c++)
- re_syntax_table[c] = Sword;
- re_syntax_table[0327] = 0;
- re_syntax_table[0367] = 0;
-
- done = 1;
-}
-
-#endif /* SYNTAX_TABLE */
-#undef P
-#endif /* emacs */
-
-
-/* Sequents are missing isgraph. */
-#ifndef isgraph
-#define isgraph(c) (isprint((c)) && !isspace((c)))
-#endif
-
-/* Get the interface, including the syntax bits. */
-#include "regex.h"
-
-
-/* These are the command codes that appear in compiled regular
- expressions, one per byte. Some command codes 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. */
-
-enum regexpcode
- {
- unused=0,
- exactn=1, /* Followed by one byte giving n, then by n literal bytes. */
- begline, /* Fail unless at beginning of line. */
- endline, /* Fail unless at end of line. */
- jump, /* Followed by two bytes giving relative address to jump to. */
- on_failure_jump, /* Followed by two bytes giving relative address of
- place to resume at in case of failure. */
- finalize_jump, /* Throw away latest failure point and then jump to
- address. */
- maybe_finalize_jump, /* Like jump but finalize if safe to do so.
- This is used to jump back to the beginning
- of a repeat. If the command that follows
- this jump is clearly incompatible with the
- one at the beginning of the repeat, such that
- we can be sure that there is no use backtracking
- out of repetitions already completed,
- then we finalize. */
- dummy_failure_jump, /* Jump, 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
- use it as an intermediary kind of jump when
- compiling an or construct. */
- succeed_n, /* Used like on_failure_jump except has to succeed n times;
- then gets turned into an on_failure_jump. The relative
- address following it is useless until then. The
- address is followed by two bytes containing n. */
- jump_n, /* Similar to jump, but jump n times only; also the relative
- address following is in turn followed by yet two more bytes
- containing n. */
- set_number_at, /* Set the following relative location to the
- subsequent number. */
- anychar, /* Matches any (more or less) one character. */
- charset, /* 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_not, /* Same parameters as charset, but match any character
- that is not one of those specified. */
- start_memory, /* Start remembering the text that is matched, for
- storing in a memory register. Followed by one
- byte containing the register number. Register numbers
- must be in the range 0 through RE_NREGS. */
- stop_memory, /* Stop remembering the text that is matched
- and store it in a memory register. Followed by
- one byte containing the register number. Register
- numbers must be in the range 0 through RE_NREGS. */
- duplicate, /* Match a duplicate of something remembered.
- Followed by one byte containing the index of the memory
- register. */
- before_dot, /* Succeeds if before point. */
- at_dot, /* Succeeds if at point. */
- after_dot, /* Succeeds if after point. */
- begbuf, /* Succeeds if at beginning of buffer. */
- endbuf, /* Succeeds if at end of buffer. */
- 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. */
- syntaxspec, /* Matches any character whose syntax is specified.
- followed by a byte which contains a syntax code,
- e.g., Sword. */
- notsyntaxspec /* Matches any character whose syntax differs from
- that specified. */
- };
-
-
-/* Number of failure points to allocate space for initially,
- when matching. If this number is exceeded, more space is allocated,
- so it is not a hard limit. */
-
-#ifndef NFAILURES
-#define NFAILURES 80
-#endif
-
-#ifdef CHAR_UNSIGNED
-#define SIGN_EXTEND_CHAR(c) ((c)>(char)127?(c)-256:(c)) /* for IBM RT */
-#endif
-#ifndef SIGN_EXTEND_CHAR
-#define SIGN_EXTEND_CHAR(x) (x)
-#endif
-
-
-/* Store NUMBER in two contiguous bytes starting at DESTINATION. */
-#define STORE_NUMBER(destination, number) \
- { (destination)[0] = (number) & 0377; \
- (destination)[1] = (number) >> 8; }
-
-/* Same as STORE_NUMBER, except increment the destination pointer to
- the byte after where the number is stored. Watch out that values for
- DESTINATION such as p + 1 won't work, whereas p will. */
-#define STORE_NUMBER_AND_INCR(destination, number) \
- { STORE_NUMBER(destination, number); \
- (destination) += 2; }
-
-
-/* Put into DESTINATION a number stored in two contingous bytes starting
- at SOURCE. */
-#define EXTRACT_NUMBER(destination, source) \
- { (destination) = *(source) & 0377; \
- (destination) += SIGN_EXTEND_CHAR (*(char *)((source) + 1)) << 8; }
-
-/* Same as EXTRACT_NUMBER, except increment the pointer for source to
- point to second byte of SOURCE. Note that SOURCE has to be a value
- such as p, not, e.g., p + 1. */
-#define EXTRACT_NUMBER_AND_INCR(destination, source) \
- { EXTRACT_NUMBER (destination, source); \
- (source) += 2; }
-
-
-/* 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. */
-
-long
-re_set_syntax (syntax)
- long syntax;
-{
- long ret;
-
- ret = obscure_syntax;
- obscure_syntax = syntax;
- return ret;
-}
-
-/* Set by re_set_syntax to the current regexp syntax to recognize. */
-long obscure_syntax = 0;
-
-
-
-/* Macros for re_compile_pattern, which is found below these definitions. */
-
-#define CHAR_CLASS_MAX_LENGTH 6
-
-/* Fetch the next character in the uncompiled pattern, translating it if
- necessary. */
-#define PATFETCH(c) \
- {if (p == pend) goto end_of_pattern; \
- c = * (unsigned char *) p++; \
- if (translate) c = translate[c]; }
-
-/* Fetch the next character in the uncompiled pattern, with no
- translation. */
-#define PATFETCH_RAW(c) \
- {if (p == pend) goto end_of_pattern; \
- c = * (unsigned char *) p++; }
-
-#define PATUNFETCH p--
-
-
-/* If the buffer isn't allocated when it comes in, use this. */
-#define INIT_BUF_SIZE 28
-
-/* 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 CH to it. */
-#define BUFPUSH(ch) \
- { \
- GET_BUFFER_SPACE (1); \
- *b++ = (char) (ch); \
- }
-
-/* Extend the buffer by twice its current size via reallociation and
- reset the pointers that pointed into the old allocation to point to
- the correct places in the new allocation. If extending the buffer
- results in it being larger than 1 << 16, then flag memory exhausted. */
-#define EXTEND_BUFFER \
- { char *old_buffer = bufp->buffer; \
- if (bufp->allocated == (1L<<16)) goto too_big; \
- bufp->allocated *= 2; \
- if (bufp->allocated > (1L<<16)) bufp->allocated = (1L<<16); \
- bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated); \
- if (bufp->buffer == 0) \
- goto memory_exhausted; \
- b = (b - old_buffer) + bufp->buffer; \
- if (fixup_jump) \
- fixup_jump = (fixup_jump - old_buffer) + bufp->buffer; \
- if (laststart) \
- laststart = (laststart - old_buffer) + bufp->buffer; \
- begalt = (begalt - old_buffer) + bufp->buffer; \
- if (pending_exact) \
- pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
- }
-
-/* Set the bit for character C in a character set list. */
-#define SET_LIST_BIT(c) (b[(c) / BYTEWIDTH] |= 1 << ((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); \
- } \
- } \
- }
-
-/* Subroutines for re_compile_pattern. */
-/* static void store_jump (), insert_jump (), store_jump_n (),
- insert_jump_n (), insert_op_2 (); */
-
-
-/* re_compile_pattern takes a regular-expression string
- and converts it into a buffer full of byte commands for matching.
-
- PATTERN is the address of the pattern string
- SIZE is the length of it.
- BUFP is a struct re_pattern_buffer * which points to the info
- on where to store the byte commands.
- This structure contains a char * which points to the
- actual space, which should have been obtained with malloc.
- re_compile_pattern may use realloc to grow the buffer space.
-
- The number of bytes of commands can be found out by looking in
- the `struct re_pattern_buffer' that bufp pointed to, after
- re_compile_pattern returns. */
-
-char *
-re_compile_pattern (pattern, size, bufp)
- char *pattern;
- size_t size;
- struct re_pattern_buffer *bufp;
-{
- register char *b = bufp->buffer;
- register char *p = pattern;
- char *pend = pattern + size;
- register unsigned c, c1;
- char *p0;
- unsigned char *translate = (unsigned char *) bufp->translate;
-
- /* Address of the count-byte of the most recently inserted `exactn'
- command. This makes it possible to tell whether a new exact-match
- character can be added to that command or requires a new `exactn'
- command. */
-
- char *pending_exact = 0;
-
- /* 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. */
-
- char *fixup_jump = 0;
-
- /* Address of start of the most recently finished expression.
- This tells postfix * where to find the start of its operand. */
-
- char *laststart = 0;
-
- /* In processing a repeat, 1 means zero matches is allowed. */
-
- char zero_times_ok;
-
- /* In processing a repeat, 1 means many matches is allowed. */
-
- char many_times_ok;
-
- /* Address of beginning of regexp, or inside of last \(. */
-
- char *begalt = b;
-
- /* In processing an interval, at least this many matches must be made. */
- int lower_bound;
-
- /* In processing an interval, at most this many matches can be made. */
- int upper_bound;
-
- /* Place in pattern (i.e., the {) to which to go back if the interval
- is invalid. */
- char *beg_interval = 0;
-
- /* Stack of information saved by \( and restored by \).
- Four stack elements are pushed by each \(:
- First, the value of b.
- Second, the value of fixup_jump.
- Third, the value of regnum.
- Fourth, the value of begalt. */
-
- int stackb[40];
- int *stackp = stackb;
- int *stacke = stackb + 40;
- int *stackt;
-
- /* Counts \('s as they are encountered. Remembered for the matching \),
- where it becomes the register number to put in the stop_memory
- command. */
-
- int regnum = 1;
-
- bufp->fastmap_accurate = 0;
-
-#ifndef emacs
-#ifndef SYNTAX_TABLE
- /* Initialize the syntax table. */
- init_syntax_once();
-#endif
-#endif
-
- if (bufp->allocated == 0)
- {
- bufp->allocated = INIT_BUF_SIZE;
- if (bufp->buffer)
- /* EXTEND_BUFFER loses when bufp->allocated is 0. */
- bufp->buffer = (char *) realloc (bufp->buffer, INIT_BUF_SIZE);
- else
- /* Caller did not allocate a buffer. Do it for them. */
- bufp->buffer = (char *) malloc (INIT_BUF_SIZE);
- if (!bufp->buffer) goto memory_exhausted;
- begalt = b = bufp->buffer;
- }
-
- while (p != pend)
- {
- PATFETCH (c);
-
- switch (c)
- {
- case '$':
- {
- char *p1 = p;
- /* When testing what follows the $,
- look past the \-constructs that don't consume anything. */
- if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- while (p1 != pend)
- {
- if (*p1 == '\\' && p1 + 1 != pend
- && (p1[1] == '<' || p1[1] == '>'
- || p1[1] == '`' || p1[1] == '\''
-#ifdef emacs
- || p1[1] == '='
-#endif
- || p1[1] == 'b' || p1[1] == 'B'))
- p1 += 2;
- else
- break;
- }
- if (obscure_syntax & RE_TIGHT_VBAR)
- {
- if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS) && p1 != pend)
- goto normal_char;
- /* Make operand of last vbar end before this `$'. */
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
- fixup_jump = 0;
- BUFPUSH (endline);
- break;
- }
- /* $ means succeed if at end of line, but only in special contexts.
- If validly in the middle of a pattern, it is a normal character. */
-
- if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) && p1 != pend)
- goto invalid_pattern;
- if (p1 == pend || *p1 == '\n'
- || (obscure_syntax & RE_CONTEXT_INDEP_OPS)
- || (obscure_syntax & RE_NO_BK_PARENS
- ? *p1 == ')'
- : *p1 == '\\' && p1[1] == ')')
- || (obscure_syntax & RE_NO_BK_VBAR
- ? *p1 == '|'
- : *p1 == '\\' && p1[1] == '|'))
- {
- BUFPUSH (endline);
- break;
- }
- goto normal_char;
- }
- case '^':
- /* ^ means succeed if at beg of line, but only if no preceding
- pattern. */
-
- if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) && laststart)
- goto invalid_pattern;
- if (laststart && p - 2 >= pattern && p[-2] != '\n'
- && !(obscure_syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- if (obscure_syntax & RE_TIGHT_VBAR)
- {
- if (p != pattern + 1
- && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- BUFPUSH (begline);
- begalt = b;
- }
- else
- BUFPUSH (begline);
- break;
-
- case '+':
- case '?':
- if ((obscure_syntax & RE_BK_PLUS_QM)
- || (obscure_syntax & RE_LIMITED_OPS))
- goto normal_char;
- handle_plus:
- case '*':
- /* If there is no previous pattern, char not special. */
- if (!laststart)
- {
- if (obscure_syntax & RE_CONTEXTUAL_INVALID_OPS)
- goto invalid_pattern;
- else if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- }
- /* If there is a sequence of repetition chars,
- collapse it down to just one. */
- zero_times_ok = 0;
- many_times_ok = 0;
- while (1)
- {
- zero_times_ok |= c != '+';
- many_times_ok |= c != '?';
- if (p == pend)
- break;
- PATFETCH (c);
- if (c == '*')
- ;
- else if (!(obscure_syntax & RE_BK_PLUS_QM)
- && (c == '+' || c == '?'))
- ;
- else if ((obscure_syntax & RE_BK_PLUS_QM)
- && c == '\\')
- {
- /* int c1; */
- PATFETCH (c1);
- if (!(c1 == '+' || c1 == '?'))
- {
- PATUNFETCH;
- PATUNFETCH;
- break;
- }
- c = c1;
- }
- else
- {
- PATUNFETCH;
- break;
- }
- }
-
- /* 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)
- {
- /* If more than one repetition is allowed, 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). */
- GET_BUFFER_SPACE (3);
- store_jump (b, maybe_finalize_jump, laststart - 3);
- b += 3; /* Because store_jump put stuff here. */
- }
- /* 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 (on_failure_jump, laststart, b + 3, b);
- pending_exact = 0;
- b += 3;
- if (!zero_times_ok)
- {
- /* At least one repetition is required, so insert a
- dummy-failure 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 (6);
- insert_jump (dummy_failure_jump, laststart, laststart + 6, b);
- b += 3;
- }
- break;
-
- case '.':
- laststart = b;
- BUFPUSH (anychar);
- break;
-
- case '[':
- if (p == pend)
- goto invalid_pattern;
- while (b - bufp->buffer
- > bufp->allocated - 3 - (1 << BYTEWIDTH) / BYTEWIDTH)
- EXTEND_BUFFER;
-
- laststart = b;
- if (*p == '^')
- {
- BUFPUSH (charset_not);
- p++;
- }
- else
- BUFPUSH (charset);
- p0 = p;
-
- BUFPUSH ((1 << BYTEWIDTH) / BYTEWIDTH);
- /* Clear the whole map */
- memset (b, 0, (1 << BYTEWIDTH) / BYTEWIDTH);
-
- if ((obscure_syntax & RE_HAT_NOT_NEWLINE) && b[-2] == charset_not)
- SET_LIST_BIT ('\n');
-
-
- /* Read in characters and ranges, setting map bits. */
- while (1)
- {
- /* Don't translate while fetching, in case it's a range bound.
- When we set the bit for the character, we translate it. */
- PATFETCH_RAW (c);
-
- /* If set, \ escapes characters when inside [...]. */
- if ((obscure_syntax & RE_AWK_CLASS_HACK) && c == '\\')
- {
- PATFETCH(c1);
- SET_LIST_BIT (c1);
- continue;
- }
- if (c == ']')
- {
- if (p == p0 + 1)
- {
- /* If this is an empty bracket expression. */
- if ((obscure_syntax & RE_NO_EMPTY_BRACKETS)
- && p == pend)
- goto invalid_pattern;
- }
- else
- /* Stop if this isn't merely a ] inside a bracket
- expression, but rather the end of a bracket
- expression. */
- break;
- }
- /* Get a range. */
- if (p[0] == '-' && p[1] != ']')
- {
- PATFETCH (c1);
- /* Don't translate the range bounds while fetching them. */
- PATFETCH_RAW (c1);
-
- if ((obscure_syntax & RE_NO_EMPTY_RANGES) && c > c1)
- goto invalid_pattern;
-
- if ((obscure_syntax & RE_NO_HYPHEN_RANGE_END)
- && c1 == '-' && *p != ']')
- goto invalid_pattern;
-
- while (c <= c1)
- {
- /* Translate each char that's in the range. */
- if (translate)
- SET_LIST_BIT (translate[c]);
- else
- SET_LIST_BIT (c);
- c++;
- }
- }
- else if ((obscure_syntax & RE_CHAR_CLASSES)
- && c == '[' && p[0] == ':')
- {
- /* Longest valid character class word has six characters. */
- char str[CHAR_CLASS_MAX_LENGTH];
- PATFETCH (c);
- c1 = 0;
- /* If no ] at end. */
- if (p == pend)
- goto invalid_pattern;
- while (1)
- {
- /* Don't translate the ``character class'' characters. */
- PATFETCH_RAW (c);
- if (c == ':' || c == ']' || p == pend
- || c1 == CHAR_CLASS_MAX_LENGTH)
- break;
- str[c1++] = c;
- }
- str[c1] = '\0';
- if (p == pend
- || c == ']' /* End of the bracket expression. */
- || p[0] != ']'
- || p + 1 == pend
- || (strcmp (str, "alpha") != 0
- && strcmp (str, "upper") != 0
- && strcmp (str, "lower") != 0
- && strcmp (str, "digit") != 0
- && strcmp (str, "alnum") != 0
- && strcmp (str, "xdigit") != 0
- && strcmp (str, "space") != 0
- && strcmp (str, "print") != 0
- && strcmp (str, "punct") != 0
- && strcmp (str, "graph") != 0
- && strcmp (str, "cntrl") != 0))
- {
- /* Undo the ending character, the letters, and leave
- the leading : and [ (but set bits for them). */
- c1++;
- while (c1--)
- PATUNFETCH;
- SET_LIST_BIT ('[');
- SET_LIST_BIT (':');
- }
- else
- {
- /* The ] at the end of the character class. */
- PATFETCH (c);
- if (c != ']')
- goto invalid_pattern;
- for (c = 0; c < (1 << BYTEWIDTH); c++)
- {
- if ((strcmp (str, "alpha") == 0 && isalpha (c))
- || (strcmp (str, "upper") == 0 && isupper (c))
- || (strcmp (str, "lower") == 0 && islower (c))
- || (strcmp (str, "digit") == 0 && isdigit (c))
- || (strcmp (str, "alnum") == 0 && isalnum (c))
- || (strcmp (str, "xdigit") == 0 && isxdigit (c))
- || (strcmp (str, "space") == 0 && isspace (c))
- || (strcmp (str, "print") == 0 && isprint (c))
- || (strcmp (str, "punct") == 0 && ispunct (c))
- || (strcmp (str, "graph") == 0 && isgraph (c))
- || (strcmp (str, "cntrl") == 0 && iscntrl (c)))
- SET_LIST_BIT (c);
- }
- }
- }
- else if (translate)
- SET_LIST_BIT (translate[c]);
- else
- SET_LIST_BIT (c);
- }
-
- /* Discard any character set/class bitmap bytes that are all
- 0 at the end of the map. Decrement the map-length byte too. */
- while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
- b[-1]--;
- b += b[-1];
- break;
-
- case '(':
- if (! (obscure_syntax & RE_NO_BK_PARENS))
- goto normal_char;
- else
- goto handle_open;
-
- case ')':
- if (! (obscure_syntax & RE_NO_BK_PARENS))
- goto normal_char;
- else
- goto handle_close;
-
- case '\n':
- if (! (obscure_syntax & RE_NEWLINE_OR))
- goto normal_char;
- else
- goto handle_bar;
-
- case '|':
- if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS)
- && (! laststart || p == pend))
- goto invalid_pattern;
- else if (! (obscure_syntax & RE_NO_BK_VBAR))
- goto normal_char;
- else
- goto handle_bar;
-
- case '{':
- if (! ((obscure_syntax & RE_NO_BK_CURLY_BRACES)
- && (obscure_syntax & RE_INTERVALS)))
- goto normal_char;
- else
- goto handle_interval;
-
- case '\\':
- if (p == pend) goto invalid_pattern;
- PATFETCH_RAW (c);
- switch (c)
- {
- case '(':
- if (obscure_syntax & RE_NO_BK_PARENS)
- goto normal_backsl;
- handle_open:
- if (stackp == stacke) goto nesting_too_deep;
-
- /* Laststart should point to the start_memory that we are about
- to push (unless the pattern has RE_NREGS or more ('s). */
- *stackp++ = b - bufp->buffer;
- if (regnum < RE_NREGS)
- {
- BUFPUSH (start_memory);
- BUFPUSH (regnum);
- }
- *stackp++ = fixup_jump ? fixup_jump - bufp->buffer + 1 : 0;
- *stackp++ = regnum++;
- *stackp++ = begalt - bufp->buffer;
- fixup_jump = 0;
- laststart = 0;
- begalt = b;
- break;
-
- case ')':
- if (obscure_syntax & RE_NO_BK_PARENS)
- goto normal_backsl;
- handle_close:
- if (stackp == stackb) goto unmatched_close;
- begalt = *--stackp + bufp->buffer;
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
- if (stackp[-1] < RE_NREGS)
- {
- BUFPUSH (stop_memory);
- BUFPUSH (stackp[-1]);
- }
- stackp -= 2;
- fixup_jump = *stackp ? *stackp + bufp->buffer - 1 : 0;
- laststart = *--stackp + bufp->buffer;
- break;
-
- case '|':
- if ((obscure_syntax & RE_LIMITED_OPS)
- || (obscure_syntax & RE_NO_BK_VBAR))
- goto normal_backsl;
- handle_bar:
- if (obscure_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 (6);
- insert_jump (on_failure_jump, begalt, b + 6, b);
- pending_exact = 0;
- b += 3;
- /* The alternative before the previous alternative has a
- jump after it which gets executed if it gets matched.
- Adjust that jump so it will jump to the previous
- 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. */
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
-
- /* Leave space for a jump after previous alternative---to be
- filled in later. */
- fixup_jump = b;
- b += 3;
-
- laststart = 0;
- begalt = b;
- break;
-
- case '{':
- if (! (obscure_syntax & RE_INTERVALS)
- /* Let \{ be a literal. */
- || ((obscure_syntax & RE_INTERVALS)
- && (obscure_syntax & RE_NO_BK_CURLY_BRACES))
- /* If it's the string "\{". */
- || (p - 2 == pattern && p == pend))
- goto normal_backsl;
- handle_interval:
- beg_interval = p - 1; /* The {. */
- /* If there is no previous pattern, this isn't an interval. */
- if (!laststart)
- {
- if (obscure_syntax & RE_CONTEXTUAL_INVALID_OPS)
- goto invalid_pattern;
- else
- goto normal_backsl;
- }
- /* It also isn't an interval if not preceded by an re
- matching a single character or subexpression, or if
- the current type of intervals can't handle back
- references and the previous thing is a back reference. */
- if (! (*laststart == anychar
- || *laststart == charset
- || *laststart == charset_not
- || *laststart == start_memory
- || (*laststart == exactn && laststart[1] == 1)
- || (! (obscure_syntax & RE_NO_BK_REFS)
- && *laststart == duplicate)))
- {
- if (obscure_syntax & RE_NO_BK_CURLY_BRACES)
- goto normal_char;
-
- /* Posix extended syntax is handled in previous
- statement; this is for Posix basic syntax. */
- if (obscure_syntax & RE_INTERVALS)
- goto invalid_pattern;
-
- goto normal_backsl;
- }
- lower_bound = -1; /* So can see if are set. */
- upper_bound = -1;
- GET_UNSIGNED_NUMBER (lower_bound);
- if (c == ',')
- {
- GET_UNSIGNED_NUMBER (upper_bound);
- if (upper_bound < 0)
- upper_bound = RE_DUP_MAX;
- }
- if (upper_bound < 0)
- upper_bound = lower_bound;
- if (! (obscure_syntax & RE_NO_BK_CURLY_BRACES))
- {
- if (c != '\\')
- goto invalid_pattern;
- PATFETCH (c);
- }
- if (c != '}' || lower_bound < 0 || upper_bound > RE_DUP_MAX
- || lower_bound > upper_bound
- || ((obscure_syntax & RE_NO_BK_CURLY_BRACES)
- && p != pend && *p == '{'))
- {
- if (obscure_syntax & RE_NO_BK_CURLY_BRACES)
- goto unfetch_interval;
- else
- goto invalid_pattern;
- }
-
- /* If 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 this jump is inserted. */
-
- if (upper_bound == 0)
- {
- GET_BUFFER_SPACE (3);
- insert_jump (jump, laststart, b + 3, b);
- b += 3;
- }
-
- /* Otherwise, after lower_bound number of succeeds, jump
- to after the jump_n which will be inserted at the end
- of the buffer, and insert that jump_n. */
- else
- { /* Set to 5 if only one repetition is allowed and
- hence no jump_n is inserted at the current end of
- the buffer; then only space for the succeed_n is
- needed. Otherwise, need space for both the
- succeed_n and the jump_n. */
-
- unsigned slots_needed = upper_bound == 1 ? 5 : 10;
-
- GET_BUFFER_SPACE (slots_needed);
- /* Initialize the succeed_n to n, even though it will
- be set by its attendant set_number_at, because
- re_compile_fastmap will need to know it. Jump to
- what the end of buffer will be after inserting
- this succeed_n and possibly appending a jump_n. */
- insert_jump_n (succeed_n, laststart, b + slots_needed,
- b, lower_bound);
- b += 5; /* Just increment for the succeed_n here. */
-
- /* More than one repetition is allowed, so put in at
- the end of the buffer a backward jump from b to the
- succeed_n we put in above. By the time we've gotten
- to this jump when matching, we'll have matched once
- already, so jump back only upper_bound - 1 times. */
-
- if (upper_bound > 1)
- {
- store_jump_n (b, jump_n, laststart, upper_bound - 1);
- b += 5;
- /* When hit this when matching, reset the
- preceding jump_n's n to upper_bound - 1. */
- BUFPUSH (set_number_at);
- GET_BUFFER_SPACE (2);
- STORE_NUMBER_AND_INCR (b, -5);
- STORE_NUMBER_AND_INCR (b, upper_bound - 1);
- }
- /* When hit this when matching, set the succeed_n's n. */
- GET_BUFFER_SPACE (5);
- insert_op_2 (set_number_at, laststart, b, 5, lower_bound);
- b += 5;
- }
- pending_exact = 0;
- beg_interval = 0;
- break;
-
-
- unfetch_interval:
- /* If an invalid interval, match the characters as literals. */
- if (beg_interval)
- p = beg_interval;
- else
- {
- fprintf (stderr,
- "regex: no interval beginning to which to backtrack.\n");
- exit (1);
- }
-
- beg_interval = 0;
- PATFETCH (c); /* normal_char expects char in `c'. */
- goto normal_char;
- break;
-
-#ifdef emacs
- case '=':
- BUFPUSH (at_dot);
- break;
-
- case 's':
- laststart = b;
- BUFPUSH (syntaxspec);
- PATFETCH (c);
- BUFPUSH (syntax_spec_code[c]);
- break;
-
- case 'S':
- laststart = b;
- BUFPUSH (notsyntaxspec);
- PATFETCH (c);
- BUFPUSH (syntax_spec_code[c]);
- break;
-#endif /* emacs */
-
- case 'w':
- laststart = b;
- BUFPUSH (wordchar);
- break;
-
- case 'W':
- laststart = b;
- BUFPUSH (notwordchar);
- break;
-
- case '<':
- BUFPUSH (wordbeg);
- break;
-
- case '>':
- BUFPUSH (wordend);
- break;
-
- case 'b':
- BUFPUSH (wordbound);
- break;
-
- case 'B':
- BUFPUSH (notwordbound);
- break;
-
- case '`':
- BUFPUSH (begbuf);
- break;
-
- case '\'':
- BUFPUSH (endbuf);
- break;
-
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (obscure_syntax & RE_NO_BK_REFS)
- goto normal_char;
- c1 = c - '0';
- if (c1 >= regnum)
- {
- if (obscure_syntax & RE_NO_EMPTY_BK_REF)
- goto invalid_pattern;
- else
- goto normal_char;
- }
- /* Can't back reference to a subexpression if inside of it. */
- for (stackt = stackp - 2; stackt > stackb; stackt -= 4)
- if (*stackt == c1)
- goto normal_char;
- laststart = b;
- BUFPUSH (duplicate);
- BUFPUSH (c1);
- break;
-
- case '+':
- case '?':
- if (obscure_syntax & RE_BK_PLUS_QM)
- goto handle_plus;
- else
- goto normal_backsl;
- break;
-
- default:
- normal_backsl:
- /* 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. */
- if (translate) c = translate[c];
- goto normal_char;
- }
- break;
-
- default:
- normal_char: /* Expects the character in `c'. */
- if (!pending_exact || pending_exact + *pending_exact + 1 != b
- || *pending_exact == 0177 || *p == '*' || *p == '^'
- || ((obscure_syntax & RE_BK_PLUS_QM)
- ? *p == '\\' && (p[1] == '+' || p[1] == '?')
- : (*p == '+' || *p == '?'))
- || ((obscure_syntax & RE_INTERVALS)
- && ((obscure_syntax & RE_NO_BK_CURLY_BRACES)
- ? *p == '{'
- : (p[0] == '\\' && p[1] == '{'))))
- {
- laststart = b;
- BUFPUSH (exactn);
- pending_exact = b;
- BUFPUSH (0);
- }
- BUFPUSH (c);
- (*pending_exact)++;
- }
- }
-
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
-
- if (stackp != stackb) goto unmatched_open;
-
- bufp->used = b - bufp->buffer;
- return 0;
-
- invalid_pattern:
- return "Invalid regular expression";
-
- unmatched_open:
- return "Unmatched \\(";
-
- unmatched_close:
- return "Unmatched \\)";
-
- end_of_pattern:
- return "Premature end of regular expression";
-
- nesting_too_deep:
- return "Nesting too deep";
-
- too_big:
- return "Regular expression too big";
-
- memory_exhausted:
- return "Memory exhausted";
-}
-
-
-/* Store a jump of the form <OPCODE> <relative address>.
- Store in the location FROM a jump operation to jump to relative
- address FROM - TO. OPCODE is the opcode to store. */
-
-static void
-store_jump (from, opcode, to)
- char *from, *to;
- int opcode;
-{
- from[0] = (char)opcode;
- STORE_NUMBER(from + 1, to - (from + 3));
-}
-
-
-/* Open up space before char FROM, and insert there a jump to TO.
- CURRENT_END gives the end of the storage not in use, so we know
- how much data to copy up. OP is the opcode of the jump to insert.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-insert_jump (op, from, to, current_end)
- int op;
- char *from, *to, *current_end;
-{
- register char *pfrom = current_end; /* Copy from here... */
- register char *pto = current_end + 3; /* ...to here. */
-
- while (pfrom != from)
- *--pto = *--pfrom;
- store_jump (from, op, to);
-}
-
-
-/* Store a jump of the form <opcode> <relative address> <n> .
-
- Store in the location FROM a jump operation to jump to relative
- address FROM - TO. OPCODE is the opcode to store, N is a number the
- jump uses, say, to decide how many times to jump.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-store_jump_n (from, opcode, to, n)
- char *from, *to;
- int opcode;
- unsigned n;
-{
- from[0] = (char)opcode;
- STORE_NUMBER (from + 1, to - (from + 3));
- STORE_NUMBER (from + 3, n);
-}
-
-
-/* Similar to insert_jump, but handles a jump which needs an extra
- number to handle minimum and maximum cases. Open up space at
- location FROM, and insert there a jump to TO. CURRENT_END gives the
- end of the storage in use, so we know how much data to copy up. OP is
- the opcode of the jump to insert.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-insert_jump_n (op, from, to, current_end, n)
- int op;
- char *from, *to, *current_end;
- unsigned n;
-{
- register char *pfrom = current_end; /* Copy from here... */
- register char *pto = current_end + 5; /* ...to here. */
-
- while (pfrom != from)
- *--pto = *--pfrom;
- store_jump_n (from, op, to, n);
-}
-
-
-/* Open up space at location THERE, and insert operation OP followed by
- NUM_1 and NUM_2. CURRENT_END gives the end of the storage in use, so
- we know how much data to copy up.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-insert_op_2 (op, there, current_end, num_1, num_2)
- int op;
- char *there, *current_end;
- int num_1, num_2;
-{
- register char *pfrom = current_end; /* Copy from here... */
- register char *pto = current_end + 5; /* ...to here. */
-
- while (pfrom != there)
- *--pto = *--pfrom;
-
- there[0] = (char)op;
- STORE_NUMBER (there + 1, num_1);
- STORE_NUMBER (there + 3, num_2);
-}
-
-
-
-/* Given a pattern, compute a fastmap from it. The 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 totally implausible text.
-
- The caller must supply the address of a (1 << BYTEWIDTH)-byte data
- area as bufp->fastmap.
- The other components of bufp describe the pattern to be used. */
-
-void
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
-{
- unsigned char *pattern = (unsigned char *) bufp->buffer;
- int size = bufp->used;
- register char *fastmap = bufp->fastmap;
- register unsigned char *p = pattern;
- register unsigned char *pend = pattern + size;
- register int j, k;
- unsigned char *translate = (unsigned char *) bufp->translate;
- unsigned is_a_succeed_n;
-
-#ifndef NO_ALLOCA
- unsigned char *stackb[NFAILURES];
- unsigned char **stackp = stackb;
-
-#else
- unsigned char **stackb;
- unsigned char **stackp;
- stackb = (unsigned char **) malloc (NFAILURES * sizeof (unsigned char *));
- stackp = stackb;
-
-#endif /* NO_ALLOCA */
- memset (fastmap, 0, (1 << BYTEWIDTH));
- bufp->fastmap_accurate = 1;
- bufp->can_be_null = 0;
-
- while (p)
- {
- is_a_succeed_n = 0;
- if (p == pend)
- {
- bufp->can_be_null = 1;
- break;
- }
-#ifdef SWITCH_ENUM_BUG
- switch ((int) ((enum regexpcode) *p++))
-#else
- switch ((enum regexpcode) *p++)
-#endif
- {
- case exactn:
- if (translate)
- fastmap[translate[p[1]]] = 1;
- else
- fastmap[p[1]] = 1;
- break;
-
- case begline:
- case before_dot:
- case at_dot:
- case after_dot:
- case begbuf:
- case endbuf:
- case wordbound:
- case notwordbound:
- case wordbeg:
- case wordend:
- continue;
-
- case endline:
- if (translate)
- fastmap[translate['\n']] = 1;
- else
- fastmap['\n'] = 1;
-
- if (bufp->can_be_null != 1)
- bufp->can_be_null = 2;
- break;
-
- case jump_n:
- case finalize_jump:
- case maybe_finalize_jump:
- case jump:
- case dummy_failure_jump:
- EXTRACT_NUMBER_AND_INCR (j, p);
- p += j;
- if (j > 0)
- continue;
- /* Jump backward reached implies we just went through
- the body of a loop and matched nothing.
- Opcode jumped to should be an on_failure_jump.
- Just treat it like an ordinary jump.
- For a * loop, it has pushed its failure point already;
- If so, discard that as redundant. */
-
- if ((enum regexpcode) *p != on_failure_jump
- && (enum regexpcode) *p != succeed_n)
- continue;
- p++;
- EXTRACT_NUMBER_AND_INCR (j, p);
- p += j;
- if (stackp != stackb && *stackp == p)
- stackp--;
- continue;
-
- case on_failure_jump:
- handle_on_failure_jump:
- EXTRACT_NUMBER_AND_INCR (j, p);
- *++stackp = p + j;
- if (is_a_succeed_n)
- EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */
- continue;
-
- case succeed_n:
- is_a_succeed_n = 1;
- /* 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;
- goto handle_on_failure_jump;
- }
- continue;
-
- case set_number_at:
- p += 4;
- continue;
-
- case start_memory:
- case stop_memory:
- p++;
- continue;
-
- case duplicate:
- bufp->can_be_null = 1;
- fastmap['\n'] = 1;
- case anychar:
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- if (j != '\n')
- fastmap[j] = 1;
- if (bufp->can_be_null)
- {
- FREE_AND_RETURN_VOID(stackb);
- }
- /* Don't return; check the alternative paths
- so we can set can_be_null if appropriate. */
- 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;
-
-#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;
-
-#else /* not emacs */
- case syntaxspec:
- case notsyntaxspec:
- break;
-#endif /* not emacs */
-
- case charset:
- for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
- if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
- {
- if (translate)
- fastmap[translate[j]] = 1;
- else
- fastmap[j] = 1;
- }
- break;
-
- case charset_not:
- /* Chars beyond end of map must be allowed */
- for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
- if (translate)
- fastmap[translate[j]] = 1;
- else
- fastmap[j] = 1;
-
- for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
- if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
- {
- if (translate)
- fastmap[translate[j]] = 1;
- else
- fastmap[j] = 1;
- }
- break;
-
- case unused: /* pacify gcc -Wall */
- break;
- }
-
- /* Get here means we have successfully found the possible starting
- characters of one path of the pattern. We need not follow this
- path any farther. Instead, look at the next alternative
- remembered in the stack. */
- if (stackp != stackb)
- p = *stackp--;
- else
- break;
- }
- FREE_AND_RETURN_VOID(stackb);
-}
-
-
-
-/* Like re_search_2, below, but only one string is specified, and
- doesn't let you say where to stop matching. */
-
-int
-re_search (pbufp, string, size, startpos, range, regs)
- struct re_pattern_buffer *pbufp;
- char *string;
- int size, startpos, range;
- struct re_registers *regs;
-{
- return re_search_2 (pbufp, (char *) 0, 0, string, size, startpos, range,
- regs, size);
-}
-
-
-/* Using the compiled pattern in PBUFP->buffer, first tries to match the
- virtual concatenation of STRING1 and STRING2, starting first at index
- STARTPOS, then at STARTPOS + 1, and so on. RANGE is the number of
- places to try before giving up. If RANGE is negative, it searches
- backwards, i.e., the starting positions tried are STARTPOS, STARTPOS
- - 1, etc. STRING1 and STRING2 are of SIZE1 and SIZE2, respectively.
- In REGS, return the indices of the virtual concatenation of STRING1
- and STRING2 that matched the entire PBUFP->buffer and its contained
- subexpressions. Do not consider matching one past the index MSTOP in
- the virtual concatenation of STRING1 and STRING2.
-
- The value returned is the position in the strings at which the match
- was found, or -1 if no match was found, or -2 if error (such as
- failure stack overflow). */
-
-int
-re_search_2 (pbufp, string1, size1, string2, size2, startpos, range,
- regs, mstop)
- struct re_pattern_buffer *pbufp;
- char *string1, *string2;
- int size1, size2;
- int startpos;
- register int range;
- struct re_registers *regs;
- int mstop;
-{
- register char *fastmap = pbufp->fastmap;
- register unsigned char *translate = (unsigned char *) pbufp->translate;
- int total_size = size1 + size2;
- int endpos = startpos + range;
- int val;
-
- /* Check for out-of-range starting position. */
- if (startpos < 0 || startpos > total_size)
- return -1;
-
- /* Fix up range if it would eventually take startpos outside of the
- virtual concatenation of string1 and string2. */
- if (endpos < -1)
- range = -1 - startpos;
- else if (endpos > total_size)
- range = total_size - startpos;
-
- /* Update the fastmap now if not correct already. */
- if (fastmap && !pbufp->fastmap_accurate)
- re_compile_fastmap (pbufp);
-
- /* If the search isn't to be a backwards one, don't waste time in a
- long search for a pattern that says it is anchored. */
- if (pbufp->used > 0 && (enum regexpcode) pbufp->buffer[0] == begbuf
- && range > 0)
- {
- if (startpos > 0)
- return -1;
- else
- range = 1;
- }
-
- while (1)
- {
- /* If a fastmap is supplied, skip quickly over characters that
- cannot possibly be the start of a match. Note, however, that
- if the pattern can possibly match the null string, we must
- test it at each starting point so that we take the first null
- string we get. */
-
- if (fastmap && startpos < total_size && pbufp->can_be_null != 1)
- {
- if (range > 0) /* Searching forwards. */
- {
- register int lim = 0;
- register unsigned char *p;
- int irange = range;
- if (startpos < size1 && startpos + range >= size1)
- lim = range - (size1 - startpos);
-
- p = ((unsigned char *)
- &(startpos >= size1 ? string2 - size1 : string1)[startpos]);
-
- while (range > lim && !fastmap[translate
- ? translate[*p++]
- : *p++])
- range--;
- startpos += irange - range;
- }
- else /* Searching backwards. */
- {
- register unsigned char c;
-
- if (string1 == 0 || startpos >= size1)
- c = string2[startpos - size1];
- else
- c = string1[startpos];
-
- c &= 0xff;
- if (translate ? !fastmap[translate[c]] : !fastmap[c])
- goto advance;
- }
- }
-
- if (range >= 0 && startpos == total_size
- && fastmap && pbufp->can_be_null == 0)
- return -1;
-
- val = re_match_2 (pbufp, string1, size1, string2, size2, startpos,
- regs, mstop);
- if (val >= 0)
- return startpos;
- if (val == -2)
- return -2;
-
-#ifndef NO_ALLOCA
-#ifdef C_ALLOCA
- alloca (0);
-#endif /* C_ALLOCA */
-
-#endif /* NO_ALLOCA */
- advance:
- if (!range)
- break;
- else if (range > 0)
- {
- range--;
- startpos++;
- }
- else
- {
- range++;
- startpos--;
- }
- }
- return -1;
-}
-
-
-
-#ifndef emacs /* emacs never uses this. */
-int
-re_match (pbufp, string, size, pos, regs)
- struct re_pattern_buffer *pbufp;
- char *string;
- int size, pos;
- struct re_registers *regs;
-{
- return re_match_2 (pbufp, (char *) 0, 0, string, size, pos, regs, size);
-}
-#endif /* not emacs */
-
-
-/* The following are used for re_match_2, defined below: */
-
-/* Roughly the maximum number of failure points on the stack. Would be
- exactly that if always pushed MAX_NUM_FAILURE_ITEMS each time we failed. */
-
-int re_max_failures = 2000;
-
-/* Routine used by re_match_2. */
-/* static int memcmp_translate (); *//* already declared */
-
-
-/* Structure and accessing macros used in re_match_2: */
-
-struct register_info
-{
- unsigned is_active : 1;
- unsigned matched_something : 1;
-};
-
-#define IS_ACTIVE(R) ((R).is_active)
-#define MATCHED_SOMETHING(R) ((R).matched_something)
-
-
-/* Macros used by re_match_2: */
-
-
-/* I.e., regstart, regend, and reg_info. */
-
-#define NUM_REG_ITEMS 3
-
-/* We push at most this many things on the stack whenever we
- fail. The `+ 2' refers to PATTERN_PLACE and STRING_PLACE, which are
- arguments to the PUSH_FAILURE_POINT macro. */
-
-#define MAX_NUM_FAILURE_ITEMS (RE_NREGS * NUM_REG_ITEMS + 2)
-
-
-/* We push this many things on the stack whenever we fail. */
-
-#define NUM_FAILURE_ITEMS (last_used_reg * NUM_REG_ITEMS + 2)
-
-
-/* This pushes most of the information about the current state we will want
- if we ever fail back to it. */
-
-#define PUSH_FAILURE_POINT(pattern_place, string_place) \
- { \
- long last_used_reg, this_reg; \
- \
- /* Find out how many registers are active or have been matched. \
- (Aside from register zero, which is only set at the end.) */ \
- for (last_used_reg = RE_NREGS - 1; last_used_reg > 0; last_used_reg--)\
- if (regstart[last_used_reg] != (unsigned char *)(-1L)) \
- break; \
- \
- if (stacke - stackp < NUM_FAILURE_ITEMS) \
- { \
- unsigned char **stackx; \
- unsigned int len = stacke - stackb; \
- if (len > re_max_failures * MAX_NUM_FAILURE_ITEMS) \
- { \
- FREE_AND_RETURN(stackb,(-2)); \
- } \
- \
- /* Roughly double the size of the stack. */ \
- stackx = DOUBLE_STACK(stackx,stackb,len); \
- /* Rearrange the pointers. */ \
- stackp = stackx + (stackp - stackb); \
- stackb = stackx; \
- stacke = stackb + 2 * len; \
- } \
- \
- /* Now push the info for each of those registers. */ \
- for (this_reg = 1; this_reg <= last_used_reg; this_reg++) \
- { \
- *stackp++ = regstart[this_reg]; \
- *stackp++ = regend[this_reg]; \
- *stackp++ = (unsigned char *) &reg_info[this_reg]; \
- } \
- \
- /* Push how many registers we saved. */ \
- *stackp++ = (unsigned char *) last_used_reg; \
- \
- *stackp++ = pattern_place; \
- *stackp++ = string_place; \
- }
-
-
-/* This pops what PUSH_FAILURE_POINT pushes. */
-
-#define POP_FAILURE_POINT() \
- { \
- int temp; \
- stackp -= 2; /* Remove failure points. */ \
- temp = (int) *--stackp; /* How many regs pushed. */ \
- temp *= NUM_REG_ITEMS; /* How much to take off the stack. */ \
- stackp -= temp; /* Remove the register info. */ \
- }
-
-
-#define MATCHING_IN_FIRST_STRING (dend == end_match_1)
-
-/* Is true if there is a first string and if PTR is pointing anywhere
- inside it or just past the end. */
-
-#define IS_IN_FIRST_STRING(ptr) \
- (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
-
-/* 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; \
- }
-
-
-/* Call this when have matched something; it sets `matched' flags for the
- registers corresponding to the subexpressions of which we currently
- are inside. */
-#define SET_REGS_MATCHED \
- { unsigned this_reg; \
- for (this_reg = 0; this_reg < RE_NREGS; this_reg++) \
- { \
- if (IS_ACTIVE(reg_info[this_reg])) \
- MATCHED_SOMETHING(reg_info[this_reg]) = 1; \
- else \
- MATCHED_SOMETHING(reg_info[this_reg]) = 0; \
- } \
- }
-
-/* Test if at very beginning or at very end of the virtual concatenation
- of string1 and string2. If there is only one string, we've put it in
- string2. */
-
-#define AT_STRINGS_BEG (d == (size1 ? string1 : string2) || !size2)
-#define AT_STRINGS_END (d == end2)
-
-#define AT_WORD_BOUNDARY \
- (AT_STRINGS_BEG || AT_STRINGS_END || IS_A_LETTER (d - 1) != IS_A_LETTER (d))
-
-/* We have two special cases to check for:
- 1) if we're past the end of string1, we have to look at the first
- character in string2;
- 2) if we're before the beginning of string2, we have to look at the
- last character in string1; we assume there is a string1, so use
- this in conjunction with AT_STRINGS_BEG. */
-#define IS_A_LETTER(d) \
- (SYNTAX ((d) == end1 ? *string2 : (d) == string2 - 1 ? *(end1 - 1) : *(d))\
- == Sword)
-
-
-/* Match the pattern described by PBUFP against the virtual
- concatenation of STRING1 and STRING2, which are of SIZE1 and SIZE2,
- respectively. Start the match at index POS in the virtual
- concatenation of STRING1 and STRING2. In REGS, return the indices of
- the virtual concatenation of STRING1 and STRING2 that matched the
- entire PBUFP->buffer and its contained subexpressions. Do not
- consider matching one past the index MSTOP in the virtual
- concatenation of STRING1 and STRING2.
-
- If pbufp->fastmap is nonzero, then it had better be up to date.
-
- The reason that the data to match are specified as two components
- which are to be regarded as concatenated is so this function can be
- used directly on the contents of an Emacs buffer.
-
- -1 is returned if there is no match. -2 is returned if there is an
- error (such as match stack overflow). Otherwise the value is the
- length of the substring which was matched. */
-
-int
-re_match_2 (pbufp, string1_arg, size1, string2_arg, size2, pos, regs, mstop)
- struct re_pattern_buffer *pbufp;
- char *string1_arg, *string2_arg;
- int size1, size2;
- int pos;
- struct re_registers *regs;
- int mstop;
-{
- register unsigned char *p = (unsigned char *) pbufp->buffer;
-
- /* Pointer to beyond end of buffer. */
- register unsigned char *pend = p + pbufp->used;
-
- unsigned char *string1 = (unsigned char *) string1_arg;
- unsigned char *string2 = (unsigned char *) string2_arg;
- unsigned char *end1; /* Just past end of first string. */
- unsigned char *end2; /* Just past end of second string. */
-
- /* Pointers into string1 and string2, just past the last characters in
- each to consider matching. */
- unsigned char *end_match_1, *end_match_2;
-
- register unsigned char *d, *dend;
- register int mcnt; /* Multipurpose. */
- unsigned char *translate = (unsigned char *) pbufp->translate;
- unsigned is_a_jump_n = 0;
-
- /* 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. */
-
-#ifndef NO_ALLOCA
- unsigned char *initial_stack[MAX_NUM_FAILURE_ITEMS * NFAILURES];
-#endif
- unsigned char **stackb;
- unsigned char **stackp;
- unsigned char **stacke;
-
-
- /* 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.) */
-
- unsigned char *regstart[RE_NREGS];
- unsigned char *regend[RE_NREGS];
-
- /* 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. */
-
- struct register_info reg_info[RE_NREGS];
-
-
- /* 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 = 0;
- unsigned char *best_regstart[RE_NREGS];
- unsigned char *best_regend[RE_NREGS];
-
- /* Initialize the stack. */
-#ifdef NO_ALLOCA
- stackb = (unsigned char **) malloc (MAX_NUM_FAILURE_ITEMS * NFAILURES * sizeof (char *));
-#else
- stackb = initial_stack;
-#endif
- stackp = stackb;
- stacke = &stackb[MAX_NUM_FAILURE_ITEMS * NFAILURES];
-
-#ifdef DEBUG_REGEX
- fprintf (stderr, "Entering re_match_2(%s%s)\n", string1_arg, string2_arg);
-#endif
-
- /* Initialize subexpression text positions to -1 to mark ones that no
- \( or ( and \) or ) has been seen for. Also set all registers to
- inactive and mark them as not having matched anything or ever
- failed. */
- for (mcnt = 0; mcnt < RE_NREGS; mcnt++)
- {
- regstart[mcnt] = regend[mcnt] = (unsigned char *) (-1L);
- IS_ACTIVE (reg_info[mcnt]) = 0;
- MATCHED_SOMETHING (reg_info[mcnt]) = 0;
- }
-
- if (regs)
- for (mcnt = 0; mcnt < RE_NREGS; mcnt++)
- regs->start[mcnt] = regs->end[mcnt] = -1;
-
- /* Set up pointers to ends of strings.
- Don't allow the second string to be empty unless both are empty. */
- if (size2 == 0)
- {
- string2 = string1;
- size2 = size1;
- string1 = 0;
- size1 = 0;
- }
- end1 = string1 + size1;
- end2 = string2 + size2;
-
- /* Compute where to stop matching, within the two strings. */
- if (mstop <= size1)
- {
- end_match_1 = string1 + mstop;
- end_match_2 = string2;
- }
- else
- {
- end_match_1 = end1;
- end_match_2 = string2 + mstop - 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;
-
-
- /* This loops over pattern commands. It exits by returning from the
- function if match is complete, or it drops through if match fails
- at this starting point in the input data. */
-
- while (1)
- {
-#ifdef DEBUG_REGEX
- fprintf (stderr,
- "regex loop(%d): matching 0x%02d\n",
- p - (unsigned char *) pbufp->buffer,
- *p);
-#endif
- is_a_jump_n = 0;
- /* End of pattern means we might have succeeded. */
- if (p == pend)
- {
- /* If not end of string, try backtracking. Otherwise done. */
- if (d != end_match_2)
- {
- if (stackp != stackb)
- {
- /* More failure points to try. */
-
- unsigned in_same_string =
- IS_IN_FIRST_STRING (best_regend[0])
- == MATCHING_IN_FIRST_STRING;
-
- /* If exceeds best match so far, save it. */
- if (! best_regs_set
- || (in_same_string && d > best_regend[0])
- || (! in_same_string && ! MATCHING_IN_FIRST_STRING))
- {
- best_regs_set = 1;
- best_regend[0] = d; /* Never use regstart[0]. */
-
- for (mcnt = 1; mcnt < RE_NREGS; 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. */
- d = best_regend[0];
-
- for (mcnt = 0; mcnt < RE_NREGS; mcnt++)
- {
- regstart[mcnt] = best_regstart[mcnt];
- regend[mcnt] = best_regend[mcnt];
- }
- }
- }
-
- /* If caller wants register contents data back, convert it
- to indices. */
- if (regs)
- {
- regs->start[0] = pos;
- if (MATCHING_IN_FIRST_STRING)
- regs->end[0] = d - string1;
- else
- regs->end[0] = d - string2 + size1;
- for (mcnt = 1; mcnt < RE_NREGS; mcnt++)
- {
- if (regend[mcnt] == (unsigned char *)(-1L))
- {
- regs->start[mcnt] = -1;
- regs->end[mcnt] = -1;
- continue;
- }
- if (IS_IN_FIRST_STRING (regstart[mcnt]))
- regs->start[mcnt] = regstart[mcnt] - string1;
- else
- regs->start[mcnt] = regstart[mcnt] - string2 + size1;
-
- if (IS_IN_FIRST_STRING (regend[mcnt]))
- regs->end[mcnt] = regend[mcnt] - string1;
- else
- regs->end[mcnt] = regend[mcnt] - string2 + size1;
- }
- }
- FREE_AND_RETURN(stackb,
- (d - pos - (MATCHING_IN_FIRST_STRING ?
- string1 :
- string2 - size1)));
- }
-
- /* Otherwise match next pattern command. */
-#ifdef SWITCH_ENUM_BUG
- switch ((int) ((enum regexpcode) *p++))
-#else
- switch ((enum regexpcode) *p++)
-#endif
- {
-
- /* \( [or `(', as appropriate] is represented by start_memory,
- \) by stop_memory. Both of those commands are followed by
- a register number in the next byte. The text matched
- within the \( and \) is recorded under that number. */
- case start_memory:
- regstart[*p] = d;
- IS_ACTIVE (reg_info[*p]) = 1;
- MATCHED_SOMETHING (reg_info[*p]) = 0;
- p++;
- break;
-
- case stop_memory:
- regend[*p] = d;
- IS_ACTIVE (reg_info[*p]) = 0;
-
- /* If just failed to match something this time around with a sub-
- expression that's in a loop, try to force exit from the loop. */
- if ((! MATCHED_SOMETHING (reg_info[*p])
- || (enum regexpcode) p[-3] == start_memory)
- && (p + 1) != pend)
- {
- register unsigned char *p2 = p + 1;
- mcnt = 0;
- switch (*p2++)
- {
- case jump_n:
- is_a_jump_n = 1;
- case finalize_jump:
- case maybe_finalize_jump:
- case jump:
- case dummy_failure_jump:
- EXTRACT_NUMBER_AND_INCR (mcnt, p2);
- if (is_a_jump_n)
- p2 += 2;
- break;
- }
- p2 += mcnt;
-
- /* If the next operation is a jump backwards in the pattern
- to an on_failure_jump, 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 && (enum regexpcode) *p2++ == on_failure_jump)
- {
- EXTRACT_NUMBER_AND_INCR (mcnt, p2);
- PUSH_FAILURE_POINT (p2 + mcnt, d);
- goto fail;
- }
- }
- p++;
- break;
-
- /* \<digit> has been turned into a `duplicate' command which is
- followed by the numeric value of <digit> as the register number. */
- case duplicate:
- {
- int regno = *p++; /* Get which register to match against */
- register unsigned char *d2, *dend2;
-
- /* 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 = ((IS_IN_FIRST_STRING (regstart[regno])
- == IS_IN_FIRST_STRING (regend[regno]))
- ? regend[regno] : end_match_1);
- while (1)
- {
- /* If necessary, advance to next segment in register
- contents. */
- while (d2 == dend2)
- {
- if (dend2 == end_match_2) break;
- if (dend2 == regend[regno]) break;
- d2 = string2, dend2 = regend[regno]; /* end of string1 => advance to string2. */
- }
- /* 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
- ? memcmp_translate (d, d2, mcnt, translate)
- : memcmp ((char *)d, (char *)d2, mcnt))
- goto fail;
- d += mcnt, d2 += mcnt;
- }
- }
- break;
-
- case anychar:
- PREFETCH; /* Fetch a data character. */
- /* Match anything but a newline, maybe even a null. */
- if ((translate ? translate[*d] : *d) == '\n'
- || ((obscure_syntax & RE_DOT_NOT_NULL)
- && (translate ? translate[*d] : *d) == '\000'))
- goto fail;
- SET_REGS_MATCHED;
- d++;
- break;
-
- case charset:
- case charset_not:
- {
- int not = 0; /* Nonzero for charset_not. */
- register int c;
- if (*(p - 1) == (unsigned char) charset_not)
- not = 1;
-
- PREFETCH; /* Fetch a data character. */
-
- if (translate)
- c = translate[*d];
- else
- c = *d;
-
- if (c < *p * BYTEWIDTH
- && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
- not = !not;
-
- p += 1 + *p;
-
- if (!not) goto fail;
- SET_REGS_MATCHED;
- d++;
- break;
- }
-
- case begline:
- if ((size1 != 0 && d == string1)
- || (size1 == 0 && size2 != 0 && d == string2)
- || (d && d[-1] == '\n')
- || (size1 == 0 && size2 == 0))
- break;
- else
- goto fail;
-
- case endline:
- if (d == end2
- || (d == end1 ? (size2 == 0 || *string2 == '\n') : *d == '\n'))
- break;
- goto fail;
-
- /* `or' constructs are handled by starting each alternative with
- an on_failure_jump that points to the start of the next
- alternative. Each alternative except the last ends with a
- jump to the joining point. (Actually, each jump except for
- the last one really jumps to the following jump, because
- tensioning the jumps is a hassle.) */
-
- /* The start of a stupid repeat has an on_failure_jump that points
- past the end of the repeat text. This makes a failure point so
- that on failure to match a repetition, matching restarts past
- as many repetitions have been found with no way to fail and
- look for another one. */
-
- /* A smart repeat is similar but loops back to the on_failure_jump
- so that each repetition makes another failure point. */
-
- case on_failure_jump:
- on_failure:
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- PUSH_FAILURE_POINT (p + mcnt, d);
- break;
-
- /* The end of a smart repeat has a maybe_finalize_jump back.
- Change it either to a finalize_jump or an ordinary jump. */
- case maybe_finalize_jump:
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- {
- register unsigned char *p2 = p;
- /* Compare what follows with the beginning of the repeat.
- If we can establish that there is nothing that they would
- both match, we can change to finalize_jump. */
- while (p2 + 1 != pend
- && (*p2 == (unsigned char) stop_memory
- || *p2 == (unsigned char) start_memory))
- p2 += 2; /* Skip over reg number. */
- if (p2 == pend)
- p[-3] = (unsigned char) finalize_jump;
- else if (*p2 == (unsigned char) exactn
- || *p2 == (unsigned char) endline)
- {
- register int c = *p2 == (unsigned char) endline ? '\n' : p2[2];
- register unsigned char *p1 = p + mcnt;
- /* p1[0] ... p1[2] are an on_failure_jump.
- Examine what follows that. */
- if (p1[3] == (unsigned char) exactn && p1[5] != c)
- p[-3] = (unsigned char) finalize_jump;
- else if (p1[3] == (unsigned char) charset
- || p1[3] == (unsigned char) charset_not)
- {
- int not = p1[3] == (unsigned char) charset_not;
- if (c < p1[4] * BYTEWIDTH
- && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
- not = !not;
- /* `not' is 1 if c would match. */
- /* That means it is not safe to finalize. */
- if (!not)
- p[-3] = (unsigned char) finalize_jump;
- }
- }
- }
- p -= 2; /* Point at relative address again. */
- if (p[-1] != (unsigned char) finalize_jump)
- {
- p[-1] = (unsigned char) jump;
- goto nofinalize;
- }
- /* Note fall through. */
-
- /* The end of a stupid repeat has a finalize_jump back to the
- start, where another failure point will be made which will
- point to after all the repetitions found so far. */
-
- /* Take off failure points put on by matching on_failure_jump
- because didn't fail. Also remove the register information
- put on by the on_failure_jump. */
- case finalize_jump:
- POP_FAILURE_POINT ();
- /* Note fall through. */
-
- /* Jump without taking off any failure points. */
- case jump:
- nofinalize:
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- p += mcnt;
- break;
-
- case dummy_failure_jump:
- /* Normally, the on_failure_jump pushes a failure point, which
- then gets popped at finalize_jump. We will end up at
- finalize_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 finalize_jump to pop. */
- PUSH_FAILURE_POINT (0, 0);
- goto nofinalize;
-
-
- /* Have to succeed matching what follows at least n times. Then
- just handle like an on_failure_jump. */
- case succeed_n:
- EXTRACT_NUMBER (mcnt, p + 2);
- /* Originally, this is how many times we HAVE to succeed. */
- if (mcnt)
- {
- mcnt--;
- p += 2;
- STORE_NUMBER_AND_INCR (p, mcnt);
- }
- else if (mcnt == 0)
- {
- p[2] = unused;
- p[3] = unused;
- goto on_failure;
- }
- else
- {
- fprintf (stderr, "regex: the succeed_n's n is not set.\n");
- exit (1);
- }
- break;
-
- case jump_n:
- EXTRACT_NUMBER (mcnt, p + 2);
- /* Originally, this is how many times we CAN jump. */
- if (mcnt)
- {
- mcnt--;
- STORE_NUMBER(p + 2, mcnt);
- goto nofinalize; /* Do the jump without taking off
- any failure points. */
- }
- /* If don't have to jump any more, skip over the rest of command. */
- else
- p += 4;
- break;
-
- case set_number_at:
- {
- register unsigned char *p1;
-
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- p1 = p + mcnt;
- EXTRACT_NUMBER_AND_INCR (mcnt, p);
- STORE_NUMBER (p1, mcnt);
- break;
- }
-
- /* Ignore these. Used to ignore the n of succeed_n's which
- currently have n == 0. */
- case unused:
- break;
-
- case wordbound:
- if (AT_WORD_BOUNDARY)
- break;
- goto fail;
-
- case notwordbound:
- if (AT_WORD_BOUNDARY)
- goto fail;
- break;
-
- case wordbeg:
- if (IS_A_LETTER (d) && (!IS_A_LETTER (d - 1) || AT_STRINGS_BEG))
- break;
- goto fail;
-
- case wordend:
- /* Have to check if AT_STRINGS_BEG before looking at d - 1. */
- if (!AT_STRINGS_BEG && IS_A_LETTER (d - 1)
- && (!IS_A_LETTER (d) || AT_STRINGS_END))
- break;
- goto fail;
-
-#ifdef emacs
- case before_dot:
- if (PTR_CHAR_POS (d) >= point)
- goto fail;
- break;
-
- case at_dot:
- if (PTR_CHAR_POS (d) != point)
- goto fail;
- break;
-
- case after_dot:
- if (PTR_CHAR_POS (d) <= point)
- goto fail;
- break;
-
- case wordchar:
- mcnt = (int) Sword;
- goto matchsyntax;
-
- case syntaxspec:
- mcnt = *p++;
- matchsyntax:
- PREFETCH;
- if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail;
- SET_REGS_MATCHED;
- break;
-
- case notwordchar:
- mcnt = (int) Sword;
- goto matchnotsyntax;
-
- case notsyntaxspec:
- mcnt = *p++;
- matchnotsyntax:
- PREFETCH;
- if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail;
- SET_REGS_MATCHED;
- break;
-
-#else /* not emacs */
-
- case wordchar:
- PREFETCH;
- if (!IS_A_LETTER (d))
- goto fail;
- SET_REGS_MATCHED;
- break;
-
- case notwordchar:
- PREFETCH;
- if (IS_A_LETTER (d))
- goto fail;
- SET_REGS_MATCHED;
- break;
-
- case before_dot:
- case at_dot:
- case after_dot:
- case syntaxspec:
- case notsyntaxspec:
- break;
-
-#endif /* not emacs */
-
- case begbuf:
- if (AT_STRINGS_BEG)
- break;
- goto fail;
-
- case endbuf:
- if (AT_STRINGS_END)
- break;
- goto fail;
-
- case exactn:
- /* Match the next few pattern characters exactly.
- mcnt is how many characters to match. */
- mcnt = *p++;
- /* 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[*d++] != *p++) goto fail;
- }
- while (--mcnt);
- }
- else
- {
- do
- {
- PREFETCH;
- if (*d++ != *p++) goto fail;
- }
- while (--mcnt);
- }
- SET_REGS_MATCHED;
- break;
- }
- continue; /* Successfully executed one pattern command; keep going. */
-
- /* Jump here if any matching operation fails. */
- fail:
- if (stackp != stackb)
- /* A restart point is known. Restart there and pop it. */
- {
- short last_used_reg, this_reg;
-
- /* If this failure point is from a dummy_failure_point, just
- skip it. */
- if (!stackp[-2])
- {
- POP_FAILURE_POINT ();
- goto fail;
- }
-
- d = *--stackp;
- p = *--stackp;
- if (d >= string1 && d <= end1)
- dend = end_match_1;
- /* Restore register info. */
- last_used_reg = (long) *--stackp;
-
- /* Make the ones that weren't saved -1 or 0 again. */
- for (this_reg = RE_NREGS - 1; this_reg > last_used_reg; this_reg--)
- {
- regend[this_reg] = (unsigned char *) (-1L);
- regstart[this_reg] = (unsigned char *) (-1L);
- IS_ACTIVE (reg_info[this_reg]) = 0;
- MATCHED_SOMETHING (reg_info[this_reg]) = 0;
- }
-
- /* And restore the rest from the stack. */
- for ( ; this_reg > 0; this_reg--)
- {
- reg_info[this_reg] = *(struct register_info *) *--stackp;
- regend[this_reg] = *--stackp;
- regstart[this_reg] = *--stackp;
- }
- }
- else
- break; /* Matching at this starting point really fails. */
- }
-
- if (best_regs_set)
- goto restore_best_regs;
-
- FREE_AND_RETURN(stackb,(-1)); /* Failure to match. */
-}
-
-
-static int
-memcmp_translate (s1, s2, len, translate)
- unsigned char *s1, *s2;
- register int len;
- unsigned char *translate;
-{
- register unsigned char *p1 = s1, *p2 = s2;
- while (len)
- {
- if (translate [*p1++] != translate [*p2++]) return 1;
- len--;
- }
- return 0;
-}
-
-
-
-/* Entry points compatible with 4.2 BSD regex library. */
-
-#if !defined(emacs) && !defined(GAWK)
-
-static struct re_pattern_buffer re_comp_buf;
-
-char *
-re_comp (s)
- char *s;
-{
- if (!s)
- {
- if (!re_comp_buf.buffer)
- return "No previous regular expression";
- return 0;
- }
-
- if (!re_comp_buf.buffer)
- {
- if (!(re_comp_buf.buffer = (char *) malloc (200)))
- return "Memory exhausted";
- re_comp_buf.allocated = 200;
- if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH)))
- return "Memory exhausted";
- }
- return re_compile_pattern (s, strlen (s), &re_comp_buf);
-}
-
-int
-re_exec (s)
- char *s;
-{
- int len = strlen (s);
- return 0 <= re_search (&re_comp_buf, s, len, 0, len,
- (struct re_registers *) 0);
-}
-#endif /* not emacs && not GAWK */
-
-
-
-#ifdef test
-
-#ifdef atarist
-long _stksize = 2L; /* reserve memory for stack */
-#endif
-#include <stdio.h>
-
-/* 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
- };
-
-#ifdef canned
-
-#include "tests.h"
-
-typedef enum { extended_test, basic_test } test_type;
-
-/* Use this to run the tests we've thought of. */
-
-void
-main ()
-{
- test_type t = extended_test;
-
- if (t == basic_test)
- {
- printf ("Running basic tests:\n\n");
- test_posix_basic ();
- }
- else if (t == extended_test)
- {
- printf ("Running extended tests:\n\n");
- test_posix_extended ();
- }
-}
-
-#else /* not canned */
-
-/* Use this to run interactive tests. */
-
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- char pat[80];
- struct re_pattern_buffer buf;
- int i;
- char c;
- char fastmap[(1 << BYTEWIDTH)];
-
- /* Allow a command argument to specify the style of syntax. */
- if (argc > 1)
- obscure_syntax = atol (argv[1]);
-
- buf.allocated = 40;
- buf.buffer = (char *) malloc (buf.allocated);
- buf.fastmap = fastmap;
- buf.translate = upcase;
-
- while (1)
- {
- gets (pat);
-
- if (*pat)
- {
- re_compile_pattern (pat, strlen(pat), &buf);
-
- for (i = 0; i < buf.used; i++)
- printchar (buf.buffer[i]);
-
- putchar ('\n');
-
- printf ("%d allocated, %d used.\n", buf.allocated, buf.used);
-
- re_compile_fastmap (&buf);
- printf ("Allowed by fastmap: ");
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (fastmap[i]) printchar (i);
- putchar ('\n');
- }
-
- gets (pat); /* Now read the string to match against */
-
- i = re_match (&buf, pat, strlen (pat), 0, 0);
- printf ("Match value %d.\n", i);
- }
-}
-
-#endif
-
-
-#ifdef NOTDEF
-print_buf (bufp)
- struct re_pattern_buffer *bufp;
-{
- int i;
-
- printf ("buf is :\n----------------\n");
- for (i = 0; i < bufp->used; i++)
- printchar (bufp->buffer[i]);
-
- printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used);
-
- printf ("Allowed by fastmap: ");
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (bufp->fastmap[i])
- printchar (i);
- printf ("\nAllowed by translate: ");
- if (bufp->translate)
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (bufp->translate[i])
- printchar (i);
- printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't");
- printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not");
-}
-#endif /* NOTDEF */
-
-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);
-}
-
-error (string)
- char *string;
-{
- puts (string);
- exit (1);
-}
-#endif /* test */
diff --git a/gnu/usr.bin/awk/regex.h b/gnu/usr.bin/awk/regex.h
deleted file mode 100644
index fce11c3..0000000
--- a/gnu/usr.bin/awk/regex.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/* Definitions for data structures callers pass the regex library.
-
- Copyright (C) 1985, 1989-90 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. */
-
-
-#ifndef __REGEXP_LIBRARY
-#define __REGEXP_LIBRARY
-
-/* Define number of parens for which we record the beginnings and ends.
- This affects how much space the `struct re_registers' type takes up. */
-#ifndef RE_NREGS
-#define RE_NREGS 10
-#endif
-
-#define BYTEWIDTH 8
-
-
-/* Maximum number of duplicates an interval can allow. */
-#ifndef RE_DUP_MAX
-#define RE_DUP_MAX ((1 << 15) - 1)
-#endif
-
-
-/* This defines the various regexp syntaxes. */
-extern long obscure_syntax;
-
-
-/* The following bits are used in the obscure_syntax variable to choose among
- alternative regexp syntaxes. */
-
-/* If this bit is set, plain parentheses serve as grouping, and backslash
- parentheses are needed for literal searching.
- If not set, backslash-parentheses are grouping, and plain parentheses
- are for literal searching. */
-#define RE_NO_BK_PARENS 1L
-
-/* If this bit is set, plain | serves as the `or'-operator, and \| is a
- literal.
- If not set, \| serves as the `or'-operator, and | is a literal. */
-#define RE_NO_BK_VBAR (1L << 1)
-
-/* If this bit is not set, plain + or ? serves as an operator, and \+, \? are
- literals.
- If set, \+, \? are operators and plain +, ? are literals. */
-#define RE_BK_PLUS_QM (1L << 2)
-
-/* If this bit is set, | binds tighter than ^ or $.
- If not set, the contrary. */
-#define RE_TIGHT_VBAR (1L << 3)
-
-/* If this bit is set, then treat newline as an OR operator.
- If not set, treat it as a normal character. */
-#define RE_NEWLINE_OR (1L << 4)
-
-/* If this bit is set, then special characters may act as normal
- characters in some contexts. Specifically, this applies to:
- ^ -- only special at the beginning, or after ( or |;
- $ -- only special at the end, or before ) or |;
- *, +, ? -- only special when not after the beginning, (, or |.
- If this bit is not set, special characters (such as *, ^, and $)
- always have their special meaning regardless of the surrounding
- context. */
-#define RE_CONTEXT_INDEP_OPS (1L << 5)
-
-/* If this bit is not set, then \ before anything inside [ and ] is taken as
- a real \.
- If set, then such a \ escapes the following character. This is a
- special case for awk. */
-#define RE_AWK_CLASS_HACK (1L << 6)
-
-/* If this bit is set, then \{ and \} or { and } serve as interval operators.
- If not set, then \{ and \} and { and } are treated as literals. */
-#define RE_INTERVALS (1L << 7)
-
-/* If this bit is not set, then \{ and \} serve as interval operators and
- { and } are literals.
- If set, then { and } serve as interval operators and \{ and \} are
- literals. */
-#define RE_NO_BK_CURLY_BRACES (1L << 8)
-
-/* 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 (1L << 9)
-
-/* If this bit is set, then the dot re doesn't match a null byte.
- If not set, it does. */
-#define RE_DOT_NOT_NULL (1L << 10)
-
-/* If this bit is set, then [^...] doesn't match a newline.
- If not set, it does. */
-#define RE_HAT_NOT_NEWLINE (1L << 11)
-
-/* If this bit is set, back references are recognized.
- If not set, they aren't. */
-#define RE_NO_BK_REFS (1L << 12)
-
-/* If this bit is set, back references must refer to a preceding
- subexpression. If not set, a back reference to a nonexistent
- subexpression is treated as literal characters. */
-#define RE_NO_EMPTY_BK_REF (1L << 13)
-
-/* If this bit is set, bracket expressions can't be empty.
- If it is set, they can be empty. */
-#define RE_NO_EMPTY_BRACKETS (1L << 14)
-
-/* If this bit is set, then *, +, ? and { cannot be first in an re or
- immediately after a |, or a (. Furthermore, a | cannot be first or
- last in an re, or immediately follow another | or a (. Also, a ^
- cannot appear in a nonleading position and a $ cannot appear in a
- nontrailing position (outside of bracket expressions, that is). */
-#define RE_CONTEXTUAL_INVALID_OPS (1L << 15)
-
-/* If this bit is set, then +, ? and | aren't recognized as operators.
- If it's not, they are. */
-#define RE_LIMITED_OPS (1L << 16)
-
-/* If this bit is set, then an ending range point has to collate higher
- or equal to the starting range point.
- If it's not set, then when the ending range point collates higher
- than the starting range point, the range is just considered empty. */
-#define RE_NO_EMPTY_RANGES (1L << 17)
-
-/* If this bit is set, then a hyphen (-) can't be an ending range point.
- If it isn't, then it can. */
-#define RE_NO_HYPHEN_RANGE_END (1L << 18)
-
-
-/* Define combinations of bits for the standard possibilities. */
-#define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- | RE_CONTEXT_INDEP_OPS)
-#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_AWK_CLASS_HACK)
-#define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR)
-#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
-#define RE_SYNTAX_EMACS 0
-#define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM \
- | RE_CHAR_CLASSES | RE_DOT_NOT_NULL \
- | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF \
- | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS \
- | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END)
-
-#define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES \
- | RE_NO_BK_VBAR | RE_NO_BK_PARENS \
- | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES \
- | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \
- | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES \
- | RE_NO_HYPHEN_RANGE_END)
-
-
-/* This data structure is used to represent a compiled pattern. */
-
-struct re_pattern_buffer
- {
- char *buffer; /* Space holding the compiled pattern commands. */
- long allocated; /* Size of space that `buffer' points to. */
- long used; /* Length of portion of buffer actually occupied */
- char *fastmap; /* Pointer to fastmap, if any, or zero if none. */
- /* re_search uses the fastmap, if there is one,
- to skip over totally implausible characters. */
- char *translate; /* Translate table to apply to all characters before
- comparing, or zero for no translation.
- The translation is applied to a pattern when it is
- compiled and to data when it is matched. */
- char fastmap_accurate;
- /* Set to zero when a new pattern is stored,
- set to one when the fastmap is updated from it. */
- char can_be_null; /* Set to one by compiling fastmap
- if this pattern might match the null string.
- It does not necessarily match the null string
- in that case, but if this is zero, it cannot.
- 2 as value means can match null string
- but at end of range or before a character
- listed in the fastmap. */
- };
-
-
-/* search.c (search_buffer) needs this one value. It is defined both in
- regex.c and here. */
-#define RE_EXACTN_VALUE 1
-
-
-/* Structure to store register contents data in.
-
- Pass the address of such a structure as an argument to re_match, etc.,
- if you want this information back.
-
- For i from 1 to RE_NREGS - 1, start[i] records the starting index in
- the string of where the ith subexpression matched, and end[i] records
- one after the ending index. start[0] and end[0] are analogous, for
- the entire pattern. */
-
-struct re_registers
- {
- int start[RE_NREGS];
- int end[RE_NREGS];
- };
-
-
-
-#ifdef __STDC__
-
-extern char *re_compile_pattern (char *, size_t, struct re_pattern_buffer *);
-/* Is this really advertised? */
-extern void re_compile_fastmap (struct re_pattern_buffer *);
-extern int re_search (struct re_pattern_buffer *, char*, int, int, int,
- struct re_registers *);
-extern int re_search_2 (struct re_pattern_buffer *, char *, int,
- char *, int, int, int,
- struct re_registers *, int);
-extern int re_match (struct re_pattern_buffer *, char *, int, int,
- struct re_registers *);
-extern int re_match_2 (struct re_pattern_buffer *, char *, int,
- char *, int, int, struct re_registers *, int);
-extern long re_set_syntax (long syntax);
-
-#ifndef GAWK
-/* 4.2 bsd compatibility. */
-extern char *re_comp (char *);
-extern int re_exec (char *);
-#endif
-
-#else /* !__STDC__ */
-
-extern char *re_compile_pattern ();
-/* Is this really advertised? */
-extern void re_compile_fastmap ();
-extern int re_search (), re_search_2 ();
-extern int re_match (), re_match_2 ();
-extern long re_set_syntax();
-
-#ifndef GAWK
-/* 4.2 bsd compatibility. */
-extern char *re_comp ();
-extern int re_exec ();
-#endif
-
-#endif /* __STDC__ */
-
-
-#ifdef SYNTAX_TABLE
-extern char *re_syntax_table;
-#endif
-
-#endif /* !__REGEXP_LIBRARY */
diff --git a/gnu/usr.bin/awk/version.c b/gnu/usr.bin/awk/version.c
deleted file mode 100644
index adea5fa..0000000
--- a/gnu/usr.bin/awk/version.c
+++ /dev/null
@@ -1,46 +0,0 @@
-char *version_string = "@(#)Gnu Awk (gawk) 2.15";
-
-/* 1.02 fixed /= += *= etc to return the new Left Hand Side instead
- of the Right Hand Side */
-
-/* 1.03 Fixed split() to treat strings of space and tab as FS if
- the split char is ' '.
-
- Added -v option to print version number
-
- Fixed bug that caused rounding when printing large numbers */
-
-/* 2.00beta Incorporated the functionality of the "new" awk as described
- the book (reference not handy). Extensively tested, but no
- doubt still buggy. Badly needs tuning and cleanup, in
- particular in memory management which is currently almost
- non-existent. */
-
-/* 2.01 JF: Modified to compile under GCC, and fixed a few
- bugs while I was at it. I hope I didn't add any more.
- I modified parse.y to reduce the number of reduce/reduce
- conflicts. There are still a few left. */
-
-/* 2.02 Fixed JF's bugs; improved memory management, still needs
- lots of work. */
-
-/* 2.10 Major grammar rework and lots of bug fixes from David.
- Major changes for performance enhancements from David.
- A number of minor bug fixes and new features from Arnold.
- Changes for MSDOS from Conrad Kwok and Scott Garfinkle.
- The gawk.texinfo and info files included! */
-
-/* 2.11 Bug fix release to 2.10. Lots of changes for portability,
- speed, and configurability. */
-
-/* 2.12 Lots of changes for portability, speed, and configurability.
- Several bugs fixed. POSIX compliance. Removal of last set
- of hard-wired limits. Atari and VMS ports added. */
-
-/* 2.13 Public release of 2.12 */
-
-/* 2.14 Mostly bug fixes. */
-
-/* 2.15 Bug fixes plus intermixing of command-line source and files,
- GNU long options, ARGIND, ERRNO and Plan 9 style /dev/ files. */
-
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 fac7437..0000000
--- a/gnu/usr.bin/bc/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-PROG= bc
-SRCS= bc.c global.c scan.c util.c main.c number.c storage.c load.c execute.c
-MAN1= bc.1
-CFLAGS+= -D_POSIX_SOURCE -I$(.CURDIR)
-
-.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 b387f92..0000000
--- a/gnu/usr.bin/bc/bc.1
+++ /dev/null
@@ -1,730 +0,0 @@
-.\"
-.\" bc.1 - the *roff document processor source for the bc manual
-.\"
-.\" This file is part of bc written for MINIX.
-.\" 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 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
-.\"
-.\"
-.TH bc 1 .\" "Command Manual" v1.02 "Feb 3, 1992"
-.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.02.
-.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 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.
-.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 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
-"b" (bell), "f" (form feed), "n" (newline), "r" (carriage return), "t"
-(tab), and "\e" (backslash). Any other character following the
-backslash will be ignored. This still does not allow the double quote
-character to be part of any string.
-.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 10240 bytes of
-compiled byte code each. This limit (BC_MAX_SEGS) can be easily changed
-to have more than 10 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 (sesv@iwtsf.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.c b/gnu/usr.bin/bc/bc.c
deleted file mode 100644
index 923215e..0000000
--- a/gnu/usr.bin/bc/bc.c
+++ /dev/null
@@ -1,1369 +0,0 @@
-#ifndef lint
-static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
-#endif
-#define YYBYACC 1
-#line 2 "bc.y"
-/* 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 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"
-#line 38 "bc.y"
-typedef union {
- char *s_value;
- char c_value;
- int i_value;
- arg_list *a_value;
- } YYSTYPE;
-#line 46 "y.tab.c"
-#define NEWLINE 257
-#define AND 258
-#define OR 259
-#define NOT 260
-#define STRING 261
-#define NAME 262
-#define NUMBER 263
-#define MUL_OP 264
-#define ASSIGN_OP 265
-#define REL_OP 266
-#define INCR_DECR 267
-#define Define 268
-#define Break 269
-#define Quit 270
-#define Length 271
-#define Return 272
-#define For 273
-#define If 274
-#define While 275
-#define Sqrt 276
-#define Else 277
-#define Scale 278
-#define Ibase 279
-#define Obase 280
-#define Auto 281
-#define Read 282
-#define Warranty 283
-#define Halt 284
-#define Last 285
-#define Continue 286
-#define Print 287
-#define Limits 288
-#define UNARY_MINUS 289
-#define YYERRCODE 256
-short yylhs[] = { -1,
- 0, 0, 10, 10, 10, 11, 11, 11, 11, 12,
- 12, 12, 12, 12, 12, 15, 15, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 16, 17, 18,
- 19, 13, 20, 13, 22, 23, 13, 13, 25, 13,
- 24, 24, 26, 26, 21, 27, 21, 28, 14, 5,
- 5, 6, 6, 6, 7, 7, 7, 7, 8, 8,
- 9, 9, 9, 9, 4, 4, 2, 2, 29, 1,
- 30, 1, 31, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 3, 3, 3, 3, 3, 3,
-};
-short yylen[] = { 2,
- 0, 2, 2, 1, 2, 0, 1, 3, 2, 0,
- 1, 2, 3, 2, 3, 1, 2, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 4, 0, 0, 0,
- 0, 13, 0, 7, 0, 0, 7, 3, 0, 3,
- 1, 3, 1, 1, 0, 0, 3, 0, 12, 0,
- 1, 0, 3, 3, 1, 3, 3, 5, 0, 1,
- 1, 3, 3, 5, 0, 1, 0, 1, 0, 4,
- 0, 4, 0, 4, 2, 3, 3, 3, 3, 3,
- 2, 1, 1, 3, 4, 2, 2, 4, 4, 4,
- 3, 1, 4, 1, 1, 1, 1,
-};
-short yydefred[] = { 1,
- 0, 0, 0, 21, 0, 83, 0, 0, 22, 24,
- 0, 0, 28, 0, 35, 0, 0, 94, 95, 0,
- 18, 25, 97, 23, 39, 19, 0, 0, 0, 0,
- 0, 2, 0, 16, 4, 7, 5, 17, 0, 0,
- 0, 0, 96, 86, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 81, 0, 0, 0, 11, 71,
- 73, 0, 0, 0, 0, 0, 69, 87, 3, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 91, 43, 0, 40, 0, 84,
- 0, 0, 38, 0, 0, 0, 0, 0, 0, 0,
- 0, 8, 0, 85, 0, 93, 0, 0, 0, 88,
- 27, 0, 0, 33, 0, 89, 90, 0, 13, 15,
- 0, 0, 0, 62, 0, 0, 0, 0, 0, 29,
- 0, 0, 42, 0, 56, 0, 0, 0, 0, 0,
- 64, 0, 0, 0, 46, 34, 37, 0, 48, 58,
- 30, 0, 0, 0, 0, 47, 53, 54, 0, 0,
- 0, 31, 49, 0, 32,
-};
-short yydgoto[] = { 1,
- 30, 79, 31, 113, 108, 149, 109, 73, 74, 32,
- 33, 58, 34, 35, 59, 48, 138, 155, 164, 131,
- 146, 50, 132, 88, 54, 89, 152, 154, 101, 94,
- 95,
-};
-short yysindex[] = { 0,
- -7, 58, 212, 0, -22, 0, -233, -241, 0, 0,
- -8, -5, 0, -4, 0, 2, 4, 0, 0, 9,
- 0, 0, 0, 0, 0, 0, 212, 212, 91, 725,
- -240, 0, -29, 0, 0, 0, 0, 0, 84, 245,
- 212, -57, 0, 0, 10, 212, 212, 14, 212, 16,
- 212, 212, 23, 156, 0, 549, 127, -52, 0, 0,
- 0, 212, 212, 212, 212, 212, 0, 0, 0, 91,
- -17, 725, 24, -3, 578, -205, 562, 725, 27, 212,
- 606, 212, 669, 716, 0, 0, 725, 0, 19, 0,
- 91, 127, 0, 212, 212, -36, -39, -91, -91, -36,
- 212, 0, 166, 0, 277, 0, -21, 36, 40, 0,
- 0, 725, 28, 0, 725, 0, 0, 156, 0, 0,
- 84, 540, -39, 0, -9, 725, -2, -37, -174, 0,
- 127, 48, 0, 346, 0, -167, 3, 212, -185, 127,
- 0, -188, 6, 37, 0, 0, 0, -205, 0, 0,
- 0, 127, -42, 91, 212, 0, 0, 0, -20, 54,
- 26, 0, 0, 127, 0,
-};
-short yyrindex[] = { 0,
- -16, 0, 0, 0, 409, 0, 0, 0, 0, 0,
- 0, -58, 0, 0, 0, 0, 426, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, -50, 46,
- 470, 0, 0, 0, 0, 0, 0, 0, 661, 56,
- 0, 525, 0, 0, 0, 0, 59, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -6,
- 705, 7, 0, 60, 0, 61, 0, 63, 0, 49,
- 0, 0, 0, 0, 0, 0, 17, 0, 78, 0,
- -47, -45, 0, 0, 0, 537, 440, 620, 637, 594,
- 0, 0, 0, 0, 0, 0, -33, 0, 66, 0,
- 0, -19, 0, 0, 68, 0, 0, 0, 0, 0,
- 667, 680, 508, 0, 705, 18, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -31, 49, -44, 0,
- 0, -40, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 69, 0, 0, 0, 0, 0,
- 13, 0, 0, 0, 0,
-};
-short yygindex[] = { 0,
- 958, 0, 104, -118, 0, 0, -35, 0, 0, 0,
- 0, -34, 22, 0, 15, 0, 0, 0, 0, 0,
- 0, 0, 0, -1, 0, 0, 0, 0, 0, 0,
- 0,
-};
-#define YYTABLESIZE 1113
-short yytable[] = { 52,
- 26, 129, 66, 64, 52, 65, 92, 55, 10, 57,
- 55, 12, 57, 14, 45, 36, 158, 40, 52, 144,
- 45, 66, 40, 38, 67, 55, 68, 57, 42, 70,
- 40, 46, 28, 41, 47, 49, 160, 27, 92, 66,
- 105, 51, 6, 52, 43, 18, 19, 61, 53, 76,
- 61, 23, 9, 80, 66, 82, 107, 66, 63, 10,
- 44, 63, 118, 85, 104, 28, 26, 111, 41, 127,
- 27, 12, 93, 103, 10, 44, 128, 12, 38, 14,
- 45, 134, 52, 129, 102, 136, 130, 137, 140, 142,
- 135, 145, 148, 143, 162, 151, 59, 28, 150, 67,
- 60, 50, 27, 68, 20, 119, 51, 65, 36, 65,
- 44, 0, 153, 120, 0, 29, 133, 0, 0, 159,
- 0, 0, 0, 0, 0, 0, 64, 0, 65, 0,
- 28, 0, 0, 0, 0, 27, 41, 0, 0, 0,
- 0, 44, 0, 0, 0, 0, 0, 0, 29, 0,
- 163, 0, 139, 0, 0, 0, 0, 0, 0, 0,
- 0, 147, 0, 0, 0, 0, 28, 0, 0, 0,
- 20, 27, 62, 156, 0, 119, 0, 66, 0, 0,
- 29, 0, 0, 0, 0, 165, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 28, 0, 0, 26, 0,
- 27, 0, 41, 0, 91, 28, 10, 0, 0, 12,
- 27, 14, 45, 29, 157, 52, 52, 0, 26, 52,
- 52, 52, 52, 55, 62, 57, 52, 69, 52, 52,
- 52, 52, 52, 52, 52, 52, 161, 52, 52, 52,
- 6, 52, 52, 52, 52, 52, 52, 52, 2, 29,
- 9, 28, 3, 4, 5, 6, 27, 10, 124, 7,
- 8, 9, 10, 11, 12, 13, 14, 15, 16, 12,
- 17, 18, 19, 44, 20, 21, 22, 23, 24, 25,
- 26, 57, 0, 0, 28, 3, 4, 5, 6, 27,
- 0, 0, 7, 44, 9, 10, 11, 12, 13, 14,
- 15, 16, 20, 17, 18, 19, 0, 20, 21, 22,
- 23, 24, 25, 26, 37, 0, 28, 3, 4, 5,
- 6, 27, 20, 0, 7, 0, 9, 10, 11, 12,
- 13, 14, 15, 16, 41, 17, 18, 19, 0, 20,
- 21, 22, 23, 24, 25, 26, 57, 62, 0, 63,
- 3, 4, 5, 6, 41, 0, 0, 7, 0, 9,
- 10, 11, 12, 13, 14, 15, 16, 0, 17, 18,
- 19, 0, 20, 21, 22, 23, 24, 25, 26, 0,
- 0, 0, 0, 0, 0, 28, 3, 4, 5, 6,
- 27, 0, 0, 7, 0, 9, 10, 11, 12, 13,
- 14, 15, 16, 0, 17, 18, 19, 0, 20, 21,
- 22, 23, 24, 25, 26, 3, 86, 5, 6, 0,
- 0, 0, 7, 0, 0, 3, 11, 5, 6, 0,
- 0, 16, 7, 17, 18, 19, 11, 20, 141, 0,
- 23, 16, 0, 17, 18, 19, 0, 20, 0, 92,
- 23, 92, 92, 92, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 96, 92, 96, 96,
- 96, 3, 0, 5, 6, 0, 0, 0, 7, 0,
- 76, 0, 11, 76, 96, 0, 0, 16, 0, 17,
- 18, 19, 0, 20, 0, 0, 23, 0, 76, 0,
- 0, 92, 92, 0, 3, 0, 71, 6, 0, 0,
- 82, 7, 82, 82, 82, 11, 0, 0, 96, 96,
- 16, 0, 17, 18, 19, 0, 20, 0, 82, 23,
- 0, 0, 76, 92, 0, 0, 3, 0, 125, 6,
- 0, 0, 0, 7, 0, 0, 0, 11, 70, 0,
- 96, 70, 16, 0, 17, 18, 19, 0, 20, 0,
- 0, 23, 82, 82, 76, 92, 70, 92, 92, 92,
- 0, 0, 0, 0, 0, 0, 0, 79, 0, 79,
- 79, 79, 64, 92, 65, 0, 0, 0, 0, 90,
- 0, 64, 0, 65, 82, 79, 0, 0, 0, 0,
- 70, 0, 110, 0, 64, 3, 65, 5, 6, 0,
- 0, 0, 7, 0, 0, 0, 11, 92, 92, 0,
- 64, 16, 65, 17, 18, 19, 0, 20, 0, 79,
- 23, 0, 70, 66, 80, 0, 80, 80, 80, 0,
- 0, 0, 66, 0, 0, 0, 114, 0, 64, 92,
- 65, 0, 80, 0, 0, 66, 0, 0, 0, 0,
- 77, 79, 77, 77, 77, 92, 92, 92, 0, 0,
- 106, 66, 92, 92, 92, 92, 0, 78, 77, 78,
- 78, 78, 96, 96, 96, 92, 80, 0, 0, 96,
- 96, 96, 96, 0, 0, 78, 76, 76, 76, 66,
- 0, 75, 96, 0, 75, 76, 0, 72, 0, 116,
- 72, 64, 77, 65, 0, 0, 76, 0, 80, 75,
- 74, 0, 0, 74, 0, 72, 82, 82, 82, 78,
- 0, 0, 0, 82, 0, 82, 0, 0, 74, 0,
- 0, 0, 0, 0, 77, 92, 82, 92, 92, 92,
- 0, 0, 0, 75, 0, 0, 117, 0, 64, 72,
- 65, 78, 66, 0, 70, 70, 70, 64, 0, 65,
- 0, 0, 74, 70, 0, 0, 0, 0, 0, 0,
- 0, 92, 92, 92, 70, 75, 0, 0, 92, 0,
- 92, 72, 0, 79, 79, 79, 0, 60, 92, 0,
- 79, 92, 79, 62, 74, 63, 60, 61, 0, 66,
- 0, 0, 62, 79, 63, 0, 0, 0, 66, 60,
- 61, 0, 0, 0, 0, 62, 0, 63, 0, 0,
- 0, 0, 0, 0, 0, 60, 61, 0, 0, 0,
- 0, 62, 0, 63, 0, 0, 0, 0, 0, 0,
- 80, 80, 80, 0, 0, 0, 0, 80, 0, 80,
- 0, 0, 0, 60, 61, 0, 0, 0, 0, 62,
- 80, 63, 0, 0, 0, 0, 77, 77, 77, 0,
- 0, 0, 0, 0, 0, 77, 0, 0, 0, 0,
- 0, 0, 0, 78, 78, 78, 77, 0, 0, 0,
- 0, 0, 78, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 78, 0, 0, 0, 75, 75, 75,
- 0, 0, 0, 72, 72, 72, 60, 61, 0, 0,
- 0, 0, 62, 0, 63, 0, 74, 75, 74, 0,
- 0, 0, 0, 72, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 74, 0, 0, 0,
- 39, 0, 92, 92, 0, 0, 0, 0, 92, 92,
- 92, 92, 0, 60, 61, 0, 0, 0, 0, 62,
- 0, 63, 60, 61, 55, 56, 0, 0, 62, 0,
- 63, 0, 0, 0, 0, 0, 0, 72, 75, 0,
- 0, 0, 0, 77, 78, 0, 81, 0, 83, 84,
- 0, 87, 0, 0, 0, 0, 0, 0, 0, 96,
- 97, 98, 99, 100, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 112, 0, 115,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 121, 122, 0, 0, 0, 0, 0, 123, 0,
- 75, 0, 126, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 87, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 75, 0, 0, 0, 112, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 112,
-};
-short yycheck[] = { 40,
- 59, 44, 94, 43, 45, 45, 59, 41, 59, 41,
- 44, 59, 44, 59, 59, 1, 59, 40, 59, 138,
- 262, 41, 40, 2, 265, 59, 267, 59, 262, 59,
- 40, 40, 40, 91, 40, 40, 155, 45, 59, 59,
- 44, 40, 59, 40, 278, 279, 280, 41, 40, 40,
- 44, 285, 59, 40, 94, 40, 262, 94, 41, 59,
- 44, 44, 44, 41, 41, 40, 125, 41, 91, 91,
- 45, 59, 125, 91, 125, 59, 41, 125, 57, 125,
- 125, 91, 123, 44, 70, 123, 59, 262, 41, 257,
- 93, 277, 281, 91, 41, 59, 41, 40, 93, 41,
- 41, 41, 45, 41, 59, 91, 41, 59, 41, 41,
- 7, -1, 148, 92, -1, 123, 118, -1, -1, 154,
- -1, -1, -1, -1, -1, -1, 43, -1, 45, -1,
- 40, -1, -1, -1, -1, 45, 59, -1, -1, -1,
- -1, 125, -1, -1, -1, -1, -1, -1, 123, -1,
- 125, -1, 131, -1, -1, -1, -1, -1, -1, -1,
- -1, 140, -1, -1, -1, -1, 40, -1, -1, -1,
- 125, 45, 264, 152, -1, 161, -1, 94, -1, -1,
- 123, -1, -1, -1, -1, 164, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 40, -1, -1, 257, -1,
- 45, -1, 125, -1, 257, 40, 257, -1, -1, 257,
- 45, 257, 257, 123, 257, 256, 257, -1, 277, 260,
- 261, 262, 263, 257, 264, 257, 267, 257, 269, 270,
- 271, 272, 273, 274, 275, 276, 257, 278, 279, 280,
- 257, 282, 283, 284, 285, 286, 287, 288, 256, 123,
- 257, 40, 260, 261, 262, 263, 45, 257, 93, 267,
- 268, 269, 270, 271, 272, 273, 274, 275, 276, 257,
- 278, 279, 280, 257, 282, 283, 284, 285, 286, 287,
- 288, 256, -1, -1, 40, 260, 261, 262, 263, 45,
- -1, -1, 267, 277, 269, 270, 271, 272, 273, 274,
- 275, 276, 257, 278, 279, 280, -1, 282, 283, 284,
- 285, 286, 287, 288, 257, -1, 40, 260, 261, 262,
- 263, 45, 277, -1, 267, -1, 269, 270, 271, 272,
- 273, 274, 275, 276, 257, 278, 279, 280, -1, 282,
- 283, 284, 285, 286, 287, 288, 256, 264, -1, 266,
- 260, 261, 262, 263, 277, -1, -1, 267, -1, 269,
- 270, 271, 272, 273, 274, 275, 276, -1, 278, 279,
- 280, -1, 282, 283, 284, 285, 286, 287, 288, -1,
- -1, -1, -1, -1, -1, 40, 260, 261, 262, 263,
- 45, -1, -1, 267, -1, 269, 270, 271, 272, 273,
- 274, 275, 276, -1, 278, 279, 280, -1, 282, 283,
- 284, 285, 286, 287, 288, 260, 261, 262, 263, -1,
- -1, -1, 267, -1, -1, 260, 271, 262, 263, -1,
- -1, 276, 267, 278, 279, 280, 271, 282, 93, -1,
- 285, 276, -1, 278, 279, 280, -1, 282, -1, 41,
- 285, 43, 44, 45, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 41, 59, 43, 44,
- 45, 260, -1, 262, 263, -1, -1, -1, 267, -1,
- 41, -1, 271, 44, 59, -1, -1, 276, -1, 278,
- 279, 280, -1, 282, -1, -1, 285, -1, 59, -1,
- -1, 93, 94, -1, 260, -1, 262, 263, -1, -1,
- 41, 267, 43, 44, 45, 271, -1, -1, 93, 94,
- 276, -1, 278, 279, 280, -1, 282, -1, 59, 285,
- -1, -1, 93, 125, -1, -1, 260, -1, 262, 263,
- -1, -1, -1, 267, -1, -1, -1, 271, 41, -1,
- 125, 44, 276, -1, 278, 279, 280, -1, 282, -1,
- -1, 285, 93, 94, 125, 41, 59, 43, 44, 45,
- -1, -1, -1, -1, -1, -1, -1, 41, -1, 43,
- 44, 45, 43, 59, 45, -1, -1, -1, -1, 41,
- -1, 43, -1, 45, 125, 59, -1, -1, -1, -1,
- 93, -1, 41, -1, 43, 260, 45, 262, 263, -1,
- -1, -1, 267, -1, -1, -1, 271, 93, 94, -1,
- 43, 276, 45, 278, 279, 280, -1, 282, -1, 93,
- 285, -1, 125, 94, 41, -1, 43, 44, 45, -1,
- -1, -1, 94, -1, -1, -1, 41, -1, 43, 125,
- 45, -1, 59, -1, -1, 94, -1, -1, -1, -1,
- 41, 125, 43, 44, 45, 257, 258, 259, -1, -1,
- 93, 94, 264, 265, 266, 267, -1, 41, 59, 43,
- 44, 45, 257, 258, 259, 277, 93, -1, -1, 264,
- 265, 266, 267, -1, -1, 59, 257, 258, 259, 94,
- -1, 41, 277, -1, 44, 266, -1, 41, -1, 41,
- 44, 43, 93, 45, -1, -1, 277, -1, 125, 59,
- 41, -1, -1, 44, -1, 59, 257, 258, 259, 93,
- -1, -1, -1, 264, -1, 266, -1, -1, 59, -1,
- -1, -1, -1, -1, 125, 41, 277, 43, 44, 45,
- -1, -1, -1, 93, -1, -1, 41, -1, 43, 93,
- 45, 125, 94, -1, 257, 258, 259, 43, -1, 45,
- -1, -1, 93, 266, -1, -1, -1, -1, -1, -1,
- -1, 257, 258, 259, 277, 125, -1, -1, 264, -1,
- 266, 125, -1, 257, 258, 259, -1, 258, 94, -1,
- 264, 277, 266, 264, 125, 266, 258, 259, -1, 94,
- -1, -1, 264, 277, 266, -1, -1, -1, 94, 258,
- 259, -1, -1, -1, -1, 264, -1, 266, -1, -1,
- -1, -1, -1, -1, -1, 258, 259, -1, -1, -1,
- -1, 264, -1, 266, -1, -1, -1, -1, -1, -1,
- 257, 258, 259, -1, -1, -1, -1, 264, -1, 266,
- -1, -1, -1, 258, 259, -1, -1, -1, -1, 264,
- 277, 266, -1, -1, -1, -1, 257, 258, 259, -1,
- -1, -1, -1, -1, -1, 266, -1, -1, -1, -1,
- -1, -1, -1, 257, 258, 259, 277, -1, -1, -1,
- -1, -1, 266, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 277, -1, -1, -1, 257, 258, 259,
- -1, -1, -1, 257, 258, 259, 258, 259, -1, -1,
- -1, -1, 264, -1, 266, -1, 257, 277, 259, -1,
- -1, -1, -1, 277, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 277, -1, -1, -1,
- 3, -1, 258, 259, -1, -1, -1, -1, 264, 265,
- 266, 267, -1, 258, 259, -1, -1, -1, -1, 264,
- -1, 266, 258, 259, 27, 28, -1, -1, 264, -1,
- 266, -1, -1, -1, -1, -1, -1, 40, 41, -1,
- -1, -1, -1, 46, 47, -1, 49, -1, 51, 52,
- -1, 54, -1, -1, -1, -1, -1, -1, -1, 62,
- 63, 64, 65, 66, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 80, -1, 82,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 94, 95, -1, -1, -1, -1, -1, 101, -1,
- 103, -1, 105, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 118, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 134, -1, -1, -1, 138, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 155,
-};
-#define YYFINAL 1
-#ifndef YYDEBUG
-#define YYDEBUG 0
-#endif
-#define YYMAXTOKEN 289
-#if YYDEBUG
-char *yyname[] = {
-"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,"'('","')'",0,"'+'","','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,"NEWLINE","AND","OR","NOT","STRING","NAME","NUMBER","MUL_OP",
-"ASSIGN_OP","REL_OP","INCR_DECR","Define","Break","Quit","Length","Return",
-"For","If","While","Sqrt","Else","Scale","Ibase","Obase","Auto","Read",
-"Warranty","Halt","Last","Continue","Print","Limits","UNARY_MINUS",
-};
-char *yyrule[] = {
-"$accept : program",
-"program :",
-"program : program input_item",
-"input_item : semicolon_list NEWLINE",
-"input_item : function",
-"input_item : error NEWLINE",
-"semicolon_list :",
-"semicolon_list : statement_or_error",
-"semicolon_list : semicolon_list ';' statement_or_error",
-"semicolon_list : semicolon_list ';'",
-"statement_list :",
-"statement_list : statement_or_error",
-"statement_list : statement_list NEWLINE",
-"statement_list : statement_list NEWLINE statement_or_error",
-"statement_list : statement_list ';'",
-"statement_list : statement_list ';' statement",
-"statement_or_error : statement",
-"statement_or_error : error statement",
-"statement : Warranty",
-"statement : Limits",
-"statement : expression",
-"statement : STRING",
-"statement : Break",
-"statement : Continue",
-"statement : Quit",
-"statement : Halt",
-"statement : Return",
-"statement : Return '(' return_expression ')'",
-"$$1 :",
-"$$2 :",
-"$$3 :",
-"$$4 :",
-"statement : For $$1 '(' opt_expression ';' $$2 opt_expression ';' $$3 opt_expression ')' $$4 statement",
-"$$5 :",
-"statement : If '(' expression ')' $$5 statement opt_else",
-"$$6 :",
-"$$7 :",
-"statement : While $$6 '(' expression $$7 ')' statement",
-"statement : '{' statement_list '}'",
-"$$8 :",
-"statement : Print $$8 print_list",
-"print_list : print_element",
-"print_list : print_element ',' print_list",
-"print_element : STRING",
-"print_element : expression",
-"opt_else :",
-"$$9 :",
-"opt_else : Else $$9 statement",
-"$$10 :",
-"function : Define NAME '(' opt_parameter_list ')' '{' NEWLINE opt_auto_define_list $$10 statement_list NEWLINE '}'",
-"opt_parameter_list :",
-"opt_parameter_list : define_list",
-"opt_auto_define_list :",
-"opt_auto_define_list : Auto define_list NEWLINE",
-"opt_auto_define_list : Auto define_list ';'",
-"define_list : NAME",
-"define_list : NAME '[' ']'",
-"define_list : define_list ',' NAME",
-"define_list : define_list ',' NAME '[' ']'",
-"opt_argument_list :",
-"opt_argument_list : argument_list",
-"argument_list : expression",
-"argument_list : NAME '[' ']'",
-"argument_list : argument_list ',' expression",
-"argument_list : argument_list ',' NAME '[' ']'",
-"opt_expression :",
-"opt_expression : expression",
-"return_expression :",
-"return_expression : expression",
-"$$11 :",
-"expression : named_expression ASSIGN_OP $$11 expression",
-"$$12 :",
-"expression : expression AND $$12 expression",
-"$$13 :",
-"expression : expression OR $$13 expression",
-"expression : NOT expression",
-"expression : expression REL_OP expression",
-"expression : expression '+' expression",
-"expression : expression '-' expression",
-"expression : expression MUL_OP expression",
-"expression : expression '^' expression",
-"expression : '-' expression",
-"expression : named_expression",
-"expression : NUMBER",
-"expression : '(' expression ')'",
-"expression : NAME '(' opt_argument_list ')'",
-"expression : INCR_DECR named_expression",
-"expression : named_expression INCR_DECR",
-"expression : Length '(' expression ')'",
-"expression : Sqrt '(' expression ')'",
-"expression : Scale '(' expression ')'",
-"expression : Read '(' ')'",
-"named_expression : NAME",
-"named_expression : NAME '[' expression ']'",
-"named_expression : Ibase",
-"named_expression : Obase",
-"named_expression : Scale",
-"named_expression : Last",
-};
-#endif
-#define yyclearin (yychar=(-1))
-#define yyerrok (yyerrflag=0)
-#ifdef YYSTACKSIZE
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH YYSTACKSIZE
-#endif
-#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
-#define YYABORT 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("yydebug: state %d, reading %d (%s)\n", yystate,
- yychar, yys);
- }
-#endif
- }
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
-#if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, shifting to state %d\n",
- 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("yydebug: state %d, error recovery shifting\
- to state %d\n", *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("yydebug: error recovery discarding state %d\n",
- *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("yydebug: state %d, error recovery discards token %d (%s)\n",
- yystate, yychar, yys);
- }
-#endif
- yychar = (-1);
- goto yyloop;
- }
-yyreduce:
-#if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, reducing by rule %d (%s)\n",
- yystate, yyn, yyrule[yyn]);
-#endif
- yym = yylen[yyn];
- yyval = yyvsp[1-yym];
- switch (yyn)
- {
-case 1:
-#line 106 "bc.y"
-{
- yyval.i_value = 0;
- if (interactive)
- {
- printf ("%s\n", BC_VERSION);
- welcome ();
- }
- }
-break;
-case 3:
-#line 117 "bc.y"
-{ run_code (); }
-break;
-case 4:
-#line 119 "bc.y"
-{ run_code (); }
-break;
-case 5:
-#line 121 "bc.y"
-{
- yyerrok;
- init_gen ();
- }
-break;
-case 6:
-#line 127 "bc.y"
-{ yyval.i_value = 0; }
-break;
-case 10:
-#line 133 "bc.y"
-{ yyval.i_value = 0; }
-break;
-case 17:
-#line 142 "bc.y"
-{ yyval.i_value = yyvsp[0].i_value; }
-break;
-case 18:
-#line 145 "bc.y"
-{ warranty (""); }
-break;
-case 19:
-#line 147 "bc.y"
-{ limits (); }
-break;
-case 20:
-#line 149 "bc.y"
-{
- if (yyvsp[0].i_value & 2)
- warn ("comparison in expression");
- if (yyvsp[0].i_value & 1)
- generate ("W");
- else
- generate ("p");
- }
-break;
-case 21:
-#line 158 "bc.y"
-{
- yyval.i_value = 0;
- generate ("w");
- generate (yyvsp[0].s_value);
- free (yyvsp[0].s_value);
- }
-break;
-case 22:
-#line 165 "bc.y"
-{
- if (break_label == 0)
- yyerror ("Break outside a for/while");
- else
- {
- sprintf (genstr, "J%1d:", break_label);
- generate (genstr);
- }
- }
-break;
-case 23:
-#line 175 "bc.y"
-{
- warn ("Continue statement");
- if (continue_label == 0)
- yyerror ("Continue outside a for");
- else
- {
- sprintf (genstr, "J%1d:", continue_label);
- generate (genstr);
- }
- }
-break;
-case 24:
-#line 186 "bc.y"
-{ exit (0); }
-break;
-case 25:
-#line 188 "bc.y"
-{ generate ("h"); }
-break;
-case 26:
-#line 190 "bc.y"
-{ generate ("0R"); }
-break;
-case 27:
-#line 192 "bc.y"
-{ generate ("R"); }
-break;
-case 28:
-#line 194 "bc.y"
-{
- yyvsp[0].i_value = break_label;
- break_label = next_label++;
- }
-break;
-case 29:
-#line 199 "bc.y"
-{
- if (yyvsp[-1].i_value > 1)
- warn ("Comparison in first for expression");
- yyvsp[-1].i_value = next_label++;
- if (yyvsp[-1].i_value < 0)
- sprintf (genstr, "N%1d:", yyvsp[-1].i_value);
- else
- sprintf (genstr, "pN%1d:", yyvsp[-1].i_value);
- generate (genstr);
- }
-break;
-case 30:
-#line 210 "bc.y"
-{
- if (yyvsp[-1].i_value < 0) generate ("1");
- yyvsp[-1].i_value = next_label++;
- sprintf (genstr, "B%1d:J%1d:", yyvsp[-1].i_value, break_label);
- generate (genstr);
- yyval.i_value = continue_label;
- continue_label = next_label++;
- sprintf (genstr, "N%1d:", continue_label);
- generate (genstr);
- }
-break;
-case 31:
-#line 221 "bc.y"
-{
- if (yyvsp[-1].i_value > 1)
- warn ("Comparison in third for expression");
- if (yyvsp[-1].i_value < 0)
- sprintf (genstr, "J%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value);
- else
- sprintf (genstr, "pJ%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value);
- generate (genstr);
- }
-break;
-case 32:
-#line 231 "bc.y"
-{
- sprintf (genstr, "J%1d:N%1d:",
- continue_label, break_label);
- generate (genstr);
- break_label = yyvsp[-12].i_value;
- continue_label = yyvsp[-4].i_value;
- }
-break;
-case 33:
-#line 239 "bc.y"
-{
- yyvsp[-1].i_value = if_label;
- if_label = next_label++;
- sprintf (genstr, "Z%1d:", if_label);
- generate (genstr);
- }
-break;
-case 34:
-#line 246 "bc.y"
-{
- sprintf (genstr, "N%1d:", if_label);
- generate (genstr);
- if_label = yyvsp[-4].i_value;
- }
-break;
-case 35:
-#line 252 "bc.y"
-{
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "N%1d:", yyvsp[0].i_value);
- generate (genstr);
- }
-break;
-case 36:
-#line 258 "bc.y"
-{
- yyvsp[0].i_value = break_label;
- break_label = next_label++;
- sprintf (genstr, "Z%1d:", break_label);
- generate (genstr);
- }
-break;
-case 37:
-#line 265 "bc.y"
-{
- sprintf (genstr, "J%1d:N%1d:", yyvsp[-6].i_value, break_label);
- generate (genstr);
- break_label = yyvsp[-3].i_value;
- }
-break;
-case 38:
-#line 271 "bc.y"
-{ yyval.i_value = 0; }
-break;
-case 39:
-#line 273 "bc.y"
-{ warn ("print statement"); }
-break;
-case 43:
-#line 280 "bc.y"
-{
- generate ("O");
- generate (yyvsp[0].s_value);
- free (yyvsp[0].s_value);
- }
-break;
-case 44:
-#line 286 "bc.y"
-{ generate ("P"); }
-break;
-case 46:
-#line 290 "bc.y"
-{
- warn ("else clause in if statement");
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "J%d:N%1d:", yyvsp[0].i_value, if_label);
- generate (genstr);
- if_label = yyvsp[0].i_value;
- }
-break;
-case 48:
-#line 300 "bc.y"
-{
- /* Check auto list against parameter list? */
- check_params (yyvsp[-4].a_value,yyvsp[0].a_value);
- sprintf (genstr, "F%d,%s.%s[", lookup(yyvsp[-6].s_value,FUNCT),
- arg_str (yyvsp[-4].a_value,TRUE), arg_str (yyvsp[0].a_value,TRUE));
- generate (genstr);
- free_args (yyvsp[-4].a_value);
- free_args (yyvsp[0].a_value);
- yyvsp[-7].i_value = next_label;
- next_label = 0;
- }
-break;
-case 49:
-#line 312 "bc.y"
-{
- generate ("0R]");
- next_label = yyvsp[-11].i_value;
- }
-break;
-case 50:
-#line 318 "bc.y"
-{ yyval.a_value = NULL; }
-break;
-case 52:
-#line 322 "bc.y"
-{ yyval.a_value = NULL; }
-break;
-case 53:
-#line 324 "bc.y"
-{ yyval.a_value = yyvsp[-1].a_value; }
-break;
-case 54:
-#line 326 "bc.y"
-{ yyval.a_value = yyvsp[-1].a_value; }
-break;
-case 55:
-#line 329 "bc.y"
-{ yyval.a_value = nextarg (NULL, lookup (yyvsp[0].s_value,SIMPLE)); }
-break;
-case 56:
-#line 331 "bc.y"
-{ yyval.a_value = nextarg (NULL, lookup (yyvsp[-2].s_value,ARRAY)); }
-break;
-case 57:
-#line 333 "bc.y"
-{ yyval.a_value = nextarg (yyvsp[-2].a_value, lookup (yyvsp[0].s_value,SIMPLE)); }
-break;
-case 58:
-#line 335 "bc.y"
-{ yyval.a_value = nextarg (yyvsp[-4].a_value, lookup (yyvsp[-2].s_value,ARRAY)); }
-break;
-case 59:
-#line 338 "bc.y"
-{ yyval.a_value = NULL; }
-break;
-case 61:
-#line 342 "bc.y"
-{
- if (yyvsp[0].i_value > 1) warn ("comparison in argument");
- yyval.a_value = nextarg (NULL,0);
- }
-break;
-case 62:
-#line 347 "bc.y"
-{
- sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY));
- generate (genstr);
- yyval.a_value = nextarg (NULL,1);
- }
-break;
-case 63:
-#line 353 "bc.y"
-{
- if (yyvsp[0].i_value > 1) warn ("comparison in argument");
- yyval.a_value = nextarg (yyvsp[-2].a_value,0);
- }
-break;
-case 64:
-#line 358 "bc.y"
-{
- sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY));
- generate (genstr);
- yyval.a_value = nextarg (yyvsp[-4].a_value,1);
- }
-break;
-case 65:
-#line 365 "bc.y"
-{
- yyval.i_value = -1;
- warn ("Missing expression in for statement");
- }
-break;
-case 67:
-#line 372 "bc.y"
-{
- yyval.i_value = 0;
- generate ("0");
- }
-break;
-case 68:
-#line 377 "bc.y"
-{
- if (yyvsp[0].i_value > 1)
- warn ("comparison in return expresion");
- }
-break;
-case 69:
-#line 383 "bc.y"
-{
- if (yyvsp[0].c_value != '=')
- {
- if (yyvsp[-1].i_value < 0)
- sprintf (genstr, "DL%d:", -yyvsp[-1].i_value);
- else
- sprintf (genstr, "l%d:", yyvsp[-1].i_value);
- generate (genstr);
- }
- }
-break;
-case 70:
-#line 394 "bc.y"
-{
- if (yyvsp[0].i_value > 1) warn("comparison in assignment");
- if (yyvsp[-2].c_value != '=')
- {
- sprintf (genstr, "%c", yyvsp[-2].c_value);
- generate (genstr);
- }
- if (yyvsp[-3].i_value < 0)
- sprintf (genstr, "S%d:", -yyvsp[-3].i_value);
- else
- sprintf (genstr, "s%d:", yyvsp[-3].i_value);
- generate (genstr);
- yyval.i_value = 0;
- }
-break;
-case 71:
-#line 410 "bc.y"
-{
- warn("&& operator");
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "DZ%d:p", yyvsp[0].i_value);
- generate (genstr);
- }
-break;
-case 72:
-#line 417 "bc.y"
-{
- sprintf (genstr, "DZ%d:p1N%d:", yyvsp[-2].i_value, yyvsp[-2].i_value);
- generate (genstr);
- yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value;
- }
-break;
-case 73:
-#line 423 "bc.y"
-{
- warn("|| operator");
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "B%d:", yyvsp[0].i_value);
- generate (genstr);
- }
-break;
-case 74:
-#line 430 "bc.y"
-{
- int tmplab;
- tmplab = next_label++;
- sprintf (genstr, "B%d:0J%d:N%d:1N%d:",
- yyvsp[-2].i_value, tmplab, yyvsp[-2].i_value, tmplab);
- generate (genstr);
- yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value;
- }
-break;
-case 75:
-#line 439 "bc.y"
-{
- yyval.i_value = yyvsp[0].i_value;
- warn("! operator");
- generate ("!");
- }
-break;
-case 76:
-#line 445 "bc.y"
-{
- yyval.i_value = 3;
- switch (*(yyvsp[-1].s_value))
- {
- case '=':
- generate ("=");
- break;
-
- case '!':
- generate ("#");
- break;
-
- case '<':
- if (yyvsp[-1].s_value[1] == '=')
- generate ("{");
- else
- generate ("<");
- break;
-
- case '>':
- if (yyvsp[-1].s_value[1] == '=')
- generate ("}");
- else
- generate (">");
- break;
- }
- }
-break;
-case 77:
-#line 473 "bc.y"
-{
- generate ("+");
- yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
- }
-break;
-case 78:
-#line 478 "bc.y"
-{
- generate ("-");
- yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
- }
-break;
-case 79:
-#line 483 "bc.y"
-{
- genstr[0] = yyvsp[-1].c_value;
- genstr[1] = 0;
- generate (genstr);
- yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
- }
-break;
-case 80:
-#line 490 "bc.y"
-{
- generate ("^");
- yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
- }
-break;
-case 81:
-#line 495 "bc.y"
-{
- generate ("n");
- yyval.i_value = yyvsp[0].i_value;
- }
-break;
-case 82:
-#line 500 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[0].i_value < 0)
- sprintf (genstr, "L%d:", -yyvsp[0].i_value);
- else
- sprintf (genstr, "l%d:", yyvsp[0].i_value);
- generate (genstr);
- }
-break;
-case 83:
-#line 509 "bc.y"
-{
- int len = strlen(yyvsp[0].s_value);
- yyval.i_value = 1;
- if (len == 1 && *yyvsp[0].s_value == '0')
- generate ("0");
- else if (len == 1 && *yyvsp[0].s_value == '1')
- generate ("1");
- else
- {
- generate ("K");
- generate (yyvsp[0].s_value);
- generate (":");
- }
- free (yyvsp[0].s_value);
- }
-break;
-case 84:
-#line 525 "bc.y"
-{ yyval.i_value = yyvsp[-1].i_value | 1; }
-break;
-case 85:
-#line 527 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[-1].a_value != NULL)
- {
- sprintf (genstr, "C%d,%s:",
- lookup (yyvsp[-3].s_value,FUNCT),
- arg_str (yyvsp[-1].a_value,FALSE));
- free_args (yyvsp[-1].a_value);
- }
- else
- {
- sprintf (genstr, "C%d:", lookup (yyvsp[-3].s_value,FUNCT));
- }
- generate (genstr);
- }
-break;
-case 86:
-#line 543 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[0].i_value < 0)
- {
- if (yyvsp[-1].c_value == '+')
- sprintf (genstr, "DA%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value);
- else
- sprintf (genstr, "DM%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value);
- }
- else
- {
- if (yyvsp[-1].c_value == '+')
- sprintf (genstr, "i%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value);
- else
- sprintf (genstr, "d%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value);
- }
- generate (genstr);
- }
-break;
-case 87:
-#line 562 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[-1].i_value < 0)
- {
- sprintf (genstr, "DL%d:x", -yyvsp[-1].i_value);
- generate (genstr);
- if (yyvsp[0].c_value == '+')
- sprintf (genstr, "A%d:", -yyvsp[-1].i_value);
- else
- sprintf (genstr, "M%d:", -yyvsp[-1].i_value);
- }
- else
- {
- sprintf (genstr, "l%d:", yyvsp[-1].i_value);
- generate (genstr);
- if (yyvsp[0].c_value == '+')
- sprintf (genstr, "i%d:", yyvsp[-1].i_value);
- else
- sprintf (genstr, "d%d:", yyvsp[-1].i_value);
- }
- generate (genstr);
- }
-break;
-case 88:
-#line 585 "bc.y"
-{ generate ("cL"); yyval.i_value = 1;}
-break;
-case 89:
-#line 587 "bc.y"
-{ generate ("cR"); yyval.i_value = 1;}
-break;
-case 90:
-#line 589 "bc.y"
-{ generate ("cS"); yyval.i_value = 1;}
-break;
-case 91:
-#line 591 "bc.y"
-{
- warn ("read function");
- generate ("cI"); yyval.i_value = 1;
- }
-break;
-case 92:
-#line 597 "bc.y"
-{ yyval.i_value = lookup(yyvsp[0].s_value,SIMPLE); }
-break;
-case 93:
-#line 599 "bc.y"
-{
- if (yyvsp[-1].i_value > 1) warn("comparison in subscript");
- yyval.i_value = lookup(yyvsp[-3].s_value,ARRAY);
- }
-break;
-case 94:
-#line 604 "bc.y"
-{ yyval.i_value = 0; }
-break;
-case 95:
-#line 606 "bc.y"
-{ yyval.i_value = 1; }
-break;
-case 96:
-#line 608 "bc.y"
-{ yyval.i_value = 2; }
-break;
-case 97:
-#line 610 "bc.y"
-{ yyval.i_value = 3; }
-break;
-#line 1314 "y.tab.c"
- }
- yyssp -= yym;
- yystate = *yyssp;
- yyvsp -= yym;
- yym = yylhs[yyn];
- if (yystate == 0 && yym == 0)
- {
-#if YYDEBUG
- if (yydebug)
- printf("yydebug: after reduction, shifting from state 0 to\
- state %d\n", 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("yydebug: state %d, reading %d (%s)\n",
- 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("yydebug: after reduction, shifting from state %d \
-to state %d\n", *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/bc/bcdefs.h b/gnu/usr.bin/bc/bcdefs.h
deleted file mode 100644
index a9d2176..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 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 ea91eaf..0000000
--- a/gnu/usr.bin/bc/const.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* const.h: Constants for bc. */
-
-/* This file is part of bc written for MINIX.
- 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 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
-#define SIMPLE 0
-#define ARRAY 1
-#define FUNCT 2
-#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 a7bc9c7..0000000
--- a/gnu/usr.bin/bc/execute.c
+++ /dev/null
@@ -1,783 +0,0 @@
-/* execute.c - run a bc program. */
-
-/* This file is part of bc written for MINIX.
- 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 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 'n': out_char ('\n'); break;
- case 't': out_char ('\t'); break;
- case 'r': out_char ('\r'); break;
- case 'b': out_char (007); break;
- case 'f': out_char ('\f'); 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 1e7dc1c..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 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 e2b6007..0000000
--- a/gnu/usr.bin/bc/global.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* global.h: The global variables for bc. */
-
-/* This file is part of bc written for MINIX.
- 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 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 current "break level" and if statements. */
-EXTERN int break_label;
-EXTERN int if_label;
-EXTERN int continue_label;
-
-/* Label numbers. */
-EXTERN int next_label;
-
-/* Used for "code" generation. */
-EXTERN char genstr[80];
-EXTERN int out_count;
-EXTERN char did_gen;
-
-/* Interactive and other flags. */
-EXTERN char interactive;
-EXTERN char compile_only;
-EXTERN char use_math;
-EXTERN char warn_not_std;
-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/libmath.b b/gnu/usr.bin/bc/libmath.b
deleted file mode 100644
index 30d9532..0000000
--- a/gnu/usr.bin/bc/libmath.b
+++ /dev/null
@@ -1,255 +0,0 @@
-/* libmath.b for bc for minix. */
-
-/* This file is part of bc written for MINIX.
- 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 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
-
-*************************************************************************/
-
-
-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
- }
-}
-
-/* Natural log. Uses the fact that ln(x^2) = 2*ln(x)
- The series used is:
- ln(x) = 2(a+a^3/3+a^5/5+...) where a=(x-1)/(x+1)
-*/
-
-define l(x) {
- auto e, f, i, m, n, v, z
-
- /* return something for the special case. */
- if (x <= 0) return (1 - 10^scale)
-
- /* Precondition x to make .5 < x < 2.0. */
- z = scale;
- scale += 4;
- f = 2;
- i=0
- while (x >= 2) { /* for large numbers */
- f *= 2;
- x = sqrt(x);
- }
- while (x <= .5) { /* for small numbers */
- f *= 2;
- x = sqrt(x);
- }
-
- /* Set up the loop. */
- v = n = (x-1)/(x+1)
- m = n*n
-
- /* Sum the series. */
- for (i=3; 1; i+=2) {
- e = (n *= m) / i
- if (e == 0) {
- v = f*v
- scale = z
- return (v/1)
- }
- v += e
- }
-}
-
-/* Sin(x) uses the standard series:
- sin(x) = x - x^3/3! + x^5/5! - x^7/7! ... */
-
-define s(x) {
- auto e, i, m, n, s, v, z
-
- /* precondition x. */
- z = scale
- scale = 1.1*z + 1;
- v = a(1)
- if (x < 0) {
- m = 1;
- x = -x;
- }
- scale = 0
- n = (x / v + 2 )/4
- x = x - 4*n*v
- if (n%2) x = -x
-
- /* Do the loop. */
- scale = z + 2;
- v = e = x
- s = -x*x
- for (i=3; 1; i+=2) {
- e *= s/(i*(i-1))
- if (e == 0) {
- scale = z
- if (m) return (-v/1);
- return (v/1);
- }
- v += e
- }
-}
-
-/* Cosine : cos(x) = sin(x+pi/2) */
-define c(x) {
- auto v;
- scale += 1;
- v = s(x+a(1)*2);
- scale -= 1;
- return (v/1);
-}
-
-/* Arctan: Using the formula:
- atan(x) = atan(c) + atan((x-c)/(1+xc)) for a small c (.2 here)
- For under .2, use the series:
- atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... */
-
-define a(x) {
- auto a, e, f, i, m, n, s, v, z
-
- /* Special case and for fast answers */
- if (x==1) {
- if (scale <= 25) return (.7853981633974483096156608/1)
- if (scale <= 40) return (.7853981633974483096156608458198757210492/1)
- if (scale <= 60) \
- return (.785398163397448309615660845819875721049292349843776455243736/1)
- }
- if (x==.2) {
- if (scale <= 25) return (.1973955598498807583700497/1)
- if (scale <= 40) return (.1973955598498807583700497651947902934475/1)
- if (scale <= 60) \
- return (.197395559849880758370049765194790293447585103787852101517688/1)
- }
-
- /* Negative x? */
- if (x<0) {
- m = 1;
- x = -x;
- }
-
- /* Save the scale. */
- z = scale;
-
- /* Note: a and f are known to be zero due to being auto vars. */
- /* Calculate atan of a known number. */
- if (x > .2) {
- scale = z+4;
- a = a(.2);
- }
-
- /* Precondition x. */
- scale = z+2;
- while (x > .2) {
- f += 1;
- x = (x-.2) / (1+x*.2);
- }
-
- /* Initialize the series. */
- v = n = x;
- s = -x*x;
-
- /* Calculate the series. */
- for (i=3; 1; i+=2) {
- e = (n *= s) / i;
- if (e == 0) {
- scale = z;
- if (m) return ((f*a+v)/-1);
- return ((f*a+v)/1);
- }
- v += e
- }
-}
-
-
-/* Bessel function of integer order. Uses the following:
- j(-n,x) = (-1)^n*j(n,x)
- j(n,x) = x^n/(2^n*n!) * (1 - x^2/(2^2*1!*(n+1)) + x^4/(2^4*2!*(n+1)*(n+2))
- - x^6/(2^6*3!*(n+1)*(n+2)*(n+3)) .... )
-*/
-define j(n,x) {
- auto a, d, e, f, i, m, s, v, z
-
- /* Make n an integer and check for negative n. */
- z = scale;
- scale = 0;
- n = n/1;
- if (n<0) {
- n = -n;
- if (n%2 == 1) m = 1;
- }
-
- /* Compute the factor of x^n/(2^n*n!) */
- f = 1;
- for (i=2; i<=n; i++) f = f*i;
- scale = 1.5*z;
- f = x^n / 2^n / f;
-
- /* Initialize the loop .*/
- v = e = 1;
- s = -x*x/4
- scale = 1.5*z
-
- /* The Loop.... */
- for (i=1; 1; i++) {
- e = e * s / i / (n+i);
- if (e == 0) {
- scale = z
- if (m) return (-f*v/1);
- return (f*v/1);
- }
- v += e;
- }
-}
diff --git a/gnu/usr.bin/bc/load.c b/gnu/usr.bin/bc/load.c
deleted file mode 100644
index be4ab3a..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 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 33827cc..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 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 a1fc146..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[l4:0<Z0:1s10:pl4:ns4:pN0:l2:s12:pK4\
-:l12:+K.44:l4:*+s2:pN1:l4:1>Z2:l8:1+s8:pl4:K2:/s4:pJ1:N2:1l4:\
-+s11:pl4:s5:p1s6:pK2:s9:pN4:1B5:J3:N6:l9:i9:pJ4:N5:l5:l4:*s5:\
-l6:l9:*s6:/s7:pl7:0=Z7:l8:0>Z8:N9:l8:d8:Z10:l11:l11:*s11:pJ9:N10:\
-N8:l12:s2:pl10:Z11:1l11:/RN11:l11:1/RN7:l11:l7:+s11:pJ6:N3:0R]\
-@r\
-@iF2,4.7,8,9,10,13,11,12[l4:0{Z0:1K10:l2:^-RN0:l2:s12:pl2:K4:\
-+s2:pK2:s8:p0s9:pN1:l4:K2:}Z2:l8:K2:*s8:pl4:cRs4:pJ1:N2:N3:l4:\
-K.5:{Z4:l8:K2:*s8:pl4:cRs4:pJ3:N4:l4:1-l4:1+/s13:s11:pl13:l13:\
-*s10:pK3:s9:pN6:1B7:J5:N8:l9:K2:+s9:pJ6:N7:l13:l10:*s13:l9:/s7:\
-pl7:0=Z9:l8:l11:*s11:pl12:s2:pl11:1/RN9:l11:l7:+s11:pJ8:N5:0R]\
-@r\
-@iF3,4.7,9,10,13,14,11,12[l2:s12:pK1.1:l12:*1+s2:p1C4,0:s11:p\
-l4:0<Z0:1s10:pl4:ns4:pN0:0s2:pl4:l11:/K2:+K4:/s13:pl4:K4:l13:\
-*l11:*-s4:pl13:K2:%Z1:l4:ns4:pN1:l12:K2:+s2:pl4:s7:s11:pl4:nl4:\
-*s14:pK3:s9:pN3:1B4:J2:N5:l9:K2:+s9:pJ3:N4:l7:l14:l9:l9:1-*/*\
-s7:pl7:0=Z6:l12:s2:pl10:Z7:l11:n1/RN7:l11:1/RN6:l11:l7:+s11:p\
-J5:N2:0R]@r\
-@iF5,4.11[l2:1+s2:pl4:1C4,0:K2:*+C3,0:s11:pl2:1-s2:pl11:1/R0R]\
-@r\
-@iF4,4.5,7,8,9,10,13,14,11,12[l4:1=Z0:l2:K25:{Z1:K.7853981633974483096156608\
-:1/RN1:l2:K40:{Z2:K.7853981633974483096156608458198757210492:\
-1/RN2:l2:K60:{Z3:K.785398163397448309615660845819875721049292349843776455243736\
-:1/RN3:N0:l4:K.2:=Z4:l2:K25:{Z5:K.1973955598498807583700497:1\
-/RN5:l2:K40:{Z6:K.1973955598498807583700497651947902934475:1/\
-RN6:l2:K60:{Z7:K.197395559849880758370049765194790293447585103787852101517688\
-:1/RN7:N4:l4:0<Z8:1s10:pl4:ns4:pN8:l2:s12:pl4:K.2:>Z9:l12:K4:\
-+s2:pK.2:C4,0:s5:pN9:l12:K2:+s2:pN10:l4:K.2:>Z11:l8:1+s8:pl4:\
-K.2:-1l4:K.2:*+/s4:pJ10:N11:l4:s13:s11:pl4:nl4:*s14:pK3:s9:pN13:\
-1B14:J12:N15:l9:K2:+s9:pJ13:N14:l13:l14:*s13:l9:/s7:pl7:0=Z16:\
-l12:s2:pl10:Z17:l8:l5:*l11:+1n/RN17:l8:l5:*l11:+1/RN16:l11:l7:\
-+s11:pJ15:N12:0R]@r\
-@iF6,13,4.5,6,7,8,9,10,14,11,12[l2:s12:p0s2:pl13:1/s13:pl13:0\
-<Z0:l13:ns13:pl13:K2:%1=Z1:1s10:pN1:N0:1s8:pK2:s9:pN3:l9:l13:\
-{B4:J2:N5:l9:i9:pJ3:N4:l8:l9:*s8:pJ5:N2:K1.5:l12:*s2:pl4:l13:\
-^K2:l13:^/l8:/s8:p1s7:s11:pl4:nl4:*K4:/s14:pK1.5:l12:*s2:p1s9:\
-pN7:1B8:J6:N9:l9:i9:pJ7:N8:l7:l14:*l9:/l13:l9:+/s7:pl7:0=Z10:\
-l12:s2:pl10:Z11:l8:nl11:*1/RN11:l8:l11:*1/RN10:l11:l7:+s11:pJ9:N6:\
-0R]@r"
diff --git a/gnu/usr.bin/bc/number.c b/gnu/usr.bin/bc/number.c
deleted file mode 100644
index 346b44a..0000000
--- a/gnu/usr.bin/bc/number.c
+++ /dev/null
@@ -1,1405 +0,0 @@
-/* number.c: Implements arbitrary precision numbers. */
-
-/* This file is part of bc written for MINIX.
- 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 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;
- 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;
- 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));
- }
- temp = copy_num (_one_);
- power = copy_num (num1);
-
- /* Do the calculation. */
- while (exponent != 0)
- {
- if (exponent & 1 != 0)
- bc_multiply (temp, power, &temp, rscale);
- bc_multiply (power, power, &power, 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);
- cscale = rscale + 2;
- 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, rscale);
- guess1->n_scale = 0;
- bc_raise (guess, guess1, &guess, rscale);
- free_num (&guess1);
- }
-
- /* Find the square root using Newton's algorithm. */
- done = FALSE;
- 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) 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);
- 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);
- return 0;
-}
-
-
-/* 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 9938515..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 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 fea9405..0000000
--- a/gnu/usr.bin/bc/proto.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* proto.h: Prototype function definitions for "external" functions. */
-
-/* This file is part of bc written for MINIX.
- 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 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. */
-#ifndef NO_UNISTD
-#include <unistd.h>
-#endif
-#ifndef NO_STDLIB
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#endif
-
-/* 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, int));
-_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 char *));
-
diff --git a/gnu/usr.bin/bc/scan.c b/gnu/usr.bin/bc/scan.c
deleted file mode 100644
index 59aa6e5..0000000
--- a/gnu/usr.bin/bc/scan.c
+++ /dev/null
@@ -1,1368 +0,0 @@
-/* A lexical scanner generated by flex */
-
-/* scanner skeleton version:
- * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
- */
-
-#define FLEX_SCANNER
-
-#include <stdio.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-#include <osfcn.h>
-
-/* use prototypes in function declarations */
-#define YY_USE_PROTOS
-
-/* the "const" storage-class-modifier is valid */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#ifdef __STDC__
-
-#ifdef __GNUC__
-#include <stddef.h>
-void *malloc( size_t );
-void free( void* );
-#else
-#include <stdlib.h>
-#endif /* __GNUC__ */
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-
-#ifdef __TURBOC__
-#define YY_USE_CONST
-#endif
-
-
-#ifndef YY_USE_CONST
-#define const
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-/* we can't get here if it's an ANSI C compiler, or a C++ compiler,
- * so it's got to be a K&R compiler, and therefore there's no standard
- * place from which to include these definitions
- */
-/* char *malloc();
-int free(); */
-int read();
-#endif
-
-
-/* amount of stuff to slurp up with each read */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* returned upon end-of-file */
-#define YY_END_TOK 0
-
-/* copy whatever the last rule matched to the standard output */
-
-/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
-/* this used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite()
- */
-#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
-
-/* gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#define YY_INPUT(buf,result,max_size) \
- if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
- YY_FATAL_ERROR( "read() in flex scanner failed" );
-#define YY_NULL 0
-
-/* no semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#define yyterminate() return ( YY_NULL )
-
-/* report a fatal error */
-
-/* The funky do-while is used to turn this macro definition into
- * a single C statement (which needs a semi-colon terminator).
- * This avoids problems with code like:
- *
- * if ( something_happens )
- * YY_FATAL_ERROR( "oops, the something happened" );
- * else
- * everything_okay();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the YY_FATAL_ERROR() call.
- */
-
-#define YY_FATAL_ERROR(msg) \
- do \
- { \
- (void) fputs( msg, stderr ); \
- (void) putc( '\n', stderr ); \
- exit( 1 ); \
- } \
- while ( 0 )
-
-/* default yywrap function - always treat EOF as an EOF */
-#define yywrap() 1
-
-/* enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* action number for EOF rule of a given start state */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* special action meaning "start processing a new file" */
-#define YY_NEW_FILE \
- do \
- { \
- yy_init_buffer( yy_current_buffer, yyin ); \
- yy_load_buffer_state(); \
- } \
- while ( 0 )
-
-/* default declaration of generated scanner - a define so the user can
- * easily add parameters
- */
-#define YY_DECL int yylex YY_PROTO(( void ))
-
-/* code executed at the end of each rule */
-#define YY_BREAK break;
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
-#endif
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-#define YY_CHAR unsigned char
-# line 1 "scan.l"
-#define INITIAL 0
-# line 2 "scan.l"
-/* scan.l: the (f)lex description file for the scanner. */
-
-/* This file is part of bc written for MINIX.
- 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 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" );
-
-# line 60 "scan.l"
-
-/* done after the current pattern has been matched and before the
- * corresponding action - sets up yytext
- */
-#define YY_DO_BEFORE_ACTION \
- yytext = yy_bp; \
- yyleng = yy_cp - yy_bp; \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* return all but the first 'n' matched characters back to the input stream */
-#define yyless(n) \
- do \
- { \
- /* undo effects of setting up yytext */ \
- *yy_cp = yy_hold_char; \
- yy_c_buf_p = yy_cp = yy_bp + n; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yytext )
-
-
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- YY_CHAR *yy_ch_buf; /* input buffer */
- YY_CHAR *yy_buf_pos; /* current position in input buffer */
-
- /* size of input buffer in bytes, not including room for EOB characters*/
- int yy_buf_size;
-
- /* number of characters read into yy_ch_buf, not including EOB characters */
- int yy_n_chars;
-
- int yy_eof_status; /* whether we've seen an EOF on this buffer */
-#define EOF_NOT_SEEN 0
- /* "pending" happens when the EOF has been seen but there's still
- * some text process
- */
-#define EOF_PENDING 1
-#define EOF_DONE 2
- };
-
-static YY_BUFFER_STATE yy_current_buffer;
-
-/* we provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state"
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed */
-static YY_CHAR yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
-
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-#ifndef YY_USER_INIT
-#define YY_USER_INIT
-#endif
-
-extern YY_CHAR *yytext;
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-YY_CHAR *yytext;
-int yyleng;
-
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-
-#define YY_END_OF_BUFFER 40
-typedef int yy_state_type;
-static const short int yy_accept[144] =
- { 0,
- 0, 0, 40, 38, 33, 31, 25, 38, 26, 38,
- 22, 26, 22, 22, 38, 26, 37, 29, 27, 29,
- 38, 22, 35, 35, 35, 35, 35, 35, 35, 35,
- 35, 35, 35, 35, 35, 35, 35, 35, 38, 33,
- 29, 0, 36, 27, 23, 30, 37, 0, 34, 37,
- 37, 0, 28, 32, 35, 35, 35, 35, 35, 35,
- 35, 35, 35, 7, 35, 35, 35, 35, 35, 35,
- 35, 35, 35, 35, 35, 24, 37, 0, 0, 37,
- 0, 35, 35, 35, 35, 35, 6, 35, 35, 35,
- 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
-
- 35, 13, 35, 35, 35, 14, 16, 35, 17, 35,
- 35, 35, 35, 3, 15, 35, 35, 9, 35, 35,
- 2, 35, 35, 11, 35, 35, 12, 20, 35, 10,
- 35, 8, 35, 1, 4, 21, 5, 35, 35, 35,
- 19, 18, 0
- } ;
-
-static const YY_CHAR yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 1, 1, 6, 7, 1, 8,
- 9, 10, 11, 12, 13, 14, 15, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 1, 17, 18,
- 19, 20, 1, 1, 21, 21, 21, 21, 21, 21,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 22, 23, 24, 25, 26, 1, 27, 28, 29, 30,
-
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 36, 48, 36,
- 49, 36, 50, 51, 52, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static const YY_CHAR yy_meta[53] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 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, 1,
- 1, 1
- } ;
-
-static const short int yy_base[146] =
- { 0,
- 0, 0, 193, 194, 190, 194, 172, 185, 170, 181,
- 194, 168, 42, 41, 41, 46, 52, 167, 61, 166,
- 181, 164, 135, 137, 139, 148, 140, 136, 0, 149,
- 27, 50, 147, 130, 126, 141, 40, 36, 120, 168,
- 194, 164, 194, 194, 194, 194, 66, 165, 194, 72,
- 76, 164, 194, 194, 0, 120, 134, 124, 131, 117,
- 117, 122, 132, 0, 113, 117, 117, 128, 119, 118,
- 52, 125, 107, 106, 114, 194, 80, 145, 84, 88,
- 144, 105, 118, 98, 108, 111, 0, 95, 95, 93,
- 105, 102, 91, 95, 88, 103, 85, 93, 84, 85,
-
- 90, 0, 90, 91, 85, 0, 0, 93, 0, 77,
- 76, 90, 74, 0, 0, 75, 87, 0, 90, 85,
- 0, 75, 83, 0, 76, 63, 0, 0, 66, 0,
- 62, 0, 47, 0, 0, 0, 0, 45, 53, 29,
- 0, 0, 194, 111, 56
- } ;
-
-static const short int yy_def[146] =
- { 0,
- 143, 1, 143, 143, 143, 143, 143, 144, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 143, 143,
- 143, 144, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 143, 143, 143, 143, 143,
- 143, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
- 145, 145, 0, 143, 143
- } ;
-
-static const short int yy_nxt[247] =
- { 0,
- 4, 5, 6, 7, 8, 9, 10, 11, 11, 12,
- 13, 11, 14, 15, 16, 17, 11, 18, 19, 20,
- 17, 11, 21, 11, 22, 4, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 29, 29, 32, 29, 29,
- 33, 34, 35, 36, 37, 29, 29, 38, 29, 11,
- 39, 11, 46, 46, 63, 49, 47, 55, 64, 44,
- 44, 47, 74, 48, 44, 50, 53, 51, 72, 75,
- 53, 53, 51, 53, 52, 53, 65, 142, 96, 41,
- 66, 77, 73, 141, 67, 53, 77, 80, 78, 50,
- 140, 51, 80, 139, 81, 77, 51, 97, 52, 47,
-
- 77, 138, 78, 80, 47, 137, 48, 136, 80, 135,
- 81, 42, 42, 134, 133, 132, 131, 130, 129, 128,
- 127, 126, 125, 124, 123, 122, 121, 120, 119, 118,
- 117, 116, 115, 114, 113, 112, 111, 110, 109, 108,
- 107, 106, 105, 104, 103, 102, 80, 77, 101, 100,
- 99, 98, 95, 94, 93, 92, 91, 90, 89, 88,
- 87, 86, 85, 84, 83, 82, 51, 79, 43, 40,
- 76, 71, 70, 69, 68, 62, 61, 60, 59, 58,
- 57, 56, 44, 54, 41, 41, 44, 45, 44, 43,
- 41, 40, 143, 3, 143, 143, 143, 143, 143, 143,
-
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143
- } ;
-
-static const short int yy_chk[247] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 13, 14, 31, 16, 15, 145, 31, 14,
- 13, 15, 38, 15, 16, 17, 19, 17, 37, 38,
- 19, 19, 17, 19, 17, 19, 32, 140, 71, 19,
- 32, 47, 37, 139, 32, 19, 47, 50, 47, 51,
- 138, 51, 50, 133, 50, 77, 51, 71, 51, 79,
-
- 77, 131, 77, 80, 79, 129, 79, 126, 80, 125,
- 80, 144, 144, 123, 122, 120, 119, 117, 116, 113,
- 112, 111, 110, 108, 105, 104, 103, 101, 100, 99,
- 98, 97, 96, 95, 94, 93, 92, 91, 90, 89,
- 88, 86, 85, 84, 83, 82, 81, 78, 75, 74,
- 73, 72, 70, 69, 68, 67, 66, 65, 63, 62,
- 61, 60, 59, 58, 57, 56, 52, 48, 42, 40,
- 39, 36, 35, 34, 33, 30, 28, 27, 26, 25,
- 24, 23, 22, 21, 20, 18, 12, 10, 9, 8,
- 7, 5, 3, 143, 143, 143, 143, 143, 143, 143,
-
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static YY_CHAR *yy_last_accepting_cpos;
-
-/* the intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-
-/* these variables are all declared out here so that section 3 code can
- * manipulate them
- */
-/* points to current character in buffer */
-static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
-void yyrestart YY_PROTO(( FILE *input_file ));
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-
-#define yy_new_buffer yy_create_buffer
-
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-
-YY_DECL
- {
- register yy_state_type yy_current_state;
- register YY_CHAR *yy_cp, *yy_bp;
- register int yy_act;
-
-
-
- if ( yy_init )
- {
- YY_USER_INIT;
-
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( yy_current_buffer )
- yy_init_buffer( yy_current_buffer, yyin );
- else
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_load_buffer_state();
-
- yy_init = 0;
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yy_c_buf_p;
-
- /* support of yytext */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of the
- * current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yy_start;
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[*yy_cp];
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = yy_def[yy_current_state];
- if ( yy_current_state >= 144 )
- yy_c = yy_meta[yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 194 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
-
- YY_DO_BEFORE_ACTION;
- YY_USER_ACTION;
-
-do_action: /* this label is used only to access EOF actions */
-
-
- switch ( yy_act )
- {
- case 0: /* must backtrack */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-# line 61 "scan.l"
-return(Define);
- YY_BREAK
-case 2:
-# line 62 "scan.l"
-return(Break);
- YY_BREAK
-case 3:
-# line 63 "scan.l"
-return(Quit);
- YY_BREAK
-case 4:
-# line 64 "scan.l"
-return(Length);
- YY_BREAK
-case 5:
-# line 65 "scan.l"
-return(Return);
- YY_BREAK
-case 6:
-# line 66 "scan.l"
-return(For);
- YY_BREAK
-case 7:
-# line 67 "scan.l"
-return(If);
- YY_BREAK
-case 8:
-# line 68 "scan.l"
-return(While);
- YY_BREAK
-case 9:
-# line 69 "scan.l"
-return(Sqrt);
- YY_BREAK
-case 10:
-# line 70 "scan.l"
-return(Scale);
- YY_BREAK
-case 11:
-# line 71 "scan.l"
-return(Ibase);
- YY_BREAK
-case 12:
-# line 72 "scan.l"
-return(Obase);
- YY_BREAK
-case 13:
-# line 73 "scan.l"
-return(Auto);
- YY_BREAK
-case 14:
-# line 74 "scan.l"
-return(Else);
- YY_BREAK
-case 15:
-# line 75 "scan.l"
-return(Read);
- YY_BREAK
-case 16:
-# line 76 "scan.l"
-return(Halt);
- YY_BREAK
-case 17:
-# line 77 "scan.l"
-return(Last);
- YY_BREAK
-case 18:
-# line 78 "scan.l"
-return(Warranty);
- YY_BREAK
-case 19:
-# line 79 "scan.l"
-return(Continue);
- YY_BREAK
-case 20:
-# line 80 "scan.l"
-return(Print);
- YY_BREAK
-case 21:
-# line 81 "scan.l"
-return(Limits);
- YY_BREAK
-case 22:
-# line 82 "scan.l"
-{ yylval.c_value = yytext[0];
- return((int)yytext[0]); }
- YY_BREAK
-case 23:
-# line 84 "scan.l"
-{ return(AND); }
- YY_BREAK
-case 24:
-# line 85 "scan.l"
-{ return(OR); }
- YY_BREAK
-case 25:
-# line 86 "scan.l"
-{ return(NOT); }
- YY_BREAK
-case 26:
-# line 87 "scan.l"
-{ yylval.c_value = yytext[0]; return(MUL_OP); }
- YY_BREAK
-case 27:
-# line 88 "scan.l"
-{ yylval.c_value = yytext[0]; return(ASSIGN_OP); }
- YY_BREAK
-case 28:
-# line 89 "scan.l"
-{
-#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);
- }
- YY_BREAK
-case 29:
-# line 103 "scan.l"
-{ yylval.s_value = strcopyof(yytext); return(REL_OP); }
- YY_BREAK
-case 30:
-# line 104 "scan.l"
-{ yylval.c_value = yytext[0]; return(INCR_DECR); }
- YY_BREAK
-case 31:
-# line 105 "scan.l"
-{ line_no++; return(NEWLINE); }
- YY_BREAK
-case 32:
-# line 106 "scan.l"
-{ line_no++; /* ignore a "quoted" newline */ }
- YY_BREAK
-case 33:
-# line 107 "scan.l"
-{ /* ignore spaces and tabs */ }
- YY_BREAK
-case 34:
-# line 108 "scan.l"
-{
- 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;
- }
- }
- }
- YY_BREAK
-case 35:
-# line 129 "scan.l"
-{ yylval.s_value = strcopyof(yytext); return(NAME); }
- YY_BREAK
-case 36:
-# line 130 "scan.l"
-{
- 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);
- }
- YY_BREAK
-case 37:
-# line 142 "scan.l"
-{
- 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);
- }
- YY_BREAK
-case 38:
-# line 169 "scan.l"
-{
- 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);
- }
- YY_BREAK
-case 39:
-# line 178 "scan.l"
-ECHO;
- YY_BREAK
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* amount of text matched not including the EOB char */
- int yy_amount_of_matched_text = yy_cp - yytext - 1;
-
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
-
- /* note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the end-
- * of-buffer state). Contrast this with the test in yyinput().
- */
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* this was really a NUL */
- {
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yytext + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* okay, we're now positioned to make the
- * NUL transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we
- * don't want to build jamming into it because
- * then it will run more slowly)
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yytext + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* consume the NUL */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* note: because we've taken care in
- * yy_get_next_buffer() to have set up yytext,
- * we can now set up yy_c_buf_p so that if some
- * total hoser (like flex itself) wants
- * to call the scanner after we return the
- * YY_NULL, it'll still work - another YY_NULL
- * will get returned.
- */
- yy_c_buf_p = yytext + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF((yy_start - 1) / 2);
- goto do_action;
- }
-
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- }
- break;
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
-#ifdef FLEX_DEBUG
- printf( "action # %d\n", yy_act );
-#endif
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- }
- }
- }
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * synopsis
- * int yy_get_next_buffer();
- *
- * returns a code representing an action
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
-
- {
- register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
- register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- /* try to read more data */
-
- /* first move last chars to start of buffer */
- number_to_move = yy_c_buf_p - yytext;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_n_chars = 0;
-
- else
- {
- int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- else if ( num_to_read <= 0 )
- YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
-
- /* read in more data */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move == 1 )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yy_current_buffer->yy_eof_status = EOF_DONE;
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_eof_status = EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- /* yytext begins at the second character in yy_ch_buf; the first
- * character is the one which preceded it before reading in the latest
- * buffer; it needs to be kept around in case it's a newline, so
- * yy_get_previous_state() will have with '^' rules active
- */
-
- yytext = &yy_current_buffer->yy_ch_buf[1];
-
- return ( ret_val );
- }
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached
- *
- * synopsis
- * yy_state_type yy_get_previous_state();
- */
-
-static yy_state_type yy_get_previous_state()
-
- {
- register yy_state_type yy_current_state;
- register YY_CHAR *yy_cp;
-
- yy_current_state = yy_start;
-
- for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = yy_def[yy_current_state];
- if ( yy_current_state >= 144 )
- yy_c = yy_meta[yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
- }
-
- return ( yy_current_state );
- }
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-register yy_state_type yy_current_state;
-#endif
-
- {
- register int yy_is_jam;
- register YY_CHAR *yy_cp = yy_c_buf_p;
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = yy_def[yy_current_state];
- if ( yy_current_state >= 144 )
- yy_c = yy_meta[yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
- yy_is_jam = (yy_current_state == 143);
-
- return ( yy_is_jam ? 0 : yy_current_state );
- }
-
-
-#ifdef YY_USE_PROTOS
-static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-YY_CHAR c;
-register YY_CHAR *yy_bp;
-#endif
-
- {
- register YY_CHAR *yy_cp = yy_c_buf_p;
-
- /* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
- register YY_CHAR *dest =
- &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
- register YY_CHAR *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
-
- while ( source > yy_current_buffer->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += dest - source;
- yy_bp += dest - source;
- yy_n_chars = yy_current_buffer->yy_buf_size;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
- yy_cp[-2] = '\n';
-
- *--yy_cp = c;
-
- /* note: the formal parameter *must* be called "yy_bp" for this
- * macro to now work correctly
- */
- YY_DO_BEFORE_ACTION; /* set up yytext again */
- }
-
-
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
-
- {
- int c;
- YY_CHAR *yy_cp = yy_c_buf_p;
-
- *yy_cp = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* this was really a NUL */
- *yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- yytext = yy_c_buf_p;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- {
- yy_c_buf_p = yytext + YY_MORE_ADJ;
- return ( EOF );
- }
-
- YY_NEW_FILE;
-
-#ifdef __cplusplus
- return ( yyinput() );
-#else
- return ( input() );
-#endif
- }
- break;
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext + YY_MORE_ADJ;
- break;
-
- case EOB_ACT_LAST_MATCH:
-#ifdef __cplusplus
- YY_FATAL_ERROR( "unexpected last match in yyinput()" );
-#else
- YY_FATAL_ERROR( "unexpected last match in input()" );
-#endif
- }
- }
- }
-
- c = *yy_c_buf_p;
- yy_hold_char = *++yy_c_buf_p;
-
- return ( c );
- }
-
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
-
- {
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
-
- {
- if ( yy_current_buffer == new_buffer )
- return;
-
- if ( yy_current_buffer )
- {
- /* flush out information for old buffer */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
-
- /* we don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
-
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
-
- {
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
-
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- yy_init_buffer( b, file );
-
- return ( b );
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-
- {
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
-
- free( (char *) b->yy_ch_buf );
- free( (char *) b );
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
-
- {
- b->yy_input_file = file;
-
- /* we put in the '\n' and start reading from [1] so that an
- * initial match-at-newline will be true.
- */
-
- b->yy_ch_buf[0] = '\n';
- b->yy_n_chars = 1;
-
- /* we always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[1];
-
- b->yy_eof_status = EOF_NOT_SEEN;
- }
-# line 178 "scan.l"
-
-
-
-
-/* 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 1edd6e2..0000000
--- a/gnu/usr.bin/bc/storage.c
+++ /dev/null
@@ -1,967 +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 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;
-
- 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;
- 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;
- char warned = FALSE;
- 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
- {
- if (!warned)
- {
- rt_error ("Parameter number mismatch");
- warned = TRUE;
- }
- }
- 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 954c719..0000000
--- a/gnu/usr.bin/bc/util.c
+++ /dev/null
@@ -1,794 +0,0 @@
-/* util.c: Utility routines for bc. */
-
-/* This file is part of bc written for MINIX.
- 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 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;
- char 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. COMMAS tells
- if each number should be seperated by commas.*/
-
-_PROTOTYPE (static char *make_arg_str, (arg_list *args, int len, int commas));
-
-static char *
-make_arg_str (args, len, commas)
- arg_list *args;
- int len;
- int commas;
-{
- char *temp;
- char sval[20];
-
- /* Recursive call. */
- if (args != NULL)
- temp = make_arg_str (args->next, len+11, commas);
- else
- {
- temp = (char *) bc_malloc (len);
- *temp = 0;
- return temp;
- }
-
- /* Add the current number to the end of the string. */
- if (len != 1 && commas)
- sprintf (sval, "%d,", args->av_name);
- else
- sprintf (sval, "%d", args->av_name);
- temp = strcat (temp, sval);
- return (temp);
-}
-
-char *
-arg_str (args, commas)
- arg_list *args;
- int commas;
-{
- if (arglist2 != NULL)
- free (arglist2);
- arglist2 = arglist1;
- arglist1 = make_arg_str (args, 1, commas);
- 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:
- if (id->f_name != 0)
- {
- free(name);
- 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);
- }
-}
-
-
-/* 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 6b3f909..0000000
--- a/gnu/usr.bin/bc/version.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#define BC_VERSION \
- "bc 1.02 (Mar 3, 92) Copyright (C) 1991, 1992 Free Software Foundation, Inc."
-
diff --git a/gnu/usr.bin/bc/y.tab.h b/gnu/usr.bin/bc/y.tab.h
deleted file mode 100644
index 9e65a2f..0000000
--- a/gnu/usr.bin/bc/y.tab.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#define NEWLINE 257
-#define AND 258
-#define OR 259
-#define NOT 260
-#define STRING 261
-#define NAME 262
-#define NUMBER 263
-#define MUL_OP 264
-#define ASSIGN_OP 265
-#define REL_OP 266
-#define INCR_DECR 267
-#define Define 268
-#define Break 269
-#define Quit 270
-#define Length 271
-#define Return 272
-#define For 273
-#define If 274
-#define While 275
-#define Sqrt 276
-#define Else 277
-#define Scale 278
-#define Ibase 279
-#define Obase 280
-#define Auto 281
-#define Read 282
-#define Warranty 283
-#define Halt 284
-#define Last 285
-#define Continue 286
-#define Print 287
-#define Limits 288
-#define UNARY_MINUS 289
-typedef union {
- char *s_value;
- char c_value;
- int i_value;
- arg_list *a_value;
- } YYSTYPE;
-extern YYSTYPE yylval;
diff --git a/gnu/usr.bin/cvs/Makefile b/gnu/usr.bin/cvs/Makefile
deleted file mode 100644
index d75858b..0000000
--- a/gnu/usr.bin/cvs/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-SUBDIR = lib cvs mkmodules
-
-.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/cvs/contrib/README b/gnu/usr.bin/cvs/contrib/README
deleted file mode 100644
index 412be26..0000000
--- a/gnu/usr.bin/cvs/contrib/README
+++ /dev/null
@@ -1,68 +0,0 @@
-@(#)README 1.8 92/04/10
-
-This "contrib" directory is a place holder for code/scripts sent to
-me by contributors around the world. This READM file will be kept
-up-to-date from release to release. BUT, I must point out that these
-contributions are really, REALLY UNSSUPPORTED. In fact, I probably
-don't even know what they do. Nor do I guarantee to have tried them,
-or ported them to work with this CVS distribution. If you have questions,
-you might contact the author, but you should not necessarily expect
-a reply. USE AT YOUR OWN RISK -- and all that stuff.
-
-Contents of this directory:
-
- README This file.
- log.pl A perl script suitable for including in your
- $CVSROOT/CVSROOT/loginfo file for logging commit
- changes. Includes the RCS revision of the change
- as part of the log.
- Contributed by Kevin Samborn <samborn@sunrise.com>.
- pcl-cvs A directory that contains GNU Emacs lisp code which
- implements a CVS-mode for emacs.
- Contributed by Per Cederqvist <ceder@lysator.liu.se>.
- commit_prep.pl A perl script, to be combined with log_accum.pl, to
- log_accum.pl provide for a way to combine the individual log
- messages of a multi-directory "commit" into a
- single log message, and mail the result somewhere.
- Also does other checks for $Id and that you are
- committing the correct revision of the file.
- Read the comments carefully.
- Contributed by David Hampton <hampton@cisco.com>.
- mfpipe.pl Another perl script for logging. Allows you to
- pipe the log message to a file and/or send mail
- to some alias.
- Contributed by John Clyne <clyne@niwot.scd.ucar.edu>.
- rcs-to-cvs Script to import sources that may have been under
- RCS control already.
- Contributed by Per Cederqvist <ceder@lysator.liu.se>.
- cvscheck Identifies files added, changed, or removed in a
- cvscheck.man checked out CVS tree; also notices unknown files.
- Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
- cvshelp.man An introductory manual page written by Lowell Skoog
- <fluke!lowell@uunet.uu.net>. It is most likely
- out-of-date relative to CVS 1.3, but still may be
- useful.
- dirfns A shar file which contains some code that might
- help your system support opendir/readdir/closedir,
- if it does not already.
- Copied from the C-News distribution.
- rcslock.pl A perl script that can be added to your commitinfo
- file that tries to determine if your RCS file is
- currently locked by someone else, as might be the
- case for a binary file.
- Contributed by John Rouillard <rouilj@cs.umb.edu>.
- cvs_acls.pl A perl script that implements Access Control Lists
- by using the "commitinfo" hook provided with the
- "cvs commit" command.
- Contributed by David G. Grubbs <dgg@ksr.com>.
- descend A shell script that can be used to recursively
- descend.man descend through a directory. In CVS 1.2, this was
- very useful, since many of the commands were not
- recursive. In CVS 1.3 (and later), however, most of
- the commands are recursive. However, this may still
- come in handy.
- Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
- cln_hist.pl A perl script to compress your
- $CVSROOT/CVSROOT/history file, as it can grow quite
- large after extended use.
- Contributed by David G. Grubbs <dgg@ksr.com>
diff --git a/gnu/usr.bin/cvs/contrib/cln_hist.pl b/gnu/usr.bin/cvs/contrib/cln_hist.pl
deleted file mode 100644
index b353edc..0000000
--- a/gnu/usr.bin/cvs/contrib/cln_hist.pl
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/perl -- # -*-Perl-*-
-#
-# cln_hist.pl,v 1.1 1992/04/10 03:04:15 berliner Exp
-# Contributed by David G. Grubbs <dgg@ksr.com>
-#
-# Clean up the history file. 10 Record types: MAR OFT WUCG
-#
-# WUCG records are thrown out.
-# MAR records are retained.
-# T records: retain only last tag with same combined tag/module.
-#
-# Two passes: Walk through the first time and remember the
-# 1. Last Tag record with same "tag" and "module" names.
-# 2. Last O record with unique user/module/directory, unless followed
-# by a matching F record.
-#
-
-$r = $ENV{"CVSROOT"};
-$c = "$r/CVSROOT";
-$h = "$c/history";
-
-eval "print STDERR \$die='Unknown parameter $1\n' if !defined \$$1; \$$1=\$';"
- while ($ARGV[0] =~ /^(\w+)=/ && shift(@ARGV));
-exit 255 if $die; # process any variable=value switches
-
-%tags = ();
-%outs = ();
-
-#
-# Move history file to safe place and re-initialize a new one.
-#
-rename($h, "$h.bak");
-open(XX, ">$h");
-close(XX);
-
-#
-# Pass1 -- remember last tag and checkout.
-#
-open(HIST, "$h.bak");
-while (<HIST>) {
- next if /^[MARWUCG]/;
-
- # Save whole line keyed by tag|module
- if (/^T/) {
- @tmp = split(/\|/, $_);
- $tags{$tmp[4] . '|' . $tmp[5]} = $_;
- }
- # Save whole line
- if (/^[OF]/) {
- @tmp = split(/\|/, $_);
- $outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} = $_;
- }
-}
-
-#
-# Pass2 -- print out what we want to save.
-#
-open(SAVE, ">$h.work");
-open(HIST, "$h.bak");
-while (<HIST>) {
- next if /^[FWUCG]/;
-
- # If whole line matches saved (i.e. "last") one, print it.
- if (/^T/) {
- @tmp = split(/\|/, $_);
- next if $tags{$tmp[4] . '|' . $tmp[5]} ne $_;
- }
- # Save whole line
- if (/^O/) {
- @tmp = split(/\|/, $_);
- next if $outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} ne $_;
- }
-
- print SAVE $_;
-}
-
-#
-# Put back the saved stuff
-#
-system "cat $h >> $h.work";
-
-if (-s $h) {
- rename ($h, "$h.interim");
- print "history.interim has non-zero size.\n";
-} else {
- unlink($h);
-}
-
-rename ("$h.work", $h);
-
-exit(0);
diff --git a/gnu/usr.bin/cvs/contrib/commit_prep.pl b/gnu/usr.bin/cvs/contrib/commit_prep.pl
deleted file mode 100644
index b3f7e9a..0000000
--- a/gnu/usr.bin/cvs/contrib/commit_prep.pl
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/usr/local/bin/perl -w
-#
-#
-# Perl filter to handle pre-commit checking of files. This program
-# records the last directory where commits will be taking place for
-# use by the log_accumulate script. For new file, it forcing the
-# existence of a RCS "Id" keyword in the first ten lines of the file.
-# For existing files, it checks version number in the "Id" line to
-# prevent losing changes because an old version of a file was copied
-# into the direcory.
-#
-# Possible future enhancements:
-#
-#
-# Check for cruft left by unresolved conflicts. Search for
-# "^<<<<<<<$", "^-------$", and "^>>>>>>>$".
-#
-# Look for a copyright and automagically update it to the
-# current year.
-#
-# Contributed by David Hampton <hampton@cisco.com>
-#
-
-############################################################
-#
-# Configurable options
-#
-############################################################
-#
-# Check each file (except dot files) for an RCS "Id" keyword.
-#
-$check_id = 1;
-
-#
-# Record the directory for later use by the log_accumulate stript.
-#
-$record_directory = 1;
-
-############################################################
-#
-# Constants
-#
-############################################################
-$LAST_FILE = "/tmp/#cvs.lastdir";
-$ENTRIES = "CVS/Entries";
-
-$NoId = "
-%s - Does not contain a line with the keyword \"Id:\".
- Please see the template files for an example.\n";
-
-# Protect string from substitution by RCS.
-$NoName = "
-%s - The ID line should contain only \"\$\I\d\:\ \$\" for a newly created file.\n";
-
-$BadName = "
-%s - The file name '%s' in the ID line does not match
- the actual filename.\n";
-
-$BadVersion = "
-%s - How dare you!! You replaced your copy of the file '%s',
- which was based upon version %s, with an %s version based
- upon %s. Please move your '%s' out of the way, perform an
- update to get the current version, and them merge your changes
- into that file.\n";
-
-############################################################
-#
-# Subroutines
-#
-############################################################
-
-sub write_line {
- local($filename, $line) = @_;
- open(FILE, ">$filename") || die("Cannot open $filename, stopped");
- print(FILE $line, "\n");
- close(FILE);
-}
-
-sub check_version {
- local($i, $id, $rname, $version);
- local($filename, $cvsversion) = @_;
-
- open(FILE, $filename) || die("Cannot open $filename, stopped");
- for ($i = 1; $i < 10; $i++) {
- $pos = -1;
- last if eof(FILE);
- $line = <FILE>;
- $pos = index($line, "Id: ");
- last if ($pos >= 0);
- }
-
- if ($pos == -1) {
- printf($NoId, $filename);
- return(1);
- }
-
- ($id, $rname, $version) = split(' ', substr($line, $pos));
- if ($cvsversion{$filename} == 0) {
- if ($rname ne "\$") {
- printf($NoName, $filename);
- return(1);
- }
- return(0);
- }
-
- if ($rname ne "$filename,v") {
- printf($BadName, $filename, substr($rname, 0, length($rname)-2));
- return(1);
- }
- if ($cvsversion{$filename} < $version) {
- printf($BadVersion, $filename, $filename, $cvsversion{$filename},
- "newer", $version, $filename);
- return(1);
- }
- if ($cvsversion{$filename} > $version) {
- printf($BadVersion, $filename, $filename, $cvsversion{$filename},
- "older", $version, $filename);
- return(1);
- }
- return(0);
-}
-
-#############################################################
-#
-# Main Body
-#
-############################################################
-
-$id = getpgrp();
-#print("ARGV - ", join(":", @ARGV), "\n");
-#print("id - ", id, "\n");
-
-#
-# Suck in the Entries file
-#
-open(ENTRIES, $ENTRIES) || die("Cannot open $ENTRIES.\n");
-while (<ENTRIES>) {
- local($filename, $version) = split('/', substr($_, 1));
- $cvsversion{$filename} = $version;
-}
-
-#
-# Now check each file name passed in, except for dot files. Dot files
-# are considered to be administrative files by this script.
-#
-if ($check_id != 0) {
- $failed = 0;
- $directory = $ARGV[0];
- shift @ARGV;
- foreach $arg (@ARGV) {
- next if (index($arg, ".") == 0);
- $failed += &check_version($arg);
- }
- if ($failed) {
- print "\n";
- exit(1);
- }
-}
-
-#
-# Record this directory as the last one checked. This will be used
-# by the log_accumulate script to determine when it is processing
-# the final directory of a multi-directory commit.
-#
-if ($record_directory != 0) {
- &write_line("$LAST_FILE.$id", $directory);
-}
-exit(0);
diff --git a/gnu/usr.bin/cvs/contrib/cvs_acls.pl b/gnu/usr.bin/cvs/contrib/cvs_acls.pl
deleted file mode 100644
index 1a0096a..0000000
--- a/gnu/usr.bin/cvs/contrib/cvs_acls.pl
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/usr/bin/perl -- # -*-Perl-*-
-#
-# cvs_acls.pl,v 1.2 1992/04/11 16:01:24 berliner Exp
-#
-# Access control lists for CVS. dgg@ksr.com (David G. Grubbs)
-#
-# CVS "commitinfo" for matching repository names, running the program it finds
-# on the same line. More information is available in the CVS man pages.
-#
-# ==== INSTALLATION:
-#
-# To use this program as I intended, do the following four things:
-#
-# 0. Install PERL. :-)
-#
-# 1. Put one line, as the *only* non-comment line, in your commitinfo file:
-#
-# DEFAULT /usr/local/bin/cvs_acls
-#
-# 2. Install this file as /usr/local/bin/cvs_acls and make it executable.
-#
-# 3. Create a file named $CVSROOT/CVSROOT/avail.
-#
-# ==== FORMAT OF THE avail FILE:
-#
-# The avail file determines whether you may commit files. It contains lines
-# read from top to bottom, keeping track of a single "bit". The "bit"
-# defaults to "on". It can be turned "off" by "unavail" lines and "on" by
-# "avail" lines. ==> Last one counts.
-#
-# Any line not beginning with "avail" or "unavail" is ignored.
-#
-# Lines beginning with "avail" or "unavail" are assumed to be '|'-separated
-# triples: (All spaces and tabs are ignored in a line.)
-#
-# {avail.*,unavail.*} [| user,user,... [| repos,repos,...]]
-#
-# 1. String starting with "avail" or "unavail".
-# 2. Optional, comma-separated list of usernames.
-# 3. Optional, comma-separated list of repository pathnames.
-# These are pathnames relative to $CVSROOT. They can be directories or
-# filenames. A directory name allows access to all files and
-# directories below it.
-#
-# Example: (Text from the ';;' rightward may not appear in the file.)
-#
-# unavail ;; Make whole repository unavailable.
-# avail|dgg ;; Except for user "dgg".
-# avail|fred, john|bin/ls ;; Except when "fred" or "john" commit to
-# ;; the module whose repository is "bin/ls"
-#
-# PROGRAM LOGIC:
-#
-# CVS passes to @ARGV an absolute directory pathname (the repository
-# appended to your $CVSROOT variable), followed by a list of filenames
-# within that directory.
-#
-# We walk through the avail file looking for a line that matches both
-# the username and repository.
-#
-# A username match is simply the user's name appearing in the second
-# column of the avail line in a space-or-comma separate list.
-#
-# A repository match is either:
-# - One element of the third column matches $ARGV[0], or some
-# parent directory of $ARGV[0].
-# - Otherwise *all* file arguments ($ARGV[1..$#ARGV]) must be
-# in the file list in one avail line.
-# - In other words, using directory names in the third column of
-# the avail file allows committing of any file (or group of
-# files in a single commit) in the tree below that directory.
-# - If individual file names are used in the third column of
-# the avail file, then files must be committed individually or
-# all files specified in a single commit must all appear in
-# third column of a single avail line.
-#
-
-$debug = 0;
-$cvsroot = $ENV{'CVSROOT'};
-$availfile = $cvsroot . "/CVSROOT/avail";
-$myname = $ENV{"USER"} if !($myname = $ENV{"LOGNAME"});
-
-eval "print STDERR \$die='Unknown parameter $1\n' if !defined \$$1; \$$1=\$';"
- while ($ARGV[0] =~ /^(\w+)=/ && shift(@ARGV));
-exit 255 if $die; # process any variable=value switches
-
-die "Must set CVSROOT\n" if !$cvsroot;
-($repos = shift) =~ s:^$cvsroot/::;
-grep($_ = $repos . '/' . $_, @ARGV);
-
-print "$$ Repos: $repos\n","$$ ==== ",join("\n$$ ==== ",@ARGV),"\n" if $debug;
-
-$exit_val = 0; # Good Exit value
-
-$universal_off = 0;
-open (AVAIL, $availfile) || exit(0); # It is ok for avail file not to exist
-while (<AVAIL>) {
- chop;
- next if /^\s*\#/;
- next if /^\s*$/;
- ($flagstr, $u, $m) = split(/[\s,]*\|[\s,]*/, $_);
-
- # Skip anything not starting with "avail" or "unavail" and complain.
- (print "Bad avail line: $_\n"), next
- if ($flagstr !~ /^avail/ && $flagstr !~ /^unavail/);
-
- # Set which bit we are playing with. ('0' is OK == Available).
- $flag = (($& eq "avail") ? 0 : 1);
-
- # If we find a "universal off" flag (i.e. a simple "unavail") remember it
- $universal_off = 1 if ($flag && !$u && !$m);
-
- # $myname considered "in user list" if actually in list or is NULL
- $in_user = (!$u || grep ($_ eq $myname, split(/[\s,]+/,$u)));
- print "$$ \$myname($myname) in user list: $_\n" if $debug && $in_user;
-
- # Module matches if it is a NULL module list in the avail line. If module
- # list is not null, we check every argument combination.
- if (!($in_repo = !$m)) {
- @tmp = split(/[\s,]+/,$m);
- for $j (@tmp) {
- # If the repos from avail is a parent(or equal) dir of $repos, OK
- $in_repo = 1, last if ($repos eq $j || $repos =~ /^$j\//);
- }
- if (!$in_repo) {
- $in_repo = 1;
- for $j (@ARGV) {
- last if !($in_repo = grep ($_ eq $j, @tmp));
- }
- }
- }
- print "$$ \$repos($repos) in repository list: $_\n" if $debug && $in_repo;
-
- $exit_val = $flag if ($in_user && $in_repo);
- print "$$ ==== \$exit_val = $exit_val\n$$ ==== \$flag = $flag\n" if $debug;
-}
-close(AVAIL);
-print "$$ ==== \$exit_val = $exit_val\n" if $debug;
-print "**** Access denied: Insufficient Karma ($myname|$repos)\n" if $exit_val;
-print "**** Access allowed: Personal Karma exceeds Environmental Karma.\n"
- if $universal_off && !$exit_val;
-exit($exit_val);
diff --git a/gnu/usr.bin/cvs/contrib/cvscheck b/gnu/usr.bin/cvs/contrib/cvscheck
deleted file mode 100644
index 67fdbbd..0000000
--- a/gnu/usr.bin/cvs/contrib/cvscheck
+++ /dev/null
@@ -1,84 +0,0 @@
-#! /bin/sh
-# cvscheck,v 1.2 1992/04/10 03:04:19 berliner Exp
-#
-# cvscheck - identify files added, changed, or removed
-# in CVS working directory
-#
-# Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
-#
-# This program should be run in a working directory that has been
-# checked out using CVS. It identifies files that have been added,
-# changed, or removed in the working directory, but not "cvs
-# committed". It also determines whether the files have been "cvs
-# added" or "cvs removed". For directories, it is only practical to
-# determine whether they have been added.
-
-name=cvscheck
-changes=0
-
-# If we can't run CVS commands in this directory
-cvs status . > /dev/null 2>&1
-if [ $? != 0 ] ; then
-
- # Bail out
- echo "$name: there is no version here; bailing out" 1>&2
- exit 1
-fi
-
-# Identify files added to working directory
-for file in .* * ; do
-
- # Skip '.' and '..'
- if [ $file = '.' -o $file = '..' ] ; then
- continue
- fi
-
- # If a regular file
- if [ -f $file ] ; then
- if cvs status $file | grep -s '^From:[ ]*New file' ; then
- echo "file added: $file - not CVS committed"
- changes=`expr $changes + 1`
- elif cvs status $file | grep -s '^From:[ ]*no entry for' ; then
- echo "file added: $file - not CVS added, not CVS committed"
- changes=`expr $changes + 1`
- fi
-
- # Else if a directory
- elif [ -d $file -a $file != CVS.adm ] ; then
-
- # Move into it
- cd $file
-
- # If CVS commands don't work inside
- cvs status . > /dev/null 2>&1
- if [ $? != 0 ] ; then
- echo "directory added: $file - not CVS added"
- changes=`expr $changes + 1`
- fi
-
- # Move back up
- cd ..
- fi
-done
-
-# Identify changed files
-changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
-for file in $changedfiles ; do
- echo "file changed: $file - not CVS committed"
- changes=`expr $changes + 1`
-done
-
-# Identify files removed from working directory
-removedfiles=`cvs status | egrep '^File:[ ]*no file' | awk '{print $4}'`
-
-# Determine whether each file has been cvs removed
-for file in $removedfiles ; do
- if cvs status $file | grep -s '^From:[ ]*-' ; then
- echo "file removed: $file - not CVS committed"
- else
- echo "file removed: $file - not CVS removed, not CVS committed"
- fi
- changes=`expr $changes + 1`
-done
-
-exit $changes
diff --git a/gnu/usr.bin/cvs/contrib/cvscheck.man b/gnu/usr.bin/cvs/contrib/cvscheck.man
deleted file mode 100644
index 10d47f5..0000000
--- a/gnu/usr.bin/cvs/contrib/cvscheck.man
+++ /dev/null
@@ -1,53 +0,0 @@
-.\" cvscheck.man,v 1.1 1992/04/10 03:04:20 berliner Exp
-.\" Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
-.TH CVSCHECK LOCAL "4 March 1991" FLUKE
-.SH NAME
-cvscheck \- identify files added, changed, or removed in a CVS working
-directory
-.SH SYNOPSIS
-.B cvscheck
-.SH DESCRIPTION
-This command is a housekeeping aid. It should be run in a working
-directory that has been checked out using CVS. It identifies files
-that have been added, changed, or removed in the working directory, but
-not CVS
-.BR commit ted.
-It also determines whether the files have been CVS
-.BR add ed
-or CVS
-.BR remove d.
-For directories, this command determines only whether they have been
-.BR add ed.
-It operates in the current directory only.
-.LP
-This command provides information that is available using CVS
-.B status
-and CVS
-.BR diff .
-The advantage of
-.B cvscheck
-is that its output is very concise. It saves you the strain (and
-potential error) of interpreting the output of CVS
-.B status
-and
-.BR diff .
-.LP
-See
-.BR cvs (local)
-or
-.BR cvshelp (local)
-for instructions on how to add or remove a file or directory in a
-CVS-controlled package.
-.SH DIAGNOSTICS
-The exit status is 0 if no files have been added, changed, or removed
-from the current directory. Otherwise, the command returns a count of
-the adds, changes, and deletes.
-.SH SEE ALSO
-.BR cvs (local),
-.BR cvshelp (local)
-.SH AUTHOR
-Lowell Skoog
-.br
-Software Technology Group
-.br
-Technical Computing
diff --git a/gnu/usr.bin/cvs/contrib/cvshelp.man b/gnu/usr.bin/cvs/contrib/cvshelp.man
deleted file mode 100644
index a7128a8..0000000
--- a/gnu/usr.bin/cvs/contrib/cvshelp.man
+++ /dev/null
@@ -1,562 +0,0 @@
-.\" cvshelp.man,v 1.1 1992/04/10 03:04:21 berliner Exp
-.\" Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
-.\" Full space in nroff; half space in troff
-.de SP
-.if n .sp
-.if t .sp .5
-..
-.\" Start a command example
-.de XS
-.SP
-.in +.5i
-.ft B
-.nf
-..
-.\" End a command example
-.de XE
-.fi
-.ft P
-.in -.5i
-.SP
-..
-.TH CVSHELP LOCAL "17 March 1991" FLUKE
-.SH NAME
-cvshelp \- advice on using the Concurrent Versions System
-.SH DESCRIPTION
-This man page is based on experience using CVS.
-It is bound to change as we gain more experience.
-If you come up with better advice than is found here,
-contact the Software Technology
-Group and we will add it to this page.
-.SS "Getting Started"
-Use the following steps to prepare to use CVS:
-.TP
-\(bu
-Take a look at the CVS manual page to see what it can do for you, and
-if it fits your environment (or can possibly be made to fit your
-environment).
-.XS
-man cvs
-.XE
-If things look good, continue on...
-.TP
-\(bu
-Setup the master source repository. Choose a directory with
-ample disk space available for source files. This is where the RCS
-`,v' files will be stored. Say you choose
-.B /src/master
-as the root
-of your source repository. Make the
-.SB CVSROOT.adm
-directory in the root of the source repository:
-.XS
-mkdir /src/master/CVSROOT.adm
-.XE
-.TP
-\(bu
-Populate this directory with the
-.I loginfo
-and
-.I modules
-files from the
-.B "/usr/doc/local/cvs"
-directory. Edit these files to reflect your local source repository
-environment \- they may be quite small initially, but will grow as
-sources are added to your source repository. Turn these files into
-RCS controlled files:
-.XS
-cd /src/master/CVSROOT.adm
-ci \-m'Initial loginfo file' loginfo
-ci \-m'Initial modules file' modules
-.XE
-.TP
-\(bu
-Run the command:
-.XS
-mkmodules /src/master/CVSROOT.adm
-.XE
-This will build the
-.BR ndbm (3)
-file for the modules database.
-.TP
-\(bu
-Remember to edit the
-.I modules
-file manually when sources are checked
-in with
-.B checkin
-or CVS
-.BR add .
-A copy of the
-.I modules
-file for editing can be retrieved with the command:
-.XS
-cvs checkout CVSROOT.adm
-.XE
-.TP
-\(bu
-Have all users of the CVS system set the
-.SM CVSROOT
-environment variable appropriately to reflect the placement of your
-source repository. If the above example is used, the following
-commands can be placed in a
-.I .login
-or
-.I .profile
-file:
-.XS
-setenv CVSROOT /src/master
-.XE
-for csh users, and
-.XS
-CVSROOT=/src/master; export CVSROOT
-.XE
-for sh users.
-.SS "Placing Locally Written Sources Under CVS Control"
-Say you want to place the `whizbang' sources under
-CVS control. Say further that the sources have never
-been under revision control before.
-.TP
-\(bu
-Move the source hierarchy (lock, stock, and barrel)
-into the master source repository:
-.XS
-mv ~/whizbang $CVSROOT
-.XE
-.TP
-\(bu
-Clean out unwanted object files:
-.XS
-cd $CVSROOT/whizbang
-make clean
-.XE
-.TP
-\(bu
-Turn every file in the hierarchy into an RCS controlled file:
-.XS
-descend \-f 'ci \-t/dev/null \-m"Placed under CVS control" \-nV\fR\fIx\fR\fB_\fR\fIy\fR\fB *'
-.XE
-In this example, the initial release tag is \fBV\fIx\fB_\fIy\fR,
-representing version \fIx\fR.\fIy\fR.
-.LP
-You can use CVS on sources that are already under RCS control.
-The following example shows how.
-In this example, the source package is called `skunkworks'.
-.TP
-\(bu
-Move the source hierarchy into the master source
-repository:
-.XS
-mv ~/skunkworks $CVSROOT
-.XE
-.TP
-\(bu
-Clean out unwanted object files:
-.XS
-cd $CVSROOT/skunkworks
-make clean
-.XE
-.TP
-\(bu
-Clean out unwanted working files, leaving only the RCS `,v' files:
-.XS
-descend \-r rcsclean
-.XE
-Note: If any working files have been checked out and changed,
-.B rcsclean
-will fail. Check in the modified working files
-and run the command again.
-.TP
-\(bu
-Get rid of
-.SB RCS
-subdirectories. CVS does not use them.
-.XS
-descend \-r \-f 'mv RCS/*,v .'
-descend \-r \-f 'rmdir RCS'
-.XE
-.TP
-\(bu
-Delete any unwanted files that remain in the source hierarchy. Then
-make sure all files are under RCS control:
-.XS
-descend \-f 'ci \-t/dev/null \-m"Placed under CVS control" \-n\fR\fItag\fR\fB *'
-.XE
-.I tag
-is the latest symbolic revision tag that you applied to your package
-(if any). Note: This command will probably generate lots of error
-messages (for directories and existing RCS files) that you can
-ignore.
-.SS "Placing a Third-Party Source Distribution Under CVS Control"
-The
-.B checkin
-command checks third-party sources into CVS. The
-difference between third-party sources and locally
-written sources is that third-party sources must be checked into a
-separate branch (called the
-.IR "vendor branch" )
-of the RCS tree. This makes it possible to merge local changes to
-the sources with later releases from the vendor.
-.TP
-\(bu
-Save the original distribution kit somewhere. For example, if the
-master source repository is
-.B /src/master
-the distribution kit could be saved in
-.BR /src/dist .
-Organize the distribution directory so that each release
-is clearly identifiable.
-.TP
-\(bu
-Unpack the package in a scratch directory, for example
-.BR ~/scratch .
-.TP
-\(bu
-Create a repository for the package.
-In this example, the package is called `Bugs-R-Us 4.3'.
-.XS
-mkdir $CVSROOT/bugs
-.XE
-.TP
-\(bu
-Check in the unpacked files:
-.XS
-cd ~/scratch
-checkin \-m 'Bugs-R-Us 4.3 distribution' bugs VENDOR V4_3
-.XE
-There is nothing magic about the tag `VENDOR', which is applied to
-the vendor branch. You can use whatever tag you want. `VENDOR' is a
-useful convention.
-.TP
-\(bu
-Never modify vendor files before checking them in.
-Check in the files
-.I exactly
-as you unpacked them.
-If you check in locally modified files, future vendor releases may
-wipe out your local changes.
-.SS "Working With CVS-Controlled Sources"
-To use or edit the sources, you must check out a private copy.
-For the following examples, the master files are assumed to reside in
-.BR "$CVSROOT/behemoth" .
-The working directory is
-.BR "~/work" .
-See
-.BR cvs (local)
-for more details on the commands mentioned below.
-.TP
-.I "To Check Out Working Files
-Use CVS
-.BR checkout :
-.XS
-cd ~/work
-cvs checkout behemoth
-.XE
-There is nothing magic about the working directory. CVS will check
-out sources anywhere you like. Once you have a working copy of the
-sources, you can compile or edit them as desired.
-.TP
-.I "To Display Changes You Have Made"
-Use CVS
-.BR diff
-to display detailed changes, equivalent to
-.BR rcsdiff (local).
-You can also use
-.BR cvscheck (local)
-to list files added, changed, and removed in
-the directory, but not yet
-.BR commit ted.
-You must be in a directory containing working files.
-.TP
-.I "To Display Revision Information"
-Use CVS
-.BR log ,
-which is equivalent to
-.BR rlog (local).
-You must be in a directory containing working files.
-.TP
-.I "To Update Working Files"
-Use CVS
-.BR update
-in a directory containing working files.
-This command brings your working files up
-to date with changes checked into the
-master repository since you last checked out or updated
-your files.
-.TP
-.I "To Check In Your Changes"
-Use CVS
-.BR commit
-in a directory containing working files.
-This command checks your changes into the master repository.
-You can specify files by name or use
-.XS
-cvs commit \-a
-.XE
-to
-.B commit
-all the files you have changed.
-.TP
-.I "To Add a File"
-Add the file to the working directory.
-Use CVS
-.B add
-to mark the file as added.
-Use CVS
-.B commit
-to add the file to the master repository.
-.TP
-.I "To Remove a File"
-Remove the file from the working directory.
-Use CVS
-.B remove
-to mark the file as removed.
-Use CVS
-.B commit
-to move the file from its current location in the master repository
-to the CVS
-.IR Attic
-directory.
-.TP
-.I "To Add a Directory"
-Add the directory to the working directory.
-Use CVS
-.B add
-to add the directory to the master repository.
-.TP
-.I "To Remove a Directory"
-.br
-You shouldn't remove directories under CVS. You should instead remove
-their contents and then prune them (using the
-.B \-f
-and
-.B \-p
-options) when you
-.B checkout
-or
-.B update
-your working files.
-.TP
-.I "To Tag a Release"
-Use CVS
-.B tag
-to apply a symbolic tag to the latest revision of each file in the
-master repository. For example:
-.XS
-cvs tag V2_1 behemoth
-.XE
-.TP
-.I "To Retrieve an Exact Copy of a Previous Release"
-During a CVS
-.B checkout
-or
-.BR update ,
-use the
-.B \-r
-option to retrieve revisions associated with a symbolic tag.
-Use the
-.B \-f
-option to ignore all RCS files that do not contain the
-tag.
-Use the
-.B \-p
-option to prune directories that wind up empty because none
-of their files matched the tag. Example:
-.XS
-cd ~/work
-cvs checkout \-r V2_1 \-f \-p behemoth
-.XE
-.SS "Logging Changes"
-It is a good idea to keep a change log together with the
-sources. As a minimum, the change log should name and describe each
-tagged release. The change log should also be under CVS control and
-should be tagged along with the sources.
-.LP
-.BR cvslog (local)
-can help. This command logs
-changes reported during CVS
-.B commit
-operations. It automatically
-updates a change log file in your working directory. When you are
-finished making changes, you (optionally) edit the change log file and
-then commit it to the master repository.
-.LP
-Note: You must edit the change log to describe a new release
-and
-.B commit
-it to the master repository
-.I before
-.BR tag ging
-the release using CVS. Otherwise, the release description will not be
-included in the tagged package.
-.LP
-See
-.BR cvslog (local)
-for more information.
-.SS "Merging a Subsequent Third-Party Distribution"
-The initial steps in this process are identical to placing a
-third-party distribution under CVS for the first time: save the
-distribution kit and unpack the package in a scratch directory. From
-that point the steps diverge.
-The following example considers release 5.0 of the
-Bugs-R-Us package.
-.TP
-\(bu
-Check in the sources after unpacking them:
-.XS
-cd ~/scratch
-checkin \-m 'Bugs-R-Us 5.0 distribution' bugs VENDOR V5_0 \\
- | tee ~/WARNINGS
-.XE
-It is important to save the output of
-.B checkin
-in a file
-because it lists the sources that have been locally modified.
-It is best to save the file in a different directory (for example,
-your home directory). Otherwise,
-.B checkin
-will try to check it into the master repository.
-.TP
-\(bu
-In your usual working directory, check out a fresh copy of the
-distribution that you just checked in.
-.XS
-cd ~/work
-cvs checkout \-r VENDOR bugs
-.XE
-The
-.B checkout
-command shown above retrieves the latest revision on the vendor branch.
-.TP
-\(bu
-See the `WARNINGS' file for a list of all locally modified
-sources.
-For each locally modified source,
-look at the differences between
-the new distribution and the latest local revision:
-.XS
-cvs diff \-r \fR\fILocalRev file\fR\fB
-.XE
-In this command,
-.I LocalRev
-is the latest
-numeric or symbolic revision
-on the RCS trunk of
-.IR file .
-You can use CVS
-.B log
-to get the revision history.
-.TP
-\(bu
-If your local modifications to a file have been incorporated into
-the vendor's distribution, then you should reset the default RCS
-branch for that file to the vendor branch. CVS doesn't provide a
-mechanism to do this. You have to do it by hand in the master
-repository:
-.XS
-rcs \-bVENDOR \fR\fIfile\fR\fB,v
-.XE
-.TP
-\(bu
-If your local modifications need to be merged with the
-new distribution, use CVS
-.B join
-to do it:
-.XS
-cvs join \-r VENDOR \fR\fIfile\fR\fB
-.XE
-The resulting file will be placed in your working directory.
-Edit it to resolve any overlaps.
-.TP
-\(bu
-Test the merged package.
-.TP
-\(bu
-Commit all modified files to the repository:
-.XS
-cvs commit \-a
-.XE
-.TP
-\(bu
-Tag the repository with a new local tag.
-.SS "Applying Patches to Third-Party Sources"
-Patches are handled in a manner very similar to complete
-third-party distributions. This example considers patches applied to
-Bugs-R-Us release 5.0.
-.TP
-\(bu
-Save the patch files together with the distribution kit
-to which they apply.
-The patch file names should clearly indicate the patch
-level.
-.TP
-\(bu
-In a scratch directory, check out the last `clean' vendor copy \- the
-highest revision on the vendor branch with
-.IR "no local changes" :
-.XS
-cd ~/scratch
-cvs checkout \-r VENDOR bugs
-.XE
-.TP
-\(bu
-Use
-.BR patch (local)
-to apply the patches. You should now have an image of the
-vendor's software just as though you had received a complete,
-new release.
-.TP
-\(bu
-Proceed with the steps described for merging a subsequent third-party
-distribution.
-.TP
-\(bu
-Note: When you get to the step that requires you
-to check out the new distribution after you have
-checked it into the vendor branch, you should move to a different
-directory. Do not attempt to
-.B checkout
-files in the directory in
-which you applied the patches. If you do, CVS will try to merge the
-changes that you made during patching with the version being checked
-out and things will get very confusing. Instead,
-go to a different directory (like your working directory) and
-check out the files there.
-.SS "Advice to Third-Party Source Hackers"
-As you can see from the preceding sections, merging local changes
-into third-party distributions remains difficult, and probably
-always will. This fact suggests some guidelines:
-.TP
-\(bu
-Minimize local changes.
-.I Never
-make stylistic changes.
-Change makefiles only as much as needed for installation. Avoid
-overhauling anything. Pray that the vendor does the same.
-.TP
-\(bu
-Avoid renaming files or moving them around.
-.TP
-\(bu
-Put independent, locally written files like help documents, local
-tools, or man pages in a sub-directory called `local-additions'.
-Locally written files that are linked into an existing executable
-should be added right in with the vendor's sources (not in a
-`local-additions' directory).
-If, in the future,
-the vendor distributes something
-equivalent to your locally written files
-you can CVS
-.B remove
-the files from the `local-additions' directory at that time.
-.SH SEE ALSO
-.BR cvs (local),
-.BR checkin (local),
-.BR cvslog (local),
-.BR cvscheck (local)
-.SH AUTHOR
-Lowell Skoog
-.br
-Software Technology Group
-.br
-Technical Computing
diff --git a/gnu/usr.bin/cvs/contrib/descend b/gnu/usr.bin/cvs/contrib/descend
deleted file mode 100644
index b63e4a7..0000000
--- a/gnu/usr.bin/cvs/contrib/descend
+++ /dev/null
@@ -1,116 +0,0 @@
-#! /bin/sh
-# descend,v 1.1 1992/04/03 05:22:52 berliner Exp
-#
-# descend - walk down a directory tree and execute a command at each node
-
-fullname=$0
-name=descend
-usage="Usage: $name [-afqrv] command [directory ...]\n
-\040\040-a\040\040All: descend into directories starting with '.'\n
-\040\040-f\040\040Force: ignore errors during descent\n
-\040\040-q\040\040Quiet: don't print directory names\n
-\040\040-r\040\040Restricted: don't descend into RCS, CVS.adm, SCCS directories\n
-\040\040-v\040\040Verbose: print command before executing it"
-
-# Scan for options
-while getopts afqrv option; do
- case $option in
- a)
- alldirs=$option
- options=$options" "-$option
- ;;
- f)
- force=$option
- options=$options" "-$option
- ;;
- q)
- verbose=
- quiet=$option
- options=$options" "-$option
- ;;
- r)
- restricted=$option
- options=$options" "-$option
- ;;
- v)
- verbose=$option
- quiet=
- options=$options" "-$option
- ;;
- \?)
- /usr/5bin/echo $usage 1>&2
- exit 1
- ;;
- esac
-done
-shift `expr $OPTIND - 1`
-
-# Get command to execute
-if [ $# -lt 1 ] ; then
- /usr/5bin/echo $usage 1>&2
- exit 1
-else
- command=$1
- shift
-fi
-
-# If no directory specified, use '.'
-if [ $# -lt 1 ] ; then
- default_dir=.
-fi
-
-# For each directory specified
-for dir in $default_dir "$@" ; do
-
- # Spawn sub-shell so we return to starting directory afterward
- (cd $dir
-
- # Execute specified command
- if [ -z "$quiet" ] ; then
- echo In directory `hostname`:`pwd`
- fi
- if [ -n "$verbose" ] ; then
- echo $command
- fi
- eval "$command" || if [ -z "$force" ] ; then exit 1; fi
-
- # Collect dot file names if necessary
- if [ -n "$alldirs" ] ; then
- dotfiles=.*
- else
- dotfiles=
- fi
-
- # For each file in current directory
- for file in $dotfiles * ; do
-
- # Skip '.' and '..'
- if [ "$file" = "." -o "$file" = ".." ] ; then
- continue
- fi
-
- # If a directory but not a symbolic link
- if [ -d "$file" -a ! -h "$file" ] ; then
-
- # If not skipping this type of directory
- if [ \( "$file" != "RCS" -a \
- "$file" != "SCCS" -a \
- "$file" != "CVS" -a \
- "$file" != "CVS.adm" \) \
- -o -z "$restricted" ] ; then
-
- # Recursively descend into it
- $fullname $options "$command" "$file" \
- || if [ -z "$force" ] ; then exit 1; fi
- fi
-
- # Else if a directory AND a symbolic link
- elif [ -d "$file" -a -h "$file" ] ; then
-
- if [ -z "$quiet" ] ; then
- echo In directory `hostname`:`pwd`/$file: symbolic link: skipping
- fi
- fi
- done
- ) || if [ -z "$force" ] ; then exit 1; fi
-done
diff --git a/gnu/usr.bin/cvs/contrib/descend.man b/gnu/usr.bin/cvs/contrib/descend.man
deleted file mode 100644
index adeab3b..0000000
--- a/gnu/usr.bin/cvs/contrib/descend.man
+++ /dev/null
@@ -1,115 +0,0 @@
-.\" descend.man,v 1.1 1992/04/03 05:22:53 berliner Exp
-.TH DESCEND 1 "31 March 1992"
-.SH NAME
-descend \- walk directory tree and execute a command at each node
-.SH SYNOPSIS
-.B descend
-[
-.B \-afqrv
-]
-.I command
-[
-.I directory
-\&.\|.\|.
-]
-.SH DESCRIPTION
-.B descend
-walks down a directory tree and executes a command at each node. It
-is not as versatile as
-.BR find (1),
-but it has a simpler syntax. If no
-.I directory
-is specified,
-.B descend
-starts at the current one.
-.LP
-Unlike
-.BR find ,
-.B descend
-can be told to skip the special directories associated with RCS,
-CVS, and SCCS. This makes
-.B descend
-especially handy for use with these packages. It can be used with
-other commands too, of course.
-.LP
-.B descend
-is a poor man's way to make any command recursive. Note:
-.B descend
-does not follow symbolic links to directories unless they are
-specified on the command line.
-.SH OPTIONS
-.TP 15
-.B \-a
-.I All.
-Descend into directories that begin with '.'.
-.TP
-.B \-f
-.I Force.
-Ignore errors during descent. Normally,
-.B descend
-quits when an error occurs.
-.TP
-.B \-q
-.I Quiet.
-Suppress the message `In directory
-.IR directory '
-that is normally printed during the descent.
-.TP
-.B \-r
-.I Restricted.
-Don't descend into the special directories
-.SB RCS,
-.SB CVS,
-.SB CVS.adm,
-and
-.SB SCCS.
-.TP
-.B \-v
-.I Verbose.
-Print
-.I command
-before executing it.
-.SH EXAMPLES
-.TP 15
-.B "descend ls"
-Cheap substitute for `ls -R'.
-.TP 15
-.B "descend -f 'rm *' tree"
-Strip `tree' of its leaves. This command descends the `tree'
-directory, removing all regular files. Since
-.BR rm (1)
-does not remove directories, this command leaves the directory
-structure of `tree' intact, but denuded. The
-.B \-f
-option is required to keep
-.B descend
-from quitting. You could use `rm \-f' instead.
-.TP
-.B "descend -r 'co RCS/*'" /project/src/
-Check out every RCS file under the directory
-.BR "/project/src" .
-.TP
-.B "descend -r 'cvs diff'"
-Perform CVS `diff' operation on every directory below (and including)
-the current one.
-.SH DIAGNOSTICS
-Returns 1 if errors occur (and the
-.B \-f
-option is not used). Otherwise returns 0.
-.SH SEE ALSO
-.BR find (1),
-.BR rcsintro (1),
-.BR cvs (1),
-.BR sccs (1)
-.SH AUTHOR
-Lowell Skoog
-.br
-Software Technology Group
-.br
-John Fluke Mfg. Co., Inc.
-.SH BUGS
-Shell metacharacters in
-.I command
-may have bizarre effects. In particular, compound commands
-(containing ';', '[', and ']' characters) will not work. It is best
-to enclose complicated commands in single quotes \(aa\ \(aa.
diff --git a/gnu/usr.bin/cvs/contrib/dirfns b/gnu/usr.bin/cvs/contrib/dirfns
deleted file mode 100644
index 8324c41..0000000
--- a/gnu/usr.bin/cvs/contrib/dirfns
+++ /dev/null
@@ -1,481 +0,0 @@
-echo 'directory.3':
-sed 's/^X//' >'directory.3' <<'!'
-X.TH DIRECTORY 3 imported
-X.DA 9 Oct 1985
-X.SH NAME
-Xopendir, readdir, telldir, seekdir, rewinddir, closedir \- high-level directory operations
-X.SH SYNOPSIS
-X.B #include <sys/types.h>
-X.br
-X.B #include <ndir.h>
-X.PP
-X.SM
-X.B DIR
-X.B *opendir(filename)
-X.br
-X.B char *filename;
-X.PP
-X.SM
-X.B struct direct
-X.B *readdir(dirp)
-X.br
-X.B DIR *dirp;
-X.PP
-X.SM
-X.B long
-X.B telldir(dirp)
-X.br
-X.B DIR *dirp;
-X.PP
-X.SM
-X.B seekdir(dirp, loc)
-X.br
-X.B DIR *dirp;
-X.br
-X.B long loc;
-X.PP
-X.SM
-X.B rewinddir(dirp)
-X.br
-X.B DIR *dirp;
-X.PP
-X.SM
-X.B closedir(dirp)
-X.br
-X.B DIR *dirp;
-X.SH DESCRIPTION
-XThis library provides high-level primitives for directory scanning,
-Xsimilar to those available for 4.2BSD's (very different) directory system.
-X.\"The purpose of this library is to simulate
-X.\"the new flexible length directory names of 4.2bsd UNIX
-X.\"on top of the old directory structure of v7.
-XIt incidentally provides easy portability to and from 4.2BSD (insofar
-Xas such portability is not compromised by other 4.2/VAX dependencies).
-X.\"It allows programs to be converted immediately
-X.\"to the new directory access interface,
-X.\"so that they need only be relinked
-X.\"when moved to 4.2bsd.
-X.\"It is obtained with the loader option
-X.\".BR \-lndir .
-X.PP
-X.I Opendir
-Xopens the directory named by
-X.I filename
-Xand associates a
-X.I directory stream
-Xwith it.
-X.I Opendir
-Xreturns a pointer to be used to identify the
-X.I directory stream
-Xin subsequent operations.
-XThe pointer
-X.SM
-X.B NULL
-Xis returned if
-X.I filename
-Xcannot be accessed or is not a directory.
-X.PP
-X.I Readdir
-Xreturns a pointer to the next directory entry.
-XIt returns
-X.B NULL
-Xupon reaching the end of the directory or detecting
-Xan invalid
-X.I seekdir
-Xoperation.
-X.PP
-X.I Telldir
-Xreturns the current location associated with the named
-X.I directory stream.
-X.PP
-X.I Seekdir
-Xsets the position of the next
-X.I readdir
-Xoperation on the
-X.I directory stream.
-XThe new position reverts to the one associated with the
-X.I directory stream
-Xwhen the
-X.I telldir
-Xoperation was performed.
-XValues returned by
-X.I telldir
-Xare good only for the lifetime of the DIR pointer from
-Xwhich they are derived.
-XIf the directory is closed and then reopened,
-Xthe
-X.I telldir
-Xvalue may be invalidated
-Xdue to undetected directory compaction in 4.2BSD.
-XIt is safe to use a previous
-X.I telldir
-Xvalue immediately after a call to
-X.I opendir
-Xand before any calls to
-X.I readdir.
-X.PP
-X.I Rewinddir
-Xresets the position of the named
-X.I directory stream
-Xto the beginning of the directory.
-X.PP
-X.I Closedir
-Xcauses the named
-X.I directory stream
-Xto be closed,
-Xand the structure associated with the DIR pointer to be freed.
-X.PP
-XA
-X.I direct
-Xstructure is as follows:
-X.PP
-X.RS
-X.nf
-Xstruct direct {
-X /* unsigned */ long d_ino; /* inode number of entry */
-X unsigned short d_reclen; /* length of this record */
-X unsigned short d_namlen; /* length of string in d_name */
-X char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
-X};
-X.fi
-X.RE
-X.PP
-XThe
-X.I d_reclen
-Xfield is meaningless in non-4.2BSD systems and should be ignored.
-XThe use of a
-X.I long
-Xfor
-X.I d_ino
-Xis also a 4.2BSDism;
-X.I ino_t
-X(see
-X.IR types (5))
-Xshould be used elsewhere.
-XThe macro
-X.I DIRSIZ(dp)
-Xgives the minimum memory size needed to hold the
-X.I direct
-Xvalue pointed to by
-X.IR dp ,
-Xwith the minimum necessary allocation for
-X.IR d_name .
-X.PP
-XThe preferred way to search the current directory for entry ``name'' is:
-X.PP
-X.RS
-X.nf
-X len = strlen(name);
-X dirp = opendir(".");
-X if (dirp == NULL) {
-X fprintf(stderr, "%s: can't read directory .\\n", argv[0]);
-X return NOT_FOUND;
-X }
-X while ((dp = readdir(dirp)) != NULL)
-X if (dp->d_namlen == len && strcmp(dp->d_name, name) == 0) {
-X closedir(dirp);
-X return FOUND;
-X }
-X closedir(dirp);
-X return NOT_FOUND;
-X.RE
-X.\".SH LINKING
-X.\"This library is accessed by specifying ``-lndir'' as the
-X.\"last argument to the compile line, e.g.:
-X.\".PP
-X.\" cc -I/usr/include/ndir -o prog prog.c -lndir
-X.SH "SEE ALSO"
-Xopen(2),
-Xclose(2),
-Xread(2),
-Xlseek(2)
-X.SH HISTORY
-XWritten by
-XKirk McKusick at Berkeley (ucbvax!mckusick).
-XMiscellaneous bug fixes from elsewhere.
-XThe size of the data structure has been decreased to avoid excessive
-Xspace waste under V7 (where filenames are 14 characters at most).
-XFor obscure historical reasons, the include file is also available
-Xas
-X.IR <ndir/sys/dir.h> .
-XThe Berkeley version lived in a separate library (\fI\-lndir\fR),
-Xwhereas ours is
-Xpart of the C library, although the separate library is retained to
-Xmaximize compatibility.
-X.PP
-XThis manual page has been substantially rewritten to be informative in
-Xthe absence of a 4.2BSD manual.
-X.SH BUGS
-XThe
-X.I DIRSIZ
-Xmacro actually wastes a bit of space due to some padding requirements
-Xthat are an artifact of 4.2BSD.
-X.PP
-XThe returned value of
-X.I readdir
-Xpoints to a static area that will be overwritten by subsequent calls.
-X.PP
-XThere are some unfortunate name conflicts with the \fIreal\fR V7
-Xdirectory structure definitions.
-!
-echo 'dir.h':
-sed 's/^X//' >'dir.h' <<'!'
-X/* dir.h 4.4 82/07/25 */
-X
-X/*
-X * A directory consists of some number of blocks of DIRBLKSIZ
-X * bytes, where DIRBLKSIZ is chosen such that it can be transferred
-X * to disk in a single atomic operation (e.g. 512 bytes on most machines).
-X *
-X * Each DIRBLKSIZ byte block contains some number of directory entry
-X * structures, which are of variable length. Each directory entry has
-X * a struct direct at the front of it, containing its inode number,
-X * the length of the entry, and the length of the name contained in
-X * the entry. These are followed by the name padded to a 4 byte boundary
-X * with null bytes. All names are guaranteed null terminated.
-X * The maximum length of a name in a directory is MAXNAMLEN.
-X *
-X * The macro DIRSIZ(dp) gives the amount of space required to represent
-X * a directory entry. Free space in a directory is represented by
-X * entries which have dp->d_reclen >= DIRSIZ(dp). All DIRBLKSIZ bytes
-X * in a directory block are claimed by the directory entries. This
-X * usually results in the last entry in a directory having a large
-X * dp->d_reclen. When entries are deleted from a directory, the
-X * space is returned to the previous entry in the same directory
-X * block by increasing its dp->d_reclen. If the first entry of
-X * a directory block is free, then its dp->d_ino is set to 0.
-X * Entries other than the first in a directory do not normally have
-X * dp->d_ino set to 0.
-X */
-X#define DIRBLKSIZ 512
-X#ifdef VMUNIX
-X#define MAXNAMLEN 255
-X#else
-X#define MAXNAMLEN 14
-X#endif
-X
-Xstruct direct {
-X /* unsigned */ long d_ino; /* inode number of entry */
-X unsigned short d_reclen; /* length of this record */
-X unsigned short d_namlen; /* length of string in d_name */
-X char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
-X};
-X
-X/*
-X * The DIRSIZ macro gives the minimum record length which will hold
-X * the directory entry. This requires the amount of space in struct direct
-X * without the d_name field, plus enough space for the name with a terminating
-X * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
-X */
-X#undef DIRSIZ
-X#define DIRSIZ(dp) \
-X ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
-X
-X#ifndef KERNEL
-X/*
-X * Definitions for library routines operating on directories.
-X */
-Xtypedef struct _dirdesc {
-X int dd_fd;
-X long dd_loc;
-X long dd_size;
-X char dd_buf[DIRBLKSIZ];
-X} DIR;
-X#ifndef NULL
-X#define NULL 0
-X#endif
-Xextern DIR *opendir();
-Xextern struct direct *readdir();
-Xextern long telldir();
-X#ifdef void
-Xextern void seekdir();
-Xextern void closedir();
-X#endif
-X#define rewinddir(dirp) seekdir((dirp), (long)0)
-X#endif KERNEL
-!
-echo 'makefile':
-sed 's/^X//' >'makefile' <<'!'
-XDIR = closedir.o opendir.o readdir.o seekdir.o telldir.o
-XCFLAGS=-O -I. -Dvoid=int
-XDEST=..
-X
-Xall: $(DIR)
-X
-Xmv: $(DIR)
-X mv $(DIR) $(DEST)
-X
-Xcpif: dir.h
-X cp dir.h /usr/include/ndir.h
-X
-Xclean:
-X rm -f *.o
-!
-echo 'closedir.c':
-sed 's/^X//' >'closedir.c' <<'!'
-Xstatic char sccsid[] = "@(#)closedir.c 4.2 3/10/82";
-X
-X#include <sys/types.h>
-X#include <dir.h>
-X
-X/*
-X * close a directory.
-X */
-Xvoid
-Xclosedir(dirp)
-X register DIR *dirp;
-X{
-X close(dirp->dd_fd);
-X dirp->dd_fd = -1;
-X dirp->dd_loc = 0;
-X free((char *)dirp);
-X}
-!
-echo 'opendir.c':
-sed 's/^X//' >'opendir.c' <<'!'
-X/* Copyright (c) 1982 Regents of the University of California */
-X
-Xstatic char sccsid[] = "@(#)opendir.c 4.4 11/12/82";
-X
-X#include <sys/types.h>
-X#include <sys/stat.h>
-X#include <dir.h>
-X
-X/*
-X * open a directory.
-X */
-XDIR *
-Xopendir(name)
-X char *name;
-X{
-X register DIR *dirp;
-X register int fd;
-X struct stat statbuf;
-X char *malloc();
-X
-X if ((fd = open(name, 0)) == -1)
-X return NULL;
-X if (fstat(fd, &statbuf) == -1 || !(statbuf.st_mode & S_IFDIR)) {
-X close(fd);
-X return NULL;
-X }
-X if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
-X close (fd);
-X return NULL;
-X }
-X dirp->dd_fd = fd;
-X dirp->dd_loc = 0;
-X dirp->dd_size = 0; /* so that telldir will work before readdir */
-X return dirp;
-X}
-!
-echo 'readdir.c':
-sed 's/^X//' >'readdir.c' <<'!'
-X/* Copyright (c) 1982 Regents of the University of California */
-X
-Xstatic char sccsid[] = "@(#)readdir.c 4.3 8/8/82";
-X
-X#include <sys/types.h>
-X#include <dir.h>
-X
-X/*
-X * read an old stlye directory entry and present it as a new one
-X */
-X#define ODIRSIZ 14
-X
-Xstruct olddirect {
-X ino_t od_ino;
-X char od_name[ODIRSIZ];
-X};
-X
-X/*
-X * get next entry in a directory.
-X */
-Xstruct direct *
-Xreaddir(dirp)
-X register DIR *dirp;
-X{
-X register struct olddirect *dp;
-X static struct direct dir;
-X
-X for (;;) {
-X if (dirp->dd_loc == 0) {
-X dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
-X DIRBLKSIZ);
-X if (dirp->dd_size <= 0) {
-X dirp->dd_size = 0;
-X return NULL;
-X }
-X }
-X if (dirp->dd_loc >= dirp->dd_size) {
-X dirp->dd_loc = 0;
-X continue;
-X }
-X dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
-X dirp->dd_loc += sizeof(struct olddirect);
-X if (dp->od_ino == 0)
-X continue;
-X dir.d_ino = dp->od_ino;
-X strncpy(dir.d_name, dp->od_name, ODIRSIZ);
-X dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
-X dir.d_namlen = strlen(dir.d_name);
-X dir.d_reclen = DIRBLKSIZ;
-X return (&dir);
-X }
-X}
-!
-echo 'seekdir.c':
-sed 's/^X//' >'seekdir.c' <<'!'
-Xstatic char sccsid[] = "@(#)seekdir.c 4.9 3/25/83";
-X
-X#include <sys/param.h>
-X#include <dir.h>
-X
-X/*
-X * seek to an entry in a directory.
-X * Only values returned by "telldir" should be passed to seekdir.
-X */
-Xvoid
-Xseekdir(dirp, loc)
-X register DIR *dirp;
-X long loc;
-X{
-X long curloc, base, offset;
-X struct direct *dp;
-X extern long lseek();
-X
-X curloc = telldir(dirp);
-X if (loc == curloc)
-X return;
-X base = loc & ~(DIRBLKSIZ - 1);
-X offset = loc & (DIRBLKSIZ - 1);
-X (void) lseek(dirp->dd_fd, base, 0);
-X dirp->dd_size = 0;
-X dirp->dd_loc = 0;
-X while (dirp->dd_loc < offset) {
-X dp = readdir(dirp);
-X if (dp == NULL)
-X return;
-X }
-X}
-!
-echo 'telldir.c':
-sed 's/^X//' >'telldir.c' <<'!'
-Xstatic char sccsid[] = "@(#)telldir.c 4.1 2/21/82";
-X
-X#include <sys/types.h>
-X#include <dir.h>
-X
-X/*
-X * return a pointer into a directory
-X */
-Xlong
-Xtelldir(dirp)
-X DIR *dirp;
-X{
-X long lseek();
-X
-X return (lseek(dirp->dd_fd, 0L, 1) - dirp->dd_size + dirp->dd_loc);
-X}
-!
-echo done
diff --git a/gnu/usr.bin/cvs/contrib/log.pl b/gnu/usr.bin/cvs/contrib/log.pl
deleted file mode 100644
index a6c75f6..0000000
--- a/gnu/usr.bin/cvs/contrib/log.pl
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/perl
-
-# Modified by berliner@Sun.COM to add support for CVS 1.3 2/27/92
-#
-# Date: Tue, 6 Aug 91 13:27 EDT
-# From: samborn@sunrise.com (Kevin Samborn)
-#
-# I revised the perl script I sent you yesterday to use the info you
-# send in on stdin. (I am appending the newer script to the end)
-#
-# now the output looks like this:
-#
-# **************************************
-# date: Tuesday, August 6, 1991 @ 13:17
-# author: samborn
-# Update of /elmer/cvs/CVSROOT.adm
-# In directory astro:/home/samborn/CVSROOT.adm
-#
-# Modified Files:
-# test3
-#
-# Added Files:
-# test6
-#
-# Removed Files:
-# test4
-#
-# Log Message:
-# wow, what a test
-#
-# RCS: 1.4 /elmer/cvs/CVSROOT.adm/test3,v
-# RCS: 1.1 /elmer/cvs/CVSROOT.adm/test6,v
-# RCS: 1.1 /elmer/cvs/CVSROOT.adm/Attic/test4,v
-#
-
-#
-# turn off setgid
-#
-$) = $(;
-
-#
-# parse command line arguments
-#
-@files = split(/ /,$ARGV[0]);
-$logfile = $ARGV[1];
-$cvsroot = $ENV{'CVSROOT'};
-
-#
-# Some date and time arrays
-#
-@mos = (January,February,March,April,May,June,July,August,September,
- October,November,December);
-@days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday);
-($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
-
-#
-# get login name
-#
-$login = getlogin || (getpwuid($<))[0] || "nobody";
-
-#
-# open log file for appending
-#
-if ((open(OUT, ">>" . $logfile)) != 1) {
- die "Could not open logfile " . $logfile . "\n";
-}
-
-#
-# Header
-#
-print OUT "\n";
-print OUT "**************************************\n";
-print OUT "date: " . $days[$wday] . ", " . $mos[$mon] . " " . $mday . ", 19" . $year .
- " @ " . $hour . ":" . sprintf("%02d", $min) . "\n";
-print OUT "author: " . $login . "\n";
-
-#
-#print the stuff on stdin to the logfile
-#
-open(IN, "-");
-while(<IN>) {
- print OUT $_;
-}
-close(IN);
-
-print OUT "\n";
-
-#
-# after log information, do an 'cvs -Qn status' on each file in the arguments.
-#
-for $file (@files[1..$#files]) {
- if ($file eq "-") {
- last;
- }
- open(RCS,"-|") || exec 'cvs', '-Qn', 'status', $file;
- while (<RCS>) {
- if (substr($_, 0, 7) eq " RCS") {
- print OUT;
- }
- }
- close (RCS);
-}
-
-close (OUT);
diff --git a/gnu/usr.bin/cvs/contrib/log_accum.pl b/gnu/usr.bin/cvs/contrib/log_accum.pl
deleted file mode 100644
index 798e25f..0000000
--- a/gnu/usr.bin/cvs/contrib/log_accum.pl
+++ /dev/null
@@ -1,331 +0,0 @@
-#!/usr/local/bin/perl -w
-#
-# Perl filter to handle the log messages from the checkin of files in
-# a directory. This script will group the lists of files by log
-# message, and mail a single consolidated log message at the end of
-# the commit.
-#
-# This file assumes a pre-commit checking program that leaves the
-# names of the first and last commit directories in a temporary file.
-#
-# Contributed by David Hampton <hampton@cisco.com>
-#
-
-############################################################
-#
-# Configurable options
-#
-############################################################
-#
-# Do cisco Systems, Inc. specific nonsense.
-#
-$cisco_systems = 1;
-
-#
-# Recipient of all mail messages
-#
-$mailto = "sw-notification@cisco.com";
-
-############################################################
-#
-# Constants
-#
-############################################################
-$STATE_NONE = 0;
-$STATE_CHANGED = 1;
-$STATE_ADDED = 2;
-$STATE_REMOVED = 3;
-$STATE_LOG = 4;
-
-$LAST_FILE = "/tmp/#cvs.lastdir";
-$CHANGED_FILE = "/tmp/#cvs.files.changed";
-$ADDED_FILE = "/tmp/#cvs.files.added";
-$REMOVED_FILE = "/tmp/#cvs.files.removed";
-$LOG_FILE = "/tmp/#cvs.files.log";
-$FILE_PREFIX = "#cvs.files";
-
-$VERSION_FILE = "version";
-$TRUNKREV_FILE = "TrunkRev";
-$CHANGES_FILE = "Changes";
-$CHANGES_TEMP = "Changes.tmp";
-
-############################################################
-#
-# Subroutines
-#
-############################################################
-
-sub format_names {
- local($dir, @files) = @_;
- local(@lines);
- $lines[0] = sprintf(" %-08s", $dir);
- foreach $file (@files) {
- if (length($lines[$#lines]) + length($file) > 60) {
- $lines[++$#lines] = sprintf(" %8s", " ");
- }
- $lines[$#lines] .= " ".$file;
- }
- @lines;
-}
-
-sub cleanup_tmpfiles {
- local($all) = @_;
- local($wd, @files);
-
- $wd = `pwd`;
- chdir("/tmp");
- opendir(DIR, ".");
- if ($all == 1) {
- push(@files, grep(/$id$/, readdir(DIR)));
- } else {
- push(@files, grep(/^$FILE_PREFIX.*$id$/, readdir(DIR)));
- }
- closedir(DIR);
- foreach (@files) {
- unlink $_;
- }
- chdir($wd);
-}
-
-sub write_logfile {
- local($filename, @lines) = @_;
- open(FILE, ">$filename") || die ("Cannot open log file $filename.\n");
- print(FILE join("\n", @lines), "\n");
- close(FILE);
-}
-
-sub append_to_file {
- local($filename, $dir, @files) = @_;
- if (@files) {
- local(@lines) = &format_names($dir, @files);
- open(FILE, ">>$filename") || die ("Cannot open file $filename.\n");
- print(FILE join("\n", @lines), "\n");
- close(FILE);
- }
-}
-
-sub write_line {
- local($filename, $line) = @_;
- open(FILE, ">$filename") || die("Cannot open file $filename.\n");
- print(FILE $line, "\n");
- close(FILE);
-}
-
-sub read_line {
- local($line);
- local($filename) = @_;
- open(FILE, "<$filename") || die("Cannot open file $filename.\n");
- $line = <FILE>;
- close(FILE);
- chop($line);
- $line;
-}
-
-sub read_file {
- local(@text);
- local($filename, $leader) = @_;
- open(FILE, "<$filename") || return ();
- while (<FILE>) {
- chop;
- push(@text, sprintf(" %-10s %s", $leader, $_));
- $leader = "";
- }
- close(FILE);
- @text;
-}
-
-sub read_logfile {
- local(@text);
- local($filename, $leader) = @_;
- open(FILE, "<$filename") || die ("Cannot open log file $filename.\n");
- while (<FILE>) {
- chop;
- push(@text, $leader.$_);
- }
- close(FILE);
- @text;
-}
-
-sub bump_version {
- local($trunkrev, $editnum, $version);
-
- $trunkrev = &read_line("$ENV{'CVSROOT'}/$repository/$TRUNKREV_FILE");
- $editnum = &read_line("$ENV{'CVSROOT'}/$repository/$VERSION_FILE");
- &write_line("$ENV{'CVSROOT'}/$repository/$VERSION_FILE", $editnum+1);
- $version = $trunkrev . "(" . $editnum . ")";
-}
-
-sub build_header {
- local($version) = @_;
- local($header);
- local($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
- $header = sprintf("%-8s %s %02d/%02d/%02d %02d:%02d:%02d",
- $login, $version, $year%100, $mon+1, $mday,
- $hour, $min, $sec);
-}
-
-sub do_changes_file {
- local($changes, $tmpchanges);
- local(@text) = @_;
-
- $changes = "$ENV{'CVSROOT'}/$repository/$CHANGES_FILE";
- $tmpchanges = "$ENV{'CVSROOT'}/$repository/$CHANGES_TEMP";
- if (rename($changes, $tmpchanges) != 1) {
- die("Cannot rename $changes to $tmpchanges.\n");
- }
- open(CHANGES, ">$changes") || die("Cannot open $changes.\n");
- open(TMPCHANGES, "<$tmpchanges") || die("Cannot open $tmpchanges.\n");
- print(CHANGES join("\n", @text), "\n\n");
- print(CHANGES <TMPCHANGES>);
- close(CHANGES);
- close(TMPCHANGES);
- unlink($tmpchanges);
-}
-
-sub mail_notification {
- local($name, @text) = @_;
- open(MAIL, "| mail -s \"Source Repository Modification\" $name");
- print(MAIL join("\n", @text));
- close(MAIL);
-}
-
-#############################################################
-#
-# Main Body
-#
-############################################################
-
-#
-# Initialize basic variables
-#
-$id = getpgrp();
-$state = $STATE_NONE;
-$login = getlogin || (getpwuid($<))[0] || die("Unknown user $<.\n");
-@files = split(' ', $ARGV[0]);
-@path = split('/', $files[0]);
-$repository = @path[0];
-if ($#path == 0) {
- $dir = ".";
-} else {
- $dir = join('/', @path[1..$#path]);
-}
-#print("ARGV - ", join(":", @ARGV), "\n");
-#print("files - ", join(":", @files), "\n");
-#print("path - ", join(":", @path), "\n");
-#print("dir - ", $dir, "\n");
-#print("id - ", $id, "\n");
-
-#
-# Check for a new directory first. This will always appear as a
-# single item in the argument list, and an empty log message.
-#
-if ($ARGV[0] =~ /New directory/) {
- $version = &bump_version if ($cisco_systems != 0);
- $header = &build_header($version);
- @text = ();
- push(@text, $header);
- push(@text, "");
- push(@text, " ".$ARGV[0]);
- &do_changes_file(@text) if ($cisco_systems != 0);
- &mail_notification($mailto, @text);
- exit 0;
-}
-
-#
-# Iterate over the body of the message collecting information.
-#
-while (<STDIN>) {
- chop; # Drop the newline
- if (/^Modified Files/) { $state = $STATE_CHANGED; next; }
- if (/^Added Files/) { $state = $STATE_ADDED; next; }
- if (/^Removed Files/) { $state = $STATE_REMOVED; next; }
- if (/^Log Message/) { $state = $STATE_LOG; next; }
- s/^[ \t\n]+//; # delete leading space
- s/[ \t\n]+$//; # delete trailing space
-
- push (@changed_files, split) if ($state == $STATE_CHANGED);
- push (@added_files, split) if ($state == $STATE_ADDED);
- push (@removed_files, split) if ($state == $STATE_REMOVED);
- push (@log_lines, $_) if ($state == $STATE_LOG);
-}
-
-#
-# Strip leading and trailing blank lines from the log message. Also
-# compress multiple blank lines in the body of the message down to a
-# single blank line.
-#
-while ($#log_lines > -1) {
- last if ($log_lines[0] ne "");
- shift(@log_lines);
-}
-while ($#log_lines > -1) {
- last if ($log_lines[$#log_lines] ne "");
- pop(@log_lines);
-}
-for ($i = $#log_lines; $i > 0; $i--) {
- if (($log_lines[$i - 1] eq "") && ($log_lines[$i] eq "")) {
- splice(@log_lines, $i, 1);
- }
-}
-
-#
-# Find the log file that matches this log message
-#
-for ($i = 0; ; $i++) {
- last if (! -e "$LOG_FILE.$i.$id");
- @text = &read_logfile("$LOG_FILE.$i.$id", "");
- last if ($#text == -1);
- last if (join(" ", @log_lines) eq join(" ", @text));
-}
-
-#
-# Spit out the information gathered in this pass.
-#
-&write_logfile("$LOG_FILE.$i.$id", @log_lines);
-&append_to_file("$ADDED_FILE.$i.$id", $dir, @added_files);
-&append_to_file("$CHANGED_FILE.$i.$id", $dir, @changed_files);
-&append_to_file("$REMOVED_FILE.$i.$id", $dir, @removed_files);
-
-#
-# Check whether this is the last directory. If not, quit.
-#
-$_ = &read_line("$LAST_FILE.$id");
-exit 0 if (! grep(/$files[0]$/, $_));
-
-#
-# This is it. The commits are all finished. Lump everything together
-# into a single message, fire a copy off to the mailing list, and drop
-# it on the end of the Changes file.
-#
-# Get the full version number
-#
-$version = &bump_version if ($cisco_systems != 0);
-$header = &build_header($version);
-
-#
-# Produce the final compilation of the log messages
-#
-@text = ();
-push(@text, $header);
-push(@text, "");
-for ($i = 0; ; $i++) {
- last if (! -e "$LOG_FILE.$i.$id");
- push(@text, &read_file("$CHANGED_FILE.$i.$id", "Modified:"));
- push(@text, &read_file("$ADDED_FILE.$i.$id", "Added:"));
- push(@text, &read_file("$REMOVED_FILE.$i.$id", "Removed:"));
- push(@text, " Log:");
- push(@text, &read_logfile("$LOG_FILE.$i.$id", " "));
- push(@text, "");
-}
-if ($cisco_systems != 0) {
- @ddts = grep(/^CSCdi/, split(' ', join(" ", @text)));
- $text[0] .= " " . join(" ", @ddts);
-}
-#
-# Put the log message at the beginning of the Changes file and mail
-# out the notification.
-#
-&do_changes_file(@text) if ($cisco_systems != 0);
-&mail_notification($mailto, @text);
-&cleanup_tmpfiles(1);
-exit 0;
diff --git a/gnu/usr.bin/cvs/contrib/mfpipe.pl b/gnu/usr.bin/cvs/contrib/mfpipe.pl
deleted file mode 100644
index 74cc5e1..0000000
--- a/gnu/usr.bin/cvs/contrib/mfpipe.pl
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/perl
-#
-# From: clyne@niwot.scd.ucar.EDU (John Clyne)
-# Date: Fri, 28 Feb 92 09:54:21 MST
-#
-# BTW, i wrote a perl script that is similar to 'nfpipe' except that in
-# addition to logging to a file it provides a command line option for mailing
-# change notices to a group of users. Obviously you probably wouldn't want
-# to mail every change. But there may be certain directories that are commonly
-# accessed by a group of users who would benefit from an email notice.
-# Especially if they regularly beat on the same directory. Anyway if you
-# think anyone would be interested here it is.
-#
-# mfpipe.pl,v 1.1 1992/03/02 01:22:41 berliner Exp
-#
-#
-# File: mfpipe
-#
-# Author: John Clyne
-# National Center for Atmospheric Research
-# PO 3000, Boulder, Colorado
-#
-# Date: Wed Feb 26 18:34:53 MST 1992
-#
-# Description: Tee standard input to mail a list of users and to
-# a file. Used by CVS logging.
-#
-# Usage: mfpipe [-f file] [user@host...]
-#
-# Environment: CVSROOT
-# Path to CVS root.
-#
-# Files:
-#
-#
-# Options: -f file
-# Capture output to 'file'
-#
-
-$header = "Log Message:\n";
-
-$mailcmd = "| mail -s 'CVS update notice'";
-$whoami = `whoami`;
-chop $whoami;
-$date = `date`;
-chop $date;
-
-$cvsroot = $ENV{'CVSROOT'};
-
-while (@ARGV) {
- $arg = shift @ARGV;
-
- if ($arg eq '-f') {
- $file = shift @ARGV;
- }
- else {
- $users = "$users $arg";
- }
-}
-
-if ($users) {
- $mailcmd = "$mailcmd $users";
- open(MAIL, $mailcmd) || die "Execing $mail: $!\n";
-}
-
-if ($file) {
- $logfile = "$cvsroot/LOG/$file";
- open(FILE, ">> $logfile") || die "Opening $logfile: $!\n";
-}
-
-print FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile);
-
-while (<>) {
- print FILE $log if ($log && $logfile);
-
- print FILE $_ if ($logfile);
- print MAIL $_ if ($users);
-
- $log = "log: " if ($_ eq $header);
-}
-
-close FILE;
-die "Write failed" if $?;
-close MAIL;
-die "Mail failed" if $?;
-
-exit 0;
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog b/gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog
deleted file mode 100644
index fab9a7d..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog
+++ /dev/null
@@ -1,119 +0,0 @@
-Tue Apr 7 09:11:27 1992 Per Cederqvist (ceder@leopold)
-
- * Release 1.02.
-
- * pcl-cvs.el (cvs-diff-backup, cvs-edit-done, cvs-status): Call
- save-some-buffers.
-
- * pcl-cvs.el (cvs-diff-backup-extractor): Fixed syntax error.
-
- * Makefile, README, compile-all.el, dist-makefile, pcl-cvs.el,
- pcl-cvs.texinfo (XXRELEASEXX): A magic string that is substituted
- for the current release number when a distribution is made.
- (Release 1.01 says that it is release 1.00).
-
- * pcl-cvs.el (cvs-find-file): Added missing pair of parenthesis.
-
-Mon Mar 30 14:25:26 1992 Per Cederqvist (ceder@leopold)
-
- * Release 1.01.
-
- * pcl-cvs.el (cvs-parse-buffer): The message when waiting for a
- lock has been changed.
-
-Sun Mar 29 05:29:57 1992 Per Cederqvist (ceder@leopold)
-
- * Release 1.00.
-
- * pcl-cvs.el (cvs-do-update, cvs-sentinel, cvs-parse-buffer):
- Major rewrite of buffer and window selection and handling.
- The *cvs* buffer is now killed whenever a new "cvs update" is
- initiated. The -update buffer is replaced with the *cvs*
- buffer when the update is completed.
-
-Sat Mar 28 21:03:05 1992 Per Cederqvist (ceder@robin)
-
- * pcl-cvs.el (cvs-delete-unused-temporary-buffers): Fixed it.
-
- * pcl-cvs.el (cvs-auto-remove-handled): New variable.
- * pcl-cvs.el (cvs-edit-done): Use it.
- * pcl-cvs.texinfo (Customization, Removing handled entries):
- Document it.
-
- * pcl-cvs.el (cvs-mode): Turn of the undo feature. It really
- isn't useful in a cookie buffer...
-
- * pcl-cvs.el (cvs-edit-done): Committing a file now looks more
- like diffing a file. The window handling is better.
- * pcl-cvs.el (cvs-use-temp-buffer): The &optional switch is no
- longer needed.
-
-Mon Mar 23 00:20:33 1992 Per Cederqvist (ceder@robin)
-
- * Release 0.97.
-
- * pcl-cvs.el (default-directory): Make sure it always ends in a
- slash. fileinfo->dir does NOT end in a slash, and I had forgotten
- to call file-name-as-directory in various places.
-
- * pcl-cvs.el (cvs-diff-backup-extractor): Signal an error if a
- fileinfo without backup file is given.
-
- * pcl-cvs.el (cvs-mode): Added documentation.
-
- * pcl-cvs.el (cvs-execute-list): Fix the order of files in the
- same directory.
-
- * pcl-cvs.el (cvs-log-flags, cvs-status-flags): New variables.
- * pcl-cvs.el (cvs-log, cvs-status): Use them.
- * pcl-cvs.texinfo (Customization): Document them.
-
- * pcl-cvs.el (cvs-diff-backup): Filter non-backup-diffable files
- at an earlier stage, like cvs-commit does.
-
- * pcl-cvs.el (cvs-diff-flags): New variable.
- * pcl-cvs.el (cvs-diff-backup): Use it.
- * pcl-cvs.texinfo (Customization): Document it.
-
- * pcl-cvs.el (cvs-execute-single-file-list): Remove &rest before
- last argument. No callers needed updating.
-
- * pcl-cvs.el (cvs-execute-list): Remove the &rest before the last
- argument (constant-args). Update all callers of cvs-execute-list
- to use the new calling convention.
- * pcl-cvs.el (cvs-cvs-diff-flags): Now a list of strings instead
- of a string.
- * pcl-cvs.texinfo (Customization): Document the change to
- cvs-cvs-diff-flags.
-
- * Release 0.96.
-
- * pcl-cvs.el (cvs-cvs-diff-flags): New variable.
- * pcl-cvs.el (cvs-diff-cvs): Use it.
- * pcl-cvs.texinfo (Customization, Viewing differences): Document it.
-
- * pcl-cvs.el (cvs-use-temp-buffe): Don't switch to the temporary
- buffer. Use display-buffer and set-buffer instead. This way
- cvs-log, cvs-status, cvs-diff-cvs and friends don't select the
- temporary buffer. The cursor will remain in the *cvs* buffer.
-
-Sun Mar 22 21:50:18 1992 Per Cederqvist (ceder@robin)
-
- * pcl-cvs.el (cvs-find-file, cvs-find-file-other-window): Don't
- prompt when reading in a directory in dired.
-
- * Makefile (pcl-cvs-$(VER)): Include pcl-cvs-startup.el in the
- distribution.
-
- * dist-makefile (pcl-cvs.dvi): Don't fail even if texindex does
- not exist.
-
- * pcl-cvs.texinfo (@setchapternewpage): Changed from 'off' to 'on'.
- * pcl-cvs.texinfo (Variable index): Joined into function index.
- * pcl-cvs.texinfo (Key index): add a description about the key.
- * pcl-cvs.texinfo: Many other small changes.
-
-Wed Mar 18 01:58:38 1992 Per Cederqvist (ceder@leopold)
-
- * Use GNU General Public License version 2.
-
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL b/gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL
deleted file mode 100644
index 8c89053..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL
+++ /dev/null
@@ -1,83 +0,0 @@
-This text is copied from the TeXinfo manual for pcl-cvs.
-
-Installation of the pcl-cvs program
-===================================
-
- 1. Edit the file `Makefile' to reflect the situation at your site.
- The only things you have to change is the definition of
- `lispdir' and `infodir'. The elisp files will be copied to
- `lispdir', and the info file to `infodir'.
-
- 2. Configure pcl-cvs.el
-
- There are a couple of paths that you have to check to make
- sure that they match you system. They appear early in the file
- pcl-cvs.el.
-
- *NOTE:* If your system is running emacs 18.57 or earlier
- you MUST uncomment the line that says:
-
- (setq delete-exited-processes nil)
-
- Setting `delete-exited-processes' to `nil' works around a bug
- in emacs that causes it to dump core. The bug was fixed in
- emacs 18.58.
-
- 3. Type `make install' in the source directory. This will
- byte-compile all `.el' files and copy both the `.el' and the
- `.elc' into the directory you specified in step 1.
-
- If you don't want to install the `.el' files but only the
- `.elc' files (the byte-compiled files), you can type ``make
- install_elc'' instead of ``make install''.
-
- If you only want to create the compiled elisp files, but
- don't want to install them, you can type `make elcfiles'
- instead. This is what happens if you only type `make' without
- parameters.
-
- 4. Edit the file `default.el' in your emacs lisp directory (usually
- `/usr/gnu/emacs/lisp' or something similar) and enter the
- contents of the file `pcl-cvs-startup.el' into it. It contains
- a couple of `auto-load's that facilitates the use of pcl-cvs.
-
-
-
-
-Installation of the on-line manual.
-===================================
-
- 1. Create the info file `pcl-cvs' from `pcl-cvs.texinfo' by typing
- `make info'. If you don't have the program `makeinfo' you can
- get it by anonymous ftp from e.g. `ftp.gnu.ai.mit.edu' as
- `pub/gnu/texinfo-2.14.tar.Z' (there might be a newer version
- there when you read this), or you could use the preformatted
- info file `pcl-cvs.info' that is included in the distribution
- (type `cp pcl-cvs.info pcl-cvs').
-
- 2. Move the info file `pcl-cvs' to your standard info directory.
- This might be called something like `/usr/gnu/emacs/info'.
-
- 3. Edit the file `dir' in the info directory and enter one line to
- contain a pointer to the info file `pcl-cvs'. The line can, for
- instance, look like this:
-
- * Pcl-cvs: (pcl-cvs). An Emacs front-end to CVS.
-
-
-
-
-How to make typeset documentation from pcl-cvs.texinfo
-======================================================
-
- If you have TeX installed at your site, you can make a typeset
-manual from `pcl-cvs.texinfo'.
-
- 1. Run TeX by typing ``make pcl-cvs.dvi''. You will not get the
- indices unless you have the `texindex' program.
-
- 2. Convert the resulting device independent file `pcl-cvs.dvi' to a
- form which your printer can output and print it. If you have a
- postscript printer there is a program, `dvi2ps', which does.
- There is also a program which comes together with TeX, `dvips',
- which you can use.
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile b/gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile
deleted file mode 100644
index f0ded69..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile
+++ /dev/null
@@ -1,78 +0,0 @@
-# Makefile,v 1.2 1992/04/07 20:49:07 berliner Exp
-# Makefile for pcl-cvs release 1.02.
-# Copyright (C) 1992 Per Cederqvist
-#
-# 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.
-
-# This is the directory in which the ELFILES and ELCFILES will be
-# installed.
-
-lispdir = /usr/local/lib/elisp
-
-# Where to install the info file.
-
-prefix=/usr/local
-infodir = $(prefix)/info
-
-#
-# The rest of this file should not need to be modified.
-#
-
-# Just in case...
-SHELL = /bin/sh
-
-ELFILES = pcl-cvs.el cookie.el elib-dll.el elib-node.el
-ELCFILES = pcl-cvs.elc cookie.elc elib-dll.elc elib-node.elc
-INFOFILES = pcl-cvs
-TEXTMPS = pcl-cvs.aux pcl-cvs.log pcl-cvs.toc pcl-cvs.dvi pcl-cvs.cp \
- pcl-cvs.fn pcl-cvs.vr pcl-cvs.tp pcl-cvs.ky pcl-cvs.pg \
- pcl-cvs.cps pcl-cvs.fns pcl-cvs.kys pcl-cvs.pgs pcl-cvs.tps \
- pcl-cvs.vrs
-
-INSTALL = install
-INSTALL_DATA = $(INSTALL)
-
-elcfiles:
- emacs -batch -l ./compile-all.el -f compile-pcl-cvs
-
-all: elcfiles info
-
-# Don't install the info file yet, since it requires makeinfo
-# version 2.something (and version 1.something is distributed with emacs).
-#
-# install: install_elc install_info
-install: install_elc
- for i in $(ELFILES); do $(INSTALL_DATA) $$i $(lispdir)/$$i; done
-
-install_elc: elcfiles
- for i in $(ELCFILES); do $(INSTALL_DATA) $$i $(lispdir)/$$i; done
-
-install_info: pcl-cvs
- $(INSTALL_DATA) pcl-cvs $(infodir)/pcl-cvs
-
-info pcl-cvs: pcl-cvs.texinfo
- makeinfo +fill-column=70 pcl-cvs.texinfo
-
-pcl-cvs.dvi: pcl-cvs.texinfo
- tex pcl-cvs.texinfo
- -texindex pcl-cvs.cp pcl-cvs.fn pcl-cvs.vr pcl-cvs.tp pcl-cvs.ky \
- pcl-cvs.pg
- tex pcl-cvs.texinfo
-
-mostlyclean clean realclean:
- rm -f *~ core $(ELCFILES) $(INFOFILES) $(TEXTMPS)
-
-tags TAGS:
- etags *.el
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/README b/gnu/usr.bin/cvs/contrib/pcl-cvs/README
deleted file mode 100644
index 6f0a5fe..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/README
+++ /dev/null
@@ -1,14 +0,0 @@
-README,v 1.2 1992/04/07 20:49:09 berliner Exp
-
-This is the readme file for pcl-cvs, release 1.02.
-
-Pcl-cvs is a front-end to CVS version 1.3. It integrates the most
-frequently used CVS commands into emacs.
-
-There is some configuration that needs to be done in pcl-cvs.el to get
-it to work. See the instructions in file INSTALL.
-
-Full documentation is in pcl-cvs.texinfo. Since it requires makeinfo
-2.14 a preformatted info file is also included (pcl-cvs.info).
-
- ceder@lysator.liu.se
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el
deleted file mode 100644
index 74f1bca..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el
+++ /dev/null
@@ -1,52 +0,0 @@
-;;;; compile-all.el,v 1.2 1992/04/07 20:49:10 berliner Exp
-;;;; This file byte-compiles all .el files in pcl-cvs release 1.02.
-;;;;
-;;;; Copyright (C) 1991 Inge Wallin
-;;;;
-;;;; This file is part of the GNU Emacs lisp library, Elib.
-;;;;
-;;;; GNU Elib is free software; you can 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 Elib is distributed in the hope that it will be useful,
-;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 Emacs; see the file COPYING. If not, write to
-;;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-;;;;
-
-
-(setq elib-files '("elib-node"
- "elib-dll"
- "cookie"
- "pcl-cvs"))
-
-
-(defun compile-file-if-necessary (file)
- "Compile the Elib file FILE if necessary.
-
-This is done if FILE.el is newer than FILE.elc or if FILE.elc doesn't exist."
- (let ((el-name (concat file ".el"))
- (elc-name (concat file ".elc")))
- (if (or (not (file-exists-p elc-name))
- (file-newer-than-file-p el-name elc-name))
- (progn
- (message (format "Byte-compiling %s..." el-name))
- (byte-compile-file el-name)))))
-
-
-(defun compile-pcl-cvs ()
- "Byte-compile all uncompiled files of elib.
-Be sure to have . in load-path since a number of files in elib
-depend on other files and we always want the newer one even if
-a previous version of elib exists."
-
- (interactive)
- (setq load-path (append '(".") load-path))
- (mapcar (function compile-file-if-necessary)
- elib-files))
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/cookie.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/cookie.el
deleted file mode 100644
index 8bd4bdf..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/cookie.el
+++ /dev/null
@@ -1,884 +0,0 @@
-;;; cookie.el,v 1.2 1992/04/07 20:49:12 berliner Exp
-;;; cookie.el -- Utility to display cookies in buffers
-;;; Copyright (C) 1991, 1992 Per Cederqvist
-;;;
-;;; 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.
-
-;;;; TO-DO: Byt namn! tin -> wrapper (eller n}got b{ttre).
-
-;;; Note that this file is still under development. Comments,
-;;; enhancements and bug fixes are welcome.
-;;; Send them to ceder@lysator.liu.se.
-
-(defun impl nil (error "Not yet implemented!"))
-
-;;; Cookie is a package that imlements a connection between an
-;;; elib-dll and the contents of a buffer. Possible uses are dired
-;;; (have all files in a list, and show them), buffer-list,
-;;; kom-prioritize (in the LysKOM elisp client) and others. pcl-cvs.el
-;;; uses cookie.el.
-;;;
-;;; A cookie buffer contains a header, any number of cookies, and a
-;;; footer. The header and footer are constant strings that are given
-;;; to cookie-create when the buffer is placed under cookie. Each cookie
-;;; is displayed in the buffer by calling a user-supplied function
-;;; that takes a cookie and returns a string. The string may be
-;;; empty, or contain any number of lines. An extra newline is always
-;;; appended unless the string is empty.
-;;;
-;;; Cookie does not affect the mode of the buffer in any way. It
-;;; merely makes it easy to connect an underlying data representation
-;;; to the buffer contents.
-;;;
-;;; The cookie-node data type:
-;;; start-marker
-;;; ;; end-marker This field is no longer present.
-;;; cookie The user-supplied element.
-;;;
-;;; A dll of cookie-nodes are held in the buffer local variable
-;;; cake-tin.
-;;;
-;;; A tin is an object that contains one cookie. You can get the next
-;;; and previous tin.
-;;;
-
-(require 'elib-dll)
-(provide 'cookie)
-
-(defvar cookies nil
- "A doubly linked list that contains the underlying data representation
-for the contents of a cookie buffer. The package elib-dll is used to
-manipulate this list.")
-
-(defvar cookie-pretty-printer nil
- "The function that is used to pretty-print a cookie in this buffer.")
-
-(defvar cookie-header nil
- "The tin that holds the header cookie.")
-
-(defvar cookie-footer nil
- "The tin that holds the footer cookie.")
-
-(defvar cookie-last-tin nil
- "The tin the cursor was positioned at, the last time the cookie
-package checked the cursor position. Buffer local in all buffers
-the cookie package works on. You may set this if your package
-thinks it knows where the cursor will be the next time this
-package is called. It can speed things up.
-
-It must never be set to a tin that has been deleted.")
-
-;;; ================================================================
-;;; Internal functions for use in the cookie package
-
-(put 'cookie-set-buffer 'lisp-indent-hook 1)
-
-(defmacro cookie-set-buffer (buffer &rest forms)
-
- ;; Execute FORMS with BUFFER selected as current buffer.
- ;; Return value of last form in FORMS. INTERNAL USE ONLY.
-
- (let ((old-buffer (make-symbol "old-buffer")))
- (` (let (((, old-buffer) (current-buffer)))
- (set-buffer (get-buffer-create (, buffer)))
- (unwind-protect
- (progn (,@ forms))
- (set-buffer (, old-buffer)))))))
-
-
-(defmacro cookie-filter-hf (tin)
-
- ;; Evaluate TIN once and return it. BUT if it is
- ;; equal to cookie-header or cookie-footer return nil instead.
- ;; INTERNAL USE ONLY.
-
- (let ((tempvar (make-symbol "tin")))
- (` (let (((, tempvar) (, tin)))
- (if (or (eq (, tempvar) cookie-header)
- (eq (, tempvar) cookie-footer))
- nil
- (, tempvar))))))
-
-
-;;; cookie-tin
-;;; Constructor:
-
-(defun cookie-create-tin (start-marker
- cookie)
- ;; Create a tin. INTERNAL USE ONLY.
- (cons 'COOKIE-TIN (vector start-marker nil cookie)))
-
-
-;;; Selectors:
-
-(defun cookie-tin-start-marker (cookie-tin)
- ;; Get start-marker from cookie-tin. INTERNAL USE ONLY.
- (elt (cdr cookie-tin) 0))
-
-;(defun cookie-tin-end-marker (cookie-tin)
-; ;;Get end-marker from cookie-tin. INTERNAL USE ONLY.
-; (elt (cdr cookie-tin) 1))
-
-(defun cookie-tin-cookie-safe (cookie-tin)
- ;; Get cookie from cookie-tin. INTERNAL USE ONLY.
- ;; Returns nil if given nil as input.
- ;; This is the same as cookie-tin-cookie in version 18.57
- ;; of emacs, but elt should signal an error when given nil
- ;; as input (according to the info files).
- (elt (cdr cookie-tin) 2))
-
-(defun cookie-tin-cookie (cookie-tin)
- ;; Get cookie from cookie-tin. INTERNAL USE ONLY.
- (elt (cdr cookie-tin) 2))
-
-
-;;; Modifiers:
-
-(defun set-cookie-tin-start-marker (cookie-tin newval)
- ;; Set start-marker in cookie-tin to NEWVAL. INTERNAL USE ONLY.
- (aset (cdr cookie-tin) 0 newval))
-
-;(defun set-cookie-tin-end-marker (cookie-tin newval)
-; ;; Set end-marker in cookie-tin to NEWVAL. INTERNAL USE ONLY.
-; (aset (cdr cookie-tin) 1 newval))
-
-(defun set-cookie-tin-cookie (cookie-tin newval)
- ;; Set cookie in cookie-tin to NEWVAL. INTERNAL USE ONLY.
- (aset (cdr cookie-tin) 2 newval))
-
-
-
-;;; Predicate:
-
-(defun cookie-tin-p (object)
- ;; Return t if OBJECT is a tin. INTERNAL USE ONLY.
- (eq (car-safe object) 'COOKIE-TIN))
-
-;;; end of cookie-tin data type.
-
-
-(defun cookie-create-tin-and-insert (cookie string pos)
- ;; Insert STRING at POS in current buffer. Remember start
- ;; position. Create a tin containing them and the COOKIE.
- ;; INTERNAL USE ONLY.
-
- (save-excursion
- (goto-char pos)
- ;; Remember the position as a number so that it doesn't move
- ;; when we insert the string.
- (let ((start (if (markerp pos)
- (marker-position pos)
- pos)))
- ;; Use insert-before-markers so that the marker for the
- ;; next cookie is updated.
- (insert-before-markers string)
- (insert-before-markers ?\n)
- (cookie-create-tin (copy-marker start) cookie))))
-
-
-(defun cookie-delete-tin-internal (tin)
- ;; Delete a cookie from the buffer. INTERNAL USE ONLY.
- ;; Can not be used on the footer.
- (delete-region (cookie-tin-start-marker (dll-element cookies tin))
- (cookie-tin-start-marker
- (dll-element cookies
- (dll-next cookies tin)))))
-
-
-
-(defun cookie-refresh-tin (tin)
- ;; Redisplay the cookie represented by TIN. INTERNAL USE ONLY.
- ;; Can not be used on the footer.
-
- (save-excursion
- ;; First, remove the string:
- (delete-region (cookie-tin-start-marker (dll-element cookies tin))
- (1- (marker-position
- (cookie-tin-start-marker
- (dll-element cookies
- (dll-next cookies tin))))))
-
- ;; Calculate and insert the string.
-
- (goto-char (cookie-tin-start-marker (dll-element cookies tin)))
- (insert
- (funcall cookie-pretty-printer
- (cookie-tin-cookie (dll-element cookies tin))))))
-
-
-;;; ================================================================
-;;; The public members of the cookie package
-
-
-(defun cookie-cookie (buffer tin)
- "Get the cookie from a TIN. Args: BUFFER TIN."
- (cookie-set-buffer buffer
- (cookie-tin-cookie (dll-element cookies tin))))
-
-
-
-
-(defun cookie-create (buffer pretty-printer &optional header footer)
-
- "Start to use the cookie package in BUFFER.
-BUFFER may be a buffer or a buffer name. It is created if it does not exist.
-Beware that the entire contents of the buffer will be erased.
-PRETTY-PRINTER is a function that takes one cookie and returns a string
-to be displayed in the buffer. The string may be empty. If it is not
-empty a newline will be added automatically. It may span several lines.
-Optional third argument HEADER is a string that will always be present
-at the top of the buffer. HEADER should end with a newline. Optionaly
-fourth argument FOOTER is similar, and will always be inserted at the
-bottom of the buffer."
-
- (cookie-set-buffer buffer
-
- (erase-buffer)
-
- (make-local-variable 'cookie-last-tin)
- (make-local-variable 'cookie-pretty-printer)
- (make-local-variable 'cookie-header)
- (make-local-variable 'cookie-footer)
- (make-local-variable 'cookies)
-
- (setq cookie-last-tin nil)
- (setq cookie-pretty-printer pretty-printer)
- (setq cookies (dll-create))
-
- (dll-enter-first cookies
- (cookie-create-tin-and-insert
- header header 0))
- (setq cookie-header (dll-nth cookies 0))
-
- (dll-enter-last cookies
- (cookie-create-tin-and-insert
- footer footer (point-max)))
- (setq cookie-footer (dll-nth cookies -1))
-
- (goto-char (point-min))
- (forward-line 1)))
-
-
-(defun cookie-set-header (buffer header)
- "Change the header. Args: BUFFER HEADER."
- (impl))
-
-
-(defun cookie-set-footer (buffer header)
- "Change the footer. Args: BUFFER FOOTER."
- (impl))
-
-
-
-(defun cookie-enter-first (buffer cookie)
- "Enter a COOKIE first in BUFFER.
-Args: BUFFER COOKIE."
-
- (cookie-set-buffer buffer
-
- ;; It is always safe to insert an element after the first element,
- ;; because the header is always present. (dll-nth cookies 0) should
- ;; never return nil.
-
- (dll-enter-after
- cookies
- (dll-nth cookies 0)
- (cookie-create-tin-and-insert
- cookie
- (funcall cookie-pretty-printer cookie)
- (cookie-tin-start-marker
- (dll-element cookies (dll-nth cookies 1)))))))
-
-
-
-(defun cookie-enter-last (buffer cookie)
- "Enter a COOKIE last in BUFFER.
-Args: BUFFER COOKIE."
-
- (cookie-set-buffer buffer
-
- ;; Remember that the header and footer are always present. There
- ;; is no need to check if (dll-nth cookies -2) returns nil.
-
- (dll-enter-before
- cookies
- (dll-nth cookies -1)
- (cookie-create-tin-and-insert
- cookie
- (funcall cookie-pretty-printer cookie)
- (cookie-tin-start-marker (dll-last cookies))))))
-
-
-(defun cookie-enter-after (buffer node cookie)
- (impl))
-
-
-(defun cookie-enter-before (buffer node cookie)
- (impl))
-
-
-
-(defun cookie-next (buffer tin)
- "Get the next tin. Args: BUFFER TIN.
-Returns nil if TIN is nil or the last cookie."
- (if tin
- (cookie-set-buffer buffer
- (cookie-filter-hf (dll-next cookies tin)))))
-
-
-
-(defun cookie-previous (buffer tin)
- "Get the previous tin. Args: BUFFER TIN.
-Returns nil if TIN is nil or the first cookie."
- (if tin
- (cookie-set-buffer buffer
- (cookie-filter-hf (dll-previous cookies tin)))))
-
-
-(defun cookie-nth (buffer n)
-
- "Return the Nth tin. Args: BUFFER N.
-N counts from zero. Nil is returned if there is less than N cookies.
-If N is negative, return the -(N+1)th last element.
-Thus, (cookie-nth dll 0) returns the first node,
-and (cookie-nth dll -1) returns the last node.
-
-Use cookie-cookie to extract the cookie from the tin."
-
- (cookie-set-buffer buffer
-
- ;; Skip the header (or footer, if n is negative).
- (if (< n 0)
- (setq n (1- n))
- (setq n (1+ n)))
-
- (cookie-filter-hf (dll-nth cookies n))))
-
-
-
-(defun cookie-delete (buffer tin)
- "Delete a cookie. Args: BUFFER TIN."
-
- (cookie-set-buffer buffer
- (if (eq cookie-last-tin tin)
- (setq cookie-last-tin nil))
-
- (cookie-delete-tin-internal tin)
- (dll-delete cookies tin)))
-
-
-
-(defun cookie-delete-first (buffer)
- "Delete first cookie and return it. Args: BUFFER.
-Returns nil if there is no cookie left."
-
- (cookie-set-buffer buffer
-
- ;; We have to check that we do not try to delete the footer.
-
- (let ((tin (dll-nth cookies 1))) ;Skip the header.
- (if (eq tin cookie-footer)
- nil
- (cookie-delete-tin-internal tin)
- (cookie-tin-cookie (dll-delete cookies tin))))))
-
-
-
-(defun cookie-delete-last (buffer)
- "Delete last cookie and return it. Args: BUFFER.
-Returns nil if there is no cookie left."
-
- (cookie-set-buffer buffer
-
- ;; We have to check that we do not try to delete the header.
-
- (let ((tin (dll-nth cookies -2))) ;Skip the footer.
- (if (eq tin cookie-header)
- nil
- (cookie-delete-tin-internal tin)
- (cookie-tin-cookie (dll-delete cookies tin))))))
-
-
-
-(defun cookie-first (buffer)
-
- "Return the first cookie in BUFFER. The cookie is not removed."
-
- (cookie-set-buffer buffer
- (let ((tin (cookie-filter-hf (dll-nth cookies -1))))
- (if tin
- (cookie-tin-cookie-safe
- (dll-element cookies tin))))))
-
-
-(defun cookie-last (buffer)
-
- "Return the last cookie in BUFFER. The cookie is not removed."
-
- (cookie-set-buffer buffer
- (let ((tin (cookie-filter-hf (dll-nth cookies -2))))
- (if tin
- (cookie-tin-cookie-safe
- (dll-element cookies tin))))))
-
-
-(defun cookie-empty (buffer)
-
- "Return true if there are no cookies in BUFFER."
-
- (cookie-set-buffer buffer
- (eq (dll-nth cookies 1) cookie-footer)))
-
-
-(defun cookie-length (buffer)
-
- "Return number of cookies in BUFFER."
-
- ;; Don't count the footer and header.
-
- (cookie-set-buffer buffer
- (- (dll-length cookies) 2)))
-
-
-(defun cookie-all (buffer)
-
- "Return a list of all cookies in BUFFER."
-
- (cookie-set-buffer buffer
- (let (result
- (tin (dll-nth cookies -2)))
- (while (not (eq tin cookie-header))
- (setq result (cons (cookie-tin-cookie (dll-element cookies tin))
- result))
- (setq tin (dll-previous cookies tin)))
- result)))
-
-(defun cookie-clear (buffer)
-
- "Remove all cookies in buffer."
-
- (cookie-set-buffer buffer
- (cookie-create buffer cookie-pretty-printer
- (cookie-tin-cookie (dll-element cookies cookie-header))
- (cookie-tin-cookie (dll-element cookies cookie-footer)))))
-
-
-
-(defun cookie-map (map-function buffer &rest map-args)
-
- "Apply MAP-FUNCTION to all cookies in BUFFER.
-MAP-FUNCTION is applied to the first element first.
-If MAP-FUNCTION returns non-nil the cookie will be refreshed.
-
-Note that BUFFER will be current buffer when MAP-FUNCTION is called.
-
-If more than two arguments are given to cookie-map, remaining
-arguments will be passed to MAP-FUNCTION."
-
- (cookie-set-buffer buffer
- (let ((tin (dll-nth cookies 1))
- result)
-
- (while (not (eq tin cookie-footer))
-
- (if (apply map-function
- (cookie-tin-cookie (dll-element cookies tin))
- map-args)
- (cookie-refresh-tin tin))
-
- (setq tin (dll-next cookies tin))))))
-
-
-
-(defun cookie-map-reverse (map-function buffer &rest map-args)
-
- "Apply MAP-FUNCTION to all cookies in BUFFER.
-MAP-FUNCTION is applied to the last cookie first.
-If MAP-FUNCTION returns non-nil the cookie will be refreshed.
-
-Note that BUFFER will be current buffer when MAP-FUNCTION is called.
-
-If more than two arguments are given to cookie-map, remaining
-arguments will be passed to MAP-FUNCTION."
-
- (cookie-set-buffer buffer
- (let ((tin (dll-nth cookies -2))
- result)
-
- (while (not (eq tin cookie-header))
-
- (if (apply map-function
- (cookie-tin-cookie (dll-element cookies tin))
- map-args)
- (cookie-refresh-tin tin))
-
- (setq tin (dll-previous cookies tin))))))
-
-
-
-(defun cookie-enter-cookies (buffer cookie-list)
-
- "Insert all cookies in the list COOKIE-LIST last in BUFFER.
-Args: BUFFER COOKIE-LIST."
-
- (while cookie-list
- (cookie-enter-last buffer (car cookie-list))
- (setq cookie-list (cdr cookie-list))))
-
-
-(defun cookie-filter (buffer predicate)
-
- "Remove all cookies in BUFFER for which PREDICATE returns nil.
-Note that BUFFER will be current-buffer when PREDICATE is called.
-
-The PREDICATE is called with one argument, the cookie."
-
- (cookie-set-buffer buffer
- (let ((tin (dll-nth cookies 1))
- next)
- (while (not (eq tin cookie-footer))
- (setq next (dll-next cookies tin))
- (if (funcall predicate (cookie-tin-cookie (dll-element cookies tin)))
- nil
- (cookie-delete-tin-internal tin)
- (dll-delete cookies tin))
- (setq tin next)))))
-
-
-(defun cookie-filter-tins (buffer predicate)
-
- "Remove all cookies in BUFFER for which PREDICATE returns nil.
-Note that BUFFER will be current-buffer when PREDICATE is called.
-
-The PREDICATE is called with one argument, the tin."
-
- (cookie-set-buffer buffer
- (let ((tin (dll-nth cookies 1))
- next)
- (while (not (eq tin cookie-footer))
- (setq next (dll-next cookies tin))
- (if (funcall predicate tin)
- nil
- (cookie-delete-tin-internal tin)
- (dll-delete cookies tin))
- (setq tin next)))))
-
-(defun cookie-pos-before-middle-p (pos tin1 tin2)
-
- "Return true if POS is in the first half of the region defined by TIN1 and
-TIN2."
-
- (< pos (/ (+ (cookie-tin-start-marker (dll-element cookeis tin1))
- (cookie-tin-start-marker (dll-element cookeis tin2)))
- 2)))
-
-
-(defun cookie-get-selection (buffer pos &optional guess force-guess)
-
- "Return the tin the POS is within.
-Args: BUFFER POS &optional GUESS FORCE-GUESS.
-GUESS should be a tin that it is likely that POS is near. If FORCE-GUESS
-is non-nil GUESS is always used as a first guess, otherwise the first
-guess is the first tin, last tin, or GUESS, whichever is nearest to
-pos in the BUFFER.
-
-If pos points within the header, the first cookie is returned.
-If pos points within the footer, the last cookie is returned.
-Nil is returned if there is no cookie.
-
-It is often good to specify cookie-last-tin as GUESS, but remember
-that cookie-last-tin is buffer local in all buffers that cookie
-operates on."
-
- (cookie-set-buffer buffer
-
- (cond
- ; No cookies present?
- ((eq (dll-nth cookies 1) (dll-nth cookies -1))
- nil)
-
- ; Before first cookie?
- ((< pos (cookie-tin-start-marker
- (dll-element cookies (dll-nth cookies 1))))
- (dll-nth cookies 1))
-
- ; After last cookie?
- ((>= pos (cookie-tin-start-marker (dll-last cookies)))
- (dll-nth cookies -2))
-
- ; We now now that pos is within a cookie.
- (t
- ; Make an educated guess about which of the three known
- ; cookies (the first, the last, or GUESS) is nearest.
- (setq
- guess
- (cond
- (force-guess guess)
- (guess
- (cond
- ;; Closest to first cookie?
- ((cookie-pos-before-middle-p
- pos guess
- (dll-nth cookies 1))
- (dll-nth cookies 1))
- ;; Closest to GUESS?
- ((cookie-pos-before-middle-p
- pos guess
- cookie-footer)
- guess)
- ;; Closest to last cookie.
- (t (dll-previous cookies cookie-footer))))
- (t
- ;; No guess given.
- (cond
- ;; First half?
- ((cookie-pos-before-middle-p
- pos (dll-nth cookies 1)
- cookie-footer)
- (dll-nth cookies 1))
- (t (dll-previous cookies cookie-footer))))))
-
- ;; GUESS is now a "best guess".
-
- ;; Find the correct cookie. First determine in which direction
- ;; it lies, and then move in that direction until it is found.
-
- (cond
- ;; Is pos after the guess?
- ((>= pos (cookie-tin-start-marker (dll-element cookiess guess)))
-
- ;; Loop until we are exactly one cookie too far down...
- (while (>= pos (cookie-tin-start-marker (dll-element cookiess guess)))
- (setq guess (dll-next cookies guess)))
-
- ;; ...and return the previous cookie.
- (dll-previous cookies guess))
-
- ;; Pos is before guess
- (t
-
- (while (< pos (cookie-tin-start-marker (dll-element cookiess guess)))
- (setq guess (dll-previous cookies guess)))
-
- guess))))))
-
-
-(defun cookie-start-marker (buffer tin)
-
- "Return start-position of a cookie in BUFFER.
-Args: BUFFER TIN.
-The marker that is returned should not be modified in any way,
-and is only valid until the contents of the cookie buffer changes."
-
- (cookie-set-buffer buffer
- (cookie-tin-start-marker (dll-element cookies tin))))
-
-
-(defun cookie-end-marker (buffer tin)
-
- "Return end-position of a cookie in BUFFER.
-Args: BUFFER TIN.
-The marker that is returned should not be modified in any way,
-and is only valid until the contents of the cookie buffer changes."
-
- (cookie-set-buffer buffer
- (cookie-tin-start-marker
- (dll-element cookies (dll-next cookies tin)))))
-
-
-
-(defun cookie-refresh (buffer)
-
- "Refresh all cookies in BUFFER.
-Cookie-pretty-printer will be called for all cookies and the new result
-displayed.
-
-See also cookie-invalidate-tins."
-
- (cookie-set-buffer buffer
-
- (erase-buffer)
-
- (set-marker (cookie-tin-start-marker (dll-element cookies cookie-header))
- (point) buffer)
- (insert (cookie-tin-cookie (dll-element cookies cookie-header)))
- (insert "\n")
-
- (let ((tin (dll-nth cookies 1)))
- (while (not (eq tin cookie-footer))
-
- (set-marker (cookie-tin-start-marker (dll-element cookies tin))
- (point) buffer)
- (insert
- (funcall cookie-pretty-printer
- (cookie-tin-cookie (dll-element cookies tin))))
- (insert "\n")
- (setq tin (dll-next cookies tin))))
-
- (set-marker (cookie-tin-start-marker (dll-element cookies cookie-footer))
- (point) buffer)
- (insert (cookie-tin-cookie (dll-element cookies cookie-footer)))
- (insert "\n")))
-
-
-(defun cookie-invalidate-tins (buffer &rest tins)
-
- "Refresh some cookies.
-Args: BUFFER &rest TINS."
-
- (cookie-set-buffer buffer
-
- (while tins
- (cookie-refresh-tin (car tins))
- (setq tins (cdr tins)))))
-
-
-;;; Cookie movement commands.
-
-(defun cookie-set-goal-column (buffer goal)
- "Set goal-column for BUFFER.
-Args: BUFFER GOAL.
-goal-column is made buffer-local."
- (cookie-set-buffer buffer
- (make-local-variable 'goal-column)
- (setq goal-column goal)))
-
-
-(defun cookie-previous-cookie (buffer pos arg)
- "Move point to the ARGth previous cookie.
-Don't move if we are at the first cookie.
-ARG is the prefix argument when called interactively.
-Args: BUFFER POS ARG.
-Sets cookie-last-tin to the cookie we move to."
-
- (interactive (list (current-buffer) (point)
- (prefix-numeric-value current-prefix-arg)))
-
- (cookie-set-buffer buffer
- (setq cookie-last-tin
- (cookie-get-selection buffer pos cookie-last-tin))
-
- (while (and cookie-last-tin (> arg 0))
- (setq arg (1- arg))
- (setq cookie-last-tin
- (dll-previous cookies cookie-last-tin)))
-
- ;; Never step above the first cookie.
-
- (if (null (cookie-filter-hf cookie-last-tin))
- (setq cookie-last-tin (dll-nth cookies 1)))
-
- (goto-char
- (cookie-tin-start-marker
- (dll-element cookies cookie-last-tin)))
-
- (if goal-column
- (move-to-column goal-column))))
-
-
-
-(defun cookie-next-cookie (buffer pos arg)
- "Move point to the ARGth next cookie.
-Don't move if we are at the last cookie.
-ARG is the prefix argument when called interactively.
-Args: BUFFER POS ARG.
-Sets cookie-last-tin to the cookie we move to."
-
- (interactive (list (current-buffer) (point)
- (prefix-numeric-value current-prefix-arg)))
-
- (cookie-set-buffer buffer
- (setq cookie-last-tin
- (cookie-get-selection buffer pos cookie-last-tin))
-
- (while (and cookie-last-tin (> arg 0))
- (setq arg (1- arg))
- (setq cookie-last-tin
- (dll-next cookies cookie-last-tin)))
-
- (if (null (cookie-filter-hf cookie-last-tin))
- (setq cookie-last-tin (dll-nth cookies -2)))
-
- (goto-char
- (cookie-tin-start-marker
- (dll-element cookies cookie-last-tin)))
-
- (if goal-column
- (move-to-column goal-column))))
-
-
-(defun cookie-collect-tins (buffer predicate &rest predicate-args)
-
- "Return a list of all tins in BUFFER whose cookie PREDICATE
-returns true for.
-PREDICATE is a function that takes a cookie as its argument.
-The tins on the returned list will appear in the same order
-as in the buffer. You should not rely on in which order PREDICATE
-is called. Note that BUFFER is current-buffer when PREDICATE
-is called. (If you call cookie-collect with another buffer set
-as current-buffer and need to access buffer-local variables
-from that buffer within PREDICATE you must send them via
-PREDICATE-ARGS).
-
-If more than two arguments are given to cookie-collect the remaining
-arguments will be passed to PREDICATE.
-
-Use cookie-cookie to get the cookie from the tin."
-
- (cookie-set-buffer buffer
- (let ((tin (dll-nth cookies -2))
- result)
-
- (while (not (eq tin cookie-header))
-
- (if (apply predicate
- (cookie-tin-cookie (dll-element cookies tin))
- predicate-args)
- (setq result (cons tin result)))
-
- (setq tin (dll-previous cookies tin)))
- result)))
-
-
-(defun cookie-collect-cookies (buffer predicate &rest predicate-args)
-
- "Return a list of all cookies in BUFFER that PREDICATE
-returns true for.
-PREDICATE is a function that takes a cookie as its argument.
-The cookie on the returned list will appear in the same order
-as in the buffer. You should not rely on in which order PREDICATE
-is called. Note that BUFFER is current-buffer when PREDICATE
-is called. (If you call cookie-collect with another buffer set
-as current-buffer and need to access buffer-local variables
-from that buffer within PREDICATE you must send them via
-PREDICATE-ARGS).
-
-If more than two arguments are given to cookie-collect the remaining
-arguments will be passed to PREDICATE."
-
- (cookie-set-buffer buffer
- (let ((tin (dll-nth cookies -2))
- result)
-
- (while (not (eq tin cookie-header))
-
- (if (apply predicate
- (cookie-tin-cookie (dll-element cookies tin))
- predicate-args)
- (setq result (cons (cookie-tin-cookie (dll-element cookies tin))
- result)))
-
- (setq tin (dll-previous cookies tin)))
- result)))
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll-debug.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll-debug.el
deleted file mode 100644
index 733ff86..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll-debug.el
+++ /dev/null
@@ -1,298 +0,0 @@
-;;; elib-dll-debug -- A slow implementation of elib-dll for debugging.
-;;; elib-dll-debug.el,v 1.2 1992/04/07 20:49:13 berliner Exp
-;;; Copyright (C) 1991,1992 Per Cederqvist
-;;;
-;;; 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.
-
-
-;;; This is a plug-in replacement for elib-dll.el. It is dreadfully
-;;; slow, but it facilitates debugging. Don't trust the comments in
-;;; this file too much.
-(provide 'elib-dll)
-
-;;;
-;;; A doubly linked list consists of one cons cell which holds the tag
-;;; 'DL-LIST in the car cell and the list in the cdr
-;;; cell. The doubly linked list is implemented as a normal list. You
-;;; should use elib-dll.el and not this package in debugged code. This
-;;; package is not written for speed...
-;;;
-
-;;; ================================================================
-;;; Internal functions for use in the doubly linked list package
-
-(defun dll-get-dummy-node (dll)
-
- ;; Return the dummy node. INTERNAL USE ONLY.
- dll)
-
-(defun dll-list-nodes (dll)
-
- ;; Return a list of all nodes in DLL. INTERNAL USE ONLY.
-
- (cdr dll))
-
-(defun dll-set-from-node-list (dll list)
-
- ;; Set the contents of DLL to the nodes in LIST.
- ;; INTERNAL USE ONLY.
-
- (setcdr dll list))
-
-(defun dll-get-node-before (dll node)
- ;; Return the node in DLL that points to NODE. Use
- ;; (dll-get-node-before some-list nil) to get the last node.
- ;; INTERNAL USE ONLY.
- (while (and dll (not (eq (cdr dll) node)))
- (setq dll (cdr dll)))
- (if (not dll)
- (error "Node not on list"))
- dll)
-
-(defmacro dll-insert-after (node element)
- (let ((node-v (make-symbol "node"))
- (element-v (make-symbol "element")))
- (` (let (((, node-v) (, node))
- ((, element-v) (, element)))
- (setcdr (, node-v) (cons (, element-v) (cdr (, node-v))))))))
-
-;;; ===================================================================
-;;; The public functions which operate on doubly linked lists.
-
-(defmacro dll-element (dll node)
-
- "Get the element of a NODE in a doubly linked list DLL.
-Args: DLL NODE."
-
- (` (car (, node))))
-
-
-(defun dll-create ()
- "Create an empty doubly linked list."
- (cons 'DL-LIST nil))
-
-
-(defun dll-p (object)
- "Return t if OBJECT is a doubly linked list, otherwise return nil."
- (eq (car-safe object) 'DL-LIST))
-
-
-(defun dll-enter-first (dll element)
- "Add an element first on a doubly linked list.
-Args: DLL ELEMENT."
- (setcdr dll (cons element (cdr dll))))
-
-
-(defun dll-enter-last (dll element)
- "Add an element last on a doubly linked list.
-Args: DLL ELEMENT."
- (dll-insert-after (dll-get-node-before dll nil) element))
-
-
-(defun dll-enter-after (dll node element)
- "In the doubly linked list DLL, insert a node containing ELEMENT after NODE.
-Args: DLL NODE ELEMENT."
-
- (dll-get-node-before dll node)
- (dll-insert-after node element))
-
-
-(defun dll-enter-before (dll node element)
- "In the doubly linked list DLL, insert a node containing ELEMENT before NODE.
-Args: DLL NODE ELEMENT."
-
- (dll-insert-after (dll-get-node-before dll node) element))
-
-
-
-(defun dll-next (dll node)
- "Return the node after NODE, or nil if NODE is the last node.
-Args: DLL NODE."
-
- (dll-get-node-before dll node)
- (cdr node))
-
-
-(defun dll-previous (dll node)
- "Return the node before NODE, or nil if NODE is the first node.
-Args: DLL NODE."
-
- (dll-get-node-before dll node))
-
-
-(defun dll-delete (dll node)
-
- "Delete NODE from the doubly linked list DLL.
-Args: DLL NODE. Return the element of node."
-
- ;; This is a no-op when applied to the dummy node. This will return
- ;; nil if applied to the dummy node since it always contains nil.
-
- (setcdr (dll-get-node-before dll node) (cdr node)))
-
-
-(defun dll-delete-first (dll)
-
- "Delete the first NODE from the doubly linked list DLL.
-Return the element. Args: DLL. Returns nil if the DLL was empty."
-
- ;; Relies on the fact that dll-delete does nothing and
- ;; returns nil if given the dummy node.
-
- (setcdr dll (cdr (cdr dll))))
-
-
-(defun dll-delete-last (dll)
-
- "Delete the last NODE from the doubly linked list DLL.
-Return the element. Args: DLL. Returns nil if the DLL was empty."
-
- ;; Relies on the fact that dll-delete does nothing and
- ;; returns nil if given the dummy node.
-
- (setcdr dll (dll-get-node-before dll nil) nil))
-
-
-(defun dll-first (dll)
-
- "Return the first element on the doubly linked list DLL.
-Return nil if the list is empty. The element is not removed."
-
- (car (cdr dll)))
-
-
-
-
-(defun dll-last (dll)
-
- "Return the last element on the doubly linked list DLL.
-Return nil if the list is empty. The element is not removed."
-
- (car (dll-get-node-before dll nil)))
-
-
-
-(defun dll-nth (dll n)
-
- "Return the Nth node from the doubly linked list DLL.
- Args: DLL N
-N counts from zero. If DLL is not that long, nil is returned.
-If N is negative, return the -(N+1)th last element.
-Thus, (dll-nth dll 0) returns the first node,
-and (dll-nth dll -1) returns the last node."
-
- ;; Branch 0 ("follow left pointer") is used when n is negative.
- ;; Branch 1 ("follow right pointer") is used otherwise.
-
- (if (>= n 0)
- (nthcdr n (cdr dll))
- (unwind-protect
- (progn (setcdr dll (nreverse (cdr dll)))
- (nthcdr (- n) dll))
- (setcdr dll (nreverse (cdr dll))))))
-
-(defun dll-empty (dll)
-
- "Return t if the doubly linked list DLL is empty, nil otherwise"
-
- (not (cdr dll)))
-
-(defun dll-length (dll)
-
- "Returns the number of elements in the doubly linked list DLL."
-
- (length (cdr dll)))
-
-
-
-(defun dll-copy (dll &optional element-copy-fnc)
-
- "Return a copy of the doubly linked list DLL.
-If optional second argument ELEMENT-COPY-FNC is non-nil it should be
-a function that takes one argument, an element, and returns a copy of it.
-If ELEMENT-COPY-FNC is not given the elements are not copied."
-
- (if element-copy-fnc
- (cons 'DL-LIST (mapcar element-copy-fnc (cdr dll)))
- (copy-sequence dll)))
-
-
-(defun dll-all (dll)
-
- "Return all elements on the double linked list DLL as an ordinary list."
-
- (cdr dll))
-
-
-(defun dll-clear (dll)
-
- "Clear the doubly linked list DLL, i.e. make it completely empty."
-
- (setcdr dll nil))
-
-
-(defun dll-map (map-function dll)
-
- "Apply MAP-FUNCTION to all elements in the doubly linked list DLL.
-The function is applied to the first element first."
-
- (mapcar map-function (cdr dll)))
-
-
-(defun dll-map-reverse (map-function dll)
-
- "Apply MAP-FUNCTION to all elements in the doubly linked list DLL.
-The function is applied to the last element first."
-
- (unwind-protect
- (setcdr dll (nreverse (cdr dll)))
- (mapcar map-function (cdr dll))
- (setcdr dll (nreverse (cdr dll)))))
-
-
-(defun dll-create-from-list (list)
-
- "Given an elisp LIST create a doubly linked list with the same elements."
-
- (cons 'DL-LIST list))
-
-
-
-(defun dll-sort (dll predicate)
-
- "Sort the doubly linked list DLL, stably, comparing elements using PREDICATE.
-Returns the sorted list. DLL is modified by side effects.
-PREDICATE is called with two elements of DLL, and should return T
-if the first element is \"less\" than the second."
-
- (setcdr dll (sort (cdr dll) predicate))
- dll)
-
-
-(defun dll-filter (dll predicate)
-
- "Remove all elements in the doubly linked list DLL for which PREDICATE
-return nil."
-
- (let* ((prev dll)
- (node (cdr dll)))
-
- (while node
- (cond
- ((funcall predicate (car node))
- (setq prev node))
- (t
- (setcdr prev (cdr node))))
- (setq node (cdr node)))))
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll.el
deleted file mode 100644
index 855bd19..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-dll.el
+++ /dev/null
@@ -1,386 +0,0 @@
-;;; elib-dll.el,v 1.2 1992/04/07 20:49:15 berliner Exp
-;;; elib-dll.el -- Some primitives for Doubly linked lists.
-;;; Copyright (C) 1991, 1992 Per Cederqvist
-;;;
-;;; 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.
-
-;;; Mail bug reports to ceder@lysator.liu.se.
-
-(require 'elib-node)
-(provide 'elib-dll)
-
-;;;
-;;; A doubly linked list consists of one cons cell which holds the tag
-;;; 'DL-LIST in the car cell and a pointer to a dummy node in the cdr
-;;; cell. The doubly linked list is implemented as a circular list
-;;; with the dummy node first and last. The dummy node is recognized
-;;; by comparing it to the node which the cdr of the cons cell points
-;;; to.
-;;;
-
-;;; ================================================================
-;;; Internal functions for use in the doubly linked list package
-
-(defun dll-get-dummy-node (dll)
-
- ;; Return the dummy node. INTERNAL USE ONLY.
- (cdr dll))
-
-(defun dll-list-nodes (dll)
-
- ;; Return a list of all nodes in DLL. INTERNAL USE ONLY.
-
- (let* ((result nil)
- (dummy (dll-get-dummy-node dll))
- (node (elib-node-left dummy)))
-
- (while (not (eq node dummy))
- (setq result (cons node result))
- (setq node (elib-node-left node)))
-
- result))
-
-(defun dll-set-from-node-list (dll list)
-
- ;; Set the contents of DLL to the nodes in LIST.
- ;; INTERNAL USE ONLY.
-
- (dll-clear dll)
- (let* ((dummy (dll-get-dummy-node dll))
- (left dummy))
- (while list
- (elib-node-set-left (car list) left)
- (elib-node-set-right left (car list))
- (setq left (car list))
- (setq list (cdr list)))
-
- (elib-node-set-right left dummy)
- (elib-node-set-left dummy left)))
-
-
-;;; ===================================================================
-;;; The public functions which operate on doubly linked lists.
-
-(defmacro dll-element (dll node)
-
- "Get the element of a NODE in a doubly linked list DLL.
-Args: DLL NODE."
-
- (` (elib-node-data (, node))))
-
-
-(defun dll-create ()
- "Create an empty doubly linked list."
- (let ((dummy-node (elib-node-create nil nil nil)))
- (elib-node-set-right dummy-node dummy-node)
- (elib-node-set-left dummy-node dummy-node)
- (cons 'DL-LIST dummy-node)))
-
-(defun dll-p (object)
- "Return t if OBJECT is a doubly linked list, otherwise return nil."
- (eq (car-safe object) 'DL-LIST))
-
-(defun dll-enter-first (dll element)
- "Add an element first on a doubly linked list.
-Args: DLL ELEMENT."
- (dll-enter-after
- dll
- (dll-get-dummy-node dll)
- element))
-
-
-(defun dll-enter-last (dll element)
- "Add an element last on a doubly linked list.
-Args: DLL ELEMENT."
- (dll-enter-before
- dll
- (dll-get-dummy-node dll)
- element))
-
-
-(defun dll-enter-after (dll node element)
- "In the doubly linked list DLL, insert a node containing ELEMENT after NODE.
-Args: DLL NODE ELEMENT."
-
- (let ((new-node (elib-node-create
- node (elib-node-right node)
- element)))
- (elib-node-set-left (elib-node-right node) new-node)
- (elib-node-set-right node new-node)))
-
-
-(defun dll-enter-before (dll node element)
- "In the doubly linked list DLL, insert a node containing ELEMENT before NODE.
-Args: DLL NODE ELEMENT."
-
- (let ((new-node (elib-node-create
- (elib-node-left node) node
- element)))
- (elib-node-set-right (elib-node-left node) new-node)
- (elib-node-set-left node new-node)))
-
-
-
-(defun dll-next (dll node)
- "Return the node after NODE, or nil if NODE is the last node.
-Args: DLL NODE."
-
- (if (eq (elib-node-right node) (dll-get-dummy-node dll))
- nil
- (elib-node-right node)))
-
-
-(defun dll-previous (dll node)
- "Return the node before NODE, or nil if NODE is the first node.
-Args: DLL NODE."
-
- (if (eq (elib-node-left node) (dll-get-dummy-node dll))
- nil
- (elib-node-left node)))
-
-
-(defun dll-delete (dll node)
-
- "Delete NODE from the doubly linked list DLL.
-Args: DLL NODE. Return the element of node."
-
- ;; This is a no-op when applied to the dummy node. This will return
- ;; nil if applied to the dummy node since it always contains nil.
-
- (elib-node-set-right (elib-node-left node) (elib-node-right node))
- (elib-node-set-left (elib-node-right node) (elib-node-left node))
- (dll-element dll node))
-
-
-
-(defun dll-delete-first (dll)
-
- "Delete the first NODE from the doubly linked list DLL.
-Return the element. Args: DLL. Returns nil if the DLL was empty."
-
- ;; Relies on the fact that dll-delete does nothing and
- ;; returns nil if given the dummy node.
-
- (dll-delete dll (elib-node-right (dll-get-dummy-node dll))))
-
-
-(defun dll-delete-last (dll)
-
- "Delete the last NODE from the doubly linked list DLL.
-Return the element. Args: DLL. Returns nil if the DLL was empty."
-
- ;; Relies on the fact that dll-delete does nothing and
- ;; returns nil if given the dummy node.
-
- (dll-delete dll (elib-node-left (dll-get-dummy-node dll))))
-
-
-(defun dll-first (dll)
-
- "Return the first element on the doubly linked list DLL.
-Return nil if the list is empty. The element is not removed."
-
- (if (eq (elib-node-right (dll-get-dummy-node dll))
- (dll-get-dummy-node dll))
- nil
- (elib-node-data (elib-node-right (dll-get-dummy-node dll)))))
-
-
-
-
-(defun dll-last (dll)
-
- "Return the last element on the doubly linked list DLL.
-Return nil if the list is empty. The element is not removed."
-
- (if (eq (elib-node-left (dll-get-dummy-node dll))
- (dll-get-dummy-node dll))
- nil
- (elib-node-data (elib-node-left (dll-get-dummy-node dll)))))
-
-
-
-(defun dll-nth (dll n)
-
- "Return the Nth node from the doubly linked list DLL.
- Args: DLL N
-N counts from zero. If DLL is not that long, nil is returned.
-If N is negative, return the -(N+1)th last element.
-Thus, (dll-nth dll 0) returns the first node,
-and (dll-nth dll -1) returns the last node."
-
- ;; Branch 0 ("follow left pointer") is used when n is negative.
- ;; Branch 1 ("follow right pointer") is used otherwise.
-
- (let* ((dummy (dll-get-dummy-node dll))
- (branch (if (< n 0) 0 1))
- (node (elib-node-branch dummy branch)))
-
- (if (< n 0)
- (setq n (- -1 n)))
-
- (while (and (not (eq dummy node))
- (> n 0))
- (setq node (elib-node-branch node branch))
- (setq n (1- n)))
-
- (if (eq dummy node)
- nil
- node)))
-
-
-(defun dll-empty (dll)
-
- "Return t if the doubly linked list DLL is empty, nil otherwise"
-
- (eq (elib-node-left (dll-get-dummy-node dll))
- (dll-get-dummy-node dll)))
-
-(defun dll-length (dll)
-
- "Returns the number of elements in the doubly linked list DLL."
-
- (let* ((dummy (dll-get-dummy-node dll))
- (node (elib-node-right dummy))
- (n 0))
-
- (while (not (eq node dummy))
- (setq node (elib-node-right node))
- (setq n (1+ n)))
-
- n))
-
-
-
-(defun dll-copy (dll &optional element-copy-fnc)
-
- "Return a copy of the doubly linked list DLL.
-If optional second argument ELEMENT-COPY-FNC is non-nil it should be
-a function that takes one argument, an element, and returns a copy of it.
-If ELEMENT-COPY-FNC is not given the elements are not copied."
-
- (let ((result (dll-create))
- (node (dll-nth dll 0)))
- (if element-copy-fnc
-
- ;; Copy the elements with the user-supplied function.
- (while node
- (dll-enter-last result
- (funcall element-copy-fnc
- (dll-element dll node)))
- (setq node (dll-next dll node)))
-
- ;; Don't try to copy the elements - they might be
- ;; circular lists, or anything at all...
- (while node
- (dll-enter-last result (dll-element dll node))
- (setq node (dll-next dll node))))
-
- result))
-
-
-
-(defun dll-all (dll)
-
- "Return all elements on the double linked list DLL as an ordinary list."
-
- (let* ((result nil)
- (dummy (dll-get-dummy-node dll))
- (node (elib-node-left dummy)))
-
- (while (not (eq node dummy))
- (setq result (cons (dll-element dll node) result))
- (setq node (elib-node-left node)))
-
- result))
-
-
-(defun dll-clear (dll)
-
- "Clear the doubly linked list DLL, i.e. make it completely empty."
-
- (elib-node-set-left (dll-get-dummy-node dll) (dll-get-dummy-node dll))
- (elib-node-set-right (dll-get-dummy-node dll) (dll-get-dummy-node dll)))
-
-
-(defun dll-map (map-function dll)
-
- "Apply MAP-FUNCTION to all elements in the doubly linked list DLL.
-The function is applied to the first element first."
-
- (let* ((dummy (dll-get-dummy-node dll))
- (node (elib-node-right dummy)))
-
- (while (not (eq node dummy))
- (funcall map-function (dll-element dll node))
- (setq node (elib-node-right node)))))
-
-
-(defun dll-map-reverse (map-function dll)
-
- "Apply MAP-FUNCTION to all elements in the doubly linked list DLL.
-The function is applied to the last element first."
-
- (let* ((dummy (dll-get-dummy-node dll))
- (node (elib-node-left dummy)))
-
- (while (not (eq node dummy))
- (funcall map-function (dll-element dll node))
- (setq node (elib-node-left node)))))
-
-
-(defun dll-create-from-list (list)
-
- "Given an elisp LIST create a doubly linked list with the same elements."
-
- (let ((dll (dll-create)))
- (while list
- (dll-enter-last dll (car list))
- (setq list (cdr list)))
- dll))
-
-
-
-(defun dll-sort (dll predicate)
-
- "Sort the doubly linked list DLL, stably, comparing elements using PREDICATE.
-Returns the sorted list. DLL is modified by side effects.
-PREDICATE is called with two elements of DLL, and should return T
-if the first element is \"less\" than the second."
-
- (dll-set-from-node-list
- dll (sort (dll-list-nodes dll)
- (function (lambda (x1 x2)
- (funcall predicate
- (dll-element dll x1)
- (dll-element dll x2))))))
- dll)
-
-
-(defun dll-filter (dll predicate)
-
- "Remove all elements in the doubly linked list DLL for which PREDICATE
-return nil."
-
- (let* ((dummy (dll-get-dummy-node dll))
- (node (elib-node-right dummy))
- next)
-
- (while (not (eq node dummy))
- (setq next (elib-node-right node))
- (if (funcall predicate (dll-element dll node))
- nil
- (dll-delete dll node))
- (setq node next))))
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-node.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-node.el
deleted file mode 100644
index 6c476a3..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/elib-node.el
+++ /dev/null
@@ -1,89 +0,0 @@
-;;;; elib-node.el,v 1.2 1992/04/07 20:49:16 berliner Exp
-;;;; This file implements the nodes used in binary trees and
-;;;; doubly linked lists
-;;;;
-;;;; Copyright (C) 1991 Inge Wallin
-;;;;
-;;;; This file is part of the GNU Emacs lisp library, Elib.
-;;;;
-;;;; GNU Elib is free software; you can 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 Elib is distributed in the hope that it will be useful,
-;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 Emacs; see the file COPYING. If not, write to
-;;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-;;;;
-;;;; Author: Inge Wallin
-;;;;
-
-;;;
-;;; A node is implemented as an array with three elements, using
-;;; (elt node 0) as the left pointer
-;;; (elt node 1) as the right pointer
-;;; (elt node 2) as the data
-;;;
-;;; Some types of trees, e.g. AVL trees, need bigger nodes, but
-;;; as long as the first three parts are the left pointer, the
-;;; right pointer and the data field, these macros can be used.
-;;;
-
-
-(provide 'elib-node)
-
-
-(defmacro elib-node-create (left right data)
- "Create a tree node from LEFT, RIGHT and DATA."
- (` (vector (, left) (, right) (, data))))
-
-
-(defmacro elib-node-left (node)
- "Return the left pointer of NODE."
- (` (aref (, node) 0)))
-
-
-(defmacro elib-node-right (node)
- "Return the right pointer of NODE."
- (` (aref (, node) 1)))
-
-
-(defmacro elib-node-data (node)
- "Return the data of NODE."
- (` (aref (, node) 2)))
-
-
-(defmacro elib-node-set-left (node newleft)
- "Set the left pointer of NODE to NEWLEFT."
- (` (aset (, node) 0 (, newleft))))
-
-
-(defmacro elib-node-set-right (node newright)
- "Set the right pointer of NODE to NEWRIGHT."
- (` (aset (, node) 1 (, newright))))
-
-
-(defmacro elib-node-set-data (node newdata)
- "Set the data of NODE to NEWDATA."
- (` (aset (, node) 2 (, newdata))))
-
-
-
-(defmacro elib-node-branch (node branch)
- "Get value of a branch of a node.
-NODE is the node, and BRANCH is the branch.
-0 for left pointer, 1 for right pointer and 2 for the data."
- (` (aref (, node) (, branch))))
-
-
-(defmacro elib-node-set-branch (node branch newval)
- "Set value of a branch of a node.
-NODE is the node, and BRANCH is the branch.
-0 for left pointer, 1 for the right pointer and 2 for the data.
-NEWVAL is new value of the branch."
- (` (aset (, node) (, branch) (, newval))))
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el
deleted file mode 100644
index 27bb57c..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el
+++ /dev/null
@@ -1,6 +0,0 @@
-;;; pcl-cvs-startup.el,v 1.2 1992/04/07 20:49:17 berliner Exp
-(autoload 'cvs-update "pcl-cvs"
- "Run a 'cvs update' in the current working directory. Feed the
-output to a *cvs* buffer and run cvs-mode on it.
-If optional prefix argument LOCAL is non-nil, 'cvs update -l' is run."
- t)
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el
deleted file mode 100644
index 99da369..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el
+++ /dev/null
@@ -1,1476 +0,0 @@
-;;; pcl-cvs.el,v 1.2 1992/04/07 20:49:19 berliner Exp
-;;; pcl-cvs.el -- A Front-end to CVS 1.3 or later. Release 1.02.
-;;; Copyright (C) 1991, 1992 Per Cederqvist
-;;;
-;;; 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.
-
-;;;; See below for installation instructions.
-;;;;
-;;;; There is an TeXinfo file that describes this package. The GNU
-;;;; General Public License is included in that file. You should read
-;;;; it to get the most from this package.
-
-;;; Don't try to use this with CVS 1.2 or earlier. It won't work. Get
-;;; CVS 1.3.
-
-;;; Mail questions and bug reports to ceder@lysator.liu.se.
-
-(require 'cookie)
-(provide 'pcl-cvs)
-
-;;; -------------------------------------------------------
-;;; START OF THINGS TO CHECK WHEN INSTALLING
-
-(defvar cvs-program "/usr/gnu/bin/cvs"
- "*Full path to the cvs executable.")
-
-(defvar cvs-diff-program "/usr/gnu/bin/diff"
- "*Full path to the diff program.")
-
-(defvar cvs-rm-program "/usr/gnu/bin/rm"
- "*Full path to the rm program. Typically /bin/rm.")
-
-;; Uncomment the following line if you are running on 18.57 or earlier.
-;(setq delete-exited-processes nil)
-;; Emacs version 18.57 and earlier is likely to crash if
-;; delete-exited-processes is t, since the sentinel uses lots of
-;; memory, and 18.57 forgets to GCPROT a variable if
-;; delete-exited-processes is t.
-
-;;; END OF THINGS TO CHECK WHEN INSTALLING
-;;; --------------------------------------------------------
-
-(defvar cvs-bakprefix ".#"
- "The prefix that CVS prepends to files when rcsmerge'ing.")
-
-(defvar cvs-erase-input-buffer nil
- "*Non-nil if input buffers should be cleared before asking for new info.")
-
-(defvar cvs-auto-remove-handled nil
- "*Non-nil if cvs-remove-handled should be called automatically.
-If this is set to any non-nil value entries that does not need to be
-checked in will be removed from the *cvs* buffer after every cvs-commit
-command.")
-
-(defconst cvs-cursor-column 14
- "Column to position cursor in in cvs-mode.
-Column 0 is left-most column.")
-
-(defvar cvs-mode-map nil
- "Keymap for the cvs mode.")
-
-(defvar cvs-edit-mode-map nil
- "Keymap for the cvs edit mode (used when editing cvs log messages).")
-
-(defvar cvs-buffer-name "*cvs*"
- "Name of the cvs buffer.")
-
-(defvar cvs-commit-prompt-buffer "*cvs-commit-message*"
- "Name of buffer in which the user is prompted for a log message when
-committing files.")
-
-(defvar cvs-temp-buffer-name "*cvs-tmp*"
- "*Name of the cvs temporary buffer.
-Output from cvs is placed here by synchronous commands.")
-
-(defvar cvs-cvs-diff-flags nil
- "*List of strings to use as flags to pass to ``cvs diff''.
-Used by cvs-diff-cvs.
-Set this to '("-u") to get a Unidiff format, or '("-c") to get context diffs.")
-
-(defvar cvs-status-flags nil
- "*List of strings to pass to ``cvs status''.")
-
-(defvar cvs-log-flags nil
- "*List of strings to pass to ``cvs log''.")
-
-(defvar cvs-diff-flags nil
- "*List of strings to use as flags to pass to ``diff''.
-Do not confuse with cvs-cvs-diff-flags. Used by cvs-diff-backup.")
-
-(defvar cvs-buffers-to-delete nil
- "List of temporary buffers that should be discarded as soon as possible.
-Due to a bug in emacs 18.57 the sentinel can't discard them reliably.")
-
-;; You are NOT allowed to disable this message by default. However, you
-;; are encouraged to inform your users that by adding
-;; (setq cvs-inhibit-copyright-message t)
-;; to their .emacs they can get rid of it. Just don't add that line
-;; to your default.el!
-(defvar cvs-inhibit-copyright-message nil
- "*Don't display a Copyright message in the ``*cvs*'' buffer.")
-
-(defvar cvs-startup-message
- (if cvs-inhibit-copyright-message
- "PCL-CVS release 1.02"
- "PCL-CVS release 1.02. Copyright (C) 1992 Per Cederqvist
-Pcl-cvs comes with absolutely no warranty; for details consult the manual.
-This is free software, and you are welcome to redistribute it under certain
-conditions; again, consult the TeXinfo manual for details.")
- "*Startup message for CVS.")
-
-(defvar cvs-cvs-buffer nil
- "Internal to pcl-cvs.el.
-This variable exists in the *cvs-commit-message* buffer and names
-the *cvs* buffer.")
-
-;;; The cvs data structure:
-;;;
-;;; When the `cvs update' is ready we parse the output. Every file
-;;; that is affected in some way is added as a cookie of fileinfo
-;;; (as defined below).
-;;;
-
-;;; cvs-fileinfo
-;;;
-;;; marked t/nil
-;;; type One of
-;;; UPDATED - file copied from repository
-;;; MODIFIED - modified by you, unchanged in
-;;; repository
-;;; ADDED - added by you, not yet committed
-;;; REMOVED - removed by you, not yet committed
-;;; CVS-REMOVED- removed, since file no longer exists
-;;; in the repository.
-;;; MERGED - successful merge
-;;; CONFLICT - conflict when merging
-;;; REM-CONFLICT-removed in repository, changed locally.
-;;; MOD-CONFLICT-removed locally, changed in repository.
-;;; DIRCHANGE - A change of directory.
-;;; UNKNOWN - An unknown file.
-;;; MOVE-AWAY - A file that is in the way.
-;;; REPOS-MISSING- The directory is removed from the
-;;; repository. Go fetch a backup.
-;;; dir Directory the file resides in. Should not end with
-;;; slash.
-;;; file-name The file name.
-;;; backup-file Name of the backup file if MERGED or CONFLICT.
-;;; cvs-diff-buffer A buffer that contains a 'cvs diff file'.
-;;; backup-diff-buffer A buffer that contains a 'diff file backup-file'.
-;;; full-log The output from cvs, unparsed.
-;;; mod-time Modification time of file used for *-diff-buffer.
-;;; handled True if this file doesn't require further action.
-;;;
-;;; Constructor:
-
-;;; cvs-fileinfo
-
-;;; Constructor:
-
-(defun cvs-create-fileinfo (type
- dir
- file-name
- full-log)
- "Create a fileinfo from all parameters.
-Arguments: TYPE DIR FILE-NAME FULL-LOG.
-A fileinfo has the following fields:
-
- marked t/nil
- type One of
- UPDATED - file copied from repository
- MODIFIED - modified by you, unchanged in
- repository
- ADDED - added by you, not yet committed
- REMOVED - removed by you, not yet committed
- CVS-REMOVED- removed, since file no longer exists
- in the repository.
- MERGED - successful merge
- CONFLICT - conflict when merging
- REM-CONFLICT-removed in repository, but altered
- locally.
- MOD-CONFLICT-removed locally, changed in repository.
- DIRCHANGE - A change of directory.
- UNKNOWN - An unknown file.
- MOVE-AWAY - A file that is in the way.
- REPOS-MISSING- The directory has vanished from the
- repository.
- dir Directory the file resides in. Should not end with slash.
- file-name The file name.
- backup-file Name of the backup file if MERGED or CONFLICT.
- cvs-diff-buffer A buffer that contains a 'cvs diff file'.
- backup-diff-buffer A buffer that contains a 'diff file backup-file'.
- full-log The output from cvs, unparsed.
- mod-time Modification time of file used for *-diff-buffer.
- handled True if this file doesn't require further action."
- (cons
- 'CVS-FILEINFO
- (vector nil nil type dir file-name nil nil nil full-log nil)))
-
-
-;;; Selectors:
-
-(defun cvs-fileinfo->handled (cvs-fileinfo)
- "Get the `handled' field from CVS-FILEINFO."
- (elt (cdr cvs-fileinfo) 0))
-
-(defun cvs-fileinfo->marked (cvs-fileinfo)
- "Check if CVS-FILEINFO is marked."
- (elt (cdr cvs-fileinfo) 1))
-
-(defun cvs-fileinfo->type (cvs-fileinfo)
- "Get type from CVS-FILEINFO.
-Type is one of UPDATED, MODIFIED, ADDED, REMOVED, CVS-REMOVED, MERGED,
-CONFLICT, REM-CONFLICT, MOD-CONFLICT, DIRCHANGE, UNKNOWN, MOVE-AWAY
-or REPOS-MISSING."
- (elt (cdr cvs-fileinfo) 2))
-
-(defun cvs-fileinfo->dir (cvs-fileinfo)
- "Get dir from CVS-FILEINFO.
-The directory name does not end with a slash. "
- (elt (cdr cvs-fileinfo) 3))
-
-(defun cvs-fileinfo->file-name (cvs-fileinfo)
- "Get file-name from CVS-FILEINFO."
- (elt (cdr cvs-fileinfo) 4))
-
-(defun cvs-fileinfo->backup-file (cvs-fileinfo)
- "Get backup-file from CVS-FILEINFO."
- (elt (cdr cvs-fileinfo) 5))
-
-(defun cvs-fileinfo->cvs-diff-buffer (cvs-fileinfo)
- "Get cvs-diff-buffer from CVS-FILEINFO."
- (elt (cdr cvs-fileinfo) 6))
-
-(defun cvs-fileinfo->backup-diff-buffer (cvs-fileinfo)
- "Get backup-diff-buffer from CVS-FILEINFO."
- (elt (cdr cvs-fileinfo) 7))
-
-(defun cvs-fileinfo->full-log (cvs-fileinfo)
- "Get full-log from CVS-FILEINFO."
- (elt (cdr cvs-fileinfo) 8))
-
-(defun cvs-fileinfo->mod-time (cvs-fileinfo)
- "Get mod-time from CVS-FILEINFO."
- (elt (cdr cvs-fileinfo) 9))
-
-;;; Modifiers:
-
-(defun cvs-set-fileinfo->handled (cvs-fileinfo newval)
- "Set handled in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 0 newval))
-
-(defun cvs-set-fileinfo->marked (cvs-fileinfo newval)
- "Set marked in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 1 newval))
-
-(defun cvs-set-fileinfo->type (cvs-fileinfo newval)
- "Set type in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 2 newval))
-
-(defun cvs-set-fileinfo->dir (cvs-fileinfo newval)
- "Set dir in CVS-FILEINFO to NEWVAL.
-The directory should now end with a slash."
- (aset (cdr cvs-fileinfo) 3 newval))
-
-(defun cvs-set-fileinfo->file-name (cvs-fileinfo newval)
- "Set file-name in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 4 newval))
-
-(defun cvs-set-fileinfo->backup-file (cvs-fileinfo newval)
- "Set backup-file in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 5 newval))
-
-(defun cvs-set-fileinfo->cvs-diff-buffer (cvs-fileinfo newval)
- "Set cvs-diff-buffer in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 6 newval))
-
-(defun cvs-set-fileinfo->backup-diff-buffer (cvs-fileinfo newval)
- "Set backup-diff-buffer in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 7 newval))
-
-(defun cvs-set-fileinfo->full-log (cvs-fileinfo newval)
- "Set full-log in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 8 newval))
-
-(defun cvs-set-fileinfo->mod-time (cvs-fileinfo newval)
- "Set full-log in CVS-FILEINFO to NEWVAL."
- (aset (cdr cvs-fileinfo) 9 newval))
-
-
-
-;;; Predicate:
-
-(defun cvs-fileinfo-p (object)
- "Return t if OBJECT is a cvs-fileinfo."
- (eq (car-safe object) 'CVS-FILEINFO))
-
-;;;; End of types.
-
-(defun cvs-use-temp-buffer ()
- "Display a temporary buffer in another window and select it.
-The selected window will not be changed. The temporary buffer will
-be erased and writable."
-
- (display-buffer (get-buffer-create cvs-temp-buffer-name))
- (set-buffer cvs-temp-buffer-name)
- (setq buffer-read-only nil)
- (erase-buffer))
-
-; Too complicated to handle all the cases that are generated.
-; Maybe later.
-;(defun cvs-examine (directory &optional local)
-; "Run a 'cvs -n update' in the current working directory.
-;That is, check what needs to be done, but don't change the disc.
-;Feed the output to a *cvs* buffer and run cvs-mode on it.
-;If optional prefix argument LOCAL is non-nil, 'cvs update -l' is run."
-; (interactive (list (read-file-name "CVS Update (directory): "
-; nil default-directory nil)
-; current-prefix-arg))
-; (cvs-do-update directory local 'noupdate))
-
-(defun cvs-update (directory &optional local)
- "Run a 'cvs update' in the current working directory. Feed the
-output to a *cvs* buffer and run cvs-mode on it.
-If optional prefix argument LOCAL is non-nil, 'cvs update -l' is run."
- (interactive (list (read-file-name "CVS Update (directory): "
- nil default-directory nil)
- current-prefix-arg))
- (cvs-do-update directory local nil))
-
-(defun cvs-filter (predicate list &rest extra-args)
- "Apply PREDICATE to each element on LIST.
-Args: PREDICATE LIST &rest EXTRA-ARGS.
-Return a new list consisting of those elements that PREDICATE
-returns non-nil for.
-
-If more than two arguments are given the remaining args are
-passed to PREDICATE."
- ;; Avoid recursion - this should work for LONG lists also!
- (let* ((head (cons 'dummy-header nil))
- (tail head))
- (while list
- (if (apply predicate (car list) extra-args)
- (setq tail (setcdr tail (list (car list)))))
- (setq list (cdr list)))
- (cdr head)))
-
-(defun cvs-update-no-prompt ()
- "Run cvs update in current directory."
- (interactive)
- (cvs-do-update default-directory nil nil))
-
-(defun cvs-do-update (directory local dont-change-disc)
- "Do a 'cvs update' in DIRECTORY.
-If LOCAL is non-nil 'cvs update -l' is executed.
-If DONT-CHANGE-DISC is non-nil 'cvs -n update' is executed.
-Both LOCAL and DONT-CHANGE-DISC may be non-nil simultaneously.
-
-*Note*: DONT-CHANGE-DISC does not yet work. The parser gets confused."
- (save-some-buffers)
- (let* ((this-dir (file-name-as-directory (expand-file-name directory)))
- (use-this-window (equal (buffer-name (current-buffer))
- cvs-buffer-name))
- (update-buffer (generate-new-buffer
- (concat (file-name-nondirectory
- (substring this-dir 0 -1))
- "-update")))
- cvs-process args)
-
- ;; The *cvs* buffer is killed to avoid confusion - is the update ready
- ;; or not?
- (if (get-buffer cvs-buffer-name)
- (kill-buffer cvs-buffer-name))
-
- ;; Generate "-n update -l".
- (if local (setq args (list "-l")))
- (setq args (cons "update" args))
- (if dont-change-disc (setq args (cons "-n" args)))
-
- ;; Set up the buffer that receives the output from "cvs update".
- (if use-this-window
- (switch-to-buffer update-buffer)
- (set-buffer update-buffer)
- (display-buffer update-buffer))
-
- (setq default-directory this-dir)
- (setq cvs-process
- (let ((process-connection-type nil)) ; Use a pipe, not a pty.
- (apply 'start-process "cvs" update-buffer cvs-program args)))
-
- (setq mode-line-process
- (concat ": "
- (symbol-name (process-status cvs-process))))
- (set-buffer-modified-p (buffer-modified-p)) ; Update the mode line.
- (set-process-sentinel cvs-process 'cvs-sentinel)
-
- ;; Work around a bug in emacs 18.57 and earlier.
- (setq cvs-buffers-to-delete
- (cvs-delete-unused-temporary-buffers cvs-buffers-to-delete))))
-
-(defun cvs-delete-unused-temporary-buffers (list)
- "Delete all buffers on LIST that is not visible.
-Return a list of all buffers that still is alive."
-
- (cond
- ((null list) nil)
- ((get-buffer-window (car list))
- (cons (car list)
- (cvs-delete-unused-temporary-buffers (cdr list))))
- (t
- (kill-buffer (car list))
- (cvs-delete-unused-temporary-buffers (cdr list)))))
-
-
-(put 'cvs-mode 'mode-class 'special)
-
-(defun cvs-mode ()
- "\\<cvs-mode-map>Mode used for pcl-cvs, a frontend to CVS.
-
-To get the *cvs* buffer you should use ``\\[cvs-update]''.
-
-Full documentation is in the TeXinfo file. These are the most useful commands:
-
-\\[cookie-previous-cookie] Move up. \\[cookie-next-cookie] Move down.
-\\[cvs-commit] Commit file. \\[cvs-update-no-prompt] Reupdate directory.
-\\[cvs-mark] Mark file/dir. \\[cvs-unmark] Unmark file/dir.
-\\[cvs-mark-all-files] Mark all files. \\[cvs-unmark-all-files] Unmark all files.
-\\[cvs-find-file] Edit file/run Dired. \\[cvs-find-file-other-window] Find file or run Dired in other window.
-\\[cvs-remove-handled] Remove processed entries. \\[cvs-add-change-log-entry-other-window] Write ChangeLog in other window.
-\\[cvs-add] Add to repository. \\[cvs-remove-file] Remove file.
-\\[cvs-diff-cvs] Diff between base revision. \\[cvs-diff-backup] Diff backup file.
-\\[cvs-acknowledge] Delete line from buffer. \\[cvs-ignore] Add file to the .cvsignore file.
-\\[cvs-log] Run ``cvs log''. \\[cvs-status] Run ``cvs status''.
-
-Entry to this mode runs cvs-mode-hook.
-This description is updated for release 1.02 of pcl-cvs.
-All bindings:
-\\{cvs-mode-map}"
- (interactive)
- (setq major-mode 'cvs-mode)
- (setq mode-name "CVS")
- (setq buffer-read-only nil)
- (buffer-flush-undo (current-buffer))
- (make-local-variable 'goal-column)
- (setq goal-column cvs-cursor-column)
- (use-local-map cvs-mode-map)
- (run-hooks 'cvs-mode-hook))
-
-(defun cvs-sentinel (proc msg)
- "Sentinel for the cvs update process.
-This is responsible for parsing the output from the cvs update when
-it is finished."
- (cond
- ((null (buffer-name (process-buffer proc)))
- ;; buffer killed
- (set-process-buffer proc nil))
- ((memq (process-status proc) '(signal exit))
- (let* ((obuf (current-buffer))
- (omax (point-max))
- (opoint (point)))
- ;; save-excursion isn't the right thing if
- ;; process-buffer is current-buffer
- (unwind-protect
- (progn
- (set-buffer (process-buffer proc))
- (setq mode-line-process
- (concat ": "
- (symbol-name (process-status proc))))
- (cvs-parse-buffer)
- (setq cvs-buffers-to-delete
- (cons (process-buffer proc) cvs-buffers-to-delete)))
- (set-buffer-modified-p (buffer-modified-p)))
- (if (equal obuf (process-buffer proc))
- nil
- (set-buffer (process-buffer proc))
- (if (< opoint omax)
- (goto-char opoint))
- (set-buffer obuf))))))
-
-(defun cvs-skip-line (regexp errormsg &optional arg)
- "Like forward-line, but check that the skipped line matches REGEXP.
-If it doesn't match REGEXP (error ERRORMSG) is called.
-If optional ARG, a number, is given the ARGth parenthesized expression
-in the REGEXP is returned as a string.
-Point should be in column 1 when this function is called."
- (cond
- ((looking-at regexp)
- (forward-line 1)
- (if arg
- (buffer-substring (match-beginning arg)
- (match-end arg))))
- (t
- (error errormsg))))
-
-(defun cvs-get-current-dir (dirname)
- "Return current working directory, suitable for cvs-parse-buffer.
-Args: DIRNAME.
-Concatenates default-directory and DIRNAME to form an absolute path."
- (if (string= "." dirname)
- (substring default-directory 0 -1)
- (concat default-directory dirname)))
-
-
-(defun cvs-parse-buffer ()
- "Parse the current buffer and select a *cvs* buffer.
-Signals an error if unexpected output was detected in the buffer."
- (goto-char (point-min))
- (let ((buf (get-buffer-create cvs-buffer-name))
- (current-dir default-directory)
- (root-dir default-directory)
- (parse-buf (current-buffer)))
-
- (cookie-create
- buf 'cvs-pp cvs-startup-message ;Se comment above cvs-startup-message.
- "---------- End -----")
-
- (cookie-enter-first
- buf
- (cvs-create-fileinfo
- 'DIRCHANGE current-dir
- nil ""))
-
- (while (< (point) (point-max))
- (cond
-
- ;; CVS is descending a subdirectory.
-
- ((looking-at "cvs update: Updating \\(.*\\)$")
- (setq current-dir
- (cvs-get-current-dir
- (buffer-substring (match-beginning 1) (match-end 1))))
-
- ;; Omit empty directories.
- (if (eq (cvs-fileinfo->type (cookie-last buf))
- 'DIRCHANGE)
- (cookie-delete-last buf))
-
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'DIRCHANGE current-dir
- nil (buffer-substring (match-beginning 0)
- (match-end 0))))
- (forward-line 1))
-
- ;; File removed, since it is removed (by third party) in repository.
-
- ((or (looking-at "cvs update: warning: \\(.*\\) is not (any longer) \
-pertinent")
- (looking-at "cvs update: \\(.*\\) is no longer in the repository"))
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'CVS-REMOVED current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0)
- (match-end 0))))
- (forward-line 1))
-
- ;; File removed by you, but recreated by cvs. Ignored.
-
- ((looking-at "cvs update: warning: .* was lost$")
- (forward-line 1))
-
- ;; A file that has been created by you, but added to the cvs
- ;; repository by another.
-
- ((looking-at "^cvs update: move away \\(.*\\); it is in the way$")
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'MOVE-AWAY current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0)
- (match-end 0))))
- (forward-line 1))
-
- ;; Empty line. Probably inserted by mistake by user (or developer :-)
- ;; Ignore.
-
- ((looking-at "^$")
- (forward-line 1))
-
- ;; Cvs waits for a lock. Ignore.
-
- ((looking-at
- "^cvs update: \\[..:..:..\\] waiting for .*lock in ")
- (forward-line 1))
-
- ;; File removed in repository, but edited by you.
-
- ((looking-at
- "cvs update: conflict: \\(.*\\) is modified but no longer \
-in the repository$")
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'REM-CONFLICT current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0)
- (match-end 0))))
- (forward-line 1))
-
- ((looking-at
- "cvs update: conflict: removed \\(.*\\) was modified by second party")
- (cvs-create-fileinfo
- 'MOD-CONFLICT current-dir
- (buffer-substring (match-beginning 1) (match-end 1))
- (buffer-substring (match-beginning 0) (match-end 0)))
- (forward-line 1))
-
- ((looking-at "cvs update: in directory ")
- (let ((start (point)))
- (forward-line 1)
- (cvs-skip-line
- (regexp-quote "cvs [update aborted]: there is no repository ")
- "Unexpected cvs output.")
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'REPOS-MISSING current-dir
- nil
- (buffer-substring start (point))))))
-
- ;; The file is copied from the repository.
-
- ((looking-at "U \\(.*\\)$")
- (cookie-enter-last
- buf
- (let ((fileinfo
- (cvs-create-fileinfo
- 'UPDATED current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0) (match-end 0)))))
- (cvs-set-fileinfo->handled fileinfo t)
- fileinfo))
- (forward-line 1))
-
- ;; The file is modified by the user, and untouched in the repository.
-
- ((looking-at "M \\(.*\\)$")
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'MODIFIED current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0) (match-end 0))))
- (forward-line 1))
-
- ;; The file is "cvs add"ed, but not "cvs ci"ed.
-
- ((looking-at "A \\(.*\\)$")
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'ADDED current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0) (match-end 0))))
- (forward-line 1))
-
- ;; The file is "cvs remove"ed, but not "cvs ci"ed.
-
- ((looking-at "R \\(.*\\)$")
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'REMOVED current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0) (match-end 0))))
- (forward-line 1))
-
- ;; Unknown file.
-
- ((looking-at "? \\(.*\\)$")
- (cookie-enter-last
- buf
- (cvs-create-fileinfo
- 'UNKNOWN current-dir
- (file-name-nondirectory
- (buffer-substring (match-beginning 1) (match-end 1)))
- (buffer-substring (match-beginning 0) (match-end 0))))
- (forward-line 1))
- (t
-
- ;; CVS has decided to merge someone elses changes into this
- ;; document. This leads to a lot of garbage being printed.
- ;; First there is two lines that contains no information
- ;; that we skip (but we check that we recognize them).
-
- (let ((complex-start (point))
- initial-revision filename)
-
- (cvs-skip-line "^RCS file: .*$" "Parse error.")
- (setq initial-revision
- (cvs-skip-line "^retrieving revision \\(.*\\)$"
- "Unexpected output from cvs." 1))
- (cvs-skip-line "^retrieving revision .*$"
- "Unexpected output from cvs.")
-
- ;; Get the file name from the next line.
-
- (setq
- filename
- (cvs-skip-line
- "^Merging differences between [0-9.]+ and [0-9.]+ into \\(.*\\)$"
- "Unexpected output from cvs."
- 1))
-
- (cond
-
- ;; The file was successfully merged.
-
- ((looking-at "^M ")
- (forward-line 1)
- (let ((fileinfo
- (cvs-create-fileinfo
- 'MERGED current-dir
- filename
- (buffer-substring complex-start (point)))))
- (cvs-set-fileinfo->backup-file
- fileinfo
- (concat cvs-bakprefix filename "." initial-revision))
- (cookie-enter-last
- buf fileinfo)))
-
- ;; A conflicting merge.
-
- (t
- (cvs-skip-line "^merge: overlaps during merge$"
- "Unexpected output from cvs.")
- (cvs-skip-line "^cvs update: conflicts found in "
- "Unexpected output from cvs.")
- (cvs-skip-line "^C " "Unexpected cvs output.")
- (let ((fileinfo
- (cvs-create-fileinfo
- 'CONFLICT current-dir
- filename
- (buffer-substring complex-start (point)))))
-
- (cvs-set-fileinfo->backup-file
- fileinfo
- (concat cvs-bakprefix filename "." initial-revision))
-
- (cookie-enter-last buf fileinfo))))))))
-
- ;; All parsing is done.
-
- ;; If the last entry is a directory, remove it.
- (if (eq (cvs-fileinfo->type (cookie-last buf))
- 'DIRCHANGE)
- (cookie-delete-last buf))
-
- (set-buffer buf)
- (cvs-mode)
- (setq cookie-last-tin (cookie-nth buf 0))
- (goto-char (point-min))
- (cookie-previous-cookie buf (point-min) 1)
- (setq default-directory root-dir)
- (if (get-buffer-window parse-buf)
- (set-window-buffer (get-buffer-window parse-buf) buf)
- (display-buffer buf))))
-
-
-(defun cvs-pp (fileinfo)
- "Pretty print FILEINFO into a string."
-
- (let ((a (cvs-fileinfo->type fileinfo))
- (s (if (cvs-fileinfo->marked fileinfo)
- "*" " "))
- (f (cvs-fileinfo->file-name fileinfo))
- (ci (if (cvs-fileinfo->handled fileinfo)
- " " "ci")))
- (cond
- ((eq a 'UPDATED)
- (format "%s Updated %s" s f))
- ((eq a 'MODIFIED)
- (format "%s Modified %s %s" s ci f))
- ((eq a 'MERGED)
- (format "%s Merged %s %s" s ci f))
- ((eq a 'CONFLICT)
- (format "%s Conflict %s" s f))
- ((eq a 'ADDED)
- (format "%s Added %s %s" s ci f))
- ((eq a 'REMOVED)
- (format "%s Removed %s %s" s ci f))
- ((eq a 'UNKNOWN)
- (format "%s Unknown %s" s f))
- ((eq a 'CVS-REMOVED)
- (format "%s Removed from repository: %s" s f))
- ((eq a 'REM-CONFLICT)
- (format "%s Conflict: Removed from repository, changed by you: %s" s f))
- ((eq a 'MOD-CONFLICT)
- (format "%s Conflict: Removed by you, changed in repository: %s" s f))
- ((eq a 'DIRCHANGE)
- (format "\nIn directory %s:"
- (cvs-fileinfo->dir fileinfo)))
- ((eq a 'MOVE-AWAY)
- (format "%s Move away %s - it is in the way" s f))
- ((eq a 'REPOS-MISSING)
- (format " This repository is missing! Remove this dir manually."))
- (t
- (format "%s Internal error! %s" s f)))))
-
-
-;;; You can define your own keymap in .emacs. pcl-cvs.el won't overwrite it.
-
-(if cvs-mode-map
- nil
- (setq cvs-mode-map (make-keymap))
- (suppress-keymap cvs-mode-map)
- (define-key cvs-mode-map " " 'cookie-next-cookie)
- (define-key cvs-mode-map "?" 'describe-mode)
- (define-key cvs-mode-map "A" 'cvs-add-change-log-entry-other-window)
- (define-key cvs-mode-map "M" 'cvs-mark-all-files)
- (define-key cvs-mode-map "U" 'cvs-unmark-all-files)
- (define-key cvs-mode-map "\C-?" 'cvs-unmark-up)
- (define-key cvs-mode-map "\C-n" 'cookie-next-cookie)
- (define-key cvs-mode-map "\C-p" 'cookie-previous-cookie)
- (define-key cvs-mode-map "a" 'cvs-add)
- (define-key cvs-mode-map "b" 'cvs-diff-backup)
- (define-key cvs-mode-map "c" 'cvs-commit)
- (define-key cvs-mode-map "d" 'cvs-diff-cvs)
- (define-key cvs-mode-map "f" 'cvs-find-file)
- (define-key cvs-mode-map "g" 'cvs-update-no-prompt)
- (define-key cvs-mode-map "i" 'cvs-ignore)
- (define-key cvs-mode-map "l" 'cvs-log)
- (define-key cvs-mode-map "m" 'cvs-mark)
- (define-key cvs-mode-map "n" 'cookie-next-cookie)
- (define-key cvs-mode-map "o" 'cvs-find-file-other-window)
- (define-key cvs-mode-map "p" 'cookie-previous-cookie)
- (define-key cvs-mode-map "r" 'cvs-remove-file)
- (define-key cvs-mode-map "s" 'cvs-status)
- (define-key cvs-mode-map "\C-k" 'cvs-acknowledge)
- (define-key cvs-mode-map "x" 'cvs-remove-handled)
- (define-key cvs-mode-map "u" 'cvs-unmark))
-
-
-(defun cvs-get-marked ()
- "Return a list of all selected tins.
-If there are any marked tins, return them.
-Otherwise, if the cursor selects a directory, return all files in it.
-Otherwise return (a list containing) the file the cursor points to, or
-an empty list if it doesn't point to a file at all."
-
- (cond
- ;; Any marked cookies?
- ((cookie-collect-tins (current-buffer)
- 'cvs-fileinfo->marked))
- ;; Nope.
- (t
- (let ((sel (cookie-get-selection
- (current-buffer) (point) cookie-last-tin)))
- (cond
- ;; If a directory is selected, all it members are returned.
- ((and sel (eq (cvs-fileinfo->type
- (cookie-cookie (current-buffer) sel))
- 'DIRCHANGE))
- (cookie-collect-tins
- (current-buffer) 'cvs-dir-member-p
- (cvs-fileinfo->dir (cookie-cookie (current-buffer) sel))))
- (t
- (list sel)))))))
-
-
-(defun cvs-dir-member-p (fileinfo dir)
- "Return true if FILEINFO represents a file in directory DIR."
- (and (not (eq (cvs-fileinfo->type fileinfo) 'DIRCHANGE))
- (string= (cvs-fileinfo->dir fileinfo) dir)))
-
-(defun cvs-dir-empty-p (cvs-buf tin)
- "Return non-nil if TIN is a directory that is empty.
-Args: CVS-BUF TIN."
- (and (eq (cvs-fileinfo->type (cookie-cookie cvs-buf tin)) 'DIRCHANGE)
- (or (not (cookie-next cvs-buf tin))
- (eq (cvs-fileinfo->type (cookie-cookie cvs-buf
- (cookie-next cvs-buf tin)))
- 'DIRCHANGE))))
-
-(defun cvs-remove-handled ()
- "Remove all lines that are handled.
-Empty directories are removed."
- (interactive)
- ;; Pass one: remove files that are handled.
- (cookie-filter (current-buffer)
- (function
- (lambda (fileinfo) (not (cvs-fileinfo->handled fileinfo)))))
- ;; Pass two: remove empty directories.
- (cookie-filter-tins (current-buffer)
- (function
- (lambda (tin)
- (not (cvs-dir-empty-p (current-buffer) tin))))))
-
-(defun cvs-mark (pos)
- "Mark a fileinfo. Args: POS.
-If the fileinfo is a directory, all the contents of that directory are
-marked instead. A directory can never be marked.
-POS is a buffer position."
-
- (interactive "d")
-
- (let* ((tin (cookie-get-selection
- (current-buffer) pos cookie-last-tin))
- (sel (cookie-cookie (current-buffer) tin)))
-
- (cond
- ;; Does POS point to a directory? If so, mark all files in that directory.
- ((eq (cvs-fileinfo->type sel) 'DIRCHANGE)
- (cookie-map
- (function (lambda (f dir)
- (cond
- ((cvs-dir-member-p f dir)
- (cvs-set-fileinfo->marked f t)
- t)))) ;Tell cookie to redisplay this cookie.
- (current-buffer)
- (cvs-fileinfo->dir sel)))
- (t
- (cvs-set-fileinfo->marked sel t)
- (cookie-invalidate-tins (current-buffer) tin)
- (cookie-next-cookie (current-buffer) pos 1)))))
-
-
-(defun cvs-committable (tin cvs-buf)
- "Check if the TIN is committable.
-It is committable if it
- a) is not handled and
- b) is either MODIFIED, ADDED, REMOVED, MERGED or CONFLICT."
- (let* ((fileinfo (cookie-cookie cvs-buf tin))
- (type (cvs-fileinfo->type fileinfo)))
- (and (not (cvs-fileinfo->handled fileinfo))
- (or (eq type 'MODIFIED)
- (eq type 'ADDED)
- (eq type 'REMOVED)
- (eq type 'MERGED)
- (eq type 'CONFLICT)))))
-
-(defun cvs-commit ()
-
- "Check in all marked files, or the current file.
-The user will be asked for a log message in a buffer.
-If cvs-erase-input-buffer is non-nil that buffer will be erased.
-Otherwise mark and point will be set around the entire contents of the
-buffer so that it is easy to kill the contents of the buffer with \\[kill-region]."
-
- (interactive)
-
- (let* ((cvs-buf (current-buffer))
- (marked (cvs-filter (function cvs-committable)
- (cvs-get-marked)
- cvs-buf)))
- (if (null marked)
- (error "Nothing to commit!")
- (pop-to-buffer (get-buffer-create cvs-commit-prompt-buffer))
- (goto-char (point-min))
-
- (if cvs-erase-input-buffer
- (erase-buffer)
- (push-mark (point-max)))
- (cvs-edit-mode)
- (make-local-variable 'cvs-commit-list)
- (setq cvs-commit-list marked)
- (make-local-variable 'cvs-cvs-buffer)
- (setq cvs-cvs-buffer cvs-buf)
- (message "Press C-c C-c when you are done editing."))))
-
-
-(defun cvs-edit-done ()
- "Commit the files to the repository."
- (interactive)
- (save-some-buffers)
- (let ((cc-list cvs-commit-list)
- (cc-buffer cvs-cvs-buffer)
- (msg-buffer (current-buffer))
- (msg (buffer-substring (point-min) (point-max))))
- (pop-to-buffer cc-buffer)
- (bury-buffer msg-buffer)
- (cvs-use-temp-buffer)
- (message "Committing...")
- (cvs-execute-list cc-list cvs-program (list "commit" "-m" msg))
- (mapcar (function
- (lambda (tin)
- (cvs-set-fileinfo->handled (cookie-cookie cc-buffer tin) t)))
- cc-list)
- (apply 'cookie-invalidate-tins cc-buffer cc-list)
- (set-buffer cc-buffer)
- (if cvs-auto-remove-handled
- (cvs-remove-handled)))
-
- (message "Committing... Done."))
-
-
-(defun cvs-execute-list (tin-list program constant-args)
- "Run PROGRAM on all elements on TIN-LIST.
-Args: TIN-LIST PROGRAM CONSTANT-ARGS
-The PROGRAM will be called with pwd set to the directory the
-files reside in. CONSTANT-ARGS should be a list of strings. The
-arguments given to the program will be CONSTANT-ARGS followed by all
-the files (from TIN-LIST) that resides in that directory. If the files
-in TIN-LIST resides in different directories the PROGRAM will be run
-once for each directory (if all files in the same directory appears
-after each other."
-
- (while tin-list
- (let ((current-dir (cvs-fileinfo->dir
- (cookie-cookie cvs-buffer-name
- (car tin-list))))
- arg-list arg-str)
-
- ;; Collect all marked files in this directory.
-
- (while (and tin-list
- (string=
- current-dir
- (cvs-fileinfo->dir
- (cookie-cookie cvs-buffer-name (car tin-list)))))
- (setq arg-list
- (cons (cvs-fileinfo->file-name
- (cookie-cookie cvs-buffer-name (car tin-list)))
- arg-list))
- (setq tin-list (cdr tin-list)))
-
- (setq arg-list (nreverse arg-list))
-
- ;; Execute the command on all the files that were collected.
-
- (setq default-directory (file-name-as-directory current-dir))
- (insert (format "=== cd %s\n" default-directory))
- (insert (format "=== %s %s\n\n"
- program
- (mapconcat '(lambda (foo) foo)
- (nconc (copy-sequence constant-args)
- arg-list)
- " ")))
- (apply 'call-process program nil t t
- (nconc (copy-sequence constant-args) arg-list))
- (goto-char (point-max)))))
-
-
-(defun cvs-execute-single-file-list (tin-list extractor program constant-args)
- "Run PROGRAM on all elements on TIN-LIST.
-
-Args: TIN-LIST EXTRACTOR PROGRAM CONSTANT-ARGS
-
-The PROGRAM will be called with pwd set to the directory the files
-reside in. CONSTANT-ARGS is a list of strings to pass as arguments to
-PROGRAM. The arguments given to the program will be CONSTANT-ARGS
-followed by the list that EXTRACTOR returns.
-
-EXTRACTOR will be called once for each file on TIN-LIST. It is given
-one argument, the cvs-fileinfo. It can return t, which means ignore
-this file, or a list of arguments to send to the program."
-
- (while tin-list
- (let ((default-directory (file-name-as-directory
- (cvs-fileinfo->dir
- (cookie-cookie cvs-buffer-name
- (car tin-list)))))
- (arg-list
- (funcall extractor
- (cookie-cookie cvs-buffer-name (car tin-list)))))
-
- ;; Execute the command unless extractor returned t.
-
- (if (eq arg-list t)
- nil
- (insert (format "=== cd %s\n" default-directory))
- (insert (format "=== %s %s\n\n"
- program
- (mapconcat '(lambda (foo) foo)
- (nconc (copy-sequence constant-args)
- arg-list)
- " ")))
- (apply 'call-process program nil t t
- (nconc (copy-sequence constant-args) arg-list))
- (goto-char (point-max))))
- (setq tin-list (cdr tin-list))))
-
-
-(defun cvs-edit-mode ()
- "\\<cvs-edit-mode-map>Mode for editing cvs log messages.
-Commands:
-\\[cvs-edit-done] checks in the file when you are ready.
-This mode is based on fundamental mode."
- (interactive)
- (use-local-map cvs-edit-mode-map)
- (setq major-mode 'cvs-edit-mode)
- (setq mode-name "CVS Log")
- (auto-fill-mode 1))
-
-
-(if cvs-edit-mode-map
- nil
- (setq cvs-edit-mode-map (make-sparse-keymap))
- (define-prefix-command 'cvs-control-c-prefix)
- (define-key cvs-edit-mode-map "\C-c" 'cvs-control-c-prefix)
- (define-key cvs-edit-mode-map "\C-c\C-c" 'cvs-edit-done))
-
-
-(defun cvs-diff-cvs ()
- "Diff the selected files against the repository.
-The flags the variable cvs-cvs-diff-flags will be passed to ``cvs diff''."
- (interactive)
-
- (save-some-buffers)
- (let ((marked (cvs-get-marked)))
- (cvs-use-temp-buffer)
- (message "cvsdiffing...")
- (cvs-execute-list marked cvs-program (cons "diff" cvs-cvs-diff-flags)))
- (message "cvsdiffing... Done."))
-
-
-(defun cvs-backup-diffable (tin cvs-buf)
- "Check if the TIN is backup-diffable.
-It must have a backup file to be diffable."
- (cvs-fileinfo->backup-file (cookie-cookie cvs-buf tin)))
-
-(defun cvs-diff-backup ()
- "Diff the files against the backup file.
-This command can be used on files that are marked with \"Merged\"
-or \"Conflict\" in the *cvs* buffer.
-
-The flags in cvs-diff-flags will be passed to ``diff''."
-
- (interactive)
- (save-some-buffers)
- (let ((marked (cvs-filter (function cvs-backup-diffable)
- (cvs-get-marked)
- (current-buffer))))
- (if (null marked)
- (error "No ``Conflict'' or ``Merged'' file selected!"))
- (cvs-use-temp-buffer)
- (message "diffing...")
- (cvs-execute-single-file-list
- marked 'cvs-diff-backup-extractor cvs-diff-program cvs-diff-flags))
- (message "diffing... Done."))
-
-
-(defun cvs-diff-backup-extractor (fileinfo)
- "Return the filename and the name of the backup file as a list.
-Signal an error if there is no backup file."
- (if (null (cvs-fileinfo->backup-file fileinfo))
- (error "%s has no backup file."
- (concat
- (file-name-as-directory (cvs-fileinfo->dir fileinfo))
- (cvs-fileinfo->file-name fileinfo))))
- (list (cvs-fileinfo->file-name fileinfo)
- (cvs-fileinfo->backup-file fileinfo)))
-
-(defun cvs-find-file-other-window (pos)
- "Select a buffer containing the file in another window.
-Args: POS"
- (interactive "d")
- (save-some-buffers)
- (let* ((cookie-last-tin
- (cookie-get-selection (current-buffer) pos cookie-last-tin))
- (type (cvs-fileinfo->type (cookie-cookie (current-buffer)
- cookie-last-tin))))
- (cond
- ((or (eq type 'REMOVED)
- (eq type 'CVS-REMOVED))
- (error "Can't visit a removed file."))
- ((eq type 'DIRCHANGE)
- (let ((obuf (current-buffer))
- (odir default-directory))
- (setq default-directory
- (file-name-as-directory
- (cvs-fileinfo->dir
- (cookie-cookie (current-buffer) cookie-last-tin))))
- (dired-other-window default-directory)
- (set-buffer obuf)
- (setq default-directory odir)))
- (t
- (find-file-other-window (cvs-full-path (current-buffer)
- cookie-last-tin))))))
-
-(defun cvs-full-path (buffer tin)
- "Return the full path for the file that is described in TIN.
-Args: BUFFER TIN."
- (concat
- (file-name-as-directory
- (cvs-fileinfo->dir (cookie-cookie buffer tin)))
- (cvs-fileinfo->file-name (cookie-cookie buffer tin))))
-
-(defun cvs-find-file (pos)
- "Select a buffer containing the file in another window.
-Args: POS"
- (interactive "d")
- (let* ((cvs-buf (current-buffer))
- (cookie-last-tin (cookie-get-selection cvs-buf pos cookie-last-tin))
- (fileinfo (cookie-cookie cvs-buf cookie-last-tin))
- (type (cvs-fileinfo->type fileinfo)))
- (cond
- ((or (eq type 'REMOVED)
- (eq type 'CVS-REMOVED))
- (error "Can't visit a removed file."))
- ((eq type 'DIRCHANGE)
- (let ((odir default-directory))
- (setq default-directory
- (file-name-as-directory (cvs-fileinfo->dir fileinfo)))
- (dired default-directory)
- (set-buffer cvs-buf)
- (setq default-directory odir)))
- (t
- (find-file (cvs-full-path cvs-buf cookie-last-tin))))))
-
-(defun cvs-mark-all-files ()
- "Mark all files.
-Directories are not marked."
- (interactive)
- (cookie-map (function (lambda (cookie)
- (cond
- ((not (eq (cvs-fileinfo->type cookie) 'DIRCHANGE))
- (cvs-set-fileinfo->marked cookie t)
- t))))
- (current-buffer)))
-
-
-(defun cvs-unmark (pos)
- "Unmark a fileinfo. Args: POS."
- (interactive "d")
-
- (let* ((tin (cookie-get-selection
- (current-buffer) pos cookie-last-tin))
- (sel (cookie-cookie (current-buffer) tin)))
-
- (cond
- ((eq (cvs-fileinfo->type sel) 'DIRCHANGE)
- (cookie-map
- (function (lambda (f dir)
- (cond
- ((cvs-dir-member-p f dir)
- (cvs-set-fileinfo->marked f nil)
- t))))
- (current-buffer)
- (cvs-fileinfo->dir sel)))
- (t
- (cvs-set-fileinfo->marked sel nil)
- (cookie-invalidate-tins (current-buffer) tin)
- (cookie-next-cookie (current-buffer) pos 1)))))
-
-(defun cvs-unmark-all-files ()
- "Unmark all files.
-Directories are also unmarked, but that doesn't matter, since
-they should always be unmarked."
- (interactive)
- (cookie-map (function (lambda (cookie)
- (cvs-set-fileinfo->marked cookie nil)
- t))
- (current-buffer)))
-
-
-(defun cvs-do-removal (cvs-buf tins)
- "Remove files.
-Args: CVS-BUF TINS.
-CVS-BUF is the cvs buffer. TINS is a list of tins that the
-user wants to delete. The files are deleted. If the type of
-the tin is 'UNKNOWN the tin is removed from the buffer. If it
-is anything else the file is added to a list that should be
-`cvs remove'd and the tin is changed to be of type 'REMOVED.
-
-Returns a list of tins files that should be `cvs remove'd."
- (cvs-use-temp-buffer)
- (mapcar 'cvs-insert-full-path tins)
- (cond
- ((and tins (yes-or-no-p (format "Delete %d files? " (length tins))))
- (let (files-to-remove)
- (while tins
- (let* ((tin (car tins))
- (fileinfo (cookie-cookie cvs-buf tin))
- (type (cvs-fileinfo->type fileinfo)))
- (if (not (or (eq type 'REMOVED) (eq type 'CVS-REMOVED)))
- (progn
- (delete-file (cvs-full-path cvs-buf tin))
- (cond
- ((or (eq type 'UNKNOWN) (eq type 'MOVE-AWAY))
- (cookie-delete cvs-buf tin))
- (t
- (setq files-to-remove (cons tin files-to-remove))
- (cvs-set-fileinfo->type fileinfo 'REMOVED)
- (cvs-set-fileinfo->handled fileinfo nil)
- (cookie-invalidate-tins cvs-buf tin))))))
- (setq tins (cdr tins)))
- files-to-remove))
- (t nil)))
-
-
-
-(defun cvs-remove-file ()
- "Remove all marked files."
- (interactive)
- (let ((files-to-remove (cvs-do-removal (current-buffer) (cvs-get-marked))))
- (if (null files-to-remove)
- nil
- (cvs-use-temp-buffer)
- (message "removing from repository...")
- (cvs-execute-list files-to-remove cvs-program '("remove"))
- (message "removing from repository... done."))))
-
-(defun cvs-acknowledge ()
- "Remove all marked files from the buffer."
- (interactive)
-
- (mapcar (function (lambda (tin)
- (cookie-delete (current-buffer) tin)))
- (cvs-get-marked))
- (setq cookie-last-tin nil))
-
-
-(defun cvs-unmark-up (pos)
- "Unmark the file on the previous line.
-Takes one argument POS, a buffer position."
- (interactive "d")
- (cookie-previous-cookie (current-buffer) pos 1)
- (cvs-set-fileinfo->marked (cookie-cookie (current-buffer) cookie-last-tin)
- nil)
- (cookie-invalidate-tins (current-buffer) cookie-last-tin))
-
-(defun cvs-add-file-update-buffer (cvs-buf tin)
- "Subfunction to cvs-add. Internal use only.
-Update the display. Return non-nil if `cvs add' should be called on this
-file. Args: CVS-BUF TIN.
-Returns 'ADD or 'RESURRECT."
- (let ((fileinfo (cookie-cookie cvs-buf tin)))
- (cond
- ((eq (cvs-fileinfo->type fileinfo) 'UNKNOWN)
- (cvs-set-fileinfo->type fileinfo 'ADDED)
- (cookie-invalidate-tins cvs-buf tin)
- 'ADD)
- ((eq (cvs-fileinfo->type fileinfo) 'REMOVED)
- (cvs-set-fileinfo->type fileinfo 'UPDATED)
- (cvs-set-fileinfo->handled fileinfo t)
- (cookie-invalidate-tins cvs-buf tin)
- 'RESURRECT))))
-
-(defun cvs-add-sub (cvs-buf candidates)
- "Internal use only.
-Args: CVS-BUF CANDIDATES.
-CANDIDATES is a list of tins. Updates the CVS-BUF and returns a pair of lists.
-The first list is unknown tins that shall be `cvs add -m msg'ed.
-The second list is removed files that shall be `cvs add'ed (resurrected)."
- (let (add resurrect)
- (while candidates
- (let ((type (cvs-add-file-update-buffer cvs-buf (car candidates))))
- (cond ((eq type 'ADD)
- (setq add (cons (car candidates) add)))
- ((eq type 'RESURRECT)
- (setq resurrect (cons (car candidates) resurrect)))))
- (setq candidates (cdr candidates)))
- (cons add resurrect)))
-
-(defun cvs-add ()
- "Add marked files to the cvs repository."
- (interactive)
-
- (let* ((buf (current-buffer))
- (result (cvs-add-sub buf (cvs-get-marked)))
- (added (car result))
- (resurrect (cdr result))
- (msg (if added (read-from-minibuffer "Enter description: "))))
-
- (if (or resurrect added)
- (cvs-use-temp-buffer))
-
- (cond (resurrect
- (message "Resurrecting files from repository...")
- (cvs-execute-list resurrect cvs-program '("add"))
- (message "Done.")))
-
- (cond (added
- (message "Adding new files to repository...")
- (cvs-execute-list added cvs-program (list "add" "-m" msg))
- (message "Done.")))))
-
-(defun cvs-ignore ()
- "Arrange so that CVS ignores the selected files.
-This command ignores files that are not flagged as `Unknown'."
- (interactive)
-
- (mapcar (function (lambda (tin)
- (cond
- ((eq (cvs-fileinfo->type
- (cookie-cookie (current-buffer) tin)) 'UNKNOWN)
- (cvs-append-to-ignore
- (cookie-cookie (current-buffer) tin))
- (cookie-delete (current-buffer) tin)))))
- (cvs-get-marked))
- (setq cookie-last-tin nil))
-
-(defun cvs-append-to-ignore (fileinfo)
- "Append the file in fileinfo to the .cvsignore file"
- (save-window-excursion
- (set-buffer (find-file-noselect (concat (file-name-as-directory
- (cvs-fileinfo->dir fileinfo))
- ".cvsignore")))
- (goto-char (point-max))
- (if (not (zerop (current-column)))
- (insert "\n"))
- (insert (cvs-fileinfo->file-name fileinfo) "\n")
- (save-buffer)))
-
-(defun cvs-status ()
- "Show cvs status for all marked files."
- (interactive)
-
- (save-some-buffers)
- (let ((marked (cvs-get-marked)))
- (cvs-use-temp-buffer)
- (message "Running cvs status ...")
- (cvs-execute-list marked cvs-program (cons "status" cvs-status-flags)))
- (message "Running cvs status ... Done."))
-
-(defun cvs-log ()
- "Display the cvs log of all selected files."
- (interactive)
-
- (let ((marked (cvs-get-marked)))
- (cvs-use-temp-buffer)
- (message "Running cvs log ...")
- (cvs-execute-list marked cvs-program (cons "log" cvs-log-flags)))
- (message "Running cvs log ... Done."))
-
-
-(defun cvs-insert-full-path (tin)
- "Insert full path to the file described in TIN."
- (insert (format "%s\n" (cvs-full-path cvs-buffer-name tin))))
-
-
-(defun cvs-add-change-log-entry-other-window (pos)
- "Add a ChangeLog entry in the ChangeLog of the current directory.
-Args: POS."
- (interactive "d")
- (let* ((cvs-buf (current-buffer))
- (odir default-directory))
- (setq default-directory
- (file-name-as-directory
- (cvs-fileinfo->dir
- (cookie-cookie
- cvs-buf
- (cookie-get-selection cvs-buf pos cookie-last-tin)))))
- (if (not default-directory) ;In case there was no entries.
- (setq default-directory odir))
- (add-change-log-entry-other-window)
- (set-buffer cvs-buf)
- (setq default-directory odir)))
-
-
-(defun print-cvs-tin (foo)
- "Debug utility."
- (let ((cookie (cookie-cookie (current-buffer) foo))
- (stream (get-buffer-create "debug")))
- (princ "==============\n" stream)
- (princ (cvs-fileinfo->file-name cookie) stream)
- (princ "\n" stream)
- (princ (cvs-fileinfo->dir cookie) stream)
- (princ "\n" stream)
- (princ (cvs-fileinfo->full-log cookie) stream)
- (princ "\n" stream)
- (princ (cvs-fileinfo->marked cookie) stream)
- (princ "\n" stream)))
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info
deleted file mode 100644
index 3c0d3c0..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info
+++ /dev/null
@@ -1,1367 +0,0 @@
-Info file pcl-cvs, produced by Makeinfo, -*- Text -*- from input
-file pcl-cvs.texinfo.
-
- Copyright (C) 1992 Per Cederqvist
-
- 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" and this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-
-
-File: pcl-cvs, Node: Top, Next: Copying, Prev: (dir), Up: (dir)
-
- This info manual describes pcl-cvs which is a GNU Emacs front-end
-to CVS. It works with CVS version 1.3. This manual is updated to
-release 1.02 of pcl-cvs.
-
-* Menu:
-
-* Copying:: GNU General Public License
-* Installation:: How to install pcl-cvs on your system.
-* About pcl-cvs:: Authors and ftp sites.
-
-* Getting started:: An introduction with a walk-through example.
-* Buffer contents:: An explanation of the buffer contents.
-* Commands:: All commands, grouped by type.
-
-* Customization:: How you can tailor pcl-cvs to suit your needs.
-* Future enhancements:: Future enhancements of pcl-cvs.
-* Reporting bugs and ideas:: Where to report bugs.
-
-* Function and Variable Index:: List of functions and variables.
-* Concept Index:: List of concepts.
-* Key Index:: List of keystrokes.
-
- -- The Detailed Node Listing --
-
-Installation
-
-* Pcl-cvs installation:: How to install pcl-cvs on your system.
-* On-line manual installation:: How to install the on-line manual.
-* Typeset manual installation:: How to create typeset documentation
- about pcl-cvs.
-
-About pcl-cvs
-
-* Contributors:: Contributors to pcl-cvs.
-* Archives:: Where can I get a copy of Pcl-Cvs?
-
-Buffer contents
-
-* File status:: The meaning of the second field.
-* Selected files:: How selection works.
-
-Commands
-
-* Updating the directory:: Commands to update the local directory
-* Movement commands:: How to move up and down in the buffer
-* Marking files:: How to mark files that other commands
- will later operate on.
-* Committing changes:: Checking in your modifications to the
- CVS repository.
-* Editing files:: Loading files into Emacs.
-* Getting info about files:: Display the log and status of files.
-* Adding and removing files:: Adding and removing files
-* Removing handled entries:: Uninteresting lines can easily be removed.
-* Ignoring files:: Telling CVS to ignore generated files.
-* Viewing differences:: Commands to `diff' different versions.
-
-
-File: pcl-cvs, Node: Copying, Next: Installation, Prev: Top, Up: Top
-
-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.
-
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 1. 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.
-
- 2. 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.
-
- 3. 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:
-
- 1. You must cause the modified files to carry prominent
- notices stating that you changed the files and the date of
- any change.
-
- 2. 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.
-
- 3. 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.
-
- 4. 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:
-
- 1. 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,
-
- 2. 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,
-
- 3. 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.
-
- 5. 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.
-
- 6. 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.
-
- 7. 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.
-
- 8. 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.
-
- 9. 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.
-
- 10. 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.
-
- 11. 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
-
- 12. 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.
-
- 13. 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.
-
-
-File: pcl-cvs, Node: Installation, Next: About pcl-cvs, Prev: Copying, Up: Top
-
-Installation
-************
-
- This section describes the installation of pcl-cvs, the GNU Emacs
-CVS front-end. You should install not only the elisp files
-themselves, but also the on-line documentation so that your users
-will know how to use it. You can create typeset documentation from
-the file `pcl-cvs.texinfo' as well as an on-line info file. The
-following steps are also described in the file `INSTALL' in the
-source directory.
-
-* Menu:
-
-* Pcl-cvs installation:: How to install pcl-cvs on your system.
-* On-line manual installation:: How to install the on-line manual.
-* Typeset manual installation:: How to create typeset documentation
- about pcl-cvs.
-
-
-File: pcl-cvs, Node: Pcl-cvs installation, Next: On-line manual installation, Prev: Installation, Up: Installation
-
-Installation of the pcl-cvs program
-===================================
-
- 1. Edit the file `Makefile' to reflect the situation at your site.
- The only things you have to change is the definition of
- `lispdir' and `infodir'. The elisp files will be copied to
- `lispdir', and the info file to `infodir'.
-
- 2. Configure pcl-cvs.el
-
- There are a couple of paths that you have to check to make
- sure that they match you system. They appear early in the file
- pcl-cvs.el.
-
- *NOTE:* If your system is running emacs 18.57 or earlier
- you MUST uncomment the line that says:
-
- (setq delete-exited-processes nil)
-
- Setting `delete-exited-processes' to `nil' works around a bug
- in emacs that causes it to dump core. The bug was fixed in
- emacs 18.58.
-
- 3. Type `make install' in the source directory. This will
- byte-compile all `.el' files and copy both the `.el' and the
- `.elc' into the directory you specified in step 1.
-
- If you don't want to install the `.el' files but only the
- `.elc' files (the byte-compiled files), you can type ``make
- install_elc'' instead of ``make install''.
-
- If you only want to create the compiled elisp files, but
- don't want to install them, you can type `make elcfiles'
- instead. This is what happens if you only type `make' without
- parameters.
-
- 4. Edit the file `default.el' in your emacs lisp directory (usually
- `/usr/gnu/emacs/lisp' or something similar) and enter the
- contents of the file `pcl-cvs-startup.el' into it. It contains
- a couple of `auto-load's that facilitates the use of pcl-cvs.
-
-
-File: pcl-cvs, Node: On-line manual installation, Next: Typeset manual installation, Prev: Pcl-cvs installation, Up: Installation
-
-Installation of the on-line manual.
-===================================
-
- 1. Create the info file `pcl-cvs' from `pcl-cvs.texinfo' by typing
- `make info'. If you don't have the program `makeinfo' you can
- get it by anonymous ftp from e.g. `ftp.gnu.ai.mit.edu' as
- `pub/gnu/texinfo-2.14.tar.Z' (there might be a newer version
- there when you read this), or you could use the preformatted
- info file `pcl-cvs.info' that is included in the distribution
- (type `cp pcl-cvs.info pcl-cvs').
-
- 2. Move the info file `pcl-cvs' to your standard info directory.
- This might be called something like `/usr/gnu/emacs/info'.
-
- 3. Edit the file `dir' in the info directory and enter one line to
- contain a pointer to the info file `pcl-cvs'. The line can, for
- instance, look like this:
-
- * Pcl-cvs: (pcl-cvs). An Emacs front-end to CVS.
-
-
-File: pcl-cvs, Node: Typeset manual installation, Prev: On-line manual installation, Up: Installation
-
-How to make typeset documentation from pcl-cvs.texinfo
-======================================================
-
- If you have TeX installed at your site, you can make a typeset
-manual from `pcl-cvs.texinfo'.
-
- 1. Run TeX by typing ``make pcl-cvs.dvi''. You will not get the
- indices unless you have the `texindex' program.
-
- 2. Convert the resulting device independent file `pcl-cvs.dvi' to a
- form which your printer can output and print it. If you have a
- postscript printer there is a program, `dvi2ps', which does.
- There is also a program which comes together with TeX, `dvips',
- which you can use.
-
-
-File: pcl-cvs, Node: About pcl-cvs, Next: Getting started, Prev: Installation, Up: Top
-
-About pcl-cvs
-*************
-
- Pcl-cvs is a front-end to CVS version 1.3. It integrates the most
-frequently used CVS commands into emacs.
-
-* Menu:
-
-* Contributors:: Contributors to pcl-cvs.
-* Archives:: Where can I get a copy of Pcl-Cvs?
-
-
-File: pcl-cvs, Node: Contributors, Next: Archives, Prev: About pcl-cvs, Up: About pcl-cvs
-
-Contributors to pcl-cvs
-=======================
-
- Contributions to the package are welcome. I have limited time to
-work on this project, but I will gladly add any code that you
-contribute to me to this package (*note Reporting bugs and ideas::.).
-
- The following persons have made contributions to pcl-cvs.
-
- * Brian Berliner wrote CVS, together with some other contributors.
- Without his work on CVS this package would be useless...
-
- * Per Cederqvist wrote most of the otherwise unattributed
- functions in pcl-cvs as well as all documentation.
-
- * Inge Wallin (`inge@lysator.liu.se') wrote the skeleton to
- `pcl-cvs.texinfo', and gave useful comments on it. He also
- wrote the files `elib-node.el' and `compile-all.el'. The file
- `cookie.el' was inspired by Inge.
-
- * Linus Tolke (`linus@lysator.liu.se') contributed useful comments
- on both the functionality and the documentation.
-
-
-File: pcl-cvs, Node: Archives, Prev: Contributors, Up: About pcl-cvs
-
-Where can I get pcl-cvs?
-========================
-
- This release of pcl-cvs is included in the CVS 1.3 distribution.
-However, since pcl-cvs has had less time to mature (the first line of
-code was written less than a year ago) it is likely that there will
-be a new release of pcl-cvs before the next release of CVS.
-
- The latest release of pcl-cvs can be fetched via anonymous ftp
-from `ftp.lysator.liu.se', (IP no. 130.236.254.1) in the directory
-`pub/emacs'. If you don't live in Scandinavia you should probably
-check with archie to see if there is a site closer to you that
-archives pcl-cvs.
-
- New releases will be announced to appropriate newsgroups. If you
-send your email address to me I will add you to my list of people to
-mail when I make a new release.
-
-
-File: pcl-cvs, Node: Getting started, Next: Buffer contents, Prev: About pcl-cvs, Up: Top
-
-Getting started
-***************
-
- This document assumes that you know what CVS is, and that you at
-least knows the fundamental concepts of CVS. If that is not the
-case you should read the man page for CVS.
-
- Pcl-cvs is only useful once you have checked out a module. So
-before you invoke it you must have a copy of a module somewhere in
-the file system.
-
- You invoke pcl-cvs by typing `M-x pcl-cvs RET'. If your emacs
-responds with `[No match]' your system administrator has not
-installed pcl-cvs properly. Try `M-x load-library RET pcl-cvs RET'.
-If that also fails - talk to your root. If it succeeds you might put
-this line in your `.emacs' file so that you don't have to type the
-`load-library' command every time you wish to use pcl-cvs:
-
- (autoload 'cvs-update "pcl-cvs" nil t)
-
- The function `cvs-update' will ask for a directory. The command
-`cvs update' will be run in that directory. (It should contain
-files that have been checked out from a CVS archive.) The output
-from `cvs' will be parsed and presented in a table in a buffer called
-`*cvs*'. It might look something like this:
-
- PCL-CVS release 1.02.
-
- In directory /users/ceder/FOO/test:
- Updated bar
- Updated file.txt
- Modified ci namechange
- Updated newer
-
- In directory /users/ceder/FOO/test/sub:
- Modified ci ChangeLog
- ---------- End -----
-
- In this example the three files (`bar', `file.txt' and `newer')
-that are marked with `Updated' have been copied from the CVS
-repository to `/users/ceder/FOO/test/' since someone else have
-checked in newer versions of them. Two files (`namechange' and
-`sub/ChangeLog') have been modified locally, and needs to be checked
-in.
-
- You can move the cursor up and down in the buffer with `C-n' and
-`C-p' or `n' and `p'. If you press `c' on one of the `Modified'
-files that file will be checked in to the CVS repository. *Note
-Committing changes::. You can press `x' to get rid of the
-"uninteresting" files that have only been `Updated' (and don't
-require any further action from you).
-
- You can also easily get a `diff' between your modified file and
-the base version that you started from, and you can get the output
-from `cvs log' and `cvs status' on the listed files simply by
-pressing a key (*note Getting info about files::.).
-
-
-File: pcl-cvs, Node: Buffer contents, Next: Commands, Prev: Getting started, Up: Top
-
-Buffer contents
-***************
-
- The display contains four columns. They contain, from left to
-right:
-
- * An asterisk when the file is "marked" (*note Selected files::.).
-
- * The status of the file. See *Note File status::, for more
- information.
-
- * A "need to be checked in"-marker (`ci').
-
- * The file name.
-
-* Menu:
-
-* File status:: The meaning of the second field.
-* Selected files:: How selection works.
-
-
-File: pcl-cvs, Node: File status, Next: Selected files, Prev: Buffer contents, Up: Buffer contents
-
-File status
-===========
-
- The `file status' field can have the following values:
-
-`Updated'
- The file was brought up to date with respect to the repository.
- This is done for any file that exists in the repository but
- not in your source, and for files that you haven't changed but
- are not the most recent versions available in the repository.
-
-`Modified'
- The file is modified in your working directory, and there
- was no modification to the same file in the repository.
-
-`Merged'
- The file is modified in your working directory, and there were
- modifications in the repository as well as in your copy, but
- they were merged successfully, without conflict, in your
- working directory.
-
-`Conflict'
- A conflict was detected while trying to merge your changes to
- FILE with changes from the source repository. FILE (the copy
- in your working directory) is now the output of the `rcsmerge'
- command on the two versions; an unmodified copy of your file is
- also in your working directory, with the name `.#FILE.VERSION',
- where VERSION is the RCS revision that your modified file
- started from. *Note Viewing differences::, for more details.
-
-`Added'
- The file has been added by you, but it still needs to be
- checked in to the repository.
-
-`Removed'
- The file has been removed by you, but it needs to be checked in
- to the repository. You can resurrect it by typing `a' (*note
- Adding and removing files::.).
-
-`Unknown'
- A file that was detected in your directory, but that neither
- appears in the repository, nor is present on the list of files
- that CVS should ignore.
-
- There are also a few special cases, that rarely occur, which have
-longer strings in the fields:
-
-`Removed from repository'
- The file has been removed from your directory since someone has
- removed it from the repository. (It is still present in the
- Attic directory, so no permanent loss has occurred). This,
- unlike the other entries in this table, is not an error
- condition.
-
-`Removed from repository, changed by you'
- You have modified a file that someone have removed from the
- repository. You can correct this situation by removing the
- file manually (see *note Adding and removing files::.).
-
-`Removed by you, changed in repository'
- You have removed a file, and before you committed the removal
- someone committed a change to that file. You could use `a' to
- resurrect the file (see *note Adding and removing files::.).
-
-`Move away FILE - it is in the way'
- For some reason CVS does not like the file FILE. Rename or
- remove it.
-
-`This repository is missing! Remove this dir manually.'
- It is impossible to remove a directory in the CVS repository in
- a clean way. Someone have tried to remove one, and CVS gets
- confused. Remove your copy of the directory.
-
-
-File: pcl-cvs, Node: Selected files, Prev: File status, Up: Buffer contents
-
-Selected files
-==============
-
- Many of the commands works on the current set of "selected" files.
-
- * If there are any files that are marked they constitute the set
- of selected files.
-
- * Otherwise, if the cursor points to a file, that file is the
- selected file.
-
- * Otherwise, if the cursor points to a directory, all the files
- in that directory that appears in the buffer are the selected
- files.
-
- This scheme might seem a little complicated, but once one get
-used to it, it is quite powerful.
-
- *Note Marking files:: tells how you mark and unmark files.
-
-
-File: pcl-cvs, Node: Commands, Next: Customization, Prev: Buffer contents, Up: Top
-
-Commands
-********
-
- The nodes in this menu contains explanations about all the
-commands that you can use in pcl-cvs. They are grouped together by
-type.
-
-* Menu:
-
-* Updating the directory:: Commands to update the local directory
-* Movement commands:: How to move up and down in the buffer
-* Marking files:: How to mark files that other commands
- will later operate on.
-* Committing changes:: Checking in your modifications to the
- CVS repository.
-* Editing files:: Loading files into Emacs.
-* Getting info about files:: Display the log and status of files.
-* Adding and removing files:: Adding and removing files
-* Removing handled entries:: Uninteresting lines can easily be removed.
-* Ignoring files:: Telling CVS to ignore generated files.
-* Viewing differences:: Commands to `diff' different versions.
-
-
-File: pcl-cvs, Node: Updating the directory, Next: Movement commands, Prev: Commands, Up: Commands
-
-Updating the directory
-======================
-
-`M-x cvs-update'
- Run a `cvs update' command. You will be asked for the
- directory in which the `cvs update' will be run. The output
- will be parsed by pcl-cvs, and the result printed in the
- `*cvs*' buffer (see *note Buffer contents::. for a description
- of the contents).
-
- By default, `cvs-update' will descend recursively into
- subdirectories. You can avoid that behavior by giving a prefix
- argument to it (e.g., by typing `C-u M-x cvs-update RET').
-
- All other commands in pcl-cvs requires that you have a `*cvs*'
- buffer. This is the command that you use to get one.
-
-`g'
- This will run `cvs update' again. It will always use the same
- buffer that was used with the previous `cvs update'. Give a
- prefix argument to avoid descending into subdirectories. This
- runs the command `cvs-update-no-prompt'.
-
-
-File: pcl-cvs, Node: Movement commands, Next: Marking files, Prev: Updating the directory, Up: Commands
-
-Movement Commands
-=================
-
- You can use most normal Emacs commands to move forward and
-backward in the buffer. Some keys are rebound to functions that
-take advantage of the fact that the buffer is a pcl-cvs buffer:
-
-`SPC'
-`C-n'
-`n'
- These keys move the cursor one file forward, towards the end of
- the buffer (`cookie-next-cookie').
-
-`C-p'
-`p'
- These keys move one file backward, towards the beginning of the
- buffer (`cookie-previous-cookie').
-
-
-File: pcl-cvs, Node: Marking files, Next: Committing changes, Prev: Movement commands, Up: Commands
-
-Marking files
-=============
-
- Pcl-cvs works on a set of "selected files" (*note Selected
-files::.). You can mark and unmark files with these commands:
-
-`m'
- This marks the file that the cursor is positioned on. If the
- cursor is positioned on a directory all files in that directory
- will be marked. (`cvs-mark').
-
-`u'
- Unmark the file that the cursor is positioned on. If the cursor
- is on a directory, all files in that directory will be unmarked.
- (`cvs-unmark').
-
-`M'
- Mark *all* files in the buffer (`cvs-mark-all-files').
-
-`U'
- Unmark *all* files (`cvs-unmark-all-files').
-
-`DEL'
- Unmark the file on the previous line, and move point to that
- line (`cvs-unmark-up').
-
-
-File: pcl-cvs, Node: Committing changes, Next: Editing files, Prev: Marking files, Up: Commands
-
-Committing changes
-==================
-
-`c'
- All files that have a "need to be checked in"-marker (*note
- Buffer contents::.) can be checked in with the `c' command. It
- checks in all selected files (*note Selected files::.) (except
- those who lack the "ci"-marker - they are ignored). Pressing
- `c' causes `cvs-commit' to be run.
-
- When you press `c' you will get a buffer called
- `*cvs-commit-message*'. Enter the log message for the file(s)
- in it. When you are ready you should press `C-c C-c' to
- actually commit the files (using `cvs-edit-done').
-
- Normally the `*cvs-commit-message*' buffer will retain the log
- message from the previous commit, but if the variable
- `cvs-erase-input-buffer' is set to a non-nil value the buffer
- will be erased. Point and mark will always be located around
- the entire buffer so that you can easily erase it with `C-w'
- (`kill-region').
-
-
-File: pcl-cvs, Node: Editing files, Next: Getting info about files, Prev: Committing changes, Up: Commands
-
-Editing files
-=============
-
- There are currently three commands that can be used to find a
-file (that is, load it into a buffer and start editing it there).
-These commands work on the line that the cursor is situated at.
-They ignore any marked files.
-
-`f'
- Find the file that the cursor points to. Run `dired'
-
- (*note Dired: (Emacs)Dired.)
-
- if the cursor points to a directory (`cvs-find-file').
-
-`o'
- Like `f', but use another window (`cvs-find-file-other-window').
-
-`A'
- Invoke `add-change-log-entry-other-window' to edit a
- `ChangeLog' file. The `ChangeLog' will be found in the
- directory of the file the cursor points to.
- (`cvs-add-change-log-entry-other-window').
-
-
-File: pcl-cvs, Node: Getting info about files, Next: Adding and removing files, Prev: Editing files, Up: Commands
-
-Getting info about files
-========================
-
- Both of the following commands can be customized. *Note
-Customization::.
-
-`l'
- Run `cvs log' on all selected files, and show the result in a
- temporary buffer (`cvs-log').
-
-`s'
- Run `cvs status' on all selected files, and show the result in a
- temporary buffer (`cvs-status').
-
-
-File: pcl-cvs, Node: Adding and removing files, Next: Removing handled entries, Prev: Getting info about files, Up: Commands
-
-Adding and removing files
-=========================
-
- The following commands are available to make it easy to add and
-remove files from the CVS repository.
-
-`a'
- Add all selected files. This command can be used on `Unknown'
- files (see *note File status::.). The status of the file will
- change to `Added', and you will have to use `c' (`cvs-commit',
- see *note Committing changes::.) to really add the file to the
- repository.
-
- This command can also be used on `Removed' files (before you
- commit them) to resurrect them.
-
- Selected files that are neither `Unknown' nor `Removed' will be
- ignored by this command.
-
- The command that is run is `cvs-add'.
-
-`r'
- This command removes the selected files (after prompting for
- confirmation). The files are `rm'ed from your directory and
- (unless the status was `Unknown'; *note File status::.) they
- will also be `cvs remove'd. If the files were `Unknown' they
- will disappear from the buffer. Otherwise their status will
- change to `Removed', and you must use `c' (`cvs-commit', *note
- Committing changes::.) to commit the removal.
-
- The command that is run is `cvs-remove-file'.
-
-
-File: pcl-cvs, Node: Removing handled entries, Next: Ignoring files, Prev: Adding and removing files, Up: Commands
-
-Removing handled entries
-========================
-
-`x'
- This command allows you to remove all entries that you have
- processed. More specifically, the lines for `Updated' files
- (*note File status::. and files that have been checked in
- (*note Committing changes::.) are removed from the buffer. If
- a directory becomes empty the heading for that directory is
- also removed. This makes it easier to get an overview of what
- needs to be done.
-
- The command is called `cvs-remove-handled'. If
- `cvs-auto-remove-handled' is set to non-`nil' this will
- automatically be performed after every commit.
-
-`C-k'
- This command can be used for lines that `cvs-remove-handled'
- would not delete, but that you want to delete
- (`cvs-acknowledge').
-
-
-File: pcl-cvs, Node: Ignoring files, Next: Viewing differences, Prev: Removing handled entries, Up: Commands
-
-Ignoring files
-==============
-
-`i'
- Arrange so that CVS will ignore the selected files. The file
- names are added to the `.cvsignore' file in the corresponding
- directory. If the `.cvsignore' doesn't exist it will be
- created.
-
- The `.cvsignore' file should normally be added to the
- repository, but you could ignore it also if you like it better
- that way.
-
- This runs `cvs-ignore'.
-
-
-File: pcl-cvs, Node: Viewing differences, Prev: Ignoring files, Up: Commands
-
-Viewing differences
-===================
-
-`d'
- Display a `cvs diff' between the selected files and the RCS
- version that they are based on. *Note Customization::
- describes how you can send flags to `cvs diff'. (The function
- that does the job is `cvs-diff-cvs').
-
-`b'
- If CVS finds a conflict while merging two versions of a file
- (during a `cvs update', *note Updating the directory::.) it
- will save the original file in a file called `.#FILE.VERSION'
- where FILE is the name of the file, and VERSION is the RCS
- version number that your file was based on.
-
- With the `b' command you can run a `diff' on the files
- `.#FILE.VERSION' and `FILE'. You can get a context- or Unidiff
- by setting `cvs-diff-flags' - *note Customization::.. This
- command only works on files that have status `Conflict' or
- `Merged'. The name of the command is `cvs-diff-backup'.
-
-
-File: pcl-cvs, Node: Customization, Next: Future enhancements, Prev: Commands, Up: Top
-
-Customization
-*************
-
- If you have an idea about any customization that would be handy
-but isn't present in this list, please tell me! *Note Reporting
-bugs and ideas:: for info on how to reach me.
-
-`cvs-erase-input-buffer'
- If set to anything else than `nil' the edit buffer will be
- erased before you write the log message (*note Committing
- changes::.).
-
-`cvs-inhibit-copyright-message'
- The copyright message that is displayed on startup can be
- annoying after a while. Set this variable to `t' if you want
- to get rid of it. (But don't set this to `t' in the system
- defaults file - new users should see this message at least
- once).
-
-`cvs-cvs-diff-flags'
- A list of strings to pass as arguments to the `cvs diff'
- program. This is used by `cvs-diff-cvs' (key `d', *note
- Viewing differences::.). If you prefer the Unidiff format you
- could add this line to your `.emacs' file:
-
- (setq cvs-cvs-diff-flags '("-u"))
-
-`cvs-diff-flags'
- Like `cvs-cvs-diff-flags', but passed to `diff'. This is used
- by `cvs-diff-backup' (key `b', *note Viewing differences::.).
-
-`cvs-log-flags'
- List of strings to send to `cvs log'. Used by `cvs-log' (key
- `l', *note Getting info about files::.).
-
-`cvs-status-flags'
- List of strings to send to `cvs status'. Used by `cvs-status'
- (key `s', *note Getting info about files::.).
-
-`cvs-auto-remove-handled'
- If this variable is set to any non-`nil' value
- `cvs-remove-handled' will be called every time you check in
- files, after the check-in is ready. *Note Removing handled
- entries::.
-
-
-File: pcl-cvs, Node: Future enhancements, Next: Reporting bugs and ideas, Prev: Customization, Up: Top
-
-Future enhancements
-*******************
-
- Pcl-cvs is still under development and needs a number of
-enhancements to be called complete. Here is my current wish-list
-for future releases of pcl-cvs:
-
- * Dired support. I have an experimental `dired-cvs.el' that works
- together with CVS 1.2. Unfortunately I wrote it on top of a
- non-standard `dired.el', so it must be rewritten.
-
- * It should be possible to run commands such as `cvs log', `cvs
- status' and `cvs commit' directly from a buffer containing a
- file, instead of having to `cvs-update'. If the directory
- contains many files the `cvs-update' can take quite some time,
- especially on a slow machine.
-
- If you miss something in this wish-list, let me know! I don't
-promise that I will write it, but I will at least try to coordinate
-the efforts of making a good Emacs front end to CVS. See *Note
-Reporting bugs and ideas:: for information about how to reach me.
-
-
-File: pcl-cvs, Node: Reporting bugs and ideas, Next: Function and Variable Index, Prev: Future enhancements, Up: Top
-
-Reporting bugs and ideas
-************************
-
- If you find a bug or misfeature, don't hesitate to tell me! Send
-email to `ceder@lysator.liu.se'.
-
- If you have ideas for improvements, or if you have written some
-extensions to this package, I would like to hear from you. I hope
-that you find this package useful!
-
-
-File: pcl-cvs, Node: Function and Variable Index, Next: Concept Index, Prev: Reporting bugs and ideas, Up: Top
-
-Function and Variable Index
-***************************
-
-* Menu:
-
-* cookie-next-cookie: Movement commands.
-* cookie-previous-cookie: Movement commands.
-* cvs-acknowledge: Removing handled entries.
-* cvs-add: Adding and removing files.
-* cvs-add-change-log-entry-other-window: Editing files.
-* cvs-auto-remove-handled (variable): Customization.
-* cvs-commit: Committing changes.
-* cvs-cvs-diff-flags (variable): Customization.
-* cvs-diff-backup: Viewing differences.
-* cvs-diff-cvs: Viewing differences.
-* cvs-diff-flags (variable): Customization.
-* cvs-erase-input-buffer (variable): Committing changes.
-* cvs-erase-input-buffer (variable): Customization.
-* cvs-find-file: Editing files.
-* cvs-find-file-other-window: Editing files.
-* cvs-inhibit-copyright-message (variable): Customization.
-* cvs-log: Getting info about files.
-* cvs-log-flags (variable): Customization.
-* cvs-mark: Marking files.
-* cvs-mark-all-files: Marking files.
-* cvs-remove-file: Adding and removing files.
-* cvs-remove-handled: Removing handled entries.
-* cvs-status: Getting info about files.
-* cvs-status-flags (variable): Customization.
-* cvs-unmark: Marking files.
-* cvs-unmark-all-files: Marking files.
-* cvs-unmark-up: Marking files.
-* cvs-update: Updating the directory.
-* cvs-update-no-prompt: Updating the directory.
-
-
-File: pcl-cvs, Node: Concept Index, Next: Key Index, Prev: Function and Variable Index, Up: Top
-
-Concept Index
-*************
-
-* Menu:
-
-* About pcl-cvs: About pcl-cvs.
-* Active files: Selected files.
-* Added (file status): File status.
-* Adding files: Adding and removing files.
-* Archives: Archives.
-* Author, how to reach: Reporting bugs and ideas.
-* Authors: Contributors.
-* Automatically remove handled files: Customization.
-* Buffer contents: Buffer contents.
-* Bugs, how to report them: Reporting bugs and ideas.
-* Ci: Committing changes.
-* Commit buffer: Committing changes.
-* Committing changes: Committing changes.
-* Conflict (file status): File status.
-* Conflicts, how to resolve them: Viewing differences.
-* Context diff, how to get: Customization.
-* Contributors: Contributors.
-* Copyright message, getting rid of it: Customization.
-* Customization: Customization.
-* Deleting files: Adding and removing files.
-* Diff: Viewing differences.
-* Dired: Editing files.
-* Edit buffer: Committing changes.
-* Editing files: Editing files.
-* Email archives: Archives.
-* Email to the author: Reporting bugs and ideas.
-* Enhancements: Future enhancements.
-* Erasing commit message: Committing changes.
-* Erasing the input buffer: Customization.
-* Example run: Getting started.
-* Expunging uninteresting entries: Removing handled entries.
-* File selection: Selected files.
-* File status: File status.
-* Finding files: Editing files.
-* Ftp-sites: Archives.
-* Generating a typeset manual: Typeset manual installation.
-* Generating the on-line manual: On-line manual installation.
-* Getting pcl-cvs: Archives.
-* Getting rid of the Copyright message.: Customization.
-* Getting rid of uninteresting lines: Removing handled entries.
-* Getting status: Getting info about files.
-* Handled lines, removing them: Removing handled entries.
-* Info-file (how to generate): On-line manual installation.
-* Inhibiting the Copyright message.: Customization.
-* Installation: Installation.
-* Installation of elisp files: Pcl-cvs installation.
-* Installation of on-line manual: On-line manual installation.
-* Installation of typeset manual: Typeset manual installation.
-* Introduction: Getting started.
-* Invoking dired: Editing files.
-* Loading files: Editing files.
-* Log (RCS/cvs command): Getting info about files.
-* Manual installation (on-line): On-line manual installation.
-* Manual installation (typeset): Typeset manual installation.
-* Marked files: Selected files.
-* Marking files: Marking files.
-* Merged (file status): File status.
-* Modified (file status): File status.
-* Move away FILE - it is in the way (file status): File status.
-* Movement Commands: Movement commands.
-* On-line manual (how to generate): On-line manual installation.
-* Printing a manual: Typeset manual installation.
-* Putting files under CVS control: Adding and removing files.
-* Removed (file status): File status.
-* Removed by you, changed in repository (file status): File status.
-* Removed from repository (file status): File status.
-* Removed from repository, changed by you (file status): File status.
-* Removing files: Adding and removing files.
-* Removing uninteresting (processed) lines: Removing handled entries.
-* Reporting bugs and ideas: Reporting bugs and ideas.
-* Resurrecting files: Adding and removing files.
-* Selected files: Selected files.
-* Selecting files (commands to mark files): Marking files.
-* Sites: Archives.
-* Status (cvs command): Getting info about files.
-* TeX - generating a typeset manual: Typeset manual installation.
-* This repository is missing!... (file status): File status.
-* Unidiff, how to get: Customization.
-* Uninteresting entries, getting rid of them: Removing handled entries.
-* Unknown (file status): File status.
-* Updated (file status): File status.
-* Variables, list of all: Customization.
-* Viewing differences: Viewing differences.
-
-
-File: pcl-cvs, Node: Key Index, Prev: Concept Index, Up: Top
-
-Key Index
-*********
-
-* Menu:
-
-* A - add ChangeLog entry: Editing files.
-* C-k - remove selected entries: Removing handled entries.
-* C-n - Move down one file: Movement commands.
-* C-p - Move up one file: Movement commands.
-* DEL - unmark previous file: Marking files.
-* M - marking all files: Marking files.
-* SPC - Move down one file: Movement commands.
-* U - unmark all files: Marking files.
-* a - add a file: Adding and removing files.
-* b - diff backup file: Viewing differences.
-* c - commit files: Committing changes.
-* d - run cvs diff: Viewing differences.
-* f - find file or directory: Editing files.
-* g - Rerun cvs update: Updating the directory.
-* l - run cvs log: Getting info about files.
-* m - marking a file: Marking files.
-* n - Move down one file: Movement commands.
-* o - find file in other window: Editing files.
-* p - Move up on file: Movement commands.
-* r - remove a file: Adding and removing files.
-* s - run cvs status: Getting info about files.
-* u - unmark a file: Marking files.
-* x - remove processed entries: Removing handled entries.
-
-
-
-Tag Table:
-Node: Top1004
-Node: Copying3396
-Node: Installation22716
-Node: Pcl-cvs installation23507
-Node: On-line manual installation25291
-Node: Typeset manual installation26310
-Node: About pcl-cvs27048
-Node: Contributors27417
-Node: Archives28440
-Node: Getting started29287
-Node: Buffer contents31728
-Node: File status32277
-Node: Selected files35303
-Node: Commands35976
-Node: Updating the directory37018
-Node: Movement commands38043
-Node: Marking files38629
-Node: Committing changes39456
-Node: Editing files40502
-Node: Getting info about files41335
-Node: Adding and removing files41805
-Node: Removing handled entries43145
-Node: Ignoring files44058
-Node: Viewing differences44593
-Node: Customization45595
-Node: Future enhancements47326
-Node: Reporting bugs and ideas48394
-Node: Function and Variable Index48842
-Node: Concept Index50743
-Node: Key Index55865
-
-End Tag Table
diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo
deleted file mode 100644
index 5ad8db1..0000000
--- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo
+++ /dev/null
@@ -1,1437 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-
-@comment pcl-cvs.texinfo,v 1.2 1992/04/07 20:49:23 berliner Exp
-@comment Documentation for the GNU Emacs CVS mode.
-@comment Copyright (C) 1992 Per Cederqvist
-
-@comment This file is part of the pcl-cvs distribution.
-
-@comment Pcl-cvs is free software; you can redistribute it and/or modify
-@comment it under the terms of the GNU General Public License as published by
-@comment the Free Software Foundation; either version 1, or (at your option)
-@comment any later version.
-
-@comment Pcl-cvs is distributed in the hope that it will be useful,
-@comment but WITHOUT ANY WARRANTY; without even the implied warranty of
-@comment MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-@comment GNU General Public License for more details.
-
-@comment You should have received a copy of the GNU General Public License
-@comment along with pcl-cvs; see the file COPYING. If not, write to
-@comment the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-@setfilename pcl-cvs
-@settitle Pcl-cvs - The Emacs Front-End to CVS
-@setchapternewpage on
-
-@ifinfo
-Copyright @copyright{} 1992 Per Cederqvist
-
-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'' and
-this permission notice may be included in translations approved by the
-Free Software Foundation instead of in the original English.
-@end ifinfo
-
-@synindex vr fn
-@comment The titlepage section does not appear in the Info file.
-@titlepage
-@sp 4
-@comment The title is printed in a large font.
-@center @titlefont{User's Guide}
-@sp
-@center @titlefont{to}
-@sp
-@center @titlefont{pcl-cvs - the Emacs Front-End to CVS}
-@sp 2
-@center release 1.02
-@comment -release-
-@sp 3
-@center Per Cederqvist
-@sp 3
-@center last updated 29 Mar 1992
-@comment -date-
-
-@comment The following two commands start the copyright page
-@comment for the printed manual. This will not appear in the Info file.
-@page
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1992 Per Cederqvist
-
-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'' and
-this permission notice may be included in translations approved by the
-Free Software Foundation instead of in the original English.
-@end titlepage
-
-@comment ================================================================
-@comment The real text starts here
-@comment ================================================================
-
-@node Top, Copying, (dir), (dir)
-@comment node-name, next, previous, up
-
-
-@ifinfo
-This info manual describes pcl-cvs which is a GNU Emacs front-end to
-CVS. It works with CVS version 1.3. This manual is updated to release
-1.02 of pcl-cvs.
-@end ifinfo
-@comment -release-
-
-@menu
-* Copying:: GNU General Public License
-* Installation:: How to install pcl-cvs on your system.
-* About pcl-cvs:: Authors and ftp sites.
-
-* Getting started:: An introduction with a walk-through example.
-* Buffer contents:: An explanation of the buffer contents.
-* Commands:: All commands, grouped by type.
-
-* Customization:: How you can tailor pcl-cvs to suit your needs.
-* Future enhancements:: Future enhancements of pcl-cvs.
-* Reporting bugs and ideas:: Where to report bugs.
-
-* Function and Variable Index:: List of functions and variables.
-* Concept Index:: List of concepts.
-* Key Index:: List of keystrokes.
-
- --- The Detailed Node Listing ---
-
-Installation
-
-* Pcl-cvs installation:: How to install pcl-cvs on your system.
-* On-line manual installation:: How to install the on-line manual.
-* Typeset manual installation:: How to create typeset documentation
- about pcl-cvs.
-
-About pcl-cvs
-
-* Contributors:: Contributors to pcl-cvs.
-* Archives:: Where can I get a copy of Pcl-Cvs?
-
-Buffer contents
-
-* File status:: The meaning of the second field.
-* Selected files:: How selection works.
-
-Commands
-
-* Updating the directory:: Commands to update the local directory
-* Movement commands:: How to move up and down in the buffer
-* Marking files:: How to mark files that other commands
- will later operate on.
-* Committing changes:: Checking in your modifications to the
- CVS repository.
-* Editing files:: Loading files into Emacs.
-* Getting info about files:: Display the log and status of files.
-* Adding and removing files:: Adding and removing files
-* Removing handled entries:: Uninteresting lines can easily be removed.
-* Ignoring files:: Telling CVS to ignore generated files.
-* Viewing differences:: Commands to @samp{diff} different versions.
-@end menu
-
-@node Copying, Installation, Top, Top
-@unnumbered 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 Installation, About pcl-cvs, Copying, Top
-@comment node-name, next, previous, up
-@chapter Installation
-@cindex Installation
-
-This section describes the installation of pcl-cvs, the GNU Emacs CVS
-front-end. You should install not only the elisp files themselves, but
-also the on-line documentation so that your users will know how to use
-it. You can create typeset documentation from the file
-@file{pcl-cvs.texinfo} as well as an on-line info file. The following
-steps are also described in the file @file{INSTALL} in the source
-directory.
-
-@menu
-* Pcl-cvs installation:: How to install pcl-cvs on your system.
-* On-line manual installation:: How to install the on-line manual.
-* Typeset manual installation:: How to create typeset documentation
- about pcl-cvs.
-@end menu
-
-@node Pcl-cvs installation, On-line manual installation, Installation, Installation
-@comment node-name, next, previous, up
-@section Installation of the pcl-cvs program
-@cindex Installation of elisp files
-
-@enumerate
-@item
-Edit the file @file{Makefile} to reflect the situation at your site.
-The only things you have to change is the definition of @code{lispdir}
-and @code{infodir}. The elisp files will be copied to @code{lispdir},
-and the info file to @code{infodir}.
-
-@item
-Configure pcl-cvs.el
-
-There are a couple of paths that you have to check to make sure that
-they match you system. They appear early in the file pcl-cvs.el.
-
-@strong{NOTE:} If your system is running emacs 18.57 or earlier you MUST
-uncomment the line that says:
-
-@example
-(setq delete-exited-processes nil)
-@end example
-
-Setting @code{delete-exited-processes} to @code{nil} works around a bug
-in emacs that causes it to dump core. The bug was fixed in emacs
-18.58.@refill
-
-@item
-Type @samp{make install} in the source directory. This will
-byte-compile all @file{.el} files and copy both the @file{.el} and the
-@file{.elc} into the directory you specified in step 1.
-
-If you don't want to install the @file{.el} files but only the
-@file{.elc} files (the byte-compiled files), you can type `@samp{make
-install_elc}' instead of `@samp{make install}'.
-
-If you only want to create the compiled elisp files, but don't want to
-install them, you can type @samp{make elcfiles} instead. This is what
-happens if you only type @samp{make} without parameters.
-
-@item
-Edit the file @file{default.el} in your emacs lisp directory (usually
-@file{/usr/gnu/emacs/lisp} or something similar) and enter the contents
-of the file @file{pcl-cvs-startup.el} into it. It contains a couple of
-@code{auto-load}s that facilitates the use of pcl-cvs.
-
-@end enumerate
-
-@node On-line manual installation, Typeset manual installation, Pcl-cvs installation, Installation
-@comment node-name, next, previous, up
-@section Installation of the on-line manual.
-@cindex Manual installation (on-line)
-@cindex Installation of on-line manual
-@cindex Generating the on-line manual
-@cindex On-line manual (how to generate)
-@cindex Info-file (how to generate)
-
-@enumerate
-@item
-Create the info file @file{pcl-cvs} from @file{pcl-cvs.texinfo} by
-typing @samp{make info}. If you don't have the program @samp{makeinfo}
-you can get it by anonymous ftp from e.g. @samp{ftp.gnu.ai.mit.edu} as
-@file{pub/gnu/texinfo-2.14.tar.Z} (there might be a newer version there
-when you read this), or you could use the preformatted info file
-@file{pcl-cvs.info} that is included in the distribution (type
-@samp{cp pcl-cvs.info pcl-cvs}).@refill
-
-@item
-Move the info file @file{pcl-cvs} to your standard info directory.
-This might be called something like @file{/usr/gnu/emacs/info}.@refill
-
-@item
-Edit the file @file{dir} in the info directory and enter one line to
-contain a pointer to the info file @file{pcl-cvs}. The line can, for
-instance, look like this:@refill
-
-@example
-* Pcl-cvs: (pcl-cvs). An Emacs front-end to CVS.
-@end example
-@end enumerate
-
-@node Typeset manual installation, , On-line manual installation, Installation
-@comment node-name, next, previous, up
-@section How to make typeset documentation from pcl-cvs.texinfo
-@cindex Manual installation (typeset)
-@cindex Installation of typeset manual
-@cindex Printing a manual
-@cindex TeX - generating a typeset manual
-@cindex Generating a typeset manual
-
-If you have @TeX{} installed at your site, you can make a typeset manual
-from @file{pcl-cvs.texinfo}.
-
-@enumerate
-@item
-Run @TeX{} by typing `@samp{make pcl-cvs.dvi}'. You will not get the
-indices unless you have the @code{texindex} program.
-
-@item
-Convert the resulting device independent file @file{pcl-cvs.dvi} to a
-form which your printer can output and print it. If you have a
-postscript printer there is a program, @code{dvi2ps}, which does. There
-is also a program which comes together with @TeX{}, @code{dvips}, which
-you can use.
-
-@end enumerate
-
-@node About pcl-cvs, Getting started, Installation, Top
-@comment node-name, next, previous, up
-@chapter About pcl-cvs
-@cindex About pcl-cvs
-
-Pcl-cvs is a front-end to CVS version 1.3. It integrates the most
-frequently used CVS commands into emacs.
-
-@menu
-* Contributors:: Contributors to pcl-cvs.
-* Archives:: Where can I get a copy of Pcl-Cvs?
-@end menu
-
-@node Contributors, Archives, About pcl-cvs, About pcl-cvs
-@comment node-name, next, previous, up
-@section Contributors to pcl-cvs
-@cindex Contributors
-@cindex Authors
-
-Contributions to the package are welcome. I have limited time to work
-on this project, but I will gladly add any code that you contribute to
-me to this package (@pxref{Reporting bugs and ideas}).
-
-The following persons have made contributions to pcl-cvs.
-
-@itemize @bullet
-@item
-Brian Berliner wrote CVS, together with some other contributors.
-Without his work on CVS this package would be useless@dots{}
-
-@item
-Per Cederqvist wrote most of the otherwise unattributed functions in
-pcl-cvs as well as all documentation.
-
-@item
-Inge Wallin (@samp{inge@@lysator.liu.se}) wrote the skeleton to
-@file{pcl-cvs.texinfo}, and gave useful comments on it. He also wrote
-the files @file{elib-node.el} and @file{compile-all.el}. The file
-@file{cookie.el} was inspired by Inge.@refill
-
-@item
-Linus Tolke (@samp{linus@@lysator.liu.se}) contributed useful comments
-on both the functionality and the documentation.@refill
-
-@end itemize
-
-
-@node Archives, , Contributors, About pcl-cvs
-@comment node-name, next, previous, up
-@section Where can I get pcl-cvs?
-@cindex Sites
-@cindex Archives
-@cindex Ftp-sites
-@cindex Getting pcl-cvs
-@cindex Email archives
-
-This release of pcl-cvs is included in the CVS 1.3 distribution.
-However, since pcl-cvs has had less time to mature (the first line of
-code was written less than a year ago) it is likely that there will be a
-new release of pcl-cvs before the next release of CVS.
-
-The latest release of pcl-cvs can be fetched via anonymous ftp from
-@code{ftp.lysator.liu.se}, (IP no. 130.236.254.1) in the directory
-@code{pub/emacs}. If you don't live in Scandinavia you should probably
-check with archie to see if there is a site closer to you that archives
-pcl-cvs.
-
-New releases will be announced to appropriate newsgroups. If you send
-your email address to me I will add you to my list of people to mail
-when I make a new release.
-
-@node Getting started, Buffer contents, About pcl-cvs, Top
-@comment node-name, next, previous, up
-@chapter Getting started
-@cindex Introduction
-@cindex Example run
-
-This document assumes that you know what CVS is, and that you at least
-knows the fundamental concepts of CVS. If that is not the case you
-should read the man page for CVS.
-
-Pcl-cvs is only useful once you have checked out a module. So before
-you invoke it you must have a copy of a module somewhere in the file
-system.
-
-You invoke pcl-cvs by typing @kbd{M-x pcl-cvs RET}. If your emacs
-responds with @samp{[No match]} your system administrator has not
-installed pcl-cvs properly. Try @kbd{M-x load-library RET pcl-cvs RET}.
-If that also fails - talk to your root. If it succeeds you might put
-this line in your @file{.emacs} file so that you don't have to type the
-@samp{load-library} command every time you wish to use pcl-cvs:
-
-@example
-(autoload 'cvs-update "pcl-cvs" nil t)
-@end example
-
-The function @code{cvs-update} will ask for a directory. The command
-@samp{cvs update} will be run in that directory. (It should contain
-files that have been checked out from a CVS archive.) The output from
-@code{cvs} will be parsed and presented in a table in a buffer called
-@samp{*cvs*}. It might look something like this:
-
-@example
-PCL-CVS release 1.02.
-@comment -release-
-
-In directory /users/ceder/FOO/test:
- Updated bar
- Updated file.txt
- Modified ci namechange
- Updated newer
-
-In directory /users/ceder/FOO/test/sub:
- Modified ci ChangeLog
----------- End -----
-@end example
-
-In this example the three files (@file{bar}, @file{file.txt} and
-@file{newer}) that are marked with @samp{Updated} have been copied from
-the CVS repository to @file{/users/ceder/FOO/test/} since someone else
-have checked in newer versions of them. Two files (@file{namechange}
-and @file{sub/ChangeLog}) have been modified locally, and needs to be
-checked in.
-
-You can move the cursor up and down in the buffer with @kbd{C-n} and
-@kbd{C-p} or @kbd{n} and @kbd{p}. If you press @kbd{c} on one of the
-@samp{Modified} files that file will be checked in to the CVS
-repository. @xref{Committing changes}. You can press @kbd{x} to get rid
-of the "uninteresting" files that have only been @samp{Updated} (and
-don't require any further action from you).@refill
-
-You can also easily get a @samp{diff} between your modified file and the
-base version that you started from, and you can get the output from
-@samp{cvs log} and @samp{cvs status} on the listed files simply by
-pressing a key (@pxref{Getting info about files}).
-
-@node Buffer contents, Commands, Getting started, Top
-@comment node-name, next, previous, up
-@chapter Buffer contents
-@cindex Buffer contents
-
-The display contains four columns. They contain, from left to right:
-
-@itemize @bullet
-@item
-An asterisk when the file is @dfn{marked} (@pxref{Selected
-files}).@refill
-@item
-The status of the file. See @xref{File status}, for more information.@refill
-@item
-A "need to be checked in"-marker (@samp{ci}).
-@item
-The file name.
-@end itemize
-
-@menu
-* File status:: The meaning of the second field.
-* Selected files:: How selection works.
-@end menu
-
-@node File status, Selected files, Buffer contents, Buffer contents
-@comment node-name, next, previous, up
-@section File status
-@cindex File status
-@cindex Updated (file status)
-@cindex Modified (file status)
-@cindex Merged (file status)
-@cindex Conflict (file status)
-@cindex Added (file status)
-@cindex Removed (file status)
-@cindex Unknown (file status)
-@cindex Removed from repository (file status)
-@cindex Removed from repository, changed by you (file status)
-@cindex Removed by you, changed in repository (file status)
-@cindex Move away @var{file} - it is in the way (file status)
-@cindex This repository is missing!@dots{} (file status)
-
-The @samp{file status} field can have the following values:
-
-@table @samp
-@item Updated
-The file was brought up to date with respect to the repository. This is
-done for any file that exists in the repository but not in your source,
-and for files that you haven't changed but are not the most recent
-versions available in the repository.@refill
-
-@item Modified
-The file is modified in your working directory, and there was no
-modification to the same file in the repository.@refill
-
-@item Merged
-The file is modified in your working directory, and there were
-modifications in the repository as well as in your copy, but they were
-merged successfully, without conflict, in your working directory.@refill
-
-@item Conflict
-A conflict was detected while trying to merge your changes to @var{file}
-with changes from the source repository. @var{file} (the copy in your
-working directory) is now the output of the @samp{rcsmerge} command on
-the two versions; an unmodified copy of your file is also in your
-working directory, with the name @file{.#@var{file}.@var{version}},
-where @var{version} is the RCS revision that your modified file started
-from. @xref{Viewing differences}, for more details.@refill
-
-@item Added
-The file has been added by you, but it still needs to be checked in to
-the repository.@refill
-
-@item Removed
-The file has been removed by you, but it needs to be checked in to the
-repository. You can resurrect it by typing @kbd{a} (@pxref{Adding and
-removing files}).@refill
-
-@item Unknown
-A file that was detected in your directory, but that neither appears in
-the repository, nor is present on the list of files that CVS should
-ignore.@refill
-
-@end table
-
-There are also a few special cases, that rarely occur, which have longer
-strings in the fields:
-
-@table @samp
-@item Removed from repository
-The file has been removed from your directory since someone has removed
-it from the repository. (It is still present in the Attic directory, so
-no permanent loss has occurred). This, unlike the other entries in this
-table, is not an error condition.@refill
-
-@item Removed from repository, changed by you
-You have modified a file that someone have removed from the repository.
-You can correct this situation by removing the file manually (see
-@pxref{Adding and removing files}).@refill
-
-@item Removed by you, changed in repository
-You have removed a file, and before you committed the removal someone
-committed a change to that file. You could use @kbd{a} to resurrect the
-file (see @pxref{Adding and removing files}).@refill
-
-@item Move away @var{file} - it is in the way
-For some reason CVS does not like the file @var{file}. Rename or remove
-it.@refill
-
-@item This repository is missing! Remove this dir manually.
-It is impossible to remove a directory in the CVS repository in a clean
-way. Someone have tried to remove one, and CVS gets confused. Remove
-your copy of the directory.@refill
-@end table
-
-@node Selected files, , File status, Buffer contents
-@comment node-name, next, previous, up
-@section Selected files
-@cindex Selected files
-@cindex Marked files
-@cindex File selection
-@cindex Active files
-
-Many of the commands works on the current set of @dfn{selected} files.
-
-@itemize @bullet
-@item
-If there are any files that are marked they constitute the set of
-selected files.@refill
-@item
-Otherwise, if the cursor points to a file, that file is the selected
-file.@refill
-@item
-Otherwise, if the cursor points to a directory, all the files in that
-directory that appears in the buffer are the selected files.
-@end itemize
-
-This scheme might seem a little complicated, but once one get used to
-it, it is quite powerful.
-
-@xref{Marking files} tells how you mark and unmark files.
-
-@node Commands, Customization, Buffer contents, Top
-@comment node-name, next, previous, up
-@chapter Commands
-
-@iftex
-This chapter describes all the commands that you can use in pcl-cvs.
-@end iftex
-@ifinfo
-The nodes in this menu contains explanations about all the commands that
-you can use in pcl-cvs. They are grouped together by type.
-@end ifinfo
-
-@menu
-* Updating the directory:: Commands to update the local directory
-* Movement commands:: How to move up and down in the buffer
-* Marking files:: How to mark files that other commands
- will later operate on.
-* Committing changes:: Checking in your modifications to the
- CVS repository.
-* Editing files:: Loading files into Emacs.
-* Getting info about files:: Display the log and status of files.
-* Adding and removing files:: Adding and removing files
-* Removing handled entries:: Uninteresting lines can easily be removed.
-* Ignoring files:: Telling CVS to ignore generated files.
-* Viewing differences:: Commands to @samp{diff} different versions.
-@end menu
-
-@node Updating the directory, Movement commands, Commands, Commands
-@comment node-name, next, previous, up
-@section Updating the directory
-@findex cvs-update
-@findex cvs-update-no-prompt
-@kindex g - Rerun @samp{cvs update}
-
-
-@table @kbd
-
-@item M-x cvs-update
-Run a @samp{cvs update} command. You will be asked for the directory in
-which the @samp{cvs update} will be run. The output will be parsed by
-pcl-cvs, and the result printed in the @samp{*cvs*} buffer (see
-@pxref{Buffer contents} for a description of the contents).@refill
-
-By default, @samp{cvs-update} will descend recursively into
-subdirectories. You can avoid that behavior by giving a prefix
-argument to it (e.g., by typing @kbd{C-u M-x cvs-update RET}).@refill
-
-All other commands in pcl-cvs requires that you have a @samp{*cvs*}
-buffer. This is the command that you use to get one.@refill
-
-@item g
-This will run @samp{cvs update} again. It will always use the same
-buffer that was used with the previous @samp{cvs update}. Give a prefix
-argument to avoid descending into subdirectories. This runs the command
-@samp{cvs-update-no-prompt}.@refill
-@end table
-@node Movement commands, Marking files, Updating the directory, Commands
-@comment node-name, next, previous, up
-@section Movement Commands
-@cindex Movement Commands
-@findex cookie-next-cookie
-@findex cookie-previous-cookie
-@kindex SPC - Move down one file
-@kindex C-n - Move down one file
-@kindex n - Move down one file
-@kindex C-p - Move up one file
-@kindex p - Move up on file
-
-You can use most normal Emacs commands to move forward and backward in
-the buffer. Some keys are rebound to functions that take advantage of
-the fact that the buffer is a pcl-cvs buffer:
-
-
-@table @kbd
-@item SPC
-@itemx C-n
-@itemx n
-These keys move the cursor one file forward, towards the end of the
-buffer (@code{cookie-next-cookie}).
-
-@item C-p
-@itemx p
-These keys move one file backward, towards the beginning of the buffer
-(@code{cookie-previous-cookie}).
-@end table
-
-@node Marking files, Committing changes, Movement commands, Commands
-@comment node-name, next, previous, up
-@section Marking files
-@cindex Selecting files (commands to mark files)
-@cindex Marking files
-@kindex m - marking a file
-@kindex M - marking all files
-@kindex u - unmark a file
-@kindex U - unmark all files
-@kindex DEL - unmark previous file
-@findex cvs-mark
-@findex cvs-unmark
-@findex cvs-mark-all-files
-@findex cvs-unmark-all-files
-@findex cvs-unmark-up
-
-Pcl-cvs works on a set of @dfn{selected files} (@pxref{Selected files}).
-You can mark and unmark files with these commands:
-
-@table @kbd
-@item m
-This marks the file that the cursor is positioned on. If the cursor is
-positioned on a directory all files in that directory will be marked.
-(@code{cvs-mark}).
-
-@item u
-Unmark the file that the cursor is positioned on. If the cursor is on a
-directory, all files in that directory will be unmarked.
-(@code{cvs-unmark}).@refill
-
-@item M
-Mark @emph{all} files in the buffer (@code{cvs-mark-all-files}).
-
-@item U
-Unmark @emph{all} files (@code{cvs-unmark-all-files}).
-
-@item @key{DEL}
-Unmark the file on the previous line, and move point to that line
-(@code{cvs-unmark-up}).
-@end table
-
-@node Committing changes, Editing files, Marking files, Commands
-@comment node-name, next, previous, up
-@section Committing changes
-@cindex Committing changes
-@cindex Ci
-@findex cvs-commit
-@kindex c - commit files
-@vindex cvs-erase-input-buffer (variable)
-@cindex Commit buffer
-@cindex Edit buffer
-@cindex Erasing commit message
-
-@table @kbd
-@item c
-All files that have a "need to be checked in"-marker (@pxref{Buffer
-contents}) can be checked in with the @kbd{c} command. It checks in all
-selected files (@pxref{Selected files}) (except those who lack the
-"ci"-marker - they are ignored). Pressing @kbd{c} causes
-@code{cvs-commit} to be run.@refill
-
-When you press @kbd{c} you will get a buffer called
-@samp{*cvs-commit-message*}. Enter the log message for the file(s) in
-it. When you are ready you should press @kbd{C-c C-c} to actually
-commit the files (using @code{cvs-edit-done}).
-
-Normally the @samp{*cvs-commit-message*} buffer will retain the log
-message from the previous commit, but if the variable
-@code{cvs-erase-input-buffer} is set to a non-nil value the buffer will
-be erased. Point and mark will always be located around the entire
-buffer so that you can easily erase it with @kbd{C-w}
-(@samp{kill-region}).@refill
-@end table
-
-@node Editing files, Getting info about files, Committing changes, Commands
-@comment node-name, next, previous, up
-@section Editing files
-
-@cindex Editing files
-@cindex Finding files
-@cindex Loading files
-@cindex Dired
-@cindex Invoking dired
-@findex cvs-find-file
-@findex cvs-find-file-other-window
-@findex cvs-add-change-log-entry-other-window
-@kindex f - find file or directory
-@kindex o - find file in other window
-@kindex A - add ChangeLog entry
-
-There are currently three commands that can be used to find a file (that
-is, load it into a buffer and start editing it there). These commands
-work on the line that the cursor is situated at. They ignore any marked
-files.
-
-@table @kbd
-@item f
-Find the file that the cursor points to. Run @samp{dired}
-@ifinfo
-(@pxref{Dired,,,Emacs})
-@end ifinfo
-if the cursor points to a directory (@code{cvs-find-file}).@refill
-
-@item o
-Like @kbd{f}, but use another window
-(@code{cvs-find-file-other-window}).@refill
-
-@item A
-Invoke @samp{add-change-log-entry-other-window} to edit a
-@samp{ChangeLog} file. The @samp{ChangeLog} will be found in the
-directory of the file the cursor points to.
-(@code{cvs-add-change-log-entry-other-window}).@refill
-@end table
-
-@node Getting info about files, Adding and removing files, Editing files, Commands
-@comment node-name, next, previous, up
-@section Getting info about files
-@cindex Status (cvs command)
-@cindex Log (RCS/cvs command)
-@cindex Getting status
-@kindex l - run @samp{cvs log}
-@kindex s - run @samp{cvs status}
-@findex cvs-log
-@findex cvs-status
-
-Both of the following commands can be customized.
-@xref{Customization}.@refill
-
-@table @kbd
-@item l
-Run @samp{cvs log} on all selected files, and show the result in a
-temporary buffer (@code{cvs-log}).
-
-@item s
-Run @samp{cvs status} on all selected files, and show the result in a
-temporary buffer (@code{cvs-status}).
-@end table
-
-@node Adding and removing files, Removing handled entries, Getting info about files, Commands
-@comment node-name, next, previous, up
-@section Adding and removing files
-@cindex Adding files
-@cindex Removing files
-@cindex Resurrecting files
-@cindex Deleting files
-@cindex Putting files under CVS control
-@kindex a - add a file
-@kindex r - remove a file
-@findex cvs-add
-@findex cvs-remove-file
-
-The following commands are available to make it easy to add and remove
-files from the CVS repository.
-
-@table @kbd
-@item a
-Add all selected files. This command can be used on @samp{Unknown}
-files (see @pxref{File status}). The status of the file will change to
-@samp{Added}, and you will have to use @kbd{c} (@samp{cvs-commit}, see
-@pxref{Committing changes}) to really add the file to the
-repository.@refill
-
-This command can also be used on @samp{Removed} files (before you commit
-them) to resurrect them.
-
-Selected files that are neither @samp{Unknown} nor @samp{Removed} will
-be ignored by this command.
-
-The command that is run is @code{cvs-add}.
-
-@item r
-This command removes the selected files (after prompting for
-confirmation). The files are @samp{rm}ed from your directory and
-(unless the status was @samp{Unknown}; @pxref{File status}) they will
-also be @samp{cvs remove}d. If the files were @samp{Unknown} they will
-disappear from the buffer. Otherwise their status will change to
-@samp{Removed}, and you must use @kbd{c} (@samp{cvs-commit},
-@pxref{Committing changes}) to commit the removal.@refill
-
-The command that is run is @code{cvs-remove-file}.
-@end table
-
-@node Removing handled entries, Ignoring files, Adding and removing files, Commands
-@comment node-name, next, previous, up
-@section Removing handled entries
-@cindex Expunging uninteresting entries
-@cindex Uninteresting entries, getting rid of them
-@cindex Getting rid of uninteresting lines
-@cindex Removing uninteresting (processed) lines
-@cindex Handled lines, removing them
-@kindex x - remove processed entries
-@kindex C-k - remove selected entries
-@findex cvs-remove-handled
-@findex cvs-acknowledge
-
-@table @kbd
-@item x
-This command allows you to remove all entries that you have processed.
-More specifically, the lines for @samp{Updated} files (@pxref{File
-status} and files that have been checked in (@pxref{Committing changes})
-are removed from the buffer. If a directory becomes empty the heading
-for that directory is also removed. This makes it easier to get an
-overview of what needs to be done.
-
-The command is called @code{cvs-remove-handled}. If
-@samp{cvs-auto-remove-handled} is set to non-@samp{nil} this will
-automatically be performed after every commit.@refill
-
-@item C-k
-This command can be used for lines that @samp{cvs-remove-handled} would
-not delete, but that you want to delete (@code{cvs-acknowledge}).
-@end table
-
-@node Ignoring files, Viewing differences, Removing handled entries, Commands
-@comment node-name, next, previous, up
-@section Ignoring files
-
-@table @kbd
-@item i
-Arrange so that CVS will ignore the selected files. The file names are
-added to the @file{.cvsignore} file in the corresponding directory. If
-the @file{.cvsignore} doesn't exist it will be created.
-
-The @file{.cvsignore} file should normally be added to the repository,
-but you could ignore it also if you like it better that way.
-
-This runs @code{cvs-ignore}.
-@end table
-
-@node Viewing differences, , Ignoring files, Commands
-@comment node-name, next, previous, up
-@section Viewing differences
-@cindex Diff
-@cindex Conflicts, how to resolve them
-@cindex Viewing differences
-@kindex d - run @samp{cvs diff}
-@kindex b - diff backup file
-@findex cvs-diff-cvs
-@findex cvs-diff-backup
-
-@table @kbd
-@item d
-Display a @samp{cvs diff} between the selected files and the RCS version
-that they are based on. @xref{Customization} describes how you can send
-flags to @samp{cvs diff}. (The function that does the job is
-@code{cvs-diff-cvs}).@refill
-
-@item b
-If CVS finds a conflict while merging two versions of a file (during a
-@samp{cvs update}, @pxref{Updating the directory}) it will save the
-original file in a file called @file{.#@var{FILE}.@var{VERSION}} where
-@var{FILE} is the name of the file, and @var{VERSION} is the RCS version
-number that your file was based on.
-
-With the @kbd{b} command you can run a @samp{diff} on the files
-@file{.#@var{FILE}.@var{VERSION}} and @file{@var{FILE}}. You can get a
-context- or Unidiff by setting @samp{cvs-diff-flags} -
-@pxref{Customization}. This command only works on files that have
-status @samp{Conflict} or @samp{Merged}. The name of the command is
-@code{cvs-diff-backup}. @refill
-@end table
-
-@node Customization, Future enhancements, Commands, Top
-@comment node-name, next, previous, up
-@chapter Customization
-@vindex cvs-erase-input-buffer (variable)
-@vindex cvs-inhibit-copyright-message (variable)
-@vindex cvs-cvs-diff-flags (variable)
-@vindex cvs-diff-flags (variable)
-@vindex cvs-log-flags (variable)
-@vindex cvs-status-flags (variable)
-@vindex cvs-auto-remove-handled (variable)
-@cindex Inhibiting the Copyright message.
-@cindex Copyright message, getting rid of it
-@cindex Getting rid of the Copyright message.
-@cindex Customization
-@cindex Variables, list of all
-@cindex Erasing the input buffer
-@cindex Context diff, how to get
-@cindex Unidiff, how to get
-@cindex Automatically remove handled files
-
-If you have an idea about any customization that would be handy but
-isn't present in this list, please tell me! @xref{Reporting bugs and
-ideas} for info on how to reach me.@refill
-
-@table @samp
-@item cvs-erase-input-buffer
-If set to anything else than @samp{nil} the edit buffer will be erased
-before you write the log message (@pxref{Committing changes}).
-
-@item cvs-inhibit-copyright-message
-The copyright message that is displayed on startup can be annoying after
-a while. Set this variable to @samp{t} if you want to get rid of it.
-(But don't set this to @samp{t} in the system defaults file - new users
-should see this message at least once).
-
-@item cvs-cvs-diff-flags
-A list of strings to pass as arguments to the @samp{cvs diff} program.
-This is used by @samp{cvs-diff-cvs} (key @kbd{d}, @pxref{Viewing
-differences}). If you prefer the Unidiff format you could add this line
-to your @file{.emacs} file:@refill
-
-@example
-(setq cvs-cvs-diff-flags '("-u"))
-@end example
-
-@item cvs-diff-flags
-Like @samp{cvs-cvs-diff-flags}, but passed to @samp{diff}. This is used
-by @samp{cvs-diff-backup} (key @kbd{b}, @pxref{Viewing differences}).
-
-@item cvs-log-flags
-List of strings to send to @samp{cvs log}. Used by @samp{cvs-log} (key
-@kbd{l}, @pxref{Getting info about files}).
-
-@item cvs-status-flags
-List of strings to send to @samp{cvs status}. Used by @samp{cvs-status}
-(key @kbd{s}, @pxref{Getting info about files}).
-
-@item cvs-auto-remove-handled
-If this variable is set to any non-@samp{nil} value
-@samp{cvs-remove-handled} will be called every time you check in files,
-after the check-in is ready. @xref{Removing handled entries}.@refill
-
-@end table
-@node Future enhancements, Reporting bugs and ideas, Customization, Top
-@comment node-name, next, previous, up
-@chapter Future enhancements
-@cindex Enhancements
-
-Pcl-cvs is still under development and needs a number of enhancements to
-be called complete. Here is my current wish-list for future releases of
-pcl-cvs:
-
-@itemize @bullet
-@item
-Dired support. I have an experimental @file{dired-cvs.el} that works
-together with CVS 1.2. Unfortunately I wrote it on top of a
-non-standard @file{dired.el}, so it must be rewritten.@refill
-
-@item
-It should be possible to run commands such as @samp{cvs log}, @samp{cvs
-status} and @samp{cvs commit} directly from a buffer containing a file,
-instead of having to @samp{cvs-update}. If the directory contains many
-files the @samp{cvs-update} can take quite some time, especially on a
-slow machine.
-@end itemize
-
-
-If you miss something in this wish-list, let me know! I don't promise
-that I will write it, but I will at least try to coordinate the efforts
-of making a good Emacs front end to CVS. See @xref{Reporting bugs and
-ideas} for information about how to reach me.@refill
-
-
-@node Reporting bugs and ideas, Function and Variable Index, Future enhancements, Top
-@comment node-name, next, previous, up
-@chapter Reporting bugs and ideas
-@cindex Reporting bugs and ideas
-@cindex Bugs, how to report them
-@cindex Author, how to reach
-@cindex Email to the author
-
-If you find a bug or misfeature, don't hesitate to tell me! Send email
-to @samp{ceder@@lysator.liu.se}.
-
-If you have ideas for improvements, or if you have written some
-extensions to this package, I would like to hear from you. I hope that
-you find this package useful!
-
-
-@node Function and Variable Index, Concept Index, Reporting bugs and ideas, Top
-@comment node-name, next, previous, up
-@unnumbered Function and Variable Index
-
-@printindex fn
-
-@node Concept Index, Key Index, Function and Variable Index, Top
-@comment node-name, next, previous, up
-@unnumbered Concept Index
-
-@printindex cp
-
-@node Key Index, , Concept Index, Top
-@comment node-name, next, previous, up
-@unnumbered Key Index
-
-@printindex ky
-
-@summarycontents
-@contents
-@bye
diff --git a/gnu/usr.bin/cvs/contrib/rcs-to-cvs b/gnu/usr.bin/cvs/contrib/rcs-to-cvs
deleted file mode 100644
index 1a241b9..0000000
--- a/gnu/usr.bin/cvs/contrib/rcs-to-cvs
+++ /dev/null
@@ -1,208 +0,0 @@
-#!/bin/csh
-#
-# rcs-to-cvs,v 1.3 1992/04/10 03:04:25 berliner Exp
-# Contributed by Per Cederqvist <ceder@lysator.liu.se>.
-#
-# Copyright (c) 1989, 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.0 kit.
-#
-#############################################################################
-# #
-# This script is used to check in sources that previously was under RCS or #
-# no source control system. #
-# #
-# Usage: rcs-to-cvs repository #
-# #
-# The repository is the directory where the sources should #
-# be deposited.
-# #
-# checkin traverses the current directory, ensuring that an #
-# identical directory structure exists in the repository directory. It #
-# then checks the files in in the following manner: #
-# #
-# 1) If the file doesn't yet exist, check it in #
-# as revision 0.1 #
-# #
-# The script also is somewhat verbose in letting the user know what is #
-# going on. It prints a diagnostic when it creates a new file, or updates #
-# a file that has been modified on the trunk. #
-# #
-#############################################################################
-
-set vbose = 0
-set message = ""
-set cvsbin = /usr/gnu/bin
-set rcsbin = /usr/gnu/bin
-set grep = /bin/grep
-set message_file = /usr/tmp/checkin.$$
-set got_one = 0
-
-if ( $#argv < 1 ) then
- echo "Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository"
- exit 1
-endif
-while ( $#argv )
- switch ( $argv[1] )
- case -v:
- set vbose = 1
- breaksw
- case -m:
- shift
- echo $argv[1] > $message_file
- set got_one = 1
- breaksw
- case -f:
- shift
- set message_file = $argv[1]
- set got_one = 2
- breaksw
- default:
- break
- endsw
- shift
-end
-if ( $#argv < 1 ) then
- echo "Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository"
- exit 1
-endif
-set repository = $argv[1]
-shift
-
-if ( ! $?CVSROOT ) then
- echo "Please set the environmental variable CVSROOT to the root"
- echo " of the tree you wish to update"
- exit 1
-endif
-
-if ( $got_one == 0 ) then
- echo "Please Edit this file to contain the RCS log information" >$message_file
- echo "to be associated with this file (please remove these lines)">>$message_file
- if ( $?EDITOR ) then
- $EDITOR $message_file > /dev/tty
- else
- /usr/ucb/vi $message_file > /dev/tty
- endif
- set got_one = 1
-endif
-
-umask 22
-
-set update_dir = ${CVSROOT}/${repository}
-if ( -d SCCS ) then
- echo SCCS files detected!
- exit 1
-endif
-if ( -d RCS ) then
- $rcsbin/co RCS/* >& /dev/null
-endif
-foreach name ( * .[a-zA-Z0-9]* )
- echo $name
- if ( "$name" == SCCS ) then
- continue
- endif
- if ( "$name" == RCS ) then
- continue
- endif
- if ( $vbose ) then
- echo "Updating ${repository}/${name}"
- endif
- if ( -d "$name" ) then
- if ( ! -d "${update_dir}/${name}" ) then
- echo "WARNING: Creating new directory ${repository}/${name}"
- mkdir "${update_dir}/${name}"
- if ( $status ) then
- echo "ERROR: mkdir failed - aborting"
- exit 1
- endif
- endif
- chdir "$name"
- if ( $status ) then
- echo "ERROR: Couldn\'t chdir to "$name" - aborting"
- exit 1
- endif
- if ( $vbose ) then
- rcs-to-cvs -v -f $message_file "${repository}/${name}"
- else
- rcs-to-cvs -f $message_file "${repository}/${name}"
- endif
- if ( $status ) then
- exit 1
- endif
- chdir ..
- else # if not directory
- if ( ! -f "$name" ) then
- echo "WARNING: "$name" is neither a regular file"
- echo " nor a directory - ignored"
- continue
- endif
- set file = "${update_dir}/${name},v"
- set new = 0
- set comment = ""
- grep -s '\$Log.*\$' "${name}"
- if ( $status == 0 ) then # If $Log keyword
- set myext = ${name:e}
- set knownext = 0
- foreach xx ( "c" "csh" "e" "f" "h" "l" "mac" "me" "mm" "ms" "p" "r" "red" "s" "sh" "sl" "cl" "ml" "el" "tex" "y" "ye" "yr" "" )
- if ( "${myext}" == "${xx}" ) then
- set knownext = 1
- break
- endif
- end
- if ( $knownext == 0 ) then
- echo For file ${file}:
- grep '\$Log.*\$' "${name}"
- echo -n "Please insert a comment leader for file ${name} > "
- set comment = $<
- endif
- endif
- if ( ! -f "$file" ) then # If not exists in repository
- if ( ! -f "${update_dir}/Attic/${name},v" ) then
- echo "WARNING: Creating new file ${repository}/${name}"
- if ( -f RCS/"${name}",v ) then
- echo "MSG: Copying old rcs file."
- cp RCS/"${name}",v "$file"
- else
- if ( "${comment}" != "" ) then
- $rcsbin/rcs -q -i -c"${comment}" -t${message_file} -m'.' "$file"
- endif
- $rcsbin/ci -q -u0.1 -t${message_file} -m'.' "$file"
- if ( $status ) then
- echo "ERROR: Initial check-in of $file failed - aborting"
- exit 1
- endif
- set new = 1
- endif
- else
- set file = "${update_dir}/Attic/${name},v"
- echo "WARNING: IGNORED: ${repository}/Attic/${name}"
- continue
- endif
- else # File existed
- echo ERROR: File exists: Ignored: "$file"
- continue
-# set headbranch = `sed -n '/^head/p; /^branch/p; 2q' $file`
-# if ( $#headbranch != 2 && $#headbranch != 4 ) then
-# echo "ERROR: corrupted RCS file $file - aborting"
-# endif
-# set head = "$headbranch[2]"
-# set branch = ""
-# if ( $#headbranch == 4 ) then
-# set branch = "$headbranch[4]"
-# endif
-# if ( "$head" == "1.1;" && "$branch" != "1.1.1;" ) then
-# ${rcsbin}/rcsdiff -q -r1.1 $file > /dev/null
-# if ( ! $status ) then
-# set new = 1
-# endif
-# else
-# if ( "$branch" != "1.1.1;" ) then
-# echo -n "WARNING: Updating locally modified file "
-# echo "${repository}/${name}"
-# endif
-# endif
- endif
- endif
-end
-if ( $got_one == 1 ) rm $message_file
diff --git a/gnu/usr.bin/cvs/contrib/rcslock.pl b/gnu/usr.bin/cvs/contrib/rcslock.pl
deleted file mode 100644
index db09b4b..0000000
--- a/gnu/usr.bin/cvs/contrib/rcslock.pl
+++ /dev/null
@@ -1,234 +0,0 @@
-#!/usr/bin/perl
-
-# Author: John Rouillard (rouilj@cs.umb.edu)
-# Supported: Yeah right. (Well what do you expect for 2 hours work?)
-# Blame-to: rouilj@cs.umb.edu
-# Complaints to: Anybody except Brian Berliner, he's blameless for
-# this script.
-# Acknowlegements: The base code for this script has been acquired
-# from the log.pl script.
-
-# rcslock.pl - A program to prevent commits when a file to be ckecked
-# in is locked in the repository.
-
-# There are times when you need exclusive access to a file. This
-# often occurs when binaries are checked into the repository, since
-# cvs's (actually rcs's) text based merging mechanism won't work. This
-# script allows you to use the rcs lock mechanism (rcs -l) to make
-# sure that no changes to a repository are able to be committed if
-# those changes would result in a locked file being changed.
-
-# WARNING:
-# This script will work only if locking is set to strict.
-#
-
-# Setup:
-# Add the following line to the commitinfo file:
-
-# ALL /local/location/for/script/lockcheck [options]
-
-# Where ALL is replaced by any suitable regular expression.
-# Options are -v for verbose info, or -d for debugging info.
-# The %s will provide the repository directory name and the names of
-# all changed files.
-
-# Use:
-# When a developer needs exclusive access to a version of a file, s/he
-# should use "rcs -l" in the repository tree to lock the version they
-# are working on. CVS will automagically release the lock when the
-# commit is performed.
-
-# Method:
-# An "rlog -h" is exec'ed to give info on all about to be
-# committed files. This (header) information is parsed to determine
-# if any locks are outstanding and what versions of the file are
-# locked. This filename, version number info is used to index an
-# associative array. All of the files to be committed are checked to
-# see if any locks are outstanding. If locks are outstanding, the
-# version number of the current file (taken from the CVS/Entries
-# subdirectory) is used in the key to determine if that version is
-# locked. If the file being checked in is locked by the person doing
-# the checkin, the commit is allowed, but if the lock is held on that
-# version of a file by another person, the commit is not allowed.
-
-$ext = ",v"; # The extension on your rcs files.
-
-$\="\n"; # I hate having to put \n's at the end of my print statements
-$,=' '; # Spaces should occur between arguments to print when printed
-
-# turn off setgid
-#
-$) = $(;
-
-#
-# parse command line arguments
-#
-require 'getopts.pl';
-
-&Getopts("vd"); # verbose or debugging
-
-# Verbose is useful when debugging
-$opt_v = $opt_d if defined $opt_d;
-
-# $files[0] is really the name of the subdirectory.
-# @files = split(/ /,$ARGV[0]);
-@files = @ARGV[0..$#ARGV];
-$cvsroot = $ENV{'CVSROOT'};
-
-#
-# get login name
-#
-$login = getlogin || (getpwuid($<))[0] || "nobody";
-
-#
-# save the current directory since we have to return here to parse the
-# CVS/Entries file if a lock is found.
-#
-$pwd = `/bin/pwd`;
-chop $pwd;
-
-print "Starting directory is $pwd" if defined $opt_d ;
-
-#
-# cd to the repository directory and check on the files.
-#
-print "Checking directory ", $files[0] if defined $opt_v ;
-
-if ( $files[0] =~ /^\// )
-{
- print "Directory path is $files[0]" if defined $opt_d ;
- chdir $files[0] || die "Can't change to repository directory $files[0]" ;
-}
-else
-{
- print "Directory path is $cvsroot/$files[0]" if defined $opt_d ;
- chdir ($cvsroot . "/" . $files[0]) ||
- die "Can't change to repository directory $files[0] in $cvsroot" ;
-}
-
-
-# Open the rlog process and apss all of the file names to that one
-# process to cut down on exec overhead. This may backfire if there
-# are too many files for the system buffer to handle, but if there are
-# that many files, chances are that the cvs repository is not set up
-# cleanly.
-
-print "opening rlog -h @files[1..$#files] |" if defined $opt_d;
-
-open( RLOG, "rlog -h @files[1..$#files] |") || die "Can't run rlog command" ;
-
-# Create the locks associative array. The elements in the array are
-# of two types:
-#
-# The name of the RCS file with a value of the total number of locks found
-# for that file,
-# or
-#
-# The name of the rcs file concatenated with the version number of the lock.
-# The value of this element is the name of the locker.
-
-# The regular expressions used to split the rcs info may have to be changed.
-# The current ones work for rcs 5.6.
-
-$lock = 0;
-
-while (<RLOG>)
-{
- chop;
- next if /^$/; # ditch blank lines
-
- if ( $_ =~ /^RCS file: (.*)$/ )
- {
- $curfile = $1;
- next;
- }
-
- if ( $_ =~ /^locks: strict$/ )
- {
- $lock = 1 ;
- next;
- }
-
- if ( $lock )
- {
- # access list: is the line immediately following the list of locks.
- if ( /^access list:/ )
- { # we are done getting lock info for this file.
- $lock = 0;
- }
- else
- { # We are accumulating lock info.
-
- # increment the lock count
- $locks{$curfile}++;
- # save the info on the version that is locked. $2 is the
- # version number $1 is the name of the locker.
- $locks{"$curfile" . "$2"} = $1
- if /[ ]*([a-zA-Z._]*): ([0-9.]*)$/;
-
- print "lock by $1 found on $curfile version $2" if defined $opt_d;
-
- }
- }
-}
-
-# Lets go back to the starting directory and see if any locked files
-# are ones we are interested in.
-
-chdir $pwd;
-
-# fo all of the file names (remember $files[0] is the directory name
-foreach $i (@files[1..$#files])
-{
- if ( defined $locks{$i . $ext} )
- { # well the file has at least one lock outstanding
-
- # find the base version number of our file
- &parse_cvs_entry($i,*entry);
-
- # is our version of this file locked?
- if ( defined $locks{$i . $ext . $entry{"version"}} )
- { # if so, it is by us?
- if ( $login ne ($by = $locks{$i . $ext . $entry{"version"}}) )
- {# crud somebody else has it locked.
- $outstanding_lock++ ;
- print "$by has file $i locked for version " , $entry{"version"};
- }
- else
- { # yeah I have it locked.
- print "You have a lock on file $i for version " , $entry{"version"}
- if defined $opt_v;
- }
- }
- }
-}
-
-exit $outstanding_lock;
-
-
-### End of main program
-
-sub parse_cvs_entry
-{ # a very simple minded hack at parsing an entries file.
-local ( $file, *entry ) = @_;
-local ( @pp );
-
-
-open(ENTRIES, "< CVS/Entries") || die "Can't open entries file";
-
-while (<ENTRIES>)
- {
- if ( $_ =~ /^\/$file\// )
- {
- @pp = split('/');
-
- $entry{"name"} = $pp[1];
- $entry{"version"} = $pp[2];
- $entry{"dates"} = $pp[3];
- $entry{"name"} = $pp[4];
- $entry{"name"} = $pp[5];
- $entry{"sticky"} = $pp[6];
- return;
- }
- }
-}
diff --git a/gnu/usr.bin/cvs/contrib/sccs2rcs b/gnu/usr.bin/cvs/contrib/sccs2rcs
deleted file mode 100644
index a208645..0000000
--- a/gnu/usr.bin/cvs/contrib/sccs2rcs
+++ /dev/null
@@ -1,277 +0,0 @@
-#!/bin/csh -f
-#
-# Sccs2rcs is a script to convert an existing SCCS
-# history into an RCS history without losing any of
-# the information contained therein.
-# It has been tested under the following OS's:
-# SunOS 3.5, 4.0.3, 4.1
-# Ultrix-32 2.0, 3.1
-#
-# Things to note:
-# + It will NOT delete or alter your ./SCCS history under any circumstances.
-#
-# + Run in a directory where ./SCCS exists and where you can
-# create ./RCS
-#
-# + /usr/local/bin is put in front of the default path.
-# (SCCS under Ultrix is set-uid sccs, bad bad bad, so
-# /usr/local/bin/sccs here fixes that)
-#
-# + Date, time, author, comments, branches, are all preserved.
-#
-# + If a command fails somewhere in the middle, it bombs with
-# a message -- remove what it's done so far and try again.
-# "rm -rf RCS; sccs unedit `sccs tell`; sccs clean"
-# There is no recovery and exit is far from graceful.
-# If a particular module is hanging you up, consider
-# doing it separately; move it from the current area so that
-# the next run will have a better chance or working.
-# Also (for the brave only) you might consider hacking
-# the s-file for simpler problems: I've successfully changed
-# the date of a delta to be in sync, then run "sccs admin -z"
-# on the thing.
-#
-# + After everything finishes, ./SCCS will be moved to ./old-SCCS.
-#
-# This file may be copied, processed, hacked, mutilated, and
-# even destroyed as long as you don't tell anyone you wrote it.
-#
-# Ken Cox
-# Viewlogic Systems, Inc.
-# kenstir@viewlogic.com
-# ...!harvard!cg-atla!viewlog!kenstir
-#
-# Various hacks made by Brian Berliner before inclusion in CVS contrib area.
-#
-# sccs2rcs,v 1.1 1992/04/10 03:04:26 berliner Exp
-
-
-#we'll assume the user set up the path correctly
-# for the Pmax, /usr/ucb/sccs is suid sccs, what a pain
-# /usr/local/bin/sccs should override /usr/ucb/sccs there
-set path = (/usr/local/bin $path)
-
-
-############################################################
-# Error checking
-#
-if (! -w .) then
- echo "Error: ./ not writeable by you."
- exit 1
-endif
-if (! -d SCCS) then
- echo "Error: ./SCCS directory not found."
- exit 1
-endif
-set edits = (`sccs tell`)
-if ($#edits) then
- echo "Error: $#edits file(s) out for edit...clean up before converting."
- exit 1
-endif
-if (-d RCS) then
- echo "Warning: RCS directory exists"
- if (`ls -a RCS | wc -l` > 2) then
- echo "Error: RCS directory not empty
- exit 1
- endif
-else
- mkdir RCS
-endif
-
-sccs clean
-
-set logfile = /tmp/sccs2rcs_$$_log
-rm -f $logfile
-set tmpfile = /tmp/sccs2rcs_$$_tmp
-rm -f $tmpfile
-set emptyfile = /tmp/sccs2rcs_$$_empty
-echo -n "" > $emptyfile
-set initialfile = /tmp/sccs2rcs_$$_init
-echo "Initial revision" > $initialfile
-set sedfile = /tmp/sccs2rcs_$$_sed
-rm -f $sedfile
-set revfile = /tmp/sccs2rcs_$$_rev
-rm -f $revfile
-
-# the quotes surround the dollar signs to fool RCS when I check in this script
-set sccs_keywords = (\
- '%W%[ ]*%G%'\
- '%W%[ ]*%E%'\
- '%W%'\
- '%Z%%M%[ ]*%I%[ ]*%G%'\
- '%Z%%M%[ ]*%I%[ ]*%E%'\
- '%M%[ ]*%I%[ ]*%G%'\
- '%M%[ ]*%I%[ ]*%E%'\
- '%M%'\
- '%I%'\
- '%G%'\
- '%E%'\
- '%U%')
-set rcs_keywords = (\
- '$'Id'$'\
- '$'Id'$'\
- '$'Id'$'\
- '$'SunId'$'\
- '$'SunId'$'\
- '$'Id'$'\
- '$'Id'$'\
- '$'RCSfile'$'\
- '$'Revision'$'\
- '$'Date'$'\
- '$'Date'$'\
- '')
-
-
-############################################################
-# Get some answers from user
-#
-echo ""
-echo "Do you want to be prompted for a description of each"
-echo "file as it is checked in to RCS initially?"
-echo -n "(y=prompt for description, n=null description) [y] ?"
-set ans = $<
-if ((_$ans == _) || (_$ans == _y) || (_$ans == _Y)) then
- set nodesc = 0
-else
- set nodesc = 1
-endif
-echo ""
-echo "The default keyword substitutions are as follows and are"
-echo "applied in the order specified:"
-set i = 1
-while ($i <= $#sccs_keywords)
-# echo ' '\"$sccs_keywords[$i]\"' ==> '\"$rcs_keywords[$i]\"
- echo " $sccs_keywords[$i] ==> $rcs_keywords[$i]"
- @ i = $i + 1
-end
-echo ""
-echo -n "Do you want to change them [n] ?"
-set ans = $<
-if ((_$ans != _) && (_$ans != _n) && (_$ans != _N)) then
- echo "You can't always get what you want."
- echo "Edit this script file and change the variables:"
- echo ' $sccs_keywords'
- echo ' $rcs_keywords'
-else
- echo "good idea."
-endif
-
-# create the sed script
-set i = 1
-while ($i <= $#sccs_keywords)
- echo "s,$sccs_keywords[$i],$rcs_keywords[$i],g" >> $sedfile
- @ i = $i + 1
-end
-
-onintr ERROR
-
-############################################################
-# Loop over every s-file in SCCS dir
-#
-foreach sfile (SCCS/s.*)
- # get rid of the "s." at the beginning of the name
- set file = `echo $sfile:t | sed -e "s/^..//"`
-
- # work on each rev of that file in ascending order
- set firsttime = 1
- sccs prs $file | grep "^D " | awk '{print $2}' | sed -e 's/\./ /g' | sort -n -u +0 +1 +2 +3 +4 +5 +6 +7 +8 | sed -e 's/ /./g' > $revfile
- foreach rev (`cat $revfile`)
- if ($status != 0) goto ERROR
-
- # get file into current dir and get stats
- set date = `sccs prs -r$rev $file | grep "^D " | awk '{printf("19%s %s", $3, $4); exit}'`
- set author = `sccs prs -r$rev $file | grep "^D " | awk '{print $5; exit}'`
- echo ""
- echo "==> file $file, rev=$rev, date=$date, author=$author"
- sccs edit -r$rev $file >>& $logfile
- if ($status != 0) goto ERROR
- echo checked out of SCCS
-
- # add RCS keywords in place of SCCS keywords
- sed -f $sedfile $file > $tmpfile
- if ($status != 0) goto ERROR
- echo performed keyword substitutions
- cp $tmpfile $file
-
- # check file into RCS
- if ($firsttime) then
- set firsttime = 0
- if ($nodesc) then
- echo about to do ci
- echo ci -f -r$rev -d"$date" -w$author -t$emptyfile $file
- ci -f -r$rev -d"$date" -w$author -t$emptyfile $file < $initialfile >>& $logfile
- if ($status != 0) goto ERROR
- echo initial rev checked into RCS without description
- else
- echo ""
- echo Enter a brief description of the file $file \(end w/ Ctrl-D\):
- cat > $tmpfile
- ci -f -r$rev -d"$date" -w$author -t$tmpfile $file < $initialfile >>& $logfile
- if ($status != 0) goto ERROR
- echo initial rev checked into RCS
- endif
- else
- # get RCS lock
- set lckrev = `echo $rev | sed -e 's/\.[0-9]*$//'`
- if ("$lckrev" =~ [0-9]*.*) then
- # need to lock the brach -- it is OK if the lock fails
- rcs -l$lckrev $file >>& $logfile
- else
- # need to lock the trunk -- must succeed
- rcs -l $file >>& $logfile
- if ($status != 0) goto ERROR
- endif
- echo got lock
- sccs prs -r$rev $file | grep "." > $tmpfile
- # it's OK if grep fails here and gives status == 1
- # put the delta message in $tmpfile
- ed $tmpfile >>& $logfile <<EOF
-/COMMENTS
-1,.d
-w
-q
-EOF
- ci -f -r$rev -d"$date" -w$author $file < $tmpfile >>& $logfile
- if ($status != 0) goto ERROR
- echo checked into RCS
- endif
- sccs unedit $file >>& $logfile
- if ($status != 0) goto ERROR
- end
- rm -f $file
-end
-
-
-############################################################
-# Clean up
-#
-echo cleaning up...
-mv SCCS old-SCCS
-rm -f $tmpfile $emptyfile $initialfile $sedfile
-echo ===================================================
-echo " Conversion Completed Successfully"
-echo ""
-echo " SCCS history now in old-SCCS/"
-echo ===================================================
-set exitval = 0
-goto cleanup
-
-ERROR:
-foreach f (`sccs tell`)
- sccs unedit $f
-end
-echo ""
-echo ""
-echo Danger\! Danger\!
-echo Some command exited with a non-zero exit status.
-echo Log file exists in $logfile.
-echo ""
-echo Incomplete history in ./RCS -- remove it
-echo Original unchanged history in ./SCCS
-set exitval = 1
-
-cleanup:
-# leave log file
-rm -f $tmpfile $emptyfile $initialfile $sedfile $revfile
-
-exit $exitval
diff --git a/gnu/usr.bin/cvs/cvs/Makefile b/gnu/usr.bin/cvs/cvs/Makefile
deleted file mode 100644
index 37ea28c0a..0000000
--- a/gnu/usr.bin/cvs/cvs/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-PROG = cvs
-CFLAGS += -I${.CURDIR}/../lib \
- -DDIRENT -DSTDC_HEADERS -DPOSIX -DBROKEN_SIGISMEMBER \
- -DFTIME_MISSING -DHAVE_TIMEZONE -DUTIME_NULL_MISSING -DDO_LINKS
-
-.if exists(${.CURDIR}/../lib/obj)
-LDADD= -L${.CURDIR}/../lib/obj -lcvs
-.else
-LDADD= -L${.CURDIR}/../lib/ -lcvs
-.endif
-
-SRCS = add.c admin.c checkin.c checkout.c classify.c commit.c \
-create_adm.c diff.c entries.c find_names.c history.c ignore.c \
-import.c lock.c log.c logmsg.c main.c rcs.c modules.c \
-no_diff.c parseinfo.c patch.c recurse.c release.c remove.c repos.c rtag.c \
-status.c tag.c update.c vers_ts.c version.c
-
-MAN1= cvs.1
-MAN5= cvs.5
-
-check:
- @echo `pwd` ${.CURDIR}
-
-.include <bsd.prog.mk>
-.include "../../Makefile.inc"
diff --git a/gnu/usr.bin/cvs/cvs/add.c b/gnu/usr.bin/cvs/cvs/add.c
deleted file mode 100644
index b4925bf..0000000
--- a/gnu/usr.bin/cvs/cvs/add.c
+++ /dev/null
@@ -1,447 +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.3 kit.
- *
- * Add
- *
- * Adds a file or directory to the RCS source repository. For a file,
- * the entry is marked as "needing to be added" in the user's own CVS
- * directory, and really added to the repository when it is committed.
- * For a directory, it is added at the appropriate place in the source
- * repository and a CVS directory is generated within the directory.
- *
- * The -m option is currently the only supported option. Some may wish to
- * supply standard "rcs" options here, but I've found that this causes more
- * trouble than anything else.
- *
- * The user files or directories must already exist. For a directory, it must
- * not already have a CVS file in it.
- *
- * An "add" on a file that has been "remove"d but not committed will cause the
- * file to be resurrected.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)add.c 1.46 92/04/03";
-#endif
-
-#if __STDC__
-static int add_directory (char *repository, char *dir);
-static int build_entry (char *repository, char *user, char *options,
- char *message, List * entries);
-#else
-static int add_directory ();
-static int build_entry ();
-#endif /* __STDC__ */
-
-static char *add_usage[] =
-{
- "Usage: %s %s [-k rcs-kflag] [-m message] files...\n",
- "\t-k\tUse \"rcs-kflag\" to add the file with the specified kflag.\n",
- "\t-m\tUse \"message\" for the creation log.\n",
- NULL
-};
-
-int
-add (argc, argv)
- int argc;
- char *argv[];
-{
- char message[MAXMESGLEN];
- char *user;
- int i;
- char *repository;
- int c;
- int err = 0;
- int added_files = 0;
- char *options = NULL;
- List *entries;
- Vers_TS *vers;
-
- if (argc == 1 || argc == -1)
- usage (add_usage);
-
- /* parse args */
- message[0] = '\0';
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "k:m:")) != -1)
- {
- switch (c)
- {
- case 'k':
- if (options)
- free (options);
- options = RCS_check_kflag (optarg);
- break;
-
- case 'm':
- if (strlen (optarg) >= sizeof (message))
- {
- error (0, 0, "warning: message too long; truncated!");
- (void) strncpy (message, optarg, sizeof (message));
- message[sizeof (message) - 1] = '\0';
- }
- else
- (void) strcpy (message, optarg);
- break;
- case '?':
- default:
- usage (add_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc <= 0)
- usage (add_usage);
-
- /* find the repository associated with our current dir */
- repository = Name_Repository ((char *) NULL, (char *) NULL);
- entries = ParseEntries (0);
-
- /* walk the arg list adding files/dirs */
- for (i = 0; i < argc; i++)
- {
- int begin_err = err;
-
- user = argv[i];
- if (index (user, '/') != NULL)
- {
- error (0, 0,
- "cannot add files with '/' in their name; %s not added", user);
- err++;
- continue;
- }
-
- vers = Version_TS (repository, options, (char *) NULL, (char *) NULL,
- user, 0, 0, entries, (List *) NULL);
- if (vers->vn_user == NULL)
- {
- /* No entry available, ts_rcs is invalid */
- if (vers->vn_rcs == NULL)
- {
- /* There is no RCS file either */
- if (vers->ts_user == NULL)
- {
- /* There is no user file either */
- error (0, 0, "nothing known about %s", user);
- err++;
- }
- else if (!isdir (user))
- {
- /*
- * See if a directory exists in the repository with
- * the same name. If so, blow this request off.
- */
- char dname[PATH_MAX];
- (void) sprintf (dname, "%s/%s", repository, user);
- if (isdir (dname))
- {
- error (0, 0,
- "cannot add file `%s' since the directory",
- user);
- error (0, 0, "`%s' already exists in the repository",
- dname);
- error (1, 0, "illegal filename overlap");
- }
-
- /* There is a user file, so build the entry for it */
- if (build_entry (repository, user, vers->options,
- message, entries) != 0)
- err++;
- else if (!quiet)
- {
- added_files++;
- error (0, 0, "scheduling file `%s' for addition",
- user);
- }
- }
- }
- else
- {
-
- /*
- * There is an RCS file already, so somebody else must've
- * added it
- */
- error (0, 0, "%s added independently by second party", user);
- err++;
- }
- }
- else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
- {
-
- /*
- * An entry for a new-born file, ts_rcs is dummy, but that is
- * inappropriate here
- */
- error (0, 0, "%s has already been entered", user);
- err++;
- }
- else if (vers->vn_user[0] == '-')
- {
- /* An entry for a removed file, ts_rcs is invalid */
- if (vers->ts_user == NULL)
- {
- /* There is no user file (as it should be) */
- if (vers->vn_rcs == NULL)
- {
-
- /*
- * There is no RCS file, so somebody else must've removed
- * it from under us
- */
- error (0, 0,
- "cannot resurrect %s; RCS file removed by second party", user);
- err++;
- }
- else
- {
-
- /*
- * There is an RCS file, so remove the "-" from the
- * version number and restore the file
- */
- char *tmp = xmalloc (strlen (user) + 50);
-
- (void) strcpy (tmp, vers->vn_user + 1);
- (void) strcpy (vers->vn_user, tmp);
- (void) sprintf (tmp, "Resurrected %s", user);
- Register (entries, user, vers->vn_user, tmp, vers->options,
- vers->tag, vers->date);
- free (tmp);
-
- /* XXX - bugs here; this really resurrect the head */
- if (update (2, argv + i - 1) == 0)
- {
- error (0, 0, "%s, version %s, resurrected", user,
- vers->vn_user);
- }
- else
- {
- error (0, 0, "could not resurrect %s", user);
- err++;
- }
- }
- }
- else
- {
- /* The user file shouldn't be there */
- error (0, 0, "%s should be removed and is still there (or is back again)", user);
- err++;
- }
- }
- else
- {
- /* A normal entry, ts_rcs is valid, so it must already be there */
- error (0, 0, "%s already exists, with version number %s", user,
- vers->vn_user);
- err++;
- }
- freevers_ts (&vers);
-
- /* passed all the checks. Go ahead and add it if its a directory */
- if (begin_err == err && isdir (user))
- {
- err += add_directory (repository, user);
- continue;
- }
- }
- if (added_files)
- error (0, 0, "use 'cvs commit' to add %s permanently",
- (added_files == 1) ? "this file" : "these files");
- dellist (&entries);
- return (err);
-}
-
-/*
- * The specified user file is really a directory. So, let's make sure that
- * it is created in the RCS source repository, and that the user's directory
- * is updated to include a CVS directory.
- *
- * Returns 1 on failure, 0 on success.
- */
-static int
-add_directory (repository, dir)
- char *repository;
- char *dir;
-{
- char cwd[PATH_MAX], rcsdir[PATH_MAX];
- char message[PATH_MAX + 100];
- char *tag, *date;
-
- if (index (dir, '/') != NULL)
- {
- error (0, 0,
- "directory %s not added; must be a direct sub-directory", dir);
- return (1);
- }
- if (strcmp (dir, CVSADM) == 0 || strcmp (dir, OCVSADM) == 0)
- {
- error (0, 0, "cannot add a `%s' or a `%s' directory", CVSADM, OCVSADM);
- return (1);
- }
-
- /* before we do anything else, see if we have any per-directory tags */
- ParseTag (&tag, &date);
-
- /* now, remember where we were, so we can get back */
- if (getwd (cwd) == NULL)
- {
- error (0, 0, "cannot get working directory: %s", cwd);
- return (1);
- }
- if (chdir (dir) < 0)
- {
- error (0, errno, "cannot chdir to %s", dir);
- return (1);
- }
- if (isfile (CVSADM) || isfile (OCVSADM))
- {
- error (0, 0,
- "%s/%s (or %s/%s) already exists", dir, CVSADM, dir, OCVSADM);
- goto out;
- }
-
- (void) sprintf (rcsdir, "%s/%s", repository, dir);
- if (isfile (rcsdir) && !isdir (rcsdir))
- {
- error (0, 0, "%s is not a directory; %s not added", rcsdir, dir);
- goto out;
- }
-
- /* setup the log message */
- (void) sprintf (message, "Directory %s added to the repository\n", rcsdir);
- if (tag)
- {
- (void) strcat (message, "--> Using per-directory sticky tag `");
- (void) strcat (message, tag);
- (void) strcat (message, "'\n");
- }
- if (date)
- {
- (void) strcat (message, "--> Using per-directory sticky date `");
- (void) strcat (message, date);
- (void) strcat (message, "'\n");
- }
-
- if (!isdir (rcsdir))
- {
- mode_t omask;
- char line[MAXLINELEN];
- Node *p;
- List *ulist;
-
- (void) printf ("Add directory %s to the repository (y/n) [n] ? ",
- rcsdir);
- (void) fflush (stdout);
- clearerr (stdin);
- if (fgets (line, sizeof (line), stdin) == NULL ||
- (line[0] != 'y' && line[0] != 'Y'))
- {
- error (0, 0, "directory %s not added", rcsdir);
- goto out;
- }
- omask = umask (2);
- if (mkdir (rcsdir, 0777) < 0)
- {
- error (0, errno, "cannot mkdir %s", rcsdir);
- (void) umask ((int) omask);
- goto out;
- }
- (void) umask ((int) omask);
-
- /*
- * Set up an update list with a single title node for Update_Logfile
- */
- ulist = getlist ();
- p = getnode ();
- p->type = UPDATE;
- p->delproc = update_delproc;
- p->key = xstrdup ("- New directory");
- p->data = (char *) T_TITLE;
- (void) addnode (ulist, p);
- Update_Logfile (rcsdir, message, (char *) NULL, (FILE *) NULL, ulist);
- dellist (&ulist);
- }
-
- Create_Admin (".", rcsdir, tag, date);
- if (tag)
- free (tag);
- if (date)
- free (date);
-
- (void) printf ("%s", message);
-out:
- if (chdir (cwd) < 0)
- error (1, errno, "cannot chdir to %s", cwd);
- return (0);
-}
-
-/*
- * Builds an entry for a new file and sets up "CVS/file",[pt] by
- * interrogating the user. Returns non-zero on error.
- */
-static int
-build_entry (repository, user, options, message, entries)
- char *repository;
- char *user;
- char *options;
- char *message;
- List *entries;
-{
- char fname[PATH_MAX];
- char line[MAXLINELEN];
- FILE *fp;
-
- /*
- * There may be an old file with the same name in the Attic! This is,
- * perhaps, an awkward place to check for this, but other places are
- * equally awkward.
- */
- (void) sprintf (fname, "%s/%s/%s%s", repository, CVSATTIC, user, RCSEXT);
- if (isreadable (fname))
- {
- error (0, 0, "there is an old file %s already in %s/%s", user,
- repository, CVSATTIC);
- return (1);
- }
-
- if (noexec)
- return (0);
-
- /*
- * The options for the "add" command are store in the file CVS/user,p
- */
- (void) sprintf (fname, "%s/%s%s", CVSADM, user, CVSEXT_OPT);
- fp = open_file (fname, "w+");
- if (fclose (fp) == EOF)
- error(1, errno, "cannot close %s", fname);
-
- /*
- * And the requested log is read directly from the user and stored in the
- * file user,t. If the "message" argument is set, use it as the
- * initial creation log (which typically describes the file).
- */
- (void) sprintf (fname, "%s/%s%s", CVSADM, user, CVSEXT_LOG);
- fp = open_file (fname, "w+");
- if (*message && fputs (message, fp) == EOF)
- error (1, errno, "cannot write to %s", fname);
- if (fclose(fp) == EOF)
- error(1, errno, "cannot close %s", fname);
-
- /*
- * Create the entry now, since this allows the user to interrupt us above
- * without needing to clean anything up (well, we could clean up the ,p
- * and ,t files, but who cares).
- */
- (void) sprintf (line, "Initial %s", user);
- Register (entries, user, "0", line, options, (char *) 0, (char *) 0);
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/admin.c b/gnu/usr.bin/cvs/cvs/admin.c
deleted file mode 100644
index 91d3929..0000000
--- a/gnu/usr.bin/cvs/cvs/admin.c
+++ /dev/null
@@ -1,124 +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.3 kit.
- *
- * Administration
- *
- * For now, this is basically a front end for rcs. All options are passed
- * directly on.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)admin.c 1.17 92/03/31";
-#endif
-
-#if __STDC__
-static Dtype admin_dirproc (char *dir, char *repos, char *update_dir);
-static int admin_fileproc (char *file, char *update_dir,
- char *repository, List *entries,
- List *srcfiles);
-#else
-static int admin_fileproc ();
-static Dtype admin_dirproc ();
-#endif /* __STDC__ */
-
-static char *admin_usage[] =
-{
- "Usage: %s %s rcs-options files...\n",
- NULL
-};
-
-static int ac;
-static char **av;
-
-int
-admin (argc, argv)
- int argc;
- char *argv[];
-{
- int err;
-
- if (argc <= 1)
- usage (admin_usage);
-
- /* skip all optional arguments to see if we have any file names */
- for (ac = 1; ac < argc; ac++)
- if (argv[ac][0] != '-')
- break;
- argc -= ac;
- av = argv + 1;
- argv += ac;
- ac--;
- if (ac == 0 || argc == 0)
- usage (admin_usage);
-
- /* start the recursion processor */
- err = start_recursion (admin_fileproc, (int (*) ()) NULL, admin_dirproc,
- (int (*) ()) NULL, argc, argv, 0,
- W_LOCAL, 0, 1, (char *) NULL, 1);
- return (err);
-}
-
-/*
- * Called to run "rcs" on a particular file.
- */
-/* ARGSUSED */
-static int
-admin_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- Vers_TS *vers;
- char *version;
- char **argv;
- int argc;
- int retcode = 0;
-
- vers = Version_TS (repository, (char *) NULL, (char *) NULL, (char *) NULL,
- file, 0, 0, entries, srcfiles);
-
- version = vers->vn_user;
- if (version == NULL)
- return (0);
- else if (strcmp (version, "0") == 0)
- {
- error (0, 0, "cannot admin newly added file `%s'", file);
- return (0);
- }
-
- run_setup ("%s%s", Rcsbin, RCS);
- for (argc = ac, argv = av; argc; argc--, argv++)
- run_arg (*argv);
- run_arg (vers->srcfile->path);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- {
- if (!quiet)
- error (0, retcode == -1 ? errno : 0,
- "%s failed for `%s'", RCS, file);
- return (1);
- }
- return (0);
-}
-
-/*
- * Print a warm fuzzy message
- */
-/* ARGSUSED */
-static Dtype
-admin_dirproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- if (!quiet)
- error (0, 0, "Administrating %s", update_dir);
- return (R_PROCESS);
-}
diff --git a/gnu/usr.bin/cvs/cvs/checkin.c b/gnu/usr.bin/cvs/cvs/checkin.c
deleted file mode 100644
index 14f7c05..0000000
--- a/gnu/usr.bin/cvs/cvs/checkin.c
+++ /dev/null
@@ -1,135 +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.3 kit.
- *
- * Check In
- *
- * Does a very careful checkin of the file "user", and tries not to spoil its
- * modification time (to avoid needless recompilations). When RCS ID keywords
- * get expanded on checkout, however, the modification time is updated and
- * there is no good way to get around this.
- *
- * Returns non-zero on error.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)checkin.c 1.40 92/03/31";
-#endif
-
-int
-Checkin (type, file, repository, rcs, rev, tag, message, entries)
- int type;
- char *file;
- char *repository;
- char *rcs;
- char *rev;
- char *tag;
- char *message;
- List *entries;
-{
- char fname[PATH_MAX];
- Vers_TS *vers;
-
- (void) printf ("Checking in %s;\n", file);
- (void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
-
- /*
- * Move the user file to a backup file, so as to preserve its
- * modification times, then place a copy back in the original file name
- * for the checkin and checkout.
- */
- if (!noexec)
- copy_file (file, fname);
-
- run_setup ("%s%s -f %s%s", Rcsbin, RCS_CI,
- rev ? "-r" : "", rev ? rev : "");
- run_args ("-m%s", message);
- run_arg (rcs);
-
- switch (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL))
- {
- case 0: /* everything normal */
-
- /*
- * The checkin succeeded, so now check the new file back out and
- * see if it matches exactly with the one we checked in. If it
- * does, just move the original user file back, thus preserving
- * the modes; otherwise, we have no recourse but to leave the
- * newly checkout file as the user file and remove the old
- * original user file.
- */
-
- /* XXX - make sure -k options are used on the co; and tag/date? */
- run_setup ("%s%s -q %s%s", Rcsbin, RCS_CO,
- rev ? "-r" : "", rev ? rev : "");
- run_arg (rcs);
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- xchmod (file, 1);
- if (xcmp (file, fname) == 0)
- rename_file (fname, file);
- else
- (void) unlink_file (fname);
-
- /*
- * If we want read-only files, muck the permissions here, before
- * getting the file time-stamp.
- */
- if (cvswrite == FALSE)
- xchmod (file, 0);
-
- /* for added files with symbolic tags, need to add the tag too */
- if (type == 'A' && tag && !isdigit (*tag))
- {
- run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, tag, rev);
- run_arg (rcs);
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
-
- /* re-register with the new data */
- vers = Version_TS (repository, (char *) NULL, tag, (char *) NULL,
- file, 1, 1, entries, (List *) NULL);
- if (strcmp (vers->options, "-V4") == 0)
- vers->options[0] = '\0';
- Register (entries, file, vers->vn_rcs, vers->ts_user, vers->options,
- vers->tag, vers->date);
- history_write (type, (char *) 0, vers->vn_rcs, file, repository);
- freevers_ts (&vers);
- break;
-
- case -1: /* fork failed */
- if (!noexec)
- error (1, errno, "could not check in %s -- fork failed", file);
- return (1);
-
- default: /* ci failed */
-
- /*
- * The checkin failed, for some unknown reason, so we restore the
- * original user file, print an error, and return an error
- */
- if (!noexec)
- {
- rename_file (fname, file);
- error (0, 0, "could not check in %s", file);
- }
- return (1);
- }
-
- /*
- * When checking in a specific revision, we may have locked the wrong
- * branch, so to be sure, we do an extra unlock here before
- * returning.
- */
- if (rev)
- {
- run_setup ("%s%s -q -u", Rcsbin, RCS);
- run_arg (rcs);
- (void) run_exec (RUN_TTY, RUN_TTY, DEVNULL, RUN_NORMAL);
- }
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/checkout.c b/gnu/usr.bin/cvs/cvs/checkout.c
deleted file mode 100644
index ad5a5b8..0000000
--- a/gnu/usr.bin/cvs/cvs/checkout.c
+++ /dev/null
@@ -1,718 +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.3 kit.
- *
- * Create Version
- *
- * "checkout" creates a "version" of an RCS repository. This version is owned
- * totally by the user and is actually an independent copy, to be dealt with
- * as seen fit. Once "checkout" has been called in a given directory, it
- * never needs to be called again. The user can keep up-to-date by calling
- * "update" when he feels like it; this will supply him with a merge of his
- * own modifications and the changes made in the RCS original. See "update"
- * for details.
- *
- * "checkout" can be given a list of directories or files to be updated and in
- * the case of a directory, will recursivley create any sub-directories that
- * exist in the repository.
- *
- * When the user is satisfied with his own modifications, the present version
- * can be committed by "commit"; this keeps the present version in tact,
- * usually.
- *
- * The call is cvs checkout [options] <module-name>...
- *
- * "checkout" creates a directory ./CVS, in which it keeps its administration,
- * in two files, Repository and Entries. The first contains the name of the
- * repository. The second contains one line for each registered file,
- * consisting of the version number it derives from, its time stamp at
- * derivation time and its name. Both files are normal files and can be
- * edited by the user, if necessary (when the repository is moved, e.g.)
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)checkout.c 1.67 92/04/10";
-#endif
-
-#if __STDC__
-static char *findslash (char *start, char *p);
-static int build_dirs_and_chdir (char *dir, char *prepath, char *realdir,
- int sticky);
-static int checkout_proc (int *pargc, char *argv[], char *where,
- char *mwhere, char *mfile, int shorten,
- int local_specified, char *omodule,
- char *msg);
-#else
-static int checkout_proc ();
-static char *findslash ();
-static int build_dirs_and_chdir ();
-#endif /* __STDC__ */
-
-static char *checkout_usage[] =
-{
- "Usage:\n %s %s [-ANPQcflnpqs] [-r rev | -D date] [-d dir] [-k kopt] modules...\n",
- "\t-A\tReset any sticky tags/date/kopts.\n",
- "\t-N\tDon't shorten module paths if -d specified.\n",
- "\t-P\tPrune empty directories.\n",
- "\t-Q\tReally quiet.\n",
- "\t-c\t\"cat\" the module database.\n",
- "\t-f\tForce a head revision match if tag/date not found.\n",
- "\t-l\tLocal directory only, not recursive\n",
- "\t-n\tDo not run module program (if any).\n",
- "\t-p\tCheck out files to standard output.\n",
- "\t-q\tSomewhat quiet.\n",
- "\t-s\tLike -c, but include module status.\n",
- "\t-r rev\tCheck out revision or tag. (implies -P)\n",
- "\t-D date\tCheck out revisions as of date. (implies -P)\n",
- "\t-d dir\tCheck out into dir instead of module name.\n",
- "\t-k kopt\tUse RCS kopt -k option on checkout.\n",
- "\t-j rev\tMerge in changes made between current revision and rev.\n",
- NULL
-};
-
-static char *export_usage[] =
-{
- "Usage: %s %s [-NPQflnq] [-r rev | -D date] [-d dir] module...\n",
- "\t-N\tDon't shorten module paths if -d specified.\n",
- "\t-Q\tReally quiet.\n",
- "\t-f\tForce a head revision match if tag/date not found.\n",
- "\t-l\tLocal directory only, not recursive\n",
- "\t-n\tDo not run module program (if any).\n",
- "\t-q\tSomewhat quiet.\n",
- "\t-r rev\tCheck out revision or tag. (implies -P)\n",
- "\t-D date\tCheck out revisions as of date. (implies -P)\n",
- "\t-d dir\tCheck out into dir instead of module name.\n",
- NULL
-};
-
-static int checkout_prune_dirs;
-static int force_tag_match = 1;
-static int pipeout;
-static int aflag;
-static char *options = NULL;
-static char *tag = NULL;
-static char *date = NULL;
-static char *join_rev1 = NULL;
-static char *join_rev2 = NULL;
-static char *preload_update_dir = NULL;
-
-int
-checkout (argc, argv)
- int argc;
- char *argv[];
-{
- register int i;
- int c;
- DBM *db;
- int cat = 0, err = 0, status = 0;
- int run_module_prog = 1;
- int local = 0;
- int shorten = -1;
- char *where = NULL;
- char *valid_options, **valid_usage;
-
- /*
- * A smaller subset of options are allowed for the export command, which
- * is essentially like checkout, except that it hard-codes certain
- * options to be on (like -kv) and takes care to remove the CVS directory
- * when it has done its duty
- */
- if (strcmp (command_name, "export") == 0)
- {
- valid_options = "Nnd:flRQqr:D:";
- valid_usage = export_usage;
- }
- else
- {
- valid_options = "ANnk:d:flRpQqcsr:D:j:P";
- valid_usage = checkout_usage;
- }
-
- if (argc == -1)
- usage (valid_usage);
-
- ign_setup ();
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, valid_options)) != -1)
- {
- switch (c)
- {
- case 'A':
- aflag = 1;
- break;
- case 'N':
- shorten = 0;
- break;
- case 'k':
- if (options)
- free (options);
- options = RCS_check_kflag (optarg);
- break;
- case 'n':
- run_module_prog = 0;
- break;
- case 'Q':
- really_quiet = 1;
- /* FALL THROUGH */
- case 'q':
- quiet = 1;
- break;
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case 'P':
- checkout_prune_dirs = 1;
- break;
- case 'p':
- pipeout = 1;
- run_module_prog = 0; /* don't run module prog when piping */
- noexec = 1; /* so no locks will be created */
- break;
- case 'c':
- cat = 1;
- break;
- case 'd':
- where = optarg;
- if (shorten == -1)
- shorten = 1;
- break;
- case 's':
- status = 1;
- break;
- case 'f':
- force_tag_match = 0;
- break;
- case 'r':
- tag = optarg;
- checkout_prune_dirs = 1;
- break;
- case 'D':
- date = Make_Date (optarg);
- checkout_prune_dirs = 1;
- break;
- case 'j':
- if (join_rev2)
- error (1, 0, "only two -j options can be specified");
- if (join_rev1)
- join_rev2 = optarg;
- else
- join_rev1 = optarg;
- break;
- case '?':
- default:
- usage (valid_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (shorten == -1)
- shorten = 0;
-
- if ((!(cat + status) && argc == 0) || ((cat + status) && argc != 0)
- || (tag && date))
- usage (valid_usage);
-
- if (where && pipeout)
- error (1, 0, "-d and -p are mutually exclusive");
-
- if (strcmp (command_name, "export") == 0)
- {
- if (!tag && !date)
- {
- error (0, 0, "must specify a tag or date");
- usage (valid_usage);
- }
- if (tag && isdigit (tag[0]))
- error (1, 0, "tag `%s' must be a symbolic tag", tag);
- options = RCS_check_kflag ("v");/* -kv must be on */
- }
-
- if (cat || status)
- {
- cat_module (status);
- return (0);
- }
- db = open_module ();
-
- /*
- * if we have more than one argument and where was specified, we make the
- * where, cd into it, and try to shorten names as much as possible.
- * Otherwise, we pass the where as a single argument to do_module.
- */
- if (argc > 1 && where != NULL)
- {
- char repository[PATH_MAX];
-
- (void) mkdir (where, 0777);
- if (chdir (where) < 0)
- error (1, errno, "cannot chdir to %s", where);
- preload_update_dir = xstrdup (where);
- where = (char *) NULL;
- if (!isfile (CVSADM) && !isfile (OCVSADM))
- {
- (void) sprintf (repository, "%s/%s", CVSroot, CVSNULLREPOS);
- if (!isfile (repository))
- (void) mkdir (repository, 0777);
- Create_Admin (".", repository, (char *) NULL, (char *) NULL);
- if (!noexec)
- {
- FILE *fp;
-
- fp = open_file (CVSADM_ENTSTAT, "w+");
- if (fclose(fp) == EOF)
- error(1, errno, "cannot close %s", CVSADM_ENTSTAT);
- }
- }
- }
-
- /*
- * if where was specified (-d) and we have not taken care of it already
- * with the multiple arg stuff, and it was not a simple directory name
- * but rather a path, we strip off everything but the last component and
- * attempt to cd to the indicated place. where then becomes simply the
- * last component
- */
- if (where != NULL && index (where, '/') != NULL)
- {
- char *slash;
-
- slash = rindex (where, '/');
- *slash = '\0';
-
- if (chdir (where) < 0)
- error (1, errno, "cannot chdir to %s", where);
-
- preload_update_dir = xstrdup (where);
-
- where = slash + 1;
- if (*where == '\0')
- where = NULL;
- }
-
- for (i = 0; i < argc; i++)
- err += do_module (db, argv[i], CHECKOUT, "Updating", checkout_proc,
- where, shorten, local, run_module_prog,
- (char *) NULL);
- close_module (db);
- return (err);
-}
-
-/*
- * process_module calls us back here so we do the actual checkout stuff
- */
-/* ARGSUSED */
-static int
-checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
- local_specified, omodule, msg)
- int *pargc;
- char *argv[];
- char *where;
- char *mwhere;
- char *mfile;
- int shorten;
- int local_specified;
- char *omodule;
- char *msg;
-{
- int err = 0;
- int which;
- char *cp;
- char *cp2;
- char repository[PATH_MAX];
- char xwhere[PATH_MAX];
- char *oldupdate = NULL;
- char *prepath;
- char *realdirs;
-
- /*
- * OK, so we're doing the checkout! Our args are as follows:
- * argc,argv contain either dir or dir followed by a list of files
- * where contains where to put it (if supplied by checkout)
- * mwhere contains the module name or -d from module file
- * mfile says do only that part of the module
- * shorten = TRUE says shorten as much as possible
- * omodule is the original arg to do_module()
- */
-
- /* set up the repository (maybe) for the bottom directory */
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
-
- /* save the original value of preload_update_dir */
- if (preload_update_dir != NULL)
- oldupdate = xstrdup (preload_update_dir);
-
- /* fix up argv[] for the case of partial modules */
- if (mfile != NULL)
- {
- char file[PATH_MAX];
-
- /* if mfile is really a path, straighten it out first */
- if ((cp = rindex (mfile, '/')) != NULL)
- {
- *cp = 0;
- (void) strcat (repository, "/");
- (void) strcat (repository, mfile);
-
- /*
- * Now we need to fill in the where correctly. if !shorten, tack
- * the rest of the path onto where if where is filled in
- * otherwise tack the rest of the path onto mwhere and make that
- * the where
- *
- * If shorten is enabled, we might use mwhere to set where if
- * nobody set it yet, so we'll need to setup mwhere as the last
- * component of the path we are tacking onto repository
- */
- if (!shorten)
- {
- if (where != NULL)
- (void) sprintf (xwhere, "%s/%s", where, mfile);
- else
- (void) sprintf (xwhere, "%s/%s", mwhere, mfile);
- where = xwhere;
- }
- else
- {
- char *slash;
-
- if ((slash = rindex (mfile, '/')) != NULL)
- mwhere = slash + 1;
- else
- mwhere = mfile;
- }
- mfile = cp + 1;
- }
-
- (void) sprintf (file, "%s/%s", repository, mfile);
- if (isdir (file))
- {
-
- /*
- * The portion of a module was a directory, so kludge up where to
- * be the subdir, and fix up repository
- */
- (void) strcpy (repository, file);
-
- /*
- * At this point, if shorten is not enabled, we make where either
- * where with mfile concatenated, or if where hadn't been set we
- * set it to mwhere with mfile concatenated.
- *
- * If shorten is enabled and where hasn't been set yet, then where
- * becomes mfile
- */
- if (!shorten)
- {
- if (where != NULL)
- (void) sprintf (xwhere, "%s/%s", where, mfile);
- else
- (void) sprintf (xwhere, "%s/%s", mwhere, mfile);
- where = xwhere;
- }
- else if (where == NULL)
- where = mfile;
- }
- else
- {
- int i;
-
- /*
- * The portion of a module was a file, so kludge up argv to be
- * correct
- */
- for (i = 1; i < *pargc; i++)/* free the old ones */
- free (argv[i]);
- argv[1] = xstrdup (mfile); /* set up the new one */
- *pargc = 2;
-
- /* where gets mwhere if where isn't set */
- if (where == NULL)
- where = mwhere;
- }
- }
-
- /*
- * if shorten is enabled and where isn't specified yet, we pluck the last
- * directory component of argv[0] and make it the where
- */
- if (shorten && where == NULL)
- {
- if ((cp = rindex (argv[0], '/')) != NULL)
- {
- (void) strcpy (xwhere, cp + 1);
- where = xwhere;
- }
- }
-
- /* if where is still NULL, use mwhere if set or the argv[0] dir */
- if (where == NULL)
- {
- if (mwhere)
- where = mwhere;
- else
- {
- (void) strcpy (xwhere, argv[0]);
- where = xwhere;
- }
- }
-
- if (preload_update_dir != NULL)
- {
- char tmp[PATH_MAX];
-
- (void) sprintf (tmp, "%s/%s", preload_update_dir, where);
- free (preload_update_dir);
- preload_update_dir = xstrdup (tmp);
- }
- else
- preload_update_dir = xstrdup (where);
-
- /*
- * At this point, where is the directory we want to build, repository is
- * the repository for the lowest level of the path.
- */
-
- /*
- * If we are sending everything to stdout, we can skip a whole bunch of
- * work from here
- */
- if (!pipeout)
- {
-
- /*
- * We need to tell build_dirs not only the path we want it to build,
- * but also the repositories we want it to populate the path with. To
- * accomplish this, we pass build_dirs a ``real path'' with valid
- * repositories and a string to pre-pend based on how many path
- * elements exist in where. Big Black Magic
- */
- prepath = xstrdup (repository);
- cp = rindex (where, '/');
- cp2 = rindex (prepath, '/');
- while (cp != NULL)
- {
- cp = findslash (where, cp - 1);
- cp2 = findslash (prepath, cp2 - 1);
- }
- *cp2 = '\0';
- realdirs = cp2 + 1;
-
- /*
- * build dirs on the path if necessary and leave us in the bottom
- * directory (where if where was specified) doesn't contain a CVS
- * subdir yet, but all the others contain CVS and Entries.Static
- * files
- */
- if (build_dirs_and_chdir (where, prepath, realdirs, *pargc <= 1) != 0)
- {
- error (0, 0, "ignoring module %s", omodule);
- free (prepath);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (1);
- }
-
- /* clean up */
- free (prepath);
-
- /* set up the repository (or make sure the old one matches) */
- if (!isfile (CVSADM) && !isfile (OCVSADM))
- {
- FILE *fp;
-
- if (!noexec && *pargc > 1)
- {
- Create_Admin (".", repository, (char *) NULL, (char *) NULL);
- fp = open_file (CVSADM_ENTSTAT, "w+");
- if (fclose(fp) == EOF)
- error(1, errno, "cannot close %s", CVSADM_ENTSTAT);
- }
- else
- Create_Admin (".", repository, tag, date);
- }
- else
- {
- char *repos;
-
- /* get the contents of the previously existing repository */
- repos = Name_Repository ((char *) NULL, preload_update_dir);
- if (strcmp (repository, repos) != 0)
- {
- error (0, 0, "existing repository %s does not match %s",
- repos, repository);
- error (0, 0, "ignoring module %s", omodule);
- free (repos);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (1);
- }
- free (repos);
- }
- }
-
- /*
- * If we are going to be updating to stdout, we need to cd to the
- * repository directory so the recursion processor can use the current
- * directory as the place to find repository information
- */
- if (pipeout)
- {
- if (chdir (repository) < 0)
- {
- error (0, errno, "cannot chdir to %s", repository);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (1);
- }
- which = W_REPOS;
- }
- else
- which = W_LOCAL | W_REPOS;
-
- if (tag != NULL || date != NULL)
- which |= W_ATTIC;
-
- /*
- * if we are going to be recursive (building dirs), go ahead and call the
- * update recursion processor. We will be recursive unless either local
- * only was specified, or we were passed arguments
- */
- if (!(local_specified || *pargc > 1))
- {
- if (strcmp (command_name, "export") != 0 && !pipeout)
- history_write ('O', preload_update_dir, tag ? tag : date, where,
- repository);
- err += do_update (0, (char **) NULL, options, tag, date,
- force_tag_match, 0 /* !local */ ,
- 1 /* update -d */ , aflag, checkout_prune_dirs,
- pipeout, which, join_rev1, join_rev2,
- preload_update_dir);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (err);
- }
-
- if (!pipeout)
- {
- int i;
- List *entries;
-
- /* we are only doing files, so register them */
- entries = ParseEntries (0);
- for (i = 1; i < *pargc; i++)
- {
- char line[MAXLINELEN];
- char *user;
- Vers_TS *vers;
-
- user = argv[i];
- vers = Version_TS (repository, options, tag, date, user,
- force_tag_match, 0, entries, (List *) NULL);
- if (vers->ts_user == NULL)
- {
- (void) sprintf (line, "Initial %s", user);
- Register (entries, user, vers->vn_rcs, line, vers->options,
- vers->tag, vers->date);
- }
- freevers_ts (&vers);
- }
- dellist (&entries);
- }
-
- /* Don't log "export", just regular "checkouts" */
- if (strcmp (command_name, "export") != 0 && !pipeout)
- history_write ('O', preload_update_dir, (tag ? tag : date), where,
- repository);
-
- /* go ahead and call update now that everything is set */
- err += do_update (*pargc - 1, argv + 1, options, tag, date,
- force_tag_match, local_specified, 1 /* update -d */,
- aflag, checkout_prune_dirs, pipeout, which, join_rev1,
- join_rev2, preload_update_dir);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (err);
-}
-
-static char *
-findslash (start, p)
- char *start;
- char *p;
-{
- while ((int) p >= (int) start && *p != '/')
- p--;
- if ((int) p < (int) start)
- return (NULL);
- else
- return (p);
-}
-
-/*
- * build all the dirs along the path to dir with CVS subdirs with appropriate
- * repositories and Entries.Static files
- */
-static int
-build_dirs_and_chdir (dir, prepath, realdir, sticky)
- char *dir;
- char *prepath;
- char *realdir;
- int sticky;
-{
- FILE *fp;
- char repository[PATH_MAX];
- char path[PATH_MAX];
- char path2[PATH_MAX];
- char *slash;
- char *slash2;
- char *cp;
- char *cp2;
-
- (void) strcpy (path, dir);
- (void) strcpy (path2, realdir);
- for (cp = path, cp2 = path2;
- (slash = index (cp, '/')) != NULL && (slash2 = index (cp2, '/')) != NULL;
- cp = slash + 1, cp2 = slash2 + 1)
- {
- *slash = '\0';
- *slash2 = '\0';
- (void) mkdir (cp, 0777);
- if (chdir (cp) < 0)
- {
- error (0, errno, "cannot chdir to %s", cp);
- return (1);
- }
- if (!isfile (CVSADM) && !isfile (OCVSADM) &&
- strcmp (command_name, "export") != 0)
- {
- (void) sprintf (repository, "%s/%s", prepath, path2);
- Create_Admin (".", repository, sticky ? (char *) NULL : tag,
- sticky ? (char *) NULL : date);
- if (!noexec)
- {
- fp = open_file (CVSADM_ENTSTAT, "w+");
- if (fclose(fp) == EOF)
- error(1, errno, "cannot close %s", CVSADM_ENTSTAT);
- }
- }
- *slash = '/';
- *slash2 = '/';
- }
- (void) mkdir (cp, 0777);
- if (chdir (cp) < 0)
- {
- error (0, errno, "cannot chdir to %s", cp);
- return (1);
- }
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/classify.c b/gnu/usr.bin/cvs/cvs/classify.c
deleted file mode 100644
index 318fab8..0000000
--- a/gnu/usr.bin/cvs/cvs/classify.c
+++ /dev/null
@@ -1,380 +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.3 kit.
- *
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)classify.c 1.11 92/03/31";
-#endif
-
-#if __STDC__
-static void sticky_ck (char *file, int aflag, Vers_TS * vers, List * entries);
-#else
-static void sticky_ck ();
-#endif /* __STDC__ */
-
-/*
- * Classify the state of a file
- */
-Ctype
-Classify_File (file, tag, date, options, force_tag_match, aflag, repository,
- entries, srcfiles, versp)
- char *file;
- char *tag;
- char *date;
- char *options;
- int force_tag_match;
- int aflag;
- char *repository;
- List *entries;
- List *srcfiles;
- Vers_TS **versp;
-{
- Vers_TS *vers;
- Ctype ret;
-
- /* get all kinds of good data about the file */
- vers = Version_TS (repository, options, tag, date, file,
- force_tag_match, 0, entries, srcfiles);
-
- if (vers->vn_user == NULL)
- {
- /* No entry available, ts_rcs is invalid */
- if (vers->vn_rcs == NULL)
- {
- /* there is no RCS file either */
- if (vers->ts_user == NULL)
- {
- /* there is no user file */
- if (!force_tag_match || !(vers->tag || vers->date))
- if (!really_quiet)
- error (0, 0, "nothing known about %s", file);
- ret = T_UNKNOWN;
- }
- else
- {
- /* there is a user file */
- if (!force_tag_match || !(vers->tag || vers->date))
- if (!really_quiet)
- error (0, 0, "use `cvs add' to create an entry for %s",
- file);
- ret = T_UNKNOWN;
- }
- }
- else
- {
- /* there is an rcs file */
-
- if (vers->ts_user == NULL)
- {
- /* There is no user file; needs checkout */
- ret = T_CHECKOUT;
- }
- else
- {
- /*
- * There is a user file; print a warning and add it to the
- * conflict list, only if it is indeed different from what we
- * plan to extract
- */
- if (No_Difference (file, vers, entries))
- {
- /* the files were different so it is a conflict */
- if (!really_quiet)
- error (0, 0, "move away %s; it is in the way", file);
- ret = T_CONFLICT;
- }
- else
- /* since there was no difference, still needs checkout */
- ret = T_CHECKOUT;
- }
- }
- }
- else if (strcmp (vers->vn_user, "0") == 0)
- {
- /* An entry for a new-born file; ts_rcs is dummy */
-
- if (vers->ts_user == NULL)
- {
- /*
- * There is no user file, but there should be one; remove the
- * entry
- */
- if (!really_quiet)
- error (0, 0, "warning: new-born %s has disappeared", file);
- ret = T_REMOVE_ENTRY;
- }
- else
- {
- /* There is a user file */
-
- if (vers->vn_rcs == NULL)
- /* There is no RCS file, added file */
- ret = T_ADDED;
- else
- {
- /*
- * There is an RCS file, so someone else must have checked
- * one in behind our back; conflict
- */
- if (!really_quiet)
- error (0, 0,
- "conflict: %s created independently by second party",
- file);
- ret = T_CONFLICT;
- }
- }
- }
- else if (vers->vn_user[0] == '-')
- {
- /* An entry for a removed file, ts_rcs is invalid */
-
- if (vers->ts_user == NULL)
- {
- char tmp[PATH_MAX];
-
- /* There is no user file (as it should be) */
-
- (void) sprintf (tmp, "-%s", vers->vn_rcs ? vers->vn_rcs : "");
-
- if (vers->vn_rcs == NULL)
- {
-
- /*
- * There is no RCS file; this is all-right, but it has been
- * removed independently by a second party; remove the entry
- */
- ret = T_REMOVE_ENTRY;
- }
- else if (strcmp (tmp, vers->vn_user) == 0)
-
- /*
- * The RCS file is the same version as the user file was, and
- * that's OK; remove it
- */
- ret = T_REMOVED;
- else
- {
-
- /*
- * The RCS file is a newer version than the removed user file
- * and this is definitely not OK; make it a conflict.
- */
- if (!really_quiet)
- error (0, 0,
- "conflict: removed %s was modified by second party",
- file);
- ret = T_CONFLICT;
- }
- }
- else
- {
- /* The user file shouldn't be there */
- if (!really_quiet)
- error (0, 0, "%s should be removed and is still there", file);
- ret = T_REMOVED;
- }
- }
- else
- {
- /* A normal entry, TS_Rcs is valid */
- if (vers->vn_rcs == NULL)
- {
- /* There is no RCS file */
-
- if (vers->ts_user == NULL)
- {
- /* There is no user file, so just remove the entry */
- if (!really_quiet)
- error (0, 0, "warning: %s is not (any longer) pertinent",
- file);
- ret = T_REMOVE_ENTRY;
- }
- else if (strcmp (vers->ts_user, vers->ts_rcs) == 0)
- {
-
- /*
- * The user file is still unmodified, so just remove it from
- * the entry list
- */
- if (!really_quiet)
- error (0, 0, "%s is no longer in the repository", file);
- ret = T_REMOVE_ENTRY;
- }
- else
- {
- /*
- * The user file has been modified and since it is no longer
- * in the repository, a conflict is raised
- */
- if (No_Difference (file, vers, entries))
- {
- /* they are different -> conflict */
- if (!really_quiet)
- error (0, 0,
- "conflict: %s is modified but no longer in the repository",
- file);
- ret = T_CONFLICT;
- }
- else
- {
- /* they weren't really different */
- if (!really_quiet)
- error (0, 0,
- "warning: %s is not (any longer) pertinent",
- file);
- ret = T_REMOVE_ENTRY;
- }
- }
- }
- else if (strcmp (vers->vn_rcs, vers->vn_user) == 0)
- {
- /* The RCS file is the same version as the user file */
-
- if (vers->ts_user == NULL)
- {
-
- /*
- * There is no user file, so note that it was lost and
- * extract a new version
- */
- if (strcmp (command_name, "update") == 0)
- if (!really_quiet)
- error (0, 0, "warning: %s was lost", file);
- ret = T_CHECKOUT;
- }
- else if (strcmp (vers->ts_user, vers->ts_rcs) == 0)
- {
-
- /*
- * The user file is still unmodified, so nothing special at
- * all to do -- no lists updated, unless the sticky -k option
- * has changed. If the sticky tag has changed, we just need
- * to re-register the entry
- */
- if (vers->entdata->options &&
- strcmp (vers->entdata->options, vers->options) != 0)
- ret = T_CHECKOUT;
- else
- {
- sticky_ck (file, aflag, vers, entries);
- ret = T_UPTODATE;
- }
- }
- else
- {
-
- /*
- * The user file appears to have been modified, but we call
- * No_Difference to verify that it really has been modified
- */
- if (No_Difference (file, vers, entries))
- {
-
- /*
- * they really are different; modified if we aren't
- * changing any sticky -k options, else needs merge
- */
-#ifdef XXX_FIXME_WHEN_RCSMERGE_IS_FIXED
- if (strcmp (vers->entdata->options ?
- vers->entdata->options : "", vers->options) == 0)
- ret = T_MODIFIED;
- else
- ret = T_NEEDS_MERGE;
-#else
- ret = T_MODIFIED;
- sticky_ck (file, aflag, vers, entries);
-#endif
- }
- else
- {
- /* file has not changed; check out if -k changed */
- if (strcmp (vers->entdata->options ?
- vers->entdata->options : "", vers->options) != 0)
- {
- ret = T_CHECKOUT;
- }
- else
- {
-
- /*
- * else -> note that No_Difference will Register the
- * file already for us, using the new tag/date. This
- * is the desired behaviour
- */
- ret = T_UPTODATE;
- }
- }
- }
- }
- else
- {
- /* The RCS file is a newer version than the user file */
-
- if (vers->ts_user == NULL)
- {
- /* There is no user file, so just get it */
-
- if (strcmp (command_name, "update") == 0)
- if (!really_quiet)
- error (0, 0, "warning: %s was lost", file);
- ret = T_CHECKOUT;
- }
- else if (strcmp (vers->ts_user, vers->ts_rcs) == 0)
- {
-
- /*
- * The user file is still unmodified, so just get it as well
- */
- ret = T_CHECKOUT;
- }
- else
- {
- if (No_Difference (file, vers, entries))
- /* really modified, needs to merge */
- ret = T_NEEDS_MERGE;
- else
- /* not really modified, check it out */
- ret = T_CHECKOUT;
- }
- }
- }
-
- /* free up the vers struct, or just return it */
- if (versp != (Vers_TS **) NULL)
- *versp = vers;
- else
- freevers_ts (&vers);
-
- /* return the status of the file */
- return (ret);
-}
-
-static void
-sticky_ck (file, aflag, vers, entries)
- char *file;
- int aflag;
- Vers_TS *vers;
- List *entries;
-{
- if (aflag || vers->tag || vers->date)
- {
- char *enttag = vers->entdata->tag;
- char *entdate = vers->entdata->date;
-
- if ((enttag && vers->tag && strcmp (enttag, vers->tag)) ||
- ((enttag && !vers->tag) || (!enttag && vers->tag)) ||
- (entdate && vers->date && strcmp (entdate, vers->date)) ||
- ((entdate && !vers->date) || (!entdate && vers->date)))
- {
- Register (entries, file, vers->vn_user, vers->ts_rcs,
- vers->options, vers->tag, vers->date);
- }
- }
-}
diff --git a/gnu/usr.bin/cvs/cvs/commit.c b/gnu/usr.bin/cvs/cvs/commit.c
deleted file mode 100644
index 1b2f3be..0000000
--- a/gnu/usr.bin/cvs/cvs/commit.c
+++ /dev/null
@@ -1,1229 +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.3 kit.
- *
- * Commit Files
- *
- * "commit" commits the present version to the RCS repository, AFTER
- * having done a test on conflicts.
- *
- * The call is: cvs commit [options] files...
- *
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)commit.c 1.84 92/03/31";
-#endif
-
-#if __STDC__
-static Dtype check_direntproc (char *dir, char *repos, char *update_dir);
-static int check_fileproc (char *file, char *update_dir, char *repository,
- List * entries, List * srcfiles);
-static int check_filesdoneproc (int err, char *repos, char *update_dir);
-static int checkaddfile (char *file, char *repository, char *tag);
-static Dtype commit_direntproc (char *dir, char *repos, char *update_dir);
-static int commit_dirleaveproc (char *dir, int err, char *update_dir);
-static int commit_fileproc (char *file, char *update_dir, char *repository,
- List * entries, List * srcfiles);
-static int commit_filesdoneproc (int err, char *repository, char *update_dir);
-static int finaladd (char *file, char *revision, char *tag, char *repository,
- List *entries);
-static int findmaxrev (Node * p);
-static int fsortcmp (Node * p, Node * q);
-static int lock_RCS (char *user, char *rcs, char *rev, char *repository);
-static int lock_filesdoneproc (int err, char *repository, char *update_dir);
-static int lockrcsfile (char *file, char *repository, char *rev);
-static int precommit_list_proc (Node * p);
-static int precommit_proc (char *repository, char *filter);
-static int remove_file (char *file, char *repository, char *tag,
- List *entries);
-static void fix_rcs_modes (char *rcs, char *user);
-static void fixaddfile (char *file, char *repository);
-static void fixbranch (char *file, char *repository, char *branch);
-static void unlockrcs (char *file, char *repository);
-static void ci_delproc (Node *p);
-static void locate_rcs (char *file, char *repository, char *rcs);
-#else
-static int fsortcmp ();
-static int lock_filesdoneproc ();
-static int check_fileproc ();
-static Dtype check_direntproc ();
-static int precommit_list_proc ();
-static int precommit_proc ();
-static int check_filesdoneproc ();
-static int commit_fileproc ();
-static int commit_filesdoneproc ();
-static Dtype commit_direntproc ();
-static int commit_dirleaveproc ();
-static int findmaxrev ();
-static int remove_file ();
-static int finaladd ();
-static void unlockrcs ();
-static void fixaddfile ();
-static void fixbranch ();
-static int checkaddfile ();
-static int lockrcsfile ();
-static int lock_RCS ();
-static void fix_rcs_modes ();
-static void ci_delproc ();
-static void locate_rcs ();
-#endif /* __STDC__ */
-
-struct commit_info
-{
- Ctype status; /* as returned from Classify_File() */
- char *rev; /* a numeric rev, if we know it */
- char *tag; /* any sticky tag, or -r option */
-};
-struct master_lists
-{
- List *ulist; /* list for Update_Logfile */
- List *cilist; /* list with commit_info structs */
-};
-
-static int got_message;
-static int run_module_prog = 1;
-static int aflag;
-static char *tag;
-static char *write_dirtag;
-static char *logfile;
-static List *mulist;
-static List *locklist;
-static char *message;
-
-static char *commit_usage[] =
-{
- "Usage: %s %s [-nRl] [-m msg | -f logfile] [-r rev] files...\n",
- "\t-n\tDo not run the module program (if any).\n",
- "\t-R\tProcess directories recursively.\n",
- "\t-l\tLocal directory only (not recursive).\n",
- "\t-f file\tRead the log message from file.\n",
- "\t-m msg\tLog message.\n",
- "\t-r rev\tCommit to this branch or trunk revision.\n",
- NULL
-};
-
-int
-commit (argc, argv)
- int argc;
- char *argv[];
-{
- int c;
- int err = 0;
- int local = 0;
-
- if (argc == -1)
- usage (commit_usage);
-
-#ifdef CVS_BADROOT
- /*
- * For log purposes, do not allow "root" to commit files. If you look
- * like root, but are really logged in as a non-root user, it's OK.
- */
- if (geteuid () == (uid_t) 0)
- {
- struct passwd *pw;
-
- if ((pw = (struct passwd *) getpwnam (getcaller ())) == NULL)
- error (1, 0, "you are unknown to this system");
- if (pw->pw_uid == (uid_t) 0)
- error (1, 0, "cannot commit files as 'root'");
- }
-#endif /* CVS_BADROOT */
-
- message = xmalloc (MAXMESGLEN + 1);
- message[0] = '\0'; /* Null message by default */
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "nlRm:f:r:")) != -1)
- {
- switch (c)
- {
- case 'n':
- run_module_prog = 0;
- break;
- case 'm':
-#ifdef FORCE_USE_EDITOR
- use_editor = TRUE;
-#else
- use_editor = FALSE;
-#endif
- if (strlen (optarg) >= (size_t) MAXMESGLEN)
- {
- error (0, 0, "warning: message too long; truncated!");
- (void) strncpy (message, optarg, MAXMESGLEN);
- message[MAXMESGLEN] = '\0';
- }
- else
- (void) strcpy (message, optarg);
- break;
- case 'r':
- if (tag)
- free (tag);
- tag = xstrdup (optarg);
- break;
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case 'f':
-#ifdef FORCE_USE_EDITOR
- use_editor = TRUE;
-#else
- use_editor = FALSE;
-#endif
- logfile = optarg;
- break;
- case '?':
- default:
- usage (commit_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- /* numeric specified revision means we ignore sticky tags... */
- if (tag && isdigit (*tag))
- {
- aflag = 1;
- /* strip trailing dots */
- while (tag[strlen (tag) - 1] == '.')
- tag[strlen (tag) - 1] = '\0';
- }
-
- /* some checks related to the "-f logfile" option */
- if (logfile)
- {
- int n, logfd;
-
- if (*message)
- error (1, 0, "cannot specify both a message and a log file");
-
- if ((logfd = open (logfile, O_RDONLY)) < 0 ||
- (n = read (logfd, message, MAXMESGLEN)) < 0)
- {
- error (1, errno, "cannot read log message from %s", logfile);
- }
- (void) close (logfd);
- message[n] = '\0';
- }
-
- /* XXX - this is not the perfect check for this */
- if (argc <= 0)
- write_dirtag = tag;
-
- /*
- * Run the recursion processor to find all the dirs to lock and lock all
- * the dirs
- */
- locklist = getlist ();
- err = start_recursion ((int (*) ()) NULL, lock_filesdoneproc,
- (Dtype (*) ()) NULL, (int (*) ()) NULL, argc,
- argv, local, W_LOCAL, aflag, 0, (char *) NULL, 0);
- sortlist (locklist, fsortcmp);
- if (Writer_Lock (locklist) != 0)
- error (1, 0, "lock failed - giving up");
-
- /*
- * Set up the master update list
- */
- mulist = getlist ();
-
- /*
- * Run the recursion processor to verify the files are all up-to-date
- */
- err = start_recursion (check_fileproc, check_filesdoneproc,
- check_direntproc, (int (*) ()) NULL, argc,
- argv, local, W_LOCAL, aflag, 0, (char *) NULL, 1);
- if (err)
- {
- Lock_Cleanup ();
- error (1, 0, "correct above errors first!");
- }
-
- /*
- * Run the recursion processor to commit the files
- */
- if (noexec == 0)
- err = start_recursion (commit_fileproc, commit_filesdoneproc,
- commit_direntproc, commit_dirleaveproc,
- argc, argv, local, W_LOCAL, aflag, 0,
- (char *) NULL, 1);
-
- /*
- * Unlock all the dirs and clean up
- */
- Lock_Cleanup ();
- dellist (&mulist);
- dellist (&locklist);
- return (err);
-}
-
-/*
- * compare two lock list nodes (for sort)
- */
-static int
-fsortcmp (p, q)
- Node *p, *q;
-{
- return (strcmp (p->key, q->key));
-}
-
-/*
- * Create a list of repositories to lock
- */
-/* ARGSUSED */
-static int
-lock_filesdoneproc (err, repository, update_dir)
- int err;
- char *repository;
- char *update_dir;
-{
- Node *p;
-
- p = getnode ();
- p->type = LOCK;
- p->key = xstrdup (repository);
- if (p->key == NULL || addnode (locklist, p) != 0)
- freenode (p);
- return (err);
-}
-
-/*
- * Check to see if a file is ok to commit and make sure all files are
- * up-to-date
- */
-/* ARGSUSED */
-static int
-check_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- Ctype status;
- char *xdir;
- Node *p;
- List *ulist, *cilist;
- Vers_TS *vers;
- struct commit_info *ci;
- int save_noexec, save_quiet, save_really_quiet;
-
- save_noexec = noexec;
- save_quiet = quiet;
- save_really_quiet = really_quiet;
- noexec = quiet = really_quiet = 1;
-
- /* handle specified numeric revision specially */
- if (tag && isdigit (*tag))
- {
- /* If the tag is for the trunk, make sure we're at the head */
- if (numdots (tag) < 2)
- {
- status = Classify_File (file, (char *) NULL, (char *) NULL,
- (char *) NULL, 1, aflag, repository,
- entries, srcfiles, &vers);
- if (status == T_UPTODATE)
- {
- freevers_ts (&vers);
- status = Classify_File (file, tag, (char *) NULL,
- (char *) NULL, 1, aflag, repository,
- entries, srcfiles, &vers);
- if (status == T_REMOVE_ENTRY)
- status = T_MODIFIED;
- }
- }
- else
- {
- char *xtag, *cp;
-
- /*
- * The revision is off the main trunk; make sure we're
- * up-to-date with the head of the specified branch.
- */
- xtag = xstrdup (tag);
- if ((numdots (xtag) & 1) != 0)
- {
- cp = rindex (xtag, '.');
- *cp = '\0';
- }
- status = Classify_File (file, xtag, (char *) NULL,
- (char *) NULL, 1, aflag, repository,
- entries, srcfiles, &vers);
- if ((status == T_REMOVE_ENTRY || status == T_CONFLICT)
- && (cp = rindex (xtag, '.')) != NULL)
- {
- /* pluck one more dot off the revision */
- *cp = '\0';
- freevers_ts (&vers);
- status = Classify_File (file, xtag, (char *) NULL,
- (char *) NULL, 1, aflag, repository,
- entries, srcfiles, &vers);
- if (status == T_UPTODATE || status == T_REMOVE_ENTRY)
- status = T_MODIFIED;
- }
- /* now, muck with vers to make the tag correct */
- free (vers->tag);
- vers->tag = xstrdup (tag);
- free (xtag);
- }
- }
- else
- status = Classify_File (file, tag, (char *) NULL, (char *) NULL,
- 1, 0, repository, entries, srcfiles, &vers);
- noexec = save_noexec;
- quiet = save_quiet;
- really_quiet = save_really_quiet;
-
- switch (status)
- {
- case T_CHECKOUT:
- case T_NEEDS_MERGE:
- case T_CONFLICT:
- case T_REMOVE_ENTRY:
- error (0, 0, "Up-to-date check failed for `%s'", file);
- freevers_ts (&vers);
- return (1);
- case T_MODIFIED:
- case T_ADDED:
- case T_REMOVED:
- /*
- * some quick sanity checks; if no numeric -r option specified:
- * - can't have a sticky date
- * - can't have a sticky tag that is not a branch
- * Also,
- * - if status is T_REMOVED, can't have a numeric tag
- * - if status is T_ADDED, rcs file must not exist
- * - if status is T_ADDED, can't have a non-trunk numeric rev
- */
- if (!tag || !isdigit (*tag))
- {
- if (vers->date)
- {
- error (0, 0,
- "cannot commit with sticky date for file `%s'",
- file);
- freevers_ts (&vers);
- return (1);
- }
- if (status == T_MODIFIED && vers->tag &&
- !RCS_isbranch (file, vers->tag, srcfiles))
- {
- error (0, 0,
- "sticky tag `%s' for file `%s' is not a branch",
- vers->tag, file);
- freevers_ts (&vers);
- return (1);
- }
- }
- if (status == T_REMOVED && vers->tag && isdigit (*vers->tag))
- {
- error (0, 0,
- "cannot remove file `%s' which has a numeric sticky tag of `%s'",
- file, vers->tag);
- freevers_ts (&vers);
- return (1);
- }
- if (status == T_ADDED)
- {
- char rcs[PATH_MAX];
-
- locate_rcs (file, repository, rcs);
- if (isreadable (rcs))
- {
- error (0, 0,
- "cannot add file `%s' when RCS file `%s' already exists",
- file, rcs);
- freevers_ts (&vers);
- return (1);
- }
- if (vers->tag && isdigit (*vers->tag) &&
- numdots (vers->tag) > 1)
- {
- error (0, 0,
- "cannot add file `%s' with revision `%s'; must be on trunk",
- file, vers->tag);
- freevers_ts (&vers);
- return (1);
- }
- }
-
- /* done with consistency checks; now, to get on with the commit */
- if (update_dir[0] == '\0')
- xdir = ".";
- else
- xdir = update_dir;
- if ((p = findnode (mulist, xdir)) != NULL)
- {
- ulist = ((struct master_lists *) p->data)->ulist;
- cilist = ((struct master_lists *) p->data)->cilist;
- }
- else
- {
- struct master_lists *ml;
-
- ulist = getlist ();
- cilist = getlist ();
- p = getnode ();
- p->key = xstrdup (xdir);
- p->type = UPDATE;
- ml = (struct master_lists *)
- xmalloc (sizeof (struct master_lists));
- ml->ulist = ulist;
- ml->cilist = cilist;
- p->data = (char *) ml;
- (void) addnode (mulist, p);
- }
-
- /* first do ulist, then cilist */
- p = getnode ();
- p->key = xstrdup (file);
- p->type = UPDATE;
- p->delproc = update_delproc;
- p->data = (char *) status;
- (void) addnode (ulist, p);
-
- p = getnode ();
- p->key = xstrdup (file);
- p->type = UPDATE;
- p->delproc = ci_delproc;
- ci = (struct commit_info *) xmalloc (sizeof (struct commit_info));
- ci->status = status;
- if (vers->tag)
- if (isdigit (*vers->tag))
- ci->rev = xstrdup (vers->tag);
- else
- ci->rev = RCS_whatbranch (file, vers->tag, srcfiles);
- else
- ci->rev = (char *) NULL;
- ci->tag = xstrdup (vers->tag);
- p->data = (char *) ci;
- (void) addnode (cilist, p);
- break;
- case T_UNKNOWN:
- error (0, 0, "nothing known about `%s'", file);
- freevers_ts (&vers);
- return (1);
- case T_UPTODATE:
- break;
- default:
- error (0, 0, "Unknown status 0x%x for `%s'", status, file);
- break;
- }
-
- freevers_ts (&vers);
- return (0);
-}
-
-/*
- * Print warm fuzzies while examining the dirs
- */
-/* ARGSUSED */
-static Dtype
-check_direntproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- if (!quiet)
- error (0, 0, "Examining %s", update_dir);
-
- return (R_PROCESS);
-}
-
-/*
- * Walklist proc to run pre-commit checks
- */
-static int
-precommit_list_proc (p)
- Node *p;
-{
- if (p->data == (char *) T_ADDED || p->data == (char *) T_MODIFIED)
- run_arg (p->key);
- return (0);
-}
-
-/*
- * Callback proc for pre-commit checking
- */
-static List *ulist;
-static int
-precommit_proc (repository, filter)
- char *repository;
- char *filter;
-{
- /* see if the filter is there, only if it's a full path */
- if (filter[0] == '/' && !isfile (filter))
- {
- error (0, errno, "cannot find pre-commit filter `%s'", filter);
- return (1); /* so it fails! */
- }
-
- run_setup ("%s %s", filter, repository);
- (void) walklist (ulist, precommit_list_proc);
- return (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY));
-}
-
-/*
- * Run the pre-commit checks for the dir
- */
-/* ARGSUSED */
-static int
-check_filesdoneproc (err, repos, update_dir)
- int err;
- char *repos;
- char *update_dir;
-{
- int n;
- Node *p;
-
- /* find the update list for this dir */
- p = findnode (mulist, update_dir);
- if (p != NULL)
- ulist = ((struct master_lists *) p->data)->ulist;
- else
- ulist = (List *) NULL;
-
- /* skip the checks if there's nothing to do */
- if (ulist == NULL || ulist->list->next == ulist->list)
- return (err);
-
- /* run any pre-commit checks */
- if ((n = Parse_Info (CVSROOTADM_COMMITINFO, repos, precommit_proc, 1)) > 0)
- {
- error (0, 0, "Pre-commit check failed");
- err += n;
- }
-
- return (err);
-}
-
-/*
- * Do the work of committing a file
- */
-static int maxrev;
-static char sbranch[PATH_MAX];
-
-/* ARGSUSED */
-static int
-commit_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- Node *p;
- int err = 0;
- List *ulist, *cilist;
- struct commit_info *ci;
- char rcs[PATH_MAX];
-
- if (update_dir[0] == '\0')
- p = findnode (mulist, ".");
- else
- p = findnode (mulist, update_dir);
-
- /*
- * if p is null, there were file type command line args which were
- * all up-to-date so nothing really needs to be done
- */
- if (p == NULL)
- return (0);
- ulist = ((struct master_lists *) p->data)->ulist;
- cilist = ((struct master_lists *) p->data)->cilist;
-
- /*
- * At this point, we should have the commit message unless we were called
- * with files as args from the command line. In that latter case, we
- * need to get the commit message ourselves
- */
- if (use_editor && !got_message)
- {
- got_message = 1;
- do_editor (update_dir, message, repository, ulist);
- }
-
- p = findnode (cilist, file);
- if (p == NULL)
- return (0);
-
- ci = (struct commit_info *) p->data;
- if (ci->status == T_MODIFIED)
- {
- if (lockrcsfile (file, repository, ci->rev) != 0)
- {
- unlockrcs (file, repository);
- return (1);
- }
- }
- else if (ci->status == T_ADDED)
- {
- if (checkaddfile (file, repository, ci->tag) != 0)
- {
- fixaddfile (file, repository);
- return (1);
- }
- }
-
- /*
- * Add the file for real
- */
- if (ci->status == T_ADDED)
- {
- char *xrev = (char *) NULL;
-
- if (ci->rev == NULL)
- {
- /* find the max major rev number in this directory */
- maxrev = 0;
- (void) walklist (entries, findmaxrev);
- if (maxrev == 0)
- maxrev = 1;
- xrev = xmalloc (20);
- (void) sprintf (xrev, "%d", maxrev);
- }
-
- /* XXX - an added file with symbolic -r should add tag as well */
- err = finaladd (file, ci->rev ? ci->rev : xrev, ci->tag,
- repository, entries);
- if (xrev)
- free (xrev);
- return (err);
- }
-
- if (ci->status == T_MODIFIED)
- {
- locate_rcs (file, repository, rcs);
- err = Checkin ('M', file, repository, rcs, ci->rev, ci->tag,
- message, entries);
- if (err != 0)
- {
- unlockrcs (file, repository);
- fixbranch (file, repository, sbranch);
- }
- }
-
- if (ci->status == T_REMOVED)
- err = remove_file (file, repository, ci->tag, entries);
-
- return (err);
-}
-
-/*
- * Log the commit and clean up the update list
- */
-/* ARGSUSED */
-static int
-commit_filesdoneproc (err, repository, update_dir)
- int err;
- char *repository;
- char *update_dir;
-{
- List *ulist, *cilist;
- char *xtag = (char *) NULL;
- Node *p;
-
- p = findnode (mulist, update_dir);
- if (p != NULL)
- {
- ulist = ((struct master_lists *) p->data)->ulist;
- cilist = ((struct master_lists *) p->data)->cilist;
- }
- else
- return (err);
-
- got_message = 0;
-
- /* see if we need to specify a per-directory or -r option tag */
- if (tag == NULL)
- ParseTag (&xtag, (char **) NULL);
-
- Update_Logfile (repository, message, tag ? tag : xtag, (FILE *) 0, ulist);
- dellist (&ulist);
- dellist (&cilist);
- if (xtag)
- free (xtag);
-
- if (err == 0 && run_module_prog)
- {
- char *cp;
- FILE *fp;
- char line[MAXLINELEN];
- char *repository;
-
- /* It is not an error if Checkin.prog does not exist. */
- if ((fp = fopen (CVSADM_CIPROG, "r")) != NULL)
- {
- if (fgets (line, sizeof (line), fp) != NULL)
- {
- if ((cp = rindex (line, '\n')) != NULL)
- *cp = '\0';
- repository = Name_Repository ((char *) NULL, update_dir);
- run_setup ("%s %s", line, repository);
- (void) printf ("%s %s: Executing '", program_name,
- command_name);
- run_print (stdout);
- (void) printf ("'\n");
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- free (repository);
- }
- (void) fclose (fp);
- }
- }
-
- return (err);
-}
-
-/*
- * Get the log message for a dir and print a warm fuzzy
- */
-/* ARGSUSED */
-static Dtype
-commit_direntproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- Node *p;
- List *ulist;
- char *real_repos;
-
- /* find the update list for this dir */
- p = findnode (mulist, update_dir);
- if (p != NULL)
- ulist = ((struct master_lists *) p->data)->ulist;
- else
- ulist = (List *) NULL;
-
- /* skip the files as an optimization */
- if (ulist == NULL || ulist->list->next == ulist->list)
- return (R_SKIP_FILES);
-
- /* print the warm fuzzy */
- if (!quiet)
- error (0, 0, "Committing %s", update_dir);
-
- /* get commit message */
- if (use_editor)
- {
- got_message = 1;
- real_repos = Name_Repository (dir, update_dir);
- do_editor (update_dir, message, real_repos, ulist);
- free (real_repos);
- }
- return (R_PROCESS);
-}
-
-/*
- * Process the post-commit proc if necessary
- */
-/* ARGSUSED */
-static int
-commit_dirleaveproc (dir, err, update_dir)
- char *dir;
- int err;
- char *update_dir;
-{
- /* update the per-directory tag info */
- if (err == 0 && write_dirtag != NULL)
- WriteTag ((char *) NULL, write_dirtag, (char *) NULL);
-
- return (err);
-}
-
-/*
- * find the maximum major rev number in an entries file
- */
-static int
-findmaxrev (p)
- Node *p;
-{
- char *cp;
- int thisrev;
- Entnode *entdata;
-
- entdata = (Entnode *) p->data;
- cp = index (entdata->version, '.');
- if (cp != NULL)
- *cp = '\0';
- thisrev = atoi (entdata->version);
- if (cp != NULL)
- *cp = '.';
- if (thisrev > maxrev)
- maxrev = thisrev;
- return (0);
-}
-
-/*
- * Actually remove a file by moving it to the attic
- * XXX - if removing a ,v file that is a relative symbolic link to
- * another ,v file, we probably should add a ".." component to the
- * link to keep it relative after we move it into the attic.
- */
-static int
-remove_file (file, repository, tag, entries)
- char *file;
- char *repository;
- char *tag;
- List *entries;
-{
- int omask;
- int retcode;
- char rcs[PATH_MAX];
- char tmp[PATH_MAX];
-
- locate_rcs (file, repository, rcs);
- if (tag)
- {
- /* a symbolic tag is specified; just remove the tag from the file */
- run_setup ("%s%s -q -N%s", Rcsbin, RCS, tag);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, DEVNULL, RUN_NORMAL)) != 0)
- {
- if (!quiet)
- error (0, retcode == -1 ? errno : 0,
- "failed to remove tag `%s' from `%s'", tag, rcs);
- return (1);
- }
- return (0);
- }
- else
- {
- /* no symbolic tag specified; really move it into the Attic */
- (void) sprintf (tmp, "%s/%s", repository, CVSATTIC);
- omask = umask (2);
- (void) mkdir (tmp, 0777);
- (void) umask (omask);
- (void) sprintf (tmp, "%s/%s/%s%s", repository, CVSATTIC, file, RCSEXT);
-
- if ((strcmp (rcs, tmp) == 0 || rename (rcs, tmp) != -1) ||
- (!isreadable (rcs) && isreadable (tmp)))
- {
- Scratch_Entry (entries, file);
- return (0);
- }
- }
- return (1);
-}
-
-/*
- * Do the actual checkin for added files
- */
-static int
-finaladd (file, rev, tag, repository, entries)
- char *file;
- char *rev;
- char *tag;
- char *repository;
- List *entries;
-{
- int ret;
- char tmp[PATH_MAX];
- char rcs[PATH_MAX];
-
- locate_rcs (file, repository, rcs);
- ret = Checkin ('A', file, repository, rcs, rev, tag,
- message, entries);
- if (ret == 0)
- {
- (void) sprintf (tmp, "%s/%s%s", CVSADM, file, CVSEXT_OPT);
- (void) unlink_file (tmp);
- (void) sprintf (tmp, "%s/%s%s", CVSADM, file, CVSEXT_LOG);
- (void) unlink_file (tmp);
- }
- else
- fixaddfile (file, repository);
- return (ret);
-}
-
-/*
- * Unlock an rcs file
- */
-static void
-unlockrcs (file, repository)
- char *file;
- char *repository;
-{
- char rcs[PATH_MAX];
- int retcode = 0;
-
- locate_rcs (file, repository, rcs);
- run_setup ("%s%s -q -u", Rcsbin, RCS);
- run_arg (rcs);
-
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "could not unlock %s", rcs);
-}
-
-/*
- * remove a partially added file. if we can parse it, leave it alone.
- */
-static void
-fixaddfile (file, repository)
- char *file;
- char *repository;
-{
- RCSNode *rcsfile;
- char rcs[PATH_MAX];
- int save_really_quiet;
-
- locate_rcs (file, repository, rcs);
- save_really_quiet = really_quiet;
- really_quiet = 1;
- if ((rcsfile = RCS_parsercsfile (rcs)) == NULL)
- (void) unlink_file (rcs);
- else
- freercsnode (&rcsfile);
- really_quiet = save_really_quiet;
-}
-
-/*
- * put the branch back on an rcs file
- */
-static void
-fixbranch (file, repository, branch)
- char *file;
- char *repository;
- char *branch;
-{
- char rcs[PATH_MAX];
- int retcode = 0;
-
- if (branch != NULL && branch[0] != '\0')
- {
- locate_rcs (file, repository, rcs);
- run_setup ("%s%s -q -b%s", Rcsbin, RCS, branch);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "cannot restore branch to %s for %s", branch, rcs);
- }
-}
-
-/*
- * do the initial part of a file add for the named file. if adding
- * with a tag, put the file in the Attic and point the symbolic tag
- * at the committed revision.
- */
-static int
-checkaddfile (file, repository, tag)
- char *file;
- char *repository;
- char *tag;
-{
- FILE *fp;
- char *cp;
- char rcs[PATH_MAX];
- char fname[PATH_MAX];
- int omask;
- int retcode = 0;
-
- if (tag)
- {
- (void) sprintf(rcs, "%s/%s", repository, CVSATTIC);
- omask = umask (2);
- (void) mkdir (rcs, 0777);
- (void) umask (omask);
- (void) sprintf (rcs, "%s/%s/%s%s", repository, CVSATTIC, file, RCSEXT);
- }
- else
- locate_rcs (file, repository, rcs);
-
- run_setup ("%s%s -i", Rcsbin, RCS);
- run_args ("-t%s/%s%s", CVSADM, file, CVSEXT_LOG);
- (void) sprintf (fname, "%s/%s%s", CVSADM, file, CVSEXT_OPT);
- fp = open_file (fname, "r");
- while (fgets (fname, sizeof (fname), fp) != NULL)
- {
- if ((cp = rindex (fname, '\n')) != NULL)
- *cp = '\0';
- if (*fname)
- run_arg (fname);
- }
- (void) fclose (fp);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- {
- error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "could not create %s", rcs);
- return (1);
- }
- fix_rcs_modes (rcs, file);
- return (0);
-}
-
-/*
- * Lock the rcs file ``file''
- */
-static int
-lockrcsfile (file, repository, rev)
- char *file;
- char *repository;
- char *rev;
-{
- char rcs[PATH_MAX];
-
- locate_rcs (file, repository, rcs);
- if (lock_RCS (file, rcs, rev, repository) != 0)
- return (1);
- else
- return (0);
-}
-
-/*
- * Attempt to place a lock on the RCS file; returns 0 if it could and 1 if it
- * couldn't. If the RCS file currently has a branch as the head, we must
- * move the head back to the trunk before locking the file, and be sure to
- * put the branch back as the head if there are any errors.
- */
-static int
-lock_RCS (user, rcs, rev, repository)
- char *user;
- char *rcs;
- char *rev;
- char *repository;
-{
- RCSNode *rcsfile;
- char *branch = NULL;
- int err = 0;
-
- /*
- * For a specified, numeric revision of the form "1" or "1.1", (or when
- * no revision is specified ""), definitely move the branch to the trunk
- * before locking the RCS file.
- *
- * The assumption is that if there is more than one revision on the trunk,
- * the head points to the trunk, not a branch... and as such, it's not
- * necessary to move the head in this case.
- */
- if (rev == NULL || (rev && isdigit (*rev) && numdots (rev) < 2))
- {
- if ((rcsfile = RCS_parsercsfile (rcs)) == NULL)
- {
- /* invalid rcs file? */
- err = 1;
- }
- else
- {
- /* rcsfile is valid */
- branch = xstrdup (rcsfile->branch);
- freercsnode (&rcsfile);
- if (branch != NULL)
- {
- run_setup ("%s%s -q -b", Rcsbin, RCS);
- run_arg (rcs);
- if (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL) != 0)
- {
- error (0, 0, "cannot change branch to default for %s",
- rcs);
- if (branch)
- free (branch);
- return (1);
- }
- }
- run_setup ("%s%s -q -l", Rcsbin, RCS);
- run_arg (rcs);
- err = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
- }
- else
- {
- run_setup ("%s%s -q -l%s", Rcsbin, RCS, rev ? rev : "");
- run_arg (rcs);
- (void) run_exec (RUN_TTY, RUN_TTY, DEVNULL, RUN_NORMAL);
- }
-
- if (err == 0)
- {
- if (branch)
- {
- (void) strcpy (sbranch, branch);
- free (branch);
- }
- else
- sbranch[0] = '\0';
- return (0);
- }
-
- /* try to restore the branch if we can on error */
- if (branch != NULL)
- fixbranch (user, repository, branch);
-
- if (branch)
- free (branch);
- return (1);
-}
-
-/*
- * Called when "add"ing files to the RCS respository, as it is necessary to
- * preserve the file modes in the same fashion that RCS does. This would be
- * automatic except that we are placing the RCS ,v file very far away from
- * the user file, and I can't seem to convince RCS of the location of the
- * user file. So we munge it here, after the ,v file has been successfully
- * initialized with "rcs -i".
- */
-static void
-fix_rcs_modes (rcs, user)
- char *rcs;
- char *user;
-{
- struct stat sb;
-
- if (stat (user, &sb) != -1)
- (void) chmod (rcs, (int) sb.st_mode & ~0222);
-}
-
-/*
- * free an UPDATE node's data (really nothing to do)
- */
-void
-update_delproc (p)
- Node *p;
-{
- p->data = (char *) NULL;
-}
-
-/*
- * Free the commit_info structure in p.
- */
-static void
-ci_delproc (p)
- Node *p;
-{
- struct commit_info *ci;
-
- ci = (struct commit_info *) p->data;
- if (ci->rev)
- free (ci->rev);
- if (ci->tag)
- free (ci->tag);
- free (ci);
-}
-
-/*
- * Find an RCS file in the repository.
- */
-static void
-locate_rcs (file, repository, rcs)
- char *file;
- char *repository;
- char *rcs;
-{
- (void) sprintf (rcs, "%s/%s%s", repository, file, RCSEXT);
- if (!isreadable (rcs))
- {
- (void) sprintf (rcs, "%s/%s/%s%s", repository, CVSATTIC, file, RCSEXT);
- if (!isreadable (rcs))
- (void) sprintf (rcs, "%s/%s%s", repository, file, RCSEXT);
- }
-}
diff --git a/gnu/usr.bin/cvs/cvs/config.h b/gnu/usr.bin/cvs/cvs/config.h
deleted file mode 100644
index b3bee5f..0000000
--- a/gnu/usr.bin/cvs/cvs/config.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/* @(#)config.h 1.19 92/03/31 */
-
-/*
- * 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.3 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
-
-/*
- * If, before installing this version of CVS, you were running RCS V4 AND you
- * are installing this CVS and RCS V5 and GNU diff 1.15 all at the same time,
- * you should turn on the following define. It only exists to try to do
- * reasonable things with your existing checked out files when you upgrade to
- * RCS V5, since the keyword expansion formats have changed with RCS V5.
- *
- * If you already have been running with RCS5, or haven't been running with CVS
- * yet at all, or are sticking with RCS V4 for now, leave the commented out.
- */
-#ifndef HAD_RCS4
-/* #define HAD_RCS4 */
-#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. If you are using the GNU
- * version of diff (version 1.15 or later), this should be "diff -a".
- *
- * NOTE: this program is only used for the ``patch'' sub-command. 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 "grep" program to execute when checking to see if a merged file had
- * any conflicts. This "grep" must support the "-s" option and a standard
- * regular expression as an argument. Specify a full pathname if your site
- * wants to use a particular grep.
- */
-#ifndef GREP
-#define GREP "grep"
-#endif
-
-/*
- * The "rm" program to execute when pruning directories that are not part of
- * a release. This "rm" must support the "-fr" options. Specify a full
- * pathname if your site wants to use a particular rm.
- */
-#ifndef RM
-#define RM "rm"
-#endif
-
-/*
- * The "sort" program to execute when displaying the module database. Specify
- * a full pathname if your site wants to use a particular sort.
- */
-#ifndef SORT
-#define SORT "sort"
-#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.
- *
- * 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
-
-/*
- * 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 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
-
-/*
- * The "cvs diff" command accepts all the single-character options that GNU
- * diff (1.15) accepts. Except -D. GNU diff uses -D as a way to put
- * cpp-style #define's around the output differences. CVS, by default, uses
- * -D to specify a free-form date (like "cvs diff -D '1 week ago'"). If
- * you would prefer that the -D option of "cvs diff" work like the GNU diff
- * option, then comment out this define.
- */
-#ifndef CVS_DIFFDATE
-#define CVS_DIFFDATE
-#endif
-
-/* 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
-
-/*
- * Some UNIX distributions don't include these in their stat.h Defined here
- * because "config.h" is always included last.
- */
-#ifndef S_IWRITE
-#define S_IWRITE 0000200 /* write permission, owner */
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 0000020 /* write permission, grougroup */
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 0000002 /* write permission, other */
-#endif
diff --git a/gnu/usr.bin/cvs/cvs/create_adm.c b/gnu/usr.bin/cvs/cvs/create_adm.c
deleted file mode 100644
index 911258e..0000000
--- a/gnu/usr.bin/cvs/cvs/create_adm.c
+++ /dev/null
@@ -1,100 +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.3 kit.
- *
- * Create Administration.
- *
- * Creates a CVS administration directory based on the argument repository; the
- * "Entries" file is prefilled from the "initrecord" argument.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)create_adm.c 1.24 92/03/31";
-#endif
-
-void
-Create_Admin (dir, repository, tag, date)
- char *dir;
- char *repository;
- char *tag;
- char *date;
-{
- FILE *fout;
- char *cp;
- char tmp[PATH_MAX];
-
- if (noexec)
- return;
-
- if (!isdir (repository))
- error (1, 0, "there is no repository %s", repository);
-
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM);
- else
- (void) strcpy (tmp, CVSADM);
-
- if (isfile (tmp))
- error (1, 0, "there is a version here already");
- else
- {
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, OCVSADM);
- else
- (void) strcpy (tmp, OCVSADM);
-
- if (isfile (tmp))
- error (1, 0, "there is a version here already");
- }
-
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM);
- else
- (void) strcpy (tmp, CVSADM);
- make_directory (tmp);
-
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
- else
- (void) strcpy (tmp, CVSADM_REP);
- fout = open_file (tmp, "w+");
- cp = repository;
- strip_path (cp);
-
-#ifdef RELATIVE_REPOS
- /*
- * If the Repository file is to hold a relative path, try to strip off
- * the leading CVSroot argument.
- */
- if (CVSroot != NULL)
- {
- char path[PATH_MAX];
-
- (void) sprintf (path, "%s/", CVSroot);
- if (strncmp (repository, path, strlen (path)) == 0)
- cp = repository + strlen (path);
- }
-#endif
-
- if (fprintf (fout, "%s\n", cp) == EOF)
- error (1, errno, "write to %s failed", tmp);
- if (fclose (fout) == EOF)
- error (1, errno, "cannot close %s", tmp);
-
- /* now, do the Entries file */
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
- else
- (void) strcpy (tmp, CVSADM_ENT);
- fout = open_file (tmp, "w+");
- if (fclose (fout) == EOF)
- error (1, errno, "cannot close %s", tmp);
-
- /* Create a new CVS/Tag file */
- WriteTag (dir, tag, date);
-}
diff --git a/gnu/usr.bin/cvs/cvs/cvs.1 b/gnu/usr.bin/cvs/cvs/cvs.1
deleted file mode 100644
index f0c648f..0000000
--- a/gnu/usr.bin/cvs/cvs/cvs.1
+++ /dev/null
@@ -1,1991 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id cvs.1,v 1.12 1992/04/10 03:05:16 berliner Exp
-.TH CVS 1 "\*(Dt"
-.\" Full space in nroff; half space in troff
-.de SP
-.if n .sp
-.if t .sp .5
-..
-.\" quoted command
-.de `
-.RB ` "\|\\$1\|" '\\$2
-..
-.SH "NAME"
-cvs \- Concurrent Versions System
-.SH "SYNOPSIS"
-.TP
-\fBcvs\fP [ \fIcvs_options\fP ]
-.I cvs_command
-[
-.I command_options
-] [
-.I command_args
-]
-.SH "DESCRIPTION"
-.IX "revision control system" "\fLcvs\fR"
-.IX cvs "" "\fLcvs\fP \- concurrent versions system"
-.IX "concurrent versions system \- \fLcvs\fP"
-.IX "release control system" "cvs command" "" "\fLcvs\fP \- concurrent versions system"
-.IX "source control system" "cvs command" "" "\fLcvs\fP \- concurrent versions system"
-.IX revisions "cvs command" "" "\fLcvs\fP \- source control"
-.B cvs
-is a front end to the
-.BR rcs ( 1 )
-revision control system which extends
-the notion of revision control from a collection of files in a single
-directory to a hierarchical collection of directories consisting of
-revision controlled files.
-These directories and files can be combined together to form a software
-release.
-.B cvs
-provides the functions necessary to manage these software releases and to
-control the concurrent editing of source files among multiple software
-developers.
-.SP
-.B cvs
-keeps a single copy of the master sources.
-This copy is called the source ``repository''; it contains all the
-information to permit extracting previous software releases at any
-time based on either a symbolic revision tag, or a date in the past.
-.SH "ESSENTIAL COMMANDS"
-.B cvs
-provides a rich variety of commands (\fIcvs_command\fP in the
-Synopsis), each of which often has a wealth of options, to satisfy the
-many needs of source management in distributed environments. However,
-you don't have to master every detail to do useful work with
-.BR cvs ;
-in fact, five commands are sufficient to use (and contribute to)
-the source repository.
-.TP
-\fBcvs checkout\fP \fImodules\fP\|.\|.\|.
-A necessary preliminary for most \fBcvs\fP work: creates your private
-copy of the source for \fImodules\fP (named collections of source; you
-can also use a path relative to the source repository here). You can
-work with this copy without interfering with others' work. At least
-one subdirectory level is always created.
-.TP
-.B cvs update
-Execute this command from \fIwithin\fP your private source
-directory when you wish to update your copies of source files from
-changes that other developers have made to the source in the
-repository.
-.TP
-\fBcvs add\fP \fIfile\fP\|.\|.\|.
-Use this command to enroll new files in \fBcvs\fP records of your
-working directory. The files will be added to the repository the next
-time you run
-.` "cvs commit".
-Note:
-You should use the
-.` "cvs import"
-command to bootstrap new sources into the source repository.
-.` "cvs add"
-is only used for new files to an already checked-out module.
-.TP
-\fBcvs remove\fP \fIfile\fP\|.\|.\|.
-Use this command (after erasing any files listed) to declare that you
-wish to eliminate files from the repository. The removal does not
-affect others until you run
-.` "cvs commit".
-.TP
-\fBcvs commit\fP \fIfile\fP\|.\|.\|.
-Use this command when you wish to ``publish'' your changes to other
-developers, by incorporating them in the source repository.
-.SH "OPTIONS"
-The
-.B cvs
-command line can include
-.IR cvs_options ,
-which apply to the overall
-.B cvs
-program; a
-.IR cvs_command ,
-which specifies a particular action on the source repository; and
-.I command_options
-and
-.I command_arguments
-to fully specify what the
-.I cvs_command
-will do.
-.SP
-.I Warning:
-you must be careful of precisely where you place options relative to the
-.IR cvs_command .
-The same option can mean different things depending on whether it
-is in the
-.I cvs_options
-position (to the left of a
-.B cvs
-command) or in the
-.I command_options
-position (to the right of a
-.B cvs
-command).
-.SP
-There are only two situations where you may omit
-.IR cvs_command :
-.` "cvs \-H"
-elicits a list of available commands, and
-.` "cvs \-v "
-displays version information on \fBcvs\fP itself.
-.SP
-.SH "CVS OPTIONS"
-Use these options to control the overall
-.B cvs
-program:
-.TP
-.B \-H
-Display usage information about the specified
-.I cvs_command
-(but do not actually execute the command). If you don't specify a
-command name,
-.` "cvs \-H"
-displays a summary of all the commands available.
-.TP
-.B \-Q
-Causes the command to be
-.I really
-quiet; the command will generate output only for serious problems.
-.TP
-.B \-q
-Causes the command to be somewhat quiet; informational messages, such
-as reports of recursion through subdirectories, are suppressed.
-.TP
-\fB\-b\fP \fIbindir\fP
-Use
-.I bindir
-as the directory where
-.SM RCS
-programs are located.
-Overrides the setting of the
-.SM RCSBIN
-environment variable.
-This value should be specified as an absolute pathname.
-.TP
-\fB\-d\fP \fICVS_root_directory\fP
-Use
-.I CVS_root_directory
-as the root directory pathname of the master
-.SM RCS
-source repository.
-Overrides the setting of the
-.SM CVSROOT
-environment variable.
-This value should be specified as an absolute pathname.
-.TP
-\fB\-e\fP \fIeditor\fP
-Use
-.I editor
-to enter revision log information.
-Overrides the setting of the
-.SM EDITOR
-environment variable.
-.TP
-.B \-l
-Do not log the
-.I cvs_command
-in the command history (but execute it anyway). See the description
-of the
-.B history
-command for information on command history.
-.TP
-.B \-n
-Do not change any files. Attempt to execute the
-.IR cvs_command ,
-but only to issue reports; do not remove, update, or merge any
-existing files, or create any new files.
-.TP
-.B \-t
-Trace program execution; display messages showing the steps of
-.B cvs
-activity. Particularly useful with
-.B \-n
-to explore the potential impact of an unfamiliar command.
-.TP
-.B \-r
-Makes new working files files read-only.
-Same effect as if the
-.SM CVSREAD
-environment variable is set.
-.TP
-.B \-v
-Displays version and copyright information for
-.BR cvs .
-.TP
-.B \-w
-Makes new working files read-write (default).
-Overrides the setting of the
-.SM CVSREAD
-environment variable.
-.SH "USAGE"
-Except when requesting general help with
-.` "cvs \-H",
-you must specify a
-.I cvs_command
-to
-.B cvs
-to select a specific release control function to perform.
-Each
-.B cvs
-command accepts its own collection of options and arguments.
-However, many options are available across several commands.
-You can display a usage summary for each command by specifying the
-.B \-H
-option with the command.
-.SH "CVS COMMAND SUMMARY"
-Here are brief descriptions of all the
-.B cvs
-commands:
-.TP
-.B add
-Add a new file or directory to the repository, pending a
-.` "cvs commit"
-on the same file.
-Can only be done from within sources created by a previous
-.` "cvs checkout"
-invocation.
-Use
-.` "cvs import"
-to place whole new hierarchies of sources under
-.B cvs
-control.
-(Does not directly affect repository; changes
-working directory.)
-.TP
-.B admin
-Execute
-.SM RCS
-control functions on the source repository. (Changes
-repository directly; uses working directory without changing it.)
-.TP
-.B checkout
-Make a working directory of source files for editing. (Creates or changes
-working directory.)
-.TP
-.B commit
-Apply to the source repository changes, additions, and deletions from your
-working directory. (Changes repository.)
-.TP
-.B diff
-Show differences between files in working directory and source
-repository, or between two revisions in source repository.
-(Does not change either repository or working directory.)
-.TP
-.B export
-Prepare copies of a set of source files for shipment off site.
-Differs from
-.` "cvs checkout"
-in that no
-.B cvs
-administrative directories are created (and therefore
-.` "cvs commit"
-cannot be executed from a directory prepared with
-.` "cvs export"),
-and a symbolic tag must be specified.
-(Does not change repository; creates directory similar to working
-directories).
-.TP
-.B history
-Show reports on
-.B cvs
-commands that you or others have executed on a particular file or
-directory in the source repository. (Does not change repository or
-working directory.) History logs are kept only if enabled by creation
-of the
-.` "$CVSROOT/CVSROOT/history"
-file; see
-.BR cvs ( 5 ).
-.TP
-.B import
-Incorporate a set of updates from off-site into the source repository,
-as a ``vendor branch''. (Changes repository.)
-.TP
-.B log
-Display
-.SM RCS
-log information.
-(Does not change repository or working directory.)
-.TP
-.B rdiff
-Prepare a collection of diffs as a patch file between two releases in
-the repository. (Does not change repository or working directory.)
-.TP
-.B release
-Cancel a
-.` "cvs checkout",
-abandoning any changes.
-(Can delete working directory; no effect on repository.)
-.TP
-.B remove
-Remove files from the source repository, pending a
-.` "cvs commit"
-on the same files. (Does not directly affect repository;
-changes working directory.)
-.TP
-.B rtag
-Explicitly specify a symbolic tag for particular revisions of files in the
-source repository. See also
-.` "cvs tag".
-(Changes repository directly; does not require or affect
-working directory.)
-.TP
-.B status
-Show current status of files: latest version, version in working
-directory, whether working version has been edited and, optionally,
-symbolic tags in the
-.SM RCS
-file. (Does not change
-repository or working directory.)
-.TP
-.B tag
-Specify a symbolic tag for files in the repository. Tags the revisions
-that were last synchronized with your working directory. (Changes
-repository directly; uses working directory without changing it.)
-.TP
-.B update
-Bring your working directory up to date with changes from the
-repository. Merges are performed automatically when possible; a
-warning is issued if manual resolution is required for conflicting
-changes. (Changes working directory; does not change repository.)
-.SH "COMMON COMMAND OPTIONS"
-This section describes the
-.I command_options
-that are available across several
-.B cvs
-commands. Not all commands support all of these options; each option
-is only supported for commands where it makes sense. However, when
-a command has one of these options you can count on the same meaning
-for the option as in other commands. (Other command
-options, which are listed with the individual commands, may have
-different meanings from one
-.B cvs
-command to another.)
-.I "Warning:"
-the
-.B history
-command is an exception;
-it supports many options that conflict
-even with these standard options.
-.TP
-\fB\-D\fP \fIdate_spec\fP
-Use the most recent revision no later than \fIdate_spec\fP (a single
-argument, date description specifying a date in the
-past). A wide variety of date formats are supported by the underlying
-.SM RCS
-facilities, similar to those described in
-.BR co ( 1 ),
-but not exactly the same.
-The \fIdate_spec\fP is interpreted as being in the local timezone, unless a
-specific timezone is specified.
-The specification is ``sticky'' when you use it to make a
-private copy of a source file; that is, when you get a working file
-using \fB\-D\fP, \fBcvs\fP records the date you
-specified, so that further updates in the same directory will use the
-same date (unless you explicitly override it; see the description of
-the \fBupdate\fP command).
-.B \-D
-is available with the
-.BR checkout ", " diff, ", " history ", " export ", "
-.BR rdiff ", " rtag ", and "
-.B update
-commands.
-Examples of valid date specifications include:
-.in +1i
-.ft B
-.nf
-1 month ago
-2 hours ago
-400000 seconds ago
-last year
-last Monday
-yesterday
-a fortnight ago
-3/31/92 10:00:07 PST
-January 23, 1987 10:05pm
-22:00 GMT
-.fi
-.ft P
-.in -1i
-.TP
-.B \-f
-When you specify a particular date or tag to \fBcvs\fP commands, they
-normally ignore files that do not contain the tag (or did not exist on
-the date) that you specified. Use the \fB\-f\fP option if you want
-files retrieved even when there is no match for the tag or date. (The
-most recent version is used in this situation.)
-.B \-f
-is available with these commands:
-.BR checkout ", " export ", "
-.BR rdiff ", " rtag ", and " update .
-.TP
-.B \-H
-Help; describe the options available for this command. This is the
-only option supported for
-.I all
-.B cvs
-commands.
-.TP
-\fB\-k\fP \fIkflag\fP
-Alter the default
-.SM RCS
-processing of keywords; all the
-.B \-k
-options described in
-.BR rcs ( 1 )
-are available. The \fB\-k\fP option is available with the
-.BR add ", " checkout ", " diff ", "
-.RB rdiff ", and " update
-commands. Your \fIkflag\fP specification is ``sticky'' when you use
-it to create a private copy of a source file; that is, when you use
-this option with the \fBcheckout\fP or \fBupdate\fP commands,
-\fBcvs\fP associates your selected \fIkflag\fP with the file, and
-continues to use it with future \fBupdate\fP commands on the same file
-until you specify otherwise.
-.TP
-.B \-l
-Local; run only in current working directory, rather than recurring through
-subdirectories. Available with the following commands:
-.BR checkout ", " commit ", " diff ", "
-.BR export ", " remove ", " rdiff ", " rtag ", "
-.BR status ", " tag ", and " update .
-.I Warning:
-this is not the same
-as the overall
-.` "cvs \-l"
-option, which you can specify to the
-.I left
-of a
-.B cvs
-command!
-.TP
-.B \-n
-Do
-.I not
-run any
-.BR checkout / commit / tag / update
-program. (A program can be specified to run on each of these
-activities, in the modules database; this option bypasses it.)
-Available with the
-.BR checkout ", " commit ", " export ", and "
-.B rtag
-commands.
-.I Warning:
-this is not the same
-as the overall
-.` "cvs \-n"
-option, which you can specify to the
-.I left
-of a
-.B cvs
-command!
-.TP
-.B \-P
-Prune (remove) directories that are empty after being updated, on
-.BR checkout ", or " update .
-Normally, an empty directory (one that is void of revision-controlled
-files) is left alone.
-Specifying
-.B \-P
-will cause these directories to be silently removed from your checked-out
-sources.
-This does not remove the directory from the repository, only from your
-checked out copy.
-Note that this option is implied by the
-.B \-r
-or
-.B \-D
-options of
-.BR checkout " and " export .
-.TP
-.B \-p
-Pipe the files retrieved from the repository to standard output,
-rather than writing them in the current directory. Available with the
-.BR checkout " and " update
-commands.
-.TP
-.B \-Q
-Causes the command to be
-.I really
-quiet; the command will generate output only for serious problems.
-Available with the following commands:
-.BR checkout ", " import ", " export ", "
-.BR rdiff ", " rtag ", "
-.BR tag ", and " update .
-.TP
-.B \-q
-Causes the command to be somewhat quiet; informational messages, such
-as reports of recursion through subdirectories, are suppressed.
-Available with the following commands:
-.BR checkout ", " import ", " export ", "
-.BR rtag ", "
-.BR tag ", and " update .
-.TP
-\fB\-r\fP \fItag\fP
-Use the revision specified by the
-.I tag
-argument instead of the default ``head'' revision. As well as
-arbitrary tags defined with the \fBtag\fP or \fBrtag\fP command, two
-special tags are always available:
-.` "HEAD"
-refers to the most
-recent version available in the repository, and
-.` "BASE"
-refers to the revision you last checked out into the current working
-directory.
-.SP
-The \fItag\fP specification is ``sticky'' when you use
-this option with
-.` "cvs checkout"
-or
-.` "cvs update"
-to
-make your own copy of a file: \fBcvs\fP remembers the \fItag\fP and
-continues to use it on future \fBupdate\fP commands, until you specify
-otherwise.
-.I tag
-can be either a symbolic or numeric tag, in
-.SM RCS
-fashion.
-Specifying the
-.B \-q
-option along with the
-.B \-r
-option is often useful, to suppress the warning messages when the
-.SM RCS
-file does not contain the specified tag.
-.B \-r
-is available with the
-.BR checkout ", " commit ", " diff ", "
-.BR history ", " export ", "
-.BR rdiff ", " rtag ", and " update
-commands.
-.I Warning:
-this is not the same
-as the overall
-.` "cvs \-r"
-option, which you can specify to the
-.I left
-of a
-.B cvs
-command!
-.SH "CVS COMMANDS"
-Here (finally) are details on all the
-.B cvs
-commands and the options each accepts. The summary lines at the top
-of each command's description highlight three kinds of things:
-.TP 1i
-\ \ \ \ Command Options and Arguments
-Special options are described in detail below; common command options
-may appear only in the summary line.
-.TP 1i
-\ \ \ \ Working Directory, or Repository?
-Some \fBcvs\fP commands require a working directory to operate; some
-require a repository. Also, some commands \fIchange\fP the
-repository, some change the working directory, and some change
-nothing.
-.TP 1i
-\ \ \ \ Synonyms
-Many commands have synonyms, which you may find easier to
-remember (or type) than the principal name.
-.PP
-.TP
-\fBadd\fP [\fB\-k\fP \fIkflag\fP] [\fB\-m '\fP\fImessage\fP\fB'\fP] \fIfiles.\|.\|.\fP
-.I Requires:
-repository, working directory.
-.br
-.I Changes:
-working directory.
-.br
-.I Synonym:
-.B new
-.br
-Use the
-.B add
-command to create a new file or directory in the
-.SM RCS
-source repository.
-The files or directories specified with
-.B add
-must already exist in the current directory (which must have been created
-with the
-.B checkout
-command).
-To add a whole new directory hierarchy to the source repository
-(for example, files received from a third-party vendor), use the
-.` "cvs import"
-command instead.
-.SP
-If the argument to
-.` "cvs add"
-refers to an immediate sub-directory, the directory is
-created at the correct place in the
-.SM RCS
-source repository, and the necessary
-.B cvs
-administration files are created in your working directory.
-If the directory already exists in the source repository,
-.` "cvs add"
-still creates the administration files in your version of the directory.
-This allows you to use
-.` "cvs add"
-to add a particular directory to your private sources even if
-someone else created that directory after your
-.B checkout
-of the sources. You can do the following:
-.SP
-.in +1i
-.ft B
-.nf
-example% mkdir new_directory
-example% cvs add new_directory
-example% cvs update new_directory
-.fi
-.ft P
-.in -1i
-.SP
-An alternate approach using
-.` "cvs update"
-might be:
-.SP
-.in +1i
-.ft B
-.nf
-example% cvs update -d new_directory
-.fi
-.ft P
-.in -1i
-.SP
-(To add \fIany available\fP new directories to your working directory, it's
-probably simpler to use
-.` "cvs checkout"
-or
-.` "cvs update -d".)
-.SP
-The added files are not placed in the
-.SM RCS
-source repository until you use
-.` "cvs commit"
-to make the change permanent.
-Doing a
-.` "cvs add"
-on a file that was removed with the
-.` "cvs remove"
-command will resurrect the file, if no
-.` "cvs commit"
-command intervened.
-.SP
-You will have the opportunity to specify a logging message, as usual,
-when you use
-.` "cvs commit"
-to make the new file permanent. If you'd like to have another
-logging message associated with just
-.I creation
-of the file (for example, to describe the file's purpose), you can
-specify it with the
-.` "\-m \fImessage\fP"
-option to the
-.B add
-command.
-.SP
-The
-.` "-k kflag"
-option specifies the default way that this
-file will be checked out.
-The
-.` "kflag"
-argument is stored in the
-.SM RCS
-file and can be changed with
-.` "cvs admin".
-Specifying
-.` "-ko"
-is useful for checking in binaries that
-shouldn't have the
-.SM RCS
-id strings expanded.
-.TP
-\fBadmin\fP [\fIrcs-options\fP] \fIfiles.\|.\|.\fP
-.I Requires:
-repository, working directory.
-.br
-.I Changes:
-repository.
-.br
-.I Synonym:
-.B rcs
-.br
-This is the
-.B cvs
-interface to assorted administrative
-.SM RCS
-facilities, documented in
-.BR rcs ( 1 ).
-.` "cvs admin"
-simply passes all its options and arguments to the
-.B rcs
-command; it does no filtering or other processing.
-This command does work recursively, however, so extreme care should be
-used.
-.TP
-\fBcheckout\fP [\fBoptions\fP] \fImodules\fP.\|.\|.
-.I Requires:
-repository.
-.br
-.I Changes:
-working directory.
-.br
-.I Synonyms:
-.BR co ", " get
-.br
-Make a working directory containing copies of the source files specified by
-.IR modules .
-You must execute
-.` "cvs checkout"
-before using most of the other
-.B cvs
-commands, since most of them operate on your working directory.
-.SP
-\fImodules\fP are either symbolic names (themselves defined as the
-module
-.` "modules"
-in the source repository; see
-.BR cvs ( 5 ))
-for some collection of source directories and files, or paths to
-directories or files in the repository.
-.SP
-Depending on the
-.I modules
-you specify,
-.B checkout
-may recursively create directories and populate them with the appropriate
-source files.
-You can then edit these source files at any time (regardless of whether
-other software developers are editing their own copies of the sources);
-update them to include new changes applied by others to the source
-repository; or commit your work as a permanent change to the
-.SM RCS
-repository.
-.SP
-Note that
-.B checkout
-is used to create directories.
-The top-level directory created is always added to the directory
-where
-.B checkout
-is invoked, and usually has the same name as the specified
-.IR module .
-In the case of a
-.I module
-alias, the created sub-directory may have a different name, but you can be
-sure that it will be a sub-directory, and that
-.B checkout
-will show the relative path leading to each file as it is extracted into
-your private work area (unless you specify the
-.B \-Q
-option).
-.SP
-Running
-.` "cvs checkout"
-on a directory that was already built by a prior
-.B checkout
-is also permitted, and
-has the same effect as specifying the
-.B \-d
-option to the
-.B update
-command described below.
-.SP
-The
-.I options
-permitted with
-.` "cvs checkout"
-include the standard command options
-.BR \-P ", " \-Q ", " \-f ", "
-.BI \-k " kflag"
-\&,
-.BR \-l ", " \-n ", " \-p ", "
-.BR \-q ", " \-r
-.IR tag ", and"
-.BI \-D " date"\c
-\&.
-.SP
-In addition to those, you can use these special command options
-with
-.BR checkout :
-.SP
-Use the
-.B \-A
-option to reset any sticky tags, dates, or
-.B \-k
-options. (If you get a working file using one of the
-\fB\-r\fP, \fB\-D\fP, or \fB\-k\fP options, \fBcvs\fP remembers the
-corresponding tag, date, or \fIkflag\fP and continues using it on
-future updates; use the \fB\-A\fP option to make \fBcvs\fP forget these
-specifications, and retrieve the ``head'' version of the file).
-.SP
-The
-.BI \-j " branch"
-option merges the changes made between the
-resulting revision and the revision that it is based on (e.g., if
-the tag refers to a branch,
-.B cvs
-will merge all changes made in that branch into your working file).
-.SP
-With two \fB-j\fP options,
-.B cvs
-will merge in the changes between the two respective revisions.
-This can be used to ``remove'' a certain delta from your working file.
-.SP
-In addition, each \fB-j\fP option can contain on optional date
-specification which, when used with branches, can limit the chosen
-revision to one within a specific date.
-An optional date is specified by adding a colon (:) to the tag.
-An example might be what
-.` "cvs import"
-tells you to do when you have
-just imported sources that have conflicts with local changes:
-.SP
-.in +1i
-.ft B
-.nf
-example% cvs checkout -jTAG:yesterday -jTAG module
-.fi
-.ft P
-.in -1i
-.SP
-Use the
-.B \-N
-option with
-.` "\-d \fIdir\fP"
-to avoid shortening module paths in your working directory. (Normally, \fBcvs\fP shortens paths as much as possible when you specify an explicit target directory.)
-.SP
-Use the
-.B \-c
-option to copy the module file, sorted, to the standard output,
-instead of creating or modifying any files or directories in your
-working directory.
-.SP
-Use the
-.BI \-d " dir"
-option to create a directory called
-.I dir
-for the working files, instead of using the module name. Unless you
-also use \fB\-N\fP, the paths created under \fIdir\fP will be as short
-as possible.
-.SP
-Use the
-.B \-s
-option to display per-module status information stored with
-the
-.B \-s
-option within the modules file.
-.TP
-\fBcommit\fP [\fB\-lnR\fP] [\fB\-m\fP '\fIlog_message\fP' | \fB\-f\fP \fIfile\fP] [\fB\-r\fP \fIrevision\fP] [\fIfiles.\|.\|.\fP]
-.I Requires:
-working directory, repository.
-.br
-.I Changes:
-repository.
-.br
-.I Synonym:
-.B ci
-.br
-Use
-.` "cvs commit"
-when you want to incorporate changes from your working source
-files into the general source repository.
-.SP
-If you don't specify particular \fIfiles\fP to commit, all
-of the files in your working current directory are examined.
-.B commit
-is careful to change in the repository only those files that you have
-really changed. By default (or if you explicitly specify the
-.B \-R
-option), files
-in subdirectories are also examined and committed if they have
-changed; you can use the
-.B \-l
-option to limit
-.B commit
-to the current directory only.
-.SP
-.B commit
-verifies that the selected files are up to date with the current revisions
-in the source repository; it will notify you, and exit without
-committing, if any of the specified files must be made current first
-with
-.` "cvs update".
-.B commit
-does not call the
-.B update
-command for you, but rather leaves that for you to do when
-the time is right.
-.SP
-When all is well, an editor is invoked to allow you to enter a log
-message that will be written to one or more logging programs and placed in the
-.SM RCS
-source repository file.
-You can instead specify the log message on the command line with the
-.B \-m
-option, thus suppressing the editor invocation, or use the
-.B \-f
-option to specify that the argument \fIfile\fP contains the log message.
-.SP
-The
-.B \-r
-option can be used to commit to a particular symbolic or numeric revision
-within the
-.SM RCS
-file.
-For example, to bring all your files up to the
-.SM RCS
-revision ``3.0'' (including those that haven't changed), you might do:
-.SP
-.in +1i
-.ft B
-.nf
-example% cvs commit -r3.0
-.fi
-.ft P
-.in -1i
-.SP
-.B cvs
-will only allow you to commit to a revision that is on the main trunk (a
-revision with a single dot).
-However, you can also commit to a branch revision (one that has an even
-number of dots) with the
-.B \-r
-option.
-To create a branch revision, one typically use the
-.B \-b option of the
-.BR rtag " or " tag
-commands.
-Then, either
-.BR checkout " or " update
-can be used to base your sources on the newly created branch.
-From that point on, all
-.B commit
-changes made within these working sources will be automatically added
-to a branch revision, thereby not perturbing main-line development in any
-way.
-For example, if you had to create a patch to the 1.2 version of the
-product, even though the 2.0 version is already under development, you
-might do:
-.SP
-.in +1i
-.ft B
-.nf
-example% cvs rtag -b -rFCS1_2 FCS1_2_Patch product_module
-example% cvs checkout -rFCS1_2_Patch product_module
-example% cd product_module
-[[ hack away ]]
-example% cvs commit
-.fi
-.ft P
-.in -1i
-.SP
-Say you have been working on some extremely experimental software, based on
-whatever revision you happened to checkout last week.
-If others in your group would like to work on this software with you, but
-without disturbing main-line development, you could commit your change to a
-new branch.
-Others can then checkout your experimental stuff and utilize the full
-benefit of
-.B cvs
-conflict resolution.
-The scenario might look like:
-.SP
-.in +1i
-.ft B
-.nf
-example% cvs tag -b EXPR1
-example% cvs update -rEXPR1
-[[ hack away ]]
-example% cvs commit
-.fi
-.ft P
-.in -1i
-.SP
-Others would simply do
-.` "cvs checkout -rEXPR1 whatever_module"
-to work with you on the experimental change.
-.TP
-\fBdiff\fP [\fB\-kl\fP] [\fIrcsdiff_options\fP] [[\fB\-r\fP \fIrev1\fP | \fB\-D\fP \fIdate1\fP] [\fB\-r\fP \fIrev2\fP | \fB\-D\fP \fIdate2\fP]] [\fIfiles.\|.\|.\fP]
-.I Requires:
-working directory, repository.
-.br
-.I Changes:
-nothing.
-.br
-You can compare your working files with revisions in the source
-repository, with the
-.` "cvs diff"
-command. If you don't specify a particular revision, your files
-are compared with the revisions they were based on. You can also use
-the standard
-.B cvs
-command option
-.B \-r
-to specify a particular revision to compare your files with. Finally,
-if you use
-.B \-r
-twice, you can see differences between two revisions in the
-repository.
-You can also specify
-.B \-D
-options to diff against a revision in the past.
-The
-.B \-r
-and
-.B \-D
-options can be mixed together with at most two options ever specified.
-.SP
-See
-.BR rcsdiff ( 1 )
-for a list of other accepted options.
-.SP
-If you don't specify any files,
-.B diff
-will display differences for all those files in the current directory
-(and its subdirectories, unless you use the standard option
-.BR \-l )
-that
-differ from the corresponding revision in the source repository
-(i.e. files that
-.I you
-have changed), or that differ from the revision specified.
-.TP
-\fBexport\fP [\-\fBf\|lNnQq\fP] \fB\-r\fP \fIrev\fP\||\|\fB\-D\fP \fIdate\fP [\fB\-d\fP \fIdir\fP] \fImodule\fP.\|.\|.
-.I Requires:
-repository.
-.br
-.I Changes:
-current directory.
-.br
-This command is a variant of
-.` "cvs checkout";
-use it when you want a copy of the source for \fImodule\fP
-without the \fBcvs\fP administrative directories. For example, you
-might use
-.` "cvs export"
-to prepare source for shipment
-off-site. This command \fIrequires\fP that you specify a date or tag
-(with \fB\-D\fP or \fB\-r\fP), so that you can count on reproducing
-the source you ship to others.
-.SP
-The only non-standard options are
-.` "\-d \fIdir\fP"
-(write the
-source into directory \fIdir\fP) and
-.` "\-N"
-(don't shorten
-module paths).
-These have the same meanings as the same options in
-.` "cvs checkout".
-.SP
-The
-.B \-kv
-option is always set when
-.B export
-is used.
-This causes any
-.SM RCS
-keywords to be expanded such that an
-.B import
-done at some other site will not lose the keyword revision information.
-There is no way to override this.
-.TP
-\fBhistory\fP [\fB\-\fP\fIreport\fP] [\fB\-\fP\fIflags\fP] [\fB\-\fP\fIoptions args\fP] [\fIfiles\fP.\|.\|.]
-.I Requires:
-the file
-.` "$CVSROOT/CVSROOT/history"
-.br
-.I Changes:
-nothing.
-.br
-\fBcvs\fP keeps a history file that tracks each use of the
-\fBcheckout\fP, \fBcommit\fP, \fBrtag\fP, \fBupdate\fP, and \fBrelease\fP
-commands. You can use
-.` "cvs history"
-to display this
-information in various formats.
-.SP
-.I Warning:
-.` "cvs history"
-uses
-.` "\-f",
-.` "\-l",
-.` "\-n",
-and
-.` "\-p"
-in ways that conflict with the
-descriptions in
-.SM
-COMMON COMMAND OPTIONS\c
-\&.
-.SP
-Several options (shown above as \fB\-\fP\fIreport\fP) control what
-kind of report is generated:
-.TP 1i
-.B \ \ \ \ \ \ \-c
-Report on each time \fBcommit\fP was used (i.e., each time the
-repository was modified).
-.TP 1i
-\fB\ \ \ \ \ \ \-m\fP \fImodule\fP
-Report on a particular \fImodule\fP. (You can meaningfully use
-\fB\-m\fP more than once on the command line.)
-.TP 1i
-.B \ \ \ \ \ \ \-o
-Report on checked-out modules.
-.TP 1i
-.B \ \ \ \ \ \ \-T
-Report on all tags.
-.TP 1i
-\fB\ \ \ \ \ \ \-x\fP \fItyp\fP
-Extract a particular set of record types \fIX\fP from the \fBcvs\fP
-history. The types are indicated by single letters, which you may
-specify in combination.
-Certain commands have a single record type: \fBcheckout\fP (type `O'),
-\fBrelease\fP (type `F'), and \fBrtag\fP (type `T'). One of four
-record types may result from an \fBupdate\fP: `W', when the working copy
-of a file is deleted during update (because it was gone from the
-repository); `U', when a working file was copied from the
-repository; `G', when a merge was necessary and it succeeded; and 'C',
-when a merge was necessary but collisions were detected (requiring
-manual merging). Finally, one of three record types results from
-\fBcommit\fP: `M', when a file was modified; `A', when a file is first
-added; and `R', when a file is removed.
-.TP 1i
-.B \ \ \ \ \ \ \-e
-Everything (all record types); equivalent to specifying
-.` "\-xMACFROGWUT".
-.PP
-.RS .5i
-The options shown as \fB\-\fP\fIflags\fP constrain the report without
-requiring option arguments:
-.RE
-.TP 1i
-.B \ \ \ \ \ \ \-a
-Show data for all users (the default is to show data only for the user
-executing
-.` "cvs history").
-.TP 1i
-.B \ \ \ \ \ \ \-l
-Show last modification only.
-.TP 1i
-.B \ \ \ \ \ \ \-w
-Show only the records for modifications done from the same working
-directory where
-.` "cvs history"
-is executing.
-.PP
-.RS .5i
-The options shown as \fB\-\fP\fIoptions args\fP constrain the report
-based on an argument:
-.RE
-.TP 1i
-\fB\ \ \ \ \ \ \-b\fP \fIstr\fP
-Show data back to a record containing the string \fIstr\fP in either
-the module name, the file name, or the repository path.
-.TP 1i
-\fB\ \ \ \ \ \ \-D\fP \fIdate\fP
-Show data since \fIdate\fP.
-.TP 1i
-\fB\ \ \ \ \ \ \-p\fP \fIrepository\fP
-Show data for a particular source repository (you can specify several
-\fB\-p\fP options on the same command line).
-.TP 1i
-\fB\ \ \ \ \ \ \-r\fP \fIrev\fP
-Show records referring to revisions since the revision or tag
-named \fIrev\fP appears in individual RCS files.
-Each
-.SM RCS
-file is searched for the revision or tag.
-.TP 1i
-\fB\ \ \ \ \ \ \-t\fP \fItag\fP
-Show records since tag \fItag\fP was last added to the the history file.
-This differs from the \fB-r\fP flag above in that it reads
-only the history file, not the
-.SM RCS
-files, and is much faster.
-.TP 1i
-\fB\ \ \ \ \ \ \-u\fP \fIname\fP
-Show records for user \fIname\fP.
-.PP
-.TP
-\fBimport\fP [\fB\-\fP\fIoptions\fP] \fIrepository vendortag releasetag\fP.\|.\|.
-.I Requires:
-Repository, source distribution directory.
-.br
-.I Changes:
-repository.
-.br
-Use
-.` "cvs import"
-to incorporate an entire source
-distribution from an outside source (e.g., a source vendor) into your
-source repository directory. You can use this command both for
-initial creation of a repository, and for wholesale updates to the
-module form the outside source.
-.SP
-The \fIrepository\fP argument gives a directory name (or a path to a
-directory) under the CVS root directory for repositories; if the
-directory did not exist, \fBimport\fP creates it.
-.SP
-When you use \fBimport\fP for updates to source that has been modified in your
-source repository (since a prior \fBimport\fP), it
-will notify you of any files that conflict in the two branches of
-development; use
-.` "cvs checkout -j"
-to reconcile the differences, as \fBimport\fP instructs you to do.
-.SP
-By default, certain file names are ignored during
-.` "cvs import":
-names associated with
-.SM CVS
-administration, or with other common source control systems; common
-names for patch files, object files, archive files, and editor backup
-files; and other names that are usually artifacts of assorted utilities.
-Currently, the default list of ignored files includes files matching
-these names:
-.SP
-.in +1i
-.ft B
-.nf
-RCSLOG RCS SCCS
-CVS* cvslog.*
-tags TAGS
-\&.make.state .nse_depinfo
-*~ #* .#* ,*
-*.old *.bak *.orig *.rej .del\-*
-*.a *.o *.Z *.elc *.ln core
-.fi
-.ft P
-.in -1i
-.SP
-The outside source is saved in a first-level
-.SM RCS
-branch, by default
-.` "1.1.1".
-Updates are leaves of this
-branch; for example, files from the first imported collection of
-source will be revision
-.` "1.1.1.1",
-then files from the first
-imported update will be revision
-.` "1.1.1.2",
-and so on.
-.SP
-At least three arguments are required. \fIrepository\fP is needed to
-identify the collection of source. \fIvendortag\fP is a tag for the
-entire branch (e.g., for
-.` "1.1.1").
-You must also specify at
-least one \fIreleasetag\fP to identify the files at the leaves created
-each time you execute
-.` "cvs import".
-.SP
-Three of the standard
-.B cvs
-command options are available: \fB\-Q\fP, \fB\-q\fP, and \fB\-m\fP
-\fImessage\fP. If you do not specify a logging message with
-\fB\-m\fP, your editor is invoked (as with \fBcommit\fP) to allow you
-to enter one.
-.SP
-There are two additional special options.
-.SP
-Use
-.` "\-b \fIbranch\fP"
-to specify a first-level branch other
-than
-.` "1.1.1".
-.SP
-Use
-.` "\-I \fIname\fP"
-to specify file names that should be
-ignored during \fBimport\fP. You can use this option repeatedly.
-To avoid ignoring any files at all (even those ignored by default),
-specify
-.` "\-I !".
-.TP
-\fBlog\fP [\fB\-l\fP] \fIrlog-options [files\fP\|.\|.\|.]
-.I Requires:
-repository, working directory.
-.br
-.I Changes:
-nothing.
-.br
-.I Synonym:
-.B rlog
-.br
-Display log information for \fIfiles\fP.
-.` "cvs log"
-calls
-the
-.SM RCS
-utility \fBrlog\fP; all the options described in
-.BR rlog ( 1 )
-are available. Among the more useful \fBrlog\fP options are \fB\-h\fP
-to display only the header (including tag definitions, but omitting
-most of the full log); \fB\-r\fP to select logs on particular
-revisions or ranges of revisions; and \fB\-d\fP to select particular
-dates or date ranges. See
-.BR rlog ( 1 )
-for full explanations.
-This command is recursive by default, unless the
-.B \-l
-option is specified.
-.TP
-\fBrdiff\fP [\fB\-\fP\fIflags\fP] [\fB\-V\fP \fIvn\fP] [\fB\-r\fP \fIt\fP|\fB\-D\fP \fId\fP [\fB\-r\fP \fIt2\fP|\fB\-D\fP \fId2\fP]] \fImodules\|.\|.\|.\fP
-.I Requires:
-repository.
-.br
-.I Changes:
-nothing.
-.br
-.I Synonym:
-.B patch
-.br
-Builds a Larry Wall format
-.BR patch ( 1 )
-file between two releases, that can be fed directly into the
-.B patch
-program to bring an old release up-to-date with the new release.
-(This is one of the few \fBcvs\fP commands that operates directly from
-the repository, and doesn't require a prior
-.BR checkout .)
-The diff output is sent to the standard output device.
-You can specify (using the standard \fB\-r\fP and \fB\-D\fP options)
-any combination of one or two revisions or dates.
-If only one revision or date is specified, the
-patch file reflects differences between that revision or date and the
-current ``head'' revisions in the
-.SM RCS
-file.
-.SP
-Note that if the software release affected
-is contained in more than one directory, then it may be necessary to
-specify the
-.B \-p
-option to the
-.B patch
-command when patching the old sources, so that
-.B patch
-is able to find the files that are located in other directories.
-.SP
-If you use the option \fB\-V\fP \fIvn\fP,
-.SM RCS
-keywords are expanded according to the rules current in
-.SM RCS
-version \fIvn\fP (the expansion format changed with
-.SM RCS
-version 5).
-.SP
-The standard option \fIflags\fP \fB\-f\fP, \fB\-l\fP, \fB\-Q\fP, and
-\fB\-q\fP are available with this command. There are also several
-special options flags:
-.SP
-If you use the
-.B \-s
-option, no patch output is produced.
-Instead, a summary of the changed or added files between the two
-releases is sent to the standard output device.
-This is useful for finding out, for example, which files have changed
-between two dates or revisions.
-.SP
-If you use the
-.B \-t
-option, a diff of the top two revisions is sent to the standard output device.
-This is most useful for seeing what the last change to a file was.
-.SP
-If you use the
-.B \-u
-option, the patch output uses the newer ``unidiff'' format for context
-diffs.
-.SP
-You can use
-.B \-c
-to explicitly specify the
-.` "diff \-c"
-form of context diffs
-(which is the default), if you like.
-.TP
-\fBrelease\fP [\fB\-dQq\fP] \fImodules\fP\|.\|.\|.
-.I Requires:
-Working directory.
-.br
-.I Changes:
-Working directory, history log.
-.br
-This command is meant to safely cancel the effect of
-.` "cvs checkout'.
-Since
-.B cvs
-doesn't lock files, it isn't strictly necessary to use this command.
-You can always simply delete your working directory, if you
-like; but you risk losing changes you may have forgotten, and you
-leave no trace in the
-.B cvs
-history file that you've abandoned your checkout.
-.SP
-Use
-.` "cvs release"
-to avoid these problems. This command
-checks that no un-committed changes are present; that you are
-executing it from immediately above, or inside, a \fBcvs\fP working
-directory; and that the repository recorded for your files is the same
-as the repository defined in the module database.
-.SP
-If all these conditions are true,
-.` "cvs release"
-leaves a
-record of its execution (attesting to your intentionally abandoning
-your checkout) in the
-.B cvs
-history log.
-.SP
-You can use the \fB\-d\fP flag to request that your working copies of
-the source files be deleted if the \fBrelease\fP succeeds.
-.TP
-\fBremove\fP [\fB\-lR\fP] [\fIfiles\|.\|.\|.\fP]
-.I Requires:
-Working directory.
-.br
-.I Changes:
-Working directory.
-.br
-.I Synonyms:
-.BR rm ", " delete
-.br
-Use this command to declare that you wish to remove \fIfiles\fP from
-the source repository. Like most
-.B cvs
-commands,
-.` "cvs remove"
-works on files in your working
-directory, not directly on the repository. As a safeguard, it also
-requires that you first erase the specified files from your working
-directory.
-.SP
-The files are not actually removed until you apply your changes to the
-repository with
-.BR commit ;
-at that point, the corresponding
-.SM RCS
-files in the source repository are
-.I moved
-into the
-.` "Attic"
-directory (also within the source repository).
-.SP
-This command is recursive by default, scheduing all physically removed
-files that it finds for removal by the next
-.BR commit .
-Use the
-.B \-l
-option to avoid this recursion, or just specify that actual files that you
-wish remove to consider.
-.TP
-\fBrtag\fP [\fB\-f\|alnRQq\fP] [\fB\-b\fP] [\fB\-d\fP] [\fB\-r\fP \fItag\fP | \fB\-D\fP \fIdate\fP] \fIsymbolic_tag\fP \fImodules\|.\|.\|.\fP
-.I Requires:
-repository.
-.br
-.I Changes:
-repository.
-.br
-.I Synonym:
-.B rfreeze
-.br
-You can use this command to assign symbolic tags to particular,
-explicitly specified source versions in the repository.
-.` "cvs rtag"
-works directly on the repository contents (and requires no
-prior
-.BR checkout ).
-Use
-.` "cvs tag"
-instead, to base the selection of
-versions to tag on the contents of your working directory.
-.SP
-In general, tags (often the symbolic names of software distributions)
-should not be removed, but the
-.B \-d
-option is available as a means to remove completely obsolete symbolic names
-if necessary (as might be the case for an Alpha release, say).
-.SP
-The \fB-b\fP option makes the tag a ``branch'' tag, allowing
-concurrent, isolated development.
-This is most useful for creating a patch to a previously released software
-distribution.
-.SP
-You can use the standard \fB\-r\fP and \fB\-D\fP options to tag only those
-files that already contain a certain tag. This method would be used
-to rename a tag: tag only the files identified by the old tag, then delete the
-old tag, leaving the new tag on exactly the same files as the old tag.
-.SP
-.B rtag
-executes recursively by default, tagging all subdirectories of
-\fImodules\fP you specify in the argument. You can restrict its
-operation to top-level directories with the standard \fB\-l\fP option;
-or you can explicitly request recursion with \fB\-R\fP.
-.SP
-The modules database can specify a program to execute whenever a tag
-is specified; a typical use is to send electronic mail to a group of
-interested parties. If you want to bypass that program, use the
-standard \fB\-n\fP option.
-.SP
-The standard options \fB\-Q\fP and \fB\-q\fP are also available with
-this command.
-.SP
-Use the
-.B \-a
-option to have
-.B rtag
-look in the
-.` "Attic"
-for removed files that contin the specified tag.
-The tag is removed from these files, which makes it convenient to re-use a
-symbolic tag as development continues (and files get removed from the
-up-coming distribution).
-.TP
-\fBstatus\fP [\fB\-lR\fP] [\fB\-v\fP] [\fIfiles\fP\|.\|.\|.]
-.I Requires:
-working directory, repository.
-.br
-.I Changes:
-nothing.
-.br
-Display a brief report on the current status of \fIfiles\fP with
-respect to the source repository, including any ``sticky'' tags,
-dates, or \fB\-k\fP options. (``Sticky'' options will restrict how
-.` "cvs update"
-operates until you reset them; see the
-description of
-.` "cvs update \-A\|.\|.\|.".)
-.SP
-You can also use this command to anticipate the potential impact of a
-.` "cvs update"
-on your working source directory. If you do
-not specify any \fIfiles\fP explicitly, reports are shown for all
-files that \fBcvs\fP has placed in your working directory. You can
-limit the scope of this search to the current directory itself (not
-its subdirectories) with the standard \fB\-l\fP option flag; or you
-can explicitly request recursive status reports with the \fB\-R\fP
-option.
-.SP
-The
-.B \-v
-option causes the symbolic tags for the
-.SM RCS
-file to be displayed as well.
-.TP
-\fBtag\fP [\fB\-lQqR\fP] [\fB\-b\fP] [\fB\-d\fP] \fIsymbolic_tag\fP [\fIfiles\fP\|.\|.\|.\|]
-.I Requires:
-working directory, repository.
-.br
-.I Changes:
-repository.
-.br
-.I Synonym:
-.B freeze
-.br
-Use this command to assign symbolic tags to the nearest repository
-versions to your working sources. The tags are applied immediately to
-the repository, as with \fBrtag\fP, but the versions are supplied
-implicitly by the \fBcvs\fP records of your working files' history
-rather than applied explicitly.
-.SP
-One use for tags is to record a ``snapshot'' of the current sources
-when the software freeze date of a project arrives. As bugs are fixed
-after the freeze date, only those changed sources that are to be part
-of the release need be re-tagged.
-.SP
-The symbolic tags are meant to permanently record which revisions of which
-files were used in creating a software distribution.
-The
-.B checkout
-and
-.B update
-commands allow you to extract an exact copy of a tagged release at any time in
-the future, regardless of whether files have been changed, added, or removed
-since the release was tagged.
-.SP
-If you use
-.` "cvs tag \-d \fIsymbolic_tag\fP\|.\|.\|.",
-the
-symbolic tag you specify is
-.I deleted
-instead of being added. \fIWarning\fP: Be very certain of your ground
-before you delete a tag; doing this effectively discards some
-historical information, which may later turn out to have been valuable.
-.SP
-The \fB-b\fP option makes the tag a ``branch'' tag, allowing
-concurrent, isolated development.
-This is most useful for creating a patch to a previously released software
-distribution.
-.SP
-Normally,
-.B tag
-executes recursively through subdirectories; you can prevent this by
-using the standard \fB\-l\fP option, or specify the recursion
-explicitly by using \fB\-R\fP.
-.TP
-\fBupdate\fP [\fB\-Adf\|lPpQqR\fP] [\fB\-d\fP] [\fB\-r\fP \fItag\fP|\fB\-D\fP \fIdate\fP] \fIfiles\|.\|.\|.\fP
-.I Requires:
-repository, working directory.
-.br
-.I Changes:
-working directory.
-.br
-After you've run
-.B checkout
-to create your private copy of source from the common repository,
-other developers will continue changing the central source. From time
-to time, when it is convenient in your development process, you can
-use the
-.B update
-command
-from within your working directory to reconcile your work with any
-revisions applied to the source repository since your last
-.B checkout
-or
-.BR update .
-.SP
-.B update
-keeps you informed of its progress by printing a line for each file,
-prefaced with one of the characters
-.` "U A R M C ?"
-to indicate the status of the file:
-.TP 1i
-\fBU\fP \fIfile\fP
-The file was brought \fIup to date\fP with respect to the repository.
-This is done for any file that exists in the repository but not in
-your source, and for files that you haven't changed but are not the most
-recent versions available in the repository.
-.TP 1i
-\fBA\fP \fIfile\fP
-The file has been \fIadded\fP to your private copy of the sources, and
-will be added to the
-.SM RCS
-source repository when you run
-.` "cvs commit"
-on the file.
-This is a reminder to you that the file needs to be committed.
-.TP 1i
-\fBR\fP \fIfile\fP
-The file has been \fIremoved\fP from your private copy of the sources, and
-will be removed from the
-.SM RCS
-source repository when you run
-.` "cvs commit"
-on the file.
-This is a reminder to you that the file needs to be committed.
-.TP 1i
-\fBM\fP \fIfile\fP
-The file is \fImodified\fP in your working directory.
-.` "M"
-can indicate one of two states for a file you're working on: either
-there were no modifications to the same file in the repository, so
-that your file remains as you last saw it; or there were modifications
-in the repository as well as in your copy, but they were
-\fImerged\fP successfully, without conflict, in your working
-directory.
-.TP 1i
-\fBC\fP \fIfile\fP
-A \fIconflict\fP was detected while trying to merge your changes to
-\fIfile\fP with changes from the source repository. \fIfile\fP (the
-copy in your working directory) is now the output of the
-.BR rcsmerge ( 1 )
-command on the two versions; an unmodified copy of your file is also
-in your working directory, with the name `\fB.#\fP\fIfile\fP\fB.\fP\fIversion\fP',
-where
-.I version
-is the
-.SM RCS
-revision that your modified file started from.
-(Note that some systems automatically purge files that begin with
-\&
-.` ".#"
-if they have not been accessed for a few days.
-If you intend to keep a copy of your original file, it is a very good
-idea to rename it.)
-.TP 1i
-\fB?\fP \fIfile\fP
-\fIfile\fP is in your working directory, but does not correspond to
-anything in the source repository, and is not in the list of files
-for \fBcvs\fP to ignore (see the description of the \fB\-I\fP option).
-.PP
-.RS .5i
-.SP
-Use the
-.B \-A
-option to reset any sticky tags, dates, or
-.B \-k
-options. (If you get a working copy of a file by using one of the
-\fB\-r\fP, \fB\-D\fP, or \fB\-k\fP options, \fBcvs\fP remembers the
-corresponding tag, date, or \fIkflag\fP and continues using it on
-future updates; use the \fB\-A\fP option to make \fBcvs\fP forget these
-specifications, and retrieve the ``head'' version of the file).
-.SP
-The \fB\-j\fP\fIbranch\fP option
-merges the changes made between the
-resulting revision and the revision that it is based on (e.g., if
-the tag refers to a branch,
-.B cvs
-will merge all changes made in
-that branch into your working file).
-.SP
-With two \fB-j\fP options,
-.B cvs
-will merge in the changes between the two respective revisions.
-This can be used to ``remove'' a certain delta from your working file.
-E.g., If the file foo.c is based on
-revision 1.6 and I want to remove the changes made between 1.3 and
-1.5, I might do:
-.SP
-.in +1i
-.ft B
-.nf
-example% cvs update -j1.5 -j1.3 foo.c # note the order...
-.fi
-.ft P
-.in -1i
-.SP
-In addition, each \fB-j\fP option can contain on optional date
-specification which, when used with branches, can limit the chosen
-revision to one within a specific date.
-An optional date is specified by adding a colon (:) to the tag.
-.SP
-.in +1i
-.ft B
-.nf
--jSymbolic_Tag:Date_Specifier
-.fi
-.ft P
-.in -1i
-.SP
-Use the
-.B \-d
-option to create any directories that exist in the repository if they're
-missing from the working directory. (Normally, update acts only on
-directories and files that were already enrolled in your
-working directory.) This is useful for updating directories
-that were created in the repository since the initial
-\fBcheckout\fP; but it has an unfortunate side effect. If you
-deliberately avoided certain directories in the repository when you
-created your working directory (either through use of a module name or by
-listing explicitly the files and directories you wanted on the
-command line), then updating with
-.B \-d
-will create those directories, which may not be what you want.
-.SP
-Use \fB\-I\fP \fIname\fP to ignore files whose names match \fIname\fP
-(in your working directory) during the update. You can specify
-\fB\-I\fP more than once on the command line to specify several files
-to ignore. By default,
-\fBupdate\fP ignores files whose names match any of the following:
-.SP
-.in +1i
-.ft B
-.nf
-RCSLOG RCS SCCS
-CVS* cvslog.*
-tags TAGS
-\&.make.state .nse_depinfo
-*~ #* .#* ,*
-*.old *.bak *.orig *.rej .del\-*
-*.a *.o *.Z *.elc *.ln core
-.fi
-.ft P
-.in -1i
-.SP
-Use
-.` "\-I !"
-to avoid ignoring any files at all.
-.SP
-The standard \fBcvs\fP command options \fB\-f\fP, \fB\-k\fP,
-\fB\-l\fP, \fB\-P\fP, \fB\-p\fP, \fB\-Q\fP, \fB\-q\fP, and \fB\-r\fP
-are also available with \fBupdate\fP.
-.RE
-.SH "FILES"
-For more detailed information on
-.B cvs
-supporting files, see
-.BR cvs ( 5 ).
-.LP
-.I
-Files in working directories:
-.TP
-CVS
-A directory of \fBcvs\fP administrative files.
-.I
-Do not delete.
-.TP
-CVS/Entries
-List and status of files in your working directory.
-.TP
-CVS/Entries.Backup
-A backup of
-.` "CVS/Entries".
-.TP
-CVS/Entries.Static
-Flag: do not add more entries on
-.` "cvs update".
-.TP
-CVS/Repository
-Pathname to the corresponding directory in the source repository.
-.TP
-CVS/Tag
-Contains the per-directory ``sticky'' tag or date information.
-This file is created/updated when you specify
-.B \-r
-or
-.B \-D
-to the
-.B checkout
-or
-.B update
-commands, and no files are specified.
-.TP
-CVS/Checkin.prog
-Name of program to run on
-.` "cvs commit".
-.TP
-CVS/Update.prog
-Name of program to run on
-.` "cvs update".
-.LP
-.I
-Files in source repositories:
-.TP
-$CVSROOT/CVSROOT
-Directory of global administrative files for repository.
-.TP
-CVSROOT/commitinfo,v
-Records programs for filtering
-.` "cvs commit"
-requests.
-.TP
-CVSROOT/history
-Log file of \fBcvs\fP transactions.
-.TP
-CVSROOT/modules,v
-Definitions for modules in this repository.
-.TP
-CVSROOT/loginfo,v
-Records programs for piping
-.` "cvs commit"
-log entries.
-.TP
-CVSROOT/rcsinfo,v
-Records pathnames to templates used dueing a
-.` "cvs commit"
-operation.
-.TP
-CVSROOT/editinfo,v
-Records programs for editing/validating
-.` "cvs commit"
-log entries.
-.TP
-Attic
-Directory for removed source files.
-.TP
-#cvs.lock
-A lock directory created by
-.B cvs
-when doing sensitive changes to the
-.SM RCS
-source repository.
-.TP
-#cvs.tfl.\fIpid\fP
-Temporary lock file for repository.
-.TP
-#cvs.rfl.\fIpid\fP
-A read lock.
-.TP
-#cvs.wfl.\fIpid\fP
-A write lock.
-.SH "ENVIRONMENT VARIABLES"
-.TP
-.SM CVSROOT
-Should contain the full pathname to the root of the
-.B cvs
-source repository (where the
-.SM RCS
-files are kept). This information must be available to \fBcvs\fP for
-most commands to execute; if
-.SM CVSROOT
-is not set, or if you wish to override it for one invocation, you can
-supply it on the command line:
-.` "cvs \-d \fIcvsroot cvs_command\fP\|.\|.\|."
-You may not need to set
-.SM CVSROOT
-if your \fBcvs\fP binary has the right path compiled in; use
-.` "cvs \-v"
-to display all compiled-in paths.
-.TP
-.SM CVSREAD
-If this is set,
-.B checkout
-and
-.B update
-will try hard to make the files in your working directory read-only.
-When this is not set, the default behavior is to permit modification
-of your working files.
-.TP
-.SM RCSBIN
-Specifies the full pathname where to find
-.SM RCS
-programs, such as
-.BR co ( 1 )
-and
-.BR ci ( 1 ).
-If not set, a compiled-in value is used; see the display from
-.` "cvs \-v".
-.TP
-.SM EDITOR
-Specifies the program to use for recording log messages during
-.BR commit .
-If not set, the default is
-.BR /usr/ucb/vi .
-.SH "AUTHORS"
-.TP
-Dick Grune
-Original author of the
-.B cvs
-shell script version posted to
-.B comp.sources.unix
-in the volume6 release of December, 1986.
-Credited with much of the
-.B cvs
-conflict resolution algorithms.
-.TP
-Brian Berliner
-Coder and designer of the
-.B cvs
-program itself in April, 1989, based on the original work done by Dick.
-.TP
-Jeff Polk
-Helped Brian with the design of the
-.B cvs
-module and vendor branch support and author of the
-.BR checkin ( 1 )
-shell script (the ancestor of
-.` "cvs import").
-.SH "SEE ALSO"
-.BR ci ( 1 ),
-.BR co ( 1 ),
-.BR cvs ( 5 ),
-.BR diff ( 1 ),
-.BR grep ( 1 ),
-.BR mkmodules ( 1 ),
-.BR patch ( 1 ),
-.BR rcs ( 1 ),
-.BR rcsdiff ( 1 ),
-.BR rcsmerge ( 1 ),
-.BR rlog ( 1 ),
-.BR rm ( 1 ),
-.BR sort ( 1 ).
diff --git a/gnu/usr.bin/cvs/cvs/cvs.5 b/gnu/usr.bin/cvs/cvs/cvs.5
deleted file mode 100644
index 49ca562..0000000
--- a/gnu/usr.bin/cvs/cvs/cvs.5
+++ /dev/null
@@ -1,326 +0,0 @@
-.TH cvs 5 "12 February 1992"
-.\" Full space in nroff; half space in troff
-.de SP
-.if n .sp
-.if t .sp .5
-..
-.SH NAME
-cvs \- Concurrent Versions System support files
-.SH SYNOPSIS
-.hy 0
-.na
-.TP
-.B $CVSROOT/CVSROOT/modules,v
-.TP
-.B $CVSROOT/CVSROOT/commitinfo,v
-.TP
-.B $CVSROOT/CVSROOT/loginfo,v
-.TP
-.B $CVSROOT/CVSROOT/rcsinfo,v
-.TP
-.B $CVSROOT/CVSROOT/editinfo,v
-.TP
-.B $CVSROOT/CVSROOT/cvsignore,v
-.TP
-.B $CVSROOT/CVSROOT/history
-.ad b
-.hy 1
-.SH DESCRIPTION
-.B cvs
-is a system for providing source control to hierarchical collections
-of source directories. Commands and procedures for using \fBcvs\fP
-are described in
-.BR cvs ( 1 ).
-.SP
-.B cvs
-manages \fIsource repositories\fP, the directories containing master
-copies of the revision-controlled files, by copying particular
-revisions of the files to (and modifications back from) developers'
-private \fIworking directories\fP. In terms of file structure, each
-individual source repository is an immediate subdirectory of
-\fB$CVSROOT\fP.
-.SP
-The files described here are supporting files; they do not have to
-exist for \fBcvs\fP to operate, but they allow you to make \fBcvs\fP
-operation more flexible.
-.SP
-The
-.BR cvsinit ( 1 )
-shell script included at the top-level of the
-.B cvs
-distribution can be used to setup an initial
-.B $CVSROOT/CVSROOT
-area, if you don't have one already.
-.SP
-You can use the `\|modules\|' file to define symbolic names for
-collections of source maintained with \fBcvs\fP. If there is no
-`\|modules\|' file, developers must specify complete path names
-(absolute, or relative to \fB$CVSROOT\fP) for the files they wish to
-manage with \fBcvs\fP commands.
-.SP
-You can use the `\|commitinfo\|' file to define programs to execute
-whenever `\|\fBcvs commit\fP\|' is about to execute.
-These programs are used for ``pre-commit'' checking to verify that the
-modified, added, and removed files are really ready to be committed.
-Some uses for this check might be to turn off a portion (or all) of the
-source repository from a particular person or group.
-Or, perhaps, to verify that the changed files conform to the site's
-standards for coding practice.
-.SP
-You can use the `\|loginfo\|' file to define programs to execute after
-any
-.BR commit ,
-which writes a log entry for changes in the repository.
-These logging programs might be used to append the log message to a file.
-Or send the log message through electronic mail to a group of developers.
-Or, perhaps, post the log message to a particular newsgroup.
-.SP
-You can use the `\|rcsinfo\|' file to define forms for log messages.
-.SP
-You can use the `\|editinfo\|' file to define a program to execute for
-editing/validating `\|\fBcvs commit\fP\|' log entries.
-This is most useful when used with a `\|rcsinfo\|' forms specification, as
-it can verify that the proper fields of the form have been filled in by the
-user committing the change.
-.SP
-You can use the `\|cvsignore\|' file to specify the default list of
-files to ignore during \fBupdate\fP.
-.SP
-You can use the `\|history\|' file to record the \fBcvs\fP commands
-that affect the repository.
-The creation of this file enables history logging.
-.SH FILES
-.TP
-.B modules
-The `\|modules\|' file records your definitions of names for
-collections of source code. \fBcvs\fP will use these definitions if
-you create a file with the right format in
-`\|\fB$CVSROOT/CVSROOT/modules,v\fP\|'.
-The
-.BR mkmodules ( 1 )
-command should be run whenever the modules file changes, so that the
-appropriate files can be generated (depending on how you have configured
-.B cvs
-operation).
-.SP
-To allow convenient editing of the `\|modules\|' file itself, the file should
-include an entry like the following (where \fIlocalbin\fP represents the
-directory where your site installs programs like
-.BR mkmodules ( 1 )):
-.SP
-.nf
-\&\fBmodules \-i /\fP\fIlocalbin\fP\fB/mkmodules CVSROOT modules\fP
-.fi
-.SP
-This defines the name `\|\fBmodules\fP\|' as the module name for the
-file itself, so that you can use
-.SP
-.in +1i
-.ft B
-.nf
-example% cvs checkout modules
-.fi
-.ft P
-.in -1i
-.SP
-to get an editable copy of the file. You should define similar module
-entries for the other configuration files described here (except
-\&`\|history\|').
-The
-.BR cvsinit ( 1 )
-script will setup a smilar `\|modules\|' file for you automatically.
-.SP
-The `\|modules\|' file may contain blank lines and comments (lines
-beginning with `\|\fB#\fP\|') as well as module definitions.
-Long lines can be continued on the next line by specifying a backslash
-(``\e'') as the last character on the line.
-.SP
-A \fImodule definition\fP is a single line of the `\|modules\|' file,
-in either of two formats. In both cases, \fImname\fP represents the
-symbolic module name, and the remainder of the line is its definition.
-.SP
-\fImname\fP \fB\-a\fP \fIaliases\fP\|.\|.\|.
-.br
-This represents the simplest way of defining a module \fImname\fP.
-The `\|\fB\-a\fP\|' flags the definition as a simple alias: \fBcvs\fP
-will treat any use of \fImname\fP (as a command argument) as if the list
-of names \fIaliases\fP had been specified instead. \fIaliases\fP may
-contain either other module names or paths. When you use paths in
-\fIaliases\fP, `\|\fBcvs checkout\fP\|' creates all intermediate
-directories in the working directory, just as if the path had been
-specified explicitly in the \fBcvs\fP arguments.
-.SP
-.nf
-\fImname\fP [ \fIoptions\fP ] \fIdir\fP [ \fIfiles\fP\|.\|.\|. ] [ \fB&\fP\fImodule\fP\|.\|.\|. ]
-.fi
-.SP
-In the simplest case, this form of module definition reduces to
-`\|\fImname dir\fP\|'. This defines all the files in directory
-\fIdir\fP as module \fImname\fP. \fIdir\fP is a relative path (from
-\fB$CVSROOT\fP) to a directory of source in one of the source
-repositories. In this case, on \fBcheckout\fP, a single directory
-called \fImname\fP is created as a working directory; no intermediate
-directory levels are used by default, even if \fIdir\fP was a path
-involving several directory levels.
-.SP
-By explicitly specifying \fIfiles\fP in the module definition after
-\fIdir\fP, you can select particular files from directory
-\fIdir\fP. The sample definition for \fBmodules\fP is an example of
-a module defined with a single file from a particular directory. Here
-is another example:
-.SP
-.nf
-.ft B
-m4test unsupported/gnu/m4 foreach.m4 forloop.m4
-.ft P
-.fi
-.SP
-With this definition, executing `\|\fBcvs checkout m4test\fP\|'
-will create a single working directory `\|m4test\|' containing the two
-files listed, which both come from a common directory several levels
-deep in the \fBcvs\fP source repository.
-.SP
-A module definition can refer to other modules by including
-`\|\fB&\fP\fImodule\fP\|' in its definition. \fBcheckout\fP creates
-a subdirectory for each such \fImodule\fP, in your working directory.
-.br
-.I
-New in \fBcvs\fP 1.3;
-avoid this feature if sharing module definitions with older versions
-of \fBcvs\fP.
-.SP
-Finally, you can use one or more of the following \fIoptions\fP in
-module definitions:
-.SP
-\&`\|\fB\-d\fP \fIname\fP\|', to name the working directory something
-other than the module name.
-.br
-.I
-New in \fBcvs\fP 1.3;
-avoid this feature if sharing module definitions with older versions
-of \fBcvs\fP.
-.SP
-\&`\|\fB\-i\fP \fIprog\fP\|' allows you to specify a program \fIprog\fP
-to run whenever files in a module are committed. \fIprog\fP runs with a
-single argument, the full pathname of the affected directory in a
-source repository. The `\|commitinfo\|', `\|loginfo\|', and
-`\|editinfo\|' files provide other ways to call a program on \fBcommit\fP.
-.SP
-`\|\fB\-o\fP \fIprog\fP\|' allows you to specify a program \fIprog\fP
-to run whenever files in a module are checked out. \fIprog\fP runs
-with a single argument, the module name.
-.SP
-`\|\fB\-t\fP \fIprog\fP\|' allows you to specify a program \fIprog\fP
-to run whenever files in a module are tagged. \fIprog\fP runs with two
-arguments: the module name and the symbolic tag specified to \fBrtag\fP.
-.SP
-`\|\fB\-u\fP \fIprog\fP\|' allows you to specify a program \fIprog\fP
-to run whenever `\|\fBcvs update\fP\|' is executed from the top-level
-directory of the checked-out module. \fIprog\fP runs with a
-single argument, the full path to the source repository for this module.
-.TP
-\&\fBcommitinfo\fP, \fBloginfo\fP, \fBrcsinfo\fP, \fBeditinfo\fP
-These files all specify programs to call at different points in the
-`\|\fBcvs commit\fP\|' process. They have a common structure.
-Each line is a pair of fields: a regular expression, separated by
-whitespace from a filename or command-line template.
-Whenever one of the regular expression matches a directory name in the
-repository, the rest of the line is used.
-If the line begins with a \fB#\fP character, the entire line is considered
-a comment and is ignored.
-Whitespace between the fields is also ignored.
-.SP
-For `\|loginfo\|', the rest of the
-line is a command-line template to execute.
-The templates can include not only
-a program name, but whatever list of arguments you wish. If you write
-`\|\fB%s\fP\|' somewhere on the argument list, \fBcvs\fP supplies, at
-that point, the list of files affected by the \fBcommit\fP.
-The first entry in the list is the relative path within the source
-repository where the change is being made.
-The remaining arguments list the files that are being modified, added, or
-removed by this \fBcommit\fP invocation.
-.SP
-For `\|commitinfo\|', the rest of the line is a command-line template to
-execute.
-The template can include can include not only a program name, but whatever
-list of arguments you wish.
-The full path to the current source repository is appended to the template,
-followed by the file names of any files involved in the commit (added,
-removed, and modified files).
-.SP
-For `\|rcsinfo\|', the rest of the line is the full path to a file that
-should be loaded into the log message template.
-.SP
-For `\|editinfo\|', the rest of the line is a command-line template to
-execute.
-The template can include can include not only a program name, but whatever
-list of arguments you wish.
-The full path to the current log message template file is appended to the
-template.
-.SP
-You can use one of two special strings instead of a regular
-expression: `\|\fBALL\fP\|' specifies a command line template that
-must always be executed, and `\|\fBDEFAULT\fP\|' specifies a command
-line template to use if no regular expression is a match.
-.SP
-The `\|commitinfo\|' file contains commands to execute \fIbefore\fP any
-other \fBcommit\fP activity, to allow you to check any conditions that
-must be satisfied before \fBcommit\fP can proceed. The rest of the
-\fBcommit\fP will execute only if all selected commands from this file
-exit with exit status \fB0\fP.
-.SP
-The `\|rcsinfo\|' file allows you to specify \fIlog templates\fP for
-the \fBcommit\fP logging session; you can use this to provide a form
-to edit when filling out the \fBcommit\fP log. The field after the
-regular expression, in this file, contains filenames (of files
-containing the logging forms) rather than command templates.
-.SP
-The `\|editinfo\|' file allows you to execute a script \fIbefore the
-commit starts\fP, but after the log information is recorded. These
-"edit" scripts can verify information recorded in the log file. If
-the edit script exits wth a non-zero exit status, the commit is aborted.
-.SP
-The `\|loginfo\|' file contains commands to execute \fIat the end\fP
-of a commit. The text specified as a commit log message is piped
-through the command; typical uses include sending mail, filing an
-article in a newsgroup, or appending to a central file.
-.TP
-\&\fBcvsignore\fP, \fB.cvsignore\fP
-The default list of files (or
-.BR sh ( 1 )
-file name patterns) to ignore during `\|\fBcvs update\fP\|'.
-At startup time, \fBcvs\fP loads the compiled in default list of file name
-patterns (see
-.BR cvs ( 1 )).
-Then the per-repository list included in \fB$CVSROOT/CVSROOT/cvsignore\fP
-is loaded, if it exists.
-Then the per-user list is loaded from `\|$HOME/.cvsignore\|'.
-Finally, as \fBcvs\fP traverses through your directories, it will load any
-per-directory `\|.cvsignore\|' files whenever it finds one.
-These per-directory files are only valid for exactly the directory that
-contains them, not for any sub-directories.
-.TP
-.B history
-Create this file in \fB$CVSROOT/CVSROOT\fP to enable history logging
-(see the description of `\|\fBcvs history\fP\|').
-.SH "SEE ALSO"
-.BR cvs ( 1 ),
-.BR mkmodules ( 1 ).
-.SH COPYING
-Copyright \(co 1992 Cygnus Support, Brian Berliner, and Jeff Polk
-.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/cvs/cvs/cvs.h b/gnu/usr.bin/cvs/cvs/cvs.h
deleted file mode 100644
index ec47581..0000000
--- a/gnu/usr.bin/cvs/cvs/cvs.h
+++ /dev/null
@@ -1,438 +0,0 @@
-/* @(#)cvs.h 1.72 92/03/31 */
-
-#include "system.h"
-#include <stdio.h>
-#include <ctype.h>
-#include <pwd.h>
-#include <signal.h>
-#include "hash.h"
-#include "rcs.h"
-#include "regex.h"
-#include "fnmatch.h"
-#include "getopt.h"
-#include "wait.h"
-#include "config.h"
-#ifdef MY_NDBM
-#include "myndbm.h"
-#else
-#include <ndbm.h>
-#endif /* !MY_NDBM */
-
-/* XXX - for now this is static */
-#undef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN+2
-#else
-#define PATH_MAX 1024+2
-#endif
-
-/* just in case this implementation does not define this */
-#ifndef L_tmpnam
-#define L_tmpnam 50
-#endif
-
-#if __STDC__
-#define CONST const
-#define PTR void *
-#else
-#define CONST
-#define PTR char *
-#endif
-
-/*
- * 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.3 kit.
- *
- * Definitions for the CVS Administrative directory and the files it contains.
- * Here as #define's to make changing the names a simple task.
- */
-#define CVSADM "CVS"
-#define CVSADM_ENT "CVS/Entries"
-#define CVSADM_ENTBAK "CVS/Entries.Backup"
-#define CVSADM_ENTSTAT "CVS/Entries.Static"
-#define CVSADM_REP "CVS/Repository"
-#define CVSADM_CIPROG "CVS/Checkin.prog"
-#define CVSADM_UPROG "CVS/Update.prog"
-#define CVSADM_TAG "CVS/Tag"
-
-/*
- * The following are obsolete and are maintained here only so that they can be
- * cleaned up during the transition
- */
-#define OCVSADM "CVS.adm" /* for CVS 1.2 and earlier */
-#define CVSADM_FILE "CVS/Files"
-#define CVSADM_MOD "CVS/Mod"
-
-/*
- * Definitions for the CVSROOT Administrative directory and the files it
- * contains. This directory is created as a sub-directory of the $CVSROOT
- * environment variable, and holds global administration information for the
- * entire source repository beginning at $CVSROOT.
- */
-#define CVSROOTADM "CVSROOT"
-#define CVSROOTADM_MODULES "modules"
-#define CVSROOTADM_LOGINFO "loginfo"
-#define CVSROOTADM_RCSINFO "rcsinfo"
-#define CVSROOTADM_COMMITINFO "commitinfo"
-#define CVSROOTADM_EDITINFO "editinfo"
-#define CVSROOTADM_HISTORY "history"
-#define CVSROOTADM_IGNORE "cvsignore"
-#define CVSNULLREPOS "Emptydir" /* an empty directory */
-
-/* support for the modules file (CVSROOTADM_MODULES) */
-#define CVSMODULE_OPTS "ad:i:lo:s:t:u:"/* options in modules file */
-#define CVSMODULE_SPEC '&' /* special delimiter */
-
-/*
- * The following are obsolete and are maintained here only so that they can be
- * cleaned up during the transition
- */
-#define OCVSROOTADM "CVSROOT.adm" /* for CVS 1.2 and earlier */
-
-/* Other CVS file names */
-#define CVSATTIC "Attic"
-#define CVSLCK "#cvs.lock"
-#define CVSTFL "#cvs.tfl"
-#define CVSRFL "#cvs.rfl"
-#define CVSWFL "#cvs.wfl"
-#define CVSEXT_OPT ",p"
-#define CVSEXT_LOG ",t"
-#define CVSPREFIX ",,"
-#define CVSDOTIGNORE ".cvsignore"
-
-/* miscellaneous CVS defines */
-#define CVSEDITPREFIX "CVS: "
-#define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */
-#define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */
-#define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */
-#define BAKPREFIX ".#" /* when rcsmerge'ing */
-#define DEVNULL "/dev/null"
-
-#define FALSE 0
-#define TRUE 1
-
-/*
- * Special tags. -rHEAD refers to the head of an RCS file, regardless of any
- * sticky tags. -rBASE refers to the current revision the user has checked
- * out This mimics the behaviour of RCS.
- */
-#define TAG_HEAD "HEAD"
-#define TAG_BASE "BASE"
-
-/* Environment variable used by CVS */
-#define CVSREAD_ENV "CVSREAD" /* make files read-only */
-#define CVSREAD_DFLT FALSE /* writable files by default */
-
-#define RCSBIN_ENV "RCSBIN" /* RCS binary directory */
-/* #define RCSBIN_DFLT Set by config.h */
-
-#define EDITOR_ENV "EDITOR" /* which editor to use */
-/* #define EDITOR_DFLT Set by config.h */
-
-#define CVSROOT_ENV "CVSROOT" /* source directory root */
-#define CVSROOT_DFLT NULL /* No dflt; must set for checkout */
-
-#define IGNORE_ENV "CVSIGNORE" /* More files to ignore */
-
-/*
- * If the beginning of the Repository matches the following string, strip it
- * so that the output to the logfile does not contain a full pathname.
- *
- * If the CVSROOT environment variable is set, it overrides this define.
- */
-#define REPOS_STRIP "/master/"
-
-/*
- * The maximum number of files per each CVS directory. This is mainly for
- * sizing arrays statically rather than dynamically. 3000 seems plenty for
- * now.
- */
-#define MAXFILEPERDIR 3000
-#define MAXLINELEN 5000 /* max input line from a file */
-#define MAXPROGLEN 30000 /* max program length to system() */
-#define MAXLISTLEN 40000 /* For [A-Z]list holders */
-#define MAXMESGLEN 10000 /* max RCS log message size */
-#define MAXDATELEN 50 /* max length for a date */
-
-/* The type of request that is being done in do_module() */
-enum mtype
-{
- CHECKOUT, TAG, PATCH
-};
-
-/*
- * defines for Classify_File() to determine the current state of a file.
- * These are also used as types in the data field for the list we make for
- * Update_Logfile in commit, import, and add.
- */
-enum classify_type
-{
- T_UNKNOWN = 1, /* no old-style analog existed */
- T_CONFLICT, /* C (conflict) list */
- T_NEEDS_MERGE, /* G (needs merging) list */
- T_MODIFIED, /* M (needs checked in) list */
- T_CHECKOUT, /* O (needs checkout) list */
- T_ADDED, /* A (added file) list */
- T_REMOVED, /* R (removed file) list */
- T_REMOVE_ENTRY, /* W (removed entry) list */
- T_UPTODATE, /* File is up-to-date */
- T_TITLE /* title for node type */
-};
-typedef enum classify_type Ctype;
-
-/*
- * a struct vers_ts contains all the information about a file including the
- * user and rcs file names, and the version checked out and the head.
- *
- * this is usually obtained from a call to Version_TS which takes a tag argument
- * for the RCS file if desired
- */
-struct vers_ts
-{
- char *vn_user; /* rcs version user file derives from
- * it can have the following special
- * values:
- * empty = no user file
- * 0 = user file is new
- * -vers = user file to be removed */
- char *vn_rcs; /* the verion for the rcs file
- * (tag version?) */
- char *ts_user; /* the timestamp for the user file */
- char *ts_rcs; /* the user timestamp from entries */
- char *options; /* opts from Entries file
- * (keyword expansion) */
- char *tag; /* tag stored in the Entries file */
- char *date; /* date stored in the Entries file */
- Entnode *entdata; /* pointer to entries file node */
- RCSNode *srcfile; /* pointer to parsed src file info */
-};
-typedef struct vers_ts Vers_TS;
-
-/*
- * structure used for list-private storage by ParseEntries() and
- * Version_TS().
- */
-struct stickydirtag
-{
- int aflag;
- char *tag;
- char *date;
- char *options;
-};
-
-/* flags for run_exec(), the fast system() for CVS */
-#define RUN_NORMAL 0x0000 /* no special behaviour */
-#define RUN_COMBINED 0x0001 /* stdout is duped to stderr */
-#define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */
-#define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */
-#define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */
-#define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */
-#define RUN_TTY (char *)0 /* for the benefit of lint */
-
-/* Flags for find_{names,dirs} routines */
-#define W_LOCAL 0x01 /* look for files locally */
-#define W_REPOS 0x02 /* look for files in the repository */
-#define W_ATTIC 0x04 /* look for files in the attic */
-
-/* Flags for return values of direnter procs for the recursion processor */
-enum direnter_type
-{
- R_PROCESS = 1, /* process files and maybe dirs */
- R_SKIP_FILES, /* don't process files in this dir */
- R_SKIP_DIRS, /* don't process sub-dirs */
- R_SKIP_ALL /* don't process files or dirs */
-};
-typedef enum direnter_type Dtype;
-
-extern char *program_name, *command_name;
-extern char *Rcsbin, *Editor, *CVSroot;
-extern char *CurDir;
-extern int really_quiet, quiet;
-extern int use_editor;
-extern int cvswrite;
-
-extern int trace; /* Show all commands */
-extern int noexec; /* Don't modify disk anywhere */
-extern int logoff; /* Don't write history entry */
-
-/* Externs that are included directly in the CVS sources */
-#if __STDC__
-int Reader_Lock (char *xrepository);
-DBM *open_module (void);
-FILE *Fopen (char *name, char *mode);
-FILE *open_file (char *name, char *mode);
-List *Find_Dirs (char *repository, int which);
-List *ParseEntries (int aflag);
-char *Make_Date (char *rawdate);
-char *Name_Repository (char *dir, char *update_dir);
-char *Short_Repository (char *repository);
-char *getcaller (void);
-char *time_stamp (char *file);
-char *xmalloc (int bytes);
-char *xrealloc (char *ptr, int bytes);
-char *xstrdup (char *str);
-int No_Difference (char *file, Vers_TS * vers, List * entries);
-int Parse_Info (char *infofile, char *repository, int (*callproc) (), int all);
-int Reader_Lock (char *xrepository);
-int SIG_register (int sig, SIGTYPE (*fn) ());
-int Writer_Lock (List * list);
-int gethostname (char *name, int namelen);
-int ign_name (char *name);
-int isdir (char *file);
-int isfile (char *file);
-int islink (char *file);
-int isreadable (char *file);
-int iswritable (char *file);
-int link_file (char *from, char *to);
-int numdots (char *s);
-int run_exec (char *stin, char *stout, char *sterr, int flags);
-int unlink_file (char *f);
-int update (int argc, char *argv[]);
-int xcmp (char *file1, char *file2);
-int yesno (void);
-time_t get_date (char *date, struct timeb *now);
-void Create_Admin (char *dir, char *repository, char *tag, char *date);
-void Lock_Cleanup (void);
-void ParseTag (char **tagp, char **datep);
-void Scratch_Entry (List * list, char *fname);
-void WriteTag (char *dir, char *tag, char *date);
-void cat_module (int status);
-void check_entries (char *dir);
-void close_module (DBM * db);
-void copy_file (char *from, char *to);
-void error (int status, int errnum, char *message,...);
-void fperror (FILE * fp, int status, int errnum, char *message,...);
-void free_names (int *pargc, char *argv[]);
-void freevers_ts (Vers_TS ** versp);
-void ign_add (char *ign, int hold);
-void ign_add_file (char *file, int hold);
-void ign_setup (void);
-void line2argv (int *pargc, char *argv[], char *line);
-void make_directories (char *name);
-void make_directory (char *name);
-void rename_file (char *from, char *to);
-void run_arg (char *s);
-void run_args (char *fmt,...);
-void run_print (FILE * fp);
-void run_setup (char *fmt,...);
-void strip_path (char *path);
-void update_delproc (Node * p);
-void usage (char **cpp);
-void xchmod (char *fname, int writable);
-int Checkin (int type, char *file, char *repository, char *rcs, char *rev,
- char *tag, char *message, List * entries);
-Ctype Classify_File (char *file, char *tag, char *date, char *options,
- int force_tag_match, int aflag, char *repository,
- List *entries, List *srcfiles, Vers_TS **versp);
-List *Find_Names (char *repository, int which, int aflag,
- List ** optentries);
-void Register (List * list, char *fname, char *vn, char *ts,
- char *options, char *tag, char *date);
-void Update_Logfile (char *repository, char *xmessage, char *xrevision,
- FILE * xlogfp, List * xchanges);
-Vers_TS *Version_TS (char *repository, char *options, char *tag,
- char *date, char *user, int force_tag_match,
- int set_time, List * entries, List * xfiles);
-void do_editor (char *dir, char *message, char *repository,
- List * changes);
-int do_module (DBM * db, char *mname, enum mtype m_type, char *msg,
- int (*callback_proc) (), char *where, int shorten,
- int local_specified, int run_module_prog, char *extra_arg);
-int do_recursion (int (*xfileproc) (), int (*xfilesdoneproc) (),
- Dtype (*xdirentproc) (), int (*xdirleaveproc) (),
- Dtype xflags, int xwhich, int xaflag, int xreadlock,
- int xdosrcs);
-int do_update (int argc, char *argv[], char *xoptions, char *xtag,
- char *xdate, int xforce, int local, int xbuild,
- int xaflag, int xprune, int xpipeout, int which,
- char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir);
-void history_write (int type, char *update_dir, char *revs, char *name,
- char *repository);
-int start_recursion (int (*fileproc) (), int (*filesdoneproc) (),
- Dtype (*direntproc) (), int (*dirleaveproc) (),
- int argc, char *argv[], int local, int which,
- int aflag, int readlock, char *update_preload,
- int dosrcs);
-void SIG_beginCrSect ();
-void SIG_endCrSect ();
-#else /* !__STDC__ */
-DBM *open_module ();
-FILE *Fopen ();
-FILE *open_file ();
-List *Find_Dirs ();
-List *Find_Names ();
-List *ParseEntries ();
-Vers_TS *Version_TS ();
-char *Make_Date ();
-char *Name_Repository ();
-char *Short_Repository ();
-char *getcaller ();
-char *time_stamp ();
-char *xmalloc ();
-char *xrealloc ();
-char *xstrdup ();
-int Checkin ();
-Ctype Classify_File ();
-int No_Difference ();
-int Parse_Info ();
-int Reader_Lock ();
-int SIG_register ();
-int Writer_Lock ();
-int do_module ();
-int do_recursion ();
-int do_update ();
-int gethostname ();
-int ign_name ();
-int isdir ();
-int isfile ();
-int islink ();
-int isreadable ();
-int iswritable ();
-int link_file ();
-int numdots ();
-int run_exec ();
-int start_recursion ();
-int unlink_file ();
-int update ();
-int xcmp ();
-int yesno ();
-time_t get_date ();
-void Create_Admin ();
-void Lock_Cleanup ();
-void ParseTag ();
-void ParseTag ();
-void Register ();
-void Scratch_Entry ();
-void Update_Logfile ();
-void WriteTag ();
-void cat_module ();
-void check_entries ();
-void close_module ();
-void copy_file ();
-void do_editor ();
-void error ();
-void fperror ();
-void free_names ();
-void freevers_ts ();
-void history_write ();
-void ign_add ();
-void ign_add_file ();
-void ign_setup ();
-void line2argv ();
-void make_directories ();
-void make_directory ();
-void rename_file ();
-void run_arg ();
-void run_args ();
-void run_print ();
-void run_setup ();
-void strip_path ();
-void update_delproc ();
-void usage ();
-void xchmod ();
-void SIG_beginCrSect ();
-void SIG_endCrSect ();
-#endif /* __STDC__ */
diff --git a/gnu/usr.bin/cvs/cvs/diff.c b/gnu/usr.bin/cvs/cvs/diff.c
deleted file mode 100644
index db8b4b7..0000000
--- a/gnu/usr.bin/cvs/cvs/diff.c
+++ /dev/null
@@ -1,407 +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.3 kit.
- *
- * Difference
- *
- * Run diff against versions in the repository. Options that are specified are
- * passed on directly to "rcsdiff".
- *
- * Without any file arguments, runs diff against all the currently modified
- * files.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)diff.c 1.52 92/04/10";
-#endif
-
-#if __STDC__
-static Dtype diff_dirproc (char *dir, char *pos_repos, char *update_dir);
-static int diff_dirleaveproc (char *dir, int err, char *update_dir);
-static int diff_file_nodiff (char *file, char *repository, List *entries,
- List *srcfiles, Vers_TS *vers);
-static int diff_fileproc (char *file, char *update_dir, char *repository,
- List * entries, List * srcfiles);
-static void diff_mark_errors (int err);
-#else
-static int diff_fileproc ();
-static Dtype diff_dirproc ();
-static int diff_dirleaveproc ();
-static int diff_file_nodiff ();
-static void diff_mark_errors ();
-#endif /* __STDC__ */
-
-static char *diff_rev1, *diff_rev2;
-static char *diff_date1, *diff_date2;
-static char *use_rev1, *use_rev2;
-static char *options;
-static char opts[PATH_MAX];
-static int diff_errors;
-
-static char *diff_usage[] =
-{
- "Usage: %s %s [-l] [rcsdiff-options]\n",
-#ifdef CVS_DIFFDATE
- " [[-r rev1 | -D date1] [-r rev2 | -D date2]] [files...] \n",
-#else
- " [-r rev1 [-r rev2]] [files...] \n",
-#endif
- "\t-l\tLocal directory only, not recursive\n",
- "\t-D d1\tDiff revision for date against working file.\n",
- "\t-D d2\tDiff rev1/date1 against date2.\n",
- "\t-r rev1\tDiff revision for rev1 against working file.\n",
- "\t-r rev2\tDiff rev1/date1 against rev2.\n",
- NULL
-};
-
-int
-diff (argc, argv)
- int argc;
- char *argv[];
-{
- char tmp[50];
- int c, err = 0;
- int local = 0;
-
- if (argc == -1)
- usage (diff_usage);
-
- /*
- * Note that we catch all the valid arguments here, so that we can
- * intercept the -r arguments for doing revision diffs; and -l/-R for a
- * non-recursive/recursive diff.
- */
- optind = 1;
- while ((c = gnu_getopt (argc, argv,
- "abcdefhilnpqtuw0123456789BHQRTC:D:F:I:L:V:k:r:")) != -1)
- {
- switch (c)
- {
- 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': case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': case 'B':
- case 'H': case 'T': case 'Q':
- (void) sprintf (tmp, " -%c", (char) c);
- (void) strcat (opts, tmp);
- if (c == 'Q')
- {
- quiet = 1;
- really_quiet = 1;
- c = 'q';
- }
- break;
- case 'C': case 'F': case 'I': case 'L': case 'V':
-#ifndef CVS_DIFFDATE
- case 'D':
-#endif
- (void) sprintf (tmp, " -%c%s", (char) c, optarg);
- (void) strcat (opts, tmp);
- break;
- case 'R':
- local = 0;
- break;
- case 'l':
- local = 1;
- break;
- case 'q':
- quiet = 1;
- break;
- case 'k':
- if (options)
- free (options);
- options = RCS_check_kflag (optarg);
- break;
- case 'r':
- if (diff_rev2 != NULL || diff_date2 != NULL)
- error (1, 0,
- "no more than two revisions/dates can be specified");
- if (diff_rev1 != NULL || diff_date1 != NULL)
- diff_rev2 = optarg;
- else
- diff_rev1 = optarg;
- break;
-#ifdef CVS_DIFFDATE
- case 'D':
- if (diff_rev2 != NULL || diff_date2 != NULL)
- error (1, 0,
- "no more than two revisions/dates can be specified");
- if (diff_rev1 != NULL || diff_date1 != NULL)
- diff_date2 = Make_Date (optarg);
- else
- diff_date1 = Make_Date (optarg);
- break;
-#endif
- case '?':
- default:
- usage (diff_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- /* make sure options is non-null */
- if (!options)
- options = xstrdup ("");
-
- /* start the recursion processor */
- err = start_recursion (diff_fileproc, (int (*) ()) NULL, diff_dirproc,
- diff_dirleaveproc, argc, argv, local,
- W_LOCAL, 0, 1, (char *) NULL, 1);
-
- /* clean up */
- free (options);
- return (err);
-}
-
-/*
- * Do a file diff
- */
-/* ARGSUSED */
-static int
-diff_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- int status, err = 2; /* 2 == trouble, like rcsdiff */
- Vers_TS *vers;
-
- vers = Version_TS (repository, (char *) NULL, (char *) NULL, (char *) NULL,
- file, 1, 0, entries, srcfiles);
-
- if (vers->vn_user == NULL)
- {
- error (0, 0, "I know nothing about %s", file);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
- }
- else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
- {
- error (0, 0, "%s is a new entry, no comparison available", file);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
- }
- else if (vers->vn_user[0] == '-')
- {
- error (0, 0, "%s was removed, no comparison available", file);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
- }
- else
- {
- if (vers->vn_rcs == NULL && vers->srcfile == NULL)
- {
- error (0, 0, "cannot find revision control file for %s", file);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
- }
- else
- {
- if (vers->ts_user == NULL)
- {
- error (0, 0, "cannot find %s", file);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
- }
- }
- }
-
- if (diff_file_nodiff (file, repository, entries, srcfiles, vers))
- {
- freevers_ts (&vers);
- return (0);
- }
-
- (void) fflush (stdout);
- if (use_rev2)
- {
- run_setup ("%s%s %s %s -r%s -r%s", Rcsbin, RCS_DIFF,
- opts, *options ? options : vers->options,
- use_rev1, use_rev2);
- }
- else
- {
- run_setup ("%s%s %s %s -r%s", Rcsbin, RCS_DIFF, opts,
- *options ? options : vers->options, use_rev1);
- }
- run_arg (vers->srcfile->path);
-
- switch ((status = run_exec (RUN_TTY, RUN_TTY, RUN_TTY,
- RUN_REALLY|RUN_COMBINED)))
- {
- case -1: /* fork failed */
- error (1, errno, "fork failed during rcsdiff of %s",
- vers->srcfile->path);
- case 0: /* everything ok */
- err = 0;
- break;
- default: /* other error */
- err = status;
- break;
- }
-
- (void) fflush (stdout);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
-}
-
-/*
- * Remember the exit status for each file.
- */
-static void
-diff_mark_errors (err)
- int err;
-{
- if (err > diff_errors)
- diff_errors = err;
-}
-
-/*
- * Print a warm fuzzy message when we enter a dir
- */
-/* ARGSUSED */
-static Dtype
-diff_dirproc (dir, pos_repos, update_dir)
- char *dir;
- char *pos_repos;
- char *update_dir;
-{
- /* XXX - check for dirs we don't want to process??? */
- if (!quiet)
- error (0, 0, "Diffing %s", update_dir);
- return (R_PROCESS);
-}
-
-/*
- * Concoct the proper exit status.
- */
-/* ARGSUSED */
-static int
-diff_dirleaveproc (dir, err, update_dir)
- char *dir;
- int err;
- char *update_dir;
-{
- return (diff_errors);
-}
-
-/*
- * verify that a file is different 0=same 1=different
- */
-static int
-diff_file_nodiff (file, repository, entries, srcfiles, vers)
- char *file;
- char *repository;
- List *entries;
- List *srcfiles;
- Vers_TS *vers;
-{
- Vers_TS *xvers;
- char tmp[L_tmpnam+1];
-
- /* free up any old use_rev* variables and reset 'em */
- if (use_rev1)
- free (use_rev1);
- if (use_rev2)
- free (use_rev2);
- use_rev1 = use_rev2 = (char *) NULL;
-
- if (diff_rev1 || diff_date1)
- {
- /* special handling for TAG_HEAD */
- if (diff_rev1 && strcmp (diff_rev1, TAG_HEAD) == 0)
- use_rev1 = xstrdup (vers->vn_rcs);
- else
- {
- xvers = Version_TS (repository, (char *) NULL, diff_rev1,
- diff_date1, file, 1, 0, entries, srcfiles);
- if (xvers->vn_rcs == NULL)
- {
- if (diff_rev1)
- error (0, 0, "tag %s is not in file %s", diff_rev1, file);
- else
- error (0, 0, "no revision for date %s in file %s",
- diff_date1, file);
- return (1);
- }
- use_rev1 = xstrdup (xvers->vn_rcs);
- freevers_ts (&xvers);
- }
- }
- if (diff_rev2 || diff_date2)
- {
- /* special handling for TAG_HEAD */
- if (diff_rev2 && strcmp (diff_rev2, TAG_HEAD) == 0)
- use_rev2 = xstrdup (vers->vn_rcs);
- else
- {
- xvers = Version_TS (repository, (char *) NULL, diff_rev2,
- diff_date2, file, 1, 0, entries, srcfiles);
- if (xvers->vn_rcs == NULL)
- {
- if (diff_rev1)
- error (0, 0, "tag %s is not in file %s", diff_rev2, file);
- else
- error (0, 0, "no revision for date %s in file %s",
- diff_date2, file);
- return (1);
- }
- use_rev2 = xstrdup (xvers->vn_rcs);
- freevers_ts (&xvers);
- }
-
- /* now, see if we really need to do the diff */
- return (strcmp (use_rev1, use_rev2) == 0);
- }
- if (use_rev1 == NULL || strcmp (use_rev1, vers->vn_user) == 0)
- {
- if (strcmp (vers->ts_rcs, vers->ts_user) == 0 &&
- (!(*options) || strcmp (options, vers->options) == 0))
- {
- return (1);
- }
- if (use_rev1 == NULL)
- use_rev1 = xstrdup (vers->vn_user);
- }
-
- /*
- * with 0 or 1 -r option specified, run a quick diff to see if we
- * should bother with it at all.
- */
- run_setup ("%s%s -p -q %s -r%s", Rcsbin, RCS_CO,
- *options ? options : vers->options, use_rev1);
- run_arg (vers->srcfile->path);
- switch (run_exec (RUN_TTY, tmpnam (tmp), RUN_TTY, RUN_REALLY))
- {
- case 0: /* everything ok */
- if (xcmp (file, tmp) == 0)
- {
- (void) unlink (tmp);
- return (1);
- }
- break;
- case -1: /* fork failed */
- (void) unlink (tmp);
- error (1, errno, "fork failed during checkout of %s",
- vers->srcfile->path);
- default:
- break;
- }
- (void) unlink (tmp);
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/entries.c b/gnu/usr.bin/cvs/cvs/entries.c
deleted file mode 100644
index 6453e4f..0000000
--- a/gnu/usr.bin/cvs/cvs/entries.c
+++ /dev/null
@@ -1,488 +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.3 kit.
- *
- * Entries file to Files file
- *
- * Creates the file Files containing the names that comprise the project, from
- * the Entries file.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)entries.c 1.37 92/03/31";
-#endif
-
-#if __STDC__
-static Node *AddEntryNode (List * list, char *name, char *version,
- char *timestamp, char *options, char *tag,
- char *date);
-#else
-static Node *AddEntryNode ();
-#endif /* __STDC__ */
-
-static FILE *entfile;
-static char *entfilename; /* for error messages */
-
-/*
- * Write out the line associated with a node of an entries file
- */
-static int
-write_ent_proc (node)
- Node *node;
-{
- Entnode *p;
-
- p = (Entnode *) node->data;
- if (fprintf (entfile, "/%s/%s/%s/%s/", node->key, p->version,
- p->timestamp, p->options) == EOF)
- error (1, errno, "cannot write %s", entfilename);
- if (p->tag)
- {
- if (fprintf (entfile, "T%s\n", p->tag) == EOF)
- error (1, errno, "cannot write %s", entfilename);
- }
- else if (p->date)
- {
- if (fprintf (entfile, "D%s\n", p->date) == EOF)
- error (1, errno, "cannot write %s", entfilename);
- }
- else if (fprintf (entfile, "\n") == EOF)
- error (1, errno, "cannot write %s", entfilename);
- return (0);
-}
-
-/*
- * write out the current entries file given a list, making a backup copy
- * first of course
- */
-static void
-write_entries (list)
- List *list;
-{
- /* open the new one and walk the list writing entries */
- entfilename = CVSADM_ENTBAK;
- entfile = open_file (entfilename, "w+");
- (void) walklist (list, write_ent_proc);
- if (fclose (entfile) == EOF)
- error (1, errno, "error closing %s", entfilename);
-
- /* now, atomically (on systems that support it) rename it */
- rename_file (entfilename, CVSADM_ENT);
-}
-
-/*
- * Removes the argument file from the Entries file if necessary.
- */
-void
-Scratch_Entry (list, fname)
- List *list;
- char *fname;
-{
- Node *node;
-
- if (trace)
- (void) fprintf (stderr, "-> Scratch_Entry(%s)\n", fname);
-
- /* hashlookup to see if it is there */
- if ((node = findnode (list, fname)) != NULL)
- {
- delnode (node); /* delete the node */
- if (!noexec)
- write_entries (list); /* re-write the file */
- }
-}
-
-/*
- * Enters the given file name/version/time-stamp into the Entries file,
- * removing the old entry first, if necessary.
- */
-void
-Register (list, fname, vn, ts, options, tag, date)
- List *list;
- char *fname;
- char *vn;
- char *ts;
- char *options;
- char *tag;
- char *date;
-{
- Node *node;
-
- if (trace)
- (void) fprintf (stderr, "-> Register(%s, %s, %s, %s, %s %s)\n",
- fname, vn, ts, options, tag ? tag : "",
- date ? date : "");
- /* was it already there? */
- if ((node = findnode (list, fname)) != NULL)
- {
- /* take it out */
- delnode (node);
-
- /* add the new one and re-write the file */
- (void) AddEntryNode (list, fname, vn, ts, options, tag, date);
- if (!noexec)
- write_entries (list);
- }
- else
- {
- /* add the new one */
- node = AddEntryNode (list, fname, vn, ts, options, tag, date);
-
- if (!noexec)
- {
- /* append it to the end */
- entfilename = CVSADM_ENT;
- entfile = open_file (entfilename, "a");
- (void) write_ent_proc (node);
- if (fclose (entfile) == EOF)
- error (1, errno, "error closing %s", entfilename);
- }
- }
-}
-
-/*
- * Node delete procedure for list-private sticky dir tag/date info
- */
-static void
-freesdt (p)
- Node *p;
-{
- struct stickydirtag *sdtp;
-
- sdtp = (struct stickydirtag *) p->data;
- if (sdtp->tag)
- free (sdtp->tag);
- if (sdtp->date)
- free (sdtp->date);
- if (sdtp->options)
- free (sdtp->options);
- free ((char *) sdtp);
-}
-
-/*
- * Read the entries file into a list, hashing on the file name.
- */
-List *
-ParseEntries (aflag)
- int aflag;
-{
- List *entries;
- char line[MAXLINELEN];
- char *cp, *user, *vn, *ts, *options;
- char *tag_or_date, *tag, *date;
- char *dirtag, *dirdate;
- int lineno = 0;
- FILE *fpin;
-
- /* get a fresh list... */
- entries = getlist ();
-
- /*
- * Parse the CVS/Tag file, to get any default tag/date settings. Use
- * list-private storage to tuck them away for Version_TS().
- */
- ParseTag (&dirtag, &dirdate);
- if (aflag || dirtag || dirdate)
- {
- struct stickydirtag *sdtp;
-
- sdtp = (struct stickydirtag *) xmalloc (sizeof (*sdtp));
- bzero ((char *) sdtp, sizeof (*sdtp));
- sdtp->aflag = aflag;
- sdtp->tag = xstrdup (dirtag);
- sdtp->date = xstrdup (dirdate);
-
- /* feed it into the list-private area */
- entries->list->data = (char *) sdtp;
- entries->list->delproc = freesdt;
- }
-
- again:
- fpin = fopen (CVSADM_ENT, "r");
- if (fpin == NULL)
- error (0, errno, "cannot open %s for reading", CVSADM_ENT);
- else
- {
- while (fgets (line, sizeof (line), fpin) != NULL)
- {
- lineno++;
- if (line[0] == '/')
- {
- user = line + 1;
- if ((cp = index (user, '/')) == NULL)
- continue;
- *cp++ = '\0';
- vn = cp;
- if ((cp = index (vn, '/')) == NULL)
- continue;
- *cp++ = '\0';
- ts = cp;
- if ((cp = index (ts, '/')) == NULL)
- continue;
- *cp++ = '\0';
- options = cp;
- if ((cp = index (options, '/')) == NULL)
- continue;
- *cp++ = '\0';
- tag_or_date = cp;
- if ((cp = index (tag_or_date, '\n')) == NULL)
- continue;
- *cp = '\0';
- tag = (char *) NULL;
- date = (char *) NULL;
- if (*tag_or_date == 'T')
- tag = tag_or_date + 1;
- else if (*tag_or_date == 'D')
- date = tag_or_date + 1;
- (void) AddEntryNode (entries, user, vn, ts, options, tag, date);
- }
- else
- {
- /* try conversion only on first line */
- if (lineno == 1)
- {
- (void) fclose (fpin);
- check_entries ((char *) NULL);
- goto again;
- }
- }
- }
- }
-
- /* clean up and return */
- if (fpin)
- (void) fclose (fpin);
- if (dirtag)
- free (dirtag);
- if (dirdate)
- free (dirdate);
- return (entries);
-}
-
-/*
- * Look at the entries file to determine if it is in the old entries format.
- * If so, convert it to the new format.
- */
-void
-check_entries (dir)
- char *dir;
-{
- FILE *fpin, *fpout;
- char tmp[MAXLINELEN];
- char line[MAXLINELEN];
- char entname[MAXLINELEN];
- char entbak[MAXLINELEN];
- char *cp, *user, *rev, *ts, *opt;
-
- if (dir != NULL)
- {
- (void) sprintf (entname, "%s/%s", dir, CVSADM_ENT);
- (void) sprintf (entbak, "%s/%s", dir, CVSADM_ENTBAK);
- }
- else
- {
- (void) strcpy (entname, CVSADM_ENT);
- (void) strcpy (entbak, CVSADM_ENTBAK);
- }
-
- fpin = open_file (entname, "r");
- if (fgets (line, sizeof (line), fpin) == NULL)
- {
- (void) fclose (fpin);
- return;
- }
- (void) fclose (fpin);
- if (line[0] != '/')
- {
- rename_file (entname, entbak);
- fpin = open_file (entbak, "r");
- fpout = open_file (entname, "w+");
- while (fgets (line, sizeof (line), fpin) != NULL)
- {
- if (line[0] == '/')
- {
- if (fputs (line, fpout) == EOF)
- error (1, errno, "cannot write %s", CVSADM_ENT);
- continue;
- }
- rev = line;
- if ((ts = index (line, '|')) == NULL)
- continue;
- *ts++ = '\0';
- if ((user = rindex (ts, ' ')) == NULL)
- continue;
- *user++ = '\0';
- if ((cp = index (user, '|')) == NULL)
- continue;
- *cp = '\0';
- opt = "";
-#ifdef HAVE_RCS5
-#ifdef HAD_RCS4
- opt = "-V4";
-#endif
-#endif
- if (fprintf (fpout, "/%s/%s/%s/%s/\n", user, rev, ts, opt) == EOF)
- error (1, errno, "cannot write %s", CVSADM_ENT);
- }
- (void) fclose (fpin);
- if (fclose (fpout) == EOF)
- error (1, errno, "cannot close %s", entname);
-
- /* clean up any old Files or Mod files */
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_FILE);
- else
- (void) strcpy (tmp, CVSADM_FILE);
- if (isfile (tmp))
- (void) unlink (tmp);
-
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_MOD);
- else
- (void) strcpy (tmp, CVSADM_MOD);
- if (isfile (tmp))
- (void) unlink (tmp);
- }
-}
-
-/*
- * Free up the memory associated with the data section of an ENTRIES type
- * node
- */
-static void
-Entries_delproc (node)
- Node *node;
-{
- Entnode *p;
-
- p = (Entnode *) node->data;
- free (p->version);
- free (p->timestamp);
- free (p->options);
- if (p->tag)
- free (p->tag);
- if (p->date)
- free (p->date);
- free ((char *) p);
-}
-
-/*
- * Get an Entries file list node, initialize it, and add it to the specified
- * list
- */
-static Node *
-AddEntryNode (list, name, version, timestamp, options, tag, date)
- List *list;
- char *name;
- char *version;
- char *timestamp;
- char *options;
- char *tag;
- char *date;
-{
- Node *p;
- Entnode *entdata;
-
- /* get a node and fill in the regular stuff */
- p = getnode ();
- p->type = ENTRIES;
- p->delproc = Entries_delproc;
-
- /* this one gets a key of the name for hashing */
- p->key = xstrdup (name);
-
- /* malloc the data parts and fill them in */
- p->data = xmalloc (sizeof (Entnode));
- entdata = (Entnode *) p->data;
- entdata->version = xstrdup (version);
- entdata->timestamp = xstrdup (timestamp);
- entdata->options = xstrdup (options);
- if (entdata->options == NULL)
- entdata->options = xstrdup ("");/* must be non-NULL */
- entdata->tag = xstrdup (tag);
- entdata->date = xstrdup (date);
-
- /* put the node into the list */
- if (addnode (list, p) != 0)
- error (0, 0, "Duplicate filename in entries file (%s) -- ignored",
- name);
-
- return (p);
-}
-
-/*
- * Write out/Clear the CVS/Tag file.
- */
-void
-WriteTag (dir, tag, date)
- char *dir;
- char *tag;
- char *date;
-{
- FILE *fout;
- char tmp[PATH_MAX];
-
- if (noexec)
- return;
-
- if (dir == NULL)
- (void) strcpy (tmp, CVSADM_TAG);
- else
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_TAG);
-
- if (tag || date)
- {
- fout = open_file (tmp, "w+");
- if (tag)
- {
- if (fprintf (fout, "T%s\n", tag) == EOF)
- error (1, errno, "write to %s failed", tmp);
- }
- else
- {
- if (fprintf (fout, "D%s\n", date) == EOF)
- error (1, errno, "write to %s failed", tmp);
- }
- if (fclose (fout) == EOF)
- error (1, errno, "cannot close %s", tmp);
- }
- else
- (void) unlink_file (tmp);
-}
-
-/*
- * Parse the CVS/Tag file for the current directory.
- */
-void
-ParseTag (tagp, datep)
- char **tagp;
- char **datep;
-{
- FILE *fp;
- char line[MAXLINELEN];
- char *cp;
-
- if (tagp)
- *tagp = (char *) NULL;
- if (datep)
- *datep = (char *) NULL;
- fp = fopen (CVSADM_TAG, "r");
- if (fp)
- {
- if (fgets (line, sizeof (line), fp) != NULL)
- {
- if ((cp = rindex (line, '\n')) != NULL)
- *cp = '\0';
- if (*line == 'T' && tagp)
- *tagp = xstrdup (line + 1);
- else if (*line == 'D' && datep)
- *datep = xstrdup (line + 1);
- }
- (void) fclose (fp);
- }
-}
diff --git a/gnu/usr.bin/cvs/cvs/find_names.c b/gnu/usr.bin/cvs/cvs/find_names.c
deleted file mode 100644
index 187bd23..0000000
--- a/gnu/usr.bin/cvs/cvs/find_names.c
+++ /dev/null
@@ -1,272 +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.3 kit.
- *
- * Find Names
- *
- * Finds all the pertinent file names, both from the administration and from the
- * repository
- *
- * Find Dirs
- *
- * Finds all pertinent sub-directories of the checked out instantiation and the
- * repository (and optionally the attic)
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)find_names.c 1.38 92/04/10";
-#endif
-
-#if __STDC__
-static int find_dirs (char *dir, List * list, int checkadm);
-static int find_rcs (char *dir, List * list);
-#else
-static int find_rcs ();
-static int find_dirs ();
-#endif /* __STDC__ */
-
-static List *filelist;
-
-/*
- * add the key from entry on entries list to the files list
- */
-static int
-add_entries_proc (node)
- Node *node;
-{
- Node *fnode;
-
- fnode = getnode ();
- fnode->type = FILES;
- fnode->key = xstrdup (node->key);
- if (addnode (filelist, fnode) != 0)
- freenode (fnode);
- return (0);
-}
-
-/*
- * compare two files list node (for sort)
- */
-static int
-fsortcmp (p, q)
- Node *p, *q;
-{
- return (strcmp (p->key, q->key));
-}
-
-List *
-Find_Names (repository, which, aflag, optentries)
- char *repository;
- int which;
- int aflag;
- List **optentries;
-{
- List *entries;
- List *files;
- char dir[PATH_MAX];
-
- /* make a list for the files */
- files = filelist = getlist ();
-
- /* look at entries (if necessary) */
- if (which & W_LOCAL)
- {
- /* parse the entries file (if it exists) */
- entries = ParseEntries (aflag);
-
- if (entries != NULL)
- {
- /* walk the entries file adding elements to the files list */
- (void) walklist (entries, add_entries_proc);
-
- /* if our caller wanted the entries list, return it; else free it */
- if (optentries != NULL)
- *optentries = entries;
- else
- dellist (&entries);
- }
- }
-
- if ((which & W_REPOS) && repository && !isreadable (CVSADM_ENTSTAT))
- {
- /* search the repository */
- if (find_rcs (repository, files) != 0)
- error (1, errno, "cannot open directory %s", repository);
-
- /* search the attic too */
- if (which & W_ATTIC)
- {
- (void) sprintf (dir, "%s/%s", repository, CVSATTIC);
- (void) find_rcs (dir, files);
- }
- }
-
- /* sort the list into alphabetical order and return it */
- sortlist (files, fsortcmp);
- return (files);
-}
-
-/*
- * create a list of directories to traverse from the current directory
- */
-List *
-Find_Dirs (repository, which)
- char *repository;
- int which;
-{
- List *dirlist;
-
- /* make a list for the directories */
- dirlist = getlist ();
-
- /* find the local ones */
- if (which & W_LOCAL)
- {
- /* look only for CVS controlled sub-directories */
- if (find_dirs (".", dirlist, 1) != 0)
- error (1, errno, "cannot open current directory");
- }
-
- /* look for sub-dirs in the repository */
- if ((which & W_REPOS) && repository)
- {
- /* search the repository */
- if (find_dirs (repository, dirlist, 0) != 0)
- error (1, errno, "cannot open directory %s", repository);
-
-#ifdef ATTIC_DIR_SUPPORT /* XXX - FIXME */
- /* search the attic too */
- if (which & W_ATTIC)
- {
- char dir[PATH_MAX];
-
- (void) sprintf (dir, "%s/%s", repository, CVSATTIC);
- (void) find_dirs (dir, dirlist, 0);
- }
-#endif
- }
-
- /* sort the list into alphabetical order and return it */
- sortlist (dirlist, fsortcmp);
- return (dirlist);
-}
-
-/*
- * Finds all the ,v files in the argument directory, and adds them to the
- * files list. Returns 0 for success and non-zero if the argument directory
- * cannot be opened.
- */
-static int
-find_rcs (dir, list)
- char *dir;
- List *list;
-{
- Node *p;
- CONST char *regex_err;
- char line[50];
- struct direct *dp;
- DIR *dirp;
-
- /* set up to read the dir */
- if ((dirp = opendir (dir)) == NULL)
- return (1);
-
- /* set up a regular expression to find the ,v files */
- (void) sprintf (line, ".*%s$", RCSEXT);
- if ((regex_err = re_comp (line)) != NULL)
- error (1, 0, "%s", regex_err);
-
- /* read the dir, grabbing the ,v files */
- while ((dp = readdir (dirp)) != NULL)
- {
- if (re_exec (dp->d_name))
- {
- char *comma;
-
- comma = rindex (dp->d_name, ','); /* strip the ,v */
- *comma = '\0';
- p = getnode ();
- p->type = FILES;
- p->key = xstrdup (dp->d_name);
- if (addnode (list, p) != 0)
- freenode (p);
- }
- }
- (void) closedir (dirp);
- return (0);
-}
-
-/*
- * Finds all the subdirectories of the argument dir and adds them to the
- * specified list. Sub-directories without a CVS administration directory
- * are optionally ignored Returns 0 for success or 1 on error.
- */
-static int
-find_dirs (dir, list, checkadm)
- char *dir;
- List *list;
- int checkadm;
-{
- Node *p;
- CONST char *regex_err;
- char tmp[PATH_MAX];
- char admdir[PATH_MAX];
- struct direct *dp;
- DIR *dirp;
-
- /* build a regex to blow off ,v files */
- (void) sprintf (tmp, ".*%s$", RCSEXT);
- if ((regex_err = re_comp (tmp)) != NULL)
- error (1, 0, "%s", regex_err);
-
- /* set up to read the dir */
- if ((dirp = opendir (dir)) == NULL)
- return (1);
-
- /* read the dir, grabbing sub-dirs */
- while ((dp = readdir (dirp)) != NULL)
- {
- if (strcmp (dp->d_name, ".") == 0 ||
- strcmp (dp->d_name, "..") == 0 ||
- strcmp (dp->d_name, CVSATTIC) == 0 ||
- strcmp (dp->d_name, CVSLCK) == 0 ||
- re_exec (dp->d_name)) /* don't bother stating ,v files */
- continue;
-
- (void) sprintf (tmp, "%s/%s", dir, dp->d_name);
- if (isdir (tmp))
- {
- /* check for administration directories (if needed) */
- if (checkadm)
- {
- /* blow off symbolic links to dirs in local dir */
- if (islink (tmp))
- continue;
-
- /* check for new style */
- (void) sprintf (admdir, "%s/%s", tmp, CVSADM);
- if (!isdir (admdir))
- {
- /* and old style */
- (void) sprintf (admdir, "%s/%s", tmp, OCVSADM);
- if (!isdir (admdir))
- continue;
- }
- }
-
- /* put it in the list */
- p = getnode ();
- p->type = DIRS;
- p->key = xstrdup (dp->d_name);
- if (addnode (list, p) != 0)
- freenode (p);
- }
- }
- (void) closedir (dirp);
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/history.c b/gnu/usr.bin/cvs/cvs/history.c
deleted file mode 100644
index 9675c4c..0000000
--- a/gnu/usr.bin/cvs/cvs/history.c
+++ /dev/null
@@ -1,1373 +0,0 @@
-/*
- *
- * You may distribute under the terms of the GNU General Public License
- * as specified in the README file that comes with the CVS 1.0 kit.
- *
- * **************** History of Users and Module ****************
- *
- * LOGGING: Append record to "${CVSROOT}/CVSROOTADM/CVSROOTADM_HISTORY".
- *
- * On For each Tag, Add, Checkout, Commit, Update or Release command,
- * one line of text is written to a History log.
- *
- * X date | user | CurDir | special | rev(s) | argument '\n'
- *
- * where: [The spaces in the example line above are not in the history file.]
- *
- * X is a single character showing the type of event:
- * T "Tag" cmd.
- * O "Checkout" cmd.
- * F "Release" cmd.
- * W "Update" cmd - No User file, Remove from Entries file.
- * U "Update" cmd - File was checked out over User file.
- * G "Update" cmd - File was merged successfully.
- * C "Update" cmd - File was merged and shows overlaps.
- * M "Commit" cmd - "Modified" file.
- * A "Commit" cmd - "Added" file.
- * R "Commit" cmd - "Removed" file.
- *
- * date is a fixed length 8-char hex representation of a Unix time_t.
- * [Starting here, variable fields are delimited by '|' chars.]
- *
- * user is the username of the person who typed the command.
- *
- * CurDir The directory where the action occurred. This should be the
- * absolute path of the directory which is at the same level as
- * the "Repository" field (for W,U,G,C & M,A,R).
- *
- * Repository For record types [W,U,G,C,M,A,R] this field holds the
- * repository read from the administrative data where the
- * command was typed.
- * T "A" --> New Tag, "D" --> Delete Tag
- * Otherwise it is the Tag or Date to modify.
- * O,F A "" (null field)
- *
- * rev(s) Revision number or tag.
- * T The Tag to apply.
- * O The Tag or Date, if specified, else "" (null field).
- * F "" (null field)
- * W The Tag or Date, if specified, else "" (null field).
- * U The Revision checked out over the User file.
- * G,C The Revision(s) involved in merge.
- * M,A,R RCS Revision affected.
- *
- * argument The module (for [TOUF]) or file (for [WUGCMAR]) affected.
- *
- *
- *** Report categories: "User" and "Since" modifiers apply to all reports.
- * [For "sort" ordering see the "sort_order" routine.]
- *
- * Extract list of record types
- *
- * -e, -x [TOFWUGCMAR]
- *
- * Extracted records are simply printed, No analysis is performed.
- * All "field" modifiers apply. -e chooses all types.
- *
- * Checked 'O'ut modules
- *
- * -o, -w
- * Checked out modules. 'F' and 'O' records are examined and if
- * the last record for a repository/file is an 'O', a line is
- * printed. "-w" forces the "working dir" to be used in the
- * comparison instead of the repository.
- *
- * Committed (Modified) files
- *
- * -c, -l, -w
- * All 'M'odified, 'A'dded and 'R'emoved records are examined.
- * "Field" modifiers apply. -l forces a sort by file within user
- * and shows only the last modifier. -w works as in Checkout.
- *
- * Warning: Be careful with what you infer from the output of
- * "cvs hi -c -l". It means the last time *you*
- * changed the file, not the list of files for which
- * you were the last changer!!!
- *
- * Module history for named modules.
- * -m module, -l
- *
- * This is special. If one or more modules are specified, the
- * module names are remembered and the files making up the
- * modules are remembered. Only records matching exactly those
- * files and repositories are shown. Sorting by "module", then
- * filename, is implied. If -l ("last modified") is specified,
- * then "update" records (types WUCG), tag and release records
- * are ignored and the last (by date) "modified" record.
- *
- * TAG history
- *
- * -T All Tag records are displayed.
- *
- *** Modifiers.
- *
- * Since ... [All records contain a timestamp, so any report
- * category can be limited by date.]
- *
- * -D date - The "date" is parsed into a Unix "time_t" and
- * records with an earlier time stamp are ignored.
- * -r rev/tag - A "rev" begins with a digit. A "tag" does not. If
- * you use this option, every file is searched for the
- * indicated rev/tag.
- * -t tag - The "tag" is searched for in the history file and no
- * record is displayed before the tag is found. An
- * error is printed if the tag is never found.
- * -b string - Records are printed only back to the last reference
- * to the string in the "module", "file" or
- * "repository" fields.
- *
- * Field Selections [Simple comparisons on existing fields. All field
- * selections are repeatable.]
- *
- * -a - All users.
- * -u user - If no user is given and '-a' is not given, only
- * records for the user typing the command are shown.
- * ==> If -a or -u is not specified, just use "self".
- *
- * -f filematch - Only records in which the "file" field contains the
- * string "filematch" are considered.
- *
- * -p repository - Only records in which the "repository" string is a
- * prefix of the "repos" field are considered.
- *
- * -m modulename - Only records which contain "modulename" in the
- * "module" field are considered.
- *
- *
- * EXAMPLES: ("cvs history", "cvs his" or "cvs hi")
- *
- *** Checked out files for username. (default self, e.g. "dgg")
- * cvs hi [equivalent to: "cvs hi -o -u dgg"]
- * cvs hi -u user [equivalent to: "cvs hi -o -u user"]
- * cvs hi -o [equivalent to: "cvs hi -o -u dgg"]
- *
- *** Committed (modified) files from the beginning of the file.
- * cvs hi -c [-u user]
- *
- *** Committed (modified) files since Midnight, January 1, 1990:
- * cvs hi -c -D 'Jan 1 1990' [-u user]
- *
- *** Committed (modified) files since tag "TAG" was stored in the history file:
- * cvs hi -c -t TAG [-u user]
- *
- *** Committed (modified) files since tag "TAG" was placed on the files:
- * cvs hi -c -r TAG [-u user]
- *
- *** Who last committed file/repository X?
- * cvs hi -c -l -[fp] X
- *
- *** Modified files since tag/date/file/repos?
- * cvs hi -c {-r TAG | -D Date | -b string}
- *
- *** Tag history
- * cvs hi -T
- *
- *** History of file/repository/module X.
- * cvs hi -[fpn] X
- *
- *** History of user "user".
- * cvs hi -e -u user
- *
- *** Dump (eXtract) specified record types
- * cvs hi -x [TOFWUGCMAR]
- *
- *
- * FUTURE: J[Join], I[Import] (Not currently implemented.)
- *
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)history.c 1.31 92/04/10";
-#endif
-
-static struct hrec
-{
- char *type; /* Type of record (In history record) */
- char *user; /* Username (In history record) */
- char *dir; /* "Compressed" Working dir (In history record) */
- char *repos; /* (Tag is special.) Repository (In history record) */
- char *rev; /* Revision affected (In history record) */
- char *file; /* Filename (In history record) */
- char *end; /* Ptr into repository to copy at end of workdir */
- char *mod; /* The module within which the file is contained */
- time_t date; /* Calculated from date stored in record */
- int idx; /* Index of record, for "stable" sort. */
-} *hrec_head;
-
-
-#if __STDC__
-static char *fill_hrec (char *line, struct hrec * hr);
-static int accept_hrec (struct hrec * hr, struct hrec * lr);
-static int select_hrec (struct hrec * hr);
-static int sort_order (CONST PTR l, CONST PTR r);
-static int within (char *find, char *string);
-static time_t date_and_time (char *date_str);
-static void expand_modules (void);
-static void read_hrecs (char *fname);
-static void report_hrecs (void);
-static void save_file (char *dir, char *name, char *module);
-static void save_module (char *module);
-static void save_user (char *name);
-#else
-static int sort_order ();
-static time_t date_and_time ();
-static void save_user ();
-static void save_file ();
-static void save_module ();
-static void expand_modules ();
-static char *fill_hrec ();
-static void read_hrecs ();
-static int within ();
-static int select_hrec ();
-static void report_hrecs ();
-static int accept_hrec ();
-#endif /* __STDC__ */
-
-#define ALL_REC_TYPES "TOFWUCGMAR"
-#define USER_INCREMENT 2
-#define FILE_INCREMENT 128
-#define MODULE_INCREMENT 5
-#define HREC_INCREMENT 128
-
-static short report_count;
-
-static short extract;
-static short v_checkout;
-static short modified;
-static short tag_report;
-static short module_report;
-static short working;
-static short last_entry;
-static short all_users;
-
-static short user_sort;
-static short repos_sort;
-static short file_sort;
-static short module_sort;
-
-static time_t since_date;
-static char since_rev[20]; /* Maxrev ~= 99.99.99.999 */
-static char since_tag[64];
-static struct hrec *last_since_tag;
-static char backto[128];
-static struct hrec *last_backto;
-static char rec_types[20];
-
-static int hrec_count;
-static int hrec_max;
-
-static char **user_list; /* Ptr to array of ptrs to user names */
-static int user_max; /* Number of elements allocated */
-static int user_count; /* Number of elements used */
-
-static struct file_list_str
-{
- char *l_file;
- char *l_module;
-} *file_list; /* Ptr to array file name structs */
-static int file_max; /* Number of elements allocated */
-static int file_count; /* Number of elements used */
-
-static char **mod_list; /* Ptr to array of ptrs to module names */
-static int mod_max; /* Number of elements allocated */
-static int mod_count; /* Number of elements used */
-
-static int histsize;
-static char *histdata;
-static char *histfile; /* Ptr to the history file name */
-
-static char *history_usg[] =
-{
- "Usage: %s %s [-report] [-flags] [-options args] [files...]\n\n",
- " Reports:\n",
- " -T Produce report on all TAGs\n",
- " -c Committed (Modified) files\n",
- " -o Checked out modules\n",
- " -m <module> Look for specified module (repeatable)\n",
- " -x [TOFWUCGMAR] Extract by record type\n",
- " Flags:\n",
- " -a All users (Default is self)\n",
- " -e Everything (same as -x, but all record types)\n",
- " -l Last modified (committed or modified report)\n",
- " -w Working directory must match\n",
- " Options:\n",
- " -D <date> Since date (Many formats)\n",
- " -b <str> Back to record with str in module/file/repos field\n",
- " -f <file> Specified file (same as command line) (repeatable)\n",
- " -n <modulename> In module (repeatable)\n",
- " -p <repos> In repository (repeatable)\n",
- " -r <rev/tag> Since rev or tag (looks inside RCS files!)\n",
- " -t <tag> Since tag record placed in history file (by anyone).\n",
- " -u <user> For user name (repeatable)\n",
- NULL};
-
-/* Sort routine for qsort:
- - If a user is selected at all, sort it first. User-within-file is useless.
- - If a module was selected explicitly, sort next on module.
- - Then sort by file. "File" is "repository/file" unless "working" is set,
- then it is "workdir/file". (Revision order should always track date.)
- - Always sort timestamp last.
-*/
-static int
-sort_order (l, r)
- CONST PTR l;
- CONST PTR r;
-{
- int i;
- CONST struct hrec *left = (CONST struct hrec *) l;
- CONST struct hrec *right = (CONST struct hrec *) r;
-
- if (user_sort) /* If Sort by username, compare users */
- {
- if ((i = strcmp (left->user, right->user)) != 0)
- return (i);
- }
- if (module_sort) /* If sort by modules, compare module names */
- {
- if (left->mod && right->mod)
- if ((i = strcmp (left->mod, right->mod)) != 0)
- return (i);
- }
- if (repos_sort) /* If sort by repository, compare them. */
- {
- if ((i = strcmp (left->repos, right->repos)) != 0)
- return (i);
- }
- if (file_sort) /* If sort by filename, compare files, NOT dirs. */
- {
- if ((i = strcmp (left->file, right->file)) != 0)
- return (i);
-
- if (working)
- {
- if ((i = strcmp (left->dir, right->dir)) != 0)
- return (i);
-
- if ((i = strcmp (left->end, right->end)) != 0)
- return (i);
- }
- }
-
- /*
- * By default, sort by date, time
- * XXX: This fails after 2030 when date slides into sign bit
- */
- if ((i = ((long) (left->date) - (long) (right->date))) != 0)
- return (i);
-
- /* For matching dates, keep the sort stable by using record index */
- return (left->idx - right->idx);
-}
-
-static time_t
-date_and_time (date_str)
- char *date_str;
-{
- time_t t;
-
- t = get_date (date_str, (struct timeb *) NULL);
- if (t == (time_t) - 1)
- error (1, 0, "Can't parse date/time: %s", date_str);
- return (t);
-}
-
-int
-history (argc, argv)
- int argc;
- char **argv;
-{
- int i, c;
- char fname[PATH_MAX];
-
- if (argc == -1)
- usage (history_usg);
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "Tacelow?D:b:f:m:n:p:r:t:u:x:X:")) != -1)
- {
- switch (c)
- {
- case 'T': /* Tag list */
- report_count++;
- tag_report++;
- break;
- case 'a': /* For all usernames */
- all_users++;
- break;
- case 'c':
- report_count++;
- modified = 1;
- break;
- case 'e':
- report_count++;
- extract++;
- (void) strcpy (rec_types, ALL_REC_TYPES);
- break;
- case 'l': /* Find Last file record */
- last_entry = 1;
- break;
- case 'o':
- report_count++;
- v_checkout = 1;
- break;
- case 'w': /* Match Working Dir (CurDir) fields */
- working = 1;
- break;
- case 'X': /* Undocumented debugging flag */
- histfile = optarg;
- break;
- case 'D': /* Since specified date */
- if (*since_rev || *since_tag || *backto)
- {
- error (0, 0, "date overriding rev/tag/backto");
- *since_rev = *since_tag = *backto = '\0';
- }
- since_date = date_and_time (optarg);
- break;
- case 'b': /* Since specified file/Repos */
- if (since_date || *since_rev || *since_tag)
- {
- error (0, 0, "backto overriding date/rev/tag");
- *since_rev = *since_tag = '\0';
- since_date = 0;
- }
- if (strlen (optarg) >= sizeof (backto))
- {
- error (0, 0, "backto truncated to %d bytes",
- sizeof (backto) - 1);
- optarg[sizeof (backto) - 1] = '\0';
- }
- (void) strcpy (backto, optarg);
- break;
- case 'f': /* For specified file */
- save_file ("", optarg, (char *) NULL);
- break;
- case 'm': /* Full module report */
- report_count++;
- module_report++;
- case 'n': /* Look for specified module */
- save_module (optarg);
- break;
- case 'p': /* For specified directory */
- save_file (optarg, "", (char *) NULL);
- break;
- case 'r': /* Since specified Tag/Rev */
- if (since_date || *since_tag || *backto)
- {
- error (0, 0, "rev overriding date/tag/backto");
- *since_tag = *backto = '\0';
- since_date = 0;
- }
- (void) strcpy (since_rev, optarg);
- break;
- case 't': /* Since specified Tag/Rev */
- if (since_date || *since_rev || *backto)
- {
- error (0, 0, "tag overriding date/marker/file/repos");
- *since_rev = *backto = '\0';
- since_date = 0;
- }
- (void) strcpy (since_tag, optarg); /* tag */
- break;
- case 'u': /* For specified username */
- save_user (optarg);
- break;
- case 'x':
- report_count++;
- extract++;
- {
- char *cp;
-
- for (cp = optarg; *cp; cp++)
- if (!index (ALL_REC_TYPES, *cp))
- error (1, 0, "%c is not a valid report type", cp);
- }
- (void) strcpy (rec_types, optarg);
- break;
- case '?':
- default:
- usage (history_usg);
- break;
- }
- }
- c = optind; /* Save the handled option count */
-
- /* ================ Now analyze the arguments a bit */
- if (!report_count)
- v_checkout++;
- else if (report_count > 1)
- error (1, 0, "Only one report type allowed from: \"-Tcomx\".");
-
- if (all_users)
- save_user ("");
-
- if (mod_list)
- expand_modules ();
-
- if (tag_report)
- {
- if (!index (rec_types, 'T'))
- (void) strcat (rec_types, "T");
- }
- else if (extract)
- {
- if (user_list)
- user_sort++;
- }
- else if (modified)
- {
- (void) strcpy (rec_types, "MAR");
- /*
- * If the user has not specified a date oriented flag ("Since"), sort
- * by Repository/file before date. Default is "just" date.
- */
- if (!since_date && !*since_rev && !*since_tag && !*backto)
- {
- repos_sort++;
- file_sort++;
- /*
- * If we are not looking for last_modified and the user specified
- * one or more users to look at, sort by user before filename.
- */
- if (!last_entry && user_list)
- user_sort++;
- }
- }
- else if (module_report)
- {
- (void) strcpy (rec_types, last_entry ? "OMAR" : ALL_REC_TYPES);
- module_sort++;
- repos_sort++;
- file_sort++;
- working = 0; /* User's workdir doesn't count here */
- }
- else
- /* Must be "checkout" or default */
- {
- (void) strcpy (rec_types, "OF");
- /* See comments in "modified" above */
- if (!last_entry && user_list)
- user_sort++;
- if (!since_date && !*since_rev && !*since_tag && !*backto)
- file_sort++;
- }
-
- /* If no users were specified, use self (-a saves a universal ("") user) */
- if (!user_list)
- save_user (getcaller ());
-
- /* If we're looking back to a Tag value, must consider "Tag" records */
- if (*since_tag && !index (rec_types, 'T'))
- (void) strcat (rec_types, "T");
-
- argc -= c;
- argv += c;
- for (i = 0; i < argc; i++)
- save_file ("", argv[i], (char *) NULL);
-
- if (histfile)
- (void) strcpy (fname, histfile);
- else
- (void) sprintf (fname, "%s/%s/%s", CVSroot,
- CVSROOTADM, CVSROOTADM_HISTORY);
-
- read_hrecs (fname);
- qsort ((PTR) hrec_head, hrec_count, sizeof (struct hrec), sort_order);
- report_hrecs ();
-
- return (0);
-}
-
-void
-history_write (type, update_dir, revs, name, repository)
- int type;
- char *update_dir;
- char *revs;
- char *name;
- char *repository;
-{
- char fname[PATH_MAX], workdir[PATH_MAX], homedir[PATH_MAX];
- static char username[20]; /* !!! Should be global */
- FILE *fp;
- char *slash = "", *cp, *cp2, *repos;
- int i;
- static char *tilde = "";
- static char *PrCurDir = NULL;
-
- if (logoff) /* History is turned off by cmd line switch */
- return;
- (void) sprintf (fname, "%s/%s/%s", CVSroot, CVSROOTADM, CVSROOTADM_HISTORY);
-
- /* turn off history logging if the history file does not exist */
- if (!isfile (fname))
- {
- logoff = 1;
- return;
- }
-
- if (!(fp = Fopen (fname, "a"))) /* Some directory not there! */
- return;
-
- repos = Short_Repository (repository);
-
- if (!PrCurDir)
- {
- struct passwd *pw;
-
- (void) strcpy (username, getcaller ());
- PrCurDir = CurDir;
- if (!(pw = (struct passwd *) getpwnam (username)))
- error (0, 0, "cannot find own username");
- else
- {
- /* Assumes neither CurDir nor pw->pw_dir ends in '/' */
- i = strlen (pw->pw_dir);
- if (!strncmp (CurDir, pw->pw_dir, i))
- {
- PrCurDir += i; /* Point to '/' separator */
- tilde = "~";
- }
- else
- {
- /* Try harder to find a "homedir" */
- if (!getwd (workdir))
- error (1, errno, "can't getwd in history");
- if (chdir (pw->pw_dir) < 0)
- error (1, errno, "can't chdir(%s)", pw->pw_dir);
- if (!getwd (homedir))
- error (1, errno, "can't getwd in:", pw->pw_dir);
- (void) chdir (workdir);
-
- i = strlen (homedir);
- if (!strncmp (CurDir, homedir, i))
- {
- PrCurDir += i; /* Point to '/' separator */
- tilde = "~";
- }
- }
- }
- }
-
- if (type == 'T')
- {
- repos = update_dir;
- update_dir = "";
- }
- else if (update_dir && *update_dir)
- slash = "/";
- else
- update_dir = "";
-
- (void) sprintf (workdir, "%s%s%s%s", tilde, PrCurDir, slash, update_dir);
-
- /*
- * "workdir" is the directory where the file "name" is. ("^~" == $HOME)
- * "repos" is the Repository, relative to $CVSROOT where the RCS file is.
- *
- * "$workdir/$name" is the working file name.
- * "$CVSROOT/$repos/$name,v" is the RCS file in the Repository.
- *
- * First, note that the history format was intended to save space, not
- * to be human readable.
- *
- * The working file directory ("workdir") and the Repository ("repos")
- * usually end with the same one or more directory elements. To avoid
- * duplication (and save space), the "workdir" field ends with
- * an integer offset into the "repos" field. This offset indicates the
- * beginning of the "tail" of "repos", after which all characters are
- * duplicates.
- *
- * In other words, if the "workdir" field has a '*' (a very stupid thing
- * to put in a filename) in it, then every thing following the last '*'
- * is a hex offset into "repos" of the first character from "repos" to
- * append to "workdir" to finish the pathname.
- *
- * It might be easier to look at an example:
- *
- * M273b3463|dgg|~/work*9|usr/local/cvs/examples|1.2|loginfo
- *
- * Indicates that the workdir is really "~/work/cvs/examples", saving
- * 10 characters, where "~/work*d" would save 6 characters and mean that
- * the workdir is really "~/work/examples". It will mean more on
- * directories like: usr/local/gnu/emacs/dist-19.17/lisp/term
- *
- * "workdir" is always an absolute pathname (~/xxx is an absolute path)
- * "repos" is always a relative pathname. So we can assume that we will
- * never run into the top of "workdir" -- there will always be a '/' or
- * a '~' at the head of "workdir" that is not matched by anything in
- * "repos". On the other hand, we *can* run off the top of "repos".
- *
- * Only "compress" if we save characters.
- */
-
- if (!repos)
- repos = "";
-
- cp = workdir + strlen (workdir) - 1;
- cp2 = repos + strlen (repos) - 1;
- for (i = 0; cp2 >= repos && cp > workdir && *cp == *cp2--; cp--)
- i++;
-
- if (i > 2)
- {
- i = strlen (repos) - i;
- (void) sprintf ((cp + 1), "*%x", i);
- }
-
- if (fprintf (fp, "%c%08x|%s|%s|%s|%s|%s\n", type, time ((time_t *) NULL),
- username, workdir, repos, revs ? revs : "", name) == EOF)
- error (1, errno, "cannot write to history file: %s", fname);
- (void) fclose (fp);
-}
-
-/*
- * save_user() adds a user name to the user list to select. Zero-length
- * username ("") matches any user.
- */
-static void
-save_user (name)
- char *name;
-{
- if (user_count == user_max)
- {
- user_max += USER_INCREMENT;
- user_list = (char **) xrealloc ((char *) user_list,
- (int) user_max * sizeof (char *));
- }
- user_list[user_count++] = xstrdup (name);
-}
-
-/*
- * save_file() adds file name and associated module to the file list to select.
- *
- * If "dir" is null, store a file name as is.
- * If "name" is null, store a directory name with a '*' on the front.
- * Else, store concatenated "dir/name".
- *
- * Later, in the "select" stage:
- * - if it starts with '*', it is prefix-matched against the repository.
- * - if it has a '/' in it, it is matched against the repository/file.
- * - else it is matched against the file name.
- */
-static void
-save_file (dir, name, module)
- char *dir;
- char *name;
- char *module;
-{
- char *cp;
- struct file_list_str *fl;
-
- if (file_count == file_max)
- {
- file_max += FILE_INCREMENT;
- file_list = (struct file_list_str *) xrealloc ((char *) file_list,
- file_max * sizeof (*fl));
- }
- fl = &file_list[file_count++];
- fl->l_file = cp = xmalloc (strlen (dir) + strlen (name) + 2);
- fl->l_module = module;
-
- if (dir && *dir)
- {
- if (name && *name)
- {
- (void) strcpy (cp, dir);
- (void) strcat (cp, "/");
- (void) strcat (cp, name);
- }
- else
- {
- *cp++ = '*';
- (void) strcpy (cp, dir);
- }
- }
- else
- {
- if (name && *name)
- {
- (void) strcpy (cp, name);
- }
- else
- {
- error (0, 0, "save_file: null dir and file name");
- }
- }
-}
-
-static void
-save_module (module)
- char *module;
-{
- if (mod_count == mod_max)
- {
- mod_max += MODULE_INCREMENT;
- mod_list = (char **) xrealloc ((char *) mod_list,
- mod_max * sizeof (char *));
- }
- mod_list[mod_count++] = xstrdup (module);
-}
-
-static void
-expand_modules ()
-{
-}
-
-/* fill_hrec
- *
- * Take a ptr to 7-part history line, ending with a newline, for example:
- *
- * M273b3463|dgg|~/work*9|usr/local/cvs/examples|1.2|loginfo
- *
- * Split it into 7 parts and drop the parts into a "struct hrec".
- * Return a pointer to the character following the newline.
- */
-
-#define NEXT_BAR(here) do { while (isspace(*line)) line++; hr->here = line; while ((c = *line++) && c != '|') ; if (!c) return(rtn); *(line - 1) = '\0'; } while (0)
-
-static char *
-fill_hrec (line, hr)
- char *line;
- struct hrec *hr;
-{
- char *cp, *rtn;
- int c;
- int off;
- static int idx = 0;
-
- bzero ((char *) hr, sizeof (*hr));
- while (isspace (*line))
- line++;
- if (!(rtn = index (line, '\n')))
- return ("");
- *rtn++ = '\0';
-
- hr->type = line++;
- (void) sscanf (line, "%x", &hr->date);
- while (*line && index ("0123456789abcdefABCDEF", *line))
- line++;
- if (*line == '\0')
- return (rtn);
-
- line++;
- NEXT_BAR (user);
- NEXT_BAR (dir);
- if ((cp = rindex (hr->dir, '*')) != NULL)
- {
- *cp++ = '\0';
- (void) sscanf (cp, "%x", &off);
- hr->end = line + off;
- }
- else
- hr->end = line - 1; /* A handy pointer to '\0' */
- NEXT_BAR (repos);
- NEXT_BAR (rev);
- hr->idx = idx++;
- if (index ("FOT", *(hr->type)))
- hr->mod = line;
-
- NEXT_BAR (file); /* This returns ptr to next line or final '\0' */
- return (rtn); /* If it falls through, go on to next record */
-}
-
-/* read_hrecs's job is to read the history file and fill in all the "hrec"
- * (history record) array elements with the ones we need to print.
- *
- * Logic:
- * - Read the whole history file into a single buffer.
- * - Walk through the buffer, parsing lines out of the buffer.
- * 1. Split line into pointer and integer fields in the "next" hrec.
- * 2. Apply tests to the hrec to see if it is wanted.
- * 3. If it *is* wanted, bump the hrec pointer down by one.
- */
-static void
-read_hrecs (fname)
- char *fname;
-{
- char *cp, *cp2;
- int i, fd;
- struct hrec *hr;
- struct stat st_buf;
-
- if ((fd = open (fname, O_RDONLY)) < 0)
- error (1, errno, "cannot open history file: %s", fname);
-
- if (fstat (fd, &st_buf) < 0)
- error (1, errno, "can't stat history file");
-
- /* Exactly enough space for lines data */
- if (!(i = st_buf.st_size))
- error (1, 0, "history file is empty");
- histdata = cp = xmalloc (i + 2);
- histsize = i;
-
- if (read (fd, cp, i) != i)
- error (1, errno, "cannot read log file");
- (void) close (fd);
-
- if (*(cp + i - 1) != '\n')
- {
- *(cp + i) = '\n'; /* Make sure last line ends in '\n' */
- i++;
- }
- *(cp + i) = '\0';
- for (cp2 = cp; cp2 - cp < i; cp2++)
- {
- if (*cp2 != '\n' && !isprint (*cp2))
- *cp2 = ' ';
- }
-
- hrec_max = HREC_INCREMENT;
- hrec_head = (struct hrec *) xmalloc (hrec_max * sizeof (struct hrec));
-
- while (*cp)
- {
- if (hrec_count == hrec_max)
- {
- struct hrec *old_head = hrec_head;
-
- hrec_max += HREC_INCREMENT;
- hrec_head = (struct hrec *) xrealloc ((char *) hrec_head,
- hrec_max * sizeof (struct hrec));
- if (hrec_head != old_head)
- {
- if (last_since_tag)
- last_since_tag = hrec_head + (last_since_tag - old_head);
- if (last_backto)
- last_backto = hrec_head + (last_backto - old_head);
- }
- }
-
- hr = hrec_head + hrec_count;
- cp = fill_hrec (cp, hr); /* cp == next line or '\0' at end of buffer */
-
- if (select_hrec (hr))
- hrec_count++;
- }
-
- /* Special selection problem: If "since_tag" is set, we have saved every
- * record from the 1st occurrence of "since_tag", when we want to save
- * records since the *last* occurrence of "since_tag". So what we have
- * to do is bump hrec_head forward and reduce hrec_count accordingly.
- */
- if (last_since_tag)
- {
- hrec_count -= (last_since_tag - hrec_head);
- hrec_head = last_since_tag;
- }
-
- /* Much the same thing is necessary for the "backto" option. */
- if (last_backto)
- {
- hrec_count -= (last_backto - hrec_head);
- hrec_head = last_backto;
- }
-}
-
-/* Utility program for determining whether "find" is inside "string" */
-static int
-within (find, string)
- char *find, *string;
-{
- int c, len;
-
- if (!find || !string)
- return (0);
-
- c = *find++;
- len = strlen (find);
-
- while (*string)
- {
- if (!(string = index (string, c)))
- return (0);
- string++;
- if (!strncmp (find, string, len))
- return (1);
- }
- return (0);
-}
-
-/* The purpose of "select_hrec" is to apply the selection criteria based on
- * the command arguments and defaults and return a flag indicating whether
- * this record should be remembered for printing.
- */
-static int
-select_hrec (hr)
- struct hrec *hr;
-{
- char **cpp, *cp, *cp2;
- struct file_list_str *fl;
- int count;
-
- /* "Since" checking: The argument parser guarantees that only one of the
- * following four choices is set:
- *
- * 1. If "since_date" is set, it contains a Unix time_t specified on the
- * command line. hr->date fields earlier than "since_date" are ignored.
- * 2. If "since_rev" is set, it contains either an RCS "dotted" revision
- * number (which is of limited use) or a symbolic TAG. Each RCS file
- * is examined and the date on the specified revision (or the revision
- * corresponding to the TAG) in the RCS file (CVSROOT/repos/file) is
- * compared against hr->date as in 1. above.
- * 3. If "since_tag" is set, matching tag records are saved. The field
- * "last_since_tag" is set to the last one of these. Since we don't
- * know where the last one will be, all records are saved from the
- * first occurrence of the TAG. Later, at the end of "select_hrec"
- * records before the last occurrence of "since_tag" are skipped.
- * 4. If "backto" is set, all records with a module name or file name
- * matching "backto" are saved. In addition, all records with a
- * repository field with a *prefix* matching "backto" are saved.
- * The field "last_backto" is set to the last one of these. As in
- * 3. above, "select_hrec" adjusts to include the last one later on.
- */
- if (since_date)
- {
- if (hr->date < since_date)
- return (0);
- }
- else if (*since_rev)
- {
- Vers_TS *vers;
- time_t t;
-
- vers = Version_TS (hr->repos, (char *) NULL, since_rev, (char *) NULL,
- hr->file, 1, 0, (List *) NULL, (List *) NULL);
- if (vers->vn_rcs)
- {
- if ((t = RCS_getrevtime (vers->srcfile, vers->vn_rcs, (char *) 0, 0))
- != (time_t) 0)
- {
- if (hr->date < t)
- {
- freevers_ts (&vers);
- return (0);
- }
- }
- }
- freevers_ts (&vers);
- }
- else if (*since_tag)
- {
- if (*(hr->type) == 'T')
- {
- /*
- * A 'T'ag record, the "rev" field holds the tag to be set,
- * while the "repos" field holds "D"elete, "A"dd or a rev.
- */
- if (within (since_tag, hr->rev))
- {
- last_since_tag = hr;
- return (1);
- }
- else
- return (0);
- }
- if (!last_since_tag)
- return (0);
- }
- else if (*backto)
- {
- if (within (backto, hr->file) || within (backto, hr->mod) ||
- within (backto, hr->repos))
- last_backto = hr;
- else
- return (0);
- }
-
- /* User checking:
- *
- * Run down "user_list", match username ("" matches anything)
- * If "" is not there and actual username is not there, return failure.
- */
- if (user_list && hr->user)
- {
- for (cpp = user_list, count = user_count; count; cpp++, count--)
- {
- if (!**cpp)
- break; /* null user == accept */
- if (!strcmp (hr->user, *cpp)) /* found listed user */
- break;
- }
- if (!count)
- return (0); /* Not this user */
- }
-
- /* Record type checking:
- *
- * 1. If Record type is not in rec_types field, skip it.
- * 2. If mod_list is null, keep everything. Otherwise keep only modules
- * on mod_list.
- * 3. If neither a 'T', 'F' nor 'O' record, run through "file_list". If
- * file_list is null, keep everything. Otherwise, keep only files on
- * file_list, matched appropriately.
- */
- if (!index (rec_types, *(hr->type)))
- return (0);
- if (!index ("TFO", *(hr->type))) /* Don't bother with "file" if "TFO" */
- {
- if (file_list) /* If file_list is null, accept all */
- {
- for (fl = file_list, count = file_count; count; fl++, count--)
- {
- /* 1. If file_list entry starts with '*', skip the '*' and
- * compare it against the repository in the hrec.
- * 2. If file_list entry has a '/' in it, compare it against
- * the concatenation of the repository and file from hrec.
- * 3. Else compare the file_list entry against the hrec file.
- */
- char cmpfile[PATH_MAX];
-
- if (*(cp = fl->l_file) == '*')
- {
- cp++;
- /* if argument to -p is a prefix of repository */
- if (!strncmp (cp, hr->repos, strlen (cp)))
- {
- hr->mod = fl->l_module;
- break;
- }
- }
- else
- {
- if (index (cp, '/'))
- {
- (void) sprintf (cp2 = cmpfile, "%s/%s",
- hr->repos, hr->file);
- }
- else
- {
- cp2 = hr->file;
- }
-
- /* if requested file is found within {repos}/file fields */
- if (within (cp, cp2))
- {
- hr->mod = fl->l_module;
- break;
- }
- }
- }
- if (!count)
- return (0); /* String specified and no match */
- }
- }
- if (mod_list)
- {
- for (cpp = mod_list, count = mod_count; count; cpp++, count--)
- {
- if (hr->mod && !strcmp (hr->mod, *cpp)) /* found module */
- break;
- }
- if (!count)
- return (0); /* Module specified & this record is not one of them. */
- }
-
- return (1); /* Select this record unless rejected above. */
-}
-
-/* The "sort_order" routine (when handed to qsort) has arranged for the
- * hrecs files to be in the right order for the report.
- *
- * Most of the "selections" are done in the select_hrec routine, but some
- * selections are more easily done after the qsort by "accept_hrec".
- */
-static void
-report_hrecs ()
-{
- struct hrec *hr, *lr;
- struct tm *tm;
- int i, count, ty;
- char *cp;
- int user_len, file_len, rev_len, mod_len, repos_len;
-
- if (*since_tag && !last_since_tag)
- {
- (void) printf ("No tag found: %s\n", since_tag);
- return;
- }
- else if (*backto && !last_backto)
- {
- (void) printf ("No module, file or repository with: %s\n", backto);
- return;
- }
- else if (hrec_count < 1)
- {
- (void) printf ("No records selected.\n");
- return;
- }
-
- user_len = file_len = rev_len = mod_len = repos_len = 0;
-
- /* Run through lists and find maximum field widths */
- hr = lr = hrec_head;
- hr++;
- for (count = hrec_count; count--; lr = hr, hr++)
- {
- char repos[PATH_MAX];
-
- if (!count)
- hr = NULL;
- if (!accept_hrec (lr, hr))
- continue;
-
- ty = *(lr->type);
- (void) strcpy (repos, lr->repos);
- if ((cp = rindex (repos, '/')) != NULL)
- {
- if (lr->mod && !strcmp (++cp, lr->mod))
- {
- (void) strcpy (cp, "*");
- }
- }
- if ((i = strlen (lr->user)) > user_len)
- user_len = i;
- if ((i = strlen (lr->file)) > file_len)
- file_len = i;
- if (ty != 'T' && (i = strlen (repos)) > repos_len)
- repos_len = i;
- if (ty != 'T' && (i = strlen (lr->rev)) > rev_len)
- rev_len = i;
- if (lr->mod && (i = strlen (lr->mod)) > mod_len)
- mod_len = i;
- }
-
- /* Walk through hrec array setting "lr" (Last Record) to each element.
- * "hr" points to the record following "lr" -- It is NULL in the last
- * pass.
- *
- * There are two sections in the loop below:
- * 1. Based on the report type (e.g. extract, checkout, tag, etc.),
- * decide whether the record should be printed.
- * 2. Based on the record type, format and print the data.
- */
- for (lr = hrec_head, hr = (lr + 1); hrec_count--; lr = hr, hr++)
- {
- char workdir[PATH_MAX], repos[PATH_MAX];
-
- if (!hrec_count)
- hr = NULL;
- if (!accept_hrec (lr, hr))
- continue;
-
- ty = *(lr->type);
- tm = localtime (&(lr->date));
- (void) printf ("%c %02d/%02d %02d:%02d %-*s", ty, tm->tm_mon + 1,
- tm->tm_mday, tm->tm_hour, tm->tm_min, user_len, lr->user);
-
- (void) sprintf (workdir, "%s%s", lr->dir, lr->end);
- if ((cp = rindex (workdir, '/')) != NULL)
- {
- if (lr->mod && !strcmp (++cp, lr->mod))
- {
- (void) strcpy (cp, "*");
- }
- }
- (void) strcpy (repos, lr->repos);
- if ((cp = rindex (repos, '/')) != NULL)
- {
- if (lr->mod && !strcmp (++cp, lr->mod))
- {
- (void) strcpy (cp, "*");
- }
- }
-
- switch (ty)
- {
- case 'T':
- /* 'T'ag records: repository is a "tag type", rev is the tag */
- (void) printf (" %-*s [%s:%s]", mod_len, lr->mod, lr->rev,
- repos);
- if (working)
- (void) printf (" {%s}", workdir);
- break;
- case 'F':
- case 'O':
- if (lr->rev && *(lr->rev))
- (void) printf (" [%s]", lr->rev);
- (void) printf (" %-*s =%s%-*s %s", repos_len, repos, lr->mod,
- mod_len + 1 - strlen (lr->mod), "=", workdir);
- break;
- case 'W':
- case 'U':
- case 'C':
- case 'G':
- case 'M':
- case 'A':
- case 'R':
- (void) printf (" %-*s %-*s %-*s =%s= %s", rev_len, lr->rev,
- file_len, lr->file, repos_len, repos,
- lr->mod ? lr->mod : "", workdir);
- break;
- default:
- (void) printf ("Hey! What is this junk? RecType[0x%2.2x]", ty);
- break;
- }
- (void) putchar ('\n');
- }
-}
-
-static int
-accept_hrec (lr, hr)
- struct hrec *hr, *lr;
-{
- int ty;
-
- ty = *(lr->type);
-
- if (last_since_tag && ty == 'T')
- return (1);
-
- if (v_checkout)
- {
- if (ty != 'O')
- return (0); /* Only interested in 'O' records */
-
- /* We want to identify all the states that cause the next record
- * ("hr") to be different from the current one ("lr") and only
- * print a line at the allowed boundaries.
- */
-
- if (!hr || /* The last record */
- strcmp (hr->user, lr->user) || /* User has changed */
- strcmp (hr->mod, lr->mod) ||/* Module has changed */
- (working && /* If must match "workdir" */
- (strcmp (hr->dir, lr->dir) || /* and the 1st parts or */
- strcmp (hr->end, lr->end)))) /* the 2nd parts differ */
-
- return (1);
- }
- else if (modified)
- {
- if (!last_entry || /* Don't want only last rec */
- !hr || /* Last entry is a "last entry" */
- strcmp (hr->repos, lr->repos) || /* Repository has changed */
- strcmp (hr->file, lr->file))/* File has changed */
- return (1);
-
- if (working)
- { /* If must match "workdir" */
- if (strcmp (hr->dir, lr->dir) || /* and the 1st parts or */
- strcmp (hr->end, lr->end)) /* the 2nd parts differ */
- return (1);
- }
- }
- else if (module_report)
- {
- if (!last_entry || /* Don't want only last rec */
- !hr || /* Last entry is a "last entry" */
- strcmp (hr->mod, lr->mod) ||/* Module has changed */
- strcmp (hr->repos, lr->repos) || /* Repository has changed */
- strcmp (hr->file, lr->file))/* File has changed */
- return (1);
- }
- else
- {
- /* "extract" and "tag_report" always print selected records. */
- return (1);
- }
-
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/ignore.c b/gnu/usr.bin/cvs/cvs/ignore.c
deleted file mode 100644
index 74ab90c..0000000
--- a/gnu/usr.bin/cvs/cvs/ignore.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * .cvsignore file support contributed by David G. Grubbs <dgg@ksr.com>
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)ignore.c 1.13 92/04/03";
-#endif
-
-/*
- * Ignore file section.
- *
- * "!" may be included any time to reset the list (i.e. ignore nothing);
- * "*" may be specified to ignore everything. It stays as the first
- * element forever, unless a "!" clears it out.
- */
-
-static char **ign_list; /* List of files to ignore in update
- * and import */
-static char **s_ign_list = NULL;
-static int ign_count; /* Number of active entries */
-static int s_ign_count = 0;
-static int ign_size; /* This many slots available (plus
- * one for a NULL) */
-static int ign_hold; /* Index where first "temporary" item
- * is held */
-
-char *ign_default = ". .. core RCSLOG tags TAGS RCS SCCS .make.state .nse_depinfo #* .#* cvslog.* ,* CVS* .del-* *.a *.o *.so *.Z *~ *.old *.elc *.ln *.bak *.BAK *.orig *.rej";
-
-#define IGN_GROW 16 /* grow the list by 16 elements at a
- * time */
-
-/*
- * To the "ignore list", add the hard-coded default ignored wildcards above,
- * the wildcards found in $CVSROOT/CVSROOT/cvsignore, the wildcards found in
- * ~/.cvsignore and the wildcards found in the CVSIGNORE environment
- * variable.
- */
-void
-ign_setup ()
-{
- extern char *getenv ();
- struct passwd *pw;
- char file[PATH_MAX];
- char *tmp;
-
- /* Start with default list and special case */
- tmp = xstrdup (ign_default);
- ign_add (tmp, 0);
- free (tmp);
-
- /* Then add entries found in repository, if it exists */
- (void) sprintf (file, "%s/%s/%s", CVSroot, CVSROOTADM, CVSROOTADM_IGNORE);
- if (isfile (file))
- ign_add_file (file, 0);
-
- /* Then add entries found in home dir, (if user has one) and file exists */
- if ((pw = (struct passwd *) getpwuid (getuid ())) && pw->pw_dir)
- {
- (void) sprintf (file, "%s/%s", pw->pw_dir, CVSDOTIGNORE);
- if (isfile (file))
- ign_add_file (file, 0);
- }
-
- /* Then add entries found in CVSIGNORE environment variable. */
- ign_add (getenv (IGNORE_ENV), 0);
-
- /* Later, add ignore entries found in -I arguments */
-}
-
-/*
- * Open a file and read lines, feeding each line to a line parser. Arrange
- * for keeping a temporary list of wildcards at the end, if the "hold"
- * argument is set.
- */
-void
-ign_add_file (file, hold)
- char *file;
- int hold;
-{
- FILE *fp;
- char line[1024];
-
- /* restore the saved list (if any) */
- if (s_ign_list != NULL)
- {
- int i;
-
- for (i = 0; i < s_ign_count; i++)
- ign_list[i] = s_ign_list[i];
- ign_count = s_ign_count;
- ign_list[ign_count] = NULL;
-
- s_ign_count = 0;
- free (s_ign_list);
- s_ign_list = NULL;
- }
-
- /* is this a temporary ignore file? */
- if (hold)
- {
- /* re-set if we had already done a temporary file */
- if (ign_hold)
- {
- int i;
-
- for (i = ign_hold; i < ign_count; i++)
- free (ign_list[i]);
- ign_count = ign_hold;
- ign_list[ign_count] = NULL;
- }
- else
- {
- ign_hold = ign_count;
- }
- }
-
- /* load the file */
- if (!(fp = fopen (file, "r")))
- return;
- while (fgets (line, sizeof (line), fp))
- ign_add (line, hold);
- (void) fclose (fp);
-}
-
-/* Parse a line of space-separated wildcards and add them to the list. */
-void
-ign_add (ign, hold)
- char *ign;
- int hold;
-{
- if (!ign || !*ign)
- return;
-
- for (; *ign; ign++)
- {
- char *mark;
- char save;
-
- /* ignore whitespace before the token */
- if (isspace (*ign))
- continue;
-
- /*
- * if we find a single character !, we must re-set the ignore list
- * (saving it if necessary). We also catch * as a special case in a
- * global ignore file as an optimization
- */
- if (isspace (*(ign + 1)) && (*ign == '!' || *ign == '*'))
- {
- if (!hold)
- {
- /* permanently reset the ignore list */
- int i;
-
- for (i = 0; i < ign_count; i++)
- free (ign_list[i]);
- ign_count = 0;
- ign_list[0] = NULL;
-
- /* if we are doing a '!', continue; otherwise add the '*' */
- if (*ign == '!')
- continue;
- }
- else if (*ign == '!')
- {
- /* temporarily reset the ignore list */
- int i;
-
- if (ign_hold)
- {
- for (i = ign_hold; i < ign_count; i++)
- free (ign_list[i]);
- ign_hold = 0;
- }
- s_ign_list = (char **) xmalloc (ign_count * sizeof (char *));
- for (i = 0; i < ign_count; i++)
- s_ign_list[i] = ign_list[i];
- s_ign_count = ign_count;
- ign_count = 0;
- ign_list[0] = NULL;
- continue;
- }
- }
-
- /* If we have used up all the space, add some more */
- if (ign_count >= ign_size)
- {
- ign_size += IGN_GROW;
- ign_list = (char **) xrealloc ((char *) ign_list,
- (ign_size + 1) * sizeof (char *));
- }
-
- /* find the end of this token */
- for (mark = ign; *mark && !isspace (*mark); mark++)
- /* do nothing */ ;
-
- save = *mark;
- *mark = '\0';
-
- ign_list[ign_count++] = xstrdup (ign);
- ign_list[ign_count] = NULL;
-
- *mark = save;
- if (save)
- ign = mark;
- else
- ign = mark - 1;
- }
-}
-
-/* Return 1 if the given filename should be ignored by update or import. */
-int
-ign_name (name)
- char *name;
-{
- char **cpp = ign_list;
-
- if (cpp == NULL)
- return (0);
-
- while (*cpp)
- if (fnmatch (*cpp++, name, 0) == 0)
- return (1);
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/import.c b/gnu/usr.bin/cvs/cvs/import.c
deleted file mode 100644
index 095a800..0000000
--- a/gnu/usr.bin/cvs/cvs/import.c
+++ /dev/null
@@ -1,1007 +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.3 kit.
- *
- * "import" checks in the vendor release located in the current directory into
- * the CVS source repository. The CVS vendor branch support is utilized.
- *
- * At least three arguments are expected to follow the options:
- * repository Where the source belongs relative to the CVSROOT
- * VendorTag Vendor's major tag
- * VendorReleTag Tag for this particular release
- *
- * Additional arguments specify more Vendor Release Tags.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)import.c 1.52 92/03/31";
-#endif
-
-#define FILE_HOLDER ".#cvsxxx"
-
-#if __STDC__
-static char *get_comment (char *user);
-static int add_rcs_file (char *message, char *rcs, char *user, char *vtag,
- int targc, char *targv[]);
-static int expand_at_signs (char *buf, off_t size, FILE *fp);
-static int add_rev (char *message, char *rcs, char *vfile, char *vers);
-static int add_tags (char *rcs, char *vfile, char *vtag, int targc,
- char *targv[]);
-static int import_descend (char *message, char *vtag, int targc, char *targv[]);
-static int import_descend_dir (char *message, char *dir, char *vtag,
- int targc, char *targv[]);
-static int process_import_file (char *message, char *vfile, char *vtag,
- int targc, char *targv[]);
-static int update_rcs_file (char *message, char *vfile, char *vtag, int targc,
- char *targv[]);
-static void add_log (int ch, char *fname);
-#else
-static int import_descend ();
-static int process_import_file ();
-static int update_rcs_file ();
-static int add_rev ();
-static int add_tags ();
-static char *get_comment ();
-static int add_rcs_file ();
-static int expand_at_signs ();
-static void add_log ();
-static int import_descend_dir ();
-#endif /* __STDC__ */
-
-static int repos_len;
-static char vhead[50];
-static char vbranch[50];
-static FILE *logfp;
-static char repository[PATH_MAX];
-static int conflicts;
-
-static char *import_usage[] =
-{
- "Usage: %s %s [-Qq] [-I ign] [-m msg] [-b branch]\n",
- " repository vendor-tag release-tags...\n",
- "\t-Q\tReally quiet.\n",
- "\t-q\tSomewhat quiet.\n",
- "\t-I ign\tMore files to ignore (! to reset).\n",
- "\t-b bra\tVendor branch id.\n",
- "\t-m msg\tLog message.\n",
- NULL
-};
-
-int
-import (argc, argv)
- int argc;
- char *argv[];
-{
- char message[MAXMESGLEN];
- char tmpfile[L_tmpnam+1];
- char *cp;
- int i, c, msglen, err;
- List *ulist;
- Node *p;
-
- if (argc == -1)
- usage (import_usage);
-
- ign_setup ();
-
- (void) strcpy (vbranch, CVSBRANCH);
- message[0] = '\0';
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "Qqb:m:I:")) != -1)
- {
- switch (c)
- {
- case 'Q':
- really_quiet = 1;
- /* FALL THROUGH */
- case 'q':
- quiet = 1;
- break;
- case 'b':
- (void) strcpy (vbranch, optarg);
- break;
- case 'm':
-#ifdef FORCE_USE_EDITOR
- use_editor = TRUE;
-#else
- use_editor = FALSE;
-#endif
- if (strlen (optarg) >= (sizeof (message) - 1))
- {
- error (0, 0, "warning: message too long; truncated!");
- (void) strncpy (message, optarg, sizeof (message));
- message[sizeof (message) - 2] = '\0';
- }
- else
- (void) strcpy (message, optarg);
- break;
- case 'I':
- ign_add (optarg, 0);
- break;
- case '?':
- default:
- usage (import_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
- if (argc < 3)
- usage (import_usage);
-
- for (i = 1; i < argc; i++) /* check the tags for validity */
- RCS_check_tag (argv[i]);
-
- /* XXX - this should be a module, not just a pathname */
- if (argv[0][0] != '/')
- {
- if (CVSroot == NULL)
- {
- error (0, 0, "missing CVSROOT environment variable\n");
- error (1, 0, "Set it or specify the '-d' option to %s.",
- program_name);
- }
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
- repos_len = strlen (CVSroot);
- }
- else
- {
- (void) strcpy (repository, argv[0]);
- repos_len = 0;
- }
-
- /*
- * Consistency checks on the specified vendor branch. It must be
- * composed of only numbers and dots ('.'). Also, for now we only
- * support branching to a single level, so the specified vendor branch
- * must only have two dots in it (like "1.1.1").
- */
- for (cp = vbranch; *cp != '\0'; cp++)
- if (!isdigit (*cp) && *cp != '.')
- error (1, 0, "%s is not a numeric branch", vbranch);
- if (numdots (vbranch) != 2)
- error (1, 0, "Only branches with two dots are supported: %s", vbranch);
- (void) strcpy (vhead, vbranch);
- cp = rindex (vhead, '.');
- *cp = '\0';
- if (use_editor)
- do_editor ((char *) NULL, message, repository, (List *) NULL);
- msglen = strlen (message);
- if (msglen == 0 || message[msglen - 1] != '\n')
- {
- message[msglen] = '\n';
- message[msglen + 1] = '\0';
- }
-
- /*
- * Make all newly created directories writable. Should really use a more
- * sophisticated security mechanism here.
- */
- (void) umask (2);
- make_directories (repository);
-
- /* Create the logfile that will be logged upon completion */
- if ((logfp = fopen (tmpnam (tmpfile), "w+")) == NULL)
- error (1, errno, "cannot create temporary file `%s'", tmpfile);
- (void) unlink (tmpfile); /* to be sure it goes away */
- (void) fprintf (logfp, "\nVendor Tag:\t%s\n", argv[1]);
- (void) fprintf (logfp, "Release Tags:\t");
- for (i = 2; i < argc; i++)
- (void) fprintf (logfp, "%s\n\t\t", argv[i]);
- (void) fprintf (logfp, "\n");
-
- /* Just Do It. */
- err = import_descend (message, argv[1], argc - 2, argv + 2);
- if (conflicts)
- {
- if (!really_quiet)
- {
- (void) printf ("\n%d conflicts created by this import.\n",
- conflicts);
- (void) printf ("Use the following command to help the merge:\n\n");
- (void) printf ("\t%s checkout -j%s:yesterday -j%s %s\n\n",
- program_name, argv[1], argv[1], argv[0]);
- }
-
- (void) fprintf (logfp, "\n%d conflicts created by this import.\n",
- conflicts);
- (void) fprintf (logfp,
- "Use the following command to help the merge:\n\n");
- (void) fprintf (logfp, "\t%s checkout -j%s:yesterday -j%s %s\n\n",
- program_name, argv[1], argv[1], argv[0]);
- }
- else
- {
- if (!really_quiet)
- (void) printf ("\nNo conflicts created by this import\n\n");
- (void) fprintf (logfp, "\nNo conflicts created by this import\n\n");
- }
-
- /*
- * Write out the logfile and clean up.
- */
- ulist = getlist ();
- p = getnode ();
- p->type = UPDATE;
- p->delproc = update_delproc;
- p->key = xstrdup ("- Imported sources");
- p->data = (char *) T_TITLE;
- (void) addnode (ulist, p);
- Update_Logfile (repository, message, vbranch, logfp, ulist);
- dellist (&ulist);
- (void) fclose (logfp);
- return (err);
-}
-
-/*
- * process all the files in ".", then descend into other directories.
- */
-static int
-import_descend (message, vtag, targc, targv)
- char *message;
- char *vtag;
- int targc;
- char *targv[];
-{
- DIR *dirp;
- struct direct *dp;
- int err = 0;
- int has_dirs = 0;
- FILE *links = (FILE *)0;
-
- /* first, load up any per-directory ignore lists */
- ign_add_file (CVSDOTIGNORE, 1);
-
- if ((dirp = opendir (".")) == NULL)
- {
- err++;
- }
- else
- {
- while ((dp = readdir (dirp)) != NULL)
- {
- if (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0)
- continue;
- if (ign_name (dp->d_name))
- {
- add_log ('I', dp->d_name);
- continue;
- }
- if (isdir (dp->d_name))
- {
- has_dirs = 1;
- }
- else
- {
- if (islink (dp->d_name))
- {
-#ifdef DO_LINKS
- char lnbuf[PATH_MAX];
- int lln;
-
- add_log ('L', dp->d_name);
- if ((lln = readlink(dp->d_name, lnbuf, PATH_MAX)) == -1) {
- error(0, errno, "Can't read contents of symlink %s",
- dp->d_name);
- return (1);
- }
- else {
- if (!links) {
- char lnrep[PATH_MAX];
-
- sprintf(lnrep, "%s/SymLinks", repository);
- links = fopen(lnrep, "a+");
- if (!links) {
- error (0, errno,
- "Can't open SymLinks file %s", lnrep);
- return (1);
- }
- }
- lnbuf[lln] = '\0';
- fputs(dp->d_name, links);
- fputc('\n', links);
- fputs(lnbuf, links);
- fputc('\n', links);
- }
-#else
- add_log ('L', dp->d_name);
- err++;
-#endif
- }
- else
- {
- err += process_import_file (message, dp->d_name,
- vtag, targc, targv);
- }
- }
- }
- (void) closedir (dirp);
- }
- if (has_dirs)
- {
- if ((dirp = opendir (".")) == NULL)
- err++;
- else
- {
- while ((dp = readdir (dirp)) != NULL)
- {
- if (ign_name (dp->d_name) || !isdir (dp->d_name))
- continue;
- err += import_descend_dir (message, dp->d_name,
- vtag, targc, targv);
- }
- (void) closedir (dirp);
- }
- }
- if (links)
- fclose(links);
- return (err);
-}
-
-/*
- * Process the argument import file.
- */
-static int
-process_import_file (message, vfile, vtag, targc, targv)
- char *message;
- char *vfile;
- char *vtag;
- int targc;
- char *targv[];
-{
- char attic_name[PATH_MAX];
- char rcs[PATH_MAX];
-
- (void) sprintf (rcs, "%s/%s%s", repository, vfile, RCSEXT);
- if (!isfile (rcs))
- {
- (void) sprintf (attic_name, "%s/%s/%s%s", repository, CVSATTIC,
- vfile, RCSEXT);
- if (!isfile (attic_name))
- {
-
- /*
- * A new import source file; it doesn't exist as a ,v within the
- * repository nor in the Attic -- create it anew.
- */
- add_log ('N', vfile);
- return (add_rcs_file (message, rcs, vfile, vtag, targc, targv));
- }
- }
-
- /*
- * an rcs file exists. have to do things the official, slow, way.
- */
- return (update_rcs_file (message, vfile, vtag, targc, targv));
-}
-
-/*
- * The RCS file exists; update it by adding the new import file to the
- * (possibly already existing) vendor branch.
- */
-static int
-update_rcs_file (message, vfile, vtag, targc, targv)
- char *message;
- char *vfile;
- char *vtag;
- int targc;
- char *targv[];
-{
- Vers_TS *vers;
- char letter;
- int ierrno;
-
- vers = Version_TS (repository, (char *) NULL, vbranch, (char *) NULL, vfile,
- 1, 0, (List *) NULL, (List *) NULL);
- if (vers->vn_rcs != NULL)
- {
- char xtmpfile[50];
- int different;
- int retcode = 0;
-
- /* XXX - should be more unique */
- (void) sprintf (xtmpfile, "/tmp/%s", FILE_HOLDER);
-
- /*
- * The rcs file does have a revision on the vendor branch. Compare
- * this revision with the import file; if they match exactly, there
- * is no need to install the new import file as a new revision to the
- * branch. Just tag the revision with the new import tags.
- *
- * This is to try to cut down the number of "C" conflict messages for
- * locally modified import source files.
- */
-#ifdef HAVE_RCS5
- run_setup ("%s%s -q -f -r%s -p -ko", Rcsbin, RCS_CO, vers->vn_rcs);
-#else
- run_setup ("%s%s -q -f -r%s -p", Rcsbin, RCS_CO, vers->vn_rcs);
-#endif
- run_arg (vers->srcfile->path);
- if ((retcode = run_exec (RUN_TTY, xtmpfile, RUN_TTY,
- RUN_NORMAL|RUN_REALLY)) != 0)
- {
- ierrno = errno;
- fperror (logfp, 0, retcode == -1 ? ierrno : 0,
- "ERROR: cannot co revision %s of file %s", vers->vn_rcs,
- vers->srcfile->path);
- error (0, retcode == -1 ? ierrno : 0,
- "ERROR: cannot co revision %s of file %s", vers->vn_rcs,
- vers->srcfile->path);
- (void) unlink_file (xtmpfile);
- return (1);
- }
- different = xcmp (xtmpfile, vfile);
- (void) unlink_file (xtmpfile);
- if (!different)
- {
- int retval = 0;
-
- /*
- * The two files are identical. Just update the tags, print the
- * "U", signifying that the file has changed, but needs no
- * attention, and we're done.
- */
- if (add_tags (vers->srcfile->path, vfile, vtag, targc, targv))
- retval = 1;
- add_log ('U', vfile);
- freevers_ts (&vers);
- return (retval);
- }
- }
-
- /* We may have failed to parse the RCS file; check just in case */
- if (vers->srcfile == NULL || add_rev (message, vers->srcfile->path,
- vfile, vers->vn_rcs) ||
- add_tags (vers->srcfile->path, vfile, vtag, targc, targv))
- {
- freevers_ts (&vers);
- return (1);
- }
-
- if (vers->srcfile->branch == NULL ||
- strcmp (vers->srcfile->branch, vbranch) != 0)
- {
- conflicts++;
- letter = 'C';
- }
- else
- letter = 'U';
- add_log (letter, vfile);
-
- freevers_ts (&vers);
- return (0);
-}
-
-/*
- * Add the revision to the vendor branch
- */
-static int
-add_rev (message, rcs, vfile, vers)
- char *message;
- char *rcs;
- char *vfile;
- char *vers;
-{
- int locked, status, ierrno;
- int retcode = 0;
-
- if (noexec)
- return (0);
-
- locked = 0;
- if (vers != NULL)
- {
- run_setup ("%s%s -q -l%s", Rcsbin, RCS, vbranch);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, DEVNULL, DEVNULL, RUN_NORMAL)) == 0)
- locked = 1;
- else if (retcode == -1)
- {
- error (0, errno, "fork failed");
- return (1);
- }
- }
- if (link_file (vfile, FILE_HOLDER) < 0)
- {
- if (errno == EEXIST)
- {
- (void) unlink_file (FILE_HOLDER);
- (void) link_file (vfile, FILE_HOLDER);
- }
- else
- {
- ierrno = errno;
- fperror (logfp, 0, ierrno, "ERROR: cannot create link to %s", vfile);
- error (0, ierrno, "ERROR: cannot create link to %s", vfile);
- return (1);
- }
- }
- run_setup ("%s%s -q -f -r%s", Rcsbin, RCS_CI, vbranch);
- run_args ("-m%s", message);
- run_arg (rcs);
- status = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- ierrno = errno;
- rename_file (FILE_HOLDER, vfile);
- if (status)
- {
- if (!noexec)
- {
- fperror (logfp, 0, status == -1 ? ierrno : 0, "ERROR: Check-in of %s failed", rcs);
- error (0, status == -1 ? ierrno : 0, "ERROR: Check-in of %s failed", rcs);
- }
- if (locked)
- {
- run_setup ("%s%s -q -u%s", Rcsbin, RCS, vbranch);
- run_arg (rcs);
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
- return (1);
- }
- return (0);
-}
-
-/*
- * Add the vendor branch tag and all the specified import release tags to the
- * RCS file. The vendor branch tag goes on the branch root (1.1.1) while the
- * vendor release tags go on the newly added leaf of the branch (1.1.1.1,
- * 1.1.1.2, ...).
- */
-static int
-add_tags (rcs, vfile, vtag, targc, targv)
- char *rcs;
- char *vfile;
- char *vtag;
- int targc;
- char *targv[];
-{
- int i, ierrno;
- Vers_TS *vers;
- int retcode = 0;
-
- if (noexec)
- return (0);
-
- run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, vtag, vbranch);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- {
- ierrno = errno;
- fperror (logfp, 0, retcode == -1 ? ierrno : 0,
- "ERROR: Failed to set tag %s in %s", vtag, rcs);
- error (0, retcode == -1 ? ierrno : 0,
- "ERROR: Failed to set tag %s in %s", vtag, rcs);
- return (1);
- }
- vers = Version_TS (repository, (char *) NULL, vtag, (char *) NULL, vfile,
- 1, 0, (List *) NULL, (List *) NULL);
- for (i = 0; i < targc; i++)
- {
- run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, targv[i], vers->vn_rcs);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- {
- ierrno = errno;
- fperror (logfp, 0, retcode == -1 ? ierrno : 0,
- "WARNING: Couldn't add tag %s to %s", targv[i], rcs);
- error (0, retcode == -1 ? ierrno : 0,
- "WARNING: Couldn't add tag %s to %s", targv[i], rcs);
- }
- }
- freevers_ts (&vers);
- return (0);
-}
-
-/*
- * Stolen from rcs/src/rcsfnms.c, and adapted/extended.
- */
-struct compair
-{
- char *suffix, *comlead;
-};
-
-struct compair comtable[] =
-{
-
-/*
- * comtable pairs each filename suffix with a comment leader. The comment
- * leader is placed before each line generated by the $Log keyword. This
- * table is used to guess the proper comment leader from the working file's
- * suffix during initial ci (see InitAdmin()). Comment leaders are needed for
- * languages without multiline comments; for others they are optional.
- */
- "a", "-- ", /* Ada */
- "ada", "-- ",
- "asm", ";; ", /* assembler (MS-DOS) */
- "bat", ":: ", /* batch (MS-DOS) */
- "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* */
- "csh", "# ", /* shell */
- "e", "# ", /* efl */
- "el", "; ", /* Emacs Lisp */
- "f", "c ", /* Fortran */
- "for", "c ",
- "h", " * ", /* C-header */
- "hh", "// ", /* C++ header */
- "hpp", "// ",
- "hxx", "// ",
- "in", "# ", /* for Makefile.in */
- "l", " * ", /* lex (conflict between lex and
- * franzlisp) */
- "mac", ";; ", /* macro (DEC-10, MS-DOS, PDP-11,
- * VMS, etc) */
- "me", ".\\\" ", /* me-macros t/nroff */
- "ml", "; ", /* mocklisp */
- "mm", ".\\\" ", /* mm-macros t/nroff */
- "ms", ".\\\" ", /* ms-macros t/nroff */
- "man", ".\\\" ", /* man-macros t/nroff */
- "1", ".\\\" ", /* feeble attempt at man pages... */
- "2", ".\\\" ",
- "3", ".\\\" ",
- "4", ".\\\" ",
- "5", ".\\\" ",
- "6", ".\\\" ",
- "7", ".\\\" ",
- "8", ".\\\" ",
- "9", ".\\\" ",
- "p", " * ", /* pascal */
- "pas", " * ",
- "pl", "# ", /* perl (conflict with Prolog) */
- "ps", "% ", /* postscript */
- "r", "# ", /* ratfor */
- "red", "% ", /* psl/rlisp */
-#ifdef sparc
- "s", "! ", /* assembler */
-#endif
-#ifdef mc68000
- "s", "| ", /* assembler */
-#endif
-#ifdef pdp11
- "s", "/ ", /* assembler */
-#endif
-#ifdef vax
- "s", "# ", /* assembler */
-#endif
-#ifdef __ksr__
- "s", "# ", /* assembler */
- "S", "# ", /* Macro assembler */
-#endif
- "sh", "# ", /* shell */
- "sl", "% ", /* psl */
- "tex", "% ", /* tex */
- "y", " * ", /* yacc */
- "ye", " * ", /* yacc-efl */
- "yr", " * ", /* yacc-ratfor */
- "", "# ", /* default for empty suffix */
- NULL, "# " /* default for unknown suffix; */
-/* must always be last */
-};
-
-static char *
-get_comment (user)
- char *user;
-{
- char *cp, *suffix;
- char suffix_path[PATH_MAX];
- int i;
-
- cp = rindex (user, '.');
- if (cp != NULL)
- {
- cp++;
-
- /*
- * Convert to lower-case, since we are not concerned about the
- * case-ness of the suffix.
- */
- (void) strcpy (suffix_path, cp);
- for (cp = suffix_path; *cp; cp++)
- if (isupper (*cp))
- *cp = tolower (*cp);
- suffix = suffix_path;
- }
- else
- suffix = ""; /* will use the default */
- for (i = 0;; i++)
- {
- if (comtable[i].suffix == NULL) /* default */
- return (comtable[i].comlead);
- if (strcmp (suffix, comtable[i].suffix) == 0)
- return (comtable[i].comlead);
- }
-}
-
-static int
-add_rcs_file (message, rcs, user, vtag, targc, targv)
- char *message;
- char *rcs;
- char *user;
- char *vtag;
- int targc;
- char *targv[];
-{
- FILE *fprcs, *fpuser;
- struct stat sb;
- struct tm *ftm;
- time_t now;
- char altdate1[50], altdate2[50];
- char *author, *buf;
- int i, mode, ierrno, err = 0;
-
- if (noexec)
- return (0);
-
- fprcs = open_file (rcs, "w+");
- fpuser = open_file (user, "r");
-
- /*
- * putadmin()
- */
- if (fprintf (fprcs, "head %s;\n", vhead) == EOF ||
- fprintf (fprcs, "branch %s;\n", vbranch) == EOF ||
- fprintf (fprcs, "access ;\n") == EOF ||
- fprintf (fprcs, "symbols ") == EOF)
- {
- goto write_error;
- }
-
- for (i = targc - 1; i >= 0; i--) /* RCS writes the symbols backwards */
- if (fprintf (fprcs, "%s:%s.1 ", targv[i], vbranch) == EOF)
- goto write_error;
-
- if (fprintf (fprcs, "%s:%s;\n", vtag, vbranch) == EOF ||
- fprintf (fprcs, "locks ; strict;\n") == EOF ||
- /* XXX - make sure @@ processing works in the RCS file */
- fprintf (fprcs, "comment @%s@;\n\n", get_comment (user)) == EOF)
- {
- goto write_error;
- }
-
- /*
- * puttree()
- */
- (void) time (&now);
-#ifdef HAVE_RCS5
- ftm = gmtime (&now);
-#else
- ftm = localtime (&now);
-#endif
- (void) sprintf (altdate1, DATEFORM,
- ftm->tm_year + (ftm->tm_year < 100 ? 0 : 1900),
- ftm->tm_mon + 1, ftm->tm_mday, ftm->tm_hour,
- ftm->tm_min, ftm->tm_sec);
- now++;
-#ifdef HAVE_RCS5
- ftm = gmtime (&now);
-#else
- ftm = localtime (&now);
-#endif
- (void) sprintf (altdate2, DATEFORM,
- ftm->tm_year + (ftm->tm_year < 100 ? 0 : 1900),
- ftm->tm_mon + 1, ftm->tm_mday, ftm->tm_hour,
- ftm->tm_min, ftm->tm_sec);
- author = getcaller ();
-
- if (fprintf (fprcs, "\n%s\n", vhead) == EOF ||
- fprintf (fprcs, "date %s; author %s; state Exp;\n",
- altdate1, author) == EOF ||
- fprintf (fprcs, "branches %s.1;\n", vbranch) == EOF ||
- fprintf (fprcs, "next ;\n") == EOF ||
- fprintf (fprcs, "\n%s.1\n", vbranch) == EOF ||
- fprintf (fprcs, "date %s; author %s; state Exp;\n",
- altdate2, author) == EOF ||
- fprintf (fprcs, "branches ;\n") == EOF ||
- fprintf (fprcs, "next ;\n\n") == EOF ||
- /*
- * putdesc()
- */
- fprintf (fprcs, "\ndesc\n") == EOF ||
- fprintf (fprcs, "@@\n\n\n") == EOF ||
- /*
- * putdelta()
- */
- fprintf (fprcs, "\n%s\n", vhead) == EOF ||
- fprintf (fprcs, "log\n") == EOF ||
- fprintf (fprcs, "@Initial revision\n@\n") == EOF ||
- fprintf (fprcs, "text\n@") == EOF)
- {
- goto write_error;
- }
-
- if (fstat (fileno (fpuser), &sb) < 0)
- error (1, errno, "cannot fstat %s", user);
- if (sb.st_size > 0)
- {
- off_t size;
-
- size = sb.st_size;
- buf = xmalloc ((int) size);
- if (fread (buf, (int) size, 1, fpuser) != 1)
- error (1, errno, "cannot read file %s for copying", user);
- if (expand_at_signs (buf, size, fprcs) == EOF)
- goto write_error;
- free (buf);
- }
- if (fprintf (fprcs, "@\n\n") == EOF ||
- fprintf (fprcs, "\n%s.1\n", vbranch) == EOF ||
- fprintf (fprcs, "log\n@") == EOF ||
- expand_at_signs (message, (off_t) strlen (message), fprcs) == EOF ||
- fprintf (fprcs, "@\ntext\n") == EOF ||
- fprintf (fprcs, "@@\n") == EOF)
- {
- goto write_error;
- }
- if (fclose (fprcs) == EOF)
- {
- ierrno = errno;
- goto write_error_noclose;
- }
- (void) fclose (fpuser);
-
- /*
- * Fix the modes on the RCS files. They must maintain the same modes as
- * the original user file, except that all write permissions must be
- * turned off.
- */
- mode = sb.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH);
- if (chmod (rcs, mode) < 0)
- {
- ierrno = errno;
- fperror (logfp, 0, ierrno,
- "WARNING: cannot change mode of file %s", rcs);
- error (0, ierrno, "WARNING: cannot change mode of file %s", rcs);
- err++;
- }
- return (err);
-
-write_error:
- ierrno = errno;
- (void) fclose (fprcs);
-write_error_noclose:
- (void) fclose (fpuser);
- fperror (logfp, 0, ierrno, "ERROR: cannot write file %s", rcs);
- error (0, ierrno, "ERROR: cannot write file %s", rcs);
- if (ierrno == ENOSPC)
- {
- (void) unlink (rcs);
- fperror (logfp, 0, 0, "ERROR: out of space - aborting");
- error (1, 0, "ERROR: out of space - aborting");
- }
- return (err + 1);
-}
-
-/*
- * Sigh.. need to expand @ signs into double @ signs
- */
-static int
-expand_at_signs (buf, size, fp)
- char *buf;
- off_t size;
- FILE *fp;
-{
- char *cp, *end;
-
- for (cp = buf, end = buf + size; cp < end; cp++)
- {
- if (*cp == '@')
- (void) putc ('@', fp);
- if (putc (*cp, fp) == EOF)
- return (EOF);
- }
- return (1);
-}
-
-/*
- * Write an update message to (potentially) the screen and the log file.
- */
-static void
-add_log (ch, fname)
- char ch;
- char *fname;
-{
- if (!really_quiet) /* write to terminal */
- {
- if (repos_len)
- (void) printf ("%c %s/%s\n", ch, repository + repos_len + 1, fname);
- else if (repository[0])
- (void) printf ("%c %s/%s\n", ch, repository, fname);
- else
- (void) printf ("%c %s\n", ch, fname);
- }
-
- if (repos_len) /* write to logfile */
- (void) fprintf (logfp, "%c %s/%s\n", ch,
- repository + repos_len + 1, fname);
- else if (repository[0])
- (void) fprintf (logfp, "%c %s/%s\n", ch, repository, fname);
- else
- (void) fprintf (logfp, "%c %s\n", ch, fname);
-}
-
-/*
- * This is the recursive function that walks the argument directory looking
- * for sub-directories that have CVS administration files in them and updates
- * them recursively.
- *
- * Note that we do not follow symbolic links here, which is a feature!
- */
-static int
-import_descend_dir (message, dir, vtag, targc, targv)
- char *message;
- char *dir;
- char *vtag;
- int targc;
- char *targv[];
-{
- char cwd[PATH_MAX];
- char *cp;
- int ierrno, err;
-
- if (islink (dir))
- return (0);
- if (getwd (cwd) == NULL)
- {
- fperror (logfp, 0, 0, "ERROR: cannot get working directory: %s", cwd);
- error (0, 0, "ERROR: cannot get working directory: %s", cwd);
- return (1);
- }
- if (repository[0] == '\0')
- (void) strcpy (repository, dir);
- else
- {
- (void) strcat (repository, "/");
- (void) strcat (repository, dir);
- }
- if (!quiet)
- error (0, 0, "Importing %s", repository);
- if (chdir (dir) < 0)
- {
- ierrno = errno;
- fperror (logfp, 0, ierrno, "ERROR: cannot chdir to %s", repository);
- error (0, ierrno, "ERROR: cannot chdir to %s", repository);
- err = 1;
- goto out;
- }
- if (!isdir (repository))
- {
- if (isfile (repository))
- {
- fperror (logfp, 0, 0, "ERROR: %s is a file, should be a directory!",
- repository);
- error (0, 0, "ERROR: %s is a file, should be a directory!",
- repository);
- err = 1;
- goto out;
- }
- if (noexec == 0 && mkdir (repository, 0777) < 0)
- {
- ierrno = errno;
- fperror (logfp, 0, ierrno,
- "ERROR: cannot mkdir %s -- not added", repository);
- error (0, ierrno,
- "ERROR: cannot mkdir %s -- not added", repository);
- err = 1;
- goto out;
- }
- }
- err = import_descend (message, vtag, targc, targv);
- out:
- if ((cp = rindex (repository, '/')) != NULL)
- *cp = '\0';
- else
- repository[0] = '\0';
- if (chdir (cwd) < 0)
- error (1, errno, "cannot chdir to %s", cwd);
- return (err);
-}
diff --git a/gnu/usr.bin/cvs/cvs/lock.c b/gnu/usr.bin/cvs/cvs/lock.c
deleted file mode 100644
index 5da23b3..0000000
--- a/gnu/usr.bin/cvs/cvs/lock.c
+++ /dev/null
@@ -1,522 +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.3 kit.
- *
- * Set Lock
- *
- * Lock file support for CVS.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)lock.c 1.42 92/04/10";
-#endif
-
-extern char *ctime ();
-
-#if __STDC__
-static int readers_exist (char *repository);
-static int set_lock (char *lockdir, int will_wait, char *repository);
-static void set_lockers_name (struct stat *statp);
-static int set_writelock_proc (Node * p);
-static int unlock_proc (Node * p);
-static int write_lock (char *repository);
-static void unlock (char *repository);
-static void lock_wait ();
-#else
-static int unlock_proc ();
-static void unlock ();
-static int set_writelock_proc ();
-static int write_lock ();
-static int readers_exist ();
-static int set_lock ();
-static void set_lockers_name ();
-static void lock_wait ();
-#endif /* __STDC__ */
-
-static char lockers_name[20];
-static char *repository;
-static char readlock[PATH_MAX], writelock[PATH_MAX];
-static int cleanup_lckdir;
-static List *locklist;
-
-#define L_OK 0 /* success */
-#define L_ERROR 1 /* error condition */
-#define L_LOCK_OWNED 2 /* lock already owned by us */
-#define L_LOCKED 3 /* lock owned by someone else */
-
-/*
- * Clean up all outstanding locks
- */
-void
-Lock_Cleanup ()
-{
- /* clean up simple locks (if any) */
- if (repository != NULL)
- {
- unlock (repository);
- repository = (char *) NULL;
- }
-
- /* clean up multiple locks (if any) */
- if (locklist != (List *) NULL)
- {
- (void) walklist (locklist, unlock_proc);
- locklist = (List *) NULL;
- }
-}
-
-/*
- * walklist proc for removing a list of locks
- */
-static int
-unlock_proc (p)
- Node *p;
-{
- unlock (p->key);
- return (0);
-}
-
-/*
- * Remove the lock files (without complaining if they are not there),
- */
-static void
-unlock (repository)
- char *repository;
-{
- char tmp[PATH_MAX];
- struct stat sb;
-
- if (readlock[0] != '\0')
- {
- (void) sprintf (tmp, "%s/%s", repository, readlock);
- (void) unlink (tmp);
- }
-
- if (writelock[0] != '\0')
- {
- (void) sprintf (tmp, "%s/%s", repository, writelock);
- (void) unlink (tmp);
- }
-
- /*
- * Only remove the lock directory if it is ours, note that this does
- * lead to the limitation that one user ID should not be committing
- * files into the same Repository directory at the same time. Oh well.
- */
- (void) sprintf (tmp, "%s/%s", repository, CVSLCK);
- if (stat (tmp, &sb) != -1 && sb.st_uid == geteuid () &&
- (writelock[0] != '\0' || (readlock[0] != '\0' && cleanup_lckdir)))
- {
- (void) rmdir (tmp);
- }
- cleanup_lckdir = 0;
-}
-
-/*
- * Create a lock file for readers
- */
-int
-Reader_Lock (xrepository)
- char *xrepository;
-{
- int err = 0;
- FILE *fp;
- char tmp[PATH_MAX];
-
- if (noexec)
- return (0);
-
- /* we only do one directory at a time for read locks! */
- if (repository != NULL)
- {
- error (0, 0, "Reader_Lock called while read locks set - Help!");
- return (1);
- }
-
- if (readlock[0] == '\0')
- (void) sprintf (readlock, "%s.%d", CVSRFL, getpid ());
-
- /* remember what we're locking (for lock_cleanup) */
- repository = xrepository;
-
- /* make sure we clean up on error */
- (void) SIG_register (SIGHUP, Lock_Cleanup);
- (void) SIG_register (SIGINT, Lock_Cleanup);
- (void) SIG_register (SIGQUIT, Lock_Cleanup);
- (void) SIG_register (SIGPIPE, Lock_Cleanup);
- (void) SIG_register (SIGTERM, Lock_Cleanup);
-
- /* make sure we can write the repository */
- (void) sprintf (tmp, "%s/%s.%d", xrepository, CVSTFL, getpid ());
- if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF)
- {
- error (0, errno, "cannot create read lock in repository `%s'",
- xrepository);
- readlock[0] = '\0';
- (void) unlink (tmp);
- return (1);
- }
- (void) unlink (tmp);
-
- /* get the lock dir for our own */
- (void) sprintf (tmp, "%s/%s", xrepository, CVSLCK);
- if (set_lock (tmp, 1, xrepository) != L_OK)
- {
- error (0, 0, "failed to obtain dir lock in repository `%s'",
- xrepository);
- readlock[0] = '\0';
- return (1);
- }
-
- /* write a read-lock */
- (void) sprintf (tmp, "%s/%s", xrepository, readlock);
- if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF)
- {
- error (0, errno, "cannot create read lock in repository `%s'",
- xrepository);
- readlock[0] = '\0';
- err = 1;
- }
-
- /* free the lock dir */
- (void) sprintf (tmp, "%s/%s", xrepository, CVSLCK);
- if (rmdir (tmp) < 0)
- error (0, errno, "failed to remove lock dir `%s'", tmp);
-
- return (err);
-}
-
-/*
- * Lock a list of directories for writing
- */
-static char *lock_error_repos;
-static int lock_error;
-int
-Writer_Lock (list)
- List *list;
-{
- if (noexec)
- return (0);
-
- /* We only know how to do one list at a time */
- if (locklist != (List *) NULL)
- {
- error (0, 0, "Writer_Lock called while write locks set - Help!");
- return (1);
- }
-
- for (;;)
- {
- /* try to lock everything on the list */
- lock_error = L_OK; /* init for set_writelock_proc */
- lock_error_repos = (char *) NULL; /* init for set_writelock_proc */
- locklist = list; /* init for Lock_Cleanup */
- (void) strcpy (lockers_name, "unknown");
-
- (void) walklist (list, set_writelock_proc);
-
- switch (lock_error)
- {
- case L_ERROR: /* Real Error */
- Lock_Cleanup (); /* clean up any locks we set */
- error (0, 0, "lock failed - giving up");
- return (1);
-
- case L_LOCKED: /* Someone already had a lock */
- Lock_Cleanup (); /* clean up any locks we set */
- lock_wait (lock_error_repos); /* sleep a while and try again */
- continue;
-
- case L_OK: /* we got the locks set */
- return (0);
-
- default:
- error (0, 0, "unknown lock status %d in Writer_Lock",
- lock_error);
- return (1);
- }
- }
-}
-
-/*
- * walklist proc for setting write locks
- */
-static int
-set_writelock_proc (p)
- Node *p;
-{
- /* if some lock was not OK, just skip this one */
- if (lock_error != L_OK)
- return (0);
-
- /* apply the write lock */
- lock_error_repos = p->key;
- lock_error = write_lock (p->key);
- return (0);
-}
-
-/*
- * Create a lock file for writers returns L_OK if lock set ok, L_LOCKED if
- * lock held by someone else or L_ERROR if an error occurred
- */
-static int
-write_lock (repository)
- char *repository;
-{
- int status;
- FILE *fp;
- char tmp[PATH_MAX];
-
- if (writelock[0] == '\0')
- (void) sprintf (writelock, "%s.%d", CVSWFL, getpid ());
-
- /* make sure we clean up on error */
- (void) SIG_register (SIGHUP, Lock_Cleanup);
- (void) SIG_register (SIGINT, Lock_Cleanup);
- (void) SIG_register (SIGQUIT, Lock_Cleanup);
- (void) SIG_register (SIGPIPE, Lock_Cleanup);
- (void) SIG_register (SIGTERM, Lock_Cleanup);
-
- /* make sure we can write the repository */
- (void) sprintf (tmp, "%s/%s.%d", repository, CVSTFL, getpid ());
- if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF)
- {
- error (0, errno, "cannot create write lock in repository `%s'",
- repository);
- (void) unlink (tmp);
- return (L_ERROR);
- }
- (void) unlink (tmp);
-
- /* make sure the lock dir is ours (not necessarily unique to us!) */
- (void) sprintf (tmp, "%s/%s", repository, CVSLCK);
- status = set_lock (tmp, 0, repository);
- if (status == L_OK || status == L_LOCK_OWNED)
- {
- /* we now own a writer - make sure there are no readers */
- if (readers_exist (repository))
- {
- /* clean up the lock dir if we created it */
- if (status == L_OK)
- {
- if (rmdir (tmp) < 0)
- error (0, errno, "failed to remove lock dir `%s'", tmp);
- }
-
- /* indicate we failed due to read locks instead of error */
- return (L_LOCKED);
- }
-
- /* write the write-lock file */
- (void) sprintf (tmp, "%s/%s", repository, writelock);
- if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF)
- {
- int xerrno = errno;
-
- (void) unlink (tmp);
- /* free the lock dir if we created it */
- if (status == L_OK)
- {
- (void) sprintf (tmp, "%s/%s", repository, CVSLCK);
- if (rmdir (tmp) < 0)
- error (0, errno, "failed to remove lock dir `%s'", tmp);
- }
-
- /* return the error */
- error (0, xerrno, "cannot create write lock in repository `%s'",
- repository);
- return (L_ERROR);
- }
- return (L_OK);
- }
- else
- return (status);
-}
-
-/*
- * readers_exist() returns 0 if there are no reader lock files remaining in
- * the repository; else 1 is returned, to indicate that the caller should
- * sleep a while and try again.
- */
-static int
-readers_exist (repository)
- char *repository;
-{
- char line[MAXLINELEN];
- DIR *dirp;
- struct direct *dp;
- struct stat sb;
- CONST char *regex_err;
- int ret = 0;
-
-#ifdef CVS_FUDGELOCKS
-again:
-#endif
-
- if ((dirp = opendir (repository)) == NULL)
- error (1, 0, "cannot open directory %s", repository);
-
- (void) sprintf (line, "^%s.*", CVSRFL);
- if ((regex_err = re_comp (line)) != NULL)
- error (1, 0, "%s", regex_err);
-
- while ((dp = readdir (dirp)) != NULL)
- {
- (void) sprintf (line, "%s/%s", repository, dp->d_name);
- if (re_exec (dp->d_name))
- {
-#ifdef CVS_FUDGELOCKS
- time_t now;
-
- (void) time (&now);
-
- /*
- * If the create time of the file is more than CVSLCKAGE seconds
- * ago, try to clean-up the lock file, and if successful, re-open
- * the directory and try again.
- */
- if (stat (line, &sb) != -1)
- {
- if (now >= (sb.st_ctime + CVSLCKAGE) && unlink (line) != -1)
- {
- (void) closedir (dirp);
- goto again;
- }
- set_lockers_name (&sb);
- }
-#else
- if (stat (line, &sb) != -1)
- set_lockers_name (&sb);
-#endif
- ret = 1;
- break;
- }
- }
- (void) closedir (dirp);
- return (ret);
-}
-
-/*
- * Set the static variable lockers_name appropriately, based on the stat
- * structure passed in.
- */
-static void
-set_lockers_name (statp)
- struct stat *statp;
-{
- struct passwd *pw;
-
- if ((pw = (struct passwd *) getpwuid (statp->st_uid)) !=
- (struct passwd *) NULL)
- {
- (void) strcpy (lockers_name, pw->pw_name);
- }
- else
- (void) sprintf (lockers_name, "uid%d", statp->st_uid);
-}
-
-/*
- * Persistently tries to make the directory "lckdir",, which serves as a
- * lock. If the create time on the directory is greater than CVSLCKAGE
- * seconds old, just try to remove the directory.
- */
-static int
-set_lock (lockdir, will_wait, repository)
- char *lockdir;
- int will_wait;
- char *repository;
-{
- struct stat sb;
-#ifdef CVS_FUDGELOCKS
- time_t now;
-#endif
-
- /*
- * Note that it is up to the callers of set_lock() to arrange for signal
- * handlers that do the appropriate things, like remove the lock
- * directory before they exit.
- */
- cleanup_lckdir = 0;
- for (;;)
- {
- SIG_beginCrSect ();
- if (mkdir (lockdir, 0777) == 0)
- {
- cleanup_lckdir = 1;
- SIG_endCrSect ();
- return (L_OK);
- }
- SIG_endCrSect ();
-
- if (errno != EEXIST)
- {
- error (0, errno,
- "failed to create lock directory in repository `%s'",
- repository);
- return (L_ERROR);
- }
-
- /*
- * stat the dir - if it is non-existent, re-try the loop since
- * someone probably just removed it (thus releasing the lock)
- */
- if (stat (lockdir, &sb) < 0)
- {
- if (errno == ENOENT)
- continue;
-
- error (0, errno, "couldn't stat lock directory `%s'", lockdir);
- return (L_ERROR);
- }
-
- /*
- * if we already own the lock, go ahead and return 1 which means it
- * existed but we owned it
- */
- if (sb.st_uid == geteuid () && !will_wait)
- return (L_LOCK_OWNED);
-
-#ifdef CVS_FUDGELOCKS
-
- /*
- * If the create time of the directory is more than CVSLCKAGE seconds
- * ago, try to clean-up the lock directory, and if successful, just
- * quietly retry to make it.
- */
- (void) time (&now);
- if (now >= (sb.st_ctime + CVSLCKAGE))
- {
- if (rmdir (lockdir) >= 0)
- continue;
- }
-#endif
-
- /* set the lockers name */
- set_lockers_name (&sb);
-
- /* if he wasn't willing to wait, return an error */
- if (!will_wait)
- return (L_LOCKED);
- lock_wait (repository);
- }
-}
-
-/*
- * Print out a message that the lock is still held, then sleep a while.
- */
-static void
-lock_wait (repos)
- char *repos;
-{
- time_t now;
-
- (void) time (&now);
- error (0, 0, "[%8.8s] waiting for %s's lock in %s", ctime (&now) + 11,
- lockers_name, repos);
- (void) sleep (CVSLCKSLEEP);
-}
diff --git a/gnu/usr.bin/cvs/cvs/log.c b/gnu/usr.bin/cvs/cvs/log.c
deleted file mode 100644
index 9e7ab8b..0000000
--- a/gnu/usr.bin/cvs/cvs/log.c
+++ /dev/null
@@ -1,132 +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.3 kit.
- *
- * Print Log Information
- *
- * Prints the RCS "log" (rlog) information for the specified files. With no
- * argument, prints the log information for all the files in the directory
- * (recursive by default).
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)log.c 1.39 92/03/31";
-#endif
-
-#if __STDC__
-static Dtype log_dirproc (char *dir, char *repository, char *update_dir);
-static int log_fileproc (char *file, char *update_dir, char *repository,
- List * entries, List * srcfiles);
-#else
-static int log_fileproc ();
-static Dtype log_dirproc ();
-#endif /* __STDC__ */
-
-static char options[PATH_MAX];
-
-static char *log_usage[] =
-{
- "Usage: %s %s [-l] [rlog-options] [files...]\n",
- "\t-l\tLocal directory only, no recursion.\n",
- NULL
-};
-
-int
-cvslog (argc, argv)
- int argc;
- char *argv[];
-{
- int i;
- int numopt = 1;
- int err = 0;
- int local = 0;
-
- if (argc == -1)
- usage (log_usage);
-
- /*
- * All 'log' command options except -l are passed directly on to 'rlog'
- */
- options[0] = '\0'; /* Assume none */
- for (i = 1; i < argc; i++)
- {
- if (argv[i][0] == '-' || argv[i][0] == '\0')
- {
- numopt++;
- switch (argv[i][1])
- {
- case 'l':
- local = 1;
- break;
- default:
- (void) strcat (options, " ");
- (void) strcat (options, argv[i]);
- break;
- }
- }
- }
- argc -= numopt;
- argv += numopt;
-
- err = start_recursion (log_fileproc, (int (*) ()) NULL, log_dirproc,
- (int (*) ()) NULL, argc, argv, local,
- W_LOCAL | W_REPOS | W_ATTIC, 0, 1,
- (char *) NULL, 1);
- return (err);
-}
-
-/*
- * Do an rlog on a file
- */
-/* ARGSUSED */
-static int
-log_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- Node *p;
- RCSNode *rcsfile;
- int retcode = 0;
-
- p = findnode (srcfiles, file);
- if (p == NULL || (rcsfile = (RCSNode *) p->data) == NULL)
- {
- if (!really_quiet)
- error (0, 0, "nothing known about %s", file);
- return (1);
- }
-
- run_setup ("%s%s %s", Rcsbin, RCS_RLOG, options);
- run_arg (rcsfile->path);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_REALLY)) == -1)
- {
- error (1, errno, "fork failed for rlog on %s", file);
- }
- return (retcode);
-}
-
-/*
- * Print a warm fuzzy message
- */
-/* ARGSUSED */
-static Dtype
-log_dirproc (dir, repository, update_dir)
- char *dir;
- char *repository;
- char *update_dir;
-{
- if (!isdir (dir))
- return (R_SKIP_ALL);
-
- if (!quiet)
- error (0, 0, "Logging %s", update_dir);
- return (R_PROCESS);
-}
diff --git a/gnu/usr.bin/cvs/cvs/logmsg.c b/gnu/usr.bin/cvs/cvs/logmsg.c
deleted file mode 100644
index ce1da92..0000000
--- a/gnu/usr.bin/cvs/cvs/logmsg.c
+++ /dev/null
@@ -1,449 +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.3 kit.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)logmsg.c 1.40 92/04/10";
-#endif
-
-#if __STDC__
-static int find_type (Node * p);
-static int fmt_proc (Node * p);
-static int logfile_write (char *repository, char *filter, char *title,
- char *message, char *revision, FILE * logfp,
- List * changes);
-static int rcsinfo_proc (char *repository, char *template);
-static int title_proc (Node * p);
-static int update_logfile_proc (char *repository, char *filter);
-static void setup_tmpfile (FILE * xfp, char *xprefix, List * changes);
-static int editinfo_proc (char *repository, char *template);
-#else
-static void setup_tmpfile ();
-static int find_type ();
-static int fmt_proc ();
-static int rcsinfo_proc ();
-static int update_logfile_proc ();
-static int title_proc ();
-static int logfile_write ();
-static int editinfo_proc ();
-#endif /* __STDC__ */
-
-static FILE *fp;
-static char *strlist;
-static char *editinfo_editor;
-static Ctype type;
-
-/*
- * Puts a standard header on the output which is either being prepared for an
- * editor session, or being sent to a logfile program. The modified, added,
- * and removed files are included (if any) and formatted to look pretty.
- */
-static char *prefix;
-static int col;
-static void
-setup_tmpfile (xfp, xprefix, changes)
- FILE *xfp;
- char *xprefix;
- List *changes;
-{
- /* set up statics */
- fp = xfp;
- prefix = xprefix;
-
- type = T_MODIFIED;
- if (walklist (changes, find_type) != 0)
- {
- (void) fprintf (fp, "%sModified Files:\n", prefix);
- (void) fprintf (fp, "%s\t", prefix);
- col = 8;
- (void) walklist (changes, fmt_proc);
- (void) fprintf (fp, "\n");
- }
- type = T_ADDED;
- if (walklist (changes, find_type) != 0)
- {
- (void) fprintf (fp, "%sAdded Files:\n", prefix);
- (void) fprintf (fp, "%s\t", prefix);
- col = 8;
- (void) walklist (changes, fmt_proc);
- (void) fprintf (fp, "\n");
- }
- type = T_REMOVED;
- if (walklist (changes, find_type) != 0)
- {
- (void) fprintf (fp, "%sRemoved Files:\n", prefix);
- (void) fprintf (fp, "%s\t", prefix);
- col = 8;
- (void) walklist (changes, fmt_proc);
- (void) fprintf (fp, "\n");
- }
-}
-
-/*
- * Looks for nodes of a specified type and returns 1 if found
- */
-static int
-find_type (p)
- Node *p;
-{
- if (p->data == (char *) type)
- return (1);
- else
- return (0);
-}
-
-/*
- * Breaks the files list into reasonable sized lines to avoid line wrap...
- * all in the name of pretty output. It only works on nodes whose types
- * match the one we're looking for
- */
-static int
-fmt_proc (p)
- Node *p;
-{
- if (p->data == (char *) type)
- {
- if ((col + (int) strlen (p->key)) > 70)
- {
- (void) fprintf (fp, "\n%s\t", prefix);
- col = 8;
- }
- (void) fprintf (fp, "%s ", p->key);
- col += strlen (p->key) + 1;
- }
- return (0);
-}
-
-/*
- * Builds a temporary file using setup_tmpfile() and invokes the user's
- * editor on the file. The header garbage in the resultant file is then
- * stripped and the log message is stored in the "message" argument.
- *
- * rcsinfo - is the name of a file containing lines tacked onto the end of the
- * RCS info offered to the user for editing. If specified, the '-m' flag to
- * "commit" is disabled -- users are forced to run the editor.
- *
- */
-void
-do_editor (dir, message, repository, changes)
- char *dir;
- char *message;
- char *repository;
- List *changes;
-{
- static int reuse_log_message = 0;
- char line[MAXLINELEN], fname[L_tmpnam+1];
- char *orig_message;
- struct stat pre_stbuf, post_stbuf;
- int retcode = 0;
-
- if (noexec || reuse_log_message)
- return;
-
- orig_message = xstrdup (message); /* save it for later */
-
- /* Create a temporary file */
- (void) tmpnam (fname);
- again:
- if ((fp = fopen (fname, "w+")) == NULL)
- error (1, 0, "cannot create temporary file %s", fname);
-
- /* set up the file so that the first line is blank if no msg specified */
- if (*orig_message)
- {
- (void) fprintf (fp, "%s", orig_message);
- if (orig_message[strlen (orig_message) - 1] != '\n')
- (void) fprintf (fp, "\n");
- }
- else
- (void) fprintf (fp, "\n");
-
- /* tack templates on if necessary */
- (void) Parse_Info (CVSROOTADM_RCSINFO, repository, rcsinfo_proc, 1);
-
- (void) fprintf (fp,
- "%s----------------------------------------------------------------------\n",
- CVSEDITPREFIX);
- (void) fprintf (fp,
- "%sEnter Log. Lines beginning with `%s' are removed automatically\n%s\n",
- CVSEDITPREFIX, CVSEDITPREFIX, CVSEDITPREFIX);
- if (dir != NULL)
- (void) fprintf (fp, "%sCommitting in %s\n%s\n", CVSEDITPREFIX,
- dir, CVSEDITPREFIX);
- setup_tmpfile (fp, CVSEDITPREFIX, changes);
- (void) fprintf (fp,
- "%s----------------------------------------------------------------------\n",
- CVSEDITPREFIX);
-
- /* finish off the temp file */
- (void) fclose (fp);
- if (stat (fname, &pre_stbuf) == -1)
- pre_stbuf.st_mtime = 0;
-
- if (editinfo_editor)
- free (editinfo_editor);
- editinfo_editor = (char *) NULL;
- (void) Parse_Info (CVSROOTADM_EDITINFO, repository, editinfo_proc, 0);
-
- /* run the editor */
- run_setup ("%s", editinfo_editor ? editinfo_editor : Editor);
- run_arg (fname);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY,
- RUN_NORMAL | RUN_SIGIGNORE)) != 0)
- error (editinfo_editor ? 1 : 0, retcode == -1 ? errno : 0,
- editinfo_editor ? "Logfile verification failed" :
- "warning: editor session failed");
-
- /* put the entire message back into the message variable */
- fp = open_file (fname, "r");
- *message = '\0';
- while (fgets (line, sizeof (line), fp) != NULL)
- {
- if (strncmp (line, CVSEDITPREFIX, sizeof (CVSEDITPREFIX) - 1) == 0)
- continue;
- if (((int) strlen (message) + (int) strlen (line)) >= MAXMESGLEN)
- {
- error (0, 0, "warning: log message truncated!");
- break;
- }
- (void) strcat (message, line);
- }
- (void) fclose (fp);
- if ((stat (fname, &post_stbuf) == 0 &&
- pre_stbuf.st_mtime == post_stbuf.st_mtime) ||
- (*message == '\0' || strcmp (message, "\n") == 0))
- {
- for (;;)
- {
- (void) printf ("\nLog message unchanged or not specified\n");
- (void) printf ("a)bort, c)continue, e)dit, !)reuse this message unchanged for remaining dirs\n");
- (void) printf ("Action: (continue) ");
- (void) fflush (stdout);
- *line = '\0';
- (void) fgets (line, sizeof (line), stdin);
- if (*line == '\0' || *line == '\n' || *line == 'c' || *line == 'C')
- break;
- if (*line == 'a' || *line == 'A')
- error (1, 0, "aborted by user");
- if (*line == 'e' || *line == 'E')
- goto again;
- if (*line == '!')
- {
- reuse_log_message = 1;
- break;
- }
- (void) printf ("Unknown input\n");
- }
- }
- free (orig_message);
- (void) unlink_file (fname);
-}
-
-/*
- * callback proc for Parse_Info for rcsinfo templates this routine basically
- * copies the matching template onto the end of the tempfile we are setting
- * up
- */
-/* ARGSUSED */
-static int
-rcsinfo_proc (repository, template)
- char *repository;
- char *template;
-{
- static char *last_template;
- FILE *tfp;
- char line[MAXLINELEN];
-
- /* nothing to do if the last one included is the same as this one */
- if (last_template && strcmp (last_template, template) == 0)
- return (0);
- if (last_template)
- free (last_template);
- last_template = xstrdup (template);
-
- if ((tfp = fopen (template, "r")) != NULL)
- {
- while (fgets (line, sizeof (line), tfp) != NULL)
- (void) fputs (line, fp);
- (void) fclose (tfp);
- return (0);
- }
- else
- {
- error (0, 0, "Couldn't open rcsinfo template file %s", template);
- return (1);
- }
-}
-
-/*
- * Uses setup_tmpfile() to pass the updated message on directly to any
- * logfile programs that have a regular expression match for the checked in
- * directory in the source repository. The log information is fed into the
- * specified program as standard input.
- */
-static char *title;
-static FILE *logfp;
-static char *message;
-static char *revision;
-static List *changes;
-
-void
-Update_Logfile (repository, xmessage, xrevision, xlogfp, xchanges)
- char *repository;
- char *xmessage;
- char *xrevision;
- FILE *xlogfp;
- List *xchanges;
-{
- char *srepos;
-
- /* set up static vars for update_logfile_proc */
- message = xmessage;
- revision = xrevision;
- logfp = xlogfp;
- changes = xchanges;
-
- /* figure out a good title string */
- srepos = Short_Repository (repository);
-
- /* allocate a chunk of memory to hold the title string */
- if (!strlist)
- strlist = xmalloc (MAXLISTLEN);
- strlist[0] = '\0';
-
- type = T_TITLE;
- (void) walklist (changes, title_proc);
- type = T_ADDED;
- (void) walklist (changes, title_proc);
- type = T_MODIFIED;
- (void) walklist (changes, title_proc);
- type = T_REMOVED;
- (void) walklist (changes, title_proc);
- title = xmalloc (strlen (srepos) + strlen (strlist) + 1 + 2); /* for 's */
- (void) sprintf (title, "'%s%s'", srepos, strlist);
-
- /* to be nice, free up this chunk of memory */
- free (strlist);
- strlist = (char *) NULL;
-
- /* call Parse_Info to do the actual logfile updates */
- (void) Parse_Info (CVSROOTADM_LOGINFO, repository, update_logfile_proc, 1);
-
- /* clean up */
- free (title);
-}
-
-/*
- * callback proc to actually do the logfile write from Update_Logfile
- */
-static int
-update_logfile_proc (repository, filter)
- char *repository;
- char *filter;
-{
- return (logfile_write (repository, filter, title, message, revision,
- logfp, changes));
-}
-
-/*
- * concatenate each name onto strlist
- */
-static int
-title_proc (p)
- Node *p;
-{
- if (p->data == (char *) type)
- {
- (void) strcat (strlist, " ");
- (void) strcat (strlist, p->key);
- }
- return (0);
-}
-
-/*
- * Since some systems don't define this...
- */
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-
-/*
- * Writes some stuff to the logfile "filter" and returns the status of the
- * filter program.
- */
-static int
-logfile_write (repository, filter, title, message, revision, logfp, changes)
- char *repository;
- char *filter;
- char *title;
- char *message;
- char *revision;
- FILE *logfp;
- List *changes;
-{
- char cwd[PATH_MAX], host[MAXHOSTNAMELEN];
- FILE *pipefp, *Popen ();
- char *prog = xmalloc (MAXPROGLEN);
- char *cp;
- int c;
-
- /*
- * A maximum of 6 %s arguments are supported in the filter
- */
- (void) sprintf (prog, filter, title, title, title, title, title, title);
- if ((pipefp = Popen (prog, "w")) == NULL)
- {
- if (!noexec)
- error (0, 0, "cannot write entry to log filter: %s", prog);
- free (prog);
- return (1);
- }
- if (gethostname (host, sizeof (host)) < 0)
- (void) strcpy (host, "(unknown)");
- (void) fprintf (pipefp, "Update of %s\n", repository);
- (void) fprintf (pipefp, "In directory %s:%s\n\n", host,
- ((cp = getwd (cwd)) != NULL) ? cp : cwd);
- if (revision && *revision)
- (void) fprintf (pipefp, "Revision/Branch: %s\n\n", revision);
- setup_tmpfile (pipefp, "", changes);
- (void) fprintf (pipefp, "Log Message:\n%s\n", message);
- if (logfp != (FILE *) 0)
- {
- (void) fprintf (pipefp, "Status:\n");
- (void) rewind (logfp);
- while ((c = getc (logfp)) != EOF)
- (void) putc ((char) c, pipefp);
- }
- free (prog);
- return (pclose (pipefp));
-}
-
-/*
- * We choose to use the *last* match within the editinfo file for this
- * repository. This allows us to have a global editinfo program for the
- * root of some hierarchy, for example, and different ones within different
- * sub-directories of the root (like a special checker for changes made to
- * the "src" directory versus changes made to the "doc" or "test"
- * directories.
- */
-/* ARGSUSED */
-static int
-editinfo_proc(repository, editor)
- char *repository;
- char *editor;
-{
- /* nothing to do if the last match is the same as this one */
- if (editinfo_editor && strcmp (editinfo_editor, editor) == 0)
- return (0);
- if (editinfo_editor)
- free (editinfo_editor);
-
- editinfo_editor = xstrdup (editor);
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/main.c b/gnu/usr.bin/cvs/cvs/main.c
deleted file mode 100644
index ce10eb8..0000000
--- a/gnu/usr.bin/cvs/cvs/main.c
+++ /dev/null
@@ -1,444 +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.3 kit.
- *
- * This is the main C driver for the CVS system.
- *
- * Credit to Dick Grune, Vrije Universiteit, Amsterdam, for writing
- * the shell-script CVS system that this is based on.
- *
- * Usage:
- * cvs [options] command [options] [files/modules...]
- *
- * Where "command" is composed of:
- * admin RCS command
- * checkout Check out a module/dir/file
- * export Like checkout, but used for exporting sources
- * update Brings work tree in sync with repository
- * commit Checks files into the repository
- * diff Runs diffs between revisions
- * log Prints "rlog" information for files
- * add Adds an entry to the repository
- * remove Removes an entry from the repository
- * status Status info on the revisions
- * rdiff "patch" format diff listing between releases
- * tag Add/delete a symbolic tag to the RCS file
- * rtag Add/delete a symbolic tag to the RCS file
- * import Import sources into CVS, using vendor branches
- * release Indicate that Module is no longer in use.
- * history Display history of Users and Modules.
- */
-
-#include "cvs.h"
-#include "patchlevel.h"
-
-char rcsid[] = "@(#)main.c 1.64 92/03/31\n";
-
-extern char *getenv ();
-
-char *program_name;
-char *command_name = "";
-
-int use_editor = TRUE;
-int cvswrite = !CVSREAD_DFLT;
-int really_quiet = FALSE;
-int quiet = FALSE;
-int trace = FALSE;
-int noexec = FALSE;
-int logoff = FALSE;
-
-char *CurDir;
-
-/*
- * Defaults, for the environment variables that are not set
- */
-char *Rcsbin = RCSBIN_DFLT;
-char *Editor = EDITOR_DFLT;
-char *CVSroot = CVSROOT_DFLT;
-
-#if __STDC__
-int add (int argc, char **argv);
-int admin (int argc, char **argv);
-int checkout (int argc, char **argv);
-int commit (int argc, char **argv);
-int diff (int argc, char **argv);
-int history (int argc, char **argv);
-int import (int argc, char **argv);
-int cvslog (int argc, char **argv);
-int patch (int argc, char **argv);
-int release (int argc, char **argv);
-int cvsremove (int argc, char **argv);
-int rtag (int argc, char **argv);
-int status (int argc, char **argv);
-int tag (int argc, char **argv);
-int update (int argc, char **argv);
-#else
-int add ();
-int admin ();
-int checkout ();
-int commit ();
-int diff ();
-int history ();
-int import ();
-int cvslog ();
-int patch ();
-int release ();
-int cvsremove ();
-int rtag ();
-int status ();
-int tag ();
-int update ();
-#endif /* __STDC__ */
-
-struct cmd
-{
- char *fullname; /* Full name of the function (e.g. "commit") */
- char *nick1; /* alternate name (e.g. "ci") */
- char *nick2; /* another alternate names (e.g. "ci") */
- int (*func) (); /* Function takes (argc, argv) arguments. */
-} cmds[] =
-
-{
- { "add", "ad", "new", add },
- { "admin", "adm", "rcs", admin },
- { "checkout", "co", "get", checkout },
- { "commit", "ci", "com", commit },
- { "diff", "di", "dif", diff },
- { "export", "exp", "ex", checkout },
- { "history", "hi", "his", history },
- { "import", "im", "imp", import },
- { "log", "lo", "rlog", cvslog },
- { "rdiff", "patch", "pa", patch },
- { "release", "re", "rel", release },
- { "remove", "rm", "delete", cvsremove },
- { "status", "st", "stat", status },
- { "rtag", "rt", "rfreeze", rtag },
- { "tag", "ta", "freeze", tag },
- { "update", "up", "upd", update },
- { NULL, NULL, NULL, NULL },
-};
-
-static char *usg[] =
-{
- "Usage: %s [cvs-options] command [command-options] [files...]\n",
- " Where 'cvs-options' are:\n",
- " -H Displays Usage information for command\n",
- " -Q Cause CVS to be really quiet.\n",
- " -q Cause CVS to be somewhat quiet.\n",
- " -r Make checked-out files read-only\n",
- " -w Make checked-out files read-write (default)\n",
- " -l Turn History logging off\n",
- " -n Do not execute anything that will change the disk\n",
- " -t Show trace of program execution -- Try with -n\n",
- " -v CVS version and copyright\n",
- " -b bindir Find RCS programs in 'bindir'\n",
- " -e editor Use 'editor' for editing log information\n",
- " -d CVS_root Overrides $CVSROOT as the root of the CVS tree\n",
- "\n",
- " and where 'command' is:\n",
- " add Adds a new file/directory to the repository\n",
- " admin Administration front end for rcs\n",
- " checkout Checkout sources for editing\n",
- " commit Checks files into the repository\n",
- " diff Runs diffs between revisions\n",
- " history Shows status of files and users\n",
- " import Import sources into CVS, using vendor branches\n",
- " export Export sources from CVS, similar to checkout\n",
- " log Prints out 'rlog' information for files\n",
- " rdiff 'patch' format diffs between releases\n",
- " release Indicate that a Module is no longer in use\n",
- " remove Removes an entry from the repository\n",
- " status Status info on the revisions\n",
- " tag Add a symbolic tag to checked out version of RCS file\n",
- " rtag Add a symbolic tag to the RCS file\n",
- " update Brings work tree in sync with repository\n",
- NULL,
-};
-
-static SIGTYPE
-main_cleanup ()
-{
- exit (1);
-}
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- extern char *version_string;
- char *cp;
- struct cmd *cm;
- int c, help = FALSE, err = 0;
- int rcsbin_update_env, cvs_update_env;
- char tmp[PATH_MAX];
-
- /*
- * Just save the last component of the path for error messages
- */
- if ((program_name = rindex (argv[0], '/')) == NULL)
- program_name = argv[0];
- else
- program_name++;
-
- CurDir = xmalloc (PATH_MAX);
- if (!getwd (CurDir))
- error (1, 0, "cannot get working directory: %s", CurDir);
-
- /*
- * Query the environment variables up-front, so that
- * they can be overridden by command line arguments
- */
- rcsbin_update_env = *Rcsbin; /* RCSBIN_DFLT must be set */
- if ((cp = getenv (RCSBIN_ENV)) != NULL)
- {
- Rcsbin = cp;
- rcsbin_update_env = 0; /* it's already there */
- }
- if ((cp = getenv (EDITOR_ENV)) != NULL)
- Editor = cp;
- if ((cp = getenv (CVSROOT_ENV)) != NULL)
- {
- CVSroot = cp;
- cvs_update_env = 0; /* it's already there */
- }
- if (getenv (CVSREAD_ENV) != NULL)
- cvswrite = FALSE;
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "Qqrwtnlvb:e:d:H")) != -1)
- {
- switch (c)
- {
- case 'Q':
- really_quiet = TRUE;
- /* FALL THROUGH */
- case 'q':
- quiet = TRUE;
- break;
- case 'r':
- cvswrite = FALSE;
- break;
- case 'w':
- cvswrite = TRUE;
- break;
- case 't':
- trace = TRUE;
- break;
- case 'n':
- noexec = TRUE;
- case 'l': /* Fall through */
- logoff = TRUE;
- break;
- case 'v':
- (void) fputs (rcsid, stdout);
- (void) fputs (version_string, stdout);
- (void) sprintf (tmp, "Patch Level: %d\n", PATCHLEVEL);
- (void) fputs (tmp, stdout);
- (void) fputs ("\nCopyright (c) 1992, Brian Berliner and Jeff Polk\nCopyright (c) 1989-1992, Brian Berliner\n\nCVS may be copied only under the terms of the GNU General Public License,\na copy of which can be found with the CVS 1.3 distribution kit.\n", stdout);
- exit (0);
- break;
- case 'b':
- Rcsbin = optarg;
- rcsbin_update_env = 1; /* need to update environment */
- break;
- case 'e':
- Editor = optarg;
- break;
- case 'd':
- CVSroot = optarg;
- cvs_update_env = 1; /* need to update environment */
- break;
- case 'H':
- help = TRUE;
- break;
- case '?':
- default:
- usage (usg);
- }
- }
- argc -= optind;
- argv += optind;
- if (argc < 1)
- usage (usg);
-
- /*
- * XXX - Compatibility. This can be removed in the release after CVS 1.3.
- * Try to rename the CVSROOT.adm file to CVSROOT, unless there already is
- * a CVSROOT directory.
- */
- if (CVSroot != NULL)
- {
- char rootadm[PATH_MAX];
- char orootadm[PATH_MAX];
-
- (void) sprintf (rootadm, "%s/%s", CVSroot, CVSROOTADM);
- if (!isdir (rootadm))
- {
- (void) sprintf (orootadm, "%s/%s", CVSroot, OCVSROOTADM);
- if (isdir (orootadm))
- (void) rename (orootadm, rootadm);
- }
- strip_path (CVSroot);
- }
-
- /*
- * Specifying just the '-H' flag to the sub-command causes a Usage
- * message to be displayed.
- */
- command_name = cp = argv[0];
- if (help == TRUE || (argc > 1 && strcmp (argv[1], "-H") == 0))
- argc = -1;
- else
- {
- /*
- * Check to see if we can write into the history file. If not,
- * we assume that we can't work in the repository.
- * BUT, only if the history file exists.
- */
- {
- char path[PATH_MAX];
- int save_errno;
-
- if (!CVSroot || !*CVSroot)
- error (1, 0, "You don't have a %s environment variable",
- CVSROOT_ENV);
- (void) sprintf (path, "%s/%s", CVSroot, CVSROOTADM);
- if (access (path, R_OK | X_OK))
- {
- save_errno = errno;
- error (0, 0,
- "Sorry, you don't have sufficient access to %s", CVSroot);
- error (1, save_errno, "%s", path);
- }
- (void) strcat (path, "/");
- (void) strcat (path, CVSROOTADM_HISTORY);
- if (isfile (path) && access (path, R_OK | W_OK))
- {
- save_errno = errno;
- error (0, 0,
- "Sorry, you don't have read/write access to the history file");
- error (1, save_errno, "%s", path);
- }
- }
- }
-
-#ifndef PUTENV_MISSING
- /* Now, see if we should update the environment with the Rcsbin value */
- if (cvs_update_env)
- {
- char *env;
-
- env = xmalloc (strlen (CVSROOT_ENV) + strlen (CVSroot) + 1 + 1);
- (void) sprintf (env, "%s=%s", CVSROOT_ENV, CVSroot);
- (void) putenv (env);
- /* do not free env, as putenv has control of it */
- }
- if (rcsbin_update_env)
- {
- char *env;
-
- env = xmalloc (strlen (RCSBIN_ENV) + strlen (Rcsbin) + 1 + 1);
- (void) sprintf (env, "%s=%s", RCSBIN_ENV, Rcsbin);
- (void) putenv (env);
- /* do not free env, as putenv has control of it */
- }
-#endif
-
- /*
- * If Rcsbin is set to something, make sure it is terminated with
- * a slash character. If not, add one.
- */
- if (*Rcsbin)
- {
- int len = strlen (Rcsbin);
- char *rcsbin;
-
- if (Rcsbin[len - 1] != '/')
- {
- rcsbin = Rcsbin;
- Rcsbin = xmalloc (len + 2); /* one for '/', one for NULL */
- (void) strcpy (Rcsbin, rcsbin);
- (void) strcat (Rcsbin, "/");
- }
- }
-
- for (cm = cmds; cm->fullname; cm++)
- {
- if (cm->nick1 && !strcmp (cp, cm->nick1))
- break;
- if (cm->nick2 && !strcmp (cp, cm->nick2))
- break;
- if (!strcmp (cp, cm->fullname))
- break;
- }
-
- if (!cm->fullname)
- usage (usg); /* no match */
- else
- {
- command_name = cm->fullname; /* Global pointer for later use */
- (void) SIG_register (SIGHUP, main_cleanup);
- (void) SIG_register (SIGINT, main_cleanup);
- (void) SIG_register (SIGQUIT, main_cleanup);
- (void) SIG_register (SIGPIPE, main_cleanup);
- (void) SIG_register (SIGTERM, main_cleanup);
-
-#ifndef SETVBUF_MISSING
- /*
- * Make stdout line buffered, so 'tail -f' can monitor progress.
- * Patch creates too much output to monitor and it runs slowly.
- */
- if (strcmp (cm->fullname, "patch"))
- (void) setvbuf (stdout, (char *) NULL, _IOLBF, 0);
-#endif
-
- err = (*(cm->func)) (argc, argv);
- }
- /*
- * If the command's error count is modulo 256, we need to change it
- * so that we don't overflow the 8-bits we get to report exit status
- */
- if (err && (err % 256) == 0)
- err = 1;
- Lock_Cleanup ();
- return (err);
-}
-
-char *
-Make_Date (rawdate)
- char *rawdate;
-{
- struct tm *ftm;
- time_t unixtime;
- char date[256]; /* XXX bigger than we'll ever need? */
- char *ret;
-
- unixtime = get_date (rawdate, (struct timeb *) NULL);
- if (unixtime == (time_t) - 1)
- error (1, 0, "Can't parse date/time: %s", rawdate);
-#ifdef HAVE_RCS5
- ftm = gmtime (&unixtime);
-#else
- ftm = localtime (&unixtime);
-#endif
- (void) sprintf (date, DATEFORM,
- ftm->tm_year + (ftm->tm_year < 100 ? 0 : 1900),
- ftm->tm_mon + 1, ftm->tm_mday, ftm->tm_hour,
- ftm->tm_min, ftm->tm_sec);
- ret = xstrdup (date);
- return (ret);
-}
-
-void
-usage (cpp)
- register char **cpp;
-{
- (void) fprintf (stderr, *cpp++, program_name, command_name);
- for (; *cpp; cpp++)
- (void) fprintf (stderr, *cpp);
- exit (1);
-}
diff --git a/gnu/usr.bin/cvs/cvs/modules.c b/gnu/usr.bin/cvs/cvs/modules.c
deleted file mode 100644
index b0658d7..0000000
--- a/gnu/usr.bin/cvs/cvs/modules.c
+++ /dev/null
@@ -1,810 +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.3 kit.
- *
- * Modules
- *
- * Functions for accessing the modules file.
- *
- * The modules file supports basically three formats of lines:
- * key [options] directory files... [ -x directory [files] ] ...
- * key [options] directory [ -x directory [files] ] ...
- * key -a aliases...
- *
- * The -a option allows an aliasing step in the parsing of the modules
- * file. The "aliases" listed on a line following the -a are
- * processed one-by-one, as if they were specified as arguments on the
- * command line.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)modules.c 1.57 92/04/10";
-#endif
-
-struct sortrec
-{
- char *modname;
- char *status;
- char *rest;
- char *comment;
-};
-
-#if __STDC__
-static int sort_order (CONST PTR l, CONST PTR r);
-static void save_d (char *k, int ks, char *d, int ds);
-#else
-static int sort_order ();
-static void save_d ();
-#endif /* __STDC__ */
-
-
-/*
- * Open the modules file, and die if the CVSROOT environment variable
- * was not set. If the modules file does not exist, that's fine, and
- * a warning message is displayed and a NULL is returned.
- */
-DBM *
-open_module ()
-{
- char mfile[PATH_MAX];
-
- if (CVSroot == NULL)
- {
- (void) fprintf (stderr,
- "%s: must set the CVSROOT environment variable\n",
- program_name);
- error (1, 0, "or specify the '-d' option to %s", program_name);
- }
- (void) sprintf (mfile, "%s/%s/%s", CVSroot, CVSROOTADM, CVSROOTADM_MODULES);
- return (dbm_open (mfile, O_RDONLY, 0666));
-}
-
-/*
- * Close the modules file, if the open succeeded, that is
- */
-void
-close_module (db)
- DBM *db;
-{
- if (db != NULL)
- dbm_close (db);
-}
-
-/*
- * This is the recursive function that processes a module name.
- * It calls back the passed routine for each directory of a module
- * It runs the post checkout or post tag proc from the modules file
- */
-int
-do_module (db, mname, m_type, msg, callback_proc, where,
- shorten, local_specified, run_module_prog, extra_arg)
- DBM *db;
- char *mname;
- enum mtype m_type;
- char *msg;
- int (*callback_proc) ();
- char *where;
- int shorten;
- int local_specified;
- int run_module_prog;
- char *extra_arg;
-{
- char *checkin_prog = NULL;
- char *checkout_prog = NULL;
- char *tag_prog = NULL;
- char *update_prog = NULL;
- char cwd[PATH_MAX];
- char line[MAXLINELEN];
- char *xmodargv[MAXFILEPERDIR];
- char **modargv;
- char *value;
- char *zvalue;
- char *mwhere = NULL;
- char *mfile = NULL;
- char *spec_opt = NULL;
- char xvalue[PATH_MAX];
- int modargc, alias = 0;
- datum key, val;
- char *cp;
- int c, err = 0;
-
- /* remember where we start */
- if (getwd (cwd) == NULL)
- error (1, 0, "cannot get current working directory: %s", cwd);
-
- /* strip extra stuff from the module name */
- strip_path (mname);
-
- /*
- * Look up the module using the following scheme:
- * 1) look for mname as a module name
- * 2) look for mname as a directory
- * 3) look for mname as a file
- * 4) take mname up to the first slash and look it up as a module name
- * (this is for checking out only part of a module)
- */
-
- /* look it up as a module name */
- key.dptr = mname;
- key.dsize = strlen (key.dptr);
- if (db != NULL)
- val = dbm_fetch (db, key);
- else
- val.dptr = NULL;
- if (val.dptr != NULL)
- {
- /* null terminate the value XXX - is this space ours? */
- val.dptr[val.dsize] = '\0';
-
- /* If the line ends in a comment, strip it off */
- if ((cp = index (val.dptr, '#')) != NULL)
- {
- do
- *cp-- = '\0';
- while (isspace (*cp));
- }
- value = val.dptr;
- mwhere = xstrdup (mname);
- goto found;
- }
- else
- {
- char file[PATH_MAX];
- char attic_file[PATH_MAX];
- char *acp;
-
- /* check to see if mname is a directory or file */
-
- (void) sprintf (file, "%s/%s", CVSroot, mname);
- if ((acp = rindex (mname, '/')) != NULL)
- {
- *acp = '\0';
- (void) sprintf (attic_file, "%s/%s/%s/%s%s", CVSroot, mname,
- CVSATTIC, acp + 1, RCSEXT);
- *acp = '/';
- }
- else
- (void) sprintf (attic_file, "%s/%s/%s%s", CVSroot, CVSATTIC,
- mname, RCSEXT);
-
- if (isdir (file))
- {
- value = mname;
- goto found;
- }
- else
- {
- (void) strcat (file, RCSEXT);
- if (isfile (file) || isfile (attic_file))
- {
- /* if mname was a file, we have to split it into "dir file" */
- if ((cp = rindex (mname, '/')) != NULL && cp != mname)
- {
- char *slashp;
-
- /* put the ' ' in a copy so we don't mess up the original */
- value = strcpy (xvalue, mname);
- slashp = rindex (value, '/');
- *slashp = ' ';
- }
- else
- {
- /*
- * the only '/' at the beginning or no '/' at all
- * means the file we are interested in is in CVSROOT
- * itself so the directory should be '.'
- */
- if (cp == mname)
- {
- /* drop the leading / if specified */
- value = strcpy (xvalue, ". ");
- (void) strcat (xvalue, mname + 1);
- }
- else
- {
- /* otherwise just copy it */
- value = strcpy (xvalue, ". ");
- (void) strcat (xvalue, mname);
- }
- }
- goto found;
- }
- }
- }
-
- /* look up everything to the first / as a module */
- if (mname[0] != '/' && (cp = index (mname, '/')) != NULL)
- {
- /* Make the slash the new end of the string temporarily */
- *cp = '\0';
- key.dptr = mname;
- key.dsize = strlen (key.dptr);
-
- /* do the lookup */
- if (db != NULL)
- val = dbm_fetch (db, key);
- else
- val.dptr = NULL;
-
- /* if we found it, clean up the value and life is good */
- if (val.dptr != NULL)
- {
- char *cp2;
-
- /* null terminate the value XXX - is this space ours? */
- val.dptr[val.dsize] = '\0';
-
- /* If the line ends in a comment, strip it off */
- if ((cp2 = index (val.dptr, '#')) != NULL)
- {
- do
- *cp2-- = '\0';
- while (isspace (*cp2));
- }
- value = val.dptr;
-
- /* mwhere gets just the module name */
- mwhere = xstrdup (mname);
- mfile = cp + 1;
-
- /* put the / back in mname */
- *cp = '/';
-
- goto found;
- }
-
- /* put the / back in mname */
- *cp = '/';
- }
-
- /* if we got here, we couldn't find it using our search, so give up */
- error (0, 0, "cannot find module `%s' - ignored", mname);
- err++;
- if (mwhere)
- free (mwhere);
- return (err);
-
-
- /*
- * At this point, we found what we were looking for in one
- * of the many different forms.
- */
- found:
-
- /* copy value to our own string since if we go recursive we'll be
- really screwed if we do another dbm lookup */
- zvalue = xstrdup (value);
- value = zvalue;
-
- /* search the value for the special delimiter and save for later */
- if ((cp = index (value, CVSMODULE_SPEC)) != NULL)
- {
- *cp = '\0'; /* null out the special char */
- spec_opt = cp + 1; /* save the options for later */
-
- if (cp != value) /* strip whitespace if necessary */
- while (isspace (*--cp))
- *cp = '\0';
-
- if (cp == value)
- {
- /*
- * we had nothing but special options, so skip arg
- * parsing and regular stuff entirely
- *
- * If there were only special ones though, we must
- * make the appropriate directory and cd to it
- */
- char *dir;
-
- /* XXX - XXX - MAJOR HACK - DO NOT SHIP - this needs to
- be !pipeout, but we don't know that here yet */
- if (!run_module_prog)
- goto out;
-
- dir = where ? where : mname;
- /* XXX - think about making null repositories at each dir here
- instead of just at the bottom */
- make_directories (dir);
- if (chdir (dir) < 0)
- {
- error (0, errno, "cannot chdir to %s", dir);
- spec_opt = NULL;
- err++;
- goto out;
- }
- if (!isfile (CVSADM) && !isfile (OCVSADM))
- {
- char nullrepos[PATH_MAX];
-
- (void) sprintf (nullrepos, "%s/%s/%s", CVSroot,
- CVSROOTADM, CVSNULLREPOS);
- if (!isfile (nullrepos))
- (void) mkdir (nullrepos, 0777);
- Create_Admin (".", nullrepos, (char *) NULL, (char *) NULL);
- if (!noexec)
- {
- FILE *fp;
-
- fp = open_file (CVSADM_ENTSTAT, "w+");
- if (fclose (fp) == EOF)
- error (1, errno, "cannot close %s", CVSADM_ENTSTAT);
- }
- }
- out:
- goto do_special;
- }
- }
-
- /* don't do special options only part of a module was specified */
- if (mfile != NULL)
- spec_opt = NULL;
-
- /*
- * value now contains one of the following:
- * 1) dir
- * 2) dir file
- * 3) the value from modules without any special args
- * [ args ] dir [file] [file] ...
- * or -a module [ module ] ...
- */
-
- /* Put the value on a line with XXX prepended for getopt to eat */
- (void) sprintf (line, "%s %s", "XXX", value);
-
- /* turn the line into an argv[] array */
- line2argv (&modargc, xmodargv, line);
- modargv = xmodargv;
-
- /* parse the args */
- optind = 1;
- while ((c = gnu_getopt (modargc, modargv, CVSMODULE_OPTS)) != -1)
- {
- switch (c)
- {
- case 'a':
- alias = 1;
- break;
- case 'd':
- if (mwhere)
- free (mwhere);
- mwhere = xstrdup (optarg);
- break;
- case 'i':
- checkin_prog = optarg;
- break;
- case 'l':
- local_specified = 1;
- case 'o':
- checkout_prog = optarg;
- break;
- case 't':
- tag_prog = optarg;
- break;
- case 'u':
- update_prog = optarg;
- break;
- case '?':
- error (0, 0,
- "modules file has invalid option for key %s value %s",
- key.dptr, val.dptr);
- err++;
- if (mwhere)
- free (mwhere);
- free (zvalue);
- return (err);
- }
- }
- modargc -= optind;
- modargv += optind;
- if (modargc == 0)
- {
- error (0, 0, "modules file missing directory for module %s", mname);
- if (mwhere)
- free (mwhere);
- free (zvalue);
- return (++err);
- }
-
- /* if this was an alias, call ourselves recursively for each module */
- if (alias)
- {
- int i;
-
- for (i = 0; i < modargc; i++)
- err += do_module (db, modargv[i], m_type, msg, callback_proc,
- where, shorten, local_specified,
- run_module_prog, extra_arg);
- if (mwhere)
- free (mwhere);
- free (zvalue);
- return (err);
- }
-
- /* otherwise, process this module */
- err += callback_proc (&modargc, modargv, where, mwhere, mfile, shorten,
- local_specified, mname, msg);
-
- /* clean up */
- free_names (&modargc, modargv);
-
- /* if there were special include args, process them now */
-
- do_special:
-
- /* blow off special options if -l was specified */
- if (local_specified)
- spec_opt = NULL;
-
- while (spec_opt != NULL)
- {
- char *next_opt;
-
- cp = index (spec_opt, CVSMODULE_SPEC);
- if (cp != NULL)
- {
- /* save the beginning of the next arg */
- next_opt = cp + 1;
-
- /* strip whitespace off the end */
- do
- *cp = '\0';
- while (isspace (*--cp));
- }
- else
- next_opt = NULL;
-
- /* strip whitespace from front */
- while (isspace (*spec_opt))
- spec_opt++;
-
- if (*spec_opt == '\0')
- error (0, 0, "Mal-formed %c option for module %s - ignored",
- CVSMODULE_SPEC, mname);
- else
- err += do_module (db, spec_opt, m_type, msg, callback_proc,
- (char *) NULL, 0, local_specified,
- run_module_prog, extra_arg);
- spec_opt = next_opt;
- }
-
- /* write out the checkin/update prog files if necessary */
- if (err == 0 && !noexec && m_type == CHECKOUT && run_module_prog)
- {
- FILE *fp;
-
- if (checkin_prog != NULL)
- {
- fp = open_file (CVSADM_CIPROG, "w+");
- (void) fprintf (fp, "%s\n", checkin_prog);
- if (fclose (fp) == EOF)
- error (1, errno, "cannot close %s", CVSADM_CIPROG);
- }
- if (update_prog != NULL)
- {
- fp = open_file (CVSADM_UPROG, "w+");
- (void) fprintf (fp, "%s\n", update_prog);
- if (fclose (fp) == EOF)
- error (1, errno, "cannot close %s", CVSADM_UPROG);
- }
- }
-
- /* cd back to where we started */
- if (chdir (cwd) < 0)
- error (1, errno, "failed chdir to %s!", cwd);
-
- /* run checkout or tag prog if appropriate */
- if (err == 0 && run_module_prog)
- {
- if ((m_type == TAG && tag_prog != NULL) ||
- (m_type == CHECKOUT && checkout_prog != NULL))
- {
- /*
- * If a relative pathname is specified as the checkout or
- * tag proc, try to tack on the current "where" value.
- * if we can't find a matching program, just punt and use
- * whatever is specified in the modules file.
- */
- char real_prog[PATH_MAX];
- char *prog = (m_type == TAG ? tag_prog : checkout_prog);
- char *real_where = (where != NULL ? where : mwhere);
-
- if ((*prog != '/') && (*prog != '.'))
- {
- (void) sprintf (real_prog, "%s/%s", real_where, prog);
- if (isfile (real_prog))
- prog = real_prog;
- }
-
- run_setup ("%s %s", prog, real_where);
- if (extra_arg)
- run_arg (extra_arg);
-
- if (!quiet)
- {
- (void) printf ("%s %s: Executing '", program_name,
- command_name);
- run_print (stdout);
- (void) printf ("'\n");
- }
- err += run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
- }
-
- /* clean up */
- if (mwhere)
- free (mwhere);
- free (zvalue);
-
- return (err);
-}
-
-/* - Read all the records from the modules database into an array.
- - Sort the array depending on what format is desired.
- - Print the array in the format desired.
-
- Currently, there are only two "desires":
-
- 1. Sort by module name and format the whole entry including switches,
- files and the comment field: (Including aliases)
-
- modulename -s switches, one per line, even if
- -i it has many switches.
- Directories and files involved, formatted
- to cover multiple lines if necessary.
- # Comment, also formatted to cover multiple
- # lines if necessary.
-
- 2. Sort by status field string and print: (*not* including aliases)
-
- modulename STATUS Directories and files involved, formatted
- to cover multiple lines if necessary.
- # Comment, also formatted to cover multiple
- # lines if necessary.
-*/
-
-static struct sortrec *s_head;
-
-static int s_max = 0; /* Number of elements allocated */
-static int s_count = 0; /* Number of elements used */
-
-static int Status;
-static char def_status[] = "NONE";
-
-/* Sort routine for qsort:
- - If we want the "Status" field to be sorted, check it first.
- - Then compare the "module name" fields. Since they are unique, we don't
- have to look further.
-*/
-static int
-sort_order (l, r)
- CONST PTR l;
- CONST PTR r;
-{
- int i;
- CONST struct sortrec *left = (CONST struct sortrec *) l;
- CONST struct sortrec *right = (CONST struct sortrec *) r;
-
- if (Status)
- {
- /* If Sort by status field, compare them. */
- if ((i = strcmp (left->status, right->status)) != 0)
- return (i);
- }
- return (strcmp (left->modname, right->modname));
-}
-
-static void
-save_d (k, ks, d, ds)
- char *k;
- int ks;
- char *d;
- int ds;
-{
- char *cp, *cp2;
- struct sortrec *s_rec;
-
- if (Status && *d == '-' && *(d + 1) == 'a')
- return; /* We want "cvs co -s" and it is an alias! */
-
- if (s_count == s_max)
- {
- s_max += 64;
- s_head = (struct sortrec *) xrealloc ((char *) s_head, s_max * sizeof (*s_head));
- }
- s_rec = &s_head[s_count];
- s_rec->modname = cp = xmalloc (ks + 1);
- (void) strncpy (cp, k, ks);
- *(cp + ks) = '\0';
-
- s_rec->rest = cp2 = xmalloc (ds + 1);
- cp = d;
- *(cp + ds) = '\0'; /* Assumes an extra byte at end of static dbm buffer */
-
- while (isspace (*cp))
- cp++;
- /* Turn <spaces> into one ' ' -- makes the rest of this routine simpler */
- while (*cp)
- {
- if (isspace (*cp))
- {
- *cp2++ = ' ';
- while (isspace (*cp))
- cp++;
- }
- else
- *cp2++ = *cp++;
- }
- *cp2 = '\0';
-
- /* Look for the "-s statusvalue" text */
- if (Status)
- {
- s_rec->status = def_status;
-
- /* Minor kluge, but general enough to maintain */
- for (cp = s_rec->rest; (cp2 = index (cp, '-')) != NULL; cp = ++cp2)
- {
- if (*(cp2 + 1) == 's' && *(cp2 + 2) == ' ')
- {
- s_rec->status = (cp2 += 3);
- while (*cp2 != ' ')
- cp2++;
- *cp2++ = '\0';
- cp = cp2;
- break;
- }
- }
- }
- else
- cp = s_rec->rest;
-
- /* Find comment field, clean up on all three sides & compress blanks */
- if ((cp2 = cp = index (cp, '#')) != NULL)
- {
- if (*--cp2 == ' ')
- *cp2 = '\0';
- if (*++cp == ' ')
- cp++;
- s_rec->comment = cp;
- }
- else
- s_rec->comment = "";
-
- s_count++;
-}
-
-void
-cat_module (status)
- int status;
-{
- DBM *db;
- datum key, val;
- int i, c, wid, argc, cols = 80, indent, fill;
- int moduleargc;
- struct sortrec *s_h;
- char *cp, *cp2, **argv;
- char line[MAXLINELEN], *moduleargv[MAXFILEPERDIR];
-
-#ifdef sun
-#ifdef TIOCGSIZE
- struct ttysize ts;
-
- (void) ioctl (0, TIOCGSIZE, &ts);
- cols = ts.ts_cols;
-#endif
-#else
-#ifdef TIOCGWINSZ
- struct winsize ws;
-
- (void) ioctl (0, TIOCGWINSZ, &ws);
- cols = ws.ws_col;
-#endif
-#endif
-
- Status = status;
-
- /* Read the whole modules file into allocated records */
- if (!(db = open_module ()))
- error (1, 0, "failed to open the modules file");
-
- for (key = dbm_firstkey (db); key.dptr != NULL; key = dbm_nextkey (db))
- {
- val = dbm_fetch (db, key);
- if (val.dptr != NULL)
- save_d (key.dptr, key.dsize, val.dptr, val.dsize);
- }
-
- /* Sort the list as requested */
- qsort ((PTR) s_head, s_count, sizeof (struct sortrec), sort_order);
-
- /*
- * Run through the sorted array and format the entries
- * indent = space for modulename + space for status field
- */
- indent = 12 + (status * 12);
- fill = cols - (indent + 2);
- for (s_h = s_head, i = 0; i < s_count; i++, s_h++)
- {
- /* Print module name (and status, if wanted) */
- (void) printf ("%-12s", s_h->modname);
- if (status)
- {
- (void) printf (" %-11s", s_h->status);
- if (s_h->status != def_status)
- *(s_h->status + strlen (s_h->status)) = ' ';
- }
-
- /* Parse module file entry as command line and print options */
- (void) sprintf (line, "%s %s", s_h->modname, s_h->rest);
- line2argv (&moduleargc, moduleargv, line);
- argc = moduleargc;
- argv = moduleargv;
-
- optind = 1;
- wid = 0;
- while ((c = gnu_getopt (argc, argv, CVSMODULE_OPTS)) != -1)
- {
- if (!status)
- {
- if (c == 'a')
- {
- (void) printf (" -a");
- wid += 3; /* Could just set it to 3 */
- }
- else
- {
- if (strlen (optarg) + 4 + wid > (unsigned) fill)
- {
- (void) printf ("\n%*s", indent, "");
- wid = 0;
- }
- (void) printf (" -%c %s", c, optarg);
- wid += strlen (optarg) + 4;
- }
- }
- }
- argc -= optind;
- argv += optind;
-
- /* Format and Print all the files and directories */
- for (; argc--; argv++)
- {
- if (strlen (*argv) + wid > (unsigned) fill)
- {
- (void) printf ("\n%*s", indent, "");
- wid = 0;
- }
- (void) printf (" %s", *argv);
- wid += strlen (*argv) + 1;
- }
- (void) printf ("\n");
-
- /* Format the comment field -- save_d (), compressed spaces */
- for (cp2 = cp = s_h->comment; *cp; cp2 = cp)
- {
- (void) printf ("%*s # ", indent, "");
- if (strlen (cp2) < (unsigned) (fill - 2))
- {
- (void) printf ("%s\n", cp2);
- break;
- }
- cp += fill - 2;
- while (*cp != ' ' && cp > cp2)
- cp--;
- if (cp == cp2)
- {
- (void) printf ("%s\n", cp2);
- break;
- }
-
- *cp++ = '\0';
- (void) printf ("%s\n", cp2);
- }
- }
-}
diff --git a/gnu/usr.bin/cvs/cvs/no_diff.c b/gnu/usr.bin/cvs/cvs/no_diff.c
deleted file mode 100644
index 4057c88..0000000
--- a/gnu/usr.bin/cvs/cvs/no_diff.c
+++ /dev/null
@@ -1,85 +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.3 kit.
- *
- * No Difference
- *
- * The user file looks modified judging from its time stamp; however it needn't
- * be. No_difference() finds out whether it is or not. If it is not, it
- * updates the administration.
- *
- * returns 0 if no differences are found and non-zero otherwise
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)no_diff.c 1.35 92/03/31";
-#endif
-
-int
-No_Difference (file, vers, entries)
- char *file;
- Vers_TS *vers;
- List *entries;
-{
- Node *p;
- char tmp[L_tmpnam+1];
- int ret;
- char *ts, *options;
- int retcode = 0;
-
- if (!vers->srcfile || !vers->srcfile->path)
- return (-1); /* different since we couldn't tell */
-
- if (vers->entdata && vers->entdata->options)
- options = xstrdup (vers->entdata->options);
- else
- options = xstrdup ("");
-
- run_setup ("%s%s -p -q -r%s %s", Rcsbin, RCS_CO,
- vers->vn_user ? vers->vn_user : "", options);
- run_arg (vers->srcfile->path);
- if ((retcode = run_exec (RUN_TTY, tmpnam (tmp), RUN_TTY, RUN_REALLY)) == 0)
- {
- if (!iswritable (file)) /* fix the modes as a side effect */
- xchmod (file, 1);
-
- /* do the byte by byte compare */
- if (xcmp (file, tmp) == 0)
- {
- if (cvswrite == FALSE) /* fix the modes as a side effect */
- xchmod (file, 0);
-
- /* no difference was found, so fix the entries file */
- ts = time_stamp (file);
- Register (entries, file,
- vers->vn_user ? vers->vn_user : vers->vn_rcs, ts,
- options, vers->tag, vers->date);
- free (ts);
-
- /* update the entdata pointer in the vers_ts structure */
- p = findnode (entries, file);
- vers->entdata = (Entnode *) p->data;
-
- ret = 0;
- }
- else
- ret = 1; /* files were really different */
- }
- else
- {
- error (0, retcode == -1 ? errno : 0,
- "could not check out revision %s of %s", vers->vn_user, file);
- ret = -1; /* different since we couldn't tell */
- }
-
- if (trace)
- (void) fprintf (stderr, "-> unlink(%s)\n", tmp);
- (void) unlink (tmp);
- free (options);
- return (ret);
-}
diff --git a/gnu/usr.bin/cvs/cvs/parseinfo.c b/gnu/usr.bin/cvs/cvs/parseinfo.c
deleted file mode 100644
index 65343f5..0000000
--- a/gnu/usr.bin/cvs/cvs/parseinfo.c
+++ /dev/null
@@ -1,147 +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.3 kit.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)parseinfo.c 1.16 92/04/10";
-#endif
-
-/*
- * Parse the INFOFILE file for the specified REPOSITORY. Invoke CALLPROC for
- * each line in the file that matches the REPOSITORY.
- * Return 0 for success, -1 if there was not an INFOFILE, and >0 for failure.
- */
-int
-Parse_Info (infofile, repository, callproc, all)
- char *infofile;
- char *repository;
- int (*callproc) ();
- int all;
-{
- int err = 0;
- FILE *fp_info;
- char infopath[PATH_MAX];
- char line[MAXLINELEN];
- char *default_value = NULL;
- int callback_done, line_number;
- char *cp, *exp, *value, *srepos;
- CONST char *regex_err;
-
- if (CVSroot == NULL)
- {
- /* XXX - should be error maybe? */
- error (0, 0, "CVSROOT variable not set");
- return (1);
- }
-
- /* find the info file and open it */
- (void) sprintf (infopath, "%s/%s/%s", CVSroot,
- CVSROOTADM, infofile);
- if ((fp_info = fopen (infopath, "r")) == NULL)
- return (0); /* no file -> nothing special done */
-
- /* strip off the CVSROOT if repository was absolute */
- srepos = Short_Repository (repository);
-
- /* search the info file for lines that match */
- callback_done = line_number = 0;
- while (fgets (line, sizeof (line), fp_info) != NULL)
- {
- line_number++;
-
- /* skip lines starting with # */
- if (line[0] == '#')
- continue;
-
- /* skip whitespace at beginning of line */
- for (cp = line; *cp && isspace (*cp); cp++)
- ;
-
- /* if *cp is null, the whole line was blank */
- if (*cp == '\0')
- continue;
-
- /* the regular expression is everything up to the first space */
- for (exp = cp; *cp && !isspace (*cp); cp++)
- ;
- if (*cp != '\0')
- *cp++ = '\0';
-
- /* skip whitespace up to the start of the matching value */
- while (*cp && isspace (*cp))
- cp++;
-
- /* no value to match with the regular expression is an error */
- if (*cp == '\0')
- {
- error (0, 0, "syntax error at line %d file %s; ignored",
- line_number, infofile);
- continue;
- }
- value = cp;
-
- /* strip the newline off the end of the value */
- if ((cp = rindex (value, '\n')) != NULL)
- *cp = '\0';
-
- /*
- * At this point, exp points to the regular expression, and value
- * points to the value to call the callback routine with. Evaluate
- * the regular expression against srepos and callback with the value
- * if it matches.
- */
-
- /* save the default value so we have it later if we need it */
- if (strcmp (exp, "DEFAULT") == 0)
- {
- default_value = xstrdup (value);
- continue;
- }
-
- /*
- * For a regular expression of "ALL", do the callback always We may
- * execute lots of ALL callbacks in addition to one regular matching
- * callback or default
- */
- if (strcmp (exp, "ALL") == 0)
- {
- if (all)
- err += callproc (repository, value);
- else
- error(0, 0, "Keyword `ALL' is ignored at line %d in %s file",
- line_number, infofile);
- continue;
- }
-
- /* see if the repository matched this regular expression */
- if ((regex_err = re_comp (exp)) != NULL)
- {
- error (0, 0, "bad regular expression at line %d file %s: %s",
- line_number, infofile, regex_err);
- continue;
- }
- if (re_exec (srepos) == 0)
- continue; /* no match */
-
- /* it did, so do the callback and note that we did one */
- err += callproc (repository, value);
- callback_done = 1;
- }
- (void) fclose (fp_info);
-
- /* if we fell through and didn't callback at all, do the default */
- if (callback_done == 0 && default_value != NULL)
- err += callproc (repository, default_value);
-
- /* free up space if necessary */
- if (default_value != NULL)
- free (default_value);
-
- return (err);
-}
diff --git a/gnu/usr.bin/cvs/cvs/patch.c b/gnu/usr.bin/cvs/cvs/patch.c
deleted file mode 100644
index 11134a7..0000000
--- a/gnu/usr.bin/cvs/cvs/patch.c
+++ /dev/null
@@ -1,523 +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.3 kit.
- *
- * Patch
- *
- * Create a Larry Wall format "patch" file between a previous release and the
- * current head of a module, or between two releases. Can specify the
- * release as either a date or a revision number.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)patch.c 1.50 92/04/10";
-
-#endif
-
-#if __STDC__
-static SIGTYPE patch_cleanup (void);
-static Dtype patch_dirproc (char *dir, char *repos, char *update_dir);
-static int patch_fileproc (char *file, char *update_dir, char *repository,
- List * entries, List * srcfiles);
-static int patch_proc (int *pargc, char *argv[], char *xwhere,
- char *mwhere, char *mfile, int shorten,
- int local_specified, char *mname, char *msg);
-#else
-static int patch_proc ();
-static int patch_fileproc ();
-static Dtype patch_dirproc ();
-static SIGTYPE patch_cleanup ();
-#endif /* __STDC__ */
-
-static int force_tag_match = 1;
-static int patch_short = 0;
-static int toptwo_diffs = 0;
-static int local = 0;
-static char *options = NULL;
-static char *rev1 = NULL;
-static char *rev2 = NULL;
-static char *date1 = NULL;
-static char *date2 = NULL;
-static char tmpfile1[L_tmpnam+1], tmpfile2[L_tmpnam+1], tmpfile3[L_tmpnam+1];
-static int unidiff = 0;
-
-static char *patch_usage[] =
-{
- "Usage: %s %s [-Qflq] [-c|-u] [-s|-t] [-V %%d]\n",
- " -r rev|-D date [-r rev2 | -D date2] modules...\n",
- "\t-Q\tReally quiet.\n",
- "\t-f\tForce a head revision match if tag/date not found.\n",
- "\t-l\tLocal directory only, not recursive\n",
- "\t-c\tContext diffs (default)\n",
- "\t-u\tUnidiff format.\n",
- "\t-s\tShort patch - one liner per file.\n",
- "\t-t\tTop two diffs - last change made to the file.\n",
- "\t-D date\tDate.\n",
- "\t-r rev\tRevision - symbolic or numeric.\n",
- "\t-V vers\tUse RCS Version \"vers\" for keyword expansion.\n",
- NULL
-};
-
-int
-patch (argc, argv)
- int argc;
- char *argv[];
-{
- register int i;
- int c;
- int err = 0;
- DBM *db;
-
- if (argc == -1)
- usage (patch_usage);
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "V:k:cuftsQqlRD:r:")) != -1)
- {
- switch (c)
- {
- case 'Q':
- really_quiet = 1;
- /* FALL THROUGH */
- case 'q':
- quiet = 1;
- break;
- case 'f':
- force_tag_match = 0;
- break;
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case 't':
- toptwo_diffs = 1;
- break;
- case 's':
- patch_short = 1;
- break;
- case 'D':
- if (rev2 != NULL || date2 != NULL)
- error (1, 0,
- "no more than two revisions/dates can be specified");
- if (rev1 != NULL || date1 != NULL)
- date2 = Make_Date (optarg);
- else
- date1 = Make_Date (optarg);
- break;
- case 'r':
- if (rev2 != NULL || date2 != NULL)
- error (1, 0,
- "no more than two revisions/dates can be specified");
- if (rev1 != NULL || date1 != NULL)
- rev2 = optarg;
- else
- rev1 = optarg;
- break;
- case 'k':
- if (options)
- free (options);
- options = RCS_check_kflag (optarg);
- break;
- case 'V':
- if (atoi (optarg) <= 0)
- error (1, 0, "must specify a version number to -V");
- if (options)
- free (options);
- options = xmalloc (strlen (optarg) + 1 + 2); /* for the -V */
- (void) sprintf (options, "-V%s", optarg);
- break;
- case 'u':
- unidiff = 1; /* Unidiff */
- break;
- case 'c': /* Context diff */
- unidiff = 0;
- break;
- case '?':
- default:
- usage (patch_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- /* Sanity checks */
- if (argc < 1)
- usage (patch_usage);
-
- if (toptwo_diffs && patch_short)
- error (1, 0, "-t and -s options are mutually exclusive");
- if (toptwo_diffs && (date1 != NULL || date2 != NULL ||
- rev1 != NULL || rev2 != NULL))
- error (1, 0, "must not specify revisions/dates with -t option!");
-
- if (!toptwo_diffs && (date1 == NULL && date2 == NULL &&
- rev1 == NULL && rev2 == NULL))
- error (1, 0, "must specify at least one revision/date!");
- if (date1 != NULL && date2 != NULL)
- if (RCS_datecmp (date1, date2) >= 0)
- error (1, 0, "second date must come after first date!");
-
- /* if options is NULL, make it a NULL string */
- if (options == NULL)
- options = xstrdup ("");
-
- /* clean up if we get a signal */
- (void) SIG_register (SIGHUP, patch_cleanup);
- (void) SIG_register (SIGINT, patch_cleanup);
- (void) SIG_register (SIGQUIT, patch_cleanup);
- (void) SIG_register (SIGPIPE, patch_cleanup);
- (void) SIG_register (SIGTERM, patch_cleanup);
-
- db = open_module ();
- for (i = 0; i < argc; i++)
- err += do_module (db, argv[i], PATCH, "Patching", patch_proc,
- (char *) NULL, 0, 0, 0, (char *) NULL);
- close_module (db);
- free (options);
- patch_cleanup ();
- return (err);
-}
-
-/*
- * callback proc for doing the real work of patching
- */
-/* ARGSUSED */
-static char where[PATH_MAX];
-static int
-patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
- mname, msg)
- int *pargc;
- char *argv[];
- char *xwhere;
- char *mwhere;
- char *mfile;
- int shorten;
- int local_specified;
- char *mname;
- char *msg;
-{
- int err = 0;
- int which;
- char repository[PATH_MAX];
-
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
- (void) strcpy (where, argv[0]);
-
- /* if mfile isn't null, we need to set up to do only part of the module */
- if (mfile != NULL)
- {
- char *cp;
- char path[PATH_MAX];
-
- /* if the portion of the module is a path, put the dir part on repos */
- if ((cp = rindex (mfile, '/')) != NULL)
- {
- *cp = '\0';
- (void) strcat (repository, "/");
- (void) strcat (repository, mfile);
- (void) strcat (where, "/");
- (void) strcat (where, mfile);
- mfile = cp + 1;
- }
-
- /* take care of the rest */
- (void) sprintf (path, "%s/%s", repository, mfile);
- if (isdir (path))
- {
- /* directory means repository gets the dir tacked on */
- (void) strcpy (repository, path);
- (void) strcat (where, "/");
- (void) strcat (where, mfile);
- }
- else
- {
- int i;
-
- /* a file means muck argv */
- for (i = 1; i < *pargc; i++)
- free (argv[i]);
- argv[1] = xstrdup (mfile);
- (*pargc) = 2;
- }
- }
-
- /* cd to the starting repository */
- if (chdir (repository) < 0)
- {
- error (0, errno, "cannot chdir to %s", repository);
- return (1);
- }
-
- if (force_tag_match)
- which = W_REPOS | W_ATTIC;
- else
- which = W_REPOS;
-
- /* start the recursion processor */
- err = start_recursion (patch_fileproc, (int (*) ()) NULL, patch_dirproc,
- (int (*) ()) NULL, *pargc - 1, argv + 1, local,
- which, 0, 1, where, 1);
-
- return (err);
-}
-
-/*
- * Called to examine a particular RCS file, as appropriate with the options
- * that were set above.
- */
-/* ARGSUSED */
-static int
-patch_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- char *vers_tag, *vers_head;
- char rcsspace[PATH_MAX];
- char *rcs = rcsspace;
- Node *p;
- RCSNode *rcsfile;
- FILE *fp1, *fp2, *fp3;
- int ret = 0;
- int isattic = 0;
- int retcode = 0;
- char file1[PATH_MAX], file2[PATH_MAX], strippath[PATH_MAX];
- char line1[MAXLINELEN], line2[MAXLINELEN];
- char *cp1, *cp2, *commap;
- FILE *fp;
-
-
- /* find the parsed rcs file */
- p = findnode (srcfiles, file);
- if (p == NULL)
- return (1);
- rcsfile = (RCSNode *) p->data;
- if ((rcsfile->flags & VALID) && (rcsfile->flags & INATTIC))
- isattic = 1;
-
- (void) sprintf (rcs, "%s%s", file, RCSEXT);
-
- /* if vers_head is NULL, may have been removed from the release */
- if (isattic && rev2 == NULL && date2 == NULL)
- vers_head = NULL;
- else
- vers_head = RCS_getversion (rcsfile, rev2, date2, force_tag_match);
-
- if (toptwo_diffs)
- {
- if (vers_head == NULL)
- return (1);
-
- if (!date1)
- date1 = xmalloc (50); /* plenty big :-) */
- *date1 = '\0';
- if (RCS_getrevtime (rcsfile, vers_head, date1, 1) == -1)
- {
- if (!really_quiet)
- error (0, 0, "cannot find date in rcs file %s revision %s",
- rcs, vers_head);
- return (1);
- }
- }
- vers_tag = RCS_getversion (rcsfile, rev1, date1, force_tag_match);
-
- if (vers_tag == NULL && (vers_head == NULL || isattic))
- return (0); /* nothing known about specified revs */
-
- if (vers_tag && vers_head && strcmp (vers_head, vers_tag) == 0)
- return (0); /* not changed between releases */
-
- if (patch_short)
- {
- (void) printf ("File ");
- if (vers_tag == NULL)
- (void) printf ("%s is new; current revision %s\n", rcs, vers_head);
- else if (vers_head == NULL)
- (void) printf ("%s is removed; not included in release %s\n",
- rcs, rev2 ? rev2 : date2);
- else
- (void) printf ("%s changed from revision %s to %s\n",
- rcs, vers_tag, vers_head);
- return (0);
- }
- if ((fp1 = fopen (tmpnam (tmpfile1), "w+")) != NULL)
- (void) fclose (fp1);
- if ((fp2 = fopen (tmpnam (tmpfile2), "w+")) != NULL)
- (void) fclose (fp2);
- if ((fp3 = fopen (tmpnam (tmpfile3), "w+")) != NULL)
- (void) fclose (fp3);
- if (fp1 == NULL || fp2 == NULL || fp3 == NULL)
- {
- error (0, 0, "cannot create temporary files");
- ret = 1;
- goto out;
- }
- if (vers_tag != NULL)
- {
- run_setup ("%s%s %s -p -q -r%s", Rcsbin, RCS_CO, options, vers_tag);
- run_arg (rcsfile->path);
- if ((retcode = run_exec (RUN_TTY, tmpfile1, RUN_TTY, RUN_NORMAL)) != 0)
- {
- if (!really_quiet)
- error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "co of revision %s in %s failed", vers_tag, rcs);
- ret = 1;
- goto out;
- }
- }
- else if (toptwo_diffs)
- {
- ret = 1;
- goto out;
- }
- if (vers_head != NULL)
- {
- run_setup ("%s%s %s -p -q -r%s", Rcsbin, RCS_CO, options, vers_head);
- run_arg (rcsfile->path);
- if ((retcode = run_exec (RUN_TTY, tmpfile2, RUN_TTY, RUN_NORMAL)) != 0)
- {
- if (!really_quiet)
- error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "co of revision %s in %s failed", vers_head, rcs);
- ret = 1;
- goto out;
- }
- }
- run_setup ("%s -%c", DIFF, unidiff ? 'u' : 'c');
- run_arg (tmpfile1);
- run_arg (tmpfile2);
- switch (run_exec (RUN_TTY, tmpfile3, RUN_TTY, RUN_NORMAL))
- {
- case -1: /* fork/wait failure */
- error (1, errno, "fork for diff failed on %s", rcs);
- break;
- case 0: /* nothing to do */
- break;
- case 1:
- /*
- * The two revisions are really different, so read the first two
- * lines of the diff output file, and munge them to include more
- * reasonable file names that "patch" will understand.
- */
- fp = open_file (tmpfile3, "r");
- if (fgets (line1, sizeof (line1), fp) == NULL ||
- fgets (line2, sizeof (line2), fp) == NULL)
- {
- error (0, errno, "failed to read diff file header %s for %s",
- tmpfile3, rcs);
- ret = 1;
- (void) fclose (fp);
- goto out;
- }
- if (!unidiff)
- {
- if (strncmp (line1, "*** ", 4) != 0 ||
- strncmp (line2, "--- ", 4) != 0 ||
- (cp1 = index (line1, '\t')) == NULL ||
- (cp2 = index (line2, '\t')) == NULL)
- {
- error (0, 0, "invalid diff header for %s", rcs);
- ret = 1;
- (void) fclose (fp);
- goto out;
- }
- }
- else
- {
- if (strncmp (line1, "--- ", 4) != 0 ||
- strncmp (line2, "+++ ", 4) != 0 ||
- (cp1 = index (line1, '\t')) == NULL ||
- (cp2 = index (line2, '\t')) == NULL)
- {
- error (0, 0, "invalid unidiff header for %s", rcs);
- ret = 1;
- (void) fclose (fp);
- goto out;
- }
- }
- if (CVSroot != NULL)
- (void) sprintf (strippath, "%s/", CVSroot);
- else
- (void) strcpy (strippath, REPOS_STRIP);
- if (strncmp (rcs, strippath, strlen (strippath)) == 0)
- rcs += strlen (strippath);
- commap = rindex (rcs, ',');
- *commap = '\0';
- if (vers_tag != NULL)
- {
- (void) sprintf (file1, "%s%s%s:%s", update_dir,
- update_dir[0] ? "/" : "", rcs, vers_tag);
- }
- else
- {
- (void) strcpy (file1, DEVNULL);
- }
- (void) sprintf (file2, "%s%s%s:%s", update_dir,
- update_dir[0] ? "/" : "", rcs,
- vers_head ? vers_head : "removed");
- if (unidiff)
- {
- (void) printf ("diff -u %s %s\n", file1, file2);
- (void) printf ("--- %s%s+++ ", file1, cp1);
- }
- else
- {
- (void) printf ("diff -c %s %s\n", file1, file2);
- (void) printf ("*** %s%s--- ", file1, cp1);
- }
-
- if (update_dir[0] != '\0')
- (void) printf ("%s/", update_dir);
- (void) printf ("%s%s", rcs, cp2);
- while (fgets (line1, sizeof (line1), fp) != NULL)
- (void) printf ("%s", line1);
- (void) fclose (fp);
- break;
- default:
- error (0, 0, "diff failed for %s", rcs);
- }
- out:
- (void) unlink_file (tmpfile1);
- (void) unlink_file (tmpfile2);
- (void) unlink_file (tmpfile3);
- return (ret);
-}
-
-/*
- * Print a warm fuzzy message
- */
-/* ARGSUSED */
-static Dtype
-patch_dirproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- if (!quiet)
- error (0, 0, "Diffing %s", update_dir);
- return (R_PROCESS);
-}
-
-/*
- * Clean up temporary files
- */
-static SIGTYPE
-patch_cleanup ()
-{
- if (tmpfile1[0] != '\0')
- (void) unlink_file (tmpfile1);
- if (tmpfile2[0] != '\0')
- (void) unlink_file (tmpfile2);
- if (tmpfile3[0] != '\0')
- (void) unlink_file (tmpfile3);
-}
diff --git a/gnu/usr.bin/cvs/cvs/patchlevel.h b/gnu/usr.bin/cvs/cvs/patchlevel.h
deleted file mode 100644
index dc2214d..0000000
--- a/gnu/usr.bin/cvs/cvs/patchlevel.h
+++ /dev/null
@@ -1 +0,0 @@
-#define PATCHLEVEL 0
diff --git a/gnu/usr.bin/cvs/cvs/rcs.c b/gnu/usr.bin/cvs/cvs/rcs.c
deleted file mode 100644
index e882b8c..0000000
--- a/gnu/usr.bin/cvs/cvs/rcs.c
+++ /dev/null
@@ -1,1449 +0,0 @@
-/*
- * Copyright (c) 1992, Brian Berliner and Jeff Polk
- *
- * You may distribute under the terms of the GNU General Public License as
- * specified in the README file that comes with the CVS 1.3 kit.
- *
- * The routines contained in this file do all the rcs file parsing and
- * manipulation
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)rcs.c 1.28 92/03/31";
-#endif
-
-#if __STDC__
-static char *RCS_getbranch (RCSNode * rcs, char *tag, int force_tag_match);
-static char *RCS_getdatebranch (RCSNode * rcs, char *date, char *branch);
-static int getrcskey (FILE * fp, char **keyp, char **valp);
-static int parse_rcs_proc (Node * file);
-static int checkmagic_proc (Node *p);
-static void do_branches (List * list, char *val);
-static void do_symbols (List * list, char *val);
-static void null_delproc (Node * p);
-static void rcsnode_delproc (Node * p);
-static void rcsvers_delproc (Node * p);
-#else
-static int parse_rcs_proc ();
-static int checkmagic_proc ();
-static void rcsnode_delproc ();
-static void rcsvers_delproc ();
-static void null_delproc ();
-static int getrcskey ();
-static void do_symbols ();
-static void do_branches ();
-static char *RCS_getbranch ();
-static char *RCS_getdatebranch ();
-#endif /* __STDC__ */
-
-static List *rcslist;
-static char *repository;
-
-/*
- * Parse all the rcs files specified and return a list
- */
-List *
-RCS_parsefiles (files, xrepos)
- List *files;
- char *xrepos;
-{
- /* initialize */
- repository = xrepos;
- rcslist = getlist ();
-
- /* walk the list parsing files */
- if (walklist (files, parse_rcs_proc) != 0)
- {
- /* free the list and return NULL on error */
- dellist (&rcslist);
- return ((List *) NULL);
- }
- else
- /* return the list we built */
- return (rcslist);
-}
-
-/*
- * Parse an rcs file into a node on the rcs list
- */
-static int
-parse_rcs_proc (file)
- Node *file;
-{
- Node *p;
- RCSNode *rdata;
-
- /* parse the rcs file into rdata */
- rdata = RCS_parse (file->key, repository);
-
- /* if we got a valid RCSNode back, put it on the list */
- if (rdata != (RCSNode *) NULL)
- {
- p = getnode ();
- p->key = xstrdup (file->key);
- p->delproc = rcsnode_delproc;
- p->type = RCSNODE;
- p->data = (char *) rdata;
- (void) addnode (rcslist, p);
- }
- return (0);
-}
-
-/*
- * Parse an rcsfile given a user file name and a repository
- */
-RCSNode *
-RCS_parse (file, repos)
- char *file;
- char *repos;
-{
- RCSNode *rcs;
- char rcsfile[PATH_MAX];
-
- (void) sprintf (rcsfile, "%s/%s%s", repos, file, RCSEXT);
- if (!isreadable (rcsfile))
- {
- (void) sprintf (rcsfile, "%s/%s/%s%s", repos, CVSATTIC,
- file, RCSEXT);
- if (!isreadable (rcsfile))
- return (NULL);
- rcs = RCS_parsercsfile (rcsfile);
- if (rcs != NULL)
- {
- rcs->flags |= INATTIC;
- rcs->flags |= VALID;
- }
- return (rcs);
- }
- rcs = RCS_parsercsfile (rcsfile);
- if (rcs != NULL)
- rcs->flags |= VALID;
- return (rcs);
-}
-
-/*
- * Do the real work of parsing an RCS file
- */
-RCSNode *
-RCS_parsercsfile (rcsfile)
- char *rcsfile;
-{
- Node *q, *r;
- RCSNode *rdata;
- RCSVers *vnode;
- int n;
- char *cp;
- char *key, *value;
- FILE *fp;
-
- /* open the rcsfile */
- if ((fp = fopen (rcsfile, "r")) == NULL)
- {
- error (0, errno, "Couldn't open rcs file `%s'", rcsfile);
- return (NULL);
- }
-
- /* make a node */
- rdata = (RCSNode *) xmalloc (sizeof (RCSNode));
- bzero ((char *) rdata, sizeof (RCSNode));
- rdata->refcount = 1;
- rdata->path = xstrdup (rcsfile);
- rdata->versions = getlist ();
- rdata->dates = getlist ();
-
- /*
- * process all the special header information, break out when we get to
- * the first revision delta
- */
- for (;;)
- {
- /* get the next key/value pair */
-
- /* if key is NULL here, then the file is missing some headers */
- if (getrcskey (fp, &key, &value) == -1 || key == NULL)
- {
- if (!really_quiet)
- error (0, 0, "`%s' does not appear to be a valid rcs file",
- rcsfile);
- freercsnode (&rdata);
- (void) fclose (fp);
- return (NULL);
- }
-
- /* process it */
- if (strcmp (RCSHEAD, key) == 0 && value != NULL)
- {
- rdata->head = xstrdup (value);
- continue;
- }
- if (strcmp (RCSBRANCH, key) == 0 && value != NULL)
- {
- rdata->branch = xstrdup (value);
- if ((numdots (rdata->branch) & 1) != 0)
- {
- /* turn it into a branch if it's a revision */
- cp = rindex (rdata->branch, '.');
- *cp = '\0';
- }
- continue;
- }
- if (strcmp (RCSSYMBOLS, key) == 0)
- {
- if (value != NULL)
- {
- /* if there are tags, set up the tag list */
- rdata->symbols = getlist ();
- do_symbols (rdata->symbols, value);
- continue;
- }
- }
-
- /*
- * check key for '.''s and digits (probably a rev) if it is a
- * revision, we are done with the headers and are down to the
- * revision deltas, so we break out of the loop
- */
- for (cp = key; (isdigit (*cp) || *cp == '.') && *cp != '\0'; cp++)
- /* do nothing */ ;
- if (*cp == '\0' && strncmp (RCSDATE, value, strlen (RCSDATE)) == 0)
- break;
-
- /* if we haven't grabbed it yet, we didn't want it */
- }
-
- /*
- * we got out of the loop, so we have the first part of the first
- * revision delta in our hand key=the revision and value=the date key and
- * its value
- */
- for (;;)
- {
- char *valp;
- char date[MAXDATELEN];
-
- /* grab the value of the date from value */
- valp = value + strlen (RCSDATE);/* skip the "date" keyword */
- while (isspace (*valp)) /* take space off front of value */
- valp++;
- (void) strcpy (date, valp);
-
- /* get the nodes (q is by version, r is by date) */
- q = getnode ();
- r = getnode ();
- q->type = RCSVERS;
- r->type = RCSVERS;
- q->delproc = rcsvers_delproc;
- r->delproc = null_delproc;
- q->data = r->data = xmalloc (sizeof (RCSVers));
- bzero (q->data, sizeof (RCSVers));
- vnode = (RCSVers *) q->data;
-
- /* fill in the version before we forget it */
- q->key = vnode->version = xstrdup (key);
-
- /* throw away the author field */
- (void) getrcskey (fp, &key, &value);
-
- /* throw away the state field */
- (void) getrcskey (fp, &key, &value);
-
- /* fill in the date field */
- r->key = vnode->date = xstrdup (date);
-
- /* fill in the branch list (if any branches exist) */
- (void) getrcskey (fp, &key, &value);
- if (value != (char *) NULL)
- {
- vnode->branches = getlist ();
- do_branches (vnode->branches, value);
- }
-
- /* fill in the next field if there is a next revision */
- (void) getrcskey (fp, &key, &value);
- if (value != (char *) NULL)
- vnode->next = xstrdup (value);
-
- /*
- * at this point, we skip any user defined fields XXX - this is where
- * we put the symbolic link stuff???
- */
- while ((n = getrcskey (fp, &key, &value)) >= 0)
- {
- /* if we have a revision, break and do it */
- for (cp = key; (isdigit (*cp) || *cp == '.') && *cp != '\0'; cp++)
- /* do nothing */ ;
- if (*cp == '\0' && strncmp (RCSDATE, value, strlen (RCSDATE)) == 0)
- break;
- }
-
- /* add the nodes to the lists */
- (void) addnode (rdata->versions, q);
- (void) addnode (rdata->dates, r);
-
- /*
- * if we left the loop because there were no more keys, we break out
- * of the revision processing loop
- */
- if (n < 0)
- break;
- }
-
- (void) fclose (fp);
- return (rdata);
-}
-
-/*
- * rcsnode_delproc - free up an RCS type node
- */
-static void
-rcsnode_delproc (p)
- Node *p;
-{
- freercsnode ((RCSNode **) & p->data);
-}
-
-/*
- * freercsnode - free up the info for an RCSNode
- */
-void
-freercsnode (rnodep)
- RCSNode **rnodep;
-{
- if (rnodep == NULL || *rnodep == NULL)
- return;
-
- ((*rnodep)->refcount)--;
- if ((*rnodep)->refcount != 0)
- {
- *rnodep = (RCSNode *) NULL;
- return;
- }
- free ((*rnodep)->path);
- dellist (&(*rnodep)->versions);
- dellist (&(*rnodep)->dates);
- if ((*rnodep)->symbols != (List *) NULL)
- dellist (&(*rnodep)->symbols);
- if ((*rnodep)->head != (char *) NULL)
- free ((*rnodep)->head);
- if ((*rnodep)->branch != (char *) NULL)
- free ((*rnodep)->branch);
- free ((char *) *rnodep);
- *rnodep = (RCSNode *) NULL;
-}
-
-/*
- * rcsvers_delproc - free up an RCSVers type node
- */
-static void
-rcsvers_delproc (p)
- Node *p;
-{
- RCSVers *rnode;
-
- rnode = (RCSVers *) p->data;
-
- if (rnode->branches != (List *) NULL)
- dellist (&rnode->branches);
- if (rnode->next != (char *) NULL)
- free (rnode->next);
- free ((char *) rnode);
-}
-
-/*
- * null_delproc - don't free anything since it will be free'd by someone else
- */
-/* ARGSUSED */
-static void
-null_delproc (p)
- Node *p;
-{
- /* don't do anything */
-}
-
-/*
- * getrcskey - fill in the key and value from the rcs file the algorithm is
- * as follows
- *
- * o skip whitespace o fill in key with everything up to next white
- * space or semicolon
- * o if key == "desc" then key and data are NULL and return -1
- * o if key wasn't terminated by a semicolon, skip white space and fill
- * in value with everything up to a semicolon o compress all whitespace
- * down to a single space
- * o if a word starts with @, do funky rcs processing
- * o strip whitespace off end of value or set value to NULL if it empty
- * o return 0 since we found something besides "desc"
- */
-
-static char *key = NULL;
-static int keysize = 0;
-static char *value = NULL;
-static int valsize = 0;
-
-#define ALLOCINCR 1024
-
-static int
-getrcskey (fp, keyp, valp)
- FILE *fp;
- char **keyp;
- char **valp;
-{
- char *cur, *max;
- int c;
- int funky = 0;
- int white = 1;
-
- /* skip leading whitespace */
- while (1)
- {
- c = getc (fp);
- if (c == EOF)
- {
- *keyp = (char *) NULL;
- *valp = (char *) NULL;
- return (-1);
- }
- if (!isspace (c))
- break;
- }
-
- /* fill in key */
- cur = key;
- max = key + keysize;
- while (!isspace (c) && c != ';')
- {
- if (cur < max)
- *cur++ = c;
- else
- {
- key = xrealloc (key, keysize + ALLOCINCR);
- cur = key + keysize;
- keysize += ALLOCINCR;
- max = key + keysize;
- *cur++ = c;
- }
- c = getc (fp);
- if (c == EOF)
- {
- *keyp = (char *) NULL;
- *valp = (char *) NULL;
- return (-1);
- }
- }
- *cur = '\0';
-
- /* if we got "desc", we are done with the file */
- if (strcmp (RCSDESC, key) == 0)
- {
- *keyp = (char *) NULL;
- *valp = (char *) NULL;
- return (-1);
- }
-
- /* if we ended key with a semicolon, there is no value */
- if (c == ';')
- {
- *keyp = key;
- *valp = (char *) NULL;
- return (0);
- }
-
- /* otherwise, there might be a value, so fill it in */
- (void) ungetc (c, fp);
- cur = value;
- max = value + valsize;
-
- /* process the value */
- for (;;)
- {
- /* get a character */
- c = getc (fp);
- if (c == EOF)
- {
- *keyp = (char *) NULL;
- *valp = (char *) NULL;
- return (-1);
- }
-
- /* if we are in funky mode, do the rest of this string */
- if (funky)
- {
-
- /*
- * funky mode processing does the following: o @@ means one @ o
- * all other characters are literal up to a single @ (including
- * ';')
- */
- for (;;)
- {
- if (c == '@')
- {
- c = getc (fp);
- if (c == EOF)
- {
- *keyp = (char *) NULL;
- *valp = (char *) NULL;
- return (-1);
- }
- if (c != '@')
- {
- /* @ followed by non @ turns off funky mode */
- funky = 0;
- break;
- }
- /* otherwise, we already ate one @ so copy the other one */
- }
-
- /* put the character on the value (maybe allocating space) */
- if (cur >= max)
- {
- value = xrealloc (value, valsize + ALLOCINCR);
- cur = value + valsize;
- valsize += ALLOCINCR;
- max = value + valsize;
- }
- *cur++ = c;
- c = getc (fp);
- if (c == EOF)
- {
- *keyp = (char *) NULL;
- *valp = (char *) NULL;
- return (-1);
- }
- }
- }
-
- /* if we got the semi-colon we are done with the entire value */
- if (c == ';')
- break;
-
- /* process the character we got */
- if (white && c == '@')
- {
-
- /*
- * if we are starting a word with an '@', enable funky processing
- */
- white = 0; /* you can't be funky and white :-) */
- funky = 1;
- }
- else
- {
-
- /*
- * we put the character on the list, compressing all whitespace
- * to a single space
- */
-
- /* whitespace with white set means compress it out */
- if (white && isspace (c))
- continue;
-
- if (isspace (c))
- {
- /* make c a space and set white */
- white = 1;
- c = ' ';
- }
- else
- white = 0;
-
- /* put the char on the end of value (maybe allocating space) */
- if (cur >= max)
- {
- value = xrealloc (value, valsize + ALLOCINCR);
- cur = value + valsize;
- valsize += ALLOCINCR;
- max = value + valsize;
- }
- *cur++ = c;
- }
- }
-
- /* if the last char was white space, take it off */
- if (white && cur != value)
- cur--;
-
- /* terminate the string */
- if (cur)
- *cur = '\0';
-
- /* if the string is empty, make it null */
- if (value && *value != '\0')
- *valp = value;
- else
- *valp = NULL;
- *keyp = key;
- return (0);
-}
-
-/*
- * process the symbols list of the rcs file
- */
-static void
-do_symbols (list, val)
- List *list;
- char *val;
-{
- Node *p;
- char *cp = val;
- char *tag, *rev;
-
- for (;;)
- {
- /* skip leading whitespace */
- while (isspace (*cp))
- cp++;
-
- /* if we got to the end, we are done */
- if (*cp == '\0')
- break;
-
- /* split it up into tag and rev */
- tag = cp;
- cp = index (cp, ':');
- *cp++ = '\0';
- rev = cp;
- while (!isspace (*cp) && *cp != '\0')
- cp++;
- if (*cp != '\0')
- *cp++ = '\0';
-
- /* make a new node and add it to the list */
- p = getnode ();
- p->key = xstrdup (tag);
- p->data = xstrdup (rev);
- (void) addnode (list, p);
- }
-}
-
-/*
- * process the branches list of a revision delta
- */
-static void
-do_branches (list, val)
- List *list;
- char *val;
-{
- Node *p;
- char *cp = val;
- char *branch;
-
- for (;;)
- {
- /* skip leading whitespace */
- while (isspace (*cp))
- cp++;
-
- /* if we got to the end, we are done */
- if (*cp == '\0')
- break;
-
- /* find the end of this branch */
- branch = cp;
- while (!isspace (*cp) && *cp != '\0')
- cp++;
- if (*cp != '\0')
- *cp++ = '\0';
-
- /* make a new node and add it to the list */
- p = getnode ();
- p->key = xstrdup (branch);
- (void) addnode (list, p);
- }
-}
-
-/*
- * Version Number
- *
- * Returns the requested version number of the RCS file, satisfying tags and/or
- * dates, and walking branches, if necessary.
- *
- * The result is returned; null-string if error.
- */
-char *
-RCS_getversion (rcs, tag, date, force_tag_match)
- RCSNode *rcs;
- char *tag;
- char *date;
- int force_tag_match;
-{
- /* make sure we have something to look at... */
- if (rcs == NULL)
- return ((char *) NULL);
-
- if (tag && date)
- {
- char *cp, *rev, *tagrev;
-
- /*
- * first lookup the tag; if that works, turn the revision into
- * a branch and lookup the date.
- */
- tagrev = RCS_gettag (rcs, tag, force_tag_match);
- if (tagrev == NULL)
- return ((char *) NULL);
-
- if ((cp = rindex (tagrev, '.')) != NULL)
- *cp = '\0';
- rev = RCS_getdatebranch (rcs, date, tagrev);
- free (tagrev);
- return (rev);
- }
- else if (tag)
- return (RCS_gettag (rcs, tag, force_tag_match));
- else if (date)
- return (RCS_getdate (rcs, date, force_tag_match));
- else
- return (RCS_head (rcs));
-
-}
-
-/*
- * Find the revision for a specific tag.
- * If force_tag_match is set, return NULL if an exact match is not
- * possible otherwise return RCS_head (). We are careful to look for
- * and handle "magic" revisions specially.
- *
- * If the matched tag is a branch tag, find the head of the branch.
- */
-char *
-RCS_gettag (rcs, tag, force_tag_match)
- RCSNode *rcs;
- char *tag;
- int force_tag_match;
-{
- Node *p;
-
- /* make sure we have something to look at... */
- if (rcs == NULL)
- return ((char *) NULL);
-
- /* If tag is "HEAD", special case to get head RCS revision */
- if (tag && (strcmp (tag, TAG_HEAD) == 0 || *tag == '\0'))
- if (force_tag_match && (rcs->flags & VALID) && (rcs->flags & INATTIC))
- return ((char *) NULL); /* head request for removed file */
- else
- return (RCS_head (rcs));
-
- if (!isdigit (tag[0]))
- {
- /* If we got a symbolic tag, resolve it to a numeric */
- if (rcs == NULL)
- p = NULL;
- else
- p = findnode (rcs->symbols, tag);
- if (p != NULL)
- {
- int dots;
- char *magic, *branch, *cp;
-
- tag = p->data;
-
- /*
- * If this is a magic revision, we turn it into either its
- * physical branch equivalent (if one exists) or into
- * its base revision, which we assume exists.
- */
- dots = numdots (tag);
- if (dots > 2 && (dots & 1) != 0)
- {
- branch = rindex (tag, '.');
- cp = branch++ - 1;
- while (*cp != '.')
- cp--;
-
- /* see if we have .magic-branch. (".0.") */
- magic = xmalloc (strlen (tag) + 1);
- (void) sprintf (magic, ".%d.", RCS_MAGIC_BRANCH);
- if (strncmp (magic, cp, strlen (magic)) == 0)
- {
- char *xtag;
-
- /* it's magic. See if the branch exists */
- *cp = '\0'; /* turn it into a revision */
- xtag = xstrdup (tag);
- *cp = '.'; /* and back again */
- (void) sprintf (magic, "%s.%s", xtag, branch);
- branch = RCS_getbranch (rcs, magic, 1);
- free (magic);
- if (branch != NULL)
- {
- free (xtag);
- return (branch);
- }
- return (xtag);
- }
- free (magic);
- }
- }
- else
- {
- /* The tag wasn't there, so return the head or NULL */
- if (force_tag_match)
- return (NULL);
- else
- return (RCS_head (rcs));
- }
- }
-
- /*
- * numeric tag processing:
- * 1) revision number - just return it
- * 2) branch number - find head of branch
- */
-
- /* strip trailing dots */
- while (tag[strlen (tag) - 1] == '.')
- tag[strlen (tag) - 1] = '\0';
-
- if ((numdots (tag) & 1) == 0)
- {
- /* we have a branch tag, so we need to walk the branch */
- return (RCS_getbranch (rcs, tag, force_tag_match));
- }
- else
- {
- /* we have a revision tag, so make sure it exists */
- if (rcs == NULL)
- p = NULL;
- else
- p = findnode (rcs->versions, tag);
- if (p != NULL)
- return (xstrdup (tag));
- else
- {
- /* The revision wasn't there, so return the head or NULL */
- if (force_tag_match)
- return (NULL);
- else
- return (RCS_head (rcs));
- }
- }
-}
-
-/*
- * Return a "magic" revision as a virtual branch off of REV for the RCS file.
- * A "magic" revision is one which is unique in the RCS file. By unique, I
- * mean we return a revision which:
- * - has a branch of 0 (see rcs.h RCS_MAGIC_BRANCH)
- * - has a revision component which is not an existing branch off REV
- * - has a revision component which is not an existing magic revision
- * - is an even-numbered revision, to avoid conflicts with vendor branches
- * The first point is what makes it "magic".
- *
- * As an example, if we pass in 1.37 as REV, we will look for an existing
- * branch called 1.37.2. If it did not exist, we would look for an
- * existing symbolic tag with a numeric part equal to 1.37.0.2. If that
- * didn't exist, then we know that the 1.37.2 branch can be reserved by
- * creating a symbolic tag with 1.37.0.2 as the numeric part.
- *
- * This allows us to fork development with very little overhead -- just a
- * symbolic tag is used in the RCS file. When a commit is done, a physical
- * branch is dynamically created to hold the new revision.
- *
- * Note: We assume that REV is an RCS revision and not a branch number.
- */
-static char *check_rev;
-char *
-RCS_magicrev (rcs, rev)
- RCSNode *rcs;
- char *rev;
-{
- int rev_num;
- char *xrev, *test_branch;
-
- xrev = xmalloc (strlen (rev) + 14); /* enough for .0.number */
- check_rev = xrev;
-
- /* only look at even numbered branches */
- for (rev_num = 2; ; rev_num += 2)
- {
- /* see if the physical branch exists */
- (void) sprintf (xrev, "%s.%d", rev, rev_num);
- test_branch = RCS_getbranch (rcs, xrev, 1);
- if (test_branch != NULL) /* it did, so keep looking */
- {
- free (test_branch);
- continue;
- }
-
- /* now, create a "magic" revision */
- (void) sprintf (xrev, "%s.%d.%d", rev, RCS_MAGIC_BRANCH, rev_num);
-
- /* walk the symbols list to see if a magic one already exists */
- if (walklist (rcs->symbols, checkmagic_proc) != 0)
- continue;
-
- /* we found a free magic branch. Claim it as ours */
- return (xrev);
- }
-}
-
-/*
- * walklist proc to look for a match in the symbols list.
- * Returns 0 if the symbol does not match, 1 if it does.
- */
-static int
-checkmagic_proc (p)
- Node *p;
-{
- if (strcmp (check_rev, p->data) == 0)
- return (1);
- else
- return (0);
-}
-
-/*
- * Returns non-zero if the specified revision number or symbolic tag
- * resolves to a "branch" within the rcs file. We do take into account
- * any magic branches as well.
- */
-int
-RCS_isbranch (file, rev, srcfiles)
- char *file;
- char *rev;
- List *srcfiles;
-{
- int dots;
- Node *p;
- RCSNode *rcs;
-
- /* numeric revisions are easy -- even number of dots is a branch */
- if (isdigit (*rev))
- return ((numdots (rev) & 1) == 0);
-
- /* assume a revision if you can't find the RCS info */
- p = findnode (srcfiles, file);
- if (p == NULL)
- return (0);
-
- /* now, look for a match in the symbols list */
- rcs = (RCSNode *) p->data;
- p = findnode (rcs->symbols, rev);
- if (p == NULL)
- return (0);
- dots = numdots (p->data);
- if ((dots & 1) == 0)
- return (1);
-
- /* got a symbolic tag match, but it's not a branch; see if it's magic */
- if (dots > 2)
- {
- char *magic;
- char *branch = rindex (p->data, '.');
- char *cp = branch - 1;
- while (*cp != '.')
- cp--;
-
- /* see if we have .magic-branch. (".0.") */
- magic = xmalloc (strlen (p->data) + 1);
- (void) sprintf (magic, ".%d.", RCS_MAGIC_BRANCH);
- if (strncmp (magic, cp, strlen (magic)) == 0)
- {
- free (magic);
- return (1);
- }
- free (magic);
- }
- return (0);
-}
-
-/*
- * Returns a pointer to malloc'ed memory which contains the branch
- * for the specified *symbolic* tag. Magic branches are handled correctly.
- */
-char *
-RCS_whatbranch (file, rev, srcfiles)
- char *file;
- char *rev;
- List *srcfiles;
-{
- int dots;
- Node *p;
- RCSNode *rcs;
-
- /* assume no branch if you can't find the RCS info */
- p = findnode (srcfiles, file);
- if (p == NULL)
- return ((char *) NULL);
-
- /* now, look for a match in the symbols list */
- rcs = (RCSNode *) p->data;
- p = findnode (rcs->symbols, rev);
- if (p == NULL)
- return ((char *) NULL);
- dots = numdots (p->data);
- if ((dots & 1) == 0)
- return (xstrdup (p->data));
-
- /* got a symbolic tag match, but it's not a branch; see if it's magic */
- if (dots > 2)
- {
- char *magic;
- char *branch = rindex (p->data, '.');
- char *cp = branch++ - 1;
- while (*cp != '.')
- cp--;
-
- /* see if we have .magic-branch. (".0.") */
- magic = xmalloc (strlen (p->data) + 1);
- (void) sprintf (magic, ".%d.", RCS_MAGIC_BRANCH);
- if (strncmp (magic, cp, strlen (magic)) == 0)
- {
- /* yep. it's magic. now, construct the real branch */
- *cp = '\0'; /* turn it into a revision */
- (void) sprintf (magic, "%s.%s", p->data, branch);
- *cp = '.'; /* and turn it back */
- return (magic);
- }
- free (magic);
- }
- return ((char *) NULL);
-}
-
-/*
- * Get the head of the specified branch. If the branch does not exist,
- * return NULL or RCS_head depending on force_tag_match
- */
-static char *
-RCS_getbranch (rcs, tag, force_tag_match)
- RCSNode *rcs;
- char *tag;
- int force_tag_match;
-{
- Node *p, *head;
- RCSVers *vn;
- char *xtag;
- char *nextvers;
- char *cp;
-
- /* make sure we have something to look at... */
- if (rcs == NULL)
- return ((char *) NULL);
-
- /* find out if the tag contains a dot, or is on the trunk */
- cp = rindex (tag, '.');
-
- /* trunk processing is the special case */
- if (cp == NULL)
- {
- xtag = xmalloc (strlen (tag) + 1 + 1); /* +1 for an extra . */
- (void) strcpy (xtag, tag);
- (void) strcat (xtag, ".");
- for (cp = rcs->head; cp != NULL;)
- {
- if (strncmp (xtag, cp, strlen (xtag)) == 0)
- break;
- p = findnode (rcs->versions, cp);
- if (p == NULL)
- {
- free (xtag);
- if (force_tag_match)
- return (NULL);
- else
- return (RCS_head (rcs));
- }
- vn = (RCSVers *) p->data;
- cp = vn->next;
- }
- free (xtag);
- if (cp == NULL)
- {
- if (force_tag_match)
- return (NULL);
- else
- return (RCS_head (rcs));
- }
- return (xstrdup (cp));
- }
-
- /* if it had a `.', terminate the string so we have the base revision */
- *cp = '\0';
-
- /* look up the revision this branch is based on */
- p = findnode (rcs->versions, tag);
-
- /* put the . back so we have the branch again */
- *cp = '.';
-
- if (p == NULL)
- {
- /* if the base revision didn't exist, return head or NULL */
- if (force_tag_match)
- return (NULL);
- else
- return (RCS_head (rcs));
- }
-
- /* find the first element of the branch we are looking for */
- vn = (RCSVers *) p->data;
- if (vn->branches == NULL)
- return (NULL);
- xtag = xmalloc (strlen (tag) + 1 + 1); /* 1 for the extra '.' */
- (void) strcpy (xtag, tag);
- (void) strcat (xtag, ".");
- head = vn->branches->list;
- for (p = head->next; p != head; p = p->next)
- if (strncmp (p->key, xtag, strlen (xtag)) == 0)
- break;
- free (xtag);
-
- if (p == head)
- {
- /* we didn't find a match so return head or NULL */
- if (force_tag_match)
- return (NULL);
- else
- return (RCS_head (rcs));
- }
-
- /* now walk the next pointers of the branch */
- nextvers = p->key;
- do
- {
- p = findnode (rcs->versions, nextvers);
- if (p == NULL)
- {
- /* a link in the chain is missing - return head or NULL */
- if (force_tag_match)
- return (NULL);
- else
- return (RCS_head (rcs));
- }
- vn = (RCSVers *) p->data;
- nextvers = vn->next;
- } while (nextvers != NULL);
-
- /* we have the version in our hand, so go for it */
- return (xstrdup (vn->version));
-}
-
-/*
- * Get the head of the RCS file. If branch is set, this is the head of the
- * branch, otherwise the real head
- */
-char *
-RCS_head (rcs)
- RCSNode *rcs;
-{
- /* make sure we have something to look at... */
- if (rcs == NULL)
- return ((char *) NULL);
-
- if (rcs->branch)
- return (RCS_getbranch (rcs, rcs->branch, 1));
-
- /*
- * NOTE: we call getbranch with force_tag_match set to avoid any
- * possibility of recursion
- */
- else
- return (xstrdup (rcs->head));
-}
-
-/*
- * Get the most recent revision, based on the supplied date, but use some
- * funky stuff and follow the vendor branch maybe
- */
-char *
-RCS_getdate (rcs, date, force_tag_match)
- RCSNode *rcs;
- char *date;
- int force_tag_match;
-{
- char *cur_rev = NULL;
- char *retval = NULL;
- Node *p;
- RCSVers *vers = NULL;
-
- /* make sure we have something to look at... */
- if (rcs == NULL)
- return ((char *) NULL);
-
- /* if the head is on a branch, try the branch first */
- if (rcs->branch != NULL)
- retval = RCS_getdatebranch (rcs, date, rcs->branch);
-
- /* if we found a match, we are done */
- if (retval != NULL)
- return (retval);
-
- /* otherwise if we have a trunk, try it */
- if (rcs->head)
- {
- p = findnode (rcs->versions, rcs->head);
- while (p != NULL)
- {
- /* if the date of this one is before date, take it */
- vers = (RCSVers *) p->data;
- if (RCS_datecmp (vers->date, date) <= 0)
- {
- cur_rev = vers->version;
- break;
- }
-
- /* if there is a next version, find the node */
- if (vers->next != NULL)
- p = findnode (rcs->versions, vers->next);
- else
- p = (Node *) NULL;
- }
- }
-
- /*
- * at this point, either we have the revision we want, or we have the
- * first revision on the trunk (1.1?) in our hands
- */
-
- /* if we found what we're looking for, and it's not 1.1 return it */
- if (cur_rev != NULL && strcmp (cur_rev, "1.1") != 0)
- return (xstrdup (cur_rev));
-
- /* look on the vendor branch */
- retval = RCS_getdatebranch (rcs, date, CVSBRANCH);
-
- /*
- * if we found a match, return it; otherwise, we return the first
- * revision on the trunk or NULL depending on force_tag_match and the
- * date of the first rev
- */
- if (retval != NULL)
- return (retval);
-
- if (!force_tag_match || RCS_datecmp (vers->date, date) <= 0)
- return (xstrdup (vers->version));
- else
- return (NULL);
-}
-
-/*
- * Look up the last element on a branch that was put in before the specified
- * date (return the rev or NULL)
- */
-static char *
-RCS_getdatebranch (rcs, date, branch)
- RCSNode *rcs;
- char *date;
- char *branch;
-{
- char *cur_rev = NULL;
- char *cp;
- char *xbranch, *xrev;
- Node *p;
- RCSVers *vers;
-
- /* look up the first revision on the branch */
- xrev = xstrdup (branch);
- cp = rindex (xrev, '.');
- if (cp == NULL)
- {
- free (xrev);
- return (NULL);
- }
- *cp = '\0'; /* turn it into a revision */
- p = findnode (rcs->versions, xrev);
- free (xrev);
- if (p == NULL)
- return (NULL);
- vers = (RCSVers *) p->data;
-
- /* if no branches list, return NULL */
- if (vers->branches == NULL)
- return (NULL);
-
- /* walk the branches list looking for the branch number */
- xbranch = xmalloc (strlen (branch) + 1 + 1); /* +1 for the extra dot */
- (void) strcpy (xbranch, branch);
- (void) strcat (xbranch, ".");
- for (p = vers->branches->list->next; p != vers->branches->list; p = p->next)
- if (strncmp (p->key, xbranch, strlen (xbranch)) == 0)
- break;
- free (xbranch);
- if (p == vers->branches->list)
- return (NULL);
-
- p = findnode (rcs->versions, p->key);
-
- /* walk the next pointers until you find the end, or the date is too late */
- while (p != NULL)
- {
- vers = (RCSVers *) p->data;
- if (RCS_datecmp (vers->date, date) <= 0)
- cur_rev = vers->version;
- else
- break;
-
- /* if there is a next version, find the node */
- if (vers->next != NULL)
- p = findnode (rcs->versions, vers->next);
- else
- p = (Node *) NULL;
- }
-
- /* if we found something acceptable, return it - otherwise NULL */
- if (cur_rev != NULL)
- return (xstrdup (cur_rev));
- else
- return (NULL);
-}
-
-/*
- * Compare two dates in RCS format. Beware the change in format on January 1,
- * 2000, when years go from 2-digit to full format.
- */
-int
-RCS_datecmp (date1, date2)
- char *date1, *date2;
-{
- int length_diff = strlen (date1) - strlen (date2);
-
- return (length_diff ? length_diff : strcmp (date1, date2));
-}
-
-/*
- * Lookup the specified revision in the ,v file and return, in the date
- * argument, the date specified for the revision *minus one second*, so that
- * the logically previous revision will be found later.
- *
- * Returns zero on failure, RCS revision time as a Unix "time_t" on success.
- */
-time_t
-RCS_getrevtime (rcs, rev, date, fudge)
- RCSNode *rcs;
- char *rev;
- char *date;
- int fudge;
-{
- char tdate[MAXDATELEN];
- struct tm xtm, *ftm;
- time_t revdate = 0;
- Node *p;
- RCSVers *vers;
-
- /* make sure we have something to look at... */
- if (rcs == NULL)
- return (revdate);
-
- /* look up the revision */
- p = findnode (rcs->versions, rev);
- if (p == NULL)
- return (-1);
- vers = (RCSVers *) p->data;
-
- /* split up the date */
- ftm = &xtm;
- (void) sscanf (vers->date, SDATEFORM, &ftm->tm_year, &ftm->tm_mon,
- &ftm->tm_mday, &ftm->tm_hour, &ftm->tm_min,
- &ftm->tm_sec);
- if (ftm->tm_year > 1900)
- ftm->tm_year -= 1900;
-
- /* put the date in a form getdate can grok */
-#ifdef HAVE_RCS5
- (void) sprintf (tdate, "%d/%d/%d GMT %d:%d:%d", ftm->tm_mon,
- ftm->tm_mday, ftm->tm_year, ftm->tm_hour,
- ftm->tm_min, ftm->tm_sec);
-#else
- (void) sprintf (tdate, "%d/%d/%d %d:%d:%d", ftm->tm_mon,
- ftm->tm_mday, ftm->tm_year, ftm->tm_hour,
- ftm->tm_min, ftm->tm_sec);
-#endif
-
- /* turn it into seconds since the epoch */
- revdate = get_date (tdate, (struct timeb *) NULL);
- if (revdate != (time_t) -1)
- {
- revdate -= fudge; /* remove "fudge" seconds */
- if (date)
- {
- /* put an appropriate string into ``date'' if we were given one */
-#ifdef HAVE_RCS5
- ftm = gmtime (&revdate);
-#else
- ftm = localtime (&revdate);
-#endif
- (void) sprintf (date, DATEFORM,
- ftm->tm_year + (ftm->tm_year < 100 ? 0 : 1900),
- ftm->tm_mon + 1, ftm->tm_mday, ftm->tm_hour,
- ftm->tm_min, ftm->tm_sec);
- }
- }
- return (revdate);
-}
-
-/*
- * The argument ARG is the getopt remainder of the -k option specified on the
- * command line. This function returns malloc'ed space that can be used
- * directly in calls to RCS V5, with the -k flag munged correctly.
- */
-char *
-RCS_check_kflag (arg)
- char *arg;
-{
- static char *kflags[] =
- {"kv", "kvl", "k", "v", "o", (char *) NULL};
- char karg[10];
- char **cpp = NULL;
-
-#ifndef HAVE_RCS5
- error (1, 0, "%s %s: your version of RCS does not support the -k option",
- program_name, command_name);
-#endif
-
- if (arg)
- {
- for (cpp = kflags; *cpp != NULL; cpp++)
- {
- if (strcmp (arg, *cpp) == 0)
- break;
- }
- }
-
- if (arg == NULL || *cpp == NULL)
- {
- (void) fprintf (stderr, "%s %s: invalid -k option\n",
- program_name, command_name);
- (void) fprintf (stderr, "\tvalid options are:\n");
- for (cpp = kflags; *cpp != NULL; cpp++)
- (void) fprintf (stderr, "\t\t-k%s\n", *cpp);
- error (1, 0, "Please retry with a valid -k option");
- }
-
- (void) sprintf (karg, "-k%s", *cpp);
- return (xstrdup (karg));
-}
-
-/*
- * Do some consistency checks on the symbolic tag... These should equate
- * pretty close to what RCS checks, though I don't know for certain.
- */
-void
-RCS_check_tag (tag)
- char *tag;
-{
- char *invalid = "$,.:;@"; /* invalid RCS tag characters */
- char *cp;
-
- /*
- * The first character must be an alphabetic letter. The remaining
- * characters cannot be non-visible graphic characters, and must not be
- * in the set of "invalid" RCS identifier characters.
- */
- if (isalpha (*tag))
- {
- for (cp = tag; *cp; cp++)
- {
- if (!isgraph (*cp))
- error (1, 0, "tag `%s' has non-visible graphic characters",
- tag);
- if (index (invalid, *cp))
- error (1, 0, "tag `%s' must not contain the characters `%s'",
- tag, invalid);
- }
- }
- else
- error (1, 0, "tag `%s' must start with a letter", tag);
-}
diff --git a/gnu/usr.bin/cvs/cvs/rcs.h b/gnu/usr.bin/cvs/cvs/rcs.h
deleted file mode 100644
index ba5bdae..0000000
--- a/gnu/usr.bin/cvs/cvs/rcs.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* @(#)rcs.h 1.14 92/03/31 */
-
-/*
- * 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.3 kit.
- *
- * RCS source control definitions needed by rcs.c and friends
- */
-
-#define RCS "rcs"
-#define RCS_CI "ci"
-#define RCS_CO "co"
-#define RCS_RLOG "rlog"
-#define RCS_DIFF "rcsdiff"
-#define RCS_MERGE "merge"
-#define RCS_RCSMERGE "rcsmerge"
-#define RCS_MERGE_PAT "^>>>>>>> " /* runs "grep" with this pattern */
-#define RCSEXT ",v"
-#define RCSHEAD "head"
-#define RCSBRANCH "branch"
-#define RCSSYMBOLS "symbols"
-#define RCSDATE "date"
-#define RCSDESC "desc"
-#define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d"
-#define SDATEFORM "%d.%d.%d.%d.%d.%d"
-
-/*
- * Opaque structure definitions used by RCS specific lookup routines
- */
-#define VALID 0x1 /* flags field contains valid data */
-#define INATTIC 0x2 /* RCS file is located in the Attic */
-struct rcsnode
-{
- int refcount;
- int flags;
- char *path;
- char *head;
- char *branch;
- List *symbols;
- List *versions;
- List *dates;
-};
-typedef struct rcsnode RCSNode;
-
-struct rcsversnode
-{
- char *version;
- char *date;
- char *next;
- List *branches;
-};
-typedef struct rcsversnode RCSVers;
-
-/*
- * CVS reserves all even-numbered branches for its own use. "magic" branches
- * (see rcs.c) are contained as virtual revision numbers (within symbolic
- * tags only) off the RCS_MAGIC_BRANCH, which is 0. CVS also reserves the
- * ".1" branch for vendor revisions. So, if you do your own branching, you
- * should limit your use to odd branch numbers starting at 3.
- */
-#define RCS_MAGIC_BRANCH 0
-
-/*
- * exported interfaces
- */
-#if __STDC__
-List *RCS_parsefiles (List * files, char *xrepos);
-RCSNode *RCS_parse (char *file, char *repos);
-RCSNode *RCS_parsercsfile (char *rcsfile);
-char *RCS_check_kflag (char *arg);
-char *RCS_getdate (RCSNode * rcs, char *date, int force_tag_match);
-char *RCS_gettag (RCSNode * rcs, char *tag, int force_tag_match);
-char *RCS_getversion (RCSNode * rcs, char *tag, char *date,
- int force_tag_match);
-char *RCS_magicrev (RCSNode *rcs, char *rev);
-int RCS_isbranch (char *file, char *rev, List *srcfiles);
-char *RCS_whatbranch (char *file, char *tag, List *srcfiles);
-char *RCS_head (RCSNode * rcs);
-int RCS_datecmp (char *date1, char *date2);
-time_t RCS_getrevtime (RCSNode * rcs, char *rev, char *date, int fudge);
-void RCS_check_tag (char *tag);
-void freercsnode (RCSNode ** rnodep);
-#else
-List *RCS_parsefiles ();
-RCSNode *RCS_parse ();
-char *RCS_head ();
-char *RCS_getversion ();
-char *RCS_magicrev ();
-int RCS_isbranch ();
-char *RCS_whatbranch ();
-char *RCS_gettag ();
-char *RCS_getdate ();
-char *RCS_check_kflag ();
-void RCS_check_tag ();
-time_t RCS_getrevtime ();
-RCSNode *RCS_parsercsfile ();
-int RCS_datecmp ();
-void freercsnode ();
-#endif /* __STDC__ */
diff --git a/gnu/usr.bin/cvs/cvs/recurse.c b/gnu/usr.bin/cvs/cvs/recurse.c
deleted file mode 100644
index 82301d5..0000000
--- a/gnu/usr.bin/cvs/cvs/recurse.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Copyright (c) 1992, Brian Berliner and Jeff Polk
- *
- * You may distribute under the terms of the GNU General Public License as
- * specified in the README file that comes with the CVS 1.3 kit.
- *
- * General recursion handler
- *
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)recurse.c 1.22 92/04/10";
-#endif
-
-#if __STDC__
-static int do_dir_proc (Node * p);
-static int do_file_proc (Node * p);
-static void addlist (List ** listp, char *key);
-#else
-static int do_file_proc ();
-static int do_dir_proc ();
-static void addlist ();
-#endif /* __STDC__ */
-
-
-/*
- * Local static versions eliminates the need for globals
- */
-static int (*fileproc) ();
-static int (*filesdoneproc) ();
-static Dtype (*direntproc) ();
-static int (*dirleaveproc) ();
-static int which;
-static Dtype flags;
-static int aflag;
-static int readlock;
-static int dosrcs;
-static char update_dir[PATH_MAX];
-static char *repository = NULL;
-static List *entries = NULL;
-static List *srcfiles = NULL;
-static List *filelist = NULL;
-static List *dirlist = NULL;
-
-/*
- * Called to start a recursive command Command line arguments are processed
- * if present, otherwise the local directory is processed.
- */
-int
-start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
- argc, argv, local, which, aflag, readlock,
- update_preload, dosrcs)
- int (*fileproc) ();
- int (*filesdoneproc) ();
- Dtype (*direntproc) ();
- int (*dirleaveproc) ();
- int argc;
- char *argv[];
- int local;
- int which;
- int aflag;
- int readlock;
- char *update_preload;
- int dosrcs;
-{
- int i, err = 0;
- Dtype flags;
-
- if (update_preload == NULL)
- update_dir[0] = '\0';
- else
- (void) strcpy (update_dir, update_preload);
-
- if (local)
- flags = R_SKIP_DIRS;
- else
- flags = R_PROCESS;
-
- /* clean up from any previous calls to start_recursion */
- if (repository)
- {
- free (repository);
- repository = (char *) NULL;
- }
- if (entries)
- dellist (&entries);
- if (srcfiles)
- dellist (&srcfiles);
- if (filelist)
- dellist (&filelist);
- if (dirlist)
- dellist (&dirlist);
-
- if (argc == 0)
- {
-
- /*
- * There were no arguments, so we'll probably just recurse. The
- * exception to the rule is when we are called from a directory
- * without any CVS administration files. That has always meant to
- * process each of the sub-directories, so we pretend like we were
- * called with the list of sub-dirs of the current dir as args
- */
- if ((which & W_LOCAL) && !isdir (CVSADM) && !isdir (OCVSADM))
- dirlist = Find_Dirs ((char *) NULL, W_LOCAL);
- else
- addlist (&dirlist, ".");
-
- err += do_recursion (fileproc, filesdoneproc, direntproc,
- dirleaveproc, flags, which, aflag,
- readlock, dosrcs);
- }
- else
- {
-
- /*
- * There were arguments, so we have to handle them by hand. To do
- * that, we set up the filelist and dirlist with the arguments and
- * call do_recursion. do_recursion recognizes the fact that the
- * lists are non-null when it starts and doesn't update them
- */
-
- /* look for args with /-s in them */
- for (i = 0; i < argc; i++)
- if (index (argv[i], '/') != NULL)
- break;
-
- /* if we didn't find any hard one's, do it the easy way */
- if (i == argc)
- {
- /* set up the lists */
- for (i = 0; i < argc; i++)
- {
- if (isdir (argv[i]))
- addlist (&dirlist, argv[i]);
- else
- {
- if (isdir (CVSADM) || isdir (OCVSADM))
- {
- char *repos;
- char tmp[PATH_MAX];
-
- repos = Name_Repository ((char *) NULL, update_dir);
- (void) sprintf (tmp, "%s/%s", repos, argv[i]);
- if (isdir (tmp))
- addlist (&dirlist, argv[i]);
- else
- addlist (&filelist, argv[i]);
- free (repos);
- }
- else
- addlist (&filelist, argv[i]);
- }
- }
-
- /* we aren't recursive if no directories were specified */
- if (dirlist == NULL)
- local = 1;
-
- /* process the lists */
- err += do_recursion (fileproc, filesdoneproc, direntproc,
- dirleaveproc, flags, which, aflag,
- readlock, dosrcs);
- }
- /* otherwise - do it the hard way */
- else
- {
- char *cp;
- char *dir = (char *) NULL;
- char *comp = (char *) NULL;
- char *oldupdate = (char *) NULL;
- char savewd[PATH_MAX];
-
- if (getwd (savewd) == NULL)
- error (1, 0, "could not get working directory: %s", savewd);
-
- for (i = 0; i < argc; i++)
- {
- /* split the arg into the dir and component parts */
- dir = xstrdup (argv[i]);
- if ((cp = rindex (dir, '/')) != NULL)
- {
- *cp = '\0';
- comp = xstrdup (cp + 1);
- oldupdate = xstrdup (update_dir);
- if (update_dir[0] != '\0')
- (void) strcat (update_dir, "/");
- (void) strcat (update_dir, dir);
- }
- else
- {
- comp = xstrdup (dir);
- if (dir)
- free (dir);
- dir = (char *) NULL;
- }
-
- /* chdir to the appropriate place if necessary */
- if (dir && chdir (dir) < 0)
- error (1, errno, "could not chdir to %s", dir);
-
- /* set up the list */
- if (isdir (comp))
- addlist (&dirlist, comp);
- else
- {
- if (isdir (CVSADM) || isdir (OCVSADM))
- {
- char *repos;
- char tmp[PATH_MAX];
-
- repos = Name_Repository ((char *) NULL, update_dir);
- (void) sprintf (tmp, "%s/%s", repos, comp);
- if (isdir (tmp))
- addlist (&dirlist, comp);
- else
- addlist (&filelist, comp);
- free (repos);
- }
- else
- addlist (&filelist, comp);
- }
-
- /* do the recursion */
- err += do_recursion (fileproc, filesdoneproc, direntproc,
- dirleaveproc, flags, which,
- aflag, readlock, dosrcs);
-
- /* chdir back and fix update_dir if necessary */
- if (dir && chdir (savewd) < 0)
- error (1, errno, "could not chdir to %s", dir);
- if (oldupdate)
- {
- (void) strcpy (update_dir, oldupdate);
- free (oldupdate);
- }
-
- }
- if (dir)
- free (dir);
- if (comp)
- free (comp);
- }
- }
- return (err);
-}
-
-/*
- * Implement the recursive policies on the local directory. This may be
- * called directly, or may be called by start_recursion
- */
-int
-do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc,
- xflags, xwhich, xaflag, xreadlock, xdosrcs)
- int (*xfileproc) ();
- int (*xfilesdoneproc) ();
- Dtype (*xdirentproc) ();
- int (*xdirleaveproc) ();
- Dtype xflags;
- int xwhich;
- int xaflag;
- int xreadlock;
- int xdosrcs;
-{
- int err = 0;
- int dodoneproc = 1;
- char *srepository;
-
- /* do nothing if told */
- if (xflags == R_SKIP_ALL)
- return (0);
-
- /* set up the static vars */
- fileproc = xfileproc;
- filesdoneproc = xfilesdoneproc;
- direntproc = xdirentproc;
- dirleaveproc = xdirleaveproc;
- flags = xflags;
- which = xwhich;
- aflag = xaflag;
- readlock = noexec ? 0 : xreadlock;
- dosrcs = xdosrcs;
-
- /*
- * Fill in repository with the current repository
- */
- if (which & W_LOCAL)
- {
- if (isdir (CVSADM) || isdir (OCVSADM))
- repository = Name_Repository ((char *) NULL, update_dir);
- else
- repository = NULL;
- }
- else
- {
- repository = xmalloc (PATH_MAX);
- (void) getwd (repository);
- }
- srepository = repository; /* remember what to free */
-
- /*
- * The filesdoneproc needs to be called for each directory where files
- * processed, or each directory that is processed by a call where no
- * directories were passed in. In fact, the only time we don't want to
- * call back the filesdoneproc is when we are processing directories that
- * were passed in on the command line (or in the special case of `.' when
- * we were called with no args
- */
- if (dirlist != NULL && filelist == NULL)
- dodoneproc = 0;
-
- /*
- * If filelist or dirlist is already set, we don't look again. Otherwise,
- * find the files and directories
- */
- if (filelist == NULL && dirlist == NULL)
- {
- /* both lists were NULL, so start from scratch */
- if (fileproc != NULL && flags != R_SKIP_FILES)
- {
- int lwhich = which;
-
- /* be sure to look in the attic if we have sticky tags/date */
- if ((lwhich & W_ATTIC) == 0)
- if (isreadable (CVSADM_TAG))
- lwhich |= W_ATTIC;
-
- /* find the files and fill in entries if appropriate */
- filelist = Find_Names (repository, lwhich, aflag, &entries);
- }
-
- /* find sub-directories if we will recurse */
- if (flags != R_SKIP_DIRS)
- dirlist = Find_Dirs (repository, which);
- }
- else
- {
- /* something was passed on the command line */
- if (filelist != NULL && fileproc != NULL)
- {
- /* we will process files, so pre-parse entries */
- if (which & W_LOCAL)
- entries = ParseEntries (aflag);
- }
- }
-
- /* process the files (if any) */
- if (filelist != NULL)
- {
- /* read lock it if necessary */
- if (readlock && repository && Reader_Lock (repository) != 0)
- error (1, 0, "read lock failed - giving up");
-
- /* pre-parse the source files */
- if (dosrcs && repository)
- srcfiles = RCS_parsefiles (filelist, repository);
- else
- srcfiles = (List *) NULL;
-
- /* process the files */
- err += walklist (filelist, do_file_proc);
-
- /* unlock it */
- if (readlock)
- Lock_Cleanup ();
-
- /* clean up */
- dellist (&filelist);
- dellist (&srcfiles);
- dellist (&entries);
- }
-
- /* call-back files done proc (if any) */
- if (dodoneproc && filesdoneproc != NULL)
- err = filesdoneproc (err, repository, update_dir[0] ? update_dir : ".");
-
- /* process the directories (if necessary) */
- if (dirlist != NULL)
- err += walklist (dirlist, do_dir_proc);
-#ifdef notdef
- else if (dirleaveproc != NULL)
- err += dirleaveproc(".", err, ".");
-#endif
- dellist (&dirlist);
-
- /* free the saved copy of the pointer if necessary */
- if (srepository)
- {
- (void) free (srepository);
- repository = (char *) NULL;
- }
-
- return (err);
-}
-
-/*
- * Process each of the files in the list with the callback proc
- */
-static int
-do_file_proc (p)
- Node *p;
-{
- if (fileproc != NULL)
- return (fileproc (p->key, update_dir, repository, entries, srcfiles));
- else
- return (0);
-}
-
-/*
- * Process each of the directories in the list (recursing as we go)
- */
-static int
-do_dir_proc (p)
- Node *p;
-{
- char *dir = p->key;
- char savewd[PATH_MAX];
- char newrepos[PATH_MAX];
- List *sdirlist;
- char *srepository;
- char *cp;
- Dtype dir_return = R_PROCESS;
- int stripped_dot = 0;
- int err = 0;
-
- /* set up update_dir - skip dots if not at start */
- if (strcmp (dir, ".") != 0)
- {
- if (update_dir[0] != '\0')
- {
- (void) strcat (update_dir, "/");
- (void) strcat (update_dir, dir);
- }
- else
- (void) strcpy (update_dir, dir);
-
- /*
- * Here we need a plausible repository name for the sub-directory. We
- * create one by concatenating the new directory name onto the
- * previous repository name. The only case where the name should be
- * used is in the case where we are creating a new sub-directory for
- * update -d and in that case the generated name will be correct.
- */
- if (repository == NULL)
- newrepos[0] = '\0';
- else
- (void) sprintf (newrepos, "%s/%s", repository, dir);
- }
- else
- {
- if (update_dir[0] == '\0')
- (void) strcpy (update_dir, dir);
-
- if (repository == NULL)
- newrepos[0] = '\0';
- else
- (void) strcpy (newrepos, repository);
- }
-
- /* call-back dir entry proc (if any) */
- if (direntproc != NULL)
- dir_return = direntproc (dir, newrepos, update_dir);
-
- /* only process the dir if the return code was 0 */
- if (dir_return != R_SKIP_ALL)
- {
- /* save our current directory and static vars */
- if (getwd (savewd) == NULL)
- error (1, 0, "could not get working directory: %s", savewd);
- sdirlist = dirlist;
- srepository = repository;
- dirlist = NULL;
-
- /* cd to the sub-directory */
- if (chdir (dir) < 0)
- error (1, errno, "could not chdir to %s", dir);
-
- /* honor the global SKIP_DIRS (a.k.a. local) */
- if (flags == R_SKIP_DIRS)
- dir_return = R_SKIP_DIRS;
-
- /* remember if the `.' will be stripped for subsequent dirs */
- if (strcmp (update_dir, ".") == 0)
- {
- update_dir[0] = '\0';
- stripped_dot = 1;
- }
-
- /* make the recursive call */
- err += do_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
- dir_return, which, aflag, readlock, dosrcs);
-
- /* put the `.' back if necessary */
- if (stripped_dot)
- (void) strcpy (update_dir, ".");
-
- /* call-back dir leave proc (if any) */
- if (dirleaveproc != NULL)
- err = dirleaveproc (dir, err, update_dir);
-
- /* get back to where we started and restore state vars */
- if (chdir (savewd) < 0)
- error (1, errno, "could not chdir to %s", savewd);
- dirlist = sdirlist;
- repository = srepository;
- }
-
- /* put back update_dir */
- if ((cp = rindex (update_dir, '/')) != NULL)
- *cp = '\0';
- else
- update_dir[0] = '\0';
-
- return (err);
-}
-
-/*
- * Add a node to a list allocating the list if necessary
- */
-static void
-addlist (listp, key)
- List **listp;
- char *key;
-{
- Node *p;
-
- if (*listp == NULL)
- *listp = getlist ();
- p = getnode ();
- p->type = FILES;
- p->key = xstrdup (key);
- (void) addnode (*listp, p);
-}
diff --git a/gnu/usr.bin/cvs/cvs/release.c b/gnu/usr.bin/cvs/cvs/release.c
deleted file mode 100644
index 34d36bc..0000000
--- a/gnu/usr.bin/cvs/cvs/release.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Release: "cancel" a checkout in the history log.
- *
- * - Don't allow release if anything is active - Don't allow release if not
- * above or inside repository. - Don't allow release if ./CVS/Repository is
- * not the same as the directory specified in the module database.
- *
- * - Enter a line in the history log indicating the "release". - If asked to,
- * delete the local working directory.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)release.c 1.21 92/02/29";
-#endif
-
-#if __STDC__
-static void release_delete (char *dir);
-#else
-static void release_delete ();
-#endif /* __STDC__ */
-
-static char *release_usage[] =
-{
- "Usage: %s %s [-d] modules...\n",
- "\t-Q\tReally quiet.\n",
- "\t-d\tDelete the given directory.\n",
- "\t-q\tSomewhat quiet.\n",
- NULL
-};
-
-static short delete;
-
-int
-release (argc, argv)
- int argc;
- char **argv;
-{
- FILE *fp;
- register int i, c;
- register char *cp;
- int margc;
- DBM *db;
- datum key, val;
- char *repository, *srepos;
- char **margv, *modargv[MAXFILEPERDIR], line[PATH_MAX];
-
- if (argc == -1)
- usage (release_usage);
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "Qdq")) != -1)
- {
- switch (c)
- {
- case 'Q':
- really_quiet = 1;
- /* FALL THROUGH */
- case 'q':
- quiet = 1;
- break;
- case 'd':
- delete++;
- break;
- case '?':
- default:
- usage (release_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (!(db = open_module ()))
- return (1);
- for (i = 0; i < argc; i++)
- {
-
- /*
- * If we are in a repository, do it. Else if we are in the parent of
- * a directory with the same name as the module, "cd" into it and
- * look for a repository there.
- */
- if (isdir (argv[i]))
- {
- if (chdir (argv[i]) < 0)
- {
- if (!really_quiet)
- error (0, 0, "can't chdir to: %s", argv[i]);
- continue;
- }
- if (!isdir (CVSADM) && !isdir (OCVSADM))
- {
- if (!really_quiet)
- error (0, 0, "no repository module: %s", argv[i]);
- continue;
- }
- }
- else
- {
- if (!really_quiet)
- error (0, 0, "no such directory/module: %s", argv[i]);
- continue;
- }
-
- repository = Name_Repository ((char *) NULL, (char *) NULL);
- srepos = Short_Repository (repository);
-
- /* grab module entry from database and check against short repos */
- key.dptr = argv[i];
- key.dsize = strlen (key.dptr);
- val = dbm_fetch (db, key);
- if (!val.dptr)
- {
- error (0, 0, "no such module name: %s", argv[i]);
- continue;
- }
- val.dptr[val.dsize] = '\0';
- if ((cp = index (val.dptr, '#')) != NULL) /* Strip out a comment */
- {
- do
- {
- *cp-- = '\0';
- } while (isspace (*cp));
- }
- (void) sprintf (line, "%s %s", key.dptr, val.dptr);
- line2argv (&margc, modargv, line);
- margv = modargv;
-
- optind = 1;
- while (gnu_getopt (margc, margv, CVSMODULE_OPTS) != -1)
- /* do nothing */ ;
- margc -= optind;
- margv += optind;
-
- if (margc < 1)
- {
- error (0, 0, "modules file missing directory for key %s value %s",
- key.dptr, val.dptr);
- continue;
- }
- if (strcmp (*margv, srepos))
- {
- error (0, 0, "repository mismatch: module[%s], here[%s]",
- *margv, srepos);
- free (repository);
- continue;
- }
-
- if (!really_quiet)
- {
-
- /*
- * Now see if there is any reason not to allow a "Release" This
- * is "popen()" instead of "Popen()" since we don't want "-n" to
- * stop it.
- */
- fp = popen ("cvs -n -q update", "r");
- c = 0;
- while (fgets (line, sizeof (line), fp))
- {
- if (index ("MARCZ", *line))
- c++;
- (void) printf (line);
- }
- (void) pclose (fp);
- (void) printf ("You have [%d] altered files in this repository.\n",
- c);
- (void) printf ("Are you sure you want to release %smodule `%s': ",
- delete ? "(and delete) " : "", argv[i]);
- c = !yesno ();
- if (c) /* "No" */
- {
- (void) fprintf (stderr, "** `%s' aborted by user choice.\n",
- command_name);
- free (repository);
- continue;
- }
- }
-
- /*
- * So, we've passed all the tests, go ahead and release it. First,
- * log the release, then attempt to delete it.
- */
- history_write ('F', argv[i], "", argv[i], ""); /* F == Free */
- free (repository);
-
- if (delete)
- release_delete (argv[i]);
- }
- close_module (db);
- return (0);
-}
-
-/* We want to "rm -r" the repository, but let us be a little paranoid. */
-static void
-release_delete (dir)
- char *dir;
-{
- struct stat st;
- ino_t ino;
- int retcode = 0;
-
- (void) stat (".", &st);
- ino = st.st_ino;
- (void) chdir ("..");
- (void) stat (dir, &st);
- if (ino != st.st_ino)
- {
- error (0, 0,
- "Parent dir on a different disk, delete of %s aborted", dir);
- return;
- }
- run_setup ("%s -r", RM);
- run_arg (dir);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- error (0, retcode == -1 ? errno : 0,
- "deletion of module %s failed.", dir);
-}
diff --git a/gnu/usr.bin/cvs/cvs/remove.c b/gnu/usr.bin/cvs/cvs/remove.c
deleted file mode 100644
index 5cce883..0000000
--- a/gnu/usr.bin/cvs/cvs/remove.c
+++ /dev/null
@@ -1,176 +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.3 kit.
- *
- * Remove a File
- *
- * Removes entries from the present version. The entries will be removed from
- * the RCS repository upon the next "commit".
- *
- * "remove" accepts no options, only file names that are to be removed. The
- * file must not exist in the current directory for "remove" to work
- * correctly.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)remove.c 1.34 92/04/10";
-#endif
-
-#if __STDC__
-static int remove_fileproc (char *file, char *update_dir,
- char *repository, List *entries,
- List *srcfiles);
-static Dtype remove_dirproc (char *dir, char *repos, char *update_dir);
-#else
-static Dtype remove_dirproc ();
-static int remove_fileproc ();
-#endif
-
-static int local;
-static int removed_files;
-static int auto_removed_files;
-
-static char *remove_usage[] =
-{
- "Usage: %s %s [-lR] [files...]\n",
- "\t-l\tProcess this directory only (not recursive).\n",
- "\t-R\tProcess directories recursively.\n",
- NULL
-};
-
-int
-cvsremove (argc, argv)
- int argc;
- char *argv[];
-{
- int c, err;
-
- if (argc == -1)
- usage (remove_usage);
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "lR")) != -1)
- {
- switch (c)
- {
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case '?':
- default:
- usage (remove_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- /* start the recursion processor */
- err = start_recursion (remove_fileproc, (int (*) ()) NULL, remove_dirproc,
- (int (*) ()) NULL, argc, argv, local,
- W_LOCAL, 0, 1, (char *) NULL, 1);
-
- if (removed_files)
- error (0, 0, "use '%s commit' to remove %s permanently", program_name,
- (removed_files == 1) ? "this file" : "these files");
- else
- if (!auto_removed_files)
- error (0, 0, "no files removed; use `%s' to remove the file first",
- RM);
-
- return (err);
-}
-
-/*
- * remove the file, only if it has already been physically removed
- */
-/* ARGSUSED */
-static int
-remove_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- char fname[PATH_MAX];
- Vers_TS *vers;
-
- vers = Version_TS (repository, (char *) NULL, (char *) NULL, (char *) NULL,
- file, 0, 0, entries, srcfiles);
-
- if (vers->ts_user != NULL)
- {
- freevers_ts (&vers);
- return (0);
- }
-
- if (vers->vn_user == NULL)
- {
- if (!quiet)
- error (0, 0, "nothing known about %s", file);
- freevers_ts (&vers);
- return (0);
- }
-
- if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
- {
- /*
- * It's a file that has been added, but not commited yet. So,
- * remove the ,p and ,t file for it and scratch it from the
- * entries file.
- */
- Scratch_Entry (entries, file);
- (void) sprintf (fname, "%s/%s%s", CVSADM, file, CVSEXT_OPT);
- (void) unlink_file (fname);
- (void) sprintf (fname, "%s/%s%s", CVSADM, file, CVSEXT_LOG);
- (void) unlink_file (fname);
- if (!quiet)
- error (0, 0, "removed `%s'.", file);
- auto_removed_files++;
- }
- else if (vers->vn_user[0] == '-')
- {
- freevers_ts (&vers);
- return (0);
- }
- else
- {
- /* Re-register it with a negative version number. */
- (void) strcpy (fname, "-");
- (void) strcat (fname, vers->vn_user);
- Register (entries, file, fname, vers->ts_rcs, vers->options,
- vers->tag, vers->date);
- if (!quiet)
- {
- error (0, 0, "scheduling %s for removal", file);
- removed_files++;
- }
- }
-
- freevers_ts (&vers);
- return (0);
-}
-
-/*
- * Print a warm fuzzy message
- */
-/* ARGSUSED */
-static Dtype
-remove_dirproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- if (!quiet)
- error (0, 0, "Removing %s", update_dir);
- return (R_PROCESS);
-}
diff --git a/gnu/usr.bin/cvs/cvs/repos.c b/gnu/usr.bin/cvs/cvs/repos.c
deleted file mode 100644
index 43a9dfe..0000000
--- a/gnu/usr.bin/cvs/cvs/repos.c
+++ /dev/null
@@ -1,169 +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.3 kit.
- *
- * Name of Repository
- *
- * Determine the name of the RCS repository and sets "Repository" accordingly.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)repos.c 1.28 92/03/31";
-#endif
-
-char *
-Name_Repository (dir, update_dir)
- char *dir;
- char *update_dir;
-{
- FILE *fpin;
- char *ret, *xupdate_dir;
- char repos[PATH_MAX];
- char path[PATH_MAX];
- char tmp[PATH_MAX];
- char cvsadm[PATH_MAX];
- char ocvsadm[PATH_MAX];
- char *cp;
- int has_cvsadm = 0, has_ocvsadm = 0;
-
- if (update_dir && *update_dir)
- xupdate_dir = update_dir;
- else
- xupdate_dir = ".";
-
- if (dir != NULL)
- {
- (void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
- (void) sprintf (ocvsadm, "%s/%s", dir, OCVSADM);
- }
- else
- {
- (void) strcpy (cvsadm, CVSADM);
- (void) strcpy (ocvsadm, OCVSADM);
- }
-
- /* sanity checks */
- if (!(has_cvsadm = isdir (cvsadm)) && !(has_ocvsadm = isdir (ocvsadm)))
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "there is no version here; do '%s checkout' first",
- program_name);
- }
-
- if (has_ocvsadm)
- {
- if (has_cvsadm)
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "error: both `%s' and `%s' exist; I give up",
- CVSADM, OCVSADM);
- }
- if (rename (ocvsadm, cvsadm) < 0)
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, errno, "cannot rename `%s' to `%s'; I give up",
- OCVSADM, CVSADM);
- }
-
- /*
- * We have converted the old CVS.adm directory to the new CVS
- * directory. Now, convert the Entries file to the new format, if
- * necessary.
- */
- check_entries (dir);
- }
-
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
- else
- (void) strcpy (tmp, CVSADM_ENT);
-
- if (!isreadable (tmp))
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "*PANIC* administration files missing");
- }
-
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
- else
- (void) strcpy (tmp, CVSADM_REP);
-
- if (!isreadable (tmp))
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "*PANIC* administration files missing");
- }
-
- /*
- * The assumption here is that the repository is always contained in the
- * first line of the "Repository" file.
- */
- fpin = open_file (tmp, "r");
-
- if (fgets (repos, PATH_MAX, fpin) == NULL)
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, errno, "cannot read %s", CVSADM_REP);
- }
- (void) fclose (fpin);
- if ((cp = rindex (repos, '\n')) != NULL)
- *cp = '\0'; /* strip the newline */
-
- /*
- * If this is a relative repository pathname, turn it into an absolute
- * one by tacking on the CVSROOT environment variable. If the CVSROOT
- * environment variable is not set, die now.
- */
- if (strcmp (repos, "..") == 0 || strncmp (repos, "../", 3) == 0)
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (0, 0, "`..'-relative repositories are not supported.");
- error (1, 0, "illegal source repository");
- }
- if (repos[0] != '/')
- {
- if (CVSroot == NULL)
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (0, 0, "must set the CVSROOT environment variable\n");
- error (0, 0, "or specify the '-d' option to %s.", program_name);
- error (1, 0, "illegal repository setting");
- }
- (void) strcpy (path, repos);
- (void) sprintf (repos, "%s/%s", CVSroot, path);
- }
- if (!isdir (repos))
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "there is no repository %s", repos);
- }
-
- /* allocate space to return and fill it in */
- strip_path (repos);
- ret = xstrdup (repos);
- return (ret);
-}
-
-/*
- * Return a pointer to the repository name relative to CVSROOT from a
- * possibly fully qualified repository
- */
-char *
-Short_Repository (repository)
- char *repository;
-{
- if (repository == NULL)
- return (NULL);
-
- /* if repository matches CVSroot at the beginning, strip off CVSroot */
- if (strncmp (CVSroot, repository, strlen (CVSroot)) == 0)
- return (repository + strlen (CVSroot) + 1);
- else
- return (repository);
-}
diff --git a/gnu/usr.bin/cvs/cvs/rtag.c b/gnu/usr.bin/cvs/cvs/rtag.c
deleted file mode 100644
index a53e8c7..0000000
--- a/gnu/usr.bin/cvs/cvs/rtag.c
+++ /dev/null
@@ -1,403 +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.3 kit.
- *
- * Rtag
- *
- * Add or delete a symbolic name to an RCS file, or a collection of RCS files.
- * Uses the modules database, if necessary.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)rtag.c 1.57 92/04/10";
-#endif
-
-#if __STDC__
-static Dtype rtag_dirproc (char *dir, char *repos, char *update_dir);
-static int rtag_fileproc (char *file, char *update_dir,
- char *repository, List * entries,
- List * srcfiles);
-static int rtag_proc (int *pargc, char *argv[], char *xwhere,
- char *mwhere, char *mfile, int shorten,
- int local_specified, char *mname, char *msg);
-static int rtag_delete (RCSNode *rcsfile);
-#else
-static int rtag_proc ();
-static int rtag_fileproc ();
-static Dtype rtag_dirproc ();
-static int rtag_delete ();
-#endif /* __STDC__ */
-
-static char *symtag;
-static char *numtag;
-static int delete; /* adding a tag by default */
-static int attic_too; /* remove tag from Attic files */
-static int branch_mode; /* make an automagic "branch" tag */
-static char *date;
-static int local; /* recursive by default */
-static int force_tag_match = 1; /* force by default */
-
-static char *rtag_usage[] =
-{
- "Usage: %s %s [-QaflRnq] [-b] [-d] [-r tag|-D date] tag modules...\n",
- "\t-Q\tReally quiet.\n",
- "\t-a\tClear tag from removed files that would not otherwise be tagged.\n",
- "\t-f\tForce a head revision match if tag/date not found.\n",
- "\t-l\tLocal directory only, not recursive\n",
- "\t-R\tProcess directories recursively.\n",
- "\t-n\tNo execution of 'tag program'\n",
- "\t-q\tSomewhat quiet.\n",
- "\t-d\tDelete the given Tag.\n",
- "\t-b\tMake the tag a \"branch\" tag, allowing concurrent development.\n",
- "\t-[rD]\tExisting tag or Date.\n",
- NULL
-};
-
-int
-rtag (argc, argv)
- int argc;
- char *argv[];
-{
- register int i;
- int c;
- DBM *db;
- int run_module_prog = 1;
- int err = 0;
-
- if (argc == -1)
- usage (rtag_usage);
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "anfQqlRdbr:D:")) != -1)
- {
- switch (c)
- {
- case 'a':
- attic_too = 1;
- break;
- case 'n':
- run_module_prog = 0;
- break;
- case 'Q':
- really_quiet = 1;
- /* FALL THROUGH */
- case 'q':
- quiet = 1;
- break;
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case 'd':
- delete = 1;
- break;
- case 'f':
- force_tag_match = 0;
- break;
- case 'b':
- branch_mode = 1;
- break;
- case 'r':
- numtag = optarg;
- break;
- case 'D':
- if (date)
- free (date);
- date = Make_Date (optarg);
- break;
- case '?':
- default:
- usage (rtag_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
- if (argc < 2)
- usage (rtag_usage);
- symtag = argv[0];
- argc--;
- argv++;
-
- if (date && numtag)
- error (1, 0, "-r and -D options are mutually exclusive");
- if (delete && branch_mode)
- error (0, 0, "warning: -b ignored with -d options");
- RCS_check_tag (symtag);
-
- db = open_module ();
- for (i = 0; i < argc; i++)
- {
- /* XXX last arg should be repository, but doesn't make sense here */
- history_write ('T', (delete ? "D" : (numtag ? numtag :
- (date ? date : "A"))), symtag, argv[i], "");
- err += do_module (db, argv[i], TAG, delete ? "Untagging" : "Tagging",
- rtag_proc, (char *) NULL, 0, 0, run_module_prog,
- symtag);
- }
- close_module (db);
- return (err);
-}
-
-/*
- * callback proc for doing the real work of tagging
- */
-/* ARGSUSED */
-static int
-rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
- mname, msg)
- int *pargc;
- char *argv[];
- char *xwhere;
- char *mwhere;
- char *mfile;
- int shorten;
- int local_specified;
- char *mname;
- char *msg;
-{
- int err = 0;
- int which;
- char repository[PATH_MAX];
- char where[PATH_MAX];
-
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
- (void) strcpy (where, argv[0]);
-
- /* if mfile isn't null, we need to set up to do only part of the module */
- if (mfile != NULL)
- {
- char *cp;
- char path[PATH_MAX];
-
- /* if the portion of the module is a path, put the dir part on repos */
- if ((cp = rindex (mfile, '/')) != NULL)
- {
- *cp = '\0';
- (void) strcat (repository, "/");
- (void) strcat (repository, mfile);
- (void) strcat (where, "/");
- (void) strcat (where, mfile);
- mfile = cp + 1;
- }
-
- /* take care of the rest */
- (void) sprintf (path, "%s/%s", repository, mfile);
- if (isdir (path))
- {
- /* directory means repository gets the dir tacked on */
- (void) strcpy (repository, path);
- (void) strcat (where, "/");
- (void) strcat (where, mfile);
- }
- else
- {
- int i;
-
- /* a file means muck argv */
- for (i = 1; i < *pargc; i++)
- free (argv[i]);
- argv[1] = xstrdup (mfile);
- (*pargc) = 2;
- }
- }
-
- /* chdir to the starting directory */
- if (chdir (repository) < 0)
- {
- error (0, errno, "cannot chdir to %s", repository);
- return (1);
- }
-
- if (delete || attic_too || (force_tag_match && numtag))
- which = W_REPOS | W_ATTIC;
- else
- which = W_REPOS;
-
- /* start the recursion processor */
- err = start_recursion (rtag_fileproc, (int (*) ()) NULL, rtag_dirproc,
- (int (*) ()) NULL, *pargc - 1, argv + 1, local,
- which, 0, 1, where, 1);
-
- return (err);
-}
-
-/*
- * Called to tag a particular file, as appropriate with the options that were
- * set above.
- */
-/* ARGSUSED */
-static int
-rtag_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- Node *p;
- RCSNode *rcsfile;
- char *version, *rev;
- int retcode = 0;
-
- /* find the parsed RCS data */
- p = findnode (srcfiles, file);
- if (p == NULL)
- return (1);
- rcsfile = (RCSNode *) p->data;
-
- /*
- * For tagging an RCS file which is a symbolic link, you'd best be
- * running with RCS 5.6, since it knows how to handle symbolic links
- * correctly without breaking your link!
- */
-
- if (delete)
- return (rtag_delete (rcsfile));
-
- /*
- * If we get here, we are adding a tag. But, if -a was specified, we
- * need to check to see if a -r or -D option was specified. If neither
- * was specified and the file is in the Attic, remove the tag.
- */
- if (attic_too && (!numtag && !date))
- {
- if ((rcsfile->flags & VALID) && (rcsfile->flags & INATTIC))
- return (rtag_delete (rcsfile));
- }
-
- version = RCS_getversion (rcsfile, numtag, date, force_tag_match);
- if (version == NULL)
- {
- /* If -a specified, clean up any old tags */
- if (attic_too)
- (void) rtag_delete (rcsfile);
-
- if (!quiet && !force_tag_match)
- {
- error (0, 0, "cannot find tag `%s' in `%s'",
- numtag ? numtag : "head", rcsfile->path);
- return (1);
- }
- return (0);
- }
- if (numtag && isdigit (*numtag) && strcmp (numtag, version) != 0)
- {
-
- /*
- * We didn't find a match for the numeric tag that was specified, but
- * that's OK. just pass the numeric tag on to rcs, to be tagged as
- * specified. Could get here if one tried to tag "1.1.1" and there
- * was a 1.1.1 branch with some head revision. In this case, we want
- * the tag to reference "1.1.1" and not the revision at the head of
- * the branch. Use a symbolic tag for that.
- */
- rev = branch_mode ? RCS_magicrev (rcsfile, version) : numtag;
- run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, symtag, numtag);
- }
- else
- {
- char *oversion;
-
- /*
- * As an enhancement for the case where a tag is being re-applied to
- * a large body of a module, make one extra call to Version_Number to
- * see if the tag is already set in the RCS file. If so, check to
- * see if it needs to be moved. If not, do nothing. This will
- * likely save a lot of time when simply moving the tag to the
- * "current" head revisions of a module -- which I have found to be a
- * typical tagging operation.
- */
- oversion = RCS_getversion (rcsfile, symtag, (char *) 0, 1);
- if (oversion != NULL)
- {
- if (strcmp (version, oversion) == 0)
- {
- free (version);
- free (oversion);
- return (0);
- }
- free (oversion);
- }
- rev = branch_mode ? RCS_magicrev (rcsfile, version) : version;
- run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, symtag, rev);
- }
- run_arg (rcsfile->path);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- {
- if (!quiet)
- error (0, retcode == -1 ? errno : 0,
- "failed to set tag `%s' to revision `%s' in `%s'",
- symtag, rev, rcsfile->path);
- free (version);
- return (1);
- }
- free (version);
- return (0);
-}
-
-/*
- * If -d is specified, "force_tag_match" is set, so that this call to
- * Version_Number() will return a NULL version string if the symbolic
- * tag does not exist in the RCS file.
- *
- * If the -r flag was used, numtag is set, and we only delete the
- * symtag from files that have numtag.
- *
- * This is done here because it's MUCH faster than just blindly calling
- * "rcs" to remove the tag... trust me.
- */
-static int
-rtag_delete (rcsfile)
- RCSNode *rcsfile;
-{
- char *version;
- int retcode;
-
- if (numtag)
- {
- version = RCS_getversion (rcsfile, numtag, (char *) 0, 1);
- if (version == NULL)
- return (0);
- free (version);
- }
-
- version = RCS_getversion (rcsfile, symtag, (char *) 0, 1);
- if (version == NULL)
- return (0);
- free (version);
-
- run_setup ("%s%s -q -N%s", Rcsbin, RCS, symtag);
- run_arg (rcsfile->path);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, DEVNULL, RUN_NORMAL)) != 0)
- {
- if (!quiet)
- error (0, retcode == -1 ? errno : 0,
- "failed to remove tag `%s' from `%s'", symtag,
- rcsfile->path);
- return (1);
- }
- return (0);
-}
-
-/*
- * Print a warm fuzzy message
- */
-/* ARGSUSED */
-static Dtype
-rtag_dirproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- if (!quiet)
- error (0, 0, "%s %s", delete ? "Untagging" : "Tagging", update_dir);
- return (R_PROCESS);
-}
diff --git a/gnu/usr.bin/cvs/cvs/status.c b/gnu/usr.bin/cvs/cvs/status.c
deleted file mode 100644
index 9749740..0000000
--- a/gnu/usr.bin/cvs/cvs/status.c
+++ /dev/null
@@ -1,230 +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.3 kit.
- *
- * Status Information
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)status.c 1.48 92/03/31";
-#endif
-
-#if __STDC__
-static Dtype status_dirproc (char *dir, char *repos, char *update_dir);
-static int status_fileproc (char *file, char *update_dir,
- char *repository, List * entries,
- List * srcfiles);
-static int tag_list_proc (Node * p);
-#else
-static int tag_list_proc ();
-static int status_fileproc ();
-static Dtype status_dirproc ();
-#endif /* __STDC__ */
-
-static int local = 0;
-static int long_format = 0;
-
-static char *status_usage[] =
-{
- "Usage: %s %s [-vlR] [files...]\n",
- "\t-v\tVerbose format; includes tag information for the file\n",
- "\t-l\tProcess this directory only (not recursive).\n",
- "\t-R\tProcess directories recursively.\n",
- NULL
-};
-
-int
-status (argc, argv)
- int argc;
- char *argv[];
-{
- int c;
- int err = 0;
-
- if (argc == -1)
- usage (status_usage);
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "vlR")) != -1)
- {
- switch (c)
- {
- case 'v':
- long_format = 1;
- break;
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case '?':
- default:
- usage (status_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- /* start the recursion processor */
- err = start_recursion (status_fileproc, (int (*) ()) NULL, status_dirproc,
- (int (*) ()) NULL, argc, argv, local,
- W_LOCAL, 0, 1, (char *) NULL, 1);
-
- return (err);
-}
-
-/*
- * display the status of a file
- */
-/* ARGSUSED */
-static int
-status_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- Ctype status;
- char *sstat;
- Vers_TS *vers;
-
- status = Classify_File (file, (char *) NULL, (char *) NULL, (char *) NULL,
- 1, 0, repository, entries, srcfiles, &vers);
- switch (status)
- {
- case T_UNKNOWN:
- sstat = "Unknown";
- break;
- case T_CHECKOUT:
- sstat = "Needs Checkout";
- break;
- case T_CONFLICT:
- sstat = "Unresolved Conflict";
- break;
- case T_ADDED:
- sstat = "Locally Added";
- break;
- case T_REMOVED:
- sstat = "Locally Removed";
- break;
- case T_MODIFIED:
- sstat = "Locally Modified";
- break;
- case T_REMOVE_ENTRY:
- sstat = "Entry Invalid";
- break;
- case T_UPTODATE:
- sstat = "Up-to-date";
- break;
- case T_NEEDS_MERGE:
- sstat = "Needs Merge";
- break;
- default:
- sstat = "Classify Error";
- break;
- }
-
- (void) printf ("===================================================================\n");
- if (vers->ts_user == NULL)
- (void) printf ("File: no file %s\t\tStatus: %s\n\n", file, sstat);
- else
- (void) printf ("File: %-17.17s\tStatus: %s\n\n", file, sstat);
-
- if (vers->vn_user == NULL)
- (void) printf (" Version:\t\tNo entry for %s\n", file);
- else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
- (void) printf (" Version:\t\tNew file!\n");
- else
- (void) printf (" Version:\t\t%s\t%s\n", vers->vn_user,
- &vers->ts_rcs[25]);
-
- if (vers->vn_rcs == NULL)
- (void) printf (" RCS Version:\tNo revision control file\n");
- else
- (void) printf (" RCS Version:\t%s\t%s\n", vers->vn_rcs,
- vers->srcfile->path);
-
- if (vers->entdata)
- {
- Entnode *edata;
-
- edata = vers->entdata;
- if (edata->tag)
- {
- if (vers->vn_rcs == NULL)
- (void) printf (
- " Sticky Tag:\t\t%s - MISSING from RCS file!\n",
- edata->tag);
- else
- {
- if (isdigit (edata->tag[0]))
- (void) printf (" Sticky Tag:\t\t%s\n", edata->tag);
- else
- (void) printf (" Sticky Tag:\t\t%s (%s: %s)\n",
- edata->tag, numdots (vers->vn_rcs) % 2 ?
- "revision" : "branch", vers->vn_rcs);
- }
- }
- else
- (void) printf (" Sticky Tag:\t\t(none)\n");
-
- if (edata->date)
- (void) printf (" Sticky Date:\t%s\n", edata->date);
- else
- (void) printf (" Sticky Date:\t(none)\n");
-
- if (edata->options && edata->options[0])
- (void) printf (" Sticky Options:\t%s\n", edata->options);
- else
- (void) printf (" Sticky Options:\t(none)\n");
-
- if (long_format && vers->srcfile)
- {
- (void) printf ("\n Existing Tags:\n");
- if (vers->srcfile->symbols)
- (void) walklist (vers->srcfile->symbols, tag_list_proc);
- else
- (void) printf ("\tNo Tags Exist\n");
- }
- }
-
- (void) printf ("\n");
- freevers_ts (&vers);
- return (0);
-}
-
-/*
- * Print a warm fuzzy message
- */
-/* ARGSUSED */
-static Dtype
-status_dirproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- if (!quiet)
- error (0, 0, "Examining %s", update_dir);
- return (R_PROCESS);
-}
-
-/*
- * Print out a tag and its type
- */
-static int
-tag_list_proc (p)
- Node *p;
-{
- (void) printf ("\t%-25.25s\t(%s: %s)\n", p->key,
- numdots (p->data) % 2 ? "revision" : "branch",
- p->data);
- return (0);
-}
diff --git a/gnu/usr.bin/cvs/cvs/tag.c b/gnu/usr.bin/cvs/cvs/tag.c
deleted file mode 100644
index 71a8c46..0000000
--- a/gnu/usr.bin/cvs/cvs/tag.c
+++ /dev/null
@@ -1,263 +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.3 kit.
- *
- * Tag
- *
- * Add or delete a symbolic name to an RCS file, or a collection of RCS files.
- * Uses the checked out revision in the current directory.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)tag.c 1.56 92/03/31";
-#endif
-
-#if __STDC__
-static Dtype tag_dirproc (char *dir, char *repos, char *update_dir);
-static int tag_fileproc (char *file, char *update_dir,
- char *repository, List * entries,
- List * srcfiles);
-#else
-static int tag_fileproc ();
-static Dtype tag_dirproc ();
-#endif /* __STDC__ */
-
-static char *symtag;
-static int delete; /* adding a tag by default */
-static int branch_mode; /* make an automagic "branch" tag */
-static int local; /* recursive by default */
-
-static char *tag_usage[] =
-{
- "Usage: %s %s [-QlRq] [-b] [-d] tag [files...]\n",
- "\t-Q\tReally quiet.\n",
- "\t-l\tLocal directory only, not recursive.\n",
- "\t-R\tProcess directories recursively.\n",
- "\t-q\tSomewhat quiet.\n",
- "\t-d\tDelete the given Tag.\n",
- "\t-b\tMake the tag a \"branch\" tag, allowing concurrent development.\n",
- NULL
-};
-
-int
-tag (argc, argv)
- int argc;
- char *argv[];
-{
- int c;
- int err = 0;
-
- if (argc == -1)
- usage (tag_usage);
-
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "QqlRdb")) != -1)
- {
- switch (c)
- {
- case 'Q':
- really_quiet = 1;
- /* FALL THROUGH */
- case 'q':
- quiet = 1;
- break;
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case 'd':
- delete = 1;
- break;
- case 'b':
- branch_mode = 1;
- break;
- case '?':
- default:
- usage (tag_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc == 0)
- usage (tag_usage);
- symtag = argv[0];
- argc--;
- argv++;
-
- if (delete && branch_mode)
- error (0, 0, "warning: -b ignored with -d options");
- RCS_check_tag (symtag);
-
- /* start the recursion processor */
- err = start_recursion (tag_fileproc, (int (*) ()) NULL, tag_dirproc,
- (int (*) ()) NULL, argc, argv, local,
- W_LOCAL, 0, 1, (char *) NULL, 1);
- return (err);
-}
-
-/*
- * Called to tag a particular file (the currently checked out version is
- * tagged with the specified tag - or the specified tag is deleted).
- */
-/* ARGSUSED */
-static int
-tag_fileproc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- char *version, *oversion;
- char *rev;
- Vers_TS *vers;
- int retcode = 0;
-
- vers = Version_TS (repository, (char *) NULL, (char *) NULL, (char *) NULL,
- file, 0, 0, entries, srcfiles);
-
- if (delete)
- {
-
- /*
- * If -d is specified, "force_tag_match" is set, so that this call to
- * Version_Number() will return a NULL version string if the symbolic
- * tag does not exist in the RCS file.
- *
- * This is done here because it's MUCH faster than just blindly calling
- * "rcs" to remove the tag... trust me.
- */
-
- version = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1);
- if (version == NULL || vers->srcfile == NULL)
- {
- freevers_ts (&vers);
- return (0);
- }
- free (version);
-
- run_setup ("%s%s -q -N%s", Rcsbin, RCS, symtag);
- run_arg (vers->srcfile->path);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, DEVNULL, RUN_NORMAL)) != 0)
- {
- if (!quiet)
- error (0, retcode == -1 ? errno : 0,
- "failed to remove tag %s from %s", symtag,
- vers->srcfile->path);
- freevers_ts (&vers);
- return (1);
- }
-
- /* warm fuzzies */
- if (!really_quiet)
- {
- if (update_dir[0])
- (void) printf ("D %s/%s\n", update_dir, file);
- else
- (void) printf ("D %s\n", file);
- }
-
- freevers_ts (&vers);
- return (0);
- }
-
- /*
- * If we are adding a tag, we need to know which version we have checked
- * out and we'll tag that version.
- */
- version = vers->vn_user;
- if (version == NULL)
- {
- freevers_ts (&vers);
- return (0);
- }
- else if (strcmp (version, "0") == 0)
- {
- if (!quiet)
- error (0, 0, "couldn't tag added but un-commited file `%s'", file);
- freevers_ts (&vers);
- return (0);
- }
- else if (version[0] == '-')
- {
- if (!quiet)
- error (0, 0, "skipping removed but un-commited file `%s'", file);
- freevers_ts (&vers);
- return (0);
- }
- else if (vers->srcfile == NULL)
- {
- if (!quiet)
- error (0, 0, "cannot find revision control file for `%s'", file);
- freevers_ts (&vers);
- return (0);
- }
-
- /*
- * As an enhancement for the case where a tag is being re-applied to a
- * large number of files, make one extra call to Version_Number to see if
- * the tag is already set in the RCS file. If so, check to see if it
- * needs to be moved. If not, do nothing. This will likely save a lot of
- * time when simply moving the tag to the "current" head revisions of a
- * module -- which I have found to be a typical tagging operation.
- */
- oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1);
- if (oversion != NULL)
- {
- if (strcmp (version, oversion) == 0)
- {
- free (oversion);
- freevers_ts (&vers);
- return (0);
- }
- free (oversion);
- }
- rev = branch_mode ? RCS_magicrev (vers->srcfile, version) : version;
- run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, symtag, rev);
- run_arg (vers->srcfile->path);
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
- {
- if (!quiet)
- error (0, retcode == -1 ? errno : 0,
- "failed to set tag %s to revision %s in %s",
- symtag, rev, vers->srcfile->path);
- freevers_ts (&vers);
- return (1);
- }
-
- /* more warm fuzzies */
- if (!really_quiet)
- {
- if (update_dir[0])
- (void) printf ("T %s/%s\n", update_dir, file);
- else
- (void) printf ("T %s\n", file);
- }
-
- freevers_ts (&vers);
- return (0);
-}
-
-/*
- * Print a warm fuzzy message
- */
-/* ARGSUSED */
-static Dtype
-tag_dirproc (dir, repos, update_dir)
- char *dir;
- char *repos;
- char *update_dir;
-{
- if (!quiet)
- error (0, 0, "%s %s", delete ? "Untagging" : "Tagging", update_dir);
- return (R_PROCESS);
-}
diff --git a/gnu/usr.bin/cvs/cvs/update.c b/gnu/usr.bin/cvs/cvs/update.c
deleted file mode 100644
index c25bc75..0000000
--- a/gnu/usr.bin/cvs/cvs/update.c
+++ /dev/null
@@ -1,1059 +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.3 kit.
- *
- * "update" updates the version in the present directory with respect to the RCS
- * repository. The present version must have been created by "checkout". The
- * user can keep up-to-date by calling "update" whenever he feels like it.
- *
- * The present version can be committed by "commit", but this keeps the version
- * in tact.
- *
- * Arguments following the options are taken to be file names to be updated,
- * rather than updating the entire directory.
- *
- * Modified or non-existent RCS files are checked out and reported as U
- * <user_file>
- *
- * Modified user files are reported as M <user_file>. If both the RCS file and
- * the user file have been modified, the user file is replaced by the result
- * of rcsmerge, and a backup file is written for the user in .#file.version.
- * If this throws up irreconcilable differences, the file is reported as C
- * <user_file>, and as M <user_file> otherwise.
- *
- * Files added but not yet committed are reported as A <user_file>. Files
- * removed but not yet committed are reported as R <user_file>.
- *
- * If the current directory contains subdirectories that hold concurrent
- * versions, these are updated too. If the -d option was specified, new
- * directories added to the repository are automatically created and updated
- * as well.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)update.c 1.83 92/04/10";
-#endif
-
-#if __STDC__
-static int checkout_file (char *file, char *repository, List *entries,
- List *srcfiles, Vers_TS *vers_ts, char *update_dir);
-static int isemptydir (char *dir);
-static int merge_file (char *file, char *repository, List *entries,
- Vers_TS *vers, char *update_dir);
-static int scratch_file (char *file, char *repository, List * entries,
- char *update_dir);
-static Dtype update_dirent_proc (char *dir, char *repository, char *update_dir);
-static int update_dirleave_proc (char *dir, int err, char *update_dir);
-static int update_file_proc (char *file, char *update_dir, char *repository,
- List * entries, List * srcfiles);
-static int update_filesdone_proc (int err, char *repository, char *update_dir);
-static int write_letter (char *file, int letter, char *update_dir);
-static void ignore_files (List * ilist, char *update_dir);
-static void join_file (char *file, List *srcfiles, Vers_TS *vers_ts,
- char *update_dir);
-#else
-static int update_file_proc ();
-static int update_filesdone_proc ();
-static Dtype update_dirent_proc ();
-static int update_dirleave_proc ();
-static int isemptydir ();
-static int scratch_file ();
-static int checkout_file ();
-static int write_letter ();
-static int merge_file ();
-static void ignore_files ();
-static void join_file ();
-#endif /* __STDC__ */
-
-static char *options = NULL;
-static char *tag = NULL;
-static char *date = NULL;
-static char *join_rev1, *date_rev1;
-static char *join_rev2, *date_rev2;
-static int aflag = 0;
-static int force_tag_match = 1;
-static int update_build_dirs = 0;
-static int update_prune_dirs = 0;
-static int pipeout = 0;
-static List *ignlist = (List *) NULL;
-
-static char *update_usage[] =
-{
- "Usage:\n %s %s [-APQdflRpq] [-k kopt] [-r rev|-D date] [-j rev] [-I ign] [files...]\n",
- "\t-A\tReset any sticky tags/date/kopts.\n",
- "\t-P\tPrune empty directories.\n",
- "\t-Q\tReally quiet.\n",
- "\t-d\tBuild directories, like checkout does.\n",
- "\t-f\tForce a head revision match if tag/date not found.\n",
- "\t-l\tLocal directory only, no recursion.\n",
- "\t-R\tProcess directories recursively.\n",
- "\t-p\tSend updates to standard output.\n",
- "\t-q\tSomewhat quiet.\n",
- "\t-k kopt\tUse RCS kopt -k option on checkout.\n",
- "\t-r rev\tUpdate using specified revision/tag.\n",
- "\t-D date\tSet date to update from.\n",
- "\t-j rev\tMerge in changes made between current revision and rev.\n",
- "\t-I ign\tMore files to ignore (! to reset).\n",
- NULL
-};
-
-/*
- * update is the argv,argc based front end for arg parsing
- */
-int
-update (argc, argv)
- int argc;
- char *argv[];
-{
- int c, err;
- int local = 0; /* recursive by default */
- int which; /* where to look for files and dirs */
-
- if (argc == -1)
- usage (update_usage);
-
- ign_setup ();
-
- /* parse the args */
- optind = 1;
- while ((c = gnu_getopt (argc, argv, "ApPflRQqdk:r:D:j:I:")) != -1)
- {
- switch (c)
- {
- case 'A':
- aflag = 1;
- break;
- case 'I':
- ign_add (optarg, 0);
- break;
- case 'k':
- if (options)
- free (options);
- options = RCS_check_kflag (optarg);
- break;
- case 'l':
- local = 1;
- break;
- case 'R':
- local = 0;
- break;
- case 'Q':
- really_quiet = 1;
- /* FALL THROUGH */
- case 'q':
- quiet = 1;
- break;
- case 'd':
- update_build_dirs = 1;
- break;
- case 'f':
- force_tag_match = 0;
- break;
- case 'r':
- tag = optarg;
- break;
- case 'D':
- date = Make_Date (optarg);
- break;
- case 'P':
- update_prune_dirs = 1;
- break;
- case 'p':
- pipeout = 1;
- noexec = 1; /* so no locks will be created */
- break;
- case 'j':
- if (join_rev2)
- error (1, 0, "only two -j options can be specified");
- if (join_rev1)
- join_rev2 = optarg;
- else
- join_rev1 = optarg;
- break;
- case '?':
- default:
- usage (update_usage);
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- /*
- * If we are updating the entire directory (for real) and building dirs
- * as we go, we make sure there is no static entries file and write the
- * tag file as appropriate
- */
- if (argc <= 0 && !pipeout)
- {
- if (update_build_dirs)
- (void) unlink_file (CVSADM_ENTSTAT);
-
- /* keep the CVS/Tag file current with the specified arguments */
- if (aflag || tag || date)
- WriteTag ((char *) NULL, tag, date);
- }
-
- /* look for files/dirs locally and in the repository */
- which = W_LOCAL | W_REPOS;
-
- /* look in the attic too if a tag or date is specified */
- if (tag != NULL || date != NULL)
- which |= W_ATTIC;
-
- /* call the command line interface */
- err = do_update (argc, argv, options, tag, date, force_tag_match,
- local, update_build_dirs, aflag, update_prune_dirs,
- pipeout, which, join_rev1, join_rev2, (char *) NULL);
-
- /* free the space Make_Date allocated if necessary */
- if (date != NULL)
- free (date);
-
- return (err);
-}
-
-/*
- * Command line interface to update (used by checkout)
- */
-int
-do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag,
- xprune, xpipeout, which, xjoin_rev1, xjoin_rev2, preload_update_dir)
- int argc;
- char *argv[];
- char *xoptions;
- char *xtag;
- char *xdate;
- int xforce;
- int local;
- int xbuild;
- int xaflag;
- int xprune;
- int xpipeout;
- int which;
- char *xjoin_rev1;
- char *xjoin_rev2;
- char *preload_update_dir;
-{
- int err = 0;
- char *cp;
-
- /* fill in the statics */
- options = xoptions;
- tag = xtag;
- date = xdate;
- force_tag_match = xforce;
- update_build_dirs = xbuild;
- aflag = xaflag;
- update_prune_dirs = xprune;
- pipeout = xpipeout;
-
- /* setup the join support */
- join_rev1 = xjoin_rev1;
- join_rev2 = xjoin_rev2;
- if (join_rev1 && (cp = index (join_rev1, ':')) != NULL)
- {
- *cp++ = '\0';
- date_rev1 = Make_Date (cp);
- }
- else
- date_rev1 = (char *) NULL;
- if (join_rev2 && (cp = index (join_rev2, ':')) != NULL)
- {
- *cp++ = '\0';
- date_rev2 = Make_Date (cp);
- }
- else
- date_rev2 = (char *) NULL;
-
- /* call the recursion processor */
- err = start_recursion (update_file_proc, update_filesdone_proc,
- update_dirent_proc, update_dirleave_proc,
- argc, argv, local, which, aflag, 1,
- preload_update_dir, 1);
- return (err);
-}
-
-/*
- * This is the callback proc for update. It is called for each file in each
- * directory by the recursion code. The current directory is the local
- * instantiation. file is the file name we are to operate on. update_dir is
- * set to the path relative to where we started (for pretty printing).
- * repository is the repository. entries and srcfiles are the pre-parsed
- * entries and source control files.
- *
- * This routine decides what needs to be done for each file and does the
- * appropriate magic for checkout
- */
-static int
-update_file_proc (file, update_dir, repository, entries, srcfiles)
- char *file;
- char *update_dir;
- char *repository;
- List *entries;
- List *srcfiles;
-{
- int retval;
- Ctype status;
- Vers_TS *vers;
-
- status = Classify_File (file, tag, date, options, force_tag_match,
- aflag, repository, entries, srcfiles, &vers);
- if (pipeout)
- {
- /*
- * We just return success without doing anything if any of the really
- * funky cases occur
- *
- * If there is still a valid RCS file, do a regular checkout type
- * operation
- */
- switch (status)
- {
- case T_UNKNOWN: /* unknown file was explicitly asked
- * about */
- case T_REMOVE_ENTRY: /* needs to be un-registered */
- case T_ADDED: /* added but not committed */
- retval = 0;
- break;
- case T_CONFLICT: /* old punt-type errors */
- retval = 1;
- break;
- case T_UPTODATE: /* file was already up-to-date */
- case T_NEEDS_MERGE: /* needs merging */
- case T_MODIFIED: /* locally modified */
- case T_REMOVED: /* removed but not committed */
- case T_CHECKOUT: /* needs checkout */
- retval = checkout_file (file, repository, entries, srcfiles,
- vers, update_dir);
- break;
-
- default: /* can't ever happen :-) */
- error (0, 0,
- "unknown file status %d for file %s", status, file);
- retval = 0;
- break;
- }
- }
- else
- {
- switch (status)
- {
- case T_UNKNOWN: /* unknown file was explicitly asked
- * about */
- case T_UPTODATE: /* file was already up-to-date */
- retval = 0;
- break;
- case T_CONFLICT: /* old punt-type errors */
- retval = 1;
- break;
- case T_NEEDS_MERGE: /* needs merging */
- retval = merge_file (file, repository, entries,
- vers, update_dir);
- break;
- case T_MODIFIED: /* locally modified */
- retval = write_letter (file, 'M', update_dir);
- break;
- case T_CHECKOUT: /* needs checkout */
- retval = checkout_file (file, repository, entries, srcfiles,
- vers, update_dir);
- break;
- case T_ADDED: /* added but not committed */
- retval = write_letter (file, 'A', update_dir);
- break;
- case T_REMOVED: /* removed but not committed */
- retval = write_letter (file, 'R', update_dir);
- break;
- case T_REMOVE_ENTRY: /* needs to be un-registered */
- retval = scratch_file (file, repository, entries, update_dir);
- break;
- default: /* can't ever happen :-) */
- error (0, 0,
- "unknown file status %d for file %s", status, file);
- retval = 0;
- break;
- }
- }
-
- /* only try to join if things have gone well thus far */
- if (retval == 0 && join_rev1)
- join_file (file, srcfiles, vers, update_dir);
-
- /* if this directory has an ignore list, add this file to it */
- if (ignlist)
- {
- Node *p;
-
- p = getnode ();
- p->type = FILES;
- p->key = xstrdup (file);
- (void) addnode (ignlist, p);
- }
-
- freevers_ts (&vers);
- return (retval);
-}
-
-/*
- * update_filesdone_proc () is used
- */
-/* ARGSUSED */
-static int
-update_filesdone_proc (err, repository, update_dir)
- int err;
- char *repository;
- char *update_dir;
-{
- /* if this directory has an ignore list, process it then free it */
- if (ignlist)
- {
- ignore_files (ignlist, update_dir);
- dellist (&ignlist);
- }
-
- /* Clean up CVS admin dirs if we are export */
- if (strcmp (command_name, "export") == 0)
- {
- run_setup ("%s -fr", RM);
- run_arg (CVSADM);
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
-
-#ifdef DO_LINKS
- {
- char lnfile[PATH_MAX];
- FILE *links;
-
- sprintf(lnfile, "%s/SymLinks", repository);
- links = fopen(lnfile, "r");
- if (links) {
- char from[PATH_MAX], to[PATH_MAX];
-
- /* Read all the link pairs from the symlinks file */
- while (fgets(to, PATH_MAX, links)) {
- fgets(from, PATH_MAX, links);
-
- /* Strip off the newlines */
- to[strlen(to) - 1] = '\0';
- from[strlen(from) - 1] = '\0';
-
- /* Do it */
- if (symlink(from, to) == -1) {
- error (0, errno, "Unable to create symlink `%s'", to);
- return 1;
- }
- else if (!quiet)
- error (0, 0, "Creating symlink %s", to);
- }
- fclose(links);
- }
- }
-#endif
-
- return (err);
-}
-
-/*
- * update_dirent_proc () is called back by the recursion processor before a
- * sub-directory is processed for update. In this case, update_dirent proc
- * will probably create the directory unless -d isn't specified and this is a
- * new directory. A return code of 0 indicates the directory should be
- * processed by the recursion code. A return of non-zero indicates the
- * recursion code should skip this directory.
- */
-static Dtype
-update_dirent_proc (dir, repository, update_dir)
- char *dir;
- char *repository;
- char *update_dir;
-{
- if (!isdir (dir))
- {
- /* if we aren't building dirs, blow it off */
- if (!update_build_dirs)
- return (R_SKIP_ALL);
-
- if (noexec)
- {
- /* ignore the missing dir if -n is specified */
- error (0, 0, "New directory `%s' -- ignored", dir);
- return (R_SKIP_ALL);
- }
- else
- {
- /* otherwise, create the dir and appropriate adm files */
- make_directory (dir);
- Create_Admin (dir, repository, tag, date);
- }
- }
-
- /*
- * If we are building dirs and not going to stdout, we make sure there is
- * no static entries file and write the tag file as appropriate
- */
- if (!pipeout)
- {
- if (update_build_dirs)
- {
- char tmp[PATH_MAX];
-
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENTSTAT);
- (void) unlink_file (tmp);
- }
-
- /* keep the CVS/Tag file current with the specified arguments */
- if (aflag || tag || date)
- WriteTag (dir, tag, date);
-
- /* initialize the ignore list for this directory */
- ignlist = getlist ();
- }
-
- /* print the warm fuzzy message */
- if (!quiet)
- error (0, 0, "Updating %s", update_dir);
-
- return (R_PROCESS);
-}
-
-/*
- * update_dirleave_proc () is called back by the recursion code upon leaving
- * a directory. It will prune empty directories if needed and will execute
- * any appropriate update programs.
- */
-/* ARGSUSED */
-static int
-update_dirleave_proc (dir, err, update_dir)
- char *dir;
- int err;
- char *update_dir;
-{
- FILE *fp;
-
- /* run the update_prog if there is one */
- if (err == 0 && !pipeout && !noexec &&
- (fp = fopen (CVSADM_UPROG, "r")) != NULL)
- {
- char *cp;
- char *repository;
- char line[MAXLINELEN];
-
- repository = Name_Repository ((char *) NULL, update_dir);
- if (fgets (line, sizeof (line), fp) != NULL)
- {
- if ((cp = rindex (line, '\n')) != NULL)
- *cp = '\0';
- run_setup ("%s %s", line, repository);
- (void) printf ("%s %s: Executing '", program_name, command_name);
- run_print (stdout);
- (void) printf ("'\n");
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
- (void) fclose (fp);
- free (repository);
- }
-
- /* Clean up CVS admin dirs if we are export */
- if (strcmp (command_name, "export") == 0)
- {
- run_setup ("%s -fr", RM);
- run_arg (CVSADM);
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
-
- /* Prune empty dirs on the way out - if necessary */
- (void) chdir ("..");
- if (update_prune_dirs && isemptydir (dir))
- {
- run_setup ("%s -fr", RM);
- run_arg (dir);
- (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- }
-
- return (err);
-}
-
-/*
- * Returns 1 if the argument directory is completely empty, other than the
- * existence of the CVS directory entry. Zero otherwise.
- */
-static int
-isemptydir (dir)
- char *dir;
-{
- DIR *dirp;
- struct direct *dp;
-
- if ((dirp = opendir (dir)) == NULL)
- {
- error (0, 0, "cannot open directory %s for empty check", dir);
- return (0);
- }
- while ((dp = readdir (dirp)) != NULL)
- {
- if (strcmp (dp->d_name, ".") != 0 && strcmp (dp->d_name, "..") != 0 &&
- strcmp (dp->d_name, CVSADM) != 0 &&
- strcmp (dp->d_name, OCVSADM) != 0)
- {
- (void) closedir (dirp);
- return (0);
- }
- }
- (void) closedir (dirp);
- return (1);
-}
-
-/*
- * scratch the Entries file entry associated with a file
- */
-static int
-scratch_file (file, repository, entries, update_dir)
- char *file;
- char *repository;
- List *entries;
- char *update_dir;
-{
- history_write ('W', update_dir, "", file, repository);
- Scratch_Entry (entries, file);
- (void) unlink_file (file);
- return (0);
-}
-
-/*
- * check out a file - essentially returns the result of the fork on "co".
- */
-static int
-checkout_file (file, repository, entries, srcfiles, vers_ts, update_dir)
- char *file;
- char *repository;
- List *entries;
- List *srcfiles;
- Vers_TS *vers_ts;
- char *update_dir;
-{
- char backup[PATH_MAX];
- int set_time, retval = 0;
- int retcode = 0;
-
- /* don't screw with backup files if we're going to stdout */
- if (!pipeout)
- {
- (void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, file);
- if (isfile (file))
- rename_file (file, backup);
- else
- (void) unlink_file (backup);
- }
-
- run_setup ("%s%s -q -r%s %s", Rcsbin, RCS_CO, vers_ts->vn_rcs,
- vers_ts->options);
-
- /*
- * if we are checking out to stdout, print a nice message to stderr, and
- * add the -p flag to the command
- */
- if (pipeout)
- {
- run_arg ("-p");
- if (!quiet)
- {
- (void) fprintf (stderr, "===================================================================\n");
- if (update_dir[0])
- (void) fprintf (stderr, "Checking out %s/%s\n",
- update_dir, file);
- else
- (void) fprintf (stderr, "Checking out %s\n", file);
- (void) fprintf (stderr, "RCS: %s\n", vers_ts->srcfile->path);
- (void) fprintf (stderr, "VERS: %s\n", vers_ts->vn_rcs);
- (void) fprintf (stderr, "***************\n");
- }
- }
-
- /* tack on the rcs and maybe the user file */
- run_arg (vers_ts->srcfile->path);
- if (!pipeout)
- run_arg (file);
-
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY,
- (pipeout ? (RUN_NORMAL|RUN_REALLY) : RUN_NORMAL))) == 0)
- {
- if (!pipeout)
- {
- Vers_TS *xvers_ts;
-
- if (cvswrite == TRUE)
- xchmod (file, 1);
-
- /* set the time from the RCS file iff it was unknown before */
- if (vers_ts->vn_user == NULL ||
- strncmp (vers_ts->ts_rcs, "Initial", 7) == 0)
- {
- set_time = 1;
- }
- else
- set_time = 0;
-
- xvers_ts = Version_TS (repository, options, tag, date, file,
- force_tag_match, set_time, entries, srcfiles);
- if (strcmp (xvers_ts->options, "-V4") == 0)
- xvers_ts->options[0] = '\0';
- Register (entries, file, xvers_ts->vn_rcs, xvers_ts->ts_user,
- xvers_ts->options, xvers_ts->tag, xvers_ts->date);
-
- /* fix up the vers structure, in case it is used by join */
- if (join_rev1)
- {
- if (vers_ts->vn_user != NULL)
- free (vers_ts->vn_user);
- if (vers_ts->vn_rcs != NULL)
- free (vers_ts->vn_rcs);
- vers_ts->vn_user = xstrdup (xvers_ts->vn_rcs);
- vers_ts->vn_rcs = xstrdup (xvers_ts->vn_rcs);
- }
-
- /* If this is really Update and not Checkout, recode history */
- if (strcmp (command_name, "update") == 0)
- history_write ('U', update_dir, xvers_ts->vn_rcs, file,
- repository);
-
- freevers_ts (&xvers_ts);
-
- if (!really_quiet)
- {
- if (update_dir[0])
- (void) printf ("U %s/%s\n", update_dir, file);
- else
- (void) printf ("U %s\n", file);
- }
- }
- }
- else
- {
- int old_errno = errno; /* save errno value over the rename */
-
- if (!pipeout && isfile (backup))
- rename_file (backup, file);
-
- error (retcode == -1 ? 1 : 0, retcode == -1 ? old_errno : 0,
- "could not check out %s", file);
-
- retval = retcode;
- }
-
- if (!pipeout)
- (void) unlink_file (backup);
-
- return (retval);
-}
-
-/*
- * Several of the types we process only print a bit of information consisting
- * of a single letter and the name.
- */
-static int
-write_letter (file, letter, update_dir)
- char *file;
- char letter;
- char *update_dir;
-{
- if (!really_quiet)
- {
- if (update_dir[0])
- (void) printf ("%c %s/%s\n", letter, update_dir, file);
- else
- (void) printf ("%c %s\n", letter, file);
- }
- return (0);
-}
-
-/*
- * Do all the magic associated with a file which needs to be merged
- */
-static int
-merge_file (file, repository, entries, vers, update_dir)
- char *file;
- char *repository;
- List *entries;
- Vers_TS *vers;
- char *update_dir;
-{
- char user[PATH_MAX];
- char backup[PATH_MAX];
- int status;
- int retcode = 0;
-
- /*
- * The users currently modified file is moved to a backup file name
- * ".#filename.version", so that it will stay around for a few days
- * before being automatically removed by some cron daemon. The "version"
- * is the version of the file that the user was most up-to-date with
- * before the merge.
- */
- (void) sprintf (backup, "%s%s.%s", BAKPREFIX, file, vers->vn_user);
- if (update_dir[0])
- (void) sprintf (user, "%s/%s", update_dir, file);
- else
- (void) strcpy (user, file);
-
- (void) unlink_file (backup);
- copy_file (file, backup);
- xchmod (file, 1);
-
- /* XXX - Do merge by hand instead of using rcsmerge, due to -k handling */
- run_setup ("%s%s %s -r%s -r%s", Rcsbin, RCS_RCSMERGE, vers->options,
- vers->vn_user, vers->vn_rcs);
- run_arg (vers->srcfile->path);
- status = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- if (status != 0
-#ifdef HAVE_RCS5
- && status != 1
-#endif
- )
- {
- error (0, status == -1 ? errno : 0,
- "could not merge revision %s of %s", vers->vn_user, user);
- error (status == -1 ? 1 : 0, 0, "restoring %s from backup file %s",
- user, backup);
- rename_file (backup, file);
- return (1);
- }
- /* XXX - Might want to make sure that rcsmerge changed the file */
- if (strcmp (vers->options, "-V4") == 0)
- vers->options[0] = '\0';
- Register (entries, file, vers->vn_rcs, vers->ts_rcs, vers->options,
- vers->tag, vers->date);
-
- /* fix up the vers structure, in case it is used by join */
- if (join_rev1)
- {
- if (vers->vn_user != NULL)
- free (vers->vn_user);
- vers->vn_user = xstrdup (vers->vn_rcs);
- }
-
- /* possibly run GREP to see if there appear to be conflicts in the file */
- run_setup ("%s -s", GREP);
- run_arg (RCS_MERGE_PAT);
- run_arg (file);
- if (status == 1 ||
- (retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) == 0)
- {
- if (!noexec)
- error (0, 0, "conflicts found in %s", user);
-
- if (!really_quiet)
- (void) printf ("C %s\n", user);
-
- history_write ('C', update_dir, vers->vn_rcs, file, repository);
-
- }
- else if (retcode == -1)
- {
- error (1, errno, "fork failed while examining update of %s", user);
- }
- else
- {
- if (!really_quiet)
- (void) printf ("M %s\n", user);
- history_write ('G', update_dir, vers->vn_rcs, file, repository);
- }
- return (0);
-}
-
-/*
- * Do all the magic associated with a file which needs to be joined
- * (-j option)
- */
-static void
-join_file (file, srcfiles, vers, update_dir)
- char *file;
- List *srcfiles;
- Vers_TS *vers;
- char *update_dir;
-{
- char user[PATH_MAX];
- char backup[PATH_MAX];
- char *rev, *baserev;
- char *options;
- int status;
-
- /* determine if we need to do anything at all */
- if (vers->vn_user == NULL || vers->srcfile == NULL ||
- vers->srcfile->path == NULL)
- {
- return;
- }
-
- /* special handling when two revisions are specified */
- if (join_rev1 && join_rev2)
- {
- rev = RCS_getversion (vers->srcfile, join_rev2, date_rev2, 1);
- if (rev == NULL)
- {
- if (!quiet && date_rev2 == NULL)
- error (0, 0,
- "cannot find revision %s in file %s", join_rev2, file);
- return;
- }
-
- baserev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1);
- if (baserev == NULL)
- {
- if (!quiet && date_rev1 == NULL)
- error (0, 0,
- "cannot find revision %s in file %s", join_rev1, file);
- free (rev);
- return;
- }
-
- /*
- * nothing to do if:
- * second revision matches our BASE revision (vn_user) &&
- * both revisions are on the same branch
- */
- if (strcmp (vers->vn_user, rev) == 0 &&
- numdots (baserev) == numdots (rev))
- {
- /* might be the same branch. take a real look */
- char *dot = rindex (baserev, '.');
- int len = (dot - baserev) + 1;
-
- if (strncmp (baserev, rev, len) == 0)
- return;
- }
- }
- else
- {
- rev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1);
- if (rev == NULL)
- return;
- if (strcmp (rev, vers->vn_user) == 0) /* no merge necessary */
- {
- free (rev);
- return;
- }
-
- baserev = RCS_whatbranch (file, join_rev1, srcfiles);
- if (baserev)
- {
- char *cp;
-
- /* we get a branch -- turn it into a revision, or NULL if trunk */
- if ((cp = rindex (baserev, '.')) == NULL)
- {
- free (baserev);
- baserev = (char *) NULL;
- }
- else
- *cp = '\0';
- }
- }
- if (baserev && strcmp (baserev, rev) == 0)
- {
- /* they match -> nothing to do */
- free (rev);
- free (baserev);
- return;
- }
-
- /* OK, so we have a revision and possibly a base revision; continue on */
-
- /*
- * The users currently modified file is moved to a backup file name
- * ".#filename.version", so that it will stay around for a few days
- * before being automatically removed by some cron daemon. The "version"
- * is the version of the file that the user was most up-to-date with
- * before the merge.
- */
- (void) sprintf (backup, "%s%s.%s", BAKPREFIX, file, vers->vn_user);
- if (update_dir[0])
- (void) sprintf (user, "%s/%s", update_dir, file);
- else
- (void) strcpy (user, file);
-
- (void) unlink_file (backup);
- copy_file (file, backup);
- xchmod (file, 1);
-
- options = vers->options;
-#ifdef HAVE_RCS5
- if (*options == '\0')
- options = "-kk"; /* to ignore keyword expansions */
-#endif
-
- /* XXX - Do merge by hand instead of using rcsmerge, due to -k handling */
- run_setup ("%s%s %s %s%s -r%s", Rcsbin, RCS_RCSMERGE, options,
- baserev ? "-r" : "", baserev ? baserev : "", rev);
- run_arg (vers->srcfile->path);
- status = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
- if (status != 0
-#ifdef HAVE_RCS5
- && status != 1
-#endif
- )
- {
- error (0, status == -1 ? errno : 0,
- "could not merge revision %s of %s", rev, user);
- error (status == -1 ? 1 : 0, 0, "restoring %s from backup file %s",
- user, backup);
- rename_file (backup, file);
- }
- free (rev);
- if (baserev)
- free (baserev);
- return;
-}
-
-/*
- * Process the current directory, looking for files not in ILIST and not on
- * the global ignore list for this directory.
- */
-static void
-ignore_files (ilist, update_dir)
- List *ilist;
- char *update_dir;
-{
- DIR *dirp;
- struct direct *dp;
- struct stat sb;
- char *file;
- char *xdir;
-
- /* we get called with update_dir set to "." sometimes... strip it */
- if (strcmp (update_dir, ".") == 0)
- xdir = "";
- else
- xdir = update_dir;
-
- dirp = opendir (".");
- if (dirp == NULL)
- return;
-
- ign_add_file (CVSDOTIGNORE, 1);
- while ((dp = readdir (dirp)) != NULL)
- {
- file = dp->d_name;
- if (strcmp (file, ".") == 0 || strcmp (file, "..") == 0)
- continue;
- if (findnode (ilist, file) != NULL)
- continue;
- if (lstat (file, &sb) != -1)
- {
- if (S_ISDIR (sb.st_mode))
- continue;
-#ifdef S_IFLNK
- if (S_ISLNK (sb.st_mode))
- continue;
-#endif
- }
- if (ign_name (file))
- continue;
- (void) write_letter (file, '?', xdir);
- }
- (void) closedir (dirp);
-}
diff --git a/gnu/usr.bin/cvs/cvs/vers_ts.c b/gnu/usr.bin/cvs/cvs/vers_ts.c
deleted file mode 100644
index 6ac2488..0000000
--- a/gnu/usr.bin/cvs/cvs/vers_ts.c
+++ /dev/null
@@ -1,224 +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.3 kit.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)vers_ts.c 1.36 92/03/31";
-#endif
-
-extern char *ctime (); /* XXX - should use gmtime/asctime */
-
-/*
- * Fill in and return a Vers_TS structure "user" is the name of the local
- * file; entries is the entries file - preparsed for our pleasure. xfiles is
- * all source code control files, preparsed for our pleasure
- */
-Vers_TS *
-Version_TS (repository, options, tag, date, user, force_tag_match,
- set_time, entries, xfiles)
- char *repository;
- char *options;
- char *tag;
- char *date;
- char *user;
- int force_tag_match;
- int set_time;
- List *entries;
- List *xfiles;
-{
- Node *p;
- RCSNode *rcsdata;
- Vers_TS *vers_ts;
- struct stickydirtag *sdtp;
-
- /* get a new Vers_TS struct */
- vers_ts = (Vers_TS *) xmalloc (sizeof (Vers_TS));
- bzero ((char *) vers_ts, sizeof (*vers_ts));
-
- /*
- * look up the entries file entry and fill in the version and timestamp
- * if entries is NULL, there is no entries file so don't bother trying to
- * look it up (used by checkout -P)
- */
- if (entries == NULL)
- {
- sdtp = NULL;
- p = NULL;
- }
- else
- {
- p = findnode (entries, user);
- sdtp = (struct stickydirtag *) entries->list->data; /* list-private */
- }
-
- if (p != NULL)
- {
- Entnode *entdata = (Entnode *) p->data;
-
- vers_ts->vn_user = xstrdup (entdata->version);
- vers_ts->ts_rcs = xstrdup (entdata->timestamp);
- if (!tag)
- {
- if (!(sdtp && sdtp->aflag))
- vers_ts->tag = xstrdup (entdata->tag);
- }
- if (!date)
- {
- if (!(sdtp && sdtp->aflag))
- vers_ts->date = xstrdup (entdata->date);
- }
- if (!options || (options && *options == '\0'))
- {
- if (!(sdtp && sdtp->aflag))
- vers_ts->options = xstrdup (entdata->options);
- }
- vers_ts->entdata = entdata;
- }
-
- /*
- * -k options specified on the command line override (and overwrite)
- * options stored in the entries file
- */
- if (options)
- vers_ts->options = xstrdup (options);
- else if (sdtp && sdtp->aflag == 0)
- {
- if (!vers_ts->options)
- vers_ts->options = xstrdup (sdtp->options);
- }
- if (!vers_ts->options)
- vers_ts->options = xstrdup ("");
-
- /*
- * if tags were specified on the command line, they override what is in
- * the Entries file
- */
- if (tag || date)
- {
- vers_ts->tag = xstrdup (tag);
- vers_ts->date = xstrdup (date);
- }
- else if (!vers_ts->entdata && (sdtp && sdtp->aflag == 0))
- {
- if (!vers_ts->tag)
- vers_ts->tag = xstrdup (sdtp->tag);
- if (!vers_ts->date)
- vers_ts->date = xstrdup (sdtp->date);
- }
-
- /* Now look up the info on the source controlled file */
- if (xfiles != (List *) NULL)
- {
- p = findnode (xfiles, user);
- if (p != NULL)
- {
- rcsdata = (RCSNode *) p->data;
- rcsdata->refcount++;
- }
- else
- rcsdata = NULL;
- }
- else
- rcsdata = RCS_parse (user, repository);
-
- if (rcsdata != NULL)
- {
- /* squirrel away the rcsdata pointer for others */
- vers_ts->srcfile = rcsdata;
-
- /* get RCS version number into vn_rcs (if appropriate) */
- if (((vers_ts->tag || vers_ts->date) && force_tag_match) ||
- ((rcsdata->flags & VALID) && (rcsdata->flags & INATTIC) == 0))
- {
- if (vers_ts->tag && strcmp (vers_ts->tag, TAG_BASE) == 0)
- vers_ts->vn_rcs = xstrdup (vers_ts->vn_user);
- else
- vers_ts->vn_rcs = RCS_getversion (rcsdata, vers_ts->tag,
- vers_ts->date, force_tag_match);
- }
-
- /*
- * If the source control file exists and has the requested revision,
- * get the Date the revision was checked in. If "user" exists, set
- * its mtime.
- */
- if (set_time)
- {
- struct utimbuf t;
-
- if (vers_ts->vn_rcs &&
- (t.actime = t.modtime = RCS_getrevtime (rcsdata, vers_ts->vn_rcs,
- (char *) 0, 0)) != -1)
- (void) utime (user, &t);
- }
- }
-
- /* get user file time-stamp in ts_user */
- if (entries != (List *) NULL)
- vers_ts->ts_user = time_stamp (user);
-
- return (vers_ts);
-}
-
-/*
- * Gets the time-stamp for the file "file" and returns it in space it
- * allocates
- */
-char *
-time_stamp (file)
- char *file;
-{
- struct stat sb;
- char *cp;
- char *ts;
-
- if (stat (file, &sb) < 0)
- {
- ts = NULL;
- }
- else
- {
- ts = xmalloc (51); /* 51 = 2 ctime strings + NULL */
- cp = ctime (&sb.st_ctime); /* copy in the create time */
- cp[24] = ' ';
- (void) strcpy (ts, cp);
- cp = ctime (&sb.st_mtime); /* copy in the modify time */
- cp[24] = '\0';
- (void) strcat (ts, cp);
- }
-
- return (ts);
-}
-
-/*
- * free up a Vers_TS struct
- */
-void
-freevers_ts (versp)
- Vers_TS **versp;
-{
- if ((*versp)->srcfile)
- freercsnode (&((*versp)->srcfile));
- if ((*versp)->vn_user)
- free ((*versp)->vn_user);
- if ((*versp)->vn_rcs)
- free ((*versp)->vn_rcs);
- if ((*versp)->ts_user)
- free ((*versp)->ts_user);
- if ((*versp)->ts_rcs)
- free ((*versp)->ts_rcs);
- if ((*versp)->options)
- free ((*versp)->options);
- if ((*versp)->tag)
- free ((*versp)->tag);
- if ((*versp)->date)
- free ((*versp)->date);
- free ((char *) *versp);
- *versp = (Vers_TS *) NULL;
-}
diff --git a/gnu/usr.bin/cvs/cvs/version.c b/gnu/usr.bin/cvs/cvs/version.c
deleted file mode 100644
index 18a9d14..0000000
--- a/gnu/usr.bin/cvs/cvs/version.c
+++ /dev/null
@@ -1,11 +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.3 kit.
- *
- * version.c - the CVS version number
- */
-
-char *version_string = "\nConcurrent Versions System (CVS) 1.3\n";
diff --git a/gnu/usr.bin/cvs/doc/cvs.ms b/gnu/usr.bin/cvs/doc/cvs.ms
deleted file mode 100644
index 567179b..0000000
--- a/gnu/usr.bin/cvs/doc/cvs.ms
+++ /dev/null
@@ -1,1073 +0,0 @@
-.\" soelim cvs.ms | pic | tbl | troff -ms
-.\" @(#)cvs.ms 1.2 92/01/30
-.\"
-.\" troff source to the cvs USENIX article, Winter 1990, Washington, D.C.
-.\" Copyright (c) 1989, Brian Berliner
-.\"
-.\" 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 can be reached at: berliner@prisma.com
-.\"
-.de SP
-.if n .sp
-.if t .sp .5
-..
-.de hl
-.br
-.in +0.5i
-\l'\\n(LLu-1i'
-.in -0.5i
-.sp
-..
-.OH ""
-.nr PS 11
-.nr PO 1.25i
-.pl -0.2i
-.TL
-.ps 14
-.ft B
-.nf
-CVS II:
-Parallelizing Software Development
-.fi
-.ft
-.ps
-.AU
-.ps 12
-.ft I
-Brian Berliner
-.ft
-.ps
-.AI
-.ps 12
-.ft I
-Prisma, Inc.
-5465 Mark Dabling Blvd.
-Colorado Springs, CO 80918
-berliner@prisma.com
-.ft
-.ps
-.AB
-The program described in this paper fills a need in the UNIX
-community for a freely available tool to manage software revision and
-release control in a multi-developer, multi-directory, multi-group
-environment.
-This tool also addresses the increasing need for tracking third-party vendor
-source distributions while trying to maintain local modifications to
-earlier releases.
-.AE
-.NH
-Background
-.PP
-In large software development projects, it is usually necessary for more
-than one software developer to be modifying (usually different) modules of the
-code at the same time.
-Some of these code modifications are done in an
-experimental sense, at least until the code functions correctly, and some
-testing of the entire program is usually necessary.
-Then, the modifications are returned to a master source repository
-so that others in the project can
-enjoy the new bug-fix or functionality.
-In order to manage such a project, some sort of revision control system is
-necessary.
-.PP
-Specifically, UNIX\**
-.FS
-UNIX is a registered trademark of AT&T.
-.FE
-kernel development is an excellent example of the
-problems that an adequate revision control system must address.
-The SunOS\**
-.FS
-SunOS is a trademark of Sun Microsystems, Inc.
-.FE
-kernel is composed of over a thousand files spread across a
-hierarchy of dozens of directories.\**
-.FS
-Yes, the SunOS 4.0 kernel is composed of over a \fIthousand\fP files!
-.FE
-Pieces of the kernel must be edited
-by many software developers within an organization.
-While undesirable in
-theory, it is not uncommon to have two or more people making
-modifications to the same file within the kernel sources in
-order to facilitate a desired change.
-Existing revision control systems like
-.SM
-RCS
-.LG
-[Tichy] or
-.SM
-SCCS
-.LG
-[Bell] serialize file modifications by
-allowing only one developer to have a writable copy of a particular file at
-any one point in time.
-That developer is said to
-have \*Qlocked\*U the file for his exclusive use, and no other developer is
-allowed to check out a writable copy of the file until the locking
-developer has finished impeding others' productivity.
-Development pressures of productivity and deadlines
-often force organizations to require that multiple developers be able to
-simultaneously edit
-copies of the same revision controlled file.
-.PP
-The necessity for multiple developers to modify the same file concurrently
-questions the value of serialization-based policies in traditional revision
-control.
-This paper discusses the approach that
-Prisma took in adapting a standard revision control system,
-.SM
-RCS\c
-.LG
-, along with an existing public-domain collection of shell scripts that sits
-atop
-.SM
-RCS
-.LG
-and provides the basic conflict-resolution algorithms.
-The resulting
-program, \fBcvs\fP, addresses not only the issue of conflict-resolution in
-a multi-developer open-editing environment, but also the issues of
-software release control and vendor source support and integration.
-.NH
-The CVS Program
-.PP
-\fBcvs\fP
-(Concurrent Versions System)
-is a front end to the
-.SM
-RCS
-.LG
-revision control system which extends
-the notion of revision control from a collection of files in a single
-directory to a hierarchical collection of directories each containing
-revision controlled files.
-Directories and files in the \fBcvs\fP system can be combined together in
-many ways to form a software release.
-\fBcvs\fP
-provides the functions necessary to manage these software releases and to
-control the concurrent editing of source files among multiple software
-developers.
-.PP
-The six major features of \fBcvs\fP are listed below, and will be
-described in more detail in the following sections:
-.RS
-.IP 1.
-Concurrent access and conflict-resolution algorithms to guarantee that
-source changes are not \*Qlost.\*U
-.IP 2.
-Support for tracking third-party vendor source distributions while
-maintaining the local modifications made to those sources.
-.IP 3.
-A flexible module database that provides a symbolic mapping of names to
-components of a larger software distribution.
-This symbolic mapping provides for location independence within the software
-release and, for example, allows one to check out a copy of the \*Qdiff\*U
-program without ever knowing that the sources to \*Qdiff\*U actually reside
-in the \*Qbin/diff\*U directory.
-.IP 4.
-Configurable logging support allows all \*Qcommitted\*U source file changes
-to be logged using an arbitrary program to save the log messages in a file,
-notesfile, or news database.
-.IP 5.
-A software release can be symbolically tagged and checked out at any time
-based on that tag.
-An exact copy of a previous software release can be checked out at
-any time, \fIregardless\fP of whether files or directories have been
-added/removed from the \*Qcurrent\*U software release.
-As well,
-a \*Qdate\*U can be used to check out the \fIexact\fP version of the software
-release as of the specified date.
-.IP 6.
-A \*Qpatch\*U format file [Wall] can be produced between two software
-releases, even if the releases span multiple directories.
-.RE
-.PP
-The sources maintained by \fBcvs\fP are kept within a single directory
-hierarchy known as the \*Qsource repository.\*U
-This \*Qsource repository\*U holds the actual
-.SM
-RCS
-.LG
-\*Q,v\*U files directly, as well as a special per-repository directory
-(\c
-.SM
-CVSROOT.adm\c
-.LG
-) which contains a small number of administrative files that describe the
-repository and how it can be accessed.
-See Figure 1 for a picture of the \fBcvs\fP tree.
-.KF
-.hl
-.DS B
-.PS
-line from 4.112,9.200 to 5.550,8.887
-line from 5.447,8.884 to 5.550,8.887 to 5.458,8.933
-line from 4.112,9.200 to 4.550,8.950
-line from 4.451,8.978 to 4.550,8.950 to 4.476,9.021
-line from 4.112,9.200 to 3.737,8.887
-line from 3.798,8.971 to 3.737,8.887 to 3.830,8.932
-line from 3.612,8.762 to 4.737,8.137
-line from 4.638,8.164 to 4.737,8.137 to 4.662,8.208
-line from 3.612,8.762 to 3.737,8.137
-line from 3.693,8.231 to 3.737,8.137 to 3.742,8.240
-line from 3.612,8.762 to 2.612,8.200
-line from 2.687,8.271 to 2.612,8.200 to 2.712,8.227
-line from 2.362,9.262 to 2.737,8.950
-line from 2.645,8.995 to 2.737,8.950 to 2.677,9.033
-line from 2.362,9.262 to 1.925,8.950
-line from 1.992,9.028 to 1.925,8.950 to 2.021,8.988
-line from 3.362,9.762 to 4.050,9.387
-line from 3.950,9.413 to 4.050,9.387 to 3.974,9.457
-line from 3.362,9.762 to 2.487,9.387
-line from 2.570,9.450 to 2.487,9.387 to 2.589,9.404
-.ps 11
-"newfs.c,v" at 4.487,8.043 ljust
-.ps 11
-"mkfs.c,v" at 3.487,8.043 ljust
-.ps 11
-"Makefile,v" at 2.237,8.043 ljust
-.ps 11
-"newfs" at 3.487,8.793 ljust
-.ps 11
-"halt.c,v" at 5.487,8.793 ljust
-.ps 11
-"Makefile,v" at 4.237,8.793 ljust
-.ps 11
-"modules,v" at 2.487,8.793 ljust
-.ps 11
-"loginfo,v" at 1.488,8.793 ljust
-.ps 11
-"etc" at 3.987,9.293 ljust
-.ps 11
-"CVSROOT.adm" at 1.988,9.293 ljust
-.ps 11
-"/src/master" at 2.987,9.793 ljust
-.PE
-.DE
-.hl
-.ce 100
-.LG
-\fBFigure 1.\fP
-.SM
-\fBcvs\fP Source Repository
-.ce 0
-.sp
-.KE
-.NH 2
-Software Conflict Resolution\**
-.FS
-The basic conflict-resolution algorithms
-used in the \fBcvs\fP program find their roots
-in the original work done by Dick Grune at Vrije Universiteit in Amsterdam
-and posted to \fBcomp.sources.unix\fP in the volume 6 release sometime in 1986.
-This original version of \fBcvs\fP was a collection of shell scripts that
-combined to form a front end to the
-.SM
-RCS
-.LG
-programs.
-.FE
-.PP
-\fBcvs\fP allows several software developers to edit personal copies of a
-revision controlled file concurrently.
-The revision number of each checked out file is maintained independently
-for each user, and \fBcvs\fP forces the checked out file to be current with
-the \*Qhead\*U revision before it can be \*Qcommitted\*U as a permanent change.
-A checked out file is brought up-to-date with the \*Qhead\*U revision using
-the \*Qupdate\*U command of \fBcvs\fP.
-This command compares the \*Qhead\*U revision number with that of the user's
-file and performs an
-.SM
-RCS
-.LG
-merge operation if they are not the same.
-The result of the merge is a file that contains the user's modifications
-and those modifications that were \*Qcommitted\*U after the user
-checked out his version of the file (as well as a backup copy of the
-user's original file).
-\fBcvs\fP points out any conflicts during the merge.
-It is the user's responsibility to resolve these conflicts
-and to \*Qcommit\*U his/her changes when ready.
-.PP
-Although the \fBcvs\fP conflict-resolution algorithm was defined in 1986,
-it is remarkably similar to the \*QCopy-Modify-Merge\*U scenario included
-with NSE\**
-.FS
-NSE is the Network Software Environment, a product of Sun Microsystems, Inc.
-.FE
-and described in [Honda] and [Courington].
-The following explanation from [Honda] also applies to \fBcvs\fP:
-.QP
-Simply stated, a developer copies an object without locking it, modifies
-the copy, and then merges the modified copy with the original.
-This paradigm allows developers to work in isolation from one another since
-changes are made to copies of objects.
-Because locks are not used, development is not serialized and can proceed
-in parallel.
-Developers, however, must merge objects after the changes have been made.
-In particular, a developer must resolve conflicts when the same object has
-been modified by someone else.
-.PP
-In practice, Prisma has found that conflicts that occur when the same
-object has been modified by someone else are quite rare.
-When they do happen, the changes made by the other developer are usually
-easily resolved.
-This practical use has shown that the \*QCopy-Modify-Merge\*U paradigm is a
-correct and useful one.
-.NH 2
-Tracking Third-Party Source Distributions
-.PP
-Currently, a large amount of software is based on source
-distributions from a third-party distributor.
-It is often the case that local modifications are to be made to this
-distribution, \fIand\fP that the vendor's future releases should be
-tracked.
-Rolling your local modifications forward into the new vendor release is a
-time-consuming task, but \fBcvs\fP can ease this burden somewhat.
-The \fBcheckin\fP program of \fBcvs\fP initially sets up a source
-repository by integrating the source modules directly from the vendor's
-release, preserving the directory hierarchy of the vendor's distribution.
-The branch support of
-.SM
-RCS
-.LG
-is used to build this vendor release as a branch of the main
-.SM
-RCS
-.LG
-trunk.
-Figure 2 shows how the \*Qhead\*U tracks a sample vendor
-branch when no local modifications have been made to the file.
-.KF
-.hl
-.DS B
-.PS
-ellipse at 3.237,6.763 wid 1.000 ht 0.500
-dashwid = 0.050i
-line dashed from 3.237,7.513 to 3.737,7.513 to 3.737,9.762 to 4.237,9.762
-line from 4.138,9.737 to 4.237,9.762 to 4.138,9.787
-line dashed from 2.237,8.262 to 3.237,8.262 to 3.237,7.013
-line from 3.212,7.112 to 3.237,7.013 to 3.262,7.112
-line from 3.737,6.763 to 4.237,6.763
-line from 4.138,6.737 to 4.237,6.763 to 4.138,6.788
-line from 2.237,6.763 to 2.737,6.763
-line from 2.637,6.737 to 2.737,6.763 to 2.637,6.788
-line from 1.738,6.013 to 1.738,6.513
-line from 1.762,6.413 to 1.738,6.513 to 1.713,6.413
-line from 1.238,7.013 to 2.237,7.013 to 2.237,6.513 to 1.238,6.513 to 1.238,7.013
-line from 4.237,9.012 to 5.237,9.012 to 5.237,8.512 to 4.237,8.512 to 4.237,9.012
-line from 4.237,8.012 to 5.237,8.012 to 5.237,7.513 to 4.237,7.513 to 4.237,8.012
-line from 4.237,7.013 to 5.237,7.013 to 5.237,6.513 to 4.237,6.513 to 4.237,7.013
-line from 4.737,7.013 to 4.737,7.513
-line from 4.763,7.413 to 4.737,7.513 to 4.712,7.413
-line from 4.737,8.012 to 4.737,8.512
-line from 4.763,8.412 to 4.737,8.512 to 4.712,8.412
-line from 4.237,10.012 to 5.237,10.012 to 5.237,9.512 to 4.237,9.512 to 4.237,10.012
-line from 4.737,9.012 to 4.737,9.512
-line from 4.763,9.412 to 4.737,9.512 to 4.712,9.412
-line from 5.987,5.013 to 5.987,6.013 to 0.988,6.013 to 0.988,5.013 to 5.987,5.013
-.ps 11
-"\"HEAD\"" at 1.550,8.231 ljust
-.ps 11
-"'SunOS'" at 2.987,6.293 ljust
-.ps 11
-"1.1.1" at 3.050,6.793 ljust
-.ps 11
-"1.1" at 1.613,6.793 ljust
-.ps 11
-"1.1.1.1" at 4.487,6.793 ljust
-.ps 11
-"1.1.1.2" at 4.487,7.793 ljust
-.ps 11
-"1.1.1.3" at 4.487,8.793 ljust
-.ps 11
-"1.1.1.4" at 4.487,9.793 ljust
-.ps 11
-"'SunOS_4_0'" at 5.487,6.793 ljust
-.ps 11
-"'SunOS_4_0_1'" at 5.487,7.793 ljust
-.ps 11
-"'YAPT_5_5C'" at 5.487,8.793 ljust
-.ps 11
-"'SunOS_4_0_3'" at 5.487,9.793 ljust
-.ps 11
-"rcsfile.c,v" at 2.987,5.543 ljust
-.PE
-.DE
-.hl
-.ce 100
-.LG
-\fBFigure 2.\fP
-.SM
-\fBcvs\fP Vendor Branch Example
-.ce 0
-.sp .3
-.KE
-Once this is done, developers can check out files and make local changes to
-the vendor's source distribution.
-These local changes form a new branch to the tree which is then used as the
-source for future check outs.
-Figure 3 shows how the \*Qhead\*U moves to the main
-.SM
-RCS
-.LG
-trunk when a local modification is made.
-.KF
-.hl
-.DS B
-.PS
-ellipse at 3.237,6.763 wid 1.000 ht 0.500
-dashwid = 0.050i
-line dashed from 2.800,9.075 to 1.738,9.075 to 1.738,8.012
-line from 1.713,8.112 to 1.738,8.012 to 1.762,8.112
-line from 1.738,7.013 to 1.738,7.513
-line from 1.762,7.413 to 1.738,7.513 to 1.713,7.413
-line from 1.238,8.012 to 2.237,8.012 to 2.237,7.513 to 1.238,7.513 to 1.238,8.012
-line from 3.737,6.763 to 4.237,6.763
-line from 4.138,6.737 to 4.237,6.763 to 4.138,6.788
-line from 2.237,6.763 to 2.737,6.763
-line from 2.637,6.737 to 2.737,6.763 to 2.637,6.788
-line from 1.738,6.013 to 1.738,6.513
-line from 1.762,6.413 to 1.738,6.513 to 1.713,6.413
-line from 1.238,7.013 to 2.237,7.013 to 2.237,6.513 to 1.238,6.513 to 1.238,7.013
-line from 4.237,9.012 to 5.237,9.012 to 5.237,8.512 to 4.237,8.512 to 4.237,9.012
-line from 4.237,8.012 to 5.237,8.012 to 5.237,7.513 to 4.237,7.513 to 4.237,8.012
-line from 4.237,7.013 to 5.237,7.013 to 5.237,6.513 to 4.237,6.513 to 4.237,7.013
-line from 4.737,7.013 to 4.737,7.513
-line from 4.763,7.413 to 4.737,7.513 to 4.712,7.413
-line from 4.737,8.012 to 4.737,8.512
-line from 4.763,8.412 to 4.737,8.512 to 4.712,8.412
-line from 4.237,10.012 to 5.237,10.012 to 5.237,9.512 to 4.237,9.512 to 4.237,10.012
-line from 4.737,9.012 to 4.737,9.512
-line from 4.763,9.412 to 4.737,9.512 to 4.712,9.412
-line from 5.987,5.013 to 5.987,6.013 to 0.988,6.013 to 0.988,5.013 to 5.987,5.013
-.ps 11
-"1.2" at 1.613,7.793 ljust
-.ps 11
-"\"HEAD\"" at 2.862,9.043 ljust
-.ps 11
-"'SunOS'" at 2.987,6.293 ljust
-.ps 11
-"1.1.1" at 3.050,6.793 ljust
-.ps 11
-"1.1" at 1.613,6.793 ljust
-.ps 11
-"1.1.1.1" at 4.487,6.793 ljust
-.ps 11
-"1.1.1.2" at 4.487,7.793 ljust
-.ps 11
-"1.1.1.3" at 4.487,8.793 ljust
-.ps 11
-"1.1.1.4" at 4.487,9.793 ljust
-.ps 11
-"'SunOS_4_0'" at 5.487,6.793 ljust
-.ps 11
-"'SunOS_4_0_1'" at 5.487,7.793 ljust
-.ps 11
-"'YAPT_5_5C'" at 5.487,8.793 ljust
-.ps 11
-"'SunOS_4_0_3'" at 5.487,9.793 ljust
-.ps 11
-"rcsfile.c,v" at 2.987,5.543 ljust
-.PE
-.DE
-.hl
-.ce 100
-.LG
-\fBFigure 3.\fP
-.SM
-\fBcvs\fP Local Modification to Vendor Branch
-.ce 0
-.sp
-.KE
-.PP
-When a new version of the vendor's source distribution arrives, the
-\fBcheckin\fP program adds the new and changed vendor's files to the
-already existing source repository.
-For files that have not been changed locally, the new file from the
-vendor becomes the current \*Qhead\*U revision.
-For files that have been modified locally, \fBcheckin\fP warns that the
-file must be merged with the new vendor release.
-The \fBcvs\fP \*Qjoin\*U command is a useful tool that aids this process by
-performing the necessary
-.SM
-RCS
-.LG
-merge, as is done above when performing an \*Qupdate.\*U
-.PP
-There is also limited support for \*Qdual\*U derivations for source files.
-See Figure 4 for a sample dual-derived file.
-.KF
-.hl
-.DS B
-.PS
-ellipse at 2.337,8.575 wid 0.700 ht 0.375
-ellipse at 2.312,9.137 wid 0.700 ht 0.375
-line from 1.225,9.012 to 1.225,9.363
-line from 1.250,9.263 to 1.225,9.363 to 1.200,9.263
-line from 0.875,9.725 to 1.600,9.725 to 1.600,9.363 to 0.875,9.363 to 0.875,9.725
-line from 0.875,9.012 to 1.600,9.012 to 1.600,8.650 to 0.875,8.650 to 0.875,9.012
-line from 4.050,10.200 to 4.775,10.200 to 4.775,9.850 to 4.050,9.850 to 4.050,10.200
-line from 4.050,9.475 to 4.775,9.475 to 4.775,9.113 to 4.050,9.113 to 4.050,9.475
-line from 4.050,8.762 to 4.775,8.762 to 4.775,8.400 to 4.050,8.400 to 4.050,8.762
-line from 4.425,8.762 to 4.425,9.113
-line from 4.450,9.013 to 4.425,9.113 to 4.400,9.013
-line from 4.425,9.475 to 4.425,9.850
-line from 4.450,9.750 to 4.425,9.850 to 4.400,9.750
-line from 3.050,10.000 to 3.775,10.000 to 3.775,9.637 to 3.050,9.637 to 3.050,10.000
-line from 3.050,9.312 to 3.775,9.312 to 3.775,8.950 to 3.050,8.950 to 3.050,9.312
-line from 0.713,7.325 to 0.713,8.075 to 4.925,8.075 to 4.925,7.325 to 0.713,7.325
-line from 1.238,8.075 to 1.238,8.637
-line from 1.262,8.537 to 1.238,8.637 to 1.213,8.537
-line from 1.613,8.825 to 1.975,8.575
-line from 1.878,8.611 to 1.975,8.575 to 1.907,8.652
-line from 2.675,8.575 to 4.050,8.575
-line from 3.950,8.550 to 4.050,8.575 to 3.950,8.600
-line from 2.675,9.137 to 3.050,9.137
-line from 2.950,9.112 to 3.050,9.137 to 2.950,9.162
-line from 3.425,9.325 to 3.425,9.637
-line from 3.450,9.537 to 3.425,9.637 to 3.400,9.537
-line from 1.613,8.825 to 1.925,9.137
-line from 1.872,9.049 to 1.925,9.137 to 1.837,9.084
-.ps 11
-"'BSD'" at 2.138,9.481 ljust
-.ps 11
-"1.2" at 1.113,9.543 ljust
-.ps 11
-"1.1" at 1.125,8.831 ljust
-.ps 11
-"1.1.1.1" at 4.175,8.543 ljust
-.ps 11
-"1.1.1.2" at 4.175,9.281 ljust
-.ps 11
-"1.1.1.3" at 4.175,9.993 ljust
-.ps 11
-"1.1.2.2" at 3.175,9.793 ljust
-.ps 11
-"1.1.2.1" at 3.175,9.106 ljust
-.ps 11
-"rcsfile.c,v" at 2.425,7.706 ljust
-.ps 11
-"1.1.1" at 2.175,8.568 ljust
-.ps 11
-"'SunOS'" at 2.125,8.243 ljust
-.ps 11
-"1.1.2" at 2.163,9.131 ljust
-.PE
-.DE
-.hl
-.ce 100
-.LG
-\fBFigure 4.\fP
-.SM
-\fBcvs\fP Support For \*QDual\*U Derivations
-.ce 0
-.sp
-.KE
-This example tracks the SunOS distribution but includes major changes from
-Berkeley.
-These BSD files are saved directly in the
-.SM
-RCS
-.LG
-file off a new branch.
-.NH 2
-Location Independent Module Database
-.PP
-\fBcvs\fP contains support for a simple, yet powerful, \*Qmodule\*U database.
-For reasons of efficiency, this database is stored in \fBndbm\fP\|(3) format.
-The module database is used to apply names to collections of directories
-and files as a matter of convenience for checking out pieces of a large
-software distribution.
-The database records the physical location of the sources as a form of
-information hiding, allowing one to check out whole directory hierarchies
-or individual files without regard for their actual location within the
-global source distribution.
-.PP
-Consider the following small sample of a module database, which must be
-tailored manually to each specific source repository environment:
-.DS
-\f(CW #key [-option argument] directory [files...]
- diff bin/diff
- libc lib/libc
- sys -o sys/tools/make_links sys
- modules -i mkmodules CVSROOT.adm modules
- kernel -a sys lang/adb
- ps bin Makefile ps.c\fP
-.DE
-.PP
-The \*Qdiff\*U and \*Qlibc\*U modules refer to whole directory hierarchies that
-are extracted on check out.
-The \*Qsys\*U module extracts the \*Qsys\*U hierarchy, and runs the
-\*Qmake_links\*U program at the end of the check out process (the \fI-o\fP
-option specifies a program to run on check\fIo\fPut).
-The \*Qmodules\*U module allows one to edit the module database file and
-runs the \*Qmkmodules\*U program on check\fIi\fPn to regenerate the
-\fBndbm\fP database that \fBcvs\fP uses.
-The \*Qkernel\*U module is an alias (as the \fI-a\fP option specifies)
-which causes the remaining arguments after the \fI-a\fP to be interpreted
-exactly as if they had been specified on the command line.
-This is useful for objects that require shared pieces of code from far away
-places to be compiled (as is the case with the kernel debugger, \fBkadb\fP,
-which shares code with the standard \fBadb\fP debugger).
-The \*Qps\*U module shows that the source for \*Qps\*U lives in the \*Qbin\*U
-directory, but only \fIMakefile\fP and \fIps.c\fP are required to build the
-object.
-.PP
-The module database at Prisma is now populated for the entire UNIX
-distribution and thereby allows us to issue the
-following convenient commands to check out components of the UNIX
-distribution without regard for their actual location within the master source
-repository:
-.DS
-\f(CW example% cvs checkout diff
- example% cvs checkout libc ps
- example% cd diff; make\fP
-.DE
-.PP
-In building the module database file, it is quite possible to have name
-conflicts within a global software distribution.
-For example, SunOS provides two \fBcat\fP programs:
-one for the standard environment, \fI/bin/cat\fP, and one for the System V
-environment, \fI/usr/5bin/cat\fP.
-We resolved this conflict by naming the standard \fBcat\fP module
-\*Qcat\*U, and the System V \fBcat\fP module \*Q5cat\*U.
-Similar name modifications must be applied to other conflicting names, as
-might be found between a utility program and a library function, though
-Prisma chose not to include individual library functions within the module
-database at this time.
-.NH 2
-Configurable Logging Support
-.PP
-The \fBcvs\fP \*Qcommit\*U command is used to make a permanent change to the
-master source repository (where the
-.SM
-RCS
-.LG
-\*Q,v\*U files live).
-Whenever a \*Qcommit\*U is done, the log message for the change is carefully
-logged by an arbitrary program (in a file, notesfile, news database, or
-mail).
-For example, a collection of these updates can be used to produce release
-notices.
-\fBcvs\fP can be configured to send log updates through one or more filter
-programs, based on a regular expression match on the directory that is
-being changed.
-This allows multiple related or unrelated projects to exist within a single
-\fBcvs\fP source repository tree, with each different project sending its
-\*Qcommit\*U reports to a unique log device.
-.PP
-A sample logging configuration file might look as follows:
-.DS
-\f(CW #regex filter-program
- DEFAULT /usr/local/bin/nfpipe -t %s utils.updates
- ^diag /usr/local/bin/nfpipe -t %s diag.updates
- ^local /usr/local/bin/nfpipe -t %s local.updates
- ^perf /usr/local/bin/nfpipe -t %s perf.updates
- ^sys /usr/local/bin/nfpipe -t %s kernel.updates\fP
-.DE
-.PP
-This sample allows the diagnostics and performance groups to
-share the same source repository with the kernel and utilities groups.
-Changes that they make are sent directly to their own notesfile [Essick]
-through the \*Qnfpipe\*U program.
-A sufficiently simple title is substituted for the \*Q%s\*U argument before
-the filter program is executed.
-This logging configuration file is tailored manually to each specific
-source repository environment.
-.NH 2
-Tagged Releases and Dates
-.PP
-Any release can be given a symbolic tag name that is stored directly in the
-.SM
-RCS
-.LG
-files.
-This tag can be used at any time to get an exact copy of any previous
-release.
-With equal ease, one can also extract an exact copy of the source files as
-of any arbitrary date in the past as well.
-Thus, all that's required to tag the current kernel, and to tag the kernel
-as of the Fourth of July is:
-.DS
-\f(CW example% cvs tag TEST_KERNEL kernel
- example% cvs tag -D 'July 4' PATRIOTIC_KERNEL kernel\fP
-.DE
-The following command would retrieve an exact copy of the test kernel at
-some later date:
-.DS
-\f(CW example% cvs checkout -fp -rTEST_KERNEL kernel\fP
-.DE
-The \fI-f\fP option causes only files that match the specified tag to be
-extracted, while the \fI-p\fP option automatically prunes empty directories.
-Consequently, directories added to the kernel after the test kernel was
-tagged are not included in the newly extracted copy of the test kernel.
-.PP
-The \fBcvs\fP date support has exactly the same interface as that provided
-with
-.SM
-RCS\c
-.LG
-, however \fBcvs\fP must process the \*Q,v\*U files directly due to the
-special handling required by the vendor branch support.
-The standard
-.SM
-RCS
-.LG
-date handling only processes one branch (or the main trunk) when checking
-out based on a date specification.
-\fBcvs\fP must instead process the current \*Qhead\*U branch and, if a
-match is not found, proceed to look for a match on the vendor branch.
-This, combined with reasons of performance, is why \fBcvs\fP processes
-revision (symbolic and numeric) and date specifications directly from the
-\*Q,v\*U files.
-.NH 2
-Building \*Qpatch\*U Source Distributions
-.PP
-\fBcvs\fP can produce a \*Qpatch\*U format [Wall] output file which can be
-used to bring a previously released software distribution current with the
-newest release.
-This patch file supports an entire directory hierarchy within a single
-patch, as well as being able to add whole new files to the previous
-release.
-One can combine symbolic revisions and dates together to display changes in
-a very generic way:
-.DS
-\f(CW example% cvs patch -D 'December 1, 1988' \e
- -D 'January 1, 1989' sys\fP
-.DE
-This example displays the kernel changes made in the month of December,
-1988.
-To release a patch file, for example, to take the \fBcvs\fP distribution
-from version 1.0 to version 1.4 might be done as follows:
-.DS
-\f(CW example% cvs patch -rCVS_1_0 -rCVS_1_4 cvs\fP
-.DE
-.NH
-CVS Experience
-.NH 2
-Statistics
-.PP
-A quick summary of the scale that \fBcvs\fP is addressing today
-can be found in Table 1.
-.KF
-.TS
-box center tab(:);
-c s
-c s
-c | c
-l | n .
-\fB\s+2Revision Control Statistics at Prisma
-as of 11/11/89\fP\s-2
-_
-How Many...:Total
-=
-Files:17243
-Directories:1005
-Lines of code:3927255
-Removed files:131
-Software developers:14
-Software groups:6
-Megabytes of source:128
-.TE
-.ce 100
-.LG
-\fBTable 1.\fP
-.SM
-\fBcvs\fP Statistics
-.ce 0
-.sp .3
-.KE
-Table 2 shows the history of files changed or added and the number
-of source lines affected by the change at Prisma.
-Only changes made to the kernel sources are included.
-.KF
-.TS
-box center tab(:);
-c s s s s
-c s s s s
-c || c | c || c | c
-c || c | c || c | c
-l || n | n || n | n.
-\fB\s+2Prisma Kernel Source File Changes
-By Month, 1988-1989\fP\s-2
-_
-Month:# Changed:# Lines:# Added:# Lines
-\^:Files:Changed:Files:Added
-=
-Dec:87:3619:68:9266
-Jan:39:4324:0:0
-Feb:73:1578:5:3550
-Mar:99:5301:18:11461
-Apr:112:7333:11:5759
-May:138:5371:17:13986
-Jun:65:2261:27:12875
-Jul:34:2000:1:58
-Aug:65:6378:8:4724
-Sep:266:23410:113:39965
-Oct:22:621:1:155
-Total:1000:62196:269:101799
-.TE
-.ce 100
-.LG
-\fBTable 2.\fP
-.SM
-\fBcvs\fP Usage History for the Kernel
-.ce 0
-.sp
-.KE
-The large number of source file changes made in September are the result of
-merging the SunOS 4.0.3 sources into the kernel.
-This merge process is described in section 3.3.
-.NH 2
-Performance
-.PP
-The performance of \fBcvs\fP is currently quite reasonable.
-Little effort has been expended on tuning \fBcvs\fP, although performance
-related decisions were made during the \fBcvs\fP design.
-For example, \fBcvs\fP parses the
-.SM
-RCS
-.LG
-\*Q,v\*U files directly instead of running an
-.SM
-RCS
-.LG
-process.
-This includes following branches as well as integrating with the vendor
-source branches and the main trunk when checking out files based on a date.
-.PP
-Checking out the entire kernel source tree (1223 files/59 directories)
-currently takes 16 wall clock minutes on a Sun-4/280.
-However, bringing the tree up-to-date with the current kernel sources, once
-it has been checked out, takes only 1.5 wall clock minutes.
-Updating the \fIcomplete\fP 128 MByte source tree under \fBcvs\fP control
-(17243 files/1005 directories) takes roughly 28 wall clock minutes and
-utilizes one-third of the machine.
-For now this is entirely acceptable; improvements on these numbers will
-possibly be made in the future.
-.NH 2
-The SunOS 4.0.3 Merge
-.PP
-The true test of the \fBcvs\fP vendor branch support came with the arrival
-of the SunOS 4.0.3 source upgrade tape.
-As described above, the \fBcheckin\fP program was used to install the new
-sources and the resulting output file listed the files that had been
-locally modified, needing to be merged manually.
-For the kernel, there were 94 files in conflict.
-The \fBcvs\fP \*Qjoin\*U command was used on each of the 94 conflicting
-files, and the remaining conflicts were resolved.
-.PP
-The \*Qjoin\*U command performs an \fBrcsmerge\fP operation.
-This in turn uses \fI/usr/lib/diff3\fP to produce a three-way diff file.
-As it happens, the \fBdiff3\fP program has a hard-coded limit of 200
-source-file changes maximum.
-This proved to be too small for a few of the kernel files that needed
-merging by hand, due to the large number of local changes that Prisma had
-made.
-The \fBdiff3\fP problem was solved by increasing the hard-coded limit by an
-order of magnitude.
-.PP
-The SunOS 4.0.3 kernel source upgrade distribution contained
-346 files, 233 of which were modifications to previously released files,
-and 113 of which were newly added files.
-\fBcheckin\fP added the 113 new files to the source repository
-without intervention.
-Of the 233 modified files, 139 dropped in cleanly by \fBcheckin\fP, since
-Prisma had not made any local changes to them, and 94 required manual
-merging due to local modifications.
-The 233 modified files consisted of 20,766 lines of differences.
-It took one developer two days to manually merge the 94 files using the
-\*Qjoin\*U command and resolving conflicts manually.
-An additional day was required for kernel debugging.
-The entire process of merging over 20,000 lines of differences was
-completed in less than a week.
-This one time-savings alone was justification enough for the \fBcvs\fP
-development effort; we expect to gain even more when tracking future SunOS
-releases.
-.NH
-Future Enhancements and Current Bugs
-.PP
-Since \fBcvs\fP was designed to be incomplete, for reasons of design
-simplicity, there are naturally a good
-number of enhancements that can be made to make it more useful.
-As well, some nuisances exist in the current implementation.
-.RS
-.IP \(bu 3
-\fBcvs\fP does not currently \*Qremember\*U who has a checked out a copy of a
-module.
-As a result, it is impossible to know who might be working on the same
-module that you are.
-A simple-minded database that is updated nightly would likely suffice.
-.IP \(bu 3
-Signal processing, keyboard interrupt handling in particular, is currently
-somewhat weak.
-This is due to the heavy use of the \fBsystem\fP\|(3) library
-function to execute
-.SM
-RCS
-.LG
-programs like \fBco\fP and \fBci\fP.
-It sometimes takes multiple interrupts to make \fBcvs\fP quit.
-This can be fixed by using a home-grown \fBsystem\fP\|() replacement.
-.IP \(bu 3
-Security of the source repository is currently not dealt with directly.
-The usual UNIX approach of user-group-other security permissions through
-the file system is utilized, but nothing else.
-\fBcvs\fP could likely be a set-group-id executable that checks a
-protected database to verify user access permissions for particular objects
-before allowing any operations to affect those objects.
-.IP \(bu 3
-With every checked-out directory, \fBcvs\fP maintains some administrative
-files that record the current revision numbers of the checked-out files as
-well as the location of the respective source repository.
-\fBcvs\fP does not recover nicely at all if these administrative files are
-removed.
-.IP \(bu 3
-The source code for \fBcvs\fP has been tested extensively on Sun-3 and
-Sun-4 systems, all running SunOS 4.0 or later versions of the operating
-system.
-Since the code has not yet been compiled under other platforms, the overall
-portability of the code is still questionable.
-.IP \(bu 3
-As witnessed in the previous section, the \fBcvs\fP method for tracking
-third party vendor source distributions can work quite nicely.
-However, if the vendor changes the directory structure or the file names
-within the source distribution, \fBcvs\fP has no way of matching the old
-release with the new one.
-It is currently unclear as to how to solve this, though it is certain to
-happen in practice.
-.RE
-.NH
-Availability
-.PP
-The \fBcvs\fP program sources can be found in a recent posting to the
-\fBcomp.sources.unix\fP newsgroup.
-It is also currently available via anonymous ftp from \*Qprisma.com\*U.
-Copying rights for \fBcvs\fP will be covered by the GNU General Public
-License.
-.NH
-Summary
-.PP
-Prisma has used \fBcvs\fP since December, 1988.
-It has evolved to meet our specific needs of revision and release control.
-We will make our code freely available so that others can
-benefit from our work, and can enhance \fBcvs\fP to meet broader needs yet.
-.PP
-Many of the other software release and revision control systems, like the
-one described in [Glew], appear to use a collection of tools that are
-geared toward specific environments \(em one set of tools for the kernel,
-one set for \*Qgeneric\*U software, one set for utilities, and one set for
-kernel and utilities.
-Each of these tool sets apparently handle some specific aspect of the
-problem uniquely.
-\fBcvs\fP took a somewhat different approach.
-File sharing through symbolic or hard links is not addressed; instead, the
-disk space is simply burned since it is \*Qcheap.\*U
-Support for producing objects for multiple architectures is not addressed;
-instead, a parallel checked-out source tree must be used for each
-architecture, again wasting disk space to simplify complexity and ease of
-use \(em punting on this issue allowed \fIMakefile\fPs to remain
-unchanged, unlike the approach taken in [Mahler], thereby maintaining closer
-compatibility with the third-party vendor sources.
-\fBcvs\fP is essentially a source-file server, making no assumptions or
-special handling of the sources that it controls.
-To \fBcvs\fP:
-.QP
-A source is a source, of course, of course, unless of course the source is
-Mr. Ed.\**
-.FS
-\fBcvs\fP, of course, does not really discriminate against Mr. Ed.\**
-.FE
-.FS
-Yet.
-.FE
-.LP
-Sources are maintained, saved, and retrievable at any time based on
-symbolic or numeric revision or date in the past.
-It is entirely up to \fBcvs\fP wrapper programs to provide for release
-environments and such.
-.PP
-The major advantage of \fBcvs\fP over the
-many other similar systems that have already been designed is the
-simplicity of \fBcvs\fP.
-\fBcvs\fP contains only three programs that do all the work of release
-and revision control, and two manually-maintained administrative
-files for each source repository.
-Of course, the deciding factor of any tool is whether people use it, and if
-they even \fIlike\fP to use it.
-At Prisma, \fBcvs\fP prevented members of the kernel
-group from killing each other.
-.NH
-Acknowledgements
-.PP
-Many thanks to Dick Grune at Vrije Universiteit in Amsterdam for his work
-on the original version of \fBcvs\fP and for making it available to the
-world.
-Thanks to Jeff Polk of Prisma for helping with the design of the module
-database, vendor branch support, and for writing the \fBcheckin\fP shell
-script.
-Thanks also to the entire software group at Prisma for taking the
-time to review the paper and correct my grammar.
-.NH
-References
-.IP [Bell] 12
-Bell Telephone Laboratories.
-\*QSource Code Control System User's Guide.\*U
-\fIUNIX System III Programmer's Manual\fP, October 1981.
-.IP [Courington] 12
-Courington, W.
-\fIThe Network Software Environment\fP,
-Sun Technical Report FE197-0, Sun Microsystems Inc, February 1989.
-.IP [Essick] 12
-Essick, Raymond B. and Robert Bruce Kolstad.
-\fINotesfile Reference Manual\fP,
-Department of Computer Science Technical Report #1081,
-University of Illinois at Urbana-Champaign, Urbana, Illinois,
-1982, p. 26.
-.IP [Glew] 12
-Glew, Andy.
-\*QBoxes, Links, and Parallel Trees:
-Elements of a Configuration Management System.\*U
-\fIWorkshop Proceedings of the Software Management Conference\fP, USENIX,
-New Orleans, April 1989.
-.IP [Grune] 12
-Grune, Dick.
-Distributed the original shell script version of \fBcvs\fP in the
-\fBcomp.sources.unix\fP volume 6 release in 1986.
-.IP [Honda] 12
-Honda, Masahiro and Terrence Miller.
-\*QSoftware Management Using a CASE Environment.\*U
-\fIWorkshop Proceedings of the Software Management Conference\fP, USENIX,
-New Orleans, April 1989.
-.IP [Mahler] 12
-Mahler, Alex and Andreas Lampen.
-\*QAn Integrated Toolset for Engineering Software Configurations.\*U
-\fIProceedings of the ACM SIGSOFT/SIGPLAN Software Engineering Symposium on
-Practical Software Development Environments\fP, ACM, Boston, November 1988.
-Described is the \fBshape\fP toolkit posted to the
-\fBcomp.sources.unix\fP newsgroup in the volume 19 release.
-.IP [Tichy] 12
-Tichy, Walter F.
-\*QDesign, Implementation, and Evaluation of a Revision Control System.\*U
-\fIProceedings of the 6th International Conference on Software
-Engineering\fP, IEEE, Tokyo, September 1982.
-.IP [Wall] 12
-Wall, Larry.
-The \fBpatch\fP program is an indispensable tool for applying a diff file
-to an original.
-Can be found on uunet.uu.net in ~ftp/pub/patch.tar.
diff --git a/gnu/usr.bin/cvs/examples/commitinfo b/gnu/usr.bin/cvs/examples/commitinfo
deleted file mode 100644
index bdb94b6..0000000
--- a/gnu/usr.bin/cvs/examples/commitinfo
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# commitinfo,v 1.2 1992/03/31 04:19:47 berliner Exp
-#
-# The "commitinfo" file is used to control pre-commit checks.
-# The filter on the right is invoked with the repository and a list
-# of files to check. A non-zero exit of the filter program will
-# cause the commit to be aborted.
-#
-# The first entry on a line is a regular expression which is tested
-# against the directory that the change is being committed to, relative to the
-# $CVSROOT. If a match is found, then the remainder of the line is the
-# name of the filter to run.
-#
-# If the repository name does not match any of the regular expressions in this
-# file, the "DEFAULT" line is used, if it is specified.
-#
-# If the name ALL appears as a regular expression it is always used
-# in addition to the first matching regex or DEFAULT.
-#
-^cvs checkforcvsid
-DEFAULT checkforid
diff --git a/gnu/usr.bin/cvs/examples/editinfo b/gnu/usr.bin/cvs/examples/editinfo
deleted file mode 100644
index b454abd..0000000
--- a/gnu/usr.bin/cvs/examples/editinfo
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# editinfo,v 1.1 1992/03/21 06:49:39 berliner Exp
-#
-# The "editinfo" file is used to allow verification of logging
-# information. It works best when a template (as specified in the
-# rcsinfo file) is provided for the logging procedure. Given a
-# template with locations for, a bug-id number, a list of people who
-# reviewed the code before it can be checked in, and an external
-# process to catalog the differences that were code reviewed, the
-# following test can be applied to the code:
-#
-# Making sure that the entered bug-id number is correct.
-# Validating that the code that was reviewed is indeed the code being
-# checked in (using the bug-id number or a seperate review
-# number to identify this particular code set.).
-#
-# If any of the above test failed, then the commit would be aborted.
-#
-# Actions such as mailing a copy of the report to each reviewer are
-# better handled by an entry in the loginfo file.
-#
-# Although these test could be handled by an interactive script being
-# called via an entry in commitinfo, The information reported in
-# such a script can't be easily merged into the report.
-#
-# One thing that should be noted is the the ALL keyword is not
-# supported. There can be only one entry that matches a given
-# repository.
-#
-DEFAULT $CVSROOT/CVSROOT/edit "%s"
diff --git a/gnu/usr.bin/cvs/examples/loginfo b/gnu/usr.bin/cvs/examples/loginfo
deleted file mode 100644
index 6339439..0000000
--- a/gnu/usr.bin/cvs/examples/loginfo
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# @(#)loginfo 1.5 92/03/31
-#
-# The "loginfo" file is used to control where "cvs commit" log information
-# is sent. The first entry on a line is a regular expression which is tested
-# against the directory that the change is being made to, relative to the
-# $CVSROOT. If a match is found, then the remainder of the line is a filter
-# program that should expect log information on its standard input.
-#
-# The filter program may use one and only one % modifier (ala printf). If
-# %s is specified in the filter program, a brief title is included (enclosed
-# in single quotes) showing the modified file names.
-#
-# If the repository name does not match any of the regular expressions in this
-# file, the "DEFAULT" line is used, if it is specified.
-#
-# If the name ALL appears as a regular expression it is always used
-# in addition to the first matching regex or DEFAULT.
-#
-DEFAULT $CVSROOT/CVSROOT/log.pl %s $CVSROOT/CVSROOT/commitlog
diff --git a/gnu/usr.bin/cvs/examples/modules b/gnu/usr.bin/cvs/examples/modules
deleted file mode 100644
index 893b47b..0000000
--- a/gnu/usr.bin/cvs/examples/modules
+++ /dev/null
@@ -1,566 +0,0 @@
-#
-# CVS Modules file for Prisma sources
-# @(#)modules 1.5 92/03/31
-#
-# Three different line formats are valid:
-# key -a aliases...
-# key [options] directory
-# key [options] directory files...
-#
-# Where "options" are composed of:
-# -i prog Run "prog" on "cvs commit" from top-level of module.
-# -o prog Run "prog" on "cvs checkout" of module.
-# -t prog Run "prog" on "cvs rtag" of module.
-# -u prog Run "prog" on "cvs update" of module.
-# -d dir Place module in directory "dir" instead of module name.
-# -l Top-level directory only -- do not recurse.
-#
-# And "directory" is a path to a directory relative to $CVSROOT.
-#
-# The "-a" option specifies an alias. An alias is interpreted as if
-# everything on the right of the "-a" had been typed on the command line.
-#
-# You can encode a module within a module by using the special '&'
-# character to interpose another module into the current module. This
-# can be useful for creating a module that consists of many directories
-# spread out over the entire source repository.
-#
-
-# Convenient aliases
-world -a .
-kernel -a sys lang/adb sparcsim
-
-# CVSROOT support
-CVSROOT -i /usr/local/bin/mkmodules CVSROOT
-modules -i /usr/local/bin/mkmodules CVSROOT modules
-loginfo -i /usr/local/bin/mkmodules CVSROOT loginfo
-commitinfo -i /usr/local/bin/mkmodules CVSROOT commitinfo
-rcsinfo -i /usr/local/bin/mkmodules CVSROOT rcsinfo
-
-# The "sys" entry exists only to make symbolic links after checkout
-sys -o sys/tools/make_links sys
-
-# Sub-directories of "bin"
-awk bin/awk
-csh bin/csh
-diff bin/diff
-make bin/make
-sed bin/sed
-sh bin/sh
-
-# Programs that live in "bin"
-cat bin Makefile cat.c
-chgrp bin Makefile chgrp.c
-chmod bin Makefile chmod.c
-cmp bin Makefile cmp.c
-cp bin Makefile cp.c
-date bin Makefile date.c
-dd bin Makefile dd.c
-df bin Makefile df.c
-domainname bin Makefile domainname.c
-du bin Makefile du.c
-echo bin Makefile echo.c
-ed bin Makefile ed.c
-env bin Makefile env.c
-expr bin Makefile expr.c
-grep bin Makefile grep.c
-hostid bin Makefile hostid.c
-hostname bin Makefile hostname.c
-kill bin Makefile kill.c
-ldd bin Makefile ldd.c
-line bin Makefile line.c
-ln bin Makefile ln.c
-login bin Makefile login.c
-ls bin Makefile ls.c
-mail bin Makefile mail.c
-mkdir bin Makefile mkdir.c
-mt bin Makefile mt.c
-mv bin Makefile mv.c
-newgrp bin Makefile newgrp.c
-nice bin Makefile nice.c
-od bin Makefile od.c
-pagesize bin Makefile pagesize.c
-passwd bin Makefile passwd.c
-pr bin Makefile pr.c
-ps bin Makefile ps.c
-pwd bin Makefile pwd.c
-rm bin Makefile rm.c
-rmail bin Makefile rmail.c
-rmdir bin Makefile rmdir.c
-stty bin Makefile stty.c
-su bin Makefile su.c
-sync bin Makefile sync.c
-tar bin Makefile tar.c
-tee bin Makefile tee.c
-test bin Makefile test.c
-time bin Makefile time.c
-wall bin Makefile wall.c
-who bin Makefile who.c
-write bin Makefile write.c
-
-# Sub-directories of "etc"
-dump etc/dump
-files etc/files
-fsck etc/fsck
-getty etc/getty
-in.routed etc/in.routed
-restore etc/restore
-rpc.lockd etc/rpc.lockd
-rpc.statd etc/rpc.statd
-
-# Programs that live in "etc"
-arp etc Makefile arp.c
-biod etc Makefile biod.c
-chown etc Makefile chown.c
-clri etc Makefile clri.c
-dkinfo etc Makefile dkinfo.c
-dmesg etc Makefile dmesg.c
-fsirand etc Makefile fsirand.c
-halt etc Makefile halt.c
-ifconfig etc Makefile ifconfig.c
-in.rlogind etc Makefile in.rlogind.c
-in.rshd etc Makefile in.rshd.c
-inetd etc Makefile inetd.c
-init etc Makefile init.c
-mkfs etc Makefile mkfs.c
-mknod etc Makefile mknod.c
-mount etc Makefile mount.c
-newfs etc Makefile newfs.c
-nfsd etc Makefile nfsd.c
-portmap etc Makefile portmap.c
-pstat etc Makefile pstat.c
-reboot etc Makefile reboot.c
-renice etc Makefile renice.c
-rmt etc Makefile rmt.c
-shutdown etc Makefile shutdown.c
-syslogd etc Makefile syslogd.c
-umount etc Makefile umount.c
-update etc Makefile update.c
-vipw etc Makefile vipw.c
-ypbind etc Makefile ypbind.c
-
-# Sub-directories of "games"
-adventure games/adventure
-backgammon games/backgammon
-battlestar games/battlestar
-boggle games/boggle
-chess games/chess
-ching games/ching
-cribbage games/cribbage
-fortune games/fortune
-hack games/hack
-hangman games/hangman
-hunt games/hunt
-life games/life
-mille games/mille
-monop games/monop
-quiz games/quiz
-robots games/robots
-sail games/sail
-snake games/snake
-trek games/trek
-
-# Programs that live in "games"
-arithmetic games Makefile arithmetic.c
-banner games Makefile banner.c
-bcd games Makefile bcd.c
-bj games Makefile bj.c
-btlgammon games Makefile btlgammon.c
-canfield games Makefile canfield.c
-cfscores games Makefile cfscores.c
-craps games Makefile craps.c
-factor games Makefile factor.c
-fish games Makefile fish.c
-moo games Makefile moo.c
-number games Makefile number.c
-primes games Makefile primes.c
-rain games Makefile rain.c
-random games Makefile random.c
-worm games Makefile worm.c
-worms games Makefile worms.c
-wump games Makefile wump.c
-
-# Sub-directories of "lang"
-adb lang/adb
-as lang/as
-boot lang/boot
-c2 lang/c2
-cgrdr lang/cgrdr
-compile lang/compile
-cpp lang/cpp
-dbx lang/dbx
-f77 lang/f77
-inline lang/inline
-iropt lang/iropt
-ld lang/ld
-lint lang/lint
-m4 lang/m4
-pascal lang/pascal
-pcc lang/pcc
-ratfor lang/ratfor
-rtld lang/rtld
-tcov lang/tcov
-vroot lang/vroot
-
-# Programs that live in "lang"
-ar lang Makefile ar.c
-nm lang Makefile nm.c
-ranlib lang Makefile ranlib.c
-size lang Makefile size.c
-strip lang Makefile strip.c
-symorder lang Makefile symorder.c
-
-# Sub-directories of "lib"
-csu lib/csu
-libc lib/libc
-
-# Programs that live in "lib"
-# NONE
-
-# Sub-directories of "lib/libc"
-libc_compat lib/libc/compat
-libc_crt lib/libc/crt
-libc_des lib/libc/des
-libc_gen lib/libc/gen
-libc_net lib/libc/net
-libc_inet lib/libc/inet
-libc_rpc lib/libc/rpc
-libc_stdio lib/libc/stdio
-libc_sun lib/libc/sun
-libc_sys lib/libc/sys
-libc_yp lib/libc/yp
-
-# Programs that live in "lib/libc"
-# NONE
-
-#Sub-directories of "local"
-notes local/notes
-
-# Sub-directories of "man"
-man1 man/man1
-man2 man/man2
-man3 man/man3
-man4 man/man4
-man5 man/man5
-man6 man/man6
-man7 man/man7
-man8 man/man8
-manl man/manl
-
-# Programs that live in "man"
-# NONE
-
-# Sub-directories of "old"
-old_compact old/compact
-old_eyacc old/eyacc
-old_filemerge old/filemerge
-old_make old/make
-
-# Programs that live in "old"
-old_analyze old Makefile analyze.c
-old_prmail old Makefile prmail.c
-old_pti old Makefile pti.c
-old_syslog old Makefile syslog.c
-
-# Sub-directories of "ucb"
-Mail ucb/Mail
-compress ucb/compress
-error ucb/error
-ex ucb/ex
-ftp ucb/ftp
-gprof ucb/gprof
-indent ucb/indent
-lpr ucb/lpr
-more ucb/more
-msgs ucb/msgs
-netstat ucb/netstat
-rdist ucb/rdist
-talk ucb/talk
-tftp ucb/tftp
-tset ucb/tset
-vgrind ucb/vgrind
-
-# Programs that live in "ucb"
-biff ucb Makefile biff.c
-checknr ucb Makefile checknr.c
-clear ucb Makefile clear.c
-colcrt ucb Makefile colcrt.c
-colrm ucb Makefile colrm.c
-ctags ucb Makefile ctags.c
-expand ucb Makefile expand.c
-finger ucb Makefile finger.c
-fold ucb Makefile fold.c
-from ucb Makefile from.c
-fsplit ucb Makefile fsplit.c
-gcore ucb Makefile gcore.c
-groups ucb Makefile groups.c
-head ucb Makefile head.c
-last ucb Makefile last.c
-lastcomm ucb Makefile lastcomm.c
-leave ucb Makefile leave.c
-logger ucb Makefile logger.c
-man_prog ucb Makefile man.c
-mkstr ucb Makefile mkstr.c
-printenv ucb Makefile printenv.c
-quota ucb Makefile quota.c
-rcp ucb Makefile rcp.c
-rdate ucb Makefile rdate.c
-rlogin ucb Makefile rlogin.c
-rsh ucb Makefile rsh.c
-rup ucb Makefile rup.c
-ruptime ucb Makefile ruptime.c
-rusers ucb Makefile rusers.c
-rwho ucb Makefile rwho.c
-sccs ucb Makefile sccs.c
-script ucb Makefile script.c
-soelim ucb Makefile soelim.c
-strings ucb Makefile strings.c
-tail ucb Makefile tail.c
-tcopy ucb Makefile tcopy.c
-telnet ucb Makefile telnet.c
-ul ucb Makefile ul.c
-unexpand ucb Makefile unexpand.c
-unifdef ucb Makefile unifdef.c
-users ucb Makefile users.c
-vmstat ucb Makefile vmstat.c
-w ucb Makefile w.c
-wc ucb Makefile wc.c
-what ucb Makefile what.c
-whatis ucb Makefile whatis.c
-whereis ucb Makefile whereis.c
-whoami ucb Makefile whoami.c
-whois ucb Makefile whois.c
-xstr ucb Makefile xstr.c
-yes ucb Makefile yes.c
-
-# Sub-directories of "usr.bin"
-calendar usr.bin/calendar
-cflow usr.bin/cflow
-ctrace usr.bin/ctrace
-cxref usr.bin/cxref
-dc usr.bin/dc
-des usr.bin/des
-diff3 usr.bin/diff3
-sun_eqn usr.bin/eqn
-file usr.bin/file
-find usr.bin/find
-graph usr.bin/graph
-lex usr.bin/lex
-sun_neqn usr.bin/neqn
-sun_nroff usr.bin/nroff
-sun_plot usr.bin/plot
-prof usr.bin/prof
-refer usr.bin/refer
-rpcgen usr.bin/rpcgen
-spell usr.bin/spell
-sun_tbl usr.bin/tbl
-tip usr.bin/tip
-trace usr.bin/trace
-sun_troff usr.bin/troff
-uucp usr.bin/uucp
-xsend usr.bin/xsend
-yacc usr.bin/yacc
-
-# Programs that live in "usr.bin"
-basename usr.bin Makefile basename.c
-bc usr.bin Makefile bc.c
-cal usr.bin Makefile cal.c
-cb usr.bin Makefile cb.c
-checkeq usr.bin Makefile checkeq.c
-chkey usr.bin Makefile chkey.c
-click usr.bin Makefile click.c
-col usr.bin Makefile col.c
-comm usr.bin Makefile comm.c
-cpio usr.bin Makefile cpio.c
-crypt usr.bin Makefile crypt.c
-csplit usr.bin Makefile csplit.c
-cut usr.bin Makefile cut.c
-deroff usr.bin Makefile deroff.c
-egrep usr.bin Makefile egrep.c
-fgrep usr.bin Makefile fgrep.c
-getopt usr.bin Makefile getopt.c
-id usr.bin Makefile id.c
-installcmd usr.bin Makefile installcmd.c
-iostat usr.bin Makefile iostat.c
-ipcrm usr.bin Makefile ipcrm.c
-ipcs usr.bin Makefile ipcs.c
-join usr.bin Makefile join.c
-keylogin usr.bin Makefile keylogin.c
-logname usr.bin Makefile logname.c
-look usr.bin Makefile look.c
-mesg usr.bin Makefile mesg.c
-nl usr.bin Makefile nl.c
-pack usr.bin Makefile pack.c
-paste usr.bin Makefile paste.c
-ptx usr.bin Makefile ptx.c
-rev usr.bin Makefile rev.c
-screenblank usr.bin Makefile screenblank.c
-sdiff usr.bin Makefile sdiff.c
-sleep usr.bin Makefile sleep.c
-sort usr.bin Makefile sort.c
-spline usr.bin Makefile spline.c
-split usr.bin Makefile split.c
-sum usr.bin Makefile sum.c
-touch usr.bin Makefile touch.c
-tr usr.bin Makefile tr.c
-tsort usr.bin Makefile tsort.c
-tty usr.bin Makefile tty.c
-uniq usr.bin Makefile uniq.c
-units usr.bin Makefile units.c
-unpack usr.bin Makefile unpack.c
-xargs usr.bin Makefile xargs.c
-ypcat usr.bin Makefile ypcat.c
-ypmatch usr.bin Makefile ypmatch.c
-yppasswd usr.bin Makefile yppasswd.c
-ypwhich usr.bin Makefile ypwhich.c
-
-# Sub-directories of "usr.etc"
-automount usr.etc/automount
-c2convert usr.etc/c2convert
-config usr.etc/config
-cron usr.etc/cron
-eeprom usr.etc/eeprom
-etherfind usr.etc/etherfind
-format usr.etc/format
-htable usr.etc/htable
-implog usr.etc/implog
-in.ftpd -a usr.etc/in.ftpd ucb/ftp
-in.named usr.etc/in.named
-in.rwhod usr.etc/in.rwhod
-keyserv usr.etc/keyserv
-ndbootd usr.etc/ndbootd
-praudit usr.etc/praudit
-rexd usr.etc/rexd
-rpc.bootparamd usr.etc/rpc.bootparamd
-termcap usr.etc/termcap
-upgrade usr.etc/upgrade
-yp usr.etc/yp
-zic usr.etc/zic
-
-# Programs that live in "usr.etc"
-ac usr.etc Makefile ac.c
-accton usr.etc Makefile accton.c
-audit usr.etc Makefile audit.c
-auditd usr.etc Makefile auditd.c
-catman usr.etc Makefile catman.c
-chroot usr.etc Makefile chroot.c
-dcheck usr.etc Makefile dcheck.c
-devnm usr.etc Makefile devnm.c
-dumpfs usr.etc Makefile dumpfs.c
-edquota usr.etc Makefile edquota.c
-exportfs usr.etc Makefile exportfs.c
-foption usr.etc Makefile foption.c
-gettable usr.etc Makefile gettable.c
-grpck usr.etc Makefile grpck.c
-icheck usr.etc Makefile icheck.c
-in.comsat usr.etc Makefile in.comsat.c
-in.fingerd usr.etc Makefile in.fingerd.c
-in.rexecd usr.etc Makefile in.rexecd.c
-in.telnetd usr.etc Makefile in.telnetd.c
-in.tnamed usr.etc Makefile in.tnamed.c
-kgmon usr.etc Makefile kgmon.c
-link usr.etc Makefile link.c
-mkfile usr.etc Makefile mkfile.c
-mkproto usr.etc Makefile mkproto.c
-mount_lo usr.etc Makefile mount_lo.c
-ncheck usr.etc Makefile ncheck.c
-nfsstat usr.etc Makefile nfsstat.c
-ping usr.etc Makefile ping.c
-pwck usr.etc Makefile pwck.c
-quot usr.etc Makefile quot.c
-quotacheck usr.etc Makefile quotacheck.c
-quotaon usr.etc Makefile quotaon.c
-rarpd usr.etc Makefile rarpd.c
-repquota usr.etc Makefile repquota.c
-route usr.etc Makefile route.c
-rpc.etherd usr.etc Makefile rpc.etherd.c
-rpc.mountd usr.etc Makefile rpc.mountd.c
-rpc.pwdauthd usr.etc Makefile rpc.pwdauthd.c
-rpc.rquotad usr.etc Makefile rpc.rquotad.c
-rpc.rstatd usr.etc Makefile rpc.rstatd.c
-rpc.rusersd usr.etc Makefile rpc.rusersd.c
-rpc.rwalld usr.etc Makefile rpc.rwalld.c
-rpc.sprayd usr.etc Makefile rpc.sprayd.c
-rpc.yppasswdd usr.etc Makefile rpc.yppasswdd.c
-rpc.ypupdated usr.etc Makefile rpc.ypupdated.c
-rpcinfo usr.etc Makefile rpcinfo.c
-rwall usr.etc Makefile rwall.c
-sa usr.etc Makefile sa.c
-savecore usr.etc Makefile savecore.c
-showmount usr.etc Makefile showmount.c
-spray usr.etc Makefile spray.c
-swapon usr.etc Makefile swapon.c
-trpt usr.etc Makefile trpt.c
-tunefs usr.etc Makefile tunefs.c
-unlink usr.etc Makefile unlink.c
-
-# Sub-directories of "usr.lib"
-bb_count usr.lib/bb_count
-fixedwidthfonts usr.lib/fixedwidthfonts
-libcurses usr.lib/libcurses
-libdbm usr.lib/libdbm
-libg usr.lib/libg
-libkvm usr.lib/libkvm
-libln usr.lib/libln
-liblwp usr.lib/liblwp
-libm usr.lib/libm
-libmp usr.lib/libmp
-libpixrect usr.lib/libpixrect
-libplot usr.lib/libplot
-libresolv usr.lib/libresolv
-librpcsvc usr.lib/librpcsvc
-libtermlib usr.lib/libtermlib
-liby usr.lib/liby
-me usr.lib/me
-ms usr.lib/ms
-sendmail usr.lib/sendmail
-sun_tmac usr.lib/tmac
-vfont usr.lib/vfont
-
-# Programs that live in "usr.lib"
-getNAME usr.lib Makefile getNAME
-makekey usr.lib Makefile makekey
-
-# Sub-directories of "5bin"
-5diff3 5bin/diff3
-5m4 5bin/m4
-
-# Sub-directories of "5bin", but use sources from other places
-5cxref -a 5bin/cxref usr.bin/cxref
-5sed -a 5bin/sed bin/sed
-5lint -a 5bin/lint lang/pcc lang/lint
-
-# Programs that live in "5bin"
-5banner 5bin Makefile banner.c
-5cat 5bin Makefile cat.c
-5du 5bin Makefile du.c
-5echo 5bin Makefile echo.c
-5expr 5bin Makefile expr.c
-5ls 5bin Makefile ls.c
-5nohup 5bin Makefile nohup.c
-5od 5bin Makefile od.c
-5pg 5bin Makefile pg.c
-5pr 5bin Makefile pr.c
-5sum 5bin Makefile sum.c
-5tabs 5bin Makefile tabs.c
-5time 5bin Makefile time.c
-5tr 5bin Makefile tr.c
-5uname 5bin Makefile uname.c
-
-# Programs that live in "5bin", but use sources from other places
-5chmod -a 5bin/Makefile bin/chmod.c
-5date -a 5bin/Makefile bin/date.c
-5grep -a 5bin/Makefile bin/grep.c
-5stty -a 5bin/Makefile bin/stty.c
-5col -a 5bin/Makefile usr.bin/col.c
-5sort -a 5bin/Makefile usr.bin/sort.c
-5touch -a 5bin/Makefile usr.bin/touch.c
-
-# Sub-directories of "5lib"
-5compile 5lib/compile
-5libcurses 5lib/libcurses
-5liby 5lib/liby
-5terminfo 5lib/terminfo
-
-# Programs that live in "5lib"
-# NONE
diff --git a/gnu/usr.bin/cvs/examples/rcsinfo b/gnu/usr.bin/cvs/examples/rcsinfo
deleted file mode 100644
index 6d91455..0000000
--- a/gnu/usr.bin/cvs/examples/rcsinfo
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# rcsinfo,v 1.3 1992/04/10 18:59:14 berliner Exp
-#
-# The "rcsinfo" file is used to control templates with which the editor
-# is invoked on commit and import.
-#
-# The first entry on a line is a regular expression which is tested
-# against the directory that the change is being made to, relative to the
-# $CVSROOT. If a match is found, then the remainder of the line is the
-# name of the file that contains the template.
-#
-# If the repository name does not match any of the regular expressions in this
-# file, the "DEFAULT" line is used, if it is specified.
-#
-# If the name ALL appears as a regular expression it is always used
-# in addition to the first matching regex or DEFAULT.
-#
-DEFAULT /src/master/CVSROOT/rcstemplate
diff --git a/gnu/usr.bin/cvs/lib/Makefile b/gnu/usr.bin/cvs/lib/Makefile
deleted file mode 100644
index 3c68ed5..0000000
--- a/gnu/usr.bin/cvs/lib/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-LIB = cvs
-
-CFLAGS += -I${.CURDIR} -I${.CURDIR}/../cvs -DFTIME_MISSING -DHAVE_TIMEZONE
-
-SRCS = argmatch.c error.c getopt.c sighandle.c strippath.c stripslash.c yesno.c \
- getdate.y fnmatch.c regex.c subr.c myndbm.c hash.c
-
-CLEANFILES+= getdate.c
-
-install:
- @echo -n
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/cvs/lib/Makefile.in b/gnu/usr.bin/cvs/lib/Makefile.in
deleted file mode 100644
index a8309f2..0000000
--- a/gnu/usr.bin/cvs/lib/Makefile.in
+++ /dev/null
@@ -1,91 +0,0 @@
-# Makefile for library files used by GNU CVS.
-# Do not use this makefile directly, but only from `../Makefile'.
-# Copyright (C) 1986, 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.
-
-# @(#)Makefile.in 1.12 92/03/31
-
-SHELL = /bin/sh
-
-srcdir = @srcdir@
-@VPATH@
-
-SOURCES = argmatch.c \
-error.c getopt.c getopt1.c \
-sighandle.c \
-strippath.c stripslash.c yesno.c \
-getdate.y \
-hostname.c fnmatch.c ftruncate.c mkdir.c rename.c regex.c \
-strdup.c getwd.c alloca.c
-
-OBJECTS = argmatch.o \
-error.o getopt.o getopt1.o \
-sighandle.o \
-strippath.o stripslash.o yesno.o \
-getdate.o \
-@LIBOBJS@
-
-DISTFILES = Makefile.in getopt.h \
-fnmatch.h regex.h system.h wait.h $(SOURCES)
-
-xxx:
- @cd ..; $(MAKE) all SUBDIRS=lib
-
-all: libcvs.a
-.PHONY: all
-
-install: all
-.PHONY: install
-
-tags: $(DISTFILES)
- ctags $(DISTFILES)
-
-TAGS: $(DISTFILES)
- etags $(DISTFILES)
-
-ls:
- @echo $(DISTFILES)
-.PHONY: ls
-
-clean:
- rm -f *.a *.o *.tab.c getdate.c
-.PHONY: clean
-
-distclean: clean
- rm -f tags TAGS Makefile
-.PHONY: distclean
-
-realclean: distclean
-.PHONY: realclean
-
-dist:
- ln $(DISTFILES) ../`cat ../.fname`/lib
-.PHONY: dist
-
-libcvs.a: $(OBJECTS)
- $(AR) cr $@ $(OBJECTS)
- -$(RANLIB) $@
-
-getdate.c: getdate.y
- @echo expect 8 shift/reduce conflicts
- $(YACC) $(srcdir)/getdate.y
- -if test -f y.tab.c ; then mv y.tab.c getdate.c ; fi
- -if test -f getdate.tab.c ; then mv getdate.tab.c getdate.c ; fi
-
-fnmatch.o: fnmatch.h
-getopt1.o: getopt.h
-regex.o: regex.h
-getwd.o: system.h
diff --git a/gnu/usr.bin/cvs/lib/alloca.c b/gnu/usr.bin/cvs/lib/alloca.c
deleted file mode 100644
index d2a54b3..0000000
--- a/gnu/usr.bin/cvs/lib/alloca.c
+++ /dev/null
@@ -1,191 +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 */
-
-#if __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));
- }
-}
-
diff --git a/gnu/usr.bin/cvs/lib/argmatch.c b/gnu/usr.bin/cvs/lib/argmatch.c
deleted file mode 100644
index 3f765fe..0000000
--- a/gnu/usr.bin/cvs/lib/argmatch.c
+++ /dev/null
@@ -1,83 +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> */
-
-#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/cvs/lib/dup2.c b/gnu/usr.bin/cvs/lib/dup2.c
deleted file mode 100644
index 0bd3aca..0000000
--- a/gnu/usr.bin/cvs/lib/dup2.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- dup2 -- 7th Edition UNIX system call emulation for UNIX System V
-
- last edit: 11-Feb-1987 D A Gwyn
-*/
-
-#include <errno.h>
-#include <fcntl.h>
-
-extern int close(), fcntl();
-
-int
-dup2( oldfd, newfd )
- int oldfd; /* already-open file descriptor */
- int newfd; /* desired duplicate descriptor */
-{
- register int ret; /* for fcntl() return value */
- register int save; /* for saving entry errno */
-
- if ( oldfd == newfd )
- return oldfd; /* be careful not to close() */
-
- save = errno; /* save entry errno */
- (void) close( newfd ); /* in case newfd is open */
- /* (may have just clobbered the original errno value) */
-
- ret = fcntl( oldfd, F_DUPFD, newfd ); /* dupe it */
-
- if ( ret >= 0 )
- errno = save; /* restore entry errno */
- else /* fcntl() returned error */
- if ( errno == EINVAL )
- errno = EBADF; /* we think of everything */
-
- return ret; /* return file descriptor */
-}
diff --git a/gnu/usr.bin/cvs/lib/error.c b/gnu/usr.bin/cvs/lib/error.c
deleted file mode 100644
index fadb1c5..0000000
--- a/gnu/usr.bin/cvs/lib/error.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/* error.c -- error handler for noninteractive utilities
- Copyright (C) 1990-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. */
-
-/* David MacKenzie */
-/* Brian Berliner added support for CVS */
-
-#ifndef lint
-static char rcsid[] = "@(#)error.c 1.9 92/03/31";
-#endif /* not lint */
-
-#include <stdio.h>
-
-/* turn on CVS support by default, since this is the CVS distribution */
-#define CVS_SUPPORT
-
-#ifdef CVS_SUPPORT
-#if __STDC__
-void Lock_Cleanup(void);
-#else
-void Lock_Cleanup();
-#endif /* __STDC__ */
-#endif /* CVS_SUPPORT */
-
-#ifndef VPRINTF_MISSING
-
-#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
-
-#ifndef DOPRNT_MISSING
-#define va_alist args
-#define va_dcl int args;
-#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
-
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#include <string.h>
-#else
-#if __STDC__
-void exit(int status);
-#else
-void exit ();
-#endif /* __STDC__ */
-#endif
-
-#ifdef STRERROR_MISSING
-static char *
-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";
-}
-#endif /* STRERROR_MISSING */
-
-/* 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 (VPRINTF_MISSING) && __STDC__
-error (int status, int errnum, char *message, ...)
-#else
-error (status, errnum, message, va_alist)
- int status;
- int errnum;
- char *message;
- va_dcl
-#endif
-{
- extern char *program_name;
-#ifdef CVS_SUPPORT
- extern char *command_name;
-#endif
-#ifndef VPRINTF_MISSING
- va_list args;
-#endif
-
-#ifdef CVS_SUPPORT
- if (command_name && *command_name)
- if (status)
- fprintf (stderr, "%s [%s aborted]: ", program_name, command_name);
- else
- fprintf (stderr, "%s %s: ", program_name, command_name);
- else
- fprintf (stderr, "%s: ", program_name);
-#else
- fprintf (stderr, "%s: ", program_name);
-#endif
-#ifndef VPRINTF_MISSING
- VA_START (args, message);
- vfprintf (stderr, message, args);
- va_end (args);
-#else
-#ifndef DOPRNT_MISSING
- _doprnt (message, &args, stderr);
-#else
- fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
-#endif
- if (errnum)
- fprintf (stderr, ": %s", strerror (errnum));
- putc ('\n', stderr);
- fflush (stderr);
- if (status)
- {
-#ifdef CVS_SUPPORT
- Lock_Cleanup();
-#endif
- exit (status);
- }
-}
-
-#ifdef CVS_SUPPORT
-
-/* Print the program name and error message MESSAGE, which is a printf-style
- format string with optional args to the file specified by FP.
- If ERRNUM is nonzero, print its corresponding system error message.
- Exit with status STATUS if it is nonzero. */
-/* VARARGS */
-void
-#if !defined (VPRINTF_MISSING) && __STDC__
-fperror (FILE *fp, int status, int errnum, char *message, ...)
-#else
-fperror (fp, status, errnum, message, va_alist)
- FILE *fp;
- int status;
- int errnum;
- char *message;
- va_dcl
-#endif
-{
- extern char *program_name;
-#ifndef VPRINTF_MISSING
- va_list args;
-#endif
-
- fprintf (fp, "%s: ", program_name);
-#ifndef VPRINTF_MISSING
- VA_START (args, message);
- vfprintf (fp, message, args);
- va_end (args);
-#else
-#ifndef DOPRNT_MISSING
- _doprnt (message, &args, fp);
-#else
- fprintf (fp, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
-#endif
- if (errnum)
- fprintf (fp, ": %s", strerror (errnum));
- putc ('\n', fp);
- fflush (fp);
- if (status)
- {
-#ifdef CVS_SUPPORT
- Lock_Cleanup();
-#endif
- exit (status);
- }
-}
-
-#endif /* CVS_SUPPORT */
diff --git a/gnu/usr.bin/cvs/lib/fnmatch.c b/gnu/usr.bin/cvs/lib/fnmatch.c
deleted file mode 100644
index 50fa94c..0000000
--- a/gnu/usr.bin/cvs/lib/fnmatch.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Copyright (C) 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-/* Modified slightly by Brian Berliner <berliner@sun.com> for CVS use */
-
-/* IGNORE(@ */
-/* #include <ansidecl.h> */
-/* @) */
-#include <errno.h>
-#include <fnmatch.h>
-
-#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
-extern int errno;
-#endif
-
-#if !__STDC__
-#define const
-#endif
-
-/* Match STRING against the filename pattern PATTERN, returning zero if
- it matches, nonzero if not. */
-int
-#if __STDC__
-fnmatch (const char *pattern, const char *string, int flags)
-#else
-fnmatch (pattern, string, flags)
- char *pattern;
- char *string;
- int flags;
-#endif
-{
- register const char *p = pattern, *n = string;
- register char c;
-
- if ((flags & ~__FNM_FLAGS) != 0)
- {
- errno = EINVAL;
- return -1;
- }
-
- while ((c = *p++) != '\0')
- {
- switch (c)
- {
- case '?':
- if (*n == '\0')
- return FNM_NOMATCH;
- else if ((flags & FNM_PATHNAME) && *n == '/')
- return FNM_NOMATCH;
- else if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- return FNM_NOMATCH;
- break;
-
- case '\\':
- if (!(flags & FNM_NOESCAPE))
- c = *p++;
- if (*n != c)
- return FNM_NOMATCH;
- break;
-
- case '*':
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- return FNM_NOMATCH;
-
- for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
- if (((flags & FNM_PATHNAME) && *n == '/') ||
- (c == '?' && *n == '\0'))
- return FNM_NOMATCH;
-
- if (c == '\0')
- return 0;
-
- {
- char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
- for (--p; *n != '\0'; ++n)
- if ((c == '[' || *n == c1) &&
- fnmatch(p, n, flags & ~FNM_PERIOD) == 0)
- return 0;
- return FNM_NOMATCH;
- }
-
- case '[':
- {
- /* Nonzero if the sense of the character class is inverted. */
- register int not;
-
- if (*n == '\0')
- return FNM_NOMATCH;
-
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- return FNM_NOMATCH;
-
- not = (*p == '!' || *p == '^');
- if (not)
- ++p;
-
- c = *p++;
- for (;;)
- {
- register char cstart = c, cend = c;
-
- if (!(flags & FNM_NOESCAPE) && c == '\\')
- cstart = cend = *p++;
-
- if (c == '\0')
- /* [ (unterminated) loses. */
- return FNM_NOMATCH;
-
- c = *p++;
-
- if ((flags & FNM_PATHNAME) && c == '/')
- /* [/] can never match. */
- return FNM_NOMATCH;
-
- if (c == '-' && *p != ']')
- {
- cend = *p++;
- if (!(flags & FNM_NOESCAPE) && cend == '\\')
- cend = *p++;
- if (cend == '\0')
- return FNM_NOMATCH;
- c = *p++;
- }
-
- if (*n >= cstart && *n <= cend)
- goto matched;
-
- if (c == ']')
- break;
- }
- if (!not)
- return FNM_NOMATCH;
- break;
-
- matched:;
- /* Skip the rest of the [...] that already matched. */
- while (c != ']')
- {
- if (c == '\0')
- /* [... (unterminated) loses. */
- return FNM_NOMATCH;
-
- c = *p++;
- if (!(flags & FNM_NOESCAPE) && c == '\\')
- /* 1003.2d11 is unclear if this is right. %%% */
- ++p;
- }
- if (not)
- return FNM_NOMATCH;
- }
- break;
-
- default:
- if (c != *n)
- return FNM_NOMATCH;
- }
-
- ++n;
- }
-
- if (*n == '\0')
- return 0;
-
- return FNM_NOMATCH;
-}
diff --git a/gnu/usr.bin/cvs/lib/fnmatch.h b/gnu/usr.bin/cvs/lib/fnmatch.h
deleted file mode 100644
index a1e4f87..0000000
--- a/gnu/usr.bin/cvs/lib/fnmatch.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Copyright (C) 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#ifndef _FNMATCH_H
-
-#define _FNMATCH_H 1
-
-/* Bits set in the FLAGS argument to `fnmatch'. */
-#undef FNM_PATHNAME
-#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */
-#undef FNM_NOESCAPE
-#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */
-#undef FNM_PERIOD
-#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */
-#undef __FNM_FLAGS
-#define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD)
-
-/* Value returned by `fnmatch' if STRING does not match PATTERN. */
-#undef FNM_NOMATCH
-#define FNM_NOMATCH 1
-
-/* Match STRING against the filename pattern PATTERN,
- returning zero if it matches, FNM_NOMATCH if not. */
-#if __STDC__
-extern int fnmatch (const char *pattern, const char *string, int flags);
-#else
-extern int fnmatch ();
-#endif
-
-#endif /* fnmatch.h */
diff --git a/gnu/usr.bin/cvs/lib/ftruncate.c b/gnu/usr.bin/cvs/lib/ftruncate.c
deleted file mode 100644
index 17d263d..0000000
--- a/gnu/usr.bin/cvs/lib/ftruncate.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ftruncate emulations that work on some System V's.
- This file is in the public domain. */
-
-#include <sys/types.h>
-#include <fcntl.h>
-
-#ifdef F_CHSIZE
-int
-ftruncate (fd, length)
- int fd;
- off_t length;
-{
- return fcntl (fd, F_CHSIZE, length);
-}
-#else
-#ifdef F_FREESP
-/* The following function was written by
- kucharsk@Solbourne.com (William Kucharski) */
-
-#include <sys/stat.h>
-#include <errno.h>
-#include <unistd.h>
-
-int
-ftruncate (fd, length)
- int fd;
- off_t length;
-{
- 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), SEEK_SET) < 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, 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
-int
-ftruncate (fd, length)
- int fd;
- off_t length;
-{
- return chsize (fd, length);
-}
-#endif
-#endif
diff --git a/gnu/usr.bin/cvs/lib/getdate.y b/gnu/usr.bin/cvs/lib/getdate.y
deleted file mode 100644
index d010cb6..0000000
--- a/gnu/usr.bin/cvs/lib/getdate.y
+++ /dev/null
@@ -1,889 +0,0 @@
-%{
-/* 1.8
-** @(#)getdate.y 1.8 92/03/03
-**
-** 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 *//* Unused static variable */
-/* SUPPRESS 288 on yyerrlab *//* Label unused */
-
-#include "system.h"
-#include <ctype.h>
-
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
-#ifdef __GNUC__
-#undef alloca /* might get redefined below */
-#endif
-#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[] = "@(#)getdate.y 1.8 92/03/03";
-#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;
- }
- | 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 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 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 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 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 */
- { "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 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 */
-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 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;
-}
-
-
-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(FTIME_MISSING)
- (void)time(&ftz.time);
- /* Set the timezone global. */
- tzset();
-#if defined(HAVE_TIMEZONE)
- tm = localtime(&ftz.time);
- ftz.timezone = tm->tm_gmtoff / 60;
-#else
-#if defined(timezone)
- ftz.tzone = (int) timezone / 60;
-#else
- ftz.timezone = (int) timezone / 60;
-#endif /* defined(timezone) */
-#endif /* defined(HAVE_TIMEZONE) */
-#else
- (void)ftime(&ftz);
-#endif /* defined(FTIME_MISSING) */
- }
-
- tm = localtime(&now->time);
- yyYear = tm->tm_year;
- yyMonth = tm->tm_mon + 1;
- yyDay = tm->tm_mday;
-#if defined(timezone)
- yyTimezone = now->tzone;
-#else
- yyTimezone = now->timezone;
-#endif /* defined(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/cvs/lib/getopt.c b/gnu/usr.bin/cvs/lib/getopt.c
deleted file mode 100644
index c322fc2..0000000
--- a/gnu/usr.bin/cvs/lib/getopt.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/* Getopt for GNU.
- Copyright (C) 1987-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__
-#define const
-#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 _POSIX_OPTION_ORDER 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. */
-
-#ifndef lint
-static char rcsid[] = "@(#)getopt.c 1.7 92/03/31";
-#endif
-
-#include <stdio.h>
-
-#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
-#include <stdlib.h>
-#else /* STDC_HEADERS or __GNU_LIBRARY__ */
-char *getenv ();
-char *malloc ();
-#endif /* STDC_HEADERS or __GNU_LIBRARY__ */
-
-/* AIX requires this to be the first thing in the file. */
-#ifdef __GNUC__
-#if !defined(bsdi) && !defined(__386BSD__)
-#define alloca __builtin_alloca
-#endif
-#else /* not __GNUC__ */
-#ifdef sparc
-#include <alloca.h>
-#else
-#ifdef _AIX
- #pragma alloca
-#else
-char *alloca ();
-#endif
-#endif /* sparc */
-#endif /* not __GNUC__ */
-
-#if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
-#include <string.h>
-#ifndef bcopy
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#endif
-#ifndef index
-#define index strchr
-#endif
-#else /* USG or STDC_HEADERS or __GNU_LIBRARY__ */
-#ifdef VMS
-#include <string.h>
-#else /* VMS */
-#include <strings.h>
-#endif /* VMS */
-/* Declaring bcopy causes errors on systems whose declarations are different.
- If the declaration is omitted, everything works fine. */
-#endif /* USG or STDC_HEADERS or __GNU_LIBRARY__ */
-
-/* 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
- _POSIX_OPTION_ORDER 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 POSIX_ME_HARDER, 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;
-
-/* Describe the long-named options requested by the application.
- _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an
- element containing a name which is zero.
- The field `has_arg' is 1 if the option takes an argument,
- 2 if it takes an optional argument. */
-
-struct option
-{
- char *name;
- int has_arg;
- int *flag;
- int val;
-};
-
-const struct option *_getopt_long_options;
-
-int _getopt_long_only = 0;
-
-/* Index in _GETOPT_LONG_OPTIONS of the long-named option actually found.
- Only valid when a long-named option was found. */
-
-int option_index;
-
-/* 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. */
-
- bcopy (&argv[first_nonopt], temp, nonopts_size);
- bcopy (&argv[last_nonopt], &argv[first_nonopt],
- (optind - last_nonopt) * sizeof (char *));
- bcopy (temp, &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
- otherwise. */
-
-int
-gnu_getopt (argc, argv, optstring)
- int argc;
- char **argv;
- const char *optstring;
-{
- 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 = 0;
-
- /* 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 ("POSIX_ME_HARDER") != 0)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
- }
-
- if (nextchar == 0 || *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 (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)
- && (_getopt_long_options == 0
- || argv[optind][0] != '+'
- || argv[optind][1] == 0))
- 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 (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)
- && (_getopt_long_options == 0
- || 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.
- Start decoding its characters. */
-
- nextchar = argv[optind] + 1;
- }
-
- if (_getopt_long_options != 0
- && (argv[optind][0] == '+'
- || (_getopt_long_only && argv[optind][0] == '-'))
- )
- {
- const struct option *p;
- char *s = nextchar;
- int exact = 0;
- int ambig = 0;
- const struct option *pfound = 0;
- int indfound = 0;
-
- while (*s && *s != '=')
- s++;
-
- /* Test all options for either exact match or abbreviated matches. */
- for (p = _getopt_long_options, 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 == 0)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- fprintf (stderr, "%s: option `%s' is ambiguous\n",
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
-
- if (pfound != 0)
- {
- option_index = indfound;
- optind++;
- if (*s)
- {
- if (pfound->has_arg > 0)
- optarg = s + 1;
- else
- {
- 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
- {
- fprintf (stderr, "%s: option `%s' requires an argument\n",
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- nextchar += strlen (nextchar);
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- /* Can't find it as a long option. If this is getopt_long_only,
- and the option starts with '-' and is a valid short
- option, then interpret it as a short option. Otherwise it's
- an error. */
- if (_getopt_long_only == 0 || argv[optind][0] == '+' ||
- index (optstring, *nextchar) == 0)
- {
- if (opterr != 0)
- fprintf (stderr, "%s: unrecognized option `%c%s'\n",
- argv[0], argv[optind][0], nextchar);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == 0)
- optind++;
-
- if (temp == 0 || c == ':')
- {
- if (opterr != 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);
- }
- 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 = 0;
- }
- 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 != 0)
- 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 = 0;
- }
- }
- return c;
- }
-}
-
-#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 = gnu_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/cvs/lib/getopt.h b/gnu/usr.bin/cvs/lib/getopt.h
deleted file mode 100644
index 5f902de..0000000
--- a/gnu/usr.bin/cvs/lib/getopt.h
+++ /dev/null
@@ -1,102 +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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* @(#)getopt.h 1.6 92/03/31 */
-
-/* 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.
- _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- The field `has_arg' is:
- 0 if the option does not take an argument,
- 1 if the option requires an argument,
- 2 if the option takes an optional argument.
-
- If the field `flag' is nonzero, 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
-{
- char *name;
- int has_arg;
- int *flag;
- int val;
-};
-
-#if __STDC__
-extern const struct option *_getopt_long_options;
-#else
-extern struct option *_getopt_long_options;
-#endif
-
-/* If nonzero, '-' can introduce long-named options.
- Set by getopt_long_only. */
-
-extern int _getopt_long_only;
-
-/* The index in GETOPT_LONG_OPTIONS of the long-named option found.
- Only valid when a long-named option has been found by the most
- recent call to `getopt'. */
-
-extern int option_index;
-
-#if __STDC__
-int gnu_getopt (int argc, char **argv, const char *shortopts);
-int gnu_getopt_long (int argc, char **argv, const char *shortopts,
- const struct option *longopts, int *longind);
-int gnu_getopt_long_only (int argc, char **argv, const char *shortopts,
- const struct option *longopts, int *longind);
-#else
-int gnu_getopt ();
-int gnu_getopt_long ();
-int gnu_getopt_long_only ();
-#endif
diff --git a/gnu/usr.bin/cvs/lib/getopt1.c b/gnu/usr.bin/cvs/lib/getopt1.c
deleted file mode 100644
index 8606462..0000000
--- a/gnu/usr.bin/cvs/lib/getopt1.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/* Getopt for GNU.
- Copyright (C) 1987-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. */
-
-#include "getopt.h"
-
-#if !__STDC__
-#define const
-#endif
-
-#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
-#include <stdlib.h>
-#else /* STDC_HEADERS or __GNU_LIBRARY__ */
-char *getenv ();
-#endif /* STDC_HEADERS or __GNU_LIBRARY__ */
-
-#if !defined (NULL)
-#define NULL 0
-#endif
-
-int
-gnu_getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char **argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- int val;
-
- /* For strict POSIX compatibility, we must turn off long options. */
- if (getenv ("POSIX_ME_HARDER") == 0)
- _getopt_long_options = long_options;
- val = gnu_getopt (argc, argv, options);
- if (val == 0 && opt_index != NULL)
- *opt_index = option_index;
- return val;
-}
-
-/* Like getopt_long, but '-' as well as '+' can indicate a long option.
- If an option that starts with '-' doesn't match a long option,
- but does match a short option, it is parsed as a short option
- instead. */
-
-int
-gnu_getopt_long_only (argc, argv, options, long_options, opt_index)
- int argc;
- char **argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- int val;
-
- _getopt_long_options = long_options;
- _getopt_long_only = 1;
- val = gnu_getopt (argc, argv, options);
- if (val == 0 && opt_index != NULL)
- *opt_index = option_index;
- return val;
-}
-
-
-#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;
- char *name = '\0';
- 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 '?':
- 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/cvs/lib/getwd.c b/gnu/usr.bin/cvs/lib/getwd.c
deleted file mode 100644
index 854feaf..0000000
--- a/gnu/usr.bin/cvs/lib/getwd.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* getwd.c -- get current working directory pathname
- Copyright (C) 1992 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Some systems which include both getwd() and getcwd() have an implementation
- of getwd() which is much faster than getcwd(). As a result, we use the
- system's getwd() if it is available */
-
-#include "system.h"
-
-/* Get the current working directory into PATHNAME */
-
-char *
-getwd (pathname)
- char *pathname;
-{
- return (getcwd(pathname, PATH_MAX));
-}
diff --git a/gnu/usr.bin/cvs/lib/hash.c b/gnu/usr.bin/cvs/lib/hash.c
deleted file mode 100644
index fb29497..0000000
--- a/gnu/usr.bin/cvs/lib/hash.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 1992, Brian Berliner and Jeff Polk
- *
- * You may distribute under the terms of the GNU General Public License as
- * specified in the README file that comes with the CVS 1.3 kit.
- *
- * Polk's hash list manager. So cool.
- */
-
-#include "cvs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#)hash.c 1.14 92/03/31";
-#endif
-
-/* global caches */
-static List *listcache = NULL;
-static Node *nodecache = NULL;
-
-#if __STDC__
-static void freenode_mem (Node * p);
-#else
-static void freenode_mem ();
-#endif /* __STDC__ */
-
-/* hash function */
-static int
-hashp (key)
- char *key;
-{
- register char *p;
- register int n = 0;
-
- for (p = key; *p; p++)
- n += *p;
-
- return (n % HASHSIZE);
-}
-
-/*
- * create a new list (or get an old one from the cache)
- */
-List *
-getlist ()
-{
- int i;
- List *list;
- Node *node;
-
- if (listcache != NULL)
- {
- /* get a list from the cache and clear it */
- list = listcache;
- listcache = listcache->next;
- list->next = (List *) NULL;
- for (i = 0; i < HASHSIZE; i++)
- list->hasharray[i] = (Node *) NULL;
- }
- else
- {
- /* make a new list from scratch */
- list = (List *) xmalloc (sizeof (List));
- bzero ((char *) list, sizeof (List));
- node = getnode ();
- list->list = node;
- node->type = HEADER;
- node->next = node->prev = node;
- }
- return (list);
-}
-
-/*
- * free up a list
- */
-void
-dellist (listp)
- List **listp;
-{
- int i;
- Node *p;
-
- if (*listp == (List *) NULL)
- return;
-
- p = (*listp)->list;
-
- /* free each node in the list (except header) */
- while (p->next != p)
- delnode (p->next);
-
- /* free any list-private data, without freeing the actual header */
- freenode_mem (p);
-
- /* free up the header nodes for hash lists (if any) */
- for (i = 0; i < HASHSIZE; i++)
- {
- if ((p = (*listp)->hasharray[i]) != (Node *) NULL)
- {
- /* put the nodes into the cache */
- p->type = UNKNOWN;
- p->next = nodecache;
- nodecache = p;
- }
- }
-
- /* put it on the cache */
- (*listp)->next = listcache;
- listcache = *listp;
- *listp = (List *) NULL;
-}
-
-/*
- * get a new list node
- */
-Node *
-getnode ()
-{
- Node *p;
-
- if (nodecache != (Node *) NULL)
- {
- /* get one from the cache */
- p = nodecache;
- nodecache = p->next;
- }
- else
- {
- /* make a new one */
- p = (Node *) xmalloc (sizeof (Node));
- }
-
- /* always make it clean */
- bzero ((char *) p, sizeof (Node));
- p->type = UNKNOWN;
-
- return (p);
-}
-
-/*
- * remove a node from it's list (maybe hash list too) and free it
- */
-void
-delnode (p)
- Node *p;
-{
- if (p == (Node *) NULL)
- return;
-
- /* take it out of the list */
- p->next->prev = p->prev;
- p->prev->next = p->next;
-
- /* if it was hashed, remove it from there too */
- if (p->hashnext != (Node *) NULL)
- {
- p->hashnext->hashprev = p->hashprev;
- p->hashprev->hashnext = p->hashnext;
- }
-
- /* free up the storage */
- freenode (p);
-}
-
-/*
- * free up the storage associated with a node
- */
-static void
-freenode_mem (p)
- Node *p;
-{
- if (p->delproc != (void (*) ()) NULL)
- p->delproc (p); /* call the specified delproc */
- else
- {
- if (p->data != NULL) /* otherwise free() it if necessary */
- free (p->data);
- }
- if (p->key != NULL) /* free the key if necessary */
- free (p->key);
-
- /* to be safe, re-initialize these */
- p->key = p->data = (char *) NULL;
- p->delproc = (void (*) ()) NULL;
-}
-
-/*
- * free up the storage associated with a node and recycle it
- */
-void
-freenode (p)
- Node *p;
-{
- /* first free the memory */
- freenode_mem (p);
-
- /* then put it in the cache */
- p->type = UNKNOWN;
- p->next = nodecache;
- nodecache = p;
-}
-
-/*
- * insert item p at end of list "list" (maybe hash it too) if hashing and it
- * already exists, return -1 and don't actually put it in the list
- *
- * return 0 on success
- */
-int
-addnode (list, p)
- List *list;
- Node *p;
-{
- int hashval;
- Node *q;
-
- if (p->key != NULL) /* hash it too? */
- {
- hashval = hashp (p->key);
- if (list->hasharray[hashval] == NULL) /* make a header for list? */
- {
- q = getnode ();
- q->type = HEADER;
- list->hasharray[hashval] = q->hashnext = q->hashprev = q;
- }
-
- /* put it into the hash list if it's not already there */
- for (q = list->hasharray[hashval]->hashnext;
- q != list->hasharray[hashval]; q = q->hashnext)
- {
- if (strcmp (p->key, q->key) == 0)
- return (-1);
- }
- q = list->hasharray[hashval];
- p->hashprev = q->hashprev;
- p->hashnext = q;
- p->hashprev->hashnext = p;
- q->hashprev = p;
- }
-
- /* put it into the regular list */
- p->prev = list->list->prev;
- p->next = list->list;
- list->list->prev->next = p;
- list->list->prev = p;
-
- return (0);
-}
-
-/*
- * look up an entry in hash list table
- */
-Node *
-findnode (list, key)
- List *list;
- char *key;
-{
- Node *head, *p;
-
- if (list == (List *) NULL)
- return ((Node *) NULL);
-
- head = list->hasharray[hashp (key)];
- if (head == (Node *) NULL)
- return ((Node *) NULL);
-
- for (p = head->hashnext; p != head; p = p->hashnext)
- if (strcmp (p->key, key) == 0)
- return (p);
- return ((Node *) NULL);
-}
-
-/*
- * walk a list with a specific proc
- */
-int
-walklist (list, proc)
- List *list;
- int (*proc) ();
-{
- Node *head, *p;
- int err = 0;
-
- if (list == NULL)
- return (0);
-
- head = list->list;
- for (p = head->next; p != head; p = p->next)
- err += proc (p);
- return (err);
-}
-
-/*
- * sort the elements of a list (in place)
- */
-void
-sortlist (list, comp)
- List *list;
- int (*comp) ();
-{
- Node *head, *remain, *p, *q;
-
- /* save the old first element of the list */
- head = list->list;
- remain = head->next;
-
- /* make the header node into a null list of it's own */
- head->next = head->prev = head;
-
- /* while there are nodes remaining, do insert sort */
- while (remain != head)
- {
- /* take one from the list */
- p = remain;
- remain = remain->next;
-
- /* traverse the sorted list looking for the place to insert it */
- for (q = head->next; q != head; q = q->next)
- {
- if (comp (p, q) < 0)
- {
- /* p comes before q */
- p->next = q;
- p->prev = q->prev;
- p->prev->next = p;
- q->prev = p;
- break;
- }
- }
- if (q == head)
- {
- /* it belongs at the end of the list */
- p->next = head;
- p->prev = head->prev;
- p->prev->next = p;
- head->prev = p;
- }
- }
-}
diff --git a/gnu/usr.bin/cvs/lib/hash.h b/gnu/usr.bin/cvs/lib/hash.h
deleted file mode 100644
index 54f227e..0000000
--- a/gnu/usr.bin/cvs/lib/hash.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* @(#)hash.h 1.18 92/03/31 */
-
-/*
- * Copyright (c) 1992, Brian Berliner and Jeff Polk
- *
- * You may distribute under the terms of the GNU General Public License as
- * specified in the README file that comes with the CVS 1.3 kit.
- */
-
-/*
- * The number of buckets for the hash table contained in each list. This
- * should probably be prime.
- */
-#define HASHSIZE 151
-
-/*
- * Types of nodes
- */
-enum ntype
-{
- UNKNOWN, HEADER, ENTRIES, FILES, LIST, RCSNODE,
- RCSVERS, DIRS, UPDATE, LOCK, NDBMNODE
-};
-typedef enum ntype Ntype;
-
-struct node
-{
- Ntype type;
- struct node *next;
- struct node *prev;
- struct node *hashnext;
- struct node *hashprev;
- char *key;
- char *data;
- void (*delproc) ();
-};
-typedef struct node Node;
-
-struct list
-{
- Node *list;
- Node *hasharray[HASHSIZE];
- struct list *next;
-};
-typedef struct list List;
-
-struct entnode
-{
- char *version;
- char *timestamp;
- char *options;
- char *tag;
- char *date;
-};
-typedef struct entnode Entnode;
-
-#if __STDC__
-List *getlist (void);
-Node *findnode (List * list, char *key);
-Node *getnode (void);
-int addnode (List * list, Node * p);
-int walklist (List * list, int (*proc) ());
-void dellist (List ** listp);
-void delnode (Node * p);
-void freenode (Node * p);
-void sortlist (List * list, int (*comp) ());
-#else
-List *getlist ();
-Node *findnode ();
-Node *getnode ();
-int addnode ();
-int walklist ();
-void dellist ();
-void delnode ();
-void freenode ();
-void sortlist ();
-#endif /* __STDC__ */
diff --git a/gnu/usr.bin/cvs/lib/mkdir.c b/gnu/usr.bin/cvs/lib/mkdir.c
deleted file mode 100644
index b17cca2..0000000
--- a/gnu/usr.bin/cvs/lib/mkdir.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* mkrmdir.c -- BSD compatible directory functions for System V
- Copyright (C) 1988, 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. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-
-/* mkdir and rmdir adapted from GNU tar. */
-
-/* Make directory DPATH, with permission mode DMODE.
-
- Written by Robert Rother, Mariah Corporation, August 1985
- (sdcsvax!rmr or rmr@uscd). If you want it, it's yours.
-
- 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. */
-
-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;
-
- cpid = fork ();
- switch (cpid)
- {
- case -1: /* Cannot 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.
- This won't suffice to set SUID, SGID, etc. on this
- directory, so the parent process calls chmod afterward. */
- status = umask (0); /* Get current umask. */
- umask (status | (0777 & ~dmode)); /* Set for mkdir. */
- execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
- _exit (1);
-
- default: /* Parent process. */
- while (wait (&status) != cpid) /* Wait for kid to finish. */
- /* Do nothing. */ ;
-
- if (status & 0xFFFF)
- {
- errno = EIO; /* /bin/mkdir failed. */
- return -1;
- }
- return chmod (dpath, dmode);
- }
-}
-
-/* Remove directory DPATH.
- Return 0 if successful, -1 if not. */
-
-int
-rmdir (dpath)
- char *dpath;
-{
- int cpid, status;
- struct stat statbuf;
-
- if (stat (dpath, &statbuf) != 0)
- return -1; /* stat set errno. */
-
- if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
- {
- errno = ENOTDIR;
- return -1;
- }
-
- cpid = fork ();
- switch (cpid)
- {
- case -1: /* Cannot fork. */
- return -1; /* errno is set already. */
-
- case 0: /* Child process. */
- execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
- _exit (1);
-
- default: /* Parent process. */
- while (wait (&status) != cpid) /* Wait for kid to finish. */
- /* Do nothing. */ ;
-
- if (status & 0xFFFF)
- {
- errno = EIO; /* /bin/rmdir failed. */
- return -1;
- }
- return 0;
- }
-}
diff --git a/gnu/usr.bin/cvs/lib/myndbm.c b/gnu/usr.bin/cvs/lib/myndbm.c
deleted file mode 100644
index 8069698..0000000
--- a/gnu/usr.bin/cvs/lib/myndbm.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (c) 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.3 kit.
- *
- * A simple ndbm-emulator for CVS. It parses a text file of the format:
- *
- * key value
- *
- * at dbm_open time, and loads the entire file into memory. As such, it is
- * probably only good for fairly small modules files. Ours is about 30K in
- * size, and this code works fine.
- */
-
-#include "cvs.h"
-
-#ifdef MY_NDBM
-
-#ifndef lint
-static char rcsid[] = "@(#)myndbm.c 1.5 92/03/31";
-#endif
-
-static void mydbm_load_file ();
-
-/* ARGSUSED */
-DBM *
-mydbm_open (file, flags, mode)
- char *file;
- int flags;
- int mode;
-{
- FILE *fp;
- DBM *db;
-
- if ((fp = fopen (file, "r")) == NULL)
- return ((DBM *) 0);
-
- db = (DBM *) xmalloc (sizeof (*db));
- db->dbm_list = getlist ();
-
- mydbm_load_file (fp, db->dbm_list);
- (void) fclose (fp);
- return (db);
-}
-
-void
-mydbm_close (db)
- DBM *db;
-{
- dellist (&db->dbm_list);
- free ((char *) db);
-}
-
-datum
-mydbm_fetch (db, key)
- DBM *db;
- datum key;
-{
- Node *p;
- char *s;
- datum val;
-
- /* make sure it's null-terminated */
- s = xmalloc (key.dsize + 1);
- (void) strncpy (s, key.dptr, key.dsize);
- s[key.dsize] = '\0';
-
- p = findnode (db->dbm_list, s);
- if (p)
- {
- val.dptr = p->data;
- val.dsize = strlen (p->data);
- }
- else
- {
- val.dptr = (char *) NULL;
- val.dsize = 0;
- }
- free (s);
- return (val);
-}
-
-datum
-mydbm_firstkey (db)
- DBM *db;
-{
- Node *head, *p;
- datum key;
-
- head = db->dbm_list->list;
- p = head->next;
- if (p != head)
- {
- key.dptr = p->key;
- key.dsize = strlen (p->key);
- }
- else
- {
- key.dptr = (char *) NULL;
- key.dsize = 0;
- }
- db->dbm_next = p->next;
- return (key);
-}
-
-datum
-mydbm_nextkey (db)
- DBM *db;
-{
- Node *head, *p;
- datum key;
-
- head = db->dbm_list->list;
- p = db->dbm_next;
- if (p != head)
- {
- key.dptr = p->key;
- key.dsize = strlen (p->key);
- }
- else
- {
- key.dptr = (char *) NULL;
- key.dsize = 0;
- }
- db->dbm_next = p->next;
- return (key);
-}
-
-static void
-mydbm_load_file (fp, list)
- FILE *fp;
- List *list;
-{
- char line[MAXLINELEN], value[MAXLINELEN];
- char *cp, *vp;
- int len, cont;
-
- for (cont = 0; fgets (line, sizeof (line), fp) != NULL;)
- {
- if ((cp = rindex (line, '\n')) != NULL)
- *cp = '\0'; /* strip the newline */
-
- /*
- * Add the line to the value, at the end if this is a continuation
- * line; otherwise at the beginning, but only after any trailing
- * backslash is removed.
- */
- vp = value;
- if (cont)
- vp += strlen (value);
-
- /*
- * See if the line we read is a continuation line, and strip the
- * backslash if so.
- */
- len = strlen (line);
- if (len > 0)
- cp = &line[len - 1];
- else
- cp = line;
- if (*cp == '\\')
- {
- cont = 1;
- *cp = '\0';
- }
- else
- {
- cont = 0;
- }
- (void) strcpy (vp, line);
- if (value[0] == '#')
- continue; /* comment line */
- vp = value;
- while (*vp && isspace (*vp))
- vp++;
- if (*vp == '\0')
- continue; /* empty line */
-
- /*
- * If this was not a continuation line, add the entry to the database
- */
- if (!cont)
- {
- Node *p = getnode ();
- char *kp;
-
- kp = vp;
- while (*vp && !isspace (*vp))
- vp++;
- *vp++ = '\0'; /* NULL terminate the key */
- p->type = NDBMNODE;
- p->key = xstrdup (kp);
- while (*vp && isspace (*vp))
- vp++; /* skip whitespace to value */
- if (*vp == '\0')
- {
- error (0, 0, "warning: NULL value for key `%s'", p->key);
- freenode (p);
- continue;
- }
- p->data = xstrdup (vp);
- if (addnode (list, p) == -1)
- {
- error (0, 0, "duplicate key found for `%s'", p->key);
- freenode (p);
- }
- }
- }
-}
-
-#endif /* MY_NDBM */
diff --git a/gnu/usr.bin/cvs/lib/myndbm.h b/gnu/usr.bin/cvs/lib/myndbm.h
deleted file mode 100644
index d71acdf..0000000
--- a/gnu/usr.bin/cvs/lib/myndbm.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)myndbm.h 1.3 92/02/29 */
-
-#ifdef MY_NDBM
-
-#define DBLKSIZ 4096
-
-typedef struct
-{
- List *dbm_list; /* cached database */
- Node *dbm_next; /* next key to return for nextkey() */
-} DBM;
-
-typedef struct
-{
- char *dptr;
- int dsize;
-} datum;
-
-/*
- * So as not to conflict with other dbm_open, etc., routines that may
- * be included by someone's libc, all of my emulation routines are prefixed
- * by "my" and we define the "standard" ones to be "my" ones here.
- */
-#define dbm_open mydbm_open
-#define dbm_close mydbm_close
-#define dbm_fetch mydbm_fetch
-#define dbm_firstkey mydbm_firstkey
-#define dbm_nextkey mydbm_nextkey
-
-#if __STDC__
-DBM *mydbm_open (char *file, int flags, int mode);
-void mydbm_close (DBM * db);
-datum mydbm_fetch (DBM * db, datum key);
-datum mydbm_firstkey (DBM * db);
-datum mydbm_nextkey (DBM * db);
-#else
-DBM *mydbm_open ();
-void mydbm_close ();
-datum mydbm_fetch ();
-datum mydbm_firstkey ();
-datum mydbm_nextkey ();
-#endif /* __STDC__ */
-
-#endif /* MY_NDBM */
diff --git a/gnu/usr.bin/cvs/lib/regex.c b/gnu/usr.bin/cvs/lib/regex.c
deleted file mode 100644
index 3bccfd3..0000000
--- a/gnu/usr.bin/cvs/lib/regex.c
+++ /dev/null
@@ -1,4867 +0,0 @@
-/* Extended regular expression matching and search library,
- version 0.4.
- (Implements POSIX draft P10003.2/D11.2, except for multibyte characters.)
-
- Copyright (C) 1985, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if defined (_AIX) && !defined (REGEX_MALLOC)
- #pragma alloca
-#endif
-
-#define _GNU_SOURCE
-
-/* For interactive testing, compile with -Dtest. Then this becomes
- a self-contained program which reads a pattern, describes how it
- compiles, then reads a string and searches for it. If a command-line
- argument is present, it is taken to be the value for obscure_syntax (in
- decimal). The default is 0 (Emacs-style syntax).
-
- If DEBUG is defined, this prints many voluminous messages about what
- it is doing (if the variable `debug' is nonzero). */
-
-
-/* The `emacs' switch turns on certain matching commands
- that make sense only in Emacs. */
-#ifdef emacs
-#include "config.h"
-#include "lisp.h"
-#include "buffer.h"
-#include "syntax.h"
-
-/* Emacs uses `NULL' as a predicate. */
-#undef NULL
-
-#else /* not emacs */
-
-/* POSIX.1 says that <unistd.h> might need <sys/types.h>. We also need
- it for regex.h. */
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if defined (USG) || defined (POSIX) || defined (STDC_HEADERS)
-#ifndef BSTRING
-#include <string.h>
-#ifndef bcopy
-#define bcopy(s,d,n) memcpy ((d), (s), (n))
-#endif
-#ifndef bcmp
-#define bcmp(s1,s2,n) memcmp ((s1), (s2), (n))
-#endif
-#ifndef bzero
-#define bzero(s,n) memset ((s), 0, (n))
-#endif
-#endif /* not BSTRING */
-#endif /* USG or POSIX or STDC_HEADERS */
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else /* not STDC_HEADERS */
-char *malloc ();
-char *realloc ();
-#endif /* not STDC_HEADERS */
-
-/* If debugging, we use standard I/O. */
-#ifdef DEBUG
-#include <stdio.h>
-#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(3) etc. are used for the character classes. */
-#include <ctype.h>
-#ifndef isgraph
-#define isgraph(c) (isprint (c) && !isspace (c))
-#endif
-#ifndef isblank
-#define isblank(c) ((c) == ' ' || (c) == '\t')
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef SIGN_EXTEND_CHAR
-#ifdef __CHAR_UNSIGNED__ /* for, e.g., IBM RT */
-#define SIGN_EXTEND_CHAR(c) (((c)^128) - 128) /* As in Harbison and Steele. */
-#else
-#define SIGN_EXTEND_CHAR /* As nothing. */
-#endif /* not CHAR_UNSIGNED */
-#endif /* not SIGN_EXTEND_CHAR */
-
-/* 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, size) (realloc (source, size))
-
-#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__ */
-#ifdef sparc
-#include <alloca.h>
-#else /* not __GNUC__ or sparc */
-char *alloca ();
-#endif /* not sparc */
-#endif /* not __GNUC__ */
-
-#endif /* not alloca */
-
-/* Still not REGEX_MALLOC. */
-
-#define REGEX_ALLOCATE alloca
-
-/* Requires a `char *destination' declared. */
-#define REGEX_REALLOCATE(source, size) \
- (destination = (char *) alloca (size), \
- bcopy (source, destination, size), \
- destination)
-
-#endif /* not REGEX_MALLOC */
-
-/* (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 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))
-
-/* 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. */
- no_pop_jump,
-
- /* Same as no_pop_jump, but marks the end of an alternative. */
- jump_past_next_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. */
- 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 no_pop_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,
-
- /* Used like on_failure_jump except has to succeed n times; The
- two-byte relative address following it is useless until then.
- The address is followed by two more bytes containing n. */
- succeed_n,
-
- /* Similar to no_pop_jump, but jump n times only; also the
- relative address following is in turn followed by yet two
- more bytes containing n. */
- no_pop_jump_n,
-
- /* Set the following relative location (two bytes) to the
- subsequent (two-byte) 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 (*(const char *)((source) + 1)) << 8;\
- } while (0)
-
-#ifdef DEBUG
-static int
-extract_number (source)
- unsigned char *source;
-{
- int answer = *source & 0377;
- answer += (SIGN_EXTEND_CHAR (*(char *)((source) + 1))) << 8;
-
- return answer;
-}
-#endif
-
-
-/* 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 (destination, source)
- int *destination;
- unsigned char **source;
-{
- *destination = extract_number (*source);
- *source += 2;
-}
-#endif
-
-
-/* Is true if there is a first string and if PTR is pointing anywhere
- inside it or just past the end. */
-
-#define IS_IN_FIRST_STRING(ptr) \
- (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
-
-#ifdef DEBUG
-
-extern void printchar ();
-
-/* Print a compiled pattern buffer in human-readable form, starting at
- the START pointer into it and ending just before the pointer END. */
-
-static void
-partial_compiled_pattern_printer (pbufp, start, end)
- struct re_pattern_buffer *pbufp;
- unsigned char *start;
- unsigned char *end;
-{
-
- int mcnt, mcnt2;
- unsigned char *p = start;
- unsigned char *pend = end;
-
- if (start == NULL)
- {
- printf ("(null)\n");
- return;
- }
-
- /* This loop loops over pattern commands. */
- while (p < pend)
- {
- 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;
-
- printf ("/charset%s/", *(p - 1) == charset_not ? "_not" : "");
-
- for (c = 0; p < pend && c < *p * BYTEWIDTH; c++)
- {
- if (p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
- printchar (c);
- }
- 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/0/%d", mcnt);
- break;
-
- case on_failure_keep_string_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/on_failure_keep_string_jump/0/%d", mcnt);
- break;
-
- case dummy_failure_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/dummy_failure_jump/0/%d", mcnt);
- break;
-
- case maybe_pop_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/maybe_pop_jump/0/%d", mcnt);
- break;
-
- case pop_failure_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/pop_failure_jump/0/%d", mcnt);
- break;
-
- case jump_past_next_alt:
- extract_number_and_incr (&mcnt, &p);
- printf ("/jump_past_next_alt/0/%d", mcnt);
- break;
-
- case no_pop_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/no_pop_jump/0/%d", mcnt);
- break;
-
- case succeed_n:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2);
- break;
-
- case no_pop_jump_n:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/no_pop_jump_n/0/%d/0/%d", mcnt, mcnt2);
- break;
-
- case set_number_at:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/set_number_at/0/%d/0/%d", mcnt, 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 wordchar:
- printf ("/wordchar-emacs");
- mcnt = (int) Sword;
- break;
-
- case syntaxspec:
- printf ("/syntaxspec");
- mcnt = *p++;
- printf ("/%d", mcnt);
- break;
-
- case notwordchar:
- printf ("/notwordchar-emacs");
- mcnt = (int) Sword;
- break;
-
- case notsyntaxspec:
- printf ("/notsyntaxspec");
- mcnt = *p++;
- printf ("/%d", mcnt);
- break;
-#else /* not emacs */
- case wordchar:
- printf ("/wordchar-notemacs");
- break;
-
- case notwordchar:
- printf ("/notwordchar-notemacs");
- break;
-#endif /* not emacs */
-
- case begbuf:
- printf ("/begbuf");
- break;
-
- case endbuf:
- printf ("/endbuf");
- break;
-
- default:
- printf ("?%d", *(p-1));
- }
- }
- printf ("/\n");
-}
-
-static void
-compiled_pattern_printer (pbufp)
- struct re_pattern_buffer *pbufp;
-{
- partial_compiled_pattern_printer (pbufp, pbufp->buffer,
- pbufp->buffer + pbufp->used);
-}
-
-
-static void
-double_string_printer (where, string1, size1, string2, size2)
- unsigned char *where;
- unsigned char *string1;
- unsigned char *string2;
- int size1;
- int size2;
-{
- unsigned this_char;
-
- if (where == NULL)
- printf ("(null)");
- else
- {
- if (IS_IN_FIRST_STRING (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]);
- }
-}
-
-#endif /* DEBUG */
-
-#ifdef DEBUG
-
-/* It is useful to test things that must to 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_COMPILED_PATTERN_PRINTER(p, s, e) \
- if (debug) partial_compiled_pattern_printer (p, s, e)
-#define DEBUG_DOUBLE_STRING_PRINTER(w, s1, sz1, s2, sz2) \
- if (debug) double_string_printer (w, s1, sz1, s2, sz2)
-
-#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_COMPILED_PATTERN_PRINTER(p, s, e)
-#define DEBUG_DOUBLE_STRING_PRINTER(w, s1, sz1, s2, sz2)
-
-#endif /* not DEBUG */
-
-typedef char boolean;
-#define false 0
-#define true 1
-
-/* Set by re_set_syntax to the current regexp syntax to recognize. Can
- also be assigned to more or less arbitrarily. Since we use this as a
- collection of bits, declaring it unsigned maximizes portability. */
-reg_syntax_t obscure_syntax = 0;
-
-
-/* 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 = obscure_syntax;
-
- obscure_syntax = 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 */
- };
-
-/* Other subroutine declarations and macros for regex_compile. */
-
-static void store_jump (), insert_jump (), store_jump_n (),
- insert_jump_n (), insert_op_2 ();
-
-static boolean at_endline_op_p (), group_in_compile_stack ();
-
-/* 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 PAT_PUSH(c) \
- do { \
- GET_BUFFER_SPACE (1); \
- *b++ = (unsigned char) (c); \
- } while (0)
-
-
-/* Make sure we have two more bytes of buffer space and then add C1 and
- C2 to it. */
-#define PAT_PUSH_2(c1, c2) \
- do { \
- GET_BUFFER_SPACE (2); \
- *b++ = (unsigned char) (c1); \
- *b++ = (unsigned char) (c2); \
- } while (0)
-
-
-/* Make sure we have two more bytes of buffer space and then add C1, C2
- and C3 to it. */
-#define PAT_PUSH_3(c1, c2, c3) \
- do { \
- GET_BUFFER_SPACE (3); \
- *b++ = (unsigned char) (c1); \
- *b++ = (unsigned char) (c2); \
- *b++ = (unsigned char) (c3); \
- } while (0)
-
-/* This is not an arbitrary limit: the arguments to the opcodes 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. */
-#define MAX_BUF_SIZE (1L << 16)
-
-/* 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. */
-typedef unsigned char regnum_t;
-#define MAX_REGNUM ((regnum_t) ((1 << BYTEWIDTH) - 1))
-
-
-/* Macros for the compile stack. */
-
-/* This type needs to be able to hold values from 0 to MAX_BUF_SIZE - 1. */
-typedef short 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[(c) / BYTEWIDTH] |= 1 << ((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); \
- } \
- } \
- }
-
-
-/* Read the endpoint of a range from the uncompiled pattern and set the
- corresponding bits in the compiled pattern. */
-
-#define DO_RANGE \
- { \
- char end; \
- char this_char = p[-2]; \
- \
- if (p == pend) \
- return REG_ERANGE; \
- PATFETCH (end); \
- if (syntax & RE_NO_EMPTY_RANGES && this_char > end) \
- return REG_ERANGE; \
- while (this_char <= end) \
- { \
- SET_LIST_BIT (TRANSLATE (this_char)); \
- this_char++; \
- } \
- }
-
-
-#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"))
-
-
-/* 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 set to zero;
- `re_nsub' is set to the number of groups in PATTERN;
- `not_bol' and `not_eol' are set to 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;
- int size;
- reg_syntax_t syntax;
- struct re_pattern_buffer *bufp;
-{
- register unsigned char c, c1;
- const char *p1;
-
- /* Points to the end of the buffer, where we should append. */
- register unsigned char *b;
-
- /* 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;
-
- /* Place in the uncompiled pattern (i.e., the {) to
- which to go back if the interval is invalid. */
- const char *beg_interval; /* The `{'. */
- const char *following_left_brace;
-
- /* Address of beginning of regexp, or inside of last group. */
- unsigned char *begalt;
-
- /* 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. The type
- here is determined by MAX_REGNUM. */
- regnum_t regnum = 0;
-
- /* Keeps track of unclosed groups. */
- compile_stack_type compile_stack;
-
-#ifdef DEBUG
- DEBUG_PRINT1 ("\nCompiling pattern: ");
- if (debug)
- {
- unsigned debug_count;
-
- for (debug_count = 0; debug_count < size; debug_count++)
- printchar (pattern[debug_count]);
-
- DEBUG_PRINT1 ("\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)
- { /* EXTEND_BUFFER loses when bufp->allocated is 0. 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)
- {
- /* ^ matches the empty string at the beginning of a string (or
- possibly a line). If RE_CONTEXT_INDEP_ANCHORS is set, ^ is
- always an operator (and foo^bar is unmatchable). If that bit
- isn't set, it's an operator only at the beginning of the
- pattern or after an alternation or open-group operator, or,
- if RE_NEWLINE_ORDINARY is not set, after a newline (except it
- can be preceded by other operators that match the empty
- string); otherwise, it's a normal character. */
- case '^':
- {
- if ( /* If at start of (sub)pattern, it's an operator. */
- laststart == 0
- /* If context independent, it's an operator. */
- || syntax & RE_CONTEXT_INDEP_ANCHORS
- /* If after a newline, might be an operator. (Since
- laststart is nonzero here, we know we have at
- least one byte before the ^.) */
- || (!(syntax & RE_NEWLINE_ORDINARY) && p[-2] == '\n'))
- PAT_PUSH (begline);
- else
- goto normal_char;
- }
- break;
-
-
- /* $ matches the empty string following the end of the string (or
- possibly a line). It follows rules dual to those for ^. */
- 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_op_p (p, pend, syntax))
- PAT_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);
-
- /* Get 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 ('.')
- && p < pend && TRANSLATE (*p) == TRANSLATE ('\n')
- && !(syntax & RE_DOT_NEWLINE))
- { /* We have .*\n. */
- store_jump (b, no_pop_jump, laststart);
- keep_string_p = true;
- }
- else
- /* Anything else. */
- store_jump (b, maybe_pop_jump, 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, b);
- pending_exact = 0;
- b += 3;
-
- if (!zero_times_ok)
- {
- /* At least one repetition is required, so insert a
- dummy_failure 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);
- b += 3;
- }
- }
- break;
-
-
- case '.':
- laststart = b;
- PAT_PUSH (anychar);
- break;
-
-
- case '[':
- {
- boolean just_had_a_char_class = false;
-
- if (p == pend) return REG_EBRACK;
-
- /* Ensure that we have enough space to push an entire
- charset: the opcode, the byte count, and the bitmap. */
- while (b - bufp->buffer + 2 + (1 << BYTEWIDTH) / BYTEWIDTH
- > bufp->allocated)
- EXTEND_BUFFER ();
-
- laststart = b;
-
- PAT_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. */
- PAT_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 (just_had_a_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 != ']')
- {
- DO_RANGE;
- }
-
- else if (p[0] == '-' && p[1] != ']')
- { /* This handles ranges made up of characters only. */
- PATFETCH (c1); /* The `-'. */
- DO_RANGE;
- }
-
- /* 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);
- }
- just_had_a_char_class = true;
- }
- else
- {
- c1++;
- while (c1--)
- PATUNFETCH;
- SET_LIST_BIT ('[');
- SET_LIST_BIT (':');
- just_had_a_char_class = false;
- }
- }
- else
- {
- just_had_a_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_bar;
- else
- goto normal_char;
-
-
- case '|':
- if (syntax & RE_NO_BK_VBAR)
- goto handle_bar;
- 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:
- if (syntax & RE_NO_EMPTY_GROUPS)
- {
- p1 = p;
- if (!(syntax & RE_NO_BK_PARENS) && *p1 == '\\') p1++;
-
- /* If found an empty group... */
- if (*p1 == ')') return REG_BADPAT;
- }
-
- 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. */
- if (regnum <= MAX_REGNUM)
- {
- COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2;
- PAT_PUSH_3 (start_memory, regnum, 0);
- }
-
- compile_stack.avail++;
-
- fixup_alt_jump = 0;
- laststart = 0;
- begalt = b;
- 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)
- store_jump (fixup_alt_jump, jump_past_next_alt, b);
-
- /* 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;
-
- /* 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;
- PAT_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_bar:
- if (syntax & RE_LIMITED_OPS)
- goto normal_char;
-
- /* Disallow empty alternatives if RE_NO_EMPTY_ALTS is set.
- Caveat: can't detect if the vbar is followed by a
- trailing '$' yet, unless it's the last thing in a
- pattern; the routine for verifying endlines has to do
- the rest. */
- if ((syntax & RE_NO_EMPTY_ALTS)
- && (!laststart || p == pend
- || (*p == '$' && p + 1 == pend)
- || ((syntax & RE_NO_BK_PARENS)
- ? (p < pend && *p == ')')
- : (p + 1 < pend && p[0] == '\\' && p[1] == ')'))))
- return REG_BADPAT;
-
- /* 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, b);
- 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 (fixup_alt_jump, jump_past_next_alt, 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 intervals must be allowed. */
-
- /* For intervals, at least (most) this many matches must
- be made. */
- int lower_bound = -1, upper_bound = -1;
-
- beg_interval = p - 1; /* The `{'. */
- following_left_brace = NULL;
-
- 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;
- }
-
- if (upper_bound < 0)
- 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 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 this jump is inserted. */
- if (upper_bound == 0)
- {
- GET_BUFFER_SPACE (3);
- insert_jump (no_pop_jump, laststart, b + 3, b);
- b += 3;
- }
-
- /* Otherwise, after lower_bound number of succeeds, jump
- to after the no_pop_jump_n which will be inserted at
- the end of the buffer, and insert that
- no_pop_jump_n. */
- else
- { /* Set to 5 if only one repetition is allowed and
- hence no no_pop_jump_n is inserted at the current
- end of the buffer. Otherwise, need 10 bytes total
- for the succeed_n and the no_pop_jump_n. */
- unsigned slots_needed = upper_bound == 1 ? 5 : 10;
-
- GET_BUFFER_SPACE (slots_needed);
- /* Initialize the succeed_n to n, even though it will
- be set by its attendant set_number_at, because
- re_compile_fastmap will need to know it. Jump to
- what the end of buffer will be after inserting
- this succeed_n and possibly appending a
- no_pop_jump_n. */
- insert_jump_n (succeed_n, laststart, b + slots_needed,
- b, lower_bound);
- b += 5; /* Just increment for the succeed_n here. */
-
-
- /* More than one repetition is allowed, so put in at
- the end of the buffer a backward jump from b to the
- succeed_n we put in above. By the time we've gotten
- to this jump when matching, we'll have matched once
- already, so jump back only upper_bound - 1 times. */
- if (upper_bound > 1)
- {
- store_jump_n (b, no_pop_jump_n, laststart,
- upper_bound - 1);
- b += 5;
-
- /* When hit this when matching, reset the
- preceding no_pop_jump_n's n to upper_bound - 1. */
- PAT_PUSH (set_number_at);
-
- /* Only need to get space for the numbers. */
- GET_BUFFER_SPACE (4);
- STORE_NUMBER_AND_INCR (b, -5);
- STORE_NUMBER_AND_INCR (b, upper_bound - 1);
- }
-
- /* When hit this when matching, set the succeed_n's n. */
- GET_BUFFER_SPACE (5);
- insert_op_2 (set_number_at, laststart, b, 5, lower_bound);
- b += 5;
- }
- pending_exact = 0;
- beg_interval = NULL;
-
- if (following_left_brace)
- goto normal_char;
- }
- 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 '=':
- PAT_PUSH (at_dot);
- break;
-
- case 's':
- laststart = b;
- PATFETCH (c);
- PAT_PUSH_2 (syntaxspec, syntax_spec_code[c]);
- break;
-
- case 'S':
- laststart = b;
- PATFETCH (c);
- PAT_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
- break;
-#endif /* emacs */
-
-
- case 'w':
- laststart = b;
- PAT_PUSH (wordchar);
- break;
-
-
- case 'W':
- laststart = b;
- PAT_PUSH (notwordchar);
- break;
-
-
- case '<':
- PAT_PUSH (wordbeg);
- break;
-
- case '>':
- PAT_PUSH (wordend);
- break;
-
- case 'b':
- PAT_PUSH (wordbound);
- break;
-
- case 'B':
- PAT_PUSH (notwordbound);
- break;
-
- case '`':
- PAT_PUSH (begbuf);
- break;
-
- case '\'':
- PAT_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)
- {
- if (syntax & RE_NO_MISSING_BK_REF)
- return REG_ESUBREG;
- else
- goto normal_char;
- }
-
- /* Can't back reference to a subexpression if inside of it. */
- if (group_in_compile_stack (compile_stack, c1))
- goto normal_char;
-
- laststart = b;
- PAT_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;
-
- PAT_PUSH_2 (exactn, 0);
- pending_exact = b - 1;
- }
-
- PAT_PUSH (c);
- (*pending_exact)++;
- break;
- } /* switch (c) */
- } /* while p != pend */
-
-
- /* Through the pattern now. */
-
- if (fixup_alt_jump)
- store_jump (fixup_alt_jump, jump_past_next_alt, 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;
- return REG_NOERROR;
-} /* regex_compile */
-
-/* Subroutines for regex_compile. */
-
-/* Store a jump of the form <OPCODE> <relative address>.
- Store in the location FROM a jump operation to jump to relative
- address FROM - TO. OPCODE is the opcode to store. */
-
-static void
-store_jump (from, op, to)
- unsigned char *from, *to;
- re_opcode_t op;
-{
- from[0] = (unsigned char) op;
- STORE_NUMBER (from + 1, to - (from + 3));
-}
-
-
-/* Open up space before char FROM, and insert there a jump to TO.
- CURRENT_END gives the end of the storage not in use, so we know
- how much data to copy up. OP is the opcode of the jump to insert.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-insert_jump (op, from, to, current_end)
- re_opcode_t op;
- unsigned char *from, *to, *current_end;
-{
- register unsigned char *pfrom = current_end; /* Copy from here... */
- register unsigned char *pto = current_end + 3; /* ...to here. */
-
- while (pfrom != from)
- *--pto = *--pfrom;
-
- store_jump (from, op, to);
-}
-
-
-/* Store a jump of the form <opcode> <relative address> <n>.
-
- Store in the location FROM a jump operation to jump to relative
- address FROM - TO. OPCODE is the opcode to store, N is a number the
- jump uses, say, to decide how many times to jump.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-store_jump_n (from, op, to, n)
- unsigned char *from, *to;
- re_opcode_t op;
- unsigned n;
-{
- from[0] = (unsigned char) op;
- STORE_NUMBER (from + 1, to - (from + 3));
- STORE_NUMBER (from + 3, n);
-}
-
-
-/* Similar to insert_jump, but handles a jump which needs an extra
- number to handle minimum and maximum cases. Open up space at
- location FROM, and insert there a jump to TO. CURRENT_END gives the
- end of the storage in use, so we know how much data to copy up. OP is
- the opcode of the jump to insert.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-insert_jump_n (op, from, to, current_end, n)
- re_opcode_t op;
- unsigned char *from, *to, *current_end;
- unsigned n;
-{
- register unsigned char *pfrom = current_end;
- register unsigned char *pto = current_end + 5;
-
- while (pfrom != from)
- *--pto = *--pfrom;
-
- store_jump_n (from, op, to, n);
-}
-
-
-/* Open up space at location THERE, and insert operation OP followed by
- NUM_1 and NUM_2. CURRENT_END gives the end of the storage in use, so
- we know how much data to copy up.
-
- If you call this function, you must zero out pending_exact. */
-
-static void
-insert_op_2 (op, there, current_end, num_1, num_2)
- re_opcode_t op;
- unsigned char *there, *current_end;
- int num_1, num_2;
-{
- register unsigned char *pfrom = current_end;
- register unsigned char *pto = current_end + 5;
-
- while (pfrom != there)
- *--pto = *--pfrom;
-
- there[0] = (unsigned char) op;
- STORE_NUMBER (there + 1, num_1);
- STORE_NUMBER (there + 3, num_2);
-}
-
-
-/* Return true if the pattern position P is at a close-group or
- alternation operator, or if it is a newline and RE_NEWLINE_ORDINARY
- is not set in SYNTAX. Before checking, though, we skip past all
- operators that match the empty string.
-
- This is not quite the dual of what happens with ^. There, we can
- easily check if the (sub)pattern so far can match only the empty
- string, because we have seen the pattern, and `laststart' is set to
- exactly that. But we cannot easily look at the pattern yet to come
- to see if it matches the empty string; that would require us to compile
- the pattern, then go back and analyze the pattern after every
- endline. POSIX required this at one point (that $ be in a
- ``trailing'' position to be considered an anchor), so we implemented
- it, but it was slow and took lots of code, and we were never really
- convinced it worked in all cases. So now it's gone, and we live with
- the slight inconsistency between ^ and $. */
-
-static boolean
-at_endline_op_p (p, pend, syntax)
- const char *p, *pend;
- int syntax;
-{
- boolean context_indep = !!(syntax & RE_CONTEXT_INDEP_ANCHORS);
-
- /* Skip past operators that match the empty string. (Except we don't
- handle empty groups.) */
- while (p < pend)
- {
- if (context_indep && (*p == '^' || *p == '$'))
- p++;
-
- /* All others start with \. */
- else if (*p == '\\' && p + 1 < pend
- && (p[1] == 'b' || p[1] == 'B'
- || p[1] == '<' || p[1] == '>'
- || p[1] == '`' || p[1] == '\''
-#ifdef emacs
- || p[1] == '='
-#endif
- ))
- p += 2;
-
- else /* Not an empty string operator. */
- break;
- }
-
- /* See what we're at now. */
- return p < pend
- && ((!(syntax & RE_NEWLINE_ORDINARY) && *p == '\n')
- || (syntax & RE_NO_BK_PARENS
- ? *p == ')'
- : *p == '\\' && p + 1 < pend && p[1] == ')')
- || (syntax & RE_NO_BK_VBAR
- ? *p == '|'
- : (*p == '\\' && p + 1 < pend && p[1] == '|')));
-}
-
-
-/* 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;
-}
-
-/* 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 *failure_stack_elt_t;
-
-typedef struct
-{
- failure_stack_elt_t *stack;
- unsigned size;
- unsigned avail; /* Offset of next open position. */
-} failure_stack_type;
-
-#define FAILURE_STACK_EMPTY() (failure_stack.avail == 0)
-#define FAILURE_STACK_PTR_EMPTY() (failure_stack_ptr->avail == 0)
-#define FAILURE_STACK_FULL() (failure_stack.avail == failure_stack.size)
-#define FAILURE_STACK_TOP() (failure_stack.stack[failure_stack.avail])
-
-
-/* Initialize FAILURE_STACK. Return 1 if success, 0 if not. */
-
-#define INIT_FAILURE_STACK(failure_stack) \
- ((failure_stack).stack = (failure_stack_elt_t *) \
- REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (failure_stack_elt_t)), \
- (failure_stack).stack == NULL \
- ? 0 \
- : ((failure_stack).size = INIT_FAILURE_ALLOC, \
- (failure_stack).avail = 0, \
- 1))
-
-
-/* Double the size of FAILURE_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_FAILURE_STACK(failure_stack) \
- ((failure_stack).size > re_max_failures * MAX_FAILURE_ITEMS \
- ? 0 \
- : ((failure_stack).stack = (failure_stack_elt_t *) \
- REGEX_REALLOCATE ((failure_stack).stack, \
- ((failure_stack).size << 1) * sizeof (failure_stack_elt_t)), \
- \
- (failure_stack).stack == NULL \
- ? 0 \
- : ((failure_stack).size <<= 1, \
- 1)))
-
-
-/* Push PATTERN_OP on FAILURE_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, failure_stack) \
- ((FAILURE_STACK_FULL () \
- && !DOUBLE_FAILURE_STACK (failure_stack)) \
- ? 0 \
- : ((failure_stack).stack[(failure_stack).avail++] = pattern_op, \
- 1))
-
-/* This pushes an item onto the failure stack. Must be a four-byte
- value. Assumes the variable `failure_stack'. Probably should only
- be called from within `PUSH_FAILURE_POINT'. */
-#define PUSH_FAILURE_ITEM(item) \
- failure_stack.stack[failure_stack.avail++] = (failure_stack_elt_t) item
-
-/* The complement operation. Assumes stack is nonempty, and pointed to
- `failure_stack_ptr'. */
-#define POP_FAILURE_ITEM() \
- failure_stack_ptr->stack[--failure_stack_ptr->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 failure_stack, regstart, regend, reg_info, and
- num_regs be declared. DOUBLE_FAILURE_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. */ \
- int this_reg; \
- \
- DEBUG_STATEMENT (failure_id++); \
- DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \
- DEBUG_PRINT2 (" Before push, next avail: %d\n", (failure_stack).avail);\
- DEBUG_PRINT2 (" size: %d\n", (failure_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_FAILURE_STACK (failure_stack)) \
- return failure_code; \
- \
- DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \
- (failure_stack).size); \
- DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\
- } \
- \
- /* Push the info, starting with the registers. */ \
- DEBUG_PRINT1 ("\n"); \
- \
- 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_nothing=%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); \
- } \
- \
- 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_COMPILED_PATTERN_PRINTER (bufp, pattern_place, pend); \
- PUSH_FAILURE_ITEM (pattern_place); \
- \
- DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \
- DEBUG_DOUBLE_STRING_PRINTER (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)
-
-/* 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 \
- ((failure_stack).size - (failure_stack).avail)
-
-/* 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. The other components of BUFP describe the
- pattern to be used.
-
- We set the `can_be_null' and `fastmap_accurate' fields in the pattern
-
- Returns 0 if it can compile a fastmap. Returns -2 if there is an
- internal error. */
-
-int
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
-{
- int j, k;
- failure_stack_type failure_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;
- unsigned long size = bufp->used;
- const unsigned char *p = pattern;
- register unsigned char *pend = pattern + size;
-
- INIT_FAILURE_STACK (failure_stack);
-
- bzero (fastmap, 1 << BYTEWIDTH);
- bufp->fastmap_accurate = 1; /* It will be when we're done. */
- bufp->can_be_null = 0;
-
- while (p)
- {
- boolean is_a_succeed_n = false;
-
- if (p == pend)
- if (FAILURE_STACK_EMPTY ())
- {
- bufp->can_be_null = 1;
- break;
- }
- else
- p = failure_stack.stack[--failure_stack.avail];
-
-#ifdef SWITCH_ENUM_BUG
- switch ((int) ((re_opcode_t) *p++))
-#else
- switch ((re_opcode_t) *p++)
-#endif
- {
- 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 no_op:
- case begline:
- case begbuf:
- case endbuf:
- case wordbound:
- case notwordbound:
- case wordbeg:
- case wordend:
- continue;
-
-
- case endline:
- if (!bufp->can_be_null)
- bufp->can_be_null = 2;
- break;
-
-
- case no_pop_jump_n:
- case pop_failure_jump:
- case maybe_pop_jump:
- case no_pop_jump:
- case jump_past_next_alt:
- case dummy_failure_jump:
- EXTRACT_NUMBER_AND_INCR (j, p);
- p += j;
- if (j > 0)
- continue;
-
- /* Jump backward reached implies we just went through
- the body of a loop and matched nothing. Opcode jumped to
- should be an 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 (!FAILURE_STACK_EMPTY ()
- && failure_stack.stack[failure_stack.avail - 1] == p)
- failure_stack.avail--;
-
- continue;
-
-
- case on_failure_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 there can't be any more
- possibilities for the fastmap beyond pend. */
- if (p + j < pend)
- {
- if (!PUSH_PATTERN_OP (p + j, failure_stack))
- return -2;
- }
-
- if (is_a_succeed_n)
- EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */
-
- continue;
-
-
- case succeed_n:
- is_a_succeed_n = true;
-
- /* 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;
- goto handle_on_failure_jump;
- }
- continue;
-
-
- case set_number_at:
- p += 4;
- continue;
-
-
- case start_memory:
- case stop_memory:
- p += 2;
- continue;
-
-
- /* I don't understand this case (any of it). --karl */
- case duplicate:
- bufp->can_be_null = 1;
- fastmap['\n'] = 1;
-
-
- case anychar:
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- if (j != '\n')
- fastmap[j] = 1;
- if (bufp->can_be_null)
- return 0;
-
- /* Don't return; check the alternative paths
- so we can set can_be_null if appropriate. */
- 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;
-
-
-#ifdef emacs
- case before_dot:
- case at_dot:
- case after_dot:
- continue;
-
-
- 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;
-#endif /* not emacs */
-
- default:
- abort ();
- } /* switch *p++ */
-
- /* Getting here means we have successfully found the possible starting
- characters of one path of the pattern. We need not follow this
- path any farther. Instead, look at the next alternative
- remembered in the stack, or quit. The test at the top of the
- loop does these things. */
- p = pend;
- } /* while p */
-
- return 0;
-} /* re_compile_fastmap */
-
-/* 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;
-
- /* Update the fastmap now if not correct already. */
- if (fastmap && !bufp->fastmap_accurate)
- if (re_compile_fastmap (bufp) == -2)
- return -2;
-
- /* If the search isn't to be a backwards one, don't waste time in a
- long search for a pattern that says it is anchored. */
- if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf
- && range > 0)
- {
- if (startpos > 0)
- return -1;
- else
- range = 1;
- }
-
- 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 want to skip over 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[*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 (translate
- ? !fastmap[(unsigned char) translate[(unsigned char) c]]
- : !fastmap[(unsigned char) 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 == 0)
- 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 */
-
-/* Declarations and macros for re_match_2. */
-
-static int bcmp_translate ();
-static boolean alt_match_null_string_p (),
- common_op_match_null_string_p (),
- group_match_null_string_p ();
-static void pop_failure_point ();
-
-
-/* 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. */
-typedef union
-{
- failure_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_NOTHING_UNSET_VALUE'. */
-#define MATCH_NOTHING_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)
-
-
-/* Call this when have matched something; it sets `matched' flags for the
- registers corresponding to the group of which we currently are inside.
- Also records whether this group ever matched something. We only care
- about this information at `stop_memory', and then only about the
- previous time through the loop (if the group is starred or whatever).
- So it is ok to clear all the nonactive registers here. */
-#define SET_REGS_MATCHED() \
- do \
- { \
- unsigned 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 a pointer into one or the other of the strings into an
- offset from the beginning of that string. */
-#define POINTER_TO_OFFSET(pointer) IS_IN_FIRST_STRING (pointer) \
- ? (pointer) - string1 \
- : (pointer) - string2 + size1
-
-/* Registers are set to a sentinel value when they haven't yet matched
- anything. */
-#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 there is only one string, we've put it in
- string2. */
-#define AT_STRINGS_BEG (d == (size1 ? string1 : string2) || !size2)
-#define AT_STRINGS_END (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.
-
- We assume there is a string1, so use this in conjunction with
- AT_STRINGS_BEG. */
-#define LETTER_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 || AT_STRINGS_END || LETTER_P (d - 1) != LETTER_P (d))
-
-
-/* Free everything we malloc. */
-#ifdef REGEX_MALLOC
-#define FREE_VARIABLES() \
- do { \
- free (failure_stack.stack); \
- free (regstart); \
- free (regend); \
- free (old_regstart); \
- free (old_regend); \
- free (reg_info); \
- free (best_regstart); \
- free (best_regend); \
- reg_info = NULL; \
- failure_stack.stack = NULL; \
- regstart = regend = old_regstart = old_regend \
- = best_regstart = best_regend = NULL; \
- } while (0)
-#else /* not REGEX_MALLOC */
-#define FREE_VARIABLES() /* As nothing, since we use alloca. */
-#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)
- const 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. (If
- BUFP->caller_allocated_regs is nonzero, we fill REGS->num_regs
- registers; if zero, we set REGS->num_regs to max (RE_NREGS,
- re_nsub+1) and allocate the space with malloc before filling.)
-
- 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)
- const 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. */
- failure_stack_type failure_stack;
-#ifdef DEBUG
- static unsigned failure_id = 0;
-#endif
-
- /* We fill all the registers internally, independent of what we
- return, for use in backreferences. The number here includes
- register zero. */
- unsigned num_regs = bufp->re_nsub + 1;
-
- /* The currently active registers. */
- unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- unsigned 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
- = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *));
- const char **regend
- = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *));
-
- /* 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
- = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *));
- const char **old_regend
- = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *));
-
- /* 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 = (register_info_type *)
- REGEX_ALLOCATE (num_regs * sizeof (register_info_type));
-
- /* 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 = 0;
- const char **best_regstart
- = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *));
- const char **best_regend
- = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *));
-
- /* Used when we pop values we don't care about. */
- const char **reg_dummy
- = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *));
- register_info_type *reg_info_dummy = (register_info_type *)
- REGEX_ALLOCATE (num_regs * sizeof (register_info_type));
-
-#ifdef DEBUG
- /* Counts the total number of registers pushed. */
- unsigned num_regs_pushed = 0;
-#endif
-
- DEBUG_PRINT1 ("\n\nEntering re_match_2.\n");
-
- if (!INIT_FAILURE_STACK (failure_stack))
- return -2;
-
- if (!(regstart && regend && old_regstart && old_regend && reg_info
- && best_regstart && best_regend))
- {
- FREE_VARIABLES ();
- return -2;
- }
-
- /* 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
- \( or ( and \) or ) has been seen for. Also set all registers to
- inactive and mark them as not having any inner groups, able to
- match the empty string, matched anything so far, or ever failed. */
- for (mcnt = 0; 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_NOTHING_UNSET_VALUE;
- IS_ACTIVE (reg_info[mcnt]) = 0;
- MATCHED_SOMETHING (reg_info[mcnt]) = 0;
- EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
- }
-
- IS_ACTIVE (reg_info[0]) = 1;
-
- /* 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_COMPILED_PATTERN_PRINTER (bufp, p, pend);
- DEBUG_PRINT1 ("The string to match is: `");
- DEBUG_DOUBLE_STRING_PRINTER (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 not end of string, try backtracking. Otherwise done. */
- if (d != end_match_2)
- {
- DEBUG_PRINT1 ("backtracking.\n");
-
- if (!FAILURE_STACK_EMPTY ())
- { /* More failure points to try. */
-
- boolean in_same_string =
- IS_IN_FIRST_STRING (best_regend[0])
- == MATCHING_IN_FIRST_STRING;
-
- /* If exceeds best match so far, save it. */
- if (!best_regs_set
- || (in_same_string && d > best_regend[0])
- || (!in_same_string && !MATCHING_IN_FIRST_STRING))
- {
- best_regs_set = 1;
- best_regend[0] = d; /* Never use regstart[0]. */
-
- 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. */
- d = best_regend[0];
-
- if (d >= string1 && d <= end1)
- dend = end_match_1;
-
- for (mcnt = 0; 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)
- {
- /* If they haven't allocated it, we'll do it. */
- if (!bufp->caller_allocated_regs)
- {
- 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;
- }
-
- /* 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 at the
- beginning. */
- 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
- it than were in the pattern, set the extra elements to
- -1. If we allocated the registers, this is the case,
- because we always allocate enough to have at least -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_PRINT2 ("%d 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 anything but 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 ();
- 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. */
-
- if (c < (unsigned char) (*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_NOTHING_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;
-
- /* This loop will always terminate, because register 0 is
- always active. */
- assert (IS_ACTIVE (reg_info[0]));
- while (!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)
- highest_active_reg = r;
- else
- {
- lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- highest_active_reg = NO_HIGHEST_ACTIVE_REG;
- }
- }
-
- /* 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 no_pop_jump_n:
- is_a_jump_n = true;
- case pop_failure_jump:
- case maybe_pop_jump:
- case no_pop_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 ((int) old_regend[r] >= (int) regstart[r])
- regend[r] = old_regend[r];
- }
- }
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- PUSH_FAILURE_POINT (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 = ((IS_IN_FIRST_STRING (regstart[regno])
- == IS_IN_FIRST_STRING (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)
- {
- 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)
- {
- 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)
- break;
- goto fail;
-
-
- /* Match at the very end of the data. */
- case endbuf:
- DEBUG_PRINT1 ("EXECUTING endbuf.\n");
- if (AT_STRINGS_END)
- 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
- go through the hassle of checking 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);
- 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 only 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);
- break;
-
-
- /* A smart repeat ends with a maybe_pop_jump.
- We change it either to a pop_failure_jump or a no_pop_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. */
-
- /* 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)
- p[-3] = (unsigned char) pop_failure_jump;
-
- 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 it. */
- if ((re_opcode_t) p1[3] == exactn && p1[5] != c)
- p[-3] = (unsigned char) pop_failure_jump;
- 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;
- }
- }
- }
- p -= 2; /* Point at relative address again. */
- if ((re_opcode_t) p[-1] != pop_failure_jump)
- {
- p[-1] = (unsigned char) no_pop_jump;
- goto no_pop;
- }
- /* 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 aren't interested.
- Otherwise, we will restore only one register from the
- stack, since lowest will equal highest in
- pop_failure_point (since they'll be the same memory
- location). */
- unsigned dummy_low, dummy_high;
- unsigned char *pdummy = NULL;
-
- DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
- pop_failure_point (bufp, pend,
-#ifdef DEBUG
- string1, size1, string2, size2,
-#endif
- &failure_stack, &pdummy, &pdummy,
- &dummy_low, &dummy_high,
- &reg_dummy, &reg_dummy, &reg_info_dummy);
- }
- /* Note fall through. */
-
-
- /* Jump without taking off any failure points. */
- case no_pop_jump:
- no_pop:
- EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */
- DEBUG_PRINT2 ("EXECUTING no_pop_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_next_alt:
- DEBUG_PRINT1 ("EXECUTING jump_past_next_alt.\n");
- goto no_pop;
-
-
- /* 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);
- goto no_pop;
-
-
- /* Have to succeed matching what follows at least n times. Then
- just handle like an on_failure_jump. */
- case succeed_n:
- EXTRACT_NUMBER (mcnt, p + 2);
- DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
-
- /* Originally, this is how many times we HAVE to succeed. */
- if (mcnt)
- {
- 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;
- }
-#ifdef DEBUG
- else
- {
- fprintf (stderr, "regex: negative n at succeed_n.\n");
- abort ();
- }
-#endif /* DEBUG */
- break;
-
- case no_pop_jump_n:
- EXTRACT_NUMBER (mcnt, p + 2);
- DEBUG_PRINT2 ("EXECUTING no_pop_jump_n %d.\n", mcnt);
-
- /* Originally, this is how many times we CAN jump. */
- if (mcnt)
- {
- mcnt--;
- STORE_NUMBER(p + 2, mcnt);
- goto no_pop;
- }
- /* 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);
- 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 (LETTER_P (d) && (AT_STRINGS_BEG || !LETTER_P (d - 1)))
- break;
- goto fail;
-
- case wordend:
- DEBUG_PRINT1 ("EXECUTING wordend.\n");
- if (!AT_STRINGS_BEG && LETTER_P (d - 1)
- && (!LETTER_P (d) || AT_STRINGS_END))
- 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 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 notwordchar.\n");
- mcnt = (int) Sword;
- matchnotsyntax: /* We goto here from notsyntaxspec. */
- 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 (!LETTER_P (d))
- goto fail;
- SET_REGS_MATCHED ();
- break;
-
- case notwordchar:
- DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
- PREFETCH;
- if (LETTER_P (d))
- goto fail;
- SET_REGS_MATCHED ();
- break;
-#endif /* not emacs */
-
- default:
- abort ();
- }
- continue; /* Successfully executed one pattern command; keep going. */
-
-
- /* We goto here if a matching operation fails. */
- fail:
- if (!FAILURE_STACK_EMPTY ())
- { /* A restart point is known. Restore to that state. */
- DEBUG_PRINT1 ("\nFAIL:\n");
- pop_failure_point (bufp, pend,
-#ifdef DEBUG
- string1, size1, string2, size2,
-#endif
- &failure_stack, &p, &d, &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 no_pop_jump_n:
- is_a_jump_n = true;
- case maybe_pop_jump:
- case pop_failure_jump:
- case no_pop_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. */
-
-
-/* Pops what PUSH_FAILURE_STACK pushes. */
-
-static void
-pop_failure_point (bufp, pattern_end,
-#ifdef DEBUG
- string1, size1, string2, size2,
-#endif
- failure_stack_ptr, pattern_place, string_place,
- lowest_active_reg, highest_active_reg,
- regstart, regend, reg_info)
- const struct re_pattern_buffer *bufp; /* These not modified. */
- unsigned char *pattern_end;
-#ifdef DEBUG
- unsigned char *string1, *string2;
- int size1, size2;
-#endif
- failure_stack_type *failure_stack_ptr; /* These get modified. */
- const unsigned char **pattern_place;
- const unsigned char **string_place;
- unsigned *lowest_active_reg, *highest_active_reg;
- const unsigned char ***regstart;
- const unsigned char ***regend;
- register_info_type **reg_info;
-{
-#ifdef DEBUG
- /* Type is really unsigned; it's declared this way just to avoid a
- compiler warning. */
- failure_stack_elt_t failure_id;
-#endif
- int this_reg;
- const unsigned char *string_temp;
-
- assert (!FAILURE_STACK_PTR_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", failure_stack_ptr->avail);
- DEBUG_PRINT2 (" size: %d\n", failure_stack_ptr->size);
-
- assert (failure_stack_ptr->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)
- *string_place = string_temp;
-
- DEBUG_PRINT2 (" Popping string 0x%x: `", *string_place);
- DEBUG_DOUBLE_STRING_PRINTER (*string_place, string1, size1, string2, size2);
- DEBUG_PRINT1 ("'\n");
-
- *pattern_place = POP_FAILURE_ITEM ();
- DEBUG_PRINT2 (" Popping pattern 0x%x: ", *pattern_place);
- DEBUG_COMPILED_PATTERN_PRINTER (bufp, *pattern_place, pattern_end);
-
- /* Restore register info. */
- *highest_active_reg = (unsigned) POP_FAILURE_ITEM ();
- DEBUG_PRINT2 (" Popping high active reg: %d\n", *highest_active_reg);
-
- *lowest_active_reg = (unsigned) POP_FAILURE_ITEM ();
- DEBUG_PRINT2 (" Popping low active reg: %d\n", *lowest_active_reg);
-
- for (this_reg = *highest_active_reg; this_reg >= *lowest_active_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] = POP_FAILURE_ITEM ();
- DEBUG_PRINT2 (" end: 0x%x\n", (*regend)[this_reg]);
-
- (*regstart)[this_reg] = POP_FAILURE_ITEM ();
- DEBUG_PRINT2 (" start: 0x%x\n", (*regstart)[this_reg]);
- }
-} /* pop_failure_point */
-
-
-/* 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 no_pop_jump,
- whereas the rest start with on_failure_jump and end
- with a no_pop_jump, e.g., here is the pattern for `a|b|c':
-
- /on_failure_jump/0/6/exactn/1/a/jump_past_next_alt/0/6
- /on_failure_jump/0/6/exactn/1/b/jump_past_next_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_next_alt. */
-
- while ((re_opcode_t) p1[mcnt-3] == jump_past_next_alt)
- {
- /* `mcnt' holds how many bytes long the alternative
- is, including the ending `jump_past_next_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_next_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_next_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_next_alt just before it. `mcnt'
- contains how many bytes long the alternative is. */
- 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;
- 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_NOTHING_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 no_pop_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)
- unsigned char *s1, *s2;
- register int len;
- char *translate;
-{
- register unsigned char *p1 = s1, *p2 = 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;
- int length;
- struct re_pattern_buffer *bufp;
-{
- reg_errcode_t ret;
-
- /* GNU code is written to assume RE_NREGS registers will be set
- (and extraneous ones will be filled with -1). */
- bufp->caller_allocated_regs = 0;
-
- /* 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, obscure_syntax, 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 compilation. */
-
-#if !defined (emacs)
-
-static struct re_pattern_buffer re_comp_buf;
-
-const 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";
- }
-
- /* Match anchors at newlines. */
- re_comp_buf.newline_anchor = 1;
-
- ret = regex_compile (s, strlen (s), obscure_syntax, &re_comp_buf);
-
- return 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 */
-
-/* Entry points compatible with POSIX regex library. Don't define these
- for Emacs. */
-
-#ifndef emacs
-
-/* 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;
- unsigned 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;
-
- /* 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 how many registers to return information
- about, via `nmatch'. We have to pass that on to the matching
- routines. */
- private_preg.caller_allocated_regs = 1;
-
- 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 : NULL);
-
- /* 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. */
-
-size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
-{
- const char *msg
- = re_error_msg[errcode] == NULL ? "Success" : re_error_msg[errcode];
- size_t 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 /* not emacs */
-
-#ifdef test
-
-#include <stdio.h>
-
-/* 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
- };
-
-
-/* Use this to run interactive tests. */
-
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- char pat[500];
- struct re_pattern_buffer buf;
- int i;
- char c;
- char fastmap[(1 << BYTEWIDTH)];
-
- /* Allow a command argument to specify the style of syntax. */
- if (argc > 1)
- re_set_syntax (atoi (argv[1]));
-
- buf.allocated = 40;
- buf.buffer = (unsigned char *) malloc (buf.allocated);
- buf.fastmap = fastmap;
- buf.translate = upcase;
-
- for (;;)
- {
- printf ("Pattern = ");
- gets (pat);
-
- if (*pat)
- {
- void printchar ();
- re_compile_pattern (pat, strlen (pat), &buf);
-
- for (i = 0; i < buf.used; i++)
- printchar (buf.buffer[i]);
-
- putchar ('\n');
-
- printf ("%d allocated, %d used.\n", buf.allocated, buf.used);
-
- re_compile_fastmap (&buf);
- printf ("Allowed by fastmap: ");
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (fastmap[i]) printchar (i);
- putchar ('\n');
- }
-
- printf ("String = ");
- gets (pat); /* Now read the string to match against */
-
- i = re_match (&buf, pat, strlen (pat), 0, 0);
- printf ("Match value %d.\n\n", i);
- }
-}
-
-
-#if 0
-/* We have a fancier version now, compiled_pattern_printer. */
-print_buf (bufp)
- struct re_pattern_buffer *bufp;
-{
- int i;
-
- printf ("buf is :\n----------------\n");
- for (i = 0; i < bufp->used; i++)
- printchar (bufp->buffer[i]);
-
- printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used);
-
- printf ("Allowed by fastmap: ");
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (bufp->fastmap[i])
- printchar (i);
- printf ("\nAllowed by translate: ");
- if (bufp->translate)
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (bufp->translate[i])
- printchar (i);
- printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't");
- printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not");
-}
-#endif /* 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);
-}
-#endif /* test */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/usr.bin/cvs/lib/regex.h b/gnu/usr.bin/cvs/lib/regex.h
deleted file mode 100644
index 211ad09..0000000
--- a/gnu/usr.bin/cvs/lib/regex.h
+++ /dev/null
@@ -1,479 +0,0 @@
-/* Definitions for data structures and routines for the regular
- expression library, version REPLACE-WITH-VERSION.
-
- Copyright (C) 1985, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef __REGEXP_LIBRARY_H__
-#define __REGEXP_LIBRARY_H__
-
-/* POSIX says that <sys/types.h> must be included before <regex.h>. */
-
-/* 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 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 (1)
-
-/* 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).
- 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 now says that the behavior of * etc. in leading positions is
- undefined. We have already implemented a previous draft which
- made those constructs invalid, so we may as well not change 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.
- Furthermore, alternation cannot be first or last in an re, or
- immediately follow another alternation or begin-group. */
-#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
-
-/* If this bit is set, then . matches a newline.
- If not set, then it doesn't. */
-#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
-
-/* If this bit is set, then period doesn't match a null.
- 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, newline in the pattern is an ordinary character.
- If not set, newline before ^ or after $ allows the ^ or $ to be an
- anchor. */
-#define RE_NEWLINE_ORDINARY (RE_NEWLINE_ALT << 1)
-
-/* If this bit is not set, then \{ and \} defines an interval,
- and { and } are literals.
- If set, then { and } defines an interval, and \{ and \} are literals. */
-#define RE_NO_BK_BRACES (RE_NEWLINE_ORDINARY << 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 back references (i.e., \<digit>) are not
- recognized.
- If not set, then they are. */
-#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 you can't have empty alternatives.
- If not set, then you can. */
-#define RE_NO_EMPTY_ALTS (RE_NO_BK_VBAR << 1)
-
-/* If this bit is set, then you can't have empty groups.
- If not set, then you can. */
-#define RE_NO_EMPTY_GROUPS (RE_NO_EMPTY_ALTS << 1)
-
-/* If this bit is set, then an ending range point has to collate higher
- than or equal to the starting range point.
- If not set, then when the ending range point collates higher than the
- starting range point, we consider such a range to be empty. */
-#define RE_NO_EMPTY_RANGES (RE_NO_EMPTY_GROUPS << 1)
-
-/* If this bit is set, then all back references must refer to a preceding
- subexpression.
- If not set, then a back reference to a nonexistent subexpression is
- treated as literal characters. */
-#define RE_NO_MISSING_BK_REF (RE_NO_EMPTY_RANGES << 1)
-
-/* If this bit is set, then Regex considers an unmatched close-group
- operator to be the ordinary character parenthesis.
- If not set, then an unmatched close-group operator is invalid. */
-#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_MISSING_BK_REF << 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 obscure_syntax;
-
-
-
-/* Define combinations of the above bits for the standard possibilities.
- (The [[[ comments delimit what gets put into the Texinfo file.) */
-/* [[[begin syntaxes]]] */
-#define RE_SYNTAX_EMACS 0
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_CONTEXT_INDEP_ANCHORS | RE_CONTEXT_INDEP_OPS | RE_NO_BK_PARENS \
- | RE_NO_BK_VBAR)
-
-#define RE_SYNTAX_AWK \
- (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_SYNTAX_POSIX_AWK)
-
-#define RE_SYNTAX_GREP \
- (RE_BK_PLUS_QM | RE_NEWLINE_ALT)
-
-#define RE_SYNTAX_EGREP \
- (RE_CONTEXT_INDEP_ANCHORS | RE_CONTEXT_INDEP_OPS \
- | RE_NEWLINE_ALT | RE_NO_BK_PARENS | RE_NO_BK_VBAR)
-
-#define RE_SYNTAX_POSIX_BASIC \
- (RE_CHAR_CLASSES | RE_DOT_NEWLINE \
- | RE_DOT_NOT_NULL | RE_INTERVALS | RE_LIMITED_OPS \
- | RE_NEWLINE_ORDINARY | RE_NO_EMPTY_RANGES | RE_NO_MISSING_BK_REF)
-
-#define RE_SYNTAX_POSIX_EXTENDED \
- (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INVALID_OPS | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
- | RE_INTERVALS | RE_NEWLINE_ORDINARY | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS | RE_NO_BK_VBAR \
- | RE_NO_EMPTY_ALTS | RE_NO_EMPTY_GROUPS | RE_NO_EMPTY_RANGES \
- | RE_UNMATCHED_RIGHT_PAREN_ORD)
-/* [[[end syntaxes]]] */
-
-
-
-
-/* Maximum number of duplicates an interval can allow. */
-#undef RE_DUP_MAX
-#define RE_DUP_MAX ((1 << 15) - 1)
-
-
-/* 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;
-
- /* Set to 1 by re_compile_fastmap if this pattern can match the
- null string; 0 prevents the searcher from matching it with
- the null string. Set to 2 if it might match the null string
- either at the end of a search range or just before a
- character listed in the fastmap. */
- unsigned can_be_null : 2;
-
- /* Set to zero when regex_compile compiles a pattern; set to one
- by re_compile_fastmap when it updates the fastmap, if any. */
- unsigned fastmap_accurate : 1;
-
- /* If set, regexec reports only success or failure and does not
- return anything in pmatch. */
- 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;
-
- /* If set, re_match_2 assumes a non-null REGS argument is
- initialized. If not set, REGS is initialized to the max of
- RE_NREGS and re_nsub + 1 registers. */
- unsigned caller_allocated_regs : 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 us defining
- 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 `caller_allocated_regs' is zero in the pattern buffer, re_match_2
- returns information about this many registers. */
-#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. */
-
-#if __STDC__
-
-/* Sets the current syntax to SYNTAX. You can also simply assign to the
- `obscure_syntax' variable. */
-extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
-
-/* Compile the regular expression PATTERN, with length LENGTH
- and syntax given by the global `obscure_syntax', into the buffer
- BUFFER. Return NULL if successful, and an error string if not. */
-extern const char *re_compile_pattern (const char *pattern, int 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 (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 (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 (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 (const 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 (const struct re_pattern_buffer *buffer,
- const char *string1, int length1,
- const char *string2, int length2,
- int start,
- struct re_registers *regs,
- int stop);
-
-
-#ifndef __386BSD__
-/* 4.2 bsd compatibility. */
-#ifndef bsdi
-extern const char *re_comp (const char *);
-#endif
-extern int re_exec (const char *);
-#endif
-
-/* POSIX compatibility. */
-extern int regcomp (regex_t *preg, const char *pattern, int cflags);
-extern int regexec (const regex_t *preg, const char *string, size_t nmatch,
- regmatch_t pmatch[], int eflags);
-extern size_t regerror (int errcode, const regex_t *preg, char *errbuf,
- size_t errbuf_size);
-extern void regfree (regex_t *preg);
-
-#else /* not __STDC__ */
-
-/* Support old C compilers. */
-#define const
-
-extern reg_syntax_t re_set_syntax ();
-extern char *re_compile_pattern ();
-extern int re_search (), re_search_2 ();
-extern int re_match (), re_match_2 ();
-
-/* 4.2 BSD compatibility. */
-extern char *re_comp ();
-extern int re_exec ();
-
-/* POSIX compatibility. */
-extern int regcomp ();
-extern int regexec ();
-extern size_t regerror ();
-extern void regfree ();
-
-#endif /* not __STDC__ */
-#endif /* not __REGEXP_LIBRARY_H__ */
-
-
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/usr.bin/cvs/lib/rename.c b/gnu/usr.bin/cvs/lib/rename.c
deleted file mode 100644
index 3e0b481..0000000
--- a/gnu/usr.bin/cvs/lib/rename.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* rename.c -- BSD compatible directory function for System V
- Copyright (C) 1988, 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. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-
-/* 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;
- int pid, status;
-
- if (stat (from, &from_stats) == 0)
- {
- if (unlink (to) && errno != ENOENT)
- return -1;
- if ((from_stats.st_mode & S_IFMT) == S_IFDIR)
- {
- /* Need a setuid root process to link and unlink directories. */
- pid = fork ();
- switch (pid)
- {
- case -1: /* Error. */
- error (1, errno, "cannot fork");
-
- case 0: /* Child. */
- execl (MVDIR, "mvdir", from, to, (char *) 0);
- error (255, errno, "cannot run `%s'", MVDIR);
-
- default: /* Parent. */
- while (wait (&status) != pid)
- /* Do nothing. */ ;
-
- errno = 0; /* mvdir printed the system error message. */
- return status != 0 ? -1 : 0;
- }
- }
- else
- {
- if (link (from, to) == 0 && (unlink (from) == 0 || errno == ENOENT))
- return 0;
- }
- }
- return -1;
-}
diff --git a/gnu/usr.bin/cvs/lib/sighandle.c b/gnu/usr.bin/cvs/lib/sighandle.c
deleted file mode 100644
index 1b73b93..0000000
--- a/gnu/usr.bin/cvs/lib/sighandle.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/* sighandle.c -- Library routines for manipulating chains of signal handlers
- 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 by Paul Sander, HaL Computer Systems, Inc. <paul@hal.com>
- Brian Berliner <berliner@Sun.COM> added POSIX support */
-
-/*************************************************************************
- *
- * signal.c -- This file contains code that manipulates chains of signal
- * handlers.
- *
- * Facilities are provided to register a signal handler for
- * any specific signal. When a signal is received, all of the
- * registered signal handlers are invoked in the reverse order
- * in which they are registered. Note that the signal handlers
- * must not themselves make calls to the signal handling
- * facilities.
- *
- * @(#)sighandle.c 1.9 92/03/31
- *
- *************************************************************************/
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <signal.h>
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-#if __STDC__
-char *calloc(unsigned nelem, unsigned size);
-char *malloc(unsigned size);
-#else
-char *calloc();
-char *malloc();
-#endif /* __STDC__ */
-#endif /* STDC_HEADERS */
-
-#ifdef _MINIX
-#undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */
-#endif
-
-#ifndef SIGTYPE
-#define SIGTYPE void
-#endif
-
-/* Define the highest signal number (usually) */
-#ifndef SIGMAX
-#define SIGMAX 32
-#endif
-
-/* Define linked list of signal handlers structure */
-struct SIG_hlist {
- SIGTYPE (*handler)();
- struct SIG_hlist *next;
-};
-
-/*
- * Define array of lists of signal handlers. Note that this depends on
- * the implementation to initialize each element to a null pointer.
- */
-
-static struct SIG_hlist **SIG_handlers;
-
-/* Define array of default signal vectors */
-
-#ifdef POSIX
-static struct sigaction *SIG_defaults;
-#else
-#ifdef BSD_SIGNALS
-static struct sigvec *SIG_defaults;
-#else
-static SIGTYPE (**SIG_defaults)();
-#endif
-#endif
-
-/* Critical section housekeeping */
-static int SIG_crSectNest = 0; /* Nesting level */
-#ifdef POSIX
-static sigset_t SIG_crSectMask; /* Signal mask */
-#else
-static int SIG_crSectMask; /* Signal mask */
-#endif
-
-/*
- * Initialize the signal handler arrays
- */
-
-static int SIG_init()
-{
- int i;
-#ifdef POSIX
- sigset_t sigset_test;
-#endif
-
- if (SIG_defaults && SIG_handlers) /* already allocated */
- return (0);
-
-#ifdef POSIX
- (void) sigfillset(&sigset_test);
- for (i = 1; sigismember(&sigset_test, i) == 1; i++)
-#ifdef BROKEN_SIGISMEMBER
- if ( i >= NSIG )
- break
-#endif
- ;
- if (i < SIGMAX)
- i = SIGMAX;
- i++;
- if (!SIG_defaults)
- SIG_defaults = (struct sigaction *)
- calloc(i, sizeof(struct sigaction));
- (void) sigemptyset(&SIG_crSectMask);
-#else
- i = SIGMAX+1;
-#ifdef BSD_SIGNALS
- if (!SIG_defaults)
- SIG_defaults = (struct sigvec *)
- calloc(i, sizeof(struct sigvec));
-#else
- if (!SIG_defaults)
- SIG_defaults = (SIGTYPE (**)())
- calloc(i, sizeof(SIGTYPE (**)()));
-#endif
- SIG_crSectMask = 0;
-#endif
- if (!SIG_handlers)
- SIG_handlers = (struct SIG_hlist **)
- calloc(i, sizeof(struct SIG_hlist *));
- return (!SIG_defaults || !SIG_handlers);
-}
-
-/*
- * The following invokes each signal handler in the reverse order in which
- * they were registered.
- */
-
-static SIGTYPE SIG_handle(sig)
-int sig;
-{
- struct SIG_hlist *this;
-
- /* Dispatch signal handlers */
- this = SIG_handlers[sig];
- while (this != (struct SIG_hlist *) NULL)
- {
- (*this->handler)(sig);
- this = this->next;
- }
-
- return;
-}
-
-/*
- * The following registers a signal handler. If the handler is already
- * registered, it is not registered twice, nor is the order in which signal
- * handlers are invoked changed. If this is the first signal handler
- * registered for a given signal, the old sigvec structure is saved for
- * restoration later.
- */
-
-int SIG_register(sig,fn)
-int sig;
-SIGTYPE (*fn)();
-{
- int val;
- struct SIG_hlist *this;
-#ifdef POSIX
- struct sigaction act;
- sigset_t sigset_mask, sigset_omask;
-#else
-#ifdef BSD_SIGNALS
- struct sigvec vec;
- int mask;
-#endif
-#endif
-
- /* Initialize */
- if (SIG_init() != 0)
- return (-1);
- val = 0;
-
- /* Block this signal while we look at handler chain */
-#ifdef POSIX
- (void) sigemptyset(&sigset_mask);
- (void) sigaddset(&sigset_mask, sig);
- (void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask);
-#else
-#ifdef BSD_SIGNALS
- mask = sigblock(sigmask(sig));
-#endif
-#endif
-
- /* See if this handler was already registered */
- this = SIG_handlers[sig];
- while (this != (struct SIG_hlist *) NULL)
- {
- if (this->handler == fn) break;
- this = this->next;
- }
-
- /* Register the new handler only if it is not already registered. */
- if (this == (struct SIG_hlist *) NULL)
- {
-
- /*
- * If this is the first handler registered for this signal,
- * set up the signal handler dispatcher
- */
-
- if (SIG_handlers[sig] == (struct SIG_hlist *) NULL)
- {
-#ifdef POSIX
- act.sa_handler = SIG_handle;
- (void) sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- val = sigaction(sig, &act, &SIG_defaults[sig]);
-#else
-#ifdef BSD_SIGNALS
- bzero((char *)&vec, sizeof(vec));
- vec.sv_handler = SIG_handle;
- val = sigvec(sig, &vec, &SIG_defaults[sig]);
-#else
- if ((SIG_defaults[sig] = signal(sig, SIG_handle)) ==
- (SIGTYPE (*)()) -1)
- val = -1;
-#endif
-#endif
- }
-
- /* If not, register it */
- if ((val == 0) && (this == (struct SIG_hlist *) NULL))
- {
- this = (struct SIG_hlist *)
- malloc(sizeof(struct SIG_hlist));
- if (this == NULL)
- {
- val = -1;
- }
- else
- {
- this->handler = fn;
- this->next = SIG_handlers[sig];
- SIG_handlers[sig] = this;
- }
- }
- }
-
- /* Unblock the signal */
-#ifdef POSIX
- (void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL);
-#else
-#ifdef BSD_SIGNALS
- (void) sigsetmask(mask);
-#endif
-#endif
-
- return val;
-}
-
-/*
- * The following deregisters a signal handler. If the last signal handler for
- * a given signal is deregistered, the default sigvec information is restored.
- */
-
-int SIG_deregister(sig,fn)
-int sig;
-SIGTYPE (*fn)();
-{
- int val;
- struct SIG_hlist *this;
- struct SIG_hlist *last;
-#ifdef POSIX
- sigset_t sigset_mask, sigset_omask;
-#else
-#ifdef BSD_SIGNALS
- int mask;
-#endif
-#endif
-
- /* Initialize */
- if (SIG_init() != 0)
- return (-1);
- val = 0;
- last = (struct SIG_hlist *) NULL;
-
- /* Block this signal while we look at handler chain */
-#ifdef POSIX
- (void) sigemptyset(&sigset_mask);
- (void) sigaddset(&sigset_mask, sig);
- (void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask);
-#else
-#ifdef BSD_SIGNALS
- mask = sigblock(sigmask(sig));
-#endif
-#endif
-
- /* Search for the signal handler */
- this = SIG_handlers[sig];
- while ((this != (struct SIG_hlist *) NULL) && (this->handler != fn))
- {
- last = this;
- this = this->next;
- }
-
- /* If it was registered, remove it */
- if (this != (struct SIG_hlist *) NULL)
- {
- if (last == (struct SIG_hlist *) NULL)
- {
- SIG_handlers[sig] = this->next;
- }
- else
- {
- last->next = this->next;
- }
- free((char *) this);
- }
-
- /* Restore default behavior if there are no registered handlers */
- if (SIG_handlers[sig] == (struct SIG_hlist *) NULL)
- {
-#ifdef POSIX
- val = sigaction(sig, &SIG_defaults[sig],
- (struct sigaction *) NULL);
-#else
-#ifdef BSD_SIGNALS
- val = sigvec(sig, &SIG_defaults[sig], (struct sigvec *) NULL);
-#else
- if (signal(sig, SIG_defaults[sig]) == (SIGTYPE (*)()) -1)
- val = -1;
-#endif
-#endif
- }
-
- /* Unblock the signal */
-#ifdef POSIX
- (void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL);
-#else
-#ifdef BSD_SIGNALS
- (void) sigsetmask(mask);
-#endif
-#endif
-
- return val;
-}
-
-/*
- * The following begins a critical section.
- */
-
-void SIG_beginCrSect()
-{
- if (SIG_init() == 0)
- {
- if (SIG_crSectNest == 0)
- {
-#ifdef POSIX
- sigset_t sigset_mask;
-
- (void) sigfillset(&sigset_mask);
- (void) sigprocmask(SIG_SETMASK,
- &sigset_mask, &SIG_crSectMask);
-#else
-#ifdef BSD_SIGNALS
- SIG_crSectMask = sigblock(~0);
-#else
- /* TBD */
-#endif
-#endif
- }
- SIG_crSectNest++;
- }
-}
-
-/*
- * The following ends a critical section.
- */
-
-void SIG_endCrSect()
-{
- if (SIG_init() == 0)
- {
- SIG_crSectNest--;
- if (SIG_crSectNest == 0)
- {
-#ifdef POSIX
- (void) sigprocmask(SIG_SETMASK, &SIG_crSectMask, NULL);
-#else
-#ifdef BSD_SIGNALS
- (void) sigsetmask(SIG_crSectMask);
-#else
- /* TBD */
-#endif
-#endif
- }
- }
-}
diff --git a/gnu/usr.bin/cvs/lib/strdup.c b/gnu/usr.bin/cvs/lib/strdup.c
deleted file mode 100644
index 4e5af07..0000000
--- a/gnu/usr.bin/cvs/lib/strdup.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* strdup.c -- return a newly allocated copy of a string
- Copyright (C) 1990 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef STDC_HEADERS
-#include <string.h>
-#include <stdlib.h>
-#else
-char *malloc ();
-char *strcpy ();
-#endif
-
-/* Return a newly allocated copy of STR,
- or 0 if out of memory. */
-
-char *
-strdup (str)
- char *str;
-{
- char *newstr;
-
- newstr = (char *) malloc (strlen (str) + 1);
- if (newstr)
- strcpy (newstr, str);
- return newstr;
-}
diff --git a/gnu/usr.bin/cvs/lib/strippath.c b/gnu/usr.bin/cvs/lib/strippath.c
deleted file mode 100644
index 3d606a8..0000000
--- a/gnu/usr.bin/cvs/lib/strippath.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* strippath.c -- remove unnecessary components from a path specifier
- 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 defined(STDC_HEADERS) || defined(USG)
-#include <string.h>
-#ifndef index
-#define index strchr
-#endif
-#else
-#include <strings.h>
-#endif
-
-#include <stdio.h>
-
-#if __STDC__
-static void remove_component(char *beginc, char *endc);
-void strip_trailing_slashes(char *path);
-#else
-static void remove_component();
-void strip_trailing_slashes();
-#endif /* __STDC__ */
-
-/* Remove unnecessary components from PATH. */
-
-void
-strip_path (path)
- char *path;
-{
- int stripped = 0;
- char *cp, *slash;
-
- for (cp = path; (slash = index(cp, '/')) != NULL; cp = slash)
- {
- *slash = '\0';
- if ((!*cp && (cp != path || stripped)) ||
- strcmp(cp, ".") == 0 || strcmp(cp, "/") == 0)
- {
- stripped = 1;
- remove_component(cp, slash);
- slash = cp;
- }
- else
- {
- *slash++ = '/';
- }
- }
- strip_trailing_slashes(path);
-}
-
-/* Remove the component delimited by BEGINC and ENDC from the path */
-
-static void
-remove_component (beginc, endc)
- char *beginc;
- char *endc;
-{
- for (endc++; *endc; endc++)
- *beginc++ = *endc;
- *beginc = '\0';
-}
diff --git a/gnu/usr.bin/cvs/lib/stripslash.c b/gnu/usr.bin/cvs/lib/stripslash.c
deleted file mode 100644
index 0c26ac6..0000000
--- a/gnu/usr.bin/cvs/lib/stripslash.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* stripslash.c -- remove trailing slashes from a string
- Copyright (C) 1990 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if defined(STDC_HEADERS) || defined(USG)
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-
-/* Remove trailing slashes from PATH. */
-
-void
-strip_trailing_slashes (path)
- char *path;
-{
- int last;
-
- last = strlen (path) - 1;
- while (last > 0 && path[last] == '/')
- path[last--] = '\0';
-}
diff --git a/gnu/usr.bin/cvs/lib/subr.c b/gnu/usr.bin/cvs/lib/subr.c
deleted file mode 100644
index 2b728c2..0000000
--- a/gnu/usr.bin/cvs/lib/subr.c
+++ /dev/null
@@ -1,912 +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.3 kit.
- *
- * Various useful functions for the CVS support code.
- */
-
-#include "cvs.h"
-
-#ifdef _MINIX
-#undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */
-#endif
-
-#ifndef VPRINTF_MISSING
-#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
-
-#ifndef lint
-static char rcsid[] = "@(#)subr.c 1.52 92/03/31";
-#endif
-
-#if __STDC__
-static void run_add_arg (char *s);
-static void run_init_prog (void);
-#else
-static void run_add_arg ();
-static void run_init_prog ();
-#endif /* __STDC__ */
-
-extern char *getlogin ();
-extern char *strtok ();
-
-/*
- * Copies "from" to "to". mallocs a buffer large enough to hold the entire
- * file and does one read/one write to do the copy. This is reasonable,
- * since source files are typically not too large.
- */
-void
-copy_file (from, to)
- char *from;
- char *to;
-{
- struct stat sb;
- struct utimbuf t;
- int fdin, fdout;
- char *buf;
-
- if (trace)
- (void) fprintf (stderr, "-> copy(%s,%s)\n", from, to);
- if (noexec)
- return;
-
- if ((fdin = open (from, O_RDONLY)) < 0)
- error (1, errno, "cannot open %s for copying", from);
- if (fstat (fdin, &sb) < 0)
- error (1, errno, "cannot fstat %s", from);
- if ((fdout = creat (to, (int) sb.st_mode & 07777)) < 0)
- error (1, errno, "cannot create %s for copying", to);
- if (sb.st_size > 0)
- {
- buf = xmalloc ((int) sb.st_size);
- if (read (fdin, buf, (int) sb.st_size) != (int) sb.st_size)
- error (1, errno, "cannot read file %s for copying", from);
- if (write (fdout, buf, (int) sb.st_size) != (int) sb.st_size
-#ifndef FSYNC_MISSING
- || fsync (fdout) == -1
-#endif
- )
- {
- error (1, errno, "cannot write file %s for copying", to);
- }
- free (buf);
- }
- (void) close (fdin);
- if (close (fdout) < 0)
- error (1, errno, "cannot close %s", to);
-
- /* now, set the times for the copied file to match those of the original */
- t.actime = sb.st_atime;
- t.modtime = sb.st_mtime;
- (void) utime (to, &t);
-}
-
-/*
- * Returns non-zero if the argument file is a directory, or is a symbolic
- * link which points to a directory.
- */
-int
-isdir (file)
- char *file;
-{
- struct stat sb;
-
- if (stat (file, &sb) < 0)
- return (0);
- return (S_ISDIR (sb.st_mode));
-}
-
-/*
- * Returns non-zero if the argument file is a symbolic link.
- */
-int
-islink (file)
- char *file;
-{
-#ifdef S_ISLNK
- struct stat sb;
-
- if (lstat (file, &sb) < 0)
- return (0);
- return (S_ISLNK (sb.st_mode));
-#else
- return (0);
-#endif
-}
-
-/*
- * Returns non-zero if the argument file exists.
- */
-int
-isfile (file)
- char *file;
-{
- struct stat sb;
-
- if (stat (file, &sb) < 0)
- return (0);
- return (1);
-}
-
-/*
- * Returns non-zero if the argument file is readable.
- * XXX - must be careful if "cvs" is ever made setuid!
- */
-int
-isreadable (file)
- char *file;
-{
- return (access (file, R_OK) != -1);
-}
-
-/*
- * Returns non-zero if the argument file is writable
- * XXX - muct be careful if "cvs" is ever made setuid!
- */
-int
-iswritable (file)
- char *file;
-{
- return (access (file, W_OK) != -1);
-}
-
-/*
- * Open a file and die if it fails
- */
-FILE *
-open_file (name, mode)
- char *name;
- char *mode;
-{
- FILE *fp;
-
- if ((fp = fopen (name, mode)) == NULL)
- error (1, errno, "cannot open %s", name);
- return (fp);
-}
-
-/*
- * Open a file if allowed and return.
- */
-FILE *
-Fopen (name, mode)
- char *name;
- char *mode;
-{
- if (trace)
- (void) fprintf (stderr, "-> fopen(%s,%s)\n", name, mode);
- if (noexec)
- return (NULL);
-
- return (fopen (name, mode));
-}
-
-/*
- * Make a directory and die if it fails
- */
-void
-make_directory (name)
- char *name;
-{
- struct stat buf;
-
- if (stat (name, &buf) == 0)
- {
- if (S_ISDIR (buf.st_mode))
- {
- if (access (name, (R_OK | W_OK | X_OK)) == 0)
- {
- error (0, 0, "Directory %s already exists", name);
- return;
- }
- else
- {
- error (0, 0,
- "Directory %s already exists but is protected from you",
- name);
- }
- }
- else
- error (0, 0, "%s already exists but is not a directory", name);
- }
- if (!noexec && mkdir (name, 0777) < 0)
- error (1, errno, "cannot make directory %s", name);
-}
-
-/*
- * Make a path to the argument directory, printing a message if something
- * goes wrong.
- */
-void
-make_directories (name)
- char *name;
-{
- char *cp;
-
- if (noexec)
- return;
-
- if (mkdir (name, 0777) == 0 || errno == EEXIST)
- return;
- if (errno != ENOENT)
- {
- error (0, errno, "cannot make path to %s", name);
- return;
- }
- if ((cp = rindex (name, '/')) == NULL)
- return;
- *cp = '\0';
- make_directories (name);
- *cp++ = '/';
- if (*cp == '\0')
- return;
- (void) mkdir (name, 0777);
-}
-
-/*
- * malloc some data and die if it fails
- */
-char *
-xmalloc (bytes)
- int bytes;
-{
- char *cp;
-
- if (bytes <= 0)
- error (1, 0, "bad malloc size %d", bytes);
- if ((cp = malloc ((unsigned) bytes)) == NULL)
- error (1, 0, "malloc failed");
- return (cp);
-}
-
-/*
- * realloc data and die if it fails [I've always wanted to have "realloc" do
- * a "malloc" if the argument is NULL, but you can't depend on it. Here, I
- * can *force* it.
- */
-char *
-xrealloc (ptr, bytes)
- char *ptr;
- int bytes;
-{
- char *cp;
-
- if (!ptr)
- return (xmalloc (bytes));
-
- if (bytes <= 0)
- error (1, 0, "bad realloc size %d", bytes);
- if ((cp = realloc (ptr, (unsigned) bytes)) == NULL)
- error (1, 0, "realloc failed");
- return (cp);
-}
-
-/*
- * Duplicate a string, calling xmalloc to allocate some dynamic space
- */
-char *
-xstrdup (str)
- char *str;
-{
- char *s;
-
- if (str == NULL)
- return ((char *) NULL);
- s = xmalloc (strlen (str) + 1);
- (void) strcpy (s, str);
- return (s);
-}
-
-/*
- * Change the mode of a file, either adding write permissions, or removing
- * all write permissions. Adding write permissions honors the current umask
- * setting.
- */
-void
-xchmod (fname, writable)
- char *fname;
- int writable;
-{
- struct stat sb;
- int mode, oumask;
-
- if (stat (fname, &sb) < 0)
- {
- if (!noexec)
- error (0, errno, "cannot stat %s", fname);
- return;
- }
- if (writable)
- {
- oumask = umask (0);
- (void) umask (oumask);
- mode = sb.st_mode | ((S_IWRITE | S_IWGRP | S_IWOTH) & ~oumask);
- }
- else
- {
- mode = sb.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH);
- }
-
- if (trace)
- (void) fprintf (stderr, "-> chmod(%s,%o)\n", fname, mode);
- if (noexec)
- return;
-
- if (chmod (fname, mode) < 0)
- error (0, errno, "cannot change mode of file %s", fname);
-}
-
-/*
- * Rename a file and die if it fails
- */
-void
-rename_file (from, to)
- char *from;
- char *to;
-{
- if (trace)
- (void) fprintf (stderr, "-> rename(%s,%s)\n", from, to);
- if (noexec)
- return;
-
- if (rename (from, to) < 0)
- error (1, errno, "cannot rename file %s to %s", from, to);
-}
-
-/*
- * link a file, if possible.
- */
-int
-link_file (from, to)
- char *from, *to;
-{
- if (trace)
- (void) fprintf (stderr, "-> link(%s,%s)\n", from, to);
- if (noexec)
- return (0);
-
- return (link (from, to));
-}
-
-/*
- * unlink a file, if possible.
- */
-int
-unlink_file (f)
- char *f;
-{
- if (trace)
- (void) fprintf (stderr, "-> unlink(%s)\n", f);
- if (noexec)
- return (0);
-
- return (unlink (f));
-}
-
-/*
- * Compare "file1" to "file2". Return non-zero if they don't compare exactly.
- *
- * mallocs a buffer large enough to hold the entire file and does two reads to
- * load the buffer and calls bcmp to do the cmp. This is reasonable, since
- * source files are typically not too large.
- */
-int
-xcmp (file1, file2)
- char *file1;
- char *file2;
-{
- register char *buf1, *buf2;
- struct stat sb;
- off_t size;
- int ret, fd1, fd2;
-
- if ((fd1 = open (file1, O_RDONLY)) < 0)
- error (1, errno, "cannot open file %s for comparing", file1);
- if ((fd2 = open (file2, O_RDONLY)) < 0)
- error (1, errno, "cannot open file %s for comparing", file2);
- if (fstat (fd1, &sb) < 0)
- error (1, errno, "cannot fstat %s", file1);
- size = sb.st_size;
- if (fstat (fd2, &sb) < 0)
- error (1, errno, "cannot fstat %s", file2);
- if (size == sb.st_size)
- {
- if (size == 0)
- ret = 0;
- else
- {
- buf1 = xmalloc ((int) size);
- buf2 = xmalloc ((int) size);
- if (read (fd1, buf1, (int) size) != (int) size)
- error (1, errno, "cannot read file %s cor comparing", file1);
- if (read (fd2, buf2, (int) size) != (int) size)
- error (1, errno, "cannot read file %s for comparing", file2);
- ret = bcmp (buf1, buf2, (int) size);
- free (buf1);
- free (buf2);
- }
- }
- else
- ret = 1;
- (void) close (fd1);
- (void) close (fd2);
- return (ret);
-}
-
-/*
- * Recover the space allocated by Find_Names() and line2argv()
- */
-void
-free_names (pargc, argv)
- int *pargc;
- char *argv[];
-{
- register int i;
-
- for (i = 0; i < *pargc; i++)
- { /* only do through *pargc */
- free (argv[i]);
- }
- *pargc = 0; /* and set it to zero when done */
-}
-
-/*
- * Convert a line into argc/argv components and return the result in the
- * arguments as passed. Use free_names() to return the memory allocated here
- * back to the free pool.
- */
-void
-line2argv (pargc, argv, line)
- int *pargc;
- char *argv[];
- char *line;
-{
- char *cp;
-
- *pargc = 0;
- for (cp = strtok (line, " \t"); cp; cp = strtok ((char *) NULL, " \t"))
- {
- argv[*pargc] = xstrdup (cp);
- (*pargc)++;
- }
-}
-
-/*
- * Returns the number of dots ('.') found in an RCS revision number
- */
-int
-numdots (s)
- char *s;
-{
- char *cp;
- int dots = 0;
-
- for (cp = s; *cp; cp++)
- {
- if (*cp == '.')
- dots++;
- }
- return (dots);
-}
-
-/*
- * Get the caller's login from his uid. If the real uid is "root" try LOGNAME
- * USER or getlogin(). If getlogin() and getpwuid() both fail, return
- * the uid as a string.
- */
-char *
-getcaller ()
-{
- static char uidname[20];
- struct passwd *pw;
- char *name;
- int uid;
-
- uid = getuid ();
- if (uid == 0)
- {
- /* super-user; try getlogin() to distinguish */
- if (((name = getenv("LOGNAME")) || (name = getenv("USER")) ||
- (name = getlogin ())) && *name)
- return (name);
- }
- if ((pw = (struct passwd *) getpwuid (uid)) == NULL)
- {
- (void) sprintf (uidname, "uid%d", uid);
- return (uidname);
- }
- return (pw->pw_name);
-}
-
-/*
- * To exec a program under CVS, first call run_setup() to setup any initial
- * arguments. The options to run_setup are essentially like printf(). The
- * arguments will be parsed into whitespace separated words and added to the
- * global run_argv list.
- *
- * Then, optionally call run_arg() for each additional argument that you'd like
- * to pass to the executed program.
- *
- * Finally, call run_exec() to execute the program with the specified arguments.
- * The execvp() syscall will be used, so that the PATH is searched correctly.
- * File redirections can be performed in the call to run_exec().
- */
-static char *run_prog;
-static char **run_argv;
-static int run_argc;
-static int run_argc_allocated;
-
-/* VARARGS */
-#if !defined (VPRINTF_MISSING) && __STDC__
-void
-run_setup (char *fmt,...)
-#else
-void
-run_setup (fmt, va_alist)
- char *fmt;
- va_dcl
-
-#endif
-{
-#ifndef VPRINTF_MISSING
- va_list args;
-
-#endif
- char *cp;
- int i;
-
- run_init_prog ();
-
- /* clean out any malloc'ed values from run_argv */
- for (i = 0; i < run_argc; i++)
- {
- if (run_argv[i])
- {
- free (run_argv[i]);
- run_argv[i] = (char *) 0;
- }
- }
- run_argc = 0;
-
- /* process the varargs into run_prog */
-#ifndef VPRINTF_MISSING
- VA_START (args, fmt);
- (void) vsprintf (run_prog, fmt, args);
- va_end (args);
-#else
- (void) sprintf (run_prog, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
-
- /* put each word into run_argv, allocating it as we go */
- for (cp = strtok (run_prog, " \t"); cp; cp = strtok ((char *) NULL, " \t"))
- run_add_arg (cp);
-}
-
-void
-run_arg (s)
- char *s;
-{
- run_add_arg (s);
-}
-
-/* VARARGS */
-#if !defined (VPRINTF_MISSING) && __STDC__
-void
-run_args (char *fmt,...)
-#else
-void
-run_args (fmt, va_alist)
- char *fmt;
- va_dcl
-
-#endif
-{
-#ifndef VPRINTF_MISSING
- va_list args;
-
-#endif
-
- run_init_prog ();
-
- /* process the varargs into run_prog */
-#ifndef VPRINTF_MISSING
- VA_START (args, fmt);
- (void) vsprintf (run_prog, fmt, args);
- va_end (args);
-#else
- (void) sprintf (run_prog, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
-
- /* and add the (single) argument to the run_argv list */
- run_add_arg (run_prog);
-}
-
-static void
-run_add_arg (s)
- char *s;
-{
- /* allocate more argv entries if we've run out */
- if (run_argc >= run_argc_allocated)
- {
- run_argc_allocated += 50;
- run_argv = (char **) xrealloc ((char *) run_argv,
- run_argc_allocated * sizeof (char **));
- }
-
- if (s)
- run_argv[run_argc++] = xstrdup (s);
- else
- run_argv[run_argc] = (char *) 0;/* not post-incremented on purpose! */
-}
-
-static void
-run_init_prog ()
-{
- /* make sure that run_prog is allocated once */
- if (run_prog == (char *) 0)
- run_prog = xmalloc (10 * 1024); /* 10K of args for _setup and _arg */
-}
-
-int
-run_exec (stin, stout, sterr, flags)
- char *stin;
- char *stout;
- char *sterr;
- int flags;
-{
- int shin, shout, sherr;
- int mode_out, mode_err;
- int status = -1;
- int rerrno = 0;
- int pid, w;
-
-#ifdef POSIX
- sigset_t sigset_mask, sigset_omask;
- struct sigaction act, iact, qact;
-
-#else
-#ifdef BSD_SIGNALS
- int mask;
- struct sigvec vec, ivec, qvec;
-
-#else
- SIGTYPE (*istat) (), (*qstat) ();
-#endif
-#endif
-
- if (trace)
- {
- (void) fprintf (stderr, "-> system(");
- run_print (stderr);
- (void) fprintf (stderr, ")\n");
- }
- if (noexec && (flags & RUN_REALLY) == 0)
- return (0);
-
- /* make sure that we are null terminated, since we didn't calloc */
- run_add_arg ((char *) 0);
-
- /* setup default file descriptor numbers */
- shin = 0;
- shout = 1;
- sherr = 2;
-
- /* set the file modes for stdout and stderr */
- mode_out = mode_err = O_WRONLY | O_CREAT;
- mode_out |= ((flags & RUN_STDOUT_APPEND) ? O_APPEND : O_TRUNC);
- mode_err |= ((flags & RUN_STDERR_APPEND) ? O_APPEND : O_TRUNC);
-
- if (stin && (shin = open (stin, O_RDONLY)) == -1)
- {
- rerrno = errno;
- error (0, errno, "cannot open %s for reading (prog %s)",
- stin, run_argv[0]);
- goto out0;
- }
- if (stout && (shout = open (stout, mode_out, 0666)) == -1)
- {
- rerrno = errno;
- error (0, errno, "cannot open %s for writing (prog %s)",
- stout, run_argv[0]);
- goto out1;
- }
- if (sterr && (flags & RUN_COMBINED) == 0)
- {
- if ((sherr = open (sterr, mode_err, 0666)) == -1)
- {
- rerrno = errno;
- error (0, errno, "cannot open %s for writing (prog %s)",
- sterr, run_argv[0]);
- goto out2;
- }
- }
-
- /* The output files, if any, are now created. Do the fork and dups */
-#ifdef VFORK_MISSING
- pid = fork ();
-#else
- pid = vfork ();
-#endif
- if (pid == 0)
- {
- if (shin != 0)
- {
- (void) dup2 (shin, 0);
- (void) close (shin);
- }
- if (shout != 1)
- {
- (void) dup2 (shout, 1);
- (void) close (shout);
- }
- if (flags & RUN_COMBINED)
- (void) dup2 (1, 2);
- else if (sherr != 2)
- {
- (void) dup2 (sherr, 2);
- (void) close (sherr);
- }
-
- /* dup'ing is done. try to run it now */
- (void) execvp (run_argv[0], run_argv);
- _exit (127);
- }
- else if (pid == -1)
- {
- rerrno = errno;
- goto out;
- }
-
- /* the parent. Ignore some signals for now */
-#ifdef POSIX
- if (flags & RUN_SIGIGNORE)
- {
- act.sa_handler = SIG_IGN;
- (void) sigemptyset (&act.sa_mask);
- act.sa_flags = 0;
- (void) sigaction (SIGINT, &act, &iact);
- (void) sigaction (SIGQUIT, &act, &qact);
- }
- else
- {
- (void) sigemptyset (&sigset_mask);
- (void) sigaddset (&sigset_mask, SIGINT);
- (void) sigaddset (&sigset_mask, SIGQUIT);
- (void) sigprocmask (SIG_SETMASK, &sigset_mask, &sigset_omask);
- }
-#else
-#ifdef BSD_SIGNALS
- if (flags & RUN_SIGIGNORE)
- {
- bzero ((char *) &vec, sizeof (vec));
- vec.sv_handler = SIG_IGN;
- (void) sigvec (SIGINT, &vec, &ivec);
- (void) sigvec (SIGQUIT, &vec, &qvec);
- }
- else
- mask = sigblock (sigmask (SIGINT) | sigmask (SIGQUIT));
-#else
- istat = signal (SIGINT, SIG_IGN);
- qstat = signal (SIGQUIT, SIG_IGN);
-#endif
-#endif
-
- /* wait for our process to die and munge return status */
-#ifdef POSIX
- while ((w = waitpid (pid, &status, 0)) == -1 && errno == EINTR)
- ;
-#else
- while ((w = wait (&status)) != pid)
- {
- if (w == -1 && errno != EINTR)
- break;
- }
-#endif
- if (w == -1)
- {
- status = -1;
- rerrno = errno;
- }
- else if (WIFEXITED (status))
- status = WEXITSTATUS (status);
- else if (WIFSIGNALED (status))
- {
- if (WTERMSIG (status) == SIGPIPE)
- error (1, 0, "broken pipe");
- status = 2;
- }
- else
- status = 1;
-
- /* restore the signals */
-#ifdef POSIX
- if (flags & RUN_SIGIGNORE)
- {
- (void) sigaction (SIGINT, &iact, (struct sigaction *) NULL);
- (void) sigaction (SIGQUIT, &qact, (struct sigaction *) NULL);
- }
- else
- (void) sigprocmask (SIG_SETMASK, &sigset_omask, (sigset_t *) NULL);
-#else
-#ifdef BSD_SIGNALS
- if (flags & RUN_SIGIGNORE)
- {
- (void) sigvec (SIGINT, &ivec, (struct sigvec *) NULL);
- (void) sigvec (SIGQUIT, &qvec, (struct sigvec *) NULL);
- }
- else
- (void) sigsetmask (mask);
-#else
- (void) signal (SIGINT, istat);
- (void) signal (SIGQUIT, qstat);
-#endif
-#endif
-
- /* cleanup the open file descriptors */
- out:
- if (sterr)
- (void) close (sherr);
- out2:
- if (stout)
- (void) close (shout);
- out1:
- if (stin)
- (void) close (shin);
-
- out0:
- if (rerrno)
- errno = rerrno;
- return (status);
-}
-
-void
-run_print (fp)
- FILE *fp;
-{
- int i;
-
- for (i = 0; i < run_argc; i++)
- {
- (void) fprintf (fp, "%s", run_argv[i]);
- if (i != run_argc - 1)
- (void) fprintf (fp, " ");
- }
-}
-
-FILE *
-Popen (cmd, mode)
- char *cmd, *mode;
-{
- if (trace)
- (void) fprintf (stderr, "-> Popen(%s,%s)\n", cmd, mode);
- if (noexec)
- return (NULL);
- return (popen (cmd, mode));
-}
-
-#ifdef lint
-#ifndef __GNUC__
-/* ARGSUSED */
-time_t
-get_date (date, now)
- char *date;
- struct timeb *now;
-{
- time_t foo = 0;
-
- return (foo);
-}
-#endif
-#endif
diff --git a/gnu/usr.bin/cvs/lib/system.h b/gnu/usr.bin/cvs/lib/system.h
deleted file mode 100644
index 6cfd68f..0000000
--- a/gnu/usr.bin/cvs/lib/system.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/* system-dependent definitions for CVS.
- Copyright (C) 1989-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. */
-
-/* @(#)system.h 1.14 92/04/10 */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
-#ifndef mode_t
-#define mode_t unsigned short
-#endif
-#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)
-#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(MKFIFO_MISSING)
-#define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
-#endif
-
-#ifdef POSIX
-#include <unistd.h>
-#include <limits.h>
-#ifndef PATH_MAX
-#define PATH_MAX pathconf ("/", _PC_PATH_MAX)
-#endif
-#else
-off_t lseek ();
-#endif
-
-#ifdef TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
-#ifdef TIMEB_H_MISSING
-struct timeb {
- time_t time; /* Seconds since the epoch */
- unsigned short millitm; /* Field not used */
-#ifdef timezone
- short tzone;
-#else
- short timezone;
-#endif
- short dstflag; /* Field not used */
-};
-#else
-#include <sys/timeb.h>
-#endif
-
-#if defined(FTIME_MISSING) && !defined(HAVE_TIMEZONE)
-#if !defined(timezone)
-extern char *timezone();
-#endif
-#endif
-
-#ifndef POSIX
-#include <sys/param.h>
-#endif
-
-#ifndef _POSIX_PATH_MAX
-#define _POSIX_PATH_MAX 255
-#endif
-
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX _POSIX_PATH_MAX
-#endif
-#endif
-
-#ifdef POSIX
-#include <utime.h>
-#else
-#ifndef ALTOS
-struct utimbuf
-{
- long actime;
- long modtime;
-};
-#endif
-int utime ();
-#endif
-
-#if defined(USG) || defined(STDC_HEADERS)
-#include <string.h>
-#ifndef STDC_HEADERS
-#include <memory.h>
-#endif
-#ifndef index
-#define index strchr
-#endif
-#ifndef rindex
-#define rindex strrchr
-#endif
-#ifndef bcopy
-#define bcopy(from, to, len) memcpy ((to), (from), (len))
-#endif
-#ifndef bzero
-#define bzero(s, n) (void) memset ((s), 0, (n))
-#endif
-#ifndef bcmp
-#define bcmp(s1, s2, n) memcmp((s1), (s2), (n))
-#endif
-#else
-#include <strings.h>
-#endif
-
-#include <errno.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-char *getenv ();
-char *malloc ();
-char *realloc ();
-char *calloc ();
-extern int errno;
-#endif
-
-#ifdef __GNUC__
-#ifdef bsdi
-#define alloca __builtin_alloca
-#endif
-#else
-#ifdef sparc
-#include <alloca.h>
-#else
-#ifndef _AIX
-/* AIX alloca decl has to be the first thing in the file, bletch! */
-char *alloca ();
-#endif
-#endif
-#endif
-
-#if defined(USG) || defined(POSIX)
-#include <fcntl.h>
-char *getcwd ();
-#else
-#include <sys/file.h>
-char *getwd ();
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-#endif
-#ifndef F_OK
-#define F_OK 0
-#define X_OK 1
-#define W_OK 2
-#define R_OK 4
-#endif
-
-#ifdef DIRENT
-#include <dirent.h>
-#ifdef direct
-#undef direct
-#endif
-#define direct dirent
-#else
-#ifdef SYSNDIR
-#include <sys/ndir.h>
-#else
-#ifdef NDIR
-#include <ndir.h>
-#else /* must be BSD */
-#include <sys/dir.h>
-#endif
-#endif
-#endif
-
-/* Convert B 512-byte blocks to kilobytes if K is nonzero,
- otherwise return it unchanged. */
-#define convert_blocks(b, k) ((k) ? ((b) + 1) / 2 : (b))
-
-#ifndef S_ISLNK
-#define lstat stat
-#endif
-
-#ifndef SIGTYPE
-#define SIGTYPE void
-#endif
diff --git a/gnu/usr.bin/cvs/lib/wait.h b/gnu/usr.bin/cvs/lib/wait.h
deleted file mode 100644
index 49cfb6d..0000000
--- a/gnu/usr.bin/cvs/lib/wait.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* wait.h -- POSIX macros for evaluating exit statuses
- Copyright (C) 1990 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef POSIX
-#include <sys/types.h> /* For pid_t. */
-#include <sys/wait.h>
-#else
-#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
diff --git a/gnu/usr.bin/cvs/lib/y.tab.h b/gnu/usr.bin/cvs/lib/y.tab.h
deleted file mode 100644
index 4a541d2..0000000
--- a/gnu/usr.bin/cvs/lib/y.tab.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#define tAGO 257
-#define tDAY 258
-#define tDAYZONE 259
-#define tID 260
-#define tMERIDIAN 261
-#define tMINUTE_UNIT 262
-#define tMONTH 263
-#define tMONTH_UNIT 264
-#define tSEC_UNIT 265
-#define tSNUMBER 266
-#define tUNUMBER 267
-#define tZONE 268
-#define tDST 269
-typedef union {
- time_t Number;
- enum _MERIDIAN Meridian;
-} YYSTYPE;
-extern YYSTYPE yylval;
diff --git a/gnu/usr.bin/cvs/lib/yesno.c b/gnu/usr.bin/cvs/lib/yesno.c
deleted file mode 100644
index a705da7..0000000
--- a/gnu/usr.bin/cvs/lib/yesno.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* yesno.c -- read a yes/no response from stdin
- 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. */
-
-#include <stdio.h>
-
-/* Read one line from standard input
- and return nonzero if that line begins with y or Y,
- otherwise return 0. */
-
-int
-yesno ()
-{
- int c;
- int rv;
-
- fflush (stderr);
- c = getchar ();
- rv = (c == 'y') || (c == 'Y');
- while (c != EOF && c != '\n')
- c = getchar ();
-
- return rv;
-}
diff --git a/gnu/usr.bin/cvs/mkmodules/Makefile b/gnu/usr.bin/cvs/mkmodules/Makefile
deleted file mode 100644
index bec0bd6..0000000
--- a/gnu/usr.bin/cvs/mkmodules/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-PROG = mkmodules
-SRCS = mkmodules.c
-CFLAGS += -I${.CURDIR}/../cvs -I${.CURDIR}/../lib
-
-.if exists(${.CURDIR}/../lib/obj)
-LDADD= -L${.CURDIR}/../lib/obj -lcvs
-.else
-LDADD= -L${.CURDIR}/../lib/ -lcvs
-.endif
-
-.include <bsd.prog.mk>
-.include "../../Makefile.inc"
diff --git a/gnu/usr.bin/cvs/mkmodules/mkmodules.1 b/gnu/usr.bin/cvs/mkmodules/mkmodules.1
deleted file mode 100644
index 07ba3f5..0000000
--- a/gnu/usr.bin/cvs/mkmodules/mkmodules.1
+++ /dev/null
@@ -1,65 +0,0 @@
-.\"
-.\" @(#)mkmodules.1 1.3 92/01/30
-.\"
-.TH MKMODULES 1 "12 October 1991"
-.SH "NAME"
-mkmodules \- Rebuild modules database for CVS
-.SH "SYNOPSIS"
-.B mkmodules
-.I directory
-.SH "DESCRIPTION"
-.B mkmodules
-rebuilds the modules database that
-.BR cvs (1)
-uses.
-The
-.I directory
-specified is expected to contain the
-.BR modules,v " and " loginfo,v
-files.
-.B mkmodules
-carefully checks out the current head revisions of each of these files and
-reuilds the
-.BR ndbm (3)
-format modules database.
-A warning is generated if the modules file contains a duplicate key.
-.SH "FILES"
-.TP
-modules,v
-The modules
-.SM RCS
-file.
-.TP
-modules
-The checked out modules file.
-.TP
-loginfo,v
-The loginfo
-.SM RCS
-file.
-.TP
-loginfo
-The checked out loginfo file.
-.TP
-modules.dir, modules.pag
-The
-.BR ndbm (1)
-format modules database.
-.SH "ENVIRONMENT VARIABLES"
-.TP
-.SM RCSBIN
-Specifies the full pathname where to find
-.SM RCS
-programs, such as
-.BR co (1)
-and
-.BR ci (1).
-If not set, the default is
-.BR /usr/local/bin .
-.SH "SEE ALSO"
-.BR checkin (1),
-.BR co (1),
-.BR cvs (1),
-.BR ndbm (3),
-.BR rcs (1),
-.SH "BUGS"
diff --git a/gnu/usr.bin/cvs/mkmodules/mkmodules.c b/gnu/usr.bin/cvs/mkmodules/mkmodules.c
deleted file mode 100644
index 59ec13a..0000000
--- a/gnu/usr.bin/cvs/mkmodules/mkmodules.c
+++ /dev/null
@@ -1,395 +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.3 kit.
- *
- * mkmodules
- *
- * Re-build the modules database for the CVS system. Accepts one argument,
- * which is the directory that the modules,v file lives in.
- */
-
-#include "cvs.h"
-
-#undef PATH_MAX
-#define PATH_MAX 1024 /* max number of bytes in pathname */
-
-#ifndef lint
-static char rcsid[] = "@(#)mkmodules.c 1.39 92/03/31";
-#endif
-
-#ifndef DBLKSIZ
-#define DBLKSIZ 4096 /* since GNU ndbm doesn't define it */
-#endif
-
-char *program_name, *command_name;
-
-char *Rcsbin = RCSBIN_DFLT;
-int noexec = 0; /* Here only to satisfy use in subr.c */
-int trace = 0; /* Here only to satisfy use in subr.c */
-
-#if __STDC__
-static int checkout_file (char *file, char *temp);
-static void make_tempfile (char *temp);
-static void mkmodules_usage (void);
-static void rename_rcsfile (char *temp, char *real);
-
-#ifndef MY_NDBM
-static void rename_dbmfile (char *temp);
-static void write_dbmfile (char *temp);
-#endif /* !MY_NDBM */
-
-#else /* !__STDC__ */
-
-static void make_tempfile ();
-static int checkout_file ();
-static void rename_rcsfile ();
-static void mkmodules_usage ();
-
-#ifndef MY_NDBM
-static void write_dbmfile ();
-static void rename_dbmfile ();
-#endif /* !MY_NDBM */
-
-#endif /* __STDC__ */
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- extern char *getenv ();
- char temp[PATH_MAX];
- char *cp;
-#ifdef MY_NDBM
- DBM *db;
-#endif
-
- /*
- * Just save the last component of the path for error messages
- */
- if ((program_name = rindex (argv[0], '/')) == NULL)
- program_name = argv[0];
- else
- program_name++;
-
- if (argc != 2)
- mkmodules_usage ();
-
- if ((cp = getenv (RCSBIN_ENV)) != NULL)
- Rcsbin = cp;
-
- /*
- * If Rcsbin is set to something, make sure it is terminated with a slash
- * character. If not, add one.
- */
- if (Rcsbin[0] != '\0')
- {
- int len = strlen (Rcsbin);
- char *rcsbin;
-
- if (Rcsbin[len - 1] != '/')
- {
- rcsbin = Rcsbin;
- Rcsbin = xmalloc (len + 2); /* one for '/', one for NULL */
- (void) strcpy (Rcsbin, rcsbin);
- (void) strcat (Rcsbin, "/");
- }
- }
-
- if (chdir (argv[1]) < 0)
- error (1, errno, "cannot chdir to %s", argv[1]);
-
- /*
- * First, do the work necessary to update the "modules" database.
- */
- make_tempfile (temp);
- switch (checkout_file (CVSROOTADM_MODULES, temp))
- {
-
- case 0: /* everything ok */
-#ifdef MY_NDBM
- /* open it, to generate any duplicate errors */
- if ((db = dbm_open (temp, O_RDONLY, 0666)) != NULL)
- dbm_close (db);
-#else
- write_dbmfile (temp);
- rename_dbmfile (temp);
-#endif
- rename_rcsfile (temp, CVSROOTADM_MODULES);
- break;
-
- case -1: /* fork failed */
- (void) unlink_file (temp);
- exit (1);
- /* NOTREACHED */
-
- default:
- error (0, 0,
- "'cvs checkout' is less functional without a %s file",
- CVSROOTADM_MODULES);
- break;
- } /* switch on checkout_file() */
-
- (void) unlink_file (temp);
-
- /*
- * Now, check out the "loginfo" file, so that it is always up-to-date in
- * the CVSROOT directory.
- */
- make_tempfile (temp);
- if (checkout_file (CVSROOTADM_LOGINFO, temp) == 0)
- rename_rcsfile (temp, CVSROOTADM_LOGINFO);
- else
- error (0, 0,
- "no logging of 'cvs commit' messages is done without a %s file",
- CVSROOTADM_LOGINFO);
- (void) unlink_file (temp);
-
- /*
- * Now, check out the "rcsinfo" file, so that it is always up-to-date in
- * the CVSROOT directory.
- */
- make_tempfile (temp);
- if (checkout_file (CVSROOTADM_RCSINFO, temp) == 0)
- rename_rcsfile (temp, CVSROOTADM_RCSINFO);
- else
- error (0, 0,
- "a %s file can be used to configure 'cvs commit' templates",
- CVSROOTADM_RCSINFO);
- (void) unlink_file (temp);
-
- /*
- * Now, check out the "editinfo" file, so that it is always up-to-date in
- * the CVSROOT directory.
- */
- make_tempfile (temp);
- if (checkout_file (CVSROOTADM_EDITINFO, temp) == 0)
- rename_rcsfile (temp, CVSROOTADM_EDITINFO);
- else
- error (0, 0,
- "a %s file can be used to validate log messages",
- CVSROOTADM_EDITINFO);
- (void) unlink_file (temp);
-
- /*
- * Now, check out the "commitinfo" file, so that it is always up-to-date
- * in the CVSROOT directory.
- */
- make_tempfile (temp);
- if (checkout_file (CVSROOTADM_COMMITINFO, temp) == 0)
- rename_rcsfile (temp, CVSROOTADM_COMMITINFO);
- else
- error (0, 0,
- "a %s file can be used to configure 'cvs commit' checking",
- CVSROOTADM_COMMITINFO);
- (void) unlink_file (temp);
- return (0);
-}
-
-/*
- * Yeah, I know, there are NFS race conditions here.
- */
-static void
-make_tempfile (temp)
- char *temp;
-{
- static int seed = 0;
- int fd;
-
- if (seed == 0)
- seed = getpid ();
- while (1)
- {
- (void) sprintf (temp, "%s%d", BAKPREFIX, seed++);
- if ((fd = open (temp, O_CREAT|O_EXCL|O_RDWR, 0666)) != -1)
- break;
- if (errno != EEXIST)
- error (1, errno, "cannot create temporary file %s", temp);
- }
- if (close(fd) < 0)
- error(1, errno, "cannot close temporary file %s", temp);
-}
-
-static int
-checkout_file (file, temp)
- char *file;
- char *temp;
-{
- char rcs[PATH_MAX];
- int retcode = 0;
-
- (void) sprintf (rcs, "%s%s", file, RCSEXT);
- if (!isfile (rcs))
- return (1);
- run_setup ("%s%s -q -p", Rcsbin, RCS_CO);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, temp, RUN_TTY, RUN_NORMAL)) != 0)
- {
- error (0, retcode == -1 ? errno : 0, "failed to check out %s file", file);
- }
- return (retcode);
-}
-
-#ifndef MY_NDBM
-
-static void
-write_dbmfile (temp)
- char *temp;
-{
- char line[DBLKSIZ], value[DBLKSIZ];
- FILE *fp;
- DBM *db;
- char *cp, *vp;
- datum key, val;
- int len, cont, err = 0;
-
- fp = open_file (temp, "r");
- if ((db = dbm_open (temp, O_RDWR | O_CREAT | O_TRUNC, 0666)) == NULL)
- error (1, errno, "cannot open dbm file %s for creation", temp);
- for (cont = 0; fgets (line, sizeof (line), fp) != NULL;)
- {
- if ((cp = rindex (line, '\n')) != NULL)
- *cp = '\0'; /* strip the newline */
-
- /*
- * Add the line to the value, at the end if this is a continuation
- * line; otherwise at the beginning, but only after any trailing
- * backslash is removed.
- */
- vp = value;
- if (cont)
- vp += strlen (value);
-
- /*
- * See if the line we read is a continuation line, and strip the
- * backslash if so.
- */
- len = strlen (line);
- if (len > 0)
- cp = &line[len - 1];
- else
- cp = line;
- if (*cp == '\\')
- {
- cont = 1;
- *cp = '\0';
- }
- else
- {
- cont = 0;
- }
- (void) strcpy (vp, line);
- if (value[0] == '#')
- continue; /* comment line */
- vp = value;
- while (*vp && isspace (*vp))
- vp++;
- if (*vp == '\0')
- continue; /* empty line */
-
- /*
- * If this was not a continuation line, add the entry to the database
- */
- if (!cont)
- {
- key.dptr = vp;
- while (*vp && !isspace (*vp))
- vp++;
- key.dsize = vp - key.dptr;
- *vp++ = '\0'; /* NULL terminate the key */
- while (*vp && isspace (*vp))
- vp++; /* skip whitespace to value */
- if (*vp == '\0')
- {
- error (0, 0, "warning: NULL value for key `%s'", key.dptr);
- continue;
- }
- val.dptr = vp;
- val.dsize = strlen (vp);
- if (dbm_store (db, key, val, DBM_INSERT) == 1)
- {
- error (0, 0, "duplicate key found for `%s'", key.dptr);
- err++;
- }
- }
- }
- dbm_close (db);
- (void) fclose (fp);
- if (err)
- {
- char dotdir[50], dotpag[50];
-
- (void) sprintf (dotdir, "%s.dir", temp);
- (void) sprintf (dotpag, "%s.pag", temp);
- (void) unlink_file (dotdir);
- (void) unlink_file (dotpag);
- error (1, 0, "DBM creation failed; correct above errors");
- }
-}
-
-static void
-rename_dbmfile (temp)
- char *temp;
-{
- char newdir[50], newpag[50];
- char dotdir[50], dotpag[50];
- char bakdir[50], bakpag[50];
-
- (void) sprintf (dotdir, "%s.dir", CVSROOTADM_MODULES);
- (void) sprintf (dotpag, "%s.pag", CVSROOTADM_MODULES);
- (void) sprintf (bakdir, "%s%s.dir", BAKPREFIX, CVSROOTADM_MODULES);
- (void) sprintf (bakpag, "%s%s.pag", BAKPREFIX, CVSROOTADM_MODULES);
- (void) sprintf (newdir, "%s.dir", temp);
- (void) sprintf (newpag, "%s.pag", temp);
-
- (void) chmod (newdir, 0666);
- (void) chmod (newpag, 0666);
-
- /* don't mess with me */
- SIG_beginCrSect ();
-
- (void) unlink_file (bakdir); /* rm .#modules.dir .#modules.pag */
- (void) unlink_file (bakpag);
- (void) rename (dotdir, bakdir); /* mv modules.dir .#modules.dir */
- (void) rename (dotpag, bakpag); /* mv modules.pag .#modules.pag */
- (void) rename (newdir, dotdir); /* mv "temp".dir modules.dir */
- (void) rename (newpag, dotpag); /* mv "temp".pag modules.pag */
-
- /* OK -- make my day */
- SIG_endCrSect ();
-}
-
-#endif /* !MY_NDBM */
-
-static void
-rename_rcsfile (temp, real)
- char *temp;
- char *real;
-{
- char bak[50];
-
- if (chmod (temp, 0444) < 0) /* chmod 444 "temp" */
- error (0, errno, "warning: cannot chmod %s", temp);
- (void) sprintf (bak, "%s%s", BAKPREFIX, real);
- (void) unlink_file (bak); /* rm .#loginfo */
- (void) rename (real, bak); /* mv loginfo .#loginfo */
- (void) rename (temp, real); /* mv "temp" loginfo */
-}
-
-/*
- * For error() only
- */
-void
-Lock_Cleanup ()
-{
-}
-
-static void
-mkmodules_usage ()
-{
- (void) fprintf (stderr, "Usage: %s modules-directory\n", program_name);
- exit (1);
-}
diff --git a/gnu/usr.bin/cvs/mkmodules/xxx b/gnu/usr.bin/cvs/mkmodules/xxx
deleted file mode 100644
index f0dd87d..0000000
--- a/gnu/usr.bin/cvs/mkmodules/xxx
+++ /dev/null
@@ -1,5320 +0,0 @@
-# 1 "/usr/src/gnu/cvs/mkmodules/mkmodules.c"
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/syslimits.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 14 "/usr/src/gnu/cvs/mkmodules/mkmodules.c" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 1
-
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/types.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef unsigned char u_char;
-typedef unsigned short u_short;
-typedef unsigned int u_int;
-typedef unsigned long u_long;
-typedef unsigned short ushort;
-
-typedef char * caddr_t;
-typedef long daddr_t;
-typedef short dev_t;
-typedef u_long ino_t;
-typedef long off_t;
-typedef u_short nlink_t;
-typedef long swblk_t;
-typedef long segsz_t;
-typedef u_short uid_t;
-typedef u_short gid_t;
-typedef short pid_t;
-typedef u_short mode_t;
-typedef u_long fixpt_t;
-
-
-typedef struct _uquad { u_long val[2]; } u_quad;
-typedef struct _quad { long val[2]; } quad;
-typedef long * qaddr_t;
-
-
-
-
-
-
-# 1 "/usr/include/machine/ansi.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 69 "/usr/include/sys/types.h" 2
-
-
-# 1 "/usr/include/machine/types.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _physadr {
- int r[1];
-} *physadr;
-
-typedef struct label_t {
- int val[6];
-} label_t;
-
-typedef u_long vm_offset_t;
-typedef u_long vm_size_t;
-
-
-# 71 "/usr/include/sys/types.h" 2
-
-
-
-
-typedef unsigned long clock_t;
-
-
-
-
-typedef unsigned int size_t;
-
-
-
-
-typedef long time_t;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef long fd_mask;
-
-
-
-
-
-
-typedef struct fd_set {
- fd_mask fds_bits[(((256 )+(( (sizeof(fd_mask) * 8 ) )-1))/( (sizeof(fd_mask) * 8 ) )) ];
-} fd_set;
-
-
-
-
-
-
-# 132 "/usr/include/sys/types.h"
-
-
-
-
-# 20 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-# 1 "/usr/include/sys/stat.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct stat
-{
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- dev_t st_rdev;
- off_t st_size;
- time_t st_atime;
- long st_spare1;
- time_t st_mtime;
- long st_spare2;
- time_t st_ctime;
- long st_spare3;
- long st_blksize;
- long st_blocks;
- u_long st_flags;
- u_long st_gen;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 76 "/usr/include/sys/cdefs.h"
-
-
-
-# 114 "/usr/include/sys/stat.h" 2
-
-
-
-mode_t umask (mode_t) ;
-int chmod (const char *, mode_t) ;
-int fstat (int, struct stat *) ;
-int mkdir (const char *, mode_t) ;
-int mkfifo (const char *, mode_t) ;
-int stat (const char *, struct stat *) ;
-
-int fchmod (int, mode_t) ;
-int lstat (const char *, struct stat *) ;
-
-
-
-# 21 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-off_t lseek ();
-
-
-
-
-
-# 1 "/usr/include/time.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/machine/ansi.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 57 "/usr/include/machine/ansi.h"
-
-# 39 "/usr/include/time.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct tm {
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- long tm_gmtoff;
- char *tm_zone;
-};
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 74 "/usr/include/time.h" 2
-
-
-
-char *asctime (const struct tm *) ;
-clock_t clock (void) ;
-char *ctime (const time_t *) ;
-double difftime (time_t, time_t) ;
-struct tm *gmtime (const time_t *) ;
-struct tm *localtime (const time_t *) ;
-time_t mktime (struct tm *) ;
-size_t strftime (char *, size_t, const char *, const struct tm *) ;
-time_t time (time_t *) ;
-
-
-void tzset (void) ;
-
-
-
-char *timezone (int, int) ;
-void tzsetwall (void) ;
-
-
-
-
-# 72 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-
-
-# 86 "/usr/src/gnu/cvs/mkmodules/../lib/system.h"
-
-# 1 "/usr/include/sys/timeb.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct timeb {
- time_t time;
- unsigned short millitm;
- short timezone;
- short dstflag;
-};
-# 87 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/param.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/types.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 135 "/usr/include/sys/types.h"
-
-# 46 "/usr/include/sys/param.h" 2
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/syslimits.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 56 "/usr/include/sys/param.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/signal.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/machine/trap.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 42 "/usr/include/sys/signal.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 90 "/usr/include/sys/signal.h" 2
-
-
-
-typedef void (*sig_t) (int) ;
-
-
-typedef void (*__sighandler_t) (int) ;
-typedef unsigned int sigset_t;
-
-
-int sigaddset (sigset_t *, int) ;
-int sigdelset (sigset_t *, int) ;
-int sigemptyset (sigset_t *) ;
-int sigfillset (sigset_t *) ;
-int sigismember (const sigset_t *, int) ;
-
-
-
-
-
-
-
-
-
-
-
-struct sigaction {
- __sighandler_t sa_handler;
- sigset_t sa_mask;
- int sa_flags;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct sigvec {
- void (*sv_handler)();
- int sv_mask;
- int sv_flags;
-};
-
-
-
-
-
-
-
-struct sigaltstack {
- char *ss_base;
- int ss_len;
- int ss_onstack;
-};
-
-
-
-
-struct sigstack {
- char *ss_sp;
- int ss_onstack;
-};
-
-
-
-
-
-
-
-
-struct sigcontext {
- int sc_onstack;
- int sc_mask;
- int sc_sp;
- int sc_fp;
- int sc_ap;
- int sc_pc;
- int sc_ps;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/types.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 135 "/usr/include/sys/types.h"
-
-# 195 "/usr/include/sys/signal.h" 2
-
-
-
-
-__sighandler_t signal (int, __sighandler_t) ;
-int raise (int) ;
-
-int kill (pid_t, int) ;
-int sigaction (int, const struct sigaction *, struct sigaction *) ;
-int sigpending (sigset_t *) ;
-int sigprocmask (int, const sigset_t *, sigset_t *) ;
-int sigsuspend (const sigset_t *) ;
-
-
-int killpg (pid_t, int) ;
-void psignal (unsigned, const char *) ;
-int sigblock (int) ;
-int siginterrupt (int, int) ;
-int sigpause (int) ;
-int sigreturn (struct sigcontext *) ;
-int sigsetmask (int) ;
-int sigstack (const struct sigstack *, struct sigstack *) ;
-int sigvec (int, struct sigvec *, struct sigvec *) ;
-
-
-
-
-
-# 79 "/usr/include/sys/param.h" 2
-
-
-
-# 1 "/usr/include/machine/param.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 82 "/usr/include/sys/param.h" 2
-
-# 1 "/usr/include/machine/endian.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 55 "/usr/include/machine/endian.h" 2
-
-
-
-
-
-
-
-
-
-# 77 "/usr/include/machine/endian.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 106 "/usr/include/machine/endian.h"
-
-
-
-
-
-
-
-
-
-
-
-
-# 83 "/usr/include/sys/param.h" 2
-
-# 1 "/usr/include/machine/limits.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 84 "/usr/include/sys/param.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 97 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct utimbuf
-{
- long actime;
- long modtime;
-};
-
-int utime ();
-
-
-# 145 "/usr/src/gnu/cvs/mkmodules/../lib/system.h"
-
-# 1 "/usr/include/strings.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/string.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/machine/ansi.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 57 "/usr/include/machine/ansi.h"
-
-# 38 "/usr/include/string.h" 2
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 49 "/usr/include/string.h" 2
-
-
-
-void *memchr (const void *, int, size_t) ;
-int memcmp (const void *, const void *, size_t) ;
-void *memcpy (void *, const void *, size_t) ;
-void *memmove (void *, const void *, size_t) ;
-void *memset (void *, int, size_t) ;
-char *strcat (char *, const char *) ;
-char *strchr (const char *, int) ;
-int strcmp (const char *, const char *) ;
-int strcoll (const char *, const char *) ;
-char *strcpy (char *, const char *) ;
-size_t strcspn (const char *, const char *) ;
-char *strerror (int) ;
-size_t strlen (const char *) ;
-char *strncat (char *, const char *, size_t) ;
-int strncmp (const char *, const char *, size_t) ;
-char *strncpy (char *, const char *, size_t) ;
-char *strpbrk (const char *, const char *) ;
-char *strrchr (const char *, int) ;
-size_t strspn (const char *, const char *) ;
-char *strstr (const char *, const char *) ;
-char *strtok (char *, const char *) ;
-size_t strxfrm (char *, const char *, size_t) ;
-
-
-
-int bcmp (const void *, const void *, size_t) ;
-void bcopy (const void *, void *, size_t) ;
-void bzero (void *, size_t) ;
-int ffs (int) ;
-char *index (const char *, int) ;
-void *memccpy (void *, const void *, int, size_t) ;
-char *rindex (const char *, int) ;
-int strcasecmp (const char *, const char *) ;
-char *strdup (const char *) ;
-void strmode (int, char *) ;
-int strncasecmp (const char *, const char *, size_t) ;
-char *strsep (char **, const char *) ;
-void swab (const void *, void *, size_t) ;
-
-
-
-
-# 36 "/usr/include/strings.h" 2
-
-# 146 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-
-
-# 1 "/usr/include/errno.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern int errno;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 149 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-
-
-
-char *getenv ();
-char *malloc ();
-char *realloc ();
-char *calloc ();
-extern int errno;
-
-
-
-
-
-
-# 173 "/usr/src/gnu/cvs/mkmodules/../lib/system.h"
-
-
-
-
-
-
-# 1 "/usr/include/sys/file.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/fcntl.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/types.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 135 "/usr/include/sys/types.h"
-
-# 46 "/usr/include/sys/fcntl.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 99 "/usr/include/sys/fcntl.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct flock {
- short l_type;
- short l_whence;
- off_t l_start;
- off_t l_len;
- pid_t l_pid;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 169 "/usr/include/sys/fcntl.h" 2
-
-
-
-int open (const char *, int, ...) ;
-int creat (const char *, mode_t) ;
-int fcntl (int, int, ...) ;
-
-int flock (int, int) ;
-
-
-
-
-
-# 36 "/usr/include/sys/file.h" 2
-
-# 1 "/usr/include/sys/unistd.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 37 "/usr/include/sys/file.h" 2
-
-
-# 73 "/usr/include/sys/file.h"
-
-# 179 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-char *getwd ();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/dir.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/dirent.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct dirent {
- u_long d_fileno;
- u_short d_reclen;
- u_short d_namlen;
-
-
-
-
- char d_name[255 + 1];
-
-};
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _dirdesc {
- int dd_fd;
- long dd_loc;
- long dd_size;
- char *dd_buf;
- int dd_len;
- long dd_seek;
-} DIR;
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 88 "/usr/include/dirent.h" 2
-
-
-
-DIR *opendir (const char *) ;
-struct dirent *readdir (DIR *) ;
-void rewinddir (DIR *) ;
-int closedir (DIR *) ;
-
-long telldir (const DIR *) ;
-void seekdir (DIR *, long) ;
-int scandir (const char *, struct dirent ***,
- int (*)(struct dirent *), int (*)(const void *, const void *)) ;
-int alphasort (const void *, const void *) ;
-int getdirentries (int, char *, int, long *) ;
-
-
-
-
-
-
-# 44 "/usr/include/sys/dir.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 208 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 3 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/include/stdio.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 42 "/usr/include/stdio.h" 2
-
-
-# 1 "/usr/include/machine/ansi.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 57 "/usr/include/machine/ansi.h"
-
-# 44 "/usr/include/stdio.h" 2
-
-
-
-
-
-
-
-
-
-
-typedef long fpos_t;
-
-
-
-
-
-
-
-
-
-
-struct __sbuf {
- unsigned char *_base;
- int _size;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct __sFILE {
- unsigned char *_p;
- int _r;
- int _w;
- short _flags;
- short _file;
- struct __sbuf _bf;
- int _lbfsize;
-
-
- void *_cookie;
- int (*_close) (void *) ;
- int (*_read) (void *, char *, int) ;
- fpos_t (*_seek) (void *, fpos_t, int) ;
- int (*_write) (void *, const char *, int) ;
-
-
- struct __sbuf _ub;
- unsigned char *_up;
- int _ur;
-
-
- unsigned char _ubuf[3];
- unsigned char _nbuf[1];
-
-
- struct __sbuf _lb;
-
-
- int _blksize;
- int _offset;
-} FILE;
-
-
-extern FILE __sF[];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-void clearerr (FILE *) ;
-int fclose (FILE *) ;
-int feof (FILE *) ;
-int ferror (FILE *) ;
-int fflush (FILE *) ;
-int fgetc (FILE *) ;
-int fgetpos (FILE *, fpos_t *) ;
-char *fgets (char *, size_t, FILE *) ;
-FILE *fopen (const char *, const char *) ;
-int fprintf (FILE *, const char *, ...) ;
-int fputc (int, FILE *) ;
-int fputs (const char *, FILE *) ;
-int fread (void *, size_t, size_t, FILE *) ;
-FILE *freopen (const char *, const char *, FILE *) ;
-int fscanf (FILE *, const char *, ...) ;
-int fseek (FILE *, long, int) ;
-int fsetpos (FILE *, const fpos_t *) ;
-long ftell (const FILE *) ;
-int fwrite (const void *, size_t, size_t, FILE *) ;
-int getc (FILE *) ;
-int getchar (void) ;
-char *gets (char *) ;
-
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-void perror (const char *) ;
-int printf (const char *, ...) ;
-int putc (int, FILE *) ;
-int putchar (int) ;
-int puts (const char *) ;
-int remove (const char *) ;
-int rename (const char *, const char *) ;
-void rewind (FILE *) ;
-int scanf (const char *, ...) ;
-void setbuf (FILE *, char *) ;
-int setvbuf (FILE *, char *, int, size_t) ;
-int sprintf (char *, const char *, ...) ;
-int sscanf (char *, const char *, ...) ;
-FILE *tmpfile (void) ;
-char *tmpnam (char *) ;
-int ungetc (int, FILE *) ;
-int vfprintf (FILE *, const char *, char * ) ;
-int vprintf (const char *, char * ) ;
-int vsprintf (char *, const char *, char * ) ;
-
-
-
-
-
-
-
-
-
-
-char *ctermid (char *) ;
-FILE *fdopen (int, const char *) ;
-int fileno (FILE *) ;
-
-
-
-
-
-
-
-
-char *fgetline (FILE *, size_t *) ;
-int fpurge (FILE *) ;
-int getw (FILE *) ;
-int pclose (FILE *) ;
-FILE *popen (const char *, const char *) ;
-int putw (int, FILE *) ;
-void setbuffer (FILE *, char *, int) ;
-int setlinebuf (FILE *) ;
-char *tempnam (const char *, const char *) ;
-int snprintf (char *, size_t, const char *, ...) ;
-int vsnprintf (char *, size_t, const char *, char * ) ;
-int vscanf (const char *, char * ) ;
-int vsscanf (const char *, const char *, char * ) ;
-
-
-
-
-
-
-
-
-
-
-
-
-
-FILE *funopen (const void *,
- int (*)(void *, char *, int),
- int (*)(void *, const char *, int),
- fpos_t (*)(void *, fpos_t, int),
- int (*)(void *)) ;
-
-
-
-
-
-
-
-
-
-int __srget (FILE *) ;
-int __svfscanf (FILE *, const char *, char * ) ;
-int __swbuf (int, FILE *) ;
-
-
-
-
-
-
-
-
-static inline int __sputc(int _c, FILE *_p) {
- if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
- return (*_p->_p++ = _c);
- else
- return (__swbuf(_c, _p));
-}
-# 331 "/usr/include/stdio.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 4 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/include/ctype.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern char _ctype_[];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 5 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/include/pwd.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "/usr/include/sys/types.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 135 "/usr/include/sys/types.h"
-
-# 39 "/usr/include/pwd.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct passwd {
- char *pw_name;
- char *pw_passwd;
- int pw_uid;
- int pw_gid;
- time_t pw_change;
- char *pw_class;
- char *pw_gecos;
- char *pw_dir;
- char *pw_shell;
- time_t pw_expire;
-};
-
-# 1 "/usr/include/sys/cdefs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 78 "/usr/include/sys/cdefs.h"
-
-# 72 "/usr/include/pwd.h" 2
-
-
-
-struct passwd *getpwuid (uid_t) ;
-struct passwd *getpwnam (const char *) ;
-
-struct passwd *getpwent (void) ;
-int setpassent (int) ;
-int setpwent (void) ;
-void endpwent (void) ;
-
-
-
-
-# 6 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/include/signal.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 222 "/usr/include/signal.h"
-
-# 7 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/hash.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-enum ntype
-{
- UNKNOWN, HEADER, ENTRIES, FILES, LIST, RCSNODE,
- RCSVERS, DIRS, UPDATE, LOCK, NDBMNODE
-};
-typedef enum ntype Ntype;
-
-struct node
-{
- Ntype type;
- struct node *next;
- struct node *prev;
- struct node *hashnext;
- struct node *hashprev;
- char *key;
- char *data;
- void (*delproc) ();
-};
-typedef struct node Node;
-
-struct list
-{
- Node *list;
- Node *hasharray[151 ];
- struct list *next;
-};
-typedef struct list List;
-
-struct entnode
-{
- char *version;
- char *timestamp;
- char *options;
- char *tag;
- char *date;
-};
-typedef struct entnode Entnode;
-
-
-List *getlist (void);
-Node *findnode (List * list, char *key);
-Node *getnode (void);
-int addnode (List * list, Node * p);
-int walklist (List * list, int (*proc) ());
-void dellist (List ** listp);
-void delnode (Node * p);
-void freenode (Node * p);
-void sortlist (List * list, int (*comp) ());
-# 77 "/usr/src/gnu/cvs/mkmodules/../cvs/hash.h"
-
-# 8 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/rcs.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct rcsnode
-{
- int refcount;
- int flags;
- char *path;
- char *head;
- char *branch;
- List *symbols;
- List *versions;
- List *dates;
-};
-typedef struct rcsnode RCSNode;
-
-struct rcsversnode
-{
- char *version;
- char *date;
- char *next;
- List *branches;
-};
-typedef struct rcsversnode RCSVers;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-List *RCS_parsefiles (List * files, char *xrepos);
-RCSNode *RCS_parse (char *file, char *repos);
-RCSNode *RCS_parsercsfile (char *rcsfile);
-char *RCS_check_kflag (char *arg);
-char *RCS_getdate (RCSNode * rcs, char *date, int force_tag_match);
-char *RCS_gettag (RCSNode * rcs, char *tag, int force_tag_match);
-char *RCS_getversion (RCSNode * rcs, char *tag, char *date,
- int force_tag_match);
-char *RCS_magicrev (RCSNode *rcs, char *rev);
-int RCS_isbranch (char *file, char *rev, List *srcfiles);
-char *RCS_whatbranch (char *file, char *tag, List *srcfiles);
-char *RCS_head (RCSNode * rcs);
-int RCS_datecmp (char *date1, char *date2);
-time_t RCS_getrevtime (RCSNode * rcs, char *rev, char *date, int fudge);
-void RCS_check_tag (char *tag);
-void freercsnode (RCSNode ** rnodep);
-# 102 "/usr/src/gnu/cvs/mkmodules/../cvs/rcs.h"
-
-# 9 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../lib/regex.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef unsigned reg_syntax_t;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern reg_syntax_t obscure_syntax;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef enum
-{
- REG_NOERROR = 0,
- 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_EEND,
- REG_ESIZE,
- REG_ERPAREN
-} reg_errcode_t;
-
-
-
-
-
-
-
-
-
-
-struct re_pattern_buffer
-{
-
-
-
-
- unsigned char *buffer;
-
-
- unsigned long allocated;
-
-
- unsigned long used;
-
-
- reg_syntax_t syntax;
-
-
-
-
- char *fastmap;
-
-
-
-
-
- char *translate;
-
-
- size_t re_nsub;
-
-
-
-
-
-
- unsigned can_be_null : 2;
-
-
-
- unsigned fastmap_accurate : 1;
-
-
-
- unsigned no_sub : 1;
-
-
-
- unsigned not_bol : 1;
-
-
- unsigned not_eol : 1;
-
-
- unsigned newline_anchor : 1;
-
-
-
-
- unsigned caller_allocated_regs : 1;
-
-};
-
-typedef struct re_pattern_buffer regex_t;
-
-
-
-
-
-
-
-
-
-
-
-typedef int regoff_t;
-
-
-
-
-struct re_registers
-{
- unsigned num_regs;
- regoff_t *start;
- regoff_t *end;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct
-{
- regoff_t rm_so;
- regoff_t rm_eo;
-} regmatch_t;
-
-
-
-
-
-
-
-
-
-
-extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
-
-
-
-
-extern const char *re_compile_pattern (const char *pattern, int length,
- struct re_pattern_buffer *buffer);
-
-
-
-
-
-extern int re_compile_fastmap (struct re_pattern_buffer *buffer);
-
-
-
-
-
-
-
-extern int re_search (struct re_pattern_buffer *buffer,
- const char *string, int length,
- int start, int range,
- struct re_registers *regs);
-
-
-
-
-extern int re_search_2 (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);
-
-
-
-
-extern int re_match (const struct re_pattern_buffer *buffer,
- const char *string, int length,
- int start, struct re_registers *regs);
-
-
-
-extern int re_match_2 (const struct re_pattern_buffer *buffer,
- const char *string1, int length1,
- const char *string2, int length2,
- int start,
- struct re_registers *regs,
- int stop);
-
-
-
-
-
-
-
-
-
-
-
-extern int regcomp (regex_t *preg, const char *pattern, int cflags);
-extern int regexec (const regex_t *preg, const char *string, size_t nmatch,
- regmatch_t pmatch[], int eflags);
-extern size_t regerror (int errcode, const regex_t *preg, char *errbuf,
- size_t errbuf_size);
-extern void regfree (regex_t *preg);
-
-# 468 "/usr/src/gnu/cvs/mkmodules/../lib/regex.h"
-
-
-
-
-
-
-
-
-
-
-
-
-# 10 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../lib/fnmatch.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern int fnmatch (const char *pattern, const char *string, int flags);
-
-
-
-
-
-# 11 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../lib/getopt.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern char *optarg;
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern int optind;
-
-
-
-
-extern int opterr;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct option
-{
- char *name;
- int has_arg;
- int *flag;
- int val;
-};
-
-
-extern const struct option *_getopt_long_options;
-
-
-
-
-
-
-
-extern int _getopt_long_only;
-
-
-
-
-
-extern int option_index;
-
-
-int gnu_getopt (int argc, char **argv, const char *shortopts);
-int gnu_getopt_long (int argc, char **argv, const char *shortopts,
- const struct option *longopts, int *longind);
-int gnu_getopt_long_only (int argc, char **argv, const char *shortopts,
- const struct option *longopts, int *longind);
-
-
-
-
-
-# 12 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../lib/wait.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 13 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/config.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern void exit ();
-
-
-
-extern char *getwd ();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 14 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-
-# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/myndbm.h" 1
-
-
-
-
-
-
-typedef struct
-{
- List *dbm_list;
- Node *dbm_next;
-} DBM;
-
-typedef struct
-{
- char *dptr;
- int dsize;
-} datum;
-
-
-
-
-
-
-
-
-
-
-
-
-
-DBM *mydbm_open (char *file, int flags, int mode);
-void mydbm_close (DBM * db);
-datum mydbm_fetch (DBM * db, datum key);
-datum mydbm_firstkey (DBM * db);
-datum mydbm_nextkey (DBM * db);
-
-
-
-
-
-
-
-
-
-# 16 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-enum mtype
-{
- CHECKOUT, TAG, PATCH
-};
-
-
-
-
-
-
-enum classify_type
-{
- T_UNKNOWN = 1,
- T_CONFLICT,
- T_NEEDS_MERGE,
- T_MODIFIED,
- T_CHECKOUT,
- T_ADDED,
- T_REMOVED,
- T_REMOVE_ENTRY,
- T_UPTODATE,
- T_TITLE
-};
-typedef enum classify_type Ctype;
-
-
-
-
-
-
-
-
-struct vers_ts
-{
- char *vn_user;
-
-
-
-
-
- char *vn_rcs;
-
- char *ts_user;
- char *ts_rcs;
- char *options;
-
- char *tag;
- char *date;
- Entnode *entdata;
- RCSNode *srcfile;
-};
-typedef struct vers_ts Vers_TS;
-
-
-
-
-
-struct stickydirtag
-{
- int aflag;
- char *tag;
- char *date;
- char *options;
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-enum direnter_type
-{
- R_PROCESS = 1,
- R_SKIP_FILES,
- R_SKIP_DIRS,
- R_SKIP_ALL
-};
-typedef enum direnter_type Dtype;
-
-extern char *program_name, *command_name;
-extern char *Rcsbin, *Editor, *CVSroot;
-extern char *CurDir;
-extern int really_quiet, quiet;
-extern int use_editor;
-extern int cvswrite;
-
-extern int trace;
-extern int noexec;
-extern int logoff;
-
-
-
-int Reader_Lock (char *xrepository);
-DBM *open_module (void);
-FILE *Fopen (char *name, char *mode);
-FILE *open_file (char *name, char *mode);
-List *Find_Dirs (char *repository, int which);
-List *ParseEntries (int aflag);
-char *Make_Date (char *rawdate);
-char *Name_Repository (char *dir, char *update_dir);
-char *Short_Repository (char *repository);
-char *getcaller (void);
-char *time_stamp (char *file);
-char *xmalloc (int bytes);
-char *xrealloc (char *ptr, int bytes);
-char *xstrdup (char *str);
-int No_Difference (char *file, Vers_TS * vers, List * entries);
-int Parse_Info (char *infofile, char *repository, int (*callproc) (), int all);
-int Reader_Lock (char *xrepository);
-int SIG_register (int sig, void (*fn) ());
-int Writer_Lock (List * list);
-int gethostname (char *name, int namelen);
-int ign_name (char *name);
-int isdir (char *file);
-int isfile (char *file);
-int islink (char *file);
-int isreadable (char *file);
-int iswritable (char *file);
-int link_file (char *from, char *to);
-int numdots (char *s);
-int run_exec (char *stin, char *stout, char *sterr, int flags);
-int unlink_file (char *f);
-int update (int argc, char *argv[]);
-int xcmp (char *file1, char *file2);
-int yesno (void);
-time_t get_date (char *date, struct timeb *now);
-void Create_Admin (char *dir, char *repository, char *tag, char *date);
-void Lock_Cleanup (void);
-void ParseTag (char **tagp, char **datep);
-void Scratch_Entry (List * list, char *fname);
-void WriteTag (char *dir, char *tag, char *date);
-void cat_module (int status);
-void check_entries (char *dir);
-void close_module (DBM * db);
-void copy_file (char *from, char *to);
-void error (int status, int errnum, char *message,...);
-void fperror (FILE * fp, int status, int errnum, char *message,...);
-void free_names (int *pargc, char *argv[]);
-void freevers_ts (Vers_TS ** versp);
-void ign_add (char *ign, int hold);
-void ign_add_file (char *file, int hold);
-void ign_setup (void);
-void line2argv (int *pargc, char *argv[], char *line);
-void make_directories (char *name);
-void make_directory (char *name);
-void rename_file (char *from, char *to);
-void run_arg (char *s);
-void run_args (char *fmt,...);
-void run_print (FILE * fp);
-void run_setup (char *fmt,...);
-void strip_path (char *path);
-void update_delproc (Node * p);
-void usage (char **cpp);
-void xchmod (char *fname, int writable);
-int Checkin (int type, char *file, char *repository, char *rcs, char *rev,
- char *tag, char *message, List * entries);
-Ctype Classify_File (char *file, char *tag, char *date, char *options,
- int force_tag_match, int aflag, char *repository,
- List *entries, List *srcfiles, Vers_TS **versp);
-List *Find_Names (char *repository, int which, int aflag,
- List ** optentries);
-void Register (List * list, char *fname, char *vn, char *ts,
- char *options, char *tag, char *date);
-void Update_Logfile (char *repository, char *xmessage, char *xrevision,
- FILE * xlogfp, List * xchanges);
-Vers_TS *Version_TS (char *repository, char *options, char *tag,
- char *date, char *user, int force_tag_match,
- int set_time, List * entries, List * xfiles);
-void do_editor (char *dir, char *message, char *repository,
- List * changes);
-int do_module (DBM * db, char *mname, enum mtype m_type, char *msg,
- int (*callback_proc) (), char *where, int shorten,
- int local_specified, int run_module_prog, char *extra_arg);
-int do_recursion (int (*xfileproc) (), int (*xfilesdoneproc) (),
- Dtype (*xdirentproc) (), int (*xdirleaveproc) (),
- Dtype xflags, int xwhich, int xaflag, int xreadlock,
- int xdosrcs);
-int do_update (int argc, char *argv[], char *xoptions, char *xtag,
- char *xdate, int xforce, int local, int xbuild,
- int xaflag, int xprune, int xpipeout, int which,
- char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir);
-void history_write (int type, char *update_dir, char *revs, char *name,
- char *repository);
-int start_recursion (int (*fileproc) (), int (*filesdoneproc) (),
- Dtype (*direntproc) (), int (*dirleaveproc) (),
- int argc, char *argv[], int local, int which,
- int aflag, int readlock, char *update_preload,
- int dosrcs);
-void SIG_beginCrSect ();
-void SIG_endCrSect ();
-# 438 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h"
-
-# 15 "/usr/src/gnu/cvs/mkmodules/mkmodules.c" 2
-
-
-
-
-
-
-PATH_MAX +2
-
-
-static char rcsid[] = "@(#)mkmodules.c 1.39 92/03/31";
-
-
-
-
-
-
-char *program_name, *command_name;
-
-char *Rcsbin = "" ;
-int noexec = 0;
-int trace = 0;
-
-
-static int checkout_file (char *file, char *temp);
-static void make_tempfile (char *temp);
-static void mkmodules_usage (void);
-static void rename_rcsfile (char *temp, char *real);
-
-
-
-
-
-
-# 60 "/usr/src/gnu/cvs/mkmodules/mkmodules.c"
-
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- extern char *getenv ();
- char temp[PATH_MAX +2 ];
- char *cp;
-
- DBM *db;
-
-
-
-
-
- if ((program_name = rindex (argv[0], '/')) == 0 )
- program_name = argv[0];
- else
- program_name++;
-
- if (argc != 2)
- mkmodules_usage ();
-
- if ((cp = getenv ("RCSBIN" )) != 0 )
- Rcsbin = cp;
-
-
-
-
-
- if (Rcsbin[0] != '\0')
- {
- int len = strlen (Rcsbin);
- char *rcsbin;
-
- if (Rcsbin[len - 1] != '/')
- {
- rcsbin = Rcsbin;
- Rcsbin = xmalloc (len + 2);
- (void) strcpy (Rcsbin, rcsbin);
- (void) strcat (Rcsbin, "/");
- }
- }
-
- if (chdir (argv[1]) < 0)
- error (1, errno, "cannot chdir to %s", argv[1]);
-
-
-
-
- make_tempfile (temp);
- switch (checkout_file ("modules" , temp))
- {
-
- case 0:
-
-
- if ((db = mydbm_open (temp, 0x0000 , 0666)) != 0 )
- mydbm_close (db);
-
-
-
-
- rename_rcsfile (temp, "modules" );
- break;
-
- case -1:
- (void) unlink_file (temp);
- exit (1);
-
-
- default:
- error (0, 0,
- "'cvs checkout' is less functional without a %s file",
- "modules" );
- break;
- }
-
- (void) unlink_file (temp);
-
-
-
-
-
- make_tempfile (temp);
- if (checkout_file ("loginfo" , temp) == 0)
- rename_rcsfile (temp, "loginfo" );
- else
- error (0, 0,
- "no logging of 'cvs commit' messages is done without a %s file",
- "loginfo" );
- (void) unlink_file (temp);
-
-
-
-
-
- make_tempfile (temp);
- if (checkout_file ("rcsinfo" , temp) == 0)
- rename_rcsfile (temp, "rcsinfo" );
- else
- error (0, 0,
- "a %s file can be used to configure 'cvs commit' templates",
- "rcsinfo" );
- (void) unlink_file (temp);
-
-
-
-
-
- make_tempfile (temp);
- if (checkout_file ("editinfo" , temp) == 0)
- rename_rcsfile (temp, "editinfo" );
- else
- error (0, 0,
- "a %s file can be used to validate log messages",
- "editinfo" );
- (void) unlink_file (temp);
-
-
-
-
-
- make_tempfile (temp);
- if (checkout_file ("commitinfo" , temp) == 0)
- rename_rcsfile (temp, "commitinfo" );
- else
- error (0, 0,
- "a %s file can be used to configure 'cvs commit' checking",
- "commitinfo" );
- (void) unlink_file (temp);
- return (0);
-}
-
-
-
-
-static void
-make_tempfile (temp)
- char *temp;
-{
- static int seed = 0;
- int fd;
-
- if (seed == 0)
- seed = getpid ();
- while (1)
- {
- (void) sprintf (temp, "%s%d", ".#" , seed++);
- if ((fd = open (temp, 0x0200 | 0x0800 | 0x0002 , 0666)) != -1)
- break;
- if (errno != 17 )
- error (1, errno, "cannot create temporary file %s", temp);
- }
- if (close(fd) < 0)
- error(1, errno, "cannot close temporary file %s", temp);
-}
-
-static int
-checkout_file (file, temp)
- char *file;
- char *temp;
-{
- char rcs[PATH_MAX +2 ];
- int retcode = 0;
-
- (void) sprintf (rcs, "%s%s", file, ",v" );
- if (!isfile (rcs))
- return (1);
- run_setup ("%s%s -q -p", Rcsbin, "co" );
- run_arg (rcs);
- if ((retcode = run_exec ( (char *)0 , temp, (char *)0 , 0x0000 )) != 0)
- {
- error (0, retcode == -1 ? errno : 0, "failed to check out %s file", file);
- }
- return (retcode);
-}
-
-# 369 "/usr/src/gnu/cvs/mkmodules/mkmodules.c"
-
-
-static void
-rename_rcsfile (temp, real)
- char *temp;
- char *real;
-{
- char bak[50];
-
- if (chmod (temp, 0444) < 0)
- error (0, errno, "warning: cannot chmod %s", temp);
- (void) sprintf (bak, "%s%s", ".#" , real);
- (void) unlink_file (bak);
- (void) rename (real, bak);
- (void) rename (temp, real);
-}
-
-
-
-
-void
-Lock_Cleanup ()
-{
-}
-
-static void
-mkmodules_usage ()
-{
- (void) fprintf ((&__sF[2]) , "Usage: %s modules-directory\n", program_name);
- exit (1);
-}
diff --git a/gnu/usr.bin/diff/COPYING b/gnu/usr.bin/diff/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/diff/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/diff/Makefile b/gnu/usr.bin/diff/Makefile
deleted file mode 100644
index e75c0a0..0000000
--- a/gnu/usr.bin/diff/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-
-PROG= diff
-SRCS= diff.c analyze.c io.c context.c ed.c normal.c ifdef.c util.c dir.c \
- version.c regex.c getopt.c getopt1.c side.c
-CFLAGS+=-DDIRENT=1 -DHAVE_UNISTD_H=1 -DHAVE_DUP2=1 -DHAVE_MEMCHR=1 \
- -DHAVE_STRERROR=1 -DHAVE_WAITPID=1 -DHAVE_FCNTL_H=1 \
- -DHAVE_STRING_H=1 -DHAVE_SYS_WAIT_H=1 -DHAVE_TIME_H=1 \
- -DHAVE_ST_BLKSIZE=1
-NOMAN=noman
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/diff/analyze.c b/gnu/usr.bin/diff/analyze.c
deleted file mode 100644
index 42167b9..0000000
--- a/gnu/usr.bin/diff/analyze.c
+++ /dev/null
@@ -1,944 +0,0 @@
-/* Analyze file differences for GNU DIFF.
- Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* The basic algorithm is described in:
- "An O(ND) Difference Algorithm and its Variations", Eugene Myers,
- Algorithmica Vol. 1 No. 2, 1986, p 251. */
-
-#include "diff.h"
-
-int read_files ();
-void finish_output ();
-void print_context_script ();
-void print_ed_script ();
-void print_ifdef_script ();
-void print_sdiff_script ();
-void print_normal_script ();
-void print_rcs_script ();
-void pr_forward_ed_script ();
-void setup_output ();
-
-extern int no_discards;
-
-static int *xvec, *yvec; /* Vectors being compared. */
-static int *fdiag; /* Vector, indexed by diagonal, containing
- the X coordinate of the point furthest
- along the given diagonal in the forward
- search of the edit matrix. */
-static int *bdiag; /* Vector, indexed by diagonal, containing
- the X coordinate of the point furthest
- along the given diagonal in the backward
- search of the edit matrix. */
-
-/* Find the midpoint of the shortest edit script for a specified
- portion of the two files.
-
- We scan from the beginnings of the files, and simultaneously from the ends,
- doing a breadth-first search through the space of edit-sequence.
- When the two searches meet, we have found the midpoint of the shortest
- edit sequence.
-
- The value returned is the number of the diagonal on which the midpoint lies.
- The diagonal number equals the number of inserted lines minus the number
- of deleted lines (counting only lines before the midpoint).
- The edit cost is stored into *COST; this is the total number of
- lines inserted or deleted (counting only lines before the midpoint).
-
- This function assumes that the first lines of the specified portions
- of the two files do not match, and likewise that the last lines do not
- match. The caller must trim matching lines from the beginning and end
- of the portions it is going to specify.
-
- Note that if we return the "wrong" diagonal value, or if
- the value of bdiag at that diagonal is "wrong",
- the worst this can do is cause suboptimal diff output.
- It cannot cause incorrect diff output. */
-
-static int
-diag (xoff, xlim, yoff, ylim, cost)
- int xoff, xlim, yoff, ylim;
- int *cost;
-{
- int *const fd = fdiag; /* Give the compiler a chance. */
- int *const bd = bdiag; /* Additional help for the compiler. */
- int *const xv = xvec; /* Still more help for the compiler. */
- int *const yv = yvec; /* And more and more . . . */
- const int dmin = xoff - ylim; /* Minimum valid diagonal. */
- const int dmax = xlim - yoff; /* Maximum valid diagonal. */
- const int fmid = xoff - yoff; /* Center diagonal of top-down search. */
- const int bmid = xlim - ylim; /* Center diagonal of bottom-up search. */
- int fmin = fmid, fmax = fmid; /* Limits of top-down search. */
- int bmin = bmid, bmax = bmid; /* Limits of bottom-up search. */
- int c; /* Cost. */
- int odd = (fmid - bmid) & 1; /* True if southeast corner is on an odd
- diagonal with respect to the northwest. */
-
- fd[fmid] = xoff;
- bd[bmid] = xlim;
-
- for (c = 1;; ++c)
- {
- int d; /* Active diagonal. */
- int big_snake = 0;
-
- /* Extend the top-down search by an edit step in each diagonal. */
- fmin > dmin ? fd[--fmin - 1] = -1 : ++fmin;
- fmax < dmax ? fd[++fmax + 1] = -1 : --fmax;
- for (d = fmax; d >= fmin; d -= 2)
- {
- int x, y, oldx, tlo = fd[d - 1], thi = fd[d + 1];
-
- if (tlo >= thi)
- x = tlo + 1;
- else
- x = thi;
- oldx = x;
- y = x - d;
- while (x < xlim && y < ylim && xv[x] == yv[y])
- ++x, ++y;
- if (x - oldx > 20)
- big_snake = 1;
- fd[d] = x;
- if (odd && bmin <= d && d <= bmax && bd[d] <= fd[d])
- {
- *cost = 2 * c - 1;
- return d;
- }
- }
-
- /* Similar extend the bottom-up search. */
- bmin > dmin ? bd[--bmin - 1] = INT_MAX : ++bmin;
- bmax < dmax ? bd[++bmax + 1] = INT_MAX : --bmax;
- for (d = bmax; d >= bmin; d -= 2)
- {
- int x, y, oldx, tlo = bd[d - 1], thi = bd[d + 1];
-
- if (tlo < thi)
- x = tlo;
- else
- x = thi - 1;
- oldx = x;
- y = x - d;
- while (x > xoff && y > yoff && xv[x - 1] == yv[y - 1])
- --x, --y;
- if (oldx - x > 20)
- big_snake = 1;
- bd[d] = x;
- if (!odd && fmin <= d && d <= fmax && bd[d] <= fd[d])
- {
- *cost = 2 * c;
- return d;
- }
- }
-
- /* Heuristic: check occasionally for a diagonal that has made
- lots of progress compared with the edit distance.
- If we have any such, find the one that has made the most
- progress and return it as if it had succeeded.
-
- With this heuristic, for files with a constant small density
- of changes, the algorithm is linear in the file size. */
-
- if (c > 200 && big_snake && heuristic)
- {
- int best;
- int bestpos;
-
- best = 0;
- for (d = fmax; d >= fmin; d -= 2)
- {
- int dd = d - fmid;
- if ((fd[d] - xoff)*2 - dd > 12 * (c + (dd > 0 ? dd : -dd)))
- {
- if (fd[d] * 2 - dd > best
- && fd[d] - xoff > 20
- && fd[d] - d - yoff > 20)
- {
- int k;
- int x = fd[d];
-
- /* We have a good enough best diagonal;
- now insist that it end with a significant snake. */
- for (k = 1; k <= 20; k++)
- if (xvec[x - k] != yvec[x - d - k])
- break;
-
- if (k == 21)
- {
- best = fd[d] * 2 - dd;
- bestpos = d;
- }
- }
- }
- }
- if (best > 0)
- {
- *cost = 2 * c - 1;
- return bestpos;
- }
-
- best = 0;
- for (d = bmax; d >= bmin; d -= 2)
- {
- int dd = d - bmid;
- if ((xlim - bd[d])*2 + dd > 12 * (c + (dd > 0 ? dd : -dd)))
- {
- if ((xlim - bd[d]) * 2 + dd > best
- && xlim - bd[d] > 20
- && ylim - (bd[d] - d) > 20)
- {
- /* We have a good enough best diagonal;
- now insist that it end with a significant snake. */
- int k;
- int x = bd[d];
-
- for (k = 0; k < 20; k++)
- if (xvec[x + k] != yvec[x - d + k])
- break;
- if (k == 20)
- {
- best = (xlim - bd[d]) * 2 + dd;
- bestpos = d;
- }
- }
- }
- }
- if (best > 0)
- {
- *cost = 2 * c - 1;
- return bestpos;
- }
- }
- }
-}
-
-/* Compare in detail contiguous subsequences of the two files
- which are known, as a whole, to match each other.
-
- The results are recorded in the vectors files[N].changed_flag, by
- storing a 1 in the element for each line that is an insertion or deletion.
-
- The subsequence of file 0 is [XOFF, XLIM) and likewise for file 1.
-
- Note that XLIM, YLIM are exclusive bounds.
- All line numbers are origin-0 and discarded lines are not counted. */
-
-static void
-compareseq (xoff, xlim, yoff, ylim)
- int xoff, xlim, yoff, ylim;
-{
- /* Slide down the bottom initial diagonal. */
- while (xoff < xlim && yoff < ylim && xvec[xoff] == yvec[yoff])
- ++xoff, ++yoff;
- /* Slide up the top initial diagonal. */
- while (xlim > xoff && ylim > yoff && xvec[xlim - 1] == yvec[ylim - 1])
- --xlim, --ylim;
-
- /* Handle simple cases. */
- if (xoff == xlim)
- while (yoff < ylim)
- files[1].changed_flag[files[1].realindexes[yoff++]] = 1;
- else if (yoff == ylim)
- while (xoff < xlim)
- files[0].changed_flag[files[0].realindexes[xoff++]] = 1;
- else
- {
- int c, d, f, b;
-
- /* Find a point of correspondence in the middle of the files. */
-
- d = diag (xoff, xlim, yoff, ylim, &c);
- f = fdiag[d];
- b = bdiag[d];
-
- if (c == 1)
- {
- /* This should be impossible, because it implies that
- one of the two subsequences is empty,
- and that case was handled above without calling `diag'.
- Let's verify that this is true. */
- abort ();
-#if 0
- /* The two subsequences differ by a single insert or delete;
- record it and we are done. */
- if (d < xoff - yoff)
- files[1].changed_flag[files[1].realindexes[b - d - 1]] = 1;
- else
- files[0].changed_flag[files[0].realindexes[b]] = 1;
-#endif
- }
- else
- {
- /* Use that point to split this problem into two subproblems. */
- compareseq (xoff, b, yoff, b - d);
- /* This used to use f instead of b,
- but that is incorrect!
- It is not necessarily the case that diagonal d
- has a snake from b to f. */
- compareseq (b, xlim, b - d, ylim);
- }
- }
-}
-
-/* Discard lines from one file that have no matches in the other file.
-
- A line which is discarded will not be considered by the actual
- comparison algorithm; it will be as if that line were not in the file.
- The file's `realindexes' table maps virtual line numbers
- (which don't count the discarded lines) into real line numbers;
- this is how the actual comparison algorithm produces results
- that are comprehensible when the discarded lines are counted.
-
- When we discard a line, we also mark it as a deletion or insertion
- so that it will be printed in the output. */
-
-void
-discard_confusing_lines (filevec)
- struct file_data filevec[];
-{
- unsigned int f, i;
- char *discarded[2];
- int *equiv_count[2];
- int *p;
-
- /* Allocate our results. */
- p = (int *) xmalloc ((filevec[0].buffered_lines + filevec[1].buffered_lines)
- * (2 * sizeof (int)));
- for (f = 0; f < 2; f++)
- {
- filevec[f].undiscarded = p; p += filevec[f].buffered_lines;
- filevec[f].realindexes = p; p += filevec[f].buffered_lines;
- }
-
- /* Set up equiv_count[F][I] as the number of lines in file F
- that fall in equivalence class I. */
-
- p = (int *) xmalloc (filevec[0].equiv_max * (2 * sizeof (int)));
- equiv_count[0] = p;
- equiv_count[1] = p + filevec[0].equiv_max;
- bzero (p, filevec[0].equiv_max * (2 * sizeof (int)));
-
- for (i = 0; i < filevec[0].buffered_lines; ++i)
- ++equiv_count[0][filevec[0].equivs[i]];
- for (i = 0; i < filevec[1].buffered_lines; ++i)
- ++equiv_count[1][filevec[1].equivs[i]];
-
- /* Set up tables of which lines are going to be discarded. */
-
- discarded[0] = (char *) xmalloc (filevec[0].buffered_lines
- + filevec[1].buffered_lines);
- discarded[1] = discarded[0] + filevec[0].buffered_lines;
- bzero (discarded[0], filevec[0].buffered_lines + filevec[1].buffered_lines);
-
- /* Mark to be discarded each line that matches no line of the other file.
- If a line matches many lines, mark it as provisionally discardable. */
-
- for (f = 0; f < 2; f++)
- {
- unsigned int end = filevec[f].buffered_lines;
- char *discards = discarded[f];
- int *counts = equiv_count[1 - f];
- int *equivs = filevec[f].equivs;
- unsigned int many = 5;
- unsigned int tem = end / 64;
-
- /* Multiply MANY by approximate square root of number of lines.
- That is the threshold for provisionally discardable lines. */
- while ((tem = tem >> 2) > 0)
- many *= 2;
-
- for (i = 0; i < end; i++)
- {
- int nmatch;
- if (equivs[i] == 0)
- continue;
- nmatch = counts[equivs[i]];
- if (nmatch == 0)
- discards[i] = 1;
- else if (nmatch > many)
- discards[i] = 2;
- }
- }
-
- /* Don't really discard the provisional lines except when they occur
- in a run of discardables, with nonprovisionals at the beginning
- and end. */
-
- for (f = 0; f < 2; f++)
- {
- unsigned int end = filevec[f].buffered_lines;
- register char *discards = discarded[f];
-
- for (i = 0; i < end; i++)
- {
- /* Cancel provisional discards not in middle of run of discards. */
- if (discards[i] == 2)
- discards[i] = 0;
- else if (discards[i] != 0)
- {
- /* We have found a nonprovisional discard. */
- register int j;
- unsigned int length;
- unsigned int provisional = 0;
-
- /* Find end of this run of discardable lines.
- Count how many are provisionally discardable. */
- for (j = i; j < end; j++)
- {
- if (discards[j] == 0)
- break;
- if (discards[j] == 2)
- ++provisional;
- }
-
- /* Cancel provisional discards at end, and shrink the run. */
- while (j > i && discards[j - 1] == 2)
- discards[--j] = 0, --provisional;
-
- /* Now we have the length of a run of discardable lines
- whose first and last are not provisional. */
- length = j - i;
-
- /* If 1/4 of the lines in the run are provisional,
- cancel discarding of all provisional lines in the run. */
- if (provisional * 4 > length)
- {
- while (j > i)
- if (discards[--j] == 2)
- discards[j] = 0;
- }
- else
- {
- register unsigned int consec;
- unsigned int minimum = 1;
- unsigned int tem = length / 4;
-
- /* MINIMUM is approximate square root of LENGTH/4.
- A subrun of two or more provisionals can stand
- when LENGTH is at least 16.
- A subrun of 4 or more can stand when LENGTH >= 64. */
- while ((tem = tem >> 2) > 0)
- minimum *= 2;
- minimum++;
-
- /* Cancel any subrun of MINIMUM or more provisionals
- within the larger run. */
- for (j = 0, consec = 0; j < length; j++)
- if (discards[i + j] != 2)
- consec = 0;
- else if (minimum == ++consec)
- /* Back up to start of subrun, to cancel it all. */
- j -= consec;
- else if (minimum < consec)
- discards[i + j] = 0;
-
- /* Scan from beginning of run
- until we find 3 or more nonprovisionals in a row
- or until the first nonprovisional at least 8 lines in.
- Until that point, cancel any provisionals. */
- for (j = 0, consec = 0; j < length; j++)
- {
- if (j >= 8 && discards[i + j] == 1)
- break;
- if (discards[i + j] == 2)
- consec = 0, discards[i + j] = 0;
- else if (discards[i + j] == 0)
- consec = 0;
- else
- consec++;
- if (consec == 3)
- break;
- }
-
- /* I advances to the last line of the run. */
- i += length - 1;
-
- /* Same thing, from end. */
- for (j = 0, consec = 0; j < length; j++)
- {
- if (j >= 8 && discards[i - j] == 1)
- break;
- if (discards[i - j] == 2)
- consec = 0, discards[i - j] = 0;
- else if (discards[i - j] == 0)
- consec = 0;
- else
- consec++;
- if (consec == 3)
- break;
- }
- }
- }
- }
- }
-
- /* Actually discard the lines. */
- for (f = 0; f < 2; f++)
- {
- char *discards = discarded[f];
- unsigned int end = filevec[f].buffered_lines;
- unsigned int j = 0;
- for (i = 0; i < end; ++i)
- if (no_discards || discards[i] == 0)
- {
- filevec[f].undiscarded[j] = filevec[f].equivs[i];
- filevec[f].realindexes[j++] = i;
- }
- else
- filevec[f].changed_flag[i] = 1;
- filevec[f].nondiscarded_lines = j;
- }
-
- free (discarded[0]);
- free (equiv_count[0]);
-}
-
-/* Adjust inserts/deletes of blank lines to join changes
- as much as possible.
-
- We do something when a run of changed lines include a blank
- line at one end and have an excluded blank line at the other.
- We are free to choose which blank line is included.
- `compareseq' always chooses the one at the beginning,
- but usually it is cleaner to consider the following blank line
- to be the "change". The only exception is if the preceding blank line
- would join this change to other changes. */
-
-int inhibit;
-
-static void
-shift_boundaries (filevec)
- struct file_data filevec[];
-{
- int f;
-
- if (inhibit)
- return;
-
- for (f = 0; f < 2; f++)
- {
- char *changed = filevec[f].changed_flag;
- char *other_changed = filevec[1-f].changed_flag;
- int i = 0;
- int j = 0;
- int i_end = filevec[f].buffered_lines;
- int preceding = -1;
- int other_preceding = -1;
-
- while (1)
- {
- int start, other_start;
-
- /* Scan forwards to find beginning of another run of changes.
- Also keep track of the corresponding point in the other file. */
-
- while (i < i_end && changed[i] == 0)
- {
- while (other_changed[j++])
- /* Non-corresponding lines in the other file
- will count as the preceding batch of changes. */
- other_preceding = j;
- i++;
- }
-
- if (i == i_end)
- break;
-
- start = i;
- other_start = j;
-
- while (1)
- {
- /* Now find the end of this run of changes. */
-
- while (changed[++i] != 0)
- ;
-
- /* If the first changed line matches the following unchanged one,
- and this run does not follow right after a previous run,
- and there are no lines deleted from the other file here,
- then classify the first changed line as unchanged
- and the following line as changed in its place. */
-
- /* You might ask, how could this run follow right after another?
- Only because the previous run was shifted here. */
-
- if (i != i_end
- && files[f].equivs[start] == files[f].equivs[i]
- && !other_changed[j]
- && !(start == preceding || other_start == other_preceding))
- {
- changed[start++] = 0;
- changed[i] = 1;
- /* Since one line-that-matches is now before this run
- instead of after, we must advance in the other file
- to keep in synch. */
- ++j;
- }
- else
- break;
- }
-
- preceding = i;
- other_preceding = j;
- }
- }
-}
-
-/* Cons an additional entry onto the front of an edit script OLD.
- LINE0 and LINE1 are the first affected lines in the two files (origin 0).
- DELETED is the number of lines deleted here from file 0.
- INSERTED is the number of lines inserted here in file 1.
-
- If DELETED is 0 then LINE0 is the number of the line before
- which the insertion was done; vice versa for INSERTED and LINE1. */
-
-static struct change *
-add_change (line0, line1, deleted, inserted, old)
- int line0, line1, deleted, inserted;
- struct change *old;
-{
- struct change *new = (struct change *) xmalloc (sizeof (struct change));
-
- new->line0 = line0;
- new->line1 = line1;
- new->inserted = inserted;
- new->deleted = deleted;
- new->link = old;
- return new;
-}
-
-/* Scan the tables of which lines are inserted and deleted,
- producing an edit script in reverse order. */
-
-static struct change *
-build_reverse_script (filevec)
- struct file_data filevec[];
-{
- struct change *script = 0;
- char *changed0 = filevec[0].changed_flag;
- char *changed1 = filevec[1].changed_flag;
- int len0 = filevec[0].buffered_lines;
- int len1 = filevec[1].buffered_lines;
-
- /* Note that changedN[len0] does exist, and contains 0. */
-
- int i0 = 0, i1 = 0;
-
- while (i0 < len0 || i1 < len1)
- {
- if (changed0[i0] || changed1[i1])
- {
- int line0 = i0, line1 = i1;
-
- /* Find # lines changed here in each file. */
- while (changed0[i0]) ++i0;
- while (changed1[i1]) ++i1;
-
- /* Record this change. */
- script = add_change (line0, line1, i0 - line0, i1 - line1, script);
- }
-
- /* We have reached lines in the two files that match each other. */
- i0++, i1++;
- }
-
- return script;
-}
-
-/* Scan the tables of which lines are inserted and deleted,
- producing an edit script in forward order. */
-
-static struct change *
-build_script (filevec)
- struct file_data filevec[];
-{
- struct change *script = 0;
- char *changed0 = filevec[0].changed_flag;
- char *changed1 = filevec[1].changed_flag;
- int i0 = filevec[0].buffered_lines, i1 = filevec[1].buffered_lines;
-
- /* Note that changedN[-1] does exist, and contains 0. */
-
- while (i0 >= 0 || i1 >= 0)
- {
- if (changed0[i0 - 1] || changed1[i1 - 1])
- {
- int line0 = i0, line1 = i1;
-
- /* Find # lines changed here in each file. */
- while (changed0[i0 - 1]) --i0;
- while (changed1[i1 - 1]) --i1;
-
- /* Record this change. */
- script = add_change (i0, i1, line0 - i0, line1 - i1, script);
- }
-
- /* We have reached lines in the two files that match each other. */
- i0--, i1--;
- }
-
- return script;
-}
-
-/* Report the differences of two files. DEPTH is the current directory
- depth. */
-int
-diff_2_files (filevec, depth)
- struct file_data filevec[];
- int depth;
-{
- int diags;
- int i;
- struct change *e, *p;
- struct change *script;
- int changes;
-
-
- /* If we have detected that either file is binary,
- compare the two files as binary. This can happen
- only when the first chunk is read.
- Also, -q means treat all files as binary. */
-
- if (read_files (filevec))
- {
- /* Files with different lengths must be different. */
- if (filevec[0].stat.st_size != filevec[1].stat.st_size
- && (filevec[0].desc < 0 || S_ISREG (filevec[0].stat.st_mode))
- && (filevec[1].desc < 0 || S_ISREG (filevec[1].stat.st_mode)))
- changes = 1;
-
- /* Standard input equals itself. */
- else if (filevec[0].desc == filevec[1].desc)
- changes = 0;
-
- else
- /* Scan both files, a buffer at a time, looking for a difference. */
- {
- /* Allocate same-sized buffers for both files. */
- int buffer_size = max (STAT_BLOCKSIZE (filevec[0].stat),
- STAT_BLOCKSIZE (filevec[1].stat));
- for (i = 0; i < 2; i++)
- filevec[i].buffer = xrealloc (filevec[i].buffer, buffer_size);
-
- for (;; filevec[0].buffered_chars = filevec[1].buffered_chars = 0)
- {
- /* Read a buffer's worth from both files. */
- for (i = 0; i < 2; i++)
- if (0 <= filevec[i].desc)
- while (filevec[i].buffered_chars != buffer_size)
- {
- int r = read (filevec[i].desc,
- filevec[i].buffer
- + filevec[i].buffered_chars,
- buffer_size - filevec[i].buffered_chars);
- if (r == 0)
- break;
- if (r < 0)
- pfatal_with_name (filevec[i].name);
- filevec[i].buffered_chars += r;
- }
-
- /* If the buffers differ, the files differ. */
- if (filevec[0].buffered_chars != filevec[1].buffered_chars
- || bcmp (filevec[0].buffer,
- filevec[1].buffer,
- filevec[0].buffered_chars) != 0)
- {
- changes = 1;
- break;
- }
-
- /* If we reach end of file, the files are the same. */
- if (filevec[0].buffered_chars != buffer_size)
- {
- changes = 0;
- break;
- }
- }
- }
-
- if (changes)
- message (no_details_flag ? "Files %s and %s differ\n"
- : "Binary files %s and %s differ\n",
- filevec[0].name, filevec[1].name);
- }
- else
- {
- /* Allocate vectors for the results of comparison:
- a flag for each line of each file, saying whether that line
- is an insertion or deletion.
- Allocate an extra element, always zero, at each end of each vector. */
-
- filevec[0].changed_flag = (char *) xmalloc (filevec[0].buffered_lines
- + filevec[1].buffered_lines
- + 4);
- bzero (filevec[0].changed_flag, filevec[0].buffered_lines
- + filevec[1].buffered_lines + 4);
- filevec[0].changed_flag++;
- filevec[1].changed_flag = filevec[0].changed_flag
- + filevec[0].buffered_lines + 2;
-
- /* Some lines are obviously insertions or deletions
- because they don't match anything. Detect them now, and
- avoid even thinking about them in the main comparison algorithm. */
-
- discard_confusing_lines (filevec);
-
- /* Now do the main comparison algorithm, considering just the
- undiscarded lines. */
-
- xvec = filevec[0].undiscarded;
- yvec = filevec[1].undiscarded;
- diags = filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3;
- fdiag = (int *) xmalloc (diags * (2 * sizeof (int)));
- bdiag = fdiag + diags;
- fdiag += filevec[1].nondiscarded_lines + 1;
- bdiag += filevec[1].nondiscarded_lines + 1;
-
- files[0] = filevec[0];
- files[1] = filevec[1];
-
- compareseq (0, filevec[0].nondiscarded_lines,
- 0, filevec[1].nondiscarded_lines);
-
- free (fdiag - (filevec[1].nondiscarded_lines + 1));
-
- /* Modify the results slightly to make them prettier
- in cases where that can validly be done. */
-
- shift_boundaries (filevec);
-
- /* Get the results of comparison in the form of a chain
- of `struct change's -- an edit script. */
-
- if (output_style == OUTPUT_ED)
- script = build_reverse_script (filevec);
- else
- script = build_script (filevec);
-
- if (script || ! no_diff_means_no_output)
- {
- /* Record info for starting up output,
- to be used if and when we have some output to print. */
- setup_output (files[0].name, files[1].name, depth);
-
- switch (output_style)
- {
- case OUTPUT_CONTEXT:
- print_context_script (script, 0);
- break;
-
- case OUTPUT_UNIFIED:
- print_context_script (script, 1);
- break;
-
- case OUTPUT_ED:
- print_ed_script (script);
- break;
-
- case OUTPUT_FORWARD_ED:
- pr_forward_ed_script (script);
- break;
-
- case OUTPUT_RCS:
- print_rcs_script (script);
- break;
-
- case OUTPUT_NORMAL:
- print_normal_script (script);
- break;
-
- case OUTPUT_IFDEF:
- print_ifdef_script (script);
- break;
-
- case OUTPUT_SDIFF:
- print_sdiff_script (script);
- }
-
- finish_output ();
- }
-
- /* Set CHANGES if we had any diffs that were printed.
- If some changes are ignored, we must scan the script to decide. */
- if (ignore_blank_lines_flag || ignore_regexp_list)
- {
- struct change *next = script;
- changes = 0;
-
- while (next && changes == 0)
- {
- struct change *this, *end;
- int first0, last0, first1, last1, deletes, inserts;
-
- /* Find a set of changes that belong together. */
- this = next;
- end = find_change (next);
-
- /* Disconnect them from the rest of the changes, making them
- a hunk, and remember the rest for next iteration. */
- next = end->link;
- end->link = NULL;
-
- /* Determine whether this hunk was printed. */
- analyze_hunk (this, &first0, &last0, &first1, &last1,
- &deletes, &inserts);
-
- /* Reconnect the script so it will all be freed properly. */
- end->link = next;
-
- if (deletes || inserts)
- changes = 1;
- }
- }
- else
- changes = (script != 0);
-
- free (filevec[0].undiscarded);
-
- free (filevec[0].changed_flag - 1);
-
- for (i = 1; i >= 0; --i)
- free (filevec[i].equivs);
-
- for (i = 0; i < 2; ++i)
- free (filevec[i].linbuf + filevec[i].linbuf_base);
-
- for (e = script; e; e = p)
- {
- p = e->link;
- free (e);
- }
-
- if (! ROBUST_OUTPUT_STYLE (output_style))
- for (i = 0; i < 2; ++i)
- if (filevec[i].missing_newline)
- {
- error ("No newline at end of file %s", filevec[i].name, "");
- changes = 2;
- }
- }
-
- if (filevec[0].buffer != filevec[1].buffer)
- free (filevec[0].buffer);
- free (filevec[1].buffer);
-
- return changes;
-}
diff --git a/gnu/usr.bin/diff/context.c b/gnu/usr.bin/diff/context.c
deleted file mode 100644
index 9b8fc3e..0000000
--- a/gnu/usr.bin/diff/context.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/* Context-format output routines for GNU DIFF.
- Copyright (C) 1988, 89, 91, 92 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "diff.h"
-
-static void pr_context_hunk ();
-static void pr_unidiff_hunk ();
-static struct change *find_hunk ();
-static void mark_ignorable ();
-static void find_function ();
-
-/* Last place find_function started searching from. */
-static int find_function_last_search;
-
-/* The value find_function returned when it started searching there. */
-static int find_function_last_match;
-
-/* Print a label for a context diff, with a file name and date or a label. */
-
-static void
-print_context_label (mark, inf, label)
- const char *mark;
- struct file_data *inf;
- const char *label;
-{
- if (label)
- fprintf (outfile, "%s %s\n", mark, label);
- else if (inf->stat.st_mtime)
- fprintf (outfile, "%s %s\t%s", mark, inf->name, ctime(&inf->stat.st_mtime));
- else
- /* Don't pretend that standard input is ancient. */
- fprintf (outfile, "%s %s\n", mark, inf->name);
-}
-
-/* Print a header for a context diff, with the file names and dates. */
-
-void
-print_context_header (inf, unidiff_flag)
- struct file_data *inf;
- int unidiff_flag;
-{
- if (unidiff_flag)
- {
- print_context_label ("---", &inf[0], file_label[0]);
- print_context_label ("+++", &inf[1], file_label[1]);
- }
- else
- {
- print_context_label ("***", &inf[0], file_label[0]);
- print_context_label ("---", &inf[1], file_label[1]);
- }
-}
-
-/* Print an edit script in context format. */
-
-void
-print_context_script (script, unidiff_flag)
- struct change *script;
- int unidiff_flag;
-{
- if (ignore_blank_lines_flag || ignore_regexp_list)
- mark_ignorable (script);
- else
- {
- struct change *e;
- for (e = script; e; e = e->link)
- e->ignore = 0;
- }
-
- find_function_last_search = - files[0].prefix_lines;
- find_function_last_match = find_function_last_search - 1;
-
- if (unidiff_flag)
- print_script (script, find_hunk, pr_unidiff_hunk);
- else
- print_script (script, find_hunk, pr_context_hunk);
-}
-
-/* Print a pair of line numbers with a comma, translated for file FILE.
- If the second number is not greater, use the first in place of it.
-
- Args A and B are internal line numbers.
- We print the translated (real) line numbers. */
-
-static void
-print_context_number_range (file, a, b)
- struct file_data *file;
- int a, b;
-{
- int trans_a, trans_b;
- translate_range (file, a, b, &trans_a, &trans_b);
-
- /* Note: we can have B < A in the case of a range of no lines.
- In this case, we should print the line number before the range,
- which is B. */
- if (trans_b > trans_a)
- fprintf (outfile, "%d,%d", trans_a, trans_b);
- else
- fprintf (outfile, "%d", trans_b);
-}
-
-/* Print a portion of an edit script in context format.
- HUNK is the beginning of the portion to be printed.
- The end is marked by a `link' that has been nulled out.
-
- Prints out lines from both files, and precedes each
- line with the appropriate flag-character. */
-
-static void
-pr_context_hunk (hunk)
- struct change *hunk;
-{
- int first0, last0, first1, last1, show_from, show_to, i;
- struct change *next;
- char *prefix;
- const char *function;
- int function_length;
- FILE *out;
-
- /* Determine range of line numbers involved in each file. */
-
- analyze_hunk (hunk, &first0, &last0, &first1, &last1, &show_from, &show_to);
-
- if (!show_from && !show_to)
- return;
-
- /* Include a context's width before and after. */
-
- i = - files[0].prefix_lines;
- first0 = max (first0 - context, i);
- first1 = max (first1 - context, i);
- last0 = min (last0 + context, files[0].valid_lines - 1);
- last1 = min (last1 + context, files[1].valid_lines - 1);
-
- /* If desired, find the preceding function definition line in file 0. */
- function = 0;
- if (function_regexp_list)
- find_function (&files[0], first0, &function, &function_length);
-
- begin_output ();
- out = outfile;
-
- /* If we looked for and found a function this is part of,
- include its name in the header of the diff section. */
- fprintf (out, "***************");
-
- if (function)
- {
- fprintf (out, " ");
- fwrite (function, 1, min (function_length - 1, 40), out);
- }
-
- fprintf (out, "\n*** ");
- print_context_number_range (&files[0], first0, last0);
- fprintf (out, " ****\n");
-
- if (show_from)
- {
- next = hunk;
-
- for (i = first0; i <= last0; i++)
- {
- /* Skip past changes that apply (in file 0)
- only to lines before line I. */
-
- while (next && next->line0 + next->deleted <= i)
- next = next->link;
-
- /* Compute the marking for line I. */
-
- prefix = " ";
- if (next && next->line0 <= i)
- /* The change NEXT covers this line.
- If lines were inserted here in file 1, this is "changed".
- Otherwise it is "deleted". */
- prefix = (next->inserted > 0 ? "!" : "-");
-
- print_1_line (prefix, &files[0].linbuf[i]);
- }
- }
-
- fprintf (out, "--- ");
- print_context_number_range (&files[1], first1, last1);
- fprintf (out, " ----\n");
-
- if (show_to)
- {
- next = hunk;
-
- for (i = first1; i <= last1; i++)
- {
- /* Skip past changes that apply (in file 1)
- only to lines before line I. */
-
- while (next && next->line1 + next->inserted <= i)
- next = next->link;
-
- /* Compute the marking for line I. */
-
- prefix = " ";
- if (next && next->line1 <= i)
- /* The change NEXT covers this line.
- If lines were deleted here in file 0, this is "changed".
- Otherwise it is "inserted". */
- prefix = (next->deleted > 0 ? "!" : "+");
-
- print_1_line (prefix, &files[1].linbuf[i]);
- }
- }
-}
-
-/* Print a pair of line numbers with a comma, translated for file FILE.
- If the second number is smaller, use the first in place of it.
- If the numbers are equal, print just one number.
-
- Args A and B are internal line numbers.
- We print the translated (real) line numbers. */
-
-static void
-print_unidiff_number_range (file, a, b)
- struct file_data *file;
- int a, b;
-{
- int trans_a, trans_b;
- translate_range (file, a, b, &trans_a, &trans_b);
-
- /* Note: we can have B < A in the case of a range of no lines.
- In this case, we should print the line number before the range,
- which is B. */
- if (trans_b <= trans_a)
- fprintf (outfile, trans_b == trans_a ? "%d" : "%d,0", trans_b);
- else
- fprintf (outfile, "%d,%d", trans_a, trans_b - trans_a + 1);
-}
-
-/* Print a portion of an edit script in unidiff format.
- HUNK is the beginning of the portion to be printed.
- The end is marked by a `link' that has been nulled out.
-
- Prints out lines from both files, and precedes each
- line with the appropriate flag-character. */
-
-static void
-pr_unidiff_hunk (hunk)
- struct change *hunk;
-{
- int first0, last0, first1, last1, show_from, show_to, i, j, k;
- struct change *next;
- char *function;
- int function_length;
- FILE *out;
-
- /* Determine range of line numbers involved in each file. */
-
- analyze_hunk (hunk, &first0, &last0, &first1, &last1, &show_from, &show_to);
-
- if (!show_from && !show_to)
- return;
-
- /* Include a context's width before and after. */
-
- i = - files[0].prefix_lines;
- first0 = max (first0 - context, i);
- first1 = max (first1 - context, i);
- last0 = min (last0 + context, files[0].valid_lines - 1);
- last1 = min (last1 + context, files[1].valid_lines - 1);
-
- /* If desired, find the preceding function definition line in file 0. */
- function = 0;
- if (function_regexp_list)
- find_function (&files[0], first0, &function, &function_length);
-
- begin_output ();
- out = outfile;
-
- fprintf (out, "@@ -");
- print_unidiff_number_range (&files[0], first0, last0);
- fprintf (out, " +");
- print_unidiff_number_range (&files[1], first1, last1);
- fprintf (out, " @@");
-
- /* If we looked for and found a function this is part of,
- include its name in the header of the diff section. */
-
- if (function)
- {
- putc (' ', out);
- fwrite (function, 1, min (function_length - 1, 40), out);
- }
- putc ('\n', out);
-
- next = hunk;
- i = first0;
- j = first1;
-
- while (i <= last0 || j <= last1)
- {
-
- /* If the line isn't a difference, output the context from file 0. */
-
- if (!next || i < next->line0)
- {
- putc (tab_align_flag ? '\t' : ' ', out);
- print_1_line ((char *)0, &files[0].linbuf[i++]);
- j++;
- }
- else
- {
- /* For each difference, first output the deleted part. */
-
- k = next->deleted;
- while (k--)
- {
- putc ('-', out);
- if (tab_align_flag)
- putc ('\t', out);
- print_1_line ((char *)0, &files[0].linbuf[i++]);
- }
-
- /* Then output the inserted part. */
-
- k = next->inserted;
- while (k--)
- {
- putc ('+', out);
- if (tab_align_flag)
- putc ('\t', out);
- print_1_line ((char *)0, &files[1].linbuf[j++]);
- }
-
- /* We're done with this hunk, so on to the next! */
-
- next = next->link;
- }
- }
-}
-
-/* Scan a (forward-ordered) edit script for the first place that more than
- 2*CONTEXT unchanged lines appear, and return a pointer
- to the `struct change' for the last change before those lines. */
-
-static struct change *
-find_hunk (start)
- struct change *start;
-{
- struct change *prev;
- int top0, top1;
- int thresh;
-
- do
- {
- /* Compute number of first line in each file beyond this changed. */
- top0 = start->line0 + start->deleted;
- top1 = start->line1 + start->inserted;
- prev = start;
- start = start->link;
- /* Threshold distance is 2*CONTEXT between two non-ignorable changes,
- but only CONTEXT if one is ignorable. */
- thresh = ((prev->ignore || (start && start->ignore))
- ? context
- : 2 * context + 1);
- /* It is not supposed to matter which file we check in the end-test.
- If it would matter, crash. */
- if (start && start->line0 - top0 != start->line1 - top1)
- abort ();
- } while (start
- /* Keep going if less than THRESH lines
- elapse before the affected line. */
- && start->line0 < top0 + thresh);
-
- return prev;
-}
-
-/* Set the `ignore' flag properly in each change in SCRIPT.
- It should be 1 if all the lines inserted or deleted in that change
- are ignorable lines. */
-
-static void
-mark_ignorable (script)
- struct change *script;
-{
- while (script)
- {
- struct change *next = script->link;
- int first0, last0, first1, last1, deletes, inserts;
-
- /* Turn this change into a hunk: detach it from the others. */
- script->link = 0;
-
- /* Determine whether this change is ignorable. */
- analyze_hunk (script, &first0, &last0, &first1, &last1, &deletes, &inserts);
- /* Reconnect the chain as before. */
- script->link = next;
-
- /* If the change is ignorable, mark it. */
- script->ignore = (!deletes && !inserts);
-
- /* Advance to the following change. */
- script = next;
- }
-}
-
-/* Find the last function-header line in FILE prior to line number LINENUM.
- This is a line containing a match for the regexp in `function_regexp'.
- Store the address of the line text into LINEP and the length of the
- line into LENP.
- Do not store anything if no function-header is found. */
-
-static void
-find_function (file, linenum, linep, lenp)
- struct file_data *file;
- int linenum;
- const char **linep;
- int *lenp;
-{
- int i = linenum;
- int last = find_function_last_search;
- find_function_last_search = i;
-
- while (--i >= last)
- {
- /* See if this line is what we want. */
- struct regexp_list *r;
- const char *line = file->linbuf[i];
- int len = file->linbuf[i + 1] - line;
-
- for (r = function_regexp_list; r; r = r->next)
- if (0 <= re_search (&r->buf, line, len, 0, len, 0))
- {
- *linep = line;
- *lenp = len;
- find_function_last_match = i;
- return;
- }
- }
- /* If we search back to where we started searching the previous time,
- find the line we found last time. */
- if (find_function_last_match >= - file->prefix_lines)
- {
- i = find_function_last_match;
- *linep = file->linbuf[i];
- *lenp = file->linbuf[i + 1] - *linep;
- return;
- }
- return;
-}
diff --git a/gnu/usr.bin/diff/diff.c b/gnu/usr.bin/diff/diff.c
deleted file mode 100644
index e4eb66f..0000000
--- a/gnu/usr.bin/diff/diff.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/* GNU DIFF main routine.
- Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* GNU DIFF was written by Mike Haertel, David Hayes,
- Richard Stallman, Len Tower, and Paul Eggert. */
-
-#define GDIFF_MAIN
-#include "diff.h"
-#include "getopt.h"
-#include "fnmatch.h"
-
-#ifndef DEFAULT_WIDTH
-#define DEFAULT_WIDTH 130
-#endif
-
-#ifndef GUTTER_WIDTH_MINIMUM
-#define GUTTER_WIDTH_MINIMUM 3
-#endif
-
-int diff_dirs ();
-int diff_2_files ();
-
-static int compare_files ();
-static int specify_format ();
-static void add_regexp();
-static void specify_style ();
-static void usage ();
-
-/* Nonzero for -r: if comparing two directories,
- compare their common subdirectories recursively. */
-
-static int recursive;
-
-/* For debugging: don't do discard_confusing_lines. */
-
-int no_discards;
-
-/* Return a string containing the command options with which diff was invoked.
- Spaces appear between what were separate ARGV-elements.
- There is a space at the beginning but none at the end.
- If there were no options, the result is an empty string.
-
- Arguments: OPTIONVEC, a vector containing separate ARGV-elements, and COUNT,
- the length of that vector. */
-
-static char *
-option_list (optionvec, count)
- char **optionvec; /* Was `vector', but that collides on Alliant. */
- int count;
-{
- int i;
- int length = 0;
- char *result;
-
- for (i = 0; i < count; i++)
- length += strlen (optionvec[i]) + 1;
-
- result = (char *) xmalloc (length + 1);
- result[0] = 0;
-
- for (i = 0; i < count; i++)
- {
- strcat (result, " ");
- strcat (result, optionvec[i]);
- }
-
- return result;
-}
-
-/* Convert STR to a positive integer, storing the result in *OUT.
- If STR is not a valid integer, return -1 (otherwise 0). */
-static int
-ck_atoi (str, out)
- char *str;
- int *out;
-{
- char *p;
- for (p = str; *p; p++)
- if (*p < '0' || *p > '9')
- return -1;
-
- *out = atoi (optarg);
- return 0;
-}
-
-/* Keep track of excluded file name patterns. */
-
-static const char **exclude;
-static int exclude_alloc, exclude_count;
-
-int
-excluded_filename (f)
- const char *f;
-{
- int i;
- for (i = 0; i < exclude_count; i++)
- if (fnmatch (exclude[i], f, 0) == 0)
- return 1;
- return 0;
-}
-
-static void
-add_exclude (pattern)
- const char *pattern;
-{
- if (exclude_alloc <= exclude_count)
- exclude = (const char **)
- (exclude_alloc == 0
- ? xmalloc ((exclude_alloc = 64) * sizeof (*exclude))
- : xrealloc (exclude, (exclude_alloc *= 2) * sizeof (*exclude)));
-
- exclude[exclude_count++] = pattern;
-}
-
-static int
-add_exclude_file (name)
- const char *name;
-{
- struct file_data f;
- char *p, *q, *lim;
-
- f.name = optarg;
- f.desc = strcmp (optarg, "-") == 0 ? 0 : open (optarg, O_RDONLY, 0);
- if (f.desc < 0 || fstat (f.desc, &f.stat) != 0)
- return -1;
-
- sip (&f, 1);
- slurp (&f);
-
- for (p = f.buffer, lim = p + f.buffered_chars; p < lim; p = q)
- {
- q = memchr (p, '\n', lim - p);
- if (!q)
- q = lim;
- *q++ = 0;
- add_exclude (p);
- }
-
- return close (f.desc);
-}
-
-/* The numbers 129- that appear in the fourth element of some entries
- tell the big switch in `main' how to process those options. */
-
-static struct option longopts[] =
-{
- {"ignore-blank-lines", 0, 0, 'B'},
- {"context", 2, 0, 'C'},
- {"ifdef", 1, 0, 'D'},
- {"show-function-line", 1, 0, 'F'},
- {"speed-large-files", 0, 0, 'H'},
- {"ignore-matching-lines", 1, 0, 'I'},
- {"label", 1, 0, 'L'},
- {"file-label", 1, 0, 'L'}, /* An alias, no longer recommended */
- {"new-file", 0, 0, 'N'},
- {"entire-new-file", 0, 0, 'N'}, /* An alias, no longer recommended */
- {"unidirectional-new-file", 0, 0, 'P'},
- {"starting-file", 1, 0, 'S'},
- {"initial-tab", 0, 0, 'T'},
- {"width", 1, 0, 'W'},
- {"text", 0, 0, 'a'},
- {"ascii", 0, 0, 'a'}, /* An alias, no longer recommended */
- {"ignore-space-change", 0, 0, 'b'},
- {"minimal", 0, 0, 'd'},
- {"ed", 0, 0, 'e'},
- {"forward-ed", 0, 0, 'f'},
- {"ignore-case", 0, 0, 'i'},
- {"paginate", 0, 0, 'l'},
- {"print", 0, 0, 'l'}, /* An alias, no longer recommended */
- {"rcs", 0, 0, 'n'},
- {"show-c-function", 0, 0, 'p'},
- {"binary", 0, 0, 'q'}, /* An alias, no longer recommended */
- {"brief", 0, 0, 'q'},
- {"recursive", 0, 0, 'r'},
- {"report-identical-files", 0, 0, 's'},
- {"expand-tabs", 0, 0, 't'},
- {"version", 0, 0, 'v'},
- {"ignore-all-space", 0, 0, 'w'},
- {"exclude", 1, 0, 'x'},
- {"exclude-from", 1, 0, 'X'},
- {"side-by-side", 0, 0, 'y'},
- {"unified", 2, 0, 'U'},
- {"left-column", 0, 0, 129},
- {"suppress-common-lines", 0, 0, 130},
- {"sdiff-merge-assist", 0, 0, 131},
- {"old-line-format", 1, 0, 132},
- {"new-line-format", 1, 0, 133},
- {"unchanged-line-format", 1, 0, 134},
- {"old-group-format", 1, 0, 135},
- {"new-group-format", 1, 0, 136},
- {"unchanged-group-format", 1, 0, 137},
- {"changed-group-format", 1, 0, 138},
- {"horizon-lines", 1, 0, 139},
- {0, 0, 0, 0}
-};
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- int val;
- int c;
- int prev = -1;
- extern char *version_string;
- int width = DEFAULT_WIDTH;
-
- program = argv[0];
-
- /* Do our initializations. */
- output_style = OUTPUT_NORMAL;
- always_text_flag = FALSE;
- ignore_space_change_flag = FALSE;
- ignore_all_space_flag = FALSE;
- length_varies = FALSE;
- ignore_case_flag = FALSE;
- ignore_blank_lines_flag = FALSE;
- ignore_regexp_list = NULL;
- function_regexp_list = NULL;
- print_file_same_flag = FALSE;
- entire_new_file_flag = FALSE;
- unidirectional_new_file_flag = FALSE;
- no_details_flag = FALSE;
- context = -1;
- line_end_char = '\n';
- tab_align_flag = FALSE;
- tab_expand_flag = FALSE;
- recursive = FALSE;
- paginate_flag = FALSE;
- heuristic = FALSE;
- dir_start_file = NULL;
- msg_chain = NULL;
- msg_chain_end = NULL;
- no_discards = 0;
-
- /* Decode the options. */
-
- while ((c = getopt_long (argc, argv,
- "0123456789abBcC:dD:efF:hHiI:lL:nNpPqrsS:tTuU:vwW:x:X:y",
- longopts, (int *)0)) != EOF)
- {
- switch (c)
- {
- /* All digits combine in decimal to specify the context-size. */
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '0':
- if (context == -1)
- context = 0;
- /* If a context length has already been specified,
- more digits allowed only if they follow right after the others.
- Reject two separate runs of digits, or digits after -C. */
- else if (prev < '0' || prev > '9')
- fatal ("context length specified twice");
-
- context = context * 10 + c - '0';
- break;
-
- case 'a':
- /* Treat all files as text files; never treat as binary. */
- always_text_flag = 1;
- break;
-
- case 'b':
- /* Ignore changes in amount of whitespace. */
- ignore_space_change_flag = 1;
- length_varies = 1;
- break;
-
- case 'B':
- /* Ignore changes affecting only blank lines. */
- ignore_blank_lines_flag = 1;
- break;
-
- case 'C': /* +context[=lines] */
- case 'U': /* +unified[=lines] */
- if (optarg)
- {
- if (context >= 0)
- fatal ("context length specified twice");
-
- if (ck_atoi (optarg, &context))
- fatal ("invalid context length argument");
- }
-
- /* Falls through. */
- case 'c':
- /* Make context-style output. */
- specify_style (c == 'U' ? OUTPUT_UNIFIED : OUTPUT_CONTEXT);
- break;
-
- case 'd':
- /* Don't discard lines. This makes things slower (sometimes much
- slower) but will find a guaranteed minimal set of changes. */
- no_discards = 1;
- break;
-
- case 'D':
- /* Make merged #ifdef output. */
- specify_style (OUTPUT_IFDEF);
- {
- int i, err = 0;
- static const char C_ifdef_group_formats[] =
- "#ifndef %s\n%%<#endif /* not %s */\n%c#ifdef %s\n%%>#endif /* %s */\n%c%%=%c#ifndef %s\n%%<#else /* %s */\n%%>#endif /* %s */\n";
- char *b = xmalloc (sizeof (C_ifdef_group_formats)
- + 7 * strlen(optarg) - 14 /* 7*"%s" */
- - 8 /* 5*"%%" + 3*"%c" */);
- sprintf (b, C_ifdef_group_formats,
- optarg, optarg, 0,
- optarg, optarg, 0, 0,
- optarg, optarg, optarg);
- for (i = 0; i < 4; i++)
- {
- err |= specify_format (&group_format[i], b);
- b += strlen (b) + 1;
- }
- if (err)
- error ("conflicting #ifdef formats", 0, 0);
- }
- break;
-
- case 'e':
- /* Make output that is a valid `ed' script. */
- specify_style (OUTPUT_ED);
- break;
-
- case 'f':
- /* Make output that looks vaguely like an `ed' script
- but has changes in the order they appear in the file. */
- specify_style (OUTPUT_FORWARD_ED);
- break;
-
- case 'F':
- /* Show, for each set of changes, the previous line that
- matches the specified regexp. Currently affects only
- context-style output. */
- add_regexp (&function_regexp_list, optarg);
- break;
-
- case 'h':
- /* Split the files into chunks of around 1500 lines
- for faster processing. Usually does not change the result.
-
- This currently has no effect. */
- break;
-
- case 'H':
- /* Turn on heuristics that speed processing of large files
- with a small density of changes. */
- heuristic = 1;
- break;
-
- case 'i':
- /* Ignore changes in case. */
- ignore_case_flag = 1;
- break;
-
- case 'I':
- /* Ignore changes affecting only lines that match the
- specified regexp. */
- add_regexp (&ignore_regexp_list, optarg);
- break;
-
- case 'l':
- /* Pass the output through `pr' to paginate it. */
- paginate_flag = 1;
- break;
-
- case 'L':
- /* Specify file labels for `-c' output headers. */
- if (!file_label[0])
- file_label[0] = optarg;
- else if (!file_label[1])
- file_label[1] = optarg;
- else
- fatal ("too many file label options");
- break;
-
- case 'n':
- /* Output RCS-style diffs, like `-f' except that each command
- specifies the number of lines affected. */
- specify_style (OUTPUT_RCS);
- break;
-
- case 'N':
- /* When comparing directories, if a file appears only in one
- directory, treat it as present but empty in the other. */
- entire_new_file_flag = 1;
- break;
-
- case 'p':
- /* Make context-style output and show name of last C function. */
- specify_style (OUTPUT_CONTEXT);
- add_regexp (&function_regexp_list, "^[_a-zA-Z$]");
- break;
-
- case '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. */
- unidirectional_new_file_flag = 1;
- break;
-
- case 'q':
- no_details_flag = 1;
- break;
-
- case 'r':
- /* When comparing directories,
- recursively compare any subdirectories found. */
- recursive = 1;
- break;
-
- case 's':
- /* Print a message if the files are the same. */
- print_file_same_flag = 1;
- break;
-
- case 'S':
- /* When comparing directories, start with the specified
- file name. This is used for resuming an aborted comparison. */
- dir_start_file = optarg;
- break;
-
- case 't':
- /* Expand tabs to spaces in the output so that it preserves
- the alignment of the input files. */
- tab_expand_flag = 1;
- break;
-
- case 'T':
- /* Use a tab in the output, rather than a space, before the
- text of an input line, so as to keep the proper alignment
- in the input line without changing the characters in it. */
- tab_align_flag = 1;
- break;
-
- case 'u':
- /* Output the context diff in unidiff format. */
- specify_style (OUTPUT_UNIFIED);
- break;
-
- case 'v':
- fprintf (stderr, "GNU diff version %s\n", version_string);
- break;
-
- case 'w':
- /* Ignore horizontal whitespace when comparing lines. */
- ignore_all_space_flag = 1;
- length_varies = 1;
- break;
-
- case 'x':
- add_exclude (optarg);
- break;
-
- case 'X':
- if (add_exclude_file (optarg) != 0)
- pfatal_with_name (optarg);
- break;
-
- case 'y':
- /* Use side-by-side (sdiff-style) columnar output. */
- specify_style (OUTPUT_SDIFF);
- break;
-
- case 'W':
- /* Set the line width for OUTPUT_SDIFF. */
- if (ck_atoi (optarg, &width) || width <= 0)
- fatal ("column width must be a positive integer");
- break;
-
- case 129:
- sdiff_left_only = 1;
- break;
-
- case 130:
- sdiff_skip_common_lines = 1;
- break;
-
- case 131:
- /* sdiff-style columns output. */
- specify_style (OUTPUT_SDIFF);
- sdiff_help_sdiff = 1;
- break;
-
- case 132:
- case 133:
- case 134:
- specify_style (OUTPUT_IFDEF);
- {
- const char **form = &line_format[c - 132];
- if (*form && strcmp (*form, optarg) != 0)
- error ("conflicting line format", 0, 0);
- *form = optarg;
- }
- break;
-
- case 135:
- case 136:
- case 137:
- case 138:
- specify_style (OUTPUT_IFDEF);
- {
- const char **form = &group_format[c - 135];
- if (*form && strcmp (*form, optarg) != 0)
- error ("conflicting group format", 0, 0);
- *form = optarg;
- }
- break;
-
- case 139:
- if (ck_atoi (optarg, &horizon_lines) || horizon_lines < 0)
- fatal ("horizon must be a nonnegative integer");
- break;
-
- default:
- usage ();
- }
- prev = c;
- }
-
- if (optind != argc - 2)
- usage ();
-
-
- {
- /*
- * We maximize first the half line width, and then the gutter width,
- * according to the following constraints:
- * 1. Two half lines plus a gutter must fit in a line.
- * 2. If the half line width is nonzero:
- * a. The gutter width is at least GUTTER_WIDTH_MINIMUM.
- * b. If tabs are not expanded to spaces,
- * a half line plus a gutter is an integral number of tabs,
- * so that tabs in the right column line up.
- */
- int t = tab_expand_flag ? 1 : TAB_WIDTH;
- int off = (width + t + GUTTER_WIDTH_MINIMUM) / (2*t) * t;
- sdiff_half_width = max (0, min (off - GUTTER_WIDTH_MINIMUM, width - off)),
- sdiff_column2_offset = sdiff_half_width ? off : width;
- }
-
- if (output_style != OUTPUT_CONTEXT && output_style != OUTPUT_UNIFIED)
- context = 0;
- else if (context == -1)
- /* Default amount of context for -c. */
- context = 3;
-
- if (output_style == OUTPUT_IFDEF)
- {
- int i;
- for (i = 0; i < sizeof (line_format) / sizeof (*line_format); i++)
- if (!line_format[i])
- line_format[i] = "%l\n";
- if (!group_format[OLD])
- group_format[OLD]
- = group_format[UNCHANGED] ? group_format[UNCHANGED] : "%<";
- if (!group_format[NEW])
- group_format[NEW]
- = group_format[UNCHANGED] ? group_format[UNCHANGED] : "%>";
- if (!group_format[UNCHANGED])
- group_format[UNCHANGED] = "%=";
- if (!group_format[CHANGED])
- group_format[CHANGED] = concat (group_format[OLD],
- group_format[NEW], "");
- }
-
- no_diff_means_no_output =
- (output_style == OUTPUT_IFDEF ?
- (!*group_format[UNCHANGED]
- || (strcmp (group_format[UNCHANGED], "%=") == 0
- && !*line_format[UNCHANGED]))
- : output_style == OUTPUT_SDIFF ? sdiff_skip_common_lines : 1);
-
- switch_string = option_list (argv + 1, optind - 1);
-
- val = compare_files (NULL, argv[optind], NULL, argv[optind + 1], 0);
-
- /* Print any messages that were saved up for last. */
- print_message_queue ();
-
- if (ferror (stdout) || fclose (stdout) != 0)
- fatal ("write error");
- exit (val);
- return val;
-}
-
-/* Add the compiled form of regexp PATTERN to REGLIST. */
-
-static void
-add_regexp (reglist, pattern)
- struct regexp_list **reglist;
- char *pattern;
-{
- struct regexp_list *r;
- const char *m;
-
- r = (struct regexp_list *) xmalloc (sizeof (*r));
- bzero (r, sizeof (*r));
- r->buf.fastmap = (char *) xmalloc (256);
- m = re_compile_pattern (pattern, strlen (pattern), &r->buf);
- if (m != 0)
- error ("%s: %s", pattern, m);
-
- /* Add to the start of the list, since it's easier than the end. */
- r->next = *reglist;
- *reglist = r;
-}
-
-static void
-usage ()
-{
- fprintf (stderr, "Usage: %s [options] from-file to-file\n", program);
- fprintf (stderr, "Options:\n\
- [-abBcdefhHilnNpPqrstTuvwy] [-C lines] [-D name] [-F regexp]\n\
- [-I regexp] [-L from-label [-L to-label]] [-S starting-file] [-U lines]\n\
- [-W columns] [-x pattern] [-X pattern-file] [--exclude=pattern]\n\
- [--exclude-from=pattern-file] [--ignore-blank-lines] [--context[=lines]]\n\
- [--ifdef=name] [--show-function-line=regexp] [--speed-large-files]\n\
- [--label=from-label [--label=to-label]] [--new-file]\n");
- fprintf (stderr, "\
- [--ignore-matching-lines=regexp] [--unidirectional-new-file]\n\
- [--starting-file=starting-file] [--initial-tab] [--width=columns]\n\
- [--text] [--ignore-space-change] [--minimal] [--ed] [--forward-ed]\n\
- [--ignore-case] [--paginate] [--rcs] [--show-c-function] [--brief]\n\
- [--recursive] [--report-identical-files] [--expand-tabs] [--version]\n");
- fprintf (stderr, "\
- [--ignore-all-space] [--side-by-side] [--unified[=lines]]\n\
- [--left-column] [--suppress-common-lines] [--sdiff-merge-assist]\n\
- [--old-line-format=format] [--new-line-format=format]\n\
- [--unchanged-line-format=format]\n\
- [--old-group-format=format] [--new-group-format=format]\n\
- [--unchanged-group-format=format] [--changed-group-format=format]\n\
- [--horizon-lines=lines]\n");
- exit (2);
-}
-
-static int
-specify_format (var, value)
- const char **var;
- const char *value;
-{
- int err = *var ? strcmp (*var, value) : 0;
- *var = value;
- return err;
-}
-
-static void
-specify_style (style)
- enum output_style style;
-{
- if (output_style != OUTPUT_NORMAL
- && output_style != style)
- error ("conflicting specifications of output style", 0, 0);
- output_style = style;
-}
-
-/* Compare two files (or dirs) with specified names
- DIR0/NAME0 and DIR1/NAME1, at level DEPTH in directory recursion.
- (if DIR0 is 0, then the name is just NAME0, etc.)
- This is self-contained; it opens the files and closes them.
-
- Value is 0 if files are the same, 1 if different,
- 2 if there is a problem opening them. */
-
-static int
-compare_files (dir0, name0, dir1, name1, depth)
- char *dir0, *dir1;
- char *name0, *name1;
- int depth;
-{
- struct file_data inf[2];
- register int i;
- int val;
- int same_files;
- int errorcount = 0;
-
- /* If this is directory comparison, perhaps we have a file
- that exists only in one of the directories.
- If so, just print a message to that effect. */
-
- if (! ((name0 != 0 && name1 != 0)
- || (unidirectional_new_file_flag && name1 != 0)
- || entire_new_file_flag))
- {
- char *name = name0 == 0 ? name1 : name0;
- char *dir = name0 == 0 ? dir1 : dir0;
- message ("Only in %s: %s\n", dir, name);
- /* Return 1 so that diff_dirs will return 1 ("some files differ"). */
- return 1;
- }
-
- /* Mark any nonexistent file with -1 in the desc field. */
- /* Mark unopened files (i.e. directories) with -2. */
-
- inf[0].desc = name0 == 0 ? -1 : -2;
- inf[1].desc = name1 == 0 ? -1 : -2;
-
- /* Now record the full name of each file, including nonexistent ones. */
-
- if (name0 == 0)
- name0 = name1;
- if (name1 == 0)
- name1 = name0;
-
- inf[0].name = dir0 == 0 ? name0 : concat (dir0, "/", name0);
- inf[1].name = dir1 == 0 ? name1 : concat (dir1, "/", name1);
-
- /* Stat the files. Record whether they are directories. */
-
- for (i = 0; i <= 1; i++)
- {
- bzero (&inf[i].stat, sizeof (struct stat));
- inf[i].dir_p = 0;
-
- if (inf[i].desc != -1)
- {
- int stat_result;
-
- if (strcmp (inf[i].name, "-") == 0)
- {
- inf[i].desc = 0;
- inf[i].name = "Standard Input";
- stat_result = fstat (0, &inf[i].stat);
- }
- else
- stat_result = stat (inf[i].name, &inf[i].stat);
-
- if (stat_result != 0)
- {
- perror_with_name (inf[i].name);
- errorcount = 1;
- }
- else
- inf[i].dir_p = S_ISDIR (inf[i].stat.st_mode) && inf[i].desc != 0;
- }
- }
-
- if (name0 == 0)
- inf[0].dir_p = inf[1].dir_p;
- if (name1 == 0)
- inf[1].dir_p = inf[0].dir_p;
-
- if (errorcount == 0 && depth == 0 && inf[0].dir_p != inf[1].dir_p)
- {
- /* If one is a directory, and it was specified in the command line,
- use the file in that dir with the other file's basename. */
-
- int fnm_arg = inf[0].dir_p;
- int dir_arg = 1 - fnm_arg;
- char *p = rindex (inf[fnm_arg].name, '/');
- char *filename = inf[dir_arg].name
- = concat (inf[dir_arg].name, "/", (p ? p+1 : inf[fnm_arg].name));
-
- if (inf[fnm_arg].desc == 0)
- fatal ("can't compare - to a directory");
-
- if (stat (filename, &inf[dir_arg].stat) != 0)
- {
- perror_with_name (filename);
- errorcount = 1;
- }
- else
- inf[dir_arg].dir_p = S_ISDIR (inf[dir_arg].stat.st_mode);
- }
-
- if (errorcount)
- {
-
- /* If either file should exist but does not, return 2. */
-
- val = 2;
-
- }
- else if ((same_files = inf[0].stat.st_ino == inf[1].stat.st_ino
- && inf[0].stat.st_dev == inf[1].stat.st_dev
- && inf[0].desc != -1
- && inf[1].desc != -1)
- && no_diff_means_no_output)
- {
- /* The two named files are actually the same physical file.
- We know they are identical without actually reading them. */
-
- val = 0;
- }
- else if (inf[0].dir_p & inf[1].dir_p)
- {
- if (output_style == OUTPUT_IFDEF)
- fatal ("-D option not supported with directories");
-
- /* If both are directories, compare the files in them. */
-
- if (depth > 0 && !recursive)
- {
- /* But don't compare dir contents one level down
- unless -r was specified. */
- message ("Common subdirectories: %s and %s\n",
- inf[0].name, inf[1].name);
- val = 0;
- }
- else
- {
- val = diff_dirs (inf, compare_files, depth);
- }
-
- }
- else if (inf[0].dir_p | inf[1].dir_p)
- {
- /* Perhaps we have a subdirectory that exists only in one directory.
- If so, just print a message to that effect. */
-
- if (inf[0].desc == -1 || inf[1].desc == -1)
- {
- if (recursive
- && (entire_new_file_flag
- || (unidirectional_new_file_flag && inf[0].desc == -1)))
- val = diff_dirs (inf, compare_files, depth);
- else
- {
- char *dir = (inf[0].desc == -1) ? dir1 : dir0;
- message ("Only in %s: %s\n", dir, name0);
- val = 1;
- }
- }
- else
- {
- /* We have a subdirectory in one directory
- and a file in the other. */
-
- message ("%s is a directory but %s is not\n",
- inf[1 - inf[0].dir_p].name, inf[inf[0].dir_p].name);
-
- /* This is a difference. */
- val = 1;
- }
- }
- else if (no_details_flag
- && inf[0].stat.st_size != inf[1].stat.st_size
- && (inf[0].desc == -1 || S_ISREG (inf[0].stat.st_mode))
- && (inf[1].desc == -1 || S_ISREG (inf[1].stat.st_mode)))
- {
- message ("Files %s and %s differ\n", inf[0].name, inf[1].name);
- val = 1;
- }
- else
- {
- /* Both exist and neither is a directory. */
-
- /* Open the files and record their descriptors. */
-
- if (inf[0].desc == -2)
- if ((inf[0].desc = open (inf[0].name, O_RDONLY, 0)) < 0)
- {
- perror_with_name (inf[0].name);
- errorcount = 1;
- }
- if (inf[1].desc == -2)
- if (same_files)
- inf[1].desc = inf[0].desc;
- else if ((inf[1].desc = open (inf[1].name, O_RDONLY, 0)) < 0)
- {
- perror_with_name (inf[1].name);
- errorcount = 1;
- }
-
- /* Compare the files, if no error was found. */
-
- val = errorcount ? 2 : diff_2_files (inf, depth);
-
- /* Close the file descriptors. */
-
- if (inf[0].desc >= 0 && close (inf[0].desc) != 0)
- {
- perror_with_name (inf[0].name);
- val = 2;
- }
- if (inf[1].desc >= 0 && inf[0].desc != inf[1].desc
- && close (inf[1].desc) != 0)
- {
- perror_with_name (inf[1].name);
- val = 2;
- }
- }
-
- /* Now the comparison has been done, if no error prevented it,
- and VAL is the value this function will return. */
-
- if (val == 0 && !inf[0].dir_p)
- {
- if (print_file_same_flag)
- message ("Files %s and %s are identical\n",
- inf[0].name, inf[1].name);
- }
- else
- fflush (stdout);
-
- if (dir0 != 0)
- free (inf[0].name);
- if (dir1 != 0)
- free (inf[1].name);
-
- return val;
-}
diff --git a/gnu/usr.bin/diff/diff.h b/gnu/usr.bin/diff/diff.h
deleted file mode 100644
index 74f025d..0000000
--- a/gnu/usr.bin/diff/diff.h
+++ /dev/null
@@ -1,335 +0,0 @@
-/* Shared definitions for GNU DIFF
- Copyright (C) 1988, 89, 91, 92 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <ctype.h>
-#include <stdio.h>
-#include "system.h"
-#include "regex.h"
-
-#ifndef PR_FILE_NAME
-#define PR_FILE_NAME "/bin/pr"
-#endif
-
-/* Character classes. */
-extern const char textchar[];
-
-/* Is_space is a little broader than ctype.h's isspace,
- because it also includes backspace and no-break space. */
-#define Is_space(c) (textchar[c] & 2)
-
-#define TAB_WIDTH 8
-
-/* Variables for command line options */
-
-#ifndef GDIFF_MAIN
-#define EXTERN extern
-#else
-#define EXTERN
-#endif
-
-enum output_style {
- /* Default output style. */
- OUTPUT_NORMAL,
- /* Output the differences with lines of context before and after (-c). */
- OUTPUT_CONTEXT,
- /* Output the differences in a unified context diff format (-u). */
- OUTPUT_UNIFIED,
- /* Output the differences as commands suitable for `ed' (-e). */
- OUTPUT_ED,
- /* Output the diff as a forward ed script (-f). */
- OUTPUT_FORWARD_ED,
- /* Like -f, but output a count of changed lines in each "command" (-n). */
- OUTPUT_RCS,
- /* Output merged #ifdef'd file (-D). */
- OUTPUT_IFDEF,
- /* Output sdiff style (-y). */
- OUTPUT_SDIFF
-};
-
-/* True for output styles that are robust,
- i.e. can handle a file that ends in a non-newline. */
-#define ROBUST_OUTPUT_STYLE(S) ((S) != OUTPUT_ED && (S) != OUTPUT_FORWARD_ED)
-
-EXTERN enum output_style output_style;
-
-/* Nonzero if output cannot be generated for identical files. */
-EXTERN int no_diff_means_no_output;
-
-/* Number of lines of context to show in each set of diffs.
- This is zero when context is not to be shown. */
-EXTERN int context;
-
-/* Consider all files as text files (-a).
- Don't interpret codes over 0177 as implying a "binary file". */
-EXTERN int always_text_flag;
-
-/* Number of lines to keep in identical prefix and suffix. */
-EXTERN int horizon_lines;
-
-/* Ignore changes in horizontal whitespace (-b). */
-EXTERN int ignore_space_change_flag;
-
-/* Ignore all horizontal whitespace (-w). */
-EXTERN int ignore_all_space_flag;
-
-/* Ignore changes that affect only blank lines (-B). */
-EXTERN int ignore_blank_lines_flag;
-
-/* 1 if lines may match even if their lengths are different.
- This depends on various options. */
-EXTERN int length_varies;
-
-/* Ignore differences in case of letters (-i). */
-EXTERN int ignore_case_flag;
-
-/* File labels for `-c' output headers (-L). */
-EXTERN char *file_label[2];
-
-struct regexp_list
-{
- struct re_pattern_buffer buf;
- struct regexp_list *next;
-};
-
-/* Regexp to identify function-header lines (-F). */
-EXTERN struct regexp_list *function_regexp_list;
-
-/* Ignore changes that affect only lines matching this regexp (-I). */
-EXTERN struct regexp_list *ignore_regexp_list;
-
-/* Say only whether files differ, not how (-q). */
-EXTERN int no_details_flag;
-
-/* Report files compared that match (-s).
- Normally nothing is output when that happens. */
-EXTERN int print_file_same_flag;
-
-/* character that ends a line. Currently this is always `\n'. */
-EXTERN char line_end_char;
-
-/* Output the differences with exactly 8 columns added to each line
- so that any tabs in the text line up properly (-T). */
-EXTERN int tab_align_flag;
-
-/* Expand tabs in the output so the text lines up properly
- despite the characters added to the front of each line (-t). */
-EXTERN int tab_expand_flag;
-
-/* In directory comparison, specify file to start with (-S).
- All file names less than this name are ignored. */
-EXTERN char *dir_start_file;
-
-/* If a file is new (appears in only one dir)
- include its entire contents (-N).
- Then `patch' would create the file with appropriate contents. */
-EXTERN int entire_new_file_flag;
-
-/* If a file is new (appears in only the second dir)
- include its entire contents (-P).
- Then `patch' would create the file with appropriate contents. */
-EXTERN int unidirectional_new_file_flag;
-
-/* Pipe each file's output through pr (-l). */
-EXTERN int paginate_flag;
-
-enum line_class {
- /* Lines taken from just the first file. */
- OLD,
- /* Lines taken from just the second file. */
- NEW,
- /* Lines common to both files. */
- UNCHANGED,
- /* A hunk containing both old and new lines (line groups only). */
- CHANGED
-};
-
-/* Line group formats for old, new, unchanged, and changed groups. */
-EXTERN const char *group_format[CHANGED + 1];
-
-/* Line formats for old, new, and unchanged lines. */
-EXTERN const char *line_format[UNCHANGED + 1];
-
-/* If using OUTPUT_SDIFF print extra information to help the sdiff filter. */
-EXTERN int sdiff_help_sdiff;
-
-/* Tell OUTPUT_SDIFF to show only the left version of common lines. */
-EXTERN int sdiff_left_only;
-
-/* Tell OUTPUT_SDIFF to not show common lines. */
-EXTERN int sdiff_skip_common_lines;
-
-/* The half line width and column 2 offset for OUTPUT_SDIFF. */
-EXTERN unsigned sdiff_half_width;
-EXTERN unsigned sdiff_column2_offset;
-
-/* String containing all the command options diff received,
- with spaces between and at the beginning but none at the end.
- If there were no options given, this string is empty. */
-EXTERN char * switch_string;
-
-/* Nonzero means use heuristics for better speed. */
-EXTERN int heuristic;
-
-/* Name of program the user invoked (for error messages). */
-EXTERN char * program;
-
-/* The result of comparison is an "edit script": a chain of `struct change'.
- Each `struct change' represents one place where some lines are deleted
- and some are inserted.
-
- LINE0 and LINE1 are the first affected lines in the two files (origin 0).
- DELETED is the number of lines deleted here from file 0.
- INSERTED is the number of lines inserted here in file 1.
-
- If DELETED is 0 then LINE0 is the number of the line before
- which the insertion was done; vice versa for INSERTED and LINE1. */
-
-struct change
-{
- struct change *link; /* Previous or next edit command */
- int inserted; /* # lines of file 1 changed here. */
- int deleted; /* # lines of file 0 changed here. */
- int line0; /* Line number of 1st deleted line. */
- int line1; /* Line number of 1st inserted line. */
- char ignore; /* Flag used in context.c */
-};
-
-/* Structures that describe the input files. */
-
-/* Data on one input file being compared. */
-
-struct file_data {
- int desc; /* File descriptor */
- char *name; /* File name */
- struct stat stat; /* File status from fstat() */
- int dir_p; /* nonzero if file is a directory */
-
- /* Buffer in which text of file is read. */
- char * buffer;
- /* Allocated size of buffer. */
- int bufsize;
- /* Number of valid characters now in the buffer. */
- int buffered_chars;
-
- /* Array of pointers to lines in the file. */
- const char **linbuf;
-
- /* linbuf_base <= buffered_lines <= valid_lines <= alloc_lines.
- linebuf[linbuf_base ... buffered_lines - 1] are possibly differing.
- linebuf[linbuf_base ... valid_lines - 1] contain valid data.
- linebuf[linbuf_base ... alloc_lines - 1] are allocated. */
- int linbuf_base, buffered_lines, valid_lines, alloc_lines;
-
- /* Pointer to end of prefix of this file to ignore when hashing. */
- const char *prefix_end;
-
- /* Count of lines in the prefix.
- There are this many lines in the file before linbuf[0]. */
- int prefix_lines;
-
- /* Pointer to start of suffix of this file to ignore when hashing. */
- const char *suffix_begin;
-
- /* Vector, indexed by line number, containing an equivalence code for
- each line. It is this vector that is actually compared with that
- of another file to generate differences. */
- int *equivs;
-
- /* Vector, like the previous one except that
- the elements for discarded lines have been squeezed out. */
- int *undiscarded;
-
- /* Vector mapping virtual line numbers (not counting discarded lines)
- to real ones (counting those lines). Both are origin-0. */
- int *realindexes;
-
- /* Total number of nondiscarded lines. */
- int nondiscarded_lines;
-
- /* Vector, indexed by real origin-0 line number,
- containing 1 for a line that is an insertion or a deletion.
- The results of comparison are stored here. */
- char *changed_flag;
-
- /* 1 if file ends in a line with no final newline. */
- int missing_newline;
-
- /* 1 more than the maximum equivalence value used for this or its
- sibling file. */
- int equiv_max;
-};
-
-/* Describe the two files currently being compared. */
-
-EXTERN struct file_data files[2];
-
-/* Queue up one-line messages to be printed at the end,
- when -l is specified. Each message is recorded with a `struct msg'. */
-
-struct msg
-{
- struct msg *next;
- char *format;
- char *arg1;
- char *arg2;
-};
-
-/* Head of the chain of queues messages. */
-
-EXTERN struct msg *msg_chain;
-
-/* Tail of the chain of queues messages. */
-
-EXTERN struct msg *msg_chain_end;
-
-/* Stdio stream to output diffs to. */
-
-EXTERN FILE *outfile;
-
-/* Declare various functions. */
-
-#if __STDC__
-#define VOID void
-#else
-#define VOID char
-#endif
-VOID *xmalloc ();
-VOID *xrealloc ();
-char *concat ();
-
-int excluded_filename ();
-int sip ();
-
-struct change *find_change ();
-
-void analyze_hunk ();
-void begin_output ();
-void error ();
-void fatal ();
-void message ();
-void output_1_line ();
-void perror_with_name ();
-void pfatal_with_name ();
-void print_1_line ();
-void print_context_header ();
-void print_message_queue ();
-void print_number_range ();
-void print_script ();
-void slurp ();
-void translate_range ();
diff --git a/gnu/usr.bin/diff/diff3.c b/gnu/usr.bin/diff/diff3.c
deleted file mode 100644
index b9952fc..0000000
--- a/gnu/usr.bin/diff/diff3.c
+++ /dev/null
@@ -1,1693 +0,0 @@
-/* Three way file comparison program (diff3) for Project GNU.
- Copyright (C) 1988, 1989, 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 by Randy Smith */
-
-#if __STDC__
-#define VOID void
-#else
-#define VOID char
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include "getopt.h"
-#include "system.h"
-
-/*
- * Internal data structures and macros for the diff3 program; includes
- * data structures for both diff3 diffs and normal diffs.
- */
-
-/* Different files within a three way diff. */
-#define FILE0 0
-#define FILE1 1
-#define FILE2 2
-
-/*
- * A three way diff is built from two two-way diffs; the file which
- * the two two-way diffs share is:
- */
-#define FILEC FILE2
-
-/*
- * Different files within a two way diff.
- * FC is the common file, FO the other file.
- */
-#define FO 0
-#define FC 1
-
-/* The ranges are indexed by */
-#define START 0
-#define END 1
-
-enum diff_type {
- ERROR, /* Should not be used */
- ADD, /* Two way diff add */
- CHANGE, /* Two way diff change */
- DELETE, /* Two way diff delete */
- DIFF_ALL, /* All three are different */
- DIFF_1ST, /* Only the first is different */
- DIFF_2ND, /* Only the second */
- DIFF_3RD /* Only the third */
-};
-
-/* Two way diff */
-struct diff_block {
- int ranges[2][2]; /* Ranges are inclusive */
- char **lines[2]; /* The actual lines (may contain nulls) */
- int *lengths[2]; /* Line lengths (including newlines, if any) */
- struct diff_block *next;
-};
-
-/* Three way diff */
-
-struct diff3_block {
- enum diff_type correspond; /* Type of diff */
- int ranges[3][2]; /* Ranges are inclusive */
- char **lines[3]; /* The actual lines (may contain nulls) */
- int *lengths[3]; /* Line lengths (including newlines, if any) */
- struct diff3_block *next;
-};
-
-/*
- * Access the ranges on a diff block.
- */
-#define D_LOWLINE(diff, filenum) \
- ((diff)->ranges[filenum][START])
-#define D_HIGHLINE(diff, filenum) \
- ((diff)->ranges[filenum][END])
-#define D_NUMLINES(diff, filenum) \
- (D_HIGHLINE (diff, filenum) - D_LOWLINE (diff, filenum) + 1)
-
-/*
- * Access the line numbers in a file in a diff by relative line
- * numbers (i.e. line number within the diff itself). Note that these
- * are lvalues and can be used for assignment.
- */
-#define D_RELNUM(diff, filenum, linenum) \
- ((diff)->lines[filenum][linenum])
-#define D_RELLEN(diff, filenum, linenum) \
- ((diff)->lengths[filenum][linenum])
-
-/*
- * And get at them directly, when that should be necessary.
- */
-#define D_LINEARRAY(diff, filenum) \
- ((diff)->lines[filenum])
-#define D_LENARRAY(diff, filenum) \
- ((diff)->lengths[filenum])
-
-/*
- * Next block.
- */
-#define D_NEXT(diff) ((diff)->next)
-
-/*
- * Access the type of a diff3 block.
- */
-#define D3_TYPE(diff) ((diff)->correspond)
-
-/*
- * Line mappings based on diffs. The first maps off the top of the
- * diff, the second off of the bottom.
- */
-#define D_HIGH_MAPLINE(diff, fromfile, tofile, lineno) \
- ((lineno) \
- - D_HIGHLINE ((diff), (fromfile)) \
- + D_HIGHLINE ((diff), (tofile)))
-
-#define D_LOW_MAPLINE(diff, fromfile, tofile, lineno) \
- ((lineno) \
- - D_LOWLINE ((diff), (fromfile)) \
- + D_LOWLINE ((diff), (tofile)))
-
-/*
- * General memory allocation function.
- */
-#define ALLOCATE(number, type) \
- (type *) xmalloc ((number) * sizeof (type))
-
-/* Options variables for flags set on command line. */
-
-/* If nonzero, treat all files as text files, never as binary. */
-static int always_text;
-
-/* If nonzero, write out an ed script instead of the standard diff3 format. */
-static int edscript;
-
-/* If nonzero, in the case of overlapping diffs (type DIFF_ALL),
- preserve the lines which would normally be deleted from
- file 1 with a special flagging mechanism. */
-static int flagging;
-
-/* Number of lines to keep in identical prefix and suffix. */
-static int horizon_lines = 10;
-
-/* If nonzero, do not output information for overlapping diffs. */
-static int simple_only;
-
-/* If nonzero, do not output information for non-overlapping diffs. */
-static int overlap_only;
-
-/* If nonzero, show information for DIFF_2ND diffs. */
-static int show_2nd;
-
-/* If nonzero, include `:wq' at the end of the script
- to write out the file being edited. */
-static int finalwrite;
-
-/* If nonzero, output a merged file. */
-static int merge;
-
-static char *argv0;
-
-/*
- * Forward function declarations.
- */
-static int myread ();
-static void fatal ();
-static void perror_with_exit ();
-static struct diff_block *process_diff ();
-static struct diff3_block *make_3way_diff ();
-static void output_diff3 ();
-static int output_diff3_edscript ();
-static int output_diff3_merge ();
-static void usage ();
-
-static struct diff3_block *using_to_diff3_block ();
-static int copy_stringlist ();
-static struct diff3_block *create_diff3_block ();
-static int compare_line_list ();
-
-static char *read_diff ();
-static enum diff_type process_diff_control ();
-static char *scan_diff_line ();
-
-static struct diff3_block *reverse_diff3_blocklist ();
-
-VOID *xmalloc ();
-static VOID *xrealloc ();
-
-static char diff_program[] = DIFF_PROGRAM;
-
-static struct option longopts[] =
-{
- {"text", 0, NULL, 'a'},
- {"show-all", 0, NULL, 'A'},
- {"ed", 0, NULL, 'e'},
- {"show-overlap", 0, NULL, 'E'},
- {"label", 1, NULL, 'L'},
- {"merge", 0, NULL, 'm'},
- {"overlap-only", 0, NULL, 'x'},
- {"easy-only", 0, NULL, '3'},
- {"version", 0, NULL, 'v'},
- {0, 0, 0, 0}
-};
-
-/*
- * Main program. Calls diff twice on two pairs of input files,
- * combines the two diffs, and outputs them.
- */
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- extern char *version_string;
- int c, i;
- int mapping[3];
- int rev_mapping[3];
- int incompat;
- int conflicts_found;
- struct diff_block *thread0, *thread1, *last_block;
- struct diff3_block *diff3;
- int tag_count = 0;
- char *tag_strings[3];
- extern char *optarg;
- char *commonname;
- char **file;
- struct stat statb;
-
- incompat = 0;
-
- argv0 = argv[0];
-
- while ((c = getopt_long (argc, argv, "aeimvx3AEXL:", longopts, (int *) 0))
- != EOF)
- {
- switch (c)
- {
- case 'a':
- always_text = 1;
- break;
- case 'A':
- show_2nd = 1;
- flagging = 1;
- incompat++;
- break;
- case 'x':
- overlap_only = 1;
- incompat++;
- break;
- case '3':
- simple_only = 1;
- incompat++;
- break;
- case 'i':
- finalwrite = 1;
- break;
- case 'm':
- merge = 1;
- break;
- case 'X':
- overlap_only = 1;
- /* Falls through */
- case 'E':
- flagging = 1;
- /* Falls through */
- case 'e':
- incompat++;
- break;
- case 'v':
- fprintf (stderr, "GNU diff3 version %s\n", version_string);
- break;
- case 'L':
- /* Handle up to three -L options. */
- if (tag_count < 3)
- {
- tag_strings[tag_count++] = optarg;
- break;
- }
- /* Falls through */
- default:
- usage ();
- /* NOTREACHED */
- }
- }
-
- edscript = incompat & ~merge; /* -AeExX3 without -m implies ed script. */
- show_2nd |= ~incompat & merge; /* -m without -AeExX3 implies -A. */
- flagging |= ~incompat & merge;
-
- if (incompat > 1 /* Ensure at most one of -AeExX3. */
- || finalwrite & merge /* -i -m would rewrite input file. */
- || (tag_count && ! flagging) /* -L requires one of -AEX. */
- || argc - optind != 3)
- usage ();
-
- file = &argv[optind];
-
- for (i = tag_count; i < 3; i++)
- tag_strings[i] = file[i];
-
- /* Always compare file1 to file2, even if file2 is "-".
- This is needed for -mAeExX3. Using the file0 as
- the common file would produce wrong results, because if the
- file0-file1 diffs didn't line up with the file0-file2 diffs
- (which is entirely possible since we don't use diff's -n option),
- diff3 might report phantom changes from file1 to file2. */
-
- if (strcmp (file[2], "-") == 0)
- {
- /* Sigh. We've got standard input as the last arg. We can't
- call diff twice on stdin. Use the middle arg as the common
- file instead. */
- if (strcmp (file[0], "-") == 0 || strcmp (file[1], "-") == 0)
- fatal ("`-' specified for more than one input file");
- mapping[0] = 0;
- mapping[1] = 2;
- mapping[2] = 1;
- }
- else
- {
- /* Normal, what you'd expect */
- mapping[0] = 0;
- mapping[1] = 1;
- mapping[2] = 2;
- }
-
- for (i = 0; i < 3; i++)
- rev_mapping[mapping[i]] = i;
-
- for (i = 0; i < 3; i++)
- if (strcmp (file[i], "-") != 0)
- if (stat (file[i], &statb) < 0)
- perror_with_exit (file[i]);
- else if (S_ISDIR(statb.st_mode))
- {
- fprintf (stderr, "%s: %s: Is a directory\n", argv0, file[i]);
- exit (2);
- }
-
-
- commonname = file[rev_mapping[FILEC]];
- thread1 = process_diff (file[rev_mapping[FILE1]], commonname, &last_block);
- if (thread1)
- for (i = 0; i < 2; i++)
- {
- horizon_lines = max (horizon_lines, D_NUMLINES (thread1, i));
- horizon_lines = max (horizon_lines, D_NUMLINES (last_block, i));
- }
- thread0 = process_diff (file[rev_mapping[FILE0]], commonname, &last_block);
- diff3 = make_3way_diff (thread0, thread1);
- if (edscript)
- conflicts_found
- = output_diff3_edscript (stdout, diff3, mapping, rev_mapping,
- tag_strings[0], tag_strings[1], tag_strings[2]);
- else if (merge)
- {
- if (! freopen (file[rev_mapping[FILE0]], "r", stdin))
- perror_with_exit (file[rev_mapping[FILE0]]);
- conflicts_found
- = output_diff3_merge (stdin, stdout, diff3, mapping, rev_mapping,
- tag_strings[0], tag_strings[1], tag_strings[2]);
- if (ferror (stdin))
- fatal ("read error");
- }
- else
- {
- output_diff3 (stdout, diff3, mapping, rev_mapping);
- conflicts_found = 0;
- }
-
- if (ferror (stdout) || fclose (stdout) != 0)
- fatal ("write error");
- exit (conflicts_found);
- return conflicts_found;
-}
-
-/*
- * Explain, patiently and kindly, how to use this program. Then exit.
- */
-static void
-usage ()
-{
- fprintf (stderr, "\
-Usage: %s [options] my-file older-file your-file\n\
-Options:\n\
- [-exAEX3v] [-i|-m] [-L label1 [-L label2 [-L label3]]] [--text] [--ed]\n\
- [--merge] [--show-all] [--show-overlap] [--overlap-only] [--easy-only]\n\
- [--label=label1 [--label=label2 [--label=label3]]] [--version]\n\
- Only one of [exAEX3] is allowed\n", argv0);
- exit (2);
-}
-
-/*
- * Routines that combine the two diffs together into one. The
- * algorithm used follows:
- *
- * File2 is shared in common between the two diffs.
- * Diff02 is the diff between 0 and 2.
- * Diff12 is the diff between 1 and 2.
- *
- * 1) Find the range for the first block in File2.
- * a) Take the lowest of the two ranges (in File2) in the two
- * current blocks (one from each diff) as being the low
- * water mark. Assign the upper end of this block as
- * being the high water mark and move the current block up
- * one. Mark the block just moved over as to be used.
- * b) Check the next block in the diff that the high water
- * mark is *not* from.
- *
- * *If* the high water mark is above
- * the low end of the range in that block,
- *
- * mark that block as to be used and move the current
- * block up. Set the high water mark to the max of
- * the high end of this block and the current. Repeat b.
- *
- * 2) Find the corresponding ranges in File0 (from the blocks
- * in diff02; line per line outside of diffs) and in File1.
- * Create a diff3_block, reserving space as indicated by the ranges.
- *
- * 3) Copy all of the pointers for file2 in. At least for now,
- * do bcmp's between corresponding strings in the two diffs.
- *
- * 4) Copy all of the pointers for file0 and 1 in. Get what you
- * need from file2 (when there isn't a diff block, it's
- * identical to file2 within the range between diff blocks).
- *
- * 5) If the diff blocks you used came from only one of the two
- * strings of diffs, then that file (i.e. the one other than
- * the common file in that diff) is the odd person out. If you used
- * diff blocks from both sets, check to see if files 0 and 1 match:
- *
- * Same number of lines? If so, do a set of bcmp's (if a
- * bcmp matches; copy the pointer over; it'll be easier later
- * if you have to do any compares). If they match, 0 & 1 are
- * the same. If not, all three different.
- *
- * Then you do it again, until you run out of blocks.
- *
- */
-
-/*
- * This routine makes a three way diff (chain of diff3_block's) from two
- * two way diffs (chains of diff_block's). It is assumed that each of
- * the two diffs passed are onto the same file (i.e. that each of the
- * diffs were made "to" the same file). The three way diff pointer
- * returned will have numbering FILE0--the other file in diff02,
- * FILE1--the other file in diff12, and FILEC--the common file.
- */
-static struct diff3_block *
-make_3way_diff (thread0, thread1)
- struct diff_block *thread0, *thread1;
-{
-/*
- * This routine works on the two diffs passed to it as threads.
- * Thread number 0 is diff02, thread number 1 is diff12. The USING
- * array is set to the base of the list of blocks to be used to
- * construct each block of the three way diff; if no blocks from a
- * particular thread are to be used, that element of the using array
- * is set to 0. The elements LAST_USING array are set to the last
- * elements on each of the using lists.
- *
- * The HIGH_WATER_MARK is set to the highest line number in the common file
- * described in any of the diffs in either of the USING lists. The
- * HIGH_WATER_THREAD names the thread. Similarly the BASE_WATER_MARK
- * and BASE_WATER_THREAD describe the lowest line number in the common file
- * described in any of the diffs in either of the USING lists. The
- * HIGH_WATER_DIFF is the diff from which the HIGH_WATER_MARK was
- * taken.
- *
- * The HIGH_WATER_DIFF should always be equal to LAST_USING
- * [HIGH_WATER_THREAD]. The OTHER_DIFF is the next diff to check for
- * higher water, and should always be equal to
- * CURRENT[HIGH_WATER_THREAD ^ 0x1]. The OTHER_THREAD is the thread
- * in which the OTHER_DIFF is, and hence should always be equal to
- * HIGH_WATER_THREAD ^ 0x1.
- *
- * The variable LAST_DIFF is kept set to the last diff block produced
- * by this routine, for line correspondence purposes between that diff
- * and the one currently being worked on. It is initialized to
- * ZERO_DIFF before any blocks have been created.
- */
-
- struct diff_block
- *using[2],
- *last_using[2],
- *current[2];
-
- int
- high_water_mark;
-
- int
- high_water_thread,
- base_water_thread,
- other_thread;
-
- struct diff_block
- *high_water_diff,
- *other_diff;
-
- struct diff3_block
- *result,
- *tmpblock,
- **result_end,
- *last_diff3;
-
- static struct diff3_block zero_diff3 = {
- ERROR,
- { {0, 0}, {0, 0}, {0, 0} },
- { (char **) 0, (char **) 0, (char **) 0 },
- { (int *) 0, (int *) 0, (int *) 0 },
- (struct diff3_block *) 0
- };
-
- /* Initialization */
- result = 0;
- result_end = &result;
- current[0] = thread0; current[1] = thread1;
- last_diff3 = &zero_diff3;
-
- /* Sniff up the threads until we reach the end */
-
- while (current[0] || current[1])
- {
- using[0] = using[1] = last_using[0] = last_using[1] =
- (struct diff_block *) 0;
-
- /* Setup low and high water threads, diffs, and marks. */
- if (!current[0])
- base_water_thread = 1;
- else if (!current[1])
- base_water_thread = 0;
- else
- base_water_thread =
- (D_LOWLINE (current[0], FC) > D_LOWLINE (current[1], FC));
-
- high_water_thread = base_water_thread;
-
- high_water_diff = current[high_water_thread];
-
-#if 0
- /* low and high waters start off same diff */
- base_water_mark = D_LOWLINE (high_water_diff, FC);
-#endif
-
- high_water_mark = D_HIGHLINE (high_water_diff, FC);
-
- /* Make the diff you just got info from into the using class */
- using[high_water_thread]
- = last_using[high_water_thread]
- = high_water_diff;
- current[high_water_thread] = high_water_diff->next;
- last_using[high_water_thread]->next
- = (struct diff_block *) 0;
-
- /* And mark the other diff */
- other_thread = high_water_thread ^ 0x1;
- other_diff = current[other_thread];
-
- /* Shuffle up the ladder, checking the other diff to see if it
- needs to be incorporated. */
- while (other_diff
- && D_LOWLINE (other_diff, FC) <= high_water_mark + 1)
- {
-
- /* Incorporate this diff into the using list. Note that
- this doesn't take it off the current list */
- if (using[other_thread])
- last_using[other_thread]->next = other_diff;
- else
- using[other_thread] = other_diff;
- last_using[other_thread] = other_diff;
-
- /* Take it off the current list. Note that this following
- code assumes that other_diff enters it equal to
- current[high_water_thread ^ 0x1] */
- current[other_thread]
- = current[other_thread]->next;
- other_diff->next
- = (struct diff_block *) 0;
-
- /* Set the high_water stuff
- If this comparison is equal, then this is the last pass
- through this loop; since diff blocks within a given
- thread cannot overlap, the high_water_mark will be
- *below* the range_start of either of the next diffs. */
-
- if (high_water_mark < D_HIGHLINE (other_diff, FC))
- {
- high_water_thread ^= 1;
- high_water_diff = other_diff;
- high_water_mark = D_HIGHLINE (other_diff, FC);
- }
-
- /* Set the other diff */
- other_thread = high_water_thread ^ 0x1;
- other_diff = current[other_thread];
- }
-
- /* The using lists contain a list of all of the blocks to be
- included in this diff3_block. Create it. */
-
- tmpblock = using_to_diff3_block (using, last_using,
- base_water_thread, high_water_thread,
- last_diff3);
-
- if (!tmpblock)
- fatal ("internal error: screwup in format of diff blocks");
-
- /* Put it on the list. */
- *result_end = tmpblock;
- result_end = &tmpblock->next;
-
- /* Set up corresponding lines correctly. */
- last_diff3 = tmpblock;
- }
- return result;
-}
-
-/*
- * using_to_diff3_block:
- * This routine takes two lists of blocks (from two separate diff
- * threads) and puts them together into one diff3 block.
- * It then returns a pointer to this diff3 block or 0 for failure.
- *
- * All arguments besides using are for the convenience of the routine;
- * they could be derived from the using array.
- * LAST_USING is a pair of pointers to the last blocks in the using
- * structure.
- * LOW_THREAD and HIGH_THREAD tell which threads contain the lowest
- * and highest line numbers for File0.
- * last_diff3 contains the last diff produced in the calling routine.
- * This is used for lines mappings which would still be identical to
- * the state that diff ended in.
- *
- * A distinction should be made in this routine between the two diffs
- * that are part of a normal two diff block, and the three diffs that
- * are part of a diff3_block.
- */
-static struct diff3_block *
-using_to_diff3_block (using, last_using, low_thread, high_thread, last_diff3)
- struct diff_block
- *using[2],
- *last_using[2];
- int low_thread, high_thread;
- struct diff3_block *last_diff3;
-{
- int low[2], high[2];
- struct diff3_block *result;
- struct diff_block *ptr;
- int d, i;
-
- /* Find the range in the common file. */
- int lowc = D_LOWLINE (using[low_thread], FC);
- int highc = D_HIGHLINE (last_using[high_thread], FC);
-
- /* Find the ranges in the other files.
- If using[d] is null, that means that the file to which that diff
- refers is equivalent to the common file over this range. */
-
- for (d = 0; d < 2; d++)
- if (using[d])
- {
- low[d] = D_LOW_MAPLINE (using[d], FC, FO, lowc);
- high[d] = D_HIGH_MAPLINE (last_using[d], FC, FO, highc);
- }
- else
- {
- low[d] = D_HIGH_MAPLINE (last_diff3, FILEC, FILE0 + d, lowc);
- high[d] = D_HIGH_MAPLINE (last_diff3, FILEC, FILE0 + d, highc);
- }
-
- /* Create a block with the appropriate sizes */
- result = create_diff3_block (low[0], high[0], low[1], high[1], lowc, highc);
-
- /* Copy information for the common file.
- Return with a zero if any of the compares failed. */
-
- for (d = 0; d < 2; d++)
- for (ptr = using[d]; ptr; ptr = D_NEXT (ptr))
- {
- int result_offset = D_LOWLINE (ptr, FC) - lowc;
-
- if (!copy_stringlist (D_LINEARRAY (ptr, FC),
- D_LENARRAY (ptr, FC),
- D_LINEARRAY (result, FILEC) + result_offset,
- D_LENARRAY (result, FILEC) + result_offset,
- D_NUMLINES (ptr, FC)))
- return 0;
- }
-
- /* Copy information for file d. First deal with anything that might be
- before the first diff. */
-
- for (d = 0; d < 2; d++)
- {
- struct diff_block *u = using[d];
- int lo = low[d], hi = high[d];
-
- for (i = 0;
- i + lo < (u ? D_LOWLINE (u, FO) : hi + 1);
- i++)
- {
- D_RELNUM (result, FILE0 + d, i) = D_RELNUM (result, FILEC, i);
- D_RELLEN (result, FILE0 + d, i) = D_RELLEN (result, FILEC, i);
- }
-
- for (ptr = u; ptr; ptr = D_NEXT (ptr))
- {
- int result_offset = D_LOWLINE (ptr, FO) - lo;
- int linec;
-
- if (!copy_stringlist (D_LINEARRAY (ptr, FO),
- D_LENARRAY (ptr, FO),
- D_LINEARRAY (result, FILE0 + d) + result_offset,
- D_LENARRAY (result, FILE0 + d) + result_offset,
- D_NUMLINES (ptr, FO)))
- return 0;
-
- /* Catch the lines between here and the next diff */
- linec = D_HIGHLINE (ptr, FC) + 1 - lowc;
- for (i = D_HIGHLINE (ptr, FO) + 1 - lo;
- i < (D_NEXT (ptr) ? D_LOWLINE (D_NEXT (ptr), FO) : hi + 1) - lo;
- i++)
- {
- D_RELNUM (result, FILE0 + d, i) = D_RELNUM (result, FILEC, linec);
- D_RELLEN (result, FILE0 + d, i) = D_RELLEN (result, FILEC, linec);
- linec++;
- }
- }
- }
-
- /* Set correspond */
- if (!using[0])
- D3_TYPE (result) = DIFF_2ND;
- else if (!using[1])
- D3_TYPE (result) = DIFF_1ST;
- else
- {
- int nl0 = D_NUMLINES (result, FILE0);
- int nl1 = D_NUMLINES (result, FILE1);
-
- if (nl0 != nl1
- || !compare_line_list (D_LINEARRAY (result, FILE0),
- D_LENARRAY (result, FILE0),
- D_LINEARRAY (result, FILE1),
- D_LENARRAY (result, FILE1),
- nl0))
- D3_TYPE (result) = DIFF_ALL;
- else
- D3_TYPE (result) = DIFF_3RD;
- }
-
- return result;
-}
-
-/*
- * This routine copies pointers from a list of strings to a different list
- * of strings. If a spot in the second list is already filled, it
- * makes sure that it is filled with the same string; if not it
- * returns 0, the copy incomplete.
- * Upon successful completion of the copy, it returns 1.
- */
-static int
-copy_stringlist (fromptrs, fromlengths, toptrs, tolengths, copynum)
- char *fromptrs[], *toptrs[];
- int *fromlengths, *tolengths;
- int copynum;
-{
- register char
- **f = fromptrs,
- **t = toptrs;
- register int
- *fl = fromlengths,
- *tl = tolengths;
-
- while (copynum--)
- {
- if (*t)
- { if (*fl != *tl || bcmp (*f, *t, *fl)) return 0; }
- else
- { *t = *f ; *tl = *fl; }
-
- t++; f++; tl++; fl++;
- }
- return 1;
-}
-
-/*
- * Create a diff3_block, with ranges as specified in the arguments.
- * Allocate the arrays for the various pointers (and zero them) based
- * on the arguments passed. Return the block as a result.
- */
-static struct diff3_block *
-create_diff3_block (low0, high0, low1, high1, low2, high2)
- register int low0, high0, low1, high1, low2, high2;
-{
- struct diff3_block *result = ALLOCATE (1, struct diff3_block);
- int numlines;
-
- D3_TYPE (result) = ERROR;
- D_NEXT (result) = 0;
-
- /* Assign ranges */
- D_LOWLINE (result, FILE0) = low0;
- D_HIGHLINE (result, FILE0) = high0;
- D_LOWLINE (result, FILE1) = low1;
- D_HIGHLINE (result, FILE1) = high1;
- D_LOWLINE (result, FILE2) = low2;
- D_HIGHLINE (result, FILE2) = high2;
-
- /* Allocate and zero space */
- numlines = D_NUMLINES (result, FILE0);
- if (numlines)
- {
- D_LINEARRAY (result, FILE0) = ALLOCATE (numlines, char *);
- D_LENARRAY (result, FILE0) = ALLOCATE (numlines, int);
- bzero (D_LINEARRAY (result, FILE0), (numlines * sizeof (char *)));
- bzero (D_LENARRAY (result, FILE0), (numlines * sizeof (int)));
- }
- else
- {
- D_LINEARRAY (result, FILE0) = (char **) 0;
- D_LENARRAY (result, FILE0) = (int *) 0;
- }
-
- numlines = D_NUMLINES (result, FILE1);
- if (numlines)
- {
- D_LINEARRAY (result, FILE1) = ALLOCATE (numlines, char *);
- D_LENARRAY (result, FILE1) = ALLOCATE (numlines, int);
- bzero (D_LINEARRAY (result, FILE1), (numlines * sizeof (char *)));
- bzero (D_LENARRAY (result, FILE1), (numlines * sizeof (int)));
- }
- else
- {
- D_LINEARRAY (result, FILE1) = (char **) 0;
- D_LENARRAY (result, FILE1) = (int *) 0;
- }
-
- numlines = D_NUMLINES (result, FILE2);
- if (numlines)
- {
- D_LINEARRAY (result, FILE2) = ALLOCATE (numlines, char *);
- D_LENARRAY (result, FILE2) = ALLOCATE (numlines, int);
- bzero (D_LINEARRAY (result, FILE2), (numlines * sizeof (char *)));
- bzero (D_LENARRAY (result, FILE2), (numlines * sizeof (int)));
- }
- else
- {
- D_LINEARRAY (result, FILE2) = (char **) 0;
- D_LENARRAY (result, FILE2) = (int *) 0;
- }
-
- /* Return */
- return result;
-}
-
-/*
- * Compare two lists of lines of text.
- * Return 1 if they are equivalent, 0 if not.
- */
-static int
-compare_line_list (list1, lengths1, list2, lengths2, nl)
- char *list1[], *list2[];
- int *lengths1, *lengths2;
- int nl;
-{
- char
- **l1 = list1,
- **l2 = list2;
- int
- *lgths1 = lengths1,
- *lgths2 = lengths2;
-
- while (nl--)
- if (!*l1 || !*l2 || *lgths1 != *lgths2++
- || bcmp (*l1++, *l2++, *lgths1++))
- return 0;
- return 1;
-}
-
-/*
- * Routines to input and parse two way diffs.
- */
-
-extern char **environ;
-
-#define DIFF_CHUNK_SIZE 10000
-
-static struct diff_block *
-process_diff (filea, fileb, last_block)
- char *filea, *fileb;
- struct diff_block **last_block;
-{
- char *diff_contents;
- char *diff_limit;
- char *scan_diff;
- enum diff_type dt;
- int i;
- struct diff_block *block_list, **block_list_end, *bptr;
-
- diff_limit = read_diff (filea, fileb, &diff_contents);
- scan_diff = diff_contents;
- block_list_end = &block_list;
-
- while (scan_diff < diff_limit)
- {
- bptr = ALLOCATE (1, struct diff_block);
- bptr->lines[0] = bptr->lines[1] = (char **) 0;
- bptr->lengths[0] = bptr->lengths[1] = (int *) 0;
-
- dt = process_diff_control (&scan_diff, bptr);
- if (dt == ERROR || *scan_diff != '\n')
- {
- fprintf (stderr, "%s: diff error: ", argv0);
- do
- {
- putc (*scan_diff, stderr);
- }
- while (*scan_diff++ != '\n');
- exit (2);
- }
- scan_diff++;
-
- /* Force appropriate ranges to be null, if necessary */
- switch (dt)
- {
- case ADD:
- bptr->ranges[0][0]++;
- break;
- case DELETE:
- bptr->ranges[1][0]++;
- break;
- case CHANGE:
- break;
- default:
- fatal ("internal error: invalid diff type in process_diff");
- break;
- }
-
- /* Allocate space for the pointers for the lines from filea, and
- parcel them out among these pointers */
- if (dt != ADD)
- {
- int numlines = D_NUMLINES (bptr, 0);
- bptr->lines[0] = ALLOCATE (numlines, char *);
- bptr->lengths[0] = ALLOCATE (numlines, int);
- for (i = 0; i < numlines; i++)
- scan_diff = scan_diff_line (scan_diff,
- &(bptr->lines[0][i]),
- &(bptr->lengths[0][i]),
- diff_limit,
- '<');
- }
-
- /* Get past the separator for changes */
- if (dt == CHANGE)
- {
- if (strncmp (scan_diff, "---\n", 4))
- fatal ("invalid diff format; invalid change separator");
- scan_diff += 4;
- }
-
- /* Allocate space for the pointers for the lines from fileb, and
- parcel them out among these pointers */
- if (dt != DELETE)
- {
- int numlines = D_NUMLINES (bptr, 1);
- bptr->lines[1] = ALLOCATE (numlines, char *);
- bptr->lengths[1] = ALLOCATE (numlines, int);
- for (i = 0; i < numlines; i++)
- scan_diff = scan_diff_line (scan_diff,
- &(bptr->lines[1][i]),
- &(bptr->lengths[1][i]),
- diff_limit,
- '>');
- }
-
- /* Place this block on the blocklist. */
- *block_list_end = bptr;
- block_list_end = &bptr->next;
- }
-
- *block_list_end = 0;
- *last_block = bptr;
- return block_list;
-}
-
-/*
- * This routine will parse a normal format diff control string. It
- * returns the type of the diff (ERROR if the format is bad). All of
- * the other important information is filled into to the structure
- * pointed to by db, and the string pointer (whose location is passed
- * to this routine) is updated to point beyond the end of the string
- * parsed. Note that only the ranges in the diff_block will be set by
- * this routine.
- *
- * If some specific pair of numbers has been reduced to a single
- * number, then both corresponding numbers in the diff block are set
- * to that number. In general these numbers are interpetted as ranges
- * inclusive, unless being used by the ADD or DELETE commands. It is
- * assumed that these will be special cased in a superior routine.
- */
-
-static enum diff_type
-process_diff_control (string, db)
- char **string;
- struct diff_block *db;
-{
- char *s = *string;
- int holdnum;
- enum diff_type type;
-
-/* These macros are defined here because they can use variables
- defined in this function. Don't try this at home kids, we're
- trained professionals!
-
- Also note that SKIPWHITE only recognizes tabs and spaces, and
- that READNUM can only read positive, integral numbers */
-
-#define SKIPWHITE(s) { while (*s == ' ' || *s == '\t') s++; }
-#define READNUM(s, num) \
- { if (!isdigit (*s)) return ERROR; holdnum = 0; \
- do { holdnum = (*s++ - '0' + holdnum * 10); } \
- while (isdigit (*s)); (num) = holdnum; }
-
- /* Read first set of digits */
- SKIPWHITE (s);
- READNUM (s, db->ranges[0][START]);
-
- /* Was that the only digit? */
- SKIPWHITE (s);
- if (*s == ',')
- {
- /* Get the next digit */
- s++;
- READNUM (s, db->ranges[0][END]);
- }
- else
- db->ranges[0][END] = db->ranges[0][START];
-
- /* Get the letter */
- SKIPWHITE (s);
- switch (*s)
- {
- case 'a':
- type = ADD;
- break;
- case 'c':
- type = CHANGE;
- break;
- case 'd':
- type = DELETE;
- break;
- default:
- return ERROR; /* Bad format */
- }
- s++; /* Past letter */
-
- /* Read second set of digits */
- SKIPWHITE (s);
- READNUM (s, db->ranges[1][START]);
-
- /* Was that the only digit? */
- SKIPWHITE (s);
- if (*s == ',')
- {
- /* Get the next digit */
- s++;
- READNUM (s, db->ranges[1][END]);
- SKIPWHITE (s); /* To move to end */
- }
- else
- db->ranges[1][END] = db->ranges[1][START];
-
- *string = s;
- return type;
-}
-
-static char *
-read_diff (filea, fileb, output_placement)
- char *filea, *fileb;
- char **output_placement;
-{
- char *argv[7];
- char horizon_arg[256];
- char **ap;
- int fds[2];
- char *diff_result;
- int current_chunk_size;
- int bytes;
- int total;
- int pid, w;
- int wstatus;
-
- ap = argv;
- *ap++ = diff_program;
- if (always_text)
- *ap++ = "-a";
- sprintf (horizon_arg, "--horizon-lines=%d", horizon_lines);
- *ap++ = horizon_arg;
- *ap++ = "--";
- *ap++ = filea;
- *ap++ = fileb;
- *ap = (char *) 0;
-
- if (pipe (fds) < 0)
- perror_with_exit ("pipe failed");
-
- pid = vfork ();
- if (pid == 0)
- {
- /* Child */
- close (fds[0]);
- if (fds[1] != fileno (stdout))
- {
- dup2 (fds[1], fileno (stdout));
- close (fds[1]);
- }
- execve (diff_program, argv, environ);
- /* Avoid stdio, because the parent process's buffers are inherited. */
- write (fileno (stderr), diff_program, strlen (diff_program));
- write (fileno (stderr), ": not found\n", 12);
- _exit (2);
- }
-
- if (pid == -1)
- perror_with_exit ("fork failed");
-
- close (fds[1]); /* Prevent erroneous lack of EOF */
- current_chunk_size = DIFF_CHUNK_SIZE;
- diff_result = (char *) xmalloc (current_chunk_size);
- total = 0;
- do {
- bytes = myread (fds[0],
- diff_result + total,
- current_chunk_size - total);
- total += bytes;
- if (total == current_chunk_size)
- diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2));
- } while (bytes);
-
- if (total != 0 && diff_result[total-1] != '\n')
- fatal ("invalid diff format; incomplete last line");
-
- *output_placement = diff_result;
-
- do
- if ((w = wait (&wstatus)) == -1)
- perror_with_exit ("wait failed");
- while (w != pid);
-
- if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
- fatal ("subsidiary diff failed");
-
- return diff_result + total;
-}
-
-
-/*
- * Scan a regular diff line (consisting of > or <, followed by a
- * space, followed by text (including nulls) up to a newline.
- *
- * This next routine began life as a macro and many parameters in it
- * are used as call-by-reference values.
- */
-static char *
-scan_diff_line (scan_ptr, set_start, set_length, limit, firstchar)
- char *scan_ptr, **set_start;
- int *set_length;
- char *limit;
- char firstchar;
-{
- char *line_ptr;
-
- if (!(scan_ptr[0] == (firstchar)
- && scan_ptr[1] == ' '))
- fatal ("invalid diff format; incorrect leading line chars");
-
- *set_start = line_ptr = scan_ptr + 2;
- while (*line_ptr++ != '\n')
- ;
-
- /* Include newline if the original line ended in a newline,
- or if an edit script is being generated.
- Copy any missing newline message to stderr if an edit script is being
- generated, because edit scripts cannot handle missing newlines.
- Return the beginning of the next line. */
- *set_length = line_ptr - *set_start;
- if (line_ptr < limit && *line_ptr == '\\')
- {
- if (edscript)
- fprintf (stderr, "%s:", argv0);
- else
- --*set_length;
- line_ptr++;
- do
- {
- if (edscript)
- putc (*line_ptr, stderr);
- }
- while (*line_ptr++ != '\n');
- }
-
- return line_ptr;
-}
-
-/*
- * This routine outputs a three way diff passed as a list of
- * diff3_block's.
- * The argument MAPPING is indexed by external file number (in the
- * argument list) and contains the internal file number (from the
- * diff passed). This is important because the user expects his
- * outputs in terms of the argument list number, and the diff passed
- * may have been done slightly differently (if the last argument
- * was "-", for example).
- * REV_MAPPING is the inverse of MAPPING.
- */
-static void
-output_diff3 (outputfile, diff, mapping, rev_mapping)
- FILE *outputfile;
- struct diff3_block *diff;
- int mapping[3], rev_mapping[3];
-{
- int i;
- int oddoneout;
- char *cp;
- struct diff3_block *ptr;
- int line;
- int length;
- int dontprint;
- static int skew_increment[3] = { 2, 3, 1 }; /* 0==>2==>1==>3 */
-
- for (ptr = diff; ptr; ptr = D_NEXT (ptr))
- {
- char x[2];
-
- switch (ptr->correspond)
- {
- case DIFF_ALL:
- x[0] = '\0';
- dontprint = 3; /* Print them all */
- oddoneout = 3; /* Nobody's odder than anyone else */
- break;
- case DIFF_1ST:
- case DIFF_2ND:
- case DIFF_3RD:
- oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
-
- x[0] = oddoneout + '1';
- x[1] = '\0';
- dontprint = oddoneout==0;
- break;
- default:
- fatal ("internal error: invalid diff type passed to output");
- }
- fprintf (outputfile, "====%s\n", x);
-
- /* Go 0, 2, 1 if the first and third outputs are equivalent. */
- for (i = 0; i < 3;
- i = (oddoneout == 1 ? skew_increment[i] : i + 1))
- {
- int realfile = mapping[i];
- int
- lowt = D_LOWLINE (ptr, realfile),
- hight = D_HIGHLINE (ptr, realfile);
-
- fprintf (outputfile, "%d:", i + 1);
- switch (lowt - hight)
- {
- case 1:
- fprintf (outputfile, "%da\n", lowt - 1);
- break;
- case 0:
- fprintf (outputfile, "%dc\n", lowt);
- break;
- default:
- fprintf (outputfile, "%d,%dc\n", lowt, hight);
- break;
- }
-
- if (i == dontprint) continue;
-
- for (line = 0; line < hight - lowt + 1; line++)
- {
- fprintf (outputfile, " ");
- cp = D_RELNUM (ptr, realfile, line);
- length = D_RELLEN (ptr, realfile, line);
- fwrite (cp, sizeof (char), length, outputfile);
- }
- if (line != 0 && cp[length - 1] != '\n')
- fprintf (outputfile, "\n\\ No newline at end of file\n");
- }
- }
-}
-
-
-/*
- * Output to OUTPUTFILE the lines of B taken from FILENUM.
- * Double any initial '.'s; yield nonzero if any initial '.'s were doubled.
- */
-static int
-dotlines (outputfile, b, filenum)
- FILE *outputfile;
- struct diff3_block *b;
- int filenum;
-{
- int i;
- int leading_dot = 0;
-
- for (i = 0;
- i < D_NUMLINES (b, filenum);
- i++)
- {
- char *line = D_RELNUM (b, filenum, i);
- if (line[0] == '.')
- {
- leading_dot = 1;
- fprintf (outputfile, ".");
- }
- fwrite (line, sizeof (char),
- D_RELLEN (b, filenum, i), outputfile);
- }
-
- return leading_dot;
-}
-
-/*
- * Output to OUTPUTFILE a '.' line. If LEADING_DOT is nonzero,
- * also output a command that removes initial '.'s
- * starting with line START and continuing for NUM lines.
- */
-static void
-undotlines (outputfile, leading_dot, start, num)
- FILE *outputfile;
- int leading_dot, start, num;
-{
- fprintf (outputfile, ".\n");
- if (leading_dot)
- if (num == 1)
- fprintf (outputfile, "%ds/^\\.//\n", start);
- else
- fprintf (outputfile, "%d,%ds/^\\.//\n", start, start + num - 1);
-}
-
-/*
- * This routine outputs a diff3 set of blocks as an ed script. This
- * script applies the changes between file's 2 & 3 to file 1. It
- * takes the precise format of the ed script to be output from global
- * variables set during options processing. Note that it does
- * destructive things to the set of diff3 blocks it is passed; it
- * reverses their order (this gets around the problems involved with
- * changing line numbers in an ed script).
- *
- * Note that this routine has the same problem of mapping as the last
- * one did; the variable MAPPING maps from file number according to
- * the argument list to file number according to the diff passed. All
- * files listed below are in terms of the argument list.
- * REV_MAPPING is the inverse of MAPPING.
- *
- * The arguments FILE0, FILE1 and FILE2 are the strings to print
- * as the names of the three files. These may be the actual names,
- * or may be the arguments specified with -L.
- *
- * Returns 1 if conflicts were found.
- */
-
-static int
-output_diff3_edscript (outputfile, diff, mapping, rev_mapping,
- file0, file1, file2)
- FILE *outputfile;
- struct diff3_block *diff;
- int mapping[3], rev_mapping[3];
- char *file0, *file1, *file2;
-{
- int leading_dot;
- int conflicts_found = 0, conflict;
- struct diff3_block *b;
-
- for (b = reverse_diff3_blocklist (diff); b; b = b->next)
- {
- /* Must do mapping correctly. */
- enum diff_type type
- = ((b->correspond == DIFF_ALL) ?
- DIFF_ALL :
- ((enum diff_type)
- (((int) DIFF_1ST)
- + rev_mapping[(int) b->correspond - (int) DIFF_1ST])));
-
- /* If we aren't supposed to do this output block, skip it. */
- switch (type)
- {
- default: continue;
- case DIFF_2ND: if (!show_2nd) continue; conflict = 1; break;
- case DIFF_3RD: if (overlap_only) continue; conflict = 0; break;
- case DIFF_ALL: if (simple_only) continue; conflict = flagging; break;
- }
-
- if (conflict)
- {
- conflicts_found = 1;
-
-
- /* Mark end of conflict. */
-
- fprintf (outputfile, "%da\n", D_HIGHLINE (b, mapping[FILE0]));
- leading_dot = 0;
- if (type == DIFF_ALL)
- {
- if (show_2nd)
- {
- /* Append lines from FILE1. */
- fprintf (outputfile, "||||||| %s\n", file1);
- leading_dot = dotlines (outputfile, b, mapping[FILE1]);
- }
- /* Append lines from FILE2. */
- fprintf (outputfile, "=======\n");
- leading_dot |= dotlines (outputfile, b, mapping[FILE2]);
- }
- fprintf (outputfile, ">>>>>>> %s\n", file2);
- undotlines (outputfile, leading_dot,
- D_HIGHLINE (b, mapping[FILE0]) + 2,
- (D_NUMLINES (b, mapping[FILE1])
- + D_NUMLINES (b, mapping[FILE2]) + 1));
-
-
- /* Mark start of conflict. */
-
- fprintf (outputfile, "%da\n<<<<<<< %s\n",
- D_LOWLINE (b, mapping[FILE0]) - 1,
- type == DIFF_ALL ? file0 : file1);
- leading_dot = 0;
- if (type == DIFF_2ND)
- {
- /* Prepend lines from FILE1. */
- leading_dot = dotlines (outputfile, b, mapping[FILE1]);
- fprintf (outputfile, "=======\n");
- }
- undotlines (outputfile, leading_dot,
- D_LOWLINE (b, mapping[FILE0]) + 1,
- D_NUMLINES (b, mapping[FILE1]));
- }
- else if (D_NUMLINES (b, mapping[FILE2]) == 0)
- /* Write out a delete */
- {
- if (D_NUMLINES (b, mapping[FILE0]) == 1)
- fprintf (outputfile, "%dd\n",
- D_LOWLINE (b, mapping[FILE0]));
- else
- fprintf (outputfile, "%d,%dd\n",
- D_LOWLINE (b, mapping[FILE0]),
- D_HIGHLINE (b, mapping[FILE0]));
- }
- else
- /* Write out an add or change */
- {
- switch (D_NUMLINES (b, mapping[FILE0]))
- {
- case 0:
- fprintf (outputfile, "%da\n",
- D_HIGHLINE (b, mapping[FILE0]));
- break;
- case 1:
- fprintf (outputfile, "%dc\n",
- D_HIGHLINE (b, mapping[FILE0]));
- break;
- default:
- fprintf (outputfile, "%d,%dc\n",
- D_LOWLINE (b, mapping[FILE0]),
- D_HIGHLINE (b, mapping[FILE0]));
- break;
- }
-
- undotlines (outputfile, dotlines (outputfile, b, mapping[FILE2]),
- D_LOWLINE (b, mapping[FILE0]),
- D_NUMLINES (b, mapping[FILE2]));
- }
- }
- if (finalwrite) fprintf (outputfile, "w\nq\n");
- return conflicts_found;
-}
-
-/*
- * Read from INFILE and output to OUTPUTFILE a set of diff3_ blocks DIFF
- * as a merged file. This acts like 'ed file0 <[output_diff3_edscript]',
- * except that it works even for binary data or incomplete lines.
- *
- * As before, MAPPING maps from arg list file number to diff file number,
- * REV_MAPPING is its inverse,
- * and FILE0, FILE1, and FILE2 are the names of the files.
- *
- * Returns 1 if conflicts were found.
- */
-
-static int
-output_diff3_merge (infile, outputfile, diff, mapping, rev_mapping,
- file0, file1, file2)
- FILE *infile, *outputfile;
- struct diff3_block *diff;
- int mapping[3], rev_mapping[3];
- char *file0, *file1, *file2;
-{
- int c, i;
- int conflicts_found = 0, conflict;
- struct diff3_block *b;
- int linesread = 0;
-
- for (b = diff; b; b = b->next)
- {
- /* Must do mapping correctly. */
- enum diff_type type
- = ((b->correspond == DIFF_ALL) ?
- DIFF_ALL :
- ((enum diff_type)
- (((int) DIFF_1ST)
- + rev_mapping[(int) b->correspond - (int) DIFF_1ST])));
- char *format_2nd = "<<<<<<< %s\n";
-
- /* If we aren't supposed to do this output block, skip it. */
- switch (type)
- {
- default: continue;
- case DIFF_2ND: if (!show_2nd) continue; conflict = 1; break;
- case DIFF_3RD: if (overlap_only) continue; conflict = 0; break;
- case DIFF_ALL: if (simple_only) continue; conflict = flagging;
- format_2nd = "||||||| %s\n";
- break;
- }
-
- /* Copy I lines from file 0. */
- i = D_LOWLINE (b, FILE0) - linesread - 1;
- linesread += i;
- while (0 <= --i)
- do
- {
- c = getc (infile);
- if (c == EOF)
- if (ferror (infile))
- perror_with_exit ("input file");
- else if (feof (infile))
- fatal ("input file shrank");
- putc (c, outputfile);
- }
- while (c != '\n');
-
- if (conflict)
- {
- conflicts_found = 1;
-
- if (type == DIFF_ALL)
- {
- /* Put in lines from FILE0 with bracket. */
- fprintf (outputfile, "<<<<<<< %s\n", file0);
- for (i = 0;
- i < D_NUMLINES (b, mapping[FILE0]);
- i++)
- fwrite (D_RELNUM (b, mapping[FILE0], i), sizeof (char),
- D_RELLEN (b, mapping[FILE0], i), outputfile);
- }
-
- if (show_2nd)
- {
- /* Put in lines from FILE1 with bracket. */
- fprintf (outputfile, format_2nd, file1);
- for (i = 0;
- i < D_NUMLINES (b, mapping[FILE1]);
- i++)
- fwrite (D_RELNUM (b, mapping[FILE1], i), sizeof (char),
- D_RELLEN (b, mapping[FILE1], i), outputfile);
- }
-
- fprintf (outputfile, "=======\n");
- }
-
- /* Put in lines from FILE2. */
- for (i = 0;
- i < D_NUMLINES (b, mapping[FILE2]);
- i++)
- fwrite (D_RELNUM (b, mapping[FILE2], i), sizeof (char),
- D_RELLEN (b, mapping[FILE2], i), outputfile);
-
- if (conflict)
- fprintf (outputfile, ">>>>>>> %s\n", file2);
-
- /* Skip I lines in file 0. */
- i = D_NUMLINES (b, FILE0);
- linesread += i;
- while (0 <= --i)
- while ((c = getc (infile)) != '\n')
- if (c == EOF)
- if (ferror (infile))
- perror_with_exit ("input file");
- else if (feof (infile))
- {
- if (i || b->next)
- fatal ("input file shrank");
- return conflicts_found;
- }
- }
- /* Copy rest of common file. */
- while ((c = getc (infile)) != EOF || !(ferror (infile) | feof (infile)))
- putc (c, outputfile);
- return conflicts_found;
-}
-
-/*
- * Reverse the order of the list of diff3 blocks.
- */
-static struct diff3_block *
-reverse_diff3_blocklist (diff)
- struct diff3_block *diff;
-{
- register struct diff3_block *tmp, *next, *prev;
-
- for (tmp = diff, prev = (struct diff3_block *) 0;
- tmp; tmp = next)
- {
- next = tmp->next;
- tmp->next = prev;
- prev = tmp;
- }
-
- return prev;
-}
-
-static int
-myread (fd, ptr, size)
- int fd, size;
- char *ptr;
-{
- int result = read (fd, ptr, size);
- if (result < 0)
- perror_with_exit ("read failed");
- return result;
-}
-
-VOID *
-xmalloc (size)
- unsigned size;
-{
- VOID *result = (VOID *) malloc (size ? size : 1);
- if (!result)
- fatal ("virtual memory exhausted");
- return result;
-}
-
-static VOID *
-xrealloc (ptr, size)
- VOID *ptr;
- unsigned size;
-{
- VOID *result = (VOID *) realloc (ptr, size ? size : 1);
- if (!result)
- fatal ("virtual memory exhausted");
- return result;
-}
-
-static void
-fatal (string)
- char *string;
-{
- fprintf (stderr, "%s: %s\n", argv0, string);
- exit (2);
-}
-
-static void
-perror_with_exit (string)
- char *string;
-{
- int e = errno;
- fprintf (stderr, "%s: ", argv0);
- errno = e;
- perror (string);
- exit (2);
-}
diff --git a/gnu/usr.bin/diff/dir.c b/gnu/usr.bin/diff/dir.c
deleted file mode 100644
index a5e3e2c..0000000
--- a/gnu/usr.bin/diff/dir.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* Read, sort and compare two directories. Used for GNU DIFF.
- Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "diff.h"
-
-static int compare_names ();
-
-/* Read the directory named by DIR and store into DIRDATA a sorted vector
- of filenames for its contents. DIR->desc == -1 means this directory is
- known to be nonexistent, so set DIRDATA to an empty vector.
- Return -1 (setting errno) if error, 0 otherwise. */
-
-struct dirdata
-{
- char **files; /* Sorted names of files in dir, terminated by (char *) 0. */
- char *data; /* Allocated storage for file names. */
-};
-
-static int
-dir_sort (dir, dirdata)
- struct file_data *dir;
- struct dirdata *dirdata;
-{
- register struct direct *next;
- register int i;
-
- /* Address of block containing the files that are described. */
- char **files;
-
- /* Number of files in directory. */
- int nfiles;
-
- /* Allocated and used storage for file name data. */
- char *data;
- size_t data_alloc, data_used;
-
- dirdata->files = 0;
- dirdata->data = 0;
- nfiles = 0;
-
- if (dir->desc != -1)
- {
- /* Open the directory and check for errors. */
- register DIR *reading = opendir (dir->name);
- if (!reading)
- return -1;
-
- /* Initialize the table of filenames. */
-
- data_alloc = max (1, (size_t) dir->stat.st_size);
- data_used = 0;
- dirdata->data = data = (char *) xmalloc (data_alloc);
-
- /* Read the directory entries, and insert the subfiles
- into the `data' table. */
-
- while ((errno = 0, (next = readdir (reading)) != 0))
- {
- char *d_name = next->d_name;
- size_t d_size;
-
- /* Ignore the files `.' and `..' */
- if (d_name[0] == '.'
- && (d_name[1] == 0 || (d_name[1] == '.' && d_name[2] == 0)))
- continue;
-
- if (excluded_filename (d_name))
- continue;
-
- d_size = strlen (d_name) + 1;
- while (data_alloc < data_used + d_size)
- dirdata->data = data = (char *) xrealloc (data, data_alloc *= 2);
- bcopy (d_name, data + data_used, d_size);
- data_used += d_size;
- nfiles++;
- }
- if (errno)
- {
- int e = errno;
- closedir (reading);
- errno = e;
- return -1;
- }
-#ifdef VOID_CLOSEDIR
- closedir (reading);
-#else
- if (closedir (reading) != 0)
- return -1;
-#endif
- }
-
- /* Create the `files' table from the `data' table. */
- dirdata->files = files = (char **) xmalloc (sizeof (char *) * (nfiles + 1));
- for (i = 0; i < nfiles; i++)
- {
- files[i] = data;
- data += strlen (data) + 1;
- }
- files[nfiles] = 0;
-
- /* Sort the table. */
- qsort (files, nfiles, sizeof (char *), compare_names);
-
- return 0;
-}
-
-/* Sort the files now in the table. */
-
-static int
-compare_names (file1, file2)
- char **file1, **file2;
-{
- return strcmp (*file1, *file2);
-}
-
-/* Compare the contents of two directories named in FILEVEC[0] and FILEVEC[1].
- This is a top-level routine; it does everything necessary for diff
- on two directories.
-
- FILEVEC[0].desc == -1 says directory FILEVEC[0] doesn't exist,
- but pretend it is empty. Likewise for FILEVEC[1].
-
- HANDLE_FILE is a caller-provided subroutine called to handle each file.
- It gets five operands: dir and name (rel to original working dir) of file
- in dir 0, dir and name pathname of file in dir 1, and the recursion depth.
-
- For a file that appears in only one of the dirs, one of the name-args
- to HANDLE_FILE is zero.
-
- DEPTH is the current depth in recursion, used for skipping top-level
- files by the -S option.
-
- Returns the maximum of all the values returned by HANDLE_FILE,
- or 2 if trouble is encountered in opening files. */
-
-int
-diff_dirs (filevec, handle_file, depth)
- struct file_data filevec[];
- int (*handle_file) ();
- int depth;
-{
- struct dirdata dirdata[2];
- int val = 0; /* Return value. */
- int i;
-
- /* Get sorted contents of both dirs. */
- for (i = 0; i < 2; i++)
- if (dir_sort (&filevec[i], &dirdata[i]) != 0)
- {
- perror_with_name (filevec[i].name);
- val = 2;
- }
-
- if (val == 0)
- {
- register char **files0 = dirdata[0].files;
- register char **files1 = dirdata[1].files;
- char *name0 = filevec[0].name;
- char *name1 = filevec[1].name;
-
- /* If `-S name' was given, and this is the topmost level of comparison,
- ignore all file names less than the specified starting name. */
-
- if (dir_start_file && depth == 0)
- {
- while (*files0 && strcmp (*files0, dir_start_file) < 0)
- files0++;
- while (*files1 && strcmp (*files1, dir_start_file) < 0)
- files1++;
- }
-
- /* Loop while files remain in one or both dirs. */
- while (*files0 || *files1)
- {
- /* Compare next name in dir 0 with next name in dir 1.
- At the end of a dir,
- pretend the "next name" in that dir is very large. */
- int nameorder = (!*files0 ? 1 : !*files1 ? -1
- : strcmp (*files0, *files1));
- int v1 = (*handle_file) (name0, 0 < nameorder ? 0 : *files0++,
- name1, nameorder < 0 ? 0 : *files1++,
- depth + 1);
- if (v1 > val)
- val = v1;
- }
- }
-
- for (i = 0; i < 2; i++)
- {
- if (dirdata[i].files)
- free (dirdata[i].files);
- if (dirdata[i].data)
- free (dirdata[i].data);
- }
-
- return val;
-}
diff --git a/gnu/usr.bin/diff/ed.c b/gnu/usr.bin/diff/ed.c
deleted file mode 100644
index fd051f2..0000000
--- a/gnu/usr.bin/diff/ed.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Output routines for ed-script format.
- Copyright (C) 1988, 89, 91, 92 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "diff.h"
-
-int change_letter ();
-int translate_line_number ();
-static void print_rcs_hunk ();
-static void print_ed_hunk ();
-static void pr_forward_ed_hunk ();
-void translate_range ();
-struct change *find_change ();
-struct change *find_reverse_change ();
-
-/* Print our script as ed commands. */
-
-void
-print_ed_script (script)
- struct change *script;
-{
- print_script (script, find_reverse_change, print_ed_hunk);
-}
-
-/* Print a hunk of an ed diff */
-
-static void
-print_ed_hunk (hunk)
- struct change *hunk;
-{
- int f0, l0, f1, l1;
- int deletes, inserts;
-
-#if 0
- hunk = flip_script (hunk);
-#endif
-#ifdef DEBUG
- debug_script (hunk);
-#endif
-
- /* Determine range of line numbers involved in each file. */
- analyze_hunk (hunk, &f0, &l0, &f1, &l1, &deletes, &inserts);
- if (!deletes && !inserts)
- return;
-
- begin_output ();
-
- /* Print out the line number header for this hunk */
- print_number_range (',', &files[0], f0, l0);
- fprintf (outfile, "%c\n", change_letter (inserts, deletes));
-
- /* Print new/changed lines from second file, if needed */
- if (inserts)
- {
- int i;
- int inserting = 1;
- for (i = f1; i <= l1; i++)
- {
- /* Resume the insert, if we stopped. */
- if (! inserting)
- fprintf (outfile, "%da\n",
- i - f1 + translate_line_number (&files[0], f0) - 1);
- inserting = 1;
-
- /* If the file's line is just a dot, it would confuse `ed'.
- So output it with a double dot, and set the flag LEADING_DOT
- so that we will output another ed-command later
- to change the double dot into a single dot. */
-
- if (files[1].linbuf[i][0] == '.'
- && files[1].linbuf[i][1] == '\n')
- {
- fprintf (outfile, "..\n");
- fprintf (outfile, ".\n");
- /* Now change that double dot to the desired single dot. */
- fprintf (outfile, "%ds/^\\.\\././\n",
- i - f1 + translate_line_number (&files[0], f0));
- inserting = 0;
- }
- else
- /* Line is not `.', so output it unmodified. */
- print_1_line ("", &files[1].linbuf[i]);
- }
-
- /* End insert mode, if we are still in it. */
- if (inserting)
- fprintf (outfile, ".\n");
- }
-}
-
-/* Print change script in the style of ed commands,
- but print the changes in the order they appear in the input files,
- which means that the commands are not truly useful with ed. */
-
-void
-pr_forward_ed_script (script)
- struct change *script;
-{
- print_script (script, find_change, pr_forward_ed_hunk);
-}
-
-static void
-pr_forward_ed_hunk (hunk)
- struct change *hunk;
-{
- int i;
- int f0, l0, f1, l1;
- int deletes, inserts;
-
- /* Determine range of line numbers involved in each file. */
- analyze_hunk (hunk, &f0, &l0, &f1, &l1, &deletes, &inserts);
- if (!deletes && !inserts)
- return;
-
- begin_output ();
-
- fprintf (outfile, "%c", change_letter (inserts, deletes));
- print_number_range (' ', files, f0, l0);
- fprintf (outfile, "\n");
-
- /* If deletion only, print just the number range. */
-
- if (!inserts)
- return;
-
- /* For insertion (with or without deletion), print the number range
- and the lines from file 2. */
-
- for (i = f1; i <= l1; i++)
- print_1_line ("", &files[1].linbuf[i]);
-
- fprintf (outfile, ".\n");
-}
-
-/* Print in a format somewhat like ed commands
- except that each insert command states the number of lines it inserts.
- This format is used for RCS. */
-
-void
-print_rcs_script (script)
- struct change *script;
-{
- print_script (script, find_change, print_rcs_hunk);
-}
-
-/* Print a hunk of an RCS diff */
-
-static void
-print_rcs_hunk (hunk)
- struct change *hunk;
-{
- int i;
- int f0, l0, f1, l1;
- int deletes, inserts;
- int tf0, tl0, tf1, tl1;
-
- /* Determine range of line numbers involved in each file. */
- analyze_hunk (hunk, &f0, &l0, &f1, &l1, &deletes, &inserts);
- if (!deletes && !inserts)
- return;
-
- begin_output ();
-
- translate_range (&files[0], f0, l0, &tf0, &tl0);
-
- if (deletes)
- {
- fprintf (outfile, "d");
- /* For deletion, print just the starting line number from file 0
- and the number of lines deleted. */
- fprintf (outfile, "%d %d\n",
- tf0,
- (tl0 >= tf0 ? tl0 - tf0 + 1 : 1));
- }
-
- if (inserts)
- {
- fprintf (outfile, "a");
-
- /* Take last-line-number from file 0 and # lines from file 1. */
- translate_range (&files[1], f1, l1, &tf1, &tl1);
- fprintf (outfile, "%d %d\n",
- tl0,
- (tl1 >= tf1 ? tl1 - tf1 + 1 : 1));
-
- /* Print the inserted lines. */
- for (i = f1; i <= l1; i++)
- print_1_line ("", &files[1].linbuf[i]);
- }
-}
diff --git a/gnu/usr.bin/diff/fnmatch.h b/gnu/usr.bin/diff/fnmatch.h
deleted file mode 100644
index 55cb17c..0000000
--- a/gnu/usr.bin/diff/fnmatch.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
-
-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; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#ifndef _FNMATCH_H
-
-#define _FNMATCH_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
-#undef __P
-#define __P(args) args
-#else /* Not C++ or ANSI C. */
-#undef __P
-#define __P(args) ()
-/* We can get away without defining `const' here only because in this file
- it is used only inside the prototype for `fnmatch', which is elided in
- non-ANSI C where `const' is problematical. */
-#endif /* C++ or ANSI C. */
-
-/* Bits set in the FLAGS argument to `fnmatch'. */
-#ifndef FNM_PATHNAME
-#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
-#endif
-#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
-#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
-
-#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE)
-#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
-#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
-#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
-#endif
-
-/* Value returned by `fnmatch' if STRING does not match PATTERN. */
-#define FNM_NOMATCH 1
-
-/* Match STRING against the filename pattern PATTERN,
- returning zero if it matches, FNM_NOMATCH if not. */
-extern int fnmatch __P ((const char *__pattern, const char *__string,
- int __flags));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* fnmatch.h */
diff --git a/gnu/usr.bin/diff/getopt.c b/gnu/usr.bin/diff/getopt.c
deleted file mode 100644
index a59a013..0000000
--- a/gnu/usr.bin/diff/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/diff/getopt.h b/gnu/usr.bin/diff/getopt.h
deleted file mode 100644
index 45541f5..0000000
--- a/gnu/usr.bin/diff/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/diff/getopt1.c b/gnu/usr.bin/diff/getopt1.c
deleted file mode 100644
index a32615c..0000000
--- a/gnu/usr.bin/diff/getopt1.c
+++ /dev/null
@@ -1,176 +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
-#include "config.h"
-#endif
-
-#include "getopt.h"
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#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/diff/ifdef.c b/gnu/usr.bin/diff/ifdef.c
deleted file mode 100644
index c5dde5c..0000000
--- a/gnu/usr.bin/diff/ifdef.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* #ifdef-format output routines for GNU DIFF.
- Copyright (C) 1989, 91, 92 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF 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 DIFF General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-GNU DIFF, but only under the conditions described in the
-GNU DIFF General Public License. A copy of this license is
-supposed to have been given to you along with GNU DIFF 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. */
-
-
-#include "diff.h"
-
-static void format_ifdef ();
-static void print_ifdef_hunk ();
-static void print_ifdef_lines ();
-struct change *find_change ();
-
-static int next_line;
-
-/* Print the edit-script SCRIPT as a merged #ifdef file. */
-
-void
-print_ifdef_script (script)
- struct change *script;
-{
- next_line = - files[0].prefix_lines;
- print_script (script, find_change, print_ifdef_hunk);
- if (next_line < files[0].valid_lines)
- {
- begin_output ();
- format_ifdef (group_format[UNCHANGED], next_line, files[0].valid_lines,
- 0, -1);
- }
-}
-
-/* Print a hunk of an ifdef diff.
- This is a contiguous portion of a complete edit script,
- describing changes in consecutive lines. */
-
-static void
-print_ifdef_hunk (hunk)
- struct change *hunk;
-{
- int first0, last0, first1, last1, deletes, inserts;
- const char *format;
-
- /* Determine range of line numbers involved in each file. */
- analyze_hunk (hunk, &first0, &last0, &first1, &last1, &deletes, &inserts);
- if (inserts)
- format = deletes ? group_format[CHANGED] : group_format[NEW];
- else if (deletes)
- format = group_format[OLD];
- else
- return;
-
- begin_output ();
-
- /* Print lines up to this change. */
- if (next_line < first0)
- format_ifdef (group_format[UNCHANGED], next_line, first0, 0, -1);
-
- /* Print this change. */
- next_line = last0 + 1;
- format_ifdef (format, first0, next_line, first1, last1 + 1);
-}
-
-/* Print a set of lines according to FORMAT.
- Lines BEG0 up to END0 are from the first file.
- If END1 is -1, then the second file's lines are identical to the first;
- otherwise, lines BEG1 up to END1 are from the second file. */
-
-static void
-format_ifdef (format, beg0, end0, beg1, end1)
- const char *format;
- int beg0, end0, beg1, end1;
-{
- register FILE *out = outfile;
- register char c;
- register const char *f = format;
-
- while ((c = *f++) != 0)
- {
- if (c == '%')
- switch ((c = *f++))
- {
- case 0:
- return;
-
- case '<':
- /* Print lines deleted from first file. */
- print_ifdef_lines (line_format[OLD], &files[0], beg0, end0);
- continue;
-
- case '=':
- /* Print common lines. */
- print_ifdef_lines (line_format[UNCHANGED], &files[0], beg0, end0);
- continue;
-
- case '>':
- /* Print lines inserted from second file. */
- if (end1 == -1)
- print_ifdef_lines (line_format[NEW], &files[0], beg0, end0);
- else
- print_ifdef_lines (line_format[NEW], &files[1], beg1, end1);
- continue;
-
- case '0':
- c = 0;
- break;
-
- default:
- break;
- }
- putc (c, out);
- }
-}
-
-/* Use FORMAT to print each line of CURRENT starting with FROM
- and continuing up to UPTO. */
-static void
-print_ifdef_lines (format, current, from, upto)
- const char *format;
- const struct file_data *current;
- int from, upto;
-{
- const char * const *linbuf = current->linbuf;
-
- /* If possible, use a single fwrite; it's faster. */
- if (!tab_expand_flag && strcmp (format, "%l\n") == 0)
- fwrite (linbuf[from], sizeof (char),
- linbuf[upto] + (linbuf[upto][-1] != '\n') - linbuf[from],
- outfile);
- else if (!tab_expand_flag && strcmp (format, "%L") == 0)
- fwrite (linbuf[from], sizeof (char), linbuf[upto] - linbuf[from], outfile);
- else
- for (; from < upto; from++)
- {
- register FILE *out = outfile;
- register char c;
- register const char *f = format;
-
- while ((c = *f++) != 0)
- {
- if (c == '%')
- switch ((c = *f++))
- {
- case 0:
- goto format_done;
-
- case 'l':
- output_1_line (linbuf[from],
- linbuf[from + 1]
- - (linbuf[from + 1][-1] == '\n'), 0, 0);
- continue;
-
- case 'L':
- output_1_line (linbuf[from], linbuf[from + 1], 0, 0);
- continue;
-
- case '0':
- c = 0;
- break;
-
- default:
- break;
- }
- putc (c, out);
- }
-
- format_done:;
- }
-}
diff --git a/gnu/usr.bin/diff/io.c b/gnu/usr.bin/diff/io.c
deleted file mode 100644
index a0633cd..0000000
--- a/gnu/usr.bin/diff/io.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/* File I/O for GNU DIFF.
- Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "diff.h"
-
-/* Rotate a value n bits to the left. */
-#define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
-#define ROL(v, n) ((v) << (n) | (v) >> (UINT_BIT - (n)))
-
-/* Given a hash value and a new character, return a new hash value. */
-#define HASH(h, c) ((c) + ROL (h, 7))
-
-int line_cmp ();
-
-/* Guess remaining number of lines from number N of lines so far,
- size S so far, and total size T. */
-#define GUESS_LINES(n,s,t) (((t) - (s)) / ((n) < 10 ? 32 : (s) / ((n)-1)) + 5)
-
-/* Type used for fast prefix comparison in find_identical_ends. */
-typedef long word;
-
-/* Character classes. */
-const char textchar[] = {
- /* ISO 8859 */
- 0, 0, 0, 0, 0, 0, 0, 0,
- 2, 2, 1, 2, 2, 2, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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
-};
-
-/* Lines are put into equivalence classes (of lines that match in line_cmp).
- Each equivalence class is represented by one of these structures,
- but only while the classes are being computed.
- Afterward, each class is represented by a number. */
-struct equivclass
-{
- int next; /* Next item in this bucket. */
- unsigned hash; /* Hash of lines in this class. */
- const char *line; /* A line that fits this class. */
- int length; /* The length of that line. */
-};
-
-/* Hash-table: array of buckets, each being a chain of equivalence classes. */
-static int *buckets;
-
-/* Number of buckets in the hash table array. */
-static int nbuckets;
-
-/* Array in which the equivalence classes are allocated.
- The bucket-chains go through the elements in this array.
- The number of an equivalence class is its index in this array. */
-static struct equivclass *equivs;
-
-/* Index of first free element in the array `equivs'. */
-static int equivs_index;
-
-/* Number of elements allocated in the array `equivs'. */
-static int equivs_alloc;
-
-/* Check for binary files and compare them for exact identity. */
-
-/* Return 1 if BUF contains a non text character.
- SIZE is the number of characters in BUF. */
-
-#define binary_file_p(buf, size) (size != 0 && memchr (buf, '\0', size) != 0)
-
-/* Get ready to read the current file.
- Return nonzero if SKIP_TEST is zero,
- and if it appears to be a binary file. */
-
-int
-sip (current, skip_test)
- struct file_data *current;
- int skip_test;
-{
- /* If we have a nonexistent file at this stage, treat it as empty. */
- if (current->desc < 0)
- {
- /* Leave room for a sentinel. */
- current->buffer = xmalloc (sizeof (word));
- current->bufsize = sizeof (word);
- current->buffered_chars = 0;
- }
- else
- {
- current->bufsize = current->buffered_chars
- = STAT_BLOCKSIZE (current->stat);
-
- if (S_ISREG (current->stat.st_mode))
- /* Get the size out of the stat block.
- Allocate enough room for appended newline and sentinel.
- Allocate at least one block, to prevent overrunning the buffer
- when comparing growing binary files. */
- current->bufsize = max (current->bufsize,
- current->stat.st_size + sizeof (word) + 1);
-
- current->buffer = xmalloc (current->bufsize);
- if (skip_test)
- current->buffered_chars = 0;
- else
- {
- /* Check first part of file to see if it's a binary file. */
- current->buffered_chars = read (current->desc,
- current->buffer,
- current->buffered_chars);
- if (current->buffered_chars < 0)
- pfatal_with_name (current->name);
- return binary_file_p (current->buffer, current->buffered_chars);
- }
- }
-
- return 0;
-}
-
-/* Slurp the rest of the current file completely into memory. */
-
-void
-slurp (current)
- struct file_data *current;
-{
- int cc;
-
- if (current->desc < 0)
- /* The file is nonexistent. */
- ;
- else if (S_ISREG (current->stat.st_mode))
- {
- /* It's a regular file; slurp in the rest all at once. */
- cc = current->stat.st_size - current->buffered_chars;
- if (cc)
- {
- cc = read (current->desc,
- current->buffer + current->buffered_chars,
- cc);
- if (cc < 0)
- pfatal_with_name (current->name);
- current->buffered_chars += cc;
- }
- }
- /* It's not a regular file; read it, growing the buffer as needed. */
- else if (always_text_flag || current->buffered_chars != 0)
- {
- for (;;)
- {
- if (current->buffered_chars == current->bufsize)
- {
- current->bufsize = current->bufsize * 2;
- current->buffer = (char *) xrealloc (current->buffer,
- current->bufsize);
- }
- cc = read (current->desc,
- current->buffer + current->buffered_chars,
- current->bufsize - current->buffered_chars);
- if (cc == 0)
- break;
- if (cc < 0)
- pfatal_with_name (current->name);
- current->buffered_chars += cc;
- }
- /* Allocate just enough room for appended newline and sentinel. */
- current->bufsize = current->buffered_chars + sizeof (word) + 1;
- current->buffer = (char *) xrealloc (current->buffer, current->bufsize);
- }
-}
-
-/* Split the file into lines, simultaneously computing the equivalence class for
- each line. */
-
-static void
-find_and_hash_each_line (current)
- struct file_data *current;
-{
- unsigned h;
- const unsigned char *p = (const unsigned char *) current->prefix_end;
- unsigned char c;
- int i, length, *bucket;
-
- /* Cache often-used quantities in local variables to help the compiler. */
- const char **linbuf = current->linbuf;
- int alloc_lines = current->alloc_lines;
- int line = 0;
- int linbuf_base = current->linbuf_base;
- int *cureqs = (int *) xmalloc (alloc_lines * sizeof (int));
- struct equivclass *eqs = equivs;
- int eqs_index = equivs_index;
- int eqs_alloc = equivs_alloc;
- const char *suffix_begin = current->suffix_begin;
- const char *bufend = current->buffer + current->buffered_chars;
- const char *incomplete_tail
- = current->missing_newline && ROBUST_OUTPUT_STYLE (output_style)
- ? bufend : (const char *) 0;
- int varies = length_varies;
-
- while ((const char *) p < suffix_begin)
- {
- const char *ip = (const char *) p;
-
- /* Compute the equivalence class for this line. */
-
- h = 0;
-
- /* Hash this line until we find a newline. */
- if (ignore_case_flag)
- {
- if (ignore_all_space_flag)
- while ((c = *p++) != '\n')
- {
- if (! Is_space (c))
- h = HASH (h, isupper (c) ? tolower (c) : c);
- }
- else if (ignore_space_change_flag)
- while ((c = *p++) != '\n')
- {
- if (c == ' ' || c == '\t')
- {
- while ((c = *p++) == ' ' || c == '\t')
- ;
- if (c == '\n')
- break;
- h = HASH (h, ' ');
- }
- /* C is now the first non-space. */
- h = HASH (h, isupper (c) ? tolower (c) : c);
- }
- else
- while ((c = *p++) != '\n')
- h = HASH (h, isupper (c) ? tolower (c) : c);
- }
- else
- {
- if (ignore_all_space_flag)
- while ((c = *p++) != '\n')
- {
- if (! Is_space (c))
- h = HASH (h, c);
- }
- else if (ignore_space_change_flag)
- while ((c = *p++) != '\n')
- {
- if (c == ' ' || c == '\t')
- {
- while ((c = *p++) == ' ' || c == '\t')
- ;
- if (c == '\n')
- break;
- h = HASH (h, ' ');
- }
- /* C is now the first non-space. */
- h = HASH (h, c);
- }
- else
- while ((c = *p++) != '\n')
- h = HASH (h, c);
- }
-
- bucket = &buckets[h % nbuckets];
- length = (const char *) p - ip - ((const char *) p == incomplete_tail);
- for (i = *bucket; ; i = eqs[i].next)
- if (!i)
- {
- /* Create a new equivalence class in this bucket. */
- i = eqs_index++;
- if (i == eqs_alloc)
- eqs = (struct equivclass *)
- xrealloc (eqs, (eqs_alloc*=2) * sizeof(*eqs));
- eqs[i].next = *bucket;
- eqs[i].hash = h;
- eqs[i].line = ip;
- eqs[i].length = length;
- *bucket = i;
- break;
- }
- else if (eqs[i].hash == h
- && (eqs[i].length == length || varies)
- && ! line_cmp (eqs[i].line, eqs[i].length, ip, length))
- /* Reuse existing equivalence class. */
- break;
-
- /* Maybe increase the size of the line table. */
- if (line == alloc_lines)
- {
- /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */
- alloc_lines = 2 * alloc_lines - linbuf_base;
- cureqs = (int *) xrealloc (cureqs, alloc_lines * sizeof (*cureqs));
- linbuf = (const char **) xrealloc (linbuf + linbuf_base,
- (alloc_lines - linbuf_base)
- * sizeof (*linbuf))
- - linbuf_base;
- }
- linbuf[line] = ip;
- cureqs[line] = i;
- ++line;
- }
-
- current->buffered_lines = line;
-
- for (i = 0; ; i++)
- {
- /* Record the line start for lines in the suffix that we care about.
- Record one more line start than lines,
- so that we can compute the length of any buffered line. */
- if (line == alloc_lines)
- {
- /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */
- alloc_lines = 2 * alloc_lines - linbuf_base;
- linbuf = (const char **) xrealloc (linbuf + linbuf_base,
- (alloc_lines - linbuf_base)
- * sizeof (*linbuf))
- - linbuf_base;
- }
- linbuf[line] = (const char *) p;
-
- if ((const char *) p == bufend)
- {
- linbuf[line] -= (const char *) p == incomplete_tail;
- break;
- }
-
- if (context <= i && no_diff_means_no_output)
- break;
-
- line++;
-
- while (*p++ != '\n')
- ;
- }
-
- /* Done with cache in local variables. */
- current->linbuf = linbuf;
- current->valid_lines = line;
- current->alloc_lines = alloc_lines;
- current->equivs = cureqs;
- equivs = eqs;
- equivs_alloc = eqs_alloc;
- equivs_index = eqs_index;
-}
-
-/* Prepare the end of the text. Make sure it's initialized.
- Make sure text ends in a newline,
- but remember that we had to add one unless -B is in effect. */
-
-static void
-prepare_text_end (current)
- struct file_data *current;
-{
- int buffered_chars = current->buffered_chars;
- char *p = current->buffer;
-
- if (buffered_chars == 0 || p[buffered_chars - 1] == '\n')
- current->missing_newline = 0;
- else
- {
- p[buffered_chars++] = '\n';
- current->buffered_chars = buffered_chars;
- current->missing_newline = ! ignore_blank_lines_flag;
- }
-
- /* Don't use uninitialized storage when planting or using sentinels. */
- if (p)
- bzero (p + buffered_chars, sizeof (word));
-}
-
-/* Given a vector of two file_data objects, find the identical
- prefixes and suffixes of each object. */
-
-static void
-find_identical_ends (filevec)
- struct file_data filevec[];
-{
- word *w0, *w1;
- char *p0, *p1, *buffer0, *buffer1;
- const char *end0, *beg0;
- const char **linbuf0, **linbuf1;
- int i, lines;
- int n0, n1, alloc_lines0, alloc_lines1;
- int buffered_prefix, prefix_count, prefix_mask;
- int tem;
-
- slurp (&filevec[0]);
- if (filevec[0].desc != filevec[1].desc)
- slurp (&filevec[1]);
- else
- {
- filevec[1].buffer = filevec[0].buffer;
- filevec[1].bufsize = filevec[0].bufsize;
- filevec[1].buffered_chars = filevec[0].buffered_chars;
- }
- for (i = 0; i < 2; i++)
- prepare_text_end (&filevec[i]);
-
- /* Find identical prefix. */
-
- p0 = buffer0 = filevec[0].buffer;
- p1 = buffer1 = filevec[1].buffer;
-
- n0 = filevec[0].buffered_chars;
- n1 = filevec[1].buffered_chars;
-
- if (p0 == p1)
- /* The buffers are the same; sentinels won't work. */
- p0 = p1 += n1;
- else
- {
- /* Insert end sentinels, in this case characters that are guaranteed
- to make the equality test false, and thus terminate the loop. */
-
- if (n0 < n1)
- p0[n0] = ~p1[n0];
- else
- p1[n1] = ~p0[n1];
-
- /* Loop until first mismatch, or to the sentinel characters. */
-
- /* Compare a word at a time for speed. */
- w0 = (word *) p0;
- w1 = (word *) p1;
- while (*w0++ == *w1++)
- ;
- --w0, --w1;
-
- /* Do the last few bytes of comparison a byte at a time. */
- p0 = (char *) w0;
- p1 = (char *) w1;
- while (*p0++ == *p1++)
- ;
- --p0, --p1;
-
- /* Don't mistakenly count missing newline as part of prefix. */
- if (ROBUST_OUTPUT_STYLE (output_style)
- && (buffer0 + n0 - filevec[0].missing_newline < p0)
- !=
- (buffer1 + n1 - filevec[1].missing_newline < p1))
- --p0, --p1;
- }
-
- /* Now P0 and P1 point at the first nonmatching characters. */
-
- /* Skip back to last line-beginning in the prefix,
- and then discard up to HORIZON_LINES lines from the prefix. */
- i = horizon_lines;
- while (p0 != buffer0 && (p0[-1] != '\n' || i--))
- --p0, --p1;
-
- /* Record the prefix. */
- filevec[0].prefix_end = p0;
- filevec[1].prefix_end = p1;
-
- /* Find identical suffix. */
-
- /* P0 and P1 point beyond the last chars not yet compared. */
- p0 = buffer0 + n0;
- p1 = buffer1 + n1;
-
- if (! ROBUST_OUTPUT_STYLE (output_style)
- || filevec[0].missing_newline == filevec[1].missing_newline)
- {
- end0 = p0; /* Addr of last char in file 0. */
-
- /* Get value of P0 at which we should stop scanning backward:
- this is when either P0 or P1 points just past the last char
- of the identical prefix. */
- beg0 = filevec[0].prefix_end + (n0 < n1 ? 0 : n0 - n1);
-
- /* Scan back until chars don't match or we reach that point. */
- while (p0 != beg0)
- if (*--p0 != *--p1)
- {
- /* Point at the first char of the matching suffix. */
- ++p0, ++p1;
- beg0 = p0;
- break;
- }
-
- /* Are we at a line-beginning in both files? If not, add the rest of
- this line to the main body. Discard up to HORIZON_LINES lines from
- the identical suffix. Also, discard one extra line,
- because shift_boundaries may need it. */
- i = horizon_lines + !((buffer0 == p0 || p0[-1] == '\n')
- &&
- (buffer1 == p1 || p1[-1] == '\n'));
- while (i-- && p0 != end0)
- while (*p0++ != '\n')
- ;
-
- p1 += p0 - beg0;
- }
-
- /* Record the suffix. */
- filevec[0].suffix_begin = p0;
- filevec[1].suffix_begin = p1;
-
- /* Calculate number of lines of prefix to save.
-
- prefix_count == 0 means save the whole prefix;
- we need this with for options like -D that output the whole file.
- We also need it for options like -F that output some preceding line;
- at least we will need to find the last few lines,
- but since we don't know how many, it's easiest to find them all.
-
- Otherwise, prefix_count != 0. Save just prefix_count lines at start
- of the line buffer; they'll be moved to the proper location later.
- Handle 1 more line than the context says (because we count 1 too many),
- rounded up to the next power of 2 to speed index computation. */
-
- if (no_diff_means_no_output && ! function_regexp_list)
- {
- for (prefix_count = 1; prefix_count < context + 1; prefix_count *= 2)
- ;
- prefix_mask = prefix_count - 1;
- alloc_lines0
- = prefix_count
- + GUESS_LINES (0, 0, p0 - filevec[0].prefix_end)
- + context;
- }
- else
- {
- prefix_count = 0;
- prefix_mask = ~0;
- alloc_lines0 = GUESS_LINES (0, 0, n0);
- }
-
- lines = 0;
- linbuf0 = (const char **) xmalloc (alloc_lines0 * sizeof (*linbuf0));
-
- /* If the prefix is needed, find the prefix lines. */
- if (! (no_diff_means_no_output
- && filevec[0].prefix_end == p0
- && filevec[1].prefix_end == p1))
- {
- p0 = buffer0;
- end0 = filevec[0].prefix_end;
- while (p0 != end0)
- {
- int l = lines++ & prefix_mask;
- if (l == alloc_lines0)
- linbuf0 = (const char **) xrealloc (linbuf0, (alloc_lines0 *= 2)
- * sizeof(*linbuf0));
- linbuf0[l] = p0;
- while (*p0++ != '\n')
- ;
- }
- }
- buffered_prefix = prefix_count && context < lines ? context : lines;
-
- /* Allocate line buffer 1. */
- tem = prefix_count ? filevec[1].suffix_begin - buffer1 : n1;
-
- alloc_lines1
- = (buffered_prefix
- + GUESS_LINES (lines, filevec[1].prefix_end - buffer1, tem)
- + context);
- linbuf1 = (const char **) xmalloc (alloc_lines1 * sizeof (*linbuf1));
-
- if (buffered_prefix != lines)
- {
- /* Rotate prefix lines to proper location. */
- for (i = 0; i < buffered_prefix; i++)
- linbuf1[i] = linbuf0[(lines - context + i) & prefix_mask];
- for (i = 0; i < buffered_prefix; i++)
- linbuf0[i] = linbuf1[i];
- }
-
- /* Initialize line buffer 1 from line buffer 0. */
- for (i = 0; i < buffered_prefix; i++)
- linbuf1[i] = linbuf0[i] - buffer0 + buffer1;
-
- /* Record the line buffer, adjusted so that
- linbuf*[0] points at the first differing line. */
- filevec[0].linbuf = linbuf0 + buffered_prefix;
- filevec[1].linbuf = linbuf1 + buffered_prefix;
- filevec[0].linbuf_base = filevec[1].linbuf_base = - buffered_prefix;
- filevec[0].alloc_lines = alloc_lines0 - buffered_prefix;
- filevec[1].alloc_lines = alloc_lines1 - buffered_prefix;
- filevec[0].prefix_lines = filevec[1].prefix_lines = lines;
-}
-
-/* Largest primes less than some power of two, for nbuckets. Values range
- from useful to preposterous. If one of these numbers isn't prime
- after all, don't blame it on me, blame it on primes (6) . . . */
-static const int primes[] =
-{
- 509,
- 1021,
- 2039,
- 4093,
- 8191,
- 16381,
- 32749,
- 65521,
- 131071,
- 262139,
- 524287,
- 1048573,
- 2097143,
- 4194301,
- 8388593,
- 16777213,
- 33554393,
- 67108859, /* Preposterously large . . . */
- 134217689,
- 268435399,
- 536870909,
- 1073741789,
- 2147483647,
- 0
-};
-
-/* Given a vector of two file_data objects, read the file associated
- with each one, and build the table of equivalence classes.
- Return 1 if either file appears to be a binary file. */
-
-int
-read_files (filevec)
- struct file_data filevec[];
-{
- int i;
- int skip_test = always_text_flag | no_details_flag;
- int appears_binary = no_details_flag | sip (&filevec[0], skip_test);
-
- if (filevec[0].desc != filevec[1].desc)
- appears_binary |= sip (&filevec[1], skip_test | appears_binary);
- else
- {
- filevec[1].buffer = filevec[0].buffer;
- filevec[1].bufsize = filevec[0].bufsize;
- filevec[1].buffered_chars = filevec[0].buffered_chars;
- }
- if (appears_binary)
- return 1;
-
- find_identical_ends (filevec);
-
- equivs_alloc = filevec[0].alloc_lines + filevec[1].alloc_lines + 1;
- equivs = (struct equivclass *) xmalloc (equivs_alloc * sizeof (struct equivclass));
- /* Equivalence class 0 is permanently safe for lines that were not
- hashed. Real equivalence classes start at 1. */
- equivs_index = 1;
-
- for (i = 0; primes[i] < equivs_alloc / 3; i++)
- if (! primes[i])
- abort ();
- nbuckets = primes[i];
-
- buckets = (int *) xmalloc (nbuckets * sizeof (*buckets));
- bzero (buckets, nbuckets * sizeof (*buckets));
-
- for (i = 0; i < 2; ++i)
- find_and_hash_each_line (&filevec[i]);
-
- filevec[0].equiv_max = filevec[1].equiv_max = equivs_index;
-
- free (equivs);
- free (buckets);
-
- return 0;
-}
diff --git a/gnu/usr.bin/diff/normal.c b/gnu/usr.bin/diff/normal.c
deleted file mode 100644
index a0cf479..0000000
--- a/gnu/usr.bin/diff/normal.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Normal-format output routines for GNU DIFF.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-#include "diff.h"
-
-int change_letter ();
-void print_normal_hunk ();
-void print_number_range ();
-struct change *find_change ();
-
-/* Print the edit-script SCRIPT as a normal diff.
- INF points to an array of descriptions of the two files. */
-
-void
-print_normal_script (script)
- struct change *script;
-{
- print_script (script, find_change, print_normal_hunk);
-}
-
-/* Print a hunk of a normal diff.
- This is a contiguous portion of a complete edit script,
- describing changes in consecutive lines. */
-
-void
-print_normal_hunk (hunk)
- struct change *hunk;
-{
- int first0, last0, first1, last1, deletes, inserts;
- register int i;
-
- /* Determine range of line numbers involved in each file. */
- analyze_hunk (hunk, &first0, &last0, &first1, &last1, &deletes, &inserts);
- if (!deletes && !inserts)
- return;
-
- begin_output ();
-
- /* Print out the line number header for this hunk */
- print_number_range (',', &files[0], first0, last0);
- fprintf (outfile, "%c", change_letter (inserts, deletes));
- print_number_range (',', &files[1], first1, last1);
- fprintf (outfile, "\n");
-
- /* Print the lines that the first file has. */
- if (deletes)
- for (i = first0; i <= last0; i++)
- print_1_line ("<", &files[0].linbuf[i]);
-
- if (inserts && deletes)
- fprintf (outfile, "---\n");
-
- /* Print the lines that the second file has. */
- if (inserts)
- for (i = first1; i <= last1; i++)
- print_1_line (">", &files[1].linbuf[i]);
-}
diff --git a/gnu/usr.bin/diff/regex.c b/gnu/usr.bin/diff/regex.c
deleted file mode 100644
index e8b5882..0000000
--- a/gnu/usr.bin/diff/regex.c
+++ /dev/null
@@ -1,4987 +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
-
-/* We need this for `regex.h', and perhaps for the Emacs include files. */
-#include <sys/types.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.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 (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 (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 void store_op1 (), store_op2 ();
-static void insert_op1 (), insert_op2 ();
-static boolean at_begline_loc_p (), at_endline_loc_p ();
-static boolean group_in_compile_stack ();
-static reg_errcode_t compile_range ();
-
-/* 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, (to) - (loc) - 3)
-
-/* Likewise, for a two-argument jump. */
-#define STORE_JUMP2(op, loc, to, arg) \
- store_op2 (op, loc, (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, (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, (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. */
-#define MAX_BUF_SIZE (1L << 16)
-
-
-/* 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. */
-typedef int 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"))
-
-/* `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;
- int 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':
- laststart = b;
- BUF_PUSH (wordchar);
- break;
-
-
- case 'W':
- laststart = b;
- BUF_PUSH (notwordchar);
- break;
-
-
- case '<':
- BUF_PUSH (wordbeg);
- break;
-
- case '>':
- BUF_PUSH (wordend);
- break;
-
- case 'b':
- BUF_PUSH (wordbound);
- break;
-
- case 'B':
- BUF_PUSH (notwordbound);
- break;
-
- case '`':
- BUF_PUSH (begbuf);
- break;
-
- case '\'':
- 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, 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;
- int 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. */
- if (range_start > range_end)
- return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-
- /* 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));
- }
-
- 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. */ \
- int 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);\
- } \
- \
- /* Push the info, starting with the registers. */ \
- DEBUG_PRINT1 ("\n"); \
- \
- 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); \
- } \
- \
- 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)
-
-/* 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;) \
- int 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); \
- \
- /* Restore register info. */ \
- high_reg = (unsigned) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
- \
- low_reg = (unsigned) 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;
- unsigned long size = bufp->used;
- const unsigned char *p = pattern;
- register unsigned char *pend = pattern + size;
-
- /* 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 = (regoff_t) 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 */
-
-/* Declarations and macros for re_match_2. */
-
-static int bcmp_translate ();
-static boolean alt_match_null_string_p (),
- common_op_match_null_string_p (),
- group_match_null_string_p ();
-
-/* 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. */
-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)
-
-
-/* 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 \
- { \
- unsigned 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. */
- unsigned num_regs = bufp->re_nsub + 1;
-
- /* The currently active registers. */
- unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- unsigned 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, **regend;
-
- /* 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, **old_regend;
-
- /* 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;
-
- /* 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, **best_regend;
-
- /* 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;
- register_info_type *reg_info_dummy;
-
-#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 ((int) old_regend[r] >= (int) regstart[r])
- regend[r] = old_regend[r];
- }
- }
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- PUSH_FAILURE_POINT (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);
- 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);
- 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'. */
- unsigned 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);
- 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);
- 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)
- unsigned char *s1, *s2;
- register int len;
- char *translate;
-{
- register unsigned char *p1 = s1, *p2 = 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;
- int 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
-
-/* 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;
- unsigned 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 /* not emacs */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/usr.bin/diff/regex.h b/gnu/usr.bin/diff/regex.h
deleted file mode 100644
index 408dd21..0000000
--- a/gnu/usr.bin/diff/regex.h
+++ /dev/null
@@ -1,490 +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__
-
-/* 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 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 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 (1)
-
-/* 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)
-
-/* 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_UNMATCHED_RIGHT_PAREN_ORD)
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
-
-#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
-#define RE_DUP_MAX ((1 << 15) - 1)
-
-
-/* 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. */
-
-#if __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, int 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));
-
-#endif /* not __REGEXP_LIBRARY_H__ */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/usr.bin/diff/sdiff.c b/gnu/usr.bin/diff/sdiff.c
deleted file mode 100644
index 7f1019e..0000000
--- a/gnu/usr.bin/diff/sdiff.c
+++ /dev/null
@@ -1,1067 +0,0 @@
-/* SDIFF -- interactive merge front end to diff
- Copyright (C) 1992 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* GNU SDIFF was written by Thomas Lord. */
-
-#include <stdio.h>
-#include <ctype.h>
-#include "system.h"
-#include <signal.h>
-#include "getopt.h"
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-/* Size of chunks read from files which must be parsed into lines. */
-#define SDIFF_BUFSIZE 65536
-
-/* Default name of the diff program */
-#ifndef DIFF_PROGRAM
-#define DIFF_PROGRAM "/usr/bin/diff"
-#endif
-
-/* Users' editor of nonchoice */
-#ifndef DEFAULT_EDITOR
-#define DEFAULT_EDITOR "ed"
-#endif
-
-extern char *version_string;
-static char const *prog;
-static char const *diffbin = DIFF_PROGRAM;
-static char const *edbin = DEFAULT_EDITOR;
-
-static char *tmpname;
-static int volatile tmpmade;
-static pid_t volatile diffpid;
-
-struct line_filter;
-static void diffarg (); /* (char *); */
-static void execdiff (); /* (int, char const *, char const *, char const *); */
-static int edit (); /* (struct line_filter *left, int lenl, struct
- line_filter *right, int lenr, FILE *outfile); */
-static int interact (); /* (struct line_filter *diff,
- struct line_filter *left,
- struct line_filter *right, FILE *outfile); */
-static void trapsigs (); /* (void); */
-/* this lossage until the gnu libc conquers the universe */
-#define TMPNAMSIZE 1024
-#define PVT_tmpdir "/tmp"
-static char *private_tempnam (); /* (const char *, const char *, int, int *); */
-static int diraccess ();
-
-/* Options: */
-
-/* name of output file if -o spec'd */
-static char *out_file;
-
-/* do not print common lines if true, set by -s option */
-static int suppress_common_flag;
-
-static struct option longopts[] =
-{
- {"ignore-blank-lines", 0, NULL, 'B'},
- {"speed-large-files", 0, NULL, 'H'},
- {"ignore-matching-lines", 1, NULL, 'I'},
- {"ignore-all-space", 0, NULL, 'W'}, /* swap W and w for historical reasons */
- {"text", 0, NULL, 'a'},
- {"ignore-space-change", 0, NULL, 'b'},
- {"minimal", 0, NULL, 'd'},
- {"ignore-case", 0, NULL, 'i'},
- {"left-column", 0, NULL, 'l'},
- {"output", 1, NULL, 'o'},
- {"suppress-common-lines", 0, NULL, 's'},
- {"expand-tabs", 0, NULL, 't'},
- {"width", 1, NULL, 'w'},
- {"version", 0, NULL, 'v'},
- {NULL, 0, NULL, 0}
-};
-
-/* prints usage message and quits */
-static void
-usage ()
-{
- fprintf (stderr, "Usage: %s [options] from-file to-file\n", prog);
- fprintf (stderr, "Options:\n\
- [-abBdHilstv] [-I regexp] [-o outfile] [-w columns]\n\
- [--text] [--minimal] [--speed-large-files] [--expand-tabs]\n\
- [--ignore-case] [--ignore-matching-lines=regexp]\n\
- [--ignore-space-change] [--ignore-blank-lines] [--ignore-all-space]\n\
- [--suppress-common-lines] [--left-column] [--output=outfile]\n\
- [--version] [--width=columns]\n");
- exit (2);
-}
-
-static void
-cleanup ()
-{
- if (0 < diffpid)
- kill (diffpid, SIGPIPE);
- if (tmpmade)
- unlink (tmpname);
-}
-
-static void
-exiterr ()
-{
- cleanup ();
- exit (2);
-}
-
-static void
-fatal (msg)
- char *msg;
-{
- fprintf (stderr, "%s: %s\n", prog, msg);
- exiterr ();
-}
-
-static void
-perror_fatal (msg)
- char *msg;
-{
- int e = errno;
- fprintf (stderr, "%s: ", prog);
- errno = e;
- perror (msg);
- exiterr ();
-}
-
-
-/* malloc freely or DIE! */
-char *
-xmalloc (size)
- size_t size;
-{
- char *r = malloc (size);
- if (!r)
- fatal ("virtual memory exhausted");
- return r;
-}
-
-static FILE *
-ck_fopen (fname, type)
- char *fname, *type;
-{
- FILE *r = fopen (fname, type);
- if (!r)
- perror_fatal (fname);
- return r;
-}
-
-
-static FILE *
-ck_fdopen (fd, type)
- int fd;
- char *type;
-{
- FILE *r = fdopen (fd, type);
- if (!r)
- perror_fatal ("fdopen");
- return r;
-}
-
-static void
-ck_fclose (f)
- FILE *f;
-{
- if (fclose (f))
- perror_fatal ("input/output error");
-}
-
-static size_t
-ck_fread (buf, size, f)
- char *buf;
- size_t size;
- FILE *f;
-{
- size_t r = fread (buf, sizeof (char), size, f);
- if (r == 0 && ferror (f))
- perror_fatal ("input error");
- return r;
-}
-
-static void
-ck_fwrite (buf, size, f)
- char *buf;
- size_t size;
- FILE *f;
-{
- if (fwrite (buf, sizeof (char), size, f) != size)
- perror_fatal ("output error");
-}
-
-static void
-ck_fflush (f)
- FILE *f;
-{
- if (fflush (f) != 0)
- perror_fatal ("output error");
-}
-
-#if !HAVE_MEMCHR
-char *
-memchr (s, c, n)
- char *s;
- int c;
- size_t n;
-{
- unsigned char *p = (unsigned char *) s, *lim = p + n;
- for (; p < lim; p++)
- if (*p == c)
- return (char *) p;
- return 0;
-}
-#endif
-
-#ifndef HAVE_WAITPID
-/* Emulate waitpid well enough for sdiff, which has at most two children. */
-static pid_t
-waitpid (pid, stat_loc, options)
- pid_t pid;
- int *stat_loc;
- int options;
-{
- static int ostatus;
- static pid_t opid;
- int npid, status;
-
- if (pid == opid)
- {
- opid = 0;
- status = ostatus;
- }
- else
- while ((npid = wait (&status)) != pid)
- {
- if (npid < 0)
- return npid;
- opid = npid;
- ostatus = status;
- }
- *stat_loc = status;
- return pid;
-}
-#endif
-
-static char const *
-expand_name (name, isdir, other_name)
- char *name;
- int isdir;
- char const *other_name;
-{
- if (strcmp (name, "-") == 0)
- fatal ("cannot interactively merge standard input");
- if (!isdir)
- return name;
- else
- {
- /* Yield NAME/BASE, where BASE is OTHER_NAME's basename. */
- const char
- *p = rindex (other_name, '/'),
- *base = p ? p+1 : other_name;
- size_t namelen = strlen (name), baselen = strlen (base);
- char *r = xmalloc (namelen + baselen + 2);
- bcopy (name, r, namelen);
- r[namelen] = '/';
- bcopy (base, r + namelen + 1, baselen + 1);
- return r;
- }
-}
-
-
-
-struct line_filter {
- FILE *infile;
- char *bufpos;
- char *buffer;
- char *buflim;
-};
-
-static void
-lf_init (lf, infile)
- struct line_filter *lf;
- FILE *infile;
-{
- lf->infile = infile;
- lf->bufpos = lf->buffer = lf->buflim = xmalloc (SDIFF_BUFSIZE + 1);
- lf->buflim[0] = '\n';
-}
-
-/* Fill an exhausted line_filter buffer from its INFILE */
-static size_t
-lf_refill (lf)
- struct line_filter *lf;
-{
- size_t s = ck_fread (lf->buffer, SDIFF_BUFSIZE, lf->infile);
- lf->bufpos = lf->buffer;
- lf->buflim = lf->buffer + s;
- lf->buflim[0] = '\n';
- return s;
-}
-
-/* Advance LINES on LF's infile, copying lines to OUTFILE */
-static void
-lf_copy (lf, lines, outfile)
- struct line_filter *lf;
- int lines;
- FILE *outfile;
-{
- char *start = lf->bufpos;
-
- while (lines)
- {
- lf->bufpos = memchr (lf->bufpos, '\n', lf->buflim - lf->bufpos);
- if (! lf->bufpos)
- {
- ck_fwrite (start, lf->buflim - start, outfile);
- if (! lf_refill (lf))
- return;
- start = lf->bufpos;
- }
- else
- {
- --lines;
- ++lf->bufpos;
- }
- }
-
- ck_fwrite (start, lf->bufpos - start, outfile);
-}
-
-/* Advance LINES on LF's infile without doing output */
-static void
-lf_skip (lf, lines)
- struct line_filter *lf;
- int lines;
-{
- while (lines)
- {
- lf->bufpos = memchr (lf->bufpos, '\n', lf->buflim - lf->bufpos);
- if (! lf->bufpos)
- {
- if (! lf_refill (lf))
- break;
- }
- else
- {
- --lines;
- ++lf->bufpos;
- }
- }
-}
-
-/* Snarf a line into a buffer. Return EOF if EOF, 0 if error, 1 if OK. */
-static int
-lf_snarf (lf, buffer, bufsize)
- struct line_filter *lf;
- char *buffer;
- size_t bufsize;
-{
- char *start = lf->bufpos;
-
- for (;;)
- {
- char *next = memchr (start, '\n', lf->buflim + 1 - start);
- size_t s = next - start;
- if (bufsize <= s)
- return 0;
- bcopy (start, buffer, s);
- if (next < lf->buflim)
- {
- buffer[s] = 0;
- lf->bufpos = next + 1;
- return 1;
- }
- if (! lf_refill (lf))
- return s ? 0 : EOF;
- buffer += s;
- bufsize -= s;
- start = next;
- }
-}
-
-
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- int opt;
- int version_requested = 0;
- char *editor = getenv ("EDITOR");
- char *differ = getenv ("DIFF");
-
- prog = argv[0];
- if (editor)
- edbin = editor;
- if (differ)
- diffbin = differ;
-
- diffarg ("diff");
-
- /* parse command line args */
- while ((opt=getopt_long (argc, argv, "abBdHiI:lo:stvw:W", longopts, (int *)0)) != EOF)
- {
- switch (opt)
- {
- case 'a':
- diffarg ("-a");
- break;
-
- case 'b':
- diffarg ("-b");
- break;
-
- case 'B':
- diffarg ("-B");
- break;
-
- case 'd':
- diffarg ("-d");
- break;
-
- case 'H':
- diffarg ("-H");
- break;
-
- case 'i':
- diffarg ("-i");
- break;
-
- case 'I':
- diffarg ("-I");
- diffarg (optarg);
- break;
-
- case 'l':
- diffarg ("--left-column");
- break;
-
- case 'o':
- out_file = optarg;
- break;
-
- case 's':
- suppress_common_flag = 1;
- break;
-
- case 't':
- diffarg ("-t");
- break;
-
- case 'v':
- version_requested = 1;
- fprintf (stderr, "GNU sdiff version %s\n", version_string);
- ck_fflush (stderr);
- break;
-
- case 'w':
- diffarg ("-W");
- diffarg (optarg);
- break;
-
- case 'W':
- diffarg ("-w");
- break;
-
- default:
- usage ();
- }
- }
-
- /* check: did user just want version message? if so exit. */
- if (version_requested && argc - optind == 0)
- exit (0);
-
- if (argc - optind != 2)
- usage ();
-
- if (! out_file)
- /* easy case: diff does everything for us */
- execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1]);
- else
- {
- FILE *left, *right, *out, *diffout;
- int diff_fds[2];
- int interact_ok;
- pid_t pid;
- struct line_filter lfilt;
- struct line_filter rfilt;
- struct line_filter diff_filt;
- int leftdir = diraccess (argv[optind]);
- int rightdir = diraccess (argv[optind + 1]);
-
- if (leftdir && rightdir)
- fatal ("both files to be compared are directories");
-
- left = ck_fopen (expand_name (argv[optind], leftdir, argv[optind + 1]), "r");
- ;
- right = ck_fopen (expand_name (argv[optind + 1], rightdir, argv[optind]), "r");
- out = ck_fopen (out_file, "w");
-
- if (pipe (diff_fds))
- perror_fatal ("pipe");
-
- trapsigs ();
-
- diffpid = pid = vfork ();
-
- if (pid == 0)
- {
- signal (SIGINT, SIG_IGN); /* in case user interrupts editor */
- signal (SIGPIPE, SIG_DFL);
-
- close (diff_fds[0]);
- if (diff_fds[1] != fileno (stdout))
- {
- dup2 (diff_fds[1], fileno (stdout));
- close (diff_fds[1]);
- }
-
- execdiff (0, "--sdiff-merge-assist", argv[optind], argv[optind + 1]);
- }
-
- if (pid < 0)
- perror_fatal ("fork failed");
-
- close (diff_fds[1]);
- diffout = ck_fdopen (diff_fds[0], "r");
-
- lf_init (&diff_filt, diffout);
- lf_init (&lfilt, left);
- lf_init (&rfilt, right);
-
- interact_ok = interact (&diff_filt, &lfilt, &rfilt, out);
-
- ck_fclose (diffout);
- ck_fclose (left);
- ck_fclose (right);
- ck_fclose (out);
-
- {
- int wstatus;
-
- if (waitpid (pid, &wstatus, 0) < 0)
- perror_fatal ("wait failed");
- diffpid = 0;
-
- if (tmpmade)
- {
- unlink (tmpname);
- tmpmade = 0;
- }
-
- if (! interact_ok)
- exit (2);
-
- if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
- fatal ("Subsidiary diff failed");
-
- exit (WEXITSTATUS (wstatus));
- }
- }
- return 0; /* Fool -Wall . . . */
-}
-
-static char **diffargv;
-
-static void
-diffarg (a)
- char *a;
-{
- static unsigned diffargs, diffargsmax;
-
- if (diffargs == diffargsmax)
- {
- if (! diffargsmax)
- {
- diffargv = (char **) xmalloc (sizeof (char));
- diffargsmax = 8;
- }
- diffargsmax *= 2;
- diffargv = (char **) realloc (diffargv, diffargsmax * sizeof (char *));
- if (! diffargv)
- fatal ("out of memory");
- }
- diffargv[diffargs++] = a;
-}
-
-static void
-execdiff (differences_only, option, file1, file2)
- int differences_only;
- char *option, *file1, *file2;
-{
- if (differences_only)
- diffarg ("--suppress-common-lines");
- diffarg (option);
- diffarg ("--");
- diffarg (file1);
- diffarg (file2);
- diffarg (0);
-
- execvp (diffbin, diffargv);
- write (fileno (stderr), diffbin, strlen (diffbin));
- write (fileno (stderr), ": not found\n", 12);
- _exit (2);
-}
-
-
-
-
-/* Signal handling */
-
-static int volatile ignore_signals;
-
-static void
-catchsig (s)
- int s;
-{
- signal (s, catchsig);
- if (! ignore_signals)
- {
- cleanup ();
- _exit (2);
- }
-}
-
-static void
-trapsigs ()
-{
- static int const sigs[] = {
-# ifdef SIGHUP
- SIGHUP,
-# endif
-# ifdef SIGQUIT
- SIGQUIT,
-# endif
-# ifdef SIGTERM
- SIGTERM,
-# endif
-# ifdef SIGXCPU
- SIGXCPU,
-# endif
-# ifdef SIGXFSZ
- SIGXFSZ,
-# endif
- SIGINT,
- SIGPIPE
- };
- int const *p;
-
- for (p = sigs; p < sigs + sizeof (sigs) / sizeof (*sigs); p++)
- if (signal (*p, SIG_IGN) != SIG_IGN && signal (*p, catchsig) != SIG_IGN)
- fatal ("signal error");
-}
-
-
-
-static void
-give_help ()
-{
- fprintf (stderr,"l:\tuse the left version\n");
- fprintf (stderr,"r:\tuse the right version\n");
- fprintf (stderr,"e l:\tedit then use the left version\n");
- fprintf (stderr,"e r:\tedit then use the right version\n");
- fprintf (stderr,"e b:\tedit then use the left and right versions concatenated\n");
- fprintf (stderr,"e:\tedit a new version\n");
- fprintf (stderr,"s:\tsilently include common lines\n");
- fprintf (stderr,"v:\tverbosely include common lines\n");
- fprintf (stderr,"q:\tquit\n");
-}
-
-static int
-skip_white ()
-{
- int c;
- while (isspace (c = getchar ()) && c != '\n')
- ;
- if (ferror (stdin))
- perror_fatal ("input error");
- return c;
-}
-
-static void
-flush_line ()
-{
- int c;
- while ((c = getchar ()) != '\n' && c != EOF)
- ;
- if (ferror (stdin))
- perror_fatal ("input error");
-}
-
-
-/* interpret an edit command */
-static int
-edit (left, lenl, right, lenr, outfile)
- struct line_filter *left;
- int lenl;
- struct line_filter *right;
- int lenr;
- FILE *outfile;
-{
- for (;;)
- {
- int cmd0, cmd1;
- int gotcmd = 0;
-
- while (!gotcmd)
- {
- if (putchar ('%') != '%')
- perror_fatal ("output error");
- ck_fflush (stdout);
-
- cmd0 = skip_white ();
- switch (cmd0)
- {
- case 'l': case 'r': case 's': case 'v': case 'q':
- if (skip_white () != '\n')
- {
- give_help ();
- flush_line ();
- continue;
- }
- gotcmd = 1;
- break;
-
- case 'e':
- cmd1 = skip_white ();
- switch (cmd1)
- {
- case 'l': case 'r': case 'b':
- if (skip_white () != '\n')
- {
- give_help ();
- flush_line ();
- continue;
- }
- gotcmd = 1;
- break;
- case '\n':
- gotcmd = 1;
- break;
- default:
- give_help ();
- flush_line ();
- continue;
- }
- break;
- case EOF:
- if (feof (stdin))
- {
- gotcmd = 1;
- cmd0 = 'q';
- break;
- }
- /* falls through */
- default:
- give_help ();
- flush_line ();
- continue;
- }
- }
-
- switch (cmd0)
- {
- case 'l':
- lf_copy (left, lenl, outfile);
- lf_skip (right, lenr);
- return 1;
- case 'r':
- lf_copy (right, lenr, outfile);
- lf_skip (left, lenl);
- return 1;
- case 's':
- suppress_common_flag = 1;
- break;
- case 'v':
- suppress_common_flag = 0;
- break;
- case 'q':
- return 0;
- case 'e':
- if (! tmpname && ! (tmpname = private_tempnam (0, "sdiff", 1, 0)))
- perror_fatal ("temporary file name");
-
- tmpmade = 1;
-
- {
- FILE *tmp = ck_fopen (tmpname, "w+");
-
- if (cmd1 == 'l' || cmd1 == 'b')
- lf_copy (left, lenl, tmp);
- else
- lf_skip (left, lenl);
-
- if (cmd1 == 'r' || cmd1 == 'b')
- lf_copy (right, lenr, tmp);
- else
- lf_skip (right, lenr);
-
- ck_fflush (tmp);
-
- {
- pid_t pid;
- int wstatus;
-
- ignore_signals = 1;
-
- pid = vfork ();
- if (pid == 0)
- {
- char const *argv[3];
- int i = 0;
-
- argv[i++] = edbin;
- argv[i++] = tmpname;
- argv[i++] = 0;
-
- execvp (edbin, (char **) argv);
- write (fileno (stderr), edbin, strlen (edbin));
- write (fileno (stderr), ": not found\n", 12);
- _exit (1);
- }
-
- if (pid < 0)
- perror_fatal ("fork failed");
-
- while (waitpid (pid, &wstatus, 0) < 0)
- if (errno != EINTR)
- perror_fatal ("wait failed");
-
- ignore_signals = 0;
-
- if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 1))
- fatal ("Subsidiary editor failed");
- }
-
- if (fseek (tmp, 0L, SEEK_SET) != 0)
- perror_fatal ("fseek");
- {
- /* SDIFF_BUFSIZE is too big for a local var
- in some compilers, so we allocate it dynamically. */
- char *buf = (char *) xmalloc (SDIFF_BUFSIZE);
- size_t size;
-
- while ((size = ck_fread (buf, SDIFF_BUFSIZE, tmp)) != 0)
- ck_fwrite (buf, size, outfile);
- ck_fclose (tmp);
-
- free (buf);
- }
- return 1;
- }
- default:
- give_help ();
- break;
- }
- }
-}
-
-
-
-/* Alternately reveal bursts of diff output and handle user editing comands. */
-static int
-interact (diff, left, right, outfile)
- struct line_filter *diff;
- struct line_filter *left;
- struct line_filter *right;
- FILE *outfile;
-{
- for (;;)
- {
- char diff_help[256];
- int snarfed = lf_snarf (diff, diff_help, sizeof (diff_help));
-
- if (snarfed <= 0)
- return snarfed;
-
- switch (diff_help[0])
- {
- case ' ':
- puts (diff_help + 1);
- break;
- case 'i':
- {
- int lenl = atoi (diff_help + 1), lenr, lenmax;
- char *p = index (diff_help, ',');
-
- if (!p)
- fatal (diff_help);
- lenr = atoi (p + 1);
- lenmax = max (lenl, lenr);
-
- if (suppress_common_flag)
- lf_skip (diff, lenmax);
- else
- lf_copy (diff, lenmax, stdout);
-
- lf_copy (left, lenl, outfile);
- lf_skip (right, lenr);
- break;
- }
- case 'c':
- {
- int lenl = atoi (diff_help + 1), lenr;
- char *p = index (diff_help, ',');
-
- if (!p)
- fatal (diff_help);
- lenr = atoi (p + 1);
- lf_copy (diff, max (lenl, lenr), stdout);
- if (! edit (left, lenl, right, lenr, outfile))
- return 0;
- break;
- }
- default:
- fatal (diff_help);
- break;
- }
- }
-}
-
-
-
-/* temporary lossage: this is torn from gnu libc */
-/* Return nonzero if DIR is an existent directory. */
-static int
-diraccess (dir)
- const char *dir;
-{
- struct stat buf;
- return stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
-}
-
-/* Return nonzero if FILE exists. */
-static int
-exists (file)
- const char *file;
-{
- struct stat buf;
- return stat (file, &buf) == 0;
-}
-
-/* These are the characters used in temporary filenames. */
-static const char letters[] =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
-/* Generate a temporary filename.
- If DIR_SEARCH is nonzero, DIR and PFX are used as
- described for tempnam. If not, a temporary filename
- in P_tmpdir with no special prefix is generated. If LENPTR
- is not NULL, *LENPTR is set the to length (including the
- terminating '\0') of the resultant filename, which is returned.
- This goes through a cyclic pattern of all possible filenames
- consisting of five decimal digits of the current pid and three
- of the characters in `letters'. Data for tempnam and tmpnam
- is kept separate, but when tempnam is using P_tmpdir and no
- prefix (i.e, it is identical to tmpnam), the same data is used.
- Each potential filename is tested for an already-existing file of
- the same name, and no name of an existing file will be returned.
- When the cycle reaches its end (12345ZZZ), NULL is returned. */
-
-
-static char *
-private_tempnam (dir, pfx, dir_search, lenptr)
- const char *dir;
- const char *pfx;
- int dir_search;
- size_t *lenptr;
-{
- static const char tmpdir[] = PVT_tmpdir;
- static struct
- {
- char buf[3];
- char *s;
- size_t i;
- } infos[2], *info;
- static char buf[TMPNAMSIZE];
- static pid_t oldpid = 0;
- pid_t pid = getpid ();
- register size_t len, plen;
-
- if (dir_search)
- {
- register const char *d = getenv ("TMPDIR");
- if (d != NULL && !diraccess (d))
- d = NULL;
- if (d == NULL && dir != NULL && diraccess (dir))
- d = dir;
- if (d == NULL && diraccess (tmpdir))
- d = tmpdir;
- if (d == NULL && diraccess ("/tmp"))
- d = "/tmp";
- if (d == NULL)
- {
- errno = ENOENT;
- return NULL;
- }
- dir = d;
- }
- else
- dir = tmpdir;
-
- if (pfx != NULL && *pfx != '\0')
- {
- plen = strlen (pfx);
- if (plen > 5)
- plen = 5;
- }
- else
- plen = 0;
-
- if (dir != tmpdir && !strcmp (dir, tmpdir))
- dir = tmpdir;
- info = &infos[(plen == 0 && dir == tmpdir) ? 1 : 0];
-
- if (pid != oldpid)
- {
- oldpid = pid;
- info->buf[0] = info->buf[1] = info->buf[2] = '0';
- info->s = &info->buf[0];
- info->i = 0;
- }
-
- len = strlen (dir) + 1 + plen + 8;
- for (;;)
- {
- *info->s = letters[info->i];
- sprintf (buf, "%s/%.*s%.5d%.3s", dir, (int) plen, pfx,
- pid % 100000, info->buf);
- if (!exists (buf))
- break;
- ++info->i;
- if (info->i > sizeof (letters) - 1)
- {
- info->i = 0;
- if (info->s == &info->buf[2])
- {
- errno = EEXIST;
- return NULL;
- }
- ++info->s;
- }
- }
-
- if (lenptr != NULL)
- *lenptr = len;
- return buf;
-}
diff --git a/gnu/usr.bin/diff/side.c b/gnu/usr.bin/diff/side.c
deleted file mode 100644
index a3d6d8b..0000000
--- a/gnu/usr.bin/diff/side.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/* sdiff-format output routines for GNU DIFF.
- Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF 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 DIFF General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-GNU DIFF, but only under the conditions described in the
-GNU DIFF General Public License. A copy of this license is
-supposed to have been given to you along with GNU DIFF 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. */
-
-
-#include "diff.h"
-
-
-static void print_sdiff_hunk ();
-static void print_sdiff_common_lines ();
-static void print_1sdiff_line ();
-
-/* Next line number to be printed in the two input files. */
-static int next0, next1;
-
-/* Print the edit-script SCRIPT as a sdiff style output. */
-
-void
-print_sdiff_script (script)
- struct change *script;
-{
- begin_output ();
-
- next0 = next1 = - files[0].prefix_lines;
- print_script (script, find_change, print_sdiff_hunk);
-
- print_sdiff_common_lines (files[0].valid_lines, files[1].valid_lines);
-}
-
-/* Tab from column FROM to column TO, where FROM <= TO. Yield TO. */
-
-static unsigned
-tab_from_to (from, to)
- unsigned from, to;
-{
- FILE *out = outfile;
- unsigned tab;
-
- if (! tab_expand_flag)
- for (tab = from + TAB_WIDTH - from % TAB_WIDTH; tab <= to; tab += TAB_WIDTH)
- {
- putc ('\t', out);
- from = tab;
- }
- while (from++ < to)
- putc (' ', out);
- return to;
-}
-
-/*
- * Print the text for half an sdiff line. This means truncate to width
- * observing tabs, and trim a trailing newline. Returns the last column
- * written (not the number of chars).
- */
-static unsigned
-print_half_line (line, indent, out_bound)
- const char * const *line;
- unsigned indent, out_bound;
-{
- FILE *out = outfile;
- register unsigned in_position = 0, out_position = 0;
- register const char
- *text_pointer = line[0],
- *text_limit = line[1];
-
- while (text_pointer < text_limit)
- {
- register unsigned char c = *text_pointer++;
-
- switch (c)
- {
- case '\t':
- {
- unsigned spaces = TAB_WIDTH - in_position % TAB_WIDTH;
- if (in_position == out_position)
- {
- unsigned tabstop = out_position + spaces;
- if (tab_expand_flag)
- {
- if (out_bound < tabstop)
- tabstop = out_bound;
- for (; out_position < tabstop; out_position++)
- putc (' ', out);
- }
- else
- if (tabstop < out_bound)
- {
- out_position = tabstop;
- putc (c, out);
- }
- }
- in_position += spaces;
- }
- break;
-
- case '\r':
- {
- putc (c, out);
- tab_from_to (0, indent);
- in_position = out_position = 0;
- }
- break;
-
- case '\b':
- if (in_position != 0 && --in_position < out_bound)
- if (out_position <= in_position)
- /* Add spaces to make up for suppressed tab past out_bound. */
- for (; out_position < in_position; out_position++)
- putc (' ', out);
- else
- {
- out_position = in_position;
- putc (c, out);
- }
- break;
-
- case '\f':
- case '\v':
- if (in_position < out_bound)
- putc (c, out);
- break;
-
- default:
- {
- register unsigned p = in_position;
- if (textchar[c])
- in_position++;
- if (p < out_bound)
- {
- out_position = in_position;
- putc (c, out);
- }
- }
- break;
-
- case '\n':
- return out_position;
- }
- }
-
- return out_position;
-}
-
-/*
- * Print side by side lines with a separator in the middle.
- * NULL parameters are taken to indicate whitespace text.
- * Blank lines that can easily be caught are reduced to a single newline.
- */
-
-static void
-print_1sdiff_line (left, sep, right)
- const char * const *left;
- int sep;
- const char * const *right;
-{
- FILE *out = outfile;
- unsigned hw = sdiff_half_width, c2o = sdiff_column2_offset;
- unsigned col = 0;
- int put_newline = 0;
-
- if (left)
- {
- if (left[1][-1] == '\n')
- put_newline = 1;
- col = print_half_line (left, 0, hw);
- }
-
- if (sep != ' ')
- {
- col = tab_from_to (col, (hw + c2o - 1) / 2) + 1;
- if (sep == '|' && put_newline != (right[1][-1] == '\n'))
- sep = put_newline ? '/' : '\\';
- putc (sep, out);
- }
-
- if (right)
- {
- if (right[1][-1] == '\n')
- put_newline = 1;
- if (**right != '\n')
- {
- col = tab_from_to (col, c2o);
- print_half_line (right, col, hw);
- }
- }
-
- if (put_newline)
- putc ('\n', out);
-}
-
-/* Print lines common to both files in side-by-side format. */
-static void
-print_sdiff_common_lines (limit0, limit1)
- int limit0, limit1;
-{
- int i0 = next0, i1 = next1;
-
- if (! sdiff_skip_common_lines && (i0 != limit0 || i1 != limit1))
- {
- if (sdiff_help_sdiff)
- fprintf (outfile, "i%d,%d\n", limit0 - i0, limit1 - i1);
-
- if (! sdiff_left_only)
- {
- while (i0 != limit0 && i1 != limit1)
- print_1sdiff_line (&files[0].linbuf[i0++], ' ', &files[1].linbuf[i1++]);
- while (i1 != limit1)
- print_1sdiff_line (0, ')', &files[1].linbuf[i1++]);
- }
- while (i0 != limit0)
- print_1sdiff_line (&files[0].linbuf[i0++], '(', 0);
- }
-
- next0 = limit0;
- next1 = limit1;
-}
-
-/* Print a hunk of an sdiff diff.
- This is a contiguous portion of a complete edit script,
- describing changes in consecutive lines. */
-
-static void
-print_sdiff_hunk (hunk)
- struct change *hunk;
-{
- int first0, last0, first1, last1, deletes, inserts;
- register int i, j;
-
- /* Determine range of line numbers involved in each file. */
- analyze_hunk (hunk, &first0, &last0, &first1, &last1, &deletes, &inserts);
- if (!deletes && !inserts)
- return;
-
- /* Print out lines up to this change. */
- print_sdiff_common_lines (first0, first1);
-
- if (sdiff_help_sdiff)
- fprintf (outfile, "c%d,%d\n", last0 - first0 + 1, last1 - first1 + 1);
-
- /* Print ``xxx | xxx '' lines */
- if (inserts && deletes)
- {
- for (i = first0, j = first1; i <= last0 && j <= last1; ++i, ++j)
- print_1sdiff_line (&files[0].linbuf[i], '|', &files[1].linbuf[j]);
- deletes = i <= last0;
- inserts = j <= last1;
- next0 = first0 = i;
- next1 = first1 = j;
- }
-
-
- /* Print `` > xxx '' lines */
- if (inserts)
- {
- for (j = first1; j <= last1; ++j)
- print_1sdiff_line (0, '>', &files[1].linbuf[j]);
- next1 = j;
- }
-
- /* Print ``xxx < '' lines */
- if (deletes)
- {
- for (i = first0; i <= last0; ++i)
- print_1sdiff_line (&files[0].linbuf[i], '<', 0);
- next0 = i;
- }
-}
diff --git a/gnu/usr.bin/diff/system.h b/gnu/usr.bin/diff/system.h
deleted file mode 100644
index b17d39a..0000000
--- a/gnu/usr.bin/diff/system.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* System dependent declarations.
- Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
-#endif
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
-#endif
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if HAVE_TIME_H
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#include <sys/file.h>
-#endif
-
-#if !HAVE_DUP2
-#define dup2(f,t) (close (t), fcntl (f,F_DUPFD,t))
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-
-#if HAVE_SYS_WAIT_H
-#ifndef _POSIX_VERSION
-/* Prevent the NeXT prototype using union wait from causing problems. */
-#define wait system_wait
-#endif
-#include <sys/wait.h>
-#ifndef _POSIX_VERSION
-#undef wait
-#endif
-#endif /* HAVE_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) & 255) == 0)
-#endif
-
-#if HAVE_ST_BLKSIZE
-#define STAT_BLOCKSIZE(s) (s).st_blksize
-#else
-#define STAT_BLOCKSIZE(s) (S_ISREG ((s).st_mode) ? 8192 : 4096)
-#endif
-
-#if DIRENT || defined (_POSIX_VERSION)
-#include <dirent.h>
-#ifdef direct
-#undef direct
-#endif
-#define direct dirent
-#else /* ! (DIRENT || defined (_POSIX_VERSION)) */
-#if SYSNDIR
-#include <sys/ndir.h>
-#else
-#if SYSDIR
-#include <sys/dir.h>
-#else
-#include <ndir.h>
-#endif
-#endif
-#endif /* ! (DIRENT || defined (_POSIX_VERSION)) */
-
-#if HAVE_VFORK_H
-#include <vfork.h>
-#endif
-
-#if HAVE_STRING_H || STDC_HEADERS
-#include <string.h>
-#ifndef index
-#define index strchr
-#endif
-#ifndef rindex
-#define rindex strrchr
-#endif
-#ifndef bcopy
-#define bcopy(s,d,n) memcpy (d,s,n)
-#endif
-#ifndef bcmp
-#define bcmp(s1,s2,n) memcmp (s1,s2,n)
-#endif
-#ifndef bzero
-#define bzero(s,n) memset (s,0,n)
-#endif
-#else
-#include <strings.h>
-#endif
-#if !HAVE_MEMCHR && !STDC_HEADERS
-char *memchr ();
-#endif
-
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <limits.h>
-#else
-char *getenv ();
-char *malloc ();
-char *realloc ();
-#if __STDC__ || __GNUC__
-#include "limits.h"
-#else
-#define INT_MAX 2147483647
-#define CHAR_BIT 8
-#endif
-#endif
-
-#include <errno.h>
-#if !STDC_HEADERS
-extern int errno;
-#endif
-
-#ifdef TRUE
-#undef TRUE
-#endif
-#ifdef FALSE
-#undef FALSE
-#endif
-#define TRUE 1
-#define FALSE 0
-
-#if !__STDC__
-#define volatile
-#endif
-
-#define min(a,b) ((a) <= (b) ? (a) : (b))
-#define max(a,b) ((a) >= (b) ? (a) : (b))
diff --git a/gnu/usr.bin/diff/util.c b/gnu/usr.bin/diff/util.c
deleted file mode 100644
index e72fd4d..0000000
--- a/gnu/usr.bin/diff/util.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/* Support routines for GNU DIFF.
- Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "diff.h"
-
-/* Use when a system call returns non-zero status.
- TEXT should normally be the file name. */
-
-void
-perror_with_name (text)
- char *text;
-{
- int e = errno;
- fprintf (stderr, "%s: ", program);
- errno = e;
- perror (text);
-}
-
-/* Use when a system call returns non-zero status and that is fatal. */
-
-void
-pfatal_with_name (text)
- char *text;
-{
- int e = errno;
- print_message_queue ();
- fprintf (stderr, "%s: ", program);
- errno = e;
- perror (text);
- exit (2);
-}
-
-/* Print an error message from the format-string FORMAT
- with args ARG1 and ARG2. */
-
-void
-error (format, arg, arg1)
- char *format;
- char *arg;
- char *arg1;
-{
- fprintf (stderr, "%s: ", program);
- fprintf (stderr, format, arg, arg1);
- fprintf (stderr, "\n");
-}
-
-/* Print an error message containing the string TEXT, then exit. */
-
-void
-fatal (m)
- char *m;
-{
- print_message_queue ();
- error ("%s", m, 0);
- exit (2);
-}
-
-/* Like printf, except if -l in effect then save the message and print later.
- This is used for things like "binary files differ" and "Only in ...". */
-
-void
-message (format, arg1, arg2)
- char *format, *arg1, *arg2;
-{
- if (paginate_flag)
- {
- struct msg *new = (struct msg *) xmalloc (sizeof (struct msg));
- if (msg_chain_end == 0)
- msg_chain = msg_chain_end = new;
- else
- {
- msg_chain_end->next = new;
- msg_chain_end = new;
- }
- new->format = format;
- new->arg1 = concat (arg1, "", "");
- new->arg2 = concat (arg2, "", "");
- new->next = 0;
- }
- else
- {
- if (sdiff_help_sdiff)
- putchar (' ');
- printf (format, arg1, arg2);
- }
-}
-
-/* Output all the messages that were saved up by calls to `message'. */
-
-void
-print_message_queue ()
-{
- struct msg *m;
-
- for (m = msg_chain; m; m = m->next)
- printf (m->format, m->arg1, m->arg2);
-}
-
-/* Call before outputting the results of comparing files NAME0 and NAME1
- to set up OUTFILE, the stdio stream for the output to go to.
-
- Usually, OUTFILE is just stdout. But when -l was specified
- we fork off a `pr' and make OUTFILE a pipe to it.
- `pr' then outputs to our stdout. */
-
-static char *current_name0;
-static char *current_name1;
-static int current_depth;
-
-void
-setup_output (name0, name1, depth)
- char *name0, *name1;
- int depth;
-{
- current_name0 = name0;
- current_name1 = name1;
- current_depth = depth;
- outfile = 0;
-}
-
-void
-begin_output ()
-{
- char *name;
-
- if (outfile != 0)
- return;
-
- /* Construct the header of this piece of diff. */
- name = (char *) xmalloc (strlen (current_name0) + strlen (current_name1)
- + strlen (switch_string) + 15);
-
- strcpy (name, "diff");
- strcat (name, switch_string);
- strcat (name, " ");
- strcat (name, current_name0);
- strcat (name, " ");
- strcat (name, current_name1);
-
- if (paginate_flag)
- {
- int pipes[2];
- int desc;
-
- /* For a `pr' and make OUTFILE a pipe to it. */
- if (pipe (pipes) < 0)
- pfatal_with_name ("pipe");
-
- fflush (stdout);
-
- desc = vfork ();
- if (desc < 0)
- pfatal_with_name ("vfork");
-
- if (desc == 0)
- {
- close (pipes[1]);
- if (pipes[0] != fileno (stdin))
- {
- if (dup2 (pipes[0], fileno (stdin)) < 0)
- pfatal_with_name ("dup2");
- close (pipes[0]);
- }
-
- if (execl (PR_FILE_NAME, PR_FILE_NAME, "-f", "-h", name, 0) < 0)
- pfatal_with_name (PR_FILE_NAME);
- }
- else
- {
- close (pipes[0]);
- outfile = fdopen (pipes[1], "w");
- }
- }
- else
- {
-
- /* If -l was not specified, output the diff straight to `stdout'. */
-
- outfile = stdout;
-
- /* If handling multiple files (because scanning a directory),
- print which files the following output is about. */
- if (current_depth > 0)
- printf ("%s\n", name);
- }
-
- free (name);
-
- /* A special header is needed at the beginning of context output. */
- switch (output_style)
- {
- case OUTPUT_CONTEXT:
- print_context_header (files, 0);
- break;
-
- case OUTPUT_UNIFIED:
- print_context_header (files, 1);
- break;
-
- default:
- break;
- }
-}
-
-/* Call after the end of output of diffs for one file.
- Close OUTFILE and get rid of the `pr' subfork. */
-
-void
-finish_output ()
-{
- if (outfile != 0 && outfile != stdout)
- {
- fclose (outfile);
- wait (0);
- }
-
- outfile = 0;
-}
-
-/* Compare two lines (typically one from each input file)
- according to the command line options.
- Return 1 if the lines differ, like `bcmp'. */
-
-int
-line_cmp (s1, len1, s2, len2)
- const char *s1, *s2;
- int len1, len2;
-{
- register const unsigned char *t1, *t2;
- register unsigned char end_char = line_end_char;
-
- /* Check first for exact identity.
- If that is true, return 0 immediately.
- This detects the common case of exact identity
- faster than complete comparison would. */
-
- if (len1 == len2 && bcmp (s1, s2, len1) == 0)
- return 0;
-
- /* Not exactly identical, but perhaps they match anyway
- when case or whitespace is ignored. */
-
- if (ignore_case_flag || ignore_space_change_flag || ignore_all_space_flag)
- {
- t1 = (const unsigned char *) s1;
- t2 = (const unsigned char *) s2;
-
- while (1)
- {
- register unsigned char c1 = *t1++;
- register unsigned char c2 = *t2++;
-
- /* Ignore horizontal whitespace if -b or -w is specified. */
-
- if (ignore_all_space_flag)
- {
- /* For -w, just skip past any white space. */
- while (Is_space (c1)) c1 = *t1++;
- while (Is_space (c2)) c2 = *t2++;
- }
- else if (ignore_space_change_flag)
- {
- /* For -b, advance past any sequence of whitespace in line 1
- and consider it just one Space, or nothing at all
- if it is at the end of the line. */
- if (c1 == ' ' || c1 == '\t')
- {
- while (1)
- {
- c1 = *t1++;
- if (c1 == end_char)
- break;
- if (c1 != ' ' && c1 != '\t')
- {
- --t1;
- c1 = ' ';
- break;
- }
- }
- }
-
- /* Likewise for line 2. */
- if (c2 == ' ' || c2 == '\t')
- {
- while (1)
- {
- c2 = *t2++;
- if (c2 == end_char)
- break;
- if (c2 != ' ' && c2 != '\t')
- {
- --t2;
- c2 = ' ';
- break;
- }
- }
- }
- }
-
- /* Upcase all letters if -i is specified. */
-
- if (ignore_case_flag)
- {
- if (islower (c1))
- c1 = toupper (c1);
- if (islower (c2))
- c2 = toupper (c2);
- }
-
- if (c1 != c2)
- break;
- if (c1 == end_char)
- return 0;
- }
- }
-
- return (1);
-}
-
-/* Find the consecutive changes at the start of the script START.
- Return the last link before the first gap. */
-
-struct change *
-find_change (start)
- struct change *start;
-{
- return start;
-}
-
-struct change *
-find_reverse_change (start)
- struct change *start;
-{
- return start;
-}
-
-/* Divide SCRIPT into pieces by calling HUNKFUN and
- print each piece with PRINTFUN.
- Both functions take one arg, an edit script.
-
- HUNKFUN is called with the tail of the script
- and returns the last link that belongs together with the start
- of the tail.
-
- PRINTFUN takes a subscript which belongs together (with a null
- link at the end) and prints it. */
-
-void
-print_script (script, hunkfun, printfun)
- struct change *script;
- struct change * (*hunkfun) ();
- void (*printfun) ();
-{
- struct change *next = script;
-
- while (next)
- {
- struct change *this, *end;
-
- /* Find a set of changes that belong together. */
- this = next;
- end = (*hunkfun) (next);
-
- /* Disconnect them from the rest of the changes,
- making them a hunk, and remember the rest for next iteration. */
- next = end->link;
- end->link = NULL;
-#ifdef DEBUG
- debug_script (this);
-#endif
-
- /* Print this hunk. */
- (*printfun) (this);
-
- /* Reconnect the script so it will all be freed properly. */
- end->link = next;
- }
-}
-
-/* Print the text of a single line LINE,
- flagging it with the characters in LINE_FLAG (which say whether
- the line is inserted, deleted, changed, etc.). */
-
-void
-print_1_line (line_flag, line)
- const char *line_flag;
- const char * const *line;
-{
- const char *text = line[0], *limit = line[1]; /* Help the compiler. */
- FILE *out = outfile; /* Help the compiler some more. */
- const char *flag_format = 0;
-
- /* If -T was specified, use a Tab between the line-flag and the text.
- Otherwise use a Space (as Unix diff does).
- Print neither space nor tab if line-flags are empty. */
-
- if (line_flag != NULL && line_flag[0] != 0)
- {
- flag_format = tab_align_flag ? "%s\t" : "%s ";
- fprintf (out, flag_format, line_flag);
- }
-
- output_1_line (text, limit, flag_format, line_flag);
-
- if ((line_flag == NULL || line_flag[0] != 0) && limit[-1] != '\n'
- && line_end_char == '\n')
- fprintf (out, "\n\\ No newline at end of file\n");
-}
-
-/* Output a line from TEXT up to LIMIT. Without -t, output verbatim.
- With -t, expand white space characters to spaces, and if FLAG_FORMAT
- is nonzero, output it with argument LINE_FLAG after every
- internal carriage return, so that tab stops continue to line up. */
-
-void
-output_1_line (text, limit, flag_format, line_flag)
- const char *text, *limit, *flag_format, *line_flag;
-{
- if (!tab_expand_flag)
- fwrite (text, sizeof (char), limit - text, outfile);
- else
- {
- register FILE *out = outfile;
- register char c;
- register const char *t = text;
- register unsigned column = 0;
-
- while (t < limit)
- switch ((c = *t++))
- {
- case '\t':
- {
- unsigned spaces = TAB_WIDTH - column % TAB_WIDTH;
- column += spaces;
- do
- putc (' ', out);
- while (--spaces);
- }
- break;
-
- case '\r':
- putc (c, out);
- if (flag_format && t < limit && *t != '\n')
- fprintf (out, flag_format, line_flag);
- column = 0;
- break;
-
- case '\b':
- if (column == 0)
- continue;
- column--;
- putc (c, out);
- break;
-
- default:
- if (textchar[(unsigned char) c])
- column++;
- /* fall into */
- case '\f':
- case '\v':
- putc (c, out);
- break;
- }
- }
-}
-
-int
-change_letter (inserts, deletes)
- int inserts, deletes;
-{
- if (!inserts)
- return 'd';
- else if (!deletes)
- return 'a';
- else
- return 'c';
-}
-
-/* Translate an internal line number (an index into diff's table of lines)
- into an actual line number in the input file.
- The internal line number is LNUM. FILE points to the data on the file.
-
- Internal line numbers count from 0 starting after the prefix.
- Actual line numbers count from 1 within the entire file. */
-
-int
-translate_line_number (file, lnum)
- struct file_data *file;
- int lnum;
-{
- return lnum + file->prefix_lines + 1;
-}
-
-void
-translate_range (file, a, b, aptr, bptr)
- struct file_data *file;
- int a, b;
- int *aptr, *bptr;
-{
- *aptr = translate_line_number (file, a - 1) + 1;
- *bptr = translate_line_number (file, b + 1) - 1;
-}
-
-/* Print a pair of line numbers with SEPCHAR, translated for file FILE.
- If the two numbers are identical, print just one number.
-
- Args A and B are internal line numbers.
- We print the translated (real) line numbers. */
-
-void
-print_number_range (sepchar, file, a, b)
- char sepchar;
- struct file_data *file;
- int a, b;
-{
- int trans_a, trans_b;
- translate_range (file, a, b, &trans_a, &trans_b);
-
- /* Note: we can have B < A in the case of a range of no lines.
- In this case, we should print the line number before the range,
- which is B. */
- if (trans_b > trans_a)
- fprintf (outfile, "%d%c%d", trans_a, sepchar, trans_b);
- else
- fprintf (outfile, "%d", trans_b);
-}
-
-/* Look at a hunk of edit script and report the range of lines in each file
- that it applies to. HUNK is the start of the hunk, which is a chain
- of `struct change'. The first and last line numbers of file 0 are stored in
- *FIRST0 and *LAST0, and likewise for file 1 in *FIRST1 and *LAST1.
- Note that these are internal line numbers that count from 0.
-
- If no lines from file 0 are deleted, then FIRST0 is LAST0+1.
-
- Also set *DELETES nonzero if any lines of file 0 are deleted
- and set *INSERTS nonzero if any lines of file 1 are inserted.
- If only ignorable lines are inserted or deleted, both are
- set to 0. */
-
-void
-analyze_hunk (hunk, first0, last0, first1, last1, deletes, inserts)
- struct change *hunk;
- int *first0, *last0, *first1, *last1;
- int *deletes, *inserts;
-{
- int f0, l0, f1, l1, show_from, show_to;
- int i;
- int nontrivial = !(ignore_blank_lines_flag || ignore_regexp_list);
- struct change *next;
-
- show_from = show_to = 0;
-
- f0 = hunk->line0;
- f1 = hunk->line1;
-
- for (next = hunk; next; next = next->link)
- {
- l0 = next->line0 + next->deleted - 1;
- l1 = next->line1 + next->inserted - 1;
- show_from += next->deleted;
- show_to += next->inserted;
-
- for (i = next->line0; i <= l0 && ! nontrivial; i++)
- if (!ignore_blank_lines_flag || files[0].linbuf[i][0] != '\n')
- {
- struct regexp_list *r;
- const char *line = files[0].linbuf[i];
- int len = files[0].linbuf[i + 1] - line;
-
- for (r = ignore_regexp_list; r; r = r->next)
- if (0 <= re_search (&r->buf, line, len, 0, len, 0))
- break; /* Found a match. Ignore this line. */
- /* If we got all the way through the regexp list without
- finding a match, then it's nontrivial. */
- if (r == NULL)
- nontrivial = 1;
- }
-
- for (i = next->line1; i <= l1 && ! nontrivial; i++)
- if (!ignore_blank_lines_flag || files[1].linbuf[i][0] != '\n')
- {
- struct regexp_list *r;
- const char *line = files[1].linbuf[i];
- int len = files[1].linbuf[i + 1] - line;
-
- for (r = ignore_regexp_list; r; r = r->next)
- if (0 <= re_search (&r->buf, line, len, 0, len, 0))
- break; /* Found a match. Ignore this line. */
- /* If we got all the way through the regexp list without
- finding a match, then it's nontrivial. */
- if (r == NULL)
- nontrivial = 1;
- }
- }
-
- *first0 = f0;
- *last0 = l0;
- *first1 = f1;
- *last1 = l1;
-
- /* If all inserted or deleted lines are ignorable,
- tell the caller to ignore this hunk. */
-
- if (!nontrivial)
- show_from = show_to = 0;
-
- *deletes = show_from;
- *inserts = show_to;
-}
-
-/* malloc a block of memory, with fatal error message if we can't do it. */
-
-VOID *
-xmalloc (size)
- unsigned size;
-{
- register VOID *value;
-
- if (size == 0)
- size = 1;
-
- value = (VOID *) malloc (size);
-
- if (!value)
- fatal ("virtual memory exhausted");
- return value;
-}
-
-/* realloc a block of memory, with fatal error message if we can't do it. */
-
-VOID *
-xrealloc (old, size)
- VOID *old;
- unsigned int size;
-{
- register VOID *value;
-
- if (size == 0)
- size = 1;
-
- value = (VOID *) realloc (old, size);
-
- if (!value)
- fatal ("virtual memory exhausted");
- return value;
-}
-
-/* Concatenate three strings, returning a newly malloc'd string. */
-
-char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- int len = strlen (s1) + strlen (s2) + strlen (s3);
- char *new = (char *) xmalloc (len + 1);
- strcpy (new, s1);
- strcat (new, s2);
- strcat (new, s3);
- return new;
-}
-
-void
-debug_script (sp)
- struct change *sp;
-{
- fflush (stdout);
- for (; sp; sp = sp->link)
- fprintf (stderr, "%3d %3d delete %d insert %d\n",
- sp->line0, sp->line1, sp->deleted, sp->inserted);
- fflush (stderr);
-}
-
-#if !HAVE_MEMCHR
-char *
-memchr (s, c, n)
- char *s;
- int c;
- size_t n;
-{
- unsigned char *p = (unsigned char *) s, *lim = p + n;
- for (; p < lim; p++)
- if (*p == c)
- return (char *) p;
- return 0;
-}
-#endif
diff --git a/gnu/usr.bin/diff/version.c b/gnu/usr.bin/diff/version.c
deleted file mode 100644
index cb9d3b9..0000000
--- a/gnu/usr.bin/diff/version.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Version number of GNU diff. */
-
-char *version_string = "2.3";
diff --git a/gnu/usr.bin/diff3/COPYING b/gnu/usr.bin/diff3/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/diff3/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/diff3/Makefile b/gnu/usr.bin/diff3/Makefile
deleted file mode 100644
index db54aa5..0000000
--- a/gnu/usr.bin/diff3/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-PROG= diff3
-SRCS= diff3.c getopt.c getopt1.c version.c
-CFLAGS+= -I$(.CURDIR)/../diff\
- -DDIRENT=1 -DHAVE_UNISTD_H=1 -DHAVE_DUP2=1 -DHAVE_MEMCHR=1\
- -DHAVE_STRERROR=1 -DHAVE_WAITPID=1 -DHAVE_FCNTL_H=1\
- -DHAVE_STRING_H=1 -DHAVE_SYS_WAIT_H=1 -DHAVE_TIME_H=1\
- -DHAVE_ST_BLKSIZE=1 -DDIFF_PROGRAM=\"/usr/bin/diff\"
-NOMAN= noman
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../diff
diff --git a/gnu/usr.bin/diff3/diff3.c b/gnu/usr.bin/diff3/diff3.c
deleted file mode 100644
index b9952fc..0000000
--- a/gnu/usr.bin/diff3/diff3.c
+++ /dev/null
@@ -1,1693 +0,0 @@
-/* Three way file comparison program (diff3) for Project GNU.
- Copyright (C) 1988, 1989, 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 by Randy Smith */
-
-#if __STDC__
-#define VOID void
-#else
-#define VOID char
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include "getopt.h"
-#include "system.h"
-
-/*
- * Internal data structures and macros for the diff3 program; includes
- * data structures for both diff3 diffs and normal diffs.
- */
-
-/* Different files within a three way diff. */
-#define FILE0 0
-#define FILE1 1
-#define FILE2 2
-
-/*
- * A three way diff is built from two two-way diffs; the file which
- * the two two-way diffs share is:
- */
-#define FILEC FILE2
-
-/*
- * Different files within a two way diff.
- * FC is the common file, FO the other file.
- */
-#define FO 0
-#define FC 1
-
-/* The ranges are indexed by */
-#define START 0
-#define END 1
-
-enum diff_type {
- ERROR, /* Should not be used */
- ADD, /* Two way diff add */
- CHANGE, /* Two way diff change */
- DELETE, /* Two way diff delete */
- DIFF_ALL, /* All three are different */
- DIFF_1ST, /* Only the first is different */
- DIFF_2ND, /* Only the second */
- DIFF_3RD /* Only the third */
-};
-
-/* Two way diff */
-struct diff_block {
- int ranges[2][2]; /* Ranges are inclusive */
- char **lines[2]; /* The actual lines (may contain nulls) */
- int *lengths[2]; /* Line lengths (including newlines, if any) */
- struct diff_block *next;
-};
-
-/* Three way diff */
-
-struct diff3_block {
- enum diff_type correspond; /* Type of diff */
- int ranges[3][2]; /* Ranges are inclusive */
- char **lines[3]; /* The actual lines (may contain nulls) */
- int *lengths[3]; /* Line lengths (including newlines, if any) */
- struct diff3_block *next;
-};
-
-/*
- * Access the ranges on a diff block.
- */
-#define D_LOWLINE(diff, filenum) \
- ((diff)->ranges[filenum][START])
-#define D_HIGHLINE(diff, filenum) \
- ((diff)->ranges[filenum][END])
-#define D_NUMLINES(diff, filenum) \
- (D_HIGHLINE (diff, filenum) - D_LOWLINE (diff, filenum) + 1)
-
-/*
- * Access the line numbers in a file in a diff by relative line
- * numbers (i.e. line number within the diff itself). Note that these
- * are lvalues and can be used for assignment.
- */
-#define D_RELNUM(diff, filenum, linenum) \
- ((diff)->lines[filenum][linenum])
-#define D_RELLEN(diff, filenum, linenum) \
- ((diff)->lengths[filenum][linenum])
-
-/*
- * And get at them directly, when that should be necessary.
- */
-#define D_LINEARRAY(diff, filenum) \
- ((diff)->lines[filenum])
-#define D_LENARRAY(diff, filenum) \
- ((diff)->lengths[filenum])
-
-/*
- * Next block.
- */
-#define D_NEXT(diff) ((diff)->next)
-
-/*
- * Access the type of a diff3 block.
- */
-#define D3_TYPE(diff) ((diff)->correspond)
-
-/*
- * Line mappings based on diffs. The first maps off the top of the
- * diff, the second off of the bottom.
- */
-#define D_HIGH_MAPLINE(diff, fromfile, tofile, lineno) \
- ((lineno) \
- - D_HIGHLINE ((diff), (fromfile)) \
- + D_HIGHLINE ((diff), (tofile)))
-
-#define D_LOW_MAPLINE(diff, fromfile, tofile, lineno) \
- ((lineno) \
- - D_LOWLINE ((diff), (fromfile)) \
- + D_LOWLINE ((diff), (tofile)))
-
-/*
- * General memory allocation function.
- */
-#define ALLOCATE(number, type) \
- (type *) xmalloc ((number) * sizeof (type))
-
-/* Options variables for flags set on command line. */
-
-/* If nonzero, treat all files as text files, never as binary. */
-static int always_text;
-
-/* If nonzero, write out an ed script instead of the standard diff3 format. */
-static int edscript;
-
-/* If nonzero, in the case of overlapping diffs (type DIFF_ALL),
- preserve the lines which would normally be deleted from
- file 1 with a special flagging mechanism. */
-static int flagging;
-
-/* Number of lines to keep in identical prefix and suffix. */
-static int horizon_lines = 10;
-
-/* If nonzero, do not output information for overlapping diffs. */
-static int simple_only;
-
-/* If nonzero, do not output information for non-overlapping diffs. */
-static int overlap_only;
-
-/* If nonzero, show information for DIFF_2ND diffs. */
-static int show_2nd;
-
-/* If nonzero, include `:wq' at the end of the script
- to write out the file being edited. */
-static int finalwrite;
-
-/* If nonzero, output a merged file. */
-static int merge;
-
-static char *argv0;
-
-/*
- * Forward function declarations.
- */
-static int myread ();
-static void fatal ();
-static void perror_with_exit ();
-static struct diff_block *process_diff ();
-static struct diff3_block *make_3way_diff ();
-static void output_diff3 ();
-static int output_diff3_edscript ();
-static int output_diff3_merge ();
-static void usage ();
-
-static struct diff3_block *using_to_diff3_block ();
-static int copy_stringlist ();
-static struct diff3_block *create_diff3_block ();
-static int compare_line_list ();
-
-static char *read_diff ();
-static enum diff_type process_diff_control ();
-static char *scan_diff_line ();
-
-static struct diff3_block *reverse_diff3_blocklist ();
-
-VOID *xmalloc ();
-static VOID *xrealloc ();
-
-static char diff_program[] = DIFF_PROGRAM;
-
-static struct option longopts[] =
-{
- {"text", 0, NULL, 'a'},
- {"show-all", 0, NULL, 'A'},
- {"ed", 0, NULL, 'e'},
- {"show-overlap", 0, NULL, 'E'},
- {"label", 1, NULL, 'L'},
- {"merge", 0, NULL, 'm'},
- {"overlap-only", 0, NULL, 'x'},
- {"easy-only", 0, NULL, '3'},
- {"version", 0, NULL, 'v'},
- {0, 0, 0, 0}
-};
-
-/*
- * Main program. Calls diff twice on two pairs of input files,
- * combines the two diffs, and outputs them.
- */
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- extern char *version_string;
- int c, i;
- int mapping[3];
- int rev_mapping[3];
- int incompat;
- int conflicts_found;
- struct diff_block *thread0, *thread1, *last_block;
- struct diff3_block *diff3;
- int tag_count = 0;
- char *tag_strings[3];
- extern char *optarg;
- char *commonname;
- char **file;
- struct stat statb;
-
- incompat = 0;
-
- argv0 = argv[0];
-
- while ((c = getopt_long (argc, argv, "aeimvx3AEXL:", longopts, (int *) 0))
- != EOF)
- {
- switch (c)
- {
- case 'a':
- always_text = 1;
- break;
- case 'A':
- show_2nd = 1;
- flagging = 1;
- incompat++;
- break;
- case 'x':
- overlap_only = 1;
- incompat++;
- break;
- case '3':
- simple_only = 1;
- incompat++;
- break;
- case 'i':
- finalwrite = 1;
- break;
- case 'm':
- merge = 1;
- break;
- case 'X':
- overlap_only = 1;
- /* Falls through */
- case 'E':
- flagging = 1;
- /* Falls through */
- case 'e':
- incompat++;
- break;
- case 'v':
- fprintf (stderr, "GNU diff3 version %s\n", version_string);
- break;
- case 'L':
- /* Handle up to three -L options. */
- if (tag_count < 3)
- {
- tag_strings[tag_count++] = optarg;
- break;
- }
- /* Falls through */
- default:
- usage ();
- /* NOTREACHED */
- }
- }
-
- edscript = incompat & ~merge; /* -AeExX3 without -m implies ed script. */
- show_2nd |= ~incompat & merge; /* -m without -AeExX3 implies -A. */
- flagging |= ~incompat & merge;
-
- if (incompat > 1 /* Ensure at most one of -AeExX3. */
- || finalwrite & merge /* -i -m would rewrite input file. */
- || (tag_count && ! flagging) /* -L requires one of -AEX. */
- || argc - optind != 3)
- usage ();
-
- file = &argv[optind];
-
- for (i = tag_count; i < 3; i++)
- tag_strings[i] = file[i];
-
- /* Always compare file1 to file2, even if file2 is "-".
- This is needed for -mAeExX3. Using the file0 as
- the common file would produce wrong results, because if the
- file0-file1 diffs didn't line up with the file0-file2 diffs
- (which is entirely possible since we don't use diff's -n option),
- diff3 might report phantom changes from file1 to file2. */
-
- if (strcmp (file[2], "-") == 0)
- {
- /* Sigh. We've got standard input as the last arg. We can't
- call diff twice on stdin. Use the middle arg as the common
- file instead. */
- if (strcmp (file[0], "-") == 0 || strcmp (file[1], "-") == 0)
- fatal ("`-' specified for more than one input file");
- mapping[0] = 0;
- mapping[1] = 2;
- mapping[2] = 1;
- }
- else
- {
- /* Normal, what you'd expect */
- mapping[0] = 0;
- mapping[1] = 1;
- mapping[2] = 2;
- }
-
- for (i = 0; i < 3; i++)
- rev_mapping[mapping[i]] = i;
-
- for (i = 0; i < 3; i++)
- if (strcmp (file[i], "-") != 0)
- if (stat (file[i], &statb) < 0)
- perror_with_exit (file[i]);
- else if (S_ISDIR(statb.st_mode))
- {
- fprintf (stderr, "%s: %s: Is a directory\n", argv0, file[i]);
- exit (2);
- }
-
-
- commonname = file[rev_mapping[FILEC]];
- thread1 = process_diff (file[rev_mapping[FILE1]], commonname, &last_block);
- if (thread1)
- for (i = 0; i < 2; i++)
- {
- horizon_lines = max (horizon_lines, D_NUMLINES (thread1, i));
- horizon_lines = max (horizon_lines, D_NUMLINES (last_block, i));
- }
- thread0 = process_diff (file[rev_mapping[FILE0]], commonname, &last_block);
- diff3 = make_3way_diff (thread0, thread1);
- if (edscript)
- conflicts_found
- = output_diff3_edscript (stdout, diff3, mapping, rev_mapping,
- tag_strings[0], tag_strings[1], tag_strings[2]);
- else if (merge)
- {
- if (! freopen (file[rev_mapping[FILE0]], "r", stdin))
- perror_with_exit (file[rev_mapping[FILE0]]);
- conflicts_found
- = output_diff3_merge (stdin, stdout, diff3, mapping, rev_mapping,
- tag_strings[0], tag_strings[1], tag_strings[2]);
- if (ferror (stdin))
- fatal ("read error");
- }
- else
- {
- output_diff3 (stdout, diff3, mapping, rev_mapping);
- conflicts_found = 0;
- }
-
- if (ferror (stdout) || fclose (stdout) != 0)
- fatal ("write error");
- exit (conflicts_found);
- return conflicts_found;
-}
-
-/*
- * Explain, patiently and kindly, how to use this program. Then exit.
- */
-static void
-usage ()
-{
- fprintf (stderr, "\
-Usage: %s [options] my-file older-file your-file\n\
-Options:\n\
- [-exAEX3v] [-i|-m] [-L label1 [-L label2 [-L label3]]] [--text] [--ed]\n\
- [--merge] [--show-all] [--show-overlap] [--overlap-only] [--easy-only]\n\
- [--label=label1 [--label=label2 [--label=label3]]] [--version]\n\
- Only one of [exAEX3] is allowed\n", argv0);
- exit (2);
-}
-
-/*
- * Routines that combine the two diffs together into one. The
- * algorithm used follows:
- *
- * File2 is shared in common between the two diffs.
- * Diff02 is the diff between 0 and 2.
- * Diff12 is the diff between 1 and 2.
- *
- * 1) Find the range for the first block in File2.
- * a) Take the lowest of the two ranges (in File2) in the two
- * current blocks (one from each diff) as being the low
- * water mark. Assign the upper end of this block as
- * being the high water mark and move the current block up
- * one. Mark the block just moved over as to be used.
- * b) Check the next block in the diff that the high water
- * mark is *not* from.
- *
- * *If* the high water mark is above
- * the low end of the range in that block,
- *
- * mark that block as to be used and move the current
- * block up. Set the high water mark to the max of
- * the high end of this block and the current. Repeat b.
- *
- * 2) Find the corresponding ranges in File0 (from the blocks
- * in diff02; line per line outside of diffs) and in File1.
- * Create a diff3_block, reserving space as indicated by the ranges.
- *
- * 3) Copy all of the pointers for file2 in. At least for now,
- * do bcmp's between corresponding strings in the two diffs.
- *
- * 4) Copy all of the pointers for file0 and 1 in. Get what you
- * need from file2 (when there isn't a diff block, it's
- * identical to file2 within the range between diff blocks).
- *
- * 5) If the diff blocks you used came from only one of the two
- * strings of diffs, then that file (i.e. the one other than
- * the common file in that diff) is the odd person out. If you used
- * diff blocks from both sets, check to see if files 0 and 1 match:
- *
- * Same number of lines? If so, do a set of bcmp's (if a
- * bcmp matches; copy the pointer over; it'll be easier later
- * if you have to do any compares). If they match, 0 & 1 are
- * the same. If not, all three different.
- *
- * Then you do it again, until you run out of blocks.
- *
- */
-
-/*
- * This routine makes a three way diff (chain of diff3_block's) from two
- * two way diffs (chains of diff_block's). It is assumed that each of
- * the two diffs passed are onto the same file (i.e. that each of the
- * diffs were made "to" the same file). The three way diff pointer
- * returned will have numbering FILE0--the other file in diff02,
- * FILE1--the other file in diff12, and FILEC--the common file.
- */
-static struct diff3_block *
-make_3way_diff (thread0, thread1)
- struct diff_block *thread0, *thread1;
-{
-/*
- * This routine works on the two diffs passed to it as threads.
- * Thread number 0 is diff02, thread number 1 is diff12. The USING
- * array is set to the base of the list of blocks to be used to
- * construct each block of the three way diff; if no blocks from a
- * particular thread are to be used, that element of the using array
- * is set to 0. The elements LAST_USING array are set to the last
- * elements on each of the using lists.
- *
- * The HIGH_WATER_MARK is set to the highest line number in the common file
- * described in any of the diffs in either of the USING lists. The
- * HIGH_WATER_THREAD names the thread. Similarly the BASE_WATER_MARK
- * and BASE_WATER_THREAD describe the lowest line number in the common file
- * described in any of the diffs in either of the USING lists. The
- * HIGH_WATER_DIFF is the diff from which the HIGH_WATER_MARK was
- * taken.
- *
- * The HIGH_WATER_DIFF should always be equal to LAST_USING
- * [HIGH_WATER_THREAD]. The OTHER_DIFF is the next diff to check for
- * higher water, and should always be equal to
- * CURRENT[HIGH_WATER_THREAD ^ 0x1]. The OTHER_THREAD is the thread
- * in which the OTHER_DIFF is, and hence should always be equal to
- * HIGH_WATER_THREAD ^ 0x1.
- *
- * The variable LAST_DIFF is kept set to the last diff block produced
- * by this routine, for line correspondence purposes between that diff
- * and the one currently being worked on. It is initialized to
- * ZERO_DIFF before any blocks have been created.
- */
-
- struct diff_block
- *using[2],
- *last_using[2],
- *current[2];
-
- int
- high_water_mark;
-
- int
- high_water_thread,
- base_water_thread,
- other_thread;
-
- struct diff_block
- *high_water_diff,
- *other_diff;
-
- struct diff3_block
- *result,
- *tmpblock,
- **result_end,
- *last_diff3;
-
- static struct diff3_block zero_diff3 = {
- ERROR,
- { {0, 0}, {0, 0}, {0, 0} },
- { (char **) 0, (char **) 0, (char **) 0 },
- { (int *) 0, (int *) 0, (int *) 0 },
- (struct diff3_block *) 0
- };
-
- /* Initialization */
- result = 0;
- result_end = &result;
- current[0] = thread0; current[1] = thread1;
- last_diff3 = &zero_diff3;
-
- /* Sniff up the threads until we reach the end */
-
- while (current[0] || current[1])
- {
- using[0] = using[1] = last_using[0] = last_using[1] =
- (struct diff_block *) 0;
-
- /* Setup low and high water threads, diffs, and marks. */
- if (!current[0])
- base_water_thread = 1;
- else if (!current[1])
- base_water_thread = 0;
- else
- base_water_thread =
- (D_LOWLINE (current[0], FC) > D_LOWLINE (current[1], FC));
-
- high_water_thread = base_water_thread;
-
- high_water_diff = current[high_water_thread];
-
-#if 0
- /* low and high waters start off same diff */
- base_water_mark = D_LOWLINE (high_water_diff, FC);
-#endif
-
- high_water_mark = D_HIGHLINE (high_water_diff, FC);
-
- /* Make the diff you just got info from into the using class */
- using[high_water_thread]
- = last_using[high_water_thread]
- = high_water_diff;
- current[high_water_thread] = high_water_diff->next;
- last_using[high_water_thread]->next
- = (struct diff_block *) 0;
-
- /* And mark the other diff */
- other_thread = high_water_thread ^ 0x1;
- other_diff = current[other_thread];
-
- /* Shuffle up the ladder, checking the other diff to see if it
- needs to be incorporated. */
- while (other_diff
- && D_LOWLINE (other_diff, FC) <= high_water_mark + 1)
- {
-
- /* Incorporate this diff into the using list. Note that
- this doesn't take it off the current list */
- if (using[other_thread])
- last_using[other_thread]->next = other_diff;
- else
- using[other_thread] = other_diff;
- last_using[other_thread] = other_diff;
-
- /* Take it off the current list. Note that this following
- code assumes that other_diff enters it equal to
- current[high_water_thread ^ 0x1] */
- current[other_thread]
- = current[other_thread]->next;
- other_diff->next
- = (struct diff_block *) 0;
-
- /* Set the high_water stuff
- If this comparison is equal, then this is the last pass
- through this loop; since diff blocks within a given
- thread cannot overlap, the high_water_mark will be
- *below* the range_start of either of the next diffs. */
-
- if (high_water_mark < D_HIGHLINE (other_diff, FC))
- {
- high_water_thread ^= 1;
- high_water_diff = other_diff;
- high_water_mark = D_HIGHLINE (other_diff, FC);
- }
-
- /* Set the other diff */
- other_thread = high_water_thread ^ 0x1;
- other_diff = current[other_thread];
- }
-
- /* The using lists contain a list of all of the blocks to be
- included in this diff3_block. Create it. */
-
- tmpblock = using_to_diff3_block (using, last_using,
- base_water_thread, high_water_thread,
- last_diff3);
-
- if (!tmpblock)
- fatal ("internal error: screwup in format of diff blocks");
-
- /* Put it on the list. */
- *result_end = tmpblock;
- result_end = &tmpblock->next;
-
- /* Set up corresponding lines correctly. */
- last_diff3 = tmpblock;
- }
- return result;
-}
-
-/*
- * using_to_diff3_block:
- * This routine takes two lists of blocks (from two separate diff
- * threads) and puts them together into one diff3 block.
- * It then returns a pointer to this diff3 block or 0 for failure.
- *
- * All arguments besides using are for the convenience of the routine;
- * they could be derived from the using array.
- * LAST_USING is a pair of pointers to the last blocks in the using
- * structure.
- * LOW_THREAD and HIGH_THREAD tell which threads contain the lowest
- * and highest line numbers for File0.
- * last_diff3 contains the last diff produced in the calling routine.
- * This is used for lines mappings which would still be identical to
- * the state that diff ended in.
- *
- * A distinction should be made in this routine between the two diffs
- * that are part of a normal two diff block, and the three diffs that
- * are part of a diff3_block.
- */
-static struct diff3_block *
-using_to_diff3_block (using, last_using, low_thread, high_thread, last_diff3)
- struct diff_block
- *using[2],
- *last_using[2];
- int low_thread, high_thread;
- struct diff3_block *last_diff3;
-{
- int low[2], high[2];
- struct diff3_block *result;
- struct diff_block *ptr;
- int d, i;
-
- /* Find the range in the common file. */
- int lowc = D_LOWLINE (using[low_thread], FC);
- int highc = D_HIGHLINE (last_using[high_thread], FC);
-
- /* Find the ranges in the other files.
- If using[d] is null, that means that the file to which that diff
- refers is equivalent to the common file over this range. */
-
- for (d = 0; d < 2; d++)
- if (using[d])
- {
- low[d] = D_LOW_MAPLINE (using[d], FC, FO, lowc);
- high[d] = D_HIGH_MAPLINE (last_using[d], FC, FO, highc);
- }
- else
- {
- low[d] = D_HIGH_MAPLINE (last_diff3, FILEC, FILE0 + d, lowc);
- high[d] = D_HIGH_MAPLINE (last_diff3, FILEC, FILE0 + d, highc);
- }
-
- /* Create a block with the appropriate sizes */
- result = create_diff3_block (low[0], high[0], low[1], high[1], lowc, highc);
-
- /* Copy information for the common file.
- Return with a zero if any of the compares failed. */
-
- for (d = 0; d < 2; d++)
- for (ptr = using[d]; ptr; ptr = D_NEXT (ptr))
- {
- int result_offset = D_LOWLINE (ptr, FC) - lowc;
-
- if (!copy_stringlist (D_LINEARRAY (ptr, FC),
- D_LENARRAY (ptr, FC),
- D_LINEARRAY (result, FILEC) + result_offset,
- D_LENARRAY (result, FILEC) + result_offset,
- D_NUMLINES (ptr, FC)))
- return 0;
- }
-
- /* Copy information for file d. First deal with anything that might be
- before the first diff. */
-
- for (d = 0; d < 2; d++)
- {
- struct diff_block *u = using[d];
- int lo = low[d], hi = high[d];
-
- for (i = 0;
- i + lo < (u ? D_LOWLINE (u, FO) : hi + 1);
- i++)
- {
- D_RELNUM (result, FILE0 + d, i) = D_RELNUM (result, FILEC, i);
- D_RELLEN (result, FILE0 + d, i) = D_RELLEN (result, FILEC, i);
- }
-
- for (ptr = u; ptr; ptr = D_NEXT (ptr))
- {
- int result_offset = D_LOWLINE (ptr, FO) - lo;
- int linec;
-
- if (!copy_stringlist (D_LINEARRAY (ptr, FO),
- D_LENARRAY (ptr, FO),
- D_LINEARRAY (result, FILE0 + d) + result_offset,
- D_LENARRAY (result, FILE0 + d) + result_offset,
- D_NUMLINES (ptr, FO)))
- return 0;
-
- /* Catch the lines between here and the next diff */
- linec = D_HIGHLINE (ptr, FC) + 1 - lowc;
- for (i = D_HIGHLINE (ptr, FO) + 1 - lo;
- i < (D_NEXT (ptr) ? D_LOWLINE (D_NEXT (ptr), FO) : hi + 1) - lo;
- i++)
- {
- D_RELNUM (result, FILE0 + d, i) = D_RELNUM (result, FILEC, linec);
- D_RELLEN (result, FILE0 + d, i) = D_RELLEN (result, FILEC, linec);
- linec++;
- }
- }
- }
-
- /* Set correspond */
- if (!using[0])
- D3_TYPE (result) = DIFF_2ND;
- else if (!using[1])
- D3_TYPE (result) = DIFF_1ST;
- else
- {
- int nl0 = D_NUMLINES (result, FILE0);
- int nl1 = D_NUMLINES (result, FILE1);
-
- if (nl0 != nl1
- || !compare_line_list (D_LINEARRAY (result, FILE0),
- D_LENARRAY (result, FILE0),
- D_LINEARRAY (result, FILE1),
- D_LENARRAY (result, FILE1),
- nl0))
- D3_TYPE (result) = DIFF_ALL;
- else
- D3_TYPE (result) = DIFF_3RD;
- }
-
- return result;
-}
-
-/*
- * This routine copies pointers from a list of strings to a different list
- * of strings. If a spot in the second list is already filled, it
- * makes sure that it is filled with the same string; if not it
- * returns 0, the copy incomplete.
- * Upon successful completion of the copy, it returns 1.
- */
-static int
-copy_stringlist (fromptrs, fromlengths, toptrs, tolengths, copynum)
- char *fromptrs[], *toptrs[];
- int *fromlengths, *tolengths;
- int copynum;
-{
- register char
- **f = fromptrs,
- **t = toptrs;
- register int
- *fl = fromlengths,
- *tl = tolengths;
-
- while (copynum--)
- {
- if (*t)
- { if (*fl != *tl || bcmp (*f, *t, *fl)) return 0; }
- else
- { *t = *f ; *tl = *fl; }
-
- t++; f++; tl++; fl++;
- }
- return 1;
-}
-
-/*
- * Create a diff3_block, with ranges as specified in the arguments.
- * Allocate the arrays for the various pointers (and zero them) based
- * on the arguments passed. Return the block as a result.
- */
-static struct diff3_block *
-create_diff3_block (low0, high0, low1, high1, low2, high2)
- register int low0, high0, low1, high1, low2, high2;
-{
- struct diff3_block *result = ALLOCATE (1, struct diff3_block);
- int numlines;
-
- D3_TYPE (result) = ERROR;
- D_NEXT (result) = 0;
-
- /* Assign ranges */
- D_LOWLINE (result, FILE0) = low0;
- D_HIGHLINE (result, FILE0) = high0;
- D_LOWLINE (result, FILE1) = low1;
- D_HIGHLINE (result, FILE1) = high1;
- D_LOWLINE (result, FILE2) = low2;
- D_HIGHLINE (result, FILE2) = high2;
-
- /* Allocate and zero space */
- numlines = D_NUMLINES (result, FILE0);
- if (numlines)
- {
- D_LINEARRAY (result, FILE0) = ALLOCATE (numlines, char *);
- D_LENARRAY (result, FILE0) = ALLOCATE (numlines, int);
- bzero (D_LINEARRAY (result, FILE0), (numlines * sizeof (char *)));
- bzero (D_LENARRAY (result, FILE0), (numlines * sizeof (int)));
- }
- else
- {
- D_LINEARRAY (result, FILE0) = (char **) 0;
- D_LENARRAY (result, FILE0) = (int *) 0;
- }
-
- numlines = D_NUMLINES (result, FILE1);
- if (numlines)
- {
- D_LINEARRAY (result, FILE1) = ALLOCATE (numlines, char *);
- D_LENARRAY (result, FILE1) = ALLOCATE (numlines, int);
- bzero (D_LINEARRAY (result, FILE1), (numlines * sizeof (char *)));
- bzero (D_LENARRAY (result, FILE1), (numlines * sizeof (int)));
- }
- else
- {
- D_LINEARRAY (result, FILE1) = (char **) 0;
- D_LENARRAY (result, FILE1) = (int *) 0;
- }
-
- numlines = D_NUMLINES (result, FILE2);
- if (numlines)
- {
- D_LINEARRAY (result, FILE2) = ALLOCATE (numlines, char *);
- D_LENARRAY (result, FILE2) = ALLOCATE (numlines, int);
- bzero (D_LINEARRAY (result, FILE2), (numlines * sizeof (char *)));
- bzero (D_LENARRAY (result, FILE2), (numlines * sizeof (int)));
- }
- else
- {
- D_LINEARRAY (result, FILE2) = (char **) 0;
- D_LENARRAY (result, FILE2) = (int *) 0;
- }
-
- /* Return */
- return result;
-}
-
-/*
- * Compare two lists of lines of text.
- * Return 1 if they are equivalent, 0 if not.
- */
-static int
-compare_line_list (list1, lengths1, list2, lengths2, nl)
- char *list1[], *list2[];
- int *lengths1, *lengths2;
- int nl;
-{
- char
- **l1 = list1,
- **l2 = list2;
- int
- *lgths1 = lengths1,
- *lgths2 = lengths2;
-
- while (nl--)
- if (!*l1 || !*l2 || *lgths1 != *lgths2++
- || bcmp (*l1++, *l2++, *lgths1++))
- return 0;
- return 1;
-}
-
-/*
- * Routines to input and parse two way diffs.
- */
-
-extern char **environ;
-
-#define DIFF_CHUNK_SIZE 10000
-
-static struct diff_block *
-process_diff (filea, fileb, last_block)
- char *filea, *fileb;
- struct diff_block **last_block;
-{
- char *diff_contents;
- char *diff_limit;
- char *scan_diff;
- enum diff_type dt;
- int i;
- struct diff_block *block_list, **block_list_end, *bptr;
-
- diff_limit = read_diff (filea, fileb, &diff_contents);
- scan_diff = diff_contents;
- block_list_end = &block_list;
-
- while (scan_diff < diff_limit)
- {
- bptr = ALLOCATE (1, struct diff_block);
- bptr->lines[0] = bptr->lines[1] = (char **) 0;
- bptr->lengths[0] = bptr->lengths[1] = (int *) 0;
-
- dt = process_diff_control (&scan_diff, bptr);
- if (dt == ERROR || *scan_diff != '\n')
- {
- fprintf (stderr, "%s: diff error: ", argv0);
- do
- {
- putc (*scan_diff, stderr);
- }
- while (*scan_diff++ != '\n');
- exit (2);
- }
- scan_diff++;
-
- /* Force appropriate ranges to be null, if necessary */
- switch (dt)
- {
- case ADD:
- bptr->ranges[0][0]++;
- break;
- case DELETE:
- bptr->ranges[1][0]++;
- break;
- case CHANGE:
- break;
- default:
- fatal ("internal error: invalid diff type in process_diff");
- break;
- }
-
- /* Allocate space for the pointers for the lines from filea, and
- parcel them out among these pointers */
- if (dt != ADD)
- {
- int numlines = D_NUMLINES (bptr, 0);
- bptr->lines[0] = ALLOCATE (numlines, char *);
- bptr->lengths[0] = ALLOCATE (numlines, int);
- for (i = 0; i < numlines; i++)
- scan_diff = scan_diff_line (scan_diff,
- &(bptr->lines[0][i]),
- &(bptr->lengths[0][i]),
- diff_limit,
- '<');
- }
-
- /* Get past the separator for changes */
- if (dt == CHANGE)
- {
- if (strncmp (scan_diff, "---\n", 4))
- fatal ("invalid diff format; invalid change separator");
- scan_diff += 4;
- }
-
- /* Allocate space for the pointers for the lines from fileb, and
- parcel them out among these pointers */
- if (dt != DELETE)
- {
- int numlines = D_NUMLINES (bptr, 1);
- bptr->lines[1] = ALLOCATE (numlines, char *);
- bptr->lengths[1] = ALLOCATE (numlines, int);
- for (i = 0; i < numlines; i++)
- scan_diff = scan_diff_line (scan_diff,
- &(bptr->lines[1][i]),
- &(bptr->lengths[1][i]),
- diff_limit,
- '>');
- }
-
- /* Place this block on the blocklist. */
- *block_list_end = bptr;
- block_list_end = &bptr->next;
- }
-
- *block_list_end = 0;
- *last_block = bptr;
- return block_list;
-}
-
-/*
- * This routine will parse a normal format diff control string. It
- * returns the type of the diff (ERROR if the format is bad). All of
- * the other important information is filled into to the structure
- * pointed to by db, and the string pointer (whose location is passed
- * to this routine) is updated to point beyond the end of the string
- * parsed. Note that only the ranges in the diff_block will be set by
- * this routine.
- *
- * If some specific pair of numbers has been reduced to a single
- * number, then both corresponding numbers in the diff block are set
- * to that number. In general these numbers are interpetted as ranges
- * inclusive, unless being used by the ADD or DELETE commands. It is
- * assumed that these will be special cased in a superior routine.
- */
-
-static enum diff_type
-process_diff_control (string, db)
- char **string;
- struct diff_block *db;
-{
- char *s = *string;
- int holdnum;
- enum diff_type type;
-
-/* These macros are defined here because they can use variables
- defined in this function. Don't try this at home kids, we're
- trained professionals!
-
- Also note that SKIPWHITE only recognizes tabs and spaces, and
- that READNUM can only read positive, integral numbers */
-
-#define SKIPWHITE(s) { while (*s == ' ' || *s == '\t') s++; }
-#define READNUM(s, num) \
- { if (!isdigit (*s)) return ERROR; holdnum = 0; \
- do { holdnum = (*s++ - '0' + holdnum * 10); } \
- while (isdigit (*s)); (num) = holdnum; }
-
- /* Read first set of digits */
- SKIPWHITE (s);
- READNUM (s, db->ranges[0][START]);
-
- /* Was that the only digit? */
- SKIPWHITE (s);
- if (*s == ',')
- {
- /* Get the next digit */
- s++;
- READNUM (s, db->ranges[0][END]);
- }
- else
- db->ranges[0][END] = db->ranges[0][START];
-
- /* Get the letter */
- SKIPWHITE (s);
- switch (*s)
- {
- case 'a':
- type = ADD;
- break;
- case 'c':
- type = CHANGE;
- break;
- case 'd':
- type = DELETE;
- break;
- default:
- return ERROR; /* Bad format */
- }
- s++; /* Past letter */
-
- /* Read second set of digits */
- SKIPWHITE (s);
- READNUM (s, db->ranges[1][START]);
-
- /* Was that the only digit? */
- SKIPWHITE (s);
- if (*s == ',')
- {
- /* Get the next digit */
- s++;
- READNUM (s, db->ranges[1][END]);
- SKIPWHITE (s); /* To move to end */
- }
- else
- db->ranges[1][END] = db->ranges[1][START];
-
- *string = s;
- return type;
-}
-
-static char *
-read_diff (filea, fileb, output_placement)
- char *filea, *fileb;
- char **output_placement;
-{
- char *argv[7];
- char horizon_arg[256];
- char **ap;
- int fds[2];
- char *diff_result;
- int current_chunk_size;
- int bytes;
- int total;
- int pid, w;
- int wstatus;
-
- ap = argv;
- *ap++ = diff_program;
- if (always_text)
- *ap++ = "-a";
- sprintf (horizon_arg, "--horizon-lines=%d", horizon_lines);
- *ap++ = horizon_arg;
- *ap++ = "--";
- *ap++ = filea;
- *ap++ = fileb;
- *ap = (char *) 0;
-
- if (pipe (fds) < 0)
- perror_with_exit ("pipe failed");
-
- pid = vfork ();
- if (pid == 0)
- {
- /* Child */
- close (fds[0]);
- if (fds[1] != fileno (stdout))
- {
- dup2 (fds[1], fileno (stdout));
- close (fds[1]);
- }
- execve (diff_program, argv, environ);
- /* Avoid stdio, because the parent process's buffers are inherited. */
- write (fileno (stderr), diff_program, strlen (diff_program));
- write (fileno (stderr), ": not found\n", 12);
- _exit (2);
- }
-
- if (pid == -1)
- perror_with_exit ("fork failed");
-
- close (fds[1]); /* Prevent erroneous lack of EOF */
- current_chunk_size = DIFF_CHUNK_SIZE;
- diff_result = (char *) xmalloc (current_chunk_size);
- total = 0;
- do {
- bytes = myread (fds[0],
- diff_result + total,
- current_chunk_size - total);
- total += bytes;
- if (total == current_chunk_size)
- diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2));
- } while (bytes);
-
- if (total != 0 && diff_result[total-1] != '\n')
- fatal ("invalid diff format; incomplete last line");
-
- *output_placement = diff_result;
-
- do
- if ((w = wait (&wstatus)) == -1)
- perror_with_exit ("wait failed");
- while (w != pid);
-
- if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
- fatal ("subsidiary diff failed");
-
- return diff_result + total;
-}
-
-
-/*
- * Scan a regular diff line (consisting of > or <, followed by a
- * space, followed by text (including nulls) up to a newline.
- *
- * This next routine began life as a macro and many parameters in it
- * are used as call-by-reference values.
- */
-static char *
-scan_diff_line (scan_ptr, set_start, set_length, limit, firstchar)
- char *scan_ptr, **set_start;
- int *set_length;
- char *limit;
- char firstchar;
-{
- char *line_ptr;
-
- if (!(scan_ptr[0] == (firstchar)
- && scan_ptr[1] == ' '))
- fatal ("invalid diff format; incorrect leading line chars");
-
- *set_start = line_ptr = scan_ptr + 2;
- while (*line_ptr++ != '\n')
- ;
-
- /* Include newline if the original line ended in a newline,
- or if an edit script is being generated.
- Copy any missing newline message to stderr if an edit script is being
- generated, because edit scripts cannot handle missing newlines.
- Return the beginning of the next line. */
- *set_length = line_ptr - *set_start;
- if (line_ptr < limit && *line_ptr == '\\')
- {
- if (edscript)
- fprintf (stderr, "%s:", argv0);
- else
- --*set_length;
- line_ptr++;
- do
- {
- if (edscript)
- putc (*line_ptr, stderr);
- }
- while (*line_ptr++ != '\n');
- }
-
- return line_ptr;
-}
-
-/*
- * This routine outputs a three way diff passed as a list of
- * diff3_block's.
- * The argument MAPPING is indexed by external file number (in the
- * argument list) and contains the internal file number (from the
- * diff passed). This is important because the user expects his
- * outputs in terms of the argument list number, and the diff passed
- * may have been done slightly differently (if the last argument
- * was "-", for example).
- * REV_MAPPING is the inverse of MAPPING.
- */
-static void
-output_diff3 (outputfile, diff, mapping, rev_mapping)
- FILE *outputfile;
- struct diff3_block *diff;
- int mapping[3], rev_mapping[3];
-{
- int i;
- int oddoneout;
- char *cp;
- struct diff3_block *ptr;
- int line;
- int length;
- int dontprint;
- static int skew_increment[3] = { 2, 3, 1 }; /* 0==>2==>1==>3 */
-
- for (ptr = diff; ptr; ptr = D_NEXT (ptr))
- {
- char x[2];
-
- switch (ptr->correspond)
- {
- case DIFF_ALL:
- x[0] = '\0';
- dontprint = 3; /* Print them all */
- oddoneout = 3; /* Nobody's odder than anyone else */
- break;
- case DIFF_1ST:
- case DIFF_2ND:
- case DIFF_3RD:
- oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
-
- x[0] = oddoneout + '1';
- x[1] = '\0';
- dontprint = oddoneout==0;
- break;
- default:
- fatal ("internal error: invalid diff type passed to output");
- }
- fprintf (outputfile, "====%s\n", x);
-
- /* Go 0, 2, 1 if the first and third outputs are equivalent. */
- for (i = 0; i < 3;
- i = (oddoneout == 1 ? skew_increment[i] : i + 1))
- {
- int realfile = mapping[i];
- int
- lowt = D_LOWLINE (ptr, realfile),
- hight = D_HIGHLINE (ptr, realfile);
-
- fprintf (outputfile, "%d:", i + 1);
- switch (lowt - hight)
- {
- case 1:
- fprintf (outputfile, "%da\n", lowt - 1);
- break;
- case 0:
- fprintf (outputfile, "%dc\n", lowt);
- break;
- default:
- fprintf (outputfile, "%d,%dc\n", lowt, hight);
- break;
- }
-
- if (i == dontprint) continue;
-
- for (line = 0; line < hight - lowt + 1; line++)
- {
- fprintf (outputfile, " ");
- cp = D_RELNUM (ptr, realfile, line);
- length = D_RELLEN (ptr, realfile, line);
- fwrite (cp, sizeof (char), length, outputfile);
- }
- if (line != 0 && cp[length - 1] != '\n')
- fprintf (outputfile, "\n\\ No newline at end of file\n");
- }
- }
-}
-
-
-/*
- * Output to OUTPUTFILE the lines of B taken from FILENUM.
- * Double any initial '.'s; yield nonzero if any initial '.'s were doubled.
- */
-static int
-dotlines (outputfile, b, filenum)
- FILE *outputfile;
- struct diff3_block *b;
- int filenum;
-{
- int i;
- int leading_dot = 0;
-
- for (i = 0;
- i < D_NUMLINES (b, filenum);
- i++)
- {
- char *line = D_RELNUM (b, filenum, i);
- if (line[0] == '.')
- {
- leading_dot = 1;
- fprintf (outputfile, ".");
- }
- fwrite (line, sizeof (char),
- D_RELLEN (b, filenum, i), outputfile);
- }
-
- return leading_dot;
-}
-
-/*
- * Output to OUTPUTFILE a '.' line. If LEADING_DOT is nonzero,
- * also output a command that removes initial '.'s
- * starting with line START and continuing for NUM lines.
- */
-static void
-undotlines (outputfile, leading_dot, start, num)
- FILE *outputfile;
- int leading_dot, start, num;
-{
- fprintf (outputfile, ".\n");
- if (leading_dot)
- if (num == 1)
- fprintf (outputfile, "%ds/^\\.//\n", start);
- else
- fprintf (outputfile, "%d,%ds/^\\.//\n", start, start + num - 1);
-}
-
-/*
- * This routine outputs a diff3 set of blocks as an ed script. This
- * script applies the changes between file's 2 & 3 to file 1. It
- * takes the precise format of the ed script to be output from global
- * variables set during options processing. Note that it does
- * destructive things to the set of diff3 blocks it is passed; it
- * reverses their order (this gets around the problems involved with
- * changing line numbers in an ed script).
- *
- * Note that this routine has the same problem of mapping as the last
- * one did; the variable MAPPING maps from file number according to
- * the argument list to file number according to the diff passed. All
- * files listed below are in terms of the argument list.
- * REV_MAPPING is the inverse of MAPPING.
- *
- * The arguments FILE0, FILE1 and FILE2 are the strings to print
- * as the names of the three files. These may be the actual names,
- * or may be the arguments specified with -L.
- *
- * Returns 1 if conflicts were found.
- */
-
-static int
-output_diff3_edscript (outputfile, diff, mapping, rev_mapping,
- file0, file1, file2)
- FILE *outputfile;
- struct diff3_block *diff;
- int mapping[3], rev_mapping[3];
- char *file0, *file1, *file2;
-{
- int leading_dot;
- int conflicts_found = 0, conflict;
- struct diff3_block *b;
-
- for (b = reverse_diff3_blocklist (diff); b; b = b->next)
- {
- /* Must do mapping correctly. */
- enum diff_type type
- = ((b->correspond == DIFF_ALL) ?
- DIFF_ALL :
- ((enum diff_type)
- (((int) DIFF_1ST)
- + rev_mapping[(int) b->correspond - (int) DIFF_1ST])));
-
- /* If we aren't supposed to do this output block, skip it. */
- switch (type)
- {
- default: continue;
- case DIFF_2ND: if (!show_2nd) continue; conflict = 1; break;
- case DIFF_3RD: if (overlap_only) continue; conflict = 0; break;
- case DIFF_ALL: if (simple_only) continue; conflict = flagging; break;
- }
-
- if (conflict)
- {
- conflicts_found = 1;
-
-
- /* Mark end of conflict. */
-
- fprintf (outputfile, "%da\n", D_HIGHLINE (b, mapping[FILE0]));
- leading_dot = 0;
- if (type == DIFF_ALL)
- {
- if (show_2nd)
- {
- /* Append lines from FILE1. */
- fprintf (outputfile, "||||||| %s\n", file1);
- leading_dot = dotlines (outputfile, b, mapping[FILE1]);
- }
- /* Append lines from FILE2. */
- fprintf (outputfile, "=======\n");
- leading_dot |= dotlines (outputfile, b, mapping[FILE2]);
- }
- fprintf (outputfile, ">>>>>>> %s\n", file2);
- undotlines (outputfile, leading_dot,
- D_HIGHLINE (b, mapping[FILE0]) + 2,
- (D_NUMLINES (b, mapping[FILE1])
- + D_NUMLINES (b, mapping[FILE2]) + 1));
-
-
- /* Mark start of conflict. */
-
- fprintf (outputfile, "%da\n<<<<<<< %s\n",
- D_LOWLINE (b, mapping[FILE0]) - 1,
- type == DIFF_ALL ? file0 : file1);
- leading_dot = 0;
- if (type == DIFF_2ND)
- {
- /* Prepend lines from FILE1. */
- leading_dot = dotlines (outputfile, b, mapping[FILE1]);
- fprintf (outputfile, "=======\n");
- }
- undotlines (outputfile, leading_dot,
- D_LOWLINE (b, mapping[FILE0]) + 1,
- D_NUMLINES (b, mapping[FILE1]));
- }
- else if (D_NUMLINES (b, mapping[FILE2]) == 0)
- /* Write out a delete */
- {
- if (D_NUMLINES (b, mapping[FILE0]) == 1)
- fprintf (outputfile, "%dd\n",
- D_LOWLINE (b, mapping[FILE0]));
- else
- fprintf (outputfile, "%d,%dd\n",
- D_LOWLINE (b, mapping[FILE0]),
- D_HIGHLINE (b, mapping[FILE0]));
- }
- else
- /* Write out an add or change */
- {
- switch (D_NUMLINES (b, mapping[FILE0]))
- {
- case 0:
- fprintf (outputfile, "%da\n",
- D_HIGHLINE (b, mapping[FILE0]));
- break;
- case 1:
- fprintf (outputfile, "%dc\n",
- D_HIGHLINE (b, mapping[FILE0]));
- break;
- default:
- fprintf (outputfile, "%d,%dc\n",
- D_LOWLINE (b, mapping[FILE0]),
- D_HIGHLINE (b, mapping[FILE0]));
- break;
- }
-
- undotlines (outputfile, dotlines (outputfile, b, mapping[FILE2]),
- D_LOWLINE (b, mapping[FILE0]),
- D_NUMLINES (b, mapping[FILE2]));
- }
- }
- if (finalwrite) fprintf (outputfile, "w\nq\n");
- return conflicts_found;
-}
-
-/*
- * Read from INFILE and output to OUTPUTFILE a set of diff3_ blocks DIFF
- * as a merged file. This acts like 'ed file0 <[output_diff3_edscript]',
- * except that it works even for binary data or incomplete lines.
- *
- * As before, MAPPING maps from arg list file number to diff file number,
- * REV_MAPPING is its inverse,
- * and FILE0, FILE1, and FILE2 are the names of the files.
- *
- * Returns 1 if conflicts were found.
- */
-
-static int
-output_diff3_merge (infile, outputfile, diff, mapping, rev_mapping,
- file0, file1, file2)
- FILE *infile, *outputfile;
- struct diff3_block *diff;
- int mapping[3], rev_mapping[3];
- char *file0, *file1, *file2;
-{
- int c, i;
- int conflicts_found = 0, conflict;
- struct diff3_block *b;
- int linesread = 0;
-
- for (b = diff; b; b = b->next)
- {
- /* Must do mapping correctly. */
- enum diff_type type
- = ((b->correspond == DIFF_ALL) ?
- DIFF_ALL :
- ((enum diff_type)
- (((int) DIFF_1ST)
- + rev_mapping[(int) b->correspond - (int) DIFF_1ST])));
- char *format_2nd = "<<<<<<< %s\n";
-
- /* If we aren't supposed to do this output block, skip it. */
- switch (type)
- {
- default: continue;
- case DIFF_2ND: if (!show_2nd) continue; conflict = 1; break;
- case DIFF_3RD: if (overlap_only) continue; conflict = 0; break;
- case DIFF_ALL: if (simple_only) continue; conflict = flagging;
- format_2nd = "||||||| %s\n";
- break;
- }
-
- /* Copy I lines from file 0. */
- i = D_LOWLINE (b, FILE0) - linesread - 1;
- linesread += i;
- while (0 <= --i)
- do
- {
- c = getc (infile);
- if (c == EOF)
- if (ferror (infile))
- perror_with_exit ("input file");
- else if (feof (infile))
- fatal ("input file shrank");
- putc (c, outputfile);
- }
- while (c != '\n');
-
- if (conflict)
- {
- conflicts_found = 1;
-
- if (type == DIFF_ALL)
- {
- /* Put in lines from FILE0 with bracket. */
- fprintf (outputfile, "<<<<<<< %s\n", file0);
- for (i = 0;
- i < D_NUMLINES (b, mapping[FILE0]);
- i++)
- fwrite (D_RELNUM (b, mapping[FILE0], i), sizeof (char),
- D_RELLEN (b, mapping[FILE0], i), outputfile);
- }
-
- if (show_2nd)
- {
- /* Put in lines from FILE1 with bracket. */
- fprintf (outputfile, format_2nd, file1);
- for (i = 0;
- i < D_NUMLINES (b, mapping[FILE1]);
- i++)
- fwrite (D_RELNUM (b, mapping[FILE1], i), sizeof (char),
- D_RELLEN (b, mapping[FILE1], i), outputfile);
- }
-
- fprintf (outputfile, "=======\n");
- }
-
- /* Put in lines from FILE2. */
- for (i = 0;
- i < D_NUMLINES (b, mapping[FILE2]);
- i++)
- fwrite (D_RELNUM (b, mapping[FILE2], i), sizeof (char),
- D_RELLEN (b, mapping[FILE2], i), outputfile);
-
- if (conflict)
- fprintf (outputfile, ">>>>>>> %s\n", file2);
-
- /* Skip I lines in file 0. */
- i = D_NUMLINES (b, FILE0);
- linesread += i;
- while (0 <= --i)
- while ((c = getc (infile)) != '\n')
- if (c == EOF)
- if (ferror (infile))
- perror_with_exit ("input file");
- else if (feof (infile))
- {
- if (i || b->next)
- fatal ("input file shrank");
- return conflicts_found;
- }
- }
- /* Copy rest of common file. */
- while ((c = getc (infile)) != EOF || !(ferror (infile) | feof (infile)))
- putc (c, outputfile);
- return conflicts_found;
-}
-
-/*
- * Reverse the order of the list of diff3 blocks.
- */
-static struct diff3_block *
-reverse_diff3_blocklist (diff)
- struct diff3_block *diff;
-{
- register struct diff3_block *tmp, *next, *prev;
-
- for (tmp = diff, prev = (struct diff3_block *) 0;
- tmp; tmp = next)
- {
- next = tmp->next;
- tmp->next = prev;
- prev = tmp;
- }
-
- return prev;
-}
-
-static int
-myread (fd, ptr, size)
- int fd, size;
- char *ptr;
-{
- int result = read (fd, ptr, size);
- if (result < 0)
- perror_with_exit ("read failed");
- return result;
-}
-
-VOID *
-xmalloc (size)
- unsigned size;
-{
- VOID *result = (VOID *) malloc (size ? size : 1);
- if (!result)
- fatal ("virtual memory exhausted");
- return result;
-}
-
-static VOID *
-xrealloc (ptr, size)
- VOID *ptr;
- unsigned size;
-{
- VOID *result = (VOID *) realloc (ptr, size ? size : 1);
- if (!result)
- fatal ("virtual memory exhausted");
- return result;
-}
-
-static void
-fatal (string)
- char *string;
-{
- fprintf (stderr, "%s: %s\n", argv0, string);
- exit (2);
-}
-
-static void
-perror_with_exit (string)
- char *string;
-{
- int e = errno;
- fprintf (stderr, "%s: ", argv0);
- errno = e;
- perror (string);
- exit (2);
-}
diff --git a/gnu/usr.bin/diff3/getopt.c b/gnu/usr.bin/diff3/getopt.c
deleted file mode 100644
index a59a013..0000000
--- a/gnu/usr.bin/diff3/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/diff3/getopt.h b/gnu/usr.bin/diff3/getopt.h
deleted file mode 100644
index 45541f5..0000000
--- a/gnu/usr.bin/diff3/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/diff3/getopt1.c b/gnu/usr.bin/diff3/getopt1.c
deleted file mode 100644
index a32615c..0000000
--- a/gnu/usr.bin/diff3/getopt1.c
+++ /dev/null
@@ -1,176 +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
-#include "config.h"
-#endif
-
-#include "getopt.h"
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#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/diff3/system.h b/gnu/usr.bin/diff3/system.h
deleted file mode 100644
index b17d39a..0000000
--- a/gnu/usr.bin/diff3/system.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* System dependent declarations.
- Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute 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 DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
-#endif
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
-#endif
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if HAVE_TIME_H
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#include <sys/file.h>
-#endif
-
-#if !HAVE_DUP2
-#define dup2(f,t) (close (t), fcntl (f,F_DUPFD,t))
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-
-#if HAVE_SYS_WAIT_H
-#ifndef _POSIX_VERSION
-/* Prevent the NeXT prototype using union wait from causing problems. */
-#define wait system_wait
-#endif
-#include <sys/wait.h>
-#ifndef _POSIX_VERSION
-#undef wait
-#endif
-#endif /* HAVE_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) & 255) == 0)
-#endif
-
-#if HAVE_ST_BLKSIZE
-#define STAT_BLOCKSIZE(s) (s).st_blksize
-#else
-#define STAT_BLOCKSIZE(s) (S_ISREG ((s).st_mode) ? 8192 : 4096)
-#endif
-
-#if DIRENT || defined (_POSIX_VERSION)
-#include <dirent.h>
-#ifdef direct
-#undef direct
-#endif
-#define direct dirent
-#else /* ! (DIRENT || defined (_POSIX_VERSION)) */
-#if SYSNDIR
-#include <sys/ndir.h>
-#else
-#if SYSDIR
-#include <sys/dir.h>
-#else
-#include <ndir.h>
-#endif
-#endif
-#endif /* ! (DIRENT || defined (_POSIX_VERSION)) */
-
-#if HAVE_VFORK_H
-#include <vfork.h>
-#endif
-
-#if HAVE_STRING_H || STDC_HEADERS
-#include <string.h>
-#ifndef index
-#define index strchr
-#endif
-#ifndef rindex
-#define rindex strrchr
-#endif
-#ifndef bcopy
-#define bcopy(s,d,n) memcpy (d,s,n)
-#endif
-#ifndef bcmp
-#define bcmp(s1,s2,n) memcmp (s1,s2,n)
-#endif
-#ifndef bzero
-#define bzero(s,n) memset (s,0,n)
-#endif
-#else
-#include <strings.h>
-#endif
-#if !HAVE_MEMCHR && !STDC_HEADERS
-char *memchr ();
-#endif
-
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <limits.h>
-#else
-char *getenv ();
-char *malloc ();
-char *realloc ();
-#if __STDC__ || __GNUC__
-#include "limits.h"
-#else
-#define INT_MAX 2147483647
-#define CHAR_BIT 8
-#endif
-#endif
-
-#include <errno.h>
-#if !STDC_HEADERS
-extern int errno;
-#endif
-
-#ifdef TRUE
-#undef TRUE
-#endif
-#ifdef FALSE
-#undef FALSE
-#endif
-#define TRUE 1
-#define FALSE 0
-
-#if !__STDC__
-#define volatile
-#endif
-
-#define min(a,b) ((a) <= (b) ? (a) : (b))
-#define max(a,b) ((a) >= (b) ? (a) : (b))
diff --git a/gnu/usr.bin/diff3/version.c b/gnu/usr.bin/diff3/version.c
deleted file mode 100644
index cb9d3b9..0000000
--- a/gnu/usr.bin/diff3/version.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Version number of GNU diff. */
-
-char *version_string = "2.3";
diff --git a/gnu/usr.bin/gdb/COPYING b/gnu/usr.bin/gdb/COPYING
deleted file mode 100644
index 9a17037..0000000
--- a/gnu/usr.bin/gdb/COPYING
+++ /dev/null
@@ -1,249 +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/gdb/ChangeLog b/gnu/usr.bin/gdb/ChangeLog
deleted file mode 100644
index 1f2342b..0000000
--- a/gnu/usr.bin/gdb/ChangeLog
+++ /dev/null
@@ -1,4887 +0,0 @@
-Thu Feb 8 01:11:55 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * GDB 3.5 released.
-
- * version.c: Change version number to 3.5
-
-Tue Feb 6 15:58:06 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * m-hp9k320.h: define ATTACH_DETACH.
- hp9k320-dep.c [ATTACH_DETACH]: New code.
-
-Thu Feb 1 17:43:00 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * valprint.c (is_nan, val_print): Use char * not void *.
-
- * symmisc.c (print_symbol): Print newline after label.
-
-Tue Jan 30 15:35:52 1990 Jim Kingdon (kingdon at albert.ai.mit.edu)
-
- * Makefile.dist (READLINE): Add {readline,history}.texinfo.
-
- * m-merlin.h: Put in clarifying comments about SHELL_FILE.
- config.gdb (merlin): Explain about /usr/local/lib/gdb-sh.
-
-Sat Jan 27 02:30:27 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * version.c: Change version number to 3.5alpha.1.
-
- * dbxread.c (process_one_symbol): Compare context_stack_depth
- with !VARIABLES_INSIDE_BLOCK, not VARIABLES_INSIDE_BLOCK.
-
-Fri Jan 26 01:21:51 1990 Jim Kingdon (kingdon at mole.ai.mit.edu)
-
- * main.c [ALIGN_STACK_ON_STARTUP]: New code.
- m-i386.h: Define ALIGN_STACK_ON_STARTUP.
-
- * m-merlin.h (NO_SIGINTERRUPT, SHELL_FILE): Define.
-
- * umax-dep.c (exec_file_command): Add commas to call to
- read_section_hdr.
-
-Tue Jan 23 15:49:47 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * dbxread.c (define_symbol): Deal with deftype 'X'.
-
- * convex-dep.c (wait): Make it pid_t.
-
- * convex-dep.c (comm_registers_info): accept decimal comm register
- specification, as "i comm 32768".
-
- * dbxread.c (process_one_symbol): Make VARIABLES_INSIDE_BLOCK
- macro say by itself where variables are. Pass it desc.
- m-convex.h (VARIABLES_INSIDE_BLOCK): Nonzero for native compiler.
-
- * m-convex.h (SET_STACK_LIMIT_HUGE): Define.
- (IGNORE_SYMBOL): Take out #ifdef N_MONPT and put in 0xc4.
-
-Fri Jan 19 20:04:15 1990 Jim Kingdon (kingdon at albert.ai.mit.edu)
-
- * printcmd.c (print_frame_args): Always set highest_offset to
- current_offset when former is -1.
-
- * dbxread.c (read_struct_type): Print nice error message
- when encountering multiple inheritance.
-
-Thu Jan 18 13:43:30 1990 Jim Kingdon (kingdon at mole.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab): Always treat N_FN as a potential
- source for a x.o or -lx symbol, ignoring OFILE_FN_FLAGGED.
-
- * printcmd.c (print_frame_args): Cast -1 to (CORE_ADDR).
-
- * hp300bsd-dep.c (_initialize_hp300_dep): Get kernel_u_addr.
- m-hp300bsd.h (KERNEL_U_ADDR): Use kernel_u_addr.
-
- * infcmd.c (run_command): #if 0 out call to
- breakpoint_clear_ignore_counts.
-
-Thu Jan 11 12:58:12 1990 Jim Kingdon (kingdon at mole)
-
- * printcmd.c (print_frame_args) [STRUCT_ARG_SYM_GARBAGE]:
- Try looking up name of var before giving up & printing '?'.
-
-Wed Jan 10 14:00:14 1990 Jim Kingdon (kingdon at pogo)
-
- * many files: Move stdio.h before param.h.
-
- * sun3-dep.c (store_inferior_registers): Only try to write FP
- regs #ifdef FP0_REGNUM.
-
-Mon Jan 8 17:56:15 1990 Jim Kingdon (kingdon at pogo)
-
- * symtab.c: #if 0 out "info methods" code.
-
-Sat Jan 6 12:33:04 1990 Jim Kingdon (kingdon at pogo)
-
- * dbxread.c (read_struct_type): Set TYPE_NFN_FIELDS_TOTAL
- from all baseclasses; remove vestigial variable baseclass.
-
- * findvar.c (read_var_value): Check REG_STRUCT_HAS_ADDR.
- printcmd.c (print_frame_args): Check STRUCT_ARG_SYM_GARBAGE.
- m-sparc.h: Define REG_STRUCT_HAS_ADDR and STRUCT_ARG_SYM_GARBAGE.
-
- * blockframe.c (get_frame_block): Subtract one from pc if not
- innermost frame.
-
-Fri Dec 29 15:26:33 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * printcmd.c (print_frame_args): check highest_offset != -1, not i.
-
-Thu Dec 28 16:21:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * valops.c (value_struct_elt): Clean up error msg.
-
- * breakpoint.c (describe_other_breakpoints):
- Delete extra space before "also set at" and add period at end.
-
-Tue Dec 19 10:28:42 1989 Jim Kingdon (kingdon at pogo)
-
- * source.c (print_source_lines): Tell user which line number
- was out of range when printing error message.
-
-Sun Dec 17 14:14:09 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * blockframe.c (find_pc_partial_function): Use
- BLOCK_START (SYMBOL_BLOCK_VALUE (f)) instead of
- SYMBOL_VALUE (f) to get start of function.
-
- * dbxread.c: Make xxmalloc just a #define for xmalloc.
-
-Thu Dec 14 16:13:16 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * m68k-opcode.h (fseq & following fp instructions):
- Change @ to $.
-
-Fri Dec 8 19:06:44 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * breakpoint.c (breakpoint_clear_ignore_counts): New function.
- infcmd.c (run_command): Call it.
-
-Wed Dec 6 15:03:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * valprint.c: Change it so "array-max 0" means there is
- no limit.
-
- * expread.y (yylex): Change error message "invalid token in
- expression" to "invalid character '%c' in expression".
-
-Mon Dec 4 16:12:54 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * blockframe.c (find_pc_partial_function): Always return 1
- for success, 0 for failure, and set *NAME and *ADDRESS to
- match the return value.
-
- * dbxread.c (symbol_file_command): Use perror_with_name on
- error from stat.
- (psymtab_to_symtab, add_file_command),
- core.c (validate_files), source.c (find_source_lines),
- default-dep.c (exec_file_command): Check for errors from stat,
- fstat, and myread.
-
-Fri Dec 1 05:16:42 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * valops.c (check_field): When following pointers, just get
- their types; don't call value_ind.
-
-Thu Nov 30 14:45:29 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * config.gdb (pyr): New machine.
- core.c [REG_STACK_SEGMENT]: New code.
- dbxread.c (process_one_symbol): Cast return from copy_pending
- to long before casting to enum namespace.
- infrun.c: Split registers_info into DO_REGISTERS_INFO
- and registers_info.
- m-pyr.h, pyr-{dep.c,opcode.h,pinsn.c}: New files.
-
- * hp300bsd-dep.c: Stay in sync with default-dep.c.
-
- * m-hp300bsd.h (IN_SIGTRAMP): Define.
-
-Mon Nov 27 23:48:21 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * m-sparc.h (EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE):
- Return floating point values in %f0.
-
-Tue Nov 21 00:34:46 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c (read_type): #if 0 out code which skips to
- comma following x-ref.
-
-Sat Nov 18 20:10:54 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * valprint.c (val_print): Undo changes of Nov 11 & 16.
- (print_string): Add parameter force_ellipses.
- (val_print): Pass force_ellipses true when we stop fetching string
- before we get to the end, else pass false.
-
-Thu Nov 16 11:59:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * infrun.c (restore_inferior_status): Don't try to restore
- selected frame if the inferior no longer exists.
-
- * valprint.c (val_print): Rewrite string printing code not to
- call print_string.
-
- * Makefile.dist (clean): Remove xgdb and xgdb.o.
-
-Tue Nov 14 12:41:47 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * Makefile.dist (XGDB, bindir, xbindir, install, all): New stuff.
-
-Sat Nov 11 15:29:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * valprint.c (val_print): chars_to_get: New variable.
-
-Thu Nov 9 12:31:47 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * main.c (main): Process "-help" as a switch that doesn't
- take an argument.
-
-Wed Nov 8 13:07:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * Makefile.dist (gdb.tar.Z): Add "else true".
-
-Tue Nov 7 12:25:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * infrun.c (restore_inferior_status): Don't dereference fid if NULL.
-
- * config.gdb (sun3, sun4): Accept "sun3" and "sun4".
-
-Mon Nov 6 09:49:23 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * Makefile.dist (Makefile): Move comments after commands.
-
- * *-dep.c [READ_COFF_SYMTAB]: Pass optional header size to
- read_section_hdr().
-
- * inflow.c: Include <fcntl.h> regardless of USG.
-
- * coffread.c (read_section_hdr): Add optional_header_size.
- (symbol_file_command): Pass optional header size to
- read_section_hdr().
- (read_coff_symtab): Initialize filestring.
-
- * version.c: Change version to 3.4.xxx.
-
- * GDB 3.4 released.
-
-Sun Nov 5 11:39:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * version.c: Change version to 3.4.
-
- * symtab.c (decode_line_1): Only skip past "struct" if it
- is there.
-
- * valops.c (value_ind), eval.c (evaluate_subexp, case UNOP_IND):
- Have "*" <int-valued-exp> return an int, not a LONGEST.
-
- * utils.c (fprintf_filtered): Pass arg{4,5,6} to sprintf.
-
- * printcmd.c (x_command): Use variable itself rather
- than treating it as a pointer only if it is a function.
- (See comment "this makes x/i main work").
-
- * coffread.c (symbol_file_command): Use error for
- "%s does not have a symbol-table.\n".
-
-Wed Nov 1 19:56:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c [BELIEVE_PCC_PROMOTION_TYPE]: New code.
- m-sparc.h: Define BELIEVE_PCC_PROMOTION_TYPE.
-
-Thu Oct 26 12:45:00 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * infrun.c: Include <sys/dir.h>.
-
- * dbxread.c (read_dbx_symtab, case N_LSYM, case 'T'):
- Check for enum types and put constants in psymtab.
-
-Mon Oct 23 15:02:25 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c (define_symbol, read_dbx_symtab): Handle enum
- constants (e.g. "b:c=e6,0").
-
-Thu Oct 19 14:57:26 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * stack.c (frame_info): Use FRAME_ARGS_ADDRESS_CORRECT
- m-vax.h (FRAME_ARGS_ADDRESS_CORRECT): New macro.
- (FRAME_ARGS_ADDRESS): Restore old meaning.
-
- * frame.h (Frame_unknown): New macro.
- stack.c (frame_info): Check for Frame_unknown return from
- FRAME_ARGS_ADDRESS.
- m-vax.h (FRAME_ARGS_ADDRESS): Sometimes return Frame_unknown.
-
- * utils.c (fatal_dump_core): Add "internal error" to message.
-
- * infrun.c (IN_SIGTRAMP): New macro.
- (wait_for_inferior): Use IN_SIGTRAMP.
- m-vax.h (IN_SIGTRAMP): New macro.
-
-Wed Oct 18 15:09:22 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * config.gdb, Makefile.dist: Shorten m-i386-sv32.h.
-
- * coffread.c (symbol_file_command): Pass 0 to select_source_symtab.
-
-Tue Oct 17 12:24:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * i386-dep.c (i386_frame_num_args): Take function from m-i386.h
- file. Check for pfi null.
- m-i386.h (FRAME_NUM_ARGS): Use i386_frame_num_args.
-
- * infrun.c (wait_for_inferior): set stop_func_name to 0
- before calling find_pc_partial_function.
-
-Thu Oct 12 01:08:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * breakpoint.c (_initialize_breakpoint): Add "disa".
-
- * Makefile.dist: Add GLOBAL_CFLAGS and pass to readline.
-
- * config.gdb (various): "$machine =" -> "machine =".
-
-Wed Oct 11 11:54:31 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * inflow.c (try_writing_regs): #if 0 out this function.
-
- * main.c (main): Add "-help" option.
-
- * dbxread.c (read_dbx_symtab): Merge code for N_FUN with
- N_STSYM, etc.
-
-Mon Oct 9 14:21:55 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * inflow.c (try_writing_regs_command): Don't write past end
- of struct user.
-
- * dbxread.c (read_struct_type): #if 0 out code which checks for
- bitpos and bitsize 0.
-
- * config.gdb: Accept sequent-i386 (not seq386).
- (symmetry): Set depfile and paramfile.
-
- * m-convex.h (IGNORE_SYMBOL): Check for N_MONPT if defined.
-
-Thu Oct 5 10:14:26 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * default-dep.c (read_inferior_memory): Put #if 0'd out comment
- within /* */.
-
-Wed Oct 4 18:44:41 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * config.gdb: Change /dev/null to m-i386.h for various
- 386 machine "opcodefile" entries.
-
- * config.gdb: Accept seq386 for sequent symmetry.
-
-Mon Oct 2 09:59:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * hp300bsd-dep.c: Fix copyright notice.
-
-Sun Oct 1 16:25:30 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * Makefile.dist (DEPFILES): Add isi-dep.c.
-
- * default-dep.c (read_inferior_memory): Move #endif after else.
-
-Sat Sep 30 12:50:16 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * version.c: Change version number to 3.3.xxx.
-
- * GDB 3.3 released.
-
- * version.c: Change version number to 3.3.
-
- * Makefile.dist (READLINE): Add vi_mode.c
-
- * config.gdb (i386): Change /dev/null to m-i386.h
-
- * config.gdb: Add ';;' before 'esac'.
-
- * Makefile.dist (gdb.tar.Z): Move comment above dependency.
-
- * dbxread.c (read_ofile_symtab): Check symbol before start
- of source file for GCC_COMPILED_FLAG_SYMBOL.
- (start_symtab): Don't clear processing_gcc_compilation.
-
-Thu Sep 28 22:30:23 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * valprint.c (print_string): If LENGTH is zero, print "".
-
-Wed Sep 27 10:15:10 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * config.gdb: "rm tmp.c" -> "rm -f tmp.c".
-
-Tue Sep 26 13:02:10 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * utils.c (_initialize_utils): Use termcap to set lines_per_page
- and chars_per_line.
-
-Mon Sep 25 10:06:43 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab, N_SOL): Do not add the same file
- more than once.
-
-Thu Sep 21 12:43:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * infcmd.c (unset_environment_command): Delete all variables
- if called with no arg.
-
- * remote.c, inferior.h (remote_{read,write}_inferior_memory):
- New functions.
- core.c ({read,write}_memory): Use remote_{read,write}_inferior_memory.
-
- * valops.c (call_function): When reserving stack space for
- arguments, call value_arg_coerce.
-
- * m-hp9k320.h: define BROKEN_LARGE_ALLOCA.
-
- * breakpoint.c (delete_command): Ask for confirmation only
- when there are breakpoints.
-
- * dbxread.c (read_struct_type): If lookup_basetype_type has
- copied a stub type, call add_undefined_type.
-
- * sparc_pinsn.c (compare_opcodes): Check for "1+i" anywhere
- in args.
-
- * val_print.c (type_print_base): Print stub types as
- "<incomplete type>".
-
-Wed Sep 20 07:32:00 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * sparc-opcode.h (swapa): Remove i bit from match.
- (all alternate space instructions): Delete surplus "foo rs1+0"
- patterns.
-
- * Makefile.dist (LDFLAGS): Set to $(CFLAGS).
-
- * remote-multi.shar (remote_utils.c, putpkt): Change csum to unsigned.
-
-Tue Sep 19 14:15:16 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * sparc-opcode.h: Set i bit in lose for many instructions which
- aren't immediate.
-
- * stack.c (print_frame_info): add "func = 0".
-
-Mon Sep 18 16:19:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * sparc-opcode.h (mov): Add mov to/from %tbr, %psr, %wim.
-
- * sparc-opcode.h (rett): Fix notation to use suggested assembler
- syntax from architecture manual.
-
- * symmetry-dep.c (I386_REGNO_TO_SYMMETRY): New macro.
- (i386_frame_find_saved_regs): Use I386_REGNO_TO_SYMMETRY.
-
-Sat Sep 16 22:21:17 1989 Jim Kingdon (kingdon at spiff)
-
- * remote.c (remote_close): Set remote_desc to -1.
-
- * gdb.texinfo (Output): Fix description of echo to match
- reality and ANSI C.
-
-Fri Sep 15 14:28:59 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * symtab.c (lookup_symbol): Add comment about "asm".
-
- * sparc-pinsn.c: Use NUMOPCODES.
-
- * sparc-opcode.h (NUMOPCODES): Use sparc_opcodes[0] not *sparc_opcodes.
-
-Thu Sep 14 15:25:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (xxmalloc): Print error message before calling abort().
-
- * infrun.c (wait_for_inferior): Check for {stop,prev}_func_name
- null before passing to strcmp.
-
-Wed Sep 13 12:34:15 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * sparc-opcode.h: New field delayed.
- sparc-pinsn.c (is_delayed_branch): New function.
- (print_insn): Check for delayed branches.
-
- * stack.c (print_frame_info): Use misc_function_vector in
- case where ar truncates file names.
-
-Tue Sep 12 00:16:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * convex-dep.c (psw_info): Move "struct pswbit *p" with declarations.
-
-Mon Sep 11 14:59:57 1989 Jim Kingdon (kingdon at spiff)
-
- * convex-dep.c (core_file_command): Delete redundant printing
- of "Program %s".
-
- * m-convex.h (ENTRY_POINT): New macro.
-
- * m-convex.h (FRAME_CHAIN_VALID): Change outside_first_object_file
- to outside_startup_file
-
- * main.c: #if 0 out catch_termination and related code.
-
- * command.c (lookup_cmd_1): Consider underscores part of
- command names.
-
-Sun Sep 10 09:20:12 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * printcmd.c: Change asdump_command to disassemble_command
- (_initialize_printcmd): Change asdump to diassemble.
-
- * main.c (main): Exit with code 0 if we hit the end of a batch
- file.
-
- * Makefile.dist (libreadline.a): Fix syntax of "CC=${CC}".
-
-Sat Sep 9 01:07:18 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * values.c (history_info): Renamed to value_history_info.
- Command renamed to "info value" (with "info history" still
- accepted).
-
- * sparc-pinsn.c (print_insn): Extend symbolic address printing
- to cover "sethi" following by an insn which uses 1+i.
-
-Fri Sep 8 14:24:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * m-hp9k320.h, m-hp300bsd.h, m-altos.h, m-sparc.h, m-sun3.h
- (READ_GDB_SYMSEGS): Remove.
- dbxread.c [READ_GDB_SYMSEGS]: Remove code to read symsegs.
-
- * sparc-pinsn.c (print_insn): Detect "sethi-or" pairs and
- print symbolic address.
-
- * sparc-opcode.h (sethi, set): Change lose from 0xc0000000 to
- 0xc0c00000000.
-
- * remote.c (remote_desc): Initialize to -1.
-
- * Makefile.dist (libreadline.a): Pass CC='${CC}' to readline makefile.
-
-Thu Sep 7 00:07:17 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (read_struct_type): Check for static member functions.
- values.c, eval.c, valarith.c, valprint.c, valops.c: Merge changes
- from Tiemann for static member functions.
-
- * sparc-opcode.h (tst): Fix all 3 patterns.
-
- * Makefile.dist (gdb1): New rule.
-
- * sparc-opcode.h: Change comment about what the disassembler
- does with the order of the opcodes.
-
- * sparc-pinsn.c (compare_opcodes): Put 1+i before i+1.
- Also fix mistaken comment about preserving order of original table.
-
- * sparc-opcode.h (clr, mov): Fix incorrect lose entries.
-
- * m-symmetry.h (FRAME_NUM_ARGS): Add check to deal with code that
- GCC sometimes generates.
-
- * config.gdb: Change all occurances of "skip" to "/dev/null".
-
- * README (about languages other than C): Update comments about
- Pascal and FORTRAN.
-
- * sparc-opcode.h (nop): Change lose from 0xae3fffff to 0xfe3fffff.
-
- * values.c (value_virtual_fn_field): #if 0-out assignment to
- VALUE_TYPE(vtbl).
-
-Wed Sep 6 12:19:22 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * utils.c (fatal_dump_core): New function.
- Makefile.dist (MALLOC_FLAGS): use -Dbotch=fatal_dump_core
-
-Tue Sep 5 15:47:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * breakpoint.c (enable_command): With no arg, enable all bkpts.
-
- * Makefile.dist (Makefile): Remove \"'s around $(MD).
-
- * Makefile.dist: In "cd readline; make . . ." change first
- SYSV_DEFINE to SYSV.
-
- * m68k-pinsn.c (_initialize_pinsn): Use alternate assembler
- syntax #ifdef HPUX_ASM
-
-Sat Sep 2 23:24:43 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * values.c (history_info): Don't check num_exp[0] if num_exp
- is nil (just like recent editing_info change).
-
-Fri Sep 1 19:19:01 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * gdb.texinfo (inc-history, inc-readline): Copy in the inc-* files
- because people might not have makeinfo.
-
- * README (xgdb): Strengthen nasty comments.
-
- * gdb.texinfo: Change @setfilename to "gdb.info".
-
-Thu Aug 31 17:23:50 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * main.c (editing_info): Don't check arg[0] if arg is null.
-
- * m-vax.h: Add comment about known sigtramp bug.
-
- * sun3-dep.c, sparc-dep.c (IS_OBJECT_FILE, exec_file_command):
- Get right text & data addresses for .o files.
-
-Wed Aug 30 13:54:19 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * utils.c (tilde_expand): Remove function (it's in readline).
-
- * sparc-opcode.h (call): Change "8" to "9" in first two
- patterns (%g7->%o7).
-
-Tue Aug 29 16:44:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * printcmd.c (whatis_command): Change 4th arg to type_print
- from 1 to -1.
-
-Mon Aug 28 12:22:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c (psymtab_to_symtab_1): In "and %s ..." change
- pst->filename to pst->dependencies[i]->filename.
-
- * blockframe.c (FRAMELESS_LOOK_FOR_PROLOGUE): New macro
- made from FRAMELESS_FUNCTION_INVOCATION from m-sun3.h except
- that it checks for zero return from get_pc_function_start.
- m-hp9k320.h, m-hp300bsd.h, m-i386.h, m-isi.h, m-altos.h,
- m-news.h, m-sparc.h, m-sun2.h, m-sun3.h, m-symmetry.h
- (FRAMELESS_FUNCTION_INVOCATION): Use FRAMELESS_LOOK_FOR_PROLOGUE.
-
- * dbxread.c (read_struct_type): Give warning and ignore field
- if bitpos and bitsize are zero.
-
-Sun Aug 27 04:55:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (psymtab_to_symtab{,_1}): Print message about
- reading in symbols before reading stringtab, not after.
-
-Sat Aug 26 02:01:53 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c (IS_OBJECT_FILE, ADDR_OF_TEXT_SEGMENT): New macros.
- (read_dbx_symtab): Use text_addr & text_size to set end_of_text_addr.
- (symbol_file_command): pass text_addr & text_size to read_dbx_symtab.
-
-Fri Aug 25 23:08:13 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * valprint.c (value_print): Try to give the name of function
- pointed to when printing a function pointer.
-
-Thu Aug 24 23:18:40 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * core.c (xfer_core_file): In cases where MEMADDR is above the
- largest address that makes sense, set i to len.
-
-Thu Aug 24 16:04:17 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * valprint.c (print_string): New function to print a character
- string, doing array-max limiting and repeat count processing.
- (val_print, value_print): Use print_string.
- (REPEAT_COUNT_THRESHOLD): New #define, the max number of elts to print
- without using a repeat count. Set to ten.
- (value_print, val_print): Use REPEAT_COUNT_THRESHOLD.
-
- * utils.c (printchar): Use {fputs,fprintf}_filtered.
-
- * valprint.c (val_print): Pass the repeat count arg to the
- fprintf_filtered call for "<repeats N times>" messages.
-
-Wed Aug 23 22:53:47 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * utils.c: Include <pwd.h>.
-
- * main.c: Declare free.
-
-Wed Aug 23 05:05:59 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * utils.c, defs.h: Add tilde_expand.
- source.c (directory_command),
- main.c (cd_command),
- main.c (set_history_filename),
- dbxread.c (symbol_file_command),
- coffread.c (symbol_file_command),
- dbxread.c (add_file_command),
- symmisc.c (print_symtabs),
- *-dep.c (exec_file_command, core_file_command),
- main.c (source_command): Use tilde_expand.
-
- * dbxread.c (read_type): When we get a cross-reference, resolve
- it immediately if possible, only calling add_undefined_type if
- necessary.
-
- * gdb.texinfo: Uncomment @includes and put comment at start
- of file telling people to use makeinfo.
-
- * valprint.c (type_print_base): Print the right thing for
- bitfields.
-
- * config.gdb (sun3os3): Set paramfile and depfile.
-
-Tue Aug 22 05:38:36 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c (symbol_file_command): Pass string table size to
- read_dbx_symtab().
- (read_dbx_symtab): Before indexing into string table, check
- string table index for reasonableness.
- (psymtab_to_symtab{,_1}, read_ofile_symtab): Same.
-
-Tue Aug 22 04:04:39 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * m68k-pinsn.c: Replaced many calls to fprintf and fputs with
- calls to fprintf_filtered and fputs_filtered.
- (print_insn_arg): Use normal MIT 68k syntax for postincrement,
- predecrement, and register indirect addressing modes.
-
-Mon Aug 21 10:08:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * main.c (initialize_signals): Set signal handler for SIGQUIT
- and SIGHUP to do_nothing.
-
- * ns32k-opcode.h (ord): Change 1D1D to 1D2D.
-
- * ns32k-pinsn.c (print_insn_arg, print_insn): Handle index
- bytes correctly.
-
- * ns32k-opcode.h: Add comments.
-
- * dbxread.c (read_type): Put enum fields in type.fields in order
- that they were found in the debugging symbols (not reverse order).
-
-Sun Aug 20 21:17:13 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * main.c (source_command): Read .gdbinit if run without argument.
-
- * source.c (directory_command): Only print "foo already in path"
- if from_tty.
-
- * version.c: Change version number to 3.2.xxx
-
-Sat Aug 19 00:24:08 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * m-news.h: Define HAVE_WAIT_STRUCT.
-
- * m-isi.h, isi-dep.c: Replace with new version from Adam de Boor.
- config.gdb: Remove isibsd43.
-
- * main.c (catch_termination): Don't say we have written
- .gdb_history until after we really have.
-
- * convex-dep.c (attach): Add "sleep (1)".
- (write_vector_register): Use "LL" with long long constant.
- (wait): Close comment.
- (wait): Change "unix 7.1 bug" to "unix 7.1 feature" & related
- changes in comment.
- (scan_stack): And fp with 0x80000000 in while loop test.
- (core_file_command): Move code to set COREFILE.
- (many places): Change printf to printf_filtered.
- (psw_info): Allow argument giving value to print as a psw.
- (_initialize_convex_dep): Update docstrings.
-
- * m-convex.h (WORDS_BIG_ENDIAN): Correct typo ("WRODS")
- define NO_SIGINTERRUPT.
- define SET_STACK_LIMIT_HUGE.
- add "undef BUILTIN_TYPE_LONGEST" before defining it.
- Use "LL" after constants in CALL_DUMMY.
-
- * dbxread.c: In the 3 places it says error "ridiculous string
- table size"... delete extra parameter to error.
-
- * dbxread.c (scan_file_globals): Check for FORTRAN common block.
- Allow multiple references for the sake of common blocks.
-
- * main.c (initialize_main): Set history_filename to include
- current directory.
-
- * valprint.c (decode_format): Don't return a defaulted size
- field if osize is zero.
-
- * gdb.texinfo (Compilation): Update information on -gg symbols.
- Document problem with ar.
-
-Fri Aug 18 19:45:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * valprint.c (val_print, value_print): Add "<repeats %d times>" code.
- Also put "..." outside quotes for strings.
-
- * main.c (initialize_main): Add comment about history output file
- being different from history input file.
-
- * m-newsos3.h: Undefine NO_SIGINTERRUPT. Rearrange a few comments.
-
- * m-newsos3.h (REGISTER_U_ADDR): Use new version from Hikichi.
-
- * sparc-opcode.h: Add comment clarifying meaning of the order of
- the entries in sparc_opcodes.
-
- * eval.c (evaluate_subexp, case UNOP_IND): Deal with deferencing
- things that are not pointers.
-
- * valops.c (value_ind): Make dereferencing an int give a LONGEST.
-
- * expprint.c (print_subexp): Add (int) cast in OP_LAST case.
-
- * dbxread.c (read_array_type): Set lower and upper if adjustable.
-
- * symtab.c (lookup_symbol): Don't abort if symbol found in psymtab
- but not in symtab.
-
-Thu Aug 17 15:51:20 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * config.gdb: Changed "Makefile.c" to "Makefile.dist".
-
-Thu Aug 17 01:58:04 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu)
-
- * sparc-opcode.h (or): Removed incorrect lose bit 0x08000000.
- [many]: Changed many `lose' entries to have the 0x10 bit set, so
- they don't think %l0 is %g0.
-
-Wed Aug 16 00:30:44 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * m-symmetry.h (STORE_STRUCT_RETURN): Also write reg 0.
- (EXTRACT_RETURN_VALUE): Call symmetry_extract_return_value.
- symmetry-dep.c (symmetry_extract_return_value): New fn.
-
- * main.c (symbol_completion_function): Deal with changed
- result_list from lookup_cmd_1 for ambiguous return.
- command.c (lookup_cmd): Same.
-
- * inflow.c [TIOCGETC]: Move #include "param.h" back before
- system #includes. Change all #ifdef TIOCGETC to
- #if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
- m-i386-sysv3.2.h, m-i386gas-sysv3.2.h: Remove "#undef TIOCGETC"
- and add "#define TIOCGETC_BROKEN".
-
- * command.c (lookup_cmd_1): Give the correct result_list in the
- case of an ambiguous return where there is a partial match
- (e.g. "info a"). Add comment clarifying what is the correct
- result_list.
-
- * gdb.texinfo (GDB History): Document the two changes below.
-
- * main.c (command_line_input): Make history expansion not
- just occur at the beginning of a line.
-
- * main.c (initialize_main): Make history expansion off by default.
-
- * inflow.c: Move #include "param.h" after system #includes.
-
- * i386-dep.c (i386_float_info): Use U_FPSTATE macro.
-
- * m-i386-sysv3.2.h, m-i386gas-sysv3.2.h: New files.
- Makefile.dist, config.gdb: Know about these new files.
-
-Tue Aug 15 21:36:11 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * symtab.c (lookup_struct_elt_type): Use type_print rather
- than assuming type has a name.
-
-Tue Aug 15 02:25:43 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu)
-
- * sparc-opcode.h (mov): Removed bogus "or i,0,d" pattern.
-
- * sparc-opcode.h (mov, or): Fixed incorrect `lose' members.
-
- * sparc-dep.c: Don't include "sparc-opcode.h".
- (skip_prologue, isanulled): Declare special types to recognize
- instructions, and use them.
-
- * sparc-pinsn.c (print_insn): Sign-extend 13-bit immediate args.
- If they are less than +9, print them in signed decimal instead
- of unsigned hex.
-
- * sparc-opcode.h, sparc-pinsn.c: Completely rewritten to share an
- opcode table with gas, and thus produce disassembly that looks
- like what the assembler accepts.
-
-Tue Aug 15 16:20:52 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * symtab.c (find_pc_psymbol): Move best_pc=psymtab->textlow-1
- after test for psymtab null.
-
- * main.c (editing_info): Remove variable retval.
-
- * config.gdb (sun3, isi): Comment out obsolete message about telling
- it whether you have an FPU (now that it detects it).
-
- * config.gdb (sun3): Accept sun3os3.
-
- * m68k-insn.h: Include <signal.h>.
-
- * m68k-pinsn.h (convert_{to,from}_68881): Add have_fpu code
-
- * m-newsos3.h: Undefine USE_PCB. That code didn't seem to work.
-
- * sparc-dep.c: Put in insn_fmt and other stuff from the old
- sparc-opcode.h.
-
- * sparc-opcode.h, sparc-pinsn.c: Correct copyright notice.
-
- * sparc-opcode.h, sparc-pinsn.c: Replace the old ones with the new
- ones by roland.
-
-Tue Aug 15 02:25:43 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu)
-
- * Makefile.dist: Don't define CC at all.
-
- * Makefile.dist (Makefile): Remove tmp.c after preprocessing.
- Use $(MD) instead of M_MAKEDEFINE in the cc command.
-
- * Makefile.dist: Don't define RL_LIB as
- "${READLINE}/libreadline.a", since READLINE is a list of files.
-
-Mon Aug 14 23:49:29 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * main.c (print_version): Change 1988 to 1989.
-
- * main.c (copying_info, initialize_main): Remove #if 0'd code.
-
-Tue Aug 1 14:44:56 1989 Hikichi (hikichi at sran203)
-
- * m-newsos3.h
- (NO_SIGINTERRUPT): have SIGINTERRUPT on NEWS os 3.
-
- * m-news.h(FRAME_FIND_SAVED_REGS): use the sun3's instead of old
- one.
-
-Mon Aug 14 15:27:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * m-news.h, m-newsos3.h, news-dep.c: Merge additional changes
- by Hikichi (ChangeLog entries above).
-
- * Makefile.dist (READLINE): List readline files individually
- so we don't accidently get random files from the readline
- directory.
-
- * m-news.h (STORE_RETURN_VALUE, EXTRACT_RETURN_VALUE):
- Expect floating point returns to be in fp0.
-
- * gdb.texinfo (Format options): New node.
-
- * gdb.texinfo: Comment out "@include"s until bfox fixes the
- readline & history docs.
-
- * dbxread.c (read_addl_syms): Set startup_file_* if necessary at
- the end (as well as when we hit ".o").
-
- * printcmd.c (decode_format): Set val.format & val.size to '?' at
- start and set defaults at end.
-
- * symtab.c (decode_line_1): Check for class_name null.
-
- * valops.c: Each place where it compares against field names,
- check for null field names. (new t_field_name variables).
-
- * utils.c (fputs_filtered): Check for linebuffer null before
- checking whether to call fputs. Remove later check for linebuffer
- null.
-
-Sun Aug 13 15:56:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * m-isi.h, m-sun3.h ({PUSH,POP}_FP_REGS): New macros.
- m-sun3.h (NUM_REGS): Conditionalize on FPU.
- config.gdb (sun3, isi): Add message about support for machines
- without FPU.
-
- * main.c (catch_termination, initialize_signals): new functions.
-
- * main.c (editing_info): Add "info editing n" and "info editing +".
- Rewrite much of this function.
- gdb.texinfo (GDB Readline): Document it.
-
- * values.c (history_info): Add "info history +". Also add code to
- do "info history +" when command is repeated.
- gdb.texinfo (Value History): Document "info history +".
-
- * expprint.c (print_subexp): Add OP_THIS to case stmt.
-
- * config.gdb (sun4os4): Put quotes around make define.
-
- * config.gdb: Canonicalize machine name at beginning.
-
-Sat Aug 12 00:50:59 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * config.gdb: define M_MAKEDEFINE
- Makefile (Makefile, MD): Be able to re-make Makefile.
-
- * main.c (command_line_input): Add comments to
- the command history.
-
- * Makefile.dist (Makefile): Add /bin/false.
-
-Fri Aug 11 14:35:33 1989 Jim Kingdon (kingdon at spiff)
-
- * Makefile.dist: Comment out .c.o rule and add TARGET_ARCH.
-
- * m-altos.h: Include sys/page.h & sys/net.h
-
- * m-altos.h (FRAME_CHAIN{,_VALID}): Use outside_startup_file.
-
- * config.gdb (altos, altosgas): Add M_SYSV & M_BSD_NM and remove
- M_ALLOCA=alloca.o from makedefine.
-
- * coffread.c (complete_symtab): Change a_entry to entry.
-
- * m-altosgas.h: New file.
-
- * m-symmetry (REGISTER_BYTE): Fix dumb mistake.
-
-Fri Aug 11 06:39:49 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * utils.c (set_screensize_command): Check for ARG being nil, since
- that's what execute_command will pass if there's no argument.
-
- * expread.y (yylex): Recognize "0x" or "0X" as the beginning of a
- number.
-
-Thu Aug 10 15:43:12 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * config.gdb, Makefile.dist: Rename Makefile.c to Makefile.dist.
-
- * m-altos.h: Add comment about porting to USGR2.
-
- * config.gdb (sparc): Add -Usparc.
-
-Wed Aug 9 14:20:39 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * m-sun3os4.h: Define BROKEN_LARGE_ALLOCA.
-
- * values.c (modify_field): Check for value too large to fit in
- bitfield.
-
- * utils.c (fputs_filtered): Allow LINEBUFFER to be NULL.
-
- * breakpoint.c (condition_command): Check for attempt to specify
- non-numeric breakpoint number.
-
- * config.gdb, Makefile, m-altos.h, altos-dep.c: Merge Altos
- port.
-
- * README: Change message about editing Makefile.
-
- * config.gdb: Edit Makefile.
- Copied Makefile to Makefile.c and changed to let config.gdb
- run us through the C preprocessor.
-
- * expread.y (yylex): Test correctly for definition of number.
-
-Wed Aug 9 11:56:05 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab): Put bracketing of entry point in
- test case for .o symbols so that it will be correct even without
- debugging symbols.
- (end_psymtab): Took bracketing out.
-
- * blockframe.c (outside_startup_file): Reverse the sense of the
- return value to make the functionality implied by the name
- correct.
-
-Tue Aug 8 11:48:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * coffread.c (symbol_file_command): Do not assume presence of a.out
- header.
-
- * blockframe.c: Replace first_object_file_end with
- startup_file_{start,end}
- (outside_startup_file): New function.
- dbxread.c (read_addl_syms, read_dbx_symtab, end_psymbol): set
- startup_file_*. Delete first_object_file_end code.
- Add entry_point and ENTRY_POINT
- coffread.c (complete_symtab): Set startup_file_*.
- (first_object_file_end): Add as static.
- m-*.h (FRAME_CHAIN, FRAME_CHAIN_VALID): Call outside_startup_file
- instead of comparing with first_object_file_end.
-
- * breakpoint.c (breakpoint_1): Change -1 to (CORE_ADDR)-1.
-
- * config.gdb (i386, i386gas): Add missing quotes at end of "echo"
-
- * source.c (directory_command): Add dont_repeat ();
-
-Mon Aug 7 18:03:51 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * dbxread.c (read_addl_syms): Change strcmp to strncmp and put 3rd
- arg back.
-
- * command.h (struct cmd_list_element): Add comment clarifying
- purpose of abbrev_flag.
-
-Mon Aug 7 12:51:03 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * printcmd.c (_initialize_printcmd): Changed "undisplay" not to
- have abbrev flag set; it isn't an abbreviation of "delete
- display", it's an alias.
-
-Mon Aug 7 00:25:15 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * symtab.c (lookup_symtab_1): Remove filematch (never used).
-
- * expread.y [type]: Add second argument to 2 calls to
- lookup_member_type which were missing them.
-
- * dbxread.c (symbol_file_command): Add from_tty arg.
- Check it before calling query.
-
- * infcmd.c (tty_command): Add from_tty arg.
-
- * eval.c (evaluate_subexp): Remove 3rd argument from
- calls to value_x_unop.
-
- * dbxread.c (read_addl_syms): Remove 3rd argument from
- call to strcmp.
-
- * gdb.texinfo (Command editing): @include inc-readline.texinfo
- and inc-history.texinfo and reorganize GDB-specific stuff.
-
- * Makefile: Add line MAKE=make.
-
- * README (second paragraph): Fix trivial errors.
-
- * dbxread.c (read_struct_type): Make sure p is initialized.
-
- * main.c (symbol_completion_function): Complete correctly
- on the empty string.
-
-Sun Aug 6 21:01:59 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * symmetry-dep.c: Remove "long" from definition of i386_follow_jump.
-
- * gdb.texinfo (Backtrace): Document "where" and "info stack".
-
- * dbxread.c (cleanup_undefined_types): Strip off "struct "
- or "union " from type names before doing comparison
-
-Sat Aug 5 02:05:36 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * config.gdb (i386, i386gas): Improve makefile editing instructions.
-
- * Makefile: Fix typo in CLIBS for SYSV.
-
- * dbxread.c (read_dbx_symtab): Deal with N_GSYM typedefs.
-
- * dbxread.c (add_file_command): Do not free name. We didn't
- allocate it; it just points into arg_string.
-
- * Makefile, m-*.h: Change LACK_VPRINTF to HAVE_VPRINTF.
-
-Fri Jul 28 00:07:48 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * valprint.c (val_print): Made sure that all returns returned a
- value (usually 0, indicating no memory printed).
-
- * core.c (read_memory): Changed "return" to "return 0".
-
- * expread.y (parse_number): Handle scientific notation when the
- string does not contain a '.'.
-
-Thu Jul 27 15:14:03 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * infrun.c (signals_info): Error if signal number passed is out of
- bounds.
-
- * defs.h: Define alloca to be __builtin_alloca if compiling with
- gcc and localized inclusion of alloca.h on the sparc with the
- other alloca stuff.
- * command.c: Doesn't need to include alloca.h on the sparc; defs.h
- does it for you.
-
- * printcmd.c (print_frame_args): Changed test for call to
- print_frame_nameless_args to check i to tell if any args had been
- printed.
-
-Thu Jul 27 04:40:56 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * blockframe.c (find_pc_partial_function): Always check that NAME
- and/or ADDRESS are not nil before storing into them.
-
-Wed Jul 26 23:41:21 1989 Roland McGrath (roland at hobbes.ai.mit.edu)
-
- * m-newsos3.h: Define BROKEN_LARGE_ALLOCA.
- * dbxread.c (symbol_file_command, psymtab_to_symtab):
- Use xmalloc #ifdef BROKEN_LARGE_ALLOCA.
-
-Tue Jul 25 16:28:18 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu)
-
- * m68k-opcode.h: moved some of the fmovem entries so they're
- all consecutive. This way the assembler doesn't bomb.
-
-Mon Jul 24 22:45:54 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * symtab.c (lookup_symbol): Changed error to an informational (if
- not very comforting) message about internal problems. This will
- get a null symbol returned to decode_line_1, which should force
- things to be looked up in the misc function vector.
-
-Wed Jul 19 13:47:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symtab.c (lookup_symbol): Changed "fatal" to "error" in
- external symbol not found in symtab in which it was supposed to be
- found. This can be reached because of a bug in ar.
-
-Tue Jul 18 22:57:43 1989 Randy Smith (roland at hobbes.ai.mit.edu)
-
- * m-news.h [REGISTER_U_ADDR]: Decreased the assumed offset of fp0
- by 4 to bring it into (apparently) appropriate alignment with
- reality.
-
-Tue Jul 18 18:14:42 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * Makefile: pinsn.o should depend on opcode.h
-
- * m68k-opcode.h: Moved fmovemx with register lists to before other
- fmovemx.
-
-Tue Jul 18 11:21:42 1989 Jim Kingdon (kingdon at susie)
-
- * Makefile, m*.h: Only #define vprintf (to _doprnt or printf,
- depends on the system) if the library lacks it (controlled by
- LACK_VPRINTF_DEFINE in makefile). Unpleasant, but necessary to
- make this work with the GNU C library.
-
-Mon Jul 17 15:17:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * breakpoint.c (breakpoint_1): Change addr-b->address to
- b->address-addr.
-
-Sun Jul 16 16:23:39 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * eval.c (evaluate_subexp): Change error message printed when
- right operand of '@' is not an integer to English.
-
- * infcmd.c (registers_info): Fix call to print_spaces_filtered
- to specify right # of arguments.
-
- * gdb.texinfo (Command Editing): Document info editing command.
-
- * coffread.c (read_file_hdr): Add MC68MAGIC.
-
- * source.c (select_source_symtab): Change MAX to max.
-
-Fri Jul 14 21:19:11 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * infcmd.c (registers_info): Clean up display to look good with long
- register names, to say "register" instead of "reg", and to put the
- "relative to selected stack frame" bit at the top.
-
-Fri Jul 14 18:23:09 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (record_misc_function): Put parens around | to force
- correct evaluation.
-
-Wed Jul 12 12:25:53 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * m-newsos3, m-news, infrun.c, Makefile, config.gdb, news-dep.c:
- Merge in Hikichi's changes for Sony/News-OS 3 support.
-
-Tue Jul 11 21:41:32 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * utils.c (fputs_filtered): Don't do any filtering if output is
- not to stdout, or if stdout is not a tty.
- (fprintf_filtered): Rely on fputs_filtered's check for whether to
- do filtering.
-
-Tue Jul 11 00:33:58 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * GDB 3.2 Released.
-
- * valprint.h: Deleted.
-
- * utils.c (fputs_filtered): Don't do any filtering if filtering is
- disabled (lines_per_page == 0).
-
-Mon Jul 10 22:27:53 1989 Randy Smith (roland at hobbes.ai.mit.edu)
-
- * expread.y [typebase]: Added "unsigned long int" and "unsigned
- short int" to specs.
-
-Mon Jul 10 21:44:55 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * main.c (main): Make -cd use cd_command to avoid
- current_directory with non-absolute pathname.
-
-Mon Jul 10 00:34:29 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (symbol_file_command): Catch errors from stat (even
- though they should never happen).
-
- * source.c (openp): If the path is null, use the current
- directory.
-
- * dbxread.c (read_dbx_symtab): Put N_SETV symbols into the misc
- function vector ...
- (record_misc_function): ... as data symbols.
-
- * utils.c (fprintf_filtered): Return after printing if we aren't
- going to do filtering.
-
- * Makefile: Added several things for make clean to take care of.
-
- * expread.y: Lowered "@" in precedence below +,-,*,/,%.
-
- * eval.c (evaluate_subexp): Return an error if the rhs of "@"
- isn't integral.
-
- * Makefile: Added removal of core and gdb[0-9] files to clean
- target.
-
- * Makefile: Made a new target "distclean", which cleans things up
- correctly for making a distribution.
-
-Sun Jul 9 23:21:27 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * dbxread.c: Surrounded define of gnu symbols with an #ifndef
- NO_GNU_STABS in case you don't want them on some machines.
- * m-npl.h, m-pn.h: Defined NO_GNU_STABS.
-
-Sun Jul 9 19:25:22 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * utils.c (fputs_filtered): New function.
- (fprintf_filtered): Use fputs_filtered.
- utils.c (print_spaces_filtered),
- command.c (help_cmd,help_cmd_list),
- printcmd.c (print_frame_args),
- stack.c (print_block_frame_locals, print_frame_arg_vars),
- valprint.c (many functions): Use fputs_filtered instead of
- fprintf_filtered to avoid arbitrary limit.
-
- * utils.c (fprintf_filtered): Fix incorrect comment.
-
-Sat Jul 8 18:12:01 1989 Randy Smith (randy at hobbes.ai.mit.edu)
-
- * valprint.c (val_print): Changed assignment of pretty to use
- prettyprint as a conditional rather than rely on values of the
- enum.
-
- * Projects: Cleaned up a little for release.
-
- * main.c (initialize_main): Initialize
- rl_completion_entry_function instead of completion_entry_function.
-
- * Makefile: Modified to use the new readline library setup.
-
- * breakpoint.c (break_command_1, delete_breakpoint,
- enable_breakpoint, disable_breakpoint): Put in new printouts for
- xgdb usage triggered off of xgdb_verbose.
- * main.c (main): Added check for flag to set xgdb_verbose.
- * stack.c (frame_command): Set frame_changed when frame command
- used.
-
-Fri Jul 7 16:20:58 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * Remove valprint.h and move contents to value.h (more logical).
-
-Fri Jul 7 02:28:06 1989 Randall Smith (randy at rice-chex)
-
- * m68k-pinsn.c (print_insn): Included a check for register list;
- if there is one, make sure to start p after it.
-
- * breakpoint.c (break_command_1, delete_breakpoint,
- enable_breakpoint, disable_breakpoint): #ifdef'd out changes
- below; they produce unwanted output in gdb mode in gnu-emacs.
-
- * gdb.texinfo: Spelled. Also removed index references from
- command editing section; the relevance/volume ratio was too low.
- Removed all references to the function index.
-
- * ns32k-opcode.h, ns32k-pinsn.c: Backed out changes of June 24th;
- haven't yet received legal papers.
-
- * .gdbinit: Included message telling the user what it is doing.
-
- * symmetry-dep.c: Added static decls for i386_get_frame_setup,
- i386_follow_jump.
- * values.c (unpack_double): Added a return (double)0 at the end to
- silence a compiler warning.
-
- * printcmd.c (containing_function_bounds, asdump_command): Created
- to dump the assembly code of a function (support for xgdb and a
- useful hack).
- (_initialize_printcmd): Added this to command list.
- * gdb.texinfo [Memory]: Added documentation for the asdump
- command.
- * breakpoint.c (break_command_1, delete_breakpoint,
- enable_breakpoint, disable_breakpoint): Added extra verbosity for
- xgdb conditionalized on the new external frame_full_file_name.
- * source.c (identify_source_line): Increase verbosity of fullname
- prointout to include pc value.
- * stack.c: Added a new variable; "frame_changed" to indicate when
- a frame has been changed so that gdb can print out a frame change
- message when the frame only changes implicitly.
- (print_frame_info): Check the new variable in determining when to
- print out a new message and set it to zero when done.
- (up_command): Increment it.
- (down_command): Decrement it.
-
- * m68k-pinsn.c (print_insn_arg [lL]): Modified cases for register
- lists to reset the point to point to after the word from which the
- list is grabbed *if* that would cause point to point farther than
- it currently is.
-
-Thu Jul 6 14:28:11 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * valprint.c (val_print, value_print): Add parameter to control
- prettyprinting.
- valprint.h: New file containing constants used for passing
- prettyprinting parameter to val{,ue}_print.
- expprint.c, infcmd.c, printcmd.c, valprint.c, values.c:
- Change all calls to val{,ue}_print to use new parameter.
-
-Mon Jul 3 22:38:11 1989 Randy Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (,process_one_symbol): Moved extern declaration for
- index out of function to beginning of file.
-
-Mon Jul 3 18:40:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * gdb.texinfo (Registers): Add "ps" to list of standard registers.
-
-Sun Jul 2 23:13:03 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * printcmd.c (enable_display): Change d->next to d = d->next so
- that "enable display" without args works.
-
-Fri Jun 30 23:42:04 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * source.c (list_command): Made error message given when no
- symtab is loaded clearer.
-
- * valops.c (value_assign): Make it so that when assigning to an
- internal variable, the type of the assignment exp is the type of
- the value being assigned.
-
-Fri Jun 30 12:12:43 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c (verbose_info): Created.
- (initialize_main): Put "info verbose" into command list.
-
- * utils.c (screensize_info): Created.
- (_initialize_utils): Defined "info screensize" as a normal command.
-
- * valprint.c (format_info): Added information about maximum number
- of array elements to function.
-
- * blockframe.c (find_pc_partial_function): Again.
-
- * blockframe.c (find_pc_partial_function): Replaced a "shouldn't
- happen" (which does) with a zero return.
-
- * main.c (dont_repeat): Moved ahead of first use.
-
-Thu Jun 29 19:15:08 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * vax-opcode.h: Made minor modifications (moved an instruction and
- removed a typo) to bring this into accord with gas' table; also
- changed copyright to reflect it being part of both gdb and gas.
-
- * m68k-opcode.h: Added whole scads and bunches of new stuff for
- the m68851 and changed the coptyrightto recognize that the file
- was shared between gdb and gas.
-
- * main.c (stop_sig): Use "dont_repeat ()" instead of *line = 0;
-
- * core.c (read_memory): Don't do anything if length is 0.
-
- * Makefile: Added readline.c to the list of files screwed by
- having the ansi ioctl.h compilation with gcc.
-
- * config.gdb: Added sun4os3 & sun4-os3 as availible options.
-
-Wed Jun 28 02:01:26 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu)
-
- * command.c (lookup_cmd): Add ignore_help_classes argument.
- (lookup_cmd_1): Add ignore_help_classes argument.
- command.c, main.c: Change callers of lookup_cmd{,_1} to supply
- value for ignore_help_classes.
-
-Tue Jun 27 18:01:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * utils.c (print_spaces_filtered): Made more efficient.
- * defs.h: Declaration.
- * valprint.c (val_print): Used in a couple of new places.
-
-Mon Jun 26 18:27:28 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * m68k-pinsn.c (print_insn_arg ['#', '^']): Combined them into one
- case which always gets the argument from the word immediately
- following the instruction.
- (print_insn_arg ["[lL]w"]): Make sure to always get the register
- mask from the word immediately following the instruction.
-
-Sun Jun 25 19:14:56 1989 Randall Smith (randy at galapas.ai.mit.edu)
-
- * Makefile: Added hp-include back in as something to distribute.
-
- * stack.c (print_block_frame_locals): Return value changed from
- void to int; return 1 if values printed. Use _filtered.
- (print_frame_local_vars): Use return value from
- print_block_frame_locals to mention if nothing printed; mention
- lack of symbol table, use _filtered.
- (print_frame_arg_vars): Tell the user if no symbol table
- or no values printed. Use fprintf_filtered instead of fprintf.
- * blockframe.c (get_prev_frame_info): Check for no inferior or
- core file before crashing.
-
- * inflow.c (inferior_died): Set current frame to zero to keep from
- looking like we're in start.
-
-Sat Jun 24 15:50:53 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * stack.c (frame_command): Added a check to make sure that there
- was an inferior or a core file.
-
- * expread.y (yylex): Allow floating point numbers of the form ".5"
- to be parsed.
-
- Changes by David Taylor at TMC:
- * ns32k-pinsn.c: Added define for ?floating point coprocessor? and
- tables for register names to be used for each of the possibilities.
- (list_search): Created; searches a list of options for a specific
- value.
- (print_insn_arg): Added 'Q', 'b', 'M', 'P', 'g', and 'G' options
- to the value location switch.
- * ns32k-opcode.h: Added several new location flags.
- [addr, enter, exit, ext[bwd], exts[bwd], lmr, lpr[bwd], restore,
- rett, spr[bwd], smr]: Improved insn format output.
-
- * symtab.c (list_symbols): Rearrange printing to produce readable
- output for "info types".
-
- * eval.c (evaluate_subexp_for_address): Fixed typo.
-
- * dbxread.c (read_type): Don't output an error message when
- there isn't a ',' after a cross-reference.
-
- * dbxread.c (read_dbx_symtab): #if'd out N_FN case in
- read_dbx_symtab if it has the EXT bit set (otherwise multiple
- cases with the same value).
-
-Fri Jun 23 13:12:08 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * symmisc.c: Changed decl of print_spaces from static to extern
- (since it's defined in utils.c).
-
- * remote.c (remote_open): Close remote_desc if it's already been
- opened.
-
- * Remote_Makefile, remote_gutils.c, remote_inflow.c,
- remote_server.c, remote_utils.c: Combined into remote-multi.shar.
- * remote-multi.shar: Created (Vikram Koka's remote stub).
- * remote-sa.m68k.shar: Created (Glenn Engel's remcom.c).
- * README: Updated to reflect new organization of remote stubs.
-
- * dbxread.c (read_dbx_symtab): Put an N_FN in with N_FN | N_EXT to
- account for those machines which don't use the external bit here.
- Sigh.
-
- * m-symmetry.h: Defined NO_SIGINTERRUPT.
-
-Thu Jun 22 12:51:37 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * printcmd.c (decode_format): Make sure characters are printed
- using a byte size.
-
- * utils.c (error): Added a terminal_ours here.
-
- * stack.c (locals_info): Added check for selected frame.
-
- * dbxread.c (read_type): Checked to make sure that a "," was
- actually found in the symbol to end a cross reference.
-
-Wed Jun 21 10:30:01 1989 Randy Smith (randy at tartarus.uchicago.edu)
-
- * expread.y (parse_number, [exp]): Allowed for the return of a
- number marked as unsigned; this will allow inclusion of unsigned
- constants.
-
- * symtab.h: Put in default definitions for BUILTIN_TYPE_LONGEST
- and BUILTIN_TYPE_UNSIGNED_LONGEST.
-
- * expread.y (parse_number): Will now accept integers suffixed with
- a 'u' (though does nothing special with it).
-
- * valarith.c (value_binop): Added cases to deal with unsigned
- arithmetic correctly.
-
-Tue Jun 20 14:25:54 1989 Randy Smith (randy at tartarus.uchicago.edu)
-
- * dbxread.c (psymtab_to_symtab_1): Changed reading in info message
- to go through printf_filtered.
-
- * symtab.c (list_symbols): Placed header message after all calls
- to psymtab_to_symtab.
-
- * symtab.c (smash_to_{function, reference, pointer}_type): Carried
- attribute of permanence for the type being smashed over the bzero
- and allowed any type to point at this one if it is permanent.
-
- * symtab.c (smash_to_{function, reference, pointer}_type): Fix
- typo: check flags of to_type instead of type.
-
- * m-hp9k320.h: Changed check on __GNU__ predefine to __GNUC__.
-
- * Makefile: Made MUNCH_DEFINE seperate and based on SYSV_DEFINE;
- they aren't the same on hp's.
-
-Mon Jun 19 17:10:16 1989 Randy Smith (randy at tartarus.uchicago.edu)
-
- * Makefile: Fixed typo.
-
- * valops.c (call_function): Error if the inferior has not been
- started.
-
- * ns32k-opcode.h [check[wc], cmpm[bwd], movm[bwd], skpsb]: Fixed
- typos.
-
-Fri Jun 9 16:23:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-news.h [NO_SIGINTERRUPT]: Defined.
-
- * dbxread.c (read_type): Start copy of undefined structure name
- past [sue] defining type of cross ref.
-
- * dbxread.c (process_one_symbol): Changed strchr to index.
-
- * ns32k-opcode.h, ns32k-pinsn.c: More changes to number of
- operands, addition of all of the set condition opcodes, addition
- of several flag letters, all patterned after the gas code.
-
- * ns32k-opcode.h [mov{su,us}[bwd], or[bwd]]: Changed number of
- operands from 1 to 2.
-
-Wed Jun 7 15:04:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symseg.h [TYPE_FLAG_STUB]: Created.
- * dbxread.c (read_type): Set flag bit if type is stub.
- (cleanup_undefined_types): Don't mark it as a stub if it's been
- defined since we first learned about it.
- * valprint.c (val_print): Print out a message to that effect if
- this type is encountered.
-
- * symseg.h, symtab.h: Moved the definition of TYPE_FLAG_PERM over
- to symseg.h so that all such definitions would be in the same place.
-
- * valprint.c (val_print): Print out <No data fields> for a
- structure if there aren't any.
-
- * dbxread.c (read_type): Set type name of a cross reference type
- to "struct whatever" or something.
-
-Tue Jun 6 19:40:52 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * breakpoint.c (breakpoint_1): Print out symbolic location of
- breakpoints for which there are no debugging symbols.
-
-Mon Jun 5 15:14:51 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * command.c (help_cmd_list): Made line_size static.
-
-Sat Jun 3 17:33:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * Makefile: Don't include the binutils hp-include directory in the
- distribution anymore; refer the users to the binutils distribution.
-
-Thu Jun 1 16:33:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * printcmd.c (disable_display_command): Fixed loop iteration for
- no arg case.
-
- * printcmd.c (disable_display_command): Added from_tty parameter
- to function.
-
- * valops.c (value_of_variable): Call read_var_value with 0 cast to
- FRAME instead of CORE_ADDR.
-
- * eval.c (evaluate_subexp): Corrected number of args passed to
- value_subscript (to 2).
-
- * infrun.c (wait_for_inferior), symtab.c (decode_line_1),
- m-convex.h: Changed name of FIRSTLINE_DEBUG_BROKEN to
- PROLOGUE_FIRSTLINE_OVERLAP.
-
- * m-merlin.h: Fixed typo.
- * ns32k-opcode.h: Added ns32381 opcodes and "cinv" insn, and fixed
- errors in movm[wd], rett, and sfsr.
-
- * eval.c (evaluate_subexp, evaluate_subexp_for_address), valops.c
- (value_zero): Change value_zero over to taking two arguments
- instead of three.
-
- * eval.c (evaluate_subexp)
- [OP_VAR_VALUE]: Get correct lval type for AVOID_SIDE_EFFECTS for
- all types of symbols.
- [BINOP_DIV]: Don't divide if avoiding side effects; just return
- an object of the correct type.
- [BINOP_REPEAT]: Don't call value_repeat, just allocate a
- repeated value.
- (evaluete_subexp_for_address) [OP_VAR_VALUE]: Just return a thing
- of the right type (after checking to make sure that we are allowed
- to take the address of whatever variable has been passed).
-
-Mon May 29 11:01:02 1989 Randall Smith (randy at galapas.ai.mit.edu)
-
- * breakpoint.c (until_break_command): Set the breakpoint with a
- frame specification so that it won't trip in inferior calls to the
- function. Also set things up so that it works based on selected
- frame, not current one.
-
-Sun May 28 15:05:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * eval.c (evalue_subexp): Change subscript case to use value_zero
- in EVAL_AVOID_SIDE_EFFECTS case.
-
-Fri May 26 12:03:56 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (read_addl_syms, psymtab_to_symtab): Removed
- cleanup_undefined_types; this needs to be done on a symtab basis.
- (end_symtab): Called cleanup_undefined_types from here.
- (cleanup_undefined_types): No longer uses lookup_symbol (brain
- dead idea; oh, well), now it searches through file_symbols.
-
-Wed May 24 15:52:43 1989 Randall Smith (randy at galapas)
-
- * source.c (select_source_symtab): Only run through
- partial_symtab_list if it exists.
-
- * coffread.c (read_coff_symtab): Don't unrecord a misc function
- when a function symbol is seen for it.
-
- * expread.y [variable]: Make sure to write a type for memvals if
- you don't get a mft you recognize.
-
-Tue May 23 12:15:57 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * dbxread.c (read_ofile_symtab, psymtab_to_symtab): Moved cleanup
- of undefined types to psymtab_to_symtab. That way it will be
- called once for all readins (which will, among other things,
- help reduce infinite loops).
-
- * symtab.h [misc_function_type]: Forced mf_unknown to 0.
- * dbxread.c (record_misc_function): Cast enum to unsigned char (to
- fit).
- * expread.y [variable]: Cast unsigned char back to enum to test.
-
-Mon May 22 13:08:25 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- Patches by John Gilmore for dealing well with floating point:
- * findvar.c (value_from_register, locate_var_value): Used
- BYTES_BIG_ENDIAN instead of an inline test.
- * m-sparc.h [IEEE_FLOAT]: Created to indicate that the sparc is
- IEEE compatible.
- * printcmd.c (print_scalar_formatted): Use BYTES_BIG_ENDIAN and
- the stream argument for printing; also modify default type for
- 'f'. Change handling of invalid floats; changed call syntax for
- is_nan.
- (print_command): Don't print out anything indicating that
- something was recorded on the history list if it wasn't.
- * valprint.c (val_print): Fixed to deal properley with new format
- of is_nan and unpacking doubles without errors occuring.
- (is_nan): Changed argument list and how it figures big endianness
- (uses macros).
- * values.c (record_latest_value): Return -1 and don't record if
- it's an invalid float.
- (value_as_double): Changed to use new unpack_double calling
- convention.
- (unpack_double): Changed not to call error if the float was
- invalid; simply to set invp and return. Changed calling syntax.
- (unpack_field_as_long, modify_field): Changed to use
- BITS_BIG_ENDIAN to determine correct action.
-
- * m-hp9k320.h [HP_OS_BUG]: Created; deals with problem where a
- trap happens after a continue.
- * infrun.c (wait_for_inferior): Used.
-
- * m-convex.h [FIRSTLINE_DEBUG_BROKEN]: Defined a flag to indicate
- that the debugging symbols output by the compiler for the first
- line of a function were broken.
- * infrun.c (wait_for_inferior), symtab.c (decode_line_1): Used.
-
- * gdb.texinfo [Data, Memory]: Minor cleanups of phrasing.
-
-Fri May 19 00:16:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (add_undefined_type, cleanup_undefined_types): Created
- to keep a list of cross references to as yet undefined types.
- (read_type): Call add_undefined_type when we run into such a case.
- (read_addl_syms, read_ofile_symtab): Call cleanup_undefined_types
- when we're done.
-
- * dbxread.c (psymtab_to_symtab, psymtab_to_symtab_1): Broke
- psymtab_to_symtab out into two routines; made sure the string
- table was only readin once and the globals were only scanned once,
- for any number of dependencies.
-
-Thu May 18 19:59:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-*.h: Defined (or not, as appropriate per machine)
- BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and WORDS_BIG_ENDIAN.
-
-Wed May 17 13:37:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c (symbol_completion_function): Always complete on result
- command list, even if exact match found. If it's really an exact
- match, it'll find it again; if there's something longer than it,
- it'll get the right result.
-
- * symtab.c (make_symbol_completion_function): Fixed typo; strcmp
- ==> strncmp.
-
- * dbxread.c (read_dbx_symtab): Change 'G' case to mark symbols as
- LOC_EXTERNAL.
-
- * expread.y [variables]: Changed default type of text symbols to
- function returning int so that one can use, eg. strcmp.
-
- * infrun.c (wait_for_inferior): Include a special flag indicating
- that one shouldn't insert the breakpoints on the next step for
- returning from a sigtramp and forcing at least one move forward.
-
- * infrun.c (wait_for_inferior): Change test for nexting into a
- function to check for current stack pointer inner than previous
- stack pointer.
-
- * infrun.c (wait_for_inferior): Check for step resume break
- address before dealing with normal breakpoints.
-
- * infrun.c (wait_for_inferior): Added a case to deal with taking
- and passing along a signal when single stepping past breakpoints
- before inserting breakpoints.
-
- * infrun.c (wait_for_inferior): Inserted special case to keep
- going after taking a signal we are supposed to be taking.
-
-Tue May 16 12:49:55 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * inflow.c (terminal_ours_1): Cast result of signal to (int
- (*)()).
-
- * gdb.texinfo: Made sure that references to the program were in
- upper case. Modify description of the "set prompt" command.
- [Running]: Cleaned up introduction.
- [Attach]: Cleaned up.
- [Stepping]: Change "Proceed" to "Continue running" or "Execute".
- Minor cleanup.
- [Source Path]: Cleaned up intro. Cleared up distinction between
- the executable search path and the source path. Restated effect
- of the "directory" command with no arguments.
- [Data]: Fixed typos and trivial details.
- [Stepping]: Fixed up explanation of "until".
-
- * source.c (print_source_lines): Print through filter.
-
- * printcmd.c (x_command): If the format with which to print is
- "i", use the address of anything that isn't a pointer instead of
- the value. This is for, eg. "x/10i main".
-
- * gdb.texinfo: Updated last modification date on manual.
-
-Mon May 15 12:11:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symtab.c (lookup_symtab): Fixed typo (name ==> copy) in call to
- lookup_symtab_1.
-
- * gdb.texinfo: Added documentation for "break [+-]n" and for new
- actions of "directory" command (taking multiple directory names at
- the same time).
-
- * m68k-opcode.h: Replaced the version in gdb with an up-to-date
- version from the assembler directory.
- * m68k-pinsn.c (print_insn_arg): Added cases 'l' & 'L' to switch
- to print register lists for movem instructions.
-
- * dbxread.c, m-convex.h: Moved convex dependent include files over
- from dbxread.c to m-convex.h.
-
- * printcmd.c (disable_display, disable_display_command): Changed
- name of first to second, and created first which takes an int as
- arg rather than a char pointer. Changed second to use first.
- (_initialize_printcmd): Changed to use second as command to call.
- (delete_current_display, disable_current_display): Changed name of
- first to second, and changed functionality to match.
- * infrun.c (normal_stop), main.c (return_to_top_level): Changed to
- call disable_current_display.
-
- * dbxread.c (process_one_symbol, read_dbx_symtab): Changed N_FN to
- be N_FN | N_EXT to deal with new Berkeley define; this works with
- either the old or the new.
-
- * Remote_Makefile, remote_gutils.c, remote_inflow.c,
- remote_server.c, remote_utils.c: Created.
- * Makefile: Included in tag and tar files.
- * README: Included a note about them.
-
- * printcmd.c (print_address): Use find_pc_partial_function to
- remove need to readin symtabs for symbolic addresses.
-
- * source.c (directory_command): Replaced function with new one
- that can accept lists of directories seperated by spaces or :'s.
-
- * inflow.c (new_tty): Replaced calls to dup2 with calls to dup.
-
-Sun May 14 12:33:16 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * stack.c (args_info): Make sure that you have an inferior or core
- file before taking action.
-
- * ns32k-opcode.h [deiw, deid]: Fixed machine code values for these
- opcodes.
-
- * dbxread.c (scan_file_globals): Modified to use misc function
- vector instead of file itself. Killed all arguments to the
- funciton; no longer needed.
- (psymtab_to_symtab): Changed call for above to reflect new (void)
- argument list.
-
- * dbxread.c (read_dbx_symtab, ): Moved HASH_OFFSET define out of
- read_dbx_symtab.
-
- * expread.y [variable]: Changed default type of misc function in
- text space to be (void ()).
-
- * Makefile: Modified for proper number of s/r conflicts (order is
- confusing; the mod that necessitated this change was on May 12th,
- not today).
-
- * expread.y (yylex): Added SIGNED, LONG, SHORT, and INT keywords.
- [typename]: Created.
- [typebase]: Added rules for LONG, LONG INT, SHORT, SHORT INT,
- SIGNED name, and UNSIGNED name (a good approximation of ansi
- standard).
-
- * Makefile: Included .c.o rule to avoid sun's make from throwing
- any curves at us.
-
- * blockframe.c: Included <obstack.h>
-
- * command.c (lookup_cmd): Clear out trailing whitespace.
-
- * command.c (lookup_cmd_1): Changed malloc to alloca.
-
-Fri May 12 12:13:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * printcmd.c (print_frame_args): Only print nameless args when you
- know how many args there are supposed to be and when you've
- printed fewer than them. Don't print nameless args between
- printed args.
-
- * symtab.c (make_symbol_completion_function): Fixed typo (= ==>
- ==).
-
- * remote.c (remote_open): ifdef'd out siginterrupt call by #ifndef
- NO_SIGINTERRUPT.
- * m-umax.h: Defined NO_SIGINTERRUPT.
-
- * expread.y [ptype, array_mod, func_mod, direct_abs_decl,
- abs_decl]: Added rules for parsing and creating arbitrarily
- strange types for casts and sizeofs.
-
- * symtab.c, symtab.h (create_array_type): Created. Some minor
- misfeatures; see comments for details (main one being that you
- might end up creating two arrays when you only needed one).
-
-Thu May 11 13:11:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * valops.c (value_zero): Add an argument for type of lval.
- * eval.c (evaluate_subexp_for_address): Take address properly in
- the avoid side affects case (ie. keep track of whether we have an
- lval in memory and we can take the address).
- (evaluate_subexp): Set the lval type of expressions created with
- value_zero properley.
-
- * valops.c, value.h (value_zero): Created--will return a value of
- any type with contents filled with zero.
- * symtab.c, symtab.h (lookup_struct_elt_type): Created.
- * eval.c (evaluate_subexp): Modified to not read memory when
- called with EVAL_AVOID_SIDE_EFFECTS.
-
- * Makefile: Moved dbxread.c ahead of coffread.c in the list of
- source files.
-
-Wed May 10 11:29:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * munch: Make sure that sysv version substitutes for the whole
- line.
-
- * symtab.h: Created an enum misc_function_type to hold the type of
- the misc function being recorded.
- * dbxread.c (record_misc_function): Branched on dbx symbols to
- decide which type to assign to a misc function.
- * coffread.c (record_misc_function): Always assign type unknown.
- * expread.y [variable]: Now tests based on new values.
-
-Tue May 9 13:03:54 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symtab.c: Changed inclusion of <strings.h> (doesn't work on
- SYSV) to declaration of index.
-
- * Makefile: Changed last couple of READLINE_FLAGS SYSV_DEFINE
-
- * source.c ({forward, reverse}_search_command): Made a default
- search file similar to for the list command.
-
-Mon May 8 18:07:51 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * printcmd.c (print_frame_args): If we don't know how many
- arguments there are to this function, don't print the nameless
- arguments. We don't know enough to find them.
-
- * printcmd.c (print_frame_args): Call print_frame_nameless_args
- with proper arguments (start & end as offsets from addr).
-
- * dbxread.c (read_addl_syms): Removed cases to deal with global
- symbols; this should all be done in scan_global_symbols.
-
-Sun May 7 11:36:23 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * Makefile: Added copying.awk to ${OTHERS}.
-
-Fri May 5 16:49:01 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * valprint.c (type_print_varspec_prefix): Don't pass
- passed_a_pointer onto children.
-
- * valprint.c (type_print_varspec_suffix): Print "array of" with
- whatever the "of" is after tha array brackets.
-
- * valprint.c (type_print_varspec_{prefix,suffix}): Arrange to
- parenthesisze pointers to arrays as well as pointers to other
- objects.
-
- * valprint.c (type_print_varspec_suffix): Make sure to print
- subscripts of multi-dimensional arrays in the right order.
-
- * infcmd.c (run_command): Fixed improper usages of variables
- within remote debugging branch.
-
- * Makefile: Added Convex.notes to the list of extra files to carry
- around.
-
- * dbxread.c (symbol_file_command): Made use of alloca or malloc
- dependent on macro define.
-
-Thu May 4 15:47:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * Makefile: Changed READLINE_FLAGS to SYSV_DEFINE and called munch
- with it also.
- * munch: Check first argument for -DSYSV and be looser about
- picking up init routines if you find it.
-
- * coffread.c: Made fclose be of type int.
-
- * breakpoint.c (_initialize_breakpoint): Put "unset" into class
- alias.
-
-Wed May 3 14:09:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-sparc.h [STACK_END_ADDR]: Parameterized off of
- machine/vmparam.h (as per John Gilmore's suggestion).
-
- * blockframe.c (get_prev_frame_info): Changed this function back
- to checking frameless invocation first before checking frame
- chain. This means that a backtrace up from start will produce the
- wrong value, but that a backtrace from a frameless function called
- in main will show up correctly.
-
- * breakpoint.c (_initialize_breakpoint): Added entry in help for
- delete that indicates that unset is an alias for it.
-
- * main.c (symbol_completion_function): Modified recognition of
- being within a single command.
-
-Tue May 2 15:13:45 1989 Randy Smith (randy at gnu)
-
- * expread.y [variable]: Add some parens to get checking of the
- misc function vector right.
-
-Mon May 1 13:07:03 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * default-dep.c (core_file_command): Made reg_offset unsigned.
-
- * default-dep.c (core_file_command): Improved error messages for
- reading in registers.
-
- * expread.y: Allowed a BLOCKNAME to be ok for a variable name (as
- per C syntax).
-
- * dbxread.c (psymtab_to_symtab): Flushed stdout after printing
- starting message about reading in symbols.
-
- * printcmd.c (print_frame_args): Switched starting place for
- printing of frameless args to be sizeof int above last real arg
- printed.
-
- * printcmd.c (print_frame_args): Modified final call to
- print_nameless_args to not use frame slots used array if none had
- been used.
-
- * infrun.c (wait_for_inferior): Take FUNCTION_START_OFFSET into
- account when dealing with comparison of pc values to function
- addresses.
-
- * Makefile: Added note about compiling gdb on a Vax running 4.3.
-
-Sun Apr 30 12:59:46 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * command.c (lookup_cmd): Got correct error message on bad
- command.
-
- * m-sun3.h [ABOUT_TO_RETURN]: Modified to allow any of the return
- instructions, including trapv and return from interupt.
-
- * command.c (lookup_cmd): If a command is found, use it's values
- for error reporting and determination of needed subcommands.
-
- * command.c (lookup_cmd): Use null string for error if cmdtype is
- null; pass *line to error instead of **.
-
- * command.c (lookup_cmd_1): End of command marked by anything but
- alpha numeric or '-'. Included ctype.h.
-
-Fri Apr 28 18:30:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * source.c (select_source_symtab): Kept line number from ever
- being less than 1 in main decode.
-
-Wed Apr 26 13:03:20 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * default-dep.c (core_file_command): Fixed typo.
-
- * utils.c (fprintf_filtered): Don't use return value from
- numchars.
-
- * main.c, command.c (complete_on_cmdlist): Moved function to
- command.c.
-
- * command.c (lookup_cmd): Modified to use my new routine. Old
- version is still there, ifdef'd out.
-
- * command.c, command.h (lookup_cmd_1): Added a routine to do all
- of the work of lookup_cmd with no error reporting and full return
- of information garnered in search.
-
-Tue Apr 25 12:37:54 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * breakpoint.c (_initialize_breakpoint): Change "delete
- breakpionts" to be in class alias and not have the abbrev flag
- set.
-
- * main.c (symbol_completion_function): Fix to correctly complete
- things that correspond to multiword aliases.
-
- * main.c (complete_on_cmdlist): Don't complete on something if it
- isn't a command or prefix (ie. if it's just a help topic).
-
- * main.c (symbol_completion_function): Set list index to be 0 if
- creating a list with just one element.
-
- * main.c (complete_on_cmdlist): Don't allow things with
- abbrev_flag set to be completion values.
- (symbol_completion_function): Don't accept an exact match if the
- abbrev flag is set.
-
- * dbxread.c (read_type): Fixed typo in comparision to check if
- type number existed.
-
- * dbxread.c (read_type): Made sure to only call dbx_lookup_type on
- typenums if typenums were not -1.
-
-Mon Apr 24 17:52:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symtab.c: Added strings.h as an include file.
-
-Fri Apr 21 15:28:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symtab.c (lookup_partial_symtab): Changed to only return a match
- if the name match is exact (which is what I want in all cases in
- which this is currently used.
-
-Thu Apr 20 11:12:34 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * m-isi.h [REGISTER_U_ADDR]: Installed new version from net.
- * default-dep.c: Deleted inclusion of fcntl.h; apparently not
- necessary.
- * Makefile: Added comment about compiling on isi under 4.3.
-
- * breakpoint.c (break_command_1): Only give decode_line_1 the
- default_breakpoint_defaults if there's nothing better (ie. make
- the default be off of the current_source notes if at all
- possible).
-
- * blockframe.c (get_prev_frame_info): Clean up comments and
- delete code ifdefed out around FRAMELESS_FUNCTION_INVOCATION test.
-
- * remote.c: Added a "?" message to protocol.
- (remote_open): Used at startup.
- (putpkt): Read whatever garbage comes over the line until we see a
- '+' (ie. don't treat garbage as a timeout).
-
- * valops.c (call_function): Eliminated no longer appropriate
- comment.
-
- * infrun.c (wait_for_inferior): Changed several convex conditional
- compilations to be conditional on CANNOT_EXECUTE_STACK.
-
-Wed Apr 19 10:18:17 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * printcmd.c (print_frame_args): Added code to attempt to deal
- with arguments that are bigger than an int.
-
- Continuation of Convex/Fortran changes:
- * printcmd.c (print_scalar_formatted): Added leading zeros to
- printing of large integers.
- (address_info, print_frame_args): Added code to deal with
- LOC_REF_ARG.
- (print_nameless_args): Allow param file to specify a routine with
- which to print typeless integers.
- (printf_command): Deal with long long values well.
- * stack.c (print_frame_arg_vars): Change to deal with LOC_REF_ARG.
- * symmisc.c (print_symbol): Change to deal with LOC_REF_ARG.
- * symseg.h: Added LOC_REF_ARG to enum address_class.
- * symtab.c (lookup_block_symbol): Changed to deal with
- LOC_REF_ARG.
- * valarith.c (value_subscripted_rvalue): Created.
- (value_subscript): Used above when app.
- (value_less, value_equal): Change to cast to (char *) before doing
- comparison, for machines where that casting does something.
- * valops.c (call_function): Setup to deal with machines where you
- cannot execute code on the stack segment.
- * valprint.c (val_print): Make sure that array element size isn't
- zero before printing. Set address of default array to address of
- first element. Put in a couple of int cast. Removed some convex
- specific code. Added check for endianness of machine in case of a
- packed structure. Added code for printing typeless integers and
- for LONG LONG's.
- (set_maximum_command): Change to use parse_and_eval_address to get
- argument (so can use expressions there).
- * values.c (value_of_internalvar, set_internalvar_component,
- set_internalvar, convenience_info): Add in hooks for trapped
- internal vars.
- (unpack_long): Deal with LONG_LONG.
- (value_field): Remove LONGEST cast.
- (using_struct_return): Fixed typo ENUM ==> UNION.
- * xgdb.c (_initialize_xgdb): Make sure that specify_exec_file_hook
- is not called unless we are setting up a windowing environ.
-
-Tue Apr 18 13:43:37 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- Various changes involved in 1) getting gdb to work on the convex,
- and 2) Getting gdb to work with fortran (due to convex!csmith):
- * convex-dep.c, convex-opcode.h, m-convex.h, convex-pinsn.c:
- Created (or replaced with new files).
- * Makefile: Add convex dependent files. Changed default flags to
- gnu malloc to be CFLAGS.
- * config.gdb: Added convex to list of machines.
- * core.c (files_info): Added a FILES_INFO_HOOK to be used if
- defined.
- (xfer_core_file): Conditionalized compilation of xfer_core_file on
- the macro XFER_CORE_FILE.
- * coffread.c (record_misc_function): Made sure it zerod type field
- (which is now being used; see next).
- * dbxread.c: Included some convex dependent include files.
- (copy_pending, fix_common_blocks): Created.
- [STAB_REG_REGNUM, BELIEVE_PCC_PROMOTION]: Created default values;
- may be overridden in m-*.h.
- Included data structures for keeping track of common blocks.
- (dbx_alloc_type): Modified; if called with negative 1's will
- create a type without putting it into the type vector.
- (read_dbx_symtab, read_addl_syms): Modified calls to
- record_misc_function to include the new information.
- (symbol_file_command, psymtab_to_symtab, add_file_command):
- Modified reading in of string table to adapt to machines which
- *don't* store the size of the string table in the first four bytes
- of the string table.
- (read_dbx_symtab, scan_file_globals, read_ofile_symtab,
- read_addl_syms): Modified assignment of namestring to accept null
- index into symtab as ok.
- (read_addl_syms): Modified readin of a new object file to fiddle
- with common blocks correctly.
- (process_one_symbol): Fixed incorrect comment about convex. Get
- symbols local to a lexical context from correct spot on a per
- machine basis. Catch a bug in pcc which occaisionally puts an SO
- where there should be an SOL. Seperate sections for N_BCOMM &
- N_ECOMM.
- (define_symbol): Ignore symbols with no ":". Use
- STAB_REG_TO_REGNUM. Added support for function args calling by
- reference.
- (read_type): Only read type number if one is there. Remove old
- (#if 0'd out) array code.
- (read_array_type): Added code for dealing with adjustable (by
- parameter) arrays half-heartedly.
- (read_enum_type): Allow a ',' to end a list of values.
- (read_range_type): Added code to check for long long.
- * expread.y: Modified to use LONGEST instead of long where
- necessary. Modified to use a default type of int for objects that
- weren't in text space.
- * findvar.c (locate_var_value, read_var_value): Modified to deal
- with args passed by reference.
- * inflow.c (create_inferior): Used CREATE_INFERIOR_HOOK if it
- exists.
- * infrun.c (attach_program): Run terminal inferior when attaching.
- (wait_for_inferior): Removed several convex dependencies.
- * main.c (float_handler): Created.
- Made whatever signal indicates a stop configurable (via macro
- STOP_SIGNAL).
- (main): Setup use of above as a signal handler. Added check for
- "-nw" in args already processed.
- (command_line_input): SIGTSTP ==>STOP_SIGNAL.
-
- * expread.y: Added token BLOCKNAME to remove reduce/reduce
- conflict.
- * Makefile: Change message to reflect new grammar.
-
-Mon Apr 17 13:24:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * printcmd.c (compare_ints): Created.
- (print_frame_args): Modified to always print arguments in the
- order in which they were found in the symbol table. Figure out
- what apots are missing on the fly.
-
- * stack.c (up_command): Error if no inferior or core file.
-
- * m-i386.h, m-symmetry.h [FRAMELESS_FUNCTION_INVOCATION]: Created;
- same as m68k.
-
- * dbxread.c (define_symbol): Changed "desc==0" test to
- "processing_gcc_compilation", which is the correct way to do it.
-
-Sat Apr 15 17:18:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * expread.y: Added precedence rules for arglists, ?:, and sizeof
- to eliminate some shift-reduce conflicts.
- * Makefile: Modified "Expect" message to conform to new results.
-
-Thu Apr 13 12:29:26 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * inflow.c (terminal_init_inferior): Fixed typo in recent diff
- installation; TIOGETC ==> TIOCGETC.
-
- * m-vax.h, m-sun2.h, m-sun3.h, m-sparc.h, m-hp*.h, m-isi.h,
- m-news.h [FRAMELESS_FUNCTION_INVOCATION]: Created macro with
- appropriate definition.
-
-Wed Apr 12 15:30:29 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * blockframe.c (get_prev_frame_info): Added in a macro to specify
- when a "frame" is called without a frame pointer being setup.
-
- * Makefile [clean]: Made sure to delete gnu malloc if it was being
- used.
-
-Mon Apr 10 12:43:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (process_one_symbol): Reset within_function to 0 after
- last RBRAC of a function.
-
- * dbxread.c (read_struct_type): Changed check for filling in of
- TYPE_MAIN_VARIANT of type.
-
- * inflow.c (create_inferior): Conditionalized fork so that it
- would be used if USG was defined and HAVE_VFORK was not defined.
-
- * defs.h: Added comment about enum command_class element
- class_alias.
-
- * dbxread.c (process_one_symbol): Fixed a typo with interesting
- implications for associative processing in the brain (':' ==> 'c').
-
- * sparc-dep.c (isabranch): Changed name to isannulled, modified to
- deal with coprocessor branches, and improved comment.
- (single_step): Changed to trap at npc + 4 instead of pc +8 on
- annulled branches. Changed name in call to isabranch as above.
-
- * m-sun4os4.h (STACK_END_ADDRESS): Changed it to 0xf8000000 under
- os 4.0.
-
-Sat Apr 8 17:04:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (process_one_symbol): In the case N_FUN or N_FNAME the
- value being refered to is sometimes just a text segment variable.
- Catch this case.
-
- * infrun.c (wait_for_inferior), breakpoint.c
- (breakpoint_stop_status): Move the selection of the frame to
- inside breakpoint_stop_status so that the frame only gets selected
- (and the symbols potentially read in) if the symbols are needed.
-
- * symtab.c (find_pc_psymbol): Fixed minor misthough (pc >=
- fucntion start, not >).
-
- * breakpoint.c (_initialize_breakpoint): Change "delete" internal
- help entry to simply refer to it being a prefix command (since the
- list of subcommands is right there on a "help delete").
-
-Fri Apr 7 15:22:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * blockframe.c (find_pc_partial_function): Created; figures out
- what function pc is in (name and address) without reading in any
- new symbols.
- * symtab.h: Added decl for above.
- * infrun.c (wait_for_inferior): Used instead of
- find_pc_function_start.
- * stack.c (print_frame_info): Used instead of hand coding for same
- thing.
-
- * dbxread.c (psymtab_to_symtab): No longer patch readin pst's out
- of the partial_symtab_list; need them there for some checks.
- * blockframe.c (block_for_pc), source.c (select_source_symtab),
- symtab.c (lookup_symbol, find_pc_symtab, list_symbols): Made extra
- sure not to call psymtab_to_symtab with ->readin == 1, since these
- psymtab now stay on the list.
- * symtab.c (sources_info): Now distinguishes between psymtabs with
- readin set and those with it not set.
-
- * symtab.c (lookup_symtab): Added check through partial symtabs
- for name with .c appended.
-
- * source.c (select_source_symtab): Changed semantics a little so
- that the argument means something.
- * source.c (list_command), symtab.c (decode_line_1): Changed call
- to select_source_symtab to match new conventions.
-
- * dbxread.c (add_file_command): This command no longer selects a
- symbol table to list from.
-
- * infrun.c (wait_for_inferior): Only call find_pc_function (to
- find out if we have debugging symbols for a function and hence if
- we should step over or into it) if we are doing a "step".
-
-Thu Apr 6 12:42:28 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c (command_line_input): Added a local buffer and only
- copied information into the global main.c buffer when it is
- appropriate for it to be saved (and repeated).
- (dont_repeat): Only nail line when we are reading from stdin
- (otherwise null lines won't repeat and what's in line needs to be
- saved).
- (read_command_lines): Fixed typo; you don't what to repeat when
- reading command lines from the input stream unless it's standard
- input.
-
- John Gilmore's (gnu@toad.com) mods for USG gdb:
- * inflow.c: Removed inclusion of sys/user.h; no longer necessary.
- (, terminal_init_inferior, terminal_inferior, terminal_ours_1,
- term_status_command, _initialize_inflow) Seperated out declaration
- and usage of terminal mode structures based on the existence of
- the individual ioctls.
- * utils.c (request_quit): Restore signal handler under USG. If
- running under USG initialize sys_siglist at run time (too much
- variation between systems).
-
-Wed Apr 5 13:47:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- John Gilmore's (gnu@toad.com) mods for USG gdb:
- * default-dep.c: Moved include of sys/user.h to after include of
- a.out.h.
- (store_inferior_registers): Fixed error message.
- (core_file_command): Improved error messages from reading in of
- u area in core file. Changed calculation of offset of registers
- to account for some machines putting it in as an offset rather
- than an absolute address. Changed error messages for reading of
- registers from core file.
-
- * coffread.c (read_file_hdr): Added final check for BADMAG macro
- to use if couldn't recognize magic number.
- * Makefile: Added explicit directions for alloca addition.
- Included alloca.c in list of possible library files. Cleaned up
- possible library usage. Included additional information on gcc
- and include files.
-
- * source.c, remote.c, inflow.c, dbxread.c, core.c, coffread.c:
- Changed include of sys/fcntl.h to an include of fcntl.h (as per
- posix; presumably this will break fewer machines. I hopw).
- * README: Added a pointer to comments at top of Makefile.
- * Makefile: Added a comment about machines which need fcntl.h in
- sys.
-
-Tue Apr 4 11:29:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * valprint.c (set_prettyprint_command, set_unionprint_command,
- format_info): Created.
- (_initialize_valprint): Added to lists of commands.
-
- * gdb.texinfo [Backtrace]: Added a section describing the format
- if symbols have not yet been read in.
-
- * valprint.c (val_print): Added code to prettyprint structures if
- "prettyprint" is set and only to print unions below the top level
- if "unionprint" is set.
-
- * infcmd.c (registers_info), valprint.c (value_print, val_print):
- Added argument to call to val_print indicating deptch of recursion.
-
- * symtab.[ch] (find_pc_psymbol): Created; finds static function
- psymbol with value nearest to but under value passed.
- * stack.c (print_frame_info): Used above to make sure I have best
- fit to pc value.
-
- * symseg.h (struct partial_symbol): Added value field.
- * dbxread.c (read_dbx_symtab): Set value field for partial symbols
- saved (so that we can lookup static symbols).
-
- * symtab.[ch] (find_pc_symtab): Changed to external.
- * stack.c (select_frame): Call above to make sure that symbols for
- a selected frame is readin.
-
-Mon Apr 3 12:48:16 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * stack.c (print_frame_info): Modified to only print out full
- stack frame info on symbols whose tables have been read in.
- * symtab.c, symtab.h (find_pc_psymtab): Made function external;
- above needed it.
-
- * main.c (,set_verbose_command, initialize_main): Created a
- variable "info_verbose" which says to talk it up in various and
- sundry places. Added command to set this variable.
- * gdb.texinfo (GDB Output): Added documentation on "set verbose"
- and changed the name of the "Screen Output" section to "GDB
- Output".
- * dbxread.c (psymtab_to_symtab): Added information message about
- symbol readin. Conditionalized on above.
-
- * dbxread.c (define_symbol): Made an "i" constant be of class
- LOC_CONST and an "r" constant be of class LOC_CONST_BYTES.
-
- * README: Made a note about modifications which may be necessary
- to the manual for this version of gdb.
-
- * blockframe.c (get_prev_frame_info): Now we get saved address and
- check for validity before we check for leafism. This means that
- we will catch the fact that we are in start, but we will miss any
- fns that start calls without an fp. This should be fine.
-
- * m-*.h (FRAME_CHAIN): Modified to return 0 if we are in start.
- This is usually a test for within the first object file.
- * m-sparc.h (FRAME_CHAIN): The test here is simply if the fp saved
- off the the start sp is 0.
-
- * blockframe.c (get_prev_frame_info): Removed check to see if we
- were in start. Screws up sparc.
-
- * m-sparc.h (FRAME_FIND_SAVED_REGISTERS): Changed test for dummy
- frame to not need frame to be innermost.
-
- * gdb.texinfo: Added section on frameless invocations of functions
- and when gdb can and can't deal with this.
-
- * stack.c (frame_info): Disallowed call if no inferior or core
- file; fails gracefully if truely bad stack specfication has been
- given (ie. parse_frame_specification returns 0).
-
-Fri Mar 31 13:59:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * infrun.c (normal_stop): Changed references to "unset-env" to
- "delete env".
-
- * infcmd.c (_initialize_infcmd): Change reference to set-args in
- help run to "set args".
-
- * remote.c (getpkt): Allow immediate quit when reading from
- device; it could be hung.
-
- * coffread.c (process_coff_symbol): Modify handling of REG
- parameter symbols.
-
-Thu Mar 30 15:27:23 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (symbol_file_command): Use malloc to allocate the
- space for the string table in symbol_file_command (and setup a
- cleanup for this). This allows a more graceful error failure if
- there isn't any memory availible (and probably allows more memory
- to be avail, depending on the machine).
-
- Additional mods for handling GNU C++ (from Tiemann):
- * dbxread.c (read_type): Added case for '#' type (method type, I
- believe).
- (read_struct_type): If type code is undefined, make the main
- variant for the type be itself. Allow recognition of bad format
- in reading of structure fields.
- * eval.c (evaluate_subexp): Modify evaluation of a member of a
- structure and pointer to same to make sure that the syntax is
- being used correctly and that the member is being accessed correctly.
- * symseg.h: Added TYPE_CODE_METHOD to enum type_code. Add a
- pointer to an array of argument types to the type structure.
- * symtab.c (lookout_method_type, smash_to_method_type): Created.
- * symtab.h (TYPE_ARG_TYPES): Created.
- * valops.c (call_function): Modified handling of methods to be the
- same as handling of functions; no longer check for members.
- * valprint.c (val_print, type_print_varspec_{prefix,suffix},
- type_print_base): Added code to print method args correctly.
- * values.c (value_virtual_fn_field): Modify access to virtual
- function table.
-
-Wed Mar 29 13:19:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * findvar.c: Special cases for REGISTER_WINDOWS: 1) Return 0 if we
- are the innermost frame, and 2) return the next frame in's value
- if the SP is being looked for.
-
- * blockframe.c (get_next_frame): Created; returns the next (inner)
- frame of the called frame.
- * frame.h: Extern delcaration for above.
-
- * main.c (command_line_input): Stick null at end before doing
- history expansion.
-
-Tue Mar 28 17:35:50 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab): Added namestring assignment to
- N_DATA/BSS/ABS case. Sigh.
-
-Sat Mar 25 17:49:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * expread.y: Defined YYDEBUG.
-
-Fri Mar 24 20:46:55 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symtab.c (make_symbol_completion_list): Completely rewrote to
- never call psymtab_to_symtab, to do a correct search (no
- duplicates) through the visible symbols, and to include structure
- and union fields in the things that it can match.
-
-Thu Mar 23 15:27:44 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (dbx_create_type): Created; allocates and inits space
- for a type without putting it on the type vector lists.
- (dbx_alloc_type): Uses above.
-
- * Makefile: xgdb.o now produced by default rules for .o.c.
-
-Fri Mar 17 14:27:50 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * infrun.c: Fixed up inclusion of aouthdr.h on UMAX_PTRACE.
-
- * Makefile, config.gdb: Added hp300bsd to potential
- configurations.
- * hp300bsd-dep.c, m-hp300bsd.h: Created.
-
- * infrun.c (wait_for_inferior): Rewrote to do no access to
- inferior until we make sure it's still there.
-
- * inflow.c (inferior_died): Added a select to force the selected
- frame to null when inferior dies.
-
- * dbxread.c (symbol_file_command): free and zero symfile when
- discarding symbols.
-
- * core.c (xfer_core_file): Extended and cleaned up logic in
- interpeting memory address.
-
- * core.c (xfer_core_file): Extended opening comment.
-
-Thu Mar 16 15:39:42 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * coffread.c (symbol_file_command): Free symfile name when freeing
- contents.
-
- * blockframe.c (get_prev_frame_info): Added to fatal error message
- to indicate that it should never happen.
-
- * stack.c (frame_info): Printed out value of "saved" sp seperately
- to call attention to the fact that it isn't stored in memory
- anywhere; the actual previous frames address is printed.
-
- * m-sparc.h (FRAME_FIND_SAVED_REGS): Set address of sp saved in
- frame to value of fp (rather than value of sp in current frame).
-
- * expread.y: Allow "unsigned" as a type itself, as well as a type
- modifier.
-
- * coffread.c: Added declaration for fclose
-
-Fri Mar 10 17:22:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c (command_line_input): Checked for -1 return from
- readline; indicates EOF.
-
-Fri Mar 3 00:31:27 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * remote.c (remote_open): Cast return from signal to (void (*)) to
- avoid problems on machines where the return type of signal is (int
- (*)).
-
- * Makefile: Removed deletion of version control from it (users
- will need it for their changes).
-
-Thu Mar 2 15:32:21 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symmetry-dep.c (print_1167_regs): Print out effective doubles on
- even number regs.
- (fetch_inferior_registers): Get the floating point regs also.
-
- * xgdb.c (do_command): Copied command before calling execute
- command (so that execute_command wouldn't write into text space).
-
- * copying.awk: Created (will produce copying.c as output when
- given COPYING as input).
- * Makefile: Used above to create copying.c.
- * main.c: Took out info_warranty and info_copying.
-
- * *.*: Changed copyright notice to use new GNU General Public
- License (includes necessary changes to manual).
-
- * xgdb.c (create_text_widget): Created text_widget before I create
- the source and sink.
- (print_prompt): Added fflush (stdout).
-
- * Makefile: Added -lXmu to the compilation line for xgdb. Left
- the old one there incase people still had R2.
-
- * README: Added note about -gg format.
-
- * remote.c (getpkt): Fixed typo; && ==> &.
-
- * Makefile: Added new variable READLINE_FLAGS so that I could
- force compilation of readline.c and history.c with -DSYSV on
- system V machines. Mentioned in Makefile comments at top.
-
-Wed Mar 1 17:01:01 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * hp9k320-dep.c (store_inferior_registers): Fixed typo.
-
-Fri Feb 24 14:58:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * hp9k320-dep.c (store_inferior_registers,
- fetch_inferior_registers): Added support for remote debugging.
-
- * remote.c (remote_timer): Created.
- (remote_open, readchar): Setup to timeout reads if they take
- longer than "timeout". This allows one to debug how long such
- things take.
- (putpkt): Modified to print a debugging message (if such things
- are enabled) each time it resends a packet.
- (getpkt): Modified to make the variable CSUM unsigned and read it
- CSUM with an & 0xff (presumably to deal with poor sign extension
- on some machines). Also made c1 and c2 unsigned.
- (remote_wait): Changed buffer to unsigned status.
- (remote_store_registers, remote_write_bytes): Puts a null byte at
- the end of the control string.
-
- * infcmd.c (attach_command, detach_command, _initialize_infcmd):
- Made attach_command and detach_command always availible, but
- modified them to only allow device file attaches if ATTACH_DETACH
- is not defined.
-
- * gdb.texinfo: Added cross reference from attach command to remote
- debugging.
-
-Thu Feb 23 12:37:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * remote.c (remote_close): Created to close the remote connection
- and set the remote_debugging flag to 0.
- * infcmd.c (detach_command): Now calls the above when appropriate.
-
- * gdb.texinfo: Removed references to the ``Distribution'' section
- in the copyright.
-
- * main.c, utils.c (ISATTY): Created default defintions of this
- macro which use isatty and fileno.
- * utils.c (fprintf_filtered, print_spaces_filtered), main.c
- (command_loop, command_line_input): Used this macro.
- * m-news.h: Created a definition to override this one.
-
- * utils.c (fprintf_filtered): Made line_size static (clueless).
-
- * utils.c (fprintf_filtered): Changed max length of line printed
- to be 255 chars or twice the format length.
-
- * symmetry-dep.c, m-symmetry: Fixed typo (^L ==> ).
-
- * printcmd.c (do_examine): Fixed typo (\n ==> \t).
-
-Wed Feb 22 16:00:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- Contributed by Jay Vosburgh (jay@mentor.cc.purdue.edu)
- * m-symmetry.h, symmetry-dep.c: Created.
- * Makefile: Added above in appropriate lists.
- * config.gdb: Added "symmetry" target.
-
- * utils.c (prompt_for_continue): Zero'd chars_printed also.
-
- * utils.c (fprintf_filtered): Call prompt for continue instead of
- doing it yourself.
-
- * dbxread.c (read_dbx_symtab): Added code to conditionalize what
- symbol type holds to "x.o" or "-lx" symbol that indicates the
- beginning of a new file.
-
-Tue Feb 21 16:22:13 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * gdb.texinfo: Deleted @ignore block at end of file.
-
- * findvar.c, stack.c: Changed comments that refered to "frame
- address" to "frame id".
-
- * findvar.c (locate_var_value): Modified so that taking the
- address of an array generates an object whose type is a pointer to
- the elements of the array.
-
-Sat Feb 18 16:35:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * gdb.texinfo: Removed reference to "!" as a shell escape
- character. Added a section on controling screen output
- (pagination); changing "Input" section to "User Interface"
- section. Changed many inappropriate subsubsection nodes into
- subsections nodes (in the readline and history expansion
- sections).
-
-Fri Feb 17 11:10:54 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * utils.c (set_screensize_command): Created.
- (_initialize_utils): Added above to setlist.
-
- * main.c (main): Added check to see if ~/.gdbinit and .gdbinit
- were the same file; only one gets read if so. Had to include
- sys/stat.h for this.
-
- * valprint.c (type_print_base): Changed calls to print_spaces to
- print_spaces_filtered.
-
- * main.c (command_line_input): Chaned test for command line
- editing to check for stdin and isatty.
-
- * main.c (command_loop): Call reinitialize_more_filter before each
- command (if reading from stdin and it's a tty).
- utils.c (initialize_more_filter): Changed name to
- reinitialize_more_filter; killed arguments.
- utils.c (_initialize_utils): Created; initialized lines_per_page
- and chars_per_line here.
-
- * utils.c (fprintf_filtered): Removed printing of "\\\n" after
- printing linesize - 1 chars; assume that the screen display will
- take care of that. Still watching that overflow.
-
- * main.c: Created the global variables linesize and pagesize to
- describe the number of chars per line and lines per page.
-
-Thu Feb 16 17:27:43 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * printcmd.c (do_examine, print_scalar_formatted, print_address,
- whatis_command, do_one_display, ptype_command), valprint.c
- (value_print, val_print, type_print_method_args, type_print_1,
- type_print_derivation_info, type_print_varspec_suffix,
- type_print_base), breakpoint.c (breakpoints_info, breakpoint_1),
- values.c (history_info), main.c (editing_info, warranty_info,
- copying_info), infcmd.c (registers_info), inflow.c
- (term_status_command), infrun.c (signals_info), stack.c
- (backtrace_command, print_frame_info), symtab.c (list_symbols,
- output_source_filename), command.c (help_cmd, help_list,
- help_command_list): Replaced calls to printf, fprintf, and putc
- with calls to [f]printf_filtered to handle more processing.
- Killed local more emulations where I noticed them.
-
-Wed Feb 15 15:27:36 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * defs.h, utils.c (initialize_more_filter, fprintf_filtered,
- printf_filtered): Created a printf that will also act as a more
- filter, prompting the user for a <return> whenever the page length
- is overflowed.
-
- * symtab.c (list_symbols): Elminated some code inside of an #if 0.
-
-Tue Feb 14 11:11:24 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * Makefile: Turned off backup versions for this file; it changes
- too often.
-
- * command.c (lookup_cmd, _initialize_command): Changed '!' so that
- it was no longer a shell escape. "sh" must be used.
-
- * main.c (command_line_input, set_history_expansion,
- initialize_main): Turned history expansion on, made it the
- default, and only execute it if the first character in the line is
- a '!'.
-
- * version.c, gdb.texinfo: Moved version to 3.2 (as usual, jumping
- the gun some time before release).
-
- * gdb.texinfo: Added sections (adapted from Brian's notes) on
- command line editing and history expansion.
-
- * main.c (set_command_editing, initialize_main): Modified name to
- set_editing and modified command to "set editing".
-
- * Makefile: Put in dependencies for READLINEOBJS.
-
- * main.c (history_info, command_info): Combined into new command
- info; deleted history_info.
- (initialize_main): Deleted "info history" command; it was
- interfering with the value history.
-
- * coffread.c (enter_linenos): Modified to do bit copy instead of
- pointer dereference, since the clipper machine can't handle having
- longs on short boundaries.
- (read_file_hdr): Added code to get number of syms for clipper.
-
- * stack.c (return_command): Fixed method for checking when all of
- the necessary frames had been popped.
-
- * dbxread.c (read_dbx_symtab (ADD_PSYMBOL_TO_LIST)): Fixed typo in
- allocation length.
-
-Mon Feb 13 10:03:27 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab): Split assignment to namestring into
- several different assignments (so that it wouldn't be done except
- when it had to be). Shortened switches and duplicated code to
- produce the lowest possible execution time. Commented (at top of
- switch) which code I duplicated.
-
- * dbxread.c (read_dbx_symtab): Modified which variables were
- register and deleted several variables which weren't used. Also
- eliminated 'F' choice from subswitch, broke out strcmp's, reversed
- compare on line 1986, and elminated test for !namestring[0]; it is
- caught by following test for null index of ':'.
-
-Sun Feb 12 12:57:56 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * main.c (gdb_completer_word_break_characters): Turned \~ into ~.
-
-Sat Feb 11 15:39:06 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * symtab.c (find_pc_psymtab): Created; checks all psymtab's till
- it finds pc.
- (find_pc_symtab): Used; fatal error if psymtab found is readin
- (should have been caught in symtab loop).
- (lookup_symbol): Added check before scan through partial symtab
- list for symbol name to be on the misc function vector (only if in
- VAR_NAMESPACE). Also made sure that psymtab's weren't fooled with
- if they had already been read in.
- (list_symbols): Checked through misc_function_vector for matching
- names if we were looking for functions.
- (make_symbol_completion_list): Checked through
- misc_function_vector for matching names.
- * dbxread.c (read_dbx_symtab): Don't bother to do processing on
- global function types; this will be taken care of by the
- misc_function hack.
-
- * symtab.h: Modified comment on misc_function structure.
-
-Fri Feb 10 18:09:33 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * symseg.h, dbxread.c (read_dbx_symtab, init_psymbol_list,
- start_psymtab, end_psymtab), coffread.c (_initialize_coff),
- symtab.c (lookup_partial_symbol, list_symbols,
- make_symbol_completion_list): Changed separate variables for
- description of partial symbol allocation into a specific kind of
- structure.
-
- (read_dbx_symtab, process_symbol_for_psymtab): Moved most of
- process_symbol_for_psymtab up into read_dbx_symtab, moved a couple
- of symbol types down to the ingore section, streamlined (I hope)
- code some, modularized access to psymbol lists.
-
-Thu Feb 9 13:21:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c (command_line_input): Made sure that it could recognize
- newlines as indications to repeat the last line.
-
- * symtab.c (_initialize_symtab): Changed size of builtin_type_void
- to be 1 for compatibility with gcc.
-
- * main.c (initialize_main): Made history_expansion the default
- when gdb is compiled with HISTORY_EXPANSION.
-
- * readline.c, readline.h, history.c, history.h, general.h,
- emacs_keymap.c, vi_keymap.c, keymaps.c, funmap.c: Made all of
- these links to /gp/gnu/bash/* to keep them updated.
- * main.c (initialize_main): Made default be command editing on.
-
-Wed Feb 8 13:32:04 1989 & Smith (randy at hobbes)
-
- * dbxread.c (read_dbx_symtab): Ignore N_BSLINE on first
- readthrough.
-
- * Makefile: Removed convex-dep.c from list of distribution files.
-
-Tue Feb 7 14:06:25 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c: Added command lists sethistlist and unsethistlist to
- accesible command lists.
- (parse_binary_operation): Created to parse a on/1/yes vs. off/0/no
- spec.
- (set_command_edit, set_history, set_history_expansion,
- set_history_write, set_history_size, set_history_filename,
- command_info, history_info): Created to allow users to control
- various aspects of command line editing.
-
- * main.c (symbol_creation_function): Created.
- (command_line_input, initialize_main): Added rest of stuff
- necessary for calling bfox' command editing routines under
- run-time control.
- * Makefile: Included readline and history source files for command
- editing; also made arrangements to make sure that the termcap
- library was available.
- * symtab.c (make_symbol_completion_list): Created.
-
-Mon Feb 6 16:25:25 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c: Invented variables to control command editing.
- command_editing_p, history_expansion_p, history_size,
- write_history_p, history_filename. Initialized them to default
- values in initialize_main.
-
- * infcmd.c (registers_info), infrun.c (signals_info),
- * main.c (gdb_read_line): Changed name to command_line_input.
- (readline): Changed name to gdb_readline; added second argument
- indicating that the read value shouldn't be saved (via malloc).
- * infcmd.c (registers_info), infrun.c (signals_info), main.c
- (copying_info), symtab.c (output_source_filename, MORE,
- list_symbols): Converted to use gdb_readline in place of
- gdb_read_line.
-
-
-Sun Feb 5 17:34:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * blockframe.c (get_frame_saved_regs): Removed macro expansion
- that had accidentally been left in the code.
-
-Sat Feb 4 17:54:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * main.c (gdb_read_line, readline): Added function readline and
- converted gdb_read_line to use it. This was a conversion to the
- line at a time style of input, in preparation for full command
- editing.
-
-Fri Feb 3 12:39:03 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab): Call end_psymtab at the end of
- read_dbx_symtab if any psymtab still needs to be completed.
-
- * config.gdb, sun3-dep.c: Brought these into accord with the
- actual sun2 status (no floating point period; sun3-dep.c unless
- has os > 3.0).
- * m-sun2os2.h: Deleted; not needed.
-
- * config.gdb: Added a couple of aliases for machines in the
- script.
-
- * infrun.c: Added inclusion of aouthdr.h inside of #ifdef UMAX
- because ptrace needs to know about the a.out header.
-
- * Makefile: Made dep.o depend on dep.c and config.status only.
-
- * expread.y: Added declarations of all of the new write_exp_elt
- functions at the include section in the top.
-
- * Makefile: Added a YACC definition so that people can use bison
- if they wish.
-
- * Makefile: Added rms' XGDB-README to the distribution.
-
- * Makefile: Added removal of init.o on a "make clean".
-
-Thu Feb 2 16:27:06 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * *-dep.c: Deleted definition of COFF_FORMAT if AOUTHDR was
- defined since 1) We *may* (recent mail message) want to define
- AOUTHDR under a basically BSD system, and 2) AOUTHDR is sometimes
- a typedef in coff encapsulation setups. Also removed #define's of
- AOUTHDR if AOUTHDR is already defined (inside of coff format).
- * core.c, dbxread.c: Removed #define's of AOUTHDR if AOUTHDR is
- already defined (inside of coff format).
-
-Tue Jan 31 12:56:01 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * GDB 3.1 released.
-
- * values.c (modify_field): Changed test for endianness to assign
- to integer and reference character (so that all bits would be
- defined).
-
-Mon Jan 30 11:41:21 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * news-dep.c: Deleted inclusion of fcntl.h; just duplicates stuff
- found in sys/file.h.
-
- * i386-dep.c: Included default definition of N_SET_MAGIC for
- COFF_FORMAT.
-
- * config.gdb: Added checks for several different operating
- systems.
-
- * coffread.c (read_struct_type): Put in a flag variable so that
- one could tell when you got to the end of a structure.
-
- * sun3-dep.c (core_file_command): Changed #ifdef based on SUNOS4
- to ifdef based on FPU.
-
- * infrun.c (restore_inferior_status): Changed error message to
- "unable to restore previously selected frame".
-
- * dbxread.c (read_dbx_symtab): Used intermediate variable in error
- message reporting a bad symbol type. (scan_file_globals,
- read_ofile_symtab, read_addl_syms): Data type of "type" changed to
- unsigned char (which is what it is).
- * i386-dep.c: Removed define of COFF_FORMAT if AOUTHDR is defined.
- Removed define of a_magic to magic (taken care of by N_MAGIC).
- (core_file_command): Zero'd core_aouthdr instead of setting magic
- to zero.
- * i386-pinsn.c: Changed jcxz == jCcxz in jump table.
- (putop): Added a case for 'C'.
- (OP_J): Added code to handle possible masking of PC value on
- certain kinds of data.
- m-i386gas.h: Moved COFF_ENCAPSULATE to before inclusion of
- m-i386.h and defined NAMES_HAVE_UNDERSCORE.
-
- * coffread.c (unrecrod_misc_function, read_coff_symtab): Added
- symbol number on which error occured to error output.
-
-Fri Jan 27 11:55:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * Makefile: Removed init.c in make clean. Removed it without -f
- and with leading - in make ?gdb.
-
-Thu Jan 26 15:08:03 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- Changes to get it to work on gould NP1.
- * dbxread.c (read_dbx_symtab): Included cases for N_NBDATA and
- N_NBBSS.
- (psymtab_to_symtab): Changed declaration of hdr to
- DECLARE_FILE_HEADERS. Changed access to use STRING_TABLE_SIZE and
- SYMBOL_TABLE_SIZE.
- * gld-pinsn.c (findframe): Added declaration of framechain() as
- FRAME_ADDR.
-
- * coffread.c (read_coff_symtab): Avoided treating typedefs as
- external symbol definitions.
-
-Wed Jan 25 14:45:43 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * Makefile: Removed reference to alloca.c. If they need it, they
- can pull alloca.o from the gnu-emacs directory.
-
- * version.c, gdb.texinfo: Updated version to 3.1 (jumping the gun
- a bit so that I won't forget when I release).
-
- * m-sun2.h, m-sun2os2.h, m-sun3os4.h, config.gdb: Modified code so
- that default includes new sun core, ptrace, and attach-detach.
- Added defaults for sun 2 os 2.
-
- Modifications to reset stack limit back to what it used to be just
- before exec. All mods inside of #ifdef SET_STACK_LIMIT_HUGE.
- * main.c: Added global variable original_stack_limit.
- (main): Set original_stack_limit to original stack limit.
- * inflow.c: Added inclusion of necessary files and external
- reference to original_stack_limit.
- (create_inferior): Reset stack limit to original_stack_limit.
-
- * dbxread.c (read_dbx_symtab): Killed PROFILE_SYMBOLS ifdef.
-
- * sparc-dep.c (isabranch): Multiplied offset by 4 before adding it
- to addr to get target.
-
- * Makefile: Added definition of SHELL to Makefile.
-
- * m-sun2os4.h: Added code to define NEW_SUN_PTRACE, NEW_SUN_CORE,
- and ATTACH_DETACH.
- * sun3-dep.c: Added code to avoid fp regs if we are on a sun2.
-
-Tue Jan 24 17:59:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (read_array_type): Added function.
- (read_type): Added call to above instead of inline code.
-
- * Makefile: Added ${GNU_MALLOC} to the list of dependencies for
- the executables.
-
-Mon Jan 23 15:08:51 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * gdb.texinfo: Added paragraph to summary describing languages
- with which gdb can be run. Also added descriptions of the
- "info-methods" and "add-file" commands.
-
- * symseg.h: Commented a range type as having TYPE_TARGET_TYPE
- pointing at the containing type for the range (often int).
- * dbxread.c (read_range_type): Added code to do actual range types
- if they are defined. Assumed that the length of a range type is
- the length of the target type; this is a lie, but will do until
- somebody gets back to me as to what these silly dbx symbols mean.
-
- * dbxread.c (read_range_type): Added code to be more picky about
- recognizing builtins as range types, to treat types defined as
- subranges of themselves to be subranges of int, and to recognize
- the char type idiom from dbx as a special case.
-
-Sun Jan 22 01:00:13 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-vax.h: Removed definition of FUNCTION_HAS_FRAME_POINTER.
- * blockframe.c (get_prev_frame_info): Removed default definition
- and use of above. Instead conditionalized checking for leaf nodes
- on FUNCTION_START_OFFSET (see comment in code).
-
-Sat Jan 21 16:59:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (read_range_type): Fixed assumption that integer was
- always type 1.
-
- * gdb.texinfo: Fixed spelling mistake and added a note in the
- running section making it clear that users may invoke subroutines
- directly from gdb.
-
- * blockframe.c: Setup a default definition for the macro
- FUNCTION_HAS_FRAME_POINTER.
- (get_prev_frame_info): Used this macro instead of checking
- SKIP_PROLOGUE directly.
- * m-vax.h: Overroad definition; all functions on the vax have
- frame pointers.
-
-Fri Jan 20 12:25:35 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * core.c: Added default definition of N_MAGIC for COFF_FORMAT.
-
- * xgdb.c: Installed a fix to keep the thing from dying when there
- isn't any frame selected.
-
- * core.c: Made a change for the UMAX system; needs a different
- file included if using that core format.
-
- * Makefile: Deleted duplicate obstack.h in dbxread.c dependency.
-
- * munch: Modified (much simpler) to cover (I hope) all cases.
-
- * utils.c (save_cleanups, restore_cleanups): Added functions to
- allow you to push and pop the chain of cleanups to be done.
- * defs.h: Declared the new functions.
- * main.c (catch_errors): Made sure that the only cleanups which
- would be done were the ones put on the chain *after* the current
- location.
-
- * m-*.h (FRAME_CHAIN_VALID): Removed check on pc in the current
- frame being valid.
- * blockframe.c (get_prev_frame_info): Made the assumption that if
- a frame's pc value was within the first object file (presumed to
- be /lib/crt0.o), that we shouldn't go any higher.
-
- * infrun.c (wait_for_inferior): Do *not* execute check for stop pc
- at step_resume_break if we are proceeding over a breakpoint (ie.
- if trap_expected != 0).
-
- * Makefile: Added -g to LDFLAGS.
-
- * m-news.h (POP_FRAME) Fixed typo.
-
- * printcmd.c (print_frame_args): Modified to print out register
- params in order by .stabs entry, not by register number.
-
- * sparc-opcode.h: Changed declaration of (struct
- arith_imm_fmt).simm to be signed (as per architecture manual).
- * sparc-pinsn.c (fprint_addr1, print_insn): Forced a cast to an
- int, so that we really would get signed behaivior (default for sun
- cc is unsigned).
-
- * i386-dep.c (i386_get_frame_setup): Replace function with new
- function provided by pace to fix bug in recognizing prologue.
-
-Thu Jan 19 11:01:22 1989 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * infcmd.c (run_command): Changed error message to "Program not
- restarted."
-
- * value.h: Changed "frame" field in value structure to be a
- FRAME_ADDR (actually CORE_ADDR) so that it could survive across
- calls.
-
- * m-sun.h (FRAME_FIND_SAVED_REGS): Fixed a typo.
-
- * value.h: Added lval: "lval_reg_frame_relative" to indicate a
- register that must be interpeted relative to a frame. Added
- single entry to value structure: "frame", used to indicate which
- frame a relative regnum is relative to.
- * findvar.c (value_from_register): Modified to correctly setup
- these fields when needed. Deleted section to fiddle with last
- register copied on little endian machine; multi register
- structures will always occupy an integral number of registers.
- (find_saved_register): Made extern.
- * values.c (allocate_value, allocate_repeat_value): Zero frame
- field on creation.
- * valops.c (value_assign): Added case for lval_reg_frame_relative;
- copy value out, modify it, and copy it back. Desclared
- find_saved_register as being external.
- * value.h: Removed addition of kludgy structure; thoroughly
- commented file.
- * values.c (free_value, free_all_values, clear_value_history,
- set_internalvar, clear_internavars): Killed free_value.
-
-Wed Jan 18 20:09:39 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * value.h: Deleted struct partial_storage; left over from
- yesterday.
-
- * findvar.c (value_from_register): Added code to create a value of
- type lval_reg_partsaved if a value is in seperate registers and
- saved in different places.
-
-Tue Jan 17 13:50:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * value.h: Added lval_reg_partsaved to enum lval_type and
- commented enum lval_type. Commented value structure.
- Added "struct partial_register_saved" to value struct; added
- macros to deal with structure to value.h.
- * values.c (free_value): Created; special cases lval_reg_partsaved
- (which has a pointer to an array which also needs to be free).
- (free_all_values, clear_value_history, set_internalvar,
- clear_internalvars): Modified to use free_values.
-
- * m-sunos4.h: Changed name to sun3os4.h.
- * m-sun2os4.h, m-sun4os4.h: Created.
- * config.gdb: Added configuration entries for each of the above.
- * Makefile: Added into correct lists.
-
- * Makefile: Added dependencies on a.out.encap.h. Made
- a.out.encap.h dependent on a.out.gnu.h and dbxread.c dependent on
- stab.gnu.h.
-
- * infrun.c, remote.c: Removed inclusion of any a.out.h files in
- these files; they aren't needed.
-
- * README: Added comment about bug reporting and comment about
- xgdb.
-
- * Makefile: Added note to HPUX dependent section warning about
- problems if compiled with gcc and mentioning the need to add
- -Ihp-include to CFLAGS if you compile on those systems. Added a
- note about needing the GNU nm with compilers *of gdb* that use the
- coff encapsulate feature also. * hp-include: Made symbolic link
- over to /gp/gnu/binutils.
-
- * Makefile: Added TSOBS NTSOBS OBSTACK and REGEX to list of things
- to delete in "make clean". Also changed "squeakyclean" target as
- "realclean".
-
- * findvar.c (value_from_register): Added assignment of VALUE_LVAL
- to be lval_memory when that is appropriate (original code didn't
- bother because it assumed that it was working with a pre lval
- memoried value).
-
- * expread.y (yylex): Changed to only return type THIS if the
- symbol "$this" is defined in some block superior or equal to the
- current expression context block.
-
-Mon Jan 16 13:56:44 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-*.h (FRAME_CHAIN_VALID): On machines which check the relation
- of FRAME_SAVED_PC (thisframe) to first_object_file_end (all except
- gould), make sure that the pc of the current frame also passes (in
- case someone stops in _start).
-
- * findvar.c (value_of_register): Changed error message in case of
- no inferior or core file.
-
- * infcmd.c (registers_info): Added a check for inferior or core
- file; error message if not.
-
- * main.c (gdb_read_line): Modified to take prompt as argument and
- output it to stdout.
- * infcmd.c (registers_info, signals_info), main.c (command_loop,
- read_command_lines, copying_info), symtab.c (decode_line_2,
- output_source_filename, MORE, list_symbols): Changed calling
- convention used to call gdb_read_line.
-
- * infcmd.c, infrun.c, main.c, symtab.c: Changed the name of the
- function "read_line" to "gdb_read_line".
- * breakpoint.c: Deleted external referenced to function
- "read_line" (not needed by code).
-
-Fri Jan 13 12:22:05 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * i386-dep.c: Include a.out.encap.h if COFF_ENCAPSULATE.
- (N_SET_MAGIC): Defined if not defined by include file.
- (core_file_command): Used N_SET_MAGIC instead of assignment to
- a_magic.
- (exec_file_command): Stuck in a HEADER_SEEK_FD.
-
- * config.gdb: Added i386-dep.c as depfile for i386gas choice.
-
- * munch: Added -I. to cc to pick up things included by the param
- file.
-
- * stab.gnu.def: Changed name to stab.def (stab.gnu.h needs this name).
- * Makefile: Changed name here also.
- * dbxread.c: Changed name of gnu-stab.h to stab.gnu.h.
-
- * gnu-stab.h: Changed name to stab.gnu.h.
- * stab.gnu.def: Added as link to binutils.
- * Makefile: Put both in in the distribution.
-
-Thu Jan 12 11:33:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c: Made which stab.h is included dependent on
- COFF_ENCAPSULATE; either <stab.h> or "gnu-stab.h".
- * Makefile: Included gnu-stab.h in the list of files to include in
- the distribution.
- * gnu-stab.h: Made a link to /gp/gnu/binutils/stab.h
-
- * Makefile: Included a.out.gnu.h and m-i386gas.h in list of
- distribution files.
- * m-i386gas.h: Changed to include m-i386.h and fiddle with it
- instead of being a whole new file.
- * a.out.gnu.h: Made a link to /gp/gnu/binutils/a.out.gnu.h.
-
- Chris Hanson's changes to gdb for hp Unix.
- * Makefile: Modified comments on hpux.
- * hp9k320-dep.c: #define'd WOPR & moved inclusion of signal.h
- * inflow.c: Moved around declaratiosn of <sys/fcntl.h> and
- <sys/ioctl.h> inside of USG depends and deleted all SYSV ifdef's
- (use USG instead).
- * munch: Modified to accept any number of spaces between the T and
- the symbol name.
-
- Pace's changes to gdb to work with COFF_ENCAPSULATE (robotussin):
- * config.gdb: Added i386gas to targets.
- * default-dep.c: Include a.out.encap.h if COFF_ENCAPSULATE.
- (N_SET_MAGIC): Defined if not defined by include file.
- (core_file_command): Used N_SET_MAGIC instead of assignment to a_magic.
- (exec_file_command): Stuck in a HEADER_SEEK_FD.
- * infrun.c, remote.c: Added an include of a.out.encap.h if
- COFF_ENCAPSULATE defined. This is commented out in these two
- files, I presume because the definitions aren't used.
- * m-i386gas.h: Created.
- * dbxread.c: Included defintions for USG.
- (READ_FILE_HEADERS): Now uses HEADER_SEEK_FD if it exists.
- (symbol_file_command): Deleted use of HEADER_SEEK_FD.
- * core.c: Deleted extra definition of COFF_FORMAT.
- (N_MAGIC): Defined to be a_magic if not already defined.
- (validate_files): USed N_MAGIC instead of reading a_magic.
-
-Wed Jan 11 12:51:00 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * remote.c: Upped PBUFSIZ.
- (getpkt): Added zeroing of c inside loop in case of error retry.
-
- * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Removed
- code to not put stuff with debugging symbols in the misc function
- list. Had been ifdef'd out.
-
- * gdb.texinfo: Added the fact that the return value for a function
- is printed if you use return.
-
- * infrun.c (wait_for_inferior): Removed test in "Have we hit
- step_resume_breakpoint" for sp values in proper orientation. Was
- in there for recursive calls in functions without frame pointers
- and it was screwing up calls to alloca.
-
- * dbxread.c: Added #ifdef COFF_ENCAPSULATE to include
- a.out.encap.h.
- (symbol_file_command): Do HEADER_SEEK_FD when defined.
- * dbxread.c, core.c: Deleted #ifdef ROBOTUSSIN stuff.
- * robotussin.h: Deleted local copy (was symlink).
- * a.out.encap.h: Created symlink to
- /gp/gnu/binutils/a.out.encap.h.
- * Makefile: Removed robotussin.h and included a.out.encap.h in
- list of files.
-
- * valprint.c (val_print, print_scalar_formatted): Changed default
- precision of printing float value; now 6 for a float and 16 for a
- double.
-
- * findvar.c (value_from_register): Added code to deal with the
- case where a value is spread over several registers. Still don't
- deal with the case when some registers are saved in memory and
- some aren't.
-
-Tue Jan 10 17:04:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * xgdb.c (xgdb_create_window): Removed third arg (XtDepth) to
- frameArgs.
-
- * infrun.c (handle_command): Error if signal number is less or
- equal to 0 or greater or equal to NSIG or a signal number is not
- provided.
-
- * command.c (lookup_cmd): Modified to not convert command section
- of command line to lower case in place (in case it isn't a
- subcommand, but an argument to a command).
-
-Fri Jan 6 17:57:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c: Changed "text area" to "data area" in comments on
- N_SETV.
-
-Wed Jan 4 12:29:54 1989 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c: Added definitions of gnu symbol types after inclusion
- of a.out.h and stab.h.
-
-Mon Jan 2 20:38:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * eval.c (evaluate_subexp): Binary logical operations needed to
- know type to determine whether second value should be evaluated.
- Modified to discover type before binup_user_defined_p branch.
- Also commented "enum noside".
-
- * Makefile: Changed invocations of munch to be "./munch".
-
- * gdb.texinfo: Updated to refer to current version of gdb with
- January 1989 last update.
-
- * coffread.c (end_symtab): Zero context stack when finishing
- lexical contexts.
- (read_coff_symtab): error if context stack 0 in ".ef" else case.
-
- * m-*.h (FRAME_SAVED_PC): Changed name of argument from "frame" to
- "FRAME" to avoid problems with replacement of "->frame" part of
- macro.
-
- * i386-dep.c (i386_get_frame_setup): Added codestream_get() to
- move codestream pointer up to the correct location in "subl $X,
- %esp" case.
-
-Sun Jan 1 14:24:35 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * valprint.c (val_print): Rewrote routine to print string pointed
- to by char pointer; was producing incorrect results when print_max
- was 0.
-
-Fri Dec 30 12:13:35 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Put
- everything on the misc function list.
-
- * Checkpointed distribution.
-
- * Makefile: Added expread.tab.c to the list of things slated for
- distribution.
-
-Thu Dec 29 10:06:41 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * stack.c (set_backtrace_limit_command, backtrace_limit_info,
- bactrace_command, _initialize_stack): Removed modifications for
- limit on backtrace. Piping the backtrace through an interuptable
- "more" emulation is a better way to do it.
-
-Wed Dec 28 11:43:09 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * stack.c
- (set_backtrace_limit_command): Added command to set a limit to the
- number of frames for a backtrace to print by default.
- (backtrace_limit_info): To print the current limit.
- (backtrace_command): To use the limit.
- (_initialize_stack): To initialize the limit to its default value
- (30), and add the set and info commands onto the appropriate
- command lists.
-
- * gdb.texinfo: Documented changes to "backtrace" and "commands"
- commands.
-
- * stack.c (backtrace_command): Altered so that a negative argument
- would show the last few frames on the stack instead of the first
- few.
- (_initialize_stack): Modified help documentation.
-
- * breakpoint.c (commands_command): Altered so that "commands" with
- no argument would refer to the last breakpoint set.
- (_initialize_breakpoint): Modified help documentation.
-
- * infrun.c (wait_for_inferior): Removed ifdef on Sun4; now you can
- single step through compiler generated sub calls and will die if
- you next off of the end of a function.
-
- * sparc-dep.c (single_step): Fixed typo; "break_insn" ==> "sizeof
- break_insn".
-
- * m-sparc.h (INIT_EXTRA_FRAME_INFO): Set the bottom of a stack
- frame to be the bottom of the stack frame inner from this, if that
- inner one is a leaf node.
-
- * dbxread.c (read_dbx_symtab): Check to make sure we don't add a
- psymtab to it's own dependency list.
-
- * dbxread.c (read_dbx_symtab): Modified check for duplicate
- dependencies to catch them correctly.
-
-Tue Dec 27 17:02:09 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-*.h (FRAME_SAVED_PC): Modified macro to take frame info
- pointer as argument.
- * stack.c (frame_info), blockframe.c (get_prev_frame_info),
- gld-pinsn.c (findframe), m-*.h (SAVED_PC_AFTER_CALL,
- FRAME_CHAIN_VALID, FRAME_NUM_ARGS): Changed usage of macros to
- conform to above.
- * m-sparc.h (FRAME_SAVED_PC), sparc-dep.c (frame_saved_pc):
- Changed frame_saved_pc to have a frame info pointer as an
- argument.
-
- * m-vax.h, m-umax.h, m-npl.h, infrun.c (wait_for_inferior),
- blockframe.c (get_prev_frame_info): Modified SAVED_PC_AFTER_CALL
- to take a frame info pointer as an argument.
-
- * blockframe.c (get_prev_frame_info): Altered the use of the
- macros FRAME_CHAIN, FRAME_CHAIN_VALID, and FRAME_CHAIN_COMBINE to
- use frame info pointers as arguments instead of frame addresses.
- * m-vax.h, m-umax.h, m-sun3.h, m-sun3.h, m-sparc.h, m-pn.h,
- m-npl.h, m-news.h, m-merlin.h, m-isi.h, m-hp9k320.h, m-i386.h:
- Modified definitions of the above macros to suit.
- * m-pn.h, m-npl.h, gould-dep.c (findframe): Modified findframe to
- use a frame info argument; also fixed internals (wouldn't work
- before).
-
- * m-sparc.h: Cosmetic changes; reordered some macros and made sure
- that nothing went over 80 lines.
-
-Thu Dec 22 11:49:15 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * Version 3.0 released.
-
- * README: Deleted note about changing -lobstack to obstack.o.
-
-Wed Dec 21 11:12:47 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-vax.h (SKIP_PROLOGUE): Now recognizes gcc prologue also.
-
- * blockframe.c (get_prev_frame_info): Added FUNCTION_START_OFFSET
- to result of get_pc_function_start.
- * infrun.c (wait_for_inferior): Same.
-
- * gdb.texinfo: Documented new "step" and "next" behavior in
- functions without line number information.
-
-Tue Dec 20 18:00:45 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * infcmd.c (step_1): Changed behavior of "step" or "next" in a
- function witout line number information. It now sets the step
- range around the function (to single step out of it) using the
- misc function vector, warns the user, and continues.
-
- * symtab.c (find_pc_line): Zero "end" subsection of returned
- symtab_and_line if no symtab found.
-
-Mon Dec 19 17:44:35 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * i386-pinsn.c (OP_REG): Added code from pace to streamline
- disassembly and corrected types.
- * i386-dep.c
- (i386_follow_jump): Code added to follow byte and word offset
- branches.
- (i386_get_frame_setup): Expanded to deal with more wide ranging
- function prologue.
- (i386_frame_find_saved_regs, i386_skip_prologue): Changed to use
- i386_get_frame_setup.
-
-
-Sun Dec 18 11:15:03 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-sparc.h: Deleted definition of SUN4_COMPILER_BUG; was designed
- to avoid something that I consider a bug in our code, not theirs,
- and which I fixed earlier. Also deleted definition of
- CANNOT_USE_ARBITRARY_FRAME; no longer used anywhere.
- FRAME_SPECIFICATION_DYADIC used instead.
-
- * infrun.c (wait_for_inferior): On the sun 4, if a function
- doesn't have a prologue, a next over it single steps into it.
- This gets around the problem of a "call .stret4" at the end of
- functions returning structures.
- * m-sparc.h: Defined SUN4_COMPILER_FEATURE.
-
- * main.c (copying_info): Seperated the last printf into two
- printfs. The 386 compiler will now handle it.
-
- * i386-pinsn.c, i386-dep.c: Moved print_387_control_word,
- print_387_status_word, print_387_status, and i386_float_info to
- dep.c Also included reg.h in dep.c.
-
-Sat Dec 17 15:31:38 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * main.c (source_command): Don't close instream if it's null
- (indicating execution of a user-defined command).
- (execute_command): Set instream to null before executing
- commands and setup clean stuff to put it back on error.
-
- * inflow.c (terminal_inferior): Went back to not checking the
- ioctl returns; there are some systems when this will simply fail.
- It seems that, on most of these systems, nothing bad will happen
- by that failure.
-
- * values.c (value_static_field): Fixed dereferencing of null
- pointer.
-
- * i386-dep.c (i386_follow_jump): Modified to deal with
- unconditional byte offsets also.
-
- * dbxread.c (read_type): Fixed typo in function type case of switch.
-
- * infcmd.c (run_command): Does not prompt to restart if command is
- not from a tty.
-
-Fri Dec 16 15:21:58 1988 Randy Smith (randy at calvin)
-
- * gdb.texinfo: Added a third option under the "Cannot Insert
- Breakpoints" workarounds.
-
- * printcmd.c (display_command): Don't do the display unless there
- is an active inferior; only set it.
-
- * findvar.c (value_of_register): Added an error check for calling
- this when the inferior isn't active and a core file isn't being
- read.
-
- * config.gdb: Added reminder about modifying REGEX in the
- makefile for the 386.
-
- * i386-pinsn.c, i386-dep.c: Moved m-i386.h helper functions over
- to i386-dep.c.b
-
-Thu Dec 15 14:04:25 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * README: Added a couple of notes about compiling gdb with itself.
-
- * breakpoint.c (set_momentary_breakpoint): Only takes FRAME_FP of
- frame if frame is non-zero.
-
- * printcmd.c (print_scalar_formatted): Implemented /g size for
- hexadecimal format on machines without an 8 byte integer type. It
- seems to be non-trivial to implement /g for other formats.
- (decode_format): Allowed hexadecimal format to make it through /g
- fileter.
-
-Wed Dec 14 13:27:04 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * expread.y: Converted all calls to write_exp_elt from the parser
- to calls to one of write_exp_elt_{opcode, sym, longcst, dblcst,
- char, type, intern}. Created all of these routines. This gets
- around possible problems in passing one of these things in one ear
- and getting something different out the other. Eliminated
- SUN4_COMPILER_BUG ifdef's; they are now superfluous.
-
- * symmisc.c (free_all_psymtabs): Reinited partial_symtab_list to 0.
- (_initialize_symmisc): Initialized both symtab_list and
- partial_symtab_list.
-
- * dbxread.c (start_psymtab): Didn't allocate anything on
- dependency list.
- (end_psymtab): Allocate dependency list on psymbol obstack from
- local list.
- (add_psymtab_dependency): Deleted.
- (read_dbx_symtab): Put dependency on local list if it isn't on it
- already.
-
- * symtab.c: Added definition of psymbol_obstack.
- * symtab.h: Added declaration of psymbol_obstack.
- * symmisc.c (free_all_psymtabs): Added freeing and
- reinitionaliztion of psymbol_obstack.
- * dbxread.c (free_all_psymbols): Deleted.
- (start_psymtab, end_psymtab,
- process_symbol_for_psymtab): Changed most allocation
- of partial symbol stuff to be off of psymbol_obstack.
-
- * symmisc.c (free_psymtab, free_all_psymtabs): Deleted
- free_psymtab subroutine.
-
- * symtab.h: Removed num_includes and includes from partial_symtab
- structure; no longer needed now that all include files have their
- own psymtab.
- * dbxread.c (start_psymtab): Eliminated initialization of above.
- (end_psymtab): Eliminated finalization of above; get
- includes from seperate list.
- (read_dbx_symtab): Moved includes from psymtab list to
- their own list; included in call to end_psymtab.
- * symmisc.c (free_psymtab): Don't free includes.
-
-Tue Dec 13 14:48:14 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * i386-pinsn.c: Reformatted entire file to correspond to gnu
- software indentation conventions.
-
- * sparc-dep.c (skip_prologue): Added capability of recognizign
- stores of input register parameters into stack slots.
-
- * sparc-dep.c: Added an include of sparc-opcode.h.
- * sparc-pinsn.c, sparc-opcode.h: Moved insn_fmt structures and
- unions from pinsn.c to opcode.h.
- * sparc-pinsn.c, sparc-dep.c (isabranch, skip_prologue): Moved
- this function from pinsn.c to dep.c.
-
- * Makefile: Put in warnings about compiling with gcc (non-ansi
- include files) and compiling with shared libs on Sunos 4.0 (can't
- debug something that's been compiled that way).
-
- * sparc-pinsn.c: Put in a completely new file (provided by
- Tiemann) to handle floating point disassembly, load and store
- instructions, and etc. better. Made the modifications this file
- (ChangeLog) list for sparc-pinsn.c again.
-
- * symtab.c (output_source_filename): Included "more" emulation hack.
-
- * symtab.c (output_source_filename): Initialized COLUMN to 0.
- (sources_info): Modified to not print out a line for
- all of the include files within a partial symtab (since
- they have pst's of their own now). Also modified to
- make a distinction between those pst's read in and
- those not.
-
- * infrun.c: Included void declaration of single_step() if it's
- going to be used.
- * sparc-dep.c (single_step): Moved function previous to use of it.
-
- * Makefile: Took removal of expread.tab.c out of make clean entry
- and put it into a new "squeakyclean" entry.
-
-Mon Dec 12 13:21:02 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * sparc-pinsn.c (skip_prologue): Changed a struct insn_fmt to a
- union insn_fmt.
-
- * inflow.c (terminal_inferior): Checked *all* return codes from
- ioctl's and fcntl's in routine.
-
- * inflow.c (terminal_inferior): Added check for sucess of
- TIOCSPGRP ioctl call. Just notifies if bad.
-
- * dbxread.c (symbol_file_command): Close was getting called twice;
- once directly and once through cleanup. Killed the direct call.
-
-Sun Dec 11 19:40:40 1988 & Smith (randy at hobbes.ai.mit.edu)
-
- * valprint.c (val_print): Deleted spurious printing of "=" from
- TYPE_CODE_REF case.
-
-Sat Dec 10 16:41:07 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c: Changed allocation of psymbols from using malloc and
- realloc to using obstacks. This means they aren't realloc'd out
- from under the pointers to them.
-
-Fri Dec 9 10:33:24 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * sparc-dep.c inflow.c core.c expread.y command.c infrun.c
- infcmd.c dbxread.c symmisc.c symtab.c printcmd.c valprint.c
- values.c source.c stack.c findvar.c breakpoint.c blockframe.c
- main.c: Various cleanups inspired by "gcc -Wall" (without checking
- for implicit declarations).
-
- * Makefile: Cleaned up some more.
-
- * valops.c, m-*.h (FIX_CALL_DUMMY): Modified to take 5 arguments
- as per what sparc needs (programming for a superset of needed
- args).
-
- * dbxread.c (process_symbol_for_psymtab): Modified to be slightly
- more picky about what it puts on the list of things *not* to be
- put on the misc function list. When/if I shift everything over to
- being placed on the misc_function_list, this will go away.
-
- * inferior.h, infrun.c: Added fields to save in inferior_status
- structure.
-
- * maketarfile: Deleted; functionality is in Makefile now.
-
- * infrun.c (wait_for_inferior): Modified algorithm for determining
- whether or not a single-step was through a subroutine call. See
- comments at top of file.
-
- * dbxread.c (read_dbx_symtab): Made sure that the IGNORE_SYMBOL
- macro would be checked during initial readin.
-
- * dbxread.c (read_ofile_symtab): Added macro GCC_COMPILED_FLAG_SYMBOL
- into dbxread.c to indicate what string in a local text symbol will
- indicate a file compiled with gcc. Defaults to "gcc_compiled.".
-
-Thu Dec 8 11:46:22 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-sparc.h (FRAME_FIND_SAVED_REGS): Cleaned up a little to take
- advantage of the new frame cache system.
-
- * inferior.h, infrun.c, valops.c, valops.c, infcmd.c: Changed
- mechanism to save inferior status over calls to inferior (eg.
- call_function); implemented save_inferior_info and
- restore_inferior_info.
-
- * blockframe.c (get_prev_frame): Simplified this by a direct call
- to get_prev_frame_info.
-
- * frame.h, stack.c, printcmd.c, m-sparc.h, sparc-dep.c: Removed
- all uses of frame_id_from_addr. There are short routines like it
- still in frame_saved_pc (m-sparc.h) and parse_frame_spec
- (stack.c). Eventually the one in frame_saved_pc will go away.
-
- * infcmd.c, sparc-dep.c: Implemented a new mechanism for
- re-selecting the selected frame on return from a call.
-
- * blockframe.c, stack.c, findvar.c, printcmd.c, m-*.h: Changed
- all routines and macros that took a "struct frame_info" as an
- argument to take a "struct frame_info *". Routines: findarg,
- framechain, print_frame_args, FRAME_ARGS_ADDRESS,
- FRAME_STRUCT_ARGS_ADDRESS, FRAME_LOCALS_ADDRESS, FRAME_NUM_ARGS,
- FRAME_FIND_SAVED_REGS.
-
- * frame.h, stack.c, printcmd.c, infcmd.c, findvar.c, breakpoint.c,
- blockframe.c, xgdb.c, i386-pinsn.c, gld-pinsn.c, m-umax.h,
- m-sun2.h, m-sun3.h, m-sparc.h, m-pn.h, m-npl.h, m-news.h,
- m-merlin.h, m-isi.h, m-i386.h, m-hp9k320.h: Changed routines to
- use "struct frame_info *" internally.
-
-Wed Dec 7 12:07:54 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * frame.h, blockframe.c, m-sparc.h, sparc-dep.c: Changed all calls
- to get_[prev_]frame_cache_item to get_[prev_]frame_info.
-
- * blockframe.c: Elminated get_frame_cache_item and
- get_prev_frame_cache_item; functionality now taken care of by
- get_frame_info and get_prev_frame_info.
-
- * blockframe.c: Put allocation on an obstack and eliminated fancy
- reallocation routines, several variables, and various nasty
- things.
-
- * frame.h, stack.c, infrun.c, blockframe.c, sparc-dep.c: Changed
- type FRAME to be a typedef to "struct frame_info *". Had to also
- change routines that returned frame id's to return the pointer
- instead of the cache index.
-
- * infcmd.c (finish_command): Used proper method of getting from
- function symbol to start of function. Was treating a symbol as a
- value.
-
- * blockframe.c, breakpoint.c, findvar.c, infcmd.c, stack.c,
- xgdb.c, i386-pinsn.c, frame.h, m-hp9k320.h, m-i386.h, m-isi.h,
- m-merlin.h, m-news.h, m-npl.h, m-pn.h, m-sparc.h, m-sun2.h,
- m-sun3.h, m-umax.h: Changed get_frame_info and get_prev_frame_info
- to return pointers instead of structures.
-
- * blockframe.c (get_pc_function_start): Modified to go to misc
- function table instead of bombing if pc was in a block without a
- containing function.
-
- * coffread.c: Dup'd descriptor passed to read_coff_symtab and
- fdopen'd it so that there wouldn't be multiple closes on the same
- fd. Also put (fclose, stream) on the cleanup list.
-
- * printcmd.c, stack.c: Changed print_frame_args to take a
- frame_info struct as argument instead of the address of the args
- to the frame.
-
- * m-i386.h (STORE_STRUCT_RETURN): Decremented sp by sizeof object
- to store (an address) rather than 1.
-
- * dbxread.c (read_dbx_symtab): Set first_object_file_end in
- read_dbx_symtab (oops).
-
- * coffread.c (fill_in_vptr_fieldno): Rewrote TYPE_BASECLASS as
- necessary.
-
-Tue Dec 6 13:03:43 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * coffread.c: Added fake support for partial_symtabs to allow
- compilation and execution without there use.
- * inflow.c: Added a couple of minor USG mods.
- * munch: Put in appropriate conditionals so that it would work on
- USG systems.
- * Makefile: Made regex.* handled same as obstack.*; made sure tar
- file included everything I wanted it to include (including
- malloc.c).
-
- * dbxread.c (end_psymtab): Create an entry in the
- partial_symtab_list for each subfile of the .o file just read in.
- This allows a "list expread.y:10" to work when we haven't read in
- expread.o's symbol stuff yet.
-
- * symtab.h, dbxread.c (psymtab_to_symtab): Recognize pst->ldsymlen
- == 0 as indicating a dummy psymtab, only in existence to cause the
- dependency list to be read in.
-
- * dbxread.c (sort_symtab_syms): Elminated reversal of symbols to
- make sure that register debug symbol decls always come before
- parameter symbols. After mod below, this is not needed.
-
- * symtab.c (lookup_block_symbol): Take parameter type symbols
- (LOC_ARG or LOC_REGPARM) after any other symbols which match.
-
- * dbxread.c (read_type): When defining a type in terms of some
- other type and the other type is supposed to have a pointer back
- to this specific kind of type (pointer, reference, or function),
- check to see if *that* type has been created yet. If it has, use
- it and fill in the appropriate slot with a pointer to it.
-
-Mon Dec 5 11:25:04 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * symmisc.c: Eliminated existence of free_inclink_symtabs and
- init_free_inclink_symtabs; they aren't called from anywhere, and
- if they were they could disrupt gdb's data structure badly
- (elimination of struct type's which values that stick around past
- elimination of inclink symtabs).
-
- * dbxread.c (symbol_file_command): Fixed a return pathway out of
- the routine to do_cleanups before it left.
-
- * infcmd.c (set_environment_command), gdb.texinfo: Added
- capability to set environmental variable values to null.
-
- * gdb.texinfo: Modified doc on "break" without args slightly.
-
-Sun Dec 4 17:03:16 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c (symbol_file_command): Added check; if there weren't
- any debugging symbols in the file just read, the user is warned.
-
- * infcmd.c: Commented set_environment_command (a little).
-
- * createtags: Cleaned up and commented.
-
- * Makefile: Updated depen_memory and write_inferior_memory in that errno is
- checked after each ptrace and returned to the caller. Used in
- value_at to detect references to addresses which are out of
- bounds. Also core.c (xfer_core_file): return 1 if invalid
- address, 0 otherwise.
-
- * inflow.c, <machine>-infdep.c: removed all calls to ptrace from
- inflo, m-sun3.h: Cleaned up dealings with
- functions returning structu0 19:19:36 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * symmisc.c: (read_symsegs) Accept only format number 2. Since
- the size of the type structure changed when C++ support was added,
- format 1 can no longer be used.
-
- * core.c, m-sunos4.h: (core_file_command) support for SunOS 4.0.
- Slight change in the core structure. #ifdef SUNOS4. New file
- m-sunos4.h. May want to change config.gdb also.
-
-Fri Jul 8 19:59:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * breakpoint.c: (break_command_1) Allow `break if condition'
- rather than parsing `if' as a function name and returning an
- error.
-
-Thu Jul 7 22:22:47 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * C++: valops.c, valprint.c, value.h, values.c: merged code to deal
- with C++ expressions.
-
-Wed Jul 6 03:28:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * C++: dbxread.c: (read_dbx_symtab, condense_misc_bunches,
- add_file_command) Merged code to read symbol information from
- an incrementally linked file. symmisc.c:
- (init_free_inclink_symtabs, free_inclink_symtabs) Cleanup
- routines.
-
-Tue Jul 5 02:50:41 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * C++: symtab.c, breakpoint.c, source.c: Merged code to deal with
- ambiguous line specifications. In C++ one can have overloaded
- function names, so that `list classname::overloadedfuncname'
- refers to several different lines, possibly sure currently configured machine
- dependent files come first in e at corn-chex.ai.mit.edu)
-
- * C++: symtab.c: replaced lookup_symtab_1 and lookup_symtab_2 with
- a modified lookup_symbol which checks for fields of the current
- implied argument `this'. printcmd.c, source.c, symtab.c,
- valops.c: Need to change callers once callers are
- installed.
-
-Wed Jun 29 01:26:56 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu)
-
- * C++: eval.c, expprint.c, expread.y, expression.h, valarith.c,
- Merged code to deal with evaluation of user-defined operators,
- member functions, and virtual functions.
- binop_must_be_user_defined tests for user-defined binops,
- value_x_binop calls the appropriate operator function.
-
-Tue Jun 28 02:56:42 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu)
-
- * C++: Makefile: changed the echo: expect 101 shift/reduce conflicts
- and 1 reduce/reduce conflict.
-
-
-Local Variables:
-mode: indented-text
-eval: (auto-fill-mode 1)
-left-margin: 8
-fill-column: 74
-version-control: never
-End:
-
- constructors, and flags being defined via public and via
- virtual paths. Added fields NEXT_VARIANT, N_BASECLASSES,
- and BASECLASSES to this type (tr: Changed types from
- having to be derived from a single baseclass to a multiple
- base class).
- * symtab.h: Added macros to access new fields defined in symseg.h.
- Added decl for lookup_basetype_type.
- * dbxread.c
- (condense_addl_misc_bunches): Function added to condense the misc
- function bunches added by reading in a new .o file.
- (read_addl_syms): Function added to read in symbols
- from a new .o file (incremental linking).
- (add_file_command): Command interface function to indicate
- incrmental linking of a new .o file; this now calls
- read_addl_syms and condense_addl_misc_bunches.
- (define_symbol): Modified code to handle types defined from base
- types which were not known when the derived class was
- output.
- (read_struct_type): Modified to better handle description of
- struct types as derived types. Possibly derived from
- several different base classes. Also added new code to
- mark definitions via virtual paths or via public paths.
- Killed seperate code to handle classes with destructors
- but without constructors and improved marking of classes
- as having destructors and constructors.
- * infcmd.c: Modified call to val_print (one more argument).
- * symtab.c (lookup_member_type): Modified to deal with new
- structure in symseg.h.
- (lookup_basetype_type): Function added to find or construct a type
- ?derived? from the given type.
- (decode_line_1): Modified to deal with new type data structures.
- Modified to deal with new number of args for
- decode_line_2.
- (decode_line_2): Changed number of args (?why?).
- (init_type): Added inits for new C++ fields from
- symseg.h.
- *valarith.c
- (value_x_binop, value_binop): Added cases for BINOP_MIN &
- BINOP_MAX.
- * valops.c
- (value_struct_elt, check_field, value_struct_elt_for_address):
- Changed to deal with multiple possible baseclasses.
- (value_of_this): Made SELECTED_FRAME an extern variable.
- * valprint.c
- (val_print): Added an argument DEREF_REF to dereference references
- automatically, instead of printing them like pointers.
- Changed number of arguments in recursive calls to itself.
- Changed to deal with varibale numbers of base classes.
- (value_print): Changed number of arguments to val_print. Print
- type of value also if value is a reference.
- (type_print_derivation_info): Added function to print out
- derivation info a a type.
- (type_print_base): Modified to use type_print_derivation_info and
- to handle multiple baseclasses.
-
-Mon Nov 21 10:32:07 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * inflow.c (term_status_command): Add trailing newline to output.
-
- * sparc-dep.c (do_save_insn, do_restore_insn): Saved
- "stop_registers" over the call for the sake of normal_stop and
- run_stack_dummy.
-
- * m-sparc.h (EXTRACT_RETURN_VALUE): Put in parenthesis to force
- addition of 8 to the int pointer, not the char pointer.
-
- * sparc-pinsn.c (print_addr1): Believe that I have gotten the
- syntax right for loads and stores as adb does it.
-
- * symtab.c (list_symbols): Turned search for match on rexegp into
- a single loop.
-
- * dbxread.c (psymtab_to_symtab): Don't read it in if it's already
- been read in.
-
- * dbxread.c (psymtab_to_symtab): Changed error to fatal in
- psymtab_to_symtab.
-
- * expread.y (parse_number): Fixed bug which treated 'l' at end of
- number as '0'.
-
-Fri Nov 18 13:57:33 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Was
- being foolish and using pointers into an array I could realloc.
- Converted these pointers into integers.
-
-Wed Nov 16 11:43:10 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-sparc.h (POP_FRAME): Made the new frame be PC_ADJUST of the
- old frame.
-
- * i386-pinsn.c, m-hp9k320.h, m-isi.h, m-merlin.h, m-news.h,
- m-npl.h, m-pn.h, m-sparc.h, m-sun2.h, m-sun3.h, m-umax.h, m-vax.h:
- Modified POP_FRAME to use the current frame instead of
- read_register (FP_REGNUM) and to flush_cached_frames before
- setting the current frame. Also added a call to set the current
- frame in those POP_FRAMEs that didn't have it.
-
- * infrun.c (wait_for_inferior): Moved call to set_current_frame up
- to guarrantee that the current frame will always be set when a
- POP_FRAME is done.
-
- * infrun.c (normal_stop): Added something to reset the pc of the
- current frame (was incorrect because of DECR_PC_AFTER_BREAK).
-
- * valprint.c (val_print): Changed to check to see if a string was
- out of bounds when being printed and to indicate this if so.
-
- * convex-dep.c (read_inferior_memory): Changed to return the value
- of errno if the call failed (which will be 0 if the call
- suceeded).
-
-Tue Nov 15 10:17:15 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * infrun.c (wait_for_inferior): Two changes: 1) Added code to
- not trigger the step breakpoint on recursive calls to functions
- without frame info, and 2) Added calls to distinguish recursive
- calls within a function without a frame (which next/nexti might
- wish to step over) from jumps to the beginning of a function
- (which it generally doesn't).
-
- * m-sparc.h (INIT_EXTRA_FRAME_INFO): Bottom set correctly for leaf
- parents.
-
- * blockframe.c (get_prev_frame_cache_item): Put in mod to check
- for a leaf node (by presence or lack of function prologue). If
- there is a leaf node, it is assumed that SAVED_PC_AFTER_CALL is
- valid. Otherwise, FRAME_SAVED_PC or read_pc is used.
-
- * blockframe.c, frame.h: Did final deletion of unused routines and
- commented problems with getting a pointer into the frame cache in
- the frame_info structure comment.
-
- * blockframe.c, frame.h, stack.c: Killed use of
- frame_id_from_frame_info; used frame_id_from_addr instead.
-
- * blockframe.c, frame.h, stack.c, others (oops): Combined stack
- cache and frame info structures.
-
- * blockframe.c, sparc-dep.c, stack.c: Created the function
- create_new_frame and used it in place of bad calls to
- frame_id_from_addr.
-
- * blockframe.c, inflow.c, infrun.c, i386-pinsn.c, m-hp9k320.h,
- m-npl.h, m-pn.h, m-sparc.h, m-sun3.h, m-vax.h, default-dep.c,
- convex-dep.c, gould-dep.c, hp9k320-dep.c, news-dep.c, sparc-dep.c,
- sun3-dep.c, umax-dep.c: Killed use of
- set_current_Frame_by_address. Used set_current_frame
- (create_new_frame...) instead.
-
- * frame.h: Killed use of FRAME_FP_ID.
-
- * infrun.c, blockframe.c: Killed select_frame_by_address. Used
- select_frame (get_current_frame (), 0) (which was correct in all
- cases that we need to worry about.
-
-Mon Nov 14 14:19:32 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * frame.h, blockframe.c, stack.c, m-sparc.h, sparc-dep.c: Added
- mechanisms to deal with possible specification of frames
- dyadically.
-
-Sun Nov 13 16:03:32 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
-
- * ns32k-opcode.h: Add insns acbw, acbd.
-
-Sun Nov 13 15:09:58 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * breakpoint.c: Changed breakpoint structure to use the address of
- a given frame (constant across inferior runs) as the criteria for
- stopping instead of the frame ident (which varies across inferior
- calls).
-
-Fri Nov 11 13:00:22 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * gld-pinsn.c (findframe): Modified to work with the new frame
- id's. Actually, it looks as if this routine should be called with
- an address anyway.
-
- * findvar.c (find_saved_register): Altered bactrace loop to work
- off of frames and not frame infos.
-
- * frame.h, blockframe.c, stack.c, sparc-dep.c, m-sparc.h: Changed
- FRAME from being the address of the frame to being a simple ident
- which is an index into the frame_cache_item list.
- * convex-dep.c, default-dep.c, gould-dep.c, hp9k320-dep.c,
- i386-pinsn.c, inflow.c, infrun.c, news-dep.c, sparc-dep.c,
- sun3-dep.c, umax-dep.c, m-hp9k320.h, m-npl.h, m-pn.h, m-sparc.h,
- m-sun3.h, m-vax.h: Changed calls of the form set_current_frame
- (read_register (FP_REGNUM)) to set_current_frame_by_address (...).
-
-Thu Nov 10 16:57:57 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * frame.h, blockframe.c, gld-pinsn.c, sparc-dep.c, stack.c,
- infrun.c, findvar.c, m-sparc.h: Changed the FRAME type to be
- purely an identifier, using FRAME_FP and FRAME_FP_ID to convert
- back and forth between the two. The identifier is *currently*
- still the frame pointer value for that frame.
-
-Wed Nov 9 17:28:14 1988 Chris Hanson (cph at kleph)
-
- * m-hp9k320.h (FP_REGISTER_ADDR): Redefine this to return
- difference between address of given FP register, and beginning of
- `struct user' that it occurs in.
-
- * hp9k320-dep.c (core_file_command): Fix sign error in size
- argument to myread. Change buffer argument to pointer; was
- copying entire structure.
- (fetch_inferior_registers, store_inferior_registers): Replace
- occurrences of `FP_REGISTER_ADDR_DIFF' with `FP_REGISTER_ADDR'.
- Flush former definition.
-
-Wed Nov 9 12:11:37 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * xgdb.c: Killed include of initialize.h.
-
- * Pulled in xgdb.c from the net.
-
- * Checkpointed distribution (to provide to 3b2 guy).
-
- * coffread.c, dbxread.c, symmisc.c, symtab.c, symseg.h: Changed
- format of table of line number--pc mapping information. Can
- handle negative pc's now.
-
- * command.c: Deleted local copy of savestring; code in utils.c is
- identical.
-
-Tue Nov 8 11:12:16 1988 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * gdb.texinfo: Added documentation for shell escape.
-
-Mon Nov 7 12:27:16 1988 Randall Smith (randy at sugar-bombs.ai.mit.edu)
-
- * command.c: Added commands for shell escape.
-
- * core.c, dbxread.c: Added ROBOTUSSIN mods.
-
- * Checkpointed distribution.
-
- * printcmd.c (x_command): Yanked error if there is no memory to
- examine (could be looking at executable straight).
-
- * sparc-pinsn.c (print_insn): Amount to leftshift sethi imm by is
- now 10 (matches adb in output).
-
- * printcmd.c (x_command): Don't attempt to set $_ & $__ if there
- is no last_examine_value (can happen if you did an x/0).
-
-Fri Nov 4 13:44:49 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * printcmd.c (x_command): Error if there is no memory to examine.
-
- * gdb.texinfo: Added "cont" to the command index.
-
- * sparc-dep.c (do_save_insn): Fixed typo in shift amount.
-
- * m68k-opcode.h: Fixed opcodes for 68881.
-
- * breakpoint.c, infcmd.c, source.c: Changed defaults in several
- places for decode_line_1 to work off of the default_breakpoint_*
- values instead of current_source_* values (the current_source_*
- values are off by 5 or so because of listing defaults).
-
- * stack.c (frame_info): ifdef'd out FRAME_SPECIFCATION_DYADIC in
- the stack.c module. If I can't do this right, I don't want to do
- it at all. Read the comment there for more info.
-
-Mon Oct 31 16:23:06 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * gdb.texinfo: Added documentation on the "until" command.
-
-Sat Oct 29 17:47:10 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * breakpoint.c, infcmd.c: Added UNTIL_COMMAND and subroutines of
- it.
-
- * breakpoint.c, infcmd.c, infrun.c: Added new field to breakpoint
- structure (silent, indicating a silent breakpoint), and modified
- breakpoint_stop_status and things that read it's return value to
- understand it.
-
-Fri Oct 28 17:45:33 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c, symmisc.c: Assorted speedups for readin, including
- special casing most common symbols, and doing buffering instead of
- calling malloc.
-
-Thu Oct 27 11:11:15 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * stack.c, sparc-dep.c, m-sparc.h: Modified to allow "info frame"
- to take two arguments on the sparc and do the right thing with
- them.
-
- * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Put
- stuff to put only symbols that didn't have debugging info on the
- misc functions list back in.
-
-Wed Oct 26 10:10:32 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * valprint.c (type_print_varspec_suffix): Added check for
- TYPE_LENGTH(TYPE_TARGET_TYPE(type)) > 0 to prevent divide by 0.
-
- * printcmd.c (print_formatted): Added check for VALUE_REPEATED;
- value_print needs to be called for that.
-
- * infrun.c (wait_for_inferior): Added break when you decide to
- stop on a null function prologue rather than continue stepping.
-
- * m-sun3.h: Added explanatory comment to REGISTER_RAW_SIZE.
-
- * expread.y (parse_c_1): Initialized paren_depth for each parse.
-
-Tue Oct 25 14:19:38 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * valprint.c, coffread.c, dbxread.c: Enum constant values in enum
- type now accessed through TYPE_FIELD_BITPOS.
-
- * dbxread.c (process_symbol_for_psymtab): Added code to deal with
- possible lack of a ":" in a debugging symbol (do nothing).
-
- * symtab.c (decode_line_1): Added check in case of all numbers for
- complete lack of symbols.
-
- * source.c (select_source_symtab): Made sure that this wouldn't
- bomb on complete lack of symbols.
-
-Mon Oct 24 12:28:29 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-sparc.h, findvar.c: Ditched REGISTER_SAVED_UNIQUELY and based
- code on REGISTER_IN_WINDOW_P and HAVE_REGISTER_WINDOWS. This will
- break when we find a register window machine which saves the
- window registers within the context of an inferior frame.
-
- * sparc-dep.c (frame_saved_pc): Put PC_ADJUST return back in for
- frame_saved_pc. Seems correct.
-
- * findvar.c, m-sparc.h: Created the macro REGISTER_SAVED_UNIQUELY
- to handle register window issues (ie. that find_saved_register
- wasn't checking the selected frame itself for shit).
-
- * sparc-dep.c (core_file_command): Offset target of o & g register
- bcopy by 1 to hit correct registers.
-
- * m-sparc.h: Changed STACK_END_ADDR.
-
-Sun Oct 23 19:41:51 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * sparc-dep.c (core_file_command): Added in code to get the i & l
- registers from the stack in the corefile, and blew away some wrong
- code to get i & l from inferior.
-
-Fri Oct 21 15:09:19 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu)
-
- * m-sparc.h (PUSH_DUMMY_FRAME): Saved the value of the RP register
- in the location reserved for i7 (in the created frame); this way
- the rp value won't get lost. The pc (what we put into the rp in
- this routine) gets saved seperately, so we loose no information.
-
- * sparc-dep.c (do_save_insn & do_restore_insn): Added a wrapper to
- preserve the proceed status state variables around each call to
- proceed (the current frame was getting munged because this wasn't
- being done).
-
- * m-sparc.h (FRAME_FIND_SAVED_REGS): Fix bug: saved registers
- addresses were being computed using absolute registers number,
- rather than numbers relative to each group of regs.
-
- * m-sparc.h (POP_FRAME): Fixed a bug (I hope) in the context
- within which saved reg numbers were being interpetted. The
- values to be restored were being gotten in the inferior frame, and
- the restoring was done in the superior frame. This means that i
- registers must be restored into o registers.
-
- * sparc-dep.c (do_restore_insn): Modified to take a pc as an
- argument, instead of a raw_buffer. This matches (at least it
- appears to match) usage from POP_FRAME, which is the only place
- from which do_restore_insn is called.
-
- * sparc-dep.c (do_save_insn and do_restore_insn): Added comments.
-
- * m-sparc.h (FRAME_FIND_SAVED_REGS): Modified my code to find the
- save addresses of out registers to use the in regs off the stack
- pointer when the current frame is 1 from the innermost.
-
-Thu Oct 20 13:56:15 1988 & Smith (randy at hobbes.ai.mit.edu)
-
- * blockframe.c, m-sparc.h: Removed code associated with
- GET_PREV_FRAME_FROM_CACHE_ITEM. This code was not needed for the
- sparc; you can always find the previous frames fp from the fp of
- the current frame (which is the sp of the previous). It's getting
- the information associated with a given frame (ie. saved
- registers) that's a bitch, because that stuff is saved relative to
- the stack pointer rather than the frame pointer.
-
- * m-sparc.h (GET_PREV_FRAME_FROM_CACHE_ITEM): Modified to return
- the frame pointer of the previous frame instead of the stack
- pointer of same.
-
- * blockframe.c (flush_cached_frames): Modified call to
- obstack_free to free back to frame_cache instead of back to zero.
- This leaves the obstack control structure in finite state (and
- still frees the entry allocated at frame_cache).
-
-Sat Oct 15 16:30:47 1988 & Smith (randy at tartarus.uchicago.edu)
-
- * valops.c (call_function): Suicide material here. Fixed a typo;
- CALL_DUMMY_STACK_ADJUST was spelled CAll_DUMMY_STACK_ADJUST on
- line 530 of the file. This cost me three days. I'm giving up
- typing for lent.
-
-Fri Oct 14 15:10:43 1988 & Smith (randy at tartarus.uchicago.edu)
-
- * m-sparc.h: Corrected a minor mistake in the dummy frame code
- that was getting the 5th argument and the first argument from the
- same place.
-
-Tue Oct 11 11:49:33 1988 & Smith (randy at tartarus.uchicago.edu)
-
- * infrun.c: Made stop_after_trap and stop_after_attach extern
- instead of static so that code which used proceed from machine
- dependent files could fiddle with them.
-
- * blockframe.c, frame.h, sparc-dep.c, m-sparc.h: Changed sense of
- ->prev and ->next in struct frame_cache_item to fit usage in rest
- of gdb (oops).
-
-Mon Oct 10 15:32:42 1988 Randy Smith (randy at gargoyle.uchicago.edu)
-
- * m-sparc.h, sparc-dep.c, blockframe.c, frame.h: Wrote
- get_frame_cache_item. Modified FRAME_SAVED_PC and frame_saved_pc
- to take only one argument and do the correct thing with it. Added
- the two macros I recently defined in blockframe.c to m-sparc.h.
- Have yet to compile this thing on a sparc, but I've now merged in
- everything that I received from tiemann, either exactly, or simply
- effectively.
-
- * source.c: Added code to allocated space to sals.sals in the case
- where no line was specified.
-
- * blockframe.c, infrun.c: Modified to cache stack frames requested
- to minimize accesses to subprocess.
-
-Tue Oct 4 15:10:39 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu)
-
- * config.gdb: Added sparc.
-
-Mon Oct 3 23:01:22 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu)
-
- * Makefile, blockframe.c, command.c, core.c, dbxread.c, defs.h,
- expread.y, findvar.c, infcmd.c, inflow.c, infrun.c, sparc-pinsn.c,
- m-sparc.h, sparc-def.c, printcmd.c, stack.c, symmisc.c, symseg.h,
- valops.c, values.c: Did initial merge of sparc port. This will
- not compile; have to do stack frame caching and finish port.
-
- * inflow.c, gdb.texinfo: `tty' now resets the controling terminal.
-
-Fri Sep 30 11:31:16 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * inferior.h, infcmd.c, infrun.c: Changed the variable
- stop_random_signal to stopped_by_random signal to fit in better
- with name conventions (variable is not a direction to the
- proceed/resume set; it is information from it).
-
-Thu Sep 29 13:30:46 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu)
-
- * infcmd.c (finish_command): Value type of return value is now
- whatever the function returns, not the type of the function (fixed
- a bug in printing said value).
-
- * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab):
- Put *all* global symbols into misc_functions. This is what was
- happening anyway, and we need it for find_pc_misc_function.
-
- ** This was eventually taken out, but I didn't mark it in the
- ChangeLog. Oops.
-
- * dbxread.c (process_symbol_for_psymtab): Put every debugger
- symbol which survives the top case except for constants on the
- symchain. This means that all of these *won't* show up in misc
- functions (this will be fixed once I make sure it's broken the way
- it's supposed to be).
-
- * dbxread.c: Modified placement of debugger globals onto the hash
- list; now we exclude the stuff after the colon and don't skip the
- first character (debugger symbols don't have underscores).
-
- * dbxread.c: Killed debuginfo stuff with ifdef's.
-
-Wed Sep 28 14:31:51 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu)
-
- * symtab.h, dbxread.c: Modified to deal with BINCL, EINCL, and
- EXCL symbols produced by the sun loader by adding a list of
- pre-requisite partial_symtabs that each partial symtab needs.
-
- * symtab.h, dbxread.c, symtab.c, symmisc.c: Modified to avoid
- doing a qsort on the local (static) psymbols for each file to
- speed startup. This feature is not completely debugged, but it's
- inclusion has forced the inclusion of another feature (dealing
- with EINCL's, BINCL's and EXCL's) and so I'm going to go in and
- deal with them.
-
- * dbxread.c (process_symbol_for_psymtab): Made sure that the class
- of the symbol made it into the partial_symbol entry.
-
-Tue Sep 27 15:10:26 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c: Fixed bug; init_psymbol_list was not being called
- with the right number of arguments (1).
-
- * dbxread.c: Put ifdef's around N_MAIN, N_M2C, and N_SCOPE to
- allow compilation on a microvax.
-
- * config.gdb: Modified so that "config.gdb vax" would work.
-
- * dbxread.c, symtab.h, symmisc.h, symtab.c, source.c: Put in many
- and varied hacks to speed up gdb startup including: A complete
- rewrite of read_dbx_symtab, a modification of the partial_symtab
- data type, deletion of select_source_symtab from
- symbol_file_command, and optimiztion of the call to strcmp in
- compare_psymbols.
-
-Thu Sep 22 11:08:54 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * dbxread.c (psymtab_to_symtab): Removed call to
- init_misc_functions.
-
- * dbxread.c: Fixed enumeration type clash (used enum instead of
- integer constant).
-
- * breakpoint.c: Fixed typo; lack of \ at end of line in middle of
- string constant.
-
- * symseg.h: Fixed typo; lack of semicolon after structure
- definition.
-
- * command.c, breakpoint.c, printcmd.c: Added cmdlist editing
- functions to add commands with the abbrev flag set. Changed
- help_cmd_list to recognize this flag and modified unset,
- undisplay, and enable, disable, and delete breakpoints to have
- this flag set.
-
-Wed Sep 21 13:34:19 1988 Randall Smith (randy at plantaris.ai.mit.edu)
-
- * breakpoint.c, infcmd.c, gdb.texinfo: Created "unset" as an alias
- for delete, and changed "unset-environment" to be the
- "environment" subcommand of "delete".
-
- * gdb.texinfo, valprint.c: Added documentation in the manual for
- breaking the set-* commands into subcommands of set. Changed "set
- maximum" to "set array-max".
-
- * main.c, printcmd.c, breakpoint.c: Moved the declaration of
- command lists into main and setup a function in main initializing
- them to guarrantee that they would be initialized before calling
- any of the individual files initialize routines.
-
- * command.c (lookup_cmd): A null string subcommand is treated as
- an unknown subcommand rather than an ambiguous one (eg. "set $x =
- 1" will now work).
-
- * infrun.c (wait_for_inferior): Put in ifdef for Sony News in
- check for trap by INNER_THAN macro.
-
- * eval.c (evaluate_subexp): Put in catch to keep the user from
- attempting to call a non function as a function.
-
-Tue Sep 20 10:35:53 1988 Randall Smith (randy at oatmeal.ai.mit.edu)
-
- * dbxread.c (read_dbx_symtab): Installed code to keep track of
- which global symbols did not have debugger symbols refering to
- them, and recording these via record_misc_function.
-
- * dbxread.c: Killed code to check for extra global symbols in the
- debugger symbol table.
-
- * printcmd.c, breakpoint.c: Modified help entries for several
- commands to make sure that abbreviations were clearly marked and
- that the right commands showed up in the help listings.
-
- * main.c, command.c, breakpoint.c, infcmd.c, printcmd.c,
- valprint.c, defs.h: Modified help system to allow help on a class
- name to show subcommands as well as commands and help on a command
- to show *all* subcommands of that command.
-
-Fri Sep 16 16:51:19 1988 Randall Smith (randy at gluteus.ai.mit.edu)
-
- * breakpoint.c (_initialize_breakpoint): Made "breakpoints"
- subcommands of enable, disable, and delete use class 0 (ie. they
- show up when you do a help xxx now).
-
- * infcmd.c,printcmd,c,main.c,valprint.c: Changed the set-*
- commands into subcommands of set. Created "set variable" for use
- with variables whose names might conflict with other subcommands.
-
- * blockframe.c, dbxread.c, coffread.c, expread.y, source.c:
- Fixed mostly minor (and one major one in block_for_pc) bugs
- involving checking the partial_symtab_list when a scan through the
- symtab_list fails.
-
-Wed Sep 14 12:02:05 1988 Randall Smith (randy at sugar-smacks.ai.mit.edu)
-
- * breakpoint.c, gdb.texinfo: Added enable breakpoints, disable
- breakpoints and delete breakpoints as synonyms for enable,
- disable, and delete. This seemed reasonable because of the
- immeninent arrival of watchpoints & etc.
-
- * gdb.texinfo: Added enable display, disable display, and delete
- display to manual.
-
-Tue Sep 13 16:53:56 1988 Randall Smith (randy at sugar-smacks.ai.mit.edu)
-
- * inferior.h, infrun.c, infcmd.c: Added variable
- stop_random_signal to indicate when a proceed had been stopped by
- an unexpected signal. Used this to determine (in normal_stop)
- whether the current display point should be deleted.
-
- * valops.c: Fix to value_ind to check for reference before doing a
- COERCE_ARRAY.
-
-Sun Jul 31 11:42:36 1988 Richard Stallman (rms at frosted-flakes.ai.mit.edu)
-
- * breakpoint.c (_initialize_breakpoint): Clean up doc for commands
- that can now apply also to auto-displays.
-
- * coffread.c (record_line): Corrected a spazz in editing.
- Also removed the two lines that assume line-numbers appear
- only in increasing order.
-
-Tue Jul 26 22:19:06 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * expression.h, eval.c, expprint.c, printcmd.c, valarith.c,
- valops.c, valprint.c, values.c, m-*.h: Changes for evaluating and
- displaying 64-bit `long long' integers. Each machine must define
- a LONGEST type, and a BUILTIN_TYPE_LONGEST.
-
- * symmisc.c: (print_symtab) check the status of the fopen and call
- perror_with_name if needed.
-
-Thu Jul 21 00:56:11 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * Convex: core.c: changes required by Convex's SOFF format were
- isolated in convex-dep.c.
-
-Wed Jul 20 21:26:10 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * coffread.c, core.c, expread.y, i386-pinsn.c, infcmd.c, inflow.c,
- infrun.c, m-i386.h, main.c, remote.c, source.c, valops.c:
- Improvements for the handling of the i386 and other machines
- running USG. (Several of these files just needed extra header files
- such as types.h.) utils.c: added bcopy, bcmp, bzero, getwd, list
- of signals, and queue routines for USG systems. Added vfork macro
- to i386
-
- * printcmd.c, breakpoint.c: New commands to enable/disable
- auto-displays. Also `delete display displaynumber' works like
- `undisplay displaynumber'.
-
-Tue Jul 19 02:17:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * coffread.c: (coff_lookup_type) Wrong portion of type_vector was
- being bzero'd after type_vector was reallocated.
-
- * printcmd.c: (delete_display) Check for a display chain before
- attempting to delete a display.
-
- * core.c, *-dep.c (*-infdep moved to *-dep): machine-dependent
- parts of core.c (core_file_command, exec_file_command) moved to
- *-dep.c.
-
-Mon Jul 18 19:45:51 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * dbxread.c: typo in read_struct_type (missing '=') was causing a
- C struct to be parsed as a C++ struct, resulting in a `invalid
- character' message.
-
-Sun Jul 17 22:27:32 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * printcmd.c, symtab.c, valops.c, expread.y: When an expression is
- read, the innermost block required to evaluate the expression is
- saved in the global variable `innermost_block'. This information
- is saved in the `block' field of an auto-display so that
- expressions with inactive variables can be skipped. `info display'
- tells the user which displays are active and which are not. New
- fn `contained_in' returns nonzero if one block is contained within
- another.
-
-Fri Jul 15 01:53:14 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * infrun.c, m-i386.h: Use macro TRAPS_EXPECTED to set number of
- traps to skip when sh execs the program. Default is 2, m-i386.h
- overrides this and sets to 4.
-
- * coffread.c, infrun.c: minor changes for the i386. May be able
- to eliminate them with more general code.
-
- * default-infdep.c: #ifdef SYSTEMV, include header file types.h.
- Also switched the order of signal.h and user.h, since System 5
- requires signal.h to come first.
-
- * core.c main.c, remote,c, source.c, inflow.c: #ifdef SYSTEMV,
- include various header files. Usually types.h and fcntl.h.
-
- * utils.c: added queue routines needed by the i386 (and other sys
- 5 machines).
-
- * sys5.c, regex.c, regex.h: new files for sys 5 systems. (The
- regex files are simply links to /gp/gnu/lib.)
-
-Thu Jul 14 01:47:14 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * config.gdb, README: Provide a list of known machines when user
- enters an invalid machine. New second arg is operating system,
- currently only used with `sunos4' or `os4'. Entry for i386 added.
-
- * news-infdep.c: new file.
-
- * m-news.h: new version which deals with new bugs in news800's OS.
-
-Tue Jul 12 19:52:16 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * Makefile, *.c, munch, config.gdb, README: New initialization
- scheme uses nm to find functions whose names begin with
- `_initialize_'. Files `initialize.h', `firstfile.c',
- `lastfile.c', `m-*init.h' no longer needed.
-
- * eval.c, symtab.c, valarith.c, valops.c, value.h, values.c: Bug
- fixes from gdb+ 2.5.4. evaluate_subexp takes a new arg, type
- expected. New fn value_virtual_fn_field.
-
-Mon Jul 11 00:48:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * core.c (read_memory): xfer_core_file was being called with an
- extra argument (0) by read_memory.
-
- * core.c (read_memory), *-infdep.c (read_inferior_memory),
- valops.c (value_at): read_memory and read_inferior_memory now work
- like write_memory and write_inferior_memory in that errno is
- checked after each ptrace and returned to the caller. Used in
- value_at to detect references to addresses which are out of
- bounds. Also core.c (xfer_core_file): return 1 if invalid
- address, 0 otherwise.
-
- * inflow.c, <machine>-infdep.c: removed all calls to ptrace from
- inflow.c and put them in machine-dependent files *-infdep.c.
-
-Sun Jul 10 19:19:36 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * symmisc.c: (read_symsegs) Accept only format number 2. Since
- the size of the type structure changed when C++ support was added,
- format 1 can no longer be used.
-
- * core.c, m-sunos4.h: (core_file_command) support for SunOS 4.0.
- Slight change in the core structure. #ifdef SUNOS4. New file
- m-sunos4.h. May want to change config.gdb also.
-
-Fri Jul 8 19:59:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * breakpoint.c: (break_command_1) Allow `break if condition'
- rather than parsing `if' as a function name and returning an
- error.
-
-Thu Jul 7 22:22:47 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * C++: valops.c, valprint.c, value.h, values.c: merged code to deal
- with C++ expressions.
-
-Wed Jul 6 03:28:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * C++: dbxread.c: (read_dbx_symtab, condense_misc_bunches,
- add_file_command) Merged code to read symbol information from
- an incrementally linked file. symmisc.c:
- (init_free_inclink_symtabs, free_inclink_symtabs) Cleanup
- routines.
-
-Tue Jul 5 02:50:41 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * C++: symtab.c, breakpoint.c, source.c: Merged code to deal with
- ambiguous line specifications. In C++ one can have overloaded
- function names, so that `list classname::overloadedfuncname'
- refers to several different lines, possibly in different files.
-
-Fri Jul 1 02:44:20 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu)
-
- * C++: symtab.c: replaced lookup_symtab_1 and lookup_symtab_2 with
- a modified lookup_symbol which checks for fields of the current
- implied argument `this'. printcmd.c, source.c, symtab.c,
- valops.c: Need to change callers once callers are
- installed.
-
-Wed Jun 29 01:26:56 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu)
-
- * C++: eval.c, expprint.c, expread.y, expression.h, valarith.c,
- Merged code to deal with evaluation of user-defined operators,
- member functions, and virtual functions.
- binop_must_be_user_defined tests for user-defined binops,
- value_x_binop calls the appropriate operator function.
-
-Tue Jun 28 02:56:42 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu)
-
- * C++: Makefile: changed the echo: expect 101 shift/reduce conflicts
- and 1 reduce/reduce conflict.
-
-Local Variables:
-mode: indented-text
-left-margin: 8
-fill-column: 74
-version-control: never
-End:
diff --git a/gnu/usr.bin/gdb/Gdbinit b/gnu/usr.bin/gdb/Gdbinit
deleted file mode 100644
index bcacd5d..0000000
--- a/gnu/usr.bin/gdb/Gdbinit
+++ /dev/null
@@ -1,15 +0,0 @@
-echo Setting up the environment for debugging gdb.\n
-
-b fatal
-
-b info_command
-commands
- silent
- return
-end
-
-define rr
- run
-end
-
-set prompt (top-gdb)
diff --git a/gnu/usr.bin/gdb/Makefile b/gnu/usr.bin/gdb/Makefile
deleted file mode 100644
index 550ed07..0000000
--- a/gnu/usr.bin/gdb/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-# @(#)Makefile 6.4 (Berkley) 5/6/91
-
-PROG= gdb
-GDBSRCS= blockframe.c breakpoint.c command.c copying.c core.c \
- cplus-dem.c dbxread.c environ.c eval.c expprint.c \
- expread.y findvar.c infcmd.c inflow.c infrun.c \
- main.c obstack.c printcmd.c regex.c remote.c \
- remote-sl.c source.c stack.c symmisc.c symtab.c \
- utils.c valarith.c valops.c valprint.c values.c \
- version.c
-READLINESRCS= funmap.c history.c keymaps.c readline.c
-SRCS= $(CONFIGSRCS) $(GDBSRCS) $(READLINESRCS) init.c
-CFLAGS+= -I. -I$(.CURDIR) -I$(.CURDIR)/config -I$(.CURDIR)/readline \
- -DHAVE_VPRINTF -DVI_MODE -DKERNELDEBUG -DNEWVM
-LDADD= -ltermcap
-YFLAGS=
-.PATH: $(.CURDIR)/config $(.CURDIR)/readline
-
-depend:
-
-.include "config/Makefile.$(MACHINE)"
-.include <bsd.prog.mk>
-
-$(OBJS): param.h
-
-#
-# Generate the constructor
-#
-init.c: $(CONFIGSRCS) $(GDBSRCS) $(READLINESRCS)
- -((cd $(.CURDIR)/config; \
- egrep -h '^_initialize_[^ ]* *\(\)' $(CONFIGSRCS)); \
- (cd $(.CURDIR); egrep -h '^_initialize_[^ ]* *\(\)' $(GDBSRCS)); \
- (cd $(.CURDIR)/readline; \
- egrep -h '^_initialize_[^ ]* *\(\)' $(READLINESRCS))) | \
- (echo 'void initialize_all_files () {'; sed -e 's/$$/;/'; echo '}') \
- > init.c
-
-CLEANFILES+= init.c param.h
diff --git a/gnu/usr.bin/gdb/Makefile.dist b/gnu/usr.bin/gdb/Makefile.dist
deleted file mode 100644
index 3cbc91f..0000000
--- a/gnu/usr.bin/gdb/Makefile.dist
+++ /dev/null
@@ -1,371 +0,0 @@
-/* This file should be run through the C preprocessor by config.gdb
- to produce the Makefile. */
-
-/* Define this to xgdb if you want to compile xgdb as well as gdb. */
-XGDB=
-/* Place to install binaries. */
-bindir=/usr/local/bin
-/* Place to install X binaries. */
-xbindir=$(bindir)
-
-/* System V: If you compile gdb with a compiler which uses the coff
- encapsulation feature (this is a function of the compiler used, NOT
- of the m-?.h file selected by config.gdb), you must make sure that
- the GNU nm is the one that is used by munch. */
-
-/* If you are compiling with GCC, make sure that either 1) You use the
- -traditional flag, or 2) You have the fixed include files where GCC
- can reach them. Otherwise the ioctl calls in inflow.c and readline.c
- will be incorrectly compiled. The "fixincludes" script in the gcc
- distribution will fix your include files up. */
-/* CC=gcc -traditional */
-CC=cc
-
-/* It is also possible that you will need to add -I/usr/include/sys to the
- CFLAGS section if your system doesn't have fcntl.h in /usr/include (which
- is where it should be according to Posix). */
-
-YACC=bison -y -v
-/* YACC=yacc */
-SHELL=/bin/sh
-MAKE=make
-
-/* Set this up with gcc if you have gnu ld and the loader will print out
- line numbers for undefinded refs. */
-/* CC-LD=gcc -static */
-CC-LD=${CC}
-
-/* If you are using the GNU C library, uncomment the following line. */
-/* HAVE_VPRINTF_DEFINE = -DHAVE_VPRINTF */
-
-/* -I. for "#include <obstack.h>". Possibly regex.h also. */
-
-/* M_CFLAGS, if defined, has system-dependent CFLAGS. */
-#if !defined(M_CFLAGS)
-#define M_CFLAGS
-#endif
-
-/* CFLAGS for both GDB and readline. */
-GLOBAL_CFLAGS = -g M_CFLAGS
-CFLAGS = -I. ${HAVE_VPRINTF_DEFINE} ${GLOBAL_CFLAGS}
-/* None of the things in CFLAGS will do any harm, and on some systems
- (e.g. SunOS4) it is important to use the M_CFLAGS. */
-LDFLAGS = $(CFLAGS)
-
-/*
- define this to be "obstack.o" if you don't have the obstack library installed
- you must at the same time define OBSTACK1 as "obstack.o"
- so that the dependencies work right. Similarly with REGEX and "regex.o".
- You must define REGEX and REGEX1 on USG machines.
- If your sysyem is missing alloca(), or, more likely, it's there but
- it doesn't work, define ALLOCA & ALLOCA1 */
-OBSTACK = obstack.o
-OBSTACK1 = obstack.o
-
-#ifdef M_REGEX
-REGEX = M_REGEX
-REGEX1 = M_REGEX
-#else
-REGEX =
-REGEX1 =
-#endif
-
-#ifdef M_ALLOCA
-ALLOCA = M_ALLOCA
-ALLOCA1 = M_ALLOCA
-#else
-ALLOCA =
-ALLOCA1 =
-#endif
-
-/*
- define this to be "malloc.o" if you want to use the gnu malloc routine
- (useful for debugging memory allocation problems in gdb). Otherwise, leave
- it blank. */
-/* GNU_MALLOC = */
-GNU_MALLOC = malloc.o
-
-/* Flags to be used in compiling malloc.o
- Specify range checking for storage allocation. */
-/* MALLOC_FLAGS = ${CFLAGS} */
-MALLOC_FLAGS = ${CFLAGS} -Drcheck -Dbotch=fatal_dump_core -DMSTATS
-
-/* Define SYSV if compiling on a system V or HP machine. */
-#ifdef M_SYSV
-SYSV_DEFINE = -DSYSV
-#else
-SYSV_DEFINE =
-#endif
-
-/* MUNCH_DEFINE should be -DSYSV if have System V-style nm,
- or null if have BSD-style nm. */
-#ifdef M_BSD_NM
-MUNCH_DEFINE =
-#else
-MUNCH_DEFINE = ${SYSV_DEFINE}
-#endif
-
-/* Flags that describe where you can find the termcap library.
- You may need to make other arrangements for USG. */
-TERMCAP = -ltermcap
-
-/* M_CLIBS, if defined, has system-dependent libs
- For example, -lPW for System V to get alloca(). */
-#ifndef M_CLIBS
-#define M_CLIBS
-#endif
-CLIBS = ${ADD_FILES} ${TERMCAP} M_CLIBS
-
-ADD_FILES = ${OBSTACK} ${REGEX} ${ALLOCA} ${GNU_MALLOC}
-ADD_DEPS = ${OBSTACK1} ${REGEX1} ${ALLOCA1} ${GNU_MALLOC}
-
-SFILES = blockframe.c breakpoint.c dbxread.c coffread.c command.c core.c \
- environ.c eval.c expprint.c findvar.c infcmd.c inflow.c infrun.c \
- kdb-start.c main.c printcmd.c \
- remote.c source.c stack.c standalone.c stuff.c symmisc.c symtab.c \
- utils.c valarith.c valops.c valprint.c values.c version.c expread.y \
- xgdb.c
-
-DEPFILES = umax-dep.c gould-dep.c default-dep.c sun3-dep.c \
- sparc-dep.c hp9k320-dep.c hp300bsd-dep.c news-dep.c i386-dep.c \
- symmetry-dep.c convex-dep.c altos-dep.c isi-dep.c pyr-dep.c
-
-PINSNS = gld-pinsn.c i386-pinsn.c sparc-pinsn.c vax-pinsn.c m68k-pinsn.c \
- ns32k-pinsn.c convex-pinsn.c pyr-pinsn.c
-
-HFILES = command.h defs.h environ.h expression.h frame.h getpagesize.h \
- inferior.h symseg.h symtab.h value.h wait.h \
- a.out.encap.h a.out.gnu.h stab.gnu.h
-
-OPCODES = m68k-opcode.h pn-opcode.h sparc-opcode.h npl-opcode.h vax-opcode.h \
- ns32k-opcode.h convex-opcode.h pyr-opcode.h
-
-MFILES = m-hp9k320.h m-hp300bsd.h m-i386.h m-i386gas.h \
- m-i386-sv32.h m-i386g-sv32.h m-isi.h m-merlin.h \
- m-altos.h m-news.h m-newsos3.h m-npl.h m-pn.h \
- m-sparc.h m-sun2.h m-sun3.h m-sun2os4.h \
- m-sun3os4.h m-sun4os4.h m-umax.h m-vax.h m-symmetry.h m-convex.h \
- m-pyr.h
-
-/* This list of files really shouldn't be in this makefile, but I can't think
- of any good way to get the readline makefile to tell us what files
- to put in our tarfile. */
-READLINE = readline.c history.c funmap.c \
- emacs_keymap.c vi_keymap.c vi_mode.c keymaps.c \
- readline.h history.h keymaps.h chardefs.h \
- inc-readline.texinfo inc-history.texinfo \
- readline.texinfo history.texinfo \
- Makefile ChangeLog
-
-REMOTE_EXAMPLES = remote-sa.m68k.shar remote-multi.shar
-
-POSSLIBS = obstack.h obstack.c regex.c regex.h malloc.c alloca.c
-
-TESTS = testbpt.c testfun.c testrec.c testreg.c testregs.c
-
-OTHERS = Makefile.dist createtags munch config.gdb ChangeLog README TAGS \
- gdb.texinfo .gdbinit COPYING expread.tab.c stab.def \
- XGDB-README copying.c Projects Convex.notes copying.awk hp-include
-
-TAGFILES = ${SFILES} ${DEPFILES} ${PINSNS} ${HFILES} ${OPCODES} ${MFILES} \
- ${POSSLIBS}
-TARFILES = ${TAGFILES} ${OTHERS} ${REMOTE_EXAMPLES}
-
-OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \
- values.o eval.o valops.o valarith.o valprint.o printcmd.o \
- symtab.o symmisc.o coffread.o dbxread.o infcmd.o infrun.o remote.o \
- command.o utils.o expread.o expprint.o pinsn.o environ.o version.o \
- copying.o ${READLINEOBS}
-
-TSOBS = core.o inflow.o dep.o
-
-NTSOBS = standalone.o
-
-TSSTART = /lib/crt0.o
-
-NTSSTART = kdb-start.o
-
-RL_LIB = readline/libreadline.a
-
-/* Do some fancy trickery to produce a line like
- -DM_MAKEDEFINE="-DM_SYSV -DM_BSD_NM".
-*/
-MD=M_MAKEDEFINE
-
-/* Avoid funny things that Sun's make throws in for us. */
-/* TARGET_ARCH is supposed to get around it putting in the machine type.
- If the "things" up there really is plural, we'll need to do something
- else as well. */
-/*.c.o:
- ${CC} -c ${CFLAGS} $< */
-TARGET_ARCH=
-
-all: gdb $(XGDB)
-
-install: gdb $(XGDB)
- cp gdb $(bindir)/gdb.new
- mv $(bindir)/gdb.new $(bindir)/gdb
- -if [ "$(XGDB)" = xgdb ]; then \
- cp xgdb $(xbindir)/xgdb.new; \
- mv $(xbindir)/xgdb.new $(xbindir)xgdb; \
- fi
-
-gdb : $(OBS) $(TSOBS) ${ADD_DEPS} ${RL_LIB}
- rm -f init.c
- ./munch ${MUNCH_DEFINE} $(OBS) $(TSOBS) > init.c
- ${CC-LD} $(LDFLAGS) -o gdb init.c $(OBS) $(TSOBS) ${RL_LIB} $(CLIBS)
-
-/* This is useful when debugging GDB, because Unix doesn't let you run GDB
- on itself without copying the executable. So "make gdb1" will make
- gdb and put a copy in gdb1, and you can run it with "gdb gdb1". */
-gdb1 : gdb
- cp gdb gdb1
-
-Makefile : Makefile.dist
- cp Makefile.dist tmp.c
- $(CC) -E >Makefile tmp.c $(MD) "-DM_MAKEDEFINE=$(MD)"
- -rm tmp.c
-/* This did not work-- -Usparc became "-Usparc" became "-Usparc.
- Or something like that. */
-/* $(CC) -E >Makefile tmp.c $(MD) "-DM_MAKEDEFINE=\"$(MD)\"" */
-
-xgdb : $(OBS) $(TSOBS) xgdb.o ${ADD_DEPS} ${RL_LIB}
- rm -f init.c
- ./munch ${MUNCH_DEFINE} $(OBS) $(TSOBS) xgdb.o > init.c
- $(CC-LD) $(LDFLAGS) -o xgdb init.c $(OBS) $(TSOBS) xgdb.o \
- -lXaw -lXmu -lXt -lX11 ${RL_LIB} $(CLIBS)
-
-/* Old (pre R3) xgdb comp.
- $(CC-LD) $(LDFLAGS) -o xgdb init.c $(OBS) $(TSOBS) xgdb.o \
- -lXaw -lXt -lX11 $(CLIBS) */
-
-kdb : $(NTSSTART) $(OBS) $(NTSOBS) ${ADD_DEPS} ${RL_LIB}
- rm -f init.c
- ./munch ${MUNCH_DEFINE} $(OBS) $(NTSOBS) > init.c
- $(CC) $(LDFLAGS) -c init.c $(CLIBS)
- ld -o kdb $(NTSSTART) $(OBS) $(NTSOBS) init.o ${RL_LIB} -lc $(CLIBS)
-
-/* If it can figure out the appropriate order, createtags will make sure
- that the proper m-*, *-dep, *-pinsn, and *-opcode files come first
- in the tags list. It will attempt to do the same for dbxread.c and
- coffread.c. This makes using M-. on machine dependent routines much
- easier. */
-
-TAGS: ${TAGFILES}
- createtags ${TAGFILES}
-tags: TAGS
-
-gdb.tar: ${TARFILES}
- rm -f gdb.tar
- mkdir dist-gdb
- cd dist-gdb ; for i in ${TARFILES} ; do ln -s ../$$i . ; done
- mkdir dist-gdb/readline
- cd dist-gdb/readline ; for i in ${READLINE} ; do ln -s ../../readline/$$i . ; done
- tar chf gdb.tar dist-gdb
- rm -rf dist-gdb
-
-/* Remove gdb.tar.Z so stupid compress doesn't ask whether we want to
- overwrite it. compress -f is not what we want, because we do want
- to know if compress would not make it smaller. */
-gdb.tar.Z: gdb.tar
- if [ -f gdb.tar.Z ]; then rm -f gdb.tar.Z; else true; fi
- compress gdb.tar
-
-clean:
- rm -f ${OBS} ${TSOBS} ${NTSOBS} ${OBSTACK} ${REGEX} ${GNU_MALLOC}
- rm -f init.c init.o
- rm -f xgdb.o xgdb
- rm -f gdb core gdb.tar gdb.tar.Z make.log
- rm -f gdb[0-9]
- cd readline ; make clean
-
-distclean: clean expread.tab.c TAGS
- rm -f dep.c opcode.h param.h pinsn.c config.status
- rm -f y.output yacc.acts yacc.tmp
- rm -f ${TESTS} Makefile
-
-realclean: clean
- rm -f expread.tab.c TAGS
- rm -f dep.c opcode.h param.h pinsn.c config.status
- rm -f Makefile
-
-xgdb.o : defs.h param.h symtab.h frame.h
-
-/* Make copying.c from COPYING */
-copying.c : COPYING copying.awk
- awk -f copying.awk < COPYING > copying.c
-
-expread.tab.c : expread.y
- @echo 'Expect 4 shift/reduce conflict.'
- ${YACC} expread.y
- mv y.tab.c expread.tab.c
-
-expread.o : expread.tab.c defs.h param.h symtab.h frame.h expression.h
- $(CC) -c ${CFLAGS} expread.tab.c
- mv expread.tab.o expread.o
-
-readline/libreadline.a : force_update
- cd readline ; ${MAKE} "SYSV=${SYSV_DEFINE}" \
- "DEBUG_FLAGS=${GLOBAL_CFLAGS}" "CC=${CC}" libreadline.a
-
-force_update :
-
-/* Only useful if you are using the gnu malloc routines. */
-malloc.o : malloc.c
- ${CC} -c ${MALLOC_FLAGS} malloc.c
-
-/* dep.o depends on config.status in case someone reconfigures gdb out
- from under an already compiled gdb. */
-dep.o : dep.c config.status defs.h param.h frame.h inferior.h obstack.h \
- a.out.encap.h
-
-/* pinsn.o depends on config.status in case someone reconfigures gdb out
- from under an already compiled gdb. */
-pinsn.o : pinsn.c config.status defs.h param.h symtab.h obstack.h symseg.h \
- frame.h opcode.h
-
-/* The rest of this is a standard dependencies list (hand edited output of
- cpp -M). It does not include dependencies of .o files on .c files. */
-/* All files which depend on config.status also depend on param.h in case
- someone reconfigures gdb out from under an already compiled gdb. */
-blockframe.o : defs.h param.h config.status symtab.h obstack.h symseg.h frame.h
-breakpoint.o : defs.h param.h config.status symtab.h obstack.h symseg.h frame.h
-coffread.o : defs.h param.h config.status
-command.o : command.h defs.h
-core.o : defs.h param.h config.status a.out.encap.h
-dbxread.o : param.h config.status defs.h symtab.h obstack.h symseg.h a.out.encap.h \
- stab.gnu.h
-environ.o : environ.h
-eval.o : defs.h param.h config.status symtab.h obstack.h symseg.h value.h expression.h
-expprint.o : defs.h symtab.h obstack.h symseg.h param.h config.status expression.h
-findvar.o : defs.h param.h config.status symtab.h obstack.h symseg.h frame.h value.h
-infcmd.o : defs.h param.h config.status symtab.h obstack.h symseg.h frame.h inferior.h \
- environ.h value.h
-inflow.o : defs.h param.h config.status frame.h inferior.h
-infrun.o : defs.h param.h config.status symtab.h obstack.h symseg.h frame.h inferior.h \
- wait.h
-kdb-start.o : defs.h param.h config.status
-main.o : defs.h command.h param.h config.status
-malloc.o : getpagesize.h
-obstack.o : obstack.h
-printcmd.o : defs.h param.h config.status frame.h symtab.h obstack.h symseg.h value.h \
- expression.h
-regex.o : regex.h
-remote.o : defs.h param.h config.status frame.h inferior.h wait.h
-source.o : defs.h symtab.h obstack.h symseg.h param.h config.status
-stack.o : defs.h param.h config.status symtab.h obstack.h symseg.h frame.h
-standalone.o : defs.h param.h config.status symtab.h obstack.h symseg.h frame.h \
- inferior.h wait.h
-symmisc.o : defs.h symtab.h obstack.h symseg.h obstack.h
-symtab.o : defs.h symtab.h obstack.h symseg.h param.h config.status obstack.h
-utils.o : defs.h param.h config.status
-valarith.o : defs.h param.h config.status symtab.h obstack.h symseg.h value.h expression.h
-valops.o : defs.h param.h config.status symtab.h obstack.h symseg.h value.h frame.h \
- inferior.h
-valprint.o : defs.h param.h config.status symtab.h obstack.h symseg.h value.h
-values.o : defs.h param.h config.status symtab.h obstack.h symseg.h value.h
-
-robotussin.h : getpagesize.h
-symtab.h : obstack.h symseg.h
-a.out.encap.h : a.out.gnu.h
-
diff --git a/gnu/usr.bin/gdb/Projects b/gnu/usr.bin/gdb/Projects
deleted file mode 100644
index f38f6c7..0000000
--- a/gnu/usr.bin/gdb/Projects
+++ /dev/null
@@ -1,114 +0,0 @@
-
- Suggested projects for aspiring or current GDB hackers
- ======================================================
-
- (You should probably chat with kingdon@ai.mit.edu to make sure that
- no one else is doing the project you chose).
-
-Add watchpoints (break if a memory location changes). This would
-usually have to involve constant single stepping, but occasionally
-there is operating system support which gdb should be able to cleanly
-use (e.g. on the 80386, there are 4 debug registers. By ptracing an
-address into them, you can get a trap on writes or on reads and
-writes).
-
-Rewrite proceed, wait_for_inferior, and normal_stop to clean them up.
-Suggestions:
-
- 1) Make each test in wait_for_inferior a seperate subroutine
- call.
- 2) Combine wait_for_inferior and normal_stop to clean up
- communication via global variables.
- 3) See if you can find some way to clean up the global
- variables that are used; possibly group them by data flow
- and information content?
-
-Work out some kind of way to allow running the inferior to be done as
-a sub-execution of, eg. breakpoint command lists. Currently running
-the inferior interupts any command list execution. This would require
-some rewriting of wait_for_inferior & friends, and hence should
-probably be done in concert with the above.
-
-Add function arguments to gdb user defined functions.
-
-Add convenience variables that refer to exec file, symbol file,
-selected frame source file, selected frame function, selected frame
-line number, etc.
-
-Add a "suspend" subcommand of the "continue" command to suspend gdb
-while continuing execution of the subprocess. Useful when you are
-debugging servers and you want to dodge out and initiate a connection
-to a server running under gdb.
-
-Make "handle" understand symbolic signal names.
-
-Work out and implement a reasonably general mechanism for multi-threaded
-processies. There are parts of one implemented in convex-dep.c, if
-you want an example.
-
-A standalone version of gdb on the i386 exists. Anyone who wants to
-do some serious working cleaning it up and making it a general
-standalone gdb should contact pace@wheaties.ai.mit.edu.
-
-Add stab information to allow reasonable debugging of inline functions
-(possibly they should show up on a stack backtrace? With a note
-indicating that they weren't "real"?).
-
-Implement support for specifying arbitrary locations of stack frames
-(in practice, this usually requires specification of both the top and
-bottom of the stack frame (fp and sp), since you *must* retrieve the
-pc that was saved in the innermost frame).
-
-Modify the naked "until" command to step until past the current source
-line, rather than past the current pc value. This is tricky simply
-because the low level routines have no way of specifying a multi-line
-step range, and there is no way of saying "don't print stuff when we
-stop" from above (otherwise could just call step many times).
-
-Modify the handling of symbols grouped through BINCL/EINCL stabs to
-allocate a partial symtab for each BINCL/EINCL grouping. This will
-seriously decrease the size of inter-psymtab dependencies and hence
-lessen the amount that needs to be read in when a new source file is
-accessed.
-
-Work out some method of saving breakpoints across the reloading of an
-executable. Probably this should be by saving the commands by which
-the breakpoints were set and re-executing them (as text locations may
-change).
-
-Do an "x/i $pc" after each stepi or nexti.
-
-Modify all of the disassemblers to use printf_filtered to get correct
-more filtering.
-
-Modify gdb to work correctly with Pascal.
-
-Rewrite macros that handle frame chaining and frameless functions.
-They should be able to tell the difference between start, main, and a
-frameless function called from main.
-
-Work out what information would need to be included in an executable
-by the compiler to allow gdb to debug functions which do not have a
-frame pointer. Modify gdb and gcc to do this.
-
-When `attached' to a program (via either OS support or remote
-debugging), gdb should arrange to catch signals which the terminal
-might send, as it is unlikely that the program will be able to notice
-them. SIGINT and SIGTSTP are obvious examples.
-
-Enhance the gdb manual with extra examples where needed.
-
-Arrange for list_command not to use decode_line_1 and thus not require
-symbols to be read in simply to read a source file.
-
-Problem in xgdb; the readline library needs the terminal in CBREAK
-mode for command line editing, but this makes it difficult to dispatch
-on button presses. Possible solution: use a define to replace getc in
-readline.c with a routine that does button dispatches. You should
-probably see XGDB-README before you fiddle with XGDB. Also, someone
-is implementing a new xgdb; it may not be worth while fiddling with
-the old one.
-
-# Local Variables:
-# mode: text
-# End:
diff --git a/gnu/usr.bin/gdb/README.gnu b/gnu/usr.bin/gdb/README.gnu
deleted file mode 100644
index fa54dec..0000000
--- a/gnu/usr.bin/gdb/README.gnu
+++ /dev/null
@@ -1,142 +0,0 @@
-This is GDB, the GNU source-level debugger, presently running under un*x.
-
-Before compiling GDB, you must tell GDB what kind of machine you are
-running on. To do this, type `config.gdb machine', where machine is
-something like `vax' or `sun2'. For a list of valid machine types,
-type `config.gdb'.
-
-Normally config.gdb edits the makefile as necessary. If you have to
-edit the makefile on a standard machine listed in config.gdb this
-should be considered a bug and reported as such.
-
-Once these files are set up, just `make' will do everything,
-producing an executable `gdb' in this directory.
-
-If you want a new (current to this release) version of the manual, you
-will have to use the gdb.texinfo file provided with this distribution.
-The gdb.texinfo file requires the texinfo-format-buffer command from
-emacs 18.55 or later.
-
-About languages other than C...
-
-C++ support has been integrated into gdb. GDB should work with
-FORTRAN programs (if you have problem, please send a bug report), but
-I am not aware of anyone who is working on getting it to use the
-syntax of any language other than C or C++. Pascal programs which use
-sets, subranges, file variables, or nested functions will not
-currently work.
-
-About -gg format...
-
-Currently GDB version 3.x does *not* support GCC's -gg format. This
-is because it (in theory) has fast enough startup on dbx debugging
-format object files that -gg format is unnecessary (and hence
-undesirable, since it wastes space and processing power in gcc). I
-would like to hear people's opinions on the amount of time currently
-spent in startup; is it fast enough?
-
-About remote debugging...
-
-The two files remote-multi.shar and remote-sa.m68k.shar contain two
-examples of a remote stub to be used with remote.c. The the -multi
-file is a general stub that can probably be running on various
-different flavors of unix to allow debugging over a serial line from
-one machine to another. The remote-sa.m68k.shar is designed to run
-standalone on a 68k type cpu and communicate properley with the
-remote.c stub over a serial line.
-
-About reporting bugs...
-
-The correct address for reporting bugs found with gdb is
-"bug-gdb@prep.ai.mit.edu". Please send all bugs to that address.
-
-About xgdb...
-
-xgdb.c was provided to us by the user community; it is not an integral
-part of the gdb distribution. The problem of providing visual
-debugging support on top of gdb is peripheral to the GNU project and
-(at least right now) we can't afford to put time into it. So while we
-will be happy to incorporate user fixes to xgdb.c, we do not guarantee
-that it will work and we will not fix bugs reported in it. Someone is
-working on writing a new XGDB, so improving (e.g. by fixing it so that
-it will work, if it doesn't currently) the current one is not worth it.
-
-For those intersted in auto display of source and the availability of
-an editor while debugging I suggest trying gdb-mode in gnu-emacs.
-Comments on this mode are welcome.
-
-About the machine-dependent files...
-
-m-<machine>.h (param.h is a link to this file).
-This file contains macro definitions that express information
-about the machine's registers, stack frame format and instructions.
-
-<machine>-opcode.h (opcode.h is a link to this file).
-<machine>-pinsn.c (pinsn.c is a link to this file).
-These files contain the information necessary to print instructions
-for your cpu type.
-
-<machine>-dep.c (dep.c is a link to this file).
-Those routines which provide a low level interface to ptrace and which
-tend to be machine-dependent. (The machine-independent routines are in
-`infrun.c' and `inflow.c')
-
-About writing code for GDB...
-
-We appreciate having users contribute code that is of general use, but
-for it to be included in future GDB releases it must be cleanly
-written. We do not want to include changes that will needlessly make future
-maintainance difficult. It is not much harder to do things right, and
-in the long term it is worth it to the GNU project, and probably to
-you individually as well.
-
-Please code according to the GNU coding standards. If you do not have
-a copy, you can request one by sending mail to gnu@prep.ai.mit.edu.
-
-Please try to avoid making machine-specific changes to
-machine-independent files (i.e. all files except "param.h" and
-"dep.c". "pinsn.c" and "opcode.h" are processor-specific but not
-operating system-dependent). If this is unavoidable, put a hook in
-the machine-independent file which calls a (possibly)
-machine-dependent macro (for example, the IGNORE_SYMBOL macro can be
-used for any symbols which need to be ignored on a specific machine.
-Calling IGNORE_SYMBOL in dbxread.c is a lot cleaner than a maze of #if
-defined's). The machine-independent code should do whatever "most"
-machines want if the macro is not defined in param.h. Using #if
-defined can sometimes be OK (e.g. SET_STACK_LIMIT_HUGE) but should be
-conditionalized on a specific feature of an operating system (set in
-param.h) rather than something like #if defined(vax) or #if
-defined(SYSV).
-
-It is better to replace entire routines which may be system-specific,
-rather than put in a whole bunch of hooks which are probably not going
-to be helpful for any purpose other than your changes. For example,
-if you want to modify dbxread.c to deal with DBX debugging symbols
-which are in COFF files rather than BSD a.out files, do something
-along the lines of a macro GET_NEXT_SYMBOL, which could have
-different definitions for COFF and a.out, rather than trying to put
-the necessary changes throughout all the code in dbxread.c that
-currently assumes BSD format.
-
-Please avoid duplicating code. For example, if something needs to be
-changed in read_inferior_memory, it is very painful because there is a
-copy in every dep.c file. The correct way to do this is to put (in
-this case) the standard ptrace interfaces in a separate file ptrace.c,
-which is used by all systems which have ptrace. ptrace.c would deal
-with variations between systems the same way any system-independent
-file would (hooks, #if defined, etc.).
-
-About debugging gdb with itself...
-
-You probably want to do a "make TAGS" after you configure your
-distribution; this will put the machine dependent routines for your
-local machine where they will be accessed first by a M-period .
-
-Also, make sure that you've compiled gdb with your local cc or taken
-appropriate precautions regarding ansification of include files. See
-the Makefile for more information.
-
-The "info" command, when executed without a subcommand in a gdb being
-debugged by gdb, will pop you back up to the top level gdb. See
-.gdbinit for more details.
-
diff --git a/gnu/usr.bin/gdb/XGdbinit.samp b/gnu/usr.bin/gdb/XGdbinit.samp
deleted file mode 100644
index a99f106..0000000
--- a/gnu/usr.bin/gdb/XGdbinit.samp
+++ /dev/null
@@ -1,15 +0,0 @@
-button "show" push-to-file %S
-button "back" pop-file
-button "break in" break %S
-button "break at" break %l
-button delete delete %b%e
-button backtrace
-button up
-button down
-button print print %E
-button print* print *(%E)
-button next
-button step
-button "do upto" until %l%e
-button finish
-button continue cont%e
diff --git a/gnu/usr.bin/gdb/Xgdb.ad b/gnu/usr.bin/gdb/Xgdb.ad
deleted file mode 100644
index 5f9fe99..0000000
--- a/gnu/usr.bin/gdb/Xgdb.ad
+++ /dev/null
@@ -1,8 +0,0 @@
-Xgdb*geometry: 580x874-0+28
-Xgdb*src*scrollVertical: whenneeded
-Xgdb*src*scrollHorizontal: whenneeded
-Xgdb*src*wrap: never
-Xgdb*src*editType: read
-Xgdb*frame.buttons.allowResize: true
-Xgdb*frame.buttons.skipAdjust: true
-Xgdb*frame*showGrip: false
diff --git a/gnu/usr.bin/gdb/blockframe.c b/gnu/usr.bin/gdb/blockframe.c
deleted file mode 100644
index 236d1cd..0000000
--- a/gnu/usr.bin/gdb/blockframe.c
+++ /dev/null
@@ -1,622 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)blockframe.c 6.4 (Berkeley) 5/11/91";
-#endif /* not lint */
-
-/* Get info from stack frames;
- convert between frames, blocks, functions and pc values.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-
-#include <obstack.h>
-
-#if defined(NEWVM) && defined(KERNELDEBUG)
-#include <sys/param.h> /* XXX for FRAME_CHAIN_VALID */
-#endif
-
-/* Start and end of object file containing the entry point.
- STARTUP_FILE_END is the first address of the next file.
- This file is assumed to be a startup file
- and frames with pc's inside it
- are treated as nonexistent.
-
- Setting these variables is necessary so that backtraces do not fly off
- the bottom of the stack. */
-CORE_ADDR startup_file_start;
-CORE_ADDR startup_file_end;
-
-/* Is ADDR outside the startup file? */
-int
-outside_startup_file (addr)
- CORE_ADDR addr;
-{
- return !(addr >= startup_file_start && addr < startup_file_end);
-}
-
-/* Address of innermost stack frame (contents of FP register) */
-
-static FRAME current_frame;
-
-struct block *block_for_pc ();
-CORE_ADDR get_pc_function_start ();
-
-/*
- * Cache for frame addresses already read by gdb. Valid only while
- * inferior is stopped. Control variables for the frame cache should
- * be local to this module.
- */
-struct obstack frame_cache_obstack;
-
-/* Return the innermost (currently executing) stack frame. */
-
-FRAME
-get_current_frame ()
-{
- /* We assume its address is kept in a general register;
- param.h says which register. */
-
- return current_frame;
-}
-
-void
-set_current_frame (frame)
- FRAME frame;
-{
- current_frame = frame;
-}
-
-FRAME
-create_new_frame (addr, pc)
- FRAME_ADDR addr;
- CORE_ADDR pc;
-{
- struct frame_info *fci; /* Same type as FRAME */
-
- fci = (struct frame_info *)
- obstack_alloc (&frame_cache_obstack,
- sizeof (struct frame_info));
-
- /* Arbitrary frame */
- fci->next = (struct frame_info *) 0;
- fci->prev = (struct frame_info *) 0;
- fci->frame = addr;
- fci->next_frame = 0; /* Since arbitrary */
- fci->pc = pc;
-
-#ifdef INIT_EXTRA_FRAME_INFO
- INIT_EXTRA_FRAME_INFO (fci);
-#endif
-
- return fci;
-}
-
-/* Return the frame that called FRAME.
- If FRAME is the original frame (it has no caller), return 0. */
-
-FRAME
-get_prev_frame (frame)
- FRAME frame;
-{
- /* We're allowed to know that FRAME and "struct frame_info *" are
- the same */
- return get_prev_frame_info (frame);
-}
-
-/* Return the frame that FRAME calls (0 if FRAME is the innermost
- frame). */
-
-FRAME
-get_next_frame (frame)
- FRAME frame;
-{
- /* We're allowed to know that FRAME and "struct frame_info *" are
- the same */
- return frame->next;
-}
-
-/*
- * Flush the entire frame cache.
- */
-void
-flush_cached_frames ()
-{
- /* Since we can't really be sure what the first object allocated was */
- obstack_free (&frame_cache_obstack, 0);
- obstack_init (&frame_cache_obstack);
-
- current_frame = (struct frame_info *) 0; /* Invalidate cache */
-}
-
-/* Return a structure containing various interesting information
- about a specified stack frame. */
-/* How do I justify including this function? Well, the FRAME
- identifier format has gone through several changes recently, and
- it's not completely inconceivable that it could happen again. If
- it does, have this routine around will help */
-
-struct frame_info *
-get_frame_info (frame)
- FRAME frame;
-{
- return frame;
-}
-
-/* If a machine allows frameless functions, it should define a macro
- FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) in param.h. FI is the struct
- frame_info for the frame, and FRAMELESS should be set to nonzero
- if it represents a frameless function invocation. */
-
-/* Many machines which allow frameless functions can detect them using
- this macro. Such machines should define FRAMELESS_FUNCTION_INVOCATION
- to just call this macro. */
-#define FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) \
-{ \
- CORE_ADDR func_start, after_prologue; \
- func_start = (get_pc_function_start ((FI)->pc) + \
- FUNCTION_START_OFFSET); \
- if (func_start) \
- { \
- after_prologue = func_start; \
- SKIP_PROLOGUE (after_prologue); \
- (FRAMELESS) = (after_prologue == func_start); \
- } \
- else \
- /* If we can't find the start of the function, we don't really */ \
- /* know whether the function is frameless, but we should be */ \
- /* able to get a reasonable (i.e. best we can do under the */ \
- /* circumstances) backtrace by saying that it isn't. */ \
- (FRAMELESS) = 0; \
-}
-
-/* Return a structure containing various interesting information
- about the frame that called NEXT_FRAME. Returns NULL
- if there is no such frame. */
-
-struct frame_info *
-get_prev_frame_info (next_frame)
- FRAME next_frame;
-{
- FRAME_ADDR address;
- struct frame_info *prev;
- int fromleaf = 0;
-
- /* If the requested entry is in the cache, return it.
- Otherwise, figure out what the address should be for the entry
- we're about to add to the cache. */
-
- if (!next_frame)
- {
- if (!current_frame)
- {
- if (!have_inferior_p () && !have_core_file_p ())
- fatal ("get_prev_frame_info: Called before cache primed. \"Shouldn't happen.\"");
- else
- error ("No inferior or core file.");
- }
-
- return current_frame;
- }
-
- /* If we have the prev one, return it */
- if (next_frame->prev)
- return next_frame->prev;
-
- /* On some machines it is possible to call a function without
- setting up a stack frame for it. On these machines, we
- define this macro to take two args; a frameinfo pointer
- identifying a frame and a variable to set or clear if it is
- or isn't leafless. */
-#ifdef FRAMELESS_FUNCTION_INVOCATION
- /* Still don't want to worry about this except on the innermost
- frame. This macro will set FROMLEAF if NEXT_FRAME is a
- frameless function invocation. */
- if (!(next_frame->next))
- {
- FRAMELESS_FUNCTION_INVOCATION (next_frame, fromleaf);
- if (fromleaf)
- address = next_frame->frame;
- }
-#endif
-
- if (!fromleaf)
- {
- /* Two macros defined in param.h specify the machine-dependent
- actions to be performed here.
- First, get the frame's chain-pointer.
- If that is zero, the frame is the outermost frame or a leaf
- called by the outermost frame. This means that if start
- calls main without a frame, we'll return 0 (which is fine
- anyway).
-
- Nope; there's a problem. This also returns when the current
- routine is a leaf of main. This is unacceptable. We move
- this to after the ffi test; I'd rather have backtraces from
- start go curfluy than have an abort called from main not show
- main. */
- address = FRAME_CHAIN (next_frame);
- if (!FRAME_CHAIN_VALID (address, next_frame))
- return 0;
- /* If this frame is a leaf, this will be superceeded by the
- code below. */
- address = FRAME_CHAIN_COMBINE (address, next_frame);
- }
- if (address == 0)
- return 0;
-
- prev = (struct frame_info *)
- obstack_alloc (&frame_cache_obstack,
- sizeof (struct frame_info));
-
- if (next_frame)
- next_frame->prev = prev;
- prev->next = next_frame;
- prev->prev = (struct frame_info *) 0;
- prev->frame = address;
- prev->next_frame = prev->next ? prev->next->frame : 0;
-
-#ifdef INIT_EXTRA_FRAME_INFO
- INIT_EXTRA_FRAME_INFO(prev);
-#endif
-
- /* This entry is in the frame queue now, which is good since
- FRAME_SAVED_PC may use that queue to figure out it's value
- (see m-sparc.h). We want the pc saved in the inferior frame. */
- prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (next_frame) :
- next_frame ? FRAME_SAVED_PC (next_frame) : read_pc ());
-
- return prev;
-}
-
-CORE_ADDR
-get_frame_pc (frame)
- FRAME frame;
-{
- struct frame_info *fi;
- fi = get_frame_info (frame);
- return fi->pc;
-}
-
-/* Find the addresses in which registers are saved in FRAME. */
-
-void
-get_frame_saved_regs (frame_info_addr, saved_regs_addr)
- struct frame_info *frame_info_addr;
- struct frame_saved_regs *saved_regs_addr;
-{
- FRAME_FIND_SAVED_REGS (frame_info_addr, *saved_regs_addr);
-}
-
-/* Return the innermost lexical block in execution
- in a specified stack frame. The frame address is assumed valid. */
-
-struct block *
-get_frame_block (frame)
- FRAME frame;
-{
- struct frame_info *fi;
- CORE_ADDR pc;
-
- fi = get_frame_info (frame);
-
- pc = fi->pc;
- if (fi->next_frame != 0)
- /* We are not in the innermost frame. We need to subtract one to
- get the correct block, in case the call instruction was the
- last instruction of the block. If there are any machines on
- which the saved pc does not point to after the call insn, we
- probably want to make fi->pc point after the call insn anyway. */
- --pc;
- return block_for_pc (pc);
-}
-
-struct block *
-get_current_block ()
-{
- return block_for_pc (read_pc ());
-}
-
-CORE_ADDR
-get_pc_function_start (pc)
- CORE_ADDR pc;
-{
- register struct block *bl = block_for_pc (pc);
- register struct symbol *symbol;
- if (bl == 0 || (symbol = block_function (bl)) == 0)
- {
- register int misc_index = find_pc_misc_function (pc);
- if (misc_index >= 0)
- return misc_function_vector[misc_index].address;
- return 0;
- }
- bl = SYMBOL_BLOCK_VALUE (symbol);
- return BLOCK_START (bl);
-}
-
-/* Return the symbol for the function executing in frame FRAME. */
-
-struct symbol *
-get_frame_function (frame)
- FRAME frame;
-{
- register struct block *bl = get_frame_block (frame);
- if (bl == 0)
- return 0;
- return block_function (bl);
-}
-
-/* Return the innermost lexical block containing the specified pc value,
- or 0 if there is none. */
-
-extern struct symtab *psymtab_to_symtab ();
-
-struct block *
-block_for_pc (pc)
- register CORE_ADDR pc;
-{
- register struct block *b;
- register int bot, top, half;
- register struct symtab *s;
- register struct partial_symtab *ps;
- struct blockvector *bl;
-
- /* First search all symtabs for one whose file contains our pc */
-
- for (s = symtab_list; s; s = s->next)
- {
- bl = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bl, 0);
- if (BLOCK_START (b) <= pc
- && BLOCK_END (b) > pc)
- break;
- }
-
- if (s == 0)
- for (ps = partial_symtab_list; ps; ps = ps->next)
- {
- if (ps->textlow <= pc
- && ps->texthigh > pc)
- {
- if (ps->readin)
- fatal ("Internal error: pc found in readin psymtab and not in any symtab.");
- s = psymtab_to_symtab (ps);
- bl = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bl, 0);
- break;
- }
- }
-
- if (s == 0)
- return 0;
-
- /* Then search that symtab for the smallest block that wins. */
- /* Use binary search to find the last block that starts before PC. */
-
- bot = 0;
- top = BLOCKVECTOR_NBLOCKS (bl);
-
- while (top - bot > 1)
- {
- half = (top - bot + 1) >> 1;
- b = BLOCKVECTOR_BLOCK (bl, bot + half);
- if (BLOCK_START (b) <= pc)
- bot += half;
- else
- top = bot + half;
- }
-
- /* Now search backward for a block that ends after PC. */
-
- while (bot >= 0)
- {
- b = BLOCKVECTOR_BLOCK (bl, bot);
- if (BLOCK_END (b) > pc)
- return b;
- bot--;
- }
-
- return 0;
-}
-
-/* Return the function containing pc value PC.
- Returns 0 if function is not known. */
-
-struct symbol *
-find_pc_function (pc)
- CORE_ADDR pc;
-{
- register struct block *b = block_for_pc (pc);
- if (b == 0)
- return 0;
- return block_function (b);
-}
-
-/* Finds the "function" (text symbol) that is smaller than PC
- but greatest of all of the potential text symbols. Sets
- *NAME and/or *ADDRESS conditionally if that pointer is non-zero.
- Returns 0 if it couldn't find anything, 1 if it did. On a zero
- return, *NAME and *ADDRESS are always set to zero. On a 1 return,
- *NAME and *ADDRESS contain real information. */
-
-int
-find_pc_partial_function (pc, name, address)
- CORE_ADDR pc;
- char **name;
- CORE_ADDR *address;
-{
- struct partial_symtab *pst = find_pc_psymtab (pc);
- struct symbol *f;
- int miscfunc;
- struct partial_symbol *psb;
-
- if (pst)
- {
- if (pst->readin)
- {
- /* The information we want has already been read in.
- We can go to the already readin symbols and we'll get
- the best possible answer. */
- f = find_pc_function (pc);
- if (!f)
- {
- return_error:
- /* No availible symbol. */
- if (name != 0)
- *name = 0;
- if (address != 0)
- *address = 0;
- return 0;
- }
-
- if (name)
- *name = SYMBOL_NAME (f);
- if (address)
- *address = BLOCK_START (SYMBOL_BLOCK_VALUE (f));
- return 1;
- }
-
- /* Get the information from a combination of the pst
- (static symbols), and the misc function vector (extern
- symbols). */
- miscfunc = find_pc_misc_function (pc);
- psb = find_pc_psymbol (pst, pc);
-
- if (!psb && miscfunc == -1)
- {
- goto return_error;
- }
- if (!psb
- || (miscfunc != -1
- && (SYMBOL_VALUE(psb)
- < misc_function_vector[miscfunc].address)))
- {
- if (address)
- *address = misc_function_vector[miscfunc].address;
- if (name)
- *name = misc_function_vector[miscfunc].name;
- return 1;
- }
- else
- {
- if (address)
- *address = SYMBOL_VALUE (psb);
- if (name)
- *name = SYMBOL_NAME (psb);
- return 1;
- }
- }
- else
- /* Must be in the misc function stuff. */
- {
- miscfunc = find_pc_misc_function (pc);
- if (miscfunc == -1)
- goto return_error;
- if (address)
- *address = misc_function_vector[miscfunc].address;
- if (name)
- *name = misc_function_vector[miscfunc].name;
- return 1;
- }
-}
-
-/* Find the misc function whose address is the largest
- while being less than PC. Return its index in misc_function_vector.
- Returns -1 if PC is not in suitable range. */
-
-int
-find_pc_misc_function (pc)
- register CORE_ADDR pc;
-{
- register int lo = 0;
- register int hi = misc_function_count-1;
- register int new;
- register int distance;
-
- /* Note that the last thing in the vector is always _etext. */
- /* Actually, "end", now that non-functions
- go on the misc_function_vector. */
-
- /* Above statement is not *always* true - fix for case where there are */
- /* no misc functions at all (ie no symbol table has been read). */
- if (hi < 0) return -1; /* no misc functions recorded */
-
- /* trivial reject range test */
- if (pc < misc_function_vector[0].address ||
- pc > misc_function_vector[hi].address)
- return -1;
-
- /* Note that the following search will not return hi if
- pc == misc_function_vector[hi].address. If "end" points to the
- first unused location, this is correct and the above test
- simply needs to be changed to
- "pc >= misc_function_vector[hi].address". */
- do {
- new = (lo + hi) >> 1;
- distance = misc_function_vector[new].address - pc;
- if (distance == 0)
- return new; /* an exact match */
- else if (distance > 0)
- hi = new;
- else
- lo = new;
- } while (hi-lo != 1);
-
- /* if here, we had no exact match, so return the lower choice */
- return lo;
-}
-
-/* Return the innermost stack frame executing inside of the specified block,
- or zero if there is no such frame. */
-
-FRAME
-block_innermost_frame (block)
- struct block *block;
-{
- struct frame_info *fi;
- register FRAME frame;
- register CORE_ADDR start = BLOCK_START (block);
- register CORE_ADDR end = BLOCK_END (block);
-
- frame = 0;
- while (1)
- {
- frame = get_prev_frame (frame);
- if (frame == 0)
- return 0;
- fi = get_frame_info (frame);
- if (fi->pc >= start && fi->pc < end)
- return frame;
- }
-}
-
-void
-_initialize_blockframe ()
-{
- obstack_init (&frame_cache_obstack);
-}
diff --git a/gnu/usr.bin/gdb/breakpoint.c b/gnu/usr.bin/gdb/breakpoint.c
deleted file mode 100644
index b515ed3..0000000
--- a/gnu/usr.bin/gdb/breakpoint.c
+++ /dev/null
@@ -1,1383 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)breakpoint.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Everything about breakpoints, for GDB.
- 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-
-/* This is the sequence of bytes we insert for a breakpoint. */
-
-static char break_insn[] = BREAKPOINT;
-
-/* States of enablement of breakpoint.
- `temporary' means disable when hit.
- `delete' means delete when hit. */
-
-enum enable { disabled, enabled, temporary, delete};
-
-/* Not that the ->silent field is not currently used by any commands
- (though the code is in there if it was to be and set_raw_breakpoint
- does set it to 0). I implemented it because I thought it would be
- useful for a hack I had to put in; I'm going to leave it in because
- I can see how there might be times when it would indeed be useful */
-
-struct breakpoint
-{
- struct breakpoint *next;
- /* Number assigned to distinguish breakpoints. */
- int number;
- /* Address to break at. */
- CORE_ADDR address;
- /* Line number of this address. Redundant. */
- int line_number;
- /* Symtab of file of this address. Redundant. */
- struct symtab *symtab;
- /* Zero means disabled; remember the info but don't break here. */
- enum enable enable;
- /* Non-zero means a silent breakpoint (don't print frame info
- if we stop here). */
- unsigned char silent;
- /* Number of stops at this breakpoint that should
- be continued automatically before really stopping. */
- int ignore_count;
- /* "Real" contents of byte where breakpoint has been inserted.
- Valid only when breakpoints are in the program. */
- char shadow_contents[sizeof break_insn];
- /* Nonzero if this breakpoint is now inserted. */
- char inserted;
- /* Nonzero if this is not the first breakpoint in the list
- for the given address. */
- char duplicate;
- /* Chain of command lines to execute when this breakpoint is hit. */
- struct command_line *commands;
- /* Stack depth (address of frame). If nonzero, break only if fp
- equals this. */
- FRAME_ADDR frame;
- /* Conditional. Break only if this expression's value is nonzero. */
- struct expression *cond;
-};
-
-#define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
-
-/* Chain of all breakpoints defined. */
-
-struct breakpoint *breakpoint_chain;
-
-/* Number of last breakpoint made. */
-
-static int breakpoint_count;
-
-/* Default address, symtab and line to put a breakpoint at
- for "break" command with no arg.
- if default_breakpoint_valid is zero, the other three are
- not valid, and "break" with no arg is an error.
-
- This set by print_stack_frame, which calls set_default_breakpoint. */
-
-int default_breakpoint_valid;
-CORE_ADDR default_breakpoint_address;
-struct symtab *default_breakpoint_symtab;
-int default_breakpoint_line;
-
-/* Remaining commands (not yet executed)
- of last breakpoint hit. */
-
-struct command_line *breakpoint_commands;
-
-static void delete_breakpoint ();
-void clear_momentary_breakpoints ();
-void breakpoint_auto_delete ();
-
-/* Flag indicating extra verbosity for xgdb. */
-extern int xgdb_verbose;
-
-/* condition N EXP -- set break condition of breakpoint N to EXP. */
-
-static void
-condition_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- register struct breakpoint *b;
- register char *p;
- register int bnum;
- register struct expression *expr;
-
- if (arg == 0)
- error_no_arg ("breakpoint number");
-
- p = arg;
- while (*p >= '0' && *p <= '9') p++;
- if (p == arg)
- /* There is no number here. (e.g. "cond a == b"). */
- error_no_arg ("breakpoint number");
- bnum = atoi (arg);
-
- ALL_BREAKPOINTS (b)
- if (b->number == bnum)
- {
- if (b->cond)
- {
- free (b->cond);
- b->cond = 0; /* parse_c_1 can leave this unchanged. */
- }
- if (*p == 0)
- {
- b->cond = 0;
- if (from_tty)
- printf ("Breakpoint %d now unconditional.\n", bnum);
- }
- else
- {
- if (*p != ' ' && *p != '\t')
- error ("Arguments must be an integer (breakpoint number) and an expression.");
-
- /* Find start of expression */
- while (*p == ' ' || *p == '\t') p++;
-
- arg = p;
- b->cond = (struct expression *) parse_c_1 (&arg, block_for_pc (b->address), 0);
- if (*arg)
- error ("Junk at end of expression");
- }
- return;
- }
-
- error ("No breakpoint number %d.", bnum);
-}
-
-static void
-commands_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- register struct breakpoint *b;
- register char *p, *p1;
- register int bnum;
- struct command_line *l;
-
- /* If we allowed this, we would have problems with when to
- free the storage, if we change the commands currently
- being read from. */
-
- if (breakpoint_commands)
- error ("Can't use the \"commands\" command among a breakpoint's commands.");
-
- /* Allow commands by itself to refer to the last breakpoint. */
- if (arg == 0)
- bnum = breakpoint_count;
- else
- {
- p = arg;
- if (! (*p >= '0' && *p <= '9'))
- error ("Argument must be integer (a breakpoint number).");
-
- while (*p >= '0' && *p <= '9') p++;
- if (*p)
- error ("Unexpected extra arguments following breakpoint number.");
-
- bnum = atoi (arg);
- }
-
- ALL_BREAKPOINTS (b)
- if (b->number == bnum)
- {
- if (from_tty && input_from_terminal_p ())
- {
- printf ("Type commands for when breakpoint %d is hit, one per line.\n\
-End with a line saying just \"end\".\n", bnum);
- fflush (stdout);
- }
- l = read_command_lines (from_tty);
- free_command_lines (b->commands);
- b->commands = l;
- return;
- }
- error ("No breakpoint number %d.", bnum);
-}
-
-/* Called from command loop to execute the commands
- associated with the breakpoint we just stopped at. */
-
-void
-do_breakpoint_commands ()
-{
- struct command_line *cmd;
-
- while (cmd = breakpoint_commands)
- {
- breakpoint_commands = 0;
- execute_command_lines(cmd);
- /* If command was "cont", breakpoint_commands is now 0,
- of if we stopped at yet another breakpoint which has commands,
- it is now the commands for the new breakpoint. */
- }
- clear_momentary_breakpoints ();
-}
-
-/* Used when the program is proceeded, to eliminate any remaining
- commands attached to the previous breakpoint we stopped at. */
-
-void
-clear_breakpoint_commands ()
-{
- breakpoint_commands = 0;
- breakpoint_auto_delete (0);
-}
-
-/* Functions to get and set the current list of pending
- breakpoint commands. These are used by run_stack_dummy
- to preserve the commands around a function call. */
-
-struct command_line *
-get_breakpoint_commands ()
-{
- return breakpoint_commands;
-}
-
-void
-set_breakpoint_commands (cmds)
- struct command_line *cmds;
-{
- breakpoint_commands = cmds;
-}
-
-/* insert_breakpoints is used when starting or continuing the program.
- remove_breakpoints is used when the program stops.
- Both return zero if successful,
- or an `errno' value if could not write the inferior. */
-
-int
-insert_breakpoints ()
-{
- register struct breakpoint *b;
- int val;
-
-#ifdef BREAKPOINT_DEBUG
- printf ("Inserting breakpoints.\n");
-#endif /* BREAKPOINT_DEBUG */
-
- ALL_BREAKPOINTS (b)
- if (b->enable != disabled && ! b->inserted && ! b->duplicate)
- {
- read_memory (b->address, b->shadow_contents, sizeof break_insn);
- val = write_memory (b->address, break_insn, sizeof break_insn);
- if (val)
- return val;
-#ifdef BREAKPOINT_DEBUG
- printf ("Inserted breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
- b->address, b->shadow_contents[0], b->shadow_contents[1]);
-#endif /* BREAKPOINT_DEBUG */
- b->inserted = 1;
- }
- return 0;
-}
-
-int
-remove_breakpoints ()
-{
- register struct breakpoint *b;
- int val;
-
-#ifdef BREAKPOINT_DEBUG
- printf ("Removing breakpoints.\n");
-#endif /* BREAKPOINT_DEBUG */
-
- ALL_BREAKPOINTS (b)
- if (b->inserted)
- {
- val = write_memory (b->address, b->shadow_contents, sizeof break_insn);
- if (val)
- return val;
- b->inserted = 0;
-#ifdef BREAKPOINT_DEBUG
- printf ("Removed breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
- b->address, b->shadow_contents[0], b->shadow_contents[1]);
-#endif /* BREAKPOINT_DEBUG */
- }
-
- return 0;
-}
-
-/* Clear the "inserted" flag in all breakpoints.
- This is done when the inferior is loaded. */
-
-void
-mark_breakpoints_out ()
-{
- register struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- b->inserted = 0;
-}
-
-/* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
- When continuing from a location with a breakpoint,
- we actually single step once before calling insert_breakpoints. */
-
-int
-breakpoint_here_p (pc)
- CORE_ADDR pc;
-{
- register struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- if (b->enable != disabled && b->address == pc)
- return 1;
-
- return 0;
-}
-
-/* Evaluate the expression EXP and return 1 if value is zero.
- This is used inside a catch_errors to evaluate the breakpoint condition. */
-
-int
-breakpoint_cond_eval (exp)
- struct expression *exp;
-{
- return value_zerop (evaluate_expression (exp));
-}
-
-/* Return 0 if PC is not the address just after a breakpoint,
- or -1 if breakpoint says do not stop now,
- or -2 if breakpoint says it has deleted itself and don't stop,
- or -3 if hit a breakpoint number -3 (delete when program stops),
- or else the number of the breakpoint,
- with 0x1000000 added (or subtracted, for a negative return value) for
- a silent breakpoint. */
-
-int
-breakpoint_stop_status (pc, frame_address)
- CORE_ADDR pc;
- FRAME_ADDR frame_address;
-{
- register struct breakpoint *b;
- register int cont = 0;
-
- /* Get the address where the breakpoint would have been. */
- pc -= DECR_PC_AFTER_BREAK;
-
- ALL_BREAKPOINTS (b)
- if (b->enable != disabled && b->address == pc)
- {
- if (b->frame && b->frame != frame_address)
- cont = -1;
- else
- {
- int value_zero;
- if (b->cond)
- {
- /* Need to select the frame, with all that implies
- so that the conditions will have the right context. */
- select_frame (get_current_frame (), 0);
- value_zero
- = catch_errors (breakpoint_cond_eval, b->cond,
- "Error occurred in testing breakpoint condition.");
- free_all_values ();
- }
- if (b->cond && value_zero)
- {
- cont = -1;
- }
- else if (b->ignore_count > 0)
- {
- b->ignore_count--;
- cont = -1;
- }
- else
- {
- if (b->enable == temporary)
- b->enable = disabled;
- breakpoint_commands = b->commands;
- if (b->silent
- || (breakpoint_commands
- && !strcmp ("silent", breakpoint_commands->line)))
- {
- if (breakpoint_commands)
- breakpoint_commands = breakpoint_commands->next;
- return (b->number > 0 ?
- 0x1000000 + b->number :
- b->number - 0x1000000);
- }
- return b->number;
- }
- }
- }
-
- return cont;
-}
-
-static void
-breakpoint_1 (bnum)
- int bnum;
-{
- register struct breakpoint *b;
- register struct command_line *l;
- register struct symbol *sym;
- CORE_ADDR last_addr = (CORE_ADDR)-1;
-
- ALL_BREAKPOINTS (b)
- if (bnum == -1 || bnum == b->number)
- {
- printf_filtered ("#%-3d %c 0x%08x", b->number,
- "nyod"[(int) b->enable],
- b->address);
- last_addr = b->address;
- if (b->symtab)
- {
- sym = find_pc_function (b->address);
- if (sym)
- {
- fputs_filtered (" in ", stdout);
- fputs_demangled (SYMBOL_NAME (sym), stdout, 1);
- fputs_filtered (" (", stdout);
- }
- fputs_filtered (b->symtab->filename, stdout);
- printf_filtered (" line %d", b->line_number);
- if (sym) fputs_filtered(")", stdout);
- }
- else
- print_address_symbolic (b->address, stdout);
-
- printf_filtered ("\n");
-
- if (b->ignore_count)
- printf_filtered ("\tignore next %d hits\n", b->ignore_count);
- if (b->frame)
- printf_filtered ("\tstop only in stack frame at 0x%x\n", b->frame);
- if (b->cond)
- {
- printf_filtered ("\tbreak only if ");
- print_expression (b->cond, stdout);
- printf_filtered ("\n");
- }
- if (l = b->commands)
- while (l)
- {
- printf_filtered ("\t%s\n", l->line);
- l = l->next;
- }
- }
-
- /* Compare against (CORE_ADDR)-1 in case some compiler decides
- that a comparison of an unsigned with -1 is always false. */
- if (last_addr != (CORE_ADDR)-1)
- set_next_address (last_addr);
-}
-
-static void
-breakpoints_info (bnum_exp)
- char *bnum_exp;
-{
- int bnum = -1;
-
- if (bnum_exp)
- bnum = parse_and_eval_address (bnum_exp);
- else if (breakpoint_chain == 0)
- printf_filtered ("No breakpoints.\n");
- else
- printf_filtered ("Breakpoints:\n\
-Num Enb Address Where\n");
-
- breakpoint_1 (bnum);
-}
-
-/* Print a message describing any breakpoints set at PC. */
-
-static void
-describe_other_breakpoints (pc)
- register CORE_ADDR pc;
-{
- register int others = 0;
- register struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- if (b->address == pc)
- others++;
- if (others > 0)
- {
- printf ("Note: breakpoint%s ", (others > 1) ? "s" : "");
- ALL_BREAKPOINTS (b)
- if (b->address == pc)
- {
- others--;
- printf ("%d%s%s ",
- b->number,
- (b->enable == disabled) ? " (disabled)" : "",
- (others > 1) ? "," : ((others == 1) ? " and" : ""));
- }
- printf ("also set at pc 0x%x.\n", pc);
- }
-}
-
-/* Set the default place to put a breakpoint
- for the `break' command with no arguments. */
-
-void
-set_default_breakpoint (valid, addr, symtab, line)
- int valid;
- CORE_ADDR addr;
- struct symtab *symtab;
- int line;
-{
- default_breakpoint_valid = valid;
- default_breakpoint_address = addr;
- default_breakpoint_symtab = symtab;
- default_breakpoint_line = line;
-}
-
-/* Rescan breakpoints at address ADDRESS,
- marking the first one as "first" and any others as "duplicates".
- This is so that the bpt instruction is only inserted once. */
-
-static void
-check_duplicates (address)
- CORE_ADDR address;
-{
- register struct breakpoint *b;
- register int count = 0;
-
- ALL_BREAKPOINTS (b)
- if (b->enable != disabled && b->address == address)
- {
- count++;
- b->duplicate = count > 1;
- }
-}
-
-/* Low level routine to set a breakpoint.
- Takes as args the three things that every breakpoint must have.
- Returns the breakpoint object so caller can set other things.
- Does not set the breakpoint number!
- Does not print anything. */
-
-static struct breakpoint *
-set_raw_breakpoint (sal)
- struct symtab_and_line sal;
-{
- register struct breakpoint *b, *b1;
-
- b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
- bzero (b, sizeof *b);
- b->address = sal.pc;
- b->symtab = sal.symtab;
- b->line_number = sal.line;
- b->enable = enabled;
- b->next = 0;
- b->silent = 0;
-
- /* Add this breakpoint to the end of the chain
- so that a list of breakpoints will come out in order
- of increasing numbers. */
-
- b1 = breakpoint_chain;
- if (b1 == 0)
- breakpoint_chain = b;
- else
- {
- while (b1->next)
- b1 = b1->next;
- b1->next = b;
- }
-
- check_duplicates (sal.pc);
-
- return b;
-}
-
-/* Set a breakpoint that will evaporate an end of command
- at address specified by SAL.
- Restrict it to frame FRAME if FRAME is nonzero. */
-
-void
-set_momentary_breakpoint (sal, frame)
- struct symtab_and_line sal;
- FRAME frame;
-{
- register struct breakpoint *b;
- b = set_raw_breakpoint (sal);
- b->number = -3;
- b->enable = delete;
- b->frame = (frame ? FRAME_FP (frame) : 0);
-}
-
-void
-clear_momentary_breakpoints ()
-{
- register struct breakpoint *b;
- ALL_BREAKPOINTS (b)
- if (b->number == -3)
- {
- delete_breakpoint (b);
- break;
- }
-}
-
-/* Set a breakpoint from a symtab and line.
- If TEMPFLAG is nonzero, it is a temporary breakpoint.
- Print the same confirmation messages that the breakpoint command prints. */
-
-void
-set_breakpoint (s, line, tempflag)
- struct symtab *s;
- int line;
- int tempflag;
-{
- register struct breakpoint *b;
- struct symtab_and_line sal;
-
- sal.symtab = s;
- sal.line = line;
- sal.pc = find_line_pc (sal.symtab, sal.line);
- if (sal.pc == 0)
- error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename);
- else
- {
- describe_other_breakpoints (sal.pc);
-
- b = set_raw_breakpoint (sal);
- b->number = ++breakpoint_count;
- b->cond = 0;
- if (tempflag)
- b->enable = temporary;
-
- printf ("Breakpoint %d at 0x%x", b->number, b->address);
- if (b->symtab)
- printf (": file %s, line %d.", b->symtab->filename, b->line_number);
- printf ("\n");
- }
-}
-
-/* Set a breakpoint according to ARG (function, linenum or *address)
- and make it temporary if TEMPFLAG is nonzero. */
-
-static void
-break_command_1 (arg, tempflag, from_tty)
- char *arg;
- int tempflag, from_tty;
-{
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
- register struct expression *cond = 0;
- register struct breakpoint *b;
- char *save_arg;
- int i;
- CORE_ADDR pc;
-
- sals.sals = NULL;
- sals.nelts = 0;
-
- sal.line = sal.pc = sal.end = 0;
- sal.symtab = 0;
-
- /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
-
- if (!arg || (arg[0] == 'i' && arg[1] == 'f'
- && (arg[2] == ' ' || arg[2] == '\t')))
- {
- if (default_breakpoint_valid)
- {
- sals.sals = (struct symtab_and_line *)
- malloc (sizeof (struct symtab_and_line));
- sal.pc = default_breakpoint_address;
- sal.line = default_breakpoint_line;
- sal.symtab = default_breakpoint_symtab;
- sals.sals[0] = sal;
- sals.nelts = 1;
- }
- else
- error ("No default breakpoint address now.");
- }
- else
- /* Force almost all breakpoints to be in terms of the
- current_source_symtab (which is decode_line_1's default). This
- should produce the results we want almost all of the time while
- leaving default_breakpoint_* alone. */
- if (default_breakpoint_valid
- && (!current_source_symtab
- || (arg && (*arg == '+' || *arg == '-'))))
- sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
- default_breakpoint_line);
- else
- sals = decode_line_1 (&arg, 1, 0, 0);
-
- if (! sals.nelts)
- return;
-
- save_arg = arg;
- for (i = 0; i < sals.nelts; i++)
- {
- sal = sals.sals[i];
- if (sal.pc == 0 && sal.symtab != 0)
- {
- pc = find_line_pc (sal.symtab, sal.line);
- if (pc == 0)
- error ("No line %d in file \"%s\".",
- sal.line, sal.symtab->filename);
- }
- else
- pc = sal.pc;
-
- while (arg && *arg)
- {
- if (arg[0] == 'i' && arg[1] == 'f'
- && (arg[2] == ' ' || arg[2] == '\t'))
- cond = (struct expression *) parse_c_1 ((arg += 2, &arg),
- block_for_pc (pc), 0);
- else
- error ("Junk at end of arguments.");
- }
- arg = save_arg;
- sals.sals[i].pc = pc;
- }
-
- for (i = 0; i < sals.nelts; i++)
- {
- sal = sals.sals[i];
-
- if (from_tty)
- describe_other_breakpoints (sal.pc);
-
- b = set_raw_breakpoint (sal);
- b->number = ++breakpoint_count;
- b->cond = cond;
- if (tempflag)
- b->enable = temporary;
-
- printf ("Breakpoint %d at 0x%x", b->number, b->address);
- if (b->symtab)
- printf (": file %s, line %d.", b->symtab->filename, b->line_number);
- printf ("\n");
- }
-
- if (sals.nelts > 1)
- {
- printf ("Multiple breakpoints were set.\n");
- printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
- }
- free (sals.sals);
-}
-
-static void
-break_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- break_command_1 (arg, 0, from_tty);
-}
-
-static void
-tbreak_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- break_command_1 (arg, 1, from_tty);
-}
-
-/*
- * Helper routine for the until_command routine in infcmd.c. Here
- * because it uses the mechanisms of breakpoints.
- */
-void
-until_break_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
- FRAME prev_frame = get_prev_frame (selected_frame);
-
- clear_proceed_status ();
-
- /* Set a breakpoint where the user wants it and at return from
- this function */
-
- if (default_breakpoint_valid)
- sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
- default_breakpoint_line);
- else
- sals = decode_line_1 (&arg, 1, 0, 0);
-
- if (sals.nelts != 1)
- error ("Couldn't get information on specified line.");
-
- sal = sals.sals[0];
- free (sals.sals); /* malloc'd, so freed */
-
- if (*arg)
- error ("Junk at end of arguments.");
-
- if (sal.pc == 0 && sal.symtab != 0)
- sal.pc = find_line_pc (sal.symtab, sal.line);
-
- if (sal.pc == 0)
- error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
-
- set_momentary_breakpoint (sal, selected_frame);
-
- /* Keep within the current frame */
-
- if (prev_frame)
- {
- struct frame_info *fi;
-
- fi = get_frame_info (prev_frame);
- sal = find_pc_line (fi->pc, 0);
- sal.pc = fi->pc;
- set_momentary_breakpoint (sal, prev_frame);
- }
-
- proceed (-1, -1, 0);
-}
-
-static void
-clear_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- register struct breakpoint *b, *b1;
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
- register struct breakpoint *found;
- int i;
-
- if (arg)
- {
- sals = decode_line_spec (arg, 1);
- }
- else
- {
- sals.sals = (struct symtab_and_line *) malloc (sizeof (struct symtab_and_line));
- sal.line = default_breakpoint_line;
- sal.symtab = default_breakpoint_symtab;
- sal.pc = 0;
- if (sal.symtab == 0)
- error ("No source file specified.");
-
- sals.sals[0] = sal;
- sals.nelts = 1;
- }
-
- for (i = 0; i < sals.nelts; i++)
- {
- /* If exact pc given, clear bpts at that pc.
- But if sal.pc is zero, clear all bpts on specified line. */
- sal = sals.sals[i];
- found = (struct breakpoint *) 0;
- while (breakpoint_chain
- && (sal.pc ? breakpoint_chain->address == sal.pc
- : (breakpoint_chain->symtab == sal.symtab
- && breakpoint_chain->line_number == sal.line)))
- {
- b1 = breakpoint_chain;
- breakpoint_chain = b1->next;
- b1->next = found;
- found = b1;
- }
-
- ALL_BREAKPOINTS (b)
- while (b->next
- && (sal.pc ? b->next->address == sal.pc
- : (b->next->symtab == sal.symtab
- && b->next->line_number == sal.line)))
- {
- b1 = b->next;
- b->next = b1->next;
- b1->next = found;
- found = b1;
- }
-
- if (found == 0)
- error ("No breakpoint at %s.", arg);
-
- if (found->next) from_tty = 1; /* Always report if deleted more than one */
- if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
- while (found)
- {
- if (from_tty) printf ("%d ", found->number);
- b1 = found->next;
- delete_breakpoint (found);
- found = b1;
- }
- if (from_tty) putchar ('\n');
- }
- free (sals.sals);
-}
-
-/* Delete breakpoint number BNUM if it is a `delete' breakpoint.
- This is called after breakpoint BNUM has been hit.
- Also delete any breakpoint numbered -3 unless there are breakpoint
- commands to be executed. */
-
-void
-breakpoint_auto_delete (bnum)
- int bnum;
-{
- register struct breakpoint *b;
- if (bnum != 0)
- ALL_BREAKPOINTS (b)
- if (b->number == bnum)
- {
- if (b->enable == delete)
- delete_breakpoint (b);
- break;
- }
- if (breakpoint_commands == 0)
- clear_momentary_breakpoints ();
-}
-
-static void
-delete_breakpoint (bpt)
- struct breakpoint *bpt;
-{
- register struct breakpoint *b;
-
- if (bpt->inserted)
- write_memory (bpt->address, bpt->shadow_contents, sizeof break_insn);
-
- if (breakpoint_chain == bpt)
- breakpoint_chain = bpt->next;
-
- ALL_BREAKPOINTS (b)
- if (b->next == bpt)
- {
- b->next = bpt->next;
- break;
- }
-
- check_duplicates (bpt->address);
-
- free_command_lines (bpt->commands);
- if (bpt->cond)
- free (bpt->cond);
-
- if (xgdb_verbose && bpt->number >=0)
- printf ("breakpoint #%d deleted\n", bpt->number);
-
- free (bpt);
-}
-
-static void map_breakpoint_numbers ();
-
-static void
-delete_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- register struct breakpoint *b, *b1;
-
- if (arg == 0)
- {
- /* Ask user only if there are some breakpoints to delete. */
- if (!from_tty
- || breakpoint_chain && query ("Delete all breakpoints? "))
- {
- /* No arg; clear all breakpoints. */
- while (breakpoint_chain)
- delete_breakpoint (breakpoint_chain);
- }
- }
- else
- map_breakpoint_numbers (arg, delete_breakpoint);
-}
-
-/* Delete all breakpoints.
- Done when new symtabs are loaded, since the break condition expressions
- may become invalid, and the breakpoints are probably wrong anyway. */
-
-void
-clear_breakpoints ()
-{
- delete_command (0, 0);
-}
-
-/* Set ignore-count of breakpoint number BPTNUM to COUNT.
- If from_tty is nonzero, it prints a message to that effect,
- which ends with a period (no newline). */
-
-void
-set_ignore_count (bptnum, count, from_tty)
- int bptnum, count, from_tty;
-{
- register struct breakpoint *b;
-
- if (count < 0)
- count = 0;
-
- ALL_BREAKPOINTS (b)
- if (b->number == bptnum)
- {
- b->ignore_count = count;
- if (!from_tty)
- return;
- else if (count == 0)
- printf ("Will stop next time breakpoint %d is reached.", bptnum);
- else if (count == 1)
- printf ("Will ignore next crossing of breakpoint %d.", bptnum);
- else
- printf ("Will ignore next %d crossings of breakpoint %d.",
- count, bptnum);
- return;
- }
-
- error ("No breakpoint number %d.", bptnum);
-}
-
-/* Clear the ignore counts of all breakpoints. */
-void
-breakpoint_clear_ignore_counts ()
-{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- b->ignore_count = 0;
-}
-
-/* Command to set ignore-count of breakpoint N to COUNT. */
-
-static void
-ignore_command (args, from_tty)
- char *args;
- int from_tty;
-{
- register char *p = args;
- register int num;
-
- if (p == 0)
- error_no_arg ("a breakpoint number");
-
- while (*p >= '0' && *p <= '9') p++;
- if (*p && *p != ' ' && *p != '\t')
- error ("First argument must be a breakpoint number.");
-
- num = atoi (args);
-
- if (*p == 0)
- error ("Second argument (specified ignore-count) is missing.");
-
- set_ignore_count (num, parse_and_eval_address (p), from_tty);
- printf ("\n");
-}
-
-/* Call FUNCTION on each of the breakpoints
- whose numbers are given in ARGS. */
-
-static void
-map_breakpoint_numbers (args, function)
- char *args;
- void (*function) ();
-{
- register char *p = args;
- register char *p1;
- register int num;
- register struct breakpoint *b;
-
- if (p == 0)
- error_no_arg ("one or more breakpoint numbers");
-
- while (*p)
- {
- p1 = p;
- while (*p1 >= '0' && *p1 <= '9') p1++;
- if (*p1 && *p1 != ' ' && *p1 != '\t')
- error ("Arguments must be breakpoint numbers.");
-
- num = atoi (p);
-
- ALL_BREAKPOINTS (b)
- if (b->number == num)
- {
- function (b);
- goto win;
- }
- printf ("No breakpoint number %d.\n", num);
- win:
- p = p1;
- while (*p == ' ' || *p == '\t') p++;
- }
-}
-
-static void
-enable_breakpoint (bpt)
- struct breakpoint *bpt;
-{
- bpt->enable = enabled;
-
- if (xgdb_verbose && bpt->number >= 0)
- printf ("breakpoint #%d enabled\n", bpt->number);
-
- check_duplicates (bpt->address);
-}
-
-static void
-enable_command (args)
- char *args;
-{
- struct breakpoint *bpt;
- if (args == 0)
- ALL_BREAKPOINTS (bpt)
- enable_breakpoint (bpt);
- else
- map_breakpoint_numbers (args, enable_breakpoint);
-}
-
-static void
-disable_breakpoint (bpt)
- struct breakpoint *bpt;
-{
- bpt->enable = disabled;
-
- if (xgdb_verbose && bpt->number >= 0)
- printf ("breakpoint #%d disabled\n", bpt->number);
-
- check_duplicates (bpt->address);
-}
-
-static void
-disable_command (args)
- char *args;
-{
- register struct breakpoint *bpt;
- if (args == 0)
- ALL_BREAKPOINTS (bpt)
- disable_breakpoint (bpt);
- else
- map_breakpoint_numbers (args, disable_breakpoint);
-}
-
-static void
-enable_once_breakpoint (bpt)
- struct breakpoint *bpt;
-{
- bpt->enable = temporary;
-
- check_duplicates (bpt->address);
-}
-
-static void
-enable_once_command (args)
- char *args;
-{
- map_breakpoint_numbers (args, enable_once_breakpoint);
-}
-
-static void
-enable_delete_breakpoint (bpt)
- struct breakpoint *bpt;
-{
- bpt->enable = delete;
-
- check_duplicates (bpt->address);
-}
-
-static void
-enable_delete_command (args)
- char *args;
-{
- map_breakpoint_numbers (args, enable_delete_breakpoint);
-}
-
-/*
- * Use default_breakpoint_'s, or nothing if they aren't valid.
- */
-struct symtabs_and_lines
-decode_line_spec_1 (string, funfirstline)
- char *string;
- int funfirstline;
-{
- struct symtabs_and_lines sals;
- if (string == 0)
- error ("Empty line specification.");
- if (default_breakpoint_valid)
- sals = decode_line_1 (&string, funfirstline,
- default_breakpoint_symtab, default_breakpoint_line);
- else
- sals = decode_line_1 (&string, funfirstline, 0, 0);
- if (*string)
- error ("Junk at end of line specification: %s", string);
- return sals;
-}
-
-
-/* Chain containing all defined enable commands. */
-
-extern struct cmd_list_element
- *enablelist, *disablelist,
- *deletelist, *enablebreaklist;
-
-extern struct cmd_list_element *cmdlist;
-
-void
-_initialize_breakpoint ()
-{
- breakpoint_chain = 0;
- breakpoint_count = 0;
-
- add_com ("ignore", class_breakpoint, ignore_command,
- "Set ignore-count of breakpoint number N to COUNT.");
-
- add_com ("commands", class_breakpoint, commands_command,
- "Set commands to be executed when a breakpoint is hit.\n\
-Give breakpoint number as argument after \"commands\".\n\
-With no argument, the targeted breakpoint is the last one set.\n\
-The commands themselves follow starting on the next line.\n\
-Type a line containing \"end\" to indicate the end of them.\n\
-Give \"silent\" as the first line to make the breakpoint silent;\n\
-then no output is printed when it is hit, except what the commands print.");
-
- add_com ("condition", class_breakpoint, condition_command,
- "Specify breakpoint number N to break only if COND is true.\n\
-N is an integer; COND is a C expression to be evaluated whenever\n\
-breakpoint N is reached. Actually break only when COND is nonzero.");
-
- add_com ("tbreak", class_breakpoint, tbreak_command,
- "Set a temporary breakpoint. Args like \"break\" command.\n\
-Like \"break\" except the breakpoint is only enabled temporarily,\n\
-so it will be disabled when hit. Equivalent to \"break\" followed\n\
-by using \"enable once\" on the breakpoint number.");
-
- add_prefix_cmd ("enable", class_breakpoint, enable_command,
- "Enable some breakpoints or auto-display expressions.\n\
-Give breakpoint numbers (separated by spaces) as arguments.\n\
-With no subcommand, breakpoints are enabled until you command otherwise.\n\
-This is used to cancel the effect of the \"disable\" command.\n\
-With a subcommand you can enable temporarily.\n\
-\n\
-The \"display\" subcommand applies to auto-displays instead of breakpoints.",
- &enablelist, "enable ", 1, &cmdlist);
-
- add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
- "Enable some breakpoints or auto-display expressions.\n\
-Give breakpoint numbers (separated by spaces) as arguments.\n\
-With no subcommand, breakpoints are enabled until you command otherwise.\n\
-This is used to cancel the effect of the \"disable\" command.\n\
-May be abbreviates to simply \"enable\".\n\
-With a subcommand you can enable temporarily.",
- &enablebreaklist, "enable breakpoints ", 1, &enablelist);
-
- add_cmd ("once", no_class, enable_once_command,
- "Enable breakpoints for one hit. Give breakpoint numbers.\n\
-If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
-See the \"tbreak\" command which sets a breakpoint and enables it once.",
- &enablebreaklist);
-
- add_cmd ("delete", no_class, enable_delete_command,
- "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
-If a breakpoint is hit while enabled in this fashion, it is deleted.",
- &enablebreaklist);
-
- add_cmd ("delete", no_class, enable_delete_command,
- "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
-If a breakpoint is hit while enabled in this fashion, it is deleted.",
- &enablelist);
-
- add_cmd ("once", no_class, enable_once_command,
- "Enable breakpoints for one hit. Give breakpoint numbers.\n\
-If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
-See the \"tbreak\" command which sets a breakpoint and enables it once.",
- &enablelist);
-
- add_prefix_cmd ("disable", class_breakpoint, disable_command,
- "Disable some breakpoints or auto-display expressions.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To disable all breakpoints, give no argument.\n\
-A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
-\n\
-The \"display\" subcommand applies to auto-displays instead of breakpoints.",
- &disablelist, "disable ", 1, &cmdlist);
- add_com_alias ("dis", "disable", class_breakpoint, 1);
- add_com_alias ("disa", "disable", class_breakpoint, 1);
-
- add_abbrev_cmd ("breakpoints", class_breakpoint, disable_command,
- "Disable some breakpoints or auto-display expressions.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To disable all breakpoints, give no argument.\n\
-A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
-This command may be abbreviated \"disable\".",
- &disablelist);
-
- add_prefix_cmd ("delete", class_breakpoint, delete_command,
- "Delete some breakpoints or auto-display expressions.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
-\n\
-Also a prefix command for deletion of other GDB objects.\n\
-The \"unset\" command is also an alias for \"delete\".",
- &deletelist, "delete ", 1, &cmdlist);
- add_com_alias ("d", "delete", class_breakpoint, 1);
- add_com_alias ("unset", "delete", class_alias, 1);
-
- add_cmd ("breakpoints", class_alias, delete_command,
- "Delete some breakpoints or auto-display expressions.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
-This command may be abbreviated \"delete\".",
- &deletelist);
-
- add_com ("clear", class_breakpoint, clear_command,
- "Clear breakpoint at specified line or function.\n\
-Argument may be line number, function name, or \"*\" and an address.\n\
-If line number is specified, all breakpoints in that line are cleared.\n\
-If function is specified, breakpoints at beginning of function are cleared.\n\
-If an address is specified, breakpoints at that address are cleared.\n\n\
-With no argument, clears all breakpoints in the line that the selected frame\n\
-is executing in.\n\
-\n\
-See also the \"delete\" command which clears breakpoints by number.");
-
- add_com ("break", class_breakpoint, break_command,
- "Set breakpoint at specified line or function.\n\
-Argument may be line number, function name, or \"*\" and an address.\n\
-If line number is specified, break at start of code for that line.\n\
-If function is specified, break at start of code for that function.\n\
-If an address is specified, break at that exact address.\n\
-With no arg, uses current execution address of selected stack frame.\n\
-This is useful for breaking on return to a stack frame.\n\
-\n\
-Multiple breakpoints at one place are permitted, and useful if conditional.\n\
-\n\
-Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
- add_com_alias ("b", "break", class_run, 1);
- add_com_alias ("br", "break", class_run, 1);
- add_com_alias ("bre", "break", class_run, 1);
- add_com_alias ("brea", "break", class_run, 1);
-
- add_info ("breakpoints", breakpoints_info,
- "Status of all breakpoints, or breakpoint number NUMBER.\n\
-Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
-\"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
-Then come the address and the file/line number.\n\n\
-Convenience variable \"$_\" and default examine address for \"x\"\n\
-are set to the address of the last breakpoint listed.");
-}
-
diff --git a/gnu/usr.bin/gdb/command.c b/gnu/usr.bin/gdb/command.c
deleted file mode 100644
index 79daea4..0000000
--- a/gnu/usr.bin/gdb/command.c
+++ /dev/null
@@ -1,856 +0,0 @@
-/* Library for reading command lines and decoding commands.
- Copyright (C) 1986, 1989 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. */
-
-#include "command.h"
-#include "defs.h"
-#include <stdio.h>
-#include <ctype.h>
-
-extern char *xmalloc ();
-
-/* Add element named NAME to command list *LIST.
- FUN should be the function to execute the command;
- it will get a character string as argument, with leading
- and trailing blanks already eliminated.
-
- DOC is a documentation string for the command.
- Its first line should be a complete sentence.
- It should start with ? for a command that is an abbreviation
- or with * for a command that most users don't need to know about. */
-
-struct cmd_list_element *
-add_cmd (name, class, fun, doc, list)
- char *name;
- int class;
- void (*fun) ();
- char *doc;
- struct cmd_list_element **list;
-{
- register struct cmd_list_element *c
- = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
-
- delete_cmd (name, list);
- c->next = *list;
- c->name = savestring (name, strlen (name));
- c->class = class;
- c->function = fun;
- c->doc = doc;
- c->prefixlist = 0;
- c->allow_unknown = 0;
- c->abbrev_flag = 0;
- c->aux = 0;
- *list = c;
- return c;
-}
-
-/* Same as above, except that the abbrev_flag is set. */
-
-struct cmd_list_element *
-add_abbrev_cmd (name, class, fun, doc, list)
- char *name;
- int class;
- void (*fun) ();
- char *doc;
- struct cmd_list_element **list;
-{
- register struct cmd_list_element *c
- = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
-
- delete_cmd (name, list);
- c->next = *list;
- c->name = savestring (name, strlen (name));
- c->class = class;
- c->function = fun;
- c->doc = doc;
- c->prefixlist = 0;
- c->allow_unknown = 0;
- c->abbrev_flag = 1;
- c->aux = 0;
- *list = c;
- return c;
-}
-
-struct cmd_list_element *
-add_alias_cmd (name, oldname, class, abbrev_flag, list)
- char *name;
- char *oldname;
- int class;
- int abbrev_flag;
- struct cmd_list_element **list;
-{
- /* Must do this since lookup_cmd tries to side-effect its first arg */
- char *copied_name;
- register struct cmd_list_element *old;
- register struct cmd_list_element *c;
- copied_name = (char *) alloca (strlen (oldname) + 1);
- strcpy (copied_name, oldname);
- old = lookup_cmd (&copied_name, *list, 0, 1, 1);
-
- if (old == 0)
- {
- delete_cmd (name, list);
- return 0;
- }
-
- c = add_cmd (name, class, old->function, old->doc, list);
- c->prefixlist = old->prefixlist;
- c->prefixname = old->prefixname;
- c->allow_unknown = old->allow_unknown;
- c->abbrev_flag = abbrev_flag;
- c->aux = old->aux;
- return c;
-}
-
-/* Like add_cmd but adds an element for a command prefix:
- a name that should be followed by a subcommand to be looked up
- in another command list. PREFIXLIST should be the address
- of the variable containing that list. */
-
-struct cmd_list_element *
-add_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
- allow_unknown, list)
- char *name;
- int class;
- void (*fun) ();
- char *doc;
- struct cmd_list_element **prefixlist;
- char *prefixname;
- int allow_unknown;
- struct cmd_list_element **list;
-{
- register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
- c->prefixlist = prefixlist;
- c->prefixname = prefixname;
- c->allow_unknown = allow_unknown;
- return c;
-}
-
-/* Like add_prefix_cmd butsets the abbrev_flag on the new command. */
-
-struct cmd_list_element *
-add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
- allow_unknown, list)
- char *name;
- int class;
- void (*fun) ();
- char *doc;
- struct cmd_list_element **prefixlist;
- char *prefixname;
- int allow_unknown;
- struct cmd_list_element **list;
-{
- register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
- c->prefixlist = prefixlist;
- c->prefixname = prefixname;
- c->allow_unknown = allow_unknown;
- c->abbrev_flag = 1;
- return c;
-}
-
-/* Remove the command named NAME from the command list. */
-
-void
-delete_cmd (name, list)
- char *name;
- struct cmd_list_element **list;
-{
- register struct cmd_list_element *c;
-
- while (*list && !strcmp ((*list)->name, name))
- {
- *list = (*list)->next;
- }
-
- if (*list)
- for (c = *list; c->next;)
- {
- if (!strcmp (c->next->name, name))
- c->next = c->next->next;
- else
- c = c->next;
- }
-}
-
-void help_cmd (), help_list (), help_cmd_list ();
-
-/* This command really has to deal with two things:
- * 1) I want documentation on *this string* (usually called by
- * "help commandname").
- * 2) I want documentation on *this list* (usually called by
- * giving a command that requires subcommands. Also called by saying
- * just "help".)
- *
- * I am going to split this into two seperate comamnds, help_cmd and
- * help_list.
- */
-
-void
-help_cmd (command, stream)
- char *command;
- FILE *stream;
-{
- struct cmd_list_element *c;
- extern struct cmd_list_element *cmdlist;
-
- if (!command)
- {
- help_list (cmdlist, "", -2, stream);
- return;
- }
-
- c = lookup_cmd (&command, cmdlist, "", 0, 0);
-
- if (c == 0)
- return;
-
- /* There are three cases here.
- If c->prefixlist is nonzer, we have a prefix command.
- Print its documentation, then list its subcommands.
-
- If c->function is nonzero, we really have a command.
- Print its documentation and return.
-
- If c->function is zero, we have a class name.
- Print its documentation (as if it were a command)
- and then set class to he number of this class
- so that the commands in the class will be listed. */
-
- fputs_filtered (c->doc, stream);
- fputs_filtered ("\n", stream);
-
- if (c->prefixlist == 0 && c->function != 0)
- return;
- fprintf_filtered (stream, "\n");
-
- /* If this is a prefix command, print it's subcommands */
- if (c->prefixlist)
- help_list (*c->prefixlist, c->prefixname, -1, stream);
-
- /* If this is a class name, print all of the commands in the class */
- if (c->function == 0)
- help_list (cmdlist, "", c->class, stream);
-}
-
-/*
- * Get a specific kind of help on a command list.
- *
- * LIST is the list.
- * CMDTYPE is the prefix to use in the title string.
- * CLASS is the class with which to list the nodes of this list (see
- * documentation for help_cmd_list below), As usual, -1 for
- * everything, -2 for just classes, and non-negative for only things
- * in a specific class.
- * and STREAM is the output stream on which to print things.
- * If you call this routine with a class >= 0, it recurses.
- */
-void
-help_list (list, cmdtype, class, stream)
- struct cmd_list_element *list;
- char *cmdtype;
- int class;
- FILE *stream;
-{
- int len;
- char *cmdtype1, *cmdtype2;
-
- /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub" */
- len = strlen (cmdtype);
- cmdtype1 = (char *) alloca (len + 1);
- cmdtype1[0] = 0;
- cmdtype2 = (char *) alloca (len + 4);
- cmdtype2[0] = 0;
- if (len)
- {
- cmdtype1[0] = ' ';
- strncpy (cmdtype1 + 1, cmdtype, len - 1);
- cmdtype1[len] = 0;
- strncpy (cmdtype2, cmdtype, len - 1);
- strcpy (cmdtype2 + len - 1, " sub");
- }
-
- if (class == -2)
- fprintf_filtered (stream, "List of classes of %scommands:\n\n", cmdtype2);
- else
- fprintf_filtered (stream, "List of %scommands:\n\n", cmdtype2);
-
- help_cmd_list (list, class, cmdtype, (class >= 0), stream);
-
- if (class == -2)
- fprintf_filtered (stream, "\n\
-Type \"help%s\" followed by a class name for a list of commands in that class.",
- cmdtype1);
-
- fprintf_filtered (stream, "\n\
-Type \"help%s\" followed by %scommand name for full documentation.\n\
-Command name abbreviations are allowed if unambiguous.\n",
- cmdtype1, cmdtype2);
-}
-
-
-/*
- * Implement a help command on command list LIST.
- * RECURSE should be non-zero if this should be done recursively on
- * all sublists of LIST.
- * PREFIX is the prefix to print before each command name.
- * STREAM is the stream upon which the output should be written.
- * CLASS should be:
- * A non-negative class number to list only commands in that
- * class.
- * -1 to list all commands in list.
- * -2 to list all classes in list.
- *
- * Note that RECURSE will be active on *all* sublists, not just the
- * ones seclected by the criteria above (ie. the selection mechanism
- * is at the low level, not the high-level).
- */
-void
-help_cmd_list (list, class, prefix, recurse, stream)
- struct cmd_list_element *list;
- int class;
- char *prefix;
- int recurse;
- FILE *stream;
-{
- register struct cmd_list_element *c;
- register char *p;
- static char *line_buffer = 0;
- static int line_size;
-
- if (!line_buffer)
- {
- line_size = 80;
- line_buffer = (char *) xmalloc (line_size);
- }
-
- for (c = list; c; c = c->next)
- {
- if (c->abbrev_flag == 0 &&
- (class == -1
- || (class == -2 && c->function == 0)
- || (class == c->class && c->function != 0)))
- {
- fprintf_filtered (stream, "%s%s -- ", prefix, c->name);
- /* Print just the first line */
- p = c->doc;
- while (*p && *p != '\n') p++;
- if (p - c->doc > line_size - 1)
- {
- line_size = p - c->doc + 1;
- free (line_buffer);
- line_buffer = (char *) xmalloc (line_size);
- }
- strncpy (line_buffer, c->doc, p - c->doc);
- line_buffer[p - c->doc] = '\0';
- fputs_filtered (line_buffer, stream);
- fputs_filtered ("\n", stream);
- }
- if (recurse
- && c->prefixlist != 0
- && c->abbrev_flag == 0)
- help_cmd_list (*c->prefixlist, class, c->prefixname, 1, stream);
- }
-}
-
-/* This routine takes a line of TEXT and a CLIST in which to
- start the lookup. When it returns it will have incremented the text
- pointer past the section of text it matched, set *RESULT_LIST to
- the list in which the last word was matched, and will return the
- cmd list element which the text matches. It will return 0 if no
- match at all was possible. It will return -1 if ambigous matches are
- possible; in this case *RESULT_LIST will be set to the list in which
- there are ambiguous choices (and text will be set to the ambiguous
- text string).
-
- It does no error reporting whatsoever; control will always return
- to the superior routine.
-
- In the case of an ambiguous return (-1), *RESULT_LIST will be set to
- point at the prefix_command (ie. the best match) *or* (special
- case) will be 0 if no prefix command was ever found. For example,
- in the case of "info a", "info" matches without ambiguity, but "a"
- could be "args" or "address", so *RESULT_LIST is set to
- the cmd_list_element for "info". So in this case
- result list should not be interpeted as a pointer to the beginning
- of a list; it simply points to a specific command.
-
- This routine does *not* modify the text pointed to by TEXT.
-
- If INGNORE_HELP_CLASSES is nonzero, ignore any command list
- elements which are actually help classes rather than commands (i.e.
- the function field of the struct cmd_list_element is 0). */
-
-struct cmd_list_element *
-lookup_cmd_1 (text, clist, result_list, ignore_help_classes)
- char **text;
- struct cmd_list_element *clist, **result_list;
- int ignore_help_classes;
-{
- char *p, *command;
- int len, tmp, nfound;
- struct cmd_list_element *found, *c;
-
- while (**text == ' ' || **text == '\t')
- (*text)++;
-
- /* Treating underscores as part of command words is important
- so that "set args_foo()" doesn't get interpreted as
- "set args _foo()". */
- for (p = *text;
- *p && (isalnum(*p) || *p == '-' || *p == '_');
- p++)
- ;
-
- /* If nothing but whitespace, return 0. */
- if (p == *text)
- return 0;
-
- len = p - *text;
-
- /* *text and p now bracket the first command word to lookup (and
- it's length is len). We copy this into a local temporary,
- converting to lower case as we go. */
-
- command = (char *) alloca (len + 1);
- for (tmp = 0; tmp < len; tmp++)
- {
- char x = (*text)[tmp];
- command[tmp] = (x >= 'A' && x <= 'Z') ? x - 'A' + 'a' : x;
- }
- command[len] = '\0';
-
- /* Look it up. */
- found = 0;
- nfound = 0;
- for (c = clist; c; c = c->next)
- if (!strncmp (command, c->name, len)
- && (!ignore_help_classes || c->function))
- {
- found = c;
- nfound++;
- if (c->name[len] == '\0')
- {
- nfound = 1;
- break;
- }
- }
-
- /* If nothing matches, we have a simple failure. */
- if (nfound == 0)
- return 0;
-
- if (nfound > 1)
- {
- *result_list = 0; /* Will be modified in calling routine
- if we know what the prefix command is.
- */
- return (struct cmd_list_element *) -1; /* Ambiguous. */
- }
-
- /* We've matched something on this list. Move text pointer forward. */
-
- *text = p;
- if (found->prefixlist)
- {
- c = lookup_cmd_1 (text, *found->prefixlist, result_list,
- ignore_help_classes);
- if (!c)
- {
- /* Didn't find anything; this is as far as we got. */
- *result_list = clist;
- return found;
- }
- else if (c == (struct cmd_list_element *) -1)
- {
- /* We've gotten this far properley, but the next step
- is ambiguous. We need to set the result list to the best
- we've found (if an inferior hasn't already set it). */
- if (!*result_list)
- /* This used to say *result_list = *found->prefixlist
- If that was correct, need to modify the documentation
- at the top of this function to clarify what is supposed
- to be going on. */
- *result_list = found;
- return c;
- }
- else
- {
- /* We matched! */
- return c;
- }
- }
- else
- {
- *result_list = clist;
- return found;
- }
-}
-
-/* Look up the contents of *LINE as a command in the command list LIST.
- LIST is a chain of struct cmd_list_element's.
- If it is found, return the struct cmd_list_element for that command
- and update *LINE to point after the command name, at the first argument.
- If not found, call error if ALLOW_UNKNOWN is zero
- otherwise (or if error returns) return zero.
- Call error if specified command is ambiguous,
- unless ALLOW_UNKNOWN is negative.
- CMDTYPE precedes the word "command" in the error message.
-
- If INGNORE_HELP_CLASSES is nonzero, ignore any command list
- elements which are actually help classes rather than commands (i.e.
- the function field of the struct cmd_list_element is 0). */
-
-struct cmd_list_element *
-lookup_cmd (line, list, cmdtype, allow_unknown, ignore_help_classes)
- char **line;
- struct cmd_list_element *list;
- char *cmdtype;
- int allow_unknown;
- int ignore_help_classes;
-{
- struct cmd_list_element *last_list = 0;
- struct cmd_list_element *c =
- lookup_cmd_1 (line, list, &last_list, ignore_help_classes);
- char *ptr = (*line) + strlen (*line) - 1;
-
- /* Clear off trailing whitespace. */
- while (ptr >= *line && (*ptr == ' ' || *ptr == '\t'))
- ptr--;
- *(ptr + 1) = '\0';
-
- if (!c)
- {
- if (!allow_unknown)
- {
- if (!*line)
- error ("Lack of needed %scommand", cmdtype);
- else
- {
- char *p = *line, *q;
-
- while (isalnum(*p) || *p == '-')
- p++;
-
- q = (char *) alloca (p - *line + 1);
- strncpy (q, *line, p - *line);
- q[p-*line] = '\0';
-
- error ("Undefined %scommand: \"%s\".", cmdtype, q);
- }
- }
- else
- return 0;
- }
- else if (c == (struct cmd_list_element *) -1)
- {
- /* Ambigous. Local values should be off prefixlist or called
- values. */
- int local_allow_unknown = (last_list ? last_list->allow_unknown :
- allow_unknown);
- char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
- struct cmd_list_element *local_list =
- (last_list ? *(last_list->prefixlist) : list);
-
- if (local_allow_unknown < 0)
- {
- if (last_list)
- return last_list; /* Found something. */
- else
- return 0; /* Found nothing. */
- }
- else
- {
- /* Report as error. */
- int amb_len;
- char ambbuf[100];
-
- for (amb_len = 0;
- ((*line)[amb_len] && (*line)[amb_len] != ' '
- && (*line)[amb_len] != '\t');
- amb_len++)
- ;
-
- ambbuf[0] = 0;
- for (c = local_list; c; c = c->next)
- if (!strncmp (*line, c->name, amb_len))
- {
- if (strlen (ambbuf) + strlen (c->name) + 6 < sizeof ambbuf)
- {
- if (strlen (ambbuf))
- strcat (ambbuf, ", ");
- strcat (ambbuf, c->name);
- }
- else
- {
- strcat (ambbuf, "..");
- break;
- }
- }
- error ("Ambiguous %scommand \"%s\": %s.", local_cmdtype,
- *line, ambbuf);
- }
- }
- else
- {
- /* We've got something. It may still not be what the caller
- wants (if this command *needs* a subcommand). */
- while (**line == ' ' || **line == '\t')
- (*line)++;
-
- if (c->prefixlist && **line && !c->allow_unknown)
- error ("Undefined %scommand: \"%s\".", c->prefixname, *line);
-
- /* Seems to be what he wants. Return it. */
- return c;
- }
-}
-
-#if 0
-/* Look up the contents of *LINE as a command in the command list LIST.
- LIST is a chain of struct cmd_list_element's.
- If it is found, return the struct cmd_list_element for that command
- and update *LINE to point after the command name, at the first argument.
- If not found, call error if ALLOW_UNKNOWN is zero
- otherwise (or if error returns) return zero.
- Call error if specified command is ambiguous,
- unless ALLOW_UNKNOWN is negative.
- CMDTYPE precedes the word "command" in the error message. */
-
-struct cmd_list_element *
-lookup_cmd (line, list, cmdtype, allow_unknown)
- char **line;
- struct cmd_list_element *list;
- char *cmdtype;
- int allow_unknown;
-{
- register char *p;
- register struct cmd_list_element *c, *found;
- int nfound;
- char ambbuf[100];
- char *processed_cmd;
- int i, cmd_len;
-
- /* Skip leading whitespace. */
-
- while (**line == ' ' || **line == '\t')
- (*line)++;
-
- /* Clear out trailing whitespace. */
-
- p = *line + strlen (*line);
- while (p != *line && (p[-1] == ' ' || p[-1] == '\t'))
- p--;
- *p = 0;
-
- /* Find end of command name. */
-
- p = *line;
- while (*p == '-'
- || (*p >= 'a' && *p <= 'z')
- || (*p >= 'A' && *p <= 'Z')
- || (*p >= '0' && *p <= '9'))
- p++;
-
- /* Look up the command name.
- If exact match, keep that.
- Otherwise, take command abbreviated, if unique. Note that (in my
- opinion) a null string does *not* indicate ambiguity; simply the
- end of the argument. */
-
- if (p == *line)
- {
- if (!allow_unknown)
- error ("Lack of needed %scommand", cmdtype);
- return 0;
- }
-
- /* Copy over to a local buffer, converting to lowercase on the way.
- This is in case the command being parsed is a subcommand which
- doesn't match anything, and that's ok. We want the original
- untouched for the routine of the original command. */
-
- processed_cmd = (char *) alloca (p - *line + 1);
- for (cmd_len = 0; cmd_len < p - *line; cmd_len++)
- {
- char x = (*line)[cmd_len];
- if (x >= 'A' && x <= 'Z')
- processed_cmd[cmd_len] = x - 'A' + 'a';
- else
- processed_cmd[cmd_len] = x;
- }
- processed_cmd[cmd_len] = '\0';
-
- /* Check all possibilities in the current command list. */
- found = 0;
- nfound = 0;
- for (c = list; c; c = c->next)
- {
- if (!strncmp (processed_cmd, c->name, cmd_len))
- {
- found = c;
- nfound++;
- if (c->name[cmd_len] == 0)
- {
- nfound = 1;
- break;
- }
- }
- }
-
- /* Report error for undefined command name. */
-
- if (nfound != 1)
- {
- if (nfound > 1 && allow_unknown >= 0)
- {
- ambbuf[0] = 0;
- for (c = list; c; c = c->next)
- if (!strncmp (processed_cmd, c->name, cmd_len))
- {
- if (strlen (ambbuf) + strlen (c->name) + 6 < sizeof ambbuf)
- {
- if (strlen (ambbuf))
- strcat (ambbuf, ", ");
- strcat (ambbuf, c->name);
- }
- else
- {
- strcat (ambbuf, "..");
- break;
- }
- }
- error ("Ambiguous %scommand \"%s\": %s.", cmdtype,
- processed_cmd, ambbuf);
- }
- else if (!allow_unknown)
- error ("Undefined %scommand: \"%s\".", cmdtype, processed_cmd);
- return 0;
- }
-
- /* Skip whitespace before the argument. */
-
- while (*p == ' ' || *p == '\t') p++;
- *line = p;
-
- if (found->prefixlist && *p)
- {
- c = lookup_cmd (line, *found->prefixlist, found->prefixname,
- found->allow_unknown);
- if (c)
- return c;
- }
-
- return found;
-}
-#endif
-
-/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
-
-/* Return a vector of char pointers which point to the different
- possible completions in LIST of TEXT. */
-
-char **
-complete_on_cmdlist (list, text)
- struct cmd_list_element *list;
- char *text;
-{
- struct cmd_list_element *ptr;
- char **matchlist;
- int sizeof_matchlist;
- int matches;
- int textlen = strlen (text);
-
- sizeof_matchlist = 10;
- matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
- matches = 0;
-
- for (ptr = list; ptr; ptr = ptr->next)
- if (!strncmp (ptr->name, text, textlen)
- && !ptr->abbrev_flag
- && (ptr->function
- || ptr->prefixlist))
- {
- if (matches == sizeof_matchlist)
- {
- sizeof_matchlist *= 2;
- matchlist = (char **) xrealloc (matchlist,
- (sizeof_matchlist
- * sizeof (char *)));
- }
-
- matchlist[matches] = (char *)
- xmalloc (strlen (ptr->name) + 1);
- strcpy (matchlist[matches++], ptr->name);
- }
-
- if (matches == 0)
- {
- free (matchlist);
- matchlist = 0;
- }
- else
- {
- matchlist = (char **) xrealloc (matchlist, ((matches + 1)
- * sizeof (char *)));
- matchlist[matches] = (char *) 0;
- }
-
- return matchlist;
-}
-
-static void
-shell_escape (arg, from_tty)
- char *arg;
- int from_tty;
-{
- int rc, status, pid;
- char *p, *user_shell;
- extern char *rindex ();
-
- if ((user_shell = (char *) getenv ("SHELL")) == NULL)
- user_shell = "/bin/sh";
-
- /* Get the name of the shell for arg0 */
- if ((p = rindex (user_shell, '/')) == NULL)
- p = user_shell;
- else
- p++; /* Get past '/' */
-
- if ((pid = fork()) == 0)
- {
- if (!arg)
- execl (user_shell, p, 0);
- else
- execl (user_shell, p, "-c", arg, 0);
-
- fprintf (stderr, "Exec of shell failed\n");
- exit (0);
- }
-
- if (pid != -1)
- while ((rc = wait (&status)) != pid && rc != -1)
- ;
- else
- error ("Fork failed");
-}
-
-void
-_initialize_command ()
-{
- add_com ("shell", class_support, shell_escape,
- "Execute the rest of the line as a shell command. \n\
-With no arguments, run an inferior shell.");
-}
diff --git a/gnu/usr.bin/gdb/command.h b/gnu/usr.bin/gdb/command.h
deleted file mode 100644
index fe28aef..0000000
--- a/gnu/usr.bin/gdb/command.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Header file for command-reading library command.c.
- Copyright (C) 1986, 1989 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. */
-
-/* This structure records one command'd definition. */
-
-struct cmd_list_element
- {
- /* Points to next command in this list. */
- struct cmd_list_element *next;
-
- /* Name of this command. */
- char *name;
-
- /* Command class; class values are chosen by application program. */
- int class;
-
- /* Function definition of this command.
- Zero for command class names and for help topics that
- are not really commands. */
- void (*function) ();
-
- /* Documentation of this command (or help topic).
- First line is brief documentation; remaining lines form, with it,
- the full documentation. First line should end with a period.
- Entire string should also end with a period, not a newline. */
- char *doc;
-
- /* Auxiliary information.
- It is up to the calling program to decide what this means. */
- char *aux;
-
- /* Nonzero identifies a prefix command. For them, the address
- of the variable containing the list of subcommands. */
- struct cmd_list_element **prefixlist;
-
- /* For prefix commands only:
- String containing prefix commands to get here: this one
- plus any others needed to get to it. Should end in a space.
- It is used before the word "command" in describing the
- commands reached through this prefix. */
- char *prefixname;
-
- /* For prefix commands only:
- nonzero means do not get an error if subcommand is not
- recognized; call the prefix's own function in that case. */
- char allow_unknown;
-
- /* Nonzero says this is an abbreviation, and should not
- be mentioned in lists of commands.
- This allows "br<tab>" to complete to "break", which it
- otherwise wouldn't. */
- char abbrev_flag;
- };
-
-/* Forward-declarations of the entry-points of command.c. */
-
-extern struct cmd_list_element *add_cmd ();
-extern struct cmd_list_element *add_alias_cmd ();
-extern struct cmd_list_element *add_prefix_cmd ();
-extern struct cmd_list_element *lookup_cmd (), *lookup_cmd_1 ();
-extern char **complete_on_cmdlist ();
-extern void delete_cmd ();
-extern void help_cmd ();
diff --git a/gnu/usr.bin/gdb/config/Makefile.i386 b/gnu/usr.bin/gdb/config/Makefile.i386
deleted file mode 100644
index cc52aa3..0000000
--- a/gnu/usr.bin/gdb/config/Makefile.i386
+++ /dev/null
@@ -1,6 +0,0 @@
-# @(#)Makefile.i386 6.2 (Berkeley) 3/21/91
-
-CONFIGSRCS= i386bsd-dep.c i386-pinsn.c
-
-param.h:
- ln -s $(.CURDIR)/config/m-i386bsd.h param.h
diff --git a/gnu/usr.bin/gdb/config/default-dep.c b/gnu/usr.bin/gdb/config/default-dep.c
deleted file mode 100644
index 13fe7b9..0000000
--- a/gnu/usr.bin/gdb/config/default-dep.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)default-dep.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Low level interface to ptrace, for GDB when running under Unix.
- Copyright (C) 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "frame.h"
-#include "inferior.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-/* #include <fcntl.h> Can we live without this? */
-
-#ifdef COFF_ENCAPSULATE
-#include "a.out.encap.h"
-#else
-#include <a.out.h>
-#endif
-#ifndef N_SET_MAGIC
-#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val))
-#endif
-
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include <sys/stat.h>
-
-extern int errno;
-
-/* This function simply calls ptrace with the given arguments.
- It exists so that all calls to ptrace are isolated in this
- machine-dependent file. */
-int
-call_ptrace (request, pid, arg3, arg4)
- int request, pid, arg3, arg4;
-{
- return ptrace (request, pid, arg3, arg4);
-}
-
-kill_inferior ()
-{
- if (remote_debugging)
- return;
- if (inferior_pid == 0)
- return;
- ptrace (8, inferior_pid, 0, 0);
- wait (0);
- inferior_died ();
-}
-
-/* This is used when GDB is exiting. It gives less chance of error.*/
-
-kill_inferior_fast ()
-{
- if (remote_debugging)
- return;
- if (inferior_pid == 0)
- return;
- ptrace (8, inferior_pid, 0, 0);
- wait (0);
-}
-
-/* Resume execution of the inferior process.
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal. */
-
-void
-resume (step, signal)
- int step;
- int signal;
-{
- errno = 0;
- if (remote_debugging)
- remote_resume (step, signal);
- else
- {
- ptrace (step ? 9 : 7, inferior_pid, 1, signal);
- if (errno)
- perror_with_name ("ptrace");
- }
-}
-
-void
-fetch_inferior_registers ()
-{
- register int regno;
- register unsigned int regaddr;
- char buf[MAX_REGISTER_RAW_SIZE];
- register int i;
-
- struct user u;
- unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
- offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- regaddr = register_addr (regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
- {
- *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0);
- regaddr += sizeof (int);
- }
- supply_register (regno, buf);
- }
-}
-
-/* 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). */
-
-store_inferior_registers (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[80];
-
- struct user u;
- unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
- offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR;
-
- if (regno >= 0)
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- ptrace (6, inferior_pid, regaddr, read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
- else for (regno = 0; regno < NUM_REGS; regno++)
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- ptrace (6, inferior_pid, regaddr, read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing all regs, number %d", regno);
- perror_with_name (buf);
- }
- }
-}
-
-/* Copy LEN bytes from inferior's memory starting at MEMADDR
- to debugger memory starting at MYADDR.
- On failure (cannot read from inferior, usually because address is out
- of bounds) returns the value of errno. */
-
-int
-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));
- extern int errno;
-
- /* Read all the longwords */
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
-#if 0
- /* This is now done by read_memory, because when this function did it,
- reading a byte or short int hardware port read whole longs, causing
- serious side effects
- such as bus errors and unexpected hardware operation. This would
- also be a problem with ptrace if the inferior process could read
- or write hardware registers, but that's not usually the case. */
- if (remote_debugging)
- buffer[i] = remote_fetch_word (addr);
- else
-#endif
- buffer[i] = ptrace (1, inferior_pid, addr, 0);
- if (errno)
- return errno;
- }
-
- /* Copy appropriate bytes out of the buffer. */
- bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
- return 0;
-}
-
-/* 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. */
-
- if (remote_debugging)
- return (remote_write_inferior_memory(memaddr, myaddr, len));
-
- buffer[0] = ptrace (1, inferior_pid, addr, 0);
-
- if (count > 1)
- buffer[count - 1] = ptrace (1, inferior_pid,
- addr + (count - 1) * sizeof (int), 0);
-
- /* Copy data to be written over corresponding part of buffer */
-
- bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- ptrace (4, inferior_pid, addr, buffer[i]);
- if (errno)
- return errno;
- }
-
- return 0;
-}
-
-/* Work with core dump and executable files, for GDB.
- This code would be in core.c if it weren't machine-dependent. */
-
-#ifndef N_TXTADDR
-#define N_TXTADDR(hdr) 0
-#endif /* no N_TXTADDR */
-
-#ifndef N_DATADDR
-#define N_DATADDR(hdr) hdr.a_text
-#endif /* no N_DATADDR */
-
-/* Make COFF and non-COFF names for things a little more compatible
- to reduce conditionals later. */
-
-#ifdef COFF_FORMAT
-#define a_magic magic
-#endif
-
-#ifndef COFF_FORMAT
-#ifndef AOUTHDR
-#define AOUTHDR struct exec
-#endif
-#endif
-
-extern char *sys_siglist[];
-
-
-/* Hook for `exec_file_command' command to call. */
-
-extern void (*exec_file_display_hook) ();
-
-/* File names of core file and executable file. */
-
-extern char *corefile;
-extern char *execfile;
-
-/* Descriptors on which core file and executable file are open.
- Note that the execchan is closed when an inferior is created
- and reopened if the inferior dies or is killed. */
-
-extern int corechan;
-extern int execchan;
-
-/* Last modification time of executable file.
- Also used in source.c to compare against mtime of a source file. */
-
-extern int exec_mtime;
-
-/* Virtual addresses of bounds of the two areas of memory in the core file. */
-
-extern CORE_ADDR data_start;
-extern CORE_ADDR data_end;
-extern CORE_ADDR stack_start;
-extern CORE_ADDR stack_end;
-
-/* Virtual addresses of bounds of two areas of memory in the exec file.
- Note that the data area in the exec file is used only when there is no core file. */
-
-extern CORE_ADDR text_start;
-extern CORE_ADDR text_end;
-
-extern CORE_ADDR exec_data_start;
-extern CORE_ADDR exec_data_end;
-
-/* Address in executable file of start of text area data. */
-
-extern int text_offset;
-
-/* Address in executable file of start of data area data. */
-
-extern int exec_data_offset;
-
-/* Address in core file of start of data area data. */
-
-extern int data_offset;
-
-/* Address in core file of start of stack area data. */
-
-extern int stack_offset;
-
-#ifdef COFF_FORMAT
-/* various coff data structures */
-
-extern FILHDR file_hdr;
-extern SCNHDR text_hdr;
-extern SCNHDR data_hdr;
-
-#endif /* not COFF_FORMAT */
-
-/* a.out header saved in core file. */
-
-extern AOUTHDR core_aouthdr;
-
-/* a.out header of exec file. */
-
-extern AOUTHDR exec_aouthdr;
-
-extern void validate_files ();
-
-core_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
- extern char registers[];
-
- /* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
- if (corefile)
- free (corefile);
- corefile = 0;
-
- if (corechan >= 0)
- close (corechan);
- corechan = -1;
-
- data_start = 0;
- data_end = 0;
- stack_start = STACK_END_ADDR;
- stack_end = STACK_END_ADDR;
-
- /* Now, if a new core file was specified, open it and digest it. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- if (have_inferior_p ())
- error ("To look at a core file, you must kill the inferior with \"kill\".");
- corechan = open (filename, O_RDONLY, 0);
- if (corechan < 0)
- perror_with_name (filename);
- /* 4.2-style (and perhaps also sysV-style) core dump file. */
- {
- struct user u;
-
- unsigned int reg_offset;
-
- val = myread (corechan, &u, sizeof u);
- if (val < 0)
- perror_with_name ("Not a core file: reading upage");
- if (val != sizeof u)
- error ("Not a core file: could only read %d bytes", val);
-
- /* We are depending on exec_file_command having been called
- previously to set exec_data_start. Since the executable
- and the core file share the same text segment, the address
- of the data segment will be the same in both. */
- data_start = exec_data_start;
-
- data_end = data_start + NBPG * u.u_dsize;
- stack_start = stack_end - NBPG * u.u_ssize;
- data_offset = NBPG * UPAGES;
- stack_offset = NBPG * (UPAGES + u.u_dsize);
-
- /* Some machines put an absolute address in here and some put
- the offset in the upage of the regs. */
- reg_offset = (int) u.u_ar0;
- if (reg_offset > NBPG * UPAGES)
- reg_offset -= KERNEL_U_ADDR;
-
- /* I don't know where to find this info.
- So, for now, mark it as not available. */
- N_SET_MAGIC (core_aouthdr, 0);
-
- /* Read the register values out of the core file and store
- them where `read_register' will find them. */
-
- {
- register int regno;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- val = lseek (corechan, register_addr (regno, reg_offset), 0);
- if (val < 0
- || (val = myread (corechan, buf, sizeof buf)) < 0)
- {
- char * buffer = (char *) alloca (strlen (reg_names[regno])
- + 30);
- strcpy (buffer, "Reading register ");
- strcat (buffer, reg_names[regno]);
-
- perror_with_name (buffer);
- }
-
- supply_register (regno, buf);
- }
- }
- }
- if (filename[0] == '/')
- corefile = savestring (filename, strlen (filename));
- else
- {
- corefile = concat (current_directory, "/", filename);
- }
-
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
- select_frame (get_current_frame (), 0);
- validate_files ();
- }
- else if (from_tty)
- printf ("No core file now.\n");
-}
-
-exec_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
-
- /* Eliminate all traces of old exec file.
- Mark text segment as empty. */
-
- if (execfile)
- free (execfile);
- execfile = 0;
- data_start = 0;
- data_end -= exec_data_start;
- text_start = 0;
- text_end = 0;
- exec_data_start = 0;
- exec_data_end = 0;
- if (execchan >= 0)
- close (execchan);
- execchan = -1;
-
- /* Now open and digest the file the user requested, if any. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
- &execfile);
- if (execchan < 0)
- perror_with_name (filename);
-
-#ifdef COFF_FORMAT
- {
- int aout_hdrsize;
- int num_sections;
-
- if (read_file_hdr (execchan, &file_hdr) < 0)
- error ("\"%s\": not in executable format.", execfile);
-
- aout_hdrsize = file_hdr.f_opthdr;
- num_sections = file_hdr.f_nscns;
-
- if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0)
- error ("\"%s\": can't read optional aouthdr", execfile);
-
- if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections,
- aout_hdrsize) < 0)
- error ("\"%s\": can't read text section header", execfile);
-
- if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections,
- aout_hdrsize) < 0)
- error ("\"%s\": can't read data section header", execfile);
-
- text_start = exec_aouthdr.text_start;
- text_end = text_start + exec_aouthdr.tsize;
- text_offset = text_hdr.s_scnptr;
- exec_data_start = exec_aouthdr.data_start;
- exec_data_end = exec_data_start + exec_aouthdr.dsize;
- exec_data_offset = data_hdr.s_scnptr;
- data_start = exec_data_start;
- data_end += exec_data_start;
- exec_mtime = file_hdr.f_timdat;
- }
-#else /* not COFF_FORMAT */
- {
- struct stat st_exec;
-
-#ifdef HEADER_SEEK_FD
- HEADER_SEEK_FD (execchan);
-#endif
-
- val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR));
-
- if (val < 0)
- perror_with_name (filename);
-
- text_start = N_TXTADDR (exec_aouthdr);
- exec_data_start = N_DATADDR (exec_aouthdr);
-
- text_offset = N_TXTOFF (exec_aouthdr);
- exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text;
-
- text_end = text_start + exec_aouthdr.a_text;
- exec_data_end = exec_data_start + exec_aouthdr.a_data;
- data_start = exec_data_start;
- data_end += exec_data_start;
-
- if (fstat (execchan, &st_exec) < 0)
- perror_with_name (filename);
- exec_mtime = st_exec.st_mtime;
- }
-#endif /* not COFF_FORMAT */
-
- validate_files ();
- }
- else if (from_tty)
- printf ("No exec file now.\n");
-
- /* Tell display code (if any) about the changed file name. */
- if (exec_file_display_hook)
- (*exec_file_display_hook) (filename);
-}
diff --git a/gnu/usr.bin/gdb/config/i386-dep.c b/gnu/usr.bin/gdb/config/i386-dep.c
deleted file mode 100644
index c4630d0..0000000
--- a/gnu/usr.bin/gdb/config/i386-dep.c
+++ /dev/null
@@ -1,1275 +0,0 @@
-/* Low level interface to ptrace, for GDB when running on the Intel 386.
- Copyright (C) 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "frame.h"
-#include "inferior.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/user.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#ifdef COFF_ENCAPSULATE
-#include "a.out.encap.h"
-#else
-#include <a.out.h>
-#endif
-
-#ifndef N_SET_MAGIC
-#ifdef COFF_FORMAT
-#define N_SET_MAGIC(exec, val) ((exec).magic = (val))
-#else
-#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val))
-#endif
-#endif
-
-#include <sys/file.h>
-#include <sys/stat.h>
-
-#include <sys/reg.h>
-
-extern int errno;
-
-/* This function simply calls ptrace with the given arguments.
- It exists so that all calls to ptrace are isolated in this
- machine-dependent file. */
-int
-call_ptrace (request, pid, arg3, arg4)
- int request, pid, arg3, arg4;
-{
- return ptrace (request, pid, arg3, arg4);
-}
-
-kill_inferior ()
-{
- if (remote_debugging)
- return;
- if (inferior_pid == 0)
- return;
- ptrace (8, inferior_pid, 0, 0);
- wait (0);
- inferior_died ();
-}
-
-/* This is used when GDB is exiting. It gives less chance of error.*/
-
-kill_inferior_fast ()
-{
- if (remote_debugging)
- return;
- if (inferior_pid == 0)
- return;
- ptrace (8, inferior_pid, 0, 0);
- wait (0);
-}
-
-/* Resume execution of the inferior process.
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal. */
-
-void
-resume (step, signal)
- int step;
- int signal;
-{
- errno = 0;
- if (remote_debugging)
- remote_resume (step, signal);
- else
- {
- ptrace (step ? 9 : 7, inferior_pid, 1, signal);
- if (errno)
- perror_with_name ("ptrace");
- }
-}
-
-void
-fetch_inferior_registers ()
-{
- register int regno;
- register unsigned int regaddr;
- char buf[MAX_REGISTER_RAW_SIZE];
- register int i;
-
- struct user u;
- unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
- offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- regaddr = register_addr (regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
- {
- *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0);
- regaddr += sizeof (int);
- }
- supply_register (regno, buf);
- }
-}
-
-/* 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). */
-
-store_inferior_registers (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[80];
-
- struct user u;
- unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
- offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR;
-
- if (regno >= 0)
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- ptrace (6, inferior_pid, regaddr, read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
- else for (regno = 0; regno < NUM_REGS; regno++)
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- ptrace (6, inferior_pid, regaddr, read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
-}
-
-/* Copy LEN bytes from inferior's memory starting at MEMADDR
- to debugger memory starting at MYADDR.
- On failure (cannot read from inferior, usually because address is out
- of bounds) returns the value of errno. */
-
-int
-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));
- extern int errno;
-
- /* Read all the longwords */
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- if (remote_debugging)
- buffer[i] = remote_fetch_word (addr);
- else
- buffer[i] = ptrace (1, inferior_pid, addr, 0);
- if (errno)
- return errno;
- }
-
- /* Copy appropriate bytes out of the buffer. */
- bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
- return 0;
-}
-
-/* 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. */
-
- if (remote_debugging)
- buffer[0] = remote_fetch_word (addr);
- else
- buffer[0] = ptrace (1, inferior_pid, addr, 0);
-
- if (count > 1)
- {
- if (remote_debugging)
- buffer[count - 1]
- = remote_fetch_word (addr + (count - 1) * sizeof (int));
- else
- buffer[count - 1]
- = ptrace (1, inferior_pid,
- addr + (count - 1) * sizeof (int), 0);
- }
-
- /* Copy data to be written over corresponding part of buffer */
-
- bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- if (remote_debugging)
- remote_store_word (addr, buffer[i]);
- else
- ptrace (4, inferior_pid, addr, buffer[i]);
- if (errno)
- return errno;
- }
-
- return 0;
-}
-
-/* Work with core dump and executable files, for GDB.
- This code would be in core.c if it weren't machine-dependent. */
-
-#ifndef N_TXTADDR
-#define N_TXTADDR(hdr) 0
-#endif /* no N_TXTADDR */
-
-#ifndef N_DATADDR
-#define N_DATADDR(hdr) hdr.a_text
-#endif /* no N_DATADDR */
-
-/* Make COFF and non-COFF names for things a little more compatible
- to reduce conditionals later. */
-
-#ifndef COFF_FORMAT
-#ifndef AOUTHDR
-#define AOUTHDR struct exec
-#endif
-#endif
-
-extern char *sys_siglist[];
-
-
-/* Hook for `exec_file_command' command to call. */
-
-extern void (*exec_file_display_hook) ();
-
-/* File names of core file and executable file. */
-
-extern char *corefile;
-extern char *execfile;
-
-/* Descriptors on which core file and executable file are open.
- Note that the execchan is closed when an inferior is created
- and reopened if the inferior dies or is killed. */
-
-extern int corechan;
-extern int execchan;
-
-/* Last modification time of executable file.
- Also used in source.c to compare against mtime of a source file. */
-
-extern int exec_mtime;
-
-/* Virtual addresses of bounds of the two areas of memory in the core file. */
-
-extern CORE_ADDR data_start;
-extern CORE_ADDR data_end;
-extern CORE_ADDR stack_start;
-extern CORE_ADDR stack_end;
-
-/* Virtual addresses of bounds of two areas of memory in the exec file.
- Note that the data area in the exec file is used only when there is no core file. */
-
-extern CORE_ADDR text_start;
-extern CORE_ADDR text_end;
-
-extern CORE_ADDR exec_data_start;
-extern CORE_ADDR exec_data_end;
-
-/* Address in executable file of start of text area data. */
-
-extern int text_offset;
-
-/* Address in executable file of start of data area data. */
-
-extern int exec_data_offset;
-
-/* Address in core file of start of data area data. */
-
-extern int data_offset;
-
-/* Address in core file of start of stack area data. */
-
-extern int stack_offset;
-
-#ifdef COFF_FORMAT
-/* various coff data structures */
-
-extern FILHDR file_hdr;
-extern SCNHDR text_hdr;
-extern SCNHDR data_hdr;
-
-#endif /* not COFF_FORMAT */
-
-/* a.out header saved in core file. */
-
-extern AOUTHDR core_aouthdr;
-
-/* a.out header of exec file. */
-
-extern AOUTHDR exec_aouthdr;
-
-extern void validate_files ();
-
-core_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
- extern char registers[];
-
- /* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
- if (corefile)
- free (corefile);
- corefile = 0;
-
- if (corechan >= 0)
- close (corechan);
- corechan = -1;
-
- data_start = 0;
- data_end = 0;
- stack_start = STACK_END_ADDR;
- stack_end = STACK_END_ADDR;
-
- /* Now, if a new core file was specified, open it and digest it. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- if (have_inferior_p ())
- error ("To look at a core file, you must kill the inferior with \"kill\".");
- corechan = open (filename, O_RDONLY, 0);
- if (corechan < 0)
- perror_with_name (filename);
- /* 4.2-style (and perhaps also sysV-style) core dump file. */
- {
- struct user u;
-
- int reg_offset;
-
- val = myread (corechan, &u, sizeof u);
- if (val < 0)
- perror_with_name (filename);
- data_start = exec_data_start;
-
- data_end = data_start + NBPG * u.u_dsize;
- stack_start = stack_end - NBPG * u.u_ssize;
- data_offset = NBPG * UPAGES;
- stack_offset = NBPG * (UPAGES + u.u_dsize);
- reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR;
-
- /* I don't know where to find this info.
- So, for now, mark it as not available. */
-/* N_SET_MAGIC (core_aouthdr, 0); */
- bzero ((char *) &core_aouthdr, sizeof core_aouthdr);
-
- /* Read the register values out of the core file and store
- them where `read_register' will find them. */
-
- {
- register int regno;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- val = lseek (corechan, register_addr (regno, reg_offset), 0);
- if (val < 0)
- perror_with_name (filename);
-
- val = myread (corechan, buf, sizeof buf);
- if (val < 0)
- perror_with_name (filename);
- supply_register (regno, buf);
- }
- }
- }
- if (filename[0] == '/')
- corefile = savestring (filename, strlen (filename));
- else
- {
- corefile = concat (current_directory, "/", filename);
- }
-
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
- select_frame (get_current_frame (), 0);
- validate_files ();
- }
- else if (from_tty)
- printf ("No core file now.\n");
-}
-
-exec_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
-
- /* Eliminate all traces of old exec file.
- Mark text segment as empty. */
-
- if (execfile)
- free (execfile);
- execfile = 0;
- data_start = 0;
- data_end -= exec_data_start;
- text_start = 0;
- text_end = 0;
- exec_data_start = 0;
- exec_data_end = 0;
- if (execchan >= 0)
- close (execchan);
- execchan = -1;
-
- /* Now open and digest the file the user requested, if any. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
- &execfile);
- if (execchan < 0)
- perror_with_name (filename);
-
-#ifdef COFF_FORMAT
- {
- int aout_hdrsize;
- int num_sections;
-
- if (read_file_hdr (execchan, &file_hdr) < 0)
- error ("\"%s\": not in executable format.", execfile);
-
- aout_hdrsize = file_hdr.f_opthdr;
- num_sections = file_hdr.f_nscns;
-
- if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0)
- error ("\"%s\": can't read optional aouthdr", execfile);
-
- if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections,
- aout_hdrsize) < 0)
- error ("\"%s\": can't read text section header", execfile);
-
- if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections,
- aout_hdrsize) < 0)
- error ("\"%s\": can't read data section header", execfile);
-
- text_start = exec_aouthdr.text_start;
- text_end = text_start + exec_aouthdr.tsize;
- text_offset = text_hdr.s_scnptr;
- exec_data_start = exec_aouthdr.data_start;
- exec_data_end = exec_data_start + exec_aouthdr.dsize;
- exec_data_offset = data_hdr.s_scnptr;
- data_start = exec_data_start;
- data_end += exec_data_start;
- exec_mtime = file_hdr.f_timdat;
- }
-#else /* not COFF_FORMAT */
- {
- struct stat st_exec;
-
-#ifdef HEADER_SEEK_FD
- HEADER_SEEK_FD (execchan);
-#endif
-
- val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR));
-
- if (val < 0)
- perror_with_name (filename);
-
- text_start = N_TXTADDR (exec_aouthdr);
- exec_data_start = N_DATADDR (exec_aouthdr);
-
- text_offset = N_TXTOFF (exec_aouthdr);
- exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text;
-
- text_end = text_start + exec_aouthdr.a_text;
- exec_data_end = exec_data_start + exec_aouthdr.a_data;
- data_start = exec_data_start;
- data_end += exec_data_start;
-
- fstat (execchan, &st_exec);
- exec_mtime = st_exec.st_mtime;
- }
-#endif /* not COFF_FORMAT */
-
- validate_files ();
- }
- else if (from_tty)
- printf ("No exec file now.\n");
-
- /* Tell display code (if any) about the changed file name. */
- if (exec_file_display_hook)
- (*exec_file_display_hook) (filename);
-}
-
-/* helper functions for m-i386.h */
-
-/* stdio style buffering to minimize calls to ptrace */
-static CORE_ADDR codestream_next_addr;
-static CORE_ADDR codestream_addr;
-static unsigned char codestream_buf[sizeof (int)];
-static int codestream_off;
-static int codestream_cnt;
-
-#define codestream_tell() (codestream_addr + codestream_off)
-#define codestream_peek() (codestream_cnt == 0 ? \
- codestream_fill(1): codestream_buf[codestream_off])
-#define codestream_get() (codestream_cnt-- == 0 ? \
- codestream_fill(0) : codestream_buf[codestream_off++])
-
-static unsigned char
-codestream_fill (peek_flag)
-{
- codestream_addr = codestream_next_addr;
- codestream_next_addr += sizeof (int);
- codestream_off = 0;
- codestream_cnt = sizeof (int);
- read_memory (codestream_addr,
- (unsigned char *)codestream_buf,
- sizeof (int));
-
- if (peek_flag)
- return (codestream_peek());
- else
- return (codestream_get());
-}
-
-static void
-codestream_seek (place)
-{
- codestream_next_addr = place & -sizeof (int);
- codestream_cnt = 0;
- codestream_fill (1);
- while (codestream_tell() != place)
- codestream_get ();
-}
-
-static void
-codestream_read (buf, count)
- unsigned char *buf;
-{
- unsigned char *p;
- int i;
- p = buf;
- for (i = 0; i < count; i++)
- *p++ = codestream_get ();
-}
-
-/* next instruction is a jump, move to target */
-static
-i386_follow_jump ()
-{
- int long_delta;
- short short_delta;
- char byte_delta;
- int data16;
- int pos;
-
- pos = codestream_tell ();
-
- data16 = 0;
- if (codestream_peek () == 0x66)
- {
- codestream_get ();
- data16 = 1;
- }
-
- switch (codestream_get ())
- {
- case 0xe9:
- /* relative jump: if data16 == 0, disp32, else disp16 */
- if (data16)
- {
- codestream_read ((unsigned char *)&short_delta, 2);
- pos += short_delta + 3; /* include size of jmp inst */
- }
- else
- {
- codestream_read ((unsigned char *)&long_delta, 4);
- pos += long_delta + 5;
- }
- break;
- case 0xeb:
- /* relative jump, disp8 (ignore data16) */
- codestream_read ((unsigned char *)&byte_delta, 1);
- pos += byte_delta + 2;
- break;
- }
- codestream_seek (pos + data16);
-}
-
-/*
- * find & return amound a local space allocated, and advance codestream to
- * first register push (if any)
- *
- * if entry sequence doesn't make sense, return -1, and leave
- * codestream pointer random
- */
-static long
-i386_get_frame_setup (pc)
-{
- unsigned char op;
-
- codestream_seek (pc);
-
- i386_follow_jump ();
-
- op = codestream_get ();
-
- if (op == 0x58) /* popl %eax */
- {
- /*
- * this function must start with
- *
- * popl %eax 0x58
- * xchgl %eax, (%esp) 0x87 0x04 0x24
- * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00
- *
- * (the system 5 compiler puts out the second xchg
- * inst, and the assembler doesn't try to optimize it,
- * so the 'sib' form gets generated)
- *
- * this sequence is used to get the address of the return
- * buffer for a function that returns a structure
- */
- int pos;
- unsigned char buf[4];
- static unsigned char proto1[3] = { 0x87,0x04,0x24 };
- static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 };
- pos = codestream_tell ();
- codestream_read (buf, 4);
- if (bcmp (buf, proto1, 3) == 0)
- pos += 3;
- else if (bcmp (buf, proto2, 4) == 0)
- pos += 4;
-
- codestream_seek (pos);
- op = codestream_get (); /* update next opcode */
- }
-
- if (op == 0x55) /* pushl %esp */
- {
- /* check for movl %esp, %ebp - can be written two ways */
- switch (codestream_get ())
- {
- case 0x8b:
- if (codestream_get () != 0xec)
- return (-1);
- break;
- case 0x89:
- if (codestream_get () != 0xe5)
- return (-1);
- break;
- default:
- return (-1);
- }
- /* check for stack adjustment
- *
- * subl $XXX, %esp
- *
- * note: you can't subtract a 16 bit immediate
- * from a 32 bit reg, so we don't have to worry
- * about a data16 prefix
- */
- op = codestream_peek ();
- if (op == 0x83)
- {
- /* subl with 8 bit immed */
- codestream_get ();
- if (codestream_get () != 0xec)
- return (-1);
- /* subl with signed byte immediate
- * (though it wouldn't make sense to be negative)
- */
- return (codestream_get());
- }
- else if (op == 0x81)
- {
- /* subl with 32 bit immed */
- int locals;
- codestream_get();
- if (codestream_get () != 0xec)
- return (-1);
- /* subl with 32 bit immediate */
- codestream_read ((unsigned char *)&locals, 4);
- return (locals);
- }
- else
- {
- return (0);
- }
- }
- else if (op == 0xc8)
- {
- /* enter instruction: arg is 16 bit unsigned immed */
- unsigned short slocals;
- codestream_read ((unsigned char *)&slocals, 2);
- codestream_get (); /* flush final byte of enter instruction */
- return (slocals);
- }
- return (-1);
-}
-
-/* Return number of args passed to a frame.
- Can return -1, meaning no way to tell. */
-
-/* on the 386, the instruction following the call could be:
- * popl %ecx - one arg
- * addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits
- * anything else - zero args
- */
-
-int
-i386_frame_num_args (fi)
- struct frame_info fi;
-{
- int retpc;
- unsigned char op;
- struct frame_info *pfi;
-
- pfi = get_prev_frame_info ((fi));
- if (pfi == 0)
- {
- /* Note: this can happen if we are looking at the frame for
- main, because FRAME_CHAIN_VALID won't let us go into
- start. If we have debugging symbols, that's not really
- a big deal; it just means it will only show as many arguments
- to main as are declared. */
- return -1;
- }
- else
- {
- retpc = pfi->pc;
- op = read_memory_integer (retpc, 1);
- if (op == 0x59)
- /* pop %ecx */
- return 1;
- else if (op == 0x83)
- {
- op = read_memory_integer (retpc+1, 1);
- if (op == 0xc4)
- /* addl $<signed imm 8 bits>, %esp */
- return (read_memory_integer (retpc+2,1)&0xff)/4;
- else
- return 0;
- }
- else if (op == 0x81)
- { /* add with 32 bit immediate */
- op = read_memory_integer (retpc+1, 1);
- if (op == 0xc4)
- /* addl $<imm 32>, %esp */
- return read_memory_integer (retpc+2, 4) / 4;
- else
- return 0;
- }
- else
- {
- return 0;
- }
- }
-}
-
-/*
- * parse the first few instructions of the function to see
- * what registers were stored.
- *
- * We handle these cases:
- *
- * The startup sequence can be at the start of the function,
- * or the function can start with a branch to startup code at the end.
- *
- * %ebp can be set up with either the 'enter' instruction, or
- * 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful,
- * but was once used in the sys5 compiler)
- *
- * Local space is allocated just below the saved %ebp by either the
- * 'enter' instruction, or by 'subl $<size>, %esp'. 'enter' has
- * a 16 bit unsigned argument for space to allocate, and the
- * 'addl' instruction could have either a signed byte, or
- * 32 bit immediate.
- *
- * Next, the registers used by this function are pushed. In
- * the sys5 compiler they will always be in the order: %edi, %esi, %ebx
- * (and sometimes a harmless bug causes it to also save but not restore %eax);
- * however, the code below is willing to see the pushes in any order,
- * and will handle up to 8 of them.
- *
- * If the setup sequence is at the end of the function, then the
- * next instruction will be a branch back to the start.
- */
-
-i386_frame_find_saved_regs (fip, fsrp)
- struct frame_info *fip;
- struct frame_saved_regs *fsrp;
-{
- unsigned long locals;
- unsigned char *p;
- unsigned char op;
- CORE_ADDR dummy_bottom;
- CORE_ADDR adr;
- int i;
-
- bzero (fsrp, sizeof *fsrp);
-
- /* if frame is the end of a dummy, compute where the
- * beginning would be
- */
- dummy_bottom = fip->frame - 4 - NUM_REGS*4 - CALL_DUMMY_LENGTH;
-
- /* check if the PC is in the stack, in a dummy frame */
- if (dummy_bottom <= fip->pc && fip->pc <= fip->frame)
- {
- /* all regs were saved by push_call_dummy () */
- adr = fip->frame - 4;
- for (i = 0; i < NUM_REGS; i++)
- {
- fsrp->regs[i] = adr;
- adr -= 4;
- }
- return;
- }
-
- locals = i386_get_frame_setup (get_pc_function_start (fip->pc));
-
- if (locals >= 0)
- {
- adr = fip->frame - 4 - locals;
- for (i = 0; i < 8; i++)
- {
- op = codestream_get ();
- if (op < 0x50 || op > 0x57)
- break;
- fsrp->regs[op - 0x50] = adr;
- adr -= 4;
- }
- }
-
- fsrp->regs[PC_REGNUM] = fip->frame + 4;
- fsrp->regs[FP_REGNUM] = fip->frame;
-}
-
-/* return pc of first real instruction */
-i386_skip_prologue (pc)
-{
- unsigned char op;
- int i;
-
- if (i386_get_frame_setup (pc) < 0)
- return (pc);
-
- /* found valid frame setup - codestream now points to
- * start of push instructions for saving registers
- */
-
- /* skip over register saves */
- for (i = 0; i < 8; i++)
- {
- op = codestream_peek ();
- /* break if not pushl inst */
- if (op < 0x50 || op > 0x57)
- break;
- codestream_get ();
- }
-
- i386_follow_jump ();
-
- return (codestream_tell ());
-}
-
-i386_push_dummy_frame ()
-{
- CORE_ADDR sp = read_register (SP_REGNUM);
- int regnum;
-
- sp = push_word (sp, read_register (PC_REGNUM));
- sp = push_word (sp, read_register (FP_REGNUM));
- write_register (FP_REGNUM, sp);
- for (regnum = 0; regnum < NUM_REGS; regnum++)
- sp = push_word (sp, read_register (regnum));
- write_register (SP_REGNUM, sp);
-}
-
-i386_pop_frame ()
-{
- FRAME frame = get_current_frame ();
- CORE_ADDR fp;
- int regnum;
- struct frame_saved_regs fsr;
- struct frame_info *fi;
-
- fi = get_frame_info (frame);
- fp = fi->frame;
- get_frame_saved_regs (fi, &fsr);
- for (regnum = 0; regnum < NUM_REGS; regnum++)
- {
- CORE_ADDR adr;
- adr = fsr.regs[regnum];
- if (adr)
- write_register (regnum, read_memory_integer (adr, 4));
- }
- write_register (FP_REGNUM, read_memory_integer (fp, 4));
- write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));
- write_register (SP_REGNUM, fp + 8);
- flush_cached_frames ();
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
-}
-
-/* this table must line up with REGISTER_NAMES in m-i386.h */
-/* symbols like 'EAX' come from <sys/reg.h> */
-static int regmap[] =
-{
- EAX, ECX, EDX, EBX,
- UESP, EBP, ESI, EDI,
- EIP, EFL, CS, SS,
- DS, ES, FS, GS,
-};
-
-/* blockend is the value of u.u_ar0, and points to the
- * place where GS is stored
- */
-i386_register_u_addr (blockend, regnum)
-{
-#if 0
- /* this will be needed if fp registers are reinstated */
- /* for now, you can look at them with 'info float'
- * sys5 wont let you change them with ptrace anyway
- */
- if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM)
- {
- int ubase, fpstate;
- struct user u;
- ubase = blockend + 4 * (SS + 1) - KSTKSZ;
- fpstate = ubase + ((char *)&u.u_fpstate - (char *)&u);
- return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM));
- }
- else
-#endif
- return (blockend + 4 * regmap[regnum]);
-
-}
-
-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 */
-}
-
-double_to_i387 (from, to)
- char *from;
- char *to;
-{
- /* push double mode on 387 stack, then pop in extended mode
- * no errors are possible because every 64-bit pattern
- * can be converted to an extended
- */
- asm ("movl 8(%ebp),%eax");
- asm ("fldl (%eax)");
- asm ("fwait");
- asm ("movl 12(%ebp),%eax");
- asm ("fstpt (%eax)");
- asm ("fwait");
-}
-
-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
-print_387_control_word (control)
-unsigned short control;
-{
- printf ("control 0x%04x: ", control);
- printf ("compute to ");
- switch ((control >> 8) & 3)
- {
- case 0: printf ("24 bits; "); break;
- case 1: printf ("(bad); "); break;
- case 2: printf ("53 bits; "); break;
- case 3: printf ("64 bits; "); break;
- }
- printf ("round ");
- switch ((control >> 10) & 3)
- {
- case 0: printf ("NEAREST; "); break;
- case 1: printf ("DOWN; "); break;
- case 2: printf ("UP; "); break;
- case 3: printf ("CHOP; "); break;
- }
- if (control & 0x3f)
- {
- printf ("mask:");
- if (control & 0x0001) printf (" INVALID");
- if (control & 0x0002) printf (" DENORM");
- if (control & 0x0004) printf (" DIVZ");
- if (control & 0x0008) printf (" OVERF");
- if (control & 0x0010) printf (" UNDERF");
- if (control & 0x0020) printf (" LOS");
- printf (";");
- }
- printf ("\n");
- if (control & 0xe080) printf ("warning: reserved bits on 0x%x\n",
- control & 0xe080);
-}
-
-static
-print_387_status_word (status)
- unsigned short status;
-{
- printf ("status 0x%04x: ", status);
- if (status & 0xff)
- {
- printf ("exceptions:");
- if (status & 0x0001) printf (" INVALID");
- if (status & 0x0002) printf (" DENORM");
- if (status & 0x0004) printf (" DIVZ");
- if (status & 0x0008) printf (" OVERF");
- if (status & 0x0010) printf (" UNDERF");
- if (status & 0x0020) printf (" LOS");
- if (status & 0x0040) printf (" FPSTACK");
- printf ("; ");
- }
- printf ("flags: %d%d%d%d; ",
- (status & 0x4000) != 0,
- (status & 0x0400) != 0,
- (status & 0x0200) != 0,
- (status & 0x0100) != 0);
-
- printf ("top %d\n", (status >> 11) & 7);
-}
-
-static
-print_387_status (status, ep)
- unsigned short status;
- struct env387 *ep;
-{
- int i;
- int bothstatus;
- int top;
- int fpreg;
- unsigned char *p;
-
- bothstatus = ((status != 0) && (ep->status != 0));
- if (status != 0)
- {
- if (bothstatus)
- printf ("u: ");
- print_387_status_word (status);
- }
-
- if (ep->status != 0)
- {
- if (bothstatus)
- printf ("e: ");
- print_387_status_word (ep->status);
- }
-
- print_387_control_word (ep->control);
- printf ("last exception: ");
- printf ("opcode 0x%x; ", ep->opcode);
- printf ("pc 0x%x:0x%x; ", ep->code_seg, ep->eip);
- printf ("operand 0x%x:0x%x\n", ep->operand_seg, ep->operand);
-
- top = (ep->status >> 11) & 7;
-
- printf ("regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- double val;
-
- printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
-
- switch ((ep->tag >> (fpreg * 2)) & 3)
- {
- case 0: printf ("valid "); break;
- case 1: printf ("zero "); break;
- case 2: printf ("trap "); break;
- case 3: printf ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf ("%02x", ep->regs[fpreg][i]);
-
- i387_to_double (ep->regs[fpreg], (char *)&val);
- printf (" %g\n", val);
- }
- if (ep->r0)
- printf ("warning: reserved0 is 0x%x\n", ep->r0);
- if (ep->r1)
- printf ("warning: reserved1 is 0x%x\n", ep->r1);
- if (ep->r2)
- printf ("warning: reserved2 is 0x%x\n", ep->r2);
- if (ep->r3)
- printf ("warning: reserved3 is 0x%x\n", ep->r3);
-}
-
-#ifndef U_FPSTATE
-#define U_FPSTATE(u) u.u_fpstate
-#endif
-
-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;
-
- uaddr = (char *)&u.u_fpvalid - (char *)&u;
- if (have_inferior_p())
- {
- unsigned int data;
- unsigned int mask;
-
- rounded_addr = uaddr & -sizeof (int);
- data = ptrace (3, inferior_pid, rounded_addr, 0);
- mask = 0xff << ((uaddr - rounded_addr) * 8);
-
- fpvalid = ((data & mask) != 0);
- }
- else
- {
- if (lseek (corechan, uaddr, 0) < 0)
- perror ("seek on core file");
- if (myread (corechan, &fpvalid, 1) < 0)
- perror ("read on core file");
-
- }
-
- if (fpvalid == 0)
- {
- printf ("no floating point status saved\n");
- return;
- }
-
- uaddr = (char *)&U_FPSTATE(u) - (char *)&u;
- if (have_inferior_p ())
- {
- 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 (3, inferior_pid, rounded_addr, 0);
- rounded_addr += sizeof (int);
- }
- }
- else
- {
- if (lseek (corechan, uaddr, 0) < 0)
- perror_with_name ("seek on core file");
- if (myread (corechan, buf, sizeof (struct fpstate)) < 0)
- perror_with_name ("read from core file");
- skip = 0;
- }
-
- fpstatep = (struct fpstate *)(buf + skip);
- print_387_status (fpstatep->status, (struct env387 *)fpstatep->state);
-}
-
diff --git a/gnu/usr.bin/gdb/config/i386-pinsn.c b/gnu/usr.bin/gdb/config/i386-pinsn.c
deleted file mode 100644
index 649baaf..0000000
--- a/gnu/usr.bin/gdb/config/i386-pinsn.c
+++ /dev/null
@@ -1,1812 +0,0 @@
-/* Print i386 instructions for GDB, the GNU debugger.
- Copyright (C) 1988, 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. */
-
-/*
- * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
- * July 1988
- */
-
-/*
- * The main tables describing the instructions is essentially a copy
- * of the "Opcode Map" chapter (Appendix A) of the Intel 80386
- * Programmers Manual. Usually, there is a capital letter, followed
- * by a small letter. The capital letter tell the addressing mode,
- * and the small letter tells about the operand size. Refer to
- * the Intel manual for details.
- */
-
-#include <stdio.h>
-#include <ctype.h>
-
-#define Eb OP_E, b_mode
-#define indirEb OP_indirE, b_mode
-#define Gb OP_G, b_mode
-#define Ev OP_E, v_mode
-#define indirEv OP_indirE, v_mode
-#define Ew OP_E, w_mode
-#define Ma OP_E, v_mode
-#define M OP_E, 0
-#define Mp OP_E, 0 /* ? */
-#define Gv OP_G, v_mode
-#define Gw OP_G, w_mode
-#define Rw OP_rm, w_mode
-#define Rd OP_rm, d_mode
-#define Ib OP_I, b_mode
-#define sIb OP_sI, b_mode /* sign extened byte */
-#define Iv OP_I, v_mode
-#define Iw OP_I, w_mode
-#define Jb OP_J, b_mode
-#define Jv OP_J, v_mode
-#define ONE OP_ONE, 0
-#define Cd OP_C, d_mode
-#define Dd OP_D, d_mode
-#define Td OP_T, d_mode
-
-#define eAX OP_REG, eAX_reg
-#define eBX OP_REG, eBX_reg
-#define eCX OP_REG, eCX_reg
-#define eDX OP_REG, eDX_reg
-#define eSP OP_REG, eSP_reg
-#define eBP OP_REG, eBP_reg
-#define eSI OP_REG, eSI_reg
-#define eDI OP_REG, eDI_reg
-#define AL OP_REG, al_reg
-#define CL OP_REG, cl_reg
-#define DL OP_REG, dl_reg
-#define BL OP_REG, bl_reg
-#define AH OP_REG, ah_reg
-#define CH OP_REG, ch_reg
-#define DH OP_REG, dh_reg
-#define BH OP_REG, bh_reg
-#define AX OP_REG, ax_reg
-#define DX OP_REG, dx_reg
-#define indirDX OP_REG, indir_dx_reg
-
-#define Sw OP_SEG, w_mode
-#define Ap OP_DIR, lptr
-#define Av OP_DIR, v_mode
-#define Ob OP_OFF, b_mode
-#define Ov OP_OFF, v_mode
-#define Xb OP_DSSI, b_mode
-#define Xv OP_DSSI, v_mode
-#define Yb OP_ESDI, b_mode
-#define Yv OP_ESDI, v_mode
-
-#define es OP_REG, es_reg
-#define ss OP_REG, ss_reg
-#define cs OP_REG, cs_reg
-#define ds OP_REG, ds_reg
-#define fs OP_REG, fs_reg
-#define gs OP_REG, gs_reg
-
-int OP_E(), OP_indirE(), OP_G(), OP_I(), OP_sI(), OP_REG();
-int OP_J(), OP_SEG();
-int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C();
-int OP_D(), OP_T(), OP_rm();
-
-
-#define b_mode 1
-#define v_mode 2
-#define w_mode 3
-#define d_mode 4
-
-#define es_reg 100
-#define cs_reg 101
-#define ss_reg 102
-#define ds_reg 103
-#define fs_reg 104
-#define gs_reg 105
-#define eAX_reg 107
-#define eCX_reg 108
-#define eDX_reg 109
-#define eBX_reg 110
-#define eSP_reg 111
-#define eBP_reg 112
-#define eSI_reg 113
-#define eDI_reg 114
-
-#define lptr 115
-
-#define al_reg 116
-#define cl_reg 117
-#define dl_reg 118
-#define bl_reg 119
-#define ah_reg 120
-#define ch_reg 121
-#define dh_reg 122
-#define bh_reg 123
-
-#define ax_reg 124
-#define cx_reg 125
-#define dx_reg 126
-#define bx_reg 127
-#define sp_reg 128
-#define bp_reg 129
-#define si_reg 130
-#define di_reg 131
-
-#define indir_dx_reg 150
-
-#define GRP1b NULL, NULL, 0
-#define GRP1S NULL, NULL, 1
-#define GRP1Ss NULL, NULL, 2
-#define GRP2b NULL, NULL, 3
-#define GRP2S NULL, NULL, 4
-#define GRP2b_one NULL, NULL, 5
-#define GRP2S_one NULL, NULL, 6
-#define GRP2b_cl NULL, NULL, 7
-#define GRP2S_cl NULL, NULL, 8
-#define GRP3b NULL, NULL, 9
-#define GRP3S NULL, NULL, 10
-#define GRP4 NULL, NULL, 11
-#define GRP5 NULL, NULL, 12
-#define GRP6 NULL, NULL, 13
-#define GRP7 NULL, NULL, 14
-#define GRP8 NULL, NULL, 15
-
-#define FLOATCODE 50
-#define FLOAT NULL, NULL, FLOATCODE
-
-struct dis386 {
- char *name;
- int (*op1)();
- int bytemode1;
- int (*op2)();
- int bytemode2;
- int (*op3)();
- int bytemode3;
-};
-
-struct dis386 dis386[] = {
- /* 00 */
- { "addb", Eb, Gb },
- { "addS", Ev, Gv },
- { "addb", Gb, Eb },
- { "addS", Gv, Ev },
- { "addb", AL, Ib },
- { "addS", eAX, Iv },
- { "pushl", es },
- { "popl", es },
- /* 08 */
- { "orb", Eb, Gb },
- { "orS", Ev, Gv },
- { "orb", Gb, Eb },
- { "orS", Gv, Ev },
- { "orb", AL, Ib },
- { "orS", eAX, Iv },
- { "pushl", cs },
- { "(bad)" }, /* 0x0f extended opcode escape */
- /* 10 */
- { "adcb", Eb, Gb },
- { "adcS", Ev, Gv },
- { "adcb", Gb, Eb },
- { "adcS", Gv, Ev },
- { "adcb", AL, Ib },
- { "adcS", eAX, Iv },
- { "pushl", ss },
- { "popl", ss },
- /* 18 */
- { "sbbb", Eb, Gb },
- { "sbbS", Ev, Gv },
- { "sbbb", Gb, Eb },
- { "sbbS", Gv, Ev },
- { "sbbb", AL, Ib },
- { "sbbS", eAX, Iv },
- { "pushl", ds },
- { "popl", ds },
- /* 20 */
- { "andb", Eb, Gb },
- { "andS", Ev, Gv },
- { "andb", Gb, Eb },
- { "andS", Gv, Ev },
- { "andb", AL, Ib },
- { "andS", eAX, Iv },
- { "(bad)" }, /* SEG ES prefix */
- { "daa" },
- /* 28 */
- { "subb", Eb, Gb },
- { "subS", Ev, Gv },
- { "subb", Gb, Eb },
- { "subS", Gv, Ev },
- { "subb", AL, Ib },
- { "subS", eAX, Iv },
- { "(bad)" }, /* SEG CS prefix */
- { "das" },
- /* 30 */
- { "xorb", Eb, Gb },
- { "xorS", Ev, Gv },
- { "xorb", Gb, Eb },
- { "xorS", Gv, Ev },
- { "xorb", AL, Ib },
- { "xorS", eAX, Iv },
- { "(bad)" }, /* SEG SS prefix */
- { "aaa" },
- /* 38 */
- { "cmpb", Eb, Gb },
- { "cmpS", Ev, Gv },
- { "cmpb", Gb, Eb },
- { "cmpS", Gv, Ev },
- { "cmpb", AL, Ib },
- { "cmpS", eAX, Iv },
- { "(bad)" }, /* SEG DS prefix */
- { "aas" },
- /* 40 */
- { "incS", eAX },
- { "incS", eCX },
- { "incS", eDX },
- { "incS", eBX },
- { "incS", eSP },
- { "incS", eBP },
- { "incS", eSI },
- { "incS", eDI },
- /* 48 */
- { "decS", eAX },
- { "decS", eCX },
- { "decS", eDX },
- { "decS", eBX },
- { "decS", eSP },
- { "decS", eBP },
- { "decS", eSI },
- { "decS", eDI },
- /* 50 */
- { "pushS", eAX },
- { "pushS", eCX },
- { "pushS", eDX },
- { "pushS", eBX },
- { "pushS", eSP },
- { "pushS", eBP },
- { "pushS", eSI },
- { "pushS", eDI },
- /* 58 */
- { "popS", eAX },
- { "popS", eCX },
- { "popS", eDX },
- { "popS", eBX },
- { "popS", eSP },
- { "popS", eBP },
- { "popS", eSI },
- { "popS", eDI },
- /* 60 */
- { "pusha" },
- { "popa" },
- { "boundS", Gv, Ma },
- { "arpl", Ew, Gw },
- { "(bad)" }, /* seg fs */
- { "(bad)" }, /* seg gs */
- { "(bad)" }, /* op size prefix */
- { "(bad)" }, /* adr size prefix */
- /* 68 */
- { "pushS", Iv }, /* 386 book wrong */
- { "imulS", Gv, Ev, Iv },
- { "pushl", sIb }, /* push of byte really pushes 4 bytes */
- { "imulS", Gv, Ev, Ib },
- { "insb", Yb, indirDX },
- { "insS", Yv, indirDX },
- { "outsb", indirDX, Xb },
- { "outsS", indirDX, Xv },
- /* 70 */
- { "jo", Jb },
- { "jno", Jb },
- { "jb", Jb },
- { "jae", Jb },
- { "je", Jb },
- { "jne", Jb },
- { "jbe", Jb },
- { "ja", Jb },
- /* 78 */
- { "js", Jb },
- { "jns", Jb },
- { "jp", Jb },
- { "jnp", Jb },
- { "jl", Jb },
- { "jnl", Jb },
- { "jle", Jb },
- { "jg", Jb },
- /* 80 */
- { GRP1b },
- { GRP1S },
- { "(bad)" },
- { GRP1Ss },
- { "testb", Eb, Gb },
- { "testS", Ev, Gv },
- { "xchgb", Eb, Gb },
- { "xchgS", Ev, Gv },
- /* 88 */
- { "movb", Eb, Gb },
- { "movS", Ev, Gv },
- { "movb", Gb, Eb },
- { "movS", Gv, Ev },
- { "movw", Ew, Sw },
- { "leaS", Gv, M },
- { "movw", Sw, Ew },
- { "popS", Ev },
- /* 90 */
- { "nop" },
- { "xchgS", eCX, eAX },
- { "xchgS", eDX, eAX },
- { "xchgS", eBX, eAX },
- { "xchgS", eSP, eAX },
- { "xchgS", eBP, eAX },
- { "xchgS", eSI, eAX },
- { "xchgS", eDI, eAX },
- /* 98 */
- { "cwtl" },
- { "cltd" },
- { "lcall", Ap },
- { "(bad)" }, /* fwait */
- { "pushf" },
- { "popf" },
- { "sahf" },
- { "lahf" },
- /* a0 */
- { "movb", AL, Ob },
- { "movS", eAX, Ov },
- { "movb", Ob, AL },
- { "movS", Ov, eAX },
- { "movsb", Yb, Xb },
- { "movsS", Yv, Xv },
- { "cmpsb", Yb, Xb },
- { "cmpsS", Yv, Xv },
- /* a8 */
- { "testb", AL, Ib },
- { "testS", eAX, Iv },
- { "stosb", Yb, AL },
- { "stosS", Yv, eAX },
- { "lodsb", AL, Xb },
- { "lodsS", eAX, Xv },
- { "scasb", AL, Xb },
- { "scasS", eAX, Xv },
- /* b0 */
- { "movb", AL, Ib },
- { "movb", CL, Ib },
- { "movb", DL, Ib },
- { "movb", BL, Ib },
- { "movb", AH, Ib },
- { "movb", CH, Ib },
- { "movb", DH, Ib },
- { "movb", BH, Ib },
- /* b8 */
- { "movS", eAX, Iv },
- { "movS", eCX, Iv },
- { "movS", eDX, Iv },
- { "movS", eBX, Iv },
- { "movS", eSP, Iv },
- { "movS", eBP, Iv },
- { "movS", eSI, Iv },
- { "movS", eDI, Iv },
- /* c0 */
- { GRP2b },
- { GRP2S },
- { "ret", Iw },
- { "ret" },
- { "lesS", Gv, Mp },
- { "ldsS", Gv, Mp },
- { "movb", Eb, Ib },
- { "movS", Ev, Iv },
- /* c8 */
- { "enter", Iw, Ib },
- { "leave" },
- { "lret", Iw },
- { "lret" },
- { "int3" },
- { "int", Ib },
- { "into" },
- { "iret" },
- /* d0 */
- { GRP2b_one },
- { GRP2S_one },
- { GRP2b_cl },
- { GRP2S_cl },
- { "aam", Ib },
- { "aad", Ib },
- { "(bad)" },
- { "xlat" },
- /* d8 */
- { FLOAT },
- { FLOAT },
- { FLOAT },
- { FLOAT },
- { FLOAT },
- { FLOAT },
- { FLOAT },
- { FLOAT },
- /* e0 */
- { "loopne", Jb },
- { "loope", Jb },
- { "loop", Jb },
- { "jCcxz", Jb },
- { "inb", AL, Ib },
- { "inS", eAX, Ib },
- { "outb", Ib, AL },
- { "outS", Ib, eAX },
- /* e8 */
- { "call", Av },
- { "jmp", Jv },
- { "ljmp", Ap },
- { "jmp", Jb },
- { "inb", AL, indirDX },
- { "inS", eAX, indirDX },
- { "outb", indirDX, AL },
- { "outS", indirDX, eAX },
- /* f0 */
- { "(bad)" }, /* lock prefix */
- { "(bad)" },
- { "(bad)" }, /* repne */
- { "(bad)" }, /* repz */
- { "hlt" },
- { "cmc" },
- { GRP3b },
- { GRP3S },
- /* f8 */
- { "clc" },
- { "stc" },
- { "cli" },
- { "sti" },
- { "cld" },
- { "std" },
- { GRP4 },
- { GRP5 },
-};
-
-struct dis386 dis386_twobyte[] = {
- /* 00 */
- { GRP6 },
- { GRP7 },
- { "larS", Gv, Ew },
- { "lslS", Gv, Ew },
- { "(bad)" },
- { "(bad)" },
- { "clts" },
- { "(bad)" },
- /* 08 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 10 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 18 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 20 */
- /* these are all backward in appendix A of the intel book */
- { "movl", Rd, Cd },
- { "movl", Rd, Dd },
- { "movl", Cd, Rd },
- { "movl", Dd, Rd },
- { "movl", Rd, Td },
- { "(bad)" },
- { "movl", Td, Rd },
- { "(bad)" },
- /* 28 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 30 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 38 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 40 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 48 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 50 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 58 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 60 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 68 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 70 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 78 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* 80 */
- { "jo", Jv },
- { "jno", Jv },
- { "jb", Jv },
- { "jae", Jv },
- { "je", Jv },
- { "jne", Jv },
- { "jbe", Jv },
- { "ja", Jv },
- /* 88 */
- { "js", Jv },
- { "jns", Jv },
- { "jp", Jv },
- { "jnp", Jv },
- { "jl", Jv },
- { "jge", Jv },
- { "jle", Jv },
- { "jg", Jv },
- /* 90 */
- { "seto", Eb },
- { "setno", Eb },
- { "setb", Eb },
- { "setae", Eb },
- { "sete", Eb },
- { "setne", Eb },
- { "setbe", Eb },
- { "seta", Eb },
- /* 98 */
- { "sets", Eb },
- { "setns", Eb },
- { "setp", Eb },
- { "setnp", Eb },
- { "setl", Eb },
- { "setge", Eb },
- { "setle", Eb },
- { "setg", Eb },
- /* a0 */
- { "pushl", fs },
- { "popl", fs },
- { "(bad)" },
- { "btS", Ev, Gv },
- { "shldS", Ev, Gv, Ib },
- { "shldS", Ev, Gv, CL },
- { "(bad)" },
- { "(bad)" },
- /* a8 */
- { "pushl", gs },
- { "popl", gs },
- { "(bad)" },
- { "btsS", Ev, Gv },
- { "shrdS", Ev, Gv, Ib },
- { "shrdS", Ev, Gv, CL },
- { "(bad)" },
- { "imulS", Gv, Ev },
- /* b0 */
- { "(bad)" },
- { "(bad)" },
- { "lssS", Gv, Mp }, /* 386 lists only Mp */
- { "btrS", Ev, Gv },
- { "lfsS", Gv, Mp }, /* 386 lists only Mp */
- { "lgsS", Gv, Mp }, /* 386 lists only Mp */
- { "movzbS", Gv, Eb },
- { "movzwS", Gv, Ew },
- /* b8 */
- { "(bad)" },
- { "(bad)" },
- { GRP8 },
- { "btcS", Ev, Gv },
- { "bsfS", Gv, Ev },
- { "bsrS", Gv, Ev },
- { "movsbS", Gv, Eb },
- { "movswS", Gv, Ew },
- /* c0 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* c8 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* d0 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* d8 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* e0 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* e8 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* f0 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- /* f8 */
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
- { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
-};
-
-static char obuf[100];
-static char *obufp;
-static char scratchbuf[100];
-static unsigned char *start_codep;
-static unsigned char *codep;
-static int mod;
-static int rm;
-static int reg;
-
-static char *names32[]={
- "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi",
-};
-static char *names16[] = {
- "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di",
-};
-static char *names8[] = {
- "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh",
-};
-static char *names_seg[] = {
- "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
-};
-
-struct dis386 grps[][8] = {
- /* GRP1b */
- {
- { "addb", Eb, Ib },
- { "orb", Eb, Ib },
- { "adcb", Eb, Ib },
- { "sbbb", Eb, Ib },
- { "andb", Eb, Ib },
- { "subb", Eb, Ib },
- { "xorb", Eb, Ib },
- { "cmpb", Eb, Ib }
- },
- /* GRP1S */
- {
- { "addS", Ev, Iv },
- { "orS", Ev, Iv },
- { "adcS", Ev, Iv },
- { "sbbS", Ev, Iv },
- { "andS", Ev, Iv },
- { "subS", Ev, Iv },
- { "xorS", Ev, Iv },
- { "cmpS", Ev, Iv }
- },
- /* GRP1Ss */
- {
- { "addS", Ev, sIb },
- { "orS", Ev, sIb },
- { "adcS", Ev, sIb },
- { "sbbS", Ev, sIb },
- { "andS", Ev, sIb },
- { "subS", Ev, sIb },
- { "xorS", Ev, sIb },
- { "cmpS", Ev, sIb }
- },
- /* GRP2b */
- {
- { "rolb", Eb, Ib },
- { "rorb", Eb, Ib },
- { "rclb", Eb, Ib },
- { "rcrb", Eb, Ib },
- { "shlb", Eb, Ib },
- { "shrb", Eb, Ib },
- { "(bad)" },
- { "sarb", Eb, Ib },
- },
- /* GRP2S */
- {
- { "rolS", Ev, Ib },
- { "rorS", Ev, Ib },
- { "rclS", Ev, Ib },
- { "rcrS", Ev, Ib },
- { "shlS", Ev, Ib },
- { "shrS", Ev, Ib },
- { "(bad)" },
- { "sarS", Ev, Ib },
- },
- /* GRP2b_one */
- {
- { "rolb", Eb },
- { "rorb", Eb },
- { "rclb", Eb },
- { "rcrb", Eb },
- { "shlb", Eb },
- { "shrb", Eb },
- { "(bad)" },
- { "sarb", Eb },
- },
- /* GRP2S_one */
- {
- { "rolS", Ev },
- { "rorS", Ev },
- { "rclS", Ev },
- { "rcrS", Ev },
- { "shlS", Ev },
- { "shrS", Ev },
- { "(bad)" },
- { "sarS", Ev },
- },
- /* GRP2b_cl */
- {
- { "rolb", Eb, CL },
- { "rorb", Eb, CL },
- { "rclb", Eb, CL },
- { "rcrb", Eb, CL },
- { "shlb", Eb, CL },
- { "shrb", Eb, CL },
- { "(bad)" },
- { "sarb", Eb, CL },
- },
- /* GRP2S_cl */
- {
- { "rolS", Ev, CL },
- { "rorS", Ev, CL },
- { "rclS", Ev, CL },
- { "rcrS", Ev, CL },
- { "shlS", Ev, CL },
- { "shrS", Ev, CL },
- { "(bad)" },
- { "sarS", Ev, CL }
- },
- /* GRP3b */
- {
- { "testb", Eb, Ib },
- { "(bad)", Eb },
- { "notb", Eb },
- { "negb", Eb },
- { "mulb", AL, Eb },
- { "imulb", AL, Eb },
- { "divb", AL, Eb },
- { "idivb", AL, Eb }
- },
- /* GRP3S */
- {
- { "testS", Ev, Iv },
- { "(bad)" },
- { "notS", Ev },
- { "negS", Ev },
- { "mulS", eAX, Ev },
- { "imulS", eAX, Ev },
- { "divS", eAX, Ev },
- { "idivS", eAX, Ev },
- },
- /* GRP4 */
- {
- { "incb", Eb },
- { "decb", Eb },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- },
- /* GRP5 */
- {
- { "incS", Ev },
- { "decS", Ev },
- { "call", indirEv },
- { "lcall", indirEv },
- { "jmp", indirEv },
- { "ljmp", indirEv },
- { "pushS", Ev },
- { "(bad)" },
- },
- /* GRP6 */
- {
- { "sldt", Ew },
- { "str", Ew },
- { "lldt", Ew },
- { "ltr", Ew },
- { "verr", Ew },
- { "verw", Ew },
- { "(bad)" },
- { "(bad)" }
- },
- /* GRP7 */
- {
- { "sgdt", Ew },
- { "sidt", Ew },
- { "lgdt", Ew },
- { "lidt", Ew },
- { "smsw", Ew },
- { "(bad)" },
- { "lmsw", Ew },
- { "(bad)" },
- },
- /* GRP8 */
- {
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "btS", Ev, Ib },
- { "btsS", Ev, Ib },
- { "btrS", Ev, Ib },
- { "btcS", Ev, Ib },
- }
-};
-
-#define PREFIX_REPZ 1
-#define PREFIX_REPNZ 2
-#define PREFIX_LOCK 4
-#define PREFIX_CS 8
-#define PREFIX_SS 0x10
-#define PREFIX_DS 0x20
-#define PREFIX_ES 0x40
-#define PREFIX_FS 0x80
-#define PREFIX_GS 0x100
-#define PREFIX_DATA 0x200
-#define PREFIX_ADR 0x400
-#define PREFIX_FWAIT 0x800
-
-static int prefixes;
-
-ckprefix ()
-{
- prefixes = 0;
- while (1)
- {
- switch (*codep)
- {
- case 0xf3:
- prefixes |= PREFIX_REPZ;
- break;
- case 0xf2:
- prefixes |= PREFIX_REPNZ;
- break;
- case 0xf0:
- prefixes |= PREFIX_LOCK;
- break;
- case 0x2e:
- prefixes |= PREFIX_CS;
- break;
- case 0x36:
- prefixes |= PREFIX_SS;
- break;
- case 0x3e:
- prefixes |= PREFIX_DS;
- break;
- case 0x26:
- prefixes |= PREFIX_ES;
- break;
- case 0x64:
- prefixes |= PREFIX_FS;
- break;
- case 0x65:
- prefixes |= PREFIX_GS;
- break;
- case 0x66:
- prefixes |= PREFIX_DATA;
- break;
- case 0x67:
- prefixes |= PREFIX_ADR;
- break;
- case 0x9b:
- prefixes |= PREFIX_FWAIT;
- break;
- default:
- return;
- }
- codep++;
- }
-}
-
-static int dflag;
-static int aflag;
-
-static char op1out[100], op2out[100], op3out[100];
-static int start_pc;
-
-/*
- * disassemble the first instruction in 'inbuf'. You have to make
- * sure all of the bytes of the instruction are filled in.
- * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
- * (see topic "Redundant prefixes" in the "Differences from 8086"
- * section of the "Virtual 8086 Mode" chapter.)
- * 'pc' should be the address of this instruction, it will
- * be used to print the target address if this is a relative jump or call
- * 'outbuf' gets filled in with the disassembled instruction. it should
- * be long enough to hold the longest disassembled instruction.
- * 100 bytes is certainly enough, unless symbol printing is added later
- * The function returns the length of this instruction in bytes.
- */
-i386dis (pc, inbuf, outbuf)
- int pc;
- unsigned char *inbuf;
- char *outbuf;
-{
- struct dis386 *dp;
- char *p;
- int i;
- int enter_instruction;
- char *first, *second, *third;
- int needcomma;
-
- obuf[0] = 0;
- op1out[0] = 0;
- op2out[0] = 0;
- op3out[0] = 0;
-
- start_pc = pc;
- start_codep = inbuf;
- codep = inbuf;
-
- ckprefix ();
-
- if (*codep == 0xc8)
- enter_instruction = 1;
- else
- enter_instruction = 0;
-
- obufp = obuf;
-
- if (prefixes & PREFIX_REPZ)
- oappend ("repz ");
- if (prefixes & PREFIX_REPNZ)
- oappend ("repnz ");
- if (prefixes & PREFIX_LOCK)
- oappend ("lock ");
-
- if ((prefixes & PREFIX_FWAIT)
- && ((*codep < 0xd8) || (*codep > 0xdf)))
- {
- /* fwait not followed by floating point instruction */
- oappend ("fwait");
- strcpy (outbuf, obuf);
- return (1);
- }
-
- /* these would be initialized to 0 if disassembling for 8086 or 286 */
- dflag = 1;
- aflag = 1;
-
- if (prefixes & PREFIX_DATA)
- dflag ^= 1;
-
- if (prefixes & PREFIX_ADR)
- {
- aflag ^= 1;
- oappend ("addr16 ");
- }
-
- if (*codep == 0x0f)
- dp = &dis386_twobyte[*++codep];
- else
- dp = &dis386[*codep];
- codep++;
- mod = (*codep >> 6) & 3;
- reg = (*codep >> 3) & 7;
- rm = *codep & 7;
-
- if (dp->name == NULL && dp->bytemode1 == FLOATCODE)
- {
- dofloat ();
- }
- else
- {
- if (dp->name == NULL)
- dp = &grps[dp->bytemode1][reg];
-
- putop (dp->name);
-
- obufp = op1out;
- if (dp->op1)
- (*dp->op1)(dp->bytemode1);
-
- obufp = op2out;
- if (dp->op2)
- (*dp->op2)(dp->bytemode2);
-
- obufp = op3out;
- if (dp->op3)
- (*dp->op3)(dp->bytemode3);
- }
-
- obufp = obuf + strlen (obuf);
- for (i = strlen (obuf); i < 6; i++)
- oappend (" ");
- oappend (" ");
-
- /* enter instruction is printed with operands in the
- * same order as the intel book; everything else
- * is printed in reverse order
- */
- if (enter_instruction)
- {
- first = op1out;
- second = op2out;
- third = op3out;
- }
- else
- {
- first = op3out;
- second = op2out;
- third = op1out;
- }
- needcomma = 0;
- if (*first)
- {
- oappend (first);
- needcomma = 1;
- }
- if (*second)
- {
- if (needcomma)
- oappend (",");
- oappend (second);
- needcomma = 1;
- }
- if (*third)
- {
- if (needcomma)
- oappend (",");
- oappend (third);
- }
- strcpy (outbuf, obuf);
- return (codep - inbuf);
-}
-
-char *float_mem[] = {
- /* d8 */
- "fadds",
- "fmuls",
- "fcoms",
- "fcomps",
- "fsubs",
- "fsubrs",
- "fdivs",
- "fdivrs",
- /* d9 */
- "flds",
- "(bad)",
- "fsts",
- "fstps",
- "fldenv",
- "fldcw",
- "fNstenv",
- "fNstcw",
- /* da */
- "fiaddl",
- "fimull",
- "ficoml",
- "ficompl",
- "fisubl",
- "fisubrl",
- "fidivl",
- "fidivrl",
- /* db */
- "fildl",
- "(bad)",
- "fistl",
- "fistpl",
- "(bad)",
- "fldt",
- "(bad)",
- "fstpt",
- /* dc */
- "faddl",
- "fmull",
- "fcoml",
- "fcompl",
- "fsubl",
- "fsubrl",
- "fdivl",
- "fdivrl",
- /* dd */
- "fldl",
- "(bad)",
- "fstl",
- "fstpl",
- "frstor",
- "(bad)",
- "fNsave",
- "fNstsw",
- /* de */
- "fiadd",
- "fimul",
- "ficom",
- "ficomp",
- "fisub",
- "fisubr",
- "fidiv",
- "fidivr",
- /* df */
- "fild",
- "(bad)",
- "fist",
- "fistp",
- "fbld",
- "fildll",
- "fbstp",
- "fistpll",
-};
-
-#define ST OP_ST, 0
-#define STi OP_STi, 0
-int OP_ST(), OP_STi();
-
-#define FGRPd9_2 NULL, NULL, 0
-#define FGRPd9_4 NULL, NULL, 1
-#define FGRPd9_5 NULL, NULL, 2
-#define FGRPd9_6 NULL, NULL, 3
-#define FGRPd9_7 NULL, NULL, 4
-#define FGRPda_5 NULL, NULL, 5
-#define FGRPdb_4 NULL, NULL, 6
-#define FGRPde_3 NULL, NULL, 7
-#define FGRPdf_4 NULL, NULL, 8
-
-struct dis386 float_reg[][8] = {
- /* d8 */
- {
- { "fadd", ST, STi },
- { "fmul", ST, STi },
- { "fcom", STi },
- { "fcomp", STi },
- { "fsub", ST, STi },
- { "fsubr", ST, STi },
- { "fdiv", ST, STi },
- { "fdivr", ST, STi },
- },
- /* d9 */
- {
- { "fld", STi },
- { "fxch", STi },
- { FGRPd9_2 },
- { "(bad)" },
- { FGRPd9_4 },
- { FGRPd9_5 },
- { FGRPd9_6 },
- { FGRPd9_7 },
- },
- /* da */
- {
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { FGRPda_5 },
- { "(bad)" },
- { "(bad)" },
- },
- /* db */
- {
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { FGRPdb_4 },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- },
- /* dc */
- {
- { "fadd", STi, ST },
- { "fmul", STi, ST },
- { "(bad)" },
- { "(bad)" },
- { "fsub", STi, ST },
- { "fsubr", STi, ST },
- { "fdiv", STi, ST },
- { "fdivr", STi, ST },
- },
- /* dd */
- {
- { "ffree", STi },
- { "(bad)" },
- { "fst", STi },
- { "fstp", STi },
- { "fucom", STi },
- { "fucomp", STi },
- { "(bad)" },
- { "(bad)" },
- },
- /* de */
- {
- { "faddp", STi, ST },
- { "fmulp", STi, ST },
- { "(bad)" },
- { FGRPde_3 },
- { "fsubp", STi, ST },
- { "fsubrp", STi, ST },
- { "fdivp", STi, ST },
- { "fdivrp", STi, ST },
- },
- /* df */
- {
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- { FGRPdf_4 },
- { "(bad)" },
- { "(bad)" },
- { "(bad)" },
- },
-};
-
-
-char *fgrps[][8] = {
- /* d9_2 0 */
- {
- "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
- },
-
- /* d9_4 1 */
- {
- "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
- },
-
- /* d9_5 2 */
- {
- "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
- },
-
- /* d9_6 3 */
- {
- "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
- },
-
- /* d9_7 4 */
- {
- "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
- },
-
- /* da_5 5 */
- {
- "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
- },
-
- /* db_4 6 */
- {
- "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
- "fNsetpm(287 only)","(bad)","(bad)","(bad)",
- },
-
- /* de_3 7 */
- {
- "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
- },
-
- /* df_4 8 */
- {
- "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
- },
-};
-
-
-dofloat ()
-{
- struct dis386 *dp;
- unsigned char floatop;
-
- floatop = codep[-1];
-
- if (mod != 3)
- {
- putop (float_mem[(floatop - 0xd8) * 8 + reg]);
- obufp = op1out;
- OP_E (v_mode);
- return;
- }
- codep++;
-
- dp = &float_reg[floatop - 0xd8][reg];
- if (dp->name == NULL)
- {
- putop (fgrps[dp->bytemode1][rm]);
- /* instruction fnstsw is only one with strange arg */
- if (floatop == 0xdf && *codep == 0xe0)
- strcpy (op1out, "%eax");
- }
- else
- {
- putop (dp->name);
- obufp = op1out;
- if (dp->op1)
- (*dp->op1)(dp->bytemode1);
- obufp = op2out;
- if (dp->op2)
- (*dp->op2)(dp->bytemode2);
- }
-}
-
-/* ARGSUSED */
-OP_ST (ignore)
-{
- oappend ("%st");
-}
-
-/* ARGSUSED */
-OP_STi (ignore)
-{
- sprintf (scratchbuf, "%%st(%d)", rm);
- oappend (scratchbuf);
-}
-
-
-/* capital letters in template are macros */
-putop (template)
- char *template;
-{
- char *p;
-
- for (p = template; *p; p++)
- {
- switch (*p)
- {
- default:
- *obufp++ = *p;
- break;
- case 'C': /* For jcxz/jecxz */
- if (aflag == 0)
- *obufp++ = 'e';
- break;
- case 'N':
- if ((prefixes & PREFIX_FWAIT) == 0)
- *obufp++ = 'n';
- break;
- case 'S':
- /* operand size flag */
- if (dflag)
- *obufp++ = 'l';
- else
- *obufp++ = 'w';
- break;
- }
- }
- *obufp = 0;
-}
-
-oappend (s)
-char *s;
-{
- strcpy (obufp, s);
- obufp += strlen (s);
- *obufp = 0;
-}
-
-append_prefix ()
-{
- if (prefixes & PREFIX_CS)
- oappend ("%cs:");
- if (prefixes & PREFIX_DS)
- oappend ("%ds:");
- if (prefixes & PREFIX_SS)
- oappend ("%ss:");
- if (prefixes & PREFIX_ES)
- oappend ("%es:");
- if (prefixes & PREFIX_FS)
- oappend ("%fs:");
- if (prefixes & PREFIX_GS)
- oappend ("%gs:");
-}
-
-OP_indirE (bytemode)
-{
- oappend ("*");
- OP_E (bytemode);
-}
-
-OP_E (bytemode)
-{
- int disp;
- int havesib;
- int didoutput = 0;
- int base;
- int index;
- int scale;
- int havebase;
-
- /* skip mod/rm byte */
- codep++;
-
- havesib = 0;
- havebase = 0;
- disp = 0;
-
- if (mod == 3)
- {
- switch (bytemode)
- {
- case b_mode:
- oappend (names8[rm]);
- break;
- case w_mode:
- oappend (names16[rm]);
- break;
- case v_mode:
- if (dflag)
- oappend (names32[rm]);
- else
- oappend (names16[rm]);
- break;
- default:
- oappend ("<bad dis table>");
- break;
- }
- return;
- }
-
- append_prefix ();
- if (rm == 4)
- {
- havesib = 1;
- havebase = 1;
- scale = (*codep >> 6) & 3;
- index = (*codep >> 3) & 7;
- base = *codep & 7;
- codep++;
- }
-
- switch (mod)
- {
- case 0:
- switch (rm)
- {
- case 4:
- /* implies havesib and havebase */
- if (base == 5) {
- havebase = 0;
- disp = get32 ();
- }
- break;
- case 5:
- disp = get32 ();
- break;
- default:
- havebase = 1;
- base = rm;
- break;
- }
- break;
- case 1:
- disp = *(char *)codep++;
- if (rm != 4)
- {
- havebase = 1;
- base = rm;
- }
- break;
- case 2:
- disp = get32 ();
- if (rm != 4)
- {
- havebase = 1;
- base = rm;
- }
- break;
- }
-
- if (mod != 0 || rm == 5 || (havesib && base == 5))
- {
- sprintf (scratchbuf, "%d", disp);
- oappend (scratchbuf);
- }
-
- if (havebase || havesib)
- {
- oappend ("(");
- if (havebase)
- oappend (names32[base]);
- if (havesib)
- {
- if (index != 4)
- {
- sprintf (scratchbuf, ",%s", names32[index]);
- oappend (scratchbuf);
- }
- sprintf (scratchbuf, ",%d", 1 << scale);
- oappend (scratchbuf);
- }
- oappend (")");
- }
-}
-
-OP_G (bytemode)
-{
- switch (bytemode)
- {
- case b_mode:
- oappend (names8[reg]);
- break;
- case w_mode:
- oappend (names16[reg]);
- break;
- case d_mode:
- oappend (names32[reg]);
- break;
- case v_mode:
- if (dflag)
- oappend (names32[reg]);
- else
- oappend (names16[reg]);
- break;
- default:
- oappend ("<internal disassembler error>");
- break;
- }
-}
-
-get32 ()
-{
- int x = 0;
-
- x = *codep++ & 0xff;
- x |= (*codep++ & 0xff) << 8;
- x |= (*codep++ & 0xff) << 16;
- x |= (*codep++ & 0xff) << 24;
- return (x);
-}
-
-get16 ()
-{
- int x = 0;
-
- x = *codep++ & 0xff;
- x |= (*codep++ & 0xff) << 8;
- return (x);
-}
-
-OP_REG (code)
-{
- char *s;
-
- switch (code)
- {
- case indir_dx_reg: s = "(%dx)"; break;
- case ax_reg: case cx_reg: case dx_reg: case bx_reg:
- case sp_reg: case bp_reg: case si_reg: case di_reg:
- s = names16[code - ax_reg];
- break;
- case es_reg: case ss_reg: case cs_reg:
- case ds_reg: case fs_reg: case gs_reg:
- s = names_seg[code - es_reg];
- break;
- case al_reg: case ah_reg: case cl_reg: case ch_reg:
- case dl_reg: case dh_reg: case bl_reg: case bh_reg:
- s = names8[code - al_reg];
- break;
- case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
- case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
- if (dflag)
- s = names32[code - eAX_reg];
- else
- s = names16[code - eAX_reg];
- break;
- default:
- s = "<internal disassembler error>";
- break;
- }
- oappend (s);
-}
-
-OP_I (bytemode)
-{
- int op;
-
- switch (bytemode)
- {
- case b_mode:
- op = *codep++ & 0xff;
- break;
- case v_mode:
- if (dflag)
- op = get32 ();
- else
- op = get16 ();
- break;
- case w_mode:
- op = get16 ();
- break;
- default:
- oappend ("<internal disassembler error>");
- return;
- }
- sprintf (scratchbuf, "$0x%x", op);
- oappend (scratchbuf);
-}
-
-OP_sI (bytemode)
-{
- int op;
-
- switch (bytemode)
- {
- case b_mode:
- op = *(char *)codep++;
- break;
- case v_mode:
- if (dflag)
- op = get32 ();
- else
- op = (short)get16();
- break;
- case w_mode:
- op = (short)get16 ();
- break;
- default:
- oappend ("<internal disassembler error>");
- return;
- }
- sprintf (scratchbuf, "$0x%x", op);
- oappend (scratchbuf);
-}
-
-OP_J (bytemode)
-{
- int disp;
- int mask = -1;
-
- switch (bytemode)
- {
- case b_mode:
- disp = *(char *)codep++;
- break;
- case v_mode:
- if (dflag)
- disp = get32 ();
- else
- {
- disp = (short)get16 ();
- /* for some reason, a data16 prefix on a jump instruction
- means that the pc is masked to 16 bits after the
- displacement is added! */
- mask = 0xffff;
- }
- break;
- default:
- oappend ("<internal disassembelr error>");
- return;
- }
-
- sprintf (scratchbuf, "0x%x",
- (start_pc + codep - start_codep + disp) & mask);
- oappend (scratchbuf);
-}
-
-/* ARGSUSED */
-OP_SEG (dummy)
-{
- static char *sreg[] = {
- "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
- };
-
- oappend (sreg[reg]);
-}
-
-OP_DIR (size)
-{
- int seg, offset;
-
- switch (size)
- {
- case lptr:
- if (aflag)
- {
- offset = get32 ();
- seg = get16 ();
- }
- else
- {
- offset = get16 ();
- seg = get16 ();
- }
- sprintf (scratchbuf, "0x%x,0x%x", seg, offset);
- oappend (scratchbuf);
- break;
- case v_mode:
- if (aflag)
- offset = get32 ();
- else
- offset = (short)get16 ();
-
- sprintf (scratchbuf, "0x%x",
- start_pc + codep - start_codep + offset);
- oappend (scratchbuf);
- break;
- default:
- oappend ("<internal disassembler error>");
- break;
- }
-}
-
-/* ARGSUSED */
-OP_OFF (bytemode)
-{
- int off;
-
- if (aflag)
- off = get32 ();
- else
- off = get16 ();
-
- sprintf (scratchbuf, "0x%x", off);
- oappend (scratchbuf);
-}
-
-/* ARGSUSED */
-OP_ESDI (dummy)
-{
- oappend ("%es:(");
- oappend (aflag ? "%edi" : "%di");
- oappend (")");
-}
-
-/* ARGSUSED */
-OP_DSSI (dummy)
-{
- oappend ("%ds:(");
- oappend (aflag ? "%esi" : "%si");
- oappend (")");
-}
-
-/* ARGSUSED */
-OP_ONE (dummy)
-{
- oappend ("1");
-}
-
-/* ARGSUSED */
-OP_C (dummy)
-{
- codep++; /* skip mod/rm */
- sprintf (scratchbuf, "%%cr%d", reg);
- oappend (scratchbuf);
-}
-
-/* ARGSUSED */
-OP_D (dummy)
-{
- codep++; /* skip mod/rm */
- sprintf (scratchbuf, "%%db%d", reg);
- oappend (scratchbuf);
-}
-
-/* ARGSUSED */
-OP_T (dummy)
-{
- codep++; /* skip mod/rm */
- sprintf (scratchbuf, "%%tr%d", reg);
- oappend (scratchbuf);
-}
-
-OP_rm (bytemode)
-{
- switch (bytemode)
- {
- case d_mode:
- oappend (names32[rm]);
- break;
- case w_mode:
- oappend (names16[rm]);
- break;
- }
-}
-
-/* GDB interface */
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-#include "inferior.h"
-
-#define MAXLEN 20
-print_insn (memaddr, stream)
- CORE_ADDR memaddr;
- FILE *stream;
-{
- unsigned char buffer[MAXLEN];
- /* should be expanded if disassembler prints symbol names */
- char outbuf[100];
- int n;
-
- read_memory (memaddr, buffer, MAXLEN);
-
- n = i386dis ((int)memaddr, buffer, outbuf);
-
- fputs (outbuf, stream);
-
- return (n);
-}
-
diff --git a/gnu/usr.bin/gdb/config/i386bsd-dep.c b/gnu/usr.bin/gdb/config/i386bsd-dep.c
deleted file mode 100644
index d298fb0..0000000
--- a/gnu/usr.bin/gdb/config/i386bsd-dep.c
+++ /dev/null
@@ -1,1884 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)i386bsd-dep.c 6.10 (Berkeley) 6/26/91";
-#endif /* not lint */
-
-/* Low level interface to ptrace, for GDB when running on the Intel 386.
- Copyright (C) 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "frame.h"
-#include "inferior.h"
-#include "value.h"
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include <a.out.h>
-
-#ifndef N_SET_MAGIC
-#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val))
-#endif
-
-#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 <sys/stat.h>
-#include <sys/ptrace.h>
-
-#include <machine/reg.h>
-
-#ifdef KERNELDEBUG
-#ifndef NEWVM
-#include <sys/vmmac.h>
-#include <machine/pte.h>
-#else
-#include <sys/proc.h> /* for curproc */
-#endif
-#include <machine/vmparam.h>
-#include <machine/cpu.h>
-#include <ctype.h>
-#include "symtab.h" /* XXX */
-
-#undef vtophys /* XXX */
-
-extern int kernel_debugging;
-
-#define KERNOFF ((unsigned)KERNBASE)
-#ifndef NEWVM
-#define INKERNEL(x) ((x) >= KERNOFF && (x) < KERNOFF + ctob(slr))
-#define INUPAGE(x) \
- ((x) >= KERNEL_U_ADDR && (x) < KERNEL_U_ADDR + NBPG)
-#else
-#define INKERNEL(x) ((x) >= KERNOFF)
-#endif
-
-#define PT_ADDR_ANY ((caddr_t) 1)
-
-/*
- * Convert from sysmap pte index to system virtual address & vice-versa.
- * (why aren't these in one of the system vm macro files???)
- */
-#define smxtob(a) (sbr + (a) * sizeof(pte))
-#define btosmx(b) (((b) - sbr) / sizeof(pte))
-
-static int ok_to_cache();
-static int found_pcb;
-#ifdef NEWVM
-static CORE_ADDR curpcb;
-static CORE_ADDR kstack;
-#endif
-
-static void setregmap();
-
-extern int errno;
-
-/*
- * This function simply calls ptrace with the given arguments. It exists so
- * that all calls to ptrace are isolated in this machine-dependent file.
- */
-int
-call_ptrace(request, pid, arg3, arg4)
- int request;
- pid_t pid;
- caddr_t arg3;
- int arg4;
-{
- return(ptrace(request, pid, arg3, arg4));
-}
-
-kill_inferior()
-{
- if (remote_debugging) {
-#ifdef KERNELDEBUG
- if (kernel_debugging)
- /*
- * It's a very, very bad idea to go away leaving
- * breakpoints in a remote kernel or to leave it
- * stopped at a breakpoint.
- */
- clear_breakpoints();
-#endif
- remote_close(0);
- inferior_died();
- } else if (inferior_pid != 0) {
- ptrace(PT_KILL, inferior_pid, 0, 0);
- wait(0);
- inferior_died();
- }
-}
-
-/*
- * This is used when GDB is exiting. It gives less chance of error.
- */
-kill_inferior_fast()
-{
- if (remote_debugging) {
-#ifdef KERNELDEBUG
- if (kernel_debugging)
- clear_breakpoints();
-#endif
- remote_close(0);
- return;
- }
- if (inferior_pid == 0)
- return;
-
- ptrace(PT_KILL, inferior_pid, 0, 0);
- wait(0);
-}
-
-/*
- * Resume execution of the inferior process. If STEP is nonzero, single-step
- * it. If SIGNAL is nonzero, give it that signal.
- */
-void
-resume(step, signal)
- int step;
- int signal;
-{
- errno = 0;
- if (remote_debugging)
- remote_resume(step, signal);
- else {
- ptrace(step ? PT_STEP : PT_CONTINUE, inferior_pid,
- PT_ADDR_ANY, signal);
- if (errno)
- perror_with_name("ptrace");
- }
-}
-
-#ifdef ATTACH_DETACH
-extern int attach_flag;
-
-/*
- * Start debugging the process whose number is PID.
- */
-attach(pid)
- int pid;
-{
- errno = 0;
- ptrace(PT_ATTACH, pid, 0, 0);
- if (errno)
- perror_with_name("ptrace");
- attach_flag = 1;
- return pid;
-}
-
-/*
- * Stop debugging the process whose number is PID and continue it
- * with signal number SIGNAL. SIGNAL = 0 means just continue it.
- */
-void
-detach(signal)
- int signal;
-{
- errno = 0;
- ptrace(PT_DETACH, inferior_pid, PT_ADDR_ANY, signal);
- if (errno)
- perror_with_name("ptrace");
- attach_flag = 0;
-}
-#endif /* ATTACH_DETACH */
-
-static unsigned int
-get_register_offset()
-{
- unsigned int offset;
- struct user u; /* XXX */
- unsigned int flags = (char *) &u.u_pcb.pcb_flags - (char *) &u;
-
- setregmap(ptrace(PT_READ_U, inferior_pid, (caddr_t)flags, 0));
-
-#ifdef NEWVM
- offset = (char *) &u.u_kproc.kp_proc.p_regs - (char *) &u;
- offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) -
- USRSTACK;
-#else
- offset = (char *) &u.u_ar0 - (char *) &u;
- offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) -
- KERNEL_U_ADDR;
-#endif
-
- return offset;
-}
-
-void
-fetch_inferior_registers()
-{
- register int regno;
- register unsigned int regaddr;
- char buf[MAX_REGISTER_RAW_SIZE];
- register int i;
- unsigned int offset;
-
- if (remote_debugging) {
- extern char registers[];
-
- remote_fetch_registers(registers);
- return;
- }
-
- offset = get_register_offset();
-
- for (regno = 0; regno < NUM_REGS; regno++) {
- regaddr = register_addr(regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) {
- *(int *)&buf[i] = ptrace(PT_READ_U, inferior_pid,
- (caddr_t)regaddr, 0);
- regaddr += sizeof(int);
- }
- supply_register(regno, buf);
- }
-}
-
-/*
- * 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).
- */
-store_inferior_registers(regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[80];
- extern char registers[];
- register int i;
- unsigned int offset;
-
- if (remote_debugging) {
- extern char registers[];
-
- remote_store_registers(registers);
- return;
- }
-
- offset = get_register_offset();
-
- if (regno >= 0) {
- regaddr = register_addr(regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) {
- errno = 0;
- ptrace(PT_WRITE_U, inferior_pid, (caddr_t)regaddr,
- *(int *) &registers[REGISTER_BYTE(regno) + i]);
- if (errno != 0) {
- sprintf(buf, "writing register number %d(%d)",
- regno, i);
- perror_with_name(buf);
- }
- regaddr += sizeof(int);
- }
- } else
- for (regno = 0; regno < NUM_REGS; regno++) {
- regaddr = register_addr(regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE(regno);
- i += sizeof(int)) {
- errno = 0;
- ptrace(PT_WRITE_U, inferior_pid,
- (caddr_t)regaddr,
- *(int *) &registers[REGISTER_BYTE(regno) + i]);
- if (errno != 0) {
- sprintf(buf,
- "writing register number %d(%d)",
- regno, i);
- perror_with_name(buf);
- }
- regaddr += sizeof(int);
- }
- }
-}
-
-/*
- * Copy LEN bytes from inferior's memory starting at MEMADDR to debugger
- * memory starting at MYADDR. On failure (cannot read from inferior, usually
- * because address is out of bounds) returns the value of errno.
- */
-int
-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));
- extern int errno;
-
- if (remote_debugging)
- return (remote_read_inferior_memory(memaddr, myaddr, len));
-
- /* Read all the longwords */
- errno = 0;
- for (i = 0; i < count && errno == 0; i++, addr += sizeof(int))
- buffer[i] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0);
-
- /* Copy appropriate bytes out of the buffer. */
- bcopy((char *) buffer + (memaddr & (sizeof(int) - 1)), myaddr, len);
- return(errno);
-}
-
-/*
- * 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.
- */
- if (remote_debugging)
- return (remote_write_inferior_memory(memaddr, myaddr, len));
-
- /*
- * Fill start and end extra bytes of buffer with existing memory
- * data.
- */
- buffer[0] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0);
-
- if (count > 1)
- buffer[count - 1] = ptrace(PT_READ_I, inferior_pid,
- (caddr_t)addr + (count - 1) * sizeof(int), 0);
-
- /* Copy data to be written over corresponding part of buffer */
-
- bcopy(myaddr, (char *) buffer + (memaddr & (sizeof(int) - 1)), len);
-
- /* Write the entire buffer. */
-
- errno = 0;
- for (i = 0; i < count && errno == 0; i++, addr += sizeof(int))
- ptrace(PT_WRITE_I, inferior_pid, (caddr_t)addr, buffer[i]);
-
- return(errno);
-}
-
-
-/*
- * Work with core dump and executable files, for GDB.
- * This code would be in core.c if it weren't machine-dependent.
- */
-
-#ifndef N_TXTADDR
-#define N_TXTADDR(hdr) 0
-#endif /* no N_TXTADDR */
-
-#ifndef N_DATADDR
-#define N_DATADDR(hdr) hdr.a_text
-#endif /* no N_DATADDR */
-
-/*
- * Make COFF and non-COFF names for things a little more compatible to reduce
- * conditionals later.
- */
-
-#ifndef AOUTHDR
-#define AOUTHDR struct exec
-#endif
-
-extern char *sys_siglist[];
-
-
-/* Hook for `exec_file_command' command to call. */
-
-extern void (*exec_file_display_hook) ();
-
-/* File names of core file and executable file. */
-
-extern char *corefile;
-extern char *execfile;
-
-/* Descriptors on which core file and executable file are open.
- Note that the execchan is closed when an inferior is created
- and reopened if the inferior dies or is killed. */
-
-extern int corechan;
-extern int execchan;
-
-/* Last modification time of executable file.
- Also used in source.c to compare against mtime of a source file. */
-
-extern int exec_mtime;
-
-/* Virtual addresses of bounds of the two areas of memory in the core file. */
-
-extern CORE_ADDR data_start;
-extern CORE_ADDR data_end;
-extern CORE_ADDR stack_start;
-extern CORE_ADDR stack_end;
-
-/* Virtual addresses of bounds of two areas of memory in the exec file.
- Note that the data area in the exec file is used only when there is no core file. */
-
-extern CORE_ADDR text_start;
-extern CORE_ADDR text_end;
-
-extern CORE_ADDR exec_data_start;
-extern CORE_ADDR exec_data_end;
-
-/* Address in executable file of start of text area data. */
-
-extern int text_offset;
-
-/* Address in executable file of start of data area data. */
-
-extern int exec_data_offset;
-
-/* Address in core file of start of data area data. */
-
-extern int data_offset;
-
-/* Address in core file of start of stack area data. */
-
-extern int stack_offset;
-
-/* a.out header saved in core file. */
-
-extern AOUTHDR core_aouthdr;
-
-/* a.out header of exec file. */
-
-extern AOUTHDR exec_aouthdr;
-
-extern void validate_files ();
-
-extern int (*core_file_hook)();
-
-#ifdef KERNELDEBUG
-/*
- * Kernel debugging routines.
- */
-
-#define IOTOP 0x100000 /* XXX should get this from include file */
-#define IOBASE 0xa0000 /* XXX should get this from include file */
-
-static CORE_ADDR file_offset;
-static CORE_ADDR lowram;
-static CORE_ADDR sbr;
-static CORE_ADDR slr;
-static struct pcb pcb;
-
-static CORE_ADDR
-ksym_lookup(name)
- char *name;
-{
- struct symbol *sym;
- int i;
-
- if ((i = lookup_misc_func(name)) < 0)
- error("kernel symbol `%s' not found.", name);
-
- return (misc_function_vector[i].address);
-}
-
-/*
- * return true if 'len' bytes starting at 'addr' can be read out as
- * longwords and/or locally cached (this is mostly for memory mapped
- * i/o register access when debugging remote kernels).
- *
- * XXX the HP code does this differently with NEWVM
- */
-static int
-ok_to_cache(addr, len)
-{
- static CORE_ADDR atdevbase;
-
- if (! atdevbase)
- atdevbase = ksym_lookup("atdevbase");
-
- if (addr >= atdevbase && addr < atdevbase + (IOTOP - IOBASE))
- return (0);
-
- return (1);
-}
-
-static
-physrd(addr, dat, len)
- u_int addr;
- char *dat;
-{
- if (lseek(corechan, addr - file_offset, L_SET) == -1)
- return (-1);
- if (read(corechan, dat, len) != len)
- return (-1);
-
- return (0);
-}
-
-/*
- * When looking at kernel data space through /dev/mem or with a core file, do
- * virtual memory mapping.
- */
-#ifdef NEWVM
-static CORE_ADDR
-vtophys(addr)
- CORE_ADDR addr;
-{
- CORE_ADDR v;
- struct pte 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.
- */
- if (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 = vtophys(ksym_lookup("PTD"));
- current_ptd = PTD;
- } else
- current_ptd = pcb.pcb_ptd;
-
- /*
- * Read the first-level page table (ptd).
- */
- v = current_ptd + ((unsigned)addr >> PD_SHIFT) * sizeof pte;
- if (physrd(v, (char *)&pte, sizeof pte) || pte.pg_v == 0)
- return (~0);
-
- /*
- * Read the second-level page table.
- */
- v = i386_ptob(pte.pg_pfnum) + ((addr&PT_MASK) >> PG_SHIFT) * sizeof pte;
- if (physrd(v, (char *) &pte, sizeof(pte)) || pte.pg_v == 0)
- return (~0);
-
- addr = i386_ptob(pte.pg_pfnum) + (addr & PGOFSET);
-#if 0
- printf("vtophys(%x) -> %x\n", oldaddr, addr);
-#endif
- return (addr);
-}
-#else
-static CORE_ADDR
-vtophys(addr)
- CORE_ADDR addr;
-{
- CORE_ADDR v;
- struct pte pte;
- CORE_ADDR oldaddr = addr;
-
- if (found_pcb == 0 && INUPAGE(addr)) {
- static CORE_ADDR pSwtchmap;
-
- if (pSwtchmap == 0)
- pSwtchmap = vtophys(ksym_lookup("Swtchmap"));
- addr = pSwtchmap;
- } else if (INKERNEL(addr)) {
- /*
- * In system space get system pte. If valid or reclaimable
- * then physical address is combination of its page number
- * and the page offset of the original address.
- */
- addr = smxtob(btop(addr - KERNOFF)) - KERNOFF;
- } else {
- v = btop(addr);
- if (v < pcb.pcb_p0lr)
- addr = (CORE_ADDR) pcb.pcb_p0br +
- v * sizeof (struct pte);
- else if (v >= pcb.pcb_p1lr && v < P1PAGES)
- addr = (CORE_ADDR) pcb.pcb_p0br +
- ((pcb.pcb_szpt * NPTEPG - HIGHPAGES) -
- (BTOPUSRSTACK - v)) * sizeof (struct pte);
- else
- return (~0);
-
- /*
- * For p0/p1 address, user-level page table should be in
- * kernel vm. Do second-level indirect by recursing.
- */
- if (!INKERNEL(addr))
- return (~0);
-
- addr = vtophys(addr);
- }
- /*
- * Addr is now address of the pte of the page we are interested in;
- * get the pte and paste up the physical address.
- */
- if (physrd(addr, (char *) &pte, sizeof(pte)))
- return (~0);
-
- if (pte.pg_v == 0 && (pte.pg_fod || pte.pg_pfnum == 0))
- return (~0);
-
- addr = (CORE_ADDR)ptob(pte.pg_pfnum) + (oldaddr & PGOFSET);
-#if 0
- printf("vtophys(%x) -> %x\n", oldaddr, addr);
-#endif
- return (addr);
-}
-
-#endif
-
-static
-kvread(addr)
- CORE_ADDR addr;
-{
- CORE_ADDR paddr = vtophys(addr);
-
- if (paddr != ~0)
- if (physrd(paddr, (char *)&addr, sizeof(addr)) == 0);
- return (addr);
-
- return (~0);
-}
-
-static void
-read_pcb(uaddr)
- u_int uaddr;
-{
- int i;
- int *pcb_regs = (int *)&pcb;
-
-#ifdef NEWVM
- if (physrd(uaddr, (char *)&pcb, sizeof pcb))
- error("cannot read pcb at %x\n", uaddr);
- printf("current pcb at %x\n", uaddr);
-#else
- if (physrd(uaddr, (char *)&pcb, sizeof pcb))
- error("cannot read pcb at %x\n", uaddr);
- printf("p0br %x p0lr %x p1br %x p1lr %x\n",
- pcb.pcb_p0br, pcb.pcb_p0lr, pcb.pcb_p1br, pcb.pcb_p1lr);
-#endif
-
- /*
- * get the register values out of the sys pcb and
- * store them where `read_register' will find them.
- */
- for (i = 0; i < 8; ++i)
- supply_register(i, &pcb_regs[i+10]);
- supply_register(8, &pcb_regs[8]); /* eip */
- supply_register(9, &pcb_regs[9]); /* eflags */
- for (i = 10; i < 13; ++i) /* cs, ss, ds */
- supply_register(i, &pcb_regs[i+9]);
- supply_register(13, &pcb_regs[18]); /* es */
- for (i = 14; i < 16; ++i) /* fs, gs */
- supply_register(i, &pcb_regs[i+8]);
-
- /* XXX 80387 registers? */
-}
-
-static void
-setup_kernel_debugging()
-{
- struct stat stb;
- int devmem = 0;
- CORE_ADDR addr;
-
- fstat(corechan, &stb);
- if ((stb.st_mode & S_IFMT) == S_IFCHR && stb.st_rdev == makedev(2, 0))
- devmem = 1;
-
-#ifdef NEWVM
- physrd(ksym_lookup("IdlePTD") - KERNOFF, &sbr, sizeof sbr);
- slr = 2 * NPTEPG; /* XXX temporary */
- printf("IdlePTD %x\n", sbr);
- curpcb = ksym_lookup("curpcb") - KERNOFF;
- physrd(curpcb, &curpcb, sizeof curpcb);
- kstack = ksym_lookup("kstack");
-#else
- sbr = ksym_lookup("Sysmap");
- slr = ksym_lookup("Syssize");
- printf("sbr %x slr %x\n", sbr, slr);
-#endif
-
- /*
- * pcb where "panic" saved registers in first thing in current
- * u area.
- */
-#ifndef NEWVM
- read_pcb(vtophys(ksym_lookup("u")));
-#endif
- found_pcb = 1;
- if (!devmem) {
- /* find stack frame */
- CORE_ADDR panicstr;
- char buf[256];
- register char *cp;
-
- panicstr = kvread(ksym_lookup("panicstr"));
- if (panicstr == ~0)
- return;
- (void) kernel_core_file_hook(panicstr, buf, sizeof(buf));
- for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++)
- if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp)))
- *cp = '?';
- if (*cp)
- *cp = '\0';
- printf("panic: %s\n", buf);
- read_pcb(ksym_lookup("dumppcb") - KERNOFF);
- }
-#ifdef NEWVM
- else
- read_pcb(vtophys(kstack));
-#endif
-
- stack_start = USRSTACK;
- stack_end = USRSTACK + ctob(UPAGES);
-}
-
-set_paddr_command(arg)
- char *arg;
-{
- u_int uaddr;
-
- if (!arg)
- error_no_arg("ps-style address for new current process");
- if (!kernel_debugging)
- error("not debugging kernel");
- uaddr = (u_int) parse_and_eval_address(arg);
-#ifndef NEWVM
- read_pcb(ctob(uaddr));
-#else
- /* p_addr is now a pcb virtual address */
- read_pcb(vtophys(uaddr));
- curpcb = uaddr;
-#endif
-
- flush_cached_frames();
- set_current_frame(create_new_frame(read_register(FP_REGNUM), read_pc()));
- select_frame(get_current_frame(), 0);
-}
-
-/*
- * read len bytes from kernel virtual address 'addr' into local
- * buffer 'buf'. Return 0 if read ok, 1 otherwise. On read
- * errors, portion of buffer not read is zeroed.
- */
-kernel_core_file_hook(addr, buf, len)
- CORE_ADDR addr;
- char *buf;
- int len;
-{
- int i;
- CORE_ADDR paddr;
-
- while (len > 0) {
- paddr = vtophys(addr);
- if (paddr == ~0) {
- bzero(buf, len);
- return (1);
- }
- /* we can't read across a page boundary */
- i = min(len, NBPG - (addr & PGOFSET));
- if (physrd(paddr, buf, i)) {
- bzero(buf, len);
- return (1);
- }
- buf += i;
- addr += i;
- len -= i;
- }
- return (0);
-}
-#endif
-
-core_file_command(filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
- extern char registers[];
-#ifdef KERNELDEBUG
- struct stat stb;
-#endif
-
- /*
- * Discard all vestiges of any previous core file and mark data and
- * stack spaces as empty.
- */
- if (corefile)
- free(corefile);
- corefile = 0;
- core_file_hook = 0;
-
- if (corechan >= 0)
- close(corechan);
- corechan = -1;
-
- /* Now, if a new core file was specified, open it and digest it. */
-
- if (filename == 0) {
- if (from_tty)
- printf("No core file now.\n");
- return;
- }
- filename = tilde_expand(filename);
- make_cleanup(free, filename);
- if (have_inferior_p())
- error("To look at a core file, you must kill the inferior with \"kill\".");
- corechan = open(filename, O_RDONLY, 0);
- if (corechan < 0)
- perror_with_name(filename);
-
-#ifdef KERNELDEBUG
- fstat(corechan, &stb);
-
- if (kernel_debugging) {
- setup_kernel_debugging();
- core_file_hook = kernel_core_file_hook;
- } else if ((stb.st_mode & S_IFMT) == S_IFCHR &&
- stb.st_rdev == makedev(2, 1)) {
- /* looking at /dev/kmem */
- data_offset = data_start = KERNOFF;
- data_end = ~0; /* XXX */
- stack_end = stack_start = data_end;
- } else
-#endif
- {
- /*
- * 4.2-style core dump file.
- */
- struct user u;
- unsigned int reg_offset;
-
- val = myread(corechan, &u, sizeof u);
- if (val < 0)
- perror_with_name("Not a core file: reading upage");
- if (val != sizeof u)
- error("Not a core file: could only read %d bytes", val);
-
- /*
- * We are depending on exec_file_command having been
- * called previously to set exec_data_start. Since
- * the executable and the core file share the same
- * text segment, the address of the data segment will
- * be the same in both.
- */
- data_start = exec_data_start;
-
-#ifndef NEWVM
- data_end = data_start + NBPG * u.u_dsize;
- stack_start = stack_end - NBPG * u.u_ssize;
- data_offset = NBPG * UPAGES;
- stack_offset = NBPG * (UPAGES + u.u_dsize);
-
- /*
- * Some machines put an absolute address in here and
- * some put the offset in the upage of the regs.
- */
- reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR;
-#else
- data_end = data_start +
- NBPG * u.u_kproc.kp_eproc.e_vm.vm_dsize;
- stack_start = stack_end -
- NBPG * u.u_kproc.kp_eproc.e_vm.vm_ssize;
- data_offset = NBPG * UPAGES;
- stack_offset = NBPG *
- (UPAGES + u.u_kproc.kp_eproc.e_vm.vm_dsize);
-
- reg_offset = (int) u.u_kproc.kp_proc.p_regs - USRSTACK;
-#endif
-
- setregmap(u.u_pcb.pcb_flags);
-
- /*
- * I don't know where to find this info. So, for now,
- * mark it as not available.
- */
- /* N_SET_MAGIC (core_aouthdr, 0); */
- bzero ((char *) &core_aouthdr, sizeof core_aouthdr);
-
- /*
- * Read the register values out of the core file and
- * store them where `read_register' will find them.
- */
- {
- register int regno;
-
- for (regno = 0; regno < NUM_REGS; regno++) {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- val = lseek(corechan, register_addr(regno, reg_offset), 0);
- if (val < 0
- || (val = myread(corechan, buf, sizeof buf)) < 0) {
- char *buffer = (char *) alloca(strlen(reg_names[regno]) + 30);
- strcpy(buffer, "Reading register ");
- strcat(buffer, reg_names[regno]);
- perror_with_name(buffer);
- }
- supply_register(regno, buf);
- }
- }
- }
-#endif
- if (filename[0] == '/')
- corefile = savestring(filename, strlen(filename));
- else
- corefile = concat(current_directory, "/", filename);
-
- set_current_frame(create_new_frame(read_register(FP_REGNUM),
- read_pc()));
- select_frame(get_current_frame(), 0);
- validate_files();
-}
-
-exec_file_command(filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
-
- /*
- * Eliminate all traces of old exec file. Mark text segment as empty.
- */
-
- if (execfile)
- free(execfile);
- execfile = 0;
- data_start = 0;
- data_end = 0;
- stack_start = 0;
- stack_end = 0;
- text_start = 0;
- text_end = 0;
- exec_data_start = 0;
- exec_data_end = 0;
- if (execchan >= 0)
- close(execchan);
- execchan = -1;
-
- /* Now open and digest the file the user requested, if any. */
-
- if (filename) {
- filename = tilde_expand(filename);
- make_cleanup(free, filename);
-
- execchan = openp(getenv("PATH"), 1, filename, O_RDONLY, 0,
- &execfile);
- if (execchan < 0)
- perror_with_name(filename);
-
- {
- struct stat st_exec;
-
-#ifdef HEADER_SEEK_FD
- HEADER_SEEK_FD(execchan);
-#endif
-
- val = myread(execchan, &exec_aouthdr, sizeof(AOUTHDR));
-
- if (val < 0)
- perror_with_name(filename);
-
-#ifdef KERNELDEBUG
- if (kernel_debugging) {
- /* Gross and disgusting XXX */
- text_start = KERNTEXT_BASE;
- exec_data_start = KERNTEXT_BASE +
- (exec_aouthdr.a_text + 4095) & ~ 4095;
- } else {
-#endif
- text_start = N_TXTADDR(exec_aouthdr);
- exec_data_start = N_DATADDR(exec_aouthdr);
-#ifdef KERNELDEBUG
- }
-#endif
-
- text_offset = N_TXTOFF(exec_aouthdr);
- exec_data_offset = N_TXTOFF(exec_aouthdr) + exec_aouthdr.a_text;
-
- text_end = text_start + exec_aouthdr.a_text;
- exec_data_end = exec_data_start + exec_aouthdr.a_data;
-
- fstat(execchan, &st_exec);
- exec_mtime = st_exec.st_mtime;
- }
-
- validate_files();
- } else if (from_tty)
- printf("No exec file now.\n");
-
- /* Tell display code (if any) about the changed file name. */
- if (exec_file_display_hook)
- (*exec_file_display_hook) (filename);
-}
-
-int dummy_code[] = {
- 0xb8909090, /* nop; nop; nop; movl $0x32323232,%eax */
- 0x32323232,
-#define DUMMY_CALL_INDEX 1
- 0x90ccd0ff, /* call %eax; int3; nop */
-};
-
-/*
- * Build `dummy' call instructions on inferior's stack to cause
- * it to call a subroutine.
- *
- * N.B. - code in wait_for_inferior requires that sp < pc < fp when
- * we take the trap 2 above so it will recognize that we stopped
- * at a `dummy' call. So, after the call sp is *not* decremented
- * to clean the arguments, code & other stuff we lay on the stack.
- * Since the regs are restored to saved values at the breakpoint,
- * sp will get reset correctly. Also, this restore means we don't
- * have to construct frame linkage info to save pc & fp. The lack
- * of frame linkage means we can't do a backtrace, etc., if the
- * called function gets a fault or hits a breakpoint but code in
- * run_stack_dummy makes this impossible anyway.
- */
-CORE_ADDR
-setup_dummy(sp, funaddr, nargs, args, struct_return_bytes, pushfn)
- CORE_ADDR sp;
- CORE_ADDR funaddr;
- int nargs;
- value *args;
- int struct_return_bytes;
- CORE_ADDR (*pushfn)();
-{
- int padding, i;
- CORE_ADDR top = sp, struct_addr, pc;
-
- i = arg_stacklen(nargs, args) + struct_return_bytes
- + sizeof(dummy_code);
- if (i & 3)
- padding = 4 - (i & 3);
- else
- padding = 0;
- pc = sp - sizeof(dummy_code);
- sp = pc - padding - struct_return_bytes;
- struct_addr = sp;
- while (--nargs >= 0)
- sp = (*pushfn)(sp, *args++);
- if (struct_return_bytes)
- STORE_STRUCT_RETURN(struct_addr, sp);
- write_register(SP_REGNUM, sp);
-
- dummy_code[DUMMY_CALL_INDEX] = (int)funaddr;
- write_memory(pc, (char *)dummy_code, sizeof(dummy_code));
-
- return pc;
-}
-
-/* helper functions for m-i386.h */
-
-/* stdio style buffering to minimize calls to ptrace */
-static CORE_ADDR codestream_next_addr;
-static CORE_ADDR codestream_addr;
-static unsigned char codestream_buf[sizeof (int)];
-static int codestream_off;
-static int codestream_cnt;
-
-#define codestream_tell() (codestream_addr + codestream_off)
-#define codestream_peek() (codestream_cnt == 0 ? \
- codestream_fill(1): codestream_buf[codestream_off])
-#define codestream_get() (codestream_cnt-- == 0 ? \
- codestream_fill(0) : codestream_buf[codestream_off++])
-
-static unsigned char
-codestream_fill (peek_flag)
-{
- codestream_addr = codestream_next_addr;
- codestream_next_addr += sizeof (int);
- codestream_off = 0;
- codestream_cnt = sizeof (int);
- read_memory (codestream_addr,
- (unsigned char *)codestream_buf,
- sizeof (int));
-
- if (peek_flag)
- return (codestream_peek());
- else
- return (codestream_get());
-}
-
-static void
-codestream_seek (place)
-{
- codestream_next_addr = place & -sizeof (int);
- codestream_cnt = 0;
- codestream_fill (1);
- while (codestream_tell() != place)
- codestream_get ();
-}
-
-static void
-codestream_read (buf, count)
- unsigned char *buf;
-{
- unsigned char *p;
- int i;
- p = buf;
- for (i = 0; i < count; i++)
- *p++ = codestream_get ();
-}
-
-/* next instruction is a jump, move to target */
-static
-i386_follow_jump ()
-{
- int long_delta;
- short short_delta;
- char byte_delta;
- int data16;
- int pos;
-
- pos = codestream_tell ();
-
- data16 = 0;
- if (codestream_peek () == 0x66)
- {
- codestream_get ();
- data16 = 1;
- }
-
- switch (codestream_get ())
- {
- case 0xe9:
- /* relative jump: if data16 == 0, disp32, else disp16 */
- if (data16)
- {
- codestream_read ((unsigned char *)&short_delta, 2);
- pos += short_delta + 3; /* include size of jmp inst */
- }
- else
- {
- codestream_read ((unsigned char *)&long_delta, 4);
- pos += long_delta + 5;
- }
- break;
- case 0xeb:
- /* relative jump, disp8 (ignore data16) */
- codestream_read ((unsigned char *)&byte_delta, 1);
- pos += byte_delta + 2;
- break;
- }
- codestream_seek (pos + data16);
-}
-
-/*
- * find & return amound a local space allocated, and advance codestream to
- * first register push (if any)
- *
- * if entry sequence doesn't make sense, return -1, and leave
- * codestream pointer random
- */
-static long
-i386_get_frame_setup (pc)
-{
- unsigned char op;
-
- codestream_seek (pc);
-
- i386_follow_jump ();
-
- op = codestream_get ();
-
- if (op == 0x58) /* popl %eax */
- {
- /*
- * this function must start with
- *
- * popl %eax 0x58
- * xchgl %eax, (%esp) 0x87 0x04 0x24
- * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00
- *
- * (the system 5 compiler puts out the second xchg
- * inst, and the assembler doesn't try to optimize it,
- * so the 'sib' form gets generated)
- *
- * this sequence is used to get the address of the return
- * buffer for a function that returns a structure
- */
- int pos;
- unsigned char buf[4];
- static unsigned char proto1[3] = { 0x87,0x04,0x24 };
- static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 };
- pos = codestream_tell ();
- codestream_read (buf, 4);
- if (bcmp (buf, proto1, 3) == 0)
- pos += 3;
- else if (bcmp (buf, proto2, 4) == 0)
- pos += 4;
-
- codestream_seek (pos);
- op = codestream_get (); /* update next opcode */
- }
-
- if (op == 0x55) /* pushl %esp */
- {
- /* check for movl %esp, %ebp - can be written two ways */
- switch (codestream_get ())
- {
- case 0x8b:
- if (codestream_get () != 0xec)
- return (-1);
- break;
- case 0x89:
- if (codestream_get () != 0xe5)
- return (-1);
- break;
- default:
- return (-1);
- }
- /* check for stack adjustment
- *
- * subl $XXX, %esp
- *
- * note: you can't subtract a 16 bit immediate
- * from a 32 bit reg, so we don't have to worry
- * about a data16 prefix
- */
- op = codestream_peek ();
- if (op == 0x83)
- {
- /* subl with 8 bit immed */
- codestream_get ();
- if (codestream_get () != 0xec)
- return (-1);
- /* subl with signed byte immediate
- * (though it wouldn't make sense to be negative)
- */
- return (codestream_get());
- }
- else if (op == 0x81)
- {
- /* subl with 32 bit immed */
- int locals;
- codestream_get();
- if (codestream_get () != 0xec)
- return (-1);
- /* subl with 32 bit immediate */
- codestream_read ((unsigned char *)&locals, 4);
- return (locals);
- }
- else
- {
- return (0);
- }
- }
- else if (op == 0xc8)
- {
- /* enter instruction: arg is 16 bit unsigned immed */
- unsigned short slocals;
- codestream_read ((unsigned char *)&slocals, 2);
- codestream_get (); /* flush final byte of enter instruction */
- return (slocals);
- }
- return (-1);
-}
-
-/* Return number of args passed to a frame.
- Can return -1, meaning no way to tell. */
-
-/* on the 386, the instruction following the call could be:
- * popl %ecx - one arg
- * addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits
- * anything else - zero args
- */
-
-int
-i386_frame_num_args (fi)
- struct frame_info fi;
-{
- int retpc;
- unsigned char op;
- struct frame_info *pfi;
-
- pfi = get_prev_frame_info ((fi));
- if (pfi == 0)
- {
- /* Note: this can happen if we are looking at the frame for
- main, because FRAME_CHAIN_VALID won't let us go into
- start. If we have debugging symbols, that's not really
- a big deal; it just means it will only show as many arguments
- to main as are declared. */
- return -1;
- }
- else
- {
- retpc = pfi->pc;
- op = read_memory_integer (retpc, 1);
- if (op == 0x59)
- /* pop %ecx */
- return 1;
- else if (op == 0x83)
- {
- op = read_memory_integer (retpc+1, 1);
- if (op == 0xc4)
- /* addl $<signed imm 8 bits>, %esp */
- return (read_memory_integer (retpc+2,1)&0xff)/4;
- else
- return 0;
- }
- else if (op == 0x81)
- { /* add with 32 bit immediate */
- op = read_memory_integer (retpc+1, 1);
- if (op == 0xc4)
- /* addl $<imm 32>, %esp */
- return read_memory_integer (retpc+2, 4) / 4;
- else
- return 0;
- }
- else
- {
- return 0;
- }
- }
-}
-
-/*
- * parse the first few instructions of the function to see
- * what registers were stored.
- *
- * We handle these cases:
- *
- * The startup sequence can be at the start of the function,
- * or the function can start with a branch to startup code at the end.
- *
- * %ebp can be set up with either the 'enter' instruction, or
- * 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful,
- * but was once used in the sys5 compiler)
- *
- * Local space is allocated just below the saved %ebp by either the
- * 'enter' instruction, or by 'subl $<size>, %esp'. 'enter' has
- * a 16 bit unsigned argument for space to allocate, and the
- * 'addl' instruction could have either a signed byte, or
- * 32 bit immediate.
- *
- * Next, the registers used by this function are pushed. In
- * the sys5 compiler they will always be in the order: %edi, %esi, %ebx
- * (and sometimes a harmless bug causes it to also save but not restore %eax);
- * however, the code below is willing to see the pushes in any order,
- * and will handle up to 8 of them.
- *
- * If the setup sequence is at the end of the function, then the
- * next instruction will be a branch back to the start.
- */
-
-i386_frame_find_saved_regs (fip, fsrp)
- struct frame_info *fip;
- struct frame_saved_regs *fsrp;
-{
- unsigned long locals;
- unsigned char *p;
- unsigned char op;
- CORE_ADDR dummy_bottom;
- CORE_ADDR adr;
- int i;
-
- bzero (fsrp, sizeof *fsrp);
-
-#if 0
- /* if frame is the end of a dummy, compute where the
- * beginning would be
- */
- dummy_bottom = fip->frame - 4 - NUM_REGS*4 - CALL_DUMMY_LENGTH;
-
- /* check if the PC is in the stack, in a dummy frame */
- if (dummy_bottom <= fip->pc && fip->pc <= fip->frame)
- {
- /* all regs were saved by push_call_dummy () */
- adr = fip->frame - 4;
- for (i = 0; i < NUM_REGS; i++)
- {
- fsrp->regs[i] = adr;
- adr -= 4;
- }
- return;
- }
-#endif
-
- locals = i386_get_frame_setup (get_pc_function_start (fip->pc));
-
- if (locals >= 0)
- {
- adr = fip->frame - 4 - locals;
- for (i = 0; i < 8; i++)
- {
- op = codestream_get ();
- if (op < 0x50 || op > 0x57)
- break;
- fsrp->regs[op - 0x50] = adr;
- adr -= 4;
- }
- }
-
- fsrp->regs[PC_REGNUM] = fip->frame + 4;
- fsrp->regs[FP_REGNUM] = fip->frame;
-}
-
-/* return pc of first real instruction */
-i386_skip_prologue (pc)
-{
- unsigned char op;
- int i;
-
- if (i386_get_frame_setup (pc) < 0)
- return (pc);
-
- /* found valid frame setup - codestream now points to
- * start of push instructions for saving registers
- */
-
- /* skip over register saves */
- for (i = 0; i < 8; i++)
- {
- op = codestream_peek ();
- /* break if not pushl inst */
- if (op < 0x50 || op > 0x57)
- break;
- codestream_get ();
- }
-
- i386_follow_jump ();
-
- return (codestream_tell ());
-}
-
-i386_pop_frame ()
-{
- FRAME frame = get_current_frame ();
- CORE_ADDR fp;
- int regnum;
- struct frame_saved_regs fsr;
- struct frame_info *fi;
-
- fi = get_frame_info (frame);
- fp = fi->frame;
- get_frame_saved_regs (fi, &fsr);
- for (regnum = 0; regnum < NUM_REGS; regnum++)
- {
- CORE_ADDR adr;
- adr = fsr.regs[regnum];
- if (adr)
- write_register (regnum, read_memory_integer (adr, 4));
- }
- write_register (FP_REGNUM, read_memory_integer (fp, 4));
- write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));
- write_register (SP_REGNUM, fp + 8);
- flush_cached_frames ();
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
-}
-
-/* this table must line up with REGISTER_NAMES in m-i386.h */
-/* symbols like 'EAX' come from <sys/reg.h> */
-static int trapmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tES, tES /* lies: no fs or gs */
-};
-static int syscallmap[] =
-{
- sEAX, sECX, sEDX, sEBX,
- sESP, sEBP, sESI, sEDI,
- sEIP, sEFLAGS, sCS, sSS,
- sCS, sCS, sCS, sCS /* lies: no ds, es, fs or gs */
-};
-static int *regmap;
-
-static void
-setregmap(flags)
- int flags;
-{
-#ifdef FM_TRAP
- regmap = flags & FM_TRAP ? trapmap: syscallmap;
-#elif EX_TRAPSTK
- regmap = flags & EX_TRAPSTK ? trapmap : syscallmap;
-#else
- regmap = trapmap; /* the lesser evil */
-#endif
-}
-
-/* blockend is the value of u.u_ar0, and points to the
- * place where GS is stored
- */
-i386_register_u_addr (blockend, regnum)
-{
-#if 0
- /* this will be needed if fp registers are reinstated */
- /* for now, you can look at them with 'info float'
- * sys5 wont let you change them with ptrace anyway
- */
- if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM)
- {
- int ubase, fpstate;
- struct user u;
- ubase = blockend + 4 * (SS + 1) - KSTKSZ;
- fpstate = ubase + ((char *)&u.u_fpstate - (char *)&u);
- return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM));
- }
- else
-#endif
- return (blockend + 4 * regmap[regnum]);
-}
-
-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 */
-}
-
-double_to_i387 (from, to)
- char *from;
- char *to;
-{
- /* push double mode on 387 stack, then pop in extended mode
- * no errors are possible because every 64-bit pattern
- * can be converted to an extended
- */
- asm ("movl 8(%ebp),%eax");
- asm ("fldl (%eax)");
- asm ("fwait");
- asm ("movl 12(%ebp),%eax");
- asm ("fstpt (%eax)");
- asm ("fwait");
-}
-
-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
-print_387_control_word (control)
-unsigned short control;
-{
- printf ("control 0x%04x: ", control);
- printf ("compute to ");
- switch ((control >> 8) & 3)
- {
- case 0: printf ("24 bits; "); break;
- case 1: printf ("(bad); "); break;
- case 2: printf ("53 bits; "); break;
- case 3: printf ("64 bits; "); break;
- }
- printf ("round ");
- switch ((control >> 10) & 3)
- {
- case 0: printf ("NEAREST; "); break;
- case 1: printf ("DOWN; "); break;
- case 2: printf ("UP; "); break;
- case 3: printf ("CHOP; "); break;
- }
- if (control & 0x3f)
- {
- printf ("mask:");
- if (control & 0x0001) printf (" INVALID");
- if (control & 0x0002) printf (" DENORM");
- if (control & 0x0004) printf (" DIVZ");
- if (control & 0x0008) printf (" OVERF");
- if (control & 0x0010) printf (" UNDERF");
- if (control & 0x0020) printf (" LOS");
- printf (";");
- }
- printf ("\n");
- if (control & 0xe080) printf ("warning: reserved bits on 0x%x\n",
- control & 0xe080);
-}
-
-static
-print_387_status_word (status)
- unsigned short status;
-{
- printf ("status 0x%04x: ", status);
- if (status & 0xff)
- {
- printf ("exceptions:");
- if (status & 0x0001) printf (" INVALID");
- if (status & 0x0002) printf (" DENORM");
- if (status & 0x0004) printf (" DIVZ");
- if (status & 0x0008) printf (" OVERF");
- if (status & 0x0010) printf (" UNDERF");
- if (status & 0x0020) printf (" LOS");
- if (status & 0x0040) printf (" FPSTACK");
- printf ("; ");
- }
- printf ("flags: %d%d%d%d; ",
- (status & 0x4000) != 0,
- (status & 0x0400) != 0,
- (status & 0x0200) != 0,
- (status & 0x0100) != 0);
-
- printf ("top %d\n", (status >> 11) & 7);
-}
-
-static
-print_387_status (status, ep)
- unsigned short status;
- struct env387 *ep;
-{
- int i;
- int bothstatus;
- int top;
- int fpreg;
- unsigned char *p;
-
- bothstatus = ((status != 0) && (ep->status != 0));
- if (status != 0)
- {
- if (bothstatus)
- printf ("u: ");
- print_387_status_word (status);
- }
-
- if (ep->status != 0)
- {
- if (bothstatus)
- printf ("e: ");
- print_387_status_word (ep->status);
- }
-
- print_387_control_word (ep->control);
- printf ("last exception: ");
- printf ("opcode 0x%x; ", ep->opcode);
- printf ("pc 0x%x:0x%x; ", ep->code_seg, ep->eip);
- printf ("operand 0x%x:0x%x\n", ep->operand_seg, ep->operand);
-
- top = (ep->status >> 11) & 7;
-
- printf (" regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- int st_regno;
- double val;
-
- /* The physical regno `fpreg' is only relevant as an index into the
- * tag word. Logical `%st' numbers are required for indexing `p->regs.
- */
- st_regno = (fpreg + 8 - top) & 0x7;
-
- printf ("%%st(%d) %s ", st_regno, fpreg == top ? "=>" : " ");
-
- switch ((ep->tag >> (fpreg * 2)) & 3)
- {
- case 0: printf ("valid "); break;
- case 1: printf ("zero "); break;
- case 2: printf ("trap "); break;
- case 3: printf ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf ("%02x", ep->regs[st_regno][i]);
-
- i387_to_double (ep->regs[st_regno], (char *)&val);
- printf (" %g\n", val);
- }
-#if 0 /* reserved fields are always 0xffff on 486's */
- if (ep->r0)
- printf ("warning: reserved0 is 0x%x\n", ep->r0);
- if (ep->r1)
- printf ("warning: reserved1 is 0x%x\n", ep->r1);
- if (ep->r2)
- printf ("warning: reserved2 is 0x%x\n", ep->r2);
- if (ep->r3)
- printf ("warning: reserved3 is 0x%x\n", ep->r3);
-#endif
-}
-
-#ifdef __386BSD__
-#define fpstate save87
-#define U_FPSTATE(u) u.u_pcb.pcb_savefpu
-#endif
-
-#ifndef U_FPSTATE
-#define U_FPSTATE(u) u.u_fpstate
-#endif
-
-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;
-
-#ifndef __386BSD__ /* XXX - look at pcb flags */
- uaddr = (char *)&u.u_fpvalid - (char *)&u;
- if (have_inferior_p())
- {
- unsigned int data;
- unsigned int mask;
-
- rounded_addr = uaddr & -sizeof (int);
- data = ptrace (PT_READ_U, inferior_pid, (caddr_t)rounded_addr, 0);
- mask = 0xff << ((uaddr - rounded_addr) * 8);
-
- fpvalid = ((data & mask) != 0);
- }
- else
- {
- if (lseek (corechan, uaddr, 0) < 0)
- perror ("seek on core file");
- if (myread (corechan, &fpvalid, 1) < 0)
- perror ("read on core file");
-
- }
-
- if (fpvalid == 0)
- {
- printf ("no floating point status saved\n");
- return;
- }
-#endif /* not __386BSD__ */
-
- uaddr = (char *)&U_FPSTATE(u) - (char *)&u;
- if (have_inferior_p ())
- {
- 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);
- }
- }
- else
- {
- if (lseek (corechan, uaddr, 0) < 0)
- perror_with_name ("seek on core file");
- if (myread (corechan, buf, sizeof (struct fpstate)) < 0)
- perror_with_name ("read from core file");
- skip = 0;
- }
-
-#ifdef __386BSD__
- print_387_status (0, (struct env387 *)buf);
-#else
- fpstatep = (struct fpstate *)(buf + skip);
- print_387_status (fpstatep->status, (struct env387 *)fpstatep->state);
-#endif
-}
-
-void
-_initialize_i386bsd_dep()
-{
-#ifdef KERNELDEBUG
- add_com ("process-address", class_obscure, set_paddr_command,
- "The process identified by (ps-style) ADDR becomes the\n\
-\"current\" process context for kernel debugging.");
- add_com_alias ("paddr", "process-address", class_obscure, 0);
-#endif
-}
diff --git a/gnu/usr.bin/gdb/config/m-i386-sv32.h b/gnu/usr.bin/gdb/config/m-i386-sv32.h
deleted file mode 100644
index 38fb4eb..0000000
--- a/gnu/usr.bin/gdb/config/m-i386-sv32.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Macro defintions for i386, running System V 3.2.
- Copyright (C) 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. */
-
-#include "m-i386.h"
-
-/* Apparently there is inconsistency among various System V's about what
- the name of this field is. */
-#define U_FPSTATE(u) u.u_fps.u_fpstate
-
-/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars
- is not. This makes problems for inflow.c. */
-#define TIOCGETC_BROKEN
diff --git a/gnu/usr.bin/gdb/config/m-i386.h b/gnu/usr.bin/gdb/config/m-i386.h
deleted file mode 100644
index 5449ec4..0000000
--- a/gnu/usr.bin/gdb/config/m-i386.h
+++ /dev/null
@@ -1,394 +0,0 @@
-/* Macro defintions for i386.
- 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. */
-
-/* Define the bit, byte, and word ordering of the machine. */
-/* #define BITS_BIG_ENDIAN */
-/* #define BYTES_BIG_ENDIAN */
-/* #define WORDS_BIG_ENDIAN */
-
-/*
- * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu)
- * July 1988
- */
-
-
-#ifndef i386
-#define i386
-#endif
-
-/* I'm running gdb 3.4 under 386/ix 2.0.2, which is a derivative of AT&T's
-Sys V/386 3.2.
-
-On some machines, gdb crashes when it's starting up while calling the
-vendor's termio tgetent() routine. It always works when run under
-itself (actually, under 3.2, it's not an infinitely recursive bug.)
-After some poking around, it appears that depending on the environment
-size, or whether you're running YP, or the phase of the moon or something,
-the stack is not always long-aligned when main() is called, and tgetent()
-takes strong offense at that. On some machines this bug never appears, but
-on those where it does, it occurs quite reliably. */
-#define ALIGN_STACK_ON_STARTUP
-
-/* define USG if you are using sys5 /usr/include's */
-#define USG
-
-/* USG systems need these */
-#define vfork() fork()
-#define MAXPATHLEN 500
-
-/* define this if you don't have the extension to coff that allows
- * file names to appear in the string table
- * (aux.x_file.x_foff)
- */
-#define COFF_NO_LONG_FILE_NAMES
-
-/* turn this on when rest of gdb is ready */
-/* #define IEEE_FLOAT */
-
-#define NBPG NBPC
-#define UPAGES USIZE
-
-#define HAVE_TERMIO
-
-/* Get rid of any system-imposed stack limit if possible. */
-
-/* #define SET_STACK_LIMIT_HUGE not in sys5 */
-
-/* Define this if the C compiler puts an underscore at the front
- of external names before giving them to the linker. */
-
-/* #define NAMES_HAVE_UNDERSCORE */
-
-/* Specify debugger information format. */
-
-/* #define READ_DBX_FORMAT */
-#define COFF_FORMAT
-
-/* number of traps that happen between exec'ing the shell
- * to run an inferior, and when we finally get to
- * the inferior code. This is 2 on most implementations.
- */
-#define START_INFERIOR_TRAPS_EXPECTED 4
-
-/* Offset from address of function to start of its code.
- Zero on most machines. */
-
-#define FUNCTION_START_OFFSET 0
-
-/* Advance PC across any function entry prologue instructions
- to reach some "real" code. */
-
-#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
-
-/* Immediately after a function call, return the saved pc.
- Can't always go through the frames for this because on some machines
- the new frame is not set up until the new function executes
- some instructions. */
-
-#define SAVED_PC_AFTER_CALL(frame) \
- (read_memory_integer (read_register (SP_REGNUM), 4))
-
-/* This is the amount to subtract from u.u_ar0
- to get the offset in the core file of the register values. */
-
-#define KERNEL_U_ADDR 0xe0000000
-
-/* Address of end of stack space. */
-
-#define STACK_END_ADDR 0x80000000
-
-/* Stack grows downward. */
-
-#define INNER_THAN <
-
-/* Sequence of bytes for breakpoint instruction. */
-
-#define BREAKPOINT {0xcc}
-
-/* Amount PC must be decremented by after a breakpoint.
- This is often the number of bytes in BREAKPOINT
- but not always. */
-
-#define DECR_PC_AFTER_BREAK 1
-
-/* Nonzero if instruction at PC is a return instruction. */
-
-#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc3)
-
-/* Return 1 if P points to an invalid floating point value.
- LEN is the length in bytes -- not relevant on the 386. */
-
-#define INVALID_FLOAT(p, len) (0)
-
-/* code to execute to print interesting information about the
- * floating point processor (if any)
- * No need to define if there is nothing to do.
- */
-#define FLOAT_INFO { i386_float_info (); }
-
-
-/* Largest integer type */
-#define LONGEST long
-
-/* Name of the builtin type for the LONGEST type above. */
-#define BUILTIN_TYPE_LONGEST builtin_type_long
-
-/* Say how long (ordinary) registers are. */
-
-#define REGISTER_TYPE long
-
-/* Number of machine registers */
-
-#define NUM_REGS 16
-
-/* Initializer for an array of names of registers.
- There should be NUM_REGS strings in this initializer. */
-
-/* the order of the first 8 registers must match the compiler's
- * numbering scheme (which is the same as the 386 scheme)
- * also, this table must match regmap in i386-pinsn.c.
- */
-#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \
- "esp", "ebp", "esi", "edi", \
- "eip", "ps", "cs", "ss", \
- "ds", "es", "fs", "gs", \
- }
-
-/* Register numbers of various important registers.
- Note that some of these values are "real" register numbers,
- and correspond to the general registers of the machine,
- and some are "phony" register numbers which are too large
- to be actual register numbers as far as the user is concerned
- but do serve to get the desired values when passed to read_register. */
-
-#define FP_REGNUM 5 /* Contains address of executing stack frame */
-#define SP_REGNUM 4 /* Contains address of top of stack */
-
-#define PC_REGNUM 8
-#define PS_REGNUM 9
-
-#define REGISTER_U_ADDR(addr, blockend, regno) \
- (addr) = i386_register_u_addr ((blockend),(regno));
-
-/* Total amount of space needed to store our copies of the machine's
- register state, the array `registers'. */
-#define REGISTER_BYTES (NUM_REGS * 4)
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-
-#define REGISTER_BYTE(N) ((N)*4)
-
-/* Number of bytes of storage in the actual machine representation
- for register N. */
-
-#define REGISTER_RAW_SIZE(N) (4)
-
-/* Number of bytes of storage in the program's representation
- for register N. */
-
-#define REGISTER_VIRTUAL_SIZE(N) (4)
-
-/* Largest value REGISTER_RAW_SIZE can have. */
-
-#define MAX_REGISTER_RAW_SIZE 4
-
-/* Largest value REGISTER_VIRTUAL_SIZE can have. */
-
-#define MAX_REGISTER_VIRTUAL_SIZE 4
-
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) (0)
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
-
-/* Return the GDB type object for the "standard" data type
- of data in register N. */
-
-#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
-
-/* Store the address of the place in which to copy the structure the
- subroutine will return. This is called from call_function. */
-
-#define STORE_STRUCT_RETURN(ADDR, SP) \
- { (SP) -= sizeof (ADDR); \
- write_memory ((SP), &(ADDR), sizeof (ADDR)); }
-
-/* Extract from an array REGBUF containing the (raw) register state
- a function return value of type TYPE, and copy that, in virtual format,
- into VALBUF. */
-
-#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
- bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
-
-/* Write into appropriate registers a function return value
- of type TYPE, given in virtual format. */
-
-#define STORE_RETURN_VALUE(TYPE,VALBUF) \
- write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
-
-/* Extract from an array REGBUF containing the (raw) register state
- the address in which a function should return its structure value,
- as a CORE_ADDR (or an expression that can be used as one). */
-
-#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
-
-
-/* Describe the pointer in each stack frame to the previous stack frame
- (its caller). */
-
-/* FRAME_CHAIN takes a frame's nominal address
- and produces the frame's chain-pointer.
-
- FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
- and produces the nominal address of the caller frame.
-
- However, if FRAME_CHAIN_VALID returns zero,
- it means the given frame is the outermost one and has no caller.
- In that case, FRAME_CHAIN_COMBINE is not used. */
-
-#define FRAME_CHAIN(thisframe) \
- (outside_startup_file ((thisframe)->pc) ? \
- read_memory_integer ((thisframe)->frame, 4) :\
- 0)
-
-#define FRAME_CHAIN_VALID(chain, thisframe) \
- (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
-
-#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
-
-/* Define other aspects of the stack frame. */
-
-/* A macro that tells us whether the function invocation represented
- by FI does not have a frame on the stack associated with it. If it
- does not, FRAMELESS is set to 1, else 0. */
-#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
- FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
-
-#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
-
-#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
-
-#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
-
-/* Return number of args passed to a frame.
- Can return -1, meaning no way to tell. */
-
-#define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi)
-
-/* Return number of bytes at start of arglist that are not really args. */
-
-#define FRAME_ARGS_SKIP 8
-
-/* Put here the code to store, into a struct frame_saved_regs,
- the addresses of the saved registers of frame described by FRAME_INFO.
- This includes special registers such as pc and fp saved in special
- ways in the stack frame. sp is even more special:
- the address we return for it IS the sp for the next frame. */
-
-#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
-{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
-
-
-/* Things needed for making the inferior call functions. */
-
-/* Push an empty stack frame, to record the current PC, etc. */
-
-#define PUSH_DUMMY_FRAME { i386_push_dummy_frame (); }
-
-/* Discard from the stack the innermost frame, restoring all registers. */
-
-#define POP_FRAME { i386_pop_frame (); }
-
-/* this is
- * call 11223344 (32 bit relative)
- * int3
- */
-
-#define CALL_DUMMY { 0x223344e8, 0xcc11 }
-
-#define CALL_DUMMY_LENGTH 8
-
-#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
-
-/* Insert the specified number of args and function address
- into a call sequence of the above form stored at DUMMYNAME. */
-
-#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
-{ \
- int from, to, delta, loc; \
- loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
- from = loc + 5; \
- to = (int)(fun); \
- delta = to - from; \
- *(int *)((char *)(dummyname) + 1) = delta; \
-}
-
-
-#if 0
-/* Interface definitions for kernel debugger KDB. */
-
-/* Map machine fault codes into signal numbers.
- First subtract 0, divide by 4, then index in a table.
- Faults for which the entry in this table is 0
- are not handled by KDB; the program's own trap handler
- gets to handle then. */
-
-#define FAULT_CODE_ORIGIN 0
-#define FAULT_CODE_UNITS 4
-#define FAULT_TABLE \
-{ 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0}
-
-/* Start running with a stack stretching from BEG to END.
- BEG and END should be symbols meaningful to the assembler.
- This is used only for kdb. */
-
-#define INIT_STACK(beg, end) {}
-
-/* Push the frame pointer register on the stack. */
-#define PUSH_FRAME_PTR {}
-
-/* Copy the top-of-stack to the frame pointer register. */
-#define POP_FRAME_PTR {}
-
-/* After KDB is entered by a fault, push all registers
- that GDB thinks about (all NUM_REGS of them),
- so that they appear in order of ascending GDB register number.
- The fault code will be on the stack beyond the last register. */
-
-#define PUSH_REGISTERS {}
-
-/* Assuming the registers (including processor status) have been
- pushed on the stack in order of ascending GDB register number,
- restore them and return to the address in the saved PC register. */
-
-#define POP_REGISTERS {}
-#endif
diff --git a/gnu/usr.bin/gdb/config/m-i386bsd.h b/gnu/usr.bin/gdb/config/m-i386bsd.h
deleted file mode 100644
index 15d97b2..0000000
--- a/gnu/usr.bin/gdb/config/m-i386bsd.h
+++ /dev/null
@@ -1,375 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1991 by William Jolitz at UUNET Technologies, Inc.
- *
- * @(#)m-i386bsd.h 6.7 (Berkeley) 5/8/91
- */
-
-/* Macro definitions for i386.
- 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. */
-
-/* Define the bit, byte, and word ordering of the machine. */
-/* #define BITS_BIG_ENDIAN */
-/* #define BYTES_BIG_ENDIAN */
-/* #define WORDS_BIG_ENDIAN */
-
-/*
- * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu)
- * July 1988
- * [ MODIFIED FOR 386BSD W. Jolitz ]
- */
-
-#ifndef i386
-#define i386 1
-#define i386b 1
-#endif
-
-#define IEEE_FLOAT
-#define LONG_LONG
-
-/* Library stuff: POSIX tty (not supported yet), V7 tty (sigh), vprintf. */
-
-#define HAVE_TERMIOS 1
-#define USE_OLD_TTY 1
-#define HAVE_VPRINTF 1
-
-/* We support local and remote kernel debugging. */
-
-#define KERNELDEBUG 1
-
-/* Get rid of any system-imposed stack limit if possible. */
-
-#define SET_STACK_LIMIT_HUGE
-
-/* Define this if the C compiler puts an underscore at the front
- of external names before giving them to the linker. */
-
-#define NAMES_HAVE_UNDERSCORE
-
-/* Specify debugger information format. */
-
-#define READ_DBX_FORMAT
-
-/* number of traps that happen between exec'ing the shell
- * to run an inferior, and when we finally get to
- * the inferior code. This is 2 on most implementations.
- */
-#define START_INFERIOR_TRAPS_EXPECTED 2
-
-/* Offset from address of function to start of its code.
- Zero on most machines. */
-
-#define FUNCTION_START_OFFSET 0
-
-/* Advance PC across any function entry prologue instructions
- to reach some "real" code. */
-
-#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
-
-/* Immediately after a function call, return the saved pc.
- Can't always go through the frames for this because on some machines
- the new frame is not set up until the new function executes
- some instructions. */
-
-#define SAVED_PC_AFTER_CALL(frame) \
- (read_memory_integer (read_register (SP_REGNUM), 4))
-
-/* This is the amount to subtract from u.u_ar0
- to get the offset in the core file of the register values. */
-
-#ifdef NEWVM
-#include <machine/vmparam.h>
-#define KERNEL_U_ADDR USRSTACK
-#else
-#define KERNEL_U_ADDR 0xfdffd000
-#endif
-
-/* Address of end of stack space. */
-
-#define STACK_END_ADDR KERNEL_U_ADDR
-
-/* Stack grows downward. */
-
-#define INNER_THAN <
-
-/* Sequence of bytes for breakpoint instruction. */
-
-#define BREAKPOINT {0xcc}
-
-/* Amount PC must be decremented by after a breakpoint.
- This is often the number of bytes in BREAKPOINT
- but not always. */
-
-#define DECR_PC_AFTER_BREAK 1
-
-/* Nonzero if instruction at PC is a return instruction. */
-
-#define ABOUT_TO_RETURN(pc) \
- strchr("\302\303\312\313\317", read_memory_integer(pc, 1))
-
-/* Return 1 if P points to an invalid floating point value.
- LEN is the length in bytes -- not relevant on the 386. */
-
-#define INVALID_FLOAT(p, len) (0)
-
-/* code to execute to print interesting information about the
- * floating point processor (if any)
- * No need to define if there is nothing to do.
- */
-#define FLOAT_INFO { i386_float_info (); }
-
-
-/* Largest integer type */
-#define LONGEST long long
-
-/* Name of the builtin type for the LONGEST type above. */
-#define BUILTIN_TYPE_LONGEST builtin_type_long_long
-
-/* Say how long (ordinary) registers are. */
-
-#define REGISTER_TYPE long
-
-/* Number of machine registers */
-
-#define NUM_REGS 16
-
-/* Initializer for an array of names of registers.
- There should be NUM_REGS strings in this initializer. */
-
-/* the order of the first 8 registers must match the compiler's
- * numbering scheme (which is the same as the 386 scheme)
- * also, this table must match regmap in i386-pinsn.c.
- */
-#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \
- "esp", "ebp", "esi", "edi", \
- "eip", "ps", "cs", "ss", \
- "ds", "es", "fs", "gs", \
- }
-
-/* Register numbers of various important registers.
- Note that some of these values are "real" register numbers,
- and correspond to the general registers of the machine,
- and some are "phony" register numbers which are too large
- to be actual register numbers as far as the user is concerned
- but do serve to get the desired values when passed to read_register. */
-
-#define FP_REGNUM 5 /* Contains address of executing stack frame */
-#define SP_REGNUM 4 /* Contains address of top of stack */
-
-#define PC_REGNUM 8
-#define PS_REGNUM 9
-
-#define REGISTER_U_ADDR(addr, blockend, regno) \
- (addr) = i386_register_u_addr ((blockend),(regno));
-
-/* Total amount of space needed to store our copies of the machine's
- register state, the array `registers'. */
-#define REGISTER_BYTES (NUM_REGS * 4)
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-
-#define REGISTER_BYTE(N) ((N)*4)
-
-/* Number of bytes of storage in the actual machine representation
- for register N. */
-
-#define REGISTER_RAW_SIZE(N) (4)
-
-/* Number of bytes of storage in the program's representation
- for register N. */
-
-#define REGISTER_VIRTUAL_SIZE(N) (4)
-
-/* Largest value REGISTER_RAW_SIZE can have. */
-
-#define MAX_REGISTER_RAW_SIZE 4
-
-/* Largest value REGISTER_VIRTUAL_SIZE can have. */
-
-#define MAX_REGISTER_VIRTUAL_SIZE 4
-
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#define REGISTER_CONVERTIBLE(N) (0)
-
-/* Convert data from raw format for register REGNUM
- to virtual format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
-
-/* Convert data from virtual format for register REGNUM
- to raw format for register REGNUM. */
-
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
-
-/* Return the GDB type object for the "standard" data type
- of data in register N. */
-
-#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
-
-/* Store the address of the place in which to copy the structure the
- subroutine will return. This is called from call_function. */
-
-#define STORE_STRUCT_RETURN(ADDR, SP) \
- { (SP) -= sizeof (ADDR); \
- write_memory ((SP), &(ADDR), sizeof (ADDR)); }
-
-/* Extract from an array REGBUF containing the (raw) register state
- a function return value of type TYPE, and copy that, in virtual format,
- into VALBUF. */
-
-#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
- bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
-
-/* Write into appropriate registers a function return value
- of type TYPE, given in virtual format. */
-
-#define STORE_RETURN_VALUE(TYPE,VALBUF) \
- write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
-
-/* Extract from an array REGBUF containing the (raw) register state
- the address in which a function should return its structure value,
- as a CORE_ADDR (or an expression that can be used as one). */
-
-#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
-
-
-/* Describe the pointer in each stack frame to the previous stack frame
- (its caller). */
-
-/* FRAME_CHAIN takes a frame's nominal address
- and produces the frame's chain-pointer.
-
- FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
- and produces the nominal address of the caller frame.
-
- However, if FRAME_CHAIN_VALID returns zero,
- it means the given frame is the outermost one and has no caller.
- In that case, FRAME_CHAIN_COMBINE is not used. */
-
-#define FRAME_CHAIN(thisframe) \
- (outside_startup_file ((thisframe)->pc) ? \
- read_memory_integer ((thisframe)->frame, 4) :\
- 0)
-
-#ifdef KERNELDEBUG
-#define KERNTEXT_BASE 0xfe000000
-#ifdef NEWVM
-#define KERNSTACK_TOP (read_register(SP_REGNUM) + 0x2000) /* approximate */
-#else
-/* #define KERNSTACK_TOP (P1PAGES << PGSHIFT) */
-#define KERNSTACK_TOP 0xfe000000
-#endif
-extern int kernel_debugging;
-#define FRAME_CHAIN_VALID(chain, thisframe) \
- (chain != 0 && \
- !kernel_debugging ? outside_startup_file(FRAME_SAVED_PC(thisframe)) :\
- (chain >= read_register(SP_REGNUM) && chain < KERNSTACK_TOP))
-#else
-#define FRAME_CHAIN_VALID(chain, thisframe) \
- (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
-#endif
-
-#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
-
-/* Define other aspects of the stack frame. */
-
-/* A macro that tells us whether the function invocation represented
- by FI does not have a frame on the stack associated with it. If it
- does not, FRAMELESS is set to 1, else 0. */
-#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
- FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
-
-#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
-
-#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
-
-#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
-
-/* Return number of args passed to a frame.
- Can return -1, meaning no way to tell. */
-
-#define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi)
-
-/* Return number of bytes at start of arglist that are not really args. */
-
-#define FRAME_ARGS_SKIP 8
-
-/* Put here the code to store, into a struct frame_saved_regs,
- the addresses of the saved registers of frame described by FRAME_INFO.
- This includes special registers such as pc and fp saved in special
- ways in the stack frame. sp is even more special:
- the address we return for it IS the sp for the next frame. */
-
-#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
-{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
-
-
-/* Discard from the stack the innermost frame, restoring all registers. */
-
-#define POP_FRAME { i386_pop_frame (); }
-
-#define NEW_CALL_FUNCTION
-
-#if 0
-/* Interface definitions for kernel debugger KDB. */
-
-/* Map machine fault codes into signal numbers.
- First subtract 0, divide by 4, then index in a table.
- Faults for which the entry in this table is 0
- are not handled by KDB; the program's own trap handler
- gets to handle then. */
-
-#define FAULT_CODE_ORIGIN 0
-#define FAULT_CODE_UNITS 4
-#define FAULT_TABLE \
-{ 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0}
-
-/* Start running with a stack stretching from BEG to END.
- BEG and END should be symbols meaningful to the assembler.
- This is used only for kdb. */
-
-#define INIT_STACK(beg, end) {}
-
-/* Push the frame pointer register on the stack. */
-#define PUSH_FRAME_PTR {}
-
-/* Copy the top-of-stack to the frame pointer register. */
-#define POP_FRAME_PTR {}
-
-/* After KDB is entered by a fault, push all registers
- that GDB thinks about (all NUM_REGS of them),
- so that they appear in order of ascending GDB register number.
- The fault code will be on the stack beyond the last register. */
-
-#define PUSH_REGISTERS {}
-
-/* Assuming the registers (including processor status) have been
- pushed on the stack in order of ascending GDB register number,
- restore them and return to the address in the saved PC register. */
-
-#define POP_REGISTERS {}
-#endif
diff --git a/gnu/usr.bin/gdb/config/m-i386g-sv32.h b/gnu/usr.bin/gdb/config/m-i386g-sv32.h
deleted file mode 100644
index 3d69eea..0000000
--- a/gnu/usr.bin/gdb/config/m-i386g-sv32.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Macro defintions for i386, running System V 3.2.
- Copyright (C) 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. */
-
-#include "m-i386gas.h"
-
-/* Apparently there is inconsistency among various System V's about what
- the name of this field is. */
-#define U_FPSTATE(u) u.u_fps.u_fpstate
-
-/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars
- is not. This makes problems for inflow.c. */
-#define TIOCGETC_BROKEN
diff --git a/gnu/usr.bin/gdb/config/m-i386gas.h b/gnu/usr.bin/gdb/config/m-i386gas.h
deleted file mode 100644
index fbd2138..0000000
--- a/gnu/usr.bin/gdb/config/m-i386gas.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Macro definitions for i386 using the GNU object file format.
- 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. */
-
-/*
- * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu)
- * July 1988
- *
- * i386gnu: COFF_ENCAPSULATE
- */
-
-
-#define COFF_ENCAPSULATE
-
-#include "m-i386.h"
-
-
-#define NAMES_HAVE_UNDERSCORE
-
-#undef COFF_FORMAT
-#define READ_DBX_FORMAT
-
diff --git a/gnu/usr.bin/gdb/copying.c b/gnu/usr.bin/gdb/copying.c
deleted file mode 100644
index b3d7519..0000000
--- a/gnu/usr.bin/gdb/copying.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/* Do not modify this file; it is created automatically
- by copying.awk. */
-extern int immediate_quit;
-static void
-copying_info ()
-{
- immediate_quit++;
- printf_filtered ("\n");
- printf_filtered (" GNU GENERAL PUBLIC LICENSE\n");
- printf_filtered (" Version 1, February 1989\n");
- printf_filtered ("\n");
- printf_filtered (" Copyright (C) 1989 Free Software Foundation, Inc.\n");
- printf_filtered (" 675 Mass Ave, Cambridge, MA 02139, USA\n");
- printf_filtered (" Everyone is permitted to copy and distribute verbatim copies\n");
- printf_filtered (" of this license document, but changing it is not allowed.\n");
- printf_filtered ("\n");
- printf_filtered (" Preamble\n");
- printf_filtered ("\n");
- printf_filtered (" The license agreements of most software companies try to keep users\n");
- printf_filtered ("at the mercy of those companies. By contrast, our General Public\n");
- printf_filtered ("License is intended to guarantee your freedom to share and change free\n");
- printf_filtered ("software--to make sure the software is free for all its users. The\n");
- printf_filtered ("General Public License applies to the Free Software Foundation's\n");
- printf_filtered ("software and to any other program whose authors commit to using it.\n");
- printf_filtered ("You can use it for your programs, too.\n");
- printf_filtered ("\n");
- printf_filtered (" When we speak of free software, we are referring to freedom, not\n");
- printf_filtered ("price. Specifically, the General Public License is designed to make\n");
- printf_filtered ("sure that you have the freedom to give away or sell copies of free\n");
- printf_filtered ("software, that you receive source code or can get it if you want it,\n");
- printf_filtered ("that you can change the software or use pieces of it in new free\n");
- printf_filtered ("programs; and that you know you can do these things.\n");
- printf_filtered ("\n");
- printf_filtered (" To protect your rights, we need to make restrictions that forbid\n");
- printf_filtered ("anyone to deny you these rights or to ask you to surrender the rights.\n");
- printf_filtered ("These restrictions translate to certain responsibilities for you if you\n");
- printf_filtered ("distribute copies of the software, or if you modify it.\n");
- printf_filtered ("\n");
- printf_filtered (" For example, if you distribute copies of a such a program, whether\n");
- printf_filtered ("gratis or for a fee, you must give the recipients all the rights that\n");
- printf_filtered ("you have. You must make sure that they, too, receive or can get the\n");
- printf_filtered ("source code. And you must tell them their rights.\n");
- printf_filtered ("\n");
- printf_filtered (" We protect your rights with two steps: (1) copyright the software, and\n");
- printf_filtered ("(2) offer you this license which gives you legal permission to copy,\n");
- printf_filtered ("distribute and/or modify the software.\n");
- printf_filtered ("\n");
- printf_filtered (" Also, for each author's protection and ours, we want to make certain\n");
- printf_filtered ("that everyone understands that there is no warranty for this free\n");
- printf_filtered ("software. If the software is modified by someone else and passed on, we\n");
- printf_filtered ("want its recipients to know that what they have is not the original, so\n");
- printf_filtered ("that any problems introduced by others will not reflect on the original\n");
- printf_filtered ("authors' reputations.\n");
- printf_filtered ("\n");
- printf_filtered (" The precise terms and conditions for copying, distribution and\n");
- printf_filtered ("modification follow.\n");
- printf_filtered (" \n");
- printf_filtered (" GNU GENERAL PUBLIC LICENSE\n");
- printf_filtered (" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n");
- printf_filtered ("\n");
- printf_filtered (" 0. This License Agreement applies to any program or other work which\n");
- printf_filtered ("contains a notice placed by the copyright holder saying it may be\n");
- printf_filtered ("distributed under the terms of this General Public License. The\n");
- printf_filtered ("\"Program\", below, refers to any such program or work, and a \"work based\n");
- printf_filtered ("on the Program\" means either the Program or any work containing the\n");
- printf_filtered ("Program or a portion of it, either verbatim or with modifications. Each\n");
- printf_filtered ("licensee is addressed as \"you\".\n");
- printf_filtered ("\n");
- printf_filtered (" 1. You may copy and distribute verbatim copies of the Program's source\n");
- printf_filtered ("code as you receive it, in any medium, provided that you conspicuously and\n");
- printf_filtered ("appropriately publish on each copy an appropriate copyright notice and\n");
- printf_filtered ("disclaimer of warranty; keep intact all the notices that refer to this\n");
- printf_filtered ("General Public License and to the absence of any warranty; and give any\n");
- printf_filtered ("other recipients of the Program a copy of this General Public License\n");
- printf_filtered ("along with the Program. You may charge a fee for the physical act of\n");
- printf_filtered ("transferring a copy.\n");
- printf_filtered ("\n");
- printf_filtered (" 2. You may modify your copy or copies of the Program or any portion of\n");
- printf_filtered ("it, and copy and distribute such modifications under the terms of Paragraph\n");
- printf_filtered ("1 above, provided that you also do the following:\n");
- printf_filtered ("\n");
- printf_filtered (" a) cause the modified files to carry prominent notices stating that\n");
- printf_filtered (" you changed the files and the date of any change; and\n");
- printf_filtered ("\n");
- printf_filtered (" b) cause the whole of any work that you distribute or publish, that\n");
- printf_filtered (" in whole or in part contains the Program or any part thereof, either\n");
- printf_filtered (" with or without modifications, to be licensed at no charge to all\n");
- printf_filtered (" third parties under the terms of this General Public License (except\n");
- printf_filtered (" that you may choose to grant warranty protection to some or all\n");
- printf_filtered (" third parties, at your option).\n");
- printf_filtered ("\n");
- printf_filtered (" c) If the modified program normally reads commands interactively when\n");
- printf_filtered (" run, you must cause it, when started running for such interactive use\n");
- printf_filtered (" in the simplest and most usual way, to print or display an\n");
- printf_filtered (" announcement including an appropriate copyright notice and a notice\n");
- printf_filtered (" that there is no warranty (or else, saying that you provide a\n");
- printf_filtered (" warranty) and that users may redistribute the program under these\n");
- printf_filtered (" conditions, and telling the user how to view a copy of this General\n");
- printf_filtered (" Public License.\n");
- printf_filtered ("\n");
- printf_filtered (" d) You may charge a fee for the physical act of transferring a\n");
- printf_filtered (" copy, and you may at your option offer warranty protection in\n");
- printf_filtered (" exchange for a fee.\n");
- printf_filtered ("\n");
- printf_filtered ("Mere aggregation of another independent work with the Program (or its\n");
- printf_filtered ("derivative) on a volume of a storage or distribution medium does not bring\n");
- printf_filtered ("the other work under the scope of these terms.\n");
- printf_filtered (" \n");
- printf_filtered (" 3. You may copy and distribute the Program (or a portion or derivative of\n");
- printf_filtered ("it, under Paragraph 2) in object code or executable form under the terms of\n");
- printf_filtered ("Paragraphs 1 and 2 above provided that you also do one of the following:\n");
- printf_filtered ("\n");
- printf_filtered (" a) accompany it with the complete corresponding machine-readable\n");
- printf_filtered (" source code, which must be distributed under the terms of\n");
- printf_filtered (" Paragraphs 1 and 2 above; or,\n");
- printf_filtered ("\n");
- printf_filtered (" b) accompany it with a written offer, valid for at least three\n");
- printf_filtered (" years, to give any third party free (except for a nominal charge\n");
- printf_filtered (" for the cost of distribution) a complete machine-readable copy of the\n");
- printf_filtered (" corresponding source code, to be distributed under the terms of\n");
- printf_filtered (" Paragraphs 1 and 2 above; or,\n");
- printf_filtered ("\n");
- printf_filtered (" c) accompany it with the information you received as to where the\n");
- printf_filtered (" corresponding source code may be obtained. (This alternative is\n");
- printf_filtered (" allowed only for noncommercial distribution and only if you\n");
- printf_filtered (" received the program in object code or executable form alone.)\n");
- printf_filtered ("\n");
- printf_filtered ("Source code for a work means the preferred form of the work for making\n");
- printf_filtered ("modifications to it. For an executable file, complete source code means\n");
- printf_filtered ("all the source code for all modules it contains; but, as a special\n");
- printf_filtered ("exception, it need not include source code for modules which are standard\n");
- printf_filtered ("libraries that accompany the operating system on which the executable\n");
- printf_filtered ("file runs, or for standard header files or definitions files that\n");
- printf_filtered ("accompany that operating system.\n");
- printf_filtered ("\n");
- printf_filtered (" 4. You may not copy, modify, sublicense, distribute or transfer the\n");
- printf_filtered ("Program except as expressly provided under this General Public License.\n");
- printf_filtered ("Any attempt otherwise to copy, modify, sublicense, distribute or transfer\n");
- printf_filtered ("the Program is void, and will automatically terminate your rights to use\n");
- printf_filtered ("the Program under this License. However, parties who have received\n");
- printf_filtered ("copies, or rights to use copies, from you under this General Public\n");
- printf_filtered ("License will not have their licenses terminated so long as such parties\n");
- printf_filtered ("remain in full compliance.\n");
- printf_filtered ("\n");
- printf_filtered (" 5. By copying, distributing or modifying the Program (or any work based\n");
- printf_filtered ("on the Program) you indicate your acceptance of this license to do so,\n");
- printf_filtered ("and all its terms and conditions.\n");
- printf_filtered ("\n");
- printf_filtered (" 6. Each time you redistribute the Program (or any work based on the\n");
- printf_filtered ("Program), the recipient automatically receives a license from the original\n");
- printf_filtered ("licensor to copy, distribute or modify the Program subject to these\n");
- printf_filtered ("terms and conditions. You may not impose any further restrictions on the\n");
- printf_filtered ("recipients' exercise of the rights granted herein.\n");
- printf_filtered (" \n");
- printf_filtered (" 7. The Free Software Foundation may publish revised and/or new versions\n");
- printf_filtered ("of the General Public License from time to time. Such new versions will\n");
- printf_filtered ("be similar in spirit to the present version, but may differ in detail to\n");
- printf_filtered ("address new problems or concerns.\n");
- printf_filtered ("\n");
- printf_filtered ("Each version is given a distinguishing version number. If the Program\n");
- printf_filtered ("specifies a version number of the license which applies to it and \"any\n");
- printf_filtered ("later version\", you have the option of following the terms and conditions\n");
- printf_filtered ("either of that version or of any later version published by the Free\n");
- printf_filtered ("Software Foundation. If the Program does not specify a version number of\n");
- printf_filtered ("the license, you may choose any version ever published by the Free Software\n");
- printf_filtered ("Foundation.\n");
- printf_filtered ("\n");
- printf_filtered (" 8. If you wish to incorporate parts of the Program into other free\n");
- printf_filtered ("programs whose distribution conditions are different, write to the author\n");
- printf_filtered ("to ask for permission. For software which is copyrighted by the Free\n");
- printf_filtered ("Software Foundation, write to the Free Software Foundation; we sometimes\n");
- printf_filtered ("make exceptions for this. Our decision will be guided by the two goals\n");
- printf_filtered ("of preserving the free status of all derivatives of our free software and\n");
- printf_filtered ("of promoting the sharing and reuse of software generally.\n");
- printf_filtered ("\n");
- immediate_quit--;
-}
-
-static void
-warranty_info ()
-{
- immediate_quit++;
- printf_filtered (" NO WARRANTY\n");
- printf_filtered ("\n");
- printf_filtered (" 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n");
- printf_filtered ("FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n");
- printf_filtered ("OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n");
- printf_filtered ("PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n");
- printf_filtered ("OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n");
- printf_filtered ("MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n");
- printf_filtered ("TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n");
- printf_filtered ("PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n");
- printf_filtered ("REPAIR OR CORRECTION.\n");
- printf_filtered ("\n");
- printf_filtered (" 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n");
- printf_filtered ("WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n");
- printf_filtered ("REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n");
- printf_filtered ("INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n");
- printf_filtered ("OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n");
- printf_filtered ("TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n");
- printf_filtered ("YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n");
- printf_filtered ("PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n");
- printf_filtered ("POSSIBILITY OF SUCH DAMAGES.\n");
- printf_filtered ("\n");
- immediate_quit--;
-}
-
-void
-_initialize_copying ()
-{
- add_info ("copying", copying_info,
- "Conditions for redistributing copies of GDB.");
- add_info ("warranty", warranty_info,
- "Various kinds of warranty you do not have.");
-}
diff --git a/gnu/usr.bin/gdb/core.c b/gnu/usr.bin/gdb/core.c
deleted file mode 100644
index 307addb..0000000
--- a/gnu/usr.bin/gdb/core.c
+++ /dev/null
@@ -1,581 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)core.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Work with core dump and executable files, for GDB.
- 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "frame.h" /* required by inferior.h */
-#include "inferior.h"
-
-#ifdef USG
-#include <sys/types.h>
-#include <fcntl.h>
-#endif
-
-#ifdef COFF_ENCAPSULATE
-#include "a.out.encap.h"
-#else
-#include <a.out.h>
-#endif
-#ifndef N_MAGIC
-#ifdef COFF_FORMAT
-#define N_MAGIC(exec) ((exec).magic)
-#else
-#define N_MAGIC(exec) ((exec).a_magic)
-#endif
-#endif
-#include <signal.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-
-#ifdef UMAX_CORE
-#include <sys/ptrace.h>
-#else
-#include <sys/user.h>
-#endif
-
-#ifndef N_TXTADDR
-#define N_TXTADDR(hdr) 0
-#endif /* no N_TXTADDR */
-
-#ifndef N_DATADDR
-#define N_DATADDR(hdr) hdr.a_text
-#endif /* no N_DATADDR */
-
-#ifndef COFF_FORMAT
-#ifndef AOUTHDR
-#define AOUTHDR struct exec
-#endif
-#endif
-
-extern char *sys_siglist[];
-
-extern core_file_command (), exec_file_command ();
-
-/* Hook for `exec_file_command' command to call. */
-
-void (*exec_file_display_hook) ();
-
-/* File names of core file and executable file. */
-
-char *corefile;
-char *execfile;
-
-/* Descriptors on which core file and executable file are open.
- Note that the execchan is closed when an inferior is created
- and reopened if the inferior dies or is killed. */
-
-int corechan;
-int execchan;
-
-/* Last modification time of executable file.
- Also used in source.c to compare against mtime of a source file. */
-
-int exec_mtime;
-
-/* Virtual addresses of bounds of the two areas of memory in the core file. */
-
-CORE_ADDR data_start;
-CORE_ADDR data_end;
-CORE_ADDR stack_start;
-CORE_ADDR stack_end;
-
-#if defined (REG_STACK_SEGMENT)
-/* Start and end of the register stack segment. */
-CORE_ADDR reg_stack_start;
-CORE_ADDR reg_stack_end;
-#endif /* REG_STACK_SEGMENT */
-
-/* Virtual addresses of bounds of two areas of memory in the exec file.
- Note that the data area in the exec file is used only when there is no core file. */
-
-CORE_ADDR text_start;
-CORE_ADDR text_end;
-
-CORE_ADDR exec_data_start;
-CORE_ADDR exec_data_end;
-
-/* Offset within executable file of start of text area data. */
-
-int text_offset;
-
-/* Offset within executable file of start of data area data. */
-
-int exec_data_offset;
-
-/* Offset within core file of start of data area data. */
-
-int data_offset;
-
-/* Offset within core file of start of stack area data. */
-
-int stack_offset;
-
-#ifdef COFF_FORMAT
-/* various coff data structures */
-
-FILHDR file_hdr;
-SCNHDR text_hdr;
-SCNHDR data_hdr;
-
-#endif /* not COFF_FORMAT */
-
-/* a.out header saved in core file. */
-
-AOUTHDR core_aouthdr;
-
-/* a.out header of exec file. */
-
-AOUTHDR exec_aouthdr;
-
-void validate_files ();
-unsigned int register_addr ();
-
-/* Call this to specify the hook for exec_file_command to call back.
- This is called from the x-window display code. */
-
-void
-specify_exec_file_hook (hook)
- void (*hook) ();
-{
- exec_file_display_hook = hook;
-}
-
-/* The exec file must be closed before running an inferior.
- If it is needed again after the inferior dies, it must
- be reopened. */
-
-void
-close_exec_file ()
-{
- if (execchan >= 0)
- close (execchan);
- execchan = -1;
-}
-
-void
-reopen_exec_file ()
-{
- if (execchan < 0 && execfile != 0)
- {
- char *filename = concat (execfile, "", "");
- exec_file_command (filename, 0);
- free (filename);
- }
-}
-
-/* If we have both a core file and an exec file,
- print a warning if they don't go together.
- This should really check that the core file came
- from that exec file, but I don't know how to do it. */
-
-void
-validate_files ()
-{
- if (execfile != 0 && corefile != 0)
- {
- struct stat st_core;
-
- if (fstat (corechan, &st_core) < 0)
- /* It might be a good idea to print an error message.
- On the other hand, if the user tries to *do* anything with
- the core file, (s)he'll find out soon enough. */
- return;
-
- if (N_MAGIC (core_aouthdr) != 0
- && bcmp (&core_aouthdr, &exec_aouthdr, sizeof core_aouthdr))
- printf ("Warning: core file does not match specified executable file.\n");
- else if (exec_mtime > st_core.st_mtime) {
-#ifdef KERNELDEBUG
- extern int kernel_debugging;
- if (!kernel_debugging)
-#endif
- printf ("Warning: exec file is newer than core file.\n");
- }
- }
-}
-
-/* Return the name of the executable file as a string.
- ERR nonzero means get error if there is none specified;
- otherwise return 0 in that case. */
-
-char *
-get_exec_file (err)
- int err;
-{
- if (err && execfile == 0)
- error ("No executable file specified.\n\
-Use the \"exec-file\" and \"symbol-file\" commands.");
- return execfile;
-}
-
-int
-have_core_file_p ()
-{
- return corefile != 0;
-}
-
-static void
-files_info ()
-{
- char *symfile;
- extern char *get_sym_file ();
-
- if (execfile)
- printf ("Executable file \"%s\".\n", execfile);
- else
- printf ("No executable file\n");
- if (corefile == 0)
- printf ("No core dump file\n");
- else
- printf ("Core dump file \"%s\".\n", corefile);
-
- if (have_inferior_p ())
- printf ("Using the running image of the program, rather than these files.\n");
-
- symfile = get_sym_file ();
- if (symfile != 0)
- printf ("Symbols from \"%s\".\n", symfile);
-
-#ifdef FILES_INFO_HOOK
- if (FILES_INFO_HOOK ())
- return;
-#endif
-
- if (! have_inferior_p ())
- {
- if (execfile)
- {
- printf ("Text segment in executable from 0x%x to 0x%x.\n",
- text_start, text_end);
- printf ("Data segment in executable from 0x%x to 0x%x.\n",
- exec_data_start, exec_data_end);
- if (corefile)
- printf ("(But since we have a core file, we're using...)\n");
- }
- if (corefile)
- {
- printf ("Data segment in core file from 0x%x to 0x%x.\n",
- data_start, data_end);
- printf ("Stack segment in core file from 0x%x to 0x%x.\n",
- stack_start, stack_end);
- }
- }
-}
-
-/* Read "memory data" from core file and/or executable file.
- Returns zero if successful, 1 if xfer_core_file failed, errno value if
- ptrace failed. */
-
-int
-read_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- if (len == 0)
- return 0;
-
- if (have_inferior_p ())
- {
- if (remote_debugging)
- return remote_read_inferior_memory (memaddr, myaddr, len);
- else
- return read_inferior_memory (memaddr, myaddr, len);
- }
- else
- return xfer_core_file (memaddr, myaddr, len);
-}
-
-/* Write LEN bytes of data starting at address MYADDR
- into debugged program memory at address MEMADDR.
- Returns zero if successful, or an errno value if ptrace failed. */
-
-int
-write_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- if (have_inferior_p ())
- {
- if (remote_debugging)
- return remote_write_inferior_memory (memaddr, myaddr, len);
- else
- return write_inferior_memory (memaddr, myaddr, len);
- }
- else
- error ("Can write memory only when program being debugged is running.");
-}
-
-#ifndef XFER_CORE_FILE
-int (*core_file_hook)(); /* hook to handle special core files like
- like /dev/mem and crash dumps */
-
-/* Read from the program's memory (except for inferior processes).
- This function is misnamed, since it only reads, never writes; and
- since it will use the core file and/or executable file as necessary.
-
- It should be extended to write as well as read, FIXME, for patching files.
-
- Return 0 if address could be read, 1 if not. */
-
-int
-xfer_core_file (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register int i;
- register int val;
- int xferchan;
- char **xferfile;
- int fileptr;
- int returnval = 0;
-
- if (core_file_hook)
- return ((*core_file_hook)(memaddr, myaddr, len));
-
- while (len > 0)
- {
- xferfile = 0;
- xferchan = 0;
-
- /* Determine which file the next bunch of addresses reside in,
- and where in the file. Set the file's read/write pointer
- to point at the proper place for the desired address
- and set xferfile and xferchan for the correct file.
-
- If desired address is nonexistent, leave them zero.
-
- i is set to the number of bytes that can be handled
- along with the next address.
-
- We put the most likely tests first for efficiency. */
-
- /* Note that if there is no core file
- data_start and data_end are equal. */
- if (memaddr >= data_start && memaddr < data_end)
- {
- i = min (len, data_end - memaddr);
- fileptr = memaddr - data_start + data_offset;
- xferfile = &corefile;
- xferchan = corechan;
- }
- /* Note that if there is no core file
- stack_start and stack_end are equal. */
- else if (memaddr >= stack_start && memaddr < stack_end)
- {
- i = min (len, stack_end - memaddr);
- fileptr = memaddr - stack_start + stack_offset;
- xferfile = &corefile;
- xferchan = corechan;
- }
-#ifdef REG_STACK_SEGMENT
- /* Pyramids have an extra segment in the virtual address space
- for the (control) stack of register-window frames */
- else if (memaddr >= reg_stack_start && memaddr < reg_stack_end)
- {
- i = min (len, reg_stack_end - memaddr);
- fileptr = memaddr - reg_stack_start + reg_stack_offset;
- xferfile = &corefile;
- xferchan = corechan;
- }
-#endif /* REG_STACK_SEGMENT */
-
- else if (corechan < 0
- && memaddr >= exec_data_start && memaddr < exec_data_end)
- {
- i = min (len, exec_data_end - memaddr);
- fileptr = memaddr - exec_data_start + exec_data_offset;
- xferfile = &execfile;
- xferchan = execchan;
- }
- else if (memaddr >= text_start && memaddr < text_end)
- {
- i = min (len, text_end - memaddr);
- fileptr = memaddr - text_start + text_offset;
- xferfile = &execfile;
- xferchan = execchan;
- }
- else if (memaddr < text_start)
- {
- i = min (len, text_start - memaddr);
- }
- else if (memaddr >= text_end
- && memaddr < (corechan >= 0? data_start : exec_data_start))
- {
- i = min (len, data_start - memaddr);
- }
- else if (corechan >= 0
- && memaddr >= data_end && memaddr < stack_start)
- {
- i = min (len, stack_start - memaddr);
- }
- else if (corechan < 0 && memaddr >= exec_data_end)
- {
- /* Since there is nothing at higher addresses than data
- (without a core file or an inferior, there is no
- stack, set i to do the rest of the operation now. */
- i = len;
- }
-#ifdef REG_STACK_SEGMENT
- else if (memaddr >= reg_stack_end && reg_stack_end != 0)
- {
- i = min (len, reg_stack_start - memaddr);
- }
- else if (memaddr >= stack_end && memaddr < reg_stack_start)
-#else /* no REG_STACK_SEGMENT. */
- else if (memaddr >= stack_end && stack_end != 0)
-#endif /* no REG_STACK_SEGMENT. */
- {
- /* Since there is nothing at higher addresses than
- the stack, set i to do the rest of the operation now. */
- i = len;
- }
- else
- {
- /* Address did not classify into one of the known ranges.
- This shouldn't happen; we catch the endpoints. */
- fatal ("Internal: Bad case logic in xfer_core_file.");
- }
-
- /* Now we know which file to use.
- Set up its pointer and transfer the data. */
- if (xferfile)
- {
- if (*xferfile == 0)
- if (xferfile == &execfile)
- error ("No program file to examine.");
- else
- error ("No core dump file or running program to examine.");
- val = lseek (xferchan, fileptr, 0);
- if (val == -1)
- perror_with_name (*xferfile);
- val = myread (xferchan, myaddr, i);
- if (val < 0)
- perror_with_name (*xferfile);
- }
- /* If this address is for nonexistent memory,
- read zeros if reading, or do nothing if writing.
- Actually, we never right. */
- else
- {
- bzero (myaddr, i);
- returnval = 1;
- }
-
- memaddr += i;
- myaddr += i;
- len -= i;
- }
- return returnval;
-}
-#endif /* XFER_CORE_FILE */
-
-/* My replacement for the read system call.
- Used like `read' but keeps going if `read' returns too soon. */
-
-int
-myread (desc, addr, len)
- int desc;
- char *addr;
- int len;
-{
- register int val;
- int orglen = len;
-
- while (len > 0)
- {
- val = read (desc, addr, len);
- if (val < 0)
- return val;
- if (val == 0)
- return orglen - len;
- len -= val;
- addr += val;
- }
- return orglen;
-}
-
-#ifdef REGISTER_U_ADDR
-
-/* Return the address in the core dump or inferior of register REGNO.
- BLOCKEND is the address of the end of the user structure. */
-
-unsigned int
-register_addr (regno, blockend)
- int regno;
- int blockend;
-{
- int addr;
-
- if (regno < 0 || regno >= NUM_REGS)
- error ("Invalid register number %d.", regno);
-
- REGISTER_U_ADDR (addr, blockend, regno);
-
- return addr;
-}
-
-#endif /* REGISTER_U_ADDR */
-
-void
-_initialize_core()
-{
- corechan = -1;
- execchan = -1;
- corefile = 0;
- execfile = 0;
- exec_file_display_hook = 0;
-
- text_start = 0;
- text_end = 0;
- data_start = 0;
- data_end = 0;
- exec_data_start = 0;
- exec_data_end = 0;
- stack_start = STACK_END_ADDR;
- stack_end = STACK_END_ADDR;
-
- add_com ("core-file", class_files, core_file_command,
- "Use FILE as core dump for examining memory and registers.\n\
-No arg means have no core file.");
- add_com ("exec-file", class_files, exec_file_command,
- "Use FILE as program for getting contents of pure memory.\n\
-If FILE cannot be found as specified, your execution directory path\n\
-is searched for a command of that name.\n\
-No arg means have no executable file.");
- add_info ("files", files_info, "Names of files being debugged.");
-}
-
diff --git a/gnu/usr.bin/gdb/cplus-dem.c b/gnu/usr.bin/gdb/cplus-dem.c
deleted file mode 100644
index 8ea9c8b..0000000
--- a/gnu/usr.bin/gdb/cplus-dem.c
+++ /dev/null
@@ -1,996 +0,0 @@
-/* Demangler for GNU C++
- Copyright (C) 1989 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 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. */
-
-/* This is for g++ 1.36.1 (November 6 version). It will probably
- require changes for any other version.
-
- Modified for g++ 1.36.2 (November 18 version). */
-
-/* This file exports one function
-
- char *cplus_demangle (const char *name, int mode)
-
- If NAME is a mangled function name produced by GNU C++, 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.
-
- If MODE > 0, then ANSI qualifiers such as `const' and `void' are output.
- Otherwise they are not.
- If MODE >= 0, parameters are emitted; otherwise not.
-
- For example,
-
- cplus_demangle ("foo__1Ai", 0) => "A::foo(int)"
- cplus_demangle ("foo__1Ai", 1) => "A::foo(int)"
- cplus_demangle ("foo__1Ai", -1) => "A::foo"
-
- cplus_demangle ("foo__1Afe", 0) => "A::foo(float,...)"
- cplus_demangle ("foo__1Afe", 1) => "A::foo(float,...)"
- cplus_demangle ("foo__1Afe", -1) => "A::foo"
-
- 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 <ctype.h>
-
-#ifdef USG
-#include <memory.h>
-#include <string.h>
-#else
-#include <strings.h>
-#define memcpy(s1, s2, n) bcopy ((s2), (s1), (n))
-#define memcmp(s1, s2, n) bcmp ((s2), (s1), (n))
-#define strchr index
-#define strrchr rindex
-#endif
-
-#ifndef __STDC__
-#define const
-#endif
-
-#ifdef __STDC__
-extern char *cplus_demangle (const char *type, int mode);
-#else
-extern char *cplus_demangle ();
-#endif
-
-#ifdef __STDC__
-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", "*",
- "convert", "+", /* unary + */
- "negate", "-", /* unary - */
- "trunc_mod", "%",
- "trunc_div", "/",
- "truth_andif", "&&",
- "truth_orif", "||",
- "truth_not", "!",
- "postincrement", "++",
- "postdecrement", "--",
- "bit_ior", "|",
- "bit_xor", "^",
- "bit_and", "&",
- "bit_not", "~",
- "call", "()",
- "cond", "?:",
- "alshift", "<<",
- "arshift", ">>",
- "component", "->",
- "indirect", "*",
- "method_call", "->()",
- "addr", "&", /* unary & */
- "array", "[]",
- "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;
-
-#ifdef __STDC__
-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, int arg_mode);
-static int do_type (const char **type, string *result, int arg_mode);
-static int do_arg (const char **type, string *result, int arg_mode);
-static void munge_function_name (string *name, int arg_mode);
-static void remember_type (const char *type, int len);
-#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 ();
-static void remember_type ();
-#endif
-
-char *
-cplus_demangle (type, arg_mode)
- const char *type;
- int arg_mode;
-{
- string decl;
- int n;
- int success = 0;
- int constructor = 0;
- int const_flag = 0;
- int i;
- const char *p;
-#ifndef LONGERNAMES
- const char *premangle;
-#endif
-
-# define print_ansi_qualifiers (arg_mode > 0)
-# define print_arg_types (arg_mode >= 0)
-
- 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, '$')) != NULL)
- {
- 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;
- }
- /* virtual table "_vt$" */
- if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$')
- {
- int n = strlen (type + 4) + 14 + 1;
- char *tem = (char *) xmalloc (n);
- strcpy (tem, type + 4);
- strcat (tem, " virtual table");
- 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, arg_mode);
- }
- p += 2;
-
-#ifndef LONGERNAMES
- premangle = p;
-#endif
- 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;
-#ifndef LONGERNAMES
- remember_type (premangle, p - premangle);
-#endif
- success = do_args (&p, &decl, arg_mode);
- if (const_flag && print_arg_types)
- string_append (&decl, " const");
- break;
- case 'F':
- p += 1;
- success = do_args (&p, &decl, arg_mode);
- 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, arg_mode)
- const char **type;
- string *result;
- int arg_mode;
-{
- int n;
- int done;
- int non_empty = 0;
- 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, arg_mode) || **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, arg_mode)) || **type != '_')
- {
- success = 0;
- break;
- }
- *type += 1;
- if (! print_ansi_qualifiers)
- break;
- 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, "volatile");
- }
- break;
- }
-
- case 'C':
- if ((*type)[1] == 'P')
- {
- *type += 1;
- if (print_ansi_qualifiers)
- {
- 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 (print_ansi_qualifiers)
- {
- 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 (print_ansi_qualifiers)
- {
- 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 'x':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "long long");
- 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, arg_mode)
- const char **type;
- string *result;
- int arg_mode;
-{
- const char *start = *type;
-
- if (!do_type (type, result, arg_mode))
- return 0;
- remember_type (start, *type - start);
- return 1;
-}
-
-static void
-remember_type (start, len)
- const char *start;
- int len;
-{
- char *tem;
-
- 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);
- }
- }
- tem = (char *) xmalloc (len + 1);
- memcpy (tem, start, len);
- tem[len] = '\0';
- typevec[ntypes++] = tem;
-}
-
-/* `decl' must be already initialised, usually non-empty;
- it won't be freed on failure */
-
-static int
-do_args (type, decl, arg_mode)
- const char **type;
- string *decl;
- int arg_mode;
-{
- string arg;
- int need_comma = 0;
-
- if (print_arg_types)
- 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 && print_arg_types)
- string_append (decl, ", ");
- if (!do_arg (&tem, &arg, arg_mode))
- return 0;
- if (print_arg_types)
- string_appends (decl, &arg);
- string_delete (&arg);
- need_comma = 1;
- }
- }
- else
- {
- if (need_comma & print_arg_types)
- string_append (decl, ", ");
- if (!do_arg (type, &arg, arg_mode))
- return 0;
- if (print_arg_types)
- string_appends (decl, &arg);
- string_delete (&arg);
- need_comma = 1;
- }
- }
-
- if (**type == 'v')
- *type += 1;
- else if (**type == 'e')
- {
- *type += 1;
- if (print_arg_types)
- {
- if (need_comma)
- string_append (decl, ",");
- string_append (decl, "...");
- }
- }
-
- if (print_arg_types)
- string_append (decl, ")");
- return 1;
-}
-
-static void
-munge_function_name (name, arg_mode)
- string *name;
- int arg_mode;
-{
- 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, arg_mode))
- {
- 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;
-}
diff --git a/gnu/usr.bin/gdb/dbxread.c b/gnu/usr.bin/gdb/dbxread.c
deleted file mode 100644
index 7a25665..0000000
--- a/gnu/usr.bin/gdb/dbxread.c
+++ /dev/null
@@ -1,5727 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)dbxread.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Read dbx symbol tables and convert to internal format, for GDB.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-/* Symbol read-in occurs in two phases:
- 1. A scan (read_dbx_symtab()) of the entire executable, whose sole
- purpose is to make a list of symbols (partial symbol table)
- which will cause symbols
- to be read in if referenced. This scan happens when the
- "symbol-file" command is given (symbol_file_command()).
- 2. Full read-in of symbols. (psymtab_to_symtab()). This happens
- when a symbol in a file for which symbols have not yet been
- read in is referenced.
- 2a. The "add-file" command. Similar to #2. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-
-#ifdef READ_DBX_FORMAT
-
-#ifdef USG
-#include <sys/types.h>
-#include <fcntl.h>
-#define L_SET 0
-#define L_INCR 1
-#endif
-
-#ifdef COFF_ENCAPSULATE
-#include "a.out.encap.h"
-#include "stab.gnu.h"
-#else
-#include <a.out.h>
-#include <stab.h>
-#endif
-#include <ctype.h>
-
-#ifndef NO_GNU_STABS
-/*
- * Define specifically gnu symbols here.
- */
-
-/* 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. */
-#ifndef N_INDR
-#define N_INDR 0xa
-#endif
-
-/* 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. */
-
-#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 N_WARNING
-#define N_WARNING 0x1E /* Warning message to print if file included */
-#endif /* This is input to 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__ */
-#endif /* NO_GNU_STABS */
-
-#include <obstack.h>
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-
-#include "symtab.h"
-
-#ifndef COFF_FORMAT
-#ifndef AOUTHDR
-#define AOUTHDR struct exec
-#endif
-#endif
-
-static void add_symbol_to_list ();
-static void read_dbx_symtab ();
-static void process_one_symbol ();
-static void free_all_psymbols ();
-static struct type *read_type ();
-static struct type *read_range_type ();
-static struct type *read_enum_type ();
-static struct type *read_struct_type ();
-static struct type *read_array_type ();
-static long read_number ();
-static void read_huge_number ();
-static void finish_block ();
-static struct blockvector *make_blockvector ();
-static struct symbol *define_symbol ();
-static void start_subfile ();
-static int hashname ();
-static void hash_symsegs ();
-static struct pending *copy_pending ();
-static void fix_common_block ();
-
-static void add_undefined_type ();
-static void cleanup_undefined_types ();
-
-extern char *index();
-
-extern struct symtab *read_symsegs ();
-extern void free_all_symtabs ();
-extern void free_all_psymtabs ();
-extern void free_inclink_symtabs ();
-
-/* C++ */
-static struct type **read_args ();
-
-/* Macro to determine which symbols to ignore when reading the first symbol
- of a file. Some machines override this definition. */
-#ifdef N_NSYMS
-#ifndef IGNORE_SYMBOL
-/* This code is used on Ultrix systems. Ignore it */
-#define IGNORE_SYMBOL(type) (type == N_NSYMS)
-#endif
-#else
-#ifndef IGNORE_SYMBOL
-/* Don't ignore any symbols. */
-#define IGNORE_SYMBOL(type) (0)
-#endif
-#endif /* not N_NSYMS */
-
-/* Macro for number of symbol table entries (in usual a.out format).
- Some machines override this definition. */
-#ifndef NUMBER_OF_SYMBOLS
-#ifdef COFF_HEADER
-#define NUMBER_OF_SYMBOLS \
- ((COFF_HEADER(hdr) ? hdr.coffhdr.filehdr.f_nsyms : hdr.a_syms) / \
- sizeof (struct nlist))
-#else
-#define NUMBER_OF_SYMBOLS (hdr.a_syms / sizeof (struct nlist))
-#endif
-#endif
-
-/* Macro for file-offset of symbol table (in usual a.out format). */
-#ifndef SYMBOL_TABLE_OFFSET
-#define SYMBOL_TABLE_OFFSET N_SYMOFF (hdr)
-#endif
-
-/* Macro for file-offset of string table (in usual a.out format). */
-#ifndef STRING_TABLE_OFFSET
-#define STRING_TABLE_OFFSET (N_SYMOFF (hdr) + hdr.a_syms)
-#endif
-
-/* Macro to store the length of the string table data in INTO. */
-#ifndef READ_STRING_TABLE_SIZE
-#define READ_STRING_TABLE_SIZE(INTO) \
-{ val = myread (desc, &INTO, sizeof INTO); \
- if (val < 0) perror_with_name (name); }
-#endif
-
-/* Macro to declare variables to hold the file's header data. */
-#ifndef DECLARE_FILE_HEADERS
-#define DECLARE_FILE_HEADERS AOUTHDR hdr
-#endif
-
-/* Macro to read the header data from descriptor DESC and validate it.
- NAME is the file name, for error messages. */
-#ifndef READ_FILE_HEADERS
-#ifdef HEADER_SEEK_FD
-#define READ_FILE_HEADERS(DESC, NAME) \
-{ HEADER_SEEK_FD (DESC); \
- val = myread (DESC, &hdr, sizeof hdr); \
- if (val < 0) perror_with_name (NAME); \
- if (N_BADMAG (hdr)) \
- error ("File \"%s\" not in executable format.", NAME); }
-#else
-#define READ_FILE_HEADERS(DESC, NAME) \
-{ val = myread (DESC, &hdr, sizeof hdr); \
- if (val < 0) perror_with_name (NAME); \
- if (N_BADMAG (hdr)) \
- error ("File \"%s\" not in executable format.", NAME); }
-#endif
-#endif
-
-/* Non-zero if this is an object (.o) file, rather than an executable.
- Distinguishing between the two is rarely necessary (and seems like
- a hack, but there is no other way to do ADDR_OF_TEXT_SEGMENT
- right for SunOS). */
-#if !defined (IS_OBJECT_FILE)
-/* This will not work
- if someone decides to make ld preserve relocation info. */
-#define IS_OBJECT_FILE (hdr.a_trsize != 0)
-#endif
-
-/* Macro for size of text segment */
-#ifndef SIZE_OF_TEXT_SEGMENT
-#define SIZE_OF_TEXT_SEGMENT hdr.a_text
-#endif
-
-/* Get the address in debugged memory of the start
- of the text segment. */
-#if !defined (ADDR_OF_TEXT_SEGMENT)
-#if defined (N_TXTADDR)
-#define ADDR_OF_TEXT_SEGMENT (IS_OBJECT_FILE ? 0 : N_TXTADDR (hdr))
-#else /* no N_TXTADDR */
-#define ADDR_OF_TEXT_SEGMENT 0
-#endif /* no N_TXTADDR */
-#endif /* no ADDR_OF_TEXT_SEGMENT */
-
-/* Macro to get entry point from headers. */
-#ifndef ENTRY_POINT
-#define ENTRY_POINT hdr.a_entry
-#endif
-
-/* Macro for name of symbol to indicate a file compiled with gcc. */
-#ifndef GCC_COMPILED_FLAG_SYMBOL
-#define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled."
-#endif
-
-/* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
-
-#ifndef STAB_REG_TO_REGNUM
-#define STAB_REG_TO_REGNUM(VALUE) (VALUE)
-#endif
-
-/* Define this as 1 if a pcc declaration of a char or short argument
- gives the correct address. Otherwise assume pcc gives the
- address of the corresponding int, which is not the same on a
- big-endian machine. */
-
-#ifndef BELIEVE_PCC_PROMOTION
-#define BELIEVE_PCC_PROMOTION 0
-#endif
-
-/* Nonzero means give verbose info on gdb action. From main.c. */
-extern int info_verbose;
-
-/* Chain of symtabs made from reading the file's symsegs.
- These symtabs do not go into symtab_list themselves,
- but the information is copied from them when appropriate
- to make the symtabs that will exist permanently. */
-
-static struct symtab *symseg_chain;
-
-/* Symseg symbol table for the file whose data we are now processing.
- It is one of those in symseg_chain. Or 0, for a compilation that
- has no symseg. */
-
-static struct symtab *current_symseg;
-
-/* Name of source file whose symbol data we are now processing.
- This comes from a symbol of type N_SO. */
-
-static char *last_source_file;
-
-/* Core address of start of text of current source file.
- This too comes from the N_SO symbol. */
-
-static CORE_ADDR last_source_start_addr;
-
-/* End of the text segment of the executable file,
- as found in the symbol _etext. */
-
-static CORE_ADDR end_of_text_addr;
-
-/* The list of sub-source-files within the current individual compilation.
- Each file gets its own symtab with its own linetable and associated info,
- but they all share one blockvector. */
-
-struct subfile
-{
- struct subfile *next;
- char *name;
- struct linetable *line_vector;
- int line_vector_length;
- int line_vector_index;
- int prev_line_number;
-};
-
-static struct subfile *subfiles;
-
-static struct subfile *current_subfile;
-
-/* Count symbols as they are processed, for error messages. */
-
-static int symnum;
-
-/* Vector of types defined so far, indexed by their dbx type numbers.
- (In newer sun systems, dbx uses a pair of numbers in parens,
- as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be
- translated through the type_translations hash table to get
- the index into the type vector.) */
-
-static struct typevector *type_vector;
-
-/* Number of elements allocated for type_vector currently. */
-
-static int type_vector_length;
-
-/* Vector of line number information. */
-
-static struct linetable *line_vector;
-
-/* Index of next entry to go in line_vector_index. */
-
-static int line_vector_index;
-
-/* Last line number recorded in the line vector. */
-
-static int prev_line_number;
-
-/* Number of elements allocated for line_vector currently. */
-
-static int line_vector_length;
-
-/* Hash table of global symbols whose values are not known yet.
- They are chained thru the SYMBOL_VALUE, since we don't
- have the correct data for that slot yet. */
-/* The use of the LOC_BLOCK code in this chain is nonstandard--
- it refers to a FORTRAN common block rather than the usual meaning. */
-
-#define HASHSIZE 127
-static struct symbol *global_sym_chain[HASHSIZE];
-
-/* Record the symbols defined for each context in a list.
- We don't create a struct block for the context until we
- know how long to make it. */
-
-#define PENDINGSIZE 100
-
-struct pending
-{
- struct pending *next;
- int nsyms;
- struct symbol *symbol[PENDINGSIZE];
-};
-
-/* List of free `struct pending' structures for reuse. */
-struct pending *free_pendings;
-
-/* Here are the three lists that symbols are put on. */
-
-struct pending *file_symbols; /* static at top level, and types */
-
-struct pending *global_symbols; /* global functions and variables */
-
-struct pending *local_symbols; /* everything local to lexical context */
-
-/* List of symbols declared since the last BCOMM. This list is a tail
- of local_symbols. When ECOMM is seen, the symbols on the list
- are noted so their proper addresses can be filled in later,
- using the common block base address gotten from the assembler
- stabs. */
-
-struct pending *common_block;
-int common_block_i;
-
-/* Stack representing unclosed lexical contexts
- (that will become blocks, eventually). */
-
-struct context_stack
-{
- struct pending *locals;
- struct pending_block *old_blocks;
- struct symbol *name;
- CORE_ADDR start_addr;
- int depth;
-};
-
-struct context_stack *context_stack;
-
-/* Index of first unused entry in context stack. */
-int context_stack_depth;
-
-/* Currently allocated size of context stack. */
-
-int context_stack_size;
-
-/* Nonzero if within a function (so symbols should be local,
- if nothing says specifically). */
-
-int within_function;
-
-/* List of blocks already made (lexical contexts already closed).
- This is used at the end to make the blockvector. */
-
-struct pending_block
-{
- struct pending_block *next;
- struct block *block;
-};
-
-struct pending_block *pending_blocks;
-
-extern CORE_ADDR startup_file_start; /* From blockframe.c */
-extern CORE_ADDR startup_file_end; /* From blockframe.c */
-
-/* File name symbols were loaded from. */
-
-static char *symfile;
-
-/* Low and high symbol values (inclusive) for the global variable
- entries in the symbol file. */
-
-static int first_global_sym, last_global_sym;
-
-/* Structures with which to manage partial symbol allocation. */
-
-struct psymbol_allocation_list global_psymbols, static_psymbols;
-
-/* Global variable which, when set, indicates that we are processing a
- .o file compiled with gcc */
-
-static unsigned char processing_gcc_compilation;
-
-/* Make a list of forward references which haven't been defined. */
-static struct type **undef_types;
-static int undef_types_allocated, undef_types_length;
-
- /* Setup a define to deal cleanly with the underscore problem */
-
-#ifdef NAMES_HAVE_UNDERSCORE
-#define HASH_OFFSET 1
-#else
-#define HASH_OFFSET 0
-#endif
-
-#if 0
-/* I'm not sure why this is here. To debug bugs which cause
- an infinite loop of allocations, I suppose. In any event,
- dumping core when out of memory isn't usually right. */
-static int
-xxmalloc (n)
-{
- int v = malloc (n);
- if (v == 0)
- {
- fprintf (stderr, "Virtual memory exhausted.\n");
- abort ();
- }
- return v;
-}
-#else /* not 0 */
-#define xxmalloc xmalloc
-#endif /* not 0 */
-
-/* Make a copy of the string at PTR with SIZE characters in the symbol obstack
- (and add a null character at the end in the copy).
- Returns the address of the copy. */
-
-static char *
-obsavestring (ptr, size)
- char *ptr;
- int size;
-{
- register char *p = (char *) obstack_alloc (symbol_obstack, size + 1);
- /* Open-coded bcopy--saves function call time.
- These strings are usually short. */
- {
- register char *p1 = ptr;
- register char *p2 = p;
- char *end = ptr + size;
- while (p1 != end)
- *p2++ = *p1++;
- }
- p[size] = 0;
- return p;
-}
-
-/* Concatenate strings S1, S2 and S3; return the new string.
- Space is found in the symbol_obstack. */
-
-static char *
-obconcat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1;
- register char *val = (char *) obstack_alloc (symbol_obstack, len);
- strcpy (val, s1);
- strcat (val, s2);
- strcat (val, s3);
- return val;
-}
-
-/* Support for Sun changes to dbx symbol format */
-
-/* For each identified header file, we have a table of types defined
- in that header file.
-
- header_files maps header file names to their type tables.
- It is a vector of n_header_files elements.
- Each element describes one header file.
- It contains a vector of types.
-
- Sometimes it can happen that the same header file produces
- different results when included in different places.
- This can result from conditionals or from different
- things done before including the file.
- When this happens, there are multiple entries for the file in this table,
- one entry for each distinct set of results.
- The entries are distinguished by the INSTANCE field.
- The INSTANCE field appears in the N_BINCL and N_EXCL symbol table and is
- used to match header-file references to their corresponding data. */
-
-struct header_file
-{
- char *name; /* Name of header file */
- int instance; /* Numeric code distinguishing instances
- of one header file that produced
- different results when included.
- It comes from the N_BINCL or N_EXCL. */
- struct type **vector; /* Pointer to vector of types */
- int length; /* Allocated length (# elts) of that vector */
-};
-
-static struct header_file *header_files;
-
-static int n_header_files;
-
-static int n_allocated_header_files;
-
-/* During initial symbol readin, we need to have a structure to keep
- track of which psymtabs have which bincls in them. This structure
- is used during readin to setup the list of dependencies within each
- partial symbol table. */
-
-struct header_file_location
-{
- char *name; /* Name of header file */
- int instance; /* See above */
- struct partial_symtab *pst; /* Partial symtab that has the
- BINCL/EINCL defs for this file */
-};
-
-/* The actual list and controling variables */
-static struct header_file_location *bincl_list, *next_bincl;
-static int bincls_allocated;
-
-/* Within each object file, various header files are assigned numbers.
- A type is defined or referred to with a pair of numbers
- (FILENUM,TYPENUM) where FILENUM is the number of the header file
- and TYPENUM is the number within that header file.
- TYPENUM is the index within the vector of types for that header file.
-
- FILENUM == 1 is special; it refers to the main source of the object file,
- and not to any header file. FILENUM != 1 is interpreted by looking it up
- in the following table, which contains indices in header_files. */
-
-static int *this_object_header_files;
-
-static int n_this_object_header_files;
-
-static int n_allocated_this_object_header_files;
-
-/* When a header file is getting special overriding definitions
- for one source file, record here the header_files index
- of its normal definition vector.
- At other times, this is -1. */
-
-static int header_file_prev_index;
-
-/* At the start of reading dbx symbols, allocate our tables. */
-
-static void
-init_header_files ()
-{
- n_allocated_header_files = 10;
- header_files = (struct header_file *) xxmalloc (10 * sizeof (struct header_file));
- n_header_files = 0;
-
- n_allocated_this_object_header_files = 10;
- this_object_header_files = (int *) xxmalloc (10 * sizeof (int));
-}
-
-/* At the end of reading dbx symbols, free our tables. */
-
-static void
-free_header_files ()
-{
- register int i;
- for (i = 0; i < n_header_files; i++)
- free (header_files[i].name);
- if (header_files) free (header_files);
- if (this_object_header_files)
- free (this_object_header_files);
-}
-
-/* Called at the start of each object file's symbols.
- Clear out the mapping of header file numbers to header files. */
-
-static void
-new_object_header_files ()
-{
- /* Leave FILENUM of 0 free for builtin types and this file's types. */
- n_this_object_header_files = 1;
- header_file_prev_index = -1;
-}
-
-/* Add header file number I for this object file
- at the next successive FILENUM. */
-
-static void
-add_this_object_header_file (i)
- int i;
-{
- if (n_this_object_header_files == n_allocated_this_object_header_files)
- {
- n_allocated_this_object_header_files *= 2;
- this_object_header_files
- = (int *) xrealloc (this_object_header_files,
- n_allocated_this_object_header_files * sizeof (int));
- }
-
- this_object_header_files[n_this_object_header_files++] = i;
-}
-
-/* Add to this file an "old" header file, one already seen in
- a previous object file. NAME is the header file's name.
- INSTANCE is its instance code, to select among multiple
- symbol tables for the same header file. */
-
-static void
-add_old_header_file (name, instance)
- char *name;
- int instance;
-{
- register struct header_file *p = header_files;
- register int i;
-
- for (i = 0; i < n_header_files; i++)
- if (!strcmp (p[i].name, name) && instance == p[i].instance)
- {
- add_this_object_header_file (i);
- return;
- }
- error ("Invalid symbol data: \"repeated\" header file that hasn't been seen before, at symtab pos %d.",
- symnum);
-}
-
-/* Add to this file a "new" header file: definitions for its types follow.
- NAME is the header file's name.
- Most often this happens only once for each distinct header file,
- but not necessarily. If it happens more than once, INSTANCE has
- a different value each time, and references to the header file
- use INSTANCE values to select among them.
-
- dbx output contains "begin" and "end" markers for each new header file,
- but at this level we just need to know which files there have been;
- so we record the file when its "begin" is seen and ignore the "end". */
-
-static void
-add_new_header_file (name, instance)
- char *name;
- int instance;
-{
- register int i;
- register struct header_file *p = header_files;
- header_file_prev_index = -1;
-
-#if 0
- /* This code was used before I knew about the instance codes.
- My first hypothesis is that it is not necessary now
- that instance codes are handled. */
-
- /* Has this header file a previous definition?
- If so, make a new entry anyway so that this use in this source file
- gets a separate entry. Later source files get the old entry.
- Record here the index of the old entry, so that any type indices
- not previously defined can get defined in the old entry as
- well as in the new one. */
-
- for (i = 0; i < n_header_files; i++)
- if (!strcmp (p[i].name, name))
- {
- header_file_prev_index = i;
- }
-
-#endif
-
- /* Make sure there is room for one more header file. */
-
- if (n_header_files == n_allocated_header_files)
- {
- n_allocated_header_files *= 2;
- header_files = (struct header_file *)
- xrealloc (header_files,
- (n_allocated_header_files
- * sizeof (struct header_file)));
- }
-
- /* Create an entry for this header file. */
-
- i = n_header_files++;
- header_files[i].name = savestring (name, strlen(name));
- header_files[i].instance = instance;
- header_files[i].length = 10;
- header_files[i].vector
- = (struct type **) xxmalloc (10 * sizeof (struct type *));
- bzero (header_files[i].vector, 10 * sizeof (struct type *));
-
- add_this_object_header_file (i);
-}
-
-/* Look up a dbx type-number pair. Return the address of the slot
- where the type for that number-pair is stored.
- The number-pair is in TYPENUMS.
-
- This can be used for finding the type associated with that pair
- or for associating a new type with the pair. */
-
-static struct type **
-dbx_lookup_type (typenums)
- int typenums[2];
-{
- register int filenum = typenums[0], index = typenums[1];
-
- if (filenum < 0 || filenum >= n_this_object_header_files)
- error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
- filenum, index, symnum);
-
- if (filenum == 0)
- {
- /* Type is defined outside of header files.
- Find it in this object file's type vector. */
- if (index >= type_vector_length)
- {
- type_vector_length *= 2;
- type_vector = (struct typevector *)
- xrealloc (type_vector,
- (sizeof (struct typevector)
- + type_vector_length * sizeof (struct type *)));
- bzero (&type_vector->type[type_vector_length / 2],
- type_vector_length * sizeof (struct type *) / 2);
- }
- return &type_vector->type[index];
- }
- else
- {
- register int real_filenum = this_object_header_files[filenum];
- register struct header_file *f;
-
- if (real_filenum >= n_header_files)
- abort ();
-
- f = &header_files[real_filenum];
-
- if (index >= f->length)
- {
- f->length *= 2;
- f->vector = (struct type **)
- xrealloc (f->vector, f->length * sizeof (struct type *));
- bzero (&f->vector[f->length / 2],
- f->length * sizeof (struct type *) / 2);
- }
- return &f->vector[index];
- }
-}
-
-/* Create a type object. Occaisionally used when you need a type
- which isn't going to be given a type number. */
-
-static struct type *
-dbx_create_type ()
-{
- register struct type *type =
- (struct type *) obstack_alloc (symbol_obstack, sizeof (struct type));
-
- bzero (type, sizeof (struct type));
- TYPE_VPTR_FIELDNO (type) = -1;
- return type;
-}
-
-/* Make sure there is a type allocated for type numbers TYPENUMS
- and return the type object.
- This can create an empty (zeroed) type object.
- TYPENUMS may be (-1, -1) to return a new type object that is not
- put into the type vector, and so may not be referred to by number. */
-
-static struct type *
-dbx_alloc_type (typenums)
- int typenums[2];
-{
- register struct type **type_addr;
- register struct type *type;
-
- if (typenums[1] != -1)
- {
- type_addr = dbx_lookup_type (typenums);
- type = *type_addr;
- }
- else
- {
- type_addr = 0;
- type = 0;
- }
-
- /* If we are referring to a type not known at all yet,
- allocate an empty type for it.
- We will fill it in later if we find out how. */
- if (type == 0)
- {
- type = dbx_create_type ();
- if (type_addr)
- *type_addr = type;
- }
-
- return type;
-}
-
-#if 0
-static struct type **
-explicit_lookup_type (real_filenum, index)
- int real_filenum, index;
-{
- register struct header_file *f = &header_files[real_filenum];
-
- if (index >= f->length)
- {
- f->length *= 2;
- f->vector = (struct type **)
- xrealloc (f->vector, f->length * sizeof (struct type *));
- bzero (&f->vector[f->length / 2],
- f->length * sizeof (struct type *) / 2);
- }
- return &f->vector[index];
-}
-#endif
-
-/* maintain the lists of symbols and blocks */
-
-/* Add a symbol to one of the lists of symbols. */
-static void
-add_symbol_to_list (symbol, listhead)
- struct symbol *symbol;
- struct pending **listhead;
-{
- /* We keep PENDINGSIZE symbols in each link of the list.
- If we don't have a link with room in it, add a new link. */
- if (*listhead == 0 || (*listhead)->nsyms == PENDINGSIZE)
- {
- register struct pending *link;
- if (free_pendings)
- {
- link = free_pendings;
- free_pendings = link->next;
- }
- else
- link = (struct pending *) xxmalloc (sizeof (struct pending));
-
- link->next = *listhead;
- *listhead = link;
- link->nsyms = 0;
- }
-
- (*listhead)->symbol[(*listhead)->nsyms++] = symbol;
-}
-
-/* At end of reading syms, or in case of quit,
- really free as many `struct pending's as we can easily find. */
-
-static void
-really_free_pendings ()
-{
- struct pending *next, *next1;
- struct pending_block *bnext, *bnext1;
-
- for (next = free_pendings; next; next = next1)
- {
- next1 = next->next;
- free (next);
- }
- free_pendings = 0;
-
- for (bnext = pending_blocks; bnext; bnext = bnext1)
- {
- bnext1 = bnext->next;
- free (bnext);
- }
- pending_blocks = 0;
-
- for (next = file_symbols; next; next = next1)
- {
- next1 = next->next;
- free (next);
- }
- for (next = global_symbols; next; next = next1)
- {
- next1 = next->next;
- free (next);
- }
-}
-
-/* Take one of the lists of symbols and make a block from it.
- Keep the order the symbols have in the list (reversed from the input file).
- Put the block on the list of pending blocks. */
-
-static void
-finish_block (symbol, listhead, old_blocks, start, end)
- struct symbol *symbol;
- struct pending **listhead;
- struct pending_block *old_blocks;
- CORE_ADDR start, end;
-{
- register struct pending *next, *next1;
- register struct block *block;
- register struct pending_block *pblock;
- struct pending_block *opblock;
- register int i;
-
- /* Count the length of the list of symbols. */
-
- for (next = *listhead, i = 0; next; i += next->nsyms, next = next->next);
-
- block = (struct block *) obstack_alloc (symbol_obstack,
- (sizeof (struct block)
- + ((i - 1)
- * sizeof (struct symbol *))));
-
- /* Copy the symbols into the block. */
-
- BLOCK_NSYMS (block) = i;
- for (next = *listhead; next; next = next->next)
- {
- register int j;
- for (j = next->nsyms - 1; j >= 0; j--)
- BLOCK_SYM (block, --i) = next->symbol[j];
- }
-
- BLOCK_START (block) = start;
- BLOCK_END (block) = end;
- BLOCK_SUPERBLOCK (block) = 0; /* Filled in when containing block is made */
- BLOCK_GCC_COMPILED (block) = processing_gcc_compilation;
-
- /* Put the block in as the value of the symbol that names it. */
-
- if (symbol)
- {
- SYMBOL_BLOCK_VALUE (symbol) = block;
- BLOCK_FUNCTION (block) = symbol;
- }
- else
- BLOCK_FUNCTION (block) = 0;
-
- /* Now "free" the links of the list, and empty the list. */
-
- for (next = *listhead; next; next = next1)
- {
- next1 = next->next;
- next->next = free_pendings;
- free_pendings = next;
- }
- *listhead = 0;
-
- /* Install this block as the superblock
- of all blocks made since the start of this scope
- that don't have superblocks yet. */
-
- opblock = 0;
- for (pblock = pending_blocks; pblock != old_blocks; pblock = pblock->next)
- {
- if (BLOCK_SUPERBLOCK (pblock->block) == 0)
- BLOCK_SUPERBLOCK (pblock->block) = block;
- opblock = pblock;
- }
-
- /* Record this block on the list of all blocks in the file.
- Put it after opblock, or at the beginning if opblock is 0.
- This puts the block in the list after all its subblocks. */
-
- /* Allocate in the symbol_obstack to save time.
- It wastes a little space. */
- pblock = (struct pending_block *)
- obstack_alloc (symbol_obstack,
- sizeof (struct pending_block));
- pblock->block = block;
- if (opblock)
- {
- pblock->next = opblock->next;
- opblock->next = pblock;
- }
- else
- {
- pblock->next = pending_blocks;
- pending_blocks = pblock;
- }
-}
-
-static struct blockvector *
-make_blockvector ()
-{
- register struct pending_block *next, *next1;
- register struct blockvector *blockvector;
- register int i;
-
- /* Count the length of the list of blocks. */
-
- for (next = pending_blocks, i = 0; next; next = next->next, i++);
-
- blockvector = (struct blockvector *)
- obstack_alloc (symbol_obstack,
- (sizeof (struct blockvector)
- + (i - 1) * sizeof (struct block *)));
-
- /* Copy the blocks into the blockvector.
- This is done in reverse order, which happens to put
- the blocks into the proper order (ascending starting address).
- finish_block has hair to insert each block into the list
- after its subblocks in order to make sure this is true. */
-
- BLOCKVECTOR_NBLOCKS (blockvector) = i;
- for (next = pending_blocks; next; next = next->next)
- BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
-
-#if 0 /* Now we make the links in the obstack, so don't free them. */
- /* Now free the links of the list, and empty the list. */
-
- for (next = pending_blocks; next; next = next1)
- {
- next1 = next->next;
- free (next);
- }
-#endif
- pending_blocks = 0;
-
- return blockvector;
-}
-
-/* Manage the vector of line numbers. */
-
-static void
-record_line (line, pc)
- int line;
- CORE_ADDR pc;
-{
- struct linetable_entry *e;
- /* Ignore the dummy line number in libg.o */
-
- if (line == 0xffff)
- return;
-
- /* Make sure line vector is big enough. */
-
- if (line_vector_index + 1 >= line_vector_length)
- {
- line_vector_length *= 2;
- line_vector = (struct linetable *)
- xrealloc (line_vector,
- (sizeof (struct linetable)
- + line_vector_length * sizeof (struct linetable_entry)));
- current_subfile->line_vector = line_vector;
- }
-
- e = line_vector->item + line_vector_index++;
- e->line = line; e->pc = pc;
-}
-
-/* Start a new symtab for a new source file.
- This is called when a dbx symbol of type N_SO is seen;
- it indicates the start of data for one original source file. */
-
-static void
-start_symtab (name, start_addr)
- char *name;
- CORE_ADDR start_addr;
-{
- register struct symtab *s;
-
- last_source_file = name;
- last_source_start_addr = start_addr;
- file_symbols = 0;
- global_symbols = 0;
- within_function = 0;
-
- /* Context stack is initially empty, with room for 10 levels. */
- context_stack
- = (struct context_stack *) xxmalloc (10 * sizeof (struct context_stack));
- context_stack_size = 10;
- context_stack_depth = 0;
-
- new_object_header_files ();
-
- for (s = symseg_chain; s; s = s->next)
- if (s->ldsymoff == symnum * sizeof (struct nlist))
- break;
- current_symseg = s;
- if (s != 0)
- return;
-
- type_vector_length = 160;
- type_vector = (struct typevector *)
- xxmalloc (sizeof (struct typevector)
- + type_vector_length * sizeof (struct type *));
- bzero (type_vector->type, type_vector_length * sizeof (struct type *));
-
- /* Initialize the list of sub source files with one entry
- for this file (the top-level source file). */
-
- subfiles = 0;
- current_subfile = 0;
- start_subfile (name);
-
-#if 0 /* This is now set at the beginning of read_ofile_symtab */
- /* Set default for compiler to pcc; assume that we aren't processing
- a gcc compiled file until proved otherwise. */
-
- processing_gcc_compilation = 0;
-#endif
-}
-
-/* Handle an N_SOL symbol, which indicates the start of
- code that came from an included (or otherwise merged-in)
- source file with a different name. */
-
-static void
-start_subfile (name)
- char *name;
-{
- register struct subfile *subfile;
-
- /* Save the current subfile's line vector data. */
-
- if (current_subfile)
- {
- current_subfile->line_vector_index = line_vector_index;
- current_subfile->line_vector_length = line_vector_length;
- current_subfile->prev_line_number = prev_line_number;
- }
-
- /* See if this subfile is already known as a subfile of the
- current main source file. */
-
- for (subfile = subfiles; subfile; subfile = subfile->next)
- {
- if (!strcmp (subfile->name, name))
- {
- line_vector = subfile->line_vector;
- line_vector_index = subfile->line_vector_index;
- line_vector_length = subfile->line_vector_length;
- prev_line_number = subfile->prev_line_number;
- current_subfile = subfile;
- return;
- }
- }
-
- /* This subfile is not known. Add an entry for it. */
-
- line_vector_index = 0;
- line_vector_length = 1000;
- prev_line_number = -2; /* Force first line number to be explicit */
- line_vector = (struct linetable *)
- xxmalloc (sizeof (struct linetable)
- + line_vector_length * sizeof (struct linetable_entry));
-
- /* Make an entry for this subfile in the list of all subfiles
- of the current main source file. */
-
- subfile = (struct subfile *) xxmalloc (sizeof (struct subfile));
- subfile->next = subfiles;
- subfile->name = savestring (name, strlen (name));
- subfile->line_vector = line_vector;
- subfiles = subfile;
- current_subfile = subfile;
-}
-
-/* Finish the symbol definitions for one main source file,
- close off all the lexical contexts for that file
- (creating struct block's for them), then make the struct symtab
- for that file and put it in the list of all such.
-
- END_ADDR is the address of the end of the file's text. */
-
-static void
-end_symtab (end_addr)
- CORE_ADDR end_addr;
-{
- register struct symtab *symtab;
- register struct blockvector *blockvector;
- register struct subfile *subfile;
- register struct linetable *lv;
- struct subfile *nextsub;
-
- if (current_symseg != 0)
- {
- last_source_file = 0;
- current_symseg = 0;
- return;
- }
-
- /* Finish the lexical context of the last function in the file;
- pop the context stack. */
-
- if (context_stack_depth > 0)
- {
- register struct context_stack *cstk;
- context_stack_depth--;
- cstk = &context_stack[context_stack_depth];
- /* Make a block for the local symbols within. */
- finish_block (cstk->name, &local_symbols, cstk->old_blocks,
- cstk->start_addr, end_addr);
- }
-
- /* Cleanup any undefined types that have been left hanging around
- (this needs to be done before the finish_blocks so that
- file_symbols is still good). */
- cleanup_undefined_types ();
-
- /* Finish defining all the blocks of this symtab. */
- finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr);
- finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr);
- blockvector = make_blockvector ();
-
- current_subfile->line_vector_index = line_vector_index;
-
- /* Now create the symtab objects proper, one for each subfile. */
- /* (The main file is one of them.) */
-
- for (subfile = subfiles; subfile; subfile = nextsub)
- {
- symtab = (struct symtab *) xxmalloc (sizeof (struct symtab));
- symtab->free_ptr = 0;
-
- /* Fill in its components. */
- symtab->blockvector = blockvector;
- type_vector->length = type_vector_length;
- symtab->typevector = type_vector;
- symtab->free_code = free_linetable;
- if (subfile->next == 0)
- symtab->free_ptr = (char *) type_vector;
-
- symtab->filename = subfile->name;
- lv = subfile->line_vector;
- lv->nitems = subfile->line_vector_index;
- symtab->linetable = (struct linetable *)
- xrealloc (lv, (sizeof (struct linetable)
- + lv->nitems * sizeof (struct linetable_entry)));
- symtab->nlines = 0;
- symtab->line_charpos = 0;
-
- /* Link the new symtab into the list of such. */
- symtab->next = symtab_list;
- symtab_list = symtab;
-
- nextsub = subfile->next;
- free (subfile);
- }
-
- type_vector = 0;
- type_vector_length = -1;
- line_vector = 0;
- line_vector_length = -1;
- last_source_file = 0;
-}
-
-#ifdef N_BINCL
-
-/* Handle the N_BINCL and N_EINCL symbol types
- that act like N_SOL for switching source files
- (different subfiles, as we call them) within one object file,
- but using a stack rather than in an arbitrary order. */
-
-struct subfile_stack
-{
- struct subfile_stack *next;
- char *name;
- int prev_index;
-};
-
-struct subfile_stack *subfile_stack;
-
-static void
-push_subfile ()
-{
- register struct subfile_stack *tem
- = (struct subfile_stack *) xxmalloc (sizeof (struct subfile_stack));
-
- tem->next = subfile_stack;
- subfile_stack = tem;
- if (current_subfile == 0 || current_subfile->name == 0)
- abort ();
- tem->name = current_subfile->name;
- tem->prev_index = header_file_prev_index;
-}
-
-static char *
-pop_subfile ()
-{
- register char *name;
- register struct subfile_stack *link = subfile_stack;
-
- if (link == 0)
- abort ();
-
- name = link->name;
- subfile_stack = link->next;
- header_file_prev_index = link->prev_index;
- free (link);
-
- return name;
-}
-#endif /* Have N_BINCL */
-
-/* Accumulate the misc functions in bunches of 127.
- At the end, copy them all into one newly allocated structure. */
-
-#define MISC_BUNCH_SIZE 127
-
-struct misc_bunch
-{
- struct misc_bunch *next;
- struct misc_function contents[MISC_BUNCH_SIZE];
-};
-
-/* Bunch currently being filled up.
- The next field points to chain of filled bunches. */
-
-static struct misc_bunch *misc_bunch;
-
-/* Number of slots filled in current bunch. */
-
-static int misc_bunch_index;
-
-/* Total number of misc functions recorded so far. */
-
-static int misc_count;
-
-static void
-init_misc_functions ()
-{
- misc_count = 0;
- misc_bunch = 0;
- misc_bunch_index = MISC_BUNCH_SIZE;
-}
-
-static void
-record_misc_function (name, address, type)
- char *name;
- CORE_ADDR address;
- int type;
-{
- register struct misc_bunch *new;
- register unsigned char mtype;
-
- if (misc_bunch_index == MISC_BUNCH_SIZE)
- {
- new = (struct misc_bunch *) xxmalloc (sizeof (struct misc_bunch));
- misc_bunch_index = 0;
- new->next = misc_bunch;
- misc_bunch = new;
- }
- misc_bunch->contents[misc_bunch_index].name = name;
- misc_bunch->contents[misc_bunch_index].address = address;
- switch (type &~ N_EXT)
- {
- case N_TEXT: mtype = mf_text; break;
- case N_DATA: mtype = mf_data; break;
- case N_BSS: mtype = mf_bss; break;
- case N_ABS: mtype = mf_abs; break;
-#ifdef N_SETV
- case N_SETV: mtype = mf_data; break;
-#endif
- default: mtype = mf_unknown; break;
- }
- misc_bunch->contents[misc_bunch_index].type = mtype;
- misc_bunch_index++;
- misc_count++;
-}
-
-static int
-compare_misc_functions (fn1, fn2)
- struct misc_function *fn1, *fn2;
-{
- /* Return a signed result based on unsigned comparisons
- so that we sort into unsigned numeric order. */
- if (fn1->address < fn2->address)
- return -1;
- if (fn1->address > fn2->address)
- return 1;
- return 0;
-}
-
-static void
-discard_misc_bunches ()
-{
- register struct misc_bunch *next;
-
- while (misc_bunch)
- {
- next = misc_bunch->next;
- free (misc_bunch);
- misc_bunch = next;
- }
-}
-
-/* INCLINK nonzero means bunches are from an incrementally-linked file.
- Add them to the existing bunches.
- Otherwise INCLINK is zero, and we start from scratch. */
-static void
-condense_misc_bunches (inclink)
- int inclink;
-{
- register int i, j;
- register struct misc_bunch *bunch;
-#ifdef NAMES_HAVE_UNDERSCORE
- int offset = 1;
-#else
- int offset = 0;
-#endif
-
- if (inclink)
- {
- misc_function_vector
- = (struct misc_function *)
- xrealloc (misc_function_vector, (misc_count + misc_function_count)
- * sizeof (struct misc_function));
- j = misc_function_count;
- }
- else
- {
- misc_function_vector
- = (struct misc_function *)
- xxmalloc (misc_count * sizeof (struct misc_function));
- j = 0;
- }
-
- bunch = misc_bunch;
- while (bunch)
- {
- for (i = 0; i < misc_bunch_index; i++)
- {
- misc_function_vector[j] = bunch->contents[i];
- misc_function_vector[j].name
- = obconcat (misc_function_vector[j].name
- + (misc_function_vector[j].name[0] == '_' ? offset : 0),
- "", "");
- j++;
- }
- bunch = bunch->next;
- misc_bunch_index = MISC_BUNCH_SIZE;
- }
-
- if (inclink)
- misc_function_count += misc_count;
- else
- misc_function_count = j;
-
- /* Sort the misc functions by address. */
-
- qsort (misc_function_vector, misc_function_count,
- sizeof (struct misc_function),
- compare_misc_functions);
-
- /* (re)build the hash table (positions changed during the sort) */
-
- for (i = 0; i < MISC_FUNC_HASH_SIZE; ++i)
- misc_function_hash_tab[i] = -1;
- for (i = 0; i < misc_function_count; ++i)
- {
- j = hash_symbol(misc_function_vector[i].name) & (MISC_FUNC_HASH_SIZE - 1);
- misc_function_vector[i].next = misc_function_hash_tab[j];
- misc_function_hash_tab[j] = i;
- }
-}
-
-/* Call sort_syms to sort alphabetically
- the symbols of each block of each symtab. */
-
-static int
-compare_symbols (s1, s2)
- struct symbol **s1, **s2;
-{
- register int namediff;
-
- /* Compare the initial characters. */
- namediff = SYMBOL_NAME (*s1)[0] - SYMBOL_NAME (*s2)[0];
- if (namediff != 0) return namediff;
-
- /* If they match, compare the rest of the names. */
- namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2));
- if (namediff != 0) return namediff;
-
- /* For symbols of the same name, registers should come first. */
- return ((SYMBOL_CLASS (*s2) == LOC_REGISTER)
- - (SYMBOL_CLASS (*s1) == LOC_REGISTER));
-}
-
-static void sort_symtab_syms ();
-
-static void
-sort_syms ()
-{
- register struct symtab *s;
-
- for (s = symtab_list; s; s = s->next)
- sort_symtab_syms (s);
-}
-
-static void
-sort_symtab_syms (s)
- register struct symtab *s;
-{
- register struct blockvector *bv = BLOCKVECTOR (s);
- int nbl = BLOCKVECTOR_NBLOCKS (bv);
- int i;
- register struct block *b;
-
- /* Note that in the following sort, we always make sure that
- register debug symbol declarations always come before regular
- debug symbol declarations (as might happen when parameters are
- then put into registers by the compiler). We do this by a
- correct compare in compare_symbols, and by the reversal of the
- symbols if we don't sort. This works as long as a register debug
- symbol always comes after a parameter debug symbol. */
-
- /* This is no longer necessary; lookup_block_symbol now always
- prefers some other declaration over a parameter declaration. We
- still sort the thing (that is necessary), but we don't reverse it
- if we shouldn't sort it. */
-
- for (i = 0; i < nbl; i++)
- {
- b = BLOCKVECTOR_BLOCK (bv, i);
- if (BLOCK_SHOULD_SORT (b))
- qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b),
- sizeof (struct symbol *), compare_symbols);
- }
-}
-
-
-extern struct symtab *psymtab_to_symtab ();
-
-/* The entry point. */
-static CORE_ADDR entry_point;
-
-static char *symfile_string_table;
-static int symfile_string_table_size;
-
-/* This is the symbol-file command. Read the file, analyze its symbols,
- and add a struct symtab to symtab_list. */
-
-void
-symbol_file_command (name, from_tty)
- char *name;
- int from_tty;
-{
- register int desc;
- DECLARE_FILE_HEADERS;
- struct nlist *nlist;
-
- /* The string table. */
- char *stringtab;
-
- /* The size of the string table (buffer is a bizarre name...). */
- long buffer;
-
- register int val;
- extern void close ();
- struct cleanup *old_chain;
- struct symtab *symseg;
- struct stat statbuf;
-
- dont_repeat ();
-
- if (name == 0)
- {
- if ((symtab_list || partial_symtab_list)
- && from_tty
- && !query ("Discard symbol table? ", 0))
- error ("Not confirmed.");
- if (symfile)
- free (symfile);
- symfile = 0;
- free_all_symtabs ();
- free_all_psymtabs ();
- return;
- }
-
- name = tilde_expand (name);
- make_cleanup (free, name);
-
- if ((symtab_list || partial_symtab_list)
- && !query ("Load new symbol table from \"%s\"? ", name))
- error ("Not confirmed.");
-
- {
- char *absolute_name;
- desc = openp (getenv ("PATH"), 1, name, O_RDONLY, 0, &absolute_name);
- if (desc < 0)
- perror_with_name (name);
- else
- name = absolute_name;
- }
-
- old_chain = make_cleanup (close, desc);
- make_cleanup (free_current_contents, &name);
-
- READ_FILE_HEADERS (desc, name);
-
- entry_point = ENTRY_POINT;
-
- if (NUMBER_OF_SYMBOLS == 0)
- {
- if (symfile)
- free (symfile);
- symfile = 0;
- free_all_symtabs ();
- free_all_psymtabs ();
- printf ("%s has no symbol-table; symbols discarded.\n", name);
- fflush (stdout);
- do_cleanups (old_chain);
- return;
- }
-
- printf ("Reading symbol data from %s...", name);
- fflush (stdout);
-
- /* Now read the string table, all at once. */
- val = lseek (desc, STRING_TABLE_OFFSET, 0);
- if (val < 0)
- perror_with_name (name);
- if (stat (name, &statbuf) == -1)
- perror_with_name (name);
- READ_STRING_TABLE_SIZE (buffer);
- if (buffer >= 0 && buffer < statbuf.st_size)
- {
- /* This should speed things up without consuming much
- extra memory (because probably little of the space is going
- to be reused anyway, whether in data or stack space).
-
- A quick test (running GDB on itself and setting 9 breakpoints
- in different files) showed that memory usage was almost
- identical for the two cases. */
-#if 0
-#ifdef BROKEN_LARGE_ALLOCA
- stringtab = (char *) xmalloc (buffer);
- make_cleanup (free, stringtab);
-#else
- stringtab = (char *) alloca (buffer);
-#endif
-#endif
- stringtab = (char *) xmalloc (buffer);
- symfile_string_table = stringtab;
- symfile_string_table_size = buffer;
- }
- else
- stringtab = NULL;
- if (stringtab == NULL)
- error ("ridiculous string table size: %d bytes", buffer);
-
- /* Usually READ_STRING_TABLE_SIZE will have shifted the file pointer.
- Occaisionally, it won't. */
- val = lseek (desc, STRING_TABLE_OFFSET, L_SET);
- if (val < 0)
- perror_with_name (name);
- val = myread (desc, stringtab, buffer);
- if (val < 0)
- perror_with_name (name);
-
- /* Throw away the old symbol table. */
-
- if (symfile)
- free (symfile);
- symfile = 0;
- free_all_symtabs ();
- free_all_psymtabs ();
-
- /* Empty the hash table of global syms looking for values. */
- bzero (global_sym_chain, sizeof global_sym_chain);
-
- /* Symsegs are no longer supported by GDB. Setting symseg_chain to
- 0 is easier than finding all the symseg code and eliminating it. */
- symseg_chain = 0;
-
- /* Position to read the symbol table. Do not read it all at once. */
- val = lseek (desc, SYMBOL_TABLE_OFFSET, 0);
- if (val < 0)
- perror_with_name (name);
-
- /* Don't put these on the cleanup chain; they need to stick around
- until the next call to symbol_file_command. *Then* we'll free
- them. */
- free_header_files ();
- init_header_files ();
-
- init_misc_functions ();
- make_cleanup (discard_misc_bunches, 0);
-
- free_pendings = 0;
- pending_blocks = 0;
- file_symbols = 0;
- global_symbols = 0;
- make_cleanup (really_free_pendings, 0);
-
- /* Now that the symbol table data of the executable file are all in core,
- process them and define symbols accordingly. Closes desc. */
-
- read_dbx_symtab (desc, stringtab, buffer, NUMBER_OF_SYMBOLS, 0,
- ADDR_OF_TEXT_SEGMENT, SIZE_OF_TEXT_SEGMENT);
-
- /* Go over the misc functions and install them in vector. */
-
- condense_misc_bunches (0);
-
- /* Don't allow char * to have a typename (else would get caddr_t.) */
-
- TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
-
- /* Make a default for file to list. */
-
- symfile = savestring (name, strlen (name));
-
- /* Call to select_source_symtab used to be here; it was using too
- much time. I'll make sure that list_sources can handle the lack
- of current_source_symtab */
-
- do_cleanups (old_chain); /* Descriptor closed here */
-
- /* Free the symtabs made by read_symsegs, but not their contents,
- which have been copied into symtabs on symtab_list. */
- while (symseg_chain)
- {
- register struct symtab *s = symseg_chain->next;
- free (symseg_chain);
- symseg_chain = s;
- }
-
- if (!partial_symtab_list)
- printf ("\n(no debugging symbols found)...");
-
- printf ("done.\n");
- fflush (stdout);
-}
-
-/* Return name of file symbols were loaded from, or 0 if none.. */
-
-char *
-get_sym_file ()
-{
- return symfile;
-}
-
-/* Buffer for reading the symbol table entries. */
-static struct nlist symbuf[4096];
-static int symbuf_idx;
-static int symbuf_end;
-
-/* I/O descriptor for reading the symbol table. */
-static int symtab_input_desc;
-
-/* The address of the string table
- of the object file we are reading (as copied into core). */
-static char *stringtab_global;
-
-/* Refill the symbol table input buffer
- and set the variables that control fetching entries from it.
- Reports an error if no data available.
- This function can read past the end of the symbol table
- (into the string table) but this does no harm. */
-
-static int
-fill_symbuf ()
-{
- int nbytes = myread (symtab_input_desc, symbuf, sizeof (symbuf));
- if (nbytes <= 0)
- error ("error or end of file reading symbol table");
- symbuf_end = nbytes / sizeof (struct nlist);
- symbuf_idx = 0;
- return 1;
-}
-
-/* dbx allows the text of a symbol name to be continued into the
- next symbol name! When such a continuation is encountered
- (a \ at the end of the text of a name)
- call this function to get the continuation. */
-
-static char *
-next_symbol_text ()
-{
- if (symbuf_idx == symbuf_end)
- fill_symbuf ();
- symnum++;
- return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global;
-}
-
-/*
- * Initializes storage for all of the partial symbols that will be
- * created by read_dbx_symtab and subsidiaries.
- */
-void
-init_psymbol_list (total_symbols)
- int total_symbols;
-{
- /* Current best guess is that there are approximately a twentieth
- of the total symbols (in a debugging file) are global or static
- oriented symbols */
- global_psymbols.size = total_symbols / 10;
- static_psymbols.size = total_symbols / 10;
- global_psymbols.next = global_psymbols.list = (struct partial_symbol *)
- xmalloc (global_psymbols.size * sizeof (struct partial_symbol));
- static_psymbols.next = static_psymbols.list = (struct partial_symbol *)
- xmalloc (static_psymbols.size * sizeof (struct partial_symbol));
-}
-
-/*
- * Initialize the list of bincls to contain none and have some
- * allocated.
- */
-static void
-init_bincl_list (number)
- int number;
-{
- bincls_allocated = number;
- next_bincl = bincl_list = (struct header_file_location *)
- xmalloc (bincls_allocated * sizeof(struct header_file_location));
-}
-
-/*
- * Add a bincl to the list.
- */
-static void
-add_bincl_to_list (pst, name, instance)
- struct partial_symtab *pst;
- char *name;
- int instance;
-{
- if (next_bincl >= bincl_list + bincls_allocated)
- {
- int offset = next_bincl - bincl_list;
- bincls_allocated *= 2;
- bincl_list = (struct header_file_location *)
- xrealloc (bincl_list,
- bincls_allocated * sizeof (struct header_file_location));
- next_bincl = bincl_list + offset;
- }
- next_bincl->pst = pst;
- next_bincl->instance = instance;
- next_bincl++->name = name;
-}
-
-/*
- * Given a name, value pair, find the corresponding
- * bincl in the list. Return the partial symtab associated
- * with that header_file_location.
- */
-struct partial_symtab *
-find_corresponding_bincl_psymtab (name, instance)
- char *name;
- int instance;
-{
- struct header_file_location *bincl;
-
- for (bincl = bincl_list; bincl < next_bincl; bincl++)
- if (bincl->instance == instance
- && !strcmp (name, bincl->name))
- return bincl->pst;
-
- return (struct partial_symtab *) 0;
-}
-
-/*
- * Free the storage allocated for the bincl list.
- */
-static void
-free_bincl_list ()
-{
- free (bincl_list);
- bincls_allocated = 0;
-}
-
-static struct partial_symtab *start_psymtab ();
-static void add_psymtab_dependency ();
-static void end_psymtab();
-
-static int
-compare_psymbols (s1, s2)
- register struct partial_symbol *s1, *s2;
-{
- register char
- *st1 = SYMBOL_NAME (s1),
- *st2 = SYMBOL_NAME (s2);
- register int i;
-
- if (st1[0] - st2[0])
- return (st1[0] - st2[0]);
- if (st1[1] - st2[1])
- return (st1[1] - st2[1]);
- if (i = strcmp(st1, st2))
- return (i);
- /* Next comparison implements policy that used to be in lookup_symbol:
- * it would search psymtabs in psymtab_list order (reverse order of
- * declaration) & take first occurance of symbol it found. So, we
- * collate duplicate names in reverse psymtab order. */
- return (s2->pst - s1->pst);
-}
-
-/* Given pointers to an a.out symbol table in core containing dbx
- style data, setup partial_symtab's describing each source file for
- which debugging information is available. NLISTLEN is the number
- of symbols in the symbol table. All symbol names are given as
- offsets relative to STRINGTAB. STRINGTAB_SIZE is the size of
- STRINGTAB.
-
- I have no idea whether or not this routine should be setup to deal
- with inclinks. It seems reasonable to me that they be dealt with
- standardly, so I am not going to make a strong effort to deal with
- them here.
- */
-
-static void
-read_dbx_symtab (desc, stringtab, stringtab_size, nlistlen, inclink,
- text_addr, text_size)
- int desc;
- register char *stringtab;
- register long stringtab_size;
- register int nlistlen;
- int inclink;
- unsigned text_addr;
- int text_size;
-{
- register struct nlist *bufp;
- register char *namestring;
- register struct partial_symbol *psym;
- register struct psymbol_allocation_list *psymbol_struct;
-
- int nsl;
- int past_first_source_file = 0;
- CORE_ADDR last_o_file_start = 0;
- char *last_o_file_name = "*bogus*";
- struct cleanup *old_chain;
- char *p;
- enum namespace ns;
- enum address_class class;
-
-#ifdef PROFILE_TYPES
- int i;
- int profile_types [256];
- int strcmp_called = 0;
- int autovars = 0;
- int global_funs = 0;
-#endif
-
- /* Current partial symtab */
- struct partial_symtab *pst;
-
- /* List of current psymtab's include files */
- char **psymtab_include_list;
- int includes_allocated;
- int includes_used;
-
- /* Index within current psymtab dependency list */
- struct partial_symtab **dependency_list;
- int dependencies_used, dependencies_allocated;
-
-#ifdef PROFILE_TYPES
- for (i = 0; i < 256; i++)
- profile_types[i] = 0;
-#endif
-
- stringtab_global = stringtab;
-
- pst = (struct partial_symtab *) 0;
-
- includes_allocated = 30;
- includes_used = 0;
- psymtab_include_list = (char **) alloca (includes_allocated *
- sizeof (char *));
-
- dependencies_allocated = 30;
- dependencies_used = 0;
- dependency_list =
- (struct partial_symtab **) alloca (dependencies_allocated *
- sizeof (struct partial_symtab *));
-
- old_chain = make_cleanup (free_all_psymtabs, 0);
-
- /* Init bincl list */
- init_bincl_list (20);
- make_cleanup (free_bincl_list, 0);
-
- /* Setup global partial symbol list */
- init_psymbol_list (nlistlen);
-
- last_source_file = 0;
-
-#ifdef END_OF_TEXT_DEFAULT
- end_of_text_addr = END_OF_TEXT_DEFAULT;
-#else
- end_of_text_addr = text_addr + text_size;
-#endif
-
- symtab_input_desc = desc; /* This is needed for fill_symbuf below */
- symbuf_end = symbuf_idx = 0;
-
- for (symnum = 0; symnum < nlistlen; symnum++)
- {
- /* Get the symbol for this run and pull out some info */
- QUIT; /* allow this to be interruptable */
- if (symbuf_idx == symbuf_end)
- fill_symbuf ();
- bufp = &symbuf[symbuf_idx++];
-
-#ifdef PROFILE_TYPES
- profile_types[bufp->n_type]++;
-#endif
-
- /*
- * Special case to speed up readin.
- */
- if (bufp->n_type == N_SLINE) continue;
-
- /* Ok. There is a lot of code duplicated in the rest of this
- switch statiement (for efficiency reasons). Since I don't
- like duplicating code, I will do my penance here, and
- describe the code which is duplicated:
-
- *) The assignment to namestring.
- *) The call to index.
- *) The addition of a partial symbol the the two partial
- symbol lists. This last is a large section of code, so
- I've imbedded it in the following macro.
- */
-
-/* Set namestring based on bufp. */
-#define SET_NAMESTRING()\
- if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) \
- error ("Invalid symbol data: bad string table offset: %d", \
- bufp->n_un.n_strx); \
- namestring = bufp->n_un.n_strx + stringtab
-
-#define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE)\
- do { \
- if ((LIST).next >= \
- (LIST).list + (LIST).size) \
- { \
- (LIST).list = (struct partial_symbol *) \
- xrealloc ((LIST).list, \
- ((LIST).size * 2 \
- * sizeof (struct partial_symbol))); \
- /* Next assumes we only went one over. Should be good if \
- program works correctly */ \
- (LIST).next = \
- (LIST).list + (LIST).size; \
- (LIST).size *= 2; \
- } \
- psym = (LIST).next++; \
- \
- SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, \
- (NAMELENGTH) + 1); \
- strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \
- SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \
- SYMBOL_NAMESPACE (psym) = (NAMESPACE); \
- SYMBOL_CLASS (psym) = (CLASS); \
- SYMBOL_VALUE (psym) = (VALUE); \
- } while (0);
-
-
- switch (bufp->n_type)
- {
- /*
- * Standard, non-debugger, symbols
- */
-
- case N_TEXT | N_EXT:
- /* Catch etext */
-
- SET_NAMESTRING();
-
- if (namestring[6] == '\0' && namestring[5] == 't'
- && namestring[4] == 'x' && namestring[3] == 'e'
- && namestring[2] == 't' && namestring[1] == 'e'
- && namestring[0] == '_')
- end_of_text_addr = bufp->n_value;
-
- /* Figure out beginning and end of global linker symbol
- section and put non-debugger specified symbols on
- tmp_symchain */
-
- last_global_sym = symnum;
- if (!first_global_sym) first_global_sym = symnum;
-
- record_misc_function (namestring, bufp->n_value,
- bufp->n_type); /* Always */
-
- continue;
-
-#ifdef N_NBTEXT
- case N_NBTEXT | N_EXT:
-#endif
-#ifdef N_NBDATA
- case N_NBDATA | N_EXT:
-#endif
-#ifdef N_NBBSS
- case N_NBBSS | N_EXT:
-#endif
-#ifdef N_SETV
- case N_SETV | N_EXT:
-#endif
- case N_ABS | N_EXT:
- case N_DATA | N_EXT:
- case N_BSS | N_EXT:
- /* Figure out beginning and end of global linker symbol
- section and put non-debugger specified symbols on
- tmp_symchain */
-
- SET_NAMESTRING();
-
- last_global_sym = symnum;
- if (!first_global_sym) first_global_sym = symnum;
-
- /* Not really a function here, but... */
- record_misc_function (namestring, bufp->n_value,
- bufp->n_type); /* Always */
-
- continue;
-
-#ifdef N_NBTEXT
- case N_NBTEXT:
-#endif
-
- /* We need to be able to deal with both N_FN or N_TEXT,
- because we have no way of knowing whether the sys-supplied ld
- or GNU ld was used to make the executable. */
-#if ! (N_FN & N_EXT)
- case N_FN:
-#endif
- case N_FN | N_EXT:
- case N_TEXT:
- SET_NAMESTRING();
- if ((namestring[0] == '-' && namestring[1] == 'l')
- || (namestring [(nsl = strlen (namestring)) - 1] == 'o'
- && namestring [nsl - 2] == '.'))
- {
- if (entry_point < bufp->n_value
- && entry_point >= last_o_file_start)
- {
- startup_file_start = last_o_file_start;
- startup_file_end = bufp->n_value;
- }
- if (past_first_source_file && pst)
- {
- end_psymtab (pst, psymtab_include_list, includes_used,
- symnum * sizeof (struct nlist), bufp->n_value,
- dependency_list, dependencies_used,
- global_psymbols.next, static_psymbols.next);
- pst = (struct partial_symtab *) 0;
- includes_used = 0;
- dependencies_used = 0;
- }
- else
- past_first_source_file = 1;
- last_o_file_start = bufp->n_value;
- last_o_file_name = namestring;
- nsl = strlen(namestring);
- if (namestring[nsl-2] == '.' && namestring[nsl-1] == 'o')
- namestring[nsl-2] = 0;
- }
- else if (strcmp(namestring, "gcc_compiled."))
- {
- if (*namestring == '_')
- ++namestring;
- namestring = obconcat(last_o_file_name, ":", namestring);
- last_global_sym = symnum;
- if (!first_global_sym)
- first_global_sym = symnum;
- record_misc_function(namestring, bufp->n_value, bufp->n_type);
- }
- continue;
-
- case N_ABS:
- case N_DATA:
- case N_BSS:
- SET_NAMESTRING();
- if (*namestring == '_')
- ++namestring;
- namestring = obconcat(last_o_file_name, ":", namestring);
- last_global_sym = symnum;
- if (!first_global_sym)
- first_global_sym = symnum;
- record_misc_function(namestring, bufp->n_value, bufp->n_type);
- continue;
-
- case N_UNDF:
- case N_UNDF | N_EXT:
-#ifdef N_NBDATA
- case N_NBDATA:
-#endif
-#ifdef N_NBBSS
- case N_NBBSS:
-#endif
-
- /* Keep going . . .*/
-
- /*
- * Special symbol types for GNU
- */
-#ifdef N_INDR
- case N_INDR:
- case N_INDR | N_EXT:
-#endif
-#ifdef N_SETA
- case N_SETA:
- case N_SETA | N_EXT:
- case N_SETT:
- case N_SETT | N_EXT:
- case N_SETD:
- case N_SETD | N_EXT:
- case N_SETB:
- case N_SETB | N_EXT:
- case N_SETV:
-#endif
- continue;
-
- /*
- * Debugger symbols
- */
-
- case N_SO:
- /* End the current partial symtab and start a new one */
-
- SET_NAMESTRING();
-
- if (pst && past_first_source_file)
- {
- end_psymtab (pst, psymtab_include_list, includes_used,
- symnum * sizeof (struct nlist), bufp->n_value,
- dependency_list, dependencies_used,
- global_psymbols.next, static_psymbols.next);
- pst = (struct partial_symtab *) 0;
- includes_used = 0;
- dependencies_used = 0;
- }
- else
- past_first_source_file = 1;
-
- pst = start_psymtab (namestring, bufp->n_value,
- symnum * sizeof (struct nlist),
- global_psymbols.next, static_psymbols.next);
-
- continue;
-
-#ifdef N_BINCL
- case N_BINCL:
- /* Add this bincl to the bincl_list for future EXCLs. No
- need to save the string; it'll be around until
- read_dbx_symtab function return */
-
- SET_NAMESTRING();
-
- add_bincl_to_list (pst, namestring, bufp->n_value);
-
- /* Mark down an include file in the current psymtab */
-
- psymtab_include_list[includes_used++] = namestring;
- if (includes_used >= includes_allocated)
- {
- char **orig = psymtab_include_list;
-
- psymtab_include_list = (char **)
- alloca ((includes_allocated *= 2) *
- sizeof (char *));
- bcopy (orig, psymtab_include_list,
- includes_used * sizeof (char *));
- }
-
- continue;
-#endif
-
- case N_SOL:
- /* Mark down an include file in the current psymtab */
-
- SET_NAMESTRING();
-
- /* In C++, one may expect the same filename to come round many
- times, when code is coming alternately from the main file
- and from inline functions in other files. So I check to see
- if this is a file we've seen before.
-
- This seems to be a lot of time to be spending on N_SOL, but
- things like "break expread.y:435" need to work (I
- suppose the psymtab_include_list could be hashed or put
- in a binary tree, if profiling shows this is a major hog). */
- {
- register int i;
- for (i = 0; i < includes_used; i++)
- if (!strcmp (namestring, psymtab_include_list[i]))
- {
- i = -1;
- break;
- }
- if (i == -1)
- continue;
- }
-
- psymtab_include_list[includes_used++] = namestring;
- if (includes_used >= includes_allocated)
- {
- char **orig = psymtab_include_list;
-
- psymtab_include_list = (char **)
- alloca ((includes_allocated *= 2) *
- sizeof (char *));
- bcopy (orig, psymtab_include_list,
- includes_used * sizeof (char *));
- }
- continue;
-
- case N_LSYM: /* Typedef or automatic variable. */
- SET_NAMESTRING();
-
- p = (char *) index (namestring, ':');
-
- /* Skip if there is no :. */
- if (!p) continue;
-
- switch (p[1])
- {
- case 'T':
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- STRUCT_NAMESPACE, LOC_TYPEDEF,
- static_psymbols, bufp->n_value);
- goto check_enum;
- case 't':
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_TYPEDEF,
- static_psymbols, bufp->n_value);
- check_enum:
- /* If this is an enumerated type, we need to
- add all the enum constants to the partial symbol
- table. This does not cover enums without names, e.g.
- "enum {a, b} c;" in C, but fortunately those are
- rare. There is no way for GDB to find those from the
- enum type without spending too much time on it. Thus
- to solve this problem, the compiler needs to put out separate
- constant symbols ('c' N_LSYMS) for enum constants in
- enums without names. */
-
- /* We are looking for something of the form
- <name> ":" ("t" | "T") [<number> "="] "e"
- {<constant> ":" <value> ","} ";". */
-
- /* Skip over the colon and the 't' or 'T'. */
- p += 2;
- /* This type may be given a number. Skip over it. */
- while ((*p >= '0' && *p <= '9')
- || *p == '=')
- p++;
-
- if (*p++ == 'e')
- {
- /* We have found an enumerated type. */
- /* According to comments in read_enum_type
- a comma could end it instead of a semicolon.
- I don't know where that happens.
- Accept either. */
- while (*p && *p != ';' && *p != ',')
- {
- char *q;
-
- /* Check for and handle cretinous dbx symbol name
- continuation! */
- if (*p == '\\')
- p = next_symbol_text ();
-
- /* Point to the character after the name
- of the enum constant. */
- for (q = p; *q && *q != ':'; q++)
- ;
- /* Note that the value doesn't matter for
- enum constants in psymtabs, just in symtabs. */
- ADD_PSYMBOL_TO_LIST (p, q - p,
- VAR_NAMESPACE, LOC_CONST,
- static_psymbols, 0);
- /* Point past the name. */
- p = q;
- /* Skip over the value. */
- while (*p && *p != ',')
- p++;
- /* Advance past the comma. */
- if (*p)
- p++;
- }
- }
-
- continue;
- case 'c':
- /* Constant, e.g. from "const" in Pascal. */
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_CONST,
- static_psymbols, bufp->n_value);
- continue;
- default:
-#ifdef PROFILE_TYPES
- if (isalpha(p[1]))
- printf ("Funny...LSYM with a letter that isn't a type\n");
- autovars++;
-#endif
- /* Skip if the thing following the : is
- not a letter (which indicates declaration of a local
- variable, which we aren't interested in). */
- continue;
- }
-
- case N_FUN:
-#if 0
- /* This special-casing of N_FUN is just wrong; N_FUN
- does not mean "function"; it means "text segment".
- So N_FUN can go with 'V', etc. as well as 'f' or 'F'. */
-
- SET_NAMESTRING();
-
- p = (char *) index (namestring, ':');
-
- if (!p || p[1] == 'F') continue;
-
-#ifdef PROFILE_TYPES
- if (p[1] != 'f')
- printf ("Funny...FUN with a letter that isn't 'F' or 'f'.\n");
- global_funs++;
-#endif
-
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_BLOCK,
- static_psymbols, bufp->n_value);
-
- continue;
-#endif /* 0 */
- case N_GSYM: /* Global (extern) variable; can be
- data or bss (sigh). */
- case N_STSYM: /* Data seg var -- static */
- case N_LCSYM: /* BSS " */
-
- /* Following may probably be ignored; I'll leave them here
- for now (until I do Pascal and Modula 2 extensions). */
-
- case N_PC: /* I may or may not need this; I
- suspect not. */
-#ifdef N_M2C
- case N_M2C: /* I suspect that I can ignore this here. */
- case N_SCOPE: /* Same. */
-#endif
-
- SET_NAMESTRING();
-
- p = (char *) index (namestring, ':');
- if (!p)
- continue; /* Not a debugging symbol. */
-
- process_symbol_for_psymtab:
-
- /* Main processing section for debugging symbols which
- the initial read through the symbol tables needs to worry
- about. If we reach this point, the symbol which we are
- considering is definitely one we are interested in.
- p must also contain the (valid) index into the namestring
- which indicates the debugging type symbol. */
-
- switch (p[1])
- {
- case 'c':
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_CONST,
- static_psymbols, bufp->n_value);
- continue;
- case 'S':
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_STATIC,
- static_psymbols, bufp->n_value);
- continue;
- case 'G':
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_EXTERNAL,
- global_psymbols, bufp->n_value);
- continue;
-
- case 't':
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_TYPEDEF,
- global_psymbols, bufp->n_value);
- continue;
-
- case 'f':
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_BLOCK,
- static_psymbols, bufp->n_value);
- continue;
-
- /* Two things show up here (hopefully); static symbols of
- local scope (static used inside braces) or extensions
- of structure symbols. We can ignore both. */
- case 'V':
- case '(':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- /* Global functions are ignored here. I'm not
- sure what psymtab they go into (or just the misc
- function vector). */
- case 'F':
- continue;
-
- default:
- fatal ("Internal error: Unexpected debugging symbol type '%c' at symnum %d.\n",
- p[1], symnum);
- }
-
-#ifdef N_BINCL
- case N_EXCL:
-
- SET_NAMESTRING();
-
- /* Find the corresponding bincl and mark that psymtab on the
- psymtab dependency list */
- {
- struct partial_symtab *needed_pst =
- find_corresponding_bincl_psymtab (namestring, bufp->n_value);
-
- /* If this include file was defined earlier in this file,
- leave it alone. */
- if (needed_pst == pst) continue;
-
- if (needed_pst)
- {
- int i;
- int found = 0;
-
- for (i = 0; i < dependencies_used; i++)
- if (dependency_list[i] == needed_pst)
- {
- found = 1;
- break;
- }
-
- /* If it's already in the list, skip the rest. */
- if (found) continue;
-
- dependency_list[dependencies_used++] = needed_pst;
- if (dependencies_used >= dependencies_allocated)
- {
- struct partial_symtab **orig = dependency_list;
- dependency_list =
- (struct partial_symtab **)
- alloca ((dependencies_allocated *= 2)
- * sizeof (struct partial_symtab *));
- bcopy (orig, dependency_list,
- (dependencies_used
- * sizeof (struct partial_symtab *)));
-#ifdef DEBUG_INFO
- fprintf (stderr, "Had to reallocate dependency list.\n");
- fprintf (stderr, "New dependencies allocated: %d\n",
- dependencies_allocated);
-#endif
- }
- }
- else
- error ("Invalid symbol data: \"repeated\" header file not previously seen, at symtab pos %d.",
- symnum);
- }
- continue;
-
- case N_EINCL:
-#endif
-#ifdef N_DSLINE
- case N_DSLINE:
-#endif
-#ifdef N_BSLINE
- case N_BSLINE:
-#endif
- case N_SSYM: /* Claim: Structure or union element.
- Hopefully, I can ignore this. */
- case N_ENTRY: /* Alternate entry point; can ignore. */
-#ifdef N_MAIN
- case N_MAIN: /* Can definitely ignore this. */
-#endif
- case N_LENG:
- case N_BCOMM:
- case N_ECOMM:
- case N_ECOML:
- case N_FNAME:
- case N_SLINE:
- case N_RSYM:
- case N_PSYM:
- case N_LBRAC:
- case N_RBRAC:
- /* These symbols aren't interesting; don't worry about them */
-
- continue;
-
- default:
- /* If we haven't found it yet, we've got problems */
-
- if (IGNORE_SYMBOL (bufp->n_type))
- continue;
-
- fatal ("Bad symbol type 0x%x encountered in gdb scan", bufp->n_type);
- }
- }
-
- /* If there's stuff to be cleaned up, clean it up. */
- if (entry_point < bufp->n_value
- && entry_point >= last_o_file_start)
- {
- startup_file_start = last_o_file_start;
- startup_file_end = bufp->n_value;
- }
-
- if (pst)
- {
- end_psymtab (pst, psymtab_include_list, includes_used,
- symnum * sizeof (struct nlist), end_of_text_addr,
- dependency_list, dependencies_used,
- global_psymbols.next, static_psymbols.next);
- includes_used = 0;
- dependencies_used = 0;
- pst = (struct partial_symtab *) 0;
- }
-
- /* sort the global & static symtab list so we can binary search them */
- qsort (global_psymbols.list, global_psymbols.next - global_psymbols.list,
- sizeof (struct partial_symbol), compare_psymbols);
- qsort (static_psymbols.list, static_psymbols.next - static_psymbols.list,
- sizeof (struct partial_symbol), compare_psymbols);
- free_bincl_list ();
- discard_cleanups (old_chain);
-#ifdef PROFILE_TYPES
- {
- int i, j;
-#define __define_stab(SYM, NUMBER, NAME) {NUMBER, NAME},
- static struct xyzzy {
- unsigned char symnum;
- char *name;
- } tmp_list[] = {
-#include "stab.def"
- {0x1, "eREF"},
- {0x2, "ABS"},
- {0x3, "eABS"},
- {0x4, "TEXT"},
- {0x5, "eTEXT"},
- {0x6, "DATA"},
- {0x7, "eDATA"},
- {0x8, "BSS"},
- {0x9, "eBSS"},
- {0x12, "COMM"},
- {0x13, "eCOMM"},
- {0x1f, "FN"},
- {0, "Unknown"},
-};
- for (i = 0; i < 256; i++)
- {
- for (j = 0; j < (sizeof (tmp_list) / sizeof (struct xyzzy)) - 1; j++)
- if (tmp_list[j].symnum == i)
- break;
- printf ("Symbol \"%s\" (0x%x) occured %d times.\n",
- tmp_list[j].name, i, profile_types[i]);
- }
- printf ("Auto vars (under LSYM): %d\n", autovars);
- printf ("Global funs (under FUN): %d\n", global_funs);
- }
-#endif
-}
-
-/*
- * Allocate and partially fill a partial symtab. It will be
- * completely filled at the end of the symbol list.
- */
-static struct partial_symtab *
-start_psymtab (filename, textlow, ldsymoff, global_syms, static_syms)
- char *filename;
- int textlow;
- int ldsymoff;
- struct partial_symbol *global_syms;
- struct partial_symbol *static_syms;
-{
- struct partial_symtab *result =
- (struct partial_symtab *) obstack_alloc (psymbol_obstack,
- sizeof (struct partial_symtab));
-
- result->filename =
- (char *) obstack_alloc (psymbol_obstack,
- strlen (filename) + 1);
- strcpy (result->filename, filename);
-
- result->textlow = textlow;
- result->ldsymoff = ldsymoff;
-
- result->readin = 0;
-
- result->globals_offset = global_syms - global_psymbols.list;
- result->statics_offset = static_syms - static_psymbols.list;
-
- result->n_global_syms = 0;
- result->n_static_syms = 0;
-
- return result;
-}
-
-
-/* Close off the current usage of a partial_symbol table entry. This
- involves setting the correct number of includes (with a realloc),
- setting the high text mark, setting the symbol length in the
- executable, and setting the length of the global and static lists
- of psymbols.
-
- The global symbols and static symbols are then seperately sorted.
-
- Then the partial symtab is put on the global list.
- *** List variables and peculiarities of same. ***
- */
-static void
-end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
- capping_text, dependency_list, number_dependencies,
- capping_global, capping_static)
- struct partial_symtab *pst;
- char **include_list;
- int num_includes;
- int capping_symbol_offset;
- int capping_text;
- struct partial_symtab **dependency_list;
- int number_dependencies;
- struct partial_symbol *capping_global, *capping_static;
-{
- int i;
- register struct partial_symbol *ps;
-
- pst->ldsymlen = capping_symbol_offset - pst->ldsymoff;
- pst->texthigh = capping_text;
-
- pst->n_global_syms =
- capping_global - (global_psymbols.list + pst->globals_offset);
- pst->n_static_syms =
- capping_static - (static_psymbols.list + pst->statics_offset);
-
- pst->dependencies = (struct partial_symtab **)
- obstack_alloc (psymbol_obstack,
- number_dependencies * sizeof (struct partial_symtab *));
- bcopy (dependency_list, pst->dependencies,
- number_dependencies * sizeof (struct partial_symtab *));
- pst->number_of_dependencies = number_dependencies;
-
- for (i = 0; i < num_includes; i++)
- {
- /* Eventually, put this on obstack */
- struct partial_symtab *subpst =
- (struct partial_symtab *)
- obstack_alloc (psymbol_obstack,
- sizeof (struct partial_symtab));
-
- subpst->filename =
- (char *) obstack_alloc (psymbol_obstack,
- strlen (include_list[i]) + 1);
- strcpy (subpst->filename, include_list[i]);
-
- subpst->ldsymoff =
- subpst->ldsymlen =
- subpst->textlow =
- subpst->texthigh = 0;
- subpst->readin = 0;
-
- subpst->dependencies = (struct partial_symtab **)
- obstack_alloc (psymbol_obstack,
- sizeof (struct partial_symtab *));
- subpst->dependencies[0] = pst;
- subpst->number_of_dependencies = 1;
-
- subpst->globals_offset =
- subpst->n_global_syms =
- subpst->statics_offset =
- subpst->n_static_syms = 0;
-
- subpst->next = partial_symtab_list;
- partial_symtab_list = subpst;
- }
-
- for (ps = global_psymbols.list + pst->globals_offset;
- ps < capping_global; ++ps)
- ps->pst = pst;
- for (ps = static_psymbols.list + pst->statics_offset;
- ps < capping_static; ++ps)
- ps->pst = pst;
-
- /* Put the psymtab on the psymtab list */
- pst->next = partial_symtab_list;
- partial_symtab_list = pst;
-}
-
-
-/* Helper routines for psymtab_to_symtab. */
-static void scan_file_globals ();
-static void read_ofile_symtab ();
-
-static void
-psymtab_to_symtab_1 (pst, desc, stringtab, stringtab_size, sym_offset)
- struct partial_symtab *pst;
- int desc;
- char *stringtab;
- int stringtab_size;
- int sym_offset;
-{
- struct cleanup *old_chain;
- int i;
-
- if (!pst)
- return;
-
- if (pst->readin)
- {
- fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
- pst->filename);
- return;
- }
-
- /* Read in all partial symbtabs on which this one is dependent */
- for (i = 0; i < pst->number_of_dependencies; i++)
- if (!pst->dependencies[i]->readin)
- {
- /* Inform about additional files that need to be read in. */
- if (info_verbose)
- {
- printf_filtered (" and %s...", pst->dependencies[i]->filename);
- fflush (stdout);
- }
- psymtab_to_symtab_1 (pst->dependencies[i], desc,
- stringtab, stringtab_size, sym_offset);
- }
-
- if (pst->ldsymlen) /* Otherwise it's a dummy */
- {
- /* Init stuff necessary for reading in symbols */
- free_pendings = 0;
- pending_blocks = 0;
- file_symbols = 0;
- global_symbols = 0;
- old_chain = make_cleanup (really_free_pendings, 0);
-
- /* Read in this files symbols */
- lseek (desc, sym_offset, L_SET);
- read_ofile_symtab (desc, stringtab, stringtab_size,
- pst->ldsymoff,
- pst->ldsymlen, pst->textlow,
- pst->texthigh - pst->textlow, 0);
- sort_symtab_syms (symtab_list); /* At beginning since just added */
-
- do_cleanups (old_chain);
- }
-
- pst->readin = 1;
-}
-
-/*
- * Read in all of the symbols for a given psymtab for real. Return
- * the value of the symtab you create. Do not free the storage
- * allocated to the psymtab; it may have pointers to it.
- */
-struct symtab *
-psymtab_to_symtab(pst)
- struct partial_symtab *pst;
-{
- int desc;
- DECLARE_FILE_HEADERS;
- char *stringtab;
- struct partial_symtab **list_patch;
- int stsize, val;
- struct stat statbuf;
- struct cleanup *old_chain;
- extern void close ();
- int i;
- struct symtab *result;
- char *name = symfile; /* Some of the macros require the */
- /* variable "name" to be defined in */
- /* the context in which they execute */
- /* (Yech!) */
-
- if (!pst)
- return 0;
-
- if (pst->readin)
- {
- fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
- pst->filename);
- return 0;
- }
-
- if (!name)
- error("No symbol file currently specified; use command symbol-file");
-
- if (pst->ldsymlen || pst->number_of_dependencies)
- {
- /* Print the message now, before reading the string table,
- to avoid disconcerting pauses. */
- if (info_verbose)
- {
- printf_filtered ("Reading in symbols for %s...", pst->filename);
- fflush (stdout);
- }
-
- /* Open symbol file and read in string table */
- if (stat (name, &statbuf) < 0)
- perror_with_name (name);
- desc = open(name, O_RDONLY, 0); /* symbol_file_command
- guarrantees that the symbol file name
- will be absolute, so there is no
- need for openp */
-
- old_chain = make_cleanup (close, desc);
-
- if (desc < 0)
- error("Symbol file not readable");
-
- READ_FILE_HEADERS (desc, name);
-
-#if 0
- /* Read in the string table */
- lseek (desc, STRING_TABLE_OFFSET, L_SET);
- READ_STRING_TABLE_SIZE (stsize);
- if (stsize >= 0 && stsize < statbuf.st_size)
- {
-#ifdef BROKEN_LARGE_ALLOCA
- stringtab = (char *) xmalloc (stsize);
- make_cleanup (free, stringtab);
-#else
- stringtab = (char *) alloca (stsize);
-#endif
- }
- else
- stringtab = NULL;
- if (stringtab == NULL)
- error ("ridiculous string table size: %d bytes", stsize);
-
- /* Usually READ_STRING_TABLE_SIZE will have shifted the file pointer.
- Occaisionally, it won't. */
- val = lseek (desc, STRING_TABLE_OFFSET, L_SET);
- if (val < 0)
- perror_with_name (name);
- val = myread (desc, stringtab, stsize);
- if (val < 0)
- perror_with_name (name);
-#endif /* 0 */
- stringtab = symfile_string_table;
- stsize = symfile_string_table_size;
-
- psymtab_to_symtab_1 (pst, desc, stringtab, stsize,
- SYMBOL_TABLE_OFFSET);
-
- /* Match with global symbols. This only needs to be done once,
- after all of the symtabs and dependencies have been read in. */
- scan_file_globals ();
-
- do_cleanups (old_chain);
-
- /* Finish up the debug error message. */
- if (info_verbose)
- printf_filtered ("done.\n");
- }
-
- /* Search through list for correct name. */
- for (result = symtab_list; result; result = result->next)
- if (!strcmp (result->filename, pst->filename))
- return result;
-
- return 0;
-}
-
-/*
- * Scan through all of the global symbols defined in the object file,
- * assigning values to the debugging symbols that need to be assigned
- * to. Get these symbols from the misc function list.
- */
-static void
-scan_file_globals ()
-{
- int hash;
- int mf;
-
- for (mf = 0; mf < misc_function_count; mf++)
- {
- char *namestring = misc_function_vector[mf].name;
- struct symbol *sym, *prev;
-
- QUIT;
-
- prev = (struct symbol *) 0;
-
- /* Get the hash index and check all the symbols
- under that hash index. */
-
- hash = hashname (namestring);
-
- for (sym = global_sym_chain[hash]; sym;)
- {
- if (*namestring == SYMBOL_NAME (sym)[0]
- && !strcmp(namestring + 1, SYMBOL_NAME (sym) + 1))
- {
- /* Splice this symbol out of the hash chain and
- assign the value we have to it. */
- if (prev)
- SYMBOL_VALUE (prev) = SYMBOL_VALUE (sym);
- else
- global_sym_chain[hash]
- = (struct symbol *) SYMBOL_VALUE (sym);
-
- /* Check to see whether we need to fix up a common block. */
- /* Note: this code might be executed several times for
- the same symbol if there are multiple references. */
- if (SYMBOL_CLASS (sym) == LOC_BLOCK)
- fix_common_block (sym, misc_function_vector[mf].address);
- else
- SYMBOL_VALUE (sym) = misc_function_vector[mf].address;
-
- if (prev)
- sym = (struct symbol *) SYMBOL_VALUE (prev);
- else
- sym = global_sym_chain[hash];
- }
- else
- {
- prev = sym;
- sym = (struct symbol *) SYMBOL_VALUE (sym);
- }
- }
- }
-}
-
-/*
- * Read in a defined section of a specific object file's symbols.
- *
- * DESC is the file descriptor for the file, positioned at the
- * beginning of the symtab
- * STRINGTAB is a pointer to the files string
- * table, already read in
- * SYM_OFFSET is the offset within the file of
- * the beginning of the symbols we want to read, NUM_SUMBOLS is the
- * number of symbols to read
- * TEXT_OFFSET is the offset to be added to
- * all values of symbols coming in and
- * TEXT_SIZE is the size of the text segment read in.
- * OFFSET is a flag which indicates that the value of all of the
- * symbols should be offset by TEXT_OFFSET (for the purposes of
- * incremental linking).
- */
-
-static void
-read_ofile_symtab (desc, stringtab, stringtab_size, sym_offset,
- sym_size, text_offset, text_size, offset)
- int desc;
- register char *stringtab;
- int sym_offset;
- int sym_size;
- int text_offset;
- int text_size;
- int offset;
-{
- register char *namestring;
- register struct symbol *sym, *prev;
- int hash;
- struct cleanup *old_chain;
- struct nlist *bufp;
- unsigned char type;
-#ifdef N_BINCL
- subfile_stack = 0;
-#endif
-
- stringtab_global = stringtab;
- last_source_file = 0;
-
- symtab_input_desc = desc;
- symbuf_end = symbuf_idx = 0;
-
- /* It is necessary to actually read one symbol *before* the start
- of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
- occurs before the N_SO symbol.
-
- Detecting this in read_dbx_symtab
- would slow down initial readin, so we look for it here instead. */
- if (sym_offset >= sizeof (struct nlist))
- {
- lseek (desc, sym_offset - sizeof (struct nlist), L_INCR);
- fill_symbuf ();
- bufp = &symbuf[symbuf_idx++];
-
- if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)
- error ("Invalid symbol data: bad string table offset: %d",
- bufp->n_un.n_strx);
- namestring = bufp->n_un.n_strx + stringtab;
-
- processing_gcc_compilation =
- (bufp->n_type == N_TEXT
- && !strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL));
- }
- else
- {
- /* The N_SO starting this symtab is the first symbol, so we
- better not check the symbol before it. I'm not this can
- happen, but it doesn't hurt to check for it. */
- lseek(desc, sym_offset, L_INCR);
- processing_gcc_compilation = 0;
- }
-
- if (symbuf_idx == symbuf_end)
- fill_symbuf();
- bufp = &symbuf[symbuf_idx];
- if ((unsigned char) bufp->n_type != N_SO)
- fatal("First symbol in segment of executable not a source symbol");
-
- for (symnum = 0;
- symnum < sym_size / sizeof(struct nlist);
- symnum++)
- {
- QUIT; /* Allow this to be interruptable */
- if (symbuf_idx == symbuf_end)
- fill_symbuf();
- bufp = &symbuf[symbuf_idx++];
- type = bufp->n_type;
-
- if (offset &&
- (type == N_TEXT || type == N_DATA || type == N_BSS))
- bufp->n_value += text_offset;
-
- if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)
- error ("Invalid symbol data: bad string table offset: %d",
- bufp->n_un.n_strx);
- namestring = bufp->n_un.n_strx + stringtab;
-
- if (type & N_STAB)
- process_one_symbol(type, bufp->n_desc,
- bufp->n_value, namestring);
- /* We skip checking for a new .o or -l file; that should never
- happen in this routine. */
- else if (type == N_TEXT
- && !strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL))
- /* I don't think this code will ever be executed, because
- the GCC_COMPILED_FLAG_SYMBOL usually is right before
- the N_SO symbol which starts this source file.
- However, there is no reason not to accept
- the GCC_COMPILED_FLAG_SYMBOL anywhere. */
- processing_gcc_compilation = 1;
- else if (type & N_EXT || type == N_TEXT
-#ifdef N_NBTEXT
- || type == N_NBTEXT
-#endif
- )
- /* Global symbol: see if we came across a dbx defintion for
- a corresponding symbol. If so, store the value. Remove
- syms from the chain when their values are stored, but
- search the whole chain, as there may be several syms from
- different files with the same name. */
- /* This is probably not true. Since the files will be read
- in one at a time, each reference to a global symbol will
- be satisfied in each file as it appears. So we skip this
- section. */
- &stringtab_global; /* For debugger; am I right? */
- }
- end_symtab (text_offset + text_size);
-}
-
-static int
-hashname (name)
- char *name;
-{
- register char *p = name;
- register int total = p[0];
- register int c;
-
- c = p[1];
- total += c << 2;
- if (c)
- {
- c = p[2];
- total += c << 4;
- if (c)
- total += p[3] << 6;
- }
-
- /* Ensure result is positive. */
- if (total < 0) total += (1000 << 6);
- return total % HASHSIZE;
-}
-
-/* Put all appropriate global symbols in the symseg data
- onto the hash chains so that their addresses will be stored
- when seen later in loader global symbols. */
-
-static void
-hash_symsegs ()
-{
- /* Look at each symbol in each block in each symseg symtab. */
- struct symtab *s;
- for (s = symseg_chain; s; s = s->next)
- {
- register int n;
- for (n = BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)) - 1; n >= 0; n--)
- {
- register struct block *b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), n);
- register int i;
- for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--)
- {
- register struct symbol *sym = BLOCK_SYM (b, i);
-
- /* Put the symbol on a chain if its value is an address
- that is figured out by the loader. */
-
- if (SYMBOL_CLASS (sym) == LOC_EXTERNAL)
- {
- register int hash = hashname (SYMBOL_NAME (sym));
- SYMBOL_VALUE (sym) = (int) global_sym_chain[hash];
- global_sym_chain[hash] = sym;
- SYMBOL_CLASS (sym) = LOC_STATIC;
- }
- }
- }
- }
-}
-
-static void
-process_one_symbol (type, desc, value, name)
- int type, desc;
- CORE_ADDR value;
- char *name;
-{
- register struct context_stack *new;
- char *colon_pos;
-
- /* Something is wrong if we see real data before
- seeing a source file name. */
-
- if (last_source_file == 0 && type != N_SO)
- {
- /* Currently this ignores N_ENTRY on Gould machines, N_NSYM on machines
- where that code is defined. */
- if (IGNORE_SYMBOL (type))
- return;
-
- error ("Invalid symbol data: does not start by identifying a source file.");
- }
-
- switch (type)
- {
- case N_FUN:
- case N_FNAME:
- /* Either of these types of symbols indicates the start of
- a new function. We must process its "name" normally for dbx,
- but also record the start of a new lexical context, and possibly
- also the end of the lexical context for the previous function. */
- /* This is not always true. This type of symbol may indicate a
- text segment variable. */
-
- colon_pos = index (name, ':');
- if (!colon_pos++
- || (*colon_pos != 'f' && *colon_pos != 'F'))
- {
- define_symbol (value, name, desc);
- break;
- }
-
- within_function = 1;
- if (context_stack_depth > 0)
- {
- new = &context_stack[--context_stack_depth];
- /* Make a block for the local symbols within. */
- finish_block (new->name, &local_symbols, new->old_blocks,
- new->start_addr, value);
- }
- /* Stack must be empty now. */
- if (context_stack_depth != 0)
- error ("Invalid symbol data: unmatched N_LBRAC before symtab pos %d.",
- symnum);
-
- new = &context_stack[context_stack_depth++];
- new->old_blocks = pending_blocks;
- new->start_addr = value;
- new->name = define_symbol (value, name, desc);
- local_symbols = 0;
- break;
-
- case N_LBRAC:
- /* This "symbol" just indicates the start of an inner lexical
- context within a function. */
-
- if (context_stack_depth == context_stack_size)
- {
- context_stack_size *= 2;
- context_stack = (struct context_stack *)
- xrealloc (context_stack,
- (context_stack_size
- * sizeof (struct context_stack)));
- }
-
- new = &context_stack[context_stack_depth++];
- new->depth = desc;
- new->locals = local_symbols;
- new->old_blocks = pending_blocks;
- new->start_addr = value;
- new->name = 0;
- local_symbols = 0;
- break;
-
- case N_RBRAC:
- /* This "symbol" just indicates the end of an inner lexical
- context that was started with N_LBRAC. */
- new = &context_stack[--context_stack_depth];
- if (desc != new->depth)
- error ("Invalid symbol data: N_LBRAC/N_RBRAC symbol mismatch, symtab pos %d.", symnum);
-
- /* Some native compilers put the variable decls inside of an
- LBRAC/RBRAC block. This macro should be nonzero if this
- is true. DESC is N_DESC from the N_RBRAC symbol. */
-#if !defined (VARIABLES_INSIDE_BLOCK)
-#define VARIABLES_INSIDE_BLOCK(desc) 0
-#endif
-
- /* Can only use new->locals as local symbols here if we're in
- gcc or on a machine that puts them before the lbrack. */
- if (!VARIABLES_INSIDE_BLOCK(desc))
- local_symbols = new->locals;
-
- /* If this is not the outermost LBRAC...RBRAC pair in the
- function, its local symbols preceded it, and are the ones
- just recovered from the context stack. Defined the block for them.
-
- If this is the outermost LBRAC...RBRAC pair, there is no
- need to do anything; leave the symbols that preceded it
- to be attached to the function's own block. However, if
- it is so, we need to indicate that we just moved outside
- of the function. */
- if (local_symbols
- && context_stack_depth > !VARIABLES_INSIDE_BLOCK(desc))
- {
- /* Muzzle a compiler bug that makes end < start. */
- if (new->start_addr > value)
- new->start_addr = value;
- /* Make a block for the local symbols within. */
- finish_block (0, &local_symbols, new->old_blocks,
- new->start_addr + last_source_start_addr,
- value + last_source_start_addr);
- }
- else
- {
- within_function = 0;
- }
- if (VARIABLES_INSIDE_BLOCK(desc))
- /* Now pop locals of block just finished. */
- local_symbols = new->locals;
- break;
-
- case N_FN | N_EXT:
- /* This kind of symbol supposedly indicates the start
- of an object file. In fact this type does not appear. */
- break;
-
- case N_SO:
- /* This type of symbol indicates the start of data
- for one source file.
- Finish the symbol table of the previous source file
- (if any) and start accumulating a new symbol table. */
-#ifdef PCC_SOL_BROKEN
- /* pcc bug, occasionally puts out SO for SOL. */
- if (context_stack_depth > 0)
- {
- start_subfile (name);
- break;
- }
-#endif
- if (last_source_file)
- end_symtab (value);
- start_symtab (name, value);
- break;
-
- case N_SOL:
- /* This type of symbol indicates the start of data for
- a sub-source-file, one whose contents were copied or
- included in the compilation of the main source file
- (whose name was given in the N_SO symbol.) */
- start_subfile (name);
- break;
-
-#ifdef N_BINCL
- case N_BINCL:
- push_subfile ();
- add_new_header_file (name, value);
- start_subfile (name);
- break;
-
- case N_EINCL:
- start_subfile (pop_subfile ());
- break;
-
- case N_EXCL:
- add_old_header_file (name, value);
- break;
-#endif /* have N_BINCL */
-
- case N_SLINE:
- /* This type of "symbol" really just records
- one line-number -- core-address correspondence.
- Enter it in the line list for this symbol table. */
- record_line (desc, value);
- break;
-
- case N_BCOMM:
- if (common_block)
- error ("Invalid symbol data: common within common at symtab pos %d",
- symnum);
- common_block = local_symbols;
- common_block_i = local_symbols ? local_symbols->nsyms : 0;
- break;
-
- case N_ECOMM:
- /* Symbols declared since the BCOMM are to have the common block
- start address added in when we know it. common_block points to
- the first symbol after the BCOMM in the local_symbols list;
- copy the list and hang it off the symbol for the common block name
- for later fixup. */
- {
- int i;
- struct pending *link = local_symbols;
- struct symbol *sym =
- (struct symbol *) xmalloc (sizeof (struct symbol));
- bzero (sym, sizeof *sym);
- SYMBOL_NAME (sym) = savestring (name, strlen (name));
- SYMBOL_CLASS (sym) = LOC_BLOCK;
- SYMBOL_NAMESPACE (sym) = (enum namespace)((long)
- copy_pending (local_symbols, common_block_i, common_block));
- i = hashname (SYMBOL_NAME (sym));
- SYMBOL_VALUE (sym) = (int) global_sym_chain[i];
- global_sym_chain[i] = sym;
- common_block = 0;
- break;
- }
-
- case N_ECOML:
- case N_LENG:
- break;
-
- default:
- if (name)
- define_symbol (value, name, desc);
- }
-}
-
-/* This function was added for C++ functionality. I presume that it
- condenses the bunches formed by reading in an additional .o file
- (incremental linking). */
-
-static void
-condense_addl_misc_bunches ()
-{
- register int i, j;
- register struct misc_bunch *bunch;
-#ifdef NAMES_HAVE_UNDERSCORE
- int offset = 1;
-#else
- int offset = 0;
-#endif
-
- misc_function_vector
- = (struct misc_function *) xrealloc (misc_function_vector,
- (misc_count + misc_function_count) * sizeof (struct misc_function));
-
- j = misc_function_count;
- bunch = misc_bunch;
- while (bunch)
- {
- for (i = 0; i < misc_bunch_index; i++)
- {
- misc_function_vector[j] = bunch->contents[i];
- misc_function_vector[j].name
- = concat (misc_function_vector[j].name
- + (misc_function_vector[j].name[0] == '_' ? offset : 0),
- "", "");
- j++;
- }
- bunch = bunch->next;
- misc_bunch_index = MISC_BUNCH_SIZE;
- }
-
- misc_function_count += misc_count;
-
- /* Sort the misc functions by address. */
-
- qsort (misc_function_vector, misc_function_count,
- sizeof (struct misc_function), compare_misc_functions);
-}
-
-
-/* Read in another .o file and create a symtab entry for it.*/
-
-static void
-read_addl_syms (desc, stringtab, nlistlen, text_addr, text_size)
- int desc;
- register char *stringtab;
- register int nlistlen;
- unsigned text_addr;
- int text_size;
-{
- FILE *stream = fdopen (desc, "r");
- register char *namestring;
- register struct symbol *sym, *prev;
- int hash;
-
-#ifdef N_BINCL
- subfile_stack = 0;
-#endif
-
- last_source_file = 0;
- bzero (global_sym_chain, sizeof global_sym_chain);
- symtab_input_desc = desc;
- stringtab_global = stringtab;
- fill_symbuf ();
-
- for (symnum = 0; symnum < nlistlen; symnum++)
- {
- struct nlist *bufp;
- unsigned char type;
-
- QUIT; /* allow this to be interruptable */
- if (symbuf_idx == symbuf_end)
- fill_symbuf ();
- bufp = &symbuf[symbuf_idx++];
- type = bufp->n_type & N_TYPE;
- namestring = bufp->n_un.n_strx + stringtab;
-
- if( (type == N_TEXT) || (type == N_DATA) || (type == N_BSS) )
- {
- /* Relocate this file's symbol table information
- to the address it has been loaded into. */
- bufp->n_value += text_addr;
- }
-
- type = bufp->n_type;
-
- if (type & N_STAB)
- process_one_symbol (type, bufp->n_desc,
- bufp->n_value, namestring);
- /* A static text symbol whose name ends in ".o"
- can only mean the start of another object file.
- So end the symtab of the source file we have been processing.
- This is how we avoid counting the libraries as part
- or the last source file.
- Also this way we find end of first object file (crt0). */
- else if ((type == N_TEXT
-#ifdef N_NBTEXT
- || type == N_NBTEXT
-#endif
- )
- && (!strcmp (namestring + strlen (namestring) - 2, ".o"))
- || ! strncmp (namestring, "-l", 2))
- {
- if (last_source_file)
- end_symtab (bufp->n_value);
- }
- else if (type & N_EXT || type == N_TEXT
-#ifdef N_NBTEXT
- || type == N_NBTEXT
-#endif
- )
- {
- int used_up = 0;
-
- /* Record the location of _etext. */
- if (type == (N_TEXT | N_EXT)
- && !strcmp (namestring, "_etext"))
- end_of_text_addr = bufp->n_value;
-
-#if 0
- /* 25 Sep 89: The following seems to be stolen from
- read_ofile_symtab, and is wrong here (i.e. there was no
- first pass for add-file symbols). */
- /* This shouldn't be necessary, as we now do all of this work
- in scan_global syms and all misc functions should have been
- recorded on the first pass. */
- /* Global symbol: see if we came across a dbx definition
- for a corresponding symbol. If so, store the value.
- Remove syms from the chain when their values are stored,
- but search the whole chain, as there may be several syms
- from different files with the same name. */
- if (type & N_EXT)
- {
- prev = 0;
-#ifdef NAMES_HAVE_UNDERSCORE
- hash = hashname (namestring + 1);
-#else /* not NAMES_HAVE_UNDERSCORE */
- hash = hashname (namestring);
-#endif /* not NAMES_HAVE_UNDERSCORE */
- for (sym = global_sym_chain[hash];
- sym;)
- {
- if (
-#ifdef NAMES_HAVE_UNDERSCORE
- *namestring == '_'
- && namestring[1] == SYMBOL_NAME (sym)[0]
- &&
- !strcmp (namestring + 2, SYMBOL_NAME (sym) + 1)
-#else /* NAMES_HAVE_UNDERSCORE */
- namestring[0] == SYMBOL_NAME (sym)[0]
- &&
- !strcmp (namestring + 1, SYMBOL_NAME (sym) + 1)
-#endif /* NAMES_HAVE_UNDERSCORE */
- )
- {
- if (prev)
- SYMBOL_VALUE (prev) = SYMBOL_VALUE (sym);
- else
- global_sym_chain[hash]
- = (struct symbol *) SYMBOL_VALUE (sym);
- if (SYMBOL_CLASS (sym) == LOC_BLOCK)
- fix_common_block (sym, bufp->n_value);
- else
- SYMBOL_VALUE (sym) = bufp->n_value;
- if (prev)
- sym = (struct symbol *) SYMBOL_VALUE (prev);
- else
- sym = global_sym_chain[hash];
-
- used_up = 1;
- }
- else
- {
- prev = sym;
- sym = (struct symbol *) SYMBOL_VALUE (sym);
- }
- }
- }
-
- /* Defined global or text symbol: record as a misc function
- if it didn't give its address to a debugger symbol above. */
- if (type <= (N_TYPE | N_EXT)
- && type != N_EXT
- && ! used_up)
- record_misc_function (namestring, bufp->n_value,
- bufp->n_type);
-#endif /* 0 */
- }
- }
-
- if (last_source_file)
- end_symtab (text_addr + text_size);
-
- fclose (stream);
-}
-
-/* C++:
- This function allows the addition of incrementally linked object files.
- Since this has a fair amount of code in common with symbol_file_command,
- it might be worthwhile to consolidate things, as was done with
- read_dbx_symtab and condense_misc_bunches. */
-
-void
-add_file_command (arg_string)
- char* arg_string;
-{
- register int desc;
- DECLARE_FILE_HEADERS;
- struct nlist *nlist;
- char *stringtab;
- long buffer;
- register int val;
- extern void close ();
- struct cleanup *old_chain;
- struct symtab *symseg;
- struct stat statbuf;
- char *name;
- unsigned text_addr;
-
- if (arg_string == 0)
- error ("add-file takes a file name and an address");
-
- arg_string = tilde_expand (arg_string);
- make_cleanup (free, arg_string);
-
- for( ; *arg_string == ' '; arg_string++ );
- name = arg_string;
- for( ; *arg_string && *arg_string != ' ' ; arg_string++ );
- *arg_string++ = (char) 0;
-
- if (name[0] == 0)
- error ("add-file takes a file name and an address");
-
- text_addr = parse_and_eval_address (arg_string);
-
- dont_repeat ();
-
- if (!query ("add symbol table from filename \"%s\" at text_addr = 0x%x\n",
- name, text_addr))
- error ("Not confirmed.");
-
- desc = open (name, O_RDONLY);
- if (desc < 0)
- perror_with_name (name);
-
- old_chain = make_cleanup (close, desc);
-
- READ_FILE_HEADERS (desc, name);
-
- if (NUMBER_OF_SYMBOLS == 0)
- {
- printf ("%s does not have a symbol-table.\n", name);
- fflush (stdout);
- return;
- }
-
- printf ("Reading symbol data from %s...", name);
- fflush (stdout);
-
- /* Now read the string table, all at once. */
- val = lseek (desc, STRING_TABLE_OFFSET, 0);
- if (val < 0)
- perror_with_name (name);
- if (stat (name, &statbuf) < 0)
- perror_with_name (name);
- READ_STRING_TABLE_SIZE (buffer);
- if (buffer >= 0 && buffer < statbuf.st_size)
- {
-#ifdef BROKEN_LARGE_ALLOCA
- stringtab = (char *) xmalloc (buffer);
- make_cleanup (free, stringtab);
-#else
- stringtab = (char *) alloca (buffer);
-#endif
- }
- else
- stringtab = NULL;
- if (stringtab == NULL)
- error ("ridiculous string table size: %d bytes", buffer);
-
- /* Usually READ_STRING_TABLE_SIZE will have shifted the file pointer.
- Occaisionally, it won't. */
- val = lseek (desc, STRING_TABLE_OFFSET, 0);
- if (val < 0)
- perror_with_name (name);
- val = myread (desc, stringtab, buffer);
- if (val < 0)
- perror_with_name (name);
-
- /* Symsegs are no longer supported by GDB. Setting symseg_chain to
- 0 is easier than finding all the symseg code and eliminating it. */
- symseg_chain = 0;
-
- /* Position to read the symbol table. Do not read it all at once. */
- val = lseek (desc, SYMBOL_TABLE_OFFSET, 0);
- if (val < 0)
- perror_with_name (name);
-
- init_misc_functions ();
- make_cleanup (discard_misc_bunches, 0);
- init_header_files ();
- make_cleanup (free_header_files, 0);
- free_pendings = 0;
- pending_blocks = 0;
- file_symbols = 0;
- global_symbols = 0;
- make_cleanup (really_free_pendings, 0);
-
- read_addl_syms (desc, stringtab, NUMBER_OF_SYMBOLS, text_addr,
- SIZE_OF_TEXT_SEGMENT);
-
-
- /* Sort symbols alphabetically within each block. */
-
- sort_syms ();
-
- /* Go over the misc functions and install them in vector. */
-
- condense_addl_misc_bunches (1);
-
- /* Don't allow char * to have a typename (else would get caddr_t.) */
-
- TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
-
- do_cleanups (old_chain);
-
- /* Free the symtabs made by read_symsegs, but not their contents,
- which have been copied into symtabs on symtab_list. */
- while (symseg_chain)
- {
- register struct symtab *s = symseg_chain->next;
- free (symseg_chain);
- symseg_chain = s;
- }
-
- printf ("done.\n");
- fflush (stdout);
-}
-
-/* Read a number by which a type is referred to in dbx data,
- or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
- Just a single number N is equivalent to (0,N).
- Return the two numbers by storing them in the vector TYPENUMS.
- TYPENUMS will then be used as an argument to dbx_lookup_type. */
-
-static void
-read_type_number (pp, typenums)
- register char **pp;
- register int *typenums;
-{
- if (**pp == '(')
- {
- (*pp)++;
- typenums[0] = read_number (pp, ',');
- typenums[1] = read_number (pp, ')');
- }
- else
- {
- typenums[0] = 0;
- typenums[1] = read_number (pp, 0);
- }
-}
-
-
-
-static struct symbol *
-define_symbol (value, string, desc)
- int value;
- char *string;
- int desc;
-{
- register struct symbol *sym
- = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol));
- char *p = (char *) index (string, ':');
- int deftype;
- register int i;
-
- /* Ignore syms with empty names. */
- if (string[0] == 0)
- return 0;
-
- /* Ignore old-style symbols from cc -go */
- if (p == 0)
- return 0;
-
- SYMBOL_NAME (sym)
- = (char *) obstack_alloc (symbol_obstack, ((p - string) + 1));
- /* Open-coded bcopy--saves function call time. */
- {
- register char *p1 = string;
- register char *p2 = SYMBOL_NAME (sym);
- while (p1 != p)
- *p2++ = *p1++;
- *p2++ = '\0';
- }
- p++;
- /* Determine the type of name being defined. */
- if ((*p >= '0' && *p <= '9') || *p == '(')
- deftype = 'l';
- else
- deftype = *p++;
-
- /* c is a special case, not followed by a type-number.
- SYMBOL:c=iVALUE for an integer constant symbol.
- SYMBOL:c=rVALUE for a floating constant symbol.
- SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
- e.g. "b:c=e6,0" for "const b = blob1"
- (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
- if (deftype == 'c')
- {
- if (*p++ != '=')
- error ("Invalid symbol data at symtab pos %d.", symnum);
- switch (*p++)
- {
- case 'r':
- {
- double d = atof (p);
- char *value;
-
- SYMBOL_TYPE (sym) = builtin_type_double;
- value = (char *) obstack_alloc (symbol_obstack, sizeof (double));
- bcopy (&d, value, sizeof (double));
- SYMBOL_VALUE_BYTES (sym) = value;
- SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
- }
- break;
- case 'i':
- {
- SYMBOL_TYPE (sym) = builtin_type_int;
- SYMBOL_VALUE (sym) = atoi (p);
- SYMBOL_CLASS (sym) = LOC_CONST;
- }
- break;
- case 'e':
- /* SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
- e.g. "b:c=e6,0" for "const b = blob1"
- (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
- {
- int typenums[2];
-
- read_type_number (&p, typenums);
- if (*p++ != ',')
- error ("Invalid symbol data: no comma in enum const symbol");
-
- SYMBOL_TYPE (sym) = *dbx_lookup_type (typenums);
- SYMBOL_VALUE (sym) = atoi (p);
- SYMBOL_CLASS (sym) = LOC_CONST;
- }
- break;
- default:
- error ("Invalid symbol data at symtab pos %d.", symnum);
- }
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &file_symbols);
- return sym;
- }
-
- /* Now usually comes a number that says which data type,
- and possibly more stuff to define the type
- (all of which is handled by read_type) */
-
- if (deftype == 'p' && *p == 'F')
- /* pF is a two-letter code that means a function parameter in Fortran.
- The type-number specifies the type of the return value.
- Translate it into a pointer-to-function type. */
- {
- p++;
- SYMBOL_TYPE (sym)
- = lookup_pointer_type (lookup_function_type (read_type (&p)));
- }
- else
- {
- struct type *type = read_type (&p);
-
- if ((deftype == 'F' || deftype == 'f')
- && TYPE_CODE (type) != TYPE_CODE_FUNC)
- SYMBOL_TYPE (sym) = lookup_function_type (type);
- else
- SYMBOL_TYPE (sym) = type;
- }
-
- switch (deftype)
- {
- case 'f':
- SYMBOL_CLASS (sym) = LOC_BLOCK;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &file_symbols);
- break;
-
- case 'F':
- SYMBOL_CLASS (sym) = LOC_BLOCK;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &global_symbols);
- break;
-
- case 'G':
- /* For a class G (global) symbol, it appears that the
- value is not correct. It is necessary to search for the
- corresponding linker definition to find the value.
- These definitions appear at the end of the namelist. */
- i = hashname (SYMBOL_NAME (sym));
- SYMBOL_VALUE (sym) = (int) global_sym_chain[i];
- global_sym_chain[i] = sym;
- SYMBOL_CLASS (sym) = LOC_STATIC;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &global_symbols);
- break;
-
- /* This case is faked by a conditional above,
- when there is no code letter in the dbx data.
- Dbx data never actually contains 'l'. */
- case 'l':
- SYMBOL_CLASS (sym) = LOC_LOCAL;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'p':
- SYMBOL_CLASS (sym) = LOC_ARG;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
-
- /* If it's gcc compiled, if it says `short', believe it. */
- if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
- break;
-
-#if defined(BELIEVE_PCC_PROMOTION_TYPE)
- /* This macro is defined on machines (e.g. sparc) where
- we should believe the type of a PCC 'short' argument,
- but shouldn't believe the address (the address is
- the address of the corresponding int). Note that
- this is only different from the BELIEVE_PCC_PROMOTION
- case on big-endian machines.
-
- My guess is that this correction, as opposed to changing
- the parameter to an 'int' (as done below, for PCC
- on most machines), is the right thing to do
- on all machines, but I don't want to risk breaking
- something that already works. On most PCC machines,
- the sparc problem doesn't come up because the calling
- function has to zero the top bytes (not knowing whether
- the called function wants an int or a short), so there
- is no practical difference between an int and a short
- (except perhaps what happens when the GDB user types
- "print short_arg = 0x10000;").
- Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the compiler
- actually produces the correct address (we don't need to fix it
- up). I made this code adapt so that it will offset the symbol
- if it was pointing at an int-aligned location and not
- otherwise. This way you can use the same gdb for 4.0.x and
- 4.1 systems. */
-
- if (0 == SYMBOL_VALUE (sym) % sizeof (int))
- {
- if (SYMBOL_TYPE (sym) == builtin_type_char
- || SYMBOL_TYPE (sym) == builtin_type_unsigned_char)
- SYMBOL_VALUE (sym) += 3;
- else if (SYMBOL_TYPE (sym) == builtin_type_short
- || SYMBOL_TYPE (sym) == builtin_type_unsigned_short)
- SYMBOL_VALUE (sym) += 2;
- }
- break;
-
-#else /* no BELIEVE_PCC_PROMOTION_TYPE. */
-
- /* If PCC says a parameter is a short or a char,
- it is really an int. */
- if (SYMBOL_TYPE (sym) == builtin_type_char
- || SYMBOL_TYPE (sym) == builtin_type_short)
- SYMBOL_TYPE (sym) = builtin_type_int;
- else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char
- || SYMBOL_TYPE (sym) == builtin_type_unsigned_short)
- SYMBOL_TYPE (sym) = builtin_type_unsigned_int;
- break;
-
-#endif /* no BELIEVE_PCC_PROMOTION_TYPE. */
-
- case 'P':
- SYMBOL_CLASS (sym) = LOC_REGPARM;
- SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (value);
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'r':
-/* XXX */
-#ifdef sparc
-{
- struct symbol *s0;
-
- /*
- * If we see a parm decl immediately followed by a reg decl of
- * the same name (and in the same block), we change it to a single
- * instance of a reg parm. Sun's cc will generate these.
- */
- if (local_symbols &&
- (s0 = local_symbols->symbol[local_symbols->nsyms - 1]) &&
- SYMBOL_CLASS(s0) == LOC_ARG &&
- strcmp(SYMBOL_NAME(s0), SYMBOL_NAME(sym)) == 0) {
- SYMBOL_CLASS (s0) = LOC_REGPARM;
- SYMBOL_VALUE (s0) = STAB_REG_TO_REGNUM (value);
- SYMBOL_NAMESPACE (s0) = VAR_NAMESPACE;
- return s0;
- }
-}
-#endif
- SYMBOL_CLASS (sym) = LOC_REGISTER;
- SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (value);
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'S':
- /* Static symbol at top level of file */
- SYMBOL_CLASS (sym) = LOC_STATIC;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &file_symbols);
- break;
-
- case 't':
- SYMBOL_CLASS (sym) = LOC_TYPEDEF;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0
- && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0)
- TYPE_NAME (SYMBOL_TYPE (sym)) =
- obsavestring (SYMBOL_NAME (sym),
- strlen (SYMBOL_NAME (sym)));
- /* C++ vagaries: we may have a type which is derived from
- a base type which did not have its name defined when the
- derived class was output. We fill in the derived class's
- base part member's name here in that case. */
- else if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
- || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
- && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
- {
- int i;
- for (i = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)); i > 0; i--)
- if (TYPE_FIELD_NAME (SYMBOL_TYPE (sym), i - 1) == 0)
- TYPE_FIELD_NAME (SYMBOL_TYPE (sym), i - 1) =
- TYPE_NAME (TYPE_BASECLASS (SYMBOL_TYPE (sym), i));
- }
-
- add_symbol_to_list (sym, &file_symbols);
- break;
-
- case 'T':
- SYMBOL_CLASS (sym) = LOC_TYPEDEF;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
- if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0
- && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0)
- TYPE_NAME (SYMBOL_TYPE (sym))
- = obconcat ("",
- (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM
- ? "enum "
- : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
- ? "struct " : "union ")),
- SYMBOL_NAME (sym));
- add_symbol_to_list (sym, &file_symbols);
- break;
-
- case 'V':
- /* Static symbol of local scope */
- SYMBOL_CLASS (sym) = LOC_STATIC;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'v':
- /* Reference parameter */
- SYMBOL_CLASS (sym) = LOC_REF_ARG;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'X':
- /* This is used by Sun FORTRAN for "function result value".
- Sun claims ("dbx and dbxtool interfaces", 2nd ed)
- that Pascal uses it too, but when I tried it Pascal used
- "x:3" (local symbol) instead. */
- SYMBOL_CLASS (sym) = LOC_LOCAL;
- SYMBOL_VALUE (sym) = value;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- default:
- error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum);
- }
- return sym;
-}
-
-/* What about types defined as forward references inside of a small lexical
- scope? */
-/* Add a type to the list of undefined types to be checked through
- once this file has been read in. */
-static void
-add_undefined_type (type)
- struct type *type;
-{
- if (undef_types_length == undef_types_allocated)
- {
- undef_types_allocated *= 2;
- undef_types = (struct type **)
- xrealloc (undef_types,
- undef_types_allocated * sizeof (struct type *));
- }
- undef_types[undef_types_length++] = type;
-}
-
-/* Add here something to go through each undefined type, see if it's
- still undefined, and do a full lookup if so. */
-static void
-cleanup_undefined_types ()
-{
- struct type **type, *ntype;
- struct symbol *sym;
-
- for (type = undef_types; type < undef_types + undef_types_length; type++)
- {
- struct type *ntype = 0;
- /* Reasonable test to see if it's been defined since. */
- if (TYPE_NFIELDS (*type) == 0)
- {
- struct pending *ppt;
- int i;
- /* Name of the type, without "struct" or "union" */
- char *typename = TYPE_NAME (*type);
-
- if (!strncmp (typename, "struct ", 7))
- typename += 7;
- if (!strncmp (typename, "union ", 6))
- typename += 6;
-
- for (ppt = file_symbols; ppt; ppt = ppt->next)
- for (i = 0; i < ppt->nsyms; i++)
- {
- struct symbol *sym = ppt->symbol[i];
-
- if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
- && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
- && (TYPE_CODE (SYMBOL_TYPE (sym)) ==
- TYPE_CODE (*type))
- && !strcmp (SYMBOL_NAME (sym), typename))
- bcopy (SYMBOL_TYPE (sym), *type, sizeof (struct type));
- }
- }
- else
- /* It has been defined; don't mark it as a stub. */
- TYPE_FLAGS (*type) &= ~TYPE_FLAG_STUB;
- }
- undef_types_length = 0;
-}
-
-
-
-/* Read a dbx type reference or definition;
- return the type that is meant.
- This can be just a number, in which case it references
- a type already defined and placed in type_vector.
- Or the number can be followed by an =, in which case
- it means to define a new type according to the text that
- follows the =. */
-
-static
-struct type *
-read_type (pp)
- register char **pp;
-{
- register struct type *type = 0;
- register int n;
- struct type *type1;
- int typenums[2];
- int xtypenums[2];
- char *tmpc;
-
- /* Read type number if present. The type number may be omitted.
- for instance in a two-dimensional array declared with type
- "ar1;1;10;ar1;1;10;4". */
- if ((**pp >= '0' && **pp <= '9')
- || **pp == '(')
- {
- read_type_number (pp, typenums);
-
- /* Detect random reference to type not yet defined.
- Allocate a type object but leave it zeroed. */
- if (**pp != '=')
- return dbx_alloc_type (typenums);
-
- *pp += 2;
- }
- else
- {
- /* 'typenums=' not present, type is anonymous. Read and return
- the definition, but don't put it in the type vector. */
- typenums[0] = typenums[1] = -1;
- *pp += 1;
- }
-
- switch ((*pp)[-1])
- {
- case 'x':
- {
- enum type_code code;
-
- /* Used to index through file_symbols. */
- struct pending *ppt;
- int i;
-
- /* Name including "struct", etc. */
- char *type_name;
-
- /* Name without "struct", etc. */
- char *type_name_only;
-
- {
- char *prefix;
- char *from, *to;
-
- /* Set the type code according to the following letter. */
- switch ((*pp)[0])
- {
- case 's':
- code = TYPE_CODE_STRUCT;
- prefix = "struct ";
- break;
- case 'u':
- code = TYPE_CODE_UNION;
- prefix = "union ";
- break;
- case 'e':
- code = TYPE_CODE_ENUM;
- prefix = "enum ";
- break;
- default:
- error ("Bad type cross reference at symnum: %d.", symnum);
- }
-
- to = type_name = (char *)
- obstack_alloc (symbol_obstack,
- (strlen (prefix) +
- ((char *) index (*pp, ':') - (*pp)) + 1));
-
- /* Copy the prefix. */
- from = prefix;
- while (*to++ = *from++)
- ;
- to--;
-
- type_name_only = to;
-
- /* Copy the name. */
- from = *pp + 1;
- while ((*to++ = *from++) != ':')
- ;
- *--to = '\0';
-
- /* Set the pointer ahead of the name which we just read. */
- *pp = from;
-
-#if 0
- /* The following hack is clearly wrong, because it doesn't
- check whether we are in a baseclass. I tried to reproduce
- the case that it is trying to fix, but I couldn't get
- g++ to put out a cross reference to a basetype. Perhaps
- it doesn't do it anymore. */
- /* Note: for C++, the cross reference may be to a base type which
- has not yet been seen. In this case, we skip to the comma,
- which will mark the end of the base class name. (The ':'
- at the end of the base class name will be skipped as well.)
- But sometimes (ie. when the cross ref is the last thing on
- the line) there will be no ','. */
- from = (char *) index (*pp, ',');
- if (from)
- *pp = from;
-#endif /* 0 */
- }
-
- /* Now check to see whether the type has already been declared. */
- /* This is necessary at least in the case where the
- program says something like
- struct foo bar[5];
- The compiler puts out a cross-reference; we better find
- set the length of the structure correctly so we can
- set the length of the array. */
- for (ppt = file_symbols; ppt; ppt = ppt->next)
- for (i = 0; i < ppt->nsyms; i++)
- {
- struct symbol *sym = ppt->symbol[i];
-
- if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
- && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
- && (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
- && !strcmp (SYMBOL_NAME (sym), type_name_only))
- {
- obstack_free (symbol_obstack, type_name);
- type = SYMBOL_TYPE (sym);
- return type;
- }
- }
-
- /* Didn't find the type to which this refers, so we must
- be dealing with a forward reference. Allocate a type
- structure for it, and keep track of it so we can
- fill in the rest of the fields when we get the full
- type. */
- type = dbx_alloc_type (typenums);
- TYPE_CODE (type) = code;
- TYPE_NAME (type) = type_name;
-
- TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
-
- add_undefined_type (type);
- return type;
- }
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '(':
- (*pp)--;
- read_type_number (pp, xtypenums);
- type = *dbx_lookup_type (xtypenums);
- if (type == 0)
- type = builtin_type_void;
- if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
- break;
-
- case '*':
- type1 = read_type (pp);
- if (TYPE_POINTER_TYPE (type1))
- {
- type = TYPE_POINTER_TYPE (type1);
- if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
- }
- else
- {
- type = dbx_alloc_type (typenums);
- smash_to_pointer_type (type, type1);
- }
- break;
-
- case '@':
- {
- struct type *domain = read_type (pp);
- char c;
- struct type *memtype;
-
- if (*(*pp)++ != ',')
- error ("invalid member type data format, at symtab pos %d.",
- symnum);
-
- memtype = read_type (pp);
- type = dbx_alloc_type (typenums);
- smash_to_member_type (type, domain, memtype);
- }
- break;
-
- case '#':
- {
- struct type *domain = read_type (pp);
- char c;
- struct type *return_type;
- struct type **args;
-
- if (*(*pp)++ != ',')
- error ("invalid member type data format, at symtab pos %d.",
- symnum);
-
- return_type = read_type (pp);
- args = read_args (pp, ';');
- type = dbx_alloc_type (typenums);
- smash_to_method_type (type, domain, return_type, args);
- }
- break;
-
- case '&':
- type1 = read_type (pp);
- if (TYPE_REFERENCE_TYPE (type1))
- {
- type = TYPE_REFERENCE_TYPE (type1);
- if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
- }
- else
- {
- type = dbx_alloc_type (typenums);
- smash_to_reference_type (type, type1);
- }
- break;
-
- case 'f':
- type1 = read_type (pp);
- if (TYPE_FUNCTION_TYPE (type1))
- {
- type = TYPE_FUNCTION_TYPE (type1);
- if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
- }
- else
- {
- type = dbx_alloc_type (typenums);
- smash_to_function_type (type, type1);
- }
- break;
-
- case 'r':
- type = read_range_type (pp, typenums);
- if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
- break;
-
- case 'e':
- type = dbx_alloc_type (typenums);
- type = read_enum_type (pp, type);
- *dbx_lookup_type (typenums) = type;
- break;
-
- case 's':
- type = dbx_alloc_type (typenums);
- type = read_struct_type (pp, type);
- break;
-
- case 'u':
- type = dbx_alloc_type (typenums);
- type = read_struct_type (pp, type);
- TYPE_CODE (type) = TYPE_CODE_UNION;
- break;
-
- case 'a':
- if (*(*pp)++ != 'r')
- error ("Invalid symbol data: unrecognized type-code `a%c' %s %d.",
- (*pp)[-1], "at symtab position", symnum);
-
- type = dbx_alloc_type (typenums);
- type = read_array_type (pp, type);
- break;
-
- default:
- error ("Invalid symbol data: unrecognized type-code `%c' at symtab pos %d.",
- (*pp)[-1], symnum);
- }
-
- if (type == 0)
- abort ();
-
-#if 0
- /* If this is an overriding temporary alteration for a header file's
- contents, and this type number is unknown in the global definition,
- put this type into the global definition at this type number. */
- if (header_file_prev_index >= 0)
- {
- register struct type **tp
- = explicit_lookup_type (header_file_prev_index, typenums[1]);
- if (*tp == 0)
- *tp = type;
- }
-#endif
- return type;
-}
-
-/* This page contains subroutines of read_type. */
-
-/* Read the description of a structure (or union type)
- and return an object describing the type. */
-
-static struct type *
-read_struct_type (pp, type)
- char **pp;
- register struct type *type;
-{
- struct nextfield
- {
- struct nextfield *next;
- int visibility;
- struct field field;
- };
-
- struct next_fnfield
- {
- struct next_fnfield *next;
- int visibility;
- struct fn_field fn_field;
- };
-
- struct next_fnfieldlist
- {
- struct next_fnfieldlist *next;
- struct fn_fieldlist fn_fieldlist;
- };
-
- register struct nextfield *list = 0;
- struct nextfield *new;
- int totalsize;
- char *name;
- register char *p;
- int nfields = 0;
- register int n;
-
- register struct next_fnfieldlist *mainlist = 0;
- int nfn_fields = 0;
- int read_possible_virtual_info = 0;
-
- if (TYPE_MAIN_VARIANT (type) == 0)
- {
- TYPE_MAIN_VARIANT (type) = type;
- }
-
- TYPE_CODE (type) = TYPE_CODE_STRUCT;
-
- /* First comes the total size in bytes. */
-
- TYPE_LENGTH (type) = read_number (pp, 0);
-
- /* C++: Now, if the class is a derived class, then the next character
- will be a '!', followed by the number of base classes derived from.
- Each element in the list contains visibility information,
- the offset of this base class in the derived structure,
- and then the base type. */
- if (**pp == '!')
- {
- int i, n_baseclasses, offset;
- struct type **baseclass_vec;
- struct type *baseclass;
- int via_public;
-
- /* Nonzero if it is a virtual baseclass, i.e.,
-
- struct A{};
- struct B{};
- struct C : public B, public virtual A {};
-
- B is a baseclass of C; A is a virtual baseclass for C. This is a C++
- 2.0 language feature. */
- int via_virtual;
-
- *pp += 1;
-
- n_baseclasses = read_number (pp, ',');
- baseclass_vec = (struct type **)
- obstack_alloc (symbol_obstack,
- (n_baseclasses) * sizeof (struct type **)) - 1;
-
- for (i = 1; i <= n_baseclasses; i++)
- {
- if (**pp == '\\')
- *pp = next_symbol_text ();
-
- switch (*(*pp)++)
- {
- case '0':
- via_virtual = 0;
- break;
- case '1':
- via_virtual = 1;
- break;
- default:
- error ("Invalid symbol data: bad visibility format at symtab pos %d",
- symnum);
- }
-
- switch (*(*pp)++)
- {
- case '0':
- via_public = 0;
- break;
- case '2':
- via_public = 1;
- break;
- default:
- error ("Invalid symbol data: bad visibility format at symtab pos %d.",
- symnum);
- }
-
- /* Offset of the portion of the object corresponding to
- this baseclass. Always zero in the absence of
- multiple inheritance. */
- offset = read_number (pp, ',');
- baseclass = read_type (pp);
- *pp += 1; /* skip trailing ';' */
-
- if (offset != 0)
- {
- static int error_printed = 0;
-
- if (!error_printed)
- {
- fprintf (stderr,
-"\nWarning: GDB has limited understanding of multiple inheritance...");
- error_printed = 1;
- }
- offset = 0;
- }
-
- baseclass_vec[i] = lookup_basetype_type (baseclass, offset, via_virtual, via_public);
-
- /* Since lookup_basetype_type can copy the type,
- it might copy a stub type (complete with stub flag).
- If so, we need to add it to the list of undefined types
- to clean up later. Even if lookup_basetype_type
- didn't copy the type, adding it to the undefined list
- will not do any harm. */
- if (TYPE_FLAGS(baseclass_vec[i]) & TYPE_FLAG_STUB)
- add_undefined_type (baseclass_vec[i]);
-
- /* Make this baseclass visible for structure-printing purposes. */
- new = (struct nextfield *) alloca (sizeof (struct nextfield));
- new->next = list;
- list = new;
- list->field.type = baseclass_vec[i];
- list->field.name = TYPE_NAME (baseclass_vec[i]);
- list->field.bitpos = offset;
- list->field.bitsize = 0; /* this should be an unpacked field! */
- nfields++;
- }
- TYPE_N_BASECLASSES (type) = n_baseclasses;
- TYPE_BASECLASSES (type) = baseclass_vec;
- }
-
- /* Now come the fields, as NAME:?TYPENUM,BITPOS,BITSIZE; for each one.
- At the end, we see a semicolon instead of a field.
-
- In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
- a static field.
-
- The `?' is a placeholder for one of '+' (public visibility),
- '0' (protected visibility), and '-' (private visibility). */
-
- /* We better set p right now, in case there are no fields at all... */
- p = *pp;
-
- while (**pp != ';')
- {
- int visibility;
-
- /* Check for and handle cretinous dbx symbol name continuation! */
- if (**pp == '\\') *pp = next_symbol_text ();
-
- /* Get space to record the next field's data. */
- new = (struct nextfield *) alloca (sizeof (struct nextfield));
- new->next = list;
- list = new;
-
- /* Get the field name. */
- p = *pp;
- while (*p != ':') p++;
- list->field.name = obsavestring (*pp, p - *pp);
-
- /* C++: Check to see if we have hit the methods yet. */
- if (p[1] == ':')
- break;
-
- *pp = p + 1;
-
- /* This means we have a visibility for a field coming. */
- if (**pp == '/')
- {
- switch (*++*pp)
- {
- case '0':
- visibility = 0;
- *pp += 1;
- break;
-
- case '1':
- visibility = 1;
- *pp += 1;
- break;
-
- case '2':
- visibility = 2;
- *pp += 1;
- break;
- }
- }
- /* else normal dbx-style format. */
-
- list->field.type = read_type (pp);
- if (**pp == ':')
- {
- list->field.bitpos = (long)-1;
- p = ++(*pp);
- while (*p != ';') p++;
- list->field.bitsize = (long) savestring (*pp, p - *pp);
- *pp = p + 1;
- nfields++;
- continue;
- }
- else if (**pp != ',')
- error ("Invalid symbol data: bad structure-type format at symtab pos %d.",
- symnum);
- (*pp)++; /* Skip the comma. */
- list->field.bitpos = read_number (pp, ',');
- list->field.bitsize = read_number (pp, ';');
-
-#if 0
- /* This is wrong because this is identical to the symbols
- produced for GCC 0-size arrays. For example:
- typedef union {
- int num;
- char str[0];
- } foo;
- The code which dumped core in such circumstances should be
- fixed not to dump core. */
-
- /* g++ -g0 can put out bitpos & bitsize zero for a static
- field. This does not give us any way of getting its
- class, so we can't know its name. But we can just
- ignore the field so we don't dump core and other nasty
- stuff. */
- if (list->field.bitpos == 0
- && list->field.bitsize == 0)
- {
- /* Have we given the warning yet? */
- static int warning_given = 0;
-
- /* Only give the warning once, no matter how many class
- variables there are. */
- if (!warning_given)
- {
- warning_given = 1;
- fprintf_filtered (stderr, "\n\
-Warning: DBX-style class variable debugging information encountered.\n\
-You seem to have compiled your program with \
-\"g++ -g0\" instead of \"g++ -g\".\n\
-Therefore GDB will not know about your class variables.\n\
-");
- }
-
- /* Ignore this field. */
- list = list->next;
- }
- else
-#endif /* 0 */
- {
- /* Detect an unpacked field and mark it as such.
- dbx gives a bit size for all fields.
- Note that forward refs cannot be packed,
- and treat enums as if they had the width of ints. */
- if (TYPE_CODE (list->field.type) != TYPE_CODE_INT
- && TYPE_CODE (list->field.type) != TYPE_CODE_ENUM)
- list->field.bitsize = 0;
- if ((list->field.bitsize == 8 * TYPE_LENGTH (list->field.type)
- || (TYPE_CODE (list->field.type) == TYPE_CODE_ENUM
- && (list->field.bitsize
- == 8 * TYPE_LENGTH (builtin_type_int))
- )
- )
- &&
- list->field.bitpos % 8 == 0)
- list->field.bitsize = 0;
- nfields++;
- }
- }
-
- /* Now come the method fields, as NAME::methods
- where each method is of the form TYPENUM,ARGS,...:PHYSNAME;
- At the end, we see a semicolon instead of a field.
-
- For the case of overloaded operators, the format is
- OPERATOR::*.methods, where OPERATOR is the string "operator",
- `*' holds the place for an operator name (such as `+=')
- and `.' marks the end of the operator name. */
- if (p[1] == ':')
- {
- /* Now, read in the methods. To simplify matters, we
- "unread" the name that has been read, so that we can
- start from the top. */
-
- p = *pp;
-
- /* chill the list of fields: the last entry (at the head)
- is a partially constructed entry which we now scrub. */
- list = list->next;
-
- /* For each list of method lists... */
- do
- {
- int i;
- struct next_fnfield *sublist = 0;
- struct fn_field *fn_fields = 0;
- int length = 0;
- struct next_fnfieldlist *new_mainlist =
- (struct next_fnfieldlist *)alloca (sizeof (struct next_fnfieldlist));
-
- /* read in the name. */
- while (*p != ':') p++;
- if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == '$')
- {
- static char opname[] = "operator";
- char *o = opname + strlen(opname);
-
- /* Skip past '::'. */
- p += 2;
- while (*p != '.')
- *o++ = *p++;
- new_mainlist->fn_fieldlist.name = savestring (opname, o - opname);
- /* Skip past '.' */
- *pp = p + 1;
- }
- else
- {
- i = 0;
- new_mainlist->fn_fieldlist.name = savestring (*pp, p - *pp);
- /* Skip past '::'. */
- *pp = p + 2;
- }
-
- do
- {
- struct next_fnfield *new_sublist =
- (struct next_fnfield *)alloca (sizeof (struct next_fnfield));
-
- /* Check for and handle cretinous dbx symbol name continuation! */
- if (**pp == '\\') *pp = next_symbol_text ();
-
- new_sublist->fn_field.type = read_type (pp);
- if (**pp != ':')
- error ("invalid symtab info for method at symbol number %d.",
- symnum);
- *pp += 1;
- new_sublist->fn_field.args =
- TYPE_ARG_TYPES (new_sublist->fn_field.type);
- p = *pp;
- while (*p != ';') p++;
- new_sublist->fn_field.physname = savestring (*pp, p - *pp);
- *pp = p + 1;
- new_sublist->visibility = *(*pp)++ - '0';
- if (**pp == '\\') *pp = next_symbol_text ();
-
- switch (*(*pp)++)
- {
- case '*':
- /* virtual member function, followed by index. */
- new_sublist->fn_field.voffset = read_number (pp, ';') + 1;
- break;
- case '?':
- /* static member function. */
- new_sublist->fn_field.voffset = 1;
- break;
- default:
- /* **pp == '.'. */
- /* normal member function. */
- new_sublist->fn_field.voffset = 0;
- break;
- }
-
- new_sublist->next = sublist;
- sublist = new_sublist;
- length++;
- }
- while (**pp != ';');
-
- *pp += 1;
-
- new_mainlist->fn_fieldlist.fn_fields =
- (struct fn_field *) obstack_alloc (symbol_obstack,
- sizeof (struct fn_field) * length);
- TYPE_FN_PRIVATE_BITS (new_mainlist->fn_fieldlist) =
- (int *) obstack_alloc (symbol_obstack,
- sizeof (int) * (1 + (length >> 5)));
-
- TYPE_FN_PROTECTED_BITS (new_mainlist->fn_fieldlist) =
- (int *) obstack_alloc (symbol_obstack,
- sizeof (int) * (1 + (length >> 5)));
-
- for (i = length; sublist; sublist = sublist->next)
- {
- new_mainlist->fn_fieldlist.fn_fields[--i] = sublist->fn_field;
- if (sublist->visibility == 0)
- B_SET (new_mainlist->fn_fieldlist.private_fn_field_bits, i);
- else if (sublist->visibility == 1)
- B_SET (new_mainlist->fn_fieldlist.protected_fn_field_bits, i);
- }
-
- new_mainlist->fn_fieldlist.length = length;
- new_mainlist->next = mainlist;
- mainlist = new_mainlist;
- nfn_fields++;
- }
- while (**pp != ';');
- }
-
- *pp += 1;
-
- /* Now create the vector of fields, and record how big it is. */
-
- TYPE_NFIELDS (type) = nfields;
- TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack,
- sizeof (struct field) * nfields);
- TYPE_FIELD_PRIVATE_BITS (type) =
- (int *) obstack_alloc (symbol_obstack,
- sizeof (int) * (1 + (nfields >> 5)));
- TYPE_FIELD_PROTECTED_BITS (type) =
- (int *) obstack_alloc (symbol_obstack,
- sizeof (int) * (1 + (nfields >> 5)));
-
- TYPE_NFN_FIELDS (type) = nfn_fields;
- TYPE_NFN_FIELDS_TOTAL (type) = nfn_fields;
-
- {
- int i;
- for (i = 1; i <= TYPE_N_BASECLASSES (type); ++i)
- TYPE_NFN_FIELDS_TOTAL (type) +=
- TYPE_NFN_FIELDS_TOTAL (TYPE_BASECLASS (type, i));
- }
-
- TYPE_FN_FIELDLISTS (type) =
- (struct fn_fieldlist *) obstack_alloc (symbol_obstack,
- sizeof (struct fn_fieldlist) * nfn_fields);
-
- /* Copy the saved-up fields into the field vector. */
-
- for (n = nfields; list; list = list->next)
- {
- TYPE_FIELD (type, --n) = list->field;
- if (list->visibility == 0)
- SET_TYPE_FIELD_PRIVATE (type, n);
- else if (list->visibility == 1)
- SET_TYPE_FIELD_PROTECTED (type, n);
- }
-
- for (n = nfn_fields; mainlist; mainlist = mainlist->next)
- TYPE_FN_FIELDLISTS (type)[--n] = mainlist->fn_fieldlist;
-
- if (**pp == '~')
- {
- *pp += 1;
-
- if (**pp == '=')
- {
- TYPE_FLAGS (type)
- |= TYPE_FLAG_HAS_CONSTRUCTOR | TYPE_FLAG_HAS_DESTRUCTOR;
- *pp += 1;
- }
- else if (**pp == '+')
- {
- TYPE_FLAGS (type) |= TYPE_FLAG_HAS_CONSTRUCTOR;
- *pp += 1;
- }
- else if (**pp == '-')
- {
- TYPE_FLAGS (type) |= TYPE_FLAG_HAS_DESTRUCTOR;
- *pp += 1;
- }
-
- /* Read either a '%' or the final ';'. */
- if (*(*pp)++ == '%')
- {
- /* Now we must record the virtual function table pointer's
- field information. */
-
- struct type *t;
- int i;
-
- t = read_type (pp);
- p = (*pp)++;
- while (*p != ';') p++;
- TYPE_VPTR_BASETYPE (type) = t;
- if (type == t)
- {
- if (TYPE_FIELD_NAME (t, 0) == 0)
- TYPE_VPTR_FIELDNO (type) = i = 0;
- else for (i = TYPE_NFIELDS (t) - 1; i >= 0; --i)
- if (! strncmp (TYPE_FIELD_NAME (t, i), *pp,
- strlen (TYPE_FIELD_NAME (t, i))))
- {
- TYPE_VPTR_FIELDNO (type) = i;
- break;
- }
- if (i < 0)
- error ("virtual function table field not found");
- }
- else
- TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, 1));
- *pp = p + 1;
- }
- else
- {
- TYPE_VPTR_BASETYPE (type) = 0;
- TYPE_VPTR_FIELDNO (type) = -1;
- }
- }
- else
- {
- TYPE_VPTR_BASETYPE (type) = 0;
- TYPE_VPTR_FIELDNO (type) = -1;
- }
-
- return type;
-}
-
-/* Read a definition of an array type,
- and create and return a suitable type object.
- Also creates a range type which represents the bounds of that
- array. */
-static struct type *
-read_array_type (pp, type)
- register char **pp;
- register struct type *type;
-{
- struct type *index_type, *element_type, *range_type;
- int lower, upper;
- int adjustable = 0;
-
- /* Format of an array type:
- "ar<index type>;lower;upper;<array_contents_type>". Put code in
- to handle this.
-
- Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
- for these, produce a type like float[][]. */
-
- index_type = read_type (pp);
- if (*(*pp)++ != ';')
- error ("Invalid symbol data; improper format of array type decl.");
-
- if (!(**pp >= '0' && **pp <= '9'))
- {
- *pp += 1;
- adjustable = 1;
- }
- lower = read_number (pp, ';');
-
- if (!(**pp >= '0' && **pp <= '9'))
- {
- *pp += 1;
- adjustable = 1;
- }
- upper = read_number (pp, ';');
-
- element_type = read_type (pp);
-
- if (adjustable)
- {
- lower = 0;
- upper = -1;
- }
-
- {
- /* Create range type. */
- range_type = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
- TYPE_CODE (range_type) = TYPE_CODE_RANGE;
- TYPE_TARGET_TYPE (range_type) = index_type;
-
- /* This should never be needed. */
- TYPE_LENGTH (range_type) = sizeof (int);
-
- TYPE_NFIELDS (range_type) = 2;
- TYPE_FIELDS (range_type) =
- (struct field *) obstack_alloc (symbol_obstack,
- 2 * sizeof (struct field));
- TYPE_FIELD_BITPOS (range_type, 0) = lower;
- TYPE_FIELD_BITPOS (range_type, 1) = upper;
- }
-
- TYPE_CODE (type) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (type) = element_type;
- TYPE_LENGTH (type) = (upper - lower + 1) * TYPE_LENGTH (element_type);
- TYPE_NFIELDS (type) = 1;
- TYPE_FIELDS (type) =
- (struct field *) obstack_alloc (symbol_obstack,
- sizeof (struct field));
- TYPE_FIELD_TYPE (type, 0) = range_type;
-
- return type;
-}
-
-
-/* Read a definition of an enumeration type,
- and create and return a suitable type object.
- Also defines the symbols that represent the values of the type. */
-
-static struct type *
-read_enum_type (pp, type)
- register char **pp;
- register struct type *type;
-{
- register char *p;
- char *name;
- register long n;
- register struct symbol *sym;
- int nsyms = 0;
- struct pending **symlist;
- struct pending *osyms, *syms;
- int o_nsyms;
-
- if (within_function)
- symlist = &local_symbols;
- else
- symlist = &file_symbols;
- osyms = *symlist;
- o_nsyms = osyms ? osyms->nsyms : 0;
-
- /* Read the value-names and their values.
- The input syntax is NAME:VALUE,NAME:VALUE, and so on.
- A semicolon or comman instead of a NAME means the end. */
- while (**pp && **pp != ';' && **pp != ',')
- {
- /* Check for and handle cretinous dbx symbol name continuation! */
- if (**pp == '\\') *pp = next_symbol_text ();
-
- p = *pp;
- while (*p != ':') p++;
- name = obsavestring (*pp, p - *pp);
- *pp = p + 1;
- n = read_number (pp, ',');
-
- sym = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol));
- bzero (sym, sizeof (struct symbol));
- SYMBOL_NAME (sym) = name;
- SYMBOL_CLASS (sym) = LOC_CONST;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- SYMBOL_VALUE (sym) = n;
- add_symbol_to_list (sym, symlist);
- nsyms++;
- }
-
- if (**pp == ';')
- (*pp)++; /* Skip the semicolon. */
-
- /* Now fill in the fields of the type-structure. */
-
- TYPE_LENGTH (type) = sizeof (int);
- TYPE_CODE (type) = TYPE_CODE_ENUM;
- TYPE_NFIELDS (type) = nsyms;
- TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack, sizeof (struct field) * nsyms);
-
- /* Find the symbols for the values and put them into the type.
- The symbols can be found in the symlist that we put them on
- to cause them to be defined. osyms contains the old value
- of that symlist; everything up to there was defined by us. */
- /* Note that we preserve the order of the enum constants, so
- that in something like "enum {FOO, LAST_THING=FOO}" we print
- FOO, not LAST_THING. */
-
- for (syms = *symlist, n = 0; syms; syms = syms->next)
- {
- int j = 0;
- if (syms == osyms)
- j = o_nsyms;
- for (; j < syms->nsyms; j++)
- {
- struct symbol *sym = syms->symbol[j];
- SYMBOL_TYPE (sym) = type;
- TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (sym);
- TYPE_FIELD_VALUE (type, n) = 0;
- TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (sym);
- TYPE_FIELD_BITSIZE (type, n++) = 0;
- }
- if (syms == osyms)
- break;
- }
-
- return type;
-}
-
-#define MAX_OF_TYPE(t) ((1 << (sizeof (t) - 1)) - 1)
-#define MIN_OF_TYPE(t) (-(1 << (sizeof (t) - 1)))
-
-static struct type *
-read_range_type (pp, typenums)
- char **pp;
- int typenums[2];
-{
- int rangenums[2];
- long n2, n3;
- int n2bits, n3bits;
- int self_subrange;
- struct type *result_type;
- struct type *index_type;
-
- /* First comes a type we are a subrange of.
- In C it is usually 0, 1 or the type being defined. */
- read_type_number (pp, rangenums);
- self_subrange = (rangenums[0] == typenums[0] &&
- rangenums[1] == typenums[1]);
-
- /* A semicolon should now follow; skip it. */
- if (**pp == ';')
- (*pp)++;
-
- /* The remaining two operands are usually lower and upper bounds
- of the range. But in some special cases they mean something else. */
- read_huge_number (pp, ';', &n2, &n2bits);
- read_huge_number (pp, ';', &n3, &n3bits);
-
- if (n2bits == -1 || n3bits == -1)
- error ("Unrecognized type range %s.", pp);
-
- if (n2bits != 0 || n3bits != 0)
-#ifdef LONG_LONG
- {
- char got_signed = 0;
- char got_unsigned = 0;
- /* Number of bits in the type. */
- int nbits;
-
- /* Range from 0 to <large number> is an unsigned large integral type. */
- if ((n2bits == 0 && n2 == 0) && n3bits != 0)
- {
- got_unsigned = 1;
- nbits = n3bits;
- }
- /* Range fro <large number> to <large number>-1 is a large signed
- integral type. */
- else if (n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
- {
- got_signed = 1;
- nbits = n2bits;
- }
-
- /* Check for "long long". */
- if (got_signed && nbits == CHAR_BIT * sizeof (long long))
- return builtin_type_long_long;
- if (got_unsigned && nbits == CHAR_BIT * sizeof (long long))
- return builtin_type_unsigned_long_long;
-
- error ("Large type isn't a long long.");
- }
-#else /* LONG_LONG */
- error ("Type long long not supported on this machine.");
-#endif
-
- /* A type defined as a subrange of itself, with bounds both 0, is void. */
- if (self_subrange && n2 == 0 && n3 == 0)
- return builtin_type_void;
-
- /* If n3 is zero and n2 is not, we want a floating type,
- and n2 is the width in bytes.
-
- Fortran programs appear to use this for complex types also,
- and they give no way to distinguish between double and single-complex!
- We don't have complex types, so we would lose on all fortran files!
- So return type `double' for all of those. It won't work right
- for the complex values, but at least it makes the file loadable. */
-
- if (n3 == 0 && n2 > 0)
- {
- if (n2 == sizeof (float))
- return builtin_type_float;
- return builtin_type_double;
- }
-
- /* If the upper bound is -1, it must really be an unsigned int. */
-
- else if (n2 == 0 && n3 == -1)
- {
- if (sizeof (int) == sizeof (long))
- return builtin_type_unsigned_int;
- else
- return builtin_type_unsigned_long;
- }
-
- /* Special case: char is defined (Who knows why) as a subrange of
- itself with range 0-127. */
- else if (self_subrange && n2 == 0 && n3 == 127)
- return builtin_type_char;
-
- /* Assumptions made here: Subrange of self is equivalent to subrange
- of int. */
- else if (n2 == 0
- && (self_subrange ||
- *dbx_lookup_type (rangenums) == builtin_type_int))
- {
- /* an unsigned type */
- if (n3 == UINT_MAX)
- return builtin_type_unsigned_int;
- if (n3 == ULONG_MAX)
- return builtin_type_unsigned_long;
- if (n3 == USHRT_MAX)
- return builtin_type_unsigned_short;
- if (n3 == UCHAR_MAX)
- return builtin_type_unsigned_char;
- }
-#ifdef LONG_LONG
- else if (n3 == 0 && n2 == -sizeof (long long))
- return builtin_type_long_long;
-#endif
- else if (n2 == -n3 -1)
- {
- /* a signed type */
- if (n3 == INT_MAX)
- return builtin_type_int;
- if (n3 == LONG_MAX)
- return builtin_type_long;
- if (n3 == SHRT_MAX)
- return builtin_type_short;
- if (n3 == CHAR_MAX)
- return builtin_type_char;
- }
-
- /* We have a real range type on our hands. Allocate space and
- return a real pointer. */
-
- /* At this point I don't have the faintest idea how to deal with
- a self_subrange type; I'm going to assume that this is used
- as an idiom, and that all of them are special cases. So . . . */
- if (self_subrange)
- error ("Type defined as subrange of itself: %s.", pp);
-
- result_type = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
- bzero (result_type, sizeof (struct type));
-
- TYPE_TARGET_TYPE (result_type) = (self_subrange ?
- builtin_type_int :
- *dbx_lookup_type(rangenums));
-
- /* We have to figure out how many bytes it takes to hold this
- range type. I'm going to assume that anything that is pushing
- the bounds of a long was taken care of above. */
- if (n2 >= MIN_OF_TYPE(char) && n3 <= MAX_OF_TYPE(char))
- TYPE_LENGTH (result_type) = 1;
- else if (n2 >= MIN_OF_TYPE(short) && n3 <= MAX_OF_TYPE(short))
- TYPE_LENGTH (result_type) = sizeof (short);
- else if (n2 >= MIN_OF_TYPE(int) && n3 <= MAX_OF_TYPE(int))
- TYPE_LENGTH (result_type) = sizeof (int);
- else if (n2 >= MIN_OF_TYPE(long) && n3 <= MAX_OF_TYPE(long))
- TYPE_LENGTH (result_type) = sizeof (long);
- else
- error ("Ranged type doesn't fit within known sizes.");
-
- TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type));
- TYPE_CODE (result_type) = TYPE_CODE_RANGE;
- TYPE_NFIELDS (result_type) = 2;
- TYPE_FIELDS (result_type) =
- (struct field *) obstack_alloc (symbol_obstack,
- 2 * sizeof (struct field));
- bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field));
- TYPE_FIELD_BITPOS (result_type, 0) = n2;
- TYPE_FIELD_BITPOS (result_type, 1) = n3;
-
- return result_type;
-}
-
-/* Read a number from the string pointed to by *PP.
- The value of *PP is advanced over the number.
- If END is nonzero, the character that ends the
- number must match END, or an error happens;
- and that character is skipped if it does match.
- If END is zero, *PP is left pointing to that character. */
-
-static long
-read_number (pp, end)
- char **pp;
- int end;
-{
- register char *p = *pp;
- register long n = 0;
- register int c;
- int sign = 1;
-
- /* Handle an optional leading minus sign. */
-
- if (*p == '-')
- {
- sign = -1;
- p++;
- }
-
- /* Read the digits, as far as they go. */
-
- while ((c = *p++) >= '0' && c <= '9')
- {
- n *= 10;
- n += c - '0';
- }
- if (end)
- {
- if (c && c != end)
- error ("Invalid symbol data: invalid character \\%03o at symbol pos %d.", c, symnum);
- }
- else
- --p;
-
- *pp = p;
- return n * sign;
-}
-
-static void
-read_huge_number (pp, end, valu, bits)
- char **pp;
- int end;
- long *valu;
- int *bits;
-{
- char *p = *pp;
- int sign = 1;
- long n = 0;
- int radix = 10;
- char overflow = 0;
- int nbits = 0;
- int c;
- long upper_limit;
-
- /* Handle an optional leading minus sign. */
-
- if (*p == '-')
- {
- sign = -1;
- p++;
- }
-
- /* Leading zero means octal. GCC uses this to output values larger
- than an int (because that would be hard in decimal). */
- if (*p == '0')
- {
- radix = 8;
- p++;
- }
-
- upper_limit = LONG_MAX / radix;
- while ((c = *p++) >= '0' && c <= '9')
- {
- if (n <= upper_limit)
- {
- n *= radix;
- n += c - '0';
- }
- else
- overflow = 1;
-
- /* This depends on large values being output in octal, which is
- what GCC does. */
- if (radix == 8)
- {
- if (nbits == 0)
- {
- if (c == '0')
- /* Ignore leading zeroes. */
- ;
- else if (c == '1')
- nbits = 1;
- else if (c == '2' || c == '3')
- nbits = 2;
- else
- nbits = 3;
- }
- else
- nbits += 3;
- }
- }
- if (end)
- {
- if (c && c != end)
- {
- if (bits != NULL)
- *bits = -1;
- return;
- }
- }
- else
- --p;
-
- *pp = p;
- if (overflow)
- {
- if (nbits == 0)
- {
- /* Large decimal constants are an error (because it is hard to
- count how many bits are in them). */
- if (bits != NULL)
- *bits = -1;
- return;
- }
-
- /* -0x7f is the same as 0x80. So deal with it by adding one to
- the number of bits. */
- if (sign == -1)
- ++nbits;
- if (bits)
- *bits = nbits;
- }
- else
- {
- if (valu)
- *valu = n * sign;
- if (bits)
- *bits = 0;
- }
-}
-
-/* Read in an argument list. This is a list of types. It is terminated with
- a ':', FYI. Return the list of types read in. */
-static struct type **
-read_args (pp, end)
- char **pp;
- int end;
-{
- struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
- int n = 0;
-
- while (**pp != end)
- {
- if (**pp != ',')
- error ("Invalid argument list: no ',', at symtab pos %d", symnum);
- *pp += 1;
-
- /* Check for and handle cretinous dbx symbol name continuation! */
- if (**pp == '\\')
- *pp = next_symbol_text ();
-
- types[n++] = read_type (pp);
- }
- *pp += 1; /* get past `end' (the ':' character) */
-
- if (n == 1)
- {
- rval = (struct type **) xmalloc (2 * sizeof (struct type *));
- }
- else if (TYPE_CODE (types[n-1]) != TYPE_CODE_VOID)
- {
- rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
- bzero (rval + n, sizeof (struct type *));
- }
- else
- {
- rval = (struct type **) xmalloc (n * sizeof (struct type *));
- }
- bcopy (types, rval, n * sizeof (struct type *));
- return rval;
-}
-
-/* This function is really horrible, but to avoid it, there would need
- to be more filling in of forward references. THIS SHOULD BE MOVED OUT
- OF COFFREAD.C AND DBXREAD.C TO SOME PLACE WHERE IT CAN BE SHARED */
-int
-fill_in_vptr_fieldno (type)
- struct type *type;
-{
- if (TYPE_VPTR_FIELDNO (type) < 0)
- TYPE_VPTR_FIELDNO (type) =
- fill_in_vptr_fieldno (TYPE_BASECLASS (type, 1));
- return TYPE_VPTR_FIELDNO (type);
-}
-
-/* Copy a pending list, used to record the contents of a common
- block for later fixup. BUG FIX by rde@topexpress.co.uk */
-static struct pending *
-copy_pending (beg, begi, end)
- struct pending *beg, *end;
- int begi;
-{
- struct pending *new = 0;
- struct pending *next;
-
- /* rde note: `begi' is an offset in block `end', NOT `beg' */
- for (next = beg; next != 0; next = next->next)
- {
- register int j;
- for (j = next == end ? begi : 0; j < next->nsyms; j++)
- add_symbol_to_list (next->symbol[j], &new);
-
- if (next == end)
- break;
- }
- return new;
-}
-
-/* Add a common block's start address to the offset of each symbol
- declared to be in it (by being between a BCOMM/ECOMM pair that uses
- the common block name). */
-
-static void
-fix_common_block (sym, value)
- struct symbol *sym;
- int value;
-{
- struct pending *next = (struct pending *) SYMBOL_NAMESPACE (sym);
- for ( ; next; next = next->next)
- {
- register int j;
- for (j = next->nsyms - 1; j >= 0; j--)
- SYMBOL_VALUE (next->symbol[j]) += value;
- }
-}
-
-void
-_initialize_dbxread ()
-{
- symfile = 0;
- header_files = (struct header_file *) 0;
- this_object_header_files = (int *) 0;
-
- undef_types_allocated = 20;
- undef_types_length = 0;
- undef_types = (struct type **) xmalloc (undef_types_allocated *
- sizeof (struct type *));
-
- add_com ("symbol-file", class_files, symbol_file_command,
- "Load symbol table (in dbx format) from executable file FILE.");
-
- add_com ("add-file", class_files, add_file_command,
- "Load the symbols from FILE, assuming its code is at TEXT_START.") ;
-}
-
-#endif /* READ_DBX_FORMAT */
diff --git a/gnu/usr.bin/gdb/defs.h b/gnu/usr.bin/gdb/defs.h
deleted file mode 100644
index de744fc..0000000
--- a/gnu/usr.bin/gdb/defs.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * @(#)defs.h 6.3 (Berkeley) 5/8/91
- */
-
-/* Basic definitions for GDB, the GNU debugger.
- Copyright (C) 1986, 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. */
-
-#define CORE_ADDR unsigned int
-
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
-
-extern char *savestring ();
-extern char *concat ();
-extern char *xmalloc (), *xrealloc ();
-extern int parse_escape ();
-extern char *reg_names[];
-
-/* Various possibilities for alloca. */
-#ifdef sparc
-#include <alloca.h>
-#else
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-extern char *alloca ();
-#endif
-#endif
-
-extern int quit_flag;
-
-extern int immediate_quit;
-
-#define QUIT { if (quit_flag) quit (); }
-
-/* Notes on classes: class_alias is for alias commands which are not
- abbreviations of the original command. */
-
-enum command_class
-{
- no_class = -1, class_run = 0, class_vars, class_stack,
- class_files, class_support, class_info, class_breakpoint,
- class_alias, class_obscure, class_user,
-};
-
-/* the cleanup list records things that have to be undone
- if an error happens (descriptors to be closed, memory to be freed, etc.)
- Each link in the chain records a function to call and an
- argument to give it.
-
- Use make_cleanup to add an element to the cleanup chain.
- Use do_cleanups to do all cleanup actions back to a given
- point in the chain. Use discard_cleanups to remove cleanups
- from the chain back to a given point, not doing them. */
-
-struct cleanup
-{
- struct cleanup *next;
- void (*function) ();
- int arg;
-};
-
-extern void do_cleanups ();
-extern void discard_cleanups ();
-extern struct cleanup *make_cleanup ();
-extern struct cleanup *save_cleanups ();
-extern void restore_cleanups ();
-extern void free_current_contents ();
-extern void reinitialize_more_filter ();
-extern void fputs_filtered ();
-extern void fprintf_filtered ();
-extern void printf_filtered ();
-extern void print_spaces_filtered ();
-extern char *tilde_expand ();
-
-/* Structure for saved commands lines
- (for breakpoints, defined commands, etc). */
-
-struct command_line
-{
- struct command_line *next;
- char *line;
- int type; /* statement type */
-#define CL_END 0
-#define CL_NORMAL 1
-#define CL_WHILE 2
-#define CL_IF 3
-#define CL_EXITLOOP 4
-#define CL_NOP 5
- struct command_line *body; /* body of loop for while, body of if */
- struct command_line *elsebody; /* body of else part of if */
-};
-
-extern struct command_line *read_command_lines ();
-extern void do_command_lines();
-
-/* String containing the current directory (what getwd would return). */
-
-char *current_directory;
-
diff --git a/gnu/usr.bin/gdb/environ.c b/gnu/usr.bin/gdb/environ.c
deleted file mode 100644
index 0220166..0000000
--- a/gnu/usr.bin/gdb/environ.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)environ.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* environ.c -- library for manipulating environments for GNU.
- Copyright (C) 1986, 1989 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. */
-
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
-
-#include "environ.h"
-
-/* Return a new environment object. */
-
-struct environ *
-make_environ ()
-{
- register struct environ *e;
-
- e = (struct environ *) xmalloc (sizeof (struct environ));
-
- e->allocated = 10;
- e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *));
- e->vector[0] = 0;
- return e;
-}
-
-/* Free an environment and all the strings in it. */
-
-void
-free_environ (e)
- register struct environ *e;
-{
- register char **vector = e->vector;
-
- while (*vector)
- free (*vector++);
-
- free (e);
-}
-
-/* Copy the environment given to this process into E.
- Also copies all the strings in it, so we can be sure
- that all strings in these environments are safe to free. */
-
-void
-init_environ (e)
- register struct environ *e;
-{
- extern char **environ;
- register int i;
-
- for (i = 0; environ[i]; i++);
-
- if (e->allocated < i)
- {
- e->allocated = max (i, e->allocated + 10);
- e->vector = (char **) xrealloc (e->vector,
- (e->allocated + 1) * sizeof (char *));
- }
-
- bcopy (environ, e->vector, (i + 1) * sizeof (char *));
-
- while (--i >= 0)
- {
- register int len = strlen (e->vector[i]) + 1;
- register char *new = (char *) xmalloc (len);
- bcopy (e->vector[i], new, len);
- e->vector[i] = new;
- }
-}
-
-/* Return the vector of environment E.
- This is used to get something to pass to execve. */
-
-char **
-environ_vector (e)
- struct environ *e;
-{
- return e->vector;
-}
-
-/* Return the value in environment E of variable VAR. */
-
-char *
-get_in_environ (e, var)
- struct environ *e;
- char *var;
-{
- register int len = strlen (var);
- register char **vector = e->vector;
- register char *s;
-
- for (; s = *vector; vector++)
- if (!strncmp (s, var, len)
- && s[len] == '=')
- return &s[len + 1];
-
- return 0;
-}
-
-/* Store the value in E of VAR as VALUE. */
-
-void
-set_in_environ (e, var, value)
- struct environ *e;
- char *var;
- char *value;
-{
- register int i;
- register int len = strlen (var);
- register char **vector = e->vector;
- register char *s;
-
- for (i = 0; s = vector[i]; i++)
- if (!strncmp (s, var, len)
- && s[len] == '=')
- break;
-
- if (s == 0)
- {
- if (i == e->allocated)
- {
- e->allocated += 10;
- vector = (char **) xrealloc (vector,
- (e->allocated + 1) * sizeof (char *));
- e->vector = vector;
- }
- vector[i + 1] = 0;
- }
- else
- free (s);
-
- s = (char *) xmalloc (len + strlen (value) + 2);
- strcpy (s, var);
- strcat (s, "=");
- strcat (s, value);
- vector[i] = s;
- return;
-}
-
-/* Remove the setting for variable VAR from environment E. */
-
-void
-unset_in_environ (e, var)
- struct environ *e;
- char *var;
-{
- register int len = strlen (var);
- register char **vector = e->vector;
- register char *s;
-
- for (; s = *vector; vector++)
- if (!strncmp (s, var, len)
- && s[len] == '=')
- {
- free (s);
- bcopy (vector + 1, vector,
- (e->allocated - (vector - e->vector)) * sizeof (char *));
- e->vector[e->allocated - 1] = 0;
- return;
- }
-}
diff --git a/gnu/usr.bin/gdb/environ.h b/gnu/usr.bin/gdb/environ.h
deleted file mode 100644
index 13f31f4..0000000
--- a/gnu/usr.bin/gdb/environ.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Header for environment manipulation library.
- Copyright (C) 1989, 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 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. */
-
-/* We manipulate environments represented as these structures. */
-
-struct environ
-{
- /* Number of usable slots allocated in VECTOR.
- VECTOR always has one slot not counted here,
- to hold the terminating zero. */
- int allocated;
- /* A vector of slots, ALLOCATED + 1 of them.
- The first few slots contain strings "VAR=VALUE"
- and the next one contains zero.
- Then come some unused slots. */
- char **vector;
-};
-
-struct environ *make_environ ();
-void free_environ ();
-void init_environ ();
-char *get_in_environ ();
-void set_in_environ ();
-void unset_in_environ ();
-char **environ_vector ();
diff --git a/gnu/usr.bin/gdb/eval.c b/gnu/usr.bin/gdb/eval.c
deleted file mode 100644
index 60779e6..0000000
--- a/gnu/usr.bin/gdb/eval.c
+++ /dev/null
@@ -1,1065 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)eval.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Evaluate expressions for GDB.
- 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. */
-
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "value.h"
-#include "expression.h"
-
-
-/* Parse the string EXP as a C expression, evaluate it,
- and return the result as a number. */
-
-CORE_ADDR
-parse_and_eval_address (exp)
- char *exp;
-{
- struct expression *expr = parse_c_expression (exp);
- register CORE_ADDR addr;
- register struct cleanup *old_chain
- = make_cleanup (free_current_contents, &expr);
-
- addr = (CORE_ADDR) value_as_long (evaluate_expression (expr));
- do_cleanups (old_chain);
- return addr;
-}
-
-/* Like parse_and_eval_address but takes a pointer to a char * variable
- and advanced that variable across the characters parsed. */
-
-CORE_ADDR
-parse_and_eval_address_1 (expptr)
- char **expptr;
-{
- struct expression *expr = parse_c_1 (expptr, 0, 0);
- register CORE_ADDR addr;
- register struct cleanup *old_chain
- = make_cleanup (free_current_contents, &expr);
-
- addr = value_as_long (evaluate_expression (expr));
- do_cleanups (old_chain);
- return addr;
-}
-
-value
-parse_and_eval (exp)
- char *exp;
-{
- struct expression *expr = parse_c_expression (exp);
- register value val;
- register struct cleanup *old_chain
- = make_cleanup (free_current_contents, &expr);
-
- val = evaluate_expression (expr);
- do_cleanups (old_chain);
- return val;
-}
-
-/* Parse up to a comma (or to a closeparen)
- in the string EXPP as an expression, evaluate it, and return the value.
- EXPP is advanced to point to the comma. */
-
-value
-parse_to_comma_and_eval (expp)
- char **expp;
-{
- struct expression *expr = parse_c_1 (expp, 0, 1);
- register value val;
- register struct cleanup *old_chain
- = make_cleanup (free_current_contents, &expr);
-
- val = evaluate_expression (expr);
- do_cleanups (old_chain);
- return val;
-}
-
-/* Evaluate an expression in internal prefix form
- such as is constructed by expread.y.
-
- See expression.h for info on the format of an expression. */
-
-static value evaluate_subexp ();
-static value evaluate_subexp_for_address ();
-static value evaluate_subexp_for_sizeof ();
-static value evaluate_subexp_with_coercion ();
-
-/* return true if 'var' has an address in inferior's memory. */
-static int
-value_has_lval(var)
- register struct symbol *var;
-{
- switch (SYMBOL_CLASS(var))
- {
- case LOC_STATIC:
- case LOC_LABEL:
- case LOC_ARG:
- case LOC_REF_ARG:
- case LOC_LOCAL:
- case LOC_BLOCK:
- return (1);
- }
- return (0);
-}
-
-/* Values of NOSIDE argument to eval_subexp. */
-enum noside
-{ EVAL_NORMAL,
- EVAL_SKIP, /* Only effect is to increment pos. */
- EVAL_AVOID_SIDE_EFFECTS, /* Don't modify any variables or
- call any functions. The value
- returned will have the correct
- type, and will have an
- approximately correct lvalue
- type (inaccuracy: anything that is
- listed as being in a register in
- the function in which it was
- declared will be lval_register). */
-};
-
-value
-evaluate_expression (exp)
- struct expression *exp;
-{
- int pc = 0;
- return evaluate_subexp (0, exp, &pc, EVAL_NORMAL);
-}
-
-/* Evaluate an expression, avoiding all memory references
- and getting a value whose type alone is correct. */
-
-value
-evaluate_type (exp)
- struct expression *exp;
-{
- int pc = 0;
- return evaluate_subexp (0, exp, &pc, EVAL_AVOID_SIDE_EFFECTS);
-}
-
-static value
-evaluate_subexp (expect_type, exp, pos, noside)
- struct type *expect_type;
- register struct expression *exp;
- register int *pos;
- enum noside noside;
-{
- enum exp_opcode op;
- int tem;
- register int pc, pc2, oldpos;
- register value arg1, arg2, arg3;
- int nargs;
- value *argvec;
-
- pc = (*pos)++;
- op = exp->elts[pc].opcode;
-
- switch (op)
- {
- case OP_SCOPE:
- tem = strlen (&exp->elts[pc + 2].string);
- (*pos) += 3 + ((tem + sizeof (union exp_element))
- / sizeof (union exp_element));
- return value_static_field (exp->elts[pc + 1].type,
- &exp->elts[pc + 2].string, -1);
-
- case OP_LONG:
- (*pos) += 3;
- return value_from_long (exp->elts[pc + 1].type,
- exp->elts[pc + 2].longconst);
-
- case OP_DOUBLE:
- (*pos) += 3;
- return value_from_double (exp->elts[pc + 1].type,
- exp->elts[pc + 2].doubleconst);
-
- case OP_VAR_VALUE:
- (*pos) += 2;
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- struct symbol * sym = exp->elts[pc + 1].symbol;
- enum lval_type lv;
-
- switch (SYMBOL_CLASS (sym))
- {
- case LOC_CONST:
- case LOC_LABEL:
- case LOC_CONST_BYTES:
- lv = not_lval;
- case LOC_REGISTER:
- case LOC_REGPARM:
- lv = lval_register;
- default:
- lv = lval_memory;
- }
-
- return value_zero (SYMBOL_TYPE (sym), lv);
- }
- else
- return value_of_variable (exp->elts[pc + 1].symbol);
-
- case OP_LAST:
- (*pos) += 2;
- return access_value_history ((int) exp->elts[pc + 1].longconst);
-
- case OP_REGISTER:
- (*pos) += 2;
- return value_of_register ((int) exp->elts[pc + 1].longconst);
-
- case OP_INTERNALVAR:
- (*pos) += 2;
- return value_of_internalvar (exp->elts[pc + 1].internalvar);
-
- case OP_STRING:
- tem = strlen (&exp->elts[pc + 1].string);
- (*pos) += 2 + ((tem + sizeof (union exp_element))
- / sizeof (union exp_element));
- if (noside == EVAL_SKIP)
- goto nosideret;
- return value_string (&exp->elts[pc + 1].string, tem);
-
- case TERNOP_COND:
- /* Skip third and second args to evaluate the first one. */
- arg1 = evaluate_subexp (0, exp, pos, noside);
- if (value_zerop (arg1))
- {
- evaluate_subexp (0, exp, pos, EVAL_SKIP);
- return evaluate_subexp (0, exp, pos, noside);
- }
- else
- {
- arg2 = evaluate_subexp (0, exp, pos, noside);
- evaluate_subexp (0, exp, pos, EVAL_SKIP);
- return arg2;
- }
-
- case OP_FUNCALL:
- (*pos) += 2;
- op = exp->elts[*pos].opcode;
- if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
- {
- int fnptr;
- int tem2;
-
- nargs = (int) exp->elts[pc + 1].longconst + 1;
- /* First, evaluate the structure into arg2 */
- pc2 = (*pos)++;
-
- if (noside == EVAL_SKIP)
- goto nosideret;
-
- if (op == STRUCTOP_MEMBER)
- {
- arg2 = evaluate_subexp_for_address (exp, pos, noside);
- }
- else
- {
- arg2 = evaluate_subexp (0, exp, pos, noside);
- }
-
- /* If the function is a virtual function, then the
- aggregate value (providing the structure) plays
- its part by providing the vtable. Otherwise,
- it is just along for the ride: call the function
- directly. */
-
- arg1 = evaluate_subexp (0, exp, pos, noside);
-
- fnptr = (int) value_as_long (arg1);
- if (fnptr < 128)
- {
- struct type *basetype;
- int i, j;
- basetype = TYPE_TARGET_TYPE (VALUE_TYPE (arg2));
- basetype = TYPE_VPTR_BASETYPE (basetype);
- for (i = TYPE_NFN_FIELDS (basetype) - 1; i >= 0; i--)
- {
- struct fn_field *f = TYPE_FN_FIELDLIST1 (basetype, i);
- /* If one is virtual, then all are virtual. */
- if (TYPE_FN_FIELD_VIRTUAL_P (f, 0))
- for (j = TYPE_FN_FIELDLIST_LENGTH (basetype, i) - 1; j >= 0; --j)
- if (TYPE_FN_FIELD_VOFFSET (f, j) == fnptr)
- {
- value vtbl;
- value base = value_ind (arg2);
- struct type *fntype = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j));
-
- if (TYPE_VPTR_FIELDNO (basetype) < 0)
- TYPE_VPTR_FIELDNO (basetype)
- = fill_in_vptr_fieldno (basetype);
-
- VALUE_TYPE (base) = basetype;
- vtbl = value_field (base, TYPE_VPTR_FIELDNO (basetype));
- VALUE_TYPE (vtbl) = lookup_pointer_type (fntype);
- VALUE_TYPE (arg1) = builtin_type_int;
- arg1 = value_subscript (vtbl, arg1);
- VALUE_TYPE (arg1) = fntype;
- goto got_it;
- }
- }
- if (i < 0)
- error ("virtual function at index %d not found", fnptr);
- }
- else
- {
- VALUE_TYPE (arg1) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)));
- }
- got_it:
-
- /* Now, say which argument to start evaluating from */
- tem = 2;
- }
- else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
- {
- /* Hair for method invocations */
- int tem2;
-
- nargs = (int) exp->elts[pc + 1].longconst + 1;
- /* First, evaluate the structure into arg2 */
- pc2 = (*pos)++;
- tem2 = strlen (&exp->elts[pc2 + 1].string);
- *pos += 2 + (tem2 + sizeof (union exp_element)) / sizeof (union exp_element);
- if (noside == EVAL_SKIP)
- goto nosideret;
-
- if (op == STRUCTOP_STRUCT)
- {
- arg2 = evaluate_subexp_for_address (exp, pos, noside);
- }
- else
- {
- arg2 = evaluate_subexp (0, exp, pos, noside);
- }
- /* Now, say which argument to start evaluating from */
- tem = 2;
- }
- else
- {
- nargs = (int) exp->elts[pc + 1].longconst;
- tem = 0;
- }
- argvec = (value *) alloca (sizeof (value) * (nargs + 2));
- for (; tem <= nargs; tem++)
- /* Ensure that array expressions are coerced into pointer objects. */
- argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
-
- /* signal end of arglist */
- argvec[tem] = 0;
-
- if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
- {
- int static_memfuncp;
-
- argvec[1] = arg2;
- argvec[0] =
- value_struct_elt (arg2, argvec+1, &exp->elts[pc2 + 1].string,
- &static_memfuncp,
- op == STRUCTOP_STRUCT
- ? "structure" : "structure pointer");
- if (static_memfuncp)
- {
- argvec[1] = argvec[0];
- nargs--;
- argvec++;
- }
- }
- else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
- {
- argvec[1] = arg2;
- argvec[0] = arg1;
- }
-
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- /* If the return type doesn't look like a function type, call an
- error. This can happen if somebody tries to turn a variable into
- a function call. This is here because people often want to
- call, eg, strcmp, which gdb doesn't know is a function. If
- gdb isn't asked for it's opinion (ie. through "whatis"),
- it won't offer it. */
-
- struct type *ftype =
- TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0]));
-
- if (ftype)
- return allocate_value (TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0])));
- else
- error ("Expression of type other than \"Function returning ...\" used as function");
- }
- return call_function (argvec[0], nargs, argvec + 1);
-
- case STRUCTOP_STRUCT:
- tem = strlen (&exp->elts[pc + 1].string);
- (*pos) += 2 + ((tem + sizeof (union exp_element))
- / sizeof (union exp_element));
-
- /* Try to convert "foo.bar" into "(&foo)->bar" so we won't copy
- * the entire contents of a large struct just to extract one
- * value from it. */
- if (noside == EVAL_NORMAL && exp->elts[*pos].opcode == OP_VAR_VALUE
- && value_has_lval(exp->elts[*pos + 1].symbol))
- arg1 = evaluate_subexp_for_address(exp, pos, noside);
- else
- arg1 = evaluate_subexp (0, exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- register struct type *type = VALUE_TYPE (arg1);
- if (TYPE_CODE (type) == TYPE_CODE_PTR)
- type = TYPE_TARGET_TYPE (type);
- return value_zero (lookup_struct_elt_type (type,
- &exp->elts[pc + 1].string),
- lval_memory);
- }
- else
- return value_struct_elt (arg1, 0, &exp->elts[pc + 1].string, 0,
- "structure");
-
- case STRUCTOP_PTR:
- tem = strlen (&exp->elts[pc + 1].string);
- (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element);
- arg1 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (lookup_struct_elt_type (TYPE_TARGET_TYPE
- (VALUE_TYPE (arg1)),
- &exp->elts[pc + 1].string),
- lval_memory);
- else
- return value_struct_elt (arg1, 0, &exp->elts[pc + 1].string, 0,
- "structure pointer");
-
- case STRUCTOP_MEMBER:
- arg1 = evaluate_subexp_for_address (exp, pos, noside);
- arg2 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- /* Now, convert these values to an address. */
- if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_PTR
- || ((TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2)))
- != TYPE_CODE_MEMBER)
- && (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2)))
- != TYPE_CODE_METHOD)))
- error ("non-pointer-to-member value used in pointer-to-member construct");
- arg3 = value_from_long (builtin_type_long,
- value_as_long (arg1) + value_as_long (arg2));
- VALUE_TYPE (arg3) =
- lookup_pointer_type (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))));
- return value_ind (arg3);
-
- case STRUCTOP_MPTR:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- /* Now, convert these values to an address. */
- if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_PTR
- || (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) != TYPE_CODE_MEMBER
- && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) != TYPE_CODE_METHOD))
- error ("non-pointer-to-member value used in pointer-to-member construct");
- arg3 = value_from_long (builtin_type_long,
- value_as_long (arg1) + value_as_long (arg2));
- VALUE_TYPE (arg3) =
- lookup_pointer_type (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))));
- return value_ind (arg3);
-
- case BINOP_ASSIGN:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
- if (binop_user_defined_p (op, arg1, arg2))
- return value_x_binop (arg1, arg2, op, 0);
- else
- return value_assign (arg1, arg2);
-
- case BINOP_ASSIGN_MODIFY:
- (*pos) += 2;
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
- op = exp->elts[pc + 1].opcode;
- if (binop_user_defined_p (op, arg1, arg2))
- return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op);
- else if (op == BINOP_ADD)
- arg2 = value_add (arg1, arg2);
- else if (op == BINOP_SUB)
- arg2 = value_sub (arg1, arg2);
- else
- arg2 = value_binop (arg1, arg2, op);
- return value_assign (arg1, arg2);
-
- case BINOP_ADD:
- arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- return value_x_binop (arg1, arg2, op, 0);
- else
- return value_add (arg1, arg2);
-
- case BINOP_SUB:
- arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- return value_x_binop (arg1, arg2, op, 0);
- else
- return value_sub (arg1, arg2);
-
- case BINOP_MUL:
- case BINOP_DIV:
- case BINOP_REM:
- case BINOP_LSH:
- case BINOP_RSH:
- case BINOP_LOGAND:
- case BINOP_LOGIOR:
- case BINOP_LOGXOR:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- return value_x_binop (arg1, arg2, op, 0);
- else
- if (noside == EVAL_AVOID_SIDE_EFFECTS
- && op == BINOP_DIV)
- return value_zero (VALUE_TYPE (arg1), not_lval);
- else
- return value_binop (arg1, arg2, op);
-
- case BINOP_SUBSCRIPT:
- arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
- VALUE_LVAL (arg1));
-
- if (binop_user_defined_p (op, arg1, arg2))
- return value_x_binop (arg1, arg2, op, 0);
- else
- return value_subscript (arg1, arg2);
-
- case BINOP_AND:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- {
- arg2 = evaluate_subexp (0, exp, pos, noside);
- goto nosideret;
- }
-
- oldpos = *pos;
- arg2 = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- *pos = oldpos;
-
- if (binop_user_defined_p (op, arg1, arg2))
- {
- arg2 = evaluate_subexp (0, exp, pos, noside);
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_zerop (arg1);
- arg2 = evaluate_subexp (0, exp, pos,
- (tem ? EVAL_SKIP : noside));
- return value_from_long (builtin_type_int,
- (LONGEST) (!tem && !value_zerop (arg2)));
- }
-
- case BINOP_OR:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- {
- arg2 = evaluate_subexp (0, exp, pos, noside);
- goto nosideret;
- }
-
- oldpos = *pos;
- arg2 = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- *pos = oldpos;
-
- if (binop_user_defined_p (op, arg1, arg2))
- {
- arg2 = evaluate_subexp (0, exp, pos, noside);
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_zerop (arg1);
- arg2 = evaluate_subexp (0, exp, pos,
- (!tem ? EVAL_SKIP : noside));
- return value_from_long (builtin_type_int,
- (LONGEST) (!tem || !value_zerop (arg2)));
- }
-
- case BINOP_EQUAL:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- {
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_equal (arg1, arg2);
- return value_from_long (builtin_type_int, (LONGEST) tem);
- }
-
- case BINOP_NOTEQUAL:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- {
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_equal (arg1, arg2);
- return value_from_long (builtin_type_int, (LONGEST) ! tem);
- }
-
- case BINOP_LESS:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- {
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_less (arg1, arg2);
- return value_from_long (builtin_type_int, (LONGEST) tem);
- }
-
- case BINOP_GTR:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- {
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_less (arg2, arg1);
- return value_from_long (builtin_type_int, (LONGEST) tem);
- }
-
- case BINOP_GEQ:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- {
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_less (arg1, arg2);
- return value_from_long (builtin_type_int, (LONGEST) ! tem);
- }
-
- case BINOP_LEQ:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (binop_user_defined_p (op, arg1, arg2))
- {
- return value_x_binop (arg1, arg2, op, 0);
- }
- else
- {
- tem = value_less (arg2, arg1);
- return value_from_long (builtin_type_int, (LONGEST) ! tem);
- }
-
- case BINOP_REPEAT:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- arg2 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT)
- error ("Non-integral right operand for \"@\" operator.");
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return allocate_repeat_value (VALUE_TYPE (arg1),
- (int) value_as_long (arg2));
- else
- return value_repeat (arg1, (int) value_as_long (arg2));
-
- case BINOP_COMMA:
- evaluate_subexp (0, exp, pos, noside);
- return evaluate_subexp (0, exp, pos, noside);
-
- case UNOP_NEG:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (unop_user_defined_p (op, arg1))
- return value_x_unop (arg1, op);
- else
- return value_neg (arg1);
-
- case UNOP_LOGNOT:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (unop_user_defined_p (op, arg1))
- return value_x_unop (arg1, op);
- else
- return value_lognot (arg1);
-
- case UNOP_ZEROP:
- arg1 = evaluate_subexp (0, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (unop_user_defined_p (op, arg1))
- return value_x_unop (arg1, op);
- else
- return value_from_long (builtin_type_int,
- (LONGEST) value_zerop (arg1));
-
- case UNOP_IND:
- if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
- expect_type = TYPE_TARGET_TYPE (expect_type);
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR
- || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF
- /* In C you can dereference an array to get the 1st elt. */
- || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY
- )
- return value_zero (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
- lval_memory);
- else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT)
- /* GDB allows dereferencing an int. */
- return value_zero (builtin_type_int, lval_memory);
- else
- error ("Attempt to take contents of a non-pointer value.");
- }
- return value_ind (arg1);
-
- case UNOP_ADDR:
- /* C++: check for and handle pointer to members. */
-
- op = exp->elts[*pos].opcode;
-
- if (noside == EVAL_SKIP)
- {
- if (op == OP_SCOPE)
- {
- char *name = &exp->elts[pc+3].string;
- int tem = strlen (name);
- (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element);
- }
- else
- evaluate_subexp (expect_type, exp, pos, EVAL_SKIP);
- goto nosideret;
- }
-
- if (op == OP_SCOPE)
- {
- char *name = &exp->elts[pc+3].string;
- int tem = strlen (name);
- struct type *domain = exp->elts[pc+2].type;
- (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element);
- arg1 = value_struct_elt_for_address (domain, expect_type, name);
- if (arg1)
- return arg1;
- error ("no field `%s' in structure", name);
- }
- else
- return evaluate_subexp_for_address (exp, pos, noside);
-
- case UNOP_SIZEOF:
- if (noside == EVAL_SKIP)
- {
- evaluate_subexp (0, exp, pos, EVAL_SKIP);
- goto nosideret;
- }
- return evaluate_subexp_for_sizeof (exp, pos);
-
- case UNOP_CAST:
- (*pos) += 2;
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- return value_cast (exp->elts[pc + 1].type, arg1);
-
- case UNOP_MEMVAL:
- (*pos) += 2;
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (exp->elts[pc + 1].type, lval_memory);
- else
- return value_at (exp->elts[pc + 1].type,
- (CORE_ADDR) value_as_long (arg1));
-
- case UNOP_PREINCREMENT:
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
- else if (unop_user_defined_p (op, arg1))
- {
- return value_x_unop (arg1, op);
- }
- else
- {
- arg2 = value_add (arg1, value_from_long (builtin_type_char,
- (LONGEST) 1));
- return value_assign (arg1, arg2);
- }
-
- case UNOP_PREDECREMENT:
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
- else if (unop_user_defined_p (op, arg1))
- {
- return value_x_unop (arg1, op);
- }
- else
- {
- arg2 = value_sub (arg1, value_from_long (builtin_type_char,
- (LONGEST) 1));
- return value_assign (arg1, arg2);
- }
-
- case UNOP_POSTINCREMENT:
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
- else if (unop_user_defined_p (op, arg1))
- {
- return value_x_unop (arg1, op);
- }
- else
- {
- arg2 = value_add (arg1, value_from_long (builtin_type_char,
- (LONGEST) 1));
- value_assign (arg1, arg2);
- return arg1;
- }
-
- case UNOP_POSTDECREMENT:
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
- else if (unop_user_defined_p (op, arg1))
- {
- return value_x_unop (arg1, op);
- }
- else
- {
- arg2 = value_sub (arg1, value_from_long (builtin_type_char,
- (LONGEST) 1));
- value_assign (arg1, arg2);
- return arg1;
- }
-
- case OP_THIS:
- (*pos) += 1;
- return value_of_this (1);
-
- default:
- error ("internal error: I do not know how to evaluate what you gave me");
- }
-
- nosideret:
- return value_from_long (builtin_type_long, (LONGEST) 1);
-}
-
-/* Evaluate a subexpression of EXP, at index *POS,
- and return the address of that subexpression.
- Advance *POS over the subexpression.
- If the subexpression isn't an lvalue, get an error.
- NOSIDE may be EVAL_AVOID_SIDE_EFFECTS;
- then only the type of the result need be correct. */
-
-static value
-evaluate_subexp_for_address (exp, pos, noside)
- register struct expression *exp;
- register int *pos;
- enum noside noside;
-{
- enum exp_opcode op;
- register int pc;
-
- pc = (*pos);
- op = exp->elts[pc].opcode;
-
- switch (op)
- {
- case UNOP_IND:
- (*pos)++;
- return evaluate_subexp (0, exp, pos, noside);
-
- case UNOP_MEMVAL:
- (*pos) += 3;
- return value_cast (lookup_pointer_type (exp->elts[pc + 1].type),
- evaluate_subexp (0, exp, pos, noside));
-
- case OP_VAR_VALUE:
- (*pos) += 3;
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- struct type *type =
- lookup_pointer_type (SYMBOL_TYPE (exp->elts[pc + 1].symbol));
- enum address_class sym_class =
- SYMBOL_CLASS (exp->elts[pc + 1].symbol);
-
- if (sym_class == LOC_CONST
- || sym_class == LOC_CONST_BYTES
- || sym_class == LOC_REGISTER
- || sym_class == LOC_REGPARM)
- error ("Attempt to take address of register or constant.");
-
- return
- value_zero (type, not_lval);
- }
- else
- return locate_var_value (exp->elts[pc + 1].symbol, (CORE_ADDR) 0);
-
- default:
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- value x = evaluate_subexp (0, exp, pos, noside);
- if (VALUE_LVAL (x) == lval_memory)
- return value_zero (TYPE_POINTER_TYPE (VALUE_TYPE (x)),
- not_lval);
- else
- error ("Attempt to take address of non-lval");
- }
- return value_addr (evaluate_subexp (0, exp, pos, noside));
- }
-}
-
-/* Evaluate like `evaluate_subexp' except coercing arrays to pointers.
- When used in contexts where arrays will be coerced anyway,
- this is equivalent to `evaluate_subexp'
- but much faster because it avoids actually fetching array contents. */
-
-static value
-evaluate_subexp_with_coercion (exp, pos, noside)
- register struct expression *exp;
- register int *pos;
- enum noside noside;
-{
- register enum exp_opcode op;
- register int pc;
- register value val;
-
- pc = (*pos);
- op = exp->elts[pc].opcode;
-
- switch (op)
- {
- case OP_VAR_VALUE:
- if (TYPE_CODE (SYMBOL_TYPE (exp->elts[pc + 1].symbol)) == TYPE_CODE_ARRAY)
- {
- (*pos) += 3;
- val = locate_var_value (exp->elts[pc + 1].symbol, (CORE_ADDR) 0);
- return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (exp->elts[pc + 1].symbol))),
- val);
- }
- }
-
- return evaluate_subexp (0, exp, pos, noside);
-}
-
-/* Evaluate a subexpression of EXP, at index *POS,
- and return a value for the size of that subexpression.
- Advance *POS over the subexpression. */
-
-static value
-evaluate_subexp_for_sizeof (exp, pos)
- register struct expression *exp;
- register int *pos;
-{
- enum exp_opcode op;
- register int pc;
- value val;
-
- pc = (*pos);
- op = exp->elts[pc].opcode;
-
- switch (op)
- {
- /* This case is handled specially
- so that we avoid creating a value for the result type.
- If the result type is very big, it's desirable not to
- create a value unnecessarily. */
- case UNOP_IND:
- (*pos)++;
- val = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- return value_from_long (builtin_type_int, (LONGEST)
- TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (val))));
-
- case UNOP_MEMVAL:
- (*pos) += 3;
- return value_from_long (builtin_type_int,
- (LONGEST) TYPE_LENGTH (exp->elts[pc + 1].type));
-
- case OP_VAR_VALUE:
- (*pos) += 3;
- return value_from_long (builtin_type_int,
- (LONGEST) TYPE_LENGTH (SYMBOL_TYPE (exp->elts[pc + 1].symbol)));
-
- default:
- val = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- return value_from_long (builtin_type_int,
- (LONGEST) TYPE_LENGTH (VALUE_TYPE (val)));
- }
-}
diff --git a/gnu/usr.bin/gdb/expprint.c b/gnu/usr.bin/gdb/expprint.c
deleted file mode 100644
index 8ac95e9..0000000
--- a/gnu/usr.bin/gdb/expprint.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/* Print in infix form a struct expression.
- Copyright (C) 1986, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "symtab.h"
-#include "param.h"
-#include "expression.h"
-#include "value.h"
-
-
-/* These codes indicate operator precedences, least tightly binding first. */
-/* Adding 1 to a precedence value is done for binary operators,
- on the operand which is more tightly bound, so that operators
- of equal precedence within that operand will get parentheses. */
-/* PREC_HYPER and PREC_ABOVE_COMMA are not the precedence of any operator;
- they are used as the "surrounding precedence" to force
- various kinds of things to be parenthesized. */
-enum precedence
-{ PREC_NULL, PREC_COMMA, PREC_ABOVE_COMMA, PREC_ASSIGN, PREC_OR, PREC_AND,
- PREC_LOGIOR, PREC_LOGAND, PREC_LOGXOR, PREC_EQUAL, PREC_ORDER,
- PREC_SHIFT, PREC_ADD, PREC_MUL, PREC_REPEAT,
- PREC_HYPER, PREC_PREFIX, PREC_SUFFIX };
-
-/* Table mapping opcodes into strings for printing operators
- and precedences of the operators. */
-
-struct op_print
-{
- char *string;
- enum exp_opcode opcode;
- /* Precedence of operator. These values are used only by comparisons. */
- enum precedence precedence;
- int right_assoc;
-};
-
-static struct op_print op_print_tab[] =
- {
- {",", BINOP_COMMA, PREC_COMMA, 0},
- {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
- {"||", BINOP_OR, PREC_OR, 0},
- {"&&", BINOP_AND, PREC_AND, 0},
- {"|", BINOP_LOGIOR, PREC_LOGIOR, 0},
- {"&", BINOP_LOGAND, PREC_LOGAND, 0},
- {"^", BINOP_LOGXOR, PREC_LOGXOR, 0},
- {"==", BINOP_EQUAL, PREC_EQUAL, 0},
- {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
- {"<=", BINOP_LEQ, PREC_ORDER, 0},
- {">=", BINOP_GEQ, PREC_ORDER, 0},
- {">", BINOP_GTR, PREC_ORDER, 0},
- {"<", BINOP_LESS, PREC_ORDER, 0},
- {">>", BINOP_RSH, PREC_SHIFT, 0},
- {"<<", BINOP_LSH, PREC_SHIFT, 0},
- {"+", BINOP_ADD, PREC_ADD, 0},
- {"-", BINOP_SUB, PREC_ADD, 0},
- {"*", BINOP_MUL, PREC_MUL, 0},
- {"/", BINOP_DIV, PREC_MUL, 0},
- {"%", BINOP_REM, PREC_MUL, 0},
- {"@", BINOP_REPEAT, PREC_REPEAT, 0},
- {"-", UNOP_NEG, PREC_PREFIX, 0},
- {"!", UNOP_ZEROP, PREC_PREFIX, 0},
- {"~", UNOP_LOGNOT, PREC_PREFIX, 0},
- {"*", UNOP_IND, PREC_PREFIX, 0},
- {"&", UNOP_ADDR, PREC_PREFIX, 0},
- {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
- {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
- {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
- /* C++ */
- {"::", BINOP_SCOPE, PREC_PREFIX, 0},
- };
-
-static void print_subexp ();
-
-void
-print_expression (exp, stream)
- struct expression *exp;
- FILE *stream;
-{
- int pc = 0;
- print_subexp (exp, &pc, stream, PREC_NULL);
-}
-
-/* Print the subexpression of EXP that starts in position POS, on STREAM.
- PREC is the precedence of the surrounding operator;
- if the precedence of the main operator of this subexpression is less,
- parentheses are needed here. */
-
-static void
-print_subexp (exp, pos, stream, prec)
- register struct expression *exp;
- register int *pos;
- FILE *stream;
- enum precedence prec;
-{
- register int tem;
- register int pc;
- int nargs;
- register char *op_str;
- int assign_modify = 0;
- enum exp_opcode opcode;
- enum precedence myprec;
- /* Set to 1 for a right-associative operator. */
- int assoc;
-
- pc = (*pos)++;
- opcode = exp->elts[pc].opcode;
- switch (opcode)
- {
- case OP_SCOPE:
- myprec = PREC_PREFIX;
- assoc = 0;
- (*pos) += 2;
- print_subexp (exp, pos, stream, (int) myprec + assoc);
- fprintf (stream, " :: ");
- nargs = strlen (&exp->elts[pc + 2].string);
- (*pos) += 1 + (nargs + sizeof (union exp_element)) / sizeof (union exp_element);
-
- fprintf (stream, &exp->elts[pc + 2].string);
- return;
-
- case OP_LONG:
- (*pos) += 3;
- value_print (value_from_long (exp->elts[pc + 1].type,
- exp->elts[pc + 2].longconst),
- stream, 0, Val_no_prettyprint);
- return;
-
- case OP_DOUBLE:
- (*pos) += 3;
- value_print (value_from_double (exp->elts[pc + 1].type,
- exp->elts[pc + 2].doubleconst),
- stream, 0, Val_no_prettyprint);
- return;
-
- case OP_VAR_VALUE:
- (*pos) += 2;
- fprintf (stream, "%s", SYMBOL_NAME (exp->elts[pc + 1].symbol));
- return;
-
- case OP_LAST:
- (*pos) += 2;
- fprintf (stream, "$%d", (int) exp->elts[pc + 1].longconst);
- return;
-
- case OP_REGISTER:
- (*pos) += 2;
- fprintf (stream, "$%s", reg_names[exp->elts[pc + 1].longconst]);
- return;
-
- case OP_INTERNALVAR:
- (*pos) += 2;
- fprintf (stream, "$%s",
- internalvar_name (exp->elts[pc + 1].internalvar));
- return;
-
- case OP_FUNCALL:
- (*pos) += 2;
- nargs = exp->elts[pc + 1].longconst;
- print_subexp (exp, pos, stream, PREC_SUFFIX);
- fprintf (stream, " (");
- for (tem = 0; tem < nargs; tem++)
- {
- if (tem > 0)
- fprintf (stream, ", ");
- print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
- }
- fprintf (stream, ")");
- return;
-
- case OP_STRING:
- nargs = strlen (&exp->elts[pc + 1].string);
- (*pos) += 2 + (nargs + sizeof (union exp_element)) / sizeof (union exp_element);
- fprintf (stream, "\"");
- for (tem = 0; tem < nargs; tem++)
- printchar ((&exp->elts[pc + 1].string)[tem], stream, '"');
- fprintf (stream, "\"");
- return;
-
- case TERNOP_COND:
- if ((int) prec > (int) PREC_COMMA)
- fprintf (stream, "(");
- /* Print the subexpressions, forcing parentheses
- around any binary operations within them.
- This is more parentheses than are strictly necessary,
- but it looks clearer. */
- print_subexp (exp, pos, stream, PREC_HYPER);
- fprintf (stream, " ? ");
- print_subexp (exp, pos, stream, PREC_HYPER);
- fprintf (stream, " : ");
- print_subexp (exp, pos, stream, PREC_HYPER);
- if ((int) prec > (int) PREC_COMMA)
- fprintf (stream, ")");
- return;
-
- case STRUCTOP_STRUCT:
- tem = strlen (&exp->elts[pc + 1].string);
- (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element);
- print_subexp (exp, pos, stream, PREC_SUFFIX);
- fprintf (stream, ".%s", &exp->elts[pc + 1].string);
- return;
-
- case STRUCTOP_PTR:
- tem = strlen (&exp->elts[pc + 1].string);
- (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element);
- print_subexp (exp, pos, stream, PREC_SUFFIX);
- fprintf (stream, "->%s", &exp->elts[pc + 1].string);
- return;
-
- case BINOP_SUBSCRIPT:
- print_subexp (exp, pos, stream, PREC_SUFFIX);
- fprintf (stream, "[");
- print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
- fprintf (stream, "]");
- return;
-
- case UNOP_POSTINCREMENT:
- print_subexp (exp, pos, stream, PREC_SUFFIX);
- fprintf (stream, "++");
- return;
-
- case UNOP_POSTDECREMENT:
- print_subexp (exp, pos, stream, PREC_SUFFIX);
- fprintf (stream, "--");
- return;
-
- case UNOP_CAST:
- (*pos) += 2;
- if ((int) prec > (int) PREC_PREFIX)
- fprintf (stream, "(");
- fprintf (stream, "(");
- type_print (exp->elts[pc + 1].type, "", stream, 0);
- fprintf (stream, ") ");
- print_subexp (exp, pos, stream, PREC_PREFIX);
- if ((int) prec > (int) PREC_PREFIX)
- fprintf (stream, ")");
- return;
-
- case UNOP_MEMVAL:
- (*pos) += 2;
- if ((int) prec > (int) PREC_PREFIX)
- fprintf (stream, "(");
- fprintf (stream, "{");
- type_print (exp->elts[pc + 1].type, "", stream, 0);
- fprintf (stream, "} ");
- print_subexp (exp, pos, stream, PREC_PREFIX);
- if ((int) prec > (int) PREC_PREFIX)
- fprintf (stream, ")");
- return;
-
- case BINOP_ASSIGN_MODIFY:
- opcode = exp->elts[pc + 1].opcode;
- (*pos) += 2;
- myprec = PREC_ASSIGN;
- assoc = 1;
- assign_modify = 1;
- for (tem = 0; tem < sizeof op_print_tab / sizeof op_print_tab[0]; tem++)
- if (op_print_tab[tem].opcode == opcode)
- {
- op_str = op_print_tab[tem].string;
- break;
- }
-
- case OP_THIS:
- ++(*pos);
- fprintf (stream, "this");
- return;
-
- default:
- for (tem = 0; tem < sizeof op_print_tab / sizeof op_print_tab[0]; tem++)
- if (op_print_tab[tem].opcode == opcode)
- {
- op_str = op_print_tab[tem].string;
- myprec = op_print_tab[tem].precedence;
- assoc = op_print_tab[tem].right_assoc;
- break;
- }
- }
-
- if ((int) myprec < (int) prec)
- fprintf (stream, "(");
- if ((int) opcode > (int) BINOP_END)
- {
- /* Unary prefix operator. */
- fprintf (stream, "%s", op_str);
- print_subexp (exp, pos, stream, PREC_PREFIX);
- }
- else
- {
- /* Binary operator. */
- /* Print left operand.
- If operator is right-associative,
- increment precedence for this operand. */
- print_subexp (exp, pos, stream, (int) myprec + assoc);
- /* Print the operator itself. */
- if (assign_modify)
- fprintf (stream, " %s= ", op_str);
- else if (op_str[0] == ',')
- fprintf (stream, "%s ", op_str);
- else
- fprintf (stream, " %s ", op_str);
- /* Print right operand.
- If operator is left-associative,
- increment precedence for this operand. */
- print_subexp (exp, pos, stream, (int) myprec + !assoc);
- }
- if ((int) myprec < (int) prec)
- fprintf (stream, ")");
-}
diff --git a/gnu/usr.bin/gdb/expread.y b/gnu/usr.bin/gdb/expread.y
deleted file mode 100644
index 96a12c4..0000000
--- a/gnu/usr.bin/gdb/expread.y
+++ /dev/null
@@ -1,1782 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-/* Parse C expressions for GDB.
- Copyright (C) 1986, 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. */
-
-/* Parse a C expression from text in a string,
- and return the result as a struct expression pointer.
- That structure contains arithmetic operations in reverse polish,
- with constants represented by operations that are followed by special data.
- See expression.h for the details of the format.
- What is important here is that it can be built up sequentially
- during the process of parsing; the lower levels of the tree always
- come first in the result. */
-
-%{
-#ifndef lint
-static char sccsid[] = "@(#)expread.y 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-#include "expression.h"
-
-#include <a.out.h>
-
-static struct expression *expout;
-static int expout_size;
-static int expout_ptr;
-
-static int yylex ();
-static void yyerror ();
-static void write_exp_elt ();
-static void write_exp_elt_opcode ();
-static void write_exp_elt_sym ();
-static void write_exp_elt_longcst ();
-static void write_exp_elt_dblcst ();
-static void write_exp_elt_type ();
-static void write_exp_elt_intern ();
-static void write_exp_string ();
-static void start_arglist ();
-static int end_arglist ();
-static void free_funcalls ();
-static char *copy_name ();
-
-/* If this is nonzero, this block is used as the lexical context
- for symbol names. */
-
-static struct block *expression_context_block;
-
-/* The innermost context required by the stack and register variables
- we've encountered so far. */
-struct block *innermost_block;
-
-/* The block in which the most recently discovered symbol was found. */
-struct block *block_found;
-
-/* Number of arguments seen so far in innermost function call. */
-static int arglist_len;
-
-/* Data structure for saving values of arglist_len
- for function calls whose arguments contain other function calls. */
-
-struct funcall
- {
- struct funcall *next;
- int arglist_len;
- };
-
-struct funcall *funcall_chain;
-
-/* This kind of datum is used to represent the name
- of a symbol token. */
-
-struct stoken
- {
- char *ptr;
- int length;
- };
-
-/* For parsing of complicated types.
- An array should be preceded in the list by the size of the array. */
-enum type_pieces
- {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function};
-static enum type_pieces *type_stack;
-static int type_stack_depth, type_stack_size;
-
-static void push_type ();
-static enum type_pieces pop_type ();
-
-/* Allow debugging of parsing. */
-#define YYDEBUG 1
-%}
-
-/* Although the yacc "value" of an expression is not used,
- since the result is stored in the structure being created,
- other node types do have values. */
-
-%union
- {
- LONGEST lval;
- unsigned LONGEST ulval;
- double dval;
- struct symbol *sym;
- struct type *tval;
- struct stoken sval;
- int voidval;
- struct block *bval;
- enum exp_opcode opcode;
- struct internalvar *ivar;
-
- struct type **tvec;
- int *ivec;
- }
-
-%type <voidval> exp exp1 start variable
-%type <tval> type typebase
-%type <tvec> nonempty_typelist
-%type <bval> block
-
-/* Fancy type parsing. */
-%type <voidval> func_mod direct_abs_decl abs_decl
-%type <tval> ptype
-%type <lval> array_mod
-
-%token <lval> INT CHAR
-%token <ulval> UINT
-%token <dval> FLOAT
-
-/* Both NAME and TYPENAME tokens represent symbols in the input,
- and both convey their data as strings.
- But a TYPENAME is a string that happens to be defined as a typedef
- or builtin type name (such as int or char)
- and a NAME is any other symbol.
-
- Contexts where this distinction is not important can use the
- nonterminal "name", which matches either NAME or TYPENAME. */
-
-%token <sval> NAME TYPENAME BLOCKNAME STRING
-%type <sval> name name_not_typename typename
-
-%token STRUCT UNION ENUM SIZEOF UNSIGNED COLONCOLON
-
-/* Special type cases, put in to allow the parser to distinguish different
- legal basetypes. */
-%token SIGNED LONG SHORT INT_KEYWORD
-
-%token <lval> LAST REGNAME
-
-%token <ivar> VARIABLE
-
-%token <opcode> ASSIGN_MODIFY
-
-/* C++ */
-%token THIS
-
-%left ','
-%left ABOVE_COMMA
-%right '=' ASSIGN_MODIFY
-%right '?'
-%left OR
-%left AND
-%left '|'
-%left '^'
-%left '&'
-%left EQUAL NOTEQUAL
-%left '<' '>' LEQ GEQ
-%left LSH RSH
-%left '@'
-%left '+' '-'
-%left '*' '/' '%'
-%right UNARY INCREMENT DECREMENT
-%right ARROW '.' '[' '('
-%left COLONCOLON
-
-%%
-
-start : exp1
- ;
-
-/* Expressions, including the comma operator. */
-exp1 : exp
- | exp1 ',' exp
- { write_exp_elt_opcode (BINOP_COMMA); }
- ;
-
-/* Expressions, not including the comma operator. */
-exp : '*' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_IND); }
-
-exp : '&' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ADDR); }
-
-exp : '-' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
- ;
-
-exp : '!' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ZEROP); }
- ;
-
-exp : '~' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGNOT); }
- ;
-
-exp : INCREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREINCREMENT); }
- ;
-
-exp : DECREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREDECREMENT); }
- ;
-
-exp : exp INCREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
- ;
-
-exp : exp DECREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
- ;
-
-exp : SIZEOF exp %prec UNARY
- { write_exp_elt_opcode (UNOP_SIZEOF); }
- ;
-
-exp : exp ARROW name
- { write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_PTR); }
- ;
-
-exp : exp ARROW '*' exp
- { write_exp_elt_opcode (STRUCTOP_MPTR); }
- ;
-
-exp : exp '.' name
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
- ;
-
-exp : exp '.' '*' exp
- { write_exp_elt_opcode (STRUCTOP_MEMBER); }
- ;
-
-exp : exp '[' exp1 ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
- ;
-
-exp : exp '('
- /* This is to save the value of arglist_len
- being accumulated by an outer function call. */
- { start_arglist (); }
- arglist ')' %prec ARROW
- { write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); }
- ;
-
-arglist :
- ;
-
-arglist : exp
- { arglist_len = 1; }
- ;
-
-arglist : arglist ',' exp %prec ABOVE_COMMA
- { arglist_len++; }
- ;
-
-exp : '{' type '}' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_MEMVAL);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_MEMVAL); }
- ;
-
-exp : '(' type ')' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_CAST); }
- ;
-
-exp : '(' exp1 ')'
- { }
- ;
-
-/* Binary operators in order of decreasing precedence. */
-
-exp : exp '@' exp
- { write_exp_elt_opcode (BINOP_REPEAT); }
- ;
-
-exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
- ;
-
-exp : exp '/' exp
- { write_exp_elt_opcode (BINOP_DIV); }
- ;
-
-exp : exp '%' exp
- { write_exp_elt_opcode (BINOP_REM); }
- ;
-
-exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
- ;
-
-exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
- ;
-
-exp : exp LSH exp
- { write_exp_elt_opcode (BINOP_LSH); }
- ;
-
-exp : exp RSH exp
- { write_exp_elt_opcode (BINOP_RSH); }
- ;
-
-exp : exp EQUAL exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
- ;
-
-exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
- ;
-
-exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ); }
- ;
-
-exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ); }
- ;
-
-exp : exp '<' exp
- { write_exp_elt_opcode (BINOP_LESS); }
- ;
-
-exp : exp '>' exp
- { write_exp_elt_opcode (BINOP_GTR); }
- ;
-
-exp : exp '&' exp
- { write_exp_elt_opcode (BINOP_LOGAND); }
- ;
-
-exp : exp '^' exp
- { write_exp_elt_opcode (BINOP_LOGXOR); }
- ;
-
-exp : exp '|' exp
- { write_exp_elt_opcode (BINOP_LOGIOR); }
- ;
-
-exp : exp AND exp
- { write_exp_elt_opcode (BINOP_AND); }
- ;
-
-exp : exp OR exp
- { write_exp_elt_opcode (BINOP_OR); }
- ;
-
-exp : exp '?' exp ':' exp %prec '?'
- { write_exp_elt_opcode (TERNOP_COND); }
- ;
-
-exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
- ;
-
-exp : exp ASSIGN_MODIFY exp
- { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode ($2);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
- ;
-
-exp : INT
- { write_exp_elt_opcode (OP_LONG);
- if ($1 == (int) $1 || $1 == (unsigned int) $1)
- write_exp_elt_type (builtin_type_int);
- else
- write_exp_elt_type (BUILTIN_TYPE_LONGEST);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_LONG); }
- ;
-
-exp : UINT
- {
- write_exp_elt_opcode (OP_LONG);
- if ($1 == (unsigned int) $1)
- write_exp_elt_type (builtin_type_unsigned_int);
- else
- write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_LONG);
- }
- ;
-
-exp : CHAR
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_char);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_LONG); }
- ;
-
-exp : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (builtin_type_double);
- write_exp_elt_dblcst ($1);
- write_exp_elt_opcode (OP_DOUBLE); }
- ;
-
-exp : variable
- ;
-
-exp : LAST
- { write_exp_elt_opcode (OP_LAST);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_LAST); }
- ;
-
-exp : REGNAME
- { write_exp_elt_opcode (OP_REGISTER);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_REGISTER); }
- ;
-
-exp : VARIABLE
- { write_exp_elt_opcode (OP_INTERNALVAR);
- write_exp_elt_intern ($1);
- write_exp_elt_opcode (OP_INTERNALVAR); }
- ;
-
-exp : SIZEOF '(' type ')' %prec UNARY
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG); }
- ;
-
-exp : STRING
- { write_exp_elt_opcode (OP_STRING);
- write_exp_string ($1);
- write_exp_elt_opcode (OP_STRING); }
- ;
-
-/* C++. */
-exp : THIS
- { write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS); }
- ;
-
-/* end of C++. */
-
-block : BLOCKNAME
- {
- struct symtab *tem = lookup_symtab (copy_name ($1));
- struct symbol *sym;
-
- if (tem)
- $$ = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), 1);
- else
- {
- sym = lookup_symbol (copy_name ($1),
- expression_context_block,
- VAR_NAMESPACE, 0);
- if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
- $$ = SYMBOL_BLOCK_VALUE (sym);
- else
- error ("No file or function \"%s\".",
- copy_name ($1));
- }
- }
- ;
-
-block : block COLONCOLON name
- { struct symbol *tem
- = lookup_symbol (copy_name ($3), $1, VAR_NAMESPACE, 0);
- if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
- error ("No function \"%s\" in specified context.",
- copy_name ($3));
- $$ = SYMBOL_BLOCK_VALUE (tem); }
- ;
-
-variable: block COLONCOLON name
- { struct symbol *sym;
- sym = lookup_symbol (copy_name ($3), $1, VAR_NAMESPACE, 0);
- if (sym == 0)
- error ("No symbol \"%s\" in specified context.",
- copy_name ($3));
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE); }
- ;
-
-variable: typebase COLONCOLON name
- {
- struct type *type = $1;
- if (TYPE_CODE (type) != TYPE_CODE_STRUCT
- && TYPE_CODE (type) != TYPE_CODE_UNION)
- error ("`%s' is not defined as an aggregate type.",
- TYPE_NAME (type));
-
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (type);
- write_exp_string ($3);
- write_exp_elt_opcode (OP_SCOPE);
- }
- | COLONCOLON name
- {
- char *name = copy_name ($2);
- struct symbol *sym;
- int i;
-
- sym = lookup_symbol (name, 0, VAR_NAMESPACE, 0);
- if (sym)
- {
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
- break;
- }
- for (i = 0; i < misc_function_count; i++)
- if (!strcmp (misc_function_vector[i].name, name))
- break;
-
- if (i < misc_function_count)
- {
- enum misc_function_type mft =
- (enum misc_function_type)
- misc_function_vector[i].type;
-
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_opcode (UNOP_MEMVAL);
- if (mft == mf_data || mft == mf_bss)
- write_exp_elt_type (builtin_type_int);
- else if (mft == mf_text)
- write_exp_elt_type (lookup_function_type (builtin_type_int));
- else
- write_exp_elt_type (builtin_type_char);
- write_exp_elt_opcode (UNOP_MEMVAL);
- }
- else
- if (symtab_list == 0
- && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
- else
- error ("No symbol \"%s\" in current context.", name);
- }
- ;
-
-variable: name_not_typename
- { struct symbol *sym;
- int is_a_field_of_this;
-
- sym = lookup_symbol (copy_name ($1),
- expression_context_block,
- VAR_NAMESPACE,
- &is_a_field_of_this);
- if (sym)
- {
- switch (sym->class)
- {
- case LOC_REGISTER:
- case LOC_ARG:
- case LOC_LOCAL:
- if (innermost_block == 0 ||
- contained_in (block_found,
- innermost_block))
- innermost_block = block_found;
- }
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
- }
- else if (is_a_field_of_this)
- {
- /* C++: it hangs off of `this'. Must
- not inadvertently convert from a method call
- to data ref. */
- if (innermost_block == 0 ||
- contained_in (block_found, innermost_block))
- innermost_block = block_found;
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($1);
- write_exp_elt_opcode (STRUCTOP_PTR);
- }
- else
- {
- register int i;
- register char *arg = copy_name ($1);
-
- for (i = 0; i < misc_function_count; i++)
- if (!strcmp (misc_function_vector[i].name, arg))
- break;
-
- if (i < misc_function_count)
- {
- enum misc_function_type mft =
- (enum misc_function_type)
- misc_function_vector[i].type;
-
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_opcode (UNOP_MEMVAL);
- if (mft == mf_data || mft == mf_bss)
- write_exp_elt_type (builtin_type_int);
- else if (mft == mf_text)
- write_exp_elt_type (lookup_function_type (builtin_type_int));
- else
- write_exp_elt_type (builtin_type_char);
- write_exp_elt_opcode (UNOP_MEMVAL);
- }
- else if (symtab_list == 0
- && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
- else
- error ("No symbol \"%s\" in current context.",
- copy_name ($1));
- }
- }
- ;
-
-
-ptype : typebase
- | typebase abs_decl
- {
- /* This is where the interesting stuff happens. */
- int done = 0;
- int array_size;
- struct type *follow_type = $1;
-
- while (!done)
- switch (pop_type ())
- {
- case tp_end:
- done = 1;
- break;
- case tp_pointer:
- follow_type = lookup_pointer_type (follow_type);
- break;
- case tp_reference:
- follow_type = lookup_reference_type (follow_type);
- break;
- case tp_array:
- array_size = (int) pop_type ();
- if (array_size != -1)
- follow_type = create_array_type (follow_type,
- array_size);
- else
- follow_type = lookup_pointer_type (follow_type);
- break;
- case tp_function:
- follow_type = lookup_function_type (follow_type);
- break;
- }
- $$ = follow_type;
- }
- ;
-
-abs_decl: '*'
- { push_type (tp_pointer); $$ = 0; }
- | '*' abs_decl
- { push_type (tp_pointer); $$ = $2; }
- | direct_abs_decl
- ;
-
-direct_abs_decl: '(' abs_decl ')'
- { $$ = $2; }
- | direct_abs_decl array_mod
- {
- push_type ((enum type_pieces) $2);
- push_type (tp_array);
- }
- | array_mod
- {
- push_type ((enum type_pieces) $1);
- push_type (tp_array);
- $$ = 0;
- }
- | direct_abs_decl func_mod
- { push_type (tp_function); }
- | func_mod
- { push_type (tp_function); }
- ;
-
-array_mod: '[' ']'
- { $$ = -1; }
- | '[' INT ']'
- { $$ = $2; }
- ;
-
-func_mod: '(' ')'
- { $$ = 0; }
- ;
-
-type : ptype
- | typebase COLONCOLON '*'
- { $$ = lookup_member_type (builtin_type_int, $1); }
- | type '(' typebase COLONCOLON '*' ')'
- { $$ = lookup_member_type ($1, $3); }
- | type '(' typebase COLONCOLON '*' ')' '(' ')'
- { $$ = lookup_member_type
- (lookup_function_type ($1), $3); }
- | type '(' typebase COLONCOLON '*' ')' '(' nonempty_typelist ')'
- { $$ = lookup_member_type
- (lookup_function_type ($1), $3);
- free ($8); }
- ;
-
-typebase
- : TYPENAME
- { $$ = lookup_typename (copy_name ($1),
- expression_context_block, 0); }
- | INT_KEYWORD
- { $$ = builtin_type_int; }
- | LONG
- { $$ = builtin_type_long; }
- | SHORT
- { $$ = builtin_type_short; }
- | LONG INT_KEYWORD
- { $$ = builtin_type_long; }
- | UNSIGNED LONG INT_KEYWORD
- { $$ = builtin_type_unsigned_long; }
- | SHORT INT_KEYWORD
- { $$ = builtin_type_short; }
- | UNSIGNED SHORT INT_KEYWORD
- { $$ = builtin_type_unsigned_short; }
- | STRUCT name
- { $$ = lookup_struct (copy_name ($2),
- expression_context_block); }
- | UNION name
- { $$ = lookup_union (copy_name ($2),
- expression_context_block); }
- | ENUM name
- { $$ = lookup_enum (copy_name ($2),
- expression_context_block); }
- | UNSIGNED typename
- { $$ = lookup_unsigned_typename (copy_name ($2)); }
- | UNSIGNED
- { $$ = builtin_type_unsigned_int; }
- | SIGNED typename
- { $$ = lookup_typename (copy_name ($2),
- expression_context_block, 0); }
- | SIGNED
- { $$ = builtin_type_int; }
- ;
-
-typename: TYPENAME
- | INT_KEYWORD
- {
- $$.ptr = "int";
- $$.length = 3;
- }
- | LONG
- {
- $$.ptr = "long";
- $$.length = 4;
- }
- | SHORT
- {
- $$.ptr = "short";
- $$.length = 5;
- }
- ;
-
-nonempty_typelist
- : type
- { $$ = (struct type **)xmalloc (sizeof (struct type *) * 2);
- $$[0] = (struct type *)0;
- $$[1] = $1;
- }
- | nonempty_typelist ',' type
- { int len = sizeof (struct type *) * ++($<ivec>1[0]);
- $$ = (struct type **)xrealloc ($1, len);
- $$[$<ivec>$[0]] = $3;
- }
- ;
-
-name : NAME
- | BLOCKNAME
- | TYPENAME
- ;
-
-name_not_typename : NAME
- | BLOCKNAME
- ;
-
-%%
-
-/* Begin counting arguments for a function call,
- saving the data about any containing call. */
-
-static void
-start_arglist ()
-{
- register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall));
-
- new->next = funcall_chain;
- new->arglist_len = arglist_len;
- arglist_len = 0;
- funcall_chain = new;
-}
-
-/* Return the number of arguments in a function call just terminated,
- and restore the data for the containing function call. */
-
-static int
-end_arglist ()
-{
- register int val = arglist_len;
- register struct funcall *call = funcall_chain;
- funcall_chain = call->next;
- arglist_len = call->arglist_len;
- free (call);
- return val;
-}
-
-/* Free everything in the funcall chain.
- Used when there is an error inside parsing. */
-
-static void
-free_funcalls ()
-{
- register struct funcall *call, *next;
-
- for (call = funcall_chain; call; call = next)
- {
- next = call->next;
- free (call);
- }
-}
-
-/* This page contains the functions for adding data to the struct expression
- being constructed. */
-
-/* Add one element to the end of the expression. */
-
-/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
- a register through here */
-
-static void
-write_exp_elt (expelt)
- union exp_element expelt;
-{
- if (expout_ptr >= expout_size)
- {
- expout_size *= 2;
- expout = (struct expression *) xrealloc (expout,
- sizeof (struct expression)
- + expout_size * sizeof (union exp_element));
- }
- expout->elts[expout_ptr++] = expelt;
-}
-
-static void
-write_exp_elt_opcode (expelt)
- enum exp_opcode expelt;
-{
- union exp_element tmp;
-
- tmp.opcode = expelt;
-
- write_exp_elt (tmp);
-}
-
-static void
-write_exp_elt_sym (expelt)
- struct symbol *expelt;
-{
- union exp_element tmp;
-
- tmp.symbol = expelt;
-
- write_exp_elt (tmp);
-}
-
-static void
-write_exp_elt_longcst (expelt)
- LONGEST expelt;
-{
- union exp_element tmp;
-
- tmp.longconst = expelt;
-
- write_exp_elt (tmp);
-}
-
-static void
-write_exp_elt_dblcst (expelt)
- double expelt;
-{
- union exp_element tmp;
-
- tmp.doubleconst = expelt;
-
- write_exp_elt (tmp);
-}
-
-static void
-write_exp_elt_type (expelt)
- struct type *expelt;
-{
- union exp_element tmp;
-
- tmp.type = expelt;
-
- write_exp_elt (tmp);
-}
-
-static void
-write_exp_elt_intern (expelt)
- struct internalvar *expelt;
-{
- union exp_element tmp;
-
- tmp.internalvar = expelt;
-
- write_exp_elt (tmp);
-}
-
-/* Add a string constant to the end of the expression.
- Follow it by its length in bytes, as a separate exp_element. */
-
-static void
-write_exp_string (str)
- struct stoken str;
-{
- register int len = str.length;
- register int lenelt
- = (len + sizeof (union exp_element)) / sizeof (union exp_element);
-
- expout_ptr += lenelt;
-
- if (expout_ptr >= expout_size)
- {
- expout_size = max (expout_size * 2, expout_ptr + 10);
- expout = (struct expression *)
- xrealloc (expout, (sizeof (struct expression)
- + (expout_size * sizeof (union exp_element))));
- }
- bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len);
- ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0;
- write_exp_elt_longcst ((LONGEST) len);
-}
-
-/* During parsing of a C expression, the pointer to the next character
- is in this variable. */
-
-static char *lexptr;
-
-/* Tokens that refer to names do so with explicit pointer and length,
- so they can share the storage that lexptr is parsing.
-
- When it is necessary to pass a name to a function that expects
- a null-terminated string, the substring is copied out
- into a block of storage that namecopy points to.
-
- namecopy is allocated once, guaranteed big enough, for each parsing. */
-
-static char *namecopy;
-
-/* Current depth in parentheses within the expression. */
-
-static int paren_depth;
-
-/* Nonzero means stop parsing on first comma (if not within parentheses). */
-
-static int comma_terminates;
-
-/* Take care of parsing a number (anything that starts with a digit).
- Set yylval and return the token type; update lexptr.
- LEN is the number of characters in it. */
-
-/*** Needs some error checking for the float case ***/
-
-static int
-parse_number (olen)
- int olen;
-{
- register char *p = lexptr;
- register LONGEST n = 0;
- register int c;
- register int base = 10;
- register int len = olen;
- char *err_copy;
- int unsigned_p = 0;
-
- extern double atof ();
-
- for (c = 0; c < len; c++)
- if (p[c] == '.')
- {
- /* It's a float since it contains a point. */
- yylval.dval = atof (p);
- lexptr += len;
- return FLOAT;
- }
-
- if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2)))
- {
- p += 2;
- base = 16;
- len -= 2;
- }
- else if (*p == '0')
- base = 8;
-
- while (len-- > 0)
- {
- c = *p++;
- if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
- if (c != 'l' && c != 'u')
- n *= base;
- if (c >= '0' && c <= '9')
- n += c - '0';
- else
- {
- if (base == 16 && c >= 'a' && c <= 'f')
- n += c - 'a' + 10;
- else if (len == 0 && c == 'l')
- ;
- else if (len == 0 && c == 'u')
- unsigned_p = 1;
- else if (base == 10 && len != 0 && (c == 'e' || c == 'E'))
- {
- /* Scientific notation, where we are unlucky enough not
- to have a '.' in the string. */
- yylval.dval = atof (lexptr);
- lexptr += olen;
- return FLOAT;
- }
- else
- {
- err_copy = (char *) alloca (olen + 1);
- bcopy (lexptr, err_copy, olen);
- err_copy[olen] = 0;
- error ("Invalid number \"%s\".", err_copy);
- }
- }
- }
-
- lexptr = p;
- if (unsigned_p)
- {
- yylval.ulval = n;
- return UINT;
- }
- else
- {
- yylval.lval = n;
- return INT;
- }
-}
-
-struct token
-{
- char *operator;
- int token;
- enum exp_opcode opcode;
-};
-
-static struct token tokentab3[] =
- {
- {">>=", ASSIGN_MODIFY, BINOP_RSH},
- {"<<=", ASSIGN_MODIFY, BINOP_LSH}
- };
-
-static struct token tokentab2[] =
- {
- {"+=", ASSIGN_MODIFY, BINOP_ADD},
- {"-=", ASSIGN_MODIFY, BINOP_SUB},
- {"*=", ASSIGN_MODIFY, BINOP_MUL},
- {"/=", ASSIGN_MODIFY, BINOP_DIV},
- {"%=", ASSIGN_MODIFY, BINOP_REM},
- {"|=", ASSIGN_MODIFY, BINOP_LOGIOR},
- {"&=", ASSIGN_MODIFY, BINOP_LOGAND},
- {"^=", ASSIGN_MODIFY, BINOP_LOGXOR},
- {"++", INCREMENT, BINOP_END},
- {"--", DECREMENT, BINOP_END},
- {"->", ARROW, BINOP_END},
- {"&&", AND, BINOP_END},
- {"||", OR, BINOP_END},
- {"::", COLONCOLON, BINOP_END},
- {"<<", LSH, BINOP_END},
- {">>", RSH, BINOP_END},
- {"==", EQUAL, BINOP_END},
- {"!=", NOTEQUAL, BINOP_END},
- {"<=", LEQ, BINOP_END},
- {">=", GEQ, BINOP_END}
- };
-
-/* assign machine-independent names to certain registers
- * (unless overridden by the REGISTER_NAMES table)
- */
-struct std_regs {
- char *name;
- int regnum;
-} std_regs[] = {
-#ifdef PC_REGNUM
- { "pc", PC_REGNUM },
-#endif
-#ifdef FP_REGNUM
- { "fp", FP_REGNUM },
-#endif
-#ifdef SP_REGNUM
- { "sp", SP_REGNUM },
-#endif
-#ifdef PS_REGNUM
- { "ps", PS_REGNUM },
-#endif
-};
-
-#define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0])
-
-/* Read one token, getting characters through lexptr. */
-
-static int
-yylex ()
-{
- register int c;
- register int namelen;
- register int i;
- register char *tokstart;
-
- retry:
-
- tokstart = lexptr;
- /* See if it is a special token of length 3. */
- for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
- if (!strncmp (tokstart, tokentab3[i].operator, 3))
- {
- lexptr += 3;
- yylval.opcode = tokentab3[i].opcode;
- return tokentab3[i].token;
- }
-
- /* See if it is a special token of length 2. */
- for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
- if (!strncmp (tokstart, tokentab2[i].operator, 2))
- {
- lexptr += 2;
- yylval.opcode = tokentab2[i].opcode;
- return tokentab2[i].token;
- }
-
- switch (c = *tokstart)
- {
- case 0:
- return 0;
-
- case ' ':
- case '\t':
- case '\n':
- lexptr++;
- goto retry;
-
- case '\'':
- lexptr++;
- c = *lexptr++;
- if (c == '\\')
- c = parse_escape (&lexptr);
- yylval.lval = c;
- c = *lexptr++;
- if (c != '\'')
- error ("Invalid character constant.");
- return CHAR;
-
- case '(':
- paren_depth++;
- lexptr++;
- return c;
-
- case ')':
- if (paren_depth == 0)
- return 0;
- paren_depth--;
- lexptr++;
- return c;
-
- case ',':
- if (comma_terminates && paren_depth == 0)
- return 0;
- lexptr++;
- return c;
-
- case '.':
- /* Might be a floating point number. */
- if (lexptr[1] >= '0' && lexptr[1] <= '9')
- break; /* Falls into number code. */
-
- case '+':
- case '-':
- case '*':
- case '/':
- case '%':
- case '|':
- case '&':
- case '^':
- case '~':
- case '!':
- case '@':
- case '<':
- case '>':
- case '[':
- case ']':
- case '?':
- case ':':
- case '=':
- case '{':
- case '}':
- lexptr++;
- return c;
-
- case '"':
- for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++)
- if (c == '\\')
- {
- c = tokstart[++namelen];
- if (c >= '0' && c <= '9')
- {
- c = tokstart[++namelen];
- if (c >= '0' && c <= '9')
- c = tokstart[++namelen];
- }
- }
- yylval.sval.ptr = tokstart + 1;
- yylval.sval.length = namelen - 1;
- lexptr += namelen + 1;
- return STRING;
- }
-
- /* Is it a number? */
- /* Note: We have already dealt with the case of the token '.'.
- See case '.' above. */
- if ((c >= '0' && c <= '9') || c == '.')
- {
- /* It's a number. */
- int got_dot = 0, got_e = 0;
- register char *p = tokstart;
- int hex = c == '0' && (p[1] == 'x' || p[1] == 'X');
- if (hex)
- p += 2;
- for (;; ++p)
- {
- if (!hex && !got_e && (*p == 'e' || *p == 'E'))
- got_dot = got_e = 1;
- else if (!hex && !got_dot && *p == '.')
- got_dot = 1;
- else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
- && (*p == '-' || *p == '+'))
- /* This is the sign of the exponent, not the end of the
- number. */
- continue;
- else if (!got_dot && !got_e && (*p=='l'||*p=='L')){
- ++p; break;
- }
- else if (!got_dot && !got_e && !hex && (*p=='u'||*p=='U')){
- ++p; break;
- }
- else if (*p < '0' || *p > '9'
- && (!hex || ((*p < 'a' || *p > 'f')
- && (*p < 'A' || *p > 'F'))))
- break;
- }
- return parse_number (p - tokstart);
- }
-
- if (!(c == '_' || c == '$'
- || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
- /* We must have come across a bad character (e.g. ';'). */
- error ("Invalid character '%c' in expression.", c);
-
- /* It's a name. See how long it is. */
- namelen = 0;
- for (c = tokstart[namelen];
- (c == '_' || c == '$' || (c >= '0' && c <= '9')
- || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
- c = tokstart[++namelen])
- ;
-
- /* The token "if" terminates the expression and is NOT
- removed from the input stream. */
- if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
- {
- return 0;
- }
-
- lexptr += namelen;
-
- /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
- and $$digits (equivalent to $<-digits> if you could type that).
- Make token type LAST, and put the number (the digits) in yylval. */
-
- if (*tokstart == '$')
- {
- register int negate = 0;
- c = 1;
- /* Double dollar means negate the number and add -1 as well.
- Thus $$ alone means -1. */
- if (namelen >= 2 && tokstart[1] == '$')
- {
- negate = 1;
- c = 2;
- }
- if (c == namelen)
- {
- /* Just dollars (one or two) */
- yylval.lval = - negate;
- return LAST;
- }
- /* Is the rest of the token digits? */
- for (; c < namelen; c++)
- if (!(tokstart[c] >= '0' && tokstart[c] <= '9'))
- break;
- if (c == namelen)
- {
- yylval.lval = atoi (tokstart + 1 + negate);
- if (negate)
- yylval.lval = - yylval.lval;
- return LAST;
- }
- }
-
- /* Handle tokens that refer to machine registers:
- $ followed by a register name. */
-
- if (*tokstart == '$') {
- for (c = 0; c < NUM_REGS; c++)
- if (namelen - 1 == strlen (reg_names[c])
- && !strncmp (tokstart + 1, reg_names[c], namelen - 1))
- {
- yylval.lval = c;
- return REGNAME;
- }
- for (c = 0; c < NUM_STD_REGS; c++)
- if (namelen - 1 == strlen (std_regs[c].name)
- && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1))
- {
- yylval.lval = std_regs[c].regnum;
- return REGNAME;
- }
- }
- /* Catch specific keywords. Should be done with a data structure. */
- switch (namelen)
- {
- case 8:
- if (!strncmp (tokstart, "unsigned", 8))
- return UNSIGNED;
- break;
- case 6:
- if (!strncmp (tokstart, "struct", 6))
- return STRUCT;
- if (!strncmp (tokstart, "signed", 6))
- return SIGNED;
- if (!strncmp (tokstart, "sizeof", 6))
- return SIZEOF;
- break;
- case 5:
- if (!strncmp (tokstart, "union", 5))
- return UNION;
- if (!strncmp (tokstart, "short", 5))
- return SHORT;
- break;
- case 4:
- if (!strncmp (tokstart, "enum", 4))
- return ENUM;
- if (!strncmp (tokstart, "long", 4))
- return LONG;
- if (!strncmp (tokstart, "this", 4)
- && lookup_symbol ("$this", expression_context_block,
- VAR_NAMESPACE, 0))
- return THIS;
- break;
- case 3:
- if (!strncmp (tokstart, "int", 3))
- return INT_KEYWORD;
- break;
- default:
- break;
- }
-
- yylval.sval.ptr = tokstart;
- yylval.sval.length = namelen;
-
- /* Any other names starting in $ are debugger internal variables. */
-
- if (*tokstart == '$')
- {
- yylval.ivar = (struct internalvar *) lookup_internalvar (copy_name (yylval.sval) + 1);
- return VARIABLE;
- }
-
- /* Use token-type BLOCKNAME for symbols that happen to be defined as
- functions or symtabs. If this is not so, then ...
- Use token-type TYPENAME for symbols that happen to be defined
- currently as names of types; NAME for other symbols.
- The caller is not constrained to care about the distinction. */
- {
- char *tmp = copy_name (yylval.sval);
- struct symbol *sym;
-
- if (lookup_partial_symtab (tmp))
- return BLOCKNAME;
- sym = lookup_symbol (tmp, expression_context_block,
- VAR_NAMESPACE, 0);
- if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
- return BLOCKNAME;
- if (lookup_typename (copy_name (yylval.sval), expression_context_block, 1))
- return TYPENAME;
- return NAME;
- }
-}
-
-static void
-yyerror ()
-{
- error ("Invalid syntax in expression.");
-}
-
-/* Return a null-terminated temporary copy of the name
- of a string token. */
-
-static char *
-copy_name (token)
- struct stoken token;
-{
- bcopy (token.ptr, namecopy, token.length);
- namecopy[token.length] = 0;
- return namecopy;
-}
-
-/* Reverse an expression from suffix form (in which it is constructed)
- to prefix form (in which we can conveniently print or execute it). */
-
-static void prefixify_subexp ();
-
-static void
-prefixify_expression (expr)
- register struct expression *expr;
-{
- register int len = sizeof (struct expression) +
- expr->nelts * sizeof (union exp_element);
- register struct expression *temp;
- register int inpos = expr->nelts, outpos = 0;
-
- temp = (struct expression *) alloca (len);
-
- /* Copy the original expression into temp. */
- bcopy (expr, temp, len);
-
- prefixify_subexp (temp, expr, inpos, outpos);
-}
-
-/* Return the number of exp_elements in the subexpression of EXPR
- whose last exp_element is at index ENDPOS - 1 in EXPR. */
-
-static int
-length_of_subexp (expr, endpos)
- register struct expression *expr;
- register int endpos;
-{
- register int oplen = 1;
- register int args = 0;
- register int i;
-
- if (endpos < 0)
- error ("?error in length_of_subexp");
-
- i = (int) expr->elts[endpos - 1].opcode;
-
- switch (i)
- {
- /* C++ */
- case OP_SCOPE:
- oplen = 4 + ((expr->elts[endpos - 2].longconst
- + sizeof (union exp_element))
- / sizeof (union exp_element));
- break;
-
- case OP_LONG:
- case OP_DOUBLE:
- oplen = 4;
- break;
-
- case OP_VAR_VALUE:
- case OP_LAST:
- case OP_REGISTER:
- case OP_INTERNALVAR:
- oplen = 3;
- break;
-
- case OP_FUNCALL:
- oplen = 3;
- args = 1 + expr->elts[endpos - 2].longconst;
- break;
-
- case UNOP_CAST:
- case UNOP_MEMVAL:
- oplen = 3;
- args = 1;
- break;
-
- case STRUCTOP_STRUCT:
- case STRUCTOP_PTR:
- args = 1;
- case OP_STRING:
- oplen = 3 + ((expr->elts[endpos - 2].longconst
- + sizeof (union exp_element))
- / sizeof (union exp_element));
- break;
-
- case TERNOP_COND:
- args = 3;
- break;
-
- case BINOP_ASSIGN_MODIFY:
- oplen = 3;
- args = 2;
- break;
-
- /* C++ */
- case OP_THIS:
- oplen = 2;
- break;
-
- default:
- args = 1 + (i < (int) BINOP_END);
- }
-
- while (args > 0)
- {
- oplen += length_of_subexp (expr, endpos - oplen);
- args--;
- }
-
- return oplen;
-}
-
-/* Copy the subexpression ending just before index INEND in INEXPR
- into OUTEXPR, starting at index OUTBEG.
- In the process, convert it from suffix to prefix form. */
-
-static void
-prefixify_subexp (inexpr, outexpr, inend, outbeg)
- register struct expression *inexpr;
- struct expression *outexpr;
- register int inend;
- int outbeg;
-{
- register int oplen = 1;
- register int args = 0;
- register int i;
- int *arglens;
- enum exp_opcode opcode;
-
- /* Compute how long the last operation is (in OPLEN),
- and also how many preceding subexpressions serve as
- arguments for it (in ARGS). */
-
- opcode = inexpr->elts[inend - 1].opcode;
- switch (opcode)
- {
- /* C++ */
- case OP_SCOPE:
- oplen = 4 + ((inexpr->elts[inend - 2].longconst
- + sizeof (union exp_element))
- / sizeof (union exp_element));
- break;
-
- case OP_LONG:
- case OP_DOUBLE:
- oplen = 4;
- break;
-
- case OP_VAR_VALUE:
- case OP_LAST:
- case OP_REGISTER:
- case OP_INTERNALVAR:
- oplen = 3;
- break;
-
- case OP_FUNCALL:
- oplen = 3;
- args = 1 + inexpr->elts[inend - 2].longconst;
- break;
-
- case UNOP_CAST:
- case UNOP_MEMVAL:
- oplen = 3;
- args = 1;
- break;
-
- case STRUCTOP_STRUCT:
- case STRUCTOP_PTR:
- args = 1;
- case OP_STRING:
- oplen = 3 + ((inexpr->elts[inend - 2].longconst
- + sizeof (union exp_element))
- / sizeof (union exp_element));
-
- break;
-
- case TERNOP_COND:
- args = 3;
- break;
-
- case BINOP_ASSIGN_MODIFY:
- oplen = 3;
- args = 2;
- break;
-
- /* C++ */
- case OP_THIS:
- oplen = 2;
- break;
-
- default:
- args = 1 + ((int) opcode < (int) BINOP_END);
- }
-
- /* Copy the final operator itself, from the end of the input
- to the beginning of the output. */
- inend -= oplen;
- bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg],
- oplen * sizeof (union exp_element));
- outbeg += oplen;
-
- /* Find the lengths of the arg subexpressions. */
- arglens = (int *) alloca (args * sizeof (int));
- for (i = args - 1; i >= 0; i--)
- {
- oplen = length_of_subexp (inexpr, inend);
- arglens[i] = oplen;
- inend -= oplen;
- }
-
- /* Now copy each subexpression, preserving the order of
- the subexpressions, but prefixifying each one.
- In this loop, inend starts at the beginning of
- the expression this level is working on
- and marches forward over the arguments.
- outbeg does similarly in the output. */
- for (i = 0; i < args; i++)
- {
- oplen = arglens[i];
- inend += oplen;
- prefixify_subexp (inexpr, outexpr, inend, outbeg);
- outbeg += oplen;
- }
-}
-
-/* This page contains the two entry points to this file. */
-
-/* Read a C expression from the string *STRINGPTR points to,
- parse it, and return a pointer to a struct expression that we malloc.
- Use block BLOCK as the lexical context for variable names;
- if BLOCK is zero, use the block of the selected stack frame.
- Meanwhile, advance *STRINGPTR to point after the expression,
- at the first nonwhite character that is not part of the expression
- (possibly a null character).
-
- If COMMA is nonzero, stop if a comma is reached. */
-
-struct expression *
-parse_c_1 (stringptr, block, comma)
- char **stringptr;
- struct block *block;
-{
- struct cleanup *old_chain;
-
- lexptr = *stringptr;
-
- paren_depth = 0;
- type_stack_depth = 0;
-
- comma_terminates = comma;
-
- if (lexptr == 0 || *lexptr == 0)
- error_no_arg ("expression to compute");
-
- old_chain = make_cleanup (free_funcalls, 0);
- funcall_chain = 0;
-
- expression_context_block = block ? block : get_selected_block ();
-
- namecopy = (char *) alloca (strlen (lexptr) + 1);
- expout_size = 10;
- expout_ptr = 0;
- expout = (struct expression *)
- xmalloc (sizeof (struct expression)
- + expout_size * sizeof (union exp_element));
- make_cleanup (free_current_contents, &expout);
- if (yyparse ())
- yyerror ();
- discard_cleanups (old_chain);
- expout->nelts = expout_ptr;
- expout = (struct expression *)
- xrealloc (expout,
- sizeof (struct expression)
- + expout_ptr * sizeof (union exp_element));
- prefixify_expression (expout);
- *stringptr = lexptr;
- return expout;
-}
-
-/* Parse STRING as an expression, and complain if this fails
- to use up all of the contents of STRING. */
-
-struct expression *
-parse_c_expression (string)
- char *string;
-{
- register struct expression *exp;
- exp = parse_c_1 (&string, 0, 0);
- if (*string)
- error ("Junk after end of expression.");
- return exp;
-}
-
-static void
-push_type (tp)
- enum type_pieces tp;
-{
- if (type_stack_depth == type_stack_size)
- {
- type_stack_size *= 2;
- type_stack = (enum type_pieces *)
- xrealloc (type_stack, type_stack_size * sizeof (enum type_pieces));
- }
- type_stack[type_stack_depth++] = tp;
-}
-
-static enum type_pieces
-pop_type ()
-{
- if (type_stack_depth)
- return type_stack[--type_stack_depth];
- return tp_end;
-}
-
-void
-_initialize_expread ()
-{
- type_stack_size = 80;
- type_stack_depth = 0;
- type_stack = (enum type_pieces *)
- xmalloc (type_stack_size * sizeof (enum type_pieces));
-}
diff --git a/gnu/usr.bin/gdb/expression.h b/gnu/usr.bin/gdb/expression.h
deleted file mode 100644
index 5a5e20e..0000000
--- a/gnu/usr.bin/gdb/expression.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/* Definitions for expressions stored in reversed prefix form, for GDB.
- Copyright (C) 1986, 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. */
-
-/* Definitions for saved C expressions. */
-
-/* An expression is represented as a vector of union exp_element's.
- Each exp_element is an opcode, except that some opcodes cause
- the following exp_element to be treated as a long or double constant
- or as a variable. The opcodes are obeyed, using a stack for temporaries.
- The value is left on the temporary stack at the end. */
-
-/* When it is necessary to include a string,
- it can occupy as many exp_elements as it needs.
- We find the length of the string using strlen,
- divide to find out how many exp_elements are used up,
- and skip that many. Strings, like numbers, are indicated
- by the preceding opcode. */
-
-enum exp_opcode
-{
-/* BINOP_... operate on two values computed by following subexpressions,
- replacing them by one result value. They take no immediate arguments. */
- BINOP_ADD, /* + */
- BINOP_SUB, /* - */
- BINOP_MUL, /* * */
- BINOP_DIV, /* / */
- BINOP_REM, /* % */
- BINOP_LSH, /* << */
- BINOP_RSH, /* >> */
- BINOP_AND, /* && */
- BINOP_OR, /* || */
- BINOP_LOGAND, /* & */
- BINOP_LOGIOR, /* | */
- BINOP_LOGXOR, /* ^ */
- BINOP_EQUAL, /* == */
- BINOP_NOTEQUAL, /* != */
- BINOP_LESS, /* < */
- BINOP_GTR, /* > */
- BINOP_LEQ, /* <= */
- BINOP_GEQ, /* >= */
- BINOP_REPEAT, /* @ */
- BINOP_ASSIGN, /* = */
- BINOP_COMMA, /* , */
- BINOP_SUBSCRIPT, /* x[y] */
- BINOP_EXP, /* Exponentiation */
-
-/* C++. */
- BINOP_MIN, /* <? */
- BINOP_MAX, /* >? */
- BINOP_SCOPE, /* :: */
-
- /* STRUCTOP_MEMBER is used for pointer-to-member constructs.
- X . * Y translates into X STRUCTOP_MEMBER Y. */
- STRUCTOP_MEMBER,
- /* STRUCTOP_MPTR is used for pointer-to-member constructs
- when X is a pointer instead of an aggregate. */
- STRUCTOP_MPTR,
-/* end of C++. */
-
- BINOP_END,
-
- BINOP_ASSIGN_MODIFY, /* +=, -=, *=, and so on.
- The following exp_element is another opcode,
- a BINOP_, saying how to modify.
- Then comes another BINOP_ASSIGN_MODIFY,
- making three exp_elements in total. */
-
-/* Operates on three values computed by following subexpressions. */
- TERNOP_COND, /* ?: */
-
-/* The OP_... series take immediate following arguments.
- After the arguments come another OP_... (the same one)
- so that the grouping can be recognized from the end. */
-
-/* OP_LONG is followed by a type pointer in the next exp_element
- and the long constant value in the following exp_element.
- Then comes another OP_LONG.
- Thus, the operation occupies four exp_elements. */
-
- OP_LONG,
-/* OP_DOUBLE is similar but takes a double constant instead of a long one. */
- OP_DOUBLE,
-/* OP_VAR_VALUE takes one struct symbol * in the following exp_element,
- followed by another OP_VAR_VALUE, making three exp_elements. */
- OP_VAR_VALUE,
-/* OP_LAST is followed by an integer in the next exp_element.
- The integer is zero for the last value printed,
- or it is the absolute number of a history element.
- With another OP_LAST at the end, this makes three exp_elements. */
- OP_LAST,
-/* OP_REGISTER is followed by an integer in the next exp_element.
- This is the number of a register to fetch (as an int).
- With another OP_REGISTER at the end, this makes three exp_elements. */
- OP_REGISTER,
-/* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element.
- With another OP_INTERNALVAR at the end, this makes three exp_elements. */
- OP_INTERNALVAR,
-/* OP_FUNCALL is followed by an integer in the next exp_element.
- The integer is the number of args to the function call.
- That many plus one values from following subexpressions
- are used, the first one being the function.
- The integer is followed by a repeat of OP_FUNCALL,
- making three exp_elements. */
- OP_FUNCALL,
-/* OP_STRING represents a string constant.
- Its format is the same as that of a STRUCTOP, but the string
- data is just made into a string constant when the operation
- is executed. */
- OP_STRING,
-
-/* UNOP_CAST is followed by a type pointer in the next exp_element.
- With another UNOP_CAST at the end, this makes three exp_elements.
- It casts the value of the following subexpression. */
- UNOP_CAST,
-/* UNOP_MEMVAL is followed by a type pointer in the next exp_element
- With another UNOP_MEMVAL at the end, this makes three exp_elements.
- It casts the contents of the word addressed by the value of the
- following subexpression. */
- UNOP_MEMVAL,
-/* UNOP_... operate on one value from a following subexpression
- and replace it with a result. They take no immediate arguments. */
- UNOP_NEG, /* Unary - */
- UNOP_ZEROP, /* Unary ! */
- UNOP_LOGNOT, /* Unary ~ */
- UNOP_IND, /* Unary * */
- UNOP_ADDR, /* Unary & */
- UNOP_PREINCREMENT, /* ++ before an expression */
- UNOP_POSTINCREMENT, /* ++ after an expression */
- UNOP_PREDECREMENT, /* -- before an expression */
- UNOP_POSTDECREMENT, /* -- after an expression */
- UNOP_SIZEOF, /* Unary sizeof (followed by expression) */
-
-/* STRUCTOP_... operate on a value from a following subexpression
- by extracting a structure component specified by a string
- that appears in the following exp_elements (as many as needed).
- STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
- They differ only in the error message given in case the value is
- not suitable or the structure component specified is not found.
-
- The length of the string follows in the next exp_element,
- (after the string), followed by another STRUCTOP_... code. */
- STRUCTOP_STRUCT,
- STRUCTOP_PTR,
-
-/* C++ */
- /* OP_THIS is just a placeholder for the class instance variable.
- It just comes in a tight (OP_THIS, OP_THIS) pair. */
- OP_THIS,
-
- /* OP_SCOPE surrounds a type name and a field name. The type
- name is encoded as one element, but the field name stays as
- a string, which, of course, is variable length. */
- OP_SCOPE,
-
-};
-
-union exp_element
-{
- enum exp_opcode opcode;
- struct symbol *symbol;
- LONGEST longconst;
- double doubleconst;
- char string;
- struct type *type;
- struct internalvar *internalvar;
-};
-
-struct expression
-{
- int nelts;
- union exp_element elts[1];
-};
-
-struct expression *parse_c_expression ();
-struct expression *parse_c_1 ();
diff --git a/gnu/usr.bin/gdb/findvar.c b/gnu/usr.bin/gdb/findvar.c
deleted file mode 100644
index 0157d10..0000000
--- a/gnu/usr.bin/gdb/findvar.c
+++ /dev/null
@@ -1,579 +0,0 @@
-/* Find a variable's value in memory, 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. */
-
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-#include "value.h"
-
-CORE_ADDR read_register ();
-
-/* Return the address in which frame FRAME's value of register REGNUM
- has been saved in memory. Or return zero if it has not been saved.
- If REGNUM specifies the SP, the value we return is actually
- the SP value, not an address where it was saved. */
-
-CORE_ADDR
-find_saved_register (frame, regnum)
- FRAME frame;
- int regnum;
-{
- struct frame_info *fi;
- struct frame_saved_regs saved_regs;
-
- register FRAME frame1 = 0;
- register CORE_ADDR addr = 0;
-
-#ifdef HAVE_REGISTER_WINDOWS
- /* We assume that a register in a register window will only be saved
- in one place (since the name changes and disappears as you go
- towards inner frames), so we only call get_frame_saved_regs on
- the current frame. This is directly in contradiction to the
- usage below, which assumes that registers used in a frame must be
- saved in a lower (more interior) frame. This change is a result
- of working on a register window machine; get_frame_saved_regs
- always returns the registers saved within a frame, within the
- context (register namespace) of that frame. */
-
- /* However, note that we don't want this to return anything if
- nothing is saved (if there's a frame inside of this one). Also,
- callers to this routine asking for the stack pointer want the
- stack pointer saved for *this* frame; this is returned from the
- next frame. */
-
-
- if (REGISTER_IN_WINDOW_P(regnum))
- {
- frame1 = get_next_frame (frame);
- if (!frame1) return 0; /* Registers of this frame are
- active. */
-
- /* Get the SP from the next frame in; it will be this
- current frame. */
- if (regnum != SP_REGNUM)
- frame1 = frame;
-
- fi = get_frame_info (frame1);
- get_frame_saved_regs (fi, &saved_regs);
- return (saved_regs.regs[regnum] ?
- saved_regs.regs[regnum] : 0);
- }
-#endif /* HAVE_REGISTER_WINDOWS */
-
- /* Note that this next routine assumes that registers used in
- frame x will be saved only in the frame that x calls and
- frames interior to it. This is not true on the sparc, but the
- above macro takes care of it, so we should be all right. */
- while (1)
- {
- QUIT;
- frame1 = get_prev_frame (frame1);
- if (frame1 == 0 || frame1 == frame)
- break;
- fi = get_frame_info (frame1);
- get_frame_saved_regs (fi, &saved_regs);
- if (saved_regs.regs[regnum])
- addr = saved_regs.regs[regnum];
- }
-
- return addr;
-}
-
-/* Copy the bytes of register REGNUM, relative to the current stack frame,
- into our memory at MYADDR.
- The number of bytes copied is REGISTER_RAW_SIZE (REGNUM). */
-
-void
-read_relative_register_raw_bytes (regnum, myaddr)
- int regnum;
- char *myaddr;
-{
- register CORE_ADDR addr;
-
- if (regnum == FP_REGNUM)
- {
- bcopy (&FRAME_FP(selected_frame), myaddr, sizeof (CORE_ADDR));
- return;
- }
-
- addr = find_saved_register (selected_frame, regnum);
-
- if (addr)
- {
- if (regnum == SP_REGNUM)
- {
- CORE_ADDR buffer = addr;
- bcopy (&buffer, myaddr, sizeof (CORE_ADDR));
- }
- else
- read_memory (addr, myaddr, REGISTER_RAW_SIZE (regnum));
- return;
- }
- read_register_bytes (REGISTER_BYTE (regnum),
- myaddr, REGISTER_RAW_SIZE (regnum));
-}
-
-/* Return a `value' with the contents of register REGNUM
- in its virtual format, with the type specified by
- REGISTER_VIRTUAL_TYPE. */
-
-value
-value_of_register (regnum)
- int regnum;
-{
- register CORE_ADDR addr;
- register value val;
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
-
- if (! (have_inferior_p () || have_core_file_p ()))
- error ("Can't get value of register without inferior or core file");
-
- addr = find_saved_register (selected_frame, regnum);
- if (addr)
- {
- if (regnum == SP_REGNUM)
- return value_from_long (builtin_type_int, (LONGEST) addr);
- read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum));
- }
- else
- read_register_bytes (REGISTER_BYTE (regnum), raw_buffer,
- REGISTER_RAW_SIZE (regnum));
-
- REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer);
- val = allocate_value (REGISTER_VIRTUAL_TYPE (regnum));
- bcopy (virtual_buffer, VALUE_CONTENTS (val), REGISTER_VIRTUAL_SIZE (regnum));
- VALUE_LVAL (val) = addr ? lval_memory : lval_register;
- VALUE_ADDRESS (val) = addr ? addr : REGISTER_BYTE (regnum);
- VALUE_REGNO (val) = regnum;
- return val;
-}
-
-/* Low level examining and depositing of registers.
-
- Note that you must call `fetch_registers' once
- before examining or depositing any registers. */
-
-char registers[REGISTER_BYTES];
-
-/* Copy LEN bytes of consecutive data from registers
- starting with the REGBYTE'th byte of register data
- into memory at MYADDR. */
-
-void
-read_register_bytes (regbyte, myaddr, len)
- int regbyte;
- char *myaddr;
- int len;
-{
- bcopy (&registers[regbyte], myaddr, len);
-}
-
-/* Copy LEN bytes of consecutive data from memory at MYADDR
- into registers starting with the REGBYTE'th byte of register data. */
-
-void
-write_register_bytes (regbyte, myaddr, len)
- int regbyte;
- char *myaddr;
- int len;
-{
- bcopy (myaddr, &registers[regbyte], len);
- if (have_inferior_p ())
- store_inferior_registers (-1);
-}
-
-/* Return the contents of register REGNO,
- regarding it as an integer. */
-
-CORE_ADDR
-read_register (regno)
- int regno;
-{
- /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
- return *(int *) &registers[REGISTER_BYTE (regno)];
-}
-
-/* Store VALUE in the register number REGNO, regarded as an integer. */
-
-void
-write_register (regno, val)
- int regno, val;
-{
- /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
-#if defined(sun4)
- /* This is a no-op on a Sun 4. */
- if (regno == 0)
- return;
-#endif
-
- *(int *) &registers[REGISTER_BYTE (regno)] = val;
-
- if (have_inferior_p ())
- store_inferior_registers (regno);
-}
-
-/* Record that register REGNO contains VAL.
- This is used when the value is obtained from the inferior or core dump,
- so there is no need to store the value there. */
-
-void
-supply_register (regno, val)
- int regno;
- char *val;
-{
- bcopy (val, &registers[REGISTER_BYTE (regno)], REGISTER_RAW_SIZE (regno));
-}
-
-/* Given a struct symbol for a variable,
- and a stack frame id, read the value of the variable
- and return a (pointer to a) struct value containing the value. */
-
-value
-read_var_value (var, frame)
- register struct symbol *var;
- FRAME frame;
-{
- register value v;
-
- struct frame_info *fi;
-
- struct type *type = SYMBOL_TYPE (var);
- register CORE_ADDR addr = 0;
- int val = SYMBOL_VALUE (var);
- register int len;
-
- v = allocate_value (type);
- VALUE_LVAL (v) = lval_memory; /* The most likely possibility. */
- len = TYPE_LENGTH (type);
-
- if (frame == 0) frame = selected_frame;
-
- switch (SYMBOL_CLASS (var))
- {
- case LOC_CONST:
- case LOC_LABEL:
- bcopy (&val, VALUE_CONTENTS (v), len);
- VALUE_LVAL (v) = not_lval;
- return v;
-
- case LOC_CONST_BYTES:
- bcopy (val, VALUE_CONTENTS (v), len);
- VALUE_LVAL (v) = not_lval;
- return v;
-
- case LOC_STATIC:
- addr = val;
- break;
-
-/* Nonzero if a struct which is located in a register or a LOC_ARG
- really contains
- the address of the struct, not the struct itself. GCC_P is nonzero
- if the function was compiled with GCC. */
-#if !defined (REG_STRUCT_HAS_ADDR)
-#define REG_STRUCT_HAS_ADDR(gcc_p) 0
-#endif
-
- case LOC_ARG:
- fi = get_frame_info (frame);
- addr = val + FRAME_ARGS_ADDRESS (fi);
- break;
-
- case LOC_REF_ARG:
- fi = get_frame_info (frame);
- addr = val + FRAME_ARGS_ADDRESS (fi);
- addr = read_memory_integer (addr, sizeof (CORE_ADDR));
- break;
-
- case LOC_LOCAL:
- fi = get_frame_info (frame);
- addr = val + FRAME_LOCALS_ADDRESS (fi);
- break;
-
- case LOC_TYPEDEF:
- error ("Cannot look up value of a typedef");
-
- case LOC_BLOCK:
- VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
- return v;
-
- case LOC_REGISTER:
- case LOC_REGPARM:
- {
- struct block *b = get_frame_block (frame);
-
- v = value_from_register (type, val, frame);
-
- if (REG_STRUCT_HAS_ADDR(b->gcc_compile_flag)
- && TYPE_CODE (type) == TYPE_CODE_STRUCT)
- addr = *(CORE_ADDR *)VALUE_CONTENTS (v);
- else
- return v;
- }
- }
-
- read_memory (addr, VALUE_CONTENTS (v), len);
- VALUE_ADDRESS (v) = addr;
- return v;
-}
-
-/* Return a value of type TYPE, stored in register REGNUM, in frame
- FRAME. */
-
-value
-value_from_register (type, regnum, frame)
- struct type *type;
- int regnum;
- FRAME frame;
-{
- char raw_buffer [MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
- CORE_ADDR addr;
- value v = allocate_value (type);
- int len = TYPE_LENGTH (type);
- char *value_bytes = 0;
- int value_bytes_copied = 0;
- int num_storage_locs;
-
- VALUE_REGNO (v) = regnum;
-
- num_storage_locs = (len > REGISTER_VIRTUAL_SIZE (regnum) ?
- ((len - 1) / REGISTER_RAW_SIZE (regnum)) + 1 :
- 1);
-
- if (num_storage_locs > 1)
- {
- /* Value spread across multiple storage locations. */
-
- int local_regnum;
- int mem_stor = 0, reg_stor = 0;
- int mem_tracking = 1;
- CORE_ADDR last_addr = 0;
-
- value_bytes = (char *) alloca (len + MAX_REGISTER_RAW_SIZE);
-
- /* Copy all of the data out, whereever it may be. */
-
- for (local_regnum = regnum;
- value_bytes_copied < len;
- (value_bytes_copied += REGISTER_RAW_SIZE (local_regnum),
- ++local_regnum))
- {
- int register_index = local_regnum - regnum;
- addr = find_saved_register (frame, local_regnum);
- if (addr == 0)
- {
- read_register_bytes (REGISTER_BYTE (local_regnum),
- value_bytes + value_bytes_copied,
- REGISTER_RAW_SIZE (local_regnum));
- reg_stor++;
- }
- else
- {
- read_memory (addr, value_bytes + value_bytes_copied,
- REGISTER_RAW_SIZE (local_regnum));
- mem_stor++;
- mem_tracking =
- (mem_tracking
- && (regnum == local_regnum
- || addr == last_addr));
- }
- last_addr = addr;
- }
-
- if ((reg_stor && mem_stor)
- || (mem_stor && !mem_tracking))
- /* Mixed storage; all of the hassle we just went through was
- for some good purpose. */
- {
- VALUE_LVAL (v) = lval_reg_frame_relative;
- VALUE_FRAME (v) = FRAME_FP (frame);
- VALUE_FRAME_REGNUM (v) = regnum;
- }
- else if (mem_stor)
- {
- VALUE_LVAL (v) = lval_memory;
- VALUE_ADDRESS (v) = find_saved_register (frame, regnum);
- }
- else if (reg_stor)
- {
- VALUE_LVAL (v) = lval_register;
- VALUE_ADDRESS (v) = REGISTER_BYTE (regnum);
- }
- else
- fatal ("value_from_register: Value not stored anywhere!");
-
- /* Any structure stored in more than one register will always be
- an inegral number of registers. Otherwise, you'd need to do
- some fiddling with the last register copied here for little
- endian machines. */
-
- /* Copy into the contents section of the value. */
- bcopy (value_bytes, VALUE_CONTENTS (v), len);
-
- return v;
- }
-
- /* Data is completely contained within a single register. Locate the
- register's contents in a real register or in core;
- read the data in raw format. */
-
- addr = find_saved_register (frame, regnum);
- if (addr == 0)
- {
- /* Value is really in a register. */
-
- VALUE_LVAL (v) = lval_register;
- VALUE_ADDRESS (v) = REGISTER_BYTE (regnum);
-
- read_register_bytes (REGISTER_BYTE (regnum),
- raw_buffer, REGISTER_RAW_SIZE (regnum));
- }
- else
- {
- /* Value was in a register that has been saved in memory. */
-
- read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum));
- VALUE_LVAL (v) = lval_memory;
- VALUE_ADDRESS (v) = addr;
- }
-
- /* Convert the raw contents to virtual contents.
- (Just copy them if the formats are the same.) */
-
- REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer);
-
- if (REGISTER_CONVERTIBLE (regnum))
- {
- /* When the raw and virtual formats differ, the virtual format
- corresponds to a specific data type. If we want that type,
- copy the data into the value.
- Otherwise, do a type-conversion. */
-
- if (type != REGISTER_VIRTUAL_TYPE (regnum))
- {
- /* eg a variable of type `float' in a 68881 register
- with raw type `extended' and virtual type `double'.
- Fetch it as a `double' and then convert to `float'. */
- v = allocate_value (REGISTER_VIRTUAL_TYPE (regnum));
- bcopy (virtual_buffer, VALUE_CONTENTS (v), len);
- v = value_cast (type, v);
- }
- else
- bcopy (virtual_buffer, VALUE_CONTENTS (v), len);
- }
- else
- {
- /* Raw and virtual formats are the same for this register. */
-
-#ifdef BYTES_BIG_ENDIAN
- if (len < REGISTER_RAW_SIZE (regnum))
- {
- /* Big-endian, and we want less than full size. */
- VALUE_OFFSET (v) = REGISTER_RAW_SIZE (regnum) - len;
- }
-#endif
-
- bcopy (virtual_buffer + VALUE_OFFSET (v),
- VALUE_CONTENTS (v), len);
- }
-
- return v;
-}
-
-/* Given a struct symbol for a variable,
- and a stack frame id,
- return a (pointer to a) struct value containing the variable's address. */
-
-value
-locate_var_value (var, frame)
- register struct symbol *var;
- FRAME frame;
-{
- register CORE_ADDR addr = 0;
- int val = SYMBOL_VALUE (var);
- struct frame_info *fi;
- struct type *type = SYMBOL_TYPE (var);
- struct type *result_type;
-
- if (frame == 0) frame = selected_frame;
-
- switch (SYMBOL_CLASS (var))
- {
- case LOC_CONST:
- case LOC_CONST_BYTES:
- error ("Address requested for identifier \"%s\" which is a constant.",
- SYMBOL_NAME (var));
-
- case LOC_REGISTER:
- case LOC_REGPARM:
- addr = find_saved_register (frame, val);
- if (addr != 0)
- {
- int len = TYPE_LENGTH (type);
-#ifdef BYTES_BIG_ENDIAN
- if (len < REGISTER_RAW_SIZE (val))
- /* Big-endian, and we want less than full size. */
- addr += REGISTER_RAW_SIZE (val) - len;
-#endif
- break;
- }
- error ("Address requested for identifier \"%s\" which is in a register.",
- SYMBOL_NAME (var));
-
- case LOC_STATIC:
- case LOC_LABEL:
- addr = val;
- break;
-
- case LOC_ARG:
- fi = get_frame_info (frame);
- addr = val + FRAME_ARGS_ADDRESS (fi);
- break;
-
- case LOC_REF_ARG:
- fi = get_frame_info (frame);
- addr = val + FRAME_ARGS_ADDRESS (fi);
- addr = read_memory_integer (addr, sizeof (CORE_ADDR));
- break;
-
- case LOC_LOCAL:
- fi = get_frame_info (frame);
- addr = val + FRAME_LOCALS_ADDRESS (fi);
- break;
-
- case LOC_TYPEDEF:
- error ("Address requested for identifier \"%s\" which is a typedef.",
- SYMBOL_NAME (var));
-
- case LOC_BLOCK:
- addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
- break;
- }
-
- /* Address of an array is of the type of address of it's elements. */
- result_type =
- lookup_pointer_type (TYPE_CODE (type) == TYPE_CODE_ARRAY ?
- TYPE_TARGET_TYPE (type) : type);
-
- return value_cast (result_type,
- value_from_long (builtin_type_long, (LONGEST) addr));
-}
-
diff --git a/gnu/usr.bin/gdb/frame.h b/gnu/usr.bin/gdb/frame.h
deleted file mode 100644
index 322ddba..0000000
--- a/gnu/usr.bin/gdb/frame.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Definitions for dealing with stack frames, for GDB, the GNU debugger.
- Copyright (C) 1986, 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. */
-
-/* Note that frame.h requires param.h! */
-
-/*
- * FRAME is the type of the identifier of a specific stack frame. It
- * is a pointer to the frame cache item corresponding to this frame.
- * Please note that frame id's are *not* constant over calls to the
- * inferior. Use frame addresses, which are.
- *
- * FRAME_ADDR is the type of the address of a specific frame. I
- * cannot imagine a case in which this would not be CORE_ADDR, so
- * maybe it's silly to give it it's own type. Life's rough.
- *
- * FRAME_FP is a macro which converts from a frame identifier into a
- * frame_address.
- *
- * FRAME_INFO_ID is a macro which "converts" from a frame info pointer
- * to a frame id. This is here in case I or someone else decides to
- * change the FRAME type again.
- *
- * This file and blockframe.c are the only places which are allowed to
- * use the equivalence between FRAME and struct frame_info *. EXCEPTION:
- * value.h uses CORE_ADDR instead of FRAME_ADDR because the compiler
- * will accept that in the absense of this file.
- */
-typedef struct frame_info *FRAME;
-typedef CORE_ADDR FRAME_ADDR;
-#define FRAME_FP(fr) ((fr)->frame)
-#define FRAME_INFO_ID(f) (f)
-
-/*
- * Caching structure for stack frames. This is also the structure
- * used for extended info about stack frames. May add more to this
- * structure as it becomes necessary.
- *
- * Note that the first entry in the cache will always refer to the
- * innermost executing frame. This value should be set (is it?
- * Check) in something like normal_stop.
- */
-struct frame_info
- {
- /* Nominal address of the frame described. */
- FRAME_ADDR frame;
- /* Address at which execution is occurring in this frame.
- For the innermost frame, it's the current pc.
- For other frames, it is a pc saved in the next frame. */
- CORE_ADDR pc;
- /* The frame called by the frame we are describing, or 0.
- This may be set even if there isn't a frame called by the one
- we are describing (.->next == 0); in that case it is simply the
- bottom of this frame */
- FRAME_ADDR next_frame;
- /* Anything extra for this structure that may have been defined
- in the machine depedent files. */
-#ifdef EXTRA_FRAME_INFO
- EXTRA_FRAME_INFO
-#endif
- /* Pointers to the next and previous frame_info's in this stack. */
- FRAME next, prev;
- };
-
-/* Describe the saved registers of a frame. */
-
-struct frame_saved_regs
- {
- /* For each register, address of where it was saved on entry to the frame,
- or zero if it was not saved on entry to this frame. */
- CORE_ADDR regs[NUM_REGS];
- };
-
-/* The stack frame that the user has specified for commands to act on.
- Note that one cannot assume this is the address of valid data. */
-
-extern FRAME selected_frame;
-
-extern struct frame_info *get_frame_info ();
-extern struct frame_info *get_prev_frame_info ();
-
-extern FRAME create_new_frame ();
-
-extern void get_frame_saved_regs ();
-
-extern FRAME get_prev_frame ();
-extern FRAME get_current_frame ();
-extern FRAME get_next_frame ();
-
-extern struct block *get_frame_block ();
-extern struct block *get_current_block ();
-extern struct block *get_selected_block ();
-extern struct symbol *get_frame_function ();
-extern struct symbol *get_pc_function ();
-
-/* In stack.c */
-extern FRAME find_relative_frame ();
-
-/* Generic pointer value indicating "I don't know." */
-#define Frame_unknown (CORE_ADDR)-1
diff --git a/gnu/usr.bin/gdb/gdb.1 b/gnu/usr.bin/gdb/gdb.1
deleted file mode 100644
index 57d744b..0000000
--- a/gnu/usr.bin/gdb/gdb.1
+++ /dev/null
@@ -1,3 +0,0 @@
-.\" %W% (Berkeley) %G%
-.\"
-.\" placeholder, until we can produce the manual page
diff --git a/gnu/usr.bin/gdb/getpagesize.h b/gnu/usr.bin/gdb/getpagesize.h
deleted file mode 100644
index 32adae6..0000000
--- a/gnu/usr.bin/gdb/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/usr.bin/gdb/infcmd.c b/gnu/usr.bin/gdb/infcmd.c
deleted file mode 100644
index 378784f..0000000
--- a/gnu/usr.bin/gdb/infcmd.c
+++ /dev/null
@@ -1,1204 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)infcmd.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Memory-access and commands for inferior process, for GDB.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-#include "inferior.h"
-#include "environ.h"
-#include "value.h"
-
-#include <signal.h>
-#include <sys/param.h>
-
-extern char *sys_siglist[];
-
-#define ERROR_NO_INFERIOR \
- if (inferior_pid == 0) error ("The program is not being run.");
-
-/* String containing arguments to give to the program,
- with a space added at the front. Just a space means no args. */
-
-static char *inferior_args;
-
-/* File name for default use for standard in/out in the inferior. */
-
-char *inferior_io_terminal;
-
-/* Pid of our debugged inferior, or 0 if no inferior now. */
-
-int inferior_pid;
-
-/* Last signal that the inferior received (why it stopped). */
-
-int stop_signal;
-
-/* Address at which inferior stopped. */
-
-CORE_ADDR stop_pc;
-
-/* Stack frame when program stopped. */
-
-FRAME_ADDR stop_frame_address;
-
-/* Number of breakpoint it stopped at, or 0 if none. */
-
-int stop_breakpoint;
-
-/* Nonzero if stopped due to a step command. */
-
-int stop_step;
-
-/* Nonzero if stopped due to completion of a stack dummy routine. */
-
-int stop_stack_dummy;
-
-/* Nonzero if stopped due to a random (unexpected) signal in inferior
- process. */
-
-int stopped_by_random_signal;
-
-/* Range to single step within.
- If this is nonzero, respond to a single-step signal
- by continuing to step if the pc is in this range. */
-
-CORE_ADDR step_range_start; /* Inclusive */
-CORE_ADDR step_range_end; /* Exclusive */
-
-/* Stack frame address as of when stepping command was issued.
- This is how we know when we step into a subroutine call,
- and how to set the frame for the breakpoint used to step out. */
-
-FRAME_ADDR step_frame_address;
-
-/* 1 means step over all subroutine calls.
- -1 means step over calls to undebuggable functions. */
-
-int step_over_calls;
-
-/* If stepping, nonzero means step count is > 1
- so don't print frame next time inferior stops
- if it stops due to stepping. */
-
-int step_multi;
-
-/* Environment to use for running inferior,
- in format described in environ.h. */
-
-struct environ *inferior_environ;
-
-CORE_ADDR read_pc ();
-struct command_line *get_breakpoint_commands ();
-void breakpoint_clear_ignore_counts ();
-
-
-int
-have_inferior_p ()
-{
- return inferior_pid != 0;
-}
-
-static void
-set_args_command (args)
- char *args;
-{
- free (inferior_args);
- if (!args) args = "";
- inferior_args = concat (" ", args, "");
-}
-
-void
-tty_command (file, from_tty)
- char *file;
- int from_tty;
-{
- if (file == 0)
- error_no_arg ("terminal name for running target process");
-
- inferior_io_terminal = savestring (file, strlen (file));
-}
-
-static void
-run_command (args, from_tty)
- char *args;
- int from_tty;
-{
- extern char **environ;
- register int i;
- char *exec_file;
- char *allargs;
-
- extern int sys_nerr;
- extern char *sys_errlist[];
- extern int errno;
-
- dont_repeat ();
-
- if (inferior_pid)
- {
- extern int inhibit_confirm;
- if (!(inhibit_confirm ||
- query ("The program being debugged has been started already.\n\
-Start it from the beginning? ")))
- error ("Program not restarted.");
- kill_inferior ();
- }
-
-#if 0
- /* On the other hand, some users want to do
- break open
- ignore 1 40
- run
- So it's not clear what is best. */
-
- /* It is confusing to the user for ignore counts to stick around
- from previous runs of the inferior. So clear them. */
- breakpoint_clear_ignore_counts ();
-#endif
-
- exec_file = (char *) get_exec_file (1);
-
- if (remote_debugging)
- {
- if (from_tty)
- {
- printf ("Starting program: %s\n", exec_file);
- fflush (stdout);
- }
- }
- else
- {
- if (args)
- set_args_command (args);
-
- if (from_tty)
- {
- printf ("Starting program: %s%s\n",
- exec_file, inferior_args);
- fflush (stdout);
- }
-
- allargs = concat ("exec ", exec_file, inferior_args);
- inferior_pid = create_inferior (allargs, environ_vector (inferior_environ));
- }
-
- clear_proceed_status ();
-
- start_inferior ();
-}
-
-void
-cont_command (proc_count_exp, from_tty)
- char *proc_count_exp;
- int from_tty;
-{
- ERROR_NO_INFERIOR;
-
- clear_proceed_status ();
-
- /* If have argument, set proceed count of breakpoint we stopped at. */
-
- if (stop_breakpoint > 0 && proc_count_exp)
- {
- set_ignore_count (stop_breakpoint,
- parse_and_eval_address (proc_count_exp) - 1,
- from_tty);
- if (from_tty)
- printf (" ");
- }
-
- if (from_tty)
- printf ("Continuing.\n");
-
- proceed (-1, -1, 0);
-}
-
-/* Step until outside of current statement. */
-static void step_1 ();
-
-static void
-step_command (count_string)
-{
- step_1 (0, 0, count_string);
-}
-
-/* Likewise, but skip over subroutine calls as if single instructions. */
-
-static void
-next_command (count_string)
-{
- step_1 (1, 0, count_string);
-}
-
-/* Likewise, but step only one instruction. */
-
-static void
-stepi_command (count_string)
-{
- step_1 (0, 1, count_string);
-}
-
-static void
-nexti_command (count_string)
-{
- step_1 (1, 1, count_string);
-}
-
-static void
-step_1 (skip_subroutines, single_inst, count_string)
- int skip_subroutines;
- int single_inst;
- char *count_string;
-{
- register int count = 1;
-
- ERROR_NO_INFERIOR;
- count = count_string ? parse_and_eval_address (count_string) : 1;
-
- for (; count > 0; count--)
- {
- clear_proceed_status ();
-
- step_frame_address = FRAME_FP (get_current_frame ());
-
- if (! single_inst)
- {
- find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
- if (step_range_end == 0)
- {
- int misc;
-
- misc = find_pc_misc_function (stop_pc);
- terminal_ours ();
- printf ("Current function has no line number information.\n");
- fflush (stdout);
-
- /* No info or after _etext ("Can't happen") */
- if (misc == -1 || misc == misc_function_count - 1)
- error ("No data available on pc function.");
-
- printf ("Single stepping until function exit.\n");
- fflush (stdout);
-
- step_range_start = misc_function_vector[misc].address;
- step_range_end = misc_function_vector[misc + 1].address;
- }
- }
- else
- {
- /* Say we are stepping, but stop after one insn whatever it does.
- Don't step through subroutine calls even to undebuggable
- functions. */
- step_range_start = step_range_end = 1;
- if (!skip_subroutines)
- step_over_calls = 0;
- }
-
- if (skip_subroutines)
- step_over_calls = 1;
-
- step_multi = (count > 1);
- proceed (-1, -1, 1);
- if (! stop_step)
- break;
- }
-}
-
-/* Continue program at specified address. */
-
-static void
-jump_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- register CORE_ADDR addr;
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
-
- ERROR_NO_INFERIOR;
-
- if (!arg)
- error_no_arg ("starting address");
-
- sals = decode_line_spec_1 (arg, 1);
- if (sals.nelts != 1)
- {
- error ("Unreasonable jump request");
- }
-
- sal = sals.sals[0];
- free (sals.sals);
-
- if (sal.symtab == 0 && sal.pc == 0)
- error ("No source file has been specified.");
-
- if (sal.pc == 0)
- sal.pc = find_line_pc (sal.symtab, sal.line);
-
- {
- struct symbol *fn = get_frame_function (get_current_frame ());
- struct symbol *sfn = find_pc_function (sal.pc);
- if (fn != 0 && sfn != fn
- && ! query ("Line %d is not in `%s'. Jump anyway? ",
- sal.line, SYMBOL_NAME (fn)))
- error ("Not confirmed.");
- }
-
- if (sal.pc == 0)
- error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
-
- addr = sal.pc;
-
- clear_proceed_status ();
-
- if (from_tty)
- printf ("Continuing at 0x%x.\n", addr);
-
- proceed (addr, 0, 0);
-}
-
-/* Continue program giving it specified signal. */
-
-static void
-signal_command (signum_exp, from_tty)
- char *signum_exp;
- int from_tty;
-{
- register int signum;
-
- dont_repeat (); /* Too dangerous. */
- ERROR_NO_INFERIOR;
-
- if (!signum_exp)
- error_no_arg ("signal number");
-
- signum = parse_and_eval_address (signum_exp);
-
- clear_proceed_status ();
-
- if (from_tty)
- printf ("Continuing with signal %d.\n", signum);
-
- proceed (stop_pc, signum, 0);
-}
-
-/* Execute a "stack dummy", a piece of code stored in the stack
- by the debugger to be executed in the inferior.
-
- To call: first, do PUSH_DUMMY_FRAME.
- Then push the contents of the dummy. It should end with a breakpoint insn.
- Then call here, passing address at which to start the dummy.
-
- The contents of all registers are saved before the dummy frame is popped
- and copied into the buffer BUFFER.
-
- The dummy's frame is automatically popped whenever that break is hit.
- If that is the first time the program stops, run_stack_dummy
- returns to its caller with that frame already gone.
- Otherwise, the caller never gets returned to. */
-
-/* 4 => return instead of letting the stack dummy run. */
-
-static int stack_dummy_testing = 0;
-
-void
-run_stack_dummy (addr, buffer)
- CORE_ADDR addr;
- REGISTER_TYPE *buffer;
-{
- /* Now proceed, having reached the desired place. */
- clear_proceed_status ();
-#ifdef notdef
- if (stack_dummy_testing & 4)
- {
- POP_FRAME;
- return;
- }
-#endif
- proceed (addr, 0, 0);
-
- if (!stop_stack_dummy)
- error ("Cannot continue previously requested operation.");
-
- /* On return, the stack dummy has been popped already. */
-
- read_register_bytes(0, buffer, REGISTER_BYTES);
-}
-
-/* Proceed until we reach the given line as argument or exit the
- function. When called with no argument, proceed until we reach a
- different source line with pc greater than our current one or exit
- the function. We skip calls in both cases.
-
- The effect of this command with an argument is identical to setting
- a momentary breakpoint at the line specified and executing
- "finish".
-
- Note that eventually this command should probably be changed so
- that only source lines are printed out when we hit the breakpoint
- we set. I'm going to postpone this until after a hopeful rewrite
- of wait_for_inferior and the proceed status code. -- randy */
-
-void
-until_next_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- FRAME frame;
- CORE_ADDR pc;
- struct symbol *func;
- struct symtab_and_line sal;
-
- clear_proceed_status ();
-
- frame = get_current_frame ();
-
- /* Step until either exited from this function or greater
- than the current line (if in symbolic section) or pc (if
- not). */
-
- pc = read_pc ();
- func = find_pc_function (pc);
-
- if (!func)
- {
- int misc_func = find_pc_misc_function (pc);
-
- if (misc_func != -1)
- error ("Execution is not within a known function.");
-
- step_range_start = misc_function_vector[misc_func].address;
- step_range_end = pc;
- }
- else
- {
- sal = find_pc_line (pc, 0);
-
- step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
- step_range_end = sal.end;
- }
-
- step_over_calls = 1;
- step_frame_address = FRAME_FP (frame);
-
- step_multi = 0; /* Only one call to proceed */
-
- proceed (-1, -1, 1);
-}
-
-void
-until_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- if (!have_inferior_p ())
- error ("The program is not being run.");
-
- if (arg)
- until_break_command (arg, from_tty);
- else
- until_next_command (arg, from_tty);
-}
-
-/* "finish": Set a temporary breakpoint at the place
- the selected frame will return to, then continue. */
-
-static void
-finish_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- struct symtab_and_line sal;
- register FRAME frame;
- struct frame_info *fi;
- register struct symbol *function;
-
- if (!have_inferior_p ())
- error ("The program is not being run.");
- if (arg)
- error ("The \"finish\" command does not take any arguments.");
-
- frame = get_prev_frame (selected_frame);
- if (frame == 0)
- error ("\"finish\" not meaningful in the outermost frame.");
-
- clear_proceed_status ();
-
- fi = get_frame_info (frame);
- sal = find_pc_line (fi->pc, 0);
- sal.pc = fi->pc;
- set_momentary_breakpoint (sal, frame);
-
- /* Find the function we will return from. */
-
- fi = get_frame_info (selected_frame);
- function = find_pc_function (fi->pc);
-
- if (from_tty)
- {
- printf ("Run till exit from ");
- print_selected_frame ();
- }
-
- proceed (-1, -1, 0);
-
- if (stop_breakpoint == -3 && function != 0)
- {
- struct type *value_type;
- register value val;
- CORE_ADDR funcaddr;
- extern char registers[];
-
- value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
- if (!value_type)
- fatal ("internal: finish_command: function has no target type");
-
- if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
- return;
-
- funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
-
- val = value_being_returned (value_type, registers,
- using_struct_return (function,
- funcaddr,
- value_type));
-
- printf ("Value returned is $%d = ", record_latest_value (val));
- value_print (val, stdout, 0, Val_no_prettyprint);
- putchar ('\n');
- }
-}
-
-static void
-program_info ()
-{
- if (inferior_pid == 0)
- {
- printf ("The program being debugged is not being run.\n");
- return;
- }
-
- printf ("Program being debugged is in process %d, stopped at 0x%x.\n",
- inferior_pid, stop_pc);
- if (stop_step)
- printf ("It stopped after being stepped.\n");
- else if (stop_breakpoint > 0)
- printf ("It stopped at breakpoint %d.\n", stop_breakpoint);
- else if (stop_signal)
- printf ("It stopped with signal %d (%s).\n",
- stop_signal, sys_siglist[stop_signal]);
-
- printf ("\nType \"info stack\" or \"info reg\" for more information.\n");
-}
-
-static void
-environment_info (var)
- char *var;
-{
- if (var)
- {
- register char *val = get_in_environ (inferior_environ, var);
- if (val)
- printf ("%s = %s\n", var, val);
- else
- printf ("Environment variable \"%s\" not defined.\n", var);
- }
- else
- {
- register char **vector = environ_vector (inferior_environ);
- while (*vector)
- printf ("%s\n", *vector++);
- }
-}
-
-static void
-set_environment_command (arg)
- char *arg;
-{
- register char *p, *val, *var;
- int nullset = 0;
-
- if (arg == 0)
- error_no_arg ("environment variable and value");
-
- /* Find seperation between variable name and value */
- p = (char *) index (arg, '=');
- val = (char *) index (arg, ' ');
-
- if (p != 0 && val != 0)
- {
- /* We have both a space and an equals. If the space is before the
- equals and the only thing between the two is more space, use
- the equals */
- if (p > val)
- while (*val == ' ')
- val++;
-
- /* Take the smaller of the two. If there was space before the
- "=", they will be the same right now. */
- p = arg + min (p - arg, val - arg);
- }
- else if (val != 0 && p == 0)
- p = val;
-
- if (p == arg)
- error_no_arg ("environment variable to set");
-
- if (p == 0 || p[1] == 0)
- {
- nullset = 1;
- if (p == 0)
- p = arg + strlen (arg); /* So that savestring below will work */
- }
- else
- {
- /* Not setting variable value to null */
- val = p + 1;
- while (*val == ' ' || *val == '\t')
- val++;
- }
-
- while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) p--;
-
- var = savestring (arg, p - arg);
- if (nullset)
- {
- printf ("Setting environment variable \"%s\" to null value.\n", var);
- set_in_environ (inferior_environ, var, "");
- }
- else
- set_in_environ (inferior_environ, var, val);
- free (var);
-}
-
-static void
-unset_environment_command (var, from_tty)
- char *var;
- int from_tty;
-{
- if (var == 0)
- /* If there is no argument, delete all environment variables.
- Ask for confirmation if reading from the terminal. */
- if (!from_tty || query ("Delete all environment variables? "))
- {
- free_environ (inferior_environ);
- inferior_environ = make_environ ();
- }
-
- unset_in_environ (inferior_environ, var);
-}
-
-/* Read an integer from debugged memory, given address and number of bytes. */
-
-long
-read_memory_integer (memaddr, len)
- CORE_ADDR memaddr;
- int len;
-{
- char cbuf;
- short sbuf;
- int ibuf;
- long lbuf;
- int result_err;
- extern int sys_nerr;
- extern char *sys_errlist[];
-
- if (len == sizeof (char))
- {
- result_err = read_memory (memaddr, &cbuf, len);
- if (result_err)
- error ("Error reading memory address 0x%x: %s (%d).",
- memaddr, (result_err < sys_nerr ?
- sys_errlist[result_err] :
- "uknown error"), result_err);
- return cbuf;
- }
- if (len == sizeof (short))
- {
- result_err = read_memory (memaddr, &sbuf, len);
- if (result_err)
- error ("Error reading memory address 0x%x: %s (%d).",
- memaddr, (result_err < sys_nerr ?
- sys_errlist[result_err] :
- "uknown error"), result_err);
- return sbuf;
- }
- if (len == sizeof (int))
- {
- result_err = read_memory (memaddr, &ibuf, len);
- if (result_err)
- error ("Error reading memory address 0x%x: %s (%d).",
- memaddr, (result_err < sys_nerr ?
- sys_errlist[result_err] :
- "uknown error"), result_err);
- return ibuf;
- }
- if (len == sizeof (lbuf))
- {
- result_err = read_memory (memaddr, &lbuf, len);
- if (result_err)
- error ("Error reading memory address 0x%x: %s (%d).",
- memaddr, (result_err < sys_nerr ?
- sys_errlist[result_err] :
- "uknown error"), result_err);
- return lbuf;
- }
- error ("Cannot handle integers of %d bytes.", len);
-}
-
-CORE_ADDR
-read_pc ()
-{
- return (CORE_ADDR) read_register (PC_REGNUM);
-}
-
-void
-write_pc (val)
- CORE_ADDR val;
-{
- write_register (PC_REGNUM, (long) val);
-#ifdef NPC_REGNUM
- write_register (NPC_REGNUM, (long) val+4);
-#endif
-}
-
-char *reg_names[] = REGISTER_NAMES;
-
-#if !defined (DO_REGISTERS_INFO)
-static void
-print_one_register(i)
- int i;
-{
- unsigned char raw_buffer[MAX_REGISTER_RAW_SIZE];
- unsigned char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
- REGISTER_TYPE val;
-
- /* Get the data in raw format, then convert also to virtual format. */
- read_relative_register_raw_bytes (i, raw_buffer);
- REGISTER_CONVERT_TO_VIRTUAL (i, raw_buffer, virtual_buffer);
-
- fputs_filtered (reg_names[i], stdout);
- print_spaces_filtered (15 - strlen (reg_names[i]), stdout);
-
- /* If virtual format is floating, print it that way. */
- if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT
- && ! INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i)))
- val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0,
- stdout, 0, 1, 0, Val_pretty_default);
- /* Else if virtual format is too long for printf,
- print in hex a byte at a time. */
- else if (REGISTER_VIRTUAL_SIZE (i) > sizeof (long))
- {
- register int j;
- printf_filtered ("0x");
- for (j = 0; j < REGISTER_VIRTUAL_SIZE (i); j++)
- printf_filtered ("%02x", virtual_buffer[j]);
- }
- /* Else print as integer in hex and in decimal. */
- else
- {
- long val;
-
- bcopy (virtual_buffer, &val, sizeof (long));
- if (val == 0)
- printf_filtered ("0");
- else
- printf_filtered ("0x%08x %d", val, val);
- }
-
- /* If register has different raw and virtual formats,
- print the raw format in hex now. */
-
- if (REGISTER_CONVERTIBLE (i))
- {
- register int j;
-
- printf_filtered (" (raw 0x");
- for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
- printf_filtered ("%02x", raw_buffer[j]);
- printf_filtered (")");
- }
- printf_filtered ("\n");
-}
-
-
-/* Print out the machine register regnum. If regnum is -1,
- print all registers.
- For most machines, having all_registers_info() print the
- register(s) one per line is good enough. If a different format
- is required, (eg, for SPARC or Pyramid 90x, which both have
- lots of regs), or there is an existing convention for showing
- all the registers, define the macro DO_REGISTERS_INFO(regnum)
- to provide that format. */
-static void
-do_registers_info (regnum, fpregs)
- int regnum;
- int fpregs;
-{
- register int i;
-
- if (regnum >= 0) {
- print_one_register(regnum);
- return;
- }
-#ifdef notdef
- printf_filtered (
-"Register Contents (relative to selected stack frame)\n\n");
-#endif
- for (i = 0; i < NUM_REGS; i++)
- if (TYPE_CODE(REGISTER_VIRTUAL_TYPE(i)) != TYPE_CODE_FLT ||
- fpregs)
- print_one_register(i);
-}
-#endif /* no DO_REGISTERS_INFO. */
-
-static void
-registers_info (addr_exp, fpregs)
- char *addr_exp;
- int fpregs;
-{
- int regnum;
-
- if (!have_inferior_p () && !have_core_file_p ())
- error ("No inferior or core file");
-
- if (addr_exp)
- {
- if (*addr_exp >= '0' && *addr_exp <= '9')
- regnum = atoi (addr_exp);
- else
- {
- register char *p = addr_exp;
- if (p[0] == '$')
- p++;
- for (regnum = 0; regnum < NUM_REGS; regnum++)
- if (!strcmp (p, reg_names[regnum]))
- break;
- if (regnum == NUM_REGS)
- error ("%s: invalid register name.", addr_exp);
- }
- }
- else
- regnum = -1;
-
-#ifdef DO_REGISTERS_INFO
- DO_REGISTERS_INFO(regnum);
-#else
- do_registers_info(regnum, fpregs);
-#endif
-}
-
-static void
-all_registers_info (addr_exp)
- char *addr_exp;
-{
- registers_info(addr_exp, 1);
-}
-
-static void
-nofp_registers_info (addr_exp)
- char *addr_exp;
-{
- registers_info(addr_exp, 0);
-}
-
-
-#ifdef ATTACH_DETACH
-#define PROCESS_ATTACH_ALLOWED 1
-#else
-#define PROCESS_ATTACH_ALLOWED 0
-#endif
-/*
- * TODO:
- * Should save/restore the tty state since it might be that the
- * program to be debugged was started on this tty and it wants
- * the tty in some state other than what we want. If it's running
- * on another terminal or without a terminal, then saving and
- * restoring the tty state is a harmless no-op.
- * This only needs to be done if we are attaching to a process.
- */
-
-/*
- * attach_command --
- * takes a program started up outside of gdb and ``attaches'' to it.
- * This stops it cold in its tracks and allows us to start tracing it.
- * For this to work, we must be able to send the process a
- * signal and we must have the same effective uid as the program.
- */
-static void
-attach_command (args, from_tty)
- char *args;
- int from_tty;
-{
- char *exec_file;
- int pid;
- int remote = 0;
-
- dont_repeat();
-
- if (!args)
- error_no_arg ("process-id or device file to attach");
-
- while (*args == ' ' || *args == '\t') args++;
-
- if (args[0] < '0' || args[0] > '9')
- remote = 1;
- else
-#ifndef ATTACH_DETACH
- error ("Can't attach to a process on this machine.");
-#else
- pid = atoi (args);
-#endif
-
- if (inferior_pid)
- {
- if (query ("A program is being debugged already. Kill it? "))
- kill_inferior ();
- else
- error ("Inferior not killed.");
- }
-
- exec_file = (char *) get_exec_file (1);
-
- if (from_tty)
- {
- if (remote)
- printf ("Attaching remote machine\n");
- else
- printf ("Attaching program: %s pid %d\n",
- exec_file, pid);
- fflush (stdout);
- }
-
- if (remote)
- {
- remote_open (args, from_tty);
- start_remote ();
- }
-#ifdef ATTACH_DETACH
- else
- attach_program (pid);
-#endif
-}
-
-/*
- * detach_command --
- * takes a program previously attached to and detaches it.
- * The program resumes execution and will no longer stop
- * on signals, etc. We better not have left any breakpoints
- * in the program or it'll die when it hits one. For this
- * to work, it may be necessary for the process to have been
- * previously attached. It *might* work if the program was
- * started via the normal ptrace (PTRACE_TRACEME).
- */
-
-static void
-detach_command (args, from_tty)
- char *args;
- int from_tty;
-{
- int signal = 0;
-
-#ifdef ATTACH_DETACH
- if (inferior_pid && !remote_debugging)
- {
- if (from_tty)
- {
- char *exec_file = (char *)get_exec_file (0);
- if (exec_file == 0)
- exec_file = "";
- printf ("Detaching program: %s pid %d\n",
- exec_file, inferior_pid);
- fflush (stdout);
- }
- if (args)
- signal = atoi (args);
-
- detach (signal);
- inferior_pid = 0;
- }
- else
-#endif
- {
- if (!remote_debugging)
- error ("Not currently attached to subsidiary or remote process.");
-
- if (args)
- error ("Argument given to \"detach\" when remotely debugging.");
-
- inferior_pid = 0;
- remote_close (from_tty);
- }
-}
-
-/* ARGSUSED */
-static void
-float_info (addr_exp)
- char *addr_exp;
-{
-#ifdef FLOAT_INFO
- FLOAT_INFO;
-#else
- printf ("No floating point info available for this processor.\n");
-#endif
-}
-
-extern struct cmd_list_element *setlist, *deletelist;
-
-void
-_initialize_infcmd ()
-{
- add_com ("tty", class_run, tty_command,
- "Set terminal for future runs of program being debugged.");
-
- add_cmd ("args", class_run, set_args_command,
- "Specify arguments to give program being debugged when it is started.\n\
-Follow this command with any number of args, to be passed to the program.",
- &setlist);
-
- add_info ("environment", environment_info,
- "The environment to give the program, or one variable's value.\n\
-With an argument VAR, prints the value of environment variable VAR to\n\
-give the program being debugged. With no arguments, prints the entire\n\
-environment to be given to the program.");
-
- add_cmd ("environment", class_run, unset_environment_command,
- "Cancel environment variable VAR for the program.\n\
-This does not affect the program until the next \"run\" command.",
- &deletelist);
-
- add_cmd ("environment", class_run, set_environment_command,
- "Set environment variable value to give the program.\n\
-Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
-VALUES of environment variables are uninterpreted strings.\n\
-This does not affect the program until the next \"run\" command.",
- &setlist);
-
-#ifdef ATTACH_DETACH
- add_com ("attach", class_run, attach_command,
- "Attach to a process that was started up outside of GDB.\n\
-This command may take as argument a process id or a device file.\n\
-For a process id, you must have permission to send the process a signal,\n\
-and it must have the same effective uid as the debugger.\n\
-For a device file, the file must be a connection to a remote debug server.\n\n\
-Before using \"attach\", you must use the \"exec-file\" command\n\
-to specify the program running in the process,\n\
-and the \"symbol-file\" command to load its symbol table.");
-#else
- add_com ("attach", class_run, attach_command,
- "Attach to a process that was started up outside of GDB.\n\
-This commands takes as an argument the name of a device file.\n\
-This file must be a connection to a remote debug server.\n\n\
-Before using \"attach\", you must use the \"exec-file\" command\n\
-to specify the program running in the process,\n\
-and the \"symbol-file\" command to load its symbol table.");
-#endif
- add_com ("detach", class_run, detach_command,
- "Detach the process previously attached.\n\
-The process is no longer traced and continues its execution.");
-
- add_com ("signal", class_run, signal_command,
- "Continue program giving it signal number SIGNUMBER.");
-
- add_com ("stepi", class_run, stepi_command,
- "Step one instruction exactly.\n\
-Argument N means do this N times (or till program stops for another reason).");
- add_com_alias ("si", "stepi", class_alias, 0);
-
- add_com ("nexti", class_run, nexti_command,
- "Step one instruction, but proceed through subroutine calls.\n\
-Argument N means do this N times (or till program stops for another reason).");
- add_com_alias ("ni", "nexti", class_alias, 0);
-
- add_com ("finish", class_run, finish_command,
- "Execute until selected stack frame returns.\n\
-Upon return, the value returned is printed and put in the value history.");
-
- add_com ("next", class_run, next_command,
- "Step program, proceeding through subroutine calls.\n\
-Like the \"step\" command as long as subroutine calls do not happen;\n\
-when they do, the call is treated as one instruction.\n\
-Argument N means do this N times (or till program stops for another reason).");
- add_com_alias ("n", "next", class_run, 1);
-
- add_com ("step", class_run, step_command,
- "Step program until it reaches a different source line.\n\
-Argument N means do this N times (or till program stops for another reason).");
- add_com_alias ("s", "step", class_run, 1);
-
- add_com ("until", class_run, until_command,
- "Execute until the program reaches a source line greater than the current\n\
-or a specified line or address or function (same args as break command).\n\
-Execution will also stop upon exit from the current stack frame.");
- add_com_alias ("u", "until", class_run, 1);
-
- add_com ("jump", class_run, jump_command,
- "Continue program being debugged at specified line or address.\n\
-Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
-for an address to start at.");
-
- add_com ("cont", class_run, cont_command,
- "Continue program being debugged, after signal or breakpoint.\n\
-If proceeding from breakpoint, a number N may be used as an argument:\n\
-then the same breakpoint won't break until the Nth time it is reached.");
- add_com_alias ("c", "cont", class_run, 1);
-
- add_com ("run", class_run, run_command,
- "Start debugged program. You may specify arguments to give it.\n\
-Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
-Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
-With no arguments, uses arguments last specified (with \"run\" or \"set args\".\n\
-To cancel previous arguments and run with no arguments,\n\
-use \"set args\" without arguments.");
- add_com_alias ("r", "run", class_run, 1);
-
- add_info ("registers", nofp_registers_info,
- "List of registers and their contents, for selected stack frame.\n\
-Register name as argument means describe only that register.\n\
-(Doesn't display floating point registers; use 'info all-registers'.)\n");
-
- add_info ("all-registers", all_registers_info,
- "List of registers and their contents, for selected stack frame.\n\
-Register name as argument means describe only that register.");
-
- add_info ("program", program_info,
- "Execution status of the program.");
-
- add_info ("float", float_info,
- "Print the status of the floating point unit\n");
-
- inferior_args = savestring (" ", 1); /* By default, no args. */
- inferior_environ = make_environ ();
- init_environ (inferior_environ);
-}
-
diff --git a/gnu/usr.bin/gdb/inferior.h b/gnu/usr.bin/gdb/inferior.h
deleted file mode 100644
index 04c662e..0000000
--- a/gnu/usr.bin/gdb/inferior.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * @(#)inferior.h 6.3 (Berkeley) 5/8/91
- */
-
-/* Variables that describe the inferior process running under GDB:
- Where it is, why it stopped, and how to step it.
- Copyright (C) 1986, 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. */
-
-/*
- * Structure in which to save the status of the inferior. Save
- * through "save_inferior_status", restore through
- * "restore_inferior_status".
- * This pair of routines should be called around any transfer of
- * control to the inferior which you don't want showing up in your
- * control variables.
- */
-struct inferior_status {
- int pc_changed;
- int stop_signal;
- int stop_pc;
- int stop_frame_address;
- int stop_breakpoint;
- int stop_step;
- int stop_stack_dummy;
- int stopped_by_random_signal;
- int trap_expected;
- CORE_ADDR step_range_start;
- CORE_ADDR step_range_end;
- FRAME_ADDR step_frame_address;
- int step_over_calls;
- CORE_ADDR step_resume_break_address;
- int stop_after_trap;
- int stop_after_attach;
- FRAME_ADDR selected_frame_address;
- int selected_level;
- struct command_line *breakpoint_commands;
- char register_context[REGISTER_BYTES];
- int restore_stack_info;
-};
-
-void save_inferior_status (), restore_inferior_status ();
-
-/* File name for default use for standard in/out in the inferior. */
-
-extern char *inferior_io_terminal;
-
-/* Pid of our debugged inferior, or 0 if no inferior now. */
-
-extern int inferior_pid;
-
-/* Nonzero if debugging a remote machine via a serial link or ethernet. */
-extern int remote_debugging;
-
-/* Routines for use in remote debugging. Documented in remote.c. */
-int remote_read_inferior_memory ();
-int remote_write_inferior_memory ();
-
-/* Last signal that the inferior received (why it stopped). */
-
-extern int stop_signal;
-
-/* Address at which inferior stopped. */
-
-extern CORE_ADDR stop_pc;
-
-/* Stack frame when program stopped. */
-
-extern FRAME_ADDR stop_frame_address;
-
-/* Number of breakpoint it stopped at, or 0 if none. */
-
-extern int stop_breakpoint;
-
-/* Nonzero if stopped due to a step command. */
-
-extern int stop_step;
-
-/* Nonzero if stopped due to completion of a stack dummy routine. */
-
-extern int stop_stack_dummy;
-
-/* Nonzero if program stopped due to a random (unexpected) signal in
- inferior process. */
-
-extern int stopped_by_random_signal;
-
-/* Range to single step within.
- If this is nonzero, respond to a single-step signal
- by continuing to step if the pc is in this range. */
-
-extern CORE_ADDR step_range_start; /* Inclusive */
-extern CORE_ADDR step_range_end; /* Exclusive */
-
-/* Stack frame address as of when stepping command was issued.
- This is how we know when we step into a subroutine call,
- and how to set the frame for the breakpoint used to step out. */
-
-extern FRAME_ADDR step_frame_address;
-
-/* 1 means step over all subroutine calls.
- -1 means step over calls to undebuggable functions. */
-
-extern int step_over_calls;
-
-/* If stepping, nonzero means step count is > 1
- so don't print frame next time inferior stops
- if it stops due to stepping. */
-
-extern int step_multi;
-
-/* Save register contents here when about to pop a stack dummy frame. */
-
-extern char stop_registers[REGISTER_BYTES];
-
-/* Nonzero if pc has been changed by the debugger
- since the inferior stopped. */
-
-extern int pc_changed;
-
-long read_memory_integer ();
diff --git a/gnu/usr.bin/gdb/inflow.c b/gnu/usr.bin/gdb/inflow.c
deleted file mode 100644
index 209fcf3..0000000
--- a/gnu/usr.bin/gdb/inflow.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)inflow.c 6.5 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Low level interface to ptrace, for GDB when running under Unix.
- 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "frame.h"
-#include "inferior.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-/* Some USG-esque systems (some of which are BSD-esque enough so that USG
- is not defined) want this header, and it won't do any harm. */
-#include <fcntl.h>
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-
-#ifdef HAVE_TERMIO
-#include <termio.h>
-#undef TIOCGETP
-#define TIOCGETP TCGETA
-#undef TIOCSETN
-#define TIOCSETN TCSETA
-#undef TIOCSETP
-#define TIOCSETP TCSETAF
-#define TERMINAL struct termio
-#else
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sgtty.h>
-#define TERMINAL struct sgttyb
-#endif
-
-#ifdef SET_STACK_LIMIT_HUGE
-#include <sys/time.h>
-#include <sys/resource.h>
-extern int original_stack_limit;
-#endif /* SET_STACK_LIMIT_HUGE */
-
-extern int errno;
-
-/* Nonzero if we are debugging an attached outside process
- rather than an inferior. */
-
-int attach_flag;
-
-
-/* Record terminal status separately for debugger and inferior. */
-
-static TERMINAL sg_inferior;
-static TERMINAL sg_ours;
-
-static int tflags_inferior;
-static int tflags_ours;
-
-#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
-static struct tchars tc_inferior;
-static struct tchars tc_ours;
-#endif
-
-#ifdef TIOCGLTC
-static struct ltchars ltc_inferior;
-static struct ltchars ltc_ours;
-#endif
-
-#ifdef TIOCLGET
-static int lmode_inferior;
-static int lmode_ours;
-#endif
-
-#ifdef TIOCGPGRP
-static int pgrp_inferior;
-static int pgrp_ours;
-#else
-static int (*sigint_ours) ();
-static int (*sigquit_ours) ();
-#endif /* TIOCGPGRP */
-
-/* Copy of inferior_io_terminal when inferior was last started. */
-static char *inferior_thisrun_terminal;
-
-static void terminal_ours_1 ();
-
-/* Nonzero if our terminal settings are in effect.
- Zero if the inferior's settings are in effect. */
-static int terminal_is_ours;
-
-/* Initialize the terminal settings we record for the inferior,
- before we actually run the inferior. */
-
-void
-terminal_init_inferior ()
-{
- if (remote_debugging)
- return;
-
- sg_inferior = sg_ours;
- tflags_inferior = tflags_ours;
-
-#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
- tc_inferior = tc_ours;
-#endif
-
-#ifdef TIOCGLTC
- ltc_inferior = ltc_ours;
-#endif
-
-#ifdef TIOCLGET
- lmode_inferior = lmode_ours;
-#endif
-
-#ifdef TIOCGPGRP
- pgrp_inferior = inferior_pid;
-#endif /* TIOCGPGRP */
-
- terminal_is_ours = 1;
-}
-
-/* Put the inferior's terminal settings into effect.
- This is preparation for starting or resuming the inferior. */
-
-void
-terminal_inferior ()
-{
- if (remote_debugging)
- return;
-
- if (terminal_is_ours) /* && inferior_thisrun_terminal == 0) */
- {
- fcntl (0, F_SETFL, tflags_inferior);
- fcntl (0, F_SETFL, tflags_inferior);
- ioctl (0, TIOCSETN, &sg_inferior);
-
-#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
- ioctl (0, TIOCSETC, &tc_inferior);
-#endif
-#ifdef TIOCGLTC
- ioctl (0, TIOCSLTC, &ltc_inferior);
-#endif
-#ifdef TIOCLGET
- ioctl (0, TIOCLSET, &lmode_inferior);
-#endif
-
-#ifdef TIOCGPGRP
- ioctl (0, TIOCSPGRP, &pgrp_inferior);
-#else
- sigint_ours = (int (*) ()) signal (SIGINT, SIG_IGN);
- sigquit_ours = (int (*) ()) signal (SIGQUIT, SIG_IGN);
-#endif /* TIOCGPGRP */
- }
- terminal_is_ours = 0;
-}
-
-/* Put some of our terminal settings into effect,
- enough to get proper results from our output,
- but do not change into or out of RAW mode
- so that no input is discarded.
-
- After doing this, either terminal_ours or terminal_inferior
- should be called to get back to a normal state of affairs. */
-
-void
-terminal_ours_for_output ()
-{
- if (remote_debugging)
- return;
-
- terminal_ours_1 (1);
-}
-
-/* Put our terminal settings into effect.
- First record the inferior's terminal settings
- so they can be restored properly later. */
-
-void
-terminal_ours ()
-{
- if (remote_debugging)
- return;
-
- terminal_ours_1 (0);
-}
-
-static void
-terminal_ours_1 (output_only)
- int output_only;
-{
-#ifdef TIOCGPGRP
- /* Ignore this signal since it will happen when we try to set the pgrp. */
- void (*osigttou) ();
-#endif /* TIOCGPGRP */
-
- if (!terminal_is_ours) /* && inferior_thisrun_terminal == 0) */
- {
- terminal_is_ours = 1;
-
-#ifdef TIOCGPGRP
- osigttou = signal (SIGTTOU, SIG_IGN);
-
- ioctl (0, TIOCGPGRP, &pgrp_inferior);
- ioctl (0, TIOCSPGRP, &pgrp_ours);
-
- signal (SIGTTOU, osigttou);
-#else
- signal (SIGINT, sigint_ours);
- signal (SIGQUIT, sigquit_ours);
-#endif /* TIOCGPGRP */
-
- tflags_inferior = fcntl (0, F_GETFL, 0);
- ioctl (0, TIOCGETP, &sg_inferior);
-
-#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
- ioctl (0, TIOCGETC, &tc_inferior);
-#endif
-#ifdef TIOCGLTC
- ioctl (0, TIOCGLTC, &ltc_inferior);
-#endif
-#ifdef TIOCLGET
- ioctl (0, TIOCLGET, &lmode_inferior);
-#endif
- }
-
-#ifdef HAVE_TERMIO
- sg_ours.c_lflag |= ICANON;
- if (output_only && !(sg_inferior.c_lflag & ICANON))
- sg_ours.c_lflag &= ~ICANON;
-#else /* not HAVE_TERMIO */
- sg_ours.sg_flags &= ~RAW & ~CBREAK;
- if (output_only)
- sg_ours.sg_flags |= (RAW | CBREAK) & sg_inferior.sg_flags;
-#endif /* not HAVE_TERMIO */
-
- fcntl (0, F_SETFL, tflags_ours);
- fcntl (0, F_SETFL, tflags_ours);
- ioctl (0, TIOCSETN, &sg_ours);
-
-#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
- ioctl (0, TIOCSETC, &tc_ours);
-#endif
-#ifdef TIOCGLTC
- ioctl (0, TIOCSLTC, &ltc_ours);
-#endif
-#ifdef TIOCLGET
- ioctl (0, TIOCLSET, &lmode_ours);
-#endif
-
-#ifdef HAVE_TERMIO
- sg_ours.c_lflag |= ICANON;
-#else /* not HAVE_TERMIO */
- sg_ours.sg_flags &= ~RAW & ~CBREAK;
-#endif /* not HAVE_TERMIO */
-}
-
-static void
-term_status_command ()
-{
- register int i;
-
- if (remote_debugging)
- {
- printf_filtered ("No terminal status when remote debugging.\n");
- return;
- }
-
- printf_filtered ("Inferior's terminal status (currently saved by GDB):\n");
-
-#ifdef HAVE_TERMIO
-
- printf_filtered ("fcntl flags = 0x%x, c_iflag = 0x%x, c_oflag = 0x%x,\n",
- tflags_inferior, sg_inferior.c_iflag, sg_inferior.c_oflag);
- printf_filtered ("c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n",
- sg_inferior.c_cflag, sg_inferior.c_lflag, sg_inferior.c_line);
- printf_filtered ("c_cc: ");
- for (i = 0; (i < NCC); i += 1)
- printf_filtered ("0x%x ", sg_inferior.c_cc[i]);
- printf_filtered ("\n");
-
-#else /* not HAVE_TERMIO */
-
- printf_filtered ("fcntl flags = 0x%x, sgttyb.sg_flags = 0x%x, owner pid = %d.\n",
- tflags_inferior, sg_inferior.sg_flags, pgrp_inferior);
-
-#endif /* not HAVE_TERMIO */
-
-#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
- printf_filtered ("tchars: ");
- for (i = 0; i < sizeof (struct tchars); i++)
- printf_filtered ("0x%x ", ((char *)&tc_inferior)[i]);
- printf_filtered ("\n");
-#endif
-
-#ifdef TIOCGLTC
- printf_filtered ("ltchars: ");
- for (i = 0; i < sizeof (struct ltchars); i++)
- printf_filtered ("0x%x ", ((char *)&ltc_inferior)[i]);
- printf_filtered ("\n");
- ioctl (0, TIOCSLTC, &ltc_ours);
-#endif
-
-#ifdef TIOCLGET
- printf_filtered ("lmode: %x\n", lmode_inferior);
-#endif
-}
-
-static void
-new_tty (ttyname)
- char *ttyname;
-{
- register int tty;
- register int fd;
-
-#ifdef TIOCNOTTY
- /* Disconnect the child process from our controlling terminal. */
- tty = open("/dev/tty", O_RDWR);
- if (tty > 0)
- {
- ioctl(tty, TIOCNOTTY, 0);
- close(tty);
- }
-#endif
-
- /* Now open the specified new terminal. */
-
- tty = open(ttyname, O_RDWR);
- if (tty == -1)
- _exit(1);
-
- /* Avoid use of dup2; doesn't exist on all systems. */
- if (tty != 0)
- { close (0); dup (tty); }
- if (tty != 1)
- { close (1); dup (tty); }
- if (tty != 2)
- { close (2); dup (tty); }
- if (tty > 2)
- close(tty);
-}
-
-/* Start an inferior process and returns its pid.
- ALLARGS is a string containing shell command to run the program.
- ENV is the environment vector to pass. */
-
-#ifndef SHELL_FILE
-#define SHELL_FILE "/bin/sh"
-#endif
-
-int
-create_inferior (allargs, env)
- char *allargs;
- char **env;
-{
- int pid;
- char *shell_command;
- extern int sys_nerr;
- extern char *sys_errlist[];
- extern int errno;
-
- /* If desired, concat something onto the front of ALLARGS.
- SHELL_COMMAND is the result. */
-#ifdef SHELL_COMMAND_CONCAT
- shell_command = (char *) alloca (strlen (SHELL_COMMAND_CONCAT) + strlen (allargs) + 1);
- strcpy (shell_command, SHELL_COMMAND_CONCAT);
- strcat (shell_command, allargs);
-#else
- shell_command = allargs;
-#endif
-
- /* exec is said to fail if the executable is open. */
- close_exec_file ();
-
-#if defined(USG) && !defined(HAVE_VFORK)
- pid = fork ();
-#else
- pid = vfork ();
-#endif
-
- if (pid < 0)
- perror_with_name ("vfork");
-
- if (pid == 0)
- {
-#ifdef TIOCGPGRP
- /* Run inferior in a separate process group. */
- setpgrp (getpid (), getpid ());
-#endif /* TIOCGPGRP */
-
-#ifdef SET_STACK_LIMIT_HUGE
- /* Reset the stack limit back to what it was. */
- {
- struct rlimit rlim;
-
- getrlimit (RLIMIT_STACK, &rlim);
- rlim.rlim_cur = original_stack_limit;
- setrlimit (RLIMIT_STACK, &rlim);
- }
-#endif /* SET_STACK_LIMIT_HUGE */
-
-
- inferior_thisrun_terminal = inferior_io_terminal;
- if (inferior_io_terminal != 0)
- new_tty (inferior_io_terminal);
-
-/* It seems that changing the signal handlers for the inferior after
- a vfork also changes them for the superior. See comments in
- initialize_signals for how we get the right signal handlers
- for the inferior. */
-/* Not needed on Sun, at least, and loses there
- because it clobbers the superior. */
-/*??? signal (SIGQUIT, SIG_DFL);
- signal (SIGINT, SIG_DFL); */
-
- call_ptrace (0);
- execle (SHELL_FILE, "sh", "-c", shell_command, 0, env);
-
- fprintf (stderr, "Cannot exec %s: %s.\n", SHELL_FILE,
- errno < sys_nerr ? sys_errlist[errno] : "unknown error");
- fflush (stderr);
- _exit (0177);
- }
-
-#ifdef TIOCGPGRP
- /* Avoid race with TIOCSPGRP: guarantee that inferior's pgrp exists. */
- setpgrp (pid, pid);
-#endif /* TIOCGPGRP */
-
-#ifdef CREATE_INFERIOR_HOOK
- CREATE_INFERIOR_HOOK (pid);
-#endif
- return pid;
-}
-
-/* Kill the inferior process. Make us have no inferior. */
-
-static void
-kill_command ()
-{
- if (remote_debugging)
- {
- inferior_pid = 0;
- return;
- }
- if (inferior_pid == 0)
- error ("The program is not being run.");
- if (!query ("Kill the inferior process? "))
- error ("Not confirmed.");
- kill_inferior ();
-}
-
-void
-inferior_died ()
-{
- inferior_pid = 0;
- attach_flag = 0;
- mark_breakpoints_out ();
- select_frame ((FRAME) 0, -1);
- reopen_exec_file ();
- if (have_core_file_p ())
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
- else
- set_current_frame (0);
-}
-
-#if 0
-/* This function is just for testing, and on some systems (Sony NewsOS
- 3.2) <sys/user.h> also includes <sys/time.h> which leads to errors
- (since on this system at least sys/time.h is not protected against
- multiple inclusion). */
-static void
-try_writing_regs_command ()
-{
- register int i;
- register int value;
- extern int errno;
-
- if (inferior_pid == 0)
- error ("There is no inferior process now.");
-
- /* A Sun 3/50 or 3/60 (at least) running SunOS 4.0.3 will have a
- kernel panic if we try to write past the end of the user area.
- Presumably Sun will fix this bug (it has been reported), but it
- is tacky to crash the system, so at least on SunOS4 we need to
- stop writing when we hit the end of the user area. */
- for (i = 0; i < sizeof (struct user); i += 2)
- {
- QUIT;
- errno = 0;
- value = call_ptrace (3, inferior_pid, i, 0);
- call_ptrace (6, inferior_pid, i, value);
- if (errno == 0)
- {
- printf (" Succeeded with address 0x%x; value 0x%x (%d).\n",
- i, value, value);
- }
- else if ((i & 0377) == 0)
- printf (" Failed at 0x%x.\n", i);
- }
-}
-#endif
-
-void
-_initialize_inflow ()
-{
- add_com ("term-status", class_obscure, term_status_command,
- "Print info on inferior's saved terminal status.");
-
-#if 0
- add_com ("try-writing-regs", class_obscure, try_writing_regs_command,
- "Try writing all locations in inferior's system block.\n\
-Report which ones can be written.");
-#endif
-
- add_com ("kill", class_run, kill_command,
- "Kill execution of program being debugged.");
-
- inferior_pid = 0;
-
- ioctl (0, TIOCGETP, &sg_ours);
- tflags_ours = fcntl (0, F_GETFL, 0);
-
-#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
- ioctl (0, TIOCGETC, &tc_ours);
-#endif
-#ifdef TIOCGLTC
- ioctl (0, TIOCGLTC, &ltc_ours);
-#endif
-#ifdef TIOCLGET
- ioctl (0, TIOCLGET, &lmode_ours);
-#endif
-
-#ifdef TIOCGPGRP
- ioctl (0, TIOCGPGRP, &pgrp_ours);
-#endif /* TIOCGPGRP */
-
- terminal_is_ours = 1;
-}
-
diff --git a/gnu/usr.bin/gdb/infrun.c b/gnu/usr.bin/gdb/infrun.c
deleted file mode 100644
index 887a0bb..0000000
--- a/gnu/usr.bin/gdb/infrun.c
+++ /dev/null
@@ -1,1459 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)infrun.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Start and stop the inferior process, for GDB.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-/* Notes on the algorithm used in wait_for_inferior to determine if we
- just did a subroutine call when stepping. We have the following
- information at that point:
-
- Current and previous (just before this step) pc.
- Current and previous sp.
- Current and previous start of current function.
-
- If the start's of the functions don't match, then
-
- a) We did a subroutine call.
-
- In this case, the pc will be at the beginning of a function.
-
- b) We did a subroutine return.
-
- Otherwise.
-
- c) We did a longjmp.
-
- If we did a longjump, we were doing "nexti", since a next would
- have attempted to skip over the assembly language routine in which
- the longjmp is coded and would have simply been the equivalent of a
- continue. I consider this ok behaivior. We'd like one of two
- things to happen if we are doing a nexti through the longjmp()
- routine: 1) It behaves as a stepi, or 2) It acts like a continue as
- above. Given that this is a special case, and that anybody who
- thinks that the concept of sub calls is meaningful in the context
- of a longjmp, I'll take either one. Let's see what happens.
-
- Acts like a subroutine return. I can handle that with no problem
- at all.
-
- -->So: If the current and previous beginnings of the current
- function don't match, *and* the pc is at the start of a function,
- we've done a subroutine call. If the pc is not at the start of a
- function, we *didn't* do a subroutine call.
-
- -->If the beginnings of the current and previous function do match,
- either:
-
- a) We just did a recursive call.
-
- In this case, we would be at the very beginning of a
- function and 1) it will have a prologue (don't jump to
- before prologue, or 2) (we assume here that it doesn't have
- a prologue) there will have been a change in the stack
- pointer over the last instruction. (Ie. it's got to put
- the saved pc somewhere. The stack is the usual place. In
- a recursive call a register is only an option if there's a
- prologue to do something with it. This is even true on
- register window machines; the prologue sets up the new
- window. It might not be true on a register window machine
- where the call instruction moved the register window
- itself. Hmmm. One would hope that the stack pointer would
- also change. If it doesn't, somebody send me a note, and
- I'll work out a more general theory.
- randy@wheaties.ai.mit.edu). This is true (albeit slipperly
- so) on all machines I'm aware of:
-
- m68k: Call changes stack pointer. Regular jumps don't.
-
- sparc: Recursive calls must have frames and therefor,
- prologues.
-
- vax: All calls have frames and hence change the
- stack pointer.
-
- b) We did a return from a recursive call. I don't see that we
- have either the ability or the need to distinguish this
- from an ordinary jump. The stack frame will be printed
- when and if the frame pointer changes; if we are in a
- function without a frame pointer, it's the users own
- lookout.
-
- c) We did a jump within a function. We assume that this is
- true if we didn't do a recursive call.
-
- d) We are in no-man's land ("I see no symbols here"). We
- don't worry about this; it will make calls look like simple
- jumps (and the stack frames will be printed when the frame
- pointer moves), which is a reasonably non-violent response.
-
-#if 0
- We skip this; it causes more problems than it's worth.
-#ifdef SUN4_COMPILER_FEATURE
- We do a special ifdef for the sun 4, forcing it to single step
- into calls which don't have prologues. This means that we can't
- nexti over leaf nodes, we can probably next over them (since they
- won't have debugging symbols, usually), and we can next out of
- functions returning structures (with a "call .stret4" at the end).
-#endif
-#endif
-*/
-
-
-
-
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-#include "inferior.h"
-#include "wait.h"
-
-#include <signal.h>
-
-/* unistd.h is needed to #define X_OK */
-#ifdef USG
-#include <unistd.h>
-#else
-#include <sys/file.h>
-#endif
-
-#ifdef UMAX_PTRACE
-#include <aouthdr.h>
-#include <sys/param.h>
-#include <sys/ptrace.h>
-#endif /* UMAX_PTRACE */
-
-/* Required by <sys/user.h>. */
-#include <sys/types.h>
-/* Required by <sys/user.h>, at least on system V. */
-#include <sys/dir.h>
-/* Needed by IN_SIGTRAMP on some machines (e.g. vax). */
-#include <sys/param.h>
-/* Needed by IN_SIGTRAMP on some machines (e.g. vax). */
-#include <sys/user.h>
-
-extern char *sys_siglist[];
-extern int errno;
-
-/* Sigtramp is a routine that the kernel calls (which then calls the
- signal handler). On most machines it is a library routine that
- is linked into the executable.
-
- This macro, given a program counter value and the name of the
- function in which that PC resides (which can be null if the
- name is not known), returns nonzero if the PC and name show
- that we are in sigtramp.
-
- On most machines just see if the name is sigtramp (and if we have
- no name, assume we are not in sigtramp). */
-#if !defined (IN_SIGTRAMP)
-#define IN_SIGTRAMP(pc, name) \
- name && !strcmp ("_sigtramp", name)
-#endif
-
-/* Tables of how to react to signals; the user sets them. */
-
-static char signal_stop[NSIG];
-static char signal_print[NSIG];
-static char signal_program[NSIG];
-
-/* Nonzero if breakpoints are now inserted in the inferior. */
-
-static int breakpoints_inserted;
-
-/* Function inferior was in as of last step command. */
-
-static struct symbol *step_start_function;
-
-/* This is the sequence of bytes we insert for a breakpoint. */
-
-static char break_insn[] = BREAKPOINT;
-
-/* Nonzero => address for special breakpoint for resuming stepping. */
-
-static CORE_ADDR step_resume_break_address;
-
-/* Original contents of the byte where the special breakpoint is. */
-
-static char step_resume_break_shadow[sizeof break_insn];
-
-/* Nonzero means the special breakpoint is a duplicate
- so it has not itself been inserted. */
-
-static int step_resume_break_duplicate;
-
-/* Nonzero if we are expecting a trace trap and should proceed from it.
- 2 means expecting 2 trace traps and should continue both times.
- That occurs when we tell sh to exec the program: we will get
- a trap after the exec of sh and a second when the program is exec'd. */
-
-static int trap_expected;
-
-/* Nonzero if the next time we try to continue the inferior, it will
- step one instruction and generate a spurious trace trap.
- This is used to compensate for a bug in HP-UX. */
-
-static int trap_expected_after_continue;
-
-/* Nonzero means expecting a trace trap
- and should stop the inferior and return silently when it happens. */
-
-int stop_after_trap;
-
-/* Nonzero means expecting a trace trap due to attaching to a process. */
-
-int stop_after_attach;
-
-/* Nonzero if pc has been changed by the debugger
- since the inferior stopped. */
-
-int pc_changed;
-
-/* Nonzero if debugging a remote machine via a serial link or ethernet. */
-
-int remote_debugging;
-
-/* Nonzero if program stopped due to error trying to insert breakpoints. */
-
-static int breakpoints_failed;
-
-/* Nonzero if inferior is in sh before our program got exec'd. */
-
-static int running_in_shell;
-
-/* Nonzero after stop if current stack frame should be printed. */
-
-static int stop_print_frame;
-
-#ifdef NO_SINGLE_STEP
-extern int one_stepped; /* From machine dependent code */
-extern void single_step (); /* Same. */
-#endif /* NO_SINGLE_STEP */
-
-static void insert_step_breakpoint ();
-static void remove_step_breakpoint ();
-static void wait_for_inferior ();
-static void normal_stop ();
-
-
-/* Clear out all variables saying what to do when inferior is continued.
- First do this, then set the ones you want, then call `proceed'. */
-
-void
-clear_proceed_status ()
-{
- trap_expected = 0;
- step_range_start = 0;
- step_range_end = 0;
- step_frame_address = 0;
- step_over_calls = -1;
- step_resume_break_address = 0;
- stop_after_trap = 0;
- stop_after_attach = 0;
-
- /* Discard any remaining commands left by breakpoint we had stopped at. */
- clear_breakpoint_commands ();
-}
-
-/* Basic routine for continuing the program in various fashions.
-
- ADDR is the address to resume at, or -1 for resume where stopped.
- SIGNAL is the signal to give it, or 0 for none,
- or -1 for act according to how it stopped.
- STEP is nonzero if should trap after one instruction.
- -1 means return after that and print nothing.
- You should probably set various step_... variables
- before calling here, if you are stepping.
-
- You should call clear_proceed_status before calling proceed. */
-
-void
-proceed (addr, signal, step)
- CORE_ADDR addr;
- int signal;
- int step;
-{
- int oneproc = 0;
-
- if (step > 0)
- step_start_function = find_pc_function (read_pc ());
- if (step < 0)
- stop_after_trap = 1;
-
- if (addr == -1)
- {
- /* If there is a breakpoint at the address we will resume at,
- step one instruction before inserting breakpoints
- so that we do not stop right away. */
-
- if (!pc_changed && breakpoint_here_p (read_pc ()))
- oneproc = 1;
- }
- else
- {
- write_register (PC_REGNUM, addr);
-#ifdef NPC_REGNUM
- write_register (NPC_REGNUM, addr + 4);
-#endif
- }
-
- if (trap_expected_after_continue)
- {
- /* If (step == 0), a trap will be automatically generated after
- the first instruction is executed. Force step one
- instruction to clear this condition. This should not occur
- if step is nonzero, but it is harmless in that case. */
- oneproc = 1;
- trap_expected_after_continue = 0;
- }
-
- if (oneproc)
- /* We will get a trace trap after one instruction.
- Continue it automatically and insert breakpoints then. */
- trap_expected = 1;
- else
- {
- int temp = insert_breakpoints ();
- if (temp)
- {
- print_sys_errmsg ("ptrace", temp);
- error ("Cannot insert breakpoints.\n\
-The same program may be running in another process.");
- }
- breakpoints_inserted = 1;
- }
-
- /* Install inferior's terminal modes. */
- terminal_inferior ();
-
- if (signal >= 0)
- stop_signal = signal;
- /* If this signal should not be seen by program,
- give it zero. Used for debugging signals. */
- else if (stop_signal < NSIG && !signal_program[stop_signal])
- stop_signal= 0;
-
- /* Resume inferior. */
- resume (oneproc || step, stop_signal);
-
- /* Wait for it to stop (if not standalone)
- and in any case decode why it stopped, and act accordingly. */
-
- wait_for_inferior ();
- normal_stop ();
-}
-
-/* Writing the inferior pc as a register calls this function
- to inform infrun that the pc has been set in the debugger. */
-
-void
-writing_pc (val)
- CORE_ADDR val;
-{
- stop_pc = val;
- pc_changed = 1;
-}
-
-/* Start an inferior process for the first time.
- Actually it was started by the fork that created it,
- but it will have stopped one instruction after execing sh.
- Here we must get it up to actual execution of the real program. */
-
-void
-start_inferior ()
-{
- /* We will get a trace trap after one instruction.
- Continue it automatically. Eventually (after shell does an exec)
- it will get another trace trap. Then insert breakpoints and continue. */
-
-#ifdef START_INFERIOR_TRAPS_EXPECTED
- trap_expected = START_INFERIOR_TRAPS_EXPECTED;
-#else
- trap_expected = 2;
-#endif
-
- running_in_shell = 0; /* Set to 1 at first SIGTRAP, 0 at second. */
- trap_expected_after_continue = 0;
- breakpoints_inserted = 0;
- mark_breakpoints_out ();
-
- /* Set up the "saved terminal modes" of the inferior
- based on what modes we are starting it with. */
- terminal_init_inferior ();
-
- /* Install inferior's terminal modes. */
- terminal_inferior ();
-
- if (remote_debugging)
- {
- trap_expected = 0;
- fetch_inferior_registers();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
- stop_frame_address = FRAME_FP (get_current_frame());
- inferior_pid = 3;
- if (insert_breakpoints())
- fatal("Can't insert breakpoints");
- breakpoints_inserted = 1;
- proceed(-1, -1, 0);
- }
- else
- {
- wait_for_inferior ();
- normal_stop ();
- }
-}
-
-/* Start or restart remote-debugging of a machine over a serial link. */
-
-void
-restart_remote ()
-{
- clear_proceed_status ();
- running_in_shell = 0;
- trap_expected = 0;
- stop_after_attach = 1;
- inferior_pid = 3;
- wait_for_inferior ();
- normal_stop();
-}
-
-void
-start_remote ()
-{
- breakpoints_inserted = 0;
- mark_breakpoints_out ();
- restart_remote();
-}
-
-#ifdef ATTACH_DETACH
-
-/* Attach to process PID, then initialize for debugging it
- and wait for the trace-trap that results from attaching. */
-
-void
-attach_program (pid)
- int pid;
-{
- attach (pid);
- inferior_pid = pid;
-
- mark_breakpoints_out ();
- terminal_init_inferior ();
- clear_proceed_status ();
- stop_after_attach = 1;
- /*proceed (-1, 0, -2);*/
- terminal_inferior ();
- wait_for_inferior ();
- normal_stop ();
-}
-#endif /* ATTACH_DETACH */
-
-/* Wait for control to return from inferior to debugger.
- If inferior gets a signal, we may decide to start it up again
- instead of returning. That is why there is a loop in this function.
- When this function actually returns it means the inferior
- should be left stopped and GDB should read more commands. */
-
-static void
-wait_for_inferior ()
-{
- register int pid;
- WAITTYPE w;
- CORE_ADDR pc;
- int tem;
- int another_trap;
- int random_signal;
- CORE_ADDR stop_sp, prev_sp;
- CORE_ADDR prev_func_start, stop_func_start;
- char *prev_func_name, *stop_func_name;
- CORE_ADDR prologue_pc;
- int stop_step_resume_break;
- CORE_ADDR step_resume_break_sp;
- int newmisc;
- int newfun_pc;
- struct symtab_and_line sal;
- int prev_pc;
- extern CORE_ADDR text_end;
- int remove_breakpoints_on_following_step = 0;
-
- prev_pc = read_pc ();
- (void) find_pc_partial_function (prev_pc, &prev_func_name,
- &prev_func_start);
- prev_func_start += FUNCTION_START_OFFSET;
- prev_sp = read_register (SP_REGNUM);
-
- while (1)
- {
- /* Clean up saved state that will become invalid. */
- pc_changed = 0;
- flush_cached_frames ();
-
- if (remote_debugging)
- remote_wait (&w);
- else
- {
- pid = wait (&w);
- if (pid != inferior_pid)
- continue;
- }
-
- /* See if the process still exists; clean up if it doesn't. */
- if (WIFEXITED (w))
- {
- terminal_ours_for_output ();
- if (WEXITSTATUS (w))
- printf ("\nProgram exited with code 0%o.\n", WEXITSTATUS (w));
- else
- printf ("\nProgram exited normally.\n");
- fflush (stdout);
- inferior_died ();
-#ifdef NO_SINGLE_STEP
- one_stepped = 0;
-#endif
- stop_print_frame = 0;
- break;
- }
- else if (!WIFSTOPPED (w))
- {
- kill_inferior ();
- stop_print_frame = 0;
- stop_signal = WTERMSIG (w);
- terminal_ours_for_output ();
- printf ("\nProgram terminated with signal %d, %s\n",
- stop_signal,
- stop_signal < NSIG
- ? sys_siglist[stop_signal]
- : "(undocumented)");
- printf ("The inferior process no longer exists.\n");
- fflush (stdout);
-#ifdef NO_SINGLE_STEP
- one_stepped = 0;
-#endif
- break;
- }
-
-#ifdef NO_SINGLE_STEP
- if (one_stepped)
- single_step (0); /* This actually cleans up the ss */
-#endif /* NO_SINGLE_STEP */
-
- fetch_inferior_registers ();
- stop_pc = read_pc ();
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
-
- stop_frame_address = FRAME_FP (get_current_frame ());
- stop_sp = read_register (SP_REGNUM);
- stop_func_start = 0;
- stop_func_name = 0;
- /* Don't care about return value; stop_func_start and stop_func_name
- will both be 0 if it doesn't work. */
- (void) find_pc_partial_function (stop_pc, &stop_func_name,
- &stop_func_start);
- stop_func_start += FUNCTION_START_OFFSET;
- another_trap = 0;
- stop_breakpoint = 0;
- stop_step = 0;
- stop_stack_dummy = 0;
- stop_print_frame = 1;
- stop_step_resume_break = 0;
- random_signal = 0;
- stopped_by_random_signal = 0;
- breakpoints_failed = 0;
-
- /* Look at the cause of the stop, and decide what to do.
- The alternatives are:
- 1) break; to really stop and return to the debugger,
- 2) drop through to start up again
- (set another_trap to 1 to single step once)
- 3) set random_signal to 1, and the decision between 1 and 2
- will be made according to the signal handling tables. */
-
- stop_signal = WSTOPSIG (w);
-
- /* First, distinguish signals caused by the debugger from signals
- that have to do with the program's own actions.
- Note that breakpoint insns may cause SIGTRAP or SIGILL
- or SIGEMT, depending on the operating system version.
- Here we detect when a SIGILL or SIGEMT is really a breakpoint
- and change it to SIGTRAP. */
-
- if (stop_signal == SIGTRAP
- || (breakpoints_inserted &&
- (stop_signal == SIGILL
- || stop_signal == SIGEMT))
- || stop_after_attach)
- {
- if (stop_signal == SIGTRAP && stop_after_trap)
- {
- stop_print_frame = 0;
- break;
- }
- if (stop_after_attach)
- break;
- /* Don't even think about breakpoints
- if still running the shell that will exec the program
- or if just proceeded over a breakpoint. */
- if (stop_signal == SIGTRAP && trap_expected)
- stop_breakpoint = 0;
- else
- {
- /* See if there is a breakpoint at the current PC. */
-#if DECR_PC_AFTER_BREAK
- /* Notice the case of stepping through a jump
- that leads just after a breakpoint.
- Don't confuse that with hitting the breakpoint.
- What we check for is that 1) stepping is going on
- and 2) the pc before the last insn does not match
- the address of the breakpoint before the current pc. */
- if (!(prev_pc != stop_pc - DECR_PC_AFTER_BREAK
- && step_range_end && !step_resume_break_address))
-#endif /* DECR_PC_AFTER_BREAK not zero */
- {
- /* See if we stopped at the special breakpoint for
- stepping over a subroutine call. */
- if (stop_pc - DECR_PC_AFTER_BREAK
- == step_resume_break_address)
- {
- stop_step_resume_break = 1;
- if (DECR_PC_AFTER_BREAK)
- {
- stop_pc -= DECR_PC_AFTER_BREAK;
- write_register (PC_REGNUM, stop_pc);
- pc_changed = 0;
- }
- }
- else
- {
- stop_breakpoint =
- breakpoint_stop_status (stop_pc, stop_frame_address);
- /* Following in case break condition called a
- function. */
- stop_print_frame = 1;
- if (stop_breakpoint && DECR_PC_AFTER_BREAK)
- {
- stop_pc -= DECR_PC_AFTER_BREAK;
- write_register (PC_REGNUM, stop_pc);
-#ifdef NPC_REGNUM
- write_register (NPC_REGNUM, stop_pc + 4);
-#endif
- pc_changed = 0;
- }
- }
- }
- }
-
- if (stop_signal == SIGTRAP)
- random_signal
- = !(stop_breakpoint || trap_expected
- || stop_step_resume_break
-#ifndef CANNOT_EXECUTE_STACK
- || (stop_sp INNER_THAN stop_pc
- && stop_pc INNER_THAN stop_frame_address)
-#else
- || stop_pc == text_end - 2
-#endif
- || (step_range_end && !step_resume_break_address));
- else
- {
- random_signal
- = !(stop_breakpoint
- || stop_step_resume_break
-#ifdef sony_news
- || (stop_sp INNER_THAN stop_pc
- && stop_pc INNER_THAN stop_frame_address)
-#endif
-
- );
- if (!random_signal)
- stop_signal = SIGTRAP;
- }
- }
- else
- random_signal = 1;
-
- /* For the program's own signals, act according to
- the signal handling tables. */
-
- if (random_signal
- && !(running_in_shell && stop_signal == SIGSEGV))
- {
- /* Signal not for debugging purposes. */
- int printed = 0;
-
- stopped_by_random_signal = 1;
-
- if (stop_signal >= NSIG
- || signal_print[stop_signal])
- {
- printed = 1;
- terminal_ours_for_output ();
- printf ("\nProgram received signal %d, %s\n",
- stop_signal,
- stop_signal < NSIG
- ? sys_siglist[stop_signal]
- : "(undocumented)");
- fflush (stdout);
- }
- if (stop_signal >= NSIG
- || signal_stop[stop_signal])
- break;
- /* If not going to stop, give terminal back
- if we took it away. */
- else if (printed)
- terminal_inferior ();
- }
-
- /* Handle cases caused by hitting a breakpoint. */
-
- if (!random_signal
- && (stop_breakpoint || stop_step_resume_break))
- {
- /* Does a breakpoint want us to stop? */
- if (stop_breakpoint && stop_breakpoint != -1
- && stop_breakpoint != -0x1000001)
- {
- /* 0x1000000 is set in stop_breakpoint as returned by
- breakpoint_stop_status to indicate a silent
- breakpoint. */
- if ((stop_breakpoint > 0 ? stop_breakpoint :
- -stop_breakpoint)
- & 0x1000000)
- {
- stop_print_frame = 0;
- if (stop_breakpoint > 0)
- stop_breakpoint -= 0x1000000;
- else
- stop_breakpoint += 0x1000000;
- }
- break;
- }
- /* But if we have hit the step-resumption breakpoint,
- remove it. It has done its job getting us here.
- The sp test is to make sure that we don't get hung
- up in recursive calls in functions without frame
- pointers. If the stack pointer isn't outside of
- where the breakpoint was set (within a routine to be
- stepped over), we're in the middle of a recursive
- call. Not true for reg window machines (sparc)
- because the must change frames to call things and
- the stack pointer doesn't have to change if it
- the bp was set in a routine without a frame (pc can
- be stored in some other window).
-
- The removal of the sp test is to allow calls to
- alloca. Nasty things were happening. Oh, well,
- gdb can only handle one level deep of lack of
- frame pointer. */
- if (stop_step_resume_break
- && (step_frame_address == 0
- || (stop_frame_address == step_frame_address)))
- {
- remove_step_breakpoint ();
- step_resume_break_address = 0;
- }
- /* Otherwise, must remove breakpoints and single-step
- to get us past the one we hit. */
- else
- {
- remove_breakpoints ();
- remove_step_breakpoint ();
- breakpoints_inserted = 0;
- another_trap = 1;
- }
-
- /* We come here if we hit a breakpoint but should not
- stop for it. Possibly we also were stepping
- and should stop for that. So fall through and
- test for stepping. But, if not stepping,
- do not stop. */
- }
-
- /* If this is the breakpoint at the end of a stack dummy,
- just stop silently. */
-#ifndef CANNOT_EXECUTE_STACK
- if (stop_sp INNER_THAN stop_pc
- && stop_pc INNER_THAN stop_frame_address)
-#else
- if (stop_pc == text_end - 2)
-#endif
- {
- stop_print_frame = 0;
- stop_stack_dummy = 1;
-#ifdef HP_OS_BUG
- trap_expected_after_continue = 1;
-#endif
- break;
- }
-
- if (step_resume_break_address)
- /* Having a step-resume breakpoint overrides anything
- else having to do with stepping commands until
- that breakpoint is reached. */
- ;
- /* If stepping through a line, keep going if still within it. */
- else if (!random_signal
- && step_range_end
- && stop_pc >= step_range_start
- && stop_pc < step_range_end
- /* The step range might include the start of the
- function, so if we are at the start of the
- step range and either the stack or frame pointers
- just changed, we've stepped outside */
- && !(stop_pc == step_range_start
- && stop_frame_address
- && (stop_sp INNER_THAN prev_sp
- || stop_frame_address != step_frame_address)))
- {
- /* Don't step through the return from a function
- unless that is the first instruction stepped through. */
- if (ABOUT_TO_RETURN (stop_pc))
- {
- stop_step = 1;
- break;
- }
- }
-
- /* We stepped out of the stepping range. See if that was due
- to a subroutine call that we should proceed to the end of. */
- else if (!random_signal && step_range_end)
- {
- if (stop_func_start)
- {
- prologue_pc = stop_func_start;
- SKIP_PROLOGUE (prologue_pc);
- }
-
- /* Did we just take a signal? */
- if (IN_SIGTRAMP (stop_pc, stop_func_name)
- && !IN_SIGTRAMP (prev_pc, prev_func_name))
- {
- /* This code is needed at least in the following case:
- The user types "next" and then a signal arrives (before
- the "next" is done). */
- /* We've just taken a signal; go until we are back to
- the point where we took it and one more. */
- step_resume_break_address = prev_pc;
- step_resume_break_duplicate =
- breakpoint_here_p (step_resume_break_address);
- step_resume_break_sp = stop_sp;
- if (breakpoints_inserted)
- insert_step_breakpoint ();
- /* Make sure that the stepping range gets us past
- that instruction. */
- if (step_range_end == 1)
- step_range_end = (step_range_start = prev_pc) + 1;
- remove_breakpoints_on_following_step = 1;
- }
-
- /* ==> See comments at top of file on this algorithm. <==*/
-
- else if (stop_pc == stop_func_start
- && (stop_func_start != prev_func_start
- || prologue_pc != stop_func_start
- || stop_sp != prev_sp))
- {
- /* It's a subroutine call */
- if (step_over_calls > 0
- || (step_over_calls && find_pc_function (stop_pc) == 0))
- {
- /* A subroutine call has happened. */
- /* Set a special breakpoint after the return */
- step_resume_break_address =
- SAVED_PC_AFTER_CALL (get_current_frame ());
- step_resume_break_duplicate
- = breakpoint_here_p (step_resume_break_address);
- step_resume_break_sp = stop_sp;
- if (breakpoints_inserted)
- insert_step_breakpoint ();
- }
- /* Subroutine call with source code we should not step over.
- Do step to the first line of code in it. */
- else if (step_over_calls)
- {
- SKIP_PROLOGUE (stop_func_start);
- sal = find_pc_line (stop_func_start, 0);
- /* Use the step_resume_break to step until
- the end of the prologue, even if that involves jumps
- (as it seems to on the vax under 4.2). */
- /* If the prologue ends in the middle of a source line,
- continue to the end of that source line.
- Otherwise, just go to end of prologue. */
-#ifdef PROLOGUE_FIRSTLINE_OVERLAP
- /* no, don't either. It skips any code that's
- legitimately on the first line. */
-#else
- if (sal.end && sal.pc != stop_func_start)
- stop_func_start = sal.end;
-#endif
-
- if (stop_func_start == stop_pc)
- {
- /* We are already there: stop now. */
- stop_step = 1;
- break;
- }
- else
- /* Put the step-breakpoint there and go until there. */
- {
- step_resume_break_address = stop_func_start;
- step_resume_break_sp = stop_sp;
-
- step_resume_break_duplicate
- = breakpoint_here_p (step_resume_break_address);
- if (breakpoints_inserted)
- insert_step_breakpoint ();
- /* Do not specify what the fp should be when we stop
- since on some machines the prologue
- is where the new fp value is established. */
- step_frame_address = 0;
- /* And make sure stepping stops right away then. */
- step_range_end = step_range_start;
- }
- }
- else
- {
- /* We get here only if step_over_calls is 0 and we
- just stepped into a subroutine. I presume
- that step_over_calls is only 0 when we're
- supposed to be stepping at the assembly
- language level.*/
- stop_step = 1;
- break;
- }
- }
- /* No subroutince call; stop now. */
- else
- {
- stop_step = 1;
- break;
- }
- }
-
- /* Save the pc before execution, to compare with pc after stop. */
- prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */
- prev_func_start = stop_func_start; /* Ok, since if DECR_PC_AFTER
- BREAK is defined, the
- original pc would not have
- been at the start of a
- function. */
- prev_func_name = stop_func_name;
- prev_sp = stop_sp;
-
- /* If we did not do break;, it means we should keep
- running the inferior and not return to debugger. */
-
- /* If trap_expected is 2, it means continue once more
- and insert breakpoints at the next trap.
- If trap_expected is 1 and the signal was SIGSEGV, it means
- the shell is doing some memory allocation--just resume it
- with SIGSEGV.
- Otherwise insert breakpoints now, and possibly single step. */
-
- if (trap_expected > 1)
- {
- trap_expected--;
- running_in_shell = 1;
- resume (0, 0);
- }
- else if (running_in_shell && stop_signal == SIGSEGV)
- {
- resume (0, SIGSEGV);
- }
- else if (trap_expected && stop_signal != SIGTRAP)
- {
- /* We took a signal which we are supposed to pass through to
- the inferior and we haven't yet gotten our trap. Simply
- continue. */
- resume ((step_range_end && !step_resume_break_address)
- || trap_expected,
- stop_signal);
- }
- else
- {
- /* Here, we are not awaiting another exec to get
- the program we really want to debug.
- Insert breakpoints now, unless we are trying
- to one-proceed past a breakpoint. */
- running_in_shell = 0;
- /* If we've just finished a special step resume and we don't
- want to hit a breakpoint, pull em out. */
- if (!step_resume_break_address &&
- remove_breakpoints_on_following_step)
- {
- remove_breakpoints_on_following_step = 0;
- remove_breakpoints ();
- breakpoints_inserted = 0;
- }
- else if (!breakpoints_inserted && !another_trap)
- {
- insert_step_breakpoint ();
- breakpoints_failed = insert_breakpoints ();
- if (breakpoints_failed)
- break;
- breakpoints_inserted = 1;
- }
-
- trap_expected = another_trap;
-
- if (stop_signal == SIGTRAP)
- stop_signal = 0;
-
- resume ((step_range_end && !step_resume_break_address)
- || trap_expected,
- stop_signal);
- }
- }
-}
-
-/* Here to return control to GDB when the inferior stops for real.
- Print appropriate messages, remove breakpoints, give terminal our modes.
-
- RUNNING_IN_SHELL nonzero means the shell got a signal before
- exec'ing the program we wanted to run.
- STOP_PRINT_FRAME nonzero means print the executing frame
- (pc, function, args, file, line number and line text).
- BREAKPOINTS_FAILED nonzero means stop was due to error
- attempting to insert breakpoints. */
-
-static void
-normal_stop ()
-{
- /* Make sure that the current_frame's pc is correct. This
- is a correction for setting up the frame info before doing
- DECR_PC_AFTER_BREAK */
- if (inferior_pid)
- (get_current_frame ())->pc = read_pc ();
-
- if (breakpoints_failed)
- {
- terminal_ours_for_output ();
- print_sys_errmsg ("ptrace", breakpoints_failed);
- printf ("Stopped; cannot insert breakpoints.\n\
-The same program may be running in another process.\n");
- }
-
- if (inferior_pid)
- remove_step_breakpoint ();
-
- if (inferior_pid && breakpoints_inserted)
- if (remove_breakpoints ())
- {
- terminal_ours_for_output ();
- printf ("Cannot remove breakpoints because program is no longer writable.\n\
-It must be running in another process.\n\
-Further execution is probably impossible.\n");
- }
-
- breakpoints_inserted = 0;
-
- /* Delete the breakpoint we stopped at, if it wants to be deleted.
- Delete any breakpoint that is to be deleted at the next stop. */
-
- breakpoint_auto_delete (stop_breakpoint);
-
- /* If an auto-display called a function and that got a signal,
- delete that auto-display to avoid an infinite recursion. */
-
- if (stopped_by_random_signal)
- disable_current_display ();
-
- if (step_multi && stop_step)
- return;
-
- terminal_ours ();
-
- if (running_in_shell)
- {
- if (stop_signal == SIGSEGV)
- {
- char *exec_file = (char *) get_exec_file (1);
-
- if (access (exec_file, X_OK) != 0)
- printf ("The file \"%s\" is not executable.\n", exec_file);
- else
- /* I don't think we should ever get here.
- wait_for_inferior now ignores SIGSEGV's which happen in
- the shell (since the Bourne shell (/bin/sh) has some
- rather, er, uh, *unorthodox* memory management
- involving catching SIGSEGV). */
- printf ("\
-You have just encountered a bug in \"sh\". GDB starts your program\n\
-by running \"sh\" with a command to exec your program.\n\
-This is so that \"sh\" will process wildcards and I/O redirection.\n\
-This time, \"sh\" crashed.\n\
-\n\
-One known bug in \"sh\" bites when the environment takes up a lot of space.\n\
-Try \"info env\" to see the environment; then use \"delete env\" to kill\n\
-some variables whose values are large; then do \"run\" again.\n\
-\n\
-If that works, you might want to put those \"delete env\" commands\n\
-into a \".gdbinit\" file in this directory so they will happen every time.\n");
- }
- /* Don't confuse user with his program's symbols on sh's data. */
- stop_print_frame = 0;
- }
-
- if (inferior_pid == 0)
- return;
-
- /* Select innermost stack frame except on return from a stack dummy routine,
- or if the program has exited. */
- if (!stop_stack_dummy)
- {
- select_frame (get_current_frame (), 0);
-
- if (stop_print_frame)
- {
- if (stop_breakpoint > 0)
- printf ("\nBpt %d, ", stop_breakpoint);
- print_sel_frame (stop_step
- && step_frame_address == stop_frame_address
- && step_start_function == find_pc_function (stop_pc));
- /* Display the auto-display expressions. */
- do_displays ();
- }
- }
-
- if (stop_stack_dummy)
- {
- /* Pop the empty frame that contains the stack dummy.
- POP_FRAME ends with a setting of the current frame, so we
- can use that next. */
-#ifndef NEW_CALL_FUNCTION
- POP_FRAME;
-#endif
- select_frame (get_current_frame (), 0);
- }
-}
-
-static void
-insert_step_breakpoint ()
-{
- if (step_resume_break_address && !step_resume_break_duplicate)
- {
- read_memory (step_resume_break_address,
- step_resume_break_shadow, sizeof break_insn);
- write_memory (step_resume_break_address,
- break_insn, sizeof break_insn);
- }
-}
-
-static void
-remove_step_breakpoint ()
-{
- if (step_resume_break_address && !step_resume_break_duplicate)
- write_memory (step_resume_break_address, step_resume_break_shadow,
- sizeof break_insn);
-}
-
-/* Specify how various signals in the inferior should be handled. */
-
-static void
-handle_command (args, from_tty)
- char *args;
- int from_tty;
-{
- register char *p = args;
- int signum = 0;
- register int digits, wordlen;
-
- if (!args)
- error_no_arg ("signal to handle");
-
- while (*p)
- {
- /* Find the end of the next word in the args. */
- for (wordlen = 0; p[wordlen] && p[wordlen] != ' ' && p[wordlen] != '\t';
- wordlen++);
- for (digits = 0; p[digits] >= '0' && p[digits] <= '9'; digits++);
-
- /* If it is all digits, it is signal number to operate on. */
- if (digits == wordlen)
- {
- signum = atoi (p);
- if (signum <= 0 || signum >= NSIG)
- {
- p[wordlen] = '\0';
- error ("Invalid signal %s given as argument to \"handle\".", p);
- }
- if (signum == SIGTRAP || signum == SIGINT)
- {
- if (!query ("Signal %d is used by the debugger.\nAre you sure you want to change it? ", signum))
- error ("Not confirmed.");
- }
- }
- else if (signum == 0)
- error ("First argument is not a signal number.");
-
- /* Else, if already got a signal number, look for flag words
- saying what to do for it. */
- else if (!strncmp (p, "stop", wordlen))
- {
- signal_stop[signum] = 1;
- signal_print[signum] = 1;
- }
- else if (wordlen >= 2 && !strncmp (p, "print", wordlen))
- signal_print[signum] = 1;
- else if (wordlen >= 2 && !strncmp (p, "pass", wordlen))
- signal_program[signum] = 1;
- else if (!strncmp (p, "ignore", wordlen))
- signal_program[signum] = 0;
- else if (wordlen >= 3 && !strncmp (p, "nostop", wordlen))
- signal_stop[signum] = 0;
- else if (wordlen >= 4 && !strncmp (p, "noprint", wordlen))
- {
- signal_print[signum] = 0;
- signal_stop[signum] = 0;
- }
- else if (wordlen >= 4 && !strncmp (p, "nopass", wordlen))
- signal_program[signum] = 0;
- else if (wordlen >= 3 && !strncmp (p, "noignore", wordlen))
- signal_program[signum] = 1;
- /* Not a number and not a recognized flag word => complain. */
- else
- {
- p[wordlen] = 0;
- error ("Unrecognized flag word: \"%s\".", p);
- }
-
- /* Find start of next word. */
- p += wordlen;
- while (*p == ' ' || *p == '\t') p++;
- }
-
- if (from_tty)
- {
- /* Show the results. */
- printf ("Number\tStop\tPrint\tPass to program\tDescription\n");
- printf ("%d\t", signum);
- printf ("%s\t", signal_stop[signum] ? "Yes" : "No");
- printf ("%s\t", signal_print[signum] ? "Yes" : "No");
- printf ("%s\t\t", signal_program[signum] ? "Yes" : "No");
- printf ("%s\n", sys_siglist[signum]);
- }
-}
-
-/* Print current contents of the tables set by the handle command. */
-
-static void
-signals_info (signum_exp)
- char *signum_exp;
-{
- register int i;
- printf_filtered ("Number\tStop\tPrint\tPass to program\tDescription\n");
-
- if (signum_exp)
- {
- i = parse_and_eval_address (signum_exp);
- if (i >= NSIG || i < 0)
- error ("Signal number out of bounds.");
- printf_filtered ("%d\t", i);
- printf_filtered ("%s\t", signal_stop[i] ? "Yes" : "No");
- printf_filtered ("%s\t", signal_print[i] ? "Yes" : "No");
- printf_filtered ("%s\t\t", signal_program[i] ? "Yes" : "No");
- printf_filtered ("%s\n", sys_siglist[i]);
- return;
- }
-
- printf_filtered ("\n");
- for (i = 0; i < NSIG; i++)
- {
- QUIT;
-
- printf_filtered ("%d\t", i);
- printf_filtered ("%s\t", signal_stop[i] ? "Yes" : "No");
- printf_filtered ("%s\t", signal_print[i] ? "Yes" : "No");
- printf_filtered ("%s\t\t", signal_program[i] ? "Yes" : "No");
- printf_filtered ("%s\n", sys_siglist[i]);
- }
-
- printf_filtered ("\nUse the \"handle\" command to change these tables.\n");
-}
-
-/* Save all of the information associated with the inferior<==>gdb
- connection. INF_STATUS is a pointer to a "struct inferior_status"
- (defined in inferior.h). */
-
-struct command_line *get_breakpoint_commands ();
-
-void
-save_inferior_status (inf_status, restore_stack_info)
- struct inferior_status *inf_status;
- int restore_stack_info;
-{
- inf_status->pc_changed = pc_changed;
- inf_status->stop_signal = stop_signal;
- inf_status->stop_pc = stop_pc;
- inf_status->stop_frame_address = stop_frame_address;
- inf_status->stop_breakpoint = stop_breakpoint;
- inf_status->stop_step = stop_step;
- inf_status->stop_stack_dummy = stop_stack_dummy;
- inf_status->stopped_by_random_signal = stopped_by_random_signal;
- inf_status->trap_expected = trap_expected;
- inf_status->step_range_start = step_range_start;
- inf_status->step_range_end = step_range_end;
- inf_status->step_frame_address = step_frame_address;
- inf_status->step_over_calls = step_over_calls;
- inf_status->step_resume_break_address = step_resume_break_address;
- inf_status->stop_after_trap = stop_after_trap;
- inf_status->stop_after_attach = stop_after_attach;
- inf_status->breakpoint_commands = get_breakpoint_commands ();
- inf_status->restore_stack_info = restore_stack_info;
-
- read_register_bytes(0, inf_status->register_context, REGISTER_BYTES);
- record_selected_frame (&(inf_status->selected_frame_address),
- &(inf_status->selected_level));
- return;
-}
-
-void
-restore_inferior_status (inf_status)
- struct inferior_status *inf_status;
-{
- FRAME fid;
- int level = inf_status->selected_level;
-
- pc_changed = inf_status->pc_changed;
- stop_signal = inf_status->stop_signal;
- stop_pc = inf_status->stop_pc;
- stop_frame_address = inf_status->stop_frame_address;
- stop_breakpoint = inf_status->stop_breakpoint;
- stop_step = inf_status->stop_step;
- stop_stack_dummy = inf_status->stop_stack_dummy;
- stopped_by_random_signal = inf_status->stopped_by_random_signal;
- trap_expected = inf_status->trap_expected;
- step_range_start = inf_status->step_range_start;
- step_range_end = inf_status->step_range_end;
- step_frame_address = inf_status->step_frame_address;
- step_over_calls = inf_status->step_over_calls;
- step_resume_break_address = inf_status->step_resume_break_address;
- stop_after_trap = inf_status->stop_after_trap;
- stop_after_attach = inf_status->stop_after_attach;
- set_breakpoint_commands (inf_status->breakpoint_commands);
-
- write_register_bytes(0, inf_status->register_context, REGISTER_BYTES);
-
- /* The inferior can be gone if the user types "print exit(0)"
- (and perhaps other times). */
- if (have_inferior_p() && inf_status->restore_stack_info)
- {
- flush_cached_frames();
- set_current_frame(create_new_frame(read_register (FP_REGNUM),
- read_pc()));
-
- fid = find_relative_frame (get_current_frame (), &level);
-
- if (fid == 0 ||
- FRAME_FP (fid) != inf_status->selected_frame_address ||
- level != 0)
- {
- /* I'm not sure this error message is a good idea. I have
- only seen it occur after "Can't continue previously
- requested operation" (we get called from do_cleanups), in
- which case it just adds insult to injury (one confusing
- error message after another. Besides which, does the
- user really care if we can't restore the previously
- selected frame? */
- fprintf (stderr, "Unable to restore previously selected frame.\n");
- select_frame (get_current_frame (), 0);
- return;
- }
-
- select_frame (fid, inf_status->selected_level);
- }
- return;
-}
-
-
-void
-_initialize_infrun ()
-{
- register int i;
-
- add_info ("signals", signals_info,
- "What debugger does when program gets various signals.\n\
-Specify a signal number as argument to print info on that signal only.");
-
- add_com ("handle", class_run, handle_command,
- "Specify how to handle a signal.\n\
-Args are signal number followed by flags.\n\
-Flags allowed are \"stop\", \"print\", \"pass\",\n\
- \"nostop\", \"noprint\" or \"nopass\".\n\
-Print means print a message if this signal happens.\n\
-Stop means reenter debugger if this signal happens (implies print).\n\
-Pass means let program see this signal; otherwise program doesn't know.\n\
-Pass and Stop may be combined.");
-
- for (i = 0; i < NSIG; i++)
- {
- signal_stop[i] = 1;
- signal_print[i] = 1;
- signal_program[i] = 1;
- }
-
- /* Signals caused by debugger's own actions
- should not be given to the program afterwards. */
- signal_program[SIGTRAP] = 0;
- signal_program[SIGINT] = 0;
-
- /* Signals that are not errors should not normally enter the debugger. */
-#ifdef SIGALRM
- signal_stop[SIGALRM] = 0;
- signal_print[SIGALRM] = 0;
-#endif /* SIGALRM */
-#ifdef SIGVTALRM
- signal_stop[SIGVTALRM] = 0;
- signal_print[SIGVTALRM] = 0;
-#endif /* SIGVTALRM */
-#ifdef SIGPROF
- signal_stop[SIGPROF] = 0;
- signal_print[SIGPROF] = 0;
-#endif /* SIGPROF */
-#ifdef SIGCHLD
- signal_stop[SIGCHLD] = 0;
- signal_print[SIGCHLD] = 0;
-#endif /* SIGCHLD */
-#ifdef SIGCLD
- signal_stop[SIGCLD] = 0;
- signal_print[SIGCLD] = 0;
-#endif /* SIGCLD */
-#ifdef SIGIO
- signal_stop[SIGIO] = 0;
- signal_print[SIGIO] = 0;
-#endif /* SIGIO */
-#ifdef SIGURG
- signal_stop[SIGURG] = 0;
- signal_print[SIGURG] = 0;
-#endif /* SIGURG */
-}
-
diff --git a/gnu/usr.bin/gdb/kgdb_proto.h b/gnu/usr.bin/gdb/kgdb_proto.h
deleted file mode 100644
index 8bbd5be..0000000
--- a/gnu/usr.bin/gdb/kgdb_proto.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Steven McCanne of Lawrence Berkeley Laboratory.
- *
- * 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.
- *
- * @(#)kgdb_proto.h 6.3 (Berkeley) 5/8/91
- *
- *
- * $Header: /home/cvs/386BSD/src/usr.bin/gdb/kgdb_proto.h,v 1.1.1.1 1993/06/12 14:52:25 rgrimes Exp $ (LBL)
- */
-
-/*
- * Message types.
- */
-#define KGDB_MEM_R 0x01
-#define KGDB_MEM_W 0x02
-#define KGDB_REG_R 0x03
-#define KGDB_REG_W 0x04
-#define KGDB_CONT 0x05
-#define KGDB_STEP 0x06
-#define KGDB_KILL 0x07
-#define KGDB_SIGNAL 0x08
-#define KGDB_EXEC 0x09
-
-#define KGDB_CMD(x) ((x) & 0x0f)
-
-/*
- * Message flags.
- */
-#define KGDB_ACK 0x80
-#define KGDB_DELTA 0x40
-#define KGDB_MORE 0x20
-#define KGDB_SEQ 0x10
diff --git a/gnu/usr.bin/gdb/main.c b/gnu/usr.bin/gdb/main.c
deleted file mode 100644
index 323de87..0000000
--- a/gnu/usr.bin/gdb/main.c
+++ /dev/null
@@ -1,2241 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)main.c 6.6 (Berkeley) 5/13/91";
-#endif /* not lint */
-
-/* Top level for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "command.h"
-#include "param.h"
-#include "expression.h"
-
-#ifdef USG
-#include <sys/types.h>
-#include <unistd.h>
-#endif
-
-#include <sys/file.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <ctype.h>
-
-#ifdef SET_STACK_LIMIT_HUGE
-#include <sys/time.h>
-#include <sys/resource.h>
-
-int original_stack_limit;
-#endif
-
-/* If this definition isn't overridden by the header files, assume
- that isatty and fileno exist on this system. */
-#ifndef ISATTY
-#define ISATTY(FP) (isatty (fileno (FP)))
-#endif
-
-extern void free ();
-
-/* Version number of GDB, as a string. */
-
-extern char *version;
-
-/*
- * Declare all cmd_list_element's
- */
-
-/* Chain containing all defined commands. */
-
-struct cmd_list_element *cmdlist;
-
-/* Chain containing all defined info subcommands. */
-
-struct cmd_list_element *infolist;
-
-/* Chain containing all defined enable subcommands. */
-
-struct cmd_list_element *enablelist;
-
-/* Chain containing all defined disable subcommands. */
-
-struct cmd_list_element *disablelist;
-
-/* Chain containing all defined delete subcommands. */
-
-struct cmd_list_element *deletelist;
-
-/* Chain containing all defined "enable breakpoint" subcommands. */
-
-struct cmd_list_element *enablebreaklist;
-
-/* Chain containing all defined set subcommands */
-
-struct cmd_list_element *setlist;
-
-/* Chain containing all defined \"set history\". */
-
-struct cmd_list_element *sethistlist;
-
-/* Chain containing all defined \"unset history\". */
-
-struct cmd_list_element *unsethistlist;
-
-/* stdio stream that command input is being read from. */
-
-FILE *instream;
-
-/* Current working directory. */
-
-char *current_directory;
-
-/* The directory name is actually stored here (usually). */
-static char dirbuf[MAXPATHLEN];
-
-#ifdef KERNELDEBUG
-/* Nonzero if we're debugging /dev/mem or a kernel crash dump */
-
-int kernel_debugging;
-#endif
-
-/* Nonzero to inhibit confirmation of quitting or restarting
- a stopped inferior. */
-int inhibit_confirm;
-
-/* Nonzero if we can write in text or core file */
-
-int writeable_text;
-
-/* The number of lines on a page, and the number of spaces
- in a line. */
-int linesize, pagesize;
-
-/* Nonzero if we should refrain from using an X window. */
-
-int inhibit_windows = 0;
-
-/* Function to call before reading a command, if nonzero.
- The function receives two args: an input stream,
- and a prompt string. */
-
-void (*window_hook) ();
-
-extern int frame_file_full_name;
-int xgdb_verbose;
-
-void execute_command();
-void free_command_lines ();
-char *gdb_readline ();
-char *command_line_input ();
-static void initialize_main ();
-static void initialize_cmd_lists ();
-void command_loop ();
-static void source_command ();
-static void print_gdb_version ();
-static void float_handler ();
-static void cd_command ();
-
-char *getenv ();
-
-/* gdb prints this when reading a command interactively */
-static char *prompt;
-
-/* Buffer used for reading command lines, and the size
- allocated for it so far. */
-
-char *line;
-int linesize;
-
-
-/* This is how `error' returns to command level. */
-
-jmp_buf to_top_level;
-
-void
-return_to_top_level ()
-{
- quit_flag = 0;
- immediate_quit = 0;
- clear_breakpoint_commands ();
- clear_momentary_breakpoints ();
- disable_current_display ();
- do_cleanups (0);
- longjmp (to_top_level, 1);
-}
-
-/* Call FUNC with arg ARG, catching any errors.
- If there is no error, return the value returned by FUNC.
- If there is an error, return zero after printing ERRSTRING
- (which is in addition to the specific error message already printed). */
-
-int
-catch_errors (func, arg, errstring)
- int (*func) ();
- int arg;
- char *errstring;
-{
- jmp_buf saved;
- int val;
- struct cleanup *saved_cleanup_chain;
-
- saved_cleanup_chain = save_cleanups ();
-
- bcopy (to_top_level, saved, sizeof (jmp_buf));
-
- if (setjmp (to_top_level) == 0)
- val = (*func) (arg);
- else
- {
- fprintf (stderr, "%s\n", errstring);
- val = 0;
- }
-
- restore_cleanups (saved_cleanup_chain);
-
- bcopy (saved, to_top_level, sizeof (jmp_buf));
- return val;
-}
-
-/* Handler for SIGHUP. */
-
-static void
-disconnect ()
-{
- kill_inferior_fast ();
- signal (SIGHUP, SIG_DFL);
- kill (getpid (), SIGHUP);
-}
-
-/* Clean up on error during a "source" command (or execution of a
- user-defined command).
- Close the file opened by the command
- and restore the previous input stream. */
-
-static void
-source_cleanup (stream)
- FILE *stream;
-{
- /* Instream may be 0; set to it when executing user-defined command. */
- if (instream)
- fclose (instream);
- instream = stream;
-}
-
-/*
- * Source $HOME/.gdbinit and $cwd/.gdbinit.
- * If X is enabled, also $HOME/.xgdbinit and $cwd/.xgdbinit.source
- */
-void
-source_init_files()
-{
- char *homedir, initfile[256];
- int samedir = 0;
-
- /* Read init file, if it exists in home directory */
- homedir = getenv ("HOME");
- if (homedir) {
- struct stat homebuf, cwdbuf;
-
- sprintf(initfile, "%s/.gdbinit", homedir);
- if (access (initfile, R_OK) == 0)
- if (!setjmp (to_top_level))
- source_command (initfile);
- if (!inhibit_windows) {
- sprintf(initfile, "%s/.xgdbinit", homedir);
- if (access (initfile, R_OK) == 0)
- if (!setjmp (to_top_level))
- source_command (initfile);
- }
- /* Determine if current directory is the same as the home
- directory, so we don't source the same file twice. */
-
- bzero (&homebuf, sizeof (struct stat));
- bzero (&cwdbuf, sizeof (struct stat));
-
- stat(homedir, &homebuf);
- stat(".", &cwdbuf);
-
- samedir = bcmp(&homebuf, &cwdbuf, sizeof(struct stat)) == 0;
- }
- /* Read the input file in the current directory, *if* it isn't
- the same file (it should exist, also). */
- if (!samedir) {
- if (access (".gdbinit", R_OK) == 0)
- if (!setjmp (to_top_level))
- source_command (".gdbinit");
- if (access (".xgdbinit", R_OK) == 0)
- if (!setjmp (to_top_level))
- source_command (".xgdbinit");
- }
-}
-
-
-int
-main (argc, argv, envp)
- int argc;
- char **argv;
- char **envp;
-{
- int count;
- int inhibit_gdbinit = 0;
- int quiet = 1;
- int batch = 0;
- register int i;
- char *cp;
-
- /* XXX Windows only for xgdb. */
- char *strrchr();
- if (cp = strrchr(argv[0], '/'))
- ++cp;
- else
- cp = argv[0];
- if (*cp != 'x')
- inhibit_windows = 1;
-
-#if defined (ALIGN_STACK_ON_STARTUP)
- i = (int) &count & 0x3;
- if (i != 0)
- alloca (4 - i);
-#endif
-
- quit_flag = 0;
- linesize = 100;
- line = (char *) xmalloc (linesize);
- *line = 0;
- instream = stdin;
-
- getwd (dirbuf);
- current_directory = dirbuf;
-
-#ifdef SET_STACK_LIMIT_HUGE
- {
- struct rlimit rlim;
-
- /* Set the stack limit huge so that alloca (particularly stringtab
- * in dbxread.c) does not fail. */
- getrlimit (RLIMIT_STACK, &rlim);
- original_stack_limit = rlim.rlim_cur;
- rlim.rlim_cur = rlim.rlim_max;
- setrlimit (RLIMIT_STACK, &rlim);
- }
-#endif /* SET_STACK_LIMIT_HUGE */
-
- /* Look for flag arguments. */
-
- for (i = 1; i < argc; i++)
- {
- if (!strcmp (argv[i], "-q") || !strcmp (argv[i], "-quiet"))
- quiet = 1;
- else if (!strcmp (argv[i], "-nx"))
- inhibit_gdbinit = 1;
- else if (!strcmp (argv[i], "-nw"))
- inhibit_windows = 1;
- else if (!strcmp (argv[i], "-batch"))
- batch = 1, quiet = 1;
- else if (!strcmp (argv[i], "-fullname"))
- frame_file_full_name = 1;
- else if (!strcmp (argv[i], "-xgdb_verbose"))
- xgdb_verbose = 1;
- /* -help: print a summary of command line switches. */
- else if (!strcmp (argv[i], "-help"))
- {
- fputs ("\
-This is GDB, the GNU debugger. Use the command\n\
- gdb [options] [executable [core-file]]\n\
-to enter the debugger.\n\
-\n\
-Options available are:\n\
- -help Print this message.\n\
- -quiet Do not print version number on startup.\n\
- -fullname Output information used by emacs-GDB interface.\n\
- -batch Exit after processing options.\n\
- -nx Do not read .gdbinit file.\n\
- -tty TTY Use TTY for input/output by the program being debugged.\n\
- -cd DIR Change current directory to DIR.\n\
- -directory DIR Search for source files in DIR.\n\
- -command FILE Execute GDB commands from FILE.\n\
- -symbols SYMFILE Read symbols from SYMFILE.\n\
- -exec EXECFILE Use EXECFILE as the executable.\n\
- -se FILE Use FILE as symbol file and executable file.\n\
- -core COREFILE Analyze the core dump COREFILE.\n\
- -k Kernel debugging.\n\
- -w Writeable text.\n\
- -v Print GNU message and version number on startup.\n\
- -nc Don't confirm quit or run commands.\n\
-\n\
-For more information, type \"help\" from within GDB, or consult the\n\
-GDB manual (available as on-line info or a printed manual).\n", stderr);
- /* Exiting after printing this message seems like
- the most useful thing to do. */
- exit (0);
- }
-#ifdef KERNELDEBUG
- else if (!strcmp (argv[i], "-k"))
- kernel_debugging = 1;
-#endif
- else if (!strcmp (argv[i], "-w"))
- writeable_text = 1;
- else if (!strcmp (argv[i], "-v"))
- quiet = 0;
- else if (!strcmp (argv[i], "-nc"))
- inhibit_confirm = 1;
- else if (argv[i][0] == '-')
- /* Other options take arguments, so don't confuse an
- argument with an option. */
- i++;
- }
-
- /* Run the init function of each source file */
-
- initialize_cmd_lists (); /* This needs to be done first */
- initialize_all_files ();
- initialize_main (); /* But that omits this file! Do it now */
- initialize_signals ();
-
- if (!quiet)
- print_gdb_version ();
-
- /* Process the command line arguments. */
-
- count = 0;
- for (i = 1; i < argc; i++)
- {
- extern void exec_file_command (), symbol_file_command ();
- extern void core_file_command ();
- register char *arg = argv[i];
- /* Args starting with - say what to do with the following arg
- as a filename. */
- if (arg[0] == '-')
- {
- extern void tty_command (), directory_command ();
-
- if (!strcmp (arg, "-q") || !strcmp (arg, "-nx")
- || !strcmp (arg, "-quiet") || !strcmp (arg, "-batch")
- || !strcmp (arg, "-fullname") || !strcmp (arg, "-nw")
- || !strcmp (arg, "-xgdb_verbose")
- || !strcmp (arg, "-help")
- || !strcmp (arg, "-k")
- || !strcmp (arg, "-w")
- || !strcmp (arg, "-v")
- || !strcmp (arg, "-nc"))
- /* Already processed above */
- continue;
-
- if (++i == argc)
- fprintf (stderr, "No argument follows \"%s\".\n", arg);
- if (!setjmp (to_top_level))
- {
- /* -s foo: get syms from foo. -e foo: execute foo.
- -se foo: do both with foo. -c foo: use foo as core dump. */
- if (!strcmp (arg, "-se"))
- {
- exec_file_command (argv[i], !batch);
- symbol_file_command (argv[i], !batch);
- }
- else if (!strcmp (arg, "-s") || !strcmp (arg, "-symbols"))
- symbol_file_command (argv[i], !batch);
- else if (!strcmp (arg, "-e") || !strcmp (arg, "-exec"))
- exec_file_command (argv[i], !batch);
- else if (!strcmp (arg, "-c") || !strcmp (arg, "-core"))
- core_file_command (argv[i], !batch);
- /* -x foo: execute commands from foo. */
- else if (!strcmp (arg, "-x") || !strcmp (arg, "-command")
- || !strcmp (arg, "-commands"))
- source_command (argv[i]);
- /* -d foo: add directory `foo' to source-file directory
- search-list */
- else if (!strcmp (arg, "-d") || !strcmp (arg, "-dir")
- || !strcmp (arg, "-directory"))
- directory_command (argv[i], 0);
- /* -cd FOO: specify current directory as FOO.
- GDB remembers the precise string FOO as the dirname. */
- else if (!strcmp (arg, "-cd"))
- {
- cd_command (argv[i], 0);
- init_source_path ();
- }
- /* -t /def/ttyp1: use /dev/ttyp1 for inferior I/O. */
- else if (!strcmp (arg, "-t") || !strcmp (arg, "-tty"))
- tty_command (argv[i], 0);
-
- else
- error ("Unknown command-line switch: \"%s\"\n", arg);
- }
- }
- else
- {
- /* Args not thus accounted for
- are treated as, first, the symbol/executable file
- and, second, the core dump file. */
- count++;
- if (!setjmp (to_top_level))
- switch (count)
- {
- case 1:
- exec_file_command (arg, !batch);
- symbol_file_command (arg, !batch);
- break;
-
- case 2:
- core_file_command (arg, !batch);
- break;
-
- case 3:
- fprintf (stderr, "Excess command line args ignored. (%s%s)\n",
- arg, (i == argc - 1) ? "" : " ...");
- }
- }
- }
-
- if (!inhibit_gdbinit)
- source_init_files();
-
- if (batch)
- {
-#if 0
- fatal ("Attempt to read commands from stdin in batch mode.");
-#endif
- /* We have hit the end of the batch file. */
- exit (0);
- }
-
- if (!quiet)
- printf ("Type \"help\" for a list of commands.\n");
-
- /* The command loop. */
-
- while (1)
- {
- if (!setjmp (to_top_level))
- command_loop ();
- if (ISATTY(stdin))
- clearerr (stdin); /* Don't get hung if C-d is typed. */
- else if (feof(instream)) /* Avoid endless loops for redirected stdin */
- break;
- }
- exit (0);
-}
-
-
-static void
-do_nothing ()
-{
-}
-
-/* Read commands from `instream' and execute them
- until end of file. */
-void
-command_loop ()
-{
- struct cleanup *old_chain;
- register int toplevel = (instream == stdin);
- register int interactive = (toplevel && ISATTY(stdin));
-
- while (!feof (instream))
- {
- register char *cmd_line;
-
- quit_flag = 0;
- if (interactive)
- reinitialize_more_filter ();
- old_chain = make_cleanup (do_nothing, 0);
- cmd_line = command_line_input (prompt, toplevel);
- execute_command (cmd_line, toplevel);
- /* Do any commands attached to breakpoint we stopped at. */
- do_breakpoint_commands ();
- do_cleanups (old_chain);
- }
-}
-
-/* Commands call this if they do not want to be repeated by null lines. */
-
-void
-dont_repeat ()
-{
- /* If we aren't reading from standard input, we are saving the last
- thing read from stdin in line and don't want to delete it. Null lines
- won't repeat here in any case. */
- if (instream == stdin)
- *line = 0;
-}
-
-/* Read a line from the stream "instream" without command line editing.
-
- It prints PROMPT once at the start.
- Action is compatible with "readline" (i.e., space for typing is
- malloced & should be freed by caller). */
-char *
-gdb_readline (prompt)
- char *prompt;
-{
- int c;
- char *result;
- int input_index = 0;
- int result_size = 80;
-
- if (prompt)
- {
- printf (prompt);
- fflush (stdout);
- }
-
- result = (char *) xmalloc (result_size);
-
- while (1)
- {
- c = fgetc (instream ? instream : stdin);
- if (c == EOF)
- {
- free(result);
- return ((char *)0);
- }
- if (c == '\n')
- break;
-
- result[input_index++] = c;
- if (input_index >= result_size)
- {
- result_size <= 1;
- result = (char *)xrealloc(result, result_size);
- }
- }
- result[input_index++] = '\0';
- return result;
-}
-
-/* Declaration for fancy readline with command line editing. */
-char *readline ();
-
-/* Variables which control command line editing and history
- substitution. These variables are given default values at the end
- of this file. */
-static int command_editing_p;
-static int history_expansion_p;
-static int write_history_p;
-static int history_size;
-static char *history_filename;
-
-/* Variables which are necessary for fancy command line editing. */
-char *gdb_completer_word_break_characters =
- " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,";
-
-/* Functions that are used as part of the fancy command line editing. */
-
-/* Generate symbol names one by one for the completer. If STATE is
- zero, then we need to initialize, otherwise the initialization has
- already taken place. TEXT is what we expect the symbol to start
- with. RL_LINE_BUFFER is available to be looked at; it contains the
- entire text of the line. RL_POINT is the offset in that line of
- the cursor. You should pretend that the line ends at RL_POINT. */
-char *
-symbol_completion_function (text, state)
- char *text;
- int state;
-{
- char **make_symbol_completion_list ();
- static char **list = (char **)NULL;
- static int index;
- char *output;
- extern char *rl_line_buffer;
- extern int rl_point;
- char *tmp_command, *p;
- struct cmd_list_element *c, *result_list;
-
- if (!state)
- {
- /* Free the storage used by LIST, but not by the strings inside. This is
- because rl_complete_internal () frees the strings. */
- if (list)
- free (list);
- list = 0;
- index = 0;
-
- /* Decide whether to complete on a list of gdb commands or on
- symbols. */
- tmp_command = (char *) alloca (rl_point + 1);
- p = tmp_command;
-
- strncpy (tmp_command, rl_line_buffer, rl_point);
- tmp_command[rl_point] = '\0';
-
- if (rl_point == 0)
- {
- /* An empty line we want to consider ambiguous; that is,
- it could be any command. */
- c = (struct cmd_list_element *) -1;
- result_list = 0;
- }
- else
- c = lookup_cmd_1 (&p, cmdlist, &result_list, 1);
-
- /* Move p up to the next interesting thing. */
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (!c)
- /* He's typed something unrecognizable. Sigh. */
- list = (char **) 0;
- else if (c == (struct cmd_list_element *) -1)
- {
- if (p + strlen(text) != tmp_command + rl_point)
- error ("Unrecognized command.");
-
- /* He's typed something ambiguous. This is easier. */
- if (result_list)
- list = complete_on_cmdlist (*result_list->prefixlist, text);
- else
- list = complete_on_cmdlist (cmdlist, text);
- }
- else
- {
- /* If we've gotten this far, gdb has recognized a full
- command. There are several possibilities:
-
- 1) We need to complete on the command.
- 2) We need to complete on the possibilities coming after
- the command.
- 2) We need to complete the text of what comes after the
- command. */
-
- if (!*p && *text)
- /* Always (might be longer versions of thie command). */
- list = complete_on_cmdlist (result_list, text);
- else if (!*p && !*text)
- {
- if (c->prefixlist)
- list = complete_on_cmdlist (*c->prefixlist, "");
- else
- list = make_symbol_completion_list ("");
- }
- else
- {
- if (c->prefixlist && !c->allow_unknown)
- {
- *p = '\0';
- error ("\"%s\" command requires a subcommand.",
- tmp_command);
- }
- else
- list = make_symbol_completion_list (text);
- }
- }
- }
-
- /* If the debugged program wasn't compiled with symbols, or if we're
- clearly completing on a command and no command matches, return
- NULL. */
- if (!list)
- return ((char *)NULL);
-
- output = list[index];
- if (output)
- index++;
-
- return (output);
-}
-
-
-void
-print_prompt ()
-{
- if (prompt)
- {
- printf ("%s", prompt);
- fflush (stdout);
- }
-}
-
-
-#ifdef HAVE_TERMIO
-#include <termio.h>
-static struct termio norm_tty;
-
-static void
-suspend_sig()
-{
- int tty = fileno(stdin);
- struct termio cur_tty;
-
- ioctl(tty, TCGETA, &cur_tty);
- ioctl(tty, TCSETAW, &norm_tty);
-
- (void) sigsetmask(0);
- signal(SIGTSTP, SIG_DFL);
- kill(0, SIGTSTP);
-
- /*
- * we've just been resumed -- current tty params become new
- * 'normal' params (in case tset/stty was done while we were
- * suspended). Merge values that readline might have changed
- * into new params, then restore term mode.
- */
- ioctl(tty, TCGETA, &norm_tty);
- cur_tty.c_lflag = (cur_tty.c_lflag & (ICANON|ECHO|ISIG)) |
- (norm_tty.c_lflag &~ (ICANON|ECHO|ISIG));
- cur_tty.c_iflag = (cur_tty.c_iflag & (IXON|ISTRIP|INPCK)) |
- (norm_tty.c_iflag &~ (IXON|ISTRIP|INPCK));
- ioctl(tty, TCSETAW, &cur_tty);
-
- signal(SIGTSTP, suspend_sig);
- print_prompt();
-
- /*
- * Forget about any previous command -- null line now will do
- * nothing.
- */
- dont_repeat();
-}
-
-#else
-
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sgtty.h>
-
-static struct sgttyb norm_tty;
-static struct tchars norm_tchars;
-static struct ltchars norm_ltchars;
-static int norm_lflags;
-
-#ifdef PASS8
-#define RL_TFLAGS (RAW|CRMOD|ECHO|CBREAK|PASS8)
-#else
-#define RL_TFLAGS (RAW|CRMOD|ECHO|CBREAK)
-#endif
-
-static void
-suspend_sig()
-{
- int tty = fileno(stdin);
- struct sgttyb cur_tty;
- struct tchars cur_tchars;
- struct ltchars cur_ltchars;
- int cur_lflags;
- int cur_flags;
-
- ioctl(tty, TIOCGETP, &cur_tty);
- ioctl(tty, TIOCGETC, &cur_tchars);
- ioctl(tty, TIOCLGET, &cur_lflags);
- ioctl(tty, TIOCGLTC, &cur_ltchars);
-
- ioctl(tty, TIOCSETP, &norm_tty);
- ioctl(tty, TIOCSETC, &norm_tchars);
- ioctl(tty, TIOCLSET, &norm_lflags);
- ioctl(tty, TIOCSLTC, &norm_ltchars);
-
- (void) sigsetmask(0);
- signal(SIGTSTP, SIG_DFL);
- kill(0, SIGTSTP);
-
- /*
- * we've just been resumed -- current tty params become new
- * 'normal' params (in case tset/stty was done while we were
- * suspended). Merge values that readline might have changed
- * into new params, then restore term mode.
- */
- ioctl(tty, TIOCGETP, &norm_tty);
- cur_flags = cur_tty.sg_flags;
- cur_tty = norm_tty;
- cur_tty.sg_flags = (cur_tty.sg_flags &~ RL_TFLAGS)
- | (cur_flags & RL_TFLAGS);
-
- ioctl(tty, TIOCLGET, &norm_lflags);
-#ifdef LPASS8
- cur_lflags = (cur_lflags &~ LPASS8) | (cur_flags & LPASS8);
-#endif
- ioctl(tty, TIOCGETC, &norm_tchars);
- ioctl(tty, TIOCGLTC, &norm_ltchars);
-
- ioctl(tty, TIOCSETP, &cur_tty);
- ioctl(tty, TIOCSETC, &cur_tchars);
- ioctl(tty, TIOCLSET, &cur_lflags);
- ioctl(tty, TIOCSLTC, &cur_ltchars);
-
- signal(SIGTSTP, suspend_sig);
- print_prompt();
-
- /*
- * Forget about any previous command -- null line now will do
- * nothing.
- */
- dont_repeat();
-}
-#endif /* HAVE_TERMIO */
-
-/* Initialize signal handlers. */
-initialize_signals ()
-{
- extern void request_quit ();
- int tty = fileno(stdin);
-
- signal (SIGINT, request_quit);
-
- /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
- passed to the inferior, which we don't want. It would be
- possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
- on BSD4.3 systems using vfork, that will (apparently) affect the
- GDB process as well as the inferior (the signal handling tables
- being shared between the two, apparently). Since we establish
- a handler for SIGQUIT, when we call exec it will set the signal
- to SIG_DFL for us. */
- signal (SIGQUIT, do_nothing);
- if (signal (SIGHUP, do_nothing) != SIG_IGN)
- signal (SIGHUP, disconnect);
- signal (SIGFPE, float_handler);
-
- ioctl(tty, TIOCGETP, &norm_tty);
- ioctl(tty, TIOCLGET, &norm_lflags);
- ioctl(tty, TIOCGETC, &norm_tchars);
- ioctl(tty, TIOCGLTC, &norm_ltchars);
- signal(SIGTSTP, suspend_sig);
-}
-
-char *
-finish_command_input(inputline, repeat, interactive)
- register char *inputline;
- int repeat;
- int interactive;
-{
- static char *do_free;
-
- if (do_free) {
- free(do_free);
- do_free = NULL;
- }
-
- /* Do history expansion if that is wished. */
- if (interactive && history_expansion_p) {
- int expanded;
-
- expanded = history_expand(inputline, &do_free);
- if (expanded) {
- /* Print the changes. */
- puts(do_free);
-
- /* An error acts like no input. */
- if (expanded < 0) {
- *do_free = 0;
- return (do_free);
- }
- }
- inputline = do_free;
- }
- /* get rid of any leading whitespace */
- while (isspace(*inputline))
- ++inputline;
- /*
- * If we just got an empty line, and that is supposed to repeat the
- * previous command, return the value in the global buffer.
- */
- if (*inputline == 0) {
- if (repeat)
- return (line);
- } else if (interactive)
- add_history(inputline);
-
- /*
- * If line is a comment, clear it out.
- * Note: comments are added to the command history. This is useful
- * when you type a command, and then realize you don't want to
- * execute it quite yet. You can comment out the command and then
- * later fetch it from the value history and remove the '#'.
- */
- if (*inputline == '#')
- *inputline = 0;
- else if (repeat) {
- /* Save into global buffer. */
- register int i = strlen(inputline) + 1;
-
- if (i > linesize) {
- line = xrealloc(line, i);
- linesize = i;
- }
- strcpy(line, inputline);
- }
- return (inputline);
-}
-
-static char *
-get_a_cmd_line(prompt, interactive)
- char *prompt;
- int interactive;
-{
- register char *cp;
-
- /* Control-C quits instantly if typed while reading input. */
- immediate_quit++;
- if (interactive && command_editing_p) {
- extern void (*rl_event_hook)();
-
- rl_event_hook = window_hook;
- cp = readline(prompt);
- } else {
- if (interactive) {
- if (window_hook) {
- print_prompt();
- (*window_hook)();
- }
- } else
- prompt = NULL;
- cp = gdb_readline(prompt);
- }
- --immediate_quit;
- return (cp);
-}
-
-/* Read one line from the command input stream `instream'
- Returns the address of the start of the line.
-
- *If* the instream == stdin & stdin is a terminal, the line read
- is copied into the file line saver (global var char *line,
- length linesize) so that it can be duplicated.
-
- This routine either uses fancy command line editing or
- simple input as the user has requested. */
-
-char *
-command_line_input(prompt, repeat)
- char *prompt;
- int repeat;
-{
- static char *do_free;
- register int interactive = (instream == stdin && ISATTY(instream));
- register char *cp;
- register int i;
-
- if (do_free) {
- free(do_free);
- do_free = NULL;
- }
- cp = get_a_cmd_line(prompt, interactive);
-
- /*
- * handle continued lines (this loop is not particularly
- * efficient because it's rare).
- */
- while (cp && cp[i = strlen(cp) - 1] == '\\') {
- register char *np = get_a_cmd_line(prompt, interactive);
- register int j;
-
- if (np == NULL) {
- cp[i] = 0;
- break;
- }
- j = strlen(np);
- cp = xrealloc(cp, i + j + 1);
- strcpy(cp + i, np);
- free(np);
- }
- if (cp == NULL)
- return ("");
- do_free = cp;
- return (finish_command_input(cp, repeat, interactive));
-}
-
-
-#define MAX_USER_ARGS 32
-
-static struct user_args {
- struct {
- char *arg;
- int len;
- } a[10];
-} uargs[MAX_USER_ARGS];
-
-static struct user_args *user_arg = uargs;
-
-static void
-arg_cleanup(ap)
- struct user_args *ap;
-{
- user_arg = ap;
-}
-
-/* Bind arguments $arg0, $arg1, ..., for a user defined command. */
-struct cleanup *
-setup_user_args(p)
- char *p;
-{
- register int i;
- struct cleanup *old_chain = make_cleanup(arg_cleanup, user_arg);
-
- if (++user_arg >= &uargs[MAX_USER_ARGS])
- error("user defined functions nested too deeply\n");
-
- bzero(user_arg, sizeof(*user_arg));
-
- i = 0;
- while (*p) {
- while (isspace(*p))
- ++p;
- user_arg->a[i].arg = p;
- while (*p && ! isspace(*p))
- ++p;
- user_arg->a[i].len = p - user_arg->a[i].arg;
- ++i;
- }
- return (old_chain);
-}
-
-static char *
-findarg(str)
- register char *str;
-{
- register char *cp = str;
- extern char *index();
-
- while (cp = index(cp, '$')) {
- if (strncmp(cp, "$arg", 4) == 0 && isdigit(cp[4]))
- return (cp);
- ++cp;
- }
- return (char *)0;
-}
-
-/* expand arguments from "line" into "new" */
-static void
-expand_args(line, new)
- register char *line, *new;
-{
- register char *cp = findarg(line);
-
- while (cp = findarg(line)) {
- int i, len;
-
- bcopy(line, new, cp - line);
- new += cp - line;
- i = cp[4] - '0';
- if (len = user_arg->a[i].len) {
- bcopy(user_arg->a[i].arg, new, len);
- new += len;
- }
- line = cp + 5;
- }
- strcpy(new, line);
-}
-
-/* expand any arguments in "line" then execute the result */
-static void
-expand_and_execute(line, from_tty)
- char *line;
- int from_tty;
-{
- void execute_command();
- char new[1024];
-
- if (! findarg(line)) {
- execute_command(line, from_tty);
- return;
- }
- expand_args(line, new);
- execute_command(new, from_tty);
-}
-
-char *
-read_one_command_line(prompt, from_tty)
- char *prompt;
-{
- register char *p, *p1;
-
- dont_repeat();
- p = command_line_input(prompt, from_tty);
-
- /* Remove trailing blanks. */
- p1 = p + strlen(p);
- while (--p1 > p && (*p1 == ' ' || *p1 == '\t'))
- ;
- *++p1 = 0;
- return (p);
-}
-
-static char cmd_prompt[] = " > ";
-
-int
-parse_control_structure(rootcmd, from_tty, level)
- struct command_line *rootcmd;
- int from_tty;
-{
- struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd));
- char *prompt;
-
- ++level;
- prompt = from_tty? &cmd_prompt[sizeof(cmd_prompt) - 1 - 2*level] :
- (char *)0;
- bzero(cmd, sizeof(*cmd));
- rootcmd->body = cmd;
- while (1) {
- char *p = read_one_command_line(prompt, from_tty);
-
- p = savestring(p, strlen(p));
- cmd->line = p;
- if (!strncmp(p, "while ", 6)) {
- cmd->type = CL_WHILE;
- if (parse_control_structure(cmd, from_tty, level))
- return (1);
- } else if (!strncmp(p, "if ", 3)) {
- cmd->type = CL_IF;
- if (parse_control_structure(cmd, from_tty, level)) {
- struct command_line *tmp;
- int stat;
-
- cmd->elsebody = cmd->body;
- stat = parse_control_structure(cmd, from_tty,
- level);
- tmp = cmd->elsebody;
- cmd->elsebody = cmd->body;
- cmd->body = tmp;
- if (stat)
- return (1);
- }
- } else if (!strcmp(p, "else")) {
- cmd->type = CL_END;
- return (1);
- } else if (!strcmp(p, "end")) {
- cmd->type = CL_END;
- return (0);
- } else if (!strcmp(p, "exitloop")) {
- cmd->type = CL_EXITLOOP;
- } else {
- cmd->type = CL_NORMAL;
- }
- cmd->next = (struct command_line *)xmalloc(sizeof(*cmd));
- cmd = cmd->next;
- bzero(cmd, sizeof(*cmd));
- }
- /* NOTREACHED */
-}
-
-int
-execute_control_structure(cmd)
- register struct command_line *cmd;
-{
- char expn[1024];
- struct expression *cond;
- int stat;
-
- while (cmd) {
- QUIT;
- switch (cmd->type) {
- case CL_END:
- return (0);
- case CL_NORMAL:
- expand_and_execute(cmd->line, 0);
- break;
- case CL_WHILE:
- expand_args(cmd->line + 6, expn);
- cond = parse_c_expression(expn);
- while (breakpoint_cond_eval(cond) == 0)
- if (execute_control_structure(cmd->body))
- break;
- free(cond);
- break;
- case CL_IF:
- expand_args(cmd->line + 3, expn);
- cond = parse_c_expression(expn);
- stat = breakpoint_cond_eval(cond);
- free(cond);
- if (stat == 0) {
- if (execute_control_structure(cmd->body))
- return (1);
- } else if (cmd->elsebody) {
- if (execute_control_structure(cmd->elsebody))
- return (1);
- }
- break;
- case CL_EXITLOOP:
- return (1);
- }
- cmd = cmd->next;
- }
- free_all_values();
-}
-
-execute_command_lines(cmd)
- struct command_line *cmd;
-{
- struct cleanup *old_chain = make_cleanup(source_cleanup, instream);
-
- /*
- * Set the instream to 0, indicating execution of a user-defined
- * function.
- */
- ++immediate_quit;
- instream = (FILE *) 0;
- (void)execute_control_structure(cmd);
- --immediate_quit;
- do_cleanups(old_chain);
-}
-
-/* do following command lines if expression true */
-if_command(p, from_tty)
- char *p;
- int from_tty;
-{
- struct cleanup *old_chain;
- struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd));
- char buf[128];
-
- sprintf(buf, "if %s", p);
-
- bzero(cmd, sizeof(*cmd));
- old_chain = make_cleanup(free_command_lines, cmd);
- cmd->type = CL_IF;
- cmd->line = savestring(buf, strlen(buf));
- /* XXX cmd->line? */
- if (parse_control_structure(cmd, from_tty, 0)) {
- struct command_line *tmp;
-
- cmd->elsebody = cmd->body;
- (void) parse_control_structure(cmd, from_tty, 0);
- tmp = cmd->elsebody;
- cmd->elsebody = cmd->body;
- cmd->body = tmp;
- }
- (void) execute_command_lines(cmd);
- do_cleanups(old_chain);
-}
-
-/* do following command lines while expression true */
-while_command(p, from_tty)
- char *p;
- int from_tty;
-{
- struct cleanup *old_chain;
- struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd));
- char buf[128];
-
- sprintf(buf, "while %s", p);
-
- bzero(cmd, sizeof(*cmd));
- old_chain = make_cleanup(free_command_lines, cmd);
- cmd->type = CL_WHILE;
- cmd->line = savestring(buf, strlen(buf));
- (void)parse_control_structure(cmd, from_tty, 0);
- (void)execute_command_lines(cmd);
- do_cleanups(old_chain);
-}
-
-/*
- * Execute the line P as a command.
- * Pass FROM_TTY as second argument to the defining function.
- */
-void
-execute_command (p, from_tty)
- char *p;
- int from_tty;
-{
- register struct cmd_list_element *c;
- register struct command_line *cmdlines;
-
- free_all_values();
- if (*p) {
- c = lookup_cmd(&p, cmdlist, "", 0, 1);
- if (c->function == 0)
- error("That is not a command, just a help topic.");
- else if (c->class == (int) class_user) {
- struct cleanup *old_chain = setup_user_args(p);
-
- cmdlines = (struct command_line *) c->function;
- if (cmdlines)
- (void)execute_command_lines(cmdlines);
-
- do_cleanups(old_chain);
- } else
- /* Pass null arg rather than an empty one. */
- (*c->function) (*p ? p : 0, from_tty);
- }
-}
-
-/*
- * Read lines from the input stream and accumulate them in a chain of struct
- * command_line's which is then returned.
- */
-struct command_line *
-read_command_lines(from_tty)
- int from_tty;
-{
- struct cleanup *old_chain;
- struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd));
- struct command_line *next;
-
- bzero(cmd, sizeof(*cmd));
- old_chain = make_cleanup(free_command_lines, cmd);
- cmd->type = CL_NOP;
- (void)parse_control_structure(cmd, from_tty, 0);
- dont_repeat();
- discard_cleanups(old_chain);
- next = cmd->body;
- free(cmd);
- return (next);
-}
-
-/* Free a chain of struct command_line's. */
-
-void
-free_command_lines(cmds)
- struct command_line *cmds;
-{
- struct command_line *next;
-
- while (cmds) {
- if (cmds->body)
- free(cmds->body);
- if (cmds->elsebody)
- free(cmds->elsebody);
- if (cmds->line)
- free(cmds->line);
- next = cmds->next;
- free(cmds);
- cmds = next;
- }
-}
-
-/* Add an element to the list of info subcommands. */
-
-void
-add_info (name, fun, doc)
- char *name;
- void (*fun) ();
- char *doc;
-{
- add_cmd (name, no_class, fun, doc, &infolist);
-}
-
-/* Add an alias to the list of info subcommands. */
-
-void
-add_info_alias (name, oldname, abbrev_flag)
- char *name;
- char *oldname;
- int abbrev_flag;
-{
- add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist);
-}
-
-/* The "info" command is defined as a prefix, with allow_unknown = 0.
- Therefore, its own definition is called only for "info" with no args. */
-
-static void
-info_command ()
-{
- printf ("\"info\" must be followed by the name of an info command.\n");
- help_list (infolist, "info ", -1, stdout);
-}
-
-/* Add an element to the list of commands. */
-
-void
-add_com (name, class, fun, doc)
- char *name;
- int class;
- void (*fun) ();
- char *doc;
-{
- add_cmd (name, class, fun, doc, &cmdlist);
-}
-
-/* Add an alias or abbreviation command to the list of commands. */
-
-void
-add_com_alias (name, oldname, class, abbrev_flag)
- char *name;
- char *oldname;
- int class;
- int abbrev_flag;
-{
- add_alias_cmd (name, oldname, class, abbrev_flag, &cmdlist);
-}
-
-void
-error_no_arg (why)
- char *why;
-{
- error ("Argument required (%s).", why);
-}
-
-static void
-help_command (command, from_tty)
- char *command;
- int from_tty; /* Ignored */
-{
- help_cmd (command, stdout);
-}
-
-static void
-validate_comname (comname)
- char *comname;
-{
- register char *p;
-
- if (comname == 0)
- error_no_arg ("name of command to define");
-
- p = comname;
- while (*p)
- {
- if (!(*p >= 'A' && *p <= 'Z')
- && !(*p >= 'a' && *p <= 'z')
- && !(*p >= '0' && *p <= '9')
- && *p != '-')
- error ("Junk in argument list: \"%s\"", p);
- p++;
- }
-}
-
-static void
-define_command (comname, from_tty)
- char *comname;
- int from_tty;
-{
- register struct command_line *cmds;
- register struct cmd_list_element *c;
- char *tem = comname;
-
- validate_comname (comname);
-
- c = lookup_cmd (&tem, cmdlist, "", -1, 1);
- if (c)
- {
- if (c->class == (int) class_user || c->class == (int) class_alias)
- tem = "Redefine command \"%s\"? ";
- else
- tem = "Really redefine built-in command \"%s\"? ";
- if (!query (tem, comname))
- error ("Command \"%s\" not redefined.", comname);
- }
-
- if (from_tty)
- {
- printf ("Type commands for definition of \"%s\".\n\
-End with a line saying just \"end\".\n", comname);
- fflush (stdout);
- }
- comname = savestring (comname, strlen (comname));
-
- cmds = read_command_lines (from_tty);
-
- if (c && c->class == (int) class_user)
- free_command_lines (c->function);
-
- add_com (comname, class_user, cmds,
- (c && c->class == (int) class_user)
- ? c->doc : savestring ("User-defined.", 13));
-}
-
-static void
-document_command (comname, from_tty)
- char *comname;
- int from_tty;
-{
- register struct cmd_list_element *c;
- register char *p;
- register char *cp;
- register char *doc = 0;
- register int len;
- char *tmp = comname;
-
- validate_comname (comname);
- c = lookup_cmd (&tmp, cmdlist, "", 0, 1);
- if (c->class != (int) class_user)
- error ("Command \"%s\" is built-in.", comname);
-
- if (from_tty)
- printf ("Type documentation for \"%s\". \
-End with a line saying just \"end\".\n", comname);
-
- while (p = read_one_command_line(from_tty? "> " : 0, from_tty))
- {
- if (strcmp(p, "end") == 0)
- break;
- len = strlen(p) + 1;
- if (! doc)
- {
- doc = xmalloc(len);
- cp = doc;
- }
- else
- {
- int i = cp - doc;
- doc = xrealloc(doc, i + len);
- cp = doc + i;
- }
- strcpy(cp, p);
- cp += len;
- cp[-1] = '\n';
- }
- if (doc && cp > doc)
- cp[-1] = 0;
- if (c->doc)
- free (c->doc);
- c->doc = doc;
-}
-
-static void
-print_gdb_version ()
-{
- printf ("GDB %s, Copyright (C) 1989 Free Software Foundation, Inc.\n\
-There is ABSOLUTELY NO WARRANTY for GDB; type \"info warranty\" for details.\n\
-GDB is free software and you are welcome to distribute copies of it\n\
- under certain conditions; type \"info copying\" to see the conditions.\n",
- version);
-}
-
-static void
-version_info ()
-{
- immediate_quit++;
- print_gdb_version ();
- immediate_quit--;
-}
-
-
-/* Command to specify a prompt string instead of "(gdb) ". */
-
-void
-set_prompt_command (text)
- char *text;
-{
- char *p, *q;
- register int c;
- char *new;
-
- if (text == 0)
- error_no_arg ("string to which to set prompt");
-
- new = (char *) xmalloc (strlen (text) + 2);
- p = text; q = new;
- while (c = *p++)
- {
- if (c == '\\')
- {
- /* \ at end of argument is used after spaces
- so they won't be lost. */
- if (*p == 0)
- break;
- c = parse_escape (&p);
- if (c == 0)
- break; /* C loses */
- else if (c > 0)
- *q++ = c;
- }
- else
- *q++ = c;
- }
- if (*(p - 1) != '\\')
- *q++ = ' ';
- *q++ = '\0';
- new = (char *) xrealloc (new, q - new);
- free (prompt);
- prompt = new;
-}
-
-static void
-quit_command ()
-{
- extern void exec_file_command ();
- if (have_inferior_p ())
- {
- if (inhibit_confirm || query ("The program is running. Quit anyway? "))
- {
- /* Prevent any warning message from reopen_exec_file, in case
- we have a core file that's inconsistent with the exec file. */
- exec_file_command (0, 0);
- kill_inferior ();
- }
- else
- error ("Not confirmed.");
- }
- /* Save the history information if it is appropriate to do so. */
- if (write_history_p && history_filename)
- write_history (history_filename);
- exit (0);
-}
-
-int
-input_from_terminal_p ()
-{
- return instream == stdin;
-}
-
-static void
-pwd_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- if (arg) error ("The \"pwd\" command does not take an argument: %s", arg);
- getwd (dirbuf);
-
- if (strcmp (dirbuf, current_directory))
- printf ("Working directory %s\n (canonically %s).\n",
- current_directory, dirbuf);
- else
- printf ("Working directory %s.\n", current_directory);
-}
-
-static void
-cd_command (dir, from_tty)
- char *dir;
- int from_tty;
-{
- int len;
- int change;
-
- if (dir == 0)
- error_no_arg ("new working directory");
-
- dir = tilde_expand (dir);
- make_cleanup (free, dir);
-
- len = strlen (dir);
- dir = savestring (dir, len - (len > 1 && dir[len-1] == '/'));
- if (dir[0] == '/')
- current_directory = dir;
- else
- {
- current_directory = concat (current_directory, "/", dir);
- free (dir);
- }
-
- /* Now simplify any occurrences of `.' and `..' in the pathname. */
-
- change = 1;
- while (change)
- {
- char *p;
- change = 0;
-
- for (p = current_directory; *p;)
- {
- if (!strncmp (p, "/./", 2)
- && (p[2] == 0 || p[2] == '/'))
- strcpy (p, p + 2);
- else if (!strncmp (p, "/..", 3)
- && (p[3] == 0 || p[3] == '/')
- && p != current_directory)
- {
- char *q = p;
- while (q != current_directory && q[-1] != '/') q--;
- if (q != current_directory)
- {
- strcpy (q-1, p+3);
- p = q-1;
- }
- }
- else p++;
- }
- }
-
- if (chdir (dir) < 0)
- perror_with_name (dir);
-
- if (from_tty)
- pwd_command ((char *) 0, 1);
-}
-
-static void
-source_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- FILE *stream;
- struct cleanup *cleanups;
- char *file = arg;
- char *path;
-
- if (file == 0)
- /* Let source without arguments read .gdbinit. */
- file = ".gdbinit";
-
- file = tilde_expand (file);
- make_cleanup (free, file);
-
-#ifdef KERNELDEBUG
- if (path = getenv(kernel_debugging? "KGDBPATH" : "GDBPATH"))
-#else
- if (path = getenv("GDBPATH"))
-#endif
- {
- int fd = openp(path, 1, file, O_RDONLY, 0, 0);
-
- if (fd == -1)
- stream = 0;
- else
- stream = fdopen(fd, "r");
- }
- else
- stream = fopen (file, "r");
-
- if (stream == 0)
- perror_with_name (file);
-
- cleanups = make_cleanup (source_cleanup, instream);
-
- instream = stream;
-
- command_loop ();
-
- do_cleanups (cleanups);
-}
-
-static void
-echo_command (text)
- char *text;
-{
- char *p = text;
- register int c;
-
- if (text)
- while (c = *p++)
- {
- if (c == '\\')
- {
- /* \ at end of argument is used after spaces
- so they won't be lost. */
- if (*p == 0)
- return;
-
- c = parse_escape (&p);
- if (c >= 0)
- fputc (c, stdout);
- }
- else
- fputc (c, stdout);
- }
- fflush(stdout);
-}
-
-static void
-dump_me_command ()
-{
- if (query ("Should GDB dump core? "))
- {
- signal (SIGQUIT, SIG_DFL);
- kill (getpid (), SIGQUIT);
- }
-}
-
-int
-parse_binary_operation (caller, arg)
- char *caller, *arg;
-{
- int length;
-
- if (!arg || !*arg)
- return 1;
-
- length = strlen (arg);
-
- while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
- length--;
-
- if (!strncmp (arg, "on", length)
- || !strncmp (arg, "1", length)
- || !strncmp (arg, "yes", length))
- return 1;
- else
- if (!strncmp (arg, "off", length)
- || !strncmp (arg, "0", length)
- || !strncmp (arg, "no", length))
- return 0;
- else
- error ("\"%s\" not given a binary valued argument.", caller);
-}
-
-/* Functions to manipulate command line editing control variables. */
-
-static void
-set_editing (arg, from_tty)
- char *arg;
- int from_tty;
-{
- command_editing_p = parse_binary_operation ("set command-editing", arg);
-}
-
-/* Number of commands to print in each call to editing_info. */
-#define Hist_print 10
-static void
-editing_info (arg, from_tty)
- char *arg;
- int from_tty;
-{
- /* Index for history commands. Relative to history_base. */
- int offset;
-
- /* Number of the history entry which we are planning to display next.
- Relative to history_base. */
- static int num = 0;
-
- /* The first command in the history which doesn't exist (i.e. one more
- than the number of the last command). Relative to history_base. */
- int hist_len;
-
- struct _hist_entry {
- char *line;
- char *data;
- } *history_get();
- extern int history_base;
-
- printf_filtered ("Interactive command editing is %s.\n",
- command_editing_p ? "on" : "off");
-
- printf_filtered ("History expansion of command input is %s.\n",
- history_expansion_p ? "on" : "off");
- printf_filtered ("Writing of a history record upon exit is %s.\n",
- write_history_p ? "enabled" : "disabled");
- printf_filtered ("The size of the history list (number of stored commands) is %d.\n",
- history_size);
- printf_filtered ("The name of the history record is \"%s\".\n\n",
- history_filename ? history_filename : "");
-
- /* Print out some of the commands from the command history. */
- /* First determine the length of the history list. */
- hist_len = history_size;
- for (offset = 0; offset < history_size; offset++)
- {
- if (!history_get (history_base + offset))
- {
- hist_len = offset;
- break;
- }
- }
-
- if (arg)
- {
- if (arg[0] == '+' && arg[1] == '\0')
- /* "info editing +" should print from the stored position. */
- ;
- else
- /* "info editing <exp>" should print around command number <exp>. */
- num = (parse_and_eval_address (arg) - history_base) - Hist_print / 2;
- }
- /* "info editing" means print the last Hist_print commands. */
- else
- {
- num = hist_len - Hist_print;
- }
-
- if (num < 0)
- num = 0;
-
- /* If there are at least Hist_print commands, we want to display the last
- Hist_print rather than, say, the last 6. */
- if (hist_len - num < Hist_print)
- {
- num = hist_len - Hist_print;
- if (num < 0)
- num = 0;
- }
-
- if (num == hist_len - Hist_print)
- printf_filtered ("The list of the last %d commands is:\n\n", Hist_print);
- else
- printf_filtered ("Some of the stored commands are:\n\n");
-
- for (offset = num; offset < num + Hist_print && offset < hist_len; offset++)
- {
- printf_filtered ("%5d %s\n", history_base + offset,
- (history_get (history_base + offset))->line);
- }
-
- /* The next command we want to display is the next one that we haven't
- displayed yet. */
- num += Hist_print;
-
- /* If the user repeats this command with return, it should do what
- "info editing +" does. This is unnecessary if arg is null,
- because "info editing +" is not useful after "info editing". */
- if (from_tty && arg)
- {
- arg[0] = '+';
- arg[1] = '\0';
- }
-}
-
-static void
-set_history_expansion (arg, from_tty)
- char *arg;
- int from_tty;
-{
- history_expansion_p = parse_binary_operation ("set history expansion", arg);
-}
-
-static void
-set_history_write (arg, from_tty)
- char *arg;
- int from_tty;
-{
- write_history_p = parse_binary_operation ("set history write", arg);
-}
-
-static void
-set_history (arg, from_tty)
- char *arg;
- int from_tty;
-{
- printf ("\"set history\" must be followed by the name of a history subcommand.\n");
- help_list (sethistlist, "set history ", -1, stdout);
-}
-
-static void
-set_history_size (arg, from_tty)
- char *arg;
- int from_tty;
-{
- if (!*arg)
- error_no_arg ("set history size");
-
- history_size = atoi (arg);
-}
-
-static void
-set_history_filename (arg, from_tty)
- char *arg;
- int from_tty;
-{
- int i;
-
- if (!arg)
- error_no_arg ("history file name");
-
- arg = tilde_expand (arg);
- make_cleanup (free, arg);
-
- i = strlen (arg) - 1;
-
- free (history_filename);
-
- while (i > 0 && (arg[i] == ' ' || arg[i] == '\t'))
- i--;
- ++i;
-
- if (!*arg)
- history_filename = (char *) 0;
- else
- history_filename = savestring (arg, i + 1);
- history_filename[i] = '\0';
-}
-
-int info_verbose;
-
-static void
-set_verbose_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- info_verbose = parse_binary_operation ("set verbose", arg);
-}
-
-static void
-verbose_info (arg, from_tty)
- char *arg;
- int from_tty;
-{
- if (arg)
- error ("\"info verbose\" does not take any arguments.\n");
-
- printf ("Verbose printing of information is %s.\n",
- info_verbose ? "on" : "off");
-}
-
-static void
-float_handler ()
-{
- error ("Invalid floating value encountered or computed.");
-}
-
-
-static void
-initialize_cmd_lists ()
-{
- cmdlist = (struct cmd_list_element *) 0;
- infolist = (struct cmd_list_element *) 0;
- enablelist = (struct cmd_list_element *) 0;
- disablelist = (struct cmd_list_element *) 0;
- deletelist = (struct cmd_list_element *) 0;
- enablebreaklist = (struct cmd_list_element *) 0;
- setlist = (struct cmd_list_element *) 0;
- sethistlist = (struct cmd_list_element *) 0;
- unsethistlist = (struct cmd_list_element *) 0;
-}
-
-static void
-initialize_main ()
-{
- char *tmpenv;
- /* Command line editing externals. */
- extern int (*rl_completion_entry_function)();
- extern char *rl_completer_word_break_characters;
- extern char *rl_readline_name;
-
- /* Set default verbose mode on. */
- info_verbose = 1;
-
-#ifdef KERNELDEBUG
- if (kernel_debugging)
- prompt = savestring ("(kgdb) ", 7);
- else
-#endif
- prompt = savestring ("(gdb) ", 6);
-
- /* Set the important stuff up for command editing. */
- command_editing_p = 1;
- history_expansion_p = 0;
- write_history_p = 0;
-
- if (tmpenv = getenv ("HISTSIZE"))
- history_size = atoi (tmpenv);
- else
- history_size = 256;
-
- stifle_history (history_size);
-
- if (tmpenv = getenv ("GDBHISTFILE"))
- history_filename = savestring (tmpenv, strlen(tmpenv));
- else
- /* We include the current directory so that if the user changes
- directories the file written will be the same as the one
- that was read. */
- history_filename = concat (current_directory, "/.gdb_history", "");
-
- read_history (history_filename);
-
- /* Setup important stuff for command line editing. */
- rl_completion_entry_function = (int (*)()) symbol_completion_function;
- rl_completer_word_break_characters = gdb_completer_word_break_characters;
- rl_readline_name = "gdb";
-
- /* Define the classes of commands.
- They will appear in the help list in the reverse of this order. */
-
- add_cmd ("obscure", class_obscure, 0, "Obscure features.", &cmdlist);
- add_cmd ("alias", class_alias, 0, "Aliases of other commands.", &cmdlist);
- add_cmd ("user", class_user, 0, "User-defined commands.\n\
-The commands in this class are those defined by the user.\n\
-Use the \"define\" command to define a command.", &cmdlist);
- add_cmd ("support", class_support, 0, "Support facilities.", &cmdlist);
- add_cmd ("status", class_info, 0, "Status inquiries.", &cmdlist);
- add_cmd ("files", class_files, 0, "Specifying and examining files.", &cmdlist);
- add_cmd ("breakpoints", class_breakpoint, 0, "Making program stop at certain points.", &cmdlist);
- add_cmd ("data", class_vars, 0, "Examining data.", &cmdlist);
- add_cmd ("stack", class_stack, 0, "Examining the stack.\n\
-The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
-counting from zero for the innermost (currently executing) frame.\n\n\
-At any time gdb identifies one frame as the \"selected\" frame.\n\
-Variable lookups are done with respect to the selected frame.\n\
-When the program being debugged stops, gdb selects the innermost frame.\n\
-The commands below can be used to select other frames by number or address.",
- &cmdlist);
- add_cmd ("running", class_run, 0, "Running the program.", &cmdlist);
-
- add_com ("pwd", class_files, pwd_command,
- "Print working directory. This is used for your program as well.");
- add_com ("cd", class_files, cd_command,
- "Set working directory to DIR for debugger and program being debugged.\n\
-The change does not take effect for the program being debugged\n\
-until the next time it is started.");
-
- add_cmd ("prompt", class_support, set_prompt_command,
- "Change gdb's prompt from the default of \"(gdb)\"",
- &setlist);
- add_com ("echo", class_support, echo_command,
- "Print a constant string. Give string as argument.\n\
-C escape sequences may be used in the argument.\n\
-No newline is added at the end of the argument;\n\
-use \"\\n\" if you want a newline to be printed.\n\
-Since leading and trailing whitespace are ignored in command arguments,\n\
-if you want to print some you must use \"\\\" before leading whitespace\n\
-to be printed or after trailing whitespace.");
- add_com ("document", class_support, document_command,
- "Document a user-defined command.\n\
-Give command name as argument. Give documentation on following lines.\n\
-End with a line of just \"end\".");
- add_com ("define", class_support, define_command,
- "Define a new command name. Command name is argument.\n\
-Definition appears on following lines, one command per line.\n\
-End with a line of just \"end\".\n\
-Use the \"document\" command to give documentation for the new command.\n\
-Commands defined in this way do not take arguments.");
-
- add_com ("source", class_support, source_command,
- "Read commands from a file named FILE.\n\
-Note that the file \".gdbinit\" is read automatically in this way\n\
-when gdb is started.");
- add_com ("quit", class_support, quit_command, "Exit gdb.");
- add_com ("help", class_support, help_command, "Print list of commands.");
- add_com_alias ("q", "quit", class_support, 1);
- add_com_alias ("h", "help", class_support, 1);
- add_com ("while", class_support, while_command,
- "execute following commands while condition is true.\n\
-Expression for condition follows \"while\" keyword.");
- add_com ("if", class_support, if_command,
- "execute following commands if condition is true.\n\
-Expression for condition follows \"if\" keyword.");
- add_cmd ("verbose", class_support, set_verbose_command,
- "Change the number of informational messages gdb prints.",
- &setlist);
- add_info ("verbose", verbose_info,
- "Status of gdb's verbose printing option.\n");
-
- add_com ("dump-me", class_obscure, dump_me_command,
- "Get fatal error; make debugger dump its core.");
-
- add_cmd ("editing", class_support, set_editing,
- "Enable or disable command line editing.\n\
-Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
-Without an argument, command line editing is enabled.", &setlist);
-
- add_prefix_cmd ("history", class_support, set_history,
- "Generic command for setting command history parameters.",
- &sethistlist, "set history ", 0, &setlist);
-
- add_cmd ("expansion", no_class, set_history_expansion,
- "Enable or disable history expansion on command input.\n\
-Without an argument, history expansion is enabled.", &sethistlist);
-
- add_cmd ("write", no_class, set_history_write,
- "Enable or disable saving of the history record on exit.\n\
-Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
-Without an argument, saving is enabled.", &sethistlist);
-
- add_cmd ("size", no_class, set_history_size,
- "Set the size of the command history, \n\
-ie. the number of previous commands to keep a record of.", &sethistlist);
-
- add_cmd ("filename", no_class, set_history_filename,
- "Set the filename in which to record the command history\n\
- (the list of previous commands of which a record is kept).", &sethistlist);
-
- add_prefix_cmd ("info", class_info, info_command,
- "Generic command for printing status.",
- &infolist, "info ", 0, &cmdlist);
- add_com_alias ("i", "info", class_info, 1);
-
- add_info ("editing", editing_info, "Status of command editor.");
-
- add_info ("version", version_info, "Report what version of GDB this is.");
-}
diff --git a/gnu/usr.bin/gdb/ngdb.i386/Makefile b/gnu/usr.bin/gdb/ngdb.i386/Makefile
deleted file mode 100644
index 3bf4c6c..0000000
--- a/gnu/usr.bin/gdb/ngdb.i386/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# %W% (Berkeley) %G%
-
-.include "../config/Makefile.$(MACHINE)"
-
-PROG= ngdb
-SRCS= i386bsd-dep.c blockframe.c
-GDBOBJS+= i386-pinsn.o \
- breakpoint.o command.o copying.o core.o \
- cplus-dem.o dbxread.o environ.o eval.o expprint.o \
- expread.o findvar.o infcmd.o inflow.o infrun.o \
- main.o obstack.o printcmd.o regex.o remote.o \
- remote-sl.o source.o stack.o symmisc.o symtab.o \
- utils.o valarith.o valops.o valprint.o values.o \
- version.o \
- funmap.o history.o keymaps.o readline.o \
- init.o
-CFLAGS+= -g -I$(.CURDIR) -I.. -I$(.CURDIR)/.. -I$(.CURDIR)/../config \
- -I/usr/src/sys.newvm \
- -DNEWVM -DHAVE_VPRINTF -DVI_MODE -DKERNELDEBUG
-# CC= /usr/old/bin/cc
-# CC= cc -traditional
-LDADD+= $(GDBOBJS:S/^/..\//g) -ltermcap
-NOMAN= noman
-
-.PATH: $(.CURDIR)/../config $(.CURDIR)/..
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gdb/obstack.c b/gnu/usr.bin/gdb/obstack.c
deleted file mode 100644
index 6f4b282..0000000
--- a/gnu/usr.bin/gdb/obstack.c
+++ /dev/null
@@ -1,313 +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 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, 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! */
-
-
-#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.
- Pick a number small enough that when rounded up to DEFAULT_ROUNDING
- it is still smaller than 4096 - 4. */
- {
- int extra = 4;
- if (extra < DEFAULT_ROUNDING)
- extra = DEFAULT_ROUNDING;
- 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;
-}
-
-/* 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;
-
- /* Compute size for new chunk. */
- new_size = (obj_size + length) << 1;
- 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 because these
- structures are aligned at least that much. */
- for (i = (obj_size + sizeof (COPYING_UNIT) - 1) / sizeof (COPYING_UNIT) - 1;
- i >= 0; i--)
- ((COPYING_UNIT *)new_chunk->contents)[i]
- = ((COPYING_UNIT *)h->object_base)[i];
-
- h->object_base = new_chunk->contents;
- h->next_free = h->object_base + obj_size;
-}
-
-/* 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;
- 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. */
-
-void
-#ifdef __STDC__
-#undef obstack_free
-obstack_free (struct obstack *h, POINTER obj)
-#else
-_obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-#endif
-{
- 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;
- while (lp != 0 && ((POINTER)lp > obj || (POINTER)(lp)->limit < obj))
- {
- plp = lp -> prev;
- (*h->freefun) (lp);
- lp = plp;
- }
- 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 ();
-}
-
-/* Let same .o link with output of gcc and other compilers. */
-
-#ifdef __STDC__
-void
-_obstack_free (h, obj)
- struct obstack *h;
- POINTER obj;
-{
- obstack_free (h, obj);
-}
-#endif
-
-#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/gdb/obstack.h b/gnu/usr.bin/gdb/obstack.h
deleted file mode 100644
index 27c017e..0000000
--- a/gnu/usr.bin/gdb/obstack.h
+++ /dev/null
@@ -1,372 +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 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, 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! */
-
-
-/* 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 "facist 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 aymbol 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 beggining of the new larger chunk. We then carry on
-accreting characters to the end of the object as we normaly 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. */
-};
-
-#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_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_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, obstack_chunk_alloc, obstack_chunk_free)
-
-#define obstack_begin(h, size) \
- _obstack_begin ((h), (size), 0, obstack_chunk_alloc, 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__)
-
-/* 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) \
- ({ struct obstack *__o = (OBSTACK); \
- (unsigned) (__o->next_free - __o->object_base); })
-
-#define obstack_room(OBSTACK) \
- ({ struct obstack *__o = (OBSTACK); \
- (unsigned) (__o->chunk_limit - __o->next_free); })
-
-#define obstack_grow(OBSTACK,where,length) \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->next_free + __len > __o->chunk_limit) \
- ? _obstack_newchunk (__o, __len) : 0); \
- bcopy (where, __o->next_free, __len); \
- __o->next_free += __len; \
- (void) 0; })
-
-#define obstack_grow0(OBSTACK,where,length) \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->next_free + __len + 1 > __o->chunk_limit) \
- ? _obstack_newchunk (__o, __len + 1) : 0), \
- bcopy (where, __o->next_free, __len), \
- __o->next_free += __len, \
- *(__o->next_free)++ = 0; \
- (void) 0; })
-
-#define obstack_1grow(OBSTACK,datum) \
-({ struct obstack *__o = (OBSTACK); \
- ((__o->next_free + 1 > __o->chunk_limit) \
- ? _obstack_newchunk (__o, 1) : 0), \
- *(__o->next_free)++ = (datum); \
- (void) 0; })
-
-#define obstack_blank(OBSTACK,length) \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- ((__o->next_free + __len > __o->chunk_limit) \
- ? _obstack_newchunk (__o, __len) : 0); \
- __o->next_free += __len; \
- (void) 0; })
-
-#define obstack_alloc(OBSTACK,length) \
-({ struct obstack *__h = (OBSTACK); \
- obstack_blank (__h, (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy(OBSTACK,where,length) \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow (__h, (where), (length)); \
- obstack_finish (__h); })
-
-#define obstack_copy0(OBSTACK,where,length) \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow0 (__h, (where), (length)); \
- obstack_finish (__h); })
-
-#define obstack_finish(OBSTACK) \
-({ struct obstack *__o = (OBSTACK); \
- void *value = (void *) __o->object_base; \
- __o->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\
- & ~ (__o->alignment_mask)); \
- ((__o->next_free - (char *)__o->chunk \
- > __o->chunk_limit - (char *)__o->chunk) \
- ? (__o->next_free = __o->chunk_limit) : 0); \
- __o->object_base = __o->next_free; \
- value; })
-
-#define obstack_free(OBSTACK, OBJ) \
-({ 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__ */
-
-/* The non-GNU macros copy the obstack-pointer into this global variable
- to avoid multiple evaluation. */
-
-extern struct obstack *_obstack;
-
-#define obstack_object_size(h) \
- (unsigned) (_obstack = (h), (h)->next_free - (h)->object_base)
-
-#define obstack_room(h) \
- (unsigned) (_obstack = (h), (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), \
- 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), \
- 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), \
- *((h)->next_free)++ = (datum))
-
-#define obstack_blank(h,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp > (h)->chunk_limit) \
- ? _obstack_newchunk ((h), (h)->temp) : 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)->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)))
-#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) \
- : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk)))
-#endif
-
-#endif /* not __GNUC__ or not __STDC__ */
-
-#endif /* not __OBSTACKS__ */
-
diff --git a/gnu/usr.bin/gdb/printcmd.c b/gnu/usr.bin/gdb/printcmd.c
deleted file mode 100644
index 6edd7bd..0000000
--- a/gnu/usr.bin/gdb/printcmd.c
+++ /dev/null
@@ -1,1867 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)printcmd.c 6.5 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Print values for GNU debugger GDB.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "frame.h"
-#include "symtab.h"
-#include "value.h"
-#include "expression.h"
-
-struct format_data
-{
- int count;
- char format;
- char size;
-};
-
-/* Last specified output format. */
-
-static char last_format = 'x';
-
-/* Last specified examination size. 'b', 'h', 'w' or `q'. */
-
-static char last_size = 'w';
-
-/* Default address to examine next. */
-
-static CORE_ADDR next_address;
-
-/* Last address examined. */
-
-static CORE_ADDR last_examine_address;
-
-/* Contents of last address examined.
- This is not valid past the end of the `x' command! */
-
-static value last_examine_value;
-
-/* Number of auto-display expression currently being displayed.
- So that we can deleted it if we get an error or a signal within it.
- -1 when not doing one. */
-
-int current_display_number;
-
-static void do_one_display ();
-
-void do_displays ();
-void print_address ();
-void print_floating ();
-void print_scalar_formatted ();
-void print_formatted_address ();
-
-
-/* Decode a format specification. *STRING_PTR should point to it.
- OFORMAT and OSIZE are used as defaults for the format and size
- if none are given in the format specification.
- If OSIZE is zero, then the size field of the returned value
- should be set only if a size is explicitly specified by the
- user.
- The structure returned describes all the data
- found in the specification. In addition, *STRING_PTR is advanced
- past the specification and past all whitespace following it. */
-
-struct format_data
-decode_format (string_ptr, oformat, osize)
- char **string_ptr;
- char oformat;
- char osize;
-{
- struct format_data val;
- register char *p = *string_ptr;
-
- val.format = '?';
- val.size = '?';
- val.count = 1;
-
- if (*p >= '0' && *p <= '9')
- val.count = atoi (p);
- while (*p >= '0' && *p <= '9') p++;
-
- /* Now process size or format letters that follow. */
-
- while (1)
- {
- if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
- val.size = *p++;
-#ifdef LONG_LONG
- else if (*p == 'l')
- {
- val.size = 'g';
- p++;
- }
-#endif
- else if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z'))
- val.format = *p++;
- else
- break;
- }
-
-#ifndef LONG_LONG
- /* Make sure 'g' size is not used on integer types.
- Well, actually, we can handle hex. */
- if (val.size == 'g' && val.format != 'f' && val.format != 'x')
- val.size = 'w';
-#endif
-
- while (*p == ' ' || *p == '\t') p++;
- *string_ptr = p;
-
- /* Set defaults for format and size if not specified. */
- if (val.format == '?')
- {
- if (val.size == '?')
- {
- /* Neither has been specified. */
- val.format = oformat;
- val.size = osize;
- }
- else
- /* If a size is specified, any format makes a reasonable
- default except 'i'. */
- val.format = oformat == 'i' ? 'x' : oformat;
- }
- else if (val.size == '?')
- switch (val.format)
- {
- case 'a':
- case 's':
- case 'A':
- /* Addresses must be words. */
- val.size = osize ? 'w' : osize;
- break;
- case 'f':
- /* Floating point has to be word or giantword. */
- if (osize == 'w' || osize == 'g')
- val.size = osize;
- else
- /* Default it to giantword if the last used size is not
- appropriate. */
- val.size = osize ? 'g' : osize;
- break;
- case 'c':
- /* Characters default to one byte. */
- val.size = osize ? 'b' : osize;
- break;
- default:
- /* The default is the size most recently specified. */
- val.size = osize;
- }
-
- return val;
-}
-
-/* Print value VAL on stdout according to FORMAT, a letter or 0.
- Do not end with a newline.
- 0 means print VAL according to its own type.
- SIZE is the letter for the size of datum being printed.
- This is used to pad hex numbers so they line up. */
-
-static void
-print_formatted (val, format, size)
- register value val;
- register char format;
- char size;
-{
- int len = TYPE_LENGTH (VALUE_TYPE (val));
-
- if (VALUE_LVAL (val) == lval_memory)
- next_address = VALUE_ADDRESS (val) + len;
-
- switch (format)
- {
- case 's':
- next_address = VALUE_ADDRESS (val)
- + value_print (value_addr (val), stdout, 0, Val_pretty_default);
- break;
-
- case 'i':
- next_address = VALUE_ADDRESS (val)
- + print_insn (VALUE_ADDRESS (val), stdout);
- break;
-
- default:
- if (format == 0
- || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY
- || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT
- || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION
- || VALUE_REPEATED (val))
- value_print (val, stdout, format, Val_pretty_default);
- else
- print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val),
- format, size, stdout);
- }
-}
-
-/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
- according to letters FORMAT and SIZE on STREAM.
- FORMAT may not be zero. Formats s and i are not supported at this level.
-
- This is how the elements of an array or structure are printed
- with a format. */
-
-void
-print_scalar_formatted (valaddr, type, format, size, stream)
- char *valaddr;
- struct type *type;
- char format;
- int size;
- FILE *stream;
-{
- LONGEST val_long;
- int len = TYPE_LENGTH (type);
-
- if (size == 'g' && sizeof (LONGEST) < 8
- && format == 'x')
- {
- /* ok, we're going to have to get fancy here. Assumption: a
- long is four bytes. */
- unsigned long v1, v2, tmp;
-
- v1 = unpack_long (builtin_type_long, valaddr);
- v2 = unpack_long (builtin_type_long, valaddr + 4);
-
-#ifdef BYTES_BIG_ENDIAN
-#else
- /* Little endian -- swap the two for printing */
- tmp = v1;
- v1 = v2;
- v2 = tmp;
-#endif
-
- switch (format)
- {
- case 'x':
- fprintf_filtered (stream, "0x%08x%08x", v1, v2);
- break;
- default:
- error ("Output size \"g\" unimplemented for format \"%c\".",
- format);
- }
- return;
- }
-
- val_long = unpack_long (type, valaddr);
-
- /* If value is unsigned, truncate it in case negative. */
- if (format != 'd')
- {
- if (len == sizeof (char))
- val_long &= (1 << 8 * sizeof(char)) - 1;
- else if (len == sizeof (short))
- val_long &= (1 << 8 * sizeof(short)) - 1;
- else if (len == sizeof (long))
- val_long &= (unsigned long) - 1;
- }
-
- switch (format)
- {
- case 'x':
-#ifdef LONG_LONG
- if (!size)
- size = (len < sizeof (long long) ? 'w' : 'g');
- switch (size)
- {
- case 'b':
- fprintf_filtered (stream, "0x%02llx", val_long);
- break;
- case 'h':
- fprintf_filtered (stream, "0x%04llx", val_long);
- break;
- case 0: /* no size specified, like in print */
- case 'w':
- fprintf_filtered (stream, "0x%08llx", val_long);
- break;
- case 'g':
- fprintf_filtered (stream, "0x%016llx", val_long);
- break;
- default:
- error ("Undefined output size \"%c\".", size);
- }
-#else
- switch (size)
- {
- case 'b':
- fprintf_filtered (stream, "0x%02x", val_long);
- break;
- case 'h':
- fprintf_filtered (stream, "0x%04x", val_long);
- break;
- case 0: /* no size specified, like in print */
- case 'w':
- fprintf_filtered (stream, "0x%08x", val_long);
- break;
- case 'g':
- fprintf_filtered (stream, "0x%o16x", val_long);
- break;
- default:
- error ("Undefined output size \"%c\".", size);
- }
-#endif /* not LONG_LONG */
- break;
-
- case 'd':
-#ifdef LONG_LONG
- fprintf_filtered (stream, "%lld", val_long);
-#else
- fprintf_filtered (stream, "%d", val_long);
-#endif
- break;
-
- case 'u':
-#ifdef LONG_LONG
- fprintf_filtered (stream, "%llu", val_long);
-#else
- fprintf_filtered (stream, "%u", val_long);
-#endif
- break;
-
- case 'o':
- if (val_long)
-#ifdef LONG_LONG
- fprintf_filtered (stream, "0%llo", val_long);
-#else
- fprintf_filtered (stream, "0%o", val_long);
-#endif
- else
- fprintf_filtered (stream, "0");
- break;
-
- case 'a':
- print_address ((CORE_ADDR) val_long, stream);
- break;
-
- case 'A':
- print_formatted_address ((CORE_ADDR) val_long, stream);
- break;
-
- case 'c':
- value_print (value_from_long (builtin_type_char, val_long), stream, 0,
- Val_pretty_default);
- break;
-
- case 'f':
- if (len == sizeof (float))
- type = builtin_type_float;
- else if (len == sizeof (double))
- type = builtin_type_double;
- print_floating(valaddr, type, stream);
- break;
-
- case 0:
- abort ();
-
- default:
- error ("Undefined output format \"%c\".", format);
- }
-}
-
-/* Print a floating point value of type TYPE, pointed to in GDB by VALADDR,
- on STREAM. */
-
-void
-print_floating(valaddr, type, stream)
- char *valaddr;
- struct type *type;
- FILE *stream;
-{
- double doub;
- int inv;
- int len = TYPE_LENGTH (type);
-
- doub = unpack_double (type, valaddr, &inv);
- if (inv)
- fprintf_filtered (stream, "Invalid float value");
- else if (doub != doub)
- {
- /* Surely it is an IEEE floating point NaN. */
-
- long low, high, *arg = (long *)valaddr; /* ASSUMED 32 BITS */
- int nonneg;
-
- if (len <= sizeof(float))
- {
- /* It's single precision. */
- low = *arg;
- nonneg = low >= 0;
- low &= 0x7fffff;
- high = 0;
- }
- else
- {
- /* It's double precision.
- Get the high and low words of the fraction.
- Distinguish big and little-endian machines. */
-#ifdef WORDS_BIG_ENDIAN
- low = arg[1], high = arg[0];
-#else
- low = arg[0], high = arg[1];
-#endif
- nonneg = high >= 0;
- high &= 0xfffff;
- }
- if (high)
- fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + nonneg, high, low);
- else
- fprintf_filtered (stream, "-NaN(0x%lx)" + nonneg, low);
- }
- else
- fprintf_filtered (stream, len <= sizeof(float) ? "%.6g" : "%.17g", doub);
-}
-
-/* Specify default address for `x' command.
- `info lines' uses this. */
-
-void
-set_next_address (addr)
- CORE_ADDR addr;
-{
- next_address = addr;
-
- /* Make address available to the user as $_. */
- set_internalvar (lookup_internalvar ("_"),
- value_from_long (builtin_type_int, (LONGEST) addr));
-}
-
-/* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM. */
-
-void
-print_address_symbolic (addr, stream)
- CORE_ADDR addr;
- FILE *stream;
-{
- register char *format;
- int name_location;
- register int i = find_pc_misc_function (addr);
-
- /* If nothing comes out, don't print anything symbolic. */
- if (i < 0) return;
- name_location = misc_function_vector[i].address;
-
- if (addr - name_location)
- format = " <%s+%d>";
- else
- format = " <%s>";
-
- fprintf_filtered (stream, format,
- misc_function_vector[i].name, addr - name_location);
-}
-
-/* Print address ADDR symbolically on STREAM.
- First print it as a number. Then perhaps print
- <SYMBOL + OFFSET> after the number. */
-
-void
-print_address (addr, stream)
- CORE_ADDR addr;
- FILE *stream;
-{
- fprintf_filtered (stream, "0x%x", addr);
- print_address_symbolic (addr, stream);
-}
-
-/* Like print_address but opnly prints symbolically. */
-
-void
-print_formatted_address (addr, stream)
- CORE_ADDR addr;
- FILE *stream;
-{
- register int i = 0;
- register char *format;
- register struct symbol *fs;
- char *name;
- int name_location;
-
- i = find_pc_partial_function (addr, &name, &name_location);
-
- /* If nothing comes out, don't print anything symbolic. */
-
- if (i == 0)
- fprintf_filtered (stream, "0x%x", addr);
- else if (addr - name_location)
- fprintf_filtered (stream, "%s+%d", name, addr - name_location);
- else
- fprintf_filtered (stream, "%s", name);
-}
-
-/* Examine data at address ADDR in format FMT.
- Fetch it from memory and print on stdout. */
-
-static void
-do_examine (fmt, addr)
- struct format_data fmt;
- CORE_ADDR addr;
-{
- register char format = 0;
- register char size;
- register int count = 1;
- struct type *val_type;
- register int i;
- register int maxelts;
-
- format = fmt.format;
- size = fmt.size;
- count = fmt.count;
- next_address = addr;
-
- /* String or instruction format implies fetch single bytes
- regardless of the specified size. */
- if (format == 's' || format == 'i')
- size = 'b';
-
- if (size == 'b')
- val_type = builtin_type_char;
- else if (size == 'h')
- val_type = builtin_type_short;
- else if (size == 'w')
- val_type = builtin_type_long;
- else if (size == 'g')
-#ifndef LONG_LONG
- val_type = builtin_type_double;
-#else
- val_type = builtin_type_long_long;
-#endif
-
- maxelts = 8;
- if (size == 'w')
- maxelts = 4;
- if (size == 'g')
- maxelts = 2;
- if (format == 's' || format == 'i')
- maxelts = 1;
-
- /* Print as many objects as specified in COUNT, at most maxelts per line,
- with the address of the next one at the start of each line. */
-
- while (count > 0)
- {
- print_address (next_address, stdout);
- printf_filtered (":");
- for (i = maxelts;
- i > 0 && count > 0;
- i--, count--)
- {
- printf_filtered ("\t");
- /* Note that print_formatted sets next_address for the next
- object. */
- last_examine_address = next_address;
- last_examine_value = value_at (val_type, next_address);
- print_formatted (last_examine_value, format, size);
- }
- printf_filtered ("\n");
- fflush (stdout);
- }
-}
-
-static void
-validate_format (fmt, cmdname)
- struct format_data fmt;
- char *cmdname;
-{
- if (fmt.size != 0)
- error ("Size letters are meaningless in \"%s\" command.", cmdname);
- if (fmt.count != 1)
- error ("Item count other than 1 is meaningless in \"%s\" command.",
- cmdname);
- if (fmt.format == 'i' || fmt.format == 's')
- error ("Format letter \"%c\" is meaningless in \"%s\" command.",
- fmt.format, cmdname);
-}
-
-static void
-print_command (exp)
- char *exp;
-{
- struct expression *expr;
- register struct cleanup *old_chain = 0;
- register char format = 0;
- register value val;
- struct format_data fmt;
- int histindex;
- int cleanup = 0;
-
- if (exp && *exp == '/')
- {
- exp++;
- fmt = decode_format (&exp, last_format, 0);
- validate_format (fmt, "print");
- last_format = format = fmt.format;
- }
-
- if (exp && *exp)
- {
- expr = parse_c_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
- cleanup = 1;
- val = evaluate_expression (expr);
- }
- else
- val = access_value_history (0);
-
- histindex = record_latest_value (val);
- if (histindex >= 0) printf_filtered ("$%d = ", histindex);
-
- print_formatted (val, format, fmt.size);
- printf_filtered ("\n");
-
- if (cleanup)
- do_cleanups (old_chain);
-}
-
-static void
-output_command (exp)
- char *exp;
-{
- struct expression *expr;
- register struct cleanup *old_chain;
- register char format = 0;
- register value val;
- struct format_data fmt;
-
- if (exp && *exp == '/')
- {
- exp++;
- fmt = decode_format (&exp, 0, 0);
- validate_format (fmt, "print");
- format = fmt.format;
- }
-
- expr = parse_c_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
-
- val = evaluate_expression (expr);
-
- print_formatted (val, format, fmt.size);
-
- do_cleanups (old_chain);
-}
-
-static void
-set_command (exp)
- char *exp;
-{
- struct expression *expr = parse_c_expression (exp);
- register struct cleanup *old_chain
- = make_cleanup (free_current_contents, &expr);
- evaluate_expression (expr);
- do_cleanups (old_chain);
-}
-
-static void
-address_info (exp)
- char *exp;
-{
- register struct symbol *sym;
- register CORE_ADDR val;
- int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero
- if exp is a field of `this'. */
-
- if (exp == 0)
- error ("Argument required.");
-
- sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE,
- &is_a_field_of_this);
- if (sym == 0)
- {
- register int i;
-
- if (is_a_field_of_this)
- {
- printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp);
- return;
- }
-
- for (i = 0; i < misc_function_count; i++)
- if (!strcmp (misc_function_vector[i].name, exp))
- break;
-
- if (i < misc_function_count)
- printf ("Symbol \"%s\" is at 0x%x in a file compiled without -g.\n",
- exp, misc_function_vector[i].address);
- else
- error ("No symbol \"%s\" in current context.", exp);
- return;
- }
-
- printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym));
- val = SYMBOL_VALUE (sym);
-
- switch (SYMBOL_CLASS (sym))
- {
- case LOC_CONST:
- case LOC_CONST_BYTES:
- printf ("constant");
- break;
-
- case LOC_LABEL:
- printf ("a label at address 0x%x", val);
- break;
-
- case LOC_REGISTER:
- printf ("a variable in register %s", reg_names[val]);
- break;
-
- case LOC_STATIC:
- printf ("static at address 0x%x", val);
- break;
-
- case LOC_REGPARM:
- printf ("an argument in register %s", reg_names[val]);
- break;
-
- case LOC_ARG:
- printf ("an argument at offset %d", val);
- break;
-
- case LOC_LOCAL:
- printf ("a local variable at frame offset %d", val);
- break;
-
- case LOC_REF_ARG:
- printf ("a reference argument at offset %d", val);
- break;
-
- case LOC_TYPEDEF:
- printf ("a typedef");
- break;
-
- case LOC_BLOCK:
- printf ("a function at address 0x%x",
- BLOCK_START (SYMBOL_BLOCK_VALUE (sym)));
- break;
- }
- printf (".\n");
-}
-
-static void
-x_command (exp, from_tty)
- char *exp;
- int from_tty;
-{
- struct expression *expr;
- struct format_data fmt;
- struct cleanup *old_chain;
- struct value *val;
-
- fmt.format = last_format;
- fmt.size = last_size;
- fmt.count = 1;
-
- if (exp && *exp == '/')
- {
- exp++;
- fmt = decode_format (&exp, last_format, last_size);
- last_size = fmt.size;
- last_format = fmt.format;
- }
-
- /* If we have an expression, evaluate it and use it as the address. */
-
- if (exp != 0 && *exp != 0)
- {
- expr = parse_c_expression (exp);
- /* Cause expression not to be there any more
- if this command is repeated with Newline.
- But don't clobber a user-defined command's definition. */
- if (from_tty)
- *exp = 0;
- old_chain = make_cleanup (free_current_contents, &expr);
- val = evaluate_expression (expr);
- /* In rvalue contexts, such as this, functions are coerced into
- pointers to functions. This makes "x/i main" work. */
- if (/* last_format == 'i'
- && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC
- && VALUE_LVAL (val) == lval_memory)
- next_address = VALUE_ADDRESS (val);
- else
- next_address = (CORE_ADDR) value_as_long (val);
- do_cleanups (old_chain);
- }
-
- do_examine (fmt, next_address);
-
- /* Set a couple of internal variables if appropriate. */
- if (last_examine_value)
- {
- /* Make last address examined available to the user as $_. */
- set_internalvar (lookup_internalvar ("_"),
- value_from_long (builtin_type_int,
- (LONGEST) last_examine_address));
-
- /* Make contents of last address examined available to the user as $__.*/
- set_internalvar (lookup_internalvar ("__"), last_examine_value);
- }
-}
-
-/* Commands for printing types of things. */
-
-static void
-whatis_command (exp)
- char *exp;
-{
- struct expression *expr;
- register value val;
- register struct cleanup *old_chain;
-
- if (exp)
- {
- expr = parse_c_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
- val = evaluate_type (expr);
- }
- else
- val = access_value_history (0);
-
- printf_filtered ("type = ");
- /* Most of the time users do not want to see all the fields
- in a structure. If they do they can use the "ptype" command.
- Hence the "-1" below. */
- type_print (VALUE_TYPE (val), "", stdout, -1);
- printf_filtered ("\n");
-
- if (exp)
- do_cleanups (old_chain);
-}
-
-static void
-ptype_command (typename)
- char *typename;
-{
- register char *p = typename;
- register int len;
- extern struct block *get_current_block ();
- register struct block *b
- = (have_inferior_p () || have_core_file_p ()) ? get_current_block () : 0;
- register struct type *type;
-
- if (typename == 0)
- error_no_arg ("type name");
-
- while (*p && *p != ' ' && *p != '\t') p++;
- len = p - typename;
- while (*p == ' ' || *p == '\t') p++;
-
- if (len == 6 && !strncmp (typename, "struct", 6))
- type = lookup_struct (p, b);
- else if (len == 5 && !strncmp (typename, "union", 5))
- type = lookup_union (p, b);
- else if (len == 4 && !strncmp (typename, "enum", 4))
- type = lookup_enum (p, b);
- else
- {
- type = lookup_typename (typename, b, 1);
- if (type == 0)
- {
- register struct symbol *sym
- = lookup_symbol (typename, b, STRUCT_NAMESPACE, 0);
- if (sym == 0)
- error ("No type named %s.", typename);
- printf_filtered ("No type named %s, but there is a ",
- typename);
- switch (TYPE_CODE (SYMBOL_TYPE (sym)))
- {
- case TYPE_CODE_STRUCT:
- printf_filtered ("struct");
- break;
-
- case TYPE_CODE_UNION:
- printf_filtered ("union");
- break;
-
- case TYPE_CODE_ENUM:
- printf_filtered ("enum");
- }
- printf_filtered (" %s. Type \"help ptype\".\n", typename);
- type = SYMBOL_TYPE (sym);
- }
- }
-
- type_print (type, "", stdout, 1);
- printf_filtered ("\n");
-}
-
-enum display_status {disabled, enabled};
-
-struct display
-{
- /* Chain link to next auto-display item. */
- struct display *next;
- /* Expression to be evaluated and displayed. */
- struct expression *exp;
- /* Item number of this auto-display item. */
- int number;
- /* Display format specified. */
- struct format_data format;
- /* Innermost block required by this expression when evaluated */
- struct block *block;
- /* Status of this display (enabled or disabled) */
- enum display_status status;
-};
-
-/* Chain of expressions whose values should be displayed
- automatically each time the program stops. */
-
-static struct display *display_chain;
-
-static int display_number;
-
-/* Add an expression to the auto-display chain.
- Specify the expression. */
-
-static void
-display_command (exp, from_tty)
- char *exp;
- int from_tty;
-{
- struct format_data fmt;
- register struct expression *expr;
- register struct display *new;
- extern struct block *innermost_block;
-
- if (exp == 0)
- {
- do_displays ();
- return;
- }
-
- if (*exp == '/')
- {
- exp++;
- fmt = decode_format (&exp, 0, 0);
- if (fmt.size && fmt.format == 0)
- fmt.format = 'x';
- if (fmt.format == 'i' || fmt.format == 's')
- fmt.size = 'b';
- }
- else
- {
- fmt.format = 0;
- fmt.size = 0;
- fmt.count = 0;
- }
-
- innermost_block = 0;
- expr = parse_c_expression (exp);
-
- new = (struct display *) xmalloc (sizeof (struct display));
-
- new->exp = expr;
- new->block = innermost_block;
- new->next = display_chain;
- new->number = ++display_number;
- new->format = fmt;
- new->status = enabled;
- display_chain = new;
-
- if (from_tty && have_inferior_p ())
- do_one_display (new);
-
- dont_repeat ();
-}
-
-static void
-free_display (d)
- struct display *d;
-{
- free (d->exp);
- free (d);
-}
-
-/* Clear out the display_chain.
- Done when new symtabs are loaded, since this invalidates
- the types stored in many expressions. */
-
-void
-clear_displays ()
-{
- register struct display *d;
-
- while (d = display_chain)
- {
- free (d->exp);
- display_chain = d->next;
- free (d);
- }
-}
-
-/* Delete the auto-display number NUM. */
-
-void
-delete_display (num)
- int num;
-{
- register struct display *d1, *d;
-
- if (!display_chain)
- error ("No display number %d.", num);
-
- if (display_chain->number == num)
- {
- d1 = display_chain;
- display_chain = d1->next;
- free_display (d1);
- }
- else
- for (d = display_chain; ; d = d->next)
- {
- if (d->next == 0)
- error ("No display number %d.", num);
- if (d->next->number == num)
- {
- d1 = d->next;
- d->next = d1->next;
- free_display (d1);
- break;
- }
- }
-}
-
-/* Delete some values from the auto-display chain.
- Specify the element numbers. */
-
-static void
-undisplay_command (args)
- char *args;
-{
- register char *p = args;
- register char *p1;
- register int num;
- register struct display *d, *d1;
-
- if (args == 0)
- {
- if (query ("Delete all auto-display expressions? "))
- clear_displays ();
- dont_repeat ();
- return;
- }
-
- while (*p)
- {
- p1 = p;
- while (*p1 >= '0' && *p1 <= '9') p1++;
- if (*p1 && *p1 != ' ' && *p1 != '\t')
- error ("Arguments must be display numbers.");
-
- num = atoi (p);
-
- delete_display (num);
-
- p = p1;
- while (*p == ' ' || *p == '\t') p++;
- }
- dont_repeat ();
-}
-
-/* Display a single auto-display.
- Do nothing if the display cannot be printed in the current context,
- or if the display is disabled. */
-
-static void
-do_one_display (d)
- struct display *d;
-{
- int within_current_scope;
-
- if (d->status == disabled)
- return;
-
- if (d->block)
- within_current_scope = contained_in (get_selected_block (), d->block);
- else
- within_current_scope = 1;
- if (!within_current_scope)
- return;
-
- current_display_number = d->number;
-
- printf_filtered ("%d: ", d->number);
- if (d->format.size)
- {
- printf_filtered ("x/");
- if (d->format.count != 1)
- printf_filtered ("%d", d->format.count);
- printf_filtered ("%c", d->format.format);
- if (d->format.format != 'i' && d->format.format != 's')
- printf_filtered ("%c", d->format.size);
- printf_filtered (" ");
- print_expression (d->exp, stdout);
- if (d->format.count != 1)
- printf_filtered ("\n");
- else
- printf_filtered (" ");
- do_examine (d->format,
- (CORE_ADDR) value_as_long (evaluate_expression (d->exp)));
-
- }
- else
- {
- if (d->format.format)
- printf_filtered ("/%c ", d->format.format);
- print_expression (d->exp, stdout);
- printf_filtered (" = ");
- print_formatted (evaluate_expression (d->exp),
- d->format.format, d->format.size);
- printf_filtered ("\n");
- }
-
- fflush (stdout);
- current_display_number = -1;
-}
-
-/* Display all of the values on the auto-display chain which can be
- evaluated in the current scope. */
-
-void
-do_displays ()
-{
- register struct display *d;
-
- for (d = display_chain; d; d = d->next)
- do_one_display (d);
-}
-
-/* Delete the auto-display which we were in the process of displaying.
- This is done when there is an error or a signal. */
-
-void
-disable_display (num)
- int num;
-{
- register struct display *d;
-
- for (d = display_chain; d; d = d->next)
- if (d->number == num)
- {
- d->status = disabled;
- return;
- }
- printf ("No display number %d.\n", num);
-}
-
-void
-disable_current_display ()
-{
- if (current_display_number >= 0)
- {
- disable_display (current_display_number);
- fprintf (stderr, "Disabling display %d to avoid infinite recursion.\n",
- current_display_number);
- }
- current_display_number = -1;
-}
-
-static void
-display_info ()
-{
- register struct display *d;
-
- if (!display_chain)
- printf ("There are no auto-display expressions now.\n");
- else
- printf_filtered ("Auto-display expressions now in effect:\n\
-Num Enb Expression\n");
-
- for (d = display_chain; d; d = d->next)
- {
- printf_filtered ("%d: %c ", d->number, "ny"[(int)d->status]);
- if (d->format.size)
- printf_filtered ("/%d%c%c ", d->format.count, d->format.size,
- d->format.format);
- else if (d->format.format)
- printf_filtered ("/%c ", d->format.format);
- print_expression (d->exp, stdout);
- if (d->block && !contained_in (get_selected_block (), d->block))
- printf_filtered (" (cannot be evaluated in the current context)");
- printf_filtered ("\n");
- fflush (stdout);
- }
-}
-
-void
-enable_display (args)
- char *args;
-{
- register char *p = args;
- register char *p1;
- register int num;
- register struct display *d;
-
- if (p == 0)
- {
- for (d = display_chain; d; d = d->next)
- d->status = enabled;
- }
- else
- while (*p)
- {
- p1 = p;
- while (*p1 >= '0' && *p1 <= '9')
- p1++;
- if (*p1 && *p1 != ' ' && *p1 != '\t')
- error ("Arguments must be display numbers.");
-
- num = atoi (p);
-
- for (d = display_chain; d; d = d->next)
- if (d->number == num)
- {
- d->status = enabled;
- goto win;
- }
- printf ("No display number %d.\n", num);
- win:
- p = p1;
- while (*p == ' ' || *p == '\t')
- p++;
- }
-}
-
-void
-disable_display_command (args, from_tty)
- char *args;
- int from_tty;
-{
- register char *p = args;
- register char *p1;
- register int num;
- register struct display *d;
-
- if (p == 0)
- {
- for (d = display_chain; d; d = d->next)
- d->status = disabled;
- }
- else
- while (*p)
- {
- p1 = p;
- while (*p1 >= '0' && *p1 <= '9')
- p1++;
- if (*p1 && *p1 != ' ' && *p1 != '\t')
- error ("Arguments must be display numbers.");
-
- num = atoi (p);
-
- disable_display (atoi (p));
-
- p = p1;
- while (*p == ' ' || *p == '\t')
- p++;
- }
-}
-
-
-/* Print the value in stack frame FRAME of a variable
- specified by a struct symbol. */
-
-void
-print_variable_value (var, frame, stream)
- struct symbol *var;
- FRAME frame;
- FILE *stream;
-{
- value val = read_var_value (var, frame);
- value_print (val, stream, 0, Val_pretty_default);
-}
-
-static int
-compare_ints (i, j)
- int *i, *j;
-{
- return *i - *j;
-}
-
-/* Print the arguments of a stack frame, given the function FUNC
- running in that frame (as a symbol), the info on the frame,
- and the number of args according to the stack frame (or -1 if unknown). */
-
-static void print_frame_nameless_args ();
-
-void
-print_frame_args (func, fi, num, stream)
- struct symbol *func;
- struct frame_info *fi;
- int num;
- FILE *stream;
-{
- struct block *b;
- int nsyms = 0;
- int first = 1;
- register int i;
- register int last_regparm = 0;
- register struct symbol *lastsym, *sym, *nextsym;
- register value val;
- /* Offset of stack argument that is at the highest offset.
- -1 if we haven't come to a stack argument yet. */
- CORE_ADDR highest_offset = (CORE_ADDR) -1;
- register CORE_ADDR addr = FRAME_ARGS_ADDRESS (fi);
-
- if (func)
- {
- b = SYMBOL_BLOCK_VALUE (func);
- nsyms = BLOCK_NSYMS (b);
- }
-
- for (i = 0; i < nsyms; i++)
- {
- QUIT;
- sym = BLOCK_SYM (b, i);
-
- if (SYMBOL_CLASS (sym) != LOC_REGPARM
- && SYMBOL_CLASS (sym) != LOC_ARG
- && SYMBOL_CLASS (sym) != LOC_REF_ARG)
- continue;
-
- /* Print the next arg. */
- if (SYMBOL_CLASS (sym) == LOC_REGPARM)
- val = value_from_register (SYMBOL_TYPE (sym),
- SYMBOL_VALUE (sym),
- FRAME_INFO_ID (fi));
- else
- {
- int current_offset = SYMBOL_VALUE (sym);
- int arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
-
- if (SYMBOL_CLASS (sym) == LOC_REF_ARG)
- val = value_at (SYMBOL_TYPE (sym),
- read_memory_integer (addr + current_offset,
- sizeof (CORE_ADDR)));
- else
- val = value_at (SYMBOL_TYPE (sym), addr + current_offset);
-
- /* Round up address of next arg to multiple of size of int. */
- current_offset
- = (((current_offset + sizeof (int) - 1) / sizeof (int))
- * sizeof (int));
-
- /* If this is the highest offset seen yet, set highest_offset. */
- if (highest_offset == (CORE_ADDR)-1
- || ((current_offset
- + (arg_size - sizeof (int) + 3) / (sizeof (int)))
- > highest_offset))
- highest_offset = current_offset;
- }
-
- if (! first)
- fprintf_filtered (stream, ", ");
- fputs_filtered (SYMBOL_NAME (sym), stream);
- fputs_filtered ("=", stream);
-
-/* Nonzero if a LOC_ARG which is a struct is useless. */
-#if !defined (STRUCT_ARG_SYM_GARBAGE)
-#define STRUCT_ARG_SYM_GARBAGE(gcc_p) 0
-#endif
-
- if (STRUCT_ARG_SYM_GARBAGE (b->gcc_compile_flag)
- && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
- && SYMBOL_CLASS (sym) == LOC_ARG)
- {
- /* Try looking up that name. SunOS4 puts out a usable
- symbol as a local variable (in addition to the one
- for the arg). */
- struct symbol *sym2 =
- lookup_symbol (SYMBOL_NAME (sym), b, VAR_NAMESPACE, 0);
-
- if (sym2 != NULL)
- val = value_of_variable (sym2);
- else
- {
- fputs_filtered ("?", stream);
- first = 0;
- continue;
- }
- }
-
- value_print (val, stream, 0, Val_no_prettyprint);
- first = 0;
- }
-
- /* Don't print nameless args in situations where we don't know
- enough about the stack to find them. */
- if (num != -1)
- {
- if (highest_offset != (CORE_ADDR) -1
- && num * sizeof (int) + FRAME_ARGS_SKIP > highest_offset)
- print_frame_nameless_args (fi, addr,
- highest_offset + sizeof (int),
- num * sizeof (int) + FRAME_ARGS_SKIP,
- stream);
- else
- print_frame_nameless_args (fi, addr, FRAME_ARGS_SKIP,
- num * sizeof (int) + FRAME_ARGS_SKIP,
- stream);
- }
-}
-
-static void
-print_frame_nameless_args (fi, argsaddr, start, end, stream)
- struct frame_info *fi;
- CORE_ADDR argsaddr;
- int start;
- int end;
- FILE *stream;
-{
- extern void (*default_scalar_print)();
- LONGEST v;
- int p = start;
- char *s = "";
-
- for (p = start; p < end; p += sizeof(int)) {
- QUIT;
-#if defined(NAMELESS_ARG)
- v = NAMELESS_ARG(fi, (p - start) / sizeof(int));
-#else
- v = read_memory_integer (argsaddr + p, sizeof (int));
-#endif
- fprintf_filtered (stream, s);
- s = ", ";
- (*default_scalar_print) (stream, builtin_type_int, v);
- }
-}
-
-static void
-printf_command (arg)
- char *arg;
-{
- register char *f;
- register char *s = arg;
- char *string;
- value *val_args;
- int nargs = 0;
- int allocated_args = 20;
- char *arg_bytes;
-
- val_args = (value *) xmalloc (allocated_args * sizeof (value));
-
- if (s == 0)
- error_no_arg ("format-control string and values to print");
-
- /* Skip white space before format string */
- while (*s == ' ' || *s == '\t') s++;
-
- /* A format string should follow, enveloped in double quotes */
- if (*s++ != '"')
- error ("Bad format string, missing '\"'.");
-
- /* Parse the format-control string and copy it into the string STRING,
- processing some kinds of escape sequence. */
-
- f = string = (char *) alloca (strlen (s) + 1);
- while (*s != '"')
- {
- int c = *s++;
- switch (c)
- {
- case '\0':
- error ("Bad format string, non-terminated '\"'.");
- /* doesn't return */
-
- case '\\':
- switch (c = *s++)
- {
- case '\\':
- *f++ = '\\';
- break;
- case 'n':
- *f++ = '\n';
- break;
- case 't':
- *f++ = '\t';
- break;
- case 'r':
- *f++ = '\r';
- break;
- case '"':
- *f++ = '"';
- break;
- default:
- /* ??? TODO: handle other escape sequences */
- error ("Unrecognized \\ escape character in format string.");
- }
- break;
-
- default:
- *f++ = c;
- }
- }
-
- /* Skip over " and following space and comma. */
- s++;
- *f++ = '\0';
- while (*s == ' ' || *s == '\t') s++;
-
- if (*s != ',' && *s != 0)
- error ("Invalid argument syntax");
-
- if (*s == ',') s++;
- while (*s == ' ' || *s == '\t') s++;
-
- {
- /* Now scan the string for %-specs and see what kinds of args they want.
- argclass[I] classifies the %-specs so we can give vprintf something
- of the right size. */
-
- enum argclass {int_arg, string_arg, double_arg, long_long_arg};
- enum argclass *argclass;
- int nargs_wanted;
- int argindex;
- int lcount;
- int i;
-
- argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass);
- nargs_wanted = 0;
- f = string;
- while (*f)
- if (*f++ == '%')
- {
- lcount = 0;
- while (index ("0123456789.hlL-+ #", *f))
- {
- if (*f == 'l' || *f == 'L')
- lcount++;
- f++;
- }
- if (*f == 's')
- argclass[nargs_wanted++] = string_arg;
- else if (*f == 'e' || *f == 'f' || *f == 'g')
- argclass[nargs_wanted++] = double_arg;
- else if (lcount > 1)
- argclass[nargs_wanted++] = long_long_arg;
- else if (*f != '%')
- argclass[nargs_wanted++] = int_arg;
- f++;
- }
-
- /* Now, parse all arguments and evaluate them.
- Store the VALUEs in VAL_ARGS. */
-
- while (*s != '\0')
- {
- char *s1;
- if (nargs == allocated_args)
- val_args = (value *) xrealloc (val_args,
- (allocated_args *= 2)
- * sizeof (value));
- s1 = s;
- val_args[nargs] = parse_to_comma_and_eval (&s1);
-
- /* If format string wants a float, unchecked-convert the value to
- floating point of the same size */
-
- if (argclass[nargs] == double_arg)
- {
- if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (float))
- VALUE_TYPE (val_args[nargs]) = builtin_type_float;
- if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (double))
- VALUE_TYPE (val_args[nargs]) = builtin_type_double;
- }
- nargs++;
- s = s1;
- if (*s == ',')
- s++;
- }
-
- if (nargs != nargs_wanted)
- error ("Wrong number of arguments for specified format-string");
-
- /* Now lay out an argument-list containing the arguments
- as doubles, integers and C pointers. */
-
- arg_bytes = (char *) alloca (sizeof (double) * nargs);
- argindex = 0;
- for (i = 0; i < nargs; i++)
- {
- if (argclass[i] == string_arg)
- {
- char *str;
- int tem, j;
- tem = value_as_long (val_args[i]);
-
- /* This is a %s argument. Find the length of the string. */
- for (j = 0; ; j++)
- {
- char c;
- QUIT;
- read_memory (tem + j, &c, 1);
- if (c == 0)
- break;
- }
-
- /* Copy the string contents into a string inside GDB. */
- str = (char *) alloca (j + 1);
- read_memory (tem, str, j);
- str[j] = 0;
-
- /* Pass address of internal copy as the arg to vprintf. */
- *((int *) &arg_bytes[argindex]) = (int) str;
- argindex += sizeof (int);
- }
- else if (VALUE_TYPE (val_args[i])->code == TYPE_CODE_FLT)
- {
- *((double *) &arg_bytes[argindex]) = value_as_double (val_args[i]);
- argindex += sizeof (double);
- }
- else
-#ifdef LONG_LONG
- if (argclass[i] == long_long_arg)
- {
- *(long long *) &arg_bytes[argindex] = value_as_long (val_args[i]);
- argindex += sizeof (long long);
- }
- else
-#endif
- {
- *((int *) &arg_bytes[argindex]) = value_as_long (val_args[i]);
- argindex += sizeof (int);
- }
- }
- }
- vprintf (string, arg_bytes);
-}
-
-/* Helper function for asdump_command. Finds the bounds of a function
- for a specified section of text. PC is an address within the
- function which you want bounds for; *LOW and *HIGH are set to the
- beginning (inclusive) and end (exclusive) of the function. This
- function returns 1 on success and 0 on failure. */
-
-static int
-containing_function_bounds (pc, low, high)
- CORE_ADDR pc, *low, *high;
-{
- int scan;
-
- if (!find_pc_partial_function (pc, 0, low))
- return 0;
-
- scan = *low;
- do {
- scan++;
- if (!find_pc_partial_function (scan, 0, high))
- return 0;
- } while (*low == *high);
-
- return 1;
-}
-
-/* Dump a specified section of assembly code. With no command line
- arguments, this command will dump the assembly code for the
- function surrounding the pc value in the selected frame. With one
- argument, it will dump the assembly code surrounding that pc value.
- Two arguments are interpeted as bounds within which to dump
- assembly. */
-
-static void
-disassemble_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- CORE_ADDR low, high;
- CORE_ADDR pc;
- char *space_index;
-
- if (!arg)
- {
- if (!selected_frame)
- error ("No frame selected.\n");
-
- pc = get_frame_pc (selected_frame);
- if (!containing_function_bounds (pc, &low, &high))
- error ("No function contains pc specified by selected frame.\n");
- }
- else if (!(space_index = (char *) index (arg, ' ')))
- {
- /* One argument. */
- pc = parse_and_eval_address (arg);
- if (!containing_function_bounds (pc, &low, &high))
- error ("No function contains specified pc.\n");
- }
- else
- {
- /* Two arguments. */
- *space_index = '\0';
- low = parse_and_eval_address (arg);
- high = parse_and_eval_address (space_index + 1);
- }
-
- printf_filtered ("Dump of assembler code ");
- if (!space_index)
- {
- char *name;
- find_pc_partial_function (pc, &name, 0);
- printf_filtered ("for function %s:\n", name);
- }
- else
- printf_filtered ("from 0x%x to 0x%x:\n", low, high);
-
- /* Dump the specified range. */
- for (pc = low; pc < high; )
- {
- QUIT;
- print_address (pc, stdout);
- printf_filtered (":\t");
- pc += print_insn (pc, stdout);
- printf_filtered ("\n");
- }
- printf_filtered ("End of assembler dump.\n");
- fflush (stdout);
-}
-
-
-extern struct cmd_list_element *enablelist, *disablelist, *deletelist;
-extern struct cmd_list_element *cmdlist, *setlist;
-
-void
-_initialize_printcmd ()
-{
- current_display_number = -1;
-
- add_info ("address", address_info,
- "Describe where variable VAR is stored.");
-
- add_com ("x", class_vars, x_command,
- "Examine memory: x/FMT ADDRESS.\n\
-ADDRESS is an expression for the memory address to examine.\n\
-FMT is a repeat count followed by a format letter and a size letter.\n\
-Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
- f(float), a(address), i(instruction), c(char) and s(string).\n\
-Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
- g is meaningful only with f, for type double.\n\
-The specified number of objects of the specified size are printed\n\
-according to the format.\n\n\
-Defaults for format and size letters are those previously used.\n\
-Default count is 1. Default address is following last thing printed\n\
-with this command or \"print\".");
-
- add_com ("disassemble", class_vars, disassemble_command,
- "Disassemble a specified section of memory.\n\
-Default is the function surrounding the pc of the selected frame.\n\
-With a single argument, the function surrounding that address is dumped.\n\
-Two arguments are taken as a range of memory to dump.");
-
- add_com ("ptype", class_vars, ptype_command,
- "Print definition of type TYPE.\n\
-Argument may be a type name defined by typedef, or \"struct STRUCTNAME\"\n\
-or \"union UNIONNAME\" or \"enum ENUMNAME\".\n\
-The selected stack frame's lexical context is used to look up the name.");
-
- add_com ("whatis", class_vars, whatis_command,
- "Print data type of expression EXP.");
-
- add_info ("display", display_info,
- "Expressions to display when program stops, with code numbers.");
-
- add_cmd ("undisplay", class_vars, undisplay_command,
- "Cancel some expressions to be displayed when program stops.\n\
-Arguments are the code numbers of the expressions to stop displaying.\n\
-No argument means cancel all automatic-display expressions.\n\
-\"delete display\" has the same effect as this command.\n\
-Do \"info display\" to see current list of code numbers.",
- &cmdlist);
-
- add_com ("display", class_vars, display_command,
- "Print value of expression EXP each time the program stops.\n\
-/FMT may be used before EXP as in the \"print\" command.\n\
-/FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
-as in the \"x\" command, and then EXP is used to get the address to examine\n\
-and examining is done as in the \"x\" command.\n\n\
-With no argument, display all currently requested auto-display expressions.\n\
-Use \"undisplay\" to cancel display requests previously made.");
-
- add_cmd ("display", class_vars, enable_display,
- "Enable some expressions to be displayed when program stops.\n\
-Arguments are the code numbers of the expressions to resume displaying.\n\
-No argument means enable all automatic-display expressions.\n\
-Do \"info display\" to see current list of code numbers.", &enablelist);
-
- add_cmd ("display", class_vars, disable_display_command,
- "Disable some expressions to be displayed when program stops.\n\
-Arguments are the code numbers of the expressions to stop displaying.\n\
-No argument means disable all automatic-display expressions.\n\
-Do \"info display\" to see current list of code numbers.", &disablelist);
-
- add_cmd ("display", class_vars, undisplay_command,
- "Cancel some expressions to be displayed when program stops.\n\
-Arguments are the code numbers of the expressions to stop displaying.\n\
-No argument means cancel all automatic-display expressions.\n\
-Do \"info display\" to see current list of code numbers.", &deletelist);
-
- add_com ("printf", class_vars, printf_command,
- "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
-This is useful for formatted output in user-defined commands.");
- add_com ("output", class_vars, output_command,
- "Like \"print\" but don't put in value history and don't print newline.\n\
-This is useful in user-defined commands.");
-
- add_prefix_cmd ("set", class_vars, set_command,
-"Perform an assignment VAR = EXP.\n\
-You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\
-(names starting with $), a register (a few standard names starting with $),\n\
-or an actual variable in the program being debugged. EXP is any expression.\n\
-Use \"set variable\" for variables with names identical to set subcommands.\n\
-\nWith a subcommand, this command modifies parts of the gdb environment",
- &setlist, "set ", 1, &cmdlist);
-
- add_cmd ("variable", class_vars, set_command,
- "Perform an assignment VAR = EXP.\n\
-You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\
-(names starting with $), a register (a few standard names starting with $),\n\
-or an actual variable in the program being debugged. EXP is any expression.\n\
-This may usually be abbreviated to simply \"set\".",
- &setlist);
-
- add_com ("print", class_vars, print_command,
- concat ("Print value of expression EXP.\n\
-Variables accessible are those of the lexical environment of the selected\n\
-stack frame, plus all those whose scope is global or an entire file.\n\
-\n\
-$NUM gets previous value number NUM. $ and $$ are the last two values.\n\
-$$NUM refers to NUM'th value back from the last one.\n\
-Names starting with $ refer to registers (with the values they would have\n\
-if the program were to return to the stack frame now selected, restoring\n\
-all registers saved by frames farther in) or else to debugger\n\
-\"convenience\" variables (any such name not a known register).\n\
-Use assignment expressions to give values to convenience variables.\n",
- "\n\
-\{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
-@ is a binary operator for treating consecutive data objects\n\
-anywhere in memory as an array. FOO@NUM gives an array whose first\n\
-element is FOO, whose second element is stored in the space following\n\
-where FOO is stored, etc. FOO must be an expression whose value\n\
-resides in memory.\n",
- "\n\
-EXP may be preceded with /FMT, where FMT is a format letter\n\
-but no count or size letter (see \"x\" command)."));
- add_com_alias ("p", "print", class_vars, 1);
-}
diff --git a/gnu/usr.bin/gdb/readline/ChangeLog b/gnu/usr.bin/gdb/readline/ChangeLog
deleted file mode 100644
index b72a59d..0000000
--- a/gnu/usr.bin/gdb/readline/ChangeLog
+++ /dev/null
@@ -1,98 +0,0 @@
-Thu Feb 8 01:04:00 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * Makefile (the *other* libreadline.a): Uncomment out ranlib line.
-
-Thu Feb 1 17:50:22 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
-
- * Makefile (libreadline.a): Uncomment out ranlib line.
-
-Sun Nov 26 16:29:11 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * readline.c (rl_deprep_terminal): Only restore local_mode_flags
- if they had been set.
-
-Thu Oct 19 17:18:40 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * Move vi_doing_insert from vi_mode.c to readline.c
-
- * readline.c: Move compare_strings before its use.
- Remove declarations.
-
- * readline.c: Move defining_kbd_macro above rl_dispatch.
- (rl_dispatch): Remove "extern int defining_kbd_macro".
-
-Mon Oct 16 11:56:03 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * readline.c (rl_set_signals): Remove unnecessary "static int
- rl_signal_handler()".
-
-Sat Sep 30 14:51:56 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
-
- * readline.c (rl_initialize): Change parsing_conditionalized_out
- to static.
- (rl_dispatch): Change defining_kbd_macro to static.
- (rl_newline): Change vi_doing_insert to static.
-
-Fri Sep 8 09:00:45 1989 Brian Fox (bfox at aurel)
-
- * readline.c: rl_prep_terminal (). Only turn on 8th bit
- as meta-bit iff the terminal is not using parity.
-
-Sun Sep 3 08:57:40 1989 Brian Fox (bfox at aurel)
-
- * readline.c: start_insert (). Uses multiple
- insertion call in cases where that makes sense.
-
- rl_insert (). Read type-ahead buffer for additional
- keys that are bound to rl_insert, and insert them
- all at once. Make insertion of single keys given
- with an argument much more efficient.
-
-Tue Aug 8 18:13:57 1989 Brian Fox (bfox at aurel)
-
- * readline.c: Changed handling of EOF. readline () returns
- (char *)EOF or consed string. The EOF character is read from the
- tty, or if the tty doesn't have one, defaults to C-d.
-
- * readline.c: Added support for event driven programs.
- rl_event_hook is the address of a function you want called
- while Readline is waiting for input.
-
- * readline.c: Cleanup time. Functions without type declarations
- do not use return with a value.
-
- * history.c: history_expand () has new variable which is the
- characters to ignore immediately following history_expansion_char.
-
-Sun Jul 16 08:14:00 1989 Brian Fox (bfox at aurel)
-
- * rl_prep_terminal ()
- BSD version turns off C-s, C-q, C-y, C-v.
-
- * readline.c -- rl_prep_terminal ()
- SYSV version hacks readline_echoing_p.
- BSD version turns on passing of the 8th bit for the duration
- of reading the line.
-
-Tue Jul 11 06:25:01 1989 Brian Fox (bfox at aurel)
-
- * readline.c: new variable rl_tilde_expander.
- If non-null, this contains the address of a function to call if
- the standard meaning for expanding a tilde fails. The function is
- called with the text sans tilde (as in "foo"), and returns a
- malloc()'ed string which is the expansion, or a NULL pointer if
- there is no expansion.
-
- * readline.h - new file chardefs.h
- Separates things that only readline.c needs from the standard
- header file publishing interesting things about readline.
-
- * readline.c:
- readline_default_bindings () now looks at terminal chararacters
- and binds those as well.
-
-Wed Jun 28 20:20:51 1989 Brian Fox (bfox at aurel)
-
- * Made readline and history into independent libraries.
-
-
diff --git a/gnu/usr.bin/gdb/readline/Makefile.gnu b/gnu/usr.bin/gdb/readline/Makefile.gnu
deleted file mode 100644
index dc11539..0000000
--- a/gnu/usr.bin/gdb/readline/Makefile.gnu
+++ /dev/null
@@ -1,114 +0,0 @@
-## -*- text -*- ####################################################
-# #
-# Makefile for readline and history libraries. #
-# #
-####################################################################
-
-# Here is a rule for making .o files from .c files that doesn't force
-# the type of the machine (like -sun3) into the flags.
-.c.o:
- $(CC) -c $(CFLAGS) $(LOCAL_INCLUDES) $(CPPFLAGS) $*.c
-
-# Destination installation directory. The libraries are copied to DESTDIR
-# when you do a `make install', and the header files to INCDIR/readline/*.h.
-DESTDIR = /usr/gnu/lib
-INCDIR = /usr/gnu/include
-
-# Define TYPES as -DVOID_SIGHANDLER if your operating system uses
-# a return type of "void" for signal handlers.
-TYPES = -DVOID_SIGHANDLER
-
-# Define SYSV as -DSYSV if you are using a System V operating system.
-#SYSV = -DSYSV
-
-# HP-UX compilation requires the BSD library.
-#LOCAL_LIBS = -lBSD
-
-# Xenix compilation requires -ldir -lx
-#LOCAL_LIBS = -ldir -lx
-
-# Comment this out if you don't think that anyone will ever desire
-# the vi line editing mode and features.
-READLINE_DEFINES = -DVI_MODE
-
-DEBUG_FLAGS = -g
-LDFLAGS = $(DEBUG_FLAGS)
-CFLAGS = $(DEBUG_FLAGS) $(TYPE) $(SYSV) -I.
-
-# A good alternative is gcc -traditional.
-#CC = gcc -traditional
-CC = cc
-RANLIB = /usr/bin/ranlib
-AR = ar
-RM = rm
-CP = cp
-
-LOCAL_INCLUDES = -I../
-
-CSOURCES = readline.c history.c funmap.c keymaps.c vi_mode.c \
- emacs_keymap.c vi_keymap.c keymaps.c
-
-HSOURCES = readline.h chardefs.h history.h keymaps.h
-SOURCES = $(CSOURCES) $(HSOURCES)
-
-DOCUMENTATION = readline.texinfo inc-readline.texinfo \
- history.texinfo inc-history.texinfo
-
-SUPPORT = COPYING Makefile $(DOCUMENTATION) ChangeLog
-
-THINGS_TO_TAR = $(SOURCES) $(SUPPORT)
-
-##########################################################################
-
-all: libreadline.a
-
-libreadline.a: readline.o history.o funmap.o keymaps.o
- $(RM) -f libreadline.a
- $(AR) clq libreadline.a readline.o history.o funmap.o keymaps.o
- if [ -f $(RANLIB) ]; then $(RANLIB) libreadline.a; fi
-
-readline.o: readline.h chardefs.h keymaps.h history.h readline.c vi_mode.c
- $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
- $(LOCAL_INCLUDES) $*.c
-
-history.o: history.c history.h
- $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
- $(LOCAL_INCLUDES) $*.c
-
-funmap.o: readline.h
- $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
- $(LOCAL_INCLUDES) $*.c
-
-keymaps.o: emacs_keymap.c vi_keymap.c keymaps.h chardefs.h keymaps.c
- $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
- $(LOCAL_INCLUDES) $*.c
-
-libtest: libreadline.a libtest.c
- $(CC) -o libtest $(CFLAGS) $(CPPFLAGS) -L. libtest.c -lreadline -ltermcap
-
-readline: readline.c history.o keymaps.o funmap.o readline.h chardefs.h
- $(CC) $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
- $(LOCAL_INCLUDES) -DTEST -o readline readline.c funmap.o \
- keymaps.o history.o -L. -ltermcap
-
-readline.tar: $(THINGS_TO_TAR)
- tar -cf readline.tar $(THINGS_TO_TAR)
-
-readline.tar.Z: readline.tar
- compress -f readline.tar
-
-install: $(DESTDIR)/libreadline.a includes
-
-includes:
- if [ ! -r $(INCDIR)/readline ]; then\
- mkdir $(INCDIR)/readline;\
- chmod a+r $(INCDIR)/readline;\
- fi
- $(CP) readline.h keymaps.h chardefs.h $(INCDIR)/readline/
-clean:
- rm -f *.o *.a *.log *.cp *.tp *.vr *.fn *.aux *.pg *.toc
-
-$(DESTDIR)/libreadline.a: libreadline.a
- -mv $(DESTDIR)/libreadline.a $(DESTDIR)/libreadline.old
- cp libreadline.a $(DESTDIR)/libreadline.a
- $(RANLIB) -t $(DESTDIR)/libreadline.a
diff --git a/gnu/usr.bin/gdb/readline/chardefs.h b/gnu/usr.bin/gdb/readline/chardefs.h
deleted file mode 100644
index 9749ae4..0000000
--- a/gnu/usr.bin/gdb/readline/chardefs.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* chardefs.h -- Character definitions for readline. */
-#ifndef _CHARDEFS_
-
-#ifndef savestring
-#define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
-#endif
-
-#ifndef whitespace
-#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
-#endif
-
-#ifdef CTRL
-#undef CTRL
-#endif
-
-/* Some character stuff. */
-#define control_character_threshold 0x020 /* smaller than this is control */
-#define meta_character_threshold 0x07f /* larger than this is Meta. */
-#define control_character_bit 0x40 /* 0x000000, must be off. */
-#define meta_character_bit 0x080 /* x0000000, must be on. */
-
-#define CTRL(c) ((c) & (~control_character_bit))
-#define META(c) ((c) | meta_character_bit)
-
-#define UNMETA(c) ((c) & (~meta_character_bit))
-#define UNCTRL(c) to_upper(((c)|control_character_bit))
-
-#define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
-#define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
-
-#define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c))
-
-#ifndef to_upper
-#define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c))
-#define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c))
-#endif
-
-#define CTRL_P(c) ((c) < control_character_threshold)
-#define META_P(c) ((c) > meta_character_threshold)
-
-#define NEWLINE '\n'
-#define RETURN CTRL('M')
-#define RUBOUT 0x07f
-#define TAB '\t'
-#define ABORT_CHAR CTRL('G')
-#define PAGE CTRL('L')
-#define SPACE 0x020
-#define ESC CTRL('[')
-
-#endif /* _CHARDEFS_ */
diff --git a/gnu/usr.bin/gdb/readline/emacs_keymap.c b/gnu/usr.bin/gdb/readline/emacs_keymap.c
deleted file mode 100644
index 7030e69..0000000
--- a/gnu/usr.bin/gdb/readline/emacs_keymap.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
-
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
-
- This file is part of GNU Readline, a library for reading lines
- of text with interactive input and history editing.
-
- Readline is free software; you can 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.
-
- Readline is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef FILE
-#include <stdio.h>
-#endif /* FILE */
-
-#include "readline.h"
-
-/* An array of function pointers, one for each possible key.
- If the type byte is ISKMAP, then the pointer is the address of
- a keymap. */
-
-KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
-
- /* Control keys. */
- { ISFUNC, (Function *)0x0 }, /* Control-@ */
- { ISFUNC, rl_beg_of_line }, /* Control-a */
- { ISFUNC, rl_backward }, /* Control-b */
- { ISFUNC, (Function *)0x0 }, /* Control-c */
- { ISFUNC, rl_delete }, /* Control-d */
- { ISFUNC, rl_end_of_line }, /* Control-e */
- { ISFUNC, rl_forward }, /* Control-f */
- { ISFUNC, rl_abort }, /* Control-g */
- { ISFUNC, rl_backward }, /* Control-h */
- { ISFUNC, rl_complete }, /* Control-i */
- { ISFUNC, rl_newline }, /* Control-j */
- { ISFUNC, rl_kill_line }, /* Control-k */
- { ISFUNC, rl_clear_screen }, /* Control-l */
- { ISFUNC, rl_newline }, /* Control-m */
- { ISFUNC, rl_get_next_history }, /* Control-n */
- { ISFUNC, (Function *)0x0 }, /* Control-o */
- { ISFUNC, rl_get_previous_history }, /* Control-p */
- { ISFUNC, rl_quoted_insert }, /* Control-q */
- { ISFUNC, rl_reverse_search_history }, /* Control-r */
- { ISFUNC, rl_forward_search_history }, /* Control-s */
- { ISFUNC, rl_transpose_chars }, /* Control-t */
- { ISFUNC, rl_unix_line_discard }, /* Control-u */
- { ISFUNC, rl_quoted_insert }, /* Control-v */
- { ISFUNC, rl_unix_word_rubout }, /* Control-w */
- { ISKMAP, (Function *)emacs_ctlx_keymap }, /* Control-x */
- { ISFUNC, rl_yank }, /* Control-y */
- { ISFUNC, (Function *)0x0 }, /* Control-z */
- { ISKMAP, (Function *)emacs_meta_keymap }, /* Control-[ */
- { ISFUNC, (Function *)0x0 }, /* Control-\ */
- { ISFUNC, (Function *)0x0 }, /* Control-] */
- { ISFUNC, (Function *)0x0 }, /* Control-^ */
- { ISFUNC, rl_undo_command }, /* Control-_ */
-
- /* The start of printing characters. */
- { ISFUNC, rl_insert }, /* SPACE */
- { ISFUNC, rl_insert }, /* ! */
- { ISFUNC, rl_insert }, /* " */
- { ISFUNC, rl_insert }, /* # */
- { ISFUNC, rl_insert }, /* $ */
- { ISFUNC, rl_insert }, /* % */
- { ISFUNC, rl_insert }, /* & */
- { ISFUNC, rl_insert }, /* ' */
- { ISFUNC, rl_insert }, /* ( */
- { ISFUNC, rl_insert }, /* ) */
- { ISFUNC, rl_insert }, /* * */
- { ISFUNC, rl_insert }, /* + */
- { ISFUNC, rl_insert }, /* , */
- { ISFUNC, rl_insert }, /* - */
- { ISFUNC, rl_insert }, /* . */
- { ISFUNC, rl_insert }, /* / */
-
- /* Regular digits. */
- { ISFUNC, rl_insert }, /* 0 */
- { ISFUNC, rl_insert }, /* 1 */
- { ISFUNC, rl_insert }, /* 2 */
- { ISFUNC, rl_insert }, /* 3 */
- { ISFUNC, rl_insert }, /* 4 */
- { ISFUNC, rl_insert }, /* 5 */
- { ISFUNC, rl_insert }, /* 6 */
- { ISFUNC, rl_insert }, /* 7 */
- { ISFUNC, rl_insert }, /* 8 */
- { ISFUNC, rl_insert }, /* 9 */
-
- /* A little more punctuation. */
- { ISFUNC, rl_insert }, /* : */
- { ISFUNC, rl_insert }, /* ; */
- { ISFUNC, rl_insert }, /* < */
- { ISFUNC, rl_insert }, /* = */
- { ISFUNC, rl_insert }, /* > */
- { ISFUNC, rl_insert }, /* ? */
- { ISFUNC, rl_insert }, /* @ */
-
- /* Uppercase alphabet. */
- { ISFUNC, rl_insert }, /* A */
- { ISFUNC, rl_insert }, /* B */
- { ISFUNC, rl_insert }, /* C */
- { ISFUNC, rl_insert }, /* D */
- { ISFUNC, rl_insert }, /* E */
- { ISFUNC, rl_insert }, /* F */
- { ISFUNC, rl_insert }, /* G */
- { ISFUNC, rl_insert }, /* H */
- { ISFUNC, rl_insert }, /* I */
- { ISFUNC, rl_insert }, /* J */
- { ISFUNC, rl_insert }, /* K */
- { ISFUNC, rl_insert }, /* L */
- { ISFUNC, rl_insert }, /* M */
- { ISFUNC, rl_insert }, /* N */
- { ISFUNC, rl_insert }, /* O */
- { ISFUNC, rl_insert }, /* P */
- { ISFUNC, rl_insert }, /* Q */
- { ISFUNC, rl_insert }, /* R */
- { ISFUNC, rl_insert }, /* S */
- { ISFUNC, rl_insert }, /* T */
- { ISFUNC, rl_insert }, /* U */
- { ISFUNC, rl_insert }, /* V */
- { ISFUNC, rl_insert }, /* W */
- { ISFUNC, rl_insert }, /* X */
- { ISFUNC, rl_insert }, /* Y */
- { ISFUNC, rl_insert }, /* Z */
-
- /* Some more punctuation. */
- { ISFUNC, rl_insert }, /* [ */
- { ISFUNC, rl_insert }, /* \ */
- { ISFUNC, rl_insert }, /* ] */
- { ISFUNC, rl_insert }, /* ^ */
- { ISFUNC, rl_insert }, /* _ */
- { ISFUNC, rl_insert }, /* ` */
-
- /* Lowercase alphabet. */
- { ISFUNC, rl_insert }, /* a */
- { ISFUNC, rl_insert }, /* b */
- { ISFUNC, rl_insert }, /* c */
- { ISFUNC, rl_insert }, /* d */
- { ISFUNC, rl_insert }, /* e */
- { ISFUNC, rl_insert }, /* f */
- { ISFUNC, rl_insert }, /* g */
- { ISFUNC, rl_insert }, /* h */
- { ISFUNC, rl_insert }, /* i */
- { ISFUNC, rl_insert }, /* j */
- { ISFUNC, rl_insert }, /* k */
- { ISFUNC, rl_insert }, /* l */
- { ISFUNC, rl_insert }, /* m */
- { ISFUNC, rl_insert }, /* n */
- { ISFUNC, rl_insert }, /* o */
- { ISFUNC, rl_insert }, /* p */
- { ISFUNC, rl_insert }, /* q */
- { ISFUNC, rl_insert }, /* r */
- { ISFUNC, rl_insert }, /* s */
- { ISFUNC, rl_insert }, /* t */
- { ISFUNC, rl_insert }, /* u */
- { ISFUNC, rl_insert }, /* v */
- { ISFUNC, rl_insert }, /* w */
- { ISFUNC, rl_insert }, /* x */
- { ISFUNC, rl_insert }, /* y */
- { ISFUNC, rl_insert }, /* z */
-
- /* Final punctuation. */
- { ISFUNC, rl_insert }, /* { */
- { ISFUNC, rl_insert }, /* | */
- { ISFUNC, rl_insert }, /* } */
- { ISFUNC, rl_insert }, /* ~ */
- { ISFUNC, rl_rubout } /* RUBOUT */
-};
-
-KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
-
- /* Meta keys. Just like above, but the high bit is set. */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-@ */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-a */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-b */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-c */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-d */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-e */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-f */
- { ISFUNC, rl_abort }, /* Meta-Control-g */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-h */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-i */
- { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-k */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-l */
- { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-n */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-o */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-p */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-q */
- { ISFUNC, rl_revert_line }, /* Meta-Control-r */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-s */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-t */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-u */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-v */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-w */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-x */
- { ISFUNC, rl_yank_nth_arg }, /* Meta-Control-y */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-z */
-
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-[ */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-\ */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-] */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-^ */
- { ISFUNC, (Function *)0x0 }, /* Meta-Control-_ */
-
- /* The start of printing characters. */
- { ISFUNC, (Function *)0x0 }, /* Meta-SPACE */
- { ISFUNC, (Function *)0x0 }, /* Meta-! */
- { ISFUNC, (Function *)0x0 }, /* Meta-" */
- { ISFUNC, (Function *)0x0 }, /* Meta-# */
- { ISFUNC, (Function *)0x0 }, /* Meta-$ */
- { ISFUNC, (Function *)0x0 }, /* Meta-% */
- { ISFUNC, (Function *)0x0 }, /* Meta-& */
- { ISFUNC, (Function *)0x0 }, /* Meta-' */
- { ISFUNC, (Function *)0x0 }, /* Meta-( */
- { ISFUNC, (Function *)0x0 }, /* Meta-) */
- { ISFUNC, (Function *)0x0 }, /* Meta-* */
- { ISFUNC, (Function *)0x0 }, /* Meta-+ */
- { ISFUNC, (Function *)0x0 }, /* Meta-, */
- { ISFUNC, rl_digit_argument }, /* Meta-- */
- { ISFUNC, (Function *)0x0 }, /* Meta-. */
- { ISFUNC, (Function *)0x0 }, /* Meta-/ */
-
- /* Regular digits. */
- { ISFUNC, rl_digit_argument }, /* Meta-0 */
- { ISFUNC, rl_digit_argument }, /* Meta-1 */
- { ISFUNC, rl_digit_argument }, /* Meta-2 */
- { ISFUNC, rl_digit_argument }, /* Meta-3 */
- { ISFUNC, rl_digit_argument }, /* Meta-4 */
- { ISFUNC, rl_digit_argument }, /* Meta-5 */
- { ISFUNC, rl_digit_argument }, /* Meta-6 */
- { ISFUNC, rl_digit_argument }, /* Meta-7 */
- { ISFUNC, rl_digit_argument }, /* Meta-8 */
- { ISFUNC, rl_digit_argument }, /* Meta-9 */
-
- /* A little more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* Meta-: */
- { ISFUNC, (Function *)0x0 }, /* Meta-; */
- { ISFUNC, rl_beginning_of_history }, /* Meta-< */
- { ISFUNC, (Function *)0x0 }, /* Meta-= */
- { ISFUNC, rl_end_of_history }, /* Meta-> */
- { ISFUNC, rl_possible_completions }, /* Meta-? */
- { ISFUNC, (Function *)0x0 }, /* Meta-@ */
-
- /* Uppercase alphabet. */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-A */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-B */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-C */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-D */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-E */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-F */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-G */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-H */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-I */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-J */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-K */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-L */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-M */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-N */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-O */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-P */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-Q */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-R */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-S */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-T */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-U */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-V */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-W */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-X */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-Y */
- { ISFUNC, rl_do_lowercase_version }, /* Meta-Z */
-
- /* Some more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* Meta-[ */
- { ISFUNC, (Function *)0x0 }, /* Meta-\ */
- { ISFUNC, (Function *)0x0 }, /* Meta-] */
- { ISFUNC, (Function *)0x0 }, /* Meta-^ */
- { ISFUNC, (Function *)0x0 }, /* Meta-_ */
- { ISFUNC, (Function *)0x0 }, /* Meta-` */
-
- /* Lowercase alphabet. */
- { ISFUNC, (Function *)0x0 }, /* Meta-a */
- { ISFUNC, rl_backward_word }, /* Meta-b */
- { ISFUNC, rl_capitalize_word }, /* Meta-c */
- { ISFUNC, rl_kill_word }, /* Meta-d */
- { ISFUNC, (Function *)0x0 }, /* Meta-e */
- { ISFUNC, rl_forward_word }, /* Meta-f */
- { ISFUNC, (Function *)0x0 }, /* Meta-g */
- { ISFUNC, (Function *)0x0 }, /* Meta-h */
- { ISFUNC, (Function *)0x0 }, /* Meta-i */
- { ISFUNC, (Function *)0x0 }, /* Meta-j */
- { ISFUNC, (Function *)0x0 }, /* Meta-k */
- { ISFUNC, rl_downcase_word }, /* Meta-l */
- { ISFUNC, (Function *)0x0 }, /* Meta-m */
- { ISFUNC, (Function *)0x0 }, /* Meta-n */
- { ISFUNC, (Function *)0x0 }, /* Meta-o */
- { ISFUNC, (Function *)0x0 }, /* Meta-p */
- { ISFUNC, (Function *)0x0 }, /* Meta-q */
- { ISFUNC, rl_revert_line }, /* Meta-r */
- { ISFUNC, (Function *)0x0 }, /* Meta-s */
- { ISFUNC, rl_transpose_words }, /* Meta-t */
- { ISFUNC, rl_upcase_word }, /* Meta-u */
- { ISFUNC, (Function *)0x0 }, /* Meta-v */
- { ISFUNC, (Function *)0x0 }, /* Meta-w */
- { ISFUNC, (Function *)0x0 }, /* Meta-x */
- { ISFUNC, rl_yank_pop }, /* Meta-y */
- { ISFUNC, (Function *)0x0 }, /* Meta-z */
-
- /* Final punctuation. */
- { ISFUNC, (Function *)0x0 }, /* Meta-{ */
- { ISFUNC, (Function *)0x0 }, /* Meta-| */
- { ISFUNC, (Function *)0x0 }, /* Meta-} */
- { ISFUNC, (Function *)0x0 }, /* Meta-~ */
- { ISFUNC, rl_backward_kill_word } /* Meta-rubout */
-};
-
-KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = {
-
- /* Control keys. */
- { ISFUNC, (Function *)0x0 }, /* Control-@ */
- { ISFUNC, (Function *)0x0 }, /* Control-a */
- { ISFUNC, (Function *)0x0 }, /* Control-b */
- { ISFUNC, (Function *)0x0 }, /* Control-c */
- { ISFUNC, (Function *)0x0 }, /* Control-d */
- { ISFUNC, (Function *)0x0 }, /* Control-e */
- { ISFUNC, (Function *)0x0 }, /* Control-f */
- { ISFUNC, rl_abort }, /* Control-g */
- { ISFUNC, (Function *)0x0 }, /* Control-h */
- { ISFUNC, (Function *)0x0 }, /* Control-i */
- { ISFUNC, (Function *)0x0 }, /* Control-j */
- { ISFUNC, (Function *)0x0 }, /* Control-k */
- { ISFUNC, (Function *)0x0 }, /* Control-l */
- { ISFUNC, (Function *)0x0 }, /* Control-m */
- { ISFUNC, (Function *)0x0 }, /* Control-n */
- { ISFUNC, (Function *)0x0 }, /* Control-o */
- { ISFUNC, (Function *)0x0 }, /* Control-p */
- { ISFUNC, (Function *)0x0 }, /* Control-q */
- { ISFUNC, rl_re_read_init_file }, /* Control-r */
- { ISFUNC, (Function *)0x0 }, /* Control-s */
- { ISFUNC, (Function *)0x0 }, /* Control-t */
- { ISFUNC, rl_undo_command }, /* Control-u */
- { ISFUNC, (Function *)0x0 }, /* Control-v */
- { ISFUNC, (Function *)0x0 }, /* Control-w */
- { ISFUNC, (Function *)0x0 }, /* Control-x */
- { ISFUNC, (Function *)0x0 }, /* Control-y */
- { ISFUNC, (Function *)0x0 }, /* Control-z */
- { ISFUNC, (Function *)0x0 }, /* Control-[ */
- { ISFUNC, (Function *)0x0 }, /* Control-\ */
- { ISFUNC, (Function *)0x0 }, /* Control-] */
- { ISFUNC, (Function *)0x0 }, /* Control-^ */
- { ISFUNC, (Function *)0x0 }, /* Control-_ */
-
- /* The start of printing characters. */
- { ISFUNC, (Function *)0x0 }, /* SPACE */
- { ISFUNC, (Function *)0x0 }, /* ! */
- { ISFUNC, (Function *)0x0 }, /* " */
- { ISFUNC, (Function *)0x0 }, /* # */
- { ISFUNC, (Function *)0x0 }, /* $ */
- { ISFUNC, (Function *)0x0 }, /* % */
- { ISFUNC, (Function *)0x0 }, /* & */
- { ISFUNC, (Function *)0x0 }, /* ' */
- { ISFUNC, rl_start_kbd_macro }, /* ( */
- { ISFUNC, rl_end_kbd_macro }, /* ) */
- { ISFUNC, (Function *)0x0 }, /* * */
- { ISFUNC, (Function *)0x0 }, /* + */
- { ISFUNC, (Function *)0x0 }, /* , */
- { ISFUNC, (Function *)0x0 }, /* - */
- { ISFUNC, (Function *)0x0 }, /* . */
- { ISFUNC, (Function *)0x0 }, /* / */
-
- /* Regular digits. */
- { ISFUNC, (Function *)0x0 }, /* 0 */
- { ISFUNC, (Function *)0x0 }, /* 1 */
- { ISFUNC, (Function *)0x0 }, /* 2 */
- { ISFUNC, (Function *)0x0 }, /* 3 */
- { ISFUNC, (Function *)0x0 }, /* 4 */
- { ISFUNC, (Function *)0x0 }, /* 5 */
- { ISFUNC, (Function *)0x0 }, /* 6 */
- { ISFUNC, (Function *)0x0 }, /* 7 */
- { ISFUNC, (Function *)0x0 }, /* 8 */
- { ISFUNC, (Function *)0x0 }, /* 9 */
-
- /* A little more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* : */
- { ISFUNC, (Function *)0x0 }, /* ; */
- { ISFUNC, (Function *)0x0 }, /* < */
- { ISFUNC, (Function *)0x0 }, /* = */
- { ISFUNC, (Function *)0x0 }, /* > */
- { ISFUNC, (Function *)0x0 }, /* ? */
- { ISFUNC, (Function *)0x0 }, /* @ */
-
- /* Uppercase alphabet. */
- { ISFUNC, rl_do_lowercase_version }, /* A */
- { ISFUNC, rl_do_lowercase_version }, /* B */
- { ISFUNC, rl_do_lowercase_version }, /* C */
- { ISFUNC, rl_do_lowercase_version }, /* D */
- { ISFUNC, rl_do_lowercase_version }, /* E */
- { ISFUNC, rl_do_lowercase_version }, /* F */
- { ISFUNC, rl_do_lowercase_version }, /* G */
- { ISFUNC, rl_do_lowercase_version }, /* H */
- { ISFUNC, rl_do_lowercase_version }, /* I */
- { ISFUNC, rl_do_lowercase_version }, /* J */
- { ISFUNC, rl_do_lowercase_version }, /* K */
- { ISFUNC, rl_do_lowercase_version }, /* L */
- { ISFUNC, rl_do_lowercase_version }, /* M */
- { ISFUNC, rl_do_lowercase_version }, /* N */
- { ISFUNC, rl_do_lowercase_version }, /* O */
- { ISFUNC, rl_do_lowercase_version }, /* P */
- { ISFUNC, rl_do_lowercase_version }, /* Q */
- { ISFUNC, rl_do_lowercase_version }, /* R */
- { ISFUNC, rl_do_lowercase_version }, /* S */
- { ISFUNC, rl_do_lowercase_version }, /* T */
- { ISFUNC, rl_do_lowercase_version }, /* U */
- { ISFUNC, rl_do_lowercase_version }, /* V */
- { ISFUNC, rl_do_lowercase_version }, /* W */
- { ISFUNC, rl_do_lowercase_version }, /* X */
- { ISFUNC, rl_do_lowercase_version }, /* Y */
- { ISFUNC, rl_do_lowercase_version }, /* Z */
-
- /* Some more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* [ */
- { ISFUNC, (Function *)0x0 }, /* \ */
- { ISFUNC, (Function *)0x0 }, /* ] */
- { ISFUNC, (Function *)0x0 }, /* ^ */
- { ISFUNC, (Function *)0x0 }, /* _ */
- { ISFUNC, (Function *)0x0 }, /* ` */
-
- /* Lowercase alphabet. */
- { ISFUNC, (Function *)0x0 }, /* a */
- { ISFUNC, (Function *)0x0 }, /* b */
- { ISFUNC, (Function *)0x0 }, /* c */
- { ISFUNC, (Function *)0x0 }, /* d */
- { ISFUNC, rl_call_last_kbd_macro }, /* e */
- { ISFUNC, (Function *)0x0 }, /* f */
- { ISFUNC, (Function *)0x0 }, /* g */
- { ISFUNC, (Function *)0x0 }, /* h */
- { ISFUNC, (Function *)0x0 }, /* i */
- { ISFUNC, (Function *)0x0 }, /* j */
- { ISFUNC, (Function *)0x0 }, /* k */
- { ISFUNC, (Function *)0x0 }, /* l */
- { ISFUNC, (Function *)0x0 }, /* m */
- { ISFUNC, (Function *)0x0 }, /* n */
- { ISFUNC, (Function *)0x0 }, /* o */
- { ISFUNC, (Function *)0x0 }, /* p */
- { ISFUNC, (Function *)0x0 }, /* q */
- { ISFUNC, rl_re_read_init_file }, /* r */
- { ISFUNC, (Function *)0x0 }, /* s */
- { ISFUNC, (Function *)0x0 }, /* t */
- { ISFUNC, (Function *)0x0 }, /* u */
- { ISFUNC, (Function *)0x0 }, /* v */
- { ISFUNC, (Function *)0x0 }, /* w */
- { ISFUNC, (Function *)0x0 }, /* x */
- { ISFUNC, (Function *)0x0 }, /* y */
- { ISFUNC, (Function *)0x0 }, /* z */
-
- /* Final punctuation. */
- { ISFUNC, (Function *)0x0 }, /* { */
- { ISFUNC, (Function *)0x0 }, /* | */
- { ISFUNC, (Function *)0x0 }, /* } */
- { ISFUNC, (Function *)0x0 }, /* ~ */
- { ISFUNC, rl_backward_kill_line } /* RUBOUT */
-};
diff --git a/gnu/usr.bin/gdb/readline/funmap.c b/gnu/usr.bin/gdb/readline/funmap.c
deleted file mode 100644
index 357e716..0000000
--- a/gnu/usr.bin/gdb/readline/funmap.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* funmap.c -- attach names to functions. */
-
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
-
- This file is part of GNU Readline, a library for reading lines
- of text with interactive input and history editing.
-
- Readline is free software; you can 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.
-
- Readline is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
-extern char *xmalloc (), *xrealloc ();
-#else
-static char *xmalloc (), *xrealloc ();
-#endif
-
-#ifndef FILE
-#include <stdio.h>
-#endif /* FILE */
-
-#include "readline.h"
-
-FUNMAP **funmap = (FUNMAP **)NULL;
-static int funmap_size = 0;
-
-static int just_testing_ar_tmp = 0;
-static int just_testing_ar_tmp_2 = 5;
-int foo_testing_ar;
-
-static int funmap_entry = 0;
-
-static FUNMAP default_funmap[] = {
- { "beginning-of-line", rl_beg_of_line },
- { "backward-char", rl_backward },
- { "delete-char", rl_delete },
- { "end-of-line", rl_end_of_line },
- { "forward-char", rl_forward },
- { "accept-line", rl_newline },
- { "kill-line", rl_kill_line },
- { "clear-screen", rl_clear_screen },
- { "next-history", rl_get_next_history },
- { "previous-history", rl_get_previous_history },
- { "quoted-insert", rl_quoted_insert },
- { "reverse-search-history", rl_reverse_search_history },
- { "forward-search-history", rl_forward_search_history },
- { "transpose-chars", rl_transpose_chars },
- { "unix-line-discard", rl_unix_line_discard },
- { "unix-word-rubout", rl_unix_word_rubout },
- { "yank", rl_yank },
- { "yank-pop", rl_yank_pop },
- { "yank-nth-arg", rl_yank_nth_arg },
- { "backward-delete-char", rl_rubout },
- { "backward-word", rl_backward_word },
- { "kill-word", rl_kill_word },
- { "forward-word", rl_forward_word },
- { "tab-insert", rl_tab_insert },
- { "backward-kill-word", rl_backward_kill_word },
- { "backward-kill-line", rl_backward_kill_line },
- { "transpose-words", rl_transpose_words },
- { "digit-argument", rl_digit_argument },
- { "complete", rl_complete },
- { "possible-completions", rl_possible_completions },
- { "do-lowercase-version", rl_do_lowercase_version },
- { "digit-argument", rl_digit_argument },
- { "universal-argument", rl_universal_argument },
- { "abort", rl_abort },
- { "undo", rl_undo_command },
- { "upcase-word", rl_upcase_word },
- { "downcase-word", rl_downcase_word },
- { "capitalize-word", rl_capitalize_word },
- { "revert-line", rl_revert_line },
- { "beginning-of-history", rl_beginning_of_history },
- { "end-of-history", rl_end_of_history },
- { "self-insert", rl_insert },
- { "start-kbd-macro", rl_start_kbd_macro },
- { "end-kbd-macro", rl_end_kbd_macro },
- { "re-read-init-file", rl_re_read_init_file },
-#ifdef VI_MODE
- { "vi-movement-mode", rl_vi_movement_mode },
- { "vi-insertion-mode", rl_vi_insertion_mode },
- { "vi-arg-digit", rl_vi_arg_digit },
- { "vi-prev-word", rl_vi_prev_word },
- { "vi-next-word", rl_vi_next_word },
- { "vi-char-search", rl_vi_char_search },
- { "vi-editing-mode", rl_vi_editing_mode },
- { "vi-eof-maybe", rl_vi_eof_maybe },
- { "vi-append-mode", rl_vi_append_mode },
- { "vi-put", rl_vi_put },
- { "vi-append-eol", rl_vi_append_eol },
- { "vi-insert-beg", rl_vi_insert_beg },
- { "vi-delete", rl_vi_delete },
- { "vi-comment", rl_vi_comment },
- { "vi-first-print", rl_vi_first_print },
- { "vi-fword", rl_vi_fword },
- { "vi-fWord", rl_vi_fWord },
- { "vi-bword", rl_vi_bword },
- { "vi-bWord", rl_vi_bWord },
- { "vi-eword", rl_vi_eword },
- { "vi-eWord", rl_vi_eWord },
- { "vi-end-word", rl_vi_end_word },
- { "vi-change-case", rl_vi_change_case },
- { "vi-match", rl_vi_match },
- { "vi-bracktype", rl_vi_bracktype },
- { "vi-change-char", rl_vi_change_char },
- { "vi-yank-arg", rl_vi_yank_arg },
- { "vi-search", rl_vi_search },
- { "vi-search-again", rl_vi_search_again },
- { "vi-dosearch", rl_vi_dosearch },
- { "vi-subst", rl_vi_subst },
- { "vi-overstrike", rl_vi_overstrike },
- { "vi-overstrike-delete", rl_vi_overstrike_delete },
- { "vi-replace, ", rl_vi_replace },
- { "vi-column", rl_vi_column },
- { "vi-delete-to", rl_vi_delete_to },
- { "vi-change-to", rl_vi_change_to },
- { "vi-yank-to", rl_vi_yank_to },
- { "vi-complete", rl_vi_complete },
-#endif /* VI_MODE */
-
- {(char *)NULL, (Function *)NULL }
-};
-
-rl_add_funmap_entry (name, function)
- char *name;
- Function *function;
-{
- if (funmap_entry + 2 >= funmap_size)
- if (!funmap)
- funmap = (FUNMAP **)xmalloc ((funmap_size = 80) * sizeof (FUNMAP *));
- else
- funmap =
- (FUNMAP **)xrealloc (funmap, (funmap_size += 80) * sizeof (FUNMAP *));
-
- funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
- funmap[funmap_entry]->name = name;
- funmap[funmap_entry]->function = function;
-
- funmap[++funmap_entry] = (FUNMAP *)NULL;
-}
-
-static int funmap_initialized = 0;
-
-/* Make the funmap contain all of the default entries. */
-rl_initialize_funmap ()
-{
- register int i;
-
- if (funmap_initialized)
- return;
-
- for (i = 0; default_funmap[i].name; i++)
- rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
-
- funmap_initialized = 1;
-}
-
-/* Things that mean `Control'. */
-char *possible_control_prefixes[] = {
- "Control-", "C-", "CTRL-", (char *)NULL
-};
-
-char *possible_meta_prefixes[] = {
- "Meta", "M-", (char *)NULL
-};
-
-#ifdef STATIC_MALLOC
-
-/* **************************************************************** */
-/* */
-/* xmalloc and xrealloc () */
-/* */
-/* **************************************************************** */
-
-static char *
-xmalloc (bytes)
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)malloc (bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static char *
-xrealloc (pointer, bytes)
- char *pointer;
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)realloc (pointer, bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static
-memory_error_and_abort ()
-{
- fprintf (stderr, "history: Out of virtual memory!\n");
- abort ();
-}
-#endif /* STATIC_MALLOC */
diff --git a/gnu/usr.bin/gdb/readline/history.c b/gnu/usr.bin/gdb/readline/history.c
deleted file mode 100644
index 7087718..0000000
--- a/gnu/usr.bin/gdb/readline/history.c
+++ /dev/null
@@ -1,1462 +0,0 @@
-/* History.c -- standalone history library */
-
-/* Copyright (C) 1989 Free Software Foundation, Inc.
-
- This file contains the GNU History Library (the Library), a set of
- routines for managing the text of previously typed lines.
-
- The Library is free software; you can 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.
-
- The 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
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* The goal is to make the implementation transparent, so that you
- don't have to know what data types are used, just what functions
- you can call. I think I have done that. */
-
-/* Remove these declarations when we have a complete libgnu.a. */
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
-extern char *xmalloc (), *xrealloc ();
-#else
-static char *xmalloc (), *xrealloc ();
-#endif
-
-#include <stdio.h>
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#if defined (sparc) && defined (sun)
-#include <alloca.h>
-#else
-extern char *alloca ();
-#endif
-#endif
-
-#include "history.h"
-
-#ifndef savestring
-#define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
-#endif
-
-#ifndef whitespace
-#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
-#endif
-
-#ifndef digit
-#define digit(c) ((c) >= '0' && (c) <= '9')
-#endif
-
-#ifndef member
-#define member(c, s) ((c) ? index ((s), (c)) : 0)
-#endif
-
-/* **************************************************************** */
-/* */
-/* History functions */
-/* */
-/* **************************************************************** */
-
-/* An array of HIST_ENTRY. This is where we store the history. */
-static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
-
-/* Non-zero means that we have enforced a limit on the amount of
- history that we save. */
-static int history_stifled = 0;
-
-/* If HISTORY_STIFLED is non-zero, then this is the maximum number of
- entries to remember. */
-static int max_input_history;
-
-/* The current location of the interactive history pointer. Just makes
- life easier for outside callers. */
-static int history_offset = 0;
-
-/* The number of strings currently stored in the input_history list. */
-static int history_length = 0;
-
-/* The current number of slots allocated to the input_history. */
-static int history_size = 0;
-
-/* The number of slots to increase the_history by. */
-#define DEFAULT_HISTORY_GROW_SIZE 50
-
-/* The character that represents the start of a history expansion
- request. This is usually `!'. */
-char history_expansion_char = '!';
-
-/* The character that invokes word substitution if found at the start of
- a line. This is usually `^'. */
-char history_subst_char = '^';
-
-/* During tokenization, if this character is seen as the first character
- of a word, then it, and all subsequent characters upto a newline are
- ignored. For a Bourne shell, this should be '#'. Bash special cases
- the interactive comment character to not be a comment delimiter. */
-char history_comment_char = '\0';
-
-/* The list of characters which inhibit the expansion of text if found
- immediately following history_expansion_char. */
-char *history_no_expand_chars = " \t\n\r=";
-
-/* The logical `base' of the history array. It defaults to 1. */
-int history_base = 1;
-
-/* Begin a session in which the history functions might be used. This
- initializes interactive variables. */
-void
-using_history ()
-{
- history_offset = history_length;
-}
-
-/* Place STRING at the end of the history list. The data field
- is set to NULL. */
-void
-add_history (string)
- char *string;
-{
- HIST_ENTRY *temp;
-
- if (history_stifled && (history_length == max_input_history)) {
- register int i;
-
- /* If the history is stifled, and history_length is zero,
- and it equals max_input_history, we don't save items. */
- if (!history_length)
- return;
-
- /* If there is something in the slot, then remove it. */
- if (the_history[0]) {
- free (the_history[0]->line);
- free (the_history[0]);
- }
-
- for (i = 0; i < history_length; i++)
- the_history[i] = the_history[i + 1];
-
- history_base++;
-
- } else {
-
- if (!history_size) {
- the_history =
- (HIST_ENTRY **)xmalloc ((history_size = DEFAULT_HISTORY_GROW_SIZE)
- * sizeof (HIST_ENTRY *));
- history_length = 1;
-
- } else {
- if (history_length == (history_size - 1)) {
- the_history =
- (HIST_ENTRY **)xrealloc (the_history,
- ((history_size += DEFAULT_HISTORY_GROW_SIZE)
- * sizeof (HIST_ENTRY *)));
- }
- history_length++;
- }
- }
-
- temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
- temp->line = savestring (string);
- temp->data = (char *)NULL;
-
- the_history[history_length] = (HIST_ENTRY *)NULL;
- the_history[history_length - 1] = temp;
-}
-
-/* Make the history entry at WHICH have LINE and DATA. This returns
- the old entry so you can dispose of the data. In the case of an
- invalid WHICH, a NULL pointer is returned. */
-HIST_ENTRY *
-replace_history_entry (which, line, data)
- int which;
- char *line;
- char *data;
-{
- HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
- HIST_ENTRY *old_value;
-
- if (which >= history_length)
- return ((HIST_ENTRY *)NULL);
-
- old_value = the_history[which];
-
- temp->line = savestring (line);
- temp->data = data;
- the_history[which] = temp;
-
- return (old_value);
-}
-
-/* Returns the magic number which says what history element we are
- looking at now. In this implementation, it returns history_offset. */
-int
-where_history ()
-{
- return (history_offset);
-}
-
-/* Search the history for STRING, starting at history_offset.
- If DIRECTION < 0, then the search is through previous entries,
- else through subsequent. If the string is found, then
- current_history () is the history entry, and the value of this function
- is the offset in the line of that history entry that the string was
- found in. Otherwise, nothing is changed, and a -1 is returned. */
-int
-history_search (string, direction)
- char *string;
- int direction;
-{
- register int i = history_offset;
- register int reverse = (direction < 0);
- register char *line;
- register int index;
- int string_len = strlen (string);
-
- /* Take care of trivial cases first. */
-
- if (!history_length || (i == history_length) && !reverse)
- return (-1);
-
- if (reverse && (i == history_length))
- i--;
-
- while (1)
- {
- /* Search each line in the history list for STRING. */
-
- /* At limit for direction? */
- if ((reverse && i < 0) ||
- (!reverse && i == history_length))
- return (-1);
-
- line = the_history[i]->line;
- index = strlen (line);
-
- /* If STRING is longer than line, no match. */
- if (string_len > index)
- goto next_line;
-
- /* Do the actual search. */
- if (reverse)
- {
- index -= string_len;
-
- while (index >= 0)
- {
- if (strncmp (string, line + index, string_len) == 0)
- {
- history_offset = i;
- return (index);
- }
- index--;
- }
- }
- else
- {
- register int limit = (string_len - index) + 1;
- index = 0;
-
- while (index < limit)
- {
- if (strncmp (string, line + index, string_len) == 0)
- {
- history_offset = i;
- return (index);
- }
- index++;
- }
- }
- next_line:
- if (reverse)
- i--;
- else
- i++;
- }
-}
-
-/* Remove history element WHICH from the history. The removed
- element is returned to you so you can free the line, data,
- and containing structure. */
-HIST_ENTRY *
-remove_history (which)
- int which;
-{
- HIST_ENTRY *return_value;
-
- if (which >= history_length || !history_length)
- return_value = (HIST_ENTRY *)NULL;
- else
- {
- register int i;
- return_value = the_history[which];
-
- for (i = which; i < history_length; i++)
- the_history[i] = the_history[i + 1];
-
- history_length--;
- }
- return (return_value);
-}
-
-/* Stifle the history list, remembering only MAX number of lines. */
-void
-stifle_history (max)
- int max;
-{
- if (history_length > max)
- {
- register int i, j;
-
- /* This loses because we cannot free the data. */
- for (i = 0; i < (history_length - max); i++)
- {
- free (the_history[i]->line);
- free (the_history[i]);
- }
- history_base = i;
- for (j = 0, i = history_length - max; j < max; i++, j++)
- the_history[j] = the_history[i];
- the_history[j] = (HIST_ENTRY *)NULL;
- history_length = j;
- }
- history_stifled = 1;
- max_input_history = max;
-}
-
-/* Stop stifling the history. This returns the previous amount the history
- was stifled by. The value is positive if the history was stifled, negative
- if it wasn't. */
-int
-unstifle_history ()
-{
- int result = max_input_history;
- if (history_stifled)
- {
- result = - result;
- history_stifled = 0;
- }
- return (result);
-}
-
-/* Return the string that should be used in the place of this
- filename. This only matters when you don't specify the
- filename to read_history (), or write_history (). */
-static char *
-history_filename (filename)
- char *filename;
-{
- char *return_val = filename ? savestring (filename) : (char *)NULL;
-
- if (!return_val)
- {
- char *home = (char *)getenv ("HOME");
- if (!home) home = ".";
- return_val = (char *)xmalloc (2 + strlen (home) + strlen (".history"));
- strcpy (return_val, home);
- strcat (return_val, "/");
- strcat (return_val, ".history");
- }
- return (return_val);
-}
-
-/* What to use until the line gets too big. */
-#define TYPICAL_LINE_SIZE 2048
-
-/* Add the contents of FILENAME to the history list, a line at a time.
- If FILENAME is NULL, then read from ~/.history. Returns 0 if
- successful, or errno if not. */
-int
-read_history (filename)
- char *filename;
-{
- char *input = history_filename (filename);
- FILE *file = fopen (input, "r");
- char *line = (char *)xmalloc (TYPICAL_LINE_SIZE);
- int line_size = TYPICAL_LINE_SIZE;
- int done = 0;
-
- if (!file)
- {
- extern int errno;
- free (line);
- return (errno);
- }
-
- while (!done)
- {
- int c;
- int i;
-
- i = 0;
- while (!(done = ((c = getc (file)) == EOF)))
- {
- if (c == '\n')
- break;
-
- line [i++] = c;
- if (i == line_size)
- line = (char *)xrealloc (line, line_size += TYPICAL_LINE_SIZE);
- }
- line[i] = '\0';
- if (line[0])
- add_history (line);
- }
- free (line);
- fclose (file);
- return (0);
-}
-
-/* Overwrite FILENAME with the current history. If FILENAME is NULL,
- then write the history list to ~/.history. Values returned
- are as in read_history ().*/
-int
-write_history (filename)
- char *filename;
-{
- extern int errno;
- char *output = history_filename (filename);
- FILE *file = fopen (output, "w");
- register int i;
-
- if (!file) return (errno);
- if (!history_length) return (0);
-
- for (i = 0; i < history_length; i++)
- fprintf (file, "%s\n", the_history[i]->line);
-
- fclose (file);
- return (0);
-}
-
-/* Return the history entry at the current position, as determined by
- history_offset. If there is no entry there, return a NULL pointer. */
-HIST_ENTRY *
-current_history ()
-{
- if ((history_offset == history_length) || !the_history)
- return ((HIST_ENTRY *)NULL);
- else
- return (the_history[history_offset]);
-}
-
-/* Back up history_offset to the previous history entry, and return
- a pointer to that entry. If there is no previous entry then return
- a NULL pointer. */
-HIST_ENTRY *
-previous_history ()
-{
- if (!history_offset)
- return ((HIST_ENTRY *)NULL);
- else
- return (the_history[--history_offset]);
-}
-
-/* Move history_offset forward to the next history entry, and return
- a pointer to that entry. If there is no next entry then return a
- NULL pointer. */
-HIST_ENTRY *
-next_history ()
-{
- if (history_offset == history_length)
- return ((HIST_ENTRY *)NULL);
- else
- return (the_history[++history_offset]);
-}
-
-/* Return the current history array. The caller has to be carefull, since this
- is the actual array of data, and could be bashed or made corrupt easily.
- The array is terminated with a NULL pointer. */
-HIST_ENTRY **
-history_list ()
-{
- return (the_history);
-}
-
-/* Return the history entry which is logically at OFFSET in the history array.
- OFFSET is relative to history_base. */
-HIST_ENTRY *
-history_get (offset)
- int offset;
-{
- int index = offset - history_base;
-
- if (index >= history_length ||
- index < 0 ||
- !the_history)
- return ((HIST_ENTRY *)NULL);
- return (the_history[index]);
-}
-
-/* Search for STRING in the history list. DIR is < 0 for searching
- backwards. POS is an absolute index into the history list at
- which point to begin searching. */
-int
-history_search_pos (string, dir, pos)
- char *string;
- int dir, pos;
-{
- int ret, old = where_history ();
- history_set_pos (pos);
- if (history_search (string, dir) == -1)
- {
- history_set_pos (old);
- return (-1);
- }
- ret = where_history ();
- history_set_pos (old);
- return ret;
-}
-
-/* Make the current history item be the one at POS, an absolute index.
- Returns zero if POS is out of range, else non-zero. */
-int
-history_set_pos (pos)
- int pos;
-{
- if (pos > history_length || pos < 0 || !the_history)
- return (0);
- history_offset = pos;
- return (1);
-}
-
-
-/* **************************************************************** */
-/* */
-/* History Expansion */
-/* */
-/* **************************************************************** */
-
-/* Hairy history expansion on text, not tokens. This is of general
- use, and thus belongs in this library. */
-
-/* The last string searched for in a !?string? search. */
-static char *search_string = (char *)NULL;
-
-/* Return the event specified at TEXT + OFFSET modifying OFFSET to
- point to after the event specifier. Just a pointer to the history
- line is returned; NULL is returned in the event of a bad specifier.
- You pass STRING with *INDEX equal to the history_expansion_char that
- begins this specification.
- DELIMITING_QUOTE is a character that is allowed to end the string
- specification for what to search for in addition to the normal
- characters `:', ` ', `\t', `\n', and sometimes `?'.
- So you might call this function like:
- line = get_history_event ("!echo:p", &index, 0); */
-char *
-get_history_event (string, caller_index, delimiting_quote)
- char *string;
- int *caller_index;
- int delimiting_quote;
-{
- register int i = *caller_index;
- int which, sign = 1;
- HIST_ENTRY *entry;
-
- /* The event can be specified in a number of ways.
-
- !! the previous command
- !n command line N
- !-n current command-line minus N
- !str the most recent command starting with STR
- !?str[?]
- the most recent command containing STR
-
- All values N are determined via HISTORY_BASE. */
-
- if (string[i] != history_expansion_char)
- return ((char *)NULL);
-
- /* Move on to the specification. */
- i++;
-
- /* Handle !! case. */
- if (string[i] == history_expansion_char)
- {
- i++;
- which = history_base + (history_length - 1);
- *caller_index = i;
- goto get_which;
- }
-
- /* Hack case of numeric line specification. */
- read_which:
- if (string[i] == '-')
- {
- sign = -1;
- i++;
- }
-
- if (digit (string[i]))
- {
- int start = i;
-
- /* Get the extent of the digits. */
- for (; digit (string[i]); i++);
-
- /* Get the digit value. */
- sscanf (string + start, "%d", &which);
-
- *caller_index = i;
-
- if (sign < 0)
- which = (history_length + history_base) - which;
-
- get_which:
- if (entry = history_get (which))
- return (entry->line);
-
- return ((char *)NULL);
- }
-
- /* This must be something to search for. If the spec begins with
- a '?', then the string may be anywhere on the line. Otherwise,
- the string must be found at the start of a line. */
- {
- int index;
- char *temp;
- int substring_okay = 0;
-
- if (string[i] == '?')
- {
- substring_okay++;
- i++;
- }
-
- for (index = i; string[i]; i++)
- if (whitespace (string[i]) ||
- string[i] == '\n' ||
- string[i] == ':' ||
- (substring_okay && string[i] == '?') ||
- string[i] == delimiting_quote)
- break;
-
- temp = (char *)alloca (1 + (i - index));
- strncpy (temp, &string[index], (i - index));
- temp[i - index] = '\0';
-
- if (string[i] == '?')
- i++;
-
- *caller_index = i;
-
- search_again:
-
- index = history_search (temp, -1);
-
- if (index < 0)
- search_lost:
- {
- history_offset = history_length;
- return ((char *)NULL);
- }
-
- if (index == 0 || substring_okay ||
- (strncmp (temp, the_history[history_offset]->line,
- strlen (temp)) == 0))
- {
- search_won:
- entry = current_history ();
- history_offset = history_length;
-
- /* If this was a substring search, then remember the string that
- we matched for word substitution. */
- if (substring_okay)
- {
- if (search_string)
- free (search_string);
- search_string = savestring (temp);
- }
-
- return (entry->line);
- }
-
- if (history_offset)
- history_offset--;
- else
- goto search_lost;
-
- goto search_again;
- }
-}
-
-/* Expand the string STRING, placing the result into OUTPUT, a pointer
- to a string. Returns:
-
- 0) If no expansions took place (or, if the only change in
- the text was the de-slashifying of the history expansion
- character)
- 1) If expansions did take place
- -1) If there was an error in expansion.
-
- If an error ocurred in expansion, then OUTPUT contains a descriptive
- error message. */
-int
-history_expand (string, output)
- char *string;
- char **output;
-{
- register int j, l = strlen (string);
- int i, word_spec_error = 0;
- int cc, modified = 0;
- char *word_spec, *event;
- int starting_index, only_printing = 0, substitute_globally = 0;
-
- char *get_history_word_specifier (), *rindex ();
-
- /* The output string, and its length. */
- int len = 0;
- char *result = (char *)NULL;
-
- /* Used in add_string; */
- char *temp, tt[2], tbl[3];
-
- /* Prepare the buffer for printing error messages. */
- result = (char *)xmalloc (len = 255);
-
- result[0] = tt[1] = tbl[2] = '\0';
- tbl[0] = '\\';
- tbl[1] = history_expansion_char;
-
- /* Grovel the string. Only backslash can quote the history escape
- character. We also handle arg specifiers. */
-
- /* Before we grovel forever, see if the history_expansion_char appears
- anywhere within the text. */
-
- /* The quick substitution character is a history expansion all right. That
- is to say, "^this^that^" is equivalent to "!!:s^this^that^", and in fact,
- that is the substitution that we do. */
- if (string[0] == history_subst_char)
- {
- char *format_string = (char *)alloca (10 + strlen (string));
-
- sprintf (format_string, "%c%c:s%s",
- history_expansion_char, history_expansion_char,
- string);
- string = format_string;
- l += 4;
- goto grovel;
- }
-
- /* If not quick substitution, still maybe have to do expansion. */
-
- /* `!' followed by one of the characters in history_no_expand_chars
- is NOT an expansion. */
- for (i = 0; string[i]; i++)
- if (string[i] == history_expansion_char)
- if (!string[i + 1] || member (string[i + 1], history_no_expand_chars))
- continue;
- else
- goto grovel;
-
- free (result);
- *output = savestring (string);
- return (0);
-
- grovel:
-
- for (i = j = 0; i < l; i++)
- {
- int tchar = string[i];
- if (tchar == history_expansion_char)
- tchar = -3;
-
- switch (tchar)
- {
- case '\\':
- if (string[i + 1] == history_expansion_char)
- {
- i++;
- temp = tbl;
- goto do_add;
- }
- else
- goto add_char;
-
- /* case history_expansion_char: */
- case -3:
- starting_index = i + 1;
- cc = string[i + 1];
-
- /* If the history_expansion_char is followed by one of the
- characters in history_no_expand_chars, then it is not a
- candidate for expansion of any kind. */
- if (member (cc, history_no_expand_chars))
- goto add_char;
-
- /* There is something that is listed as a `word specifier' in csh
- documentation which means `the expanded text to this point'.
- That is not a word specifier, it is an event specifier. */
-
- if (cc == '#')
- goto hack_pound_sign;
-
- /* If it is followed by something that starts a word specifier,
- then !! is implied as the event specifier. */
-
- if (member (cc, ":$*%^"))
- {
- char fake_s[2];
- int fake_i = 0;
- i++;
- fake_s[0] = fake_s[1] = history_expansion_char;
- fake_s[2] = '\0';
- event = get_history_event (fake_s, &fake_i);
- }
- else
- {
- int quoted_search_delimiter = 0;
-
- /* If the character before this `!' is a double or single
- quote, then this expansion takes place inside of the
- quoted string. If we have to search for some text ("!foo"),
- allow the delimiter to end the search string. */
- if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
- quoted_search_delimiter = string[i - 1];
-
- event = get_history_event (string, &i, quoted_search_delimiter);
- }
-
- if (!event)
- event_not_found:
- {
- int l = 1 + (i - starting_index);
-
- temp = (char *)alloca (1 + l);
- strncpy (temp, string + starting_index, l);
- temp[l - 1] = 0;
- sprintf (result, "%s: %s.", temp,
- word_spec_error ? "Bad word specifier" : "Event not found");
- error_exit:
- *output = result;
- return (-1);
- }
-
- /* If a word specifier is found, then do what that requires. */
- starting_index = i;
-
- word_spec = get_history_word_specifier (string, event, &i);
-
- /* There is no such thing as a `malformed word specifier'. However,
- it is possible for a specifier that has no match. In that case,
- we complain. */
- if (word_spec == (char *)-1)
- bad_word_spec:
- {
- word_spec_error++;
- goto event_not_found;
- }
-
- /* If no word specifier, than the thing of interest was the event. */
- if (!word_spec)
- temp = event;
- else
- {
- temp = (char *)alloca (1 + strlen (word_spec));
- strcpy (temp, word_spec);
- free (word_spec);
- }
-
- /* Perhaps there are other modifiers involved. Do what they say. */
-
- hack_specials:
-
- if (string[i] == ':')
- {
- char *tstr;
-
- switch (string[i + 1])
- {
- /* :p means make this the last executed line. So we
- return an error state after adding this line to the
- history. */
- case 'p':
- only_printing++;
- goto next_special;
-
- /* :t discards all but the last part of the pathname. */
- case 't':
- tstr = rindex (temp, '/');
- if (tstr)
- temp = ++tstr;
- goto next_special;
-
- /* :h discards the last part of a pathname. */
- case 'h':
- tstr = rindex (temp, '/');
- if (tstr)
- *tstr = '\0';
- goto next_special;
-
- /* :r discards the suffix. */
- case 'r':
- tstr = rindex (temp, '.');
- if (tstr)
- *tstr = '\0';
- goto next_special;
-
- /* :e discards everything but the suffix. */
- case 'e':
- tstr = rindex (temp, '.');
- if (tstr)
- temp = tstr;
- goto next_special;
-
- /* :s/this/that substitutes `this' for `that'. */
- /* :gs/this/that substitutes `this' for `that' globally. */
- case 'g':
- if (string[i + 2] == 's')
- {
- i++;
- substitute_globally = 1;
- goto substitute;
- }
- else
-
- case 's':
- substitute:
- {
- char *this, *that, *new_event;
- int delimiter = 0;
- int si, l_this, l_that, l_temp = strlen (temp);
-
- if (i + 2 < strlen (string))
- delimiter = string[i + 2];
-
- if (!delimiter)
- break;
-
- i += 3;
-
- /* Get THIS. */
- for (si = i; string[si] && string[si] != delimiter; si++);
- l_this = (si - i);
- this = (char *)alloca (1 + l_this);
- strncpy (this, string + i, l_this);
- this[l_this] = '\0';
-
- i = si;
- if (string[si])
- i++;
-
- /* Get THAT. */
- for (si = i; string[si] && string[si] != delimiter; si++);
- l_that = (si - i);
- that = (char *)alloca (1 + l_that);
- strncpy (that, string + i, l_that);
- that[l_that] = '\0';
-
- i = si;
- if (string[si]) i++;
-
- /* Ignore impossible cases. */
- if (l_this > l_temp)
- goto cant_substitute;
-
- /* Find the first occurrence of THIS in TEMP. */
- si = 0;
- for (; (si + l_this) <= l_temp; si++)
- if (strncmp (temp + si, this, l_this) == 0)
- {
- new_event =
- (char *)alloca (1 + (l_that - l_this) + l_temp);
- strncpy (new_event, temp, si);
- strncpy (new_event + si, that, l_that);
- strncpy (new_event + si + l_that,
- temp + si + l_this,
- l_temp - (si + l_this));
- new_event[(l_that - l_this) + l_temp] = '\0';
- temp = new_event;
-
- if (substitute_globally)
- {
- si += l_that;
- l_temp = strlen (temp);
- substitute_globally++;
- continue;
- }
-
- goto hack_specials;
- }
-
- cant_substitute:
-
- if (substitute_globally > 1)
- {
- substitute_globally = 0;
- goto hack_specials;
- }
-
- goto event_not_found;
- }
-
- /* :# is the line so far. Note that we have to
- alloca () it since RESULT could be realloc ()'ed
- below in add_string. */
- case '#':
- hack_pound_sign:
- if (result)
- {
- temp = (char *)alloca (1 + strlen (result));
- strcpy (temp, result);
- }
- else
- temp = "";
-
- next_special:
- i += 2;
- goto hack_specials;
- }
-
- }
- /* Believe it or not, we have to back the pointer up by one. */
- --i;
- goto add_string;
-
- /* A regular character. Just add it to the output string. */
- default:
- add_char:
- tt[0] = string[i];
- temp = tt;
- goto do_add;
-
- add_string:
- modified++;
-
- do_add:
- j += strlen (temp);
- while (j > len)
- result = (char *)xrealloc (result, (len += 255));
-
- strcpy (result + (j - strlen (temp)), temp);
- }
- }
-
- *output = result;
-
- if (only_printing)
- {
- add_history (result);
- return (-1);
- }
-
- return (modified != 0);
-}
-
-/* Return a consed string which is the word specified in SPEC, and found
- in FROM. NULL is returned if there is no spec. -1 is returned if
- the word specified cannot be found. CALLER_INDEX is the offset in
- SPEC to start looking; it is updated to point to just after the last
- character parsed. */
-char *
-get_history_word_specifier (spec, from, caller_index)
- char *spec, *from;
- int *caller_index;
-{
- register int i = *caller_index;
- int first, last;
- int expecting_word_spec = 0;
- char *history_arg_extract ();
-
- /* The range of words to return doesn't exist yet. */
- first = last = 0;
-
- /* If we found a colon, then this *must* be a word specification. If
- it isn't, then it is an error. */
- if (spec[i] == ':')
- i++, expecting_word_spec++;
-
- /* Handle special cases first. */
-
- /* `%' is the word last searched for. */
- if (spec[i] == '%')
- {
- *caller_index = i + 1;
- if (search_string)
- return (savestring (search_string));
- else
- return (savestring (""));
- }
-
- /* `*' matches all of the arguments, but not the command. */
- if (spec[i] == '*')
- {
- *caller_index = i + 1;
- return (history_arg_extract (1, '$', from));
- }
-
- /* `$' is last arg. */
- if (spec[i] == '$')
- {
- *caller_index = i + 1;
- return (history_arg_extract ('$', '$', from));
- }
-
- /* Try to get FIRST and LAST figured out. */
- if (spec[i] == '-' || spec[i] == '^')
- {
- first = 1;
- goto get_last;
- }
-
- get_first:
- if (digit (spec[i]) && expecting_word_spec)
- {
- sscanf (spec + i, "%d", &first);
- for (; digit (spec[i]); i++);
- }
- else
- return ((char *)NULL);
-
- get_last:
- if (spec[i] == '^')
- {
- i++;
- last = 1;
- goto get_args;
- }
-
- if (spec[i] != '-')
- {
- last = first;
- goto get_args;
- }
-
- i++;
-
- if (digit (spec[i]))
- {
- sscanf (spec + i, "%d", &last);
- for (; digit (spec[i]); i++);
- }
- else
- if (spec[i] == '$')
- {
- i++;
- last = '$';
- }
-
- get_args:
- {
- char *result = (char *)NULL;
-
- *caller_index = i;
-
- if (last >= first)
- result = history_arg_extract (first, last, from);
-
- if (result)
- return (result);
- else
- return ((char *)-1);
- }
-}
-
-/* Extract the args specified, starting at FIRST, and ending at LAST.
- The args are taken from STRING. */
-char *
-history_arg_extract (first, last, string)
- int first, last;
- char *string;
-{
- register int i, len;
- char *result = (char *)NULL;
- int size = 0, offset = 0;
-
- char **history_tokenize (), **list;
-
- if (!(list = history_tokenize (string)))
- return ((char *)NULL);
-
- for (len = 0; list[len]; len++);
-
- if (last == '$')
- last = len - 1;
-
- if (first == '$')
- first = len - 1;
-
- last++;
-
- if (first > len || last > len)
- result = ((char *)NULL);
- else {
- for (i = first; i < last; i++)
- {
- int l = strlen (list[i]);
-
- if (!result)
- result = (char *)xmalloc ((size = (2 + l)));
- else
- result = (char *)xrealloc (result, (size += (2 + l)));
- strcpy (result + offset, list[i]);
- offset += l;
- if (i + 1 < last)
- {
- strcpy (result + offset, " ");
- offset++;
- }
- }
- }
-
- for (i = 0; i < len; i++)
- free (list[i]);
-
- free (list);
-
- return (result);
-}
-
-#define slashify_in_quotes "\\`\"$"
-
-/* Return an array of tokens, much as the shell might. The tokens are
- parsed out of STRING. */
-char **
-history_tokenize (string)
- char *string;
-{
- char **result = (char **)NULL;
- register int i, start, result_index, size;
- int len;
-
- i = result_index = size = 0;
-
- /* Get a token, and stuff it into RESULT. The tokens are split
- exactly where the shell would split them. */
- get_token:
-
- /* Skip leading whitespace. */
- for (; string[i] && whitespace(string[i]); i++);
-
- start = i;
-
- if (!string[i] || string[i] == history_comment_char)
- return (result);
-
- if (member (string[i], "()\n")) {
- i++;
- goto got_token;
- }
-
- if (member (string[i], "<>;&|")) {
- int peek = string[i + 1];
-
- if (peek == string[i]) {
- if (peek == '<') {
- if (string[1 + 2] == '-')
- i++;
- i += 2;
- goto got_token;
- }
-
- if (member (peek, ">:&|")) {
- i += 2;
- goto got_token;
- }
- } else {
- if ((peek == '&' &&
- (string[i] == '>' || string[i] == '<')) ||
- ((peek == '>') &&
- (string[i] == '&'))) {
- i += 2;
- goto got_token;
- }
- }
- i++;
- goto got_token;
- }
-
- /* Get word from string + i; */
- {
- int delimiter = 0;
-
- if (member (string[i], "\"'`"))
- delimiter = string[i++];
-
- for (;string[i]; i++) {
-
- if (string[i] == '\\') {
-
- if (string[i + 1] == '\n') {
- i++;
- continue;
- } else {
- if (delimiter != '\'')
- if ((delimiter != '"') ||
- (member (string[i], slashify_in_quotes))) {
- i++;
- continue;
- }
- }
- }
-
- if (delimiter && string[i] == delimiter) {
- delimiter = 0;
- continue;
- }
-
- if (!delimiter && (member (string[i], " \t\n;&()|<>")))
- goto got_token;
-
- if (!delimiter && member (string[i], "\"'`")) {
- delimiter = string[i];
- continue;
- }
- }
- got_token:
-
- len = i - start;
- if (result_index + 2 >= size) {
- if (!size)
- result = (char **)xmalloc ((size = 10) * (sizeof (char *)));
- else
- result =
- (char **)xrealloc (result, ((size += 10) * (sizeof (char *))));
- }
- result[result_index] = (char *)xmalloc (1 + len);
- strncpy (result[result_index], string + start, len);
- result[result_index][len] = '\0';
- result_index++;
- result[result_index] = (char *)NULL;
- }
- if (string[i])
- goto get_token;
-
- return (result);
-}
-
-#ifdef STATIC_MALLOC
-
-/* **************************************************************** */
-/* */
-/* xmalloc and xrealloc () */
-/* */
-/* **************************************************************** */
-
-static char *
-xmalloc (bytes)
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)malloc (bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static char *
-xrealloc (pointer, bytes)
- char *pointer;
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)realloc (pointer, bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static
-memory_error_and_abort ()
-{
- fprintf (stderr, "history: Out of virtual memory!\n");
- abort ();
-}
-#endif /* STATIC_MALLOC */
-
-
-/* **************************************************************** */
-/* */
-/* Test Code */
-/* */
-/* **************************************************************** */
-#ifdef TEST
-main ()
-{
- char line[1024], *t;
- int done = 0;
-
- line[0] = 0;
-
- while (!done)
- {
- fprintf (stdout, "history%% ");
- t = gets (line);
-
- if (!t)
- strcpy (line, "quit");
-
- if (line[0])
- {
- char *expansion;
- int result;
-
- using_history ();
-
- result = history_expand (line, &expansion);
- strcpy (line, expansion);
- free (expansion);
- if (result)
- fprintf (stderr, "%s\n", line);
-
- if (result < 0)
- continue;
-
- add_history (line);
- }
-
- if (strcmp (line, "quit") == 0) done = 1;
- if (strcmp (line, "save") == 0) write_history (0);
- if (strcmp (line, "read") == 0) read_history (0);
- if (strcmp (line, "list") == 0)
- {
- register HIST_ENTRY **the_list = history_list ();
- register int i;
-
- if (the_list)
- for (i = 0; the_list[i]; i++)
- fprintf (stdout, "%d: %s\n", i + history_base, the_list[i]->line);
- }
- if (strncmp (line, "delete", strlen ("delete")) == 0)
- {
- int which;
- if ((sscanf (line + strlen ("delete"), "%d", &which)) == 1)
- {
- HIST_ENTRY *entry = remove_history (which);
- if (!entry)
- fprintf (stderr, "No such entry %d\n", which);
- else
- {
- free (entry->line);
- free (entry);
- }
- }
- else
- {
- fprintf (stderr, "non-numeric arg given to `delete'\n");
- }
- }
- }
-}
-
-#endif /* TEST */
-
-/*
-* Local variables:
-* compile-command: "gcc -g -DTEST -o history history.c"
-* end:
-*/
diff --git a/gnu/usr.bin/gdb/readline/history.h b/gnu/usr.bin/gdb/readline/history.h
deleted file mode 100644
index 0bac209..0000000
--- a/gnu/usr.bin/gdb/readline/history.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* History.h -- the names of functions that you can call in history. */
-
-typedef struct _hist_entry {
- char *line;
- char *data;
-} HIST_ENTRY;
-
-/* For convenience only. You set this when interpreting history commands.
- It is the logical offset of the first history element. */
-extern int history_base;
-
-/* Begin a session in which the history functions might be used. This
- just initializes the interactive variables. */
-extern void using_history ();
-
-/* Place STRING at the end of the history list.
- The associated data field (if any) is set to NULL. */
-extern void add_history ();
-
-/* Returns the number which says what history element we are now
- looking at. */
-extern int where_history ();
-
-/* Set the position in the history list to POS. */
-int history_set_pos ();
-
-/* Search for STRING in the history list, starting at POS, an
- absolute index into the list. DIR, if negative, says to search
- backwards from POS, else forwards.
- Returns the absolute index of the history element where STRING
- was found, or -1 otherwise. */
-extern int history_search_pos ();
-
-/* A reasonably useless function, only here for completeness. WHICH
- is the magic number that tells us which element to delete. The
- elements are numbered from 0. */
-extern HIST_ENTRY *remove_history ();
-
-/* Stifle the history list, remembering only MAX number of entries. */
-extern void stifle_history ();
-
-/* Stop stifling the history. This returns the previous amount the
- history was stifled by. The value is positive if the history was
- stifled, negative if it wasn't. */
-extern int unstifle_history ();
-
-/* Add the contents of FILENAME to the history list, a line at a time.
- If FILENAME is NULL, then read from ~/.history. Returns 0 if
- successful, or errno if not. */
-extern int read_history ();
-
-/* Append the current history to FILENAME. If FILENAME is NULL,
- then append the history list to ~/.history. Values returned
- are as in read_history (). */
-extern int write_history ();
-
-
-/* Make the history entry at WHICH have LINE and DATA. This returns
- the old entry so you can dispose of the data. In the case of an
- invalid WHICH, a NULL pointer is returned. */
-extern HIST_ENTRY *replace_history_entry ();
-
-/* Return the history entry at the current position, as determined by
- history_offset. If there is no entry there, return a NULL pointer. */
-HIST_ENTRY *current_history ();
-
-/* Back up history_offset to the previous history entry, and return
- a pointer to that entry. If there is no previous entry, return
- a NULL pointer. */
-extern HIST_ENTRY *previous_history ();
-
-/* Move history_offset forward to the next item in the input_history,
- and return the a pointer to that entry. If there is no next entry,
- return a NULL pointer. */
-extern HIST_ENTRY *next_history ();
-
-/* Return a NULL terminated array of HIST_ENTRY which is the current input
- history. Element 0 of this list is the beginning of time. If there
- is no history, return NULL. */
-extern HIST_ENTRY **history_list ();
-
-/* Search the history for STRING, starting at history_offset.
- If DIRECTION < 0, then the search is through previous entries,
- else through subsequent. If the string is found, then
- current_history () is the history entry, and the value of this function
- is the offset in the line of that history entry that the string was
- found in. Otherwise, nothing is changed, and a -1 is returned. */
-extern int history_search ();
-
-/* Expand the string STRING, placing the result into OUTPUT, a pointer
- to a string. Returns:
-
- 0) If no expansions took place (or, if the only change in
- the text was the de-slashifying of the history expansion
- character)
- 1) If expansions did take place
- -1) If there was an error in expansion.
-
- If an error ocurred in expansion, then OUTPUT contains a descriptive
- error message. */
-extern int history_expand ();
-
-/* Extract a string segment consisting of the FIRST through LAST
- arguments present in STRING. Arguments are broken up as in
- the shell. */
-extern char *history_arg_extract ();
-
-
diff --git a/gnu/usr.bin/gdb/readline/keymaps.c b/gnu/usr.bin/gdb/readline/keymaps.c
deleted file mode 100644
index e0c5e39..0000000
--- a/gnu/usr.bin/gdb/readline/keymaps.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
-
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
-
- This file is part of GNU Readline, a library for reading lines
- of text with interactive input and history editing.
-
- Readline is free software; you can 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.
-
- Readline is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "keymaps.h"
-#include "emacs_keymap.c"
-
-#ifdef VI_MODE
-#include "vi_keymap.c"
-#endif
-
-/* Remove these declarations when we have a complete libgnu.a. */
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
-extern char *xmalloc (), *xrealloc ();
-#else
-static char *xmalloc (), *xrealloc ();
-#endif
-
-/* **************************************************************** */
-/* */
-/* Functions for manipulating Keymaps. */
-/* */
-/* **************************************************************** */
-
-
-/* Return a new, empty keymap.
- Free it with free() when you are done. */
-Keymap
-rl_make_bare_keymap ()
-{
- register int i;
- Keymap keymap = (Keymap)xmalloc (128 * sizeof (KEYMAP_ENTRY));
-
- for (i = 0; i < 128; i++)
- {
- keymap[i].type = ISFUNC;
- keymap[i].function = (Function *)NULL;
- }
-
- for (i = 'A'; i < ('Z' + 1); i++)
- {
- keymap[i].type = ISFUNC;
- keymap[i].function = rl_do_lowercase_version;
- }
-
- return (keymap);
-}
-
-/* Return a new keymap which is a copy of MAP. */
-Keymap
-rl_copy_keymap (map)
- Keymap map;
-{
- register int i;
- Keymap temp = rl_make_bare_keymap ();
-
- for (i = 0; i < 128; i++)
- {
- temp[i].type = map[i].type;
- temp[i].function = map[i].function;
- }
- return (temp);
-}
-
-/* Return a new keymap with the printing characters bound to rl_insert,
- the uppercase Meta characters bound to run their lowercase equivalents,
- and the Meta digits bound to produce numeric arguments. */
-Keymap
-rl_make_keymap ()
-{
- extern rl_insert (), rl_rubout (), rl_do_lowercase_version ();
- extern rl_digit_argument ();
- register int i;
- Keymap newmap;
-
- newmap = rl_make_bare_keymap ();
-
- /* All printing characters are self-inserting. */
- for (i = ' '; i < 126; i++)
- newmap[i].function = rl_insert;
-
- newmap[TAB].function = rl_insert;
- newmap[RUBOUT].function = rl_rubout;
-
- return (newmap);
-}
-
-/* Free the storage associated with MAP. */
-rl_discard_keymap (map)
- Keymap (map);
-{
- int i;
-
- if (!map)
- return;
-
- for (i = 0; i < 128; i++)
- {
- switch (map[i].type)
- {
- case ISFUNC:
- break;
-
- case ISKMAP:
- rl_discard_keymap ((Keymap)map[i].function);
- break;
-
- case ISMACR:
- free ((char *)map[i].function);
- break;
- }
- }
-}
-
-#ifdef STATIC_MALLOC
-
-/* **************************************************************** */
-/* */
-/* xmalloc and xrealloc () */
-/* */
-/* **************************************************************** */
-
-static char *
-xmalloc (bytes)
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)malloc (bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static char *
-xrealloc (pointer, bytes)
- char *pointer;
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)realloc (pointer, bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static
-memory_error_and_abort ()
-{
- fprintf (stderr, "readline: Out of virtual memory!\n");
- abort ();
-}
-#endif /* STATIC_MALLOC */
diff --git a/gnu/usr.bin/gdb/readline/keymaps.h b/gnu/usr.bin/gdb/readline/keymaps.h
deleted file mode 100644
index 3c577b3..0000000
--- a/gnu/usr.bin/gdb/readline/keymaps.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* keymaps.h -- Manipulation of readline keymaps. */
-
-#ifndef _KEYMAPS_H_
-#define _KEYMAPS_H_
-
-#include <readline/chardefs.h>
-
-#ifndef __FUNCTION_DEF
-typedef int Function ();
-#define __FUNCTION_DEF
-#endif
-
-/* A keymap contains one entry for each key in the ASCII set.
- Each entry consists of a type and a pointer.
- POINTER is the address of a function to run, or the
- address of a keymap to indirect through.
- TYPE says which kind of thing POINTER is. */
-typedef struct _keymap_entry {
- char type;
- Function *function;
-} KEYMAP_ENTRY;
-
-/* I wanted to make the above structure contain a union of:
- union { Function *function; struct _keymap_entry *keymap; } value;
- but this made it impossible for me to create a static array.
- Maybe I need C lessons. */
-
-typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[128];
-typedef KEYMAP_ENTRY *Keymap;
-
-/* The values that TYPE can have in a keymap entry. */
-#define ISFUNC 0
-#define ISKMAP 1
-#define ISMACR 2
-
-extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
-extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
-
-/* Return a new, empty keymap.
- Free it with free() when you are done. */
-Keymap rl_make_bare_keymap ();
-
-/* Return a new keymap which is a copy of MAP. */
-Keymap rl_copy_keymap ();
-
-/* Return a new keymap with the printing characters bound to rl_insert,
- the lowercase Meta characters bound to run their equivalents, and
- the Meta digits bound to produce numeric arguments. */
-Keymap rl_make_keymap ();
-
-#endif /* _KEYMAPS_H_ */
-
-
diff --git a/gnu/usr.bin/gdb/readline/readline.c b/gnu/usr.bin/gdb/readline/readline.c
deleted file mode 100644
index a29efe1..0000000
--- a/gnu/usr.bin/gdb/readline/readline.c
+++ /dev/null
@@ -1,5557 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)readline.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* readline.c -- a general facility for reading lines of input
- with emacs style editing and completion. */
-
-/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
-
- This file contains the Readline Library (the Library), a set of
- routines for providing Emacs style line input to programs that ask
- for it.
-
- The Library is free software; you can 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.
-
- The 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
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Remove these declarations when we have a complete libgnu.a. */
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
-extern char *xmalloc (), *xrealloc ();
-#else
-static char *xmalloc (), *xrealloc ();
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <signal.h>
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#if defined (sparc) && defined (sun)
-#include <alloca.h>
-#endif
-#endif
-
-#define NEW_TTY_DRIVER
-#if defined (SYSV) || defined (hpux)
-#undef NEW_TTY_DRIVER
-#include <termio.h>
-#else
-#include <sgtty.h>
-#endif
-
-#include <errno.h>
-extern int errno;
-
-#include <setjmp.h>
-
-/* These next are for filename completion. Perhaps this belongs
- in a different place. */
-#include <sys/stat.h>
-
-#include <pwd.h>
-#ifdef SYSV
-struct passwd *getpwuid (), *getpwent ();
-#endif
-
-#define HACK_TERMCAP_MOTION
-
-#ifndef SYSV
-#include <sys/dir.h>
-#else /* SYSV */
-#ifdef hpux
-#include <ndir.h>
-#else
-#include <dirent.h>
-#define direct dirent
-#define d_namlen d_reclen
-#endif /* hpux */
-#endif /* SYSV */
-
-/* Some standard library routines. */
-#include "readline.h"
-#include "history.h"
-
-#ifndef digit
-#define digit(c) ((c) >= '0' && (c) <= '9')
-#endif
-
-#ifndef isletter
-#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
-#endif
-
-#ifndef digit_value
-#define digit_value(c) ((c) - '0')
-#endif
-
-#ifndef member
-char *index ();
-#define member(c, s) ((c) ? index ((s), (c)) : 0)
-#endif
-
-#ifndef isident
-#define isident(c) ((isletter(c) || digit(c) || c == '_'))
-#endif
-
-#ifndef exchange
-#define exchange(x, y) {int temp = x; x = y; y = temp;}
-#endif
-
-static update_line ();
-static void output_character_function ();
-static delete_chars ();
-static start_insert ();
-static end_insert ();
-
-/* This typedef is equivalant to the one for Function; it allows us
- to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
-typedef void SigHandler ();
-
-#ifdef SIGWINCH
-static void rl_handle_sigwinch ();
-static SigHandler *old_sigwinch = (SigHandler *)NULL;
-#endif
-
-/* If on, then readline handles signals in a way that doesn't screw. */
-/* #define HANDLE_SIGNALS */
-
-#if defined (SYSV)
-#ifdef HANDLE_SIGNALS
-#undef HANDLE_SIGNALS
-#endif
-#endif
-
-/* Stupid comparison routine for qsort () ing strings. */
-static int
-compare_strings (s1, s2)
- char **s1, **s2;
-{
- return (strcmp (*s1, *s2));
-}
-
-
-/* **************************************************************** */
-/* */
-/* Line editing input utility */
-/* */
-/* **************************************************************** */
-
-/* A pointer to the keymap that is currently in use.
- By default, it is the standard emacs keymap. */
-Keymap keymap = emacs_standard_keymap;
-
-#define vi_mode 0
-#define emacs_mode 1
-
-/* The current style of editing. */
-int rl_editing_mode = emacs_mode;
-
-/* Non-zero if the previous command was a kill command. */
-static int last_command_was_kill = 0;
-
-/* The current value of the numeric argument specified by the user. */
-int rl_numeric_arg = 1;
-
-/* Non-zero if an argument was typed. */
-int rl_explicit_arg = 0;
-
-/* Temporary value used while generating the argument. */
-static int arg_sign = 1;
-
-/* Non-zero means we have been called at least once before. */
-static int rl_initialized = 0;
-
-/* If non-zero, this program is running in an EMACS buffer. */
-static char *running_in_emacs = (char *)NULL;
-
-/* The current offset in the current input line. */
-int rl_point;
-
-/* Mark in the current input line. */
-int rl_mark;
-
-/* Length of the current input line. */
-int rl_end;
-
-/* Make this non-zero to return the current input_line. */
-int rl_done;
-
-/* The last function executed by readline. */
-Function *rl_last_func = (Function *)NULL;
-
-/* Top level environment for readline_internal (). */
-static jmp_buf readline_top_level;
-
-/* The streams we interact with. */
-static FILE *in_stream, *out_stream;
-
-/* The names of the streams that we do input and output to. */
-FILE *rl_instream = stdin, *rl_outstream = stdout;
-
-/* Non-zero means echo characters as they are read. */
-int readline_echoing_p = 1;
-
-/* Current prompt. */
-char *rl_prompt;
-
-/* The number of characters read in order to type this complete command. */
-int rl_key_sequence_length = 0;
-
-/* If non-zero, then this is the address of a function to call just
- before readline_internal () prints the first prompt. */
-Function *rl_startup_hook = (Function *)NULL;
-
-/* What we use internally. You should always refer to RL_LINE_BUFFER. */
-static char *the_line;
-
-/* The character that can generate an EOF. Really read from
- the terminal driver... just defaulted here. */
-static int eof_char = CTRL ('D');
-
-/* Non-zero makes this the next keystroke to read. */
-int rl_pending_input = 0;
-
-/* Pointer to a useful terminal name. */
-char *rl_terminal_name = (char *)NULL;
-
-/* Line buffer and maintenence. */
-char *rl_line_buffer = (char *)NULL;
-static int rl_line_buffer_len = 0;
-#define DEFAULT_BUFFER_SIZE 256
-
-
-/* **************************************************************** */
-/* */
-/* Top Level Functions */
-/* */
-/* **************************************************************** */
-
-/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means
- none. A return value of NULL means that EOF was encountered. */
-char *
-readline (prompt)
- char *prompt;
-{
- static rl_prep_terminal (), rl_deprep_terminal ();
- char *readline_internal ();
- char *value;
-
- rl_prompt = prompt;
-
- /* If we are at EOF return a NULL string. */
- if (rl_pending_input == EOF)
- {
- rl_pending_input = 0;
- return ((char *)NULL);
- }
-
- rl_initialize ();
- rl_prep_terminal ();
-
-#ifdef SIGWINCH
- old_sigwinch = (SigHandler *)signal (SIGWINCH, rl_handle_sigwinch);
-#endif
-
-#ifdef HANDLE_SIGNALS
- rl_set_signals ();
-#endif
-
- value = readline_internal ();
- rl_deprep_terminal ();
-
-#ifdef SIGWINCH
- signal (SIGWINCH, old_sigwinch);
-#endif
-
-#ifdef HANDLE_SIGNALS
- rl_clear_signals ();
-#endif
-
- return (value);
-}
-
-/* Read a line of input from the global rl_instream, doing output on
- the global rl_outstream.
- If rl_prompt is non-null, then that is our prompt. */
-char *
-readline_internal ()
-{
- int lastc, c, eof_found;
-
- in_stream = rl_instream; out_stream = rl_outstream;
- lastc = eof_found = 0;
-
- if (rl_startup_hook)
- (*rl_startup_hook) ();
-
- if (!readline_echoing_p)
- {
- if (rl_prompt) {
- fprintf (out_stream, "%s", rl_prompt);
- fflush(out_stream);
- }
- }
- else
- {
- rl_on_new_line ();
- rl_redisplay ();
-#ifdef VI_MODE
- if (rl_editing_mode == vi_mode)
- rl_vi_insertion_mode ();
-#endif /* VI_MODE */
- }
-
- while (!rl_done)
- {
- int lk = last_command_was_kill;
- int code = setjmp (readline_top_level);
-
- if (code)
- rl_redisplay ();
-
- if (!rl_pending_input)
- {
- /* Then initialize the argument and number of keys read. */
- rl_init_argument ();
- rl_key_sequence_length = 0;
- }
-
- c = rl_read_key ();
-
- /* EOF typed to a non-blank line is a <NL>. */
- if (c == EOF && rl_end)
- c = NEWLINE;
-
- /* The character eof_char typed to blank line, and not as the
- previous character is interpreted as EOF. */
- if (((c == eof_char && lastc != c) || c == EOF) && !rl_end)
- {
- eof_found = 1;
- break;
- }
-
- lastc = c;
- rl_dispatch (c, keymap);
-
- /* If there was no change in last_command_was_kill, then no kill
- has taken place. Note that if input is pending we are reading
- a prefix command, so nothing has changed yet. */
- if (!rl_pending_input)
- {
- if (lk == last_command_was_kill)
- last_command_was_kill = 0;
- }
-
-#ifdef VI_MODE
- /* In vi mode, when you exit insert mode, the cursor moves back
- over the previous character. We explicitly check for that here. */
- if (rl_editing_mode == vi_mode && keymap == vi_movement_keymap)
- rl_vi_check ();
-#endif
-
- if (!rl_done)
- rl_redisplay ();
- }
-
- /* Restore the original of this history line, iff the line that we
- are editing was originally in the history, AND the line has changed. */
- {
- HIST_ENTRY *entry = current_history ();
-
- if (entry && rl_undo_list)
- {
- char *temp = savestring (the_line);
- rl_revert_line ();
- entry = replace_history_entry (where_history (), the_line,
- (HIST_ENTRY *)NULL);
- free_history_entry (entry);
-
- strcpy (the_line, temp);
- free (temp);
- }
- }
-
- /* At any rate, it is highly likely that this line has an undo list. Get
- rid of it now. */
- if (rl_undo_list)
- free_undo_list ();
-
- if (eof_found)
- return (char *)NULL;
- else
- return (savestring (the_line));
-}
-
-
-/* Variables for keyboard macros. */
-
-/* The currently executing macro string. If this is non-zero,
- then it is a malloc ()'ed string where input is coming from. */
-static char *executing_macro = (char *)NULL;
-
-/* The offset in the above string to the next character to be read. */
-static int executing_macro_index = 0;
-
-/* Non-zero means to save keys that we dispatch on in a kbd macro. */
-static int defining_kbd_macro = 0;
-
-/* The current macro string being built. Characters get stuffed
- in here by add_macro_char (). */
-static char *current_macro = (char *)NULL;
-
-/* The size of the buffer allocated to current_macro. */
-static int current_macro_size = 0;
-
-/* The index at which characters are being added to current_macro. */
-static int current_macro_index = 0;
-
-/* A structure used to save nested macro strings.
- It is a linked list of string/index for each saved macro. */
-struct saved_macro {
- struct saved_macro *next;
- char *string;
- int index;
-};
-
-/* The list of saved macros. */
-struct saved_macro *macro_list = (struct saved_macro *)NULL;
-
-
-/* **************************************************************** */
-/* */
-/* Signal Handling */
-/* */
-/* **************************************************************** */
-
-#ifdef SIGWINCH
-static void
-rl_handle_sigwinch (sig, code, scp)
- int sig, code;
- struct sigcontext *scp;
-{
- char *term = rl_terminal_name, *getenv ();
-
- if (readline_echoing_p)
- {
- if (!term)
- term = getenv ("TERM");
- if (!term)
- term = "dumb";
- rl_reset_terminal (term);
-#ifdef NEVER
- crlf ();
- rl_forced_update_display ();
-#endif
- }
-
- if (old_sigwinch &&
- old_sigwinch != (SigHandler *)SIG_IGN &&
- old_sigwinch != (SigHandler *)SIG_DFL)
- (*old_sigwinch)(sig, code, scp);
-}
-#endif /* SIGWINCH */
-
-#ifdef HANDLE_SIGNALS
-/* Interrupt handling. */
-static SigHandler *old_int = (SigHandler *)NULL,
- *old_tstp = (SigHandler *)NULL,
- *old_ttou = (SigHandler *)NULL,
- *old_ttin = (SigHandler *)NULL,
- *old_cont = (SigHandler *)NULL;
-
-/* Handle an interrupt character. */
-static void
-rl_signal_handler (sig, code, scp)
- int sig, code;
- struct sigcontext *scp;
-{
- static rl_prep_terminal (), rl_deprep_terminal ();
-
- switch (sig)
- {
- case SIGINT:
- free_undo_list ();
- rl_clear_message ();
- rl_init_argument ();
-#ifdef SIGWINCH
- signal (SIGWINCH, old_sigwinch);
-#endif
-
-#ifdef SIGTSTP
- case SIGTSTP:
- case SIGTTOU:
- case SIGTTIN:
-#endif
-
- rl_clean_up_for_exit ();
- rl_deprep_terminal ();
- rl_clear_signals ();
- rl_pending_input = 0;
-
- kill (getpid (), sig);
- sigsetmask (0);
-
- rl_prep_terminal ();
- rl_set_signals ();
- }
-}
-
-rl_set_signals ()
-{
- old_int = (SigHandler *)signal (SIGINT, rl_signal_handler);
-
- if (old_int == (SigHandler *)SIG_IGN)
- signal (SIGINT, SIG_IGN);
-
-#ifdef SIGTSTP
- old_tstp = (SigHandler *)signal (SIGTSTP, rl_signal_handler);
- if (old_tstp == (SigHandler *)SIG_IGN)
- signal (SIGTSTP, SIG_IGN);
-#endif
-#ifdef SIGTTOU
- old_ttou = (SigHandler *)signal (SIGTTOU, rl_signal_handler);
- old_ttin = (SigHandler *)signal (SIGTTIN, rl_signal_handler);
-#endif
-}
-
-rl_clear_signals ()
-{
- signal (SIGINT, old_int);
-
-#ifdef SIGTSTP
- signal (SIGTSTP, old_tstp);
-#endif
-#ifdef SIGTTOU
- signal (SIGTTOU, old_ttou);
- signal (SIGTTIN, old_ttin);
-#endif
-}
-#endif /* HANDLE_SIGNALS */
-
-
-
-/* **************************************************************** */
-/* */
-/* Character Input Buffering */
-/* */
-/* **************************************************************** */
-
-/* If the terminal was in xoff state when we got to it, then xon_char
- contains the character that is supposed to start it again. */
-static int xon_char, xoff_state;
-static int pop_index = 0, push_index = 0, ibuffer_len = 511;
-static unsigned char ibuffer[512];
-
-/* Non-null means it is a pointer to a function to run while waiting for
- character input. */
-Function *rl_event_hook = (Function *)NULL;
-
-#define any_typein (push_index != pop_index)
-
-/* Add KEY to the buffer of characters to be read. */
-rl_stuff_char (key)
- int key;
-{
- if (key == EOF)
- {
- key = NEWLINE;
- rl_pending_input = EOF;
- }
- ibuffer[push_index++] = key;
- if (push_index >= ibuffer_len)
- push_index = 0;
-}
-
-/* Return the amount of space available in the
- buffer for stuffing characters. */
-int
-ibuffer_space ()
-{
- if (pop_index > push_index)
- return (pop_index - push_index);
- else
- return (ibuffer_len - (push_index - pop_index));
-}
-
-/* Get a key from the buffer of characters to be read.
- Result is KEY if there was a key, or -2 if there wasn't. */
-int
-rl_get_char ()
-{
- int key;
-
- if (push_index == pop_index)
- return (-2);
-
- key = ibuffer[pop_index++];
-
- if (pop_index >= ibuffer_len)
- pop_index = 0;
-
- return (key);
-}
-
-/* Stuff KEY into the *front* of the input buffer.
- Returns non-zero if successful, zero if there is
- no space left in the buffer. */
-int
-rl_unget_char (key)
- int key;
-{
- if (ibuffer_space ())
- {
- pop_index--;
- if (pop_index < 0)
- pop_index = ibuffer_len - 1;
- ibuffer[pop_index] = key;
- return (1);
- }
- return (0);
-}
-
-
-
-static void
-rl_getc (stream)
- FILE *stream;
-{
- int result;
- int nchar;
- int tty = fileno(stream);
- char buf[512]; /* XXX - must be at least as large as ibuffer */
-
- while (1)
- {
- if (ioctl(tty, FIONREAD, &nchar) == -1)
- nchar = sizeof(buf);
- else if (nchar <= 0)
- nchar = 1;
- result = ibuffer_space();
- if (nchar > result)
- nchar = result;
- result = read(tty, buf, nchar);
- if (result > 0)
- {
- register char *cp = buf;
-
- while (--result >= 0)
- rl_stuff_char(*cp++);
- return;
- }
- if (errno != EINTR)
- {
- rl_stuff_char(EOF);
- return;
- }
- }
-}
-
-/* Read a key, including pending input. */
-int
-rl_read_key ()
-{
- int c;
-
- rl_key_sequence_length++;
-
- if (rl_pending_input)
- {
- c = rl_pending_input;
- rl_pending_input = 0;
- }
- else
- {
- static int next_macro_key ();
-
- /* If input is coming from a macro, then use that. */
- if (c = next_macro_key ())
- return (c);
-
- while ((c = rl_get_char()) == -2)
- {
- if (rl_event_hook)
- {
- (*rl_event_hook) ();
- if ((c = rl_get_char()) != -2)
- return (c);
- }
- rl_getc(in_stream);
- }
- }
-#ifdef TIOCSTART
- /* Ugh. But I can't think of a better way. */
- if (xoff_state && c == xon_char)
- {
- ioctl (fileno (in_stream), TIOCSTART, 0);
- xoff_state = 0;
- return rl_read_key ();
- }
-#endif /* TIOCSTART */
- return (c);
-}
-
-/* Do the command associated with KEY in MAP.
- If the associated command is really a keymap, then read
- another key, and dispatch into that map. */
-rl_dispatch (key, map)
- register int key;
- Keymap map;
-{
- if (defining_kbd_macro)
- {
- static add_macro_char ();
-
- add_macro_char (key);
- }
-
- if (key > 127 && key < 256)
- {
- if (map[ESC].type == ISKMAP)
- {
- map = (Keymap)map[ESC].function;
- key -= 128;
- rl_dispatch (key, map);
- }
- else
- ding ();
- return;
- }
-
- switch (map[key].type)
- {
- case ISFUNC:
- {
- Function *func = map[key].function;
-
- if (func != (Function *)NULL)
- {
- /* Special case rl_do_lowercase_version (). */
- if (func == rl_do_lowercase_version)
- {
- rl_dispatch (to_lower (key), map);
- return;
- }
-
- (*map[key].function)(rl_numeric_arg * arg_sign, key);
- }
- else
- {
- ding ();
- return;
- }
- }
- break;
-
- case ISKMAP:
- if (map[key].function != (Function *)NULL)
- {
- int newkey;
-
- rl_key_sequence_length++;
- newkey = rl_read_key ();
- rl_dispatch (newkey, (Keymap)map[key].function);
- }
- else
- {
- ding ();
- return;
- }
- break;
-
- case ISMACR:
- if (map[key].function != (Function *)NULL)
- {
- static with_macro_input ();
- char *macro = savestring ((char *)map[key].function);
-
- with_macro_input (macro);
- return;
- }
- break;
- }
-
- /* If we have input pending, then the last command was a prefix
- command. Don't change the state of rl_last_func. */
- if (!rl_pending_input)
- rl_last_func = map[key].function;
-}
-
-
-/* **************************************************************** */
-/* */
-/* Hacking Keyboard Macros */
-/* */
-/* **************************************************************** */
-
-/* Set up to read subsequent input from STRING.
- STRING is free ()'ed when we are done with it. */
-static
-with_macro_input (string)
- char *string;
-{
- static push_executing_macro ();
-
- push_executing_macro ();
- executing_macro = string;
- executing_macro_index = 0;
-}
-
-/* Return the next character available from a macro, or 0 if
- there are no macro characters. */
-static int
-next_macro_key ()
-{
- if (!executing_macro)
- return (0);
-
- if (!executing_macro[executing_macro_index])
- {
- static pop_executing_macro ();
-
- pop_executing_macro ();
- return (next_macro_key ());
- }
-
- return (executing_macro[executing_macro_index++]);
-}
-
-/* Save the currently executing macro on a stack of saved macros. */
-static
-push_executing_macro ()
-{
- struct saved_macro *saver;
-
- saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
- saver->next = macro_list;
- saver->index = executing_macro_index;
- saver->string = executing_macro;
-
- macro_list = saver;
-}
-
-/* Discard the current macro, replacing it with the one
- on the top of the stack of saved macros. */
-static
-pop_executing_macro ()
-{
- if (executing_macro)
- free (executing_macro);
-
- executing_macro = (char *)NULL;
- executing_macro_index = 0;
-
- if (macro_list)
- {
- struct saved_macro *disposer = macro_list;
- executing_macro = macro_list->string;
- executing_macro_index = macro_list->index;
- macro_list = macro_list->next;
- free (disposer);
- }
-}
-
-/* Add a character to the macro being built. */
-static
-add_macro_char (c)
- int c;
-{
- if (current_macro_index + 1 >= current_macro_size)
- {
- if (!current_macro)
- current_macro = (char *)xmalloc (current_macro_size = 25);
- else
- current_macro =
- (char *)xrealloc (current_macro, current_macro_size += 25);
- }
-
- current_macro[current_macro_index++] = c;
- current_macro[current_macro_index] = '\0';
-}
-
-/* Begin defining a keyboard macro.
- Keystrokes are recorded as they are executed.
- End the definition with rl_end_kbd_macro ().
- If a numeric argument was explicitly typed, then append this
- definition to the end of the existing macro, and start by
- re-executing the existing macro. */
-rl_start_kbd_macro (ignore1, ignore2)
- int ignore1, ignore2;
-{
- if (defining_kbd_macro)
- rl_abort ();
-
- if (rl_explicit_arg)
- {
- if (current_macro)
- with_macro_input (savestring (current_macro));
- }
- else
- current_macro_index = 0;
-
- defining_kbd_macro = 1;
-}
-
-/* Stop defining a keyboard macro.
- A numeric argument says to execute the macro right now,
- that many times, counting the definition as the first time. */
-rl_end_kbd_macro (count, ignore)
- int count, ignore;
-{
- if (!defining_kbd_macro)
- rl_abort ();
-
- current_macro_index -= (rl_key_sequence_length - 1);
- current_macro[current_macro_index] = '\0';
-
- defining_kbd_macro = 0;
-
- rl_call_last_kbd_macro (--count, 0);
-}
-
-/* Execute the most recently defined keyboard macro.
- COUNT says how many times to execute it. */
-rl_call_last_kbd_macro (count, ignore)
- int count, ignore;
-{
- if (!current_macro)
- rl_abort ();
-
- while (count--)
- with_macro_input (savestring (current_macro));
-}
-
-
-/* Non-zero means do not parse any lines other than comments and
- parser directives. */
-static unsigned char parsing_conditionalized_out = 0;
-
-/* **************************************************************** */
-/* */
-/* Initializations */
-/* */
-/* **************************************************************** */
-
-/* Initliaze readline (and terminal if not already). */
-rl_initialize ()
-{
- extern char *rl_display_prompt;
-
- /* If we have never been called before, initialize the
- terminal and data structures. */
- if (!rl_initialized)
- {
- readline_initialize_everything ();
- rl_initialized++;
- }
-
- /* Initalize the current line information. */
- rl_point = rl_end = 0;
- the_line = rl_line_buffer;
- the_line[0] = 0;
-
- /* We aren't done yet. We haven't even gotten started yet! */
- rl_done = 0;
-
- /* Tell the history routines what is going on. */
- start_using_history ();
-
- /* Make the display buffer match the state of the line. */
- {
- extern char *rl_display_prompt;
- extern int forced_display;
-
- rl_on_new_line ();
-
- rl_display_prompt = rl_prompt ? rl_prompt : "";
- forced_display = 1;
- }
-
- /* No such function typed yet. */
- rl_last_func = (Function *)NULL;
-
- /* Parsing of key-bindings begins in an enabled state. */
- {
- parsing_conditionalized_out = 0;
- }
-}
-
-/* Initialize the entire state of the world. */
-readline_initialize_everything ()
-{
- /* Find out if we are running in Emacs. */
- running_in_emacs = (char *)getenv ("EMACS");
-
- /* Allocate data structures. */
- if (!rl_line_buffer)
- rl_line_buffer =
- (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
-
- /* Initialize the terminal interface. */
- init_terminal_io ((char *)NULL);
-
- /* Bind tty characters to readline functions. */
- readline_default_bindings ();
-
- /* Initialize the function names. */
- rl_initialize_funmap ();
-
- /* Read in the init file. */
- rl_read_init_file ((char *)NULL);
-
- /* If the completion parser's default word break characters haven't
- been set yet, then do so now. */
- {
- extern char *rl_completer_word_break_characters;
- extern char *rl_basic_word_break_characters;
-
- if (rl_completer_word_break_characters == (char *)NULL)
- rl_completer_word_break_characters = rl_basic_word_break_characters;
- }
-}
-
-/* If this system allows us to look at the values of the regular
- input editing characters, then bind them to their readline
- equivalents. */
-readline_default_bindings ()
-{
-#ifdef TIOCGETP
- struct sgttyb ttybuff;
- int tty = fileno (rl_instream);
-
- if (ioctl (tty, TIOCGETP, &ttybuff) != -1)
- {
- int erase = ttybuff.sg_erase, kill = ttybuff.sg_kill;
-
- if (erase != -1 && keymap[erase].type == ISFUNC)
- keymap[erase].function = rl_rubout;
-
- if (kill != -1 && keymap[kill].type == ISFUNC)
- keymap[kill].function = rl_unix_line_discard;
- }
-
-#ifdef TIOCGLTC
- {
- struct ltchars lt;
-
- if (ioctl (tty, TIOCGLTC, &lt) != -1)
- {
- int erase = lt.t_werasc, nextc = lt.t_lnextc;
-
- if (erase != -1 && keymap[erase].type == ISFUNC)
- keymap[erase].function = rl_unix_word_rubout;
-
- if (nextc != -1 && keymap[nextc].type == ISFUNC)
- keymap[nextc].function = rl_quoted_insert;
- }
- }
-#endif /* TIOCGLTC */
-#endif /* TIOCGETP */
-}
-
-
-/* **************************************************************** */
-/* */
-/* Numeric Arguments */
-/* */
-/* **************************************************************** */
-
-/* Handle C-u style numeric args, as well as M--, and M-digits. */
-
-/* Add the current digit to the argument in progress. */
-rl_digit_argument (ignore, key)
- int ignore, key;
-{
- rl_pending_input = key;
- rl_digit_loop ();
-}
-
-/* What to do when you abort reading an argument. */
-rl_discard_argument ()
-{
- ding ();
- rl_clear_message ();
- rl_init_argument ();
-}
-
-/* Create a default argument. */
-rl_init_argument ()
-{
- rl_numeric_arg = arg_sign = 1;
- rl_explicit_arg = 0;
-}
-
-/* C-u, universal argument. Multiply the current argument by 4.
- Read a key. If the key has nothing to do with arguments, then
- dispatch on it. If the key is the abort character then abort. */
-rl_universal_argument ()
-{
- rl_numeric_arg *= 4;
- rl_digit_loop ();
-}
-
-rl_digit_loop ()
-{
- int key, c;
- while (1)
- {
- rl_message ("(arg: %d) ", arg_sign * rl_numeric_arg);
- key = c = rl_read_key ();
-
- if (keymap[c].type == ISFUNC &&
- keymap[c].function == rl_universal_argument)
- {
- rl_numeric_arg *= 4;
- continue;
- }
- c = UNMETA (c);
- if (numeric (c))
- {
- if (rl_explicit_arg)
- rl_numeric_arg = (rl_numeric_arg * 10) + (c - '0');
- else
- rl_numeric_arg = (c - '0');
- rl_explicit_arg = 1;
- }
- else
- {
- if (c == '-' && !rl_explicit_arg)
- {
- rl_numeric_arg = 1;
- arg_sign = -1;
- }
- else
- {
- rl_clear_message ();
- rl_dispatch (key, keymap);
- return;
- }
- }
- }
-}
-
-
-/* **************************************************************** */
-/* */
-/* Display stuff */
-/* */
-/* **************************************************************** */
-
-/* This is the stuff that is hard for me. I never seem to write good
- display routines in C. Let's see how I do this time. */
-
-/* (PWP) Well... Good for a simple line updater, but totally ignores
- the problems of input lines longer than the screen width.
-
- update_line and the code that calls it makes a multiple line,
- automatically wrapping line update. Carefull attention needs
- to be paid to the vertical position variables.
-
- handling of terminals with autowrap on (incl. DEC braindamage)
- could be improved a bit. Right now I just cheat and decrement
- screenwidth by one. */
-
-/* Keep two buffers; one which reflects the current contents of the
- screen, and the other to draw what we think the new contents should
- be. Then compare the buffers, and make whatever changes to the
- screen itself that we should. Finally, make the buffer that we
- just drew into be the one which reflects the current contents of the
- screen, and place the cursor where it belongs.
-
- Commands that want to can fix the display themselves, and then let
- this function know that the display has been fixed by setting the
- RL_DISPLAY_FIXED variable. This is good for efficiency. */
-
-/* Termcap variables: */
-extern char *term_up, *term_dc, *term_cr;
-extern int screenheight, screenwidth, terminal_can_insert;
-
-/* What YOU turn on when you have handled all redisplay yourself. */
-int rl_display_fixed = 0;
-
-/* The visible cursor position. If you print some text, adjust this. */
-int last_c_pos = 0;
-int last_v_pos = 0;
-
-/* The last left edge of text that was displayed. This is used when
- doing horizontal scrolling. It shifts in thirds of a screenwidth. */
-static int last_lmargin = 0;
-
-/* The line display buffers. One is the line currently displayed on
- the screen. The other is the line about to be displayed. */
-static char *visible_line = (char *)NULL;
-static char *invisible_line = (char *)NULL;
-
-/* Number of lines currently on screen minus 1. */
-int vis_botlin = 0;
-
-/* A buffer for `modeline' messages. */
-char msg_buf[128];
-
-/* Non-zero forces the redisplay even if we thought it was unnecessary. */
-int forced_display = 0;
-
-/* The stuff that gets printed out before the actual text of the line.
- This is usually pointing to rl_prompt. */
-char *rl_display_prompt = (char *)NULL;
-
-/* Default and initial buffer size. Can grow. */
-static int line_size = 1024;
-
-/* Non-zero means to always use horizontal scrolling in line display. */
-int horizontal_scroll_mode = 0;
-
-/* I really disagree with this, but my boss (among others) insists that we
- support compilers that don't work. I don't think we are gaining by doing
- so; what is the advantage in producing better code if we can't use it? */
-/* The following two declarations belong inside the
- function block, not here. */
-static void move_cursor_relative ();
-static void output_some_chars ();
-
-/* Basic redisplay algorithm. */
-rl_redisplay ()
-{
- register int in, out, c, linenum;
- register char *line = invisible_line;
- int c_pos = 0;
- int inv_botlin = 0; /* Number of lines in newly drawn buffer. */
-
- extern int readline_echoing_p;
-
- if (!readline_echoing_p)
- return;
-
- if (!rl_display_prompt)
- rl_display_prompt = "";
-
- if (!invisible_line)
- {
- visible_line = (char *)xmalloc (line_size);
- invisible_line = (char *)xmalloc (line_size);
- line = invisible_line;
- for (in = 0; in < line_size; in++)
- {
- visible_line[in] = 0;
- invisible_line[in] = 1;
- }
- rl_on_new_line ();
- }
-
- /* Draw the line into the buffer. */
- c_pos = -1;
-
- /* Mark the line as modified or not. We only do this for history
- lines. */
- out = 0;
- if (current_history () && rl_undo_list)
- {
- line[out++] = '*';
- line[out] = '\0';
- }
-
- /* If someone thought that the redisplay was handled, but the currently
- visible line has a different modification state than the one about
- to become visible, then correct the callers misconception. */
- if (visible_line[0] != invisible_line[0])
- rl_display_fixed = 0;
-
- strncpy (line + out, rl_display_prompt, strlen (rl_display_prompt));
- out += strlen (rl_display_prompt);
- line[out] = '\0';
-
- for (in = 0; in < rl_end; in++)
- {
- c = the_line[in];
-
- if (out + 1 >= line_size)
- {
- line_size *= 2;
- visible_line = (char *)xrealloc (visible_line, line_size);
- invisible_line = (char *)xrealloc (invisible_line, line_size);
- line = invisible_line;
- }
-
- if (in == rl_point)
- c_pos = out;
-
- if (c > 127)
- {
- line[out++] = 'M';
- line[out++] = '-';
- line[out++] = c - 128;
- }
-#define DISPLAY_TABS
-#ifdef DISPLAY_TABS
- else if (c == '\t')
- {
- register int newout = (out | (int)7) + 1;
- while (out < newout)
- line[out++] = ' ';
- }
-#endif
- else if (c < 32)
- {
- line[out++] = 'C';
- line[out++] = '-';
- line[out++] = c + 64;
- }
- else
- line[out++] = c;
- }
- line[out] = '\0';
- if (c_pos < 0)
- c_pos = out;
-
- /* PWP: now is when things get a bit hairy. The visible and invisible
- line buffers are really multiple lines, which would wrap every
- (screenwidth - 1) characters. Go through each in turn, finding
- the changed region and updating it. The line order is top to bottom. */
-
- /* If we can move the cursor up and down, then use multiple lines,
- otherwise, let long lines display in a single terminal line, and
- horizontally scroll it. */
-
- if (!horizontal_scroll_mode && term_up && *term_up)
- {
- int total_screen_chars = (screenwidth * screenheight);
-
- if (!rl_display_fixed || forced_display)
- {
- forced_display = 0;
-
- /* If we have more than a screenful of material to display, then
- only display a screenful. We should display the last screen,
- not the first. I'll fix this in a minute. */
- if (out >= total_screen_chars)
- out = total_screen_chars - 1;
-
- /* Number of screen lines to display. */
- inv_botlin = out / screenwidth;
-
- /* For each line in the buffer, do the updating display. */
- for (linenum = 0; linenum <= inv_botlin; linenum++)
- update_line (linenum > vis_botlin ? ""
- : &visible_line[linenum * screenwidth],
- &invisible_line[linenum * screenwidth],
- linenum);
-
- /* We may have deleted some lines. If so, clear the left over
- blank ones at the bottom out. */
- if (vis_botlin > inv_botlin)
- {
- char *tt;
- for (; linenum <= vis_botlin; linenum++)
- {
- tt = &visible_line[linenum * screenwidth];
- move_vert (linenum);
- move_cursor_relative (0, tt);
- clear_to_eol ((linenum == vis_botlin)?
- strlen (tt) : screenwidth);
- }
- }
- vis_botlin = inv_botlin;
-
- /* Move the cursor where it should be. */
- move_vert (c_pos / screenwidth);
- move_cursor_relative (c_pos % screenwidth,
- &invisible_line[(c_pos / screenwidth) * screenwidth]);
- }
- }
- else /* Do horizontal scrolling. */
- {
- int lmargin;
-
- /* Always at top line. */
- last_v_pos = 0;
-
- /* If the display position of the cursor would be off the edge
- of the screen, start the display of this line at an offset that
- leaves the cursor on the screen. */
- if (c_pos - last_lmargin > screenwidth - 2)
- lmargin = (c_pos / (screenwidth / 3) - 2) * (screenwidth / 3);
- else if (c_pos - last_lmargin < 1)
- lmargin = ((c_pos - 1) / (screenwidth / 3)) * (screenwidth / 3);
- else
- lmargin = last_lmargin;
-
- /* If the first character on the screen isn't the first character
- in the display line, indicate this with a special character. */
- if (lmargin > 0)
- line[lmargin] = '<';
-
- if (lmargin + screenwidth < out)
- line[lmargin + screenwidth - 1] = '>';
-
- if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
- {
- forced_display = 0;
- update_line (&visible_line[last_lmargin],
- &invisible_line[lmargin], 0);
-
- move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]);
- last_lmargin = lmargin;
- }
- }
- fflush (out_stream);
-
- /* Swap visible and non-visible lines. */
- {
- char *temp = visible_line;
- visible_line = invisible_line;
- invisible_line = temp;
- rl_display_fixed = 0;
- }
-}
-
-/* PWP: update_line() is based on finding the middle difference of each
- line on the screen; vis:
-
- /old first difference
- /beginning of line | /old last same /old EOL
- v v v v
-old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as
-new: eddie> Oh, my little buggy says to me, as lurgid as
- ^ ^ ^ ^
- \beginning of line | \new last same \new end of line
- \new first difference
-
- All are character pointers for the sake of speed. Special cases for
- no differences, as well as for end of line additions must be handeled.
-
- Could be made even smarter, but this works well enough */
-static
-update_line (old, new, current_line)
- register char *old, *new;
- int current_line;
-{
- register char *ofd, *ols, *oe, *nfd, *nls, *ne;
- int lendiff, wsatend;
-
- /* Find first difference. */
- for (ofd = old, nfd = new;
- (ofd - old < screenwidth) && *ofd && (*ofd == *nfd);
- ofd++, nfd++)
- ;
-
- /* Move to the end of the screen line. */
- for (oe = ofd; ((oe - old) < screenwidth) && *oe; oe++);
- for (ne = nfd; ((ne - new) < screenwidth) && *ne; ne++);
-
- /* If no difference, continue to next line. */
- if (ofd == oe && nfd == ne)
- return;
-
- wsatend = 1; /* flag for trailing whitespace */
- ols = oe - 1; /* find last same */
- nls = ne - 1;
- while ((*ols == *nls) && (ols > ofd) && (nls > nfd))
- {
- if (*ols != ' ')
- wsatend = 0;
- ols--;
- nls--;
- }
-
- if (wsatend)
- {
- ols = oe;
- nls = ne;
- }
- else if (*ols != *nls)
- {
- if (*ols) /* don't step past the NUL */
- ols++;
- if (*nls)
- nls++;
- }
-
- move_vert (current_line);
- move_cursor_relative (ofd - old, old);
-
- /* if (len (new) > len (old)) */
- lendiff = (nls - nfd) - (ols - ofd);
-
- /* Insert (diff(len(old),len(new)) ch */
- if (lendiff > 0)
- {
- if (terminal_can_insert)
- {
- extern char *term_IC;
-
- /* Sometimes it is cheaper to print the characters rather than
- use the terminal's capabilities. */
- if ((2 * (ne - nfd)) < lendiff && (!term_IC || !*term_IC))
- {
- output_some_chars (nfd, (ne - nfd));
- last_c_pos += (ne - nfd);
- }
- else
- {
- if (*ols)
- {
- start_insert (lendiff);
- output_some_chars (nfd, lendiff);
- last_c_pos += lendiff;
- end_insert ();
- }
- else
- {
- /* At the end of a line the characters do not have to
- be "inserted". They can just be placed on the screen. */
- output_some_chars (nfd, lendiff);
- last_c_pos += lendiff;
- }
- /* Copy (new) chars to screen from first diff to last match. */
- if (((nls - nfd) - lendiff) > 0)
- {
- output_some_chars (&nfd[lendiff], ((nls - nfd) - lendiff));
- last_c_pos += ((nls - nfd) - lendiff);
- }
- }
- }
- else
- { /* cannot insert chars, write to EOL */
- output_some_chars (nfd, (ne - nfd));
- last_c_pos += (ne - nfd);
- }
- }
- else /* Delete characters from line. */
- {
- /* If possible and inexpensive to use terminal deletion, then do so. */
- if (term_dc && (2 * (ne - nfd)) >= (-lendiff))
- {
- if (lendiff)
- delete_chars (-lendiff); /* delete (diff) characters */
-
- /* Copy (new) chars to screen from first diff to last match */
- if ((nls - nfd) > 0)
- {
- output_some_chars (nfd, (nls - nfd));
- last_c_pos += (nls - nfd);
- }
- }
- /* Otherwise, print over the existing material. */
- else
- {
- output_some_chars (nfd, (ne - nfd));
- last_c_pos += (ne - nfd);
- clear_to_eol ((oe - old) - (ne - new));
- }
- }
-}
-
-/* (PWP) tell the update routines that we have moved onto a
- new (empty) line. */
-rl_on_new_line ()
-{
- if (visible_line)
- visible_line[0] = '\0';
-
- last_c_pos = last_v_pos = 0;
- vis_botlin = last_lmargin = 0;
-}
-
-/* Actually update the display, period. */
-rl_forced_update_display ()
-{
- if (visible_line)
- {
- register char *temp = visible_line;
-
- while (*temp) *temp++ = '\0';
- }
- rl_on_new_line ();
- forced_display++;
- rl_redisplay ();
-}
-
-/* Move the cursor from last_c_pos to NEW, which are buffer indices.
- DATA is the contents of the screen line of interest; i.e., where
- the movement is being done. */
-static void
-move_cursor_relative (new, data)
- int new;
- char *data;
-{
- register int i;
- static void output_character_function ();
-
- /* It may be faster to output a CR, and then move forwards instead
- of moving backwards. */
- if (new + 1 < last_c_pos - new)
- {
- tputs (term_cr, 1, output_character_function);
- last_c_pos = 0;
- }
-
- if (last_c_pos == new) return;
-
- if (last_c_pos < new)
- {
- /* Move the cursor forward. We do it by printing the command
- to move the cursor forward if there is one, else print that
- portion of the output buffer again. Which is cheaper? */
-
- /* The above comment is left here for posterity. It is faster
- to print one character (non-control) than to print a control
- sequence telling the terminal to move forward one character.
- That kind of control is for people who don't know what the
- data is underneath the cursor. */
-#ifdef HACK_TERMCAP_MOTION
- extern char *term_forward_char;
-
- if (term_forward_char)
- for (i = last_c_pos; i < new; i++)
- tputs (term_forward_char, 1, output_character_function);
- else
- for (i = last_c_pos; i < new; i++)
- putc (data[i], out_stream);
-#else
- for (i = last_c_pos; i < new; i++)
- putc (data[i], out_stream);
-#endif /* HACK_TERMCAP_MOTION */
- }
- else
- backspace (last_c_pos - new);
- last_c_pos = new;
-}
-
-/* PWP: move the cursor up or down. */
-move_vert (to)
- int to;
-{
- void output_character_function ();
- register int delta, i;
-
- if (last_v_pos == to) return;
-
- if (to > screenheight)
- return;
-
- if ((delta = to - last_v_pos) > 0)
- {
- for (i = 0; i < delta; i++)
- putc ('\n', out_stream);
- tputs (term_cr, 1, output_character_function);
- last_c_pos = 0; /* because crlf() will do \r\n */
- }
- else
- { /* delta < 0 */
- if (term_up && *term_up)
- for (i = 0; i < -delta; i++)
- tputs (term_up, 1, output_character_function);
- }
- last_v_pos = to; /* now to is here */
-}
-
-/* Physically print C on out_stream. This is for functions which know
- how to optimize the display. */
-rl_show_char (c)
- int c;
-{
- if (c > 127)
- {
- fprintf (out_stream, "M-");
- c -= 128;
- }
-
-#ifdef DISPLAY_TABS
- if (c < 32 && c != '\t')
-#else
- if (c < 32)
-#endif
- {
-
- c += 64;
- }
-
- putc (c, out_stream);
- fflush (out_stream);
-}
-
-#ifdef DISPLAY_TABS
-int
-rl_character_len (c, pos)
- register int c, pos;
-{
- if (c < ' ' || c > 126)
- {
- if (c == '\t')
- return (((pos | (int)7) + 1) - pos);
- else
- return (3);
- }
- else
- return (1);
-}
-#else
-int
-rl_character_len (c)
- int c;
-{
- if (c < ' ' || c > 126)
- return (3);
- else
- return (1);
-}
-#endif /* DISPLAY_TAB */
-
-/* How to print things in the "echo-area". The prompt is treated as a
- mini-modeline. */
-rl_message (string, arg1, arg2)
- char *string;
-{
- sprintf (msg_buf, string, arg1, arg2);
- rl_display_prompt = msg_buf;
- rl_redisplay ();
-}
-
-/* How to clear things from the "echo-area". */
-rl_clear_message ()
-{
- rl_display_prompt = rl_prompt;
- rl_redisplay ();
-}
-
-/* **************************************************************** */
-/* */
-/* Terminal and Termcap */
-/* */
-/* **************************************************************** */
-
-static char *term_buffer = (char *)NULL;
-static char *term_string_buffer = (char *)NULL;
-
-/* Non-zero means this terminal can't really do anything. */
-int dumb_term = 0;
-
-char PC;
-char *BC, *UP;
-
-/* Some strings to control terminal actions. These are output by tputs (). */
-char *term_goto, *term_clreol, *term_cr, *term_clrpag, *term_backspace;
-
-int screenwidth, screenheight;
-
-/* Non-zero if we determine that the terminal can do character insertion. */
-int terminal_can_insert = 0;
-
-/* How to insert characters. */
-char *term_im, *term_ei, *term_ic, *term_ip, *term_IC;
-
-/* How to delete characters. */
-char *term_dc, *term_DC;
-
-#ifdef HACK_TERMCAP_MOTION
-char *term_forward_char;
-#endif /* HACK_TERMCAP_MOTION */
-
-/* How to go up a line. */
-char *term_up;
-
-/* Re-initialize the terminal considering that the TERM/TERMCAP variable
- has changed. */
-rl_reset_terminal (terminal_name)
- char *terminal_name;
-{
- init_terminal_io (terminal_name);
-}
-
-init_terminal_io (terminal_name)
- char *terminal_name;
-{
- char *term = (terminal_name? terminal_name : (char *)getenv ("TERM"));
- char *tgetstr (), *buffer;
-
-
- if (!term_string_buffer)
- term_string_buffer = (char *)xmalloc (2048);
-
- if (!term_buffer)
- term_buffer = (char *)xmalloc (2048);
-
- buffer = term_string_buffer;
-
- term_clrpag = term_cr = term_clreol = (char *)NULL;
-
- if (!term)
- term = "dumb";
-
- if (tgetent (term_buffer, term) < 0)
- {
- dumb_term = 1;
- return;
- }
-
- BC = tgetstr ("pc", &buffer);
- PC = buffer ? *buffer : 0;
-
- term_backspace = tgetstr ("le", &buffer);
-
- term_cr = tgetstr ("cr", &buffer);
- term_clreol = tgetstr ("ce", &buffer);
- term_clrpag = tgetstr ("cl", &buffer);
-
- if (!term_cr)
- term_cr = "\r";
-
-#ifdef HACK_TERMCAP_MOTION
- term_forward_char = tgetstr ("nd", &buffer);
-#endif /* HACK_TERMCAP_MOTION */
-
- screenwidth = tgetnum ("co");
- if (screenwidth <= 0)
- screenwidth = 80;
- screenwidth--; /* PWP: avoid autowrap bugs */
-
- screenheight = tgetnum ("li");
- if (screenheight <= 0)
- screenheight = 24;
-
- term_im = tgetstr ("im", &buffer);
- term_ei = tgetstr ("ei", &buffer);
- term_IC = tgetstr ("IC", &buffer);
- term_ic = tgetstr ("ic", &buffer);
- term_ip = tgetstr ("ip", &buffer);
- term_IC = tgetstr ("IC", &buffer);
-
- /* "An application program can assume that the terminal can do
- character insertion if *any one of* the capabilities `IC',
- `im', `ic' or `ip' is provided." */
-#ifdef notdef
- /* XXX Circumvent broken code. */
- terminal_can_insert = (term_IC || term_im || term_ic || term_ip);
-#endif
-
- term_up = tgetstr ("up", &buffer);
- term_dc = tgetstr ("dc", &buffer);
- term_DC = tgetstr ("DC", &buffer);
-}
-
-/* A function for the use of tputs () */
-static void
-output_character_function (c)
- int c;
-{
- putc (c, out_stream);
-}
-
-/* Write COUNT characters from STRING to the output stream. */
-static void
-output_some_chars (string, count)
- char *string;
- int count;
-{
- fwrite (string, 1, count, out_stream);
-}
-
-
-/* Delete COUNT characters from the display line. */
-static
-delete_chars (count)
- int count;
-{
- if (count > screenwidth)
- return;
-
- if (term_DC && *term_DC)
- {
- char *tgoto (), *buffer;
- buffer = tgoto (term_DC, 0, count);
- tputs (buffer, 1, output_character_function);
- }
- else
- {
- if (term_dc && *term_dc)
- while (count--)
- tputs (term_dc, 1, output_character_function);
- }
-}
-
-/* Prepare to insert by inserting COUNT blank spaces. */
-static
-start_insert (count)
- int count;
-{
- if (term_im && *term_im)
- tputs (term_im, 1, output_character_function);
-
- if (term_IC && *term_IC &&
- (count > 1 || !term_ic || !*term_ic))
- {
- char *tgoto (), *buffer;
- buffer = tgoto (term_IC, 0, count);
- tputs (buffer, 1, output_character_function);
- }
- else
- {
- if (term_ic && *term_ic)
- while (count--)
- tputs (term_ic, 1, output_character_function);
- }
-}
-
-/* We are finished doing our insertion. Send ending string. */
-static
-end_insert ()
-{
- if (term_ei && *term_ei)
- tputs (term_ei, 1, output_character_function);
-}
-
-/* Move the cursor back. */
-backspace (count)
- int count;
-{
- register int i;
-
- if (term_backspace)
- for (i = 0; i < count; i++)
- tputs (term_backspace, 1, output_character_function);
- else
- for (i = 0; i < count; i++)
- putc ('\b', out_stream);
-}
-
-/* Move to the start of the next line. */
-crlf ()
-{
- tputs (term_cr, 1, output_character_function);
- putc ('\n', out_stream);
-}
-
-/* Clear to the end of the line. COUNT is the minimum
- number of character spaces to clear, */
-clear_to_eol (count)
- int count;
-{
- if (term_clreol) {
- tputs (term_clreol, 1, output_character_function);
- } else {
- register int i;
- /* Do one more character space. */
- count++;
- for (i = 0; i < count; i++)
- putc (' ', out_stream);
- backspace (count);
- }
-}
-
-
-/* **************************************************************** */
-/* */
-/* Saving and Restoring the TTY */
-/* */
-/* **************************************************************** */
-
-#ifdef NEW_TTY_DRIVER
-
-/* Standard flags, including ECHO. */
-static int original_tty_flags = 0;
-
-/* Local mode flags, like LPASS8. */
-static int local_mode_flags = 0;
-
-/* Terminal characters. This has C-s and C-q in it. */
-static struct tchars original_tchars;
-
-/* Local special characters. This has the interrupt characters in it. */
-static struct ltchars original_ltchars;
-
-/* We use this to get and set the tty_flags. */
-static struct sgttyb the_ttybuff;
-
-/* Put the terminal in CBREAK mode so that we can detect key presses. */
-static
-rl_prep_terminal ()
-{
- int tty = fileno (rl_instream);
-
- /* We always get the latest tty values. Maybe stty changed them. */
-
- ioctl (tty, TIOCGETP, &the_ttybuff);
- original_tty_flags = the_ttybuff.sg_flags;
-
- readline_echoing_p = (original_tty_flags & ECHO);
-
- /* If this terminal doesn't care how the 8th bit is used,
- then we can use it for the meta-key.
- We check by seeing if BOTH odd and even parity are allowed. */
- if ((the_ttybuff.sg_flags & (ODDP | EVENP)) == (ODDP | EVENP))
- {
-#ifdef PASS8
- the_ttybuff.sg_flags |= PASS8;
-#endif
-
-#if defined (TIOCLGET) && defined (LPASS8)
- {
- int flags;
- ioctl (tty, TIOCLGET, &flags);
- local_mode_flags = flags;
- flags |= LPASS8;
- ioctl (tty, TIOCLSET, &flags);
- }
-#endif
- }
-
-#ifdef TIOCGETC
- {
- struct tchars temp;
-
- ioctl (tty, TIOCGETC, &original_tchars);
- bcopy (&original_tchars, &temp, sizeof (struct tchars));
-
- /* Get rid of C-s and C-q.
- We remember the value of startc (C-q) so that if the terminal is in
- xoff state, the user can xon it by pressing that character. */
- xon_char = temp.t_startc;
- temp.t_stopc = -1;
- temp.t_startc = -1;
-
- /* If there is an XON character, bind it to restart the output. */
- if (xon_char != -1)
- rl_bind_key (xon_char, rl_restart_output);
-
- /* If there is an EOF char, bind eof_char to it. */
- if (temp.t_eofc != -1)
- eof_char = temp.t_eofc;
-
-#ifdef NEVER
- /* Get rid of C-\ and C-c. */
- temp.t_intrc = temp.t_quitc = -1;
-#endif
-
- ioctl (tty, TIOCSETC, &temp);
- }
-#endif /* TIOCGETC */
-
-#ifdef TIOCGLTC
- {
- struct ltchars temp;
-
- ioctl (tty, TIOCGLTC, &original_ltchars);
- bcopy (&original_ltchars, &temp, sizeof (struct ltchars));
-
- /* Make the interrupt keys go away. Just enough to make people happy. */
- temp.t_dsuspc = -1; /* C-y */
- temp.t_lnextc = -1; /* C-v */
-
- ioctl (tty, TIOCSLTC, &temp);
- }
-#endif /* TIOCGLTC */
-
- the_ttybuff.sg_flags &= ~ECHO;
- the_ttybuff.sg_flags |= CBREAK;
- ioctl (tty, TIOCSETN, &the_ttybuff);
-}
-
-/* Restore the terminal to its original state. */
-static
-rl_deprep_terminal ()
-{
- int tty = fileno (rl_instream);
-
-#if defined (TIOCLGET) && defined (LPASS8)
- if ((the_ttybuff.sg_flags & (ODDP | EVENP)) == (ODDP | EVENP))
- ioctl (tty, TIOCLSET, &local_mode_flags);
-#endif
-
-#ifdef TIOCSLTC
- ioctl (tty, TIOCSLTC, &original_ltchars);
-#endif
-
-#ifdef TIOCSETC
- ioctl (tty, TIOCSETC, &original_tchars);
-#endif
-
- the_ttybuff.sg_flags = original_tty_flags;
- ioctl (tty, TIOCSETN, &the_ttybuff);
- readline_echoing_p = 1;
-}
-
-#else /* !defined (NEW_TTY_DRIVER) */
-static struct termio otio;
-
-static
-rl_prep_terminal ()
-{
- int tty = fileno (rl_instream);
- struct termio tio;
-
- ioctl (tty, TCGETA, &tio);
- ioctl (tty, TCGETA, &otio);
-
- readline_echoing_p = (tio.c_lflag & ECHO);
-
- tio.c_lflag &= ~(ICANON|ECHO);
- tio.c_iflag &= ~(IXON|ISTRIP|INPCK);
-
-#ifndef HANDLE_SIGNALS
- tio.c_lflag &= ~ISIG;
-#endif
-
- tio.c_cc[VEOF] = 1; /* really: MIN */
- tio.c_cc[VEOL] = 0; /* really: TIME */
- ioctl (tty, TCSETAW,&tio);
-}
-
-static
-rl_deprep_terminal ()
-{
- int tty = fileno (rl_instream);
- ioctl (tty, TCSETAW, &otio);
-}
-#endif /* NEW_TTY_DRIVER */
-
-
-/* **************************************************************** */
-/* */
-/* Utility Functions */
-/* */
-/* **************************************************************** */
-
-/* Return 0 if C is not a member of the class of characters that belong
- in words, or 1 if it is. */
-
-int allow_pathname_alphabetic_chars = 0;
-char *pathname_alphabetic_chars = "/-_=~.#$";
-
-int
-alphabetic (c)
- int c;
-{
- char *rindex ();
- if (pure_alphabetic (c) || (numeric (c)))
- return (1);
-
- if (allow_pathname_alphabetic_chars)
- return ((int)rindex (pathname_alphabetic_chars, c));
- else
- return (0);
-}
-
-/* Return non-zero if C is a numeric character. */
-int
-numeric (c)
- int c;
-{
- return (c >= '0' && c <= '9');
-}
-
-/* Ring the terminal bell. */
-int
-ding ()
-{
- if (readline_echoing_p)
- {
- fprintf (stderr, "\007");
- fflush (stderr);
- }
- return (-1);
-}
-
-/* How to abort things. */
-rl_abort ()
-{
- ding ();
- rl_clear_message ();
- rl_init_argument ();
- rl_pending_input = 0;
-
- defining_kbd_macro = 0;
- while (executing_macro)
- pop_executing_macro ();
-
- longjmp (readline_top_level, 1);
-}
-
-/* Return a copy of the string between FROM and TO.
- FROM is inclusive, TO is not. */
-char *
-rl_copy (from, to)
- int from, to;
-{
- register int length;
- char *copy;
-
- /* Fix it if the caller is confused. */
- if (from > to) {
- int t = from;
- from = to;
- to = t;
- }
-
- length = to - from;
- copy = (char *)xmalloc (1 + length);
- strncpy (copy, the_line + from, length);
- copy[length] = '\0';
- return (copy);
-}
-
-
-/* **************************************************************** */
-/* */
-/* Insert and Delete */
-/* */
-/* **************************************************************** */
-
-
-/* Insert a string of text into the line at point. This is the only
- way that you should do insertion. rl_insert () calls this
- function. */
-rl_insert_text (string)
- char *string;
-{
- extern int doing_an_undo;
- register int i, l = strlen (string);
- while (rl_end + l >= rl_line_buffer_len)
- {
- rl_line_buffer =
- (char *)xrealloc (rl_line_buffer,
- rl_line_buffer_len += DEFAULT_BUFFER_SIZE);
- the_line = rl_line_buffer;
- }
-
- for (i = rl_end; i >= rl_point; i--)
- the_line[i + l] = the_line[i];
- strncpy (the_line + rl_point, string, l);
-
- /* Remember how to undo this if we aren't undoing something. */
- if (!doing_an_undo)
- {
- /* If possible and desirable, concatenate the undos. */
- if ((strlen (string) == 1) &&
- rl_undo_list &&
- (rl_undo_list->what == UNDO_INSERT) &&
- (rl_undo_list->end == rl_point) &&
- (rl_undo_list->end - rl_undo_list->start < 20))
- rl_undo_list->end++;
- else
- rl_add_undo (UNDO_INSERT, rl_point, rl_point + l, (char *)NULL);
- }
- rl_point += l;
- rl_end += l;
- the_line[rl_end] = '\0';
-}
-
-/* Delete the string between FROM and TO. FROM is
- inclusive, TO is not. */
-rl_delete_text (from, to)
- int from, to;
-{
- extern int doing_an_undo;
- register char *text;
-
- /* Fix it if the caller is confused. */
- if (from > to) {
- int t = from;
- from = to;
- to = t;
- }
- text = rl_copy (from, to);
- strncpy (the_line + from, the_line + to, rl_end - to);
-
- /* Remember how to undo this delete. */
- if (!doing_an_undo)
- rl_add_undo (UNDO_DELETE, from, to, text);
- else
- free (text);
-
- rl_end -= (to - from);
- the_line[rl_end] = '\0';
-}
-
-
-/* **************************************************************** */
-/* */
-/* Readline character functions */
-/* */
-/* **************************************************************** */
-
-/* This is not a gap editor, just a stupid line input routine. No hair
- is involved in writing any of the functions, and none should be. */
-
-/* Note that:
-
- rl_end is the place in the string that we would place '\0';
- i.e., it is always safe to place '\0' there.
-
- rl_point is the place in the string where the cursor is. Sometimes
- this is the same as rl_end.
-
- Any command that is called interactively receives two arguments.
- The first is a count: the numeric arg pased to this command.
- The second is the key which invoked this command.
-*/
-
-
-/* **************************************************************** */
-/* */
-/* Movement Commands */
-/* */
-/* **************************************************************** */
-
-/* Note that if you `optimize' the display for these functions, you cannot
- use said functions in other functions which do not do optimizing display.
- I.e., you will have to update the data base for rl_redisplay, and you
- might as well let rl_redisplay do that job. */
-
-/* Move forward COUNT characters. */
-rl_forward (count)
- int count;
-{
- if (count < 0)
- rl_backward (-count);
- else
- while (count)
- {
-#ifdef VI_MODE
- if (rl_point == (rl_end - (rl_editing_mode == vi_mode)))
-#else
- if (rl_point == rl_end)
-#endif
- {
- ding ();
- return;
- }
- else
- rl_point++;
- --count;
- }
-}
-
-/* Move backward COUNT characters. */
-rl_backward (count)
- int count;
-{
- if (count < 0)
- rl_forward (-count);
- else
- while (count)
- {
- if (!rl_point)
- {
- ding ();
- return;
- }
- else
- --rl_point;
- --count;
- }
-}
-
-/* Move to the beginning of the line. */
-rl_beg_of_line ()
-{
- rl_point = 0;
-}
-
-/* Move to the end of the line. */
-rl_end_of_line ()
-{
- rl_point = rl_end;
-}
-
-/* Move forward a word. We do what Emacs does. */
-rl_forward_word (count)
- int count;
-{
- int c;
-
- if (count < 0)
- {
- rl_backward_word (-count);
- return;
- }
-
- while (count)
- {
- if (rl_point == rl_end)
- return;
-
- /* If we are not in a word, move forward until we are in one.
- Then, move forward until we hit a non-alphabetic character. */
- c = the_line[rl_point];
- if (!alphabetic (c))
- {
- while (++rl_point < rl_end)
- {
- c = the_line[rl_point];
- if (alphabetic (c)) break;
- }
- }
- if (rl_point == rl_end) return;
- while (++rl_point < rl_end)
- {
- c = the_line[rl_point];
- if (!alphabetic (c)) break;
- }
- --count;
- }
-}
-
-/* Move backward a word. We do what Emacs does. */
-rl_backward_word (count)
- int count;
-{
- int c;
-
- if (count < 0)
- {
- rl_forward_word (-count);
- return;
- }
-
- while (count)
- {
- if (!rl_point)
- return;
-
- /* Like rl_forward_word (), except that we look at the characters
- just before point. */
-
- c = the_line[rl_point - 1];
- if (!alphabetic (c))
- {
- while (--rl_point)
- {
- c = the_line[rl_point - 1];
- if (alphabetic (c)) break;
- }
- }
-
- while (rl_point)
- {
- c = the_line[rl_point - 1];
- if (!alphabetic (c))
- break;
- else --rl_point;
- }
- --count;
- }
-}
-
-/* Clear the current line. Numeric argument to C-l does this. */
-rl_refresh_line ()
-{
- int curr_line = last_c_pos / screenwidth;
-
- move_vert(curr_line);
- move_cursor_relative (0, the_line); /* XXX is this right */
- rl_forced_update_display ();
- rl_display_fixed = 1;
-}
-
-/* C-l typed to a line without quoting clears the screen, and then reprints
- the prompt and the current input line. Given a numeric arg, redraw only
- the current line. */
-rl_clear_screen ()
-{
- extern char *term_clrpag;
- static void output_character_function ();
-
- if (rl_explicit_arg)
- {
- rl_refresh_line ();
- return;
- }
-
- if (term_clrpag)
- tputs (term_clrpag, 1, output_character_function);
- else
- crlf ();
-
- rl_forced_update_display ();
- rl_display_fixed = 1;
-}
-
-
-/* **************************************************************** */
-/* */
-/* Text commands */
-/* */
-/* **************************************************************** */
-
-/* Insert the character C at the current location, moving point forward. */
-rl_insert (count, c)
- int count, c;
-{
- register int i;
- char *string;
-
- if (count <= 0)
- return;
-
- /* If we can optimize, then do it. But don't let people crash
- readline because of extra large arguments. */
- if (count > 1 && count < 1024)
- {
- string = (char *)alloca (1 + count);
-
- for (i = 0; i < count; i++)
- string[i] = c;
-
- string[i] = '\0';
- rl_insert_text (string);
- return;
- }
-
- if (count > 1024)
- {
- int descreaser;
-
- string = (char *)alloca (1024 + 1);
-
- for (i = 0; i < 1024; i++)
- string[i] = c;
-
- while (count)
- {
- descreaser = (count > 1024 ? 1024 : count);
- string[descreaser] = '\0';
- rl_insert_text (string);
- count -= descreaser;
- }
- return;
- }
-
- /* We are inserting a single character.
- If there is pending input, then make a string of all of the
- pending characters that are bound to rl_insert, and insert
- them all. */
- if (any_typein)
- {
- int slen, key = 0, t;
-
- i = 0;
- string = (char *)alloca (ibuffer_len + 1);
- string[i++] = c;
-
- while ((key = rl_get_char()) != -2 &&
- (keymap[key].type == ISFUNC &&
- keymap[key].function == rl_insert))
- string[i++] = key;
-
- if (key != -2)
- rl_unget_char (key);
-
- string[i] = '\0';
- rl_insert_text (string);
- return;
- }
- else
- {
- /* Inserting a single character. */
- string = (char *)alloca (2);
-
- string[1] = '\0';
- string[0] = c;
- rl_insert_text (string);
- }
-}
-
-/* Insert the next typed character verbatim. */
-rl_quoted_insert (count)
- int count;
-{
- int c = rl_read_key (in_stream);
- rl_insert (count, c);
-}
-
-/* Insert a tab character. */
-rl_tab_insert (count)
- int count;
-{
- rl_insert (count, '\t');
-}
-
-#ifdef VI_MODE
-/* Non-zero means enter insertion mode. */
-static vi_doing_insert = 0;
-#endif
-
-/* What to do when a NEWLINE is pressed. We accept the whole line.
- KEY is the key that invoked this command. I guess it could have
- meaning in the future. */
-rl_newline (count, key)
- int count, key;
-{
-
- rl_done = 1;
-
-#ifdef VI_MODE
- {
- if (vi_doing_insert)
- {
- rl_end_undo_group ();
- vi_doing_insert = 0;
- }
- }
-#endif /* VI_MODE */
-
- if (readline_echoing_p)
- {
- move_vert (vis_botlin);
- vis_botlin = 0;
- crlf ();
- fflush (out_stream);
- rl_display_fixed++;
- }
-}
-
-rl_clean_up_for_exit ()
-{
- if (readline_echoing_p)
- {
- move_vert (vis_botlin);
- vis_botlin = 0;
- fflush (out_stream);
- rl_restart_output ();
- }
-}
-
-/* What to do for some uppercase characters, like meta characters,
- and some characters appearing in emacs_ctlx_keymap. This function
- is just a stub, you bind keys to it and the code in rl_dispatch ()
- is special cased. */
-rl_do_lowercase_version (ignore1, ignore2)
- int ignore1, ignore2;
-{
-}
-
-/* Rubout the character behind point. */
-rl_rubout (count)
- int count;
-{
- if (count < 0)
- {
- rl_delete (-count);
- return;
- }
-
- if (!rl_point)
- {
- ding ();
- return;
- }
-
- if (count > 1)
- {
- int orig_point = rl_point;
- rl_backward (count);
- rl_kill_text (orig_point, rl_point);
- }
- else
- {
- int c = the_line[--rl_point];
- rl_delete_text (rl_point, rl_point + 1);
-
- if (rl_point == rl_end && alphabetic (c) && last_c_pos)
- {
- backspace (1);
- putc (' ', out_stream);
- backspace (1);
- last_c_pos--;
- rl_display_fixed++;
- }
- }
-}
-
-/* Delete the character under the cursor. Given a numeric argument,
- kill that many characters instead. */
-rl_delete (count, invoking_key)
- int count;
-{
- if (count < 0)
- {
- rl_rubout (-count);
- return;
- }
-
- if (rl_point == rl_end)
- {
- ding ();
- return;
- }
-
-#ifdef VI_MODE
- if ((count > 1) || ((count == 1) && (rl_editing_mode == vi_mode)))
-#else
- if (count > 1)
-#endif
- {
- int orig_point = rl_point;
- while (count && (rl_point < rl_end))
- {
- rl_point++;
- count--;
- }
- rl_kill_text (orig_point, rl_point);
- rl_point = orig_point;
- }
- else
- rl_delete_text (rl_point, rl_point + 1);
-}
-
-
-/* **************************************************************** */
-/* */
-/* Kill commands */
-/* */
-/* **************************************************************** */
-
-/* The next two functions mimic unix line editing behaviour, except they
- save the deleted text on the kill ring. This is safer than not saving
- it, and since we have a ring, nobody should get screwed. */
-
-/* This does what C-w does in Unix. We can't prevent people from
- using behaviour that they expect. */
-rl_unix_word_rubout ()
-{
- if (!rl_point) ding ();
- else {
- int orig_point = rl_point;
- while (rl_point && whitespace (the_line[rl_point - 1]))
- rl_point--;
- while (rl_point && !whitespace (the_line[rl_point - 1]))
- rl_point--;
- rl_kill_text (rl_point, orig_point);
- }
-}
-
-/* Here is C-u doing what Unix does. You don't *have* to use these
- key-bindings. We have a choice of killing the entire line, or
- killing from where we are to the start of the line. We choose the
- latter, because if you are a Unix weenie, then you haven't backspaced
- into the line at all, and if you aren't, then you know what you are
- doing. */
-rl_unix_line_discard ()
-{
- if (!rl_point) ding ();
- else {
- rl_kill_text (rl_point, 0);
- rl_point = 0;
- }
-}
-
-
-
-/* **************************************************************** */
-/* */
-/* Commands For Typos */
-/* */
-/* **************************************************************** */
-
-/* Random and interesting things in here. */
-
-
-/* **************************************************************** */
-/* */
-/* Changing Case */
-/* */
-/* **************************************************************** */
-
-/* The three kinds of things that we know how to do. */
-#define UpCase 1
-#define DownCase 2
-#define CapCase 3
-
-/* Uppercase the word at point. */
-rl_upcase_word (count)
- int count;
-{
- rl_change_case (count, UpCase);
-}
-
-/* Lowercase the word at point. */
-rl_downcase_word (count)
- int count;
-{
- rl_change_case (count, DownCase);
-}
-
-/* Upcase the first letter, downcase the rest. */
-rl_capitalize_word (count)
- int count;
-{
- rl_change_case (count, CapCase);
-}
-
-/* The meaty function.
- Change the case of COUNT words, performing OP on them.
- OP is one of UpCase, DownCase, or CapCase.
- If a negative argument is given, leave point where it started,
- otherwise, leave it where it moves to. */
-rl_change_case (count, op)
- int count, op;
-{
- register int start = rl_point, end;
- int state = 0;
-
- rl_forward_word (count);
- end = rl_point;
-
- if (count < 0)
- {
- int temp = start;
- start = end;
- end = temp;
- }
-
- /* We are going to modify some text, so let's prepare to undo it. */
- rl_modifying (start, end);
-
- for (; start < end; start++)
- {
- switch (op)
- {
- case UpCase:
- the_line[start] = to_upper (the_line[start]);
- break;
-
- case DownCase:
- the_line[start] = to_lower (the_line[start]);
- break;
-
- case CapCase:
- if (state == 0)
- {
- the_line[start] = to_upper (the_line[start]);
- state = 1;
- }
- else
- {
- the_line[start] = to_lower (the_line[start]);
- }
- if (!pure_alphabetic (the_line[start]))
- state = 0;
- break;
-
- default:
- abort ();
- }
- }
- rl_point = end;
-}
-
-/* **************************************************************** */
-/* */
-/* Transposition */
-/* */
-/* **************************************************************** */
-
-/* Transpose the words at point. */
-rl_transpose_words (count)
- int count;
-{
- char *word1, *word2;
- int w1_beg, w1_end, w2_beg, w2_end;
- int orig_point = rl_point;
-
- if (!count) return;
-
- /* Find the two words. */
- rl_forward_word (count);
- w2_end = rl_point;
- rl_backward_word (1);
- w2_beg = rl_point;
- rl_backward_word (count);
- w1_beg = rl_point;
- rl_forward_word (1);
- w1_end = rl_point;
-
- /* Do some check to make sure that there really are two words. */
- if ((w1_beg == w2_beg) || (w2_beg < w1_end))
- {
- ding ();
- rl_point = orig_point;
- return;
- }
-
- /* Get the text of the words. */
- word1 = rl_copy (w1_beg, w1_end);
- word2 = rl_copy (w2_beg, w2_end);
-
- /* We are about to do many insertions and deletions. Remember them
- as one operation. */
- rl_begin_undo_group ();
-
- /* Do the stuff at word2 first, so that we don't have to worry
- about word1 moving. */
- rl_point = w2_beg;
- rl_delete_text (w2_beg, w2_end);
- rl_insert_text (word1);
-
- rl_point = w1_beg;
- rl_delete_text (w1_beg, w1_end);
- rl_insert_text (word2);
-
- /* This is exactly correct since the text before this point has not
- changed in length. */
- rl_point = w2_end;
-
- /* I think that does it. */
- rl_end_undo_group ();
- free (word1); free (word2);
-}
-
-/* Transpose the characters at point. If point is at the end of the line,
- then transpose the characters before point. */
-rl_transpose_chars (count)
- int count;
-{
- if (!count)
- return;
-
- if (!rl_point || rl_end < 2) {
- ding ();
- return;
- }
-
- while (count) {
- if (rl_point == rl_end) {
- int t = the_line[rl_point - 1];
- the_line[rl_point - 1] = the_line[rl_point - 2];
- the_line[rl_point - 2] = t;
- } else {
- int t = the_line[rl_point];
- the_line[rl_point] = the_line[rl_point - 1];
- the_line[rl_point - 1] = t;
- if (count < 0 && rl_point)
- rl_point--;
- else
- rl_point++;
- }
- if (count < 0)
- count++;
- else
- count--;
- }
-}
-
-
-/* **************************************************************** */
-/* */
-/* Bogus Flow Control */
-/* */
-/* **************************************************************** */
-
-rl_restart_output (count, key)
- int count, key;
-{
- int fildes = fileno (stdin);
-#ifdef TIOCSTART
- ioctl (fildes, TIOCSTART, 0);
-#endif /* TIOCSTART */
-}
-
-/* **************************************************************** */
-/* */
-/* Completion matching, from readline's point of view. */
-/* */
-/* **************************************************************** */
-
-/* Pointer to the generator function for completion_matches ().
- NULL means to use filename_entry_function (), the default filename
- completer. */
-Function *rl_completion_entry_function = (Function *)NULL;
-
-/* Pointer to alternative function to create matches.
- Function is called with TEXT, START, and END.
- START and END are indices in RL_LINE_BUFFER saying what the boundaries
- of TEXT are.
- If this function exists and returns NULL then call the value of
- rl_completion_entry_function to try to match, otherwise use the
- array of strings returned. */
-Function *rl_attempted_completion_function = (Function *)NULL;
-
-/* Complete the word at or before point. You have supplied the function
- that does the initial simple matching selection algorithm (see
- completion_matches ()). The default is to do filename completion. */
-rl_complete (ignore, invoking_key)
- int ignore, invoking_key;
-{
- rl_complete_internal (TAB);
- if (running_in_emacs)
- printf ("%s", the_line);
-}
-
-/* List the possible completions. See description of rl_complete (). */
-rl_possible_completions ()
-{
- rl_complete_internal ('?');
-}
-
-/* The user must press "y" or "n". Non-zero return means "y" pressed. */
-get_y_or_n ()
-{
- int c;
- loop:
- c = rl_read_key (in_stream);
- if (c == 'y' || c == 'Y') return (1);
- if (c == 'n' || c == 'N') return (0);
- if (c == ABORT_CHAR) rl_abort ();
- ding (); goto loop;
-}
-
-/* Up to this many items will be displayed in response to a
- possible-completions call. After that, we ask the user if
- she is sure she wants to see them all. */
-int rl_completion_query_items = 100;
-
-/* The basic list of characters that signal a break between words for the
- completer routine. The contents of this variable is what breaks words
- in the shell, i.e. " \t\n\"\\'`@$><=" */
-char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=";
-
-/* The list of characters that signal a break between words for
- rl_complete_internal. The default list is the contents of
- rl_basic_word_break_characters. */
-char *rl_completer_word_break_characters = (char *)NULL;
-
-/* List of characters that are word break characters, but should be left
- in TEXT when it is passed to the completion function. The shell uses
- this to help determine what kind of completing to do. */
-char *rl_special_prefixes = (char *)NULL;
-
-/* If non-zero, then disallow duplicates in the matches. */
-int rl_ignore_completion_duplicates = 1;
-
-/* Non-zero means that the results of the matches are to be treated
- as filenames. This is ALWAYS zero on entry, and can only be changed
- within a completion entry finder function. */
-int rl_filename_completion_desired = 0;
-
-/* Complete the word at or before point.
- WHAT_TO_DO says what to do with the completion.
- `?' means list the possible completions.
- TAB means do standard completion.
- `*' means insert all of the possible completions. */
-rl_complete_internal (what_to_do)
- int what_to_do;
-{
- char *filename_completion_function ();
- char **completion_matches (), **matches;
- Function *our_func;
- int start, end, delimiter = 0;
- char *text;
-
- if (rl_completion_entry_function)
- our_func = rl_completion_entry_function;
- else
- our_func = (int (*)())filename_completion_function;
-
- /* Only the completion entry function can change this. */
- rl_filename_completion_desired = 0;
-
- /* We now look backwards for the start of a filename/variable word. */
- end = rl_point;
- if (rl_point)
- {
- while (--rl_point &&
- !rindex (rl_completer_word_break_characters, the_line[rl_point]));
-
- /* If we are at a word break, then advance past it. */
- if (rindex (rl_completer_word_break_characters, (the_line[rl_point])))
- {
- /* If the character that caused the word break was a quoting
- character, then remember it as the delimiter. */
- if (rindex ("\"'", the_line[rl_point]) && (end - rl_point) > 1)
- delimiter = the_line[rl_point];
-
- /* If the character isn't needed to determine something special
- about what kind of completion to perform, then advance past it. */
-
- if (!rl_special_prefixes ||
- !rindex (rl_special_prefixes, the_line[rl_point]))
- rl_point++;
- }
- }
-
- start = rl_point;
- rl_point = end;
- text = rl_copy (start, end);
-
- /* If the user wants to TRY to complete, but then wants to give
- up and use the default completion function, they set the
- variable rl_attempted_completion_function. */
- if (rl_attempted_completion_function)
- {
- matches =
- (char **)(*rl_attempted_completion_function) (text, start, end);
-
- if (matches)
- goto after_usual_completion;
- }
-
- matches = completion_matches (text, our_func, start, end);
-
- after_usual_completion:
- free (text);
-
- if (!matches)
- ding ();
- else
- {
- register int i;
-
- some_matches:
-
- /* It seems to me that in all the cases we handle we would like
- to ignore duplicate possiblilities. Scan for the text to
- insert being identical to the other completions. */
- if (rl_ignore_completion_duplicates)
- {
- char *lowest_common;
- int j, newlen = 0;
-
- /* Sort the items. */
- /* It is safe to sort this array, because the lowest common
- denominator found in matches[0] will remain in place. */
- for (i = 0; matches[i]; i++);
- qsort (matches, i, sizeof (char *), compare_strings);
-
- /* Remember the lowest common denimator for it may be unique. */
- lowest_common = savestring (matches[0]);
-
- for (i = 0; matches[i + 1]; i++)
- {
- if (strcmp (matches[i], matches[i + 1]) == 0)
- {
- free (matches[i]);
- matches[i] = (char *)-1;
- }
- else
- newlen++;
- }
-
- /* We have marked all the dead slots with (char *)-1.
- Copy all the non-dead entries into a new array. */
- {
- char **temp_array =
- (char **)malloc ((3 + newlen) * sizeof (char *));
-
- for (i = 1, j = 1; matches[i]; i++)
- if (matches[i] != (char *)-1)
- temp_array[j++] = matches[i];
- temp_array[j] = (char *)NULL;
-
- if (matches[0] != (char *)-1)
- free (matches[0]);
- free (matches);
-
- matches = temp_array;
- }
-
- /* Place the lowest common denominator back in [0]. */
- matches[0] = lowest_common;
-
- /* If there is one string left, and it is identical to the
- lowest common denominator, then the LCD is the string to
- insert. */
- if (j == 2 && strcmp (matches[0], matches[1]) == 0)
- {
- free (matches[1]);
- matches[1] = (char *)NULL;
- }
- }
-
- switch (what_to_do)
- {
- case TAB:
- rl_delete_text (start, rl_point);
- rl_point = start;
- rl_insert_text (matches[0]);
-
- /* If there are more matches, ring the bell to indicate.
- If this was the only match, and we are hacking files,
- check the file to see if it was a directory. If so,
- add a '/' to the name. If not, and we are at the end
- of the line, then add a space. */
- if (matches[1])
- {
- ding (); /* There are other matches remaining. */
- }
- else
- {
- char temp_string[2];
-
- temp_string[0] = delimiter ? delimiter : ' ';
- temp_string[1] = '\0';
-
- if (rl_filename_completion_desired)
- {
- struct stat finfo;
- char *tilde_expand ();
- char *filename = tilde_expand (matches[0]);
-
- if ((stat (filename, &finfo) == 0) &&
- ((finfo.st_mode & S_IFMT) == S_IFDIR))
- {
- if (the_line[rl_point] != '/')
- rl_insert_text ("/");
- }
- else
- {
- if (rl_point == rl_end)
- rl_insert_text (temp_string);
- }
- free (filename);
- }
- else
- {
- if (rl_point == rl_end)
- rl_insert_text (temp_string);
- }
- }
- break;
-
- case '*':
- {
- int i = 1;
-
- rl_delete_text (start, rl_point);
- rl_point = start;
- rl_begin_undo_group ();
- if (matches[1])
- {
- while (matches[i])
- {
- rl_insert_text (matches[i++]);
- rl_insert_text (" ");
- }
- }
- else
- {
- rl_insert_text (matches[0]);
- rl_insert_text (" ");
- }
- rl_end_undo_group ();
- }
- break;
-
-
- case '?':
- {
- int len, count, limit, max = 0;
- int j, k, l;
-
- /* Handle simple case first. What if there is only one answer? */
- if (!matches[1])
- {
- char *rindex (), *temp;
-
- if (rl_filename_completion_desired)
- temp = rindex (matches[0], '/');
- else
- temp = (char *)NULL;
-
- if (!temp)
- temp = matches[0];
- else
- temp++;
-
- crlf ();
- fprintf (out_stream, "%s", temp);
- crlf ();
- goto restart;
- }
-
- /* There is more than one answer. Find out how many there are,
- and find out what the maximum printed length of a single entry
- is. */
- for (i = 1; matches[i]; i++)
- {
- char *rindex (), *temp = (char *)NULL;
-
- /* If we are hacking filenames, then only count the characters
- after the last slash in the pathname. */
- if (rl_filename_completion_desired)
- temp = rindex (matches[i], '/');
- else
- temp = (char *)NULL;
-
- if (!temp)
- temp = matches[i];
- else
- temp++;
-
- if (strlen (temp) > max)
- max = strlen (temp);
- }
-
- len = i;
-
- /* If there are many items, then ask the user if she
- really wants to see them all. */
- if (len >= rl_completion_query_items)
- {
- crlf ();
- fprintf (out_stream,
- "There are %d possibilities. Do you really", len);
- crlf ();
- fprintf (out_stream, "wish to see them all? (y or n)");
- fflush (out_stream);
- if (!get_y_or_n ())
- {
- crlf ();
- goto restart;
- }
- }
- /* How many items of MAX length can we fit in the screen window? */
- max += 2;
- limit = screenwidth / max;
- if (limit != 1 && (limit * max == screenwidth))
- limit--;
-
- /* How many iterations of the printing loop? */
- count = (len + (limit - 1)) / limit;
-
- /* Watch out for special case. If LEN is less than LIMIT, then
- just do the inner printing loop. */
- if (len < limit) count = 1;
-
- /* Sort the items if they are not already sorted. */
- if (!rl_ignore_completion_duplicates)
- {
- qsort (matches, len, sizeof (char *), compare_strings);
- }
-
- /* Print the sorted items, up-and-down alphabetically, like
- ls might. */
- crlf ();
-
- for (i = 1; i < count + 1; i++)
- {
- for (j = 0, l = i; j < limit; j++)
- {
- if (l > len || !matches[l])
- {
- break;
- }
- else
- {
- char *rindex (), *temp = (char *)NULL;
-
- if (rl_filename_completion_desired)
- temp = rindex (matches[l], '/');
- else
- temp = (char *)NULL;
-
- if (!temp)
- temp = matches[l];
- else
- temp++;
-
- fprintf (out_stream, "%s", temp);
- for (k = 0; k < max - strlen (temp); k++)
- putc (' ', out_stream);
- }
- l += count;
- }
- crlf ();
- }
- restart:
-
- rl_on_new_line ();
- }
- break;
-
- default:
- abort ();
- }
-
- for (i = 0; matches[i]; i++)
- free (matches[i]);
- free (matches);
- }
-}
-
-/* A completion function for usernames.
- TEXT contains a partial username preceded by a random
- character (usually `~'). */
-char *
-username_completion_function (text, state)
- int state;
- char *text;
-{
- static char *username = (char *)NULL;
- static struct passwd *entry;
- static int namelen;
-
- if (!state)
- {
- if (username)
- free (username);
- username = savestring (&text[1]);
- namelen = strlen (username);
- setpwent ();
- }
-
- while (entry = getpwent ())
- {
- if (strncmp (username, entry->pw_name, namelen) == 0)
- break;
- }
-
- if (!entry)
- {
- endpwent ();
- return ((char *)NULL);
- }
- else
- {
- char *value = (char *)xmalloc (2 + strlen (entry->pw_name));
- *value = *text;
- strcpy (value + 1, entry->pw_name);
- rl_filename_completion_desired = 1;
- return (value);
- }
-}
-
-/* If non-null, this contains the address of a function to call if the
- standard meaning for expanding a tilde fails. The function is called
- with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
- which is the expansion, or a NULL pointer if there is no expansion. */
-Function *rl_tilde_expander = (Function *)NULL;
-
-/* Expand FILENAME if it begins with a tilde. This always returns
- a new string. */
-char *
-tilde_expand (filename)
- char *filename;
-{
- char *dirname = filename ? savestring (filename) : (char *)NULL;
-
- if (dirname && *dirname == '~')
- {
- char *temp_name;
- if (!dirname[1] || dirname[1] == '/')
- {
- /* Prepend $HOME to the rest of the string. */
- char *temp_home = (char *)getenv ("HOME");
-
- temp_name = (char *)alloca (1 + strlen (&dirname[1])
- + (temp_home? strlen (temp_home) : 0));
- temp_name[0] = '\0';
- if (temp_home)
- strcpy (temp_name, temp_home);
- strcat (temp_name, &dirname[1]);
- free (dirname);
- dirname = savestring (temp_name);
- }
- else
- {
- struct passwd *getpwnam (), *user_entry;
- char *username = (char *)alloca (257);
- int i, c;
-
- for (i = 1; c = dirname[i]; i++)
- {
- if (c == '/') break;
- else username[i - 1] = c;
- }
- username[i - 1] = '\0';
-
- if (!(user_entry = getpwnam (username)))
- {
- /* If the calling program has a special syntax for
- expanding tildes, and we couldn't find a standard
- expansion, then let them try. */
- if (rl_tilde_expander)
- {
- char *expansion;
-
- expansion = (char *)(*rl_tilde_expander) (username);
-
- if (expansion)
- {
- temp_name = (char *)alloca (1 + strlen (expansion)
- + strlen (&dirname[i]));
- strcpy (temp_name, expansion);
- strcat (temp_name, &dirname[i]);
- free (expansion);
- goto return_name;
- }
- }
- /*
- * We shouldn't report errors.
- */
- }
- else
- {
- temp_name = (char *)alloca (1 + strlen (user_entry->pw_dir)
- + strlen (&dirname[i]));
- strcpy (temp_name, user_entry->pw_dir);
- strcat (temp_name, &dirname[i]);
- return_name:
- free (dirname);
- dirname = savestring (temp_name);
- }
- }
- }
- return (dirname);
-}
-
-
-/* **************************************************************** */
-/* */
-/* Undo, and Undoing */
-/* */
-/* **************************************************************** */
-
-/* Non-zero tells rl_delete_text and rl_insert_text to not add to
- the undo list. */
-int doing_an_undo = 0;
-
-/* The current undo list for THE_LINE. */
-UNDO_LIST *rl_undo_list = (UNDO_LIST *)NULL;
-
-/* Remember how to undo something. Concatenate some undos if that
- seems right. */
-rl_add_undo (what, start, end, text)
- enum undo_code what;
- int start, end;
- char *text;
-{
- UNDO_LIST *temp = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST));
- temp->what = what;
- temp->start = start;
- temp->end = end;
- temp->text = text;
- temp->next = rl_undo_list;
- rl_undo_list = temp;
-}
-
-/* Free the existing undo list. */
-free_undo_list ()
-{
- while (rl_undo_list) {
- UNDO_LIST *release = rl_undo_list;
- rl_undo_list = rl_undo_list->next;
-
- if (release->what == UNDO_DELETE)
- free (release->text);
-
- free (release);
- }
-}
-
-/* Undo the next thing in the list. Return 0 if there
- is nothing to undo, or non-zero if there was. */
-int
-rl_do_undo ()
-{
- UNDO_LIST *release;
- int waiting_for_begin = 0;
-
-undo_thing:
- if (!rl_undo_list)
- return (0);
-
- doing_an_undo = 1;
-
- switch (rl_undo_list->what) {
-
- /* Undoing deletes means inserting some text. */
- case UNDO_DELETE:
- rl_point = rl_undo_list->start;
- rl_insert_text (rl_undo_list->text);
- free (rl_undo_list->text);
- break;
-
- /* Undoing inserts means deleting some text. */
- case UNDO_INSERT:
- rl_delete_text (rl_undo_list->start, rl_undo_list->end);
- rl_point = rl_undo_list->start;
- break;
-
- /* Undoing an END means undoing everything 'til we get to
- a BEGIN. */
- case UNDO_END:
- waiting_for_begin++;
- break;
-
- /* Undoing a BEGIN means that we are done with this group. */
- case UNDO_BEGIN:
- if (waiting_for_begin)
- waiting_for_begin--;
- else
- abort ();
- break;
- }
-
- doing_an_undo = 0;
-
- release = rl_undo_list;
- rl_undo_list = rl_undo_list->next;
- free (release);
-
- if (waiting_for_begin)
- goto undo_thing;
-
- return (1);
-}
-
-/* Begin a group. Subsequent undos are undone as an atomic operation. */
-rl_begin_undo_group ()
-{
- rl_add_undo (UNDO_BEGIN, 0, 0, 0);
-}
-
-/* End an undo group started with rl_begin_undo_group (). */
-rl_end_undo_group ()
-{
- rl_add_undo (UNDO_END, 0, 0, 0);
-}
-
-/* Save an undo entry for the text from START to END. */
-rl_modifying (start, end)
- int start, end;
-{
- if (start > end)
- {
- int t = start;
- start = end;
- end = t;
- }
-
- if (start != end)
- {
- char *temp = rl_copy (start, end);
- rl_begin_undo_group ();
- rl_add_undo (UNDO_DELETE, start, end, temp);
- rl_add_undo (UNDO_INSERT, start, end, (char *)NULL);
- rl_end_undo_group ();
- }
-}
-
-/* Revert the current line to its previous state. */
-rl_revert_line ()
-{
- if (!rl_undo_list) ding ();
- else {
- while (rl_undo_list)
- rl_do_undo ();
- }
-}
-
-/* Do some undoing of things that were done. */
-rl_undo_command (count)
-{
- if (count < 0) return; /* Nothing to do. */
-
- while (count)
- {
- if (rl_do_undo ())
- {
- count--;
- }
- else
- {
- ding ();
- break;
- }
- }
-}
-
-/* **************************************************************** */
-/* */
-/* History Utilities */
-/* */
-/* **************************************************************** */
-
-/* We already have a history library, and that is what we use to control
- the history features of readline. However, this is our local interface
- to the history mechanism. */
-
-/* While we are editing the history, this is the saved
- version of the original line. */
-HIST_ENTRY *saved_line_for_history = (HIST_ENTRY *)NULL;
-
-/* Set the history pointer back to the last entry in the history. */
-start_using_history ()
-{
- using_history ();
- if (saved_line_for_history)
- free_history_entry (saved_line_for_history);
-
- saved_line_for_history = (HIST_ENTRY *)NULL;
-}
-
-/* Free the contents (and containing structure) of a HIST_ENTRY. */
-free_history_entry (entry)
- HIST_ENTRY *entry;
-{
- if (!entry) return;
- if (entry->line)
- free (entry->line);
- free (entry);
-}
-
-/* Perhaps put back the current line if it has changed. */
-maybe_replace_line ()
-{
- HIST_ENTRY *temp = current_history ();
-
- /* If the current line has changed, save the changes. */
- if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list)) {
- temp = replace_history_entry (where_history (), the_line, rl_undo_list);
- free (temp->line);
- free (temp);
- }
-}
-
-/* Put back the saved_line_for_history if there is one. */
-maybe_unsave_line ()
-{
- if (saved_line_for_history) {
- strcpy (the_line, saved_line_for_history->line);
- rl_undo_list = (UNDO_LIST *)saved_line_for_history->data;
- free_history_entry (saved_line_for_history);
- saved_line_for_history = (HIST_ENTRY *)NULL;
- rl_end = rl_point = strlen (the_line);
- } else {
- ding ();
- }
-}
-
-/* Save the current line in saved_line_for_history. */
-maybe_save_line ()
-{
- if (!saved_line_for_history) {
- saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
- saved_line_for_history->line = savestring (the_line);
- saved_line_for_history->data = (char *)rl_undo_list;
- }
-}
-
-
-
-/* **************************************************************** */
-/* */
-/* History Commands */
-/* */
-/* **************************************************************** */
-
-/* Meta-< goes to the start of the history. */
-rl_beginning_of_history ()
-{
- rl_get_previous_history (1 + where_history ());
-}
-
-/* Meta-> goes to the end of the history. (The current line). */
-rl_end_of_history ()
-{
- maybe_replace_line ();
- using_history ();
- maybe_unsave_line ();
-}
-
-/* Move down to the next history line. */
-rl_get_next_history (count)
- int count;
-{
- HIST_ENTRY *temp = (HIST_ENTRY *)NULL;
-
- if (count < 0)
- {
- rl_get_previous_history (-count);
- return;
- }
-
- if (!count)
- return;
-
- maybe_replace_line ();
-
- while (count)
- {
- temp = next_history ();
- if (!temp)
- break;
- --count;
- }
-
- if (!temp)
- maybe_unsave_line ();
- else
- {
- strcpy (the_line, temp->line);
- rl_undo_list = (UNDO_LIST *)temp->data;
- rl_end = rl_point = strlen (the_line);
- }
-}
-
-/* Get the previous item out of our interactive history, making it the current
- line. If there is no previous history, just ding. */
-rl_get_previous_history (count)
- int count;
-{
- HIST_ENTRY *old_temp = (HIST_ENTRY *)NULL;
- HIST_ENTRY *temp = (HIST_ENTRY *)NULL;
-
- if (count < 0)
- {
- rl_get_next_history (-count);
- return;
- }
-
- if (!count)
- return;
-
- /* If we don't have a line saved, then save this one. */
- maybe_save_line ();
-
- /* If the current line has changed, save the changes. */
- maybe_replace_line ();
-
- while (count)
- {
- temp = previous_history ();
- if (!temp)
- break;
- else
- old_temp = temp;
- --count;
- }
-
- /* If there was a large argument, and we moved back to the start of the
- history, that is not an error. So use the last value found. */
- if (!temp && old_temp)
- temp = old_temp;
-
- if (!temp)
- ding ();
- else
- {
- strcpy (the_line, temp->line);
- rl_undo_list = (UNDO_LIST *)temp->data;
- rl_end = rl_point = strlen (the_line);
-#ifdef VI_MODE
- if (rl_editing_mode == vi_mode)
- rl_point = 0;
-#endif /* VI_MODE */
- }
-}
-
-/* There is a command in ksh which yanks into this line, the last word
- of the previous line. Here it is. We left it on M-. */
-rl_yank_previous_last_arg (ignore)
- int ignore;
-{
-}
-
-
-
-/* **************************************************************** */
-/* */
-/* I-Search and Searching */
-/* */
-/* **************************************************************** */
-
-/* Search backwards through the history looking for a string which is typed
- interactively. Start with the current line. */
-rl_reverse_search_history (sign, key)
- int sign;
- int key;
-{
- rl_search_history (-sign, key);
-}
-
-/* Search forwards through the history looking for a string which is typed
- interactively. Start with the current line. */
-rl_forward_search_history (sign, key)
- int sign;
- int key;
-{
- rl_search_history (sign, key);
-}
-
-/* Display the current state of the search in the echo-area.
- SEARCH_STRING contains the string that is being searched for,
- DIRECTION is zero for forward, or 1 for reverse,
- WHERE is the history list number of the current line. If it is
- -1, then this line is the starting one. */
-rl_display_search (search_string, reverse_p, where)
- char *search_string;
- int reverse_p, where;
-{
- char *message = (char *)NULL;
-
- message =
- (char *)alloca (1 + (search_string ? strlen (search_string) : 0) + 30);
-
- *message = '\0';
-
-#ifdef NEVER
- if (where != -1)
- sprintf (message, "[%d]", where + history_base);
-#endif
-
- strcat (message, "(");
-
- if (reverse_p)
- strcat (message, "reverse-");
-
- strcat (message, "i-search)`");
-
- if (search_string)
- strcat (message, search_string);
-
- strcat (message, "': ");
- rl_message (message, 0, 0);
- rl_redisplay ();
-}
-
-/* Search through the history looking for an interactively typed string.
- This is analogous to i-search. We start the search in the current line.
- DIRECTION is which direction to search; > 0 means forward, < 0 means
- backwards. */
-rl_search_history (direction, invoking_key)
- int direction;
- int invoking_key;
-{
- /* The string that the user types in to search for. */
- char *search_string = (char *)alloca (128);
-
- /* The current length of SEARCH_STRING. */
- int search_string_index;
-
- /* The list of lines to search through. */
- char **lines;
-
- /* The length of LINES. */
- int hlen;
-
- /* Where we get LINES from. */
- HIST_ENTRY **hlist = history_list ();
-
- int orig_point = rl_point;
- int orig_line = where_history ();
- int last_found_line = orig_line;
- int c, done = 0;
- register int i = 0;
-
-
- /* The line currently being searched. */
- char *sline;
-
- /* Offset in that line. */
- int index;
-
- /* Non-zero if we are doing a reverse search. */
- int reverse = (direction < 0);
-
- /* Create an arrary of pointers to the lines that we want to search. */
-
- maybe_replace_line ();
- if (hlist)
- for (i = 0; hlist[i]; i++);
-
- /* Allocate space for this many lines, +1 for the current input line,
- and remember those lines. */
- lines = (char **)alloca ((1 + (hlen = i)) * sizeof (char *));
- for (i = 0; i < hlen; i++)
- lines[i] = hlist[i]->line;
-
- if (saved_line_for_history)
- lines[i] = saved_line_for_history->line;
- else
- {
- /* So I have to type it in this way instead. */
- lines[i] = (char *)alloca (1 + strlen (the_line));
- strcpy (lines[i], &the_line[0]);
- }
-
- hlen++;
-
- /* The line where we start the search. */
- i = orig_line;
-
- /* Initialize search parameters. */
- *search_string = '\0';
- search_string_index = 0;
-
- rl_display_search (search_string, reverse, -1);
-
- sline = the_line;
- index = rl_point;
-
- while (!done)
- {
- c = rl_read_key (in_stream);
-
- /* Hack C to Do What I Mean. */
- {
- Function *f = (Function *)NULL;
-
- if (keymap[c].type == ISFUNC)
- f = keymap[c].function;
-
- if (f == rl_reverse_search_history)
- c = reverse ? -1 : -2;
- else if (f == rl_forward_search_history)
- c = !reverse ? -1 : -2;
- }
-
- switch (c)
- {
- case ESC:
- done = 1;
- continue;
-
- /* case invoking_key: */
- case -1:
- goto search_again;
-
- /* switch directions */
- case -2:
- direction = -direction;
- reverse = (direction < 0);
-
- goto do_search;
-
- case CTRL ('G'):
- strcpy (the_line, lines[orig_line]);
- rl_point = orig_point;
- rl_end = strlen (the_line);
- rl_clear_message ();
- return;
-
- default:
- if (c < 32 || c > 126)
- {
- rl_execute_next (c);
- done = 1;
- continue;
- }
- else
- {
- search_string[search_string_index++] = c;
- search_string[search_string_index] = '\0';
- goto do_search;
-
- search_again:
-
- if (!search_string_index)
- continue;
- else
- {
- if (reverse)
- --index;
- else
- if (index != strlen (sline))
- ++index;
- else
- ding ();
- }
- do_search:
-
- while (1)
- {
- if (reverse)
- {
- while (index >= 0)
- if (strncmp
- (search_string,
- sline + index,
- search_string_index) == 0)
- goto string_found;
- else
- index--;
- }
- else
- {
- register int limit =
- (strlen (sline) - search_string_index) + 1;
-
- while (index < limit)
- {
- if (strncmp (search_string,
- sline + index,
- search_string_index) == 0)
- goto string_found;
- index++;
- }
- }
-
- next_line:
- i += direction;
-
- /* At limit for direction? */
- if ((reverse && i < 0) ||
- (!reverse && i == hlen))
- goto search_failed;
-
- sline = lines[i];
- if (reverse)
- index = strlen (sline);
- else
- index = 0;
-
- /* If the search string is longer than the current
- line, no match. */
- if (search_string_index > strlen (sline))
- goto next_line;
-
- /* Start actually searching. */
- if (reverse)
- index -= search_string_index;
- }
-
- search_failed:
- /* We cannot find the search string. Ding the bell. */
- ding ();
- i = last_found_line;
- break;
-
- string_found:
- /* We have found the search string. Just display it. But don't
- actually move there in the history list until the user accepts
- the location. */
- strcpy (the_line, lines[i]);
- rl_point = index;
- rl_end = strlen (the_line);
- last_found_line = i;
- rl_display_search (search_string, reverse,
- (i == orig_line) ? -1 : i);
- }
- }
- continue;
- }
- /* The user has won. They found the string that they wanted. Now all
- we have to do is place them there. */
- {
- int now = last_found_line;
-
- /* First put back the original state. */
- strcpy (the_line, lines[orig_line]);
-
- if (now < orig_line)
- rl_get_previous_history (orig_line - now);
- else
- rl_get_next_history (now - orig_line);
-
- rl_point = index;
- rl_clear_message ();
- }
-}
-
-/* Make C be the next command to be executed. */
-rl_execute_next (c)
- int c;
-{
- rl_pending_input = c;
-}
-
-/* **************************************************************** */
-/* */
-/* Killing Mechanism */
-/* */
-/* **************************************************************** */
-
-/* What we assume for a max number of kills. */
-#define DEFAULT_MAX_KILLS 10
-
-/* The real variable to look at to find out when to flush kills. */
-int rl_max_kills = DEFAULT_MAX_KILLS;
-
-/* Where to store killed text. */
-char **rl_kill_ring = (char **)NULL;
-
-/* Where we are in the kill ring. */
-int rl_kill_index = 0;
-
-/* How many slots we have in the kill ring. */
-int rl_kill_ring_length = 0;
-
-/* How to say that you only want to save a certain amount
- of kill material. */
-rl_set_retained_kills (num)
- int num;
-{}
-
-/* The way to kill something. This appends or prepends to the last
- kill, if the last command was a kill command. if FROM is less
- than TO, then the text is appended, otherwise prepended. If the
- last command was not a kill command, then a new slot is made for
- this kill. */
-rl_kill_text (from, to)
- int from, to;
-{
- int slot;
- char *text = rl_copy (from, to);
-
- /* Is there anything to kill? */
- if (from == to) {
- free (text);
- last_command_was_kill++;
- return;
- }
-
- /* Delete the copied text from the line. */
- rl_delete_text (from, to);
-
- /* First, find the slot to work with. */
- if (!last_command_was_kill) {
-
- /* Get a new slot. */
- if (!rl_kill_ring) {
-
- /* If we don't have any defined, then make one. */
- rl_kill_ring =
- (char **)xmalloc (((rl_kill_ring_length = 1) + 1) * sizeof (char *));
- slot = 1;
-
- } else {
-
- /* We have to add a new slot on the end, unless we have exceeded
- the max limit for remembering kills. */
- slot = rl_kill_ring_length;
- if (slot == rl_max_kills) {
- register int i;
- free (rl_kill_ring[0]);
- for (i = 0; i < slot; i++)
- rl_kill_ring[i] = rl_kill_ring[i + 1];
- } else {
- rl_kill_ring =
- (char **)xrealloc (rl_kill_ring,
- ((slot = (rl_kill_ring_length += 1)) + 1)
- * sizeof (char *));
- }
- }
- slot--;
- } else {
- slot = rl_kill_ring_length - 1;
- }
-
- /* If the last command was a kill, prepend or append. */
- if (last_command_was_kill) {
- char *old = rl_kill_ring[slot];
- char *new = (char *)xmalloc (1 + strlen (old) + strlen (text));
-
- if (from < to) {
- strcpy (new, old);
- strcat (new, text);
- } else {
- strcpy (new, text);
- strcat (new, old);
- }
- free (old);
- free (text);
- rl_kill_ring[slot] = new;
- } else {
- rl_kill_ring[slot] = text;
- }
- rl_kill_index = slot;
- last_command_was_kill++;
-}
-
-/* Now REMEMBER! In order to do prepending or appending correctly, kill
- commands always make rl_point's original position be the FROM argument,
- and rl_point's extent be the TO argument. */
-
-
-/* **************************************************************** */
-/* */
-/* Killing Commands */
-/* */
-/* **************************************************************** */
-
-/* Delete the word at point, saving the text in the kill ring. */
-rl_kill_word (count)
- int count;
-{
- int orig_point = rl_point;
-
- if (count < 0)
- rl_backward_kill_word (-count);
- else
- {
- rl_forward_word (count);
-
- if (rl_point != orig_point)
- rl_kill_text (orig_point, rl_point);
-
- rl_point = orig_point;
- }
-}
-
-/* Rubout the word before point, placing it on the kill ring. */
-rl_backward_kill_word (count)
- int count;
-{
- int orig_point = rl_point;
-
- if (count < 0)
- rl_kill_word (-count);
- else
- {
- rl_backward_word (count);
-
- if (rl_point != orig_point)
- rl_kill_text (orig_point, rl_point);
- }
-}
-
-/* Kill from here to the end of the line. If DIRECTION is negative, kill
- back to the line start instead. */
-rl_kill_line (direction)
- int direction;
-{
- int orig_point = rl_point;
-
- if (direction < 0)
- rl_backward_kill_line (1);
- else
- {
- rl_end_of_line ();
- if (orig_point != rl_point)
- rl_kill_text (orig_point, rl_point);
- rl_point = orig_point;
- }
-}
-
-/* Kill backwards to the start of the line. If DIRECTION is negative, kill
- forwards to the line end instead. */
-rl_backward_kill_line (direction)
- int direction;
-{
- int orig_point = rl_point;
-
- if (direction < 0)
- rl_kill_line (1);
- else
- {
- if (!rl_point)
- ding ();
- else
- {
- rl_beg_of_line ();
- rl_kill_text (orig_point, rl_point);
- }
- }
-}
-
-/* Yank back the last killed text. This ignores arguments. */
-rl_yank ()
-{
- if (!rl_kill_ring) rl_abort ();
- rl_insert_text (rl_kill_ring[rl_kill_index]);
-}
-
-/* If the last command was yank, or yank_pop, and the text just
- before point is identical to the current kill item, then
- delete that text from the line, rotate the index down, and
- yank back some other text. */
-rl_yank_pop ()
-{
- int l;
-
- if (((rl_last_func != rl_yank_pop) && (rl_last_func != rl_yank)) ||
- !rl_kill_ring)
- {
- rl_abort ();
- }
-
- l = strlen (rl_kill_ring[rl_kill_index]);
- if (((rl_point - l) >= 0) &&
- (strncmp (the_line + (rl_point - l),
- rl_kill_ring[rl_kill_index], l) == 0))
- {
- rl_delete_text ((rl_point - l), rl_point);
- rl_point -= l;
- rl_kill_index--;
- if (rl_kill_index < 0)
- rl_kill_index = rl_kill_ring_length - 1;
- rl_yank ();
- }
- else
- rl_abort ();
-
-}
-
-/* Yank the COUNTth argument from the previous history line. */
-rl_yank_nth_arg (count, ignore)
- int count;
-{
- register HIST_ENTRY *entry = previous_history ();
- char *arg;
-
- if (entry)
- next_history ();
- else
- {
- ding ();
- return;
- }
-
- arg = history_arg_extract (count, count, entry->line);
- if (!arg || !*arg)
- {
- ding ();
- return;
- }
-
- rl_begin_undo_group ();
- if (rl_point && the_line[rl_point - 1] != ' ')
- rl_insert_text (" ");
- rl_insert_text (arg);
- free (arg);
- rl_end_undo_group ();
-}
-
-/* Vi Mode. */
-#ifdef VI_MODE
-#include "vi_mode.c"
-#endif /* VI_MODE */
-
-/* How to toggle back and forth between editing modes. */
-rl_vi_editing_mode ()
-{
-#ifdef VI_MODE
- rl_editing_mode = vi_mode;
- rl_vi_insertion_mode ();
-#endif /* VI_MODE */
-}
-
-rl_emacs_editing_mode ()
-{
- rl_editing_mode = emacs_mode;
- keymap = emacs_standard_keymap;
-}
-
-
-/* **************************************************************** */
-/* */
-/* Completion */
-/* */
-/* **************************************************************** */
-
-/* Non-zero means that case is not significant in completion. */
-int completion_case_fold = 0;
-
-/* Return an array of (char *) which is a list of completions for TEXT.
- If there are no completions, return a NULL pointer.
- The first entry in the returned array is the substitution for TEXT.
- The remaining entries are the possible completions.
- The array is terminated with a NULL pointer.
-
- ENTRY_FUNCTION is a function of two args, and returns a (char *).
- The first argument is TEXT.
- The second is a state argument; it should be zero on the first call, and
- non-zero on subsequent calls. It returns a NULL pointer to the caller
- when there are no more matches.
- */
-char **
-completion_matches (text, entry_function)
- char *text;
- char *(*entry_function) ();
-{
- /* Number of slots in match_list. */
- int match_list_size;
-
- /* The list of matches. */
- char **match_list =
- (char **)xmalloc (((match_list_size = 10) + 1) * sizeof (char *));
-
- /* Number of matches actually found. */
- int matches = 0;
-
- /* Temporary string binder. */
- char *string;
-
- match_list[1] = (char *)NULL;
-
- while (string = (*entry_function) (text, matches))
- {
- if (matches + 1 == match_list_size)
- match_list =
- (char **)xrealloc (match_list,
- ((match_list_size += 10) + 1) * sizeof (char *));
-
- match_list[++matches] = string;
- match_list[matches + 1] = (char *)NULL;
- }
-
- /* If there were any matches, then look through them finding out the
- lowest common denominator. That then becomes match_list[0]. */
- if (matches)
- {
- register int i = 1;
- int low = 100000; /* Count of max-matched characters. */
-
- /* If only one match, just use that. */
- if (matches == 1)
- {
- match_list[0] = match_list[1];
- match_list[1] = (char *)NULL;
- }
- else
- {
- /* Otherwise, compare each member of the list with
- the next, finding out where they stop matching. */
-
- while (i < matches)
- {
- register int c1, c2, si;
-
- if (completion_case_fold)
- {
- for (si = 0;
- (c1 = to_lower(match_list[i][si])) &&
- (c2 = to_lower(match_list[i + 1][si]));
- si++)
- if (c1 != c2) break;
- }
- else
- {
- for (si = 0;
- (c1 = match_list[i][si]) &&
- (c2 = match_list[i + 1][si]);
- si++)
- if (c1 != c2) break;
- }
-
- if (low > si) low = si;
- i++;
- }
- match_list[0] = (char *)xmalloc (low + 1);
- strncpy (match_list[0], match_list[1], low);
- match_list[0][low] = '\0';
- }
- }
- else /* There were no matches. */
- {
- free (match_list);
- match_list = (char **)NULL;
- }
- return (match_list);
-}
-
-/* Okay, now we write the entry_function for filename completion. In the
- general case. Note that completion in the shell is a little different
- because of all the pathnames that must be followed when looking up the
- completion for a command. */
-char *
-filename_completion_function (text, state)
- int state;
- char *text;
-{
- static DIR *directory;
- static char *filename = (char *)NULL;
- static char *dirname = (char *)NULL;
- static char *users_dirname = (char *)NULL;
- static int filename_len;
-
- struct direct *entry = (struct direct *)NULL;
-
- /* If we don't have any state, then do some initialization. */
- if (!state)
- {
- char *rindex (), *temp;
-
- if (dirname) free (dirname);
- if (filename) free (filename);
- if (users_dirname) free (users_dirname);
-
- filename = savestring (text);
- if (!*text) text = ".";
- dirname = savestring (text);
-
- temp = rindex (dirname, '/');
-
- if (temp)
- {
- strcpy (filename, ++temp);
- *temp = '\0';
- }
- else
- strcpy (dirname, ".");
-
- /* We aren't done yet. We also support the "~user" syntax. */
-
- /* Save the version of the directory that the user typed. */
- users_dirname = savestring (dirname);
- {
- char *tilde_expand (), *temp_dirname = tilde_expand (dirname);
- free (dirname);
- dirname = temp_dirname;
-#ifdef SHELL
- {
- extern int follow_symbolic_links;
- char *make_absolute ();
-
- if (follow_symbolic_links && (strcmp (dirname, ".") != 0))
- {
- temp_dirname = make_absolute (dirname, get_working_directory (""));
-
- if (temp_dirname)
- {
- free (dirname);
- dirname = temp_dirname;
- }
- }
- }
-#endif /* SHELL */
- }
- directory = opendir (dirname);
- filename_len = strlen (filename);
-
- rl_filename_completion_desired = 1;
- }
-
- /* At this point we should entertain the possibility of hacking wildcarded
- filenames, like /usr/man*\/te<TAB>. If the directory name contains
- globbing characters, then build an array of directories to glob on, and
- glob on the first one. */
-
- /* Now that we have some state, we can read the directory. */
-
- while (directory && (entry = readdir (directory)))
- {
- /* Special case for no filename.
- All entries except "." and ".." match. */
- if (!filename_len)
- {
- if ((strcmp (entry->d_name, ".") != 0) &&
- (strcmp (entry->d_name, "..") != 0))
- break;
- }
- else
- {
- /* Otherwise, if these match upto the length of filename, then
- it is a match. */
-#ifdef TMB_SYSV
- if ((strlen (entry->d_name) >= filename_len) &&
- (strncmp (filename, entry->d_name, filename_len) == 0))
-#else
- if ((entry->d_namlen >= filename_len) &&
- (strncmp (filename, entry->d_name, filename_len) == 0))
-#endif /* TMB_SYSV */
- {
- break;
- }
- }
- }
-
- if (!entry)
- {
- if (directory)
- {
- closedir (directory);
- directory = (DIR *)NULL;
- }
- return (char *)NULL;
- }
- else
- {
- char *temp;
-
- if (dirname && (strcmp (dirname, ".") != 0))
- {
-#ifdef TMB_SYSV
- temp = (char *)xmalloc (1 + strlen (users_dirname)
- + strlen (entry->d_name));
-#else
- temp = (char *)xmalloc (1 + strlen (users_dirname)
- + entry->d_namlen);
-#endif /* TMB_SYSV */
- strcpy (temp, users_dirname);
- strcat (temp, entry->d_name);
- }
- else
- {
- temp = (savestring (entry->d_name));
- }
- return (temp);
- }
-}
-
-
-/* **************************************************************** */
-/* */
-/* Binding keys */
-/* */
-/* **************************************************************** */
-
-/* rl_add_defun (char *name, Function *function, int key)
- Add NAME to the list of named functions. Make FUNCTION
- be the function that gets called.
- If KEY is not -1, then bind it. */
-rl_add_defun (name, function, key)
- char *name;
- Function *function;
- int key;
-{
- if (key != -1)
- rl_bind_key (key, function);
- rl_add_funmap_entry (name, function);
-}
-
-/* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */
-int
-rl_bind_key (key, function)
- int key;
- Function *function;
-{
- if (key < 0)
- return (key);
-
- if (key > 127 && key < 256)
- {
- if (keymap[ESC].type == ISKMAP)
- {
- Keymap escmap = (Keymap)keymap[ESC].function;
-
- key -= 128;
- escmap[key].type = ISFUNC;
- escmap[key].function = function;
- return (0);
- }
- return (key);
- }
-
- keymap[key].type = ISFUNC;
- keymap[key].function = function;
- return (0);
-}
-
-/* Bind KEY to FUNCTION in MAP. Returns non-zero in case of invalid
- KEY. */
-int
-rl_bind_key_in_map (key, function, map)
- int key;
- Function *function;
- Keymap map;
-{
- int result;
- Keymap oldmap = keymap;
-
- keymap = map;
- result = rl_bind_key (key, function);
- keymap = oldmap;
- return (result);
-}
-
-/* Make KEY do nothing in the currently selected keymap.
- Returns non-zero in case of error. */
-int
-rl_unbind_key (key)
- int key;
-{
- return (rl_bind_key (key, (Function *)NULL));
-}
-
-/* Make KEY do nothing in MAP.
- Returns non-zero in case of error. */
-int
-rl_unbind_key_in_map (key, map)
- int key;
- Keymap map;
-{
- return (rl_bind_key_in_map (key, (Function *)NULL, map));
-}
-
-/* Bind the key sequence represented by the string KEYSEQ to
- FUNCTION. This makes new keymaps as necessary. The initial
- place to do bindings is in MAP. */
-rl_set_key (keyseq, function, map)
- char *keyseq;
- Function *function;
- Keymap map;
-{
- rl_generic_bind (ISFUNC, keyseq, function, map);
-}
-
-/* Bind the key sequence represented by the string KEYSEQ to
- the string of characters MACRO. This makes new keymaps as
- necessary. The initial place to do bindings is in MAP. */
-rl_macro_bind (keyseq, macro, map)
- char *keyseq, *macro;
- Keymap map;
-{
- char *macro_keys = (char *)xmalloc (2 * (strlen (macro)));
- int macro_keys_len;
-
- if (rl_translate_keyseq (macro, macro_keys, &macro_keys_len))
- {
- free (macro_keys);
- return;
- }
- rl_generic_bind (ISMACR, keyseq, macro_keys, map);
-}
-
-/* Bind the key sequence represented by the string KEYSEQ to
- the arbitrary pointer DATA. TYPE says what kind of data is
- pointed to by DATA, right now this can be a function (ISFUNC),
- a macro (ISMACR), or a keymap (ISKMAP). This makes new keymaps
- as necessary. The initial place to do bindings is in MAP. */
-rl_generic_bind (type, keyseq, data, map)
- int type;
- char *keyseq, *data;
- Keymap map;
-{
- char *keys;
- int keys_len;
- register int i;
- int start;
-
- /* If no keys to bind to, exit right away. */
- if (!keyseq || !*keyseq)
- {
- if (type == ISMACR)
- free (data);
- return;
- }
-
- keys = (char *)alloca (1 + (2 * strlen (keyseq)));
-
- /* Translate the ASCII representation of KEYSEQ into an array
- of characters. Stuff the characters into ARRAY, and the
- length of ARRAY into LENGTH. */
- if (rl_translate_keyseq (keyseq, keys, &keys_len))
- return;
-
- /* Handle mapping of the ESC Key in vi mode */
- start = 0;
-#ifdef VI_MODE
- if ((rl_editing_mode == vi_mode) && (keys[0] == ESC))
- {
- start++;
- map = vi_movement_keymap;
- if(keys[1] == ESC)
- {
- extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
-
- start++;
- map = vi_escape_keymap;
- }
- }
-#endif
-
- /* Bind keys, making new keymaps as necessary. */
- for (i = start; i < keys_len; i++)
- {
- if (i + 1 < keys_len)
- {
- if (map[keys[i]].type != ISKMAP)
- {
- if (map[i].type == ISMACR)
- free ((char *)map[i].function);
-
- map[keys[i]].type = ISKMAP;
- map[keys[i]].function = (Function *)rl_make_bare_keymap ();
- }
- map = (Keymap)map[keys[i]].function;
- }
- else
- {
- if (map[keys[i]].type == ISMACR)
- free ((char *)map[keys[i]].function);
-
- map[keys[i]].function = (Function *)data;
- map[keys[i]].type = type;
- }
- }
-}
-
-/* Translate the ASCII representation of SEQ, stuffing the
- values into ARRAY, an array of characters. LEN gets the
- final length of ARRAY. Return non-zero if there was an
- error parsing SEQ. */
-rl_translate_keyseq (seq, array, len)
- char *seq, *array;
- int *len;
-{
- register int i, c, l = 0;
-
- for (i = 0; c = seq[i]; i++)
- {
- if (c == '\\')
- {
- c = seq[++i];
-
- if (!c)
- break;
-
- if (((c == 'C' || c == 'M') && seq[i + 1] == '-') ||
- (c == 'e'))
- {
- /* Handle special case of backwards define. */
- if (strncmp (&seq[i], "C-\\M-", 5) == 0)
- {
- array[l++] = ESC;
- i += 5;
- array[l++] = CTRL (to_upper (seq[i]));
- if (!seq[i])
- i--;
- continue;
- }
-
- switch (c)
- {
- case 'M':
- i++;
- array[l++] = ESC;
- break;
-
- case 'C':
- i += 2;
- array[l++] = CTRL (to_upper (seq[i]));
- break;
-
- case 'e':
- array[l++] = ESC;
- }
-
- continue;
- }
- }
- array[l++] = c;
- }
-
- array[l] = '\0';
- *len = l;
- return (0);
-}
-
-/* Return a pointer to the function that STRING represents.
- If STRING doesn't have a matching function, then a NULL pointer
- is returned. */
-Function *
-rl_named_function (string)
- char *string;
-{
- register int i;
- static int stricmp ();
-
- for (i = 0; funmap[i]; i++)
- if (stricmp (funmap[i]->name, string) == 0)
- return (funmap[i]->function);
- return ((Function *)NULL);
-}
-
-/* The last key bindings file read. */
-static char *last_readline_init_file = "~/.inputrc";
-
-/* Re-read the current keybindings file. */
-rl_re_read_init_file (count, ignore)
- int count, ignore;
-{
- rl_read_init_file (last_readline_init_file);
-}
-
-/* Do key bindings from a file. If FILENAME is NULL it defaults
- to `~/.inputrc'. If the file existed and could be opened and
- read, 0 is returned, otherwise errno is returned. */
-int
-rl_read_init_file (filename)
- char *filename;
-{
- int line_size, line_index;
- char *line = (char *)xmalloc (line_size = 100);
- char *openname;
- FILE *file;
-
- int c;
-
- /* Default the filename. */
- if (!filename)
- filename = "~/.inputrc";
-
- openname = tilde_expand (filename);
-
- /* Open the file. */
- file = fopen (openname, "r");
- free (openname);
-
- if (!file)
- return (errno);
-
- last_readline_init_file = filename;
-
- /* Loop reading lines from the file. Lines that start with `#' are
- comments, all other lines are commands for readline initialization. */
- while ((c = getc(file)) != EOF)
- {
- /* If comment, flush to EOL. */
- if (c == '#')
- {
- while ((c = getc(file)) != EOF && c != '\n');
- if (c == EOF)
- goto function_exit;
- continue;
- }
-
- /* Otherwise, this is the start of a line. Read the
- line from the file. */
- line_index = 0;
- while (c != EOF && c != '\n')
- {
- line[line_index++] = c;
- if (line_index == line_size)
- line = (char *)xrealloc (line, line_size += 100);
- c = getc (file);
- }
- line[line_index] = '\0';
-
- /* Parse the line. */
- rl_parse_and_bind (line);
- }
-
-function_exit:
-
- free (line);
- /* Close up the file and exit. */
- fclose (file);
- return (0);
-}
-
-
-/* **************************************************************** */
-/* */
-/* Parser Directives */
-/* */
-/* **************************************************************** */
-
-/* Conditionals. */
-
-/* Calling programs set this to have their argv[0]. */
-char *rl_readline_name = "other";
-
-/* Stack of previous values of parsing_conditionalized_out. */
-static unsigned char *if_stack = (unsigned char *)NULL;
-static int if_stack_depth = 0;
-static int if_stack_size = 0;
-
-/* Push parsing_conditionalized_out, and set parser state based on ARGS. */
-parser_if (args)
- char *args;
-{
- register int i;
- static int stricmp ();
-
- /* Push parser state. */
- if (if_stack_depth + 1 >= if_stack_size)
- {
- if (!if_stack)
- if_stack = (unsigned char *)xmalloc (if_stack_size = 20);
- else
- if_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20);
- }
- if_stack[if_stack_depth++] = parsing_conditionalized_out;
-
- /* We only check to see if the first word in ARGS is the same as the
- value stored in rl_readline_name. */
-
- /* Isolate first argument. */
- for (i = 0; args[i] && !whitespace (args[i]); i++);
-
- if (args[i])
- args[i++] = '\0';
-
- if (stricmp (args, rl_readline_name) == 0)
- parsing_conditionalized_out = 0;
- else
- parsing_conditionalized_out = 1;
-}
-
-/* Invert the current parser state if there is anything on the stack. */
-parser_else (args)
- char *args;
-{
- if (if_stack_depth)
- parsing_conditionalized_out = !parsing_conditionalized_out;
- else
- {
- /* *** What, no error message? *** */
- }
-}
-
-/* Terminate a conditional, popping the value of
- parsing_conditionalized_out from the stack. */
-parser_endif (args)
- char *args;
-{
- if (if_stack_depth)
- parsing_conditionalized_out = if_stack[--if_stack_depth];
- else
- {
- /* *** What, no error message? *** */
- }
-}
-
-/* Associate textual names with actual functions. */
-static struct {
- char *name;
- Function *function;
-} parser_directives [] = {
- { "if", parser_if },
- { "endif", parser_endif },
- { "else", parser_else },
- { (char *)0x0, (Function *)0x0 }
-};
-
-/* Handle a parser directive. STATEMENT is the line of the directive
- without any leading `$'. */
-static int
-handle_parser_directive (statement)
- char *statement;
-{
- register int i;
- char *directive, *args;
- static int stricmp ();
-
- /* Isolate the actual directive. */
-
- /* Skip whitespace. */
- for (i = 0; whitespace (statement[i]); i++);
-
- directive = &statement[i];
-
- for (; statement[i] && !whitespace (statement[i]); i++);
-
- if (statement[i])
- statement[i++] = '\0';
-
- for (; statement[i] && whitespace (statement[i]); i++);
-
- args = &statement[i];
-
- /* Lookup the command, and act on it. */
- for (i = 0; parser_directives[i].name; i++)
- if (stricmp (directive, parser_directives[i].name) == 0)
- {
- (*parser_directives[i].function) (args);
- return (0);
- }
-
- /* *** Should an error message be output? */
- return (1);
-}
-
-/* Read the binding command from STRING and perform it.
- A key binding command looks like: Keyname: function-name\0,
- a variable binding command looks like: set variable value.
- A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */
-rl_parse_and_bind (string)
- char *string;
-{
- extern char *possible_control_prefixes[], *possible_meta_prefixes[];
- char *rindex (), *funname, *kname;
- static int substring_member_of_array (), stricmp ();
- register int c;
- int key, i;
-
- if (!string || !*string || *string == '#')
- return;
-
- /* If this is a parser directive, act on it. */
- if (*string == '$')
- {
- handle_parser_directive (&string[1]);
- return;
- }
-
- /* If we are supposed to be skipping parsing right now, then do it. */
- if (parsing_conditionalized_out)
- return;
-
- i = 0;
- /* If this keyname is a complex key expression surrounded by quotes,
- advance to after the matching close quote. */
- if (*string == '"')
- {
- for (i = 1; c = string[i]; i++)
- {
- if (c == '"' && string[i - 1] != '\\')
- break;
- }
- }
-
- /* Advance to the colon (:) or whitespace which separates the two objects. */
- for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ );
-
- /* Mark the end of the command (or keyname). */
- if (string[i])
- string[i++] = '\0';
-
- /* If this is a command to set a variable, then do that. */
- if (stricmp (string, "set") == 0)
- {
- char *var = string + i;
- char *value;
-
- /* Make VAR point to start of variable name. */
- while (*var && whitespace (*var)) var++;
-
- /* Make value point to start of value string. */
- value = var;
- while (*value && !whitespace (*value)) value++;
- if (*value)
- *value++ = '\0';
- while (*value && whitespace (*value)) value++;
-
- rl_variable_bind (var, value);
- return;
- }
-
- /* Skip any whitespace between keyname and funname. */
- for (; string[i] && whitespace (string[i]); i++);
- funname = &string[i];
-
- /* Now isolate funname.
- For straight function names just look for whitespace, since
- that will signify the end of the string. But this could be a
- macro definition. In that case, the string is quoted, so skip
- to the matching delimiter. */
- if (*funname == '\'' || *funname == '"')
- {
- int delimiter = string[i++];
-
- for (; c = string[i]; i++)
- {
- if (c == delimiter && string[i - 1] != '\\')
- break;
- }
- if (c)
- i++;
- }
-
- /* Advance to the end of the string. */
- for (; string[i] && !whitespace (string[i]); i++);
-
- /* No extra whitespace at the end of the string. */
- string[i] = '\0';
-
- /* If this is a new-style key-binding, then do the binding with
- rl_set_key (). Otherwise, let the older code deal with it. */
- if (*string == '"')
- {
- char *seq = (char *)alloca (1 + strlen (string));
- register int j, k = 0;
-
- for (j = 1; string[j]; j++)
- {
- if (string[j] == '"' && string[j - 1] != '\\')
- break;
-
- seq[k++] = string[j];
- }
- seq[k] = '\0';
-
- /* Binding macro? */
- if (*funname == '\'' || *funname == '"')
- {
- j = strlen (funname);
-
- if (j && funname[j - 1] == *funname)
- funname[j - 1] = '\0';
-
- rl_macro_bind (seq, &funname[1], keymap);
- }
- else
- rl_set_key (seq, rl_named_function (funname), keymap);
-
- return;
- }
-
- /* Get the actual character we want to deal with. */
- kname = rindex (string, '-');
- if (!kname)
- kname = string;
- else
- kname++;
-
- key = glean_key_from_name (kname);
-
- /* Add in control and meta bits. */
- if (substring_member_of_array (string, possible_control_prefixes))
- key = CTRL (to_upper (key));
-
- if (substring_member_of_array (string, possible_meta_prefixes))
- key = META (key);
-
- /* Temporary. Handle old-style keyname with macro-binding. */
- if (*funname == '\'' || *funname == '"')
- {
- char seq[2];
- int fl = strlen (funname);
-
- seq[0] = key; seq[1] = '\0';
- if (fl && funname[fl - 1] == *funname)
- funname[fl - 1] = '\0';
-
- rl_macro_bind (seq, &funname[1], keymap);
- }
- else
- rl_bind_key (key, rl_named_function (funname));
-}
-
-rl_variable_bind (name, value)
- char *name, *value;
-{
- static int strnicmp (), stricmp ();
-
- if (stricmp (name, "editing-mode") == 0)
- {
- if (strnicmp (value, "vi", 2) == 0)
- {
-#ifdef VI_MODE
- keymap = vi_insertion_keymap;
- rl_editing_mode = vi_mode;
-#endif /* VI_MODE */
- }
- else if (strnicmp (value, "emacs", 5) == 0)
- {
- keymap = emacs_standard_keymap;
- rl_editing_mode = emacs_mode;
- }
- }
- else if (stricmp (name, "horizontal-scroll-mode") == 0)
- {
- if (!*value || stricmp (value, "On") == 0)
- horizontal_scroll_mode = 1;
- else
- horizontal_scroll_mode = 0;
- }
-}
-
-/* Return the character which matches NAME.
- For example, `Space' returns ' '. */
-
-typedef struct {
- char *name;
- int value;
-} assoc_list;
-
-assoc_list name_key_alist[] = {
- { "Space", ' ' },
- { "SPC", ' ' },
- { "Rubout", 0x7f },
- { "DEL", 0x7f },
- { "Tab", 0x09 },
- { "Newline", '\n' },
- { "Return", '\r' },
- { "RET", '\r' },
- { "LFD", '\n' },
- { "Escape", '\033' },
- { "ESC", '\033' },
-
- { (char *)0x0, 0 }
-};
-
-int
-glean_key_from_name (name)
- char *name;
-{
- register int i;
- static int stricmp ();
-
- for (i = 0; name_key_alist[i].name; i++)
- if (stricmp (name, name_key_alist[i].name) == 0)
- return (name_key_alist[i].value);
-
- return (*name);
-}
-
-
-/* **************************************************************** */
-/* */
-/* String Utility Functions */
-/* */
-/* **************************************************************** */
-
-/* Return non-zero if any members of ARRAY are a substring in STRING. */
-static int
-substring_member_of_array (string, array)
- char *string, **array;
-{
- static char *strindex ();
-
- while (*array)
- {
- if (strindex (string, *array))
- return (1);
- array++;
- }
- return (0);
-}
-
-/* Whoops, Unix doesn't have strnicmp. */
-
-/* Compare at most COUNT characters from string1 to string2. Case
- doesn't matter. */
-static int
-strnicmp (string1, string2, count)
- char *string1, *string2;
-{
- register char ch1, ch2;
-
- while (count) {
- ch1 = *string1++;
- ch2 = *string2++;
- if (to_upper(ch1) == to_upper(ch2))
- count--;
- else break;
- }
- return (count);
-}
-
-/* strcmp (), but caseless. */
-static int
-stricmp (string1, string2)
- char *string1, *string2;
-{
- register char ch1, ch2;
-
- while (*string1 && *string2) {
- ch1 = *string1++;
- ch2 = *string2++;
- if (to_upper(ch1) != to_upper(ch2))
- return (1);
- }
- return (*string1 | *string2);
-}
-
-/* Determine if s2 occurs in s1. If so, return a pointer to the
- match in s1. The compare is case insensitive. */
-static char *
-strindex (s1, s2)
- register char *s1, *s2;
-{
- register int i, l = strlen (s2);
- register int len = strlen (s1);
-
- for (i = 0; (len - i) >= l; i++)
- if (strnicmp (&s1[i], s2, l) == 0)
- return (s1 + i);
- return ((char *)NULL);
-}
-
-
-#ifdef STATIC_MALLOC
-
-/* **************************************************************** */
-/* */
-/* xmalloc and xrealloc () */
-/* */
-/* **************************************************************** */
-
-static char *
-xmalloc (bytes)
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)malloc (bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static char *
-xrealloc (pointer, bytes)
- char *pointer;
- int bytes;
-{
- static memory_error_and_abort ();
- char *temp = (char *)realloc (pointer, bytes);
-
- if (!temp)
- memory_error_and_abort ();
- return (temp);
-}
-
-static
-memory_error_and_abort ()
-{
- fprintf (stderr, "readline: Out of virtual memory!\n");
- abort ();
-}
-#endif /* STATIC_MALLOC */
-
-
-/* **************************************************************** */
-/* */
-/* Testing Readline */
-/* */
-/* **************************************************************** */
-
-#ifdef TEST
-
-main ()
-{
- HIST_ENTRY **history_list ();
- char *temp = (char *)NULL;
- char *prompt = "readline% ";
- int done = 0;
-
- while (!done)
- {
- temp = readline (prompt);
-
- /* Test for EOF. */
- if (!temp)
- exit (1);
-
- /* If there is anything on the line, print it and remember it. */
- if (*temp)
- {
- fprintf (stderr, "%s\r\n", temp);
- add_history (temp);
- }
-
- /* Check for `command' that we handle. */
- if (strcmp (temp, "quit") == 0)
- done = 1;
-
- if (strcmp (temp, "list") == 0) {
- HIST_ENTRY **list = history_list ();
- register int i;
- if (list) {
- for (i = 0; list[i]; i++) {
- fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
- free (list[i]->line);
- }
- free (list);
- }
- }
- free (temp);
- }
-}
-
-#endif /* TEST */
-
-
-/*
- * Local variables:
- * compile-command: "gcc -g -traditional -I. -I.. -DTEST -o readline readline.c keymaps.o funmap.o history.o -ltermcap"
- * end:
- */
diff --git a/gnu/usr.bin/gdb/readline/readline.h b/gnu/usr.bin/gdb/readline/readline.h
deleted file mode 100644
index 7d7fbe7..0000000
--- a/gnu/usr.bin/gdb/readline/readline.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Readline.h -- the names of functions callable from within readline. */
-
-#ifndef _READLINE_H_
-#define _READLINE_H_
-
-#include <readline/keymaps.h>
-
-#ifndef __FUNCTION_DEF
-typedef int Function ();
-#define __FUNCTION_DEF
-#endif
-
-/* The functions for manipulating the text of the line within readline.
-Most of these functions are bound to keys by default. */
-extern int
-rl_beg_of_line (), rl_backward (), rl_delete (), rl_end_of_line (),
-rl_forward (), ding (), rl_backward (), rl_newline (), rl_kill_line (),
-rl_clear_screen (), rl_get_next_history (), rl_get_previous_history (),
-rl_quoted_insert (), rl_reverse_search_history (), rl_transpose_chars
-(), rl_unix_line_discard (), rl_quoted_insert (), rl_unix_word_rubout
-(), rl_yank (), rl_rubout (), rl_backward_word (), rl_kill_word (),
-rl_forward_word (), rl_tab_insert (), rl_yank_pop (), rl_yank_nth_arg (),
-rl_backward_kill_word (), rl_backward_kill_line (), rl_transpose_words
-(), rl_complete (), rl_possible_completions (), rl_do_lowercase_version
-(), rl_digit_argument (), rl_universal_argument (), rl_abort (),
-rl_undo_command (), rl_revert_line (), rl_beginning_of_history (),
-rl_end_of_history (), rl_forward_search_history (), rl_insert (),
-rl_upcase_word (), rl_downcase_word (), rl_capitalize_word (),
-rl_restart_output (), rl_re_read_init_file ();
-
-/* These are *both* defined even when VI_MODE is not. */
-extern int rl_vi_editing_mode (), rl_emacs_editing_mode ();
-
-#ifdef VI_MODE
-/* Things for vi mode. */
-extern int rl_vi_movement_mode (), rl_vi_insertion_mode (), rl_vi_arg_digit (),
-rl_vi_prev_word (), rl_vi_next_word (), rl_vi_char_search (),
-rl_vi_eof_maybe (), rl_vi_append_mode (), rl_vi_put (),
-rl_vi_append_eol (), rl_vi_insert_beg (), rl_vi_delete (), rl_vi_comment (),
-rl_vi_first_print (), rl_vi_fword (), rl_vi_fWord (), rl_vi_bword (),
-rl_vi_bWord (), rl_vi_eword (), rl_vi_eWord (), rl_vi_end_word (),
-rl_vi_change_case (), rl_vi_match (), rl_vi_bracktype (), rl_vi_change_char (),
-rl_vi_yank_arg (), rl_vi_search (), rl_vi_search_again (),
-rl_vi_dosearch (), rl_vi_subst (), rl_vi_overstrike (),
-rl_vi_overstrike_delete (), rl_vi_replace(), rl_vi_column (),
-rl_vi_delete_to (), rl_vi_change_to (), rl_vi_yank_to (), rl_vi_complete ();
-#endif /* VI_MODE */
-
-/* Keyboard macro commands. */
-extern int
-rl_start_kbd_macro (), rl_end_kbd_macro (), rl_call_last_kbd_macro ();
-
-/* Maintaining the state of undo. We remember individual deletes and inserts
- on a chain of things to do. */
-
-/* The actions that undo knows how to undo. Notice that UNDO_DELETE means
- to insert some text, and UNDO_INSERT means to delete some text. I.e.,
- the code tells undo what to undo, not how to undo it. */
-enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
-
-/* What an element of THE_UNDO_LIST looks like. */
-typedef struct undo_list {
- struct undo_list *next;
- int start, end; /* Where the change took place. */
- char *text; /* The text to insert, if undoing a delete. */
- enum undo_code what; /* Delete, Insert, Begin, End. */
-} UNDO_LIST;
-
-/* The current undo list for RL_LINE_BUFFER. */
-extern UNDO_LIST *rl_undo_list;
-
-/* The data structure for mapping textual names to code addresses. */
-typedef struct {
- char *name;
- Function *function;
-} FUNMAP;
-
-extern FUNMAP **funmap;
-
-/* **************************************************************** */
-/* */
-/* Well Published Variables */
-/* */
-/* **************************************************************** */
-
-/* The name of the calling program. You should initialize this to
- whatever was in argv[0]. It is used when parsing conditionals. */
-extern char *rl_readline_name;
-
-/* The line buffer that is in use. */
-extern char *rl_line_buffer;
-
-/* The location of point, and end. */
-extern int rl_point, rl_end;
-
-/* The name of the terminal to use. */
-extern char *rl_terminal_name;
-
-/* The input and output streams. */
-extern FILE *rl_instream, *rl_outstream;
-
-/* The basic list of characters that signal a break between words for the
- completer routine. The contents of this variable is what breaks words
- in the shell, i.e. "n\"\\'`@$>". */
-extern char *rl_basic_word_break_characters;
-
-/* The list of characters that signal a break between words for
- rl_complete_internal. The default list is the contents of
- rl_basic_word_break_characters. */
-extern char *rl_completer_word_break_characters;
-
-/* List of characters that are word break characters, but should be left
- in TEXT when it is passed to the completion function. The shell uses
- this to help determine what kind of completing to do. */
-extern char *rl_special_prefixes;
-
-/* Pointer to the generator function for completion_matches ().
- NULL means to use filename_entry_function (), the default filename
- completer. */
-extern Function *rl_completion_entry_function;
-
-/* Pointer to alternative function to create matches.
- Function is called with TEXT, START, and END.
- START and END are indices in RL_LINE_BUFFER saying what the boundaries
- of TEXT are.
- If this function exists and returns NULL then call the value of
- rl_completion_entry_function to try to match, otherwise use the
- array of strings returned. */
-extern Function *rl_attempted_completion_function;
-
-/* If non-null, this contains the address of a function to call if the
- standard meaning for expanding a tilde fails. The function is called
- with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
- which is the expansion, or a NULL pointer if there is no expansion. */
-extern Function *rl_tilde_expander;
-
-/* If non-zero, then this is the address of a function to call just
- before readline_internal () prints the first prompt. */
-extern Function *rl_startup_hook;
-
-/* **************************************************************** */
-/* */
-/* Well Published Functions */
-/* */
-/* **************************************************************** */
-
-/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
-extern char *readline ();
-
-/* Return an array of strings which are the result of repeatadly calling
- FUNC with TEXT. */
-extern char **completion_matches ();
-
-/* rl_add_defun (char *name, Function *function, int key)
- Add NAME to the list of named functions. Make FUNCTION
- be the function that gets called.
- If KEY is not -1, then bind it. */
-extern int rl_add_defun ();
-
-#endif /* _READLINE_H_ */
-
diff --git a/gnu/usr.bin/gdb/readline/vi_keymap.c b/gnu/usr.bin/gdb/readline/vi_keymap.c
deleted file mode 100644
index 71c7ec8..0000000
--- a/gnu/usr.bin/gdb/readline/vi_keymap.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * @(#)vi_keymap.c 6.4 (Berkeley) 5/8/91
- */
-
-/* vi_keymap.c -- the keymap for vi_mode in readline (). */
-
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
-
- This file is part of GNU Readline, a library for reading lines
- of text with interactive input and history editing.
-
- Readline is free software; you can 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.
-
- Readline is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifndef FILE
-#include <stdio.h>
-#endif /* FILE */
-
-#include "readline.h"
-
-extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
-
-/* The keymap arrays for handling vi mode. */
-KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
-
- /* The regular control keys come first. */
- { ISFUNC, (Function *)0x0 }, /* Control-@ */
- { ISFUNC, (Function *)0x0 }, /* Control-a */
- { ISFUNC, (Function *)0x0 }, /* Control-b */
- { ISFUNC, (Function *)0x0 }, /* Control-c */
- { ISFUNC, rl_vi_eof_maybe }, /* Control-d */
- { ISFUNC, rl_emacs_editing_mode }, /* Control-e */
- { ISFUNC, (Function *)0x0 }, /* Control-f */
- { ISFUNC, rl_abort }, /* Control-g */
- { ISFUNC, rl_backward }, /* Control-h */
- { ISFUNC, (Function *)0x0 }, /* Control-i */
- { ISFUNC, rl_newline }, /* Control-j */
- { ISFUNC, rl_kill_line }, /* Control-k */
- { ISFUNC, rl_clear_screen }, /* Control-l */
- { ISFUNC, rl_newline }, /* Control-m */
- { ISFUNC, rl_get_next_history }, /* Control-n */
- { ISFUNC, (Function *)0x0 }, /* Control-o */
- { ISFUNC, rl_get_previous_history }, /* Control-p */
- { ISFUNC, rl_quoted_insert }, /* Control-q */
- { ISFUNC, rl_reverse_search_history }, /* Control-r */
- { ISFUNC, rl_forward_search_history }, /* Control-s */
- { ISFUNC, rl_transpose_chars }, /* Control-t */
- { ISFUNC, rl_unix_line_discard }, /* Control-u */
- { ISFUNC, rl_quoted_insert }, /* Control-v */
- { ISFUNC, rl_unix_word_rubout }, /* Control-w */
- { ISFUNC, (Function *)0x0 }, /* Control-x */
- { ISFUNC, rl_yank }, /* Control-y */
- { ISFUNC, (Function *)0x0 }, /* Control-z */
-
- { ISKMAP, (Function *)vi_escape_keymap }, /* Control-[ */
- { ISFUNC, (Function *)0x0 }, /* Control-\ */
- { ISFUNC, (Function *)0x0 }, /* Control-] */
- { ISFUNC, (Function *)0x0 }, /* Control-^ */
- { ISFUNC, rl_undo_command }, /* Control-_ */
-
- /* The start of printing characters. */
- { ISFUNC, rl_forward }, /* SPACE */
- { ISFUNC, (Function *)0x0 }, /* ! */
- { ISFUNC, (Function *)0x0 }, /* " */
- { ISFUNC, rl_vi_comment }, /* # */
- { ISFUNC, rl_end_of_line }, /* $ */
- { ISFUNC, rl_vi_match }, /* % */
- { ISFUNC, (Function *)0x0 }, /* & */
- { ISFUNC, (Function *)0x0 }, /* ' */
- { ISFUNC, (Function *)0x0 }, /* ( */
- { ISFUNC, (Function *)0x0 }, /* ) */
- { ISFUNC, rl_vi_complete }, /* * */
- { ISFUNC, rl_get_previous_history}, /* + */
- { ISFUNC, rl_vi_char_search }, /* , */
- { ISFUNC, rl_get_next_history }, /* - */
- { ISFUNC, (Function *)0x0 }, /* . */
- { ISFUNC, rl_vi_search }, /* / */
-
- /* Regular digits. */
- { ISFUNC, rl_vi_arg_digit }, /* 0 */
- { ISFUNC, rl_vi_arg_digit }, /* 1 */
- { ISFUNC, rl_vi_arg_digit }, /* 2 */
- { ISFUNC, rl_vi_arg_digit }, /* 3 */
- { ISFUNC, rl_vi_arg_digit }, /* 4 */
- { ISFUNC, rl_vi_arg_digit }, /* 5 */
- { ISFUNC, rl_vi_arg_digit }, /* 6 */
- { ISFUNC, rl_vi_arg_digit }, /* 7 */
- { ISFUNC, rl_vi_arg_digit }, /* 8 */
- { ISFUNC, rl_vi_arg_digit }, /* 9 */
-
- /* A little more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* : */
- { ISFUNC, rl_vi_char_search }, /* ; */
- { ISFUNC, (Function *)0x0 }, /* < */
- { ISFUNC, (Function *)0x0 }, /* = */
- { ISFUNC, (Function *)0x0 }, /* > */
- { ISFUNC, rl_vi_search }, /* ? */
- { ISFUNC, (Function *)0x0 }, /* @ */
-
- /* Uppercase alphabet. */
- { ISFUNC, rl_vi_append_eol }, /* A */
- { ISFUNC, rl_vi_prev_word}, /* B */
- { ISFUNC, rl_vi_change_to }, /* C */
- { ISFUNC, rl_vi_delete_to }, /* D */
- { ISFUNC, rl_vi_end_word }, /* E */
- { ISFUNC, rl_vi_char_search }, /* F */
- { ISFUNC, (Function *)0x0 }, /* G */
- { ISFUNC, (Function *)0x0 }, /* H */
- { ISFUNC, rl_vi_insert_beg }, /* I */
- { ISFUNC, (Function *)0x0 }, /* J */
- { ISFUNC, (Function *)0x0 }, /* K */
- { ISFUNC, (Function *)0x0 }, /* L */
- { ISFUNC, (Function *)0x0 }, /* M */
- { ISFUNC, rl_vi_search_again }, /* N */
- { ISFUNC, (Function *)0x0 }, /* O */
- { ISFUNC, rl_vi_put }, /* P */
- { ISFUNC, (Function *)0x0 }, /* Q */
- { ISFUNC, rl_vi_replace }, /* R */
- { ISFUNC, rl_vi_subst }, /* S */
- { ISFUNC, rl_vi_char_search }, /* T */
- { ISFUNC, rl_revert_line }, /* U */
- { ISFUNC, (Function *)0x0 }, /* V */
- { ISFUNC, rl_vi_next_word }, /* W */
- { ISFUNC, rl_rubout }, /* X */
- { ISFUNC, rl_vi_yank_to }, /* Y */
- { ISFUNC, (Function *)0x0 }, /* Z */
-
- /* Some more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* [ */
- { ISFUNC, (Function *)0x0 }, /* \ */
- { ISFUNC, (Function *)0x0 }, /* ] */
- { ISFUNC, rl_vi_first_print }, /* ^ */
- { ISFUNC, rl_vi_yank_arg }, /* _ */
- { ISFUNC, (Function *)0x0 }, /* ` */
-
- /* Lowercase alphabet. */
- { ISFUNC, rl_vi_append_mode }, /* a */
- { ISFUNC, rl_vi_prev_word }, /* b */
- { ISFUNC, rl_vi_change_to }, /* c */
- { ISFUNC, rl_vi_delete_to }, /* d */
- { ISFUNC, rl_vi_end_word }, /* e */
- { ISFUNC, rl_vi_char_search }, /* f */
- { ISFUNC, (Function *)0x0 }, /* g */
- { ISFUNC, rl_backward }, /* h */
- { ISFUNC, rl_vi_insertion_mode }, /* i */
- { ISFUNC, rl_get_next_history }, /* j */
- { ISFUNC, rl_get_previous_history }, /* k */
- { ISFUNC, rl_forward }, /* l */
- { ISFUNC, (Function *)0x0 }, /* m */
- { ISFUNC, rl_vi_search_again }, /* n */
- { ISFUNC, (Function *)0x0 }, /* o */
- { ISFUNC, rl_vi_put }, /* p */
- { ISFUNC, (Function *)0x0 }, /* q */
- { ISFUNC, rl_vi_change_char }, /* r */
- { ISFUNC, rl_vi_subst }, /* s */
- { ISFUNC, rl_vi_char_search }, /* t */
- { ISFUNC, rl_undo_command }, /* u */
- { ISFUNC, (Function *)0x0 }, /* v */
- { ISFUNC, rl_vi_next_word }, /* w */
- { ISFUNC, rl_vi_delete }, /* x */
- { ISFUNC, rl_vi_yank_to }, /* y */
- { ISFUNC, (Function *)0x0 }, /* z */
-
- /* Final punctuation. */
- { ISFUNC, (Function *)0x0 }, /* { */
- { ISFUNC, rl_vi_column }, /* | */
- { ISFUNC, (Function *)0x0 }, /* } */
- { ISFUNC, rl_vi_change_case }, /* ~ */
- { ISFUNC, rl_backward } /* RUBOUT */
-};
-
-
-KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
-
- /* The regular control keys come first. */
- { ISFUNC, (Function *)0x0 }, /* Control-@ */
- { ISFUNC, rl_insert }, /* Control-a */
- { ISFUNC, rl_insert }, /* Control-b */
- { ISFUNC, rl_insert }, /* Control-c */
- { ISFUNC, rl_vi_eof_maybe }, /* Control-d */
- { ISFUNC, rl_insert }, /* Control-e */
- { ISFUNC, rl_insert }, /* Control-f */
- { ISFUNC, rl_insert }, /* Control-g */
- { ISFUNC, rl_rubout }, /* Control-h */
- { ISFUNC, rl_complete }, /* Control-i */
- { ISFUNC, rl_newline }, /* Control-j */
- { ISFUNC, rl_insert }, /* Control-k */
- { ISFUNC, rl_insert }, /* Control-l */
- { ISFUNC, rl_newline }, /* Control-m */
- { ISFUNC, rl_insert }, /* Control-n */
- { ISFUNC, rl_insert }, /* Control-o */
- { ISFUNC, rl_insert }, /* Control-p */
- { ISFUNC, rl_insert }, /* Control-q */
- { ISFUNC, rl_reverse_search_history }, /* Control-r */
- { ISFUNC, rl_forward_search_history }, /* Control-s */
- { ISFUNC, rl_transpose_chars }, /* Control-t */
- { ISFUNC, rl_unix_line_discard }, /* Control-u */
- { ISFUNC, rl_quoted_insert }, /* Control-v */
- { ISFUNC, rl_unix_word_rubout }, /* Control-w */
- { ISFUNC, rl_insert }, /* Control-x */
- { ISFUNC, rl_yank }, /* Control-y */
- { ISFUNC, rl_insert }, /* Control-z */
-
- { ISFUNC, rl_vi_movement_mode }, /* Control-[ */
- { ISFUNC, rl_insert }, /* Control-\ */
- { ISFUNC, rl_insert }, /* Control-] */
- { ISFUNC, rl_insert }, /* Control-^ */
- { ISFUNC, rl_undo_command }, /* Control-_ */
-
- /* The start of printing characters. */
- { ISFUNC, rl_insert }, /* SPACE */
- { ISFUNC, rl_insert }, /* ! */
- { ISFUNC, rl_insert }, /* " */
- { ISFUNC, rl_insert }, /* # */
- { ISFUNC, rl_insert }, /* $ */
- { ISFUNC, rl_insert }, /* % */
- { ISFUNC, rl_insert }, /* & */
- { ISFUNC, rl_insert }, /* ' */
- { ISFUNC, rl_insert }, /* ( */
- { ISFUNC, rl_insert }, /* ) */
- { ISFUNC, rl_insert }, /* * */
- { ISFUNC, rl_insert }, /* + */
- { ISFUNC, rl_insert }, /* , */
- { ISFUNC, rl_insert }, /* - */
- { ISFUNC, rl_insert }, /* . */
- { ISFUNC, rl_insert }, /* / */
-
- /* Regular digits. */
- { ISFUNC, rl_insert }, /* 0 */
- { ISFUNC, rl_insert }, /* 1 */
- { ISFUNC, rl_insert }, /* 2 */
- { ISFUNC, rl_insert }, /* 3 */
- { ISFUNC, rl_insert }, /* 4 */
- { ISFUNC, rl_insert }, /* 5 */
- { ISFUNC, rl_insert }, /* 6 */
- { ISFUNC, rl_insert }, /* 7 */
- { ISFUNC, rl_insert }, /* 8 */
- { ISFUNC, rl_insert }, /* 9 */
-
- /* A little more punctuation. */
- { ISFUNC, rl_insert }, /* : */
- { ISFUNC, rl_insert }, /* ; */
- { ISFUNC, rl_insert }, /* < */
- { ISFUNC, rl_insert }, /* = */
- { ISFUNC, rl_insert }, /* > */
- { ISFUNC, rl_insert }, /* ? */
- { ISFUNC, rl_insert }, /* @ */
-
- /* Uppercase alphabet. */
- { ISFUNC, rl_insert }, /* A */
- { ISFUNC, rl_insert }, /* B */
- { ISFUNC, rl_insert }, /* C */
- { ISFUNC, rl_insert }, /* D */
- { ISFUNC, rl_insert }, /* E */
- { ISFUNC, rl_insert }, /* F */
- { ISFUNC, rl_insert }, /* G */
- { ISFUNC, rl_insert }, /* H */
- { ISFUNC, rl_insert }, /* I */
- { ISFUNC, rl_insert }, /* J */
- { ISFUNC, rl_insert }, /* K */
- { ISFUNC, rl_insert }, /* L */
- { ISFUNC, rl_insert }, /* M */
- { ISFUNC, rl_insert }, /* N */
- { ISFUNC, rl_insert }, /* O */
- { ISFUNC, rl_insert }, /* P */
- { ISFUNC, rl_insert }, /* Q */
- { ISFUNC, rl_insert }, /* R */
- { ISFUNC, rl_insert }, /* S */
- { ISFUNC, rl_insert }, /* T */
- { ISFUNC, rl_insert }, /* U */
- { ISFUNC, rl_insert }, /* V */
- { ISFUNC, rl_insert }, /* W */
- { ISFUNC, rl_insert }, /* X */
- { ISFUNC, rl_insert }, /* Y */
- { ISFUNC, rl_insert }, /* Z */
-
- /* Some more punctuation. */
- { ISFUNC, rl_insert }, /* [ */
- { ISFUNC, rl_insert }, /* \ */
- { ISFUNC, rl_insert }, /* ] */
- { ISFUNC, rl_insert }, /* ^ */
- { ISFUNC, rl_insert }, /* _ */
- { ISFUNC, rl_insert }, /* ` */
-
- /* Lowercase alphabet. */
- { ISFUNC, rl_insert }, /* a */
- { ISFUNC, rl_insert }, /* b */
- { ISFUNC, rl_insert }, /* c */
- { ISFUNC, rl_insert }, /* d */
- { ISFUNC, rl_insert }, /* e */
- { ISFUNC, rl_insert }, /* f */
- { ISFUNC, rl_insert }, /* g */
- { ISFUNC, rl_insert }, /* h */
- { ISFUNC, rl_insert }, /* i */
- { ISFUNC, rl_insert }, /* j */
- { ISFUNC, rl_insert }, /* k */
- { ISFUNC, rl_insert }, /* l */
- { ISFUNC, rl_insert }, /* m */
- { ISFUNC, rl_insert }, /* n */
- { ISFUNC, rl_insert }, /* o */
- { ISFUNC, rl_insert }, /* p */
- { ISFUNC, rl_insert }, /* q */
- { ISFUNC, rl_insert }, /* r */
- { ISFUNC, rl_insert }, /* s */
- { ISFUNC, rl_insert }, /* t */
- { ISFUNC, rl_insert }, /* u */
- { ISFUNC, rl_insert }, /* v */
- { ISFUNC, rl_insert }, /* w */
- { ISFUNC, rl_insert }, /* x */
- { ISFUNC, rl_insert }, /* y */
- { ISFUNC, rl_insert }, /* z */
-
- /* Final punctuation. */
- { ISFUNC, rl_insert }, /* { */
- { ISFUNC, rl_insert }, /* | */
- { ISFUNC, rl_insert }, /* } */
- { ISFUNC, rl_insert }, /* ~ */
- { ISFUNC, rl_rubout } /* RUBOUT */
-};
-
-KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
-
- /* The regular control keys come first. */
- { ISFUNC, (Function *)0x0 }, /* Control-@ */
- { ISFUNC, (Function *)0x0 }, /* Control-a */
- { ISFUNC, (Function *)0x0 }, /* Control-b */
- { ISFUNC, (Function *)0x0 }, /* Control-c */
- { ISFUNC, (Function *)0x0 }, /* Control-d */
- { ISFUNC, (Function *)0x0 }, /* Control-e */
- { ISFUNC, (Function *)0x0 }, /* Control-f */
- { ISFUNC, (Function *)0x0 }, /* Control-g */
- { ISFUNC, (Function *)0x0 }, /* Control-h */
- { ISFUNC, rl_tab_insert}, /* Control-i */
- { ISFUNC, rl_emacs_editing_mode}, /* Control-j */
- { ISFUNC, rl_kill_line }, /* Control-k */
- { ISFUNC, (Function *)0x0 }, /* Control-l */
- { ISFUNC, rl_emacs_editing_mode}, /* Control-m */
- { ISFUNC, (Function *)0x0 }, /* Control-n */
- { ISFUNC, (Function *)0x0 }, /* Control-o */
- { ISFUNC, (Function *)0x0 }, /* Control-p */
- { ISFUNC, (Function *)0x0 }, /* Control-q */
- { ISFUNC, (Function *)0x0 }, /* Control-r */
- { ISFUNC, (Function *)0x0 }, /* Control-s */
- { ISFUNC, (Function *)0x0 }, /* Control-t */
- { ISFUNC, (Function *)0x0 }, /* Control-u */
- { ISFUNC, (Function *)0x0 }, /* Control-v */
- { ISFUNC, (Function *)0x0 }, /* Control-w */
- { ISFUNC, (Function *)0x0 }, /* Control-x */
- { ISFUNC, (Function *)0x0 }, /* Control-y */
- { ISFUNC, (Function *)0x0 }, /* Control-z */
-
- { ISFUNC, rl_vi_movement_mode }, /* Control-[ */
- { ISFUNC, (Function *)0x0 }, /* Control-\ */
- { ISFUNC, (Function *)0x0 }, /* Control-] */
- { ISFUNC, (Function *)0x0 }, /* Control-^ */
- { ISFUNC, rl_undo_command }, /* Control-_ */
-
- /* The start of printing characters. */
- { ISFUNC, (Function *)0x0 }, /* SPACE */
- { ISFUNC, (Function *)0x0 }, /* ! */
- { ISFUNC, (Function *)0x0 }, /* " */
- { ISFUNC, (Function *)0x0 }, /* # */
- { ISFUNC, (Function *)0x0 }, /* $ */
- { ISFUNC, (Function *)0x0 }, /* % */
- { ISFUNC, (Function *)0x0 }, /* & */
- { ISFUNC, (Function *)0x0 }, /* ' */
- { ISFUNC, (Function *)0x0 }, /* ( */
- { ISFUNC, (Function *)0x0 }, /* ) */
- { ISFUNC, (Function *)0x0 }, /* * */
- { ISFUNC, (Function *)0x0 }, /* + */
- { ISFUNC, (Function *)0x0 }, /* , */
- { ISFUNC, (Function *)0x0 }, /* - */
- { ISFUNC, (Function *)0x0 }, /* . */
- { ISFUNC, (Function *)0x0 }, /* / */
-
- /* Regular digits. */
- { ISFUNC, rl_vi_arg_digit }, /* 0 */
- { ISFUNC, rl_vi_arg_digit }, /* 1 */
- { ISFUNC, rl_vi_arg_digit }, /* 2 */
- { ISFUNC, rl_vi_arg_digit }, /* 3 */
- { ISFUNC, rl_vi_arg_digit }, /* 4 */
- { ISFUNC, rl_vi_arg_digit }, /* 5 */
- { ISFUNC, rl_vi_arg_digit }, /* 6 */
- { ISFUNC, rl_vi_arg_digit }, /* 7 */
- { ISFUNC, rl_vi_arg_digit }, /* 8 */
- { ISFUNC, rl_vi_arg_digit }, /* 9 */
-
- /* A little more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* : */
- { ISFUNC, (Function *)0x0 }, /* ; */
- { ISFUNC, (Function *)0x0 }, /* < */
- { ISFUNC, (Function *)0x0 }, /* = */
- { ISFUNC, (Function *)0x0 }, /* > */
- { ISFUNC, (Function *)0x0 }, /* ? */
- { ISFUNC, (Function *)0x0 }, /* @ */
-
- /* Uppercase alphabet. */
- { ISFUNC, rl_do_lowercase_version }, /* A */
- { ISFUNC, rl_do_lowercase_version }, /* B */
- { ISFUNC, rl_do_lowercase_version }, /* C */
- { ISFUNC, rl_do_lowercase_version }, /* D */
- { ISFUNC, rl_do_lowercase_version }, /* E */
- { ISFUNC, rl_do_lowercase_version }, /* F */
- { ISFUNC, rl_do_lowercase_version }, /* G */
- { ISFUNC, rl_do_lowercase_version }, /* H */
- { ISFUNC, rl_do_lowercase_version }, /* I */
- { ISFUNC, rl_do_lowercase_version }, /* J */
- { ISFUNC, rl_do_lowercase_version }, /* K */
- { ISFUNC, rl_do_lowercase_version }, /* L */
- { ISFUNC, rl_do_lowercase_version }, /* M */
- { ISFUNC, rl_do_lowercase_version }, /* N */
- { ISFUNC, rl_do_lowercase_version }, /* O */
- { ISFUNC, rl_do_lowercase_version }, /* P */
- { ISFUNC, rl_do_lowercase_version }, /* Q */
- { ISFUNC, rl_do_lowercase_version }, /* R */
- { ISFUNC, rl_do_lowercase_version }, /* S */
- { ISFUNC, rl_do_lowercase_version }, /* T */
- { ISFUNC, rl_do_lowercase_version }, /* U */
- { ISFUNC, rl_do_lowercase_version }, /* V */
- { ISFUNC, rl_do_lowercase_version }, /* W */
- { ISFUNC, rl_do_lowercase_version }, /* X */
- { ISFUNC, rl_do_lowercase_version }, /* Y */
- { ISFUNC, rl_do_lowercase_version }, /* Z */
-
- /* Some more punctuation. */
- { ISFUNC, (Function *)0x0 }, /* [ */
- { ISFUNC, (Function *)0x0 }, /* \ */
- { ISFUNC, (Function *)0x0 }, /* ] */
- { ISFUNC, (Function *)0x0 }, /* ^ */
- { ISFUNC, (Function *)0x0 }, /* _ */
- { ISFUNC, (Function *)0x0 }, /* ` */
-
- /* Lowercase alphabet. */
- { ISFUNC, (Function *)0x0 }, /* a */
- { ISFUNC, (Function *)0x0 }, /* b */
- { ISFUNC, (Function *)0x0 }, /* c */
- { ISFUNC, (Function *)0x0 }, /* d */
- { ISFUNC, (Function *)0x0 }, /* e */
- { ISFUNC, (Function *)0x0 }, /* f */
- { ISFUNC, (Function *)0x0 }, /* g */
- { ISFUNC, (Function *)0x0 }, /* h */
- { ISFUNC, (Function *)0x0 }, /* i */
- { ISFUNC, (Function *)0x0 }, /* j */
- { ISFUNC, (Function *)0x0 }, /* k */
- { ISFUNC, (Function *)0x0 }, /* l */
- { ISFUNC, (Function *)0x0 }, /* m */
- { ISFUNC, (Function *)0x0 }, /* n */
- { ISFUNC, (Function *)0x0 }, /* o */
- { ISFUNC, (Function *)0x0 }, /* p */
- { ISFUNC, (Function *)0x0 }, /* q */
- { ISFUNC, (Function *)0x0 }, /* r */
- { ISFUNC, (Function *)0x0 }, /* s */
- { ISFUNC, (Function *)0x0 }, /* t */
- { ISFUNC, (Function *)0x0 }, /* u */
- { ISFUNC, (Function *)0x0 }, /* v */
- { ISFUNC, (Function *)0x0 }, /* w */
- { ISFUNC, (Function *)0x0 }, /* x */
- { ISFUNC, (Function *)0x0 }, /* y */
- { ISFUNC, (Function *)0x0 }, /* z */
-
- /* Final punctuation. */
- { ISFUNC, (Function *)0x0 }, /* { */
- { ISFUNC, (Function *)0x0 }, /* | */
- { ISFUNC, (Function *)0x0 }, /* } */
- { ISFUNC, (Function *)0x0 }, /* ~ */
- { ISFUNC, rl_backward_kill_word } /* RUBOUT */
-};
diff --git a/gnu/usr.bin/gdb/readline/vi_mode.c b/gnu/usr.bin/gdb/readline/vi_mode.c
deleted file mode 100644
index 3a13cc6..0000000
--- a/gnu/usr.bin/gdb/readline/vi_mode.c
+++ /dev/null
@@ -1,875 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * @(#)vi_mode.c 6.4 (Berkeley) 5/8/91
- */
-
-/* vi_mode.c -- A vi emulation mode for Bash.
- Mostly written by Jeff Sparkes (jeff1@????).
- */
-
-
-/* **************************************************************** */
-/* */
-/* VI Emulation Mode */
-/* */
-/* **************************************************************** */
-
-/* Last string searched for from `/' or `?'. */
-static char *vi_last_search = (char *)NULL;
-static int vi_histpos;
-
-/* *** UNCLEAN *** */
-/* Command keys which do movement for xxx_to commands. */
-static char *vi_motion = " hl^$0ftFt;,%wbeWBE|";
-
-/* Keymap used for vi replace characters. Created dynamically since
- rarely used. */
-static Keymap vi_replace_map = (Keymap)NULL;
-
-/* The number of characters inserted in the last replace operation. */
-static vi_replace_count = 0;
-
-/* Yank the nth arg from the previous line into this line at point. */
-rl_vi_yank_arg (count)
- int count;
-{
- rl_yank_nth_arg (count);
-}
-
-/* Search again for the last thing searched for. */
-rl_vi_search_again (ignore, key)
- int ignore, key;
-{
- switch (key)
- {
- case 'n':
- rl_vi_dosearch (vi_last_search, -1);
- break;
-
- case 'N':
- rl_vi_dosearch (vi_last_search, 1);
- break;
- }
-}
-
-/* Do a vi style search. */
-rl_vi_search (count, key)
- int count, key;
-{
- int dir, c;
- char *p;
-
- switch (key)
- {
- case '?':
- dir = 1;
- break;
-
- case '/':
- dir = -1;
- break;
-
- default:
- ding ();
- return;
- }
-
- vi_histpos = where_history ();
- maybe_save_line ();
-
- /* Reuse the line input buffer to read the search string. */
- the_line[0] = 0;
- rl_end = rl_point = 0;
- p = (char *)alloca (2 + (rl_prompt ? strlen (rl_prompt) : 0));
-
- sprintf (p, "%s%c", rl_prompt ? rl_prompt : "", key);
-
- rl_message (p);
-
- while (c = rl_read_key (in_stream))
- {
- switch (c)
- {
- case CTRL('W'):
- case CTRL('U'):
- case CTRL('H'):
- case RUBOUT:
- rl_dispatch (c, keymap);
- break;
-
- case ESC:
- case RETURN:
- case NEWLINE:
- goto dosearch;
- break;
-
- case CTRL('C'):
- maybe_unsave_line ();
- rl_clear_message ();
- rl_point = 0;
- ding ();
- return;
-
- default:
- rl_insert (1, c);
- break;
- }
- rl_redisplay ();
- }
- dosearch:
- if (vi_last_search)
- free (vi_last_search);
-
- vi_last_search = savestring (the_line);
- rl_vi_dosearch (the_line, dir);
-}
-
-rl_vi_dosearch (string, dir)
- char *string;
- int dir;
-{
- int old, save = vi_histpos;
- HIST_ENTRY *h;
-
- if (string == 0 || *string == 0 || vi_histpos < 0)
- {
- ding ();
- return;
- }
-
- if ((save = history_search_pos (string, dir, vi_histpos + dir)) == -1)
- {
- maybe_unsave_line ();
- rl_clear_message ();
- rl_point = 0;
- ding ();
- return;
- }
-
- vi_histpos = save;
-
- old = where_history ();
- history_set_pos (vi_histpos);
- h = current_history ();
- history_set_pos (old);
-
- strcpy (the_line, h->line);
- rl_undo_list = (UNDO_LIST *)h->data;
- rl_end = strlen (the_line);
- rl_point = 0;
- rl_clear_message ();
-}
-
-/* Completion, from vi's point of view. */
-rl_vi_complete (ignore, key)
- int ignore, key;
-{
- if (!whitespace (the_line[rl_point]))
- {
- rl_vi_end_word (1, 'E');
- rl_point++;
- }
- rl_complete_internal ('*');
- rl_vi_insertion_mode ();
-}
-
-/* Previous word in vi mode. */
-rl_vi_prev_word (count, key)
- int count, key;
-{
- if (count < 0)
- {
- rl_vi_next_word (-count, key);
- return;
- }
-
- if (uppercase_p (key))
- rl_vi_bWord (count);
- else
- rl_vi_bword (count);
-}
-
-/* Next word in vi mode. */
-rl_vi_next_word (count, key)
- int count;
-{
- if (count < 0)
- {
- rl_vi_prev_word (-count, key);
- return;
- }
-
- if (uppercase_p (key))
- rl_vi_fWord (count);
- else
- rl_vi_fword (count);
-}
-
-/* Move to the end of the ?next? word. */
-rl_vi_end_word (count, key)
- int count, key;
-{
- if (count < 0)
- {
- ding ();
- return;
- }
-
- if (uppercase_p (key))
- rl_vi_eWord (count);
- else
- rl_vi_eword (count);
-}
-
-/* Move forward a word the way that 'W' does. */
-rl_vi_fWord (count)
- int count;
-{
- while (count-- && rl_point < (rl_end - 1))
- {
- /* Skip until whitespace. */
- while (!whitespace (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
-
- /* Now skip whitespace. */
- while (whitespace (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
- }
-}
-
-rl_vi_bWord (count)
- int count;
-{
- while (count-- && rl_point > 0)
- {
- while (rl_point-- >= 0 && whitespace (the_line[rl_point]));
- while (rl_point >= 0 && !whitespace (the_line[rl_point]))
- rl_point--;
- rl_point++;
- }
-}
-
-rl_vi_eWord (count)
- int count;
-{
- while (count -- && rl_point < (rl_end - 1))
- {
- while (rl_point++ < rl_end && whitespace (the_line[rl_point]));
- while (rl_point++ < rl_end && !whitespace (the_line[rl_point]));
- rl_point--;
- }
-}
-
-rl_vi_fword (count)
- int count;
-{
- while (count -- && rl_point < (rl_end - 1))
- {
- if (isident (the_line[rl_point]))
- {
- while (isident (the_line[rl_point]) && rl_point < rl_end)
- rl_point += 1;
- }
- else if (!whitespace (the_line[rl_point]))
- {
- while (!isident (the_line[rl_point]) &&
- !whitespace (the_line[rl_point]) && rl_point < rl_end)
- rl_point += 1;
- }
-
- while (whitespace (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
- }
-}
-
-rl_vi_bword (count)
- int count;
-{
- while (count -- && rl_point > 0)
- {
- while (--rl_point > 0 && whitespace (the_line[rl_point]));
- if (rl_point > 0)
- {
- if (isident (the_line[rl_point]))
- while (--rl_point >= 0 && isident (the_line[rl_point]));
- else
- while (--rl_point >= 0 && !isident (the_line[rl_point]) &&
- !whitespace (the_line[rl_point]));
- rl_point++;
- }
- }
-}
-
-rl_vi_eword (count)
- int count;
-{
- while (count -- && rl_point < rl_end - 1)
- {
- while (++rl_point < rl_end && whitespace (the_line[rl_point]));
-
- if (rl_point < rl_end)
- {
- if (isident (the_line[rl_point]))
- while (++rl_point < rl_end && isident (the_line[rl_point]));
- else
- while (++rl_point < rl_end && !isident (the_line[rl_point])
- && !whitespace (the_line[rl_point]));
- rl_point--;
- }
- }
-}
-
-rl_vi_insert_beg ()
-{
- rl_beg_of_line ();
- rl_vi_insertion_mode ();
- return 0;
-}
-
-rl_vi_append_mode ()
-{
- if (rl_point < rl_end)
- rl_point += 1;
- rl_vi_insertion_mode ();
- return 0;
-}
-
-rl_vi_append_eol ()
-{
- rl_end_of_line ();
- rl_vi_append_mode ();
- return 0;
-}
-
-/* What to do in the case of C-d. */
-rl_vi_eof_maybe (count, c)
- int count, c;
-{
- rl_newline (1, '\n');
-}
-
-/* Insertion mode stuff. */
-
-/* Switching from one mode to the other really just involves
- switching keymaps. */
-rl_vi_insertion_mode ()
-{
- keymap = vi_insertion_keymap;
-}
-
-rl_vi_movement_mode ()
-{
- if (rl_point > 0)
- rl_backward (1);
-
- keymap = vi_movement_keymap;
- if (vi_doing_insert)
- {
- rl_end_undo_group ();
- vi_doing_insert = 0;
- }
-}
-
-rl_vi_arg_digit (count, c)
- int count, c;
-{
- if (c == '0' && rl_numeric_arg == 1 && !rl_explicit_arg)
- rl_beg_of_line ();
- else
- rl_digit_argument (count, c);
-}
-
-/* Doesn't take an arg count in vi */
-rl_vi_change_case (ignore1, ignore2)
- int ignore1, ignore2;
-{
- char c = 0;
-
- if (uppercase_p (the_line[rl_point]))
- c = to_lower (the_line[rl_point]);
- else if (lowercase_p (the_line[rl_point]))
- c = to_upper (the_line[rl_point]);
-
- /* Vi is kind of strange here. */
- if (c)
- {
- rl_begin_undo_group ();
- rl_delete (1);
- rl_insert (1, c);
- rl_end_undo_group ();
- rl_vi_check ();
- }
- else
- rl_forward (1);
-}
-
-rl_vi_put (count, key)
- int count, key;
-{
- if (!uppercase_p (key))
- {
- if(rl_point != rl_end)
- rl_point++;
- }
-
- rl_yank ();
- rl_backward (1);
-}
-
-rl_vi_check ()
-{
- if (rl_point && rl_point == rl_end)
- rl_point--;
-}
-
-rl_vi_column (count)
-{
- if (count > rl_end)
- rl_end_of_line ();
- else
- rl_point = count - 1;
-}
-
-int
-rl_vi_domove ()
-{
- int c, save;
-
- rl_mark = rl_point;
- c = rl_read_key (in_stream);
-
- if (!member (c, vi_motion))
- {
- if (digit (c))
- {
- save = rl_numeric_arg;
- rl_digit_loop1 ();
- rl_numeric_arg *= save;
- }
- else
- return (-1);
- }
-
- rl_dispatch (c, keymap);
-
- /* No change in position means the command failed. */
- if (rl_mark == rl_point)
- return (-1);
-
- if ((c == 'w' || c == 'W') && rl_point < rl_end)
- {
- rl_point--;
- while((rl_point > 0) && whitespace (the_line[rl_point]))
- rl_point--;
- rl_point++;
- }
-
- if (rl_mark < rl_point)
- exchange (rl_point, rl_mark);
-
- return (0);
-}
-
-/* A simplified loop for vi. Don't dispatch key at end.
- Don't recognize minus sign? */
-rl_digit_loop1 ()
-{
- int key, c;
-
- while (1)
- {
- rl_message ("(arg: %d) ", arg_sign * rl_numeric_arg);
- key = c = rl_read_key ();
-
- if (keymap[c].type == ISFUNC &&
- keymap[c].function == rl_universal_argument)
- {
- rl_numeric_arg *= 4;
- continue;
- }
- c = UNMETA (c);
- if (numeric (c))
- {
- if (rl_explicit_arg)
- rl_numeric_arg = (rl_numeric_arg * 10) + (c - '0');
- else
- rl_numeric_arg = (c - '0');
- rl_explicit_arg = 1;
- }
- else
- {
- rl_clear_message ();
- rl_stuff_char (key);
- }
- }
-}
-
-rl_vi_delete_to (count, key)
- int count, key;
-{
- if (uppercase_p (key))
- rl_stuff_char ('$');
-
- if (rl_vi_domove ())
- {
- ding ();
- return;
- }
-
- rl_kill_text (rl_point, rl_mark);
-}
-
-rl_vi_change_to (count, key)
- int count, key;
-{
- if (uppercase_p (key))
- rl_stuff_char ('$');
-
- if (rl_vi_domove ())
- {
- ding ();
- return;
- }
-
- rl_begin_undo_group ();
- vi_doing_insert = 1;
- rl_kill_text (rl_point, rl_mark);
- rl_vi_insertion_mode ();
-}
-
-rl_vi_yank_to (count, key)
- int count, key;
-{
- int save = rl_point;
-
- if (uppercase_p (key))
- rl_stuff_char ('$');
-
- if (rl_vi_domove ())
- {
- ding ();
- return;
- }
-
- rl_begin_undo_group ();
- rl_kill_text (rl_point, rl_mark);
- rl_end_undo_group ();
- rl_do_undo ();
- rl_point = save;
-}
-
-rl_vi_delete (count)
-{
- if (rl_point >= rl_end - 1)
- {
- rl_delete (count);
- if (rl_point > 0)
- rl_backward (1);
- }
- else
- rl_delete (count);
-}
-
-/* Turn the current line into a comment in shell history. A ksh function */
-rl_vi_comment ()
-{
- rl_beg_of_line ();
- rl_insert_text (": "); /* # doesn't work in interactive mode */
- rl_redisplay ();
- rl_newline (1, '\010');
-}
-
-rl_vi_first_print ()
-{
- rl_back_to_indent ();
-}
-
-rl_back_to_indent (ignore1, ignore2)
- int ignore1, ignore2;
-{
- rl_beg_of_line ();
- while (rl_point < rl_end && whitespace (the_line[rl_point]))
- rl_point++;
-}
-
-/* NOTE: it is necessary that opposite directions are inverses */
-#define FTO 1 /* forward to */
-#define BTO -1 /* backward to */
-#define FFIND 2 /* forward find */
-#define BFIND -2 /* backward find */
-
-rl_vi_char_search (count, key)
- int count, key;
-{
- static char target;
- static int orig_dir, dir;
- int pos;
-
- if (key == ';' || key == ',')
- dir = (key == ';' ? orig_dir : -orig_dir);
- else
- {
- target = rl_read_key();
-
- switch (key)
- {
- case 't':
- orig_dir = dir = FTO;
- break;
-
- case 'T':
- orig_dir = dir = BTO;
- break;
-
- case 'f':
- orig_dir = dir = FFIND;
- break;
-
- case 'F':
- orig_dir = dir = BFIND;
- break;
- }
- }
-
- pos = rl_point;
-
- if (dir < 0)
- {
- pos--;
- do
- {
- if (the_line[pos] == target)
- {
- if (dir == BTO)
- rl_point = pos + 1;
- else
- rl_point = pos;
- return;
- }
- }
- while (pos--);
-
- if (pos < 0)
- {
- ding ();
- return;
- }
- }
- else
- { /* dir > 0 */
- pos++;
- do
- {
- if (the_line[pos] == target)
- {
- if (dir == FTO)
- rl_point = pos - 1;
- else
- rl_point = pos;
- return;
- }
- }
- while (++pos < rl_end);
-
- if (pos >= (rl_end - 1))
- ding ();
- }
-}
-
-/* Match brackets */
-rl_vi_match ()
-{
- int count = 1, brack, pos;
-
- pos = rl_point;
- if ((brack = rl_vi_bracktype (the_line[rl_point])) == 0)
- {
- while ((brack = rl_vi_bracktype (the_line[rl_point])) == 0 &&
- rl_point < rl_end - 1)
- rl_forward (1);
-
- if (brack <= 0)
- {
- rl_point = pos;
- ding ();
- return;
- }
- }
-
- pos = rl_point;
-
- if (brack < 0)
- {
- while (count)
- {
- if (--pos >= 0)
- {
- int b = rl_vi_bracktype (the_line[pos]);
- if (b == -brack)
- count--;
- else if (b == brack)
- count++;
- }
- else
- {
- ding ();
- return;
- }
- }
- }
- else
- { /* brack > 0 */
- while (count)
- {
- if (++pos < rl_end)
- {
- int b = rl_vi_bracktype (the_line[pos]);
- if (b == -brack)
- count--;
- else if (b == brack)
- count++;
- }
- else
- {
- ding ();
- return;
- }
- }
- }
- rl_point = pos;
-}
-
-int
-rl_vi_bracktype (c)
- int c;
-{
- switch (c)
- {
- case '(': return 1;
- case ')': return -1;
- case '[': return 2;
- case ']': return -2;
- case '{': return 3;
- case '}': return -3;
- default: return 0;
- }
-}
-
-rl_vi_change_char ()
-{
- int c;
-
- c = rl_read_key();
-
- switch (c)
- {
- case '\033':
- case CTRL('C'):
- return;
-
- default:
- rl_begin_undo_group ();
- rl_delete (1);
- rl_insert (1, c);
- rl_end_undo_group ();
- break;
- }
-}
-
-rl_vi_subst (count, key)
- int count, key;
-{
- rl_begin_undo_group ();
- vi_doing_insert = 1;
-
- if (uppercase_p (key))
- {
- rl_beg_of_line ();
- rl_kill_line (1);
- }
- else
- rl_delete (1);
-
- rl_vi_insertion_mode ();
-}
-
-rl_vi_overstrike (count, key)
- int count, key;
-{
- int i;
-
- if (vi_doing_insert == 0)
- {
- vi_doing_insert = 1;
- rl_begin_undo_group ();
- }
-
- for (i = 0; i < count; i++)
- {
- vi_replace_count++;
- rl_begin_undo_group ();
-
- if (rl_point < rl_end)
- {
- rl_delete (1);
- rl_insert (1, key);
- }
- else
- rl_insert (1, key);
-
- rl_end_undo_group ();
- }
-}
-
-rl_vi_overstrike_delete (count)
- int count;
-{
- int i, s;
-
- for (i = 0; i < count; i++)
- {
- if (vi_replace_count == 0)
- {
- ding ();
- break;
- }
- s = rl_point;
-
- if (rl_do_undo ())
- vi_replace_count--;
-
- if (rl_point == s)
- rl_backward (1);
- }
-
- if (vi_replace_count == 0 && vi_doing_insert)
- {
- rl_end_undo_group ();
- rl_do_undo ();
- vi_doing_insert = 0;
- }
-}
-
-rl_vi_replace ()
-{
- int i;
-
- vi_replace_count = 0;
-
- vi_replace_map = rl_make_bare_keymap ();
-
- for (i = ' '; i < 127; i++)
- vi_replace_map[i].function = rl_vi_overstrike;
-
- vi_replace_map[RUBOUT].function = rl_vi_overstrike_delete;
- vi_replace_map[CTRL('H')].function = rl_vi_overstrike_delete;
- vi_replace_map[ESC].function = rl_vi_movement_mode;
- vi_replace_map[RETURN].function = rl_newline;
- vi_replace_map[NEWLINE].function = rl_newline;
- keymap = vi_replace_map;
-}
diff --git a/gnu/usr.bin/gdb/regex.c b/gnu/usr.bin/gdb/regex.c
deleted file mode 100644
index 45c3478..0000000
--- a/gnu/usr.bin/gdb/regex.c
+++ /dev/null
@@ -1,1738 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 1985, 1989 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! */
-
-
-/* To test, compile with -Dtest.
- This Dtestable feature turns this into a self-contained program
- which reads a pattern, describes how it compiles,
- then reads a string and searches for it. */
-
-#ifdef emacs
-
-/* The `emacs' switch turns on certain special matching commands
- that make sense only in emacs. */
-
-#include "config.h"
-#include "lisp.h"
-#include "buffer.h"
-#include "syntax.h"
-
-#else /* not emacs */
-
-#ifdef USG
-#ifndef BSTRING
-#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))
-#endif
-#endif
-
-/* Make alloca work the best possible way. */
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#ifdef sparc
-#include <alloca.h>
-#endif
-#endif
-
-/*
- * Define the syntax stuff, so we can do the \<...\> things.
- */
-
-#ifndef Sword /* must be non-zero in some of the tests below... */
-#define Sword 1
-#endif
-
-#define SYNTAX(c) re_syntax_table[c]
-
-#ifdef SYNTAX_TABLE
-
-char *re_syntax_table;
-
-#else
-
-static char re_syntax_table[256];
-
-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;
-
- done = 1;
-}
-
-#endif /* SYNTAX_TABLE */
-#endif /* not emacs */
-
-#include "regex.h"
-
-/* Number of failure points to allocate space for initially,
- when matching. If this number is exceeded, more space is allocated,
- so it is not a hard limit. */
-
-#ifndef NFAILURES
-#define NFAILURES 80
-#endif /* NFAILURES */
-
-/* width of a byte in bits */
-
-#define BYTEWIDTH 8
-
-#ifndef SIGN_EXTEND_CHAR
-#define SIGN_EXTEND_CHAR(x) (x)
-#endif
-
-static int obscure_syntax = 0;
-
-/* Specify the precise syntax of regexp for compilation.
- This provides for compatibility for various utilities
- which historically have different, incompatible syntaxes.
-
- The argument SYNTAX is a bit-mask containing the two bits
- RE_NO_BK_PARENS and RE_NO_BK_VBAR. */
-
-int
-re_set_syntax (syntax)
-{
- int ret;
-
- ret = obscure_syntax;
- obscure_syntax = syntax;
- return ret;
-}
-
-/* re_compile_pattern takes a regular-expression string
- and converts it into a buffer full of byte commands for matching.
-
- PATTERN is the address of the pattern string
- SIZE is the length of it.
- BUFP is a struct re_pattern_buffer * which points to the info
- on where to store the byte commands.
- This structure contains a char * which points to the
- actual space, which should have been obtained with malloc.
- re_compile_pattern may use realloc to grow the buffer space.
-
- The number of bytes of commands can be found out by looking in
- the struct re_pattern_buffer that bufp pointed to,
- after re_compile_pattern returns.
-*/
-
-#define PATPUSH(ch) (*b++ = (char) (ch))
-
-#define PATFETCH(c) \
- {if (p == pend) goto end_of_pattern; \
- c = * (unsigned char *) p++; \
- if (translate) c = translate[c]; }
-
-#define PATFETCH_RAW(c) \
- {if (p == pend) goto end_of_pattern; \
- c = * (unsigned char *) p++; }
-
-#define PATUNFETCH p--
-
-#define EXTEND_BUFFER \
- { char *old_buffer = bufp->buffer; \
- if (bufp->allocated == (1<<16)) goto too_big; \
- bufp->allocated *= 2; \
- if (bufp->allocated > (1<<16)) bufp->allocated = (1<<16); \
- if (!(bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated))) \
- goto memory_exhausted; \
- c = bufp->buffer - old_buffer; \
- b += c; \
- if (fixup_jump) \
- fixup_jump += c; \
- if (laststart) \
- laststart += c; \
- begalt += c; \
- if (pending_exact) \
- pending_exact += c; \
- }
-
-static int store_jump (), insert_jump ();
-
-char *
-re_compile_pattern (pattern, size, bufp)
- char *pattern;
- int size;
- struct re_pattern_buffer *bufp;
-{
- register char *b = bufp->buffer;
- register char *p = pattern;
- char *pend = pattern + size;
- register unsigned c, c1;
- char *p1;
- unsigned char *translate = (unsigned char *) bufp->translate;
-
- /* address of the count-byte of the most recently inserted "exactn" command.
- This makes it possible to tell whether a new exact-match character
- can be added to that command or requires a new "exactn" command. */
-
- char *pending_exact = 0;
-
- /* 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. */
-
- char *fixup_jump = 0;
-
- /* address of start of the most recently finished expression.
- This tells postfix * where to find the start of its operand. */
-
- char *laststart = 0;
-
- /* In processing a repeat, 1 means zero matches is allowed */
-
- char zero_times_ok;
-
- /* In processing a repeat, 1 means many matches is allowed */
-
- char many_times_ok;
-
- /* address of beginning of regexp, or inside of last \( */
-
- char *begalt = b;
-
- /* Stack of information saved by \( and restored by \).
- Four stack elements are pushed by each \(:
- First, the value of b.
- Second, the value of fixup_jump.
- Third, the value of regnum.
- Fourth, the value of begalt. */
-
- int stackb[40];
- int *stackp = stackb;
- int *stacke = stackb + 40;
- int *stackt;
-
- /* Counts \('s as they are encountered. Remembered for the matching \),
- where it becomes the "register number" to put in the stop_memory command */
-
- int regnum = 1;
-
- bufp->fastmap_accurate = 0;
-
-#ifndef emacs
-#ifndef SYNTAX_TABLE
- /*
- * Initialize the syntax table.
- */
- init_syntax_once();
-#endif
-#endif
-
- if (bufp->allocated == 0)
- {
- bufp->allocated = 28;
- if (bufp->buffer)
- /* EXTEND_BUFFER loses when bufp->allocated is 0 */
- bufp->buffer = (char *) realloc (bufp->buffer, 28);
- else
- /* Caller did not allocate a buffer. Do it for him */
- bufp->buffer = (char *) malloc (28);
- if (!bufp->buffer) goto memory_exhausted;
- begalt = b = bufp->buffer;
- }
-
- while (p != pend)
- {
- if (b - bufp->buffer > bufp->allocated - 10)
- /* Note that EXTEND_BUFFER clobbers c */
- EXTEND_BUFFER;
-
- PATFETCH (c);
-
- switch (c)
- {
- case '$':
- if (obscure_syntax & RE_TIGHT_VBAR)
- {
- if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS) && p != pend)
- goto normal_char;
- /* Make operand of last vbar end before this `$'. */
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
- fixup_jump = 0;
- PATPUSH (endline);
- break;
- }
-
- /* $ means succeed if at end of line, but only in special contexts.
- If randomly in the middle of a pattern, it is a normal character. */
- if (p == pend || *p == '\n'
- || (obscure_syntax & RE_CONTEXT_INDEP_OPS)
- || (obscure_syntax & RE_NO_BK_PARENS
- ? *p == ')'
- : *p == '\\' && p[1] == ')')
- || (obscure_syntax & RE_NO_BK_VBAR
- ? *p == '|'
- : *p == '\\' && p[1] == '|'))
- {
- PATPUSH (endline);
- break;
- }
- goto normal_char;
-
- case '^':
- /* ^ means succeed if at beg of line, but only if no preceding pattern. */
-
- if (laststart && p[-2] != '\n'
- && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- if (obscure_syntax & RE_TIGHT_VBAR)
- {
- if (p != pattern + 1
- && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- PATPUSH (begline);
- begalt = b;
- }
- else
- PATPUSH (begline);
- break;
-
- case '+':
- case '?':
- if (obscure_syntax & RE_BK_PLUS_QM)
- goto normal_char;
- handle_plus:
- case '*':
- /* If there is no previous pattern, char not special. */
- if (!laststart && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- /* If there is a sequence of repetition chars,
- collapse it down to equivalent to just one. */
- zero_times_ok = 0;
- many_times_ok = 0;
- while (1)
- {
- zero_times_ok |= c != '+';
- many_times_ok |= c != '?';
- if (p == pend)
- break;
- PATFETCH (c);
- if (c == '*')
- ;
- else if (!(obscure_syntax & RE_BK_PLUS_QM)
- && (c == '+' || c == '?'))
- ;
- else if ((obscure_syntax & RE_BK_PLUS_QM)
- && c == '\\')
- {
- int c1;
- PATFETCH (c1);
- if (!(c1 == '+' || c1 == '?'))
- {
- PATUNFETCH;
- PATUNFETCH;
- break;
- }
- c = c1;
- }
- else
- {
- PATUNFETCH;
- break;
- }
- }
-
- /* Star, etc. applied to an empty pattern is equivalent
- to an empty pattern. */
- if (!laststart)
- break;
-
- /* Now we know whether 0 matches is allowed,
- and whether 2 or more matches is allowed. */
- if (many_times_ok)
- {
- /* If more than one repetition is allowed,
- put in a backward jump at the end. */
- store_jump (b, maybe_finalize_jump, laststart - 3);
- b += 3;
- }
- insert_jump (on_failure_jump, laststart, b + 3, b);
- pending_exact = 0;
- b += 3;
- if (!zero_times_ok)
- {
- /* At least one repetition required: insert before the loop
- a skip over the initial on-failure-jump instruction */
- insert_jump (dummy_failure_jump, laststart, laststart + 6, b);
- b += 3;
- }
- break;
-
- case '.':
- laststart = b;
- PATPUSH (anychar);
- break;
-
- case '[':
- while (b - bufp->buffer
- > bufp->allocated - 3 - (1 << BYTEWIDTH) / BYTEWIDTH)
- /* Note that EXTEND_BUFFER clobbers c */
- EXTEND_BUFFER;
-
- laststart = b;
- if (*p == '^')
- PATPUSH (charset_not), p++;
- else
- PATPUSH (charset);
- p1 = p;
-
- PATPUSH ((1 << BYTEWIDTH) / BYTEWIDTH);
- /* Clear the whole map */
- bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH);
- /* Read in characters and ranges, setting map bits */
- while (1)
- {
- PATFETCH (c);
- if (c == ']' && p != p1 + 1) break;
- if (*p == '-' && p[1] != ']')
- {
- PATFETCH (c1);
- PATFETCH (c1);
- while (c <= c1)
- b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH), c++;
- }
- else
- {
- b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH);
- }
- }
- /* Discard any bitmap bytes that are all 0 at the end of the map.
- Decrement the map-length byte too. */
- while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
- b[-1]--;
- b += b[-1];
- break;
-
- case '(':
- if (! (obscure_syntax & RE_NO_BK_PARENS))
- goto normal_char;
- else
- goto handle_open;
-
- case ')':
- if (! (obscure_syntax & RE_NO_BK_PARENS))
- goto normal_char;
- else
- goto handle_close;
-
- case '\n':
- if (! (obscure_syntax & RE_NEWLINE_OR))
- goto normal_char;
- else
- goto handle_bar;
-
- case '|':
- if (! (obscure_syntax & RE_NO_BK_VBAR))
- goto normal_char;
- else
- goto handle_bar;
-
- case '\\':
- if (p == pend) goto invalid_pattern;
- PATFETCH_RAW (c);
- switch (c)
- {
- case '(':
- if (obscure_syntax & RE_NO_BK_PARENS)
- goto normal_backsl;
- handle_open:
- if (stackp == stacke) goto nesting_too_deep;
- if (regnum < RE_NREGS)
- {
- PATPUSH (start_memory);
- PATPUSH (regnum);
- }
- *stackp++ = b - bufp->buffer;
- *stackp++ = fixup_jump ? fixup_jump - bufp->buffer + 1 : 0;
- *stackp++ = regnum++;
- *stackp++ = begalt - bufp->buffer;
- fixup_jump = 0;
- laststart = 0;
- begalt = b;
- break;
-
- case ')':
- if (obscure_syntax & RE_NO_BK_PARENS)
- goto normal_backsl;
- handle_close:
- if (stackp == stackb) goto unmatched_close;
- begalt = *--stackp + bufp->buffer;
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
- if (stackp[-1] < RE_NREGS)
- {
- PATPUSH (stop_memory);
- PATPUSH (stackp[-1]);
- }
- stackp -= 2;
- fixup_jump = 0;
- if (*stackp)
- fixup_jump = *stackp + bufp->buffer - 1;
- laststart = *--stackp + bufp->buffer;
- break;
-
- case '|':
- if (obscure_syntax & RE_NO_BK_VBAR)
- goto normal_backsl;
- handle_bar:
- insert_jump (on_failure_jump, begalt, b + 6, b);
- pending_exact = 0;
- b += 3;
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
- fixup_jump = b;
- b += 3;
- laststart = 0;
- begalt = b;
- break;
-
-#ifdef emacs
- case '=':
- PATPUSH (at_dot);
- break;
-
- case 's':
- laststart = b;
- PATPUSH (syntaxspec);
- PATFETCH (c);
- PATPUSH (syntax_spec_code[c]);
- break;
-
- case 'S':
- laststart = b;
- PATPUSH (notsyntaxspec);
- PATFETCH (c);
- PATPUSH (syntax_spec_code[c]);
- break;
-#endif /* emacs */
-
- case 'w':
- laststart = b;
- PATPUSH (wordchar);
- break;
-
- case 'W':
- laststart = b;
- PATPUSH (notwordchar);
- break;
-
- case '<':
- PATPUSH (wordbeg);
- break;
-
- case '>':
- PATPUSH (wordend);
- break;
-
- case 'b':
- PATPUSH (wordbound);
- break;
-
- case 'B':
- PATPUSH (notwordbound);
- break;
-
- case '`':
- PATPUSH (begbuf);
- break;
-
- case '\'':
- PATPUSH (endbuf);
- break;
-
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- c1 = c - '0';
- if (c1 >= regnum)
- goto normal_char;
- for (stackt = stackp - 2; stackt > stackb; stackt -= 4)
- if (*stackt == c1)
- goto normal_char;
- laststart = b;
- PATPUSH (duplicate);
- PATPUSH (c1);
- break;
-
- case '+':
- case '?':
- if (obscure_syntax & RE_BK_PLUS_QM)
- goto handle_plus;
-
- default:
- normal_backsl:
- /* 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. */
- if (translate) c = translate[c];
- goto normal_char;
- }
- break;
-
- default:
- normal_char:
- if (!pending_exact || pending_exact + *pending_exact + 1 != b
- || *pending_exact == 0177 || *p == '*' || *p == '^'
- || ((obscure_syntax & RE_BK_PLUS_QM)
- ? *p == '\\' && (p[1] == '+' || p[1] == '?')
- : (*p == '+' || *p == '?')))
- {
- laststart = b;
- PATPUSH (exactn);
- pending_exact = b;
- PATPUSH (0);
- }
- PATPUSH (c);
- (*pending_exact)++;
- }
- }
-
- if (fixup_jump)
- store_jump (fixup_jump, jump, b);
-
- if (stackp != stackb) goto unmatched_open;
-
- bufp->used = b - bufp->buffer;
- return 0;
-
- invalid_pattern:
- return "Invalid regular expression";
-
- unmatched_open:
- return "Unmatched \\(";
-
- unmatched_close:
- return "Unmatched \\)";
-
- end_of_pattern:
- return "Premature end of regular expression";
-
- nesting_too_deep:
- return "Nesting too deep";
-
- too_big:
- return "Regular expression too big";
-
- memory_exhausted:
- return "Memory exhausted";
-}
-
-/* Store where `from' points a jump operation to jump to where `to' points.
- `opcode' is the opcode to store. */
-
-static int
-store_jump (from, opcode, to)
- char *from, *to;
- char opcode;
-{
- from[0] = opcode;
- from[1] = (to - (from + 3)) & 0377;
- from[2] = (to - (from + 3)) >> 8;
-}
-
-/* Open up space at char FROM, and insert there a jump to TO.
- CURRENT_END gives te end of the storage no in use,
- so we know how much data to copy up.
- OP is the opcode of the jump to insert.
-
- If you call this function, you must zero out pending_exact. */
-
-static int
-insert_jump (op, from, to, current_end)
- char op;
- char *from, *to, *current_end;
-{
- register char *pto = current_end + 3;
- register char *pfrom = current_end;
- while (pfrom != from)
- *--pto = *--pfrom;
- store_jump (from, op, to);
-}
-
-/* Given a pattern, compute a fastmap from it.
- The 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 totally implausible text.
-
- The caller must supply the address of a (1 << BYTEWIDTH)-byte data area
- as bufp->fastmap.
- The other components of bufp describe the pattern to be used. */
-
-void
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
-{
- unsigned char *pattern = (unsigned char *) bufp->buffer;
- int size = bufp->used;
- register char *fastmap = bufp->fastmap;
- register unsigned char *p = pattern;
- register unsigned char *pend = pattern + size;
- register int j, k;
- unsigned char *translate = (unsigned char *) bufp->translate;
-
- unsigned char *stackb[NFAILURES];
- unsigned char **stackp = stackb;
-
- bzero (fastmap, (1 << BYTEWIDTH));
- bufp->fastmap_accurate = 1;
- bufp->can_be_null = 0;
-
- while (p)
- {
- if (p == pend)
- {
- bufp->can_be_null = 1;
- break;
- }
-#ifdef SWITCH_ENUM_BUG
- switch ((int) ((enum regexpcode) *p++))
-#else
- switch ((enum regexpcode) *p++)
-#endif
- {
- case exactn:
- if (translate)
- fastmap[translate[p[1]]] = 1;
- else
- fastmap[p[1]] = 1;
- break;
-
- case begline:
- case before_dot:
- case at_dot:
- case after_dot:
- case begbuf:
- case endbuf:
- case wordbound:
- case notwordbound:
- case wordbeg:
- case wordend:
- continue;
-
- case endline:
- if (translate)
- fastmap[translate['\n']] = 1;
- else
- fastmap['\n'] = 1;
- if (bufp->can_be_null != 1)
- bufp->can_be_null = 2;
- break;
-
- case finalize_jump:
- case maybe_finalize_jump:
- case jump:
- case dummy_failure_jump:
- bufp->can_be_null = 1;
- j = *p++ & 0377;
- j += SIGN_EXTEND_CHAR (*(char *)p) << 8;
- p += j + 1; /* The 1 compensates for missing ++ above */
- if (j > 0)
- continue;
- /* Jump backward reached implies we just went through
- the body of a loop and matched nothing.
- Opcode jumped to should be an on_failure_jump.
- Just treat it like an ordinary jump.
- For a * loop, it has pushed its failure point already;
- if so, discard that as redundant. */
- if ((enum regexpcode) *p != on_failure_jump)
- continue;
- p++;
- j = *p++ & 0377;
- j += SIGN_EXTEND_CHAR (*(char *)p) << 8;
- p += j + 1; /* The 1 compensates for missing ++ above */
- if (stackp != stackb && *stackp == p)
- stackp--;
- continue;
-
- case on_failure_jump:
- j = *p++ & 0377;
- j += SIGN_EXTEND_CHAR (*(char *)p) << 8;
- p++;
- *++stackp = p + j;
- continue;
-
- case start_memory:
- case stop_memory:
- p++;
- continue;
-
- case duplicate:
- bufp->can_be_null = 1;
- fastmap['\n'] = 1;
- case anychar:
- for (j = 0; j < (1 << BYTEWIDTH); j++)
- if (j != '\n')
- fastmap[j] = 1;
- if (bufp->can_be_null)
- return;
- /* Don't return; check the alternative paths
- so we can set can_be_null if appropriate. */
- 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;
-
-#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;
-#endif /* emacs */
-
- case charset:
- for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
- if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
- {
- if (translate)
- fastmap[translate[j]] = 1;
- else
- fastmap[j] = 1;
- }
- break;
-
- case charset_not:
- /* Chars beyond end of map must be allowed */
- for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
- if (translate)
- fastmap[translate[j]] = 1;
- else
- fastmap[j] = 1;
-
- for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
- if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
- {
- if (translate)
- fastmap[translate[j]] = 1;
- else
- fastmap[j] = 1;
- }
- break;
- }
-
- /* Get here means we have successfully found the possible starting characters
- of one path of the pattern. We need not follow this path any farther.
- Instead, look at the next alternative remembered in the stack. */
- if (stackp != stackb)
- p = *stackp--;
- else
- break;
- }
-}
-
-/* Like re_search_2, below, but only one string is specified. */
-
-int
-re_search (pbufp, string, size, startpos, range, regs)
- struct re_pattern_buffer *pbufp;
- char *string;
- int size, startpos, range;
- struct re_registers *regs;
-{
- return re_search_2 (pbufp, 0, 0, string, size, startpos, range, regs, size);
-}
-
-/* Like re_match_2 but tries first a match starting at index STARTPOS,
- then at STARTPOS + 1, and so on.
- RANGE is the number of places to try before giving up.
- If RANGE is negative, the starting positions tried are
- STARTPOS, STARTPOS - 1, etc.
- It is up to the caller to make sure that range is not so large
- as to take the starting position outside of the input strings.
-
-The value returned is the position at which the match was found,
- or -1 if no match was found,
- or -2 if error (such as failure stack overflow). */
-
-int
-re_search_2 (pbufp, string1, size1, string2, size2, startpos, range, regs, mstop)
- struct re_pattern_buffer *pbufp;
- char *string1, *string2;
- int size1, size2;
- int startpos;
- register int range;
- struct re_registers *regs;
- int mstop;
-{
- register char *fastmap = pbufp->fastmap;
- register unsigned char *translate = (unsigned char *) pbufp->translate;
- int total = size1 + size2;
- int val;
-
- /* Update the fastmap now if not correct already */
- if (fastmap && !pbufp->fastmap_accurate)
- re_compile_fastmap (pbufp);
-
- /* Don't waste time in a long search for a pattern
- that says it is anchored. */
- if (pbufp->used > 0 && (enum regexpcode) pbufp->buffer[0] == begbuf
- && range > 0)
- {
- if (startpos > 0)
- return -1;
- else
- range = 1;
- }
-
- while (1)
- {
- /* If a fastmap is supplied, skip quickly over characters
- that cannot possibly be the start of a match.
- Note, however, that if the pattern can possibly match
- the null string, we must test it at each starting point
- so that we take the first null string we get. */
-
- if (fastmap && startpos < total && pbufp->can_be_null != 1)
- {
- if (range > 0)
- {
- register int lim = 0;
- register unsigned char *p;
- int irange = range;
- if (startpos < size1 && startpos + range >= size1)
- lim = range - (size1 - startpos);
-
- p = ((unsigned char *)
- &(startpos >= size1 ? string2 - size1 : string1)[startpos]);
-
- if (translate)
- {
- while (range > lim && !fastmap[translate[*p++]])
- range--;
- }
- else
- {
- while (range > lim && !fastmap[*p++])
- range--;
- }
- startpos += irange - range;
- }
- else
- {
- register unsigned char c;
- if (startpos >= size1)
- c = string2[startpos - size1];
- else
- c = string1[startpos];
- c &= 0xff;
- if (translate ? !fastmap[translate[c]] : !fastmap[c])
- goto advance;
- }
- }
-
- if (range >= 0 && startpos == total
- && fastmap && pbufp->can_be_null == 0)
- return -1;
-
- val = re_match_2 (pbufp, string1, size1, string2, size2, startpos, regs, mstop);
- if (0 <= val)
- {
- if (val == -2)
- return -2;
- return startpos;
- }
-
-#ifdef C_ALLOCA
- alloca (0);
-#endif /* C_ALLOCA */
-
- advance:
- if (!range) break;
- if (range > 0) range--, startpos++; else range++, startpos--;
- }
- return -1;
-}
-
-#ifndef emacs /* emacs never uses this */
-int
-re_match (pbufp, string, size, pos, regs)
- struct re_pattern_buffer *pbufp;
- char *string;
- int size, pos;
- struct re_registers *regs;
-{
- return re_match_2 (pbufp, 0, 0, string, size, pos, regs, size);
-}
-#endif /* emacs */
-
-/* Maximum size of failure stack. Beyond this, overflow is an error. */
-
-int re_max_failures = 2000;
-
-static int bcmp_translate();
-/* Match the pattern described by PBUFP
- against data which is the virtual concatenation of STRING1 and STRING2.
- SIZE1 and SIZE2 are the sizes of the two data strings.
- Start the match at position POS.
- Do not consider matching past the position MSTOP.
-
- If pbufp->fastmap is nonzero, then it had better be up to date.
-
- The reason that the data to match are specified as two components
- which are to be regarded as concatenated
- is so this function can be used directly on the contents of an Emacs buffer.
-
- -1 is returned if there is no match. -2 is returned if there is
- an error (such as match stack overflow). Otherwise the value is the length
- of the substring which was matched. */
-
-int
-re_match_2 (pbufp, string1, size1, string2, size2, pos, regs, mstop)
- struct re_pattern_buffer *pbufp;
- unsigned char *string1, *string2;
- int size1, size2;
- int pos;
- struct re_registers *regs;
- int mstop;
-{
- register unsigned char *p = (unsigned char *) pbufp->buffer;
- register unsigned char *pend = p + pbufp->used;
- /* End of first string */
- unsigned char *end1;
- /* End of second string */
- unsigned char *end2;
- /* Pointer just past last char to consider matching */
- unsigned char *end_match_1, *end_match_2;
- register unsigned char *d, *dend;
- register int mcnt;
- unsigned char *translate = (unsigned char *) pbufp->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 two char *'s.
- The first one pushed is where to resume scanning the pattern;
- the second pushed is where to resume scanning the strings.
- If the latter is zero, the failure point is a "dummy".
- If a failure happens and the innermost failure point is dormant,
- it discards that failure point and tries the next one. */
-
- unsigned char *initial_stack[2 * NFAILURES];
- unsigned char **stackb = initial_stack;
- unsigned char **stackp = stackb, **stacke = &stackb[2 * NFAILURES];
-
- /* Information on the "contents" of registers.
- These are pointers into the input strings; they record
- just what was matched (on this attempt) by some part of the pattern.
- The start_memory command stores the start of a register's contents
- and the stop_memory command stores the end.
-
- At that point, regstart[regnum] points to the first character in the register,
- regend[regnum] points to the first character beyond the end of the register,
- regstart_seg1[regnum] is true iff regstart[regnum] points into string1,
- and regend_seg1[regnum] is true iff regend[regnum] points into string1. */
-
- unsigned char *regstart[RE_NREGS];
- unsigned char *regend[RE_NREGS];
- unsigned char regstart_seg1[RE_NREGS], regend_seg1[RE_NREGS];
-
- /* Set up pointers to ends of strings.
- Don't allow the second string to be empty unless both are empty. */
- if (!size2)
- {
- string2 = string1;
- size2 = size1;
- string1 = 0;
- size1 = 0;
- }
- end1 = string1 + size1;
- end2 = string2 + size2;
-
- /* Compute where to stop matching, within the two strings */
- if (mstop <= size1)
- {
- end_match_1 = string1 + mstop;
- end_match_2 = string2;
- }
- else
- {
- end_match_1 = end1;
- end_match_2 = string2 + mstop - size1;
- }
-
- /* Initialize \) text positions to -1
- to mark ones that no \( or \) has been seen for. */
-
- for (mcnt = 0; mcnt < sizeof (regend) / sizeof (*regend); mcnt++)
- regend[mcnt] = (unsigned char *) -1;
-
- /* `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 (pos <= size1)
- d = string1 + pos, dend = end_match_1;
- else
- d = string2 + pos - size1, dend = end_match_2;
-
-/* Write PREFETCH; just before fetching a character with *d. */
-#define PREFETCH \
- while (d == dend) \
- { if (dend == end_match_2) goto fail; /* end of string2 => failure */ \
- d = string2; /* end of string1 => advance to string2. */ \
- dend = end_match_2; }
-
- /* This loop loops over pattern commands.
- It exits by returning from the function if match is complete,
- or it drops through if match fails at this starting point in the input data. */
-
- while (1)
- {
- if (p == pend)
- /* End of pattern means we have succeeded! */
- {
- /* If caller wants register contents data back, convert it to indices */
- if (regs)
- {
- regs->start[0] = pos;
- if (dend == end_match_1)
- regs->end[0] = d - string1;
- else
- regs->end[0] = d - string2 + size1;
- for (mcnt = 1; mcnt < RE_NREGS; mcnt++)
- {
- if (regend[mcnt] == (unsigned char *) -1)
- {
- regs->start[mcnt] = -1;
- regs->end[mcnt] = -1;
- continue;
- }
- if (regstart_seg1[mcnt])
- regs->start[mcnt] = regstart[mcnt] - string1;
- else
- regs->start[mcnt] = regstart[mcnt] - string2 + size1;
- if (regend_seg1[mcnt])
- regs->end[mcnt] = regend[mcnt] - string1;
- else
- regs->end[mcnt] = regend[mcnt] - string2 + size1;
- }
- }
- if (dend == end_match_1)
- return (d - string1 - pos);
- else
- return d - string2 + size1 - pos;
- }
-
- /* Otherwise match next pattern command */
-#ifdef SWITCH_ENUM_BUG
- switch ((int) ((enum regexpcode) *p++))
-#else
- switch ((enum regexpcode) *p++)
-#endif
- {
-
- /* \( is represented by a start_memory, \) by a stop_memory.
- Both of those commands contain a "register number" argument.
- The text matched within the \( and \) is recorded under that number.
- Then, \<digit> turns into a `duplicate' command which
- is followed by the numeric value of <digit> as the register number. */
-
- case start_memory:
- regstart[*p] = d;
- regstart_seg1[*p++] = (dend == end_match_1);
- break;
-
- case stop_memory:
- regend[*p] = d;
- regend_seg1[*p++] = (dend == end_match_1);
- break;
-
- case duplicate:
- {
- int regno = *p++; /* Get which register to match against */
- register unsigned char *d2, *dend2;
-
- d2 = regstart[regno];
- dend2 = ((regstart_seg1[regno] == regend_seg1[regno])
- ? regend[regno] : end_match_1);
- while (1)
- {
- /* Advance to next segment in register contents, if necessary */
- while (d2 == dend2)
- {
- if (dend2 == end_match_2) break;
- if (dend2 == regend[regno]) break;
- d2 = string2, dend2 = regend[regno]; /* end of string1 => advance to string2. */
- }
- /* At end of register contents => success */
- if (d2 == dend2) break;
-
- /* Advance to next segment in data being matched, if necessary */
- PREFETCH;
-
- /* mcnt gets # consecutive chars to compare */
- mcnt = dend - d;
- if (mcnt > dend2 - d2)
- mcnt = dend2 - d2;
- /* Compare that many; failure if mismatch, else skip them. */
- if (translate ? bcmp_translate (d, d2, mcnt, translate) : bcmp (d, d2, mcnt))
- goto fail;
- d += mcnt, d2 += mcnt;
- }
- }
- break;
-
- case anychar:
- /* fetch a data character */
- PREFETCH;
- /* Match anything but a newline. */
- if ((translate ? translate[*d++] : *d++) == '\n')
- goto fail;
- break;
-
- case charset:
- case charset_not:
- {
- /* Nonzero for charset_not */
- int not = 0;
- register int c;
- if (*(p - 1) == (unsigned char) charset_not)
- not = 1;
-
- /* fetch a data character */
- PREFETCH;
-
- if (translate)
- c = translate [*d];
- else
- c = *d;
-
- if (c < *p * BYTEWIDTH
- && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
- not = !not;
-
- p += 1 + *p;
-
- if (!not) goto fail;
- d++;
- break;
- }
-
- case begline:
- if (d == string1 || d[-1] == '\n')
- break;
- goto fail;
-
- case endline:
- if (d == end2
- || (d == end1 ? (size2 == 0 || *string2 == '\n') : *d == '\n'))
- break;
- goto fail;
-
- /* "or" constructs ("|") are handled by starting each alternative
- with an on_failure_jump that points to the start of the next alternative.
- Each alternative except the last ends with a jump to the joining point.
- (Actually, each jump except for the last one really jumps
- to the following jump, because tensioning the jumps is a hassle.) */
-
- /* The start of a stupid repeat has an on_failure_jump that points
- past the end of the repeat text.
- This makes a failure point so that, on failure to match a repetition,
- matching restarts past as many repetitions have been found
- with no way to fail and look for another one. */
-
- /* A smart repeat is similar but loops back to the on_failure_jump
- so that each repetition makes another failure point. */
-
- case on_failure_jump:
- if (stackp == stacke)
- {
- unsigned char **stackx;
- if (stacke - stackb > re_max_failures * 2)
- return -2;
- stackx = (unsigned char **) alloca (2 * (stacke - stackb)
- * sizeof (char *));
- bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *));
- stackp = stackx + (stackp - stackb);
- stacke = stackx + 2 * (stacke - stackb);
- stackb = stackx;
- }
- mcnt = *p++ & 0377;
- mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8;
- p++;
- *stackp++ = mcnt + p;
- *stackp++ = d;
- break;
-
- /* The end of a smart repeat has an maybe_finalize_jump back.
- Change it either to a finalize_jump or an ordinary jump. */
-
- case maybe_finalize_jump:
- mcnt = *p++ & 0377;
- mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8;
- p++;
- {
- register unsigned char *p2 = p;
- /* Compare what follows with the begining of the repeat.
- If we can establish that there is nothing that they would
- both match, we can change to finalize_jump */
- while (p2 != pend
- && (*p2 == (unsigned char) stop_memory
- || *p2 == (unsigned char) start_memory))
- p2++;
- if (p2 == pend)
- p[-3] = (unsigned char) finalize_jump;
- else if (*p2 == (unsigned char) exactn
- || *p2 == (unsigned char) endline)
- {
- register int c = *p2 == (unsigned char) endline ? '\n' : p2[2];
- register unsigned char *p1 = p + mcnt;
- /* p1[0] ... p1[2] are an on_failure_jump.
- Examine what follows that */
- if (p1[3] == (unsigned char) exactn && p1[5] != c)
- p[-3] = (unsigned char) finalize_jump;
- else if (p1[3] == (unsigned char) charset
- || p1[3] == (unsigned char) charset_not)
- {
- int not = p1[3] == (unsigned char) charset_not;
- if (c < p1[4] * BYTEWIDTH
- && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
- not = !not;
- /* not is 1 if c would match */
- /* That means it is not safe to finalize */
- if (!not)
- p[-3] = (unsigned char) finalize_jump;
- }
- }
- }
- p -= 2;
- if (p[-1] != (unsigned char) finalize_jump)
- {
- p[-1] = (unsigned char) jump;
- goto nofinalize;
- }
-
- /* The end of a stupid repeat has a finalize-jump
- back to the start, where another failure point will be made
- which will point after all the repetitions found so far. */
-
- case finalize_jump:
- stackp -= 2;
-
- case jump:
- nofinalize:
- mcnt = *p++ & 0377;
- mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8;
- p += mcnt + 1; /* The 1 compensates for missing ++ above */
- break;
-
- case dummy_failure_jump:
- if (stackp == stacke)
- {
- unsigned char **stackx
- = (unsigned char **) alloca (2 * (stacke - stackb)
- * sizeof (char *));
- bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *));
- stackp = stackx + (stackp - stackb);
- stacke = stackx + 2 * (stacke - stackb);
- stackb = stackx;
- }
- *stackp++ = 0;
- *stackp++ = 0;
- goto nofinalize;
-
- case wordbound:
- if (d == string1 /* Points to first char */
- || d == end2 /* Points to end */
- || (d == end1 && size2 == 0)) /* Points to end */
- break;
- if ((SYNTAX (d[-1]) == Sword)
- != (SYNTAX (d == end1 ? *string2 : *d) == Sword))
- break;
- goto fail;
-
- case notwordbound:
- if (d == string1 /* Points to first char */
- || d == end2 /* Points to end */
- || (d == end1 && size2 == 0)) /* Points to end */
- goto fail;
- if ((SYNTAX (d[-1]) == Sword)
- != (SYNTAX (d == end1 ? *string2 : *d) == Sword))
- goto fail;
- break;
-
- case wordbeg:
- if (d == end2 /* Points to end */
- || (d == end1 && size2 == 0) /* Points to end */
- || SYNTAX (* (d == end1 ? string2 : d)) != Sword) /* Next char not a letter */
- goto fail;
- if (d == string1 /* Points to first char */
- || SYNTAX (d[-1]) != Sword) /* prev char not letter */
- break;
- goto fail;
-
- case wordend:
- if (d == string1 /* Points to first char */
- || SYNTAX (d[-1]) != Sword) /* prev char not letter */
- goto fail;
- if (d == end2 /* Points to end */
- || (d == end1 && size2 == 0) /* Points to end */
- || SYNTAX (d == end1 ? *string2 : *d) != Sword) /* Next char not a letter */
- break;
- goto fail;
-
-#ifdef emacs
- case before_dot:
- if (((d - string2 <= (unsigned) size2)
- ? d - bf_p2 : d - bf_p1)
- <= point)
- goto fail;
- break;
-
- case at_dot:
- if (((d - string2 <= (unsigned) size2)
- ? d - bf_p2 : d - bf_p1)
- == point)
- goto fail;
- break;
-
- case after_dot:
- if (((d - string2 <= (unsigned) size2)
- ? d - bf_p2 : d - bf_p1)
- >= point)
- goto fail;
- break;
-
- case wordchar:
- mcnt = (int) Sword;
- goto matchsyntax;
-
- case syntaxspec:
- mcnt = *p++;
- matchsyntax:
- PREFETCH;
- if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail;
- break;
-
- case notwordchar:
- mcnt = (int) Sword;
- goto matchnotsyntax;
-
- case notsyntaxspec:
- mcnt = *p++;
- matchnotsyntax:
- PREFETCH;
- if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail;
- break;
-#else
- case wordchar:
- PREFETCH;
- if (SYNTAX (*d++) == 0) goto fail;
- break;
-
- case notwordchar:
- PREFETCH;
- if (SYNTAX (*d++) != 0) goto fail;
- break;
-#endif /* not emacs */
-
- case begbuf:
- if (d == string1) /* Note, d cannot equal string2 */
- break; /* unless string1 == string2. */
- goto fail;
-
- case endbuf:
- if (d == end2 || (d == end1 && size2 == 0))
- break;
- goto fail;
-
- case exactn:
- /* Match the next few pattern characters exactly.
- mcnt is how many characters to match. */
- mcnt = *p++;
- if (translate)
- {
- do
- {
- PREFETCH;
- if (translate[*d++] != *p++) goto fail;
- }
- while (--mcnt);
- }
- else
- {
- do
- {
- PREFETCH;
- if (*d++ != *p++) goto fail;
- }
- while (--mcnt);
- }
- break;
- }
- continue; /* Successfully matched one pattern command; keep matching */
-
- /* Jump here if any matching operation fails. */
- fail:
- if (stackp != stackb)
- /* A restart point is known. Restart there and pop it. */
- {
- if (!stackp[-2])
- { /* If innermost failure point is dormant, flush it and keep looking */
- stackp -= 2;
- goto fail;
- }
- d = *--stackp;
- p = *--stackp;
- if (d >= string1 && d <= end1)
- dend = end_match_1;
- }
- else break; /* Matching at this starting point really fails! */
- }
- return -1; /* Failure to match */
-}
-
-static int
-bcmp_translate (s1, s2, len, translate)
- unsigned char *s1, *s2;
- register int len;
- unsigned char *translate;
-{
- register unsigned char *p1 = s1, *p2 = s2;
- while (len)
- {
- if (translate [*p1++] != translate [*p2++]) return 1;
- len--;
- }
- return 0;
-}
-
-/* Entry points compatible with bsd4.2 regex library */
-
-#ifndef emacs
-
-static struct re_pattern_buffer re_comp_buf;
-
-char *
-re_comp (s)
- char *s;
-{
- if (!s)
- {
- if (!re_comp_buf.buffer)
- return "No previous regular expression";
- return 0;
- }
-
- if (!re_comp_buf.buffer)
- {
- if (!(re_comp_buf.buffer = (char *) malloc (200)))
- return "Memory exhausted";
- re_comp_buf.allocated = 200;
- if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH)))
- return "Memory exhausted";
- }
- return re_compile_pattern (s, strlen (s), &re_comp_buf);
-}
-
-int
-re_exec (s)
- char *s;
-{
- int len = strlen (s);
- return 0 <= re_search (&re_comp_buf, s, len, 0, len, 0);
-}
-
-#endif /* emacs */
-
-#ifdef test
-
-#include <stdio.h>
-
-/* Indexed by a character, gives the upper case equivalent of the character */
-
-static 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
- };
-
-main (argc, argv)
- int argc;
- char **argv;
-{
- char pat[80];
- struct re_pattern_buffer buf;
- int i;
- char c;
- char fastmap[(1 << BYTEWIDTH)];
-
- /* Allow a command argument to specify the style of syntax. */
- if (argc > 1)
- obscure_syntax = atoi (argv[1]);
-
- buf.allocated = 40;
- buf.buffer = (char *) malloc (buf.allocated);
- buf.fastmap = fastmap;
- buf.translate = upcase;
-
- while (1)
- {
- gets (pat);
-
- if (*pat)
- {
- re_compile_pattern (pat, strlen(pat), &buf);
-
- for (i = 0; i < buf.used; i++)
- printchar (buf.buffer[i]);
-
- putchar ('\n');
-
- printf ("%d allocated, %d used.\n", buf.allocated, buf.used);
-
- re_compile_fastmap (&buf);
- printf ("Allowed by fastmap: ");
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (fastmap[i]) printchar (i);
- putchar ('\n');
- }
-
- gets (pat); /* Now read the string to match against */
-
- i = re_match (&buf, pat, strlen (pat), 0, 0);
- printf ("Match value %d.\n", i);
- }
-}
-
-#ifdef NOTDEF
-print_buf (bufp)
- struct re_pattern_buffer *bufp;
-{
- int i;
-
- printf ("buf is :\n----------------\n");
- for (i = 0; i < bufp->used; i++)
- printchar (bufp->buffer[i]);
-
- printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used);
-
- printf ("Allowed by fastmap: ");
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (bufp->fastmap[i])
- printchar (i);
- printf ("\nAllowed by translate: ");
- if (bufp->translate)
- for (i = 0; i < (1 << BYTEWIDTH); i++)
- if (bufp->translate[i])
- printchar (i);
- printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't");
- printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not");
-}
-#endif
-
-printchar (c)
- char c;
-{
- if (c < 041 || c >= 0177)
- {
- putchar ('\\');
- putchar (((c >> 6) & 3) + '0');
- putchar (((c >> 3) & 7) + '0');
- putchar ((c & 7) + '0');
- }
- else
- putchar (c);
-}
-
-error (string)
- char *string;
-{
- puts (string);
- exit (1);
-}
-
-#endif /* test */
diff --git a/gnu/usr.bin/gdb/regex.h b/gnu/usr.bin/gdb/regex.h
deleted file mode 100644
index d0d8a82..0000000
--- a/gnu/usr.bin/gdb/regex.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/* Definitions for data structures callers pass the regex library.
- Copyright (C) 1985, 1989 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! */
-
-
-/* Define number of parens for which we record the beginnings and ends.
- This affects how much space the `struct re_registers' type takes up. */
-#ifndef RE_NREGS
-#define RE_NREGS 10
-#endif
-
-/* These bits are used in the obscure_syntax variable to choose among
- alternative regexp syntaxes. */
-
-/* 1 means plain parentheses serve as grouping, and backslash
- parentheses are needed for literal searching.
- 0 means backslash-parentheses are grouping, and plain parentheses
- are for literal searching. */
-#define RE_NO_BK_PARENS 1
-
-/* 1 means plain | serves as the "or"-operator, and \| is a literal.
- 0 means \| serves as the "or"-operator, and | is a literal. */
-#define RE_NO_BK_VBAR 2
-
-/* 0 means plain + or ? serves as an operator, and \+, \? are literals.
- 1 means \+, \? are operators and plain +, ? are literals. */
-#define RE_BK_PLUS_QM 4
-
-/* 1 means | binds tighter than ^ or $.
- 0 means the contrary. */
-#define RE_TIGHT_VBAR 8
-
-/* 1 means treat \n as an _OR operator
- 0 means treat it as a normal character */
-#define RE_NEWLINE_OR 16
-
-/* 0 means that a special characters (such as *, ^, and $) always have
- their special meaning regardless of the surrounding context.
- 1 means that special characters may act as normal characters in some
- contexts. Specifically, this applies to:
- ^ - only special at the beginning, or after ( or |
- $ - only special at the end, or before ) or |
- *, +, ? - only special when not after the beginning, (, or | */
-#define RE_CONTEXT_INDEP_OPS 32
-
-/* Now define combinations of bits for the standard possibilities. */
-#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
-#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
-#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
-#define RE_SYNTAX_EMACS 0
-
-/* This data structure is used to represent a compiled pattern. */
-
-struct re_pattern_buffer
- {
- char *buffer; /* Space holding the compiled pattern commands. */
- int allocated; /* Size of space that buffer points to */
- int used; /* Length of portion of buffer actually occupied */
- char *fastmap; /* Pointer to fastmap, if any, or zero if none. */
- /* re_search uses the fastmap, if there is one,
- to skip quickly over totally implausible characters */
- char *translate; /* Translate table to apply to all characters before comparing.
- Or zero for no translation.
- The translation is applied to a pattern when it is compiled
- and to data when it is matched. */
- char fastmap_accurate;
- /* Set to zero when a new pattern is stored,
- set to one when the fastmap is updated from it. */
- char can_be_null; /* Set to one by compiling fastmap
- if this pattern might match the null string.
- It does not necessarily match the null string
- in that case, but if this is zero, it cannot.
- 2 as value means can match null string
- but at end of range or before a character
- listed in the fastmap. */
- };
-
-/* Structure to store "register" contents data in.
-
- Pass the address of such a structure as an argument to re_match, etc.,
- if you want this information back.
-
- start[i] and end[i] record the string matched by \( ... \) grouping i,
- for i from 1 to RE_NREGS - 1.
- start[0] and end[0] record the entire string matched. */
-
-struct re_registers
- {
- int start[RE_NREGS];
- int end[RE_NREGS];
- };
-
-/* These are the command codes that appear in compiled regular expressions, one per byte.
- Some command codes are followed by argument bytes.
- A command code can specify any interpretation whatever for its arguments.
- Zero-bytes may appear in the compiled regular expression. */
-
-enum regexpcode
- {
- unused,
- exactn, /* followed by one byte giving n, and then by n literal bytes */
- begline, /* fails unless at beginning of line */
- endline, /* fails unless at end of line */
- jump, /* followed by two bytes giving relative address to jump to */
- on_failure_jump, /* followed by two bytes giving relative address of place
- to resume at in case of failure. */
- finalize_jump, /* Throw away latest failure point and then jump to address. */
- maybe_finalize_jump, /* Like jump but finalize if safe to do so.
- This is used to jump back to the beginning
- of a repeat. If the command that follows
- this jump is clearly incompatible with the
- one at the beginning of the repeat, such that
- we can be sure that there is no use backtracking
- out of repetitions already completed,
- then we finalize. */
- dummy_failure_jump, /* jump, 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. */
- anychar, /* matches any one character */
- charset, /* matches any one char belonging to specified set.
- First following byte is # bitmap bytes.
- Then come bytes for a bit-map 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_not, /* similar but match any character that is NOT one of those specified */
- start_memory, /* starts remembering the text that is matched
- and stores it in a memory register.
- followed by one byte containing the register number.
- Register numbers must be in the range 0 through NREGS. */
- stop_memory, /* stops remembering the text that is matched
- and stores it in a memory register.
- followed by one byte containing the register number.
- Register numbers must be in the range 0 through NREGS. */
- duplicate, /* match a duplicate of something remembered.
- Followed by one byte containing the index of the memory register. */
- before_dot, /* Succeeds if before dot */
- at_dot, /* Succeeds if at dot */
- after_dot, /* Succeeds if after dot */
- begbuf, /* Succeeds if at beginning of buffer */
- endbuf, /* Succeeds if at end of buffer */
- 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 */
- syntaxspec, /* Matches any character whose syntax is specified.
- followed by a byte which contains a syntax code, Sword or such like */
- notsyntaxspec /* Matches any character whose syntax differs from the specified. */
- };
-
-extern char *re_compile_pattern ();
-/* Is this really advertised? */
-extern void re_compile_fastmap ();
-extern int re_search (), re_search_2 ();
-extern int re_match (), re_match_2 ();
-
-/* 4.2 bsd compatibility (yuck) */
-extern char *re_comp ();
-extern int re_exec ();
-
-#ifdef SYNTAX_TABLE
-extern char *re_syntax_table;
-#endif
diff --git a/gnu/usr.bin/gdb/remote-sl.c b/gnu/usr.bin/gdb/remote-sl.c
deleted file mode 100644
index 4c72197..0000000
--- a/gnu/usr.bin/gdb/remote-sl.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * The binary remote protocol is still under development at LBL;
- * the current version can't be released.
- * Sorry, folks...
- */
-int
-sl_open()
-{
- return -1;
-}
diff --git a/gnu/usr.bin/gdb/remote.c b/gnu/usr.bin/gdb/remote.c
deleted file mode 100644
index 59658a8..0000000
--- a/gnu/usr.bin/gdb/remote.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Van Jacobson and Steven McCanne of Lawrence Berkeley Laboratory.
- *
- * 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.
- *
- * $Header: /home/cvs/386BSD/src/usr.bin/gdb/remote.c,v 1.1.1.1 1993/06/12 14:52:22 rgrimes Exp $;
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)remote.c 6.5 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-#include "param.h"
-
-#include <stdio.h>
-#include <varargs.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "wait.h"
-
-#include "kgdb_proto.h"
-
-static FILE *kiodebug;
-static int icache = 1;
-extern int kernel_debugging;
-
-static int remote_cache_valid;
-static int remote_instub;
-
-static void remote_signal();
-static void remote_debug();
-static void print_msg();
-
-static int remote_mtu;
-static int (*send_msg)();
-static int (*recv_msg)();
-static void (*closelink)();
-
-static u_char *inbuffer;
-static u_char *outbuffer;
-
-/*
- * Statistics.
- */
-static int remote_ierrs;
-static int remote_oerrs;
-static int remote_seqerrs;
-static int remote_spurious;
-
-#define PUTCMD(cmd) m_xchg(cmd, (u_char *)0, 0, (u_char *)0, (int *)0)
-
-/*
- * Send an outbound message to the remote machine and read the reply.
- * Either or both message buffers may be NULL.
- */
-static int
-m_xchg(type, out, outlen, in, inlen)
- int type;
- u_char *out;
- int outlen;
- u_char *in;
- int *inlen;
-{
- register int err, (*send)() = send_msg, (*recv)() = recv_msg;
- int ack;
- static int seqbit = 0;
-
- if (!remote_instub) {
- remote_instub = 1;
- PUTCMD(KGDB_EXEC);
- }
-
- seqbit ^= KGDB_SEQ;
- while (1) {
- err = (*send)(type | seqbit, out, outlen);
- if (err) {
- ++remote_oerrs;
- if (kiodebug)
- remote_debug("send error %d\n", err);
- }
- if (kiodebug)
- print_msg(type | seqbit, out, outlen, 'O');
-
- recv:
- err = (*recv)(&ack, in, inlen);
- if (err) {
- ++remote_ierrs;
- if (kiodebug)
- remote_debug("recv error %d\n", err);
- remote_cache_valid = 0;
- } else if (kiodebug)
- print_msg(ack, in, inlen ? *inlen : 0, 'I');
-
- if (err)
- continue;
-
- if ((ack & KGDB_ACK) == 0 || KGDB_CMD(ack) != KGDB_CMD(type)) {
- ++remote_spurious;
- continue;
- }
- if ((ack & KGDB_SEQ) ^ seqbit) {
- ++remote_seqerrs;
- goto recv;
- }
- return ack;
- }
-}
-
-/*
- * Wait for the specified message type. Discard anything else.
- * (this is used by 'remote-signal' to help us resync with other side.)
- */
-static void
-m_recv(type, in, inlen)
- int type;
- u_char *in;
- int *inlen;
-{
- int reply, err;
-
- while (1) {
- err = (*recv_msg)(&reply, in, inlen);
- if (err) {
- ++remote_ierrs;
- if (kiodebug)
- remote_debug("recv error %d\n", err);
- } else if (kiodebug)
- print_msg(reply, in, inlen ? *inlen : 0, 'I');
-
- if (KGDB_CMD(reply) == type)
- return;
- ++remote_spurious;
- }
-}
-
-/*
- * Send a message. Do not wait for *any* response from the other side.
- * Some other thread of control will pick up the ack that will be generated.
- */
-static void
-m_send(type, buf, len)
- int type;
- u_char *buf;
- int len;
-{
- int err;
-
- if (!remote_instub) {
- remote_instub = 1;
- PUTCMD(KGDB_EXEC);
- }
-
- err = (*send_msg)(type, buf, len);
- if (err) {
- ++remote_ierrs;
- if (kiodebug)
- remote_debug("[send error %d] ", err);
- }
- if (kiodebug)
- print_msg(type, buf, len, 'O');
-}
-
-/*
- * Open a connection to a remote debugger.
- * NAME is the filename used for communication.
- */
-void
-remote_open(name, from_tty)
- char *name;
- int from_tty;
-{
- int bufsize;
-
- remote_debugging = 0;
- if (sl_open(name, &send_msg, &recv_msg, &closelink, &remote_mtu,
- &bufsize))
- return;
- if (from_tty)
- printf("Remote debugging using %s\n", name);
- remote_debugging = 1;
-
- remote_cache_valid = 0;
-
- inbuffer = (u_char *)malloc(bufsize);
- outbuffer = (u_char *)malloc(bufsize);
-
- remote_signal();
-
- remote_ierrs = 0;
- remote_oerrs = 0;
- remote_spurious = 0;
-}
-
-/*
- * Close the open connection to the remote debugger. Use this when you want
- * to detach and do something else with your gdb.
- */
-void
-remote_close(from_tty)
- int from_tty;
-{
- if (!remote_debugging)
- error("remote debugging not enabled");
-
- remote_debugging = 0;
- /*
- * Take remote machine out of debug mode.
- */
- (void)PUTCMD(KGDB_KILL);
- (*closelink)();
- if (from_tty)
- printf("Ending remote debugging\n");
-
- free((char *)inbuffer);
- free((char *)outbuffer);
-}
-
-/*
- * Tell the remote machine to resume.
- */
-int
-remote_resume(step, signal)
- int step, signal;
-{
- if (!step) {
- (void)PUTCMD(KGDB_CONT);
- remote_instub = 0;
- } else {
-#ifdef NO_SINGLE_STEP
- single_step(0);
-#else
- (void)PUTCMD(KGDB_STEP);
-#endif
- }
-}
-
-/*
- * Wait until the remote machine stops, then return, storing status in STATUS
- * just as `wait' would.
- */
-int
-remote_wait(status)
- WAITTYPE *status;
-{
- int len;
-
- WSETEXIT((*status), 0);
- /*
- * When the machine stops, it will send us a KGDB_SIGNAL message,
- * so we wait for one of these.
- */
- m_recv(KGDB_SIGNAL, inbuffer, &len);
- WSETSTOP((*status), inbuffer[0]);
-}
-
-/*
- * Register context as of last remote_fetch_registers().
- */
-static char reg_cache[REGISTER_BYTES];
-
-/*
- * Read the remote registers into the block REGS.
- */
-void
-remote_fetch_registers(regs)
- char *regs;
-{
- int regno, len, rlen, ack;
- u_char *cp, *ep;
-
- regno = -1;
- do {
- outbuffer[0] = regno + 1;
- ack = m_xchg(remote_cache_valid ?
- KGDB_REG_R|KGDB_DELTA : KGDB_REG_R,
- outbuffer, 1, inbuffer, &len);
- cp = inbuffer;
- ep = cp + len;
- while (cp < ep) {
- regno = *cp++;
- rlen = REGISTER_RAW_SIZE(regno);
- bcopy((char *)cp,
- &reg_cache[REGISTER_BYTE(regno)], rlen);
- cp += rlen;
- }
- } while (ack & KGDB_MORE);
-
- remote_cache_valid = 1;
- bcopy(reg_cache, regs, REGISTER_BYTES);
-}
-
-/*
- * Store the remote registers from the contents of the block REGS.
- */
-void
-remote_store_registers(regs)
- char *regs;
-{
- u_char *cp, *ep;
- int regno, off, rlen;
-
- cp = outbuffer;
- ep = cp + remote_mtu;
-
- for (regno = 0; regno < NUM_REGS; ++regno) {
- off = REGISTER_BYTE(regno);
- rlen = REGISTER_RAW_SIZE(regno);
- if (!remote_cache_valid ||
- bcmp(&regs[off], &reg_cache[off], rlen) != 0) {
- if (cp + rlen + 1 >= ep) {
- (void)m_xchg(KGDB_REG_W,
- outbuffer, cp - outbuffer,
- (u_char *)0, (int *)0);
- cp = outbuffer;
- }
- *cp++ = regno;
- bcopy(&regs[off], cp, rlen);
- cp += rlen;
- }
- }
- if (cp != outbuffer)
- (void)m_xchg(KGDB_REG_W, outbuffer, cp - outbuffer,
- (u_char *)0, (int *)0);
- bcopy(regs, reg_cache, REGISTER_BYTES);
-}
-
-/*
- * Store a chunk of memory into the remote host.
- * 'remote_addr' is the address in the remote memory space.
- * 'cp' is the address of the buffer in our space, and 'len' is
- * the number of bytes. Returns an errno status.
- */
-int
-remote_write_inferior_memory(remote_addr, cp, len)
- CORE_ADDR remote_addr;
- u_char *cp;
- int len;
-{
- int cnt;
-
- while (len > 0) {
- cnt = min(len, remote_mtu - 4);
- bcopy((char *)&remote_addr, outbuffer, 4);
- bcopy(cp, outbuffer + 4, cnt);
- (void)m_xchg(KGDB_MEM_W, outbuffer, cnt + 4, inbuffer, &len);
-
- if (inbuffer[0])
- return inbuffer[0];
-
- remote_addr += cnt;
- cp += cnt;
- len -= cnt;
- }
- return 0;
-}
-
-/*
- * Read memory data directly from the remote machine.
- * 'remote_addr' is the address in the remote memory space.
- * 'cp' is the address of the buffer in our space, and 'len' is
- * the number of bytes. Returns an errno status.
- */
-static int
-remote_read_memory(remote_addr, cp, len)
- CORE_ADDR remote_addr;
- u_char *cp;
- int len;
-{
- int cnt, inlen;
-
- while (len > 0) {
- cnt = min(len, remote_mtu - 1);
- outbuffer[0] = cnt;
- bcopy((char *)&remote_addr, (char *)&outbuffer[1], 4);
-
- (void)m_xchg(KGDB_MEM_R, outbuffer, 5, inbuffer, &inlen);
-
- if (inbuffer[0] != 0)
- return inbuffer[0];
-
- if (cnt != inlen - 1)
- /* XXX */
- error("remote_read_memory() request botched");
-
- bcopy((char *)&inbuffer[1], (char *)cp, cnt);
-
- remote_addr += cnt;
- cp += cnt;
- len -= cnt;
- }
- return 0;
-}
-
-int
-remote_read_inferior_memory(remote_addr, cp, len)
- CORE_ADDR remote_addr;
- char *cp;
- int len;
-{
- int stat = 0;
-
- if (icache) {
- extern CORE_ADDR text_start, text_end;
- CORE_ADDR xferend = remote_addr + len;
-
- if (remote_addr < text_end && text_start < xferend) {
- /*
- * at least part of this xfer is in the text
- * space -- xfer the overlap from the exec file.
- */
- if (remote_addr >= text_start && xferend < text_end)
- return (xfer_core_file(remote_addr, cp, len));
- if (remote_addr >= text_start) {
- int i = text_end - remote_addr;
-
- if (stat = xfer_core_file(remote_addr, cp, i))
- return (stat);
- remote_addr += i;
- cp += i;
- len -= i;
- } else if (xferend <= text_end) {
- int i = xferend - text_start;
-
- len = text_start - remote_addr;
- if (stat = xfer_core_file(text_start,
- cp + len, i))
- return (stat);
- }
- }
- }
- return remote_read_memory(remote_addr, cp, len);
-}
-
-/*
- * Signal the remote machine. The remote end might be idle or it might
- * already be in debug mode -- we need to handle both case. Thus, we use
- * the framing character as the wakeup byte, and send a SIGNAL packet.
- * If the remote host is idle, the framing character will wake it up.
- * If it is in the kgdb stub, then we will get a SIGNAL reply.
- */
-static void
-remote_signal()
-{
- if (!remote_debugging)
- printf("Remote debugging not enabled.\n");
- else {
- remote_instub = 0;
- m_send(KGDB_SIGNAL, (u_char *)0, 0);
- }
-}
-
-static void
-remote_signal_command()
-{
- extern int stop_after_attach;
-
- if (!remote_debugging)
- error("Not debugging remote.");
- remote_cache_valid = 0;
- remote_signal();
- restart_remote();
-}
-
-/*
- * Print a message for debugging.
- */
-static void
-print_msg(type, buf, len, dir)
- int type;
- u_char *buf;
- int len;
- int dir;
-{
- int i;
- char *s;
-
- switch (KGDB_CMD(type)) {
- case KGDB_MEM_R: s = "memr"; break;
- case KGDB_MEM_W: s = "memw"; break;
- case KGDB_REG_R: s = "regr"; break;
- case KGDB_REG_W: s = "regw"; break;
- case KGDB_CONT: s = "cont"; break;
- case KGDB_STEP: s = "step"; break;
- case KGDB_KILL: s = "kill"; break;
- case KGDB_SIGNAL: s = "sig "; break;
- case KGDB_EXEC: s = "exec"; break;
- default: s = "unk "; break;
- }
- remote_debug("%c %c%c%c%c %s (%02x): ", dir,
- (type & KGDB_ACK) ? 'A' : '.',
- (type & KGDB_DELTA) ? 'D' : '.',
- (type & KGDB_MORE) ? 'M' : '.',
- (type & KGDB_SEQ) ? '-' : '+',
- s, type);
- if (buf)
- for (i = 0; i < len; ++i)
- remote_debug("%02x", buf[i]);
- remote_debug("\n");
-}
-
-static void
-set_remote_text_refs_command(arg, from_tty)
- char *arg;
- int from_tty;
-{
- icache = !parse_binary_operation("set remote-text-refs", arg);
-}
-
-static void
-remote_debug_command(arg, from_tty)
- char *arg;
- int from_tty;
-{
- char *name;
-
- if (kiodebug != 0 && kiodebug != stderr)
- (void)fclose(kiodebug);
-
- if (arg == 0) {
- kiodebug = 0;
- printf("Remote debugging off.\n");
- return;
- }
- if (arg[0] == '-') {
- kiodebug = stderr;
- name = "stderr";
- } else {
- kiodebug = fopen(arg, "w");
- if (kiodebug == 0) {
- printf("Cannot open '%s'.\n", arg);
- return;
- }
- name = arg;
- }
- printf("Remote debugging output routed to %s.\n", name);
-}
-
-/* ARGSUSED */
-static void
-remote_info(arg, from_tty)
- char *arg;
- int from_tty;
-{
- printf("Using %s for text references.\n",
- icache? "local executable" : "remote");
- printf("Protocol debugging is %s.\n", kiodebug? "on" : "off");
- printf("%d spurious input messages.\n", remote_spurious);
- printf("%d input errors; %d output errors; %d sequence errors.\n",
- remote_ierrs, remote_oerrs, remote_seqerrs);
-}
-
-/* VARARGS */
-static void
-remote_debug(va_alist)
- va_dcl
-{
- register char *cp;
- va_list ap;
-
- va_start(ap);
- cp = va_arg(ap, char *);
- (void)vfprintf(kiodebug, cp, ap);
- va_end(ap);
- fflush(kiodebug);
-}
-
-extern struct cmd_list_element *setlist;
-
-void
-_initialize_remote()
-{
- add_com("remote-signal", class_run, remote_signal_command,
- "If remote debugging, send interrupt signal to remote.");
- add_cmd("remote-text-refs", class_support,
- set_remote_text_refs_command,
-"Enable/disable use of local executable for text segment references.\n\
-If on, all memory read/writes go to remote.\n\
-If off, text segment reads use the local executable.",
- &setlist);
-
- add_com("remote-debug", class_run, remote_debug_command,
-"With a file name argument, enables output of remote protocol debugging\n\
-messages to said file. If file is `-', stderr is used.\n\
-With no argument, remote debugging is disabled.");
-
- add_info("remote", remote_info,
- "Show current settings of remote debugging options.");
-}
-
diff --git a/gnu/usr.bin/gdb/source.c b/gnu/usr.bin/gdb/source.c
deleted file mode 100644
index d9ae20f..0000000
--- a/gnu/usr.bin/gdb/source.c
+++ /dev/null
@@ -1,1166 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)source.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* List lines of source files for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "symtab.h"
-#include "param.h"
-
-#ifdef USG
-#include <sys/types.h>
-#include <fcntl.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-
-/* Path of directories to search for source files.
- Same format as the PATH environment variable's value. */
-
-static char *source_path;
-
-/* Symtab of default file for listing lines of. */
-
-struct symtab *current_source_symtab;
-
-/* Default next line to list. */
-
-int current_source_line;
-
-/* Line number of last line printed. Default for various commands.
- current_source_line is usually, but not always, the same as this. */
-
-static int last_line_listed;
-
-/* First line number listed by last listing command. */
-
-static int first_line_listed;
-
-
-struct symtab *psymtab_to_symtab ();
-
-/* Set the source file default for the "list" command, specifying a
- symtab. Sigh. Behaivior specification: If it is called with a
- non-zero argument, that is the symtab to select. If it is not,
- first lookup "main"; if it exists, use the symtab and line it
- defines. If not, take the last symtab in the symtab_list (if it
- exists) or the last symtab in the psytab_list (if *it* exists). If
- none of this works, report an error. */
-
-void
-select_source_symtab (s)
- register struct symtab *s;
-{
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
- struct partial_symtab *ps, *cs_pst;
-
- if (s)
- {
- current_source_symtab = s;
- current_source_line = 1;
- return;
- }
-
- /* Make the default place to list be the function `main'
- if one exists. */
- if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0))
- {
- sals = decode_line_spec ("main", 1);
- sal = sals.sals[0];
- free (sals.sals);
- current_source_symtab = sal.symtab;
- current_source_line = max (sal.line - 9, 1);
- return;
- }
-
- /* All right; find the last file in the symtab list (ignoring .h's). */
-
- if (s = symtab_list)
- {
- do
- {
- char *name = s->filename;
- int len = strlen (name);
- if (! (len > 2 && !strcmp (&name[len - 2], ".h")))
- current_source_symtab = s;
- s = s->next;
- }
- while (s);
- current_source_line = 1;
- }
- else if (partial_symtab_list)
- {
- ps = partial_symtab_list;
- while (ps)
- {
- char *name = ps->filename;
- int len = strlen (name);
- if (! (len > 2 && !strcmp (&name[len - 2], ".h")))
- cs_pst = ps;
- ps = ps->next;
- }
- if (cs_pst)
- if (cs_pst->readin)
- fatal ("Internal: select_source_symtab: readin pst found and no symtabs.");
- else
- current_source_symtab = psymtab_to_symtab (cs_pst);
- else
- current_source_symtab = 0;
- current_source_line = 1;
- }
-}
-
-static void
-directories_info ()
-{
- printf ("Source directories searched: %s\n", source_path);
-}
-
-void
-init_source_path ()
-{
- register struct symtab *s;
-
- source_path = savestring (current_directory, strlen (current_directory));
-
- /* Forget what we learned about line positions in source files;
- must check again now since files may be found in
- a different directory now. */
- for (s = symtab_list; s; s = s->next)
- if (s->line_charpos != 0)
- {
- free (s->line_charpos);
- s->line_charpos = 0;
- }
-}
-
-void
-directory_command (dirname, from_tty)
- char *dirname;
- int from_tty;
-{
- char *old = source_path;
-
- dont_repeat ();
-
- if (dirname == 0)
- {
- if (query ("Reinitialize source path to %s? ", current_directory))
- {
- init_source_path ();
- free (old);
- }
- }
- else
- {
- dirname = tilde_expand (dirname);
- make_cleanup (free, dirname);
-
- do
- {
- extern char *index ();
- char *name = dirname;
- register char *p;
- struct stat st;
-
- {
- char *colon = index (name, ':');
- char *space = index (name, ' ');
- char *tab = index (name, '\t');
- if (colon == 0 && space == 0 && tab == 0)
- p = dirname = name + strlen (name);
- else
- {
- p = 0;
- if (colon != 0 && (p == 0 || colon < p))
- p = colon;
- if (space != 0 && (p == 0 || space < p))
- p = space;
- if (tab != 0 && (p == 0 || tab < p))
- p = tab;
- dirname = p + 1;
- while (*dirname == ':' || *dirname == ' ' || *dirname == '\t')
- ++dirname;
- }
- }
-
- if (p[-1] == '/')
- /* Sigh. "foo/" => "foo" */
- --p;
- *p = '\0';
-
- while (p[-1] == '.')
- {
- if (p - name == 1)
- {
- /* "." => getwd (). */
- name = current_directory;
- goto append;
- }
- else if (p[-2] == '/')
- {
- if (p - name == 2)
- {
- /* "/." => "/". */
- *--p = '\0';
- goto append;
- }
- else
- {
- /* "...foo/." => "...foo". */
- p -= 2;
- *p = '\0';
- continue;
- }
- }
- else
- break;
- }
-
- if (*name != '/')
- name = concat (current_directory, "/", name);
- else
- name = savestring (name, p - name);
- make_cleanup (free, name);
-
- if (stat (name, &st) < 0)
- perror_with_name (name);
- if ((st.st_mode & S_IFMT) != S_IFDIR)
- error ("%s is not a directory.", name);
-
- append:
- {
- register unsigned int len = strlen (name);
-
- p = source_path;
- while (1)
- {
- if (!strncmp (p, name, len)
- && (p[len] == '\0' || p[len] == ':'))
- {
- if (from_tty)
- printf ("\"%s\" is already in the source path.\n", name);
- break;
- }
- p = index (p, ':');
- if (p != 0)
- ++p;
- else
- break;
- }
- if (p == 0)
- {
- source_path = concat (old, ":", name);
- free (old);
- old = source_path;
- }
- }
- } while (*dirname != '\0');
- if (from_tty)
- directories_info ();
- }
-}
-
-/* Open a file named STRING, searching path PATH (dir names sep by colons)
- using mode MODE and protection bits PROT in the calls to open.
- If TRY_CWD_FIRST, try to open ./STRING before searching PATH.
- (ie pretend the first element of PATH is ".")
- If FILENAMED_OPENED is non-null, set it to a newly allocated string naming
- the actual file opened (this string will always start with a "/"
-
- If a file is found, return the descriptor.
- Otherwise, return -1, with errno set for the last name we tried to open. */
-
-/* >>>> This should only allow files of certain types,
- >>>> eg executable, non-directory */
-int
-openp (path, try_cwd_first, string, mode, prot, filename_opened)
- char *path;
- int try_cwd_first;
- char *string;
- int mode;
- int prot;
- char **filename_opened;
-{
- register int fd;
- register char *filename;
- register char *p, *p1;
- register int len;
-
- if (!path)
- path = ".";
-
- /* ./foo => foo */
- while (string[0] == '.' && string[1] == '/')
- string += 2;
-
- if (try_cwd_first || string[0] == '/')
- {
- filename = string;
- fd = open (filename, mode, prot);
- if (fd >= 0 || string[0] == '/')
- goto done;
- }
-
- filename = (char *) alloca (strlen (path) + strlen (string) + 2);
- fd = -1;
- for (p = path; p; p = p1 ? p1 + 1 : 0)
- {
- p1 = (char *) index (p, ':');
- if (p1)
- len = p1 - p;
- else
- len = strlen (p);
-
- strncpy (filename, p, len);
- filename[len] = 0;
- strcat (filename, "/");
- strcat (filename, string);
-
- fd = open (filename, mode, prot);
- if (fd >= 0) break;
- }
-
- done:
- if (filename_opened)
- if (fd < 0)
- *filename_opened = (char *) 0;
- else if (filename[0] == '/')
- *filename_opened = savestring (filename, strlen (filename));
- else
- {
- *filename_opened = concat (current_directory, "/", filename);
- }
-
- return fd;
-}
-
-/* Create and initialize the table S->line_charpos that records
- the positions of the lines in the source file, which is assumed
- to be open on descriptor DESC.
- All set S->nlines to the number of such lines. */
-
-static void
-find_source_lines (s, desc)
- struct symtab *s;
- int desc;
-{
- struct stat st;
- register char *data, *p, *end;
- int nlines = 0;
- int lines_allocated = 1000;
- int *line_charpos = (int *) xmalloc (lines_allocated * sizeof (int));
- extern int exec_mtime;
-
- if (fstat (desc, &st) < 0)
- perror_with_name (s->filename);
- if (get_exec_file (0) != 0 && exec_mtime < st.st_mtime)
- printf ("Source file is more recent than executable.\n");
-
- data = (char *) alloca (st.st_size);
- if (myread (desc, data, st.st_size) < 0)
- perror_with_name (s->filename);
- end = data + st.st_size;
- p = data;
- line_charpos[0] = 0;
- nlines = 1;
- while (p != end)
- {
- if (*p++ == '\n'
- /* A newline at the end does not start a new line. */
- && p != end)
- {
- if (nlines == lines_allocated)
- {
- lines_allocated *= 2;
- line_charpos = (int *) xrealloc (line_charpos,
- sizeof (int) * lines_allocated);
- }
- line_charpos[nlines++] = p - data;
- }
- }
- s->nlines = nlines;
- s->line_charpos = (int *) xrealloc (line_charpos, nlines * sizeof (int));
-}
-
-/* Return the character position of a line LINE in symtab S.
- Return 0 if anything is invalid. */
-
-int
-source_line_charpos (s, line)
- struct symtab *s;
- int line;
-{
- if (!s) return 0;
- if (!s->line_charpos || line <= 0) return 0;
- if (line > s->nlines)
- line = s->nlines;
- return s->line_charpos[line - 1];
-}
-
-/* Return the line number of character position POS in symtab S. */
-
-int
-source_charpos_line (s, chr)
- register struct symtab *s;
- register int chr;
-{
- register int line = 0;
- register int *lnp;
-
- if (s == 0 || s->line_charpos == 0) return 0;
- lnp = s->line_charpos;
- /* Files are usually short, so sequential search is Ok */
- while (line < s->nlines && *lnp <= chr)
- {
- line++;
- lnp++;
- }
- if (line >= s->nlines)
- line = s->nlines;
- return line;
-}
-
-/* Get full pathname and line number positions for a symtab.
- Return nonzero if line numbers may have changed.
- Set *FULLNAME to actual name of the file as found by `openp',
- or to 0 if the file is not found. */
-
-int
-get_filename_and_charpos (s, line, fullname)
- struct symtab *s;
- int line;
- char **fullname;
-{
- register int desc, linenums_changed = 0;
-
- desc = openp (source_path, 0, s->filename, O_RDONLY, 0, &s->fullname);
- if (desc < 0)
- {
- if (fullname)
- *fullname = NULL;
- return 0;
- }
- if (fullname)
- *fullname = s->fullname;
- if (s->line_charpos == 0) linenums_changed = 1;
- if (linenums_changed) find_source_lines (s, desc);
- close (desc);
- return linenums_changed;
-}
-
-/* Print text describing the full name of the source file S
- and the line number LINE and its corresponding character position.
- The text starts with two Ctrl-z so that the Emacs-GDB interface
- can easily find it.
-
- MID_STATEMENT is nonzero if the PC is not at the beginning of that line.
-
- Return 1 if successful, 0 if could not find the file. */
-
-int
-identify_source_line (s, line, mid_statement)
- struct symtab *s;
- int line;
- int mid_statement;
-{
- if (s->line_charpos == 0)
- get_filename_and_charpos (s, line, 0);
- if (s->fullname == 0)
- return 0;
- printf ("\032\032%s:%d:%d:%s:0x%x\n", s->fullname,
- line, s->line_charpos[line - 1],
- mid_statement ? "middle" : "beg",
- get_frame_pc (get_current_frame()));
- current_source_line = line;
- first_line_listed = line;
- last_line_listed = line;
- current_source_symtab = s;
- return 1;
-}
-
-/* Print source lines from the file of symtab S,
- starting with line number LINE and stopping before line number STOPLINE. */
-
-void
-print_source_lines (s, line, stopline, noerror)
- struct symtab *s;
- int line, stopline;
- int noerror;
-{
- register int c;
- register int desc;
- register FILE *stream;
- int nlines = stopline - line;
-
- desc = openp (source_path, 0, s->filename, O_RDONLY, 0, &s->fullname);
- if (desc < 0)
- {
- extern int errno;
- if (noerror && line + 1 == stopline)
- {
- /* can't find the file - tell user where we are anyway */
- current_source_symtab = s;
- current_source_line = line;
- first_line_listed = line;
- last_line_listed = line;
- printf_filtered ("%d\t(%s)\n", current_source_line++, s->filename);
- }
- else
- {
- if (! noerror)
- perror_with_name (s->filename);
- print_sys_errmsg (s->filename, errno);
- }
- return;
- }
-
- if (s->line_charpos == 0)
- find_source_lines (s, desc);
-
- if (line < 1 || line > s->nlines)
- {
- close (desc);
- error ("Line number %d out of range; %s has %d lines.",
- line, s->filename, s->nlines);
- }
-
- if (lseek (desc, s->line_charpos[line - 1], 0) < 0)
- {
- close (desc);
- perror_with_name (s->filename);
- }
-
- current_source_symtab = s;
- current_source_line = line;
- first_line_listed = line;
-
- stream = fdopen (desc, "r");
- clearerr (stream);
-
- while (nlines-- > 0)
- {
- c = fgetc (stream);
- if (c == EOF) break;
- last_line_listed = current_source_line;
- printf_filtered ("%d\t", current_source_line++);
- do
- {
- if (c < 040 && c != '\t' && c != '\n')
- printf_filtered ("^%c", c + 0100);
- else if (c == 0177)
- printf_filtered ("^?");
- else
- printf_filtered ("%c", c);
- } while (c != '\n' && (c = fgetc (stream)) >= 0);
- }
-
- fclose (stream);
-}
-
-
-
-/*
- C++
- Print a list of files and line numbers which a user may choose from
- in order to list a function which was specified ambiguously
- (as with `list classname::overloadedfuncname', for example).
- The vector in SALS provides the filenames and line numbers.
- */
-static void
-ambiguous_line_spec (sals)
- struct symtabs_and_lines *sals;
-{
- int i;
-
- for (i = 0; i < sals->nelts; ++i)
- printf("file: \"%s\", line number: %d\n",
- sals->sals[i].symtab->filename, sals->sals[i].line);
-}
-
-
-static void
-file_command(arg, from_tty)
- char *arg;
- int from_tty;
-{
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
- struct symbol *sym;
- char *arg1;
- int linenum_beg = 0;
- char *p;
-
- if (symtab_list == 0 && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
-
- /* Pull in a current source symtab if necessary */
- if (arg == 0 || arg[0] == 0) {
- if (current_source_symtab == 0)
- select_source_symtab(0);
- else
- printf("%s\n", current_source_symtab->filename);
- return;
- }
- arg1 = arg;
- sals = decode_line_1 (&arg1, 0, 0, 0);
-
- if (! sals.nelts)
- return; /* C++ */
-
- if (sals.nelts > 1)
- {
- ambiguous_line_spec (&sals);
- free (sals.sals);
- return;
- }
-
- sal = sals.sals[0];
- free (sals.sals);
-
- /* Record whether the BEG arg is all digits. */
-
- for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; ++p)
- ;
- linenum_beg = (p == arg1);
-
- /* if line was specified by address,
- print exactly which line, and which file.
- In this case, sal.symtab == 0 means address is outside
- of all known source files, not that user failed to give a filename. */
- if (*arg == '*')
- {
- if (sal.symtab == 0)
- error ("No source file for address 0x%x.", sal.pc);
- sym = find_pc_function (sal.pc);
- if (sym)
- printf ("0x%x is in %s (%s, line %d).\n",
- sal.pc, SYMBOL_NAME (sym), sal.symtab->filename, sal.line);
- else
- printf ("0x%x is in %s, line %d.\n",
- sal.pc, sal.symtab->filename, sal.line);
- }
-
- /* If line was not specified by just a line number,
- and it does not imply a symtab, it must be an undebuggable symbol
- which means no source code. */
-
- if (sal.symtab == 0)
- {
- if (! linenum_beg)
- error ("No line number known for %s.", arg);
- else
- error ("No default source file yet. Do \"help list\".");
- }
- else
- {
- current_source_symtab = sal.symtab;
- current_source_line = sal.line;
- first_line_listed = sal.line;
- }
-}
-
-#define PUSH_STACK_SIZE 32
-static struct {
- struct symtab *symtab;
- int line;
-} push_stack[PUSH_STACK_SIZE];
-
-static unsigned int push_stack_ptr;
-
-static void
-push_to_file_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- struct symtab *cursym = current_source_symtab;
- int curline = current_source_line;
- register unsigned int i;
-
- file_command(arg, from_tty);
-
- /* if we got back, command was successful */
- i = push_stack_ptr;
- push_stack[i].symtab = cursym;
- push_stack[i].line = curline;
- push_stack_ptr = (i + 1) & (PUSH_STACK_SIZE - 1);
-}
-
-static void
-pop_file_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- register unsigned int i = push_stack_ptr;
-
- /* if there's something on the stack, pop it & clear the slot. */
- i = (i + (PUSH_STACK_SIZE - 1)) & (PUSH_STACK_SIZE - 1);
- if (push_stack[i].symtab) {
- current_source_symtab = push_stack[i].symtab;
- first_line_listed = current_source_line = push_stack[i].line;
- push_stack[i].symtab = NULL;
- push_stack_ptr = i;
- }
-}
-
-
-static void
-list_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- struct symtabs_and_lines sals, sals_end;
- struct symtab_and_line sal, sal_end;
- struct symbol *sym;
- char *arg1;
- int no_end = 1;
- int dummy_end = 0;
- int dummy_beg = 0;
- int linenum_beg = 0;
- char *p;
-
- if (symtab_list == 0 && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
-
- /* Pull in a current source symtab if necessary */
- if (current_source_symtab == 0 &&
- (arg == 0 || arg[0] == '+' || arg[0] == '-'))
- select_source_symtab (0);
-
- /* "l" or "l +" lists next ten lines. */
-
- if (arg == 0 || !strcmp (arg, "+"))
- {
- if (current_source_symtab == 0)
- error ("No default source file yet. Do \"help list\".");
- print_source_lines (current_source_symtab, current_source_line,
- current_source_line + 10, 0);
- return;
- }
-
- /* "l -" lists previous ten lines, the ones before the ten just listed. */
- if (!strcmp (arg, "-"))
- {
- if (current_source_symtab == 0)
- error ("No default source file yet. Do \"help list\".");
- print_source_lines (current_source_symtab,
- max (first_line_listed - 10, 1),
- first_line_listed, 0);
- return;
- }
-
- /* Now if there is only one argument, decode it in SAL
- and set NO_END.
- If there are two arguments, decode them in SAL and SAL_END
- and clear NO_END; however, if one of the arguments is blank,
- set DUMMY_BEG or DUMMY_END to record that fact. */
-
- arg1 = arg;
- if (*arg1 == ',')
- dummy_beg = 1;
- else
- {
- sals = decode_line_1 (&arg1, 0, 0, 0);
-
- if (! sals.nelts) return; /* C++ */
- if (sals.nelts > 1)
- {
- ambiguous_line_spec (&sals);
- free (sals.sals);
- return;
- }
-
- sal = sals.sals[0];
- free (sals.sals);
- }
-
- /* Record whether the BEG arg is all digits. */
-
- for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; p++);
- linenum_beg = (p == arg1);
-
- while (*arg1 == ' ' || *arg1 == '\t')
- arg1++;
- if (*arg1 == ',')
- {
- no_end = 0;
- arg1++;
- while (*arg1 == ' ' || *arg1 == '\t')
- arg1++;
- if (*arg1 == 0)
- dummy_end = 1;
- else
- {
- if (dummy_beg)
- sals_end = decode_line_1 (&arg1, 0, 0, 0);
- else
- sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line);
- if (sals_end.nelts == 0)
- return;
- if (sals_end.nelts > 1)
- {
- ambiguous_line_spec (&sals_end);
- free (sals_end.sals);
- return;
- }
- sal_end = sals_end.sals[0];
- free (sals_end.sals);
- }
- }
-
- if (*arg1)
- error ("Junk at end of line specification.");
-
- if (!no_end && !dummy_beg && !dummy_end
- && sal.symtab != sal_end.symtab)
- error ("Specified start and end are in different files.");
- if (dummy_beg && dummy_end)
- error ("Two empty args do not say what lines to list.");
-
- /* if line was specified by address,
- first print exactly which line, and which file.
- In this case, sal.symtab == 0 means address is outside
- of all known source files, not that user failed to give a filename. */
- if (*arg == '*')
- {
- if (sal.symtab == 0)
- error ("No source file for address 0x%x.", sal.pc);
- sym = find_pc_function (sal.pc);
- if (sym)
- printf ("0x%x is in %s (%s, line %d).\n",
- sal.pc, SYMBOL_NAME (sym), sal.symtab->filename, sal.line);
- else
- printf ("0x%x is in %s, line %d.\n",
- sal.pc, sal.symtab->filename, sal.line);
- }
-
- /* If line was not specified by just a line number,
- and it does not imply a symtab, it must be an undebuggable symbol
- which means no source code. */
-
- if (! linenum_beg && sal.symtab == 0)
- error ("No line number known for %s.", arg);
-
- /* If this command is repeated with RET,
- turn it into the no-arg variant. */
-
- if (from_tty)
- *arg = 0;
-
- if (dummy_beg && sal_end.symtab == 0)
- error ("No default source file yet. Do \"help list\".");
- if (dummy_beg)
- print_source_lines (sal_end.symtab, max (sal_end.line - 9, 1),
- sal_end.line + 1, 0);
- else if (sal.symtab == 0)
- error ("No default source file yet. Do \"help list\".");
- else if (no_end)
- print_source_lines (sal.symtab, max (sal.line - 5, 1), sal.line + 5, 0);
- else
- print_source_lines (sal.symtab, sal.line,
- dummy_end ? sal.line + 10 : sal_end.line + 1,
- 0);
-}
-
-/* Print info on range of pc's in a specified line. */
-
-static void
-line_info (arg, from_tty)
- char *arg;
- int from_tty;
-{
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
- int start_pc, end_pc;
- int i;
-
- if (arg == 0)
- {
- sal.symtab = current_source_symtab;
- sal.line = last_line_listed;
- sals.nelts = 1;
- sals.sals = (struct symtab_and_line *)
- xmalloc (sizeof (struct symtab_and_line));
- sals.sals[0] = sal;
- }
- else
- {
- sals = decode_line_spec_1 (arg, 0);
-
- /* If this command is repeated with RET,
- turn it into the no-arg variant. */
- if (from_tty)
- *arg = 0;
- }
-
- /* C++ More than one line may have been specified, as when the user
- specifies an overloaded function name. Print info on them all. */
- for (i = 0; i < sals.nelts; i++)
- {
- sal = sals.sals[i];
-
- if (sal.symtab == 0)
- error ("No source file specified.");
-
- if (sal.line > 0
- && find_line_pc_range (sal.symtab, sal.line, &start_pc, &end_pc))
- {
- if (start_pc == end_pc)
- printf ("Line %d of \"%s\" is at pc 0x%x but contains no code.\n",
- sal.line, sal.symtab->filename, start_pc);
- else
- printf ("Line %d of \"%s\" starts at pc 0x%x and ends at 0x%x.\n",
- sal.line, sal.symtab->filename, start_pc, end_pc);
- /* x/i should display this line's code. */
- set_next_address (start_pc);
- /* Repeating "info line" should do the following line. */
- last_line_listed = sal.line + 1;
- }
- else
- printf ("Line number %d is out of range for \"%s\".\n",
- sal.line, sal.symtab->filename);
- }
-}
-
-/* Commands to search the source file for a regexp. */
-
-static void
-forward_search_command (regex, from_tty)
- char *regex;
-{
- register int c;
- register int desc;
- register FILE *stream;
- int line = last_line_listed + 1;
- char *msg;
-
- msg = (char *) re_comp (regex);
- if (msg)
- error (msg);
-
- if (current_source_symtab == 0)
- select_source_symtab (0);
-
- /* Search from last_line_listed+1 in current_source_symtab */
-
- desc = openp (source_path, 0, current_source_symtab->filename,
- O_RDONLY, 0, &current_source_symtab->fullname);
- if (desc < 0)
- perror_with_name (current_source_symtab->filename);
-
- if (current_source_symtab->line_charpos == 0)
- find_source_lines (current_source_symtab, desc);
-
- if (line < 1 || line > current_source_symtab->nlines)
- {
- close (desc);
- error ("Expression not found");
- }
-
- if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
- {
- close (desc);
- perror_with_name (current_source_symtab->filename);
- }
-
- stream = fdopen (desc, "r");
- clearerr (stream);
- while (1) {
- char buf[4096]; /* Should be reasonable??? */
- register char *p = buf;
-
- c = fgetc (stream);
- if (c == EOF)
- break;
- do {
- *p++ = c;
- } while (c != '\n' && (c = fgetc (stream)) >= 0);
-
- /* we now have a source line in buf, null terminate and match */
- *p = 0;
- if (re_exec (buf) > 0)
- {
- /* Match! */
- fclose (stream);
- print_source_lines (current_source_symtab,
- line, line+1, 0);
- current_source_line = max (line - 5, 1);
- return;
- }
- line++;
- }
-
- printf ("Expression not found\n");
- fclose (stream);
-}
-
-static void
-reverse_search_command (regex, from_tty)
- char *regex;
-{
- register int c;
- register int desc;
- register FILE *stream;
- int line = last_line_listed - 1;
- char *msg;
-
- msg = (char *) re_comp (regex);
- if (msg)
- error (msg);
-
- if (current_source_symtab == 0)
- select_source_symtab (0);
-
- /* Search from last_line_listed-1 in current_source_symtab */
-
- desc = openp (source_path, 0, current_source_symtab->filename,
- O_RDONLY, 0, &current_source_symtab->fullname);
- if (desc < 0)
- perror_with_name (current_source_symtab->filename);
-
- if (current_source_symtab->line_charpos == 0)
- find_source_lines (current_source_symtab, desc);
-
- if (line < 1 || line > current_source_symtab->nlines)
- {
- close (desc);
- error ("Expression not found");
- }
-
- if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
- {
- close (desc);
- perror_with_name (current_source_symtab->filename);
- }
-
- stream = fdopen (desc, "r");
- clearerr (stream);
- while (1)
- {
- char buf[4096]; /* Should be reasonable??? */
- register char *p = buf;
-
- c = fgetc (stream);
- if (c == EOF)
- break;
- do {
- *p++ = c;
- } while (c != '\n' && (c = fgetc (stream)) >= 0);
-
- /* We now have a source line in buf; null terminate and match. */
- *p = 0;
- if (re_exec (buf) > 0)
- {
- /* Match! */
- fclose (stream);
- print_source_lines (current_source_symtab,
- line, line+1, 0);
- current_source_line = max (line - 5, 1);
- return;
- }
- line--;
- if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0)
- {
- fclose (stream);
- perror_with_name (current_source_symtab->filename);
- }
- }
-
- printf ("Expression not found\n");
- fclose (stream);
- return;
-}
-
-void
-_initialize_source ()
-{
- current_source_symtab = 0;
- init_source_path ();
-
- add_com ("directory", class_files, directory_command,
- "Add directory DIR to end of search path for source files.\n\
-With no argument, reset the search path to just the working directory\n\
-and forget cached info on line positions in source files.");
-
- add_info ("directories", directories_info,
- "Current search path for finding source files.");
-
- add_info ("line", line_info,
- "Core addresses of the code for a source line.\n\
-Line can be specified as\n\
- LINENUM, to list around that line in current file,\n\
- FILE:LINENUM, to list around that line in that file,\n\
- FUNCTION, to list around beginning of that function,\n\
- FILE:FUNCTION, to distinguish among like-named static functions.\n\
-Default is to describe the last source line that was listed.\n\n\
-This sets the default address for \"x\" to the line's first instruction\n\
-so that \"x/i\" suffices to start examining the machine code.\n\
-The address is also stored as the value of \"$_\".");
-
- add_com ("forward-search", class_files, forward_search_command,
- "Search for regular expression (see regex(3)) from last line listed.");
- add_com_alias ("search", "forward-search", class_files, 0);
-
- add_com ("reverse-search", class_files, reverse_search_command,
- "Search backward for regular expression (see regex(3)) from last line listed.");
-
- add_com ("list", class_files, list_command,
- "List specified function or line.\n\
-With no argument, lists ten more lines after or around previous listing.\n\
-\"list -\" lists the ten lines before a previous ten-line listing.\n\
-One argument specifies a line, and ten lines are listed around that line.\n\
-Two arguments with comma between specify starting and ending lines to list.\n\
-Lines can be specified in these ways:\n\
- LINENUM, to list around that line in current file,\n\
- FILE:LINENUM, to list around that line in that file,\n\
- FUNCTION, to list around beginning of that function,\n\
- FILE:FUNCTION, to distinguish among like-named static functions.\n\
- *ADDRESS, to list around the line containing that address.\n\
-With two args if one is empty it stands for ten lines away from the other arg.");
- add_com ("file", class_files, file_command,
- "Select current file, function and line for display or list.\n\
-Specification can have the form:\n\
- LINENUM, to select that line in current file,\n\
- FILE:LINENUM, to select that line in that file,\n\
- FUNCTION, to select beginning of that function,\n\
- FILE:FUNCTION, to distinguish among like-named static functions.\n\
- *ADDRESS, to select the line containing that address.");
- add_com ("push-to-file", class_files, push_to_file_command,
- "Like \"file\" command but remembers current file & line on a stack.\n\
-Can later return to current file with \"pop-file\" command.\n\
-Up to 32 file positions can be pushed on stack.");
- add_com ("pop-file", class_files, pop_file_command,
- "Pops back to file position saved by most recent \"push-to-file\".\n\
-If everything has been popped from stack, command does nothing.");
-}
-
diff --git a/gnu/usr.bin/gdb/stab.def b/gnu/usr.bin/gdb/stab.def
deleted file mode 100644
index b81cda4..0000000
--- a/gnu/usr.bin/gdb/stab.def
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Table of DBX symbol codes for the GNU system.
- 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. */
-
-/* Global variable. Only the name is significant.
- To find the address, look in the corresponding external symbol. */
-__define_stab (N_GSYM, 0x20, "GSYM")
-
-/* Function name for BSD Fortran. Only the name is significant.
- To find the address, look in the corresponding external symbol. */
-__define_stab (N_FNAME, 0x22, "FNAME")
-
-/* Function name or text-segment variable for C. Value is its address.
- Desc is supposedly starting line number, but GCC doesn't set it
- and DBX seems not to miss it. */
-__define_stab (N_FUN, 0x24, "FUN")
-
-/* Data-segment variable with internal linkage. Value is its address. */
-__define_stab (N_STSYM, 0x26, "STSYM")
-
-/* BSS-segment variable with internal linkage. Value is its address. */
-__define_stab (N_LCSYM, 0x28, "LCSYM")
-
-/* Name of main routine. Only the name is significant.
- This is not used in C. */
-__define_stab (N_MAIN, 0x2a, "MAIN")
-
-/* Register variable. Value is number of register. */
-__define_stab (N_RSYM, 0x40, "RSYM")
-
-/* Structure or union element. Value is offset in the structure. */
-__define_stab (N_SSYM, 0x60, "SSYM")
-
-/* Parameter variable. Value is offset from argument pointer.
- (On most machines the argument pointer is the same as the frame pointer. */
-__define_stab (N_PSYM, 0xa0, "PSYM")
-
-/* Automatic variable in the stack. Value is offset from frame pointer.
- Also used for type descriptions. */
-__define_stab (N_LSYM, 0x80, "LSYM")
-
-/* Alternate entry point. Value is its address. */
-__define_stab (N_ENTRY, 0xa4, "ENTRY")
-
-/* Name of main source file.
- Value is starting text address of the compilation. */
-__define_stab (N_SO, 0x64, "SO")
-
-/* Name of sub-source file.
- Value is starting text address of the compilation. */
-__define_stab (N_SOL, 0x84, "SOL")
-
-/* Line number in text segment. Desc is the line number;
- value is corresponding address. */
-__define_stab (N_SLINE, 0x44, "SLINE")
-/* Similar, for data segment. */
-__define_stab (N_DSLINE, 0x46, "DSLINE")
-/* Similar, for bss segment. */
-__define_stab (N_BSLINE, 0x48, "BSLINE")
-
-/* Beginning of an include file. Only Sun uses this.
- In an object file, only the name is significant.
- The Sun linker puts data into some of the other fields. */
-__define_stab (N_BINCL, 0x82, "BINCL")
-/* End of an include file. No name.
- These two act as brackets around the file's output.
- In an object file, there is no significant data in this entry.
- The Sun linker puts data into some of the fields. */
-__define_stab (N_EINCL, 0xa2, "EINCL")
-/* Place holder for deleted include file.
- This appears only in output from the Sun linker. */
-__define_stab (N_EXCL, 0xc2, "EXCL")
-
-/* Beginning of lexical block.
- The desc is the nesting level in lexical blocks.
- The value is the address of the start of the text for the block.
- The variables declared inside the block *precede* the N_LBRAC symbol. */
-__define_stab (N_LBRAC, 0xc0, "LBRAC")
-/* End of a lexical block. Desc matches the N_LBRAC's desc.
- The value is the address of the end of the text for the block. */
-__define_stab (N_RBRAC, 0xe0, "RBRAC")
-
-/* Begin named common block. Only the name is significant. */
-__define_stab (N_BCOMM, 0xe2, "BCOMM")
-/* Begin named common block. Only the name is significant
- (and it should match the N_BCOMM). */
-__define_stab (N_ECOMM, 0xe4, "ECOMM")
-/* End common (local name): value is address.
- I'm not sure how this is used. */
-__define_stab (N_ECOML, 0xe8, "ECOML")
-/* Second symbol entry containing a length-value for the preceding entry.
- The value is the length. */
-__define_stab (N_LENG, 0xfe, "LENG")
-
-/* Global symbol in Pascal.
- Supposedly the value is its line number; I'm skeptical. */
-__define_stab (N_PC, 0x30, "PC")
-
-/* Modula-2 compilation unit. Can someone say what info it contains? */
-__define_stab (N_M2C, 0x42, "M2C")
-/* Modula-2 scope information. Can someone say what info it contains? */
-__define_stab (N_SCOPE, 0xc4, "SCOPE")
diff --git a/gnu/usr.bin/gdb/stack.c b/gnu/usr.bin/gdb/stack.c
deleted file mode 100644
index 91218aa..0000000
--- a/gnu/usr.bin/gdb/stack.c
+++ /dev/null
@@ -1,960 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)stack.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Print and select stack frames 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. */
-
-/* modified by rjc Thu Nov 1 16:46:57 1990, fixed return_command so that
- it can return values, it still has problems when running on pmax,
- cannot write register 65 */
-
-#include <stdio.h>
-
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-#include "value.h"
-
-
-/* Thie "selected" stack frame is used by default for local and arg access.
- May be zero, for no selected frame. */
-
-FRAME selected_frame;
-
-/* Level of the selected frame:
- 0 for innermost, 1 for its caller, ...
- or -1 for frame specified by address with no defined level. */
-
-int selected_frame_level;
-
-/* Nonzero means print the full filename and linenumber
- when a frame is printed, and do so in a format programs can parse. */
-
-int frame_file_full_name = 0;
-
-static void select_calling_frame ();
-
-void print_frame_info ();
-
-/* Print a stack frame briefly. FRAME should be the frame id
- and LEVEL should be its level in the stack (or -1 for level not defined).
- This prints the level, the function executing, the arguments,
- and the file name and line number.
- If the pc is not at the beginning of the source line,
- the actual pc is printed at the beginning.
-
- If SOURCE is 1, print the source line as well.
- If SOURCE is -1, print ONLY the source line. */
-
-static void
-print_stack_frame (frame, level, source)
- FRAME frame;
- int level;
- int source;
-{
- struct frame_info *fi;
-
- fi = get_frame_info (frame);
-
- print_frame_info (fi, level, source, 1);
-}
-
-/* Flag which will indicate when the frame has been changed
- by and "up" or "down" command. */
-static int frame_changed;
-
-void
-print_frame_info (fi, level, source, args)
- struct frame_info *fi;
- register int level;
- int source;
- int args;
-{
- struct symtab_and_line sal;
- struct symbol *func;
- register char *funname = 0;
- int numargs;
- struct partial_symtab *pst;
-
- /* Don't give very much information if we haven't readin the
- symbol table yet. */
- pst = find_pc_psymtab (fi->pc);
- if (pst && !pst->readin)
- {
- /* Abbreviated information. */
- char *fname;
-
- if (!find_pc_partial_function (fi->pc, &fname, 0))
- fname = "??";
-
- printf_filtered ("#%-2d ", level);
- printf_filtered ("0x%x in ", fi->pc);
-
- fputs_demangled(fname, stdout, -1);
- fputs_filtered(" (...)\n", stdout);
-
- return;
- }
-
- sal = find_pc_line (fi->pc, fi->next_frame);
- func = find_pc_function (fi->pc);
- if (func)
- {
- /* In certain pathological cases, the symtabs give the wrong
- function (when we are in the first function in a file which
- is compiled without debugging symbols, the previous function
- is compiled with debugging symbols, and the "foo.o" symbol
- that is supposed to tell us where the file with debugging symbols
- ends has been truncated by ar because it is longer than 15
- characters).
-
- So look in the misc_function_vector as well, and if it comes
- up with a larger address for the function use that instead.
- I don't think this can ever cause any problems;
- there shouldn't be any
- misc_function_vector symbols in the middle of a function. */
- int misc_index = find_pc_misc_function (fi->pc);
- if (misc_index >= 0
- && (misc_function_vector[misc_index].address
- > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
- {
- /* In this case we have no way of knowing the source file
- and line number, so don't print them. */
- sal.symtab = 0;
- /* We also don't know anything about the function besides
- its address and name. */
- func = 0;
- funname = misc_function_vector[misc_index].name;
- }
- else
- funname = SYMBOL_NAME (func);
- }
- else
- {
- register int misc_index = find_pc_misc_function (fi->pc);
- if (misc_index >= 0)
- funname = misc_function_vector[misc_index].name;
- }
-
- if (frame_changed || source >= 0 || !sal.symtab)
- {
- if (level >= 0)
- printf_filtered ("#%-2d ", level);
- else if (frame_changed)
- printf ("#%-2d ", 0);
- if (fi->pc != sal.pc || !sal.symtab)
- printf_filtered ("0x%x in ", fi->pc);
- fputs_demangled(funname ? funname : "??", stdout, -1);
- printf_filtered(" (");
- if (args)
- {
- if (func)
- numargs = -1;
- else
- FRAME_NUM_ARGS (numargs, fi);
-
- print_frame_args (func, fi, numargs, stdout);
- }
- printf_filtered (")");
- if (sal.symtab)
- printf_filtered (" (%s line %d)", sal.symtab->filename, sal.line);
- printf_filtered ("\n");
- }
-
- if ((frame_changed || source != 0) && sal.symtab)
- {
- int done = 0;
- int mid_statement = source < 0 && fi->pc != sal.pc;
- if (frame_file_full_name)
- done = identify_source_line (sal.symtab, sal.line, mid_statement);
- if (!done)
- {
- if (mid_statement)
- printf_filtered ("0x%x\t", fi->pc);
- print_source_lines (sal.symtab, sal.line, sal.line + 1, 1);
- }
- current_source_line = max (sal.line - 5, 1);
- }
- frame_changed = 0;
- if (source != 0)
- set_default_breakpoint (1, fi->pc, sal.symtab, sal.line);
-
- fflush (stdout);
-}
-
-/* Call here to print info on selected frame, after a trap. */
-
-void
-print_sel_frame (just_source)
- int just_source;
-{
- print_stack_frame (selected_frame, -1, just_source ? -1 : 1);
-}
-
-/* Print info on the selected frame, including level number
- but not source. */
-
-void
-print_selected_frame ()
-{
- print_stack_frame (selected_frame, selected_frame_level, 0);
-}
-
-void flush_cached_frames ();
-
-#ifdef FRAME_SPECIFICATION_DYADIC
-extern FRAME setup_arbitrary_frame ();
-#endif
-
-/*
- * Read a frame specification in whatever the appropriate format is.
- */
-static FRAME
-parse_frame_specification (frame_exp)
- char *frame_exp;
-{
- int numargs = 0;
- int arg1, arg2;
-
- if (frame_exp)
- {
- char *addr_string, *p;
- struct cleanup *tmp_cleanup;
- struct frame_info *fci;
-
- while (*frame_exp == ' ') frame_exp++;
- for (p = frame_exp; *p && *p != ' '; p++)
- ;
-
- if (*frame_exp)
- {
- numargs = 1;
- addr_string = savestring(frame_exp, p - frame_exp);
-
- {
- tmp_cleanup = make_cleanup (free, addr_string);
- arg1 = parse_and_eval_address (addr_string);
- do_cleanups (tmp_cleanup);
- }
-
- while (*p == ' ') p++;
-
- if (*p)
- {
- numargs = 2;
- arg2 = parse_and_eval_address (p);
- }
- }
- }
-
- switch (numargs)
- {
- case 0:
- return selected_frame;
- /* NOTREACHED */
- case 1:
- {
- int level = arg1;
- FRAME fid = find_relative_frame (get_current_frame (), &level);
- FRAME tfid;
-
- if (level == 0)
- /* find_relative_frame was successful */
- return fid;
-
- /* If (s)he specifies the frame with an address, he deserves what
- (s)he gets. Still, give the highest one that matches. */
-
- for (fid = get_current_frame ();
- fid && FRAME_FP (fid) != arg1;
- fid = get_prev_frame (fid))
- ;
-
- if (fid)
- while ((tfid = get_prev_frame (fid)) &&
- (FRAME_FP (tfid) == arg1))
- fid = tfid;
-
-#ifdef FRAME_SPECIFICATION_DYADIC
- if (!fid)
- error ("Incorrect number of args in frame specification");
-
- return fid;
-#else
- return create_new_frame (arg1, 0);
-#endif
- }
- /* NOTREACHED */
- case 2:
- /* Must be addresses */
-#ifndef FRAME_SPECIFICATION_DYADIC
- error ("Incorrect number of args in frame specification");
-#else
- return setup_arbitrary_frame (arg1, arg2);
-#endif
- /* NOTREACHED */
- }
- fatal ("Internal: Error in parsing in parse_frame_specification");
- /* NOTREACHED */
-}
-
-/* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except
- that if it is unsure about the answer, it returns Frame_unknown
- instead of guessing (this happens on the VAX, for example).
-
- On most machines, we never have to guess about the args address,
- so FRAME_ARGS_ADDRESS{,_CORRECT} are the same. */
-#if !defined (FRAME_ARGS_ADDRESS_CORRECT)
-#define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS
-#endif
-
-/* Print verbosely the selected frame or the frame at address ADDR.
- This means absolutely all information in the frame is printed. */
-
-static void
-frame_info (addr_exp)
- char *addr_exp;
-{
- FRAME frame;
- struct frame_info *fi;
- struct frame_saved_regs fsr;
- struct symtab_and_line sal;
- struct symbol *func;
- FRAME calling_frame;
- int i, count;
- char *funname = 0;
-
- if (!(have_inferior_p () || have_core_file_p ()))
- error ("No inferior or core file.");
-
- frame = parse_frame_specification (addr_exp);
- if (!frame)
- error ("Invalid frame specified.");
-
- fi = get_frame_info (frame);
- get_frame_saved_regs (fi, &fsr);
- sal = find_pc_line (fi->pc, fi->next_frame);
- func = get_frame_function (frame);
- if (func)
- funname = SYMBOL_NAME (func);
- else
- {
- register int misc_index = find_pc_misc_function (fi->pc);
- if (misc_index >= 0)
- funname = misc_function_vector[misc_index].name;
- }
- calling_frame = get_prev_frame (frame);
-
- if (!addr_exp && selected_frame_level >= 0)
- printf ("Stack level %d, frame at 0x%x:\n pc = 0x%x",
- selected_frame_level, FRAME_FP(frame), fi->pc);
- else
- printf ("Stack frame at 0x%x:\n pc = 0x%x",
- FRAME_FP(frame), fi->pc);
-
- if (funname)
- printf (" in %s", funname);
- if (sal.symtab)
- printf (" (%s line %d)", sal.symtab->filename, sal.line);
- printf ("; saved pc 0x%x\n", FRAME_SAVED_PC (frame));
- if (calling_frame)
- printf (" called by frame at 0x%x", FRAME_FP (calling_frame));
- if (fi->next_frame && calling_frame)
- printf (",");
- if (fi->next_frame)
- printf (" caller of frame at 0x%x", fi->next_frame);
- if (fi->next_frame || calling_frame)
- printf ("\n");
-
- {
- /* Address of the argument list for this frame, or Frame_unknown. */
- CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi);
- /* Number of args for this frame, or -1 if unknown. */
- int numargs;
-
- if (arg_list != Frame_unknown)
- {
- printf (" Arglist at 0x%x,", arg_list);
-
- FRAME_NUM_ARGS (numargs, fi);
- if (numargs < 0)
- printf (" args: ");
- else if (numargs == 0)
- printf (" no args.");
- else if (numargs == 1)
- printf (" 1 arg: ");
- else
- printf (" %d args: ", numargs);
- print_frame_args (func, fi, numargs, stdout);
- printf ("\n");
- }
- }
-
- /* The sp is special; what's returned isn't the save address, but
- actually the value of the previous frame's sp. */
- printf (" Previous frame's sp is 0x%x\n", fsr.regs[SP_REGNUM]);
- count = 0;
- for (i = 0; i < NUM_REGS; i++)
- if (fsr.regs[i] && i != SP_REGNUM)
- {
- if (count % 4 != 0)
- printf (", ");
- else
- {
- if (count == 0)
- printf (" Saved registers:");
- printf ("\n ");
- }
- printf ("%s at 0x%x", reg_names[i], fsr.regs[i]);
- count++;
- }
- if (count)
- printf ("\n");
-}
-
-#if 0
-/* Set a limit on the number of frames printed by default in a
- backtrace. */
-
-static int backtrace_limit;
-
-static void
-set_backtrace_limit_command (count_exp, from_tty)
- char *count_exp;
- int from_tty;
-{
- int count = parse_and_eval_address (count_exp);
-
- if (count < 0)
- error ("Negative argument not meaningful as backtrace limit.");
-
- backtrace_limit = count;
-}
-
-static void
-backtrace_limit_info (arg, from_tty)
- char *arg;
- int from_tty;
-{
- if (arg)
- error ("\"Info backtrace-limit\" takes no arguments.");
-
- printf ("Backtrace limit: %d.\n", backtrace_limit);
-}
-#endif
-
-/* Print briefly all stack frames or just the innermost COUNT frames. */
-
-static void
-backtrace_command (count_exp)
- char *count_exp;
-{
- struct frame_info *fi;
- register int count;
- register FRAME frame;
- register int i;
- register FRAME trailing;
- register int trailing_level;
-
- /* The following code must do two things. First, it must
- set the variable TRAILING to the frame from which we should start
- printing. Second, it must set the variable count to the number
- of frames which we should print, or -1 if all of them. */
- trailing = get_current_frame ();
- trailing_level = 0;
- if (count_exp)
- {
- count = parse_and_eval_address (count_exp);
- if (count < 0)
- {
- FRAME current;
-
- count = -count;
-
- current = trailing;
- while (current && count--)
- current = get_prev_frame (current);
-
- /* Will stop when CURRENT reaches the top of the stack. TRAILING
- will be COUNT below it. */
- while (current)
- {
- trailing = get_prev_frame (trailing);
- current = get_prev_frame (current);
- trailing_level++;
- }
-
- count = -1;
- }
- }
- else
- count = -1;
-
- for (i = 0, frame = trailing;
- frame && count--;
- i++, frame = get_prev_frame (frame))
- {
- QUIT;
- fi = get_frame_info (frame);
- print_frame_info (fi, trailing_level + i, 0, 1);
- }
-
- /* If we've stopped before the end, mention that. */
- if (frame)
- printf_filtered ("(More stack frames follow...)\n");
-}
-
-/* Print the local variables of a block B active in FRAME.
- Return 1 if any variables were printed; 0 otherwise. */
-
-static int
-print_block_frame_locals (b, frame, stream)
- struct block *b;
- register FRAME frame;
- register FILE *stream;
-{
- int nsyms;
- register int i;
- register struct symbol *sym;
- register int values_printed = 0;
-
- nsyms = BLOCK_NSYMS (b);
-
- for (i = 0; i < nsyms; i++)
- {
- sym = BLOCK_SYM (b, i);
- if (SYMBOL_CLASS (sym) == LOC_LOCAL
- || SYMBOL_CLASS (sym) == LOC_REGISTER
- || SYMBOL_CLASS (sym) == LOC_STATIC)
- {
- values_printed = 1;
- fputs_filtered (SYMBOL_NAME (sym), stream);
- fputs_filtered (" = ", stream);
- print_variable_value (sym, frame, stream);
- fprintf_filtered (stream, "\n");
- fflush (stream);
- }
- }
- return values_printed;
-}
-
-/* Print on STREAM all the local variables in frame FRAME,
- including all the blocks active in that frame
- at its current pc.
-
- Returns 1 if the job was done,
- or 0 if nothing was printed because we have no info
- on the function running in FRAME. */
-
-static int
-print_frame_local_vars (frame, stream)
- register FRAME frame;
- register FILE *stream;
-{
- register struct block *block = get_frame_block (frame);
- register int values_printed = 0;
-
- if (block == 0)
- {
- fprintf_filtered (stream, "No symbol table info available.\n");
- fflush (stream);
- return 0;
- }
-
- while (block != 0)
- {
- if (print_block_frame_locals (block, frame, stream))
- values_printed = 1;
- /* After handling the function's top-level block, stop.
- Don't continue to its superblock, the block of
- per-file symbols. */
- if (BLOCK_FUNCTION (block))
- break;
- block = BLOCK_SUPERBLOCK (block);
- }
-
- if (!values_printed)
- {
- fprintf_filtered (stream, "No locals.\n");
- fflush (stream);
- }
-
- return 1;
-}
-
-static void
-locals_info ()
-{
- if (!have_inferior_p () && !have_core_file_p ())
- error ("No inferior or core file.");
-
- print_frame_local_vars (selected_frame, stdout);
-}
-
-static int
-print_frame_arg_vars (frame, stream)
- register FRAME frame;
- register FILE *stream;
-{
- struct symbol *func = get_frame_function (frame);
- register struct block *b;
- int nsyms;
- register int i;
- register struct symbol *sym;
- register int values_printed = 0;
-
- if (func == 0)
- {
- fprintf_filtered (stream, "No symbol table info available.\n");
- fflush (stream);
- return 0;
- }
-
- b = SYMBOL_BLOCK_VALUE (func);
- nsyms = BLOCK_NSYMS (b);
-
- for (i = 0; i < nsyms; i++)
- {
- sym = BLOCK_SYM (b, i);
- if (SYMBOL_CLASS (sym) == LOC_ARG
- || SYMBOL_CLASS (sym) == LOC_REF_ARG
- || SYMBOL_CLASS (sym) == LOC_REGPARM)
- {
- values_printed = 1;
- fputs_filtered (SYMBOL_NAME (sym), stream);
- fputs_filtered (" = ", stream);
- print_variable_value (sym, frame, stream);
- fprintf_filtered (stream, "\n");
- fflush (stream);
- }
- }
-
- if (!values_printed)
- {
- fprintf_filtered (stream, "No arguments.\n");
- fflush (stream);
- }
-
- return 1;
-}
-
-static void
-args_info ()
-{
- if (!have_inferior_p () && !have_core_file_p ())
- error ("No inferior or core file.");
- print_frame_arg_vars (selected_frame, stdout);
-}
-
-/* Select frame FRAME, and note that its stack level is LEVEL.
- LEVEL may be -1 if an actual level number is not known. */
-
-void
-select_frame (frame, level)
- FRAME frame;
- int level;
-{
- selected_frame = frame;
- selected_frame_level = level;
- /* Ensure that symbols for this frame are readin. */
- if (frame)
- find_pc_symtab (get_frame_info (frame)->pc);
-}
-
-/* Store the selected frame and its level into *FRAMEP and *LEVELP. */
-
-void
-record_selected_frame (frameaddrp, levelp)
- FRAME_ADDR *frameaddrp;
- int *levelp;
-{
- *frameaddrp = FRAME_FP (selected_frame);
- *levelp = selected_frame_level;
-}
-
-/* Return the symbol-block in which the selected frame is executing.
- Can return zero under various legitimate circumstances. */
-
-struct block *
-get_selected_block ()
-{
- if (!have_inferior_p () && !have_core_file_p ())
- return 0;
-
- if (!selected_frame)
- return get_current_block ();
- return get_frame_block (selected_frame);
-}
-
-/* Find a frame a certain number of levels away from FRAME.
- LEVEL_OFFSET_PTR points to an int containing the number of levels.
- Positive means go to earlier frames (up); negative, the reverse.
- The int that contains the number of levels is counted toward
- zero as the frames for those levels are found.
- If the top or bottom frame is reached, that frame is returned,
- but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
- how much farther the original request asked to go. */
-
-FRAME
-find_relative_frame (frame, level_offset_ptr)
- register FRAME frame;
- register int* level_offset_ptr;
-{
- register FRAME prev;
- register FRAME frame1, frame2;
-
- /* Going up is simple: just do get_prev_frame enough times
- or until initial frame is reached. */
- while (*level_offset_ptr > 0)
- {
- prev = get_prev_frame (frame);
- if (prev == 0)
- break;
- (*level_offset_ptr)--;
- frame = prev;
- }
- /* Going down could be done by iterating get_frame_info to
- find the next frame, but that would be quadratic
- since get_frame_info must scan all the way from the current frame.
- The following algorithm is linear. */
- if (*level_offset_ptr < 0)
- {
- /* First put frame1 at innermost frame
- and frame2 N levels up from there. */
- frame1 = get_current_frame ();
- frame2 = frame1;
- while (*level_offset_ptr < 0 && frame2 != frame)
- {
- frame2 = get_prev_frame (frame2);
- (*level_offset_ptr) ++;
- }
- /* Then slide frame1 and frame2 up in synchrony
- and when frame2 reaches our starting point
- frame1 must be N levels down from there. */
- while (frame2 != frame)
- {
- frame1 = get_prev_frame (frame1);
- frame2 = get_prev_frame (frame2);
- }
- return frame1;
- }
- return frame;
-}
-
-/* The "frame" command. With no arg, print selected frame briefly.
- With arg LEVEL_EXP, select the frame at level LEVEL if it is a
- valid level. Otherwise, treat level_exp as an address expression
- and print it. See parse_frame_specification for more info on proper
- frame expressions. */
-
-static void
-frame_command (level_exp, from_tty)
- char *level_exp;
- int from_tty;
-{
- register FRAME frame, frame1;
- unsigned int level = 0;
-
- if (!have_inferior_p () && ! have_core_file_p ())
- error ("No inferior or core file.");
-
- frame = parse_frame_specification (level_exp);
-
- for (frame1 = get_prev_frame (0);
- frame1 && frame1 != frame;
- frame1 = get_prev_frame (frame1))
- level++;
-
- if (!frame1)
- level = 0;
-
- frame_changed = level;
- select_frame (frame, level);
-
- if (!from_tty)
- return;
-
- print_stack_frame (selected_frame, selected_frame_level, 1);
-}
-
-/* Select the frame up one or COUNT stack levels
- from the previously selected frame, and print it briefly. */
-
-static void
-up_command (count_exp)
- char *count_exp;
-{
- register FRAME frame;
- int count = 1, count1;
- if (count_exp)
- count = parse_and_eval_address (count_exp);
- count1 = count;
-
- if (!have_inferior_p () && !have_core_file_p ())
- error ("No inferior or core file.");
-
- frame = find_relative_frame (selected_frame, &count1);
- if (count1 != 0 && count_exp == 0)
- error ("Initial frame selected; you cannot go up.");
- select_frame (frame, selected_frame_level + count - count1);
-
- print_stack_frame (selected_frame, selected_frame_level, 1);
- frame_changed++;
-}
-
-/* Select the frame down one or COUNT stack levels
- from the previously selected frame, and print it briefly. */
-
-static void
-down_command (count_exp)
- char *count_exp;
-{
- register FRAME frame;
- int count = -1, count1;
- if (count_exp)
- count = - parse_and_eval_address (count_exp);
- count1 = count;
-
- frame = find_relative_frame (selected_frame, &count1);
- if (count1 != 0 && count_exp == 0)
- error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
- select_frame (frame, selected_frame_level + count - count1);
-
- print_stack_frame (selected_frame, selected_frame_level, 1);
- frame_changed--;
-}
-
-static void
-return_command (retval_exp, from_tty)
- char *retval_exp;
- int from_tty;
-{
- value return_value;
- struct symbol *thisfun = get_frame_function (selected_frame);
- FRAME_ADDR selected_frame_addr = FRAME_FP (selected_frame);
-
- /* If interactive, require confirmation. */
-
- if (from_tty)
- {
- if (thisfun != 0)
- {
- if (!query ("Make %s return now? ", SYMBOL_NAME (thisfun)))
- error ("Not confirmed.");
- }
- else
- if (!query ("Make selected stack frame return now? "))
- error ("Not confirmed.");
- }
-
- /* Do the real work. Pop until the specified frame is current. We
- use this method because the selected_frame is not valid after
- a POP_FRAME. Note that this will not work if the selected frame
- shares it's fp with another frame. */
-
- while (selected_frame_addr != FRAME_FP (get_current_frame()))
- POP_FRAME;
-
- /* get the return value while still in this frame */
- if (retval_exp)
- return_value = parse_and_eval (retval_exp);
-
- /* Then pop that frame. */
- POP_FRAME;
-
- /* Store the return value if there was one */
-
- if (retval_exp)
- set_return_value (return_value);
-
- /* If interactive, print the frame that is now current. */
-
- if (from_tty)
- frame_command ("0", 1);
-}
-
-extern struct cmd_list_element *setlist;
-
-void
-_initialize_stack ()
-{
-#if 0
- backtrace_limit = 30;
-#endif
-
- add_com ("return", class_stack, return_command,
- "Make selected stack frame return to its caller.\n\
-Control remains in the debugger, but when you continue\n\
-execution will resume in the frame above the one now selected.\n\
-If an argument is given, it is an expression for the value to return.");
-
- add_com ("up", class_stack, up_command,
- "Select and print stack frame that called this one.\n\
-An argument says how many frames up to go.");
-
- add_com ("down", class_stack, down_command,
- "Select and print stack frame called by this one.\n\
-An argument says how many frames down to go.");
- add_com_alias ("do", "down", class_stack, 1);
-
- add_com ("frame", class_stack, frame_command,
- "Select and print a stack frame.\n\
-With no argument, print the selected stack frame. (See also \"info frame\").\n\
-An argument specifies the frame to select.\n\
-It can be a stack frame number or the address of the frame.\n\
-With argument, nothing is printed if input is coming from\n\
-a command file or a user-defined command.");
-
- add_com_alias ("f", "frame", class_stack, 1);
-
- add_com ("backtrace", class_stack, backtrace_command,
- "Print backtrace of all stack frames, or innermost COUNT frames.\n\
-With a negative argument, print outermost -COUNT frames.");
- add_com_alias ("bt", "backtrace", class_stack, 0);
- add_com_alias ("where", "backtrace", class_alias, 0);
- add_info ("stack", backtrace_command,
- "Backtrace of the stack, or innermost COUNT frames.");
- add_info_alias ("s", "stack", 1);
- add_info ("frame", frame_info,
- "All about selected stack frame, or frame at ADDR.");
- add_info_alias ("f", "frame", 1);
- add_info ("locals", locals_info,
- "Local variables of current stack frame.");
- add_info ("args", args_info,
- "Argument variables of current stack frame.");
-
-#if 0
- add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command,
- "Specify maximum number of frames for \"backtrace\" to print by default.",
- &setlist);
- add_info ("backtrace-limit", backtrace_limit_info,
- "The maximum number of frames for \"backtrace\" to print by default.");
-#endif
-}
-
diff --git a/gnu/usr.bin/gdb/symmisc.c b/gnu/usr.bin/gdb/symmisc.c
deleted file mode 100644
index bb4eb50..0000000
--- a/gnu/usr.bin/gdb/symmisc.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/* Do various things to symbol tables (other than lookup)), for GDB.
- 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. */
-
-
-#include "defs.h"
-#include "symtab.h"
-
-#include <stdio.h>
-#include <obstack.h>
-
-static void free_symtab ();
-
-
-/* Free all the symtabs that are currently installed,
- and all storage associated with them.
- Leaves us in a consistent state with no symtabs installed. */
-
-void
-free_all_symtabs ()
-{
- register struct symtab *s, *snext;
-
- /* All values will be invalid because their types will be! */
-
- clear_value_history ();
- clear_displays ();
- clear_internalvars ();
- clear_breakpoints ();
- set_default_breakpoint (0, 0, 0, 0);
-
- current_source_symtab = 0;
-
- for (s = symtab_list; s; s = snext)
- {
- snext = s->next;
- free_symtab (s);
- }
- symtab_list = 0;
- obstack_free (symbol_obstack, 0);
- obstack_init (symbol_obstack);
-
- if (misc_function_vector)
- free (misc_function_vector);
- misc_function_count = 0;
- misc_function_vector = 0;
-}
-
-/* Free a struct block <- B and all the symbols defined in that block. */
-
-static void
-free_symtab_block (b)
- struct block *b;
-{
- register int i, n;
- n = BLOCK_NSYMS (b);
- for (i = 0; i < n; i++)
- {
- free (SYMBOL_NAME (BLOCK_SYM (b, i)));
- free (BLOCK_SYM (b, i));
- }
- free (b);
-}
-
-/* Free all the storage associated with the struct symtab <- S.
- Note that some symtabs have contents malloc'ed structure by structure,
- while some have contents that all live inside one big block of memory,
- and some share the contents of another symbol table and so you should
- not free the contents on their behalf (except sometimes the linetable,
- which maybe per symtab even when the rest is not).
- It is s->free_code that says which alternative to use. */
-
-static void
-free_symtab (s)
- register struct symtab *s;
-{
- register int i, n;
- register struct blockvector *bv;
- register struct type *type;
- register struct typevector *tv;
-
- switch (s->free_code)
- {
- case free_nothing:
- /* All the contents are part of a big block of memory
- and some other symtab is in charge of freeing that block.
- Therefore, do nothing. */
- break;
-
- case free_contents:
- /* Here all the contents were malloc'ed structure by structure
- and must be freed that way. */
- /* First free the blocks (and their symbols. */
- bv = BLOCKVECTOR (s);
- n = BLOCKVECTOR_NBLOCKS (bv);
- for (i = 0; i < n; i++)
- free_symtab_block (BLOCKVECTOR_BLOCK (bv, i));
- /* Free the blockvector itself. */
- free (bv);
- /* Free the type vector. */
- tv = TYPEVECTOR (s);
- free (tv);
- /* Also free the linetable. */
-
- case free_linetable:
- /* Everything will be freed either by our `free_ptr'
- or by some other symbatb, except for our linetable.
- Free that now. */
- free (LINETABLE (s));
- break;
- }
-
- /* If there is a single block of memory to free, free it. */
- if (s->free_ptr)
- free (s->free_ptr);
-
- if (s->line_charpos)
- free (s->line_charpos);
- free (s->filename);
- free (s);
-}
-
-/* Convert a raw symbol-segment to a struct symtab,
- and relocate its internal pointers so that it is valid. */
-
-/* This is how to relocate one pointer, given a name for it.
- Works independent of the type of object pointed to. */
-#define RELOCATE(slot) (slot ? (* (char **) &slot += relocation) : 0)
-
-/* This is the inverse of RELOCATE. We use it when storing
- a core address into a slot that has yet to be relocated. */
-#define UNRELOCATE(slot) (slot ? (* (char **) &slot -= relocation) : 0)
-
-/* During the process of relocation, this holds the amount to relocate by
- (the address of the file's symtab data, in core in the debugger). */
-static int relocation;
-
-#define CORE_RELOCATE(slot) \
- ((slot) += (((slot) < data_start) ? text_relocation \
- : ((slot) < bss_start) ? data_relocation : bss_relocation))
-
-#define TEXT_RELOCATE(slot) ((slot) += text_relocation)
-
-/* Relocation amounts for addresses in the program's core image. */
-static int text_relocation, data_relocation, bss_relocation;
-
-/* Boundaries that divide program core addresses into text, data and bss;
- used to determine which relocation amount to use. */
-static int data_start, bss_start;
-
-static void relocate_typevector ();
-static void relocate_blockvector ();
-static void relocate_type ();
-static void relocate_block ();
-static void relocate_symbol ();
-static void relocate_source ();
-
-/* Relocate a file's symseg so that all the pointers are valid C pointers.
- Value is a `struct symtab'; but it is not suitable for direct
- insertion into the `symtab_list' because it describes several files. */
-
-static struct symtab *
-relocate_symtab (root)
- struct symbol_root *root;
-{
- struct symtab *sp = (struct symtab *) xmalloc (sizeof (struct symtab));
- bzero (sp, sizeof (struct symtab));
-
- relocation = (int) root;
- text_relocation = root->textrel;
- data_relocation = root->datarel;
- bss_relocation = root->bssrel;
- data_start = root->databeg;
- bss_start = root->bssbeg;
-
- sp->filename = root->filename;
- sp->ldsymoff = root->ldsymoff;
- sp->language = root->language;
- sp->compilation = root->compilation;
- sp->version = root->version;
- sp->blockvector = root->blockvector;
- sp->typevector = root->typevector;
-
- RELOCATE (TYPEVECTOR (sp));
- RELOCATE (BLOCKVECTOR (sp));
- RELOCATE (sp->version);
- RELOCATE (sp->compilation);
- RELOCATE (sp->filename);
-
- relocate_typevector (TYPEVECTOR (sp));
- relocate_blockvector (BLOCKVECTOR (sp));
-
- return sp;
-}
-
-static void
-relocate_blockvector (blp)
- register struct blockvector *blp;
-{
- register int nblocks = BLOCKVECTOR_NBLOCKS (blp);
- register int i;
- for (i = 0; i < nblocks; i++)
- RELOCATE (BLOCKVECTOR_BLOCK (blp, i));
- for (i = 0; i < nblocks; i++)
- relocate_block (BLOCKVECTOR_BLOCK (blp, i));
-}
-
-static void
-relocate_block (bp)
- register struct block *bp;
-{
- register int nsyms = BLOCK_NSYMS (bp);
- register int i;
-
- TEXT_RELOCATE (BLOCK_START (bp));
- TEXT_RELOCATE (BLOCK_END (bp));
-
- /* These two should not be recursively processed.
- The superblock need not be because all blocks are
- processed from relocate_blockvector.
- The function need not be because it will be processed
- under the block which is its scope. */
- RELOCATE (BLOCK_SUPERBLOCK (bp));
- RELOCATE (BLOCK_FUNCTION (bp));
-
- for (i = 0; i < nsyms; i++)
- RELOCATE (BLOCK_SYM (bp, i));
-
- for (i = 0; i < nsyms; i++)
- relocate_symbol (BLOCK_SYM (bp, i));
-}
-
-static void
-relocate_symbol (sp)
- register struct symbol *sp;
-{
- RELOCATE (SYMBOL_NAME (sp));
- if (SYMBOL_CLASS (sp) == LOC_BLOCK)
- {
- RELOCATE (SYMBOL_BLOCK_VALUE (sp));
- /* We can assume the block that belongs to this symbol
- is not relocated yet, since it comes after
- the block that contains this symbol. */
- BLOCK_FUNCTION (SYMBOL_BLOCK_VALUE (sp)) = sp;
- UNRELOCATE (BLOCK_FUNCTION (SYMBOL_BLOCK_VALUE (sp)));
- }
- else if (SYMBOL_CLASS (sp) == LOC_STATIC)
- CORE_RELOCATE (SYMBOL_VALUE (sp));
- else if (SYMBOL_CLASS (sp) == LOC_LABEL)
- TEXT_RELOCATE (SYMBOL_VALUE (sp));
- RELOCATE (SYMBOL_TYPE (sp));
-}
-
-static void
-relocate_typevector (tv)
- struct typevector *tv;
-{
- register int ntypes = TYPEVECTOR_NTYPES (tv);
- register int i;
-
- for (i = 0; i < ntypes; i++)
- RELOCATE (TYPEVECTOR_TYPE (tv, i));
- for (i = 0; i < ntypes; i++)
- relocate_type (TYPEVECTOR_TYPE (tv, i));
-}
-
-/* We cannot come up with an a priori spanning tree
- for the network of types, since types can be used
- for many symbols and also as components of other types.
- Therefore, we need to be able to mark types that we
- already have relocated (or are already in the middle of relocating)
- as in a garbage collector. */
-
-static void
-relocate_type (tp)
- register struct type *tp;
-{
- register int nfields = TYPE_NFIELDS (tp);
- register int i;
-
- RELOCATE (TYPE_NAME (tp));
- RELOCATE (TYPE_TARGET_TYPE (tp));
- RELOCATE (TYPE_FIELDS (tp));
- RELOCATE (TYPE_POINTER_TYPE (tp));
-
- for (i = 0; i < nfields; i++)
- {
- RELOCATE (TYPE_FIELD_TYPE (tp, i));
- RELOCATE (TYPE_FIELD_NAME (tp, i));
- }
-}
-
-static void
-relocate_sourcevector (svp)
- register struct sourcevector *svp;
-{
- register int nfiles = svp->length;
- register int i;
- for (i = 0; i < nfiles; i++)
- RELOCATE (svp->source[i]);
- for (i = 0; i < nfiles; i++)
- relocate_source (svp->source[i]);
-}
-
-static void
-relocate_source (sp)
- register struct source *sp;
-{
- register int nitems = sp->contents.nitems;
- register int i;
-
- RELOCATE (sp->name);
- for (i = 0; i < nitems; i++)
- TEXT_RELOCATE (sp->contents.item[i].pc);
-}
-
-/* Read symsegs from file named NAME open on DESC,
- make symtabs from them, and return a chain of them.
- These symtabs are not suitable for direct use in `symtab_list'
- because each one describes a single object file, perhaps many source files.
- `symbol_file_command' takes each of these, makes many real symtabs
- from it, and then frees it.
-
- We assume DESC is prepositioned at the end of the string table,
- just before the symsegs if there are any. */
-
-struct symtab *
-read_symsegs (desc, name)
- int desc;
- char *name;
-{
- struct symbol_root root;
- register char *data;
- register struct symtab *sp, *sp1, *chain = 0;
- register int len;
-
- while (1)
- {
- len = myread (desc, &root, sizeof root);
- if (len == 0 || root.format == 0)
- break;
- /* format 1 was ok for the original gdb, but since the size of the
- type structure changed when C++ support was added, it can no
- longer be used. Accept only format 2. */
- if (root.format != 2 ||
- root.length < sizeof root)
- error ("\nInvalid symbol segment format code");
- data = (char *) xmalloc (root.length);
- bcopy (&root, data, sizeof root);
- len = myread (desc, data + sizeof root,
- root.length - sizeof root);
- sp = relocate_symtab (data);
- RELOCATE (((struct symbol_root *)data)->sourcevector);
- relocate_sourcevector (((struct symbol_root *)data)->sourcevector);
- sp->next = chain;
- chain = sp;
- sp->linetable = (struct linetable *) ((struct symbol_root *)data)->sourcevector;
- }
-
- return chain;
-}
-
-static int block_depth ();
-void print_spaces ();
-static void print_symbol ();
-
-void
-print_symtabs (filename)
- char *filename;
-{
- FILE *outfile;
- register struct symtab *s;
- register int i, j;
- int len, line, blen;
- register struct linetable *l;
- struct blockvector *bv;
- register struct block *b;
- int depth;
- struct cleanup *cleanups;
- extern int fclose();
-
- if (filename == 0)
- error_no_arg ("file to write symbol data in");
-
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- outfile = fopen (filename, "w");
- if (outfile == 0)
- perror_with_name (filename);
-
- cleanups = make_cleanup (fclose, outfile);
- immediate_quit++;
-
- for (s = symtab_list; s; s = s->next)
- {
- /* First print the line table. */
- fprintf (outfile, "Symtab for file %s\n\n", s->filename);
- fprintf (outfile, "Line table:\n\n");
- l = LINETABLE (s);
- len = l->nitems;
- for (i = 0; i < len; i++)
- fprintf (outfile, " line %d at %x\n", l->item[i].line,
- l->item[i].pc);
- /* Now print the block info. */
- fprintf (outfile, "\nBlockvector:\n\n");
- bv = BLOCKVECTOR (s);
- len = BLOCKVECTOR_NBLOCKS (bv);
- for (i = 0; i < len; i++)
- {
- b = BLOCKVECTOR_BLOCK (bv, i);
- depth = block_depth (b) * 2;
- print_spaces (depth, outfile);
- fprintf (outfile, "block #%03d (object 0x%x) ", i, b);
- fprintf (outfile, "[0x%x..0x%x]", BLOCK_START (b), BLOCK_END (b));
- if (BLOCK_SUPERBLOCK (b))
- fprintf (outfile, " (under 0x%x)", BLOCK_SUPERBLOCK (b));
- if (BLOCK_FUNCTION (b))
- fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b)));
- fputc ('\n', outfile);
- blen = BLOCK_NSYMS (b);
- for (j = 0; j < blen; j++)
- {
- print_symbol (BLOCK_SYM (b, j), depth + 1, outfile);
- }
- }
-
- fprintf (outfile, "\n\n");
- }
-
- immediate_quit--;
- do_cleanups (cleanups);
-}
-
-static void
-print_symbol (symbol, depth, outfile)
- struct symbol *symbol;
- int depth;
- FILE *outfile;
-{
- print_spaces (depth, outfile);
- if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE)
- {
- fprintf (outfile, "label %s at 0x%x\n", SYMBOL_NAME (symbol),
- SYMBOL_VALUE (symbol));
- return;
- }
- if (SYMBOL_NAMESPACE (symbol) == STRUCT_NAMESPACE)
- {
- if (TYPE_NAME (SYMBOL_TYPE (symbol)))
- {
- type_print_1 (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
- }
- else
- {
- fprintf (outfile, "%s %s = ",
- (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM
- ? "enum"
- : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT
- ? "struct" : "union")),
- SYMBOL_NAME (symbol));
- type_print_1 (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
- }
- fprintf (outfile, ";\n");
- }
- else
- {
- if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
- fprintf (outfile, "typedef ");
- if (SYMBOL_TYPE (symbol))
- {
- type_print_1 (SYMBOL_TYPE (symbol), SYMBOL_NAME (symbol),
- outfile, 1, depth);
- fprintf (outfile, "; ");
- }
- else
- fprintf (outfile, "%s ", SYMBOL_NAME (symbol));
-
- switch (SYMBOL_CLASS (symbol))
- {
- case LOC_CONST:
- fprintf (outfile, "const %d (0x%x),",
- SYMBOL_VALUE (symbol), SYMBOL_VALUE (symbol));
- break;
-
- case LOC_CONST_BYTES:
- fprintf (outfile, "const %d hex bytes:",
- TYPE_LENGTH (SYMBOL_TYPE (symbol)));
- {
- int i;
- for (i = 0; i < TYPE_LENGTH (SYMBOL_TYPE (symbol)); i++)
- fprintf (outfile, " %2x", SYMBOL_VALUE_BYTES (symbol) [i]);
- fprintf (outfile, ",");
- }
- break;
-
- case LOC_STATIC:
- fprintf (outfile, "static at 0x%x,", SYMBOL_VALUE (symbol));
- break;
-
- case LOC_REGISTER:
- fprintf (outfile, "register %d,", SYMBOL_VALUE (symbol));
- break;
-
- case LOC_ARG:
- fprintf (outfile, "arg at 0x%x,", SYMBOL_VALUE (symbol));
- break;
-
- case LOC_REF_ARG:
- fprintf (outfile, "reference arg at 0x%x,", SYMBOL_VALUE (symbol));
- break;
-
- case LOC_REGPARM:
- fprintf (outfile, "parameter register %d,", SYMBOL_VALUE (symbol));
- break;
-
- case LOC_LOCAL:
- fprintf (outfile, "local at 0x%x,", SYMBOL_VALUE (symbol));
- break;
-
- case LOC_TYPEDEF:
- break;
-
- case LOC_LABEL:
- fprintf (outfile, "label at 0x%x", SYMBOL_VALUE (symbol));
- break;
-
- case LOC_BLOCK:
- fprintf (outfile, "block (object 0x%x) starting at 0x%x,",
- SYMBOL_VALUE (symbol),
- BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)));
- break;
- }
- }
- fprintf (outfile, "\n");
-}
-
-/* Return the nexting depth of a block within other blocks in its symtab. */
-
-static int
-block_depth (block)
- struct block *block;
-{
- register int i = 0;
- while (block = BLOCK_SUPERBLOCK (block)) i++;
- return i;
-}
-
-/*
- * Free all partial_symtab storage.
- */
-void
-free_all_psymtabs()
-{
- obstack_free (psymbol_obstack, 0);
- obstack_init (psymbol_obstack);
- partial_symtab_list = (struct partial_symtab *) 0;
-}
-
-void
-_initialize_symmisc ()
-{
- symtab_list = (struct symtab *) 0;
- partial_symtab_list = (struct partial_symtab *) 0;
-
- add_com ("printsyms", class_obscure, print_symtabs,
- "Print dump of current symbol definitions to file OUTFILE.");
-}
-
diff --git a/gnu/usr.bin/gdb/symseg.h b/gnu/usr.bin/gdb/symseg.h
deleted file mode 100644
index 6a61a17..0000000
--- a/gnu/usr.bin/gdb/symseg.h
+++ /dev/null
@@ -1,523 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * @(#)symseg.h 6.3 (Berkeley) 5/8/91
- */
-
-/* GDB symbol table format definitions.
- Copyright (C) 1986, 1989 Free Software Foundation, Inc.
- Hacked by Michael Tiemann (tiemann@mcc.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. */
-
-/* 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 */
-
- /* C++ */
- TYPE_CODE_MEMBER, /* Member type */
- TYPE_CODE_METHOD, /* Method type */
- TYPE_CODE_REF, /* C++ Reference types */
-};
-
-/* This appears in a type's flags word for an unsigned integer type. */
-#define TYPE_FLAG_UNSIGNED 1
-/* This appears in a type's flags word
- if it is a (pointer to a|function returning a)* built in scalar type.
- These types are never freed. */
-#define TYPE_FLAG_PERM 4
-/* This appears in a type's flags word if it is a stub type (eg. if
- someone referenced a type that wasn't definined in a source file
- via (struct sir_not_appearing_in_this_film *)). */
-#define TYPE_FLAG_STUB 8
-/* Set when a class has a constructor defined */
-#define TYPE_FLAG_HAS_CONSTRUCTOR 256
-/* Set when a class has a destructor defined */
-#define TYPE_FLAG_HAS_DESTRUCTOR 512
-/* Indicates that this type is a public baseclass of another class,
- i.e. that all its public methods are available in the derived
- class. */
-#define TYPE_FLAG_VIA_PUBLIC 1024
-/* Indicates that this type is a virtual baseclass of another class,
- i.e. that if this class is inherited more than once by another
- class, only one set of member variables will be included. */
-#define TYPE_FLAG_VIA_VIRTUAL 2048
-
-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 or method type, describes the type of the value.
- For a range type, describes the type of the full range.
- 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;
- /* C++: also need a reference type. */
- struct type *reference_type;
- struct type **arg_types;
-
- /* 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;
-
-/* Handling of pointers to members:
- TYPE_MAIN_VARIANT is used for pointer and pointer
- to member types. Normally it the value of the address of its
- containing type. However, for pointers to members, we must be
- able to allocate pointer to member types and look them up
- from some place of reference.
- NEXT_VARIANT is the next element in the chain. */
- struct type *main_variant, *next_variant;
-
- /* 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".
-
- 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;
-
- /* C++ */
- int *private_field_bits;
- int *protected_field_bits;
-
- /* Number of methods described for this type */
- short nfn_fields;
- /* Number of base classes this type derives from. */
- short n_baseclasses;
-
- /* Number of methods described for this type plus all the
- methods that it derives from. */
- int nfn_fields_total;
-
- /* For classes, structures, and unions, a description of each field,
- which consists of an overloaded name, followed by the types of
- arguments that the method expects, and then the name after it
- has been renamed to make it distinct. */
- struct fn_fieldlist
- {
- /* The overloaded name. */
- char *name;
- /* The number of methods with this name. */
- int length;
- /* The list of methods. */
- struct fn_field
- {
-#if 0
- /* The overloaded name */
- char *name;
-#endif
- /* The return value of the method */
- struct type *type;
- /* The argument list */
- struct type **args;
- /* The name after it has been processed */
- char *physname;
- /* If this is a virtual function, the offset into the vtbl-1,
- else 0. */
- int voffset;
- } *fn_fields;
-
- int *private_fn_field_bits;
- int *protected_fn_field_bits;
-
- } *fn_fieldlists;
-
- unsigned char via_protected;
- unsigned char via_public;
-
- /* For types with virtual functions, VPTR_BASETYPE is the base class which
- defined the virtual function table pointer. VPTR_FIELDNO is
- the field number of that pointer in the structure.
-
- For types that are pointer to member types, VPTR_BASETYPE
- ifs the type that this pointer is a member of.
-
- Unused otherwise. */
- struct type *vptr_basetype;
-
- int vptr_fieldno;
-
- /* If this type has a base class, put it here.
- If this type is a pointer type, the chain of member pointer
- types goes here.
- Unused otherwise.
-
- Contrary to all maxims of C style and common sense, the baseclasses
- are indexed from 1 to N_BASECLASSES rather than 0 to N_BASECLASSES-1
- (i.e. BASECLASSES points to one *before* the first element of
- the array). */
- struct type **baseclasses;
-};
-
-/* 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;
- /* A flag indicating whether or not the fucntion corresponding
- to this block was compiled with gcc or not. If there is no
- function corresponding to this block, this meaning of this flag
- is undefined. (In practice it will be 1 if the block was created
- while processing a file compiled with gcc and 0 when not). */
- unsigned char gcc_compile_flag;
- /* 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_REF_ARG, /* Value address is at spec'd position in */
- /* arglist. */
- LOC_REGPARM, /* Value is at spec'd position in register window */
- 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;
-};
-
-struct partial_symbol
-{
- /* Symbol name */
- char *name;
- /* Name space code. */
- enum namespace namespace;
- /* Address class (for info_symbols) */
- enum address_class class;
- /* Associated partial symbol table */
- struct partial_symtab *pst;
- /* Value (only used for static functions currently). Done this
- way so that we can use the struct symbol macros.
- Note that the address of a function is SYMBOL_VALUE (pst)
- in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st))
- in a symbol table. */
- union
- {
- long value;
- }
- value;
-};
-
-/*
- * Vectors of all partial symbols read in from file; actually declared
- * and used in dbxread.c.
- */
-extern struct psymbol_allocation_list {
- struct partial_symbol *list, *next;
- int size;
-} global_psymbols, static_psymbols;
-
-
-/* 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 */
-};
-
-/* Each item represents a line-->pc (or the reverse) mapping. This is
- somewhat more wasteful of space than one might wish, but since only
- the files which are actually debugged are read in to core, we don't
- waste much space.
-
- Each item used to be an int; either minus a line number, or a
- program counter. If it represents a line number, that is the line
- described by the next program counter value. If it is positive, it
- is the program counter at which the code for the next line starts. */
-
-struct linetable_entry
-{
- int line;
- CORE_ADDR pc;
-};
-
-struct linetable
-{
- int nitems;
- struct linetable_entry item[1];
-};
-
-/* All the information on one source file. */
-
-struct source
-{
- char *name; /* Name of file */
- struct linetable contents;
-};
diff --git a/gnu/usr.bin/gdb/symtab.c b/gnu/usr.bin/gdb/symtab.c
deleted file mode 100644
index a6feff4..0000000
--- a/gnu/usr.bin/gdb/symtab.c
+++ /dev/null
@@ -1,2473 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * $Header: /home/cvs/386BSD/src/usr.bin/gdb/symtab.c,v 1.1.1.1 1993/06/12 14:52:20 rgrimes Exp $;
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)symtab.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Symbol table lookup for the GNU debugger, GDB.
- Copyright (C) 1986, 1987, 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "symtab.h"
-#include "param.h"
-
-#include <obstack.h>
-#include <assert.h>
-
-char *index ();
-extern char *cplus_demangle ();
-extern struct value * value_of_this ();
-
-/* Allocate an obstack to hold objects that should be freed
- when we load a new symbol table.
- This includes the symbols made by dbxread
- and the types that are not permanent. */
-
-struct obstack obstack1;
-
-struct obstack *symbol_obstack = &obstack1;
-
-/* This obstack will be used for partial_symbol objects. It can
- probably actually be the same as the symbol_obstack above, but I'd
- like to keep them seperate for now. If I want to later, I'll
- replace one with the other. */
-
-struct obstack obstack2;
-
-struct obstack *psymbol_obstack = &obstack2;
-
-/* These variables point to the objects
- representing the predefined C data types. */
-
-struct type *builtin_type_void;
-struct type *builtin_type_char;
-struct type *builtin_type_short;
-struct type *builtin_type_int;
-struct type *builtin_type_long;
-#ifdef LONG_LONG
-struct type *builtin_type_long_long;
-#endif
-struct type *builtin_type_unsigned_char;
-struct type *builtin_type_unsigned_short;
-struct type *builtin_type_unsigned_int;
-struct type *builtin_type_unsigned_long;
-#ifdef LONG_LONG
-struct type *builtin_type_unsigned_long_long;
-#endif
-struct type *builtin_type_float;
-struct type *builtin_type_double;
-
-/* Block in which the most recently searched-for symbol was found.
- Might be better to make this a parameter to lookup_symbol and
- value_of_this. */
-struct block *block_found;
-
-/* Functions */
-static int find_line_common ();
-int lookup_misc_func ();
-struct partial_symtab *lookup_partial_symtab ();
-struct symtab *psymtab_to_symtab ();
-static struct partial_symbol *lookup_partial_symbol ();
-
-/* Check for a symtab of a specific name; first in symtabs, then in
- psymtabs. *If* there is no '/' in the name, a match after a '/'
- in the symtab filename will also work. */
-
-static struct symtab *
-lookup_symtab_1 (name)
- char *name;
-{
- register struct symtab *s;
- register struct partial_symtab *ps;
- register char *slash = index (name, '/');
- register int len = strlen (name);
-
- for (s = symtab_list; s; s = s->next)
- if (!strcmp (name, s->filename))
- return s;
-
- for (ps = partial_symtab_list; ps; ps = ps->next)
- if (!strcmp (name, ps->filename))
- {
- if (ps->readin)
- fatal ("Internal: readin pst found when no symtab found.");
- s = psymtab_to_symtab (ps);
- return s;
- }
-
- if (!slash)
- {
- for (s = symtab_list; s; s = s->next)
- {
- int l = strlen (s->filename);
-
- if (s->filename[l - len -1] == '/'
- && !strcmp (s->filename + l - len, name))
- return s;
- }
-
- for (ps = partial_symtab_list; ps; ps = ps->next)
- {
- int l = strlen (ps->filename);
-
- if (ps->filename[l - len - 1] == '/'
- && !strcmp (ps->filename + l - len, name))
- {
- if (ps->readin)
- fatal ("Internal: readin pst found when no symtab found.");
- s = psymtab_to_symtab (ps);
- return s;
- }
- }
- }
- return 0;
-}
-
-/* Lookup the symbol table of a source file named NAME. Try a couple
- of variations if the first lookup doesn't work. */
-
-struct symtab *
-lookup_symtab (name)
- char *name;
-{
- register struct symtab *s;
- register char *copy;
-
- s = lookup_symtab_1 (name);
- if (s) return s;
-
- /* If name not found as specified, see if adding ".c" helps. */
-
- copy = (char *) alloca (strlen (name) + 3);
- strcpy (copy, name);
- strcat (copy, ".c");
- s = lookup_symtab_1 (copy);
- if (s) return s;
-
- /* We didn't find anything; die. */
- return 0;
-}
-
-/* Lookup the partial symbol table of a source file named NAME. This
- only returns true on an exact match (ie. this semantics are
- different from lookup_symtab. */
-
-struct partial_symtab *
-lookup_partial_symtab (name)
-char *name;
-{
- register struct partial_symtab *s;
- register char *copy;
-
- for (s = partial_symtab_list; s; s = s->next)
- if (!strcmp (name, s->filename))
- return s;
-
- return 0;
-}
-
-/* Lookup a typedef or primitive type named NAME,
- visible in lexical block BLOCK.
- If NOERR is nonzero, return zero if NAME is not suitably defined. */
-
-struct type *
-lookup_typename (name, block, noerr)
- char *name;
- struct block *block;
- int noerr;
-{
- register struct symbol *sym = lookup_symbol (name, block, VAR_NAMESPACE, 0);
- if (sym == 0 || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
- {
- if (!strcmp (name, "int"))
- return builtin_type_int;
- if (!strcmp (name, "long"))
- return builtin_type_long;
- if (!strcmp (name, "short"))
- return builtin_type_short;
- if (!strcmp (name, "char"))
- return builtin_type_char;
- if (!strcmp (name, "float"))
- return builtin_type_float;
- if (!strcmp (name, "double"))
- return builtin_type_double;
- if (!strcmp (name, "void"))
- return builtin_type_void;
-
- if (noerr)
- return 0;
- error ("No type named %s.", name);
- }
- return SYMBOL_TYPE (sym);
-}
-
-struct type *
-lookup_unsigned_typename (name)
- char *name;
-{
- if (!strcmp (name, "int"))
- return builtin_type_unsigned_int;
- if (!strcmp (name, "long"))
- return builtin_type_unsigned_long;
- if (!strcmp (name, "short"))
- return builtin_type_unsigned_short;
- if (!strcmp (name, "char"))
- return builtin_type_unsigned_char;
- error ("No type named unsigned %s.", name);
-}
-
-/* Lookup a structure type named "struct NAME",
- visible in lexical block BLOCK. */
-
-struct type *
-lookup_struct (name, block)
- char *name;
- struct block *block;
-{
- register struct symbol *sym
- = lookup_symbol (name, block, STRUCT_NAMESPACE, 0);
-
- if (sym == 0)
- error ("No struct type named %s.", name);
- if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
- error ("This context has class, union or enum %s, not a struct.", name);
- return SYMBOL_TYPE (sym);
-}
-
-/* Lookup a union type named "union NAME",
- visible in lexical block BLOCK. */
-
-struct type *
-lookup_union (name, block)
- char *name;
- struct block *block;
-{
- register struct symbol *sym
- = lookup_symbol (name, block, STRUCT_NAMESPACE, 0);
-
- if (sym == 0)
- error ("No union type named %s.", name);
- if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_UNION)
- error ("This context has class, struct or enum %s, not a union.", name);
- return SYMBOL_TYPE (sym);
-}
-
-/* Lookup an enum type named "enum NAME",
- visible in lexical block BLOCK. */
-
-struct type *
-lookup_enum (name, block)
- char *name;
- struct block *block;
-{
- register struct symbol *sym
- = lookup_symbol (name, block, STRUCT_NAMESPACE, 0);
- if (sym == 0)
- error ("No enum type named %s.", name);
- if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM)
- error ("This context has class, struct or union %s, not an enum.", name);
- return SYMBOL_TYPE (sym);
-}
-
-/* Given a type TYPE, lookup the type of the component of type named
- NAME. */
-
-struct type *
-lookup_struct_elt_type (type, name)
- struct type *type;
- char *name;
-{
- struct type *t;
- int i;
- char *errmsg;
-
- if (TYPE_CODE (type) != TYPE_CODE_STRUCT
- && TYPE_CODE (type) != TYPE_CODE_UNION)
- {
- terminal_ours ();
- fflush (stdout);
- fprintf (stderr, "Type ");
- type_print (type, "", stderr, -1);
- fprintf (stderr, " is not a structure or union type.\n");
- return_to_top_level ();
- }
-
- for (i = TYPE_NFIELDS (type) - 1; i >= 0; i--)
- if (!strcmp (TYPE_FIELD_NAME (type, i), name))
- return TYPE_FIELD_TYPE (type, i);
-
- terminal_ours ();
- fflush (stdout);
- fprintf (stderr, "Type ");
- type_print (type, "", stderr, -1);
- fprintf (stderr, " has no component named %s\n", name);
- return_to_top_level ();
-}
-
-/* Given a type TYPE, return a type of pointers to that type.
- May need to construct such a type if this is the first use.
-
- C++: use TYPE_MAIN_VARIANT and TYPE_CHAIN to keep pointer
- to member types under control. */
-
-struct type *
-lookup_pointer_type (type)
- struct type *type;
-{
- register struct type *ptype = TYPE_POINTER_TYPE (type);
- if (ptype) return TYPE_MAIN_VARIANT (ptype);
-
- /* This is the first time anyone wanted a pointer to a TYPE. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- ptype = (struct type *) xmalloc (sizeof (struct type));
- else
- ptype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- bzero (ptype, sizeof (struct type));
- TYPE_MAIN_VARIANT (ptype) = ptype;
- TYPE_TARGET_TYPE (ptype) = type;
- TYPE_POINTER_TYPE (type) = ptype;
- /* New type is permanent if type pointed to is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (ptype) |= TYPE_FLAG_PERM;
- /* We assume the machine has only one representation for pointers! */
- TYPE_LENGTH (ptype) = sizeof (char *);
- TYPE_CODE (ptype) = TYPE_CODE_PTR;
- return ptype;
-}
-
-struct type *
-lookup_reference_type (type)
- struct type *type;
-{
- register struct type *rtype = TYPE_REFERENCE_TYPE (type);
- if (rtype) return TYPE_MAIN_VARIANT (rtype);
-
- /* This is the first time anyone wanted a pointer to a TYPE. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- rtype = (struct type *) xmalloc (sizeof (struct type));
- else
- rtype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- bzero (rtype, sizeof (struct type));
- TYPE_MAIN_VARIANT (rtype) = rtype;
- TYPE_TARGET_TYPE (rtype) = type;
- TYPE_REFERENCE_TYPE (type) = rtype;
- /* New type is permanent if type pointed to is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (rtype) |= TYPE_FLAG_PERM;
- /* We assume the machine has only one representation for pointers! */
- TYPE_LENGTH (rtype) = sizeof (char *);
- TYPE_CODE (rtype) = TYPE_CODE_REF;
- return rtype;
-}
-
-
-/* Implement direct support for MEMBER_TYPE in GNU C++.
- May need to construct such a type if this is the first use.
- The TYPE is the type of the member. The DOMAIN is the type
- of the aggregate that the member belongs to. */
-
-struct type *
-lookup_member_type (type, domain)
- struct type *type, *domain;
-{
- register struct type *mtype = TYPE_MAIN_VARIANT (type);
- struct type *main_type;
-
- main_type = mtype;
- while (mtype)
- {
- if (TYPE_DOMAIN_TYPE (mtype) == domain)
- return mtype;
- mtype = TYPE_NEXT_VARIANT (mtype);
- }
-
- /* This is the first time anyone wanted this member type. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- mtype = (struct type *) xmalloc (sizeof (struct type));
- else
- mtype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- bzero (mtype, sizeof (struct type));
- if (main_type == 0)
- main_type = mtype;
- else
- {
- TYPE_NEXT_VARIANT (mtype) = TYPE_NEXT_VARIANT (main_type);
- TYPE_NEXT_VARIANT (main_type) = mtype;
- }
- TYPE_MAIN_VARIANT (mtype) = main_type;
- TYPE_TARGET_TYPE (mtype) = type;
- TYPE_DOMAIN_TYPE (mtype) = domain;
- /* New type is permanent if type pointed to is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (mtype) |= TYPE_FLAG_PERM;
-
- /* In practice, this is never used. */
- TYPE_LENGTH (mtype) = 1;
- TYPE_CODE (mtype) = TYPE_CODE_MEMBER;
-
-#if 0
- /* Now splice in the new member pointer type. */
- if (main_type)
- {
- /* This type was not "smashed". */
- TYPE_CHAIN (mtype) = TYPE_CHAIN (main_type);
- TYPE_CHAIN (main_type) = mtype;
- }
-#endif
-
- return mtype;
-}
-
-struct type *
-lookup_method_type (type, domain, args)
- struct type *type, *domain, **args;
-{
- register struct type *mtype = TYPE_MAIN_VARIANT (type);
- struct type *main_type;
-
- main_type = mtype;
- while (mtype)
- {
- if (TYPE_DOMAIN_TYPE (mtype) == domain)
- {
- struct type **t1 = args;
- struct type **t2 = TYPE_ARG_TYPES (mtype);
- if (t2)
- {
- int i;
- for (i = 0; t1[i] != 0 && t1[i]->code != TYPE_CODE_VOID; i++)
- if (t1[i] != t2[i])
- break;
- if (t1[i] == t2[i])
- return mtype;
- }
- }
- mtype = TYPE_NEXT_VARIANT (mtype);
- }
-
- /* This is the first time anyone wanted this member type. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- mtype = (struct type *) xmalloc (sizeof (struct type));
- else
- mtype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- bzero (mtype, sizeof (struct type));
- if (main_type == 0)
- main_type = mtype;
- else
- {
- TYPE_NEXT_VARIANT (mtype) = TYPE_NEXT_VARIANT (main_type);
- TYPE_NEXT_VARIANT (main_type) = mtype;
- }
- TYPE_MAIN_VARIANT (mtype) = main_type;
- TYPE_TARGET_TYPE (mtype) = type;
- TYPE_DOMAIN_TYPE (mtype) = domain;
- TYPE_ARG_TYPES (mtype) = args;
- /* New type is permanent if type pointed to is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (mtype) |= TYPE_FLAG_PERM;
-
- /* In practice, this is never used. */
- TYPE_LENGTH (mtype) = 1;
- TYPE_CODE (mtype) = TYPE_CODE_METHOD;
-
-#if 0
- /* Now splice in the new member pointer type. */
- if (main_type)
- {
- /* This type was not "smashed". */
- TYPE_CHAIN (mtype) = TYPE_CHAIN (main_type);
- TYPE_CHAIN (main_type) = mtype;
- }
-#endif
-
- return mtype;
-}
-
-/* Given a type TYPE, return a type which has offset OFFSET,
- via_virtual VIA_VIRTUAL, and via_public VIA_PUBLIC.
- May need to construct such a type if none exists. */
-struct type *
-lookup_basetype_type (type, offset, via_virtual, via_public)
- struct type *type;
- int offset;
- int via_virtual, via_public;
-{
- register struct type *btype = TYPE_MAIN_VARIANT (type);
- struct type *main_type;
-
- if (offset != 0)
- {
- printf ("Internal error: type offset non-zero in lookup_basetype_type");
- offset = 0;
- }
-
- main_type = btype;
- while (btype)
- {
- if (/* TYPE_OFFSET (btype) == offset
- && */ TYPE_VIA_PUBLIC (btype) == via_public
- && TYPE_VIA_VIRTUAL (btype) == via_virtual)
- return btype;
- btype = TYPE_NEXT_VARIANT (btype);
- }
-
- /* This is the first time anyone wanted this member type. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- btype = (struct type *) xmalloc (sizeof (struct type));
- else
- btype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- if (main_type == 0)
- {
- main_type = btype;
- bzero (btype, sizeof (struct type));
- TYPE_MAIN_VARIANT (btype) = main_type;
- }
- else
- {
- bcopy (main_type, btype, sizeof (struct type));
- TYPE_NEXT_VARIANT (main_type) = btype;
- }
-/* TYPE_OFFSET (btype) = offset; */
- if (via_public)
- TYPE_FLAGS (btype) |= TYPE_FLAG_VIA_PUBLIC;
- if (via_virtual)
- TYPE_FLAGS (btype) |= TYPE_FLAG_VIA_VIRTUAL;
- /* New type is permanent if type pointed to is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (btype) |= TYPE_FLAG_PERM;
-
- /* In practice, this is never used. */
- TYPE_LENGTH (btype) = 1;
- TYPE_CODE (btype) = TYPE_CODE_STRUCT;
-
- return btype;
-}
-
-/* Given a type TYPE, return a type of functions that return that type.
- May need to construct such a type if this is the first use. */
-
-struct type *
-lookup_function_type (type)
- struct type *type;
-{
- register struct type *ptype = TYPE_FUNCTION_TYPE (type);
- if (ptype) return ptype;
-
- /* This is the first time anyone wanted a function returning a TYPE. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- ptype = (struct type *) xmalloc (sizeof (struct type));
- else
- ptype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- bzero (ptype, sizeof (struct type));
- TYPE_TARGET_TYPE (ptype) = type;
- TYPE_FUNCTION_TYPE (type) = ptype;
- /* New type is permanent if type returned is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (ptype) |= TYPE_FLAG_PERM;
- TYPE_LENGTH (ptype) = 1;
- TYPE_CODE (ptype) = TYPE_CODE_FUNC;
- TYPE_NFIELDS (ptype) = 0;
- return ptype;
-}
-
-/* Create an array type. Elements will be of type TYPE, and there will
- be NUM of them.
-
- Eventually this should be extended to take two more arguments which
- specify the bounds of the array and the type of the index.
- It should also be changed to be a "lookup" function, with the
- appropriate data structures added to the type field.
- Then read array type should call here. */
-
-struct type *
-create_array_type (element_type, number)
- struct type *element_type;
- int number;
-{
- struct type *result_type = (struct type *)
- obstack_alloc (symbol_obstack, sizeof (struct type));
-
- bzero (result_type, sizeof (struct type));
-
- TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (result_type) = element_type;
- TYPE_LENGTH (result_type) = number * TYPE_LENGTH (element_type);
- TYPE_NFIELDS (result_type) = 1;
- TYPE_FIELDS (result_type) =
- (struct field *) obstack_alloc (symbol_obstack, sizeof (struct field));
- TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int;
- TYPE_VPTR_FIELDNO (result_type) = -1;
-
- return result_type;
-}
-
-
-/* Smash TYPE to be a type of pointers to TO_TYPE.
- If TO_TYPE is not permanent and has no pointer-type yet,
- record TYPE as its pointer-type. */
-
-void
-smash_to_pointer_type (type, to_type)
- struct type *type, *to_type;
-{
- int type_permanent = (TYPE_FLAGS (type) & TYPE_FLAG_PERM);
-
- bzero (type, sizeof (struct type));
- TYPE_TARGET_TYPE (type) = to_type;
- /* We assume the machine has only one representation for pointers! */
- TYPE_LENGTH (type) = sizeof (char *);
- TYPE_CODE (type) = TYPE_CODE_PTR;
-
- TYPE_MAIN_VARIANT (type) = type;
-
- if (type_permanent)
- TYPE_FLAGS (type) |= TYPE_FLAG_PERM;
-
- if (TYPE_POINTER_TYPE (to_type) == 0
- && (!(TYPE_FLAGS (to_type) & TYPE_FLAG_PERM)
- || type_permanent))
- {
- TYPE_POINTER_TYPE (to_type) = type;
- }
-}
-
-/* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. */
-
-void
-smash_to_member_type (type, domain, to_type)
- struct type *type, *domain, *to_type;
-{
- bzero (type, sizeof (struct type));
- TYPE_TARGET_TYPE (type) = to_type;
- TYPE_DOMAIN_TYPE (type) = domain;
-
- /* In practice, this is never needed. */
- TYPE_LENGTH (type) = 1;
- TYPE_CODE (type) = TYPE_CODE_MEMBER;
-
- TYPE_MAIN_VARIANT (type) = lookup_member_type (domain, to_type);
-}
-
-/* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE. */
-
-void
-smash_to_method_type (type, domain, to_type, args)
- struct type *type, *domain, *to_type, **args;
-{
- bzero (type, sizeof (struct type));
- TYPE_TARGET_TYPE (type) = to_type;
- TYPE_DOMAIN_TYPE (type) = domain;
- TYPE_ARG_TYPES (type) = args;
-
- /* In practice, this is never needed. */
- TYPE_LENGTH (type) = 1;
- TYPE_CODE (type) = TYPE_CODE_METHOD;
-
- TYPE_MAIN_VARIANT (type) = lookup_method_type (domain, to_type, args);
-}
-
-/* Smash TYPE to be a type of reference to TO_TYPE.
- If TO_TYPE is not permanent and has no pointer-type yet,
- record TYPE as its pointer-type. */
-
-void
-smash_to_reference_type (type, to_type)
- struct type *type, *to_type;
-{
- int type_permanent = (TYPE_FLAGS (type) & TYPE_FLAG_PERM);
-
- bzero (type, sizeof (struct type));
- TYPE_TARGET_TYPE (type) = to_type;
- /* We assume the machine has only one representation for pointers! */
- TYPE_LENGTH (type) = sizeof (char *);
- TYPE_CODE (type) = TYPE_CODE_REF;
-
- TYPE_MAIN_VARIANT (type) = type;
-
- if (type_permanent)
- TYPE_FLAGS (type) |= TYPE_FLAG_PERM;
-
- if (TYPE_REFERENCE_TYPE (to_type) == 0
- && (!(TYPE_FLAGS (to_type) & TYPE_FLAG_PERM)
- || type_permanent))
- {
- TYPE_REFERENCE_TYPE (to_type) = type;
- }
-}
-
-/* Smash TYPE to be a type of functions returning TO_TYPE.
- If TO_TYPE is not permanent and has no function-type yet,
- record TYPE as its function-type. */
-
-void
-smash_to_function_type (type, to_type)
- struct type *type, *to_type;
-{
- int type_permanent = (TYPE_FLAGS (type) & TYPE_FLAG_PERM);
-
- bzero (type, sizeof (struct type));
- TYPE_TARGET_TYPE (type) = to_type;
- TYPE_LENGTH (type) = 1;
- TYPE_CODE (type) = TYPE_CODE_FUNC;
- TYPE_NFIELDS (type) = 0;
-
- if (type_permanent)
- TYPE_FLAGS (type) |= TYPE_FLAG_PERM;
-
- if (TYPE_FUNCTION_TYPE (to_type) == 0
- && (!(TYPE_FLAGS (to_type) & TYPE_FLAG_PERM)
- || type_permanent))
- {
- TYPE_FUNCTION_TYPE (to_type) = type;
- }
-}
-
-/* Find which partial symtab on the partial_symtab_list contains
- PC. Return 0 if none. */
-
-struct partial_symtab *
-find_pc_psymtab (pc)
- register CORE_ADDR pc;
-{
- register struct partial_symtab *ps;
-
- for (ps = partial_symtab_list; ps; ps = ps->next)
- if (pc >= ps->textlow && pc < ps->texthigh)
- return ps;
-
- return 0;
-}
-
-/* Find which partial symbol within a psymtab contains PC. Return 0
- if none. Check all psymtabs if PSYMTAB is 0. */
-struct partial_symbol *
-find_pc_psymbol (psymtab, pc)
- struct partial_symtab *psymtab;
- CORE_ADDR pc;
-{
- struct partial_symbol *best, *p;
- int best_pc;
-
- if (!psymtab)
- psymtab = find_pc_psymtab (pc);
- if (!psymtab)
- return 0;
-
- best_pc = psymtab->textlow - 1;
-
- for (p = static_psymbols.list + psymtab->statics_offset;
- (p - (static_psymbols.list + psymtab->statics_offset)
- < psymtab->n_static_syms);
- p++)
- if (SYMBOL_NAMESPACE (p) == VAR_NAMESPACE
- && SYMBOL_CLASS (p) == LOC_BLOCK
- && pc >= SYMBOL_VALUE (p)
- && SYMBOL_VALUE (p) > best_pc)
- {
- best_pc = SYMBOL_VALUE (p);
- best = p;
- }
- if (best_pc == psymtab->textlow - 1)
- return 0;
- return best;
-}
-
-
-static struct symbol *lookup_block_symbol ();
-
-/* Find the definition for a specified symbol name NAME
- in namespace NAMESPACE, visible from lexical block BLOCK.
- Returns the struct symbol pointer, or zero if no symbol is found.
- C++: if IS_A_FIELD_OF_THIS is nonzero on entry, check to see if
- NAME is a field of the current implied argument `this'. If so set
- *IS_A_FIELD_OF_THIS to 1, otherwise set it to zero.
- BLOCK_FOUND is set to the block in which NAME is found (in the case of
- a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */
-
-struct symbol *
-lookup_symbol (name, block, namespace, is_a_field_of_this)
- char *name;
- register struct block *block;
- enum namespace namespace;
- int *is_a_field_of_this;
-{
- register int i, n;
- register struct symbol *sym;
- register struct symtab *s;
- register struct partial_symtab *ps;
- register struct partial_symbol *psym;
- struct blockvector *bv;
-
- /* Search specified block and its superiors. */
-
- while (block != 0)
- {
- sym = lookup_block_symbol (block, name, namespace);
- if (sym)
- {
- block_found = block;
- return sym;
- }
- block = BLOCK_SUPERBLOCK (block);
- }
-
- /* C++: If requested to do so by the caller,
- check to see if NAME is a field of `this'. */
- if (is_a_field_of_this)
- {
- struct value *v = value_of_this (0);
-
- *is_a_field_of_this = 0;
- if (v && check_field (v, name))
- {
- *is_a_field_of_this = 1;
- return 0;
- }
- }
-
- /* Now search all global blocks. Do the symtab's first, then
- check the psymtab's */
-
- for (s = symtab_list; s; s = s->next)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, 0);
- sym = lookup_block_symbol (block, name, namespace);
- if (sym)
- {
- block_found = block;
- return sym;
- }
- }
-
- /* Check for the possibility of the symbol being a global function
- that is stored on the misc function vector. Eventually, all
- global symbols might be resolved in this way. */
-
- if (namespace == VAR_NAMESPACE)
- {
- int index = lookup_misc_func (name);
-
- if (index == -1)
- { /* Look for a mangled C++ name for NAME. */
- int name_len = strlen (name);
- for (index = misc_function_count; --index >= 0; )
- /* Assume orginal name is prefix of mangled name. */
- if (!strncmp (misc_function_vector[index].name, name, name_len))
- {
- char *demangled =
- cplus_demangle(misc_function_vector[index].name, -1);
- if (demangled != NULL)
- {
- int cond = strcmp (demangled, name);
- free (demangled);
- if (!cond)
- break;
- }
- }
- /* Loop terminates on no match with index == -1. */
- }
-
- if (index != -1)
- {
- ps = find_pc_psymtab (misc_function_vector[index].address);
- if (ps && !ps->readin)
- {
- s = psymtab_to_symtab (ps);
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, 0);
- sym = lookup_block_symbol (block, name, namespace);
- /* sym == 0 if symbol was found in the psymtab but not
- in the symtab.
- Return 0 to use the misc_function definition of "foo_".
-
- This happens for Fortran "foo_" symbols,
- which are "foo" in the symtab.
-
- This can also happen if "asm" is used to make a
- regular symbol but not a debugging symbol, e.g.
- asm(".globl _main");
- asm("_main:");
- */
-
- return sym;
- }
- }
- }
-
- if (psym = lookup_partial_symbol (name, 1, namespace))
- {
- ps = psym->pst;
- s = psymtab_to_symtab(ps);
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, 0);
- sym = lookup_block_symbol (block, name, namespace);
- if (!sym)
- fatal ("Internal: global symbol found in psymtab but not in symtab");
- return sym;
- }
-
- /* Now search all per-file blocks.
- Not strictly correct, but more useful than an error.
- Do the symtabs first, then check the psymtabs */
-
- for (s = symtab_list; s; s = s->next)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, 1);
- sym = lookup_block_symbol (block, name, namespace);
- if (sym)
- {
- block_found = block;
- return sym;
- }
- }
-
- if (psym = lookup_partial_symbol(name, 0, namespace))
- {
- ps = psym->pst;
- s = psymtab_to_symtab(ps);
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, 1);
- sym = lookup_block_symbol (block, name, namespace);
- if (!sym)
- fatal ("Internal: static symbol found in psymtab but not in symtab");
- return sym;
- }
-
- return 0;
-}
-
-/* Look, in partial_symtab PST, for symbol NAME. Check the global
- symbols if GLOBAL, the static symbols if not */
-
-static struct partial_symbol *
-lookup_partial_symbol (name, global, namespace)
- register char *name;
- register int global;
- register enum namespace namespace;
-{
- register struct partial_symbol *start, *psym;
- register struct partial_symbol *top, *bottom, *center;
- register struct partial_symtab *pst;
- register int length;
-
- if (global)
- {
- start = global_psymbols.list;
- length = global_psymbols.next - start;
- }
- else
- {
- start = static_psymbols.list;
- length = static_psymbols.next - start;
- }
-
- if (!length)
- return (struct partial_symbol *) 0;
-
- /* Binary search. This search is guarranteed to end with center
- pointing at the earliest partial symbol with the correct
- name. At that point *all* partial symbols with that name
- will be checked against the correct namespace. */
- bottom = start;
- top = start + length - 1;
- while (top > bottom)
- {
- center = bottom + (top - bottom) / 2;
-
- assert (center < top);
-
- if (strcmp (SYMBOL_NAME (center), name) >= 0)
- top = center;
- else
- bottom = center + 1;
- }
- assert (top == bottom);
-
- while (strcmp (SYMBOL_NAME (top), name) == 0)
- {
- if (!top->pst->readin && SYMBOL_NAMESPACE (top) == namespace)
- return top;
- top ++;
- }
-
- return (struct partial_symbol *) 0;
-}
-
-/* Look for a symbol in block BLOCK. */
-
-static struct symbol *
-lookup_block_symbol (block, name, namespace)
- register struct block *block;
- char *name;
- enum namespace namespace;
-{
- register int bot, top, inc;
- register struct symbol *sym, *parameter_sym;
-
- top = BLOCK_NSYMS (block);
- bot = 0;
-
- /* If the blocks's symbols were sorted, start with a binary search. */
-
- if (BLOCK_SHOULD_SORT (block))
- {
- /* First, advance BOT to not far before
- the first symbol whose name is NAME. */
-
- while (1)
- {
- inc = (top - bot + 1);
- /* No need to keep binary searching for the last few bits worth. */
- if (inc < 4)
- break;
- inc = (inc >> 1) + bot;
- sym = BLOCK_SYM (block, inc);
- if (SYMBOL_NAME (sym)[0] < name[0])
- bot = inc;
- else if (SYMBOL_NAME (sym)[0] > name[0])
- top = inc;
- else if (strcmp (SYMBOL_NAME (sym), name) < 0)
- bot = inc;
- else
- top = inc;
- }
-
- /* Now scan forward until we run out of symbols,
- find one whose name is greater than NAME,
- or find one we want.
- If there is more than one symbol with the right name and namespace,
- we return the first one. dbxread.c is careful to make sure
- that if one is a register then it comes first. */
-
- top = BLOCK_NSYMS (block);
- while (bot < top)
- {
- sym = BLOCK_SYM (block, bot);
- inc = SYMBOL_NAME (sym)[0] - name[0];
- if (inc == 0)
- inc = strcmp (SYMBOL_NAME (sym), name);
- if (inc == 0 && SYMBOL_NAMESPACE (sym) == namespace)
- return sym;
- if (inc > 0)
- return 0;
- bot++;
- }
- return 0;
- }
-
- /* Here if block isn't sorted.
- This loop is equivalent to the loop above,
- but hacked greatly for speed.
-
- Note that parameter symbols do not always show up last in the
- list; this loop makes sure to take anything else other than
- parameter symbols first; it only uses parameter symbols as a
- last resort. Note that this only takes up extra computation
- time on a match. */
-
- parameter_sym = (struct symbol *) 0;
- top = BLOCK_NSYMS (block);
- inc = name[0];
- while (bot < top)
- {
- sym = BLOCK_SYM (block, bot);
- if (SYMBOL_NAME (sym)[0] == inc
- && !strcmp (SYMBOL_NAME (sym), name)
- && SYMBOL_NAMESPACE (sym) == namespace)
- {
- if (SYMBOL_CLASS (sym) == LOC_ARG
- || SYMBOL_CLASS (sym) == LOC_REF_ARG
- || SYMBOL_CLASS (sym) == LOC_REGPARM)
- parameter_sym = sym;
- else
- return sym;
- }
- bot++;
- }
- return parameter_sym; /* Will be 0 if not found. */
-}
-
-/* Return the symbol for the function which contains a specified
- lexical block, described by a struct block BL. */
-
-struct symbol *
-block_function (bl)
- struct block *bl;
-{
- while (BLOCK_FUNCTION (bl) == 0 && BLOCK_SUPERBLOCK (bl) != 0)
- bl = BLOCK_SUPERBLOCK (bl);
-
- return BLOCK_FUNCTION (bl);
-}
-
-/* Subroutine of find_pc_line */
-
-struct symtab *
-find_pc_symtab (pc)
- register CORE_ADDR pc;
-{
- register struct block *b;
- struct blockvector *bv;
- register struct symtab *s;
- register struct partial_symtab *ps;
-
- /* Search all symtabs for one whose file contains our pc */
-
- for (s = symtab_list; s; s = s->next)
- {
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, 0);
- if (BLOCK_START (b) <= pc
- && BLOCK_END (b) > pc)
- break;
- }
-
- if (!s)
- {
- ps = find_pc_psymtab (pc);
- if (ps && ps->readin)
- fatal ("Internal error: pc in read in psymtab, but not in symtab.");
-
- if (ps)
- s = psymtab_to_symtab (ps);
- }
-
- return s;
-}
-
-/* Find the source file and line number for a given PC value.
- Return a structure containing a symtab pointer, a line number,
- and a pc range for the entire source line.
- The value's .pc field is NOT the specified pc.
- NOTCURRENT nonzero means, if specified pc is on a line boundary,
- use the line that ends there. Otherwise, in that case, the line
- that begins there is used. */
-
-struct symtab_and_line
-find_pc_line (pc, notcurrent)
- CORE_ADDR pc;
- int notcurrent;
-{
- struct symtab *s;
- register struct linetable *l;
- register int len;
- register int i;
- register struct linetable_entry *item;
- struct symtab_and_line value;
- struct blockvector *bv;
-
- /* Info on best line seen so far, and where it starts, and its file. */
-
- int best_line = 0;
- CORE_ADDR best_pc = 0;
- CORE_ADDR best_end = 0;
- struct symtab *best_symtab = 0;
-
- /* Store here the first line number
- of a file which contains the line at the smallest pc after PC.
- If we don't find a line whose range contains PC,
- we will use a line one less than this,
- with a range from the start of that file to the first line's pc. */
- int alt_line = 0;
- CORE_ADDR alt_pc = 0;
- struct symtab *alt_symtab = 0;
-
- /* Info on best line seen in this file. */
-
- int prev_line;
- CORE_ADDR prev_pc;
-
- /* Info on first line of this file. */
-
- int first_line;
- CORE_ADDR first_pc;
-
- /* If this pc is not from the current frame,
- it is the address of the end of a call instruction.
- Quite likely that is the start of the following statement.
- But what we want is the statement containing the instruction.
- Fudge the pc to make sure we get that. */
-
- if (notcurrent) pc -= 1;
-
- s = find_pc_symtab (pc);
- if (s == 0)
- {
- value.symtab = 0;
- value.line = 0;
- value.pc = pc;
- value.end = 0;
- return value;
- }
-
- bv = BLOCKVECTOR (s);
-
- /* Look at all the symtabs that share this blockvector.
- They all have the same apriori range, that we found was right;
- but they have different line tables. */
-
- for (; s && BLOCKVECTOR (s) == bv; s = s->next)
- {
- /* Find the best line in this symtab. */
- l = LINETABLE (s);
- len = l->nitems;
- prev_line = -1;
- first_line = -1;
- for (i = 0; i < len; i++)
- {
- item = &(l->item[i]);
-
- if (first_line < 0)
- {
- first_line = item->line;
- first_pc = item->pc;
- }
- /* Return the last line that did not start after PC. */
- if (pc >= item->pc)
- {
- prev_line = item->line;
- prev_pc = item->pc;
- }
- else
- break;
- }
-
- /* Is this file's best line closer than the best in the other files?
- If so, record this file, and its best line, as best so far. */
- if (prev_line >= 0 && prev_pc > best_pc)
- {
- best_pc = prev_pc;
- best_line = prev_line;
- best_symtab = s;
- if (i < len)
- best_end = item->pc;
- else
- best_end = 0;
- }
- /* Is this file's first line closer than the first lines of other files?
- If so, record this file, and its first line, as best alternate. */
- if (first_line >= 0 && first_pc > pc
- && (alt_pc == 0 || first_pc < alt_pc))
- {
- alt_pc = first_pc;
- alt_line = first_line;
- alt_symtab = s;
- }
- }
- if (best_symtab == 0)
- {
- value.symtab = alt_symtab;
- value.line = alt_line - 1;
- value.pc = BLOCK_END (BLOCKVECTOR_BLOCK (bv, 0));
- value.end = alt_pc;
- }
- else
- {
- value.symtab = best_symtab;
- value.line = best_line;
- value.pc = best_pc;
- value.end = (best_end ? best_end
- : (alt_pc ? alt_pc
- : BLOCK_END (BLOCKVECTOR_BLOCK (bv, 0))));
- }
- return value;
-}
-
-/* Find the PC value for a given source file and line number.
- Returns zero for invalid line number.
- The source file is specified with a struct symtab. */
-
-CORE_ADDR
-find_line_pc (symtab, line)
- struct symtab *symtab;
- int line;
-{
- register struct linetable *l;
- register int index;
- int dummy;
-
- if (symtab == 0)
- return 0;
- l = LINETABLE (symtab);
- index = find_line_common(l, line, &dummy);
- return index ? l->item[index].pc : 0;
-}
-
-/* Find the range of pc values in a line.
- Store the starting pc of the line into *STARTPTR
- and the ending pc (start of next line) into *ENDPTR.
- Returns 1 to indicate success.
- Returns 0 if could not find the specified line. */
-
-int
-find_line_pc_range (symtab, thisline, startptr, endptr)
- struct symtab *symtab;
- int thisline;
- CORE_ADDR *startptr, *endptr;
-{
- register struct linetable *l;
- register int index;
- int exact_match; /* did we get an exact linenumber match */
- register CORE_ADDR prev_pc;
- CORE_ADDR last_pc;
-
- if (symtab == 0)
- return 0;
-
- l = LINETABLE (symtab);
- index = find_line_common (l, thisline, &exact_match);
- if (index)
- {
- *startptr = l->item[index].pc;
- /* If we have not seen an entry for the specified line,
- assume that means the specified line has zero bytes. */
- if (!exact_match || index == l->nitems-1)
- *endptr = *startptr;
- else
- /* Perhaps the following entry is for the following line.
- It's worth a try. */
- if (l->item[index+1].line == thisline + 1)
- *endptr = l->item[index+1].pc;
- else
- *endptr = find_line_pc (symtab, thisline+1);
- return 1;
- }
-
- return 0;
-}
-
-/* Given a line table and a line number, return the index into the line
- table for the pc of the nearest line whose number is >= the specified one.
- Return 0 if none is found. The value is never zero is it is an index.
-
- Set *EXACT_MATCH nonzero if the value returned is an exact match. */
-
-static int
-find_line_common (l, lineno, exact_match)
- register struct linetable *l;
- register int lineno;
- int *exact_match;
-{
- register int i;
- register int len;
-
- /* BEST is the smallest linenumber > LINENO so far seen,
- or 0 if none has been seen so far.
- BEST_INDEX identifies the item for it. */
-
- int best_index = 0;
- int best = 0;
-
- int nextline = -1;
-
- if (lineno <= 0)
- return 0;
-
- len = l->nitems;
- for (i = 0; i < len; i++)
- {
- register struct linetable_entry *item = &(l->item[i]);
-
- if (item->line == lineno)
- {
- *exact_match = 1;
- return i;
- }
-
- if (item->line > lineno && (best == 0 || item->line < best))
- {
- best = item->line;
- best_index = i;
- }
- }
-
- /* If we got here, we didn't get an exact match. */
-
- *exact_match = 0;
- return best_index;
-}
-
-int
-find_pc_line_pc_range (pc, startptr, endptr)
- CORE_ADDR pc;
- CORE_ADDR *startptr, *endptr;
-{
- struct symtab_and_line sal;
- sal = find_pc_line (pc, 0);
- *startptr = sal.pc;
- *endptr = sal.end;
- return sal.symtab != 0;
-}
-
-/* Parse a string that specifies a line number.
- Pass the address of a char * variable; that variable will be
- advanced over the characters actually parsed.
-
- The string can be:
-
- LINENUM -- that line number in current file. PC returned is 0.
- FILE:LINENUM -- that line in that file. PC returned is 0.
- FUNCTION -- line number of openbrace of that function.
- PC returned is the start of the function.
- FILE:FUNCTION -- likewise, but prefer functions in that file.
- *EXPR -- line in which address EXPR appears.
-
- FUNCTION may be an undebuggable function found in misc_function_vector.
-
- If the argument FUNFIRSTLINE is nonzero, we want the first line
- of real code inside a function when a function is specified.
-
- DEFAULT_SYMTAB specifies the file to use if none is specified.
- It defaults to current_source_symtab.
- DEFAULT_LINE specifies the line number to use for relative
- line numbers (that start with signs). Defaults to current_source_line.
-
- Note that it is possible to return zero for the symtab
- if no file is validly specified. Callers must check that.
- Also, the line number returned may be invalid. */
-
-struct symtabs_and_lines
-decode_line_1 (argptr, funfirstline, default_symtab, default_line)
- char **argptr;
- int funfirstline;
- struct symtab *default_symtab;
- int default_line;
-{
- struct symtabs_and_lines decode_line_2 ();
- struct symtabs_and_lines values;
- struct symtab_and_line value;
- register char *p, *p1;
- register struct symtab *s;
- register struct symbol *sym;
- register CORE_ADDR pc;
- register int i;
- char *copy;
- struct symbol *sym_class;
- char *class_name, *method_name, *phys_name;
- int method_counter;
- int i1;
- struct symbol **sym_arr;
- struct type *t, *field;
- char **physnames;
-
- /* Defaults have defaults. */
-
- if (default_symtab == 0)
- {
- default_symtab = current_source_symtab;
- default_line = current_source_line;
- }
-
- /* See if arg is *PC */
-
- if (**argptr == '*')
- {
- (*argptr)++;
- pc = parse_and_eval_address_1 (argptr);
- values.sals = (struct symtab_and_line *)
- malloc (sizeof (struct symtab_and_line));
- values.nelts = 1;
- values.sals[0] = find_pc_line (pc, 0);
- values.sals[0].pc = pc;
- return values;
- }
-
- /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
-
- s = 0;
-
- for (p = *argptr; *p; p++)
- {
- if (p[0] == ':' || p[0] == ' ' || p[0] == '\t')
- break;
- }
- while (p[0] == ' ' || p[0] == '\t') p++;
-
- if (p[0] == ':')
- {
-
- /* C++ */
- if (p[1] ==':')
- {
- /* Extract the class name. */
- p1 = p;
- while (p != *argptr && p[-1] == ' ') --p;
- copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
- copy[p - *argptr] = 0;
-
- /* Discard the class name from the arg. */
- p = p1 + 2;
- while (*p == ' ' || *p == '\t') p++;
- *argptr = p;
-
- sym_class = lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0);
-
- if (sym_class &&
- (TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_STRUCT
- || TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_UNION))
- {
- /* Arg token is not digits => try it as a function name
- Find the next token (everything up to end or next whitespace). */
- p = *argptr;
- while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p !=':') p++;
- copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
- copy[p - *argptr] = '\0';
-
- /* no line number may be specified */
- while (*p == ' ' || *p == '\t') p++;
- *argptr = p;
-
- sym = 0;
- i1 = 0; /* counter for the symbol array */
- t = SYMBOL_TYPE (sym_class);
- sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*));
- physnames = (char **) alloca (TYPE_NFN_FIELDS_TOTAL (t) * sizeof(char*));
-
- if (destructor_name_p (copy, t))
- {
- /* destructors are a special case. */
- struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0);
- int len = TYPE_FN_FIELDLIST_LENGTH (t, 0) - 1;
- phys_name = TYPE_FN_FIELD_PHYSNAME (f, len);
- physnames[i1] = (char *)alloca (strlen (phys_name) + 1);
- strcpy (physnames[i1], phys_name);
- sym_arr[i1] = lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), VAR_NAMESPACE, 0);
- if (sym_arr[i1]) i1++;
- }
- else while (t)
- {
- class_name = TYPE_NAME (t);
- /* Ignore this class if it doesn't have a name.
- This prevents core dumps, but is just a workaround
- because we might not find the function in
- certain cases, such as
- struct D {virtual int f();}
- struct C : D {virtual int g();}
- (in this case g++ 1.35.1- does not put out a name
- for D as such, it defines type 19 (for example) in
- the same stab as C, and then does a
- .stabs "D:T19" and a .stabs "D:t19".
- Thus
- "break C::f" should not be looking for field f in
- the class named D,
- but just for the field f in the baseclasses of C
- (no matter what their names).
-
- However, I don't know how to replace the code below
- that depends on knowing the name of D. */
- if (class_name)
- {
- /* We just want the class name. In the context
- of C++, stripping off "struct " is always
- sensible. */
- if (strncmp("struct ", class_name, 7) == 0)
- class_name += 7;
- if (strncmp("union ", class_name, 6) == 0)
- class_name += 6;
-
- sym_class = lookup_symbol (class_name, 0, STRUCT_NAMESPACE, 0);
- for (method_counter = TYPE_NFN_FIELDS (SYMBOL_TYPE (sym_class)) - 1;
- method_counter >= 0;
- --method_counter)
- {
- int field_counter;
- struct fn_field *f =
- TYPE_FN_FIELDLIST1 (SYMBOL_TYPE (sym_class), method_counter);
-
- method_name = TYPE_FN_FIELDLIST_NAME (SYMBOL_TYPE (sym_class), method_counter);
- if (!strcmp (copy, method_name))
- /* Find all the fields with that name. */
- for (field_counter = TYPE_FN_FIELDLIST_LENGTH (SYMBOL_TYPE (sym_class), method_counter) - 1;
- field_counter >= 0;
- --field_counter)
- {
- phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
- physnames[i1] = (char*) alloca (strlen (phys_name) + 1);
- strcpy (physnames[i1], phys_name);
- sym_arr[i1] = lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), VAR_NAMESPACE, 0);
- if (sym_arr[i1]) i1++;
- }
- }
- }
- if (TYPE_N_BASECLASSES (t))
- t = TYPE_BASECLASS(t, 1);
- else
- break;
- }
-
- if (i1 == 1)
- {
- /* There is exactly one field with that name. */
- sym = sym_arr[0];
-
- if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
- {
- /* Arg is the name of a function */
- pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) + FUNCTION_START_OFFSET;
- if (funfirstline)
- SKIP_PROLOGUE (pc);
- values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line));
- values.nelts = 1;
- values.sals[0] = find_pc_line (pc, 0);
- values.sals[0].pc = (values.sals[0].end && values.sals[0].pc != pc) ? values.sals[0].end : pc;
- }
- else
- {
- values.nelts = 0;
- }
- return values;
- }
- if (i1 > 0)
- {
- /* There is more than one field with that name
- (overloaded). Ask the user which one to use. */
- return decode_line_2 (argptr, sym_arr, physnames,
- i1, funfirstline);
- }
- else
- error ("that class does not have any method named %s",copy);
- }
- else
- error("no class, struct, or union named %s", copy );
- }
- /* end of C++ */
-
-
- /* Extract the file name. */
- p1 = p;
- while (p != *argptr && p[-1] == ' ') --p;
- copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
- copy[p - *argptr] = 0;
-
- /* Find that file's data. */
- s = lookup_symtab (copy);
- if (s == 0)
- {
- if (symtab_list == 0 && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
- error ("No source file named %s.", copy);
- }
-
- /* Discard the file name from the arg. */
- p = p1 + 1;
- while (*p == ' ' || *p == '\t') p++;
- *argptr = p;
- }
-
- /* S is specified file's symtab, or 0 if no file specified.
- arg no longer contains the file name. */
-
- /* Check whether arg is all digits (and sign) */
-
- p = *argptr;
- if (*p == '-' || *p == '+') p++;
- while (*p >= '0' && *p <= '9')
- p++;
-
- if (p != *argptr && (*p == 0 || *p == ' ' || *p == '\t' || *p == ','))
- {
- /* We found a token consisting of all digits -- at least one digit. */
- enum sign {none, plus, minus} sign = none;
-
- /* This is where we need to make sure that we have good defaults.
- We must guarrantee that this section of code is never executed
- when we are called with just a function name, since
- select_source_symtab calls us with such an argument */
-
- if (s == 0 && default_symtab == 0)
- {
- if (symtab_list == 0 && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
- select_source_symtab (0);
- default_symtab = current_source_symtab;
- default_line = current_source_line;
- }
-
- if (**argptr == '+')
- sign = plus, (*argptr)++;
- else if (**argptr == '-')
- sign = minus, (*argptr)++;
- value.line = atoi (*argptr);
- switch (sign)
- {
- case plus:
- if (p == *argptr)
- value.line = 5;
- if (s == 0)
- value.line = default_line + value.line;
- break;
- case minus:
- if (p == *argptr)
- value.line = 15;
- if (s == 0)
- value.line = default_line - value.line;
- else
- value.line = 1;
- break;
- }
-
- while (*p == ' ' || *p == '\t') p++;
- *argptr = p;
- if (s == 0)
- s = default_symtab;
- value.symtab = s;
- value.pc = 0;
- values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line));
- values.sals[0] = value;
- values.nelts = 1;
- return values;
- }
-
- /* Arg token is not digits => try it as a function name
- Find the next token (everything up to end or next whitespace). */
- p = *argptr;
- while (*p && *p != ' ' && *p != '\t' && *p != ',') p++;
- copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
- copy[p - *argptr] = 0;
- while (*p == ' ' || *p == '\t') p++;
- *argptr = p;
-
- /* Look up that token as a function.
- If file specified, use that file's per-file block to start with. */
-
- if (s == 0)
- /* use current file as default if none is specified. */
- s = default_symtab;
-
- sym = lookup_symbol (copy, s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), 1) : 0,
- VAR_NAMESPACE, 0);
-
- if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
- {
- /* Arg is the name of a function */
- pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) + FUNCTION_START_OFFSET;
- if (funfirstline)
- SKIP_PROLOGUE (pc);
- value = find_pc_line (pc, 0);
-#ifdef PROLOGUE_FIRSTLINE_OVERLAP
- /* Convex: no need to suppress code on first line, if any */
- value.pc = pc;
-#else
- value.pc = (value.end && value.pc != pc) ? value.end : pc;
-#endif
- values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line));
- values.sals[0] = value;
- values.nelts = 1;
- return values;
- }
-
- if (sym)
- error ("%s is not a function.", copy);
-
- if (symtab_list == 0 && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
-
- if ((i = lookup_misc_func (copy)) >= 0)
- {
- value.symtab = 0;
- value.line = 0;
- value.pc = misc_function_vector[i].address + FUNCTION_START_OFFSET;
- if (funfirstline)
- SKIP_PROLOGUE (value.pc);
- values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line));
- values.sals[0] = value;
- values.nelts = 1;
- return values;
- }
-
- error ("Function %s not defined.", copy);
-}
-
-struct symtabs_and_lines
-decode_line_spec (string, funfirstline)
- char *string;
- int funfirstline;
-{
- struct symtabs_and_lines sals;
- if (string == 0)
- error ("Empty line specification.");
- sals = decode_line_1 (&string, funfirstline,
- current_source_symtab, current_source_line);
- if (*string)
- error ("Junk at end of line specification: %s", string);
- return sals;
-}
-
-/* Given a list of NELTS symbols in sym_arr (with corresponding
- mangled names in physnames), return a list of lines to operate on
- (ask user if necessary). */
-struct symtabs_and_lines
-decode_line_2 (argptr, sym_arr, physnames, nelts, funfirstline)
- char **argptr;
- struct symbol *sym_arr[];
- char *physnames[];
- int nelts;
- int funfirstline;
-{
- char *getenv();
- struct symtabs_and_lines values, return_values;
- register CORE_ADDR pc;
- char *args, *arg1, *command_line_input ();
- int i;
- char *prompt;
-
- values.sals = (struct symtab_and_line *) alloca (nelts * sizeof(struct symtab_and_line));
- return_values.sals = (struct symtab_and_line *) malloc (nelts * sizeof(struct symtab_and_line));
-
- i = 0;
- printf("[0] cancel\n[1] all\n");
- while (i < nelts)
- {
- if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK)
- {
- /* Arg is the name of a function */
- pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym_arr[i]))
- + FUNCTION_START_OFFSET;
- if (funfirstline)
- SKIP_PROLOGUE (pc);
- values.sals[i] = find_pc_line (pc, 0);
- values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ? values.sals[i].end : pc;
- printf("[%d] file:%s; line number:%d\n",
- (i+2), values.sals[i].symtab->filename, values.sals[i].line);
- }
- else printf ("?HERE\n");
- i++;
- }
-
- if ((prompt = getenv ("PS2")) == NULL)
- {
- prompt = ">";
- }
- printf("%s ",prompt);
- fflush(stdout);
-
- args = command_line_input (0, 0);
-
- if (args == 0)
- error_no_arg ("one or more choice numbers");
-
- i = 0;
- while (*args)
- {
- int num;
-
- arg1 = args;
- while (*arg1 >= '0' && *arg1 <= '9') arg1++;
- if (*arg1 && *arg1 != ' ' && *arg1 != '\t')
- error ("Arguments must be choice numbers.");
-
- num = atoi (args);
-
- if (num == 0)
- error ("cancelled");
- else if (num == 1)
- {
- bcopy (values.sals, return_values.sals, (nelts * sizeof(struct symtab_and_line)));
- return_values.nelts = nelts;
- return return_values;
- }
-
- if (num > nelts + 2)
- {
- printf ("No choice number %d.\n", num);
- }
- else
- {
- num -= 2;
- if (values.sals[num].pc)
- {
- return_values.sals[i++] = values.sals[num];
- values.sals[num].pc = 0;
- }
- else
- {
- printf ("duplicate request for %d ignored.\n", num);
- }
- }
-
- args = arg1;
- while (*args == ' ' || *args == '\t') args++;
- }
- return_values.nelts = i;
- return return_values;
-}
-
-/* hash a symbol ("hashpjw" from Aho, Sethi & Ullman, p.436) */
-
-int
-hash_symbol(str)
- register char *str;
-{
- register unsigned int h = 0, g;
- register unsigned char c;
-
- while (c = *(unsigned char *)str++) {
- h = (h << 4) + c;
- if (g = h & 0xf0000000) {
- h = h ^ (g >> 24);
- h = h ^ g;
- }
- }
- return ((int)h);
-}
-
-/* Return the index of misc function named NAME. */
-
-int
-lookup_misc_func (name)
- register char *name;
-{
- register int i = hash_symbol(name) & (MISC_FUNC_HASH_SIZE - 1);
-
- if (misc_function_vector == 0)
- error("No symbol file");
-
- i = misc_function_hash_tab[i];
- while (i >= 0)
- {
- if (strcmp(misc_function_vector[i].name, name) == 0)
- break;
- i = misc_function_vector[i].next;
- }
- return (i);
-}
-
-/*
- * Slave routine for sources_info. Force line breaks at ,'s.
- */
-static void
-output_source_filename (name, next)
-char *name;
-int next;
-{
- static int column = 0;
-
- if (column != 0 && column + strlen (name) >= 70)
- {
- printf_filtered ("\n");
- column = 0;
- }
- else if (column != 0)
- {
- printf_filtered (" ");
- column++;
- }
- printf_filtered ("%s", name);
- column += strlen (name);
- if (next)
- {
- printf_filtered (",");
- column++;
- }
-
- if (!next) column = 0;
-}
-
-static void
-sources_info ()
-{
- register struct symtab *s;
- register struct partial_symtab *ps;
- register int column = 0;
-
- if (symtab_list == 0 && partial_symtab_list == 0)
- {
- printf ("No symbol table is loaded.\n");
- return;
- }
-
- printf_filtered ("Source files for which symbols have been read in:\n\n");
-
- for (s = symtab_list; s; s = s->next)
- output_source_filename (s->filename, s->next);
- printf_filtered ("\n\n");
-
- printf_filtered ("Source files for which symbols will be read in on demand:\n\n");
-
- for (ps = partial_symtab_list; ps; ps = ps->next)
- if (!ps->readin)
- output_source_filename (ps->filename, ps->next);
- printf_filtered ("\n");
-}
-
-/* List all symbols (if REGEXP is 0) or all symbols matching REGEXP.
- If CLASS is zero, list all symbols except functions and type names.
- If CLASS is 1, list only functions.
- If CLASS is 2, list only type names. */
-
-static void sort_block_syms ();
-
-static void
-list_symbols (regexp, class)
- char *regexp;
- int class;
-{
- register struct symtab *s;
- register struct partial_symtab *ps;
- register struct blockvector *bv;
- struct blockvector *prev_bv = 0;
- register struct block *b;
- register int i, j;
- register struct symbol *sym;
- struct partial_symbol *psym, *bound;
- char *val;
- static char *classnames[]
- = {"variable", "function", "type", "method"};
- int print_count = 0;
- int found_in_file = 0;
-
- if (regexp)
- if (val = (char *) re_comp (regexp))
- error ("Invalid regexp: %s", val);
-
- /* Search through the partial_symtab_list *first* for all symbols
- matching the regexp. That way we don't have to reproduce all of
- the machinery below. */
- for (psym = global_psymbols.list, bound = global_psymbols.next; ;
- psym = static_psymbols.list, bound = static_psymbols.next)
- {
- for (; psym < bound; ++psym)
- {
- if (psym->pst->readin)
- continue;
-
- QUIT;
- /* If it would match (logic taken from loop below)
- load the file and go on to the next one */
- if ((regexp == 0 || re_exec (SYMBOL_NAME (psym)))
- && ((class == 0 && SYMBOL_CLASS (psym) != LOC_TYPEDEF
- && SYMBOL_CLASS (psym) != LOC_BLOCK)
- || (class == 1 && SYMBOL_CLASS (psym) == LOC_BLOCK)
- || (class == 2 && SYMBOL_CLASS (psym) == LOC_TYPEDEF)
- || (class == 3 && SYMBOL_CLASS (psym) == LOC_BLOCK)))
- psymtab_to_symtab(psym->pst);
- }
- if (psym == static_psymbols.next)
- break;
- }
-
- /* Printout here so as to get after the "Reading in symbols"
- messages which will be generated above. */
- printf_filtered (regexp
- ? "All %ss matching regular expression \"%s\":\n"
- : "All defined %ss:\n",
- classnames[class],
- regexp);
-
- /* Here, *if* the class is correct (function only, right now), we
- should search through the misc function vector for symbols that
- match and call find_pc_psymtab on them. If find_pc_psymtab returns
- 0, don't worry about it (already read in or no debugging info). */
-
- if (class == 1)
- {
- for (i = 0; i < misc_function_count; i++)
- if (regexp == 0 || re_exec (misc_function_vector[i].name))
- {
- ps = find_pc_psymtab (misc_function_vector[i].address);
- if (ps && !ps->readin)
- psymtab_to_symtab (ps);
- }
- }
-
- for (s = symtab_list; s; s = s->next)
- {
- found_in_file = 0;
- bv = BLOCKVECTOR (s);
- /* Often many files share a blockvector.
- Scan each blockvector only once so that
- we don't get every symbol many times.
- It happens that the first symtab in the list
- for any given blockvector is the main file. */
- if (bv != prev_bv)
- for (i = 0; i < 2; i++)
- {
- b = BLOCKVECTOR_BLOCK (bv, i);
- /* Skip the sort if this block is always sorted. */
- if (!BLOCK_SHOULD_SORT (b))
- sort_block_syms (b);
- for (j = 0; j < BLOCK_NSYMS (b); j++)
- {
- QUIT;
- sym = BLOCK_SYM (b, j);
- if ((regexp == 0 || re_exec (SYMBOL_NAME (sym)))
- && ((class == 0 && SYMBOL_CLASS (sym) != LOC_TYPEDEF
- && SYMBOL_CLASS (sym) != LOC_BLOCK)
- || (class == 1 && SYMBOL_CLASS (sym) == LOC_BLOCK)
- || (class == 2 && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- || (class == 3 && SYMBOL_CLASS (sym) == LOC_BLOCK)))
- {
- if (!found_in_file)
- {
- printf_filtered ("\nFile %s:\n", s->filename);
- print_count += 2;
- }
- found_in_file = 1;
- if (class != 2 && i == 1)
- printf_filtered ("static ");
- if (class == 2
- && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE)
- printf_filtered ("typedef ");
-
- if (class < 3)
- {
- type_print (SYMBOL_TYPE (sym),
- (SYMBOL_CLASS (sym) == LOC_TYPEDEF
- ? "" : SYMBOL_NAME (sym)),
- stdout, 0);
-
- if (class == 2
- && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE
- && (TYPE_NAME ((SYMBOL_TYPE (sym))) == 0
- || 0 != strcmp (TYPE_NAME ((SYMBOL_TYPE (sym))),
- SYMBOL_NAME (sym))))
- printf_filtered (" %s", SYMBOL_NAME (sym));
-
- printf_filtered (";\n");
- }
- else
- {
-# if 0
- char buf[1024];
- type_print_base (TYPE_FN_FIELD_TYPE(t, i), stdout, 0, 0);
- type_print_varspec_prefix (TYPE_FN_FIELD_TYPE(t, i), stdout, 0);
- sprintf (buf, " %s::", TYPE_NAME (t));
- type_print_method_args (TYPE_FN_FIELD_ARGS (t, i), buf, name, stdout);
-# endif
- }
- }
- }
- }
- prev_bv = bv;
- }
-}
-
-static void
-variables_info (regexp)
- char *regexp;
-{
- list_symbols (regexp, 0);
-}
-
-static void
-functions_info (regexp)
- char *regexp;
-{
- list_symbols (regexp, 1);
-}
-
-static void
-types_info (regexp)
- char *regexp;
-{
- list_symbols (regexp, 2);
-}
-
-#if 0
-/* Tiemann says: "info methods was never implemented." */
-static void
-methods_info (regexp)
- char *regexp;
-{
- list_symbols (regexp, 3);
-}
-#endif /* 0 */
-
-/* Call sort_block_syms to sort alphabetically the symbols of one block. */
-
-static int
-compare_symbols (s1, s2)
- struct symbol **s1, **s2;
-{
- /* Names that are less should come first. */
- register int namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2));
- if (namediff != 0) return namediff;
- /* For symbols of the same name, registers should come first. */
- return ((SYMBOL_CLASS (*s2) == LOC_REGISTER)
- - (SYMBOL_CLASS (*s1) == LOC_REGISTER));
-}
-
-static void
-sort_block_syms (b)
- register struct block *b;
-{
- qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b),
- sizeof (struct symbol *), compare_symbols);
-}
-
-/* Initialize the standard C scalar types. */
-
-static
-struct type *
-init_type (code, length, uns, name)
- enum type_code code;
- int length, uns;
- char *name;
-{
- register struct type *type;
-
- type = (struct type *) xmalloc (sizeof (struct type));
- bzero (type, sizeof *type);
- TYPE_MAIN_VARIANT (type) = type;
- TYPE_CODE (type) = code;
- TYPE_LENGTH (type) = length;
- TYPE_FLAGS (type) = uns ? TYPE_FLAG_UNSIGNED : 0;
- TYPE_FLAGS (type) |= TYPE_FLAG_PERM;
- TYPE_NFIELDS (type) = 0;
- TYPE_NAME (type) = name;
-
- /* C++ fancies. */
- TYPE_NFN_FIELDS (type) = 0;
- TYPE_N_BASECLASSES (type) = 0;
- TYPE_BASECLASSES (type) = 0;
- return type;
-}
-
-/* Return Nonzero if block a is lexically nested within block b,
- or if a and b have the same pc range.
- Return zero otherwise. */
-int
-contained_in (a, b)
- struct block *a, *b;
-{
- if (!a || !b)
- return 0;
- return a->startaddr >= b->startaddr && a->endaddr <= b->endaddr;
-}
-
-
-/* Helper routine for make_symbol_completion_list. */
-
-int return_val_size, return_val_index;
-char **return_val;
-
-void
-completion_list_add_symbol (symname)
- char *symname;
-{
- if (return_val_index + 3 > return_val_size)
- return_val =
- (char **)xrealloc (return_val,
- (return_val_size *= 2) * sizeof (char *));
-
- return_val[return_val_index] =
- (char *)xmalloc (1 + strlen (symname));
-
- strcpy (return_val[return_val_index], symname);
-
- return_val[++return_val_index] = (char *)NULL;
-}
-
-/* Return a NULL terminated array of all symbols (regardless of class) which
- begin by matching TEXT. If the answer is no symbols, then the return value
- is an array which contains only a NULL pointer.
-
- Problem: All of the symbols have to be copied because readline
- frees them. I'm not going to worry about this; hopefully there
- won't be that many. */
-
-char **
-make_symbol_completion_list (text)
- char *text;
-{
- register struct symtab *s;
- register struct partial_symtab *ps;
- register struct blockvector *bv;
- struct blockvector *prev_bv = 0;
- register struct block *b, *surrounding_static_block;
- extern struct block *get_selected_block ();
- register int i, j;
- register struct symbol *sym;
- struct partial_symbol *psym;
-
- int text_len = strlen (text);
- return_val_size = 100;
- return_val_index = 0;
- return_val =
- (char **)xmalloc ((1 + return_val_size) *sizeof (char *));
- return_val[0] = (char *)NULL;
-
- /* Look through the partial symtabs for all symbols which begin
- by matching TEXT. Add each one that you find to the list. */
-
- for (ps = partial_symtab_list; ps; ps = ps->next)
- {
- /* If the psymtab's been read in we'll get it when we search
- through the blockvector. */
- if (ps->readin) continue;
-
- for (psym = global_psymbols.list + ps->globals_offset;
- psym < (global_psymbols.list + ps->globals_offset
- + ps->n_global_syms);
- psym++)
- {
- QUIT; /* If interrupted, then quit. */
- if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0))
- completion_list_add_symbol (SYMBOL_NAME (psym));
- }
-
- for (psym = static_psymbols.list + ps->statics_offset;
- psym < (static_psymbols.list + ps->statics_offset
- + ps->n_static_syms);
- psym++)
- {
- QUIT;
- if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0))
- completion_list_add_symbol (SYMBOL_NAME (psym));
- }
- }
-
- /* At this point scan through the misc function vector and add each
- symbol you find to the list. Eventually we want to ignore
- anything that isn't a text symbol (everything else will be
- handled by the psymtab code above). */
-
- for (i = 0; i < misc_function_count; i++)
- if (!strncmp (text, misc_function_vector[i].name, text_len))
- completion_list_add_symbol (misc_function_vector[i].name);
-
- /* Search upwards from currently selected frame (so that we can
- complete on local vars. */
- for (b = get_selected_block (); b; b = BLOCK_SUPERBLOCK (b))
- {
- if (!BLOCK_SUPERBLOCK (b))
- surrounding_static_block = b; /* For elmin of dups */
-
- /* Also catch fields of types defined in this places which
- match our text string. Only complete on types visible
- from current context. */
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- {
- register struct symbol *sym = BLOCK_SYM (b, i);
-
- if (!strncmp (SYMBOL_NAME (sym), text, text_len))
- completion_list_add_symbol (SYMBOL_NAME (sym));
-
- if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- {
- struct type *t = SYMBOL_TYPE (sym);
- enum type_code c = TYPE_CODE (t);
-
- if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
- for (j = 0; j < TYPE_NFIELDS (t); j++)
- if (TYPE_FIELD_NAME (t, j) &&
- !strncmp (TYPE_FIELD_NAME (t, j), text, text_len))
- completion_list_add_symbol (TYPE_FIELD_NAME (t, j));
- }
- }
- }
-
- /* Go through the symtabs and check the externs and statics for
- symbols which match. */
-
- for (s = symtab_list; s; s = s->next)
- {
- struct block *b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), 0);
-
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len))
- completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i)));
- }
-
- for (s = symtab_list; s; s = s->next)
- {
- struct block *b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), 1);
-
- /* Don't do this block twice. */
- if (b == surrounding_static_block) continue;
-
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len))
- completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i)));
- }
-
- return (return_val);
-}
-
-void
-_initialize_symtab ()
-{
- add_info ("variables", variables_info,
- "All global and static variable names, or those matching REGEXP.");
- add_info ("functions", functions_info,
- "All function names, or those matching REGEXP.");
- add_info ("types", types_info,
- "All types names, or those matching REGEXP.");
-#if 0
- add_info ("methods", methods_info,
- "All method names, or those matching REGEXP::REGEXP.\n\
-If the class qualifier is ommited, it is assumed to be the current scope.\n\
-If the first REGEXP is ommited, then all methods matching the second REGEXP\n\
-are listed.");
-#endif
- add_info ("sources", sources_info,
- "Source files in the program.");
-
- obstack_init (symbol_obstack);
- obstack_init (psymbol_obstack);
-
- builtin_type_void = init_type (TYPE_CODE_VOID, 1, 0, "void");
-
- builtin_type_float = init_type (TYPE_CODE_FLT, sizeof (float), 0, "float");
- builtin_type_double = init_type (TYPE_CODE_FLT, sizeof (double), 0, "double");
-
- builtin_type_char = init_type (TYPE_CODE_INT, sizeof (char), 0, "char");
- builtin_type_short = init_type (TYPE_CODE_INT, sizeof (short), 0, "short");
- builtin_type_long = init_type (TYPE_CODE_INT, sizeof (long), 0, "long");
- builtin_type_int = init_type (TYPE_CODE_INT, sizeof (int), 0, "int");
-
- builtin_type_unsigned_char = init_type (TYPE_CODE_INT, sizeof (char), 1, "unsigned char");
- builtin_type_unsigned_short = init_type (TYPE_CODE_INT, sizeof (short), 1, "unsigned short");
- builtin_type_unsigned_long = init_type (TYPE_CODE_INT, sizeof (long), 1, "unsigned long");
- builtin_type_unsigned_int = init_type (TYPE_CODE_INT, sizeof (int), 1, "unsigned int");
-#ifdef LONG_LONG
- builtin_type_long_long =
- init_type (TYPE_CODE_INT, sizeof (long long), 0, "long long");
- builtin_type_unsigned_long_long =
- init_type (TYPE_CODE_INT, sizeof (long long), 1, "unsigned long long");
-#endif
-}
-
diff --git a/gnu/usr.bin/gdb/symtab.h b/gnu/usr.bin/gdb/symtab.h
deleted file mode 100644
index fefed60..0000000
--- a/gnu/usr.bin/gdb/symtab.h
+++ /dev/null
@@ -1,384 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * @(#)symtab.h 6.3 (Berkeley) 5/8/91
- */
-
-/* Symbol table definitions for GDB.
- Copyright (C) 1986, 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. */
-
-#include <obstack.h>
-
-/* An obstack to hold objects that should be freed
- when we load a new symbol table.
- This includes the symbols made by dbxread
- and the types that are not permanent. */
-
-extern struct obstack *symbol_obstack;
-extern struct obstack *psymbol_obstack;
-
-/* Some definitions and declarations to go with use of obstacks. */
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-extern char *xmalloc ();
-extern void free ();
-
-/* gdb can know one or several symbol tables at the same time;
- the ultimate intent is to have one for each separately-compiled module.
- Each such symbol table is recorded by a struct symtab, and they
- are all chained together. */
-
-/* In addition, gdb can record any number of miscellaneous undebuggable
- functions' addresses. In a system that appends _ to function names,
- the _'s are removed from the names stored in this table. */
-
-/* Actually, the misc function list is used to store *all* of the
- global symbols (text, data, bss, and abs). It is sometimes used
- to figure out what symtabs to read in. The "type" field appears
- never to be used. */
-
-enum misc_function_type {mf_unknown = 0, mf_text, mf_data, mf_bss, mf_abs};
-
-struct misc_function
-{
- char *name;
- CORE_ADDR address;
- int next; /* index of next in this hash bucket */
- unsigned char type; /* Really enum misc_function_type. */
-};
-
-/* Address and length of the vector recording all misc function names/addresses. */
-
-struct misc_function *misc_function_vector;
-int misc_function_count;
-#define MISC_FUNC_HASH_SIZE (2048)
-int misc_function_hash_tab[MISC_FUNC_HASH_SIZE];
-
-#include "symseg.h"
-
-/* Each source file is represented by a struct symtab. */
-/* These objects are chained through the `next' field. */
-
-struct symtab
- {
- /* Chain of all existing symtabs. */
- struct symtab *next;
- /* List of all symbol scope blocks for this symtab. */
- struct blockvector *blockvector;
- /* Table mapping core addresses to line numbers for this file. */
- struct linetable *linetable;
- /* Vector containing all types defined for this symtab. */
- struct typevector *typevector;
- /* Name of this source file. */
- char *filename;
- /* This component says how to free the data we point to:
- free_contents => do a tree walk and free each object.
- free_nothing => do nothing; some other symtab will free
- the data this one uses.
- free_linetable => free just the linetable. */
- enum free_code {free_nothing, free_contents, free_linetable}
- free_code;
- /* Pointer to one block of storage to be freed, if nonzero. */
- char *free_ptr;
- /* Total number of lines found in source file. */
- int nlines;
- /* Array mapping line number to character position. */
- int *line_charpos;
- /* Language of this source file. */
- enum language language;
- /* String of version information. May be zero. */
- char *version;
- /* String of compilation information. May be zero. */
- char *compilation;
- /* Offset within loader symbol table
- of first local symbol for this file. */
- int ldsymoff;
- /* Full name of file as found by searching the source path.
- 0 if not yet known. */
- char *fullname;
- };
-
-/*
- * Each source file that has not been fully read in is represented by
- * a partial_symtab. This contains the information on where in the
- * executable the debugging symbols for a specific file are, and a
- * list of names of global symbols which are located in this file.
- */
-struct partial_symtab
-{
- /* Chain of all existing partial symtabs. */
- struct partial_symtab *next;
- /* Name of the source file which this partial_symtab defines */
- char *filename;
- /* Offset within loader symbol table of first local symbol for this
- file and length (in bytes) of the section of the symbol table
- devoted to this file's symbols (actually, the section bracketed
- may contain more than just this files symbols
- If ldsymlen is 0, the only reason for this things existence is
- the dependency list below. Nothing else will happen when it is
- read in. */
- int ldsymoff, ldsymlen;
- /* Range of text addresses covered by this file; texthigh is the
- beginning of the next section. */
- int textlow, texthigh;
- /* Non-zero if the symtab corresponding to this psymtab has been
- readin */
- unsigned char readin;
- /* Array of pointers to all of the partial_symtab s which this one
- depends one. Since this array can only be set to previous or
- the current (?) psymtab, this dependency tree is guarranteed not
- to have any loops. */
- struct partial_symtab **dependencies;
- int number_of_dependencies;
- /* Global symbol list. This list will be sorted after readin to
- improve access. Binary search will be the usual method of
- finding a symbol within it. globals_offset is an integer offset
- within ps_globals */
- int globals_offset, n_global_syms;
- /* Static symbol list. This list will *not* be sorted after readin;
- to find a symbol in it, exhaustive search must be used. This is
- reasonable because searches through this list will eventually
- lead to either the read in of a files symbols for real (assumed
- to take a *lot* of time; check) or an error (and we don't care
- how long errors take). */
- int statics_offset, n_static_syms;
-};
-
-/* This is the list of struct symtab's that gdb considers current. */
-
-struct symtab *symtab_list;
-
-/* This is the list of struct partial_symtab's that gdb may need to access */
-
-struct partial_symtab *partial_symtab_list;
-
-/* This symtab variable specifies the current file for printing source lines */
-
-struct symtab *current_source_symtab;
-
-/* This is the next line to print for listing source lines. */
-
-int current_source_line;
-
-#define BLOCKLIST(symtab) (symtab)->blockvector
-#define BLOCKVECTOR(symtab) (symtab)->blockvector
-
-#define TYPEVECTOR(symtab) (symtab)->typevector
-
-#define LINELIST(symtab) (symtab)->linetable
-#define LINETABLE(symtab) (symtab)->linetable
-
-/* Macros normally used to access components of symbol table structures. */
-
-#define BLOCKLIST_NBLOCKS(blocklist) (blocklist)->nblocks
-#define BLOCKLIST_BLOCK(blocklist,n) (blocklist)->block[n]
-#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
-#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
-
-#define TYPEVECTOR_NTYPES(typelist) (typelist)->length
-#define TYPEVECTOR_TYPE(typelist,n) (typelist)->type[n]
-
-#define BLOCK_START(bl) (bl)->startaddr
-#define BLOCK_END(bl) (bl)->endaddr
-#define BLOCK_NSYMS(bl) (bl)->nsyms
-#define BLOCK_SYM(bl, n) (bl)->sym[n]
-#define BLOCK_FUNCTION(bl) (bl)->function
-#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
-#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
-
-/* Nonzero if symbols of block BL should be sorted alphabetically. */
-#define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40)
-
-#define SYMBOL_NAME(symbol) (symbol)->name
-#define SYMBOL_NAMESPACE(symbol) (symbol)->namespace
-#define SYMBOL_CLASS(symbol) (symbol)->class
-#define SYMBOL_VALUE(symbol) (symbol)->value.value
-#define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes
-#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
-#define SYMBOL_TYPE(symbol) (symbol)->type
-
-/* Some macros for bitfields. */
-#define B_SET(a,x) (a[x>>5] |= (1 << (x&31)))
-#define B_CLR(a,x) (a[x>>5] &= ~(1 << (x&31)))
-#define B_TST(a,x) (a[x>>5] & (1 << (x&31)))
-
-#define TYPE_NAME(thistype) (thistype)->name
-#define TYPE_TARGET_TYPE(thistype) (thistype)->target_type
-#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
-#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
-#define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type
-#define TYPE_MAIN_VARIANT(thistype) (thistype)->main_variant
-#define TYPE_NEXT_VARIANT(thistype) (thistype)->next_variant
-#define TYPE_LENGTH(thistype) (thistype)->length
-#define TYPE_FLAGS(thistype) (thistype)->flags
-#define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED)
-#define TYPE_CODE(thistype) (thistype)->code
-#define TYPE_NFIELDS(thistype) (thistype)->nfields
-#define TYPE_FIELDS(thistype) (thistype)->fields
-/* C++ */
-#define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype
-#define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype
-#define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno
-#define TYPE_FN_FIELDS(thistype) (thistype)->fn_fields
-#define TYPE_NFN_FIELDS(thistype) (thistype)->nfn_fields
-#define TYPE_NFN_FIELDS_TOTAL(thistype) (thistype)->nfn_fields_total
-#define TYPE_BASECLASSES(thistype) (thistype)->baseclasses
-#define TYPE_ARG_TYPES(thistype) (thistype)->arg_types
-#define TYPE_BASECLASS(thistype,index) (thistype)->baseclasses[index]
-#define TYPE_N_BASECLASSES(thistype) (thistype)->n_baseclasses
-#define TYPE_VIA_PUBLIC(thistype) ((thistype)->flags & TYPE_FLAG_VIA_PUBLIC)
-#define TYPE_VIA_VIRTUAL(thistype) ((thistype)->flags & TYPE_FLAG_VIA_VIRTUAL)
-
-#define TYPE_FIELD(thistype, n) (thistype)->fields[n]
-#define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type
-#define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name
-#define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type)
-#define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos
-#define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize
-#define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize
-
-#define TYPE_FIELD_PRIVATE_BITS(thistype) (thistype)->private_field_bits
-#define TYPE_FIELD_PROTECTED_BITS(thistype) (thistype)->protected_field_bits
-#define SET_TYPE_FIELD_PRIVATE(thistype, n) B_SET ((thistype)->private_field_bits, (n))
-#define SET_TYPE_FIELD_PROTECTED(thistype, n) B_SET ((thistype)->protected_field_bits, (n))
-#define TYPE_FIELD_PRIVATE(thistype, n) B_TST((thistype)->private_field_bits, (n))
-#define TYPE_FIELD_PROTECTED(thistype, n) B_TST((thistype)->protected_field_bits, (n))
-
-#define TYPE_HAS_DESTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_DESTRUCTOR)
-#define TYPE_HAS_CONSTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_CONSTRUCTOR)
-
-#define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitpos == -1)
-#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((char *)(thistype)->fields[n].bitsize)
-
-#define TYPE_FN_FIELDLISTS(thistype) (thistype)->fn_fieldlists
-#define TYPE_FN_FIELDLIST(thistype, n) (thistype)->fn_fieldlists[n]
-#define TYPE_FN_FIELDLIST1(thistype, n) (thistype)->fn_fieldlists[n].fn_fields
-#define TYPE_FN_FIELDLIST_NAME(thistype, n) (thistype)->fn_fieldlists[n].name
-#define TYPE_FN_FIELDLIST_LENGTH(thistype, n) (thistype)->fn_fieldlists[n].length
-
-#define TYPE_FN_FIELD(thistype, n) (thistype)[n]
-#define TYPE_FN_FIELD_NAME(thistype, n) (thistype)[n].name
-#define TYPE_FN_FIELD_TYPE(thistype, n) (thistype)[n].type
-#define TYPE_FN_FIELD_ARGS(thistype, n) (thistype)[n].args
-#define TYPE_FN_FIELD_PHYSNAME(thistype, n) (thistype)[n].physname
-#define TYPE_FN_FIELD_VIRTUAL_P(thistype, n) ((thistype)[n].voffset < 0)
-#define TYPE_FN_FIELD_STATIC_P(thistype, n) ((thistype)[n].voffset > 0)
-#define TYPE_FN_FIELD_VOFFSET(thistype, n) ((thistype)[n].voffset-1)
-
-#define TYPE_FN_PRIVATE_BITS(thistype) (thistype).private_fn_field_bits
-#define TYPE_FN_PROTECTED_BITS(thistype) (thistype).protected_fn_field_bits
-#define SET_TYPE_FN_PRIVATE(thistype, n) B_SET ((thistype).private_fn_field_bits, n)
-#define SET_TYPE_FN_PROTECTED(thistype, n) B_SET ((thistype).protected_fn_field_bits, n)
-#define TYPE_FN_PRIVATE(thistype, n) B_TST ((thistype).private_fn_field_bits, n)
-#define TYPE_FN_PROTECTED(thistype, n) B_TST ((thistype).protected_fn_field_bits, n)
-
-/* Functions that work on the objects described above */
-
-extern struct symtab *lookup_symtab ();
-extern struct symbol *lookup_symbol ();
-extern struct type *lookup_typename ();
-extern struct type *lookup_unsigned_typename ();
-extern struct type *lookup_struct ();
-extern struct type *lookup_union ();
-extern struct type *lookup_enum ();
-extern struct type *lookup_struct_elt_type ();
-extern struct type *lookup_pointer_type ();
-extern struct type *lookup_function_type ();
-extern struct type *lookup_basetype_type ();
-extern struct type *create_array_type ();
-extern struct symbol *block_function ();
-extern struct symbol *find_pc_function ();
-extern int find_pc_partial_function ();
-extern struct partial_symtab *find_pc_psymtab ();
-extern struct symtab *find_pc_symtab ();
-extern struct partial_symbol *find_pc_psymbol ();
-extern int find_pc_misc_function ();
-
-/* C++ stuff. */
-extern struct type *lookup_reference_type ();
-extern struct type *lookup_member_type ();
-extern struct type *lookup_class ();
-/* end of C++ stuff. */
-
-extern struct type *builtin_type_void;
-extern struct type *builtin_type_char;
-extern struct type *builtin_type_short;
-extern struct type *builtin_type_int;
-extern struct type *builtin_type_long;
-extern struct type *builtin_type_unsigned_char;
-extern struct type *builtin_type_unsigned_short;
-extern struct type *builtin_type_unsigned_int;
-extern struct type *builtin_type_unsigned_long;
-extern struct type *builtin_type_float;
-extern struct type *builtin_type_double;
-
-#ifdef LONG_LONG
-extern struct type *builtin_type_long_long;
-extern struct type *builtin_type_unsigned_long_long;
-
-#ifndef BUILTIN_TYPE_LONGEST
-#define BUILTIN_TYPE_LONGEST builtin_type_long_long
-#endif
-
-#ifndef BUILTIN_TYPE_UNSIGNED_LONGEST
-#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long_long
-#endif
-
-#else /* LONG_LONG */
-
-#ifndef BUILTIN_TYPE_LONGEST
-#define BUILTIN_TYPE_LONGEST builtin_type_long
-#endif
-
-#ifndef BUILTIN_TYPE_UNSIGNED_LONGEST
-#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long
-#endif
-
-#endif
-
-struct symtab_and_line
-{
- struct symtab *symtab;
- int line;
- CORE_ADDR pc;
- CORE_ADDR end;
-};
-
-struct symtabs_and_lines
-{
- struct symtab_and_line *sals;
- int nelts;
-};
-
-/* Given a pc value, return line number it is in.
- Second arg nonzero means if pc is on the boundary
- use the previous statement's line number. */
-
-struct symtab_and_line find_pc_line ();
-
-/* Given a string, return the line specified by it.
- For commands like "list" and "breakpoint". */
-
-struct symtabs_and_lines decode_line_spec ();
-struct symtabs_and_lines decode_line_spec_1 ();
-struct symtabs_and_lines decode_line_1 ();
diff --git a/gnu/usr.bin/gdb/utils.c b/gnu/usr.bin/gdb/utils.c
deleted file mode 100644
index b03f2be..0000000
--- a/gnu/usr.bin/gdb/utils.c
+++ /dev/null
@@ -1,1096 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * $Header: /home/cvs/386BSD/src/usr.bin/gdb/utils.c,v 1.1.1.1 1993/06/12 14:52:20 rgrimes Exp $;
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)utils.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* General utility routines for GDB, the GNU debugger.
- Copyright (C) 1986, 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. */
-
-#include "param.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sys/param.h>
-#include <pwd.h>
-#include "defs.h"
-#ifdef HAVE_TERMIO
-#include <termio.h>
-#endif
-
-/* If this definition isn't overridden by the header files, assume
- that isatty and fileno exist on this system. */
-#ifndef ISATTY
-#define ISATTY(FP) (isatty (fileno (FP)))
-#endif
-
-extern FILE *instream;
-
-void error ();
-void fatal ();
-
-/* Chain of cleanup actions established with make_cleanup,
- to be executed if an error happens. */
-
-static struct cleanup *cleanup_chain;
-
-/* Nonzero means a quit has been requested. */
-
-int quit_flag;
-
-/* Nonzero means quit immediately if Control-C is typed now,
- rather than waiting until QUIT is executed. */
-
-int immediate_quit;
-
-/* Add a new cleanup to the cleanup_chain,
- and return the previous chain pointer
- to be passed later to do_cleanups or discard_cleanups.
- Args are FUNCTION to clean up with, and ARG to pass to it. */
-
-struct cleanup *
-make_cleanup (function, arg)
- void (*function) ();
- int arg;
-{
- register struct cleanup *new
- = (struct cleanup *) xmalloc (sizeof (struct cleanup));
- register struct cleanup *old_chain = cleanup_chain;
-
- new->next = cleanup_chain;
- new->function = function;
- new->arg = arg;
- cleanup_chain = new;
-
- return old_chain;
-}
-
-/* Discard cleanups and do the actions they describe
- until we get back to the point OLD_CHAIN in the cleanup_chain. */
-
-void
-do_cleanups (old_chain)
- register struct cleanup *old_chain;
-{
- register struct cleanup *ptr;
- while ((ptr = cleanup_chain) != old_chain)
- {
- (*ptr->function) (ptr->arg);
- cleanup_chain = ptr->next;
- free (ptr);
- }
-}
-
-/* Discard cleanups, not doing the actions they describe,
- until we get back to the point OLD_CHAIN in the cleanup_chain. */
-
-void
-discard_cleanups (old_chain)
- register struct cleanup *old_chain;
-{
- register struct cleanup *ptr;
- while ((ptr = cleanup_chain) != old_chain)
- {
- cleanup_chain = ptr->next;
- free (ptr);
- }
-}
-
-/* Set the cleanup_chain to 0, and return the old cleanup chain. */
-struct cleanup *
-save_cleanups ()
-{
- struct cleanup *old_chain = cleanup_chain;
-
- cleanup_chain = 0;
- return old_chain;
-}
-
-/* Restore the cleanup chain from a previously saved chain. */
-void
-restore_cleanups (chain)
- struct cleanup *chain;
-{
- cleanup_chain = chain;
-}
-
-/* This function is useful for cleanups.
- Do
-
- foo = xmalloc (...);
- old_chain = make_cleanup (free_current_contents, &foo);
-
- to arrange to free the object thus allocated. */
-
-void
-free_current_contents (location)
- char **location;
-{
- free (*location);
-}
-
-/* Generally useful subroutines used throughout the program. */
-
-/* Like malloc but get error if no storage available. */
-
-char *
-xmalloc (size)
- long size;
-{
- register char *val = (char *) malloc (size);
- if (!val)
- fatal ("virtual memory exhausted.", 0);
- return val;
-}
-
-/* Like realloc but get error if no storage available. */
-
-char *
-xrealloc (ptr, size)
- char *ptr;
- long size;
-{
- register char *val = (char *) realloc (ptr, size);
- if (!val)
- fatal ("virtual memory exhausted.", 0);
- return val;
-}
-
-/* Print the system error message for errno, and also mention STRING
- as the file name for which the error was encountered.
- Then return to command level. */
-
-void
-perror_with_name (string)
- char *string;
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
- extern int errno;
- char *err;
- char *combined;
-
- if (errno < sys_nerr)
- err = sys_errlist[errno];
- else
- err = "unknown error";
-
- combined = (char *) alloca (strlen (err) + strlen (string) + 3);
- strcpy (combined, string);
- strcat (combined, ": ");
- strcat (combined, err);
-
- error ("%s.", combined);
-}
-
-/* Print the system error message for ERRCODE, and also mention STRING
- as the file name for which the error was encountered. */
-
-void
-print_sys_errmsg (string, errcode)
- char *string;
- int errcode;
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
- char *err;
- char *combined;
-
- if (errcode < sys_nerr)
- err = sys_errlist[errcode];
- else
- err = "unknown error";
-
- combined = (char *) alloca (strlen (err) + strlen (string) + 3);
- strcpy (combined, string);
- strcat (combined, ": ");
- strcat (combined, err);
-
- printf ("%s.\n", combined);
-}
-
-void
-quit ()
-{
-#ifdef HAVE_TERMIO
- ioctl (fileno (stdout), TCFLSH, 1);
-#else /* not HAVE_TERMIO */
- ioctl (fileno (stdout), TIOCFLUSH, 0);
-#endif /* not HAVE_TERMIO */
-#ifdef TIOCGPGRP
- error ("Quit");
-#else
- error ("Quit (expect signal %d when inferior is resumed)", SIGINT);
-#endif /* TIOCGPGRP */
-}
-
-/* Control C comes here */
-
-void
-request_quit ()
-{
- extern int remote_debugging;
-
- quit_flag = 1;
-
-#ifdef USG
- /* Restore the signal handler. */
- signal (SIGINT, request_quit);
-#endif
-
- if (immediate_quit)
- quit();
-}
-
-/* Print an error message and return to command level.
- STRING is the error message, used as a fprintf string,
- and ARG is passed as an argument to it. */
-
-void
-error (string, arg1, arg2, arg3)
- char *string;
- int arg1, arg2, arg3;
-{
- terminal_ours (); /* Should be ok even if no inf. */
- fflush (stdout);
- fprintf (stderr, string, arg1, arg2, arg3);
- fprintf (stderr, "\n");
- return_to_top_level ();
-}
-
-/* Print an error message and exit reporting failure.
- This is for a error that we cannot continue from.
- STRING and ARG are passed to fprintf. */
-
-void
-fatal (string, arg)
- char *string;
- int arg;
-{
- fprintf (stderr, "gdb: ");
- fprintf (stderr, string, arg);
- fprintf (stderr, "\n");
- exit (1);
-}
-
-/* Print an error message and exit, dumping core.
- STRING is a printf-style control string, and ARG is a corresponding
- argument. */
-void
-fatal_dump_core (string, arg)
- char *string;
- int arg;
-{
- /* "internal error" is always correct, since GDB should never dump
- core, no matter what the input. */
- fprintf (stderr, "gdb internal error: ");
- fprintf (stderr, string, arg);
- fprintf (stderr, "\n");
- signal (SIGQUIT, SIG_DFL);
- kill (getpid (), SIGQUIT);
- /* We should never get here, but just in case... */
- exit (1);
-}
-
-/* Make a copy of the string at PTR with SIZE characters
- (and add a null character at the end in the copy).
- Uses malloc to get the space. Returns the address of the copy. */
-
-char *
-savestring (ptr, size)
- char *ptr;
- int size;
-{
- register char *p = (char *) xmalloc (size + 1);
- bcopy (ptr, p, size);
- p[size] = 0;
- return p;
-}
-
-char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1;
- register char *val = (char *) xmalloc (len);
- strcpy (val, s1);
- strcat (val, s2);
- strcat (val, s3);
- return val;
-}
-
-void
-print_spaces (n, file)
- register int n;
- register FILE *file;
-{
- while (n-- > 0)
- fputc (' ', file);
-}
-
-/* Ask user a y-or-n question and return 1 iff answer is yes.
- Takes three args which are given to printf to print the question.
- The first, a control string, should end in "? ".
- It should not say how to answer, because we do that. */
-
-int
-query (ctlstr, arg1, arg2)
- char *ctlstr;
-{
- register int answer;
-
- /* Automatically answer "yes" if input is not from a terminal. */
- if (!input_from_terminal_p ())
- return 1;
-
- while (1)
- {
- printf (ctlstr, arg1, arg2);
- printf ("(y or n) ");
- fflush (stdout);
- answer = fgetc (stdin);
- clearerr (stdin); /* in case of C-d */
- if (answer != '\n')
- while (fgetc (stdin) != '\n') clearerr (stdin);
- if (answer >= 'a')
- answer -= 040;
- if (answer == 'Y')
- return 1;
- if (answer == 'N')
- return 0;
- printf ("Please answer y or n.\n");
- }
-}
-
-/* Parse a C escape sequence. STRING_PTR points to a variable
- containing a pointer to the string to parse. That pointer
- is updated past the characters we use. The value of the
- escape sequence is returned.
-
- A negative value means the sequence \ newline was seen,
- which is supposed to be equivalent to nothing at all.
-
- If \ is followed by a null character, we return a negative
- value and leave the string pointer pointing at the null character.
-
- If \ is followed by 000, we return 0 and leave the string pointer
- after the zeros. A value of 0 does not mean end of string. */
-
-int
-parse_escape (string_ptr)
- char **string_ptr;
-{
- register int c = *(*string_ptr)++;
- switch (c)
- {
- case 'a':
- return '\a';
- case 'b':
- return '\b';
- case 'e':
- return 033;
- case 'f':
- return '\f';
- case 'n':
- return '\n';
- case 'r':
- return '\r';
- case 't':
- return '\t';
- case 'v':
- return '\v';
- case '\n':
- return -2;
- case 0:
- (*string_ptr)--;
- return 0;
- case '^':
- c = *(*string_ptr)++;
- if (c == '\\')
- c = parse_escape (string_ptr);
- if (c == '?')
- return 0177;
- return (c & 0200) | (c & 037);
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- register int i = c - '0';
- register int count = 0;
- while (++count < 3)
- {
- if ((c = *(*string_ptr)++) >= '0' && c <= '7')
- {
- i *= 8;
- i += c - '0';
- }
- else
- {
- (*string_ptr)--;
- break;
- }
- }
- return i;
- }
- default:
- return c;
- }
-}
-
-/* Print the character CH on STREAM as part of the contents
- of a literal string whose delimiter is QUOTER. */
-
-void
-printchar (ch, stream, quoter)
- unsigned char ch;
- FILE *stream;
- int quoter;
-{
- register int c = ch;
- if (c < 040 || c >= 0177)
- switch (c)
- {
- case '\n':
- fputs_filtered ("\\n", stream);
- break;
- case '\b':
- fputs_filtered ("\\b", stream);
- break;
- case '\t':
- fputs_filtered ("\\t", stream);
- break;
- case '\f':
- fputs_filtered ("\\f", stream);
- break;
- case '\r':
- fputs_filtered ("\\r", stream);
- break;
- case '\033':
- fputs_filtered ("\\e", stream);
- break;
- case '\007':
- fputs_filtered ("\\a", stream);
- break;
- default:
- fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
- break;
- }
- else
- {
- if (c == '\\' || c == quoter)
- fputs_filtered ("\\", stream);
- fprintf_filtered (stream, "%c", c);
- }
-}
-
-static int lines_per_page, lines_printed, chars_per_line, chars_printed;
-
-/* Set values of page and line size. */
-static void
-set_screensize_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- char *p = arg;
- char *p1;
- int tolinesize = lines_per_page;
- int tocharsize = chars_per_line;
-
- if (p == 0)
- error_no_arg ("set screensize");
-
- while (*p >= '0' && *p <= '9')
- p++;
-
- if (*p && *p != ' ' && *p != '\t')
- error ("Non-integral argument given to \"set screensize\".");
-
- tolinesize = atoi (arg);
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p)
- {
- p1 = p;
- while (*p1 >= '0' && *p1 <= '9')
- p1++;
-
- if (*p1)
- error ("Non-integral second argument given to \"set screensize\".");
-
- tocharsize = atoi (p);
- }
-
- lines_per_page = tolinesize;
- chars_per_line = tocharsize;
-}
-
-static void
-instream_cleanup(stream)
- FILE *stream;
-{
- instream = stream;
-}
-
-static void
-prompt_for_continue ()
-{
- if (ISATTY(stdin) && ISATTY(stdout))
- {
- struct cleanup *old_chain = make_cleanup(instream_cleanup, instream);
- char *cp, *gdb_readline();
-
- instream = stdin;
- immediate_quit++;
- if (cp = gdb_readline ("---Type <return> to continue---"))
- free(cp);
- chars_printed = lines_printed = 0;
- immediate_quit--;
- do_cleanups(old_chain);
- }
-}
-
-/* Reinitialize filter; ie. tell it to reset to original values. */
-
-void
-reinitialize_more_filter ()
-{
- lines_printed = 0;
- chars_printed = 0;
-}
-
-static void
-screensize_info (arg, from_tty)
- char *arg;
- int from_tty;
-{
- if (arg)
- error ("\"info screensize\" does not take any arguments.");
-
- if (!lines_per_page)
- printf ("Output more filtering is disabled.\n");
- else
- {
- printf ("Output more filtering is enabled with\n");
- printf ("%d lines per page and %d characters per line.\n",
- lines_per_page, chars_per_line);
- }
-}
-
-/* Like fputs but pause after every screenful.
- Unlike fputs, fputs_filtered does not return a value.
- It is OK for LINEBUFFER to be NULL, in which case just don't print
- anything.
-
- Note that a longjmp to top level may occur in this routine
- (since prompt_for_continue may do so) so this routine should not be
- called when cleanups are not in place. */
-
-void
-fputs_filtered (linebuffer, stream)
- char *linebuffer;
- FILE *stream;
-{
- char *lineptr;
-
- if (linebuffer == 0)
- return;
-
- /* Don't do any filtering if it is disabled. */
- if (stream != stdout || !ISATTY(stdout) || lines_per_page == 0)
- {
- fputs (linebuffer, stream);
- return;
- }
-
- /* Go through and output each character. Show line extension
- when this is necessary; prompt user for new page when this is
- necessary. */
-
- lineptr = linebuffer;
- while (*lineptr)
- {
- /* Possible new page. */
- if (lines_printed >= lines_per_page - 1)
- prompt_for_continue ();
-
- while (*lineptr && *lineptr != '\n')
- {
- /* Print a single line. */
- if (*lineptr == '\t')
- {
- putc ('\t', stream);
- /* Shifting right by 3 produces the number of tab stops
- we have already passed, and then adding one and
- shifting left 3 advances to the next tab stop. */
- chars_printed = ((chars_printed >> 3) + 1) << 3;
- lineptr++;
- }
- else
- {
- putc (*lineptr, stream);
- chars_printed++;
- lineptr++;
- }
-
- if (chars_printed >= chars_per_line)
- {
- chars_printed = 0;
- lines_printed++;
- /* Possible new page. */
- if (lines_printed >= lines_per_page - 1)
- prompt_for_continue ();
- }
- }
-
- if (*lineptr == '\n')
- {
- lines_printed++;
- putc ('\n', stream);
- lineptr++;
- chars_printed = 0;
- }
- }
-}
-
-/* fputs_demangled is a variant of fputs_filtered that
- demangles g++ names.*/
-
-void
-fputs_demangled (linebuffer, stream, arg_mode)
- char *linebuffer;
- FILE *stream;
-{
-#ifdef __STDC__
- extern char *cplus_demangle (const char *, int);
-#else
- extern char *cplus_demangle ();
-#endif
-#define SYMBOL_MAX 1024
-
-#define SYMBOL_CHAR(c) (isascii(c) && (isalnum(c) || (c) == '_' || (c) == '$'))
-
- char buf[SYMBOL_MAX+1];
- char *p;
-
- if (linebuffer == NULL)
- return;
-
- p = linebuffer;
-
- while ( *p != (char) 0 ) {
- int i = 0;
-
- /* collect non-interesting characters into buf */
- while ( *p != (char) 0 && !SYMBOL_CHAR(*p) ) {
- buf[i++] = *p;
- p++;
- }
- if (i > 0) {
- /* output the non-interesting characters without demangling */
- buf[i] = (char) 0;
- fputs_filtered(buf, stream);
- i = 0; /* reset buf */
- }
-
- /* and now the interesting characters */
- while (i < SYMBOL_MAX && *p != (char) 0 && SYMBOL_CHAR(*p) ) {
- buf[i++] = *p;
- p++;
- }
- buf[i] = (char) 0;
- if (i > 0) {
- char * result;
-
- if ( (result = cplus_demangle(buf, arg_mode)) != NULL ) {
- fputs_filtered(result, stream);
- free(result);
- }
- else {
- fputs_filtered(buf, stream);
- }
- }
- }
-}
-
-/* Print ARG1, ARG2, and ARG3 on stdout using format FORMAT. If this
- information is going to put the amount written since the last call
- to INIIALIZE_MORE_FILTER or the last page break over the page size,
- print out a pause message and do a gdb_readline to get the users
- permision to continue.
-
- Unlike fprintf, this function does not return a value.
-
- Note that this routine has a restriction that the length of the
- final output line must be less than 255 characters *or* it must be
- less than twice the size of the format string. This is a very
- arbitrary restriction, but it is an internal restriction, so I'll
- put it in. This means that the %s format specifier is almost
- useless; unless the caller can GUARANTEE that the string is short
- enough, fputs_filtered should be used instead.
-
- Note also that a longjmp to top level may occur in this routine
- (since prompt_for_continue may do so) so this routine should not be
- called when cleanups are not in place. */
-
-void
-fprintf_filtered (stream, format, arg1, arg2, arg3, arg4, arg5, arg6)
- FILE *stream;
- char *format;
- int arg1, arg2, arg3, arg4, arg5, arg6;
-{
- static char *linebuffer = (char *) 0;
- static int line_size;
- int format_length = strlen (format);
- int numchars;
-
- /* Allocated linebuffer for the first time. */
- if (!linebuffer)
- {
- linebuffer = (char *) xmalloc (255);
- line_size = 255;
- }
-
- /* Reallocate buffer to a larger size if this is necessary. */
- if (format_length * 2 > line_size)
- {
- line_size = format_length * 2;
-
- /* You don't have to copy. */
- free (linebuffer);
- linebuffer = (char *) xmalloc (line_size);
- }
-
- /* This won't blow up if the restrictions described above are
- followed. */
- (void) sprintf (linebuffer, format, arg1, arg2, arg3, arg4, arg5, arg6);
-
- fputs_filtered (linebuffer, stream);
-}
-
-void
-printf_filtered (format, arg1, arg2, arg3, arg4, arg5, arg6)
- char *format;
- int arg1, arg2, arg3, arg4, arg5, arg6;
-{
- fprintf_filtered (stdout, format, arg1, arg2, arg3, arg4, arg5, arg6);
-}
-
-/* Print N spaces. */
-void
-print_spaces_filtered (n, stream)
- int n;
- FILE *stream;
-{
- register char *s = (char *) alloca (n + 1);
- register char *t = s;
-
- while (n--)
- *t++ = ' ';
- *t = '\0';
-
- fputs_filtered (s, stream);
-}
-
-
-#ifdef USG
-bcopy (from, to, count)
-char *from, *to;
-{
- memcpy (to, from, count);
-}
-
-bcmp (from, to, count)
-{
- return (memcmp (to, from, count));
-}
-
-bzero (to, count)
-char *to;
-{
- while (count--)
- *to++ = 0;
-}
-
-getwd (buf)
-char *buf;
-{
- getcwd (buf, MAXPATHLEN);
-}
-
-char *
-index (s, c)
- char *s;
-{
- char *strchr ();
- return strchr (s, c);
-}
-
-char *
-rindex (s, c)
- char *s;
-{
- char *strrchr ();
- return strrchr (s, c);
-}
-
-#ifndef USG
-char *sys_siglist[32] = {
- "SIG0",
- "SIGHUP",
- "SIGINT",
- "SIGQUIT",
- "SIGILL",
- "SIGTRAP",
- "SIGIOT",
- "SIGEMT",
- "SIGFPE",
- "SIGKILL",
- "SIGBUS",
- "SIGSEGV",
- "SIGSYS",
- "SIGPIPE",
- "SIGALRM",
- "SIGTERM",
- "SIGUSR1",
- "SIGUSR2",
- "SIGCLD",
- "SIGPWR",
- "SIGWIND",
- "SIGPHONE",
- "SIGPOLL",
-};
-#endif
-
-/* Queue routines */
-
-struct queue {
- struct queue *forw;
- struct queue *back;
-};
-
-insque (item, after)
-struct queue *item;
-struct queue *after;
-{
- item->forw = after->forw;
- after->forw->back = item;
-
- item->back = after;
- after->forw = item;
-}
-
-remque (item)
-struct queue *item;
-{
- item->forw->back = item->back;
- item->back->forw = item->forw;
-}
-#endif /* USG */
-
-#ifdef USG
-/* There is too much variation in Sys V signal numbers and names, so
- we must initialize them at runtime. */
-static char undoc[] = "(undocumented)";
-
-char *sys_siglist[NSIG];
-#endif /* USG */
-
-extern struct cmd_list_element *setlist;
-
-void
-_initialize_utils ()
-{
- int i;
- add_cmd ("screensize", class_support, set_screensize_command,
- "Change gdb's notion of the size of the output screen.\n\
-The first argument is the number of lines on a page.\n\
-The second argument (optional) is the number of characters on a line.",
- &setlist);
- add_info ("screensize", screensize_info,
- "Show gdb's current notion of the size of the output screen.");
-
- /* These defaults will be used if we are unable to get the correct
- values from termcap. */
- lines_per_page = 24;
- chars_per_line = 80;
- /* Initialize the screen height and width from termcap. */
- {
- int termtype = getenv ("TERM");
-
- /* Positive means success, nonpositive means failure. */
- int status;
-
- /* 2048 is large enough for all known terminals, according to the
- GNU termcap manual. */
- char term_buffer[2048];
-
- if (termtype)
- {
- status = tgetent (term_buffer, termtype);
- if (status > 0)
- {
- int val;
-
- val = tgetnum ("li");
- if (val >= 0)
- lines_per_page = val;
- else
- /* The number of lines per page is not mentioned
- in the terminal description. This probably means
- that paging is not useful (e.g. emacs shell window),
- so disable paging. */
- lines_per_page = 0;
-
- val = tgetnum ("co");
- if (val >= 0)
- chars_per_line = val;
- }
- }
- }
-
-#ifdef USG
- /* Initialize signal names. */
- for (i = 0; i < NSIG; i++)
- sys_siglist[i] = undoc;
-
-#ifdef SIGHUP
- sys_siglist[SIGHUP ] = "SIGHUP";
-#endif
-#ifdef SIGINT
- sys_siglist[SIGINT ] = "SIGINT";
-#endif
-#ifdef SIGQUIT
- sys_siglist[SIGQUIT ] = "SIGQUIT";
-#endif
-#ifdef SIGILL
- sys_siglist[SIGILL ] = "SIGILL";
-#endif
-#ifdef SIGTRAP
- sys_siglist[SIGTRAP ] = "SIGTRAP";
-#endif
-#ifdef SIGIOT
- sys_siglist[SIGIOT ] = "SIGIOT";
-#endif
-#ifdef SIGEMT
- sys_siglist[SIGEMT ] = "SIGEMT";
-#endif
-#ifdef SIGFPE
- sys_siglist[SIGFPE ] = "SIGFPE";
-#endif
-#ifdef SIGKILL
- sys_siglist[SIGKILL ] = "SIGKILL";
-#endif
-#ifdef SIGBUS
- sys_siglist[SIGBUS ] = "SIGBUS";
-#endif
-#ifdef SIGSEGV
- sys_siglist[SIGSEGV ] = "SIGSEGV";
-#endif
-#ifdef SIGSYS
- sys_siglist[SIGSYS ] = "SIGSYS";
-#endif
-#ifdef SIGPIPE
- sys_siglist[SIGPIPE ] = "SIGPIPE";
-#endif
-#ifdef SIGALRM
- sys_siglist[SIGALRM ] = "SIGALRM";
-#endif
-#ifdef SIGTERM
- sys_siglist[SIGTERM ] = "SIGTERM";
-#endif
-#ifdef SIGUSR1
- sys_siglist[SIGUSR1 ] = "SIGUSR1";
-#endif
-#ifdef SIGUSR2
- sys_siglist[SIGUSR2 ] = "SIGUSR2";
-#endif
-#ifdef SIGCLD
- sys_siglist[SIGCLD ] = "SIGCLD";
-#endif
-#ifdef SIGCHLD
- sys_siglist[SIGCHLD ] = "SIGCHLD";
-#endif
-#ifdef SIGPWR
- sys_siglist[SIGPWR ] = "SIGPWR";
-#endif
-#ifdef SIGTSTP
- sys_siglist[SIGTSTP ] = "SIGTSTP";
-#endif
-#ifdef SIGTTIN
- sys_siglist[SIGTTIN ] = "SIGTTIN";
-#endif
-#ifdef SIGTTOU
- sys_siglist[SIGTTOU ] = "SIGTTOU";
-#endif
-#ifdef SIGSTOP
- sys_siglist[SIGSTOP ] = "SIGSTOP";
-#endif
-#ifdef SIGXCPU
- sys_siglist[SIGXCPU ] = "SIGXCPU";
-#endif
-#ifdef SIGXFSZ
- sys_siglist[SIGXFSZ ] = "SIGXFSZ";
-#endif
-#ifdef SIGVTALRM
- sys_siglist[SIGVTALRM ] = "SIGVTALRM";
-#endif
-#ifdef SIGPROF
- sys_siglist[SIGPROF ] = "SIGPROF";
-#endif
-#ifdef SIGWINCH
- sys_siglist[SIGWINCH ] = "SIGWINCH";
-#endif
-#ifdef SIGCONT
- sys_siglist[SIGCONT ] = "SIGCONT";
-#endif
-#ifdef SIGURG
- sys_siglist[SIGURG ] = "SIGURG";
-#endif
-#ifdef SIGIO
- sys_siglist[SIGIO ] = "SIGIO";
-#endif
-#ifdef SIGWIND
- sys_siglist[SIGWIND ] = "SIGWIND";
-#endif
-#ifdef SIGPHONE
- sys_siglist[SIGPHONE ] = "SIGPHONE";
-#endif
-#ifdef SIGPOLL
- sys_siglist[SIGPOLL ] = "SIGPOLL";
-#endif
-#endif /* USG */
-}
diff --git a/gnu/usr.bin/gdb/valarith.c b/gnu/usr.bin/gdb/valarith.c
deleted file mode 100644
index 8e76899..0000000
--- a/gnu/usr.bin/gdb/valarith.c
+++ /dev/null
@@ -1,690 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)valarith.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Perform arithmetic and other operations on values, for GDB.
- Copyright (C) 1986, 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. */
-
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "value.h"
-#include "expression.h"
-
-
-value value_x_binop ();
-value value_subscripted_rvalue ();
-
-value
-value_add (arg1, arg2)
- value arg1, arg2;
-{
- register value val, valint, valptr;
- register int len;
-
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
-
- if ((TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR
- || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR)
- &&
- (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT
- || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_INT))
- /* Exactly one argument is a pointer, and one is an integer. */
- {
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR)
- {
- valptr = arg1;
- valint = arg2;
- }
- else
- {
- valptr = arg2;
- valint = arg1;
- }
- len = TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (valptr)));
- if (len == 0) len = 1; /* For (void *) */
- val = value_from_long (builtin_type_long,
- value_as_long (valptr)
- + (len * value_as_long (valint)));
- VALUE_TYPE (val) = VALUE_TYPE (valptr);
- return val;
- }
-
- return value_binop (arg1, arg2, BINOP_ADD);
-}
-
-value
-value_sub (arg1, arg2)
- value arg1, arg2;
-{
- register value val;
-
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
-
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR
- &&
- TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_INT)
- {
- val = value_from_long (builtin_type_long,
- value_as_long (arg1)
- - TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) * value_as_long (arg2));
- VALUE_TYPE (val) = VALUE_TYPE (arg1);
- return val;
- }
-
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR
- &&
- VALUE_TYPE (arg1) == VALUE_TYPE (arg2))
- {
- val = value_from_long (builtin_type_long,
- (value_as_long (arg1) - value_as_long (arg2))
- / TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))));
- return val;
- }
-
- return value_binop (arg1, arg2, BINOP_SUB);
-}
-
-/* Return the value of ARRAY[IDX]. */
-
-value
-value_subscript (array, idx)
- value array, idx;
-{
- if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_ARRAY
- && VALUE_LVAL (array) != lval_memory)
- return value_subscripted_rvalue (array, idx);
- else
- return value_ind (value_add (array, idx));
-}
-
-/* Return the value of EXPR[IDX], expr an aggregate rvalue
- (eg, a vector register) */
-
-value
-value_subscripted_rvalue (array, idx)
- value array, idx;
-{
- struct type *elt_type = TYPE_TARGET_TYPE (VALUE_TYPE (array));
- int elt_size = TYPE_LENGTH (elt_type);
- int elt_offs = elt_size * value_as_long (idx);
- value v;
-
- if (elt_offs >= TYPE_LENGTH (VALUE_TYPE (array)))
- error ("no such vector element");
-
- if (TYPE_CODE (elt_type) == TYPE_CODE_FLT)
- {
- if (elt_size == sizeof (float))
- v = value_from_double (elt_type, (double) *(float *)
- (VALUE_CONTENTS (array) + elt_offs));
- else
- v = value_from_double (elt_type, *(double *)
- (VALUE_CONTENTS (array) + elt_offs));
- }
- else
- {
- int offs;
- union {int i; char c;} test;
- test.i = 1;
- if (test.c == 1)
- offs = 0;
- else
- offs = sizeof (LONGEST) - elt_size;
- v = value_from_long (elt_type, *(LONGEST *)
- (VALUE_CONTENTS (array) + elt_offs - offs));
- }
-
- if (VALUE_LVAL (array) == lval_internalvar)
- VALUE_LVAL (v) = lval_internalvar_component;
- else
- VALUE_LVAL (v) = not_lval;
- VALUE_ADDRESS (v) = VALUE_ADDRESS (array);
- VALUE_OFFSET (v) = VALUE_OFFSET (array) + elt_offs;
- VALUE_BITSIZE (v) = elt_size * 8;
- return v;
-}
-
-/* Check to see if either argument is a structure. This is called so
- we know whether to go ahead with the normal binop or look for a
- user defined function instead.
-
- For now, we do not overload the `=' operator. */
-
-int
-binop_user_defined_p (op, arg1, arg2)
- enum exp_opcode op;
- value arg1, arg2;
-{
- if (op == BINOP_ASSIGN)
- return 0;
- return (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_STRUCT
- || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_STRUCT
- || (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF
- && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_STRUCT)
- || (TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_REF
- && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_STRUCT));
-}
-
-/* Check to see if argument is a structure. This is called so
- we know whether to go ahead with the normal unop or look for a
- user defined function instead.
-
- For now, we do not overload the `&' operator. */
-
-int unop_user_defined_p (op, arg1)
- enum exp_opcode op;
- value arg1;
-{
- if (op == UNOP_ADDR)
- return 0;
- return (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_STRUCT
- || (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF
- && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_STRUCT));
-}
-
-/* We know either arg1 or arg2 is a structure, so try to find the right
- user defined function. Create an argument vector that calls
- arg1.operator @ (arg1,arg2) and return that value (where '@' is any
- binary operator which is legal for GNU C++). */
-
-value
-value_x_binop (arg1, arg2, op, otherop)
- value arg1, arg2;
- int op, otherop;
-{
- value * argvec;
- char *ptr;
- char tstr[13];
- int static_memfuncp;
-
- COERCE_ENUM (arg1);
- COERCE_ENUM (arg2);
-
- /* now we know that what we have to do is construct our
- arg vector and find the right function to call it with. */
-
- if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_STRUCT)
- error ("friend functions not implemented yet");
-
- argvec = (value *) alloca (sizeof (value) * 4);
- argvec[1] = value_addr (arg1);
- argvec[2] = arg2;
- argvec[3] = 0;
-
- /* make the right function name up */
- strcpy(tstr, "operator __");
- ptr = tstr+9;
- switch (op)
- {
- case BINOP_ADD: strcpy(ptr,"+"); break;
- case BINOP_SUB: strcpy(ptr,"-"); break;
- case BINOP_MUL: strcpy(ptr,"*"); break;
- case BINOP_DIV: strcpy(ptr,"/"); break;
- case BINOP_REM: strcpy(ptr,"%"); break;
- case BINOP_LSH: strcpy(ptr,"<<"); break;
- case BINOP_RSH: strcpy(ptr,">>"); break;
- case BINOP_LOGAND: strcpy(ptr,"&"); break;
- case BINOP_LOGIOR: strcpy(ptr,"|"); break;
- case BINOP_LOGXOR: strcpy(ptr,"^"); break;
- case BINOP_AND: strcpy(ptr,"&&"); break;
- case BINOP_OR: strcpy(ptr,"||"); break;
- case BINOP_MIN: strcpy(ptr,"<?"); break;
- case BINOP_MAX: strcpy(ptr,">?"); break;
- case BINOP_ASSIGN: strcpy(ptr,"="); break;
- case BINOP_ASSIGN_MODIFY:
- switch (otherop)
- {
- case BINOP_ADD: strcpy(ptr,"+="); break;
- case BINOP_SUB: strcpy(ptr,"-="); break;
- case BINOP_MUL: strcpy(ptr,"*="); break;
- case BINOP_DIV: strcpy(ptr,"/="); break;
- case BINOP_REM: strcpy(ptr,"%="); break;
- case BINOP_LOGAND: strcpy(ptr,"&="); break;
- case BINOP_LOGIOR: strcpy(ptr,"|="); break;
- case BINOP_LOGXOR: strcpy(ptr,"^="); break;
- default:
- error ("Invalid binary operation specified.");
- }
- break;
- case BINOP_SUBSCRIPT: strcpy(ptr,"[]"); break;
- case BINOP_EQUAL: strcpy(ptr,"=="); break;
- case BINOP_NOTEQUAL: strcpy(ptr,"!="); break;
- case BINOP_LESS: strcpy(ptr,"<"); break;
- case BINOP_GTR: strcpy(ptr,">"); break;
- case BINOP_GEQ: strcpy(ptr,">="); break;
- case BINOP_LEQ: strcpy(ptr,"<="); break;
- default:
- error ("Invalid binary operation specified.");
- }
- argvec[0] = value_struct_elt (arg1, argvec+1, tstr, &static_memfuncp, "structure");
- if (argvec[0])
- {
- if (static_memfuncp)
- {
- argvec[1] = argvec[0];
- argvec++;
- }
- return call_function (argvec[0], 2 - static_memfuncp, argvec + 1);
- }
- error ("member function %s not found", tstr);
-}
-
-/* We know that arg1 is a structure, so try to find a unary user
- defined operator that matches the operator in question.
- Create an argument vector that calls arg1.operator @ (arg1)
- and return that value (where '@' is (almost) any unary operator which
- is legal for GNU C++). */
-
-value
-value_x_unop (arg1, op)
- value arg1;
- int op;
-{
- value * argvec;
- char *ptr;
- char tstr[13];
- int static_memfuncp;
-
- COERCE_ENUM (arg1);
-
- /* now we know that what we have to do is construct our
- arg vector and find the right function to call it with. */
-
- if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_STRUCT)
- error ("friend functions not implemented yet");
-
- argvec = (value *) alloca (sizeof (value) * 3);
- argvec[1] = value_addr (arg1);
- argvec[2] = 0;
-
- /* make the right function name up */
- strcpy(tstr,"operator __");
- ptr = tstr+9;
- switch (op)
- {
- case UNOP_PREINCREMENT: strcpy(ptr,"++"); break;
- case UNOP_PREDECREMENT: strcpy(ptr,"++"); break;
- case UNOP_POSTINCREMENT: strcpy(ptr,"++"); break;
- case UNOP_POSTDECREMENT: strcpy(ptr,"++"); break;
- case UNOP_ZEROP: strcpy(ptr,"!"); break;
- case UNOP_LOGNOT: strcpy(ptr,"~"); break;
- case UNOP_NEG: strcpy(ptr,"-"); break;
- default:
- error ("Invalid binary operation specified.");
- }
- argvec[0] = value_struct_elt (arg1, argvec+1, tstr, &static_memfuncp, "structure");
- if (argvec[0])
- {
- if (static_memfuncp)
- {
- argvec[1] = argvec[0];
- argvec++;
- }
- return call_function (argvec[0], 1 - static_memfuncp, argvec + 1);
- }
- error ("member function %s not found", tstr);
-}
-
-/* Perform a binary operation on two integers or two floats.
- Does not support addition and subtraction on pointers;
- use value_add or value_sub if you want to handle those possibilities. */
-
-value
-value_binop (arg1, arg2, op)
- value arg1, arg2;
- int op;
-{
- register value val;
-
- COERCE_ENUM (arg1);
- COERCE_ENUM (arg2);
-
- if ((TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_FLT
- &&
- TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT)
- ||
- (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_FLT
- &&
- TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT))
- error ("Argument to arithmetic operation not a number.");
-
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_FLT
- ||
- TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_FLT)
- {
- double v1, v2, v;
- v1 = value_as_double (arg1);
- v2 = value_as_double (arg2);
- switch (op)
- {
- case BINOP_ADD:
- v = v1 + v2;
- break;
-
- case BINOP_SUB:
- v = v1 - v2;
- break;
-
- case BINOP_MUL:
- v = v1 * v2;
- break;
-
- case BINOP_DIV:
- v = v1 / v2;
- break;
-
- default:
- error ("Integer-only operation on floating point number.");
- }
-
- val = allocate_value (builtin_type_double);
- *(double *) VALUE_CONTENTS (val) = v;
- }
- else
- /* Integral operations here. */
- {
- /* Should we promote to unsigned longest? */
- if ((TYPE_UNSIGNED (VALUE_TYPE (arg1))
- || TYPE_UNSIGNED (VALUE_TYPE (arg2)))
- && (TYPE_LENGTH (VALUE_TYPE (arg1)) >= sizeof (unsigned LONGEST)
- || TYPE_LENGTH (VALUE_TYPE (arg2)) >= sizeof (unsigned LONGEST)))
- {
- unsigned LONGEST v1, v2, v;
- v1 = (unsigned LONGEST) value_as_long (arg1);
- v2 = (unsigned LONGEST) value_as_long (arg2);
-
- switch (op)
- {
- case BINOP_ADD:
- v = v1 + v2;
- break;
-
- case BINOP_SUB:
- v = v1 - v2;
- break;
-
- case BINOP_MUL:
- v = v1 * v2;
- break;
-
- case BINOP_DIV:
- v = v1 / v2;
- break;
-
- case BINOP_REM:
- v = v1 % v2;
- break;
-
- case BINOP_LSH:
- v = v1 << v2;
- break;
-
- case BINOP_RSH:
- v = v1 >> v2;
- break;
-
- case BINOP_LOGAND:
- v = v1 & v2;
- break;
-
- case BINOP_LOGIOR:
- v = v1 | v2;
- break;
-
- case BINOP_LOGXOR:
- v = v1 ^ v2;
- break;
-
- case BINOP_AND:
- v = v1 && v2;
- break;
-
- case BINOP_OR:
- v = v1 || v2;
- break;
-
- case BINOP_MIN:
- v = v1 < v2 ? v1 : v2;
- break;
-
- case BINOP_MAX:
- v = v1 > v2 ? v1 : v2;
- break;
-
- default:
- error ("Invalid binary operation on numbers.");
- }
-
- val = allocate_value (BUILTIN_TYPE_UNSIGNED_LONGEST);
- *(unsigned LONGEST *) VALUE_CONTENTS (val) = v;
- }
- else
- {
- LONGEST v1, v2, v;
- v1 = value_as_long (arg1);
- v2 = value_as_long (arg2);
-
- switch (op)
- {
- case BINOP_ADD:
- v = v1 + v2;
- break;
-
- case BINOP_SUB:
- v = v1 - v2;
- break;
-
- case BINOP_MUL:
- v = v1 * v2;
- break;
-
- case BINOP_DIV:
- v = v1 / v2;
- break;
-
- case BINOP_REM:
- v = v1 % v2;
- break;
-
- case BINOP_LSH:
- v = v1 << v2;
- break;
-
- case BINOP_RSH:
- v = v1 >> v2;
- break;
-
- case BINOP_LOGAND:
- v = v1 & v2;
- break;
-
- case BINOP_LOGIOR:
- v = v1 | v2;
- break;
-
- case BINOP_LOGXOR:
- v = v1 ^ v2;
- break;
-
- case BINOP_AND:
- v = v1 && v2;
- break;
-
- case BINOP_OR:
- v = v1 || v2;
- break;
-
- case BINOP_MIN:
- v = v1 < v2 ? v1 : v2;
- break;
-
- case BINOP_MAX:
- v = v1 > v2 ? v1 : v2;
- break;
-
- default:
- error ("Invalid binary operation on numbers.");
- }
-
- val = allocate_value (BUILTIN_TYPE_LONGEST);
- *(LONGEST *) VALUE_CONTENTS (val) = v;
- }
- }
-
- return val;
-}
-
-/* Simulate the C operator ! -- return 1 if ARG1 contains zeros. */
-
-int
-value_zerop (arg1)
- value arg1;
-{
- register int len;
- register char *p;
-
- COERCE_ARRAY (arg1);
-
- len = TYPE_LENGTH (VALUE_TYPE (arg1));
- p = VALUE_CONTENTS (arg1);
-
- while (--len >= 0)
- {
- if (*p++)
- break;
- }
-
- return len < 0;
-}
-
-/* Simulate the C operator == by returning a 1
- iff ARG1 and ARG2 have equal contents. */
-
-int
-value_equal (arg1, arg2)
- register value arg1, arg2;
-
-{
- register int len;
- register char *p1, *p2;
- enum type_code code1;
- enum type_code code2;
-
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
-
- code1 = TYPE_CODE (VALUE_TYPE (arg1));
- code2 = TYPE_CODE (VALUE_TYPE (arg2));
-
- if (code1 == TYPE_CODE_INT && code2 == TYPE_CODE_INT)
- return value_as_long (arg1) == value_as_long (arg2);
- else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT)
- && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT))
- return value_as_double (arg1) == value_as_double (arg2);
- else if ((code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_INT)
- || (code2 == TYPE_CODE_PTR && code1 == TYPE_CODE_INT))
- return (char *) value_as_long (arg1) == (char *) value_as_long (arg2);
- else if (code1 == code2
- && ((len = TYPE_LENGTH (VALUE_TYPE (arg1)))
- == TYPE_LENGTH (VALUE_TYPE (arg2))))
- {
- p1 = VALUE_CONTENTS (arg1);
- p2 = VALUE_CONTENTS (arg2);
- while (--len >= 0)
- {
- if (*p1++ != *p2++)
- break;
- }
- return len < 0;
- }
- else
- error ("Invalid type combination in equality test.");
-}
-
-/* Simulate the C operator < by returning 1
- iff ARG1's contents are less than ARG2's. */
-
-int
-value_less (arg1, arg2)
- register value arg1, arg2;
-{
- register enum type_code code1;
- register enum type_code code2;
-
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
-
- code1 = TYPE_CODE (VALUE_TYPE (arg1));
- code2 = TYPE_CODE (VALUE_TYPE (arg2));
-
- if (code1 == TYPE_CODE_INT && code2 == TYPE_CODE_INT)
- return value_as_long (arg1) < value_as_long (arg2);
- else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT)
- && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT))
- return value_as_double (arg1) < value_as_double (arg2);
- else if ((code1 == TYPE_CODE_PTR || code1 == TYPE_CODE_INT)
- && (code2 == TYPE_CODE_PTR || code2 == TYPE_CODE_INT))
- return (char *) value_as_long (arg1) < (char *) value_as_long (arg2);
- else
- error ("Invalid type combination in ordering comparison.");
-}
-
-/* The unary operators - and ~. Both free the argument ARG1. */
-
-value
-value_neg (arg1)
- register value arg1;
-{
- register struct type *type;
-
- COERCE_ENUM (arg1);
-
- type = VALUE_TYPE (arg1);
-
- if (TYPE_CODE (type) == TYPE_CODE_FLT)
- return value_from_double (type, - value_as_double (arg1));
- else if (TYPE_CODE (type) == TYPE_CODE_INT)
- return value_from_long (type, - value_as_long (arg1));
- else
- error ("Argument to negate operation not a number.");
-}
-
-value
-value_lognot (arg1)
- register value arg1;
-{
- COERCE_ENUM (arg1);
-
- if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT)
- error ("Argument to complement operation not an integer.");
-
- return value_from_long (VALUE_TYPE (arg1), ~ value_as_long (arg1));
-}
-
diff --git a/gnu/usr.bin/gdb/valops.c b/gnu/usr.bin/gdb/valops.c
deleted file mode 100644
index ab5652c..0000000
--- a/gnu/usr.bin/gdb/valops.c
+++ /dev/null
@@ -1,1418 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)valops.c 6.4 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Perform non-arithmetic operations on values, for GDB.
- 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. */
-
-#include "stdio.h"
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "value.h"
-#include "frame.h"
-#include "inferior.h"
-
-/* Cast value ARG2 to type TYPE and return as a value.
- More general than a C cast: accepts any two types of the same length,
- and if ARG2 is an lvalue it can be cast into anything at all. */
-
-value
-value_cast (type, arg2)
- struct type *type;
- register value arg2;
-{
- register enum type_code code1;
- register enum type_code code2;
- register int scalar;
-
- /* Coerce arrays but not enums. Enums will work as-is
- and coercing them would cause an infinite recursion. */
- if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_ENUM)
- COERCE_ARRAY (arg2);
-
- code1 = TYPE_CODE (type);
- code2 = TYPE_CODE (VALUE_TYPE (arg2));
- scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_FLT
- || code2 == TYPE_CODE_ENUM);
-
- if (code1 == TYPE_CODE_FLT && scalar)
- return value_from_double (type, value_as_double (arg2));
- else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM)
- && (scalar || code2 == TYPE_CODE_PTR))
- return value_from_long (type, value_as_long (arg2));
- else if (TYPE_LENGTH (type) == TYPE_LENGTH (VALUE_TYPE (arg2)))
- {
- VALUE_TYPE (arg2) = type;
- return arg2;
- }
- else if (VALUE_LVAL (arg2) == lval_memory)
- {
- return value_at (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2));
- }
- else
- error ("Invalid cast.");
-}
-
-/* Create a value of type TYPE that is zero, and return it. */
-
-value
-value_zero (type, lv)
- struct type *type;
- enum lval_type lv;
-{
- register value val = allocate_value (type);
-
- bzero (VALUE_CONTENTS (val), TYPE_LENGTH (type));
- VALUE_LVAL (val) = lv;
-
- return val;
-}
-
-/* Return the value with a specified type located at specified address. */
-
-value
-value_at (type, addr)
- struct type *type;
- CORE_ADDR addr;
-{
- register value val = allocate_value (type);
- int temp;
-
- temp = read_memory (addr, VALUE_CONTENTS (val), TYPE_LENGTH (type));
- if (temp)
- {
- if (have_inferior_p () && !remote_debugging)
- print_sys_errmsg ("ptrace", temp);
- /* Actually, address between addr and addr + len was out of bounds. */
- error ("Cannot read memory: address 0x%x out of bounds.", addr);
- }
-
- VALUE_LVAL (val) = lval_memory;
- VALUE_ADDRESS (val) = addr;
-
- return val;
-}
-
-/* Store the contents of FROMVAL into the location of TOVAL.
- Return a new value with the location of TOVAL and contents of FROMVAL. */
-
-value
-value_assign (toval, fromval)
- register value toval, fromval;
-{
- register struct type *type = VALUE_TYPE (toval);
- register value val;
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
- int use_buffer = 0;
-
- extern CORE_ADDR find_saved_register ();
-
- COERCE_ARRAY (fromval);
-
- if (VALUE_LVAL (toval) != lval_internalvar)
- fromval = value_cast (type, fromval);
-
- /* If TOVAL is a special machine register requiring conversion
- of program values to a special raw format,
- convert FROMVAL's contents now, with result in `raw_buffer',
- and set USE_BUFFER to the number of bytes to write. */
-
- if (VALUE_REGNO (toval) >= 0
- && REGISTER_CONVERTIBLE (VALUE_REGNO (toval)))
- {
- int regno = VALUE_REGNO (toval);
- if (VALUE_TYPE (fromval) != REGISTER_VIRTUAL_TYPE (regno))
- fromval = value_cast (REGISTER_VIRTUAL_TYPE (regno), fromval);
- bcopy (VALUE_CONTENTS (fromval), virtual_buffer,
- REGISTER_VIRTUAL_SIZE (regno));
- REGISTER_CONVERT_TO_RAW (regno, virtual_buffer, raw_buffer);
- use_buffer = REGISTER_RAW_SIZE (regno);
- }
-
- switch (VALUE_LVAL (toval))
- {
- case lval_internalvar:
- set_internalvar (VALUE_INTERNALVAR (toval), fromval);
- break;
-
- case lval_internalvar_component:
- set_internalvar_component (VALUE_INTERNALVAR (toval),
- VALUE_OFFSET (toval),
- VALUE_BITPOS (toval),
- VALUE_BITSIZE (toval),
- fromval);
- break;
-
- case lval_memory:
- if (VALUE_BITSIZE (toval))
- {
- int val;
- read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- &val, sizeof val);
- modify_field (&val, (int) value_as_long (fromval),
- VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
- write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- &val, sizeof val);
- }
- else if (use_buffer)
- write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- raw_buffer, use_buffer);
- else
- write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- VALUE_CONTENTS (fromval), TYPE_LENGTH (type));
- break;
-
- case lval_register:
- if (VALUE_BITSIZE (toval))
- {
- int val;
-
- read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- &val, sizeof val);
- modify_field (&val, (int) value_as_long (fromval),
- VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
- write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- &val, sizeof val);
- }
- else if (use_buffer)
- write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- raw_buffer, use_buffer);
- else
- write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- VALUE_CONTENTS (fromval), TYPE_LENGTH (type));
- break;
-
- case lval_reg_frame_relative:
- {
- /* value is stored in a series of registers in the frame
- specified by the structure. Copy that value out, modify
- it, and copy it back in. */
- int amount_to_copy = (VALUE_BITSIZE (toval) ? 1 : TYPE_LENGTH (type));
- int reg_size = REGISTER_RAW_SIZE (VALUE_FRAME_REGNUM (toval));
- int byte_offset = VALUE_OFFSET (toval) % reg_size;
- int reg_offset = VALUE_OFFSET (toval) / reg_size;
- int amount_copied;
- char *buffer = (char *) alloca (amount_to_copy);
- int regno;
- FRAME frame;
- CORE_ADDR addr;
-
- /* Figure out which frame this is in currently. */
- for (frame = get_current_frame ();
- frame && FRAME_FP (frame) != VALUE_FRAME (toval);
- frame = get_prev_frame (frame))
- ;
-
- if (!frame)
- error ("Value being assigned to is no longer active.");
-
- amount_to_copy += (reg_size - amount_to_copy % reg_size);
-
- /* Copy it out. */
- for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset,
- amount_copied = 0);
- amount_copied < amount_to_copy;
- amount_copied += reg_size, regno++)
- {
- addr = find_saved_register (frame, regno);
- if (addr == 0)
- read_register_bytes (REGISTER_BYTE (regno),
- buffer + amount_copied,
- reg_size);
- else
- read_memory (addr, buffer + amount_copied, reg_size);
- }
-
- /* Modify what needs to be modified. */
- if (VALUE_BITSIZE (toval))
- modify_field (buffer + byte_offset,
- (int) value_as_long (fromval),
- VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
- else if (use_buffer)
- bcopy (raw_buffer, buffer + byte_offset, use_buffer);
- else
- bcopy (VALUE_CONTENTS (fromval), buffer + byte_offset,
- TYPE_LENGTH (type));
-
- /* Copy it back. */
- for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset,
- amount_copied = 0);
- amount_copied < amount_to_copy;
- amount_copied += reg_size, regno++)
- {
- addr = find_saved_register (frame, regno);
- if (addr == 0)
- write_register_bytes (REGISTER_BYTE (regno),
- buffer + amount_copied,
- reg_size);
- else
- write_memory (addr, buffer + amount_copied, reg_size);
- }
- }
- break;
-
-
- default:
- error ("Left side of = operation is not an lvalue.");
- }
-
- /* Return a value just like TOVAL except with the contents of FROMVAL
- (except in the case of the type if TOVAL is an internalvar). */
-
- if (VALUE_LVAL (toval) == lval_internalvar
- || VALUE_LVAL (toval) == lval_internalvar_component)
- {
- type = VALUE_TYPE (fromval);
- }
-
- val = allocate_value (type);
- bcopy (toval, val, VALUE_CONTENTS (val) - (char *) val);
- bcopy (VALUE_CONTENTS (fromval), VALUE_CONTENTS (val), TYPE_LENGTH (type));
- VALUE_TYPE (val) = type;
-
- return val;
-}
-
-/* Extend a value VAL to COUNT repetitions of its type. */
-
-value
-value_repeat (arg1, count)
- value arg1;
- int count;
-{
- register value val;
-
- if (VALUE_LVAL (arg1) != lval_memory)
- error ("Only values in memory can be extended with '@'.");
- if (count < 1)
- error ("Invalid number %d of repetitions.", count);
-
- val = allocate_repeat_value (VALUE_TYPE (arg1), count);
-
- read_memory (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1),
- VALUE_CONTENTS (val),
- TYPE_LENGTH (VALUE_TYPE (val)) * count);
- VALUE_LVAL (val) = lval_memory;
- VALUE_ADDRESS (val) = VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1);
-
- return val;
-}
-
-value
-value_of_variable (var)
- struct symbol *var;
-{
- return read_var_value (var, (FRAME) 0);
-}
-
-/* Given a value which is an array, return a value which is
- a pointer to its first element. */
-
-value
-value_coerce_array (arg1)
- value arg1;
-{
- register struct type *type;
- register value val;
-
- if (VALUE_LVAL (arg1) != lval_memory)
- error ("Attempt to take address of value not located in memory.");
-
- /* Get type of elements. */
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY)
- type = TYPE_TARGET_TYPE (VALUE_TYPE (arg1));
- else
- /* A phony array made by value_repeat.
- Its type is the type of the elements, not an array type. */
- type = VALUE_TYPE (arg1);
-
- /* Get the type of the result. */
- type = lookup_pointer_type (type);
- val = value_from_long (builtin_type_long,
- (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
- VALUE_TYPE (val) = type;
- return val;
-}
-
-/* Return a pointer value for the object for which ARG1 is the contents. */
-
-value
-value_addr (arg1)
- value arg1;
-{
- register struct type *type;
- register value val, arg1_coerced;
-
- /* Taking the address of an array is really a no-op
- once the array is coerced to a pointer to its first element. */
- arg1_coerced = arg1;
- COERCE_ARRAY (arg1_coerced);
- if (arg1 != arg1_coerced)
- return arg1_coerced;
-
- if (VALUE_LVAL (arg1) != lval_memory)
- error ("Attempt to take address of value not located in memory.");
-
- /* Get the type of the result. */
- type = lookup_pointer_type (VALUE_TYPE (arg1));
- val = value_from_long (builtin_type_long,
- (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1)));
- VALUE_TYPE (val) = type;
- return val;
-}
-
-/* Given a value of a pointer type, apply the C unary * operator to it. */
-
-value
-value_ind (arg1)
- value arg1;
-{
- /* Must do this before COERCE_ARRAY, otherwise an infinite loop
- will result */
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF)
- return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
- (CORE_ADDR) value_as_long (arg1));
-
- COERCE_ARRAY (arg1);
-
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_MEMBER)
- error ("not implemented: member types in value_ind");
-
- /* Allow * on an integer so we can cast it to whatever we want.
- This returns an int, which seems like the most C-like thing
- to do. "long long" variables are rare enough that
- BUILTIN_TYPE_LONGEST would seem to be a mistake. */
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT)
- return value_at (builtin_type_int,
- (CORE_ADDR) value_as_long (arg1));
- else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR)
- return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
- (CORE_ADDR) value_as_long (arg1));
- else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF)
- return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
- (CORE_ADDR) value_as_long (arg1));
- error ("Attempt to take contents of a non-pointer value.");
-}
-
-/* Pushing small parts of stack frames. */
-
-/* Push one word (the size of object that a register holds). */
-
-CORE_ADDR
-push_word (sp, buffer)
- CORE_ADDR sp;
- REGISTER_TYPE buffer;
-{
- register int len = sizeof (REGISTER_TYPE);
-
-#if 1 INNER_THAN 2
- sp -= len;
- write_memory (sp, &buffer, len);
-#else /* stack grows upward */
- write_memory (sp, &buffer, len);
- sp += len;
-#endif /* stack grows upward */
-
- return sp;
-}
-
-/* Push LEN bytes with data at BUFFER. */
-
-CORE_ADDR
-push_bytes (sp, buffer, len)
- CORE_ADDR sp;
- char *buffer;
- int len;
-{
-#if 1 INNER_THAN 2
- sp -= len;
- write_memory (sp, buffer, len);
-#else /* stack grows upward */
- write_memory (sp, buffer, len);
- sp += len;
-#endif /* stack grows upward */
-
- return sp;
-}
-
-/* Push onto the stack the specified value VALUE. */
-
-CORE_ADDR
-value_push (sp, arg)
- register CORE_ADDR sp;
- value arg;
-{
- register int len = TYPE_LENGTH (VALUE_TYPE (arg));
-
-#if 1 INNER_THAN 2
- sp -= len;
- write_memory (sp, VALUE_CONTENTS (arg), len);
-#else /* stack grows upward */
- write_memory (sp, VALUE_CONTENTS (arg), len);
- sp += len;
-#endif /* stack grows upward */
-
- return sp;
-}
-
-/* Perform the standard coercions that are specified
- for arguments to be passed to C functions. */
-
-value
-value_arg_coerce (arg)
- value arg;
-{
- register struct type *type;
-
- COERCE_ENUM (arg);
-
- type = VALUE_TYPE (arg);
-
- if (TYPE_CODE (type) == TYPE_CODE_INT
- && TYPE_LENGTH (type) < sizeof (int))
- return value_cast (builtin_type_int, arg);
-
- if (type == builtin_type_float)
- return value_cast (builtin_type_double, arg);
-
- return arg;
-}
-
-/* Push the value ARG, first coercing it as an argument
- to a C function. */
-
-CORE_ADDR
-value_arg_push (sp, arg)
- register CORE_ADDR sp;
- value arg;
-{
- return value_push (sp, value_arg_coerce (arg));
-}
-
-#ifdef NEW_CALL_FUNCTION
-
-int
-arg_stacklen(nargs, args)
- int nargs;
- value *args;
-{
- int len = 0;
-
- while (--nargs >= 0)
- len += TYPE_LENGTH(VALUE_TYPE(value_arg_coerce(args[nargs])));
-
- return len;
-}
-
-CORE_ADDR
-function_address(function, type)
- value function;
- struct type **type;
-{
- register CORE_ADDR funaddr;
- register struct type *ftype = VALUE_TYPE(function);
- register enum type_code code = TYPE_CODE(ftype);
-
- /*
- * If it's a member function, just look at the function part
- * of it.
- */
-
- /* Determine address to call. */
- if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD) {
- funaddr = VALUE_ADDRESS(function);
- *type = TYPE_TARGET_TYPE(ftype);
- } else if (code == TYPE_CODE_PTR) {
- funaddr = value_as_long(function);
- if (TYPE_CODE(TYPE_TARGET_TYPE(ftype)) == TYPE_CODE_FUNC
- || TYPE_CODE(TYPE_TARGET_TYPE(ftype)) == TYPE_CODE_METHOD)
- *type = TYPE_TARGET_TYPE(TYPE_TARGET_TYPE(ftype));
- else
- *type = builtin_type_int;
- } else if (code == TYPE_CODE_INT) {
- /*
- * Handle the case of functions lacking debugging
- * info. Their values are characters since their
- * addresses are char
- */
- if (TYPE_LENGTH(ftype) == 1)
-
- funaddr = value_as_long(value_addr(function));
- else
- /*
- * Handle integer used as address of a
- * function.
- */
- funaddr = value_as_long(function);
-
- *type = builtin_type_int;
- } else
- error("Invalid data type for function to be called.");
-
- return funaddr;
-}
-
-/* Perform a function call in the inferior.
- ARGS is a vector of values of arguments (NARGS of them).
- FUNCTION is a value, the function to be called.
- Returns a value representing what the function returned.
- May fail to return, if a breakpoint or signal is hit
- during the execution of the function. */
-
-value
-call_function(function, nargs, args)
- value function;
- int nargs;
- value *args;
-{
- register CORE_ADDR sp, pc;
- struct type *value_type;
- struct inferior_status inf_status;
- struct cleanup *old_chain;
- register CORE_ADDR funaddr;
- int struct_return_bytes;
- char retbuf[REGISTER_BYTES];
-
- if (!have_inferior_p())
- error("Cannot invoke functions if the inferior is not running.");
-
- save_inferior_status(&inf_status, 1);
- old_chain = make_cleanup(restore_inferior_status, &inf_status);
-
- sp = read_register(SP_REGNUM);
- funaddr = function_address(function, &value_type);
- /*
- * Are we returning a value using a structure return or a
- * normal value return?
- */
- if (using_struct_return(function, funaddr, value_type))
- struct_return_bytes = TYPE_LENGTH(value_type);
- else
- struct_return_bytes = 0;
- /*
- * Create a call sequence customized for this function and
- * the number of arguments for it.
- */
- pc = setup_dummy(sp, funaddr, nargs, args,
- struct_return_bytes, value_arg_push);
-
- /*
- * Execute the stack dummy stub. The register state will be
- * returned in retbuf. It is restored below.
- */
- run_stack_dummy(pc, retbuf);
-
- /*
- * This will restore the register context that existed before
- * we called the dummy function.
- */
- do_cleanups(old_chain);
-
- return value_being_returned(value_type, retbuf, struct_return_bytes);
-}
-#else
-
-/* Perform a function call in the inferior.
- ARGS is a vector of values of arguments (NARGS of them).
- FUNCTION is a value, the function to be called.
- Returns a value representing what the function returned.
- May fail to return, if a breakpoint or signal is hit
- during the execution of the function. */
-
-value
-call_function (function, nargs, args)
- value function;
- int nargs;
- value *args;
-{
- register CORE_ADDR sp;
- register int i;
- CORE_ADDR start_sp;
- static REGISTER_TYPE dummy[] = CALL_DUMMY;
- REGISTER_TYPE dummy1[sizeof dummy / sizeof (REGISTER_TYPE)];
- CORE_ADDR old_sp;
- struct type *value_type;
- unsigned char struct_return;
- CORE_ADDR struct_addr;
- struct inferior_status inf_status;
- struct cleanup *old_chain;
-
- if (!have_inferior_p ())
- error ("Cannot invoke functions if the inferior is not running.");
-
- save_inferior_status (&inf_status, 1);
- old_chain = make_cleanup (restore_inferior_status, &inf_status);
-
- /* PUSH_DUMMY_FRAME is responsible for saving the inferior registers
- (and POP_FRAME for restoring them). (At least on most machines)
- they are saved on the stack in the inferior. */
- PUSH_DUMMY_FRAME;
-
- old_sp = sp = read_register (SP_REGNUM);
-
-#if 1 INNER_THAN 2 /* Stack grows down */
- sp -= sizeof dummy;
- start_sp = sp;
-#else /* Stack grows up */
- start_sp = sp;
- sp += sizeof dummy;
-#endif
-
- {
- register CORE_ADDR funaddr;
- register struct type *ftype = VALUE_TYPE (function);
- register enum type_code code = TYPE_CODE (ftype);
-
- /* If it's a member function, just look at the function
- part of it. */
-
- /* Determine address to call. */
- if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
- {
- funaddr = VALUE_ADDRESS (function);
- value_type = TYPE_TARGET_TYPE (ftype);
- }
- else if (code == TYPE_CODE_PTR)
- {
- funaddr = value_as_long (function);
- if (TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_FUNC
- || TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_METHOD)
- value_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype));
- else
- value_type = builtin_type_int;
- }
- else if (code == TYPE_CODE_INT)
- {
- /* Handle the case of functions lacking debugging info.
- Their values are characters since their addresses are char */
- if (TYPE_LENGTH (ftype) == 1)
- funaddr = value_as_long (value_addr (function));
- else
- /* Handle integer used as address of a function. */
- funaddr = value_as_long (function);
-
- value_type = builtin_type_int;
- }
- else
- error ("Invalid data type for function to be called.");
-
- /* Are we returning a value using a structure return or a normal
- value return? */
-
- struct_return = using_struct_return (function, funaddr, value_type);
-
- /* Create a call sequence customized for this function
- and the number of arguments for it. */
- bcopy (dummy, dummy1, sizeof dummy);
- FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, value_type);
- }
-
-#ifndef CANNOT_EXECUTE_STACK
- write_memory (start_sp, dummy1, sizeof dummy);
-
-#else
- /* Convex Unix prohibits executing in the stack segment. */
- /* Hope there is empty room at the top of the text segment. */
- {
- extern CORE_ADDR text_end;
- static checked = 0;
- if (!checked)
- for (start_sp = text_end - sizeof dummy; start_sp < text_end; ++start_sp)
- if (read_memory_integer (start_sp, 1) != 0)
- error ("text segment full -- no place to put call");
- checked = 1;
- sp = old_sp;
- start_sp = text_end - sizeof dummy;
- write_memory (start_sp, dummy1, sizeof dummy);
- }
-#endif /* CANNOT_EXECUTE_STACK */
-#ifdef STACK_ALIGN
- /* If stack grows down, we must leave a hole at the top. */
- {
- int len = 0;
-
- /* Reserve space for the return structure to be written on the
- stack, if necessary */
-
- if (struct_return)
- len += TYPE_LENGTH (value_type);
-
- for (i = nargs - 1; i >= 0; i--)
- len += TYPE_LENGTH (VALUE_TYPE (value_arg_coerce (args[i])));
-#ifdef CALL_DUMMY_STACK_ADJUST
- len += CALL_DUMMY_STACK_ADJUST;
-#endif
-#if 1 INNER_THAN 2
- sp -= STACK_ALIGN (len) - len;
-#else
- sp += STACK_ALIGN (len) - len;
-#endif
- }
-#endif /* STACK_ALIGN */
-
- /* Reserve space for the return structure to be written on the
- stack, if necessary */
-
- if (struct_return)
- {
-#if 1 INNER_THAN 2
- sp -= TYPE_LENGTH (value_type);
- struct_addr = sp;
-#else
- struct_addr = sp;
- sp += TYPE_LENGTH (value_type);
-#endif
- }
-
- for (i = nargs - 1; i >= 0; i--)
- sp = value_arg_push (sp, args[i]);
-
-#ifdef CALL_DUMMY_STACK_ADJUST
-#if 1 INNER_THAN 2
- sp -= CALL_DUMMY_STACK_ADJUST;
-#else
- sp += CALL_DUMMY_STACK_ADJUST;
-#endif
-#endif /* CALL_DUMMY_STACK_ADJUST */
-
- /* Store the address at which the structure is supposed to be
- written. Note that this (and the code which reserved the space
- above) assumes that gcc was used to compile this function. Since
- it doesn't cost us anything but space and if the function is pcc
- it will ignore this value, we will make that assumption.
-
- Also note that on some machines (like the sparc) pcc uses this
- convention in a slightly twisted way also. */
-
- if (struct_return)
- STORE_STRUCT_RETURN (struct_addr, sp);
-
- /* Write the stack pointer. This is here because the statement above
- might fool with it */
- write_register (SP_REGNUM, sp);
-
- /* Figure out the value returned by the function. */
- {
- char retbuf[REGISTER_BYTES];
-
- /* Execute the stack dummy routine, calling FUNCTION.
- When it is done, discard the empty frame
- after storing the contents of all regs into retbuf. */
- run_stack_dummy (start_sp + CALL_DUMMY_START_OFFSET, retbuf);
-
- do_cleanups (old_chain);
-
- return value_being_returned (value_type, retbuf, struct_return);
- }
-}
-#endif
-
-/* Create a value for a string constant:
- Call the function malloc in the inferior to get space for it,
- then copy the data into that space
- and then return the address with type char *.
- PTR points to the string constant data; LEN is number of characters. */
-
-value
-value_string (ptr, len)
- char *ptr;
- int len;
-{
- register value val;
- register struct symbol *sym;
- value blocklen;
- register char *copy = (char *) alloca (len + 1);
- char *i = ptr;
- register char *o = copy, *ibeg = ptr;
- register int c;
-#ifdef KERNELDEBUG
- extern int kernel_debugging;
-
- if (kernel_debugging)
- error("Can't stuff string constants into kernel (yet).");
-#endif
-
- /* Copy the string into COPY, processing escapes.
- We could not conveniently process them in expread
- because the string there wants to be a substring of the input. */
-
- while (i - ibeg < len)
- {
- c = *i++;
- if (c == '\\')
- {
- c = parse_escape (&i);
- if (c == -1)
- continue;
- }
- *o++ = c;
- }
- *o = 0;
-
- /* Get the length of the string after escapes are processed. */
-
- len = o - copy;
-
- /* Find the address of malloc in the inferior. */
-
- sym = lookup_symbol ("malloc", 0, VAR_NAMESPACE, 0);
- if (sym != 0)
- {
- if (SYMBOL_CLASS (sym) != LOC_BLOCK)
- error ("\"malloc\" exists in this program but is not a function.");
- val = value_of_variable (sym);
- }
- else
- {
- register int i;
- for (i = 0; i < misc_function_count; i++)
- if (!strcmp (misc_function_vector[i].name, "malloc"))
- break;
- if (i < misc_function_count)
- val = value_from_long (builtin_type_long,
- (LONGEST) misc_function_vector[i].address);
- else
- error ("String constants require the program to have a function \"malloc\".");
- }
-
- blocklen = value_from_long (builtin_type_int, (LONGEST) (len + 1));
- val = call_function (val, 1, &blocklen);
- if (value_zerop (val))
- error ("No memory available for string constant.");
- write_memory ((CORE_ADDR) value_as_long (val), copy, len + 1);
- VALUE_TYPE (val) = lookup_pointer_type (builtin_type_char);
- return val;
-}
-
-static int
-type_field_index(t, name)
- register struct type *t;
- register char *name;
-{
- register int i;
-
- for (i = TYPE_NFIELDS(t); --i >= 0;)
- {
- register char *t_field_name = TYPE_FIELD_NAME (t, i);
-
- if (t_field_name && !strcmp (t_field_name, name))
- break;
- }
- return (i);
-}
-
-/* Given ARG1, a value of type (pointer to a)* structure/union,
- extract the component named NAME from the ultimate target structure/union
- and return it as a value with its appropriate type.
- ERR is used in the error message if ARG1's type is wrong.
-
- C++: ARGS is a list of argument types to aid in the selection of
- an appropriate method. Also, handle derived types.
-
- STATIC_MEMFUNCP, if non-NULL, points to a caller-supplied location
- where the truthvalue of whether the function that was resolved was
- a static member function or not.
-
- ERR is an error message to be printed in case the field is not found. */
-
-value
-value_struct_elt (arg1, args, name, static_memfuncp, err)
- register value arg1, *args;
- char *name;
- int *static_memfuncp;
- char *err;
-{
- register struct type *t;
- register int i;
- int found = 0;
-
- struct type *baseclass;
-
- COERCE_ARRAY (arg1);
-
- t = VALUE_TYPE (arg1);
-
- /* Check for the usual case: we have pointer, target type is a struct
- * and `name' is a legal field of the struct. In this case, we can
- * just snarf the value of the field & not waste time while value_ind
- * sucks over the entire struct. */
- if (! args)
- {
- if (TYPE_CODE(t) == TYPE_CODE_PTR
- && (TYPE_CODE((baseclass = TYPE_TARGET_TYPE(t))) == TYPE_CODE_STRUCT
- || TYPE_CODE(baseclass) == TYPE_CODE_UNION)
- && (i = type_field_index(baseclass, name)) >= 0)
- {
- register int offset;
- register struct type *f = TYPE_FIELD_TYPE(baseclass, i);
-
- offset = TYPE_FIELD_BITPOS(baseclass, i) >> 3;
- if (TYPE_FIELD_BITSIZE(baseclass, i) == 0)
- return value_at(f, (CORE_ADDR)(value_as_long(arg1) + offset));
- }
- }
-
- /* Follow pointers until we get to a non-pointer. */
-
- while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
- {
- arg1 = value_ind (arg1);
- COERCE_ARRAY (arg1);
- t = VALUE_TYPE (arg1);
- }
-
- if (TYPE_CODE (t) == TYPE_CODE_MEMBER)
- error ("not implemented: member type in value_struct_elt");
-
- if (TYPE_CODE (t) != TYPE_CODE_STRUCT
- && TYPE_CODE (t) != TYPE_CODE_UNION)
- error ("Attempt to extract a component of a value that is not a %s.", err);
-
- baseclass = t;
-
- /* Assume it's not, unless we see that it is. */
- if (static_memfuncp)
- *static_memfuncp =0;
-
- if (!args)
- {
- /* if there are no arguments ...do this... */
-
- /* Try as a variable first, because if we succeed, there
- is less work to be done. */
- while (t)
- {
- i = type_field_index(t, name);
- if (i >= 0)
- return TYPE_FIELD_STATIC (t, i)
- ? value_static_field (t, name, i) : value_field (arg1, i);
-
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- VALUE_TYPE (arg1) = t; /* side effect! */
- }
-
- /* C++: If it was not found as a data field, then try to
- return it as a pointer to a method. */
- t = baseclass;
- VALUE_TYPE (arg1) = t; /* side effect! */
-
- if (destructor_name_p (name, t))
- error ("use `info method' command to print out value of destructor");
-
- while (t)
- {
- for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
- {
- if (! strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
- {
- error ("use `info method' command to print value of method \"%s\"", name);
- }
- }
-
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- }
-
- error ("There is no field named %s.", name);
- return 0;
- }
-
- if (destructor_name_p (name, t))
- {
- if (!args[1])
- {
- /* destructors are a special case. */
- return (value)value_fn_field (arg1, 0,
- TYPE_FN_FIELDLIST_LENGTH (t, 0));
- }
- else
- {
- error ("destructor should not have any argument");
- }
- }
-
- /* This following loop is for methods with arguments. */
- while (t)
- {
- /* Look up as method first, because that is where we
- expect to find it first. */
- for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; i--)
- {
- struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
-
- if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
- {
- int j;
- struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
-
- found = 1;
- for (j = TYPE_FN_FIELDLIST_LENGTH (t, i) - 1; j >= 0; --j)
- if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j),
- TYPE_FN_FIELD_ARGS (f, j), args))
- {
- if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
- return (value)value_virtual_fn_field (arg1, f, j, t);
- if (TYPE_FN_FIELD_STATIC_P (f, j) && static_memfuncp)
- *static_memfuncp = 1;
- return (value)value_fn_field (arg1, i, j);
- }
- }
- }
-
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- VALUE_TYPE (arg1) = t; /* side effect! */
- }
-
- if (found)
- {
- error ("Structure method %s not defined for arglist.", name);
- return 0;
- }
- else
- {
- /* See if user tried to invoke data as function */
- t = baseclass;
- while (t)
- {
- i = type_field_index(t, name);
- if (i >= 0)
- return TYPE_FIELD_STATIC (t, i)
- ? value_static_field (t, name, i) : value_field (arg1, i);
-
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- VALUE_TYPE (arg1) = t; /* side effect! */
- }
- error ("Structure has no component named %s.", name);
- }
-}
-
-/* C++: return 1 is NAME is a legitimate name for the destructor
- of type TYPE. If TYPE does not have a destructor, or
- if NAME is inappropriate for TYPE, an error is signaled. */
-int
-destructor_name_p (name, type)
- char *name;
- struct type *type;
-{
- /* destructors are a special case. */
- char *dname = TYPE_NAME (type);
-
- if (name[0] == '~')
- {
- if (! TYPE_HAS_DESTRUCTOR (type))
- error ("type `%s' does not have destructor defined",
- TYPE_NAME (type));
- /* Skip past the "struct " at the front. */
- while (*dname++ != ' ') ;
- if (strcmp (dname, name+1))
- error ("destructor specification error");
- else
- return 1;
- }
- return 0;
-}
-
-/* C++: Given ARG1, a value of type (pointer to a)* structure/union,
- return 1 if the component named NAME from the ultimate
- target structure/union is defined, otherwise, return 0. */
-
-int
-check_field (arg1, name)
- register value arg1;
- char *name;
-{
- register struct type *t;
- register int i;
- int found = 0;
-
- struct type *baseclass;
-
- COERCE_ARRAY (arg1);
-
- t = VALUE_TYPE (arg1);
-
- /* Follow pointers until we get to a non-pointer. */
-
- while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
- t = TYPE_TARGET_TYPE (t);
-
- if (TYPE_CODE (t) == TYPE_CODE_MEMBER)
- error ("not implemented: member type in check_field");
-
- if (TYPE_CODE (t) != TYPE_CODE_STRUCT
- && TYPE_CODE (t) != TYPE_CODE_UNION)
- error ("Internal error: `this' is not an aggregate");
-
- baseclass = t;
-
- while (t)
- {
- for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
- {
- char *t_field_name = TYPE_FIELD_NAME (t, i);
- if (t_field_name && !strcmp (t_field_name, name))
- goto success;
- }
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- VALUE_TYPE (arg1) = t; /* side effect! */
- }
-
- /* C++: If it was not found as a data field, then try to
- return it as a pointer to a method. */
- t = baseclass;
-
- /* Destructors are a special case. */
- if (destructor_name_p (name, t))
- goto success;
-
- while (t)
- {
- for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
- {
- if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
- return 1;
- }
-
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- }
- return 0;
-
- success:
- t = VALUE_TYPE (arg1);
- while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
- {
- arg1 = value_ind (arg1);
- COERCE_ARRAY (arg1);
- t = VALUE_TYPE (arg1);
- }
-}
-
-/* C++: Given an aggregate type DOMAIN, and a member name NAME,
- return the address of this member as a pointer to member
- type. If INTYPE is non-null, then it will be the type
- of the member we are looking for. This will help us resolve
- pointers to member functions. */
-
-value
-value_struct_elt_for_address (domain, intype, name)
- struct type *domain, *intype;
- char *name;
-{
- register struct type *t = domain;
- register int i;
- int found = 0;
- value v;
-
- struct type *baseclass;
-
- if (TYPE_CODE (t) != TYPE_CODE_STRUCT
- && TYPE_CODE (t) != TYPE_CODE_UNION)
- error ("Internal error: non-aggregate type to value_struct_elt_for_address");
-
- baseclass = t;
-
- while (t)
- {
- for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
- {
- char *t_field_name = TYPE_FIELD_NAME (t, i);
- if (t_field_name && !strcmp (t_field_name, name))
- {
- if (TYPE_FIELD_PACKED (t, i))
- error ("pointers to bitfield members not allowed");
-
- v = value_from_long (builtin_type_int,
- (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
- VALUE_TYPE (v) = lookup_pointer_type (
- lookup_member_type (TYPE_FIELD_TYPE (t, i), baseclass));
- return v;
- }
- }
-
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- }
-
- /* C++: If it was not found as a data field, then try to
- return it as a pointer to a method. */
- t = baseclass;
-
- /* Destructors are a special case. */
- if (destructor_name_p (name, t))
- {
- error ("pointers to destructors not implemented yet");
- }
-
- /* Perform all necessary dereferencing. */
- while (intype && TYPE_CODE (intype) == TYPE_CODE_PTR)
- intype = TYPE_TARGET_TYPE (intype);
-
- while (t)
- {
- for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
- {
- if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
- {
- int j = TYPE_FN_FIELDLIST_LENGTH (t, i);
- struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
-
- if (intype == 0 && j > 1)
- error ("non-unique member `%s' requires type instantiation", name);
- if (intype)
- {
- while (j--)
- if (TYPE_FN_FIELD_TYPE (f, j) == intype)
- break;
- if (j < 0)
- error ("no member function matches that type instantiation");
- }
- else
- j = 0;
-
- if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
- {
- v = value_from_long (builtin_type_long,
- (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j));
- }
- else
- {
- struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
- 0, VAR_NAMESPACE, 0);
- v = locate_var_value (s, 0);
- }
- VALUE_TYPE (v) = lookup_pointer_type (lookup_member_type (TYPE_FN_FIELD_TYPE (f, j), baseclass));
- return v;
- }
- }
-
- if (TYPE_N_BASECLASSES (t) == 0)
- break;
-
- t = TYPE_BASECLASS (t, 1);
- }
- return 0;
-}
-
-/* Compare two argument lists and return the position in which they differ,
- or zero if equal.
-
- STATICP is nonzero if the T1 argument list came from a
- static member function.
-
- For non-static member functions, we ignore the first argument,
- which is the type of the instance variable. This is because we want
- to handle calls with objects from derived classes. This is not
- entirely correct: we should actually check to make sure that a
- requested operation is type secure, shouldn't we? */
-
-int
-typecmp (staticp, t1, t2)
- int staticp;
- struct type *t1[];
- value t2[];
-{
- int i;
-
- if (staticp && t1 == 0)
- return t2[1] != 0;
- if (t1 == 0)
- return 1;
- if (t1[0]->code == TYPE_CODE_VOID) return 0;
- if (t1[!staticp] == 0) return 0;
- for (i = !staticp; t1[i] && t1[i]->code != TYPE_CODE_VOID; i++)
- {
- if (! t2[i]
- || t1[i]->code != t2[i]->type->code
- || t1[i]->target_type != t2[i]->type->target_type)
- return i+1;
- }
- if (!t1[i]) return 0;
- return t2[i] ? i+1 : 0;
-}
-
-/* C++: return the value of the class instance variable, if one exists.
- Flag COMPLAIN signals an error if the request is made in an
- inappropriate context. */
-value
-value_of_this (complain)
- int complain;
-{
- extern FRAME selected_frame;
- struct symbol *func, *sym;
- char *funname = 0;
- struct block *b;
- int i;
-
- if (selected_frame == 0)
- if (complain)
- error ("no frame selected");
- else return 0;
-
- func = get_frame_function (selected_frame);
- if (func)
- funname = SYMBOL_NAME (func);
- else
- if (complain)
- error ("no `this' in nameless context");
- else return 0;
-
- b = SYMBOL_BLOCK_VALUE (func);
- i = BLOCK_NSYMS (b);
- if (i <= 0)
- if (complain)
- error ("no args, no `this'");
- else return 0;
-
- sym = BLOCK_SYM (b, 0);
- if (strncmp ("$this", SYMBOL_NAME (sym), 5))
- if (complain)
- error ("current stack frame not in method");
- else return 0;
-
- return read_var_value (sym, selected_frame);
-}
diff --git a/gnu/usr.bin/gdb/valprint.c b/gnu/usr.bin/gdb/valprint.c
deleted file mode 100644
index 781eb29..0000000
--- a/gnu/usr.bin/gdb/valprint.c
+++ /dev/null
@@ -1,1430 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)valprint.c 6.5 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Print values for GNU debugger gdb.
- Copyright (C) 1986, 1988, 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "value.h"
-
-/* GNU software is only expected to run on systems with 32-bit integers. */
-#define UINT_MAX 0xffffffff
-
-/* Maximum number of chars to print for a string pointer value
- or vector contents, or UINT_MAX for no limit. */
-
-static unsigned int print_max;
-
-static void type_print_varspec_suffix ();
-static void type_print_varspec_prefix ();
-static void type_print_base ();
-static void type_print_method_args ();
-
-
-char **unsigned_type_table;
-char **signed_type_table;
-char **float_type_table;
-
-
-/* Print repeat counts if there are more than this
- many repetitions of an element in an array. */
-#define REPEAT_COUNT_THRESHOLD 10
-
-/* Print the character string STRING, printing at most LENGTH characters.
- Printing stops early if the number hits print_max; repeat counts
- are printed as appropriate. Print ellipses at the end if we
- had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
-
-void
-print_string (stream, string, length, force_ellipses)
- FILE *stream;
- char *string;
- unsigned int length;
- int force_ellipses;
-{
- register unsigned int i;
- unsigned int things_printed = 0;
- int in_quotes = 0;
- int need_comma = 0;
-
- if (length == 0)
- {
- fputs_filtered ("\"\"", stdout);
- return;
- }
-
- for (i = 0; i < length && things_printed < print_max; ++i)
- {
- /* Position of the character we are examining
- to see whether it is repeated. */
- unsigned int rep1;
- /* Number of repititions we have detected so far. */
- unsigned int reps;
-
- QUIT;
-
- if (need_comma)
- {
- fputs_filtered (", ", stream);
- need_comma = 0;
- }
-
- rep1 = i + 1;
- reps = 1;
- while (rep1 < length && string[rep1] == string[i])
- {
- ++rep1;
- ++reps;
- }
-
- if (reps > REPEAT_COUNT_THRESHOLD)
- {
- if (in_quotes)
- {
- fputs_filtered ("\", ", stream);
- in_quotes = 0;
- }
- fputs_filtered ("'", stream);
- printchar (string[i], stream, '\'');
- fprintf_filtered (stream, "' <repeats %u times>", reps);
- i = rep1 - 1;
- things_printed += REPEAT_COUNT_THRESHOLD;
- need_comma = 1;
- }
- else
- {
- if (!in_quotes)
- {
- fputs_filtered ("\"", stream);
- in_quotes = 1;
- }
- printchar (string[i], stream, '"');
- ++things_printed;
- }
- }
-
- /* Terminate the quotes if necessary. */
- if (in_quotes)
- fputs_filtered ("\"", stream);
-
- if (force_ellipses || i < length)
- fputs_filtered ("...", stream);
-}
-
-/* Print the value VAL in C-ish syntax on stream STREAM.
- FORMAT is a format-letter, or 0 for print in natural format of data type.
- If the object printed is a string pointer, returns
- the number of string bytes printed. */
-
-int
-value_print (val, stream, format, pretty)
- value val;
- FILE *stream;
- char format;
- enum val_prettyprint pretty;
-{
- register unsigned int i, n, typelen;
-
- /* A "repeated" value really contains several values in a row.
- They are made by the @ operator.
- Print such values as if they were arrays. */
-
- if (VALUE_REPEATED (val))
- {
- n = VALUE_REPETITIONS (val);
- typelen = TYPE_LENGTH (VALUE_TYPE (val));
- fprintf_filtered (stream, "{");
- /* Print arrays of characters using string syntax. */
- if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT
- && format == 0)
- print_string (stream, VALUE_CONTENTS (val), n, 0);
- else
- {
- unsigned int things_printed = 0;
-
- for (i = 0; i < n && things_printed < print_max; i++)
- {
- /* Position of the array element we are examining to see
- whether it is repeated. */
- unsigned int rep1;
- /* Number of repititions we have detected so far. */
- unsigned int reps;
-
- if (i != 0)
- fprintf_filtered (stream, ", ");
-
- rep1 = i + 1;
- reps = 1;
- while (rep1 < n
- && !bcmp (VALUE_CONTENTS (val) + typelen * i,
- VALUE_CONTENTS (val) + typelen * rep1, typelen))
- {
- ++reps;
- ++rep1;
- }
-
- if (reps > REPEAT_COUNT_THRESHOLD)
- {
- val_print (VALUE_TYPE (val),
- VALUE_CONTENTS (val) + typelen * i,
- VALUE_ADDRESS (val) + typelen * i,
- stream, format, 1, 0, pretty);
- fprintf (stream, " <repeats %u times>", reps);
- i = rep1 - 1;
- things_printed += REPEAT_COUNT_THRESHOLD;
- }
- else
- {
- val_print (VALUE_TYPE (val),
- VALUE_CONTENTS (val) + typelen * i,
- VALUE_ADDRESS (val) + typelen * i,
- stream, format, 1, 0, pretty);
- things_printed++;
- }
- }
- if (i < n)
- fprintf_filtered (stream, "...");
- }
- fprintf_filtered (stream, "}");
- return n * typelen;
- }
- else
- {
- /* If it is a pointer, indicate what it points to.
-
- Print type also if it is a reference.
-
- C++: if it is a member pointer, we will take care
- of that when we print it. */
- if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_PTR
- || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF)
- {
- fprintf_filtered (stream, "(");
- type_print (VALUE_TYPE (val), "", stream, -1);
- fprintf_filtered (stream, ") ");
-
- /* If this is a function pointer, try to print what
- function it is pointing to by name. */
- if (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (val)))
- == TYPE_CODE_FUNC)
- {
- print_address (((int *) VALUE_CONTENTS (val))[0], stream);
- /* Return value is irrelevant except for string pointers. */
- return 0;
- }
- }
- return val_print (VALUE_TYPE (val), VALUE_CONTENTS (val),
- VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
- }
-}
-
-static int prettyprint; /* Controls prettyprinting of structures. */
-int unionprint; /* Controls printing of nested unions. */
-static void scalar_print_hack();
-void (*default_scalar_print)() = scalar_print_hack;
-
-/* Print data of type TYPE located at VALADDR (within GDB),
- which came from the inferior at address ADDRESS,
- onto stdio stream STREAM according to FORMAT
- (a letter or 0 for natural format).
-
- If the data are a string pointer, returns the number of
- sting characters printed.
-
- if DEREF_REF is nonzero, then dereference references,
- otherwise just print them like pointers.
-
- The PRETTY parameter controls prettyprinting. */
-
-int
-val_print (type, valaddr, address, stream, format,
- deref_ref, recurse, pretty)
- struct type *type;
- char *valaddr;
- CORE_ADDR address;
- FILE *stream;
- char format;
- int deref_ref;
- int recurse;
- enum val_prettyprint pretty;
-{
- register unsigned int i;
- int len, n_baseclasses;
- struct type *elttype;
- int eltlen;
- LONGEST val;
- unsigned char c;
-
- if (pretty == Val_pretty_default)
- {
- pretty = prettyprint ? Val_prettyprint : Val_no_prettyprint;
- }
-
- QUIT;
-
- if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
- {
- fprintf_filtered (stream, "<Type not defined in this context>");
- fflush (stream);
- return 0;
- }
-
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
- if (TYPE_LENGTH (type) >= 0
- && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
- {
- elttype = TYPE_TARGET_TYPE (type);
- eltlen = TYPE_LENGTH (elttype);
- len = TYPE_LENGTH (type) / eltlen;
- fprintf_filtered (stream, "{");
- /* For an array of chars, print with string syntax. */
- if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT
- && format == 0)
- print_string (stream, valaddr, len, 0);
- else
- {
- unsigned int things_printed = 0;
-
- for (i = 0; i < len && things_printed < print_max; i++)
- {
- /* Position of the array element we are examining to see
- whether it is repeated. */
- unsigned int rep1;
- /* Number of repititions we have detected so far. */
- unsigned int reps;
-
- if (i > 0)
- fprintf_filtered (stream, ", ");
-
- rep1 = i + 1;
- reps = 1;
- while (rep1 < len
- && !bcmp (valaddr + i * eltlen,
- valaddr + rep1 * eltlen, eltlen))
- {
- ++reps;
- ++rep1;
- }
-
- if (reps > REPEAT_COUNT_THRESHOLD)
- {
- val_print (elttype, valaddr + i * eltlen,
- 0, stream, format, deref_ref,
- recurse + 1, pretty);
- fprintf_filtered (stream, " <repeats %u times>", reps);
- i = rep1 - 1;
- things_printed += REPEAT_COUNT_THRESHOLD;
- }
- else
- {
- val_print (elttype, valaddr + i * eltlen,
- 0, stream, format, deref_ref,
- recurse + 1, pretty);
- things_printed++;
- }
- }
- if (i < len)
- fprintf_filtered (stream, "...");
- }
- fprintf_filtered (stream, "}");
- break;
- }
- /* Array of unspecified length: treat like pointer to first elt. */
- valaddr = (char *) &address;
-
- case TYPE_CODE_PTR:
- if (format)
- {
- print_scalar_formatted (valaddr, type, format, 0, stream);
- break;
- }
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD)
- {
- struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type));
- struct type *target = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type));
- struct fn_field *f;
- int j, len2;
- char *kind = "";
-
- val = unpack_long (builtin_type_int, valaddr);
- if (val < 128)
- {
- len = TYPE_NFN_FIELDS (domain);
- for (i = 0; i < len; i++)
- {
- f = TYPE_FN_FIELDLIST1 (domain, i);
- len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
-
- for (j = 0; j < len2; j++)
- {
- QUIT;
- if (TYPE_FN_FIELD_VOFFSET (f, j) == val)
- {
- kind = "virtual";
- goto common;
- }
- }
- }
- }
- else
- {
- struct symbol *sym = find_pc_function ((CORE_ADDR) val);
- if (sym == 0)
- error ("invalid pointer to member function");
- len = TYPE_NFN_FIELDS (domain);
- for (i = 0; i < len; i++)
- {
- f = TYPE_FN_FIELDLIST1 (domain, i);
- len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
-
- for (j = 0; j < len2; j++)
- {
- QUIT;
- if (!strcmp (SYMBOL_NAME (sym), TYPE_FN_FIELD_PHYSNAME (f, j)))
- goto common;
- }
- }
- }
- common:
- if (i < len)
- {
- fprintf_filtered (stream, "&");
- type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0);
- fprintf (stream, kind);
- if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
- && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$')
- type_print_method_args
- (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
- TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream);
- else
- type_print_method_args
- (TYPE_FN_FIELD_ARGS (f, j), "",
- TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream);
- break;
- }
- fprintf_filtered (stream, "(");
- type_print (type, "", stream, -1);
- fprintf_filtered (stream, ") %d", (int) val >> 3);
- }
- else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER)
- {
- struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type));
- struct type *target = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type));
- char *kind = "";
-
- /* VAL is a byte offset into the structure type DOMAIN.
- Find the name of the field for that offset and
- print it. */
- int extra = 0;
- int bits = 0;
- len = TYPE_NFIELDS (domain);
- /* @@ Make VAL into bit offset */
- val = unpack_long (builtin_type_int, valaddr) << 3;
- for (i = 0; i < len; i++)
- {
- int bitpos = TYPE_FIELD_BITPOS (domain, i);
- QUIT;
- if (val == bitpos)
- break;
- if (val < bitpos && i > 0)
- {
- int ptrsize = (TYPE_LENGTH (builtin_type_char) * TYPE_LENGTH (target));
- /* Somehow pointing into a field. */
- i -= 1;
- extra = (val - TYPE_FIELD_BITPOS (domain, i));
- if (extra & 0x3)
- bits = 1;
- else
- extra >>= 3;
- break;
- }
- }
- if (i < len)
- {
- fprintf_filtered (stream, "&");
- type_print_base (domain, stream, 0, 0);
- fprintf_filtered (stream, "::");
- fputs_filtered (TYPE_FIELD_NAME (domain, i), stream);
- if (extra)
- fprintf_filtered (stream, " + %d bytes", extra);
- if (bits)
- fprintf_filtered (stream, " (offset in bits)");
- break;
- }
- fprintf_filtered (stream, "%d", val >> 3);
- }
- else
- {
- fprintf_filtered (stream, "0x%x", * (int *) valaddr);
- /* For a pointer to char or unsigned char,
- also print the string pointed to, unless pointer is null. */
-
- /* For an array of chars, print with string syntax. */
- elttype = TYPE_TARGET_TYPE (type);
- i = 0; /* Number of characters printed. */
- if (TYPE_LENGTH (elttype) == 1
- && TYPE_CODE (elttype) == TYPE_CODE_INT
- && format == 0
- && unpack_long (type, valaddr) != 0
- /* If print_max is UINT_MAX, the alloca below will fail.
- In that case don't try to print the string. */
- && print_max < UINT_MAX)
- {
- fprintf_filtered (stream, " ");
-
- /* Get first character. */
- if (read_memory ( (CORE_ADDR) unpack_long (type, valaddr),
- &c, 1))
- {
- /* First address out of bounds. */
- fprintf_filtered (stream, "<Address 0x%x out of bounds>",
- (* (int *) valaddr));
- break;
- }
- else
- {
- /* A real string. */
- int out_of_bounds = 0;
- char *string = (char *) alloca (print_max);
-
- /* If the loop ends by us hitting print_max characters,
- we need to have elipses at the end. */
- int force_ellipses = 1;
-
- /* This loop only fetches print_max characters, even
- though print_string might want to print more
- (with repeated characters). This is so that
- we don't spend forever fetching if we print
- a long string consisting of the same character
- repeated. */
- while (i < print_max)
- {
- QUIT;
- if (read_memory ((CORE_ADDR) unpack_long (type, valaddr)
- + i, &c, 1))
- {
- out_of_bounds = 1;
- force_ellipses = 0;
- break;
- }
- else if (c == '\0')
- {
- force_ellipses = 0;
- break;
- }
- else
- string[i++] = c;
- }
-
- if (i != 0)
- print_string (stream, string, i, force_ellipses);
- if (out_of_bounds)
- fprintf_filtered (stream,
- " <Address 0x%x out of bounds>",
- (*(int *) valaddr) + i);
- }
-
- fflush (stream);
- }
- /* Return number of characters printed, plus one for the
- terminating null if we have "reached the end". */
- return i + (print_max && i != print_max);
- }
- break;
-
- case TYPE_CODE_MEMBER:
- error ("not implemented: member type in val_print");
- break;
-
- case TYPE_CODE_REF:
- fprintf_filtered (stream, "(0x%x &) = ", * (int *) valaddr);
- /* De-reference the reference. */
- if (deref_ref)
- {
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF)
- {
- value val = value_at (TYPE_TARGET_TYPE (type), * (int *) valaddr);
- val_print (VALUE_TYPE (val), VALUE_CONTENTS (val),
- VALUE_ADDRESS (val), stream, format,
- deref_ref, recurse + 1, pretty);
- }
- else
- fprintf_filtered (stream, "???");
- }
- break;
-
- case TYPE_CODE_UNION:
- if (recurse && !unionprint)
- {
- fprintf_filtered (stream, "{...}");
- break;
- }
- /* Fall through. */
- case TYPE_CODE_STRUCT:
- fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
- n_baseclasses = TYPE_N_BASECLASSES (type);
- for (i = 1; i <= n_baseclasses; i++)
- {
- fprintf_filtered (stream, "\n");
- if (pretty)
- print_spaces_filtered (2 + 2 * recurse, stream);
- fputs_filtered ("<", stream);
- fputs_filtered (TYPE_NAME (TYPE_BASECLASS (type, i)), stream);
- fputs_filtered ("> = ", stream);
- val_print (TYPE_FIELD_TYPE (type, 0),
- valaddr + TYPE_FIELD_BITPOS (type, i-1) / 8,
- 0, stream, 0, 0, recurse + 1, pretty);
- }
- if (i > 1) {
- fprintf_filtered (stream, "\n");
- print_spaces_filtered (2 + 2 * recurse, stream);
- fputs_filtered ("members of ", stream);
- fputs_filtered (TYPE_NAME (type), stream);
- fputs_filtered (": ", stream);
- }
- if (!len && i == 1)
- fprintf_filtered (stream, "<No data fields>");
- else
- {
- for (i -= 1; i < len; i++)
- {
- if (i > n_baseclasses) fprintf_filtered (stream, ", ");
- if (pretty)
- {
- fprintf_filtered (stream, "\n");
- print_spaces_filtered (2 + 2 * recurse, stream);
- }
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- fputs_filtered (" = ", stream);
- /* check if static field */
- if (TYPE_FIELD_STATIC (type, i))
- {
- value v;
-
- v = value_static_field (type, TYPE_FIELD_NAME (type, i), i);
- val_print (TYPE_FIELD_TYPE (type, i),
- VALUE_CONTENTS (v), 0, stream, format,
- deref_ref, recurse + 1, pretty);
- }
- else if (TYPE_FIELD_PACKED (type, i))
- {
- char *valp = (char *) & val;
- union {int i; char c;} test;
- test.i = 1;
- if (test.c != 1)
- valp += sizeof val - TYPE_LENGTH (TYPE_FIELD_TYPE (type, i));
- val = unpack_field_as_long (type, valaddr, i);
- val_print (TYPE_FIELD_TYPE (type, i), valp, 0,
- stream, format, deref_ref, recurse + 1, pretty);
- }
- else
- {
- val_print (TYPE_FIELD_TYPE (type, i),
- valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
- 0, stream, format, deref_ref,
- recurse + 1, pretty);
- }
- }
- if (pretty)
- {
- fprintf_filtered (stream, "\n");
- print_spaces_filtered (2 * recurse, stream);
- }
- }
- fprintf_filtered (stream, "}");
- break;
-
- case TYPE_CODE_ENUM:
- if (format)
- {
- print_scalar_formatted (valaddr, type, format, 0, stream);
- break;
- }
- len = TYPE_NFIELDS (type);
- val = unpack_long (builtin_type_int, valaddr);
- for (i = 0; i < len; i++)
- {
- QUIT;
- if (val == TYPE_FIELD_BITPOS (type, i))
- break;
- }
- if (i < len)
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- else
- fprintf_filtered (stream, "%d", (int) val);
- break;
-
- case TYPE_CODE_FUNC:
- if (format)
- {
- print_scalar_formatted (valaddr, type, format, 0, stream);
- break;
- }
- fprintf_filtered (stream, "{");
- type_print (type, "", stream, -1);
- fprintf_filtered (stream, "} ");
- fprintf_filtered (stream, "0x%x", address);
- break;
-
- case TYPE_CODE_INT:
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
- else
- {
- (*default_scalar_print)(stream, type, unpack_long(type, valaddr));
-#ifdef notdef
- if (TYPE_LENGTH (type) == 1)
- {
- fprintf_filtered (stream, " '");
- printchar ((unsigned char) unpack_long (type, valaddr),
- stream, '\'');
- fprintf_filtered (stream, "'");
- }
-#endif
- }
- break;
-
- case TYPE_CODE_FLT:
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
- else
- print_floating (valaddr, type, stream);
- break;
-
- case TYPE_CODE_VOID:
- fprintf_filtered (stream, "void");
- break;
-
- default:
- error ("Invalid type code in symbol table.");
- }
- fflush (stream);
- return 0;
-}
-
-/* Print a description of a type TYPE
- in the form of a declaration of a variable named VARSTRING.
- Output goes to STREAM (via stdio).
- If SHOW is positive, we show the contents of the outermost level
- of structure even if there is a type name that could be used instead.
- If SHOW is negative, we never show the details of elements' types. */
-
-void
-type_print (type, varstring, stream, show)
- struct type *type;
- char *varstring;
- FILE *stream;
- int show;
-{
- type_print_1 (type, varstring, stream, show, 0);
-}
-
-/* LEVEL is the depth to indent lines by. */
-
-void
-type_print_1 (type, varstring, stream, show, level)
- struct type *type;
- char *varstring;
- FILE *stream;
- int show;
- int level;
-{
- register enum type_code code;
- type_print_base (type, stream, show, level);
- code = TYPE_CODE (type);
- if ((varstring && *varstring)
- ||
- /* Need a space if going to print stars or brackets;
- but not if we will print just a type name. */
- ((show > 0 || TYPE_NAME (type) == 0)
- &&
- (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
- || code == TYPE_CODE_METHOD
- || code == TYPE_CODE_ARRAY
- || code == TYPE_CODE_MEMBER
- || code == TYPE_CODE_REF)))
- fprintf_filtered (stream, " ");
- type_print_varspec_prefix (type, stream, show, 0);
- fputs_filtered (varstring, stream);
- type_print_varspec_suffix (type, stream, show, 0);
-}
-
-/* Print the method arguments ARGS to the file STREAM. */
-static void
-type_print_method_args (args, prefix, varstring, staticp, stream)
- struct type **args;
- char *prefix, *varstring;
- int staticp;
- FILE *stream;
-{
- int i;
-
- fputs_filtered (" ", stream);
- fputs_filtered (prefix, stream);
- fputs_filtered (varstring, stream);
- fputs_filtered (" (", stream);
- if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
- {
- i = !staticp; /* skip the class variable */
- while (1)
- {
- type_print (args[i++], "", stream, 0);
- if (!args[i])
- {
- fprintf_filtered (stream, " ...");
- break;
- }
- else if (args[i]->code != TYPE_CODE_VOID)
- {
- fprintf_filtered (stream, ", ");
- }
- else break;
- }
- }
- fprintf_filtered (stream, ")");
-}
-
-/* If TYPE is a derived type, then print out derivation
- information. Print out all layers of the type heirarchy
- until we encounter one with multiple inheritance.
- At that point, print out that ply, and return. */
-static void
-type_print_derivation_info (stream, type)
- FILE *stream;
- struct type *type;
-{
- char *name;
- int i, n_baseclasses = TYPE_N_BASECLASSES (type);
- struct type *basetype = 0;
-
- while (type && n_baseclasses == 1)
- {
- basetype = TYPE_BASECLASS (type, 1);
- if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype)))
- {
- while (*name != ' ') name++;
- fprintf_filtered (stream, ": %s%s ",
- TYPE_VIA_PUBLIC (basetype) ? "public" : "private",
- TYPE_VIA_VIRTUAL (basetype) ? " virtual" : "");
- fputs_filtered (name + 1, stream);
- fputs_filtered (" ", stream);
- }
- n_baseclasses = TYPE_N_BASECLASSES (basetype);
- type = basetype;
- }
-
- if (type)
- {
- if (n_baseclasses != 0)
- fprintf_filtered (stream, ": ");
- for (i = 1; i <= n_baseclasses; i++)
- {
- basetype = TYPE_BASECLASS (type, i);
- if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype)))
- {
- while (*name != ' ') name++;
- fprintf_filtered (stream, "%s%s ",
- TYPE_VIA_PUBLIC (basetype) ? "public" : "private",
- TYPE_VIA_VIRTUAL (basetype) ? " virtual" : "");
- fputs_filtered (name + 1, stream);
- }
- if (i < n_baseclasses)
- fprintf_filtered (stream, ", ");
- }
- fprintf_filtered (stream, " ");
- }
-}
-
-/* Print any asterisks or open-parentheses needed before the
- variable name (to describe its type).
-
- On outermost call, pass 0 for PASSED_A_PTR.
- On outermost call, SHOW > 0 means should ignore
- any typename for TYPE and show its details.
- SHOW is always zero on recursive calls. */
-
-static void
-type_print_varspec_prefix (type, stream, show, passed_a_ptr)
- struct type *type;
- FILE *stream;
- int show;
- int passed_a_ptr;
-{
- if (type == 0)
- return;
-
- if (TYPE_NAME (type) && show <= 0)
- return;
-
- QUIT;
-
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_PTR:
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
- fprintf_filtered (stream, "*");
- break;
-
- case TYPE_CODE_MEMBER:
- if (passed_a_ptr)
- fprintf_filtered (stream, "(");
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
- fprintf_filtered (stream, " ");
- type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0,
- passed_a_ptr);
- fprintf_filtered (stream, "::");
- break;
-
- case TYPE_CODE_METHOD:
- if (passed_a_ptr)
- fprintf (stream, "(");
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
- fprintf_filtered (stream, " ");
- type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0,
- passed_a_ptr);
- fprintf_filtered (stream, "::");
- break;
-
- case TYPE_CODE_REF:
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
- fprintf_filtered (stream, "&");
- break;
-
- case TYPE_CODE_FUNC:
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
- if (passed_a_ptr)
- fprintf_filtered (stream, "(");
- break;
-
- case TYPE_CODE_ARRAY:
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
- if (passed_a_ptr)
- fprintf_filtered (stream, "(");
- }
-}
-
-/* Print any array sizes, function arguments or close parentheses
- needed after the variable name (to describe its type).
- Args work like type_print_varspec_prefix. */
-
-static void
-type_print_varspec_suffix (type, stream, show, passed_a_ptr)
- struct type *type;
- FILE *stream;
- int show;
- int passed_a_ptr;
-{
- if (type == 0)
- return;
-
- if (TYPE_NAME (type) && show <= 0)
- return;
-
- QUIT;
-
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
- if (passed_a_ptr)
- fprintf_filtered (stream, ")");
-
- fprintf_filtered (stream, "[");
- if (TYPE_LENGTH (type) >= 0
- && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
- fprintf_filtered (stream, "%d",
- (TYPE_LENGTH (type)
- / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
- fprintf_filtered (stream, "]");
-
- type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
- break;
-
- case TYPE_CODE_MEMBER:
- if (passed_a_ptr)
- fprintf_filtered (stream, ")");
- type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0);
- break;
-
- case TYPE_CODE_METHOD:
- if (passed_a_ptr)
- fprintf_filtered (stream, ")");
- type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0);
- if (passed_a_ptr)
- {
- int i;
- struct type **args = TYPE_ARG_TYPES (type);
-
- fprintf_filtered (stream, "(");
- if (args[1] == 0)
- fprintf_filtered (stream, "...");
- else for (i = 1; args[i] != 0 && args[i]->code != TYPE_CODE_VOID; i++)
- {
- type_print_1 (args[i], "", stream, -1, 0);
- if (args[i+1] == 0)
- fprintf_filtered (stream, "...");
- else if (args[i+1]->code != TYPE_CODE_VOID)
- fprintf_filtered (stream, ",");
- }
- fprintf_filtered (stream, ")");
- }
- break;
-
- case TYPE_CODE_PTR:
- case TYPE_CODE_REF:
- type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1);
- break;
-
- case TYPE_CODE_FUNC:
- type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
- passed_a_ptr);
- if (passed_a_ptr)
- fprintf_filtered (stream, ")");
- fprintf_filtered (stream, "()");
- break;
- }
-}
-
-/* Print the name of the type (or the ultimate pointer target,
- function value or array element), or the description of a
- structure or union.
-
- SHOW nonzero means don't print this type as just its name;
- show its real definition even if it has a name.
- SHOW zero means print just typename or struct tag if there is one
- SHOW negative means abbreviate structure elements.
- SHOW is decremented for printing of structure elements.
-
- LEVEL is the depth to indent by.
- We increase it for some recursive calls. */
-
-static void
-type_print_base (type, stream, show, level)
- struct type *type;
- FILE *stream;
- int show;
- int level;
-{
- char *name;
- register int i;
- register int len;
- register int lastval;
-
- QUIT;
-
- if (type == 0)
- {
- fprintf_filtered (stream, "type unknown");
- return;
- }
-
- if (TYPE_NAME (type) && show <= 0)
- {
- fputs_filtered (TYPE_NAME (type), stream);
- return;
- }
-
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
- case TYPE_CODE_PTR:
- case TYPE_CODE_MEMBER:
- case TYPE_CODE_REF:
- case TYPE_CODE_FUNC:
- case TYPE_CODE_METHOD:
- type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
- break;
-
- case TYPE_CODE_STRUCT:
- fprintf_filtered (stream, "struct ");
- goto struct_union;
-
- case TYPE_CODE_UNION:
- fprintf_filtered (stream, "union ");
- struct_union:
- if (TYPE_NAME (type) && (name = TYPE_NAME (type)))
- {
- while (*name != ' ') name++;
- fputs_filtered (name + 1, stream);
- fputs_filtered (" ", stream);
- }
- if (show < 0)
- fprintf_filtered (stream, "{...}");
- else
- {
- int i;
-
- type_print_derivation_info (stream, type);
-
- fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
- if (len)
- fprintf_filtered (stream, "\n");
- else
- {
- if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
- fprintf_filtered (stream, "<incomplete type>\n");
- else
- fprintf_filtered (stream, "<no data fields>\n");
- }
-
- /* If there is a base class for this type,
- do not print the field that it occupies. */
- for (i = TYPE_N_BASECLASSES (type); i < len; i++)
- {
- QUIT;
- /* Don't print out virtual function table. */
- if (! strncmp (TYPE_FIELD_NAME (type, i),
- "_vptr$", 6))
- continue;
-
- print_spaces_filtered (level + 4, stream);
- if (TYPE_FIELD_STATIC (type, i))
- {
- fprintf_filtered (stream, "static ");
- }
- type_print_1 (TYPE_FIELD_TYPE (type, i),
- TYPE_FIELD_NAME (type, i),
- stream, show - 1, level + 4);
- if (!TYPE_FIELD_STATIC (type, i)
- && TYPE_FIELD_PACKED (type, i))
- {
- /* It is a bitfield. This code does not attempt
- to look at the bitpos and reconstruct filler,
- unnamed fields. This would lead to misleading
- results if the compiler does not put out fields
- for such things (I don't know what it does). */
- fprintf_filtered (stream, " : %d",
- TYPE_FIELD_BITSIZE (type, i));
- }
- fprintf_filtered (stream, ";\n");
- }
-
- /* C++: print out the methods */
- len = TYPE_NFN_FIELDS (type);
- if (len) fprintf_filtered (stream, "\n");
- for (i = 0; i < len; i++)
- {
- struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
- int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
-
- for (j = 0; j < len2; j++)
- {
- QUIT;
- print_spaces_filtered (level + 4, stream);
- if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
- fprintf_filtered (stream, "virtual ");
- else if (TYPE_FN_FIELD_STATIC_P (f, j))
- fprintf_filtered (stream, "static ");
- type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), "", stream, 0);
- if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
- && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$')
- type_print_method_args
- (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
- TYPE_FN_FIELDLIST_NAME (type, i), 0, stream);
- else
- type_print_method_args
- (TYPE_FN_FIELD_ARGS (f, j), "",
- TYPE_FN_FIELDLIST_NAME (type, i),
- TYPE_FN_FIELD_STATIC_P (f, j), stream);
-
- fprintf_filtered (stream, ";\n");
- }
- if (len2) fprintf_filtered (stream, "\n");
- }
-
- print_spaces_filtered (level, stream);
- fprintf_filtered (stream, "}");
- }
- break;
-
- case TYPE_CODE_ENUM:
- fprintf_filtered (stream, "enum ");
- if (TYPE_NAME (type))
- {
- name = TYPE_NAME (type);
- while (*name != ' ') name++;
- fputs_filtered (name + 1, stream);
- fputs_filtered (" ", stream);
- }
- if (show < 0)
- fprintf_filtered (stream, "{...}");
- else
- {
- fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
- lastval = 0;
- for (i = 0; i < len; i++)
- {
- QUIT;
- if (i) fprintf_filtered (stream, ", ");
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- if (lastval != TYPE_FIELD_BITPOS (type, i))
- {
- fprintf_filtered (stream, " : %d", TYPE_FIELD_BITPOS (type, i));
- lastval = TYPE_FIELD_BITPOS (type, i);
- }
- lastval++;
- }
- fprintf_filtered (stream, "}");
- }
- break;
-
- case TYPE_CODE_INT:
- if (TYPE_UNSIGNED (type))
- name = unsigned_type_table[TYPE_LENGTH (type)];
- else
- name = signed_type_table[TYPE_LENGTH (type)];
- fputs_filtered (name, stream);
- break;
-
- case TYPE_CODE_FLT:
- name = float_type_table[TYPE_LENGTH (type)];
- fputs_filtered (name, stream);
- break;
-
- case TYPE_CODE_VOID:
- fprintf_filtered (stream, "void");
- break;
-
- case 0:
- fprintf_filtered (stream, "struct unknown");
- break;
-
- default:
- error ("Invalid type code in symbol table.");
- }
-}
-
-static void
-scalar_print_decimal(stream, type, val)
- FILE *stream;
- struct type *type;
- LONGEST val;
-{
- fprintf_filtered(stream, TYPE_UNSIGNED(type)? "%lu":"%ld", val);
-}
-
-static void
-scalar_print_hex(stream, type, val)
- FILE *stream;
- struct type *type;
- LONGEST val;
-{
- switch (TYPE_LENGTH(type)) {
- case 1:
- fprintf_filtered (stream, "0x%02lx", val);
- break;
- case 2:
- fprintf_filtered (stream, "0x%04lx", val);
- break;
- case 4:
- fprintf_filtered (stream, "0x%08lx", val);
- break;
- default:
- fprintf_filtered (stream, "0x%lx", val);
- break;
- }
-}
-
-static void
-scalar_print_octal(stream, type, val)
- FILE *stream;
- struct type *type;
- LONGEST val;
-{
- switch (TYPE_LENGTH(type)) {
- case 1:
- fprintf_filtered (stream, "0%03lo", val);
- break;
- case 2:
- fprintf_filtered (stream, "0%06lo", val);
- break;
- case 4:
- fprintf_filtered (stream, "0%012lo", val);
- break;
- default:
- fprintf_filtered (stream, "0%lo", val);
- break;
- }
-}
-
-static void
-scalar_print_hack(stream, type, val)
- FILE *stream;
- struct type *type;
- LONGEST val;
-{
- if (TYPE_UNSIGNED(type))
- scalar_print_hex(stream, type, val);
- else
- scalar_print_decimal(stream, type, val);
-}
-
-static void
-set_maximum_command (arg)
- char *arg;
-{
- if (!arg) error_no_arg ("value for maximum elements to print");
- print_max = parse_and_eval_address (arg);
- if (print_max == 0)
- print_max = UINT_MAX;
-}
-
-static void
-set_base_command(arg)
- char *arg;
-{
- int base;
-
- if (!arg)
- base = 0;
- else
- base = parse_and_eval_address (arg);
- switch (base) {
- default:
- default_scalar_print = scalar_print_hack;
- break;
- case 8:
- default_scalar_print = scalar_print_octal;
- break;
- case 10:
- default_scalar_print = scalar_print_decimal;
- break;
- case 16:
- default_scalar_print = scalar_print_hex;
- break;
- }
-}
-
-static void
-set_prettyprint_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- prettyprint = parse_binary_operation ("set prettyprint", arg);
-}
-
-static void
-set_unionprint_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- unionprint = parse_binary_operation ("set unionprint", arg);
-}
-
-format_info (arg, from_tty)
- char *arg;
- int from_tty;
-{
- if (arg)
- error ("\"info format\" does not take any arguments.");
- printf ("Prettyprinting of structures is %s.\n",
- prettyprint ? "on" : "off");
- printf ("Printing of unions interior to structures is %s.\n",
- unionprint ? "on" : "off");
- if (print_max == UINT_MAX)
- printf_filtered
- ("There is no maximum number of array elements printed.\n");
- else
- printf_filtered
- ("The maximum number of array elements printed is %d.\n", print_max);
-}
-
-extern struct cmd_list_element *setlist;
-
-void
-_initialize_valprint ()
-{
- add_cmd ("base", class_support, set_base_command,
- "Change default integer print radix to 8, 10 or 16\n\
-No args returns to the ad-hoc default of `16' for unsigned values\n\
-and `10' otherwise.",
- &setlist);
- add_cmd ("array-max", class_vars, set_maximum_command,
- "Set NUMBER as limit on string chars or array elements to print.\n\
-\"set array-max 0\" causes there to be no limit.",
- &setlist);
-
- add_cmd ("prettyprint", class_support, set_prettyprint_command,
- "Turn prettyprinting of structures on and off.",
- &setlist);
- add_alias_cmd ("pp", "prettyprint", class_support, 1, &setlist);
-
- add_cmd ("unionprint", class_support, set_unionprint_command,
- "Turn printing of unions interior to structures on and off.",
- &setlist);
-
- add_info ("format", format_info,
- "Show current settings of data formatting options.");
-
- /* Give people the defaults which they are used to. */
- prettyprint = 0;
- unionprint = 1;
-
- print_max = 200;
-
- unsigned_type_table
- = (char **) xmalloc ((1 + sizeof (unsigned LONGEST)) * sizeof (char *));
- bzero (unsigned_type_table, (1 + sizeof (unsigned LONGEST)));
- unsigned_type_table[sizeof (unsigned char)] = "unsigned char";
- unsigned_type_table[sizeof (unsigned short)] = "unsigned short";
- unsigned_type_table[sizeof (unsigned long)] = "unsigned long";
- unsigned_type_table[sizeof (unsigned int)] = "unsigned int";
-#ifdef LONG_LONG
- unsigned_type_table[sizeof (unsigned long long)] = "unsigned long long";
-#endif
-
- signed_type_table
- = (char **) xmalloc ((1 + sizeof (LONGEST)) * sizeof (char *));
- bzero (signed_type_table, (1 + sizeof (LONGEST)));
- signed_type_table[sizeof (char)] = "char";
- signed_type_table[sizeof (short)] = "short";
- signed_type_table[sizeof (long)] = "long";
- signed_type_table[sizeof (int)] = "int";
-#ifdef LONG_LONG
- signed_type_table[sizeof (long long)] = "long long";
-#endif
-
- float_type_table
- = (char **) xmalloc ((1 + sizeof (double)) * sizeof (char *));
- bzero (float_type_table, (1 + sizeof (double)));
- float_type_table[sizeof (float)] = "float";
- float_type_table[sizeof (double)] = "double";
-}
-
diff --git a/gnu/usr.bin/gdb/value.h b/gnu/usr.bin/gdb/value.h
deleted file mode 100644
index 07dd8e8..0000000
--- a/gnu/usr.bin/gdb/value.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/* Definitions for values of C expressions, for GDB.
- 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. */
-
-/*
- * The structure which defines the type of a value. It should never
- * be possible for a program lval value to survive over a call to the inferior
- * (ie to be put into the history list or an internal variable).
- */
-enum lval_type {
- /* Not an lval. */
- not_lval,
- /* In memory. Could be a saved register. */
- lval_memory,
- /* In a register. */
- lval_register,
- /* In a gdb internal variable. */
- lval_internalvar,
- /* Part of a gdb internal variable (structure field). */
- lval_internalvar_component,
- /* In a register series in a frame not the current one, which may have been
- partially saved or saved in different places (otherwise would be
- lval_register or lval_memory). */
- lval_reg_frame_relative,
-};
-
-struct value
- {
- /* Type of value; either not an lval, or one of the various
- different possible kinds of lval. */
- enum lval_type lval;
- /* Location of value (if lval). */
- union
- {
- /* Address in inferior or byte of registers structure. */
- CORE_ADDR address;
- /* Pointer to interrnal variable. */
- struct internalvar *internalvar;
- /* Number of register. Only used with
- lval_reg_frame_relative. */
- int regnum;
- } location;
- /* Describes offset of a value within lval a structure in bytes. */
- int offset;
- /* Only used for bitfields; number of bits contained in them. */
- int bitsize;
- /* Only used for bitfields; position of start of field. */
- int bitpos;
- /* Frame value is relative to. In practice, this address is only
- used if the value is stored in several registers in other than
- the current frame, and these registers have not all been saved
- at the same place in memory. This will be described in the
- lval enum above as "lval_reg_frame_relative". */
- CORE_ADDR frame_addr;
- /* Type of the value. */
- struct type *type;
- /* Values are stored in a chain, so that they can be deleted
- easily over calls to the inferior. Values assigned to internal
- variables or put into the value history are taken off this
- list. */
- struct value *next;
- /* If an lval is forced to repeat, a new value is created with
- these fields set. The new value is not an lval. */
- short repeated;
- short repetitions;
- /* Register number if the value is from a register. Is not kept
- if you take a field of a structure that is stored in a
- register. Shouldn't it be? */
- short regno;
- /* Actual contents of the value. For use of this value; setting
- it uses the stuff above. */
- long contents[1];
- };
-
-typedef struct value *value;
-
-#define VALUE_TYPE(val) (val)->type
-#define VALUE_CONTENTS(val) ((char *) (val)->contents)
-#define VALUE_LVAL(val) (val)->lval
-#define VALUE_ADDRESS(val) (val)->location.address
-#define VALUE_INTERNALVAR(val) (val)->location.internalvar
-#define VALUE_FRAME_REGNUM(val) ((val)->location.regnum)
-#define VALUE_FRAME(val) ((val)->frame_addr)
-#define VALUE_OFFSET(val) (val)->offset
-#define VALUE_BITSIZE(val) (val)->bitsize
-#define VALUE_BITPOS(val) (val)->bitpos
-#define VALUE_NEXT(val) (val)->next
-#define VALUE_REPEATED(val) (val)->repeated
-#define VALUE_REPETITIONS(val) (val)->repetitions
-#define VALUE_REGNO(val) (val)->regno
-
-/* If ARG is an array, convert it to a pointer.
- If ARG is an enum, convert it to an integer.
-
- References are dereferenced. */
-
-#define COERCE_ARRAY(arg) \
-{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
- arg = value_ind (arg); \
- if (VALUE_REPEATED (arg) \
- || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) \
- arg = value_coerce_array (arg); \
- if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
- arg = value_cast (builtin_type_unsigned_int, arg); \
-}
-
-/* If ARG is an enum, convert it to an integer. */
-
-#define COERCE_ENUM(arg) \
-{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
- arg = value_ind (arg); \
- if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
- arg = value_cast (builtin_type_unsigned_int, arg); \
-}
-
-/* Internal variables (variables for convenience of use of debugger)
- are recorded as a chain of these structures. */
-
-struct internalvar
-{
- struct internalvar *next;
- char *name;
- value value;
-};
-
-LONGEST value_as_long ();
-double value_as_double ();
-LONGEST unpack_long ();
-double unpack_double ();
-long unpack_field_as_long ();
-value value_from_long ();
-value value_from_double ();
-value value_at ();
-value value_from_register ();
-value value_of_variable ();
-value value_of_register ();
-value read_var_value ();
-value locate_var_value ();
-value allocate_value ();
-value allocate_repeat_value ();
-value value_string ();
-
-value value_binop ();
-value value_add ();
-value value_sub ();
-value value_coerce_array ();
-value value_ind ();
-value value_addr ();
-value value_assign ();
-value value_neg ();
-value value_lognot ();
-value value_struct_elt (), value_struct_elt_for_address ();
-value value_field ();
-value value_cast ();
-value value_zero ();
-value value_repeat ();
-value value_subscript ();
-
-value call_function ();
-value value_being_returned ();
-int using_struct_return ();
-
-value evaluate_expression ();
-value evaluate_type ();
-value parse_and_eval ();
-value parse_to_comma_and_eval ();
-
-value access_value_history ();
-value value_of_internalvar ();
-struct internalvar *lookup_internalvar ();
-
-int value_equal ();
-int value_less ();
-int value_zerop ();
-
-/* C++ */
-value value_of_this ();
-value value_static_field ();
-value value_x_binop ();
-value value_x_unop ();
-int binop_user_defined_p ();
-int unop_user_defined_p ();
-
-void read_register_bytes ();
-void modify_field ();
-void type_print ();
-void type_print_1 ();
-
-/* Possibilities for prettyprint parameters to routines which print
- things. */
-enum val_prettyprint {
- Val_no_prettyprint = 0,
- Val_prettyprint,
- /* Use the default setting which the user has specified. */
- Val_pretty_default
- };
-
diff --git a/gnu/usr.bin/gdb/values.c b/gnu/usr.bin/gdb/values.c
deleted file mode 100644
index 93a2911..0000000
--- a/gnu/usr.bin/gdb/values.c
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)values.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/* Low level packing and unpacking of values for GDB.
- 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. */
-
-#include <stdio.h>
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "value.h"
-
-/* The value-history records all the values printed
- by print commands during this session. Each chunk
- records 60 consecutive values. The first chunk on
- the chain records the most recent values.
- The total number of values is in value_history_count. */
-
-#define VALUE_HISTORY_CHUNK 60
-
-struct value_history_chunk
-{
- struct value_history_chunk *next;
- value values[VALUE_HISTORY_CHUNK];
-};
-
-/* Chain of chunks now in use. */
-
-static struct value_history_chunk *value_history_chain;
-
-static int value_history_count; /* Abs number of last entry stored */
-
-
-/* List of all value objects currently allocated
- (except for those released by calls to release_value)
- This is so they can be freed after each command. */
-
-static value all_values;
-
-/* Allocate a value that has the correct length for type TYPE. */
-
-value
-allocate_value (type)
- struct type *type;
-{
- register value val;
-
- /* If the type we want had no definition in the file it first
- * appeared in, it will be marked a `stub'. The real definition
- * probably appeared later so try to find it. */
- if (TYPE_FLAGS(type) & TYPE_FLAG_STUB)
- {
- register char *cp;
- register struct symbol *sym;
- extern char *index();
-
- if (cp = index(TYPE_NAME(type), ' '))
- ++cp;
- else
- cp = TYPE_NAME(type);
-
- sym = lookup_symbol(cp, 0, STRUCT_NAMESPACE, 0);
-
- if (sym && TYPE_CODE(SYMBOL_TYPE(sym)) == TYPE_CODE(type))
- bcopy (SYMBOL_TYPE (sym), type, sizeof (*type));
- }
- val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type));
- VALUE_NEXT (val) = all_values;
- all_values = val;
- VALUE_TYPE (val) = type;
- VALUE_LVAL (val) = not_lval;
- VALUE_ADDRESS (val) = 0;
- VALUE_FRAME (val) = 0;
- VALUE_OFFSET (val) = 0;
- VALUE_BITPOS (val) = 0;
- VALUE_BITSIZE (val) = 0;
- VALUE_REPEATED (val) = 0;
- VALUE_REPETITIONS (val) = 0;
- VALUE_REGNO (val) = -1;
- return val;
-}
-
-/* Allocate a value that has the correct length
- for COUNT repetitions type TYPE. */
-
-value
-allocate_repeat_value (type, count)
- struct type *type;
- int count;
-{
- register value val;
-
- val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type) * count);
- VALUE_NEXT (val) = all_values;
- all_values = val;
- VALUE_TYPE (val) = type;
- VALUE_LVAL (val) = not_lval;
- VALUE_ADDRESS (val) = 0;
- VALUE_FRAME (val) = 0;
- VALUE_OFFSET (val) = 0;
- VALUE_BITPOS (val) = 0;
- VALUE_BITSIZE (val) = 0;
- VALUE_REPEATED (val) = 1;
- VALUE_REPETITIONS (val) = count;
- VALUE_REGNO (val) = -1;
- return val;
-}
-
-/* Free all the values that have been allocated (except for those released).
- Called after each command, successful or not. */
-
-void
-free_all_values ()
-{
- register value val, next;
-
- for (val = all_values; val; val = next)
- {
- next = VALUE_NEXT (val);
- free (val);
- }
-
- all_values = 0;
-}
-
-/* Remove VAL from the chain all_values
- so it will not be freed automatically. */
-
-void
-release_value (val)
- register value val;
-{
- register value v;
-
- if (all_values == val)
- {
- all_values = val->next;
- return;
- }
-
- for (v = all_values; v; v = v->next)
- {
- if (v->next == val)
- {
- v->next = val->next;
- break;
- }
- }
-}
-
-/* Return a copy of the value ARG.
- It contains the same contents, for same memory address,
- but it's a different block of storage. */
-
-static value
-value_copy (arg)
- value arg;
-{
- register value val;
- register struct type *type = VALUE_TYPE (arg);
- if (VALUE_REPEATED (arg))
- val = allocate_repeat_value (type, VALUE_REPETITIONS (arg));
- else
- val = allocate_value (type);
- VALUE_LVAL (val) = VALUE_LVAL (arg);
- VALUE_ADDRESS (val) = VALUE_ADDRESS (arg);
- VALUE_OFFSET (val) = VALUE_OFFSET (arg);
- VALUE_BITPOS (val) = VALUE_BITPOS (arg);
- VALUE_BITSIZE (val) = VALUE_BITSIZE (arg);
- VALUE_REGNO (val) = VALUE_REGNO (arg);
- bcopy (VALUE_CONTENTS (arg), VALUE_CONTENTS (val),
- TYPE_LENGTH (VALUE_TYPE (arg))
- * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1));
- return val;
-}
-
-/* Access to the value history. */
-
-/* Record a new value in the value history.
- Returns the absolute history index of the entry. */
-
-int
-record_latest_value (val)
- value val;
-{
- int i;
- double foo;
-
- /* Check error now if about to store an invalid float. We return -1
- to the caller, but allow them to continue, e.g. to print it as "Nan". */
- if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FLT) {
- foo = unpack_double (VALUE_TYPE (val), VALUE_CONTENTS (val), &i);
- if (i) return -1; /* Indicate value not saved in history */
- }
-
- /* Here we treat value_history_count as origin-zero
- and applying to the value being stored now. */
-
- i = value_history_count % VALUE_HISTORY_CHUNK;
- if (i == 0)
- {
- register struct value_history_chunk *new
- = (struct value_history_chunk *)
- xmalloc (sizeof (struct value_history_chunk));
- bzero (new->values, sizeof new->values);
- new->next = value_history_chain;
- value_history_chain = new;
- }
-
- value_history_chain->values[i] = val;
- release_value (val);
-
- /* Now we regard value_history_count as origin-one
- and applying to the value just stored. */
-
- return ++value_history_count;
-}
-
-/* Return a copy of the value in the history with sequence number NUM. */
-
-value
-access_value_history (num)
- int num;
-{
- register struct value_history_chunk *chunk;
- register int i;
- register int absnum = num;
-
- if (absnum <= 0)
- absnum += value_history_count;
-
- if (absnum <= 0)
- {
- if (num == 0)
- error ("The history is empty.");
- else if (num == 1)
- error ("There is only one value in the history.");
- else
- error ("History does not go back to $$%d.", -num);
- }
- if (absnum > value_history_count)
- error ("History has not yet reached $%d.", absnum);
-
- absnum--;
-
- /* Now absnum is always absolute and origin zero. */
-
- chunk = value_history_chain;
- for (i = (value_history_count - 1) / VALUE_HISTORY_CHUNK - absnum / VALUE_HISTORY_CHUNK;
- i > 0; i--)
- chunk = chunk->next;
-
- return value_copy (chunk->values[absnum % VALUE_HISTORY_CHUNK]);
-}
-
-/* Clear the value history entirely.
- Must be done when new symbol tables are loaded,
- because the type pointers become invalid. */
-
-void
-clear_value_history ()
-{
- register struct value_history_chunk *next;
- register int i;
- register value val;
-
- while (value_history_chain)
- {
- for (i = 0; i < VALUE_HISTORY_CHUNK; i++)
- if (val = value_history_chain->values[i])
- free (val);
- next = value_history_chain->next;
- free (value_history_chain);
- value_history_chain = next;
- }
- value_history_count = 0;
-}
-
-static void
-value_history_info (num_exp, from_tty)
- char *num_exp;
- int from_tty;
-{
- register int i;
- register value val;
- static int num = 1;
-
- if (num_exp)
- {
- if (num_exp[0] == '+' && num_exp[1] == '\0')
- /* "info history +" should print from the stored position. */
- ;
- else
- /* "info history <exp>" should print around value number <exp>. */
- num = parse_and_eval_address (num_exp) - 5;
- }
- else
- {
- /* "info history" means print the last 10 values. */
- num = value_history_count - 9;
- }
-
- if (num <= 0)
- num = 1;
-
- for (i = num; i < num + 10 && i <= value_history_count; i++)
- {
- val = access_value_history (i);
- printf_filtered ("$%d = ", i);
- value_print (val, stdout, 0, Val_pretty_default);
- printf_filtered ("\n");
- }
-
- /* The next "info history +" should start after what we just printed. */
- num += 10;
-
- /* Hitting just return after this command should do the same thing as
- "info history +". If num_exp is null, this is unnecessary, since
- "info history +" is not useful after "info history". */
- if (from_tty && num_exp)
- {
- num_exp[0] = '+';
- num_exp[1] = '\0';
- }
-}
-
-/* Internal variables. These are variables within the debugger
- that hold values assigned by debugger commands.
- The user refers to them with a '$' prefix
- that does not appear in the variable names stored internally. */
-
-static struct internalvar *internalvars;
-
-/* Look up an internal variable with name NAME. NAME should not
- normally include a dollar sign.
-
- If the specified internal variable does not exist,
- one is created, with a void value. */
-
-struct internalvar *
-lookup_internalvar (name)
- char *name;
-{
- register struct internalvar *var;
-
- for (var = internalvars; var; var = var->next)
- if (!strcmp (var->name, name))
- return var;
-
- var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
- var->name = concat (name, "", "");
- var->value = allocate_value (builtin_type_void);
- release_value (var->value);
- var->next = internalvars;
- internalvars = var;
- return var;
-}
-
-value
-value_of_internalvar (var)
- struct internalvar *var;
-{
- register value val;
-
-#ifdef IS_TRAPPED_INTERNALVAR
- if (IS_TRAPPED_INTERNALVAR (var->name))
- return VALUE_OF_TRAPPED_INTERNALVAR (var);
-#endif
-
- val = value_copy (var->value);
- VALUE_LVAL (val) = lval_internalvar;
- VALUE_INTERNALVAR (val) = var;
- return val;
-}
-
-void
-set_internalvar_component (var, offset, bitpos, bitsize, newval)
- struct internalvar *var;
- int offset, bitpos, bitsize;
- value newval;
-{
- register char *addr = VALUE_CONTENTS (var->value) + offset;
-
-#ifdef IS_TRAPPED_INTERNALVAR
- if (IS_TRAPPED_INTERNALVAR (var->name))
- SET_TRAPPED_INTERNALVAR (var, newval, bitpos, bitsize, offset);
-#endif
-
- if (bitsize)
- modify_field (addr, (int) value_as_long (newval),
- bitpos, bitsize);
- else
- bcopy (VALUE_CONTENTS (newval), addr,
- TYPE_LENGTH (VALUE_TYPE (newval)));
-}
-
-void
-set_internalvar (var, val)
- struct internalvar *var;
- value val;
-{
-#ifdef IS_TRAPPED_INTERNALVAR
- if (IS_TRAPPED_INTERNALVAR (var->name))
- SET_TRAPPED_INTERNALVAR (var, val, 0, 0, 0);
-#endif
-
- free (var->value);
- var->value = value_copy (val);
- release_value (var->value);
-}
-
-char *
-internalvar_name (var)
- struct internalvar *var;
-{
- return var->name;
-}
-
-/* Free all internalvars. Done when new symtabs are loaded,
- because that makes the values invalid. */
-
-void
-clear_internalvars ()
-{
- register struct internalvar *var;
-
- while (internalvars)
- {
- var = internalvars;
- internalvars = var->next;
- free (var->name);
- free (var->value);
- free (var);
- }
-}
-
-static void
-convenience_info ()
-{
- register struct internalvar *var;
- int varseen = 0;
-
- for (var = internalvars; var; var = var->next)
- {
-#ifdef IS_TRAPPED_INTERNALVAR
- if (IS_TRAPPED_INTERNALVAR (var->name))
- continue;
-#endif
- if (!varseen)
- {
- printf ("Debugger convenience variables:\n\n");
- varseen = 1;
- }
- printf ("$%s: ", var->name);
- value_print (var->value, stdout, 0, Val_pretty_default);
- printf ("\n");
- }
- if (!varseen)
- printf ("No debugger convenience variables now defined.\n\
-Convenience variables have names starting with \"$\";\n\
-use \"set\" as in \"set $foo = 5\" to define them.\n");
-}
-
-/* Extract a value as a C number (either long or double).
- Knows how to convert fixed values to double, or
- floating values to long.
- Does not deallocate the value. */
-
-LONGEST
-value_as_long (val)
- register value val;
-{
- return unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val));
-}
-
-double
-value_as_double (val)
- register value val;
-{
- double foo;
- int inv;
-
- foo = unpack_double (VALUE_TYPE (val), VALUE_CONTENTS (val), &inv);
- if (inv)
- error ("Invalid floating value found in program.");
- return foo;
-}
-
-/* Unpack raw data (copied from debugee) at VALADDR
- as a long, or as a double, assuming the raw data is described
- by type TYPE. Knows how to convert different sizes of values
- and can convert between fixed and floating point.
-
- C++: It is assumed that the front-end has taken care of
- all matters concerning pointers to members. A pointer
- to member which reaches here is considered to be equivalent
- to an INT (or some size). After all, it is only an offset. */
-
-LONGEST
-unpack_long (type, valaddr)
- struct type *type;
- char *valaddr;
-{
- register enum type_code code = TYPE_CODE (type);
- register int len = TYPE_LENGTH (type);
- register int nosign = TYPE_UNSIGNED (type);
-
- if (code == TYPE_CODE_ENUM)
- code = TYPE_CODE_INT;
- if (code == TYPE_CODE_FLT)
- {
- if (len == sizeof (float))
- return * (float *) valaddr;
-
- if (len == sizeof (double))
- return * (double *) valaddr;
- }
- else if (code == TYPE_CODE_INT && nosign)
- {
- if (len == sizeof (char))
- return * (unsigned char *) valaddr;
-
- if (len == sizeof (short))
- return * (unsigned short *) valaddr;
-
- if (len == sizeof (int))
- return * (unsigned int *) valaddr;
-
- if (len == sizeof (long))
- return * (unsigned long *) valaddr;
-#ifdef LONG_LONG
- if (len == sizeof (long long))
- return * (unsigned long long *) valaddr;
-#endif
- }
- else if (code == TYPE_CODE_INT)
- {
- if (len == sizeof (char))
- return * (char *) valaddr;
-
- if (len == sizeof (short))
- return * (short *) valaddr;
-
- if (len == sizeof (int))
- return * (int *) valaddr;
-
- if (len == sizeof (long))
- return * (long *) valaddr;
-
-#ifdef LONG_LONG
- if (len == sizeof (long long))
- return * (long long *) valaddr;
-#endif
- }
- else if (code == TYPE_CODE_PTR
- || code == TYPE_CODE_REF)
- {
- if (len == sizeof (char *))
- return (CORE_ADDR) * (char **) valaddr;
- }
- else if (code == TYPE_CODE_MEMBER)
- error ("not implemented: member types in unpack_long");
-
- error ("Value not integer or pointer.");
-}
-
-/* Return a double value from the specified type and address.
- INVP points to an int which is set to 0 for valid value,
- 1 for invalid value (bad float format). In either case,
- the returned double is OK to use. */
-
-double
-unpack_double (type, valaddr, invp)
- struct type *type;
- char *valaddr;
- int *invp;
-{
- register enum type_code code = TYPE_CODE (type);
- register int len = TYPE_LENGTH (type);
- register int nosign = TYPE_UNSIGNED (type);
-
- *invp = 0; /* Assume valid. */
- if (code == TYPE_CODE_FLT)
- {
- if (INVALID_FLOAT (valaddr, len))
- {
- *invp = 1;
- return 1.234567891011121314;
- }
-
- if (len == sizeof (float))
- return * (float *) valaddr;
-
- if (len == sizeof (double))
- {
- /* Some machines require doubleword alignment for doubles.
- This code works on them, and on other machines. */
- double temp;
- bcopy ((char *) valaddr, (char *) &temp, sizeof (double));
- return temp;
- }
- }
- else if (code == TYPE_CODE_INT && nosign)
- {
- if (len == sizeof (char))
- return * (unsigned char *) valaddr;
-
- if (len == sizeof (short))
- return * (unsigned short *) valaddr;
-
- if (len == sizeof (int))
- return * (unsigned int *) valaddr;
-
- if (len == sizeof (long))
- return * (unsigned long *) valaddr;
-
-#ifdef LONG_LONG
- if (len == sizeof (long long))
- return * (unsigned long long *) valaddr;
-#endif
- }
- else if (code == TYPE_CODE_INT)
- {
- if (len == sizeof (char))
- return * (char *) valaddr;
-
- if (len == sizeof (short))
- return * (short *) valaddr;
-
- if (len == sizeof (int))
- return * (int *) valaddr;
-
- if (len == sizeof (long))
- return * (long *) valaddr;
-
-#ifdef LONG_LONG
- if (len == sizeof (long long))
- return * (long long *) valaddr;
-#endif
- }
-
- error ("Value not floating number.");
- /* NOTREACHED */
- return (double) 0; /* To silence compiler warning. */
-}
-
-/* Given a value ARG1 of a struct or union type,
- extract and return the value of one of its fields.
- FIELDNO says which field.
-
- For C++, must also be able to return values from static fields */
-
-value
-value_field (arg1, fieldno)
- register value arg1;
- register int fieldno;
-{
- register value v;
- register struct type *type = TYPE_FIELD_TYPE (VALUE_TYPE (arg1), fieldno);
- register int offset;
-
- /* Handle packed fields */
-
- offset = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) / 8;
- if (TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno))
- {
- v = value_from_long (type,
- unpack_field_as_long (VALUE_TYPE (arg1),
- VALUE_CONTENTS (arg1),
- fieldno));
- VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) % 8;
- VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno);
- }
- else
- {
- v = allocate_value (type);
- bcopy (VALUE_CONTENTS (arg1) + offset,
- VALUE_CONTENTS (v),
- TYPE_LENGTH (type));
- }
- VALUE_LVAL (v) = VALUE_LVAL (arg1);
- if (VALUE_LVAL (arg1) == lval_internalvar)
- VALUE_LVAL (v) = lval_internalvar_component;
- VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1);
- VALUE_OFFSET (v) = offset + VALUE_OFFSET (arg1);
- return v;
-}
-
-value
-value_fn_field (arg1, fieldno, subfieldno)
- register value arg1;
- register int fieldno;
-{
- register value v;
- struct fn_field *f = TYPE_FN_FIELDLIST1 (VALUE_TYPE (arg1), fieldno);
- register struct type *type = TYPE_FN_FIELD_TYPE (f, subfieldno);
- struct symbol *sym;
-
- sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, subfieldno),
- 0, VAR_NAMESPACE, 0);
- if (! sym) error ("Internal error: could not find physical method named %s",
- TYPE_FN_FIELD_PHYSNAME (f, subfieldno));
-
- v = allocate_value (type);
- VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
- VALUE_TYPE (v) = type;
- return v;
-}
-
-/* Return a virtual function as a value.
- ARG1 is the object which provides the virtual function
- table pointer.
- F is the list of member functions which contains the desired virtual
- function.
- J is an index into F which provides the desired virtual function.
- TYPE is the basetype which first provides the virtual function table. */
-value
-value_virtual_fn_field (arg1, f, j, type)
- value arg1;
- struct fn_field *f;
- int j;
- struct type *type;
-{
- /* First, get the virtual function table pointer. That comes
- with a strange type, so cast it to type `pointer to long' (which
- should serve just fine as a function type). Then, index into
- the table, and convert final value to appropriate function type. */
- value vfn, vtbl;
- value vi = value_from_long (builtin_type_int,
- (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j));
- VALUE_TYPE (arg1) = TYPE_VPTR_BASETYPE (type);
-
- /* This type may have been defined before its virtual function table
- was. If so, fill in the virtual function table entry for the
- type now. */
- if (TYPE_VPTR_FIELDNO (type) < 0)
- TYPE_VPTR_FIELDNO (type)
- = fill_in_vptr_fieldno (type);
-
- /* The virtual function table is now an array of structures
- which have the form { int16 offset, delta; void *pfn; }. */
- vtbl = value_ind (value_field (arg1, TYPE_VPTR_FIELDNO (type)));
-
- /* Index into the virtual function table. This is hard-coded because
- looking up a field is not cheap, and it may be important to save
- time, e.g. if the user has set a conditional breakpoint calling
- a virtual function. */
- vfn = value_field (value_subscript (vtbl, vi), 2);
-
- /* Reinstantiate the function pointer with the correct type. */
- VALUE_TYPE (vfn) = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j));
- return vfn;
-}
-
-/* The value of a static class member does not depend
- on its instance, only on its type. If FIELDNO >= 0,
- then fieldno is a valid field number and is used directly.
- Otherwise, FIELDNAME is the name of the field we are
- searching for. If it is not a static field name, an
- error is signaled. TYPE is the type in which we look for the
- static field member. */
-value
-value_static_field (type, fieldname, fieldno)
- register struct type *type;
- char *fieldname;
- register int fieldno;
-{
- register value v;
- struct symbol *sym;
-
- if (fieldno < 0)
- {
- register struct type *t = type;
- /* Look for static field. */
- while (t)
- {
- int i;
- for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
- if (! strcmp (TYPE_FIELD_NAME (t, i), fieldname))
- {
- if (TYPE_FIELD_STATIC (t, i))
- {
- fieldno = i;
- goto found;
- }
- else
- error ("field `%s' is not static");
- }
- t = TYPE_BASECLASSES (t) ? TYPE_BASECLASS (t, 1) : 0;
- }
-
- t = type;
-
- if (destructor_name_p (fieldname, t))
- error ("use `info method' command to print out value of destructor");
-
- while (t)
- {
- int i, j;
-
- for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; i--)
- {
- if (! strcmp (TYPE_FN_FIELDLIST_NAME (t, i), fieldname))
- {
- error ("use `info method' command to print value of method \"%s\"", fieldname);
- }
- }
- t = TYPE_BASECLASSES (t) ? TYPE_BASECLASS (t, 1) : 0;
- }
- error("there is no field named %s", fieldname);
- }
-
- found:
-
- sym = lookup_symbol (TYPE_FIELD_STATIC_PHYSNAME (type, fieldno),
- 0, VAR_NAMESPACE, 0);
- if (! sym) error ("Internal error: could not find physical static variable named %s", TYPE_FIELD_BITSIZE (type, fieldno));
-
- type = TYPE_FIELD_TYPE (type, fieldno);
- v = value_at (type, (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym));
- return v;
-}
-
-long
-unpack_field_as_long (type, valaddr, fieldno)
- struct type *type;
- char *valaddr;
- int fieldno;
-{
- long val;
- int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
- int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
-
- bcopy (valaddr + bitpos / 8, &val, sizeof val);
-
- /* Extracting bits depends on endianness of the machine. */
-#ifdef BITS_BIG_ENDIAN
- val = val >> (sizeof val * 8 - bitpos % 8 - bitsize);
-#else
- val = val >> (bitpos % 8);
-#endif
-
- val &= (1 << bitsize) - 1;
- return val;
-}
-
-void
-modify_field (addr, fieldval, bitpos, bitsize)
- char *addr;
- int fieldval;
- int bitpos, bitsize;
-{
- long oword;
-
- /* Reject values too big to fit in the field in question.
- Otherwise adjoining fields may be corrupted. */
- if (fieldval & ~((1<<bitsize)-1))
- error ("Value %d does not fit in %d bits.", fieldval, bitsize);
-
- bcopy (addr, &oword, sizeof oword);
-
- /* Shifting for bit field depends on endianness of the machine. */
-#ifdef BITS_BIG_ENDIAN
- bitpos = sizeof (oword) * 8 - bitpos - bitsize;
-#endif
-
- oword &= ~(((1 << bitsize) - 1) << bitpos);
- oword |= fieldval << bitpos;
- bcopy (&oword, addr, sizeof oword);
-}
-
-/* Convert C numbers into newly allocated values */
-
-value
-value_from_long (type, num)
- struct type *type;
- register LONGEST num;
-{
- register value val = allocate_value (type);
- register enum type_code code = TYPE_CODE (type);
- register int len = TYPE_LENGTH (type);
-
- if (code == TYPE_CODE_INT || code == TYPE_CODE_ENUM)
- {
- if (len == sizeof (char))
- * (char *) VALUE_CONTENTS (val) = num;
- else if (len == sizeof (short))
- * (short *) VALUE_CONTENTS (val) = num;
- else if (len == sizeof (int))
- * (int *) VALUE_CONTENTS (val) = num;
- else if (len == sizeof (long))
- * (long *) VALUE_CONTENTS (val) = num;
-#ifdef LONG_LONG
- else if (len == sizeof (long long))
- * (long long *) VALUE_CONTENTS (val) = num;
-#endif
- else
- error ("Integer type encountered with unexpected data length.");
- }
- else
- error ("Unexpected type encountered for integer constant.");
-
- return val;
-}
-
-value
-value_from_double (type, num)
- struct type *type;
- double num;
-{
- register value val = allocate_value (type);
- register enum type_code code = TYPE_CODE (type);
- register int len = TYPE_LENGTH (type);
-
- if (code == TYPE_CODE_FLT)
- {
- if (len == sizeof (float))
- * (float *) VALUE_CONTENTS (val) = num;
- else if (len == sizeof (double))
- * (double *) VALUE_CONTENTS (val) = num;
- else
- error ("Floating type encountered with unexpected data length.");
- }
- else
- error ("Unexpected type encountered for floating constant.");
-
- return val;
-}
-
-/* Deal with the value that is "about to be returned". */
-
-/* Return the value that a function returning now
- would be returning to its caller, assuming its type is VALTYPE.
- RETBUF is where we look for what ought to be the contents
- of the registers (in raw form). This is because it is often
- desirable to restore old values to those registers
- after saving the contents of interest, and then call
- this function using the saved values.
- struct_return is non-zero when the function in question is
- using the structure return conventions on the machine in question;
- 0 when it is using the value returning conventions (this often
- means returning pointer to where structure is vs. returning value). */
-
-value
-value_being_returned (valtype, retbuf, struct_return)
- register struct type *valtype;
- char retbuf[REGISTER_BYTES];
- int struct_return;
-{
- register value val;
-
- if (struct_return)
- return value_at (valtype, EXTRACT_STRUCT_VALUE_ADDRESS (retbuf));
-
- val = allocate_value (valtype);
- EXTRACT_RETURN_VALUE (valtype, retbuf, VALUE_CONTENTS (val));
-
- return val;
-}
-
-/* Return true if the function specified is using the structure returning
- convention on this machine to return arguments, or 0 if it is using
- the value returning convention. FUNCTION is the value representing
- the function, FUNCADDR is the address of the function, and VALUE_TYPE
- is the type returned by the function */
-
-struct block *block_for_pc ();
-
-int
-using_struct_return (function, funcaddr, value_type)
- value function;
- CORE_ADDR funcaddr;
- struct type *value_type;
-{
- register enum type_code code = TYPE_CODE (value_type);
-
- if (code == TYPE_CODE_STRUCT ||
- code == TYPE_CODE_UNION ||
- code == TYPE_CODE_ARRAY)
- {
- struct block *b = block_for_pc (funcaddr);
-
- if (!(BLOCK_GCC_COMPILED (b) && TYPE_LENGTH (value_type) < 8))
- return 1;
- }
-
- return 0;
-}
-
-/* Store VAL so it will be returned if a function returns now.
- Does not verify that VAL's type matches what the current
- function wants to return. */
-
-void
-set_return_value (val)
- value val;
-{
- register enum type_code code = TYPE_CODE (VALUE_TYPE (val));
- char regbuf[REGISTER_BYTES];
- double dbuf;
- LONGEST lbuf;
-
- if (code == TYPE_CODE_STRUCT
- || code == TYPE_CODE_UNION)
- error ("Specifying a struct or union return value is not supported.");
-
- if (code == TYPE_CODE_FLT)
- {
- dbuf = value_as_double (val);
-
- STORE_RETURN_VALUE (VALUE_TYPE (val), &dbuf);
- }
- else
- {
- lbuf = value_as_long (val);
- STORE_RETURN_VALUE (VALUE_TYPE (val), &lbuf);
- }
-}
-
-void
-_initialize_values ()
-{
- add_info ("convenience", convenience_info,
- "Debugger convenience (\"$foo\") variables.\n\
-These variables are created when you assign them values;\n\
-thus, \"print $foo=1\" gives \"$foo\" the value 1. Values may be any type.\n\n\
-A few convenience variables are given values automatically GDB:\n\
-\"$_\"holds the last address examined with \"x\" or \"info lines\",\n\
-\"$__\" holds the contents of the last address examined with \"x\".");
-
- add_info ("values", value_history_info,
- "Elements of value history (around item number IDX, or last ten).");
- add_info_alias ("history", value_history_info, 0);
-}
diff --git a/gnu/usr.bin/gdb/version.c b/gnu/usr.bin/gdb/version.c
deleted file mode 100644
index 2f3dd85..0000000
--- a/gnu/usr.bin/gdb/version.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Define the current version number of GDB.
- Copyright (C) 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. */
-
-char *version = "3.5";
diff --git a/gnu/usr.bin/gdb/wait.h b/gnu/usr.bin/gdb/wait.h
deleted file mode 100644
index c431cb6..0000000
--- a/gnu/usr.bin/gdb/wait.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Van Jacobson and Steven McCanne of Lawrence Berkeley Laboratory.
- *
- * 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.
- *
- * @(#)wait.h 6.3 (Berkeley) 5/8/91
- */
-
-/* Define how to access the structure that the wait system call stores.
- On many systems, there is a structure defined for this.
- But on vanilla-ish USG systems there is not. */
-
-#ifndef HAVE_WAIT_STRUCT
-
-#define WAITTYPE int
-#define WIFSTOPPED(w) (((w)&0377) == 0177)
-#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
-#define WIFEXITED(w) (((w)&0377) == 0)
-#define WEXITSTATUS(w) ((w) >> 8)
-#define WSTOPSIG(w) ((w) >> 8)
-#define WCOREDUMP(w) (((w)&0200) != 0)
-#define WTERMSIG(w) ((w) & 0177)
-#define WSETEXIT(w, status) ((w) = (status))
-#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
-
-#else
-
-#include <sys/wait.h>
-
-#define WAITTYPE union wait
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(w) (w).w_retcode
-#endif
-#ifndef WSTOPSIG
-#define WSTOPSIG(w) (w).w_stopsig
-#endif
-#ifndef WCOREDUMP
-#define WCOREDUMP(w) (w).w_coredump
-#endif
-#ifndef WTERMSIG
-#define WTERMSIG(w) (w).w_termsig
-#endif
-#ifndef WSETEXIT
-#define WSETEXIT(w, status) ((w).w_status = (status))
-#endif
-#ifndef WSETSTOP
-#define WSETSTOP(w,sig) \
- ((w).w_stopsig = (sig), (w).w_coredump = 0, (w).w_termsig = 0177)
-#endif
-
-#endif
diff --git a/gnu/usr.bin/gdb/xgdb/Makefile b/gnu/usr.bin/gdb/xgdb/Makefile
deleted file mode 100644
index 72c5359..0000000
--- a/gnu/usr.bin/gdb/xgdb/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-# %W% (Berkeley) %G%
-
-.include "../config/Makefile.$(MACHINE)"
-
-PROG= xgdb
-SRCS= xgdb.c xgdbinit.c
-GDBOBJS+= $(CONFIGSRCS:R:S/$/.o/g) \
- blockframe.o breakpoint.o command.o copying.o core.o \
- cplus-dem.o dbxread.o environ.o eval.o expprint.o \
- expread.o findvar.o infcmd.o inflow.o infrun.o \
- main.o obstack.o printcmd.o regex.o remote.o \
- remote-sl.o source.o stack.o symmisc.o symtab.o \
- utils.o valarith.o valops.o valprint.o values.o \
- version.o \
- funmap.o history.o keymaps.o readline.o
-CFLAGS+= -I.. -I$(.CURDIR)/.. -I$(.CURDIR)/../config \
- -DHAVE_VPRINTF -DVI_MODE -DKERNELDEBUG
-LDFLAGS+= -L/usr/lib/X11
-LDADD+= $(GDBOBJS:S/^/..\//g) -lXaw -lXmu -lXt -lXext -lX11 -ltermcap
-NOMAN= noman
-
-.include "../../Makefile.inc"
-.include <bsd.prog.mk>
-
-#
-# Generate the constructor
-#
-xgdbinit.c: ../init.c xgdb.c
- -(sed -e '/^}$$/d' ../init.c; \
- egrep -h '^_initialize_[^ ]* *\(\)' $(.CURDIR)/xgdb.c; \
- echo ';}') > xgdbinit.c
-
-CLEANFILES+= xgdbinit.c
diff --git a/gnu/usr.bin/gdb/xgdb/xgdb.c b/gnu/usr.bin/gdb/xgdb/xgdb.c
deleted file mode 100644
index a2bd4f6..0000000
--- a/gnu/usr.bin/gdb/xgdb/xgdb.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory.
- *
- * static char rcsid[] = "$Header: /home/cvs/386BSD/src/usr.bin/gdb/xgdb/xgdb.c,v 1.1.1.1 1993/06/12 14:52:36 rgrimes Exp $";
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)xgdb.c 6.3 (Berkeley) 5/8/91";
-#endif /* not lint */
-
-/*
- * Interface from GDB to X windows. Copyright (C) 1987 Free Software
- * Foundation, Inc.
- *
- * GDB 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 GDB
- * General Public License for full details.
- *
- * Everyone is granted permission to copy, modify and redistribute GDB, but only
- * under the conditions described in the GDB General Public License. A copy
- * of this license is supposed to have been given to you along with GDB 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.
- *
- * In other words, go ahead and share GDB, but don't try to stop anyone else
- * from sharing it farther. Help stamp out software hoarding!
- */
-
-/*
- * Original version was contributed by Derek Beatty, 30 June 87.
- * This version is essentially a re-write of the original by Van
- * Jacobson (van@helios.ee.lbl.gov), Nov, 90.
- */
-
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-
-extern int stop_breakpoint;
-
-#include <X11/IntrinsicP.h>
-#include <X11/StringDefs.h>
-#include <X11/Xaw/AsciiSink.h>
-#include <X11/Xaw/AsciiText.h>
-#include <X11/Xaw/Box.h>
-#include <X11/Xaw/Command.h>
-#include <X11/Xaw/Label.h>
-#include <X11/Xaw/Paned.h>
-#include <X11/Xaw/Text.h>
-
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/file.h>
-#include <sys/errno.h>
-
-extern int errno;
-extern char *getenv();
-extern char *malloc();
-extern void bcopy();
-extern int select();
-
-extern int get_filename_and_charpos();
-extern int source_line_charpos();
-extern int source_charpos_line();
-extern void execute_command();
-extern void error_no_arg();
-extern void add_com();
-
-/* The X display where the window appears. */
-
-static char *displayname;
-static Display *display;
-
-static XtAppContext app_context;
-
-/* Windows manipulated by this package. */
-
-static Widget main_widget;
-static Widget containing_widget;
-static Widget source_name_widget;
-static Widget source_text_widget;
-static Widget button_box_widget;
-
-/* Source text display. */
-
-static struct frame_info *last_fi;
-static CORE_ADDR last_pc;
-static struct symtab *last_cur_symtab;
-static int last_cur_line;
-
-static int source_window_line;
-static char *source_window_file;
-static struct symtab *source_window_symtab;
-
-static char version_label[64];
-extern char *version;
-
-/* Forward declarations */
-
-static Widget create_text_widget();
-
-static int
-safe_strcmp(a, b)
- register char *a, *b;
-{
- register int i;
-
- if (a == b)
- return (0);
- if (!a && b)
- return (1);
- if (a && !b)
- return (-1);
- return (strcmp(a, b));
-}
-
-
-/* Display an appropriate piece of source code in the source window. */
-
-void
-xgdb_display_source()
-{
- char *filename = NULL;
- struct symtab_and_line get_selected_frame_sal();
- struct symtab_and_line sal;
- struct frame_info *fi;
-
- /* Do nothing if called before we are initialized */
-
- if (!containing_widget)
- return;
-
- /*
- * Figure out what to display (the appropriate hooks to tell
- * us don't exist so we guess): If there's a current frame
- * and it or its pc changed from the last time we were here,
- * display appropriate source line. Otherwise if the current
- * source symtab or line is different, display that line.
- * Otherwise nothing changed so leave the display alone.
- */
- fi = get_frame_info(selected_frame);
- if (fi && (fi != last_fi || fi->pc != last_pc)) {
- last_fi = fi;
- last_pc = fi->pc;
- sal = find_pc_line(fi->pc, fi->next_frame);
- if (sal.symtab == NULL) { /* XXX */
- sal.symtab = current_source_symtab;
- sal.line = current_source_line;
- }
- current_source_symtab = sal.symtab;
- current_source_line = sal.line;
- } else if (current_source_symtab != last_cur_symtab ||
- current_source_line != last_cur_line) {
- sal.symtab = last_cur_symtab = current_source_symtab;
- sal.line = last_cur_line = current_source_line;
- } else
- return;
- /*
- * Do a path search and get the exact filename of this source file.
- * Also scan it and find its source lines if not already done.
- */
- if (sal.symtab && filename == NULL) {
- if (get_filename_and_charpos(sal.symtab, sal.line, &filename))
- /* line numbers may have changed - force highlight */
- source_window_line = -1;
- }
-
- /*
- * If the source window is wrong, destroy it and make a new one.
- */
- if (safe_strcmp(filename, source_window_file)) {
- Arg args[1];
- Widget src = XawTextGetSource(source_text_widget);
-
- if (filename) {
- XtSetArg(args[0], XtNstring, filename);
- XtSetValues(src, args, XtNumber(args));
- args[0].name = XtNlabel;
- XtSetValues(source_name_widget, args, XtNumber(args));
- } else {
- XtSetArg(args[0], XtNstring, "/dev/null");
- XtSetValues(src, args, XtNumber(args));
- XtSetArg(args[0], XtNlabel, "");
- XtSetValues(source_name_widget, args, XtNumber(args));
- }
- if (source_window_file)
- free(source_window_file);
- source_window_file = filename;
- source_window_line = sal.line + 1; /* force highlight */
- }
- if (sal.symtab && source_window_line != sal.line) {
- /*
- * Update display and cursor positions as necessary.
- * Cursor should be placed on line sal.line.
- */
- XawTextPosition l, r;
-
- source_window_symtab = sal.symtab;
- source_window_line = sal.line;
- l = source_line_charpos(source_window_symtab, sal.line);
- r = source_line_charpos(source_window_symtab, sal.line + 1);
- if (r < l)
- r = l + 1;
- XawTextSetSelection(source_text_widget, l, r);
- XawTextScrollToLine(source_text_widget, l, 10, 3);
- XawTextSetInsertionPoint(source_text_widget, l);
- }
-}
-
-
-/*
- * Handlers for buttons.
- */
-
-static int
-current_lineno()
-{
- XawTextPosition start, finish;
-
- XawTextGetSelectionPos(source_text_widget, &start, &finish);
- if (start >= finish)
- start = XawTextGetInsertionPoint(source_text_widget);
-
- return (source_charpos_line(source_window_symtab, start));
-}
-
-static char *
-append_selection(cp)
- char *cp;
-{
- int len;
- XawTextPosition l, r;
-
- XawTextGetSelectionPos(source_text_widget, &l, &r);
- if ((len = r - l) > 0) {
- Widget src = XawTextGetSource(source_text_widget);
-
- while (len > 0) {
- XawTextBlock tb;
-
- XawTextSourceRead(src, l, &tb, len);
- bcopy(tb.ptr, cp, tb.length);
- cp += tb.length;
- len -= tb.length;
- }
- if (cp[-1] == 0)
- --cp;
- }
- return (cp);
-}
-
-static char *
-append_selection_word(cp)
- register char *cp;
-{
- register int len;
- XawTextPosition l, r;
- XawTextBlock tb;
- register char c;
- register Widget src = XawTextGetSource(source_text_widget);
-
- XawTextGetSelectionPos(source_text_widget, &l, &r);
- if ((len = r - l) <= 0) {
- l = XawTextGetInsertionPoint(source_text_widget);
- len = 128; /* XXX */
-
- /* might have clicked in middle of word -- back up to start */
- for ( ; l > 0; --l) {
- XawTextSourceRead(src, l - 1, &tb, 1);
- c = tb.ptr[0];
- if (! isalnum(c) && c != '_' && c != '$')
- break;
- }
- }
- while (len > 0) {
- char *sp;
- int i;
-
- XawTextSourceRead(src, l, &tb, len);
- for (sp = tb.ptr, i = tb.length; --i >= 0; ) {
- c = *sp++;
- if (!isalnum(c) && c != '_' && c != '$')
- return (cp);
- *cp++ = c;
- }
- len -= tb.length;
- }
- return (cp);
-}
-
-static char *
-append_selection_expr(cp)
- char *cp;
-{
- int len;
- XawTextPosition l, r;
- Widget src = XawTextGetSource(source_text_widget);
- XawTextBlock tb;
- char *sp;
- char c;
-
- XawTextGetSelectionPos(source_text_widget, &l, &r);
- if (r > l)
- return (append_selection(cp));
-
- l = XawTextGetInsertionPoint(source_text_widget);
-
- /* might have clicked in middle of word -- back up to start */
- for ( ; l > 0; --l) {
- XawTextSourceRead(src, l - 1, &tb, 1);
- c = tb.ptr[0];
- if (! isalnum(c) && c != '_' && c != '$')
- break;
- }
-
- len = 128; /* XXX */
- while (len > 0) {
- int i;
- char pstack[64];
- int pcnt = 0;
-
- XawTextSourceRead(src, l, &tb, len);
- for (sp = tb.ptr, i = tb.length; --i >= 0; ) {
- switch (c = *sp++) {
- case '\n':
- case ';':
- return (cp);
- case '=':
- if (cp[-1] != '=')
- return (cp - 1);
- if (len == 128)
- return (cp);
- break;
- case ',':
- if (pcnt <= 0)
- return (cp);
- break;
- case '(':
- pstack[pcnt] = ')';
- if (++pcnt >= sizeof(pstack))
- return (cp);
- break;
- case '[':
- pstack[pcnt] = ']';
- if (++pcnt >= sizeof(pstack))
- return (cp);
- break;
- case ')':
- case ']':
- if (--pcnt < 0 || pstack[pcnt] != c)
- return (cp);
- break;
- }
- *cp++ = c;
- }
- len -= tb.length;
- }
- return (cp);
-}
-
-static int input_avail; /* XXX kluge: do_command sets this when command
- * data from button is avaialble to force top level
- * to break out of its loop. */
-/*
- * Handle a button by running the command COMMAND.
- */
-static void
-do_command(w, command, call_data)
- Widget w;
- register char *command;
- caddr_t call_data;
-{
- char cmd_line[256];
- char buf[256];
- register char *out = cmd_line;
- char *cp;
- register char c;
- extern char *finish_command_input();
-
- while (c = *command++) {
- if (c == '%') {
- switch (*command++) {
- case 's': /* current selection */
- out = append_selection(out);
- break;
- case 'S': /* 1st selected "word" at curor */
- out = append_selection_word(out);
- break;
- case 'e': /* echo cmd before executing */
- break;
- case 'E': /* 1st selected expression at curor */
- out = append_selection_expr(out);
- break;
-
- case 'l': /* current line number */
- (void) sprintf(buf, "%d", current_lineno());
- for (cp = buf; c = *cp++; *out++ = c)
- ;
- break;
- case 'L': /* line we're stopped at */
- (void) sprintf(buf, "%d", source_window_line);
- for (cp = buf; c = *cp++; *out++ = c)
- ;
- break;
- case 'f': /* current file name */
- for (cp = source_window_symtab->filename;
- c = *cp++; *out++ = c)
- ;
- break;
- case 'b': /* break # we're stopped at */
- if (stop_breakpoint <= 0)
- /* if no breakpoint, don't do cmd */
- return;
-
- (void) sprintf(buf, "%d", stop_breakpoint);
- for (cp = buf; c = *cp++; *out++ = c)
- ;
- break;
- }
- } else
- *out++ = c;
- }
- *out = 0;
- reinitialize_more_filter();
- /* have to exit via readline or tty modes stay messed up */
- for (cp = cmd_line; c = *cp++; )
- rl_stuff_char(c);
- rl_stuff_char('\n');
- input_avail = 1;
-}
-
-/*
- * Define and display all the buttons.
- */
-static void
-addbutton(parent, name, function, closure)
- Widget parent;
- char *name;
- void (*function) ();
- caddr_t closure;
-{
- static XtCallbackRec Callback[] = {
- {NULL, (caddr_t) NULL},
- {NULL, (caddr_t) NULL},
- };
- static Arg commandArgs[] = {
- {XtNlabel, (XtArgVal) NULL},
- {XtNcallback, (XtArgVal) Callback},
- };
- Widget w;
- char wname[128];
- register char *cp;
-
- strcpy(wname, name);
- while ((cp = index(wname, '*')) || (cp = index(wname, '.')))
- *cp -= 0x10;
-
- if (w = XtNameToWidget(parent, wname))
- XtDestroyWidget(w);
-
- Callback[0].callback = (XtCallbackProc) function;
- Callback[0].closure = (caddr_t) closure;
- commandArgs[0].value = (XtArgVal) name;
- XtCreateManagedWidget(wname, commandWidgetClass, parent,
- commandArgs, XtNumber(commandArgs));
-}
-
-/*
- * Create the button windows and store them in `buttons'.
- */
-static void
-create_buttons(parent)
- Widget parent;
-{
- addbutton(parent, "quit", do_command, "quit");
-}
-
-static void
-button_command(arg)
- char *arg;
-{
- char *label;
- unsigned int len;
-
- if (! arg)
- error_no_arg("button label and command");
-
- for (len = strlen(arg); len > 0 && isspace(arg[len - 1]); --len)
- ;
- if (len == 0)
- error_no_arg("button label and command");
- arg[len] = 0;
-
- /* make a copy of button label & command for toolkit to use */
- label = malloc(len + 1);
- strcpy(label, arg);
-
- /* find the end of the label */
- if (*label == '"') {
- if ((arg = index(++label, '"')) == 0) {
- printf("button label missing closing quote\n");
- return;
- }
- *arg++ = 0;
- } else if (arg = index(label, ' '))
- *arg++ = 0;
- else
- arg = label;
-
- while (*arg && isspace(*arg))
- ++arg;
-
- addbutton(button_box_widget, label, do_command, arg);
-}
-
-static void
-button_delete_command(arg)
- char *arg;
-{
- unsigned int len;
- Widget w;
- register char *cp;
-
- if (! arg)
- error_no_arg("button name");
-
- for (len = strlen(arg); len > 0 && isspace(arg[len - 1]); --len)
- ;
- if (len == 0)
- error_no_arg("button name");
- arg[len] = 0;
-
- /* find the end of the label */
- if (*arg == '"') {
- if ((cp = index(++arg, '"')) == 0) {
- printf("button label missing closing quote\n");
- return;
- }
- *cp++ = 0;
- }
- while ((cp = index(arg, '*')) || (cp = index(arg, '.')))
- *cp -= 0x10;
-
- if (w = XtNameToWidget(button_box_widget, arg))
- XtDestroyWidget(w);
-}
-
-/*
- * Create a "label window" that just displays the string LABEL.
- */
-static Widget
-create_label(name, label)
- char *name, *label;
-{
- Arg args[1];
- Widget w;
-
- XtSetArg(args[0], XtNlabel, label);
- w = XtCreateManagedWidget(name, labelWidgetClass, containing_widget,
- args, XtNumber(args));
- return (w);
-}
-
-/*
- * Create a subwindow of PARENT that displays and scrolls the contents of
- * file FILENAME.
- */
-static Widget
-create_text_widget(parent, filename)
- Widget parent;
- char *filename;
-{
- static Arg arg[] = {
- {XtNstring, NULL},
- {XtNtype, XawAsciiFile},
- {XtNcursor, None},
- };
- Widget text_widget;
-
- arg[0].value = (XtArgVal)filename;
- text_widget = XtCreateManagedWidget("src", asciiTextWidgetClass,
- parent, arg, XtNumber(arg));
- return (text_widget);
-}
-
-/*
- * Entry point to create the widgets representing our display.
- */
-void
-xgdb_create_window()
-{
- /* initialize toolkit, setup defaults */
-#ifdef notyet
- main_widget = XtAppInitialize(&app_context, "Xgdb", NULL, 0,
- argcptr, argv, NULL, NULL, 0);
-#else
- char *dummy_argv[] = { "xgdb", 0 };
- int dummy_argc = 1;
- main_widget = XtAppInitialize(&app_context, "Xgdb", NULL, 0,
- &dummy_argc, dummy_argv, NULL, NULL, 0);
-#endif
- display = XtDisplay(main_widget);
- containing_widget = XtCreateManagedWidget("frame", panedWidgetClass,
- main_widget, NULL, 0);
-
- sprintf(version_label, "XGDB %s", version);
- button_box_widget = XtCreateManagedWidget("buttons", boxWidgetClass,
- containing_widget, NULL, 0);
- create_buttons(button_box_widget);
- source_name_widget = create_label("srcLabel", "No source file yet.");
- source_text_widget = create_text_widget(containing_widget, "/dev/null");
-
- XtRealizeWidget(main_widget);
- XFlush(display);
-}
-
-/*
- * If we use an X window, the readline input loop is told to call
- * this function before reading a character from stdin.
- */
-/*ARGSUSED*/
-static void
-xgdb_window_hook()
-{
- register int inmask = 1 << fileno(stdin);
- register int xmask = 1 << ConnectionNumber(display);
- register int nfds, pend;
- int input_rfds;
- XEvent ev;
-
- /*
- * Display our current idea of the `interesting' source file then
- * loop, dispatching window events until data is available on
- * stdin. Then return so the input data can be processed.
- */
- input_avail = 0;
- xgdb_display_source();
-
- input_rfds = 0;
- while (input_avail == 0 && (input_rfds & inmask) == 0) {
- pend = XPending(display);
- if (!pend) {
- input_rfds = inmask | xmask;
- nfds = select(32, &input_rfds, 0, 0,
- (struct timeval *)0);
- if (nfds == -1 && errno == EINTR)
- continue;
- }
- if (pend || (input_rfds & xmask)) {
- XNextEvent(display, &ev);
- XtDispatchEvent(&ev);
- }
- }
-}
-
-void
-_initialize_xgdb()
-{
- extern void (*window_hook) ();
- extern int inhibit_windows;
- extern struct cmd_list_element *deletelist;
-
- if (inhibit_windows)
- return;
-
- if (! displayname) {
- displayname = getenv("DISPLAY");
- if (! displayname) {
- fprintf(stderr, "xgdb: no display name\n");
- inhibit_windows = 1;
- return;
- }
- }
- xgdb_create_window();
- window_hook = xgdb_window_hook;
- add_com("button", class_support, button_command,
-"Add command button to xgdb window. First argument is button\n\
-label, second is command associated with button. Command can\n\
-include printf-like escapes:\n\
- %s for current selection,\n\
- %S for first 'word' of current selection,\n\
- %e for current selection or expression at insertion pt,\n\
- %E for current selection or expression at insertion pt,\n\
- %l for current line number,\n\
- %L for line program stopped at,\n\
- %f for current file name,\n\
- %b for current breakpoint number.");
- add_cmd("button", class_support, button_delete_command,
-"Delete a button from the xgdb window.\n\
-Argument is name of button to be deleted.",
- &deletelist);
-}
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 c8d4915..0000000
--- a/gnu/usr.bin/grep/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-PROG= grep
-SRCS= dfa.c grep.c getopt.c kwset.c obstack.c regex.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
-
-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 fc649af..0000000
--- a/gnu/usr.bin/grep/dfa.c
+++ /dev/null
@@ -1,2525 +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(C) && !isspace(C))
-#endif
-
-#ifdef isascii
-#define ISALPHA(C) (isascii(C) && isalpha(C))
-#define ISUPPER(C) (isascii(C) && isupper(C))
-#define ISLOWER(C) (isascii(C) && islower(C))
-#define ISDIGIT(C) (isascii(C) && isdigit(C))
-#define ISXDIGIT(C) (isascii(C) && isxdigit(C))
-#define ISSPACE(C) (isascii(C) && isspace(C))
-#define ISPUNCT(C) (isascii(C) && ispunct(C))
-#define ISALNUM(C) (isascii(C) && isalnum(C))
-#define ISPRINT(C) (isascii(C) && isprint(C))
-#define ISGRAPH(C) (isascii(C) && isgraph(C))
-#define ISCNTRL(C) (isascii(C) && iscntrl(C))
-#else
-#define ISALPHA(C) isalpha(C)
-#define ISUPPER(C) isupper(C)
-#define ISLOWER(C) islower(C)
-#define ISDIGIT(C) isdigit(C)
-#define ISXDIGIT(C) isxdigit(C)
-#define ISSPACE(C) isspace(C)
-#define ISPUNCT(C) ispunct(C)
-#define ISALNUM(C) isalnum(C)
-#define ISPRINT(C) isprint(C)
-#define ISGRAPH(C) isgraph(C)
-#define ISCNTRL(C) iscntrl(C)
-#endif
-
-#include "dfa.h"
-#include "regex.h"
-
-#if __STDC__
-typedef void *ptr_t;
-#else
-typedef char *ptr_t;
-#endif
-
-static void dfamust();
-
-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;
- while (c <= c2)
- {
- setbit(c, ccl);
- if (case_fold)
- if (ISUPPER(c))
- setbit(tolower(c), ccl);
- else if (ISLOWER(c))
- setbit(toupper(c), ccl);
- ++c;
- }
- 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(c))
- setbit(tolower(c), ccl);
- else
- setbit(toupper(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(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 27c6b0e..0000000
--- a/gnu/usr.bin/grep/grep.1
+++ /dev/null
@@ -1,375 +0,0 @@
-.TH GREP 1 "1992 September 10" "GNU Project"
-.SH NAME
-grep, egrep, fgrep \- print lines matching a pattern
-.SH SYNOPOSIS
-.B grep
-[
-.BR \- [[ AB "] ]\c"
-.I "num"
-]
-[
-.BR \- [ CEFGVBchilnsvwx ]
-]
-[
-.B \-e
-]
-.I pattern
-|
-.BI \-f file
-] [
-.I 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 similiar (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" .
-.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 \-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.
-.PD
-.SH "REGULAR EXPRESSIONS"
-.PP
-A regular expression is a pattern that describes a set of strings.
-Regular expressions are constructed analagously 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 07872a1..0000000
--- a/gnu/usr.bin/grep/grep.c
+++ /dev/null
@@ -1,826 +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. */
-
-#include <errno.h>
-#include <stdio.h>
-
-#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
-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
-
-/* 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
-
-/* 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;
- }
- bufdesc = fd;
-#if defined(HAVE_WORKING_MMAP)
- if (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);
- }
- cc = read(bufdesc, buffer + bufsalloc, bufalloc - bufsalloc);
- }
-#else
- 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. */
-
-/* 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;
-}
-
-/* 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;
-
- reset(fd);
-
- totalcc = 0;
- lastout = 0;
- totalnl = 0;
- pending = 0;
-
- nlines = 0;
- residue = 0;
- save = 0;
-
- for (;;)
- {
- if (fillbuf(save) < 0)
- {
- error(filename, errno);
- return nlines;
- }
- 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);
- }
- 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 USAGE \
- "usage: %s [-[[AB] ]<num>] [-[CEFGVchilnqsvwx]] [-[ef]] <expr> [<files...>]\n"
-
-static void
-usage()
-{
- fprintf(stderr, USAGE, prog);
- 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, count_matches, no_filenames, list_files, suppress_errors;
- int opt, cc, desc, count, status;
- FILE *fp;
- extern char *optarg;
- extern int optind;
-
- 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;
-
- while ((opt = getopt(argc, argv, "0123456789A:B:CEFGVX:bce:f:hiLlnqsvwxy"))
- != EOF)
- 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;
- 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 (argc - optind > 1 && !no_filenames)
- out_file = 1;
-
- status = 1;
-
- if (optind < argc)
- while (optind < argc)
- {
- desc = strcmp(argv[optind], "-") ? open(argv[optind], O_RDONLY) : 0;
- if (desc < 0)
- {
- if (!suppress_errors)
- error(argv[optind], errno);
- }
- else
- {
- filename = desc == 0 ? "(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 != 0)
- close(desc);
- ++optind;
- }
- else
- {
- filename = "(standard input)";
- count = grep(0);
- 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 9b09071..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 8a18e45..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/regex.c b/gnu/usr.bin/grep/regex.c
deleted file mode 100644
index e8b5882..0000000
--- a/gnu/usr.bin/grep/regex.c
+++ /dev/null
@@ -1,4987 +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
-
-/* We need this for `regex.h', and perhaps for the Emacs include files. */
-#include <sys/types.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.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 (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 (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 void store_op1 (), store_op2 ();
-static void insert_op1 (), insert_op2 ();
-static boolean at_begline_loc_p (), at_endline_loc_p ();
-static boolean group_in_compile_stack ();
-static reg_errcode_t compile_range ();
-
-/* 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, (to) - (loc) - 3)
-
-/* Likewise, for a two-argument jump. */
-#define STORE_JUMP2(op, loc, to, arg) \
- store_op2 (op, loc, (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, (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, (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. */
-#define MAX_BUF_SIZE (1L << 16)
-
-
-/* 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. */
-typedef int 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"))
-
-/* `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;
- int 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':
- laststart = b;
- BUF_PUSH (wordchar);
- break;
-
-
- case 'W':
- laststart = b;
- BUF_PUSH (notwordchar);
- break;
-
-
- case '<':
- BUF_PUSH (wordbeg);
- break;
-
- case '>':
- BUF_PUSH (wordend);
- break;
-
- case 'b':
- BUF_PUSH (wordbound);
- break;
-
- case 'B':
- BUF_PUSH (notwordbound);
- break;
-
- case '`':
- BUF_PUSH (begbuf);
- break;
-
- case '\'':
- 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, 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;
- int 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. */
- if (range_start > range_end)
- return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-
- /* 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));
- }
-
- 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. */ \
- int 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);\
- } \
- \
- /* Push the info, starting with the registers. */ \
- DEBUG_PRINT1 ("\n"); \
- \
- 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); \
- } \
- \
- 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)
-
-/* 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;) \
- int 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); \
- \
- /* Restore register info. */ \
- high_reg = (unsigned) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
- \
- low_reg = (unsigned) 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;
- unsigned long size = bufp->used;
- const unsigned char *p = pattern;
- register unsigned char *pend = pattern + size;
-
- /* 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 = (regoff_t) 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 */
-
-/* Declarations and macros for re_match_2. */
-
-static int bcmp_translate ();
-static boolean alt_match_null_string_p (),
- common_op_match_null_string_p (),
- group_match_null_string_p ();
-
-/* 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. */
-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)
-
-
-/* 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 \
- { \
- unsigned 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. */
- unsigned num_regs = bufp->re_nsub + 1;
-
- /* The currently active registers. */
- unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- unsigned 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, **regend;
-
- /* 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, **old_regend;
-
- /* 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;
-
- /* 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, **best_regend;
-
- /* 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;
- register_info_type *reg_info_dummy;
-
-#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 ((int) old_regend[r] >= (int) regstart[r])
- regend[r] = old_regend[r];
- }
- }
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- PUSH_FAILURE_POINT (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);
- 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);
- 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'. */
- unsigned 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);
- 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);
- 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)
- unsigned char *s1, *s2;
- register int len;
- char *translate;
-{
- register unsigned char *p1 = s1, *p2 = 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;
- int 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
-
-/* 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;
- unsigned 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 /* not emacs */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/usr.bin/grep/regex.h b/gnu/usr.bin/grep/regex.h
deleted file mode 100644
index 408dd21..0000000
--- a/gnu/usr.bin/grep/regex.h
+++ /dev/null
@@ -1,490 +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__
-
-/* 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 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 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 (1)
-
-/* 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)
-
-/* 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_UNMATCHED_RIGHT_PAREN_ORD)
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
-
-#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
-#define RE_DUP_MAX ((1 << 15) - 1)
-
-
-/* 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. */
-
-#if __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, int 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));
-
-#endif /* not __REGEXP_LIBRARY_H__ */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/usr.bin/grep/search.c b/gnu/usr.bin/grep/search.c
deleted file mode 100644
index d2be489..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
-
-#ifdef isascii
-#define ISALNUM(C) (isascii(C) && isalnum(C))
-#define ISUPPER(C) (isascii(C) && isupper(C))
-#else
-#define ISALNUM(C) isalnum(C)
-#define ISUPPER(C) isupper(C)
-#endif
-
-#define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C))
-
-#include "grep.h"
-#include "dfa.h"
-#include "kwset.h"
-#include "regex.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/regress.sh b/gnu/usr.bin/grep/tests/regress.sh
deleted file mode 100644
index b947036..0000000
--- a/gnu/usr.bin/grep/tests/regress.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /bin/sh
-# Regression test for GNU e?grep.
-# Usage: regress.sh [dir-containing-egrep]
-
-builddir=${1-..}
-
-failures=0
-
-# The Khadafy test is brought to you by Scott Anderson . . .
-$builddir/egrep -f khadafy.regexp khadafy.lines > khadafy.out
-if cmp khadafy.lines khadafy.out
-then
- rm khadafy.out
-else
- echo Khadafy test failed -- output left on khadafy.out
- failures=1
-fi
-
-# . . . and the following by Henry Spencer.
-
-awk -F: -f scriptgen.awk spencer.tests > tmp.script
-
-if sh tmp.script $builddir
-then
- rm tmp.script
- exit $failures
-else
- rm tmp.script
- exit 1
-fi
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 913f198..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-
-1: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/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 0506da5..0000000
--- a/gnu/usr.bin/gzip/ChangeLog
+++ /dev/null
@@ -1,526 +0,0 @@
-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 368e218..0000000
--- a/gnu/usr.bin/gzip/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# @(#)Makefile 5.3 (Berkeley) 5/12/90
-
-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 -DHAVE_UNISTD_H=1 -DDIRENT=1
-MLINKS= gzip.1 gunzip.1 gzip.1 zcat.1 gzip.1 gzcat.1
-LINKS+= ${BINDIR}/gzip ${BINDIR}/gunzip
-LINKS+= ${BINDIR}/gzip ${BINDIR}/gzcat
-LINKS+= ${BINDIR}/gzip ${BINDIR}/zcat
-
-afterinstall:
- install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/zforce ${.CURDIR}/gzexe ${.CURDIR}/znew \
- ${.CURDIR}/zmore ${.CURDIR}/zdiff ${.CURDIR}/zgrep \
- ${DESTDIR}${BINDIR}
-
-match.o: ${.CURDIR}/match.S
- $(CPP) ${.CURDIR}/match.S >_match.s
- $(CC) -c _match.s
- mv _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 b47e9a5..0000000
--- a/gnu/usr.bin/gzip/NEWS
+++ /dev/null
@@ -1,196 +0,0 @@
-Current Version: 1.2.2.
-See the file ChangeLog for the details of all changes.
-
-Major changes from 1.2 to 1.2.1
-* 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 3a7b283..0000000
--- a/gnu/usr.bin/gzip/README
+++ /dev/null
@@ -1,159 +0,0 @@
-This is the file README for the gzip distribution, version 1.2.2.
-
-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.)
-
-WARNINGS about broken optimizers:
-
-- on the NeXT, "cc -finline-functions" is broken. gzip produces
- valid .gz files but they are much too large because the string
- matching code misses most matches. Use "cc -O" instead.
-
-- on the Mips R4000, gcc -O (version 2.3.1) generates bad code, use cc
- or just gcc -g instead.
-
-- gcc 2.3.3 and 2.4.3 on the SGI Indigo IRIX 4.0.5 also produce bad code.
- Use instead: make CC='cc -O2' or gcc without -O.
-
-- On Solaris 2.1 for x86, the January 1993 "OEM" compiler release
- generates bad code. This is fixed in the June 1993 "FCS" release.
-
-- on Sparc with SunOS 4.1.1 and the SC1.0 compiler, the optimizer
- works up to -O3 but -O4 does not work.
-
-- MSC 5.1 with -Ox and -DDYN_ALLOC generates bad code in inflate.c.
- The default is static allocation (no DYN_ALLOC) and -Ox works on inflate.c.
- But -Ox does not work on util.c, so you must use -Oait -Gs.
-
-- On dnix 5.3 2.2 cc version 2.37c is buggy. Version 2.38d works.
-
-- On an Alliant running Concentrix, cc (even without optimization) generates
- incorrect code. You have to use gcc.
-
-For all machines, Use "make check" to check that gzip was compiled correctly.
-
-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 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 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 needs go32.exe,
- available in omnigate.clarkson.edu:/pub/msdos/djgpp/djdev110.zip
-
-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.
-
-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 a5e79c1..0000000
--- a/gnu/usr.bin/gzip/THANKS
+++ /dev/null
@@ -1,226 +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:
-
-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
-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
-Jim Bernard jbernard@iola.mines.colorado.edu
-Karl Berry karl@cs.umb.edu
-James W. Birdsall jwbirdsa@picarefy.picarefy.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
-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
-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
-Kevin Cosgrove kevinc@tekig6.pen.tek.com
-Stephen J Cowley s.j.cowley@amtp.cam.ac.uk
-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
-John DeRoo deroo@grout.adv.shr.dec.com
-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
-John Eaton jwe@che.utexas.edu
-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
-Per Foreby perf@efd.lth.se
-Alexander Fraser alex@cs.umb.edu
-Noah Friedman friedman@gnu.ai.mit.edu
-Bob Friesenhahn bfriesen@iphase.com
-Andy Fyfe andy@scp.caltech.edu
-Geoff geoff@frs.faxon.com
-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
-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
-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
-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
-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
-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
-Tom Kloos tk@sequent.com
-Carsten Koch carsten.koch@icem.de
-Winfried Koenig win@in.rhein-main.de
-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
-Hugues Leroy hugues.leroy@irisa.fr
-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
-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
-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
-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
-Helmut Muelner hmuelner@fiicmds04.tu-graz.ac.at
-Urban D Mueller umueller@amiga.physik.unizh.ch
-Timothy Murphy tim@maths.tcd.ie
-Greg Naber greg@squally.halcyon.com
-Jay Nayegandhi jayng@bbiv02.enet.dec.com
-Karl L. Noell noell@informatik.fh-wiesbaden.dbp.de
-Arthur David Olson ado@elsie.nci.nih.gov
-Piet van Oostrum piet@cs.ruu.nl
-Rafael R. Pappalardo rafapa@obelix.cica.es
-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
-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
-Sunando Sen sens@fasecon.econ.nyu.edu
-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
-Sotiris Vassilopoulos vassilopoulos@virginia.edu
-Pedro A. M. Vazquez vazquez@iqm.unicamp.br
-Arjan de Vet devet@win.tue.nl
-Vadim V. Vlasov vvlasov@inucres.msk.su
-Eduard Vopicka eduard.vopicka@vse.cs
-Theo Vosse vosse@ruls41.leidenuniv.nl
-Marcel Waldvogel marcel@nice.usergroup.ethz.ch
-Stephen J. Walick steve@nshore.org
-Gray Watson gray@antaire.com
-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
-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 37b3c5c..0000000
--- a/gnu/usr.bin/gzip/TODO
+++ /dev/null
@@ -1,53 +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.
-
-- 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 610c7f0..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
-
-#ifndef lint
-static char rcsid[] = "$Id: bits.c,v 0.9 1993/06/11 10:16:58 jloup Exp $";
-#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 c6c7358..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 :-)
- */
-#ifndef lint
-static char rcsid[] = "$Id: crypt.c,v 0.6 1993/03/22 09:48:47 jloup Exp $";
-#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 eaad69a..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 */
-
-#ifndef lint
-static char rcsid[] = "$Id: deflate.c,v 0.14 1993/06/12 20:11:10 jloup Exp $";
-#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) */
-
-int 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. 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 9971e7b..0000000
--- a/gnu/usr.bin/gzip/getopt.c
+++ /dev/null
@@ -1,716 +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, 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 defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
-#include <alloca.h>
-#else
-#ifdef _AIX
- #pragma alloca
-#else
-char *alloca ();
-#endif
-#endif /* alloca.h */
-#endif /* not __GNUC__ */
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
-#ifndef _NO_PROTO
-# define _NO_PROTO
-#endif
-
-#include <stdio.h>
-
-#if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
-#include <string.h>
-#endif
-
-/* 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 !__STDC__
-#define const
-#endif
-
-/* 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. */
-
-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;
-
-#ifdef __GNU_LIBRARY__
-#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 *);
-#ifdef _CRAY
- char *temp[last_nonopt - first_nonopt];
-#else
- char **temp = (char **) __alloca (nonopts_size);
-#endif
-
- /* 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 = 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 == 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 ((char*)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 ((char*)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], 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);
-}
-
-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
-
-/* 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/gzip/getopt.h b/gnu/usr.bin/gzip/getopt.h
deleted file mode 100644
index bd3b8e4..0000000
--- a/gnu/usr.bin/gzip/getopt.h
+++ /dev/null
@@ -1,126 +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'. */
-
-enum _argtype
-{
- no_argument,
- required_argument,
- optional_argument
-};
-
-#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 3382bcf..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
- 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 | "/usr/local/bin"/gzip -cd > /tmp/gztmp$$; then
- /bin/chmod 700 /tmp/gztmp$$
- prog="`echo $0 | /bin/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
- "/usr/local/bin"/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" | "/usr/local/bin"/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/gzexe.in b/gnu/usr.bin/gzip/gzexe.in
deleted file mode 100644
index a28ec3d..0000000
--- a/gnu/usr.bin/gzip/gzexe.in
+++ /dev/null
@@ -1,151 +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
- 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 | "BINDIR"/gzip -cd > /tmp/gztmp$$; then
- /bin/chmod 700 /tmp/gztmp$$
- prog="`echo $0 | /bin/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
- "BINDIR"/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" | "BINDIR"/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/gzip.1 b/gnu/usr.bin/gzip/gzip.1
deleted file mode 100644
index 06ec9d9..0000000
--- a/gnu/usr.bin/gzip/gzip.1
+++ /dev/null
@@ -1,439 +0,0 @@
-.PU
-.TH GZIP 1
-.SH NAME
-gzip, gunzip, zcat \- compress or expand files
-.SH SYNOPSIS
-.ll +8
-.B gzip
-.RB [ " \-acdfhlLnrtvV19 " ]
-.RB [ \-S\ suffix ]
-[
-.I "name \&..."
-]
-.ll -8
-.br
-.B gunzip
-.RB [ " \-acfhlLnrtvV " ]
-.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 and Atari.)
-If no files are specified, 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 new file name is too long for its file system,
-.I gzip
-truncates it and keeps the original file name in the compressed file.
-.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
-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 ouput: 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 --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 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.
-.TP
-.B \-q --quiet
-Suppress all warnings.
-.TP
-.B \-r --recurse
-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. 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 (optimal 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:
-
- zcat old.gz | gzip > new.gz
-.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="-8 -v"; export GZIP
- for csh: setenv GZIP "-8 -v"
- for MSDOS: set GZIP=-8 -v
-
-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), zip(1), unzip(1), compress(1),
-pack(1), compact(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 [-cdfhlLnrtvV19] [-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 /dev/rmt/datn
- for csh: (setenv GZIP "-q"; tar xfz /dev/rmt/datn)
-
-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.
-.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.
diff --git a/gnu/usr.bin/gzip/gzip.c b/gnu/usr.bin/gzip/gzip.c
deleted file mode 100644
index 37100cd..0000000
--- a/gnu/usr.bin/gzip/gzip.c
+++ /dev/null
@@ -1,1679 +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.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: gzip.c,v 0.22 1993/06/16 16:53:43 jloup 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 = 0; /* don't save or restore the original file name */
-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 the original name */
- {"quiet", 0, 0, 'q'}, /* quiet mode */
- {"silent", 0, 0, 'q'}, /* quiet mode */
- {"recurse", 0, 0, 'r'}, /* recurse through directories */
- {"suffix", 1, 0, 'S'}, /* use given suffix instead of .gz */
- {"test", 0, 0, 't'}, /* test compressed file integrity */
- {"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 reset_times OF((char *name, struct stat *statb));
-local void copy_stat OF((struct stat *ifstat));
-local void treat_dir OF((char *dir));
-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 */
-
-#define strequ(s1, s2) (strcmp((s1),(s2)) == 0)
-
-/* ======================================================================== */
-local void usage()
-{
- fprintf(stderr, "usage: %s [-%scdfhlLn%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 .gz file contents",
- " -L --license display software license",
- " -n --no-name do not save or restore the original name",
- " -q --quiet suppress all warnings",
-#ifndef NO_DIR
- " -r --recurse recurse through directories",
-#endif
-#ifdef MAX_EXT_CHARS
- " -S .suf --suffix .suf use suffix .suf instead of .z",
-#else
- " -S .suf --suffix .suf use suffix .suf instead of .gz",
-#endif
- " -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 = 0; /* 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) {
- signal (SIGINT, (sig_type)abort_gzip);
- }
-#ifdef SIGTERM
- signal(SIGTERM, (sig_type)abort_gzip);
-#endif
-#ifdef SIGHUP
- 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:cdfhlLnqrS: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 'n':
- no_name = 1; 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 */
-
- 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) {
- 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 && 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. */
-#ifdef NO_STDIN_FSTAT
- time_stamp = 0; /* time unknown */
-#else
- if (fstat(fileno(stdin), &istat) != 0) {
- error("fstat(stdin)");
- }
- /* If you do not wish to save the time stamp when input comes from a pipe,
- * compile with -DNO_PIPE_TIMESTAMP.
- */
-#ifdef NO_PIPE_TIMESTAMP
- if (!S_ISREG(istat.st_mode))
- time_stamp = 0;
- else
-#endif
- time_stamp = istat.st_mtime;
-#endif
- 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;
-{
- /* 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 */
- reset_times (iname, &st);
- } 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 = istat.st_mtime;
-
- /* Generate output file name */
- if (to_stdout && !list) {
- 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 (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
-
- 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) {
- if (list) 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.
- * 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;
- char magic[2]; /* magic header */
-
- /* 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();
- }
- time_stamp = istat.st_mtime; /* may be modified later for some methods */
- 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;
- }
- time_stamp = (ulg)get_byte();
- time_stamp |= ((ulg)get_byte()) << 8;
- time_stamp |= ((ulg)get_byte()) << 16;
- time_stamp |= ((ulg)get_byte()) << 24;
-
- (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 */
- while ((c=get_byte()) != 0) c++;
- } 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);
- base++; /* 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) { /* 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 = ~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, buf, sizeof(buf)) != sizeof(buf)) {
- read_error();
- }
- crc = LG(buf);
- bytes_out = LG(buf+4);
- }
- }
-#endif /* RECORD_IO */
- date = ctime(&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.
- *
- * IN assertion: This function is only called for the compressed file;
- * 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;
-
- p = get_suffix(name);
- if (p == NULL) error("can't recover suffix\n");
- *p = '\0';
- len = strlen(name);
- 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 */
-
- if (stat(ofname, &ostat) != 0) return 0;
-
- /* Check for name truncation on existing file: */
- 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)) {
- 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;
- }
- }
- (void) chmod(ofname, 0777);
- if (unlink(ofname)) {
- fprintf(stderr, "%s: ", progname);
- perror(ofname);
- exit_code = ERROR;
- return ERROR;
- }
- return OK;
-}
-
-
-/* ========================================================================
- * Set the access and modification times from the given stat buffer.
- */
-local void reset_times (name, statb)
- char *name;
- struct stat *statb;
-{
-#ifndef NO_UTIME
- 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);
- }
-#else
- name = name; statb = statb; /* avoid warnings */
-#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) {
- 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: */
- (void) chmod(ifname, 0777);
- 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;
-{
- 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 88b0710..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 dccd597..0000000
--- a/gnu/usr.bin/gzip/inflate.c
+++ /dev/null
@@ -1,953 +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.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup 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 */
- } 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 */
- }
-
-
- /* 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 a360ca9..0000000
--- a/gnu/usr.bin/gzip/lzw.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* lzw.c -- compress files in LZW format.
- * This is a dummy version avoiding patent problems.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: lzw.c,v 0.9 1993/06/10 13:27:31 jloup Exp $";
-#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");
- 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 4a3d681..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 0.14 1993/06/11 18:33:24 jloup Exp $ */
-
-/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix
- * external symbols with an underline character '_'.
- */
-#ifdef 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 4cb03a3..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.2"
-#define PATCHLEVEL 0
-#define REVDATE "17 Jun 93"
-
-/* This version does not support compression into old compress format: */
-#ifdef LZW
-# undef LZW
-#endif
-
-/* $Id: revision.h,v 0.23 1993/06/16 15:03:51 jloup Exp $ */
diff --git a/gnu/usr.bin/gzip/tailor.h b/gnu/usr.bin/gzip/tailor.h
deleted file mode 100644
index 960ff28..0000000
--- a/gnu/usr.bin/gzip/tailor.h
+++ /dev/null
@@ -1,300 +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: tailor.h,v 0.18 1993/06/14 19:32:20 jloup Exp $ */
-
-#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_UTIME
-# define NO_OFF_T
-# 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"
-# endif
-# define NO_CHOWN
-# define PROTO
-# define STDC_HEADERS
-# define casemap(c) tolow(c)
-# 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 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 casemap(c) tolow(c) /* Force file names to lower case */
-# 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 NO_SYMLINK
-# define NO_MULTIPLE_DOTS
-# define MAX_EXT_CHARS 3
-# define Z_SUFFIX "z"
-# define NO_CHOWN
-# 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
-
-#ifdef WIN32
-# define OS_CODE 0x0b
-#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 673dfde..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"
-
-#ifndef lint
-static char rcsid[] = "$Id: trees.c,v 0.12 1993/06/10 13:27:54 jloup 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("-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 2c03d1f..0000000
--- a/gnu/usr.bin/gzip/unlzh.c
+++ /dev/null
@@ -1,385 +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.
- */
-
-#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));
-
-/* io.c */
-local void fillbuf OF((int n));
-local unsigned getbits OF((int n));
-local void init_getbits OF((void));
-
-#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 < 4096
- error cannot overlay c_table and d_buf
-#endif
-
-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 < 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] != (ush)((unsigned) 1 << 16))
- error("Bad table\n");
-
- jutbits = 16 - tablebits;
- for (i = 1; i <= 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 != (ush)((unsigned) 1 << 16)) {
- k = 1 << tablebits;
- while (i != k) table[i++] = 0;
- }
-
- avail = nchar;
- mask = (unsigned) 1 << (15 - tablebits);
- for (ch = 0; ch < nchar; ch++) {
- if ((len = bitlen[ch]) == 0) continue;
- nextcode = start[len] + weight[len];
- if (len <= 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 61c45fc..0000000
--- a/gnu/usr.bin/gzip/unlzw.c
+++ /dev/null
@@ -1,374 +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.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: unlzw.c,v 0.15 1993/06/10 13:28:35 jloup Exp $";
-#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);
-
- if (oldcode == -1) {
- 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("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 789cbc0..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.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: unpack.c,v 1.4 1993/06/11 19:25:36 jloup Exp $";
-#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 < 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 != 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 48cdebe..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.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: unzip.c,v 0.13 1993/06/10 13:29:00 jloup Exp $";
-#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 != 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 52f1bdd..0000000
--- a/gnu/usr.bin/gzip/util.c
+++ /dev/null
@@ -1,462 +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.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: util.c,v 0.15 1993/06/15 09:04:13 jloup 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); env = NULL;
- 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 warn(a, b)
- char *a, *b; /* message strings juxtaposed in output */
-{
- WARN((stderr, "%s: %s: warning: %s%s\n", progname, ifname, a, b));
-}
-
-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/zcmp b/gnu/usr.bin/gzip/zcmp
deleted file mode 100644
index c21e7ef..0000000
--- a/gnu/usr.bin/gzip/zcmp
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-
-# 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.
-
-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 -cd "$2" > /tmp/"$F".$$
- gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$
- STAT="$?"
- /bin/rm -f /tmp/"$F".$$;;
-
- *) gzip -cd "$1" | $comp $OPTIONS - "$2"
- STAT="$?";;
- esac;;
- *) case "$2" in
- *[-.]gz | *[-.][zZ] | *.t[ga]z)
- gzip -cd "$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 b/gnu/usr.bin/gzip/zdiff
deleted file mode 100644
index 3de5cb4..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 -cd "$2" > /tmp/"$F".$$
- gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$
- STAT="$?"
- /bin/rm -f /tmp/"$F".$$;;
-
- *) gzip -cd "$1" | $comp $OPTIONS - "$2"
- STAT="$?";;
- esac;;
- *) case "$2" in
- *[-.]gz | *[-.][zZ] | *.t[ga]z)
- gzip -cd "$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/zip.c b/gnu/usr.bin/gzip/zip.c
deleted file mode 100644
index 3928262..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.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: zip.c,v 0.17 1993/06/10 13:29:25 jloup Exp $";
-#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 6a089a2..0000000
--- a/gnu/usr.bin/gzip/zmore
+++ /dev/null
@@ -1,47 +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
- gzip -cdfq | eval ${PAGER-more}
-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 01be32c..0000000
--- a/gnu/usr.bin/gzip/znew
+++ /dev/null
@@ -1,153 +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
-
-A=
-fileno=0
-
-for arg
-do
- case "$arg" in
- -*) opt="$opt $arg";;
- *) fileno=`expr $fileno + 1`
- eval A$fileno=\$arg
- A="$A \"\$A$fileno\""
- ;;
- esac
-done
-
-if test $fileno -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
-
-eval set "$A" # the files are now in $1, $2, ...
-
-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 810c51d..0000000
--- a/gnu/usr.bin/gzip/znew.1
+++ /dev/null
@@ -1,37 +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.
-.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 6816916..0000000
--- a/gnu/usr.bin/ld/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# @(#)Makefile 6.2 (Berkeley) 4/30/91
-
-PROG= ld
-SRCS= ld.c cplus-dem.c
-NOMAN= noman
-LINKS= ${BINDIR}/ld ${BINDIR}/../libexec/ld++
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/ld/cplus-dem.c b/gnu/usr.bin/ld/cplus-dem.c
deleted file mode 100644
index c24ca7a..0000000
--- a/gnu/usr.bin/ld/cplus-dem.c
+++ /dev/null
@@ -1,974 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)cplus-dem.c 5.4 (Berkeley) 4/30/91";
-#endif /* not lint */
-
-/* Demangler for GNU C++
- Copyright (C) 1989 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 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. */
-
-/* This is for g++ 1.36.1 (November 6 version). It will probably
- require changes for any other version.
-
- Modified for g++ 1.36.2 (November 18 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 <ctype.h>
-
-#ifdef USG
-#include <memory.h>
-#include <string.h>
-#else
-#include <strings.h>
-#define memcpy(s1, s2, n) bcopy ((s2), (s1), (n))
-#define memcmp(s1, s2, n) bcmp ((s2), (s1), (n))
-#define strchr index
-#define strrchr rindex
-#endif
-
-#ifndef __STDC__
-#define const
-#endif
-
-#ifdef __STDC__
-extern char *cplus_demangle (const char *type);
-#else
-extern char *cplus_demangle ();
-#endif
-
-#ifdef __STDC__
-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", "*",
- "convert", "+", /* unary + */
- "negate", "-", /* unary - */
- "trunc_mod", "%",
- "trunc_div", "/",
- "truth_andif", "&&",
- "truth_orif", "||",
- "truth_not", "!",
- "postincrement", "++",
- "postdecrement", "--",
- "bit_ior", "|",
- "bit_xor", "^",
- "bit_and", "&",
- "bit_not", "~",
- "call", "()",
- "cond", "?:",
- "alshift", "<<",
- "arshift", ">>",
- "component", "->",
- "indirect", "*",
- "method_call", "->()",
- "addr", "&", /* unary & */
- "array", "[]",
- "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;
-
-#ifdef __STDC__
-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);
-static void remember_type (const char *type, int len);
-#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 ();
-static void remember_type ();
-#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;
-#ifndef LONGERNAMES
- const char *premangle;
-#endif
-
- 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, '$')) != NULL)
- {
- 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;
- }
- /* virtual table */
- if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$')
- {
- int n = strlen (type + 4) + 14 + 1;
- char *tem = (char *) xmalloc (n);
- strcpy (tem, type + 4);
- strcat (tem, " virtual table");
- 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;
-
-#ifndef LONGERNAMES
- premangle = p;
-#endif
- 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;
-#ifndef LONGERNAMES
- remember_type (premangle, p - premangle);
-#endif
- 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 = 0;
- 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 'x':
- *type += 1;
- if (non_empty)
- string_append (result, " ");
- string_append (result, "long long");
- 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;
-{
- const char *start = *type;
-
- if (!do_type (type, result))
- return 0;
- remember_type (start, *type - start);
- return 1;
-}
-
-static void
-remember_type (start, len)
- const char *start;
- int len;
-{
- char *tem;
-
- 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);
- }
- }
- tem = (char *) xmalloc (len + 1);
- memcpy (tem, start, len);
- tem[len] = '\0';
- typevec[ntypes++] = tem;
-}
-
-/* `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;
-}
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c
deleted file mode 100644
index 3c1fa70..0000000
--- a/gnu/usr.bin/ld/ld.c
+++ /dev/null
@@ -1,4716 +0,0 @@
-/*-
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
- */
-
-#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. */
-
-/* Define how to initialize system-dependent header fields. */
-
-#include <ar.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <fcntl.h>
-#include <a.out.h>
-#include <stab.h>
-#include <string.h>
-
-/* symseg.h defines the obsolete GNU debugging format; we should nuke it. */
-#define CORE_ADDR unsigned long /* For symseg.h */
-#include "symseg.h"
-
-#define N_SET_MAGIC(exec, val) ((exec).a_magic = val)
-
-/* If compiled with GNU C, use the built-in alloca */
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#endif
-
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
-/* Macro to control the number of undefined references printed */
-#define MAX_UREFS_PRINTED 10
-
-/* Size of a page; obtained from the operating system. */
-
-int page_size;
-
-/* Name this program was invoked by. */
-
-char *progname;
-
-/* System dependencies */
-
-/* Define this to specify the default executable format. */
-
-#ifndef DEFAULT_MAGIC
-#define DEFAULT_MAGIC ZMAGIC
-#endif
-
-#ifdef hp300
-#define INITIALIZE_HEADER outheader.a_mid = MID_HP300
-#endif
-
-/* create screwball format for 386BSD to save space on floppies -wfj */
-int screwballmode;
-
-/*
- * 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.
- *
- *
- */
-
-/* The following #if has been modifed for cross compilation */
-/* It originally read: #if defined(sun) && defined(sparc) */
-/* Marc Ullman, Stanford University Nov. 1 1989 */
-#if defined(sun) && (TARGET == SUN4)
-/* Sparc (Sun 4) macros */
-#undef relocation_info
-#define relocation_info reloc_info_sparc
-#define RELOC_ADDRESS(r) ((r)->r_address)
-#define RELOC_EXTERN_P(r) ((r)->r_extern)
-#define RELOC_TYPE(r) ((r)->r_index)
-#define RELOC_SYMBOL(r) ((r)->r_index)
-#define RELOC_MEMORY_SUB_P(r) 0
-#define RELOC_MEMORY_ADD_P(r) 0
-#define RELOC_ADD_EXTRA(r) ((r)->r_addend)
-#define RELOC_PCREL_P(r) \
- ((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22)
-#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])
-
-/* 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 the last few may be incorrect; I have no information */
-static int reloc_target_rightshift[] = {
- 0, 0, 0, 0, 0, 0, 2, 2, 10, 0, 0, 0, 0, 0, 0,
-};
-static int reloc_target_size[] = {
- 0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static int reloc_target_bitsize[] = {
- 8, 16, 32, 8, 16, 32, 30, 22, 22, 22, 13, 10, 32, 32, 16,
-};
-
-#define MAX_ALIGNMENT (sizeof (double))
-#endif
-
-/* 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
-#define RELOC_TARGET_SIZE(r) ((r)->r_length)
-#define RELOC_TARGET_BITPOS(r) 0
-#define RELOC_TARGET_BITSIZE(r) 32
-#endif
-
-#ifndef MAX_ALIGNMENT
-#define MAX_ALIGNMENT (sizeof (int))
-#endif
-
-#ifdef nounderscore
-#define LPREFIX '.'
-#else
-#define LPREFIX 'L'
-#endif
-
-#ifndef TEXT_START
-#define TEXT_START(x) N_TXTADDR(x)
-#endif
-
-/* 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. */
-
-/* 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 */
-
-#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__ */
-
-/* Symbol table */
-
-/* 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. */
-
-typedef
- struct glosym
- {
- /* Pointer to next symbol in this symbol's hash bucket. */
- struct glosym *link;
- /* Name of this symbol. */
- char *name;
- /* Value of this symbol as a global symbol. */
- long value;
- /* Chain of external 'nlist's in files for this symbol, both defs
- and refs. */
- struct nlist *refs;
- /* Any warning message that might be associated with this symbol
- from an N_WARNING symbol encountered. */
- char *warning;
- /* Nonzero means definitions of this symbol as common have been seen,
- and the value here is the largest size specified by any of them. */
- int max_common_size;
- /* For relocatable_output, records the index of this global sym in the
- symbol table to be written, with the first global sym given index 0.*/
- int def_count;
- /* Nonzero means a definition of this global symbol is known to exist.
- Library members should not be loaded on its account. */
- char defined;
- /* Nonzero means a reference to this global symbol has been seen
- in a file that is surely being loaded.
- A value higher than 1 is the n_type code for the symbol's
- definition. */
- char referenced;
- /* A count of the number of undefined references printed for a
- specific symbol. If a symbol is unresolved at the end of
- digest_symbols (and the loading run is supposed to produce
- relocatable output) do_file_warnings keeps track of how many
- unresolved reference error messages have been printed for
- each symbol here. When the number hits MAX_UREFS_PRINTED,
- messages stop. */
- unsigned char undef_refs;
- /* 1 means that this symbol has multiple definitions. 2 means
- that it has multiple definitions, and some of them are set
- elements, one of which has been printed out already. */
- unsigned char multiply_defined;
- /* Nonzero means print a message at all refs or defs of this symbol */
- char trace;
- }
- symbol;
-
-/* Demangler for C++. */
-extern char *cplus_demangle ();
-
-/* Demangler function to use. */
-char *(*demangler)() = NULL;
-
-/* Number of buckets in symbol hash table */
-#define TABSIZE 1009
-
-/* The symbol hash table: a vector of TABSIZE pointers to struct glosym. */
-symbol *symtab[TABSIZE];
-
-/* Number of symbols in symbol hash table. */
-int num_hash_tab_syms = 0;
-
-/* Count the number of nlist entries that are for local symbols.
- This count and the three following counts
- are incremented as as symbols are entered in the symbol table. */
-int local_sym_count;
-
-/* Count number of nlist entries that are for local symbols
- whose names don't start with L. */
-int non_L_local_sym_count;
-
-/* Count the number of nlist entries for debugger info. */
-int debugger_sym_count;
-
-/* Count the number of global symbols referenced and not defined. */
-int undefined_global_sym_count;
-
-/* Count the number of global symbols multiply defined. */
-int multiple_def_count;
-
-/* Count the number of defined global symbols.
- Each symbol is counted only once
- regardless of how many different nlist entries refer to it,
- since the output file will need only one nlist entry for it.
- This count is computed by `digest_symbols';
- it is undefined while symbols are being loaded. */
-int defined_global_sym_count;
-
-/* Count the number of symbols defined through common declarations.
- This count is kept in symdef_library, linear_library, and
- enter_global_ref. It is incremented when the defined flag is set
- in a symbol because of a common definition, and decremented when
- the symbol is defined "for real" (ie. by something besides a common
- definition). */
-int common_defined_global_count;
-
-/* Count the number of set element type symbols and the number of
- separate vectors which these symbols will fit into. See the
- GNU a.out.h for more info.
- This count is computed by 'enter_file_symbols' */
-int set_symbol_count;
-int set_vector_count;
-
-/* 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 string_list_element *set_element_prefixes;
-
-/* Count the number of definitions done indirectly (ie. done relative
- to the value of some other symbol. */
-int global_indirect_count;
-
-/* Count the number of warning symbols encountered. */
-int warning_count;
-
-/* Total number of symbols to be written in the output file.
- Computed by digest_symbols from the variables above. */
-int nsyms;
-
-
-/* Nonzero means ptr to symbol entry for symbol to use as start addr.
- -e sets this. */
-symbol *entry_symbol;
-
-symbol *edata_symbol; /* the symbol _edata */
-symbol *etext_symbol; /* the symbol _etext */
-symbol *end_symbol; /* the symbol _end */
-
-/* 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. */
-
-struct file_entry {
- /* Name of this file. */
- char *filename;
- /* 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;
-
- /* Describe the layout of the contents of the file */
-
- /* The file's a.out header. */
- struct exec header;
- /* Offset in file of GDB symbol segment, or 0 if there is none. */
- int symseg_offset;
-
- /* Describe data from the file loaded into core */
-
- /* Symbol table of the file. */
- struct nlist *symbols;
- /* Size in bytes of string table. */
- int string_size;
- /* Pointer to the string table.
- The string table is not kept in core all the time,
- but when it is in core, its address is here. */
- char *strings;
-
- /* Next two used only if `relocatable_output' or if needed for */
- /* output of undefined reference line numbers. */
-
- /* Text reloc info saved by `write_text' for `coptxtrel'. */
- struct relocation_info *textrel;
- /* Data reloc info saved by `write_data' for `copdatrel'. */
- struct relocation_info *datarel;
-
- /* Relation of this file's segments to the output file */
-
- /* Start of this file's text seg in the output file core image. */
- int text_start_address;
- /* Start of this file's data seg in the output file core image. */
- int data_start_address;
- /* Start of this file's bss seg in the output file core image. */
- int bss_start_address;
- /* Offset in bytes in the output file symbol table
- of the first local symbol for this file. Set by `write_file_symbols'. */
- int local_syms_offset;
-
- /* For library members only */
-
- /* For a library, points to chain of entries for the library members. */
- struct file_entry *subfiles;
- /* For a library member, offset of the member within the archive.
- Zero for files that are not library members. */
- int starting_offset;
- /* Size of contents of this file, if library member. */
- int total_size;
- /* For library member, points to the library's own entry. */
- struct file_entry *superfile;
- /* For library member, points to next entry for next member. */
- struct file_entry *chain;
-
- /* 1 if file is a library. */
- char library_flag;
-
- /* 1 if file's header has been read into this structure. */
- char header_read_flag;
-
- /* 1 means search a set of directories for this file. */
- char search_dirs_flag;
-
- /* 1 means this is base file of incremental load.
- Do not load this file's text or data.
- Also default text_start to after this file's bss. */
- char just_syms_flag;
-};
-
-/* 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;
-
-/* Length of that vector. */
-int number_of_files;
-
-/* 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;
-
-/* Descriptor for writing that file with `mywrite'. */
-
-int outdesc;
-
-/* Header for that file (filled in by `write_header'). */
-
-struct exec outheader;
-
-#ifdef COFF_ENCAPSULATE
-struct coffheader coffheader;
-int need_coff_header;
-#endif
-
-/* The following are computed by `digest_symbols'. */
-
-int text_size; /* total size of text of all input files. */
-int data_size; /* total size of data of all input files. */
-int bss_size; /* total size of bss of all input files. */
-int text_reloc_size; /* total size of text relocation of all input files. */
-int data_reloc_size; /* total size of data relocation of all input */
- /* files. */
-
-/* Specifications of start and length of the area reserved at the end
- of the text segment for the set vectors. Computed in 'digest_symbols' */
-int set_sect_start;
-int set_sect_size;
-
-/* Pointer for in core storage for the above vectors, before they are
- written. */
-unsigned long *set_vectors;
-
-/* Amount of cleared space to leave between the text and data segments. */
-
-int text_pad;
-
-/* Amount of bss segment to include as part of the data segment. */
-
-int data_pad;
-
-/* Format of __.SYMDEF:
- First, a longword containing the size of the 'symdef' data that follows.
- Second, zero or more 'symdef' structures.
- Third, a longword containing the length of symbol name strings.
- Fourth, zero or more symbol name strings (each followed by a null). */
-
-struct symdef {
- int symbol_name_string_index;
- int library_member_offset;
-};
-
-/* Record most of the command options. */
-
-/* Address we assume the text section will be loaded at.
- We relocate symbols and text and data for this, but we do not
- write any padding in the output file for it. */
-int text_start;
-
-/* Offset of default entry-pc within the text section. */
-int entry_offset;
-
-/* Address we decide the data section will be loaded at. */
-int data_start;
-
-/* `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;
-
-/* Magic number to use for the output file, set by switch. */
-int magic;
-
-/* Nonzero means print names of input files as processed. */
-int trace_files;
-
-/* 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;
-
-/* 1 => write load map. */
-int write_map;
-
-/* 1 => write relocation into output file so can re-input it later. */
-int relocatable_output;
-
-/* 1 => assign space to common symbols even if `relocatable_output'. */
-int force_common_definition;
-
-/* Standard directories to search for files specified by -l. */
-char *standard_search_dirs[] =
-#ifdef STANDARD_SEARCH_DIRS
- {STANDARD_SEARCH_DIRS};
-#else
-#ifdef NON_NATIVE
- {"/usr/local/lib/gnu"};
-#else
- {"/lib", "/usr/lib", "/usr/local/lib"};
-#endif
-#endif
-
-/* Actual vector of directories to search;
- this contains those specified with -L plus the standard ones. */
-char **search_dirs;
-
-/* Length of the vector `search_dirs'. */
-int n_search_dirs;
-
-/* Non zero means to create the output executable. */
-/* Cleared by nonfatal errors. */
-int make_executable;
-
-/* Force the executable to be output, even if there are non-fatal
- errors */
-int force_executable;
-
-/* 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. */
-struct glosym **cmdline_references;
-int cl_refs_allocated;
-
-void bcopy (), bzero ();
-int malloc (), realloc ();
-#ifndef alloca
-int alloca ();
-#endif
-int free ();
-
-int xmalloc ();
-int xrealloc ();
-void fatal ();
-void fatal_with_file ();
-void perror_name ();
-void perror_file ();
-void error ();
-
-void digest_symbols ();
-void print_symbols ();
-void load_symbols ();
-void decode_command ();
-void list_undefined_symbols ();
-void list_unresolved_references ();
-void write_output ();
-void write_header ();
-void write_text ();
-void read_file_relocation ();
-void write_data ();
-void write_rel ();
-void write_syms ();
-void write_symsegs ();
-void mywrite ();
-void symtab_init ();
-void padfile ();
-char *concat ();
-char *get_file_name ();
-symbol *getsym (), *getsym_soft ();
-
-int
-main (argc, argv)
- char **argv;
- int argc;
-{
-/* 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. */
- getrlimit (RLIMIT_STACK, &rlim);
- rlim.rlim_cur = rlim.rlim_max;
- setrlimit (RLIMIT_STACK, &rlim);
- }
-#endif /* RLIMIT_STACK */
-
- page_size = getpagesize ();
- progname = argv[0];
-
- /* 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;
-
- /* 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;
- set_element_prefixes = 0;
-
- /* 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;
- set_symbol_count = 0;
- set_vector_count = 0;
- global_indirect_count = 0;
- warning_count = 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
- = (struct glosym **) xmalloc (cl_refs_allocated
- * sizeof(struct glosym *));
- *cmdline_references = 0;
-
- /* Completely decode ARGV. */
-
- decode_command (argc, argv);
-
- /* Create the symbols `etext', `edata' and `end'. */
-
- if (!relocatable_output)
- symtab_init ();
-
- /* 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. */
-
- N_SET_MAGIC (outheader, magic);
-#ifdef INITIALIZE_HEADER
- INITIALIZE_HEADER;
-#endif
-
- text_size = sizeof (struct exec);
-#ifdef COFF_ENCAPSULATE
- if (relocatable_output == 0 && file_table[0].just_syms_flag == 0)
- {
- need_coff_header = 1;
- /* set this flag now, since it will change the values of N_TXTOFF, etc */
- N_SET_FLAGS (outheader, N_FLAGS_COFF_ENCAPSULATE);
- text_size += sizeof (struct coffheader);
- }
-#endif
-
- text_size -= N_TXTOFF (outheader);
-
- if (text_size < 0)
- text_size = 0;
- entry_offset = text_size;
-
- if (!T_flag_specified && !relocatable_output && !screwballmode)
- 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 */
-
- 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);
-}
-
-void decode_option ();
-
-/* 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. */
-
-int
-classify_arg (arg)
- register char *arg;
-{
- if (*arg != '-') return 0;
- switch (arg[1])
- {
- case 'A':
- case 'D':
- case 'e':
- case 'L':
- case 'l':
- case 'o':
- case 'u':
- case 'V':
- case 'y':
- if (arg[2])
- return 1;
- return 2;
-
- case 'B':
- if (! strcmp (&arg[2], "static"))
- 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. */
-
-void
-decode_command (argc, argv)
- char **argv;
- int argc;
-{
- register int i;
- register struct file_entry *p;
- char *cp;
-
- number_of_files = 0;
- output_filename = "a.out";
-
- n_search_dirs = 0;
- search_dirs = (char **) xmalloc (sizeof (char *));
-
- /* 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)
- fatal ("no argument following %s\n", 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)
- fatal ("no input files", 0);
-
- 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++)
- {
- register int code = classify_arg (argv[i]);
-
- if (code)
- {
- char *string;
- if (code == 2)
- string = argv[i+1];
- else
- string = &argv[i][2];
-
- if (argv[i][1] == 'A')
- {
- if (p != file_table)
- fatal ("-A specified before an input file other than the first");
-
- p->filename = string;
- p->local_sym_name = string;
- p->just_syms_flag = 1;
- p++;
- }
- if (argv[i][1] == 'l')
- {
- if (cp = rindex(string, '/'))
- {
- *cp++ = '\0';
- cp = concat (string, "/lib", cp);
- p->filename = concat (cp, ".a", "");
- }
- else
- p->filename = concat ("lib", string, ".a");
-
- p->local_sym_name = concat ("-l", string, "");
- p->search_dirs_flag = 1;
- p++;
- }
- i += code - 1;
- }
- else
- {
- p->filename = argv[i];
- p->local_sym_name = argv[i];
- p++;
- }
- }
-
- /* Now check some option settings for consistency. */
-
-#ifdef NMAGIC
- if ((magic == ZMAGIC || magic == NMAGIC)
-#else
- if ((magic == ZMAGIC)
-#endif
- && (text_start - text_start_alignment) & (page_size - 1))
- fatal ("-T argument not multiple of page size, with sharable output", 0);
-
- /* Append the standard search directories to the user-specified ones. */
- {
- int n = sizeof standard_search_dirs / sizeof standard_search_dirs[0];
- n_search_dirs += n;
- search_dirs
- = (char **) xrealloc (search_dirs, n_search_dirs * sizeof (char *));
- bcopy (standard_search_dirs, &search_dirs[n_search_dirs - n],
- n * sizeof (char *));
- }
-}
-
-
-void
-add_cmdline_ref (sp)
- struct glosym *sp;
-{
- struct glosym **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 = (struct glosym **)
- xrealloc (cmdline_references,
- cl_refs_allocated * sizeof (struct glosym *));
- ptr = cmdline_references + diff;
- }
-
- *ptr++ = sp;
- *ptr = (struct glosym *) 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;
-}
-
-int parse ();
-
-/* 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. */
-
-void
-decode_option (swt, arg)
- register char *swt, *arg;
-{
- /* We get Bstatic from gcc on suns. */
- if (! strcmp (swt + 1, "Bstatic"))
- return;
- if (! strcmp (swt + 1, "Ttext"))
- {
- text_start = parse (arg, "%x", "invalid argument to -Ttext");
- T_flag_specified = 1;
- return;
- }
- if (! strcmp (swt + 1, "Tdata"))
- {
- 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, "screwballmode"))
- {
- screwballmode = 1;
- magic = OMAGIC;
- text_start = sizeof(struct exec);
- 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':
- force_common_definition = 1;
- return;
-
- case 'e':
- entry_symbol = getsym (arg);
- if (!entry_symbol->defined && !entry_symbol->referenced)
- undefined_global_sym_count++;
- entry_symbol->referenced = 1;
- add_cmdline_ref (entry_symbol);
- return;
-
- case 'l':
- /* If linking with libg++, use the C++ demangler. */
- if (arg != NULL && strcmp (arg, "g++") == 0)
- demangler = cplus_demangle;
- return;
- magic = OMAGIC;
-
- case 'L':
- n_search_dirs++;
- search_dirs
- = (char **) xrealloc (search_dirs, n_search_dirs * sizeof (char *));
- search_dirs[n_search_dirs - 1] = arg;
- return;
-
- case 'M':
- write_map = 1;
- return;
-
- case 'N':
- magic = OMAGIC;
-#ifdef notnow
-text_start = sizeof(struct exec); /* XXX */
-screwballmode=1;
-#endif
- return;
-
-#ifdef NMAGIC
- case 'n':
- magic = NMAGIC;
- return;
-#endif
-
- case 'o':
- output_filename = arg;
- return;
-
- case 'r':
- relocatable_output = 1;
- magic = OMAGIC;
- text_start = 0;
- 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->referenced)
- undefined_global_sym_count++;
- sp->referenced = 1;
- add_cmdline_ref (sp);
- }
- return;
-
- case 'V':
- {
- struct string_list_element *new
- = (struct string_list_element *)
- xmalloc (sizeof (struct string_list_element));
-
- new->str = arg;
- new->next = set_element_prefixes;
- set_element_prefixes = new;
- return;
- }
-
- case 'X':
- discard_locals = DISCARD_L;
- return;
-
- case 'x':
- discard_locals = DISCARD_ALL;
- return;
-
- case 'y':
- {
- register symbol *sp = getsym (&swt[2]);
- sp->trace = 1;
- }
- return;
-
- case 'z':
- magic = ZMAGIC;
- return;
-
- default:
- fatal ("invalid command option `%s'", swt);
- }
-}
-
-/** Convenient functions for operating on one or all files being */
- /** loaded. */
-void print_file_name ();
-
-/* 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 int arg;
-{
- register int i;
-
- for (i = 0; i < number_of_files; i++)
- {
- register struct file_entry *entry = &file_table[i];
- if (entry->library_flag)
- {
- register struct file_entry *subentry = entry->subfiles;
- for (; subentry; subentry = subentry->chain)
- (*function) (subentry, arg);
- }
- else
- (*function) (entry, arg);
- }
-}
-
-/* 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 int 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->library_flag)
- {
- register struct file_entry *subentry = entry->subfiles;
- for (; subentry; subentry = subentry->chain)
- 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 int arg;
-{
- register int i;
-
- for (i = 0; i < number_of_files; i++)
- {
- register struct file_entry *entry = &file_table[i];
- if (entry->just_syms_flag)
- continue;
- if (entry->library_flag)
- {
- register struct file_entry *subentry = entry->subfiles;
- for (; subentry; subentry = subentry->chain)
- (*function) (subentry, arg);
- }
- else
- (*function) (entry, 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 desc;
-
- if (entry->superfile)
- return file_open (entry->superfile);
-
- if (entry == input_file)
- return input_desc;
-
- if (input_file) file_close ();
-
- if (entry->search_dirs_flag)
- {
- int i;
-
- for (i = 0; i < n_search_dirs; i++)
- {
- register char *string
- = concat (search_dirs[i], "/", entry->filename);
- desc = open (string, O_RDONLY, 0);
- if (desc > 0)
- {
- entry->filename = string;
- entry->search_dirs_flag = 0;
- break;
- }
- free (string);
- }
- }
- else
- desc = open (entry->filename, O_RDONLY, 0);
-
- if (desc > 0)
- {
- input_file = entry;
- input_desc = desc;
- return desc;
- }
-
- perror_file (entry);
- /* NOTREACHED */
-}
-
-/* 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->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->superfile)
- {
- supfile = get_file_name (entry->superfile);
- result = (char *) xmalloc (strlen (supfile)
- + strlen (entry->filename) + 3);
- sprintf (result, "%s(%s)", supfile, entry->filename);
- free (supfile);
- }
- else
- {
- result = (char *) xmalloc (strlen (entry->filename) + 1);
- strcpy (result, entry->filename);
- }
- return result;
-}
-
-/* Medium-level input routines for rel files. */
-
-/* Read a file's header into the proper place in the file_entry.
- DESC is the descriptor on which the file is open.
- ENTRY is the file's entry. */
-
-void
-read_header (desc, entry)
- int desc;
- register struct file_entry *entry;
-{
- register int len;
- struct exec *loc = (struct exec *) &entry->header;
-
- lseek (desc, entry->starting_offset, 0);
-#ifdef COFF_ENCAPSULATE
- if (entry->just_syms_flag)
- lseek (desc, sizeof(coffheader), 1);
-#endif
- len = read (desc, loc, sizeof (struct exec));
- if (len != sizeof (struct exec))
- fatal_with_file ("failure reading header of ", entry);
- if (N_BADMAG (*loc))
- fatal_with_file ("bad magic number in ", entry);
-
- entry->header_read_flag = 1;
-}
-
-/* Read the symbols of file ENTRY into core.
- Assume it is already open, on descriptor DESC.
- 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 (desc, entry)
- struct file_entry *entry;
- int desc;
-{
- int str_size;
-
- if (!entry->header_read_flag)
- read_header (desc, entry);
-
- entry->symbols = (struct nlist *) xmalloc (entry->header.a_syms);
-
- lseek (desc, N_SYMOFF (entry->header) + entry->starting_offset, 0);
- if (entry->header.a_syms != read (desc, entry->symbols, entry->header.a_syms))
- fatal_with_file ("premature end of file in symbols of ", entry);
-
- lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0);
- if (sizeof str_size != read (desc, &str_size, sizeof str_size))
- fatal_with_file ("bad string table size in ", entry);
-
- entry->string_size = str_size;
-}
-
-/* Read the string table of file ENTRY into core.
- Assume it is already open, on descriptor DESC.
- Also record whether a GDB symbol segment follows the string table. */
-
-void
-read_entry_strings (desc, entry)
- struct file_entry *entry;
- int desc;
-{
- int buffer;
-
- if (!entry->header_read_flag)
- read_header (desc, entry);
-
- lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0);
- if (entry->string_size != read (desc, entry->strings, entry->string_size))
- fatal_with_file ("premature end of file in strings of ", entry);
-
-#if 0
- /* While we are here, see if the file has a symbol segment at the end.
- For a separate file, just try reading some more.
- For a library member, compare current pos against total size. */
- if (entry->superfile)
- {
- if (entry->total_size == N_STROFF (entry->header) + entry->string_size)
- return;
- }
- else
- {
- buffer = read (desc, &buffer, sizeof buffer);
- if (buffer == 0)
- return;
- if (buffer != sizeof buffer)
- fatal_with_file ("premature end of file in GDB symbol segment of ", entry);
- }
-#endif
- /* Don't try to do anything with symsegs. */
- return;
-#if 0
- /* eliminate warning of `statement not reached'. */
- entry->symseg_offset = N_STROFF (entry->header) + entry->string_size;
-#endif
-}
-
-/* Read in the symbols of all input files. */
-
-void read_file_symbols (), read_entry_symbols (), read_entry_strings ();
-void enter_file_symbols (), enter_global_ref (), search_library ();
-
-void
-load_symbols ()
-{
- register int i;
-
- if (trace_files) fprintf (stderr, "Loading symbols:\n\n");
-
- for (i = 0; i < number_of_files; i++)
- {
- register struct file_entry *entry = &file_table[i];
- read_file_symbols (entry);
- }
-
- 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 desc;
- register int len;
- struct exec hdr;
-
- desc = file_open (entry);
-
-#ifdef COFF_ENCAPSULATE
- if (entry->just_syms_flag)
- lseek (desc, sizeof(coffheader),0);
-#endif
-
- len = read (desc, &hdr, sizeof hdr);
- if (len != sizeof hdr)
- fatal_with_file ("failure reading header of ", entry);
-
- if (!N_BADMAG (hdr))
- {
- read_entry_symbols (desc, entry);
- entry->strings = (char *) alloca (entry->string_size);
- read_entry_strings (desc, entry);
- enter_file_symbols (entry);
- entry->strings = 0;
- }
- else
- {
- char armag[SARMAG];
-
- lseek (desc, 0, 0);
- if (SARMAG != read (desc, armag, SARMAG) || strncmp (armag, ARMAG, SARMAG))
- fatal_with_file ("malformed input file (not rel or archive) ", entry);
- entry->library_flag = 1;
- search_library (desc, 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;
-{
- register struct nlist
- *p,
- *end = entry->symbols + entry->header.a_syms / sizeof (struct nlist);
-
- if (trace_files) prline_file_name (entry, stderr);
-
- for (p = entry->symbols; p < end; p++)
- {
- if (p->n_type == (N_SETV | N_EXT)) continue;
- if (set_element_prefixes
- && set_element_prefixed_p (p->n_un.n_strx + entry->strings))
- p->n_type += (N_SETA - N_ABS);
-
- if (SET_ELEMENT_P (p->n_type))
- {
- set_symbol_count++;
- if (!relocatable_output)
- enter_global_ref (p, p->n_un.n_strx + entry->strings, entry);
- }
- else if (p->n_type == N_WARNING)
- {
- char *name = p->n_un.n_strx + entry->strings;
-
- /* Grab the next entry. */
- p++;
- if (p->n_type != (N_UNDF | N_EXT))
- {
- fprintf (stderr, "%s: Warning symbol found in %s without external reference following.\n",
- progname, entry->filename);
- make_executable = 0;
- p--; /* Process normally. */
- }
- else
- {
- symbol *sp;
- char *sname = p->n_un.n_strx + entry->strings;
- /* Deal with the warning symbol. */
- enter_global_ref (p, p->n_un.n_strx + entry->strings, entry);
- sp = getsym (sname);
- sp->warning = (char *) xmalloc (strlen(name) + 1);
- strcpy (sp->warning, name);
- warning_count++;
- }
- }
- else if (p->n_type & N_EXT)
- enter_global_ref (p, p->n_un.n_strx + entry->strings, entry);
- else if (p->n_un.n_strx && !(p->n_type & (N_STAB | N_EXT)))
- {
- if ((p->n_un.n_strx + entry->strings)[0] != LPREFIX)
- non_L_local_sym_count++;
- local_sym_count++;
- }
- else 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. */
-
- local_sym_count++;
- non_L_local_sym_count++;
-}
-
-/* Enter one global symbol in the hash table.
- NLIST_P points to the `struct nlist' read 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.
-
- The `struct nlist' is modified by placing it on a chain of
- all such structs that refer to the same global symbol.
- This chain starts in the `refs' field of the symbol table entry
- and is chained through the `n_name'. */
-
-void
-enter_global_ref (nlist_p, name, entry)
- register struct nlist *nlist_p;
- char *name;
- struct file_entry *entry;
-{
- register symbol *sp = getsym (name);
- register int type = nlist_p->n_type;
- int oldref = sp->referenced;
- int olddef = sp->defined;
-
- nlist_p->n_un.n_name = (char *) sp->refs;
- sp->refs = nlist_p;
-
- sp->referenced = 1;
- if (type != (N_UNDF | N_EXT) || nlist_p->n_value)
- {
- if (!sp->defined || sp->defined == (N_UNDF | N_EXT))
- sp->defined = type;
-
- if (oldref && !olddef)
- /* It used to be undefined and we're defining it. */
- undefined_global_sym_count--;
-
- if (!olddef && type == (N_UNDF | N_EXT) && nlist_p->n_value)
- {
- /* First definition and it's common. */
- common_defined_global_count++;
- sp->max_common_size = nlist_p->n_value;
- }
- else if (olddef && sp->max_common_size && type != (N_UNDF | N_EXT))
- {
- /* It used to be common and we're defining it as
- something else. */
- common_defined_global_count--;
- sp->max_common_size = 0;
- }
- else if (olddef && sp->max_common_size && type == (N_UNDF | N_EXT)
- && sp->max_common_size < nlist_p->n_value)
- /* It used to be common and this is a new common entry to
- which we need to pay attention. */
- sp->max_common_size = nlist_p->n_value;
-
- /* Are we defining it as a set element? */
- if (SET_ELEMENT_P (type)
- && (!olddef || (olddef && sp->max_common_size)))
- set_vector_count++;
- /* As an indirection? */
- else if (type == (N_INDR | N_EXT))
- {
- /* Indirect symbols value should be modified to point
- a symbol being equivalenced to. */
- nlist_p->n_value
- = (unsigned int) getsym ((nlist_p + 1)->n_un.n_strx
- + entry->strings);
- if ((symbol *) nlist_p->n_value == sp)
- {
- /* Somebody redefined a symbol to be itself. */
- fprintf (stderr, "%s: Symbol %s indirected to itself.\n",
- entry->filename, name);
- /* Rewrite this symbol as being a global text symbol
- with value 0. */
- nlist_p->n_type = sp->defined = N_TEXT | N_EXT;
- nlist_p->n_value = 0;
- /* Don't make the output executable. */
- make_executable = 0;
- }
- else
- global_indirect_count++;
- }
- }
- else
- if (!oldref)
-#ifndef DOLLAR_KLUDGE
- undefined_global_sym_count++;
-#else
- {
- if (entry->superfile && type == (N_UNDF | N_EXT) && name[1] == '$')
- {
- /* This is an (ISI?) $-conditional; skip it */
- sp->referenced = 0;
- if (sp->trace)
- {
- fprintf (stderr, "symbol %s is a $-conditional ignored in ", sp->name);
- print_file_name (entry, stderr);
- fprintf (stderr, "\n");
- }
- return;
- }
- else
- undefined_global_sym_count++;
- }
-#endif
-
- if (sp == end_symbol && entry->just_syms_flag && !T_flag_specified
- && !screwballmode)
- text_start = nlist_p->n_value;
-
- if (sp->trace)
- {
- register char *reftype;
- switch (type & N_TYPE)
- {
- case N_UNDF:
- if (nlist_p->n_value)
- reftype = "defined as common";
- else reftype = "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_SETT:
- reftype = "is a text set element";
- break;
-
- case N_SETD:
- reftype = "is a data set element";
- break;
-
- case N_SETB:
- reftype = "is a BSS set element";
- break;
-
- case N_SETA:
- reftype = "is an absolute set element";
- break;
-
- case N_SETV:
- reftype = "defined in data section as vector";
- break;
-
- case N_INDR:
- reftype = (char *) alloca (23
- + strlen ((nlist_p + 1)->n_un.n_strx
- + entry->strings));
- sprintf (reftype, "defined equivalent to %s",
- (nlist_p + 1)->n_un.n_strx + entry->strings);
- break;
-
-#ifdef sequent
- case N_SHUNDF:
- reftype = "shared undf";
- break;
-
-/* These conflict with cases above.
- case N_SHDATA:
- reftype = "shared data";
- break;
-
- case N_SHBSS:
- reftype = "shared BSS";
- break;
-*/
- default:
- reftype = "I don't know this type";
- break;
-#endif
- }
-
- fprintf (stderr, "symbol %s %s in ", sp->name, reftype);
- print_file_name (entry, stderr);
- fprintf (stderr, "\n");
- }
-}
-
-/* This return 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, n_ptr)
- struct file_entry *entry;
- register struct nlist *n_ptr;
-{
- if (n_ptr >= entry->symbols &&
- n_ptr < (entry->symbols
- + (entry->header.a_syms / sizeof (struct nlist))))
- return (unsigned long) entry;
- return 0;
-}
-
-
-/* Searching libraries */
-
-struct file_entry *decode_library_subfile ();
-void linear_library (), symdef_library ();
-
-/* Search the library ENTRY, already open on descriptor DESC.
- 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 (desc, entry)
- int desc;
- struct file_entry *entry;
-{
- int member_length;
- register char *name;
- register struct file_entry *subentry;
-
- if (!undefined_global_sym_count) return;
-
- /* Examine its first member, which starts SARMAG bytes in. */
- subentry = decode_library_subfile (desc, 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 (desc, entry, member_length);
- else
- linear_library (desc, 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 DESC.
- SUBFILE_OFFSET is the byte index in the library of this member's header.
- We store the length of the member into *LENGTH_LOC. */
-
-struct file_entry *
-decode_library_subfile (desc, library_entry, subfile_offset, length_loc)
- int desc;
- struct file_entry *library_entry;
- int subfile_offset;
- int *length_loc;
-{
- int bytes_read;
- register int namelen;
- int member_length;
- register char *name;
- struct ar_hdr hdr1;
- register struct file_entry *subentry;
-
- lseek (desc, subfile_offset, 0);
-
- bytes_read = read (desc, &hdr1, sizeof hdr1);
- if (!bytes_read)
- return 0; /* end of archive */
-
- if (sizeof hdr1 != bytes_read)
- fatal_with_file ("malformed library archive ", library_entry);
-
- if (sscanf (hdr1.ar_size, "%d", &member_length) != 1)
- fatal_with_file ("malformatted header of archive member in ", library_entry);
-
- 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++);
-
- name = (char *) xmalloc (namelen+1);
- strncpy (name, hdr1.ar_name, namelen);
- name[namelen] = 0;
-
- subentry->filename = name;
- subentry->local_sym_name = name;
- subentry->symbols = 0;
- subentry->strings = 0;
- subentry->subfiles = 0;
- subentry->starting_offset = subfile_offset + sizeof hdr1;
- subentry->superfile = library_entry;
- subentry->library_flag = 0;
- subentry->header_read_flag = 0;
- subentry->just_syms_flag = 0;
- subentry->chain = 0;
- subentry->total_size = member_length;
-
- (*length_loc) = member_length;
-
- return subentry;
-}
-
-int subfile_wanted_p ();
-
-/* Search a library that has a __.SYMDEF member.
- DESC 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. */
-
-void
-symdef_library (desc, entry, member_length)
- int desc;
- struct file_entry *entry;
- int member_length;
-{
- int *symdef_data = (int *) xmalloc (member_length);
- register struct symdef *symdef_base;
- char *sym_name_base;
- int number_of_symdefs;
- 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 (desc, symdef_data, member_length);
- if (bytes_read != member_length)
- fatal_with_file ("malformatted __.SYMDEF in ", entry);
-
- number_of_symdefs = *symdef_data / sizeof (struct symdef);
- if (number_of_symdefs < 0 ||
- number_of_symdefs * sizeof (struct symdef) + 2 * sizeof (int) > member_length)
- fatal_with_file ("malformatted __.SYMDEF in ", entry);
-
- symdef_base = (struct symdef *) (symdef_data + 1);
- length_of_strings = *(int *) (symdef_base + number_of_symdefs);
-
- if (length_of_strings < 0
- || number_of_symdefs * sizeof (struct symdef) + length_of_strings
- + 2 * sizeof (int) > member_length)
- fatal_with_file ("malformatted __.SYMDEF in ", entry);
-
- sym_name_base = sizeof (int) + (char *) (symdef_base + number_of_symdefs);
-
- /* Check all the string indexes for validity. */
-
- for (i = 0; i < number_of_symdefs; i++)
- {
- register int index = symdef_base[i].symbol_name_string_index;
- if (index < 0 || index >= length_of_strings
- || (index && *(sym_name_base + index - 1)))
- fatal_with_file ("malformatted __.SYMDEF in ", 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 < number_of_symdefs
- && (undefined_global_sym_count || common_defined_global_count));
- i++)
- if (symdef_base[i].symbol_name_string_index >= 0)
- {
- register symbol *sp;
-
- sp = getsym_soft (sym_name_base
- + symdef_base[i].symbol_name_string_index);
-
- /* If we find a symbol that appears to be needed, think carefully
- about the archive member that the symbol is in. */
-
- if (sp && ((sp->referenced && !sp->defined)
- || (sp->defined && sp->max_common_size)))
- {
- int junk;
- register int j;
- register int offset = symdef_base[i].library_member_offset;
- struct file_entry *subentry;
-
- /* 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 (desc, entry, offset, &junk);
- if (subentry == 0)
- fatal ("invalid offset for %s in symbol table of %s",
- sym_name_base
- + symdef_base[i].symbol_name_string_index,
- entry->filename);
- read_entry_symbols (desc, subentry);
- subentry->strings = (char *) malloc (subentry->string_size);
- read_entry_strings (desc, subentry);
-
- /* Now scan the symbol table and decide whether to load. */
-
- if (!subfile_wanted_p (subentry))
- {
- 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;
-
- 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 < number_of_symdefs; j++)
- {
- if (symdef_base[j].library_member_offset == offset)
- symdef_base[j].symbol_name_string_index = -1;
- }
- }
-
- /* We'll read the strings again if we need them again. */
- free (subentry->strings);
- subentry->strings = 0;
- }
- }
- }
-
- free (symdef_data);
-}
-
-/* Search a library that has no __.SYMDEF.
- ENTRY is the library's file_entry.
- DESC is the descriptor it is open on. */
-
-void
-linear_library (desc, entry)
- int desc;
- struct file_entry *entry;
-{
- register struct file_entry *prev = 0;
- register int this_subfile_offset = SARMAG;
-
- while (undefined_global_sym_count || common_defined_global_count)
- {
- int member_length;
- register struct file_entry *subentry;
-
- subentry = decode_library_subfile (desc, entry, this_subfile_offset,
- &member_length);
-
- if (!subentry) return;
-
- read_entry_symbols (desc, subentry);
- subentry->strings = (char *) alloca (subentry->string_size);
- read_entry_strings (desc, subentry);
-
- if (!subfile_wanted_p (subentry))
- {
- free (subentry->symbols);
- free (subentry);
- }
- else
- {
- 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. */
-
-int
-subfile_wanted_p (entry)
- struct file_entry *entry;
-{
- register struct nlist *p;
- register struct nlist *end
- = entry->symbols + entry->header.a_syms / sizeof (struct nlist);
-#ifdef DOLLAR_KLUDGE
- register int dollar_cond = 0;
-#endif
-
- for (p = entry->symbols; p < end; p++)
- {
- register int type = p->n_type;
- register char *name = p->n_un.n_strx + entry->strings;
-
- /* If the symbol has an interesting definition, we could
- potentially want it. */
- if (type & N_EXT
- && (type != (N_UNDF | N_EXT) || p->n_value
-
-#ifdef DOLLAR_KLUDGE
- || name[1] == '$'
-#endif
- )
- && !SET_ELEMENT_P (type)
- && !set_element_prefixed_p (name))
- {
- register symbol *sp = getsym_soft (name);
-
-#ifdef DOLLAR_KLUDGE
- if (name[1] == '$')
- {
- sp = getsym_soft (&name[2]);
- dollar_cond = 1;
- if (!sp) continue;
- if (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;
-
- if ((sp->referenced && !sp->defined)
- || (sp->defined && sp->max_common_size && (type & N_TEXT) == 0))
- {
- /* 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->max_common_size)
- common_defined_global_count++;
-
- if (sp->max_common_size < p->n_value)
- sp->max_common_size = p->n_value;
- if (!sp->defined)
- undefined_global_sym_count--;
- sp->defined = 1;
- continue;
- }
-
- if (write_map)
- {
- print_file_name (entry, stdout);
- fprintf (stdout, " needed due to %s\n", sp->name);
- }
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-void consider_file_section_lengths (), relocate_file_addresses ();
-
-/* 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. */
-
-void
-digest_symbols ()
-{
- register int i;
- int setv_fill_count;
-
- if (trace_files)
- fprintf (stderr, "Digesting symbol information:\n\n");
-
- /* Compute total size of sections */
-
- each_file (consider_file_section_lengths, 0);
-
- /* If necessary, pad text section to full page in the file.
- Include the padding in the text segment size. */
-
- if (magic == ZMAGIC)
- {
- int text_end = text_size + N_TXTOFF (outheader);
- text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end;
- text_size += text_pad;
- }
-
-#ifdef _N_BASEADDR
- /* SunOS 4.1 N_TXTADDR depends on the value of outheader.a_entry. */
- outheader.a_entry = N_PAGSIZ (outheader);
-#endif
-
- outheader.a_text = text_size;
-#ifdef sequent
- outheader.a_text += N_ADDRADJ (outheader);
-#endif
-
- /* Make the data segment address start in memory on a suitable boundary. */
-
- if (! Tdata_flag_specified)
- data_start = N_DATADDR (outheader) + text_start - TEXT_START (outheader);
-
- /* Set up the set element vector */
-
- 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
- = (2 * set_symbol_count + set_vector_count) * sizeof (unsigned long);
- set_sect_start = data_start + data_size;
- data_size += set_sect_size;
- set_vectors = (unsigned long *) xmalloc (set_sect_size);
- setv_fill_count = 0;
- }
-
- /* Compute start addresses of each file's sections and symbols. */
-
- each_full_file (relocate_file_addresses, 0);
-
- /* Now, for each symbol, verify that it is defined globally at most once.
- Put the global value into the symbol entry.
- Common symbols are allocated here, in the BSS section.
- Each defined symbol is given a '->defined' field
- which is the correct N_ code for its definition,
- except in the case of common symbols with -r.
- Then make all the references point at the symbol entry
- instead of being chained together. */
-
- defined_global_sym_count = 0;
-
- for (i = 0; i < TABSIZE; i++)
- {
- register symbol *sp;
- for (sp = symtab[i]; sp; sp = sp->link)
- {
- /* For each symbol */
- register struct nlist *p, *next;
- int defs = 0, com = sp->max_common_size;
- struct nlist *first_definition;
- for (p = sp->refs; p; p = next)
- {
- register int type = p->n_type;
-
- if (SET_ELEMENT_P (type))
- {
- if (relocatable_output)
- fatal ("internal: global ref to set element with -r");
- if (!defs++)
- {
- sp->value = set_sect_start
- + setv_fill_count++ * sizeof (unsigned long);
- sp->defined = N_SETV | N_EXT;
- first_definition = p;
- }
- else if ((sp->defined & ~N_EXT) != N_SETV)
- {
- sp->multiply_defined = 1;
- multiple_def_count++;
- }
- set_vectors[setv_fill_count++] = p->n_value;
- }
- else if ((type & N_EXT) && type != (N_UNDF | N_EXT))
- {
- /* non-common definition */
- if (defs++ && sp->value != p->n_value)
- {
- sp->multiply_defined = 1;
- multiple_def_count++;
- }
- sp->value = p->n_value;
- sp->defined = type;
- first_definition = p;
- }
- next = (struct nlist *) p->n_un.n_name;
- p->n_un.n_name = (char *) sp;
- }
- /* Allocate as common if defined as common and not defined for real */
- if (com && !defs)
- {
- if (!relocatable_output || force_common_definition)
- {
- int align = sizeof (int);
-
- /* 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). */
-
- com = (com + sizeof (int) - 1) & (- sizeof (int));
-
- while (!(com & align))
- align <<= 1;
-
- align = align > MAX_ALIGNMENT ? MAX_ALIGNMENT : align;
-
- bss_size = ((((bss_size + data_size + data_start)
- + (align - 1)) & (- align))
- - data_size - data_start);
-
- sp->value = data_start + data_size + bss_size;
- sp->defined = N_BSS | N_EXT;
- bss_size += com;
- if (write_map)
- printf ("Allocating common %s: %x at %x\n",
- sp->name, com, sp->value);
- }
- else
- {
- sp->defined = 0;
- undefined_global_sym_count++;
- }
- }
- /* Set length word at front of vector and zero byte at end.
- Reverse the vector itself to put it in file order. */
- if ((sp->defined & ~N_EXT) == N_SETV)
- {
- unsigned long length_word_index
- = (sp->value - set_sect_start) / sizeof (unsigned long);
- unsigned long i, tmp;
-
- set_vectors[length_word_index]
- = setv_fill_count - 1 - length_word_index;
-
- /* Reverse the vector. */
- for (i = 1;
- i < (setv_fill_count - length_word_index - 1) / 2 + 1;
- i++)
- {
- tmp = set_vectors[length_word_index + i];
- set_vectors[length_word_index + i]
- = set_vectors[setv_fill_count - i];
- set_vectors[setv_fill_count - i] = tmp;
- }
-
- set_vectors[setv_fill_count++] = 0;
- }
- if (sp->defined)
- defined_global_sym_count++;
- }
- }
-
- if (end_symbol) /* These are null if -r. */
- {
- etext_symbol->value = text_size + text_start;
- edata_symbol->value = data_start + data_size;
- end_symbol->value = 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 (magic == ZMAGIC)
- data_pad = ((data_pad + data_size + page_size - 1) & (- page_size))
- - data_size;
-
- bss_size -= data_pad;
- if (bss_size < 0) bss_size = 0;
-
- data_size += data_pad;
-}
-
-/* Accumulate the section sizes of input file ENTRY
- into the section sizes of the output file. */
-
-void
-consider_file_section_lengths (entry)
- register struct file_entry *entry;
-{
- if (entry->just_syms_flag)
- return;
-
- 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 += 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. */
-
-void
-relocate_file_addresses (entry)
- register struct file_entry *entry;
-{
- 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 += data_start + data_size;
-
- {
- register struct nlist *p;
- register struct nlist *end
- = entry->symbols + entry->header.a_syms / sizeof (struct nlist);
-
- for (p = entry->symbols; p < end; p++)
- {
- /* If this belongs to a section, update it by the section's start address */
- register int type = p->n_type & N_TYPE;
-
- switch (type)
- {
- case N_TEXT:
- case N_SETT:
- p->n_value += entry->text_start_address;
- break;
- case N_DATA:
- case N_SETV:
- case N_SETD:
- /* 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;
- }
- }
- }
-}
-
-void describe_file_sections (), list_file_locals ();
-
-/* Print a complete or partial map of the output file. */
-
-void
-print_symbols (outfile)
- FILE *outfile;
-{
- register int i;
-
- fprintf (outfile, "\nFiles:\n\n");
-
- each_file (describe_file_sections, outfile);
-
- fprintf (outfile, "\nGlobal symbols:\n\n");
-
- for (i = 0; i < TABSIZE; i++)
- {
- register symbol *sp;
- for (sp = symtab[i]; sp; sp = sp->link)
- {
- if (sp->defined == 1)
- fprintf (outfile, " %s: common, length 0x%x\n", sp->name, sp->max_common_size);
- if (sp->defined)
- fprintf (outfile, " %s: 0x%x\n", sp->name, sp->value);
- else if (sp->referenced)
- fprintf (outfile, " %s: undefined\n", sp->name);
- }
- }
-
- each_file (list_file_locals, outfile);
-}
-
-void
-describe_file_sections (entry, outfile)
- struct file_entry *entry;
- FILE *outfile;
-{
- fprintf (outfile, " ");
- print_file_name (entry, outfile);
- if (entry->just_syms_flag)
- fprintf (outfile, " symbols only\n", 0);
- else
- fprintf (outfile, " text %x(%x), data %x(%x), bss %x(%x) 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);
-}
-
-void
-list_file_locals (entry, outfile)
- struct file_entry *entry;
- FILE *outfile;
-{
- register struct nlist
- *p,
- *end = entry->symbols + entry->header.a_syms / sizeof (struct nlist);
-
- 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");
-
- for (p = entry->symbols; p < end; p++)
- /* 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%x\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 */
-int list_unresolved_refs; /* List unresolved refs */
-int list_warning_symbols; /* List warning syms */
-int list_multiple_defs; /* List multiple definitions */
-
-/*
- * 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 nlist *sym;
-};
-
-void qsort ();
-/*
- * 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. */
-
-int
-relocation_entries_relation (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. */
-
-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;
-
- current->sym = next->sym;
- current->line = next->line;
- current->filename = next->filename;
-
- while (++(next->sym) < (entry->symbols
- + entry->header.a_syms/sizeof (struct 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 (next->sym->n_type & 0xff)
- {
- case N_SLINE:
- if (use_data_symbols) continue;
- next->line = next->sym->n_desc;
- return 1;
- case N_DSLINE:
- if (!use_data_symbols) continue;
- next->line = next->sym->n_desc;
- return 1;
-#ifdef HAVE_SUN_STABS
- case N_EINCL:
- next->filename = source->filename;
- continue;
-#endif
- case N_SO:
- source->filename = next->sym->n_un.n_strx + entry->strings;
- source->line++;
-#ifdef HAVE_SUN_STABS
- case N_BINCL:
-#endif
- case N_SOL:
- next->filename
- = next->sym->n_un.n_strx + entry->strings;
- default:
- continue;
- }
- }
- next->sym = (struct nlist *) 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. */
-
-struct line_debug_entry *
-init_debug_scan (use_data_symbols, entry)
- int use_data_symbols;
- struct file_entry *entry;
-{
- struct line_debug_entry
- *state_pointer
- = (struct line_debug_entry *)
- xmalloc (3 * sizeof (struct line_debug_entry));
- register struct line_debug_entry
- *current = state_pointer,
- *next = state_pointer + 1,
- *source = state_pointer + 2; /* Used to store source file */
-
- struct nlist *tmp;
-
- for (tmp = entry->symbols;
- tmp < (entry->symbols
- + entry->header.a_syms/sizeof (struct nlist));
- tmp++)
- if (tmp->n_type == (int) N_SO)
- break;
-
- if (tmp >= (entry->symbols
- + entry->header.a_syms/sizeof (struct nlist)))
- {
- /* I believe this translates to "We lose" */
- current->filename = next->filename = entry->filename;
- current->line = next->line = -1;
- current->sym = next->sym = (struct nlist *) 0;
- return state_pointer;
- }
-
- next->line = source->line = 0;
- next->filename = source->filename
- = (tmp->n_un.n_strx + entry->strings);
- source->sym = (struct nlist *) entry;
- next->sym = tmp;
-
- next_debug_entry (use_data_symbols, state_pointer); /* To setup next */
-
- 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;
- }
-
-
- next_debug_entry (use_data_symbols, state_pointer); /* To setup current */
-
- 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. */
-
-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 = state_pointer,
- *next = state_pointer + 1;
- struct line_debug_entry *tmp_pointer;
-
- int use_data_symbols;
-
- if (next->sym)
- use_data_symbols = (next->sym->n_type & N_TYPE) == N_DATA;
- else
- return current->line;
-
- /* Go back to the beginning if we've already passed it. */
- if (current->sym->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->n_value > address)
- return -1;
-
- while (next->sym
- && next->sym->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. */
-
-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
- *reloc_start = data_segment ? entry->datarel : entry->textrel,
- *reloc;
- int reloc_size
- = ((data_segment ? entry->header.a_drsize : entry->header.a_trsize)
- / sizeof (struct relocation_info));
- int start_of_segment
- = (data_segment ? entry->data_start_address : entry->text_start_address);
- struct nlist *start_of_syms = entry->symbols;
- struct line_debug_entry *state_pointer
- = init_debug_scan (data_segment != 0, entry);
- register struct line_debug_entry
- *current = state_pointer;
- /* 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;
-
- /* We need to sort the relocation info here. Sheesh, so much effort
- for one lousy error optimization. */
-
- qsort (reloc_start, reloc_size, sizeof (struct relocation_info),
- relocation_entries_relation);
-
- for (reloc = reloc_start;
- reloc < (reloc_start + reloc_size);
- reloc++)
- {
- register struct nlist *s;
- register symbol *g;
-
- /* If the relocation isn't resolved through a symbol, continue */
- if (!RELOC_EXTERN_P(reloc))
- continue;
-
- s = &(entry->symbols[RELOC_SYMBOL(reloc)]);
-
- /* 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 (!(s->n_type & N_EXT))
- continue;
-
- g = (symbol *) s->n_un.n_name;
- errmsg = 0;
-
- if (!g->defined && list_unresolved_refs) /* Reference */
- {
- /* Mark as being noted by relocation warning pass. */
- SET_BIT (nlist_bitvector, s - start_of_syms);
-
- 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;
-
- /* Mark as being noted by relocation warning pass. */
- SET_BIT (nlist_bitvector, s - 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;
-
- if (demangler == NULL || (nm = (*demangler)(g->name)) == NULL)
- nm = g->name;
- errmsg = (char *) xmalloc (strlen (errfmt) + strlen (nm) + 1);
- sprintf (errmsg, errfmt, nm, data_segment ? "data" : "text");
- if (nm != g->name)
- free (nm);
- }
-
- address_to_line (RELOC_ADDRESS (reloc) + 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 number_of_syms = entry->header.a_syms / sizeof (struct nlist);
- unsigned char *nlist_bitvector
- = (unsigned char *) alloca ((number_of_syms >> 3) + 1);
- struct line_debug_entry *text_scan, *data_scan;
- int i;
- char *errfmt, *file_name;
- int line_number;
- int dont_allow_symbol_name;
-
- bzero (nlist_bitvector, (number_of_syms >> 3) + 1);
-
- /* Read in the files strings if they aren't available */
- if (!entry->strings)
- {
- int desc;
-
- entry->strings = (char *) alloca (entry->string_size);
- desc = file_open (entry);
- read_entry_strings (desc, entry);
- }
-
- read_file_relocation (entry);
-
- /* Do text warnings based on a scan through the relocation info. */
- do_relocation_warnings (entry, 0, outfile, nlist_bitvector);
-
- /* Do data warnings based on a scan through the relocation 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 < number_of_syms; i++)
- {
- struct nlist *s;
- struct glosym *g;
-
- s = entry->symbols + i;
-
- if (!(s->n_type & N_EXT))
- continue;
-
- g = (symbol *) s->n_un.n_name;
- dont_allow_symbol_name = 0;
-
- if (list_multiple_defs && g->multiply_defined)
- {
- errfmt = "Definition of symbol %s (multiply defined)";
- switch (s->n_type)
- {
- case N_TEXT | N_EXT:
- line_number = address_to_line (s->n_value, text_scan);
- file_name = text_scan[0].filename;
- break;
- case N_DATA | N_EXT:
- line_number = address_to_line (s->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->multiply_defined == 2)
- continue;
- errfmt = "First set element definition of symbol %s (multiply defined)";
- break;
- default:
- continue; /* Don't print out multiple defs
- at references. */
- }
- }
- else if (BIT_SET_P (nlist_bitvector, i))
- continue;
- else if (list_unresolved_refs && !g->defined)
- {
- 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->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 (s->n_type != (N_EXT | N_UNDF)
- || (i && (s-1)->n_type == N_WARNING))
- continue;
-
- errfmt = g->warning;
- line_number = -1;
- dont_allow_symbol_name = 1;
- }
- else
- continue;
-
- if (line_number == -1)
- fprintf (outfile, "%s: ", entry->filename);
- else
- fprintf (outfile, "%s:%d: ", file_name, line_number);
-
- if (dont_allow_symbol_name)
- fprintf (outfile, "%s", errfmt);
- else
- {
- char *nm;
- if (demangler != NULL && (nm = (*demangler)(g->name)) != NULL)
- {
- fprintf (outfile, errfmt, nm);
- free (nm);
- }
- else
- fprintf (outfile, errfmt, g->name);
- }
-
- fputc ('\n', outfile);
- }
- free (text_scan);
- free (data_scan);
- entry->strings = 0; /* Since it will dissapear anyway. */
-}
-
-do_warnings (outfile)
- FILE *outfile;
-{
- list_unresolved_refs = !relocatable_output && undefined_global_sym_count;
- list_warning_symbols = warning_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;
-
- each_file (do_file_warnings, outfile);
-
- if (list_unresolved_refs || list_multiple_defs)
- make_executable = 0;
-}
-
-/* Write the output file */
-
-void
-write_output ()
-{
- struct stat statbuf;
- int filemode;
-
- (void) unlink (output_filename);
- outdesc = open (output_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
- if (outdesc < 0) perror_name (output_filename);
-
- if (fstat (outdesc, &statbuf) < 0)
- perror_name (output_filename);
-
- filemode = statbuf.st_mode;
-
- chmod (output_filename, filemode & ~0111);
-
- /* 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 ();
-
- /* Copy any GDB symbol segments from input files. */
- write_symsegs ();
-
- close (outdesc);
-
- if (chmod (output_filename, filemode | 0111) == -1)
- perror_name (output_filename);
-}
-
-void modify_location (), perform_relocation (), copy_text (), copy_data ();
-
-void
-write_header ()
-{
- N_SET_MAGIC (outheader, magic);
- outheader.a_text = text_size;
-#ifdef sequent
- outheader.a_text += N_ADDRADJ (outheader);
- if (entry_symbol == 0)
- entry_symbol = getsym("start");
-#endif
- outheader.a_data = data_size;
- outheader.a_bss = bss_size;
- outheader.a_entry = (entry_symbol ? entry_symbol->value
- : text_start + entry_offset);
-if (screwballmode) {
- N_SET_MAGIC (outheader, ZMAGIC);
- outheader.a_text = 0;
- outheader.a_data = text_size + data_size;
- outheader.a_entry = (entry_symbol ? entry_symbol->value
- : sizeof(struct exec));
-}
-#ifdef COFF_ENCAPSULATE
- if (need_coff_header)
- {
- /* We are encapsulating BSD format within COFF format. */
- struct coffscn *tp, *dp, *bp;
-
- tp = &coffheader.scns[0];
- dp = &coffheader.scns[1];
- bp = &coffheader.scns[2];
-
- strcpy (tp->s_name, ".text");
- tp->s_paddr = text_start;
- tp->s_vaddr = text_start;
- tp->s_size = text_size;
- tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec);
- tp->s_relptr = 0;
- tp->s_lnnoptr = 0;
- tp->s_nreloc = 0;
- tp->s_nlnno = 0;
- tp->s_flags = 0x20;
- strcpy (dp->s_name, ".data");
- dp->s_paddr = data_start;
- dp->s_vaddr = data_start;
- dp->s_size = data_size;
- dp->s_scnptr = tp->s_scnptr + tp->s_size;
- dp->s_relptr = 0;
- dp->s_lnnoptr = 0;
- dp->s_nreloc = 0;
- dp->s_nlnno = 0;
- dp->s_flags = 0x40;
- strcpy (bp->s_name, ".bss");
- bp->s_paddr = dp->s_vaddr + dp->s_size;
- bp->s_vaddr = bp->s_paddr;
- bp->s_size = bss_size;
- bp->s_scnptr = 0;
- bp->s_relptr = 0;
- bp->s_lnnoptr = 0;
- bp->s_nreloc = 0;
- bp->s_nlnno = 0;
- bp->s_flags = 0x80;
-
- coffheader.f_magic = COFF_MAGIC;
- coffheader.f_nscns = 3;
- /* store an unlikely time so programs can
- * tell that there is a bsd header
- */
- coffheader.f_timdat = 1;
- coffheader.f_symptr = 0;
- coffheader.f_nsyms = 0;
- coffheader.f_opthdr = 28;
- coffheader.f_flags = 0x103;
- /* aouthdr */
- coffheader.magic = ZMAGIC;
- coffheader.vstamp = 0;
- coffheader.tsize = tp->s_size;
- coffheader.dsize = dp->s_size;
- coffheader.bsize = bp->s_size;
- coffheader.entry = outheader.a_entry;
- coffheader.text_start = tp->s_vaddr;
- coffheader.data_start = dp->s_vaddr;
- }
-#endif
-
-#ifdef INITIALIZE_HEADER
- INITIALIZE_HEADER;
-#endif
-
- if (strip_symbols == STRIP_ALL)
- nsyms = 0;
- else
- {
- nsyms = (defined_global_sym_count
- + undefined_global_sym_count);
- if (discard_locals == DISCARD_L)
- nsyms += non_L_local_sym_count;
- else if (discard_locals == DISCARD_NONE)
- nsyms += local_sym_count;
- /* One extra for following reference on indirects */
- if (relocatable_output)
- nsyms += set_symbol_count + global_indirect_count;
- }
-
- if (strip_symbols == STRIP_NONE)
- nsyms += debugger_sym_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;
- }
-
-#ifdef COFF_ENCAPSULATE
- if (need_coff_header)
- mywrite (&coffheader, sizeof coffheader, 1, outdesc);
-#endif
- mywrite (&outheader, sizeof (struct exec), 1, outdesc);
-if (screwballmode)
- N_SET_MAGIC (outheader, OMAGIC);
-
- /* 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, outdesc);
-#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, outdesc);
-}
-
-int
-text_offset (entry)
- struct file_entry *entry;
-{
- return entry->starting_offset + N_TXTOFF (entry->header);
-}
-
-/* Read in all of the relocation information */
-
-void
-read_relocation ()
-{
- each_full_file (read_file_relocation, 0);
-}
-
-/* Read in the relocation sections of ENTRY if necessary */
-
-void
-read_file_relocation (entry)
- struct file_entry *entry;
-{
- register struct relocation_info *reloc;
- int desc;
- int read_return;
-
- desc = -1;
- if (!entry->textrel)
- {
- reloc = (struct relocation_info *) xmalloc (entry->header.a_trsize);
- desc = file_open (entry);
- lseek (desc,
- text_offset (entry) + entry->header.a_text + entry->header.a_data,
- L_SET);
- if (entry->header.a_trsize != (read_return = read (desc, reloc, entry->header.a_trsize)))
- {
- fprintf (stderr, "Return from read: %d\n", read_return);
- fatal_with_file ("premature eof in text relocation of ", entry);
- }
- entry->textrel = reloc;
- }
-
- if (!entry->datarel)
- {
- reloc = (struct relocation_info *) xmalloc (entry->header.a_drsize);
- if (desc == -1) desc = file_open (entry);
- lseek (desc,
- text_offset (entry) + entry->header.a_text
- + entry->header.a_data + entry->header.a_trsize,
- L_SET);
- if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize))
- fatal_with_file ("premature eof in data relocation of ", entry);
- entry->datarel = reloc;
- }
-}
-
-/* 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 desc;
- register struct relocation_info *reloc;
-
- if (trace_files)
- prline_file_name (entry, stderr);
-
- desc = 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) reloc = entry->textrel;
- else if (relocatable_output)
- {
- read_file_relocation (entry);
- reloc = entry->textrel;
- }
- else
- {
- reloc = (struct relocation_info *) alloca (entry->header.a_trsize);
- lseek (desc, text_offset (entry) + entry->header.a_text + entry->header.a_data, 0);
- if (entry->header.a_trsize != read (desc, reloc, entry->header.a_trsize))
- fatal_with_file ("premature eof in text relocation of ", entry);
- }
-
- /* Read the text section into core. */
-
- lseek (desc, text_offset (entry), 0);
- if (entry->header.a_text != read (desc, bytes, entry->header.a_text))
- fatal_with_file ("premature eof in text section of ", entry);
-
-
- /* Relocate the text according to the text relocation. */
-
- perform_relocation (bytes, entry->text_start_address, entry->header.a_text,
- reloc, entry->header.a_trsize, entry);
-
- /* Write the relocated text to the output file. */
-
- mywrite (bytes, 1, entry->header.a_text, outdesc);
-}
-
-/* Relocate the data segment of each input file
- and write to the output file. */
-
-void
-write_data ()
-{
- if (trace_files)
- fprintf (stderr, "Copying and relocating data:\n\n");
-
- 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)
- mywrite (set_vectors, 2 * set_symbol_count + set_vector_count,
- sizeof (unsigned long), outdesc);
-
- if (trace_files)
- fprintf (stderr, "\n");
-
- padfile (data_pad, outdesc);
-}
-
-/* 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 struct relocation_info *reloc;
- register char *bytes;
- register int desc;
-
- if (trace_files)
- prline_file_name (entry, stderr);
-
- desc = file_open (entry);
-
- bytes = (char *) alloca (entry->header.a_data);
-
- if (entry->datarel) reloc = entry->datarel;
- else if (relocatable_output) /* Will need this again */
- {
- read_file_relocation (entry);
- reloc = entry->datarel;
- }
- else
- {
- reloc = (struct relocation_info *) alloca (entry->header.a_drsize);
- lseek (desc, text_offset (entry) + entry->header.a_text
- + entry->header.a_data + entry->header.a_trsize,
- 0);
- if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize))
- fatal_with_file ("premature eof in data relocation of ", entry);
- }
-
- lseek (desc, text_offset (entry) + entry->header.a_text, 0);
- if (entry->header.a_data != read (desc, bytes, entry->header.a_data))
- fatal_with_file ("premature eof in data section of ", entry);
-
- perform_relocation (bytes, entry->data_start_address - entry->header.a_text,
- entry->header.a_data, reloc, entry->header.a_drsize, entry);
-
- mywrite (bytes, 1, entry->header.a_data, outdesc);
-}
-
-/* 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_INFO is the address of the relocation info, in core.
- RELOC_SIZE is its length in bytes. */
-/* This version is about to be severly hacked by Randy. Hope it
- works afterwards. */
-void
-perform_relocation (data, pc_relocation, data_size, reloc_info, reloc_size, entry)
- char *data;
- struct relocation_info *reloc_info;
- struct file_entry *entry;
- int pc_relocation;
- int data_size;
- int reloc_size;
-{
- register struct relocation_info *p = reloc_info;
- struct relocation_info *end
- = reloc_info + reloc_size / sizeof (struct relocation_info);
- 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;
-
- for (; p < end; p++)
- {
- register int relocation = 0;
- register int addr = RELOC_ADDRESS(p);
- register unsigned int mask = 0;
-
- if (addr >= data_size)
- fatal_with_file ("relocation address out of range in ", entry);
-
- if (RELOC_EXTERN_P(p))
- {
- int symindex = RELOC_SYMBOL (p) * sizeof (struct nlist);
- symbol *sp = ((symbol *)
- (((struct nlist *)
- (((char *)entry->symbols) + symindex))
- ->n_un.n_name));
-
-#ifdef N_INDR
- /* Resolve indirection */
- if ((sp->defined & ~N_EXT) == N_INDR)
- sp = (symbol *) sp->value;
-#endif
-
- if (symindex >= entry->header.a_syms)
- fatal_with_file ("relocation symbolnum out of range in ", entry);
-
- /* If the symbol is undefined, leave it at zero. */
- if (! sp->defined)
- relocation = 0;
- else
- relocation = sp->value;
- }
- else switch (RELOC_TYPE(p))
- {
- case N_TEXT:
- case N_TEXT | N_EXT:
- relocation = 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 = 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 = 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:
- fatal_with_file ("nonexternal relocation code invalid in ", entry);
- }
-
-#ifdef RELOC_ADD_EXTRA
- relocation += RELOC_ADD_EXTRA(p);
- 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 (p))
- {
- if ((int)p->r_type <= RELOC_32
- || RELOC_EXTERN_P (p) == 0)
- RELOC_ADD_EXTRA (p) = relocation;
- }
- /* External PC-relative relocations continue to move around;
- update their relocations by the amount they have moved
- so far. */
- else if (RELOC_EXTERN_P (p))
- RELOC_ADD_EXTRA (p) -= pc_relocation;
- continue;
- }
-#endif
-
- if (RELOC_PCREL_P(p))
- relocation -= pc_relocation;
-
- relocation >>= RELOC_VALUE_RIGHTSHIFT(p);
-
- /* Unshifted mask for relocation */
- mask = 1 << RELOC_TARGET_BITSIZE(p) - 1;
- mask |= mask - 1;
- relocation &= mask;
-
- /* Shift everything up to where it's going to be used */
- relocation <<= RELOC_TARGET_BITPOS(p);
- mask <<= RELOC_TARGET_BITPOS(p);
-
- switch (RELOC_TARGET_SIZE(p))
- {
- case 0:
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & *(char *) (data + addr);
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & *(char *) (data + addr);
- *(char *) (data + addr) &= ~mask;
- *(char *) (data + addr) |= relocation;
- break;
-
- case 1:
-#ifdef tahoe
- if (((int) data + addr & 1) == 0)
- {
-#endif
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & *(short *) (data + addr);
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & *(short *) (data + addr);
- *(short *) (data + addr) &= ~mask;
- *(short *) (data + addr) |= relocation;
-#ifdef tahoe
- }
- /*
- * The CCI Power 6 (aka Tahoe) architecture has byte-aligned
- * instruction operands but requires data accesses to be aligned.
- * Brain-damage...
- */
- else
- {
- unsigned char *da = (unsigned char *) (data + addr);
- unsigned short s = da[0] << 8 | da[1];
-
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & s;
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & s;
- s &= ~mask;
- s |= relocation;
- da[0] = s >> 8;
- da[1] = s;
- }
-#endif
- break;
-
- case 2:
-#ifndef _CROSS_TARGET_ARCH
-#ifdef tahoe
- if (((int) data + addr & 3) == 0)
- {
-#endif
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & *(long *) (data + addr);
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & *(long *) (data + addr);
- *(long *) (data + addr) &= ~mask;
- *(long *) (data + addr) |= relocation;
-#ifdef tahoe
- }
- else
- {
- unsigned char *da = (unsigned char *) (data + addr);
- unsigned long l = da[0] << 24 | da[1] << 16 | da[2] << 8 | da[3];
-
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & l;
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & l;
- l &= ~mask;
- l |= relocation;
- da[0] = l >> 24;
- da[1] = l >> 16;
- da[2] = l >> 8;
- da[3] = l;
- }
-#endif
-#else
- /* Handle long word alignment requirements of SPARC architecture */
- /* WARNING: This fix makes an assumption on byte ordering */
- /* Marc Ullman, Stanford University Nov. 1 1989 */
- if (RELOC_MEMORY_SUB_P(p)) {
- relocation -= mask &
- ((*(unsigned short *) (data + addr) << 16) |
- *(unsigned short *) (data + addr + 2));
- } else if (RELOC_MEMORY_ADD_P(p)) {
- relocation += mask &
- ((*(unsigned short *) (data + addr) << 16) |
- *(unsigned short *) (data + addr + 2));
- }
- *(unsigned short *) (data + addr) &= (~mask >> 16);
- *(unsigned short *) (data + addr + 2) &= (~mask & 0xffff);
- *(unsigned short *) (data + addr) |= (relocation >> 16);
- *(unsigned short *) (data + addr + 2) |= (relocation & 0xffff);
-#endif
- break;
-
- default:
- fatal_with_file ("Unimplemented relocation field length in ", entry);
- }
- }
-}
-
-/* For relocatable_output only: write out the relocation,
- relocating the addresses-to-be-relocated. */
-
-void coptxtrel (), copdatrel ();
-
-void
-write_rel ()
-{
- register int i;
- register 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. */
-
- for (i = 0; i < TABSIZE; i++)
- {
- symbol *sp;
- for (sp = symtab[i]; sp; sp = sp->link)
- if (sp->referenced || sp->defined)
- {
- sp->def_count = count++;
- /* Leave room for the reference required by N_INDR, if
- necessary. */
- if ((sp->defined & ~N_EXT) == N_INDR)
- count++;
- }
- }
- /* Correct, because if (relocatable_output), we will also be writing
- whatever indirect blocks we have. */
- if (count != defined_global_sym_count
- + undefined_global_sym_count + global_indirect_count)
- fatal ("internal error");
-
- /* 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");
-}
-
-void
-coptxtrel (entry)
- struct file_entry *entry;
-{
- register struct relocation_info *p, *end;
- register int reloc = entry->text_start_address;
-
- p = entry->textrel;
- end = (struct relocation_info *) (entry->header.a_trsize + (char *) p);
- while (p < end)
- {
- RELOC_ADDRESS(p) += reloc;
- if (RELOC_EXTERN_P(p))
- {
- register int symindex = RELOC_SYMBOL(p) * sizeof (struct nlist);
- symbol *symptr = ((symbol *)
- (((struct nlist *)
- (((char *)entry->symbols) + symindex))
- ->n_un.n_name));
-
- if (symindex >= entry->header.a_syms)
- fatal_with_file ("relocation symbolnum out of range in ", entry);
-
-#ifdef N_INDR
- /* Resolve indirection. */
- if ((symptr->defined & ~N_EXT) == N_INDR)
- symptr = (symbol *) symptr->value;
-#endif
-
- /* If the symbol is now defined, change the external relocation
- to an internal one. */
-
- if (symptr->defined)
- {
- RELOC_EXTERN_P(p) = 0;
- RELOC_SYMBOL(p) = (symptr->defined & N_TYPE);
-#ifdef RELOC_ADD_EXTRA
- /* If we aren't going to be adding in the value in
- memory on the next pass of the loader, then we need
- to add it in from the relocation entry. Otherwise
- the work we did in this pass is lost. */
- if (!RELOC_MEMORY_ADD_P(p))
- RELOC_ADD_EXTRA (p) += symptr->value;
-#endif
- }
- else
- /* Debugger symbols come first, so have to start this
- after them. */
- RELOC_SYMBOL(p) = (symptr->def_count + nsyms
- - defined_global_sym_count
- - undefined_global_sym_count
- - global_indirect_count);
- }
- p++;
- }
- mywrite (entry->textrel, 1, entry->header.a_trsize, outdesc);
-}
-
-void
-copdatrel (entry)
- struct file_entry *entry;
-{
- register struct relocation_info *p, *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;
-
- p = entry->datarel;
- end = (struct relocation_info *) (entry->header.a_drsize + (char *) p);
- while (p < end)
- {
- RELOC_ADDRESS(p) += reloc;
- if (RELOC_EXTERN_P(p))
- {
- register int symindex = RELOC_SYMBOL(p) * sizeof (struct nlist);
- symbol *symptr = ((symbol *)
- (((struct nlist *)
- (((char *)entry->symbols) + symindex))
- ->n_un.n_name));
- int symtype;
-
- if (symindex >= entry->header.a_syms)
- fatal_with_file ("relocation symbolnum out of range in ", entry);
-
-#ifdef N_INDR
- /* Resolve indirection. */
- if ((symptr->defined & ~N_EXT) == N_INDR)
- symptr = (symbol *) symptr->value;
-#endif
-
- symtype = symptr->defined & N_TYPE;
-
- if (force_common_definition
- || symtype == N_DATA || symtype == N_TEXT || symtype == N_ABS)
- {
- RELOC_EXTERN_P(p) = 0;
- RELOC_SYMBOL(p) = symtype;
- }
- else
- /* Debugger symbols come first, so have to start this
- after them. */
- RELOC_SYMBOL(p)
- = (((symbol *)
- (((struct nlist *)
- (((char *)entry->symbols) + symindex))
- ->n_un.n_name))
- ->def_count
- + nsyms - defined_global_sym_count
- - undefined_global_sym_count
- - global_indirect_count);
- }
- p++;
- }
- mywrite (entry->datarel, 1, entry->header.a_drsize, outdesc);
-}
-
-void write_file_syms ();
-void write_string_table ();
-
-/* Offsets and current lengths of symbol and string tables in output file. */
-
-int symbol_table_offset;
-int symbol_table_len;
-
-/* Address in output file where string table starts. */
-int string_table_offset;
-
-/* Offset within string table
- where the strings in `strtab_vector' should be written. */
-int string_table_len;
-
-/* Total size of string table strings allocated so far,
- including strings in `strtab_vector'. */
-int strtab_size;
-
-/* Vector whose elements are strings to be added to the string table. */
-char **strtab_vector;
-
-/* Vector whose elements are the lengths of those strings. */
-int *strtab_lens;
-
-/* Index in `strtab_vector' at which the next string will be stored. */
-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. */
-
-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;
-}
-
-FILE *outstream = (FILE *) 0;
-
-/* 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;
-
- lseek (outdesc, string_table_offset + string_table_len, 0);
-
- if (!outstream)
- outstream = fdopen (outdesc, "w");
-
- for (i = 0; i < strtab_index; i++)
- {
- fwrite (strtab_vector[i], 1, strtab_lens[i], outstream);
- string_table_len += strtab_lens[i];
- }
-
- fflush (outstream);
-
- /* Report I/O error such as disk full. */
- if (ferror (outstream))
- perror_name (output_filename);
-}
-
-/* Write the symbol table and string table of the output file. */
-
-void
-write_syms ()
-{
- /* Number of symbols written so far. */
- int syms_written = 0;
- register int i;
- register symbol *sp;
-
- /* 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 ((defined_global_sym_count
- + undefined_global_sym_count
- + global_indirect_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;
-
- symbol_table_offset = N_SYMOFF (outheader);
- symbol_table_len = 0;
- string_table_offset = N_STROFF (outheader);
- string_table_len = strtab_size;
-
- if (strip_symbols == STRIP_ALL)
- return;
-
- /* Write the local symbols defined by the various files. */
-
- each_file (write_file_syms, &syms_written);
- file_close ();
-
- /* Now 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 ((num_hash_tab_syms
- + global_indirect_count) * sizeof (char *));
- strtab_lens = (int *) alloca ((num_hash_tab_syms
- + global_indirect_count) * sizeof (int));
- strtab_index = 0;
-
- /* Scan the symbol hash table, bucket by bucket. */
-
- for (i = 0; i < TABSIZE; i++)
- for (sp = symtab[i]; sp; sp = sp->link)
- {
- struct nlist nl;
-
- nl.n_other = 0;
- nl.n_desc = 0;
-
- /* Compute a `struct nlist' for the symbol. */
-
- if (sp->defined || sp->referenced)
- {
- /* common condition needs to be before undefined condition */
- /* because unallocated commons are set undefined in */
- /* digest_symbols */
- if (sp->defined > 1) /* defined with known type */
- {
- /* If the target of an indirect symbol has been
- defined and we are outputting an executable,
- resolve the indirection; it's no longer needed */
- if (!relocatable_output
- && ((sp->defined & N_TYPE) == N_INDR)
- && (((symbol *) sp->value)->defined > 1))
- {
- symbol *newsp = (symbol *) sp->value;
- nl.n_type = newsp->defined;
- nl.n_value = newsp->value;
- }
- else
- {
- nl.n_type = sp->defined;
- if (sp->defined != (N_INDR | N_EXT))
- nl.n_value = sp->value;
- else
- nl.n_value = 0;
- }
- }
- else if (sp->max_common_size) /* defined as common but not allocated. */
- {
- /* happens only with -r and not -d */
- /* write out a common definition */
- nl.n_type = N_UNDF | N_EXT;
- nl.n_value = sp->max_common_size;
- }
- else if (!sp->defined) /* undefined -- legit only if -r */
- {
- nl.n_type = N_UNDF | N_EXT;
- nl.n_value = 0;
- }
- else
- fatal ("internal error: %s defined in mysterious way", 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++;
- if (nl.n_type == (N_INDR | N_EXT))
- {
- struct nlist xtra_ref;
- xtra_ref.n_type = N_EXT | N_UNDF;
- xtra_ref.n_un.n_strx
- = assign_string_table_index (((symbol *) sp->value)->name);
- xtra_ref.n_other = 0;
- xtra_ref.n_desc = 0;
- xtra_ref.n_value = 0;
- *bufp++ = xtra_ref;
- syms_written++;
- }
- }
- }
-
- /* Output the buffer full of `struct nlist's. */
-
- lseek (outdesc, symbol_table_offset + symbol_table_len, 0);
- mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc);
- symbol_table_len += sizeof (struct nlist) * (bufp - buf);
-
- if (syms_written != nsyms)
- fatal ("internal error: wrong number of symbols written into output file", 0);
-
- if (symbol_table_offset + symbol_table_len != string_table_offset)
- fatal ("internal error: inconsistent symbol table length", 0);
-
- /* Now the total string table size is known, so write it.
- We are already positioned at the right place in the file. */
-
- mywrite (&strtab_size, sizeof (int), 1, outdesc); /* we're at right place */
-
- /* Write the strings for the global symbols. */
-
- write_string_table ();
-}
-
-/* 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;
-{
- register struct nlist *p = entry->symbols;
- register struct nlist *end = p + entry->header.a_syms / sizeof (struct nlist);
-
- /* 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 (entry->header.a_syms + sizeof (struct nlist));
- register struct nlist *bufp = buf;
-
- /* Upper bound on number of syms to be written here. */
- int max_syms = (entry->header.a_syms / sizeof (struct nlist)) + 1;
-
- /* 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)++;
- entry->local_syms_offset = *syms_written_addr * sizeof (struct nlist);
- }
-
- /* Read the file's string table. */
-
- entry->strings = (char *) alloca (entry->string_size);
- read_entry_strings (file_open (entry), entry);
-
- for (; p < end; p++)
- {
- register int type = p->n_type;
- register int write = 0;
-
- /* WRITE gets 1 for a non-global symbol that should be written. */
-
-
- if (SET_ELEMENT_P (type)) /* This occurs even if global. These */
- /* types of symbols are never written */
- /* globally, though they are stored */
- /* globally. */
- write = relocatable_output;
- else if (!(type & (N_STAB | N_EXT)))
- /* ordinary local symbol */
- write = ((discard_locals != DISCARD_ALL)
- && !(discard_locals == DISCARD_L &&
- (p->n_un.n_strx + entry->strings)[0] == LPREFIX)
- && type != N_WARNING);
- else if (!(type & N_EXT))
- /* debugger symbol */
- write = (strip_symbols == STRIP_NONE);
-
- if (write)
- {
- /* If this symbol has a name,
- allocate space for it in the output string table. */
-
- if (p->n_un.n_strx)
- p->n_un.n_strx = assign_string_table_index (p->n_un.n_strx
- + entry->strings);
-
- /* Output this symbol to the buffer and count it. */
-
- *bufp++ = *p;
- (*syms_written_addr)++;
- }
- }
-
- /* All the symbols are now in BUF; write them. */
-
- lseek (outdesc, symbol_table_offset + symbol_table_len, 0);
- mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc);
- symbol_table_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 dissapear anyway. */
-}
-
-/* Copy any GDB symbol segments from the input files to the output file.
- The contents of the symbol segment is copied without change
- except that we store some information into the beginning of it. */
-
-void write_file_symseg ();
-
-void
-write_symsegs ()
-{
- each_file (write_file_symseg, 0);
-}
-
-void
-write_file_symseg (entry)
- struct file_entry *entry;
-{
- char buffer[4096];
- struct symbol_root root;
- int indesc;
- int len;
-
- if (entry->symseg_offset == 0)
- return;
-
- /* This entry has a symbol segment. Read the root of the segment. */
-
- indesc = file_open (entry);
- lseek (indesc, entry->symseg_offset + entry->starting_offset, 0);
- if (sizeof root != read (indesc, &root, sizeof root))
- fatal_with_file ("premature end of file in symbol segment of ", entry);
-
- /* Store some relocation info into the root. */
-
- root.ldsymoff = entry->local_syms_offset;
- root.textrel = entry->text_start_address;
- root.datarel = entry->data_start_address - entry->header.a_text;
- root.bssrel = entry->bss_start_address
- - entry->header.a_text - entry->header.a_data;
- root.databeg = entry->data_start_address - root.datarel;
- root.bssbeg = entry->bss_start_address - root.bssrel;
-
- /* Write the modified root into the output file. */
-
- mywrite (&root, sizeof root, 1, outdesc);
-
- /* Copy the rest of the symbol segment unchanged. */
-
- if (entry->superfile)
- {
- /* Library member: number of bytes to copy is determined
- from the member's total size. */
-
- int total = entry->total_size - entry->symseg_offset - sizeof root;
-
- while (total > 0)
- {
- len = read (indesc, buffer, min (sizeof buffer, total));
-
- if (len != min (sizeof buffer, total))
- fatal_with_file ("premature end of file in symbol segment of ", entry);
- total -= len;
- mywrite (buffer, len, 1, outdesc);
- }
- }
- else
- {
- /* A separate file: copy until end of file. */
-
- while (len = read (indesc, buffer, sizeof buffer))
- {
- mywrite (buffer, len, 1, outdesc);
- if (len < sizeof buffer)
- break;
- }
- }
-
- file_close ();
-}
-
-/* Create the symbol table entries for `etext', `edata' and `end'. */
-
-void
-symtab_init ()
-{
-#ifndef nounderscore
- edata_symbol = getsym ("_edata");
- etext_symbol = getsym ("_etext");
- end_symbol = getsym ("_end");
-#else
- edata_symbol = getsym ("edata");
- etext_symbol = getsym ("etext");
- end_symbol = getsym ("end");
-#endif
-
-#ifdef sun
- {
- symbol *dynamic_symbol = getsym ("__DYNAMIC");
- dynamic_symbol->defined = N_ABS | N_EXT;
- dynamic_symbol->referenced = 1;
- dynamic_symbol->value = 0;
- }
-#endif
-
-#ifdef sequent
- {
- symbol *_387_flt_symbol = getsym ("_387_flt");
- _387_flt_symbol->defined = N_ABS | N_EXT;
- _387_flt_symbol->referenced = 1;
- _387_flt_symbol->value = 0;
- }
-#endif
-
- edata_symbol->defined = N_DATA | N_EXT;
- etext_symbol->defined = N_TEXT | N_EXT;
- end_symbol->defined = N_BSS | N_EXT;
-
- edata_symbol->referenced = 1;
- etext_symbol->referenced = 1;
- end_symbol->referenced = 1;
-}
-
-/* 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) % TABSIZE;
-
- /* Search the bucket. */
-
- for (bp = symtab[hashval]; bp; bp = bp->link)
- if (! strcmp (key, bp->name))
- return bp;
-
- /* Nothing was found; create a new symbol table entry. */
-
- bp = (symbol *) xmalloc (sizeof (symbol));
- bp->refs = 0;
- bp->name = (char *) xmalloc (strlen (key) + 1);
- strcpy (bp->name, key);
- bp->defined = 0;
- bp->referenced = 0;
- bp->trace = 0;
- bp->value = 0;
- bp->max_common_size = 0;
- bp->warning = 0;
- bp->undef_refs = 0;
- bp->multiply_defined = 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) % TABSIZE;
-
- /* Search the bucket. */
-
- for (bp = symtab[hashval]; bp; bp = bp->link)
- if (! strcmp (key, bp->name))
- return bp;
-
- return 0;
-}
-
-/* Report a fatal error.
- STRING is a printf format string and ARG is one arg for it. */
-
-void
-fatal (string, arg)
- char *string, *arg;
-{
- fprintf (stderr, "ld: ");
- fprintf (stderr, string, arg);
- fprintf (stderr, "\n");
- exit (1);
-}
-
-/* Report a fatal error. The error message is STRING
- followed by the filename of ENTRY. */
-
-void
-fatal_with_file (string, entry)
- char *string;
- struct file_entry *entry;
-{
- fprintf (stderr, "ld: ");
- fprintf (stderr, string);
- print_file_name (entry, stderr);
- fprintf (stderr, "\n");
- exit (1);
-}
-
-/* Report a fatal error using the message for the last failed system call,
- followed by the string NAME. */
-
-void
-perror_name (name)
- char *name;
-{
- extern int errno, sys_nerr;
- extern char *sys_errlist[];
- char *s;
-
- if (errno < sys_nerr)
- s = concat ("", sys_errlist[errno], " for %s");
- else
- s = "cannot open %s";
- fatal (s, name);
-}
-
-/* Report a fatal error using the message for the last failed system call,
- followed by the name of file ENTRY. */
-
-void
-perror_file (entry)
- struct file_entry *entry;
-{
- extern int errno, sys_nerr;
- extern char *sys_errlist[];
- char *s;
-
- if (errno < sys_nerr)
- s = concat ("", sys_errlist[errno], " for ");
- else
- s = "cannot open ";
- fatal_with_file (s, entry);
-}
-
-/* Report a nonfatal error.
- STRING is a format for printf, and ARG1 ... ARG3 are args for it. */
-
-void
-error (string, arg1, arg2, arg3)
- char *string, *arg1, *arg2, *arg3;
-{
- fprintf (stderr, "%s: ", progname);
- fprintf (stderr, string, arg1, arg2, arg3);
- fprintf (stderr, "\n");
-}
-
-
-/* Output COUNT*ELTSIZE bytes of data at BUF
- to the descriptor DESC. */
-
-void
-mywrite (buf, count, eltsize, desc)
- char *buf;
- int count;
- int eltsize;
- int desc;
-{
- register int val;
- register int bytes = count * eltsize;
-
- while (bytes > 0)
- {
- val = write (desc, buf, bytes);
- if (val <= 0)
- perror_name (output_filename);
- buf += val;
- bytes -= val;
- }
-}
-
-/* Output PADDING zero-bytes to descriptor OUTDESC.
- PADDING may be negative; in that case, do nothing. */
-
-void
-padfile (padding, outdesc)
- int padding;
- int outdesc;
-{
- register char *buf;
- if (padding <= 0)
- return;
-
- buf = (char *) alloca (padding);
- bzero (buf, padding);
- mywrite (buf, padding, 1, outdesc);
-}
-
-/* Return a newly-allocated string
- whose contents concatenate the strings S1, S2, S3. */
-
-char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- register int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
- register char *result = (char *) xmalloc (len1 + len2 + len3 + 1);
-
- strcpy (result, s1);
- strcpy (result + len1, s2);
- strcpy (result + len1 + len2, s3);
- result[len1 + len2 + len3] = 0;
-
- return result;
-}
-
-/* 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. */
-
-int
-parse (arg, format, error)
- char *arg, *format;
-{
- int x;
- if (1 != sscanf (arg, format, &x))
- fatal (error, arg);
- return x;
-}
-
-/* Like malloc but get fatal error if memory is exhausted. */
-
-int
-xmalloc (size)
- int size;
-{
- register int result = malloc (size);
- if (!result)
- fatal ("virtual memory exhausted", 0);
- return result;
-}
-
-/* Like realloc but get fatal error if memory is exhausted. */
-
-int
-xrealloc (ptr, size)
- char *ptr;
- int size;
-{
- register int result = realloc (ptr, size);
- if (!result)
- fatal ("virtual memory exhausted", 0);
- return result;
-}
-
-#ifdef USG
-
-void
-bzero (p, n)
- char *p;
-{
- memset (p, 0, n);
-}
-
-void
-bcopy (from, to, n)
- char *from, *to;
-{
- memcpy (to, from, n);
-}
-
-getpagesize ()
-{
- return (4096);
-}
-
-#endif
-
-#if defined(sun) && (TARGET == SUN4)
-
-/* Don't use local pagesize to build for Sparc. */
-
-getpagesize ()
-{
- return (8192);
-}
-#endif
diff --git a/gnu/usr.bin/ld/symseg.h b/gnu/usr.bin/ld/symseg.h
deleted file mode 100644
index fe9939f..0000000
--- a/gnu/usr.bin/ld/symseg.h
+++ /dev/null
@@ -1,358 +0,0 @@
-/*-
- *
- * This code is derived from software copyrighted by the Free Software
- * Foundation.
- *
- * @(#)symseg.h 5.4 (Berkeley) 4/30/91
- */
-
-/* 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/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 0e7e506..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 whatis 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 c0df250..0000000
--- a/gnu/usr.bin/man/Makefile.inc
+++ /dev/null
@@ -1,34 +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 -cs
-manpath_config_file= /etc/manpath.config
-troff= /usr/bin/groff -Tps -man
-nroff= /usr/bin/groff -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
-
-# For scripts.
-.if !target(obj)
-obj:
- @cd ${.CURDIR}; rm -rf obj; \
- here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
- echo "$$here -> $$dest"; ln -s $$dest obj; \
- if test -d /usr/obj -a ! -d $$dest; then \
- mkdir -p $$dest; \
- else \
- true; \
- fi;
-.endif
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 6208d5e..0000000
--- a/gnu/usr.bin/man/apropos/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
-.if exists(${.CURDIR}/obj)
-MANP= ${.CURDIR}/obj/apropos.1
-TARG= ${.CURDIR}/obj/apropos
-.else
-MANP= ${.CURDIR}/apropos.1
-TARG= ${.CURDIR}/apropos
-.endif
-
-all: ${TARG} ${MANP}
-
-depend rcsfreeze tags all:
- @echo -n
-
-cleandir: clean
- cd ${.CURDIR}; rm -rf obj;
-
-clean:
- @rm -f ${TARG} ${MANP}
-
-${TARG}: ${.CURDIR}/apropos.sh
- sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
- -e 's,%pager%,${pager},' \
- ${.CURDIR}/apropos.sh > $@
-
-${MANP}: ${.CURDIR}/apropos.man
- 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}/apropos.man > $@
-
-install: ${TARG} maninstall
- install -c -o bin -g bin -m 555 ${TARG} ${DESTDIR}/usr/bin
-
-maninstall: ${MANP}
- install -c -o bin -g bin -m 444 ${MANP} ${DESTDIR}/usr/share/man/man1
-
-.include "../Makefile.inc"
diff --git a/gnu/usr.bin/man/apropos/apropos b/gnu/usr.bin/man/apropos/apropos
deleted file mode 100644
index 8735e5f..0000000
--- a/gnu/usr.bin/man/apropos/apropos
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/sh
-#
-# apropos -- search the whatis database for keywords.
-#
-# 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
-
-PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
-
-libdir=/etc
-
-if [ $# = 0 ]
-then
- echo "usage: `basename $0` keyword ..."
- exit 1
-fi
-
-manpath=`/usr/bin/manpath -q | tr : '\040'`
-
-if [ "$manpath" = "" ]
-then
- echo "whatis: manpath is null"
- exit 1
-fi
-
-if [ "$PAGER" = "" ]
-then
- PAGER="/usr/gnu/bin/less -sC"
-fi
-
-while [ $1 ]
-do
- found=0
- for d in $manpath /usr/lib
- do
- if [ -f $d/whatis ]
- then
- grep -i "$1" $d/whatis
- status=$?
- if [ "$status" = "0" ]
- then
- found=1
- fi
- fi
- done
-
- if [ "$found" = "0" ]
- then
- echo "$1: nothing appropriate"
- fi
-
- shift
-done | $PAGER
-
-exit
diff --git a/gnu/usr.bin/man/apropos/apropos.1 b/gnu/usr.bin/man/apropos/apropos.1
deleted file mode 100644
index 3bb3e17..0000000
--- a/gnu/usr.bin/man/apropos/apropos.1
+++ /dev/null
@@ -1,27 +0,0 @@
-.\" Man page for apropos
-.\"
-.\" 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
-.\"
-.TH apropos 1 "Jan 15, 1991"
-.LO 1
-.SH NAME
-apropos \- search the whatis database for strings
-.SH SYNOPSIS
-.BI apropos
-keyword ...
-.SH DESCRIPTION
-apropos searches a set of database files containing short descriptions
-of system commands for keywords and displays the result on the
-standard output.
-.SH "SEE ALSO"
-whatis(1), man(1).
diff --git a/gnu/usr.bin/man/apropos/apropos.man b/gnu/usr.bin/man/apropos/apropos.man
deleted file mode 100644
index 3bb3e17..0000000
--- a/gnu/usr.bin/man/apropos/apropos.man
+++ /dev/null
@@ -1,27 +0,0 @@
-.\" Man page for apropos
-.\"
-.\" 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
-.\"
-.TH apropos 1 "Jan 15, 1991"
-.LO 1
-.SH NAME
-apropos \- search the whatis database for strings
-.SH SYNOPSIS
-.BI apropos
-keyword ...
-.SH DESCRIPTION
-apropos searches a set of database files containing short descriptions
-of system commands for keywords and displays the result on the
-standard output.
-.SH "SEE ALSO"
-whatis(1), man(1).
diff --git a/gnu/usr.bin/man/apropos/apropos.sh b/gnu/usr.bin/man/apropos/apropos.sh
deleted file mode 100644
index 070b848..0000000
--- a/gnu/usr.bin/man/apropos/apropos.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/sh
-#
-# apropos -- search the whatis database for keywords.
-#
-# 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
-
-PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
-
-libdir=%libdir%
-
-if [ $# = 0 ]
-then
- echo "usage: `basename $0` keyword ..."
- exit 1
-fi
-
-manpath=`%bindir%/manpath -q | tr : '\040'`
-
-if [ "$manpath" = "" ]
-then
- echo "whatis: manpath is null"
- exit 1
-fi
-
-if [ "$PAGER" = "" ]
-then
- PAGER="%pager%"
-fi
-
-while [ $1 ]
-do
- found=0
- for d in $manpath /usr/lib
- do
- if [ -f $d/whatis ]
- then
- grep -i "$1" $d/whatis
- status=$?
- if [ "$status" = "0" ]
- then
- found=1
- fi
- fi
- done
-
- if [ "$found" = "0" ]
- then
- echo "$1: nothing appropriate"
- fi
-
- shift
-done | $PAGER
-
-exit
diff --git a/gnu/usr.bin/man/catman/Makefile b/gnu/usr.bin/man/catman/Makefile
deleted file mode 100644
index 3592877..0000000
--- a/gnu/usr.bin/man/catman/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-obj cleandir clean depend rcsfreeze tags all:
- @echo -n
-
-install:
- install -c -o bin -g bin -m 555 catman ${DESTDIR}/usr/bin
-
-.include "../Makefile.inc"
diff --git a/gnu/usr.bin/man/catman/catman b/gnu/usr.bin/man/catman/catman
deleted file mode 100644
index a2d16a1..0000000
--- a/gnu/usr.bin/man/catman/catman
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-# usage: sh catman
-# put the section numbers here:
-SECTIONS="1 2 3 4 5 6 7 8"
-MANDIR=/usr/share/man
-
-formatman()
-{
- echo " "$1 "->" $*
- (cd cat$section; rm -f $*)
- nroff -man < man$section/$1 > cat$section/$1
- catfile=$1; shift
- while [ $# -gt 0 ]
- do
- ln cat$section/$catfile cat$section/$1
- shift
- done
-}
-
-cd $MANDIR
-for section in $SECTIONS
-do
- echo formatting section $section ...
-
- IFS=" "
- allfiles=`ls -i1 man$section | sort | awk '{if (inode ~ $1) printf "/" $2;
- else printf " " $2; inode = $1 } END {printf "\n"}'`
- for files in $allfiles
- do
- IFS="/"
- tfiles=`echo $files`
- IFS=" "
- formatman $tfiles
- done
-done
-exit 0
diff --git a/gnu/usr.bin/man/lib/Makefile b/gnu/usr.bin/man/lib/Makefile
deleted file mode 100644
index d364b32..0000000
--- a/gnu/usr.bin/man/lib/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-LIB = man
-
-.if exists(${.CURDIR}/obj)
-CONFH= ${.CURDIR}/obj/config.h
-.else
-CONFH= ${.CURDIR}/config.h
-.endif
-
-
-CFLAGS+= -I${.CURDIR} -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS -DALT_SYSTEMS
-CLEANFILES+= ${CONFH}
-SRCS = util.c gripes.c
-
-libman.a:: ${CONFH}
-
-install:
- @echo -n
-
-depend ${CONFH}: ${.CURDIR}/config.h_dist ../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},' \
- ${.CURDIR}/config.h_dist > ${CONFH}
-
-.include <bsd.lib.mk>
diff --git a/gnu/usr.bin/man/lib/config.h b/gnu/usr.bin/man/lib/config.h
deleted file mode 100644
index 2c23168..0000000
--- a/gnu/usr.bin/man/lib/config.h
+++ /dev/null
@@ -1,216 +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
- */
-
-#ifdef COMPRESS
-#define DO_COMPRESS
-#define DO_UNCOMPRESS
-#endif
-
-/*
- * 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 "/usr/bin/apropos"
-#endif
-
-#ifndef WHATIS
-#define WHATIS "/usr/bin/whatis"
-#endif
-
-#ifndef PAGER
-#define PAGER "/usr/gnu/bin/less -sC"
-#endif
-
-#ifdef HAS_TROFF
-#ifndef TROFF
-#define TROFF "/usr/bin/groff -Tps -man"
-#endif
-#endif
-
-#ifndef NROFF
-#define NROFF "/usr/bin/groff -Tascii -man"
-#endif
-
-#ifndef EQN
-#define EQN "/usr/bin/eqn -Tps"
-#endif
-
-#ifndef NEQN
-#define NEQN "/usr/bin/eqn -Tascii"
-#endif
-
-#ifndef TBL
-#define TBL "/usr/bin/tbl"
-#endif
-
-#ifndef COL
-#define COL "/usr/bin/col"
-#endif
-
-#ifndef VGRIND
-#define VGRIND "/usr/bin/vgrind"
-#endif
-
-#ifndef REFER
-#define REFER "/usr/bin/refer"
-#endif
-
-#ifndef GRAP
-#define GRAP ""
-#endif
-
-#ifndef PIC
-#define PIC "/usr/bin/pic"
-#endif
-
-/*
- * Define the absolute path to the configuration file.
- */
-#ifndef MAN_MAIN
- static char config_file[] = "/etc/manpath.config";
-#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.
- */
-#ifdef DO_UNCOMPRESS
-/* .F files */
-#define FCAT ""
-/* .Y files */
-#define YCAT ""
-/* .Z files */
-#define ZCAT "/usr/bin/zcat"
-#endif
-
-/*
- * 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.
- */
-#ifdef DO_COMPRESS
-#define COMPRESSOR ""
-#define COMPRESS_EXT ""
-#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", "n", "l", "6", "8", "2", "3", "4", "5", "7", "p", "o", 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/config.h_dist b/gnu/usr.bin/man/lib/config.h_dist
deleted file mode 100644
index 74122df..0000000
--- a/gnu/usr.bin/man/lib/config.h_dist
+++ /dev/null
@@ -1,216 +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
- */
-
-#ifdef COMPRESS
-#define DO_COMPRESS
-#define DO_UNCOMPRESS
-#endif
-
-/*
- * 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.
- */
-#ifdef DO_UNCOMPRESS
-/* .F files */
-#define FCAT ""
-/* .Y files */
-#define YCAT ""
-/* .Z files */
-#define ZCAT "%zcat%"
-#endif
-
-/*
- * 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.
- */
-#ifdef DO_COMPRESS
-#define COMPRESSOR ""
-#define COMPRESS_EXT ""
-#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", "n", "l", "6", "8", "2", "3", "4", "5", "7", "p", "o", 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 76f8e70..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 e3be4a0..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 b0babed..0000000
--- a/gnu/usr.bin/man/lib/util.c
+++ /dev/null
@@ -1,150 +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>
-
-#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);
- }
-}
-
-/*
- * 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);
-
- /*
- * Ultrix returns 127 for failure. Is this normal?
- */
- if (status == 127)
- {
- 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 dca3e15..0000000
--- a/gnu/usr.bin/man/makewhatis/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-.if exists(${.CURDIR}/obj)
-TARG= ${.CURDIR}/obj/makewhatis
-.else
-TARG= ${.CURDIR}/makewhatis
-.endif
-
-all: ${TARG}
-
-depend rcsfreeze tags all:
- @echo -n
-
-cleandir: clean
- cd ${.CURDIR}; rm -rf obj;
-
-clean:
- @rm -f ${TARG}
-
-install:
- install -c -o bin -g bin -m 555 ${TARG} ${DESTDIR}/usr/bin
-
-${TARG}: ${.CURDIR}/makewhatis.sh
- sed -e 's/%sections%/ "1", "n", "l", "6", "8", "2", "3", "4", "5", "7", "p", "o", NULL/' ${.CURDIR}/makewhatis.sh > ${TARG}
-
-.include "../Makefile.inc"
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis b/gnu/usr.bin/man/makewhatis/makewhatis
deleted file mode 100644
index e6c238c..0000000
--- a/gnu/usr.bin/man/makewhatis/makewhatis
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/sh
-#
-# makewhatis -- update the whatis database in the man directories.
-#
-# 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
-
-PATH=/bin:/usr/local/bin:/usr/ucb:/usr/bin
-
-if [ $# = 0 ]
-then
- echo "usage: makewhatis directory [...]"
- exit 1
-fi
-
-for dir in $*
-do
- cd $dir
- for subdir in man*
- do
- if [ -d $subdir ]
- then
- for f in `find . -name '*' -print`
- do
- sed -n '/^\.TH.*$/p
- /^\.SH[ ]*NAME/,/^\.SH/p' $f |\
- sed -e 's/\\[ ]*\-/-/
- s/^.PP.*$//
- s/\\(em//
- s/\\fI//
- s/\\fR//' |\
- awk 'BEGIN {insh = 0} {
- if ($1 == ".TH")
- sect = $3
- else if ($1 == ".SH" && insh == 1) {
- if (i > 0 && name != NULL) {
- namesect = sprintf("%s (%s)", name, sect)
- printf("%-20.20s", namesect)
- printf(" - ")
- for (j = 0; j < i-1; j++)
- printf("%s ", desc[j])
- printf("%s\n", desc[i-1])
- }
- } else if ($1 == ".SH" && insh == 0) {
- insh = 1
- count = 0
- i = 0
- } else if (insh == 1) {
- count++
- if (count == 1 && NF > 2) {
- start = 2
- if ($2 == "-") start = 3
- if (NF > start + 1)
- for (j = start; j <= NF; j++)
- desc[i++] = $j
- name = $1
- } else {
- for (j = 1; j <= NF; j++)
- desc[i++] = $j
- }
- }
- }'
- done
- cd ..
- fi
- done | sort | colrm 80 > $dir/whatis.db.tmp
- mv $dir/whatis.db.tmp $dir/whatis
-done
-
-exit
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.sh b/gnu/usr.bin/man/makewhatis/makewhatis.sh
deleted file mode 100644
index 1d86d19..0000000
--- a/gnu/usr.bin/man/makewhatis/makewhatis.sh
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/bin/sh
-#
-# makewhatis -- update the whatis database in the man directories.
-#
-# 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
-
-PATH=/bin:/usr/local/bin:/usr/ucb:/usr/bin
-
-if [ $# = 0 ]
-then
- echo "usage: makewhatis directory [...]"
- exit 1
-fi
-for dir in $*
-do
- cd $dir
- for subdir in man*
- do
- if [ -d $subdir ]
- then
- for f in `find $subdir -type f -print`
- do
- sed -n '/^\.TH.*$/p
- /^\.Dt.*$/p
- /^\.S[hH][ ]*NAME/,/^\.S[hH]/p' $f |\
- sed -e 's/\\[ ]*\-/-/
- s/^.P[Pp].*$//
- s/\\(em//
- s/\\fI//
- s/\\fR//' |\
- awk 'BEGIN {insh = 0; inSh = 0; Nd = 0} {
- if ($1 == ".TH" || $1 == ".Dt")
- sect = $3
- else if (($1 == ".br" && insh == 1)\
- || ($1 == ".SH" && insh == 1)\
- || ($1 == ".Sh" && inSh == 1)) {
- if (i > 0 && nc > 0) {
- for (k= 1; k <= nc; k++) {
- namesect = sprintf("%s (%s)", name[k], sect)
- printf("%s", namesect)
- printf(" - ")
- for (j = 0; j < i-1; j++)
- printf("%s ", desc[j])
- printf("%s\n", desc[i-1])
- }
- }
- count = 0
- i = 0
- nc = 0
- } else if ($1 == ".SH" && insh == 0) {
- insh = 1
- count = 0
- i = 0
- nc = 0
- } else if ($1 == ".Sh" && inSh == 0) {
- inSh = 1
- i = 0
- nc = 0
- } else if (insh == 1) {
- count++
- if (count == 1 && NF > 2) {
- start = 2
- for (k = 1; k <= NF; k++)
- if ($k == "-") {
- start = k + 1
- break
- } else {
- sub(",","",$k)
- if ($k != "")
- name[++nc] = $k
- }
- if (NF >= start)
- for (j = start; j <= NF; j++)
- desc[i++] = $j
- } else {
- for (j = 1; j <= NF; j++)
- desc[i++] = $j
- }
- } else if ($1 == ".Nm" && inSh == 1 && Nd == 0) {
- for (k = 2; k <= NF; k++) {
- sub(",","",$k)
- if ($k != "")
- name[++nc] = $k
- }
- } else if ($1 == ".Nd" && inSh == 1) {
- Nd = 1
- for (j = 2; j <= NF; j++)
- desc[i++] = $j
- } else if (Nd == 1) {
- start = 1
- if ($1 ~ /\..*/)
- start = 2
- for (j = start; j <= NF; j++)
- desc[i++] = $j
- }
- }'
- done
- fi
- done | sort | colrm 80 | uniq > $dir/whatis.db.tmp
- mv $dir/whatis.db.tmp $dir/whatis
-done
-
-exit
diff --git a/gnu/usr.bin/man/man/Makefile b/gnu/usr.bin/man/man/Makefile
deleted file mode 100644
index c00976b..0000000
--- a/gnu/usr.bin/man/man/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-PROG= man
-SRCS= man.c manpath.c glob.c
-BINMODE=6555
-
-.if exists(${.CURDIR}/../lib/obj)
-LDADD= -L${.CURDIR}/../lib/obj -lman
-CFLAGS+= -I${.CURDIR}/../lib/obj
-.else
-LDADD= -L${.CURDIR}/../lib/ -lman
-.endif
-
-.if exists(${.CURDIR}/obj)
-MAN1= ${.CURDIR}/obj/man.1
-.else
-MAN1= ${.CURDIR}/man.1
-.endif
-
-DPADD+= ${MAN1}
-CFLAGS+= -I${.CURDIR}/../lib -DSTDC_HEADERS -DPOSIX -DHAS_TROFF
-CFLAGS+= -DDO_UNCOMPRESS -DALT_SYSTEMS -DSETREUID -DCATMODE=0664
-CLEANFILES+= ${MAN1}
-
-${MAN1}: ${.CURDIR}/man.man
- 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}/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 5bfb1bf..0000000
--- a/gnu/usr.bin/man/man/glob.c
+++ /dev/null
@@ -1,680 +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 ();
-
-/* 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;
-
- 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')
- return 0; /* Missing ']'. */
-
- c = *p++;
-
- if (c == '-')
- {
- cend = *p++;
- if (cend == '\\')
- cend = *p++;
- if (cend == '\0')
- return 0;
- c = *p++;
- }
- if (c1 >= cstart && c1 <= cend)
- 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;
- 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.1 b/gnu/usr.bin/man/man/man.1
deleted file mode 100644
index f17aced..0000000
--- a/gnu/usr.bin/man/man/man.1
+++ /dev/null
@@ -1,132 +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
-.\"
-.TH man 1 "Jan 5, 1991"
-.LO 1
-.SH NAME
-man \- format and display the on-line manual pages
-.SH SYNOPSIS
-man [\-adfhktw] [\-m system] [\-p string] [\-M path] [\-P pager]
-[\-S list] [section] name ...
-.SH DESCRIPTION
-man formats and displays the on-line manual pages. This version knows
-about the MANPATH and 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.
-.SH OPTIONS
-.TP
-.B \-\^M " path"
-Specify an alternate manpath. By default, man uses
-.B manpath
-to determine the path to search. This option overrides the
-.B MANPATH
-environment variable.
-.TP
-.B \-\^P " pager"
-Specify which pager to use. By default, man uses
-.B /usr/local/bin/less -sC,
-This option overrides the
-.B PAGER
-environment variable.
-.TP
-.B \-\^S " list"
-List is a colon separated list of manual sections to search.
-This option overrides the
-.B MANSECT
-environment variable.
-.TP
-.B \-\^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
-.B name,
-not just the first.
-.TP
-.B \-\^d
-Don't actually display the man pages, but do print gobs of debugging
-information.
-.TP
-.B \-\^f
-Equivalent to
-.B whatis.
-.TP
-.B \-\^h
-Print a one line help message and exit.
-.TP
-.B \-\^k
-Equivalent to
-.B apropos.
-.TP
-.B \-\^m " system"
-Specify an alternate set of man pages to search based on the system
-name given.
-.TP
-.B \-\^p " 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
-.B MANROFFSEQ
-environment variable.
-.TP
-.B \-\^t
-Use
-.B /usr/bin/groff -Tps -man
-to format the manual page, passing the output to
-.B stdout.
-The output from
-.B /usr/bin/groff -Tps -man
-may need to be passed through some filter or another before being
-printed.
-.TP
-.B \-\^w
-Don't actually display the man pages, but do print the location(s) of
-the files that would be formatted or displayed.
-.SH ENVIRONMENT
-.TP \w'MANROFFSEQ\ \ 'u
-.B MANPATH
-If
-.B MANPATH
-is set, its value is used as the path to search for manual pages.
-.TP
-.B MANROFFSEQ
-If
-.B 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.
-.TP
-.B MANSEC
-If
-.B MANSEC
-is set, its value is used to determine which manual sections to search.
-.TP
-.B PAGER
-If
-.B PAGER
-is set, its value is used as the name of the program to use to display
-the man page. By default,
-.B /usr/local/bin/less -sC
-is used.
-.SH "SEE ALSO"
-apropos(1), whatis(1), manpath(1), less(1), groff(1).
-.SH BUGS
-The
-.B \-t
-option only works if a troff-like program is installed.
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c
deleted file mode 100644
index 3b6e2bf..0000000
--- a/gnu/usr.bin/man/man/man.c
+++ /dev/null
@@ -1,1431 +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/types.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/file.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 *strdup ();
-
-extern char **glob_vector ();
-extern char **glob_filename ();
-extern int access ();
-extern int unlink ();
-extern int system ();
-extern int chmod ();
-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]);
-
- 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);
- else if (whatis)
- do_whatis (nextarg);
- else
- {
- status = man (nextarg);
-
- if (status == 0)
- gripe_not_found (nextarg, section);
- }
- }
- return status;
-}
-
-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)
- {
- fprintf (stderr, "Warning: couldn't stat file %s!\n", p);
- }
- else if (status == 0)
- {
- 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);
- 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 ((end = strchr (p, ':')) != NULL)
- *end = '\0';
-
-#ifdef ALT_SYSTEMS
- if (alt_system)
- {
- char buf[BUFSIZ];
-
- if (debug)
- fprintf (stderr, "Alternate system `%s' specified\n",
- alt_system_name);
-
- strcpy (buf, p);
- strcat (buf, "/");
- strcat (buf, 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) == NULL) || (isdigit (name[0])))
- 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 len = strlen (name) + 3;
- to_name = (char *) malloc (len);
- if (to_name == NULL)
- gripe_alloc (len, "to_name");
- strcpy (to_name, name);
- strcat (to_name, ".Z");
- }
- else
- to_name = strdup (name);
-#else
- to_name = strdup (name);
-#endif
-
- t1 = strrchr (to_name, '/');
- if (t1 != NULL)
- {
- *t1 = NULL;
- 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[BUFSIZ];
- char **gf;
-
- if (cat)
- sprintf (pathname, "%s/cat%s/%s.%s*", path, section, name, section);
- else
- sprintf (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)
- sprintf (pathname, "%s/cat%s/%s.%c*", path, section, name, *section);
- else
- sprintf (pathname, "%s/man%s/%s.%c*", path, section, name, *section);
-
- gf = glob_filename (pathname);
- }
- if ((gf == (char **) -1 || *gf == NULL) && isdigit (*section))
- {
- if (cat)
- sprintf (pathname, "%s/cat%s/%s.0*", path, section, name);
- else
- sprintf (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[BUFSIZ];
-
- if (cat)
- sprintf (buf, "%s/cat%s/%s.%s", path, section, name, section);
- else
- sprintf (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)
- sprintf (buf, "%s/cat%c/%s.%s", path, section[0], name, section);
- else
- sprintf (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];
-}
-
-#ifdef DO_UNCOMPRESS
-char *
-get_expander (file)
- char *file;
-{
- char *expander = NULL;
- int len = strlen (file);
-
- if (file[len - 2] == '.')
- {
- switch (file[len - 1])
- {
-#ifdef FCAT
- case 'F':
- if (strcmp (FCAT, "") != 0)
- expander = strdup (FCAT);
- break;
-#endif
-#ifdef YCAT
- case 'Y':
- if (strcmp (YCAT, "") != 0)
- expander = strdup (YCAT);
- break;
-#endif
-#ifdef ZCAT
- case 'Z':
- if (strcmp (ZCAT, "") != 0)
- expander = strdup (ZCAT);
- break;
-#endif
- default:
- break;
- }
- }
- return expander;
-}
-#endif
-
-/*
- * Simply display the preformatted page.
- */
-int
-display_cat_file (file)
- register char *file;
-{
- register int found;
- char command[BUFSIZ];
-
- found = 0;
-
- if (access (file, R_OK) == 0)
- {
-#ifdef DO_UNCOMPRESS
- char *expander = get_expander (file);
-
- if (expander != NULL)
- sprintf (command, "%s %s | %s", expander, file, pager);
- else
- sprintf (command, "%s %s", pager, file);
-#else
- sprintf (command, "%s %s", pager, file);
-#endif
-
- 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[BUFSIZ];
-
- FILE *fp;
- char *beg;
- char *end;
-
- strcpy (ult, name);
- strcpy (buf, name);
-
- next:
-
- if ((fp = fopen (ult, "r")) == NULL)
- return buf;
-
- if (fgets (buf, BUFSIZ, fp) == NULL)
- return ult;
-
- if (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';
-
- strcpy (ult, path);
- strcat (ult, "/");
- strcat (ult, beg);
-
- strcpy (buf, ult);
-
- goto next;
- }
-
- if (debug)
- fprintf (stderr, "found ultimate source file %s\n", ult);
-
- return ult;
-}
-
-void
-add_directive (first, d, file, buf)
- int *first;
- char *d;
- char *file;
- char *buf;
-{
- if (strcmp (d, "") != 0)
- {
- if (*first)
- {
- *first = 0;
- strcpy (buf, d);
- strcat (buf, " ");
- strcat (buf, file);
- }
- else
- {
- strcat (buf, " | ");
- strcat (buf, d);
- }
- }
-}
-
-int
-parse_roff_directive (cp, file, buf)
- char *cp;
- char *file;
- char *buf;
-{
- 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);
- else
- add_directive (&first, NEQN, file, buf);
-
- break;
-
- case 'g':
-
- if (debug)
- fprintf (stderr, "found grap(1) directive\n");
-
- add_directive (&first, GRAP, file, buf);
-
- break;
-
- case 'p':
-
- if (debug)
- fprintf (stderr, "found pic(1) directive\n");
-
- add_directive (&first, PIC, file, buf);
-
- break;
-
- case 't':
-
- if (debug)
- fprintf (stderr, "found tbl(1) directive\n");
-
- tbl_found++;
- add_directive (&first, TBL, file, buf);
- break;
-
- case 'v':
-
- if (debug)
- fprintf (stderr, "found vgrind(1) directive\n");
-
- add_directive (&first, VGRIND, file, buf);
- break;
-
- case 'r':
-
- if (debug)
- fprintf (stderr, "found refer(1) directive\n");
-
- add_directive (&first, REFER, file, buf);
- break;
-
- case ' ':
- case '\t':
- case '\n':
-
- goto done;
-
- default:
-
- return -1;
- }
- }
-
- done:
-
- if (first)
- return 1;
-
-#ifdef HAS_TROFF
- if (troff)
- {
- strcat (buf, " | ");
- strcat (buf, TROFF);
- }
- else
-#endif
- {
- strcat (buf, " | ");
- strcat (buf, NROFF);
- }
-
- if (tbl_found && !troff && strcmp (COL, "") != 0)
- {
- strcat (buf, " | ");
- strcat (buf, COL);
- }
-
- 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);
-
- 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, 100, fp);
- if (*cp++ == '\'' && *cp++ == '\\' && *cp++ == '"' && *cp++ == ' ')
- {
- if (debug)
- fprintf (stderr, "parsing directive from file\n");
-
- status = parse_roff_directive (cp, file, buf);
-
- fclose (fp);
-
- 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);
-
- if (status == 0)
- return buf;
-
- if (status == -1)
- gripe_roff_command_from_env ();
- }
-
- if (debug)
- fprintf (stderr, "using default preprocessor sequence\n");
-
-#ifdef HAS_TROFF
- if (troff)
- {
- if (strcmp (TBL, "") != 0)
- {
- strcpy (buf, TBL);
- strcat (buf, " ");
- strcat (buf, file);
- strcat (buf, " | ");
- strcat (buf, TROFF);
- }
- else
- {
- strcpy (buf, TROFF);
- strcat (buf, " ");
- strcat (buf, file);
- }
- }
- else
-#endif
- {
- if (strcmp (TBL, "") != 0)
- {
- strcpy (buf, TBL);
- strcat (buf, " ");
- strcat (buf, file);
- strcat (buf, " | ");
- strcat (buf, NROFF);
- }
- else
- {
- strcpy (buf, NROFF);
- strcat (buf, " ");
- strcat (buf, file);
- }
-
- if (strcmp (COL, "") != 0)
- {
- strcat (buf, " | ");
- strcat (buf, COL);
- }
- }
- return buf;
-}
-
-/*
- * 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)
- register char *path;
- register char *man_file;
- register char *cat_file;
-{
- int status;
- int mode;
- FILE *fp;
- char *roff_command;
- char command[BUFSIZ];
-
- if ((fp = fopen (cat_file, "w")) != NULL)
- {
- fclose (fp);
- unlink (cat_file);
-
- roff_command = make_roff_command (man_file);
- if (roff_command == NULL)
- return 0;
- else
-#ifdef DO_COMPRESS
- sprintf (command, "(cd %s ; %s | %s > %s)", path,
- roff_command, COMPRESSOR, cat_file);
-#else
- sprintf (command, "(cd %s ; %s > %s)", path,
- roff_command, cat_file);
-#endif
- /*
- * Don't let the user interrupt the system () call and screw up
- * the formmatted man page if we're not done yet.
- */
- signal (SIGINT, SIG_IGN);
-
- fprintf (stderr, "Formatting page, please wait...\n");
-
- status = do_system_command (command);
-
- if (status == 1)
- {
- mode = CATMODE;
- chmod (cat_file, mode);
-
- if (debug)
- fprintf (stderr, "mode of %s is now %o\n", cat_file, mode);
- }
-
- signal (SIGINT, SIG_DFL);
-
- return 1;
- }
- else
- {
- if (debug)
- fprintf (stderr, "Couldn't open %s for writing.\n", cat_file);
-
- 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[BUFSIZ];
-
- 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
- sprintf (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");
-
- 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);
-#endif
-
- found = make_cat_file (path, man_file, cat_file);
-
-#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);
- }
-#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);
- }
-#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
- sprintf (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 = 0;
-
- 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;
- static char *tmp_section_list[100];
-
- 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; ; 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 2c034fe..0000000
--- a/gnu/usr.bin/man/man/man.man
+++ /dev/null
@@ -1,132 +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
-.\"
-.TH man 1 "Jan 5, 1991"
-.LO 1
-.SH NAME
-man \- format and display the on-line manual pages
-.SH SYNOPSIS
-man [\-adfhktw] [\-m system] [\-p string] [\-M path] [\-P pager]
-[\-S list] [section] name ...
-.SH DESCRIPTION
-man formats and displays the on-line manual pages. This version knows
-about the MANPATH and 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.
-.SH OPTIONS
-.TP
-.B \-\^M " path"
-Specify an alternate manpath. By default, man uses
-.B manpath
-to determine the path to search. This option overrides the
-.B MANPATH
-environment variable.
-.TP
-.B \-\^P " pager"
-Specify which pager to use. By default, man uses
-.B %pager%,
-This option overrides the
-.B PAGER
-environment variable.
-.TP
-.B \-\^S " list"
-List is a colon separated list of manual sections to search.
-This option overrides the
-.B MANSECT
-environment variable.
-.TP
-.B \-\^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
-.B name,
-not just the first.
-.TP
-.B \-\^d
-Don't actually display the man pages, but do print gobs of debugging
-information.
-.TP
-.B \-\^f
-Equivalent to
-.B whatis.
-.TP
-.B \-\^h
-Print a one line help message and exit.
-.TP
-.B \-\^k
-Equivalent to
-.B apropos.
-.TP
-.B \-\^m " system"
-Specify an alternate set of man pages to search based on the system
-name given.
-.TP
-.B \-\^p " 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
-.B MANROFFSEQ
-environment variable.
-.TP
-.B \-\^t
-Use
-.B %troff%
-to format the manual page, passing the output to
-.B stdout.
-The output from
-.B %troff%
-may need to be passed through some filter or another before being
-printed.
-.TP
-.B \-\^w
-Don't actually display the man pages, but do print the location(s) of
-the files that would be formatted or displayed.
-.SH ENVIRONMENT
-.TP \w'MANROFFSEQ\ \ 'u
-.B MANPATH
-If
-.B MANPATH
-is set, its value is used as the path to search for manual pages.
-.TP
-.B MANROFFSEQ
-If
-.B 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.
-.TP
-.B MANSEC
-If
-.B MANSEC
-is set, its value is used to determine which manual sections to search.
-.TP
-.B PAGER
-If
-.B PAGER
-is set, its value is used as the name of the program to use to display
-the man page. By default,
-.B %pager%
-is used.
-.SH "SEE ALSO"
-apropos(1), whatis(1), manpath(1), less(1), groff(1).
-.SH BUGS
-The
-.B \-t
-option only works if a troff-like program is installed.
diff --git a/gnu/usr.bin/man/man/manpath.c b/gnu/usr.bin/man/man/manpath.c
deleted file mode 100644
index ccf7a55..0000000
--- a/gnu/usr.bin/man/man/manpath.c
+++ /dev/null
@@ -1,520 +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 ();
-
- 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)
- if ((p = strchr (bp, '\t')) == NULL)
- 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)
- if ((p = strchr (bp, '\t')) == NULL)
- 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 ();
- }
- dlp++;
- }
-
- 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/man/manpath.h b/gnu/usr.bin/man/man/manpath.h
deleted file mode 100644
index a61761f..0000000
--- a/gnu/usr.bin/man/man/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/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/strdup.c b/gnu/usr.bin/man/man/strdup.c
deleted file mode 100644
index 4e5af07..0000000
--- a/gnu/usr.bin/man/man/strdup.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* strdup.c -- return a newly allocated copy of a string
- Copyright (C) 1990 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef STDC_HEADERS
-#include <string.h>
-#include <stdlib.h>
-#else
-char *malloc ();
-char *strcpy ();
-#endif
-
-/* Return a newly allocated copy of STR,
- or 0 if out of memory. */
-
-char *
-strdup (str)
- char *str;
-{
- char *newstr;
-
- newstr = (char *) malloc (strlen (str) + 1);
- if (newstr)
- strcpy (newstr, str);
- return newstr;
-}
diff --git a/gnu/usr.bin/man/man/version.h b/gnu/usr.bin/man/man/version.h
deleted file mode 100644
index 4d9eb63..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 c86bf1b..0000000
--- a/gnu/usr.bin/man/manpath/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-PROG= manpath
-SRCS= manpath.c
-
-.if exists(${.CURDIR}/../lib/obj)
-LDADD= -L${.CURDIR}/../lib/obj -lman
-.else
-LDADD= -L${.CURDIR}/../lib/ -lman
-.endif
-
-.if exists(${.CURDIR}/obj)
-MAN1=${.CURDIR}/obj/manpath.1
-.else
-MAN1=${.CURDIR}/manpath.1
-.endif
-
-DPADD+= ${MAN1}
-CFLAGS+= -DMAIN -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS
-CFLAGS+= -DALT_SYSTEMS -I${.CURDIR}/../lib -I${.CURDIR}/../lib/obj
-CLEANFILES+= ${MAN1}
-
-${MAN1}: ${.CURDIR}/manpath.man
- 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 555 ${.CURDIR}/manpath.config ${DESTDIR}${manpath_config_file}
-
-.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 ccf7a55..0000000
--- a/gnu/usr.bin/man/manpath/manpath.c
+++ /dev/null
@@ -1,520 +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 ();
-
- 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)
- if ((p = strchr (bp, '\t')) == NULL)
- 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)
- if ((p = strchr (bp, '\t')) == NULL)
- 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 ();
- }
- dlp++;
- }
-
- 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 b9c1171..0000000
--- a/gnu/usr.bin/man/manpath/manpath.config
+++ /dev/null
@@ -1,30 +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/gnu/man
-#
-# set up PATH to MANPATH mapping
-#
-MANPATH_MAP /bin /usr/share/man
-MANPATH_MAP /usr/bin /usr/share/man
-MANPATH_MAP /usr/ucb /usr/share/man
-MANPATH_MAP /usr/local/mh /usr/local/mh/man
-MANPATH_MAP /usr/local/bin /usr/local/man
-MANPATH_MAP /usr/gnu /usr/gnu/man
-MANPATH_MAP /usr/X386 /usr/X386/man
diff --git a/gnu/usr.bin/man/manpath/manpath.h b/gnu/usr.bin/man/manpath/manpath.h
deleted file mode 100644
index a61761f..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 9212324..0000000
--- a/gnu/usr.bin/man/manpath/manpath.man
+++ /dev/null
@@ -1,56 +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
-.\"
-.TH manpath 1 "Jan 5, 1991"
-.LO 1
-.SH NAME
-manpath \- determine user's search path for man pages
-.SH SYNOPSIS
-manpath [\-q]
-.SH DESCRIPTION
-manpath tries to determine the user's manpath from a set of system
-defaults and the user's
-.B 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
-manpath is used by
-.B man
-to determine the search path, so user's normally don't need to set the
-.B MANPATH
-environment variable directly.
-.SH OPTIONS
-.TP
-.B \-\^q
-Operate quietly. Only echo the final manpath.
-.SH ENVIRONMENT
-.TP \w'MANPATH\ \ 'u
-.B MANPATH
-If
-.B MANPATH
-is set,
-.B manpath
-echoes its value on the standard output and issues a warning on the
-standard error.
-.SH FILES
-.TP \w'%manpath_config_file%'u+2n
-.BI %manpath_config_file%
-System configuration file.
-.SH "SEE ALSO"
-apropos(1), whatis(1), man(1).
-.SH BUGS
-None known.
diff --git a/gnu/usr.bin/man/whatis/Makefile b/gnu/usr.bin/man/whatis/Makefile
deleted file mode 100644
index 94347e1..0000000
--- a/gnu/usr.bin/man/whatis/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
-.if exists(${.CURDIR}/obj)
-MANP= ${.CURDIR}/obj/whatis.1
-TARG= ${.CURDIR}/obj/whatis
-.else
-MANP= ${.CURDIR}/whatis.1
-TARG= ${.CURDIR}/whatis
-.endif
-
-all: ${TARG} ${MANP}
-
-depend rcsfreeze tags all:
- @echo -n
-
-cleandir: clean
- cd ${.CURDIR}; rm -rf obj;
-
-clean:
- @rm -f ${TARG} ${MANP}
-
-${TARG}: ${.CURDIR}/whatis.sh
- sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
- -e 's,%pager%,${pager},' \
- ${.CURDIR}/whatis.sh > ${TARG}
-
-${MANP}: ${.CURDIR}/whatis.man
- 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}/whatis.man > ${MANP}
-
-install: ${TARG} maninstall
- install -c -o bin -g bin -m 555 ${TARG} ${DESTDIR}/usr/bin
-
-maninstall: ${MANP}
- install -c -o bin -g bin -m 444 ${MANP} ${DESTDIR}/usr/share/man/man1
-
-.include "../Makefile.inc"
diff --git a/gnu/usr.bin/man/whatis/whatis b/gnu/usr.bin/man/whatis/whatis
deleted file mode 100644
index e8cae0a..0000000
--- a/gnu/usr.bin/man/whatis/whatis
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# whatis -- search the whatis database for keywords. Like apropos,
-# but match only commands (as whole words).
-#
-# 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
-
-PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
-
-libdir=/etc
-
-if [ $# = 0 ]
-then
- echo "usage: `basename $0` name ..."
- exit 1
-fi
-
-manpath=`/usr/bin/manpath -q | tr : '\040'`
-
-if [ "$manpath" = "" ]
-then
- echo "whatis: manpath is null"
- exit 1
-fi
-
-if [ "$PAGER" = "" ]
-then
- PAGER="/usr/gnu/bin/less -sC"
-fi
-
-while [ $1 ]
-do
- found=0
- for d in $manpath /usr/lib
- do
- if [ -f $d/whatis ]
- then
- grep -iw "^$1" $d/whatis
- status=$?
- if [ "$status" = "0" ]
- then
- found=1
- export found;
- fi
- fi
- done
-
- if [ "$found" = "0" ]
- then
- echo "$1: nothing appropriate"
- fi
-
- shift
-done | $PAGER
-
-exit
diff --git a/gnu/usr.bin/man/whatis/whatis.1 b/gnu/usr.bin/man/whatis/whatis.1
deleted file mode 100644
index 9e5528d..0000000
--- a/gnu/usr.bin/man/whatis/whatis.1
+++ /dev/null
@@ -1,27 +0,0 @@
-.\" Man page for 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
-.\"
-.TH whatis 1 "Jan 5, 1991"
-.LO 1
-.SH NAME
-whatis \- search the whatis database for complete words.
-.SH SYNOPSIS
-.BI whatis
-keyword ...
-.SH DESCRIPTION
-whatis searches a set of database files containing short descriptions
-of system commands for keywords and displays the result on the
-standard output. Only complete word matches are displayed.
-.SH "SEE ALSO"
-apropos(1), man(1).
diff --git a/gnu/usr.bin/man/whatis/whatis.man b/gnu/usr.bin/man/whatis/whatis.man
deleted file mode 100644
index 9e5528d..0000000
--- a/gnu/usr.bin/man/whatis/whatis.man
+++ /dev/null
@@ -1,27 +0,0 @@
-.\" Man page for 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
-.\"
-.TH whatis 1 "Jan 5, 1991"
-.LO 1
-.SH NAME
-whatis \- search the whatis database for complete words.
-.SH SYNOPSIS
-.BI whatis
-keyword ...
-.SH DESCRIPTION
-whatis searches a set of database files containing short descriptions
-of system commands for keywords and displays the result on the
-standard output. Only complete word matches are displayed.
-.SH "SEE ALSO"
-apropos(1), man(1).
diff --git a/gnu/usr.bin/man/whatis/whatis.sh b/gnu/usr.bin/man/whatis/whatis.sh
deleted file mode 100644
index 34abaaa..0000000
--- a/gnu/usr.bin/man/whatis/whatis.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# whatis -- search the whatis database for keywords. Like apropos,
-# but match only commands (as whole words).
-#
-# 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
-
-PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
-
-libdir=%libdir%
-
-if [ $# = 0 ]
-then
- echo "usage: `basename $0` name ..."
- exit 1
-fi
-
-manpath=`%bindir%/manpath -q | tr : '\040'`
-
-if [ "$manpath" = "" ]
-then
- echo "whatis: manpath is null"
- exit 1
-fi
-
-if [ "$PAGER" = "" ]
-then
- PAGER="%pager%"
-fi
-
-while [ $1 ]
-do
- found=0
- for d in $manpath /usr/lib
- do
- if [ -f $d/whatis ]
- then
- grep -iw "^$1" $d/whatis
- status=$?
- if [ "$status" = "0" ]
- then
- found=1
- export found;
- fi
- fi
- done
-
- if [ "$found" = "0" ]
- then
- echo "$1: nothing appropriate"
- fi
-
- shift
-done | $PAGER
-
-exit
diff --git a/gnu/usr.bin/patch/EXTERN.h b/gnu/usr.bin/patch/EXTERN.h
deleted file mode 100644
index bdc1ef9..0000000
--- a/gnu/usr.bin/patch/EXTERN.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* $Header: EXTERN.h,v 2.0 86/09/17 15:35:37 lwall Exp $
- *
- * $Log: EXTERN.h,v $
- * Revision 2.0 86/09/17 15:35:37 lwall
- * Baseline for netwide release.
- *
- */
-
-#ifdef EXT
-#undef EXT
-#endif
-#define EXT extern
-
-#ifdef INIT
-#undef INIT
-#endif
-#define INIT(x)
-
-#ifdef DOINIT
-#undef DOINIT
-#endif
diff --git a/gnu/usr.bin/patch/INTERN.h b/gnu/usr.bin/patch/INTERN.h
deleted file mode 100644
index 38574ef..0000000
--- a/gnu/usr.bin/patch/INTERN.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* $Header: INTERN.h,v 2.0 86/09/17 15:35:58 lwall Exp $
- *
- * $Log: INTERN.h,v $
- * Revision 2.0 86/09/17 15:35:58 lwall
- * Baseline for netwide release.
- *
- */
-
-#ifdef EXT
-#undef EXT
-#endif
-#define EXT
-
-#ifdef INIT
-#undef INIT
-#endif
-#define INIT(x) = x
-
-#define DOINIT
diff --git a/gnu/usr.bin/patch/Makefile b/gnu/usr.bin/patch/Makefile
deleted file mode 100644
index d614e89..0000000
--- a/gnu/usr.bin/patch/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-PROG= patch
-SRCS = backupfile.c getopt.c getopt1.c inp.c patch.c pch.c util.c \
- version.c
-CFLAGS += -DHAVE_CONFIG_H
-MAN= patch.1
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/patch/backupfile.c b/gnu/usr.bin/patch/backupfile.c
deleted file mode 100644
index d7eb5874..0000000
--- a/gnu/usr.bin/patch/backupfile.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/* backupfile.c -- make Emacs style backup file names
- Copyright (C) 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.
- Some algorithms adapted from GNU Emacs. */
-
-#include "config.h"
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include "backupfile.h"
-#ifdef STDC_HEADERS
-#include <string.h>
-#include <stdlib.h>
-#else
-char *malloc ();
-#endif
-
-#if defined (HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-
-#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 */
-
-#ifndef isascii
-#define ISDIGIT(c) (isdigit ((unsigned char) (c)))
-#else
-#define ISDIGIT(c) (isascii (c) && isdigit (c))
-#endif
-
-#if defined (_POSIX_VERSION)
-/* 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
-
-/* Which type of backup file names are generated. */
-enum backup_type backup_type = none;
-
-/* The extension added to file names to produce a simple (as opposed
- to numbered) backup file name. */
-char *simple_backup_suffix = "~";
-
-char *basename ();
-char *dirname ();
-static char *concat ();
-char *find_backup_file_name ();
-static char *make_version_name ();
-static int max_backup_version ();
-static int version_number ();
-
-/* Return NAME with any leading path stripped off. */
-
-char *
-basename (name)
- char *name;
-{
- char *r = name, *p = name;
-
- while (*p)
- if (*p++ == '/')
- r = p;
- return r;
-}
-
-#ifndef NODIR
-/* Return the name of the new backup file for file FILE,
- allocated with malloc. Return 0 if out of memory.
- FILE must not end with a '/' unless it is the root directory.
- Do not call this function if backup_type == none. */
-
-char *
-find_backup_file_name (file)
- char *file;
-{
- char *dir;
- char *base_versions;
- int highest_backup;
-
- if (backup_type == simple)
- {
- char *s = malloc (strlen (file) + strlen (simple_backup_suffix) + 1);
- strcpy (s, file);
- addext (s, simple_backup_suffix, '~');
- return s;
- }
- base_versions = concat (basename (file), ".~");
- if (base_versions == 0)
- return 0;
- dir = dirname (file);
- if (dir == 0)
- {
- free (base_versions);
- return 0;
- }
- highest_backup = max_backup_version (base_versions, dir);
- free (base_versions);
- free (dir);
- if (backup_type == numbered_existing && highest_backup == 0)
- return concat (file, simple_backup_suffix);
- return make_version_name (file, highest_backup + 1);
-}
-
-/* Return the number of the highest-numbered backup file for file
- FILE in directory DIR. If there are no numbered backups
- of FILE in DIR, or an error occurs reading DIR, return 0.
- FILE should already have ".~" appended to it. */
-
-static int
-max_backup_version (file, dir)
- char *file, *dir;
-{
- DIR *dirp;
- struct dirent *dp;
- int highest_version;
- int this_version;
- int file_name_length;
-
- dirp = opendir (dir);
- if (!dirp)
- return 0;
-
- highest_version = 0;
- file_name_length = strlen (file);
-
- while ((dp = readdir (dirp)) != 0)
- {
- if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) <= file_name_length)
- continue;
-
- this_version = version_number (file, dp->d_name, file_name_length);
- if (this_version > highest_version)
- highest_version = this_version;
- }
- closedir (dirp);
- return highest_version;
-}
-
-/* Return a string, allocated with malloc, containing
- "FILE.~VERSION~". Return 0 if out of memory. */
-
-static char *
-make_version_name (file, version)
- char *file;
- int version;
-{
- char *backup_name;
-
- backup_name = malloc (strlen (file) + 16);
- if (backup_name == 0)
- return 0;
- sprintf (backup_name, "%s.~%d~", file, version);
- return backup_name;
-}
-
-/* If BACKUP is a numbered backup of BASE, return its version number;
- otherwise return 0. BASE_LENGTH is the length of BASE.
- BASE should already have ".~" appended to it. */
-
-static int
-version_number (base, backup, base_length)
- char *base;
- char *backup;
- int base_length;
-{
- int version;
- char *p;
-
- version = 0;
- if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length]))
- {
- for (p = &backup[base_length]; ISDIGIT (*p); ++p)
- version = version * 10 + *p - '0';
- if (p[0] != '~' || p[1])
- version = 0;
- }
- return version;
-}
-
-/* Return the newly-allocated concatenation of STR1 and STR2.
- If out of memory, return 0. */
-
-static char *
-concat (str1, str2)
- char *str1, *str2;
-{
- char *newstr;
- char str1_length = strlen (str1);
-
- newstr = malloc (str1_length + strlen (str2) + 1);
- if (newstr == 0)
- return 0;
- strcpy (newstr, str1);
- strcpy (newstr + str1_length, str2);
- return newstr;
-}
-
-/* Return the leading directories part of PATH,
- allocated with malloc. If out of memory, return 0.
- Assumes that trailing slashes have already been
- removed. */
-
-char *
-dirname (path)
- char *path;
-{
- char *newpath;
- char *slash;
- int length; /* Length of result, not including NUL. */
-
- slash = basename (path);
- if (slash == path)
- {
- /* File is in the current directory. */
- path = ".";
- length = 1;
- }
- else
- {
- /* Remove any trailing slashes from result. */
- while (*--slash == '/' && slash > path)
- ;
-
- length = slash - path + 1;
- }
- newpath = malloc (length + 1);
- if (newpath == 0)
- return 0;
- strncpy (newpath, path, length);
- newpath[length] = 0;
- return newpath;
-}
-
-/* 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, "patch: ");
- if (problem == -1)
- fprintf (stderr, "invalid");
- else /* Assume -2. */
- fprintf (stderr, "ambiguous");
- fprintf (stderr, " %s `%s'\n", kind, value);
-}
-
-static char *backup_args[] =
-{
- "never", "simple", "nil", "existing", "t", "numbered", 0
-};
-
-static enum backup_type backup_types[] =
-{
- simple, simple, numbered_existing, numbered_existing, numbered, numbered
-};
-
-/* Return the type of backup indicated by VERSION.
- Unique abbreviations are accepted. */
-
-enum backup_type
-get_version (version)
- char *version;
-{
- int i;
-
- if (version == 0 || *version == 0)
- return numbered_existing;
- i = argmatch (version, backup_args);
- if (i >= 0)
- return backup_types[i];
- invalid_arg ("version control type", version, i);
- exit (1);
-}
-#endif /* NODIR */
-
-/* Append to FILENAME the extension EXT, unless the result would be too long,
- in which case just append the character E. */
-
-void
-addext (filename, ext, e)
- char *filename, *ext;
- int e;
-{
- char *s = basename (filename);
- int slen = strlen (s), extlen = strlen (ext);
- long slen_max = -1;
-
-#if HAVE_PATHCONF && defined (_PC_NAME_MAX)
-#ifndef _POSIX_NAME_MAX
-#define _POSIX_NAME_MAX 14
-#endif
- if (slen + extlen <= _POSIX_NAME_MAX)
- /* The file name is so short there's no need to call pathconf. */
- slen_max = _POSIX_NAME_MAX;
- else if (s == filename)
- slen_max = pathconf (".", _PC_NAME_MAX);
- else
- {
- char c = *s;
- *s = 0;
- slen_max = pathconf (filename, _PC_NAME_MAX);
- *s = c;
- }
-#endif
- if (slen_max == -1) {
-#ifdef HAVE_LONG_FILE_NAMES
- slen_max = 255;
-#else
- slen_max = 14;
-#endif
- }
- if (slen + extlen <= slen_max)
- strcpy (s + slen, ext);
- else
- {
- if (slen_max <= slen) {
- /* Try to preserve difference between .h .c etc. */
- if (slen == slen_max && s[slen - 2] == '.')
- s[slen - 2] = s[slen - 1];
-
- slen = slen_max - 1;
- }
- s[slen] = e;
- s[slen + 1] = 0;
- }
-}
diff --git a/gnu/usr.bin/patch/backupfile.h b/gnu/usr.bin/patch/backupfile.h
deleted file mode 100644
index dfd1fc4..0000000
--- a/gnu/usr.bin/patch/backupfile.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* backupfile.h -- declarations for making Emacs style backup file names
- Copyright (C) 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* When to make backup files. */
-enum backup_type
-{
- /* Never make backups. */
- none,
-
- /* Make simple backups of every file. */
- simple,
-
- /* Make numbered backups of files that already have numbered backups,
- and simple backups of the others. */
- numbered_existing,
-
- /* Make numbered backups of every file. */
- numbered
-};
-
-extern enum backup_type backup_type;
-extern char *simple_backup_suffix;
-
-#ifdef __STDC__
-char *find_backup_file_name (char *file);
-enum backup_type get_version (char *version);
-void addext (char *, char *, int);
-#else
-char *find_backup_file_name ();
-enum backup_type get_version ();
-void addext ();
-#endif
diff --git a/gnu/usr.bin/patch/common.h b/gnu/usr.bin/patch/common.h
deleted file mode 100644
index d1906fd..0000000
--- a/gnu/usr.bin/patch/common.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
- *
- * $Log: common.h,v $
- * Revision 2.0.1.2 88/06/22 20:44:53 lwall
- * patch12: sprintf was declared wrong
- *
- * Revision 2.0.1.1 88/06/03 15:01:56 lwall
- * patch10: support for shorter extensions.
- *
- * Revision 2.0 86/09/17 15:36:39 lwall
- * Baseline for netwide release.
- *
- */
-
-#define DEBUGGING
-
-#define VOIDUSED 7
-#include "config.h"
-
-/* shut lint up about the following when return value ignored */
-
-#define Signal (void)signal
-#define Unlink (void)unlink
-#define Lseek (void)lseek
-#define Fseek (void)fseek
-#define Fstat (void)fstat
-#define Pclose (void)pclose
-#define Close (void)close
-#define Fclose (void)fclose
-#define Fflush (void)fflush
-#define Sprintf (void)sprintf
-#define Mktemp (void)mktemp
-#define Strcpy (void)strcpy
-#define Strcat (void)strcat
-
-/* NeXT declares malloc and realloc incompatibly from us in some of
- these files. Temporarily redefine them to prevent errors. */
-#define malloc system_malloc
-#define realloc system_realloc
-#include <stdio.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <signal.h>
-#undef malloc
-#undef realloc
-
-/* constants */
-
-/* AIX predefines these. */
-#ifdef TRUE
-#undef TRUE
-#endif
-#ifdef FALSE
-#undef FALSE
-#endif
-#define TRUE (1)
-#define FALSE (0)
-
-#define MAXHUNKSIZE 100000 /* is this enough lines? */
-#define INITHUNKMAX 125 /* initial dynamic allocation size */
-#define MAXLINELEN 1024
-#define BUFFERSIZE 1024
-
-#define SCCSPREFIX "s."
-#define GET "get %s"
-#define GET_LOCKED "get -e %s"
-#define SCCSDIFF "get -p %s | diff - %s >/dev/null"
-
-#define RCSSUFFIX ",v"
-#define CHECKOUT "co %s"
-#define CHECKOUT_LOCKED "co -l %s"
-#define RCSDIFF "rcsdiff %s > /dev/null"
-
-/* handy definitions */
-
-#define Null(t) ((t)0)
-#define Nullch Null(char *)
-#define Nullfp Null(FILE *)
-#define Nulline Null(LINENUM)
-
-#define Ctl(ch) ((ch) & 037)
-
-#define strNE(s1,s2) (strcmp(s1, s2))
-#define strEQ(s1,s2) (!strcmp(s1, s2))
-#define strnNE(s1,s2,l) (strncmp(s1, s2, l))
-#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
-
-/* typedefs */
-
-typedef char bool;
-typedef long LINENUM; /* must be signed */
-typedef unsigned MEM; /* what to feed malloc */
-
-/* globals */
-
-EXT int Argc; /* guess */
-EXT char **Argv;
-EXT int optind_last; /* for restarting plan_b */
-
-EXT struct stat filestat; /* file statistics area */
-EXT int filemode INIT(0644);
-
-EXT char buf[MAXLINELEN]; /* general purpose buffer */
-EXT FILE *ofp INIT(Nullfp); /* output file pointer */
-EXT FILE *rejfp INIT(Nullfp); /* reject file pointer */
-
-EXT int myuid; /* cache getuid return value */
-
-EXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */
-EXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */
-
-#define MAXFILEC 2
-EXT int filec INIT(0); /* how many file arguments? */
-EXT char *filearg[MAXFILEC];
-EXT bool ok_to_create_file INIT(FALSE);
-EXT char *bestguess INIT(Nullch); /* guess at correct filename */
-
-EXT char *outname INIT(Nullch);
-EXT char rejname[128];
-
-EXT char *origprae INIT(Nullch);
-
-EXT char *TMPOUTNAME;
-EXT char *TMPINNAME;
-EXT char *TMPREJNAME;
-EXT char *TMPPATNAME;
-EXT bool toutkeep INIT(FALSE);
-EXT bool trejkeep INIT(FALSE);
-
-EXT LINENUM last_offset INIT(0);
-#ifdef DEBUGGING
-EXT int debug INIT(0);
-#endif
-EXT LINENUM maxfuzz INIT(2);
-EXT bool force INIT(FALSE);
-EXT bool batch INIT(FALSE);
-EXT bool verbose INIT(TRUE);
-EXT bool reverse INIT(FALSE);
-EXT bool noreverse INIT(FALSE);
-EXT bool skip_rest_of_patch INIT(FALSE);
-EXT int strippath INIT(957);
-EXT bool canonicalize INIT(FALSE);
-
-#define CONTEXT_DIFF 1
-#define NORMAL_DIFF 2
-#define ED_DIFF 3
-#define NEW_CONTEXT_DIFF 4
-#define UNI_DIFF 5
-EXT int diff_type INIT(0);
-
-EXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */
-EXT char if_defined[128]; /* #ifdef xyzzy */
-EXT char not_defined[128]; /* #ifndef xyzzy */
-EXT char else_defined[] INIT("#else\n");/* #else */
-EXT char end_defined[128]; /* #endif xyzzy */
-
-EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
-
-#include <errno.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#include <string.h>
-#else
-extern int errno;
-FILE *popen();
-char *malloc();
-char *realloc();
-long atol();
-char *getenv();
-char *strcpy();
-char *strcat();
-#endif
-char *mktemp();
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#else
-long lseek();
-#endif
-#if defined(_POSIX_VERSION) || defined(HAVE_FCNTL_H)
-#include <fcntl.h>
-#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
diff --git a/gnu/usr.bin/patch/config.h b/gnu/usr.bin/patch/config.h
deleted file mode 100644
index 71623d7..0000000
--- a/gnu/usr.bin/patch/config.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* Portability variables. -*- C -*- */
-
-/* Define if the system does not support the `const' keyword. */
-/* #undef const */
-
-/* Define if the system supports file names longer than 14 characters. */
-#define HAVE_LONG_FILE_NAMES
-
-/* Define if the system has pathconf(). */
-/* #undef HAVE_PATHCONF */
-
-/* Define if the system has strerror(). */
-#define HAVE_STRERROR 1
-
-/* Define if the system has ANSI C header files and library functions. */
-#define STDC_HEADERS
-
-/* Define if the system uses strchr instead of index
- and strrchr instead of rindex. */
-#define HAVE_STRING_H 1
-
-#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
-#define index strchr
-#define rindex strrchr
-#endif
-
-/* Define if the system has unistd.h. */
-#define HAVE_UNISTD_H 1
-
-/* Define if the system has fcntl.h. */
-#define HAVE_FCNTL_H 1
-
-/* Define as either int or void -- the type that signal handlers return. */
-#define RETSIGTYPE void
-
-#ifndef RETSIGTYPE
-#define RETSIGTYPE void
-#endif
-
-/* Which directory library header to use. */
-#define DIRENT 1 /* dirent.h */
-/* #undef SYSNDIR */ /* sys/ndir.h */
-/* #undef SYSDIR */ /* sys/dir.h */
-/* #undef NDIR */ /* ndir.h */
-/* #undef NODIR */ /* none -- don't make numbered backup files */
-
-/* Define if the system lets you pass fewer arguments to a function
- than the function actually accepts (in the absence of a prototype).
- Defining it makes I/O calls slightly more efficient.
- You need not bother defining it unless your C preprocessor chokes on
- multi-line arguments to macros. */
-/* #undef CANVARARG */
-
-/* Define Reg* as either `register' or nothing, depending on whether
- the C compiler pays attention to this many register declarations.
- The intent is that you don't have to order your register declarations
- in the order of importance, so you can freely declare register variables
- in sub-blocks of code and as function parameters.
- Do not use Reg<n> more than once per routine.
-
- These don't really matter a lot, since most modern C compilers ignore
- register declarations and often do a better job of allocating
- registers than people do. */
-
-#define Reg1 register
-#define Reg2 register
-#define Reg3 register
-#define Reg4 register
-#define Reg5 register
-#define Reg6 register
-#define Reg7
-#define Reg8
-#define Reg9
-#define Reg10
-#define Reg11
-#define Reg12
-#define Reg13
-#define Reg14
-#define Reg15
-#define Reg16
diff --git a/gnu/usr.bin/patch/getopt.c b/gnu/usr.bin/patch/getopt.c
deleted file mode 100644
index a59a013..0000000
--- a/gnu/usr.bin/patch/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/patch/getopt.h b/gnu/usr.bin/patch/getopt.h
deleted file mode 100644
index 45541f5..0000000
--- a/gnu/usr.bin/patch/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/patch/getopt1.c b/gnu/usr.bin/patch/getopt1.c
deleted file mode 100644
index a32615c..0000000
--- a/gnu/usr.bin/patch/getopt1.c
+++ /dev/null
@@ -1,176 +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
-#include "config.h"
-#endif
-
-#include "getopt.h"
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#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/patch/inp.c b/gnu/usr.bin/patch/inp.c
deleted file mode 100644
index c99054f..0000000
--- a/gnu/usr.bin/patch/inp.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/* $Header: inp.c,v 2.0.1.1 88/06/03 15:06:13 lwall Locked $
- *
- * $Log: inp.c,v $
- * Revision 2.0.1.1 88/06/03 15:06:13 lwall
- * patch10: made a little smarter about sccs files
- *
- * Revision 2.0 86/09/17 15:37:02 lwall
- * Baseline for netwide release.
- *
- */
-
-#include "EXTERN.h"
-#include "common.h"
-#include "util.h"
-#include "pch.h"
-#include "INTERN.h"
-#include "inp.h"
-
-/* Input-file-with-indexable-lines abstract type */
-
-static long i_size; /* size of the input file */
-static char *i_womp; /* plan a buffer for entire file */
-static char **i_ptr; /* pointers to lines in i_womp */
-
-static int tifd = -1; /* plan b virtual string array */
-static char *tibuf[2]; /* plan b buffers */
-static LINENUM tiline[2] = {-1, -1}; /* 1st line in each buffer */
-static LINENUM lines_per_buf; /* how many lines per buffer */
-static int tireclen; /* length of records in tmp file */
-
-/* New patch--prepare to edit another file. */
-
-void
-re_input()
-{
- if (using_plan_a) {
- i_size = 0;
-#ifndef lint
- if (i_ptr != Null(char**))
- free((char *)i_ptr);
-#endif
- if (i_womp != Nullch)
- free(i_womp);
- i_womp = Nullch;
- i_ptr = Null(char **);
- }
- else {
- using_plan_a = TRUE; /* maybe the next one is smaller */
- Close(tifd);
- tifd = -1;
- free(tibuf[0]);
- free(tibuf[1]);
- tibuf[0] = tibuf[1] = Nullch;
- tiline[0] = tiline[1] = -1;
- tireclen = 0;
- }
-}
-
-/* Constuct the line index, somehow or other. */
-
-void
-scan_input(filename)
-char *filename;
-{
- if (!plan_a(filename))
- plan_b(filename);
- if (verbose) {
- say3("Patching file %s using Plan %s...\n", filename,
- (using_plan_a ? "A" : "B") );
- }
-}
-
-/* Try keeping everything in memory. */
-
-bool
-plan_a(filename)
-char *filename;
-{
- int ifd, statfailed;
- Reg1 char *s;
- Reg2 LINENUM iline;
- char lbuf[MAXLINELEN];
- int output_elsewhere = strcmp(filename, outname);
-
- statfailed = stat(filename, &filestat);
- if (statfailed && ok_to_create_file) {
- if (verbose)
- say2("(Creating file %s...)\n",filename);
- makedirs(filename, TRUE);
- close(creat(filename, 0666));
- statfailed = stat(filename, &filestat);
- }
- /* For nonexistent or read-only files, look for RCS or SCCS versions. */
- if (statfailed
- || (! output_elsewhere
- && (/* No one can write to it. */
- (filestat.st_mode & 0222) == 0
- /* I can't write to it. */
- || ((filestat.st_mode & 0022) == 0
- && filestat.st_uid != myuid)))) {
- struct stat cstat;
- char *cs = Nullch;
- char *filebase;
- int pathlen;
-
- filebase = basename(filename);
- pathlen = filebase - filename;
-
- /* Put any leading path into `s'.
- Leave room in lbuf for the diff command. */
- s = lbuf + 20;
- strncpy(s, filename, pathlen);
-
-#define try(f,a1,a2) (Sprintf(s + pathlen, f, a1, a2), stat(s, &cstat) == 0)
- if (( try("RCS/%s%s", filebase, RCSSUFFIX)
- || try("RCS/%s" , filebase, 0)
- || try( "%s%s", filebase, RCSSUFFIX))
- &&
- /* Check that RCS file is not working file.
- Some hosts don't report file name length errors. */
- (statfailed
- || ( (filestat.st_dev ^ cstat.st_dev)
- | (filestat.st_ino ^ cstat.st_ino)))) {
- Sprintf(buf, output_elsewhere?CHECKOUT:CHECKOUT_LOCKED, filename);
- Sprintf(lbuf, RCSDIFF, filename);
- cs = "RCS";
- } else if ( try("SCCS/%s%s", SCCSPREFIX, filebase)
- || try( "%s%s", SCCSPREFIX, filebase)) {
- Sprintf(buf, output_elsewhere?GET:GET_LOCKED, s);
- Sprintf(lbuf, SCCSDIFF, s, filename);
- cs = "SCCS";
- } else if (statfailed)
- fatal2("can't find %s\n", filename);
- /* else we can't write to it but it's not under a version
- control system, so just proceed. */
- if (cs) {
- if (!statfailed) {
- if ((filestat.st_mode & 0222) != 0)
- /* The owner can write to it. */
- fatal3("file %s seems to be locked by somebody else under %s\n",
- filename, cs);
- /* It might be checked out unlocked. See if it's safe to
- check out the default version locked. */
- if (verbose)
- say3("Comparing file %s to default %s version...\n",
- filename, cs);
- if (system(lbuf))
- fatal3("can't check out file %s: differs from default %s version\n",
- filename, cs);
- }
- if (verbose)
- say3("Checking out file %s from %s...\n", filename, cs);
- if (system(buf) || stat(filename, &filestat))
- fatal3("can't check out file %s from %s\n", filename, cs);
- }
- }
- filemode = filestat.st_mode;
- if (!S_ISREG(filemode))
- fatal2("%s is not a normal file--can't patch\n", filename);
- i_size = filestat.st_size;
- if (out_of_mem) {
- set_hunkmax(); /* make sure dynamic arrays are allocated */
- out_of_mem = FALSE;
- return FALSE; /* force plan b because plan a bombed */
- }
-#ifdef lint
- i_womp = Nullch;
-#else
- i_womp = malloc((MEM)(i_size+2)); /* lint says this may alloc less than */
- /* i_size, but that's okay, I think. */
-#endif
- if (i_womp == Nullch)
- return FALSE;
- if ((ifd = open(filename, 0)) < 0)
- pfatal2("can't open file %s", filename);
-#ifndef lint
- if (read(ifd, i_womp, (int)i_size) != i_size) {
- Close(ifd); /* probably means i_size > 15 or 16 bits worth */
- free(i_womp); /* at this point it doesn't matter if i_womp was */
- return FALSE; /* undersized. */
- }
-#endif
- Close(ifd);
- if (i_size && i_womp[i_size-1] != '\n')
- i_womp[i_size++] = '\n';
- i_womp[i_size] = '\0';
-
- /* count the lines in the buffer so we know how many pointers we need */
-
- iline = 0;
- for (s=i_womp; *s; s++) {
- if (*s == '\n')
- iline++;
- }
-#ifdef lint
- i_ptr = Null(char**);
-#else
- i_ptr = (char **)malloc((MEM)((iline + 2) * sizeof(char *)));
-#endif
- if (i_ptr == Null(char **)) { /* shucks, it was a near thing */
- free((char *)i_womp);
- return FALSE;
- }
-
- /* now scan the buffer and build pointer array */
-
- iline = 1;
- i_ptr[iline] = i_womp;
- for (s=i_womp; *s; s++) {
- if (*s == '\n')
- i_ptr[++iline] = s+1; /* these are NOT null terminated */
- }
- input_lines = iline - 1;
-
- /* now check for revision, if any */
-
- if (revision != Nullch) {
- if (!rev_in_string(i_womp)) {
- if (force) {
- if (verbose)
- say2(
-"Warning: this file doesn't appear to be the %s version--patching anyway.\n",
- revision);
- }
- else if (batch) {
- fatal2(
-"this file doesn't appear to be the %s version--aborting.\n", revision);
- }
- else {
- ask2(
-"This file doesn't appear to be the %s version--patch anyway? [n] ",
- revision);
- if (*buf != 'y')
- fatal1("aborted\n");
- }
- }
- else if (verbose)
- say2("Good. This file appears to be the %s version.\n",
- revision);
- }
- return TRUE; /* plan a will work */
-}
-
-/* Keep (virtually) nothing in memory. */
-
-void
-plan_b(filename)
-char *filename;
-{
- Reg3 FILE *ifp;
- Reg1 int i = 0;
- Reg2 int maxlen = 1;
- Reg4 bool found_revision = (revision == Nullch);
-
- using_plan_a = FALSE;
- if ((ifp = fopen(filename, "r")) == Nullfp)
- pfatal2("can't open file %s", filename);
- if ((tifd = creat(TMPINNAME, 0666)) < 0)
- pfatal2("can't open file %s", TMPINNAME);
- while (fgets(buf, sizeof buf, ifp) != Nullch) {
- if (revision != Nullch && !found_revision && rev_in_string(buf))
- found_revision = TRUE;
- if ((i = strlen(buf)) > maxlen)
- maxlen = i; /* find longest line */
- }
- if (revision != Nullch) {
- if (!found_revision) {
- if (force) {
- if (verbose)
- say2(
-"Warning: this file doesn't appear to be the %s version--patching anyway.\n",
- revision);
- }
- else if (batch) {
- fatal2(
-"this file doesn't appear to be the %s version--aborting.\n", revision);
- }
- else {
- ask2(
-"This file doesn't appear to be the %s version--patch anyway? [n] ",
- revision);
- if (*buf != 'y')
- fatal1("aborted\n");
- }
- }
- else if (verbose)
- say2("Good. This file appears to be the %s version.\n",
- revision);
- }
- Fseek(ifp, 0L, 0); /* rewind file */
- lines_per_buf = BUFFERSIZE / maxlen;
- tireclen = maxlen;
- tibuf[0] = malloc((MEM)(BUFFERSIZE + 1));
- tibuf[1] = malloc((MEM)(BUFFERSIZE + 1));
- if (tibuf[1] == Nullch)
- fatal1("out of memory\n");
- for (i=1; ; i++) {
- if (! (i % lines_per_buf)) /* new block */
- if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
- pfatal1("can't write temp file");
- if (fgets(tibuf[0] + maxlen * (i%lines_per_buf), maxlen + 1, ifp)
- == Nullch) {
- input_lines = i - 1;
- if (i % lines_per_buf)
- if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
- pfatal1("can't write temp file");
- break;
- }
- }
- Fclose(ifp);
- Close(tifd);
- if ((tifd = open(TMPINNAME, 0)) < 0) {
- pfatal2("can't reopen file %s", TMPINNAME);
- }
-}
-
-/* Fetch a line from the input file, \n terminated, not necessarily \0. */
-
-char *
-ifetch(line,whichbuf)
-Reg1 LINENUM line;
-int whichbuf; /* ignored when file in memory */
-{
- if (line < 1 || line > input_lines)
- return "";
- if (using_plan_a)
- return i_ptr[line];
- else {
- LINENUM offline = line % lines_per_buf;
- LINENUM baseline = line - offline;
-
- if (tiline[0] == baseline)
- whichbuf = 0;
- else if (tiline[1] == baseline)
- whichbuf = 1;
- else {
- tiline[whichbuf] = baseline;
-#ifndef lint /* complains of long accuracy */
- Lseek(tifd, (long)baseline / lines_per_buf * BUFFERSIZE, 0);
-#endif
- if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0)
- pfatal2("error reading tmp file %s", TMPINNAME);
- }
- return tibuf[whichbuf] + (tireclen*offline);
- }
-}
-
-/* True if the string argument contains the revision number we want. */
-
-bool
-rev_in_string(string)
-char *string;
-{
- Reg1 char *s;
- Reg2 int patlen;
-
- if (revision == Nullch)
- return TRUE;
- patlen = strlen(revision);
- if (strnEQ(string,revision,patlen) && isspace(string[patlen]))
- return TRUE;
- for (s = string; *s; s++) {
- if (isspace(*s) && strnEQ(s+1, revision, patlen) &&
- isspace(s[patlen+1] )) {
- return TRUE;
- }
- }
- return FALSE;
-}
diff --git a/gnu/usr.bin/patch/inp.h b/gnu/usr.bin/patch/inp.h
deleted file mode 100644
index c6d2a91..0000000
--- a/gnu/usr.bin/patch/inp.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* $Header: inp.h,v 2.0 86/09/17 15:37:25 lwall Exp $
- *
- * $Log: inp.h,v $
- * Revision 2.0 86/09/17 15:37:25 lwall
- * Baseline for netwide release.
- *
- */
-
-EXT LINENUM input_lines INIT(0); /* how long is input file in lines */
-EXT LINENUM last_frozen_line INIT(0); /* how many input lines have been */
- /* irretractibly output */
-
-bool rev_in_string();
-void scan_input();
-bool plan_a(); /* returns false if insufficient memory */
-void plan_b();
-char *ifetch();
-
diff --git a/gnu/usr.bin/patch/patch.1 b/gnu/usr.bin/patch/patch.1
deleted file mode 100644
index bf20668..0000000
--- a/gnu/usr.bin/patch/patch.1
+++ /dev/null
@@ -1,570 +0,0 @@
-.\" -*- nroff -*-
-.rn '' }`
-'\" $Header: patch.man,v 2.0.1.2 88/06/22 20:47:18 lwall Locked $
-'\"
-'\" $Log: patch.man,v $
-'\" Revision 2.0.1.2 88/06/22 20:47:18 lwall
-'\" patch12: now avoids Bell System Logo
-'\"
-'\" Revision 2.0.1.1 88/06/03 15:12:51 lwall
-'\" patch10: -B switch was contributed.
-'\"
-'\" Revision 2.0 86/09/17 15:39:09 lwall
-'\" Baseline for netwide release.
-'\"
-'\" Revision 1.4 86/08/01 19:23:22 lwall
-'\" Documented -v, -p, -F.
-'\" Added notes to patch senders.
-'\"
-'\" Revision 1.3 85/03/26 15:11:06 lwall
-'\" Frozen.
-'\"
-'\" Revision 1.2.1.4 85/03/12 16:14:27 lwall
-'\" Documented -p.
-'\"
-'\" Revision 1.2.1.3 85/03/12 16:09:41 lwall
-'\" Documented -D.
-'\"
-'\" Revision 1.2.1.2 84/12/05 11:06:55 lwall
-'\" Added -l switch, and noted bistability bug.
-'\"
-'\" Revision 1.2.1.1 84/12/04 17:23:39 lwall
-'\" Branch for sdcrdcf changes.
-'\"
-'\" Revision 1.2 84/12/04 17:22:02 lwall
-'\" Baseline version.
-'\"
-.de Sh
-.br
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp
-.if t .sp .5v
-.if n .sp
-..
-'\"
-'\" Set up \*(-- to give an unbreakable dash;
-'\" string Tr holds user defined translation string.
-'\" Bell System Logo is used as a dummy character.
-'\"
-.ie n \{\
-.tr \(*W-\*(Tr
-.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 PATCH 1 LOCAL
-.SH NAME
-patch - apply a diff file to an original
-.SH SYNOPSIS
-.B patch
-[options] [origfile [patchfile]] [+ [options] [origfile]]...
-.sp
-but usually just
-.sp
-.B patch
-<patchfile
-.SH DESCRIPTION
-.I Patch
-will take a patch file containing any of the four forms of difference
-listing produced by the
-.I diff
-program and apply those differences to an original file, producing a patched
-version.
-By default, the patched version is put in place of the original, with
-the original file backed up to the same name with the
-extension \*(L".orig\*(R" (\*(L"~\*(R" on systems that do not
-support long file names), or as specified by the
-\fB\-b\fP (\fB\-\-suffix\fP),
-\fB\-B\fP (\fB\-\-prefix\fP),
-or
-\fB\-V\fP (\fB\-\-version\-control\fP)
-options.
-The extension used for making backup files may also be specified in the
-.B SIMPLE_BACKUP_SUFFIX
-environment variable, which is overridden by the above options.
-.PP
-If the backup file already exists,
-.B patch
-creates a new backup file name by changing the first lowercase letter
-in the last component of the file's name into uppercase. If there are
-no more lowercase letters in the name, it removes the first character
-from the name. It repeats this process until it comes up with a
-backup file that does not already exist.
-.PP
-You may also specify where you want the output to go with a
-\fB\-o\fP (\fB\-\-output\fP)
-option; if that file already exists, it is backed up first.
-.PP
-If
-.I patchfile
-is omitted, or is a hyphen, the patch will be read from standard input.
-.PP
-Upon startup, patch will attempt to determine the type of the diff listing,
-unless over-ruled by a
-\fB\-c\fP (\fB\-\-context\fP),
-\fB\-e\fP (\fB\-\-ed\fP),
-\fB\-n\fP (\fB\-\-normal\fP),
-or
-\fB\-u\fP (\fB\-\-unified\fP)
-option.
-Context diffs (old-style, new-style, and unified) and
-normal diffs are applied by the
-.I patch
-program itself, while
-.I ed
-diffs are simply fed to the
-.I ed
-editor via a pipe.
-.PP
-.I Patch
-will try to skip any leading garbage, apply the diff,
-and then skip any trailing garbage.
-Thus you could feed an article or message containing a
-diff listing to
-.IR patch ,
-and it should work.
-If the entire diff is indented by a consistent amount,
-this will be taken into account.
-.PP
-With context diffs, and to a lesser extent with normal diffs,
-.I patch
-can detect when the line numbers mentioned in the patch are incorrect,
-and will attempt to find the correct place to apply each hunk of the patch.
-As a first guess, it takes the line number mentioned for the hunk, plus or
-minus any offset used in applying the previous hunk.
-If that is not the correct place,
-.I patch
-will scan both forwards and backwards for a set of lines matching the context
-given in the hunk.
-First
-.I patch
-looks for a place where all lines of the context match.
-If no such place is found, and it's a context diff, and the maximum fuzz factor
-is set to 1 or more, then another scan takes place ignoring the first and last
-line of context.
-If that fails, and the maximum fuzz factor is set to 2 or more,
-the first two and last two lines of context are ignored,
-and another scan is made.
-(The default maximum fuzz factor is 2.)
-If
-.I patch
-cannot find a place to install that hunk of the patch, it will put the
-hunk out to a reject file, which normally is the name of the output file
-plus \*(L".rej\*(R" (\*(L"#\*(R" on systems that do not support
-long file names).
-(Note that the rejected hunk will come out in context diff form whether the
-input patch was a context diff or a normal diff.
-If the input was a normal diff, many of the contexts will simply be null.)
-The line numbers on the hunks in the reject file may be different than
-in the patch file: they reflect the approximate location patch thinks the
-failed hunks belong in the new file rather than the old one.
-.PP
-As each hunk is completed, you will be told whether the hunk succeeded or
-failed, and which line (in the new file)
-.I patch
-thought the hunk should go on.
-If this is different from the line number specified in the diff you will
-be told the offset.
-A single large offset MAY be an indication that a hunk was installed in the
-wrong place.
-You will also be told if a fuzz factor was used to make the match, in which
-case you should also be slightly suspicious.
-.PP
-If no original file is specified on the command line,
-.I patch
-will try to figure out from the leading garbage what the name of the file
-to edit is.
-In the header of a context diff, the file name is found from lines beginning
-with \*(L"***\*(R" or \*(L"---\*(R", with the shortest name of an existing
-file winning.
-Only context diffs have lines like that, but if there is an \*(L"Index:\*(R"
-line in the leading garbage,
-.I patch
-will try to use the file name from that line.
-The context diff header takes precedence over an Index line.
-If no file name can be intuited from the leading garbage, you will be asked
-for the name of the file to patch.
-.PP
-If the original file cannot be found or is read-only, but a suitable
-SCCS or RCS file is handy,
-.I patch
-will attempt to get or check out the file.
-.PP
-Additionally, if the leading garbage contains a \*(L"Prereq: \*(R" line,
-.I patch
-will take the first word from the prerequisites line (normally a version
-number) and check the input file to see if that word can be found.
-If not,
-.I patch
-will ask for confirmation before proceeding.
-.PP
-The upshot of all this is that you should be able to say, while in a news
-interface, the following:
-.Sp
- | patch -d /usr/src/local/blurfl
-.Sp
-and patch a file in the blurfl directory directly from the article containing
-the patch.
-.PP
-If the patch file contains more than one patch,
-.I patch
-will try to apply each of them as if they came from separate patch files.
-This means, among other things, that it is assumed that the name of the file
-to patch must be determined for each diff listing,
-and that the garbage before each diff listing will
-be examined for interesting things such as file names and revision level, as
-mentioned previously.
-You can give options (and another original file name) for the second and
-subsequent patches by separating the corresponding argument lists
-by a \*(L'+\*(R'.
-(The argument list for a second or subsequent patch may not specify a new
-patch file, however.)
-.PP
-.I Patch
-recognizes the following options:
-.TP 5
-.B "\-b suff, \-\-suffix=suff"
-causes
-.B suff
-to be interpreted as the backup extension, to be
-used in place of \*(L".orig\*(R" or \*(L"~\*(R".
-.TP 5
-.B "\-B pref, \-\-prefix=pref"
-causes
-.B pref
-to be interpreted as a prefix to the backup file
-name. If this argument is specified, any argument from
-.B \-b
-will be ignored.
-.TP 5
-.B "\-c, \-\-context"
-forces
-.I patch
-to interpret the patch file as a context diff.
-.TP 5
-.B "\-d dir, \-\-directory=dir"
-causes
-.I patch
-to interpret
-.B dir
-as a directory, and cd to it before doing
-anything else.
-.TP 5
-.B "\-D sym, \-\-ifdef=sym"
-causes
-.I patch
-to use the "#ifdef...#endif" construct to mark changes.
-.B sym
-will be used as the differentiating symbol.
-.TP 5
-.B "\-e, \-\-ed"
-forces
-.I patch
-to interpret the patch file as an
-.I ed
-script.
-.TP 5
-.B "\-E, \-\-remove\-empty\-files"
-causes
-.I patch
-to remove output files that are empty after the patches have been applied.
-.TP 5
-.B "\-f, \-\-force"
-forces
-.I patch
-to assume that the user knows exactly what he or she is doing, and to not
-ask any questions. It assumes the following: skip patches for which a
-file to patch can't be found; patch files even though they have the
-wrong version for the ``Prereq:'' line in the patch; and assume that
-patches are not reversed even if they look like they are.
-This option does not suppress commentary; use
-.B \-s
-for that.
-.TP 5
-.B "\-t, \-\-batch"
-similar to
-.BR \-f ,
-in that it suppresses questions, but makes some different assumptions:
-skip patches for which a file to patch can't be found (the same as \fB\-f\fP);
-skip patches for which the file has the wrong version for the ``Prereq:'' line
-in the patch; and assume that patches are reversed if they look like
-they are.
-.TP 5
-.B "\-F number, \-\-fuzz=number"
-sets the maximum fuzz factor.
-This option only applies to context diffs, and causes
-.I patch
-to ignore up to that many lines in looking for places to install a hunk.
-Note that a larger fuzz factor increases the odds of a faulty patch.
-The default fuzz factor is 2, and it may not be set to more than
-the number of lines of context in the context diff, ordinarily 3.
-.TP 5
-.B "\-l, \-\-ignore\-whitespace"
-causes the pattern matching to be done loosely, in case the tabs and
-spaces have been munged in your input file.
-Any sequence of whitespace in the pattern line will match any sequence
-in the input file.
-Normal characters must still match exactly.
-Each line of the context must still match a line in the input file.
-.TP 5
-.B "\-n, \-\-normal"
-forces
-.I patch
-to interpret the patch file as a normal diff.
-.TP 5
-.B "\-N, \-\-forward"
-causes
-.I patch
-to ignore patches that it thinks are reversed or already applied.
-See also
-.B \-R .
-.TP 5
-.B "\-o file, \-\-output=file"
-causes
-.B file
-to be interpreted as the output file name.
-.TP 5
-.B "\-p[number], \-\-strip[=number]"
-sets the pathname strip count,
-which controls how pathnames found in the patch file are treated, in case
-the you keep your files in a different directory than the person who sent
-out the patch.
-The strip count specifies how many slashes are to be stripped from
-the front of the pathname.
-(Any intervening directory names also go away.)
-For example, supposing the file name in the patch file was
-.sp
- /u/howard/src/blurfl/blurfl.c
-.sp
-setting
-.B \-p
-or
-.B \-p0
-gives the entire pathname unmodified,
-.B \-p1
-gives
-.sp
- u/howard/src/blurfl/blurfl.c
-.sp
-without the leading slash,
-.B \-p4
-gives
-.sp
- blurfl/blurfl.c
-.sp
-and not specifying
-.B \-p
-at all just gives you "blurfl.c", unless all of the directories in the
-leading path (u/howard/src/blurfl) exist and that path is relative,
-in which case you get the entire pathname unmodified.
-Whatever you end up with is looked for either in the current directory,
-or the directory specified by the
-.B \-d
-option.
-.TP 5
-.B "\-r file, \-\-reject\-file=file"
-causes
-.B file
-to be interpreted as the reject file name.
-.TP 5
-.B "\-R, \-\-reverse"
-tells
-.I patch
-that this patch was created with the old and new files swapped.
-(Yes, I'm afraid that does happen occasionally, human nature being what it
-is.)
-.I Patch
-will attempt to swap each hunk around before applying it.
-Rejects will come out in the swapped format.
-The
-.B \-R
-option will not work with
-.I ed
-diff scripts because there is too little
-information to reconstruct the reverse operation.
-.Sp
-If the first hunk of a patch fails,
-.I patch
-will reverse the hunk to see if it can be applied that way.
-If it can, you will be asked if you want to have the
-.B \-R
-option set.
-If it can't, the patch will continue to be applied normally.
-(Note: this method cannot detect a reversed patch if it is a normal diff
-and if the first command is an append (i.e. it should have been a delete)
-since appends always succeed, due to the fact that a null context will match
-anywhere.
-Luckily, most patches add or change lines rather than delete them, so most
-reversed normal diffs will begin with a delete, which will fail, triggering
-the heuristic.)
-.TP 5
-.B "\-s, \-\-silent, \-\-quiet"
-makes
-.I patch
-do its work silently, unless an error occurs.
-.TP 5
-.B "\-S, \-\-skip"
-causes
-.I patch
-to ignore this patch from the patch file, but continue on looking
-for the next patch in the file.
-Thus
-.sp
- patch -S + -S + <patchfile
-.sp
-will ignore the first and second of three patches.
-.TP 5
-.B "\-u, \-\-unified"
-forces
-.I patch
-to interpret the patch file as a unified context diff (a unidiff).
-.TP 5
-.B "\-v, \-\-version"
-causes
-.I patch
-to print out its revision header and patch level.
-.TP 5
-.B "\-V method, \-\-version\-\-control=method"
-causes
-.B method
-to be interpreted as a method for creating
-backup file names. The type of backups made can also be given in the
-.B VERSION_CONTROL
-environment variable, which is overridden by this option.
-The
-.B -B
-option overrides this option, causing the prefix to always be used for
-making backup file names.
-The value of the
-.B VERSION_CONTROL
-environment variable and the argument to the
-.B -V
-option are like the GNU
-Emacs `version-control' variable; they also recognize synonyms that
-are more descriptive. The valid values are (unique abbreviations are
-accepted):
-.RS
-.TP
-`t' or `numbered'
-Always make numbered backups.
-.TP
-`nil' or `existing'
-Make numbered backups of files that already
-have them, simple backups of the others.
-This is the default.
-.TP
-`never' or `simple'
-Always make simple backups.
-.RE
-.TP 5
-.B "\-x number, \-\-debug=number"
-sets internal debugging flags, and is of interest only to
-.I patch
-patchers.
-.SH AUTHOR
-Larry Wall <lwall@netlabs.com>
-.br
-with many other contributors.
-.SH ENVIRONMENT
-.TP
-.B TMPDIR
-Directory to put temporary files in; default is /tmp.
-.TP
-.B SIMPLE_BACKUP_SUFFIX
-Extension to use for backup file names instead of \*(L".orig\*(R" or
-\*(L"~\*(R".
-.TP
-.B VERSION_CONTROL
-Selects when numbered backup files are made.
-.SH FILES
-$TMPDIR/patch*
-.SH SEE ALSO
-diff(1)
-.SH NOTES FOR PATCH SENDERS
-There are several things you should bear in mind if you are going to
-be sending out patches.
-First, you can save people a lot of grief by keeping a patchlevel.h file
-which is patched to increment the patch level as the first diff in the
-patch file you send out.
-If you put a Prereq: line in with the patch, it won't let them apply
-patches out of order without some warning.
-Second, make sure you've specified the file names right, either in a
-context diff header, or with an Index: line.
-If you are patching something in a subdirectory, be sure to tell the patch
-user to specify a
-.B \-p
-option as needed.
-Third, you can create a file by sending out a diff that compares a
-null file to the file you want to create.
-This will only work if the file you want to create doesn't exist already in
-the target directory.
-Fourth, take care not to send out reversed patches, since it makes people wonder
-whether they already applied the patch.
-Fifth, while you may be able to get away with putting 582 diff listings into
-one file, it is probably wiser to group related patches into separate files in
-case something goes haywire.
-.SH DIAGNOSTICS
-Too many to list here, but generally indicative that
-.I patch
-couldn't parse your patch file.
-.PP
-The message \*(L"Hmm...\*(R" indicates that there is unprocessed text in
-the patch file and that
-.I patch
-is attempting to intuit whether there is a patch in that text and, if so,
-what kind of patch it is.
-.PP
-.I Patch
-will exit with a non-zero status if any reject files were created.
-When applying a set of patches in a loop it behooves you to check this
-exit status so you don't apply a later patch to a partially patched file.
-.SH CAVEATS
-.I Patch
-cannot tell if the line numbers are off in an
-.I ed
-script, and can only detect
-bad line numbers in a normal diff when it finds a \*(L"change\*(R" or
-a \*(L"delete\*(R" command.
-A context diff using fuzz factor 3 may have the same problem.
-Until a suitable interactive interface is added, you should probably do
-a context diff in these cases to see if the changes made sense.
-Of course, compiling without errors is a pretty good indication that the patch
-worked, but not always.
-.PP
-.I Patch
-usually produces the correct results, even when it has to do a lot of
-guessing.
-However, the results are guaranteed to be correct only when the patch is
-applied to exactly the same version of the file that the patch was
-generated from.
-.SH BUGS
-Could be smarter about partial matches, excessively \&deviant offsets and
-swapped code, but that would take an extra pass.
-.PP
-If code has been duplicated (for instance with #ifdef OLDCODE ... #else ...
-#endif),
-.I patch
-is incapable of patching both versions, and, if it works at all, will likely
-patch the wrong one, and tell you that it succeeded to boot.
-.PP
-If you apply a patch you've already applied,
-.I patch
-will think it is a reversed patch, and offer to un-apply the patch.
-This could be construed as a feature.
-.rn }` ''
diff --git a/gnu/usr.bin/patch/patch.c b/gnu/usr.bin/patch/patch.c
deleted file mode 100644
index 77d98e7..0000000
--- a/gnu/usr.bin/patch/patch.c
+++ /dev/null
@@ -1,945 +0,0 @@
-char rcsid[] =
- "$Header: patch.c,v 2.0.2.0 90/05/01 22:17:50 davison Locked $";
-
-/* patch - a program to apply diffs to original files
- *
- * Copyright 1986, Larry Wall
- *
- * This program may be copied as long as you don't try to make any
- * money off of it, or pretend that you wrote it.
- *
- * $Log: patch.c,v $
- * Revision 2.0.2.0 90/05/01 22:17:50 davison
- * patch12u: unidiff support added
- *
- * Revision 2.0.1.6 88/06/22 20:46:39 lwall
- * patch12: rindex() wasn't declared
- *
- * Revision 2.0.1.5 88/06/03 15:09:37 lwall
- * patch10: exit code improved.
- * patch10: better support for non-flexfilenames.
- *
- * Revision 2.0.1.4 87/02/16 14:00:04 lwall
- * Short replacement caused spurious "Out of sync" message.
- *
- * Revision 2.0.1.3 87/01/30 22:45:50 lwall
- * Improved diagnostic on sync error.
- * Moved do_ed_script() to pch.c.
- *
- * Revision 2.0.1.2 86/11/21 09:39:15 lwall
- * Fuzz factor caused offset of installed lines.
- *
- * Revision 2.0.1.1 86/10/29 13:10:22 lwall
- * Backwards search could terminate prematurely.
- *
- * Revision 2.0 86/09/17 15:37:32 lwall
- * Baseline for netwide release.
- *
- * Revision 1.5 86/08/01 20:53:24 lwall
- * Changed some %d's to %ld's.
- * Linted.
- *
- * Revision 1.4 86/08/01 19:17:29 lwall
- * Fixes for machines that can't vararg.
- * Added fuzz factor.
- * Generalized -p.
- * General cleanup.
- *
- * 85/08/15 van%ucbmonet@berkeley
- * Changes for 4.3bsd diff -c.
- *
- * Revision 1.3 85/03/26 15:07:43 lwall
- * Frozen.
- *
- * Revision 1.2.1.9 85/03/12 17:03:35 lwall
- * Changed pfp->_file to fileno(pfp).
- *
- * Revision 1.2.1.8 85/03/12 16:30:43 lwall
- * Check i_ptr and i_womp to make sure they aren't null before freeing.
- * Also allow ed output to be suppressed.
- *
- * Revision 1.2.1.7 85/03/12 15:56:13 lwall
- * Added -p option from jromine@uci-750a.
- *
- * Revision 1.2.1.6 85/03/12 12:12:51 lwall
- * Now checks for normalness of file to patch.
- *
- * Revision 1.2.1.5 85/03/12 11:52:12 lwall
- * Added -D (#ifdef) option from joe@fluke.
- *
- * Revision 1.2.1.4 84/12/06 11:14:15 lwall
- * Made smarter about SCCS subdirectories.
- *
- * Revision 1.2.1.3 84/12/05 11:18:43 lwall
- * Added -l switch to do loose string comparison.
- *
- * Revision 1.2.1.2 84/12/04 09:47:13 lwall
- * Failed hunk count not reset on multiple patch file.
- *
- * Revision 1.2.1.1 84/12/04 09:42:37 lwall
- * Branch for sdcrdcf changes.
- *
- * Revision 1.2 84/11/29 13:29:51 lwall
- * Linted. Identifiers uniqified. Fixed i_ptr malloc() bug. Fixed
- * multiple calls to mktemp(). Will now work on machines that can only
- * read 32767 chars. Added -R option for diffs with new and old swapped.
- * Various cosmetic changes.
- *
- * Revision 1.1 84/11/09 17:03:58 lwall
- * Initial revision
- *
- */
-
-#include "INTERN.h"
-#include "common.h"
-#include "EXTERN.h"
-#include "version.h"
-#include "util.h"
-#include "pch.h"
-#include "inp.h"
-#include "backupfile.h"
-#include "getopt.h"
-
-/* procedures */
-
-void reinitialize_almost_everything();
-void get_some_switches();
-LINENUM locate_hunk();
-void abort_hunk();
-void apply_hunk();
-void init_output();
-void init_reject();
-void copy_till();
-void spew_output();
-void dump_line();
-bool patch_match();
-bool similar();
-void re_input();
-void my_exit();
-
-/* TRUE if -E was specified on command line. */
-static int remove_empty_files = FALSE;
-
-/* TRUE if -R was specified on command line. */
-static int reverse_flag_specified = FALSE;
-
-/* Apply a set of diffs as appropriate. */
-
-int
-main(argc,argv)
-int argc;
-char **argv;
-{
- LINENUM where;
- LINENUM newwhere;
- LINENUM fuzz;
- LINENUM mymaxfuzz;
- int hunk = 0;
- int failed = 0;
- int failtotal = 0;
- bool rev_okayed = 0;
- int i;
-
- setbuf(stderr, serrbuf);
- for (i = 0; i<MAXFILEC; i++)
- filearg[i] = Nullch;
-
- myuid = getuid();
-
- /* Cons up the names of the temporary files. */
- {
- /* Directory for temporary files. */
- char *tmpdir;
- int tmpname_len;
-
- tmpdir = getenv ("TMPDIR");
- if (tmpdir == NULL) {
- tmpdir = "/tmp";
- }
- tmpname_len = strlen (tmpdir) + 20;
-
- TMPOUTNAME = (char *) malloc (tmpname_len);
- strcpy (TMPOUTNAME, tmpdir);
- strcat (TMPOUTNAME, "/patchoXXXXXX");
- Mktemp(TMPOUTNAME);
-
- TMPINNAME = (char *) malloc (tmpname_len);
- strcpy (TMPINNAME, tmpdir);
- strcat (TMPINNAME, "/patchiXXXXXX");
- Mktemp(TMPINNAME);
-
- TMPREJNAME = (char *) malloc (tmpname_len);
- strcpy (TMPREJNAME, tmpdir);
- strcat (TMPREJNAME, "/patchrXXXXXX");
- Mktemp(TMPREJNAME);
-
- TMPPATNAME = (char *) malloc (tmpname_len);
- strcpy (TMPPATNAME, tmpdir);
- strcat (TMPPATNAME, "/patchpXXXXXX");
- Mktemp(TMPPATNAME);
- }
-
- {
- char *v;
-
- v = getenv ("SIMPLE_BACKUP_SUFFIX");
- if (v)
- simple_backup_suffix = v;
- else
- simple_backup_suffix = ".orig";
-#ifndef NODIR
- v = getenv ("VERSION_CONTROL");
- backup_type = get_version (v); /* OK to pass NULL. */
-#endif
- }
-
- /* parse switches */
- Argc = argc;
- Argv = argv;
- get_some_switches();
-
- /* make sure we clean up /tmp in case of disaster */
- set_signals(0);
-
- for (
- open_patch_file(filearg[1]);
- there_is_another_patch();
- reinitialize_almost_everything()
- ) { /* for each patch in patch file */
-
- if (outname == Nullch)
- outname = savestr(filearg[0]);
-
- /* for ed script just up and do it and exit */
- if (diff_type == ED_DIFF) {
- do_ed_script();
- continue;
- }
-
- /* initialize the patched file */
- if (!skip_rest_of_patch)
- init_output(TMPOUTNAME);
-
- /* initialize reject file */
- init_reject(TMPREJNAME);
-
- /* find out where all the lines are */
- if (!skip_rest_of_patch)
- scan_input(filearg[0]);
-
- /* from here on, open no standard i/o files, because malloc */
- /* might misfire and we can't catch it easily */
-
- /* apply each hunk of patch */
- hunk = 0;
- failed = 0;
- rev_okayed = FALSE;
- out_of_mem = FALSE;
- while (another_hunk()) {
- hunk++;
- fuzz = Nulline;
- mymaxfuzz = pch_context();
- if (maxfuzz < mymaxfuzz)
- mymaxfuzz = maxfuzz;
- if (!skip_rest_of_patch) {
- do {
- where = locate_hunk(fuzz);
- if (hunk == 1 && where == Nulline && !(force|rev_okayed)) {
- /* dwim for reversed patch? */
- if (!pch_swap()) {
- if (fuzz == Nulline)
- say1(
-"Not enough memory to try swapped hunk! Assuming unswapped.\n");
- continue;
- }
- reverse = !reverse;
- where = locate_hunk(fuzz); /* try again */
- if (where == Nulline) { /* didn't find it swapped */
- if (!pch_swap()) /* put it back to normal */
- fatal1("lost hunk on alloc error!\n");
- reverse = !reverse;
- }
- else if (noreverse) {
- if (!pch_swap()) /* put it back to normal */
- fatal1("lost hunk on alloc error!\n");
- reverse = !reverse;
- say1(
-"Ignoring previously applied (or reversed) patch.\n");
- skip_rest_of_patch = TRUE;
- }
- else if (batch) {
- if (verbose)
- say3(
-"%seversed (or previously applied) patch detected! %s -R.",
- reverse ? "R" : "Unr",
- reverse ? "Assuming" : "Ignoring");
- }
- else {
- ask3(
-"%seversed (or previously applied) patch detected! %s -R? [y] ",
- reverse ? "R" : "Unr",
- reverse ? "Assume" : "Ignore");
- if (*buf == 'n') {
- ask1("Apply anyway? [n] ");
- if (*buf == 'y')
- rev_okayed = TRUE;
- else
- skip_rest_of_patch = TRUE;
- where = Nulline;
- reverse = !reverse;
- if (!pch_swap()) /* put it back to normal */
- fatal1("lost hunk on alloc error!\n");
- }
- }
- }
- } while (!skip_rest_of_patch && where == Nulline &&
- ++fuzz <= mymaxfuzz);
-
- if (skip_rest_of_patch) { /* just got decided */
- Fclose(ofp);
- ofp = Nullfp;
- }
- }
-
- newwhere = pch_newfirst() + last_offset;
- if (skip_rest_of_patch) {
- abort_hunk();
- failed++;
- if (verbose)
- say3("Hunk #%d ignored at %ld.\n", hunk, newwhere);
- }
- else if (where == Nulline) {
- abort_hunk();
- failed++;
- if (verbose)
- say3("Hunk #%d failed at %ld.\n", hunk, newwhere);
- }
- else {
- apply_hunk(where);
- if (verbose) {
- say3("Hunk #%d succeeded at %ld", hunk, newwhere);
- if (fuzz)
- say2(" with fuzz %ld", fuzz);
- if (last_offset)
- say3(" (offset %ld line%s)",
- last_offset, last_offset==1L?"":"s");
- say1(".\n");
- }
- }
- }
-
- if (out_of_mem && using_plan_a) {
- optind = optind_last;
- say1("\n\nRan out of memory using Plan A--trying again...\n\n");
- if (ofp)
- Fclose(ofp);
- ofp = Nullfp;
- if (rejfp)
- Fclose(rejfp);
- rejfp = Nullfp;
- continue;
- }
-
- assert(hunk);
-
- /* finish spewing out the new file */
- if (!skip_rest_of_patch)
- spew_output();
-
- /* and put the output where desired */
- ignore_signals();
- if (!skip_rest_of_patch) {
- struct stat statbuf;
- char *realout = outname;
-
- if (move_file(TMPOUTNAME, outname) < 0) {
- toutkeep = TRUE;
- realout = TMPOUTNAME;
- chmod(TMPOUTNAME, filemode);
- }
- else
- chmod(outname, filemode);
-
- if (remove_empty_files && stat(realout, &statbuf) == 0
- && statbuf.st_size == 0) {
- if (verbose)
- say2("Removing %s (empty after patching).\n", realout);
- while (unlink(realout) >= 0) ; /* while is for Eunice. */
- }
- }
- Fclose(rejfp);
- rejfp = Nullfp;
- if (failed) {
- failtotal += failed;
- if (!*rejname) {
- Strcpy(rejname, outname);
- addext(rejname, ".rej", '#');
- }
- if (skip_rest_of_patch) {
- say4("%d out of %d hunks ignored--saving rejects to %s\n",
- failed, hunk, rejname);
- }
- else {
- say4("%d out of %d hunks failed--saving rejects to %s\n",
- failed, hunk, rejname);
- }
- if (move_file(TMPREJNAME, rejname) < 0)
- trejkeep = TRUE;
- }
- set_signals(1);
- }
- my_exit(failtotal);
-}
-
-/* Prepare to find the next patch to do in the patch file. */
-
-void
-reinitialize_almost_everything()
-{
- re_patch();
- re_input();
-
- input_lines = 0;
- last_frozen_line = 0;
-
- filec = 0;
- if (filearg[0] != Nullch && !out_of_mem) {
- free(filearg[0]);
- filearg[0] = Nullch;
- }
-
- if (outname != Nullch) {
- free(outname);
- outname = Nullch;
- }
-
- last_offset = 0;
-
- diff_type = 0;
-
- if (revision != Nullch) {
- free(revision);
- revision = Nullch;
- }
-
- reverse = reverse_flag_specified;
- skip_rest_of_patch = FALSE;
-
- get_some_switches();
-
- if (filec >= 2)
- fatal1("you may not change to a different patch file\n");
-}
-
-static char *shortopts = "-b:B:cd:D:eEfF:lnNo:p::r:RsStuvV:x:";
-static struct option longopts[] =
-{
- {"suffix", 1, NULL, 'b'},
- {"prefix", 1, NULL, 'B'},
- {"context", 0, NULL, 'c'},
- {"directory", 1, NULL, 'd'},
- {"ifdef", 1, NULL, 'D'},
- {"ed", 0, NULL, 'e'},
- {"remove-empty-files", 0, NULL, 'E'},
- {"force", 0, NULL, 'f'},
- {"fuzz", 1, NULL, 'F'},
- {"ignore-whitespace", 0, NULL, 'l'},
- {"normal", 0, NULL, 'n'},
- {"forward", 0, NULL, 'N'},
- {"output", 1, NULL, 'o'},
- {"strip", 2, NULL, 'p'},
- {"reject-file", 1, NULL, 'r'},
- {"reverse", 0, NULL, 'R'},
- {"quiet", 0, NULL, 's'},
- {"silent", 0, NULL, 's'},
- {"skip", 0, NULL, 'S'},
- {"batch", 0, NULL, 't'},
- {"unified", 0, NULL, 'u'},
- {"version", 0, NULL, 'v'},
- {"version-control", 1, NULL, 'V'},
- {"debug", 1, NULL, 'x'},
- {0, 0, 0, 0}
-};
-
-/* Process switches and filenames up to next '+' or end of list. */
-
-void
-get_some_switches()
-{
- Reg1 int optc;
-
- rejname[0] = '\0';
- optind_last = optind;
- if (optind == Argc)
- return;
- while ((optc = getopt_long (Argc, Argv, shortopts, longopts, (int *) 0))
- != -1) {
- if (optc == 1) {
- if (strEQ(optarg, "+"))
- return;
- if (filec == MAXFILEC)
- fatal1("too many file arguments\n");
- filearg[filec++] = savestr(optarg);
- }
- else {
- switch (optc) {
- case 'b':
- simple_backup_suffix = savestr(optarg);
- break;
- case 'B':
- origprae = savestr(optarg);
- break;
- case 'c':
- diff_type = CONTEXT_DIFF;
- break;
- case 'd':
- if (chdir(optarg) < 0)
- pfatal2("can't cd to %s", optarg);
- break;
- case 'D':
- do_defines = TRUE;
- if (!isalpha(*optarg) && '_' != *optarg)
- fatal1("argument to -D is not an identifier\n");
- Sprintf(if_defined, "#ifdef %s\n", optarg);
- Sprintf(not_defined, "#ifndef %s\n", optarg);
- Sprintf(end_defined, "#endif /* %s */\n", optarg);
- break;
- case 'e':
- diff_type = ED_DIFF;
- break;
- case 'E':
- remove_empty_files = TRUE;
- break;
- case 'f':
- force = TRUE;
- break;
- case 'F':
- maxfuzz = atoi(optarg);
- break;
- case 'l':
- canonicalize = TRUE;
- break;
- case 'n':
- diff_type = NORMAL_DIFF;
- break;
- case 'N':
- noreverse = TRUE;
- break;
- case 'o':
- outname = savestr(optarg);
- break;
- case 'p':
- if (optarg)
- strippath = atoi(optarg);
- else
- strippath = 0;
- break;
- case 'r':
- Strcpy(rejname, optarg);
- break;
- case 'R':
- reverse = TRUE;
- reverse_flag_specified = TRUE;
- break;
- case 's':
- verbose = FALSE;
- break;
- case 'S':
- skip_rest_of_patch = TRUE;
- break;
- case 't':
- batch = TRUE;
- break;
- case 'u':
- diff_type = UNI_DIFF;
- break;
- case 'v':
- version();
- break;
- case 'V':
-#ifndef NODIR
- backup_type = get_version (optarg);
-#endif
- break;
-#ifdef DEBUGGING
- case 'x':
- debug = atoi(optarg);
- break;
-#endif
- default:
- fprintf(stderr, "\
-Usage: %s [options] [origfile [patchfile]] [+ [options] [origfile]]...\n",
- Argv[0]);
- fprintf(stderr, "\
-Options:\n\
- [-ceEflnNRsStuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
- [-D symbol] [-F max-fuzz] [-o out-file] [-p[strip-count]]\n\
- [-r rej-name] [-V {numbered,existing,simple}] [--context]\n\
- [--prefix=backup-prefix] [--suffix=backup-ext] [--ifdef=symbol]\n\
- [--directory=directory] [--ed] [--fuzz=max-fuzz] [--force] [--batch]\n\
- [--ignore-whitespace] [--forward] [--reverse] [--output=out-file]\n");
- fprintf(stderr, "\
- [--strip[=strip-count]] [--normal] [--reject-file=rej-name] [--skip]\n\
- [--remove-empty-files] [--quiet] [--silent] [--unified] [--version]\n\
- [--version-control={numbered,existing,simple}]\n");
- my_exit(1);
- }
- }
- }
-
- /* Process any filename args given after "--". */
- for (; optind < Argc; ++optind) {
- if (filec == MAXFILEC)
- fatal1("too many file arguments\n");
- filearg[filec++] = savestr(Argv[optind]);
- }
-}
-
-/* Attempt to find the right place to apply this hunk of patch. */
-
-LINENUM
-locate_hunk(fuzz)
-LINENUM fuzz;
-{
- Reg1 LINENUM first_guess = pch_first() + last_offset;
- Reg2 LINENUM offset;
- LINENUM pat_lines = pch_ptrn_lines();
- Reg3 LINENUM max_pos_offset = input_lines - first_guess
- - pat_lines + 1;
- Reg4 LINENUM max_neg_offset = first_guess - last_frozen_line - 1
- + pch_context();
-
- if (!pat_lines) /* null range matches always */
- return first_guess;
- if (max_neg_offset >= first_guess) /* do not try lines < 0 */
- max_neg_offset = first_guess - 1;
- if (first_guess <= input_lines && patch_match(first_guess, Nulline, fuzz))
- return first_guess;
- for (offset = 1; ; offset++) {
- Reg5 bool check_after = (offset <= max_pos_offset);
- Reg6 bool check_before = (offset <= max_neg_offset);
-
- if (check_after && patch_match(first_guess, offset, fuzz)) {
-#ifdef DEBUGGING
- if (debug & 1)
- say3("Offset changing from %ld to %ld\n", last_offset, offset);
-#endif
- last_offset = offset;
- return first_guess+offset;
- }
- else if (check_before && patch_match(first_guess, -offset, fuzz)) {
-#ifdef DEBUGGING
- if (debug & 1)
- say3("Offset changing from %ld to %ld\n", last_offset, -offset);
-#endif
- last_offset = -offset;
- return first_guess-offset;
- }
- else if (!check_before && !check_after)
- return Nulline;
- }
-}
-
-/* We did not find the pattern, dump out the hunk so they can handle it. */
-
-void
-abort_hunk()
-{
- Reg1 LINENUM i;
- Reg2 LINENUM pat_end = pch_end();
- /* add in last_offset to guess the same as the previous successful hunk */
- LINENUM oldfirst = pch_first() + last_offset;
- LINENUM newfirst = pch_newfirst() + last_offset;
- LINENUM oldlast = oldfirst + pch_ptrn_lines() - 1;
- LINENUM newlast = newfirst + pch_repl_lines() - 1;
- char *stars = (diff_type >= NEW_CONTEXT_DIFF ? " ****" : "");
- char *minuses = (diff_type >= NEW_CONTEXT_DIFF ? " ----" : " -----");
-
- fprintf(rejfp, "***************\n");
- for (i=0; i<=pat_end; i++) {
- switch (pch_char(i)) {
- case '*':
- if (oldlast < oldfirst)
- fprintf(rejfp, "*** 0%s\n", stars);
- else if (oldlast == oldfirst)
- fprintf(rejfp, "*** %ld%s\n", oldfirst, stars);
- else
- fprintf(rejfp, "*** %ld,%ld%s\n", oldfirst, oldlast, stars);
- break;
- case '=':
- if (newlast < newfirst)
- fprintf(rejfp, "--- 0%s\n", minuses);
- else if (newlast == newfirst)
- fprintf(rejfp, "--- %ld%s\n", newfirst, minuses);
- else
- fprintf(rejfp, "--- %ld,%ld%s\n", newfirst, newlast, minuses);
- break;
- case '\n':
- fprintf(rejfp, "%s", pfetch(i));
- break;
- case ' ': case '-': case '+': case '!':
- fprintf(rejfp, "%c %s", pch_char(i), pfetch(i));
- break;
- default:
- fatal1("fatal internal error in abort_hunk\n");
- }
- }
-}
-
-/* We found where to apply it (we hope), so do it. */
-
-void
-apply_hunk(where)
-LINENUM where;
-{
- Reg1 LINENUM old = 1;
- Reg2 LINENUM lastline = pch_ptrn_lines();
- Reg3 LINENUM new = lastline+1;
-#define OUTSIDE 0
-#define IN_IFNDEF 1
-#define IN_IFDEF 2
-#define IN_ELSE 3
- Reg4 int def_state = OUTSIDE;
- Reg5 bool R_do_defines = do_defines;
- Reg6 LINENUM pat_end = pch_end();
-
- where--;
- while (pch_char(new) == '=' || pch_char(new) == '\n')
- new++;
-
- while (old <= lastline) {
- if (pch_char(old) == '-') {
- copy_till(where + old - 1);
- if (R_do_defines) {
- if (def_state == OUTSIDE) {
- fputs(not_defined, ofp);
- def_state = IN_IFNDEF;
- }
- else if (def_state == IN_IFDEF) {
- fputs(else_defined, ofp);
- def_state = IN_ELSE;
- }
- fputs(pfetch(old), ofp);
- }
- last_frozen_line++;
- old++;
- }
- else if (new > pat_end) {
- break;
- }
- else if (pch_char(new) == '+') {
- copy_till(where + old - 1);
- if (R_do_defines) {
- if (def_state == IN_IFNDEF) {
- fputs(else_defined, ofp);
- def_state = IN_ELSE;
- }
- else if (def_state == OUTSIDE) {
- fputs(if_defined, ofp);
- def_state = IN_IFDEF;
- }
- }
- fputs(pfetch(new), ofp);
- new++;
- }
- else if (pch_char(new) != pch_char(old)) {
- say3("Out-of-sync patch, lines %ld,%ld--mangled text or line numbers, maybe?\n",
- pch_hunk_beg() + old,
- pch_hunk_beg() + new);
-#ifdef DEBUGGING
- say3("oldchar = '%c', newchar = '%c'\n",
- pch_char(old), pch_char(new));
-#endif
- my_exit(1);
- }
- else if (pch_char(new) == '!') {
- copy_till(where + old - 1);
- if (R_do_defines) {
- fputs(not_defined, ofp);
- def_state = IN_IFNDEF;
- }
- while (pch_char(old) == '!') {
- if (R_do_defines) {
- fputs(pfetch(old), ofp);
- }
- last_frozen_line++;
- old++;
- }
- if (R_do_defines) {
- fputs(else_defined, ofp);
- def_state = IN_ELSE;
- }
- while (pch_char(new) == '!') {
- fputs(pfetch(new), ofp);
- new++;
- }
- }
- else {
- assert(pch_char(new) == ' ');
- old++;
- new++;
- if (R_do_defines && def_state != OUTSIDE) {
- fputs(end_defined, ofp);
- def_state = OUTSIDE;
- }
- }
- }
- if (new <= pat_end && pch_char(new) == '+') {
- copy_till(where + old - 1);
- if (R_do_defines) {
- if (def_state == OUTSIDE) {
- fputs(if_defined, ofp);
- def_state = IN_IFDEF;
- }
- else if (def_state == IN_IFNDEF) {
- fputs(else_defined, ofp);
- def_state = IN_ELSE;
- }
- }
- while (new <= pat_end && pch_char(new) == '+') {
- fputs(pfetch(new), ofp);
- new++;
- }
- }
- if (R_do_defines && def_state != OUTSIDE) {
- fputs(end_defined, ofp);
- }
-}
-
-/* Open the new file. */
-
-void
-init_output(name)
-char *name;
-{
- ofp = fopen(name, "w");
- if (ofp == Nullfp)
- pfatal2("can't create %s", name);
-}
-
-/* Open a file to put hunks we can't locate. */
-
-void
-init_reject(name)
-char *name;
-{
- rejfp = fopen(name, "w");
- if (rejfp == Nullfp)
- pfatal2("can't create %s", name);
-}
-
-/* Copy input file to output, up to wherever hunk is to be applied. */
-
-void
-copy_till(lastline)
-Reg1 LINENUM lastline;
-{
- Reg2 LINENUM R_last_frozen_line = last_frozen_line;
-
- if (R_last_frozen_line > lastline)
- fatal1("misordered hunks! output would be garbled\n");
- while (R_last_frozen_line < lastline) {
- dump_line(++R_last_frozen_line);
- }
- last_frozen_line = R_last_frozen_line;
-}
-
-/* Finish copying the input file to the output file. */
-
-void
-spew_output()
-{
-#ifdef DEBUGGING
- if (debug & 256)
- say3("il=%ld lfl=%ld\n",input_lines,last_frozen_line);
-#endif
- if (input_lines)
- copy_till(input_lines); /* dump remainder of file */
- Fclose(ofp);
- ofp = Nullfp;
-}
-
-/* Copy one line from input to output. */
-
-void
-dump_line(line)
-LINENUM line;
-{
- Reg1 char *s;
- Reg2 char R_newline = '\n';
-
- /* Note: string is not null terminated. */
- for (s=ifetch(line, 0); putc(*s, ofp) != R_newline; s++) ;
-}
-
-/* Does the patch pattern match at line base+offset? */
-
-bool
-patch_match(base, offset, fuzz)
-LINENUM base;
-LINENUM offset;
-LINENUM fuzz;
-{
- Reg1 LINENUM pline = 1 + fuzz;
- Reg2 LINENUM iline;
- Reg3 LINENUM pat_lines = pch_ptrn_lines() - fuzz;
-
- for (iline=base+offset+fuzz; pline <= pat_lines; pline++,iline++) {
- if (canonicalize) {
- if (!similar(ifetch(iline, (offset >= 0)),
- pfetch(pline),
- pch_line_len(pline) ))
- return FALSE;
- }
- else if (strnNE(ifetch(iline, (offset >= 0)),
- pfetch(pline),
- pch_line_len(pline) ))
- return FALSE;
- }
- return TRUE;
-}
-
-/* Do two lines match with canonicalized white space? */
-
-bool
-similar(a,b,len)
-Reg1 char *a;
-Reg2 char *b;
-Reg3 int len;
-{
- while (len) {
- if (isspace(*b)) { /* whitespace (or \n) to match? */
- if (!isspace(*a)) /* no corresponding whitespace? */
- return FALSE;
- while (len && isspace(*b) && *b != '\n')
- b++,len--; /* skip pattern whitespace */
- while (isspace(*a) && *a != '\n')
- a++; /* skip target whitespace */
- if (*a == '\n' || *b == '\n')
- return (*a == *b); /* should end in sync */
- }
- else if (*a++ != *b++) /* match non-whitespace chars */
- return FALSE;
- else
- len--; /* probably not necessary */
- }
- return TRUE; /* actually, this is not reached */
- /* since there is always a \n */
-}
-
-/* Exit with cleanup. */
-
-void
-my_exit(status)
-int status;
-{
- Unlink(TMPINNAME);
- if (!toutkeep) {
- Unlink(TMPOUTNAME);
- }
- if (!trejkeep) {
- Unlink(TMPREJNAME);
- }
- Unlink(TMPPATNAME);
- exit(status);
-}
diff --git a/gnu/usr.bin/patch/patchlevel.h b/gnu/usr.bin/patch/patchlevel.h
deleted file mode 100644
index d5de3a9..0000000
--- a/gnu/usr.bin/patch/patchlevel.h
+++ /dev/null
@@ -1 +0,0 @@
-#define PATCH_VERSION "2.1"
diff --git a/gnu/usr.bin/patch/pch.c b/gnu/usr.bin/patch/pch.c
deleted file mode 100644
index 6b7d77d..0000000
--- a/gnu/usr.bin/patch/pch.c
+++ /dev/null
@@ -1,1305 +0,0 @@
-/* $Header: pch.c,v 2.0.1.7 88/06/03 15:13:28 lwall Locked $
- *
- * $Log: pch.c,v $
- * Revision 2.0.2.0 90/05/01 22:17:51 davison
- * patch12u: unidiff support added
- *
- * Revision 2.0.1.7 88/06/03 15:13:28 lwall
- * patch10: Can now find patches in shar scripts.
- * patch10: Hunks that swapped and then swapped back could core dump.
- *
- * Revision 2.0.1.6 87/06/04 16:18:13 lwall
- * pch_swap didn't swap p_bfake and p_efake.
- *
- * Revision 2.0.1.5 87/01/30 22:47:42 lwall
- * Improved responses to mangled patches.
- *
- * Revision 2.0.1.4 87/01/05 16:59:53 lwall
- * New-style context diffs caused double call to free().
- *
- * Revision 2.0.1.3 86/11/14 10:08:33 lwall
- * Fixed problem where a long pattern wouldn't grow the hunk.
- * Also restored p_input_line when backtracking so error messages are right.
- *
- * Revision 2.0.1.2 86/11/03 17:49:52 lwall
- * New-style delete triggers spurious assertion error.
- *
- * Revision 2.0.1.1 86/10/29 15:52:08 lwall
- * Could falsely report new-style context diff.
- *
- * Revision 2.0 86/09/17 15:39:37 lwall
- * Baseline for netwide release.
- *
- */
-
-#include "EXTERN.h"
-#include "common.h"
-#include "util.h"
-#include "INTERN.h"
-#include "pch.h"
-
-/* Patch (diff listing) abstract type. */
-
-static long p_filesize; /* size of the patch file */
-static LINENUM p_first; /* 1st line number */
-static LINENUM p_newfirst; /* 1st line number of replacement */
-static LINENUM p_ptrn_lines; /* # lines in pattern */
-static LINENUM p_repl_lines; /* # lines in replacement text */
-static LINENUM p_end = -1; /* last line in hunk */
-static LINENUM p_max; /* max allowed value of p_end */
-static LINENUM p_context = 3; /* # of context lines */
-static LINENUM p_input_line = 0; /* current line # from patch file */
-static char **p_line = Null(char**); /* the text of the hunk */
-static short *p_len = Null(short*); /* length of each line */
-static char *p_Char = Nullch; /* +, -, and ! */
-static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */
-static int p_indent; /* indent to patch */
-static LINENUM p_base; /* where to intuit this time */
-static LINENUM p_bline; /* line # of p_base */
-static LINENUM p_start; /* where intuit found a patch */
-static LINENUM p_sline; /* and the line number for it */
-static LINENUM p_hunk_beg; /* line number of current hunk */
-static LINENUM p_efake = -1; /* end of faked up lines--don't free */
-static LINENUM p_bfake = -1; /* beg of faked up lines */
-
-/* Prepare to look for the next patch in the patch file. */
-
-void
-re_patch()
-{
- p_first = Nulline;
- p_newfirst = Nulline;
- p_ptrn_lines = Nulline;
- p_repl_lines = Nulline;
- p_end = (LINENUM)-1;
- p_max = Nulline;
- p_indent = 0;
-}
-
-/* Open the patch file at the beginning of time. */
-
-void
-open_patch_file(filename)
-char *filename;
-{
- if (filename == Nullch || !*filename || strEQ(filename, "-")) {
- pfp = fopen(TMPPATNAME, "w");
- if (pfp == Nullfp)
- pfatal2("can't create %s", TMPPATNAME);
- while (fgets(buf, sizeof buf, stdin) != Nullch)
- fputs(buf, pfp);
- Fclose(pfp);
- filename = TMPPATNAME;
- }
- pfp = fopen(filename, "r");
- if (pfp == Nullfp)
- pfatal2("patch file %s not found", filename);
- Fstat(fileno(pfp), &filestat);
- p_filesize = filestat.st_size;
- next_intuit_at(0L,1L); /* start at the beginning */
- set_hunkmax();
-}
-
-/* Make sure our dynamically realloced tables are malloced to begin with. */
-
-void
-set_hunkmax()
-{
-#ifndef lint
- if (p_line == Null(char**))
- p_line = (char**) malloc((MEM)hunkmax * sizeof(char *));
- if (p_len == Null(short*))
- p_len = (short*) malloc((MEM)hunkmax * sizeof(short));
-#endif
- if (p_Char == Nullch)
- p_Char = (char*) malloc((MEM)hunkmax * sizeof(char));
-}
-
-/* Enlarge the arrays containing the current hunk of patch. */
-
-void
-grow_hunkmax()
-{
- hunkmax *= 2;
- /*
- * Note that on most systems, only the p_line array ever gets fresh memory
- * since p_len can move into p_line's old space, and p_Char can move into
- * p_len's old space. Not on PDP-11's however. But it doesn't matter.
- */
- assert(p_line != Null(char**) && p_len != Null(short*) && p_Char != Nullch);
-#ifndef lint
- p_line = (char**) realloc((char*)p_line, (MEM)hunkmax * sizeof(char *));
- p_len = (short*) realloc((char*)p_len, (MEM)hunkmax * sizeof(short));
- p_Char = (char*) realloc((char*)p_Char, (MEM)hunkmax * sizeof(char));
-#endif
- if (p_line != Null(char**) && p_len != Null(short*) && p_Char != Nullch)
- return;
- if (!using_plan_a)
- fatal1("out of memory\n");
- out_of_mem = TRUE; /* whatever is null will be allocated again */
- /* from within plan_a(), of all places */
-}
-
-/* True if the remainder of the patch file contains a diff of some sort. */
-
-bool
-there_is_another_patch()
-{
- if (p_base != 0L && p_base >= p_filesize) {
- if (verbose)
- say1("done\n");
- return FALSE;
- }
- if (verbose)
- say1("Hmm...");
- diff_type = intuit_diff_type();
- if (!diff_type) {
- if (p_base != 0L) {
- if (verbose)
- say1(" Ignoring the trailing garbage.\ndone\n");
- }
- else
- say1(" I can't seem to find a patch in there anywhere.\n");
- return FALSE;
- }
- if (verbose)
- say3(" %sooks like %s to me...\n",
- (p_base == 0L ? "L" : "The next patch l"),
- diff_type == UNI_DIFF ? "a unified diff" :
- diff_type == CONTEXT_DIFF ? "a context diff" :
- diff_type == NEW_CONTEXT_DIFF ? "a new-style context diff" :
- diff_type == NORMAL_DIFF ? "a normal diff" :
- "an ed script" );
- if (p_indent && verbose)
- say3("(Patch is indented %d space%s.)\n", p_indent, p_indent==1?"":"s");
- skip_to(p_start,p_sline);
- while (filearg[0] == Nullch) {
- if (force || batch) {
- say1("No file to patch. Skipping...\n");
- filearg[0] = savestr(bestguess);
- return TRUE;
- }
- ask1("File to patch: ");
- if (*buf != '\n') {
- if (bestguess)
- free(bestguess);
- bestguess = savestr(buf);
- filearg[0] = fetchname(buf, 0, FALSE);
- }
- if (filearg[0] == Nullch) {
- ask1("No file found--skip this patch? [n] ");
- if (*buf != 'y') {
- continue;
- }
- if (verbose)
- say1("Skipping patch...\n");
- filearg[0] = fetchname(bestguess, 0, TRUE);
- skip_rest_of_patch = TRUE;
- return TRUE;
- }
- }
- return TRUE;
-}
-
-/* Determine what kind of diff is in the remaining part of the patch file. */
-
-int
-intuit_diff_type()
-{
- Reg4 long this_line = 0;
- Reg5 long previous_line;
- Reg6 long first_command_line = -1;
- long fcl_line;
- Reg7 bool last_line_was_command = FALSE;
- Reg8 bool this_is_a_command = FALSE;
- Reg9 bool stars_last_line = FALSE;
- Reg10 bool stars_this_line = FALSE;
- Reg3 int indent;
- Reg1 char *s;
- Reg2 char *t;
- char *indtmp = Nullch;
- char *oldtmp = Nullch;
- char *newtmp = Nullch;
- char *indname = Nullch;
- char *oldname = Nullch;
- char *newname = Nullch;
- Reg11 int retval;
- bool no_filearg = (filearg[0] == Nullch);
-
- ok_to_create_file = FALSE;
- Fseek(pfp, p_base, 0);
- p_input_line = p_bline - 1;
- for (;;) {
- previous_line = this_line;
- last_line_was_command = this_is_a_command;
- stars_last_line = stars_this_line;
- this_line = ftell(pfp);
- indent = 0;
- p_input_line++;
- if (fgets(buf, sizeof buf, pfp) == Nullch) {
- if (first_command_line >= 0L) {
- /* nothing but deletes!? */
- p_start = first_command_line;
- p_sline = fcl_line;
- retval = ED_DIFF;
- goto scan_exit;
- }
- else {
- p_start = this_line;
- p_sline = p_input_line;
- retval = 0;
- goto scan_exit;
- }
- }
- for (s = buf; *s == ' ' || *s == '\t' || *s == 'X'; s++) {
- if (*s == '\t')
- indent += 8 - (indent % 8);
- else
- indent++;
- }
- for (t=s; isdigit(*t) || *t == ','; t++) ;
- this_is_a_command = (isdigit(*s) &&
- (*t == 'd' || *t == 'c' || *t == 'a') );
- if (first_command_line < 0L && this_is_a_command) {
- first_command_line = this_line;
- fcl_line = p_input_line;
- p_indent = indent; /* assume this for now */
- }
- if (!stars_last_line && strnEQ(s, "*** ", 4))
- oldtmp = savestr(s+4);
- else if (strnEQ(s, "--- ", 4))
- newtmp = savestr(s+4);
- else if (strnEQ(s, "+++ ", 4))
- oldtmp = savestr(s+4); /* pretend it is the old name */
- else if (strnEQ(s, "Index:", 6))
- indtmp = savestr(s+6);
- else if (strnEQ(s, "Prereq:", 7)) {
- for (t=s+7; isspace(*t); t++) ;
- revision = savestr(t);
- for (t=revision; *t && !isspace(*t); t++) ;
- *t = '\0';
- if (!*revision) {
- free(revision);
- revision = Nullch;
- }
- }
- if ((!diff_type || diff_type == ED_DIFF) &&
- first_command_line >= 0L &&
- strEQ(s, ".\n") ) {
- p_indent = indent;
- p_start = first_command_line;
- p_sline = fcl_line;
- retval = ED_DIFF;
- goto scan_exit;
- }
- if ((!diff_type || diff_type == UNI_DIFF) && strnEQ(s, "@@ -", 4)) {
- if (!atol(s+3))
- ok_to_create_file = TRUE;
- p_indent = indent;
- p_start = this_line;
- p_sline = p_input_line;
- retval = UNI_DIFF;
- goto scan_exit;
- }
- stars_this_line = strnEQ(s, "********", 8);
- if ((!diff_type || diff_type == CONTEXT_DIFF) && stars_last_line &&
- strnEQ(s, "*** ", 4)) {
- if (!atol(s+4))
- ok_to_create_file = TRUE;
- /* if this is a new context diff the character just before */
- /* the newline is a '*'. */
- while (*s != '\n')
- s++;
- p_indent = indent;
- p_start = previous_line;
- p_sline = p_input_line - 1;
- retval = (*(s-1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF);
- goto scan_exit;
- }
- if ((!diff_type || diff_type == NORMAL_DIFF) &&
- last_line_was_command &&
- (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2)) ) {
- p_start = previous_line;
- p_sline = p_input_line - 1;
- p_indent = indent;
- retval = NORMAL_DIFF;
- goto scan_exit;
- }
- }
- scan_exit:
- if (no_filearg) {
- if (indtmp != Nullch)
- indname = fetchname(indtmp, strippath, ok_to_create_file);
- if (oldtmp != Nullch)
- oldname = fetchname(oldtmp, strippath, ok_to_create_file);
- if (newtmp != Nullch)
- newname = fetchname(newtmp, strippath, ok_to_create_file);
- if (oldname && newname) {
- if (strlen(oldname) < strlen(newname))
- filearg[0] = savestr(oldname);
- else
- filearg[0] = savestr(newname);
- }
- else if (oldname)
- filearg[0] = savestr(oldname);
- else if (newname)
- filearg[0] = savestr(newname);
- else if (indname)
- filearg[0] = savestr(indname);
- }
- if (bestguess) {
- free(bestguess);
- bestguess = Nullch;
- }
- if (filearg[0] != Nullch)
- bestguess = savestr(filearg[0]);
- else if (indtmp != Nullch)
- bestguess = fetchname(indtmp, strippath, TRUE);
- else {
- if (oldtmp != Nullch)
- oldname = fetchname(oldtmp, strippath, TRUE);
- if (newtmp != Nullch)
- newname = fetchname(newtmp, strippath, TRUE);
- if (oldname && newname) {
- if (strlen(oldname) < strlen(newname))
- bestguess = savestr(oldname);
- else
- bestguess = savestr(newname);
- }
- else if (oldname)
- bestguess = savestr(oldname);
- else if (newname)
- bestguess = savestr(newname);
- }
- if (indtmp != Nullch)
- free(indtmp);
- if (oldtmp != Nullch)
- free(oldtmp);
- if (newtmp != Nullch)
- free(newtmp);
- if (indname != Nullch)
- free(indname);
- if (oldname != Nullch)
- free(oldname);
- if (newname != Nullch)
- free(newname);
- return retval;
-}
-
-/* Remember where this patch ends so we know where to start up again. */
-
-void
-next_intuit_at(file_pos,file_line)
-long file_pos;
-long file_line;
-{
- p_base = file_pos;
- p_bline = file_line;
-}
-
-/* Basically a verbose fseek() to the actual diff listing. */
-
-void
-skip_to(file_pos,file_line)
-long file_pos;
-long file_line;
-{
- char *ret;
-
- assert(p_base <= file_pos);
- if (verbose && p_base < file_pos) {
- Fseek(pfp, p_base, 0);
- say1("The text leading up to this was:\n--------------------------\n");
- while (ftell(pfp) < file_pos) {
- ret = fgets(buf, sizeof buf, pfp);
- assert(ret != Nullch);
- say2("|%s", buf);
- }
- say1("--------------------------\n");
- }
- else
- Fseek(pfp, file_pos, 0);
- p_input_line = file_line - 1;
-}
-
-/* Make this a function for better debugging. */
-static void
-malformed ()
-{
- fatal3("malformed patch at line %ld: %s", p_input_line, buf);
- /* about as informative as "Syntax error" in C */
-}
-
-/* True if there is more of the current diff listing to process. */
-
-bool
-another_hunk()
-{
- Reg1 char *s;
- Reg8 char *ret;
- Reg2 int context = 0;
-
- while (p_end >= 0) {
- if (p_end == p_efake)
- p_end = p_bfake; /* don't free twice */
- else
- free(p_line[p_end]);
- p_end--;
- }
- assert(p_end == -1);
- p_efake = -1;
-
- p_max = hunkmax; /* gets reduced when --- found */
- if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) {
- long line_beginning = ftell(pfp);
- /* file pos of the current line */
- LINENUM repl_beginning = 0; /* index of --- line */
- Reg4 LINENUM fillcnt = 0; /* #lines of missing ptrn or repl */
- Reg5 LINENUM fillsrc; /* index of first line to copy */
- Reg6 LINENUM filldst; /* index of first missing line */
- bool ptrn_spaces_eaten = FALSE; /* ptrn was slightly misformed */
- Reg9 bool repl_could_be_missing = TRUE;
- /* no + or ! lines in this hunk */
- bool repl_missing = FALSE; /* we are now backtracking */
- long repl_backtrack_position = 0;
- /* file pos of first repl line */
- LINENUM repl_patch_line; /* input line number for same */
- Reg7 LINENUM ptrn_copiable = 0;
- /* # of copiable lines in ptrn */
-
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch || strnNE(buf, "********", 8)) {
- next_intuit_at(line_beginning,p_input_line);
- return FALSE;
- }
- p_context = 100;
- p_hunk_beg = p_input_line + 1;
- while (p_end < p_max) {
- line_beginning = ftell(pfp);
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch) {
- if (p_max - p_end < 4)
- Strcpy(buf, " \n"); /* assume blank lines got chopped */
- else {
- if (repl_beginning && repl_could_be_missing) {
- repl_missing = TRUE;
- goto hunk_done;
- }
- fatal1("unexpected end of file in patch\n");
- }
- }
- p_end++;
- assert(p_end < hunkmax);
- p_Char[p_end] = *buf;
-#ifdef zilog
- p_line[(short)p_end] = Nullch;
-#else
- p_line[p_end] = Nullch;
-#endif
- switch (*buf) {
- case '*':
- if (strnEQ(buf, "********", 8)) {
- if (repl_beginning && repl_could_be_missing) {
- repl_missing = TRUE;
- goto hunk_done;
- }
- else
- fatal2("unexpected end of hunk at line %ld\n",
- p_input_line);
- }
- if (p_end != 0) {
- if (repl_beginning && repl_could_be_missing) {
- repl_missing = TRUE;
- goto hunk_done;
- }
- fatal3("unexpected *** at line %ld: %s", p_input_line, buf);
- }
- context = 0;
- p_line[p_end] = savestr(buf);
- if (out_of_mem) {
- p_end--;
- return FALSE;
- }
- for (s=buf; *s && !isdigit(*s); s++) ;
- if (!*s)
- malformed ();
- if (strnEQ(s,"0,0",3))
- strcpy(s,s+2);
- p_first = (LINENUM) atol(s);
- while (isdigit(*s)) s++;
- if (*s == ',') {
- for (; *s && !isdigit(*s); s++) ;
- if (!*s)
- malformed ();
- p_ptrn_lines = ((LINENUM)atol(s)) - p_first + 1;
- }
- else if (p_first)
- p_ptrn_lines = 1;
- else {
- p_ptrn_lines = 0;
- p_first = 1;
- }
- p_max = p_ptrn_lines + 6; /* we need this much at least */
- while (p_max >= hunkmax)
- grow_hunkmax();
- p_max = hunkmax;
- break;
- case '-':
- if (buf[1] == '-') {
- if (repl_beginning ||
- (p_end != p_ptrn_lines + 1 + (p_Char[p_end-1] == '\n')))
- {
- if (p_end == 1) {
- /* `old' lines were omitted - set up to fill */
- /* them in from 'new' context lines. */
- p_end = p_ptrn_lines + 1;
- fillsrc = p_end + 1;
- filldst = 1;
- fillcnt = p_ptrn_lines;
- }
- else {
- if (repl_beginning) {
- if (repl_could_be_missing){
- repl_missing = TRUE;
- goto hunk_done;
- }
- fatal3(
-"duplicate \"---\" at line %ld--check line numbers at line %ld\n",
- p_input_line, p_hunk_beg + repl_beginning);
- }
- else {
- fatal4(
-"%s \"---\" at line %ld--check line numbers at line %ld\n",
- (p_end <= p_ptrn_lines
- ? "Premature"
- : "Overdue" ),
- p_input_line, p_hunk_beg);
- }
- }
- }
- repl_beginning = p_end;
- repl_backtrack_position = ftell(pfp);
- repl_patch_line = p_input_line;
- p_line[p_end] = savestr(buf);
- if (out_of_mem) {
- p_end--;
- return FALSE;
- }
- p_Char[p_end] = '=';
- for (s=buf; *s && !isdigit(*s); s++) ;
- if (!*s)
- malformed ();
- p_newfirst = (LINENUM) atol(s);
- while (isdigit(*s)) s++;
- if (*s == ',') {
- for (; *s && !isdigit(*s); s++) ;
- if (!*s)
- malformed ();
- p_repl_lines = ((LINENUM)atol(s)) - p_newfirst + 1;
- }
- else if (p_newfirst)
- p_repl_lines = 1;
- else {
- p_repl_lines = 0;
- p_newfirst = 1;
- }
- p_max = p_repl_lines + p_end;
- if (p_max > MAXHUNKSIZE)
- fatal4("hunk too large (%ld lines) at line %ld: %s",
- p_max, p_input_line, buf);
- while (p_max >= hunkmax)
- grow_hunkmax();
- if (p_repl_lines != ptrn_copiable
- && (p_context != 0 || p_repl_lines != 1))
- repl_could_be_missing = FALSE;
- break;
- }
- goto change_line;
- case '+': case '!':
- repl_could_be_missing = FALSE;
- change_line:
- if (buf[1] == '\n' && canonicalize)
- strcpy(buf+1," \n");
- if (!isspace(buf[1]) && buf[1] != '>' && buf[1] != '<' &&
- repl_beginning && repl_could_be_missing) {
- repl_missing = TRUE;
- goto hunk_done;
- }
- if (context >= 0) {
- if (context < p_context)
- p_context = context;
- context = -1000;
- }
- p_line[p_end] = savestr(buf+2);
- if (out_of_mem) {
- p_end--;
- return FALSE;
- }
- break;
- case '\t': case '\n': /* assume the 2 spaces got eaten */
- if (repl_beginning && repl_could_be_missing &&
- (!ptrn_spaces_eaten || diff_type == NEW_CONTEXT_DIFF) ) {
- repl_missing = TRUE;
- goto hunk_done;
- }
- p_line[p_end] = savestr(buf);
- if (out_of_mem) {
- p_end--;
- return FALSE;
- }
- if (p_end != p_ptrn_lines + 1) {
- ptrn_spaces_eaten |= (repl_beginning != 0);
- context++;
- if (!repl_beginning)
- ptrn_copiable++;
- p_Char[p_end] = ' ';
- }
- break;
- case ' ':
- if (!isspace(buf[1]) &&
- repl_beginning && repl_could_be_missing) {
- repl_missing = TRUE;
- goto hunk_done;
- }
- context++;
- if (!repl_beginning)
- ptrn_copiable++;
- p_line[p_end] = savestr(buf+2);
- if (out_of_mem) {
- p_end--;
- return FALSE;
- }
- break;
- default:
- if (repl_beginning && repl_could_be_missing) {
- repl_missing = TRUE;
- goto hunk_done;
- }
- malformed ();
- }
- /* set up p_len for strncmp() so we don't have to */
- /* assume null termination */
- if (p_line[p_end])
- p_len[p_end] = strlen(p_line[p_end]);
- else
- p_len[p_end] = 0;
- }
-
- hunk_done:
- if (p_end >=0 && !repl_beginning)
- fatal2("no --- found in patch at line %ld\n", pch_hunk_beg());
-
- if (repl_missing) {
-
- /* reset state back to just after --- */
- p_input_line = repl_patch_line;
- for (p_end--; p_end > repl_beginning; p_end--)
- free(p_line[p_end]);
- Fseek(pfp, repl_backtrack_position, 0);
-
- /* redundant 'new' context lines were omitted - set */
- /* up to fill them in from the old file context */
- if (!p_context && p_repl_lines == 1) {
- p_repl_lines = 0;
- p_max--;
- }
- fillsrc = 1;
- filldst = repl_beginning+1;
- fillcnt = p_repl_lines;
- p_end = p_max;
- }
- else if (!p_context && fillcnt == 1) {
- /* the first hunk was a null hunk with no context */
- /* and we were expecting one line -- fix it up. */
- while (filldst < p_end) {
- p_line[filldst] = p_line[filldst+1];
- p_Char[filldst] = p_Char[filldst+1];
- p_len[filldst] = p_len[filldst+1];
- filldst++;
- }
-#if 0
- repl_beginning--; /* this doesn't need to be fixed */
-#endif
- p_end--;
- p_first++; /* do append rather than insert */
- fillcnt = 0;
- p_ptrn_lines = 0;
- }
-
- if (diff_type == CONTEXT_DIFF &&
- (fillcnt || (p_first > 1 && ptrn_copiable > 2*p_context)) ) {
- if (verbose)
- say4("%s\n%s\n%s\n",
-"(Fascinating--this is really a new-style context diff but without",
-"the telltale extra asterisks on the *** line that usually indicate",
-"the new style...)");
- diff_type = NEW_CONTEXT_DIFF;
- }
-
- /* if there were omitted context lines, fill them in now */
- if (fillcnt) {
- p_bfake = filldst; /* remember where not to free() */
- p_efake = filldst + fillcnt - 1;
- while (fillcnt-- > 0) {
- while (fillsrc <= p_end && p_Char[fillsrc] != ' ')
- fillsrc++;
- if (fillsrc > p_end)
- fatal2("replacement text or line numbers mangled in hunk at line %ld\n",
- p_hunk_beg);
- p_line[filldst] = p_line[fillsrc];
- p_Char[filldst] = p_Char[fillsrc];
- p_len[filldst] = p_len[fillsrc];
- fillsrc++; filldst++;
- }
- while (fillsrc <= p_end && fillsrc != repl_beginning &&
- p_Char[fillsrc] != ' ')
- fillsrc++;
-#ifdef DEBUGGING
- if (debug & 64)
- printf("fillsrc %ld, filldst %ld, rb %ld, e+1 %ld\n",
- fillsrc,filldst,repl_beginning,p_end+1);
-#endif
- assert(fillsrc==p_end+1 || fillsrc==repl_beginning);
- assert(filldst==p_end+1 || filldst==repl_beginning);
- }
- }
- else if (diff_type == UNI_DIFF) {
- long line_beginning = ftell(pfp);
- /* file pos of the current line */
- Reg4 LINENUM fillsrc; /* index of old lines */
- Reg5 LINENUM filldst; /* index of new lines */
- char ch;
-
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch || strnNE(buf, "@@ -", 4)) {
- next_intuit_at(line_beginning,p_input_line);
- return FALSE;
- }
- s = buf+4;
- if (!*s)
- malformed ();
- p_first = (LINENUM) atol(s);
- while (isdigit(*s)) s++;
- if (*s == ',') {
- p_ptrn_lines = (LINENUM) atol(++s);
- while (isdigit(*s)) s++;
- } else
- p_ptrn_lines = 1;
- if (*s == ' ') s++;
- if (*s != '+' || !*++s)
- malformed ();
- p_newfirst = (LINENUM) atol(s);
- while (isdigit(*s)) s++;
- if (*s == ',') {
- p_repl_lines = (LINENUM) atol(++s);
- while (isdigit(*s)) s++;
- } else
- p_repl_lines = 1;
- if (*s == ' ') s++;
- if (*s != '@')
- malformed ();
- if (!p_ptrn_lines)
- p_first++; /* do append rather than insert */
- p_max = p_ptrn_lines + p_repl_lines + 1;
- while (p_max >= hunkmax)
- grow_hunkmax();
- fillsrc = 1;
- filldst = fillsrc + p_ptrn_lines;
- p_end = filldst + p_repl_lines;
- Sprintf(buf,"*** %ld,%ld ****\n",p_first,p_first + p_ptrn_lines - 1);
- p_line[0] = savestr(buf);
- if (out_of_mem) {
- p_end = -1;
- return FALSE;
- }
- p_Char[0] = '*';
- Sprintf(buf,"--- %ld,%ld ----\n",p_newfirst,p_newfirst+p_repl_lines-1);
- p_line[filldst] = savestr(buf);
- if (out_of_mem) {
- p_end = 0;
- return FALSE;
- }
- p_Char[filldst++] = '=';
- p_context = 100;
- context = 0;
- p_hunk_beg = p_input_line + 1;
- while (fillsrc <= p_ptrn_lines || filldst <= p_end) {
- line_beginning = ftell(pfp);
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch) {
- if (p_max - filldst < 3)
- Strcpy(buf, " \n"); /* assume blank lines got chopped */
- else {
- fatal1("unexpected end of file in patch\n");
- }
- }
- if (*buf == '\t' || *buf == '\n') {
- ch = ' '; /* assume the space got eaten */
- s = savestr(buf);
- }
- else {
- ch = *buf;
- s = savestr(buf+1);
- }
- if (out_of_mem) {
- while (--filldst > p_ptrn_lines)
- free(p_line[filldst]);
- p_end = fillsrc-1;
- return FALSE;
- }
- switch (ch) {
- case '-':
- if (fillsrc > p_ptrn_lines) {
- free(s);
- p_end = filldst-1;
- malformed ();
- }
- p_Char[fillsrc] = ch;
- p_line[fillsrc] = s;
- p_len[fillsrc++] = strlen(s);
- break;
- case '=':
- ch = ' ';
- /* FALL THROUGH */
- case ' ':
- if (fillsrc > p_ptrn_lines) {
- free(s);
- while (--filldst > p_ptrn_lines)
- free(p_line[filldst]);
- p_end = fillsrc-1;
- malformed ();
- }
- context++;
- p_Char[fillsrc] = ch;
- p_line[fillsrc] = s;
- p_len[fillsrc++] = strlen(s);
- s = savestr(s);
- if (out_of_mem) {
- while (--filldst > p_ptrn_lines)
- free(p_line[filldst]);
- p_end = fillsrc-1;
- return FALSE;
- }
- /* FALL THROUGH */
- case '+':
- if (filldst > p_end) {
- free(s);
- while (--filldst > p_ptrn_lines)
- free(p_line[filldst]);
- p_end = fillsrc-1;
- malformed ();
- }
- p_Char[filldst] = ch;
- p_line[filldst] = s;
- p_len[filldst++] = strlen(s);
- break;
- default:
- p_end = filldst;
- malformed ();
- }
- if (ch != ' ' && context > 0) {
- if (context < p_context)
- p_context = context;
- context = -1000;
- }
- }/* while */
- }
- else { /* normal diff--fake it up */
- char hunk_type;
- Reg3 int i;
- LINENUM min, max;
- long line_beginning = ftell(pfp);
-
- p_context = 0;
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch || !isdigit(*buf)) {
- next_intuit_at(line_beginning,p_input_line);
- return FALSE;
- }
- p_first = (LINENUM)atol(buf);
- for (s=buf; isdigit(*s); s++) ;
- if (*s == ',') {
- p_ptrn_lines = (LINENUM)atol(++s) - p_first + 1;
- while (isdigit(*s)) s++;
- }
- else
- p_ptrn_lines = (*s != 'a');
- hunk_type = *s;
- if (hunk_type == 'a')
- p_first++; /* do append rather than insert */
- min = (LINENUM)atol(++s);
- for (; isdigit(*s); s++) ;
- if (*s == ',')
- max = (LINENUM)atol(++s);
- else
- max = min;
- if (hunk_type == 'd')
- min++;
- p_end = p_ptrn_lines + 1 + max - min + 1;
- if (p_end > MAXHUNKSIZE)
- fatal4("hunk too large (%ld lines) at line %ld: %s",
- p_end, p_input_line, buf);
- while (p_end >= hunkmax)
- grow_hunkmax();
- p_newfirst = min;
- p_repl_lines = max - min + 1;
- Sprintf(buf, "*** %ld,%ld\n", p_first, p_first + p_ptrn_lines - 1);
- p_line[0] = savestr(buf);
- if (out_of_mem) {
- p_end = -1;
- return FALSE;
- }
- p_Char[0] = '*';
- for (i=1; i<=p_ptrn_lines; i++) {
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch)
- fatal2("unexpected end of file in patch at line %ld\n",
- p_input_line);
- if (*buf != '<')
- fatal2("< expected at line %ld of patch\n", p_input_line);
- p_line[i] = savestr(buf+2);
- if (out_of_mem) {
- p_end = i-1;
- return FALSE;
- }
- p_len[i] = strlen(p_line[i]);
- p_Char[i] = '-';
- }
- if (hunk_type == 'c') {
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch)
- fatal2("unexpected end of file in patch at line %ld\n",
- p_input_line);
- if (*buf != '-')
- fatal2("--- expected at line %ld of patch\n", p_input_line);
- }
- Sprintf(buf, "--- %ld,%ld\n", min, max);
- p_line[i] = savestr(buf);
- if (out_of_mem) {
- p_end = i-1;
- return FALSE;
- }
- p_Char[i] = '=';
- for (i++; i<=p_end; i++) {
- ret = pgets(buf, sizeof buf, pfp);
- p_input_line++;
- if (ret == Nullch)
- fatal2("unexpected end of file in patch at line %ld\n",
- p_input_line);
- if (*buf != '>')
- fatal2("> expected at line %ld of patch\n", p_input_line);
- p_line[i] = savestr(buf+2);
- if (out_of_mem) {
- p_end = i-1;
- return FALSE;
- }
- p_len[i] = strlen(p_line[i]);
- p_Char[i] = '+';
- }
- }
- if (reverse) /* backwards patch? */
- if (!pch_swap())
- say1("Not enough memory to swap next hunk!\n");
-#ifdef DEBUGGING
- if (debug & 2) {
- int i;
- char special;
-
- for (i=0; i <= p_end; i++) {
- if (i == p_ptrn_lines)
- special = '^';
- else
- special = ' ';
- fprintf(stderr, "%3d %c %c %s", i, p_Char[i], special, p_line[i]);
- Fflush(stderr);
- }
- }
-#endif
- if (p_end+1 < hunkmax) /* paranoia reigns supreme... */
- p_Char[p_end+1] = '^'; /* add a stopper for apply_hunk */
- return TRUE;
-}
-
-/* Input a line from the patch file, worrying about indentation. */
-
-char *
-pgets(bf,sz,fp)
-char *bf;
-int sz;
-FILE *fp;
-{
- char *ret = fgets(bf, sz, fp);
- Reg1 char *s;
- Reg2 int indent = 0;
-
- if (p_indent && ret != Nullch) {
- for (s=buf;
- indent < p_indent && (*s == ' ' || *s == '\t' || *s == 'X'); s++) {
- if (*s == '\t')
- indent += 8 - (indent % 7);
- else
- indent++;
- }
- if (buf != s)
- Strcpy(buf, s);
- }
- return ret;
-}
-
-/* Reverse the old and new portions of the current hunk. */
-
-bool
-pch_swap()
-{
- char **tp_line; /* the text of the hunk */
- short *tp_len; /* length of each line */
- char *tp_char; /* +, -, and ! */
- Reg1 LINENUM i;
- Reg2 LINENUM n;
- bool blankline = FALSE;
- Reg3 char *s;
-
- i = p_first;
- p_first = p_newfirst;
- p_newfirst = i;
-
- /* make a scratch copy */
-
- tp_line = p_line;
- tp_len = p_len;
- tp_char = p_Char;
- p_line = Null(char**); /* force set_hunkmax to allocate again */
- p_len = Null(short*);
- p_Char = Nullch;
- set_hunkmax();
- if (p_line == Null(char**) || p_len == Null(short*) || p_Char == Nullch) {
-#ifndef lint
- if (p_line == Null(char**))
- free((char*)p_line);
- p_line = tp_line;
- if (p_len == Null(short*))
- free((char*)p_len);
- p_len = tp_len;
-#endif
- if (p_Char == Nullch)
- free((char*)p_Char);
- p_Char = tp_char;
- return FALSE; /* not enough memory to swap hunk! */
- }
-
- /* now turn the new into the old */
-
- i = p_ptrn_lines + 1;
- if (tp_char[i] == '\n') { /* account for possible blank line */
- blankline = TRUE;
- i++;
- }
- if (p_efake >= 0) { /* fix non-freeable ptr range */
- if (p_efake <= i)
- n = p_end - i + 1;
- else
- n = -i;
- p_efake += n;
- p_bfake += n;
- }
- for (n=0; i <= p_end; i++,n++) {
- p_line[n] = tp_line[i];
- p_Char[n] = tp_char[i];
- if (p_Char[n] == '+')
- p_Char[n] = '-';
- p_len[n] = tp_len[i];
- }
- if (blankline) {
- i = p_ptrn_lines + 1;
- p_line[n] = tp_line[i];
- p_Char[n] = tp_char[i];
- p_len[n] = tp_len[i];
- n++;
- }
- assert(p_Char[0] == '=');
- p_Char[0] = '*';
- for (s=p_line[0]; *s; s++)
- if (*s == '-')
- *s = '*';
-
- /* now turn the old into the new */
-
- assert(tp_char[0] == '*');
- tp_char[0] = '=';
- for (s=tp_line[0]; *s; s++)
- if (*s == '*')
- *s = '-';
- for (i=0; n <= p_end; i++,n++) {
- p_line[n] = tp_line[i];
- p_Char[n] = tp_char[i];
- if (p_Char[n] == '-')
- p_Char[n] = '+';
- p_len[n] = tp_len[i];
- }
- assert(i == p_ptrn_lines + 1);
- i = p_ptrn_lines;
- p_ptrn_lines = p_repl_lines;
- p_repl_lines = i;
-#ifndef lint
- if (tp_line == Null(char**))
- free((char*)tp_line);
- if (tp_len == Null(short*))
- free((char*)tp_len);
-#endif
- if (tp_char == Nullch)
- free((char*)tp_char);
- return TRUE;
-}
-
-/* Return the specified line position in the old file of the old context. */
-
-LINENUM
-pch_first()
-{
- return p_first;
-}
-
-/* Return the number of lines of old context. */
-
-LINENUM
-pch_ptrn_lines()
-{
- return p_ptrn_lines;
-}
-
-/* Return the probable line position in the new file of the first line. */
-
-LINENUM
-pch_newfirst()
-{
- return p_newfirst;
-}
-
-/* Return the number of lines in the replacement text including context. */
-
-LINENUM
-pch_repl_lines()
-{
- return p_repl_lines;
-}
-
-/* Return the number of lines in the whole hunk. */
-
-LINENUM
-pch_end()
-{
- return p_end;
-}
-
-/* Return the number of context lines before the first changed line. */
-
-LINENUM
-pch_context()
-{
- return p_context;
-}
-
-/* Return the length of a particular patch line. */
-
-short
-pch_line_len(line)
-LINENUM line;
-{
- return p_len[line];
-}
-
-/* Return the control character (+, -, *, !, etc) for a patch line. */
-
-char
-pch_char(line)
-LINENUM line;
-{
- return p_Char[line];
-}
-
-/* Return a pointer to a particular patch line. */
-
-char *
-pfetch(line)
-LINENUM line;
-{
- return p_line[line];
-}
-
-/* Return where in the patch file this hunk began, for error messages. */
-
-LINENUM
-pch_hunk_beg()
-{
- return p_hunk_beg;
-}
-
-/* Apply an ed script by feeding ed itself. */
-
-void
-do_ed_script()
-{
- Reg1 char *t;
- Reg2 long beginning_of_this_line;
- Reg3 bool this_line_is_command = FALSE;
- Reg4 FILE *pipefp;
-
- if (!skip_rest_of_patch) {
- Unlink(TMPOUTNAME);
- copy_file(filearg[0], TMPOUTNAME);
- if (verbose)
- Sprintf(buf, "/bin/ed %s", TMPOUTNAME);
- else
- Sprintf(buf, "/bin/ed - %s", TMPOUTNAME);
- pipefp = popen(buf, "w");
- }
- for (;;) {
- beginning_of_this_line = ftell(pfp);
- if (pgets(buf, sizeof buf, pfp) == Nullch) {
- next_intuit_at(beginning_of_this_line,p_input_line);
- break;
- }
- p_input_line++;
- for (t=buf; isdigit(*t) || *t == ','; t++) ;
- this_line_is_command = (isdigit(*buf) &&
- (*t == 'd' || *t == 'c' || *t == 'a') );
- if (this_line_is_command) {
- if (!skip_rest_of_patch)
- fputs(buf, pipefp);
- if (*t != 'd') {
- while (pgets(buf, sizeof buf, pfp) != Nullch) {
- p_input_line++;
- if (!skip_rest_of_patch)
- fputs(buf, pipefp);
- if (strEQ(buf, ".\n"))
- break;
- }
- }
- }
- else {
- next_intuit_at(beginning_of_this_line,p_input_line);
- break;
- }
- }
- if (skip_rest_of_patch)
- return;
- fprintf(pipefp, "w\n");
- fprintf(pipefp, "q\n");
- Fflush(pipefp);
- Pclose(pipefp);
- ignore_signals();
- if (move_file(TMPOUTNAME, outname) < 0) {
- toutkeep = TRUE;
- chmod(TMPOUTNAME, filemode);
- }
- else
- chmod(outname, filemode);
- set_signals(1);
-}
diff --git a/gnu/usr.bin/patch/pch.h b/gnu/usr.bin/patch/pch.h
deleted file mode 100644
index 97a5b28..0000000
--- a/gnu/usr.bin/patch/pch.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* $Header: pch.h,v 2.0.1.1 87/01/30 22:47:16 lwall Exp $
- *
- * $Log: pch.h,v $
- * Revision 2.0.1.1 87/01/30 22:47:16 lwall
- * Added do_ed_script().
- *
- * Revision 2.0 86/09/17 15:39:57 lwall
- * Baseline for netwide release.
- *
- */
-
-EXT FILE *pfp INIT(Nullfp); /* patch file pointer */
-
-void re_patch();
-void open_patch_file();
-void set_hunkmax();
-void grow_hunkmax();
-bool there_is_another_patch();
-int intuit_diff_type();
-void next_intuit_at();
-void skip_to();
-bool another_hunk();
-bool pch_swap();
-char *pfetch();
-short pch_line_len();
-LINENUM pch_first();
-LINENUM pch_ptrn_lines();
-LINENUM pch_newfirst();
-LINENUM pch_repl_lines();
-LINENUM pch_end();
-LINENUM pch_context();
-LINENUM pch_hunk_beg();
-char pch_char();
-char *pfetch();
-char *pgets();
-void do_ed_script();
diff --git a/gnu/usr.bin/patch/util.c b/gnu/usr.bin/patch/util.c
deleted file mode 100644
index ecb85ff..0000000
--- a/gnu/usr.bin/patch/util.c
+++ /dev/null
@@ -1,433 +0,0 @@
-#include "EXTERN.h"
-#include "common.h"
-#include "INTERN.h"
-#include "util.h"
-#include "backupfile.h"
-
-void my_exit();
-
-#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 */
-
-/* Rename a file, copying it if necessary. */
-
-int
-move_file(from,to)
-char *from, *to;
-{
- char bakname[512];
- Reg1 char *s;
- Reg2 int i;
- Reg3 int fromfd;
-
- /* to stdout? */
-
- if (strEQ(to, "-")) {
-#ifdef DEBUGGING
- if (debug & 4)
- say2("Moving %s to stdout.\n", from);
-#endif
- fromfd = open(from, 0);
- if (fromfd < 0)
- pfatal2("internal error, can't reopen %s", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- if (write(1, buf, i) != 1)
- pfatal1("write failed");
- Close(fromfd);
- return 0;
- }
-
- if (origprae) {
- Strcpy(bakname, origprae);
- Strcat(bakname, to);
- } else {
-#ifndef NODIR
- char *backupname = find_backup_file_name(to);
- if (backupname == (char *) 0)
- fatal1("out of memory\n");
- Strcpy(bakname, backupname);
- free(backupname);
-#else /* NODIR */
- Strcpy(bakname, to);
- Strcat(bakname, simple_backup_suffix);
-#endif /* NODIR */
- }
-
- if (stat(to, &filestat) == 0) { /* output file exists */
- dev_t to_device = filestat.st_dev;
- ino_t to_inode = filestat.st_ino;
- char *simplename = bakname;
-
- for (s=bakname; *s; s++) {
- if (*s == '/')
- simplename = s+1;
- }
- /* Find a backup name that is not the same file.
- Change the first lowercase char into uppercase;
- if that isn't sufficient, chop off the first char and try again. */
- while (stat(bakname, &filestat) == 0 &&
- to_device == filestat.st_dev && to_inode == filestat.st_ino) {
- /* Skip initial non-lowercase chars. */
- for (s=simplename; *s && !islower(*s); s++) ;
- if (*s)
- *s = toupper(*s);
- else
- Strcpy(simplename, simplename+1);
- }
- while (unlink(bakname) >= 0) ; /* while() is for benefit of Eunice */
-#ifdef DEBUGGING
- if (debug & 4)
- say3("Moving %s to %s.\n", to, bakname);
-#endif
- if (rename(to, bakname) < 0) {
- say4("Can't backup %s, output is in %s: %s\n", to, from,
- strerror(errno));
- return -1;
- }
- while (unlink(to) >= 0) ;
- }
-#ifdef DEBUGGING
- if (debug & 4)
- say3("Moving %s to %s.\n", from, to);
-#endif
- if (rename(from, to) < 0) { /* different file system? */
- Reg4 int tofd;
-
- tofd = creat(to, 0666);
- if (tofd < 0) {
- say4("Can't create %s, output is in %s: %s\n",
- to, from, strerror(errno));
- return -1;
- }
- fromfd = open(from, 0);
- if (fromfd < 0)
- pfatal2("internal error, can't reopen %s", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- if (write(tofd, buf, i) != i)
- pfatal1("write failed");
- Close(fromfd);
- Close(tofd);
- }
- Unlink(from);
- return 0;
-}
-
-/* Copy a file. */
-
-void
-copy_file(from,to)
-char *from, *to;
-{
- Reg3 int tofd;
- Reg2 int fromfd;
- Reg1 int i;
-
- tofd = creat(to, 0666);
- if (tofd < 0)
- pfatal2("can't create %s", to);
- fromfd = open(from, 0);
- if (fromfd < 0)
- pfatal2("internal error, can't reopen %s", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- if (write(tofd, buf, i) != i)
- pfatal2("write to %s failed", to);
- Close(fromfd);
- Close(tofd);
-}
-
-/* Allocate a unique area for a string. */
-
-char *
-savestr(s)
-Reg1 char *s;
-{
- Reg3 char *rv;
- Reg2 char *t;
-
- if (!s)
- s = "Oops";
- t = s;
- while (*t++);
- rv = malloc((MEM) (t - s));
- if (rv == Nullch) {
- if (using_plan_a)
- out_of_mem = TRUE;
- else
- fatal1("out of memory\n");
- }
- else {
- t = rv;
- while (*t++ = *s++);
- }
- return rv;
-}
-
-#if defined(lint) && defined(CANVARARG)
-
-/*VARARGS ARGSUSED*/
-say(pat) char *pat; { ; }
-/*VARARGS ARGSUSED*/
-fatal(pat) char *pat; { ; }
-/*VARARGS ARGSUSED*/
-pfatal(pat) char *pat; { ; }
-/*VARARGS ARGSUSED*/
-ask(pat) char *pat; { ; }
-
-#else
-
-/* Vanilla terminal output (buffered). */
-
-void
-say(pat,arg1,arg2,arg3)
-char *pat;
-long arg1,arg2,arg3;
-{
- fprintf(stderr, pat, arg1, arg2, arg3);
- Fflush(stderr);
-}
-
-/* Terminal output, pun intended. */
-
-void /* very void */
-fatal(pat,arg1,arg2,arg3)
-char *pat;
-long arg1,arg2,arg3;
-{
- fprintf(stderr, "patch: **** ");
- fprintf(stderr, pat, arg1, arg2, arg3);
- my_exit(1);
-}
-
-/* Say something from patch, something from the system, then silence . . . */
-
-void /* very void */
-pfatal(pat,arg1,arg2,arg3)
-char *pat;
-long arg1,arg2,arg3;
-{
- int errnum = errno;
-
- fprintf(stderr, "patch: **** ");
- fprintf(stderr, pat, arg1, arg2, arg3);
- fprintf(stderr, ": %s\n", strerror(errnum));
- my_exit(1);
-}
-
-/* Get a response from the user, somehow or other. */
-
-void
-ask(pat,arg1,arg2,arg3)
-char *pat;
-long arg1,arg2,arg3;
-{
- int ttyfd;
- int r;
- bool tty2 = isatty(2);
-
- Sprintf(buf, pat, arg1, arg2, arg3);
- Fflush(stderr);
- write(2, buf, strlen(buf));
- if (tty2) { /* might be redirected to a file */
- r = read(2, buf, sizeof buf);
- }
- else if (isatty(1)) { /* this may be new file output */
- Fflush(stdout);
- write(1, buf, strlen(buf));
- r = read(1, buf, sizeof buf);
- }
- else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) {
- /* might be deleted or unwriteable */
- write(ttyfd, buf, strlen(buf));
- r = read(ttyfd, buf, sizeof buf);
- Close(ttyfd);
- }
- else if (isatty(0)) { /* this is probably patch input */
- Fflush(stdin);
- write(0, buf, strlen(buf));
- r = read(0, buf, sizeof buf);
- }
- else { /* no terminal at all--default it */
- buf[0] = '\n';
- r = 1;
- }
- if (r <= 0)
- buf[0] = 0;
- else
- buf[r] = '\0';
- if (!tty2)
- say1(buf);
-}
-#endif /* lint */
-
-/* How to handle certain events when not in a critical region. */
-
-void
-set_signals(reset)
-int reset;
-{
-#ifndef lint
- static RETSIGTYPE (*hupval)(),(*intval)();
-
- if (!reset) {
- hupval = signal(SIGHUP, SIG_IGN);
- if (hupval != SIG_IGN)
- hupval = (RETSIGTYPE(*)())my_exit;
- intval = signal(SIGINT, SIG_IGN);
- if (intval != SIG_IGN)
- intval = (RETSIGTYPE(*)())my_exit;
- }
- Signal(SIGHUP, hupval);
- Signal(SIGINT, intval);
-#endif
-}
-
-/* How to handle certain events when in a critical region. */
-
-void
-ignore_signals()
-{
-#ifndef lint
- Signal(SIGHUP, SIG_IGN);
- Signal(SIGINT, SIG_IGN);
-#endif
-}
-
-/* Make sure we'll have the directories to create a file.
- If `striplast' is TRUE, ignore the last element of `filename'. */
-
-void
-makedirs(filename,striplast)
-Reg1 char *filename;
-bool striplast;
-{
- char tmpbuf[256];
- Reg2 char *s = tmpbuf;
- char *dirv[20]; /* Point to the NULs between elements. */
- Reg3 int i;
- Reg4 int dirvp = 0; /* Number of finished entries in dirv. */
-
- /* Copy `filename' into `tmpbuf' with a NUL instead of a slash
- between the directories. */
- while (*filename) {
- if (*filename == '/') {
- filename++;
- dirv[dirvp++] = s;
- *s++ = '\0';
- }
- else {
- *s++ = *filename++;
- }
- }
- *s = '\0';
- dirv[dirvp] = s;
- if (striplast)
- dirvp--;
- if (dirvp < 0)
- return;
-
- strcpy(buf, "mkdir");
- s = buf;
- for (i=0; i<=dirvp; i++) {
- struct stat sbuf;
-
- if (stat(tmpbuf, &sbuf) && errno == ENOENT) {
- while (*s) s++;
- *s++ = ' ';
- strcpy(s, tmpbuf);
- }
- *dirv[i] = '/';
- }
- if (s != buf)
- system(buf);
-}
-
-/* Make filenames more reasonable. */
-
-char *
-fetchname(at,strip_leading,assume_exists)
-char *at;
-int strip_leading;
-int assume_exists;
-{
- char *fullname;
- char *name;
- Reg1 char *t;
- char tmpbuf[200];
- int sleading = strip_leading;
-
- if (!at)
- return Nullch;
- while (isspace(*at))
- at++;
-#ifdef DEBUGGING
- if (debug & 128)
- say4("fetchname %s %d %d\n",at,strip_leading,assume_exists);
-#endif
- if (strnEQ(at, "/dev/null", 9)) /* so files can be created by diffing */
- return Nullch; /* against /dev/null. */
- name = fullname = t = savestr(at);
-
- /* Strip off up to `sleading' leading slashes and null terminate. */
- for (; *t && !isspace(*t); t++)
- if (*t == '/')
- if (--sleading >= 0)
- name = t+1;
- *t = '\0';
-
- /* If no -p option was given (957 is the default value!),
- we were given a relative pathname,
- and the leading directories that we just stripped off all exist,
- put them back on. */
- if (strip_leading == 957 && name != fullname && *fullname != '/') {
- name[-1] = '\0';
- if (stat(fullname, &filestat) == 0 && S_ISDIR (filestat.st_mode)) {
- name[-1] = '/';
- name=fullname;
- }
- }
-
- name = savestr(name);
- free(fullname);
-
- if (stat(name, &filestat) && !assume_exists) {
- char *filebase = basename(name);
- int pathlen = filebase - name;
-
- /* Put any leading path into `tmpbuf'. */
- strncpy(tmpbuf, name, pathlen);
-
-#define try(f, a1, a2) (Sprintf(tmpbuf + pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)
- if ( try("RCS/%s%s", filebase, RCSSUFFIX)
- || try("RCS/%s" , filebase, 0)
- || try( "%s%s", filebase, RCSSUFFIX)
- || try("SCCS/%s%s", SCCSPREFIX, filebase)
- || try( "%s%s", SCCSPREFIX, filebase))
- return name;
- free(name);
- name = Nullch;
- }
-
- return name;
-}
-
-char *
-xmalloc (size)
- unsigned size;
-{
- register char *p = (char *) malloc (size);
- if (!p)
- fatal("out of memory");
- return p;
-}
diff --git a/gnu/usr.bin/patch/util.h b/gnu/usr.bin/patch/util.h
deleted file mode 100644
index d8e46bb..0000000
--- a/gnu/usr.bin/patch/util.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* $Header: util.h,v 2.0 86/09/17 15:40:06 lwall Exp $
- *
- * $Log: util.h,v $
- * Revision 2.0 86/09/17 15:40:06 lwall
- * Baseline for netwide release.
- *
- */
-
-/* and for those machine that can't handle a variable argument list */
-
-#ifdef CANVARARG
-
-#define say1 say
-#define say2 say
-#define say3 say
-#define say4 say
-#define ask1 ask
-#define ask2 ask
-#define ask3 ask
-#define ask4 ask
-#define fatal1 fatal
-#define fatal2 fatal
-#define fatal3 fatal
-#define fatal4 fatal
-#define pfatal1 pfatal
-#define pfatal2 pfatal
-#define pfatal3 pfatal
-#define pfatal4 pfatal
-
-#else /* hope they allow multi-line macro actual arguments */
-
-#ifdef lint
-
-#define say1(a) say(a, 0, 0, 0)
-#define say2(a,b) say(a, (b)==(b), 0, 0)
-#define say3(a,b,c) say(a, (b)==(b), (c)==(c), 0)
-#define say4(a,b,c,d) say(a, (b)==(b), (c)==(c), (d)==(d))
-#define ask1(a) ask(a, 0, 0, 0)
-#define ask2(a,b) ask(a, (b)==(b), 0, 0)
-#define ask3(a,b,c) ask(a, (b)==(b), (c)==(c), 0)
-#define ask4(a,b,c,d) ask(a, (b)==(b), (c)==(c), (d)==(d))
-#define fatal1(a) fatal(a, 0, 0, 0)
-#define fatal2(a,b) fatal(a, (b)==(b), 0, 0)
-#define fatal3(a,b,c) fatal(a, (b)==(b), (c)==(c), 0)
-#define fatal4(a,b,c,d) fatal(a, (b)==(b), (c)==(c), (d)==(d))
-#define pfatal1(a) pfatal(a, 0, 0, 0)
-#define pfatal2(a,b) pfatal(a, (b)==(b), 0, 0)
-#define pfatal3(a,b,c) pfatal(a, (b)==(b), (c)==(c), 0)
-#define pfatal4(a,b,c,d) pfatal(a, (b)==(b), (c)==(c), (d)==(d))
-
-#else /* lint */
- /* if this doesn't work, try defining CANVARARG above */
-#define say1(a) say(a, Nullch, Nullch, Nullch)
-#define say2(a,b) say(a, b, Nullch, Nullch)
-#define say3(a,b,c) say(a, b, c, Nullch)
-#define say4 say
-#define ask1(a) ask(a, Nullch, Nullch, Nullch)
-#define ask2(a,b) ask(a, b, Nullch, Nullch)
-#define ask3(a,b,c) ask(a, b, c, Nullch)
-#define ask4 ask
-#define fatal1(a) fatal(a, Nullch, Nullch, Nullch)
-#define fatal2(a,b) fatal(a, b, Nullch, Nullch)
-#define fatal3(a,b,c) fatal(a, b, c, Nullch)
-#define fatal4 fatal
-#define pfatal1(a) pfatal(a, Nullch, Nullch, Nullch)
-#define pfatal2(a,b) pfatal(a, b, Nullch, Nullch)
-#define pfatal3(a,b,c) pfatal(a, b, c, Nullch)
-#define pfatal4 pfatal
-
-#endif /* lint */
-
-/* if neither of the above work, join all multi-line macro calls. */
-#endif
-
-EXT char serrbuf[BUFSIZ]; /* buffer for stderr */
-
-char *fetchname();
-int move_file();
-void copy_file();
-void say();
-void fatal();
-void pfatal();
-void ask();
-char *savestr();
-void set_signals();
-void ignore_signals();
-void makedirs();
-char *basename();
diff --git a/gnu/usr.bin/patch/version.c b/gnu/usr.bin/patch/version.c
deleted file mode 100644
index f0b5223..0000000
--- a/gnu/usr.bin/patch/version.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* $Header: version.c,v 2.0 86/09/17 15:40:11 lwall Exp $
- *
- * $Log: version.c,v $
- * Revision 2.0 86/09/17 15:40:11 lwall
- * Baseline for netwide release.
- *
- */
-
-#include "EXTERN.h"
-#include "common.h"
-#include "util.h"
-#include "INTERN.h"
-#include "patchlevel.h"
-#include "version.h"
-
-void my_exit();
-
-/* Print out the version number and die. */
-
-void
-version()
-{
- fprintf(stderr, "Patch version %s\n", PATCH_VERSION);
- my_exit(0);
-}
diff --git a/gnu/usr.bin/patch/version.h b/gnu/usr.bin/patch/version.h
deleted file mode 100644
index 08fe68d..0000000
--- a/gnu/usr.bin/patch/version.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* $Header: version.h,v 2.0 86/09/17 15:40:14 lwall Exp $
- *
- * $Log: version.h,v $
- * Revision 2.0 86/09/17 15:40:14 lwall
- * Baseline for netwide release.
- *
- */
-
-void version();
diff --git a/gnu/usr.bin/pr/COPYING b/gnu/usr.bin/pr/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/gnu/usr.bin/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
-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/pr/Makefile b/gnu/usr.bin/pr/Makefile
deleted file mode 100644
index 6c8d431..0000000
--- a/gnu/usr.bin/pr/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-
-PROG= pr
-SRCS= pr.c getopt.c getopt1.c error.c xmalloc.c version.c
-
-CFLAGS+=-I${.CURDIR}
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/pr/error.c b/gnu/usr.bin/pr/error.c
deleted file mode 100644
index e849c5b..0000000
--- a/gnu/usr.bin/pr/error.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* error.c -- error handler for noninteractive utilities
- Copyright (C) 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Written by David MacKenzie. */
-
-#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/pr/getopt.c b/gnu/usr.bin/pr/getopt.c
deleted file mode 100644
index a59a013..0000000
--- a/gnu/usr.bin/pr/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/pr/getopt.h b/gnu/usr.bin/pr/getopt.h
deleted file mode 100644
index 45541f5..0000000
--- a/gnu/usr.bin/pr/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/pr/getopt1.c b/gnu/usr.bin/pr/getopt1.c
deleted file mode 100644
index a32615c..0000000
--- a/gnu/usr.bin/pr/getopt1.c
+++ /dev/null
@@ -1,176 +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
-#include "config.h"
-#endif
-
-#include "getopt.h"
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#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/pr/pr.1 b/gnu/usr.bin/pr/pr.1
deleted file mode 100644
index 10cdd8c..0000000
--- a/gnu/usr.bin/pr/pr.1
+++ /dev/null
@@ -1,103 +0,0 @@
-.TH PR 1L \" -*- nroff -*-
-.SH NAME
-pr \- convert text files for printing
-.SH SYNOPSIS
-.B pr
-[+PAGE] [\-COLUMN] [\-abcdfFmrtv] [\-e[in-tab-char[in-tab-width]]]
-[\-h header] [\-i[out-tab-char[out-tab-width]]] [\-l page-length]
-[\-n[number-separator[digits]]] [\-o left-margin]
-[\-s[column-separator]] [\-w page-width] [\-\-help] [\-\-version] [file...]
-.SH DESCRIPTION
-This manual page
-documents the GNU version of
-.BR pr .
-.B pr
-prints on the standard output a paginated and optionally multicolumn
-copy of the text files given on the command line, or of the standard
-input if no files are given or when the file name `\-' is encountered.
-Form feeds in the input cause page breaks in the output.
-.SS OPTIONS
-.TP
-.I \+PAGE
-Begin printing with page \fIPAGE\fP.
-.TP
-.I \-COLUMN
-Produce \fICOLUMN\fP-column output and print columns down. The column
-width is automatically decreased as \fICOLUMN\fP increases; unless you
-use the \fI\-w\fP option to increase the page width as well, this
-option might cause some columns to be truncated.
-.TP
-.I \-a
-Print columns across rather than down.
-.TP
-.I \-b
-Balance columns on the last page.
-.TP
-.I \-c
-Print control characters using hat notation (e.g., `^G'); print other
-unprintable characters in octal backslash notation.
-.TP
-.I \-d
-Double space the output.
-.TP
-.I "\-e[in-tab-char[in-tab-width]]"
-Expand tabs to spaces on input. Optional argument \fIin-tab-char\fP
-is the input tab character, default tab. Optional argument
-\fIin-tab-width\fP is the input tab character's width, default 8.
-.TP
-.I "\-F, \-f"
-Use a formfeed instead of newlines to separate output pages.
-.TP
-.I "\-h header"
-Replace the filename in the header with the string \fIheader\fP.
-.TP
-.I "\-\-help"
-Print a usage message and exit with a non-zero status.
-.TP
-.I "\-i[out-tab-char[out-tab-width]]"
-Replace spaces with tabs on output. Optional argument
-\fIout-tab-char\fP is the output tab character, default tab.
-Optional argument \fIout-tab-width\fP is the output tab character's
-width, default 8.
-.TP
-.I "\-l page-length"
-Set the page length to \fIpage-length\fP lines. The default is 66.
-If \fIpage-length\fP is less than 10, the headers and footers are
-omitted, as if the \fI\-t\fP option had been given.
-.TP
-.I \-m
-Print all files in parallel, one in each column.
-.TP
-.I "\-n[number-separator[digits]]"
-Precede each column with a line number; with parallel files, precede
-each line with a line number. Optional argument
-\fInumber-separator\fP is the character to print after each number,
-default tab. Optional argument \fIdigits\fP is the number of digits
-per line number, default 5.
-.TP
-.I "\-o left-margin"
-Offset each line with a margin \fIleft-margin\fP spaces wide. The
-total page width is this offset plus the width set with the \fI\-w\fP
-option.
-.TP
-.I \-r
-Do not print a warning message when an argument file cannot be opened.
-Failure to open a file still makes the exit status nonzero, however.
-.TP
-.I "\-s[column-separator]"
-Separate columns by the single character \fIcolumn-separator\fP,
-default tab, instead of spaces.
-.TP
-.I \-t
-Do not print the 5-line header and the 5-line trailer that are
-normally on each page, and do not fill out the bottoms of pages (with
-blank lines or formfeeds).
-.TP
-.I \-v
-Print unprintable characters in octal backslash notation.
-.TP
-.I "\-\-version"
-Print version information on standard error then exit.
-.TP
-.I "\-w page-width"
-Set the page width to \fIpage-width\fP columns. The default is 72.
diff --git a/gnu/usr.bin/pr/pr.c b/gnu/usr.bin/pr/pr.c
deleted file mode 100644
index 250f532..0000000
--- a/gnu/usr.bin/pr/pr.c
+++ /dev/null
@@ -1,1875 +0,0 @@
-/* pr -- convert text files for printing.
- Copyright (C) 1988, 1991 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Author: Pete TerMaat. */
-
-/* Things to watch: Sys V screws up on ...
- pr -n -3 -s: /usr/dict/words
- pr -m -o10 -n /usr/dict/words{,,,}
- pr -6 -a -n -o5 /usr/dict/words
-
- Ideas:
-
- Keep a things_to_do list of functions to call when we know we have
- something to print. Cleaner than current series of checks.
-
- Improve the printing of control prefixes.
-
-
- Options:
-
- +PAGE Begin output at page PAGE of the output.
-
- -COLUMN Produce output that is COLUMN columns wide and print
- columns down.
-
- -a Print columns across rather than down. The input
- one
- two
- three
- four
- will be printed as
- one two three
- four
-
- -b Balance columns on the last page.
-
- -c Print unprintable characters as control prefixes.
- Control-g is printed as ^G.
-
- -d Double space the output.
-
- -e[c[k]] Expand tabs to spaces on input. Optional argument C
- is the input tab character. (Default is `\t'.) Optional
- argument K is the input tab character's width. (Default is 8.)
-
- -F
- -f Use formfeeds instead of newlines to separate pages.
-
- -h header Replace the filename in the header with the string HEADER.
-
- -i[c[k]] Replace spaces with tabs on output. Optional argument
- C is the output tab character. (Default is `\t'.) Optional
- argument K is the output tab character's width. (Default
- is 8.)
-
- -l lines Set the page length to LINES. Default is 66.
-
- -m Print files in parallel.
-
- -n[c[k]] Precede each column with a line number.
- (With parallel files, precede each line with a line
- number.) Optional argument C is the character to print
- after each number. (Default `\t'.) Optional argument
- K is the number of digits per line number. (Default 5.)
-
- -o offset Offset each line with a margin OFFSET spaces wide.
- Total page width is the size of this offset plus the
- width set with `-w'.
-
- -r Ignore files that can't be opened.
-
- -s[c] Separate each line with a character. Optional argument C is
- the character to be used. Default is `\t'.
-
- -t Do not print headers or footers.
-
- -v Print unprintable characters as escape sequences.
- Control-G becomes \007.
-
- -w width Set the page width to WIDTH characters. */
-
-
-#include <stdio.h>
-#include <getopt.h>
-#include <sys/types.h>
-#include <time.h>
-#include "system.h"
-#include "version.h"
-
-char *xmalloc ();
-char *xrealloc ();
-void error ();
-
-static int char_to_clump ();
-static int read_line ();
-static int print_page ();
-static int print_stored ();
-static int open_file ();
-static int skip_to_page ();
-static void getoptarg ();
-static void usage ();
-static void print_files ();
-static void init_header ();
-static void init_store_cols ();
-static void store_columns ();
-static void balance ();
-static void store_char ();
-static void pad_down ();
-static void read_rest_of_line ();
-static void print_char ();
-static void cleanup ();
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-/* Used with start_position in the struct COLUMN described below.
- If start_position == ANYWHERE, we aren't truncating columns and
- can begin printing a column anywhere. Otherwise we must pad to
- the horizontal position start_position. */
-#define ANYWHERE 0
-
-/* Each column has one of these structures allocated for it.
- If we're only dealing with one file, fp is the same for all
- columns.
-
- The general strategy is to spend time setting up these column
- structures (storing columns if necessary), after which printing
- is a matter of flitting from column to column and calling
- print_func.
-
- Parallel files, single files printing across in multiple
- columns, and single files printing down in multiple columns all
- fit the same printing loop.
-
- print_func Function used to print lines in this column.
- If we're storing this column it will be
- print_stored(), Otherwise it will be read_line().
-
- char_func Function used to process characters in this column.
- If we're storing this column it will be store_char(),
- otherwise it will be print_char().
-
- current_line Index of the current entry in line_vector, which
- contains the index of the first character of the
- current line in buff[].
-
- lines_stored Number of lines in this column which are stored in
- buff.
-
- lines_to_print If we're storing this column, lines_to_print is
- the number of stored_lines which remain to be
- printed. Otherwise it is the number of lines
- we can print without exceeding lines_per_body.
-
- start_position The horizontal position we want to be in before we
- print the first character in this column.
-
- numbered True means precede this column with a line number. */
-
-struct COLUMN
-{
- FILE *fp; /* Input stream for this column. */
- char *name; /* File name. */
- enum
- {
- OPEN,
- ON_HOLD, /* Hit a form feed. */
- CLOSED
- } status; /* Status of the file pointer. */
- int (*print_func) (); /* Func to print lines in this col. */
- void (*char_func) (); /* Func to print/store chars in this col. */
- int current_line; /* Index of current place in line_vector. */
- int lines_stored; /* Number of lines stored in buff. */
- int lines_to_print; /* No. lines stored or space left on page. */
- int start_position; /* Horizontal position of first char. */
- int numbered;
-};
-
-typedef struct COLUMN COLUMN;
-
-#define NULLCOL (COLUMN *)0
-
-/* The name under which this program was invoked. */
-char *program_name;
-
-/* All of the columns to print. */
-static COLUMN *column_vector;
-
-/* When printing a single file in multiple downward columns,
- we store the leftmost columns contiguously in buff.
- To print a line from buff, get the index of the first char
- from line_vector[i], and print up to line_vector[i + 1]. */
-static char *buff;
-
-/* Index of the position in buff where the next character
- will be stored. */
-static int buff_current;
-
-/* The number of characters in buff.
- Used for allocation of buff and to detect overflow of buff. */
-static int buff_allocated;
-
-/* Array of indices into buff.
- Each entry is an index of the first character of a line.
- This is used when storing lines to facilitate shuffling when
- we do column balancing on the last page. */
-static int *line_vector;
-
-/* Array of horizonal positions.
- For each line in line_vector, end_vector[line] is the horizontal
- position we are in after printing that line. We keep track of this
- so that we know how much we need to pad to prepare for the next
- column. */
-static int *end_vector;
-
-/* (-m) True means we're printing multiple files in parallel. */
-static int parallel_files = FALSE;
-
-/* (-[0-9]+) True means we're given an option explicitly specifying
- number of columns. Used to detect when this option is used with -m. */
-static int explicit_columns = FALSE;
-
-/* (-t) True means we're printing headers and footers. */
-static int extremities = TRUE;
-
-/* True means we need to print a header as soon as we know we've got input
- to print after it. */
-static int print_a_header;
-
-/* (-h) True means we're using the standard header rather than a
- customized one specified by the -h flag. */
-static int standard_header = TRUE;
-
-/* (-f) True means use formfeeds instead of newlines to separate pages. */
-static int use_form_feed = FALSE;
-
-/* True means we have read the standard input. */
-static int have_read_stdin = FALSE;
-
-/* True means the -a flag has been given. */
-static int print_across_flag = FALSE;
-
-/* True means we're printing one file in multiple (>1) downward columns. */
-static int storing_columns = TRUE;
-
-/* (-b) True means balance columns on the last page as Sys V does. */
-static int balance_columns = FALSE;
-
-/* (-l) Number of lines on a page, including header and footer lines. */
-static int lines_per_page = 66;
-
-/* Number of lines in the header and footer can be reset to 0 using
- the -t flag. */
-static int lines_per_header = 5;
-static int lines_per_body;
-static int lines_per_footer = 5;
-
-/* (-w) Width in characters of the page. Does not include the width of
- the margin. */
-static int chars_per_line = 72;
-
-/* Number of characters in a column. Based on the gutter and page widths. */
-static int chars_per_column;
-
-/* (-e) True means convert tabs to spaces on input. */
-static int untabify_input = FALSE;
-
-/* (-e) The input tab character. */
-static char input_tab_char = '\t';
-
-/* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ...
- where the leftmost column is 1. */
-static int chars_per_input_tab = 8;
-
-/* (-i) True means convert spaces to tabs on output. */
-static int tabify_output = FALSE;
-
-/* (-i) The output tab character. */
-static char output_tab_char = '\t';
-
-/* (-i) The width of the output tab. */
-static int chars_per_output_tab = 8;
-
-/* Keeps track of pending white space. When we hit a nonspace
- character after some whitespace, we print whitespace, tabbing
- if necessary to get to output_position + spaces_not_printed. */
-static int spaces_not_printed;
-
-/* Number of spaces between columns (though tabs can be used when possible to
- use up the equivalent amount of space). Not sure if this is worth making
- a flag for. BSD uses 0, Sys V uses 1. Sys V looks better. */
-static int chars_per_gutter = 1;
-
-/* (-o) Number of spaces in the left margin (tabs used when possible). */
-static int chars_per_margin = 0;
-
-/* Position where the next character will fall.
- Leftmost position is 0 + chars_per_margin.
- Rightmost position is chars_per_margin + chars_per_line - 1.
- This is important for converting spaces to tabs on output. */
-static int output_position;
-
-/* Horizontal position relative to the current file.
- (output_position depends on where we are on the page;
- input_position depends on where we are in the file.)
- Important for converting tabs to spaces on input. */
-static int input_position;
-
-/* Count number of failed opens so we can exit with non-zero
- status if there were any. */
-static int failed_opens = 0;
-
-/* The horizontal position we'll be at after printing a tab character
- of width c_ from the position h_. */
-#define pos_after_tab(c_, h_) h_ - h_ % c_ + c_
-
-/* The number of spaces taken up if we print a tab character with width
- c_ from position h_. */
-#define tab_width(c_, h_) - h_ % c_ + c_
-
-/* (-NNN) Number of columns of text to print. */
-static int columns = 1;
-
-/* (+NNN) Page number on which to begin printing. */
-static int first_page_number = 1;
-
-/* Number of files open (not closed, not on hold). */
-static int files_ready_to_read = 0;
-
-/* Current page number. Displayed in header. */
-static int page_number;
-
-/* Current line number. Displayed when -n flag is specified.
-
- When printing files in parallel (-m flag), line numbering is as follows:
- 1 foo goo moo
- 2 hoo too zoo
-
- When printing files across (-a flag), ...
- 1 foo 2 moo 3 goo
- 4 hoo 3 too 6 zoo
-
- Otherwise, line numbering is as follows:
- 1 foo 3 goo 5 too
- 2 moo 4 hoo 6 zoo */
-static int line_number;
-
-/* (-n) True means lines should be preceded by numbers. */
-static int numbered_lines = FALSE;
-
-/* (-n) Character which follows each line number. */
-static char number_separator = '\t';
-
-/* (-n) Width in characters of a line number. */
-static int chars_per_number = 5;
-
-/* Used when widening the first column to accommodate numbers -- only
- needed when printing files in parallel. Includes width of both the
- number and the number_separator. */
-static int number_width;
-
-/* Buffer sprintf uses to format a line number. */
-static char *number_buff;
-
-/* (-v) True means unprintable characters are printed as escape sequences.
- control-g becomes \007. */
-static int use_esc_sequence = FALSE;
-
-/* (-c) True means unprintable characters are printed as control prefixes.
- control-g becomes ^G. */
-static int use_cntrl_prefix = FALSE;
-
-/* (-d) True means output is double spaced. */
-static int double_space = FALSE;
-
-/* Number of files opened initially in init_files. Should be 1
- unless we're printing multiple files in parallel. */
-static int total_files = 0;
-
-/* (-r) True means don't complain if we can't open a file. */
-static int ignore_failed_opens = FALSE;
-
-/* (-s) True means we separate columns with a specified character. */
-static int use_column_separator = FALSE;
-
-/* Character used to separate columns if the the -s flag has been specified. */
-static char column_separator = '\t';
-
-/* Number of separator characters waiting to be printed as soon as we
- know that we have any input remaining to be printed. */
-static int separators_not_printed;
-
-/* Position we need to pad to, as soon as we know that we have input
- remaining to be printed. */
-static int padding_not_printed;
-
-/* True means we should pad the end of the page. Remains false until we
- know we have a page to print. */
-static int pad_vertically;
-
-/* (-h) String of characters used in place of the filename in the header. */
-static char *custom_header;
-
-/* String containing the date, filename or custom header, and "Page ". */
-static char *header;
-
-static int *clump_buff;
-
-/* True means we truncate lines longer than chars_per_column. */
-static int truncate_lines = FALSE;
-
-/* If non-zero, display usage information and exit. */
-static int flag_help;
-
-/* If non-zero, print the version on standard error. */
-static int flag_version;
-
-static struct option const long_options[] =
-{
- {"help", no_argument, &flag_help, 1},
- {"version", no_argument, &flag_version, 1},
- {0, 0, 0, 0}
-};
-
-/* Return the number of columns that have either an open file or
- stored lines. */
-
-static int
-cols_ready_to_print ()
-{
- COLUMN *q;
- int i;
- int n;
-
- n = 0;
- for (q = column_vector, i = 0; i < columns; ++q, ++i)
- if (q->status == OPEN ||
- (storing_columns && q->lines_stored > 0 && q->lines_to_print > 0))
- ++n;
- return n;
-}
-
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int accum = 0;
- int n_files;
- char **file_names;
-
- program_name = argv[0];
-
- n_files = 0;
- file_names = (char **) xmalloc ((argc - 1) * sizeof (char *));
-
- while (1)
- {
- c = getopt_long (argc, argv,
- "-0123456789abcde::fFh:i::l:mn::o:rs::tvw:",
- long_options, (int *) 0);
- if (c == 1) /* Non-option argument. */
- {
- char *s;
- s = optarg;
- if (*s == '+')
- {
- ++s;
- if (!ISDIGIT (*s))
- {
- error (0, 0, "`+' requires a numeric argument");
- usage ();
- }
- /* FIXME: use strtol */
- first_page_number = atoi (s);
- }
- else
- {
- file_names[n_files++] = optarg;
- }
- }
- else
- {
- if (ISDIGIT (c))
- {
- accum = accum * 10 + c - '0';
- continue;
- }
- else
- {
- if (accum > 0)
- {
- columns = accum;
- explicit_columns = TRUE;
- accum = 0;
- }
- }
- }
-
- if (c == 1)
- continue;
-
- if (c == EOF)
- break;
-
- switch (c)
- {
- case 0: /* getopt long option */
- break;
-
- case 'a':
- print_across_flag = TRUE;
- storing_columns = FALSE;
- break;
- case 'b':
- balance_columns = TRUE;
- break;
- case 'c':
- use_cntrl_prefix = TRUE;
- break;
- case 'd':
- double_space = TRUE;
- break;
- case 'e':
- if (optarg)
- getoptarg (optarg, 'e', &input_tab_char,
- &chars_per_input_tab);
- /* Could check tab width > 0. */
- untabify_input = TRUE;
- break;
- case 'f':
- case 'F':
- use_form_feed = TRUE;
- break;
- case 'h':
- custom_header = optarg;
- standard_header = FALSE;
- break;
- case 'i':
- if (optarg)
- getoptarg (optarg, 'i', &output_tab_char,
- &chars_per_output_tab);
- /* Could check tab width > 0. */
- tabify_output = TRUE;
- break;
- case 'l':
- lines_per_page = atoi (optarg);
- break;
- case 'm':
- parallel_files = TRUE;
- storing_columns = FALSE;
- break;
- case 'n':
- numbered_lines = TRUE;
- if (optarg)
- getoptarg (optarg, 'n', &number_separator,
- &chars_per_number);
- break;
- case 'o':
- chars_per_margin = atoi (optarg);
- break;
- case 'r':
- ignore_failed_opens = TRUE;
- break;
- case 's':
- use_column_separator = TRUE;
- if (optarg)
- {
- char *s;
- s = optarg;
- column_separator = *s;
- if (*++s)
- {
- fprintf (stderr, "\
-%s: extra characters in the argument to the `-s' option: `%s'\n",
- program_name, s);
- usage ();
- }
- }
- break;
- case 't':
- extremities = FALSE;
- break;
- case 'v':
- use_esc_sequence = TRUE;
- break;
- case 'w':
- chars_per_line = atoi (optarg);
- break;
- default:
- usage ();
- break;
- }
- }
-
- if (flag_version)
- {
- fprintf (stderr, "%s\n", version_string);
- exit (0);
- }
-
- if (flag_help)
- usage ();
-
- if (parallel_files && explicit_columns)
- error (1, 0,
- "Cannot specify number of columns when printing in parallel.");
-
- if (parallel_files && print_across_flag)
- error (1, 0,
- "Cannot specify both printing across and printing in parallel.");
-
- for ( ; optind < argc; optind++)
- {
- file_names[n_files++] = argv[optind];
- }
-
- if (n_files == 0)
- {
- /* No file arguments specified; read from standard input. */
- print_files (0, (char **) 0);
- }
- else
- {
- if (parallel_files)
- print_files (n_files, file_names);
- else
- {
- int i;
- for (i=0; i<n_files; i++)
- print_files (1, &file_names[i]);
- }
- }
-
- cleanup ();
-
- if (have_read_stdin && fclose (stdin) == EOF)
- error (1, errno, "standard input");
- if (ferror (stdout) || fclose (stdout) == EOF)
- error (1, errno, "write error");
- if (failed_opens > 0)
- exit(1);
- exit (0);
-}
-
-/* Parse options of the form -scNNN.
-
- Example: -nck, where 'n' is the option, c is the optional number
- separator, and k is the optional width of the field used when printing
- a number. */
-
-static void
-getoptarg (arg, switch_char, character, number)
- char *arg, switch_char, *character;
- int *number;
-{
- if (!ISDIGIT (*arg))
- *character = *arg++;
- if (*arg)
- {
- if (ISDIGIT (*arg))
- *number = atoi (arg);
- else
- {
- fprintf (stderr, "\
-%s: extra characters in the argument to the `-%c' option: `%s'\n",
- program_name, switch_char, arg);
- usage ();
- }
- }
-}
-
-/* Set parameters related to formatting. */
-
-static void
-init_parameters (number_of_files)
- int number_of_files;
-{
- int chars_used_by_number = 0;
-
- lines_per_body = lines_per_page - lines_per_header - lines_per_footer;
- if (lines_per_body <= 0)
- extremities = FALSE;
- if (extremities == FALSE)
- lines_per_body = lines_per_page;
-
- if (double_space)
- lines_per_body = lines_per_body / 2;
-
- /* If input is stdin, cannot print parallel files. BSD dumps core
- on this. */
- if (number_of_files == 0)
- parallel_files = FALSE;
-
- if (parallel_files)
- columns = number_of_files;
-
- /* Tabification is assumed for multiple columns. */
- if (columns > 1)
- {
- if (!use_column_separator)
- truncate_lines = TRUE;
-
- untabify_input = TRUE;
- tabify_output = TRUE;
- }
- else
- storing_columns = FALSE;
-
- if (numbered_lines)
- {
- if (number_separator == input_tab_char)
- {
- number_width = chars_per_number +
- tab_width (chars_per_input_tab,
- (chars_per_margin + chars_per_number));
- }
- else
- number_width = chars_per_number + 1;
- /* The number is part of the column width unless we are
- printing files in parallel. */
- if (parallel_files)
- chars_used_by_number = number_width;
- }
-
- chars_per_column = (chars_per_line - chars_used_by_number -
- (columns - 1) * chars_per_gutter) / columns;
-
- if (chars_per_column < 1)
- error (1, 0, "page width too narrow");
-
- if (numbered_lines)
- {
- if (number_buff != (char *) 0)
- free (number_buff);
- number_buff = (char *)
- xmalloc (2 * chars_per_number * sizeof (char));
- }
-
- /* Pick the maximum between the tab width and the width of an
- escape sequence. */
- if (clump_buff != (int *) 0)
- free (clump_buff);
- clump_buff = (int *) xmalloc ((chars_per_input_tab > 4
- ? chars_per_input_tab : 4) * sizeof (int));
-}
-
-/* Open the necessary files,
- maintaining a COLUMN structure for each column.
-
- With multiple files, each column p has a different p->fp.
- With single files, each column p has the same p->fp.
- Return 1 if (number_of_files > 0) and no files can be opened,
- 0 otherwise. */
-
-static int
-init_fps (number_of_files, av)
- int number_of_files;
- char **av;
-{
- int i, files_left;
- COLUMN *p;
- FILE *firstfp;
- char *firstname;
-
- total_files = 0;
-
- if (column_vector != NULLCOL)
- free ((char *) column_vector);
- column_vector = (COLUMN *) xmalloc (columns * sizeof (COLUMN));
-
- if (parallel_files)
- {
- files_left = number_of_files;
- for (p = column_vector; files_left--; ++p, ++av)
- {
- if (open_file (*av, p) == 0)
- {
- --p;
- --columns;
- }
- }
- if (columns == 0)
- return 1;
- init_header ("", -1);
- }
- else
- {
- p = column_vector;
- if (number_of_files > 0)
- {
- if (open_file (*av, p) == 0)
- return 1;
- init_header (*av, fileno (p->fp));
- }
- else
- {
- p->name = "standard input";
- p->fp = stdin;
- have_read_stdin = TRUE;
- p->status = OPEN;
- ++total_files;
- init_header ("", -1);
- }
-
- firstname = p->name;
- firstfp = p->fp;
- for (i = columns - 1, ++p; i; --i, ++p)
- {
- p->name = firstname;
- p->fp = firstfp;
- p->status = OPEN;
- }
- }
- files_ready_to_read = total_files;
- return 0;
-}
-
-/* Determine print_func and char_func, the functions
- used by each column for printing and/or storing.
-
- Determine the horizontal position desired when we begin
- printing a column (p->start_position). */
-
-static void
-init_funcs ()
-{
- int i, h, h_next;
- COLUMN *p;
-
- h = chars_per_margin;
-
- if (use_column_separator)
- h_next = ANYWHERE;
- else
- {
- /* When numbering lines of parallel files, we enlarge the
- first column to accomodate the number. Looks better than
- the Sys V approach. */
- if (parallel_files && numbered_lines)
- h_next = h + chars_per_column + number_width;
- else
- h_next = h + chars_per_column;
- }
-
- /* This loop takes care of all but the rightmost column. */
-
- for (p = column_vector, i = 1; i < columns; ++p, ++i)
- {
- if (storing_columns) /* One file, multi columns down. */
- {
- p->char_func = store_char;
- p->print_func = print_stored;
- }
- else
- /* One file, multi columns across; or parallel files. */
- {
- p->char_func = print_char;
- p->print_func = read_line;
- }
-
- /* Number only the first column when printing files in
- parallel. */
- p->numbered = numbered_lines && (!parallel_files || i == 1);
- p->start_position = h;
-
- /* If we're using separators, all start_positions are
- ANYWHERE, except the first column's start_position when
- using a margin. */
-
- if (use_column_separator)
- {
- h = ANYWHERE;
- h_next = ANYWHERE;
- }
- else
- {
- h = h_next + chars_per_gutter;
- h_next = h + chars_per_column;
- }
- }
-
- /* The rightmost column.
-
- Doesn't need to be stored unless we intend to balance
- columns on the last page. */
- if (storing_columns && balance_columns)
- {
- p->char_func = store_char;
- p->print_func = print_stored;
- }
- else
- {
- p->char_func = print_char;
- p->print_func = read_line;
- }
-
- p->numbered = numbered_lines && (!parallel_files || i == 1);
- p->start_position = h;
-}
-
-/* Open a file. Return nonzero if successful, zero if failed. */
-
-static int
-open_file (name, p)
- char *name;
- COLUMN *p;
-{
- if (!strcmp (name, "-"))
- {
- p->name = "standard input";
- p->fp = stdin;
- have_read_stdin = 1;
- }
- else
- {
- p->name = name;
- p->fp = fopen (name, "r");
- }
- if (p->fp == NULL)
- {
- ++failed_opens;
- if (!ignore_failed_opens)
- error (0, errno, "%s", name);
- return 0;
- }
- p->status = OPEN;
- ++total_files;
- return 1;
-}
-
-/* Close the file in P.
-
- If we aren't dealing with multiple files in parallel, we change
- the status of all columns in the column list to reflect the close. */
-
-static void
-close_file (p)
- COLUMN *p;
-{
- COLUMN *q;
- int i;
-
- if (p->status == CLOSED)
- return;
- if (ferror (p->fp))
- error (1, errno, "%s", p->name);
- if (p->fp != stdin && fclose (p->fp) == EOF)
- error (1, errno, "%s", p->name);
-
- if (!parallel_files)
- {
- for (q = column_vector, i = columns; i; ++q, --i)
- {
- q->status = CLOSED;
- if (q->lines_stored == 0)
- {
- q->lines_to_print = 0;
- }
- }
- }
- else
- {
- p->status = CLOSED;
- p->lines_to_print = 0;
- }
-
- --files_ready_to_read;
-}
-
-/* Put a file on hold until we start a new page,
- since we've hit a form feed.
-
- If we aren't dealing with parallel files, we must change the
- status of all columns in the column list. */
-
-static void
-hold_file (p)
- COLUMN *p;
-{
- COLUMN *q;
- int i;
-
- if (!parallel_files)
- for (q = column_vector, i = columns; i; ++q, --i)
- q->status = ON_HOLD;
- else
- p->status = ON_HOLD;
- p->lines_to_print = 0;
- --files_ready_to_read;
-}
-
-/* Undo hold_file -- go through the column list and change any
- ON_HOLD columns to OPEN. Used at the end of each page. */
-
-static void
-reset_status ()
-{
- int i = columns;
- COLUMN *p;
-
- for (p = column_vector; i; --i, ++p)
- if (p->status == ON_HOLD)
- {
- p->status = OPEN;
- files_ready_to_read++;
- }
-}
-
-/* Print a single file, or multiple files in parallel.
-
- Set up the list of columns, opening the necessary files.
- Allocate space for storing columns, if necessary.
- Skip to first_page_number, if user has asked to skip leading pages.
- Determine which functions are appropriate to store/print lines
- in each column.
- Print the file(s). */
-
-static void
-print_files (number_of_files, av)
- int number_of_files;
- char **av;
-{
- init_parameters (number_of_files);
- if (init_fps (number_of_files, av))
- return;
- if (storing_columns)
- init_store_cols ();
-
- if (first_page_number > 1)
- {
- if (!skip_to_page (first_page_number))
- return;
- else
- page_number = first_page_number;
- }
- else
- page_number = 1;
-
- init_funcs ();
-
- line_number = 1;
- while (print_page ())
- ;
-}
-
-/* Generous estimate of number of characters taken up by "Jun 7 00:08 " and
- "Page NNNNN". */
-#define CHARS_FOR_DATE_AND_PAGE 50
-
-/* Initialize header information.
- If DESC is non-negative, it is a file descriptor open to
- FILENAME for reading.
-
- Allocate space for a header string,
- Determine the time, insert file name or user-specified string.
-
- It might be nice to have a "blank headers" option, since
- pr -h "" still prints the date and page number. */
-
-static void
-init_header (filename, desc)
- char *filename;
- int desc;
-{
- int chars_per_header;
- char *f = filename;
- char *t, *middle;
- struct stat st;
-
- if (filename == 0)
- f = "";
-
- /* If parallel files or standard input, use current time. */
- if (desc < 0 || !strcmp (filename, "-") || fstat (desc, &st))
- st.st_mtime = time ((time_t *) 0);
- t = ctime (&st.st_mtime);
-
- t[16] = '\0'; /* Mark end of month and time string. */
- t[24] = '\0'; /* Mark end of year string. */
-
- middle = standard_header ? f : custom_header;
-
- chars_per_header = strlen (middle) + CHARS_FOR_DATE_AND_PAGE + 1;
- if (header != (char *) 0)
- free (header);
- header = (char *) xmalloc (chars_per_header * sizeof (char));
-
- sprintf (header, "%s %s %s Page", &t[4], &t[20], middle);
-}
-
-/* Set things up for printing a page
-
- Scan through the columns ...
- Determine which are ready to print
- (i.e., which have lines stored or open files)
- Set p->lines_to_print appropriately
- (to p->lines_stored if we're storing, or lines_per_body
- if we're reading straight from the file)
- Keep track of this total so we know when to stop printing */
-
-static void
-init_page ()
-{
- int j;
- COLUMN *p;
-
- if (storing_columns)
- {
- store_columns ();
- for (j = columns - 1, p = column_vector; j; --j, ++p)
- {
- p->lines_to_print = p->lines_stored;
- }
-
- /* Last column. */
- if (balance_columns)
- {
- p->lines_to_print = p->lines_stored;
- }
- /* Since we're not balancing columns, we don't need to store
- the rightmost column. Read it straight from the file. */
- else
- {
- if (p->status == OPEN)
- {
- p->lines_to_print = lines_per_body;
- }
- else
- p->lines_to_print = 0;
- }
- }
- else
- for (j = columns, p = column_vector; j; --j, ++p)
- if (p->status == OPEN)
- {
- p->lines_to_print = lines_per_body;
- }
- else
- p->lines_to_print = 0;
-}
-
-/* Print one page.
-
- As long as there are lines left on the page and columns ready to print,
- Scan across the column list
- if the column has stored lines or the file is open
- pad to the appropriate spot
- print the column
- pad the remainder of the page with \n or \f as requested
- reset the status of all files -- any files which where on hold because
- of formfeeds are now put back into the lineup. */
-
-static int
-print_page ()
-{
- int j;
- int lines_left_on_page;
- COLUMN *p;
-
- /* Used as an accumulator (with | operator) of successive values of
- pad_vertically. The trick is to set pad_vertically
- to zero before each run through the inner loop, then after that
- loop, it tells us whether a line was actually printed (whether a
- newline needs to be output -- or two for double spacing). But those
- values have to be accumulated (in pv) so we can invoke pad_down
- properly after the outer loop completes. */
- int pv;
-
- init_page ();
-
- if (cols_ready_to_print () == 0)
- return FALSE;
-
- if (extremities)
- print_a_header = TRUE;
-
- /* Don't pad unless we know a page was printed. */
- pad_vertically = FALSE;
- pv = FALSE;
-
- lines_left_on_page = lines_per_body;
- if (double_space)
- lines_left_on_page *= 2;
-
- while (lines_left_on_page > 0 && cols_ready_to_print () > 0)
- {
- output_position = 0;
- spaces_not_printed = 0;
- separators_not_printed = 0;
- pad_vertically = FALSE;
-
- for (j = 1, p = column_vector; j <= columns; ++j, ++p)
- {
- input_position = 0;
- if (p->lines_to_print > 0)
- {
- padding_not_printed = p->start_position;
-
- if (!(p->print_func) (p))
- read_rest_of_line (p);
- pv |= pad_vertically;
-
- if (use_column_separator)
- ++separators_not_printed;
-
- --p->lines_to_print;
- if (p->lines_to_print <= 0)
- {
- if (cols_ready_to_print () <= 0)
- break;
- }
- }
- }
-
- if (pad_vertically)
- {
- putchar ('\n');
- --lines_left_on_page;
- }
-
- if (double_space && pv && extremities)
- {
- putchar ('\n');
- --lines_left_on_page;
- }
- }
-
- pad_vertically = pv;
-
- if (pad_vertically && extremities)
- pad_down (lines_left_on_page + lines_per_footer);
-
- reset_status (); /* Change ON_HOLD to OPEN. */
-
- return TRUE; /* More pages to go. */
-}
-
-/* Allocate space for storing columns.
-
- This is necessary when printing multiple columns from a single file.
- Lines are stored consecutively in buff, separated by '\0'.
- (We can't use a fixed offset since with the '-s' flag lines aren't
- truncated.)
-
- We maintain a list (line_vector) of pointers to the beginnings
- of lines in buff. We allocate one more than the number of lines
- because the last entry tells us the index of the last character,
- which we need to know in order to print the last line in buff. */
-
-static void
-init_store_cols ()
-{
- int total_lines = lines_per_body * columns;
- int chars_if_truncate = total_lines * (chars_per_column + 1);
-
- if (line_vector != (int *) 0)
- free ((int *) line_vector);
- line_vector = (int *) xmalloc ((total_lines + 1) * sizeof (int *));
-
- if (end_vector != (int *) 0)
- free ((int *) end_vector);
- end_vector = (int *) xmalloc (total_lines * sizeof (int *));
-
- if (buff != (char *) 0)
- free (buff);
- buff_allocated = use_column_separator ? 2 * chars_if_truncate
- : chars_if_truncate; /* Tune this. */
- buff = (char *) xmalloc (buff_allocated * sizeof (char));
-}
-
-/* Store all but the rightmost column.
- (Used when printing a single file in multiple downward columns)
-
- For each column
- set p->current_line to be the index in line_vector of the
- first line in the column
- For each line in the column
- store the line in buff
- add to line_vector the index of the line's first char
- buff_start is the index in buff of the first character in the
- current line. */
-
-static void
-store_columns ()
-{
- int i, j;
- int line = 0;
- int buff_start;
- int last_col; /* The rightmost column which will be saved in buff */
- COLUMN *p;
-
- buff_current = 0;
- buff_start = 0;
-
- if (balance_columns)
- last_col = columns;
- else
- last_col = columns - 1;
-
- for (i = 1, p = column_vector; i <= last_col; ++i, ++p)
- p->lines_stored = 0;
-
- for (i = 1, p = column_vector; i <= last_col && files_ready_to_read;
- ++i, ++p)
- {
- p->current_line = line;
- for (j = lines_per_body; j && files_ready_to_read; --j)
-
- if (p->status == OPEN) /* Redundant. Clean up. */
- {
- input_position = 0;
-
- if (!read_line (p, i))
- read_rest_of_line (p);
-
- if (p->status == OPEN
- || buff_start != buff_current)
- {
- ++p->lines_stored;
- line_vector[line] = buff_start;
- end_vector[line++] = input_position;
- buff_start = buff_current;
- }
- }
- }
-
- /* Keep track of the location of the last char in buff. */
- line_vector[line] = buff_start;
-
- if (balance_columns && p->lines_stored != lines_per_body)
- balance (line);
-}
-
-static void
-balance (total_stored)
- int total_stored;
-{
- COLUMN *p;
- int i, lines;
- int first_line = 0;
-
- for (i = 1, p = column_vector; i <= columns; ++i, ++p)
- {
- lines = total_stored / columns;
- if (i <= total_stored % columns)
- ++lines;
-
- p->lines_stored = lines;
- p->current_line = first_line;
-
- first_line += lines;
- }
-}
-
-/* Store a character in the buffer. */
-
-static void
-store_char (c)
- int c;
-{
- if (buff_current >= buff_allocated)
- {
- /* May be too generous. */
- buff_allocated = 2 * buff_allocated;
- buff = (char *) xrealloc (buff, buff_allocated * sizeof (char));
- }
- buff[buff_current++] = (char) c;
-}
-
-static void
-number (p)
- COLUMN *p;
-{
- int i;
- char *s;
-
- sprintf (number_buff, "%*d", chars_per_number, line_number++);
- s = number_buff;
- for (i = chars_per_number; i > 0; i--)
- (p->char_func) ((int) *s++);
-
- if (number_separator == input_tab_char)
- {
- i = number_width - chars_per_number;
- while (i-- > 0)
- (p->char_func) ((int) ' ');
- }
- else
- (p->char_func) ((int) number_separator);
-
- if (truncate_lines && !parallel_files)
- input_position += number_width;
-}
-
-/* Print (or store) padding until the current horizontal position
- is position. */
-
-static void
-pad_across_to (position)
- int position;
-{
- register int h = output_position;
-
- if (tabify_output)
- spaces_not_printed = position - output_position;
- else
- {
- while (++h <= position)
- putchar (' ');
- output_position = position;
- }
-}
-
-/* Pad to the bottom of the page.
-
- If the user has requested a formfeed, use one.
- Otherwise, use newlines. */
-
-static void
-pad_down (lines)
- int lines;
-{
- register int i;
-
- if (use_form_feed)
- putchar ('\f');
- else
- for (i = lines; i; --i)
- putchar ('\n');
-}
-
-/* Read the rest of the line.
-
- Read from the current column's file until an end of line is
- hit. Used when we've truncated a line and we no longer need
- to print or store its characters. */
-
-static void
-read_rest_of_line (p)
- COLUMN *p;
-{
- register int c;
- FILE *f = p->fp;
-
- while ((c = getc (f)) != '\n')
- {
- if (c == '\f')
- {
- hold_file (p);
- break;
- }
- else if (c == EOF)
- {
- close_file (p);
- break;
- }
- }
-}
-
-/* If we're tabifying output,
-
- When print_char encounters white space it keeps track
- of our desired horizontal position and delays printing
- until this function is called. */
-
-static void
-print_white_space ()
-{
- register int h_new;
- register int h_old = output_position;
- register int goal = h_old + spaces_not_printed;
-
- while (goal - h_old > 1
- && (h_new = pos_after_tab (chars_per_output_tab, h_old)) <= goal)
- {
- putchar (output_tab_char);
- h_old = h_new;
- }
- while (++h_old <= goal)
- putchar (' ');
-
- output_position = goal;
- spaces_not_printed = 0;
-}
-
-/* Print column separators.
-
- We keep a count until we know that we'll be printing a line,
- then print_separators() is called. */
-
-static void
-print_separators ()
-{
- for (; separators_not_printed > 0; --separators_not_printed)
- print_char (column_separator);
-}
-
-/* Print (or store, depending on p->char_func) a clump of N
- characters. */
-
-static void
-print_clump (p, n, clump)
- COLUMN *p;
- int n;
- int *clump;
-{
- while (n--)
- (p->char_func) (*clump++);
-}
-
-/* Print a character.
-
- If we're tabifying, all tabs have been converted to spaces by
- process_char(). Keep a count of consecutive spaces, and when
- a nonspace is encountered, call print_white_space() to print the
- required number of tabs and spaces. */
-
-static void
-print_char (c)
- int c;
-{
- if (tabify_output)
- {
- if (c == ' ')
- {
- ++spaces_not_printed;
- return;
- }
- else if (spaces_not_printed > 0)
- print_white_space ();
-
- /* Nonprintables are assumed to have width 0, except '\b'. */
- if (!ISPRINT (c))
- {
- if (c == '\b')
- --output_position;
- }
- else
- ++output_position;
- }
- putchar (c);
-}
-
-/* Skip to page PAGE before printing. */
-
-static int
-skip_to_page (page)
- int page;
-{
- int n, i, j;
- COLUMN *p;
-
- for (n = 1; n < page; ++n)
- {
- for (i = 1; i <= lines_per_body; ++i)
- {
- for (j = 1, p = column_vector; j <= columns; ++j, ++p)
- read_rest_of_line (p);
- }
- reset_status ();
- }
- return files_ready_to_read > 0;
-}
-
-/* Print a header.
-
- Formfeeds are assumed to use up two lines at the beginning of
- the page. */
-
-static void
-print_header ()
-{
- if (!use_form_feed)
- fprintf (stdout, "\n\n");
-
- output_position = 0;
- pad_across_to (chars_per_margin);
- print_white_space ();
-
- fprintf (stdout, "%s %d\n\n\n", header, page_number++);
-
- print_a_header = FALSE;
- output_position = 0;
-}
-
-/* Print (or store, if p->char_func is store_char()) a line.
-
- Read a character to determine whether we have a line or not.
- (We may hit EOF, \n, or \f)
-
- Once we know we have a line,
- set pad_vertically = TRUE, meaning it's safe
- to pad down at the end of the page, since we do have a page.
- print a header if needed.
- pad across to padding_not_printed if needed.
- print any separators which need to be printed.
- print a line number if it needs to be printed.
-
- Print the clump which corresponds to the first character.
-
- Enter a loop and keep printing until an end of line condition
- exists, or until we exceed chars_per_column.
-
- Return FALSE if we exceed chars_per_column before reading
- an end of line character, TRUE otherwise. */
-
-static int
-read_line (p)
- COLUMN *p;
-{
- register int c, chars;
- int last_input_position;
-
- c = getc (p->fp);
-
- last_input_position = input_position;
- switch (c)
- {
- case '\f':
- hold_file (p);
- return TRUE;
- case EOF:
- close_file (p);
- return TRUE;
- case '\n':
- break;
- default:
- chars = char_to_clump (c);
- }
-
- if (truncate_lines && input_position > chars_per_column)
- {
- input_position = last_input_position;
- return FALSE;
- }
-
- if (p->char_func != store_char)
- {
- pad_vertically = TRUE;
-
- if (print_a_header)
- print_header ();
-
- if (padding_not_printed != ANYWHERE)
- {
- pad_across_to (padding_not_printed);
- padding_not_printed = ANYWHERE;
- }
-
- if (use_column_separator)
- print_separators ();
- }
-
- if (p->numbered)
- number (p);
-
- if (c == '\n')
- return TRUE;
-
- print_clump (p, chars, clump_buff);
-
- for (;;)
- {
- c = getc (p->fp);
-
- switch (c)
- {
- case '\n':
- return TRUE;
- case '\f':
- hold_file (p);
- return TRUE;
- case EOF:
- close_file (p);
- return TRUE;
- }
-
- last_input_position = input_position;
- chars = char_to_clump (c);
- if (truncate_lines && input_position > chars_per_column)
- {
- input_position = last_input_position;
- return FALSE;
- }
-
- print_clump (p, chars, clump_buff);
- }
-}
-
-/* Print a line from buff.
-
- If this function has been called, we know we have something to
- print. Therefore we set pad_vertically to TRUE, print
- a header if necessary, pad across if necessary, and print
- separators if necessary.
-
- Return TRUE, meaning there is no need to call read_rest_of_line. */
-
-static int
-print_stored (p)
- COLUMN *p;
-{
- int line = p->current_line++;
- register char *first = &buff[line_vector[line]];
- register char *last = &buff[line_vector[line + 1]];
-
- pad_vertically = TRUE;
-
- if (print_a_header)
- print_header ();
-
- if (padding_not_printed != ANYWHERE)
- {
- pad_across_to (padding_not_printed);
- padding_not_printed = ANYWHERE;
- }
-
- if (use_column_separator)
- print_separators ();
-
- while (first != last)
- print_char (*first++);
-
- if (spaces_not_printed == 0)
- output_position = p->start_position + end_vector[line];
-
- return TRUE;
-}
-
-/* Convert a character to the proper format and return the number of
- characters in the resulting clump. Increment input_position by
- the width of the clump.
-
- Tabs are converted to clumps of spaces.
- Nonprintable characters may be converted to clumps of escape
- sequences or control prefixes.
-
- Note: the width of a clump is not necessarily equal to the number of
- characters in clump_buff. (e.g, the width of '\b' is -1, while the
- number of characters is 1.) */
-
-static int
-char_to_clump (c)
- int c;
-{
- register int *s = clump_buff;
- register int i;
- char esc_buff[4];
- int width;
- int chars;
-
- if (c == input_tab_char)
- {
- width = tab_width (chars_per_input_tab, input_position);
-
- if (untabify_input)
- {
- for (i = width; i; --i)
- *s++ = ' ';
- chars = width;
- }
- else
- {
- *s = c;
- chars = 1;
- }
-
- }
- else if (!ISPRINT (c))
- {
- if (use_esc_sequence)
- {
- width = 4;
- chars = 4;
- *s++ = '\\';
- sprintf (esc_buff, "%03o", c);
- for (i = 0; i <= 2; ++i)
- *s++ = (int) esc_buff[i];
- }
- else if (use_cntrl_prefix)
- {
- if (c < 0200)
- {
- width = 2;
- chars = 2;
- *s++ = '^';
- *s++ = c ^ 0100;
- }
- else
- {
- width = 4;
- chars = 4;
- *s++ = '\\';
- sprintf (esc_buff, "%03o", c);
- for (i = 0; i <= 2; ++i)
- *s++ = (int) esc_buff[i];
- }
- }
- else if (c == '\b')
- {
- width = -1;
- chars = 1;
- *s = c;
- }
- else
- {
- width = 0;
- chars = 1;
- *s = c;
- }
- }
- else
- {
- width = 1;
- chars = 1;
- *s = c;
- }
-
- input_position += width;
- return chars;
-}
-
-/* We've just printed some files and need to clean up things before
- looking for more options and printing the next batch of files.
-
- Free everything we've xmalloc'ed, except `header'. */
-
-static void
-cleanup ()
-{
- if (number_buff)
- free (number_buff);
- if (clump_buff)
- free (clump_buff);
- if (column_vector)
- free (column_vector);
- if (line_vector)
- free (line_vector);
- if (end_vector)
- free (end_vector);
- if (buff)
- free (buff);
-}
-
-/* Complain, print a usage message, and die. */
-
-static void
-usage ()
-{
- fprintf (stderr, "\
-Usage: %s [+PAGE] [-COLUMN] [-abcdfFmrtv] [-e[in-tab-char[in-tab-width]]]\n\
- [-h header] [-i[out-tab-char[out-tab-width]]] [-l page-length]\n\
- [-n[number-separator[digits]]] [-o left-margin]\n\
- [-s[column-separator]] [-w page-width] [--help] [--version] [file...]\n",
- program_name);
- exit (2);
-}
diff --git a/gnu/usr.bin/pr/system.h b/gnu/usr.bin/pr/system.h
deleted file mode 100644
index d26022d..0000000
--- a/gnu/usr.bin/pr/system.h
+++ /dev/null
@@ -1,168 +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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Include sys/types.h before this file. */
-
-#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)
-#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
-
-#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
-#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
-#include <memory.h>
-#endif
-#include <string.h>
-#ifndef index
-#define index strchr
-#endif
-#ifndef rindex
-#define rindex strrchr
-#endif
-/* Don't define bcopy; we need one that can handle overlaps. */
-#ifndef bzero
-#define bzero(s, n) memset ((s), 0, (n))
-#endif
-#ifndef bcmp
-#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
-#endif
-#else
-#include <strings.h>
-#ifndef __386BSD__
-char *memchr ();
-#endif
-#endif
-
-#include <errno.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-char *getenv ();
-extern int errno;
-#endif
-
-#if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
-#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>
-
-#ifndef 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))
diff --git a/gnu/usr.bin/pr/version.c b/gnu/usr.bin/pr/version.c
deleted file mode 100644
index a629418..0000000
--- a/gnu/usr.bin/pr/version.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "version.h"
-const char *version_string = "GNU textutils 1.6";
diff --git a/gnu/usr.bin/pr/version.h b/gnu/usr.bin/pr/version.h
deleted file mode 100644
index 63de4fd..0000000
--- a/gnu/usr.bin/pr/version.h
+++ /dev/null
@@ -1 +0,0 @@
-extern const char *version_string;
diff --git a/gnu/usr.bin/pr/xmalloc.c b/gnu/usr.bin/pr/xmalloc.c
deleted file mode 100644
index f989004..0000000
--- a/gnu/usr.bin/pr/xmalloc.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* xmalloc.c -- malloc with out of memory checking
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-char *malloc ();
-char *realloc ();
-void free ();
-#endif
-
-void error ();
-
-/* Allocate N bytes of memory dynamically, with error checking. */
-
-char *
-xmalloc (n)
- unsigned n;
-{
- char *p;
-
- p = malloc (n);
- if (p == 0)
- /* Must exit with 2 for `cmp'. */
- error (2, 0, "virtual memory exhausted");
- return p;
-}
-
-/* Change the size of an allocated block of memory P to N bytes,
- with error checking.
- If P is NULL, run xmalloc.
- If N is 0, run free and return NULL. */
-
-char *
-xrealloc (p, n)
- char *p;
- unsigned n;
-{
- if (p == 0)
- return xmalloc (n);
- if (n == 0)
- {
- free (p);
- return 0;
- }
- p = realloc (p, n);
- if (p == 0)
- /* Must exit with 2 for `cmp'. */
- error (2, 0, "virtual memory exhausted");
- return p;
-}
diff --git a/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 cd593ed..0000000
--- a/gnu/usr.bin/rcs/Makefile.inc
+++ /dev/null
@@ -1,7 +0,0 @@
-# Location of librcs
-
-.if exists(${.CURDIR}/../lib/obj)
-LIBRCS= ${.CURDIR}/../lib/obj/librcs.a
-.else
-LIBRCS= ${.CURDIR}/../lib/librcs.a
-.endif
diff --git a/gnu/usr.bin/rcs/ci/Makefile b/gnu/usr.bin/rcs/ci/Makefile
deleted file mode 100644
index 3ac3d29..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 5736dc9..0000000
--- a/gnu/usr.bin/rcs/ci/ci.1
+++ /dev/null
@@ -1,772 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: ci.1,v 5.9 1991/10/07 17:32:46 eggert Exp $
-.ds r \&\s-1RCS\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 may 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 \-k ,
-.BR \-l ,
-.BR \-M ,
-.BR \-q ,
-.BR \-r ,
-or
-.BR \-u .
-.I rev
-may be symbolic, numeric, or mixed.
-If
-.I rev
-is
-.BR $ ,
-.B ci
-determines the revision number from keyword values in the working file.
-.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
-.BR \-r [\f2rev\fP]
-checks in a revision, releases the corresponding lock, and
-removes the working file. This is the default.
-.RS
-.PP
-The
-.B \-r
-option has an unusual meaning in
-.BR ci .
-In other \*r commands,
-.B \-r
-merely specifies a revision number,
-but in
-.B ci
-it also releases a lock and removes the working file.
-See
-.B \-u
-for a tricky example.
-.RE
-.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 ,
-.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
-.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 may 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]
-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.
-.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
-may not 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
-.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 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/ file
-or
-.IB path /RCS/ file.
-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 file names,
-and is empty (i.e. just the empty suffix) for other hosts.
-.SH "FILE NAMING"
-Pairs of \*r files and working files may 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 be
-.B RCS/
-or must end in
-.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
-Several temporary files may be 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 '+1n-1/1n
-.IP \(bu \nn
-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 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
-will be able to 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 path name
-.I B
-that will 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 ,
-and
-.BR \-x .
-.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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by Paul Eggert.
-.SH "SEE ALSO"
-co(1), ident(1), make(1), rcs(1), rcsclean(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.
-.br
diff --git a/gnu/usr.bin/rcs/ci/ci.c b/gnu/usr.bin/rcs/ci/ci.c
deleted file mode 100644
index 566747e..0000000
--- a/gnu/usr.bin/rcs/ci/ci.c
+++ /dev/null
@@ -1,1165 +0,0 @@
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * RCS checkin operation
- */
-/*******************************************************************
- * check revisions into RCS files
- *******************************************************************
- */
-
-
-
-/* $Log: ci.c,v $
- * 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*));
-static int addelta P((void));
-static int addsyms P((char const*));
-static int fixwork P((mode_t,char const*));
-static int removelock P((struct hshentry*));
-static int xpandfile P((RILE*,char const*,struct hshentry const*,char const**));
-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 *));
-
-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, *lastassoc;
-
-mainProg(ciId, "ci", "$Id: ci.c,v 5.21 1991/11/20 17:58:07 eggert Exp $")
-{
- static char const cmdusage[] =
- "\nci usage: ci -{fklqru}[rev] -mmsg -{nN}name -sstate -t[textfile] -Vn file ...";
- static char const default_state[] = DEFAULTSTATE;
-
- char altdate[datesize];
- char olddate[datesize];
- char newdatebuf[datesize], targetdatebuf[datesize];
- char *a, **newargv, *textfile;
- char const *author, *krev, *rev, *state;
- char const *diffilename, *expfilename;
- char const *workdiffname, *newworkfilename;
- char const *mtime;
- int lockflag, lockthis, mtimeflag, removedlock;
- int r;
- int changedRCS, changework, newhead;
- int usestatdate; /* Use mod time of file for -d. */
- mode_t newworkmode; /* mode for working file */
- struct hshentry *workdelta;
-
- setrid();
-
- author = rev = state = textfile = nil;
- lockflag = false;
- mtimeflag = false;
- altdate[0]= '\0'; /* empty alternate date for -d */
- usestatdate=false;
- suffixes = X_DEFAULT;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- while (a = *++argv, 0<--argc && *a++=='-') {
- switch (*a++) {
-
- case 'r':
- keepworkingfile = lockflag = false;
- revno:
- if (*a) {
- if (rev) warn("redefinition of revision number");
- rev = a;
- }
- break;
-
- case 'l':
- keepworkingfile=lockflag=true;
- goto revno;
-
- case 'u':
- keepworkingfile=true; lockflag=false;
- 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)
- warn("missing message for -m option");
- break;
-
- case 'n':
- if (!*a) {
- error("missing symbolic name after -n");
- break;
- }
- checksid(a);
- addassoclst(false, a);
- break;
-
- case 'N':
- if (!*a) {
- error("missing symbolic name after -N");
- break;
- }
- checksid(a);
- addassoclst(true, a);
- break;
-
- case 's':
- if (*a) {
- if (state) redefined('s');
- checksid(a);
- state = a;
- } else
- warn("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
- warn("missing author for -w option");
- break;
-
- case 'x':
- suffixes = a;
- break;
-
- case 'V':
- setRCSversion(*argv);
- break;
-
-
-
- default:
- faterror("unknown option: %s%s", *argv, cmdusage);
- };
- } /* end processing of options */
-
- if (argc<1) faterror("no input file%s", cmdusage);
-
- /* now handle all filenames */
- do {
- targetdelta=nil;
- ffree();
-
- switch (pairfilenames(argc, argv, rcswriteopen, false, false)) {
-
- case -1: /* New RCS file */
-# if has_setuid && has_getuid
- if (euid() != ruid()) {
- error("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 */
- rcsinitflag = !Head;
- }
-
- /* now RCSfilename contains the name of the RCS file, and
- * workfilename contains the name of the working file.
- * If the RCS file exists, finptr contains the file descriptor for the
- * RCS file. The admin node is initialized.
- * RCSstat is set.
- */
-
- diagnose("%s <-- %s\n", RCSfilename,workfilename);
-
- if (!(workptr = Iopen(workfilename, FOPEN_R_WORK, &workstat))) {
- eerror(workfilename);
- continue;
- }
- if (finptr && !checkaccesslist()) continue; /* give up */
-
- krev = rev;
- if (keepflag) {
- /* get keyword values from working file */
- if (!getoldkeys(workptr)) continue;
- if (!rev && !*(krev = prevrev.string)) {
- error("can't find a revision number in %s",workfilename);
- continue;
- }
- if (!*prevdate.string && *altdate=='\0' && usestatdate==false)
- warn("can't find a date in %s", workfilename);
- if (!*prevauthor.string && !author)
- warn("can't find an author in %s", workfilename);
- if (!*prevstate.string && !state)
- warn("can't find a state in %s", workfilename);
- } /* 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=nil;
- newdelta.lockedby=nil; /*might be changed by addlock() */
- newdelta.selector = true;
- /* set author */
- if (author!=nil)
- 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!=nil)
- 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!=nil &&
- cmpnum(newdelta.date,targetdelta->date) < 0) {
- error("Date %s precedes %s in existing revision %s.",
- date2str(newdelta.date, newdatebuf),
- date2str(targetdelta->date, targetdatebuf),
- targetdelta->num
- );
- continue;
- }
-
-
- if (lockflag && addlock(&newdelta) < 0) continue;
- if (!addsyms(newdelta.num))
- continue;
-
-
- putadmin(frewrite);
- puttree(Head,frewrite);
- putdesc(false,textfile);
-
- changework = Expand != OLD_EXPAND;
- lockthis = lockflag;
- workdelta = &newdelta;
-
- /* build rest of file */
- if (rcsinitflag) {
- diagnose("initial revision: %s\n", newdelnum.string);
- /* get logmessage */
- newdelta.log=getlogmsg();
- if (!putdftext(newdelnum.string,newdelta.log,workptr,frewrite,false)) continue;
- RCSstat.st_mode = workstat.st_mode;
- changedRCS = true;
- } else {
- diffilename = maketemp(0);
- workdiffname = workfilename;
- if (workdiffname[0] == '+') {
- /* Some diffs have options with leading '+'. */
- char *dp = ftnalloc(char, strlen(workfilename)+3);
- workdiffname = dp;
- *dp++ = '.';
- *dp++ = SLASH;
- VOID strcpy(dp, workfilename);
- }
- newhead = Head == &newdelta;
- if (!newhead)
- foutptr = frewrite;
- expfilename = buildrevision(
- gendeltas, targetdelta, (FILE*)0, false
- );
- if (
- !forceciflag &&
- (changework = rcsfcmp(
- workptr, &workstat, expfilename, 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;
- }
- if (!(changedRCS =
- lockflag < removedlock
- || assoclst
- || newdelta.state != default_state
- && strcmp(newdelta.state, targetdelta->state) != 0
- ))
- 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;
- if (fseek(frewrite, 0L, SEEK_SET) != 0)
- Oerror();
-# if !has_ftruncate
- bad_truncate = 1;
-# else
- /*
- * Work around a common ftruncate() bug.
- * We can't rely on has_truncate, because we might
- * be using a filesystem exported to us via NFS.
- */
- bad_truncate = ftruncate(fileno(frewrite),(off_t)0);
- if (bad_truncate && errno != EACCES)
- Oerror();
-# endif
- 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 (removedlock && removelock(workdelta)<0)
- continue;
- if (!addsyms(workdelta->num))
- continue;
- if (!dorewrite(true, true))
- 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 {
- diagnose("new revision: %s; previous revision: %s\n",
- newdelnum.string, targetdelta->num
- );
- newdelta.log = getlogmsg();
- switch (run((char*)0, diffilename,
- DIFF DIFF_FLAGS,
- newhead ? workdiffname : expfilename,
- newhead ? expfilename : workdiffname,
- (char*)0
- )) {
- case DIFF_FAILURE: case DIFF_SUCCESS: break;
- default: faterror("diff failed");
- }
- if (newhead) {
- Irewind(workptr);
- if (!putdftext(newdelnum.string,newdelta.log,workptr,frewrite,false)) continue;
- if (!putdtext(targetdelta->num,targetdelta->log,diffilename,frewrite,true)) continue;
- } else
- if (!putdtext(newdelnum.string,newdelta.log,diffilename,frewrite,true)) continue;
- changedRCS = true;
- }
- }
- if (!donerewrite(changedRCS))
- continue;
-
- if (!keepworkingfile) {
- Izclose(&workptr);
- r = un_link(workfilename); /* Get rid of old file */
- } else {
- newworkmode = WORKMODE(RCSstat.st_mode,
- ! (Expand==VAL_EXPAND || lockthis < StrictLocks)
- );
- mtime = mtimeflag ? workdelta->date : (char const*)0;
-
- /* 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;
- switch (xpandfile(
- workptr, workfilename,
- workdelta, &newworkfilename
- )) {
- 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:
- if (!(r = setfiledate(newworkfilename,mtime))) {
- Izclose(&workptr);
- ignoreints();
- r = chnamemod(&exfile, newworkfilename, workfilename, newworkmode);
- keepdirtemp(newworkfilename);
- restoreints();
- }
- }
- }
- }
- if (r != 0) {
- eerror(workfilename);
- continue;
- }
- diagnose("done\n");
-
- } while (cleanup(),
- ++argv, --argc >=1);
-
- tempunlink();
- exitmain(exitstatus);
-} /* end of main (ci) */
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- Izclose(&workptr);
- Ozclose(&exfile);
- Ozclose(&fcopy);
- Ozclose(&frewrite);
- dirtempunlink();
-}
-
-#if lint
-# define exiterr ciExit
-#endif
- exiting void
-exiterr()
-{
- 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 unsigned i;
- int removedlock;
- unsigned 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!=nil)) {
- bufscpy(&newdelnum, Dbranch);
- newdnumlength = countnumflds(Dbranch);
- }
- if (newdnumlength==0) bufscpy(&newdelnum, "1.1");
- else if (newdnumlength==1) bufscat(&newdelnum, ".1");
- else if (newdnumlength>2) {
- error("Branch point doesn't exist for %s.",newdelnum.string);
- return -1;
- } /* newdnumlength == 2 is OK; */
- Head = &newdelta;
- newdelta.next=nil;
- 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 = nil;
- } else {
- /* middle revision; start a new branch */
- bufscpy(&newdelnum, "");
- return addbranch(targetdelta,&newdelnum);
- }
- 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)) {
- error("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) {
- error("deltanumber %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++ != '.')
- ;
- *--tp = 0; /* Kill final dot to get old delta temporarily. */
- if (!(targetdelta=genrevs(newdelnum.string,(char*)nil,(char*)nil,(char*)nil,&gendeltas)))
- return -1;
- if (cmpnum(targetdelta->num, newdelnum.string) != 0) {
- error("can't find branchpoint %s", newdelnum.string);
- return -1;
- }
- *tp = '.'; /* Restore final dot. */
- return addbranch(targetdelta,&newdelnum);
- }
-}
-
-
-
- static int
-addbranch(branchpoint,num)
- struct hshentry *branchpoint;
- struct buf *num;
-/* 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.
- */
-{
- struct branchhead *bhead, **btrail;
- struct buf branchnum;
- int removedlock, result;
- unsigned field, numlength;
- static struct branchhead newbranch; /* new branch to be inserted */
-
- numlength = countnumflds(num->string);
-
- if (branchpoint->branches==nil) {
- /* 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=nil;
-
- } 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=nil;
- } 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*)nil,
- (char*)nil,(char*)nil,&gendeltas);
- bufautoend(&branchnum);
- if (!targetdelta)
- return -1;
- if (cmpnum(num->string,targetdelta->num) <= 0) {
- error("deltanumber %s too low; must be higher than %s",
- num->string,targetdelta->num);
- return -1;
- }
- if (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=nil;
- return 0;
-}
-
- 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))
- 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 lock *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 {
- error("revision %s locked by %s",num,next->login);
- return -1;
- }
- if (!StrictLocks && myself(RCSstat.st_uid))
- return 0;
- error("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 */
- time_t t;
-
- if (!buffer[0]) {
- t = time((time_t *)0);
- if (t == -1)
- faterror("time not available");
- time2date(t, buffer);
- }
- return buffer;
-}
-
- static int
-#if has_prototypes
-fixwork(mode_t newworkmode, char const *mtime)
- /* The `#if has_prototypes' is needed because mode_t might promote to int. */
-#else
- fixwork(newworkmode, mtime)
- mode_t newworkmode;
- char const *mtime;
-#endif
-{
- int r;
- return
- 1 < workstat.st_nlink
- || newworkmode&S_IWUSR && !myself(workstat.st_uid)
- ? -1
- :
- workstat.st_mode != newworkmode
- &&
- (r =
-# if has_fchmod
- fchmod(Ifileno(workptr), newworkmode)
-# else
- chmod(workfilename, newworkmode)
-# endif
- ) != 0
- ? r
- :
- setfiledate(workfilename, mtime);
-}
-
- static int
-xpandfile(unexfile, dir, delta, exfilename)
- RILE *unexfile;
- char const *dir;
- struct hshentry const *delta;
- char const **exfilename;
-/*
- * Read unexfile and copy it to a
- * file in dir, 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 *EXFILENAME.
- */
-{
- char const *targetfname;
- int e, r;
-
- targetfname = makedirtemp(dir, 1);
- if (!(exfile = fopen(targetfname, FOPEN_W_WORK))) {
- eerror(targetfname);
- error("can't expand working file");
- return -1;
- }
- r = 0;
- if (Expand == OLD_EXPAND)
- fastcopy(unexfile,exfile);
- else {
- for (;;) {
- e = expandline(unexfile,exfile,delta,false,(FILE*)nil);
- if (e < 0)
- break;
- r |= e;
- if (e <= 1)
- break;
- }
- }
- *exfilename = targetfname;
- aflush(exfile);
- 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);
- 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 * sp;
-{
- struct Symrev *pt;
-
- pt = talloc(struct Symrev);
- pt->ssymbol = sp;
- pt->override = flag;
- pt->nextsym = nil;
- if (lastassoc)
- lastassoc->nextsym = pt;
- else
- assoclst = pt;
- lastassoc = pt;
- return;
-}
diff --git a/gnu/usr.bin/rcs/co/Makefile b/gnu/usr.bin/rcs/co/Makefile
deleted file mode 100644
index a759d1f..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 d9ce65e..0000000
--- a/gnu/usr.bin/rcs/co/co.1
+++ /dev/null
@@ -1,569 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: co.1,v 5.7 1991/08/19 03:13:55 eggert Exp $
-.ds g \&\s-1UTC\s0
-.ds r \&\s-1RCS\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 may 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 may 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 may 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
-.I 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. 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
-.BR \-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.
-.TP
-.BR \-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 binary file formats
-that cannot tolerate any changes to substrings
-that happen to take the form of keyword strings.
-.TP
-.BR \-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
-.I date.
-The date and time may 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 (\*g):
-.RS
-.LP
-.RS
-.nf
-.ta \w'\f3Thu, 11 Jan 1990 20:00:00 \-0800\fP 'u
-.ne 9
-\f38:00 pm lt\fP
-\f34:00 AM, Jan. 12, 1990\fP note: default is \*g
-\f31990/01/12 04:00:00\fP \*r date 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
-\f3Fri-JST, 1990, 1pm Jan 12\fP
-\f312-January-1990, 04:00-WET\fP
-.ta 4n +4n +4n +4n
-.fi
-.RE
-.LP
-Most fields in the date and time may be defaulted.
-The default time zone is \*g.
-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, the date
-.B "20, 10:30"
-defaults to
-10:30:00 \*g of the 20th of the \*g 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
-.I state.
-.TP
-.BR \-w [\f2login\fP]
-retrieves the latest revision on the selected branch which was checked in
-by the user with login name
-.I 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
-.I 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
-.I rev2.
-This means that all changes that transform
-.I rev2
-into
-.I rev1
-are applied to a copy of
-.I 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
-may 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
-.I rev1.
-.RE
-.TP
-.BI \-V n
-Emulate \*r version
-.I n,
-where
-.I n
-may be
-.BR 3 ,
-.BR 4 ,
-or
-.BR 5 .
-This may 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
-.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 will lose its default branch.
-An \*r revision generated while emulating version 4 or earlier will have
-a timestamp that is off by up to 13 hours.
-A revision extracted while emulating version 4 or earlier will contain
-dates of the form
-.IB yy / mm / dd
-instead of
-.IB yyyy / mm / dd
-and may also contain different white space in the substitution for
-.BR $\&Log$ .
-.TP
-.BI \-x "suffixes"
-Use
-.I suffixes
-to characterize \*r files.
-See
-.BR ci (1)
-for details.
-.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 may 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 (\*g) the revision was checked in.
-.TP
-.B $\&Header$
-A standard header containing the full pathname of the \*r file, the
-revision number, the date (\*g), 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, preceded by a header
-containing the \*r filename, the revision number, the author, and the date
-(\*g).
-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.
-.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).
-.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.
-.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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by Paul Eggert.
-.SH "SEE ALSO"
-ci(1), ctime(3), date(1), ident(1), make(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 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.
-.SH BUGS
-The
-.B \-d
-option sometimes gets confused, and accepts no date before 1970.
-.br
diff --git a/gnu/usr.bin/rcs/co/co.c b/gnu/usr.bin/rcs/co/co.c
deleted file mode 100644
index 9435574..0000000
--- a/gnu/usr.bin/rcs/co/co.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * RCS checkout operation
- */
-/*****************************************************************************
- * check out revisions from RCS files
- *****************************************************************************
- */
-
-
-/* $Log: co.c,v $
- * Revision 5.9 1991/10/07 17:32:46 eggert
- * ci -u src/RCS/co.c,v src/co.c <<\.
- * -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 const *getancestor P((char const*,char const*));
-static int buildjoin P((char const*));
-static int preparejoin P((void));
-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, *join, *suffixarg, *versionarg;
-static char const *joinlist[joinlength]; /* revisions to be joined */
-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 5.9 1991/10/07 17:32:46 eggert Exp $")
-{
- static char const cmdusage[] =
- "\nco usage: co -{flpqru}[rev] -ddate -jjoinlist -sstate -w[login] -Vn file ...";
-
- char *a, **newargv;
- char const *author, *date, *rev, *state;
- char const *joinfilename, *newdate, *neworkfilename;
- int changelock; /* 1 if a lock has been changed, -1 if error */
- int expmode, r, tostdout, workstatstat;
- struct buf numericrev; /* expanded revision number */
- char finaldate[datesize];
-
- setrid();
- author = date = rev = state = nil;
- bufautobegin(&numericrev);
- expmode = -1;
- suffixes = X_DEFAULT;
- tostdout = 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("-l overrides -u.");
- }
- lockflag = 1;
- goto revno;
-
- case 'u':
- if (0 < lockflag) {
- warn("-l overrides -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 (join) redefined('j');
- join = a;
- }
- break;
-
- case 'M':
- mtimeflag = true;
- goto revno;
-
- case 's':
- if (*a) {
- if (state) redefined('s');
- state = a;
- }
- 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 'k': /* set keyword expand mode */
- expandarg = *argv;
- if (0 <= expmode) redefined('k');
- if (0 <= (expmode = str2expmode(a)))
- break;
- /* fall into */
- default:
- faterror("unknown option: %s%s", *argv, cmdusage);
-
- };
- } /* end of option processing */
-
- if (argc<1) faterror("no input file%s", cmdusage);
- if (tostdout)
-# if text_equals_binary_stdio || text_work_stdio
- workstdout = stdout;
-# else
- if (!(workstdout = fdopen(STDOUT_FILENO, FOPEN_W_WORK)))
- efaterror("stdout");
-# endif
-
- /* now handle all filenames */
- do {
- ffree();
-
- if (pairfilenames(argc, argv, lockflag?rcswriteopen:rcsreadopen, true, false) <= 0)
- continue;
-
- /* now RCSfilename contains the name of the RCS file, and finptr
- * points at it. workfilename contains the name of the working file.
- * Also, RCSstat has been set.
- */
- diagnose("%s --> %s\n", RCSfilename,tostdout?"stdout":workfilename);
-
- workstatstat = -1;
- if (tostdout) {
- neworkfilename = 0;
- neworkptr = workstdout;
- } else {
- workstatstat = stat(workfilename, &workstat);
- neworkfilename = makedirtemp(workfilename, 1);
- if (!(neworkptr = fopen(neworkfilename, FOPEN_W_WORK))) {
- if (errno == EACCES)
- error("%s: parent directory isn't writable",
- workfilename
- );
- else
- eerror(neworkfilename);
- continue;
- }
- }
-
- gettree(); /* reads in the delta tree */
-
- if (Head==nil) {
- /* no revisions; create empty file */
- diagnose("no revisions present; generating empty revision 0.0\n");
- Ozclose(&fcopy);
- if (workstatstat == 0)
- if (!rmworkfile()) continue;
- changelock = 0;
- newdate = 0;
- /* Can't reserve a delta, so don't call addlock */
- } else {
- if (rev!=nil) {
- /* expand symbolic revision number */
- if (!expandsym(rev, &numericrev))
- continue;
- } else
- switch (lockflag<0 ? findlock(false,&targetdelta) : 0) {
- 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);
-
- if (
- changelock < 0 ||
- changelock && !checkaccesslist() ||
- !dorewrite(lockflag, changelock)
- )
- continue;
-
- if (0 <= expmode)
- Expand = expmode;
- if (0 < lockflag && Expand == VAL_EXPAND) {
- error("cannot combine -kv and -l");
- continue;
- }
-
- if (join && !preparejoin()) 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;
- joinfilename = buildrevision(
- gendeltas, targetdelta,
- join&&tostdout ? (FILE*)0 : neworkptr,
- Expand!=OLD_EXPAND
- );
-# 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))
- continue;
-
- newdate = targetdelta->date;
- if (join) {
- newdate = 0;
- if (!joinfilename) {
- aflush(neworkptr);
- joinfilename = neworkfilename;
- }
- if (!buildjoin(joinfilename))
- continue;
- }
- }
- if (!tostdout) {
- r = 0;
- if (mtimeflag && newdate) {
- if (!join)
- aflush(neworkptr);
- r = setfiledate(neworkfilename, newdate);
- }
- if (r == 0) {
- ignoreints();
- r = chnamemod(&neworkptr, neworkfilename, workfilename,
- WORKMODE(RCSstat.st_mode,
- !(Expand==VAL_EXPAND || lockflag<=0&&StrictLocks)
- )
- );
- keepdirtemp(neworkfilename);
- restoreints();
- }
- if (r != 0) {
- eerror(workfilename);
- error("see %s", neworkfilename);
- continue;
- }
- diagnose("done\n");
- }
- } while (cleanup(),
- ++argv, --argc >=1);
-
- tempunlink();
- Ofclose(workstdout);
- exitmain(exitstatus);
-
-} /* end of main (co) */
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- Ozclose(&frewrite);
-# if !large_memory
- if (fcopy!=workstdout) Ozclose(&fcopy);
-# endif
- if (neworkptr!=workstdout) Ozclose(&neworkptr);
- dirtempunlink();
-}
-
-#if lint
-# define exiterr coExit
-#endif
- exiting void
-exiterr()
-{
- dirtempunlink();
- tempunlink();
- _exit(EXIT_FAILURE);
-}
-
-
-/*****************************************************************
- * The following routines are auxiliary routines
- *****************************************************************/
-
- static int
-rmworkfile()
-/* Function: prepares to remove workfilename, 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): ",
- workfilename,
- myself(workstat.st_uid) ? "" : ", and you do not own it"
- )) {
- error(!quietflag && ttystdin()
- ? "checkout aborted"
- : "writable %s exists; checkout aborted", workfilename);
- 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 lock * next, * trail;
- char const *num;
- struct lock dummy;
- int whomatch, nummatch;
-
- num=delta->num;
- dummy.nextlock=next=Locks;
- trail = &dummy;
- while (next!=nil) {
- 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)) {
- error("revision %s locked by %s; use co -r or rcs -u",num,next->login);
- return -1;
- }
- trail=next;
- next=next->nextlock;
- }
- if (next!=nil) {
- /*found one; delete it */
- trail->nextlock=next->nextlock;
- Locks=dummy.nextlock;
- next->delta->lockedby=nil; /* reset locked-by */
- return 1; /*success*/
- } else return 0; /*no lock on delta*/
-}
-
-
-
-
-/*****************************************************************
- * The rest of the routines are for handling joins
- *****************************************************************/
-
-
- static char const *
-addjoin(joinrev)
- char *joinrev;
-/* Add joinrev's number to joinlist, yielding address of char past joinrev,
- * or nil if no such revision exists.
- */
-{
- register char *j;
- register struct hshentry const *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*)nil,(char*)nil,(char*)nil,&joindeltas);
- bufautoend(&numrev);
- *j = terminator;
- if (d) {
- joinlist[++lastjoin] = d->num;
- return j;
- }
- return nil;
-}
-
- static int
-preparejoin()
-/* Function: Parses a join list pointed to by join and places pointers to the
- * revision numbers into joinlist.
- */
-{
- register char const *j;
-
- j=join;
- lastjoin= -1;
- for (;;) {
- while ((*j==' ')||(*j=='\t')||(*j==',')) j++;
- if (*j=='\0') break;
- if (lastjoin>=joinlength-2) {
- error("too many joins");
- return(false);
- }
- 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 {
- error("join pair incomplete");
- return false;
- }
- } 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 {
- error("join pair incomplete");
- return false;
- }
- }
- }
- if (lastjoin<1) {
- error("empty join");
- return false;
- } else return true;
-}
-
-
-
- static char const *
-getancestor(r1, r2)
- char const *r1, *r2;
-/* Yield the common ancestor of r1 and r2 if successful, nil otherwise.
- * Work reliably only if r1 and r2 are not branch numbers.
- */
-{
- static struct buf t1, t2;
-
- unsigned 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 ? (unsigned)2 : l1);
- VOID partialno(&t2, r2, l2>2 ? (unsigned)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);
- }
- error("common ancestor of %s and %s undefined", r1, r2);
- return nil;
-}
-
-
-
- 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[12];
- char const **p;
-
- bufautobegin(&commarg);
- bufautobegin(&subs);
- rev2 = maketemp(0);
- rev3 = maketemp(3); /* buildrevision() may use 1 and 2 */
-
- cov[0] = nil;
- /* cov[1] setup below */
- cov[2] = CO;
- /* cov[3] setup below */
- p = &cov[4];
- if (expandarg) *p++ = expandarg;
- if (suffixarg) *p++ = suffixarg;
- if (versionarg) *p++ = versionarg;
- *p++ = quietarg;
- *p++ = RCSfilename;
- *p = nil;
-
- mergev[0] = nil;
- mergev[1] = nil;
- mergev[2] = MERGE;
- mergev[3] = mergev[5] = "-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[1] = rev2;
- cov[3] = commarg.string;
- if (runv(cov))
- goto badmerge;
- diagnose("revision %s\n",joinlist[i+1]);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, joinlist[i+1]);
- cov[1] = rev3;
- cov[3] = commarg.string;
- if (runv(cov))
- goto badmerge;
- diagnose("merging...\n");
- mergev[4] = subs.string;
- mergev[6] = joinlist[i+1];
- p = &mergev[7];
- if (quietflag) *p++ = quietarg;
- if (lastjoin<=i+2 && workstdout) *p++ = "-p";
- *p++ = initialfile;
- *p++ = rev2;
- *p++ = rev3;
- *p = nil;
- switch (runv(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 7b3f807..0000000
--- a/gnu/usr.bin/rcs/doc/rcs.ms
+++ /dev/null
@@ -1,1524 +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 $
-.\" PS and PE center pic diagrams. (The corresponding ms-macros may not.)
-.de PS
-.nr pE (\\n(.lu-\\$2u)/2u
-.in +\\n(pEu
-.ne \\$1u
-..
-.de PE
-.in -\\n(pEu
-..
-.de D(
-.DS
-.nr VS 12p
-.vs 12p
-.I
-..
-.de D)
-.DE
-.nr VS 18p
-.vs 18p
-.R
-..
-.de Id
-.ND \\$4
-..
-.Id $Id: rcs.ms,v 5.2 1991/01/03 10:57:28 eggert Exp $
-.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 a partial reproduction 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
-/* \*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.
-.IP "\fIrcsclean\fP \fB\- clean working directory\fP"
-.sp 0
-.ne 10
-\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 25e028b..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 37c8eda..0000000
--- a/gnu/usr.bin/rcs/ident/ident.1
+++ /dev/null
@@ -1,76 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-.ds iD \\$3 \\$4 \\$5 \\$6 \\$7
-..
-.Id $Id: ident.1,v 5.0 1990/08/22 09:09:36 eggert Exp $
-.ds r \s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH IDENT 1 \*(Dt GNU
-.SH NAME
-ident \- identify files
-.SH SYNOPSIS
-.B ident
-[
-.B \-q
-] [
-.I file
-\&.\|.\|. ]
-.SH DESCRIPTION
-.B ident
-searches for all occurrences of the pattern
-.BI $ keyword : .\|.\|. $
-in the named files or, if no file name appears, 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.
-.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
-\f3char rcsid[] = \&"$\&Id: f.c,v \*(iD $\&";\fP
-.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
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990 by 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 a2cc018..0000000
--- a/gnu/usr.bin/rcs/ident/ident.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-/*
- * RCS identification operation
- */
-
-/* $Log: ident.c,v $
- * 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 void scanfile P((FILE*,char const*,int));
-
-mainProg(identId, "ident", "$Id: ident.c,v 5.3 1991/09/10 22:15:46 eggert Exp $")
-/* Ident searches the named files for all occurrences
- * of the pattern $keyword:...$, where the keywords are
- * Author, Date, Header, Id, Log, RCSfile, Revision, Source, and State.
- */
-
-{
- FILE *fp;
- int quiet;
- int status = EXIT_SUCCESS;
-
- if ((quiet = argc > 1 && strcmp("-q",argv[1])==0)) {
- argc--; argv++;
- }
-
- if (argc<2)
- scanfile(stdin, (char*)0, quiet);
-
- while ( --argc > 0 ) {
- if (!(fp = fopen(*++argv, FOPEN_R))) {
- VOID fprintf(stderr, "%s error: can't open %s\n", cmdid, *argv);
- status = EXIT_FAILURE;
- } else {
- scanfile(fp, *argv, quiet);
- if (argc>1) VOID putchar('\n');
- }
- }
- if (ferror(stdout) || fclose(stdout)!=0) {
- VOID fprintf(stderr, "%s error: write error\n", cmdid);
- status = EXIT_FAILURE;
- }
- exitmain(status);
-}
-
-#if lint
- exiting void identExit() { _exit(EXIT_FAILURE); }
-#endif
-
-
- static void
-scanfile(file, name, quiet)
- register FILE *file;
- char const *name;
- int quiet;
-/* Function: scan an open file with descriptor file for keywords.
- * Return false if there's a read error.
- */
-{
- register int c;
-
- if (name)
- VOID printf("%s:\n", name);
- else
- name = "input";
- c = 0;
- for (;;) {
- if (c < 0) {
- if (feof(file))
- break;
- if (ferror(file))
- goto read_error;
- }
- if (c == KDELIM) {
- if ((c = match(file)))
- continue;
- quiet = true;
- }
- c = getc(file);
- }
- if (!quiet)
- VOID fprintf(stderr, "%s warning: no id keywords in %s\n", cmdid, name);
- if (fclose(file) == 0)
- return;
-
- read_error:
- VOID fprintf(stderr, "%s error: %s: read error\n", cmdid, name);
- exit(EXIT_FAILURE);
-}
-
-
-
- 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 < 0)
- 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 < 0 && 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 fprintf(stdout, " %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 8428686..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 rcsutil.c \
- merger.c
-
-NOPROFILE=noprofile
-
-install:
-
-.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 d29e511..0000000
--- a/gnu/usr.bin/rcs/lib/conf.h
+++ /dev/null
@@ -1,495 +0,0 @@
-/* RCS compile-time configuration */
-
- /* $Id: conf.sh,v 5.14 1991/11/20 18:21:10 eggert Exp $ */
-
-/*
- * 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_SOURCE */ /* Define this if Posix + strict Standard C. */
-
-#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 <pwd.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <utime.h>
-/* #include <vfork.h> */
-
-/* Define the following symbols to be 1 or 0. */
-#define has_sys_dir_h 1 /* Does #include <sys/dir.h> work? */
-#define has_sys_param_h 1 /* Does #include <sys/param.h> work? */
-#define has_readlink 1 /* Does readlink() work? */
-
-/* #undef NAME_MAX */ /* Uncomment this if NAME_MAX is broken. */
-
-#if !defined(NAME_MAX) && !defined(_POSIX_NAME_MAX)
-# if has_sys_dir_h
-# include <sys/dir.h>
-# endif
-# ifndef NAME_MAX
-# ifndef MAXNAMLEN
-# define MAXNAMLEN 14
-# endif
-# define NAME_MAX MAXNAMLEN
-# endif
-#endif
-#if !defined(PATH_MAX) && !defined(_POSIX_PATH_MAX)
-# if has_sys_param_h
-# include <sys/param.h>
-# define included_sys_param_h 1
-# endif
-# ifndef PATH_MAX
-# ifndef MAXPATHLEN
-# define MAXPATHLEN 1024
-# endif
-# define PATH_MAX (MAXPATHLEN-1)
-# endif
-#endif
-#if has_readlink && !defined(MAXSYMLINKS)
-# if has_sys_param_h && !included_sys_param_h
-# include <sys/param.h>
-# endif
-# ifndef MAXSYMLINKS
-# define MAXSYMLINKS 20 /* BSD; not standard yet */
-# endif
-#endif
-
-/* Comment out the keyword definitions below if the keywords work. */
-/* #define const */
-/* #define volatile */
-
-/* Comment out the typedefs below if the types are already declared. */
-/* Fix any uncommented typedefs that are wrong. */
-/* typedef int mode_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; */
-
-/* Define the following symbols to be 1 or 0. */
-#define has_prototypes 1 /* Do function prototypes work? */
-#define has_stdarg 1 /* Does <stdarg.h> work? */
-#define has_varargs 0 /* Does <varargs.h> work? */
-#define va_start_args 2 /* How many args does va_start() take? */
-#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 text_equals_binary_stdio 1 /* Does stdio treat text like binary? */
-#define text_work_stdio 0 /* Text i/o for working file, binary for RCS file? */
-#if text_equals_binary_stdio
- /* Text and binary i/o behave the same, or binary i/o does not work. */
-# define FOPEN_R "r"
-# define FOPEN_W "w"
-# define FOPEN_WPLUS "w+"
-#else
- /* Text and binary i/o behave differently. */
- /* This is incompatible with Posix and Unix. */
-# define FOPEN_R "rb"
-# define FOPEN_W "wb"
-# define FOPEN_WPLUS "w+b"
-#endif
-#if text_work_stdio
-# define FOPEN_R_WORK "r"
-# define FOPEN_W_WORK "w"
-# define FOPEN_WPLUS_WORK "w+"
-#else
-# define FOPEN_R_WORK FOPEN_R
-# define FOPEN_W_WORK FOPEN_W
-# define FOPEN_WPLUS_WORK FOPEN_WPLUS
-#endif
-
-/* Define or comment out the following symbols as needed. */
-#define bad_fopen_wplus 0 /* Does fopen(f,FOPEN_WPLUS) fail to truncate f? */
-#define getlogin_is_secure 0 /* Is getlogin() secure? Usually it's not. */
-#define has_dirent 1 /* Do opendir(), readdir(), closedir() work? */
-#define has_fchmod 0 /* Does fchmod() work? */
-#define has_fputs 0 /* 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_link 1 /* Does link() work? */
-#define has_memcmp 1 /* Does memcmp() work? */
-#define has_memcpy 1 /* Does memcpy() work? */
-#define has_memmove 1 /* Does memmove() work? */
-#define has_madvise 0 /* Does madvise() work? */
-#define has_mmap 0 /* Does mmap() work on regular files? */
-#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 VOID (void) /* 'VOID e;' discards the value of an expression 'e'. */
-#define has_seteuid 0 /* Does seteuid() work? See README. */
-#define has_setuid 1 /* Does setuid() exist? */
-#define has_signal 1 /* Does signal() work? */
-#define signal_args P((int)) /* arguments of signal handlers */
-#define signal_type void /* type returned by signal handlers */
-#define sig_zaps_handler 0 /* Must a signal handler reinvoke signal()? */
-#define has_sigaction 1 /* Does struct sigaction work? */
-/* #define has_sigblock ? */ /* Does sigblock() work? */
-/* #define sigmask(s) (1 << ((s)-1)) */ /* Yield mask for signal number. */
-#define has_sys_siglist 0 /* Does sys_siglist[] work? */
-typedef ssize_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 has_mktemp 1 /* Does mktemp() work? */
-#define has_NFS 1 /* Might NFS be used? */
-/* #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 0 /* Does vfork() work? */
-#define has_fork 1 /* Does fork() work? */
-#define has_spawn 0 /* Does spawn*() work? */
-#define has_wait 1 /* Does wait() work? */
-#define has_waitpid 0 /* Does waitpid() work? */
-#define RCS_SHELL "/bin/sh" /* shell to run RCS subprograms */
-#define has_vfprintf 1 /* Does vfprintf() work? */
-/* #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 0 /* Can main memory hold entire RCS files? */
-/* #undef ULONG_MAX */ /* Uncomment this if ULONG_MAX is broken (e.g. < 0). */
-/* struct utimbuf { time_t actime, modtime; }; */ /* Uncomment this if needed. */
-#define CO "/usr/bin/co" /* name of 'co' program */
-#define COMPAT2 0 /* Are version 2 files supported? */
-#define DATEFORM "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d" /* e.g. 01.01.01.01.01.01 */
-#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 DIFF_FLAGS , "-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 pathname separator */
-#define SLASHes '/' /* `case SLASHes:' labels all pathname separators */
-#define isSLASH(c) ((c) == SLASH) /* Is arg a pathname separator? */
-#define ROOTPATH(p) isSLASH((p)[0]) /* Is p an absolute pathname? */
-#define X_DEFAULT ",v/" /* default value for -x option */
-#define DIFF_ABSOLUTE 1 /* Is ROOTPATH(DIFF) true? */
-#define ALL_ABSOLUTE 1 /* Are all subprograms absolute pathnames? */
-#define SENDMAIL "/usr/bin/mail" /* how to send mail */
-#define TZ_must_be_set 0 /* Must TZ be set for gmtime() to work? */
-
-
-
-/* Adjust the following declarations as needed. */
-
-
-#if __GNUC__ && !__STRICT_ANSI__
-# define exiting volatile /* GCC extension: function cannot return */
-#else
-# define exiting
-#endif
-
-#if has_ftruncate
- int ftruncate P((int,off_t));
-#endif
-
-/* <sys/mman.h> */
-#if has_madvise
- int madvise P((caddr_t,size_t,int));
-#endif
-#if has_mmap
- caddr_t mmap P((caddr_t,size_t,int,int,int,off_t));
- int munmap P((caddr_t,size_t));
-#endif
-
-
-/* Posix (ISO/IEC 9945-1: 1990 / IEEE Std 1003.1-1990) */
-/* These definitions are for the benefit of non-Posix hosts, and */
-/* Posix hosts that have Standard C compilers but traditional include files. */
-/* Unfortunately, mixed-up hosts are all too common. */
-
-/* <fcntl.h> */
-#ifdef F_DUPFD
- int fcntl P((int,int,...));
-#else
- int dup2 P((int,int));
-#endif
-#ifndef O_BINARY /* some non-Posix hosts need O_BINARY */
-# define O_BINARY 0 /* no effect on Posix */
-#endif
-#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
- int creat P((char const*,mode_t));
-#endif
-#ifndef O_EXCL
-# define O_EXCL 0
-#endif
-
-/* <pwd.h> */
-#if has_getpwuid
- struct passwd *getpwuid P((uid_t));
-#endif
-
-/* <signal.h> */
-#if has_sigaction
- int sigaction P((int,struct sigaction const*,struct sigaction*));
- int sigaddset P((sigset_t*,int));
- int sigemptyset P((sigset_t*));
-#else
-#if has_sigblock
- /* BSD */
- int sigblock P((int));
- int sigmask P((int));
- int sigsetmask P((int));
-#endif
-#endif
-
-/* <stdio.h> */
-FILE *fdopen P((int,char const*));
-int fileno P((FILE*));
-
-/* <sys/stat.h> */
-int chmod P((char const*,mode_t));
-int fstat P((int,struct stat*));
-int stat P((char const*,struct stat*));
-mode_t umask P((mode_t));
-#if has_fchmod
- int fchmod P((int,mode_t));
-#endif
-#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> */
-#if has_wait
- pid_t wait P((int*));
-#endif
-#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) & 255))
-#endif
-
-/* <unistd.h> */
-char *getlogin P((void));
-int close P((int));
-int isatty P((int));
-int link P((char const*,char const*));
-int open P((char const*,int,...));
-int unlink P((char const*));
-int _filbuf P((FILE*)); /* keeps lint quiet in traditional C */
-int _flsbuf P((int,FILE*)); /* keeps lint quiet in traditional C */
-long pathconf P((char const*,int));
-ssize_t write P((int,void const*,size_t));
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-# define STDOUT_FILENO 1
-# define STDERR_FILENO 2
-#endif
-#if has_fork
-# if !has_vfork
-# undef vfork
-# define vfork fork
-# endif
- pid_t vfork P((void)); /* vfork is nonstandard but faster */
-#endif
-#if has_getcwd || !has_getwd
- char *getcwd P((char*,size_t));
-#else
- char *getwd P((char*));
-#endif
-#if has_getuid
- uid_t getuid P((void));
-#endif
-#if has_readlink
-/* ssize_t readlink P((char const*,char*,size_t)); *//* BSD; not standard yet */
-#endif
-#if has_setuid
-# if !has_seteuid
-# undef seteuid
-# define seteuid setuid
-# endif
- int seteuid P((uid_t));
- uid_t geteuid P((void));
-#endif
-#if has_spawn
- int spawnv P((int,char const*,char*const*));
-# if ALL_ABSOLUTE
-# define spawn_RCS spawnv
-# else
-# define spawn_RCS spawnvp
- int spawnvp P((int,char const*,char*const*));
-# endif
-#else
- int execv P((char const*,char*const*));
-# if ALL_ABSOLUTE
-# define exec_RCS execv
-# else
-# define exec_RCS execvp
- int execvp P((char const*,char*const*));
-# endif
-#endif
-
-/* utime.h */
-int utime P((char const*,struct utimbuf const*));
-
-
-/* Standard C library */
-/* These definitions are for the benefit of hosts that have */
-/* traditional C include files, possibly with Standard C compilers. */
-/* Unfortunately, mixed-up hosts are all too common. */
-
-/* <errno.h> */
-extern int errno;
-
-/* <limits.h> */
-#ifndef ULONG_MAX
- /* This does not work in #ifs, but it's good enough for us. */
-# define ULONG_MAX ((unsigned long)-1)
-#endif
-
-/* <signal.h> */
-#if has_signal
- signal_type (*signal P((int,signal_type(*)signal_args)))signal_args;
-#endif
-
-/* <stdio.h> */
-FILE *fopen P((char const*,char const*));
-fread_type fread P((void*,freadarg_type,freadarg_type,FILE*));
-fread_type fwrite P((void const*,freadarg_type,freadarg_type,FILE*));
-int fclose P((FILE*));
-int feof P((FILE*));
-int ferror P((FILE*));
-int fflush P((FILE*));
-int fprintf P((FILE*,char const*,...));
-int fputs P((char const*,FILE*));
-int fseek P((FILE*,long,int));
-int printf P((char const*,...));
-int rename P((char const*,char const*));
-int sprintf P((char*,char const*,...));
-/* long ftell P((FILE*)); */
-void clearerr P((FILE*));
-void perror P((char const*));
-#ifndef L_tmpnam
-# define L_tmpnam 32 /* power of 2 > sizeof("/usr/tmp/xxxxxxxxxxxxxxx") */
-#endif
-#ifndef SEEK_SET
-# define SEEK_SET 0
-#endif
-#if has_mktemp
- char *mktemp P((char*)); /* traditional */
-#else
- char *tmpnam P((char*));
-#endif
-#if has_vfprintf
- int vfprintf P((FILE*,char const*,va_list));
-#else
-#if has__doprintf
- void _doprintf P((FILE*,char const*,va_list)); /* Minix */
-#else
- void _doprnt P((char const*,va_list,FILE*)); /* BSD */
-#endif
-#endif
-
-/* <stdlib.h> */
-char *getenv P((char const*));
-exiting void _exit P((int));
-exiting void exit P((int));
-malloc_type malloc P((size_t));
-malloc_type realloc P((malloc_type,size_t));
-void free P((malloc_type));
-#ifndef EXIT_FAILURE
-# define EXIT_FAILURE 1
-#endif
-#ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-#endif
-#if !has_fork && !has_spawn
- int system P((char const*));
-#endif
-
-/* <string.h> */
-char *strcpy P((char*,char const*));
-char *strchr P((char const*,int));
-char *strrchr P((char const*,int));
-int memcmp P((void const*,void const*,size_t));
-int strcmp P((char const*,char const*));
-size_t strlen P((char const*));
-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 c95c9f0..0000000
--- a/gnu/usr.bin/rcs/lib/maketime.c
+++ /dev/null
@@ -1,344 +0,0 @@
-#
-/*
- * MAKETIME derive 32-bit time value from TM structure.
- *
- * Usage:
- * int zone; Minutes west of GMT, or
- * 48*60 for localtime
- * time_t t;
- * struct tm *tp; Pointer to TM structure from <time.h>
- * t = maketime(tp,zone);
- *
- * Returns:
- * -1 if failure; parameter out of range or nonsensical.
- * else time-value.
- * Notes:
- * This code is quasi-public; it may be used freely in like software.
- * It is not to be sold, nor used in licensed software without
- * permission of the author.
- * For everyone's benefit, please report bugs and improvements!
- * Copyright 1981 by Ken Harrenstien, SRI International.
- * (ARPANET: KLH @ SRI)
- */
-/* $Log: maketime.c,v $
- * Revision 5.3 1991/08/19 03:13:55 eggert
- * Add setfiledate, str2time, TZ_must_be_set.
- *
- * Revision 5.2 1990/11/01 05:03:30 eggert
- * Remove lint.
- *
- * Revision 5.1 1990/10/04 06:30:13 eggert
- * Calculate the GMT offset of 'xxx LT' as of xxx, not as of now.
- * Don't assume time_t is 32 bits. Fix bugs near epoch and near end of time.
- *
- * Revision 5.0 1990/08/22 08:12:38 eggert
- * Switch to GMT and fix the bugs exposed thereby.
- * Permit dates past 1999/12/31. Ansify and Posixate.
- *
- * Revision 1.8 88/11/08 13:54:53 narten
- * allow negative timezones (-24h <= x <= 24h)
- *
- * Revision 1.7 88/08/28 14:47:52 eggert
- * Allow cc -R. Remove unportable "#endif XXX"s.
- *
- * Revision 1.6 87/12/18 17:05:58 narten
- * include rcsparam.h
- *
- * Revision 1.5 87/12/18 11:35:51 narten
- * maketime.c: fixed USG code - you have tgo call "tzset" in order to have
- * "timezone" set. ("localtime" calls it, but it's probably better not to
- * count on "localtime" having been called.)
- *
- * Revision 1.4 87/10/18 10:26:57 narten
- * Updating version numbers. Changes relative to 1.0 are actually
- * relative to 1.2
- *
- * Revision 1.3 87/09/24 13:58:45 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:21:48 jenkins
- * Port to suns
- *
- * Revision 1.2 83/12/05 10:12:56 wft
- * added cond. compilation for USG Unix; long timezone;
- *
- * Revision 1.1 82/05/06 11:38:00 wft
- * Initial revision
- *
- */
-
-
-#include "rcsbase.h"
-
-libId(maketId, "$Id: maketime.c,v 5.3 1991/08/19 03:13:55 eggert Exp $")
-
-static struct tm const *time2tm P((time_t));
-
-#define given(v) (0 <= (v)) /* Negative values are unspecified. */
-
-static int const daytb[] = {
- /* # days in year thus far, indexed by month (0-12!!) */
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
-};
-
- static time_t
-maketime(atm,zone)
- struct tm const *atm;
- int zone;
-{
- register struct tm const *tp;
- register int i;
- int year, yday, mon, day, hour, min, sec, leap, localzone;
- int attempts;
- time_t t, tres;
-
- attempts = 2;
- localzone = zone==48*60;
- tres = -1;
- year = mon = day = 0; /* Keep lint happy. */
-
- do {
-
- if (localzone || !given(atm->tm_year)) {
- if (tres == -1)
- if ((tres = time((time_t*)0)) == -1)
- return -1;
- tp = time2tm(tres);
- /* Get breakdowns of default time, adjusting to zone. */
- year = tp->tm_year; /* Use to set up defaults */
- yday = tp->tm_yday;
- mon = tp->tm_mon;
- day = tp->tm_mday;
- hour = tp->tm_hour;
- min = tp->tm_min;
- if (localzone) {
- tp = localtime(&tres);
- zone =
- min - tp->tm_min + 60*(
- hour - tp->tm_hour + 24*(
- /* If years differ, it's by one day. */
- year - tp->tm_year
- ? year - tp->tm_year
- : yday - tp->tm_yday));
- }
- /* Adjust the default day, month and year according to zone. */
- if ((min -= zone) < 0) {
- if (hour-(59-min)/60 < 0 && --day <= 0) {
- if (--mon < 0) {
- --year;
- mon = 11;
- }
- day = daytb[mon+1] - daytb[mon] + (mon==1&&!(year&3));
- }
- } else
- if (
- 24 <= hour+min/60 &&
- daytb[mon+1] - daytb[mon] + (mon==1&&!(year&3)) < ++day
- ) {
- if (11 < ++mon) {
- ++year;
- mon = 0;
- }
- day = 1;
- }
- }
- if (zone < -24*60 || 24*60 < zone)
- return -1;
-
-
-#ifdef DEBUG
-printf("first YMD: %d %d %d\n",year,mon,day);
-#endif
- tp = atm;
-
- /* First must find date, using specified year, month, day.
- * If one of these is unspecified, it defaults either to the
- * current date (if no more global spec was given) or to the
- * zero-value for that spec (i.e. a more global spec was seen).
- * Reject times that do not fit in time_t,
- * without assuming that time_t is 32 bits or is signed.
- */
- if (given(tp->tm_year))
- {
- year = tp->tm_year;
- mon = 0; /* Since year was given, default */
- day = 1; /* for remaining specs is zero */
- }
- if (year < 69) /* 1969/12/31 OK in some timezones. */
- return -1; /* ERR: year out of range */
- leap = !(year&3) && (year%100 || !((year+300)%400));
- year -= 70; /* UNIX time starts at 1970 */
-
- /*
- * Find day of year.
- */
- {
- if (given(tp->tm_mon))
- { mon = tp->tm_mon; /* Month was specified */
- day = 1; /* so set remaining default */
- }
- if (11 < (unsigned)mon)
- return -1; /* ERR: bad month */
- if (given(tp->tm_mday)) day = tp->tm_mday;
- if(day < 1
- || (((daytb[mon+1]-daytb[mon]) < day)
- && (day!=29 || mon!=1 || !leap) ))
- return -1; /* ERR: bad day */
- yday = daytb[mon] /* Add # of days in months so far */
- + ((leap /* Leap year, and past Feb? If */
- && mon>1)? 1:0) /* so, add leap day for this year */
- + day-1; /* And finally add # days this mon */
-
- }
- if (leap+365 <= (unsigned)yday)
- return -1; /* ERR: bad YDAY */
-
- if (year < 0) {
- if (yday != 364)
- return -1; /* ERR: too early */
- t = -1;
- } else {
- tres = year*365; /* Get # days of years so far */
- if (tres/365 != year)
- return -1; /* ERR: overflow */
- t = tres
- + ((year+1)>>2) /* plus # of leap days since 1970 */
- + yday; /* and finally add # days this year */
- if (t+4 < tres)
- return -1; /* ERR: overflow */
- }
- tres = t;
-
- if (given(i = tp->tm_wday)) /* Check WDAY if present */
- if (i != (tres+4)%7) /* 1970/01/01 was Thu = 4 */
- return -1; /* ERR: bad WDAY */
-
-#ifdef DEBUG
-printf("YMD: %d %d %d, T=%ld\n",year,mon,day,tres);
-#endif
- /*
- * Now determine time. If not given, default to zeros
- * (since time is always the least global spec)
- */
- tres *= 86400L; /* Get # seconds (24*60*60) */
- if (tres/86400L != t)
- return -1; /* ERR: overflow */
- hour = min = sec = 0;
- if (given(tp->tm_hour)) hour = tp->tm_hour;
- if (given(tp->tm_min )) min = tp->tm_min;
- if (given(tp->tm_sec )) sec = tp->tm_sec;
- if (60 <= (unsigned)min || 60 < (unsigned)sec)
- return -1; /* ERR: MS out of range */
- if (24 <= (unsigned)hour)
- if(hour != 24 || (min+sec) !=0) /* Allow 24:00 */
- return -1; /* ERR: H out of range */
-
- t = tres;
- tres += sec + 60L*(zone + min + 60*hour);
-
-#ifdef DEBUG
-printf("HMS: %d %d %d T=%ld\n",hour,min,sec,tres);
-#endif
-
- if (!localzone) /* check for overflow */
- return (year<0 ? (tres<0||86400L<=tres) : tres<t) ? -1 : tres;
-
- /* Check results; LT may have had a different GMT offset back then. */
- tp = localtime(&tres);
- if (given(atm->tm_sec) && atm->tm_sec != tp->tm_sec)
- return -1; /* If seconds don't match, we're in trouble. */
- if (!(
- given(atm->tm_min) && atm->tm_min != tp->tm_min ||
- given(atm->tm_hour) && atm->tm_hour != tp->tm_hour ||
- given(atm->tm_mday) && atm->tm_mday != tp->tm_mday ||
- given(atm->tm_mon) && atm->tm_mon != tp->tm_mon ||
- given(atm->tm_year) && atm->tm_year != tp->tm_year
- ))
- return tres; /* Everything matches. */
-
- } while (--attempts);
-
- return -1;
-}
-
-/*
-* Convert Unix time to struct tm format.
-* Use Coordinated Universal Time (UTC) if version 5 or newer;
-* use local time otherwise.
-*/
- static struct tm const *
-time2tm(unixtime)
- time_t unixtime;
-{
- struct tm const *tm;
-# if TZ_must_be_set
- static char const *TZ;
- if (!TZ && !(TZ = getenv("TZ")))
- faterror("TZ is not set");
-# endif
- if (!(tm = (RCSversion<VERSION(5) ? localtime : gmtime)(&unixtime)))
- faterror("UTC is not available; perhaps TZ is not set?");
- return tm;
-}
-
-/*
-* Convert Unix time to RCS format.
-* For compatibility with older versions of RCS,
-* dates before AD 2000 are stored without the leading "19".
-*/
- void
-time2date(unixtime,date)
- time_t unixtime;
- char date[datesize];
-{
- register struct tm const *tm = time2tm(unixtime);
- VOID sprintf(date, DATEFORM,
- tm->tm_year + (tm->tm_year<100 ? 0 : 1900),
- tm->tm_mon+1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec
- );
-}
-
-
-
- static time_t
-str2time(source)
- char const *source;
-/* Parse a free-format date in SOURCE, yielding a Unix format time. */
-{
- int zone;
- time_t unixtime;
- struct tm parseddate;
-
- if (!partime(source, &parseddate, &zone))
- faterror("can't parse date/time: %s", source);
- if ((unixtime = maketime(&parseddate, zone)) == -1)
- faterror("bad date/time: %s", source);
- return unixtime;
-}
-
- void
-str2date(source, target)
- char const *source;
- char target[datesize];
-/* Parse a free-format date in SOURCE, convert it
- * into RCS internal format, and store the result into TARGET.
- */
-{
- time2date(str2time(source), target);
-}
-
- int
-setfiledate(file, date)
- char const *file, date[datesize];
-/* Set the access and modification time of FILE to DATE. */
-{
- static struct utimbuf times; /* static so unused fields are zero */
- char datebuf[datesize];
-
- if (!date)
- return 0;
- times.actime = times.modtime = str2time(date2str(date, datebuf));
- return utime(file, &times);
-}
diff --git a/gnu/usr.bin/rcs/lib/merger.c b/gnu/usr.bin/rcs/lib/merger.c
deleted file mode 100644
index 7162ffa..0000000
--- a/gnu/usr.bin/rcs/lib/merger.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* merger - three-way file merge internals */
-
-/* Copyright 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-
-libId(mergerId, "$Id: merger.c,v 1.3 1991/08/20 23:05:00 eggert Exp $")
-
- 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;
- switch (*s) {
- case '-': case '+':
- *b = t = testalloc(strlen(s) + 3);
- VOID sprintf(t, ".%c%s", SLASH, s);
- return t;
- default:
- *b = 0;
- return s;
- }
-}
-
- int
-merge(tostdout, label, argv)
- int tostdout;
- char const *const label[2];
- char const *const argv[3];
-/*
- * Do `merge [-p] -L l0 -L l1 a0 a1 a2',
- * where TOSTDOUT specifies whether -p is present,
- * LABEL gives l0 and l1, 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 DIFF3_BIN
- t = 0;
- if (!tostdout)
- t = maketemp(0);
- s = run(
- (char*)0, t,
- DIFF3, "-am", "-L", label[0], "-L", label[1],
- a[0], a[1], a[2], (char*)0
- );
- switch (s) {
- case DIFF_SUCCESS:
- break;
- case DIFF_FAILURE:
- if (!quietflag)
- warn("overlaps during merge");
- break;
- default:
- exiterr();
- }
- if (t) {
- if (!(f = fopen(argv[0], FOPEN_W)))
- efaterror(argv[0]);
- if (!(rt = Iopen(t, FOPEN_R, (struct stat*)0)))
- efaterror(t);
- fastcopy(rt, f);
- Ifclose(rt);
- Ofclose(f);
- }
-#else
- for (i=0; i<2; i++)
- switch (run(
- (char*)0, d[i]=maketemp(i),
- DIFF, a[i], a[2], (char*)0
- )) {
- case DIFF_FAILURE: case DIFF_SUCCESS: break;
- default: exiterr();
- }
- t = maketemp(2);
- s = run(
- (char*)0, t,
- DIFF3, "-E", d[0], d[1], a[0], a[1], a[2],
- label[0], label[1], (char*)0
- );
- if (s != DIFF_SUCCESS) {
- s = DIFF_FAILURE;
- if (!quietflag)
- warn("overlaps or other problems during merge");
- }
- if (!(f = fopen(t, "a")))
- efaterror(t);
- aputs(tostdout ? "1,$p\n" : "w\n", f);
- Ofclose(f);
- if (run(t, (char*)0, ED, "-", a[0], (char*)0))
- exiterr();
-#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 4751fc5..0000000
--- a/gnu/usr.bin/rcs/lib/partime.c
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * PARTIME parse date/time string into a TM structure
- *
- * Returns:
- * 0 if parsing failed
- * else time values in specified TM structure and zone (unspecified values
- * set to TMNULL)
- * Notes:
- * This code is quasi-public; it may be used freely in like software.
- * It is not to be sold, nor used in licensed software without
- * permission of the author.
- * For everyone's benefit, please report bugs and improvements!
- * Copyright 1980 by Ken Harrenstien, SRI International.
- * (ARPANET: KLH @ SRI)
- */
-
-/* Hacknotes:
- * If parsing changed so that no backup needed, could perhaps modify
- * to use a FILE input stream. Need terminator, though.
- * Perhaps should return 0 on success, else a non-zero error val?
- */
-
-/* $Log: partime.c,v $
- * Revision 5.6 1991/08/19 03:13:55 eggert
- * Update timezones.
- *
- * Revision 5.5 1991/04/21 11:58:18 eggert
- * Don't put , just before } in initializer.
- *
- * Revision 5.4 1990/10/04 06:30:15 eggert
- * Remove date vs time heuristics that fail between 2000 and 2400.
- * Check for overflow when lexing an integer.
- * Parse 'Jan 10 LT' as 'Jan 10, LT', not 'Jan, 10 LT'.
- *
- * Revision 5.3 1990/09/24 18:56:31 eggert
- * Update timezones.
- *
- * Revision 5.2 1990/09/04 08:02:16 eggert
- * Don't parse two-digit years, because it won't work after 1999/12/31.
- * Don't permit 'Aug Aug'.
- *
- * Revision 5.1 1990/08/29 07:13:49 eggert
- * Be able to parse our own date format. Don't assume year<10000.
- *
- * Revision 5.0 1990/08/22 08:12:40 eggert
- * Switch to GMT and fix the bugs exposed thereby. Update timezones.
- * Ansify and Posixate. Fix peekahead and int-size bugs.
- *
- * Revision 1.4 89/05/01 14:48:46 narten
- * fixed #ifdef DEBUG construct
- *
- * Revision 1.3 88/08/28 14:53:40 eggert
- * Remove unportable "#endif XXX"s.
- *
- * Revision 1.2 87/03/27 14:21:53 jenkins
- * Port to suns
- *
- * Revision 1.1 82/05/06 11:38:26 wft
- * Initial revision
- *
- */
-
-#include "rcsbase.h"
-
-libId(partId, "$Id: partime.c,v 5.6 1991/08/19 03:13:55 eggert Exp $")
-
-#define given(v) (0 <= (v))
-#define TMNULL (-1) /* Items not given are given this value */
-#define TZ_OFFSET (24*60) /* TMNULL < zone_offset - TZ_OFFSET */
-
-struct tmwent {
- char const *went;
- short wval;
- char wflgs;
- char wtype;
-};
- /* wflgs */
-#define TWTIME 02 /* Word is a time value (absence implies date) */
-#define TWDST 04 /* Word is a DST-type timezone */
- /* wtype */
-#define TM_MON 1 /* month name */
-#define TM_WDAY 2 /* weekday name */
-#define TM_ZON 3 /* time zone name */
-#define TM_LT 4 /* local time */
-#define TM_DST 5 /* daylight savings time */
-#define TM_12 6 /* AM, PM, NOON, or MIDNIGHT */
- /* wval (for wtype==TM_12) */
-#define T12_AM 1
-#define T12_PM 2
-#define T12_NOON 12
-#define T12_MIDNIGHT 0
-
-static struct tmwent const tmwords [] = {
- {"january", 0, 0, TM_MON},
- {"february", 1, 0, TM_MON},
- {"march", 2, 0, TM_MON},
- {"april", 3, 0, TM_MON},
- {"may", 4, 0, TM_MON},
- {"june", 5, 0, TM_MON},
- {"july", 6, 0, TM_MON},
- {"august", 7, 0, TM_MON},
- {"september", 8, 0, TM_MON},
- {"october", 9, 0, TM_MON},
- {"november", 10, 0, TM_MON},
- {"december", 11, 0, TM_MON},
-
- {"sunday", 0, 0, TM_WDAY},
- {"monday", 1, 0, TM_WDAY},
- {"tuesday", 2, 0, TM_WDAY},
- {"wednesday", 3, 0, TM_WDAY},
- {"thursday", 4, 0, TM_WDAY},
- {"friday", 5, 0, TM_WDAY},
- {"saturday", 6, 0, TM_WDAY},
-
- {"gmt", 0*60, TWTIME, TM_ZON}, /* Greenwich */
- {"utc", 0*60, TWTIME, TM_ZON},
- {"ut", 0*60, TWTIME, TM_ZON},
- {"cut", 0*60, TWTIME, TM_ZON},
-
- {"nzst", -12*60, TWTIME, TM_ZON}, /* New Zealand */
- {"jst", -9*60, TWTIME, TM_ZON}, /* Japan */
- {"kst", -9*60, TWTIME, TM_ZON}, /* Korea */
- {"ist", -5*60-30, TWTIME, TM_ZON},/* India */
- {"eet", -2*60, TWTIME, TM_ZON}, /* Eastern Europe */
- {"cet", -1*60, TWTIME, TM_ZON}, /* Central Europe */
- {"met", -1*60, TWTIME, TM_ZON}, /* Middle Europe */
- {"wet", 0*60, TWTIME, TM_ZON}, /* Western Europe */
- {"nst", 3*60+30, TWTIME, TM_ZON},/* Newfoundland */
- {"ast", 4*60, TWTIME, TM_ZON}, /* Atlantic */
- {"est", 5*60, TWTIME, TM_ZON}, /* Eastern */
- {"cst", 6*60, TWTIME, TM_ZON}, /* Central */
- {"mst", 7*60, TWTIME, TM_ZON}, /* Mountain */
- {"pst", 8*60, TWTIME, TM_ZON}, /* Pacific */
- {"akst", 9*60, TWTIME, TM_ZON}, /* Alaska */
- {"hast", 10*60, TWTIME, TM_ZON}, /* Hawaii-Aleutian */
- {"hst", 10*60, TWTIME, TM_ZON}, /* Hawaii */
- {"sst", 11*60, TWTIME, TM_ZON}, /* Samoa */
-
- {"nzdt", -12*60, TWTIME+TWDST, TM_ZON}, /* New Zealand */
- {"kdt", -9*60, TWTIME+TWDST, TM_ZON}, /* Korea */
- {"bst", 0*60, TWTIME+TWDST, TM_ZON}, /* Britain */
- {"ndt", 3*60+30, TWTIME+TWDST, TM_ZON}, /* Newfoundland */
- {"adt", 4*60, TWTIME+TWDST, TM_ZON}, /* Atlantic */
- {"edt", 5*60, TWTIME+TWDST, TM_ZON}, /* Eastern */
- {"cdt", 6*60, TWTIME+TWDST, TM_ZON}, /* Central */
- {"mdt", 7*60, TWTIME+TWDST, TM_ZON}, /* Mountain */
- {"pdt", 8*60, TWTIME+TWDST, TM_ZON}, /* Pacific */
- {"akdt", 9*60, TWTIME+TWDST, TM_ZON}, /* Alaska */
- {"hadt", 10*60, TWTIME+TWDST, TM_ZON}, /* Hawaii-Aleutian */
-
-#if 0
- /*
- * The following names are duplicates or are not well attested.
- * A standard is needed.
- */
- {"east", -10*60, TWTIME, TM_ZON}, /* Eastern Australia */
- {"cast", -9*60-30, TWTIME, TM_ZON},/* Central Australia */
- {"cst", -8*60, TWTIME, TM_ZON}, /* China */
- {"hkt", -8*60, TWTIME, TM_ZON}, /* Hong Kong */
- {"sst", -8*60, TWTIME, TM_ZON}, /* Singapore */
- {"wast", -8*60, TWTIME, TM_ZON}, /* Western Australia */
- {"?", -6*60-30, TWTIME, TM_ZON},/* Burma */
- {"?", -4*60-30, TWTIME, TM_ZON},/* Afghanistan */
- {"it", -3*60-30, TWTIME, TM_ZON},/* Iran */
- {"ist", -2*60, TWTIME, TM_ZON}, /* Israel */
- {"mez", -1*60, TWTIME, TM_ZON}, /* Mittel-Europaeische Zeit */
- {"ast", 1*60, TWTIME, TM_ZON}, /* Azores */
- {"fst", 2*60, TWTIME, TM_ZON}, /* Fernando de Noronha */
- {"bst", 3*60, TWTIME, TM_ZON}, /* Brazil */
- {"wst", 4*60, TWTIME, TM_ZON}, /* Western Brazil */
- {"ast", 5*60, TWTIME, TM_ZON}, /* Acre Brazil */
- {"?", 9*60+30, TWTIME, TM_ZON},/* Marquesas */
- {"?", 12*60, TWTIME, TM_ZON}, /* Kwajalein */
-
- {"eadt", -10*60, TWTIME+TWDST, TM_ZON}, /* Eastern Australia */
- {"cadt", -9*60-30, TWTIME+TWDST, TM_ZON}, /* Central Australia */
- {"cdt", -8*60, TWTIME+TWDST, TM_ZON}, /* China */
- {"wadt", -8*60, TWTIME+TWDST, TM_ZON}, /* Western Australia */
- {"idt", -2*60, TWTIME+TWDST, TM_ZON}, /* Israel */
- {"eest", -2*60, TWTIME+TWDST, TM_ZON}, /* Eastern Europe */
- {"cest", -1*60, TWTIME+TWDST, TM_ZON}, /* Central Europe */
- {"mest", -1*60, TWTIME+TWDST, TM_ZON}, /* Middle Europe */
- {"mesz", -1*60, TWTIME+TWDST, TM_ZON}, /* Mittel-Europaeische Sommerzeit */
- {"west", 0*60, TWTIME+TWDST, TM_ZON}, /* Western Europe */
- {"adt", 1*60, TWTIME+TWDST, TM_ZON}, /* Azores */
- {"fdt", 2*60, TWTIME+TWDST, TM_ZON}, /* Fernando de Noronha */
- {"edt", 3*60, TWTIME+TWDST, TM_ZON}, /* Eastern Brazil */
- {"wdt", 4*60, TWTIME+TWDST, TM_ZON}, /* Western Brazil */
- {"adt", 5*60, TWTIME+TWDST, TM_ZON}, /* Acre Brazil */
-#endif
-
- {"lt", 0, TWTIME, TM_LT}, /* local time */
- {"dst", 1*60, TWTIME, TM_DST}, /* daylight savings time */
- {"ddst", 2*60, TWTIME, TM_DST}, /* double dst */
-
- {"am", T12_AM, TWTIME, TM_12},
- {"pm", T12_PM, TWTIME, TM_12},
- {"noon", T12_NOON, TWTIME, TM_12},
- {"midnight", T12_MIDNIGHT, TWTIME, TM_12},
-
- {0, 0, 0, 0} /* Zero entry to terminate searches */
-};
-
-struct token {
- char const *tcp;/* pointer to string */
- int tcnt; /* # chars */
- char tbrk; /* "break" char */
- char tbrkl; /* last break char */
- char tflg; /* 0 = alpha, 1 = numeric */
- union { /* Resulting value; */
- int tnum;/* either a #, or */
- struct tmwent const *ttmw;/* a ptr to a tmwent. */
- } tval;
-};
-
-static struct tmwent const*ptmatchstr P((char const*,int,struct tmwent const*));
-static int pt12hack P((struct tm *,int));
-static int ptitoken P((struct token *));
-static int ptstash P((int *,int));
-static int pttoken P((struct token *));
-
- static int
-goodzone(t, offset, am)
- register struct token const *t;
- int offset;
- int *am;
-{
- register int m;
- if (
- t->tflg &&
- t->tcnt == 4+offset &&
- (m = t->tval.tnum) <= 2400 &&
- isdigit(t->tcp[offset]) &&
- (m%=100) < 60
- ) {
- m += t->tval.tnum/100 * 60;
- if (t->tcp[offset-1]=='+')
- m = -m;
- *am = m;
- return 1;
- }
- return 0;
-}
-
- int
-partime(astr, atm, zone)
-char const *astr;
-register struct tm *atm;
-int *zone;
-{
- register int i;
- struct token btoken, atoken;
- int zone_offset; /* minutes west of GMT, plus TZ_OFFSET */
- register char const *cp;
- register char ch;
- int ord, midnoon;
- int *atmfield, dst, m;
- int got1 = 0;
-
- atm->tm_sec = TMNULL;
- atm->tm_min = TMNULL;
- atm->tm_hour = TMNULL;
- atm->tm_mday = TMNULL;
- atm->tm_mon = TMNULL;
- atm->tm_year = TMNULL;
- atm->tm_wday = TMNULL;
- atm->tm_yday = TMNULL;
- midnoon = TMNULL; /* and our own temp stuff */
- zone_offset = TMNULL;
- dst = TMNULL;
- btoken.tcnt = btoken.tbrk = 0;
- btoken.tcp = astr;
-
- for (;; got1=1) {
- if (!ptitoken(&btoken)) /* Get a token */
- { if(btoken.tval.tnum) return(0); /* Read error? */
- if (given(midnoon)) /* EOF, wrap up */
- if (!pt12hack(atm, midnoon))
- return 0;
- if (!given(atm->tm_min))
- atm->tm_min = 0;
- *zone =
- (given(zone_offset) ? zone_offset-TZ_OFFSET : 0)
- - (given(dst) ? dst : 0);
- return got1;
- }
- if(btoken.tflg == 0) /* Alpha? */
- { i = btoken.tval.ttmw->wval;
- switch (btoken.tval.ttmw->wtype) {
- default:
- return 0;
- case TM_MON:
- atmfield = &atm->tm_mon;
- break;
- case TM_WDAY:
- atmfield = &atm->tm_wday;
- break;
- case TM_DST:
- atmfield = &dst;
- break;
- case TM_LT:
- if (ptstash(&dst, 0))
- return 0;
- i = 48*60; /* local time magic number -- see maketime() */
- /* fall into */
- case TM_ZON:
- i += TZ_OFFSET;
- if (btoken.tval.ttmw->wflgs & TWDST)
- if (ptstash(&dst, 60))
- return 0;
- /* Peek ahead for offset immediately afterwards. */
- if (
- (btoken.tbrk=='-' || btoken.tbrk=='+') &&
- (atoken=btoken, ++atoken.tcnt, ptitoken(&atoken)) &&
- goodzone(&atoken, 0, &m)
- ) {
- i += m;
- btoken = atoken;
- }
- atmfield = &zone_offset;
- break;
- case TM_12:
- atmfield = &midnoon;
- }
- if (ptstash(atmfield, i))
- return(0); /* ERR: val already set */
- continue;
- }
-
- /* Token is number. Lots of hairy heuristics. */
- if (!isdigit(*btoken.tcp)) {
- if (!goodzone(&btoken, 1, &m))
- return 0;
- zone_offset = TZ_OFFSET + m;
- continue;
- }
-
- i = btoken.tval.tnum; /* Value now known to be valid; get it. */
- if (btoken.tcnt == 3) /* 3 digits = HMM */
- {
-hhmm4: if (ptstash(&atm->tm_min, i%100))
- return(0); /* ERR: min conflict */
- i /= 100;
-hh2: if (ptstash(&atm->tm_hour, i))
- return(0); /* ERR: hour conflict */
- continue;
- }
-
- if (4 < btoken.tcnt)
- goto year4; /* far in the future */
- if(btoken.tcnt == 4) /* 4 digits = YEAR or HHMM */
- { if (given(atm->tm_year)) goto hhmm4; /* Already got yr? */
- if (given(atm->tm_hour)) goto year4; /* Already got hr? */
- if(btoken.tbrk == ':') /* HHMM:SS ? */
- if ( ptstash(&atm->tm_hour, i/100)
- || ptstash(&atm->tm_min, i%100))
- return(0); /* ERR: hr/min clash */
- else goto coltm2; /* Go handle SS */
- if(btoken.tbrk != ',' && btoken.tbrk != '/'
- && (atoken=btoken, ptitoken(&atoken)) /* Peek */
- && ( atoken.tflg
- ? !isdigit(*atoken.tcp)
- : atoken.tval.ttmw->wflgs & TWTIME)) /* HHMM-ZON */
- goto hhmm4;
- goto year4; /* Give up, assume year. */
- }
-
- /* From this point on, assume tcnt == 1 or 2 */
- /* 2 digits = MM, DD, or HH (MM and SS caught at coltime) */
- if(btoken.tbrk == ':') /* HH:MM[:SS] */
- goto coltime; /* must be part of time. */
- if (31 < i)
- return 0;
-
- /* Check for numerical-format date */
- for (cp = "/-."; ch = *cp++;)
- { ord = (ch == '.' ? 0 : 1); /* n/m = D/M or M/D */
- if(btoken.tbrk == ch) /* "NN-" */
- { if(btoken.tbrkl != ch)
- {
- atoken = btoken;
- atoken.tcnt++;
- if (ptitoken(&atoken)
- && atoken.tflg == 0
- && atoken.tval.ttmw->wtype == TM_MON)
- goto dd2;
- if(ord)goto mm2; else goto dd2; /* "NN-" */
- } /* "-NN-" */
- if (!given(atm->tm_mday)
- && given(atm->tm_year)) /* If "YYYY-NN-" */
- goto mm2; /* then always MM */
- if(ord)goto dd2; else goto mm2;
- }
- if(btoken.tbrkl == ch /* "-NN" */
- && given(ord ? atm->tm_mon : atm->tm_mday))
- if (!given(ord ? atm->tm_mday : atm->tm_mon)) /* MM/DD */
- if(ord)goto dd2; else goto mm2;
- }
-
- /* Now reduced to choice between HH and DD */
- if (given(atm->tm_hour)) goto dd2; /* Have hour? Assume day. */
- if (given(atm->tm_mday)) goto hh2; /* Have day? Assume hour. */
- if (given(atm->tm_mon)) goto dd2; /* Have month? Assume day. */
- if(i > 24) goto dd2; /* Impossible HH means DD */
- atoken = btoken;
- if (!ptitoken(&atoken)) /* Read ahead! */
- if(atoken.tval.tnum) return(0); /* ERR: bad token */
- else goto dd2; /* EOF, assume day. */
- if ( atoken.tflg
- ? !isdigit(*atoken.tcp)
- : atoken.tval.ttmw->wflgs & TWTIME)
- /* If next token is a time spec, assume hour */
- goto hh2; /* e.g. "3 PM", "11-EDT" */
-
-dd2: if (ptstash(&atm->tm_mday, i)) /* Store day (1 based) */
- return(0);
- continue;
-
-mm2: if (ptstash(&atm->tm_mon, i-1)) /* Store month (make zero based) */
- return(0);
- continue;
-
-year4: if ((i-=1900) < 0 || ptstash(&atm->tm_year, i)) /* Store year-1900 */
- return(0); /* ERR: year conflict */
- continue;
-
- /* Hack HH:MM[[:]SS] */
-coltime:
- if (ptstash(&atm->tm_hour, i)) return 0;
- if (!ptitoken(&btoken))
- return(!btoken.tval.tnum);
- if(!btoken.tflg) return(0); /* ERR: HH:<alpha> */
- if(btoken.tcnt == 4) /* MMSS */
- if (ptstash(&atm->tm_min, btoken.tval.tnum/100)
- || ptstash(&atm->tm_sec, btoken.tval.tnum%100))
- return(0);
- else continue;
- if(btoken.tcnt != 2
- || ptstash(&atm->tm_min, btoken.tval.tnum))
- return(0); /* ERR: MM bad */
- if (btoken.tbrk != ':') continue; /* Seconds follow? */
-coltm2: if (!ptitoken(&btoken))
- return(!btoken.tval.tnum);
- if(!btoken.tflg || btoken.tcnt != 2 /* Verify SS */
- || ptstash(&atm->tm_sec, btoken.tval.tnum))
- return(0); /* ERR: SS bad */
- }
-}
-
-/* Store date/time value, return 0 if successful.
- * Fail if entry is already set.
- */
- static int
-ptstash(adr,val)
-int *adr;
-int val;
-{ register int *a;
- if (given(*(a=adr)))
- return 1;
- *a = val;
- return(0);
-}
-
-/* This subroutine is invoked for AM, PM, NOON and MIDNIGHT when wrapping up
- * just prior to returning from partime.
- */
- static int
-pt12hack(tm, aval)
-register struct tm *tm;
-register int aval;
-{ register int h = tm->tm_hour;
- switch (aval) {
- case T12_AM:
- case T12_PM:
- if (h > 12)
- return 0;
- if (h == 12)
- tm->tm_hour = 0;
- if (aval == T12_PM)
- tm->tm_hour += 12;
- break;
- default:
- if (0 < tm->tm_min || 0 < tm->tm_sec)
- return 0;
- if (!given(h) || h==12)
- tm->tm_hour = aval;
- else if (aval==T12_MIDNIGHT && (h==0 || h==24))
- return 0;
- }
- return 1;
-}
-
-/* Get a token and identify it to some degree.
- * Returns 0 on failure; token.tval will be 0 for normal EOF, otherwise
- * hit error of some sort
- */
-
- static int
-ptitoken(tkp)
-register struct token *tkp;
-{
- register char const *cp;
- register int i, j, k;
-
- if (!pttoken(tkp))
-#ifdef DEBUG
- {
- VOID printf("EOF\n");
- return(0);
- }
-#else
- return(0);
-#endif
- cp = tkp->tcp;
-
-#ifdef DEBUG
- VOID printf("Token: \"%.*s\" ", tkp->tcnt, cp);
-#endif
-
- if (tkp->tflg) {
- i = tkp->tcnt;
- if (*cp == '+' || *cp == '-') {
- cp++;
- i--;
- }
- while (0 <= --i) {
- j = tkp->tval.tnum*10;
- k = j + (*cp++ - '0');
- if (j/10 != tkp->tval.tnum || k < j) {
- /* arithmetic overflow */
- tkp->tval.tnum = 1;
- return 0;
- }
- tkp->tval.tnum = k;
- }
- } else if (!(tkp->tval.ttmw = ptmatchstr(cp, tkp->tcnt, tmwords)))
- {
-#ifdef DEBUG
- VOID printf("Not found!\n");
-#endif
- tkp->tval.tnum = 1;
- return 0;
- }
-
-#ifdef DEBUG
- if(tkp->tflg)
- VOID printf("Val: %d.\n",tkp->tval.tnum);
- else VOID printf("Found: \"%s\", val: %d, type %d\n",
- tkp->tval.ttmw->went,tkp->tval.ttmw->wval,tkp->tval.ttmw->wtype);
-#endif
-
- return(1);
-}
-
-/* Read token from input string into token structure */
- static int
-pttoken(tkp)
-register struct token *tkp;
-{
- register char const *cp;
- register int c;
- char const *astr;
-
- tkp->tcp = astr = cp = tkp->tcp + tkp->tcnt;
- tkp->tbrkl = tkp->tbrk; /* Set "last break" */
- tkp->tcnt = tkp->tbrk = tkp->tflg = 0;
- tkp->tval.tnum = 0;
-
- while(c = *cp++)
- { switch(c)
- { case ' ': case '\t': /* Flush all whitespace */
- case '\r': case '\n':
- case '\v': case '\f':
- if (!tkp->tcnt) { /* If no token yet */
- tkp->tcp = cp; /* ignore the brk */
- continue; /* and go on. */
- }
- /* fall into */
- case '(': case ')': /* Perhaps any non-alphanum */
- case '-': case ',': /* shd qualify as break? */
- case '+':
- case '/': case ':': case '.': /* Break chars */
- if(tkp->tcnt == 0) /* If no token yet */
- { tkp->tcp = cp; /* ignore the brk */
- tkp->tbrkl = c;
- continue; /* and go on. */
- }
- tkp->tbrk = c;
- return(tkp->tcnt);
- }
- if (!tkp->tcnt++) { /* If first char of token, */
- if (isdigit(c)) {
- tkp->tflg = 1;
- if (astr<cp-2 && (cp[-2]=='-'||cp[-2]=='+')) {
- /* timezone is break+sign+digit */
- tkp->tcp--;
- tkp->tcnt++;
- }
- }
- } else if ((isdigit(c)!=0) != tkp->tflg) { /* else check type */
- tkp->tbrk = c;
- return --tkp->tcnt; /* Wrong type, back up */
- }
- }
- return(tkp->tcnt); /* When hit EOF */
-}
-
-
- static struct tmwent const *
-ptmatchstr(astr,cnt,astruc)
- char const *astr;
- int cnt;
- struct tmwent const *astruc;
-{
- register char const *cp, *mp;
- register int c;
- struct tmwent const *lastptr;
- int i;
-
- lastptr = 0;
- for(;mp = astruc->went; astruc += 1)
- { cp = astr;
- for(i = cnt; i > 0; i--)
- {
- switch (*cp++ - (c = *mp++))
- { case 0: continue; /* Exact match */
- case 'A'-'a':
- if (ctab[c] == Letter)
- continue;
- }
- break;
- }
- if(i==0)
- if (!*mp) return astruc; /* Exact match */
- else if(lastptr) return(0); /* Ambiguous */
- else lastptr = astruc; /* 1st ambig */
- }
- return lastptr;
-}
diff --git a/gnu/usr.bin/rcs/lib/rcsbase.h b/gnu/usr.bin/rcs/lib/rcsbase.h
deleted file mode 100644
index c0904bb..0000000
--- a/gnu/usr.bin/rcs/lib/rcsbase.h
+++ /dev/null
@@ -1,677 +0,0 @@
-
-/*
- * RCS common definitions and data structures
- */
-#define RCSBASE "$Id: rcsbase.h,v 5.11 1991/10/07 17:32:46 eggert Exp $"
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-/*****************************************************************************
- * INSTRUCTIONS:
- * =============
- * See the Makefile for how to define C preprocessor symbols.
- * If you need to change the comment leaders, update the table comtable[]
- * in rcsfnms.c. (This can wait until you know what a comment leader is.)
- *****************************************************************************
- */
-
-
-/* $Log: rcsbase.h,v $
- * 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 PATH_MAX
-# define SIZEABLE_PATH PATH_MAX /* size of a large path; not a hard limit */
-#else
-# define SIZEABLE_PATH _POSIX_PATH_MAX
-#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 DATEFORM */
-#define joinlength 20 /* number of joined revisions permitted */
-#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
-#define nil 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
- * Ifileno, Irewind, Iseek, Itell - analogs to stdio routines
- */
-
-#if large_memory
- typedef unsigned char const *Iptr_type;
- typedef struct {
- Iptr_type ptr, lim;
- unsigned char *base; /* for lint, not Iptr_type even if has_mmap */
-# if has_mmap
-# define Ifileno(f) ((f)->fd)
- int fd;
-# else
-# define Ifileno(f) fileno((f)->stream)
- FILE *stream;
- unsigned char *readlim;
-# endif
- } RILE;
-# if has_mmap
-# 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
-# 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 Itell(f) ((f)->ptr)
-# define Iseek(f,p) ((f)->ptr = (p))
-# define Irewind(f) Iseek(f, (f)->base)
-# define cachetell() ptr
-#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))<0){testIerror(f);if(feof(f))s}else
-# define cachegeteof(c,s) Igeteof(ptr,c,s)
-# define Iget(f,c) if (((c)=getc(f))<0) testIeof(f); else
-# define cacheget(c) Iget(ptr,c)
-# define Ifileno(f) fileno(f)
-#endif
-
-/* Print a char, but abort on write error. */
-#define aputc(c,o) if (putc(c,o)<0) testOerror(o); else
-
-/* 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)&~(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) */
- struct cbuf log; /* log message requested at checkin */
- struct branchhead * branches; /* list of first revisions on branches*/
- struct cbuf ig; /* ignored phrases of revision */
- struct hshentry * next; /* next revision on same branch */
- struct hshentry * nexthsh; /* next revision with same hash value */
- unsigned long insertlns;/* lines inserted (computed by rlog) */
- unsigned 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 lock {
- char const * login;
- struct hshentry * delta;
- struct lock * 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 lint
-# define libId(name,rcsid)
-# define mainProg(name,cmd,rcsid) int name mainArgs
-#else
-# define libId(name,rcsid) char const name[] = rcsid;
-# define mainProg(name,cmd,rcsid) char const copyright[] = "Copyright 1982,1988,1989 by Walter F. Tichy\nPurdue CS\nCopyright 1990,1991 by Paul Eggert", rcsbaseId[] = RCSBASE, cmdid[] = cmd; libId(name,rcsid) 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 RCSFILE "RCSfile"
-#define REVISION "Revision"
-#define SOURCE "Source"
-#define STATE "State"
-#define keylength 8 /* max length of any of the above keywords */
-
-enum markers { Nomatch, Author, Date, Header, Id,
- Locker, Log, RCSfile, Revision, Source, State };
- /* 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[];
-exiting void exiterr P((void));
-
-/* maketime */
-int setfiledate P((char const*,char const[datesize]));
-void str2date P((char const*,char[datesize]));
-void time2date P((time_t,char[datesize]));
-
-/* merge */
-int merge P((int,char const*const[2],char const*const[3]));
-
-/* partime */
-int partime P((char const*,struct tm*,int*));
-
-/* rcsedit */
-#define ciklogsize 23 /* sizeof("checked in with -k by ") */
-extern FILE *fcopy;
-extern char const *resultfile;
-extern char const ciklog[ciklogsize];
-extern int locker_expansion;
-extern struct buf dirtfname[];
-#define newRCSfilename (dirtfname[0].string)
-RILE *rcswriteopen P((struct buf*,struct stat*,int));
-char const *makedirtemp P((char const*,int));
-char const *getcaller P((void));
-int addlock P((struct hshentry*));
-int addsymbol P((char const*,char const*,int));
-int checkaccesslist P((void));
-int chnamemod P((FILE**,char const*,char const*,mode_t));
-int donerewrite P((int));
-int dorewrite P((int,int));
-int expandline P((RILE*,FILE*,struct hshentry const*,int,FILE*));
-int findlock P((int,struct hshentry**));
-void aflush P((FILE*));
-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) ((void) ((b)->string = 0, (b)->size = 0))
-extern FILE *workstdout;
-extern char *workfilename;
-extern char const *RCSfilename;
-extern char const *suffixes;
-extern struct stat RCSstat;
-RILE *rcsreadopen P((struct buf*,struct stat*,int));
-char *bufenlarge P((struct buf*,char const**));
-char const *basename P((char const*));
-char const *getfullRCSname P((void));
-char const *maketemp P((int));
-char const *rcssuffix P((char const*));
-int pairfilenames P((int,char**,RILE*(*)P((struct buf*,struct stat*,int)),int,int));
-size_t dirlen P((char const*));
-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 ttystdin P((void));
-int yesorno P((int,char const*,...));
-struct cbuf cleanlogmsg P((char*,size_t));
-struct cbuf getsstdin P((char const*,char const*,char const*,struct buf*));
-void putdesc P((int,char*));
-
-/* rcskeep */
-extern int prevkeys;
-extern struct buf prevauthor, prevdate, prevrev, prevstate;
-int getoldkeys P((RILE*));
-
-/* rcskeys */
-extern char const *const Keyword[];
-enum markers trymatch P((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 unsigned long rcsline;
-char const *getid P((void));
-exiting void efaterror P((char const*));
-exiting void enfaterror P((int,char const*));
-exiting void faterror P((char const*,...));
-exiting void fatserror P((char const*,...));
-exiting void Ieof P((void));
-exiting void Ierror P((void));
-exiting void Oerror P((void));
-char *checkid 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 Ozclose P((FILE**));
-void afputc P((int,FILE*));
-void aprintf P((FILE*,char const*,...));
-void aputs P((char const*,FILE*));
-void checksid P((char*));
-void diagnose P((char const*,...));
-void eerror P((char const*));
-void eflush P((void));
-void enerror P((int,char const*));
-void error P((char const*,...));
-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 testIerror P((FILE*));
-void testOerror P((FILE*));
-void warn P((char const*,...));
-void warnignore P((void));
-#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 has_mmap && large_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 const enum tokens ctab[];
-
-/* rcsrev */
-char *partialno P((struct buf*,char const*,unsigned));
-char const *tiprev P((void));
-int cmpnum P((char const*,char const*));
-int cmpnumfld P((char const*,char const*,unsigned));
-int compartial P((char const*,char const*,unsigned));
-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**));
-unsigned 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 */
-struct diffcmd {
- unsigned 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 lock * Locks;
-extern struct hshentry * Head;
-extern int Expand;
-extern int StrictLocks;
-extern unsigned TotalDeltas;
-extern char const *const expand_names[];
-extern char const Kdesc[];
-extern char const Klog[];
-extern char const Ktext[];
-int getdiffcmd P((RILE*,int,FILE*,struct diffcmd*));
-int putdftext P((char const*,struct cbuf,RILE*,FILE*,int));
-int putdtext P((char const*,struct cbuf,char const*,FILE*,int));
-int str2expmode P((char const*));
-void getadmin P((void));
-void getdesc P((int));
-void gettree P((void));
-void ignorephrase P((void));
-void initdiffcmd P((struct diffcmd*));
-void putadmin P((FILE*));
-void putstring P((FILE*,int,struct cbuf,int));
-void puttree P((struct hshentry const*,FILE*));
-
-/* rcsutil */
-extern int RCSversion;
-char *cgetenv P((char const*));
-char *fstr_save P((char const*));
-char *str_save P((char const*));
-char const *date2str P((char const[datesize],char[datesize]));
-char const *getusername P((int));
-int getRCSINIT P((int,char**,char***));
-int run P((char const*,char const*,...));
-int runv P((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 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
-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_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
diff --git a/gnu/usr.bin/rcs/lib/rcsedit.c b/gnu/usr.bin/rcs/lib/rcsedit.c
deleted file mode 100644
index fab4f62..0000000
--- a/gnu/usr.bin/rcs/lib/rcsedit.c
+++ /dev/null
@@ -1,1656 +0,0 @@
-/*
- * RCS stream editor
- */
-/**********************************************************************************
- * edits the input file according to a
- * script from stdin, generated by diff -n
- * performs keyword expansion
- **********************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-/* $Log: rcsedit.c,v $
- * 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 5.11 1991/11/03 01:11:44 eggert Exp $")
-
-static void keyreplace P((enum markers,struct hshentry const*,FILE*));
-
-
-FILE *fcopy; /* result file descriptor */
-char const *resultfile; /* result file name */
-int locker_expansion; /* should the locker name be appended to Id val? */
-#if !large_memory
- static RILE *fedit; /* edit file descriptor */
- static char const *editfile; /* edit pathname */
-#endif
-static unsigned 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 */
-
-#define DIRTEMPNAMES 2
-enum maker {notmade, real, effective};
-struct buf dirtfname[DIRTEMPNAMES]; /* unlink these when done */
-static enum maker volatile dirtfmaker[DIRTEMPNAMES]; /* if these are set */
-
-
-#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
- int e;
- if (unlink(s) == 0)
- return 0;
- e = errno;
-# if has_NFS
- if (e == ENOENT)
- return 0;
-# endif
- 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(s, t)
- char const *s, *t;
-/* Link S to T, ignoring bogus EEXIST problems due to NFS failures. */
-{
- struct stat sb, tb;
-
- if (link(s,t) == 0)
- return 0;
- if (errno != EEXIST)
- return -1;
- if (
- stat(s, &sb) == 0 &&
- stat(t, &tb) == 0 &&
- sb.st_ino == tb.st_ino &&
- sb.st_dev == tb.st_dev
- )
- return 0;
- errno = EEXIST;
- return -1;
-}
-# endif
-#endif
-
-
- static exiting void
-editEndsPrematurely()
-{
- fatserror("edit script ends prematurely");
-}
-
- static exiting 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(s1, s2, n)
- register Iptr_type *s1;
- register Iptr_type const *s2;
- register unsigned long n;
-{
- if (s1 < s2)
- do {
- *s1++ = *s2++;
- } while (--n);
- else {
- s1 += n;
- s2 += n;
- do {
- *--s1 = *--s2;
- } while (--n);
- }
-}
-#endif
-
-/*
- * `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] contain 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 unsigned long gap, gapsize, linelim;
-
-
- static void
-insertline(n, l)
- unsigned 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)
- unsigned long n, nlines;
-/* Delete lines N through N+NLINES-1. N is 0-origin. */
-{
- unsigned 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;
-{
- Iseek(fin, l);
- if (expandline(fin, fout, delta, true, (FILE*)0) < 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 = Itell(fin);
- 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);
- Iseek(fin, here);
- }
- }
-}
-
-/* Open a temporary FILENAME for output, truncating any previous contents. */
-# define fopen_update_truncate(filename) fopen(filename, FOPEN_W_WORK)
-#else /* !large_memory */
- static FILE *
-fopen_update_truncate(filename)
- char const *filename;
-{
-# if bad_fopen_wplus
- if (un_link(filename) != 0)
- efaterror(filename);
-# endif
- return fopen(filename, FOPEN_WPLUS_WORK);
-}
-#endif
-
-
- void
-openfcopy(f)
- FILE *f;
-{
- if (!(fcopy = f)) {
- if (!resultfile)
- resultfile = maketemp(2);
- if (!(fcopy = fopen_update_truncate(resultfile)))
- efaterror(resultfile);
- }
-}
-
-
-#if !large_memory
-
- static void
-swapeditfiles(outfile)
- FILE *outfile;
-/* Function: swaps resultfile and editfile, assigns fedit=fcopy,
- * and rewinds fedit for reading. Set fcopy to outfile if nonnull;
- * otherwise, set fcopy to be resultfile opened for reading and writing.
- */
-{
- char const *tmpptr;
-
- editline = 0; linecorr = 0;
- if (fseek(fcopy, 0L, SEEK_SET) != 0)
- Oerror();
- fedit = fcopy;
- tmpptr=editfile; editfile=resultfile; resultfile=tmpptr;
- openfcopy(outfile);
-}
-
- void
-snapshotedit(f)
- FILE *f;
-/* Copy the current state of the edits to F. */
-{
- finishedit((struct hshentry *)nil, (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!=nil, 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!=nil) {
- while (1 < expandline(fe,fc,delta,false,(FILE*)0))
- ;
- } else {
- fastcopy(fe,fc);
- }
- Ifclose(fe);
- }
- if (!done)
- swapeditfiles(outfile);
-}
-#endif
-
-
-
-#if large_memory
-# define copylines(upto,delta) (editline = (upto))
-#else
- static void
-copylines(upto,delta)
- register unsigned long upto;
- struct hshentry const *delta;
-/*
- * Copy input lines editline+1..upto from fedit to fcopy.
- * If delta != nil, 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 *)nil, (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) <= 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))
- ;
-}
-
-
- 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
- editfile = 0;
- fedit = 0;
- editline = linecorr = 0;
- resultfile = maketemp(1);
- if (!(fcopy = fopen_update_truncate(resultfile)))
- efaterror(resultfile);
- copystring();
-#else
- register int c;
- declarecache;
- register FILE *frew;
- register unsigned 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 = cachetell();
- 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!=nil, keyword expansion is performed simultaneously.
- * If running out of lines in fedit, fedit and fcopy are swapped.
- * editfile 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.
- * resultfile 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;
- unsigned long line_lim = ULONG_MAX;
- register RILE *fe;
-# endif
- register unsigned long i;
- register RILE *fin;
-# if large_memory
- register unsigned 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 {
- copylines(dc.line1, delta); /*copy only; no delete*/
- 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)) {
- 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++, cachetell());
-# endif
- for (;;) {
- GETC(frew, c);
-# if !large_memory
- aputc(c, f);
-# endif
- if (c == '\n')
- break;
- if (c==SDELIM) {
- GETC(frew, c);
- if (c!=SDELIM) {
- if (--i)
- editEndsPrematurely();
- nextc = c;
- uncache(fin);
- return;
- }
- }
- }
- ++rcsline;
- } while (--i);
- uncache(fin);
- }
- }
-}
-
-
-
-/* The rest is for keyword expansion */
-
-
-
- int
-expandline(infile, outfile, delta, delimstuffed, frewfile)
- RILE *infile;
- FILE *outfile, *frewfile;
- struct hshentry const *delta;
- int delimstuffed;
-/*
- * Read a line from INFILE and write it to OUTFILE.
- * If DELIMSTUFFED is true, double SDELIM is replaced with single SDELIM.
- * Keyword expansion is performed with data from delta.
- * If FREWFILE is set, copy the line unchanged to FREWFILE.
- * DELIMSTUFFED must be true if FREWFILE 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+1)
- 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 */
- keyreplace(matchresult,delta,out);
- e = 1;
- break;
- }
- break;
- }
- }
-
- keystring_eof:
- *tp = 0;
- aputs(keyval.string, out);
- uncache_exit:
- uncache(infile);
- return r + e;
-}
-
-
-char const ciklog[ciklogsize] = "checked in with -k by ";
-
- static void
-keyreplace(marker,delta,out)
- enum markers marker;
- register struct hshentry const *delta;
- register FILE *out;
-/* function: outputs the keyword value(s) corresponding to marker.
- * Attributes are derived from delta.
- */
-{
- register char const *sp, *cp, *date;
- register char c;
- register size_t cs, cw, ls;
- char const *sp1;
- char datebuf[datesize];
- int RCSv;
-
- sp = Keyword[(int)marker];
-
- if (Expand == KEY_EXPAND) {
- aprintf(out, "%c%s%c", KDELIM, sp, KDELIM);
- return;
- }
-
- date= delta->date;
- RCSv = RCSversion;
-
- if (Expand == KEYVAL_EXPAND || Expand == KEYVALLOCK_EXPAND)
- aprintf(out, "%c%s%c%c", KDELIM, sp, 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 Header:
- aprintf(out, "%s %s %s %s %s",
- marker==Id || RCSv<VERSION(4)
- ? basename(RCSfilename)
- : getfullRCSname(),
- delta->num,
- date2str(date, datebuf),
- delta->author,
- RCSv==VERSION(3) && delta->lockedby ? "Locked"
- : delta->state
- );
- if (delta->lockedby!=nil)
- if (VERSION(5) <= RCSv) {
- if (locker_expansion || Expand==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
- || Expand == KEYVALLOCK_EXPAND
- || RCSv <= VERSION(4)
- )
- aputs(delta->lockedby, out);
- break;
- case Log:
- case RCSfile:
- aputs(basename(RCSfilename), out);
- break;
- case Revision:
- aputs(delta->num, out);
- break;
- case Source:
- aputs(getfullRCSname(), out);
- break;
- case State:
- aputs(delta->state, out);
- break;
- default:
- break;
- }
- if (Expand == KEYVAL_EXPAND || Expand == KEYVALLOCK_EXPAND) {
- afputc(' ', out);
- afputc(KDELIM, out);
- }
- if (marker == Log) {
- sp = delta->log.string;
- ls = delta->log.size;
- if (sizeof(ciklog)-1<=ls && !memcmp(sp,ciklog,sizeof(ciklog)-1))
- return;
- afputc('\n', out);
- cp = Comment.string;
- cw = cs = Comment.size;
- awrite(cp, cs, out);
- /* oddity: 2 spaces between date and time, not 1 as usual */
- sp1 = strchr(date2str(date,datebuf), ' ');
- 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. */
- /* Comment is the comment leader. */
- if (VERSION(5) <= RCSv)
- for (; cw && (cp[cw-1]==' ' || cp[cw-1]=='\t'); --cw)
- ;
- 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');
- }
- }
- }
-}
-
-#if has_readlink
- 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;
- unsigned linkcount = MAXSYMLINKS + 1;
-
- 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) {
- errno = ELOOP;
- return -1;
- } else {
- /* Splice symbolic link into L. */
- b[r] = '\0';
- L->string[ROOTPATH(b) ? (size_t)0 : dirlen(L->string)] = '\0';
- bufscat(L, b);
- }
- e = errno;
- bufautoend(&bigbuf);
- errno = e;
- switch (e) {
- case ENXIO:
- case EINVAL: 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 RCSNAME.
- * Then try to open RCSNAME for reading and yield its FILE* 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 frewrite to the FILE* descriptor of the lock file,
- * which will eventually turn into the new RCS file.
- */
-{
- register char *tp;
- register char const *sp, *RCSname, *x;
- RILE *f;
- size_t l;
- int e, exists, fdesc, previouslock, r;
- struct buf *dirt;
- struct stat statbuf;
-
- previouslock = frewrite != 0;
- exists =
-# if has_readlink
- resolve_symlink(RCSbuf);
-# else
- stat(RCSbuf->string, &statbuf) == 0 ? 1
- : errno==ENOENT ? 0 : -1;
-# endif
- if (exists < (mustread|previouslock))
- /*
- * 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;
-
- RCSname = RCSbuf->string;
- sp = basename(RCSname);
- l = sp - RCSname;
- dirt = &dirtfname[previouslock];
- bufscpy(dirt, RCSname);
- tp = dirt->string + l;
- x = rcssuffix(RCSname);
-# if has_readlink
- if (!x) {
- error("symbolic link to non RCS filename `%s'", RCSname);
- errno = EINVAL;
- return 0;
- }
-# endif
- if (*sp == *x) {
- error("RCS filename `%s' incompatible with suffix `%s'", sp, x);
- errno = EINVAL;
- return 0;
- }
- /* Create a lock file whose name 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++))
- ;
- tp -= 2;
- if (*tp == '_') {
- error("RCS filename `%s' ends with `%c'", RCSname, *tp);
- errno = EINVAL;
- return 0;
- }
- *tp = '_';
- }
-
- sp = tp = dirt->string;
-
- f = 0;
-
- /*
- * good news:
- * open(f, O_CREAT|O_EXCL|O_TRUNC|O_WRONLY, 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,READONLY) normally guarantees atomicity even with NFS.
- * bad news:
- * If you're root, (O_TRUNC,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.
- * Suppose client A renames the lock file ",f," to "f,v"
- * at about the same time that client B creates ",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 programs that use the traditional
- * Unix method of using link() and unlink() to get and release locks,
- * as well as RCS's method of using open() and rename().
- * There is no easy workaround for either link-unlink or open-rename.
- * 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.
- */
-# define READONLY (S_IRUSR|S_IRGRP|S_IROTH)
-# if !open_can_creat
-# define create(f) creat(f, READONLY)
-# else
-# define create(f) open(f, O_BINARY|O_CREAT|O_EXCL|O_TRUNC|O_WRONLY, 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);
- e = errno;
- setrid();
-
- if (fdesc < 0) {
- if (e == EACCES && stat(tp,&statbuf) == 0)
- /* The RCS file is busy. */
- e = EEXIST;
- } else {
- dirtfmaker[0] = effective;
- e = ENOENT;
- if (exists) {
- f = Iopen(RCSname, FOPEN_R, status);
- e = errno;
- if (f && previouslock) {
- /* Discard the previous lock in favor of this one. */
- Ozclose(&frewrite);
- seteid();
- if ((r = un_link(newRCSfilename)) != 0)
- e = errno;
- setrid();
- if (r != 0)
- enfaterror(e, newRCSfilename);
- bufscpy(&dirtfname[0], tp);
- }
- }
- if (!(frewrite = fdopen(fdesc, FOPEN_W))) {
- efaterror(newRCSfilename);
- }
- }
-
- 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 (dirtfname[i].string == name) {
- dirtfmaker[i] = notmade;
- return;
- }
- faterror("keepdirtemp");
-}
-
- char const *
-makedirtemp(name, n)
- register char const *name;
- int n;
-/*
- * Have maketemp() do all the work if name is null.
- * Otherwise, create a unique filename in name's dir using n and name
- * and store it into the dirtfname[n].
- * Because of storage in tfnames, dirtempunlink() can unlink the file later.
- * Return a pointer to the filename created.
- */
-{
- register char *tp, *np;
- register size_t dl;
- register struct buf *bn;
-
- if (!name)
- return maketemp(n);
- dl = dirlen(name);
- bn = &dirtfname[n];
- bufalloc(bn,
-# if has_mktemp
- dl + 9
-# else
- strlen(name) + 3
-# endif
- );
- bufscpy(bn, name);
- np = tp = bn->string;
- tp += dl;
- *tp++ = '_';
- *tp++ = '0'+n;
- catchints();
-# if has_mktemp
- VOID strcpy(tp, "XXXXXX");
- if (!mktemp(np) || !*np)
- faterror("can't make temporary file name `%.*s%c_%cXXXXXX'",
- (int)dl, name, SLASH, '0'+n
- );
-# else
- /*
- * Posix 1003.1-1990 has no reliable way
- * to create a unique file in a named directory.
- * We fudge here. If the working file name 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
- dirtfmaker[n] = 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 = dirtfmaker[i]) != notmade) {
- if (m == effective)
- seteid();
- VOID un_link(dirtfname[i].string);
- if (m == effective)
- setrid();
- dirtfmaker[i] = notmade;
- }
-}
-
-
- int
-#if has_prototypes
-chnamemod(FILE **fromp, char const *from, char const *to, mode_t mode)
- /* The `#if has_prototypes' is needed because mode_t might promote to int. */
-#else
- chnamemod(fromp,from,to,mode) FILE **fromp; char const *from,*to; mode_t mode;
-#endif
-/*
- * Rename a file (with optional stream pointer *FROMP) from FROM to TO.
- * FROM already exists.
- * Change its mode to MODE, before renaming if possible.
- * If FROMP, close and clear *FROMP before renaming it.
- * Unlink TO if it already exists.
- * Return -1 on error (setting errno), 0 otherwise.
- */
-{
-# if bad_a_rename
- /*
- * This host is brain damaged. A race condition is possible
- * while the lock file is temporarily writable.
- * There doesn't seem to be a workaround.
- */
- mode_t mode_while_renaming = mode|S_IWUSR;
-# else
-# define mode_while_renaming mode
-# endif
- if (fromp) {
-# if has_fchmod
- if (fchmod(fileno(*fromp), mode_while_renaming) != 0)
- return -1;
-# endif
- Ozclose(fromp);
- }
-# if has_fchmod
- else
-# endif
- if (chmod(from, mode_while_renaming) != 0)
- return -1;
-
-# if !has_rename || bad_b_rename
- VOID un_link(to);
- /*
- * We need not check the result;
- * link() or rename() will catch it.
- * No harm is done if TO does not exist.
- * However, there's a short window of inconsistency
- * during which TO does not exist.
- */
-# endif
-
- return
-# if !has_rename
- do_link(from,to) != 0 ? -1 : un_link(from)
-# else
- rename(from, to) != 0
-# if has_NFS
- && errno != ENOENT
-# endif
- ? -1
-# if bad_a_rename
- : mode != mode_while_renaming ? chmod(to, mode)
-# endif
- : 0
-# endif
- ;
-
-# undef mode_while_renaming
-}
-
-
-
- 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 lock *next, **trail, **found;
-
- found = 0;
- for (trail = &Locks; (next = *trail); trail = &next->nextlock)
- if (strcmp(getcaller(), next->login) == 0) {
- if (found) {
- error("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 = nil;
- *found = next->nextlock;
- }
- return 1;
-}
-
- int
-addlock(delta)
- struct hshentry * delta;
-/*
- * Add a lock held by caller to DELTA and yield 1 if successful.
- * Print an error message 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 lock *next;
-
- next=Locks;
- for (next = Locks; next; next = next->nextlock)
- if (cmpnum(delta->num, next->delta->num) == 0)
- if (strcmp(getcaller(), next->login) == 0)
- return 0;
- else {
- error("revision %s already locked by %s",
- delta->num, next->login
- );
- return -1;
- }
- next = ftalloc(struct lock);
- 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 true if successful.
- */
-{
- register struct assoc *next;
-
- for (next = Symbols; next; next = next->nextassoc)
- if (strcmp(name, next->symbol) == 0)
- if (rebind || strcmp(next->num,num) == 0) {
- next->num = num;
- return true;
- } else {
- error("symbolic name %s already bound to %s",
- name, next->num
- );
- return false;
- }
- next = ftalloc(struct assoc);
- next->symbol = name;
- next->num = num;
- next->nextassoc = Symbols;
- Symbols = next;
- return true;
-}
-
-
-
- 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));
-
- error("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 true on success.
- */
-{
- int r, e;
-
- if (lockflag)
- if (changed) {
- if (changed < 0)
- return false;
- putadmin(frewrite);
- puttree(Head, frewrite);
- aprintf(frewrite, "\n\n%s%c", Kdesc, nextc);
- foutptr = frewrite;
- } else {
- Ozclose(&frewrite);
- seteid();
- ignoreints();
- r = un_link(newRCSfilename);
- e = errno;
- keepdirtemp(newRCSfilename);
- restoreints();
- setrid();
- if (r != 0) {
- enerror(e, RCSfilename);
- return false;
- }
- }
- return true;
-}
-
- int
-donerewrite(changed)
- int changed;
-/*
- * Finish rewriting an RCS file if CHANGED is nonzero.
- * Return true on success.
- */
-{
- int r, e;
-
- if (changed && !nerror) {
- if (finptr) {
- fastcopy(finptr, frewrite);
- Izclose(&finptr);
- }
- if (1 < RCSstat.st_nlink)
- warn("breaking hard link to %s", RCSfilename);
- seteid();
- ignoreints();
- r = chnamemod(&frewrite, newRCSfilename, RCSfilename,
- RCSstat.st_mode & ~(S_IWUSR|S_IWGRP|S_IWOTH)
- );
- e = errno;
- keepdirtemp(newRCSfilename);
- restoreints();
- setrid();
- if (r != 0) {
- enerror(e, RCSfilename);
- error("saved in %s", newRCSfilename);
- dirtempunlink();
- return false;
- }
- }
- return true;
-}
-
- void
-aflush(f)
- FILE *f;
-{
- if (fflush(f) != 0)
- Oerror();
-}
diff --git a/gnu/usr.bin/rcs/lib/rcsfcmp.c b/gnu/usr.bin/rcs/lib/rcsfcmp.c
deleted file mode 100644
index 75a6bbc..0000000
--- a/gnu/usr.bin/rcs/lib/rcsfcmp.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * RCS file comparison
- */
-/*****************************************************************************
- * rcsfcmp()
- * Testprogram: define FCMPTEST
- *****************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-
-/* $Log: rcsfcmp.c,v $
- * 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: rcsfcmp.c,v 5.9 1991/10/07 17:32:46 eggert Exp $")
-
- 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, ufname, delta)
- register RILE *xfp;
- struct stat const *xstatp;
- char const *ufname;
- struct hshentry const *delta;
-/* Compare the files xfp and ufname. Return zero
- * if xfp has the same contents as ufname 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 ufname, 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;
- int result;
- enum markers match1;
- struct stat ustat;
-
- if (!(ufp = Iopen(ufname, FOPEN_R_WORK, &ustat))) {
- efaterror(ufname);
- }
- xeof = ueof = false;
- if (Expand==OLD_EXPAND) {
- if (!(result = xstatp->st_size!=ustat.st_size)) {
-# if has_mmap && large_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. */
- 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 */
- unsigned 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. */
- lncnt = 3;
- while (ls--) if (*sp++=='\n') lncnt++;
- 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....$) */
- for (ccnt=Comment.size; ccnt--; ) {
- Igeteof(xfp, xc, goto returnresult;);
- if(xc=='\n') break;
- /*
- * Read to the end of the comment leader or '\n',
- * whatever comes first. Some editors strip
- * trailing white space from a leader like " * ".
- */
- }
- }
- }
- } 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;
- }
- }
-
- 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 02562f0..0000000
--- a/gnu/usr.bin/rcs/lib/rcsfnms.c
+++ /dev/null
@@ -1,1088 +0,0 @@
-/*
- * RCS file name handling
- */
-/****************************************************************************
- * creation and deletion of /tmp temporaries
- * pairing of RCS file names and working file names.
- * Testprogram: define PAIRTEST
- ****************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/* $Log: rcsfnms.c,v $
- * 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 file name extensions.
- * Permit paths of arbitrary length. Beware file names 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 file names to pairfilenames().
- *
- * Revision 4.2 83/12/02 22:47:45 wft
- * Added csh, red, and sl file name 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 file name 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 file names.
- * 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 5.8 1991/09/24 00:28:40 eggert Exp $")
-
-char const *RCSfilename;
-char *workfilename;
-FILE *workstdout;
-struct stat RCSstat;
-char const *suffixes;
-
-static char const rcsdir[] = "RCS";
-#define rcsdirlen (sizeof(rcsdir)-1)
-
-static struct buf RCSbuf, RCSb;
-static int RCSerrno;
-
-
-/* Temp file names to be unlinked when done, if they are not nil. */
-#define TEMPNAMES 5 /* must be at least DIRTEMPNAMES (see rcsedit.c) */
-static char *volatile tfnames[TEMPNAMES];
-
-
-struct compair {
- char const *suffix, *comlead;
-};
-
-static struct compair const comtable[] = {
-/* comtable pairs each filename suffix with a comment leader. The comment */
-/* leader is placed before each line generated by the $Log keyword. This */
-/* table is used to guess the proper comment leader from the working file's */
-/* suffix during initial ci (see InitAdmin()). Comment leaders are needed */
-/* for languages without multiline comments; for others they are optional. */
- "a", "-- ", /* Ada */
- "ada", "-- ",
- "asm", ";; ", /* assembler (MS-DOS) */
- "bat", ":: ", /* batch (MS-DOS) */
- "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: conflict between lex and franzlisp */
- "lisp",";;; ", /* Lucid Lisp */
- "lsp", ";; ", /* Microsoft Lisp */
- "mac", ";; ", /* macro (DEC-10, MS-DOS, PDP-11, VMS, etc) */
- "me", ".\\\" ",/* me-macros t/nroff*/
- "ml", "; ", /* mocklisp */
- "mm", ".\\\" ",/* mm-macros t/nroff*/
- "ms", ".\\\" ",/* ms-macros t/nroff*/
- "p", " * ", /* Pascal */
- "pas", " * ",
- "pl", "% ", /* Prolog */
- "tex", "% ", /* TeX */
- "y", " * ", /* yacc */
- nil, "# " /* default for unknown suffix; must always be last */
-};
-
-#if has_mktemp
- 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 filename using n and the process id and store it
- * into the nth slot in tfnames.
- * Because of storage in tfnames, tempunlink() can unlink the file later.
- * Returns a pointer to the filename created.
- */
-{
- char *p;
- char const *t = tfnames[n];
-
- if (t)
- return t;
-
- catchints();
- {
-# if has_mktemp
- char const *tp = tmp();
- p = testalloc(strlen(tp) + 10);
- VOID sprintf(p, "%s%cT%cXXXXXX", tp, SLASH, '0'+n);
- if (!mktemp(p) || !*p)
- faterror("can't make temporary file name `%s%cT%cXXXXXX'",
- tp, SLASH, '0'+n
- );
-# else
- static char tfnamebuf[TEMPNAMES][L_tmpnam];
- p = tfnamebuf[n];
- if (!tmpnam(p) || !*p)
-# ifdef P_tmpdir
- faterror("can't make temporary file name `%s...'",P_tmpdir);
-# else
- faterror("can't make temporary file name");
-# endif
-# endif
- }
-
- tfnames[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 = tfnames[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.
- */
- tfnames[i] = 0;
- }
-}
-
-
- static char const *
-bindex(sp,ch)
- register char const *sp;
- int ch;
-/* 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 c=ch, *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=nil; Dbranch=nil; AccessList=nil; Symbols=nil; Locks=nil;
- StrictLocks=STRICT_LOCKING;
-
- /* guess the comment leader from the suffix*/
- Suffix=bindex(workfilename, '.');
- if (Suffix==workfilename) Suffix= ""; /* empty suffix; will get default*/
- for (i=0; !suffix_matches(Suffix,comtable[i].suffix); i++)
- ;
- Comment.string = comtable[i].comlead;
- Comment.size = strlen(comtable[i].comlead);
- Lexinit(); /* note: if !finptr, reads nothing; only initializes */
-}
-
-
-/* 'cpp' does not like this line. It seems to be the leading '_' in the */
-/* second occurence of '_POSIX_NO_TRUNC'. It evaluates correctly with */
-/* just the first term so lets just do that for now. */
-/*#if defined(_POSIX_NO_TRUNC) && _POSIX_NO_TRUNC!=-1*/
-#if defined(_POSIX_NO_TRUNC)
-# define LONG_NAMES_MAY_BE_SILENTLY_TRUNCATED 0
-#else
-# define LONG_NAMES_MAY_BE_SILENTLY_TRUNCATED 1
-#endif
-
-#if LONG_NAMES_MAY_BE_SILENTLY_TRUNCATED
-#ifdef NAME_MAX
-# define filenametoolong(path) (NAME_MAX < strlen(basename(path)))
-#else
- static int
-filenametoolong(path)
- char *path;
-/* Yield true if the last file name in PATH is too long. */
-{
- static unsigned long dot_namemax;
-
- register size_t namelen;
- register char *base;
- register unsigned long namemax;
-
- base = path + dirlen(path);
- namelen = strlen(base);
- if (namelen <= _POSIX_NAME_MAX) /* fast check for shorties */
- return false;
- if (base != path) {
- *--base = 0;
- namemax = pathconf(path, _PC_NAME_MAX);
- *base = SLASH;
- } else {
- /* Cache the results for the working directory, for speed. */
- if (!dot_namemax)
- dot_namemax = pathconf(".", _PC_NAME_MAX);
- namemax = dot_namemax;
- }
- /* If pathconf() yielded -1, namemax is now ULONG_MAX. */
- return namemax<namelen;
-}
-#endif
-#endif
-
- 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)
- ;
- 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 *
-basename(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;
- }
-}
-
- size_t
-dirlen(p)
- char const *p;
-/* Yield the length of P's directory, including its trailing SLASH. */
-{
- return basename(p) - p;
-}
-
-
- static size_t
-suffixlen(x)
- char const *x;
-/* Yield the length of X, an RCS filename 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 filename, 0 otherwise. */
-{
- char const *x, *p, *nz;
- size_t dl, 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 {
- dl = dirlen(name);
- if (
- rcsdirlen < dl &&
- !memcmp(p = name+(dl-=rcsdirlen+1), rcsdir, rcsdirlen) &&
- (!dl || isSLASH(*--p))
- )
- return nz;
- }
- x += xl;
- } while (*x++);
- return 0;
-}
-
- /*ARGSUSED*/ RILE *
-rcsreadopen(RCSname, status, mustread)
- struct buf *RCSname;
- struct stat *status;
- int mustread;
-/* Open RCSNAME for reading and yield its FILE* descriptor.
- * If successful, set *STATUS to its status.
- * Pass this routine to pairfilenames() for read-only access to the file. */
-{
- return Iopen(RCSname->string, FOPEN_R, 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||frewrite);
-
- 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 filename 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 + rcsdirlen + 1 + baselen + xlen + 1);
-
- /* Try dRCS/basex. */
- VOID memcpy(p = RCSb.string, d, dlen);
- VOID memcpy(p += dlen, rcsdir, rcsdirlen);
- p += rcsdirlen;
- *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
-pairfilenames(argc, argv, rcsopen, mustread, quiet)
- int argc;
- char **argv;
- RILE *(*rcsopen)P((struct buf*,struct stat*,int));
- int mustread, quiet;
-/* Function: Pairs the filenames pointed to by argv; argc indicates
- * how many there are.
- * Places a pointer to the RCS filename into RCSfilename,
- * and a pointer to the name of the working file into workfilename.
- * If both the workfilename and the RCS filename 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 *purefname, *pureRCSname, *x;
- int paired;
- size_t arglen, dlen, baselen, xlen;
-
- if (!(arg = *argv)) return 0; /* already paired filename */
- if (*arg == '-') {
- error("%s option is ignored after file names", arg);
- return 0;
- }
-
- purefname = basename(arg);
-
- /* Allocate buffer temporary to hold the default paired file name. */
- p = arg;
- for (;;) {
- switch (*p++) {
- /* Beware characters that cause havoc with ci -k. */
- case KDELIM:
- error("RCS file name `%s' contains %c", arg, KDELIM);
- return 0;
- case ' ': case '\n': case '\t':
- error("RCS file name `%s' contains white space", arg);
- return 0;
- default:
- continue;
- case 0:
- break;
- }
- break;
- }
-
- paired = false;
-
- /* first check suffix to see whether it is an RCS file or not */
- if ((x = rcssuffix(arg)))
- {
- /* RCS file name given*/
- RCS1 = arg;
- pureRCSname = purefname;
- baselen = x - purefname;
- if (
- 1 < argc &&
- !rcssuffix(workfilename = p = argv[1]) &&
- baselen <= (arglen = strlen(p)) &&
- ((p+=arglen-baselen) == workfilename || isSLASH(p[-1])) &&
- memcmp(purefname, p, baselen) == 0
- ) {
- argv[1] = 0;
- paired = true;
- } else {
- bufscpy(&tempbuf, purefname);
- workfilename = p = tempbuf.string;
- p[baselen] = 0;
- }
- } else {
- /* working file given; now try to find RCS file */
- workfilename = arg;
- baselen = p - purefname - 1;
- /* derive RCS file name*/
- if (
- 1 < argc &&
- (x = rcssuffix(RCS1 = argv[1])) &&
- baselen <= x - RCS1 &&
- ((pureRCSname=x-baselen)==RCS1 || isSLASH(pureRCSname[-1])) &&
- memcmp(purefname, pureRCSname, baselen) == 0
- ) {
- argv[1] = 0;
- paired = true;
- } else
- pureRCSname = RCS1 = 0;
- }
- /* now we have a (tentative) RCS filename in RCS1 and workfilename */
- /* Second, try to find the right RCS file */
- if (pureRCSname!=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 file name was given without path. */
- VOID fin2open(arg, (size_t)0, pureRCSname, baselen,
- x, strlen(x), rcsopen, mustread
- );
- else {
- /* No RCS file name was given. */
- /* Try each suffix in turn. */
- dlen = purefname-arg;
- x = suffixes;
- while (! fin2open(arg, dlen, purefname, baselen,
- x, xlen=suffixlen(x), rcsopen, mustread
- )) {
- x += xlen;
- if (!*x++)
- break;
- }
- }
- }
- RCSfilename = 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 || !frewrite) {
- if (RCSerrno == EEXIST)
- error("RCS file %s is in use", p);
- else if (!quiet || RCSerrno!=ENOENT)
- enerror(RCSerrno, p);
- return 0;
- }
- InitAdmin();
- };
-# if LONG_NAMES_MAY_BE_SILENTLY_TRUNCATED
- if (filenametoolong(p)) {
- error("RCS file name %s is too long", p);
- return 0;
- }
-# ifndef NAME_MAX
- /*
- * Check workfilename too, even though it cannot be longer,
- * because it may reside on a different filesystem.
- */
- if (filenametoolong(workfilename)) {
- error("working file name %s is too long", workfilename);
- return 0;
- }
-# endif
-# endif
-
- if (paired && workstdout)
- warn("Option -p is set; ignoring output file %s",workfilename);
-
- prevkeys = false;
- return finptr ? 1 : -1;
-}
-
-
- char const *
-getfullRCSname()
-/* Function: returns a pointer to the full path name of the RCS file.
- * Gets the working directory's name at most once.
- * Removes leading "../" and "./".
- */
-{
- static char const *wdptr;
- static struct buf rcsbuf, wdbuf;
- static size_t pathlength;
-
- register char const *realname;
- register size_t parentdirlength;
- register unsigned dotdotcounter;
- register char *d;
- register char const *wd;
-
- if (ROOTPATH(RCSfilename)) {
- return(RCSfilename);
- } else {
- if (!(wd = wdptr)) {
- /* Get working directory for the first time. */
- if (!(d = cgetenv("PWD"))) {
- bufalloc(&wdbuf, SIZEABLE_PATH + 1);
-# if !has_getcwd && has_getwd
- d = getwd(wdbuf.string);
-# else
- while (
- !(d = getcwd(wdbuf.string, wdbuf.size))
- && errno==ERANGE
- )
- bufalloc(&wdbuf, wdbuf.size<<1);
-# endif
- if (!d)
- efaterror("working directory");
- }
- parentdirlength = strlen(d);
- while (parentdirlength && isSLASH(d[parentdirlength-1])) {
- d[--parentdirlength] = 0;
- /* Check needed because some getwd implementations */
- /* generate "/" for the root. */
- }
- wdptr = wd = d;
- pathlength = parentdirlength;
- }
- /*the following must be redone since RCSfilename may change*/
- /* Find how many `../'s to remove from RCSfilename. */
- dotdotcounter =0;
- realname = RCSfilename;
- while (realname[0]=='.') {
- if (isSLASH(realname[1])) {
- /* drop leading ./ */
- realname += 2;
- } else if (realname[1]=='.' && isSLASH(realname[2])) {
- /* drop leading ../ and remember */
- dotdotcounter++;
- realname += 3;
- } else
- break;
- }
- /* Now remove dotdotcounter trailing directories from wd. */
- parentdirlength = pathlength;
- while (dotdotcounter && parentdirlength) {
- /* move pointer backwards over trailing directory */
- if (isSLASH(wd[--parentdirlength])) {
- dotdotcounter--;
- }
- }
- /* build full path name */
- bufalloc(&rcsbuf, parentdirlength+strlen(realname)+2);
- d = rcsbuf.string;
- VOID memcpy(d, wd, parentdirlength);
- d += parentdirlength;
- *d++ = SLASH;
- VOID strcpy(d, realname);
- return rcsbuf.string;
- }
-}
-
-#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 !has_waitpid
- pid_t w;
-# endif
-
- if (!size) {
- errno = EINVAL;
- return 0;
- }
- if (pipe(fd) != 0)
- return 0;
- 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
- 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 pairfilenames() 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 {
- RCSfilename=workfilename=nil;
- result = pairfilenames(argc,argv,rcsreadopen,!initflag,quietflag);
- if (result!=0) {
- diagnose("RCS file: %s; working file: %s\nFull RCS file name: %s\n",
- RCSfilename,workfilename,getfullRCSname()
- );
- }
- switch (result) {
- case 0: continue; /* already paired file */
-
- case 1: if (initflag) {
- error("RCS file %s exists already",RCSfilename);
- } else {
- diagnose("RCS file %s exists\n",RCSfilename);
- }
- Ifclose(finptr);
- break;
-
- case -1:diagnose("RCS file doesn't exist\n");
- break;
- }
-
- } while (++argv, --argc>=1);
-
-}
-
- exiting 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 9a6072e..0000000
--- a/gnu/usr.bin/rcs/lib/rcsgen.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * RCS revision generation
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-/* $Log: rcsgen.c,v $
- * 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: rcsgen.c,v 5.10 1991/10/07 17:32:46 eggert Exp $")
-
-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 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 nil 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 (resultfile and
- * editfile). 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(resultfile);
- }
- } 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 *)nil, outfile, false);
- }
- scandeltatext(deltas->first, expandflag?edit_expand:edit, true);
- finishedit(
- expandflag ? deltas->first : (struct hshentry*)nil,
- outfile, true
- );
- if (outfile)
- return 0;
- Ozclose(&fcopy);
- return resultfile;
- }
-}
-
-
-
- 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.
- * 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);
- } else {readstring();
- }
- nextlex();
- while (nexttok==ID && strcmp(NextString,Ktext)!=0)
- ignorephrase();
- 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 *)nil); 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 < 0) {
- 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 the textfile!=nil, the text is read from that
- * file, or from stdin, if textfile==nil.
- * A textfile with a leading '-' is treated as a string, not a file name.
- * 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 = fopen(textfile, "r")))
- efaterror(textfile);
- bufalloc(&desc, 1);
- p = desc.string;
- plim = p + desc.size;
- for (;;) {
- if ((c=getc(txt)) < 0) {
- 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
- );
- else if (feof(stdin))
- faterror("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);
- return cleanlogmsg(p, i);
-}
diff --git a/gnu/usr.bin/rcs/lib/rcskeep.c b/gnu/usr.bin/rcs/lib/rcskeep.c
deleted file mode 100644
index 1a0c78f..0000000
--- a/gnu/usr.bin/rcs/lib/rcskeep.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * RCS keyword extraction
- */
-/*****************************************************************************
- * main routine: getoldkeys()
- * Testprogram: define KEEPTEST
- *****************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-/* $Log: rcskeep.c,v $
- * 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.
- *
- */
-
-/*
-#define KEEPTEST
-*/
-/* Testprogram; prints out the keyword values found. */
-
-#include "rcsbase.h"
-
-libId(keepId, "$Id: rcskeep.c,v 5.4 1991/08/19 03:13:55 eggert Exp $")
-
-static int checknum P((char const*,int));
-static int getval P((RILE*,struct buf*,int));
-static int get0val P((int,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, 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 FNAME is nonnull, it is opened and closed instead of using FP.
- * The results are placed into
- * prevauthor, prevdate, 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;
-
- if (prevkeys)
- return true;
-
- needs_closing = false;
- if (!fp) {
- if (!(fp = Iopen(workfilename, FOPEN_R_WORK, (struct stat*)0))) {
- eerror(workfilename);
- return false;
- }
- needs_closing = true;
- }
-
- /* initialize to empty */
- bufscpy(&prevauthor, "");
- bufscpy(&prevdate, "");
- 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:
- if (!(
- getval(fp, (struct buf*)nil, 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*)nil, true) &&
- getval(fp, (struct buf*)nil, true))
- c = 0;
- else if (nerror)
- return false;
- else
- c = KDELIM;
- break;
- case Locker:
- case Log:
- case RCSfile:
- case Source:
- if (!getval(fp, (struct buf*)nil, false))
- return false;
- 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) {
- error("closing %c missing on keyword", KDELIM);
- return false;
- }
- if (*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()
-{
- error("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 nil.
- * 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
- }
- if (!got1)
- error("too much white space in keyword value");
- 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, prevzone;
- register char const *p;
- register int c;
-
- c = 0;
- bufautobegin(&prevday);
- if (getval(fp,&prevday,false)) {
- bufautobegin(&prevtime);
- if (getval(fp,&prevtime,false)) {
- bufautobegin(&prevzone);
- bufscpy(&prevzone, "");
- Igeteof(fp, c, c=0;);
- if (c=='-' || c=='+')
- if (!get0val(c,fp,&prevzone,false))
- c = 0;
- else
- Igeteof(fp, c, c=0;);
- if (c) {
- p = prevday.string;
- bufalloc(&prevdate, strlen(p) + strlen(prevtime.string) + strlen(prevzone.string) + 5);
- VOID sprintf(prevdate.string, "%s%s %s %s",
- /* Parse dates put out by old versions of RCS. */
- isdigit(p[0]) && isdigit(p[1]) && p[2]=='/' ? "19" : "",
- p, prevtime.string, prevzone.string
- );
- }
- bufautoend(&prevzone);
- }
- 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 true;
-}
-
- static int
-keeprev(fp)
- RILE *fp;
-/* Get previous revision from FP into prevrev. */
-{
- return getval(fp,&prevrev,false) && checknum(prevrev.string,-1);
-}
-
-
- static int
-checknum(sp,fields)
- register char const *sp;
- int fields;
-{ register int dotcount;
- dotcount=0;
- while(*sp) {
- if (*sp=='.') dotcount++;
- else if (!isdigit(*sp)) return false;
- sp++;
- }
- return fields<0 ? dotcount&1 : dotcount==fields;
-}
-
-
-
-#ifdef KEEPTEST
-
-char const cmdid[] ="keeptest";
-
- int
-main(argc, argv)
-int argc; char *argv[];
-{
- while (*(++argv)) {
- workfilename = *argv;
- getoldkeys((RILE*)0);
- VOID printf("%s: revision: %s, date: %s, author: %s, state: %s\n",
- *argv, prevrev.string, prevdate.string, prevauthor.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 82850a7..0000000
--- a/gnu/usr.bin/rcs/lib/rcskeys.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * RCS keyword table and match operation
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-/* $Log: rcskeys.c,v $
- * 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 5.2 1991/08/19 03:13:55 eggert Exp $")
-
-
-char const *const Keyword[] = {
- /* This must be in the same order as rcsbase.h's enum markers type. */
- nil,
- AUTHOR, DATE, HEADER, IDH,
- LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE
-};
-
-
-
- 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); ) {
- /* try next keyword */
- p = Keyword[j];
- s = string;
- while (*p++ == *s++) {
- if (!*p)
- switch (*s) {
- case KDELIM:
- case VDELIM:
- return (enum markers)j;
- default:
- return Nomatch;
- }
- }
- }
- return(Nomatch);
-}
-
diff --git a/gnu/usr.bin/rcs/lib/rcslex.c b/gnu/usr.bin/rcs/lib/rcslex.c
deleted file mode 100644
index cedbc40..0000000
--- a/gnu/usr.bin/rcs/lib/rcslex.c
+++ /dev/null
@@ -1,1250 +0,0 @@
-/*
- * RCS file input
- */
-/*********************************************************************************
- * Lexical Analysis.
- * hashtable, Lexinit, nextlex, getlex, getkey,
- * getid, getnum, readstring, printstring, savestring,
- * checkid, fatserror, error, faterror, warn, diagnose
- * Testprogram: define LEXDB
- *********************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-/* $Log: rcslex.c,v $
- * Revision 1.1.1.1 1993/06/18 04:22:12 jkh
- * Updated GNU utilities
- *
- * 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: rcslex.c,v 1.1.1.1 1993/06/18 04:22:12 jkh Exp $")
-
-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 */
-
-unsigned 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|quietflag)) {
- ignored_phrases = true;
- warn("Unknown phrases like `%s ...;' are in the RCS file.", 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 = nil;
-# 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] = nil;
- }
-
- 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 DIGIT:
- sp = tokbuf.string;
- limit = sp + tokbuf.size;
- *sp++ = c;
- for (;;) {
- GETC(frew, c);
- if ((d=ctab[c])!=DIGIT && d!=PERIOD)
- break;
- *sp++ = c; /* 1.2. and 1.2 are different */
- if (limit <= sp)
- sp = bufenlarge(&tokbuf, &limit);
- }
- *sp = 0;
- if (hshenter)
- lookup(tokbuf.string);
- else
- NextString = fstr_save(tokbuf.string);
- d = NUM;
- break;
-
-
- case LETTER:
- case Letter:
- sp = tokbuf.string;
- limit = sp + tokbuf.size;
- *sp++ = c;
- for (;;) {
- GETC(frew, c);
- if ((d=ctab[c])!=LETTER && d!=Letter && d!=DIGIT && d!=IDCHAR)
- break;
- *sp++ = c;
- if (limit <= sp)
- sp = bufenlarge(&tokbuf, &limit);
- }
- *sp = 0;
- NextString = fstr_save(tokbuf.string);
- d = ID; /* may be ID or keyword */
- 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 nil.
- * Treats keywords as identifiers.
- */
-{
- register char const *name;
- if (nexttok==ID) {
- name = NextString;
- nextlex();
- return name;
- } else return nil;
-}
-
-
-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 nil.
- * Doesn't work if hshenter is false.
- */
-{
- register struct hshentry * num;
- if (nexttok==NUM) {
- num=nexthsh;
- nextlex();
- return num;
- } else return nil;
-}
-
- 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.
- * Assume !foutptr.
- */
-{
- declarecache;
- register int c;
- register char *p;
- char const *limit;
- register char const *ki, *kn;
- struct cbuf r;
- struct buf b;
- register RILE *fin;
-
- if (nexttok!=ID || strcmp(NextString,key) == 0) {
- r.string = 0;
- r.size = 0;
- return r;
- } else {
- warnignore();
- fin = finptr;
- setupcache(fin); cache(fin);
- bufautobegin(&b);
- bufscpy(&b, NextString);
- ffree1(NextString);
- p = b.string + strlen(b.string);
- limit = b.string + b.size;
- c = nextc;
- for (;;) {
- for (;;) {
- if (limit <= p)
- p = bufenlarge(&b, &limit);
- *p++ = 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:
- cacheget(c);
- continue;
- case SBEGIN: /* long string */
- for (;;) {
- for (;;) {
- if (limit <= p)
- p = bufenlarge(&b, &limit);
- cacheget(c);
- *p++ = c;
- switch (c) {
- case '\n':
- ++rcsline;
- /* fall into */
- default:
- continue;
-
- case SDELIM:
- break;
- }
- break;
- }
- cacheget(c);
- if (c != SDELIM)
- break;
- if (limit <= p)
- p = bufenlarge(&b, &limit);
- *p++ = c;
- }
- continue;
- case SEMI:
- cacheget(c);
- if (ctab[c] == NEWLN) {
- ++rcsline;
- if (limit <= p)
- p = bufenlarge(&b, &limit);
- *p++ = c;
- cacheget(c);
- }
- for (;;) {
- switch (ctab[c]) {
- case NEWLN:
- ++rcsline;
- /* fall into */
- case SPACE:
- cacheget(c);
- continue;
-
- default: break;
- }
- break;
- }
- break;
- }
- break;
- }
- switch (ctab[c]) {
- case LETTER:
- case Letter:
- for (kn = key; c && *kn==c; kn++)
- cacheget(c);
- if (!*kn)
- switch (ctab[c]) {
- case DIGIT: case LETTER: case Letter:
- break;
- default:
- nextc = c;
- NextString = fstr_save(key);
- nexttok = ID;
- uncache(fin);
- goto returnit;
- }
- for (ki=key; ki<kn; ) {
- if (limit <= p)
- p = bufenlarge(&b, &limit);
- *p++ = *ki++;
- }
- break;
-
- default:
- nextc = c;
- uncache(fin);
- nextlex();
- goto returnit;
- }
- }
- returnit:
- return bufremember(&b, (size_t)(p - b.string));
- }
-}
-
-
- 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;
- }
-}
-
-
- char *
-checkid(id, delimiter)
- register char *id;
- int delimiter;
-/* 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. */
-{
- register enum tokens d;
- register char *temp;
- register char c,tc;
- register char delim = delimiter;
-
- temp = id;
- if ((d = ctab[(unsigned char)(c = *id)])==LETTER || d==Letter) {
- while ((d = ctab[(unsigned char)(c = *++id)])==LETTER
- || d==Letter || d==DIGIT || d==IDCHAR
- )
- ;
- if (c && (!delim || c!=delim && c!=' ' && c!='\t' && c!='\n')) {
- /* append \0 to end of id before error message */
- tc = c;
- while( (c=(*++id))!=' ' && c!='\t' && c!='\n' && c!='\0' && c!=delim) ;
- *id = '\0';
- faterror("invalid character %c in identifier `%s'",tc,temp);
- }
- } else {
- /* append \0 to end of id before error message */
- while( (c=(*++id))!=' ' && c!='\t' && c!='\n' && c!='\0' && c!=delim) ;
- *id = '\0';
- faterror("identifier `%s' doesn't start with letter", temp);
- }
- return id;
-}
-
- void
-checksid(id)
- char *id;
-/* Check whether the string ID is an identifier. */
-{
- VOID checkid(id, 0);
-}
-
-
- static RILE *
-#if has_mmap && large_memory
-fd2_RILE(fd, filename, status)
-#else
-fd2RILE(fd, filename, mode, status)
- char const *mode;
-#endif
- int fd;
- char const *filename;
- register struct stat *status;
-{
- struct stat st;
-
- if (!status)
- status = &st;
- if (fstat(fd, status) != 0)
- efaterror(filename);
- if (!S_ISREG(status->st_mode)) {
- error("`%s' is not a regular file", filename);
- VOID close(fd);
- errno = EINVAL;
- return 0;
- } else {
-
-# if ! (has_mmap && large_memory)
- FILE *stream;
- if (!(stream = fdopen(fd, mode)))
- efaterror(filename);
-# 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' is enormous", filename);
- for (f = rilebuf; f->base; f++)
- if (f == rilebuf+RILES)
- faterror("too many RILEs");
- if (!s) {
- static unsigned char dummy;
- f->base = &dummy;
- } else {
-# if has_mmap
- if (
- (f->base = (unsigned char *)mmap(
- (caddr_t)0, s, PROT_READ, MAP_SHARED,
- fd, (off_t)0
- )) == (unsigned char *)-1
- )
- efaterror("mmap");
-# else
- f->base = tnalloc(unsigned char, s);
-# endif
- }
- f->ptr = f->base;
- f->lim = f->base + s;
-# if has_mmap
- f->fd = fd;
-# else
- f->readlim = f->base;
- f->stream = stream;
-# endif
- if_advise_access(s, f, MADV_SEQUENTIAL);
- return f;
- }
-# endif
- }
-}
-
-#if !has_mmap && 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 (madvise((caddr_t)f->base, (size_t)(f->lim - f->base), advice) != 0)
- efaterror("madvise");
-}
-#endif
-
- RILE *
-#if has_mmap && large_memory
-I_open(filename, status)
-#else
-Iopen(filename, mode, status)
- char const *mode;
-#endif
- char const *filename;
- struct stat *status;
-/* Open FILENAME for reading, yield its descriptor, and set *STATUS. */
-{
- int fd;
-
- if ((fd = open(filename,O_RDONLY|O_BINARY)) < 0)
- return 0;
-# if has_mmap && large_memory
- return fd2_RILE(fd, filename, status);
-# else
- return fd2RILE(fd, filename, mode, status);
-# endif
-}
-
-
-#if !large_memory
-# define Iclose(f) fclose(f)
-#else
- static int
- Iclose(f)
- register RILE *f;
- {
-# if has_mmap
- size_t s = f->lim - f->base;
- if (s && munmap((caddr_t)f->base, s) != 0)
- return -1;
- f->base = 0;
- return close(f->fd);
-# else
- tfree(f->base);
- f->base = 0;
- return fclose(f->stream);
-# endif
- }
-#endif
-
-
-static int Oerrloop;
-
- exiting void
-Oerror()
-{
- if (Oerrloop)
- exiterr();
- Oerrloop = true;
- efaterror("output error");
-}
-
-exiting void Ieof() { fatserror("unexpected end of file"); }
-exiting 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(); }
-#ifndef FSYNC_ALL
-void Ofclose(f) FILE *f; { if (f && fclose(f)!=0) Oerror(); }
-#else
-void Ofclose(f) FILE *f; { if (f && (fflush(f)!=0 ||
- fsync(fileno(f))!=0 ||
- fclose(f)!=0)) Oerror(); }
-#endif
-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 eflush()
-{
- if (fflush(stderr) != 0 && !Oerrloop)
- Oerror();
-}
-
-void oflush()
-{
- if (fflush(workstdout ? workstdout : stdout) != 0 && !Oerrloop)
- Oerror();
-}
-
- static exiting void
-fatcleanup(already_newline)
- int already_newline;
-{
- VOID fprintf(stderr, already_newline+"\n%s aborted\n", cmdid);
- exiterr();
-}
-
-static void errsay() { oflush(); aprintf(stderr,"%s error: ",cmdid); nerror++; }
-static void fatsay() { oflush(); VOID fprintf(stderr,"%s error: ",cmdid); }
-
-void eerror(s) char const *s; { enerror(errno,s); }
-
- void
-enerror(e,s)
- int e;
- char const *s;
-{
- errsay();
- errno = e;
- perror(s);
- eflush();
-}
-
-exiting void efaterror(s) char const *s; { enfaterror(errno,s); }
-
- exiting void
-enfaterror(e,s)
- int e;
- char const *s;
-{
- fatsay();
- 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();
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- afputc('\n',stderr);
- eflush();
-}
-
-#if has_prototypes
- exiting void
-fatserror(char const *format,...)
-#else
- /*VARARGS1*/ exiting void
- fatserror(format, va_alist) char const *format; va_dcl
-#endif
-/* fatal syntax error */
-{
- va_list args;
- oflush();
- VOID fprintf(stderr, "%s: %s:%lu: ", cmdid, RCSfilename, rcsline);
- vararg_start(args, format);
- fvfprintf(stderr, format, args);
- va_end(args);
- fatcleanup(false);
-}
-
-#if has_prototypes
- exiting void
-faterror(char const *format,...)
-#else
- /*VARARGS1*/ exiting void faterror(format, va_alist)
- char const *format; va_dcl
-#endif
-/* fatal error, terminates program after cleanup */
-{
- va_list args;
- fatsay();
- 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
-/* prints a warning message */
-{
- va_list args;
- oflush();
- aprintf(stderr,"%s warning: ",cmdid);
- 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)
-/* Function: 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)
-#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))
-#endif
- Oerror();
-}
-
-#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);
-}
-
-exiting 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 0e7b23c..0000000
--- a/gnu/usr.bin/rcs/lib/rcsmap.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* RCS map of character types */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-
-libId(mapId, "$Id: rcsmap.c,v 5.2 1991/08/19 03:13:55 eggert Exp $")
-
-/* 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 ce11f54..0000000
--- a/gnu/usr.bin/rcs/lib/rcsrev.c
+++ /dev/null
@@ -1,790 +0,0 @@
-/*
- * RCS revision number handling
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/* $Log: rcsrev.c,v $
- * 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.
- */
-
-
-
-/*
-#define REVTEST
-*/
-/* version REVTEST is for testing the routines that generate a sequence
- * of delta numbers needed to regenerate a given delta.
- */
-
-#include "rcsbase.h"
-
-libId(revId, "$Id: rcsrev.c,v 5.3 1991/08/19 03:13:55 eggert Exp $")
-
-static char const *branchtip P((char const*));
-static struct hshentry *genbranch P((struct hshentry const*,char const*,unsigned,char const*,char const*,char const*,struct hshentries**));
-
-
-
- unsigned
-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 unsigned count;
- if ((sp=s)==nil) return(0);
- if (*sp == '\0') return(0);
- count = 1;
- do {
- if (*sp++ == '.') count++;
- } while (*sp);
- return(count);
-}
-
- void
-getbranchno(revno,branchno)
- char const *revno;
- struct buf *branchno;
-/* Given a non-nil 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 unsigned numflds;
- register char *tp;
-
- bufscpy(branchno, revno);
- numflds=countnumflds(revno);
- if (!(numflds & 1)) {
- tp = branchno->string;
- while (--numflds)
- while (*tp++ != '.')
- ;
- *(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==nil?"":num1;
- s2=num2==nil?"":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; for (d1=0; isdigit(s1[d1]); d1++) ;
- while (*s2=='0') ++s2; for (d2=0; isdigit(s2[d2]); d2++) ;
-
- /* 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;
- unsigned 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++ != '.')
- ;
- while (*s2++ != '.')
- ;
- }
- /* Now s1 and s2 point to the beginning of the respective fields */
- while (*s1=='0') ++s1; for (d1=0; isdigit(s1[d1]); d1++) ;
- while (*s2=='0') ++s2; for (d2=0; isdigit(s2[d2]); d2++) ;
-
- return d1<d2 ? -1 : d1==d2 ? memcmp(s1,s2,d1) : 1;
-}
-
-
- static void
-cantfindbranch(revno, date, author, state)
- char const *revno, date[datesize], *author, *state;
-{
- char datebuf[datesize];
-
- error("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;
- unsigned field;
-{
- struct buf t;
- bufautobegin(&t);
- error("%s %s absent", field&1?"revision":"branch",
- partialno(&t,revno,field)
- );
- bufautoend(&t);
-}
-
-
- int
-compartial(num1, num2, length)
- char const *num1, *num2;
- unsigned 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++) ;
- while (*s2=='0') ++s2; for (d2=0; isdigit(s2[d2]); d2++) ;
-
- if (d1 != d2)
- return d1<d2 ? -1 : 1;
- if ((r = memcmp(s1, s2, d1)))
- return r;
- s1 += d1;
- s2 += d1;
-
- if (*s1 == '.') s1++;
- if (*s2 == '.') s2++;
-
- if ( --length == 0 ) return 0;
- }
-}
-
-
-char * partialno(rev1,rev2,length)
- struct buf *rev1;
- char const *rev2;
- register unsigned 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, nil is returned.
- */
-{
- unsigned length;
- register struct hshentry * next;
- int result;
- char const *branchnum;
- struct buf t;
- char datebuf[datesize];
-
- bufautobegin(&t);
-
- if (!(next = Head)) {
- error("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) {
- error("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!=nil) &&
- (cmpnumfld(branchnum,next->num,1)==0) &&
- !(
- (date==nil?1:(cmpnum(date,next->date)>=0)) &&
- (author==nil?1:(strcmp(author,next->author)==0)) &&
- (state ==nil?1:(strcmp(state, next->state) ==0))
- )
- )
- {
- store1(&store, next);
- next=next->next;
- }
- if ((next==nil) ||
- (cmpnumfld(branchnum,next->num,1)!=0))/*overshot*/ {
- cantfindbranch(
- length ? revno : partialno(&t,branchnum,1),
- date, author, state
- );
- goto norev;
- } else {
- store1(&store, next);
- }
- *store = nil;
- 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==nil) || (cmpnumfld(revno,next->num,1)!=0)) {
- error("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!=nil) && (cmpnum(date,next->date)<0)){
- error("Revision %s has date %s.",
- next->num,
- date2str(next->date, datebuf)
- );
- return nil;
- }
- if ((author!=nil)&&(strcmp(author,next->author)!=0)) {
- error("Revision %s has author %s.",next->num,next->author);
- return nil;
- }
- if ((state!=nil)&&(strcmp(state,next->state)!=0)) {
- error("Revision %s has state %s.",next->num,
- next->state==nil?"<empty>":next->state);
- return nil;
- }
- *store=nil;
- return next;
- }
-
- norev:
- bufautoend(&t);
- return nil;
-}
-
-
-
-
- static struct hshentry *
-genbranch(bpoint, revno, length, date, author, state, store)
- struct hshentry const *bpoint;
- char const *revno;
- unsigned 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 nil on error
- */
-{
- unsigned field;
- register struct hshentry * next, * trail;
- register struct branchhead const *bhead;
- int result;
- struct buf t;
- char datebuf[datesize];
-
- field = 3;
- bhead = bpoint->branches;
-
- do {
- if (!bhead) {
- bufautobegin(&t);
- error("no side branches present for %s", partialno(&t,revno,field-1));
- bufautoend(&t);
- return nil;
- }
-
- /*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);
- error("branch number %s too high",partialno(&t,revno,field));
- bufautoend(&t);
- return nil;
- }
- }
-
- if (result<0) {
- absent(revno, field);
- return nil;
- }
-
- next = bhead->hsh;
- if (length==field) {
- /* pick latest one on that branch */
- trail=nil;
- do { if ((date==nil?1:(cmpnum(date,next->date)>=0)) &&
- (author==nil?1:(strcmp(author,next->author)==0)) &&
- (state ==nil?1:(strcmp(state, next->state) ==0))
- ) trail = next;
- next=next->next;
- } while (next!=nil);
-
- if (trail==nil) {
- cantfindbranch(revno, date, author, state);
- return nil;
- } else { /* print up to last one suitable */
- next = bhead->hsh;
- while (next!=trail) {
- store1(&store, next);
- next=next->next;
- }
- store1(&store, next);
- }
- *store = nil;
- return next;
- }
-
- /* length > field */
- /* find revision */
- /* check low */
- if (cmpnumfld(revno,next->num,field+1)<0) {
- bufautobegin(&t);
- error("revision number %s too low", partialno(&t,revno,field+1));
- bufautoend(&t);
- return(nil);
- }
- do {
- store1(&store, next);
- trail = next;
- next = next->next;
- } while ((next!=nil) &&
- (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(nil);
- }
- if (length == field+1) {
- if ((date!=nil) && (cmpnum(date,trail->date)<0)){
- error("Revision %s has date %s.",
- trail->num,
- date2str(trail->date, datebuf)
- );
- return nil;
- }
- if ((author!=nil)&&(strcmp(author,trail->author)!=0)) {
- error("Revision %s has author %s.",trail->num,trail->author);
- return nil;
- }
- if ((state!=nil)&&(strcmp(state,trail->state)!=0)) {
- error("Revision %s has state %s.",trail->num,
- trail->state==nil?"<empty>":trail->state);
- return nil;
- }
- }
- bhead = trail->branches;
-
- } while ((field+=2) <= length);
- * store = nil;
- 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. Returns nil if not present.
- */
-{
- register struct assoc const *next;
- next = Symbols;
- while (next!=nil) {
- if (strcmp(id, next->symbol)==0)
- return next->num;
- else next=next->nextassoc;
- }
- return nil;
-}
-
-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;
- register enum tokens d;
- unsigned dots;
-
- sp = source;
- bufalloc(target, 1);
- tp = target->string;
- if (!sp || !*sp) { /*accept nil pointer as a legal value*/
- *tp='\0';
- return true;
- }
- if (sp[0] == KDELIM && !sp[1]) {
- if (!getoldkeys(fp))
- return false;
- if (!*prevrev.string) {
- error("working file lacks revision number");
- return false;
- }
- bufscpy(target, prevrev.string);
- return true;
- }
- tlim = tp + target->size;
- dots = 0;
-
- for (;;) {
- switch (ctab[(unsigned char)*sp]) {
- case DIGIT:
- while (*sp=='0' && isdigit(sp[1]))
- /* skip leading zeroes */
- sp++;
- do {
- if (tlim <= tp)
- tp = bufenlarge(target, &tlim);
- } while (isdigit(*tp++ = *sp++));
- --sp;
- tp[-1] = '\0';
- break;
-
- case LETTER:
- case Letter:
- {
- register char *p = tp;
- register size_t s = tp - target->string;
- do {
- if (tlim <= p)
- p = bufenlarge(target, &tlim);
- *p++ = *sp++;
- } while ((d=ctab[(unsigned char)*sp])==LETTER ||
- d==Letter || d==DIGIT ||
- (d==IDCHAR));
- if (tlim <= p)
- p = bufenlarge(target, &tlim);
- *p = 0;
- tp = target->string + s;
- }
- bp = lookupsym(tp);
- if (bp==nil) {
- error("Symbolic number %s is undefined.", tp);
- return false;
- }
- do {
- if (tlim <= tp)
- tp = bufenlarge(target, &tlim);
- } while ((*tp++ = *bp++));
- break;
-
- default:
- goto improper;
- }
- switch (*sp++) {
- case '\0': return true;
- case '.': break;
- default: goto improper;
- }
- if (!*sp) {
- if (dots & 1)
- goto improper;
- if (!(bp = branchtip(target->string)))
- return false;
- bufscpy(target, bp);
- return true;
- }
- ++dots;
- tp[-1] = '.';
- }
-
- improper:
- error("improper revision number: %s", source);
- return false;
-}
-
- 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
-
-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 (!gets(symrevno)) break;
- if (*symrevno == '.') break;
- aprintf(stderr,"%s;\n",symrevno);
- expandsym(symrevno,&numricrevno);
- aprintf(stderr,"expanded number: %s; ",numricrevno.string);
- aprintf(stderr,"Date: ");
- gets(date); aprintf(stderr,"%s; ",date);
- aprintf(stderr,"Author: ");
- gets(author); aprintf(stderr,"%s; ",author);
- aprintf(stderr,"State: ");
- gets(state); aprintf(stderr, "%s;\n", state);
- target = genrevs(numricrevno.string, *date?date:(char *)nil, *author?author:(char *)nil,
- *state?state:(char*)nil, &gendeltas);
- if (target!=nil) {
- while (gendeltas) {
- aprintf(stderr,"%s\n",gendeltas->first->num);
- gendeltas = gendeltas->next;
- }
- }
- } while (true);
- aprintf(stderr,"done\n");
- exitmain(EXIT_SUCCESS);
-}
-
-exiting 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 31086c2..0000000
--- a/gnu/usr.bin/rcs/lib/rcssyn.c
+++ /dev/null
@@ -1,857 +0,0 @@
-/*
- * RCS file input
- */
-/*********************************************************************************
- * Syntax Analysis.
- * Keyword table
- * Testprogram: define SYNTEST
- * Compatibility with Release 2: define COMPAT2=1
- *********************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-/* $Log: rcssyn.c,v $
- * 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.
- */
-/* version SYNTEST inputs a RCS file and then prints out its internal
- * data structures.
-*/
-
-#include "rcsbase.h"
-
-libId(synId, "$Id: rcssyn.c,v 5.8 1991/08/19 03:13:55 eggert Exp $")
-
-/* forward */
-static char const *getkeyval P((char const*,enum tokens,int));
-static int strn2expmode P((char const*,size_t));
-
-/* keyword table */
-
-char const
- Kdesc[] = "desc",
- Klog[] = "log",
- Ktext[] = "text";
-
-static char const
- Kaccess[] = "access",
- Kauthor[] = "author",
- Kbranch[] = "branch",
- K_branches[]= "branches",
- Kcomment[] = "comment",
- Kdate[] = "date",
- Kexpand[] = "expand",
- Khead[] = "head",
- Klocks[] = "locks",
- Knext[] = "next",
- Kstate[] = "state",
- Kstrict[] = "strict",
-#if COMPAT2
- Ksuffix[] = "suffix",
-#endif
- Ksymbols[] = "symbols";
-
-static struct buf Commleader;
-static struct cbuf Ignored;
-struct cbuf Comment;
-struct access * AccessList;
-struct assoc * Symbols;
-struct lock * Locks;
-int Expand;
-int StrictLocks;
-struct hshentry * Head;
-char const * Dbranch;
-unsigned 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 lock * newlock;
- struct hshentry * delta;
- struct access **LastAccess;
- struct assoc **LastSymbol;
- struct lock **LastLock;
- struct buf b;
- struct cbuf cb;
-
- TotalDeltas=0;
-
- getkey(Khead);
- Head = getdnum();
- getsemi(Khead);
-
- Dbranch = nil;
- 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 = nil;
- 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 = nil;
- 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 lock);
- newlock->login=id;
- newlock->delta=delta;
- *LastLock = newlock;
- LastLock = &newlock->nextlock;
- }
- }
- *LastLock = nil;
- getsemi(Klocks);
-
- if ((StrictLocks = getkeyopt(Kstrict)))
- getsemi(Kstrict);
-
- Comment.size = 0;
- 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",
- 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
-ignorephrase()
-/* Ignore a phrase introduced by a later version of RCS. */
-{
- warnignore();
- hshenter=false;
- for (;;) {
- switch (nexttok) {
- case SEMI: hshenter=true; nextlex(); return;
- case ID:
- case NUM: ffree1(NextString); break;
- case STRING: readstring(); break;
- default: break;
- }
- nextlex();
- }
-}
-
-
- 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 = nil;
- getsemi(K_branches);
-
- getkey(Knext);
- Delta->next = num = getdnum();
- getsemi(Knext);
- Delta->lockedby = nil;
- 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 lock const *currlock;
-
- while (getdelta());
- 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 = nil;
-
- getkey(keyword);
- if (nexttok==token) {
- val = NextString;
- nextlex();
- } else {
- if (!optional)
- fatserror("missing %s", keyword);
- }
- getsemi(keyword);
- return(val);
-}
-
-
-
-
- void
-putadmin(fout)
-register FILE * fout;
-/* Function: Print the <admin> node read with getadmin() to file fout.
- * Assumption: Variables AccessList, Symbols, Locks, StrictLocks,
- * and Head have been set.
- */
-{
- struct assoc const *curassoc;
- struct lock const *curlock;
- struct access const *curaccess;
-
- aprintf(fout, "%s\t%s;\n", Khead, 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;
-/* Function: prints a <delta> node to fout;
- */
-{
- struct branchhead const *nextbranch;
-
- if (node == nil) 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;
-/* Function: prints the delta tree in preorder to fout, starting with root.
- */
-{
- struct branchhead const *nextbranch;
-
- if (root==nil) return;
-
- if (root->selector)
- putdelta(root,fout);
-
- puttree(root->next,fout);
-
- nextbranch = root->branches;
- while (nextbranch) {
- puttree(nextbranch->hsh,fout);
- nextbranch = nextbranch->nextbranch;
- }
-}
-
-
- static exiting void
-unexpected_EOF()
-{
- faterror("unexpected EOF in diff output");
-}
-
-int putdtext(num,log,srcfilename,fout,diffmt)
- char const *num, *srcfilename;
- struct cbuf log;
- FILE *fout;
- int diffmt;
-/* Function: write a deltatext-node to fout.
- * num points to the deltanumber, log to the logmessage, and
- * sourcefile contains the text. Doubles up all SDELIMs in both the
- * log and the text; Makes sure the log message ends in \n.
- * returns false on error.
- * If diffmt is true, also checks that text is valid diff -n output.
- */
-{
- RILE *fin;
- int result;
- if (!(fin = Iopen(srcfilename, "r", (struct stat*)0))) {
- eerror(srcfilename);
- return false;
- }
- result = putdftext(num,log,fin,fout,diffmt);
- Ifclose(fin);
- return result;
-}
-
- 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);
-}
-
- int
-putdftext(num,log,finfile,foutfile,diffmt)
- char const *num;
- struct cbuf log;
- 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,num,Klog);
- /* put log */
- putstring(fout, true, log, true);
- /* put text */
- aprintf(fout, "\n%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);
- return true;
-}
-
- void
-initdiffcmd(dc)
- register struct diffcmd *dc;
-/* Initialize *dc suitably for getdiffcmd(). */
-{
- dc->adprev = 0;
- dc->dafter = 0;
-}
-
- static exiting void
-badDiffOutput(buf)
- char const *buf;
-{
- faterror("bad diff output line: %s", buf);
-}
-
- static exiting void
-diffLineNumberTooLarge(buf)
- char const *buf;
-{
- faterror("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;
- unsigned 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) {
- faterror("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++) == ' '; )
- ;
- line1 = 0;
- while (isdigit(c)) {
- t = line1 * 10;
- if (
- ULONG_MAX/10 < line1 ||
- (line1 = t + (c - '0')) < t
- )
- diffLineNumberTooLarge(buf);
- c = *p++;
- }
- while (c == ' ')
- c = *p++;
- nlines = 0;
- while (isdigit(c)) {
- t = nlines * 10;
- if (
- ULONG_MAX/10 < nlines ||
- (nlines = t + (c - '0')) < t
- )
- diffLineNumberTooLarge(buf);
- c = *p++;
- }
- if (c || !nlines) {
- badDiffOutput(buf);
- }
- if (line1+nlines < line1)
- diffLineNumberTooLarge(buf);
- switch (buf[0]) {
- case 'a':
- if (line1 < dc->adprev) {
- faterror("backward insertion in diff output: %s", buf);
- }
- dc->adprev = line1 + 1;
- break;
- case 'd':
- if (line1 < dc->adprev || line1 < dc->dafter) {
- faterror("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
-
-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();
- putadmin(stdout);
-
- gettree();
- puttree(Head,stdout);
-
- getdesc(true);
-
- nextlex();
-
- if (!eoflex()) {
- fatserror("expecting EOF");
- }
- exitmain(EXIT_SUCCESS);
-}
-
-
-exiting void exiterr() { _exit(EXIT_FAILURE); }
-
-
-#endif
-
diff --git a/gnu/usr.bin/rcs/lib/rcsutil.c b/gnu/usr.bin/rcs/lib/rcsutil.c
deleted file mode 100644
index c523ccf1..0000000
--- a/gnu/usr.bin/rcs/lib/rcsutil.c
+++ /dev/null
@@ -1,994 +0,0 @@
-/*
- * RCS utilities
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/* $Log: rcsutil.c,v $
- * 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 5.10 1991/10/07 17:32:46 eggert 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 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 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 = nil;
-}
-
- 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 set 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;
-
- static signal_type
-catchsig(s)
- int s;
-{
- char const *sname;
- char buf[BUFSIZ];
-
-#if sig_zaps_handler
- /* If a signal arrives before we reset the signal handler, we lose. */
- VOID signal(s, SIG_IGN);
-#endif
- if (holdlevel) {
- heldsignal = s;
- return;
- }
- ignoreints();
- setrid();
- if (!quietflag) {
- sname = nil;
-#if has_sys_siglist && defined(NSIG)
- if ((unsigned)s < NSIG) {
-# ifndef sys_siglist
- extern char const *sys_siglist[];
-# endif
- sname = sys_siglist[s];
- }
-#else
- switch (s) {
-#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
- }
-#endif
- if (sname)
- VOID sprintf(buf, "\nRCS: %s. Cleaning up.\n", sname);
- else
- VOID sprintf(buf, "\nRCS: Signal %d. Cleaning up.\n", s);
- VOID write(STDERR_FILENO, buf, strlen(buf));
- }
- exiterr();
-}
-
- void
-ignoreints()
-{
- ++holdlevel;
-}
-
- void
-restoreints()
-{
- if (!--holdlevel && heldsignal)
- VOID catchsig(heldsignal);
-}
-
-
-static int const sig[] = {
-#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
-};
-#define SIGS (sizeof(sig)/sizeof(*sig))
-
-
-#if has_sigaction
-
- static void
- check_sig(r)
- int r;
- {
- if (r != 0)
- efaterror("signal");
- }
-
- static void
- setup_catchsig()
- {
- register int i;
- sigset_t blocked;
- struct sigaction act;
-
- check_sig(sigemptyset(&blocked));
- for (i=SIGS; 0<=--i; )
- check_sig(sigaddset(&blocked, sig[i]));
- for (i=SIGS; 0<=--i; ) {
- check_sig(sigaction(sig[i], (struct sigaction*)nil, &act));
- if (act.sa_handler != SIG_IGN) {
- act.sa_handler = catchsig;
- act.sa_mask = blocked;
- check_sig(sigaction(sig[i], &act, (struct sigaction*)nil));
- }
- }
- }
-
-#else
-#if has_sigblock
-
- static void
- setup_catchsig()
- {
- 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()
- {
- 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
-
- void
-catchints()
-{
- static int catching_ints;
- if (!catching_ints) {
- catching_ints = true;
- setup_catchsig();
- }
-}
-
-#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 has_mmap
- 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();
-}
-
-
-
-
-
- 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(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
-tryopen(fd,file,flags)
- int fd, flags;
- char const *file;
-{
- if (file && fdreopen(fd,file,flags) != fd)
- efaterror(file);
-}
-#else
- static int
-tryopen(fd,file,flags)
- int fd, flags;
- char const *file;
-{
- int newfd = -1;
- if (file && ((newfd=dup(fd)) < 0 || fdreopen(fd,file,flags) != fd))
- efaterror(file);
- return newfd;
-}
- static void
-redirect(old, new)
- int old, new;
-{
- if (0 <= old && (close(new) != 0 || movefd(old,new) < 0))
- efaterror("spawn I/O redirection");
-}
-#endif
-
-
-
-#if !has_fork && !has_spawn
- 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
-
-/*
-* Run a command specified by the strings in 'inoutargs'.
-* inoutargs[0], if nonnil, is the name of the input file.
-* inoutargs[1], if nonnil, is the name of the output file.
-* inoutargs[2..] form the command to be run.
-*/
- int
-runv(inoutargs)
- char const **inoutargs;
-{
- register char const **p;
- int wstatus;
-
- oflush();
- eflush();
- {
-#if has_spawn
- int in, out;
- p = inoutargs;
- in = tryopen(STDIN_FILENO, *p++, O_BINARY|O_RDONLY);
- out = tryopen(STDOUT_FILENO, *p++, O_BINARY|O_CREAT|O_TRUNC|O_WRONLY);
- wstatus = spawn_RCS(0, *p, (char*const*)p);
- if (wstatus == -1 && errno == ENOEXEC) {
- *--p = RCS_SHELL;
- wstatus = spawnv(0, *p, (char*const*)p);
- }
- redirect(in, STDIN_FILENO);
- redirect(out, STDOUT_FILENO);
-#else
-#if has_fork
- pid_t pid;
-# if !has_waitpid
- pid_t w;
-# endif
- if (!(pid = vfork())) {
- p = inoutargs;
- tryopen(STDIN_FILENO, *p++, O_BINARY|O_RDONLY);
- tryopen(STDOUT_FILENO, *p++, O_BINARY|O_CREAT|O_TRUNC|O_WRONLY);
- VOID exec_RCS(*p, (char*const*)p);
- if (errno == ENOEXEC) {
- *--p = RCS_SHELL;
- VOID execv(*p, (char*const*)p);
- }
- VOID write(STDERR_FILENO, *p, strlen(*p));
- VOID write(STDERR_FILENO, ": not found\n", 12);
- _exit(EXIT_TROUBLE);
- }
- if (pid < 0)
- efaterror("fork");
-# if has_waitpid
- if (waitpid(pid, &wstatus, 0) < 0)
- efaterror("waitpid");
-# else
- do {
- if ((w = wait(&wstatus)) < 0)
- efaterror("wait");
- } while (w != pid);
-# endif
-#else
- static struct buf b;
-
- /* Use system(). On many hosts system() discards signals. Yuck! */
- p = inoutargs+2;
- bufscpy(&b, *p);
- while (*++p)
- bufargcat(&b, ' ', *p);
- if (inoutargs[0])
- bufargcat(&b, '<', inoutargs[0]);
- if (inoutargs[1])
- bufargcat(&b, '>', inoutargs[1]);
- wstatus = system(b.string);
-#endif
-#endif
- }
- if (!WIFEXITED(wstatus))
- faterror("%s failed", inoutargs[2]);
- return WEXITSTATUS(wstatus);
-}
-
-#define CARGSMAX 20
-/*
-* Run a command.
-* The first two arguments are the input and output files (if nonnil);
-* the rest specify the command and its arguments.
-*/
- int
-#if has_prototypes
-run(char const *infile, char const *outfile, ...)
-#else
- /*VARARGS2*/
-run(infile, outfile, va_alist)
- char const *infile;
- char const *outfile;
- va_dcl
-#endif
-{
- va_list ap;
- char const *rgargs[CARGSMAX];
- register i = 0;
- rgargs[0] = infile;
- rgargs[1] = outfile;
- vararg_start(ap, outfile);
- for (i = 2; (rgargs[i++] = va_arg(ap, char const*)); )
- if (CARGSMAX <= i)
- faterror("too many command arguments");
- va_end(ap);
- return runv(rgargs);
-}
-
-
- char const *
-date2str(date, datebuf)
- char const date[datesize];
- char datebuf[datesize];
-/*
-* Format a user-readable form of the RCS format DATE into the buffer DATEBUF.
-* Yield DATEBUF.
-*/
-{
- register char const *p = date;
-
- while (*p++ != '.')
- ;
- 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
- );
- return datebuf;
-}
-
-
-int RCSversion;
-
- void
-setRCSversion(str)
- char const *str;
-{
- static int oldversion;
-
- register char const *s = str + 2;
- int v = VERSION_DEFAULT;
-
- if (oldversion)
- redefined('V');
- oldversion = true;
-
- if (*s) {
- v = 0;
- while (isdigit(*s))
- v = 10*v + *s++ - '0';
- if (*s)
- faterror("%s isn't a number", str);
- if (v < VERSION_min || VERSION_max < v)
- faterror("%s out of range %d..%d", str, VERSION_min, VERSION_max);
- }
-
- RCSversion = VERSION(v);
-}
-
- int
-getRCSINIT(argc, argv, newargv)
- int argc;
- char **argv, ***newargv;
-{
- register char *p, *q, **pp;
- unsigned n;
-
- 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++))
- ;
- }
- 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
-set_uid_to(u)
- uid_t u;
-/* Become user u. */
-{
- static int looping;
-
- if (euid() == ruid())
- return;
-#if (has_fork||has_spawn) && DIFF_ABSOLUTE
- if (seteuid(u) != 0)
- efaterror("setuid");
-#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
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 8b1957f..0000000
--- a/gnu/usr.bin/rcs/merge/merge.1
+++ /dev/null
@@ -1,102 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: merge.1,v 5.3 1991/02/28 19:18:45 eggert Exp $
-.TH MERGE 1 \*(Dt GNU
-.SH NAME
-merge \- three-way file merge
-.SH SYNOPSIS
-.B merge
-[
-.B \-L
-.I label1
-[
-.B \-L
-.I label3
-] ] [
-.B \-p
-] [
-.B \-q
-]
-.I "file1 file2 file3"
-.SH DESCRIPTION
-.B merge
-incorporates all changes that lead from
-.I file2
-to
-.I file3
-into
-.IR file1 .
-The result goes to standard output if
-.B \-p
-is present, into
-.I file1
-otherwise.
-.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
-An overlap occurs if both
-.I file1
-and
-.I file3
-have changes in a common segment of lines.
-On a few older hosts where
-.B diff3
-does not support the
-.B \-E
-option,
-.B merge
-does not detect overlaps, and merely supplies the changed lines from
-.I file3.
-On most hosts, if overlaps occur,
-.B merge
-outputs a message (unless the
-.B \-q
-option is given),
-and includes both alternatives
-in the result. The alternatives are delimited as follows:
-.LP
-.RS
-.nf
-.BI <<<<<<< " file1"
-.I "lines in file1"
-.B "======="
-.I "lines in file3"
-.BI >>>>>>> " file3"
-.RE
-.fi
-.LP
-If there are overlaps, the user should edit the result and delete one of the
-alternatives.
-If the
-.BI \-L "\ label1"
-and
-.BI \-L "\ label3"
-options are given, the labels are output in place of the names
-.I file1
-and
-.I file3
-in overlap reports.
-.SH DIAGNOSTICS
-Exit status is 0 for no overlaps, 1 for some overlaps, 2 for trouble.
-.SH IDENTIFICATION
-Author: Walter F. Tichy.
-.br
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by Paul Eggert.
-.SH SEE ALSO
-diff3(1), diff(1), rcsmerge(1), co(1).
diff --git a/gnu/usr.bin/rcs/merge/merge.c b/gnu/usr.bin/rcs/merge/merge.c
deleted file mode 100644
index 4067c18..0000000
--- a/gnu/usr.bin/rcs/merge/merge.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* merge - three-way file merge */
-
-/* Copyright 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-#include "rcsbase.h"
-
-
-static char const usage[] =
- "\nmerge: usage: merge [-p] [-q] [-L label1 [-L label3]] file1 file2 file3\n";
-
- static exiting void
-badoption(a)
- char const *a;
-{
- faterror("unknown option: %s%s", a-2, usage);
-}
-
-
-mainProg(mergeId, "merge", "$Id: merge.c,v 1.2 1991/08/19 03:13:55 eggert Exp $")
-{
- register char const *a;
- char const *label[2], *arg[3];
- int labels, tostdout;
-
- labels = 0;
- tostdout = false;
-
- while ((a = *++argv) && *a++ == '-') {
- switch (*a++) {
- case 'p': tostdout = true; break;
- case 'q': quietflag = true; break;
- case 'L':
- if (1<labels)
- faterror("too many -L options");
- if (!(label[labels++] = *++argv))
- faterror("-L needs following argument");
- --argc;
- break;
- default:
- badoption(a);
- }
- if (*a)
- badoption(a);
- --argc;
- }
-
- 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];
-
- switch (labels) {
- case 0: label[0] = arg[0]; /* fall into */
- case 1: label[1] = arg[2];
- }
-
- exitmain(merge(tostdout, label, arg));
-}
-
-
-#if lint
-# define exiterr mergeExit
-#endif
- exiting 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 e3cd12e..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 9866a9c..0000000
--- a/gnu/usr.bin/rcs/rcs/rcs.1
+++ /dev/null
@@ -1,397 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: rcs.1,v 5.6 1991/09/26 23:16:17 eggert Exp $
-.ds r \&\s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.TH RCS 1 \*(Dt GNU
-.SH NAME
-rcs \- change RCS file attributes
-.SH SYNOPSIS
-.B rcs
-.RI [ " 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
-sets the comment leader to
-.IR string .
-The comment leader
-is printed before every log message line generated by the keyword
-.B $\&Log$
-during checkout (see
-.BR co (1)).
-This is useful for programming
-languages without multi-line comments.
-An initial
-.B ci ,
-or an
-.B "rcs\ \-i"
-without
-.BR \-c ,
-guesses the comment leader from the suffix of the working file.
-.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.
-A lock is removed with
-.B ci
-or
-.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 may 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
-\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 may 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
-.I 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 may not 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
-.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.
-.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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by Paul Eggert.
-.SH "SEE ALSO"
-co(1), ci(1), ident(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
-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 70e7ffc..0000000
--- a/gnu/usr.bin/rcs/rcs/rcs.c
+++ /dev/null
@@ -1,1554 +0,0 @@
-/*
- * RCS create/change operation
- */
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/* $Log: rcs.c,v $
- * 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 buildeltatext P((struct hshentries const*));
-static int removerevs P((void));
-static int sendmail P((char const*,char const*));
-static struct Lockrev *rmnewlocklst P((struct Lockrev const*));
-static void breaklock P((struct hshentry const*));
-static void buildtree P((void));
-static void cleanup P((void));
-static void doaccess P((void));
-static void doassoc P((void));
-static void dolocks P((void));
-static void domessages 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 rcs_setstate P((char const*,char const*));
-static void scanlogtext P((struct hshentry*,int));
-static void setlock P((char const*));
-
-static struct buf numrev;
-static char const *headstate;
-static int chgheadstate, exitstatus, lockhead, unlockcaller;
-static struct Lockrev *newlocklst, *rmvlocklst;
-static struct Message *messagelst, *lastmessage;
-static struct Status *statelst, *laststate;
-static struct Symrev *assoclst, *lastassoc;
-static struct chaccess *chaccess, **nextchaccess;
-static struct delrevpair delrev;
-static struct hshentry *cuthead, *cuttail, *delstrt;
-static struct hshentries *gendeltas;
-
-mainProg(rcsId, "rcs", "$Id: rcs.c,v 5.12 1991/11/20 17:58:08 eggert Exp $")
-{
- static char const cmdusage[] =
- "\nrcs usage: rcs -{ae}logins -Afile -{blu}[rev] -cstring -{iLU} -{nNs}name[:rev] -orange -t[file] -Vn file ...";
-
- char *a, **newargv, *textfile;
- char const *branchsym, *commsyml;
- int branchflag, expmode, initflag;
- int e, r, strictlock, strict_selected, textflag;
- mode_t defaultRCSmode; /* default mode for new RCS files */
- mode_t RCSmode;
- struct buf branchnum;
- struct stat workstat;
- struct Lockrev *curlock, * rmvlock, *lockpt;
- struct Status * curstate;
-
- nosetid();
-
- nextchaccess = &chaccess;
- branchsym = commsyml = textfile = nil;
- branchflag = strictlock = false;
- bufautobegin(&branchnum);
- curlock = rmvlock = nil;
- defaultRCSmode = 0;
- expmode = -1;
- suffixes = X_DEFAULT;
- initflag= textflag = false;
- strict_selected = 0;
-
- /* preprocessing command options */
- 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;
- break;
-
- case 'a': /* add new accessor */
- getaccessor(*argv+1, append);
- break;
-
- case 'A': /* append access list according to accessfile */
- if (!*a) {
- error("missing file name after -A");
- break;
- }
- *argv = a;
- if (0 < pairfilenames(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;
- }
- lockpt = talloc(struct Lockrev);
- lockpt->revno = a;
- lockpt->nextrev = nil;
- if ( curlock )
- curlock->nextrev = lockpt;
- else
- newlocklst = lockpt;
- curlock = lockpt;
- break;
-
- case 'u': /* release lock of a locked revision */
- if (!*a) {
- unlockcaller=true;
- break;
- }
- lockpt = talloc(struct Lockrev);
- lockpt->revno = a;
- lockpt->nextrev = nil;
- if (rmvlock)
- rmvlock->nextrev = lockpt;
- else
- rmvlocklst = lockpt;
- rmvlock = lockpt;
-
- curlock = rmnewlocklst(lockpt);
- break;
-
- case 'L': /* set strict locking */
- if (strict_selected++) { /* Already selected L or U? */
- if (!strictlock) /* Already selected -U? */
- warn("-L overrides -U.");
- }
- strictlock = true;
- break;
-
- case 'U': /* release strict locking */
- if (strict_selected++) { /* Already selected L or U? */
- if (strictlock) /* Already selected -L? */
- warn("-L overrides -U.");
- }
- else
- strictlock = false;
- 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 '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 'I':
- interactiveflag = true;
- break;
-
- case 'q':
- quietflag = true;
- break;
-
- case 'x':
- suffixes = a;
- break;
-
- case 'V':
- setRCSversion(*argv);
- break;
-
- case 'k': /* set keyword expand mode */
- if (0 <= expmode) redefined('k');
- if (0 <= (expmode = str2expmode(a)))
- break;
- /* fall into */
- default:
- faterror("unknown option: %s%s", *argv, cmdusage);
- };
- } /* end processing of options */
-
- if (argc<1) faterror("no input file%s", cmdusage);
- if (nerror) {
- diagnose("%s aborted\n",cmdid);
- exitmain(EXIT_FAILURE);
- }
- if (initflag) {
- defaultRCSmode = umask((mode_t)0);
- VOID umask(defaultRCSmode);
- defaultRCSmode = (S_IRUSR|S_IRGRP|S_IROTH) & ~defaultRCSmode;
- }
-
- /* now handle all filenames */
- do {
- ffree();
-
- if ( initflag ) {
- switch (pairfilenames(argc, argv, rcswriteopen, false, false)) {
- case -1: break; /* not exist; ok */
- case 0: continue; /* error */
- case 1: error("file %s exists already", RCSfilename);
- continue;
- }
- }
- else {
- switch (pairfilenames(argc, argv, rcswriteopen, true, false)) {
- case -1: continue; /* not exist */
- case 0: continue; /* errors */
- case 1: break; /* file exists; ok*/
- }
- }
-
-
- /* now RCSfilename contains the name of the RCS file, and
- * workfilename 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", RCSfilename);
-
- RCSmode = defaultRCSmode;
- if (initflag) {
- if (stat(workfilename, &workstat) == 0)
- RCSmode = workstat.st_mode;
- } else {
- if (!checkaccesslist()) continue;
- gettree(); /* Read the delta tree. */
- RCSmode = RCSstat.st_mode;
- }
- RCSmode &= ~(S_IWUSR|S_IWGRP|S_IWOTH);
-
- /* update admin. node */
- if (strict_selected) StrictLocks = strictlock;
- if (commsyml) {
- Comment.string = commsyml;
- Comment.size = strlen(commsyml);
- }
- if (0 <= expmode) Expand = expmode;
-
- /* update default branch */
- if (branchflag && expandsym(branchsym, &branchnum)) {
- if (countnumflds(branchnum.string)) {
- Dbranch = branchnum.string;
- } else
- Dbranch = nil;
- }
-
- doaccess(); /* Update access list. */
-
- doassoc(); /* Update association list. */
-
- dolocks(); /* Update locks. */
-
- domessages(); /* Update log messages. */
-
- /* update state attribution */
- if (chgheadstate) {
- /* change state of default branch or head */
- if (Dbranch==nil) {
- if (Head==nil)
- warn("can't change states in an empty tree");
- else Head->state = headstate;
- } else {
- rcs_setstate(Dbranch,headstate); /* Can't set directly */
- }
- }
- curstate = statelst;
- while( curstate ) {
- rcs_setstate(curstate->revno,curstate->status);
- curstate = curstate->nextstatus;
- }
-
- cuthead = cuttail = nil;
- if (delrev.strt && removerevs()) {
- /* rebuild delta tree if some deltas are deleted */
- if ( cuttail )
- VOID genrevs(cuttail->num, (char *)nil,(char *)nil,
- (char *)nil, &gendeltas);
- buildtree();
- }
-
- if (nerror)
- continue;
-
- putadmin(frewrite);
- if ( Head )
- puttree(Head, frewrite);
- putdesc(textflag,textfile);
-
- if ( Head) {
- if (!delrev.strt && !messagelst) {
- /* No revision was deleted and no message was changed. */
- fastcopy(finptr, frewrite);
- } else {
- if (!cuttail || buildeltatext(gendeltas)) {
- advise_access(finptr, MADV_SEQUENTIAL);
- scanlogtext((struct hshentry *)nil, false);
- /* copy rest of delta text nodes that are not deleted */
- }
- }
- }
- Izclose(&finptr);
- if ( ! nerror ) { /* move temporary file to RCS file if no error */
- /* update mode */
- ignoreints();
- r = chnamemod(&frewrite, newRCSfilename, RCSfilename, RCSmode);
- e = errno;
- keepdirtemp(newRCSfilename);
- restoreints();
- if (r != 0) {
- enerror(e, RCSfilename);
- error("saved in %s", newRCSfilename);
- dirtempunlink();
- break;
- }
- diagnose("done\n");
- } else {
- diagnose("%s aborted; %s unchanged.\n",cmdid,RCSfilename);
- }
- } while (cleanup(),
- ++argv, --argc >=1);
-
- tempunlink();
- exitmain(exitstatus);
-} /* end of main (rcs) */
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- Ozclose(&fcopy);
- Ozclose(&frewrite);
- dirtempunlink();
-}
-
- exiting void
-exiterr()
-{
- 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') ;
- temp = sp;
- sp = checkid(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 = nil;
- else {
- while( (c = *++sp) == ' ' || c == '\n' || c == '\t') ;
- pt->revno = sp;
- }
- pt->nextsym = nil;
- if (lastassoc)
- lastassoc->nextsym = pt;
- else
- assoclst = pt;
- lastassoc = pt;
- return;
-}
-
-
- static void
-getchaccess(login, command)
- char const *login;
- enum changeaccess command;
-{
- register struct chaccess *pt;
-
- *nextchaccess = pt = talloc(struct chaccess);
- pt->login = login;
- pt->command = command;
- pt->nextchaccess = nil;
- 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 == ',') ;
- if ( c == '\0') {
- if (command == erase && sp-opt == 1) {
- getchaccess((char const*)nil, 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;
- if (lastmessage)
- lastmessage->nextmessage = pt;
- else
- messagelst = pt;
- lastmessage = pt;
-}
-
-
- 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') ;
- 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') ;
- pt = talloc(struct Status);
- pt->status = temp;
- pt->revno = sp;
- pt->nextstatus = nil;
- if (laststate)
- laststate->nextstatus = pt;
- else
- statelst = pt;
- laststate = pt;
-}
-
-
-
- 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') ;
-
- /* 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') ;
- pt->strt = sp; pt->code = 1;
- while( c != ' ' && c != '\n' && c != '\t' && c != '\0') c =(*++sp);
- *sp = '\0';
- pt->end = nil;
- 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->end = nil; pt->code = 0;
- return;
- }
- if (c != separator) {
- faterror("invalid range %s %s after -o", pt->strt, sp);
- }
- while( (c = *++sp) == ' ' || c == '\n' || c == '\t') ;
- if (!c) { /* -orev: */
- pt->end = nil; pt->code = 2;
- 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==nil.
- * For the one given by delta (if delta!=nil), 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==nil.
- */
-{
- struct hshentry const *nextdelta;
- struct cbuf cb;
-
- for (;;) {
- foutptr = 0;
- if (eoflex()) {
- if(delta)
- faterror("can't find delta for revision %s", delta->num);
- return; /* no more delta text nodes */
- }
- nextlex();
- if (!(nextdelta=getnum()))
- faterror("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);
- } else if (nextdelta->log.string && nextdelta->selector) {
- foutptr = 0;
- readstring();
- foutptr = frewrite;
- putstring(foutptr, false, nextdelta->log, true);
- afputc(nextc, foutptr);
- } else {readstring();
- }
- nextlex();
- while (nexttok==ID && strcmp(NextString,Ktext)!=0)
- ignorephrase();
- getkeystring(Ktext);
-
- if (delta==nextdelta)
- break;
- readstring(); /* skip over it */
-
- }
- /* got the one we're looking for */
- if (edit)
- editstring((struct hshentry *)nil);
- else
- enterstring();
-}
-
-
-
- static struct Lockrev *
-rmnewlocklst(which)
- struct Lockrev const *which;
-/* Function: remove lock to revision which->revno from newlocklst */
-
-{
- struct Lockrev * pt, *pre;
-
- while( newlocklst && (! strcmp(newlocklst->revno, which->revno))){
- struct Lockrev *pn = newlocklst->nextrev;
- tfree(newlocklst);
- newlocklst = pn;
- }
-
- pt = pre = newlocklst;
- while( pt ) {
- if ( ! strcmp(pt->revno, which->revno) ) {
- pre->nextrev = pt->nextrev;
- tfree(pt);
- pt = pre->nextrev;
- }
- else {
- pre = pt;
- pt = pt->nextrev;
- }
- }
- return pre;
-}
-
-
-
- static void
-doaccess()
-{
- register struct chaccess *ch;
- register struct access **p, *t;
-
- for (ch = chaccess; ch; ch = ch->nextchaccess) {
- switch (ch->command) {
- case erase:
- if (!ch->login)
- AccessList = nil;
- else
- for (p = &AccessList; (t = *p); )
- if (strcmp(ch->login, t->login) == 0)
- *p = t->nextaccess;
- else
- p = &t->nextaccess;
- break;
- case append:
- for (p = &AccessList; ; p = &t->nextaccess)
- if (!(t = *p)) {
- *p = t = ftalloc(struct access);
- t->login = ch->login;
- t->nextaccess = nil;
- break;
- } else if (strcmp(ch->login, t->login) == 0)
- break;
- break;
- }
- }
-}
-
-
- 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;
- FILE * mailmess;
-#endif
-
-
- aprintf(stderr, "Revision %s is already locked by %s.\n", Delta, who);
- 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 = fopen(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",
- basename(RCSfilename), Delta, getfullRCSname(), getcaller()
- );
- aputs("State the reason for breaking the lock:\n(terminate with single '.' or end of file)\n>> ", stderr);
-
- 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);
- }
- }
- Ozclose(&mailmess);
-
- if (run(messagefile, (char*)nil, SENDMAIL, who, (char*)nil))
- warn("Mail may have failed."),
-#else
- warn("Mail notification of broken locks is not available."),
-#endif
- warn("Please tell `%s' why you broke the lock.", who);
- return(true);
-}
-
-
-
- static void
-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 lock * next, * trail;
- char const *num;
- struct lock dummy;
-
- num=delta->num;
- dummy.nextlock=next=Locks;
- trail = &dummy;
- while (next!=nil) {
- if (strcmp(num, next->delta->num) == 0) {
- if (
- strcmp(getcaller(),next->login) != 0
- && !sendmail(num, next->login)
- ) {
- error("%s still locked by %s", num, next->login);
- return;
- }
- break; /* exact match */
- }
- trail=next;
- next=next->nextlock;
- }
- if (next!=nil) {
- /*found one */
- diagnose("%s unlocked\n",next->delta->num);
- trail->nextlock=next->nextlock;
- next->delta->lockedby=nil;
- Locks=dummy.nextlock;
- } else {
- error("no lock set on revision %s", num);
- }
-}
-
-
-
- static struct hshentry *
-searchcutpt(object, length, store)
- char const *object;
- unsigned length;
- struct hshentries *store;
-/* Function: Search store and return entry with number being object. */
-/* cuttail = nil, if the entry is Head; otherwise, cuttail */
-/* is the entry point to the one with number being object */
-
-{
- cuthead = nil;
- 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 lock const *lockpt;
- int flag;
-
-
- pt = strt;
- flag = false;
- while( pt != tail) {
- if ( pt->branches ){ /* a branch point */
- flag = true;
- error("can't remove branch point %s", pt->num);
- }
- lockpt = Locks;
- while(lockpt && lockpt->delta != pt)
- lockpt = lockpt->nextlock;
- if ( lockpt ) {
- flag = true;
- error("can't remove locked revision %s",pt->num);
- }
- pt = pt->next;
- }
-
- if ( ! flag ) {
- pt = strt;
- while( pt != tail ) {
- pt->selector = false;
- diagnose("deleting revision %s\n",pt->num);
- pt = pt->next;
- }
- }
- return flag;
-}
-
-
-
- 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( nil, if delstrt is head), and the */
-/* revision after the last removed revision in cuttail(nil */
-/* if the last is a leaf */
-
-{
- struct hshentry *target, *target2, *temp;
- unsigned length;
- int flag;
-
- flag = false;
- if (!expandsym(delrev.strt, &numrev)) return 0;
- target = genrevs(numrev.string, (char*)nil, (char*)nil, (char*)nil, &gendeltas);
- if ( ! target ) return 0;
- if (cmpnum(target->num, numrev.string)) flag = true;
- 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 (flag) {
- error("Revision %s doesn't exist.", numrev.string);
- return 0;
- }
- else
- temp = searchcutpt(numrev.string, length, gendeltas);
- cuttail = target->next;
- if ( branchpoint(temp, cuttail) ) {
- cuttail = nil;
- return 0;
- }
- delstrt = temp; /* first revision to be removed */
- return 1;
- }
-
- if (length & 1) { /* invalid branch after -o */
- error("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 = nil;
- return 0;
- }
- delstrt = temp;
- return 1;
- }
-
- if (delrev.code == 2) { /* -o rev- */
- if ( length == 2 ) {
- temp = searchcutpt(target->num, 1,gendeltas);
- if ( flag)
- cuttail = target;
- else
- cuttail = target->next;
- }
- else {
- if ( flag){
- cuthead = target;
- if ( !(temp = target->next) ) return 0;
- }
- else
- temp = searchcutpt(target->num, length, gendeltas);
- getbranchno(temp->num, &numrev); /* get branch number */
- target = genrevs(numrev.string, (char*)nil, (char*)nil, (char*)nil, &gendeltas);
- }
- if ( branchpoint( temp, cuttail ) ) {
- cuttail = nil;
- 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)
- ) {
- error("invalid revision range %s-%s", target->num, numrev.string);
- return 0;
- }
-
- target2 = genrevs(numrev.string,(char*)nil,(char*)nil,(char*)nil,&gendeltas);
- if ( ! target2 ) return 0;
-
- if ( length > 2) { /* delete revisions on branches */
- if ( cmpnum(target->num, target2->num) > 0) {
- if (cmpnum(target2->num, numrev.string))
- flag = true;
- else
- flag = false;
- temp = target;
- target = target2;
- target2 = temp;
- }
- if ( flag ) {
- if ( ! cmpnum(target->num, target2->num) ) {
- error("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
- if (cmpnum(target2->num, numrev.string))
- flag = true;
- else
- flag = false;
- if ( flag ) {
- if ( ! cmpnum(target->num, target2->num) ) {
- error("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 = nil;
- return 0;
- }
- delstrt = temp;
- return 1;
-}
-
-
-
- static void
-doassoc()
-/* Function: add or delete(if revno is nil) association */
-/* which is stored in assoclst */
-
-{
- char const *p;
- struct Symrev const *curassoc;
- struct assoc * pre, * pt;
-
- /* add new associations */
- curassoc = assoclst;
- while( curassoc ) {
- if ( curassoc->revno == nil ) { /* delete symbol */
- pre = pt = Symbols;
- while( pt && strcmp(pt->symbol,curassoc->ssymbol) ) {
- pre = pt;
- pt = pt->nextassoc;
- }
- if ( pt )
- if ( pre == pt )
- Symbols = pt->nextassoc;
- else
- pre->nextassoc = pt->nextassoc;
- else
- warn("can't delete nonexisting symbol %s",curassoc->ssymbol);
- }
- else {
- if (curassoc->revno[0]) {
- p = 0;
- if (expandsym(curassoc->revno, &numrev))
- p = fstr_save(numrev.string);
- } else if (!(p = tiprev()))
- error("no latest revision to associate with symbol %s",
- curassoc->ssymbol
- );
- if (p)
- VOID addsymbol(p, curassoc->ssymbol, curassoc->override);
- }
- curassoc = curassoc->nextsym;
- }
-
-}
-
-
-
- static void
-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;
-
- if (unlockcaller) { /* find lock for caller */
- if ( Head ) {
- if (Locks) {
- switch (findlock(true, &target)) {
- case 0:
- breaklock(Locks->delta); /* remove most recent lock */
- break;
- case 1:
- diagnose("%s unlocked\n",target->num);
- break;
- }
- } else {
- warn("No locks are set.");
- }
- } else {
- warn("can't unlock an empty tree");
- }
- }
-
- /* remove locks which are stored in rmvlocklst */
- lockpt = rmvlocklst;
- while( lockpt ) {
- if (expandsym(lockpt->revno, &numrev)) {
- target = genrevs(numrev.string, (char *)nil, (char *)nil, (char *)nil, &gendeltas);
- if ( target )
- if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
- error("can't unlock nonexisting revision %s",lockpt->revno);
- else
- breaklock(target);
- /* breaklock does its own diagnose */
- }
- lockpt = lockpt->nextrev;
- }
-
- /* add new locks which stored in newlocklst */
- lockpt = newlocklst;
- while( lockpt ) {
- setlock(lockpt->revno);
- lockpt = lockpt->nextrev;
- }
-
- if (lockhead) { /* lock default branch or head */
- if (Dbranch) {
- setlock(Dbranch);
- } else if (Head) {
- if (0 <= addlock(Head))
- diagnose("%s locked\n",Head->num);
- } else {
- warn("can't lock an empty tree");
- }
- }
-
-}
-
-
-
- static void
-setlock(rev)
- char const *rev;
-/* Function: Given a revision or branch number, finds the corresponding
- * delta and locks it for caller.
- */
-{
- struct hshentry *target;
-
- if (expandsym(rev, &numrev)) {
- target = genrevs(numrev.string, (char*)nil, (char*)nil,
- (char*)nil, &gendeltas);
- if ( target )
- if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
- error("can't lock nonexisting revision %s", numrev.string);
- else
- if (0 <= addlock(target))
- diagnose("%s locked\n", target->num);
- }
-}
-
-
- static void
-domessages()
-{
- struct hshentry *target;
- struct Message *p;
-
- for (p = messagelst; p; p = p->nextmessage)
- if (
- expandsym(p->revno, &numrev) &&
- (target = genrevs(
- numrev.string, (char*)0, (char*)0, (char*)0, &gendeltas
- ))
- )
- target->log = p->message;
-}
-
-
- static void
-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*)nil, (char*)nil,
- (char*)nil, &gendeltas);
- if ( target )
- if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
- error("can't set state of nonexisting revision %s to %s",
- numrev.string, status);
- else
- target->state = status;
- }
-}
-
-
-
-
-
- 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 *cutfilename, *diffilename;
-
- cutfilename = nil;
- cuttail->selector = false;
- scanlogtext(deltas->first, false);
- if ( cuthead ) {
- cutfilename = maketemp(3);
- if (!(fcut = fopen(cutfilename, FOPEN_W_WORK))) {
- efaterror(cutfilename);
- }
-
- while (deltas->first != cuthead) {
- deltas = deltas->rest;
- scanlogtext(deltas->first, true);
- }
-
- snapshotedit(fcut);
- Ofclose(fcut);
- }
-
- while (deltas->first != cuttail)
- scanlogtext((deltas = deltas->rest)->first, true);
- finishedit((struct hshentry *)nil, (FILE*)0, true);
- Ozclose(&fcopy);
-
- if ( cuthead ) {
- diffilename = maketemp(0);
- switch (run((char*)nil,diffilename,
- DIFF DIFF_FLAGS, cutfilename, resultfile, (char*)nil
- )) {
- case DIFF_FAILURE: case DIFF_SUCCESS: break;
- default: faterror ("diff failed");
- }
- return putdtext(cuttail->num,cuttail->log,diffilename,frewrite,true);
- } else
- return putdtext(cuttail->num,cuttail->log,resultfile,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 == nil && !quietflag) {
- if (!yesorno(false, "Do you really want to delete all revisions? [ny](n): ")) {
- error("No revision deleted");
- Delta = delstrt;
- while( Delta) {
- Delta->selector = true;
- Delta = Delta->next;
- }
- return;
- }
- }
- Head = cuttail;
- }
- return;
-}
-
-#if 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 d0dbbb8..0000000
--- a/gnu/usr.bin/rcs/rcs/rcsfile.5
+++ /dev/null
@@ -1,224 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: rcsfile.5,v 5.1 1991/08/19 03:13:55 eggert Exp $
-.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, an \*r file must end in a newline character.
-.PP
-Strings are enclosed by
-.BR @ .
-If a string contains a
-.BR @ ,
-it must be doubled;
-otherwise, strings may contain arbitrary binary data.
-.PP
-The meta syntax uses the following conventions: `|' (bar) separates
-alternatives; `{' and `}' enclose optional phrases; `{' and `}*' enclose
-phrases that may be repeated zero or more times;
-`{' and '}+' enclose phrases that must appear at least once and may be
-repeated;
-Terminal symbols are in
-.BR boldface ;
-nonterminal symbols are in
-.IR italics .
-.LP
-.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 \w'\f2deltatext\fP 'u +\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 {\f2id\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 | .\|.\|. | \f39\fP
-.LP
-\f2id\fP ::= \f2letter\fP{\f2idchar\fP}*
-.LP
-\f2letter\fP ::= any letter
-.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 may overlap.
-In most environments RCS uses the ISO 8859/1 encoding:
-letters are octal codes 101\-132, 141\-172, 300\-326, 330\-366 and 370-377,
-visible graphic characters are codes 041\-176 and 240\-377,
-and white space characters are codes 010\-015 and 040.
-.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
-.nf
-.vs 12
-.ne 38
-Example:
-.if t .in +0.5i
-.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
-.if t .in
-.cs 1
-.ce
-Fig. 1: A revision tree
-.vs
-.fi
-.PP
-.SH IDENTIFICATION
-.de VL
-\\$2
-..
-Author: Walter F. Tichy,
-Purdue University, West Lafayette, IN, 47907.
-.br
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by Paul Eggert.
-.SH SEE ALSO
-ci(1), co(1), ident(1), rcs(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 a76caa0..0000000
--- a/gnu/usr.bin/rcs/rcs/rcsintro.1
+++ /dev/null
@@ -1,292 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: rcsintro.1,v 5.1 1991/04/21 12:00:46 eggert Exp $
-.ds r \&\s-1RCS\s0
-.if n .ds - \%--
-.if t .ds - \(em
-.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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by 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 2651a3f..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 07ed722..0000000
--- a/gnu/usr.bin/rcs/rcsclean/rcsclean.1
+++ /dev/null
@@ -1,177 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: rcsclean.1,v 1.8 1991/11/03 01:09:19 eggert Exp $
-.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 working files that were checked out and never modified.
-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
-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.
-Names are paired as explained in
-.BR ci (1).
-.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 asks whether to check in a file
-if it 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
-.BR \-u [\f2rev\fP]
-Unlock the revision if it is locked and no difference is found.
-.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.
-.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 ,
-and
-.BR \-x .
-.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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by 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 ba24ab7..0000000
--- a/gnu/usr.bin/rcs/rcsclean/rcsclean.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/* rcsclean - clean up working files */
-
-/* Copyright 1991 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, 675 Mass Ave, Cambridge, MA 02139, 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: rcsclean.c,v 5.1 1991/11/03 01:11:44 eggert Exp $")
-{
- static char const usage[] =
- "\nrcsclean: usage: rcsclean [-ksubst] [-{nqru}[rev]] [-Vn] [-xsuffixes] [file ...]";
-
- static struct buf revision;
-
- char *a, **newargv;
- char const *rev, *p;
- int changelock, expmode, perform, unlocked, unlockflag, waslocked;
- struct hshentries *deltas;
- struct hshentry *delta;
- struct stat workstat;
-
- setrid();
-
- expmode = -1;
- rev = nil;
- suffixes = X_DEFAULT;
- perform = true;
- unlockflag = false;
-
- argc = getRCSINIT(argc, argv, &newargv);
- argv = newargv;
- for (;;) {
- if (--argc <= 0) {
-# if has_dirent
- argc = get_directory(".", &newargv);
- argv = newargv;
- break;
-# else
- faterror("no file names specified");
-# endif
- }
- a = *++argv;
- if (*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 'u':
- unlockflag = true;
- goto handle_revision;
-
- case 'V':
- setRCSversion(*argv);
- break;
-
- case 'x':
- suffixes = a;
- break;
-
- default:
- unknown:
- faterror("unknown option: %s%s", *argv, usage);
- }
- }
-
- do {
- ffree();
-
- if (!(
- 0 < pairfilenames(
- argc, argv,
- unlockflag&perform ? rcswriteopen : rcsreadopen,
- true, true
- ) &&
- (workptr = Iopen(workfilename,FOPEN_R_WORK,&workstat))
- ))
- 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;
- changelock = unlocked & perform;
- if (unlocked<waslocked && workstat.st_mode&(S_IWUSR|S_IWGRP|S_IWOTH))
- continue;
-
- if (!dorewrite(unlockflag, changelock))
- 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, RCSfilename);
-
- if_advise_access(changelock && deltas->first != delta,
- finptr, MADV_SEQUENTIAL
- );
- if (!donerewrite(changelock))
- continue;
-
- if (!quietflag)
- aprintf(stdout, "rm -f %s\n", workfilename);
- Izclose(&workptr);
- if (perform && un_link(workfilename) != 0)
- eerror(workfilename);
-
- } while (cleanup(), ++argv, 0 < --argc);
-
- tempunlink();
- if (!quietflag)
- Ofclose(stdout);
- exitmain(exitstatus);
-}
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
- Izclose(&workptr);
- Ozclose(&fcopy);
- Ozclose(&frewrite);
- dirtempunlink();
-}
-
-#if lint
-# define exiterr rcscleanExit
-#endif
- exiting void
-exiterr()
-{
- dirtempunlink();
- tempunlink();
- _exit(EXIT_FAILURE);
-}
-
- static int
-unlock(delta)
- struct hshentry *delta;
-{
- register struct lock **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 (errno || closedir(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 070e231..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 b78bbdd..0000000
--- a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1
+++ /dev/null
@@ -1,152 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: rcsdiff.1,v 5.3 1991/04/21 12:00:46 eggert Exp $
-.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
-] ] [
-.BI \-V n
-] [
-.BI \-x suffixes
-] [
-.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
-.B \-V
-and
-.BR \-x .
-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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by 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 7155c8d..0000000
--- a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * RCS rcsdiff operation
- */
-/*****************************************************************************
- * generate difference between RCS revisions
- *****************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/* $Log: rcsdiff.c,v $
- * 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: rcsdiff.c,v 5.10 1991/10/07 17:32:46 eggert Exp $")
-{
- static char const cmdusage[] =
- "\nrcsdiff usage: rcsdiff [-q] [-rrev1 [-rrev2]] [-Vn] [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, *versionarg;
-#if DIFF_L
- static struct buf labelbuf[2];
- int file_labels;
- char const **diff_label1, **diff_label2;
- char date2[datesize];
-#endif
- char const *cov[9];
- char const **diffv, **diffp; /* 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;
- register c;
-
- exitstatus = DIFF_SUCCESS;
-
- bufautobegin(&commarg);
- bufautobegin(&numericrev);
- revnums = 0;
- rev1 = rev2 = xrev2 = nil;
-#if DIFF_L
- file_labels = 0;
-#endif
- expandarg = versionarg = 0;
- suffixes = X_DEFAULT;
-
- /* Room for args + 2 i/o [+ 2 labels] + 1 file + 1 trailing null. */
- diffp = diffv = tnalloc(char const*, argc + 4 + 2*DIFF_L);
- *diffp++ = nil;
- *diffp++ = nil;
- *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: faterror("too many revision numbers");
- }
- goto option_handled;
-#if DIFF_L
- case 'L':
- if (++file_labels == 2)
- faterror("too many -L options");
- /* fall into */
-#endif
- case 'C': case 'D': case 'F': case 'I':
- *dcp++ = c;
- if (*a)
- do *dcp++ = *a++;
- while (*a);
- else {
- if (!--argc)
- faterror("-%c needs following argument%s",
- c, cmdusage
- );
- *diffp++ = *argv++;
- }
- break;
- case 'B': case 'H': case 'T':
- 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':
- suffixes = *argv + 2;
- goto option_handled;
- case 'V':
- versionarg = *argv;
- setRCSversion(versionarg);
- goto option_handled;
- case 'k':
- expandarg = *argv;
- if (0 <= str2expmode(expandarg+2))
- goto option_handled;
- /* fall into */
- default:
- faterror("unknown option: %s%s", *argv, cmdusage);
- };
- option_handled:
- if (dcp != *argv+1) {
- *dcp = 0;
- *diffp++ = *argv;
- }
- } /* end of option processing */
-
- if (argc<1) faterror("no input file%s", cmdusage);
-
- for (pp = diffv+3, c = 0; pp<diffp; )
- c += strlen(*pp++) + 1;
- diffvstr = a = tnalloc(char, c + 1);
- for (pp = diffv+3; pp<diffp; ) {
- p = *pp++;
- *a++ = ' ';
- while ((*a = *p++))
- a++;
- }
- *a = 0;
-
-#if DIFF_L
- diff_label1 = diff_label2 = nil;
- if (file_labels < 2) {
- if (!file_labels)
- diff_label1 = diffp++;
- diff_label2 = diffp++;
- }
-#endif
- diffp[2] = nil;
-
- cov[0] = 0;
- cov[2] = CO;
- cov[3] = "-q";
-
- /* now handle all filenames */
- do {
- ffree();
-
- if (pairfilenames(argc, argv, rcsreadopen, true, false) <= 0)
- continue;
- diagnose("===================================================================\nRCS file: %s\n",RCSfilename);
- if (!rev2) {
- /* Make sure work file is readable, and get its status. */
- if (!(workptr = Iopen(workfilename,FOPEN_R_WORK,&workstat))) {
- eerror(workfilename);
- continue;
- }
- }
-
-
- gettree(); /* reads in the delta tree */
-
- if (Head==nil) {
- error("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 *)nil,(char *)nil,(char *)nil,&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 *)nil,(char *)nil,(char *)nil,&gendeltas))) continue;
- xrev2=target->num;
- } 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], workfilename, date2);
- }
-#endif
-
- diagnose("retrieving revision %s\n", xrev1);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, xrev1);
-
- cov[1] = diffp[0] = maketemp(0);
- pp = &cov[4];
- *pp++ = commarg.string;
- if (lexpandarg)
- *pp++ = lexpandarg;
- if (versionarg)
- *pp++ = versionarg;
- *pp++ = RCSfilename;
- *pp = 0;
-
- if (runv(cov)) {
- error("co failed");
- continue;
- }
- if (!rev2) {
- diffp[1] = workfilename;
- if (workfilename[0] == '+') {
- /* Some diffs have options with leading '+'. */
- char *dp = ftnalloc(char, strlen(workfilename)+3);
- diffp[1] = dp;
- *dp++ = '.';
- *dp++ = SLASH;
- VOID strcpy(dp, workfilename);
- }
- } else {
- diagnose("retrieving revision %s\n",xrev2);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, xrev2);
- cov[1] = diffp[1] = maketemp(1);
- cov[4] = commarg.string;
- if (runv(cov)) {
- error("co failed");
- continue;
- }
- }
- if (!rev2)
- diagnose("diff%s -r%s %s\n", diffvstr, xrev1, workfilename);
- else
- diagnose("diff%s -r%s -r%s\n", diffvstr, xrev1, xrev2);
-
- switch (runv(diffv)) {
- case DIFF_SUCCESS:
- break;
- case DIFF_FAILURE:
- if (exitstatus == DIFF_SUCCESS)
- exitstatus = DIFF_FAILURE;
- break;
- default:
- error("diff failed");
- }
- } while (cleanup(),
- ++argv, --argc >=1);
-
-
- tempunlink();
- exitmain(exitstatus);
-}
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = DIFF_TROUBLE;
- Izclose(&finptr);
- Izclose(&workptr);
-}
-
-#if lint
-# define exiterr rdiffExit
-#endif
- exiting void
-exiterr()
-{
- tempunlink();
- _exit(DIFF_TROUBLE);
-}
-
-#if DIFF_L
- static char const *
-setup_label(b, name, date)
- struct buf *b;
- char const *name;
- char const date[datesize];
-{
- char *p;
- size_t l = strlen(name) + 3;
- bufalloc(b, l+datesize);
- p = b->string;
- VOID sprintf(p, "-L%s\t", name);
- VOID date2str(date, p+l);
- return p;
-}
-#endif
diff --git a/gnu/usr.bin/rcs/rcsfreeze/Makefile b/gnu/usr.bin/rcs/rcsfreeze/Makefile
deleted file mode 100644
index c1b4841..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 be669a9..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: rcsfreeze.1,v 4.4 1990/11/13 15:43:42 hammer Exp $
-.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 4219979..0000000
--- a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#! /bin/sh
-
-# rcsfreeze - assign a symbolic revision number to a configuration of RCS files
-
-# $Id: rcsfreeze.sh,v 4.4 1991/04/21 11:58:24 eggert Exp $
-
-# 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=/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:/usr/ucb:$PATH
-export PATH
-
-DATE=`date` || exit
-# Check whether we have an RCS subdirectory, so we can have the right
-# prefix for our paths.
-if [ -d RCS ]
-then RCSDIR=RCS/
-else RCSDIR=
-fi
-
-# Version number stuff, log message file
-VERSIONFILE=${RCSDIR}.rcsfreeze.ver
-LOGFILE=${RCSDIR}.rcsfreeze.log
-# Initialize, rcsfreeze never run before in the current directory
-[ -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 || exit
-trap 1 2 13 15
-
-# Now the real work begins by assigning a symbolic revision number
-# to each rcs file. Take the most recent version of the main trunk.
-
-status=
-
-for FILE in ${RCSDIR}*
-do
-# get the revision number of the most recent revision
- HEAD=`rlog -h $FILE` &&
- REV=`echo "$HEAD" | sed -n 's/^head:[ ]*//p'` &&
-# assign symbolic name to it.
- echo >&2 "rcsfreeze: $REV $FILE" &&
- rcs -q -n$SYMREVNAME:$REV $FILE || status=$?
-done
-
-exit $status
diff --git a/gnu/usr.bin/rcs/rcsmerge/Makefile b/gnu/usr.bin/rcs/rcsmerge/Makefile
deleted file mode 100644
index 801b01e..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 82871b0..0000000
--- a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1
+++ /dev/null
@@ -1,140 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: rcsmerge.1,v 5.3 1991/08/19 03:13:55 eggert Exp $
-.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
-.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 .
-.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
-.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.
-.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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by 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 e5d4394..0000000
--- a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * rcsmerge operation
- */
-/*****************************************************************************
- * join 2 revisions with respect to a third
- *****************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-/* $Log: rcsmerge.c,v $
- * 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: rcsmerge.c,v 5.7 1991/11/20 17:58:09 eggert Exp $")
-{
- static char const cmdusage[] =
- "\nrcsmerge usage: rcsmerge -rrev1 [-rrev2] [-p] [-Vn] file";
- static char const quietarg[] = "-q";
-
- register int i;
- char *a, **newargv;
- char const *arg[3];
- char const *rev[2]; /*revision numbers*/
- char const *expandarg, *versionarg;
- 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);
- rev[0] = rev[1] = nil;
- status = 0; /* Keep lint happy. */
- tostdout = false;
- expandarg = versionarg = quietarg; /* i.e. a 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[0])
- rev[0] = a;
- else if (!rev[1])
- rev[1] = a;
- else
- faterror("too many revision numbers");
- break;
- case 'x':
- suffixes = a;
- break;
- case 'V':
- versionarg = *argv;
- setRCSversion(versionarg);
- break;
-
- case 'k':
- expandarg = *argv;
- if (0 <= str2expmode(expandarg+2))
- break;
- /* fall into */
- default:
- faterror("unknown option: %s%s", *argv, cmdusage);
- };
- } /* end of option processing */
-
- if (argc<1) faterror("no input file%s", cmdusage);
- if (!rev[0]) faterror("no base revision number given");
-
- /* now handle all filenames */
-
- if (0 < pairfilenames(argc, argv, rcsreadopen, true, false)) {
-
- if (argc>2 || (argc==2&&argv[1]!=nil))
- warn("too many arguments");
- diagnose("RCS file: %s\n", RCSfilename);
- if (!(workptr = Iopen(workfilename,
- FOPEN_R_WORK,
- (struct stat*)0
- )))
- efaterror(workfilename);
-
- gettree(); /* reads in the delta tree */
-
- if (Head==nil) faterror("no revisions present");
-
- if (!*rev[0])
- rev[0] = Dbranch ? Dbranch : Head->num;
- if (!fexpandsym(rev[0], &numericrev, workptr))
- goto end;
- if (!(target=genrevs(numericrev.string, (char *)nil, (char *)nil, (char *)nil,&gendeltas))) goto end;
- rev[0] = target->num;
- if (!rev[1] || !*rev[1])
- rev[1] = Dbranch ? Dbranch : Head->num;
- if (!fexpandsym(rev[1], &numericrev, workptr))
- goto end;
- if (!(target=genrevs(numericrev.string, (char *)nil, (char *)nil, (char *)nil,&gendeltas))) goto end;
- rev[1] = target->num;
-
- if (strcmp(rev[0],rev[1]) == 0) {
- if (tostdout) {
- FILE *o;
-# if text_equals_binary_stdio || text_work_stdio
- o = stdout;
-# else
- if (!(o=fdopen(STDOUT_FILENO,FOPEN_W_WORK)))
- efaterror("stdout");
-# endif
- fastcopy(workptr,o);
- Ofclose(o);
- }
- goto end;
- }
- Izclose(&workptr);
-
- for (i=0; i<2; i++) {
- diagnose("retrieving revision %s\n", rev[i]);
- bufscpy(&commarg, "-p");
- bufscat(&commarg, rev[i]);
- if (run(
- (char*)0,
- /* Do not collide with merger.c maketemp(). */
- arg[i+1] = maketemp(i+3),
- co, quietarg, commarg.string, expandarg,
- versionarg, RCSfilename, (char*)0
- ))
- faterror("co failed");
- }
- diagnose("Merging differences between %s and %s into %s%s\n",
- rev[0], rev[1], workfilename,
- tostdout?"; result to stdout":"");
-
- arg[0] = rev[0] = workfilename;
- status = merge(tostdout, rev, arg);
- }
-
-end:
- Izclose(&workptr);
- tempunlink();
- exitmain(nerror ? DIFF_TROUBLE : status);
-}
-
-#if lint
-# define exiterr rmergeExit
-#endif
- exiting 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 e0b6c82..0000000
--- a/gnu/usr.bin/rcs/rcstest
+++ /dev/null
@@ -1,397 +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: rcstest,v 5.8 1991/11/20 17:58:10 eggert Exp $
-
-
-# Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# Report problems and direct all questions to:
-#
-# rcs-bugs@cs.purdue.edu
-
-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
-
-test -d RCS || {
- echo >&2 "$0: RCS: not a directory; please \`mkdir RCS' first."
- exit 1
-}
-
-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 &&
-<$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 &&
-<$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; }
-
-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; }
-
-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; }
-
-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; }
-
-co -l $q a.c &&
-echo 1.5 >a.c &&
-ci -u -mm $q a.c &&
-<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
-date=`date -u 2>/dev/null` ||
-date=`TZ=GMT0 date 2>/dev/null` ||
-date=`TZ= date` || exit 2
-set $date
-case $2 in
-Jan) m=01;; Feb) m=02;; Mar) m=03;; Apr) m=04;; May) m=05;; Jun) m=06;;
-Jul) m=07;; Aug) m=08;; Sep) m=09;; Oct) m=10;; Nov) m=11;; Dec) m=12;;
-*) echo >&2 "$0: $2: unknown month name"; exit 2
-esac
-case $3 in
-?) d=0$3;;
-*) d=$3
-esac
-case $6 in
-[0-9][0-9][0-9][0-9]*) D=$6/$m/$d;;
-*)
- case $5 in
- [0-9][0-9][0-9][0-9]*) D=$5/$m/$d;;
- *) echo >&2 "$0: bad date format: $date"; exit 2
- esac
-esac
-T=$4
-case $PWD in
-'') PWD=`pwd`
-esac &&
-co -l $q a.c &&
-sed 's/@/$/g' >a.kv <<EOF
-@Author: w @
-@Date: $D $T @
-@Header: $PWD$SLASH$RCSfile 2.1 $D $T w s @
-@Id: a.c 2.1 $D $T w s @
-@Locker: @
-@Log: a.c @
- * Revision 2.1 $D $T w
- * m
- *
-@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 -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" -ss -ww -u2.1 -mm $q a.c &&
-$diff a.kv a.c || { echo "#keyword expansion failed"; exit 1; }
-co -p -ko $q a.c >a.oo &&
-$diff a.o a.oo || { echo "#co -p -ko failed"; exit 1; }
-cp a.kv a.o || exit 2
-rcs -o2.1 $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 '/^[^$]/d' 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; }
-
-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; }
-
-rcs -NN:2.1 $q a.c &&
-co -rN $q a.c &&
-$diff a.kv a.c || { echo "#rcs -N failed"; exit 1; }
-
-co -l $q a.c &&
-rcs -c':::' $q a.c &&
-echo '$''Log$' >a.c &&
-ci -u -mm $q a.c &&
-test " `sed '$!d' a.c`" = ' :::' || { echo "#rcs -c failed"; exit 1; }
-
-rcs -o2.2: $q a.c &&
-co $q a.c &&
-$diff a.kv a.c || { echo "#rcs -o failed"; exit 1; }
-
-rcsdiff -r1.1 -r2.1 $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 k kv kvl o v
-do
- rm -f a.c &&
- cp a.$i a.c &&
- rcsdiff -k$i $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 &&
-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 -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
-
-nl='
-'
-{
- co -p $q a.c | tr "$nl" '\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' "$nl" >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
- n: 1.8
-comment leader: ":::"
-keyword substitution: kv
-total revisions: 13; selected revisions: 1
-description:
-1.1
-----------------------------
-revision 2.1
-date: $D $T; author: w; state: s; lines: +13 -1
-=============================================================================
-EOF
-test $? = 0 || { echo "#rlog failed"; exit 1; }
-
-
-test ! -f $lockfile || { echo "#lock file not removed"; exit 1; }
-
-exec rm -f a.* $RCSfile $RCS_alt
diff --git a/gnu/usr.bin/rcs/rlog/Makefile b/gnu/usr.bin/rcs/rlog/Makefile
deleted file mode 100644
index a1d19aa..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 fa627ff..0000000
--- a/gnu/usr.bin/rcs/rlog/rlog.1
+++ /dev/null
@@ -1,260 +0,0 @@
-.de Id
-.ds Rv \\$3
-.ds Dt \\$4
-..
-.Id $Id: rlog.1,v 5.3 1991/08/22 06:50:48 eggert Exp $
-.ds g \&\s-1UTC\s0
-.ds r \&\s-1RCS\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 (\*g).
-Without options,
-.B rlog
-prints complete information.
-The options below restrict this output.
-.nr n \w'\f3\-V\fP\f2n\fP '+1n-1/1n
-.TP \nn
-.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
-.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 \-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
-inclusive.
-A range of the form
-.BI < d
-or
-.IB d >
-selects
-all revisions dated
-.I d
-or earlier.
-A range of the form
-.IB d <
-or
-.BI > d
-selects
-all revisions dated
-.I d
-or later.
-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
-.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 .
-.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
-Revision Number: \*(Rv; Release Date: \*(Dt.
-.br
-Copyright \(co 1982, 1988, 1989 by Walter F. Tichy.
-.br
-Copyright \(co 1990, 1991 by 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 b18b0c9..0000000
--- a/gnu/usr.bin/rcs/rlog/rlog.c
+++ /dev/null
@@ -1,1204 +0,0 @@
-/*
- * RLOG operation
- */
-/*****************************************************************************
- * print contents of RCS files
- *****************************************************************************
- */
-
-/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
-*/
-
-
-
-
-/* $Log: rlog.c,v $
- * 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 lockers { /* lockers in locker option; stored */
- char const * login; /* lockerlist */
- struct lockers * 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 */
- unsigned numfld; /* option; stored in revlist */
- char const * strtrev;
- char const * endrev;
- struct Revpairs * rnext;
- } ;
-
-struct Datepairs{ /* date range in -d option; stored in */
- char strtdate[datesize]; /* duelst and datelist */
- char enddate[datesize];
- struct Datepairs * dnext;
- };
-
-static char extractdelta P((struct hshentry const*));
-static int checkrevpair P((char const*,char const*));
-static struct hshentry const *readdeltalog P((void));
-static unsigned extdate P((struct hshentry*));
-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 getnumericrev P((void));
-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 lockers *lockerlist;
-static struct stateattri *statelist;
-
-
-mainProg(rlogId, "rlog", "$Id: rlog.c,v 5.9 1991/09/17 19:07:40 eggert Exp $")
-{
- static char const cmdusage[] =
- "\nrlog usage: rlog -{bhLRt} -ddates -l[lockers] -rrevs -sstates -w[logins] -Vn file ...";
-
- register FILE *out;
- char *a, **newargv;
- struct Datepairs *currdate;
- char const *accessListString, *accessFormat, *commentFormat;
- char const *headFormat, *symbolFormat;
- struct access const *curaccess;
- struct assoc const *curassoc;
- struct hshentry const *delta;
- struct lock const *currlock;
- int descflag, selectflag;
- int onlylockflag; /* print only files with locks */
- int onlyRCSflag; /* print only RCS file name */
- unsigned revno;
-
- descflag = selectflag = true;
- onlylockflag = onlyRCSflag = false;
- 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 '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 'V':
- setRCSversion(*argv);
- break;
-
- default:
- faterror("unknown option: %s%s", *argv, cmdusage);
-
- };
- } /* end of option processing */
-
- if (argc<1) faterror("no input file%s", cmdusage);
-
- if (! (descflag|selectflag)) {
- warn("-t overrides -h.");
- descflag = true;
- }
-
- if (RCSversion < VERSION(5)) {
- accessListString = "\naccess list: ";
- accessFormat = " %s";
- commentFormat = "\ncomment leader: \"";
- headFormat = "\nRCS file: %s; Working file: %s\nhead: %s%s\nbranch: %s%s\nlocks: ";
- insDelFormat = " lines added/del: %lu/%lu";
- symbolFormat = " %s: %s;";
- } else {
- accessListString = "\naccess list:";
- accessFormat = "\n\t%s";
- commentFormat = "\ncomment leader: \"";
- headFormat = "\nRCS file: %s\nWorking file: %s\nhead:%s%s\nbranch:%s%s\nlocks:%s";
- insDelFormat = " lines: +%lu -%lu";
- symbolFormat = "\n\t%s: %s";
- }
-
- /* now handle all filenames */
- do {
- ffree();
-
- if (pairfilenames(argc, argv, rcsreadopen, true, false) <= 0)
- continue;
-
- /* now RCSfilename contains the name of the RCS file, and finptr
- * the file descriptor. Workfilename 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 ( onlyRCSflag ) {
- aprintf(out, "%s\n", RCSfilename);
- continue;
- }
- /* print RCS filename , working filename and optional
- administrative information */
- /* could use getfullRCSname() here, but that is very slow */
- aprintf(out, headFormat, RCSfilename, workfilename,
- 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 && RCSversion<VERSION(5))
- aputs(" strict", out);
-
- aputs(accessListString, out); /* print access list */
- curaccess = AccessList;
- while(curaccess) {
- aprintf(out, accessFormat, curaccess->login);
- curaccess = curaccess->nextaccess;
- }
-
- aputs("\nsymbolic names:", out); /* print symbolic names */
- for (curassoc=Symbols; curassoc; curassoc=curassoc->nextassoc)
- aprintf(out, symbolFormat, curassoc->symbol, curassoc->num);
- aputs(commentFormat, out);
- awrite(Comment.string, Comment.size, out);
- aputs("\"\n", out);
- if (VERSION(5)<=RCSversion || Expand != KEYVAL_EXPAND)
- aprintf(out, "keyword substitution: %s\n",
- expand_names[Expand]
- );
-
- gettree();
-
- aprintf(out, "total revisions: %u", TotalDeltas);
-
- revno = 0;
-
- if (Head && selectflag & descflag) {
-
- getnumericrev(); /* get numeric revision or branch names */
-
- exttree(Head);
-
- /* get most recently date of the dates pointed by duelst */
- currdate = duelst;
- while( currdate) {
- VOID sprintf(currdate->strtdate,DATEFORM,0,0,0,0,0,0);
- recentdate(Head, currdate);
- currdate = currdate->dnext;
- }
-
- revno = extdate(Head);
-
- aprintf(out, ";\tselected revisions: %u", revno);
- }
-
- afputc('\n',out);
- if (descflag) {
- aputs("description:\n", out);
- getdesc(true);
- }
- if (revno) {
- while (! (delta = readdeltalog())->selector || --revno)
- ;
- if (delta->next && countnumflds(delta->num)==2)
- /* Read through delta->next to get its insertlns. */
- while (readdeltalog() != delta->next)
- ;
- putrunk();
- putree(Head);
- }
- aputs("=============================================================================\n",out);
- } while (cleanup(),
- ++argv, --argc >= 1);
- Ofclose(out);
- exitmain(exitstatus);
-}
-
- static void
-cleanup()
-{
- if (nerror) exitstatus = EXIT_FAILURE;
- Izclose(&finptr);
-}
-
-#if lint
-# define exiterr rlogExit
-#endif
- exiting 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 == nil ) 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 == nil ) return;
-
- putforest(branchroot->nextbranch);
-
- putabranch(branchroot->hsh);
- putree(branchroot->hsh);
-}
-
-
-
-
- static void
-putabranch(root)
- struct hshentry const *root;
-/* function : print one branch */
-
-{
-
- if ( root == nil) 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];
-
- if (!node->selector)
- return;
-
- out = stdout;
- aprintf(out,
- "----------------------------\nrevision %s", node->num
- );
- if ( node->lockedby )
- aprintf(out, "\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);
-
- nextlex();
- while (nexttok==ID && strcmp(NextString,Ktext)!=0)
- ignorephrase();
- 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 unsigned 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)
- fatserror("unexpected end to edit script");
- 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 == nil) return;
-
- root->selector = extractdelta(root);
- root->log.string = nil;
- 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 lockers * newlocker;
- argv--;
- while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||
- c == '\n' || c == ';') ;
- if ( c == '\0') {
- lockerlist=nil;
- return;
- }
-
- while( c != '\0' ) {
- newlocker = talloc(struct lockers);
- newlocker->lockerlink = lockerlist;
- newlocker->login = argv;
- lockerlist = newlocker;
- while ( ( c = (*++argv)) != ',' && c != '\0' && c != ' '
- && c != '\t' && c != '\n' && c != ';') ;
- *argv = '\0';
- if ( c == '\0' ) return;
- while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||
- c == '\n' || c == ';') ;
- }
-}
-
-
-
- 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 == ';') ;
- if ( c == '\0' ) {
- authorlist = talloc(struct authors);
- authorlist->login = getusername(false);
- authorlist->nextauthor = nil;
- return;
- }
-
- while( c != '\0' ) {
- newauthor = talloc(struct authors);
- newauthor->nextauthor = authorlist;
- newauthor->login = argv;
- authorlist = newauthor;
- while( ( c = *++argv) != ',' && c != '\0' && c != ' '
- && c != '\t' && c != '\n' && c != ';') ;
- * argv = '\0';
- if ( c == '\0') return;
- while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||
- c == '\n' || c == ';') ;
- }
-}
-
-
-
-
- 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 == ';') ;
- if ( c == '\0'){
- warn("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 != '\0' && c != ' '
- && c != '\t' && c != '\n' && c != ';') ;
- *argv = '\0';
- if ( c == '\0' ) return;
- while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||
- c == '\n' || c == ';') ;
- }
-}
-
-
-
- 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 lockers const *plocker;
- struct lock * plocked, * nextlocked;
-
- if ( (lockerlist == nil) || (Locks == nil)) return;
-
- /* shorten Locks to those contained in lockerlist */
- plocked = Locks;
- Locks = nil;
- while( plocked != nil) {
- plocker = lockerlist;
- while((plocker != nil) && ( strcmp(plocker->login, plocked->login)!=0))
- plocker = plocker->lockerlink;
- nextlocked = plocked->nextlock;
- if ( plocker != nil) {
- plocked->nextlock = Locks;
- Locks = plocked;
- }
- plocked = nextlocked;
- }
-}
-
-
-
- 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 == nil) return;
- if (root->selector) {
- if ( cmpnum(root->date, pd->strtdate) >= 0 &&
- cmpnum(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 unsigned
-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;
- unsigned revno;
-
- if (!root)
- return 0;
-
- if ( datelist || duelst) {
- pdate = datelist;
- while( pdate ) {
- if ( (pdate->strtdate)[0] == '\0' || cmpnum(root->date,pdate->strtdate) >= 0){
- if ((pdate->enddate)[0] == '\0' || cmpnum(pdate->enddate,root->date) >= 0)
- break;
- }
- pdate = pdate->dnext;
- }
- if ( pdate == nil) {
- pdate = duelst;
- for (;;) {
- if (!pdate) {
- root->selector = false;
- break;
- }
- if ( cmpnum(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 lock const *plock;
- struct stateattri const *pstate;
- struct authors const *pauthor;
- struct Revpairs const *prevision;
- unsigned 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 == ';') ;
- if ( c == '\0' ) {
- warn("missing date/time after -d");
- return;
- }
-
- while( c != '\0' ) {
- switchflag = false;
- nextdate = talloc(struct Datepairs);
- if ( c == '<' ) { /* case: -d <date */
- c = *++argv;
- (nextdate->strtdate)[0] = '\0';
- } else if (c == '>') { /* case: -d'>date' */
- 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 */
- while ( (c= *++argv) == ' ' || c=='\t' || c=='\n');
- 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 ( c == '\0') return;
- while( (c = *++argv) == ';' || c == ' ' || c == '\t' || c =='\n');
- }
-}
-
-
-
- static void
-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;
- unsigned n;
- struct buf s, e;
- char const *lrev;
- struct buf const *rstart, *rend;
-
- Revlst = nil;
- ptr = revlist;
- bufautobegin(&s);
- bufautobegin(&e);
- while( ptr ) {
- n = 0;
- rstart = &s;
- rend = &e;
-
- switch (ptr->numfld) {
-
- case 1: /* -r rev */
- if (expandsym(ptr->strtrev, &s)) {
- rend = &s;
- n = countnumflds(s.string);
- if (!n && (lrev = tiprev())) {
- bufscpy(&s, lrev);
- n = countnumflds(lrev);
- }
- }
- break;
-
- case 2: /* -r rev- */
- if (expandsym(ptr->strtrev, &s)) {
- 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)) {
- if ((n = countnumflds(e.string)) < 2)
- bufscpy(&s, ".1");
- else {
- bufscpy(&s, e.string);
- VOID strcpy(strrchr(s.string,'.'), ".1");
- }
- }
- break;
-
- default: /* -r rev1-rev2 */
- if (
- expandsym(ptr->strtrev, &s)
- && expandsym(ptr->endrev, &e)
- && checkrevpair(s.string, e.string)
- ) {
- 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);
- }
- bufautoend(&s);
- bufautoend(&e);
-}
-
-
-
- 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) */
-
-{
- unsigned length = countnumflds(num1);
-
- if (
- countnumflds(num2) != length
- || 2 < length && compartial(num1, num2, length-1) != 0
- ) {
- error("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') ;
- 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)
- continue;
- break;
- }
- 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;
- if (c!=',' && c!=';')
- 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 d2976c9..0000000
--- a/gnu/usr.bin/sdiff/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-PROG= sdiff
-SRCS= sdiff.c getopt.c getopt1.c version.c
-CFLAGS+= -I$(.CURDIR)/../diff\
- -DDIRENT=1 -DHAVE_UNISTD_H=1 -DHAVE_DUP2=1 -DHAVE_MEMCHR=1\
- -DHAVE_STRERROR=1 -DHAVE_WAITPID=1 -DHAVE_FCNTL_H=1\
- -DHAVE_STRING_H=1 -DHAVE_SYS_WAIT_H=1 -DHAVE_TIME_H=1\
- -DHAVE_ST_BLKSIZE=1 -DDIFF_PROGRAM=\"/usr/bin/diff\"
-NOMAN= noman
-
-.include <bsd.prog.mk>
-.PATH: $(.CURDIR)/../diff
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 00d9276..0000000
--- a/gnu/usr.bin/sort/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-PROG= sort
-SRCS= sort.c error.c
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/sort/error.c b/gnu/usr.bin/sort/error.c
deleted file mode 100644
index e849c5b..0000000
--- a/gnu/usr.bin/sort/error.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* error.c -- error handler for noninteractive utilities
- Copyright (C) 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Written by David MacKenzie. */
-
-#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/sort/sort.1 b/gnu/usr.bin/sort/sort.1
deleted file mode 100644
index 3acc398..0000000
--- a/gnu/usr.bin/sort/sort.1
+++ /dev/null
@@ -1,218 +0,0 @@
-.TH SORT 1L \" -*- 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...]
-.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.
-.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 42e0b8e..0000000
--- a/gnu/usr.bin/sort/sort.c
+++ /dev/null
@@ -1,1774 +0,0 @@
-/* sort - sort lines of text (with all kinds of options).
- Copyright (C) 1988, 1991 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., 675 Mass Ave, Cambridge, MA 02139, 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. */
-
-/* Get isblank from GNU libc. */
-#define _GNU_SOURCE
-
-#include <sys/types.h>
-#include <signal.h>
-#include <stdio.h>
-#include "system.h"
-#ifdef _POSIX_VERSION
-#include <limits.h>
-#else
-#ifndef UCHAR_MAX
-#define UCHAR_MAX 255
-#endif
-#endif
-#ifndef STDC_HEADERS
-char *malloc ();
-char *realloc ();
-void free ();
-#endif
-
-void error ();
-static void usage ();
-
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define UCHAR_LIM (UCHAR_MAX + 1)
-#define UCHAR(c) ((unsigned char) (c))
-
-/* The kind of blanks for '-b' to skip in various options. */
-enum blanktype { bl_start, bl_end, bl_both };
-
-/* 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
-{
- char *name;
- int val;
-} 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 = 524288;
-
-/* 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 = 16384;
-
-/* 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 262144
-
-/* 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;
-
-/* 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. */
-};
-
-/* Lists of key field comparisons to be tried. */
-static 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. */
- int month; /* Flag for comparison by month name. */
- int reverse; /* Reverse the sense of comparison. */
- struct keyfield *next; /* Next keyfield to try. */
-} keyhead;
-
-/* The list of temporary files. */
-static struct tempnode
-{
- char *name;
- struct tempnode *next;
-} temphead;
-
-/* Clean up any remaining temporary files. */
-
-static void
-cleanup ()
-{
- struct tempnode *node;
-
- for (node = temphead.next; node; node = node->next)
- unlink (node->name);
-}
-
-/* Allocate N bytes of memory dynamically, with error checking. */
-
-char *
-xmalloc (n)
- unsigned 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. */
-
-char *
-xrealloc (p, n)
- char *p;
- unsigned n;
-{
- if (p == 0)
- return xmalloc (n);
- if (n == 0)
- {
- free (p);
- return 0;
- }
- p = realloc (p, n);
- if (p == 0)
- {
- error (0, 0, "virtual memory exhausted");
- cleanup ();
- exit (2);
- }
- return p;
-}
-
-static FILE *
-xfopen (file, how)
- char *file, *how;
-{
- FILE *fp = strcmp (file, "-") ? fopen (file, how) : stdin;
-
- if (fp == 0)
- {
- error (0, errno, "%s", file);
- cleanup ();
- exit (2);
- }
- if (fp == stdin)
- have_read_stdin = 1;
- return fp;
-}
-
-static void
-xfclose (fp)
- FILE *fp;
-{
- fflush (fp);
- if (fp != stdin && fp != stdout)
- {
- if (fclose (fp) != 0)
- {
- error (0, errno, "error closing file");
- cleanup ();
- exit (2);
- }
- }
- else
- /* Allow reading stdin from tty more than once. */
- clearerr (fp);
-}
-
-static void
-xfwrite (buf, size, nelem, fp)
- char *buf;
- int size, 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 ()
-{
- static int seq;
- int len = strlen (temp_file_prefix);
- char *name = xmalloc (len + 16);
- struct tempnode *node =
- (struct tempnode *) xmalloc (sizeof (struct tempnode));
-
- if (len && temp_file_prefix[len - 1] != '/')
- sprintf (name, "%s/sort%5.5d%5.5d", temp_file_prefix, getpid (), ++seq);
- else
- sprintf (name, "%ssort%5.5d%5.5d", temp_file_prefix, getpid (), ++seq);
- 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 (name)
- 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 ()
-{
- 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;
- }
-}
-
-/* Initialize BUF, allocating ALLOC bytes initially. */
-
-static void
-initbuf (buf, alloc)
- 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 (buf, fp)
- struct buffer *buf;
- FILE *fp;
-{
- int cc;
-
- bcopy (buf->buf + buf->used - buf->left, buf->buf, 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 (lines, alloc, limit)
- 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 (line, key)
- struct line *line;
- 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;
-
- while (ptr < lim && schar--)
- ++ptr;
-
- return ptr;
-}
-
-/* Return the limit of (a pointer to the first character after) the field
- in LINE specified by KEY. */
-
-static char *
-limfield (line, key)
- struct line *line;
- struct keyfield *key;
-{
- register char *ptr = line->text, *lim = ptr + line->length;
- register int eword = key->eword, echar = key->echar;
-
- if (tab)
- while (ptr < lim && eword--)
- {
- while (ptr < lim && *ptr != tab)
- ++ptr;
- if (ptr < lim && (eword || key->skipeblanks))
- ++ptr;
- }
- else
- while (ptr < lim && eword--)
- {
- while (ptr < lim && blanks[UCHAR (*ptr)])
- ++ptr;
- while (ptr < lim && !blanks[UCHAR (*ptr)])
- ++ptr;
- }
-
- if (key->skipeblanks)
- while (ptr < lim && blanks[UCHAR (*ptr)])
- ++ptr;
-
- while (ptr < lim && echar--)
- ++ptr;
-
- return ptr;
-}
-
-/* Find the lines in BUF, storing pointers and lengths in LINES.
- Also replace newlines with NULs. */
-
-static void
-findlines (buf, lines)
- 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;
- }
- }
- 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 (a, b)
- register char *a, *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 (a, b)
- register char *a, *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 == '-')
- {
- tmpa = UCHAR (*++a);
- if (tmpb != '-')
- {
- if (digits[tmpa] && digits[tmpb])
- return -1;
- return 0;
- }
- tmpb = UCHAR (*++b);
-
- 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 = logb - loga) != 0)
- return tmp;
-
- if (!loga)
- return 0;
-
- return tmpb - tmpa;
- }
- else if (tmpb == '-')
- {
- if (digits[UCHAR (tmpa)] && digits[UCHAR (*++b)])
- 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;
-
- return tmpa - tmpb;
- }
-}
-
-/* Return an integer <= 12 associated with month name S with length LEN,
- 0 if the name in S is not recognized. */
-
-static int
-getmonth (s, len)
- 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 (a, b)
- struct line *a, *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;
-
- /* 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->month)
- {
- diff = getmonth (texta, lena) - getmonth (textb, lenb);
- if (diff)
- return key->reverse ? -diff : diff;
- continue;
- }
- else if (ignore && translate)
- while (texta < lima && textb < limb)
- {
- while (texta < lima && ignore[UCHAR (*texta)])
- ++texta;
- while (textb < limb && ignore[UCHAR (*textb)])
- ++textb;
- if (texta < lima && textb < limb &&
- translate[UCHAR (*texta++)] != translate[UCHAR (*textb++)])
- {
- diff = translate[UCHAR (*--texta)] - translate[UCHAR (*--textb)];
- break;
- }
- }
- else if (ignore)
- while (texta < lima && textb < limb)
- {
- while (texta < lima && ignore[UCHAR (*texta)])
- ++texta;
- while (textb < limb && ignore[UCHAR (*textb)])
- ++textb;
- if (texta < lima && textb < limb && *texta++ != *textb++)
- {
- diff = *--texta - *--textb;
- break;
- }
- }
- else if (translate)
- while (texta < lima && textb < limb)
- {
- if (translate[UCHAR (*texta++)] != translate[UCHAR (*textb++)])
- {
- diff = translate[UCHAR (*--texta)] - translate[UCHAR (*--textb)];
- break;
- }
- }
- else
- diff = memcmp (texta, textb, min (lena, lenb));
-
- 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 (a, b)
- register struct line *a, *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;
-
- diff = UCHAR (*ap) - UCHAR (*bp);
- if (diff == 0)
- {
- diff = memcmp (ap, bp, mini);
- 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. */
-
-static int
-checkfp (fp)
- 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 cmp; /* Result of calling compare. */
- int alloc, i, success = 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);
- findlines (&buf, &lines);
-
- if (cc)
- do
- {
- /* 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))
- {
- success = 0;
- goto finish;
- }
- }
-
- /* Save the last line of the buffer and refill the buffer. */
- if (lines.lines[lines.used - 1].length > alloc)
- {
- while (lines.lines[lines.used - 1].length + 1 > alloc)
- alloc *= 2;
- temp.text = xrealloc (temp.text, alloc);
- }
- bcopy (lines.lines[lines.used - 1].text, temp.text,
- lines.lines[lines.used - 1].length + 1);
- temp.length = lines.lines[lines.used - 1].length;
-
- cc = fillbuf (&buf, fp);
- if (cc)
- {
- 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))
- {
- success = 0;
- break;
- }
- }
- }
- while (cc);
-
-finish:
- xfclose (fp);
- free (buf.buf);
- free ((char *) lines.lines);
- free (temp.text);
- return success;
-}
-
-/* Merge lines from FPS onto OFP. NFPS cannot be greater than NMERGE.
- Close FPS before returning. */
-
-static void
-mergefps (fps, nfps, ofp)
- FILE *fps[], *ofp;
- register int nfps;
-{
- 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;
-
- /* 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 out, 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;
- bcopy (lines[ord[0]].lines[cur[ord[0]]].text, saved.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 (lines, nlines, temp)
- struct line *lines, *temp;
- int nlines;
-{
- 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 (files, nfiles)
- char *files[];
- int nfiles;
-{
- int i, disorders = 0;
- FILE *fp;
-
- for (i = 0; i < nfiles; ++i)
- {
- fp = xfopen (files[i], "r");
- if (!checkfp (fp))
- {
- printf ("%s: disorder on %s\n", program_name, files[i]);
- ++disorders;
- }
- }
- return disorders;
-}
-
-/* Merge NFILES FILES onto OFP. */
-
-static void
-merge (files, nfiles, ofp)
- 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 = xfopen (temp = tempname (), "w");
- 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 = xfopen (temp = tempname (), "w");
- 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 (files, nfiles, ofp)
- 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 ntemp = 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 && !ntemp && !buf.left)
- tfp = ofp;
- else
- {
- ++ntemp;
- tfp = xfopen (tempname (), "w");
- }
- 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 (ntemp)
- {
- tempfiles = (char **) xmalloc (ntemp * sizeof (char *));
- i = ntemp;
- for (node = temphead.next; i > 0; node = node->next)
- tempfiles[--i] = node->name;
- merge (tempfiles, ntemp, ofp);
- free ((char *) tempfiles);
- }
-}
-
-/* Insert key KEY at the end of the list (`keyhead'). */
-
-static void
-insertkey (key)
- struct keyfield *key;
-{
- struct keyfield *k = &keyhead;
-
- while (k->next)
- k = k->next;
- k->next = key;
- key->next = NULL;
-}
-
-static void
-badfieldspec (s)
- char *s;
-{
- error (2, 0, "invalid field specification `%s'", s);
-}
-
-/* Handle interrupts and hangups. */
-
-static void
-sighandler (sig)
- int sig;
-{
-#ifdef _POSIX_VERSION
- struct sigaction sigact;
-
- sigact.sa_handler = SIG_DFL;
- sigemptyset (&sigact.sa_mask);
- sigact.sa_flags = 0;
- sigaction (sig, &sigact, NULL);
-#else /* !_POSIX_VERSION */
- signal (sig, SIG_DFL);
-#endif /* _POSIX_VERSION */
- 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 (s, key, blanktype)
- register 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;
-#if 0
- case 'g':
- /* Reserved for comparing floating-point numbers. */
- break;
-#endif
- case 'i':
- key->ignore = nonprinting;
- break;
- case 'M':
- key->month = 1;
- break;
- case 'n':
- key->numeric = 1;
- break;
- case 'r':
- key->reverse = 1;
- break;
- default:
- return s;
- }
- ++s;
- }
- return s;
-}
-
-void
-main (argc, argv)
- 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 _POSIX_VERSION
- struct sigaction oldact, newact;
-#endif /* _POSIX_VERSION */
-
- program_name = argv[0];
- have_read_stdin = 0;
- inittables ();
-
- temp_file_prefix = getenv ("TMPDIR");
- if (temp_file_prefix == NULL)
- temp_file_prefix = "/tmp";
-
-#ifdef _POSIX_VERSION
- 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 /* !_POSIX_VERSION */
- 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 /* !_POSIX_VERSION */
-
- gkey.sword = gkey.eword = -1;
- gkey.ignore = NULL;
- gkey.translate = NULL;
- gkey.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->month = key->reverse = 0;
- s = argv[i] + 1;
- if (!digits[UCHAR (*s)])
- 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)])
- {
- if (!key)
- usage ();
- 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)
- t--;
- t2 = 0;
- if (*s == '.')
- {
- for (++s; digits[UCHAR (*s)]; ++s)
- t2 = 10 * t2 + *s - '0';
- if (t2)
- t2--;
- }
- if (t2 || t)
- {
- key->sword = t;
- key->schar = t2;
- }
- else
- key->sword = -1;
- s = set_ordering (s, key, bl_start);
- if (*s && *s != ',')
- badfieldspec (argv[i]);
- else if (*s++)
- {
- /* Get POS2. */
- 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';
- if (t2)
- 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];
- goto outer;
- }
- else
- error (2, 0, "option `-T' requires an argument");
- break;
- case 'u':
- unique = 1;
- break;
- default:
- fprintf (stderr, "%s: unrecognized option `-%c'\n",
- argv[0], *s);
- usage ();
- }
- 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->ignore = gkey.ignore;
- key->translate = gkey.translate;
- key->skipsblanks = gkey.skipsblanks;
- key->skipeblanks = gkey.skipeblanks;
- key->month = gkey.month;
- key->numeric = gkey.numeric;
- key->reverse = gkey.reverse;
- }
-
- if (!keyhead.next && (gkey.ignore || gkey.translate || gkey.skipsblanks
- || gkey.skipeblanks || gkey.month || gkey.numeric))
- insertkey (&gkey);
- reverse = gkey.reverse;
-
- if (nfiles == 0)
- {
- nfiles = 1;
- files = &minus;
- }
-
- if (checkonly)
- exit (check (files, nfiles) != 0);
-
- if (strcmp (outfile, "-"))
- {
- for (i = 0; i < nfiles; ++i)
- if (!strcmp (outfile, files[i]))
- break;
- if (i == nfiles)
- ofp = xfopen (outfile, "w");
- else
- {
- char buf[8192];
- FILE *fp = xfopen (outfile, "r");
- int cc;
-
- tmp = tempname ();
- ofp = xfopen (tmp, "w");
- while ((cc = fread (buf, 1, sizeof buf, fp)) > 0)
- xfwrite (buf, 1, cc, ofp);
- if (ferror (fp))
- {
- error (0, errno, "%s", outfile);
- 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, "fflush", outfile);
-
- if (have_read_stdin && fclose (stdin) == EOF)
- error (1, errno, "-");
- if (ferror (stdout) || fclose (stdout) == EOF)
- error (1, errno, "write error");
-
- exit (0);
-}
-
-static void
-usage ()
-{
- fprintf (stderr, "\
-Usage: %s [-cmus] [-t separator] [-o output-file] [-T tempdir] [-bdfiMnr]\n\
- [+POS1 [-POS2]] [-k POS1[,POS2]] [file...]\n",
- program_name);
- exit (2);
-}
diff --git a/gnu/usr.bin/sort/system.h b/gnu/usr.bin/sort/system.h
deleted file mode 100644
index d26022d..0000000
--- a/gnu/usr.bin/sort/system.h
+++ /dev/null
@@ -1,168 +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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Include sys/types.h before this file. */
-
-#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)
-#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
-
-#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
-#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
-#include <memory.h>
-#endif
-#include <string.h>
-#ifndef index
-#define index strchr
-#endif
-#ifndef rindex
-#define rindex strrchr
-#endif
-/* Don't define bcopy; we need one that can handle overlaps. */
-#ifndef bzero
-#define bzero(s, n) memset ((s), 0, (n))
-#endif
-#ifndef bcmp
-#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
-#endif
-#else
-#include <strings.h>
-#ifndef __386BSD__
-char *memchr ();
-#endif
-#endif
-
-#include <errno.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-char *getenv ();
-extern int errno;
-#endif
-
-#if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
-#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>
-
-#ifndef 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))
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 7934f2b..0000000
--- a/gnu/usr.bin/tar/ChangeLog
+++ /dev/null
@@ -1,1732 +0,0 @@
-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 69a1f52..0000000
--- a/gnu/usr.bin/tar/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-PROG= tar
-SRCS= buffer.c create.c diffarch.c extract.c fnmatch.c getdate.y \
- getoldopt.c getopt.c getopt1.c gnu.c list.c mangle.c names.c port.c \
- regex.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+= -DHAVE_VPRINTF=1 -DNEEDPAD -I${.CURDIR}
-CFLAGS+= -DDEF_AR_FILE=\"/dev/rst0\" -DDEFBLOCKING=20
-CLEANFILES+=y.tab.h
-NOMAN=noman
-
-.include <bsd.prog.mk>
-.include "../../usr.bin/Makefile.inc"
diff --git a/gnu/usr.bin/tar/Makefile.gnu b/gnu/usr.bin/tar/Makefile.gnu
deleted file mode 100644
index a03617a..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 e0ffc2d..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 "regex.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 62b9c51..0000000
--- a/gnu/usr.bin/tar/create.c
+++ /dev/null
@@ -1,1454 +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 (link_name - lp->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, 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", 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 0
- if (f_dironly)
- return; /* Unless the cmdline said not to */
-#endif
- /*
- * 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)
- {
- to_oct ((long) major (hstat.st_rdev), 8,
- header->header.devmajor);
- to_oct ((long) minor (hstat.st_rdev), 8,
- header->header.devminor);
- }
-#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] = ' ';
-
-}
-
-
-/*
- * 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 d162cab..0000000
--- a/gnu/usr.bin/tar/extract.c
+++ /dev/null
@@ -1,907 +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))
- {
- 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;
- }
-#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 %ld",
- skipcrud + current_file_name,
- notumask & (int) hstat.st_mode);
- }
- }
-
- quit:
- break;
-
- case LF_LINK:
- again_link:
- {
- struct stat st1, st2;
-
- 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:
- 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:
- 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:
- 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 %ld",
- 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 %ld",
- 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/fnmatch.c b/gnu/usr.bin/tar/fnmatch.c
deleted file mode 100644
index ed8c9ee..0000000
--- a/gnu/usr.bin/tar/fnmatch.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-
-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; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#include <errno.h>
-#include <fnmatch.h>
-
-#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
-extern int errno;
-#endif
-
-/* Match STRING against the filename pattern PATTERN, returning zero if
- it matches, nonzero if not. */
-int
-fnmatch (pattern, string, flags)
- const char *pattern;
- const char *string;
- int flags;
-{
- register const char *p = pattern, *n = string;
- register char c;
-
- if ((flags & ~__FNM_FLAGS) != 0)
- {
- errno = EINVAL;
- return -1;
- }
-
- while ((c = *p++) != '\0')
- {
- switch (c)
- {
- case '?':
- if (*n == '\0')
- return FNM_NOMATCH;
- else if ((flags & FNM_PATHNAME) && *n == '/')
- return FNM_NOMATCH;
- else if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- return FNM_NOMATCH;
- break;
-
- case '\\':
- if (!(flags & FNM_NOESCAPE))
- c = *p++;
- if (*n != c)
- return FNM_NOMATCH;
- break;
-
- case '*':
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- return FNM_NOMATCH;
-
- for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
- if (((flags & FNM_PATHNAME) && *n == '/') ||
- (c == '?' && *n == '\0'))
- return FNM_NOMATCH;
-
- if (c == '\0')
- return 0;
-
- {
- char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
- for (--p; *n != '\0'; ++n)
- if ((c == '[' || *n == c1) &&
- fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
- return 0;
- return FNM_NOMATCH;
- }
-
- case '[':
- {
- /* Nonzero if the sense of the character class is inverted. */
- register int not;
-
- if (*n == '\0')
- return FNM_NOMATCH;
-
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- return FNM_NOMATCH;
-
- not = (*p == '!' || *p == '^');
- if (not)
- ++p;
-
- c = *p++;
- for (;;)
- {
- register char cstart = c, cend = c;
-
- if (!(flags & FNM_NOESCAPE) && c == '\\')
- cstart = cend = *p++;
-
- if (c == '\0')
- /* [ (unterminated) loses. */
- return FNM_NOMATCH;
-
- c = *p++;
-
- if ((flags & FNM_PATHNAME) && c == '/')
- /* [/] can never match. */
- return FNM_NOMATCH;
-
- if (c == '-' && *p != ']')
- {
- cend = *p++;
- if (!(flags & FNM_NOESCAPE) && cend == '\\')
- cend = *p++;
- if (cend == '\0')
- return FNM_NOMATCH;
- c = *p++;
- }
-
- if (*n >= cstart && *n <= cend)
- goto matched;
-
- if (c == ']')
- break;
- }
- if (!not)
- return FNM_NOMATCH;
- break;
-
- matched:;
- /* Skip the rest of the [...] that already matched. */
- while (c != ']')
- {
- if (c == '\0')
- /* [... (unterminated) loses. */
- return FNM_NOMATCH;
-
- c = *p++;
- if (!(flags & FNM_NOESCAPE) && c == '\\')
- /* 1003.2d11 is unclear if this is right. %%% */
- ++p;
- }
- if (not)
- return FNM_NOMATCH;
- }
- break;
-
- default:
- if (c != *n)
- return FNM_NOMATCH;
- }
-
- ++n;
- }
-
- if (*n == '\0')
- return 0;
-
- if ((flags & FNM_LEADING_DIR) && *n == '/')
- /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
- return 0;
-
- return FNM_NOMATCH;
-}
diff --git a/gnu/usr.bin/tar/fnmatch.h b/gnu/usr.bin/tar/fnmatch.h
deleted file mode 100644
index d4150a9..0000000
--- a/gnu/usr.bin/tar/fnmatch.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-
-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; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#ifndef _FNMATCH_H
-
-#define _FNMATCH_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
-#undef __P
-#define __P(args) args
-#else /* Not C++ or ANSI C. */
-#undef __P
-#define __P(args) ()
-#undef const
-#define const
-#endif /* C++ or ANSI C. */
-
-/* Bits set in the FLAGS argument to `fnmatch'. */
-#ifdef FNM_PATHNAME /* Because it is already defined in <unistd.h> */
-#undef FNM_PATHNAME
-#endif
-#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */
-#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */
-#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */
-#define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD|FNM_LEADING_DIR)
-
-#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_BSD_SOURCE)
-#define FNM_LEADING_DIR (1 << 3)/* Ignore `/...' after a match. */
-#define FNM_FILE_NAME FNM_PATHNAME
-#endif
-
-/* Value returned by `fnmatch' if STRING does not match PATTERN. */
-#define FNM_NOMATCH 1
-
-/* Match STRING against the filename pattern PATTERN,
- returning zero if it matches, FNM_NOMATCH if not. */
-extern int fnmatch __P ((const char *__pattern, const char *__string,
- int __flags));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* fnmatch.h */
diff --git a/gnu/usr.bin/tar/getdate.y b/gnu/usr.bin/tar/getdate.y
deleted file mode 100644
index 7b0ac79..0000000
--- a/gnu/usr.bin/tar/getdate.y
+++ /dev/null
@@ -1,969 +0,0 @@
-%{
-/* $Revision: 2.1 $
-**
-** 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 (__386BSD__)
-#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: str2date.y,v 2.1 90/09/06 08:15:06 cronan 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 */
- { "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 __386BSD__
- 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 3db9abf..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 93a5cf7..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 c3582cf..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 ef51f2b..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 (*strp))
- strp++;
- ino = atol (strp);
- while (isspace (*strp))
- strp++;
- while (isdigit (*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 a0c65a3..0000000
--- a/gnu/usr.bin/tar/list.c
+++ /dev/null
@@ -1,881 +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 ();
- 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);
-
- 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 (*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 (*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;
- 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; /* To make ctime() call portable */
- 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;
- timestamp = ctime (&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 10ec32e..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++;
- 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/regex.c b/gnu/usr.bin/tar/regex.c
deleted file mode 100644
index cb94d59..0000000
--- a/gnu/usr.bin/tar/regex.c
+++ /dev/null
@@ -1,4932 +0,0 @@
-/* Extended regular expression matching and search library,
- version 0.11.
- (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
-
-/* We need this for `regex.h', and perhaps for the Emacs include files. */
-#include <sys/types.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.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>
-
-#ifndef 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 (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 (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)
- {
- 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;
-
- printf ("/charset%s",
- (re_opcode_t) *(p - 1) == charset_not ? "_not" : "");
-
- assert (p + *p < pend);
-
- for (c = 0; c < *p; c++)
- {
- unsigned bit;
- unsigned char map_byte = p[1 + c];
-
- putchar ('/');
-
- for (bit = 0; bit < BYTEWIDTH; bit++)
- if (map_byte & (1 << bit))
- printchar (c * BYTEWIDTH + bit);
- }
- 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/0/%d", mcnt);
- break;
-
- case on_failure_keep_string_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/on_failure_keep_string_jump/0/%d", mcnt);
- break;
-
- case dummy_failure_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/dummy_failure_jump/0/%d", mcnt);
- break;
-
- case push_dummy_failure:
- printf ("/push_dummy_failure");
- break;
-
- case maybe_pop_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/maybe_pop_jump/0/%d", mcnt);
- break;
-
- case pop_failure_jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/pop_failure_jump/0/%d", mcnt);
- break;
-
- case jump_past_alt:
- extract_number_and_incr (&mcnt, &p);
- printf ("/jump_past_alt/0/%d", mcnt);
- break;
-
- case jump:
- extract_number_and_incr (&mcnt, &p);
- printf ("/jump/0/%d", mcnt);
- break;
-
- case succeed_n:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2);
- break;
-
- case jump_n:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2);
- break;
-
- case set_number_at:
- extract_number_and_incr (&mcnt, &p);
- extract_number_and_incr (&mcnt2, &p);
- printf ("/set_number_at/0/%d/0/%d", mcnt, 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));
- }
- }
- printf ("/\n");
-}
-
-
-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 void store_op1 (), store_op2 ();
-static void insert_op1 (), insert_op2 ();
-static boolean at_begline_loc_p (), at_endline_loc_p ();
-static boolean group_in_compile_stack ();
-static reg_errcode_t compile_range ();
-
-/* 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, (to) - (loc) - 3)
-
-/* Likewise, for a two-argument jump. */
-#define STORE_JUMP2(op, loc, to, arg) \
- store_op2 (op, loc, (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, (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, (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. */
-#define MAX_BUF_SIZE (1L << 16)
-
-
-/* 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. */
-typedef int 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"))
-
-/* `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;
- int 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 ('.')
- && 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;
- 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;
-
- /* 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':
- laststart = b;
- BUF_PUSH (wordchar);
- break;
-
-
- case 'W':
- laststart = b;
- BUF_PUSH (notwordchar);
- break;
-
-
- case '<':
- BUF_PUSH (wordbeg);
- break;
-
- case '>':
- BUF_PUSH (wordend);
- break;
-
- case 'b':
- BUF_PUSH (wordbound);
- break;
-
- case 'B':
- BUF_PUSH (notwordbound);
- break;
-
- case '`':
- BUF_PUSH (begbuf);
- break;
-
- case '\'':
- 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, 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: ");
- 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;
- int 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. */
- if (range_start > range_end)
- return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-
- /* 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));
- }
-
- 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. */ \
- int 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);\
- } \
- \
- /* Push the info, starting with the registers. */ \
- DEBUG_PRINT1 ("\n"); \
- \
- 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); \
- } \
- \
- 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)
-
-/* 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;) \
- int 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); \
- \
- /* Restore register info. */ \
- high_reg = (unsigned) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
- \
- low_reg = (unsigned) 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;
- unsigned long size = bufp->used;
- const unsigned char *p = pattern;
- register unsigned char *pend = pattern + size;
-
- /* 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 = (regoff_t) 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 */
-
-/* Declarations and macros for re_match_2. */
-
-static int bcmp_translate ();
-static boolean alt_match_null_string_p (),
- common_op_match_null_string_p (),
- group_match_null_string_p ();
-
-/* 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. */
-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)
-
-
-/* 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 \
- { \
- unsigned 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. */
- unsigned num_regs = bufp->re_nsub + 1;
-
- /* The currently active registers. */
- unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG;
- unsigned 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, **regend;
-
- /* 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, **old_regend;
-
- /* 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;
-
- /* 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, **best_regend;
-
- /* 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;
- register_info_type *reg_info_dummy;
-
-#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
- 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 ((int) old_regend[r] >= (int) regstart[r])
- regend[r] = old_regend[r];
- }
- }
- p1++;
- EXTRACT_NUMBER_AND_INCR (mcnt, p1);
- PUSH_FAILURE_POINT (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);
- 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);
- 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'. */
- unsigned 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);
- 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);
- 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)
- unsigned char *s1, *s2;
- register int len;
- char *translate;
-{
- register unsigned char *p1 = s1, *p2 = 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;
- int 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
-
-/* 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;
- unsigned 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;
-
- /* 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_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 /* not emacs */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/gnu/usr.bin/tar/regex.h b/gnu/usr.bin/tar/regex.h
deleted file mode 100644
index 0840861..0000000
--- a/gnu/usr.bin/tar/regex.h
+++ /dev/null
@@ -1,490 +0,0 @@
-/* Definitions for data structures and routines for the regular
- expression library, version 0.11.
-
- Copyright (C) 1985, 89, 90, 91, 92 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__
-
-/* 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 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 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 (1)
-
-/* 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)
-
-/* 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_UNMATCHED_RIGHT_PAREN_ORD)
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
-
-#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
-#define RE_DUP_MAX ((1 << 15) - 1)
-
-
-/* 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. */
-
-#if __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, int 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));
-
-#endif /* not __REGEXP_LIBRARY_H__ */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
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 eece76f..0000000
--- a/gnu/usr.bin/tar/rtapelib.c
+++ /dev/null
@@ -1,582 +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/ucb/rsh", "rsh", system, "-l", login,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bin/remsh", "remsh", system, "-l", login,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bin/rsh", "rsh", system, "-l", login,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bsd/rsh", "rsh", system, "-l", login,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bin/nsh", "nsh", system, "-l", login,
- "/etc/rmt", (char *) 0);
- }
- else
- {
- execl ("/usr/ucb/rsh", "rsh", system,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bin/remsh", "remsh", system,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bin/rsh", "rsh", system,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bsd/rsh", "rsh", system,
- "/etc/rmt", (char *) 0);
- execl ("/usr/bin/nsh", "nsh", 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.c b/gnu/usr.bin/tar/tar.c
deleted file mode 100644
index 9382582..0000000
--- a/gnu/usr.bin/tar/tar.c
+++ /dev/null
@@ -1,1504 +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 */
-#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 "regex.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 ();
-
-#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},
-
- {0, 0, 0, 0}
-};
-
-/*
- * Main routine for tar.
- */
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- extern char version_string[];
-
- 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);
- /* 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:mMN: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': /* 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 directory names while reading the archive\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 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, --after-date DATE,\n\
- --newer DATE only store files 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\
--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\
-", 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')
- {
- chdir_name = name_next (0);
- p = name_next (0);
- if (!p)
- {
- 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')
- {
- chdir_name = name_next (0);
- 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;
- 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 %d", 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);
- 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 c3fec78..0000000
--- a/gnu/usr.bin/tar/tar.h
+++ /dev/null
@@ -1,291 +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 */
-#if 0
-TAR_EXTERN char f_dironly; /* -D */
-#endif
-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 */
-
-/*
- * 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;
-
-
-/*
- * 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 4454f62..0000000
--- a/gnu/usr.bin/tar/version.c
+++ /dev/null
@@ -1 +0,0 @@
-char version_string[] = "GNU tar version 1.11.2";
diff --git a/gnu/usr.bin/tar/y.tab.h b/gnu/usr.bin/tar/y.tab.h
deleted file mode 100644
index 4a541d2..0000000
--- a/gnu/usr.bin/tar/y.tab.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#define tAGO 257
-#define tDAY 258
-#define tDAYZONE 259
-#define tID 260
-#define tMERIDIAN 261
-#define tMINUTE_UNIT 262
-#define tMONTH 263
-#define tMONTH_UNIT 264
-#define tSEC_UNIT 265
-#define tSNUMBER 266
-#define tUNUMBER 267
-#define tZONE 268
-#define tDST 269
-typedef union {
- time_t Number;
- enum _MERIDIAN Meridian;
-} YYSTYPE;
-extern YYSTYPE yylval;
OpenPOWER on IntegriCloud