Browse Source

Plan 9 from Bell Labs 2003-02-26

David du Colombier 16 years ago
parent
commit
c7188eaa2e
96 changed files with 39419 additions and 71 deletions
  1. 5 0
      acme/bin/wnew
  2. 105 22
      dist/replica/plan9.db
  3. 106 0
      dist/replica/plan9.log
  4. 4 1
      lib/ndb/common
  5. 2 0
      lib/vgadb
  6. 20 0
      sys/man/1/acid
  7. 8 0
      sys/src/9/pc/vgas3.c
  8. 6 3
      sys/src/9/pc/vgasavage.c
  9. 339 0
      sys/src/ape/cmd/diff/COPYING
  10. 1766 0
      sys/src/ape/cmd/diff/ChangeLog
  11. 24 0
      sys/src/ape/cmd/diff/FREEBSD-upgrade
  12. 126 0
      sys/src/ape/cmd/diff/NEWS
  13. 9 0
      sys/src/ape/cmd/diff/README
  14. 1084 0
      sys/src/ape/cmd/diff/analyze.c
  15. 40 0
      sys/src/ape/cmd/diff/cmpbuf.c
  16. 20 0
      sys/src/ape/cmd/diff/cmpbuf.h
  17. 118 0
      sys/src/ape/cmd/diff/config.h
  18. 468 0
      sys/src/ape/cmd/diff/context.c
  19. 71 0
      sys/src/ape/cmd/diff/diagmeet.note
  20. 1124 0
      sys/src/ape/cmd/diff/diff.c
  21. 344 0
      sys/src/ape/cmd/diff/diff.h
  22. 3916 0
      sys/src/ape/cmd/diff/diff.texi
  23. 1778 0
      sys/src/ape/cmd/diff/diff3.c
  24. 216 0
      sys/src/ape/cmd/diff/dir.c
  25. 200 0
      sys/src/ape/cmd/diff/ed.c
  26. 181 0
      sys/src/ape/cmd/diff/fnmatch.c
  27. 40 0
      sys/src/ape/cmd/diff/fnmatch.h
  28. 748 0
      sys/src/ape/cmd/diff/getopt.c
  29. 129 0
      sys/src/ape/cmd/diff/getopt.h
  30. 180 0
      sys/src/ape/cmd/diff/getopt1.c
  31. 428 0
      sys/src/ape/cmd/diff/ifdef.c
  32. 238 0
      sys/src/ape/cmd/diff/install-sh
  33. 714 0
      sys/src/ape/cmd/diff/io.c
  34. 47 0
      sys/src/ape/cmd/diff/mkfile
  35. 71 0
      sys/src/ape/cmd/diff/normal.c
  36. 87 0
      sys/src/ape/cmd/diff/prepend_args.c
  37. 21 0
      sys/src/ape/cmd/diff/prepend_args.h
  38. 6374 0
      sys/src/ape/cmd/diff/regex.c
  39. 510 0
      sys/src/ape/cmd/diff/regex.h
  40. 1109 0
      sys/src/ape/cmd/diff/sdiff.c
  41. 284 0
      sys/src/ape/cmd/diff/side.c
  42. 272 0
      sys/src/ape/cmd/diff/system.h
  43. 759 0
      sys/src/ape/cmd/diff/util.c
  44. 5 0
      sys/src/ape/cmd/diff/version.c
  45. 81 0
      sys/src/ape/cmd/diff/xmalloc.c
  46. 340 0
      sys/src/ape/cmd/patch/COPYING
  47. 1704 0
      sys/src/ape/cmd/patch/ChangeLog
  48. 34 0
      sys/src/ape/cmd/patch/FREEBSD-upgrade
  49. 183 0
      sys/src/ape/cmd/patch/INSTALL
  50. 158 0
      sys/src/ape/cmd/patch/Makefile.in
  51. 173 0
      sys/src/ape/cmd/patch/NEWS
  52. 52 0
      sys/src/ape/cmd/patch/README
  53. 14 0
      sys/src/ape/cmd/patch/acconfig.h
  54. 106 0
      sys/src/ape/cmd/patch/addext.c
  55. 92 0
      sys/src/ape/cmd/patch/argmatch.c
  56. 12 0
      sys/src/ape/cmd/patch/argmatch.h
  57. 252 0
      sys/src/ape/cmd/patch/backupfile.c
  58. 50 0
      sys/src/ape/cmd/patch/backupfile.h
  59. 32 0
      sys/src/ape/cmd/patch/basename.c
  60. 307 0
      sys/src/ape/cmd/patch/common.h
  61. 120 0
      sys/src/ape/cmd/patch/config.h
  62. 118 0
      sys/src/ape/cmd/patch/config.hin
  63. 2364 0
      sys/src/ape/cmd/patch/configure
  64. 134 0
      sys/src/ape/cmd/patch/configure.in
  65. 1054 0
      sys/src/ape/cmd/patch/getopt.c
  66. 133 0
      sys/src/ape/cmd/patch/getopt.h
  67. 189 0
      sys/src/ape/cmd/patch/getopt1.c
  68. 462 0
      sys/src/ape/cmd/patch/inp.c
  69. 10 0
      sys/src/ape/cmd/patch/inp.h
  70. 250 0
      sys/src/ape/cmd/patch/install-sh
  71. 391 0
      sys/src/ape/cmd/patch/maketime.c
  72. 39 0
      sys/src/ape/cmd/patch/maketime.h
  73. 41 0
      sys/src/ape/cmd/patch/mkfile
  74. 742 0
      sys/src/ape/cmd/patch/partime.c
  75. 67 0
      sys/src/ape/cmd/patch/partime.h
  76. 1064 0
      sys/src/ape/cmd/patch/patch.1
  77. 1302 0
      sys/src/ape/cmd/patch/patch.c
  78. 1 0
      sys/src/ape/cmd/patch/patchlevel.h
  79. 1865 0
      sys/src/ape/cmd/patch/pch.c
  80. 25 0
      sys/src/ape/cmd/patch/pch.h
  81. 125 0
      sys/src/ape/cmd/patch/quotearg.c
  82. 9 0
      sys/src/ape/cmd/patch/quotearg.h
  83. 1079 0
      sys/src/ape/cmd/patch/util.c
  84. 32 0
      sys/src/ape/cmd/patch/util.h
  85. 30 0
      sys/src/ape/cmd/patch/version.c
  86. 5 0
      sys/src/ape/cmd/patch/version.h
  87. 1 0
      sys/src/cmd/acid/acid.h
  88. 11 5
      sys/src/cmd/acid/dbg.y
  89. 5 1
      sys/src/cmd/acid/expr.c
  90. 1 0
      sys/src/cmd/acid/lex.c
  91. 11 5
      sys/src/cmd/acid/main.c
  92. 10 2
      sys/src/cmd/acid/mkfile
  93. 14 7
      sys/src/cmd/aux/vga/virge.c
  94. 18 15
      sys/src/cmd/vnc/vncs.c
  95. 1 0
      sys/src/cmd/vnc/vncs.h
  96. 10 10
      sys/src/libsunrpc/client.c

+ 5 - 0
acme/bin/wnew

@@ -0,0 +1,5 @@
+#!/bin/rc -e
+
+id=`{mkwnew $*}
+cat >/mnt/acme/$id/body
+echo clean >/mnt/acme/$id/ctl

+ 105 - 22
dist/replica/plan9.db

@@ -27,10 +27,13 @@
 386/bin/ape - 20000000775 sys sys 1016944144 0
 386/bin/ape/basename - 775 sys sys 1038443079 135228
 386/bin/ape/cc - 775 sys sys 1045537935 68930
+386/bin/ape/diff - 775 sys sys 1046198795 345686
+386/bin/ape/diff3 - 775 sys sys 1046198796 187364
 386/bin/ape/dirname - 775 sys sys 1039673023 135007
 386/bin/ape/expr - 775 sys sys 1038443080 144796
 386/bin/ape/kill - 775 sys sys 1038443080 140422
 386/bin/ape/make - 775 sys sys 1045537935 205170
+386/bin/ape/patch - 775 sys sys 1046198797 298449
 386/bin/ape/psh - 775 sys sys 1042220689 34
 386/bin/ape/sed - 775 sys sys 1038443081 160382
 386/bin/ape/sh - 775 sys sys 1045537937 477563
@@ -105,13 +108,13 @@
 386/bin/aux/ms2 - 775 sys sys 1045537953 84053
 386/bin/aux/mswordstrings - 775 sys sys 1039758542 64268
 386/bin/aux/na - 775 sys sys 1045537953 152774
-386/bin/aux/nfsmount - 775 sys sys 1045776646 231149
+386/bin/aux/nfsmount - 775 sys sys 1046182497 231137
 386/bin/aux/nfsserver - 775 sys sys 1045537954 171046
 386/bin/aux/olefs - 775 sys sys 1045537954 144352
 386/bin/aux/p9bitpost - 775 sys sys 1039758543 127979
 386/bin/aux/pcmcia - 775 sys sys 1039758543 46790
 386/bin/aux/pcnfsd - 775 sys sys 1045537955 126750
-386/bin/aux/portmap - 775 sys sys 1045776646 140702
+386/bin/aux/portmap - 775 sys sys 1046182498 140690
 386/bin/aux/portmapper - 775 sys sys 1045537955 125638
 386/bin/aux/postgif - 775 sys sys 1038443100 177440
 386/bin/aux/postprint - 775 sys sys 1038443101 161939
@@ -296,7 +299,7 @@
 386/bin/netkey - 775 sys sys 1039758579 70753
 386/bin/netstat - 775 sys sys 1045538036 81379
 386/bin/news - 775 sys sys 1045538036 70512
-386/bin/nfs - 775 sys sys 1045776647 315503
+386/bin/nfs - 775 sys sys 1046182499 315491
 386/bin/nm - 775 sys sys 1045538037 123227
 386/bin/nntpfs - 775 sys sys 1045538038 161729
 386/bin/ns - 775 sys sys 1039758580 63830
@@ -436,7 +439,7 @@
 386/bin/venti/verifyarena - 775 sys sys 1045538088 105156
 386/bin/venti/wrarena - 775 sys sys 1045538089 178907
 386/bin/venti/write - 775 sys sys 1045538089 100592
-386/bin/vncs - 775 sys sys 1045776648 437987
+386/bin/vncs - 775 sys sys 1046182501 438050
 386/bin/vncv - 775 sys sys 1045776649 266165
 386/bin/vt - 775 sys sys 1045538092 170883
 386/bin/vtdump - 775 sys sys 1045538093 160937
@@ -488,7 +491,7 @@
 386/lib/libl.a - 664 sys sys 1045538121 5412
 386/lib/libmach.a - 664 sys sys 1045538123 743792
 386/lib/libmemdraw.a - 664 sys sys 1045538124 292324
-386/lib/libmemlayer.a - 664 sys sys 1045538125 47116
+386/lib/libmemlayer.a - 664 sys sys 1046182506 47256
 386/lib/libmp.a - 664 sys sys 1045538125 77064
 386/lib/libndb.a - 664 sys sys 1045538125 52836
 386/lib/libplumb.a - 664 sys sys 1045538125 19000
@@ -496,7 +499,7 @@
 386/lib/libscribble.a - 664 sys sys 1045538126 108138
 386/lib/libsec.a - 664 sys sys 1045538128 635686
 386/lib/libstdio.a - 664 sys sys 1045538128 125144
-386/lib/libsunrpc.a - 664 sys sys 1045776662 355322
+386/lib/libsunrpc.a - 664 sys sys 1046182507 355304
 386/lib/libthread.a - 664 sys sys 1045538129 71494
 386/lib/libventi.a - 664 sys sys 1045538129 97938
 386/mbr - 775 sys sys 1022125974 407
@@ -563,7 +566,6 @@ acme/bin/386/adict - 775 sys sys 1015011247 99806
 acme/bin/386/mkwnew - 775 sys sys 1045538113 39475
 acme/bin/386/spout - 775 sys sys 1045538113 60277
 acme/bin/386/win - 775 sys sys 1045538114 178505
-acme/bin/386/wnew - 775 sys sys 1015011247 51934
 acme/bin/Battery - 775 sys sys 1017457907 451
 acme/bin/Perl - 775 sys sys 1015011260 230
 acme/bin/README - 664 sys sys 1015011256 174
@@ -617,6 +619,7 @@ acme/bin/source/win/pipe.c - 664 sys sys 1017679345 2807
 acme/bin/source/win/util.c - 664 sys sys 1017679346 1169
 acme/bin/source/win/win.c - 664 sys sys 1015011255 4240
 acme/bin/unind - 755 sys sys 1015011256 27
+acme/bin/wnew - 775 sys sys 1046184422 84
 acme/mail - 20000000775 sys sys 1015011265 0
 acme/mail/386 - 20000000775 sys sys 1015011538 0
 acme/mail/386/Mail - 775 sys sys 1045538114 176629
@@ -2667,7 +2670,7 @@ lib/namespace.ftp - 664 sys sys 1020313578 373
 lib/namespace.httpd - 664 sys sys 984695868 1209
 lib/ndb - 20000000775 sys sys 959260770 0
 lib/ndb/auth - 664 sys sys 959260674 586
-lib/ndb/common - 664 sys sys 1021579967 5168
+lib/ndb/common - 664 sys sys 1046232038 5226
 lib/ndb/consoledb - 664 sys sys 960222421 95
 lib/ndb/dhcp - 20000000775 sys sys 959260749 0
 lib/ndb/dnsdump - 664 sys sys 1032057649 61
@@ -2695,7 +2698,7 @@ lib/tftpd - 20000000775 sys sys 944944178 0
 lib/unicode - 664 sys sys 958440028 223312
 lib/unicode.notice - 664 sys sys 958504386 1398
 lib/units - 664 sys sys 1014923483 9984
-lib/vgadb - 664 sys sys 1039156374 28040
+lib/vgadb - 664 sys sys 1046203906 28125
 lib/volcanoes - 664 sys sys 944944024 119831
 lib/words - 664 sys sys 1014923442 247097
 lp - 20000000775 sys sys 958199268 0
@@ -4411,7 +4414,7 @@ sys/man/1/2c - 664 sys sys 1016731553 7349
 sys/man/1/2l - 664 sys sys 944959675 4074
 sys/man/1/INDEX - 664 sys sys 1045538129 2900
 sys/man/1/INDEX.html - 664 sys sys 1026845791 15882
-sys/man/1/acid - 664 sys sys 1016833872 9422
+sys/man/1/acid - 664 sys sys 1046201556 9731
 sys/man/1/acme - 664 sys sys 1019828741 17587
 sys/man/1/ar - 664 sys sys 1030970308 3109
 sys/man/1/ascii - 664 sys sys 957920005 2733
@@ -5194,8 +5197,8 @@ sys/src/9/pc/vgamga4xx.c - 664 sys sys 1015014527 11122
 sys/src/9/pc/vganeomagic.c - 664 sys sys 1032375144 10693
 sys/src/9/pc/vganvidia.c - 664 sys sys 1020284821 6841
 sys/src/9/pc/vgargb524.c - 664 sys sys 1015014527 4235
-sys/src/9/pc/vgas3.c - 664 sys sys 1015014527 11832
-sys/src/9/pc/vgasavage.c - 664 sys sys 1026847655 16130
+sys/src/9/pc/vgas3.c - 664 sys sys 1046203924 11986
+sys/src/9/pc/vgasavage.c - 664 sys sys 1046203931 16194
 sys/src/9/pc/vgat2r4.c - 664 sys sys 1015014528 10355
 sys/src/9/pc/vgatvp3020.c - 664 sys sys 1015014528 4491
 sys/src/9/pc/vgatvp3026.c - 664 sys sys 1015014528 3940
@@ -5298,6 +5301,44 @@ sys/src/ape/cmd - 20000000775 sys sys 1014921977 0
 sys/src/ape/cmd/README - 664 sys sys 1014921974 2953
 sys/src/ape/cmd/basename.c - 664 sys sys 1014921974 729
 sys/src/ape/cmd/cc.c - 664 sys sys 1023741702 7363
+sys/src/ape/cmd/diff - 20000000775 sys sys 1046198752 0
+sys/src/ape/cmd/diff/COPYING - 664 sys sys 1046198741 17982
+sys/src/ape/cmd/diff/ChangeLog - 664 sys sys 1046198741 66704
+sys/src/ape/cmd/diff/FREEBSD-upgrade - 664 sys sys 1046198741 354
+sys/src/ape/cmd/diff/NEWS - 664 sys sys 1046198742 4827
+sys/src/ape/cmd/diff/README - 664 sys sys 1046198742 424
+sys/src/ape/cmd/diff/analyze.c - 664 sys sys 1046198742 31324
+sys/src/ape/cmd/diff/cmpbuf.c - 664 sys sys 1046198743 1185
+sys/src/ape/cmd/diff/cmpbuf.h - 664 sys sys 1046198743 833
+sys/src/ape/cmd/diff/config.h - 664 sys sys 1046198743 3406
+sys/src/ape/cmd/diff/context.c - 664 sys sys 1046198743 13241
+sys/src/ape/cmd/diff/diagmeet.note - 664 sys sys 1046198743 1069
+sys/src/ape/cmd/diff/diff.c - 664 sys sys 1046198744 30831
+sys/src/ape/cmd/diff/diff.h - 664 sys sys 1046198744 11767
+sys/src/ape/cmd/diff/diff.texi - 664 sys sys 1046198745 150414
+sys/src/ape/cmd/diff/diff3.c - 664 sys sys 1046198745 50145
+sys/src/ape/cmd/diff/dir.c - 664 sys sys 1046198745 6178
+sys/src/ape/cmd/diff/ed.c - 664 sys sys 1046198745 5288
+sys/src/ape/cmd/diff/fnmatch.c - 664 sys sys 1046198746 4105
+sys/src/ape/cmd/diff/fnmatch.h - 664 sys sys 1046198746 1416
+sys/src/ape/cmd/diff/getopt.c - 664 sys sys 1046198746 21723
+sys/src/ape/cmd/diff/getopt.h - 664 sys sys 1046198746 4412
+sys/src/ape/cmd/diff/getopt1.c - 664 sys sys 1046198747 4228
+sys/src/ape/cmd/diff/ifdef.c - 664 sys sys 1046198747 10041
+sys/src/ape/cmd/diff/install-sh - 775 sys sys 1046198747 4771
+sys/src/ape/cmd/diff/io.c - 664 sys sys 1046198748 20341
+sys/src/ape/cmd/diff/mkfile - 664 sys sys 1046198748 557
+sys/src/ape/cmd/diff/normal.c - 664 sys sys 1046198748 2214
+sys/src/ape/cmd/diff/prepend_args.c - 664 sys sys 1046198748 2538
+sys/src/ape/cmd/diff/prepend_args.h - 664 sys sys 1046198749 979
+sys/src/ape/cmd/diff/regex.c - 664 sys sys 1046198749 186345
+sys/src/ape/cmd/diff/regex.h - 664 sys sys 1046198749 19353
+sys/src/ape/cmd/diff/sdiff.c - 664 sys sys 1046198750 23417
+sys/src/ape/cmd/diff/side.c - 664 sys sys 1046198750 7012
+sys/src/ape/cmd/diff/system.h - 664 sys sys 1046198750 5744
+sys/src/ape/cmd/diff/util.c - 664 sys sys 1046198750 18335
+sys/src/ape/cmd/diff/version.c - 664 sys sys 1046198750 94
+sys/src/ape/cmd/diff/xmalloc.c - 664 sys sys 1046198751 1828
 sys/src/ape/cmd/dirname.c - 664 sys sys 1039388400 539
 sys/src/ape/cmd/expr - 20000000775 sys sys 1014921975 0
 sys/src/ape/cmd/expr/expr.y - 664 sys sys 1014921975 5394
@@ -5407,6 +5448,48 @@ sys/src/ape/cmd/make/main.c - 664 sys sys 1014921974 7652
 sys/src/ape/cmd/make/misc.c - 664 sys sys 1014921974 7176
 sys/src/ape/cmd/make/mkfile - 664 sys sys 1014921974 337
 sys/src/ape/cmd/mkfile - 664 sys sys 1014921973 522
+sys/src/ape/cmd/patch - 20000000775 sys sys 1046198789 0
+sys/src/ape/cmd/patch/COPYING - 664 sys sys 1046198780 18007
+sys/src/ape/cmd/patch/ChangeLog - 664 sys sys 1046198780 66042
+sys/src/ape/cmd/patch/FREEBSD-upgrade - 664 sys sys 1046198780 1113
+sys/src/ape/cmd/patch/INSTALL - 664 sys sys 1046198781 7832
+sys/src/ape/cmd/patch/Makefile.in - 664 sys sys 1046198781 4495
+sys/src/ape/cmd/patch/NEWS - 664 sys sys 1046198781 7498
+sys/src/ape/cmd/patch/README - 664 sys sys 1046198781 2385
+sys/src/ape/cmd/patch/acconfig.h - 664 sys sys 1046198781 452
+sys/src/ape/cmd/patch/addext.c - 664 sys sys 1046198782 2605
+sys/src/ape/cmd/patch/argmatch.c - 664 sys sys 1046198782 2652
+sys/src/ape/cmd/patch/argmatch.h - 664 sys sys 1046198782 357
+sys/src/ape/cmd/patch/backupfile.c - 664 sys sys 1046198782 6739
+sys/src/ape/cmd/patch/backupfile.h - 664 sys sys 1046198783 1662
+sys/src/ape/cmd/patch/basename.c - 664 sys sys 1046198783 675
+sys/src/ape/cmd/patch/common.h - 664 sys sys 1046198783 6153
+sys/src/ape/cmd/patch/config.h - 664 sys sys 1046198783 3428
+sys/src/ape/cmd/patch/config.hin - 664 sys sys 1046198783 3406
+sys/src/ape/cmd/patch/configure - 775 sys sys 1046198784 70943
+sys/src/ape/cmd/patch/configure.in - 664 sys sys 1046198784 3545
+sys/src/ape/cmd/patch/getopt.c - 664 sys sys 1046198784 30164
+sys/src/ape/cmd/patch/getopt.h - 664 sys sys 1046198784 4558
+sys/src/ape/cmd/patch/getopt1.c - 664 sys sys 1046198784 4518
+sys/src/ape/cmd/patch/inp.c - 664 sys sys 1046198785 11253
+sys/src/ape/cmd/patch/inp.h - 664 sys sys 1046198785 340
+sys/src/ape/cmd/patch/install-sh - 775 sys sys 1046198785 5490
+sys/src/ape/cmd/patch/maketime.c - 664 sys sys 1046198786 10415
+sys/src/ape/cmd/patch/maketime.h - 664 sys sys 1046198786 1356
+sys/src/ape/cmd/patch/mkfile - 664 sys sys 1046198786 487
+sys/src/ape/cmd/patch/partime.c - 664 sys sys 1046198787 18935
+sys/src/ape/cmd/patch/partime.h - 664 sys sys 1046198787 2136
+sys/src/ape/cmd/patch/patch.1 - 664 sys sys 1046198787 29906
+sys/src/ape/cmd/patch/patch.c - 664 sys sys 1046198787 33892
+sys/src/ape/cmd/patch/patchlevel.h - 664 sys sys 1046198788 28
+sys/src/ape/cmd/patch/pch.c - 664 sys sys 1046198788 47529
+sys/src/ape/cmd/patch/pch.h - 664 sys sys 1046198788 893
+sys/src/ape/cmd/patch/quotearg.c - 664 sys sys 1046198788 2844
+sys/src/ape/cmd/patch/quotearg.h - 664 sys sys 1046198788 234
+sys/src/ape/cmd/patch/util.c - 664 sys sys 1046198789 24520
+sys/src/ape/cmd/patch/util.h - 664 sys sys 1046198789 1553
+sys/src/ape/cmd/patch/version.c - 664 sys sys 1046198789 869
+sys/src/ape/cmd/patch/version.h - 664 sys sys 1046198789 125
 sys/src/ape/cmd/pax - 20000000775 sys sys 1014921975 0
 sys/src/ape/cmd/pax/Makefile - 664 sys sys 1014921975 3654
 sys/src/ape/cmd/pax/PATCHLEVEL - 664 sys sys 1014921975 64
@@ -6373,16 +6456,16 @@ sys/src/cmd/9nfs/unixnames.c - 664 sys sys 1040952457 5974
 sys/src/cmd/9nfs/xfile.c - 664 sys sys 1017337816 1847
 sys/src/cmd/aan.c - 664 sys sys 1019856827 9758
 sys/src/cmd/acid - 20000000775 sys sys 944960739 0
-sys/src/cmd/acid/acid.h - 664 sys sys 1014924907 4340
+sys/src/cmd/acid/acid.h - 664 sys sys 1046198958 4354
 sys/src/cmd/acid/builtin.c - 664 sys sys 1014924908 19979
-sys/src/cmd/acid/dbg.y - 664 sys sys 944960739 5417
+sys/src/cmd/acid/dbg.y - 664 sys sys 1046198962 5450
 sys/src/cmd/acid/dot.c - 664 sys sys 944960739 2161
 sys/src/cmd/acid/exec.c - 664 sys sys 1016833876 8187
-sys/src/cmd/acid/expr.c - 664 sys sys 953242926 14981
-sys/src/cmd/acid/lex.c - 664 sys sys 1016731555 7839
+sys/src/cmd/acid/expr.c - 664 sys sys 1046198961 15093
+sys/src/cmd/acid/lex.c - 664 sys sys 1046198960 7861
 sys/src/cmd/acid/list.c - 664 sys sys 944960738 3671
-sys/src/cmd/acid/main.c - 664 sys sys 1014924908 8413
-sys/src/cmd/acid/mkfile - 664 sys sys 952627560 288
+sys/src/cmd/acid/main.c - 664 sys sys 1046198959 8475
+sys/src/cmd/acid/mkfile - 664 sys sys 1046199006 366
 sys/src/cmd/acid/print.c - 664 sys sys 984756705 6840
 sys/src/cmd/acid/proc.c - 664 sys sys 1014924908 4513
 sys/src/cmd/acid/util.c - 664 sys sys 944960738 4297
@@ -6643,7 +6726,7 @@ sys/src/cmd/aux/vga/tvp3026.c - 664 sys sys 1014925013 3580
 sys/src/cmd/aux/vga/tvp3026clock.c - 664 sys sys 1014925013 1960
 sys/src/cmd/aux/vga/vga.c - 664 sys sys 1014925013 9305
 sys/src/cmd/aux/vga/vga.h - 664 sys sys 1025416295 10154
-sys/src/cmd/aux/vga/virge.c - 664 sys sys 1025416299 16801
+sys/src/cmd/aux/vga/virge.c - 664 sys sys 1046203911 17106
 sys/src/cmd/aux/vga/vision864.c - 664 sys sys 1014925014 2325
 sys/src/cmd/aux/vga/vision964.c - 664 sys sys 1014925014 3426
 sys/src/cmd/aux/vga/vision968.c - 664 sys sys 1014925014 3959
@@ -10515,8 +10598,8 @@ sys/src/cmd/vnc/rre.c - 664 sys sys 1044880750 11496
 sys/src/cmd/vnc/screen.c - 664 sys sys 1044880750 7537
 sys/src/cmd/vnc/screen.h - 664 sys sys 1044880750 880
 sys/src/cmd/vnc/vnc.h - 664 sys sys 1044880750 2626
-sys/src/cmd/vnc/vncs.c - 664 sys sys 1045758533 20939
-sys/src/cmd/vnc/vncs.h - 664 sys sys 1044880750 890
+sys/src/cmd/vnc/vncs.c - 664 sys sys 1046184848 21022
+sys/src/cmd/vnc/vncs.h - 664 sys sys 1046200146 908
 sys/src/cmd/vnc/vncv.c - 664 sys sys 1044880750 3093
 sys/src/cmd/vnc/vncv.h - 664 sys sys 1044880750 643
 sys/src/cmd/vnc/wsys.c - 664 sys sys 1045758533 4049
@@ -11675,7 +11758,7 @@ sys/src/libstdio/vsprintf.c - 664 sys sys 1022112162 246
 sys/src/libsunrpc - 20000000775 sys sys 1045589225 0
 sys/src/libsunrpc/COPYING - 664 sys sys 1045589219 1269
 sys/src/libsunrpc/authunix.c - 664 sys sys 1045589219 1477
-sys/src/libsunrpc/client.c - 664 sys sys 1045941140 8862
+sys/src/libsunrpc/client.c - 664 sys sys 1046184855 8902
 sys/src/libsunrpc/emalloc.c - 664 sys sys 1045589220 397
 sys/src/libsunrpc/error.c - 664 sys sys 1045589221 819
 sys/src/libsunrpc/fd.c - 664 sys sys 1045589221 1734

+ 106 - 0
dist/replica/plan9.log

@@ -17962,3 +17962,109 @@
 1045935042 0 c sys/src/libmemlayer/draw.c - 664 sys sys 1045933975 4082
 1045941599 0 c sys/src/libsunrpc/client.c - 664 sys sys 1045941140 8862
 1046043045 0 c sys/man/2/sechash - 664 sys sys 1046042040 3016
+1046183430 0 c 386/bin/vncs - 775 sys sys 1046182501 438050
+1046183430 1 c 386/bin/aux/nfsmount - 775 sys sys 1046182497 231137
+1046183430 2 c 386/bin/aux/portmap - 775 sys sys 1046182498 140690
+1046183430 3 c 386/bin/nfs - 775 sys sys 1046182499 315491
+1046183430 4 c 386/lib/libmemlayer.a - 664 sys sys 1046182506 47256
+1046183430 5 c 386/lib/libsunrpc.a - 664 sys sys 1046182507 355304
+1046184225 0 d acme/bin/386/wnew - 775 sys sys 1015011247 0
+1046184448 0 a acme/bin/wnew - 775 sys sys 1046184422 84
+1046185230 0 c sys/src/cmd/vnc/vncs.c - 664 sys sys 1046184848 21022
+1046185230 1 c sys/src/libsunrpc/client.c - 664 sys sys 1046184855 8902
+1046198844 0 a 386/bin/ape/diff - 775 sys sys 1046198795 345686
+1046198844 1 a 386/bin/ape/diff3 - 775 sys sys 1046198796 187364
+1046198844 2 a 386/bin/ape/patch - 775 sys sys 1046198797 298449
+1046198844 3 a sys/src/ape/cmd/diff - 20000000775 sys sys 1046198752 0
+1046198844 4 a sys/src/ape/cmd/diff/COPYING - 664 sys sys 1046198741 17982
+1046198844 5 a sys/src/ape/cmd/diff/ChangeLog - 664 sys sys 1046198741 66704
+1046198844 6 a sys/src/ape/cmd/diff/FREEBSD-upgrade - 664 sys sys 1046198741 354
+1046198844 7 a sys/src/ape/cmd/diff/NEWS - 664 sys sys 1046198742 4827
+1046198844 8 a sys/src/ape/cmd/diff/README - 664 sys sys 1046198742 424
+1046198844 9 a sys/src/ape/cmd/diff/analyze.c - 664 sys sys 1046198742 31324
+1046198844 10 a sys/src/ape/cmd/diff/cmpbuf.c - 664 sys sys 1046198743 1185
+1046198844 11 a sys/src/ape/cmd/diff/cmpbuf.h - 664 sys sys 1046198743 833
+1046198844 12 a sys/src/ape/cmd/diff/config.h - 664 sys sys 1046198743 3406
+1046198844 13 a sys/src/ape/cmd/diff/context.c - 664 sys sys 1046198743 13241
+1046198844 14 a sys/src/ape/cmd/diff/diagmeet.note - 664 sys sys 1046198743 1069
+1046198844 15 a sys/src/ape/cmd/diff/diff.c - 664 sys sys 1046198744 30831
+1046198844 16 a sys/src/ape/cmd/diff/diff.h - 664 sys sys 1046198744 11767
+1046198844 17 a sys/src/ape/cmd/diff/diff.texi - 664 sys sys 1046198745 150414
+1046198844 18 a sys/src/ape/cmd/diff/diff3.c - 664 sys sys 1046198745 50145
+1046198844 19 a sys/src/ape/cmd/diff/dir.c - 664 sys sys 1046198745 6178
+1046198844 20 a sys/src/ape/cmd/diff/ed.c - 664 sys sys 1046198745 5288
+1046198844 21 a sys/src/ape/cmd/diff/fnmatch.c - 664 sys sys 1046198746 4105
+1046198844 22 a sys/src/ape/cmd/diff/fnmatch.h - 664 sys sys 1046198746 1416
+1046198844 23 a sys/src/ape/cmd/diff/getopt.c - 664 sys sys 1046198746 21723
+1046198844 24 a sys/src/ape/cmd/diff/getopt.h - 664 sys sys 1046198746 4412
+1046198844 25 a sys/src/ape/cmd/diff/getopt1.c - 664 sys sys 1046198747 4228
+1046198844 26 a sys/src/ape/cmd/diff/ifdef.c - 664 sys sys 1046198747 10041
+1046198844 27 a sys/src/ape/cmd/diff/install-sh - 775 sys sys 1046198747 4771
+1046198844 28 a sys/src/ape/cmd/diff/io.c - 664 sys sys 1046198748 20341
+1046198844 29 a sys/src/ape/cmd/diff/mkfile - 664 sys sys 1046198748 557
+1046198844 30 a sys/src/ape/cmd/diff/normal.c - 664 sys sys 1046198748 2214
+1046198844 31 a sys/src/ape/cmd/diff/prepend_args.c - 664 sys sys 1046198748 2538
+1046198844 32 a sys/src/ape/cmd/diff/prepend_args.h - 664 sys sys 1046198749 979
+1046198844 33 a sys/src/ape/cmd/diff/regex.c - 664 sys sys 1046198749 186345
+1046198844 34 a sys/src/ape/cmd/diff/regex.h - 664 sys sys 1046198749 19353
+1046198844 35 a sys/src/ape/cmd/diff/sdiff.c - 664 sys sys 1046198750 23417
+1046198844 36 a sys/src/ape/cmd/diff/side.c - 664 sys sys 1046198750 7012
+1046198844 37 a sys/src/ape/cmd/diff/system.h - 664 sys sys 1046198750 5744
+1046198844 38 a sys/src/ape/cmd/diff/util.c - 664 sys sys 1046198750 18335
+1046198844 39 a sys/src/ape/cmd/diff/version.c - 664 sys sys 1046198750 94
+1046198844 40 a sys/src/ape/cmd/diff/xmalloc.c - 664 sys sys 1046198751 1828
+1046198844 41 a sys/src/ape/cmd/patch - 20000000775 sys sys 1046198789 0
+1046198844 42 a sys/src/ape/cmd/patch/COPYING - 664 sys sys 1046198780 18007
+1046198844 43 a sys/src/ape/cmd/patch/ChangeLog - 664 sys sys 1046198780 66042
+1046198844 44 a sys/src/ape/cmd/patch/FREEBSD-upgrade - 664 sys sys 1046198780 1113
+1046198844 45 a sys/src/ape/cmd/patch/INSTALL - 664 sys sys 1046198781 7832
+1046198844 46 a sys/src/ape/cmd/patch/Makefile.in - 664 sys sys 1046198781 4495
+1046198844 47 a sys/src/ape/cmd/patch/NEWS - 664 sys sys 1046198781 7498
+1046198844 48 a sys/src/ape/cmd/patch/README - 664 sys sys 1046198781 2385
+1046198844 49 a sys/src/ape/cmd/patch/acconfig.h - 664 sys sys 1046198781 452
+1046198844 50 a sys/src/ape/cmd/patch/addext.c - 664 sys sys 1046198782 2605
+1046198844 51 a sys/src/ape/cmd/patch/argmatch.c - 664 sys sys 1046198782 2652
+1046198844 52 a sys/src/ape/cmd/patch/argmatch.h - 664 sys sys 1046198782 357
+1046198844 53 a sys/src/ape/cmd/patch/backupfile.c - 664 sys sys 1046198782 6739
+1046198844 54 a sys/src/ape/cmd/patch/backupfile.h - 664 sys sys 1046198783 1662
+1046198844 55 a sys/src/ape/cmd/patch/basename.c - 664 sys sys 1046198783 675
+1046198844 56 a sys/src/ape/cmd/patch/common.h - 664 sys sys 1046198783 6153
+1046198844 57 a sys/src/ape/cmd/patch/config.h - 664 sys sys 1046198783 3428
+1046198844 58 a sys/src/ape/cmd/patch/config.hin - 664 sys sys 1046198783 3406
+1046198844 59 a sys/src/ape/cmd/patch/configure - 775 sys sys 1046198784 70943
+1046198844 60 a sys/src/ape/cmd/patch/configure.in - 664 sys sys 1046198784 3545
+1046198844 61 a sys/src/ape/cmd/patch/getopt.c - 664 sys sys 1046198784 30164
+1046198844 62 a sys/src/ape/cmd/patch/getopt.h - 664 sys sys 1046198784 4558
+1046198844 63 a sys/src/ape/cmd/patch/getopt1.c - 664 sys sys 1046198784 4518
+1046198844 64 a sys/src/ape/cmd/patch/inp.c - 664 sys sys 1046198785 11253
+1046198844 65 a sys/src/ape/cmd/patch/inp.h - 664 sys sys 1046198785 340
+1046198844 66 a sys/src/ape/cmd/patch/install-sh - 775 sys sys 1046198785 5490
+1046198844 67 a sys/src/ape/cmd/patch/maketime.c - 664 sys sys 1046198786 10415
+1046198844 68 a sys/src/ape/cmd/patch/maketime.h - 664 sys sys 1046198786 1356
+1046198844 69 a sys/src/ape/cmd/patch/mkfile - 664 sys sys 1046198786 487
+1046198844 70 a sys/src/ape/cmd/patch/partime.c - 664 sys sys 1046198787 18935
+1046198844 71 a sys/src/ape/cmd/patch/partime.h - 664 sys sys 1046198787 2136
+1046198844 72 a sys/src/ape/cmd/patch/patch.1 - 664 sys sys 1046198787 29906
+1046198844 73 a sys/src/ape/cmd/patch/patch.c - 664 sys sys 1046198787 33892
+1046198844 74 a sys/src/ape/cmd/patch/patchlevel.h - 664 sys sys 1046198788 28
+1046198844 75 a sys/src/ape/cmd/patch/pch.c - 664 sys sys 1046198788 47529
+1046198844 76 a sys/src/ape/cmd/patch/pch.h - 664 sys sys 1046198788 893
+1046198844 77 a sys/src/ape/cmd/patch/quotearg.c - 664 sys sys 1046198788 2844
+1046198844 78 a sys/src/ape/cmd/patch/quotearg.h - 664 sys sys 1046198788 234
+1046198844 79 a sys/src/ape/cmd/patch/util.c - 664 sys sys 1046198789 24520
+1046198844 80 a sys/src/ape/cmd/patch/util.h - 664 sys sys 1046198789 1553
+1046198844 81 a sys/src/ape/cmd/patch/version.c - 664 sys sys 1046198789 869
+1046198844 82 a sys/src/ape/cmd/patch/version.h - 664 sys sys 1046198789 125
+1046199016 0 c sys/src/cmd/acid/acid.h - 664 sys sys 1046198958 4354
+1046199016 1 c sys/src/cmd/acid/dbg.y - 664 sys sys 1046198962 5450
+1046199016 2 c sys/src/cmd/acid/expr.c - 664 sys sys 1046198961 15093
+1046199016 3 c sys/src/cmd/acid/lex.c - 664 sys sys 1046198960 7861
+1046199016 4 c sys/src/cmd/acid/main.c - 664 sys sys 1046198959 8475
+1046199016 5 c sys/src/cmd/acid/mkfile - 664 sys sys 1046199006 366
+1046200149 0 c sys/src/cmd/vnc/vncs.h - 664 sys sys 1046200146 908
+1046203231 0 c sys/man/1/acid - 664 sys sys 1046201556 9731
+1046205032 0 c lib/vgadb - 664 sys sys 1046203906 28125
+1046205032 1 c sys/src/9/pc/vgas3.c - 664 sys sys 1046203924 11986
+1046205032 2 c sys/src/9/pc/vgasavage.c - 664 sys sys 1046203931 16194
+1046205032 3 c sys/src/cmd/aux/vga/virge.c - 664 sys sys 1046203911 17106
+1046232065 0 c lib/ndb/common - 664 sys sys 1046232038 5226

+ 4 - 1
lib/ndb/common

@@ -135,7 +135,7 @@ tcp=x400-snd port=104
 tcp=csnet-ns port=105
 tcp=pop-2 port=109
 tcp=pop3 port=110
-tcp=sunrpc port=111
+tcp=portmap port=111
 tcp=uucp-path port=117
 tcp=nntp port=119
 tcp=netbios port=139
@@ -167,6 +167,7 @@ tcp=imaps port=993
 tcp=pop3s port=995
 tcp=ingreslock port=1524
 tcp=pptp port=1723
+tcp=nfs port=2049
 tcp=webster port=2627
 tcp=weather port=3000
 tcp=secstore port=5356
@@ -209,9 +210,11 @@ udp=bootpc port=68
 udp=bootp port=67
 udp=domain port=53
 udp=dns port=53
+udp=portmap port=111
 udp=ntp port=123
 udp=snmp port=161
 udp=rip port=520
+udp=nfs port=2049
 udp=bfs port=2201
 udp=virgil port=2202
 udp=bandt2 port=7331

+ 2 - 0
lib/vgadb

@@ -139,6 +139,8 @@ ctlr
 	# vid=0x5333 did=0x8A20		# Savage 3D, not supported
 	# vid=0x5333 did=0x8A21		# Savage 3DMV, not supported
 	vid=0x5333 did=0x8A22		# Savage 4
+	vid=0x5333 did=0x8A25		# ProSavage PN133
+	vid=0x5333 did=0x8A26		# ProSavage KN133 
 	vid=0x5333 did=0x883D		# ViRGE VX
 	vid=0x5333 did=0x8C01		# ViRGE MX
 	vid=0x5333 did=0x8C03		# ViRGE MXP

+ 20 - 0
sys/man/1/acid

@@ -158,12 +158,32 @@ Statements are
 .br
 .BI defn " name" ( args ") {" " statement \fP}
 .br
+.BI defn " name"
+.br
+.IB name ( args )
+.br
+.BI builtin " name" ( args )
+.br
 .BI local " name
 .br
 .BI return " expr
 .br
 .BR whatis " [ \fI name \fP]
 .PP
+The statement
+.B defn
+.I name
+clears the definition for
+.IR name .
+A
+.B defn
+may override a built-in function;
+prefixing a function call with
+.B builtin
+ignores any overriding
+.BR defn ,
+forcing the use of the built-in function.
+.PP
 Here is a partial list of functions; see the manual for a complete list.
 .TF asm(address)
 .TP

+ 8 - 0
sys/src/9/pc/vgas3.c

@@ -18,6 +18,8 @@ enum {
 	SAVAGE3D	= 0x8A20,	/* PCI DID */
 	SAVAGE3DMV	= 0x8A21,
 	SAVAGE4		= 0x8A22,
+	PROSAVAGEP	= 0x8A25,
+	PROSAVAGEK	= 0x8A26,
 	SAVAGEMXMV	= 0x8C10,
 	SAVAGEMX	= 0x8C11,
 	SAVAGEIXMV	= 0x8C12,
@@ -127,6 +129,8 @@ s3linear(VGAscr* scr, int* size, int* align)
 		id = (vgaxi(Crtx, 0x2D)<<8)|vgaxi(Crtx, 0x2E);
 		switch(id){			/* find mmio */
 		case SAVAGE4:
+		case PROSAVAGEP:
+		case PROSAVAGEK:
 		case SUPERSAVAGEIXC16:
 			/*
 			 * We could assume that the MMIO registers
@@ -227,6 +231,8 @@ s3load(VGAscr* scr, Cursor* curs)
 	case SAVAGEMXMV:
 	case SAVAGEIXMV:
 	case SAVAGE4:
+	case PROSAVAGEP:
+	case PROSAVAGEK:
 	case SUPERSAVAGEIXC16:
 		dolock = 0;
 		p += scr->storage;
@@ -577,6 +583,8 @@ s3drawinit(VGAscr *scr)
 		break;
 	case SUPERSAVAGEIXC16:
 	case SAVAGE4:
+	case PROSAVAGEP:
+	case PROSAVAGEK:
 		/* scr->mmio is set by s3linear */
 		savageinit(scr);
 		break;

+ 6 - 3
sys/src/9/pc/vgasavage.c

@@ -18,7 +18,8 @@ enum {
 	SAVAGE3D	= 0x8A20,	/* PCI DID */
 	SAVAGE3DMV	= 0x8A21,
 	SAVAGE4		= 0x8A22,
-	SAVAGE4A	= 0x8A26,
+	PROSAVAGEP	= 0x8A25,
+	PROSAVAGEK	= 0x8A26,
 	SAVAGEMXMV	= 0x8C10,
 	SAVAGEMX	= 0x8C11,
 	SAVAGEIXMV	= 0x8C12,
@@ -363,7 +364,8 @@ savagewaitidle(VGAscr *scr)
 
 	switch(scr->id){
 	case SAVAGE4:
-	case SAVAGE4A:
+	case PROSAVAGEP:
+	case PROSAVAGEK:
 		/* wait for engine idle and FIFO empty */
 		statw = (ulong*)((uchar*)scr->mmio+AltStatus0);
 		mask = CBEMask | Ge2Idle;
@@ -492,7 +494,8 @@ savageinit(VGAscr *scr)
 	/* if you add chip IDs here be sure to update savagewaitidle */
 	switch(scr->id){
 	case SAVAGE4:
-	case SAVAGE4A:
+	case PROSAVAGEP:
+	case PROSAVAGEK:
 	case SAVAGEIXMV:
 	case SUPERSAVAGEIXC16:
 	case SAVAGEMXMV:

+ 339 - 0
sys/src/ape/cmd/diff/COPYING

@@ -0,0 +1,339 @@
+		    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.

File diff suppressed because it is too large
+ 1766 - 0
sys/src/ape/cmd/diff/ChangeLog


+ 24 - 0
sys/src/ape/cmd/diff/FREEBSD-upgrade

@@ -0,0 +1,24 @@
+Import of GNU diff 2.7
+
+Original source available as ftp://prep.ai.mit.edu/pub/gnu/diffutils-2.7.tar.gz
+
+The following files and directories were removed for this import:
+
+Makefile.in
+INSTALL
+alloca.c
+cmp.c
+diff.info
+diff.info-1
+diff.info-2
+diff.info-3
+diff.info-4
+error.c
+fnmatch.c
+fnmatch.h
+memchr.c
+mkinstalldirs
+regex.c
+regex.h
+texinfo.tex
+waitpid.c

+ 126 - 0
sys/src/ape/cmd/diff/NEWS

@@ -0,0 +1,126 @@
+User-visible changes in version 2.7:
+
+* New diff option: --binary (useful only on non-Posix hosts)
+* diff -b and -w now ignore line incompleteness; -B no longer does this.
+* cmp -c now uses locale to decide which output characters to quote.
+* Help and version messages are reorganized.
+
+
+User-visible changes in version 2.6:
+
+* New cmp, diff, diff3, sdiff option: --help
+* A new heuristic for diff greatly reduces the time needed to compare
+  large input files that contain many differences.
+* Partly as a result, GNU diff's output is not exactly the same as before.
+  Usually it is a bit smaller, but sometimes it is a bit larger.
+
+
+User-visible changes in version 2.5:
+
+* New cmp option: -v --version
+
+
+User-visible changes in version 2.4:
+
+* New cmp option: --ignore-initial=BYTES
+* New diff3 option: -T --initial-tab
+* New diff option: --line-format=FORMAT
+* New diff group format specifications:
+  <PRINTF_SPEC>[eflmnEFLMN]
+      A printf spec followed by one of the following letters
+      causes the integer corresponding to that letter to be
+      printed according to the printf specification.
+      E.g. `%5df' prints the number of the first line in the
+      group in the old file using the "%5d" format.
+	e: line number just before the group in old file; equals f - 1
+	f: first line number in group in the old file
+	l: last line number in group in the old file
+	m: line number just after the group in old file; equals l + 1
+	n: number of lines in group in the old file; equals l - f + 1
+	E, F, L, M, N: likewise, for lines in the new file
+  %(A=B?T:E)
+      If A equals B then T else E.  A and B are each either a decimal
+      constant or a single letter interpreted as above.  T and E are
+      arbitrary format strings.  This format spec is equivalent to T if
+      A's value equals B's; otherwise it is equivalent to E.  For
+      example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no lines'
+      if N (the number of lines in the group in the the new file) is 0,
+      to `1 line' if N is 1, and to `%dN lines' otherwise.
+  %c'C'
+      where C is a single character, stands for the character C.  C may not
+      be a backslash or an apostrophe.  E.g. %c':' stands for a colon.
+  %c'\O'
+      where O is a string of 1, 2, or 3 octal digits, stands for the
+      character with octal code O.  E.g. %c'\0' stands for a null character.
+* New diff line format specifications:
+  <PRINTF_SPEC>n
+      The line number, printed with <PRINTF_SPEC>.
+      E.g. `%5dn' prints the line number with a "%5d" format.
+  %c'C'
+  %c'\O'
+      The character C, or with octal code O, as above.
+* Supported <PRINTF_SPEC>s have the same meaning as with printf, but must
+  match the extended regular expression %-*[0-9]*(\.[0-9]*)?[doxX].
+* The format spec %0 introduced in version 2.1 has been removed, since it
+  is incompatible with printf specs like %02d.  To represent a null char,
+  use %c'\0' instead.
+* cmp and diff now conform to Posix.2 (ISO/IEC 9945-2:1993)
+  if the underlying system conforms to Posix:
+  - Some messages' wordings are changed in minor ways.
+  - ``White space'' is now whatever C's `isspace' says it is.
+  - When comparing directories, if `diff' finds a file that is not a regular
+    file or a directory, it reports the file's type instead of diffing it.
+    (As usual, it follows symbolic links first.)
+  - When signaled, sdiff exits with the signal's status, not with status 2.
+* Now portable to hosts where int, long, pointer, etc. are not all the same
+  size.
+* `cmp - -' now works like `diff - -'.
+
+
+User-visible changes in version 2.3:
+
+* New diff option: --horizon-lines=lines
+
+
+User-visible changes in version 2.1:
+
+* New diff options:
+  --{old,new,unchanged}-line-format='format'
+  --{old,new,unchanged,changed}-group-format='format'
+  -U
+* New diff3 option:
+  -A --show-all
+* diff3 -m now defaults to -A, not -E.
+* diff3 now takes up to three -L or --label options, not just two.
+  If just two options are given, they refer to the first two input files,
+  not the first and third input files.
+* sdiff and diff -y handle incomplete lines.
+
+
+User-visible changes in version 2.0:
+
+* Add sdiff and cmp programs.
+* Add Texinfo documentation.
+* Add configure script.
+* Improve diff performance.
+* New diff options:
+-x --exclude
+-X --exclude-from
+-P --unidirectional-new-file
+-W --width
+-y --side-by-side
+--left-column
+--sdiff-merge-assist
+--suppress-common-lines
+* diff options renamed:
+--label renamed from --file-label
+--forward-ed renamed from --reversed-ed
+--paginate renamed from --print
+--entire-new-file renamed from --entire-new-files
+--new-file renamed from --new-files
+--all-text removed
+* New diff3 options:
+-v --version
+* Add long-named equivalents for other diff3 options.
+* diff options -F (--show-function-line) and -I (--ignore-matching-lines)
+  can now be given more than once.

+ 9 - 0
sys/src/ape/cmd/diff/README

@@ -0,0 +1,9 @@
+This directory contains the GNU diff, diff3, sdiff, and cmp utilities.
+Their features are a superset of the Unix features and they are
+significantly faster.  cmp has been moved here from the GNU textutils.
+
+See the file COPYING for copying conditions.
+See the file diff.texi (or diff.info*) for documentation.
+See the file INSTALL for compilation and installation instructions.
+
+Report bugs to bug-gnu-utils@prep.ai.mit.edu

File diff suppressed because it is too large
+ 1084 - 0
sys/src/ape/cmd/diff/analyze.c


+ 40 - 0
sys/src/ape/cmd/diff/cmpbuf.c

@@ -0,0 +1,40 @@
+/* Buffer primitives for comparison operations.
+   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.  */
+
+#include "system.h"
+#include "cmpbuf.h"
+
+/* Least common multiple of two buffer sizes A and B.  */
+
+size_t
+buffer_lcm (a, b)
+     size_t a, b;
+{
+  size_t m, n, r;
+
+  /* Yield reasonable values if buffer sizes are zero.  */
+  if (!a)
+    return b ? b : 8 * 1024;
+  if (!b)
+    return a;
+
+  /* n = gcd (a, b) */
+  for (m = a, n = b;  (r = m % n) != 0;  m = n, n = r)
+    continue;
+
+  return a/n * b;
+}

+ 20 - 0
sys/src/ape/cmd/diff/cmpbuf.h

@@ -0,0 +1,20 @@
+/* Buffer primitives for comparison operations.
+   Copyright (C) 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.  */
+
+size_t buffer_lcm PARAMS((size_t, size_t));

+ 118 - 0
sys/src/ape/cmd/diff/config.h

@@ -0,0 +1,118 @@
+/* config.h.  Generated automatically by configure.  */
+/* config.hin.  Generated automatically from configure.in by autoheader.  */
+
+/* Define if using alloca.c.  */
+/* #undef C_ALLOCA */
+
+/* Define if the closedir function returns void instead of int.  */
+/* #undef CLOSEDIR_VOID */
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+   This function is required for alloca.c support on those systems.  */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix).  */
+/* #undef HAVE_ALLOCA_H */
+
+/* Define if you don't have vprintf but do have _doprnt.  */
+/* #undef HAVE_DOPRNT */
+
+/* Define if your struct stat has st_blksize.  */
+/* #define HAVE_ST_BLKSIZE 1 */
+
+/* Define if you have <vfork.h>.  */
+/* #undef HAVE_VFORK_H */
+
+/* Define if you have the vprintf function.  */
+#define HAVE_VPRINTF 1
+
+/* Define if on MINIX.  */
+/* #undef _MINIX */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef pid_t */
+
+/* Define if the system does not provide POSIX.1 features except
+   with this defined.  */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define if you need to in order for stat and other things to work.  */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at run-time.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown
+ */
+/* #undef STACK_DIRECTION */
+
+/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
+/* #undef STAT_MACROS_BROKEN */
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* Define if <sys/wait.h> is compatible with Posix applications.  */
+#define HAVE_SYS_WAIT_H 1
+
+/* Define vfork as fork if vfork does not work.  */
+/* #undef vfork */
+
+/* Define if you have the dup2 function.  */
+#define HAVE_DUP2 1
+
+/* Define if you have the memchr function.  */
+#define HAVE_MEMCHR 1
+
+/* Define if you have the sigaction function.  */
+#define HAVE_SIGACTION 1
+
+/* Define if you have the strchr function.  */
+#define HAVE_STRCHR 1
+
+/* Define if you have the strerror function.  */
+#define HAVE_STRERROR 1
+
+/* Define if you have the tmpnam function.  */
+#define HAVE_TMPNAM 1
+
+/* Define if you have the <dirent.h> header file.  */
+#define HAVE_DIRENT_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <limits.h> header file.  */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <ndir.h> header file.  */
+/* #undef HAVE_NDIR_H */
+
+/* Define if you have the <stdlib.h> header file.  */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <string.h> header file.  */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <sys/dir.h> header file.  */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define if you have the <sys/file.h> header file.  */
+#define HAVE_SYS_FILE_H 1
+
+/* Define if you have the <sys/ndir.h> header file.  */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define if you have the <time.h> header file.  */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file.  */
+#define HAVE_UNISTD_H 1

+ 468 - 0
sys/src/ape/cmd/diff/context.c

@@ -0,0 +1,468 @@
+/* Context-format output routines for GNU DIFF.
+   Copyright (C) 1988,1989,1991,1992,1993,1994 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 struct change *find_hunk PARAMS((struct change *));
+static void find_function PARAMS((struct file_data const *, int, char const **, size_t *));
+static void mark_ignorable PARAMS((struct change *));
+static void pr_context_hunk PARAMS((struct change *));
+static void pr_unidiff_hunk PARAMS((struct change *));
+static void print_context_label PARAMS ((char const *, struct file_data *, char const *));
+static void print_context_number_range PARAMS((struct file_data const *, int, int));
+static void print_unidiff_number_range PARAMS((struct file_data const *, int, int));
+
+/* 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)
+     char const *mark;
+     struct file_data *inf;
+     char const *label;
+{
+  if (label)
+    fprintf (outfile, "%s %s\n", mark, label);
+  else
+    {
+      char const *ct = ctime (&inf->stat.st_mtime);
+      if (!ct)
+	ct = "?\n";
+      /* See Posix.2 section 4.17.6.1.4 for this format.  */
+      fprintf (outfile, "%s %s\t%s", mark, inf->name, ct);
+    }
+}
+
+/* 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 const *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 const *prefix;
+  char const *function;
+  size_t 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 const *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 const *function;
+  size_t 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 (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 (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 (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 const *file;
+     int linenum;
+     char const **linep;
+     size_t *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;
+      char const *line = file->linbuf[i];
+      size_t 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;
+}

+ 71 - 0
sys/src/ape/cmd/diff/diagmeet.note

@@ -0,0 +1,71 @@
+Here is a comparison matrix which shows a case in which
+it is possible for the forward and backward scan in `diag'
+to meet along a nonzero length of diagonal simultaneous
+(so that bdiag[d] and fdiag[d] are not equal)
+even though there is no snake on that diagonal at the meeting point.
+
+
+     85   1   1   1  159  1   1   17
+        1   2   3   4
+60
+    1   2
+1
+    2  	    2   3   4
+71
+    3       3  	4   5
+85
+    4  	3   4	5
+17
+    5  	4   5
+1
+    6       4  	5   6
+183
+    7       5   6   7
+10
+    8  	    6  	7
+1
+    9           6   7  	8
+12
+                7   8   9  10
+13
+       10       8   9  10
+14
+           10   9  10
+17
+       10      10
+1
+   10   9  10
+1
+	8      10      10      10
+183
+    8   7	9       9      	9
+10
+    7   6	8   9   8      	8
+1
+    6   5    		7       7
+1
+            5          	6      	6
+1
+	       	5      	5      	5
+50
+	    5   4      	4      	4
+1
+	            4   3	3
+85
+	    5   4   3   2       2
+1
+	                    2   1
+17
+	    5   4   3   2   1       1
+1
+		                1   0
+     85   1   1   1  159  1   1  17
+
+
+
+
+
+
+
+
+

File diff suppressed because it is too large
+ 1124 - 0
sys/src/ape/cmd/diff/diff.c


+ 344 - 0
sys/src/ape/cmd/diff/diff.h

@@ -0,0 +1,344 @@
+/* Shared definitions for GNU DIFF
+   Copyright (C) 1988, 89, 91, 92, 93 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 "system.h"
+#include <stdio.h>
+#ifdef __FreeBSD__
+#include <gnuregex.h>
+#else
+#include "regex.h"
+#endif
+
+#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 white space (-b).  */
+EXTERN int      ignore_space_change_flag;
+
+/* Ignore all horizontal white space (-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 contents do not match exactly.
+   This depends on various options.  */
+EXTERN int      ignore_some_line_changes;
+
+/* 1 if files may match even if their contents are not byte-for-byte identical.
+   This depends on various options.  */
+EXTERN int      ignore_some_changes;
+
+/* 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;
+
+/* 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 char *group_format[CHANGED + 1];
+
+/* Line formats for old, new, and unchanged lines.  */
+EXTERN 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_name;
+
+/* 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 const      *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.  */
+    size_t	    bufsize;
+    /* Number of valid characters now in the buffer. */
+    size_t	    buffered_chars;
+
+    /* Array of pointers to lines in the file.  */
+    char const **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. */
+    char const *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. */
+    char const *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];
+
+/* Stdio stream to output diffs to.  */
+
+EXTERN FILE *outfile;
+
+/* Declare various functions.  */
+
+/* analyze.c */
+int diff_2_files PARAMS((struct file_data[], int));
+
+/* context.c */
+void print_context_header PARAMS((struct file_data[], int));
+void print_context_script PARAMS((struct change *, int));
+
+/* diff.c */
+int excluded_filename PARAMS((char const *));
+
+/* dir.c */
+int diff_dirs PARAMS((struct file_data const[], int (*) PARAMS((char const *, char const *, char const *, char const *, int)), int));
+
+/* ed.c */
+void print_ed_script PARAMS((struct change *));
+void pr_forward_ed_script PARAMS((struct change *));
+
+/* ifdef.c */
+void print_ifdef_script PARAMS((struct change *));
+
+/* io.c */
+int read_files PARAMS((struct file_data[], int));
+int sip PARAMS((struct file_data *, int));
+void slurp PARAMS((struct file_data *));
+
+/* normal.c */
+void print_normal_script PARAMS((struct change *));
+
+/* rcs.c */
+void print_rcs_script PARAMS((struct change *));
+
+/* side.c */
+void print_sdiff_script PARAMS((struct change *));
+
+/* util.c */
+VOID *xmalloc PARAMS((size_t));
+VOID *xrealloc PARAMS((VOID *, size_t));
+char *concat PARAMS((char const *, char const *, char const *));
+char *dir_file_pathname PARAMS((char const *, char const *));
+int change_letter PARAMS((int, int));
+int line_cmp PARAMS((char const *, char const *));
+int translate_line_number PARAMS((struct file_data const *, int));
+struct change *find_change PARAMS((struct change *));
+struct change *find_reverse_change PARAMS((struct change *));
+void analyze_hunk PARAMS((struct change *, int *, int *, int *, int *, int *, int *));
+void begin_output PARAMS((void));
+void debug_script PARAMS((struct change *));
+void error PARAMS((char const *, char const *, char const *));
+void fatal PARAMS((char const *));
+void finish_output PARAMS((void));
+void message PARAMS((char const *, char const *, char const *));
+void message5 PARAMS((char const *, char const *, char const *, char const *, char const *));
+void output_1_line PARAMS((char const *, char const *, char const *, char const *));
+void perror_with_name PARAMS((char const *));
+void pfatal_with_name PARAMS((char const *));
+void print_1_line PARAMS((char const *, char const * const *));
+void print_message_queue PARAMS((void));
+void print_number_range PARAMS((int, struct file_data *, int, int));
+void print_script PARAMS((struct change *, struct change * (*) PARAMS((struct change *)), void (*) PARAMS((struct change *))));
+void setup_output PARAMS((char const *, char const *, int));
+void translate_range PARAMS((struct file_data const *, int, int, int *, int *));
+
+/* version.c */
+extern char const version_string[];

File diff suppressed because it is too large
+ 3916 - 0
sys/src/ape/cmd/diff/diff.texi


File diff suppressed because it is too large
+ 1778 - 0
sys/src/ape/cmd/diff/diff3.c


+ 216 - 0
sys/src/ape/cmd/diff/dir.c

@@ -0,0 +1,216 @@
+/* Read, sort and compare two directories.  Used for GNU DIFF.
+   Copyright (C) 1988, 1989, 1992, 1993, 1994 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"
+
+/* 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 const **names;	/* Sorted names of files in dir, 0-terminated.  */
+  char *data;	/* Allocated storage for file names.  */
+};
+
+static int compare_names PARAMS((void const *, void const *));
+static int dir_sort PARAMS((struct file_data const *, struct dirdata *));
+
+static int
+dir_sort (dir, dirdata)
+     struct file_data const *dir;
+     struct dirdata *dirdata;
+{
+  register struct dirent *next;
+  register int i;
+
+  /* Address of block containing the files that are described.  */
+  char const **names;
+
+  /* Number of files in directory.  */
+  size_t nnames;
+
+  /* Allocated and used storage for file name data.  */
+  char *data;
+  size_t data_alloc, data_used;
+
+  dirdata->names = 0;
+  dirdata->data = 0;
+  nnames = 0;
+  data = 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 = 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 = NAMLEN (next) + 1;
+
+	  /* 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;
+
+	  while (data_alloc < data_used + d_size)
+	    dirdata->data = data = xrealloc (data, data_alloc *= 2);
+	  memcpy (data + data_used, d_name, d_size);
+	  data_used += d_size;
+	  nnames++;
+	}
+      if (errno)
+	{
+	  int e = errno;
+	  closedir (reading);
+	  errno = e;
+	  return -1;
+	}
+#if CLOSEDIR_VOID
+      closedir (reading);
+#else
+      if (closedir (reading) != 0)
+	return -1;
+#endif
+    }
+
+  /* Create the `names' table from the `data' table.  */
+  dirdata->names = names = (char const **) xmalloc (sizeof (char *)
+						    * (nnames + 1));
+  for (i = 0;  i < nnames;  i++)
+    {
+      names[i] = data;
+      data += strlen (data) + 1;
+    }
+  names[nnames] = 0;
+
+  /* Sort the table.  */
+  qsort (names, nnames, sizeof (char *), compare_names);
+
+  return 0;
+}
+
+/* Sort the files now in the table.  */
+
+static int
+compare_names (file1, file2)
+     void const *file1, *file2;
+{
+  return filename_cmp (* (char const *const *) file1,
+		       * (char const *const *) 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 const filevec[];
+     int (*handle_file) PARAMS((char const *, char const *, char const *, char const *, int));
+     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 const * const *names0 = dirdata[0].names;
+      register char const * const *names1 = dirdata[1].names;
+      char const *name0 = filevec[0].name;
+      char const *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 (*names0 && filename_cmp (*names0, dir_start_file) < 0)
+	    names0++;
+	  while (*names1 && filename_cmp (*names1, dir_start_file) < 0)
+	    names1++;
+	}
+
+      /* Loop while files remain in one or both dirs.  */
+      while (*names0 || *names1)
+	{
+	  /* 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 = (!*names0 ? 1 : !*names1 ? -1
+			   : filename_cmp (*names0, *names1));
+	  int v1 = (*handle_file) (name0, 0 < nameorder ? 0 : *names0++,
+				   name1, nameorder < 0 ? 0 : *names1++,
+				   depth + 1);
+	  if (v1 > val)
+	    val = v1;
+	}
+    }
+
+  for (i = 0; i < 2; i++)
+    {
+      if (dirdata[i].names)
+	free (dirdata[i].names);
+      if (dirdata[i].data)
+	free (dirdata[i].data);
+    }
+
+  return val;
+}

+ 200 - 0
sys/src/ape/cmd/diff/ed.c

@@ -0,0 +1,200 @@
+/* Output routines for ed-script format.
+   Copyright (C) 1988, 89, 91, 92, 93 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 print_ed_hunk PARAMS((struct change *));
+static void print_rcs_hunk PARAMS((struct change *));
+static void pr_forward_ed_hunk PARAMS((struct 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]);
+    }
+}

+ 181 - 0
sys/src/ape/cmd/diff/fnmatch.c

@@ -0,0 +1,181 @@
+/* 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.  */
+
+/* Modified slightly by Brian Berliner <berliner@sun.com> and
+   Jim Blandy <jimb@cyclic.com> for CVS use */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+/* IGNORE(@ */
+/* #include <ansidecl.h> */
+/* @) */
+#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
+#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 (FOLD_FN_CHAR (*n) != FOLD_FN_CHAR (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 == '[' || FOLD_FN_CHAR (*n) == FOLD_FN_CHAR (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 (FOLD_FN_CHAR (c) != FOLD_FN_CHAR (*n))
+	    return FNM_NOMATCH;
+	}
+      
+      ++n;
+    }
+
+  if (*n == '\0')
+    return 0;
+
+  return FNM_NOMATCH;
+}

+ 40 - 0
sys/src/ape/cmd/diff/fnmatch.h

@@ -0,0 +1,40 @@
+/* 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.  */
+
+#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 */

+ 748 - 0
sys/src/ape/cmd/diff/getopt.c

@@ -0,0 +1,748 @@
+/* Getopt for GNU.
+   NOTE: getopt is now part of the C library, so if you don't know what