Commit 0ee06df4 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

jscript: Change do_attributeless_tag_format so it works on non string objects.

parent 004eabfb
...@@ -127,26 +127,45 @@ static HRESULT do_attributeless_tag_format(DispatchEx *dispex, LCID lcid, WORD f ...@@ -127,26 +127,45 @@ static HRESULT do_attributeless_tag_format(DispatchEx *dispex, LCID lcid, WORD f
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp, const WCHAR *tagname) VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp, const WCHAR *tagname)
{ {
static const WCHAR tagfmt[] = {'<','%','s','>','%','s','<','/','%','s','>',0}; static const WCHAR tagfmt[] = {'<','%','s','>','%','s','<','/','%','s','>',0};
StringInstance *string; const WCHAR *str;
BSTR ret; DWORD length;
BSTR val_str = NULL;
HRESULT hres;
if(!is_class(dispex, JSCLASS_STRING)) { if(!is_class(dispex, JSCLASS_STRING)) {
WARN("this is not a string object\n"); VARIANT this;
return E_NOTIMPL;
V_VT(&this) = VT_DISPATCH;
V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
hres = to_string(dispex->ctx, &this, ei, &val_str);
if(FAILED(hres))
return hres;
str = val_str;
length = SysStringLen(val_str);
} }
else {
StringInstance *this = (StringInstance*)dispex;
string = (StringInstance*)dispex; str = this->str;
length = this->length;
}
if(retv) { if(retv) {
ret = SysAllocStringLen(NULL, string->length + 2*strlenW(tagname) + 5); BSTR ret = SysAllocStringLen(NULL, length + 2*strlenW(tagname) + 5);
if(!ret) if(!ret) {
SysFreeString(val_str);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
sprintfW(ret, tagfmt, tagname, string->str, tagname); sprintfW(ret, tagfmt, tagname, str, tagname);
V_VT(retv) = VT_BSTR; V_VT(retv) = VT_BSTR;
V_BSTR(retv) = ret; V_BSTR(retv) = ret;
} }
SysFreeString(val_str);
return S_OK; return S_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment