Sort the #include directives more carefully.
authorBruno Haible <bruno@clisp.org>
Tue, 25 Apr 2006 12:01:00 +0000 (12:01 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 25 Apr 2006 12:01:00 +0000 (12:01 +0000)
ChangeLog
gnulib-tool

index 8bbd7526c12a8efd4b03354d69ae26cd9e0f27c0..05100df5964a5c10de82780dd6ee6d54bf2fe0ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-25  Bruno Haible  <bruno@clisp.org>
+
+       * gnulib-tool (func_import): Output the include directives in three
+       blocks, sorted separately.
+       Reported by Ben Pfaff <blp@cs.stanford.edu>.
+
 2006-04-23  Bruno Haible  <bruno@clisp.org>
 
        * modules/copy-file: Depend on unistd.
index b7a6dea7b6d170f381f22386797dc17363925e79..fbdd5b6a68220204a1d1ef2592ebc0f74eb69bc6 100755 (executable)
@@ -22,7 +22,7 @@
 
 progname=$0
 package=gnulib
-cvsdatestamp='$Date: 2006-04-24 11:35:07 $'
+cvsdatestamp='$Date: 2006-04-25 12:01:00 $'
 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
 
@@ -1453,9 +1453,30 @@ func_import ()
   echo "Finished."
   echo
   echo "You may need to add #include directives for the following .h files."
-  for module in $modules; do
-    func_get_include_directive "$module"
-  done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/  /'
+  (
+   # First the #include <...> directives without #ifs, sorted for convenience.
+   for module in $modules; do
+     if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
+       :
+     else
+       func_get_include_directive "$module" | grep -v 'include "'
+     fi
+   done | LC_ALL=C sort -u
+   # Then the #include "..." directives without #ifs, sorted for convenience.
+   for module in $modules; do
+     if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
+       :
+     else
+       func_get_include_directive "$module" | grep 'include "'
+     fi
+   done | LC_ALL=C sort -u
+   # Then the #include directives that are surrounded by #ifs. Not sorted.
+   for module in $modules; do
+     if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
+       func_get_include_directive "$module"
+     fi
+   done
+  ) | sed -e '/^$/d;' -e 's/^/  /'
   echo
   echo "Don't forget to"
   echo "  - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"