home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume20 / perl3.0 / part21 < prev    next >
Encoding:
Internet Message Format  |  1989-11-01  |  49.0 KB

  1. Subject:  v20i104:  Perl, a language with features of C/sed/awk/shell/etc, Part21/24
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Larry Wall <lwall@jpl-devvax.jpl.nasa.gov>
  7. Posting-number: Volume 20, Issue 104
  8. Archive-name: perl3.0/part21
  9.  
  10. #! /bin/sh
  11.  
  12. # Make a new directory for the perl sources, cd to it, and run kits 1
  13. # thru 24 through sh.  When all 24 kits have been run, read README.
  14.  
  15. echo "This is perl 3.0 kit 21 (of 24).  If kit 21 is complete, the line"
  16. echo '"'"End of kit 21 (of 24)"'" will echo at the end.'
  17. echo ""
  18. export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
  19. mkdir eg eg/g eg/scan lib t x2p 2>/dev/null
  20. echo Extracting eg/scan/scan_messages
  21. sed >eg/scan/scan_messages <<'!STUFFY!FUNK!' -e 's/X//'
  22. X#!/usr/bin/perl -P
  23. X
  24. X# $Header: scan_messages,v 3.0 89/10/18 15:15:38 lwall Locked $
  25. X
  26. X# This prints out extraordinary console messages.  You'll need to customize.
  27. X
  28. Xchdir('/usr/adm/private/memories') || die "Can't cd to memories: $!\n";
  29. X
  30. X$maxpos = `cat oldmsgs 2>&1`;
  31. X
  32. X#if defined(mc300) || defined(mc500) || defined(mc700)
  33. Xopen(Msgs, '/dev/null') || die "scan_messages: can't open messages";
  34. X#else
  35. Xopen(Msgs, '/usr/adm/messages') || die "scan_messages: can't open messages";
  36. X#endif
  37. X
  38. X($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
  39. X   $blksize,$blocks) = stat(Msgs);
  40. X
  41. Xif ($size < $maxpos) {        # Did somebody truncate messages file?
  42. X    $maxpos = 0;
  43. X}
  44. X
  45. Xseek(Msgs,$maxpos,0);        # Start where we left off last time.
  46. X
  47. Xwhile (<Msgs>) {
  48. X    s/\[(\d+)\]/#/ && s/$1/#/g;
  49. X#ifdef vax
  50. X    $_ =~ s/[A-Z][a-z][a-z] +\w+ +[0-9:]+ +\w+ +//;
  51. X    next if /root@.*:/;
  52. X    next if /^vmunix: 4.3 BSD UNIX/;
  53. X    next if /^vmunix: Copyright/;
  54. X    next if /^vmunix: avail mem =/;
  55. X    next if /^vmunix: SBIA0 at /;
  56. X    next if /^vmunix: disk ra81 is/;
  57. X    next if /^vmunix: dmf. at uba/;
  58. X    next if /^vmunix: dmf.:.*asynch/;
  59. X    next if /^vmunix: ex. at uba/;
  60. X    next if /^vmunix: ex.: HW/;
  61. X    next if /^vmunix: il. at uba/;
  62. X    next if /^vmunix: il.: hardware/;
  63. X    next if /^vmunix: ra. at uba/;
  64. X    next if /^vmunix: ra.: media/;
  65. X    next if /^vmunix: real mem/;
  66. X    next if /^vmunix: syncing disks/;
  67. X    next if /^vmunix: tms/;
  68. X    next if /^vmunix: tmscp. at uba/;
  69. X    next if /^vmunix: uba. at /;
  70. X    next if /^vmunix: uda. at /;
  71. X    next if /^vmunix: uda.: unit . ONLIN/;
  72. X    next if /^vmunix: .*buffers containing/;
  73. X    next if /^syslogd: .*newslog/;
  74. X#endif
  75. X    next if /unknown service/;
  76. X    next if /^\.\.\.$/;
  77. X    if (/^[A-Z][a-z][a-z] [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]/) {
  78. X    $pfx = '';
  79. X    next;
  80. X    }
  81. X    next if /^[ \t]*$/;
  82. X    next if /^[ 0-9]*done$/;
  83. X    if (/^A/) {
  84. X    next if /^Accounting [sr]/;
  85. X    }
  86. X    elsif (/^C/) {
  87. X    next if /^Called from/;
  88. X    next if /^Copyright/;
  89. X    }
  90. X    elsif (/^E/) {
  91. X    next if /^End traceback/;
  92. X    next if /^Ethernet address =/;
  93. X    }
  94. X    elsif (/^K/) {
  95. X    next if /^KERNEL MODE/;
  96. X    }
  97. X    elsif (/^R/) {
  98. X    next if /^Rebooting Unix/;
  99. X    }
  100. X    elsif (/^S/) {
  101. X    next if /^Sun UNIX 4\.2 Release/;
  102. X    }
  103. X    elsif (/^W/) {
  104. X    next if /^WARNING: clock gained/;
  105. X    }
  106. X    elsif (/^a/) {
  107. X    next if /^arg /;
  108. X    next if /^avail mem =/;
  109. X    }
  110. X    elsif (/^b/) {
  111. X    next if /^bwtwo[0-9] at /;
  112. X    }
  113. X    elsif (/^c/) {
  114. X    next if /^cgone[0-9] at /;
  115. X    next if /^cdp[0-9] at /;
  116. X    next if /^csr /;
  117. X    }
  118. X    elsif (/^d/) {
  119. X    next if /^dcpa: init/;
  120. X    next if /^done$/;
  121. X    next if /^dts/;
  122. X    next if /^dump i\/o error/;
  123. X    next if /^dumping to dev/;
  124. X    next if /^dump succeeded/;
  125. X    $pfx = '*' if /^dev = /;
  126. X    }
  127. X    elsif (/^e/) {
  128. X    next if /^end \*\*/;
  129. X    next if /^error in copy/;
  130. X    }
  131. X    elsif (/^f/) {
  132. X    next if /^found /;
  133. X    }
  134. X    elsif (/^i/) {
  135. X    next if /^ib[0-9] at /;
  136. X    next if /^ie[0-9] at /;
  137. X    }
  138. X    elsif (/^l/) {
  139. X    next if /^le[0-9] at /;
  140. X    }
  141. X    elsif (/^m/) {
  142. X    next if /^mem = /;
  143. X    next if /^mt[0-9] at /;
  144. X    next if /^mti[0-9] at /;
  145. X    $pfx = '*' if /^mode = /;
  146. X    }
  147. X    elsif (/^n/) {
  148. X    next if /^not found /;
  149. X    }
  150. X    elsif (/^p/) {
  151. X    next if /^page map /;
  152. X    next if /^pi[0-9] at /;
  153. X    $pfx = '*' if /^panic/;
  154. X    }
  155. X    elsif (/^q/) {
  156. X    next if /^qqq /;
  157. X    }
  158. X    elsif (/^r/) {
  159. X    next if /^read  /;
  160. X    next if /^revarp: Requesting/;
  161. X    next if /^root [od]/;
  162. X    }
  163. X    elsif (/^s/) {
  164. X    next if /^sc[0-9] at /;
  165. X    next if /^sd[0-9] at /;
  166. X    next if /^sd[0-9]: </;
  167. X    next if /^si[0-9] at /;
  168. X    next if /^si_getstatus/;
  169. X    next if /^sk[0-9] at /;
  170. X    next if /^skioctl/;
  171. X    next if /^skopen/;
  172. X    next if /^skprobe/;
  173. X    next if /^skread/;
  174. X    next if /^skwrite/;
  175. X    next if /^sky[0-9] at /;
  176. X    next if /^st[0-9] at /;
  177. X    next if /^st0:.*load/;
  178. X    next if /^stat1 = /;
  179. X    next if /^syncing disks/;
  180. X    next if /^syslogd: going down on signal 15/;
  181. X    }
  182. X    elsif (/^t/) {
  183. X    next if /^timeout [0-9]/;
  184. X    next if /^tm[0-9] at /;
  185. X    next if /^tod[0-9] at /;
  186. X    next if /^tv [0-9]/;
  187. X    $pfx = '*' if /^trap address/;
  188. X    }
  189. X    elsif (/^u/) {
  190. X    next if /^unit nsk/;
  191. X    next if /^use one of/;
  192. X    $pfx = '' if /^using/;
  193. X    next if /^using [0-9]+ buffers/;
  194. X    }
  195. X    elsif (/^x/) {
  196. X    next if /^xy[0-9] at /;
  197. X    next if /^write [0-9]/;
  198. X    next if /^xy[0-9]: </;
  199. X    next if /^xyc[0-9] at /;
  200. X    }
  201. X    elsif (/^y/) {
  202. X    next if /^yyy [0-9]/;
  203. X    }
  204. X    elsif (/^z/) {
  205. X    next if /^zs[0-9] at /;
  206. X    }
  207. X    $pfx = '*' if /^[a-z]+:$/;
  208. X    s/pid [0-9]+: //;
  209. X    if (/last message repeated ([0-9]+) time/) {
  210. X    $seen{$last} += $1;
  211. X    next;
  212. X    }
  213. X    s/^/$pfx/ if $pfx;
  214. X    unless ($seen{$_}++) {
  215. X    push(@seen,$_);
  216. X    }
  217. X    $last = $_;
  218. X}
  219. X$max = tell(Msgs);
  220. X
  221. Xopen(tmp,'|sort >oldmsgs.tmp') || die "Can't create tmp file: $!\n";
  222. Xwhile ($_ = pop(@seen)) {
  223. X    print tmp $_;
  224. X}
  225. Xclose(tmp);
  226. Xopen(tmp,'oldmsgs.tmp') || die "Can't reopen tmp file: $!\n";
  227. Xwhile (<tmp>) {
  228. X    if (/^nd:/) {
  229. X    next if $seen{$_} < 20;
  230. X    }
  231. X    if (/NFS/) {
  232. X    next if $seen{$_} < 20;
  233. X    }
  234. X    if (/no carrier/) {
  235. X    next if $seen{$_} < 20;
  236. X    }
  237. X    if (/silo overflow/) {
  238. X    next if $seen{$_} < 20;
  239. X    }
  240. X    print $seen{$_},":\t",$_;
  241. X}
  242. X
  243. Xprint `rm -f oldmsgs.tmp 2>&1; echo $max > oldmsgs 2>&1`;
  244. !STUFFY!FUNK!
  245. echo Extracting t/op.stat
  246. sed >t/op.stat <<'!STUFFY!FUNK!' -e 's/X//'
  247. X#!./perl
  248. X
  249. X# $Header: op.stat,v 3.0 89/10/18 15:31:33 lwall Locked $
  250. X
  251. Xprint "1..56\n";
  252. X
  253. Xunlink "Op.stat.tmp";
  254. Xopen(foo, ">Op.stat.tmp");
  255. X
  256. X($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
  257. X    $blksize,$blocks) = stat(foo);
  258. Xif ($nlink == 1) {print "ok 1\n";} else {print "not ok 1\n";}
  259. Xif ($mtime && $mtime == $ctime) {print "ok 2\n";} else {print "not ok 2\n";}
  260. X
  261. Xprint foo "Now is the time for all good men to come to.\n";
  262. Xclose(foo);
  263. X
  264. X$base = time;
  265. Xwhile (time == $base) {}
  266. X
  267. X`rm -f Op.stat.tmp2; ln Op.stat.tmp Op.stat.tmp2; chmod 644 Op.stat.tmp`;
  268. X
  269. X($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
  270. X    $blksize,$blocks) = stat('Op.stat.tmp');
  271. X
  272. Xif ($nlink == 2) {print "ok 3\n";} else {print "not ok 3\n";}
  273. Xif ($mtime && $mtime != $ctime) {print "ok 4\n";} else {print "not ok 4\n";}
  274. Xprint "#4    :$mtime: != :$ctime:\n";
  275. X
  276. X`cp /dev/null Op.stat.tmp`;
  277. X
  278. Xif (-z 'Op.stat.tmp') {print "ok 5\n";} else {print "not ok 5\n";}
  279. Xif (! -s 'Op.stat.tmp') {print "ok 6\n";} else {print "not ok 6\n";}
  280. X
  281. X`echo hi >Op.stat.tmp`;
  282. Xif (! -z 'Op.stat.tmp') {print "ok 7\n";} else {print "not ok 7\n";}
  283. Xif (-s 'Op.stat.tmp') {print "ok 8\n";} else {print "not ok 8\n";}
  284. X
  285. Xchmod 0,'Op.stat.tmp';
  286. X$olduid = $>;        # can't test -r if uid == 0
  287. Xeval '$> = 1;';        # so switch uid (may not be implemented)
  288. Xif (!$> || ! -r 'Op.stat.tmp') {print "ok 9\n";} else {print "not ok 9\n";}
  289. Xif (!$> || ! -w 'Op.stat.tmp') {print "ok 10\n";} else {print "not ok 10\n";}
  290. Xeval '$> = $olduid;';        # switch uid back (may not be implemented)
  291. Xif (! -x 'Op.stat.tmp') {print "ok 11\n";} else {print "not ok 11\n";}
  292. X
  293. Xforeach ((12,13,14,15,16,17)) {
  294. X    print "ok $_\n";        #deleted tests
  295. X}
  296. X
  297. Xchmod 0700,'Op.stat.tmp';
  298. Xif (-r 'Op.stat.tmp') {print "ok 18\n";} else {print "not ok 18\n";}
  299. Xif (-w 'Op.stat.tmp') {print "ok 19\n";} else {print "not ok 19\n";}
  300. Xif (-x 'Op.stat.tmp') {print "ok 20\n";} else {print "not ok 20\n";}
  301. X
  302. Xif (-f 'Op.stat.tmp') {print "ok 21\n";} else {print "not ok 21\n";}
  303. Xif (! -d 'Op.stat.tmp') {print "ok 22\n";} else {print "not ok 22\n";}
  304. X
  305. Xif (-d '.') {print "ok 23\n";} else {print "not ok 23\n";}
  306. Xif (! -f '.') {print "ok 24\n";} else {print "not ok 24\n";}
  307. X
  308. Xif (`ls -l perl` =~ /^l.*->/) {
  309. X    if (-l 'perl') {print "ok 25\n";} else {print "not ok 25\n";}
  310. X}
  311. Xelse {
  312. X    print "ok 25\n";
  313. X}
  314. X
  315. Xif (-o 'Op.stat.tmp') {print "ok 26\n";} else {print "not ok 26\n";}
  316. X
  317. Xif (-e 'Op.stat.tmp') {print "ok 27\n";} else {print "not ok 27\n";}
  318. X`rm -f Op.stat.tmp Op.stat.tmp2`;
  319. Xif (! -e 'Op.stat.tmp') {print "ok 28\n";} else {print "not ok 28\n";}
  320. X
  321. Xif (-c '/dev/tty') {print "ok 29\n";} else {print "not ok 29\n";}
  322. Xif (! -c '.') {print "ok 30\n";} else {print "not ok 30\n";}
  323. X
  324. Xif (! -e '/dev/printer' || -S '/dev/printer')
  325. X    {print "ok 31\n";}
  326. Xelse
  327. X    {print "not ok 31\n";}
  328. Xif (! -S '.') {print "ok 32\n";} else {print "not ok 32\n";}
  329. X
  330. Xif (! -e '/dev/mt0' || -b '/dev/mt0')
  331. X    {print "ok 33\n";}
  332. Xelse
  333. X    {print "not ok 33\n";}
  334. Xif (! -b '.') {print "ok 34\n";} else {print "not ok 34\n";}
  335. X
  336. X$cnt = $uid = 0;
  337. X
  338. Xwhile (</usr/bin/*>) {
  339. X    $cnt++;
  340. X    $uid++ if -u;
  341. X    last if $uid && $uid < $cnt;
  342. X}
  343. X
  344. X# I suppose this is going to fail somewhere...
  345. Xif ($uid > 0 && $uid < $cnt) {print "ok 35\n";} else {print "not ok 35\n";}
  346. X
  347. Xunless (open(tty,"/dev/tty")) {
  348. X    print STDERR "Can't open /dev/tty--run t/TEST outside of make.\n";
  349. X}
  350. Xif (-t tty) {print "ok 36\n";} else {print "not ok 36\n";}
  351. Xif (-c tty) {print "ok 37\n";} else {print "not ok 37\n";}
  352. Xclose(tty);
  353. Xif (! -t tty) {print "ok 38\n";} else {print "not ok 38\n";}
  354. Xopen(null,"/dev/null");
  355. Xif (! -t null || -e '/xenix') {print "ok 39\n";} else {print "not ok 39\n";}
  356. Xclose(null);
  357. Xif (-t) {print "ok 40\n";} else {print "not ok 40\n";}
  358. X
  359. X# These aren't strictly "stat" calls, but so what?
  360. X
  361. Xif (-T 'op.stat') {print "ok 41\n";} else {print "not ok 41\n";}
  362. Xif (! -B 'op.stat') {print "ok 42\n";} else {print "not ok 42\n";}
  363. X
  364. Xif (-B './perl') {print "ok 43\n";} else {print "not ok 43\n";}
  365. Xif (! -T './perl') {print "ok 44\n";} else {print "not ok 44\n";}
  366. X
  367. Xopen(foo,'op.stat');
  368. Xif (-T foo) {print "ok 45\n";} else {print "not ok 45\n";}
  369. Xif (! -B foo) {print "ok 46\n";} else {print "not ok 46\n";}
  370. X$_ = <foo>;
  371. Xif (/perl/) {print "ok 47\n";} else {print "not ok 47\n";}
  372. Xif (-T foo) {print "ok 48\n";} else {print "not ok 48\n";}
  373. Xif (! -B foo) {print "ok 49\n";} else {print "not ok 49\n";}
  374. Xclose(foo);
  375. X
  376. Xopen(foo,'op.stat');
  377. X$_ = <foo>;
  378. Xif (/perl/) {print "ok 50\n";} else {print "not ok 50\n";}
  379. Xif (-T foo) {print "ok 51\n";} else {print "not ok 51\n";}
  380. Xif (! -B foo) {print "ok 52\n";} else {print "not ok 52\n";}
  381. Xseek(foo,0,0);
  382. Xif (-T foo) {print "ok 53\n";} else {print "not ok 53\n";}
  383. Xif (! -B foo) {print "ok 54\n";} else {print "not ok 54\n";}
  384. Xclose(foo);
  385. X
  386. Xif (-T '/dev/null') {print "ok 55\n";} else {print "not ok 55\n";}
  387. Xif (-B '/dev/null') {print "ok 56\n";} else {print "not ok 56\n";}
  388. !STUFFY!FUNK!
  389. echo Extracting x2p/hash.c
  390. sed >x2p/hash.c <<'!STUFFY!FUNK!' -e 's/X//'
  391. X/* $Header: hash.c,v 3.0 89/10/18 15:34:50 lwall Locked $
  392. X *
  393. X *    Copyright (c) 1989, Larry Wall
  394. X *
  395. X *    You may distribute under the terms of the GNU General Public License
  396. X *    as specified in the README file that comes with the perl 3.0 kit.
  397. X *
  398. X * $Log:    hash.c,v $
  399. X * Revision 3.0  89/10/18  15:34:50  lwall
  400. X * 3.0 baseline
  401. X * 
  402. X */
  403. X
  404. X#include <stdio.h>
  405. X#include "EXTERN.h"
  406. X#include "handy.h"
  407. X#include "util.h"
  408. X#include "a2p.h"
  409. X
  410. XSTR *
  411. Xhfetch(tb,key)
  412. Xregister HASH *tb;
  413. Xchar *key;
  414. X{
  415. X    register char *s;
  416. X    register int i;
  417. X    register int hash;
  418. X    register HENT *entry;
  419. X
  420. X    if (!tb)
  421. X    return Nullstr;
  422. X    for (s=key,        i=0,    hash = 0;
  423. X      /* while */ *s;
  424. X     s++,        i++,    hash *= 5) {
  425. X    hash += *s * coeff[i];
  426. X    }
  427. X    entry = tb->tbl_array[hash & tb->tbl_max];
  428. X    for (; entry; entry = entry->hent_next) {
  429. X    if (entry->hent_hash != hash)        /* strings can't be equal */
  430. X        continue;
  431. X    if (strNE(entry->hent_key,key))    /* is this it? */
  432. X        continue;
  433. X    return entry->hent_val;
  434. X    }
  435. X    return Nullstr;
  436. X}
  437. X
  438. Xbool
  439. Xhstore(tb,key,val)
  440. Xregister HASH *tb;
  441. Xchar *key;
  442. XSTR *val;
  443. X{
  444. X    register char *s;
  445. X    register int i;
  446. X    register int hash;
  447. X    register HENT *entry;
  448. X    register HENT **oentry;
  449. X
  450. X    if (!tb)
  451. X    return FALSE;
  452. X    for (s=key,        i=0,    hash = 0;
  453. X      /* while */ *s;
  454. X     s++,        i++,    hash *= 5) {
  455. X    hash += *s * coeff[i];
  456. X    }
  457. X
  458. X    oentry = &(tb->tbl_array[hash & tb->tbl_max]);
  459. X    i = 1;
  460. X
  461. X    for (entry = *oentry; entry; i=0, entry = entry->hent_next) {
  462. X    if (entry->hent_hash != hash)        /* strings can't be equal */
  463. X        continue;
  464. X    if (strNE(entry->hent_key,key))    /* is this it? */
  465. X        continue;
  466. X    safefree((char*)entry->hent_val);
  467. X    entry->hent_val = val;
  468. X    return TRUE;
  469. X    }
  470. X    entry = (HENT*) safemalloc(sizeof(HENT));
  471. X
  472. X    entry->hent_key = savestr(key);
  473. X    entry->hent_val = val;
  474. X    entry->hent_hash = hash;
  475. X    entry->hent_next = *oentry;
  476. X    *oentry = entry;
  477. X
  478. X    if (i) {                /* initial entry? */
  479. X    tb->tbl_fill++;
  480. X    if ((tb->tbl_fill * 100 / (tb->tbl_max + 1)) > FILLPCT)
  481. X        hsplit(tb);
  482. X    }
  483. X
  484. X    return FALSE;
  485. X}
  486. X
  487. X#ifdef NOTUSED
  488. Xbool
  489. Xhdelete(tb,key)
  490. Xregister HASH *tb;
  491. Xchar *key;
  492. X{
  493. X    register char *s;
  494. X    register int i;
  495. X    register int hash;
  496. X    register HENT *entry;
  497. X    register HENT **oentry;
  498. X
  499. X    if (!tb)
  500. X    return FALSE;
  501. X    for (s=key,        i=0,    hash = 0;
  502. X      /* while */ *s;
  503. X     s++,        i++,    hash *= 5) {
  504. X    hash += *s * coeff[i];
  505. X    }
  506. X
  507. X    oentry = &(tb->tbl_array[hash & tb->tbl_max]);
  508. X    entry = *oentry;
  509. X    i = 1;
  510. X    for (; entry; i=0, oentry = &entry->hent_next, entry = entry->hent_next) {
  511. X    if (entry->hent_hash != hash)        /* strings can't be equal */
  512. X        continue;
  513. X    if (strNE(entry->hent_key,key))    /* is this it? */
  514. X        continue;
  515. X    safefree((char*)entry->hent_val);
  516. X    safefree(entry->hent_key);
  517. X    *oentry = entry->hent_next;
  518. X    safefree((char*)entry);
  519. X    if (i)
  520. X        tb->tbl_fill--;
  521. X    return TRUE;
  522. X    }
  523. X    return FALSE;
  524. X}
  525. X#endif
  526. X
  527. Xhsplit(tb)
  528. XHASH *tb;
  529. X{
  530. X    int oldsize = tb->tbl_max + 1;
  531. X    register int newsize = oldsize * 2;
  532. X    register int i;
  533. X    register HENT **a;
  534. X    register HENT **b;
  535. X    register HENT *entry;
  536. X    register HENT **oentry;
  537. X
  538. X    a = (HENT**) saferealloc((char*)tb->tbl_array, newsize * sizeof(HENT*));
  539. X    bzero((char*)&a[oldsize], oldsize * sizeof(HENT*)); /* zero second half */
  540. X    tb->tbl_max = --newsize;
  541. X    tb->tbl_array = a;
  542. X
  543. X    for (i=0; i<oldsize; i++,a++) {
  544. X    if (!*a)                /* non-existent */
  545. X        continue;
  546. X    b = a+oldsize;
  547. X    for (oentry = a, entry = *a; entry; entry = *oentry) {
  548. X        if ((entry->hent_hash & newsize) != i) {
  549. X        *oentry = entry->hent_next;
  550. X        entry->hent_next = *b;
  551. X        if (!*b)
  552. X            tb->tbl_fill++;
  553. X        *b = entry;
  554. X        continue;
  555. X        }
  556. X        else
  557. X        oentry = &entry->hent_next;
  558. X    }
  559. X    if (!*a)                /* everything moved */
  560. X        tb->tbl_fill--;
  561. X    }
  562. X}
  563. X
  564. XHASH *
  565. Xhnew()
  566. X{
  567. X    register HASH *tb = (HASH*)safemalloc(sizeof(HASH));
  568. X
  569. X    tb->tbl_array = (HENT**) safemalloc(8 * sizeof(HENT*));
  570. X    tb->tbl_fill = 0;
  571. X    tb->tbl_max = 7;
  572. X    hiterinit(tb);    /* so each() will start off right */
  573. X    bzero((char*)tb->tbl_array, 8 * sizeof(HENT*));
  574. X    return tb;
  575. X}
  576. X
  577. X#ifdef NOTUSED
  578. Xhshow(tb)
  579. Xregister HASH *tb;
  580. X{
  581. X    fprintf(stderr,"%5d %4d (%2d%%)\n",
  582. X    tb->tbl_max+1,
  583. X    tb->tbl_fill,
  584. X    tb->tbl_fill * 100 / (tb->tbl_max+1));
  585. X}
  586. X#endif
  587. X
  588. Xhiterinit(tb)
  589. Xregister HASH *tb;
  590. X{
  591. X    tb->tbl_riter = -1;
  592. X    tb->tbl_eiter = Null(HENT*);
  593. X    return tb->tbl_fill;
  594. X}
  595. X
  596. XHENT *
  597. Xhiternext(tb)
  598. Xregister HASH *tb;
  599. X{
  600. X    register HENT *entry;
  601. X
  602. X    entry = tb->tbl_eiter;
  603. X    do {
  604. X    if (entry)
  605. X        entry = entry->hent_next;
  606. X    if (!entry) {
  607. X        tb->tbl_riter++;
  608. X        if (tb->tbl_riter > tb->tbl_max) {
  609. X        tb->tbl_riter = -1;
  610. X        break;
  611. X        }
  612. X        entry = tb->tbl_array[tb->tbl_riter];
  613. X    }
  614. X    } while (!entry);
  615. X
  616. X    tb->tbl_eiter = entry;
  617. X    return entry;
  618. X}
  619. X
  620. Xchar *
  621. Xhiterkey(entry)
  622. Xregister HENT *entry;
  623. X{
  624. X    return entry->hent_key;
  625. X}
  626. X
  627. XSTR *
  628. Xhiterval(entry)
  629. Xregister HENT *entry;
  630. X{
  631. X    return entry->hent_val;
  632. X}
  633. !STUFFY!FUNK!
  634. echo Extracting array.c
  635. sed >array.c <<'!STUFFY!FUNK!' -e 's/X//'
  636. X/* $Header: array.c,v 3.0 89/10/18 15:08:33 lwall Locked $
  637. X *
  638. X *    Copyright (c) 1989, Larry Wall
  639. X *
  640. X *    You may distribute under the terms of the GNU General Public License
  641. X *    as specified in the README file that comes with the perl 3.0 kit.
  642. X *
  643. X * $Log:    array.c,v $
  644. X * Revision 3.0  89/10/18  15:08:33  lwall
  645. X * 3.0 baseline
  646. X * 
  647. X */
  648. X
  649. X#include "EXTERN.h"
  650. X#include "perl.h"
  651. X
  652. XSTR *
  653. Xafetch(ar,key,lval)
  654. Xregister ARRAY *ar;
  655. Xint key;
  656. Xint lval;
  657. X{
  658. X    STR *str;
  659. X
  660. X    if (key < 0 || key > ar->ary_fill) {
  661. X    if (lval && key >= 0) {
  662. X        if (ar->ary_flags & ARF_REAL)
  663. X        str = Str_new(5,0);
  664. X        else
  665. X        str = str_static(&str_undef);
  666. X        (void)astore(ar,key,str);
  667. X        return str;
  668. X    }
  669. X    else
  670. X        return Nullstr;
  671. X    }
  672. X    if (lval && !ar->ary_array[key]) {
  673. X    str = Str_new(6,0);
  674. X    (void)astore(ar,key,str);
  675. X    return str;
  676. X    }
  677. X    return ar->ary_array[key];
  678. X}
  679. X
  680. Xbool
  681. Xastore(ar,key,val)
  682. Xregister ARRAY *ar;
  683. Xint key;
  684. XSTR *val;
  685. X{
  686. X    int retval;
  687. X
  688. X    if (key < 0)
  689. X    return FALSE;
  690. X    if (key > ar->ary_max) {
  691. X    int newmax;
  692. X
  693. X    if (ar->ary_alloc != ar->ary_array) {
  694. X        retval = ar->ary_array - ar->ary_alloc;
  695. X        Copy(ar->ary_array, ar->ary_alloc, ar->ary_max+1, STR*);
  696. X        Zero(ar->ary_alloc+ar->ary_max+1, retval, STR*);
  697. X        ar->ary_max += retval;
  698. X        ar->ary_array -= retval;
  699. X        if (key > ar->ary_max - 10) {
  700. X        newmax = key + ar->ary_max;
  701. X        goto resize;
  702. X        }
  703. X    }
  704. X    else {
  705. X        newmax = key + ar->ary_max / 5;
  706. X      resize:
  707. X        Renew(ar->ary_alloc,newmax+1, STR*);
  708. X        Zero(&ar->ary_alloc[ar->ary_max+1], newmax - ar->ary_max, STR*);
  709. X        ar->ary_array = ar->ary_alloc;
  710. X        ar->ary_max = newmax;
  711. X    }
  712. X    }
  713. X    if ((ar->ary_flags & ARF_REAL) && ar->ary_fill < key) {
  714. X    while (++ar->ary_fill < key) {
  715. X        if (ar->ary_array[ar->ary_fill] != Nullstr) {
  716. X        str_free(ar->ary_array[ar->ary_fill]);
  717. X        ar->ary_array[ar->ary_fill] = Nullstr;
  718. X        }
  719. X    }
  720. X    }
  721. X    retval = (ar->ary_array[key] != Nullstr);
  722. X    if (retval && (ar->ary_flags & ARF_REAL))
  723. X    str_free(ar->ary_array[key]);
  724. X    ar->ary_array[key] = val;
  725. X    return retval;
  726. X}
  727. X
  728. XARRAY *
  729. Xanew(stab)
  730. XSTAB *stab;
  731. X{
  732. X    register ARRAY *ar;
  733. X
  734. X    New(1,ar,1,ARRAY);
  735. X    Newz(2,ar->ary_alloc,5,STR*);
  736. X    ar->ary_array = ar->ary_alloc;
  737. X    ar->ary_magic = Str_new(7,0);
  738. X    str_magic(ar->ary_magic, stab, '#', Nullch, 0);
  739. X    ar->ary_fill = -1;
  740. X    ar->ary_index = -1;
  741. X    ar->ary_max = 4;
  742. X    ar->ary_flags = ARF_REAL;
  743. X    return ar;
  744. X}
  745. X
  746. XARRAY *
  747. Xafake(stab,size,strp)
  748. XSTAB *stab;
  749. Xint size;
  750. XSTR **strp;
  751. X{
  752. X    register ARRAY *ar;
  753. X
  754. X    New(3,ar,1,ARRAY);
  755. X    New(4,ar->ary_alloc,size+1,STR*);
  756. X    Copy(strp,ar->ary_alloc,size,STR*);
  757. X    ar->ary_array = ar->ary_alloc;
  758. X    ar->ary_magic = Str_new(8,0);
  759. X    str_magic(ar->ary_magic, stab, '#', Nullch, 0);
  760. X    ar->ary_fill = size - 1;
  761. X    ar->ary_index = -1;
  762. X    ar->ary_max = size - 1;
  763. X    ar->ary_flags = 0;
  764. X    return ar;
  765. X}
  766. X
  767. Xvoid
  768. Xaclear(ar)
  769. Xregister ARRAY *ar;
  770. X{
  771. X    register int key;
  772. X
  773. X    if (!ar || !(ar->ary_flags & ARF_REAL))
  774. X    return;
  775. X    if (key = ar->ary_array - ar->ary_alloc) {
  776. X    ar->ary_max += key;
  777. X    ar->ary_array -= key;
  778. X    }
  779. X    for (key = 0; key <= ar->ary_max; key++)
  780. X    str_free(ar->ary_array[key]);
  781. X    ar->ary_fill = -1;
  782. X    Zero(ar->ary_array, ar->ary_max+1, STR*);
  783. X}
  784. X
  785. Xvoid
  786. Xafree(ar)
  787. Xregister ARRAY *ar;
  788. X{
  789. X    register int key;
  790. X
  791. X    if (!ar)
  792. X    return;
  793. X    if (key = ar->ary_array - ar->ary_alloc) {
  794. X    ar->ary_max += key;
  795. X    ar->ary_array -= key;
  796. X    }
  797. X    if (ar->ary_flags & ARF_REAL) {
  798. X    for (key = 0; key <= ar->ary_max; key++)
  799. X        str_free(ar->ary_array[key]);
  800. X    }
  801. X    str_free(ar->ary_magic);
  802. X    Safefree(ar->ary_alloc);
  803. X    Safefree(ar);
  804. X}
  805. X
  806. Xbool
  807. Xapush(ar,val)
  808. Xregister ARRAY *ar;
  809. XSTR *val;
  810. X{
  811. X    return astore(ar,++(ar->ary_fill),val);
  812. X}
  813. X
  814. XSTR *
  815. Xapop(ar)
  816. Xregister ARRAY *ar;
  817. X{
  818. X    STR *retval;
  819. X
  820. X    if (ar->ary_fill < 0)
  821. X    return Nullstr;
  822. X    retval = ar->ary_array[ar->ary_fill];
  823. X    ar->ary_array[ar->ary_fill--] = Nullstr;
  824. X    return retval;
  825. X}
  826. X
  827. Xaunshift(ar,num)
  828. Xregister ARRAY *ar;
  829. Xregister int num;
  830. X{
  831. X    register int i;
  832. X    register STR **sstr,**dstr;
  833. X
  834. X    if (num <= 0)
  835. X    return;
  836. X    if (ar->ary_array - ar->ary_alloc >= num) {
  837. X    ar->ary_max += num;
  838. X    ar->ary_fill += num;
  839. X    while (num--)
  840. X        *--ar->ary_array = Nullstr;
  841. X    }
  842. X    else {
  843. X    (void)astore(ar,ar->ary_fill+num,(STR*)0);    /* maybe extend array */
  844. X    dstr = ar->ary_array + ar->ary_fill;
  845. X    sstr = dstr - num;
  846. X    for (i = ar->ary_fill; i >= 0; i--) {
  847. X        *dstr-- = *sstr--;
  848. X    }
  849. X    Zero(ar->ary_array, num, STR*);
  850. X    }
  851. X}
  852. X
  853. XSTR *
  854. Xashift(ar)
  855. Xregister ARRAY *ar;
  856. X{
  857. X    STR *retval;
  858. X
  859. X    if (ar->ary_fill < 0)
  860. X    return Nullstr;
  861. X    retval = *ar->ary_array;
  862. X    *(ar->ary_array++) = Nullstr;
  863. X    ar->ary_max--;
  864. X    ar->ary_fill--;
  865. X    return retval;
  866. X}
  867. X
  868. Xint
  869. Xalen(ar)
  870. Xregister ARRAY *ar;
  871. X{
  872. X    return ar->ary_fill;
  873. X}
  874. X
  875. Xafill(ar, fill)
  876. Xregister ARRAY *ar;
  877. Xint fill;
  878. X{
  879. X    if (fill < 0)
  880. X    fill = -1;
  881. X    if (fill <= ar->ary_max)
  882. X    ar->ary_fill = fill;
  883. X    else
  884. X    (void)astore(ar,fill,Nullstr);
  885. X}
  886. !STUFFY!FUNK!
  887. echo Extracting makelib.SH
  888. sed >makelib.SH <<'!STUFFY!FUNK!' -e 's/X//'
  889. Xcase $CONFIG in
  890. X'')
  891. X    if test ! -f config.sh; then
  892. X    ln ../config.sh . || \
  893. X    ln ../../config.sh . || \
  894. X    ln ../../../config.sh . || \
  895. X    (echo "Can't find config.sh."; exit 1)
  896. X    fi
  897. X    . config.sh
  898. X    ;;
  899. Xesac
  900. X: This forces SH files to create target in same directory as SH file.
  901. X: This is so that make depend always knows where to find SH derivatives.
  902. Xcase "$0" in
  903. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  904. Xesac
  905. Xecho "Extracting makelib (with variable substitutions)"
  906. X: This section of the file will have variable substitutions done on it.
  907. X: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
  908. X: Protect any dollar signs and backticks that you do not want interpreted
  909. X: by putting a backslash in front.  You may delete these comments.
  910. X$spitshell >makelib <<!GROK!THIS!
  911. X#!/usr/bin/perl
  912. X
  913. X\$perlincl = '$privlib';
  914. X!GROK!THIS!
  915. X
  916. X: In the following dollars and backticks do not need the extra backslash.
  917. X$spitshell >>makelib <<'!NO!SUBS!'
  918. X
  919. Xchdir '/usr/include' || die "Can't cd /usr/include";
  920. X
  921. X%isatype = ('char',1,'short',1,'int',1,'long',1);
  922. X
  923. Xforeach $file (@ARGV) {
  924. X    print $file,"\n";
  925. X    if ($file =~ m|^(.*)/|) {
  926. X    $dir = $1;
  927. X    if (!-d "$perlincl/$dir") {
  928. X        mkdir("$perlincl/$dir",0777);
  929. X    }
  930. X    }
  931. X    open(IN,"$file") || ((warn "Can't open $file: $!\n"),next);
  932. X    open(OUT,">$perlincl/$file") || die "Can't create $file: $!\n";
  933. X    while (<IN>) {
  934. X    chop;
  935. X    while (/\\$/) {
  936. X        chop;
  937. X        $_ .= <IN>;
  938. X        chop;
  939. X    }
  940. X    if (s:/\*:\200:g) {
  941. X        s:\*/:\201:g;
  942. X        s/\200[^\201]*\201//g;    # delete single line comments
  943. X        if (s/\200.*//) {        # begin multi-line comment?
  944. X        $_ .= '/*';
  945. X        $_ .= <IN>;
  946. X        redo;
  947. X        }
  948. X    }
  949. X    if (s/^#\s*//) {
  950. X        if (s/^define\s+(\w+)//) {
  951. X        $name = $1;
  952. X        $new = '';
  953. X        s/\s+$//;
  954. X        if (s/^\(([\w,\s]*)\)//) {
  955. X            $args = $1;
  956. X            if ($args ne '') {
  957. X            foreach $arg (split(/,\s*/,$args)) {
  958. X                $curargs{$arg} = 1;
  959. X            }
  960. X            $args =~ s/\b(\w)/\$$1/g;
  961. X            $args = "local($args) = \@_;\n$t    ";
  962. X            }
  963. X            s/^\s+//;
  964. X            do expr();
  965. X            $new =~ s/(["\\])/\\$1/g;
  966. X            if ($t ne '') {
  967. X            $new =~ s/(['\\])/\\$1/g;
  968. X            print OUT $t,
  969. X              "eval 'sub $name {\n$t    ${args}eval \"$new\";\n$t}';\n";
  970. X            }
  971. X            else {
  972. X            print OUT "sub $name {\n    ${args}eval \"$new\";\n}\n";
  973. X            }
  974. X            %curargs = ();
  975. X        }
  976. X        else {
  977. X            s/^\s+//;
  978. X            do expr();
  979. X            $new = 1 if $new eq '';
  980. X            if ($t ne '') {
  981. X            $new =~ s/(['\\])/\\$1/g;
  982. X            print OUT $t,"eval 'sub $name {",$new,";}';\n";
  983. X            }
  984. X            else {
  985. X            print OUT $t,"sub $name {",$new,";}\n";
  986. X            }
  987. X        }
  988. X        }
  989. X        elsif (/^include <(.*)>/) {
  990. X        print OUT $t,"do '$1' || die \"Can't include $1: \$!\";\n";
  991. X        }
  992. X        elsif (/^ifdef\s+(\w+)/) {
  993. X        print OUT $t,"if (defined &$1) {\n";
  994. X        $tab += 4;
  995. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  996. X        }
  997. X        elsif (/^ifndef\s+(\w+)/) {
  998. X        print OUT $t,"if (!defined &$1) {\n";
  999. X        $tab += 4;
  1000. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  1001. X        }
  1002. X        elsif (s/^if\s+//) {
  1003. X        $new = '';
  1004. X        do expr();
  1005. X        print OUT $t,"if ($new) {\n";
  1006. X        $tab += 4;
  1007. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  1008. X        }
  1009. X        elsif (s/^elif\s+//) {
  1010. X        $new = '';
  1011. X        do expr();
  1012. X        $tab -= 4;
  1013. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  1014. X        print OUT $t,"}\n${t}elsif ($new) {\n";
  1015. X        $tab += 4;
  1016. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  1017. X        }
  1018. X        elsif (/^else/) {
  1019. X        $tab -= 4;
  1020. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  1021. X        print OUT $t,"}\n${t}else {\n";
  1022. X        $tab += 4;
  1023. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  1024. X        }
  1025. X        elsif (/^endif/) {
  1026. X        $tab -= 4;
  1027. X        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  1028. X        print OUT $t,"}\n";
  1029. X        }
  1030. X    }
  1031. X    }
  1032. X    print OUT "1;\n";
  1033. X}
  1034. X
  1035. Xsub expr {
  1036. X    while ($_ ne '') {
  1037. X    s/^(\s+)//        && do {$new .= ' '; next;};
  1038. X    s/^(0x[0-9a-fA-F]+)//    && do {$new .= $1; next;};
  1039. X    s/^(\d+)//        && do {$new .= $1; next;};
  1040. X    s/^("(\\"|[^"])*")//    && do {$new .= $1; next;};
  1041. X    s/^'((\\"|[^"])*)'//    && do {
  1042. X        if ($curargs{$1}) {
  1043. X        $new .= "ord('\$$1')";
  1044. X        }
  1045. X        else {
  1046. X        $new .= "ord('$1')";
  1047. X        }
  1048. X        next;
  1049. X    };
  1050. X    s/^(struct\s+\w+)//    && do {$new .= "'$1'"; next;};
  1051. X    s/^sizeof\s*\(([^)]+)\)/{$1}/ && do {
  1052. X        $new .= '$sizeof';
  1053. X        next;
  1054. X    };
  1055. X    s/^([_a-zA-Z]\w*)//    && do {
  1056. X        $id = $1;
  1057. X        if ($curargs{$id}) {
  1058. X        $new .= '$' . $id;
  1059. X        }
  1060. X        elsif ($id eq 'defined') {
  1061. X        $new .= 'defined';
  1062. X        }
  1063. X        elsif (/^\(/) {
  1064. X        s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/;    # cheat
  1065. X        $new .= "&$id";
  1066. X        }
  1067. X        elsif ($isatype{$id}) {
  1068. X        $new .= "'$id'";
  1069. X        }
  1070. X        else {
  1071. X        $new .= '&' . $id;
  1072. X        }
  1073. X        next;
  1074. X    };
  1075. X    s/^(.)//            && do {$new .= $1; next;};
  1076. X    }
  1077. X}
  1078. X!NO!SUBS!
  1079. Xchmod 755 makelib
  1080. X$eunicefix makelib
  1081. !STUFFY!FUNK!
  1082. echo Extracting makedepend.SH
  1083. sed >makedepend.SH <<'!STUFFY!FUNK!' -e 's/X//'
  1084. Xcase $CONFIG in
  1085. X'')
  1086. X    if test ! -f config.sh; then
  1087. X    ln ../config.sh . || \
  1088. X    ln ../../config.sh . || \
  1089. X    ln ../../../config.sh . || \
  1090. X    (echo "Can't find config.sh."; exit 1)
  1091. X    fi
  1092. X    . ./config.sh
  1093. X    ;;
  1094. Xesac
  1095. Xcase "$0" in
  1096. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1097. Xesac
  1098. Xecho "Extracting makedepend (with variable substitutions)"
  1099. X$spitshell >makedepend <<!GROK!THIS!
  1100. X$startsh
  1101. X# $Header: makedepend.SH,v 3.0 89/10/18 15:20:19 lwall Locked $
  1102. X#
  1103. X# $Log:    makedepend.SH,v $
  1104. X# Revision 3.0  89/10/18  15:20:19  lwall
  1105. X# 3.0 baseline
  1106. X# 
  1107. X
  1108. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1109. X
  1110. Xcat='$cat'
  1111. Xccflags='$ccflags $sockethdr'
  1112. Xcp='$cp'
  1113. Xcpp='$cppstdin'
  1114. Xecho='$echo'
  1115. Xegrep='$egrep'
  1116. Xexpr='$expr'
  1117. Xmv='$mv'
  1118. Xrm='$rm'
  1119. Xsed='$sed'
  1120. Xsort='$sort'
  1121. Xtest='$test'
  1122. Xtr='$tr'
  1123. Xuniq='$uniq'
  1124. X!GROK!THIS!
  1125. X
  1126. X$spitshell >>makedepend <<'!NO!SUBS!'
  1127. X
  1128. X: the following weeds options from ccflags that are of no interest to cpp
  1129. Xcase "$ccflags" in
  1130. X'');;
  1131. X*)  set X $ccflags
  1132. X    ccflags=''
  1133. X    for flag do
  1134. X    case $flag in
  1135. X    -D*|-I*) ccflags="$ccflags $flag";;
  1136. X    esac
  1137. X    done
  1138. X    ;;
  1139. Xesac
  1140. X
  1141. X$cat /dev/null >.deptmp
  1142. X$rm -f *.c.c c/*.c.c
  1143. Xif test -f Makefile; then
  1144. X    mf=Makefile
  1145. Xelse
  1146. X    mf=makefile
  1147. Xfi
  1148. Xif test -f $mf; then
  1149. X    defrule=`<$mf sed -n        \
  1150. X    -e '/^\.c\.o:.*;/{'        \
  1151. X    -e    's/\$\*\.c//'        \
  1152. X    -e    's/^[^;]*;[     ]*//p'    \
  1153. X    -e    q                \
  1154. X    -e '}'                \
  1155. X    -e '/^\.c\.o: *$/{'        \
  1156. X    -e    N                \
  1157. X    -e    's/\$\*\.c//'        \
  1158. X    -e    's/^.*\n[     ]*//p'        \
  1159. X    -e    q                \
  1160. X    -e '}'`
  1161. Xfi
  1162. Xcase "$defrule" in
  1163. X'') defrule='$(CC) -c $(CFLAGS)' ;;
  1164. Xesac
  1165. X
  1166. Xmake clist || ($echo "Searching for .c files..."; \
  1167. X    $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
  1168. Xfor file in `$cat .clist`; do
  1169. X# for file in `cat /dev/null`; do
  1170. X    case "$file" in
  1171. X    *.c) filebase=`basename $file .c` ;;
  1172. X    *.y) filebase=`basename $file .c` ;;
  1173. X    esac
  1174. X    $echo "Finding dependencies for $filebase.o."
  1175. X    $sed -n <$file >$file.c \
  1176. X    -e "/^${filebase}_init(/q" \
  1177. X    -e '/^#/{' \
  1178. X    -e 's|/\*.*$||' \
  1179. X    -e 's|\\$||' \
  1180. X    -e p \
  1181. X    -e '}'
  1182. X    $cpp -I/usr/local/include -I. $ccflags $file.c | \
  1183. X    $sed \
  1184. X    -e '/^# *[0-9]/!d' \
  1185. X    -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
  1186. X    -e 's|: \./|: |' \
  1187. X    -e 's|\.c\.c|.c|' | \
  1188. X    $uniq | $sort | $uniq >> .deptmp
  1189. Xdone
  1190. X
  1191. X$sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
  1192. X
  1193. Xmake shlist || ($echo "Searching for .SH files..."; \
  1194. X    $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
  1195. Xif $test -s .deptmp; then
  1196. X    for file in `cat .shlist`; do
  1197. X    $echo `$expr X$file : 'X\(.*\).SH`: $file config.sh \; \
  1198. X        /bin/sh $file >> .deptmp
  1199. X    done
  1200. X    $echo "Updating Makefile..."
  1201. X    $echo "# If this runs make out of memory, delete /usr/include lines." \
  1202. X    >> Makefile.new
  1203. X    $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
  1204. X       >>Makefile.new
  1205. Xelse
  1206. X    make hlist || ($echo "Searching for .h files..."; \
  1207. X    $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
  1208. X    $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
  1209. X    $egrep '^#include ' `cat .clist` `cat .hlist`  >.deptmp
  1210. X    $echo "Updating Makefile..."
  1211. X    <.clist $sed -n                            \
  1212. X    -e '/\//{'                            \
  1213. X    -e   's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p"    \
  1214. X    -e   d                                \
  1215. X    -e '}'                                \
  1216. X    -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
  1217. X    <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
  1218. X    <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
  1219. X       $sed 's|^[^;]*/||' | \
  1220. X       $sed -f .hsed >> Makefile.new
  1221. X    <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
  1222. X       >> Makefile.new
  1223. X    <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
  1224. X       $sed -f .hsed >> Makefile.new
  1225. X    <.deptmp $sed -n 's|h:#include <\(.*\)>.*$|h: /usr/include/\1|p' \
  1226. X       >> Makefile.new
  1227. X    for file in `$cat .shlist`; do
  1228. X    $echo `$expr X$file : 'X\(.*\).SH`: $file config.sh \; \
  1229. X        /bin/sh $file >> Makefile.new
  1230. X    done
  1231. Xfi
  1232. X$rm -f Makefile.old
  1233. X$cp Makefile Makefile.old
  1234. X$cp Makefile.new Makefile
  1235. X$rm Makefile.new
  1236. X$echo "# WARNING: Put nothing here or make depend will gobble it up!" >> Makefile
  1237. X$rm -f .deptmp `sed 's/\.c/.c.c/' .clist` .shlist .clist .hlist .hsed
  1238. X
  1239. X!NO!SUBS!
  1240. X$eunicefix makedepend
  1241. Xchmod +x makedepend
  1242. Xcase `pwd` in
  1243. X*SH)
  1244. X    $rm -f ../makedepend
  1245. X    ln makedepend ../makedepend
  1246. X    ;;
  1247. Xesac
  1248. !STUFFY!FUNK!
  1249. echo Extracting t/op.subst
  1250. sed >t/op.subst <<'!STUFFY!FUNK!' -e 's/X//'
  1251. X#!./perl
  1252. X
  1253. X# $Header: op.subst,v 3.0 89/10/18 15:31:43 lwall Locked $
  1254. X
  1255. Xprint "1..42\n";
  1256. X
  1257. X$x = 'foo';
  1258. X$_ = "x";
  1259. Xs/x/\$x/;
  1260. Xprint "#1\t:$_: eq :\$x:\n";
  1261. Xif ($_ eq '$x') {print "ok 1\n";} else {print "not ok 1\n";}
  1262. X
  1263. X$_ = "x";
  1264. Xs/x/$x/;
  1265. Xprint "#2\t:$_: eq :foo:\n";
  1266. Xif ($_ eq 'foo') {print "ok 2\n";} else {print "not ok 2\n";}
  1267. X
  1268. X$_ = "x";
  1269. Xs/x/\$x $x/;
  1270. Xprint "#3\t:$_: eq :\$x foo:\n";
  1271. Xif ($_ eq '$x foo') {print "ok 3\n";} else {print "not ok 3\n";}
  1272. X
  1273. X$b = 'cd';
  1274. X($a = 'abcdef') =~ s'(b${b}e)'\n$1';
  1275. Xprint "#4\t:$1: eq :bcde:\n";
  1276. Xprint "#4\t:$a: eq :a\\n\$1f:\n";
  1277. Xif ($1 eq 'bcde' && $a eq 'a\n$1f') {print "ok 4\n";} else {print "not ok 4\n";}
  1278. X
  1279. X$a = 'abacada';
  1280. Xif (($a =~ s/a/x/g) == 4 && $a eq 'xbxcxdx')
  1281. X    {print "ok 5\n";} else {print "not ok 5\n";}
  1282. X
  1283. Xif (($a =~ s/a/y/g) == 0 && $a eq 'xbxcxdx')
  1284. X    {print "ok 6\n";} else {print "not ok 6 $a\n";}
  1285. X
  1286. Xif (($a =~ s/b/y/g) == 1 && $a eq 'xyxcxdx')
  1287. X    {print "ok 7\n";} else {print "not ok 7 $a\n";}
  1288. X
  1289. X$_ = 'ABACADA';
  1290. Xif (/a/i && s///gi && $_ eq 'BCD') {print "ok 8\n";} else {print "not ok 8 $_\n";}
  1291. X
  1292. X$_ = '\\' x 4;
  1293. Xif (length($_) == 4) {print "ok 9\n";} else {print "not ok 9\n";}
  1294. Xs/\\/\\\\/g;
  1295. Xif ($_ eq '\\' x 8) {print "ok 10\n";} else {print "not ok 10\n";}
  1296. X
  1297. X$_ = '\/' x 4;
  1298. Xif (length($_) == 8) {print "ok 11\n";} else {print "not ok 11\n";}
  1299. Xs/\//\/\//g;
  1300. Xif ($_ eq '\\//' x 4) {print "ok 12\n";} else {print "not ok 12\n";}
  1301. Xif (length($_) == 12) {print "ok 13\n";} else {print "not ok 13\n";}
  1302. X
  1303. X$_ = 'aaaXXXXbbb';
  1304. Xs/^a//;
  1305. Xprint $_ eq 'aaXXXXbbb' ? "ok 14\n" : "not ok 14\n";
  1306. X
  1307. X$_ = 'aaaXXXXbbb';
  1308. Xs/a//;
  1309. Xprint $_ eq 'aaXXXXbbb' ? "ok 15\n" : "not ok 15\n";
  1310. X
  1311. X$_ = 'aaaXXXXbbb';
  1312. Xs/^a/b/;
  1313. Xprint $_ eq 'baaXXXXbbb' ? "ok 16\n" : "not ok 16\n";
  1314. X
  1315. X$_ = 'aaaXXXXbbb';
  1316. Xs/a/b/;
  1317. Xprint $_ eq 'baaXXXXbbb' ? "ok 17\n" : "not ok 17\n";
  1318. X
  1319. X$_ = 'aaaXXXXbbb';
  1320. Xs/aa//;
  1321. Xprint $_ eq 'aXXXXbbb' ? "ok 18\n" : "not ok 18\n";
  1322. X
  1323. X$_ = 'aaaXXXXbbb';
  1324. Xs/aa/b/;
  1325. Xprint $_ eq 'baXXXXbbb' ? "ok 19\n" : "not ok 19\n";
  1326. X
  1327. X$_ = 'aaaXXXXbbb';
  1328. Xs/b$//;
  1329. Xprint $_ eq 'aaaXXXXbb' ? "ok 20\n" : "not ok 20\n";
  1330. X
  1331. X$_ = 'aaaXXXXbbb';
  1332. Xs/b//;
  1333. Xprint $_ eq 'aaaXXXXbb' ? "ok 21\n" : "not ok 21\n";
  1334. X
  1335. X$_ = 'aaaXXXXbbb';
  1336. Xs/bb//;
  1337. Xprint $_ eq 'aaaXXXXb' ? "ok 22\n" : "not ok 22\n";
  1338. X
  1339. X$_ = 'aaaXXXXbbb';
  1340. Xs/aX/y/;
  1341. Xprint $_ eq 'aayXXXbbb' ? "ok 23\n" : "not ok 23\n";
  1342. X
  1343. X$_ = 'aaaXXXXbbb';
  1344. Xs/Xb/z/;
  1345. Xprint $_ eq 'aaaXXXzbb' ? "ok 24\n" : "not ok 24\n";
  1346. X
  1347. X$_ = 'aaaXXXXbbb';
  1348. Xs/aaX.*Xbb//;
  1349. Xprint $_ eq 'ab' ? "ok 25\n" : "not ok 25\n";
  1350. X
  1351. X$_ = 'aaaXXXXbbb';
  1352. Xs/bb/x/;
  1353. Xprint $_ eq 'aaaXXXXxb' ? "ok 26\n" : "not ok 26\n";
  1354. X
  1355. X# now for some unoptimized versions of the same.
  1356. X
  1357. X$_ = 'aaaXXXXbbb';
  1358. X$x ne $x || s/^a//;
  1359. Xprint $_ eq 'aaXXXXbbb' ? "ok 27\n" : "not ok 27\n";
  1360. X
  1361. X$_ = 'aaaXXXXbbb';
  1362. X$x ne $x || s/a//;
  1363. Xprint $_ eq 'aaXXXXbbb' ? "ok 28\n" : "not ok 28\n";
  1364. X
  1365. X$_ = 'aaaXXXXbbb';
  1366. X$x ne $x || s/^a/b/;
  1367. Xprint $_ eq 'baaXXXXbbb' ? "ok 29\n" : "not ok 29\n";
  1368. X
  1369. X$_ = 'aaaXXXXbbb';
  1370. X$x ne $x || s/a/b/;
  1371. Xprint $_ eq 'baaXXXXbbb' ? "ok 30\n" : "not ok 30\n";
  1372. X
  1373. X$_ = 'aaaXXXXbbb';
  1374. X$x ne $x || s/aa//;
  1375. Xprint $_ eq 'aXXXXbbb' ? "ok 31\n" : "not ok 31\n";
  1376. X
  1377. X$_ = 'aaaXXXXbbb';
  1378. X$x ne $x || s/aa/b/;
  1379. Xprint $_ eq 'baXXXXbbb' ? "ok 32\n" : "not ok 32\n";
  1380. X
  1381. X$_ = 'aaaXXXXbbb';
  1382. X$x ne $x || s/b$//;
  1383. Xprint $_ eq 'aaaXXXXbb' ? "ok 33\n" : "not ok 33\n";
  1384. X
  1385. X$_ = 'aaaXXXXbbb';
  1386. X$x ne $x || s/b//;
  1387. Xprint $_ eq 'aaaXXXXbb' ? "ok 34\n" : "not ok 34\n";
  1388. X
  1389. X$_ = 'aaaXXXXbbb';
  1390. X$x ne $x || s/bb//;
  1391. Xprint $_ eq 'aaaXXXXb' ? "ok 35\n" : "not ok 35\n";
  1392. X
  1393. X$_ = 'aaaXXXXbbb';
  1394. X$x ne $x || s/aX/y/;
  1395. Xprint $_ eq 'aayXXXbbb' ? "ok 36\n" : "not ok 36\n";
  1396. X
  1397. X$_ = 'aaaXXXXbbb';
  1398. X$x ne $x || s/Xb/z/;
  1399. Xprint $_ eq 'aaaXXXzbb' ? "ok 37\n" : "not ok 37\n";
  1400. X
  1401. X$_ = 'aaaXXXXbbb';
  1402. X$x ne $x || s/aaX.*Xbb//;
  1403. Xprint $_ eq 'ab' ? "ok 38\n" : "not ok 38\n";
  1404. X
  1405. X$_ = 'aaaXXXXbbb';
  1406. X$x ne $x || s/bb/x/;
  1407. Xprint $_ eq 'aaaXXXXxb' ? "ok 39\n" : "not ok 39\n";
  1408. X
  1409. X$_ = 'abc123xyz';
  1410. Xs/\d+/$&*2/e;              # yields 'abc246xyz'
  1411. Xprint $_ eq 'abc246xyz' ? "ok 40\n" : "not ok 40\n";
  1412. Xs/\d+/sprintf("%5d",$&)/e; # yields 'abc  246xyz'
  1413. Xprint $_ eq 'abc  246xyz' ? "ok 41\n" : "not ok 41\n";
  1414. Xs/\w/$& x 2/eg;            # yields 'aabbcc  224466xxyyzz'
  1415. Xprint $_ eq 'aabbcc  224466xxyyzz' ? "ok 42\n" : "not ok 42\n";
  1416. !STUFFY!FUNK!
  1417. echo Extracting cmd.h
  1418. sed >cmd.h <<'!STUFFY!FUNK!' -e 's/X//'
  1419. X/* $Header: cmd.h,v 3.0 89/10/18 15:09:15 lwall Locked $
  1420. X *
  1421. X *    Copyright (c) 1989, Larry Wall
  1422. X *
  1423. X *    You may distribute under the terms of the GNU General Public License
  1424. X *    as specified in the README file that comes with the perl 3.0 kit.
  1425. X *
  1426. X * $Log:    cmd.h,v $
  1427. X * Revision 3.0  89/10/18  15:09:15  lwall
  1428. X * 3.0 baseline
  1429. X * 
  1430. X */
  1431. X
  1432. X#define C_NULL 0
  1433. X#define C_IF 1
  1434. X#define C_ELSE 2
  1435. X#define C_WHILE 3
  1436. X#define C_BLOCK 4
  1437. X#define C_EXPR 5
  1438. X#define C_NEXT 6
  1439. X#define C_ELSIF 7    /* temporary--turns into an IF + ELSE */
  1440. X#define C_CSWITCH 8    /* created by switch optimization in block_head() */
  1441. X#define C_NSWITCH 9    /* likewise */
  1442. X
  1443. X#ifdef DEBUGGING
  1444. X#ifndef DOINIT
  1445. Xextern char *cmdname[];
  1446. X#else
  1447. Xchar *cmdname[] = {
  1448. X    "NULL",
  1449. X    "IF",
  1450. X    "ELSE",
  1451. X    "WHILE",
  1452. X    "BLOCK",
  1453. X    "EXPR",
  1454. X    "NEXT",
  1455. X    "ELSIF",
  1456. X    "CSWITCH",
  1457. X    "NSWITCH",
  1458. X    "10"
  1459. X};
  1460. X#endif
  1461. X#endif /* DEBUGGING */
  1462. X
  1463. X#define CF_OPTIMIZE 077    /* type of optimization */
  1464. X#define CF_FIRSTNEG 0100/* conditional is ($register NE 'string') */
  1465. X#define CF_NESURE 0200    /* if short doesn't match we're sure */
  1466. X#define CF_EQSURE 0400    /* if short does match we're sure */
  1467. X#define CF_COND    01000    /* test c_expr as conditional first, if not null. */
  1468. X            /* Set for everything except do {} while currently */
  1469. X#define CF_LOOP 02000    /* loop on the c_expr conditional (loop modifiers) */
  1470. X#define CF_INVERT 04000    /* it's an "unless" or an "until" */
  1471. X#define CF_ONCE 010000    /* we've already pushed the label on the stack */
  1472. X#define CF_FLIP 020000    /* on a match do flipflop */
  1473. X#define CF_TERM 040000    /* value of this cmd might be returned */
  1474. X
  1475. X#define CFT_FALSE 0    /* c_expr is always false */
  1476. X#define CFT_TRUE 1    /* c_expr is always true */
  1477. X#define CFT_REG 2    /* c_expr is a simple register */
  1478. X#define CFT_ANCHOR 3    /* c_expr is an anchored search /^.../ */
  1479. X#define CFT_STROP 4    /* c_expr is a string comparison */
  1480. X#define CFT_SCAN 5    /* c_expr is an unanchored search /.../ */
  1481. X#define CFT_GETS 6    /* c_expr is <filehandle> */
  1482. X#define CFT_EVAL 7    /* c_expr is not optimized, so call eval() */
  1483. X#define CFT_UNFLIP 8    /* 2nd half of range not optimized */
  1484. X#define CFT_CHOP 9    /* c_expr is a chop on a register */
  1485. X#define CFT_ARRAY 10    /* this is a foreach loop */
  1486. X#define CFT_INDGETS 11    /* c_expr is <$variable> */
  1487. X#define CFT_NUMOP 12    /* c_expr is a numeric comparison */
  1488. X#define CFT_CCLASS 13    /* c_expr must start with one of these characters */
  1489. X
  1490. X#ifdef DEBUGGING
  1491. X#ifndef DOINIT
  1492. Xextern char *cmdopt[];
  1493. X#else
  1494. Xchar *cmdopt[] = {
  1495. X    "FALSE",
  1496. X    "TRUE",
  1497. X    "REG",
  1498. X    "ANCHOR",
  1499. X    "STROP",
  1500. X    "SCAN",
  1501. X    "GETS",
  1502. X    "EVAL",
  1503. X    "UNFLIP",
  1504. X    "CHOP",
  1505. X    "ARRAY",
  1506. X    "INDGETS",
  1507. X    "NUMOP",
  1508. X    "CCLASS",
  1509. X    "14"
  1510. X};
  1511. X#endif
  1512. X#endif /* DEBUGGING */
  1513. X
  1514. Xstruct acmd {
  1515. X    STAB    *ac_stab;    /* a symbol table entry */
  1516. X    ARG        *ac_expr;    /* any associated expression */
  1517. X};
  1518. X
  1519. Xstruct ccmd {
  1520. X    CMD        *cc_true;    /* normal code to do on if and while */
  1521. X    CMD        *cc_alt;    /* else cmd ptr or continue code */
  1522. X};
  1523. X
  1524. Xstruct scmd {
  1525. X    CMD        **sc_next;    /* array of pointers to commands */
  1526. X    short    sc_offset;    /* first value - 1 */
  1527. X    short    sc_max;        /* last value + 1 */
  1528. X};
  1529. X
  1530. Xstruct cmd {
  1531. X    CMD        *c_next;    /* the next command at this level */
  1532. X    ARG        *c_expr;    /* conditional expression */
  1533. X    CMD        *c_head;    /* head of this command list */
  1534. X    STR        *c_short;    /* string to match as shortcut */
  1535. X    STAB    *c_stab;    /* a symbol table entry, mostly for fp */
  1536. X    SPAT    *c_spat;    /* pattern used by optimization */
  1537. X    char    *c_label;    /* label for this construct */
  1538. X    union ucmd {
  1539. X    struct acmd acmd;    /* normal command */
  1540. X    struct ccmd ccmd;    /* compound command */
  1541. X    struct scmd scmd;    /* switch command */
  1542. X    } ucmd;
  1543. X    short    c_slen;        /* len of c_short, if not null */
  1544. X    short    c_flags;    /* optimization flags--see above */
  1545. X    char    *c_file;    /* file the following line # is from */
  1546. X    line_t      c_line;         /* line # of this command */
  1547. X    char    c_type;        /* what this command does */
  1548. X};
  1549. X
  1550. X#define Nullcmd Null(CMD*)
  1551. X
  1552. XEXT CMD *main_root INIT(Nullcmd);
  1553. XEXT CMD *eval_root INIT(Nullcmd);
  1554. X
  1555. Xstruct compcmd {
  1556. X    CMD *comp_true;
  1557. X    CMD *comp_alt;
  1558. X};
  1559. X
  1560. Xvoid opt_arg();
  1561. Xvoid evalstatic();
  1562. Xint cmd_exec();
  1563. !STUFFY!FUNK!
  1564. echo Extracting ioctl.pl
  1565. sed >ioctl.pl <<'!STUFFY!FUNK!' -e 's/X//'
  1566. X$TIOCGSIZE = 0x40087468;
  1567. X$TIOCSSIZE = 0x80087467;
  1568. X$IOCPARM_MASK = 0x1fff;
  1569. X$IOCPARM_MAX = 0x200;
  1570. X$IOC_VOID = 0x20000000;
  1571. X$IOC_OUT = 0x40000000;
  1572. X$IOC_IN = 0x80000000;
  1573. X$IOC_INOUT = 0xC0000000;
  1574. X$IOC_DIRMASK = 0xe0000000;
  1575. X$TIOCGETD = 0x40047400;
  1576. X$TIOCSETD = 0x80047401;
  1577. X$TIOCHPCL = 0x20007402;
  1578. X$TIOCMODG = 0x40047403;
  1579. X$TIOCMODS = 0x80047404;
  1580. X$TIOCM_LE = 0001;
  1581. X$TIOCM_DTR = 0002;
  1582. X$TIOCM_RTS = 0004;
  1583. X$TIOCM_ST = 0010;
  1584. X$TIOCM_SR = 0020;
  1585. X$TIOCM_CTS = 0040;
  1586. X$TIOCM_CAR = 0100;
  1587. X$TIOCM_CD = 0x40;
  1588. X$TIOCM_RNG = 0200;
  1589. X$TIOCM_RI = 0x80;
  1590. X$TIOCM_DSR = 0400;
  1591. X$TIOCGETP = 0x40067408;
  1592. X$TIOCSETP = 0x80067409;
  1593. X$TIOCSETN = 0x8006740A;
  1594. X$TIOCEXCL = 0x2000740D;
  1595. X$TIOCNXCL = 0x2000740E;
  1596. X$TIOCFLUSH = 0x80047410;
  1597. X$TIOCSETC = 0x80067411;
  1598. X$TIOCGETC = 0x40067412;
  1599. X$TANDEM = 0x00000001;
  1600. X$CBREAK = 0x00000002;
  1601. X$LCASE = 0x00000004;
  1602. X$ECHO = 0x00000008;
  1603. X$CRMOD = 0x00000010;
  1604. X$RAW = 0x00000020;
  1605. X$ODDP = 0x00000040;
  1606. X$EVENP = 0x00000080;
  1607. X$ANYP = 0x000000c0;
  1608. X$NLDELAY = 0x00000300;
  1609. X$NL0 = 0x00000000;
  1610. X$NL1 = 0x00000100;
  1611. X$NL2 = 0x00000200;
  1612. X$NL3 = 0x00000300;
  1613. X$TBDELAY = 0x00000c00;
  1614. X$TAB0 = 0x00000000;
  1615. X$TAB1 = 0x00000400;
  1616. X$TAB2 = 0x00000800;
  1617. X$XTABS = 0x00000c00;
  1618. X$CRDELAY = 0x00003000;
  1619. X$CR0 = 0x00000000;
  1620. X$CR1 = 0x00001000;
  1621. X$CR2 = 0x00002000;
  1622. X$CR3 = 0x00003000;
  1623. X$VTDELAY = 0x00004000;
  1624. X$FF0 = 0x00000000;
  1625. X$FF1 = 0x00004000;
  1626. X$BSDELAY = 0x00008000;
  1627. X$BS0 = 0x00000000;
  1628. X$BS1 = 0x00008000;
  1629. X$ALLDELAY = 0xFF00;
  1630. X$CRTBS = 0x00010000;
  1631. X$PRTERA = 0x00020000;
  1632. X$CRTERA = 0x00040000;
  1633. X$TILDE = 0x00080000;
  1634. X$MDMBUF = 0x00100000;
  1635. X$LITOUT = 0x00200000;
  1636. X$TOSTOP = 0x00400000;
  1637. X$FLUSHO = 0x00800000;
  1638. X$NOHANG = 0x01000000;
  1639. X$L001000 = 0x02000000;
  1640. X$CRTKIL = 0x04000000;
  1641. X$PASS8 = 0x08000000;
  1642. X$CTLECH = 0x10000000;
  1643. X$PENDIN = 0x20000000;
  1644. X$DECCTQ = 0x40000000;
  1645. X$NOFLSH = 0x80000000;
  1646. X$TIOCLBIS = 0x8004747F;
  1647. X$TIOCLBIC = 0x8004747E;
  1648. X$TIOCLSET = 0x8004747D;
  1649. X$TIOCLGET = 0x4004747C;
  1650. X$LCRTBS = 0x1;
  1651. X$LPRTERA = 0x2;
  1652. X$LCRTERA = 0x4;
  1653. X$LTILDE = 0x8;
  1654. X$LMDMBUF = 0x10;
  1655. X$LLITOUT = 0x20;
  1656. X$LTOSTOP = 0x40;
  1657. X$LFLUSHO = 0x80;
  1658. X$LNOHANG = 0x100;
  1659. X$LCRTKIL = 0x400;
  1660. X$LPASS8 = 0x800;
  1661. X$LCTLECH = 0x1000;
  1662. X$LPENDIN = 0x2000;
  1663. X$LDECCTQ = 0x4000;
  1664. X$LNOFLSH = 0xFFFF8000;
  1665. X$TIOCSBRK = 0x2000747B;
  1666. X$TIOCCBRK = 0x2000747A;
  1667. X$TIOCSDTR = 0x20007479;
  1668. X$TIOCCDTR = 0x20007478;
  1669. X$TIOCGPGRP = 0x40047477;
  1670. X$TIOCSPGRP = 0x80047476;
  1671. X$TIOCSLTC = 0x80067475;
  1672. X$TIOCGLTC = 0x40067474;
  1673. X$TIOCOUTQ = 0x40047473;
  1674. X$TIOCSTI = 0x80017472;
  1675. X$TIOCNOTTY = 0x20007471;
  1676. X$TIOCPKT = 0x80047470;
  1677. X$TIOCPKT_DATA = 0x00;
  1678. X$TIOCPKT_FLUSHREAD = 0x01;
  1679. X$TIOCPKT_FLUSHWRITE = 0x02;
  1680. X$TIOCPKT_STOP = 0x04;
  1681. X$TIOCPKT_START = 0x08;
  1682. X$TIOCPKT_NOSTOP = 0x10;
  1683. X$TIOCPKT_DOSTOP = 0x20;
  1684. X$TIOCSTOP = 0x2000746F;
  1685. X$TIOCSTART = 0x2000746E;
  1686. X$TIOCMSET = 0x8004746D;
  1687. X$TIOCMBIS = 0x8004746C;
  1688. X$TIOCMBIC = 0x8004746B;
  1689. X$TIOCMGET = 0x4004746A;
  1690. X$TIOCREMOTE = 0x80047469;
  1691. X$TIOCGWINSZ = 0x40087468;
  1692. X$TIOCSWINSZ = 0x80087467;
  1693. X$TIOCUCNTL = 0x80047466;
  1694. X$TIOCSSOFTC = 0x80047465;
  1695. X$TIOCGSOFTC = 0x40047464;
  1696. X$TIOCSCARR = 0x80047463;
  1697. X$TIOCWCARR = 0x20007462;
  1698. X$OTTYDISC = 0;
  1699. X$NETLDISC = 1;
  1700. X$NTTYDISC = 2;
  1701. X$TABLDISC = 3;
  1702. X$SLIPDISC = 4;
  1703. X$FIOCLEX = 0x20006601;
  1704. X$FIONCLEX = 0x20006602;
  1705. X$FIONREAD = 0x4004667F;
  1706. X$FIONBIO = 0x8004667E;
  1707. X$FIOASYNC = 0x8004667D;
  1708. X$FIOSETOWN = 0x8004667C;
  1709. X$FIOGETOWN = 0x4004667B;
  1710. X$SIOCSHIWAT = 0x80047300;
  1711. X$SIOCGHIWAT = 0x40047301;
  1712. X$SIOCSLOWAT = 0x80047302;
  1713. X$SIOCGLOWAT = 0x40047303;
  1714. X$SIOCATMARK = 0x40047307;
  1715. X$SIOCSPGRP = 0x80047308;
  1716. X$SIOCGPGRP = 0x40047309;
  1717. X$SIOCADDRT = 0x8030720A;
  1718. X$SIOCDELRT = 0x8030720B;
  1719. X$SIOCSIFADDR = 0x8020690C;
  1720. X$SIOCGIFADDR = 0xC020690D;
  1721. X$SIOCSIFDSTADDR = 0x8020690E;
  1722. X$SIOCGIFDSTADDR = 0xC020690F;
  1723. X$SIOCSIFFLAGS = 0x80206910;
  1724. X$SIOCGIFFLAGS = 0xC0206911;
  1725. X$SIOCGIFBRDADDR = 0xC0206912;
  1726. X$SIOCSIFBRDADDR = 0x80206913;
  1727. X$SIOCGIFCONF = 0xC0086914;
  1728. X$SIOCGIFNETMASK = 0xC0206915;
  1729. X$SIOCSIFNETMASK = 0x80206916;
  1730. X$SIOCGIFMETRIC = 0xC0206917;
  1731. X$SIOCSIFMETRIC = 0x80206918;
  1732. X$SIOCSARP = 0x8024691E;
  1733. X$SIOCGARP = 0xC024691F;
  1734. X$SIOCDARP = 0x80246920;
  1735. !STUFFY!FUNK!
  1736. echo Extracting lib/validate.pl
  1737. sed >lib/validate.pl <<'!STUFFY!FUNK!' -e 's/X//'
  1738. X;# $Header: validate.pl,v 3.0 89/10/18 15:20:04 lwall Locked $
  1739. X
  1740. X;# The validate routine takes a single multiline string consisting of
  1741. X;# lines containing a filename plus a file test to try on it.  (The
  1742. X;# file test may also be a 'cd', causing subsequent relative filenames
  1743. X;# to be interpreted relative to that directory.)  After the file test
  1744. X;# you may put '|| die' to make it a fatal error if the file test fails.
  1745. X;# The default is '|| warn'.  The file test may optionally have a ! prepended
  1746. X;# to test for the opposite condition.  If you do a cd and then list some
  1747. X;# relative filenames, you may want to indent them slightly for readability.
  1748. X;# If you supply your own "die" or "warn" message, you can use $file to
  1749. X;# interpolate the filename.
  1750. X
  1751. X;# Filetests may be bunched:  -rwx tests for all of -r, -w and -x.
  1752. X;# Only the first failed test of the bunch will produce a warning.
  1753. X
  1754. X;# The routine returns the number of warnings issued.
  1755. X
  1756. X;# Usage:
  1757. X;#    $warnings += do validate('
  1758. X;#    /vmunix            -e || die
  1759. X;#    /boot            -e || die
  1760. X;#    /bin            cd
  1761. X;#        csh            -ex
  1762. X;#        csh            !-ug
  1763. X;#        sh            -ex
  1764. X;#        sh            !-ug
  1765. X;#    /usr            -d || warn "What happened to $file?\n"
  1766. X;#    ');
  1767. X
  1768. Xsub validate {
  1769. X    local($file,$test,$warnings,$oldwarnings);
  1770. X    foreach $check (split(/\n/,$_[0])) {
  1771. X    next if $check =~ /^#/;
  1772. X    next if $check =~ /^$/;
  1773. X    ($file,$test) = split(' ',$check,2);
  1774. X    if ($test =~ s/^(!?-)(\w{2,}\b)/$1Z/) {
  1775. X        $testlist = $2;
  1776. X        @testlist = split(//,$testlist);
  1777. X    }
  1778. X    else {
  1779. X        @testlist = ('Z');
  1780. X    }
  1781. X    $oldwarnings = $warnings;
  1782. X    foreach $one (@testlist) {
  1783. X        $this = $test;
  1784. X        $this =~ s/(-\w\b)/$1 \$file/g;
  1785. X        $this =~ s/-Z/-$one/;
  1786. X        $this .= ' || warn' unless $this =~ /\|\|/;
  1787. X        $this =~ s/^(.*\S)\s*\|\|\s*(die|warn)$/$1 || do valmess('$2','$1')/;
  1788. X        $this =~ s/\bcd\b/chdir (\$cwd = \$file)/g;
  1789. X        eval $this;
  1790. X        last if $warnings > $oldwarnings;
  1791. X    }
  1792. X    }
  1793. X    $warnings;
  1794. X}
  1795. X
  1796. Xsub valmess {
  1797. X    local($disposition,$this) = @_;
  1798. X    $file = $cwd . '/' . $file unless $file =~ m|^/|;
  1799. X    if ($this =~ /^(!?)-(\w)\s+\$file\s*$/) {
  1800. X    $neg = $1;
  1801. X    $tmp = $2;
  1802. X    $tmp eq 'r' && ($mess = "$file is not readable by uid $>.");
  1803. X    $tmp eq 'w' && ($mess = "$file is not writable by uid $>.");
  1804. X    $tmp eq 'x' && ($mess = "$file is not executable by uid $>.");
  1805. X    $tmp eq 'o' && ($mess = "$file is not owned by uid $>.");
  1806. X    $tmp eq 'R' && ($mess = "$file is not readable by you.");
  1807. X    $tmp eq 'W' && ($mess = "$file is not writable by you.");
  1808. X    $tmp eq 'X' && ($mess = "$file is not executable by you.");
  1809. X    $tmp eq 'O' && ($mess = "$file is not owned by you.");
  1810. X    $tmp eq 'e' && ($mess = "$file does not exist.");
  1811. X    $tmp eq 'z' && ($mess = "$file does not have zero size.");
  1812. X    $tmp eq 's' && ($mess = "$file does not have non-zero size.");
  1813. X    $tmp eq 'f' && ($mess = "$file is not a plain file.");
  1814. X    $tmp eq 'd' && ($mess = "$file is not a directory.");
  1815. X    $tmp eq 'l' && ($mess = "$file is not a symbolic link.");
  1816. X    $tmp eq 'p' && ($mess = "$file is not a named pipe (FIFO).");
  1817. X    $tmp eq 'S' && ($mess = "$file is not a socket.");
  1818. X    $tmp eq 'b' && ($mess = "$file is not a block special file.");
  1819. X    $tmp eq 'c' && ($mess = "$file is not a character special file.");
  1820. X    $tmp eq 'u' && ($mess = "$file does not have the setuid bit set.");
  1821. X    $tmp eq 'g' && ($mess = "$file does not have the setgid bit set.");
  1822. X    $tmp eq 'k' && ($mess = "$file does not have the sticky bit set.");
  1823. X    $tmp eq 'T' && ($mess = "$file is not a text file.");
  1824. X    $tmp eq 'B' && ($mess = "$file is not a binary file.");
  1825. X    if ($neg eq '!') {
  1826. X        $mess =~ s/ is not / should not be / ||
  1827. X        $mess =~ s/ does not / should not / ||
  1828. X        $mess =~ s/ not / /;
  1829. X    }
  1830. X    print stderr $mess,"\n";
  1831. X    }
  1832. X    else {
  1833. X    $this =~ s/\$file/'$file'/g;
  1834. X    print stderr "Can't do $this.\n";
  1835. X    }
  1836. X    if ($disposition eq 'die') { exit 1; }
  1837. X    ++$warnings;
  1838. X}
  1839. X
  1840. X1;
  1841. !STUFFY!FUNK!
  1842. echo Extracting eg/g/gsh.man
  1843. sed >eg/g/gsh.man <<'!STUFFY!FUNK!' -e 's/X//'
  1844. X.\" $Header: gsh.man,v 3.0 89/10/18 15:14:42 lwall Locked $
  1845. X.TH GSH 8 "13 May 1988"
  1846. X.SH NAME
  1847. Xgsh \- global shell
  1848. X.SH SYNOPSIS
  1849. X.B gsh
  1850. X[options]
  1851. X.I host
  1852. X[options] 
  1853. X.I command
  1854. X.SH DESCRIPTION
  1855. X.I gsh
  1856. Xworks just like rsh(1C) except that you may specify a set of hosts to execute
  1857. Xthe command on.
  1858. XThe host sets are defined in the file /etc/ghosts.
  1859. X(An individual host name can be used as a set containing one member.)
  1860. XYou can give a command like
  1861. X
  1862. X    gsh sun /etc/mungmotd
  1863. X
  1864. Xto run /etc/mungmotd on all your Suns.
  1865. X.P
  1866. XYou may specify the union of two or more sets by using + as follows:
  1867. X
  1868. X    gsh 750+mc /etc/mungmotd
  1869. X
  1870. Xwhich will run mungmotd on all 750's and Masscomps.
  1871. X.P
  1872. XCommonly used sets should be defined in /etc/ghosts.
  1873. XFor example, you could add a line that says
  1874. X
  1875. X    pep=manny+moe+jack
  1876. X
  1877. XAnother way to do that would be to add the word "pep" after each of the host
  1878. Xentries:
  1879. X
  1880. X    manny    sun3 pep
  1881. X.br
  1882. X    moe        sun3 pep
  1883. X.br
  1884. X    jack        sun3 pep
  1885. X
  1886. XHosts and sets of host can also be excluded:
  1887. X
  1888. X    foo=sun-sun2
  1889. X
  1890. XAny host so excluded will never be included, even if a subsequent set on the
  1891. Xline includes it:
  1892. X
  1893. X    foo=abc+def
  1894. X    bar=xyz-abc+foo
  1895. X
  1896. Xcomes out to xyz+def.
  1897. X
  1898. XYou can define private host sets by creating .ghosts in your current directory
  1899. Xwith entries just like /etc/ghosts.
  1900. XAlso, if there is a file .grem, it defines "rem" to be the remaining hosts
  1901. Xfrom the last gsh or gcp that didn't succeed everywhere.
  1902. X
  1903. XOptions include all those defined by rsh, as well as
  1904. X
  1905. X.IP "\-d" 8
  1906. XCauses gsh to collect input till end of file, and then distribute that input
  1907. Xto each invokation of rsh.
  1908. X.IP "\-h" 8
  1909. XRather than print out the command followed by the output, merely prepends the
  1910. Xhost name to each line of output.
  1911. X.IP "\-s" 8
  1912. XDo work silently.
  1913. X.PP
  1914. XInterrupting with a SIGINT will cause the rsh to the current host to be skipped
  1915. Xand execution resumed with the next host.
  1916. XTo stop completely, send a SIGQUIT.
  1917. X.SH SEE ALSO
  1918. Xrsh(1C)
  1919. X.SH BUGS
  1920. XAll the bugs of rsh, since it calls rsh.
  1921. X
  1922. XAlso, will not properly return data from the remote execution that contains
  1923. Xnull characters.
  1924. !STUFFY!FUNK!
  1925. echo ""
  1926. echo "End of kit 21 (of 24)"
  1927. cat /dev/null >kit21isdone
  1928. run=''
  1929. config=''
  1930. for iskit in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24; do
  1931.     if test -f kit${iskit}isdone; then
  1932.     run="$run $iskit"
  1933.     else
  1934.     todo="$todo $iskit"
  1935.     fi
  1936. done
  1937. case $todo in
  1938.     '')
  1939.     echo "You have run all your kits.  Please read README and then type Configure."
  1940.     chmod 755 Configure
  1941.     ;;
  1942.     *)  echo "You have run$run."
  1943.     echo "You still need to run$todo."
  1944.     ;;
  1945. esac
  1946. : Someone might mail this, so...
  1947. exit
  1948.  
  1949.