beifg: Simplify the implementation of be_ifg_foreach_node().
[libfirm] / win32 / regex.h
1 #ifndef REGEX_H
2 #define REGEX_H
3
4 #include <stddef.h>
5 #include <string.h>
6 #include <stdlib.h>
7
8 /* naive and wrong regex stubs */
9 typedef struct regex_t {
10         char *pattern;
11 } regex_t;
12
13 typedef size_t regoff_t;
14
15 typedef struct regmatch_t {
16         regoff_t rm_so;
17         regoff_t rm_eo;
18 } regmatch_t;
19
20 #define REG_EXTENDED 1
21 #define REG_ICASE    2
22 #define REG_NOSUB    4
23 #define REG_NEWLINE  8
24 #define REG_NOTBOL   16
25 #define REG_NOTEOL   32
26
27 #define REG_NOMATCH 1
28
29 int regcomp(regex_t *regex, const char *pattern, int cflags)
30 {
31         (void) cflags;
32         regex->pattern = _strdup(pattern);
33         return 0;
34 }
35
36 int regexec(const regex_t *regex, const char *haystack, size_t nmatch, regmatch_t pmatch[], int flags)
37 {
38         size_t i = 0;
39         const char *pattern = regex->pattern;
40         for (i = 0; pattern[i] != '\0'; ++i) {
41                 if (pattern[i] != haystack[i])
42                         return REG_NOMATCH;
43         }
44         return 0;
45 }
46
47 void regfree(regex_t *regex)
48 {
49         free(regex->pattern);
50 }
51
52 #endif