added functions to case-insensitively compare strings that might be NULL
[rocksndiamonds.git] / src / libgame / misc.c
index 569526af608cf081e8dd976e5e8d581f91567d8e..7a3afc688ae3636bec5705994f0846933987d6a8 100644 (file)
@@ -1178,6 +1178,22 @@ boolean strEqualN(char *s1, char *s2, int n)
          strncmp(s1, s2, n) == 0);
 }
 
+boolean strEqualCase(char *s1, char *s2)
+{
+  return (s1 == NULL && s2 == NULL ? TRUE  :
+         s1 == NULL && s2 != NULL ? FALSE :
+         s1 != NULL && s2 == NULL ? FALSE :
+         strcasecmp(s1, s2) == 0);
+}
+
+boolean strEqualCaseN(char *s1, char *s2, int n)
+{
+  return (s1 == NULL && s2 == NULL ? TRUE  :
+         s1 == NULL && s2 != NULL ? FALSE :
+         s1 != NULL && s2 == NULL ? FALSE :
+         strncasecmp(s1, s2, n) == 0);
+}
+
 boolean strPrefix(char *s, char *prefix)
 {
   return (s == NULL && prefix == NULL ? TRUE  :