home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / contrib / perl4.036 / perl-4.036 / perl-4.036.diff2
Text File  |  1995-01-17  |  5KB  |  213 lines

  1. --- h2ph.man.orig    Tue Jan 17 22:19:16 1995
  2. +++ h2ph.man    Tue Jan 17 22:19:53 1995
  3. @@ -1,209 +1,3 @@
  4. -#!/usr/bin/perl
  5. -'di';
  6. -'ig00';
  7. -
  8. -$perlincl = '/usr/lib/perl4';
  9. -
  10. -chdir '/usr/include' || die "Can't cd /usr/include";
  11. -
  12. -@isatype = split(' ',<<END);
  13. -    char    uchar    u_char
  14. -    short    ushort    u_short
  15. -    int    uint    u_int
  16. -    long    ulong    u_long
  17. -    FILE
  18. -END
  19. -
  20. -@isatype{@isatype} = (1) x @isatype;
  21. -
  22. -@ARGV = ('-') unless @ARGV;
  23. -
  24. -foreach $file (@ARGV) {
  25. -    if ($file eq '-') {
  26. -    open(IN, "-");
  27. -    open(OUT, ">-");
  28. -    }
  29. -    else {
  30. -    ($outfile = $file) =~ s/\.h$/.ph/ || next;
  31. -    print "$file -> $outfile\n";
  32. -    if ($file =~ m|^(.*)/|) {
  33. -        $dir = $1;
  34. -        if (!-d "$perlincl/$dir") {
  35. -        mkdir("$perlincl/$dir",0777);
  36. -        }
  37. -    }
  38. -    open(IN,"$file") || ((warn "Can't open $file: $!\n"),next);
  39. -    open(OUT,">$perlincl/$outfile") || die "Can't create $outfile: $!\n";
  40. -    }
  41. -    while (<IN>) {
  42. -    chop;
  43. -    while (/\\$/) {
  44. -        chop;
  45. -        $_ .= <IN>;
  46. -        chop;
  47. -    }
  48. -    if (s:/\*:\200:g) {
  49. -        s:\*/:\201:g;
  50. -        s/\200[^\201]*\201//g;    # delete single line comments
  51. -        if (s/\200.*//) {        # begin multi-line comment?
  52. -        $_ .= '/*';
  53. -        $_ .= <IN>;
  54. -        redo;
  55. -        }
  56. -    }
  57. -    if (s/^#\s*//) {
  58. -        if (s/^define\s+(\w+)//) {
  59. -        $name = $1;
  60. -        $new = '';
  61. -        s/\s+$//;
  62. -        if (s/^\(([\w,\s]*)\)//) {
  63. -            $args = $1;
  64. -            if ($args ne '') {
  65. -            foreach $arg (split(/,\s*/,$args)) {
  66. -                $arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/;
  67. -                $curargs{$arg} = 1;
  68. -            }
  69. -            $args =~ s/\b(\w)/\$$1/g;
  70. -            $args = "local($args) = \@_;\n$t    ";
  71. -            }
  72. -            s/^\s+//;
  73. -            do expr();
  74. -            $new =~ s/(["\\])/\\$1/g;
  75. -            if ($t ne '') {
  76. -            $new =~ s/(['\\])/\\$1/g;
  77. -            print OUT $t,
  78. -              "eval 'sub $name {\n$t    ${args}eval \"$new\";\n$t}';\n";
  79. -            }
  80. -            else {
  81. -            print OUT "sub $name {\n    ${args}eval \"$new\";\n}\n";
  82. -            }
  83. -            %curargs = ();
  84. -        }
  85. -        else {
  86. -            s/^\s+//;
  87. -            do expr();
  88. -            $new = 1 if $new eq '';
  89. -            if ($t ne '') {
  90. -            $new =~ s/(['\\])/\\$1/g;
  91. -            print OUT $t,"eval 'sub $name {",$new,";}';\n";
  92. -            }
  93. -            else {
  94. -            print OUT $t,"sub $name {",$new,";}\n";
  95. -            }
  96. -        }
  97. -        }
  98. -        elsif (/^include\s+<(.*)>/) {
  99. -        ($incl = $1) =~ s/\.h$/.ph/;
  100. -        print OUT $t,"require '$incl';\n";
  101. -        }
  102. -        elsif (/^ifdef\s+(\w+)/) {
  103. -        print OUT $t,"if (defined &$1) {\n";
  104. -        $tab += 4;
  105. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  106. -        }
  107. -        elsif (/^ifndef\s+(\w+)/) {
  108. -        print OUT $t,"if (!defined &$1) {\n";
  109. -        $tab += 4;
  110. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  111. -        }
  112. -        elsif (s/^if\s+//) {
  113. -        $new = '';
  114. -        do expr();
  115. -        print OUT $t,"if ($new) {\n";
  116. -        $tab += 4;
  117. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  118. -        }
  119. -        elsif (s/^elif\s+//) {
  120. -        $new = '';
  121. -        do expr();
  122. -        $tab -= 4;
  123. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  124. -        print OUT $t,"}\n${t}elsif ($new) {\n";
  125. -        $tab += 4;
  126. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  127. -        }
  128. -        elsif (/^else/) {
  129. -        $tab -= 4;
  130. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  131. -        print OUT $t,"}\n${t}else {\n";
  132. -        $tab += 4;
  133. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  134. -        }
  135. -        elsif (/^endif/) {
  136. -        $tab -= 4;
  137. -        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  138. -        print OUT $t,"}\n";
  139. -        }
  140. -    }
  141. -    }
  142. -    print OUT "1;\n";
  143. -}
  144. -
  145. -sub expr {
  146. -    while ($_ ne '') {
  147. -    s/^(\s+)//        && do {$new .= ' '; next;};
  148. -    s/^(0x[0-9a-fA-F]+)//    && do {$new .= $1; next;};
  149. -    s/^(\d+)//        && do {$new .= $1; next;};
  150. -    s/^("(\\"|[^"])*")//    && do {$new .= $1; next;};
  151. -    s/^'((\\"|[^"])*)'//    && do {
  152. -        if ($curargs{$1}) {
  153. -        $new .= "ord('\$$1')";
  154. -        }
  155. -        else {
  156. -        $new .= "ord('$1')";
  157. -        }
  158. -        next;
  159. -    };
  160. -    s/^sizeof\s*\(([^)]+)\)/{$1}/ && do {
  161. -        $new .= '$sizeof';
  162. -        next;
  163. -    };
  164. -    s/^([_a-zA-Z]\w*)//    && do {
  165. -        $id = $1;
  166. -        if ($id eq 'struct') {
  167. -        s/^\s+(\w+)//;
  168. -        $id .= ' ' . $1;
  169. -        $isatype{$id} = 1;
  170. -        }
  171. -        elsif ($id eq 'unsigned') {
  172. -        s/^\s+(\w+)//;
  173. -        $id .= ' ' . $1;
  174. -        $isatype{$id} = 1;
  175. -        }
  176. -        if ($curargs{$id}) {
  177. -        $new .= '$' . $id;
  178. -        }
  179. -        elsif ($id eq 'defined') {
  180. -        $new .= 'defined';
  181. -        }
  182. -        elsif (/^\(/) {
  183. -        s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i;    # cheat
  184. -        $new .= " &$id";
  185. -        }
  186. -        elsif ($isatype{$id}) {
  187. -        if ($new =~ /{\s*$/) {
  188. -            $new .= "'$id'";
  189. -        }
  190. -        elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) {
  191. -            $new =~ s/\(\s*$//;
  192. -            s/^[\s*]*\)//;
  193. -        }
  194. -        else {
  195. -            $new .= $id;
  196. -        }
  197. -        }
  198. -        else {
  199. -        $new .= ' &' . $id;
  200. -        }
  201. -        next;
  202. -    };
  203. -    s/^(.)//            && do {$new .= $1; next;};
  204. -    }
  205. -}
  206. -##############################################################################
  207. -
  208. -    # These next few lines are legal in both Perl and nroff.
  209. -
  210.  .00;            # finish .ig
  211.   
  212.  'di            \" finish diversion--previous line must be blank
  213.