]> Savannah Git Hosting - m4.git/commitdiff

Savannah Git Hosting - m4.git/commitdiff

git git@sv / m4.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa1b673)
libm4: fix path_truncate() regressions on OS/2.
Tue, 9 Dec 2014 20:46:11 +0000 (20:46 +0000)
Tue, 9 Dec 2014 20:46:11 +0000 (20:46 +0000)
* m4/path.c (m4_path_search): Ensure that a null-terminator is
appended. Re-calculate a length of path after path_truncate().

Signed-off-by: Gary V. Vaughan <gary@gnu.org>

diff --git a/m4/path.c b/m4/path.c
index 8f5772685ae91b87411685b2d50d1149814c1947..e2816cfa33c6810961a441ca9528d07ce728ad84 100644 (file)
--- a/m4/path.c
+++ b/m4/path.c
@@ -162,8 +162,6 @@ path_truncate (char *path)
return path;
}
-#else
-# define path_truncate(path) (path)
#endif
@@ -226,7 +224,11 @@ m4_path_search (m4 *context, const char *filename, const char **suffixes)
size_t mem = strlen (filename);
/* Try appending each of the suffixes we were given. */
- filepath = path_truncate (strncpy (xmalloc (mem + max_suffix_len +1), filename, mem));
+ filepath = strncpy (xmalloc (mem + max_suffix_len +1), filename, mem +1);
+#if FILE_TRUNCATE
+ filepath = path_truncate (filepath);
+ mem = strlen (filepath); /* recalculate length after truncation */
+#endif
for (i = 0; suffixes && suffixes[i]; ++i)
{
strcpy (filepath + mem, suffixes[i]);
@@ -267,9 +269,13 @@ m4_path_search (m4 *context, const char *filename, const char **suffixes)
/* Capture errno only when searching `.'. */
e = errno;
- filepath = path_truncate (strncpy (xmalloc (mem + max_suffix_len +1), pathname, mem));
+ filepath = strncpy (xmalloc (mem + max_suffix_len +1), pathname, mem +1);
free (pathname);
-
+#if FILE_TRUNCATE
+ filepath = path_truncate (filepath);
+ mem = strlen (filepath); /* recalculate length after truncation */
+#endif
+
for (i = 0; suffixes && suffixes[i]; ++i)
{
strcpy (filepath + mem, suffixes[i]);
GNU M4 source repository
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /