bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Patch] Support for backslash in m4 macros


From: Bruno Haible
Subject: Re: [Patch] Support for backslash in m4 macros
Date: Sat, 10 Sep 2011 11:40:59 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi,

Michael Goffioul wrote:
> I'd like to propose the 2 following patches that add support for backslashes 
> in
> path names for the corresponding macros. This allows those macros to play
> nicer in Win32 environment.

Thanks, I confirm that this is the right change to make these macros work with
msvc. But let's keep this change specific to mingw. On Unix platforms,
backslash is a normal constituent character in file names; we *don't* want to
treat backslash like slash on Unix. I'm therefore applying this patch.

The use of changequote is to avoid strange behaviour by m4, see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00119.html>.


2011-09-10  Michael Goffioul  <address@hidden>  (tiny change)
            Bruno Haible  <address@hidden>

        absolute-header, include-next: Add support for MSVC compiler.
        * m4/absolute-header.m4 (gl_ABSOLUTE_HEADER_ONE): Require
        AC_CANONICAL_HOST. On native Windows, recognize also backslash as
        directory separator in #line directives.
        * m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): On native Windows,
        recognize also backslash as directory separator in #line directives.

--- m4/absolute-header.m4.orig  Sat Sep 10 11:25:54 2011
+++ m4/absolute-header.m4       Sat Sep 10 11:20:39 2011
@@ -1,4 +1,4 @@
-# absolute-header.m4 serial 13
+# absolute-header.m4 serial 14
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,6 +53,7 @@
 #   - it is silent.
 AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
   dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
   dnl that contain only a #include of other header files and no
@@ -65,15 +66,32 @@
     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
+changequote([,])
+  gl_absolute_header_sed='\#'"${gl_dirsep_regex}"'$1#{
+      s#.*"\(.*'"${gl_dirsep_regex}"'$1\)".*#\1#
+      s#^/[^/]#//&#
+      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_cv_absolute_]AS_TR_SH([[$1]]),
 [`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
-sed -n '\#/$1#{
-        s#.*"\(.*/$1\)".*#\1#
-        s#^/[^/]#//&#
-        p
-        q
-}'`])
+  sed -n "$gl_absolute_header_sed"`])
 ])
--- m4/include_next.m4.orig     Sat Sep 10 11:25:54 2011
+++ m4/include_next.m4  Sat Sep 10 11:20:39 2011
@@ -1,4 +1,4 @@
-# include_next.m4 serial 20
+# include_next.m4 serial 21
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -207,17 +207,34 @@
                  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
+changequote([,])
+               
gl_absolute_header_sed='\#'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[#{
+                   
s#.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*#\1#
+                   s#^/[^/]#//&#
+                   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 '\#/]m4_defn([gl_HEADER_NAME])[#{
-                    s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
-                    s#^/[^/]#//&#
-                    p
-                    q
-                  }'`'"'])
+                      sed -n "$gl_absolute_header_sed"`'"'])
           m4_if([$2], [check],
             [else
                AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])

-- 
In memoriam Sergei Tretyakov <http://en.wikipedia.org/wiki/Sergei_Tretyakov>



reply via email to

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