--- deliantra/server/common/re-cmp.C 2006/08/29 08:01:35 1.2 +++ deliantra/server/common/re-cmp.C 2006/09/08 04:51:08 1.3 @@ -1,6 +1,6 @@ /* * static char *rcsid_player_c = - * "$Id: re-cmp.C,v 1.2 2006/08/29 08:01:35 root Exp $"; + * "$Id: re-cmp.C,v 1.3 2006/09/08 04:51:08 pippijn Exp $"; */ @@ -37,9 +37,9 @@ /* P r o t o t y p e s */ const char *re_cmp(const char *, const char *); -static Boolean re_cmp_step(const char *, const char *, unsigned, int); +static bool re_cmp_step(const char *, const char *, unsigned, int); static void re_init(void); -static Boolean re_match_token(uchar, selection *); +static bool re_match_token(unsigned char, selection *); static const char *re_get_token(selection *, const char *); #ifdef DEBUG2 static void re_dump_sel(selection *); @@ -47,7 +47,7 @@ /* G l o b a l v a r i a b l e s */ -static Boolean re_init_done = False; +static bool re_init_done = false; static selection *re_token[RE_TOKEN_MAX]; static const char *re_substr[RE_TOKEN_MAX]; static unsigned int re_token_depth; @@ -62,10 +62,10 @@ const char * re_cmp(const char *str, const char *regexp) { const char *next_regexp; - Boolean once = False; - Boolean matched; + bool once = false; + bool matched; - if (re_init_done == False) + if (re_init_done == false) re_init(); #ifdef SAFE_CHECKS @@ -73,7 +73,7 @@ return NULL; #endif if (*regexp == '^') { - once = True; + once = true; ++regexp; } if (*regexp == 0) { @@ -85,7 +85,7 @@ re_token_depth = 0; re_substr[0] = next_regexp; - matched = False; + matched = false; while (*str != '\0' && !(matched = re_match_token(*str, re_token[0]))) str++; @@ -98,18 +98,18 @@ if (once) { switch (re_token[0]->repeat) { case rep_once: - if (matched == False) + if (matched == false) return NULL; break; case rep_once_or_more: - if (matched == False) + if (matched == false) return NULL; if (re_cmp_step(str+1, regexp, 0, 1)) return str; break; case rep_null_or_once: - if (matched == False) + if (matched == false) return re_cmp_step(str, next_regexp, 1, 0) ? str : NULL; break; case rep_null_or_more: @@ -161,7 +161,7 @@ /* A u x i l l i a r y f u n c t i o n s */ -static Boolean +static bool re_cmp_step(const char *str, const char *regexp, unsigned slot, int matches) { /* str - string to match * regexp - pattern @@ -169,7 +169,7 @@ * matches - how many times the token has matched */ const char *next_regexp; - Boolean matched; + bool matched; #ifdef DEBUG /* fprintf(stderr, "['%s', '%s', %u, %d]\n", str, regexp, slot, matches);*/ @@ -178,7 +178,7 @@ if (*regexp == 0) { /* When we reach the end of the regexp, the match is a success */ - return True; + return true; } /* This chunk of code makes sure that the regexp-tokenising happens @@ -191,7 +191,7 @@ next_regexp = re_get_token(re_token[slot], regexp); if (next_regexp == NULL) { /* Syntax error, what else can we do? */ - return False; + return false; } re_substr[slot] = next_regexp; } else { @@ -207,18 +207,18 @@ switch (re_token[slot]->repeat) { case rep_once: - if (matches == 1) { /* (matches == 1) => (matched == True) */ + if (matches == 1) { /* (matches == 1) => (matched == true) */ return re_cmp_step(str+1, next_regexp, slot+1, 0); } - return False; + return false; case rep_once_or_more: - if (matched) { /* (matched == True) => (matches >= 1) */ + if (matched) { /* (matched == true) => (matches >= 1) */ /* First check if the current token repeats more */ if (re_cmp_step(str+1, regexp, slot, matches)) - return True; + return true; return re_cmp_step(str+1, next_regexp, slot+1, 0); } - return False; + return false; case rep_null_or_once: /* We must go on to the next token, but should we advance str? */ if (matches == 0) { @@ -226,17 +226,17 @@ } else if (matches == 1) { return re_cmp_step(str+1, next_regexp, slot+1, 0); } - return False; /* Not reached */ + return false; /* Not reached */ case rep_null_or_more: if (matched) { /* Look for further repeats, advance str */ if (re_cmp_step(str+1, regexp, slot, matches)) - return True; + return true; return re_cmp_step(str, next_regexp, slot+1, 0); } return re_cmp_step(str, next_regexp, slot+1, 0); } - return False; + return false; } static void @@ -247,14 +247,14 @@ for (i = 1; i < RE_TOKEN_MAX; i++) re_token[i] = NULL; - re_init_done = True; + re_init_done = true; } -static Boolean -re_match_token(uchar c, selection *sel) { +static bool +re_match_token(unsigned char c, selection *sel) { switch (sel->type) { case sel_any: - return True; + return true; case sel_end: return (c == 0); case sel_single: @@ -268,7 +268,7 @@ case sel_not_range: return (c < sel->u.range.low && c > sel->u.range.high); } - return False; + return false; } /* re_get_token - get regular expression token @@ -285,8 +285,8 @@ # define exit_if_null #endif - Boolean quoted = False; - uchar looking_at; + bool quoted = false; + unsigned char looking_at; #ifdef SAFE_CHECKS if (sel == NULL || regexp == NULL || *regexp == 0) @@ -298,7 +298,7 @@ switch (looking_at) { case '$': if (quoted) { - quoted = False; + quoted = false; sel->type = sel_single; sel->u.single = looking_at; } else { @@ -307,7 +307,7 @@ break; case '.': if (quoted) { - quoted = False; + quoted = false; sel->type = sel_single; sel->u.single = looking_at; } else { @@ -319,18 +319,18 @@ * don't trust the compiler to analyse liveness. */ if (quoted) { - quoted = False; + quoted = false; sel->type = sel_single; sel->u.single = looking_at; } else { - Boolean neg = False; - uchar first, last = 0; + bool neg = false; + unsigned char first, last = 0; exit_if_null; looking_at = *regexp++; if (looking_at == '^') { - neg = True; + neg = true; exit_if_null; looking_at = *regexp++; } @@ -377,7 +377,7 @@ * complex with an array. */ int i; - uchar previous; + unsigned char previous; sel->type = sel_array; memset(sel->u.array, neg, sizeof(sel->u.array)); @@ -437,15 +437,15 @@ break; case '\\': if (quoted) { - quoted = False; + quoted = false; sel->type = sel_single; sel->u.single = looking_at; } else { - quoted = True; + quoted = true; } break; default: - quoted = False; + quoted = false; sel->type = sel_single; sel->u.single = looking_at; break; @@ -490,7 +490,7 @@ { int i; printf("["); - for (i = 0; i < UCHAR_MAX; i++) { + for (i = 0; i < uchar_MAX; i++) { if (sel->u.array[i]) { printf("%c", i); }