Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
d0062198
Commit
d0062198
authored
Nov 30, 2009
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 01, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added lastIndex setter implementation.
parent
34fcbb5f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
5 deletions
+59
-5
regexp.c
dlls/jscript/regexp.c
+59
-5
No files found.
dlls/jscript/regexp.c
View file @
d0062198
...
...
@@ -32,6 +32,7 @@
*/
#include <assert.h>
#include <math.h>
#include "jscript.h"
...
...
@@ -82,7 +83,8 @@ typedef struct {
JSRegExp
*
jsregexp
;
BSTR
str
;
DWORD
last_index
;
INT
last_index
;
VARIANT
last_index_var
;
}
RegExpInstance
;
static
const
WCHAR
sourceW
[]
=
{
's'
,
'o'
,
'u'
,
'r'
,
'c'
,
'e'
,
0
};
...
...
@@ -3430,6 +3432,13 @@ HRESULT regexp_match(script_ctx_t *ctx, DispatchEx *dispex, const WCHAR *str, DW
return
S_OK
;
}
static
void
set_last_index
(
RegExpInstance
*
This
,
DWORD
last_index
)
{
This
->
last_index
=
last_index
;
VariantClear
(
&
This
->
last_index_var
);
num_set_val
(
&
This
->
last_index_var
,
last_index
);
}
static
HRESULT
RegExp_source
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
...
...
@@ -3474,6 +3483,27 @@ static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return
E_NOTIMPL
;
}
static
INT
index_from_var
(
script_ctx_t
*
ctx
,
VARIANT
*
v
)
{
jsexcept_t
ei
;
VARIANT
num
;
HRESULT
hres
;
memset
(
&
ei
,
0
,
sizeof
(
ei
));
hres
=
to_number
(
ctx
,
v
,
&
ei
,
&
num
);
if
(
FAILED
(
hres
))
{
/* FIXME: Move ignoring exceptions to to_promitive */
VariantClear
(
&
ei
.
var
);
return
0
;
}
if
(
V_VT
(
&
num
)
==
VT_R8
)
{
DOUBLE
d
=
floor
(
V_R8
(
&
num
));
return
(
DOUBLE
)(
INT
)
d
==
d
?
d
:
0
;
}
return
V_I4
(
&
num
);
}
static
HRESULT
RegExp_lastIndex
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
...
...
@@ -3482,8 +3512,21 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
switch
(
flags
)
{
case
DISPATCH_PROPERTYGET
:
{
RegExpInstance
*
regexp
=
regexp_from_vdisp
(
jsthis
);
V_VT
(
retv
)
=
VT_I4
;
V_I4
(
retv
)
=
regexp
->
last_index
;
V_VT
(
retv
)
=
VT_EMPTY
;
return
VariantCopy
(
retv
,
&
regexp
->
last_index_var
);
}
case
DISPATCH_PROPERTYPUT
:
{
RegExpInstance
*
regexp
=
regexp_from_vdisp
(
jsthis
);
VARIANT
*
arg
;
HRESULT
hres
;
arg
=
get_arg
(
dp
,
0
);
hres
=
VariantCopy
(
&
regexp
->
last_index_var
,
arg
);
if
(
FAILED
(
hres
))
return
hres
;
regexp
->
last_index
=
index_from_var
(
ctx
,
arg
);
break
;
}
default:
...
...
@@ -3589,6 +3632,13 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce
return
E_OUTOFMEMORY
;
}
if
(
regexp
->
last_index
<
0
)
{
SysFreeString
(
string
);
set_last_index
(
regexp
,
0
);
*
ret
=
VARIANT_FALSE
;
return
S_OK
;
}
length
=
SysStringLen
(
string
);
if
(
regexp
->
jsregexp
->
flags
&
JSREG_GLOB
)
last_index
=
regexp
->
last_index
;
...
...
@@ -3602,10 +3652,10 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce
}
if
(
hres
==
S_OK
)
{
regexp
->
last_index
=
cp
-
string
;
set_last_index
(
regexp
,
cp
-
string
)
;
*
ret
=
VARIANT_TRUE
;
}
else
{
regexp
->
last_index
=
0
;
set_last_index
(
regexp
,
0
)
;
*
ret
=
VARIANT_FALSE
;
}
...
...
@@ -3690,6 +3740,7 @@ static void RegExp_destructor(DispatchEx *dispex)
if
(
This
->
jsregexp
)
js_DestroyRegExp
(
This
->
jsregexp
);
VariantClear
(
&
This
->
last_index_var
);
SysFreeString
(
This
->
str
);
heap_free
(
This
);
}
...
...
@@ -3764,6 +3815,9 @@ HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags,
return
E_FAIL
;
}
V_VT
(
&
regexp
->
last_index_var
)
=
VT_I4
;
V_I4
(
&
regexp
->
last_index_var
)
=
0
;
*
ret
=
&
regexp
->
dispex
;
return
S_OK
;
}
...
...
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