From: nhmall Date: Sun, 3 Jan 2021 03:28:54 +0000 (-0500) Subject: Windows SELECTSAVED follow-up X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e93eeb25fd876506b656a5654ca9c26d9400bb01;p=nethack Windows SELECTSAVED follow-up set_savefile_name() was misbehaving on Windows if the regularize argument was false. --- diff --git a/src/files.c b/src/files.c index f995f8d1a..2379607d1 100644 --- a/src/files.c +++ b/src/files.c @@ -124,8 +124,10 @@ extern char *sounddir; /* defined in sounds.c */ #endif #if defined(UNIX) && defined(QT_GRAPHICS) +#ifndef SELECTSAVED #define SELECTSAVED #endif +#endif static NHFILE *NDECL(new_nhfile); static void FDECL(free_nhfile, (NHFILE *)); @@ -895,6 +897,9 @@ boolean regularize_it; indicator_spot = 0; /* 0=no indicator, 1=before ext, 2=after ext */ const char *postappend = (const char *) 0, *sfindicator = (const char *) 0; +#if defined(WIN32) + char tmp[BUFSZ]; +#endif if (g.program_state.in_self_recover) { /* self_recover needs to be done as historical @@ -917,17 +922,18 @@ boolean regularize_it; static const char okchars[] = "*ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-."; const char *legal = okchars; - char tmp[BUFSZ]; ++legal; /* skip '*' wildcard character */ (void) fname_encode(legal, '%', g.plname, tmp, sizeof tmp); - if (strlen(tmp) < (SAVESIZE - 1)) - Strcpy(g.SAVEF, tmp); - else - overflow = 1; - indicator_spot = 1; - regularize_it = FALSE; + } else { + Sprintf(tmp, "%s", g.plname); } + if (strlen(tmp) < (SAVESIZE - 1)) + Strcpy(g.SAVEF, tmp); + else + overflow = 1; + indicator_spot = 1; + regularize_it = FALSE; #endif #ifdef UNIX Sprintf(g.SAVEF, "save/%d%s", (int) getuid(), g.plname);