home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4955 < prev    next >
Encoding:
Text File  |  1992-07-25  |  3.8 KB  |  115 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!news.mentorg.com!caeco!riffraff!randall
  3. From: randall@riffraff.slc.mentorg.com (Randall S. Krebs)
  4. Subject: PHind INCludes until TERmination
  5. Message-ID: <1992Jul24.200541.13836@caeco.mentorg.com>
  6. Sender: randall@riffraff (Randall S. Krebs)
  7. Reply-To: randall_krebs@mentorg.com
  8. Organization: Mentor Graphics Corp.,  Murray, Utah
  9. Date: Fri, 24 Jul 1992 20:05:41 GMT
  10. Lines: 103
  11.  
  12. Every time I take perl to a new platform, I struggle to find the "right"
  13. header files from /usr/include/... to install under /usr/local/lib/perl/...
  14.  
  15. Sure, "h2ph *.h sys/*.h" takes care of 99% of them, but I'm anal-retentive.
  16. (Ergo, the program name?!)  I just can't sleep at night knowing that one
  17. of those damn .ph files may depend on a file that hasn't been converted
  18. yet.  Anyway, maybe Larry would consider adding something like this to
  19. the installperl script (like maybe you didn't have enough to do?).
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of shell archive."
  28. # Contents:  phincter
  29. # Wrapped by randall@riffraff on Fri Jul 24 13:39:53 1992
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'phincter' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'phincter'\"
  33. else
  34. echo shar: Extracting \"'phincter'\" \(1613 characters\)
  35. sed "s/^X//" >'phincter' <<'END_OF_FILE'
  36. X#!/usr/bin/perl
  37. X#
  38. X# phincter - PHind INCludes until TERmination
  39. X#
  40. X# This program should be run from /usr/include (or your standard include
  41. X# file directory if deviant).  It takes a list of header file names on the
  42. X# command line and produces the same list of file names plus any included
  43. X# header file names on the standard output.
  44. X#
  45. X# Phincter is intended to be used during perl installation as follows:
  46. X#
  47. X#   # cd /usr/include
  48. X#   # h2ph `phincter *.h sys/*.h`
  49. X#
  50. X# This will convert all standard header files in /usr/include and
  51. X# /usr/include/sys PLUS any standard header files that they include.
  52. X# That way, you are less likely to have missing .ph files months down
  53. X# the road when you really need them.
  54. X
  55. X# record that we've already seen the files on the argument list
  56. X@known{@ARGV} = (1) x @ARGV;
  57. X
  58. Xwhile ($file = shift(@ARGV)) {
  59. X    # skip file if it doesn't exist
  60. X    $file =~ /\.h$/ || next;
  61. X    open(IN,"$file") || ((warn "Can't open $file: $!\n"),next);
  62. X
  63. X    # output this file name
  64. X    print "$file\n";
  65. X
  66. X    # look thru the file for #include's
  67. X    while (<IN>) {
  68. X    chop;
  69. X    while (/\\$/) {
  70. X        chop;
  71. X        $_ .= <IN>;
  72. X        chop;
  73. X    }
  74. X    # ignore comments
  75. X    if (s:/\*:\200:g) {
  76. X        s:\*/:\201:g;
  77. X        s/\200[^\201]*\201//g;    # delete single line comments
  78. X        if (s/\200.*//) {        # begin multi-line comment?
  79. X        $_ .= '/*';
  80. X        $_ .= <IN>;
  81. X        redo;
  82. X        }
  83. X    }
  84. X    # handle the #include'd file
  85. X    if (s/^#\s*//) {
  86. X        if (/^include\s+<(.*)>/) {
  87. X        $f = $1;
  88. X        if (!defined($known{$f})) {
  89. X            # first encounter!  add to the list of arguments
  90. X            push(@ARGV, $f);
  91. X            $known{$f} = 1;
  92. X        }
  93. X        }
  94. X    }
  95. X    }
  96. X    close(IN);
  97. X}
  98. X
  99. END_OF_FILE
  100. if test 1613 -ne `wc -c <'phincter'`; then
  101.     echo shar: \"'phincter'\" unpacked with wrong size!
  102. fi
  103. chmod +x 'phincter'
  104. # end of 'phincter'
  105. fi
  106. echo shar: End of shell archive.
  107. exit 0
  108.  
  109. -- 
  110.    Randall S. Krebs             | A chicken is the egg's way of making more
  111.    (randall_krebs@mentorg.com)  | eggs.  Government is anarchy's way of making
  112.    Mentor Graphics Corp.        | more anarchy.
  113.    Murray, Utah                    |              - Simon Moon -
  114. Disclaimer:  Mentor Graphics pays me for what I do, not for what I say.
  115.