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
adb4e83e
Commit
adb4e83e
authored
Jul 18, 2010
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Fixed sort_cmp for non-string arguments.
parent
06b6e3bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
21 deletions
+44
-21
array.c
dlls/jscript/array.c
+23
-21
api.js
dlls/jscript/tests/api.js
+21
-0
No files found.
dlls/jscript/array.c
View file @
adb4e83e
...
...
@@ -677,29 +677,31 @@ static HRESULT sort_cmp(script_ctx_t *ctx, DispatchEx *cmp_func, VARIANT *v1, VA
*
cmp
=
V_I4
(
&
tmp
);
else
*
cmp
=
V_R8
(
&
tmp
)
>
0
.
0
?
1
:
-
1
;
}
else
if
(
is_num_vt
(
V_VT
(
v1
)))
{
if
(
is_num_vt
(
V_VT
(
v2
)))
{
DOUBLE
d
=
num_val
(
v1
)
-
num_val
(
v2
);
if
(
d
>
0
.
0
)
*
cmp
=
1
;
else
if
(
d
<
-
0
.
0
)
*
cmp
=
-
1
;
else
*
cmp
=
0
;
}
else
{
*
cmp
=
-
1
;
}
}
else
if
(
is_num_vt
(
V_VT
(
v2
)))
{
*
cmp
=
1
;
}
else
if
(
V_VT
(
v1
)
==
VT_BSTR
)
{
if
(
V_VT
(
v2
)
==
VT_BSTR
)
*
cmp
=
strcmpW
(
V_BSTR
(
v1
),
V_BSTR
(
v2
));
}
else
if
(
V_VT
(
v1
)
==
VT_EMPTY
)
{
*
cmp
=
V_VT
(
v2
)
==
VT_EMPTY
?
0
:
1
;
}
else
if
(
V_VT
(
v2
)
==
VT_EMPTY
)
{
*
cmp
=
-
1
;
}
else
if
(
is_num_vt
(
V_VT
(
v1
))
&&
is_num_vt
(
V_VT
(
v2
)))
{
DOUBLE
d
=
num_val
(
v1
)
-
num_val
(
v2
);
if
(
d
>
0
.
0
)
*
cmp
=
1
;
else
*
cmp
=
-
1
;
}
else
if
(
V_VT
(
v2
)
==
VT_BSTR
)
{
*
cmp
=
1
;
*
cmp
=
d
<
-
0
.
0
?
-
1
:
0
;
}
else
{
*
cmp
=
0
;
BSTR
x
,
y
;
hres
=
to_string
(
ctx
,
v1
,
ei
,
&
x
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
to_string
(
ctx
,
v2
,
ei
,
&
y
);
if
(
SUCCEEDED
(
hres
))
{
*
cmp
=
strcmpW
(
x
,
y
);
SysFreeString
(
y
);
}
SysFreeString
(
x
);
if
(
FAILED
(
hres
))
return
hres
;
}
return
S_OK
;
...
...
dlls/jscript/tests/api.js
View file @
adb4e83e
...
...
@@ -704,6 +704,27 @@ tmp = arr.sort();
ok
(
arr
===
tmp
,
"tmp !== arr"
);
ok
(
arr
[
0
]
===
1
&&
arr
[
1
]
===
"aa"
&&
arr
[
2
]
===
undefined
,
"arr is sorted incorectly"
);
tmp
=
[[
"bb"
,
"aa"
],[
"ab"
,
"aa"
]].
sort
().
toString
();
ok
(
tmp
===
"ab,aa,bb,aa"
,
"sort() = "
+
tmp
);
tmp
=
[[
"bb"
,
"aa"
],
"ab"
].
sort
().
toString
();
ok
(
tmp
===
"ab,bb,aa"
,
"sort() = "
+
tmp
);
tmp
=
[[
"bb"
,
"aa"
],
"cc"
].
sort
().
toString
();
ok
(
tmp
===
"bb,aa,cc"
,
"sort() = "
+
tmp
);
tmp
=
[
2
,
"1"
].
sort
().
toString
();
ok
(
tmp
===
"1,2"
,
"sort() = "
+
tmp
);
tmp
=
[
"2"
,
1
].
sort
().
toString
();
ok
(
tmp
===
"1,2"
,
"sort() = "
+
tmp
);
tmp
=
[,,
0
,
"z"
].
sort
().
toString
();
ok
(
tmp
===
"0,z,,"
,
"sort() = "
+
tmp
);
tmp
=
[
"a,b"
,[
"a"
,
"a"
],[
"a"
,
"c"
]].
sort
().
toString
();
ok
(
tmp
===
"a,a,a,b,a,c"
,
"sort() = "
+
tmp
);
arr
=
[
"1"
,
"2"
,
"3"
];
arr
.
length
=
1
;
ok
(
arr
.
length
===
1
,
"arr.length = "
+
arr
.
length
);
...
...
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