summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-28 15:05:23 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-07-28 15:05:23 (GMT)
commit699fc16c7654c5af9260407eb7ecdbb20fc501de (patch) (side-by-side diff)
treeb2a469c22e7ed9c0b73ca1e4ac9e1fc265eda6ab
parent4b562511f67041a99b6b56204b469afac659f394 (diff)
downloaddico-699fc16c7654c5af9260407eb7ecdbb20fc501de.tar.gz
dico-699fc16c7654c5af9260407eb7ecdbb20fc501de.tar.bz2
Improve modinc
* modinc: Provide explicit construct for multiline expansion. * modules/stub.am: Use the new construct for HEADING expansion. * stub.ac: Likewise.
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xmodinc38
-rw-r--r--modules/stub.am4
-rw-r--r--stub.ac4
3 files changed, 31 insertions, 15 deletions
diff --git a/modinc b/modinc
index 7c1c5e1..5b88051 100755
--- a/modinc
+++ b/modinc
@@ -96,12 +96,29 @@ output file.
During macro expansion, each occurrence of B<< <I<NAME>> >> is replaced with
the contents of the macro variable I<NAME>, if it is defined. Expansion
-of undefined variables lefts the text as is.
+of undefined variables leaves the text as is.
-A B<< <I<NAME>> >> appearing alone after a sequence of non-whitespace
-characters (a I<prefix>) at the beginning of the line is treated specially:
-if I<NAME> expands to multiple lines, I<prefix> is prepended to each line
-on output.
+The construct B<< <I<NAME>#I<TEXT>> >> is expanded if it appears on a line
+alone, possibly preceded by any string of characters. It works similarly
+to B<< <I<NAME>> >>, except that if I<NAME> expands to multiple lines, the
+second and subsequent lines of expansion are prefixed with I<TEXT> on output.
+If I<TEXT> is empty, the content of the source line immediately preceding the
+construct is used instead. This makes it possible to use expansions after a
+comment character. E.g. if the variable B<HEADING> contains:
+
+ This file is generated automatically.
+ Please, do not edit.
+ See the docs for more info.
+
+and the input file contains:
+
+ dnl <HEADING#>
+
+Then, the resulting expansion will be:
+
+ dnl This file is generated automatically.
+ dnl Please, do not edit.
+ dnl See the docs for more info.
The macro variables are specific for each file, and are described below.
@@ -281,8 +298,7 @@ use constant EX_NOINPUT => 66; # cannot open input file
use constant EX_SOFTWARE => 70; # internal software error (not used yet)
use constant EX_CANTCREAT => 73; # can't create (user) output file
-my $progname;
-($progname = $0) =~ s/.*\///;
+my $progname = basename($0);
my $progdescr = "Recreate Dico module autoconf structure";
my $addmod;
my $dry_run;
@@ -528,14 +544,14 @@ sub make_file {
}
while (<$ifd>) {
next if (defined($ref->{ignorecomm}) and /^$ref->{ignorecomm}/);
- if (/^(\S+)<([A-Z][A-Z0-9_]+)>\s*$/) {
- my $pfx = "$1 ";
- $_ = $pfx . replace_macro($2, $ref, @_);
+ if (/^(.*)<([A-Z][A-Z0-9_]+)#([^>]*)>\s*$/) {
+ my $pfx = $3 || $1;
+ $_ = $1 . replace_macro($2, $ref);
chomp;
s/\n/\n$pfx/g;
$_ .= "\n";
} else {
- s/<([A-Z][A-Z0-9_]+)>/replace_macro($1, $ref, @_)/gex;
+ s/<([A-Z][A-Z0-9_]+)>/replace_macro($1, $ref)/gex;
}
print $ofd $_;
}
diff --git a/modules/stub.am b/modules/stub.am
index bd14b9d..56ecf6e 100644
--- a/modules/stub.am
+++ b/modules/stub.am
@@ -1,6 +1,6 @@
-#<HEADING>
+# <HEADING#>
# This file is part of GNU Dico
-# Copyright (C) 1998-2000, 2008, 2010, 2012, 2014 Sergey Poznyakoff
+# Copyright (C) 1998-2000, 2008, 2010, 2012-2016 Sergey Poznyakoff
#
# GNU Dico is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/stub.ac b/stub.ac
index 46b33c4..7e9b812 100644
--- a/stub.ac
+++ b/stub.ac
@@ -5,10 +5,10 @@
## 1. Comments starting with ## are removed from the output.
## 2. A construct <NAME> is replaced with the value of the variable NAME.
## 3. Everything else is reproduced verbatim.
-dnl<HEADING>
+dnl <HEADING#>
dnl Process this file with -*- autoconf -*- to produce a configure script.
# This file is part of GNU Dico
-# Copyright (C) 1998-2000, 2008-2010, 2012, 2013, 2014 Sergey Poznyakoff
+# Copyright (C) 1998-2000, 2008-2010, 2012-2016 Sergey Poznyakoff
#
# GNU Dico is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

Return to:

Send suggestions and report system problems to the System administrator.