e7beceff74479fee551cdb440e9165bad40f9138 angie Tue Mar 1 10:16:43 2011 -0800 Build a more accurate description in regexMatchSubstrMaybeCase. diff --git src/lib/regexHelper.c src/lib/regexHelper.c index 9b42886..9c9e340 100644 --- src/lib/regexHelper.c +++ src/lib/regexHelper.c @@ -30,35 +30,43 @@ errAbort("%s \"%s\" got regular expression compilation error %d:\n%s\n", description, exp, errNum, errBuf); } hashAdd(reHash, key, compiledExp); return(compiledExp); } } static boolean regexMatchSubstrMaybeCase(const char *string, const char *exp, regmatch_t substrArr[], size_t substrArrSize, boolean isCaseInsensitive) /* Return TRUE if string matches regular expression exp; * regexec fills in substrArr with substring offsets. */ { int compileFlags = REG_EXTENDED; +char desc[256]; +safecpy(desc, sizeof(desc), "Regular expression"); if (isCaseInsensitive) + { compileFlags |= REG_ICASE; + safecat(desc, sizeof(desc), " (case insensitive)"); + } if (substrArr == NULL) compileFlags |= REG_NOSUB; -const regex_t *compiledExp = regexCompile(exp, "Regular expression w/substrings", compileFlags); +else + safecat(desc, sizeof(desc), " with substrings"); + +const regex_t *compiledExp = regexCompile(exp, desc, compileFlags); return(regexec(compiledExp, string, substrArrSize, substrArr, 0) == 0); } boolean regexMatch(const char *string, const char *exp) /* Return TRUE if string matches regular expression exp (case sensitive). */ { return regexMatchSubstrMaybeCase(string, exp, NULL, 0, FALSE); } boolean regexMatchNoCase(const char *string, const char *exp) /* Return TRUE if string matches regular expression exp (case insensitive). */ { return regexMatchSubstrMaybeCase(string, exp, NULL, 0, TRUE); }