~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to general/g.mremove/wc2regex.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <grass/gis.h>
2
 
 
3
 
char *wc2regex(const char *wc)
4
 
{
5
 
    int i, j;
6
 
    char *regex;
7
 
 
8
 
    for (i = 0, j = 2; wc[i]; i++, j++) {
9
 
        switch (wc[i]) {
10
 
        case '.':
11
 
        case '*':
12
 
            j++;
13
 
            break;
14
 
        }
15
 
    }
16
 
    regex = (char *)G_malloc(j + 1);
17
 
    j = 0;
18
 
    regex[j++] = '^';
19
 
    for (i = 0; wc[i]; i++) {
20
 
        switch (wc[i]) {
21
 
        case '.':
22
 
            regex[j++] = '\\';
23
 
            break;
24
 
        case '*':
25
 
            regex[j++] = '.';
26
 
            break;
27
 
        case '?':
28
 
            regex[j++] = '.';
29
 
            continue;
30
 
        case '{':
31
 
            regex[j++] = '(';
32
 
            continue;
33
 
        case '}':
34
 
            regex[j++] = ')';
35
 
            continue;
36
 
        case ',':
37
 
            regex[j++] = '|';
38
 
            continue;
39
 
        }
40
 
        regex[j++] = wc[i];
41
 
    }
42
 
    regex[j++] = '$';
43
 
    regex[j] = 0;
44
 
 
45
 
    return regex;
46
 
}