Commit 1c632cd0 authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

cmd.exe: Make 'set t' show all vars starting with 't'.

parent 69194ce0
...@@ -939,12 +939,16 @@ static int WCMD_compare( const void *a, const void *b ) ...@@ -939,12 +939,16 @@ static int WCMD_compare( const void *a, const void *b )
* WCMD_setshow_sortenv * WCMD_setshow_sortenv
* *
* sort variables into order for display * sort variables into order for display
* Optionally only display those who start with a stub
* returns the count displayed
*/ */
static void WCMD_setshow_sortenv(const char *s) static int WCMD_setshow_sortenv(const char *s, const char *stub)
{ {
UINT count=0, len=0, i; UINT count=0, len=0, i, displayedcount=0, stublen=0;
const char **str; const char **str;
if (stub) stublen = strlen(stub);
/* count the number of strings, and the total length */ /* count the number of strings, and the total length */
while ( s[len] ) { while ( s[len] ) {
len += (lstrlen(&s[len]) + 1); len += (lstrlen(&s[len]) + 1);
...@@ -954,7 +958,7 @@ static void WCMD_setshow_sortenv(const char *s) ...@@ -954,7 +958,7 @@ static void WCMD_setshow_sortenv(const char *s)
/* add the strings to an array */ /* add the strings to an array */
str = LocalAlloc (LMEM_FIXED | LMEM_ZEROINIT, count * sizeof (char*) ); str = LocalAlloc (LMEM_FIXED | LMEM_ZEROINIT, count * sizeof (char*) );
if( !str ) if( !str )
return; return 0;
str[0] = s; str[0] = s;
for( i=1; i<count; i++ ) for( i=1; i<count; i++ )
str[i] = str[i-1] + lstrlen(str[i-1]) + 1; str[i] = str[i-1] + lstrlen(str[i-1]) + 1;
...@@ -964,11 +968,17 @@ static void WCMD_setshow_sortenv(const char *s) ...@@ -964,11 +968,17 @@ static void WCMD_setshow_sortenv(const char *s)
/* print it */ /* print it */
for( i=0; i<count; i++ ) { for( i=0; i<count; i++ ) {
if (!stub || CompareString (LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
str[i], stublen, stub, -1) == 2) {
WCMD_output_asis(str[i]); WCMD_output_asis(str[i]);
WCMD_output_asis("\n"); WCMD_output_asis("\n");
displayedcount++;
}
} }
LocalFree( str ); LocalFree( str );
return displayedcount;
} }
/**************************************************************************** /****************************************************************************
...@@ -982,27 +992,16 @@ void WCMD_setshow_env (char *s) { ...@@ -982,27 +992,16 @@ void WCMD_setshow_env (char *s) {
LPVOID env; LPVOID env;
char *p; char *p;
int status; int status;
char buffer[1048];
if (strlen(param1) == 0) { if (strlen(param1) == 0) {
env = GetEnvironmentStrings (); env = GetEnvironmentStrings ();
WCMD_setshow_sortenv( env ); WCMD_setshow_sortenv( env, NULL );
} }
else { else {
p = strchr (s, '='); p = strchr (s, '=');
if (p == NULL) { if (p == NULL) {
env = GetEnvironmentStrings ();
/* FIXME: Emulate Win98 for now, ie "SET C" looks ONLY for an if (WCMD_setshow_sortenv( env, s ) == 0) {
environment variable C, whereas on NT it shows ALL variables
starting with C.
*/
status = GetEnvironmentVariable(s, buffer, sizeof(buffer));
if (status) {
WCMD_output_asis( s);
WCMD_output_asis( "=");
WCMD_output_asis( buffer);
WCMD_output_asis( "\n");
} else {
WCMD_output ("Environment variable %s not defined\n", s); WCMD_output ("Environment variable %s not defined\n", s);
} }
return; return;
...@@ -1013,7 +1012,6 @@ char buffer[1048]; ...@@ -1013,7 +1012,6 @@ char buffer[1048];
status = SetEnvironmentVariable (s, p); status = SetEnvironmentVariable (s, p);
if ((!status) & (GetLastError() != ERROR_ENVVAR_NOT_FOUND)) WCMD_print_error(); if ((!status) & (GetLastError() != ERROR_ENVVAR_NOT_FOUND)) WCMD_print_error();
} }
/* WCMD_output (newline); @JED*/
} }
/**************************************************************************** /****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment