summaryrefslogtreecommitdiffstats
path: root/src/portable.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2018-07-17 17:36:48 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2018-07-17 17:36:48 (GMT)
commitbd6c93b2d26a9a80df66a25404613e285ef35815 (patch)
treef42aaba921fadc8f63651ebe1b07c0e5265800b8 /src/portable.cpp
parenta05532d8532f5f71e1ae7ff4d383102ee91cd17c (diff)
downloadDoxygen-bd6c93b2d26a9a80df66a25404613e285ef35815.zip
Doxygen-bd6c93b2d26a9a80df66a25404613e285ef35815.tar.gz
Doxygen-bd6c93b2d26a9a80df66a25404613e285ef35815.tar.bz2
Added substitution variant for character substitution
Diffstat (limited to 'src/portable.cpp')
-rw-r--r--src/portable.cpp32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/portable.cpp b/src/portable.cpp
index 224266a..b4417c2 100644
--- a/src/portable.cpp
+++ b/src/portable.cpp
@@ -36,17 +36,8 @@ int portable_system(const char *command,const char *args,bool commandHasConsole)
if (command==0) return 1;
#if defined(_WIN32) && !defined(__CYGWIN__)
- const char *p = command;
- char *q = (char *)malloc(strlen(p) + 1);
- strcpy(q, p);
- for (int i = 0 ; i < strlen(q); i++)
- {
- if (q[i] == '/')
- {
- q[i] = '\\';
- }
- }
- QCString fullCmd=q;
+ QCString commandCorrectedPath = substitute(command,'/','\\');
+ QCString fullCmd=commandCorrectedPath;
#else
QCString fullCmd=command;
#endif
@@ -136,7 +127,6 @@ int portable_system(const char *command,const char *args,bool commandHasConsole)
#else // Win32 specific
if (commandHasConsole)
{
- free(q);
return system(fullCmd);
}
else
@@ -149,7 +139,7 @@ int portable_system(const char *command,const char *args,bool commandHasConsole)
// For that case COM is initialized as follows
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
- QString commandw = QString::fromUtf8( q );
+ QString commandw = QString::fromUtf8( commandCorrectedPath );
QString argsw = QString::fromUtf8( args );
// gswin32 is a GUI api which will pop up a window and run
@@ -176,7 +166,6 @@ int portable_system(const char *command,const char *args,bool commandHasConsole)
NULL, /* ignored: icon */
NULL /* resulting application handle */
};
- free(q);
if (!ShellExecuteExW(&sInfo))
{
@@ -474,18 +463,7 @@ void portable_correct_path(void)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
const char *p = portable_getenv("PATH");
- char *q = (char *)malloc(strlen(p) + 1);
- strcpy(q, p);
- bool found = false;
- for (int i = 0 ; i < strlen(q); i++)
- {
- if (q[i] == '/')
- {
- q[i] = '\\';
- found = true;
- }
- }
- if (found) portable_setenv("PATH",q);
- free(q);
+ QCString result = substitute(p,'/','\\');
+ if (result!=p) portable_setenv("PATH",result.data());
#endif
}