Debian Codegraph @

src/base/6string.c

raw
1 /*
2 * 6string.c - some standard funtions for string manipulation
3 */
4
5 #include "../base/mdjvucfg.h"
6 #include <minidjvu/minidjvu.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <assert.h>
10 #include <stdio.h>
11 #include <ctype.h>
12
13 /* Under Windows (MSVC), there is usually no strcasecmp.
14 * So here's the rewrite.
15 */
16 static int my_strcasecmp(const char *s1, const char *s2)
17 {
18 int c1, c2;
19 while(*s1)
20 {
21 int d;
22 c1 = tolower(*s1++); c2 = tolower(*s2++);
23 d = c1 - c2;
24 if (d) return d;
25 }
26 return *s2;
27 }
28
29 MDJVU_IMPLEMENT int mdjvu_ends_with_ignore_case(const char *s, const char *prefix)
30 {
31 size_t sl = strlen(s);
32 size_t pl = strlen(prefix);
33 if (sl < pl) return 0;
34 return !my_strcasecmp(s + sl - pl, prefix);
35 }
36
37