diff --git a/include/config.h b/include/config.h index 47c56a8bc..212e53e54 100644 --- a/include/config.h +++ b/include/config.h @@ -277,6 +277,9 @@ * uncommented to define NODUMPENUMS. Doing so will disable the * nethack --dumpenums * command line option. + * Note: the extra memory is also used by when ENHANCED_SYMBOLS is + * defined, so defining both ENHANCED_SYMBOLS and NODUMPENUMS will limit + * the amount of memory and code reduction offered by the latter. */ /* #define NODUMPENUMS */ diff --git a/include/decl.h b/include/decl.h index 993e63ac7..7552ea514 100644 --- a/include/decl.h +++ b/include/decl.h @@ -437,15 +437,16 @@ struct breadcrumbs { E const char *ARGV0; #endif -enum earlyarg {ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS +enum earlyarg { + ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS #ifndef NODUMPENUMS , ARG_DUMPENUMS +#endif #ifdef ENHANCED_SYMBOLS , ARG_DUMPGLYPHIDS #endif -#endif /* NODUMPENUMS */ #ifdef WIN32 - ,ARG_WINDOWS + , ARG_WINDOWS #endif }; diff --git a/include/extern.h b/include/extern.h index 8e5482348..958f9ac2d 100644 --- a/include/extern.h +++ b/include/extern.h @@ -28,9 +28,6 @@ extern void welcome(boolean); extern int argcheck(int, char **, enum earlyarg); extern long timet_to_seconds(time_t); extern long timet_delta(time_t, time_t); -#ifndef NODUMPENUMS -extern void dump_enums(void); -#endif /* ### apply.c ### */ diff --git a/src/allmain.c b/src/allmain.c index 1bef0d7c6..209efa882 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -21,6 +21,9 @@ static void regen_pw(int); static void regen_hp(int); static void interrupt_multi(const char *); static void debug_fields(const char *); +#ifndef NODUMPENUMS +static void dump_enums(void); +#endif void early_init(void) @@ -838,17 +841,17 @@ interrupt_multi(const char *msg) */ static const struct early_opt earlyopts[] = { - {ARG_DEBUG, "debug", 5, TRUE}, - {ARG_VERSION, "version", 4, TRUE}, - {ARG_SHOWPATHS, "showpaths", 9, FALSE}, + { ARG_DEBUG, "debug", 5, TRUE }, + { ARG_VERSION, "version", 4, TRUE }, + { ARG_SHOWPATHS, "showpaths", 9, FALSE }, #ifndef NODUMPENUMS - {ARG_DUMPENUMS, "dumpenums", 9, FALSE}, -#ifdef ENHANCED_SYMBOLS - {ARG_DUMPGLYPHIDS, "dumpglyphids", 12, FALSE}, + { ARG_DUMPENUMS, "dumpenums", 9, FALSE }, +#endif +#ifdef ENHANCED_SYMBOLS + { ARG_DUMPGLYPHIDS, "dumpglyphids", 12, FALSE }, #endif -#endif /* NODUMPENUMS */ #ifdef WIN32 - {ARG_WINDOWS, "windows", 4, TRUE}, + { ARG_WINDOWS, "windows", 4, TRUE }, #endif }; @@ -922,28 +925,25 @@ argcheck(int argc, char *argv[], enum earlyarg e_arg) early_version_info(insert_into_pastebuf); return 2; } - case ARG_SHOWPATHS: { + case ARG_SHOWPATHS: return 2; - } #ifndef NODUMPENUMS - case ARG_DUMPENUMS: { + case ARG_DUMPENUMS: dump_enums(); return 2; - } +#endif #ifdef ENHANCED_SYMBOLS - case ARG_DUMPGLYPHIDS: { + case ARG_DUMPGLYPHIDS: dump_glyphids(); return 2; - } #endif -#endif /* NODUMPENUMS */ #ifdef WIN32 - case ARG_WINDOWS: { + case ARG_WINDOWS: if (extended_opt) { extended_opt++; return windows_early_options(extended_opt); } - } + /*FALLTHRU*/ #endif default: break; @@ -1028,55 +1028,61 @@ timet_delta(time_t etim, time_t stim) /* end and start times */ return (long) difftime(etim, stim); } -#ifndef NODUMPENUMS +#if !defined(NODUMPENUMS) || defined(ENHANCED_SYMBOLS) +/* monsdump[] and objdump[] are also used in utf8map.c */ #define DUMP_ENUMS struct enum_dump monsdump[] = { #include "monsters.h" - { NUMMONS, "NUMMONS" }, + { NUMMONS, "NUMMONS" }, }; struct enum_dump objdump[] = { #include "objects.h" - { NUM_OBJECTS, "NUM_OBJECTS" }, + { NUM_OBJECTS, "NUM_OBJECTS" }, }; #undef DUMP_ENUMS -void +#ifndef NODUMPENUMS +static void dump_enums(void) { - int i, j; enum enum_dumps { monsters_enum, objects_enum, objects_misc_enum, NUM_ENUM_DUMPS }; - static const char *const titles[NUM_ENUM_DUMPS] = - { "monnums", "objects_nums" , "misc_object_nums" }; - - static struct enum_dump omdump[] = { - { LAST_GEM, "LAST_GEM" }, - { NUM_GLASS_GEMS, "NUM_GLASS_GEMS" }, - { MAXSPELL, "MAXSPELL" }, + static const char *const titles[NUM_ENUM_DUMPS] = { + "monnums", "objects_nums" , "misc_object_nums" + }; + static const struct enum_dump omdump[] = { + { LAST_GEM, "LAST_GEM" }, + { NUM_GLASS_GEMS, "NUM_GLASS_GEMS" }, + { MAXSPELL, "MAXSPELL" }, + }; + static const struct enum_dump *const ed[NUM_ENUM_DUMPS] = { + monsdump, objdump, omdump }; - struct enum_dump *ed[NUM_ENUM_DUMPS] = { monsdump, objdump, omdump }; static const char *const pfx[NUM_ENUM_DUMPS] = { "PM_", "", "" }; - int szd[NUM_ENUM_DUMPS] = { SIZE(monsdump), SIZE(objdump), SIZE(omdump) }; + static int szd[NUM_ENUM_DUMPS] = { + SIZE(monsdump), SIZE(objdump), SIZE(omdump) + }; + int i, j; for (i = 0; i < NUM_ENUM_DUMPS; ++ i) { raw_printf("enum %s = {", titles[i]); for (j = 0; j < szd[i]; ++j) { raw_printf(" %s%s = %i%s", (j == szd[i] - 1) ? "" : pfx[i], - ed[i]->nm, - ed[i]->val, + ed[i][j].nm, + ed[i][j].val, (j == szd[i] - 1) ? "" : ","); - ed[i]++; } raw_print("};"); raw_print(""); } raw_print(""); } +#endif /* NODUMPENUMS */ #ifdef ENHANCED_SYMBOLS void @@ -1085,6 +1091,6 @@ dump_glyphids(void) dump_all_glyphids(stdout); } #endif /* ENHANCED_SYMBOLS */ -#endif /* NODUMPENUMS */ +#endif /* !NODUMPENUMS || ENHANCED_SYMBOLS */ /*allmain.c*/ diff --git a/src/utf8map.c b/src/utf8map.c index 4a7312786..fbffe18b7 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -15,7 +15,7 @@ extern const char *known_handling[]; /* symbols.c */ #ifdef ENHANCED_SYMBOLS #define Fprintf (void) fprintf -enum reserved_activities {res_nothing, res_dump_glyphids, res_fill_cache}; +enum reserved_activities { res_nothing, res_dump_glyphids, res_fill_cache }; enum things_to_find { find_nothing, find_pm, find_oc, find_cmap, find_glyph }; struct find_struct { enum things_to_find findtype; @@ -36,7 +36,8 @@ struct glyphid_cache_t { }; struct glyphid_cache_t *glyphid_cache; struct find_struct glyphcache_find, to_custom_symbol_find; -static void to_custom_symset_entry_callback(int glyph, struct find_struct *findwhat); +static void to_custom_symset_entry_callback(int glyph, + struct find_struct *findwhat); static int unicode_val(const char *cp); static int parse_id(const char *id, struct find_struct *findwhat); static int glyph_find_core(const char *id, struct find_struct *findwhat); @@ -475,9 +476,13 @@ glyphrep(const char *op) } int -add_custom_urep_entry(const char *customization_name, int glyphidx, - uint32 utf32ch, const uint8 *utf8str, long ucolor, - enum graphics_sets which_set) +add_custom_urep_entry( + const char *customization_name, + int glyphidx, + uint32 utf32ch, + const uint8 *utf8str, + long ucolor, + enum graphics_sets which_set) { static uint32_t closecolor = 0; static int clridx = 0; @@ -492,8 +497,8 @@ add_custom_urep_entry(const char *customization_name, int glyphidx, gdc->custtype = custom_ureps; gdc->details = 0; } - details = find_matching_symset_customization(customization_name, custom_symbols, - which_set); + details = find_matching_symset_customization(customization_name, + custom_symbols, which_set); if (details) { while (details) { if (details->content.urep.glyphidx == glyphidx) { @@ -1100,8 +1105,10 @@ glyphs_to_unicode(const char *id, const char *unicode_val, long clr) #if 0 struct customization_detail * -find_display_urep_customization(const char *customization_name, int glyphidx, - enum graphics_sets which_set) +find_display_urep_customization( + const char *customization_name, + int glyphidx, + enum graphics_sets which_set) { struct symset_customization *gdc = &g.sym_customizations[which_set]; struct customization_detail *urepdetails;