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:
+10
-4
@@ -2937,15 +2937,21 @@ void
|
|||||||
config_erradd(const char *buf)
|
config_erradd(const char *buf)
|
||||||
{
|
{
|
||||||
char lineno[QBUFSZ];
|
char lineno[QBUFSZ];
|
||||||
|
const char *punct;
|
||||||
|
|
||||||
if (!buf || !*buf)
|
if (!buf || !*buf)
|
||||||
buf = "Unknown error";
|
buf = "Unknown error";
|
||||||
|
|
||||||
|
/* if buf[] doesn't end in a period, exclamation point, or question mark,
|
||||||
|
we'll include a period (in the message, not appended to buf[]) */
|
||||||
|
punct = eos((char *) buf) - 1; /* eos(buf)-1 is valid; cast away const */
|
||||||
|
punct = index(".!?", *punct) ? "" : ".";
|
||||||
|
|
||||||
if (!g.program_state.config_error_ready) {
|
if (!g.program_state.config_error_ready) {
|
||||||
/* either very early, where pline() will use raw_print(), or
|
/* either very early, where pline() will use raw_print(), or
|
||||||
player gave bad value when prompted by interactive 'O' command */
|
player gave bad value when prompted by interactive 'O' command */
|
||||||
pline("%s%s.", !iflags.window_inited ? "config_error_add: " : "",
|
pline("%s%s%s", !iflags.window_inited ? "config_error_add: " : "",
|
||||||
buf);
|
buf, punct);
|
||||||
wait_synch();
|
wait_synch();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2971,8 +2977,8 @@ config_erradd(const char *buf)
|
|||||||
} else
|
} else
|
||||||
lineno[0] = '\0';
|
lineno[0] = '\0';
|
||||||
|
|
||||||
pline("%s %s%s.", config_error_data->secure ? "Error:" : " *",
|
pline("%s %s%s%s", config_error_data->secure ? "Error:" : " *",
|
||||||
lineno, buf);
|
lineno, buf, punct);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -51,18 +51,10 @@ regex_error_desc(struct nhregex *re, char *errbuf)
|
|||||||
} else if (!re->err) {
|
} else if (!re->err) {
|
||||||
Strcpy(errbuf, "no explanation");
|
Strcpy(errbuf, "no explanation");
|
||||||
} else {
|
} else {
|
||||||
char *p;
|
|
||||||
|
|
||||||
errbuf[0] = '\0';
|
errbuf[0] = '\0';
|
||||||
(void) strncat(errbuf, re->err->what(), BUFSZ - 1);
|
(void) strncat(errbuf, re->err->what(), BUFSZ - 1);
|
||||||
if (!errbuf[0])
|
if (!errbuf[0])
|
||||||
Strcpy(errbuf, "unspecified regexp error");
|
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;
|
return errbuf;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user