cmd.exe: Add %random% special name support.

This commit is contained in:
Jason Edmeades 2007-02-23 22:22:03 +00:00 committed by Alexandre Julliard
parent 98ae8a6941
commit e8fa5df394
1 changed files with 12 additions and 2 deletions

View File

@ -318,8 +318,8 @@ void WCMD_process_command (char *command)
/* Expand environment variables in a batch file %{0-9} first */
/* including support for any ~ modifiers */
/* Additionally: */
/* Expand the DATE, TIME, CD and ERRORLEVEL special names */
/* allowing environment variable overrides */
/* Expand the DATE, TIME, CD, RANDOM and ERRORLEVEL special */
/* names allowing environment variable overrides */
/* FIXME: Winnt would replace %1%fred%1 with first parm, then */
/* contents of fred, then the digit 1. Would need to remove */
@ -399,6 +399,16 @@ void WCMD_process_command (char *command)
strcpy (p, temp);
strcat (p, s);
} else if ((CompareString (LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
(p+1), 7, "RANDOM%", -1) == 2) &&
(GetEnvironmentVariable("RANDOM", temp, 1) == 0) &&
(GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
sprintf(temp, "%d", rand() % 32768);
s = strdup (p+8);
strcpy (p, temp);
strcat (p, s);
} else {
p++;
}