bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] include_next: minimize code duplication


From: Eric Blake
Subject: [PATCH] include_next: minimize code duplication
Date: Wed, 4 Dec 2013 10:25:15 -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 <address@hidden>
---
 ChangeLog            |  7 +++++++
 m4/include_next.m4   | 53 +++-------------------------------------------------
 modules/include_next |  1 +
 3 files changed, 11 insertions(+), 50 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b7325e8..8142f34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-12-04  Eric Blake  <address@hidden>
+
+       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-03  Eric Blake  <address@hidden>

        bootstrap: work around BSD toolchain snafu
diff --git a/m4/include_next.m4 b/m4/include_next.m4
index 108d945..f09dbe6 100644
--- a/m4/include_next.m4
+++ b/m4/include_next.m4
@@ -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'>'])
diff --git a/modules/include_next b/modules/include_next
index 3d01928..bf0b00d 100644
--- a/modules/include_next
+++ b/modules/include_next
@@ -5,6 +5,7 @@ Files:
 m4/include_next.m4

 Depends-on:
+absolute-header

 configure.ac:

-- 
1.8.3.1




reply via email to

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