From: Eric Blake Date: Wed, 4 Dec 2013 17:00:00 +0000 (-0700) Subject: include_next: minimize code duplication X-Git-Tag: snapshot-start~18 X-Git-Url: http://erislabs.net/gitweb/?p=gnulib.git;a=commitdiff_plain;h=74540d44dc16bfd3546e39ae2d7262f32a4147ab include_next: minimize code duplication 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 --- diff --git a/ChangeLog b/ChangeLog index 0c0783112..cdf69fa96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-12-04 Eric Blake + + 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 getcwd: fix compile error in configure check diff --git a/m4/include_next.m4 b/m4/include_next.m4 index 108d94567..f09dbe663 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 , , - dnl 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 3d019289f..bf0b00da3 100644 --- a/modules/include_next +++ b/modules/include_next @@ -5,6 +5,7 @@ Files: m4/include_next.m4 Depends-on: +absolute-header configure.ac: