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

Alexandre Julliard julliard at wine.codeweavers.com
Mon Feb 26 07:59:29 CST 2007


Module: wine
Branch: master
Commit: e8fa5df394c70214a0c2a53b0ddd360b8dec2c2f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e8fa5df394c70214a0c2a53b0ddd360b8dec2c2f

Author: Jason Edmeades <us at edmeades.me.uk>
Date:   Fri Feb 23 22:22:03 2007 +0000

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

---

 programs/cmd/wcmdmain.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 8380d18..2d5f805 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -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++;
       }




More information about the wine-cvs mailing list