commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r907260 - /commons/proper/daemon/trunk/src/native/nt/procrun/src/rprocess.c
Date Sat, 06 Feb 2010 17:27:35 GMT
Author: mturk
Date: Sat Feb  6 17:27:34 2010
New Revision: 907260

URL: http://svn.apache.org/viewvc?rev=907260&view=rev
Log:
Fix DAEMON-118 by applying modified patch provided by Jack Cai

Modified:
    commons/proper/daemon/trunk/src/native/nt/procrun/src/rprocess.c

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/src/rprocess.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/src/rprocess.c?rev=907260&r1=907259&r2=907260&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/src/rprocess.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/src/rprocess.c Sat Feb  6 17:27:34 2010
@@ -878,25 +878,23 @@
 static LPWSTR __apxStrQuote(LPWSTR lpDest, LPCWSTR szSrc)
 {
     LPWSTR p;
-    BOOL   q = FALSE;
+    BOOL   space = FALSE, quote = FALSE;
 
-    /* Find if string has embeded spaces 
+    /* Find if string has embeded spaces, add quotes only if no quotes found 
      */
     for (p = (LPWSTR)szSrc; *p; p++) {
-        if (*p == L' ' || *p == '\t' ||
-            *p == '"' || *p == '\\') {
-            q = TRUE;
-            break;
+        if (*p == L' ' || *p == '\t') {
+            space = TRUE;
+        } else if (*p == L'"') {
+            quote = TRUE;
         }
     }
     p = lpDest;
-    if (q) *p++ = L'"';
+    if (space && !quote) *p++ = L'"';
     while (*szSrc) {
-        if (*szSrc == '"' || *szSrc == '\\')
-            *p++ = L'\\';
         *p++ = *szSrc++;
     }
-    if (q) *p++ = L'"';
+    if (space && !quote) *p++ = L'"';
     return p;
 }
 
@@ -914,17 +912,9 @@
     apxFree(lpProc->szCommandLine);
     
     l = lstrlenW(szTitle) + 3;
-    for (i = 0; i < (DWORD)lstrlenW(szTitle); i++) {
-        if (szTitle[i] == L'"')
-            ++l;
-    }
     for (i = 0; i < dwArgc; i++) {
         int x, q = 0;
         l += (lstrlenW(lpArgs[i]) + 3);
-        for (x = 0; x < lstrlenW(lpArgs[i]); x++) {
-            if (lpArgs[i][x] == L'"')
-                ++q;
-        }
         l += q;
     }
     p = lpProc->szCommandLine = apxPoolAlloc(hProcess->hPool, l * sizeof(WCHAR));
@@ -937,3 +927,4 @@
     OutputDebugStringW(lpProc->szCommandLine);
     return lpProc->szCommandLine != NULL;
 }
+



Mime
View raw message