diff options
author | pgen <p.gen.progs@gmail.com> | 2020-03-15 00:03:07 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2020-03-24 19:57:27 +0100 |
commit | 7c5895a3214edee5be98e643510916f83353a3ac (patch) | |
tree | ae396457b33b2204032225dd9d3e5962d607d4aa | |
parent | 5d51aea989338ae7be9a900e2514877bb0493efa (diff) |
xwcscasecmp is missing in C99, use a local version
-rw-r--r-- | index.c | 4 | ||||
-rw-r--r-- | utils.c | 23 | ||||
-rw-r--r-- | utils.h | 3 |
3 files changed, 29 insertions, 1 deletions
@@ -8,12 +8,14 @@ /* *************************************************************** */ #include <stdlib.h> +#include <stdint.h> #include <unistd.h> #include <wchar.h> #include <string.h> #include "xmalloc.h" #include "list.h" +#include "utils.h" #include "index.h" /* List of words matching the current search */ @@ -163,7 +165,7 @@ tst_fuzzy_traverse(tst_node_t * p, int (*callback)(void *), int first_call, w1s[0] = p->splitchar; w2s[0] = w; - if (wcscasecmp(w1s, w2s) == 0) + if (xwcscasecmp(w1s, w2s) == 0) { ll_node_t * node; sub_tst_t * sub_tst_data; @@ -13,6 +13,7 @@ #include <string.h> #include <ctype.h> #include <stdarg.h> +#include <wctype.h> #include "xmalloc.h" #include "list.h" #include "utils.h" @@ -279,3 +280,25 @@ isprint8(int i) return (c >= 0x20 && c < 0x7f) || (c >= (unsigned char)0xa0); } + +/* ================================================= */ +/* Private imementation of wcscasecmp wimming in c99 */ +/* ================================================= */ +int +xwcscasecmp(const wchar_t * s1, const wchar_t * s2) +{ + wchar_t c1, c2; + + while (*s1) + { + c1 = towlower(*s1); + c2 = towlower(*s2); + + if (c1 != c2) + return (int)(c1 - c2); + + s1++; + s2++; + } + return (-*s2); +} @@ -59,4 +59,7 @@ isprint7(int i); int isprint8(int i); +int +xwcscasecmp(const wchar_t * w1s, const wchar_t * w2s); + #endif |