autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Allow |#_!!_#| on a line of its own in files processed by config.status


From: Demetrios Obenour
Subject: Allow |#_!!_#| on a line of its own in files processed by config.status
Date: Sat, 29 Nov 2014 20:18:30 -0500

This patch removes the prohibition against using |#_!!_#| in files that
have variables substituted into them by config.status. The patch works
by checking to see if the here document in an awk-generated shell script
is accidentally closed, and reopens it when this happens (after echoing
the heredoc delimiter). All tests pass, even when modified so that awk's
built-in getline is never used.

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index ace1675..84d611e 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -9786,9 +9786,7 @@ not contain @samp{@@@var{var1}@@@var{var2}@@} if
@var{var1} and @var{var2}
 are variable names.
 The substituted value is not rescanned for more output variables;
 occurrences of @samp{@@@var{variable}@@} in the value are inserted
-literally into the output file.  (The algorithm uses the special marker
address@hidden|#_!!_#|} internally, so neither the substituted value nor the
-output file may contain @code{|#_!!_#|}.)
+literally into the output file.
 
 If @var{value} is given, in addition assign it to @var{variable}.
 
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 9386891..99d0805 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -342,10 +342,18 @@ m4_ifdef([_AC_SUBST_FILES],
       while ((getline aline < (F[key])) > 0)
        print(aline)
       close(F[key])'
+  ac_cs_awk_escape=
   ac_cs_awk_pipe_fini=
 else
   ac_cs_awk_getline=false
   ac_cs_awk_pipe_init="print \"cat <<'|#_!!_#|' &&\""
+  ac_cs_awk_escape='
+  if (line == "|#_!!_#|") {
+    # We just closed the here document!
+    # Echo the line and reopen the heredoc
+    print "echo \"|#_!!_#|\" &&"
+    '"$ac_cs_awk_pipe_init
+  }"
   ac_cs_awk_read_file='
       print "|#_!!_#|"
       print "cat " F[key] " &&"
@@ -525,6 +533,7 @@ cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
     }
   }]])[
   print line
+]m4_ifdef([_AC_SUBST_FILES],[[\$ac_cs_awk_escape]])[
 }
 ]dnl end of double-quoted part
 m4_ifdef([_AC_SUBST_FILES],





reply via email to

[Prev in Thread] Current Thread [Next in Thread]