From 2396faac3923346e60b9de9a2b31df63966e5dce Mon Sep 17 00:00:00 2001 From: Cary R Date: Sat, 28 Nov 2009 13:47:41 -0800 Subject: [PATCH] Add basic support for spaces in the install path for MinGW. This patch adds support for spaces in the install path on MinGW. It does this by converting the Long version of the iverilog path into a Short version that does not have spaces in it. If we don't do this then we can not add support for other arguments with spaces in the path or filename. It also modifies the driver-vpi program to support spaces in the saved ivl path. This is done by just enclosing the include and library path argument in double quotes. The issue on MinGW is that if you put the executable argument to system in double quotes to escape embedded spaces then you can not put the arguments in double quotes as well. If you convert to a Short name then the spaces are removed and we can in the future escape the arguments as needed. (cherry picked from commit dd425e894515eab6f528a237147f61f226551f4e) --- driver-vpi/main.c | 10 +++++----- driver/main.c | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/driver-vpi/main.c b/driver-vpi/main.c index 8e6a9eff2..bfd1ec77b 100644 --- a/driver-vpi/main.c +++ b/driver-vpi/main.c @@ -410,7 +410,7 @@ static int parse(int argc, char *argv[]) static void checkMingwDir(char *root) { - int irv, len; + int irv; struct _stat stat_buf; char *path, *comp, *cp; @@ -518,16 +518,16 @@ static void setup_ivl_environment() } /* Build up the CFLAGS option string */ - assign(&gstr.pCFLAGS,IVERILOG_VPI_CFLAGS " -I"); + assign(&gstr.pCFLAGS,IVERILOG_VPI_CFLAGS " -I\""); append(&gstr.pCFLAGS,gstr.pIVL); appendBackSlash(&gstr.pCFLAGS); - append(&gstr.pCFLAGS,"\\include\\\\iverilog" IVERILOG_SUFFIX); + append(&gstr.pCFLAGS,"\\include\\\\iverilog\"" IVERILOG_SUFFIX); /* Build up the LDFLAGS option string */ - assign(&gstr.pLDLIBS,"-L"); + assign(&gstr.pLDLIBS,"-L\""); append(&gstr.pLDLIBS,gstr.pIVL); appendBackSlash(&gstr.pLDLIBS); - append(&gstr.pLDLIBS,"\\lib " IVERILOG_VPI_LDLIBS); + append(&gstr.pLDLIBS,"\\lib\" " IVERILOG_VPI_LDLIBS); } /* compile source modules */ diff --git a/driver/main.c b/driver/main.c index c673a9a23..cca64dda0 100644 --- a/driver/main.c +++ b/driver/main.c @@ -704,8 +704,8 @@ int main(int argc, char **argv) #ifdef __MINGW32__ { char * s; - char basepath[1024]; - GetModuleFileName(NULL,basepath,1024); + char basepath[1024], tmp[1024]; + GetModuleFileName(NULL, tmp, sizeof(tmp)); /* Calculate the ivl_root from the path to the command. This is necessary because of the installation process in @@ -722,7 +722,9 @@ int main(int argc, char **argv) turning the last two \ characters to null. Then we append the lib\ivl to finish. */ - strncpy(ivl_root, basepath, MAXSIZE); + /* Convert to a short name to remove any embedded spaces. */ + GetShortPathName(tmp, basepath, sizeof(basepath)); + strncpy(ivl_root, basepath, MAXSIZE); s = strrchr(ivl_root, sep); if (s) *s = 0; s = strrchr(ivl_root, sep);