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

Function parse_sym_line

src/symbols.c:437–654  ·  view source on GitHub ↗

returns 0 on error */

Source from the content-addressed store, hash-verified

435
436/* returns 0 on error */
437int
438parse_sym_line(char *buf, int which_set)
439{
440 int val, i;
441 const struct symparse *symp = (struct symparse *) 0;
442 char *bufp, *commentp, *altp;
443 int glyph = NO_GLYPH;
444 boolean enhanced_unavailable = FALSE, is_glyph = FALSE;
445
446 if (strlen(buf) >= BUFSZ)
447 buf[BUFSZ - 1] = '\0';
448 /* convert each instance of whitespace (tabs, consecutive spaces)
449 into a single space; leading and trailing spaces are stripped */
450 mungspaces(buf);
451
452 /* remove trailing comment, if any (this isn't strictly needed for
453 individual symbols, and it won't matter if "X#comment" without
454 separating space slips through; for handling or set description,
455 symbol set creator is responsible for preceding '#' with a space
456 and that comment itself doesn't contain " #") */
457 if ((commentp = strrchr(buf, '#')) != 0 && commentp[-1] == ' ')
458 commentp[-1] = '\0';
459
460 /* find the '=' or ':' */
461 bufp = strchr(buf, '=');
462 altp = strchr(buf, ':');
463
464 if (!bufp || (altp && altp < bufp))
465 bufp = altp;
466
467 if (!bufp) {
468 if (strncmpi(buf, "finish", 6) == 0) {
469 /* end current graphics set */
470 if (gc.chosen_symset_start)
471 gc.chosen_symset_end = TRUE;
472 gc.chosen_symset_start = FALSE;
473 return 1;
474 }
475 config_error_add("No \"finish\"");
476 return 0;
477 }
478 /* skip '=' and space which follows, if any */
479 ++bufp;
480 if (*bufp == ' ')
481 ++bufp;
482
483 symp = match_sym(buf);
484 if (!symp && buf[0] == 'G' && buf[1] == '_') {
485 if (gc.chosen_symset_start) {
486 is_glyph = match_glyph(buf);
487 } else {
488 is_glyph = TRUE; /* report error only once */
489 }
490#ifdef ENHANCED_SYMBOLS
491 enhanced_unavailable = FALSE;
492#else
493 enhanced_unavailable = TRUE;
494#endif

Callers 1

proc_symset_lineFunction · 0.85

Calls 15

mungspacesFunction · 0.85
strrchrFunction · 0.85
config_error_addFunction · 0.85
match_symFunction · 0.85
match_glyphFunction · 0.85
dupstrFunction · 0.85
init_rogue_symbolsFunction · 0.85
init_primary_symbolsFunction · 0.85
set_symhandlingFunction · 0.85
sym_valFunction · 0.85
update_primary_symsetFunction · 0.85
update_rogue_symsetFunction · 0.85

Tested by

no test coverage detected