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
31083dba
Commit
31083dba
authored
Jun 27, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Get rid of some string helper functions.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a8745d12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
61 deletions
+63
-61
string.c
dlls/kernelbase/string.c
+63
-61
No files found.
dlls/kernelbase/string.c
View file @
31083dba
...
...
@@ -308,45 +308,31 @@ BOOL WINAPI ChrCmpIA(WORD ch1, WORD ch2)
return
char_compare
(
ch1
,
ch2
,
NORM_IGNORECASE
);
}
static
BOOL
WINAPI
ChrCmpA
(
WORD
ch1
,
WORD
ch2
)
{
return
char_compare
(
ch1
,
ch2
,
0
);
}
BOOL
WINAPI
ChrCmpIW
(
WCHAR
ch1
,
WCHAR
ch2
)
{
return
CompareStringW
(
GetThreadLocale
(),
NORM_IGNORECASE
,
&
ch1
,
1
,
&
ch2
,
1
)
-
CSTR_EQUAL
;
}
static
char
*
strstr_helper
(
const
char
*
str
,
const
char
*
search
,
INT
(
WINAPI
*
cmp_func
)(
const
char
*
,
const
char
*
,
int
))
char
*
WINAPI
StrStrA
(
const
char
*
str
,
const
char
*
search
)
{
const
char
*
end
;
size_t
len
;
if
(
!
str
||
!
search
||
!*
search
)
return
NULL
;
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
search
));
if
(
!
str
||
!
search
||
!*
search
)
return
NULL
;
len
=
strlen
(
search
);
end
=
str
+
strlen
(
str
);
while
(
str
+
len
<=
end
)
{
if
(
!
cmp_func
(
str
,
search
,
len
))
return
(
char
*
)
str
;
if
(
!
StrCmpNA
(
str
,
search
,
len
))
return
(
char
*
)
str
;
str
=
CharNextA
(
str
);
}
return
NULL
;
}
char
*
WINAPI
StrStrA
(
const
char
*
str
,
const
char
*
search
)
{
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
search
));
return
strstr_helper
(
str
,
search
,
StrCmpNA
);
}
WCHAR
*
WINAPI
StrStrW
(
const
WCHAR
*
str
,
const
WCHAR
*
search
)
{
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_w
(
str
),
wine_dbgstr_w
(
search
));
...
...
@@ -465,9 +451,22 @@ WCHAR * WINAPI StrCpyNW(WCHAR *dst, const WCHAR *src, int count)
char
*
WINAPI
StrStrIA
(
const
char
*
str
,
const
char
*
search
)
{
const
char
*
end
;
size_t
len
;
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_a
(
str
),
debugstr_a
(
search
));
return
strstr_helper
(
str
,
search
,
StrCmpNIA
);
if
(
!
str
||
!
search
||
!*
search
)
return
NULL
;
len
=
strlen
(
search
);
end
=
str
+
strlen
(
str
);
while
(
str
+
len
<=
end
)
{
if
(
!
StrCmpNIA
(
str
,
search
,
len
))
return
(
char
*
)
str
;
str
=
CharNextA
(
str
);
}
return
NULL
;
}
WCHAR
*
WINAPI
StrStrIW
(
const
WCHAR
*
str
,
const
WCHAR
*
search
)
...
...
@@ -493,35 +492,22 @@ WCHAR * WINAPI StrStrIW(const WCHAR *str, const WCHAR *search)
return
NULL
;
}
static
int
strspn_helper
(
const
char
*
str
,
const
char
*
match
,
char
*
(
WINAPI
*
func
)(
const
char
*
,
WORD
),
BOOL
invert
)
int
WINAPI
StrSpnA
(
const
char
*
str
,
const
char
*
match
)
{
const
char
*
ptr
=
str
;
if
(
!
str
||
!*
str
||
!
match
)
return
0
;
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
match
));
if
(
!
str
||
!
match
)
return
0
;
while
(
*
ptr
)
{
const
char
*
test
=
func
(
match
,
*
ptr
);
if
(
!
invert
&&
!
test
)
break
;
if
(
invert
&&
test
)
break
;
if
(
!
StrChrA
(
match
,
*
ptr
))
break
;
ptr
=
CharNextA
(
ptr
);
};
}
return
ptr
-
str
;
}
int
WINAPI
StrSpnA
(
const
char
*
str
,
const
char
*
match
)
{
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
match
));
return
strspn_helper
(
str
,
match
,
StrChrA
,
FALSE
);
}
int
WINAPI
StrSpnW
(
const
WCHAR
*
str
,
const
WCHAR
*
match
)
{
if
(
!
str
||
!
match
)
return
0
;
...
...
@@ -530,9 +516,18 @@ int WINAPI StrSpnW(const WCHAR *str, const WCHAR *match)
int
WINAPI
StrCSpnA
(
const
char
*
str
,
const
char
*
match
)
{
const
char
*
ptr
=
str
;
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
match
));
return
strspn_helper
(
str
,
match
,
StrChrA
,
TRUE
);
if
(
!
str
||
!
match
)
return
0
;
while
(
*
ptr
)
{
if
(
StrChrA
(
match
,
*
ptr
))
break
;
ptr
=
CharNextA
(
ptr
);
}
return
ptr
-
str
;
}
int
WINAPI
StrCSpnW
(
const
WCHAR
*
str
,
const
WCHAR
*
match
)
...
...
@@ -545,9 +540,18 @@ int WINAPI StrCSpnW(const WCHAR *str, const WCHAR *match)
int
WINAPI
StrCSpnIA
(
const
char
*
str
,
const
char
*
match
)
{
const
char
*
ptr
=
str
;
TRACE
(
"%s, %s
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
match
));
return
strspn_helper
(
str
,
match
,
StrChrIA
,
TRUE
);
if
(
!
str
||
!
match
)
return
0
;
while
(
*
ptr
)
{
if
(
StrChrIA
(
match
,
*
ptr
))
break
;
ptr
=
CharNextA
(
ptr
);
}
return
ptr
-
str
;
}
int
WINAPI
StrCSpnIW
(
const
WCHAR
*
str
,
const
WCHAR
*
match
)
...
...
@@ -568,36 +572,23 @@ int WINAPI StrCSpnIW(const WCHAR *str, const WCHAR *match)
return
ptr
-
str
;
}
static
LPSTR
strrchra_helper
(
const
char
*
str
,
const
char
*
end
,
WORD
ch
,
BOOL
(
WINAPI
*
cmp_func
)(
WORD
,
WORD
)
)
char
*
WINAPI
StrRChrA
(
const
char
*
str
,
const
char
*
end
,
WORD
ch
)
{
const
char
*
ret
=
NULL
;
WORD
ch2
;
if
(
!
str
)
return
NULL
;
if
(
!
end
)
end
=
str
+
lstrlenA
(
str
);
TRACE
(
"%s, %s, %#x
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
end
),
ch
);
if
(
!
str
)
return
NULL
;
if
(
!
end
)
end
=
str
+
lstrlenA
(
str
);
while
(
*
str
&&
str
<=
end
)
{
ch2
=
IsDBCSLeadByte
(
*
str
)
?
*
str
<<
8
|
str
[
1
]
:
*
str
;
if
(
!
cmp_func
(
ch
,
ch2
))
ret
=
str
;
WORD
ch2
=
IsDBCSLeadByte
(
*
str
)
?
*
str
<<
8
|
str
[
1
]
:
*
str
;
if
(
!
char_compare
(
ch
,
ch2
,
0
))
ret
=
str
;
str
=
CharNextA
(
str
);
}
return
(
char
*
)
ret
;
}
char
*
WINAPI
StrRChrA
(
const
char
*
str
,
const
char
*
end
,
WORD
ch
)
{
TRACE
(
"%s, %s, %#x
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
end
),
ch
);
return
strrchra_helper
(
str
,
end
,
ch
,
ChrCmpA
);
}
WCHAR
*
WINAPI
StrRChrW
(
const
WCHAR
*
str
,
const
WCHAR
*
end
,
WORD
ch
)
{
WCHAR
*
ret
=
NULL
;
...
...
@@ -614,9 +605,20 @@ WCHAR * WINAPI StrRChrW(const WCHAR *str, const WCHAR *end, WORD ch)
char
*
WINAPI
StrRChrIA
(
const
char
*
str
,
const
char
*
end
,
WORD
ch
)
{
const
char
*
ret
=
NULL
;
TRACE
(
"%s, %s, %#x
\n
"
,
wine_dbgstr_a
(
str
),
wine_dbgstr_a
(
end
),
ch
);
return
strrchra_helper
(
str
,
end
,
ch
,
ChrCmpIA
);
if
(
!
str
)
return
NULL
;
if
(
!
end
)
end
=
str
+
lstrlenA
(
str
);
while
(
*
str
&&
str
<=
end
)
{
WORD
ch2
=
IsDBCSLeadByte
(
*
str
)
?
*
str
<<
8
|
str
[
1
]
:
*
str
;
if
(
!
ChrCmpIA
(
ch
,
ch2
))
ret
=
str
;
str
=
CharNextA
(
str
);
}
return
(
char
*
)
ret
;
}
WCHAR
*
WINAPI
StrRChrIW
(
const
WCHAR
*
str
,
const
WCHAR
*
end
,
WORD
ch
)
...
...
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