X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=misc.c;fp=misc.c;h=29ba73985ff4711753948c2965133aea6ffbe2c0;hb=9c567e5bb78debf56e2e2c1644f252de58a80d50;hp=4bf1f60e6635638fb3474e57c65e2c5a5ed02cb2;hpb=9405f2f6974fc9f5304786ea305cf67b1028950c;p=pkg%2Fabook.git diff --git a/misc.c b/misc.c index 4bf1f60..29ba739 100644 --- a/misc.c +++ b/misc.c @@ -16,6 +16,9 @@ #include #include #include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "misc.h" #ifdef ABOOK_SRC # include "abook.h" @@ -181,7 +184,7 @@ strconcat (const char *str, ...) int -safe_strcmp(const char *s1, const char * s2) +safe_strcmp(const char *s1, const char *s2) { if (s1 == NULL && s2 == NULL) return 0; if (s1 == NULL) return -1; @@ -190,6 +193,20 @@ safe_strcmp(const char *s1, const char * s2) return strcmp(s1, s2); } +int +safe_strcoll(const char *s1, const char *s2) +{ +#ifdef HAVE_STRCOLL + if (s1 == NULL && s2 == NULL) return 0; + if (s1 == NULL) return -1; + if (s2 == NULL) return 1; + + return strcoll(s1, s2); +#else /* fall back to strcmp */ + return safe_strcmp(s1, s2); +#endif +} + char * my_getcwd() {