an easy fix for strcmpi and we move on
Here in branch paxed-new_lev_comp-B (branched from paxed-new_lev_comp) is a simple fix for the strcmpi issue. The bottom section of lev_main.c has a bunch of forced linkages to names from NetHack etc. #ifdef STRICT_REF_DEF bunch of stuff #endif This change to lev_main should make everything work for those that don't supply a compiler library version of strcmpi() With this patch, those people can just add a -DSTRICT_REF_DEF to their compile line for lev_main.c. This would close the issue in a simple way, and doesn't require linking in anything new to the level compiler, or modifying any port's Makefiles etc.
This commit is contained in:
+22
-4
@@ -697,7 +697,7 @@ funcdef_defined(f, name, casesense)
|
|||||||
if (casesense) {
|
if (casesense) {
|
||||||
if (!strcmp(name, f->name)) return f;
|
if (!strcmp(name, f->name)) return f;
|
||||||
} else {
|
} else {
|
||||||
if (!strcasecmp(name, f->name)) return f;
|
if (!strcmpi(name, f->name)) return f;
|
||||||
}
|
}
|
||||||
f = f->next;
|
f = f->next;
|
||||||
}
|
}
|
||||||
@@ -748,7 +748,7 @@ vardef_defined(f, name, casesense)
|
|||||||
if (casesense) {
|
if (casesense) {
|
||||||
if (!strcmp(name, f->name)) return f;
|
if (!strcmp(name, f->name)) return f;
|
||||||
} else {
|
} else {
|
||||||
if (!strcasecmp(name, f->name)) return f;
|
if (!strcmpi(name, f->name)) return f;
|
||||||
}
|
}
|
||||||
f = f->next;
|
f = f->next;
|
||||||
}
|
}
|
||||||
@@ -988,7 +988,7 @@ char c;
|
|||||||
/* didn't find it; lets try case insensitive search */
|
/* didn't find it; lets try case insensitive search */
|
||||||
for (i = LOW_PM; i < NUMMONS; i++)
|
for (i = LOW_PM; i < NUMMONS; i++)
|
||||||
if (!class || class == mons[i].mlet)
|
if (!class || class == mons[i].mlet)
|
||||||
if (!strcasecmp(s, mons[i].mname)) {
|
if (!strcmpi(s, mons[i].mname)) {
|
||||||
if (be_verbose)
|
if (be_verbose)
|
||||||
lc_warning("Monster type \"%s\" matches \"%s\".", s, mons[i].mname);
|
lc_warning("Monster type \"%s\" matches \"%s\".", s, mons[i].mname);
|
||||||
return i;
|
return i;
|
||||||
@@ -1020,7 +1020,7 @@ char c; /* class */
|
|||||||
for (i = class ? bases[class] : 0; i < NUM_OBJECTS; i++) {
|
for (i = class ? bases[class] : 0; i < NUM_OBJECTS; i++) {
|
||||||
if (class && objects[i].oc_class != class) break;
|
if (class && objects[i].oc_class != class) break;
|
||||||
objname = obj_descr[i].oc_name;
|
objname = obj_descr[i].oc_name;
|
||||||
if (objname && !strcasecmp(s, objname)) {
|
if (objname && !strcmpi(s, objname)) {
|
||||||
if (be_verbose)
|
if (be_verbose)
|
||||||
lc_warning("Object type \"%s\" matches \"%s\".", s, objname);
|
lc_warning("Object type \"%s\" matches \"%s\".", s, objname);
|
||||||
return i;
|
return i;
|
||||||
@@ -1381,6 +1381,24 @@ struct window_procs windowprocs;
|
|||||||
# ifdef DEFINE_OSPEED
|
# ifdef DEFINE_OSPEED
|
||||||
short ospeed;
|
short ospeed;
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef STRNCMPI
|
||||||
|
int
|
||||||
|
strncmpi(s1, s2, n) /* case insensitive counted string comparison */
|
||||||
|
register const char *s1, *s2;
|
||||||
|
register int n; /*(should probably be size_t, which is usually unsigned)*/
|
||||||
|
{ /*{ aka strncasecmp }*/
|
||||||
|
register char t1, t2;
|
||||||
|
|
||||||
|
while (n--) {
|
||||||
|
if (!*s2) return (*s1 != 0); /* s1 >= s2 */
|
||||||
|
else if (!*s1) return -1; /* s1 < s2 */
|
||||||
|
t1 = lowc(*s1++);
|
||||||
|
t2 = lowc(*s2++);
|
||||||
|
if (t1 != t2) return (t1 > t2) ? 1 : -1;
|
||||||
|
}
|
||||||
|
return 0; /* s1 == s2 */
|
||||||
|
}
|
||||||
|
# endif /* STRNCMPI */
|
||||||
#endif /* STRICT_REF_DEF */
|
#endif /* STRICT_REF_DEF */
|
||||||
|
|
||||||
/*lev_main.c*/
|
/*lev_main.c*/
|
||||||
|
|||||||
Reference in New Issue
Block a user