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
16ba7f44
Commit
16ba7f44
authored
May 25, 2018
by
Jacek Caban
Committed by
Alexandre Julliard
May 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added String.trim implementation.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
776618fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
string.c
dlls/jscript/string.c
+37
-0
documentmode.js
dlls/mshtml/tests/documentmode.js
+2
-0
es5.js
dlls/mshtml/tests/es5.js
+17
-0
No files found.
dlls/jscript/string.c
View file @
16ba7f44
...
...
@@ -63,6 +63,7 @@ static const WCHAR toLowerCaseW[] = {'t','o','L','o','w','e','r','C','a','s','e'
static
const
WCHAR
toUpperCaseW
[]
=
{
't'
,
'o'
,
'U'
,
'p'
,
'p'
,
'e'
,
'r'
,
'C'
,
'a'
,
's'
,
'e'
,
0
};
static
const
WCHAR
toLocaleLowerCaseW
[]
=
{
't'
,
'o'
,
'L'
,
'o'
,
'c'
,
'a'
,
'l'
,
'e'
,
'L'
,
'o'
,
'w'
,
'e'
,
'r'
,
'C'
,
'a'
,
's'
,
'e'
,
0
};
static
const
WCHAR
toLocaleUpperCaseW
[]
=
{
't'
,
'o'
,
'L'
,
'o'
,
'c'
,
'a'
,
'l'
,
'e'
,
'U'
,
'p'
,
'p'
,
'e'
,
'r'
,
'C'
,
'a'
,
's'
,
'e'
,
0
};
static
const
WCHAR
trimW
[]
=
{
't'
,
'r'
,
'i'
,
'm'
,
0
};
static
const
WCHAR
localeCompareW
[]
=
{
'l'
,
'o'
,
'c'
,
'a'
,
'l'
,
'e'
,
'C'
,
'o'
,
'm'
,
'p'
,
'a'
,
'r'
,
'e'
,
0
};
static
const
WCHAR
fromCharCodeW
[]
=
{
'f'
,
'r'
,
'o'
,
'm'
,
'C'
,
'h'
,
'a'
,
'r'
,
'C'
,
'o'
,
'd'
,
'e'
,
0
};
...
...
@@ -1465,6 +1466,41 @@ static HRESULT String_toLocaleUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD
return
E_NOTIMPL
;
}
static
HRESULT
String_trim
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
const
WCHAR
*
str
,
*
begin
,
*
end
;
jsstr_t
*
jsstr
;
unsigned
len
;
HRESULT
hres
;
hres
=
to_flat_string
(
ctx
,
jsval_disp
(
jsthis
->
u
.
disp
),
&
jsstr
,
&
str
);
if
(
FAILED
(
hres
))
{
WARN
(
"to_flat_string failed: %08x
\n
"
,
hres
);
return
hres
;
}
len
=
jsstr_length
(
jsstr
);
TRACE
(
"%s
\n
"
,
debugstr_wn
(
str
,
len
));
for
(
begin
=
str
,
end
=
str
+
len
;
begin
<
end
&&
isspaceW
(
*
begin
);
begin
++
);
while
(
end
>
begin
+
1
&&
isspaceW
(
*
(
end
-
1
)))
end
--
;
if
(
r
)
{
jsstr_t
*
ret
;
if
(
begin
==
str
&&
end
==
str
+
len
)
ret
=
jsstr_addref
(
jsstr
);
else
ret
=
jsstr_alloc_len
(
begin
,
end
-
begin
);
if
(
ret
)
*
r
=
jsval_string
(
ret
);
else
hres
=
E_OUTOFMEMORY
;
}
jsstr_release
(
jsstr
);
return
hres
;
}
static
HRESULT
String_localeCompare
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
...
...
@@ -1552,6 +1588,7 @@ static const builtin_prop_t String_props[] = {
{
toLowerCaseW
,
String_toLowerCase
,
PROPF_METHOD
},
{
toStringW
,
String_toString
,
PROPF_METHOD
},
{
toUpperCaseW
,
String_toUpperCase
,
PROPF_METHOD
},
{
trimW
,
String_trim
,
PROPF_ES5
|
PROPF_METHOD
},
{
valueOfW
,
String_valueOf
,
PROPF_METHOD
}
};
...
...
dlls/mshtml/tests/documentmode.js
View file @
16ba7f44
...
...
@@ -142,6 +142,8 @@ function test_javascript() {
test_exposed
(
"toISOString"
,
Date
.
prototype
,
v
>=
9
);
test_exposed
(
"isArray"
,
Array
,
v
>=
9
);
test_exposed
(
"indexOf"
,
Array
.
prototype
,
v
>=
9
);
test_exposed
(
"trim"
,
String
.
prototype
,
v
>=
9
);
/* FIXME: IE8 implements weird semi-functional property descriptors. */
if
(
v
!=
8
)
{
test_exposed
(
"getOwnPropertyDescriptor"
,
Object
,
v
>=
8
);
...
...
dlls/mshtml/tests/es5.js
View file @
16ba7f44
...
...
@@ -427,6 +427,22 @@ function test_defineProperty() {
next_test
();
}
function
test_string_trim
()
{
function
test_trim
(
value
,
expected
)
{
var
r
=
String
.
prototype
.
trim
.
call
(
value
);
ok
(
r
===
expected
,
"trim("
+
value
+
") = "
+
r
);
}
test_trim
(
"test"
,
"test"
);
test_trim
(
false
,
"false"
);
test_trim
(
"
\
n
\
t
\
rte st
\
t
\
t
\
n"
,
"te st"
);
test_trim
({
toString
:
function
()
{
return
" test "
;
}
},
"test"
);
test_trim
(
""
,
""
);
test_trim
(
"
\
t
\
n"
,
""
);
next_test
();
}
function
test_global_properties
()
{
var
o
;
...
...
@@ -452,5 +468,6 @@ var tests = [
test_identifier_keywords
,
test_getOwnPropertyDescriptor
,
test_defineProperty
,
test_string_trim
,
test_global_properties
];
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