include_next: minimize code duplication
authorEric Blake <eblake@redhat.com>
Wed, 4 Dec 2013 17:00:00 +0000 (10:00 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 4 Dec 2013 17:58:26 +0000 (10:58 -0700)
I noticed some code duplication while trying to resolve a bug
originally reported by Rhys Ulerich:
https://lists.gnu.org/archive/html/bug-gnulib/2013-10/msg00049.html

* modules/include_next (Depends-on): Add absolute-header.
* m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): Reuse
gl_ABSOLUTE_HEADER_ONE instead of open-coding it.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
m4/include_next.m4
modules/include_next

index 0c07831..cdf69fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-12-04  Eric Blake  <eblake@redhat.com>
+
+       include_next: minimize code duplication
+       * modules/include_next (Depends-on): Add absolute-header.
+       * m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): Reuse
+       gl_ABSOLUTE_HEADER_ONE instead of open-coding it.
+
 2013-12-04  Pádraig Brady <P@draigBrady.com>
 
        getcwd: fix compile error in configure check
index 108d945..f09dbe6 100644 (file)
@@ -192,56 +192,9 @@ dnl until we can assume autoconf 2.64 or newer.
              if test AS_VAR_GET(gl_header_exists) = yes; then
              AS_VAR_POPDEF([gl_header_exists])
             ])
-               AC_LANG_CONFTEST(
-                 [AC_LANG_SOURCE(
-                    [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
-                  )])
-               dnl AIX "xlc -E" and "cc -E" omit #line directives for header
-               dnl files that contain only a #include of other header files and
-               dnl no non-comment tokens of their own. This leads to a failure
-               dnl to detect the absolute name of <dirent.h>, <signal.h>,
-               dnl <poll.h> and others. The workaround is to force preservation
-               dnl of comments through option -C. This ensures all necessary
-               dnl #line directives are present. GCC supports option -C as well.
-               case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-changequote(,)
-               case "$host_os" in
-                 mingw*)
-                   dnl For the sake of native Windows compilers (excluding gcc),
-                   dnl treat backslash as a directory separator, like /.
-                   dnl Actually, these compilers use a double-backslash as
-                   dnl directory separator, inside the
-                   dnl   # line "filename"
-                   dnl directives.
-                   gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-               dnl A sed expression that turns a string into a basic regular
-               dnl expression, for use within "/.../".
-               gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-changequote([,])
-               gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-changequote(,)dnl
-                   s|^/[^/]|//&|
-changequote([,])dnl
-                   p
-                   q
-                 }'
-               dnl eval is necessary to expand gl_absname_cpp.
-               dnl Ultrix and Pyramid sh refuse to redirect output of eval,
-               dnl so use subshell.
-               AS_VAR_SET(gl_next_header,
-                 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
-                      sed -n "$gl_absolute_header_sed"`'"'])
+           gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME)
+           AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME))
+           AS_VAR_SET(gl_next_header, ['"'$gl_header'"'])
           m4_if([$2], [check],
             [else
                AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
index 3d01928..bf0b00d 100644 (file)
@@ -5,6 +5,7 @@ Files:
 m4/include_next.m4
 
 Depends-on:
+absolute-header
 
 configure.ac: