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
9307a5dd
Commit
9307a5dd
authored
Sep 25, 2008
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 25, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added String.match implementation for non-regexp arguments.
parent
e0413ddf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
19 deletions
+30
-19
string.c
dlls/jscript/string.c
+25
-19
api.js
dlls/jscript/tests/api.js
+5
-0
No files found.
dlls/jscript/string.c
View file @
9307a5dd
...
...
@@ -354,6 +354,7 @@ static HRESULT String_match(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
{
StringInstance
*
This
=
(
StringInstance
*
)
dispex
;
match_result_t
*
match_result
;
DispatchEx
*
regexp
;
DispatchEx
*
array
;
VARIANT
var
,
*
arg_var
;
DWORD
match_cnt
,
i
;
...
...
@@ -361,32 +362,38 @@ static HRESULT String_match(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
TRACE
(
"
\n
"
);
if
(
dp
->
cArgs
-
dp
->
cNamedArgs
!=
1
)
{
if
(
arg_cnt
(
dp
)
!=
1
)
{
FIXME
(
"unsupported args
\n
"
);
return
E_NOTIMPL
;
}
arg_var
=
get_arg
(
dp
,
0
);
switch
(
V_VT
(
arg_var
))
{
case
VT_DISPATCH
:
{
DispatchEx
*
regexp
;
case
VT_DISPATCH
:
regexp
=
iface_to_jsdisp
((
IUnknown
*
)
V_DISPATCH
(
arg_var
));
if
(
regexp
)
{
if
(
regexp
->
builtin_info
->
class
==
JSCLASS_REGEXP
)
{
hres
=
regexp_match
(
regexp
,
This
->
str
,
This
->
length
,
FALSE
,
&
match_result
,
&
match_cnt
)
;
if
(
regexp
->
builtin_info
->
class
==
JSCLASS_REGEXP
)
break
;
jsdisp_release
(
regexp
);
}
default:
{
BSTR
match_str
;
hres
=
to_string
(
dispex
->
ctx
,
arg_var
,
ei
,
&
match_str
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
create_regexp_str
(
dispex
->
ctx
,
match_str
,
SysStringLen
(
match_str
),
NULL
,
0
,
&
regexp
);
SysFreeString
(
match_str
);
if
(
FAILED
(
hres
))
return
hres
;
break
;
}
jsdisp_release
(
regexp
);
}
}
default:
FIXME
(
"implemented only for regexp args
\n
"
);
return
E_NOTIMPL
;
}
hres
=
regexp_match
(
regexp
,
This
->
str
,
This
->
length
,
FALSE
,
&
match_result
,
&
match_cnt
);
jsdisp_release
(
regexp
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
!
match_cnt
)
{
TRACE
(
"no match
\n
"
);
...
...
@@ -415,14 +422,13 @@ static HRESULT String_match(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
break
;
}
if
(
FAILED
(
hres
))
{
jsdisp_release
(
array
);
return
hres
;
}
if
(
SUCCEEDED
(
hres
)
&&
retv
)
{
V_VT
(
retv
)
=
VT_DISPATCH
;
V_DISPATCH
(
retv
)
=
(
IDispatch
*
)
_IDispatchEx_
(
array
);
return
S_OK
;
}
else
{
jsdisp_release
(
array
);
}
return
hres
;
}
typedef
struct
{
...
...
dlls/jscript/tests/api.js
View file @
9307a5dd
...
...
@@ -151,6 +151,11 @@ arr.concat = String.prototype.concat;
tmp
=
arr
.
concat
(
"d"
);
ok
(
tmp
===
"2,ad"
,
"arr.concat = "
+
tmp
);
m
=
"a+bcabc"
.
match
(
"a+"
);
ok
(
typeof
(
m
)
===
"object"
,
"typeof m is not object"
);
ok
(
m
.
length
===
1
,
"m.length is not 1"
);
ok
(
m
[
"0"
]
===
"a"
,
"m[0] is not
\"
ab
\"
"
);
r
=
"- [test] -"
.
replace
(
"[test]"
,
"success"
);
ok
(
r
===
"- success -"
,
"r = "
+
r
+
" expected '- success -'"
);
...
...
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