home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5948 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  2.6 KB

  1. Path: sparky!uunet!sun-barr!west.West.Sun.COM!cronkite.Central.Sun.COM!sixgun.East.Sun.COM!matthew
  2. From: matthew@sunpix.East.Sun.COM (Matthew Stier - Sun NC Development Center)
  3. Newsgroups: comp.lang.perl
  4. Subject: Adding phincter into h2ph
  5. Date: 15 Sep 1992 17:49:48 GMT
  6. Organization: Sun Microsystems, Research Triangle Park, NC
  7. Lines: 86
  8. Distribution: world
  9. Message-ID: <1957nsINN8gt@sixgun.East.Sun.COM>
  10. NNTP-Posting-Host: superdave.east.sun.com
  11.  
  12.  
  13. Why scan thru the include files twice when once will do.
  14.  
  15. Most of the code in phincter appears to be grabbed directly from h2ph, so
  16. I just merged the 'phincter' uniq code back into h2ph, and now h2ph will
  17. try to grab all the include files it needs.
  18.  
  19. The first two segments of this patch implement phincter in h2ph.  The third
  20. fixes a logic flaw in the handling of '#if' statements, where the subroutine
  21. being called, is never declared.
  22.  
  23. c:
  24. #if defined(ALWAYS);      /* Testing if ALWAYS declared */
  25. #if (NEVER == 12);        /* NEVER is not declared      */
  26.  
  27. perl:
  28. if defined(&ALWAYS);      # Testing if ALWAYS declared
  29. if (&NEVER == 12)         # Perl tries to make a call to a subroutine 
  30.                           # that does not exist.
  31.  
  32. fixed perl:
  33. if defined(&ALWAYS);      # Testing if ALWAYS declared 
  34. if (eval '&NEVER' == 12); # Run thru eval, to catch if NEVER is not declared
  35.  
  36.  
  37. *** /depot/gnu/src/perl-4.035/h2ph    Fri Sep 11 23:28:27 1992
  38. --- ./h2ph    Tue Sep 15 12:56:25 1992
  39. ***************
  40. *** 19,24 ****
  41. --- 19,28 ----
  42.   @ARGV = ('-') unless @ARGV;
  43.   
  44.   foreach $file (@ARGV) {
  45. +     $known{$file} = 1;
  46. + }
  47. + while ($file = shift(@ARGV)) {
  48.       if ($file eq '-') {
  49.       open(IN, "-");
  50.       open(OUT, ">-");
  51. ***************
  52. *** 93,99 ****
  53.           }
  54.           }
  55.           elsif (/^include\s+<(.*)>/) {
  56. !         ($incl = $1) =~ s/\.h$/.ph/;
  57.           print OUT $t,"require '$incl';\n";
  58.           }
  59.           elsif (/^ifdef\s+(\w+)/) {
  60. --- 97,109 ----
  61.           }
  62.           }
  63.           elsif (/^include\s+<(.*)>/) {
  64. !         $incl = $1;
  65. !         if (!defined($known{$incl}) && $file ne '-') {
  66. !             # first encounter!  add to the list of arguments
  67. !             push(@ARGV, $incl);
  68. !             $known{$incl} = 1;
  69. !         }
  70. !         $incl =~ s/\.h$/.ph/;
  71.           print OUT $t,"require '$incl';\n";
  72.           }
  73.           elsif (/^ifdef\s+(\w+)/) {
  74. ***************
  75. *** 193,199 ****
  76.           }
  77.           }
  78.           else {
  79. !         $new .= ' &' . $id;
  80.           }
  81.           next;
  82.       };
  83. --- 203,209 ----
  84.           }
  85.           }
  86.           else {
  87. !         $new .= ($new =~ /defined\s*\($/ ? '&$id' : "eval '&$id'");
  88.           }
  89.           next;
  90.       };
  91.  
  92. -- 
  93. Matthew Lee Stier                          |
  94. Sun Microsystems ---  RTP, NC  27709-3447  |     "Wisconsin   Escapee"
  95. Email: matthew.stier@East.Sun.COM          |
  96. Phone: (919) 469-8300 fax: (919) 460-8355  | 
  97.