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

Function read_sym_file

src/files.c:2630–2674  ·  view source on GitHub ↗

* Returns 1 if the chosen symset was found and loaded. * 0 if it wasn't found in the sym file or other problem. */

Source from the content-addressed store, hash-verified

2628 * 0 if it wasn't found in the sym file or other problem.
2629 */
2630int
2631read_sym_file(int which_set)
2632{
2633 FILE *fp;
2634
2635 gs.symset[which_set].explicitly = FALSE;
2636 if (!(fp = fopen_sym_file()))
2637 return 0;
2638
2639 gs.symset[which_set].explicitly = TRUE;
2640 gc.chosen_symset_start = gc.chosen_symset_end = FALSE;
2641 gs.symset_which_set = which_set;
2642 gs.symset_count = 0;
2643
2644 config_error_init(TRUE, "symbols", FALSE);
2645
2646 parse_conf_file(fp, proc_symset_line);
2647 (void) fclose(fp);
2648
2649 if (!gc.chosen_symset_start && !gc.chosen_symset_end) {
2650 /* name caller put in symset[which_set].name was not found;
2651 if it looks like "Default symbols", null it out and return
2652 success to use the default; otherwise, return failure */
2653 if (gs.symset[which_set].name
2654 && (fuzzymatch(gs.symset[which_set].name, "Default symbols",
2655 " -_", TRUE)
2656 || !strcmpi(gs.symset[which_set].name, "default")))
2657 clear_symsetentry(which_set, TRUE);
2658 config_error_done();
2659
2660 /* If name was defined, it was invalid. Then we're loading fallback */
2661 if (gs.symset[which_set].name) {
2662 gs.symset[which_set].explicitly = FALSE;
2663 return 0;
2664 }
2665
2666 return 1;
2667 }
2668 if (!gc.chosen_symset_end)
2669 config_error_add("Missing finish for symset \"%s\"",
2670 gs.symset[which_set].name ? gs.symset[which_set].name
2671 : "unknown");
2672 config_error_done();
2673 return 1;
2674}
2675
2676/* ---------- END SYMSET FILE HANDLING ----------- */
2677

Callers 7

optfn_cursesgraphicsFunction · 0.85
optfn_DECgraphicsFunction · 0.85
optfn_IBMgraphicsFunction · 0.85
optfn_roguesymsetFunction · 0.85
optfn_symsetFunction · 0.85
load_symsetFunction · 0.85
do_symsetFunction · 0.85

Calls 8

fopen_sym_fileFunction · 0.85
config_error_initFunction · 0.85
parse_conf_fileFunction · 0.85
fcloseFunction · 0.85
fuzzymatchFunction · 0.85
clear_symsetentryFunction · 0.85
config_error_doneFunction · 0.85
config_error_addFunction · 0.85

Tested by

no test coverage detected