2 # Derive #define directives from specially formatted `case ...:' statements.
7 (my $VERSION = '$Revision: 1.3 $ ') =~ tr/[0-9].//cd;
8 (my $ME = $0) =~ s
|.*/||;
12 # Nobody ever checks the status of print()s. That's okay, because
13 # if any do fail, we're guaranteed to get an indicator when we close()
16 # Close stdout now, and if there were no errors, return happy status.
17 # If stdout has already been closed by the script, though, do nothing.
23 # Errors closing stdout. Indicate that, and hope stderr is OK.
24 warn "$ME: closing standard output: $!\n";
26 # Don't be so arrogant as to assume that we're the first END handler
27 # defined, and thus the last one invoked. There may be others yet
28 # to come. $? will be passed on to them, and to the final _exit().
30 # If it isn't already an error, make it one (and if it _is_ an error,
31 # preserve the value: it might be important).
38 my $STREAM = ($exit_code == 0 ?
*STDOUT
: *STDERR
);
41 print $STREAM "Try `$ME --help' for more information.\n";
46 Usage: $ME [OPTIONS] FILE
52 Derive #define directives from specially formatted `case ...:' statements.
54 --help display this help and exit
55 --version output version information and exit
65 help
=> sub { usage
0 },
66 version
=> sub { print "$ME version $VERSION\n"; exit },
72 and (warn "$ME: missing FILE arguments\n"), $fail = 1;
74 and (warn "$ME: too many arguments\n"), $fail = 1;
81 or die "$ME: can't open `$file' for reading: $!\n";
83 # For each line like this:
84 # case S_MAGIC_ROMFS: /* 0x7275 */
86 # # define S_MAGIC_ROMFS 0x7275
87 # Fail if there is a `case S_MAGIC_.*' line without
88 # a properly formed comment.
91 /* Define the magic numbers as given by statfs(2).
92 Please send additions to meskes\@debian.org.
93 This file is generated automatically from $file. */
98 while (defined (my $line = <FH
>))
100 $line =~ /^[ \t]+case S_MAGIC_/
102 $line =~ m!^[ \t]+case (S_MAGIC_\w+): /\* (0x[0-9A-Fa-f]+) \*/$!
103 or (warn "$ME:$file:$.: malformed case S_MAGIC_... line"),
107 print "# define $name $value\n";
111 #elif defined __GNU__
112 # include <hurd/hurd_types.h>