[PATCH 6/6] [cmd] Add support for eol= processing in for /f
Ann and Jason Edmeades
jason at edmeades.me.uk
Tue Oct 16 18:43:35 CDT 2012
Add support for eol= in for /f which allows you to specify a
character which skips the whole line if the first parameter starts
with it.
Again, NT4 is just broken in this regard so skipped. Remaining
todos on eol= tests are because parameter delimiters are not
handled correctly yet.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20121017/32facd0c/attachment.html>
-------------- next part --------------
From 020163ee795195e2f527f4946cf8e52ea9e1e257 Mon Sep 17 00:00:00 2001
From: Jason Edmeades <jason at edmeades.me.uk>
Date: Wed, 17 Oct 2012 00:33:45 +0100
Subject: [PATCH 6/6] [cmd] Add support for eol= processing in for /f
Add support for eol= in for /f which allows you to specify a
character which skips the whole line if the first parameter starts
with it.
Again, NT4 is just broken in this regard so skipped. Remaining
todos on eol= tests are because parameter delimiters are not
handled correctly yet.
---
programs/cmd/builtins.c | 8 ++++----
programs/cmd/tests/test_builtins.cmd | 12 ++++++++++++
programs/cmd/tests/test_builtins.cmd.exp | 3 +++
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 82de0bc..87fcc9c 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1633,7 +1633,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
eolW, sizeof(eolW)/sizeof(WCHAR)) == CSTR_EQUAL) {
forf_eol = *(pos + sizeof(eolW)/sizeof(WCHAR));
pos = pos + sizeof(eolW)/sizeof(WCHAR) + 1;
- WINE_FIXME("Found eol as %c(%x)\n", forf_eol, forf_eol);
+ WINE_TRACE("Found eol as %c(%x)\n", forf_eol, forf_eol);
/* Save number of lines to skip (Can be in base 10, hex (0x...) or octal (0xx) */
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
@@ -1948,12 +1948,12 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
continue;
}
- /* Skip blank lines*/
+ /* Skip blank lines and ones starting with the eol character */
parm = WCMD_parameter (buffer, 0, &where, NULL, FALSE, FALSE);
WINE_TRACE("Parsed parameter: %s from %s\n", wine_dbgstr_w(parm),
wine_dbgstr_w(buffer));
- if (where) {
+ if (where && where[0] != forf_eol) {
/* FIXME: The following should be moved into its own routine and
reused for the string literal parsing below */
thisCmdStart = cmdStart;
@@ -1983,7 +1983,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
WINE_TRACE("Parsed parameter: %s from %s\n", wine_dbgstr_w(parm),
wine_dbgstr_w(buffer));
- if (where && forf_skip == 0) {
+ if (where && forf_skip == 0 && where[0] != forf_eol) {
/* FIXME: The following should be moved into its own routine and
reused for the string literal parsing below */
thisCmdStart = cmdStart;
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index bdc4a3f..2c0464c 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1016,6 +1016,17 @@ rem for a simple todo_wine test
rem (for /f "usebackq" %%i in (`echo z a b`) do echo %%i) || echo not supported
rem (for /f usebackq %%i in (`echo z a b`) do echo %%i) || echo not supported
echo ------ eol option
+if "%CD%"=="" goto :SkipFORFeolNT4
+echo Line one>foo
+echo and Line two>>foo
+echo Line three>>foo
+for /f "eol=L" %%i in (foo) do echo %%i
+for /f "eol=a" %%i in (foo) do echo %%i
+del foo
+goto :ContinueFORFeol
+:SkipFORFeolNT4
+for /l %%i in (1,1,3) do echo Broken NT4 functionality%%i
+:ContinueFORFeol
for /f "eol=@" %%i in (" ad") do echo %%i
for /f "eol=@" %%i in (" z at y") do echo %%i
for /f "eol=|" %%i in ("a|d") do echo %%i
@@ -1042,6 +1053,7 @@ for /f "skip=4" %%i in (foo) do echo %%i > output_file
if not exist output_file (echo no output) else (del output_file)
for /f "skip=02" %%i in (foo) do echo %%i
for /f "skip=0x2" %%i in (foo) do echo %%i
+for /f "skip=1" %%i in ("Failed") do echo %%i
cd ..
rd /s/q foobar
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index c0b7baf..0d0bc75 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -643,6 +643,9 @@ Passed1 at or_broken@Missing functionality - Broken1
Passed2 at or_broken@Missing functionality - Broken2
Passed3 at or_broken@Missing functionality - Broken3
------ eol option
+and at or_broken@Broken NT4 functionality1
+Line at or_broken@Broken NT4 functionality2
+Line at or_broken@Broken NT4 functionality3
@todo_wine at ad
@todo_wine at z@y
a|d
--
1.7.9.5
More information about the wine-patches
mailing list