Changeset 12204 for trunk/libtransmission/wildmat.c
- Timestamp:
- Mar 22, 2011, 3:19:54 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/wildmat.c
r11599 r12204 21 21 ** The precondition that must be fulfilled is that DoMatch will consume 22 22 ** at least one character in text. This is true if *p is neither '*' nor 23 ** '\0'.) The last return has ABORT instead of FALSEto avoid quadratic23 ** '\0'.) The last return has ABORT instead of false to avoid quadratic 24 24 ** behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx". With 25 ** FALSE, each star-loop has to run to the end of the text; with ABORT25 ** false, each star-loop has to run to the end of the text; with ABORT 26 26 ** only the last one does. 27 27 ** 28 28 ** Once the control of one instance of DoMatch enters the star-loop, that 29 ** instance will return either TRUEor ABORT, and any calling instance29 ** instance will return either true or ABORT, and any calling instance 30 30 ** will therefore return immediately after (without calling recursively 31 31 ** again). In effect, only one star-loop is ever active. It would be … … 52 52 53 53 /* 54 ** Match text and p, return TRUE, FALSE, or ABORT.54 ** Match text and p, return true, false, or ABORT. 55 55 */ 56 56 static int … … 71 71 default: 72 72 if (*text != *p) 73 return FALSE;73 return false; 74 74 continue; 75 75 case '?': … … 82 82 if (*p == '\0') 83 83 /* Trailing star matches everything. */ 84 return TRUE;84 return true; 85 85 while (*text) 86 if ((matched = DoMatch(text++, p)) != FALSE)86 if ((matched = DoMatch(text++, p)) != false) 87 87 return matched; 88 88 return ABORT; 89 89 case '[': 90 reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE;90 reverse = p[1] == NEGATE_CLASS ? true : false; 91 91 if (reverse) 92 92 /* Inverted character class. */ 93 93 p++; 94 for (last = 0400, matched = FALSE; *++p && *p != ']'; last = *p)94 for (last = 0400, matched = false; *++p && *p != ']'; last = *p) 95 95 /* This next line requires a good C compiler. */ 96 96 if (*p == '-' ? *text <= *++p && *text >= last : *text == *p) 97 matched = TRUE;97 matched = true; 98 98 if (matched == reverse) 99 return FALSE;99 return false; 100 100 continue; 101 101 } … … 104 104 #ifdef MATCH_TAR_PATTERN 105 105 if (*text == '/') 106 return TRUE;106 return true; 107 107 #endif /* MATCH_TAR_ATTERN */ 108 108 return *text == '\0'; … … 110 110 111 111 112 /* 113 ** User-level routine. Returns TRUE or FALSE. 114 */ 115 int 112 /* User-level routine. returns whether or not 'text' and 'p' matched */ 113 bool 116 114 tr_wildmat(const char * text, const char * p ) 117 115 { 118 116 if (p[0] == '*' && p[1] == '\0') 119 return TRUE;117 return true; 120 118 121 return DoMatch(text, p) == TRUE;119 return DoMatch(text, p) == true; 122 120 }
Note: See TracChangeset
for help on using the changeset viewer.