summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2010-07-19 07:10:53 +0000
committerPaul Smith <psmith@gnu.org>2010-07-19 07:10:53 +0000
commitfba20a776da6d4a36db21d9b21e9e937bef00ac3 (patch)
tree4cf2063962595ca40234d4832a00f7eeb7ebb321 /misc.c
parentdf2fa7c5a5726b4e0a50e0eff209a3518ab19603 (diff)
downloadgunmake-fba20a776da6d4a36db21d9b21e9e937bef00ac3.tar.gz
- Many fixup patches from Savannah.
- Fix the test suite on Solaris (from Boris) - Update the manual for .ONESHELL
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index 39c2835..7a6f773 100644
--- a/misc.c
+++ b/misc.c
@@ -614,6 +614,34 @@ strcasecmp (const char *s1, const char *s2)
}
}
#endif
+
+#if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI
+
+/* If we don't have strncasecmp() (from POSIX), or anything that can
+ substitute for it, define our own version. */
+
+int
+strncasecmp (const char *s1, const char *s2, int n)
+{
+ while (n-- > 0)
+ {
+ int c1 = (int) *(s1++);
+ int c2 = (int) *(s2++);
+
+ if (isalpha (c1))
+ c1 = tolower (c1);
+ if (isalpha (c2))
+ c2 = tolower (c2);
+
+ if (c1 != '\0' && c1 == c2)
+ continue;
+
+ return (c1 - c2);
+ }
+
+ return 0;
+}
+#endif
#ifdef GETLOADAVG_PRIVILEGED