Introduce strcasecmp_ptr() and use it in a few places

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-06-03 15:31:28 +02:00
parent 6773049a4c
commit 6cf3011c6c
3 changed files with 24 additions and 45 deletions
+8 -7
View File
@@ -19,18 +19,19 @@
#include "util.h"
int strcmp_ptr(const char *a, const char *b) {
/* Like strcmp(), but tries to make sense of NULL pointers */
if (a && b)
return strcmp(a, b);
return CMP(a, b); /* Direct comparison of pointers, one of which is NULL */
}
if (!a && b)
return -1;
int strcasecmp_ptr(const char *a, const char *b) {
/* Like strcasecmp(), but tries to make sense of NULL pointers */
if (a && !b)
return 1;
return 0;
if (a && b)
return strcasecmp(a, b);
return CMP(a, b); /* Direct comparison of pointers, one of which is NULL */
}
char* endswith(const char *s, const char *postfix) {