MCPcopy Create free account
hub / github.com/NetHack/NetHack / config_erradd

Function config_erradd

src/cfgfiles.c:1543–1589  ·  view source on GitHub ↗

varargs 'config_error_add()' moved to pline.c */

Source from the content-addressed store, hash-verified

1541
1542/* varargs 'config_error_add()' moved to pline.c */
1543void
1544config_erradd(const char *buf)
1545{
1546 char lineno[QBUFSZ];
1547 const char *punct;
1548
1549 if (!buf || !*buf)
1550 buf = "Unknown error";
1551
1552 /* if buf[] doesn't end in a period, exclamation point, or question mark,
1553 we'll include a period (in the message, not appended to buf[]) */
1554 punct = c_eos((char *) buf) - 1; /* eos(buf)-1 is valid */
1555 punct = strchr(".!?", *punct) ? "" : ".";
1556
1557 if (!program_state.config_error_ready) {
1558 /* either very early, where pline() will use raw_print(), or
1559 player gave bad value when prompted by interactive 'O' command */
1560 pline("%s%s%s", !iflags.window_inited ? "config_error_add: " : "",
1561 buf, punct);
1562 wait_synch();
1563 return;
1564 }
1565
1566 if (iflags.in_lua) {
1567 struct _config_error_errmsg *dat
1568 = (struct _config_error_errmsg *) alloc(sizeof *dat);
1569
1570 dat->next = config_error_msg;
1571 dat->line_num = config_error_data->line_num;
1572 dat->errormsg = dupstr(buf);
1573 config_error_msg = dat;
1574 return;
1575 }
1576
1577 config_error_data->num_errors++;
1578 if (!config_error_data->origline_shown && !config_error_data->secure) {
1579 pline("\n%s", config_error_data->origline);
1580 config_error_data->origline_shown = TRUE;
1581 }
1582 if (config_error_data->line_num > 0 && !config_error_data->secure) {
1583 Sprintf(lineno, "Line %d: ", config_error_data->line_num);
1584 } else
1585 lineno[0] = '\0';
1586
1587 pline("%s %s%s%s", config_error_data->secure ? "Error:" : " *",
1588 lineno, buf, punct);
1589}
1590
1591int
1592config_error_done(void)

Callers 1

vconfig_error_addFunction · 0.85

Calls 5

c_eosFunction · 0.85
wait_synchFunction · 0.85
dupstrFunction · 0.85
plineFunction · 0.70
allocFunction · 0.70

Tested by

no test coverage detected