aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-28 18:05:23 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-07-28 18:05:23 +0300
commit699fc16c7654c5af9260407eb7ecdbb20fc501de (patch)
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.
-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.
96 96
97During macro expansion, each occurrence of B<< <I<NAME>> >> is replaced with 97During macro expansion, each occurrence of B<< <I<NAME>> >> is replaced with
98the contents of the macro variable I<NAME>, if it is defined. Expansion 98the contents of the macro variable I<NAME>, if it is defined. Expansion
99of undefined variables lefts the text as is. 99of undefined variables leaves the text as is.
100 100
101A B<< <I<NAME>> >> appearing alone after a sequence of non-whitespace 101The construct B<< <I<NAME>#I<TEXT>> >> is expanded if it appears on a line
102characters (a I<prefix>) at the beginning of the line is treated specially: 102alone, possibly preceded by any string of characters. It works similarly
103if I<NAME> expands to multiple lines, I<prefix> is prepended to each line 103to B<< <I<NAME>> >>, except that if I<NAME> expands to multiple lines, the
104on output. 104second and subsequent lines of expansion are prefixed with I<TEXT> on output.
105If I<TEXT> is empty, the content of the source line immediately preceding the
106construct is used instead. This makes it possible to use expansions after a
107comment 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
113and the input file contains:
114
115 dnl <HEADING#>
116
117Then, 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
106The macro variables are specific for each file, and are described below. 123The 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
281use constant EX_SOFTWARE => 70; # internal software error (not used yet) 298use constant EX_SOFTWARE => 70; # internal software error (not used yet)
282use constant EX_CANTCREAT => 73; # can't create (user) output file 299use constant EX_CANTCREAT => 73; # can't create (user) output file
283 300
284my $progname; 301my $progname = basename($0);
285($progname = $0) =~ s/.*\///;
286my $progdescr = "Recreate Dico module autoconf structure"; 302my $progdescr = "Recreate Dico module autoconf structure";
287my $addmod; 303my $addmod;
288my $dry_run; 304my $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
diff --git a/stub.ac b/stub.ac
index 46b33c4..7e9b812 100644
--- a/stub.ac
+++ b/stub.ac
@@ -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.
8dnl<HEADING> 8dnl <HEADING#>
9dnl Process this file with -*- autoconf -*- to produce a configure script. 9dnl 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

Return to:

Send suggestions and report system problems to the System administrator.