home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume20 / perl / patch10 < prev    next >
Encoding:
Text File  |  1991-06-19  |  22.1 KB  |  819 lines

  1. Newsgroups: comp.sources.misc
  2. From: Larry Wall <lwall@netlabs.com>
  3. Subject:  v20i062:  perl - The perl programming language, Patch10
  4. Message-ID: <1991Jun20.030845.8919@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: de248178bb74b164e1b03b6260eebbfc
  6. Date: Thu, 20 Jun 1991 03:08:45 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Larry Wall <lwall@netlabs.com>
  10. Posting-number: Volume 20, Issue 62
  11. Archive-name: perl/patch10
  12. Patch-To: perl: Volume 18, Issue 19-54
  13.  
  14. System: perl version 4.0
  15. Patch #: 10
  16. Priority: HIGH
  17. Subject: pack(hh,1) dumped core
  18. Subject: read didn't work from character special files open for writing
  19. Subject: close-on-exec wrongly set on system file descriptors
  20. Subject: //g only worked first time through
  21. Subject: perl -v printed incorrect copyright notice
  22. Subject: certain pattern optimizations were botched
  23. Subject: documented some newer features in addenda
  24. Subject: $) and $| incorrectly handled in run-time patterns
  25. Subject: added tests for case-insensitive regular expressions
  26. Subject: m'$foo' now treats string as single quoted
  27.  
  28. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your perl source
  29.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  30.     If you don't have the patch program, apply the following by hand,
  31.     or get patch (version 2.0, latest patchlevel).
  32.  
  33.     After patching:
  34.         Configure -d
  35.         make depend
  36.         make
  37.         make test
  38.         make install
  39.  
  40.     If patch indicates that patchlevel is the wrong version, you may need
  41.     to apply one or more previous patches, or the patch may already
  42.     have been applied.  See the patchlevel.h file to find out what has or
  43.     has not been applied.  In any event, don't continue with the patch.
  44.  
  45.     If you are missing previous patches they can be obtained from me:
  46.  
  47.     Larry Wall
  48.     lwall@netlabs.com
  49.  
  50.     If you send a mail message of the following form it will greatly speed
  51.     processing:
  52.  
  53.     Subject: Command
  54.     @SH mailpatch PATH perl 4.0 LIST
  55.            ^ note the c
  56.  
  57.     where PATH is a return path FROM ME TO YOU either in Internet notation,
  58.     or in bang notation from some well-known host, and LIST is the number
  59.     of one or more patches you need, separated by spaces, commas, and/or
  60.     hyphens.  Saying 35- says everything from 35 to the end.
  61.  
  62.  
  63. Index: patchlevel.h
  64. Prereq: 9
  65. 1c1
  66. < #define PATCHLEVEL 9
  67. ---
  68. > #define PATCHLEVEL 10
  69.  
  70. Index: doarg.c
  71. *** doarg.c.old    Mon Jun 10 01:32:56 1991
  72. --- doarg.c    Mon Jun 10 01:33:01 1991
  73. ***************
  74. *** 1,4 ****
  75. ! /* $RCSfile: doarg.c,v $$Revision: 4.0.1.2 $$Date: 91/06/07 10:42:17 $
  76.    *
  77.    *    Copyright (c) 1991, Larry Wall
  78.    *
  79. --- 1,4 ----
  80. ! /* $RCSfile: doarg.c,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:18:41 $
  81.    *
  82.    *    Copyright (c) 1991, Larry Wall
  83.    *
  84. ***************
  85. *** 6,11 ****
  86. --- 6,14 ----
  87.    *    License or the Artistic License, as specified in the README file.
  88.    *
  89.    * $Log:    doarg.c,v $
  90. +  * Revision 4.0.1.3  91/06/10  01:18:41  lwall
  91. +  * patch10: pack(hh,1) dumped core
  92. +  * 
  93.    * Revision 4.0.1.2  91/06/07  10:42:17  lwall
  94.    * patch4: new copyright notice
  95.    * patch4: // wouldn't use previous pattern if it started with a null character
  96. ***************
  97. *** 494,502 ****
  98.       case 'b':
  99.           {
  100.           char *savepat = pat;
  101. !         int saveitems = items;
  102.   
  103.           fromstr = NEXTFROM;
  104.           aptr = str_get(fromstr);
  105.           if (pat[-1] == '*')
  106.               len = fromstr->str_cur;
  107. --- 497,506 ----
  108.       case 'b':
  109.           {
  110.           char *savepat = pat;
  111. !         int saveitems;
  112.   
  113.           fromstr = NEXTFROM;
  114. +         saveitems = items;
  115.           aptr = str_get(fromstr);
  116.           if (pat[-1] == '*')
  117.               len = fromstr->str_cur;
  118. ***************
  119. *** 551,559 ****
  120.       case 'h':
  121.           {
  122.           char *savepat = pat;
  123. !         int saveitems = items;
  124.   
  125.           fromstr = NEXTFROM;
  126.           aptr = str_get(fromstr);
  127.           if (pat[-1] == '*')
  128.               len = fromstr->str_cur;
  129. --- 555,564 ----
  130.       case 'h':
  131.           {
  132.           char *savepat = pat;
  133. !         int saveitems;
  134.   
  135.           fromstr = NEXTFROM;
  136. +         saveitems = items;
  137.           aptr = str_get(fromstr);
  138.           if (pat[-1] == '*')
  139.               len = fromstr->str_cur;
  140.  
  141. Index: doio.c
  142. *** doio.c.old    Mon Jun 10 01:33:20 1991
  143. --- doio.c    Mon Jun 10 01:33:26 1991
  144. ***************
  145. *** 1,4 ****
  146. ! /* $RCSfile: doio.c,v $$Revision: 4.0.1.2 $$Date: 91/06/07 10:53:39 $
  147.    *
  148.    *    Copyright (c) 1991, Larry Wall
  149.    *
  150. --- 1,4 ----
  151. ! /* $RCSfile: doio.c,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:21:19 $
  152.    *
  153.    *    Copyright (c) 1991, Larry Wall
  154.    *
  155. ***************
  156. *** 6,11 ****
  157. --- 6,15 ----
  158.    *    License or the Artistic License, as specified in the README file.
  159.    *
  160.    * $Log:    doio.c,v $
  161. +  * Revision 4.0.1.3  91/06/10  01:21:19  lwall
  162. +  * patch10: read didn't work from character special files open for writing
  163. +  * patch10: close-on-exec wrongly set on system file descriptors
  164. +  * 
  165.    * Revision 4.0.1.2  91/06/07  10:53:39  lwall
  166.    * patch4: new copyright notice
  167.    * patch4: system fd's are now treated specially
  168. ***************
  169. *** 237,243 ****
  170.           (void)fclose(fp);
  171.           goto say_false;
  172.       }
  173. !     if (S_ISSOCK(statbuf.st_mode) || (S_ISCHR(statbuf.st_mode) && writing))
  174.           stio->type = 's';    /* in case a socket was passed in to us */
  175.   #ifdef S_IFMT
  176.       else if (!(statbuf.st_mode & S_IFMT))
  177. --- 241,247 ----
  178.           (void)fclose(fp);
  179.           goto say_false;
  180.       }
  181. !     if (S_ISSOCK(statbuf.st_mode))
  182.           stio->type = 's';    /* in case a socket was passed in to us */
  183.   #ifdef S_IFMT
  184.       else if (!(statbuf.st_mode & S_IFMT))
  185. ***************
  186. *** 244,253 ****
  187.           stio->type = 's';    /* some OS's return 0 on fstat()ed socket */
  188.   #endif
  189.       }
  190. - #if defined(HAS_FCNTL) && defined(F_SETFD)
  191. -     fd = fileno(fp);
  192. -     fcntl(fd,F_SETFD,fd > maxsysfd);
  193. - #endif
  194.       if (saveifp) {        /* must use old fp? */
  195.       fd = fileno(saveifp);
  196.       if (saveofp) {
  197. --- 248,253 ----
  198. ***************
  199. *** 263,278 ****
  200.       }
  201.       fp = saveifp;
  202.       }
  203.       stio->ifp = fp;
  204.       if (writing) {
  205. !     if (stio->type != 's')
  206. !         stio->ofp = fp;
  207. !     else
  208.           if (!(stio->ofp = fdopen(fileno(fp),"w"))) {
  209.           fclose(fp);
  210.           stio->ifp = Nullfp;
  211.           goto say_false;
  212.           }
  213.       }
  214.       return TRUE;
  215.   
  216. --- 263,284 ----
  217.       }
  218.       fp = saveifp;
  219.       }
  220. + #if defined(HAS_FCNTL) && defined(F_SETFD)
  221. +     fd = fileno(fp);
  222. +     fcntl(fd,F_SETFD,fd > maxsysfd);
  223. + #endif
  224.       stio->ifp = fp;
  225.       if (writing) {
  226. !     if (stio->type == 's'
  227. !       || (stio->type == '>' && S_ISCHR(statbuf.st_mode)) ) {
  228.           if (!(stio->ofp = fdopen(fileno(fp),"w"))) {
  229.           fclose(fp);
  230.           stio->ifp = Nullfp;
  231.           goto say_false;
  232.           }
  233. +     }
  234. +     else
  235. +         stio->ofp = fp;
  236.       }
  237.       return TRUE;
  238.   
  239.  
  240. Index: dolist.c
  241. *** dolist.c.old    Mon Jun 10 01:33:39 1991
  242. --- dolist.c    Mon Jun 10 01:33:43 1991
  243. ***************
  244. *** 1,4 ****
  245. ! /* $RCSfile: dolist.c,v $$Revision: 4.0.1.1 $$Date: 91/06/07 10:58:28 $
  246.    *
  247.    *    Copyright (c) 1991, Larry Wall
  248.    *
  249. --- 1,4 ----
  250. ! /* $RCSfile: dolist.c,v $$Revision: 4.0.1.2 $$Date: 91/06/10 01:22:15 $
  251.    *
  252.    *    Copyright (c) 1991, Larry Wall
  253.    *
  254. ***************
  255. *** 6,11 ****
  256. --- 6,14 ----
  257.    *    License or the Artistic License, as specified in the README file.
  258.    *
  259.    * $Log:    dolist.c,v $
  260. +  * Revision 4.0.1.2  91/06/10  01:22:15  lwall
  261. +  * patch10: //g only worked first time through
  262. +  * 
  263.    * Revision 4.0.1.1  91/06/07  10:58:28  lwall
  264.    * patch4: new copyright notice
  265.    * patch4: added global modifier for pattern matches
  266. ***************
  267. *** 202,207 ****
  268. --- 205,212 ----
  269.           goto gotcha;
  270.       }
  271.       else {
  272. +         if (global)
  273. +         spat->spat_regexp->startp[0] = Nullch;
  274.           if (gimme == G_ARRAY)
  275.           return sp;
  276.           str_sset(str,&str_no);
  277. ***************
  278. *** 276,281 ****
  279. --- 281,288 ----
  280.   nope:
  281.       spat->spat_regexp->startp[0] = Nullch;
  282.       ++spat->spat_short->str_u.str_useful;
  283. +     if (global)
  284. +     spat->spat_regexp->startp[0] = Nullch;
  285.       if (gimme == G_ARRAY)
  286.       return sp;
  287.       str_sset(str,&str_no);
  288.  
  289. Index: t/op/pat.t
  290. *** t/op/pat.t.old    Mon Jun 10 01:35:45 1991
  291. --- t/op/pat.t    Mon Jun 10 01:35:47 1991
  292. ***************
  293. *** 1,8 ****
  294.   #!./perl
  295.   
  296. ! # $RCSfile: pat.t,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:01:26 $
  297.   
  298. ! print "1..48\n";
  299.   
  300.   $x = "abc\ndef\n";
  301.   
  302. --- 1,8 ----
  303.   #!./perl
  304.   
  305. ! # $RCSfile: pat.t,v $$Revision: 4.0.1.2 $$Date: 91/06/10 01:29:34 $
  306.   
  307. ! print "1..51\n";
  308.   
  309.   $x = "abc\ndef\n";
  310.   
  311. ***************
  312. *** 174,176 ****
  313. --- 174,184 ----
  314.   
  315.   $x = "$t1$t2$t3$t4$t5$t6$t7$t8$t9";
  316.   print $x eq '505550555' ? "ok 48\n" : "not ok 48 $x\n";
  317. + $xyz = 'xyz';
  318. + print "abc" =~ /^abc$|$xyz/ ? "ok 49\n" : "not ok 49\n";
  319. + # perl 4.009 says "unmatched ()"
  320. + eval '"abc" =~ /a(bc$)|$xyz/; $result = "$&:$1"';
  321. + print $@ eq "" ? "ok 50\n" : "not ok 50\n";
  322. + print $result eq "abc:bc" ? "ok 51\n" : "not ok 51\n";
  323.  
  324. Index: perl.c
  325. *** perl.c.old    Mon Jun 10 01:33:57 1991
  326. --- perl.c    Mon Jun 10 01:34:01 1991
  327. ***************
  328. *** 1,4 ****
  329. ! char rcsid[] = "$RCSfile: perl.c,v $$Revision: 4.0.1.3 $$Date: 91/06/07 11:40:18 $\nPatch level: ###\n";
  330.   /*
  331.    *    Copyright (c) 1991, Larry Wall
  332.    *
  333. --- 1,4 ----
  334. ! char rcsid[] = "$RCSfile: perl.c,v $$Revision: 4.0.1.4 $$Date: 91/06/10 01:23:07 $\nPatch level: ###\n";
  335.   /*
  336.    *    Copyright (c) 1991, Larry Wall
  337.    *
  338. ***************
  339. *** 6,11 ****
  340. --- 6,14 ----
  341.    *    License or the Artistic License, as specified in the README file.
  342.    *
  343.    * $Log:    perl.c,v $
  344. +  * Revision 4.0.1.4  91/06/10  01:23:07  lwall
  345. +  * patch10: perl -v printed incorrect copyright notice
  346. +  * 
  347.    * Revision 4.0.1.3  91/06/07  11:40:18  lwall
  348.    * patch4: changed old $^P to $^X
  349.    * 
  350. ***************
  351. *** 1199,1206 ****
  352.   #endif
  353.   #endif
  354.       fputs("\n\
  355. ! Perl may be copied only under the terms of the GNU General Public License,\n\
  356. ! a copy of which can be found with the Perl 4.0 distribution kit.\n",stdout);
  357.   #ifdef MSDOS
  358.           usage(origargv[0]);
  359.   #endif
  360. --- 1202,1209 ----
  361.   #endif
  362.   #endif
  363.       fputs("\n\
  364. ! Perl may be copied only under the terms of either the Artistic License or the\n\
  365. ! GNU General Public License, which may be found in the Perl 4.0 source kit.\n",stdout);
  366.   #ifdef MSDOS
  367.           usage(origargv[0]);
  368.   #endif
  369.  
  370. Index: perl.h
  371. *** perl.h.old    Mon Jun 10 01:34:12 1991
  372. --- perl.h    Mon Jun 10 01:34:14 1991
  373. ***************
  374. *** 1,4 ****
  375. ! /* $RCSfile: perl.h,v $$Revision: 4.0.1.2 $$Date: 91/06/07 11:28:33 $
  376.    *
  377.    *    Copyright (c) 1991, Larry Wall
  378.    *
  379. --- 1,4 ----
  380. ! /* $RCSfile: perl.h,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:25:10 $
  381.    *
  382.    *    Copyright (c) 1991, Larry Wall
  383.    *
  384. ***************
  385. *** 6,11 ****
  386. --- 6,14 ----
  387.    *    License or the Artistic License, as specified in the README file.
  388.    *
  389.    * $Log:    perl.h,v $
  390. +  * Revision 4.0.1.3  91/06/10  01:25:10  lwall
  391. +  * patch10: certain pattern optimizations were botched
  392. +  * 
  393.    * Revision 4.0.1.2  91/06/07  11:28:33  lwall
  394.    * patch4: new copyright notice
  395.    * patch4: made some allowances for "semi-standard" C
  396. ***************
  397. *** 749,754 ****
  398. --- 752,758 ----
  399.   STR *interp();
  400.   void free_arg();
  401.   STIO *stio_new();
  402. + void hoistmust();
  403.   
  404.   EXT struct stat statbuf;
  405.   EXT struct stat statcache;
  406.  
  407. Index: perl.man
  408. *** perl.man.old    Mon Jun 10 01:34:47 1991
  409. --- perl.man    Mon Jun 10 01:35:01 1991
  410. ***************
  411. *** 1,7 ****
  412.   .rn '' }`
  413. ! ''' $RCSfile: perl.man,v $$Revision: 4.0.1.2 $$Date: 91/06/07 11:41:23 $
  414.   ''' 
  415.   ''' $Log:    perl.man,v $
  416.   ''' Revision 4.0.1.2  91/06/07  11:41:23  lwall
  417.   ''' patch4: added global modifier for pattern matches
  418.   ''' patch4: default top-of-form format is now FILEHANDLE_TOP
  419. --- 1,10 ----
  420.   .rn '' }`
  421. ! ''' $RCSfile: perl.man,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:26:02 $
  422.   ''' 
  423.   ''' $Log:    perl.man,v $
  424. + ''' Revision 4.0.1.3  91/06/10  01:26:02  lwall
  425. + ''' patch10: documented some newer features in addenda
  426. + ''' 
  427.   ''' Revision 4.0.1.2  91/06/07  11:41:23  lwall
  428.   ''' patch4: added global modifier for pattern matches
  429.   ''' patch4: default top-of-form format is now FILEHANDLE_TOP
  430. ***************
  431. *** 5802,5807 ****
  432. --- 5805,5815 ----
  433.   The
  434.   .B $/
  435.   variable may now be set to a multi-character delimiter.
  436. + .PP
  437. + There is now a g modifier on ordinary pattern matching that causes it
  438. + to iterate through a string finding multiple matches.
  439. + .PP
  440. + All of the $^X variables are new except for $^T.
  441.   .SH BUGS
  442.   .PP
  443.   .I Perl
  444.  
  445. Index: t/op/re_tests
  446. *** t/op/re_tests.old    Mon Jun 10 01:35:52 1991
  447. --- t/op/re_tests    Mon Jun 10 01:35:54 1991
  448. ***************
  449. *** 135,137 ****
  450. --- 135,274 ----
  451.   a[-]?c    ac    y    $&    ac
  452.   (abc)\1    abcabc    y    $1    abc
  453.   ([a-c]*)\1    abcabc    y    $1    abc
  454. + 'abc'i    ABC    y    $&    ABC
  455. + 'abc'i    XBC    n    -    -
  456. + 'abc'i    AXC    n    -    -
  457. + 'abc'i    ABX    n    -    -
  458. + 'abc'i    XABCY    y    $&    ABC
  459. + 'abc'i    ABABC    y    $&    ABC
  460. + 'ab*c'i    ABC    y    $&    ABC
  461. + 'ab*bc'i    ABC    y    $&    ABC
  462. + 'ab*bc'i    ABBC    y    $&    ABBC
  463. + 'ab*bc'i    ABBBBC    y    $&    ABBBBC
  464. + 'ab{0,}bc'i    ABBBBC    y    $&    ABBBBC
  465. + 'ab+bc'i    ABBC    y    $&    ABBC
  466. + 'ab+bc'i    ABC    n    -    -
  467. + 'ab+bc'i    ABQ    n    -    -
  468. + 'ab{1,}bc'i    ABQ    n    -    -
  469. + 'ab+bc'i    ABBBBC    y    $&    ABBBBC
  470. + 'ab{1,}bc'i    ABBBBC    y    $&    ABBBBC
  471. + 'ab{1,3}bc'i    ABBBBC    y    $&    ABBBBC
  472. + 'ab{3,4}bc'i    ABBBBC    y    $&    ABBBBC
  473. + 'ab{4,5}bc'i    ABBBBC    n    -    -
  474. + 'ab?bc'i    ABBC    y    $&    ABBC
  475. + 'ab?bc'i    ABC    y    $&    ABC
  476. + 'ab{0,1}bc'i    ABC    y    $&    ABC
  477. + 'ab?bc'i    ABBBBC    n    -    -
  478. + 'ab?c'i    ABC    y    $&    ABC
  479. + 'ab{0,1}c'i    ABC    y    $&    ABC
  480. + '^abc$'i    ABC    y    $&    ABC
  481. + '^abc$'i    ABCC    n    -    -
  482. + '^abc'i    ABCC    y    $&    ABC
  483. + '^abc$'i    AABC    n    -    -
  484. + 'abc$'i    AABC    y    $&    ABC
  485. + '^'i    ABC    y    $&    
  486. + '$'i    ABC    y    $&    
  487. + 'a.c'i    ABC    y    $&    ABC
  488. + 'a.c'i    AXC    y    $&    AXC
  489. + 'a.*c'i    AXYZC    y    $&    AXYZC
  490. + 'a.*c'i    AXYZD    n    -    -
  491. + 'a[bc]d'i    ABC    n    -    -
  492. + 'a[bc]d'i    ABD    y    $&    ABD
  493. + 'a[b-d]e'i    ABD    n    -    -
  494. + 'a[b-d]e'i    ACE    y    $&    ACE
  495. + 'a[b-d]'i    AAC    y    $&    AC
  496. + 'a[-b]'i    A-    y    $&    A-
  497. + 'a[b-]'i    A-    y    $&    A-
  498. + 'a[b-a]'i    -    c    -    -
  499. + 'a[]b'i    -    c    -    -
  500. + 'a['i    -    c    -    -
  501. + 'a]'i    A]    y    $&    A]
  502. + 'a[]]b'i    A]B    y    $&    A]B
  503. + 'a[^bc]d'i    AED    y    $&    AED
  504. + 'a[^bc]d'i    ABD    n    -    -
  505. + 'a[^-b]c'i    ADC    y    $&    ADC
  506. + 'a[^-b]c'i    A-C    n    -    -
  507. + 'a[^]b]c'i    A]C    n    -    -
  508. + 'a[^]b]c'i    ADC    y    $&    ADC
  509. + 'ab|cd'i    ABC    y    $&    AB
  510. + 'ab|cd'i    ABCD    y    $&    AB
  511. + '()ef'i    DEF    y    $&-$1    EF-
  512. + '()*'i    -    c    -    -
  513. + '*a'i    -    c    -    -
  514. + '^*'i    -    c    -    -
  515. + '$*'i    -    c    -    -
  516. + '(*)b'i    -    c    -    -
  517. + '$b'i    B    n    -    -
  518. + 'a\'i    -    c    -    -
  519. + 'a\(b'i    A(B    y    $&-$1    A(B-
  520. + 'a\(*b'i    AB    y    $&    AB
  521. + 'a\(*b'i    A((B    y    $&    A((B
  522. + 'a\\b'i    A\B    y    $&    A\B
  523. + 'abc)'i    -    c    -    -
  524. + '(abc'i    -    c    -    -
  525. + '((a))'i    ABC    y    $&-$1-$2    A-A-A
  526. + '(a)b(c)'i    ABC    y    $&-$1-$2    ABC-A-C
  527. + 'a+b+c'i    AABBABC    y    $&    ABC
  528. + 'a{1,}b{1,}c'i    AABBABC    y    $&    ABC
  529. + 'a**'i    -    c    -    -
  530. + 'a*?'i    -    c    -    -
  531. + '(a*)*'i    -    c    -    -
  532. + '(a*)+'i    -    c    -    -
  533. + '(a|)*'i    -    c    -    -
  534. + '(a*|b)*'i    -    c    -    -
  535. + '(a+|b)*'i    AB    y    $&-$1    AB-B
  536. + '(a+|b){0,}'i    AB    y    $&-$1    AB-B
  537. + '(a+|b)+'i    AB    y    $&-$1    AB-B
  538. + '(a+|b){1,}'i    AB    y    $&-$1    AB-B
  539. + '(a+|b)?'i    AB    y    $&-$1    A-A
  540. + '(a+|b){0,1}'i    AB    y    $&-$1    A-A
  541. + '(^)*'i    -    c    -    -
  542. + '(ab|)*'i    -    c    -    -
  543. + ')('i    -    c    -    -
  544. + '[^ab]*'i    CDE    y    $&    CDE
  545. + 'abc'i        n    -    -
  546. + 'a*'i        y    $&    
  547. + '([abc])*d'i    ABBBCD    y    $&-$1    ABBBCD-C
  548. + '([abc])*bcd'i    ABCD    y    $&-$1    ABCD-A
  549. + 'a|b|c|d|e'i    E    y    $&    E
  550. + '(a|b|c|d|e)f'i    EF    y    $&-$1    EF-E
  551. + '((a*|b))*'i    -    c    -    -
  552. + 'abcd*efg'i    ABCDEFG    y    $&    ABCDEFG
  553. + 'ab*'i    XABYABBBZ    y    $&    AB
  554. + 'ab*'i    XAYABBBZ    y    $&    A
  555. + '(ab|cd)e'i    ABCDE    y    $&-$1    CDE-CD
  556. + '[abhgefdc]ij'i    HIJ    y    $&    HIJ
  557. + '^(ab|cd)e'i    ABCDE    n    x$1y    XY
  558. + '(abc|)ef'i    ABCDEF    y    $&-$1    EF-
  559. + '(a|b)c*d'i    ABCD    y    $&-$1    BCD-B
  560. + '(ab|ab*)bc'i    ABC    y    $&-$1    ABC-A
  561. + 'a([bc]*)c*'i    ABC    y    $&-$1    ABC-BC
  562. + 'a([bc]*)(c*d)'i    ABCD    y    $&-$1-$2    ABCD-BC-D
  563. + 'a([bc]+)(c*d)'i    ABCD    y    $&-$1-$2    ABCD-BC-D
  564. + 'a([bc]*)(c+d)'i    ABCD    y    $&-$1-$2    ABCD-B-CD
  565. + 'a[bcd]*dcdcde'i    ADCDCDE    y    $&    ADCDCDE
  566. + 'a[bcd]+dcdcde'i    ADCDCDE    n    -    -
  567. + '(ab|a)b*c'i    ABC    y    $&-$1    ABC-AB
  568. + '((a)(b)c)(d)'i    ABCD    y    $1-$2-$3-$4    ABC-A-B-D
  569. + '[a-zA-Z_][a-zA-Z0-9_]*'i    ALPHA    y    $&    ALPHA
  570. + '^a(bc+|b[eh])g|.h$'i    ABH    y    $&-$1    BH-
  571. + '(bc+d$|ef*g.|h?i(j|k))'i    EFFGZ    y    $&-$1-$2    EFFGZ-EFFGZ-
  572. + '(bc+d$|ef*g.|h?i(j|k))'i    IJ    y    $&-$1-$2    IJ-IJ-J
  573. + '(bc+d$|ef*g.|h?i(j|k))'i    EFFG    n    -    -
  574. + '(bc+d$|ef*g.|h?i(j|k))'i    BCDD    n    -    -
  575. + '(bc+d$|ef*g.|h?i(j|k))'i    REFFGZ    y    $&-$1-$2    EFFGZ-EFFGZ-
  576. + '((((((((((a))))))))))'i    A    y    $10    A
  577. + '((((((((((a))))))))))\10'i    AA    y    $&    AA
  578. + '((((((((((a))))))))))\41'i    AA    n    -    -
  579. + '((((((((((a))))))))))\41'i    A!    y    $&    A!
  580. + '(((((((((a)))))))))'i    A    y    $&    A
  581. + 'multiple words of text'i    UH-UH    n    -    -
  582. + 'multiple words'i    MULTIPLE WORDS, YEAH    y    $&    MULTIPLE WORDS
  583. + '(.*)c(.*)'i    ABCDE    y    $&-$1-$2    ABCDE-AB-DE
  584. + '\((.*), (.*)\)'i    (A, B)    y    ($2, $1)    (B, A)
  585. + '[k]'i    AB    n    -    -
  586. + 'abcd'i    ABCD    y    $&-\$&-\\$&    ABCD-$&-\ABCD
  587. + 'a(bc)d'i    ABCD    y    $1-\$1-\\$1    BC-$1-\BC
  588. + 'a[-]?c'i    AC    y    $&    AC
  589. + '(abc)\1'i    ABCABC    y    $1    ABC
  590. + '([a-c]*)\1'i    ABCABC    y    $1    ABC
  591.  
  592. Index: t/op/regexp.t
  593. Prereq: 4.0
  594. *** t/op/regexp.t.old    Mon Jun 10 01:36:00 1991
  595. --- t/op/regexp.t    Mon Jun 10 01:36:01 1991
  596. ***************
  597. *** 1,6 ****
  598.   #!./perl
  599.   
  600. ! # $Header: regexp.t,v 4.0 91/03/20 01:54:22 lwall Locked $
  601.   
  602.   open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
  603.       || die "Can't open re_tests";
  604. --- 1,6 ----
  605.   #!./perl
  606.   
  607. ! # $RCSfile: regexp.t,v $$Revision: 4.0.1.1 $$Date: 91/06/10 01:30:29 $
  608.   
  609.   open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
  610.       || die "Can't open re_tests";
  611. ***************
  612. *** 11,20 ****
  613.   print "1..$numtests\n";
  614.   open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
  615.       || die "Can't open re_tests";
  616.   while (<TESTS>) {
  617.       ($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_);
  618.       $input = join(':',$pat,$subject,$result,$repl,$expect);
  619. !     eval "\$match = (\$subject =~ \$pat); \$got = \"$repl\";";
  620.       if ($result eq 'c') {
  621.       if ($@ ne '') {print "ok $.\n";} else {print "not ok $.\n";}
  622.       }
  623. --- 11,22 ----
  624.   print "1..$numtests\n";
  625.   open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
  626.       || die "Can't open re_tests";
  627. + $| = 1;
  628.   while (<TESTS>) {
  629.       ($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_);
  630.       $input = join(':',$pat,$subject,$result,$repl,$expect);
  631. !     $pat = "'$pat'" unless $pat =~ /^'/;
  632. !     eval "\$match = (\$subject =~ m$pat); \$got = \"$repl\";";
  633.       if ($result eq 'c') {
  634.       if ($@ ne '') {print "ok $.\n";} else {print "not ok $.\n";}
  635.       }
  636.  
  637. Index: str.c
  638. *** str.c.old    Mon Jun 10 01:35:33 1991
  639. --- str.c    Mon Jun 10 01:35:37 1991
  640. ***************
  641. *** 1,4 ****
  642. ! /* $RCSfile: str.c,v $$Revision: 4.0.1.2 $$Date: 91/06/07 11:58:13 $
  643.    *
  644.    *    Copyright (c) 1991, Larry Wall
  645.    *
  646. --- 1,4 ----
  647. ! /* $RCSfile: str.c,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:27:54 $
  648.    *
  649.    *    Copyright (c) 1991, Larry Wall
  650.    *
  651. ***************
  652. *** 6,11 ****
  653. --- 6,14 ----
  654.    *    License or the Artistic License, as specified in the README file.
  655.    *
  656.    * $Log:    str.c,v $
  657. +  * Revision 4.0.1.3  91/06/10  01:27:54  lwall
  658. +  * patch10: $) and $| incorrectly handled in run-time patterns
  659. +  * 
  660.    * Revision 4.0.1.2  91/06/07  11:58:13  lwall
  661.    * patch4: new copyright notice
  662.    * patch4: taint check on undefined string could cause core dump
  663. ***************
  664. *** 939,946 ****
  665.           ++s;
  666.           t = s;
  667.       }
  668. !     else if ((*s == '@' || (*s == '$' && !index(nointrp,s[1]))) &&
  669. !       s+1 < send) {
  670.           str_ncat(str,t,s-t);
  671.           t = s;
  672.           if (*s == '$' && s[1] == '#' && (isalpha(s[2]) || s[2] == '_'))
  673. --- 942,955 ----
  674.           ++s;
  675.           t = s;
  676.       }
  677. !     else if (*s == '$' && s+1 < send && *nointrp && index(nointrp,s[1])) {
  678. !         str_ncat(str, t, s - t);
  679. !         str_ncat(str, "$b", 2);
  680. !         str_ncat(str, s, 2);
  681. !         s += 2;
  682. !         t = s;
  683. !     }
  684. !     else if ((*s == '@' || *s == '$') && s+1 < send) {
  685.           str_ncat(str,t,s-t);
  686.           t = s;
  687.           if (*s == '$' && s[1] == '#' && (isalpha(s[2]) || s[2] == '_'))
  688. ***************
  689. *** 1171,1176 ****
  690. --- 1180,1188 ----
  691.           if (s-t > 0)
  692.           str_ncat(str,t,s-t);
  693.           switch(*++s) {
  694. +         default:
  695. +         fatal("panic: unknown interp cookie\n");
  696. +         break;
  697.           case 'a':
  698.           str_scat(str,*++elem);
  699.           break;
  700.  
  701. Index: toke.c
  702. *** toke.c.old    Mon Jun 10 01:36:15 1991
  703. --- toke.c    Mon Jun 10 01:36:21 1991
  704. ***************
  705. *** 1,4 ****
  706. ! /* $RCSfile: toke.c,v $$Revision: 4.0.1.2 $$Date: 91/06/07 12:05:56 $
  707.    *
  708.    *    Copyright (c) 1991, Larry Wall
  709.    *
  710. --- 1,4 ----
  711. ! /* $RCSfile: toke.c,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:32:26 $
  712.    *
  713.    *    Copyright (c) 1991, Larry Wall
  714.    *
  715. ***************
  716. *** 6,11 ****
  717. --- 6,15 ----
  718.    *    License or the Artistic License, as specified in the README file.
  719.    *
  720.    * $Log:    toke.c,v $
  721. +  * Revision 4.0.1.3  91/06/10  01:32:26  lwall
  722. +  * patch10: m'$foo' now treats string as single quoted
  723. +  * patch10: certain pattern optimizations were botched
  724. +  * 
  725.    * Revision 4.0.1.2  91/06/07  12:05:56  lwall
  726.    * patch4: new copyright notice
  727.    * patch4: debugger lost track of lines in eval
  728. ***************
  729. *** 1514,1519 ****
  730. --- 1518,1524 ----
  731.       int len;
  732.       SPAT savespat;
  733.       STR *str = Str_new(93,0);
  734. +     char delim;
  735.   
  736.       Newz(801,spat,1,SPAT);
  737.       spat->spat_next = curstash->tbl_spatroot;    /* link into spat list */
  738. ***************
  739. *** 1538,1544 ****
  740.       yylval.arg = Nullarg;
  741.       return s;
  742.       }
  743. !     s++;
  744.       while (*s == 'i' || *s == 'o' || *s == 'g') {
  745.       if (*s == 'i') {
  746.           s++;
  747. --- 1543,1549 ----
  748.       yylval.arg = Nullarg;
  749.       return s;
  750.       }
  751. !     delim = *s++;
  752.       while (*s == 'i' || *s == 'o' || *s == 'g') {
  753.       if (*s == 'i') {
  754.           s++;
  755. ***************
  756. *** 1556,1562 ****
  757.       }
  758.       len = str->str_cur;
  759.       e = str->str_ptr + len;
  760. !     for (d = str->str_ptr; d < e; d++) {
  761.       if (*d == '\\')
  762.           d++;
  763.       else if ((*d == '$' && d[1] && d[1] != '|' && d[1] != ')') ||
  764. --- 1561,1571 ----
  765.       }
  766.       len = str->str_cur;
  767.       e = str->str_ptr + len;
  768. !     if (delim == '\'')
  769. !     d = e;
  770. !     else
  771. !     d = str->str_ptr;
  772. !     for (; d < e; d++) {
  773.       if (*d == '\\')
  774.           d++;
  775.       else if ((*d == '$' && d[1] && d[1] != '|' && d[1] != ')') ||
  776. ***************
  777. *** 1738,1743 ****
  778. --- 1747,1753 ----
  779.       return s;
  780.   }
  781.   
  782. + void
  783.   hoistmust(spat)
  784.   register SPAT *spat;
  785.   {
  786. ***************
  787. *** 1744,1752 ****
  788.       if (!spat->spat_short && spat->spat_regexp->regstart &&
  789.       (!spat->spat_regexp->regmust || spat->spat_regexp->reganch & ROPT_ANCH)
  790.          ) {
  791. -     spat->spat_short = spat->spat_regexp->regstart;
  792.       if (!(spat->spat_regexp->reganch & ROPT_ANCH))
  793.           spat->spat_flags |= SPAT_SCANFIRST;
  794.       }
  795.       else if (spat->spat_regexp->regmust) {/* is there a better short-circuit? */
  796.       if (spat->spat_short &&
  797. --- 1754,1764 ----
  798.       if (!spat->spat_short && spat->spat_regexp->regstart &&
  799.       (!spat->spat_regexp->regmust || spat->spat_regexp->reganch & ROPT_ANCH)
  800.          ) {
  801.       if (!(spat->spat_regexp->reganch & ROPT_ANCH))
  802.           spat->spat_flags |= SPAT_SCANFIRST;
  803. +     else if (spat->spat_flags & SPAT_FOLD)
  804. +         return;
  805. +     spat->spat_short = str_smake(spat->spat_regexp->regstart);
  806.       }
  807.       else if (spat->spat_regexp->regmust) {/* is there a better short-circuit? */
  808.       if (spat->spat_short &&
  809.  
  810. #### End of Patch 10 ####
  811. exit 0 # Just in case...
  812. -- 
  813. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  814. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  815. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  816. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  817.