Require bison and flex
These are needed only during development cycle, as the created sources are included in the tarball. * am/bison.m4: New file. * am/flex.m4: New file. * configure.ac: Use MU_PROG_BISON and MU_PROG_FLEX * mu-aux/gylwrap: Drop support for alternative command line syntax and the --stdout option.
Showing
5 changed files
with
54 additions
and
83 deletions
am/bison.m4
0 → 100644
am/flex.m4
0 → 100644
... | @@ -72,7 +72,7 @@ AC_SUBST(MU_LIB_COMMON_INCLUDES,'-I${top_builddir} -I${top_srcdir}/include -I${ | ... | @@ -72,7 +72,7 @@ AC_SUBST(MU_LIB_COMMON_INCLUDES,'-I${top_builddir} -I${top_srcdir}/include -I${ |
72 | AC_SUBST(MU_APP_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_srcdir}/lib/gnu -I${top_builddir}/lib/gnu -I${top_builddir} -I${top_builddir}/include') | 72 | AC_SUBST(MU_APP_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_srcdir}/lib/gnu -I${top_builddir}/lib/gnu -I${top_builddir} -I${top_builddir}/include') |
73 | 73 | ||
74 | # Use our replacement for the ylwrap tool | 74 | # Use our replacement for the ylwrap tool |
75 | AC_SUBST([MU_YLWRAP],'$(mu_aux_dir)/gylwrap --compatibility --') | 75 | AC_SUBST([MU_YLWRAP],'$(mu_aux_dir)/gylwrap --') |
76 | 76 | ||
77 | dnl Check for programs | 77 | dnl Check for programs |
78 | AC_PROG_CC | 78 | AC_PROG_CC |
... | @@ -83,8 +83,8 @@ AC_PROG_INSTALL | ... | @@ -83,8 +83,8 @@ AC_PROG_INSTALL |
83 | AC_PROG_LN_S | 83 | AC_PROG_LN_S |
84 | AC_LIBTOOL_DLOPEN | 84 | AC_LIBTOOL_DLOPEN |
85 | AC_PROG_LIBTOOL | 85 | AC_PROG_LIBTOOL |
86 | AC_PROG_YACC | 86 | MU_PROG_BISON |
87 | AM_PROG_LEX | 87 | MU_PROG_LEX |
88 | AM_PROG_LIBTOOL | 88 | AM_PROG_LIBTOOL |
89 | 89 | ||
90 | ## Predefine several variables used to display configuration status | 90 | ## Predefine several variables used to display configuration status | ... | ... |
... | @@ -149,8 +149,13 @@ typedef unsigned int mu_debug_level_t; | ... | @@ -149,8 +149,13 @@ typedef unsigned int mu_debug_level_t; |
149 | 149 | ||
150 | #define MU_DEFAULT_RECORD _MU_DEFAULT_RECORD_ | 150 | #define MU_DEFAULT_RECORD _MU_DEFAULT_RECORD_ |
151 | 151 | ||
152 | /* The use of this structure and associated ioctl is deprecated. This | 152 | /* This structure used to be called mu_locus in mailutils up to |
153 | definition is provided for transition period */ | 153 | 3.2.91-46 [release-3.2-71-g719e64a]. It is superseded by |
154 | structs mu_locus_point and mu_locus_range, defined in | ||
155 | <mailutils/locus.h>. | ||
156 | |||
157 | This definition is provided for backward compatibility. Authors are | ||
158 | urged to switch to the new API as soon as their time permits. */ | ||
154 | struct mu_locus_DEPRECATED | 159 | struct mu_locus_DEPRECATED |
155 | { | 160 | { |
156 | char *mu_file; | 161 | char *mu_file; | ... | ... |
... | @@ -35,22 +35,9 @@ gylwrap - wrapper for yacc, lex and similar programs | ... | @@ -35,22 +35,9 @@ gylwrap - wrapper for yacc, lex and similar programs |
35 | =head1 SYNOPSIS | 35 | =head1 SYNOPSIS |
36 | 36 | ||
37 | B<gylwrap> | 37 | B<gylwrap> |
38 | [B<-c?>] | ||
39 | [B<--compatibility>] | ||
40 | [B<--yyrepl=>I<PREFIX>] | ||
41 | [B<--yysym=>I<STRING>] | ||
42 | [B<--stdout>] | ||
43 | [B<--help>] | ||
44 | [B<--version>] | ||
45 | I<COMMAND> | ||
46 | I<INPUT> | ||
47 | I<OUTPUT> I<DESIRED>... | ||
48 | |||
49 | B<ylwrap> | ||
50 | [B<-?>] | 38 | [B<-?>] |
51 | [B<--yyrepl=>I<PREFIX>] | 39 | [B<--yyrepl=>I<PREFIX>] |
52 | [B<--yysym=>I<STRING>] | 40 | [B<--yysym=>I<STRING>] |
53 | [B<--stdout>] | ||
54 | [B<--help>] | 41 | [B<--help>] |
55 | [B<--version>] | 42 | [B<--version>] |
56 | I<INPUT> | 43 | I<INPUT> |
... | @@ -66,9 +53,9 @@ symbols to avoid clashes when multiple parsers and/or lexers are | ... | @@ -66,9 +53,9 @@ symbols to avoid clashes when multiple parsers and/or lexers are |
66 | linked in a single executable. | 53 | linked in a single executable. |
67 | 54 | ||
68 | To achieve this, B<gylwrap> creates a temporary directory, changes | 55 | To achieve this, B<gylwrap> creates a temporary directory, changes |
69 | to it, and runs I<COMMAND> (which may contain arguments and options) | 56 | to it, and runs I<PROGRAM>, with I<ARGS> and I<INPUT> as its arguments. |
70 | with I<INPUT> as its last argument. Upon successful exit, it processes | 57 | Upon successful exit from I<PROGRAM>, B<gylwrap> processes the |
71 | the I<OUTPUT> I<DESIRED> pairs. Each I<OUTPUT> file is then renamed | 58 | I<OUTPUT>-I<DESIRED> pairs. Each I<OUTPUT> file is then renamed |
72 | to the file I<DESIRED>, taking care to fix up any eventual B<#line> | 59 | to the file I<DESIRED>, taking care to fix up any eventual B<#line> |
73 | directives. | 60 | directives. |
74 | 61 | ||
... | @@ -78,18 +65,11 @@ For a list of symbols that are subject for replacement, inspect the | ... | @@ -78,18 +65,11 @@ For a list of symbols that are subject for replacement, inspect the |
78 | B<@sym> variable at the start of the script. Additional names can be | 65 | B<@sym> variable at the start of the script. Additional names can be |
79 | added to this list using the B<--yysym> option. | 66 | added to this list using the B<--yysym> option. |
80 | 67 | ||
81 | If given the B<--compatibility> option or if invoked as B<ylwrap>, | 68 | Prior to running the I<PROGRAM>, B<gylwrap> program checks whether the |
82 | the tool runs in compatibility mode, mimicking the behavior of the | 69 | file named B<gylwrap.conf> exists in directory of the I<INPUT> file. |
83 | standard B<ylwrap> utility from GNU Automake. Command line arguments | 70 | If found, it is parsed as follows. Empty lines and comments (introduced |
84 | consist of two lists, separated by B<-->. The left-hand side list | 71 | by the hash sign) are ignored. Rest of lines are either option |
85 | supplies the I<OUTPUT>,I<DESIRED> pairs, and the right-hand side one | 72 | assignements, or section headings. |
86 | supplies the command and its arguments. | ||
87 | |||
88 | In both modes, prior to running the command, the program looks for file | ||
89 | B<gylwrap.conf> in the same directory as the I<INPUT> file. If found, | ||
90 | the file is sourced. Empty lines and comments (introduced by the hash | ||
91 | sign) are ignored. Rest of lines are either option assignements, or | ||
92 | section headings. | ||
93 | 73 | ||
94 | Option assignements have the form B<I<OPTION> = I<VALUE>>, and generally, | 74 | Option assignements have the form B<I<OPTION> = I<VALUE>>, and generally, |
95 | have the same meaning as the corresponding command line option without | 75 | have the same meaning as the corresponding command line option without |
... | @@ -101,10 +81,6 @@ the leading two dashes: | ... | @@ -101,10 +81,6 @@ the leading two dashes: |
101 | 81 | ||
102 | Replace the B<yy> prefix with I<PREFIX> in the identifiers. | 82 | Replace the B<yy> prefix with I<PREFIX> in the identifiers. |
103 | 83 | ||
104 | =item B<stdout = 1> | ||
105 | |||
106 | Enable the B<--stdout> option. | ||
107 | |||
108 | =item B<yysym => I<NAME> | 84 | =item B<yysym => I<NAME> |
109 | 85 | ||
110 | Add I<NAME> to the list of symbols suitable for prefix replacement. | 86 | Add I<NAME> to the list of symbols suitable for prefix replacement. |
... | @@ -126,14 +102,6 @@ command line argument. | ... | @@ -126,14 +102,6 @@ command line argument. |
126 | 102 | ||
127 | =over 4 | 103 | =over 4 |
128 | 104 | ||
129 | =item B<-c>, B<--compatibility> | ||
130 | |||
131 | Run in compatibility mode. | ||
132 | |||
133 | =item B<--stdout> | ||
134 | |||
135 | Redirect I<COMMAND>'s standard output to the first I<OUTPUT>. | ||
136 | |||
137 | =item B<--yyrepl=>I<PREFIX> | 105 | =item B<--yyrepl=>I<PREFIX> |
138 | 106 | ||
139 | Replace the B<yy> prefix in global symbols with I<PREFIX>. | 107 | Replace the B<yy> prefix in global symbols with I<PREFIX>. |
... | @@ -233,9 +201,6 @@ my $yyrx; | ... | @@ -233,9 +201,6 @@ my $yyrx; |
233 | # String to replace the "yy" prefix with. | 201 | # String to replace the "yy" prefix with. |
234 | my $yyrepl; | 202 | my $yyrepl; |
235 | 203 | ||
236 | # If set, redirect the stdout from the command to the first output file. | ||
237 | my $stdout; | ||
238 | |||
239 | # Input directory with special characters escaped, for "#line" directive | 204 | # Input directory with special characters escaped, for "#line" directive |
240 | # fixup. | 205 | # fixup. |
241 | my $input_rx; | 206 | my $input_rx; |
... | @@ -244,14 +209,12 @@ my $input_rx; | ... | @@ -244,14 +209,12 @@ my $input_rx; |
244 | # input file name. Default entry is ''. | 209 | # input file name. Default entry is ''. |
245 | my %config; | 210 | my %config; |
246 | 211 | ||
247 | # Name of the first output file. This is used in compatibility mode to | 212 | # Name of the first output file. This is used to avoid bailing out if |
248 | # avoid bailing out if one of the output files (except the principal one) | 213 | # one of the output files (except the principal one) does not exist. |
249 | # does not exist. | ||
250 | my $parser; | 214 | my $parser; |
251 | 215 | ||
252 | # Name this program was invoked as. | 216 | # Name this program was invoked as. |
253 | my $progname = basename($0); | 217 | my $progname = basename($0); |
254 | my $compat = $progname eq 'ylwrap'; # True if running in compatibility mode | ||
255 | 218 | ||
256 | # List of files created during the run, for cleanup purposes. | 219 | # List of files created during the run, for cleanup purposes. |
257 | my @created; | 220 | my @created; |
... | @@ -261,9 +224,7 @@ sub filter { | ... | @@ -261,9 +224,7 @@ sub filter { |
261 | my $target = basename($to); | 224 | my $target = basename($to); |
262 | my $ifd; | 225 | my $ifd; |
263 | unless (open($ifd, '<', $from)) { | 226 | unless (open($ifd, '<', $from)) { |
264 | if ($compat) { | ||
265 | return if $from ne $parser; | 227 | return if $from ne $parser; |
266 | } | ||
267 | die "can't open input file $from: $!"; | 228 | die "can't open input file $from: $!"; |
268 | } | 229 | } |
269 | open(my $ofd, '>', $to) | 230 | open(my $ofd, '>', $to) |
... | @@ -296,8 +257,8 @@ sub readconf { | ... | @@ -296,8 +257,8 @@ sub readconf { |
296 | } elsif (/^\[(.+)\]/) { | 257 | } elsif (/^\[(.+)\]/) { |
297 | $key = $1; | 258 | $key = $1; |
298 | } elsif (m/(.+?)\s*=\s*(.+)$/) { | 259 | } elsif (m/(.+?)\s*=\s*(.+)$/) { |
299 | if ($1 eq 'yysym') { | 260 | if ($1 eq 'yysym' || $1 eq 'flags') { |
300 | push @{$config{$key}{$1}}, $2; | 261 | push @{$config{$key}{$1}}, (split /\s+/, $2); |
301 | } else { | 262 | } else { |
302 | $config{$key}{$1} = $2; | 263 | $config{$key}{$1} = $2; |
303 | } | 264 | } |
... | @@ -308,28 +269,20 @@ sub readconf { | ... | @@ -308,28 +269,20 @@ sub readconf { |
308 | close($fd); | 269 | close($fd); |
309 | } | 270 | } |
310 | 271 | ||
311 | my ($command, $input, @output); | 272 | my $input; |
273 | my @output; | ||
312 | 274 | ||
313 | GetOptions("yyrepl=s" => \$yyrepl, | 275 | GetOptions("yyrepl=s" => \$yyrepl, |
314 | "yysym=s@" => \@yysym, | 276 | "yysym=s@" => \@yysym, |
315 | "stdout" => \$stdout, | ||
316 | "compatibility|c" => \$compat, | ||
317 | "help|?" => sub { | 277 | "help|?" => sub { |
318 | pod2usage(-exitstatus => 0, -verbose => 2); | 278 | pod2usage(-exitstatus => 0, -verbose => 2); |
319 | } | 279 | } |
320 | ) or exit(1); | 280 | ) or exit(1); |
321 | 281 | ||
322 | if ($compat) { | 282 | $input = shift @ARGV; |
323 | $input = shift @ARGV; | 283 | while (my $arg = shift @ARGV) { |
324 | while (my $arg = shift @ARGV) { | ||
325 | last if ($arg eq '--'); | 284 | last if ($arg eq '--'); |
326 | push @output, $arg; | 285 | push @output, $arg; |
327 | } | ||
328 | $command = join(' ', @ARGV); | ||
329 | } else { | ||
330 | pod2usage(-exitstatus => 1, -verbose => 0, -output => \*STDERR) | ||
331 | unless @ARGV >= 2; | ||
332 | ($command, $input, @output) = @ARGV; | ||
333 | } | 286 | } |
334 | 287 | ||
335 | pod2usage(-exitstatus => 1, -verbose => 0, -output => \*STDERR) | 288 | pod2usage(-exitstatus => 1, -verbose => 0, -output => \*STDERR) |
... | @@ -345,9 +298,6 @@ my $confile = "$input_dir/gylwrap.conf"; | ... | @@ -345,9 +298,6 @@ my $confile = "$input_dir/gylwrap.conf"; |
345 | readconf($confile) if -r $confile; | 298 | readconf($confile) if -r $confile; |
346 | 299 | ||
347 | my $input_base = basename($input); | 300 | my $input_base = basename($input); |
348 | unless ($stdout) { | ||
349 | $stdout = $config{$input_base}{stdout} || $config{''}{stdout}; | ||
350 | } | ||
351 | unless ($yyrepl) { | 301 | unless ($yyrepl) { |
352 | $yyrepl = $config{$input_base}{yyrepl} || $config{''}{yyrepl}; | 302 | $yyrepl = $config{$input_base}{yyrepl} || $config{''}{yyrepl}; |
353 | } | 303 | } |
... | @@ -361,20 +311,13 @@ if ($yyrepl) { | ... | @@ -361,20 +311,13 @@ if ($yyrepl) { |
361 | } | 311 | } |
362 | } | 312 | } |
363 | 313 | ||
364 | my $prog = $command; | ||
365 | $prog =~ s/\s.*$//; | ||
366 | |||
367 | if (my $flags = $config{$input_base}{flags} || $config{''}{flags}) { | 314 | if (my $flags = $config{$input_base}{flags} || $config{''}{flags}) { |
368 | $command .= ' ' . $flags; | 315 | push @ARGV, @$flags; |
369 | } | 316 | } |
317 | push @ARGV, $input; | ||
370 | 318 | ||
371 | $parser = $output[0]; | 319 | $parser = $output[0]; |
372 | 320 | ||
373 | $command .= ' '.$input; | ||
374 | if ($stdout) { | ||
375 | $command .= '>'.$parser; | ||
376 | } | ||
377 | |||
378 | # Create working directory | 321 | # Create working directory |
379 | my $wd = tempdir("ylXXXXXX", DIR => '.', CLEANUP => 1) | 322 | my $wd = tempdir("ylXXXXXX", DIR => '.', CLEANUP => 1) |
380 | or die "cannot create temporary directory"; | 323 | or die "cannot create temporary directory"; |
... | @@ -387,12 +330,12 @@ END { | ... | @@ -387,12 +330,12 @@ END { |
387 | chdir ".."; | 330 | chdir ".."; |
388 | } | 331 | } |
389 | 332 | ||
390 | system($command); | 333 | system(@ARGV); |
391 | if ($? == -1) { | 334 | if ($? == -1) { |
392 | print STDERR "$prog: $!\n"; | 335 | print STDERR "$ARGV[0]: $!\n"; |
393 | exit(127); | 336 | exit(127); |
394 | } elsif ($? & 127) { | 337 | } elsif ($? & 127) { |
395 | print STDERR "$prog died with signal ".($? & 127)."\n"; | 338 | print STDERR "$ARGV[0] died with signal ".($? & 127)."\n"; |
396 | exit(127); | 339 | exit(127); |
397 | } else { | 340 | } else { |
398 | my $code = $? >> 8; | 341 | my $code = $? >> 8; | ... | ... |
-
Please register or sign in to post a comment