[make/f17] Add a patch for avoiding glob if possible
Petr Machata
pmachata at fedoraproject.org
Tue Mar 13 22:04:13 UTC 2012
commit c662835b9abb1c0331eed4036cce5671a230aa73
Author: Petr Machata <pmachata at redhat.com>
Date: Tue Mar 13 23:03:27 2012 +0100
Add a patch for avoiding glob if possible
make-3.82-expensive_glob.patch | 116 ++++++++++++++++++++++++++++++++++++++++
make.spec | 9 +++-
2 files changed, 124 insertions(+), 1 deletions(-)
---
diff --git a/make-3.82-expensive_glob.patch b/make-3.82-expensive_glob.patch
new file mode 100644
index 0000000..8663f50
--- /dev/null
+++ b/make-3.82-expensive_glob.patch
@@ -0,0 +1,116 @@
+Index: read.c
+===================================================================
+RCS file: /sources/make/make/read.c,v
+retrieving revision 1.198
+retrieving revision 1.200
+diff -u -r1.198 -r1.200
+--- read.c 29 Apr 2011 15:27:39 -0000 1.198
++++ read.c 7 May 2011 14:36:12 -0000 1.200
+@@ -2901,6 +2901,7 @@
+ const char *name;
+ const char **nlist = 0;
+ char *tildep = 0;
++ int globme = 1;
+ #ifndef NO_ARCHIVES
+ char *arname = 0;
+ char *memname = 0;
+@@ -3109,32 +3110,40 @@
+ }
+ #endif /* !NO_ARCHIVES */
+
+- switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
+- {
+- case GLOB_NOSPACE:
+- fatal (NILF, _("virtual memory exhausted"));
+-
+- case 0:
+- /* Success. */
+- i = gl.gl_pathc;
+- nlist = (const char **)gl.gl_pathv;
+- break;
+-
+- case GLOB_NOMATCH:
+- /* If we want only existing items, skip this one. */
+- if (flags & PARSEFS_EXISTS)
+- {
+- i = 0;
+- break;
+- }
+- /* FALLTHROUGH */
+-
+- default:
+- /* By default keep this name. */
++ /* glob() is expensive: don't call it unless we need to. */
++ if (!(flags & PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL)
++ {
++ globme = 0;
+ i = 1;
+ nlist = &name;
+- break;
+- }
++ }
++ else
++ switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
++ {
++ case GLOB_NOSPACE:
++ fatal (NILF, _("virtual memory exhausted"));
++
++ case 0:
++ /* Success. */
++ i = gl.gl_pathc;
++ nlist = (const char **)gl.gl_pathv;
++ break;
++
++ case GLOB_NOMATCH:
++ /* If we want only existing items, skip this one. */
++ if (flags & PARSEFS_EXISTS)
++ {
++ i = 0;
++ break;
++ }
++ /* FALLTHROUGH */
++
++ default:
++ /* By default keep this name. */
++ i = 1;
++ nlist = &name;
++ break;
++ }
+
+ /* For each matched element, add it to the list. */
+ while (i-- > 0)
+@@ -3174,7 +3183,8 @@
+ #endif /* !NO_ARCHIVES */
+ NEWELT (concat (2, prefix, nlist[i]));
+
+- globfree (&gl);
++ if (globme)
++ globfree (&gl);
+
+ #ifndef NO_ARCHIVES
+ if (arname)
+Index: tests/scripts/functions/wildcard
+===================================================================
+RCS file: /sources/make/make/tests/scripts/functions/wildcard,v
+retrieving revision 1.6
+retrieving revision 1.7
+diff -u -r1.6 -r1.7
+--- tests/scripts/functions/wildcard 13 Jun 2009 21:21:49 -0000 1.6
++++ tests/scripts/functions/wildcard 7 May 2011 14:36:11 -0000 1.7
+@@ -88,4 +88,16 @@
+ !,
+ '', "\n");
+
++# TEST #5: wildcard used to verify file existence
++
++touch('xxx.yyy');
++
++run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
++ '', "file=xxx.yyy\n");
++
++unlink('xxx.yyy');
++
++run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
++ '', "file=\n");
++
+ 1;
diff --git a/make.spec b/make.spec
index 1816aab..4585492 100644
--- a/make.spec
+++ b/make.spec
@@ -3,7 +3,7 @@ Summary: A GNU tool which simplifies the build process for users
Name: make
Epoch: 1
Version: 3.82
-Release: 10%{?dist}
+Release: 11%{?dist}
License: GPLv2+
Group: Development/Tools
URL: http://www.gnu.org/software/make/
@@ -30,6 +30,9 @@ Patch13: make-3.82-warn_undefined_function.patch
# http://lists.gnu.org/archive/html/bug-make/2011-06/msg00032.html
Patch14: make-3.82-trace.patch
+# http://lists.gnu.org/archive/html/bug-make/2011-04/msg00002.html
+Patch15: make-3.82-expensive_glob.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
@@ -59,6 +62,7 @@ makefile.
%patch12 -p0
%patch13 -p2
%patch14 -p1
+%patch15 -p0
%build
%configure
@@ -101,6 +105,9 @@ fi
%{_infodir}/*.info*
%changelog
+* Tue Mar 13 2012 Petr Machata <pmachata at redhat.com> - 1:3.82-11
+- Add a patch for avoiding glob if possible by Michael Meeks
+
* Mon Mar 12 2012 Petr Machata <pmachata at redhat.com> - 1:3.82-10
- Apply the following patches, proposed upstream by Norbert Thiebaud:
- A patch for warning on call of undefined function
More information about the scm-commits
mailing list