Mercurial > hg > th-libs
diff th_strmatch.c @ 453:efd33accdc81
Break backwards compatibility by renaming BOOL, TRUE and FALSE to lowercase.
Introduce optional but default use of stdbool.h.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Jan 2018 22:56:03 +0200 |
parents | 1b3472ba7b23 |
children | 347bfd3e017e |
line wrap: on
line diff
--- a/th_strmatch.c Wed Oct 25 22:32:07 2017 +0300 +++ b/th_strmatch.c Tue Jan 02 22:56:03 2018 +0200 @@ -6,14 +6,14 @@ * Please read file 'COPYING' for information on license and distribution. */ -BOOL TH_STRMATCH_FUNC (const char *haystack, const char *pattern) +bool TH_STRMATCH_FUNC (const char *haystack, const char *pattern) { - BOOL matched = TRUE, any = FALSE, end = FALSE; + bool matched = true, any = false, end = false; const char *tmp = NULL; // Check given pattern and string if (haystack == NULL || pattern == NULL) - return FALSE; + return false; // Start comparision while (matched && !end) @@ -27,14 +27,14 @@ haystack++; } else - matched = FALSE; + matched = false; break; case '*': pattern++; if (!*pattern || *pattern == '?') - end = TRUE; - any = TRUE; + end = true; + any = true; tmp = pattern; break; @@ -44,21 +44,21 @@ if (*haystack) haystack++; else - end = TRUE; + end = true; } else if (*haystack) { if (tmp) { - any = TRUE; + any = true; pattern = tmp; } else - matched = FALSE; + matched = false; } else - end = TRUE; + end = true; break; default: @@ -66,13 +66,13 @@ { if (TH_STRMATCH_COLLATE(*pattern) == TH_STRMATCH_COLLATE(*haystack)) { - any = FALSE; + any = false; } else if (*haystack) haystack++; else - matched = FALSE; + matched = false; } else { @@ -86,15 +86,15 @@ else if (tmp) { - any = TRUE; + any = true; pattern = tmp; } else - matched = FALSE; + matched = false; } if (!*haystack && !*pattern) - end = TRUE; + end = true; break; }