summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2008-09-22 21:17:43 -0600
committerEric Blake <ebb9@byu.net>2008-09-22 21:17:43 -0600
commit389962e4de8a76bf4c32a0a1febb71f3289e1660 (patch)
tree98ca6af2addb62ad4390e8fc872b60751e59e47c
parentce29ff7a556f2ddd44263caa1123346f7af2d80a (diff)
downloadm4-389962e4de8a76bf4c32a0a1febb71f3289e1660.tar.gz
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 <ebb9@byu.net>
-rw-r--r--ChangeLog8
-rw-r--r--m4/gnulib-cache.m44
-rw-r--r--src/m4.h2
-rw-r--r--src/path.c14
4 files changed, 18 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 258bb778..69969b0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-09-22 Eric Blake <ebb9@byu.net>
+
+ 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 <ebb9@byu.net>
Fix bootstrap for Solaris /bin/sh.
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index c2d5e1e3..49f7c181 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 3bdbdca4..947a89e9 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 27ac4cc3..4b904fc9 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;
}