From 69f8a328e1d41b1cd799c715a8398ab0f096a8f4 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 18 Sep 2021 15:28:04 -0700 Subject: [PATCH] lefty SFstrncmp: replace with strncasecmp This functionality is built in to libc these days. --- cmd/lefty/ws/x11/libfilereq/Path.c | 57 ++++++++---------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/cmd/lefty/ws/x11/libfilereq/Path.c b/cmd/lefty/ws/x11/libfilereq/Path.c index cbbb69436..badee85f8 100644 --- a/cmd/lefty/ws/x11/libfilereq/Path.c +++ b/cmd/lefty/ws/x11/libfilereq/Path.c @@ -40,10 +40,6 @@ #include "config.h" #include -#ifdef SEL_FILE_IGNORE_CASE -#include -#endif /* def SEL_FILE_IGNORE_CASE */ - #include #include #include "SFinternal.h" @@ -55,6 +51,10 @@ extern uid_t getuid (); #endif /* defined (SVR4) || defined (SYSV) || defined (USG) */ #include +#include +#ifndef _MSC_VER +#include +#endif #include "SFDecls.h" @@ -136,43 +136,6 @@ static void SFunreadableDir (SFDir *dir) { dir->nChars = strlen (cannotOpen); } -#ifdef SEL_FILE_IGNORE_CASE -static int SFstrncmp (char *p, char *q, int n) { - char c1, c2; - char *psave, *qsave; - int nsave; - - psave = p; - qsave = q; - nsave = n; - c1 = *p++; - if (islower (c1)) { - c1 = toupper (c1); - } - c2 = *q++; - if (islower (c2)) { - c2 = toupper (c2); - } - while ((--n >= 0) && (c1 == c2)) { - if (!c1) { - return strncmp (psave, qsave, nsave); - } - c1 = *p++; - if (islower (c1)) { - c1 = toupper (c1); - } - c2 = *q++; - if (islower (c2)) { - c2 = toupper (c2); - } - } - if (n < 0) { - return strncmp (psave, qsave, nsave); - } - return c1 - c2; -} -#endif /* def SEL_FILE_IGNORE_CASE */ - static void SFreplaceText (SFDir *dir, char *str) { int len; @@ -256,7 +219,11 @@ static int SFfindFile (SFDir *dir, char *str) { name[last] = 0; #ifdef SEL_FILE_IGNORE_CASE - result = SFstrncmp (str, name, len); +#ifdef _MSC_VER + result = _strnicmp(str, name, len); +#else + result = strncasecmp(str, name, len); +#endif #else /* def SEL_FILE_IGNORE_CASE */ result = strncmp (str, name, len); #endif /* def SEL_FILE_IGNORE_CASE */ @@ -275,7 +242,11 @@ static int SFfindFile (SFDir *dir, char *str) { name[last] = 0; #ifdef SEL_FILE_IGNORE_CASE - result = SFstrncmp (str, name, len); +#ifdef _MSC_VER + result = _strnicmp(str, name, len); +#else + result = strncasecmp(str, name, len); +#endif #else /* def SEL_FILE_IGNORE_CASE */ result = strncmp (str, name, len); #endif /* def SEL_FILE_IGNORE_CASE */ -- 2.40.0