wcmd: ignore start and end quotes (try 5)

André Hentschel nerv at dawncrow.de
Fri Aug 28 11:34:32 CDT 2009


now without touching the existing code

in cmd tested with:
>set foo=bar
>set foo
bar
>set "foo=test"
>set foo
test
>set "foo"
test

strip function tested with:
wine cmd /c "net help"
wine cmd /c /s "net help"
wine cmd /k "net help"
wine cmd /k /s "net help"
wine cmd /c "net "help""
wine cmd /c /s "net "help""
wine cmd /k "net "help""
wine cmd /k /s "net "help""

and the results stay the same
---
 programs/cmd/builtins.c |    5 +++++
 programs/cmd/wcmd.h     |    1 +
 programs/cmd/wcmdmain.c |    2 +-
 3 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index b544a37..612e5d9 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2072,6 +2072,8 @@ void WCMD_setshow_env (WCHAR *s) {
 
     s += 2;
     while (*s && *s==' ') s++;
+    if (*s=='\"')
+        WCMD_opt_s_strip_quotes(s);
 
     /* If no parameter, or no '=' sign, return an error */
     if (!(*s) || ((p = strchrW (s, '=')) == NULL )) {
@@ -2096,6 +2098,9 @@ void WCMD_setshow_env (WCHAR *s) {
 
   } else {
     DWORD gle;
+
+    if (*s=='\"')
+        WCMD_opt_s_strip_quotes(s);
     p = strchrW (s, '=');
     if (p == NULL) {
       env = GetEnvironmentStrings ();
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index 667b3b9..00bada2 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -100,6 +100,7 @@ WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string);
 void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable, WCHAR *forValue, BOOL justFors);
 
 void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
+void WCMD_opt_s_strip_quotes(WCHAR *cmd);
 WCHAR *WCMD_LoadMessage(UINT id);
 WCHAR *WCMD_strdupW(WCHAR *input);
 void WCMD_strsubstW(WCHAR *start, WCHAR* next, WCHAR* insert, int len);
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index d3aea6d..249526f 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -457,7 +457,7 @@ WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string) {
  *
  *	Remove first and last quote WCHARacters, preserving all other text
  */
-static void WCMD_opt_s_strip_quotes(WCHAR *cmd) {
+void WCMD_opt_s_strip_quotes(WCHAR *cmd) {
   WCHAR *src = cmd + 1, *dest = cmd, *lastq = NULL;
   while((*dest=*src) != '\0') {
       if (*src=='\"')
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list