From 6f10c9f818786b424303778aff484c9ebe4cc859 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 30 Oct 2016 08:56:28 +0100 Subject: [PATCH] cpitf.c; allow spaces in paths like "Program Files" as search path for spinit if in MS Windows --- src/frontend/cpitf.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/frontend/cpitf.c b/src/frontend/cpitf.c index 4041acbc7..f145d1b44 100644 --- a/src/frontend/cpitf.c +++ b/src/frontend/cpitf.c @@ -242,10 +242,8 @@ ft_cpinit(void) wl_free(wl); } - /* Now source the standard startup file spinit or tclspinit. */ - - /* set variables to read program configuration into spinit for VS */ #ifdef _MSC_VER + /* set variables to read program configuration into spinit for VS */ #ifdef CONFIG64 #ifdef NGDEBUG cp_vset("pg_config", CP_STRING, "d64"); @@ -261,15 +259,31 @@ ft_cpinit(void) #endif #endif - /* jump over leading spaces */ + /* Now source the standard startup file spinit or tclspinit. */ for (copys = s = cp_tildexpand(Lib_Path); copys && *copys; ) { + /* jump over leading spaces */ s = skip_ws(s); #ifdef OUTDEBUG printf("cpitf.c, spinit path is %s\n", s); #endif +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(HAS_WINGUI) + /* MS Windows allows path names with spaces, e.g. "Program Files". + The old code below does not do then. + So just copy the whole string s into buf */ + size_t sl = strlen(s); + if (sl >= BSIZE_SP) { + fprintf(cp_err, "Note: Cannot evaluate spinit, path is too long!\n"); + tcap_init(); + return; + } + size_t ii = 0; + for (r = buf; *s && ii < sl; r++, s++, ii++) + *r = *s; +#else /* copy s into buf until space is seen, r is the actual position */ for (r = buf; *s && !isspace_c(*s); r++, s++) *r = *s; +#endif tfree(copys); /* add a path separator to buf at actual position */ (void) strcpy(r, DIR_PATHSEP);