From 1c2c986ebb2d16e491c68656217f5352b3d809c8 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 17 Sep 2021 18:16:15 -0700 Subject: [PATCH] lefty SFcompareEntries: replace case-insensitive alternative with 'strcasecmp' This functionality is built in to libc these days. --- cmd/lefty/ws/x11/libfilereq/Dir.c | 44 ++++++++----------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/cmd/lefty/ws/x11/libfilereq/Dir.c b/cmd/lefty/ws/x11/libfilereq/Dir.c index 07e6007a0..04193f4f5 100644 --- a/cmd/lefty/ws/x11/libfilereq/Dir.c +++ b/cmd/lefty/ws/x11/libfilereq/Dir.c @@ -39,6 +39,10 @@ #include "config.h" #include +#include +#ifndef _MSC_VER +#include +#endif #ifdef SEL_FILE_IGNORE_CASE #include @@ -58,44 +62,18 @@ extern void qsort (); #include "SFDecls.h" -#ifdef SEL_FILE_IGNORE_CASE int SFcompareEntries (const void *vp, const void *vq) { const SFEntry *p = vp, *q = vq; - char *r, *s; - char c1, c2; - - r = p->real; - s = q->real; - c1 = *r++; - if (islower (c1)) { - c1 = toupper (c1); - } - c2 = *s++; - if (islower (c2)) { - c2 = toupper (c2); - } - while (c1 == c2) { - if (!c1) { - return strcmp (p->real, q->real); - } - c1 = *r++; - if (islower (c1)) { - c1 = toupper (c1); - } - c2 = *s++; - if (islower (c2)) { - c2 = toupper (c2); - } - } - return c1 - c2; -} +#ifdef SEL_FILE_IGNORE_CASE +#ifdef _MSC_VER + return _stricmp(p->real, q->real); +#else + return strcasecmp(p->real, q->real); +#endif #else /* def SEL_FILE_IGNORE_CASE */ -int SFcompareEntries (const void *vp, const void *vq) { - const SFEntry *p = vp, *q = vq; - return strcmp (p->real, q->real); -} #endif /* def SEL_FILE_IGNORE_CASE */ +} int SFgetDir (SFDir *dir) { SFEntry *result = NULL; -- 2.40.0