diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-03-07 20:52:43 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-04-21 15:45:39 +0200 |
commit | 0f67af9d785254e394dd773fc9f34da2557a1983 (patch) | |
tree | 2fb5a3299ae5622b9a368ea7aa556ad04cda4fac | |
parent | 522e743f64ba29be98fe3f44596d7a7ed57f6aca (diff) | |
download | nx-libs-0f67af9d785254e394dd773fc9f34da2557a1983.tar.gz nx-libs-0f67af9d785254e394dd773fc9f34da2557a1983.tar.bz2 nx-libs-0f67af9d785254e394dd773fc9f34da2557a1983.zip |
nxcomp/Children.cpp: Don't generate warnings with duplicated NX paths.
Fixes ArcticaProject/nx-libs#370.
-rw-r--r-- | nxcomp/Children.cpp | 131 |
1 files changed, 70 insertions, 61 deletions
diff --git a/nxcomp/Children.cpp b/nxcomp/Children.cpp index 224a86f6d..265ba4e37 100644 --- a/nxcomp/Children.cpp +++ b/nxcomp/Children.cpp @@ -260,58 +260,63 @@ int NXTransDialog(const char *caption, const char *message, // in the default NX path. // - strcpy(command, "nxclient"); + if (i == 0) + { - char newPath[DEFAULT_STRING_LIMIT]; + strcpy(command, "nxclient"); - strcpy(newPath, "/usr/NX/bin:/opt/NX/bin:/usr/local/NX/bin:"); + char newPath[DEFAULT_STRING_LIMIT]; - #ifdef __APPLE__ + strcpy(newPath, "/usr/NX/bin:/opt/NX/bin:/usr/local/NX/bin:"); - strcat(newPath, "/Applications/NX Client for OSX.app/Contents/MacOS:"); + #ifdef __APPLE__ - #endif + strcat(newPath, "/Applications/NX Client for OSX.app/Contents/MacOS:"); - #ifdef __CYGWIN32__ + #endif - strcat(newPath, ".:"); + #ifdef __CYGWIN32__ - #endif + strcat(newPath, ".:"); - int newLength = strlen(newPath); + #endif - char *oldPath = getenv("PATH"); + int newLength = strlen(newPath); - strncpy(newPath + newLength, oldPath, DEFAULT_STRING_LIMIT - newLength - 1); + char *oldPath = getenv("PATH"); - newPath[DEFAULT_STRING_LIMIT - 1] = '\0'; + strncpy(newPath + newLength, oldPath, DEFAULT_STRING_LIMIT - newLength - 1); - #ifdef WARNING - *logofs << "NXTransDialog: WARNING! Trying with path '" - << newPath << "'.\n" << logofs_flush; - #endif + newPath[DEFAULT_STRING_LIMIT - 1] = '\0'; - cerr << "Warning" << ": Trying with path '" << newPath - << "'.\n"; + #ifdef WARNING + *logofs << "NXTransDialog: WARNING! Trying with path '" + << newPath << "'.\n" << logofs_flush; + #endif - // - // Solaris doesn't seem to have - // function setenv(). - // + cerr << "Warning" << ": Trying with path '" << newPath + << "'.\n"; - #ifdef __sun + // + // Solaris doesn't seem to have + // function setenv(). + // - char newEnv[DEFAULT_STRING_LIMIT + 5]; + #ifdef __sun - sprintf(newEnv,"PATH=%s", newPath); + char newEnv[DEFAULT_STRING_LIMIT + 5]; - putenv(newEnv); + sprintf(newEnv,"PATH=%s", newPath); - #else + putenv(newEnv); - setenv("PATH", newPath, 1); + #else - #endif + setenv("PATH", newPath, 1); + + #endif + + } } // @@ -455,60 +460,64 @@ int NXTransClient(const char* display) // in the default NX path. // - strcpy(command, "nxclient"); + if (i == 0) + { - char newPath[DEFAULT_STRING_LIMIT]; + strcpy(command, "nxclient"); - strcpy(newPath, "/usr/NX/bin:/opt/NX/bin:/usr/local/NX/bin:"); + char newPath[DEFAULT_STRING_LIMIT]; - #ifdef __APPLE__ + strcpy(newPath, "/usr/NX/bin:/opt/NX/bin:/usr/local/NX/bin:"); - strcat(newPath, "/Applications/NX Client for OSX.app/Contents/MacOS:"); + #ifdef __APPLE__ - #endif + strcat(newPath, "/Applications/NX Client for OSX.app/Contents/MacOS:"); - #ifdef __CYGWIN32__ + #endif - strcat(newPath, ".:"); + #ifdef __CYGWIN32__ - #endif + strcat(newPath, ".:"); - int newLength = strlen(newPath); + #endif - char *oldPath = getenv("PATH"); + int newLength = strlen(newPath); - strncpy(newPath + newLength, oldPath, DEFAULT_STRING_LIMIT - newLength - 1); + char *oldPath = getenv("PATH"); - newPath[DEFAULT_STRING_LIMIT - 1] = '\0'; + strncpy(newPath + newLength, oldPath, DEFAULT_STRING_LIMIT - newLength - 1); - #ifdef WARNING - *logofs << "NXTransClient: WARNING! Trying with path '" - << newPath << "'.\n" << logofs_flush; - #endif + newPath[DEFAULT_STRING_LIMIT - 1] = '\0'; - cerr << "Warning" << ": Trying with path '" << newPath - << "'.\n"; + #ifdef WARNING + *logofs << "NXTransClient: WARNING! Trying with path '" + << newPath << "'.\n" << logofs_flush; + #endif - // - // Solaris doesn't seem to have - // function setenv(). - // + cerr << "Warning" << ": Trying with path '" << newPath + << "'.\n"; - #ifdef __sun + // + // Solaris doesn't seem to have + // function setenv(). + // - char newEnv[DEFAULT_STRING_LIMIT + 5]; + #ifdef __sun - sprintf(newEnv,"PATH=%s", newPath); + char newEnv[DEFAULT_STRING_LIMIT + 5]; - putenv(newEnv); + sprintf(newEnv,"PATH=%s", newPath); - #else + putenv(newEnv); - setenv("PATH", newPath, 1); + #else - #endif - } + setenv("PATH", newPath, 1); + #endif + } + + } // // Hopefully useless. // |