lregex: some simple syncs

This commit is contained in:
Jiří Techet 2016-10-12 12:06:06 +02:00
parent ca1622412f
commit 380a662a25

View File

@ -199,18 +199,16 @@ static bool parseTagRegex (
*name = scanSeparators (regexp); *name = scanSeparators (regexp);
if (*regexp == '\0') if (*regexp == '\0')
printf ("regex: empty regexp\n"); error (WARNING, "empty regexp");
else if (**name != separator) else if (**name != separator)
printf ("regex: %s: incomplete regexp\n", regexp); error (WARNING, "%s: incomplete regexp", regexp);
else else
{ {
char* const third = scanSeparators (*name); char* const third = scanSeparators (*name);
if (**name == '\0') if (**name != '\0' && (*name) [strlen (*name) - 1] == '\\')
printf ("regex: %s: regexp missing name pattern\n", regexp); error (WARNING, "error in name pattern: \"%s\"", *name);
if ((*name) [strlen (*name) - 1] == '\\')
printf ("regex: error in name pattern: \"%s\"\n", *name);
if (*third != separator) if (*third != separator)
printf ("regex: %s: regexp missing final separator\n", regexp); error (WARNING, "%s: regexp missing final separator", regexp);
else else
{ {
char* const fourth = scanSeparators (third); char* const fourth = scanSeparators (third);
@ -326,8 +324,8 @@ static void parseKinds (
*description = NULL; *description = NULL;
if (kinds == NULL || kinds [0] == '\0') if (kinds == NULL || kinds [0] == '\0')
{ {
*kind = 'r'; *kind = KIND_REGEX_DEFAULT;
*kindName = eStrdup ("regex"); *kindName = eStrdup (KIND_REGEX_DEFAULT_LONG);
} }
else if (kinds [0] != '\0') else if (kinds [0] != '\0')
{ {
@ -335,11 +333,11 @@ static void parseKinds (
if (k [0] != ',' && (k [1] == ',' || k [1] == '\0')) if (k [0] != ',' && (k [1] == ',' || k [1] == '\0'))
*kind = *k++; *kind = *k++;
else else
*kind = 'r'; *kind = KIND_REGEX_DEFAULT;
if (*k == ',') if (*k == ',')
++k; ++k;
if (k [0] == '\0') if (k [0] == '\0')
*kindName = eStrdup ("regex"); *kindName = eStrdup (KIND_REGEX_DEFAULT_LONG);
else else
{ {
const char *const comma = strchr (k, ','); const char *const comma = strchr (k, ',');
@ -377,13 +375,13 @@ static void processLanguageRegex (const langType language,
else if (parameter [0] != '@') else if (parameter [0] != '@')
addLanguageRegex (language, parameter); addLanguageRegex (language, parameter);
else if (! doesFileExist (parameter + 1)) else if (! doesFileExist (parameter + 1))
printf ("regex: cannot open regex file\n"); error (WARNING, "cannot open regex file");
else else
{ {
const char* regexfile = parameter + 1; const char* regexfile = parameter + 1;
MIO* const mio = mio_new_file (regexfile, "r"); MIO* const mio = mio_new_file (regexfile, "r");
if (mio == NULL) if (mio == NULL)
printf ("regex: %s\n", regexfile); error (WARNING | PERROR, "%s", regexfile);
else else
{ {
vString* const regex = vStringNew (); vString* const regex = vStringNew ();
@ -541,8 +539,7 @@ extern void addTagRegex (
} }
} }
extern void addCallbackRegex ( extern void addCallbackRegex (const langType language CTAGS_ATTR_UNUSED,
const langType language CTAGS_ATTR_UNUSED,
const char* const regex CTAGS_ATTR_UNUSED, const char* const regex CTAGS_ATTR_UNUSED,
const char* const flags CTAGS_ATTR_UNUSED, const char* const flags CTAGS_ATTR_UNUSED,
const regexCallback callback CTAGS_ATTR_UNUSED) const regexCallback callback CTAGS_ATTR_UNUSED)
@ -648,9 +645,23 @@ extern void freeRegexResources (void)
SetUpper = -1; SetUpper = -1;
} }
/* Check for broken regcomp() on Cygwin */ /* Return true if available. */
extern bool checkRegex (void) extern bool checkRegex (void)
{ {
/* not needed now we have GRegex */ /* not needed with GRegex */
return true; #if 0 /*defined (CHECK_REGCOMP)*/
{
/* Check for broken regcomp() on Cygwin */
regex_t patbuf;
int errcode;
if (regcomp (&patbuf, "/hello/", 0) != 0)
error (WARNING, "Disabling broken regex");
else
regexAvailable = true;
}
#else
/* We are using bundled regex engine. */
regexAvailable = true;
#endif
return regexAvailable;
} }