home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5864 < prev    next >
Encoding:
Text File  |  1992-09-11  |  3.7 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: Re: aub problem finding sys/socket.ph
  5. Message-ID: <1992Sep10.210105.9330@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. References: <5601@blue.cis.pitt.edu.UUCP> <1992Sep9.043504.7463@odin.corp.sgi.com> <5638@blue.cis.pitt.edu.UUCP> <1992Sep9.142703.12533@news.eng.convex.com>
  10. Date: Thu, 10 Sep 1992 21:01:05 GMT
  11. Lines: 102
  12.  
  13. In article <1992Sep9.142703.12533@news.eng.convex.com>, Tom Christiansen <tchrist@convex.COM> writes:
  14. >
  15. > Building all the *.ph files is something of a black art.  For 
  16. > any given *.h file, you first have to build every include 
  17. > file it itself includes, recursively.
  18.  
  19. Which is why I wrote and am reposting the following:
  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 Thu Sep 10 15:00:39 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             | "My ultimate nightmare?  Oh, that's an
  111.    (randall_krebs@mentorg.com)  |  easy one!  The McLaughlin group as dinner
  112.    Mentor Graphics Corp.        |  guests."
  113.    Murray, Utah                    |  
  114. Disclaimer:  Mentor Graphics pays me for what I do, not for what I say.
  115.