config_error_add()'s terminating period

Have the config error reporting routine check whether the message
it's delivering already has end-of-sentence punctuation instead of
adding that unconditionally.
This commit is contained in:
PatR
2022-07-05 23:20:58 -07:00
parent c3832a6afa
commit ab32ec4ad6
2 changed files with 10 additions and 12 deletions

View File

@@ -51,18 +51,10 @@ regex_error_desc(struct nhregex *re, char *errbuf)
} else if (!re->err) {
Strcpy(errbuf, "no explanation");
} else {
char *p;
errbuf[0] = '\0';
(void) strncat(errbuf, re->err->what(), BUFSZ - 1);
if (!errbuf[0])
Strcpy(errbuf, "unspecified regexp error");
/* caller will pass our result to config_error_add() and it adds
sentence ending period, so if the regex class error explanation
already ends in a period, strip that off */
if ((p = strrchr(errbuf, '.')) != 0 && !p[1])
*p = '\0';
}
return errbuf;
}