From: PatR Date: Mon, 20 Feb 2023 20:22:14 +0000 (-0800) Subject: fix #K3863 - replace 'for (int i=0;...' in core X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2ec99ecf1b57a4cc0c3eaaa86ead495ad2b7854;p=nethack fix #K3863 - replace 'for (int i=0;...' in core The Makefiles and some of the hints have already been updated to specify that C99 is required in response to #K3863. The code was evidently being compiled in the default mode of an old version of gcc and that mode complained that C99 was required to specify a declaration in the initializer clause of a 'for(initialize;test;update)statement'. Other C99 features used by nethack were apparently accepted as extensions in the default conformance mode. There's only one such declaration in the core code so replace it with a separate declaration and ordinary 'for' loop. win/Qt/{lots}.cpp and win/win32/{few}.c have these declarations but the core didn't. --- diff --git a/src/cmd.c b/src/cmd.c index 655f15794..067dfd811 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -4059,14 +4059,14 @@ RESTORE_WARNING_FORMAT_NONLITERAL static int wiz_display_macros(void) { + static const char display_issues[] = "Display macro issues:"; char buf[BUFSZ]; winid win; - int test, trouble = 0, no_glyph = NO_GLYPH, max_glyph = MAX_GLYPH; - static const char *const display_issues = "Display macro issues:"; + int glyph, test, trouble = 0, no_glyph = NO_GLYPH, max_glyph = MAX_GLYPH; win = create_nhwindow(NHW_TEXT); - for (int glyph = 0; glyph < MAX_GLYPH; ++glyph) { + for (glyph = 0; glyph < MAX_GLYPH; ++glyph) { /* glyph_is_cmap / glyph_to_cmap() */ if (glyph_is_cmap(glyph)) { test = glyph_to_cmap(glyph);