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
940b0258
Commit
940b0258
authored
Jan 31, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Factor out format_error_message implementation.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f6c5da47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
14 deletions
+38
-14
error.c
dlls/jscript/error.c
+38
-14
No files found.
dlls/jscript/error.c
View file @
940b0258
...
...
@@ -19,6 +19,7 @@
#include <math.h>
#include <assert.h>
#include <wchar.h>
#include "jscript.h"
#include "engine.h"
...
...
@@ -374,9 +375,42 @@ HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
return
S_OK
;
}
static
jsstr_t
*
format_error_message
(
HRESULT
error
,
const
WCHAR
*
arg
)
{
size_t
len
,
arg_len
=
0
;
const
WCHAR
*
res
,
*
pos
;
WCHAR
*
buf
,
*
p
;
jsstr_t
*
r
;
if
(
!
is_jscript_error
(
error
))
return
jsstr_empty
();
len
=
LoadStringW
(
jscript_hinstance
,
HRESULT_CODE
(
error
),
(
WCHAR
*
)
&
res
,
0
);
pos
=
wmemchr
(
res
,
'|'
,
len
);
if
(
pos
&&
arg
)
arg_len
=
lstrlenW
(
arg
);
r
=
jsstr_alloc_buf
(
len
+
arg_len
-
(
pos
?
1
:
0
),
&
buf
);
if
(
!
r
)
return
jsstr_empty
();
p
=
buf
;
if
(
pos
>
res
)
{
memcpy
(
p
,
res
,
(
pos
-
res
)
*
sizeof
(
WCHAR
));
p
+=
pos
-
res
;
}
pos
=
pos
?
pos
+
1
:
res
;
if
(
arg_len
)
{
memcpy
(
p
,
arg
,
arg_len
*
sizeof
(
WCHAR
));
p
+=
arg_len
;
}
if
(
pos
!=
res
+
len
)
memcpy
(
p
,
pos
,
(
res
+
len
-
pos
)
*
sizeof
(
WCHAR
));
return
r
;
}
static
HRESULT
throw_error
(
script_ctx_t
*
ctx
,
HRESULT
error
,
const
WCHAR
*
str
,
jsdisp_t
*
constr
)
{
WCHAR
buf
[
1024
],
*
pos
=
NULL
;
jsdisp_t
*
err
;
jsstr_t
*
msg
;
HRESULT
hres
;
...
...
@@ -384,22 +418,12 @@ static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, j
if
(
!
is_jscript_error
(
error
))
return
error
;
buf
[
0
]
=
'\0'
;
LoadStringW
(
jscript_hinstance
,
HRESULT_CODE
(
error
),
buf
,
ARRAY_SIZE
(
buf
));
if
(
str
)
pos
=
wcschr
(
buf
,
'|'
);
if
(
pos
)
{
int
len
=
lstrlenW
(
str
);
memmove
(
pos
+
len
,
pos
+
1
,
(
lstrlenW
(
pos
+
1
)
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
pos
,
str
,
len
*
sizeof
(
WCHAR
));
}
WARN
(
"%s
\n
"
,
debugstr_w
(
buf
));
msg
=
jsstr_alloc
(
buf
);
msg
=
format_error_message
(
error
,
str
);
if
(
!
msg
)
return
E_OUTOFMEMORY
;
WARN
(
"%s
\n
"
,
debugstr_jsstr
(
msg
));
hres
=
create_error
(
ctx
,
constr
,
error
,
msg
,
&
err
);
jsstr_release
(
msg
);
if
(
FAILED
(
hres
))
...
...
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