diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-28 18:05:23 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-28 18:05:23 +0300 |
commit | 699fc16c7654c5af9260407eb7ecdbb20fc501de (patch) | |
tree | b2a469c22e7ed9c0b73ca1e4ac9e1fc265eda6ab | |
parent | 4b562511f67041a99b6b56204b469afac659f394 (diff) | |
download | dico-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.
-rwxr-xr-x | modinc | 38 | ||||
-rw-r--r-- | modules/stub.am | 4 | ||||
-rw-r--r-- | stub.ac | 4 |
3 files changed, 31 insertions, 15 deletions
@@ -96,12 +96,29 @@ output file. | |||
96 | 96 | ||
97 | During macro expansion, each occurrence of B<< <I<NAME>> >> is replaced with | 97 | During macro expansion, each occurrence of B<< <I<NAME>> >> is replaced with |
98 | the contents of the macro variable I<NAME>, if it is defined. Expansion | 98 | the contents of the macro variable I<NAME>, if it is defined. Expansion |
99 | of undefined variables lefts the text as is. | 99 | of undefined variables leaves the text as is. |
100 | 100 | ||
101 | A B<< <I<NAME>> >> appearing alone after a sequence of non-whitespace | 101 | The construct B<< <I<NAME>#I<TEXT>> >> is expanded if it appears on a line |
102 | characters (a I<prefix>) at the beginning of the line is treated specially: | 102 | alone, possibly preceded by any string of characters. It works similarly |
103 | if I<NAME> expands to multiple lines, I<prefix> is prepended to each line | 103 | to B<< <I<NAME>> >>, except that if I<NAME> expands to multiple lines, the |
104 | on output. | 104 | second and subsequent lines of expansion are prefixed with I<TEXT> on output. |
105 | If I<TEXT> is empty, the content of the source line immediately preceding the | ||
106 | construct is used instead. This makes it possible to use expansions after a | ||
107 | comment character. E.g. if the variable B<HEADING> contains: | ||
108 | |||
109 | This file is generated automatically. | ||
110 | Please, do not edit. | ||
111 | See the docs for more info. | ||
112 | |||
113 | and the input file contains: | ||
114 | |||
115 | dnl <HEADING#> | ||
116 | |||
117 | Then, the resulting expansion will be: | ||
118 | |||
119 | dnl This file is generated automatically. | ||
120 | dnl Please, do not edit. | ||
121 | dnl See the docs for more info. | ||
105 | 122 | ||
106 | The macro variables are specific for each file, and are described below. | 123 | The macro variables are specific for each file, and are described below. |
107 | 124 | ||
@@ -281,8 +298,7 @@ use constant EX_NOINPUT => 66; # cannot open input file | |||
281 | use constant EX_SOFTWARE => 70; # internal software error (not used yet) | 298 | use constant EX_SOFTWARE => 70; # internal software error (not used yet) |
282 | use constant EX_CANTCREAT => 73; # can't create (user) output file | 299 | use constant EX_CANTCREAT => 73; # can't create (user) output file |
283 | 300 | ||
284 | my $progname; | 301 | my $progname = basename($0); |
285 | ($progname = $0) =~ s/.*\///; | ||
286 | my $progdescr = "Recreate Dico module autoconf structure"; | 302 | my $progdescr = "Recreate Dico module autoconf structure"; |
287 | my $addmod; | 303 | my $addmod; |
288 | my $dry_run; | 304 | my $dry_run; |
@@ -528,14 +544,14 @@ sub make_file { | |||
528 | } | 544 | } |
529 | while (<$ifd>) { | 545 | while (<$ifd>) { |
530 | next if (defined($ref->{ignorecomm}) and /^$ref->{ignorecomm}/); | 546 | next if (defined($ref->{ignorecomm}) and /^$ref->{ignorecomm}/); |
531 | if (/^(\S+)<([A-Z][A-Z0-9_]+)>\s*$/) { | 547 | if (/^(.*)<([A-Z][A-Z0-9_]+)#([^>]*)>\s*$/) { |
532 | my $pfx = "$1 "; | 548 | my $pfx = $3 || $1; |
533 | $_ = $pfx . replace_macro($2, $ref, @_); | 549 | $_ = $1 . replace_macro($2, $ref); |
534 | chomp; | 550 | chomp; |
535 | s/\n/\n$pfx/g; | 551 | s/\n/\n$pfx/g; |
536 | $_ .= "\n"; | 552 | $_ .= "\n"; |
537 | } else { | 553 | } else { |
538 | s/<([A-Z][A-Z0-9_]+)>/replace_macro($1, $ref, @_)/gex; | 554 | s/<([A-Z][A-Z0-9_]+)>/replace_macro($1, $ref)/gex; |
539 | } | 555 | } |
540 | print $ofd $_; | 556 | print $ofd $_; |
541 | } | 557 | } |
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 @@ | |||
1 | #<HEADING> | 1 | # <HEADING#> |
2 | # This file is part of GNU Dico | 2 | # This file is part of GNU Dico |
3 | # Copyright (C) 1998-2000, 2008, 2010, 2012, 2014 Sergey Poznyakoff | 3 | # Copyright (C) 1998-2000, 2008, 2010, 2012-2016 Sergey Poznyakoff |
4 | # | 4 | # |
5 | # GNU Dico is free software; you can redistribute it and/or modify | 5 | # GNU Dico is free software; you can redistribute it and/or modify |
6 | # it under the terms of the GNU General Public License as published by | 6 | # it under the terms of the GNU General Public License as published by |
@@ -5,10 +5,10 @@ | |||
5 | ## 1. Comments starting with ## are removed from the output. | 5 | ## 1. Comments starting with ## are removed from the output. |
6 | ## 2. A construct <NAME> is replaced with the value of the variable NAME. | 6 | ## 2. A construct <NAME> is replaced with the value of the variable NAME. |
7 | ## 3. Everything else is reproduced verbatim. | 7 | ## 3. Everything else is reproduced verbatim. |
8 | dnl<HEADING> | 8 | dnl <HEADING#> |
9 | dnl Process this file with -*- autoconf -*- to produce a configure script. | 9 | dnl Process this file with -*- autoconf -*- to produce a configure script. |
10 | # This file is part of GNU Dico | 10 | # This file is part of GNU Dico |
11 | # Copyright (C) 1998-2000, 2008-2010, 2012, 2013, 2014 Sergey Poznyakoff | 11 | # Copyright (C) 1998-2000, 2008-2010, 2012-2016 Sergey Poznyakoff |
12 | # | 12 | # |
13 | # GNU Dico is free software; you can redistribute it and/or modify | 13 | # GNU Dico is free software; you can redistribute it and/or modify |
14 | # it under the terms of the GNU General Public License as published by | 14 | # it under the terms of the GNU General Public License as published by |