278 |
# $M4. |
# $M4. |
279 |
my $m4 = $ENV{"M4"} || '@M4@'; |
my $m4 = $ENV{"M4"} || '@M4@'; |
280 |
# Some non-GNU m4's don't reject the --help option, so give them /dev/null. |
# Some non-GNU m4's don't reject the --help option, so give them /dev/null. |
281 |
die "$me: need GNU m4 1.4 or later: $m4\n" |
error "need GNU m4 1.4 or later: $m4" |
282 |
if system "$m4 --help </dev/null 2>&1 | grep reload-state >/dev/null"; |
if system "$m4 --help </dev/null 2>&1 | grep reload-state >/dev/null"; |
283 |
|
|
284 |
# Set some high recursion limit as the default limit, 250, has already |
# Set some high recursion limit as the default limit, 250, has already |
443 |
} |
} |
444 |
elsif ($type eq 'end-language:') |
elsif ($type eq 'end-language:') |
445 |
{ |
{ |
446 |
die "$me: $autom4te_cfg:$.: end-language mismatch: $lang\n" |
error "$autom4te_cfg:$.: end-language mismatch: $lang" |
447 |
if $lang ne lc $words[0]; |
if $lang ne lc $words[0]; |
448 |
} |
} |
449 |
elsif ($type eq 'args:') |
elsif ($type eq 'args:') |
452 |
} |
} |
453 |
else |
else |
454 |
{ |
{ |
455 |
die "$me: $autom4te_cfg:$.: unknown directive: $type\n"; |
error "$autom4te_cfg:$.: unknown directive: $type"; |
456 |
} |
} |
457 |
} |
} |
458 |
} |
} |
477 |
|
|
478 |
foreach (@language) |
foreach (@language) |
479 |
{ |
{ |
480 |
die "$me: unknown language: $_\n" |
error "unknown language: $_" |
481 |
unless exists $language{lc $_}; |
unless exists $language{lc $_}; |
482 |
unshift @ARGV, @{$language{lc $_}}; |
unshift @ARGV, @{$language{lc $_}}; |
483 |
} |
} |
510 |
"F|freeze" => \$freeze, |
"F|freeze" => \$freeze, |
511 |
); |
); |
512 |
|
|
513 |
die "$me: too few arguments |
error "too few arguments |
514 |
Try `$me --help' for more information.\n" |
Try `$me --help' for more information." |
515 |
unless @ARGV; |
unless @ARGV; |
516 |
|
|
517 |
# Freezing: |
# Freezing: |
519 |
# And it implies melting: there is risk not to update properly using |
# And it implies melting: there is risk not to update properly using |
520 |
# old frozen files, and worse yet: we could load a frozen file and |
# old frozen files, and worse yet: we could load a frozen file and |
521 |
# refreeze it! A sort of caching :) |
# refreeze it! A sort of caching :) |
522 |
die "$me: cannot freeze and trace\n" |
error "cannot freeze and trace" |
523 |
if $freeze && @trace; |
if $freeze && @trace; |
524 |
$melt = 1 |
$melt = 1 |
525 |
if $freeze; |
if $freeze; |
612 |
# |
# |
613 |
# We don't output directly to the cache files, to avoid problems |
# We don't output directly to the cache files, to avoid problems |
614 |
# when we are interrupted (that leaves corrupted files). |
# when we are interrupted (that leaves corrupted files). |
615 |
my $command = ("$m4" |
xsystem ("$m4" |
616 |
. join (' --include=', '', @include) |
. join (' --include=', '', @include) |
617 |
. " --define=m4_warnings=$m4_warnings" |
. " --define=m4_warnings=$m4_warnings" |
618 |
. ' --debug=aflq' |
. ' --debug=aflq' |
619 |
. " --error-output=$tcache" . $req->id . "t" |
. " --error-output=$tcache" . $req->id . "t" |
620 |
. join (' --trace=', '', sort @macro) |
. join (' --trace=', '', sort @macro) |
621 |
. " @ARGV" |
. " @ARGV" |
622 |
. ' </dev/null' |
. ' </dev/null' |
623 |
. " >$ocache" . $req->id . "t"); |
. " >$ocache" . $req->id . "t"); |
|
verbose "running: $command"; |
|
|
system $command; |
|
|
if ($?) |
|
|
{ |
|
|
verbose "$m4: failed with exit status: " . ($? >> 8) . "\n"; |
|
|
exit $? >> 8; |
|
|
} |
|
624 |
|
|
625 |
# Everything went ok: preserve the outputs. |
# Everything went ok: preserve the outputs. |
626 |
foreach my $file (map { $_ . $req->id } ($tcache, $ocache)) |
foreach my $file (map { $_ . $req->id } ($tcache, $ocache)) |
627 |
{ |
{ |
628 |
use File::Copy; |
use File::Copy; |
629 |
move ("${file}t", "$file") |
move ("${file}t", "$file") |
630 |
or die "$me: cannot not rename ${file}t as $file: $!\n"; |
or error "cannot not rename ${file}t as $file: $!"; |
631 |
} |
} |
632 |
} |
} |
633 |
|
|
703 |
{ |
{ |
704 |
$out->open($output, O_CREAT | O_WRONLY | O_TRUNC, oct ($mode)); |
$out->open($output, O_CREAT | O_WRONLY | O_TRUNC, oct ($mode)); |
705 |
} |
} |
706 |
die "$me: cannot create $output: $!\n" |
error "cannot create $output: $!" |
707 |
unless $out; |
unless $out; |
708 |
my $in = new Autom4te::XFile ($ocache . $req->id); |
my $in = new Autom4te::XFile ($ocache . $req->id); |
709 |
|
|
830 |
} |
} |
831 |
elsif (/^(\$.)/) |
elsif (/^(\$.)/) |
832 |
{ |
{ |
833 |
die "$me: invalid escape: $1\n"; |
error "invalid escape: $1"; |
834 |
} |
} |
835 |
else |
else |
836 |
{ |
{ |
1055 |
|
|
1056 |
# When processing the file with diversion disabled, there must be no |
# When processing the file with diversion disabled, there must be no |
1057 |
# output but comments and empty lines. |
# output but comments and empty lines. |
1058 |
my $command = ("$m4" |
my $result = xqx ("$m4" |
1059 |
. ' --fatal-warning' |
. ' --fatal-warning' |
1060 |
. join (' --include=', '', @include) |
. join (' --include=', '', @include) |
1061 |
. ' --define=divert' |
. ' --define=divert' |
1062 |
. " @ARGV" |
. " @ARGV" |
1063 |
. ' </dev/null'); |
. ' </dev/null'); |
|
verbose "running: $command"; |
|
|
my $result = `$command`; |
|
1064 |
$result =~ s/#.*\n//g; |
$result =~ s/#.*\n//g; |
1065 |
$result =~ s/^\n//mg; |
$result =~ s/^\n//mg; |
|
if ($?) |
|
|
{ |
|
|
verbose "$m4: failed with exit status: " . ($? >> 8) . "\n"; |
|
|
exit $? >> 8; |
|
|
} |
|
1066 |
if ($result) |
if ($result) |
1067 |
{ |
{ |
1068 |
print STDERR "$me: freezing produced output:\n$result"; |
print STDERR "$me: freezing produced output:\n$result"; |
1071 |
|
|
1072 |
# If freezing produces output, something went wrong: a bad `divert', |
# If freezing produces output, something went wrong: a bad `divert', |
1073 |
# or an improper paren etc. |
# or an improper paren etc. |
1074 |
$command = ("$m4" |
xsystem ("$m4" |
1075 |
. ' --fatal-warning' |
. ' --fatal-warning' |
1076 |
. join (' --include=', '', @include) |
. join (' --include=', '', @include) |
1077 |
. " --freeze-state=$output" |
. " --freeze-state=$output" |
1078 |
. " @ARGV" |
. " @ARGV" |
1079 |
. ' </dev/null'); |
. ' </dev/null'); |
|
verbose "running: $command"; |
|
|
system $command; |
|
|
if ($?) |
|
|
{ |
|
|
verbose "$m4: failed with exit status: " . ($? >> 8) . "\n"; |
|
|
exit $? >> 8; |
|
|
} |
|
1080 |
} |
} |
1081 |
|
|
1082 |
## -------------- ## |
## -------------- ## |
1098 |
if (! -d "$cache") |
if (! -d "$cache") |
1099 |
{ |
{ |
1100 |
mkdir "$cache", 0755 |
mkdir "$cache", 0755 |
1101 |
or die "$me: cannot create $cache: $!\n"; |
or error "cannot create $cache: $!"; |
1102 |
} |
} |
1103 |
|
|
1104 |
# Read the cache index if available and older than autom4te itself. |
# Read the cache index if available and older than autom4te itself. |