Module: wine
Branch: stable
Commit: 5d6c525dc4d4390f468ffafaf1e6cdeb29f410d6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5d6c525dc4d4390f468ffafa…
Author: Jason Edmeades <us(a)edmeades.me.uk>
Date: Mon Sep 10 23:30:19 2018 +0100
cmd: Handle "for" loop handling of tokens, where * does not follow a number.
With the 'for' loop /f syntax, if tokens are requested the the normal
syntax is something like tokens=1,2* but there is valid syntax like
1,2,* (which effectively means the same). Make this other syntax work.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45722
Signed-off-by: Jason Edmeades <us(a)edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
(cherry picked from commit 1a7333bec627a31a43d380ecc63e5792e302373e)
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/builtins.c | 48 +++++++++++++++++++-------------
programs/cmd/tests/test_builtins.cmd | 3 +-
programs/cmd/tests/test_builtins.cmd.exp | 1 +
3 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 9cd86b3..48cfc13 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1836,8 +1836,8 @@ static int WCMD_for_nexttoken(int lasttoken, WCHAR *tokenstr,
if (doall) *doall = FALSE;
if (duplicates) *duplicates = FALSE;
- WINE_TRACE("Find next token after %d in %s was %d\n", lasttoken,
- wine_dbgstr_w(tokenstr), nexttoken);
+ WINE_TRACE("Find next token after %d in %s\n", lasttoken,
+ wine_dbgstr_w(tokenstr));
/* Loop through the token string, parsing it. Valid syntax is:
token=m or x-y with comma delimiter and optionally * to finish*/
@@ -1845,11 +1845,21 @@ static int WCMD_for_nexttoken(int lasttoken, WCHAR *tokenstr,
int nextnumber1, nextnumber2 = -1;
WCHAR *nextchar;
- /* It is valid syntax tokens=* which just means get whole line */
+ /* Remember if the next character is a star, it indicates a need to
+ show all remaining tokens and should be the last character */
if (*pos == '*') {
if (doall) *doall = TRUE;
if (totalfound) (*totalfound)++;
- nexttoken = 0;
+ /* If we have not found a next token to return, then indicate
+ time to process the star */
+ if (nexttoken == -1) {
+ if (lasttoken == -1) {
+ /* Special case the syntax of tokens=* which just means get whole line */
+ nexttoken = 0;
+ } else {
+ nexttoken = lasttoken;
+ }
+ }
break;
}
@@ -1882,8 +1892,9 @@ static int WCMD_for_nexttoken(int lasttoken, WCHAR *tokenstr,
if (nextnumber2 >= nextnumber1 && totalfound) {
*totalfound = *totalfound + 1 + (nextnumber2 - nextnumber1);
}
+ pos = nextchar;
- } else {
+ } else if (pos != nextchar) {
if (totalfound) (*totalfound)++;
/* See if the number found is one we have already seen */
@@ -1894,26 +1905,25 @@ static int WCMD_for_nexttoken(int lasttoken, WCHAR *tokenstr,
((nexttoken == -1) || (nextnumber1 < nexttoken))) {
nexttoken = nextnumber1;
}
+ pos = nextchar;
+ } else {
+ /* Step on to the next character, usually over comma */
+ if (*pos) pos++;
}
- /* Remember if it is followed by a star, and if it is indicate a need to
- show all tokens, unless a duplicate has been found */
- if (*nextchar == '*') {
- if (doall) *doall = TRUE;
- if (totalfound) (*totalfound)++;
- }
-
- /* Step on to the next character */
- pos = nextchar;
- if (*pos) pos++;
}
/* Return result */
- if (nexttoken == -1) nexttoken = lasttoken;
- WINE_TRACE("Found next token after %d was %d\n", lasttoken, nexttoken);
- if (totalfound) WINE_TRACE("Found total tokens in total %d\n", *totalfound);
- if (doall && *doall) WINE_TRACE("Request for all tokens found\n");
+ if (nexttoken == -1) {
+ WINE_TRACE("No next token found, previous was %d\n", lasttoken);
+ nexttoken = lasttoken;
+ } else if (nexttoken==lasttoken && doall && *doall) {
+ WINE_TRACE("Request for all remaining tokens now\n");
+ } else {
+ WINE_TRACE("Found next token after %d was %d\n", lasttoken, nexttoken);
+ }
+ if (totalfound) WINE_TRACE("Found total tokens to be %d\n", *totalfound);
if (duplicates && *duplicates) WINE_TRACE("Duplicate numbers found\n");
return nexttoken;
}
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 08b9d9d..1874b0c 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1774,11 +1774,12 @@ for /f "tokens=1,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k
for /f "tokens=1,1,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
for /f "tokens=2,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
for /f "tokens=3,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
-rem Special case tokens=*
+rem Special case tokens=* or tokens=n,*
echo 3.14>testfile
FOR /F "tokens=*" %%A IN (testfile) DO @echo 1:%%A,%%B
FOR /F "tokens=1*" %%A IN (testfile) DO @echo 2:%%A,%%B
FOR /F "tokens=2*" %%A IN (testfile) DO @echo 3:%%A,%%B
+FOR /F "tokens=1,* delims=." %%A IN (testfile) DO @echo 4:%%A,%%B
del testfile
cd ..
rd /s/q foobar
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index e105576..ebb3161 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1255,6 +1255,7 @@ h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o
h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o
1:3.14,%B
2:3.14,
+4:3,14
------ parameter splitting
:forFParameterSplittingFunc myparam1=myvalue1 myparam2=myparam2 mytest@space@@space@@space@
:forFParameterSplittingFunc myparam1=myvalue1 myparam2=myparam2 mytest@space@@space@@space@
Module: wine
Branch: stable
Commit: f18ebeda4ebd0b5e1f81b23c66327c73868c3a05
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f18ebeda4ebd0b5e1f81b23c…
Author: Jason Edmeades <us(a)edmeades.me.uk>
Date: Sun Jul 15 23:15:27 2018 +0100
cmd: Handle special case tokens=* in for /f.
for /f allows a special syntax of tokens=* (rather than tokens=1* for example)
which just means put the whole line into the next variable). Note the handling of
the 'next variable' was wrong in the case of it being 'A' or 'a' as the wrap
calculation was wrong, but this only affected using this new syntax.
Signed-off-by: Jason Edmeades <us(a)edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
(cherry picked from commit 4030a952095398e5a42f0a74213f6a1e9186c4bc)
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/builtins.c | 28 ++++++++++++++++++----------
programs/cmd/tests/test_builtins.cmd | 12 ++++++++++++
programs/cmd/tests/test_builtins.cmd.exp | 5 +++++
3 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 752cf43..9cd86b3 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1845,6 +1845,14 @@ static int WCMD_for_nexttoken(int lasttoken, WCHAR *tokenstr,
int nextnumber1, nextnumber2 = -1;
WCHAR *nextchar;
+ /* It is valid syntax tokens=* which just means get whole line */
+ if (*pos == '*') {
+ if (doall) *doall = TRUE;
+ if (totalfound) (*totalfound)++;
+ nexttoken = 0;
+ break;
+ }
+
/* Get the next number */
nextnumber1 = strtoulW(pos, &nextchar, 10);
@@ -1973,22 +1981,22 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
*/
lasttoken = -1;
nexttoken = WCMD_for_nexttoken(lasttoken, forf_tokens, &totalfound,
- NULL, &thisduplicate);
+ &starfound, &thisduplicate);
varidx = FOR_VAR_IDX(variable);
/* Empty out variables */
for (varoffset=0;
- varidx >= 0 && varoffset<totalfound && ((varidx+varoffset)%26);
+ varidx >= 0 && varoffset<totalfound && (((varidx%26) + varoffset) < 26);
varoffset++) {
forloopcontext.variable[varidx + varoffset] = (WCHAR *)nullW;
- /* Stop if we walk beyond z or Z */
- if (((varidx+varoffset) % 26) == 0) break;
}
- /* Loop extracting the tokens */
+ /* Loop extracting the tokens
+ Note: nexttoken of 0 means there were no tokens requested, to handle
+ the special case of tokens=* */
varoffset = 0;
WINE_TRACE("Parsing buffer into tokens: '%s'\n", wine_dbgstr_w(buffer));
- while (varidx >= 0 && (nexttoken > lasttoken)) {
+ while (varidx >= 0 && (nexttoken > 0 && (nexttoken > lasttoken))) {
anyduplicates |= thisduplicate;
/* Extract the token number requested and set into the next variable context */
@@ -1996,9 +2004,9 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
WINE_TRACE("Parsed token %d(%d) as parameter %s\n", nexttoken,
varidx + varoffset, wine_dbgstr_w(parm));
if (varidx >=0) {
- forloopcontext.variable[varidx + varoffset] = heap_strdupW(parm);
+ if (parm) forloopcontext.variable[varidx + varoffset] = heap_strdupW(parm);
varoffset++;
- if (((varidx + varoffset) %26) == 0) break;
+ if (((varidx%26)+varoffset) >= 26) break;
}
/* Find the next token */
@@ -2009,12 +2017,12 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
/* If all the rest of the tokens were requested, and there is still space in
the variable range, write them now */
- if (!anyduplicates && starfound && varidx >= 0 && ((varidx+varoffset) % 26)) {
+ if (!anyduplicates && starfound && varidx >= 0 && (((varidx%26) + varoffset) < 26)) {
nexttoken++;
WCMD_parameter_with_delims(buffer, (nexttoken-1), &parm, FALSE, FALSE, forf_delims);
WINE_TRACE("Parsed allremaining tokens (%d) as parameter %s\n",
varidx + varoffset, wine_dbgstr_w(parm));
- forloopcontext.variable[varidx + varoffset] = heap_strdupW(parm);
+ if (parm) forloopcontext.variable[varidx + varoffset] = heap_strdupW(parm);
}
/* Execute the body of the foor loop with these values */
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index cf9a986..08b9d9d 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1774,6 +1774,12 @@ for /f "tokens=1,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k
for /f "tokens=1,1,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
for /f "tokens=2,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
for /f "tokens=3,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
+rem Special case tokens=*
+echo 3.14>testfile
+FOR /F "tokens=*" %%A IN (testfile) DO @echo 1:%%A,%%B
+FOR /F "tokens=1*" %%A IN (testfile) DO @echo 2:%%A,%%B
+FOR /F "tokens=2*" %%A IN (testfile) DO @echo 3:%%A,%%B
+del testfile
cd ..
rd /s/q foobar
echo ------ parameter splitting
@@ -1786,6 +1792,12 @@ goto :forFParameterSplittingEnd
echo %~0 %~1 %~2 %~3 %~4 %~5
goto :eof
:forFParameterSplittingEnd
+echo 3.14>testfile
+FOR /F "delims=. tokens=*" %%A IN (testfile) DO @echo 4:%%A,%%B
+FOR /F "delims=. tokens=1*" %%A IN (testfile) DO @echo 5:%%A,%%B
+FOR /F "delims=. tokens=2*" %%A IN (testfile) DO @echo 6:%%A,%%B
+FOR /F "delims=. tokens=3*" %%A IN (testfile) DO @echo 7:%%A,%%B
+del testfile
echo ------------ Testing del ------------
echo abc > file
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index dd8d1d4..e105576 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1253,9 +1253,14 @@ h=%h i=a j=b k=c l=d e f g m=%m n=%n o=%o@or_broken@h=%h i=a j=b k=c l=d e f g m
h=%h i=a j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=a j=c k= l= m= n=%n o=%o
h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o
h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o
+1:3.14,%B
+2:3.14,
------ parameter splitting
:forFParameterSplittingFunc myparam1=myvalue1 myparam2=myparam2 mytest@space@@space@@space@
:forFParameterSplittingFunc myparam1=myvalue1 myparam2=myparam2 mytest@space@@space@@space@
+4:3.14,%B
+5:3,14
+6:14,
------------ Testing del ------------
deleting 'file'
errorlevel is 0, good
Module: wine
Branch: stable
Commit: 8304053aadb2139880c9efd9f61b5bff285f9980
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8304053aadb2139880c9efd9…
Author: Rodrigo Saboya <saboya(a)gmail.com>
Date: Tue Sep 11 14:27:42 2018 -0300
wine.inf: Updates E. South America Standard Time DST data.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45786
Signed-off-by: Rodrigo Saboya <saboya(a)gmail.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
(cherry picked from commit b29cdbd5f23548d9631e5c98ec923b6d2d16a3f8)
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
loader/wine.inf.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/loader/wine.inf.in b/loader/wine.inf.in
index 1ed87dc..be3e861 100644
--- a/loader/wine.inf.in
+++ b/loader/wine.inf.in
@@ -2799,7 +2799,7 @@ HKLM,%CurrentVersionNT%\Time Zones\E. Australia Standard Time,"TZI",1,a8,fd,ff,f
HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time,"Display",,"America/Sao_Paulo"
HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time,"Dlt",,"E. South America Daylight Time"
HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time,"Std",,"E. South America Standard Time"
-HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time,"TZI",1,b4,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,03,00,00,00,00,00,00,00,00,00,00,00,0a,00,00,00,03,00,00,00,00,00,00,00,00,00
+HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time,"TZI",1,b4,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,03,00,00,00,00,00,00,00,00,00,00,00,0b,00,00,00,01,00,00,00,00,00,00,00,00,00
HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time\Dynamic DST,"2015",1,b4,00,00,00,00,00,00,00,c4,ff,ff,ff,df,07,02,00,00,00,16,00,00,00,00,00,00,00,00,00,df,07,0a,00,00,00,12,00,00,00,00,00,00,00,00,00
HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time\Dynamic DST,"2023",1,b4,00,00,00,00,00,00,00,c4,ff,ff,ff,e7,07,02,00,00,00,1a,00,00,00,00,00,00,00,00,00,e7,07,0a,00,00,00,0f,00,00,00,00,00,00,00,00,00
HKLM,%CurrentVersionNT%\Time Zones\E. South America Standard Time\Dynamic DST,"2026",1,b4,00,00,00,00,00,00,00,c4,ff,ff,ff,ea,07,02,00,00,00,16,00,00,00,00,00,00,00,00,00,ea,07,0a,00,00,00,12,00,00,00,00,00,00,00,00,00