Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/distrib/utils/libhack Pull up following revision(s) (requ...
details: https://anonhg.NetBSD.org/src/rev/e4c1b6c9b762
branches: netbsd-9
changeset: 458206:e4c1b6c9b762
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Sun Aug 18 13:12:27 2019 +0000
description:
Pull up following revision(s) (requested by martin in ticket #74):
distrib/utils/libhack/strcasecmp.c: revision 1.2
distrib/utils/libhack/strcasecmp.c: revision 1.3
Make this at least work for ASCII strings (there are way more users
than libcurses in various crunched environments, so the original assumption
of a very limited set of inputs was wrong).
use unsigned char to prevent sign extension.
diffstat:
distrib/utils/libhack/strcasecmp.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diffs (36 lines):
diff -r 0be3f2b2c595 -r e4c1b6c9b762 distrib/utils/libhack/strcasecmp.c
--- a/distrib/utils/libhack/strcasecmp.c Sun Aug 18 10:02:10 2019 +0000
+++ b/distrib/utils/libhack/strcasecmp.c Sun Aug 18 13:12:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strcasecmp.c,v 1.1 2019/07/28 10:21:18 martin Exp $ */
+/* $NetBSD: strcasecmp.c,v 1.1.2.1 2019/08/18 13:12:27 msaitoh Exp $ */
/*
* Written by Martin Husemann <martin%NetBSD.org@localhost>
@@ -8,13 +8,21 @@
#include <strings.h>
/*
- * Cheap and dirty strcasecmp() - implements just enough
- * for our libcurses in crunched environments: since we
- * know all compared strings are fixed, uppercase, and plain ASCII,
- * just use strcmp()
+ * Simple strcasecmp, try to avoid pulling in real locales
*/
int
strcasecmp(const char *s1, const char *s2)
{
- return strcmp(s1, s2);
+ unsigned char c1, c2;
+
+ do {
+ c1 = *s1++;
+ c2 = *s2++;
+ if (c1 >= 'A' && c1 <= 'Z')
+ c1 += 'a' - 'A';
+ if (c2 >= 'A' && c2 <= 'Z')
+ c2 += 'a' - 'A';
+ } while (c1 == c2 && c1 != 0 && c2 != 0);
+
+ return ((c1 == c2) ? 0 : ((c1 > c2) ? 1 : -1));
}
Home |
Main Index |
Thread Index |
Old Index