home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume25 / perl / patch15 < prev    next >
Encoding:
Text File  |  1991-11-13  |  46.9 KB  |  1,763 lines

  1. Newsgroups: comp.sources.misc
  2. From: lwall@netlabs.com (Larry Wall)
  3. Subject:  v25i064:  perl - The perl programming language, Patch15
  4. Message-ID: <1991Nov13.214427.3782@sparky.imd.sterling.com>
  5. X-Md4-Signature: efbe162c35757d3f3864564e8f96ee1c
  6. Date: Wed, 13 Nov 1991 21:44:27 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: lwall@netlabs.com (Larry Wall)
  10. Posting-number: Volume 25, Issue 64
  11. Archive-name: perl/patch15
  12. Environment: UNIX, MS-DOS, OS2
  13. Patch-To: perl: Volume 18, Issue 19-54
  14.  
  15. System: perl version 4.0
  16. Patch #: 15
  17. Priority: MED-HIGH
  18. Subject: patch #11, continued
  19.  
  20. Description:
  21.     See patch #11.
  22.  
  23. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your perl source
  24.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  25.     If you don't have the patch program, apply the following by hand,
  26.     or get patch (version 2.0, latest patchlevel).
  27.  
  28.     After patching:
  29.         *** DO NOTHING--INSTALL ALL PATCHES UP THROUGH #18 FIRST ***
  30.  
  31.     If patch indicates that patchlevel is the wrong version, you may need
  32.     to apply one or more previous patches, or the patch may already
  33.     have been applied.  See the patchlevel.h file to find out what has or
  34.     has not been applied.  In any event, don't continue with the patch.
  35.  
  36.     If you are missing previous patches they can be obtained from me:
  37.  
  38.     Larry Wall
  39.     lwall@netlabs.com
  40.  
  41.     If you send a mail message of the following form it will greatly speed
  42.     processing:
  43.  
  44.     Subject: Command
  45.     @SH mailpatch PATH perl 4.0 LIST
  46.            ^ note the c
  47.  
  48.     where PATH is a return path FROM ME TO YOU either in Internet notation,
  49.     or in bang notation from some well-known host, and LIST is the number
  50.     of one or more patches you need, separated by spaces, commas, and/or
  51.     hyphens.  Saying 35- says everything from 35 to the end.
  52.  
  53.  
  54. Index: patchlevel.h
  55. Prereq: 14
  56. 1c1
  57. < #define PATCHLEVEL 14
  58. ---
  59. > #define PATCHLEVEL 15
  60.  
  61. Index: hash.c
  62. *** hash.c.old    Tue Nov  5 19:26:22 1991
  63. --- hash.c    Tue Nov  5 19:26:23 1991
  64. ***************
  65. *** 1,4 ****
  66. ! /* $RCSfile: hash.c,v $$Revision: 4.0.1.1 $$Date: 91/06/07 11:10:11 $
  67.    *
  68.    *    Copyright (c) 1991, Larry Wall
  69.    *
  70. --- 1,4 ----
  71. ! /* $RCSfile: hash.c,v $$Revision: 4.0.1.2 $$Date: 91/11/05 17:24:13 $
  72.    *
  73.    *    Copyright (c) 1991, Larry Wall
  74.    *
  75. ***************
  76. *** 6,11 ****
  77. --- 6,14 ----
  78.    *    License or the Artistic License, as specified in the README file.
  79.    *
  80.    * $Log:    hash.c,v $
  81. +  * Revision 4.0.1.2  91/11/05  17:24:13  lwall
  82. +  * patch11: saberized perl
  83. +  * 
  84.    * Revision 4.0.1.1  91/06/07  11:10:11  lwall
  85.    * patch4: new copyright notice
  86.    * 
  87. ***************
  88. *** 70,76 ****
  89.       else
  90.           maxi = tb->tbl_coeffsize;
  91.       for (s=key,        i=0,    hash = 0;
  92. !                 i < maxi;
  93.            s++,        i++,    hash *= 5) {
  94.           hash += *s * coeff[i];
  95.       }
  96. --- 73,79 ----
  97.       else
  98.           maxi = tb->tbl_coeffsize;
  99.       for (s=key,        i=0,    hash = 0;
  100. !                 i < maxi;            /*SUPPRESS 8*/
  101.            s++,        i++,    hash *= 5) {
  102.           hash += *s * coeff[i];
  103.       }
  104. ***************
  105. *** 129,134 ****
  106. --- 132,138 ----
  107.       return FALSE;
  108.   
  109.       if (hash)
  110. +     /*SUPPRESS 530*/
  111.       ;
  112.       else if (!tb->tbl_coeffsize)
  113.       hash = *key + 128 * key[1] + 128 * key[klen-1];
  114. ***************
  115. *** 138,144 ****
  116.       else
  117.           maxi = tb->tbl_coeffsize;
  118.       for (s=key,        i=0,    hash = 0;
  119. !                 i < maxi;
  120.            s++,        i++,    hash *= 5) {
  121.           hash += *s * coeff[i];
  122.       }
  123. --- 142,148 ----
  124.       else
  125.           maxi = tb->tbl_coeffsize;
  126.       for (s=key,        i=0,    hash = 0;
  127. !                 i < maxi;            /*SUPPRESS 8*/
  128.            s++,        i++,    hash *= 5) {
  129.           hash += *s * coeff[i];
  130.       }
  131. ***************
  132. *** 226,232 ****
  133.       else
  134.           maxi = tb->tbl_coeffsize;
  135.       for (s=key,        i=0,    hash = 0;
  136. !                 i < maxi;
  137.            s++,        i++,    hash *= 5) {
  138.           hash += *s * coeff[i];
  139.       }
  140. --- 230,236 ----
  141.       else
  142.           maxi = tb->tbl_coeffsize;
  143.       for (s=key,        i=0,    hash = 0;
  144. !                 i < maxi;            /*SUPPRESS 8*/
  145.            s++,        i++,    hash *= 5) {
  146.           hash += *s * coeff[i];
  147.       }
  148. ***************
  149. *** 425,430 ****
  150. --- 429,435 ----
  151.       tb->tbl_dbm = 0;            /* now clear just cache */
  152.   #endif
  153.       (void)hiterinit(tb);
  154. +     /*SUPPRESS 560*/
  155.       while (hent = hiternext(tb)) {    /* concise but not very efficient */
  156.       hentfree(ohent);
  157.       ohent = hent;
  158.  
  159. Index: hash.h
  160. *** hash.h.old    Tue Nov  5 19:26:24 1991
  161. --- hash.h    Tue Nov  5 19:26:25 1991
  162. ***************
  163. *** 1,4 ****
  164. ! /* $RCSfile: hash.h,v $$Revision: 4.0.1.1 $$Date: 91/06/07 11:10:33 $
  165.    *
  166.    *    Copyright (c) 1991, Larry Wall
  167.    *
  168. --- 1,4 ----
  169. ! /* $RCSfile: hash.h,v $$Revision: 4.0.1.2 $$Date: 91/11/05 17:24:31 $
  170.    *
  171.    *    Copyright (c) 1991, Larry Wall
  172.    *
  173. ***************
  174. *** 6,11 ****
  175. --- 6,14 ----
  176.    *    License or the Artistic License, as specified in the README file.
  177.    *
  178.    * $Log:    hash.h,v $
  179. +  * Revision 4.0.1.2  91/11/05  17:24:31  lwall
  180. +  * patch11: random cleanup
  181. +  * 
  182.    * Revision 4.0.1.1  91/06/07  11:10:33  lwall
  183.    * patch4: new copyright notice
  184.    * 
  185. ***************
  186. *** 59,64 ****
  187. --- 62,68 ----
  188.   HASH *hnew();
  189.   void hclear();
  190.   void hentfree();
  191. + void hfree();
  192.   int hiterinit();
  193.   HENT *hiternext();
  194.   char *hiterkey();
  195.  
  196. Index: hints/hp9000_800.sh
  197. *** hints/hp9000_800.sh.old    Tue Nov  5 19:26:32 1991
  198. --- hints/hp9000_800.sh    Tue Nov  5 19:26:32 1991
  199. ***************
  200. *** 0 ****
  201. --- 1 ----
  202. + libswanted=`echo $libswanted | sed 's/malloc //'`
  203.  
  204. Index: installperl
  205. *** installperl.old    Tue Nov  5 19:26:46 1991
  206. --- installperl    Tue Nov  5 19:26:46 1991
  207. ***************
  208. *** 6,12 ****
  209.       shift;
  210.   }
  211.   
  212. ! @scripts = ('h2ph', 'x2p/s2p', 'x2p/find2perl');
  213.   @manpages = ('perl.man', 'h2ph.man', 'x2p/a2p.man', 'x2p/s2p.man');
  214.   
  215.   $version = sprintf("%5.3f", $]);
  216. --- 6,14 ----
  217.       shift;
  218.   }
  219.   
  220. ! umask 022;
  221. ! @scripts = ('cppstdin', 'h2ph', 'c2ph', 'pstruct', 'x2p/s2p', 'x2p/find2perl');
  222.   @manpages = ('perl.man', 'h2ph.man', 'x2p/a2p.man', 'x2p/s2p.man');
  223.   
  224.   $version = sprintf("%5.3f", $]);
  225. ***************
  226. *** 85,91 ****
  227.   ($udev,$uino) = stat("/usr/bin");
  228.   
  229.   if (-w _ && ($udev != $ddev || $uino != $dino) && !$nonono) {
  230. !     unlink "/usr/bin/perl";
  231.       eval 'symlink("$installbin/perl", "/usr/bin/perl")' ||
  232.       eval 'link("$installbin/perl", "/usr/bin/perl")' ||
  233.       &cmd("cp $installbin/perl /usr/bin");
  234. --- 87,93 ----
  235.   ($udev,$uino) = stat("/usr/bin");
  236.   
  237.   if (-w _ && ($udev != $ddev || $uino != $dino) && !$nonono) {
  238. !     &unlink("/usr/bin/perl");
  239.       eval 'symlink("$installbin/perl", "/usr/bin/perl")' ||
  240.       eval 'link("$installbin/perl", "/usr/bin/perl")' ||
  241.       &cmd("cp $installbin/perl /usr/bin");
  242. ***************
  243. *** 100,115 ****
  244.       s#.*/##; &chmod(0755, "$installscr/$_");
  245.   }
  246.   
  247. - # Install library files.
  248. - &makedir($installprivlib);
  249. - ($pdev,$pino) = stat($installprivlib);
  250. - if ($pdev != $ddev || $pino != $dino) {
  251. -     &cmd("cd lib && cp *.pl $installprivlib");
  252. - }
  253.   # Install man pages.
  254.   
  255.   if ($mansrc ne '') {
  256. --- 102,107 ----
  257. ***************
  258. *** 133,138 ****
  259. --- 125,152 ----
  260.       }
  261.       }
  262.   }
  263. + # Install library files.
  264. + &makedir($installprivlib);
  265. + if (chdir "lib") {
  266. +     ($pdev,$pino) = stat($installprivlib);
  267. +     ($ldev,$lino) = stat('.');
  268. +     if ($pdev != $ldev || $pino != $lino) {
  269. +     foreach $file (<*.pl>) {
  270. +         &unlink("$installprivlib/$file");
  271. +         &cmd("cp $file $installprivlib");
  272. +     }
  273. +     }
  274. +     chdir ".." || die "Can't cd back to source directory: $!\n";
  275. + }
  276. + else {
  277. +     warn "Can't cd to lib to install lib files: $!\n";
  278. + }
  279. + &chmod(0755, "usub/mus");
  280.   
  281.   print STDERR "  Installation complete\n";
  282.   
  283.  
  284. Index: malloc.c
  285. *** malloc.c.old    Tue Nov  5 19:27:12 1991
  286. --- malloc.c    Tue Nov  5 19:27:12 1991
  287. ***************
  288. *** 1,6 ****
  289. ! /* $RCSfile: malloc.c,v $$Revision: 4.0.1.2 $$Date: 91/06/07 11:20:45 $
  290.    *
  291.    * $Log:    malloc.c,v $
  292.    * Revision 4.0.1.2  91/06/07  11:20:45  lwall
  293.    * patch4: many, many itty-bitty portability fixes
  294.    * 
  295. --- 1,9 ----
  296. ! /* $RCSfile: malloc.c,v $$Revision: 4.0.1.3 $$Date: 91/11/05 17:57:40 $
  297.    *
  298.    * $Log:    malloc.c,v $
  299. +  * Revision 4.0.1.3  91/11/05  17:57:40  lwall
  300. +  * patch11: safe malloc code now integrated into Perl's malloc when possible
  301. +  * 
  302.    * Revision 4.0.1.2  91/06/07  11:20:45  lwall
  303.    * patch4: many, many itty-bitty portability fixes
  304.    * 
  305. ***************
  306. *** 13,18 ****
  307. --- 16,22 ----
  308.    */
  309.   
  310.   #ifndef lint
  311. + /*SUPPRESS 592*/
  312.   static char sccsid[] = "@(#)malloc.c    4.3 (Berkeley) 9/16/83";
  313.   
  314.   #ifdef DEBUGGING
  315. ***************
  316. *** 110,115 ****
  317. --- 114,123 ----
  318.   #define    ASSERT(p)
  319.   #endif
  320.   
  321. + #ifdef safemalloc
  322. + static int an = 0;
  323. + #endif
  324.   MALLOCPTRTYPE *
  325.   malloc(nbytes)
  326.       register unsigned nbytes;
  327. ***************
  328. *** 118,123 ****
  329. --- 126,148 ----
  330.         register int bucket = 0;
  331.         register unsigned shiftr;
  332.   
  333. + #ifdef safemalloc
  334. + #ifdef DEBUGGING
  335. +     int size = nbytes;
  336. + #endif
  337. + #ifdef MSDOS
  338. +     if (nbytes > 0xffff) {
  339. +         fprintf(stderr, "Allocation too large: %lx\n", nbytes);
  340. +         exit(1);
  341. +     }
  342. + #endif /* MSDOS */
  343. + #ifdef DEBUGGING
  344. +     if ((long)nbytes < 0)
  345. +         fatal("panic: malloc");
  346. + #endif
  347. + #endif /* safemalloc */
  348.       /*
  349.        * Convert amount of memory requested into
  350.        * closest block size stored in hash buckets
  351. ***************
  352. *** 136,143 ****
  353.        */
  354.         if (nextf[bucket] == NULL)    
  355.             morecore(bucket);
  356. !       if ((p = (union overhead *)nextf[bucket]) == NULL)
  357.             return (NULL);
  358.       /* remove from linked list */
  359.   #ifdef RCHECK
  360.       if (*((int*)p) & (sizeof(union overhead) - 1))
  361. --- 161,187 ----
  362.        */
  363.         if (nextf[bucket] == NULL)    
  364.             morecore(bucket);
  365. !       if ((p = (union overhead *)nextf[bucket]) == NULL) {
  366. ! #ifdef safemalloc
  367. !         fputs("Out of memory!\n", stderr);
  368. !         exit(1);
  369. ! #else
  370.             return (NULL);
  371. + #endif
  372. +     }
  373. + #ifdef safemalloc
  374. + #ifdef DEBUGGING
  375. + #  ifndef I286
  376. +     if (debug & 128)
  377. +         fprintf(stderr,"0x%x: (%05d) malloc %d bytes\n",p+1,an++,size);
  378. + #  else
  379. +     if (debug & 128)
  380. +         fprintf(stderr,"0x%lx: (%05d) malloc %d bytes\n",p+1,an++,size);
  381. + #  endif
  382. + #endif
  383. + #endif /* safemalloc */
  384.       /* remove from linked list */
  385.   #ifdef RCHECK
  386.       if (*((int*)p) & (sizeof(union overhead) - 1))
  387. ***************
  388. *** 240,245 ****
  389. --- 284,301 ----
  390.       register union overhead *op;
  391.       char *cp = (char*)mp;
  392.   
  393. + #ifdef safemalloc
  394. + #ifdef DEBUGGING
  395. + #  ifndef I286
  396. +     if (debug & 128)
  397. +         fprintf(stderr,"0x%x: (%05d) free\n",cp,an++);
  398. + #  else
  399. +     if (debug & 128)
  400. +         fprintf(stderr,"0x%lx: (%05d) free\n",cp,an++);
  401. + #  endif
  402. + #endif
  403. + #endif /* safemalloc */
  404.         if (cp == NULL)
  405.             return;
  406.       op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
  407. ***************
  408. *** 292,297 ****
  409. --- 348,372 ----
  410.       int was_alloced = 0;
  411.       char *cp = (char*)mp;
  412.   
  413. + #ifdef safemalloc
  414. + #ifdef DEBUGGING
  415. +     int size = nbytes;
  416. + #endif
  417. + #ifdef MSDOS
  418. +     if (nbytes > 0xffff) {
  419. +         fprintf(stderr, "Reallocation too large: %lx\n", size);
  420. +         exit(1);
  421. +     }
  422. + #endif /* MSDOS */
  423. +     if (!cp)
  424. +         fatal("Null realloc");
  425. + #ifdef DEBUGGING
  426. +     if ((long)nbytes < 0)
  427. +         fatal("panic: realloc");
  428. + #endif
  429. + #endif /* safemalloc */
  430.         if (cp == NULL)
  431.             return (malloc(nbytes));
  432.       op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
  433. ***************
  434. *** 336,349 ****
  435.               *((u_int *)((caddr_t)op + nbytes - RSLOP)) = RMAGIC;
  436.           }
  437.   #endif
  438. !         return((MALLOCPTRTYPE*)cp);
  439.       }
  440. !       if ((res = (char*)malloc(nbytes)) == NULL)
  441. !           return (NULL);
  442. !       if (cp != res)            /* common optimization */
  443. !         (void)bcopy(cp, res, (int)((nbytes < onb) ? nbytes : onb));
  444. !       if (was_alloced)
  445. !         free(cp);
  446.         return ((MALLOCPTRTYPE*)res);
  447.   }
  448.   
  449. --- 411,442 ----
  450.               *((u_int *)((caddr_t)op + nbytes - RSLOP)) = RMAGIC;
  451.           }
  452.   #endif
  453. !         res = cp;
  454.       }
  455. !     else {
  456. !         if ((res = (char*)malloc(nbytes)) == NULL)
  457. !             return (NULL);
  458. !         if (cp != res)            /* common optimization */
  459. !             bcopy(cp, res, (int)(nbytes < onb ? nbytes : onb));
  460. !         if (was_alloced)
  461. !             free(cp);
  462. !     }
  463. ! #ifdef safemalloc
  464. ! #ifdef DEBUGGING
  465. ! #  ifndef I286
  466. !     if (debug & 128) {
  467. !         fprintf(stderr,"0x%x: (%05d) rfree\n",res,an++);
  468. !         fprintf(stderr,"0x%x: (%05d) realloc %d bytes\n",res,an++,size);
  469. !     }
  470. ! #  else
  471. !     if (debug & 128) {
  472. !         fprintf(stderr,"0x%lx: (%05d) rfree\n",res,an++);
  473. !         fprintf(stderr,"0x%lx: (%05d) realloc %d bytes\n",res,an++,size);
  474. !     }
  475. ! #  endif
  476. ! #endif
  477. ! #endif /* safemalloc */
  478.         return ((MALLOCPTRTYPE*)res);
  479.   }
  480.   
  481.  
  482. Index: hints/mpc.sh
  483. *** hints/mpc.sh.old    Tue Nov  5 19:26:34 1991
  484. --- hints/mpc.sh    Tue Nov  5 19:26:34 1991
  485. ***************
  486. *** 0 ****
  487. --- 1 ----
  488. + ccflags="$ccflags -X18"
  489.  
  490. Index: usub/mus
  491. *** usub/mus.old    Tue Nov  5 19:28:22 1991
  492. --- usub/mus    Tue Nov  5 19:28:23 1991
  493. ***************
  494. *** 64,74 ****
  495.           if ($mode =~ /O/) {
  496.           if ($what eq 'gnum') {
  497.               push(@outies, "\t    str_numset(st[$i], (double) $name);\n");
  498.           }
  499.           else {
  500.               push(@outies, "\t    str_set(st[$i], (char*) $name);\n");
  501.           }
  502. -         push(@callnames, "&$name");
  503.           }
  504.           else {
  505.           push(@callnames, $name);
  506. --- 64,75 ----
  507.           if ($mode =~ /O/) {
  508.           if ($what eq 'gnum') {
  509.               push(@outies, "\t    str_numset(st[$i], (double) $name);\n");
  510. +             push(@callnames, "&$name");
  511.           }
  512.           else {
  513.               push(@outies, "\t    str_set(st[$i], (char*) $name);\n");
  514. +             push(@callnames, "$name");
  515.           }
  516.           }
  517.           else {
  518.           push(@callnames, $name);
  519. ***************
  520. *** 76,81 ****
  521. --- 77,87 ----
  522.           if ($mode =~ /I/) {
  523.           print <<EOF;
  524.           $type    $name =$x    $cast    str_$what(st[$i]);
  525. + EOF
  526. +         }
  527. +             elsif ($type =~ /char/) {
  528. +             print <<EOF;
  529. +         char    ${name}[133];
  530.   EOF
  531.           }
  532.           else {
  533.  
  534. Index: lib/newgetopt.pl
  535. *** lib/newgetopt.pl.old    Tue Nov  5 19:27:05 1991
  536. --- lib/newgetopt.pl    Tue Nov  5 19:27:05 1991
  537. ***************
  538. *** 1,11 ****
  539.   # newgetopt.pl -- new options parsing
  540.   
  541. ! # SCCS Status     : @(#)@ newgetopt.pl    1.7
  542.   # Author          : Johan Vromans
  543.   # Created On      : Tue Sep 11 15:00:12 1990
  544.   # Last Modified By: Johan Vromans
  545. ! # Last Modified On: Sun Oct 14 14:35:36 1990
  546. ! # Update Count    : 34
  547.   # Status          : Okay
  548.   
  549.   # This package implements a new getopt function. This function adheres
  550. --- 1,11 ----
  551.   # newgetopt.pl -- new options parsing
  552.   
  553. ! # SCCS Status     : @(#)@ newgetopt.pl    1.8
  554.   # Author          : Johan Vromans
  555.   # Created On      : Tue Sep 11 15:00:12 1990
  556.   # Last Modified By: Johan Vromans
  557. ! # Last Modified On: Thu Sep 26 20:10:41 1991
  558. ! # Update Count    : 35
  559.   # Status          : Okay
  560.   
  561.   # This package implements a new getopt function. This function adheres
  562. ***************
  563. *** 138,143 ****
  564. --- 138,146 ----
  565.           if ( $mand eq "=" ) {
  566.           print STDERR ("Option ", $opt, " requires an argument\n");
  567.           $error++;
  568. +         }
  569. +         if ( $mand eq ":" ) {
  570. +         $arg = $type eq "s" ? "" : 0;
  571.           }
  572.           next;
  573.       }
  574.  
  575. Index: hints/opus.sh
  576. *** hints/opus.sh.old    Tue Nov  5 19:26:35 1991
  577. --- hints/opus.sh    Tue Nov  5 19:26:36 1991
  578. ***************
  579. *** 0 ****
  580. --- 1 ----
  581. + ccflags="$ccflags -X18"
  582.  
  583. Index: perl.c
  584. *** perl.c.old    Tue Nov  5 19:27:15 1991
  585. --- perl.c    Tue Nov  5 19:27:16 1991
  586. ***************
  587. *** 1,4 ****
  588. ! char rcsid[] = "$RCSfile: perl.c,v $$Revision: 4.0.1.4 $$Date: 91/06/10 01:23:07 $\nPatch level: ###\n";
  589.   /*
  590.    *    Copyright (c) 1991, Larry Wall
  591.    *
  592. --- 1,4 ----
  593. ! char rcsid[] = "$RCSfile: perl.c,v $$Revision: 4.0.1.5 $$Date: 91/11/05 18:03:32 $\nPatch level: ###\n";
  594.   /*
  595.    *    Copyright (c) 1991, Larry Wall
  596.    *
  597. ***************
  598. *** 6,11 ****
  599. --- 6,20 ----
  600.    *    License or the Artistic License, as specified in the README file.
  601.    *
  602.    * $Log:    perl.c,v $
  603. +  * Revision 4.0.1.5  91/11/05  18:03:32  lwall
  604. +  * patch11: random cleanup
  605. +  * patch11: $0 was being truncated at times
  606. +  * patch11: cppstdin now installed outside of source directory
  607. +  * patch11: -P didn't allow use of #elif or #undef
  608. +  * patch11: prepared for ctype implementations that don't define isascii()
  609. +  * patch11: added eval {}
  610. +  * patch11: eval confused by string containing null
  611. +  * 
  612.    * Revision 4.0.1.4  91/06/10  01:23:07  lwall
  613.    * patch10: perl -v printed incorrect copyright notice
  614.    * 
  615. ***************
  616. *** 26,31 ****
  617. --- 35,42 ----
  618.    * 
  619.    */
  620.   
  621. + /*SUPPRESS 560*/
  622.   #include "EXTERN.h"
  623.   #include "perl.h"
  624.   #include "perly.h"
  625. ***************
  626. *** 64,69 ****
  627. --- 75,81 ----
  628.   {
  629.       register STR *str;
  630.       register char *s;
  631. +     char *scriptname;
  632.       char *getenv();
  633.       bool dosearch = FALSE;
  634.   #ifdef DOSUID
  635. ***************
  636. *** 193,198 ****
  637. --- 205,214 ----
  638.           s++;
  639.           goto reswitch;
  640.       case 'S':
  641. + #ifdef TAINT
  642. +         if (euid != uid || egid != gid)
  643. +         fatal("No -S allowed in setuid scripts");
  644. + #endif
  645.           dosearch = TRUE;
  646.           s++;
  647.           goto reswitch;
  648. ***************
  649. *** 212,221 ****
  650.       }
  651.       }
  652.     switch_end:
  653.       if (e_fp) {
  654.       (void)fclose(e_fp);
  655.       argc++,argv--;
  656. !     argv[0] = e_tmpname;
  657.       }
  658.   
  659.   #ifdef MSDOS
  660. --- 228,238 ----
  661.       }
  662.       }
  663.     switch_end:
  664. +     scriptname = argv[0];
  665.       if (e_fp) {
  666.       (void)fclose(e_fp);
  667.       argc++,argv--;
  668. !     scriptname = e_tmpname;
  669.       }
  670.   
  671.   #ifdef MSDOS
  672. ***************
  673. *** 259,275 ****
  674.   
  675.       /* open script */
  676.   
  677. !     if (argv[0] == Nullch)
  678.   #ifdef MSDOS
  679.       {
  680.       if ( isatty(fileno(stdin)) )
  681.         moreswitches("v");
  682. !     argv[0] = "-";
  683.       }
  684.   #else
  685. !     argv[0] = "-";
  686.   #endif
  687. !     if (dosearch && !index(argv[0], '/') && (s = getenv("PATH"))) {
  688.       char *xfound = Nullch, *xfailed = Nullch;
  689.       int len;
  690.   
  691. --- 276,292 ----
  692.   
  693.       /* open script */
  694.   
  695. !     if (scriptname == Nullch)
  696.   #ifdef MSDOS
  697.       {
  698.       if ( isatty(fileno(stdin)) )
  699.         moreswitches("v");
  700. !     scriptname = "-";
  701.       }
  702.   #else
  703. !     scriptname = "-";
  704.   #endif
  705. !     if (dosearch && !index(scriptname, '/') && (s = getenv("PATH"))) {
  706.       char *xfound = Nullch, *xfailed = Nullch;
  707.       int len;
  708.   
  709. ***************
  710. *** 289,295 ****
  711.           if (len && tokenbuf[len-1] != '\\')
  712.   #endif
  713.           (void)strcat(tokenbuf+len,"/");
  714. !         (void)strcat(tokenbuf+len,argv[0]);
  715.   #ifdef DEBUGGING
  716.           if (debug & 1)
  717.           fprintf(stderr,"Looking for %s\n",tokenbuf);
  718. --- 306,312 ----
  719.           if (len && tokenbuf[len-1] != '\\')
  720.   #endif
  721.           (void)strcat(tokenbuf+len,"/");
  722. !         (void)strcat(tokenbuf+len,scriptname);
  723.   #ifdef DEBUGGING
  724.           if (debug & 1)
  725.           fprintf(stderr,"Looking for %s\n",tokenbuf);
  726. ***************
  727. *** 305,324 ****
  728.           xfailed = savestr(tokenbuf);
  729.       }
  730.       if (!xfound)
  731. !         fatal("Can't execute %s", xfailed ? xfailed : argv[0] );
  732.       if (xfailed)
  733.           Safefree(xfailed);
  734. !     argv[0] = savestr(xfound);
  735.       }
  736.   
  737.       fdpid = anew(Nullstab);    /* for remembering popen pids by fd */
  738.       pidstatus = hnew(COEFFSIZE);/* for remembering status of dead pids */
  739.   
  740. !     origfilename = savestr(argv[0]);
  741.       curcmd->c_filestab = fstab(origfilename);
  742.       if (strEQ(origfilename,"-"))
  743. !     argv[0] = "";
  744.       if (preprocess) {
  745.       str_cat(str,"-I");
  746.       str_cat(str,PRIVLIB);
  747.       (void)sprintf(buf, "\
  748. --- 322,347 ----
  749.           xfailed = savestr(tokenbuf);
  750.       }
  751.       if (!xfound)
  752. !         fatal("Can't execute %s", xfailed ? xfailed : scriptname );
  753.       if (xfailed)
  754.           Safefree(xfailed);
  755. !     scriptname = savestr(xfound);
  756.       }
  757.   
  758.       fdpid = anew(Nullstab);    /* for remembering popen pids by fd */
  759.       pidstatus = hnew(COEFFSIZE);/* for remembering status of dead pids */
  760.   
  761. !     origfilename = savestr(scriptname);
  762.       curcmd->c_filestab = fstab(origfilename);
  763.       if (strEQ(origfilename,"-"))
  764. !     scriptname = "";
  765.       if (preprocess) {
  766. +     char *cpp = CPPSTDIN;
  767. +     if (strEQ(cpp,"cppstdin"))
  768. +         sprintf(tokenbuf, "%s/%s", SCRIPTDIR, cpp);
  769. +     else
  770. +         sprintf(tokenbuf, "%s", cpp);
  771.       str_cat(str,"-I");
  772.       str_cat(str,PRIVLIB);
  773.       (void)sprintf(buf, "\
  774. ***************
  775. *** 329,336 ****
  776.    -e '/^#[     ]*ifdef[     ]/b' \
  777.    -e '/^#[     ]*ifndef[     ]/b' \
  778.    -e '/^#[     ]*else/b' \
  779.    -e '/^#[     ]*endif/b' \
  780. !  -e 's/^#.*//' \
  781.    %s | %s -C %s %s",
  782.   #ifdef MSDOS
  783.         "",
  784. --- 352,361 ----
  785.    -e '/^#[     ]*ifdef[     ]/b' \
  786.    -e '/^#[     ]*ifndef[     ]/b' \
  787.    -e '/^#[     ]*else/b' \
  788. +  -e '/^#[     ]*elif[     ]/b' \
  789. +  -e '/^#[     ]*undef[     ]/b' \
  790.    -e '/^#[     ]*endif/b' \
  791. !  -e 's/^[     ]*#.*//' \
  792.    %s | %s -C %s %s",
  793.   #ifdef MSDOS
  794.         "",
  795. ***************
  796. *** 338,344 ****
  797.         "/bin/",
  798.   #endif
  799.         (doextract ? "-e '1,/^#/d\n'" : ""),
  800. !       argv[0], CPPSTDIN, str_get(str), CPPMINUS);
  801.   #ifdef DEBUGGING
  802.       if (debug & 64) {
  803.           fputs(buf,stderr);
  804. --- 363,369 ----
  805.         "/bin/",
  806.   #endif
  807.         (doextract ? "-e '1,/^#/d\n'" : ""),
  808. !       scriptname, tokenbuf, str_get(str), CPPMINUS);
  809.   #ifdef DEBUGGING
  810.       if (debug & 64) {
  811.           fputs(buf,stderr);
  812. ***************
  813. *** 360,370 ****
  814.   #endif /* IAMSUID */
  815.       rsfp = mypopen(buf,"r");
  816.       }
  817. !     else if (!*argv[0])
  818.       rsfp = stdin;
  819.       else
  820. !     rsfp = fopen(argv[0],"r");
  821. !     if (rsfp == Nullfp) {
  822.   #ifdef DOSUID
  823.   #ifndef IAMSUID        /* in case script is not readable before setuid */
  824.       if (euid && stat(stab_val(curcmd->c_filestab)->str_ptr,&statbuf) >= 0 &&
  825. --- 385,400 ----
  826.   #endif /* IAMSUID */
  827.       rsfp = mypopen(buf,"r");
  828.       }
  829. !     else if (!*scriptname) {
  830. ! #ifdef TAINT
  831. !     if (euid != uid || egid != gid)
  832. !         fatal("Can't take set-id script from stdin");
  833. ! #endif
  834.       rsfp = stdin;
  835. +     }
  836.       else
  837. !     rsfp = fopen(scriptname,"r");
  838. !     if ((FILE*)rsfp == Nullfp) {
  839.   #ifdef DOSUID
  840.   #ifndef IAMSUID        /* in case script is not readable before setuid */
  841.       if (euid && stat(stab_val(curcmd->c_filestab)->str_ptr,&statbuf) >= 0 &&
  842. ***************
  843. *** 473,479 ****
  844.           fatal("No #! line");
  845.       s = tokenbuf+2;
  846.       if (*s == ' ') s++;
  847. !     while (!isspace(*s)) s++;
  848.       if (strnNE(s-4,"perl",4) && strnNE(s-9,"perl",4))  /* sanity check */
  849.           fatal("Not a perl script");
  850.       while (*s == ' ' || *s == '\t') s++;
  851. --- 503,509 ----
  852.           fatal("No #! line");
  853.       s = tokenbuf+2;
  854.       if (*s == ' ') s++;
  855. !     while (!isSPACE(*s)) s++;
  856.       if (strnNE(s-4,"perl",4) && strnNE(s-9,"perl",4))  /* sanity check */
  857.           fatal("Not a perl script");
  858.       while (*s == ' ' || *s == '\t') s++;
  859. ***************
  860. *** 484,490 ****
  861.        */
  862.       len = strlen(validarg);
  863.       if (strEQ(validarg," PHOOEY ") ||
  864. !         strnNE(s,validarg,len) || !isspace(s[len]))
  865.           fatal("Args must match #! line");
  866.   
  867.   #ifndef IAMSUID
  868. --- 514,520 ----
  869.        */
  870.       len = strlen(validarg);
  871.       if (strEQ(validarg," PHOOEY ") ||
  872. !         strnNE(s,validarg,len) || !isSPACE(s[len]))
  873.           fatal("Args must match #! line");
  874.   
  875.   #ifndef IAMSUID
  876. ***************
  877. *** 593,598 ****
  878. --- 623,629 ----
  879.           doextract = FALSE;
  880.           if (s = instr(s,"perl -")) {
  881.           s += 6;
  882. +         /*SUPPRESS 530*/
  883.           while (s = moreswitches(s)) ;
  884.           }
  885.           if (cddir && chdir(cddir) < 0)
  886. ***************
  887. *** 872,881 ****
  888.   /* this routine is in perl.c by virtue of being sort of an alternate main() */
  889.   
  890.   int
  891. ! do_eval(str,optype,stash,gimme,arglast)
  892.   STR *str;
  893.   int optype;
  894.   HASH *stash;
  895.   int gimme;
  896.   int *arglast;
  897.   {
  898. --- 903,913 ----
  899.   /* this routine is in perl.c by virtue of being sort of an alternate main() */
  900.   
  901.   int
  902. ! do_eval(str,optype,stash,savecmd,gimme,arglast)
  903.   STR *str;
  904.   int optype;
  905.   HASH *stash;
  906. + int savecmd;
  907.   int gimme;
  908.   int *arglast;
  909.   {
  910. ***************
  911. *** 891,896 ****
  912. --- 923,929 ----
  913.       SPAT * VOLATILE oldspat = curspat;
  914.       SPAT * VOLATILE oldlspat = lastspat;
  915.       static char *last_eval = Nullch;
  916. +     static long last_elen = 0;
  917.       static CMD *last_root = Nullcmd;
  918.       VOLATILE int sp = arglast[0];
  919.       char *specfilename;
  920. ***************
  921. *** 996,1006 ****
  922.           retval = yyparse();
  923.           retval |= error_count;
  924.       }
  925. !     else if (last_root && *bufptr == *last_eval && strEQ(bufptr,last_eval)){
  926.           retval = 0;
  927.           eval_root = last_root;    /* no point in reparsing */
  928.       }
  929. !     else if (in_eval == 1) {
  930.           if (last_root) {
  931.           Safefree(last_eval);
  932.           last_eval = Nullch;
  933. --- 1029,1040 ----
  934.           retval = yyparse();
  935.           retval |= error_count;
  936.       }
  937. !     else if (last_root && last_elen == bufend - bufptr
  938. !       && *bufptr == *last_eval && !bcmp(bufptr,last_eval)){
  939.           retval = 0;
  940.           eval_root = last_root;    /* no point in reparsing */
  941.       }
  942. !     else if (in_eval == 1 && !savecmd) {
  943.           if (last_root) {
  944.           Safefree(last_eval);
  945.           last_eval = Nullch;
  946. ***************
  947. *** 1007,1013 ****
  948.           cmd_free(last_root);
  949.           }
  950.           last_root = Nullcmd;
  951. !         last_eval = savestr(bufptr);
  952.           retval = yyparse();
  953.           retval |= error_count;
  954.           if (!retval)
  955. --- 1041,1048 ----
  956.           cmd_free(last_root);
  957.           }
  958.           last_root = Nullcmd;
  959. !         last_elen = bufend - bufptr;
  960. !         last_eval = nsavestr(bufptr, last_elen);
  961.           retval = yyparse();
  962.           retval |= error_count;
  963.           if (!retval)
  964. ***************
  965. *** 1035,1041 ****
  966.   #endif
  967.           cmd_free(eval_root);
  968.   #endif
  969. !         if (eval_root == last_root)
  970.           last_root = Nullcmd;
  971.           eval_root = myroot = Nullcmd;
  972.       }
  973. --- 1070,1076 ----
  974.   #endif
  975.           cmd_free(eval_root);
  976.   #endif
  977. !         if ((CMD*)eval_root == last_root)
  978.           last_root = Nullcmd;
  979.           eval_root = myroot = Nullcmd;
  980.       }
  981. ***************
  982. *** 1051,1057 ****
  983.       for (i = arglast[0] + 1; i <= sp; i++)
  984.           st[i] = str_mortal(st[i]);
  985.                   /* if we don't save result, free zaps it */
  986. !     if (in_eval != 1 && myroot != last_root)
  987.           cmd_free(myroot);
  988.       }
  989.   
  990. --- 1086,1094 ----
  991.       for (i = arglast[0] + 1; i <= sp; i++)
  992.           st[i] = str_mortal(st[i]);
  993.                   /* if we don't save result, free zaps it */
  994. !     if (savecmd)
  995. !         eval_root = myroot;
  996. !     else if (in_eval != 1 && myroot != last_root)
  997.           cmd_free(myroot);
  998.       }
  999.   
  1000. ***************
  1001. *** 1091,1096 ****
  1002. --- 1128,1195 ----
  1003.       return sp;
  1004.   }
  1005.   
  1006. + int
  1007. + do_try(cmd,gimme,arglast)
  1008. + CMD *cmd;
  1009. + int gimme;
  1010. + int *arglast;
  1011. + {
  1012. +     STR **st = stack->ary_array;
  1013. +     CMD * VOLATILE oldcurcmd = curcmd;
  1014. +     VOLATILE int oldtmps_base = tmps_base;
  1015. +     VOLATILE int oldsave = savestack->ary_fill;
  1016. +     SPAT * VOLATILE oldspat = curspat;
  1017. +     SPAT * VOLATILE oldlspat = lastspat;
  1018. +     VOLATILE int sp = arglast[0];
  1019. +     tmps_base = tmps_max;
  1020. +     str_set(stab_val(stabent("@",TRUE)),"");
  1021. +     in_eval++;
  1022. +     if (++loop_ptr >= loop_max) {
  1023. +     loop_max += 128;
  1024. +     Renew(loop_stack, loop_max, struct loop);
  1025. +     }
  1026. +     loop_stack[loop_ptr].loop_label = "_EVAL_";
  1027. +     loop_stack[loop_ptr].loop_sp = sp;
  1028. + #ifdef DEBUGGING
  1029. +     if (debug & 4) {
  1030. +     deb("(Pushing label #%d _EVAL_)\n", loop_ptr);
  1031. +     }
  1032. + #endif
  1033. +     if (setjmp(loop_stack[loop_ptr].loop_env)) {
  1034. +     st = stack->ary_array;
  1035. +     sp = arglast[0];
  1036. +     if (gimme != G_ARRAY)
  1037. +         st[++sp] = &str_undef;
  1038. +     }
  1039. +     else {
  1040. +     sp = cmd_exec(cmd,gimme,sp);
  1041. +     st = stack->ary_array;
  1042. + /*    for (i = arglast[0] + 1; i <= sp; i++)
  1043. +         st[i] = str_mortal(st[i]);  not needed, I think */
  1044. +                 /* if we don't save result, free zaps it */
  1045. +     }
  1046. +     in_eval--;
  1047. + #ifdef DEBUGGING
  1048. +     if (debug & 4) {
  1049. +     char *tmps = loop_stack[loop_ptr].loop_label;
  1050. +     deb("(Popping label #%d %s)\n",loop_ptr,
  1051. +         tmps ? tmps : "" );
  1052. +     }
  1053. + #endif
  1054. +     loop_ptr--;
  1055. +     tmps_base = oldtmps_base;
  1056. +     curspat = oldspat;
  1057. +     lastspat = oldlspat;
  1058. +     curcmd = oldcurcmd;
  1059. +     if (savestack->ary_fill > oldsave)    /* let them use local() */
  1060. +     restorelist(oldsave);
  1061. +     return sp;
  1062. + }
  1063.   /* This routine handles any switches that can be given during run */
  1064.   
  1065.   static char *
  1066. ***************
  1067. *** 1099,1105 ****
  1068.   {
  1069.       int numlen;
  1070.   
  1071. -   reswitch:
  1072.       switch (*s) {
  1073.       case '0':
  1074.       nrschar = scanoct(s, 4, &numlen);
  1075. --- 1198,1203 ----
  1076. ***************
  1077. *** 1141,1151 ****
  1078.   #else
  1079.       warn("Recompile perl with -DDEBUGGING to use -D switch\n");
  1080.   #endif
  1081. !     for (s++; isdigit(*s); s++) ;
  1082.       return s;
  1083.       case 'i':
  1084.       inplace = savestr(s+1);
  1085. !     for (s = inplace; *s && !isspace(*s); s++) ;
  1086.       *s = '\0';
  1087.       break;
  1088.       case 'I':
  1089. --- 1239,1251 ----
  1090.   #else
  1091.       warn("Recompile perl with -DDEBUGGING to use -D switch\n");
  1092.   #endif
  1093. !     /*SUPPRESS 530*/
  1094. !     for (s++; isDIGIT(*s); s++) ;
  1095.       return s;
  1096.       case 'i':
  1097.       inplace = savestr(s+1);
  1098. !     /*SUPPRESS 530*/
  1099. !     for (s = inplace; *s && !isSPACE(*s); s++) ;
  1100.       *s = '\0';
  1101.       break;
  1102.       case 'I':
  1103. ***************
  1104. *** 1162,1168 ****
  1105.       case 'l':
  1106.       minus_l = TRUE;
  1107.       s++;
  1108. !     if (isdigit(*s)) {
  1109.           ors = savestr("\n");
  1110.           orslen = 1;
  1111.           *ors = scanoct(s, 3 + (*s == '0'), &numlen);
  1112. --- 1262,1268 ----
  1113.       case 'l':
  1114.       minus_l = TRUE;
  1115.       s++;
  1116. !     if (isDIGIT(*s)) {
  1117.           ors = savestr("\n");
  1118.           orslen = 1;
  1119.           *ors = scanoct(s, 3 + (*s == '0'), &numlen);
  1120.  
  1121. Index: perl.h
  1122. *** perl.h.old    Tue Nov  5 19:27:19 1991
  1123. --- perl.h    Tue Nov  5 19:27:20 1991
  1124. ***************
  1125. *** 1,4 ****
  1126. ! /* $RCSfile: perl.h,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:25:10 $
  1127.    *
  1128.    *    Copyright (c) 1991, Larry Wall
  1129.    *
  1130. --- 1,4 ----
  1131. ! /* $RCSfile: perl.h,v $$Revision: 4.0.1.4 $$Date: 91/11/05 18:06:10 $
  1132.    *
  1133.    *    Copyright (c) 1991, Larry Wall
  1134.    *
  1135. ***************
  1136. *** 6,11 ****
  1137. --- 6,17 ----
  1138.    *    License or the Artistic License, as specified in the README file.
  1139.    *
  1140.    * $Log:    perl.h,v $
  1141. +  * Revision 4.0.1.4  91/11/05  18:06:10  lwall
  1142. +  * patch11: various portability fixes
  1143. +  * patch11: added support for dbz
  1144. +  * patch11: added some support for 64-bit integers
  1145. +  * patch11: hex() didn't understand leading 0x
  1146. +  * 
  1147.    * Revision 4.0.1.3  91/06/10  01:25:10  lwall
  1148.    * patch10: certain pattern optimizations were botched
  1149.    * 
  1150. ***************
  1151. *** 25,30 ****
  1152. --- 31,53 ----
  1153.   #define VOIDWANT 1
  1154.   #include "config.h"
  1155.   
  1156. + #ifdef MYMALLOC
  1157. + #   ifdef HIDEMYMALLOC
  1158. + #    define malloc Mymalloc
  1159. + #    define realloc Myremalloc
  1160. + #    define free Myfree
  1161. + #   endif
  1162. + #   define safemalloc malloc
  1163. + #   define saferealloc realloc
  1164. + #   define safefree free
  1165. + #endif
  1166. + /* work around some libPW problems */
  1167. + #define fatal Myfatal
  1168. + #ifdef DOINIT
  1169. + char Error[1];
  1170. + #endif
  1171.   #ifdef MSDOS
  1172.   /* This stuff now in the MS-DOS config.h file. */
  1173.   #else /* !MSDOS */
  1174. ***************
  1175. *** 197,202 ****
  1176. --- 220,242 ----
  1177.   #endif
  1178.   #endif
  1179.   
  1180. + #ifdef WANT_DBZ
  1181. + #include <dbz.h>
  1182. + #define SOME_DBM
  1183. + #define dbm_fetch(db,dkey) fetch(dkey)
  1184. + #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
  1185. + #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  1186. + #define dbm_close(db) dbmclose()
  1187. + #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  1188. + #define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
  1189. + #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  1190. + #ifdef HAS_NDBM
  1191. + #undef HAS_NDBM
  1192. + #endif
  1193. + #ifndef HAS_ODBM
  1194. + #define HAS_ODBM
  1195. + #endif
  1196. + #else
  1197.   #ifdef HAS_GDBM
  1198.   #ifdef I_GDBM
  1199.   #include <gdbm.h>
  1200. ***************
  1201. *** 234,239 ****
  1202. --- 274,280 ----
  1203.   #endif /* HAS_ODBM */
  1204.   #endif /* HAS_NDBM */
  1205.   #endif /* HAS_GDBM */
  1206. + #endif /* WANT_DBZ */
  1207.   #ifdef SOME_DBM
  1208.   EXT char *dbmkey;
  1209.   EXT int dbmlen;
  1210. ***************
  1211. *** 303,308 ****
  1212. --- 344,353 ----
  1213.   #   endif
  1214.   #endif
  1215.   
  1216. + #if S_ISBLK(060000) == 060000
  1217. +     XXX Your sys/stat.h appears to be buggy.  Please fix it.
  1218. + #endif
  1219.   #ifndef S_ISREG
  1220.   #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  1221.   #endif
  1222. ***************
  1223. *** 377,382 ****
  1224. --- 422,447 ----
  1225.   #undef f_next
  1226.   #endif
  1227.   
  1228. + #if defined(cray) || defined(gould)
  1229. + #   define SLOPPYDIVIDE
  1230. + #endif
  1231. + #if defined(cray) || defined(convex) || BYTEORDER > 0xffff
  1232. + #   define QUAD
  1233. + #endif
  1234. + #ifdef QUAD
  1235. + #   ifdef cray
  1236. + #    define quad int
  1237. + #   else
  1238. + #    ifdef convex
  1239. + #        define quad long long
  1240. + #    else
  1241. + #        define quad long
  1242. + #    endif
  1243. + #   endif
  1244. + #endif
  1245.   typedef unsigned int STRLEN;
  1246.   
  1247.   typedef struct arg ARG;
  1248. ***************
  1249. *** 631,637 ****
  1250.   EXT char **origenviron;
  1251.   extern char **environ;
  1252.   
  1253. ! EXT line_t subline INIT(0);
  1254.   EXT STR *subname INIT(Nullstr);
  1255.   EXT int arybase INIT(0);
  1256.   
  1257. --- 696,702 ----
  1258.   EXT char **origenviron;
  1259.   extern char **environ;
  1260.   
  1261. ! EXT long subline INIT(0);
  1262.   EXT STR *subname INIT(Nullstr);
  1263.   EXT int arybase INIT(0);
  1264.   
  1265. ***************
  1266. *** 676,682 ****
  1267.   EXT int lastspbase;
  1268.   EXT int lastsize;
  1269.   
  1270. ! EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEF");
  1271.   EXT char *origfilename;
  1272.   EXT FILE * VOLATILE rsfp;
  1273.   EXT char buf[1024];
  1274. --- 741,747 ----
  1275.   EXT int lastspbase;
  1276.   EXT int lastsize;
  1277.   
  1278. ! EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  1279.   EXT char *origfilename;
  1280.   EXT FILE * VOLATILE rsfp;
  1281.   EXT char buf[1024];
  1282. ***************
  1283. *** 753,758 ****
  1284. --- 818,824 ----
  1285.   void free_arg();
  1286.   STIO *stio_new();
  1287.   void hoistmust();
  1288. + void scanconst();
  1289.   
  1290.   EXT struct stat statbuf;
  1291.   EXT struct stat statcache;
  1292.  
  1293. Index: perl.man
  1294. *** perl.man.old    Tue Nov  5 19:27:27 1991
  1295. --- perl.man    Tue Nov  5 19:27:30 1991
  1296. ***************
  1297. *** 1,7 ****
  1298.   .rn '' }`
  1299. ! ''' $RCSfile: perl.man,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:26:02 $
  1300.   ''' 
  1301.   ''' $Log:    perl.man,v $
  1302.   ''' Revision 4.0.1.3  91/06/10  01:26:02  lwall
  1303.   ''' patch10: documented some newer features in addenda
  1304.   ''' 
  1305. --- 1,13 ----
  1306.   .rn '' }`
  1307. ! ''' $RCSfile: perl.man,v $$Revision: 4.0.1.4 $$Date: 91/11/05 18:11:05 $
  1308.   ''' 
  1309.   ''' $Log:    perl.man,v $
  1310. + ''' Revision 4.0.1.4  91/11/05  18:11:05  lwall
  1311. + ''' patch11: added sort {} LIST
  1312. + ''' patch11: added eval {}
  1313. + ''' patch11: documented meaning of scalar(%foo)
  1314. + ''' patch11: sprintf() now supports any length of s field
  1315. + ''' 
  1316.   ''' Revision 4.0.1.3  91/06/10  01:26:02  lwall
  1317.   ''' patch10: documented some newer features in addenda
  1318.   ''' 
  1319. ***************
  1320. *** 449,456 ****
  1321.   allows
  1322.   .I perl
  1323.   to do unsafe operations.
  1324. ! Currently the only \*(L"unsafe\*(R" operation is the unlinking of directories while
  1325. ! running as superuser.
  1326.   .TP 5
  1327.   .B \-v
  1328.   prints the version and patchlevel of your
  1329. --- 455,463 ----
  1330.   allows
  1331.   .I perl
  1332.   to do unsafe operations.
  1333. ! Currently the only \*(L"unsafe\*(R" operations are the unlinking of directories while
  1334. ! running as superuser, and running setuid programs with fatal taint checks
  1335. ! turned into warnings.
  1336.   .TP 5
  1337.   .B \-v
  1338.   prints the version and patchlevel of your
  1339. ***************
  1340. *** 479,485 ****
  1341.   The
  1342.   .B \-x
  1343.   switch only controls the the disposal of leading garbage.
  1344. ! The script must be terminated with __END__ if there is trailing garbage
  1345.   to be ignored (the script can process any or all of the trailing garbage
  1346.   via the DATA filehandle if desired).
  1347.   .Sh "Data Types and Objects"
  1348. --- 486,492 ----
  1349.   The
  1350.   .B \-x
  1351.   switch only controls the the disposal of leading garbage.
  1352. ! The script must be terminated with _\|_END_\|_ if there is trailing garbage
  1353.   to be ignored (the script can process any or all of the trailing garbage
  1354.   via the DATA filehandle if desired).
  1355.   .Sh "Data Types and Objects"
  1356. ***************
  1357. *** 573,581 ****
  1358.   The following is always true:
  1359.   .nf
  1360.   
  1361. !     @whatever == $#whatever \- $[ + 1;
  1362.   
  1363.   .fi
  1364.   .PP
  1365.   Multi-dimensional arrays are not directly supported, but see the discussion
  1366.   of the $; variable later for a means of emulating multiple subscripts with
  1367. --- 580,593 ----
  1368.   The following is always true:
  1369.   .nf
  1370.   
  1371. !     scalar(@whatever) == $#whatever \- $[ + 1;
  1372.   
  1373.   .fi
  1374. + If you evaluate an associative array in a scalar context, it returns
  1375. + a value which is true if and only if the array contains any elements.
  1376. + (If there are any elements, the value returned is a string consisting
  1377. + of the number of used buckets and the number of allocated buckets, separated
  1378. + by a slash.)
  1379.   .PP
  1380.   Multi-dimensional arrays are not directly supported, but see the discussion
  1381.   of the $; variable later for a means of emulating multiple subscripts with
  1382. ***************
  1383. *** 666,679 ****
  1384.   word by a space, since single quote is a valid character in an identifier
  1385.   (see Packages).
  1386.   .PP
  1387. ! Two special literals are __LINE__ and __FILE__, which represent the current
  1388.   line number and filename at that point in your program.
  1389.   They may only be used as separate tokens; they will not be interpolated
  1390.   into strings.
  1391. ! In addition, the token __END__ may be used to indicate the logical end of the
  1392.   script before the actual end of file.
  1393.   Any following text is ignored (but may be read via the DATA filehandle).
  1394. ! The two control characters ^D and ^Z are synonyms for __END__.
  1395.   .PP
  1396.   A word that doesn't have any other interpretation in the grammar will be
  1397.   treated as if it had single quotes around it.
  1398. --- 678,691 ----
  1399.   word by a space, since single quote is a valid character in an identifier
  1400.   (see Packages).
  1401.   .PP
  1402. ! Two special literals are _\|_LINE_\|_ and _\|_FILE_\|_, which represent the current
  1403.   line number and filename at that point in your program.
  1404.   They may only be used as separate tokens; they will not be interpolated
  1405.   into strings.
  1406. ! In addition, the token _\|_END_\|_ may be used to indicate the logical end of the
  1407.   script before the actual end of file.
  1408.   Any following text is ignored (but may be read via the DATA filehandle).
  1409. ! The two control characters ^D and ^Z are synonyms for _\|_END_\|_.
  1410.   .PP
  1411.   A word that doesn't have any other interpretation in the grammar will be
  1412.   treated as if it had single quotes around it.
  1413. ***************
  1414. *** 1844,1850 ****
  1415.   DBNAME is the name of the database (without the .dir or .pag extension).
  1416.   If the database does not exist, it is created with protection specified
  1417.   by MODE (as modified by the umask).
  1418. ! If your system only supports the older dbm functions, you may only have one
  1419.   dbmopen in your program.
  1420.   If your system has neither dbm nor ndbm, calling dbmopen produces a fatal
  1421.   error.
  1422. --- 1856,1862 ----
  1423.   DBNAME is the name of the database (without the .dir or .pag extension).
  1424.   If the database does not exist, it is created with protection specified
  1425.   by MODE (as modified by the umask).
  1426. ! If your system only supports the older dbm functions, you may perform only one
  1427.   dbmopen in your program.
  1428.   If your system has neither dbm nor ndbm, calling dbmopen produces a fatal
  1429.   error.
  1430. ***************
  1431. *** 1896,1902 ****
  1432.           unless defined($value = readlink $sym);
  1433.       eval '@foo = ()' if defined(@foo);
  1434.       die "No XYZ package defined" unless defined %_XYZ;
  1435. !     sub foo { defined &bar ? &bar(@_) : die "No bar"; }
  1436.   
  1437.   .fi
  1438.   See also undef.
  1439. --- 1908,1914 ----
  1440.           unless defined($value = readlink $sym);
  1441.       eval '@foo = ()' if defined(@foo);
  1442.       die "No XYZ package defined" unless defined %_XYZ;
  1443. !     sub foo { defined &$bar ? &$bar(@_) : die "No bar"; }
  1444.   
  1445.   .fi
  1446.   See also undef.
  1447. ***************
  1448. *** 1984,2001 ****
  1449.   If you pass arrays as part of LIST you may wish to pass the length
  1450.   of the array in front of each array.
  1451.   (See the section on subroutines later on.)
  1452. - SUBROUTINE may be a scalar variable, in which case the variable contains
  1453. - the name of the subroutine to execute.
  1454.   The parentheses are required to avoid confusion with the \*(L"do EXPR\*(R"
  1455.   form.
  1456.   .Sp
  1457. ! As an alternate form, you may call a subroutine by prefixing the name with
  1458.   an ampersand: &foo(@args).
  1459.   If you aren't passing any arguments, you don't have to use parentheses.
  1460.   If you omit the parentheses, no @_ array is passed to the subroutine.
  1461.   The & form is also used to specify subroutines to the defined and undef
  1462. ! operators.
  1463. ! .Ip "do EXPR" 8 3
  1464.   Uses the value of EXPR as a filename and executes the contents of the file
  1465.   as a
  1466.   .I perl
  1467. --- 1996,2020 ----
  1468.   If you pass arrays as part of LIST you may wish to pass the length
  1469.   of the array in front of each array.
  1470.   (See the section on subroutines later on.)
  1471.   The parentheses are required to avoid confusion with the \*(L"do EXPR\*(R"
  1472.   form.
  1473.   .Sp
  1474. ! SUBROUTINE may also be a single scalar variable, in which case
  1475. ! the name of the subroutine to execute is taken from the variable.
  1476. ! .Sp
  1477. ! As an alternate (and preferred) form,
  1478. ! you may call a subroutine by prefixing the name with
  1479.   an ampersand: &foo(@args).
  1480.   If you aren't passing any arguments, you don't have to use parentheses.
  1481.   If you omit the parentheses, no @_ array is passed to the subroutine.
  1482.   The & form is also used to specify subroutines to the defined and undef
  1483. ! operators:
  1484. ! .nf
  1485. !     if (defined &$var) { &$var($parm); undef &$var; }
  1486. ! .fi
  1487. ! :Ip "do EXPR" 8 3
  1488.   Uses the value of EXPR as a filename and executes the contents of the file
  1489.   as a
  1490.   .I perl
  1491. ***************
  1492. *** 2128,2133 ****
  1493. --- 2147,2153 ----
  1494.   .fi
  1495.   .Ip "eval(EXPR)" 8 6
  1496.   .Ip "eval EXPR" 8 6
  1497. + .Ip "eval BLOCK" 8 6
  1498.   EXPR is parsed and executed as if it were a little
  1499.   .I perl
  1500.   program.
  1501. ***************
  1502. *** 2149,2154 ****
  1503. --- 2169,2201 ----
  1504.   (such as dbmopen or symlink) is implemented.
  1505.   It is also Perl's exception trapping mechanism, where the die operator is
  1506.   used to raise exceptions.
  1507. + .Sp
  1508. + If the code to be executed doesn't vary, you may use
  1509. + the eval-BLOCK form to trap run-time errors without incurring
  1510. + the penalty of recompiling each time.
  1511. + The error, if any, is still returned in $@.
  1512. + Evaluating a single-quoted string (as EXPR) has the same effect, except that
  1513. + the eval-EXPR form reports syntax errors at run time via $@, whereas the
  1514. + eval-BLOCK form reports syntax errors at compile time.  The eval-EXPR form
  1515. + is optimized to eval-BLOCK the first time it succeeds.  (Since the replacement
  1516. + side of a substitution is considered a single-quoted string when you
  1517. + use the e modifier, the same optimization occurs there.)  Examples:
  1518. + .nf
  1519. + .ne 11
  1520. +     # make divide-by-zero non-fatal
  1521. +     eval { $answer = $a / $b; }; warn $@ if $@;
  1522. +     # optimized to same thing after first use
  1523. +     eval '$answer = $a / $b'; warn $@ if $@;
  1524. +     # a compile-time error
  1525. +     eval { $answer = };
  1526. +     # a run-time error
  1527. +     eval '$answer =';    # sets $@
  1528. + .fi
  1529.   .Ip "exec(LIST)" 8 8
  1530.   .Ip "exec LIST" 8 6
  1531.   If there is more than one argument in LIST, or if LIST is an array with
  1532. ***************
  1533. *** 3558,3565 ****
  1534.   .Ip "sleep EXPR" 8
  1535.   .Ip "sleep" 8
  1536.   Causes the script to sleep for EXPR seconds, or forever if no EXPR.
  1537. ! May be interrupted by sending the process a SIGALARM.
  1538.   Returns the number of seconds actually slept.
  1539.   .Ip "socket(SOCKET,DOMAIN,TYPE,PROTOCOL)" 8 3
  1540.   Opens a socket of the specified kind and attaches it to filehandle SOCKET.
  1541.   DOMAIN, TYPE and PROTOCOL are specified the same as for the system call
  1542. --- 3605,3614 ----
  1543.   .Ip "sleep EXPR" 8
  1544.   .Ip "sleep" 8
  1545.   Causes the script to sleep for EXPR seconds, or forever if no EXPR.
  1546. ! May be interrupted by sending the process a SIGALRM.
  1547.   Returns the number of seconds actually slept.
  1548. + You probably cannot mix alarm() and sleep() calls, since sleep() is
  1549. + often implemented using alarm().
  1550.   .Ip "socket(SOCKET,DOMAIN,TYPE,PROTOCOL)" 8 3
  1551.   Opens a socket of the specified kind and attaches it to filehandle SOCKET.
  1552.   DOMAIN, TYPE and PROTOCOL are specified the same as for the system call
  1553. ***************
  1554. *** 3578,3602 ****
  1555.   .Ip "sort(SUBROUTINE LIST)" 8 9
  1556.   .Ip "sort(LIST)" 8
  1557.   .Ip "sort SUBROUTINE LIST" 8
  1558.   .Ip "sort LIST" 8
  1559.   Sorts the LIST and returns the sorted array value.
  1560.   Nonexistent values of arrays are stripped out.
  1561. ! If SUBROUTINE is omitted, sorts in standard string comparison order.
  1562.   If SUBROUTINE is specified, gives the name of a subroutine that returns
  1563.   an integer less than, equal to, or greater than 0,
  1564.   depending on how the elements of the array are to be ordered.
  1565.   (The <=> and cmp operators are extremely useful in such routines.)
  1566.   In the interests of efficiency the normal calling code for subroutines
  1567.   is bypassed, with the following effects: the subroutine may not be a recursive
  1568.   subroutine, and the two elements to be compared are passed into the subroutine
  1569.   not via @_ but as $a and $b (see example below).
  1570.   They are passed by reference so don't modify $a and $b.
  1571. ! SUBROUTINE may be a scalar variable name, in which case the value provides
  1572. ! the name of the subroutine to use.
  1573.   Examples:
  1574.   .nf
  1575.   
  1576. ! .ne 4
  1577.       sub byage {
  1578.           $age{$a} <=> $age{$b};    # presuming integers
  1579.       }
  1580. --- 3627,3677 ----
  1581.   .Ip "sort(SUBROUTINE LIST)" 8 9
  1582.   .Ip "sort(LIST)" 8
  1583.   .Ip "sort SUBROUTINE LIST" 8
  1584. + .Ip "sort BLOCK LIST" 8
  1585.   .Ip "sort LIST" 8
  1586.   Sorts the LIST and returns the sorted array value.
  1587.   Nonexistent values of arrays are stripped out.
  1588. ! If SUBROUTINE or BLOCK is omitted, sorts in standard string comparison order.
  1589.   If SUBROUTINE is specified, gives the name of a subroutine that returns
  1590.   an integer less than, equal to, or greater than 0,
  1591.   depending on how the elements of the array are to be ordered.
  1592.   (The <=> and cmp operators are extremely useful in such routines.)
  1593. + SUBROUTINE may be a scalar variable name, in which case the value provides
  1594. + the name of the subroutine to use.
  1595. + In place of a SUBROUTINE name, you can provide a BLOCK as an anonymous,
  1596. + in-line sort subroutine.
  1597. + .Sp
  1598.   In the interests of efficiency the normal calling code for subroutines
  1599.   is bypassed, with the following effects: the subroutine may not be a recursive
  1600.   subroutine, and the two elements to be compared are passed into the subroutine
  1601.   not via @_ but as $a and $b (see example below).
  1602.   They are passed by reference so don't modify $a and $b.
  1603. ! .Sp
  1604.   Examples:
  1605.   .nf
  1606.   
  1607. ! .ne 2
  1608. !     # sort lexically
  1609. !     @articles = sort @files;
  1610. ! .ne 2
  1611. !     # same thing, but with explicit sort routine
  1612. !     @articles = sort {$a cmp $b;} @files;
  1613. ! .ne 2
  1614. !     # same thing in reversed order
  1615. !     @articles = sort {$b cmp $a;} @files;
  1616. ! .ne 2
  1617. !     # sort numerically ascending
  1618. !     @articles = sort {$a <=> $b;} @files;
  1619. ! .ne 2
  1620. !     # sort numerically descending
  1621. !     @articles = sort {$b <=> $a;} @files;
  1622. ! .ne 5
  1623. !     # sort using explicit subroutine name
  1624.       sub byage {
  1625.           $age{$a} <=> $age{$b};    # presuming integers
  1626.       }
  1627. ***************
  1628. *** 4175,4183 ****
  1629.   record, the page is advanced by writing a form feed,
  1630.   a special top-of-page format is used
  1631.   to format the new page header, and then the record is written.
  1632. ! By default the top-of-page format is \*(L"top\*(R", but it
  1633. ! may be set to the
  1634. ! format of your choice by assigning the name to the $^ variable.
  1635.   The number of lines remaining on the current page is in variable $-, which
  1636.   can be set to 0 to force a new page.
  1637.   .Sp
  1638. --- 4250,4259 ----
  1639.   record, the page is advanced by writing a form feed,
  1640.   a special top-of-page format is used
  1641.   to format the new page header, and then the record is written.
  1642. ! By default the top-of-page format is the name of the filehandle with
  1643. ! \*(L"_TOP\*(R" appended, but it may be dynamicallly set to the
  1644. ! format of your choice by assigning the name to the $^ variable while
  1645. ! the filehandle is selected.
  1646.   The number of lines remaining on the current page is in variable $-, which
  1647.   can be set to 0 to force a new page.
  1648.   .Sp
  1649. ***************
  1650. *** 5574,5580 ****
  1651.   
  1652.   .fi
  1653.   .SH AUTHOR
  1654. ! Larry Wall <lwall@jpl-devvax.Jpl.Nasa.Gov>
  1655.   .br
  1656.   MS-DOS port by Diomidis Spinellis <dds@cc.ic.ac.uk>
  1657.   .SH FILES
  1658. --- 5650,5656 ----
  1659.   
  1660.   .fi
  1661.   .SH AUTHOR
  1662. ! Larry Wall <lwall@netlabs.com>
  1663.   .br
  1664.   MS-DOS port by Diomidis Spinellis <dds@cc.ic.ac.uk>
  1665.   .SH FILES
  1666. ***************
  1667. *** 5775,5780 ****
  1668. --- 5851,5859 ----
  1669.   
  1670.   .fi
  1671.   .PP
  1672. + The descriptions of alarm and sleep refer to signal SIGALARM.  These
  1673. + should refer to SIGALRM.
  1674. + .PP
  1675.   The
  1676.   .B \-0
  1677.   switch to set the initial value of $/ was added to Perl after the book
  1678. ***************
  1679. *** 5810,5815 ****
  1680. --- 5889,5899 ----
  1681.   to iterate through a string finding multiple matches.
  1682.   .PP
  1683.   All of the $^X variables are new except for $^T.
  1684. + .PP
  1685. + The default top-of-form format for FILEHANDLE is now FILEHANDLE_TOP rather
  1686. + than top.
  1687. + .PP
  1688. + The eval {} and sort {} constructs were added in version 4.011.
  1689.   .SH BUGS
  1690.   .PP
  1691.   .I Perl
  1692. ***************
  1693. *** 5823,5831 ****
  1694.   .PP
  1695.   While none of the built-in data types have any arbitrary size limits (apart
  1696.   from memory size), there are still a few arbitrary limits:
  1697. ! a given identifier may not be longer than 255 characters;
  1698. ! sprintf is limited on many machines to 128 characters per field (unless the format
  1699. ! specifier is exactly %s);
  1700.   and no component of your PATH may be longer than 255 if you use \-S.
  1701.   .PP
  1702.   .I Perl
  1703. --- 5907,5913 ----
  1704.   .PP
  1705.   While none of the built-in data types have any arbitrary size limits (apart
  1706.   from memory size), there are still a few arbitrary limits:
  1707. ! a given identifier may not be longer than 255 characters,
  1708.   and no component of your PATH may be longer than 255 if you use \-S.
  1709.   .PP
  1710.   .I Perl
  1711.  
  1712. *** End of Patch 15 ***
  1713. exit 0 # Just in case...
  1714. -- 
  1715. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1716. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1717. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1718. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1719.