~ubuntu-branches/ubuntu/wily/spatialite/wily-proposed

« back to all changes in this revision

Viewing changes to test/test_helpers.h

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-07-14 11:57:46 UTC
  • mfrom: (16.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150714115746-e2iljfmb5sq7o5hh
Tags: 4.3.0-1
Move from experimental to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#else
4
4
#define UNUSED
5
5
#endif
 
6
 
 
7
#ifdef __WIN32
 
8
/*
 
9
 * Windows replacement for strcastr
 
10
 *
 
11
 * original code from:
 
12
 * https://code.google.com/p/msysgit/source/browse/compat/strcasestr.c?repo=4msysgit&name=mingw-v1.5.2.4-devel
 
13
 */
 
14
static char *
 
15
strcasestr (const char *haystack, const char *needle)
 
16
{
 
17
    int nlen = strlen (needle);
 
18
    int hlen = strlen (haystack) - nlen + 1;
 
19
    int i;
 
20
 
 
21
    for (i = 0; i < hlen; i++)
 
22
      {
 
23
          int j;
 
24
          for (j = 0; j < nlen; j++)
 
25
            {
 
26
                unsigned char c1 = haystack[i + j];
 
27
                unsigned char c2 = needle[j];
 
28
                if (toupper (c1) != toupper (c2))
 
29
                    goto next;
 
30
            }
 
31
          return (char *) haystack + i;
 
32
        next:
 
33
          ;
 
34
      }
 
35
    return NULL;
 
36
}
 
37
#endif
 
38
 
 
39
#ifdef __WIN32
 
40
/* 
 
41
 * public domain strtok_r() by Charlie Gordon
 
42
 *
 
43
 *   from comp.lang.c  9/14/2007
 
44
 *
 
45
 *      http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
 
46
 *
 
47
 *     (Declaration that it's public domain):
 
48
 *      http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
 
49
 */
 
50
static char *
 
51
strtok_r (char *str, const char *delim, char **nextp)
 
52
{
 
53
    char *ret;
 
54
 
 
55
    if (str == NULL)
 
56
      {
 
57
          str = *nextp;
 
58
      }
 
59
 
 
60
    str += strspn (str, delim);
 
61
 
 
62
    if (*str == '\0')
 
63
      {
 
64
          return NULL;
 
65
      }
 
66
 
 
67
    ret = str;
 
68
 
 
69
    str += strcspn (str, delim);
 
70
 
 
71
    if (*str)
 
72
      {
 
73
          *str++ = '\0';
 
74
      }
 
75
 
 
76
    *nextp = str;
 
77
 
 
78
    return ret;
 
79
}
 
80
#endif