]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* autoconf.sh (finalize.awk): New subtool, eved from the previous
authorAkim Demaille <akim@epita.fr>
Mon, 7 Aug 2000 12:07:17 +0000 (12:07 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 7 Aug 2000 12:07:17 +0000 (12:07 +0000)
literal AWK program that performed the `oline' and quadrigraphs
substitution.
Fix its `oline' computation which was dead wrong when there are
empty lines (i.e., always).
Enhance it in order to look for and report unexpanded macro.
Don't let it pretend there are bugs in Autoconf (c:, the test
suite makes this scenario pretty unlikely as opposed to an actual
user bug.
Catch `m4_' too.
Remove the shell snippet which used to do this.

ChangeLog
autoconf.in
autoconf.sh
bin/autoconf.in

index 711630d8888e9a464e184b241be0837b9b7bac79..9f610772bf67046fe1299322cc1c2dce66563fcb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2000-08-07  Akim Demaille  <akim@epita.fr>
+
+       * autoconf.sh (finalize.awk): New subtool, eved from the previous
+       literal AWK program that performed the `oline' and quadrigraphs
+       substitution.
+       Fix its `oline' computation which was dead wrong when there are
+       empty lines (i.e., always).
+       Enhance it in order to look for and report unexpanded macro.
+       Don't let it pretend there are bugs in Autoconf (c:, the test
+       suite makes this scenario pretty unlikely as opposed to an actual
+       user bug.
+       Catch `m4_' too.
+       Remove the shell snippet which used to do this.
+
 2000-08-07  Akim Demaille  <akim@epita.fr>
 
        * acgeneral.m4 (AC_MSG_NOTICE): New macro, suggested by Pavel
index a5a2303848813e3f847b42dbb7c6ce7d52840aaa..8bb4d9dd888bb238259e5b95d50516192ef88167 100644 (file)
@@ -299,20 +299,9 @@ case $task in
   # M4 expansion.
   $run_m4f -D_AC_WARNINGS=$_ac_warnings $infile >$tmp/configure || exit 2
 
-  # You could add your own prefixes to pattern if you wanted to check for
-  # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
-  # alternation.
-  pattern="A[CHM]_"
-
-  if grep "^[^#]*$pattern" $tmp/configure >/dev/null 2>&1; then
-    echo "$me: undefined macros:" >&2
-    sed -n "s/^[^#]*\\($pattern[_A-Za-z0-9]*\\).*/\\1/p" $tmp/configure |
-      while read macro; do
-       grep -n "^[^#]*$macro" $infile /dev/null
-       test $? = 1 && echo "***BUG in Autoconf--please report*** $macro"
-      done | sort -u >&2
-    status=1
-  fi
+  # You can add your own prefixes to pattern if you want to check for
+  # them too.
+  pattern="A[CHM]_|m4_"
 
   if test "x$outfile" != x-; then
     chmod +x $outfile
@@ -321,31 +310,71 @@ case $task in
   # Put the real line numbers into configure to make config.log more
   # helpful.  Because quoting can sometimes get really painful in m4,
   # there are special @tokens@ to substitute.
-  $AWK '
+  cat >$tmp/finalize.awk <<EOF
+    function undefined (file, line, macro)
+    {
+      print file ":" line ": warning: undefined macro: " macro | "cat >&2"
+    }
+
     {
       sub(/[         ]*$/, "")
-      if ($0 == "")
+      if (\$0 == "")
         {
           if (!duplicate)
-            print
+            {
+               oline++
+               print
+            }
           duplicate = 1
           next
         }
       duplicate = 0
       oline++
-      if ($0 ~ /__oline__/)
+      if (\$0 ~ /__oline__/)
         while (sub(/__oline__/, oline))
           continue
-      while (sub(/@<:@/, "["))
+      while (sub (/@<:@/, "["))
         continue
-      while (sub(/@:>@/, "]"))
+      while (sub (/@:>@/, "]"))
         continue
-      while (sub(/@S\|@/, "$"))
+      while (sub (/@S\|@/, "$"))
         continue
-      while (sub(/@%:@/, "#"))
+      while (sub (/@%:@/, "#"))
         continue
+      # Dubious feature: we tolerate macro names when commented.
+      if (/^[^#]*($pattern)/)
+        {
+           match (\$0, /($pattern)[_A-Za-z0-9]*/)
+           macros [substr (\$0, RSTART, RLENGTH)] = oline
+           some_macros_were_not_expanded = 1
+        }
       print
-    }' <$tmp/configure >&4
+    }
+
+    # If there are some macros which are left unexpanded in the output,
+    # try to find the input which is responsible.  Otherwise, try to help.
+    END {
+      if (some_macros_were_not_expanded)
+        {
+          line = 0
+          while (getline < "$infile")
+            {
+              line++
+              for (macro in macros)
+              if (index (\$0, macro))
+                {
+                  delete macros [macro]
+                  undefined ("$infile", line, macro)
+                }
+            }
+          close ("$infile")
+          for (macro in macros)
+            undefined ("$outfile", macros [macro], macro)
+          exit 1
+        }
+    }
+EOF
+    $AWK -f $tmp/finalize.awk <$tmp/configure >&4
   ;; # End of the task script.
 
 
index a5a2303848813e3f847b42dbb7c6ce7d52840aaa..8bb4d9dd888bb238259e5b95d50516192ef88167 100644 (file)
@@ -299,20 +299,9 @@ case $task in
   # M4 expansion.
   $run_m4f -D_AC_WARNINGS=$_ac_warnings $infile >$tmp/configure || exit 2
 
-  # You could add your own prefixes to pattern if you wanted to check for
-  # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
-  # alternation.
-  pattern="A[CHM]_"
-
-  if grep "^[^#]*$pattern" $tmp/configure >/dev/null 2>&1; then
-    echo "$me: undefined macros:" >&2
-    sed -n "s/^[^#]*\\($pattern[_A-Za-z0-9]*\\).*/\\1/p" $tmp/configure |
-      while read macro; do
-       grep -n "^[^#]*$macro" $infile /dev/null
-       test $? = 1 && echo "***BUG in Autoconf--please report*** $macro"
-      done | sort -u >&2
-    status=1
-  fi
+  # You can add your own prefixes to pattern if you want to check for
+  # them too.
+  pattern="A[CHM]_|m4_"
 
   if test "x$outfile" != x-; then
     chmod +x $outfile
@@ -321,31 +310,71 @@ case $task in
   # Put the real line numbers into configure to make config.log more
   # helpful.  Because quoting can sometimes get really painful in m4,
   # there are special @tokens@ to substitute.
-  $AWK '
+  cat >$tmp/finalize.awk <<EOF
+    function undefined (file, line, macro)
+    {
+      print file ":" line ": warning: undefined macro: " macro | "cat >&2"
+    }
+
     {
       sub(/[         ]*$/, "")
-      if ($0 == "")
+      if (\$0 == "")
         {
           if (!duplicate)
-            print
+            {
+               oline++
+               print
+            }
           duplicate = 1
           next
         }
       duplicate = 0
       oline++
-      if ($0 ~ /__oline__/)
+      if (\$0 ~ /__oline__/)
         while (sub(/__oline__/, oline))
           continue
-      while (sub(/@<:@/, "["))
+      while (sub (/@<:@/, "["))
         continue
-      while (sub(/@:>@/, "]"))
+      while (sub (/@:>@/, "]"))
         continue
-      while (sub(/@S\|@/, "$"))
+      while (sub (/@S\|@/, "$"))
         continue
-      while (sub(/@%:@/, "#"))
+      while (sub (/@%:@/, "#"))
         continue
+      # Dubious feature: we tolerate macro names when commented.
+      if (/^[^#]*($pattern)/)
+        {
+           match (\$0, /($pattern)[_A-Za-z0-9]*/)
+           macros [substr (\$0, RSTART, RLENGTH)] = oline
+           some_macros_were_not_expanded = 1
+        }
       print
-    }' <$tmp/configure >&4
+    }
+
+    # If there are some macros which are left unexpanded in the output,
+    # try to find the input which is responsible.  Otherwise, try to help.
+    END {
+      if (some_macros_were_not_expanded)
+        {
+          line = 0
+          while (getline < "$infile")
+            {
+              line++
+              for (macro in macros)
+              if (index (\$0, macro))
+                {
+                  delete macros [macro]
+                  undefined ("$infile", line, macro)
+                }
+            }
+          close ("$infile")
+          for (macro in macros)
+            undefined ("$outfile", macros [macro], macro)
+          exit 1
+        }
+    }
+EOF
+    $AWK -f $tmp/finalize.awk <$tmp/configure >&4
   ;; # End of the task script.
 
 
index a5a2303848813e3f847b42dbb7c6ce7d52840aaa..8bb4d9dd888bb238259e5b95d50516192ef88167 100644 (file)
@@ -299,20 +299,9 @@ case $task in
   # M4 expansion.
   $run_m4f -D_AC_WARNINGS=$_ac_warnings $infile >$tmp/configure || exit 2
 
-  # You could add your own prefixes to pattern if you wanted to check for
-  # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
-  # alternation.
-  pattern="A[CHM]_"
-
-  if grep "^[^#]*$pattern" $tmp/configure >/dev/null 2>&1; then
-    echo "$me: undefined macros:" >&2
-    sed -n "s/^[^#]*\\($pattern[_A-Za-z0-9]*\\).*/\\1/p" $tmp/configure |
-      while read macro; do
-       grep -n "^[^#]*$macro" $infile /dev/null
-       test $? = 1 && echo "***BUG in Autoconf--please report*** $macro"
-      done | sort -u >&2
-    status=1
-  fi
+  # You can add your own prefixes to pattern if you want to check for
+  # them too.
+  pattern="A[CHM]_|m4_"
 
   if test "x$outfile" != x-; then
     chmod +x $outfile
@@ -321,31 +310,71 @@ case $task in
   # Put the real line numbers into configure to make config.log more
   # helpful.  Because quoting can sometimes get really painful in m4,
   # there are special @tokens@ to substitute.
-  $AWK '
+  cat >$tmp/finalize.awk <<EOF
+    function undefined (file, line, macro)
+    {
+      print file ":" line ": warning: undefined macro: " macro | "cat >&2"
+    }
+
     {
       sub(/[         ]*$/, "")
-      if ($0 == "")
+      if (\$0 == "")
         {
           if (!duplicate)
-            print
+            {
+               oline++
+               print
+            }
           duplicate = 1
           next
         }
       duplicate = 0
       oline++
-      if ($0 ~ /__oline__/)
+      if (\$0 ~ /__oline__/)
         while (sub(/__oline__/, oline))
           continue
-      while (sub(/@<:@/, "["))
+      while (sub (/@<:@/, "["))
         continue
-      while (sub(/@:>@/, "]"))
+      while (sub (/@:>@/, "]"))
         continue
-      while (sub(/@S\|@/, "$"))
+      while (sub (/@S\|@/, "$"))
         continue
-      while (sub(/@%:@/, "#"))
+      while (sub (/@%:@/, "#"))
         continue
+      # Dubious feature: we tolerate macro names when commented.
+      if (/^[^#]*($pattern)/)
+        {
+           match (\$0, /($pattern)[_A-Za-z0-9]*/)
+           macros [substr (\$0, RSTART, RLENGTH)] = oline
+           some_macros_were_not_expanded = 1
+        }
       print
-    }' <$tmp/configure >&4
+    }
+
+    # If there are some macros which are left unexpanded in the output,
+    # try to find the input which is responsible.  Otherwise, try to help.
+    END {
+      if (some_macros_were_not_expanded)
+        {
+          line = 0
+          while (getline < "$infile")
+            {
+              line++
+              for (macro in macros)
+              if (index (\$0, macro))
+                {
+                  delete macros [macro]
+                  undefined ("$infile", line, macro)
+                }
+            }
+          close ("$infile")
+          for (macro in macros)
+            undefined ("$outfile", macros [macro], macro)
+          exit 1
+        }
+    }
+EOF
+    $AWK -f $tmp/finalize.awk <$tmp/configure >&4
   ;; # End of the task script.