home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume18 / perl / part34 < prev    next >
Internet Message Format  |  1991-04-20  |  51KB

  1. From: lwall@netlabs.com (Larry Wall)
  2. Newsgroups: comp.sources.misc
  3. Subject: v18i052:  perl - The perl programming language, Part34/36
  4. Message-ID: <1991Apr19.014951.5142@sparky.IMD.Sterling.COM>
  5. Date: 19 Apr 91 01:49:51 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 9ec7af2a 039d76e1 a016c771 32513094
  8.  
  9. Submitted-by: Larry Wall <lwall@netlabs.com>
  10. Posting-number: Volume 18, Issue 52
  11. Archive-name: perl/part34
  12.  
  13. [There are 36 kits for perl version 4.0.]
  14.  
  15. #! /bin/sh
  16.  
  17. # Make a new directory for the perl sources, cd to it, and run kits 1
  18. # thru 36 through sh.  When all 36 kits have been run, read README.
  19.  
  20. echo "This is perl 4.0 kit 34 (of 36).  If kit 34 is complete, the line"
  21. echo '"'"End of kit 34 (of 36)"'" will echo at the end.'
  22. echo ""
  23. export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
  24. mkdir eg eg/g eg/scan eg/van h2pl h2pl/eg h2pl/eg/sys lib msdos os2 os2/eg t t/comp t/op usub x2p 2>/dev/null
  25. echo Extracting os2/dir.h
  26. sed >os2/dir.h <<'!STUFFY!FUNK!' -e 's/X//'
  27. X/*
  28. X * @(#) dir.h 1.4 87/11/06   Public Domain.
  29. X *
  30. X *  A public domain implementation of BSD directory routines for
  31. X *  MS-DOS.  Written by Michael Rendell ({uunet,utai}michael@garfield),
  32. X *  August 1987
  33. X *
  34. X *  Enhanced and ported to OS/2 by Kai Uwe Rommel; added scandir() prototype
  35. X *  December 1989, February 1990
  36. X *  Change of MAXPATHLEN for HPFS, October 1990
  37. X */
  38. X
  39. X
  40. X#define MAXNAMLEN  256
  41. X#define MAXPATHLEN 256
  42. X
  43. X#define A_RONLY    0x01
  44. X#define A_HIDDEN   0x02
  45. X#define A_SYSTEM   0x04
  46. X#define A_LABEL    0x08
  47. X#define A_DIR      0x10
  48. X#define A_ARCHIVE  0x20
  49. X
  50. X
  51. Xstruct direct
  52. X{
  53. X  ino_t    d_ino;                   /* a bit of a farce */
  54. X  int      d_reclen;                /* more farce */
  55. X  int      d_namlen;                /* length of d_name */
  56. X  char     d_name[MAXNAMLEN + 1];   /* null terminated */
  57. X  /* nonstandard fields */
  58. X  long     d_size;                  /* size in bytes */
  59. X  unsigned d_mode;                  /* DOS or OS/2 file attributes */
  60. X  unsigned d_time;
  61. X  unsigned d_date;
  62. X};
  63. X
  64. X/* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel).
  65. X * The find_first and find_next calls deliver this data without any extra cost.
  66. X * If this data is needed, these fields save a lot of extra calls to stat()
  67. X * (each stat() again performs a find_first call !).
  68. X */
  69. X
  70. Xstruct _dircontents
  71. X{
  72. X  char *_d_entry;
  73. X  long _d_size;
  74. X  unsigned _d_mode, _d_time, _d_date;
  75. X  struct _dircontents *_d_next;
  76. X};
  77. X
  78. Xtypedef struct _dirdesc
  79. X{
  80. X  int  dd_id;                   /* uniquely identify each open directory */
  81. X  long dd_loc;                  /* where we are in directory entry is this */
  82. X  struct _dircontents *dd_contents;   /* pointer to contents of dir */
  83. X  struct _dircontents *dd_cp;         /* pointer to current position */
  84. X}
  85. XDIR;
  86. X
  87. X
  88. Xextern int attributes;
  89. X
  90. Xextern DIR *opendir(char *);
  91. Xextern struct direct *readdir(DIR *);
  92. Xextern void seekdir(DIR *, long);
  93. Xextern long telldir(DIR *);
  94. Xextern void closedir(DIR *);
  95. X#define rewinddir(dirp) seekdir(dirp, 0L)
  96. X
  97. Xextern int scandir(char *, struct direct ***,
  98. X                   int (*)(struct direct *),
  99. X                   int (*)(struct direct *, struct direct *));
  100. X
  101. Xextern int getfmode(char *);
  102. Xextern int setfmode(char *, unsigned);
  103. !STUFFY!FUNK!
  104. echo Extracting os2/eg/os2.pl
  105. sed >os2/eg/os2.pl <<'!STUFFY!FUNK!' -e 's/X//'
  106. Xextproc C:\binp\misc\perl.exe -S
  107. X#!perl
  108. X
  109. X# os2.pl:  Demonstrates the OS/2 system calls and shows off some of the
  110. X# features in common with the UNIX version.
  111. X
  112. Xdo "syscalls.pl" || die "Cannot load syscalls.pl ($!)";
  113. X
  114. X# OS/2 version number.
  115. X
  116. X    $version = "  "; syscall($OS2_GetVersion,$version); 
  117. X    ($minor, $major) = unpack("CC", $version);
  118. X    print "You are using OS/2 version ", int($major/10), 
  119. X            ".", int($minor/10), "\n\n";
  120. X# Process ID.
  121. X    print "This process ID is $$ and its parent's ID is ", 
  122. X        getppid(), "\n\n";
  123. X
  124. X# Priority.
  125. X
  126. X    printf "Current priority is %x\n", getpriority(0,0);
  127. X    print "Changing priority by +5\n";
  128. X    print "Failed!\n" unless setpriority(0,0,+5);
  129. X    printf "Priority is now %x\n\n", getpriority(0,0);
  130. X
  131. X# Beep.
  132. X    print "Here is an A440.\n\n";
  133. X    syscall($OS2_Beep,440,50);
  134. X
  135. X# Pipes.  Unlike MS-DOS, OS/2 supports true asynchronous pipes.
  136. X    open(ROT13, '|perl -pe y/a-zA-Z/n-za-mN-ZA-M/') || die;
  137. X    select(ROT13); $|=1; select(STDOUT);
  138. X    print "Type two lines of stuff, and I'll ROT13 it while you wait.\n".
  139. X          "If you type fast, you might be able to type both of your\n".
  140. X          "lines before I get a chance to translate the first line.\n";
  141. X    $_ = <STDIN>; print ROT13 $_;
  142. X    $_ = <STDIN>; print ROT13 $_;
  143. X    close(ROT13);
  144. X    print "Thanks.\n\n";
  145. X
  146. X# Inspecting the disks.
  147. X    print "Let's look at the disks you have installed...\n\n";
  148. X
  149. X    $x = "\0\0";
  150. X    syscall($OS2_Config, $x, 2);
  151. X    print "You have ", unpack("S", $x), " floppy disks,\n";
  152. X
  153. X    $x = "  ";
  154. X    syscall($OS2_PhysicalDisk, 1, $x, 2, 0, 0);
  155. X    ($numdisks) = unpack("S", $x);
  156. X
  157. X    print "and $numdisks partitionable disks.\n\n";
  158. X    for ($i = 1; $i <= $numdisks; $i++) {
  159. X        $disk = $i . ":";
  160. X        $handle = "  ";
  161. X        syscall($OS2_PhysicalDisk, 2, $handle, 2, $disk, 3);
  162. X        ($numhandle) = unpack("S", $handle);
  163. X        $zero = pack("C", 0);
  164. X        $parmblock = " " x 16;
  165. X        syscall($OS2_IOCtl, $parmblock, $zero, 0x63, 9, $numhandle);
  166. X        ($x, $cylinders, $heads, $sect) = unpack("SSSS", $parmblock);
  167. X        print "Hard drive #$i:\n";
  168. X        print "   cylinders: $cylinders\n";
  169. X        print "       heads: $heads\n";
  170. X        print "    sect/trk: $sect\n";
  171. X        syscall($OS2_PhysicalDisk, 3, 0, 0, $handle, 2);
  172. X    }
  173. X
  174. X# I won't bother with the other stuff.  You get the idea.
  175. X
  176. !STUFFY!FUNK!
  177. echo Extracting t/op/write.t
  178. sed >t/op/write.t <<'!STUFFY!FUNK!' -e 's/X//'
  179. X#!./perl
  180. X
  181. X# $Header: write.t,v 4.0 91/03/20 01:55:34 lwall Locked $
  182. X
  183. Xprint "1..3\n";
  184. X
  185. Xformat OUT =
  186. Xthe quick brown @<<
  187. X$fox
  188. Xjumped
  189. X@*
  190. X$multiline
  191. X^<<<<<<<<<
  192. X$foo
  193. X^<<<<<<<<<
  194. X$foo
  195. X^<<<<<<...
  196. X$foo
  197. Xnow @<<the@>>>> for all@|||||men to come @<<<<
  198. X'i' . 's', "time\n", $good, 'to'
  199. X.
  200. X
  201. Xopen(OUT, '>Op.write.tmp') || die "Can't create Op.write.tmp";
  202. X
  203. X$fox = 'foxiness';
  204. X$good = 'good';
  205. X$multiline = "forescore\nand\nseven years\n";
  206. X$foo = 'when in the course of human events it becomes necessary';
  207. Xwrite(OUT);
  208. Xclose OUT;
  209. X
  210. X$right =
  211. X"the quick brown fox
  212. Xjumped
  213. Xforescore
  214. Xand
  215. Xseven years
  216. Xwhen in
  217. Xthe course
  218. Xof huma...
  219. Xnow is the time for all good men to come to\n";
  220. X
  221. Xif (`cat Op.write.tmp` eq $right)
  222. X    { print "ok 1\n"; unlink 'Op.write.tmp'; }
  223. Xelse
  224. X    { print "not ok 1\n"; }
  225. X
  226. Xformat OUT2 =
  227. Xthe quick brown @<<
  228. X$fox
  229. Xjumped
  230. X@*
  231. X$multiline
  232. X^<<<<<<<<< ~~
  233. X$foo
  234. Xnow @<<the@>>>> for all@|||||men to come @<<<<
  235. X'i' . 's', "time\n", $good, 'to'
  236. X.
  237. X
  238. Xopen(OUT2, '>Op.write.tmp') || die "Can't create Op.write.tmp";
  239. X
  240. X$fox = 'foxiness';
  241. X$good = 'good';
  242. X$multiline = "forescore\nand\nseven years\n";
  243. X$foo = 'when in the course of human events it becomes necessary';
  244. Xwrite(OUT2);
  245. Xclose OUT2;
  246. X
  247. X$right =
  248. X"the quick brown fox
  249. Xjumped
  250. Xforescore
  251. Xand
  252. Xseven years
  253. Xwhen in
  254. Xthe course
  255. Xof human
  256. Xevents it
  257. Xbecomes
  258. Xnecessary
  259. Xnow is the time for all good men to come to\n";
  260. X
  261. Xif (`cat Op.write.tmp` eq $right)
  262. X    { print "ok 2\n"; unlink 'Op.write.tmp'; }
  263. Xelse
  264. X    { print "not ok 2\n"; }
  265. X
  266. Xeval <<'EOFORMAT';
  267. Xformat OUT2 =
  268. Xthe brown quick @<<
  269. X$fox
  270. Xjumped
  271. X@*
  272. X$multiline
  273. X^<<<<<<<<< ~~
  274. X$foo
  275. Xnow @<<the@>>>> for all@|||||men to come @<<<<
  276. X'i' . 's', "time\n", $good, 'to'
  277. X.
  278. XEOFORMAT
  279. X
  280. Xopen(OUT2, '>Op.write.tmp') || die "Can't create Op.write.tmp";
  281. X
  282. X$fox = 'foxiness';
  283. X$good = 'good';
  284. X$multiline = "forescore\nand\nseven years\n";
  285. X$foo = 'when in the course of human events it becomes necessary';
  286. Xwrite(OUT2);
  287. Xclose OUT2;
  288. X
  289. X$right =
  290. X"the brown quick fox
  291. Xjumped
  292. Xforescore
  293. Xand
  294. Xseven years
  295. Xwhen in
  296. Xthe course
  297. Xof human
  298. Xevents it
  299. Xbecomes
  300. Xnecessary
  301. Xnow is the time for all good men to come to\n";
  302. X
  303. Xif (`cat Op.write.tmp` eq $right)
  304. X    { print "ok 3\n"; unlink 'Op.write.tmp'; }
  305. Xelse
  306. X    { print "not ok 3\n"; }
  307. X
  308. !STUFFY!FUNK!
  309. echo Extracting lib/complete.pl
  310. sed >lib/complete.pl <<'!STUFFY!FUNK!' -e 's/X//'
  311. X;#
  312. X;#    @(#)complete.pl    1.0 (sun!waynet) 11/11/88
  313. X;#
  314. X;# Author: Wayne Thompson
  315. X;#
  316. X;# Description:
  317. X;#     This routine provides word completion.
  318. X;#     (TAB) attempts word completion.
  319. X;#     (^D)  prints completion list.
  320. X;#    (These may be changed by setting $Complete'complete, etc.)
  321. X;#
  322. X;# Diagnostics:
  323. X;#     Bell when word completion fails.
  324. X;#
  325. X;# Dependencies:
  326. X;#     The tty driver is put into raw mode.
  327. X;#
  328. X;# Bugs:
  329. X;#
  330. X;# Usage:
  331. X;#     $input = do Complete('prompt_string', @completion_list);
  332. X;#
  333. X
  334. XCONFIG: {
  335. X    package Complete;
  336. X
  337. X    $complete =    "\004";
  338. X    $kill =    "\025";
  339. X    $erase1 =    "\177";
  340. X    $erase2 =    "\010";
  341. X}
  342. X
  343. Xsub Complete {
  344. X    package Complete;
  345. X
  346. X    local ($prompt) = shift (@_);
  347. X    local ($c, $cmp, $l, $r, $ret, $return, $test);
  348. X    @_cmp_lst = sort @_;
  349. X    local($[) = 0;
  350. X    system 'stty raw -echo';
  351. X    loop: {
  352. X    print $prompt, $return;
  353. X    while (($c = getc(stdin)) ne "\r") {
  354. X        if ($c eq "\t") {            # (TAB) attempt completion
  355. X        @_match = ();
  356. X        foreach $cmp (@_cmp_lst) {
  357. X            push (@_match, $cmp) if $cmp =~ /^$return/;
  358. X        }
  359. X                $test = $_match[0];
  360. X                $l = length ($test);
  361. X        unless ($#_match == 0) {
  362. X                    shift (@_match);
  363. X                    foreach $cmp (@_match) {
  364. X                        until (substr ($cmp, 0, $l) eq substr ($test, 0, $l)) {
  365. X                            $l--;
  366. X                        }
  367. X                    }
  368. X                    print "\007";
  369. X                }
  370. X                print $test = substr ($test, $r, $l - $r);
  371. X                $r = length ($return .= $test);
  372. X        }
  373. X        elsif ($c eq $complete) {        # (^D) completion list
  374. X        print "\r\n";
  375. X        foreach $cmp (@_cmp_lst) {
  376. X            print "$cmp\r\n" if $cmp =~ /^$return/;
  377. X        }
  378. X        redo loop;
  379. X        }
  380. X            elsif ($c eq $kill && $r) {    # (^U) kill
  381. X                $return = '';
  382. X                $r = 0;
  383. X                print "\r\n";
  384. X                redo loop;
  385. X            }
  386. X                                            # (DEL) || (BS) erase
  387. X        elsif ($c eq $erase1 || $c eq $erase2) {
  388. X        if($r) {
  389. X            print "\b \b";
  390. X            chop ($return);
  391. X            $r--;
  392. X        }
  393. X        }
  394. X        elsif ($c =~ /\S/) {                # printable char
  395. X        $return .= $c;
  396. X        $r++;
  397. X        print $c;
  398. X        }
  399. X    }
  400. X    }
  401. X    system 'stty -raw echo';
  402. X    print "\n";
  403. X    $return;
  404. X}
  405. X
  406. X1;
  407. !STUFFY!FUNK!
  408. echo Extracting eg/scan/scanner
  409. sed >eg/scan/scanner <<'!STUFFY!FUNK!' -e 's/X//'
  410. X#!/usr/bin/perl
  411. X
  412. X# $Header: scanner,v 4.0 91/03/20 01:14:11 lwall Locked $
  413. X
  414. X# This runs all the scan_* routines on all the machines in /etc/ghosts.
  415. X# We run this every morning at about 6 am:
  416. X
  417. X#    !/bin/sh
  418. X#    cd /usr/adm/private
  419. X#    decrypt scanner | perl >scan.out 2>&1
  420. X#    mail admin <scan.out
  421. X
  422. X# Note that the scan_* files should be encrypted with the key "-inquire", and
  423. X# scanner should be encrypted somehow so that people can't find that key.
  424. X# I leave it up to you to figure out how to unencrypt it before executing.
  425. X
  426. X$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/ucb:.';
  427. X
  428. X$| = 1;        # command buffering on stdout
  429. X
  430. Xprint "Subject: bizarre happenings\n\n";
  431. X
  432. X(chdir '/usr/adm/private') || die "Can't cd to /usr/adm/private: $!\n";
  433. X
  434. Xif ($#ARGV >= 0) {
  435. X    @scanlist = @ARGV;
  436. X} else {
  437. X    @scanlist = split(/[ \t\n]+/,`echo scan_*`);
  438. X}
  439. X
  440. Xscan: while ($scan = shift(@scanlist)) {
  441. X    print "\n********** $scan **********\n";
  442. X    $showhost++;
  443. X
  444. X    $systype = 'all';
  445. X
  446. X    open(ghosts, '/etc/ghosts') || die 'No /etc/ghosts file';
  447. X
  448. X    $one_of_these = ":$systype:";
  449. X    if ($systype =~ s/\+/[+]/g) {
  450. X    $one_of_these =~ s/\+/:/g;
  451. X    }
  452. X
  453. X    line: while (<ghosts>) {
  454. X    s/[ \t]*\n//;
  455. X    if (!$_ || /^#/) {
  456. X        next line;
  457. X    }
  458. X    if (/^([a-zA-Z_0-9]+)=(.+)/) {
  459. X        $name = $1; $repl = $2;
  460. X        $repl =~ s/\+/:/g;
  461. X        $one_of_these =~ s/:$name:/:$repl:/;
  462. X        next line;
  463. X    }
  464. X    @gh = split;
  465. X    $host = $gh[0];
  466. X    if ($showhost) { $showhost = "$host:\t"; }
  467. X    class: while ($class = pop(gh)) {
  468. X        if (index($one_of_these,":$class:") >=0) {
  469. X        $iter = 0;
  470. X        `exec crypt -inquire <$scan >.x 2>/dev/null`;
  471. X        unless (open(scan,'.x')) {
  472. X            print "Can't run $scan: $!\n";
  473. X            next scan;
  474. X        }
  475. X        $cmd = <scan>;
  476. X        unless ($cmd =~ s/#!(.*)\n/$1/) {
  477. X            $cmd = '/usr/bin/perl';
  478. X        }
  479. X        close(scan);
  480. X        if (open(PIPE,"exec rsh $host '$cmd' <.x|")) {
  481. X            sleep(5);
  482. X            unlink '.x';
  483. X            while (<PIPE>) {
  484. X            last if $iter++ > 1000;        # must be looping
  485. X            next if /^[0-9.]+u [0-9.]+s/;
  486. X            print $showhost,$_;
  487. X            }
  488. X            close(PIPE);
  489. X        } else {
  490. X            print "(Can't execute rsh: $!)\n";
  491. X        }
  492. X        last class;
  493. X        }
  494. X    }
  495. X    }
  496. X}
  497. !STUFFY!FUNK!
  498. echo Extracting eg/g/gcp.man
  499. sed >eg/g/gcp.man <<'!STUFFY!FUNK!' -e 's/X//'
  500. X.\" $Header: gcp.man,v 4.0 91/03/20 01:10:13 lwall Locked $
  501. X.TH GCP 1C "13 May 1988"
  502. X.SH NAME
  503. Xgcp \- global file copy
  504. X.SH SYNOPSIS
  505. X.B gcp
  506. Xfile1 file2
  507. X.br
  508. X.B gcp
  509. X[
  510. X.B \-r
  511. X] file ... directory
  512. X.SH DESCRIPTION
  513. X.I gcp
  514. Xworks just like rcp(1C) except that you may specify a set of hosts to copy files
  515. Xfrom or to.
  516. XThe host sets are defined in the file /etc/ghosts.
  517. X(An individual host name can be used as a set containing one member.)
  518. XYou can give a command like
  519. X
  520. X    gcp /etc/motd sun:
  521. X
  522. Xto copy your /etc/motd file to /etc/motd on all the Suns.
  523. XIf, on the other hand, you say
  524. X
  525. X    gcp /a/foo /b/bar sun:/tmp
  526. X
  527. Xthen your files will be copied to /tmp on all the Suns.
  528. XThe general rule is that if you don't specify the destination directory,
  529. Xfiles go to the same directory they are in currently.
  530. X.P
  531. XYou may specify the union of two or more sets by using + as follows:
  532. X
  533. X    gcp /a/foo /b/bar 750+mc:
  534. X
  535. Xwhich will copy /a/foo to /a/foo on all 750's and Masscomps, and then copy
  536. X/b/bar to /b/bar on all 750's and Masscomps.
  537. X.P
  538. XCommonly used sets should be defined in /etc/ghosts.
  539. XFor example, you could add a line that says
  540. X
  541. X    pep=manny+moe+jack
  542. X
  543. XAnother way to do that would be to add the word "pep" after each of the host
  544. Xentries:
  545. X
  546. X    manny    sun3 pep
  547. X.br
  548. X    moe        sun3 pep
  549. X.br
  550. X    jack        sun3 pep
  551. X
  552. XHosts and sets of host can also be excluded:
  553. X
  554. X    foo=sun-sun2
  555. X
  556. XAny host so excluded will never be included, even if a subsequent set on the
  557. Xline includes it:
  558. X
  559. X    foo=abc+def
  560. X.br
  561. X    bar=xyz-abc+foo
  562. X
  563. Xcomes out to xyz+def.
  564. X
  565. XYou can define private host sets by creating .ghosts in your current directory
  566. Xwith entries just like /etc/ghosts.
  567. XAlso, if there is a file .grem, it defines "rem" to be the remaining hosts
  568. Xfrom the last gsh or gcp that didn't succeed everywhere.
  569. X.PP
  570. XInterrupting with a SIGINT will cause the rcp to the current host to be skipped
  571. Xand execution resumed with the next host.
  572. XTo stop completely, send a SIGQUIT.
  573. X.SH SEE ALSO
  574. Xrcp(1C)
  575. X.SH BUGS
  576. XAll the bugs of rcp, since it calls rcp.
  577. !STUFFY!FUNK!
  578. echo Extracting t/TEST
  579. sed >t/TEST <<'!STUFFY!FUNK!' -e 's/X//'
  580. X#!./perl
  581. X
  582. X# $Header: TEST,v 4.0 91/03/20 01:40:22 lwall Locked $
  583. X
  584. X# This is written in a peculiar style, since we're trying to avoid
  585. X# most of the constructs we'll be testing for.
  586. X
  587. X$| = 1;
  588. X
  589. Xif ($ARGV[0] eq '-v') {
  590. X    $verbose = 1;
  591. X    shift;
  592. X}
  593. X
  594. Xchdir 't' if -f 't/TEST';
  595. X
  596. Xif ($ARGV[0] eq '') {
  597. X    @ARGV = split(/[ \n]/,
  598. X      `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
  599. X}
  600. X
  601. Xopen(CONFIG,"../config.sh");
  602. Xwhile (<CONFIG>) {
  603. X    if (/sharpbang='(.*)'/) {
  604. X    $sharpbang = ($1 eq '#!');
  605. X    last;
  606. X    }
  607. X}
  608. X$bad = 0;
  609. Xwhile ($test = shift) {
  610. X    if ($test =~ /^$/) {
  611. X    next;
  612. X    }
  613. X    $te = $test;
  614. X    chop($te);
  615. X    print "$te" . '.' x (15 - length($te));
  616. X    if ($sharpbang) {
  617. X    open(results,"./$test|") || (print "can't run.\n");
  618. X    } else {
  619. X    open(script,"$test") || die "Can't run $test.\n";
  620. X    $_ = <script>;
  621. X    close(script);
  622. X    if (/#!..perl(.*)/) {
  623. X        $switch = $1;
  624. X    } else {
  625. X        $switch = '';
  626. X    }
  627. X    open(results,"./perl$switch $test|") || (print "can't run.\n");
  628. X    }
  629. X    $ok = 0;
  630. X    $next = 0;
  631. X    while (<results>) {
  632. X    if ($verbose) {
  633. X        print $_;
  634. X    }
  635. X    unless (/^#/) {
  636. X        if (/^1\.\.([0-9]+)/) {
  637. X        $max = $1;
  638. X        $next = 1;
  639. X        $ok = 1;
  640. X        } else {
  641. X        $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
  642. X        if (/^ok (.*)/ && $1 == $next) {
  643. X            $next = $next + 1;
  644. X        } else {
  645. X            $ok = 0;
  646. X        }
  647. X        }
  648. X    }
  649. X    }
  650. X    $next = $next - 1;
  651. X    if ($ok && $next == $max) {
  652. X    print "ok\n";
  653. X    } else {
  654. X    $next += 1;
  655. X    print "FAILED on test $next\n";
  656. X    $bad = $bad + 1;
  657. X    $_ = $test;
  658. X    if (/^base/) {
  659. X        die "Failed a basic test--cannot continue.\n";
  660. X    }
  661. X    }
  662. X}
  663. X
  664. Xif ($bad == 0) {
  665. X    if ($ok) {
  666. X    print "All tests successful.\n";
  667. X    } else {
  668. X    die "FAILED--no tests were run for some reason.\n";
  669. X    }
  670. X} else {
  671. X    if ($bad == 1) {
  672. X    die "Failed 1 test.\n";
  673. X    } else {
  674. X    die "Failed $bad tests.\n";
  675. X    }
  676. X}
  677. X($user,$sys,$cuser,$csys) = times;
  678. Xprint sprintf("u=%g  s=%g  cu=%g  cs=%g\n",$user,$sys,$cuser,$csys);
  679. !STUFFY!FUNK!
  680. echo Extracting eg/rename
  681. sed >eg/rename <<'!STUFFY!FUNK!' -e 's/X//'
  682. X#!/usr/bin/perl
  683. X'di';
  684. X'ig00';
  685. X#
  686. X# $Header: rename,v 4.0 91/03/20 01:11:53 lwall Locked $
  687. X#
  688. X# $Log:    rename,v $
  689. X# Revision 4.0  91/03/20  01:11:53  lwall
  690. X# 4.0 baseline.
  691. X# 
  692. X# Revision 3.0.1.2  90/08/09  03:17:57  lwall
  693. X# patch19: added man page for relink and rename
  694. X# 
  695. X
  696. X($op = shift) || die "Usage: rename perlexpr [filenames]\n";
  697. Xif (!@ARGV) {
  698. X    @ARGV = <STDIN>;
  699. X    chop(@ARGV);
  700. X}
  701. Xfor (@ARGV) {
  702. X    $was = $_;
  703. X    eval $op;
  704. X    die $@ if $@;
  705. X    rename($was,$_) unless $was eq $_;
  706. X}
  707. X##############################################################################
  708. X
  709. X    # These next few lines are legal in both Perl and nroff.
  710. X
  711. X.00;            # finish .ig
  712. X'di            \" finish diversion--previous line must be blank
  713. X.nr nl 0-1        \" fake up transition to first page again
  714. X.nr % 0            \" start at page 1
  715. X';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
  716. X.TH RENAME 1 "July 30, 1990"
  717. X.AT 3
  718. X.SH NAME
  719. Xrename \- renames multiple files
  720. X.SH SYNOPSIS
  721. X.B rename perlexpr [files]
  722. X.SH DESCRIPTION
  723. X.I Rename
  724. Xrenames the filenames supplied according to the rule specified as the
  725. Xfirst argument.
  726. XThe argument is a Perl expression which is expected to modify the $_
  727. Xstring in Perl for at least some of the filenames specified.
  728. XIf a given filename is not modified by the expression, it will not be
  729. Xrenamed.
  730. XIf no filenames are given on the command line, filenames will be read
  731. Xvia standard input.
  732. X.PP
  733. XFor example, to rename all files matching *.bak to strip the extension,
  734. Xyou might say
  735. X.nf
  736. X
  737. X    rename 's/\e.bak$//' *.bak
  738. X
  739. X.fi
  740. XTo translate uppercase names to lower, you'd use
  741. X.nf
  742. X
  743. X    rename 'y/A-Z/a-z/' *
  744. X
  745. X.fi
  746. X.SH ENVIRONMENT
  747. XNo environment variables are used.
  748. X.SH FILES
  749. X.SH AUTHOR
  750. XLarry Wall
  751. X.SH "SEE ALSO"
  752. Xmv(1)
  753. X.br
  754. Xperl(1)
  755. X.SH DIAGNOSTICS
  756. XIf you give an invalid Perl expression you'll get a syntax error.
  757. X.SH BUGS
  758. X.I Rename
  759. Xdoes not check for the existence of target filenames, so use with care.
  760. X.ex
  761. !STUFFY!FUNK!
  762. echo Extracting msdos/usage.c
  763. sed >msdos/usage.c <<'!STUFFY!FUNK!' -e 's/X//'
  764. X/*    usage.c
  765. X *
  766. X * Show usage message.
  767. X */
  768. X
  769. X#include <stdio.h>
  770. X#include <string.h>
  771. X
  772. X
  773. Xusage(char *myname)
  774. X{
  775. Xchar    * p;
  776. Xchar     * name_p;
  777. X
  778. Xname_p = myname;
  779. Xif ( p = strrchr(myname,'/') )
  780. X    name_p = p+1;    /* point after final '/' */
  781. X#ifdef MSDOS
  782. Xif ( p = strrchr(name_p,'\\') )
  783. X    name_p = p+1;    /* point after final '\\' */
  784. Xif ( p = strrchr(name_p,':') )
  785. X    name_p = p+1;    /* point after final ':' */
  786. X  printf("\nUsage: %s [-acdnpsSvw] [-Dnumber] [-i[extension]] [-Idirectory]"
  787. X#else
  788. X  printf("\nUsage: %s [-acdnpPsSuUvw] [-Dnumber] [-i[extension]] [-Idirectory]"
  789. X#endif
  790. X         "\n            [-e \"command\"] [-x[directory]] [filename] [arguments]\n", name_p);
  791. X
  792. X  printf("\n  -a  autosplit mode with -n or -p"
  793. X         "\n  -c  syntaxcheck only"
  794. X         "\n  -d  run scripts under debugger"
  795. X         "\n  -n  assume 'while (<>) { ...script... }' loop arround your script"
  796. X         "\n  -p  assume loop like -n but print line also like sed"
  797. X#ifndef MSDOS
  798. X         "\n  -P  run script through C preprocessor befor compilation"
  799. X#endif
  800. X         "\n  -s  enable some switch parsing for switches after script name"
  801. X         "\n  -S  look for the script using PATH environment variable");
  802. X#ifndef MSDOS
  803. X  printf("\n  -u  dump core after compiling the script"
  804. X         "\n  -U  allow unsafe operations");
  805. X#endif
  806. X  printf("\n  -v  print version number and patchlevel of perl"
  807. X         "\n  -w  turn warnings on for compilation of your script\n"
  808. X         "\n  -Dnumber        set debugging flags"
  809. X         "\n  -i[extension]   edit <> files in place (make backup if extension supplied)"
  810. X         "\n  -Idirectory     specify include directory in conjunction with -P"
  811. X         "\n  -e command      one line of script, multiple -e options are allowed"
  812. X         "\n                  [filename] can be ommitted, when -e is used"
  813. X         "\n  -x[directory]   strip off text before #!perl line and perhaps cd to directory\n");
  814. X}
  815. !STUFFY!FUNK!
  816. echo Extracting t/op/split.t
  817. sed >t/op/split.t <<'!STUFFY!FUNK!' -e 's/X//'
  818. X#!./perl
  819. X
  820. X# $Header: split.t,v 4.0 91/03/20 01:54:42 lwall Locked $
  821. X
  822. Xprint "1..12\n";
  823. X
  824. X$FS = ':';
  825. X
  826. X$_ = 'a:b:c';
  827. X
  828. X($a,$b,$c) = split($FS,$_);
  829. X
  830. Xif (join(';',$a,$b,$c) eq 'a;b;c') {print "ok 1\n";} else {print "not ok 1\n";}
  831. X
  832. X@ary = split(/:b:/);
  833. Xif (join("$_",@ary) eq 'aa:b:cc') {print "ok 2\n";} else {print "not ok 2\n";}
  834. X
  835. X$_ = "abc\n";
  836. X@xyz = (@ary = split(//));
  837. Xif (join(".",@ary) eq "a.b.c.\n") {print "ok 3\n";} else {print "not ok 3\n";}
  838. X
  839. X$_ = "a:b:c::::";
  840. X@ary = split(/:/);
  841. Xif (join(".",@ary) eq "a.b.c") {print "ok 4\n";} else {print "not ok 4\n";}
  842. X
  843. X$_ = join(':',split(' ',"    a b\tc \t d "));
  844. Xif ($_ eq 'a:b:c:d') {print "ok 5\n";} else {print "not ok 5 #$_#\n";}
  845. X
  846. X$_ = join(':',split(/ */,"foo  bar bie\tdoll"));
  847. Xif ($_ eq "f:o:o:b:a:r:b:i:e:\t:d:o:l:l")
  848. X    {print "ok 6\n";} else {print "not ok 6\n";}
  849. X
  850. X$_ = join(':', 'foo', split(/ /,'a b  c'), 'bar');
  851. Xif ($_ eq "foo:a:b::c:bar") {print "ok 7\n";} else {print "not ok 7 $_\n";}
  852. X
  853. X# Can we say how many fields to split to?
  854. X$_ = join(':', split(' ','1 2 3 4 5 6', 3));
  855. Xprint $_ eq '1:2:3 4 5 6' ? "ok 8\n" : "not ok 8 $_\n";
  856. X
  857. X# Can we do it as a variable?
  858. X$x = 4;
  859. X$_ = join(':', split(' ','1 2 3 4 5 6', $x));
  860. Xprint $_ eq '1:2:3:4 5 6' ? "ok 9\n" : "not ok 9 $_\n";
  861. X
  862. X# Does the 999 suppress null field chopping?
  863. X$_ = join(':', split(/:/,'1:2:3:4:5:6:::', 999));
  864. Xprint $_ eq '1:2:3:4:5:6:::' ? "ok 10\n" : "not ok 10 $_\n";
  865. X
  866. X# Does assignment to a list imply split to one more field than that?
  867. X$foo = `./perl -D1024 -e '(\$a,\$b) = split;' 2>&1`;
  868. Xprint $foo =~ /DEBUGGING/ || $foo =~ /num\(3\)/ ? "ok 11\n" : "not ok 11\n";
  869. X
  870. X# Can we say how many fields to split to when assigning to a list?
  871. X($a,$b) = split(' ','1 2 3 4 5 6', 2);
  872. X$_ = join(':',$a,$b);
  873. Xprint $_ eq '1:2 3 4 5 6' ? "ok 12\n" : "not ok 12 $_\n";
  874. X
  875. !STUFFY!FUNK!
  876. echo Extracting h2pl/eg/sys/errno.pl
  877. sed >h2pl/eg/sys/errno.pl <<'!STUFFY!FUNK!' -e 's/X//'
  878. X$EPERM = 0x1;
  879. X$ENOENT = 0x2;
  880. X$ESRCH = 0x3;
  881. X$EINTR = 0x4;
  882. X$EIO = 0x5;
  883. X$ENXIO = 0x6;
  884. X$E2BIG = 0x7;
  885. X$ENOEXEC = 0x8;
  886. X$EBADF = 0x9;
  887. X$ECHILD = 0xA;
  888. X$EAGAIN = 0xB;
  889. X$ENOMEM = 0xC;
  890. X$EACCES = 0xD;
  891. X$EFAULT = 0xE;
  892. X$ENOTBLK = 0xF;
  893. X$EBUSY = 0x10;
  894. X$EEXIST = 0x11;
  895. X$EXDEV = 0x12;
  896. X$ENODEV = 0x13;
  897. X$ENOTDIR = 0x14;
  898. X$EISDIR = 0x15;
  899. X$EINVAL = 0x16;
  900. X$ENFILE = 0x17;
  901. X$EMFILE = 0x18;
  902. X$ENOTTY = 0x19;
  903. X$ETXTBSY = 0x1A;
  904. X$EFBIG = 0x1B;
  905. X$ENOSPC = 0x1C;
  906. X$ESPIPE = 0x1D;
  907. X$EROFS = 0x1E;
  908. X$EMLINK = 0x1F;
  909. X$EPIPE = 0x20;
  910. X$EDOM = 0x21;
  911. X$ERANGE = 0x22;
  912. X$EWOULDBLOCK = 0x23;
  913. X$EINPROGRESS = 0x24;
  914. X$EALREADY = 0x25;
  915. X$ENOTSOCK = 0x26;
  916. X$EDESTADDRREQ = 0x27;
  917. X$EMSGSIZE = 0x28;
  918. X$EPROTOTYPE = 0x29;
  919. X$ENOPROTOOPT = 0x2A;
  920. X$EPROTONOSUPPORT = 0x2B;
  921. X$ESOCKTNOSUPPORT = 0x2C;
  922. X$EOPNOTSUPP = 0x2D;
  923. X$EPFNOSUPPORT = 0x2E;
  924. X$EAFNOSUPPORT = 0x2F;
  925. X$EADDRINUSE = 0x30;
  926. X$EADDRNOTAVAIL = 0x31;
  927. X$ENETDOWN = 0x32;
  928. X$ENETUNREACH = 0x33;
  929. X$ENETRESET = 0x34;
  930. X$ECONNABORTED = 0x35;
  931. X$ECONNRESET = 0x36;
  932. X$ENOBUFS = 0x37;
  933. X$EISCONN = 0x38;
  934. X$ENOTCONN = 0x39;
  935. X$ESHUTDOWN = 0x3A;
  936. X$ETOOMANYREFS = 0x3B;
  937. X$ETIMEDOUT = 0x3C;
  938. X$ECONNREFUSED = 0x3D;
  939. X$ELOOP = 0x3E;
  940. X$ENAMETOOLONG = 0x3F;
  941. X$EHOSTDOWN = 0x40;
  942. X$EHOSTUNREACH = 0x41;
  943. X$ENOTEMPTY = 0x42;
  944. X$EPROCLIM = 0x43;
  945. X$EUSERS = 0x44;
  946. X$EDQUOT = 0x45;
  947. X$ESTALE = 0x46;
  948. X$EREMOTE = 0x47;
  949. X$EDEADLK = 0x48;
  950. X$ENOLCK = 0x49;
  951. X$MTH_UNDEF_SQRT = 0x12C;
  952. X$MTH_OVF_EXP = 0x12D;
  953. X$MTH_UNDEF_LOG = 0x12E;
  954. X$MTH_NEG_BASE = 0x12F;
  955. X$MTH_ZERO_BASE = 0x130;
  956. X$MTH_OVF_POW = 0x131;
  957. X$MTH_LRG_SIN = 0x132;
  958. X$MTH_LRG_COS = 0x133;
  959. X$MTH_LRG_TAN = 0x134;
  960. X$MTH_LRG_COT = 0x135;
  961. X$MTH_OVF_TAN = 0x136;
  962. X$MTH_OVF_COT = 0x137;
  963. X$MTH_UNDEF_ASIN = 0x138;
  964. X$MTH_UNDEF_ACOS = 0x139;
  965. X$MTH_UNDEF_ATAN2 = 0x13A;
  966. X$MTH_OVF_SINH = 0x13B;
  967. X$MTH_OVF_COSH = 0x13C;
  968. X$MTH_UNDEF_ZLOG = 0x13D;
  969. X$MTH_UNDEF_ZDIV = 0x13E;
  970. !STUFFY!FUNK!
  971. echo Extracting t/op/substr.t
  972. sed >t/op/substr.t <<'!STUFFY!FUNK!' -e 's/X//'
  973. X#!./perl
  974. X
  975. X# $Header: substr.t,v 4.0 91/03/20 01:55:05 lwall Locked $
  976. X
  977. Xprint "1..22\n";
  978. X
  979. X$a = 'abcdefxyz';
  980. X
  981. Xprint (substr($a,0,3) eq 'abc' ? "ok 1\n" : "not ok 1\n");
  982. Xprint (substr($a,3,3) eq 'def' ? "ok 2\n" : "not ok 2\n");
  983. Xprint (substr($a,6,999) eq 'xyz' ? "ok 3\n" : "not ok 3\n");
  984. Xprint (substr($a,999,999) eq '' ? "ok 4\n" : "not ok 4\n");
  985. Xprint (substr($a,6,-1) eq '' ? "ok 5\n" : "not ok 5\n");
  986. Xprint (substr($a,-3,1) eq 'x' ? "ok 6\n" : "not ok 6\n");
  987. X
  988. X$[ = 1;
  989. X
  990. Xprint (substr($a,1,3) eq 'abc' ? "ok 7\n" : "not ok 7\n");
  991. Xprint (substr($a,4,3) eq 'def' ? "ok 8\n" : "not ok 8\n");
  992. Xprint (substr($a,7,999) eq 'xyz' ? "ok 9\n" : "not ok 9\n");
  993. Xprint (substr($a,999,999) eq '' ? "ok 10\n" : "not ok 10\n");
  994. Xprint (substr($a,7,-1) eq '' ? "ok 11\n" : "not ok 11\n");
  995. Xprint (substr($a,-3,1) eq 'x' ? "ok 12\n" : "not ok 12\n");
  996. X
  997. X$[ = 0;
  998. X
  999. Xsubstr($a,3,3) = 'XYZ';
  1000. Xprint $a eq 'abcXYZxyz' ? "ok 13\n" : "not ok 13\n";
  1001. Xsubstr($a,0,2) = '';
  1002. Xprint $a eq 'cXYZxyz' ? "ok 14\n" : "not ok 14\n";
  1003. Xy/a/a/;
  1004. Xsubstr($a,0,0) = 'ab';
  1005. Xprint $a eq 'abcXYZxyz' ? "ok 15\n" : "not ok 15 $a\n";
  1006. Xsubstr($a,0,0) = '12345678';
  1007. Xprint $a eq '12345678abcXYZxyz' ? "ok 16\n" : "not ok 16\n";
  1008. Xsubstr($a,-3,3) = 'def';
  1009. Xprint $a eq '12345678abcXYZdef' ? "ok 17\n" : "not ok 17\n";
  1010. Xsubstr($a,-3,3) = '<';
  1011. Xprint $a eq '12345678abcXYZ<' ? "ok 18\n" : "not ok 18\n";
  1012. Xsubstr($a,-1,1) = '12345678';
  1013. Xprint $a eq '12345678abcXYZ12345678' ? "ok 19\n" : "not ok 19\n";
  1014. X
  1015. X$a = 'abcdefxyz';
  1016. X
  1017. Xprint (substr($a,6) eq 'xyz' ? "ok 20\n" : "not ok 20\n");
  1018. Xprint (substr($a,-3) eq 'xyz' ? "ok 21\n" : "not ok 21\n");
  1019. Xprint (substr($a,999) eq '' ? "ok 22\n" : "not ok 22\n");
  1020. !STUFFY!FUNK!
  1021. echo Extracting t/op/index.t
  1022. sed >t/op/index.t <<'!STUFFY!FUNK!' -e 's/X//'
  1023. X#!./perl
  1024. X
  1025. X# $Header: index.t,v 4.0 91/03/20 01:53:05 lwall Locked $
  1026. X
  1027. Xprint "1..20\n";
  1028. X
  1029. X
  1030. X$foo = 'Now is the time for all good men to come to the aid of their country.';
  1031. X
  1032. X$first = substr($foo,0,index($foo,'the'));
  1033. Xprint ($first eq "Now is " ? "ok 1\n" : "not ok 1\n");
  1034. X
  1035. X$last = substr($foo,rindex($foo,'the'),100);
  1036. Xprint ($last eq "their country." ? "ok 2\n" : "not ok 2\n");
  1037. X
  1038. X$last = substr($foo,index($foo,'Now'),2);
  1039. Xprint ($last eq "No" ? "ok 3\n" : "not ok 3\n");
  1040. X
  1041. X$last = substr($foo,rindex($foo,'Now'),2);
  1042. Xprint ($last eq "No" ? "ok 4\n" : "not ok 4\n");
  1043. X
  1044. X$last = substr($foo,index($foo,'.'),100);
  1045. Xprint ($last eq "." ? "ok 5\n" : "not ok 5\n");
  1046. X
  1047. X$last = substr($foo,rindex($foo,'.'),100);
  1048. Xprint ($last eq "." ? "ok 6\n" : "not ok 6\n");
  1049. X
  1050. Xprint index("ababa","a",-1) == 0 ? "ok 7\n" : "not ok 7\n";
  1051. Xprint index("ababa","a",0) == 0 ? "ok 8\n" : "not ok 8\n";
  1052. Xprint index("ababa","a",1) == 2 ? "ok 9\n" : "not ok 9\n";
  1053. Xprint index("ababa","a",2) == 2 ? "ok 10\n" : "not ok 10\n";
  1054. Xprint index("ababa","a",3) == 4 ? "ok 11\n" : "not ok 11\n";
  1055. Xprint index("ababa","a",4) == 4 ? "ok 12\n" : "not ok 12\n";
  1056. Xprint index("ababa","a",5) == -1 ? "ok 13\n" : "not ok 13\n";
  1057. X
  1058. Xprint rindex("ababa","a",-1) == -1 ? "ok 14\n" : "not ok 14\n";
  1059. Xprint rindex("ababa","a",0) == 0 ? "ok 15\n" : "not ok 15\n";
  1060. Xprint rindex("ababa","a",1) == 0 ? "ok 16\n" : "not ok 16\n";
  1061. Xprint rindex("ababa","a",2) == 2 ? "ok 17\n" : "not ok 17\n";
  1062. Xprint rindex("ababa","a",3) == 2 ? "ok 18\n" : "not ok 18\n";
  1063. Xprint rindex("ababa","a",4) == 4 ? "ok 19\n" : "not ok 19\n";
  1064. Xprint rindex("ababa","a",5) == 4 ? "ok 20\n" : "not ok 20\n";
  1065. !STUFFY!FUNK!
  1066. echo Extracting hash.h
  1067. sed >hash.h <<'!STUFFY!FUNK!' -e 's/X//'
  1068. X/* $Header: hash.h,v 4.0 91/03/20 01:22:38 lwall Locked $
  1069. X *
  1070. X *    Copyright (c) 1989, Larry Wall
  1071. X *
  1072. X *    You may distribute under the terms of the GNU General Public License
  1073. X *    as specified in the README file that comes with the perl 3.0 kit.
  1074. X *
  1075. X * $Log:    hash.h,v $
  1076. X * Revision 4.0  91/03/20  01:22:38  lwall
  1077. X * 4.0 baseline.
  1078. X * 
  1079. X */
  1080. X
  1081. X#define FILLPCT 80        /* don't make greater than 99 */
  1082. X#define DBM_CACHE_MAX 63    /* cache 64 entries for dbm file */
  1083. X                /* (resident array acts as a write-thru cache)*/
  1084. X
  1085. X#define COEFFSIZE (16 * 8)    /* size of coeff array */
  1086. X
  1087. Xtypedef struct hentry HENT;
  1088. X
  1089. Xstruct hentry {
  1090. X    HENT    *hent_next;
  1091. X    char    *hent_key;
  1092. X    STR        *hent_val;
  1093. X    int        hent_hash;
  1094. X    int        hent_klen;
  1095. X};
  1096. X
  1097. Xstruct htbl {
  1098. X    HENT    **tbl_array;
  1099. X    int        tbl_max;    /* subscript of last element of tbl_array */
  1100. X    int        tbl_dosplit;    /* how full to get before splitting */
  1101. X    int        tbl_fill;    /* how full tbl_array currently is */
  1102. X    int        tbl_riter;    /* current root of iterator */
  1103. X    HENT    *tbl_eiter;    /* current entry of iterator */
  1104. X    SPAT     *tbl_spatroot;    /* list of spats for this package */
  1105. X    char    *tbl_name;    /* name, if a symbol table */
  1106. X#ifdef SOME_DBM
  1107. X#ifdef HAS_GDBM
  1108. X    GDBM_FILE    tbl_dbm;
  1109. X#else
  1110. X#ifdef HAS_NDBM
  1111. X    DBM        *tbl_dbm;
  1112. X#else
  1113. X    int        tbl_dbm;
  1114. X#endif
  1115. X#endif
  1116. X#endif
  1117. X    unsigned char tbl_coeffsize;    /* is 0 for symbol tables */
  1118. X};
  1119. X
  1120. XSTR *hfetch();
  1121. Xbool hstore();
  1122. XSTR *hdelete();
  1123. XHASH *hnew();
  1124. Xvoid hclear();
  1125. Xvoid hentfree();
  1126. Xint hiterinit();
  1127. XHENT *hiternext();
  1128. Xchar *hiterkey();
  1129. XSTR *hiterval();
  1130. Xbool hdbmopen();
  1131. Xvoid hdbmclose();
  1132. Xbool hdbmstore();
  1133. !STUFFY!FUNK!
  1134. echo Extracting t/op/repeat.t
  1135. sed >t/op/repeat.t <<'!STUFFY!FUNK!' -e 's/X//'
  1136. X#!./perl
  1137. X
  1138. X# $Header: repeat.t,v 4.0 91/03/20 01:54:26 lwall Locked $
  1139. X
  1140. Xprint "1..19\n";
  1141. X
  1142. X# compile time
  1143. X
  1144. Xif ('-' x 5 eq '-----') {print "ok 1\n";} else {print "not ok 1\n";}
  1145. Xif ('-' x 1 eq '-') {print "ok 2\n";} else {print "not ok 2\n";}
  1146. Xif ('-' x 0 eq '') {print "ok 3\n";} else {print "not ok 3\n";}
  1147. X
  1148. Xif ('ab' x 3 eq 'ababab') {print "ok 4\n";} else {print "not ok 4\n";}
  1149. X
  1150. X# run time
  1151. X
  1152. X$a = '-';
  1153. Xif ($a x 5 eq '-----') {print "ok 5\n";} else {print "not ok 5\n";}
  1154. Xif ($a x 1 eq '-') {print "ok 6\n";} else {print "not ok 6\n";}
  1155. Xif ($a x 0 eq '') {print "ok 7\n";} else {print "not ok 7\n";}
  1156. X
  1157. X$a = 'ab';
  1158. Xif ($a x 3 eq 'ababab') {print "ok 8\n";} else {print "not ok 8\n";}
  1159. X
  1160. X$a = 'xyz';
  1161. X$a x= 2;
  1162. Xif ($a eq 'xyzxyz') {print "ok 9\n";} else {print "not ok 9\n";}
  1163. X$a x= 1;
  1164. Xif ($a eq 'xyzxyz') {print "ok 10\n";} else {print "not ok 10\n";}
  1165. X$a x= 0;
  1166. Xif ($a eq '') {print "ok 11\n";} else {print "not ok 11\n";}
  1167. X
  1168. X@x = (1,2,3);
  1169. X
  1170. Xprint join('', @x x 4) eq '3333' ? "ok 12\n" : "not ok 12\n";
  1171. Xprint join('', (@x) x 4) eq '123123123123' ? "ok 13\n" : "not ok 13\n";
  1172. Xprint join('', (@x,()) x 4) eq '123123123123' ? "ok 14\n" : "not ok 14\n";
  1173. Xprint join('', (@x,1) x 4) eq '1231123112311231' ? "ok 15\n" : "not ok 15\n";
  1174. Xprint join(':', () x 4) eq '' ? "ok 16\n" : "not ok 16\n";
  1175. Xprint join(':', (9) x 4) eq '9:9:9:9' ? "ok 17\n" : "not ok 17\n";
  1176. Xprint join(':', (9,9) x 4) eq '9:9:9:9:9:9:9:9' ? "ok 18\n" : "not ok 18\n";
  1177. Xprint join('', (split(//,"123")) x 2) eq '123123' ? "ok 19\n" : "not ok 19\n";
  1178. !STUFFY!FUNK!
  1179. echo Extracting msdos/dir.h
  1180. sed >msdos/dir.h <<'!STUFFY!FUNK!' -e 's/X//'
  1181. X/* $Header: dir.h,v 4.0 91/03/20 01:34:20 lwall Locked $
  1182. X *
  1183. X *    (C) Copyright 1987, 1990 Diomidis Spinellis.
  1184. X *
  1185. X *    You may distribute under the terms of the GNU General Public License
  1186. X *    as specified in the README file that comes with the perl 3.0 kit.
  1187. X *
  1188. X * $Log:    dir.h,v $
  1189. X * Revision 4.0  91/03/20  01:34:20  lwall
  1190. X * 4.0 baseline.
  1191. X * 
  1192. X * Revision 3.0.1.1  90/03/27  16:07:08  lwall
  1193. X * patch16: MSDOS support
  1194. X * 
  1195. X * Revision 1.1  90/03/18  20:32:29  dds
  1196. X * Initial revision
  1197. X *
  1198. X *
  1199. X */
  1200. X
  1201. X/*
  1202. X * defines the type returned by the directory(3) functions
  1203. X */
  1204. X
  1205. X#ifndef __DIR_INCLUDED
  1206. X#define __DIR_INCLUDED
  1207. X
  1208. X/*Directory entry size */
  1209. X#ifdef DIRSIZ
  1210. X#undef DIRSIZ
  1211. X#endif
  1212. X#define DIRSIZ(rp)    (sizeof(struct direct))
  1213. X
  1214. X/*
  1215. X * Structure of a directory entry
  1216. X */
  1217. Xstruct direct    {
  1218. X    ino_t    d_ino;            /* inode number (not used by MS-DOS) */
  1219. X    int    d_namlen;        /* Name length */
  1220. X    char    d_name[13];        /* file name */
  1221. X};
  1222. X
  1223. Xstruct _dir_struc {            /* Structure used by dir operations */
  1224. X    char *start;            /* Starting position */
  1225. X    char *curr;            /* Current position */
  1226. X    struct direct dirstr;        /* Directory structure to return */
  1227. X};
  1228. X
  1229. Xtypedef struct _dir_struc DIR;        /* Type returned by dir operations */
  1230. X
  1231. XDIR *cdecl opendir(char *filename);
  1232. Xstruct direct *readdir(DIR *dirp);
  1233. Xlong telldir(DIR *dirp);
  1234. Xvoid seekdir(DIR *dirp,long loc);
  1235. Xvoid rewinddir(DIR *dirp);
  1236. Xvoid closedir(DIR *dirp);
  1237. X
  1238. X#endif /* __DIR_INCLUDED */
  1239. !STUFFY!FUNK!
  1240. echo Extracting spat.h
  1241. sed >spat.h <<'!STUFFY!FUNK!' -e 's/X//'
  1242. X/* $Header: spat.h,v 4.0 91/03/20 01:39:36 lwall Locked $
  1243. X *
  1244. X *    Copyright (c) 1989, Larry Wall
  1245. X *
  1246. X *    You may distribute under the terms of the GNU General Public License
  1247. X *    as specified in the README file that comes with the perl 3.0 kit.
  1248. X *
  1249. X * $Log:    spat.h,v $
  1250. X * Revision 4.0  91/03/20  01:39:36  lwall
  1251. X * 4.0 baseline.
  1252. X * 
  1253. X */
  1254. X
  1255. Xstruct scanpat {
  1256. X    SPAT    *spat_next;        /* list of all scanpats */
  1257. X    REGEXP    *spat_regexp;        /* compiled expression */
  1258. X    ARG        *spat_repl;        /* replacement string for subst */
  1259. X    ARG        *spat_runtime;        /* compile pattern at runtime */
  1260. X    STR        *spat_short;        /* for a fast bypass of execute() */
  1261. X    bool    spat_flags;
  1262. X    char    spat_slen;
  1263. X};
  1264. X
  1265. X#define SPAT_USED 1            /* spat has been used once already */
  1266. X#define SPAT_ONCE 2            /* use pattern only once per reset */
  1267. X#define SPAT_SCANFIRST 4        /* initial constant not anchored */
  1268. X#define SPAT_ALL 8            /* initial constant is whole pat */
  1269. X#define SPAT_SKIPWHITE 16        /* skip leading whitespace for split */
  1270. X#define SPAT_FOLD 32            /* case insensitivity */
  1271. X#define SPAT_CONST 64            /* subst replacement is constant */
  1272. X#define SPAT_KEEP 128            /* keep 1st runtime pattern forever */
  1273. X
  1274. XEXT SPAT *curspat;        /* what to do \ interps from */
  1275. XEXT SPAT *lastspat;        /* what to use in place of null pattern */
  1276. X
  1277. XEXT char *hint INIT(Nullch);    /* hint from cmd_exec to do_match et al */
  1278. X
  1279. X#define Nullspat Null(SPAT*)
  1280. !STUFFY!FUNK!
  1281. echo Extracting t/op/undef.t
  1282. sed >t/op/undef.t <<'!STUFFY!FUNK!' -e 's/X//'
  1283. X#!./perl
  1284. X
  1285. X# $Header: undef.t,v 4.0 91/03/20 01:55:16 lwall Locked $
  1286. X
  1287. Xprint "1..21\n";
  1288. X
  1289. Xprint defined($a) ? "not ok 1\n" : "ok 1\n";
  1290. X
  1291. X$a = 1+1;
  1292. Xprint defined($a) ? "ok 2\n" : "not ok 2\n";
  1293. X
  1294. Xundef $a;
  1295. Xprint defined($a) ? "not ok 3\n" : "ok 3\n";
  1296. X
  1297. X$a = "hi";
  1298. Xprint defined($a) ? "ok 4\n" : "not ok 4\n";
  1299. X
  1300. X$a = $b;
  1301. Xprint defined($a) ? "not ok 5\n" : "ok 5\n";
  1302. X
  1303. X@ary = ("1arg");
  1304. X$a = pop(@ary);
  1305. Xprint defined($a) ? "ok 6\n" : "not ok 6\n";
  1306. X$a = pop(@ary);
  1307. Xprint defined($a) ? "not ok 7\n" : "ok 7\n";
  1308. X
  1309. X@ary = ("1arg");
  1310. X$a = shift(@ary);
  1311. Xprint defined($a) ? "ok 8\n" : "not ok 8\n";
  1312. X$a = shift(@ary);
  1313. Xprint defined($a) ? "not ok 9\n" : "ok 9\n";
  1314. X
  1315. X$ary{'foo'} = 'hi';
  1316. Xprint defined($ary{'foo'}) ? "ok 10\n" : "not ok 10\n";
  1317. Xprint defined($ary{'bar'}) ? "not ok 11\n" : "ok 11\n";
  1318. Xundef $ary{'foo'};
  1319. Xprint defined($ary{'foo'}) ? "not ok 12\n" : "ok 12\n";
  1320. X
  1321. Xprint defined(@ary) ? "ok 13\n" : "not ok 13\n";
  1322. Xprint defined(%ary) ? "ok 14\n" : "not ok 14\n";
  1323. Xundef @ary;
  1324. Xprint defined(@ary) ? "not ok 15\n" : "ok 15\n";
  1325. Xundef %ary;
  1326. Xprint defined(%ary) ? "not ok 16\n" : "ok 16\n";
  1327. X@ary = (1);
  1328. Xprint defined @ary ? "ok 17\n" : "not ok 17\n";
  1329. X%ary = (1,1);
  1330. Xprint defined %ary ? "ok 18\n" : "not ok 18\n";
  1331. X
  1332. Xsub foo { print "ok 19\n"; }
  1333. X
  1334. X&foo || print "not ok 19\n";
  1335. X
  1336. Xprint defined &foo ? "ok 20\n" : "not ok 20\n";
  1337. Xundef &foo;
  1338. Xprint defined(&foo) ? "not ok 21\n" : "ok 21\n";
  1339. !STUFFY!FUNK!
  1340. echo Extracting eg/van/unvanish
  1341. sed >eg/van/unvanish <<'!STUFFY!FUNK!' -e 's/X//'
  1342. X#!/usr/bin/perl
  1343. X
  1344. X# $Header: unvanish,v 4.0 91/03/20 01:15:38 lwall Locked $
  1345. X
  1346. Xsub it {
  1347. X    if ($olddir ne '.') {
  1348. X    chop($pwd = `pwd`) if $pwd eq '';
  1349. X    (chdir $olddir) || die "Directory $olddir is not accesible";
  1350. X    }
  1351. X    unless ($olddir eq '.deleted') {
  1352. X    if (-d '.deleted') {
  1353. X        chdir '.deleted' || die "Directory .deleted is not accesible";
  1354. X    }
  1355. X    else {
  1356. X        chop($pwd = `pwd`) if $pwd eq '';
  1357. X        die "Directory .deleted does not exist" unless $pwd =~ /\.deleted$/;
  1358. X    }
  1359. X    }
  1360. X    print `mv $startfiles$filelist..$force`;
  1361. X    if ($olddir ne '.') {
  1362. X    (chdir $pwd) || die "Can't get back to original directory $pwd: $!\n";
  1363. X    }
  1364. X}
  1365. X
  1366. Xif ($#ARGV < 0) {
  1367. X    open(lastcmd,'.deleted/.lastcmd') || 
  1368. X    open(lastcmd,'.lastcmd') || 
  1369. X        die "No previous vanish in this dir";
  1370. X    $ARGV = <lastcmd>;
  1371. X    close(lastcmd);
  1372. X    @ARGV = split(/[\n ]+/,$ARGV);
  1373. X}
  1374. X
  1375. Xwhile ($ARGV[0] =~ /^-/) {
  1376. X    $_ = shift;
  1377. X    /^-f/ && ($force = ' >/dev/null 2>&1');
  1378. X    /^-i/ && ($interactive = 1);
  1379. X    if (/^-+$/) {
  1380. X    $startfiles = '- ';
  1381. X    last;
  1382. X    }
  1383. X}
  1384. X
  1385. Xwhile ($file = shift) {
  1386. X    if ($file =~ s|^(.*)/||) {
  1387. X    $dir = $1;
  1388. X    }
  1389. X    else {
  1390. X    $dir = '.';
  1391. X    }
  1392. X
  1393. X    if ($dir ne $olddir) {
  1394. X    do it() if $olddir;
  1395. X    $olddir = $dir;
  1396. X    }
  1397. X
  1398. X    if ($interactive) {
  1399. X    print "unvanish: restore $dir/$file? ";
  1400. X    next unless <stdin> =~ /^y/i;
  1401. X    }
  1402. X
  1403. X    $filelist .= $file; $filelist .= ' ';
  1404. X
  1405. X}
  1406. X
  1407. Xdo it() if $olddir;
  1408. !STUFFY!FUNK!
  1409. echo Extracting cflags.SH
  1410. sed >cflags.SH <<'!STUFFY!FUNK!' -e 's/X//'
  1411. Xcase $CONFIG in
  1412. X'')
  1413. X    if test ! -f config.sh; then
  1414. X    ln ../config.sh . || \
  1415. X    ln ../../config.sh . || \
  1416. X    ln ../../../config.sh . || \
  1417. X    (echo "Can't find config.sh."; exit 1)
  1418. X    fi 2>/dev/null
  1419. X    . ./config.sh
  1420. X    ;;
  1421. Xesac
  1422. Xcase "$0" in
  1423. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1424. Xesac
  1425. X
  1426. Xalso=': '
  1427. Xcase $# in
  1428. X1) also='echo 1>&2 "      CFLAGS = "'
  1429. Xesac
  1430. X
  1431. Xcase $# in
  1432. X0) set *.c; echo "The current C flags are:" ;;
  1433. X*) set `echo "$* " | sed 's/\.o /.c /g'`
  1434. Xesac
  1435. Xfor file do
  1436. X
  1437. X    case "$#" in
  1438. X    1) ;;
  1439. X    *) echo $n "    $file    $c" ;;
  1440. X    esac
  1441. X
  1442. X    case "$file" in
  1443. X    array.c) ;;
  1444. X    cmd.c) ;;
  1445. X    cons.c) ;;
  1446. X    consarg.c) ;;
  1447. X    doarg.c) ;;
  1448. X    doio.c) ;;
  1449. X    dolist.c) ;;
  1450. X    dump.c) ;;
  1451. X    eval.c) ;;
  1452. X    form.c) ;;
  1453. X    hash.c) ;;
  1454. X    malloc.c) ;;
  1455. X    perl.c) ;;
  1456. X    perly.c) ;;
  1457. X    regcomp.c) ;;
  1458. X    regexec.c) ;;
  1459. X    stab.c) ;;
  1460. X    str.c) ;;
  1461. X    toke.c) ;;
  1462. X    usersub.c) ;;
  1463. X    util.c) ;;
  1464. X    tarray.c) ;;
  1465. X    tcmd.c) ;;
  1466. X    tcons.c) ;;
  1467. X    tconsarg.c) ;;
  1468. X    tdoarg.c) ;;
  1469. X    tdoio.c) ;;
  1470. X    tdolist.c) ;;
  1471. X    tdump.c) ;;
  1472. X    teval.c) ;;
  1473. X    tform.c) ;;
  1474. X    thash.c) ;;
  1475. X    tmalloc.c) ;;
  1476. X    tperl.c) ;;
  1477. X    tperly.c) ;;
  1478. X    tregcomp.c) ;;
  1479. X    tregexec.c) ;;
  1480. X    tstab.c) ;;
  1481. X    tstr.c) ;;
  1482. X    ttoke.c) ;;
  1483. X    tusersub.c) ;;
  1484. X    tutil.c) ;;
  1485. X    *) ;;
  1486. X    esac
  1487. X
  1488. X    echo "$ccflags $optimize $large $split"
  1489. X    eval "$also $ccflags $optimize $large $split"
  1490. Xdone
  1491. !STUFFY!FUNK!
  1492. echo Extracting eg/van/vanish
  1493. sed >eg/van/vanish <<'!STUFFY!FUNK!' -e 's/X//'
  1494. X#!/usr/bin/perl
  1495. X
  1496. X# $Header: vanish,v 4.0 91/03/20 01:16:05 lwall Locked $
  1497. X
  1498. Xsub it {
  1499. X    if ($olddir ne '.') {
  1500. X    chop($pwd = `pwd`) if $pwd eq '';
  1501. X    (chdir $olddir) || die "Directory $olddir is not accesible";
  1502. X    }
  1503. X    if (!-d .deleted) {
  1504. X    print `mkdir .deleted; chmod 775 .deleted`;
  1505. X    die "You can't remove files from $olddir" if $?;
  1506. X    }
  1507. X    $filelist =~ s/ $//;
  1508. X    $filelist =~ s/#/\\#/g;
  1509. X    if ($filelist !~ /^[ \t]*$/) {
  1510. X    open(lastcmd,'>.deleted/.lastcmd');
  1511. X    print lastcmd $filelist,"\n";
  1512. X    close(lastcmd);
  1513. X    print `/bin/mv $startfiles$filelist .deleted$force`;
  1514. X    }
  1515. X    if ($olddir ne '.') {
  1516. X    (chdir $pwd) || die "Can't get back to original directory $pwd: $!\n";
  1517. X    }
  1518. X}
  1519. X
  1520. Xwhile ($ARGV[0] =~ /^-/) {
  1521. X    $_ = shift;
  1522. X    /^-f/ && ($force = ' >/dev/null 2>&1');
  1523. X    /^-i/ && ($interactive = 1);
  1524. X    if (/^-+$/) {
  1525. X    $startfiles = '- ';
  1526. X    last;
  1527. X    }
  1528. X}
  1529. X
  1530. Xchop($pwd = `pwd`);
  1531. X
  1532. Xwhile ($file = shift) {
  1533. X    if ($file =~ s|^(.*)/||) {
  1534. X    $dir = $1;
  1535. X    }
  1536. X    else {
  1537. X    $dir = '.';
  1538. X    }
  1539. X
  1540. X    if ($interactive) {
  1541. X    print "vanish: remove $dir/$file? ";
  1542. X    next unless <stdin> =~ /^y/i;
  1543. X    }
  1544. X
  1545. X    if ($file eq '.deleted') {
  1546. X    print stderr "To delete .deleted (the trashcan) use the 'empty' command.\n";
  1547. X    next;
  1548. X    }
  1549. X
  1550. X    if ($dir ne $olddir) {
  1551. X    do it() if $olddir;
  1552. X    $olddir = $dir;
  1553. X    }
  1554. X
  1555. X    $filelist .= $file; $filelist .= ' ';
  1556. X}
  1557. X
  1558. Xdo it() if $olddir;
  1559. !STUFFY!FUNK!
  1560. echo Extracting eg/scan/scan_df
  1561. sed >eg/scan/scan_df <<'!STUFFY!FUNK!' -e 's/X//'
  1562. X#!/usr/bin/perl -P
  1563. X
  1564. X# $Header: scan_df,v 4.0 91/03/20 01:12:28 lwall Locked $
  1565. X
  1566. X# This report points out filesystems that are in danger of overflowing.
  1567. X
  1568. X(chdir '/usr/adm/private/memories') || die "Can't cd to memories: $!\n";
  1569. X`df >newdf`;
  1570. Xopen(Df, 'olddf');
  1571. X
  1572. Xwhile (<Df>) {
  1573. X    ($fs,$kbytes,$used,$avail,$capacity,$mounted_on) = split;
  1574. X    next if $fs =~ /:/;
  1575. X    next if $fs eq '';
  1576. X    $oldused{$fs} = $used;
  1577. X}
  1578. X
  1579. Xopen(Df, 'newdf') || die "scan_df: can't open newdf";
  1580. X
  1581. Xwhile (<Df>) {
  1582. X    ($fs,$kbytes,$used,$avail,$capacity,$mounted_on) = split;
  1583. X    next if $fs =~ /:/;
  1584. X    next if $fs eq '';
  1585. X    $oldused = $oldused{$fs};
  1586. X    next if ($oldused == $used && $capacity < 99);    # inactive filesystem
  1587. X    if ($capacity >= 90) {
  1588. X#if defined(mc300) || defined(mc500) || defined(mc700)
  1589. X    $_ = substr($_,0,13) . '        ' . substr($_,13,1000);
  1590. X    $kbytes /= 2;        # translate blocks to K
  1591. X    $used /= 2;
  1592. X    $oldused /= 2;
  1593. X    $avail /= 2;
  1594. X#endif
  1595. X    $diff = int($used - $oldused);
  1596. X    if ($avail < $diff * 2) {    # mark specially if in danger
  1597. X        $mounted_on .= ' *';
  1598. X    }
  1599. X    next if $diff < 50 && $mounted_on eq '/';
  1600. X    $fs =~ s|/dev/||;
  1601. X    if ($diff >= 0) {
  1602. X        $diff = '(+' . $diff . ')';
  1603. X    }
  1604. X    else {
  1605. X        $diff = '(' . $diff . ')';
  1606. X    }
  1607. X    printf "%-8s%8d%8d %-8s%8d%7s    %s\n",
  1608. X        $fs,$kbytes,$used,$diff,$avail,$capacity,$mounted_on;
  1609. X    }
  1610. X}
  1611. X
  1612. Xrename('newdf','olddf');
  1613. !STUFFY!FUNK!
  1614. echo Extracting usub/man2mus
  1615. sed >usub/man2mus <<'!STUFFY!FUNK!' -e 's/X//'
  1616. X#!/usr/bin/perl
  1617. Xwhile (<>) {
  1618. X    if (/^\.SH SYNOPSIS/) {
  1619. X    $spec = '';
  1620. X    for ($_ = <>; $_ && !/^\.SH/; $_ = <>) {
  1621. X        s/^\.[IRB][IRB]\s*//;
  1622. X        s/^\.[IRB]\s+//;
  1623. X        next if /^\./;
  1624. X        s/\\f\w//g;
  1625. X        s/\\&//g;
  1626. X        s/^\s+//;
  1627. X        next if /^$/;
  1628. X        next if /^#/;
  1629. X        $spec .= $_;
  1630. X    }
  1631. X    $_ = $spec;
  1632. X    0 while s/\(([^),;]*)\s*,\s*([^);]*)\)/($1|$2)/g;
  1633. X    s/\(\*([^,;]*)\)\(\)/(*)()$1/g;
  1634. X    s/(\w+)\[\]/*$1/g;
  1635. X
  1636. X    s/\n/ /g;
  1637. X    s/\s+/ /g;
  1638. X    s/(\w+) \(([^*])/$1($2/g;
  1639. X    s/^ //;
  1640. X    s/ ?; ?/\n/g;
  1641. X    s/\) /)\n/g;
  1642. X    s/ \* / \*/g;
  1643. X    s/\* / \*/g;
  1644. X
  1645. X    $* = 1;
  1646. X    0 while s/^((struct )?\w+ )([^\n,]*), ?(.*)/$1$3\n$1$4/g;
  1647. X    $* = 0;
  1648. X    s/\|/,/g;
  1649. X
  1650. X    @cases = ();
  1651. X    for (reverse split(/\n/,$_)) {
  1652. X        if (/\)$/) {
  1653. X        ($type,$name,$args) = split(/(\w+)\(/);
  1654. X        $type =~ s/ $//;
  1655. X        if ($type =~ /^(\w+) =/) {
  1656. X            $type = $type{$1} if $type{$1};
  1657. X        }
  1658. X        $type = 'int' if $type eq '';
  1659. X        @args = grep(/./, split(/[,)]/,$args));
  1660. X        $case = "CASE $type $name\n";
  1661. X        foreach $arg (@args) {
  1662. X            $type = $type{$arg} || "int";
  1663. X            $type =~ s/ //g;
  1664. X            $type .= "\t" if length($type) < 8;
  1665. X            if ($type =~ /\*/) {
  1666. X            $case .= "IO    $type    $arg\n";
  1667. X            }
  1668. X            else {
  1669. X            $case .= "I    $type    $arg\n";
  1670. X            }
  1671. X        }
  1672. X        $case .= "END\n\n";
  1673. X        unshift(@cases, $case);
  1674. X        }
  1675. X        else {
  1676. X        $type{$name} = $type if ($type,$name) = /(.*\W)(\w+)$/;
  1677. X        }
  1678. X    }
  1679. X    print @cases;
  1680. X    }
  1681. X}
  1682. !STUFFY!FUNK!
  1683. echo Extracting makedir.SH
  1684. sed >makedir.SH <<'!STUFFY!FUNK!' -e 's/X//'
  1685. Xcase $CONFIG in
  1686. X'')
  1687. X    if test ! -f config.sh; then
  1688. X    ln ../config.sh . || \
  1689. X    ln ../../config.sh . || \
  1690. X    ln ../../../config.sh . || \
  1691. X    (echo "Can't find config.sh."; exit 1)
  1692. X    fi 2>/dev/null
  1693. X    . ./config.sh
  1694. X    ;;
  1695. Xesac
  1696. Xcase "$0" in
  1697. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1698. Xesac
  1699. Xecho "Extracting makedir (with variable substitutions)"
  1700. X$spitshell >makedir <<!GROK!THIS!
  1701. X$startsh
  1702. X# $Header: makedir.SH,v 4.0 91/03/20 01:27:13 lwall Locked $
  1703. X# 
  1704. X# $Log:    makedir.SH,v $
  1705. X# Revision 4.0  91/03/20  01:27:13  lwall
  1706. X# 4.0 baseline.
  1707. X# 
  1708. X# 
  1709. X
  1710. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1711. X
  1712. Xcase \$# in
  1713. X  0)
  1714. X    $echo "makedir pathname filenameflag"
  1715. X    exit 1
  1716. X    ;;
  1717. Xesac
  1718. X
  1719. X: guarantee one slash before 1st component
  1720. Xcase \$1 in
  1721. X  /*) ;;
  1722. X  *)  set ./\$1 \$2 ;;
  1723. Xesac
  1724. X
  1725. X: strip last component if it is to be a filename
  1726. Xcase X\$2 in
  1727. X  X1) set \`$echo \$1 | $sed 's:\(.*\)/[^/]*\$:\1:'\` ;;
  1728. X  *)  set \$1 ;;
  1729. Xesac
  1730. X
  1731. X: return reasonable status if nothing to be created
  1732. Xif $test -d "\$1" ; then
  1733. X    exit 0
  1734. Xfi
  1735. X
  1736. Xlist=''
  1737. Xwhile true ; do
  1738. X    case \$1 in
  1739. X    */*)
  1740. X    list="\$1 \$list"
  1741. X    set \`echo \$1 | $sed 's:\(.*\)/:\1 :'\`
  1742. X    ;;
  1743. X    *)
  1744. X    break
  1745. X    ;;
  1746. X    esac
  1747. Xdone
  1748. X
  1749. Xset \$list
  1750. X
  1751. Xfor dir do
  1752. X    $mkdir \$dir >/dev/null 2>&1
  1753. Xdone
  1754. X!GROK!THIS!
  1755. X$eunicefix makedir
  1756. Xchmod +x makedir
  1757. !STUFFY!FUNK!
  1758. echo Extracting eg/scan/scan_last
  1759. sed >eg/scan/scan_last <<'!STUFFY!FUNK!' -e 's/X//'
  1760. X#!/usr/bin/perl -P
  1761. X
  1762. X# $Header: scan_last,v 4.0 91/03/20 01:12:45 lwall Locked $
  1763. X
  1764. X# This reports who was logged on at weird hours
  1765. X
  1766. X($dy, $mo, $lastdt) = split(/ +/,`date`);
  1767. X
  1768. Xopen(Last, 'exec last 2>&1 |') || die "scan_last: can't run last";
  1769. X
  1770. Xwhile (<Last>) {
  1771. X#if defined(mc300) || defined(mc500) || defined(mc700)
  1772. X    $_ = substr($_,0,19) . substr($_,23,100);
  1773. X#endif
  1774. X    next if /^$/;
  1775. X    (print),next if m|^/|;
  1776. X    $login  = substr($_,0,8);
  1777. X    $tty    = substr($_,10,7);
  1778. X    $from   = substr($_,19,15);
  1779. X    $day    = substr($_,36,3);
  1780. X    $mo     = substr($_,40,3);
  1781. X    $dt     = substr($_,44,2);
  1782. X    $hr     = substr($_,47,2);
  1783. X    $min    = substr($_,50,2);
  1784. X    $dash   = substr($_,53,1);
  1785. X    $tohr   = substr($_,55,2);
  1786. X    $tomin  = substr($_,58,2);
  1787. X    $durhr  = substr($_,63,2);
  1788. X    $durmin = substr($_,66,2);
  1789. X    
  1790. X    next unless $hr;
  1791. X    next if $login eq 'reboot  ';
  1792. X    next if $login eq 'shutdown';
  1793. X
  1794. X    if ($dt != $lastdt) {
  1795. X    if ($lastdt < $dt) {
  1796. X        $seen += $dt - $lastdt;
  1797. X    }
  1798. X    else {
  1799. X        $seen++;
  1800. X    }
  1801. X    $lastdt = $dt;
  1802. X    }
  1803. X
  1804. X    $inat = $hr + $min / 60;
  1805. X    if ($tohr =~ /^[a-z]/) {
  1806. X    $outat = 12;        # something innocuous
  1807. X    } else {
  1808. X    $outat = $tohr + $tomin / 60;
  1809. X    }
  1810. X
  1811. X  last if $seen + ($inat < 8) > 1;
  1812. X
  1813. X    if ($inat < 5 || $inat > 21 || $outat < 6 || $outat > 23) {
  1814. X    print;
  1815. X    }
  1816. X}
  1817. !STUFFY!FUNK!
  1818. echo Extracting x2p/hash.h
  1819. sed >x2p/hash.h <<'!STUFFY!FUNK!' -e 's/X//'
  1820. X/* $Header: hash.h,v 4.0 91/03/20 01:57:53 lwall Locked $
  1821. X *
  1822. X *    Copyright (c) 1989, Larry Wall
  1823. X *
  1824. X *    You may distribute under the terms of the GNU General Public License
  1825. X *    as specified in the README file that comes with the perl 3.0 kit.
  1826. X *
  1827. X * $Log:    hash.h,v $
  1828. X * Revision 4.0  91/03/20  01:57:53  lwall
  1829. X * 4.0 baseline.
  1830. X * 
  1831. X */
  1832. X
  1833. X#define FILLPCT 60        /* don't make greater than 99 */
  1834. X
  1835. X#ifdef DOINIT
  1836. Xchar coeff[] = {
  1837. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
  1838. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
  1839. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
  1840. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
  1841. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
  1842. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
  1843. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
  1844. X        61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1};
  1845. X#else
  1846. Xextern char coeff[];
  1847. X#endif
  1848. X
  1849. Xtypedef struct hentry HENT;
  1850. X
  1851. Xstruct hentry {
  1852. X    HENT    *hent_next;
  1853. X    char    *hent_key;
  1854. X    STR        *hent_val;
  1855. X    int        hent_hash;
  1856. X};
  1857. X
  1858. Xstruct htbl {
  1859. X    HENT    **tbl_array;
  1860. X    int        tbl_max;
  1861. X    int        tbl_fill;
  1862. X    int        tbl_riter;    /* current root of iterator */
  1863. X    HENT    *tbl_eiter;    /* current entry of iterator */
  1864. X};
  1865. X
  1866. XSTR *hfetch();
  1867. Xbool hstore();
  1868. Xbool hdelete();
  1869. XHASH *hnew();
  1870. Xint hiterinit();
  1871. XHENT *hiternext();
  1872. Xchar *hiterkey();
  1873. XSTR *hiterval();
  1874. !STUFFY!FUNK!
  1875. echo Extracting t/comp/term.t
  1876. sed >t/comp/term.t <<'!STUFFY!FUNK!' -e 's/X//'
  1877. X#!./perl
  1878. X
  1879. X# $Header: term.t,v 4.0 91/03/20 01:50:36 lwall Locked $
  1880. X
  1881. X# tests that aren't important enough for base.term
  1882. X
  1883. Xprint "1..14\n";
  1884. X
  1885. X$x = "\\n";
  1886. Xprint "#1\t:$x: eq " . ':\n:' . "\n";
  1887. Xif ($x eq '\n') {print "ok 1\n";} else {print "not ok 1\n";}
  1888. X
  1889. X$x = "#2\t:$x: eq :\\n:\n";
  1890. Xprint $x;
  1891. Xunless (index($x,'\\\\')>0) {print "ok 2\n";} else {print "not ok 2\n";}
  1892. X
  1893. Xif (length('\\\\') == 2) {print "ok 3\n";} else {print "not ok 3\n";}
  1894. X
  1895. X$one = 'a';
  1896. X
  1897. Xif (length("\\n") == 2) {print "ok 4\n";} else {print "not ok 4\n";}
  1898. Xif (length("\\\n") == 2) {print "ok 5\n";} else {print "not ok 5\n";}
  1899. Xif (length("$one\\n") == 3) {print "ok 6\n";} else {print "not ok 6\n";}
  1900. Xif (length("$one\\\n") == 3) {print "ok 7\n";} else {print "not ok 7\n";}
  1901. Xif (length("\\n$one") == 3) {print "ok 8\n";} else {print "not ok 8\n";}
  1902. Xif (length("\\\n$one") == 3) {print "ok 9\n";} else {print "not ok 9\n";}
  1903. Xif (length("\\${one}") == 2) {print "ok 10\n";} else {print "not ok 10\n";}
  1904. X
  1905. Xif ("${one}b" eq "ab") { print "ok 11\n";} else {print "not ok 11\n";}
  1906. X
  1907. X@foo = (1,2,3);
  1908. Xif ("$foo[1]b" eq "2b") { print "ok 12\n";} else {print "not ok 12\n";}
  1909. Xif ("@foo[0..1]b" eq "1 2b") { print "ok 13\n";} else {print "not ok 13\n";}
  1910. X$" = '::';
  1911. Xif ("@foo[0..1]b" eq "1::2b") { print "ok 14\n";} else {print "not ok 14\n";}
  1912. !STUFFY!FUNK!
  1913. echo Extracting os2/glob.c
  1914. sed >os2/glob.c <<'!STUFFY!FUNK!' -e 's/X//'
  1915. X/*
  1916. X * Globbing for OS/2.  Relies on the expansion done by the library
  1917. X * startup code. (dds)
  1918. X */
  1919. X
  1920. X#include <stdio.h>
  1921. X#include <string.h>
  1922. X
  1923. Xmain(int argc, char *argv[])
  1924. X{
  1925. X  register i;
  1926. X
  1927. X  for (i = 1; i < argc; i++)
  1928. X  {
  1929. X    fputs(IsFileSystemFAT(argv[i]) ? strlwr(argv[i]) : argv[i], stdout);
  1930. X    putchar(0);
  1931. X  }
  1932. X}
  1933. !STUFFY!FUNK!
  1934. echo " "
  1935. echo "End of kit 34 (of 36)"
  1936. cat /dev/null >kit34isdone
  1937. run=''
  1938. config=''
  1939. 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 25 26 27 28 29 30 31 32 33 34 35 36; do
  1940.     if test -f kit${iskit}isdone; then
  1941.     run="$run $iskit"
  1942.     else
  1943.     todo="$todo $iskit"
  1944.     fi
  1945. done
  1946. case $todo in
  1947.     '')
  1948.     echo "You have run all your kits.  Please read README and then type Configure."
  1949.     for combo in *:AA; do
  1950.         if test -f "$combo"; then
  1951.         realfile=`basename $combo :AA`
  1952.         cat $realfile:[A-Z][A-Z] >$realfile
  1953.         rm -rf $realfile:[A-Z][A-Z]
  1954.         fi
  1955.     done
  1956.     rm -rf kit*isdone
  1957.     chmod 755 Configure
  1958.     ;;
  1959.     *)  echo "You have run$run."
  1960.     echo "You still need to run$todo."
  1961.     ;;
  1962. esac
  1963. : Someone might mail this, so...
  1964. exit
  1965.  
  1966. exit 0 # Just in case...
  1967. -- 
  1968. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1969. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1970. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1971. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1972.