Module: wine Branch: master Commit: 4b1ef917bc1bec43749f4d7a576567ad33b537a2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4b1ef917bc1bec43749f4d7a57...
Author: Jason Edmeades us@edmeades.me.uk Date: Tue Mar 13 00:11:04 2007 +0000
cmd.exe: Add SET /P support.
---
programs/cmd/builtins.c | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 8359152..02004ae 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1278,11 +1278,42 @@ void WCMD_setshow_env (char *s) { char *p; int status;
- if (strlen(param1) == 0) { + if (param1[0] == 0x00 && quals[0] == 0x00) { env = GetEnvironmentStrings (); WCMD_setshow_sortenv( env, NULL ); + return; } - else { + + /* See if /P supplied, and if so echo the prompt, and read in a reply */ + if (CompareString (LOCALE_USER_DEFAULT, + NORM_IGNORECASE | SORT_STRINGSORT, + s, 2, "/P", -1) == 2) { + char string[MAXSTRING]; + DWORD count; + + s += 2; + while (*s && *s==' ') s++; + + /* If no parameter, or no '=' sign, return an error */ + if (!(*s) || ((p = strchr (s, '=')) == NULL )) { + WCMD_output ("Argument missing\n"); + return; + } + + /* Output the prompt */ + *p++ = '\0'; + if (strlen(p) != 0) WCMD_output(p); + + /* Read the reply */ + ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL); + if (count > 1) { + string[count-1] = '\0'; /* ReadFile output is not null-terminated! */ + if (string[count-2] == '\r') string[count-2] = '\0'; /* Under Windoze we get CRLF! */ + WINE_TRACE("set /p: Setting var '%s' to '%s'\n", s, string); + status = SetEnvironmentVariable (s, string); + } + + } else { p = strchr (s, '='); if (p == NULL) { env = GetEnvironmentStrings ();