summaryrefslogtreecommitdiffstats
path: root/repos/autotools/autotools-git/m4/m4-patches/0002-modules-inclusions-fix-path-searching-issues.patch
diff options
context:
space:
mode:
Diffstat (limited to 'repos/autotools/autotools-git/m4/m4-patches/0002-modules-inclusions-fix-path-searching-issues.patch')
-rw-r--r--repos/autotools/autotools-git/m4/m4-patches/0002-modules-inclusions-fix-path-searching-issues.patch130
1 files changed, 84 insertions, 46 deletions
diff --git a/repos/autotools/autotools-git/m4/m4-patches/0002-modules-inclusions-fix-path-searching-issues.patch b/repos/autotools/autotools-git/m4/m4-patches/0002-modules-inclusions-fix-path-searching-issues.patch
index 2389f33..1ee896b 100644
--- a/repos/autotools/autotools-git/m4/m4-patches/0002-modules-inclusions-fix-path-searching-issues.patch
+++ b/repos/autotools/autotools-git/m4/m4-patches/0002-modules-inclusions-fix-path-searching-issues.patch
@@ -1,34 +1,40 @@
-From 60af89a04825c502ac374b3cf3c077e6427451c8 Mon Sep 17 00:00:00 2001
+From e287753cb90be996ae932aeb63b58a8075f8189a Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
-Date: Wed, 28 May 2014 12:25:52 +0200
-Subject: [PATCH 2/2] modules,inclusions: fix path searching issues
+Date: Thu, 16 Jun 2016 13:42:13 +0200
+Subject: [PATCH 2/2] modules, inclusions: fix path searching issues
-When 'm4' directory occurred in M4PATH or current directory, the
-m4 processor ended up with message 'Is a directory' and did not
-continue to search for 'm4.so' somewhere else in path.
+When 'm4' directory occurred in M4PATH or current directory
+(happens very often with autotooled packages), the m4 processor
+ended up with message 'Is a directory' and did not continue to
+search for 'm4.so' somewhere else in path.
-Expanding 'include(Makefile)' for example failed when M4PATH was
-set because the current directory was not searched.
+Expanding 'include(Makefile)' from $(srcdir) for example failed
+when M4PATH was set because the current directory was not
+searched.
* m4/path.c (try_prefixes): New function.
-(m4_path_search): Deduplicate suffix trying by try_prefixes.
+(m4_path_search): De-duplicate suffix trying by try_prefixes.
(m4__include_init): Always prepend current directory.
* tests/testsuite.at (AT_CHECK_M4): Filter out test output
dependant on user's setup.
* tests/options.at: Adjust expected stderr output.
+* tests/others.at: As we now return really the _first_ errno
+occured during path searching, we need to adjust expected error
+output.
* doc/m4.texi: likewise.
---
doc/m4.texi | 2 +
- m4/path.c | 111 +++++++++++++++++++++++++++--------------------------
+ m4/path.c | 126 ++++++++++++++++++++++++++++-------------------------
tests/options.at | 6 ++-
+ tests/others.at | 8 ++--
tests/testsuite.at | 1 +
- 4 files changed, 64 insertions(+), 56 deletions(-)
+ 5 files changed, 77 insertions(+), 66 deletions(-)
diff --git a/doc/m4.texi b/doc/m4.texi
-index 8d40cae..95eb083 100644
+index ba1b157..7f0d375 100644
--- a/doc/m4.texi
+++ b/doc/m4.texi
-@@ -4682,6 +4682,8 @@
+@@ -4683,6 +4683,8 @@
@comment options: -dip
@example
$ @kbd{m4 -dip -I doc/examples}
@@ -38,16 +44,18 @@ index 8d40cae..95eb083 100644
define(`foo', `m4wrap(`wrapped text
')dnl')
diff --git a/m4/path.c b/m4/path.c
-index 3a93289..66e460b 100644
+index ef743a3..a1ff090 100644
--- a/m4/path.c
+++ b/m4/path.c
-@@ -143,6 +143,53 @@ m4_add_include_directory (m4 *context, const char *dir, bool prepend)
+@@ -182,6 +182,63 @@ m4_add_include_directory (m4 *context, const char *dir, bool prepend)
#endif
}
-+/* FILENAME must contain directory path also */
++/* Search for m4 module in DIRNAME directory. Try to test _all_ SUFFIXES with
++ FILENAME; use the first combination which seems to be correct m4 module. If
++ the FILENAME is absolute path, DIRNAME shall be NULL. */
+static char *
-+try_prefixes (m4 *context, const char *dirname, const char *filename,
++try_suffixes (m4 *context, const char *dirname, const char *filename,
+ size_t max_suffix_len, const char **suffixes)
+{
+ int e = 0, i;
@@ -56,20 +64,27 @@ index 3a93289..66e460b 100644
+ size_t mem = strlen (filepath);
+ filepath = xrealloc (filepath, mem + max_suffix_len + 1);
+
-+ /* Try appending each of the suffixes we were given. */
++#if TRUNCATE_FILENAME
++ filepath = path_truncate (filepath);
++ mem = strlen (filepath); /* recalculate length after truncation */
++#endif
++
+#ifdef DEBUG_INCL
+ xfprintf (stderr, "path_search (%s) -- trying %s\n", filename, filepath);
+#endif
+
-+
-+ /* If search fails, we'll use the error we got from the first try
-+ access (usually with no suffix). */
++ /* If search fails, we'll use the errno we got from the first unsuccessful
++ try. */
+ for (i = 0; suffixes && suffixes[i]; !i && (e = errno), ++i)
+ {
+ struct stat st;
+ int rc;
+ strcpy (filepath + mem, suffixes[i]);
+
++ /* Use stat() here rather than access() because access does not give us
++ S_ISDIR(st.st_mode) info. Choosing a module which we have no
++ privileges to open is not problem because dlopening later will fail
++ anyway with a understandable error. */
+ if (stat (filepath, &st))
+ continue;
+
@@ -82,6 +97,7 @@ index 3a93289..66e460b 100644
+ filepath));
+ return filepath;
+ }
++
+ if (S_ISDIR (st.st_mode))
+ errno = EISDIR;
+ }
@@ -95,7 +111,7 @@ index 3a93289..66e460b 100644
/* Search for FILENAME according to -B options, `.', -I options, then
M4PATH environment. If successful, return the open file, and if
-@@ -181,61 +228,18 @@ m4_path_search (m4 *context, const char *filename, const char **suffixes)
+@@ -220,69 +277,18 @@ m4_path_search (m4 *context, const char *filename, const char **suffixes)
/* If file is absolute, or if we are not searching a path, a single
lookup will do the trick. */
if (IS_ABSOLUTE_FILE_NAME (filename))
@@ -103,7 +119,11 @@ index 3a93289..66e460b 100644
- size_t mem = strlen (filename);
-
- /* Try appending each of the suffixes we were given. */
-- filepath = strncpy (xmalloc (mem + max_suffix_len +1), filename, mem);
+- filepath = strncpy (xmalloc (mem + max_suffix_len +1), filename, mem +1);
+-#if TRUNCATE_FILENAME
+- filepath = path_truncate (filepath);
+- mem = strlen (filepath); /* recalculate length after truncation */
+-#endif
- for (i = 0; suffixes && suffixes[i]; ++i)
- {
- strcpy (filepath + mem, suffixes[i]);
@@ -116,13 +136,13 @@ index 3a93289..66e460b 100644
- e = errno;
- }
- free (filepath);
--
++ return try_suffixes (context, NULL, filename, max_suffix_len, suffixes);
+
- /* No such file. */
- errno = e;
- return NULL;
- }
-+ return try_prefixes (context, NULL, filename, max_suffix_len, suffixes);
-
+-
- for (incl = m4__get_search_path (context)->list;
- incl != NULL; incl = incl->next)
+ for (incl = m4__get_search_path (context)->list, i = 0;
@@ -146,14 +166,18 @@ index 3a93289..66e460b 100644
- else if (!incl->len)
- /* Capture errno only when searching `.'. */
- e = errno;
--
-- filepath = strncpy (xmalloc (mem + max_suffix_len +1), pathname, mem);
-- free (pathname);
-+ char *pathname = try_prefixes (context, incl->dir, filename,
++ char *pathname = try_suffixes (context, incl->dir, filename,
+ max_suffix_len, suffixes);
+ if (pathname)
+ return pathname;
+- filepath = strncpy (xmalloc (mem + max_suffix_len +1), pathname, mem +1);
+- free (pathname);
+-#if TRUNCATE_FILENAME
+- filepath = path_truncate (filepath);
+- mem = strlen (filepath); /* recalculate length after truncation */
+-#endif
+-
- for (i = 0; suffixes && suffixes[i]; ++i)
- {
- strcpy (filepath + mem, suffixes[i]);
@@ -166,21 +190,11 @@ index 3a93289..66e460b 100644
}
errno = e;
-@@ -336,8 +340,7 @@ m4__include_init (m4 *context)
- /* If M4PATH was not set, then search just the current directory by
- default. */
- assert (info);
-- if (info->list_end == NULL)
-- search_path_add (info, "", false);
-+ search_path_add (info, "", true);
-
- /* Non-core modules installation directory. */
- search_path_add (info, PKGLIBDIR, false);
diff --git a/tests/options.at b/tests/options.at
-index 8503f8f..574ed3f 100644
+index 7084207..8fa19b6 100644
--- a/tests/options.at
+++ b/tests/options.at
-@@ -422,10 +422,12 @@ m4debug: input from m4wrap exhausted
+@@ -423,10 +423,12 @@ m4debug: input from m4wrap exhausted
dnl Test all flags.
AT_CHECK_M4([-dV in], [0], [[3
0
@@ -194,7 +208,7 @@ index 8503f8f..574ed3f 100644
m4debug: module gnu: opening file
m4debug: module gnu: init hook called
m4debug: module gnu: opened
-@@ -700,7 +702,7 @@ AT_CHECK_M4([-I post -B pre in], [1],
+@@ -701,7 +703,7 @@ AT_CHECK_M4([-I post -B pre in], [1],
[[in pre/foo
in ./bar
in post/blah
@@ -203,11 +217,35 @@ index 8503f8f..574ed3f 100644
]])
AT_CLEANUP
+diff --git a/tests/others.at b/tests/others.at
+index 9c7a0c6..507ef78 100644
+--- a/tests/others.at
++++ b/tests/others.at
+@@ -144,15 +144,15 @@ AT_DATA([in3.m4],
+
+ AT_CHECK_M4([in1.m4/], [1], [], [stderr])
+ dnl mingw fails with EINVAL rather than the expected ENOTDIR
+-AT_CHECK([$SED 's/Invalid argument/Not a directory/' stderr], [0],
+-[[m4: cannot open file 'in1.m4/': Not a directory
++AT_CHECK([$SED 's/Invalid argument/No such file or directory/' stderr], [0],
++[[m4: cannot open file 'in1.m4/': No such file or directory
+ ]])
+
+ AT_CHECK_M4([in1.m4], [1], [[
+ ]], [stderr])
+ dnl mingw fails with EINVAL rather than the expected ENOTDIR
+-AT_CHECK([$SED 's/Invalid argument/Not a directory/' stderr], [0],
+-[[m4:in1.m4:1: include: cannot open file 'in2.m4/': Not a directory
++AT_CHECK([$SED 's/Invalid argument/No such file or directory/' stderr], [0],
++[[m4:in1.m4:1: include: cannot open file 'in2.m4/': No such file or directory
+ ]])
+
+ AT_CHECK_M4([in2.m4], [0], [[
diff --git a/tests/testsuite.at b/tests/testsuite.at
-index 26d8346..66bb70b 100644
+index a7cdfc4..20246e2 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
-@@ -88,6 +88,7 @@ m4_case([$4], [], [], [ignore], [],
+@@ -89,6 +89,7 @@ m4_case([$4], [], [], [ignore], [],
/^m4debug: module/s/opening file.*/opening file/
s/\(cannot open module [^:]*\):.*/\1/
s/Bad file number/Bad file descriptor/
@@ -216,5 +254,5 @@ index 26d8346..66bb70b 100644
' stderr >&2]], [0], [], [$4])])
])
--
-1.9.3
+2.7.4