cmd: Enable '%0' through '%9' as valid FOR loop variables.

Note: there are many other letters than can be used as variable names.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
Eric Pouech 2024-05-06 10:32:44 +02:00 committed by Alexandre Julliard
parent dc7e8da528
commit 2b51e5aca0
2 changed files with 6 additions and 4 deletions

View file

@ -613,8 +613,8 @@ N
@todo_wine@foo
@todo_wine@bar
--- in digit variables
@todo_wine@a %1 %2
@todo_wine@b %1 %2
a %1 %2
b %1 %2
------------ Testing parameter zero ------------
:func parm1
[:func] [@drive@] [@path@] [test] [.cmd] [@drive@@shortpath@test.cmd]

View file

@ -266,12 +266,13 @@ typedef struct _DIRECTORY_STACK
/* Data structure to for loop variables during for body execution, bearing
in mind that for loops can be nested */
#define MAX_FOR_VARIABLES 52
#define MAX_FOR_VARIABLES (2*26+10)
static inline int for_var_char_to_index(WCHAR c)
{
if (c >= L'a' && c <= L'z') return c - L'a';
if (c >= L'A' && c <= L'Z') return c - L'A' + 26;
if (c >= L'0' && c <= L'9') return c - L'0' + 2 * 26;
return -1;
}
@ -279,7 +280,8 @@ static inline WCHAR for_var_index_to_char(int var_idx)
{
if (var_idx < 0 || var_idx >= MAX_FOR_VARIABLES) return L'?';
if (var_idx < 26) return L'a' + var_idx;
return L'A' + var_idx - 26;
if (var_idx < 52) return L'A' + var_idx - 26;
return L'0' + var_idx - 52;
}
/* check that the range [var_idx, var_idx + var_offset] is a contiguous range */