From 02da5f2d38c3166d5c3c7d87dc876ddf358d80f6 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 11 Nov 2019 14:19:16 -0500 Subject: [PATCH] more Windows path environ variable translation bits --- src/files.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/files.c b/src/files.c index 38a692113..454a80bc7 100644 --- a/src/files.c +++ b/src/files.c @@ -354,10 +354,13 @@ const char *basenam; int whichprefix UNUSED_if_not_PREFIXES_IN_USE; int buffnum UNUSED_if_not_PREFIXES_IN_USE; { +#ifdef PREFIXES_IN_USE + char *bufptr; +#endif #ifdef WIN32 char tmpbuf[BUFSZ]; - #endif + #ifndef PREFIXES_IN_USE return basenam; #else @@ -369,20 +372,17 @@ int buffnum UNUSED_if_not_PREFIXES_IN_USE; impossible("Invalid fqn_filename_buffer specified: %d", buffnum); buffnum = 0; } - if (strlen(fqn_prefix[whichprefix]) + strlen(basenam) - >= FQN_MAX_FILENAME) { - impossible("fqname too long: %s + %s", fqn_prefix[whichprefix], - basenam); + bufptr = fqn_prefix[whichprefix]; +#ifdef WIN32 + if (strchr(fqn_prefix[whichprefix], '%') + || strchr(fqn_prefix[whichprefix], '~')) + bufptr = translate_path_variables(fqn_prefix[whichprefix], tmpbuf); +#endif + if (strlen(bufptr) + strlen(basenam) >= FQN_MAX_FILENAME) { + impossible("fqname too long: %s + %s", bufptr, basenam); return basenam; /* XXX */ } -#ifdef WIN32 - if (strchr(fqn_prefix[whichprefix], '%') || - strchr(fqn_prefix[whichprefix], '~')) - Strcpy(fqn_filename_buffer[buffnum], - translate_path_variables(fqn_prefix[whichprefix], tmpbuf)); - else -#endif - Strcpy(fqn_filename_buffer[buffnum], fqn_prefix[whichprefix]); + Strcpy(fqn_filename_buffer[buffnum], bufptr); return strcat(fqn_filename_buffer[buffnum], basenam); #endif /* !PREFIXES_IN_USE */ }