ref: 70bd1665792632bc3007dfb07024a072010ff975
parent: 41e9faca71d687dedc6c37892b4a7035bdb89139
author: zamfofex <zamfofex@twdb.moe>
date: Mon Mar 17 15:12:20 EDT 2025
drop dependency on 'strcasecmp'
--- a/main.c
+++ b/main.c
@@ -5,7 +5,7 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
-#include <strings.h>
+#include <ctype.h>
#include "moonfish.h"
#include "threads.h"
@@ -33,7 +33,7 @@
{int i;
for (i = 0 ; options[i].name != NULL ; i++) {- if (!strcasecmp(options[i].name, name)) return options[i].value;
+ if (!strcmp(options[i].name, name)) return options[i].value;
}
return -1;
}
@@ -253,6 +253,17 @@
if (!moonfish_equal(&chess0, &chess)) moonfish_reroot(root, &chess);
}
+static int moonfish_compare_name(char *a, char *b)
+{+ unsigned char ch0, ch1;
+ while (*a != 0 && *b != 0) {+ ch0 = *a++;
+ ch1 = *b++;
+ if (tolower(ch0) != tolower(ch1)) return 1;
+ }
+ return 0;
+}
+
static void moonfish_setoption(struct moonfish_info *info)
{char *arg, *end;
@@ -272,7 +283,7 @@
}
for (i = 0 ; info->options[i].name != NULL ; i++) {- if (!strcasecmp(arg, info->options[i].name)) break;
+ if (!moonfish_compare_name(arg, info->options[i].name)) break;
}
if (info->options[i].name == NULL) {--
⑨