Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

835 lines
16 KiB

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S %0 %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  11. goto endofperl
  12. @rem ';
  13. #!perl
  14. #line 15
  15. eval 'exec C:\Perl\bin\perl.exe -S $0 ${1+"$@"}'
  16. if $running_under_some_shell;
  17. ($startperl = <<'/../') =~ s/\s*\z//;
  18. #!perl
  19. /../
  20. ($perlpath = <<'/../') =~ s/\s*\z//;
  21. C:\Perl\bin\perl.exe
  22. /../
  23. # $RCSfile: s2p.SH,v $$Revision: 4.1 $$Date: 92/08/07 18:29:23 $
  24. #
  25. # $Log: s2p.SH,v $
  26. =head1 NAME
  27. s2p - Sed to Perl translator
  28. =head1 SYNOPSIS
  29. B<s2p [options] filename>
  30. =head1 DESCRIPTION
  31. I<s2p> takes a sed script specified on the command line (or from
  32. standard input) and produces a comparable I<perl> script on the
  33. standard output.
  34. =head2 Options
  35. Options include:
  36. =over 5
  37. =item B<-DE<lt>numberE<gt>>
  38. sets debugging flags.
  39. =item B<-n>
  40. specifies that this sed script was always invoked with a B<sed -n>.
  41. Otherwise a switch parser is prepended to the front of the script.
  42. =item B<-p>
  43. specifies that this sed script was never invoked with a B<sed -n>.
  44. Otherwise a switch parser is prepended to the front of the script.
  45. =back
  46. =head2 Considerations
  47. The perl script produced looks very sed-ish, and there may very well
  48. be better ways to express what you want to do in perl. For instance,
  49. s2p does not make any use of the split operator, but you might want
  50. to.
  51. The perl script you end up with may be either faster or slower than
  52. the original sed script. If you're only interested in speed you'll
  53. just have to try it both ways. Of course, if you want to do something
  54. sed doesn't do, you have no choice. It's often possible to speed up
  55. the perl script by various methods, such as deleting all references to
  56. $\ and chop.
  57. =head1 ENVIRONMENT
  58. s2p uses no environment variables.
  59. =head1 AUTHOR
  60. Larry Wall E<lt>F<[email protected]>E<gt>
  61. =head1 FILES
  62. =head1 SEE ALSO
  63. perl The perl compiler/interpreter
  64. a2p awk to perl translator
  65. =head1 DIAGNOSTICS
  66. =head1 BUGS
  67. =cut
  68. $indent = 4;
  69. $shiftwidth = 4;
  70. $l = '{'; $r = '}';
  71. while ($ARGV[0] =~ /^-/) {
  72. $_ = shift;
  73. last if /^--/;
  74. if (/^-D/) {
  75. $debug++;
  76. open(BODY,'>-');
  77. next;
  78. }
  79. if (/^-n/) {
  80. $assumen++;
  81. next;
  82. }
  83. if (/^-p/) {
  84. $assumep++;
  85. next;
  86. }
  87. die "I don't recognize this switch: $_\n";
  88. }
  89. unless ($debug) {
  90. open(BODY,"+>/tmp/sperl$$") ||
  91. &Die("Can't open temp file: $!\n");
  92. }
  93. if (!$assumen && !$assumep) {
  94. print BODY &q(<<'EOT');
  95. : while ($ARGV[0] =~ /^-/) {
  96. : $_ = shift;
  97. : last if /^--/;
  98. : if (/^-n/) {
  99. : $nflag++;
  100. : next;
  101. : }
  102. : die "I don't recognize this switch: $_\\n";
  103. : }
  104. :
  105. EOT
  106. }
  107. print BODY &q(<<'EOT');
  108. : #ifdef PRINTIT
  109. : #ifdef ASSUMEP
  110. : $printit++;
  111. : #else
  112. : $printit++ unless $nflag;
  113. : #endif
  114. : #endif
  115. : <><>
  116. : $\ = "\n"; # automatically add newline on print
  117. : <><>
  118. : #ifdef TOPLABEL
  119. : LINE:
  120. : while (chop($_ = <>)) {
  121. : #else
  122. : LINE:
  123. : while (<>) {
  124. : chop;
  125. : #endif
  126. EOT
  127. LINE:
  128. while (<>) {
  129. # Wipe out surrounding whitespace.
  130. s/[ \t]*(.*)\n$/$1/;
  131. # Perhaps it's a label/comment.
  132. if (/^:/) {
  133. s/^:[ \t]*//;
  134. $label = &make_label($_);
  135. if ($. == 1) {
  136. $toplabel = $label;
  137. if (/^(top|(re)?start|redo|begin(ning)|again|input)$/i) {
  138. $_ = <>;
  139. redo LINE; # Never referenced, so delete it if not a comment.
  140. }
  141. }
  142. $_ = "$label:";
  143. if ($lastlinewaslabel++) {
  144. $indent += 4;
  145. print BODY &tab, ";\n";
  146. $indent -= 4;
  147. }
  148. if ($indent >= 2) {
  149. $indent -= 2;
  150. $indmod = 2;
  151. }
  152. next;
  153. } else {
  154. $lastlinewaslabel = '';
  155. }
  156. # Look for one or two address clauses
  157. $addr1 = '';
  158. $addr2 = '';
  159. if (s/^([0-9]+)//) {
  160. $addr1 = "$1";
  161. $addr1 = "\$. == $addr1" unless /^,/;
  162. }
  163. elsif (s/^\$//) {
  164. $addr1 = 'eof()';
  165. }
  166. elsif (s|^/||) {
  167. $addr1 = &fetchpat('/');
  168. }
  169. if (s/^,//) {
  170. if (s/^([0-9]+)//) {
  171. $addr2 = "$1";
  172. } elsif (s/^\$//) {
  173. $addr2 = "eof()";
  174. } elsif (s|^/||) {
  175. $addr2 = &fetchpat('/');
  176. } else {
  177. &Die("Invalid second address at line $.\n");
  178. }
  179. if ($addr2 =~ /^\d+$/) {
  180. $addr1 .= "..$addr2";
  181. }
  182. else {
  183. $addr1 .= "...$addr2";
  184. }
  185. }
  186. # Now we check for metacommands {, }, and ! and worry
  187. # about indentation.
  188. s/^[ \t]+//;
  189. # a { to keep vi happy
  190. if ($_ eq '}') {
  191. $indent -= 4;
  192. next;
  193. }
  194. if (s/^!//) {
  195. $if = 'unless';
  196. $else = "$r else $l\n";
  197. } else {
  198. $if = 'if';
  199. $else = '';
  200. }
  201. if (s/^{//) { # a } to keep vi happy
  202. $indmod = 4;
  203. $redo = $_;
  204. $_ = '';
  205. $rmaybe = '';
  206. } else {
  207. $rmaybe = "\n$r";
  208. if ($addr2 || $addr1) {
  209. $space = ' ' x $shiftwidth;
  210. } else {
  211. $space = '';
  212. }
  213. $_ = &transmogrify();
  214. }
  215. # See if we can optimize to modifier form.
  216. if ($addr1) {
  217. if ($_ !~ /[\n{}]/ && $rmaybe && !$change &&
  218. $_ !~ / if / && $_ !~ / unless /) {
  219. s/;$/ $if $addr1;/;
  220. $_ = substr($_,$shiftwidth,1000);
  221. } else {
  222. $_ = "$if ($addr1) $l\n$change$_$rmaybe";
  223. }
  224. $change = '';
  225. next LINE;
  226. }
  227. } continue {
  228. @lines = split(/\n/,$_);
  229. for (@lines) {
  230. unless (s/^ *<<--//) {
  231. print BODY &tab;
  232. }
  233. print BODY $_, "\n";
  234. }
  235. $indent += $indmod;
  236. $indmod = 0;
  237. if ($redo) {
  238. $_ = $redo;
  239. $redo = '';
  240. redo LINE;
  241. }
  242. }
  243. if ($lastlinewaslabel++) {
  244. $indent += 4;
  245. print BODY &tab, ";\n";
  246. $indent -= 4;
  247. }
  248. if ($appendseen || $tseen || !$assumen) {
  249. $printit++ if $dseen || (!$assumen && !$assumep);
  250. print BODY &q(<<'EOT');
  251. : #ifdef SAWNEXT
  252. : }
  253. : continue {
  254. : #endif
  255. : #ifdef PRINTIT
  256. : #ifdef DSEEN
  257. : #ifdef ASSUMEP
  258. : print if $printit++;
  259. : #else
  260. : if ($printit)
  261. : { print; }
  262. : else
  263. : { $printit++ unless $nflag; }
  264. : #endif
  265. : #else
  266. : print if $printit;
  267. : #endif
  268. : #else
  269. : print;
  270. : #endif
  271. : #ifdef TSEEN
  272. : $tflag = 0;
  273. : #endif
  274. : #ifdef APPENDSEEN
  275. : if ($atext) { chop $atext; print $atext; $atext = ''; }
  276. : #endif
  277. EOT
  278. }
  279. print BODY &q(<<'EOT');
  280. : }
  281. EOT
  282. unless ($debug) {
  283. print &q(<<"EOT");
  284. : $startperl
  285. : eval 'exec $perlpath -S \$0 \${1+"\$@"}'
  286. : if \$running_under_some_shell;
  287. :
  288. EOT
  289. print"$opens\n" if $opens;
  290. seek(BODY, 0, 0) || die "Can't rewind temp file: $!\n";
  291. while (<BODY>) {
  292. /^[ \t]*$/ && next;
  293. /^#ifdef (\w+)/ && ((${lc $1} || &skip), next);
  294. /^#else/ && (&skip, next);
  295. /^#endif/ && next;
  296. s/^<><>//;
  297. print;
  298. }
  299. }
  300. &Cleanup;
  301. exit;
  302. sub Cleanup {
  303. unlink "/tmp/sperl$$";
  304. }
  305. sub Die {
  306. &Cleanup;
  307. die $_[0];
  308. }
  309. sub tab {
  310. "\t" x ($indent / 8) . ' ' x ($indent % 8);
  311. }
  312. sub make_filehandle {
  313. local($_) = $_[0];
  314. local($fname) = $_;
  315. if (!$seen{$fname}) {
  316. $_ = "FH_" . $_ if /^\d/;
  317. s/[^a-zA-Z0-9]/_/g;
  318. s/^_*//;
  319. $_ = "\U$_";
  320. if ($fhseen{$_}) {
  321. for ($tmp = "a"; $fhseen{"$_$tmp"}; $a++) {}
  322. $_ .= $tmp;
  323. }
  324. $fhseen{$_} = 1;
  325. $opens .= &q(<<"EOT");
  326. : open($_, '>$fname') || die "Can't create $fname: \$!";
  327. EOT
  328. $seen{$fname} = $_;
  329. }
  330. $seen{$fname};
  331. }
  332. sub make_label {
  333. local($label) = @_;
  334. $label =~ s/[^a-zA-Z0-9]/_/g;
  335. if ($label =~ /^[0-9_]/) { $label = 'L' . $label; }
  336. $label = substr($label,0,8);
  337. # Could be a reserved word, so capitalize it.
  338. substr($label,0,1) =~ y/a-z/A-Z/
  339. if $label =~ /^[a-z]/;
  340. $label;
  341. }
  342. sub transmogrify {
  343. { # case
  344. if (/^d/) {
  345. $dseen++;
  346. chop($_ = &q(<<'EOT'));
  347. : <<--#ifdef PRINTIT
  348. : $printit = 0;
  349. : <<--#endif
  350. : next LINE;
  351. EOT
  352. $sawnext++;
  353. next;
  354. }
  355. if (/^n/) {
  356. chop($_ = &q(<<'EOT'));
  357. : <<--#ifdef PRINTIT
  358. : <<--#ifdef DSEEN
  359. : <<--#ifdef ASSUMEP
  360. : print if $printit++;
  361. : <<--#else
  362. : if ($printit)
  363. : { print; }
  364. : else
  365. : { $printit++ unless $nflag; }
  366. : <<--#endif
  367. : <<--#else
  368. : print if $printit;
  369. : <<--#endif
  370. : <<--#else
  371. : print;
  372. : <<--#endif
  373. : <<--#ifdef APPENDSEEN
  374. : if ($atext) {chop $atext; print $atext; $atext = '';}
  375. : <<--#endif
  376. : $_ = <>;
  377. : chop;
  378. : <<--#ifdef TSEEN
  379. : $tflag = 0;
  380. : <<--#endif
  381. EOT
  382. next;
  383. }
  384. if (/^a/) {
  385. $appendseen++;
  386. $command = $space . "\$atext .= <<'End_Of_Text';\n<<--";
  387. $lastline = 0;
  388. while (<>) {
  389. s/^[ \t]*//;
  390. s/^[\\]//;
  391. unless (s|\\$||) { $lastline = 1;}
  392. s/^([ \t]*\n)/<><>$1/;
  393. $command .= $_;
  394. $command .= '<<--';
  395. last if $lastline;
  396. }
  397. $_ = $command . "End_Of_Text";
  398. last;
  399. }
  400. if (/^[ic]/) {
  401. if (/^c/) { $change = 1; }
  402. $addr1 = 1 if $addr1 eq '';
  403. $addr1 = '$iter = (' . $addr1 . ')';
  404. $command = $space .
  405. " if (\$iter == 1) { print <<'End_Of_Text'; }\n<<--";
  406. $lastline = 0;
  407. while (<>) {
  408. s/^[ \t]*//;
  409. s/^[\\]//;
  410. unless (s/\\$//) { $lastline = 1;}
  411. s/'/\\'/g;
  412. s/^([ \t]*\n)/<><>$1/;
  413. $command .= $_;
  414. $command .= '<<--';
  415. last if $lastline;
  416. }
  417. $_ = $command . "End_Of_Text";
  418. if ($change) {
  419. $dseen++;
  420. $change = "$_\n";
  421. chop($_ = &q(<<"EOT"));
  422. : <<--#ifdef PRINTIT
  423. : $space\$printit = 0;
  424. : <<--#endif
  425. : ${space}next LINE;
  426. EOT
  427. $sawnext++;
  428. }
  429. last;
  430. }
  431. if (/^s/) {
  432. $delim = substr($_,1,1);
  433. $len = length($_);
  434. $repl = $end = 0;
  435. $inbracket = 0;
  436. for ($i = 2; $i < $len; $i++) {
  437. $c = substr($_,$i,1);
  438. if ($c eq $delim) {
  439. if ($inbracket) {
  440. substr($_, $i, 0) = '\\';
  441. $i++;
  442. $len++;
  443. }
  444. else {
  445. if ($repl) {
  446. $end = $i;
  447. last;
  448. } else {
  449. $repl = $i;
  450. }
  451. }
  452. }
  453. elsif ($c eq '\\') {
  454. $i++;
  455. if ($i >= $len) {
  456. $_ .= 'n';
  457. $_ .= <>;
  458. $len = length($_);
  459. $_ = substr($_,0,--$len);
  460. }
  461. elsif (substr($_,$i,1) =~ /^[n]$/) {
  462. ;
  463. }
  464. elsif (!$repl &&
  465. substr($_,$i,1) =~ /^[(){}\w]$/) {
  466. $i--;
  467. $len--;
  468. substr($_, $i, 1) = '';
  469. }
  470. elsif (!$repl &&
  471. substr($_,$i,1) =~ /^[<>]$/) {
  472. substr($_,$i,1) = 'b';
  473. }
  474. elsif ($repl && substr($_,$i,1) =~ /^\d$/) {
  475. substr($_,$i-1,1) = '$';
  476. }
  477. }
  478. elsif ($c eq '@') {
  479. substr($_, $i, 0) = '\\';
  480. $i++;
  481. $len++;
  482. }
  483. elsif ($c eq '&' && $repl) {
  484. substr($_, $i, 0) = '$';
  485. $i++;
  486. $len++;
  487. }
  488. elsif ($c eq '$' && $repl) {
  489. substr($_, $i, 0) = '\\';
  490. $i++;
  491. $len++;
  492. }
  493. elsif ($c eq '[' && !$repl) {
  494. $i++ if substr($_,$i,1) eq '^';
  495. $i++ if substr($_,$i,1) eq ']';
  496. $inbracket = 1;
  497. }
  498. elsif ($c eq ']') {
  499. $inbracket = 0;
  500. }
  501. elsif ($c eq "\t") {
  502. substr($_, $i, 1) = '\\t';
  503. $i++;
  504. $len++;
  505. }
  506. elsif (!$repl && index("()+",$c) >= 0) {
  507. substr($_, $i, 0) = '\\';
  508. $i++;
  509. $len++;
  510. }
  511. }
  512. &Die("Malformed substitution at line $.\n")
  513. unless $end;
  514. $pat = substr($_, 0, $repl + 1);
  515. $repl = substr($_, $repl+1, $end-$repl-1);
  516. $end = substr($_, $end + 1, 1000);
  517. &simplify($pat);
  518. $subst = "$pat$repl$delim";
  519. $cmd = '';
  520. while ($end) {
  521. if ($end =~ s/^g//) {
  522. $subst .= 'g';
  523. next;
  524. }
  525. if ($end =~ s/^p//) {
  526. $cmd .= ' && (print)';
  527. next;
  528. }
  529. if ($end =~ s/^w[ \t]*//) {
  530. $fh = &make_filehandle($end);
  531. $cmd .= " && (print $fh \$_)";
  532. $end = '';
  533. next;
  534. }
  535. &Die("Unrecognized substitution command".
  536. "($end) at line $.\n");
  537. }
  538. chop ($_ = &q(<<"EOT"));
  539. : <<--#ifdef TSEEN
  540. : $subst && \$tflag++$cmd;
  541. : <<--#else
  542. : $subst$cmd;
  543. : <<--#endif
  544. EOT
  545. next;
  546. }
  547. if (/^p/) {
  548. $_ = 'print;';
  549. next;
  550. }
  551. if (/^w/) {
  552. s/^w[ \t]*//;
  553. $fh = &make_filehandle($_);
  554. $_ = "print $fh \$_;";
  555. next;
  556. }
  557. if (/^r/) {
  558. $appendseen++;
  559. s/^r[ \t]*//;
  560. $file = $_;
  561. $_ = "\$atext .= `cat $file 2>/dev/null`;";
  562. next;
  563. }
  564. if (/^P/) {
  565. $_ = 'print $1 if /^(.*)/;';
  566. next;
  567. }
  568. if (/^D/) {
  569. chop($_ = &q(<<'EOT'));
  570. : s/^.*\n?//;
  571. : redo LINE if $_;
  572. : next LINE;
  573. EOT
  574. $sawnext++;
  575. next;
  576. }
  577. if (/^N/) {
  578. chop($_ = &q(<<'EOT'));
  579. : $_ .= "\n";
  580. : $len1 = length;
  581. : $_ .= <>;
  582. : chop if $len1 < length;
  583. : <<--#ifdef TSEEN
  584. : $tflag = 0;
  585. : <<--#endif
  586. EOT
  587. next;
  588. }
  589. if (/^h/) {
  590. $_ = '$hold = $_;';
  591. next;
  592. }
  593. if (/^H/) {
  594. $_ = '$hold .= "\n", $hold .= $_;';
  595. next;
  596. }
  597. if (/^g/) {
  598. $_ = '$_ = $hold;';
  599. next;
  600. }
  601. if (/^G/) {
  602. $_ = '$_ .= "\n", $_ .= $hold;';
  603. next;
  604. }
  605. if (/^x/) {
  606. $_ = '($_, $hold) = ($hold, $_);';
  607. next;
  608. }
  609. if (/^b$/) {
  610. $_ = 'next LINE;';
  611. $sawnext++;
  612. next;
  613. }
  614. if (/^b/) {
  615. s/^b[ \t]*//;
  616. $lab = &make_label($_);
  617. if ($lab eq $toplabel) {
  618. $_ = 'redo LINE;';
  619. } else {
  620. $_ = "goto $lab;";
  621. }
  622. next;
  623. }
  624. if (/^t$/) {
  625. $_ = 'next LINE if $tflag;';
  626. $sawnext++;
  627. $tseen++;
  628. next;
  629. }
  630. if (/^t/) {
  631. s/^t[ \t]*//;
  632. $lab = &make_label($_);
  633. $_ = q/if ($tflag) {$tflag = 0; /;
  634. if ($lab eq $toplabel) {
  635. $_ .= 'redo LINE;}';
  636. } else {
  637. $_ .= "goto $lab;}";
  638. }
  639. $tseen++;
  640. next;
  641. }
  642. if (/^y/) {
  643. s/abcdefghijklmnopqrstuvwxyz/a-z/g;
  644. s/ABCDEFGHIJKLMNOPQRSTUVWXYZ/A-Z/g;
  645. s/abcdef/a-f/g;
  646. s/ABCDEF/A-F/g;
  647. s/0123456789/0-9/g;
  648. s/01234567/0-7/g;
  649. $_ .= ';';
  650. }
  651. if (/^=/) {
  652. $_ = 'print $.;';
  653. next;
  654. }
  655. if (/^q/) {
  656. chop($_ = &q(<<'EOT'));
  657. : close(ARGV);
  658. : @ARGV = ();
  659. : next LINE;
  660. EOT
  661. $sawnext++;
  662. next;
  663. }
  664. } continue {
  665. if ($space) {
  666. s/^/$space/;
  667. s/(\n)(.)/$1$space$2/g;
  668. }
  669. last;
  670. }
  671. $_;
  672. }
  673. sub fetchpat {
  674. local($outer) = @_;
  675. local($addr) = $outer;
  676. local($inbracket);
  677. local($prefix,$delim,$ch);
  678. # Process pattern one potential delimiter at a time.
  679. DELIM: while (s#^([^\]+(|)[\\/]*)([]+(|)[\\/])##) {
  680. $prefix = $1;
  681. $delim = $2;
  682. if ($delim eq '\\') {
  683. s/(.)//;
  684. $ch = $1;
  685. $delim = '' if $ch =~ /^[(){}A-Za-mo-z]$/;
  686. $ch = 'b' if $ch =~ /^[<>]$/;
  687. $delim .= $ch;
  688. }
  689. elsif ($delim eq '[') {
  690. $inbracket = 1;
  691. s/^\^// && ($delim .= '^');
  692. s/^]// && ($delim .= ']');
  693. }
  694. elsif ($delim eq ']') {
  695. $inbracket = 0;
  696. }
  697. elsif ($inbracket || $delim ne $outer) {
  698. $delim = '\\' . $delim;
  699. }
  700. $addr .= $prefix;
  701. $addr .= $delim;
  702. if ($delim eq $outer && !$inbracket) {
  703. last DELIM;
  704. }
  705. }
  706. $addr =~ s/\t/\\t/g;
  707. $addr =~ s/\@/\\@/g;
  708. &simplify($addr);
  709. $addr;
  710. }
  711. sub q {
  712. local($string) = @_;
  713. local($*) = 1;
  714. $string =~ s/^:\t?//g;
  715. $string;
  716. }
  717. sub simplify {
  718. $_[0] =~ s/_a-za-z0-9/\\w/ig;
  719. $_[0] =~ s/a-z_a-z0-9/\\w/ig;
  720. $_[0] =~ s/a-za-z_0-9/\\w/ig;
  721. $_[0] =~ s/a-za-z0-9_/\\w/ig;
  722. $_[0] =~ s/_0-9a-za-z/\\w/ig;
  723. $_[0] =~ s/0-9_a-za-z/\\w/ig;
  724. $_[0] =~ s/0-9a-z_a-z/\\w/ig;
  725. $_[0] =~ s/0-9a-za-z_/\\w/ig;
  726. $_[0] =~ s/\[\\w\]/\\w/g;
  727. $_[0] =~ s/\[^\\w\]/\\W/g;
  728. $_[0] =~ s/\[0-9\]/\\d/g;
  729. $_[0] =~ s/\[^0-9\]/\\D/g;
  730. $_[0] =~ s/\\d\\d\*/\\d+/g;
  731. $_[0] =~ s/\\D\\D\*/\\D+/g;
  732. $_[0] =~ s/\\w\\w\*/\\w+/g;
  733. $_[0] =~ s/\\t\\t\*/\\t+/g;
  734. $_[0] =~ s/(\[.[^]]*\])\1\*/$1+/g;
  735. $_[0] =~ s/([\w\s!@#%^&-=,:;'"])\1\*/$1+/g;
  736. }
  737. sub skip {
  738. local($level) = 0;
  739. while(<BODY>) {
  740. /^#ifdef/ && $level++;
  741. /^#else/ && !$level && return;
  742. /^#endif/ && !$level-- && return;
  743. }
  744. die "Unterminated `#ifdef' conditional\n";
  745. }
  746. __END__
  747. :endofperl