m4-patches
[Top][All Lists]
Advanced

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

alternate path separators


From: Eric Blake
Subject: alternate path separators
Date: Mon, 22 Sep 2008 21:27:47 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080708 Thunderbird/2.0.0.16 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On mingw, \ is the preferred path separator, and absolute paths don't
necessarily start with /.  Gnulib already makes supporting this easy, as
follows.  The master branch already had something like this patch
(http://git.savannah.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=26a80b5);
only branch-1.4 and branch-1.6 needed it.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjYYjMACgkQ84KuGfSFAYDYWACdHdiJFrk5vgL1bmhNVz72XcRM
PsAAoIWMeiaA9xNluX6w7YvAjvhP63yj
=5zLF
-----END PGP SIGNATURE-----
>From 389962e4de8a76bf4c32a0a1febb71f3289e1660 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 22 Sep 2008 21:17:43 -0600
Subject: [PATCH] Support alternate path separator.

* m4/gnulib-cache.m4: Import dirname and filenamecat modules.
* src/m4.h (includes): Add headers.
* src/path.c (m4_path_search): Avoid literal use of '/' as path
separator and when detecting absolute paths.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog          |    8 ++++++++
 m4/gnulib-cache.m4 |    4 +++-
 src/m4.h           |    2 ++
 src/path.c         |   14 +++++---------
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 258bb77..69969b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-09-22  Eric Blake  <address@hidden>
+
+       Support alternate path separator.
+       * m4/gnulib-cache.m4: Import dirname and filenamecat modules.
+       * src/m4.h (includes): Add headers.
+       * src/path.c (m4_path_search): Avoid literal use of '/' as path
+       separator and when detecting absolute paths.
+
 2008-09-16  Eric Blake  <address@hidden>
 
        Fix bootstrap for Solaris /bin/sh.
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index c2d5e1e..49f7c18 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests 
--no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset 
binary-io c-stack clean-temp cloexec close-stream closein config-h error fdl 
fflush fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload 
gpl-3.0 intprops mkstemp obstack progname regex sigaction stdbool stdint 
stdlib-safer strsignal strstr strtod strtol unlocked-io verror version-etc 
version-etc-fsf xalloc xprintf xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 
--source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests 
--no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset 
binary-io c-stack clean-temp cloexec close-stream closein config-h dirname 
error fdl fflush filenamecat fopen-safer fseeko gendocs getopt git-version-gen 
gnumakefile gnupload gpl-3.0 intprops mkstemp obstack progname regex sigaction 
stdbool stdint stdlib-safer strsignal strstr strtod strtol unlocked-io verror 
version-etc version-etc-fsf xalloc xprintf xvasprintf-posix
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
@@ -31,9 +31,11 @@ gl_MODULES([
   close-stream
   closein
   config-h
+  dirname
   error
   fdl
   fflush
+  filenamecat
   fopen-safer
   fseeko
   gendocs
diff --git a/src/m4.h b/src/m4.h
index 3bdbdca..947a89e 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -38,8 +38,10 @@
 #include "cloexec.h"
 #include "close-stream.h"
 #include "closein.h"
+#include "dirname.h"
 #include "error.h"
 #include "exitfail.h"
+#include "filenamecat.h"
 #include "obstack.h"
 #include "stdio--.h"
 #include "stdlib--.h"
diff --git a/src/path.c b/src/path.c
index 27ac4cc..4b904fc 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1,7 +1,7 @@
 /* GNU m4 -- A simple macro processor
 
-   Copyright (C) 1989, 1990, 1991, 1992, 1993, 2004, 2006, 2007 Free
-   Software Foundation, Inc.
+   Copyright (C) 1989, 1990, 1991, 1992, 1993, 2004, 2006, 2007, 2008
+   Free Software Foundation, Inc.
 
    This file is part of GNU M4.
 
@@ -141,17 +141,13 @@ m4_path_search (const char *file, char **result)
     }
 
   /* If file not found, and filename absolute, fail.  */
-  if (*file == '/' || no_gnu_extensions)
+  if (IS_ABSOLUTE_FILE_NAME (file) || no_gnu_extensions)
     return NULL;
   e = errno;
 
-  name = (char *) xmalloc (dir_max_length + 1 + strlen (file) + 1);
-
   for (incl = dir_list; incl != NULL; incl = incl->next)
     {
-      strncpy (name, incl->dir, incl->len);
-      name[incl->len] = '/';
-      strcpy (name + incl->len + 1, file);
+      name = file_name_concat (incl->dir, file, NULL);
 
 #ifdef DEBUG_INCL
       xfprintf (stderr, "m4_path_search (%s) -- trying %s\n", file, name);
@@ -172,8 +168,8 @@ m4_path_search (const char *file, char **result)
          errno = e;
          return fp;
        }
+      free (name);
     }
-  free (name);
   errno = e;
   return fp;
 }
-- 
1.6.0.2


reply via email to

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