Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c27f8f72
Commit
c27f8f72
authored
Aug 16, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Aug 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Introduce an option_equals helper for WCMD_parse_forf_options.
parent
79e78218
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
builtins.c
programs/cmd/builtins.c
+19
-21
No files found.
programs/cmd/builtins.c
View file @
c27f8f72
...
...
@@ -1631,6 +1631,19 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
return
;
}
static
BOOL
option_equals
(
WCHAR
**
haystack
,
const
WCHAR
*
needle
)
{
int
len
=
wcslen
(
needle
);
if
(
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
*
haystack
,
len
,
needle
,
len
)
==
CSTR_EQUAL
)
{
*
haystack
+=
len
;
return
TRUE
;
}
return
FALSE
;
}
/*****************************************************************************
* WCMD_parse_forf_options
*
...
...
@@ -1653,11 +1666,6 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
WCHAR
*
pos
=
options
;
int
len
=
lstrlenW
(
pos
);
const
int
eol_len
=
lstrlenW
(
L"eol="
);
const
int
skip_len
=
lstrlenW
(
L"skip="
);
const
int
tokens_len
=
lstrlenW
(
L"tokens="
);
const
int
delims_len
=
lstrlenW
(
L"delims="
);
const
int
usebackq_len
=
lstrlenW
(
L"usebackq"
);
/* Initialize to defaults */
lstrcpyW
(
delims
,
L"
\t
"
);
...
...
@@ -1678,36 +1686,28 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
pos
++
;
/* Save End of line character (Ignore line if first token (based on delims) starts with it) */
}
else
if
(
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
pos
,
eol_len
,
L"eol="
,
eol_len
)
==
CSTR_EQUAL
)
{
*
eol
=
*
(
pos
+
eol_len
);
pos
=
pos
+
eol_len
+
1
;
}
else
if
(
option_equals
(
&
pos
,
L"eol="
))
{
*
eol
=
*
pos
++
;
WINE_TRACE
(
"Found eol as %c(%x)
\n
"
,
*
eol
,
*
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
,
pos
,
skip_len
,
L"skip="
,
skip_len
)
==
CSTR_EQUAL
)
{
}
else
if
(
option_equals
(
&
pos
,
L"skip="
))
{
WCHAR
*
nextchar
=
NULL
;
pos
=
pos
+
skip_len
;
*
skip
=
wcstoul
(
pos
,
&
nextchar
,
0
);
WINE_TRACE
(
"Found skip as %d lines
\n
"
,
*
skip
);
pos
=
nextchar
;
/* Save if usebackq semantics are in effect */
}
else
if
(
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
pos
,
usebackq_len
,
L"usebackq"
,
usebackq_len
)
==
CSTR_EQUAL
)
{
}
else
if
(
option_equals
(
&
pos
,
L"usebackq"
))
{
*
usebackq
=
TRUE
;
pos
=
pos
+
usebackq_len
;
WINE_TRACE
(
"Found usebackq
\n
"
);
/* Save the supplied delims. Slightly odd as space can be a delimiter but only
if you finish the optionsroot string with delims= otherwise the space is
just a token delimiter! */
}
else
if
(
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
pos
,
delims_len
,
L"delims="
,
delims_len
)
==
CSTR_EQUAL
)
{
}
else
if
(
option_equals
(
&
pos
,
L"delims="
))
{
int
i
=
0
;
pos
=
pos
+
delims_len
;
while
(
*
pos
&&
*
pos
!=
' '
)
{
delims
[
i
++
]
=
*
pos
;
pos
++
;
...
...
@@ -1717,11 +1717,9 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
WINE_TRACE
(
"Found delims as '%s'
\n
"
,
wine_dbgstr_w
(
delims
));
/* Save the tokens being requested */
}
else
if
(
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
pos
,
tokens_len
,
L"tokens="
,
tokens_len
)
==
CSTR_EQUAL
)
{
}
else
if
(
option_equals
(
&
pos
,
L"tokens="
))
{
int
i
=
0
;
pos
=
pos
+
tokens_len
;
while
(
*
pos
&&
*
pos
!=
' '
)
{
tokens
[
i
++
]
=
*
pos
;
pos
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment