summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-03-19 13:51:31 -0600
committerEric Blake <ebb9@byu.net>2009-03-21 15:33:01 -0600
commit993cc5e94d2546ae7bfcb99cf749edb61a13efaf (patch)
tree5efccf4c0be5ed1010a59f34ca5b4d9c1b940eaa
parent44a3615b7b82cbe0fd1c4743ff4d593f00796261 (diff)
downloadm4-993cc5e94d2546ae7bfcb99cf749edb61a13efaf.tar.gz
Use memcmp2 to simplify lexicographic comparisons.
* m4/gnulib-cache.m4: Import memcmp2. * src/builtin.c (dumpdef_cmp): Use it. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit d7f708504fc66d0bcd35b60c1a5143c39197c8eb)
-rw-r--r--ChangeLog6
-rw-r--r--ltdl/m4/gnulib-cache.m43
-rw-r--r--modules/m4.c6
3 files changed, 10 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 43819ac1..f25fbe92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-21 Eric Blake <ebb9@byu.net>
+
+ Use memcmp2 to simplify lexicographic comparisons.
+ * ltdl/m4/gnulib-cache.m4: Import memcmp2.
+ * modules/m4.c (dumpdef_cmp_CB): Use it.
+
2009-03-19 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Fix m4.1 build race, exposed by parallelism through GNUmakefile.
diff --git a/ltdl/m4/gnulib-cache.m4 b/ltdl/m4/gnulib-cache.m4
index 9e664dab..45af3063 100644
--- a/ltdl/m4/gnulib-cache.m4
+++ b/ltdl/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=libgnu --source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --tests-base=tests/gnu --aux-dir=build-aux --with-tests --libtool --macro-prefix=M4 assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h configmake dirname error execute exit fdl-1.3 fflush filenamecat flexmember fopen fopen-safer freadptr freadseek fseeko gendocs gettext git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack obstack-printf-posix pipe progname propername quote regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtod strtol tempname unlocked-io vasnprintf-posix verify verror wait-process xalloc xalloc-die xmemdup0 xprintf-posix xstrndup xvasprintf-posix
+# gnulib-tool --import --dir=. --local-dir=local --lib=libgnu --source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --tests-base=tests/gnu --aux-dir=build-aux --with-tests --libtool --macro-prefix=M4 assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h configmake dirname error execute exit fdl-1.3 fflush filenamecat flexmember fopen fopen-safer freadptr freadseek fseeko gendocs gettext git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memcmp2 memmem mkstemp obstack obstack-printf-posix pipe progname propername quote regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtod strtol tempname unlocked-io vasnprintf-posix verify verror wait-process xalloc xalloc-die xmemdup0 xprintf-posix xstrndup xvasprintf-posix
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([local])
@@ -51,6 +51,7 @@ gl_MODULES([
gpl-3.0
intprops
memchr2
+ memcmp2
memmem
mkstemp
obstack
diff --git a/modules/m4.c b/modules/m4.c
index 394abf3d..f3cfc94d 100644
--- a/modules/m4.c
+++ b/modules/m4.c
@@ -30,6 +30,7 @@
#include "execute.h"
#include "memchr2.h"
+#include "memcmp2.h"
#include "quotearg.h"
#include "stdlib--.h"
#include "tempname.h"
@@ -256,10 +257,7 @@ dumpdef_cmp_CB (const void *s1, const void *s2)
{
const m4_string *a = (const m4_string *) s1;
const m4_string *b = (const m4_string *) s2;
- int result = memcmp (a->str, b->str, a->len < b->len ? a->len : b->len);
- if (!result)
- result = a->len < b->len ? -1 : b->len < a->len;
- return result;
+ return memcmp2 (a->str, a->len, b->str, b->len);
}
/* The function m4_dump_symbols () is for use by "dumpdef". It builds up a