- Sync inetcomm, inseng, jscript to Wine-1.1.43.

svn path=/trunk/; revision=46956
This commit is contained in:
Aleksey Bragin 2010-04-20 16:42:47 +00:00
parent 0cb69766f3
commit 79c442dc8f
6 changed files with 145 additions and 101 deletions

View file

@ -268,7 +268,7 @@ static HRESULT WINAPI MimeInternat_FindCharset(IMimeInternational *iface, LPCSTR
if(SUCCEEDED(hr)) if(SUCCEEDED(hr))
*phCharset = add_charset(&This->charsets, &mlang_info, *phCharset = add_charset(&This->charsets, &mlang_info,
(HCHARSET)InterlockedIncrement(&This->next_charset_handle)); UlongToHandle(InterlockedIncrement(&This->next_charset_handle)));
} }
LeaveCriticalSection(&This->cs); LeaveCriticalSection(&This->cs);

View file

@ -1419,7 +1419,7 @@ static HRESULT create_sub_stream(IStream *stream, ULARGE_INTEGER start, ULARGE_I
typedef struct body_t typedef struct body_t
{ {
struct list entry; struct list entry;
HBODY hbody; DWORD index;
IMimeBody *mime_body; IMimeBody *mime_body;
struct body_t *parent; struct body_t *parent;
@ -1434,7 +1434,7 @@ typedef struct MimeMessage
IStream *stream; IStream *stream;
struct list body_tree; struct list body_tree;
HBODY next_hbody; DWORD next_index;
} MimeMessage; } MimeMessage;
static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID riid, void **ppv) static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID riid, void **ppv)
@ -1512,13 +1512,13 @@ static HRESULT WINAPI MimeMessage_IsDirty(
return E_NOTIMPL; return E_NOTIMPL;
} }
static body_t *new_body_entry(IMimeBody *mime_body, HBODY hbody, body_t *parent) static body_t *new_body_entry(IMimeBody *mime_body, DWORD index, body_t *parent)
{ {
body_t *body = HeapAlloc(GetProcessHeap(), 0, sizeof(*body)); body_t *body = HeapAlloc(GetProcessHeap(), 0, sizeof(*body));
if(body) if(body)
{ {
body->mime_body = mime_body; body->mime_body = mime_body;
body->hbody = hbody; body->index = index;
list_init(&body->children); list_init(&body->children);
body->parent = parent; body->parent = parent;
} }
@ -1630,8 +1630,7 @@ static body_t *create_sub_body(MimeMessage *msg, IStream *pStm, BODYOFFSETS *off
offset->cbBodyStart = cur.u.LowPart + offset->cbHeaderStart; offset->cbBodyStart = cur.u.LowPart + offset->cbHeaderStart;
if(parent) MimeBody_set_offsets(impl_from_IMimeBody(mime_body), offset); if(parent) MimeBody_set_offsets(impl_from_IMimeBody(mime_body), offset);
IMimeBody_SetData(mime_body, IET_BINARY, NULL, NULL, &IID_IStream, pStm); IMimeBody_SetData(mime_body, IET_BINARY, NULL, NULL, &IID_IStream, pStm);
body = new_body_entry(mime_body, msg->next_hbody, parent); body = new_body_entry(mime_body, msg->next_index++, parent);
msg->next_hbody = (HBODY)((DWORD)msg->next_hbody + 1);
if(IMimeBody_IsContentType(mime_body, "multipart", NULL) == S_OK) if(IMimeBody_IsContentType(mime_body, "multipart", NULL) == S_OK)
{ {
@ -1812,7 +1811,7 @@ static HRESULT find_body(struct list *list, HBODY hbody, body_t **body)
LIST_FOR_EACH_ENTRY(cur, list, body_t, entry) LIST_FOR_EACH_ENTRY(cur, list, body_t, entry)
{ {
if(cur->hbody == hbody) if(cur->index == HandleToUlong(hbody))
{ {
*body = cur; *body = cur;
return S_OK; return S_OK;
@ -1948,7 +1947,7 @@ static HRESULT WINAPI MimeMessage_GetBody(
hr = get_body(This, location, hPivot, &body); hr = get_body(This, location, hPivot, &body);
if(hr == S_OK) *phBody = body->hbody; if(hr == S_OK) *phBody = UlongToHandle(body->index);
return hr; return hr;
} }
@ -2003,38 +2002,35 @@ static HRESULT WINAPI MimeMessage_CountBodies(
return S_OK; return S_OK;
} }
static HRESULT find_next(IMimeMessage *msg, LPFINDBODY find_body, HBODY *out) static HRESULT find_next(IMimeMessage *msg, body_t *body, LPFINDBODY find, HBODY *out)
{ {
HRESULT hr; MimeMessage *This = (MimeMessage *)msg;
IMimeBody *mime_body; struct list *ptr;
HBODY next; HBODY next;
if(find_body->dwReserved == 0) for (;;)
find_body->dwReserved = (DWORD)HBODY_ROOT;
else
{ {
hr = IMimeMessage_GetBody(msg, IBL_FIRST, (HBODY)find_body->dwReserved, &next); if (!body) ptr = list_head( &This->body_tree );
if(hr == S_OK)
find_body->dwReserved = (DWORD)next;
else else
{ {
hr = IMimeMessage_GetBody(msg, IBL_NEXT, (HBODY)find_body->dwReserved, &next); ptr = list_head( &body->children );
if(hr == S_OK) while (!ptr)
find_body->dwReserved = (DWORD)next; {
else if (!body->parent) return MIME_E_NOT_FOUND;
return MIME_E_NOT_FOUND; if (!(ptr = list_next( &body->parent->children, &body->entry ))) body = body->parent;
}
}
body = LIST_ENTRY( ptr, body_t, entry );
next = UlongToHandle( body->index );
find->dwReserved = body->index;
if (IMimeBody_IsContentType(body->mime_body, find->pszPriType, find->pszSubType) == S_OK)
{
*out = next;
return S_OK;
} }
} }
return MIME_E_NOT_FOUND;
hr = IMimeMessage_BindToObject(msg, (HBODY)find_body->dwReserved, &IID_IMimeBody, (void**)&mime_body);
if(IMimeBody_IsContentType(mime_body, find_body->pszPriType, find_body->pszSubType) == S_OK)
{
IMimeBody_Release(mime_body);
*out = (HBODY)find_body->dwReserved;
return S_OK;
}
IMimeBody_Release(mime_body);
return find_next(msg, find_body, out);
} }
static HRESULT WINAPI MimeMessage_FindFirst( static HRESULT WINAPI MimeMessage_FindFirst(
@ -2045,7 +2041,7 @@ static HRESULT WINAPI MimeMessage_FindFirst(
TRACE("(%p)->(%p, %p)\n", iface, pFindBody, phBody); TRACE("(%p)->(%p, %p)\n", iface, pFindBody, phBody);
pFindBody->dwReserved = 0; pFindBody->dwReserved = 0;
return find_next(iface, pFindBody, phBody); return find_next( iface, NULL, pFindBody, phBody );
} }
static HRESULT WINAPI MimeMessage_FindNext( static HRESULT WINAPI MimeMessage_FindNext(
@ -2053,9 +2049,15 @@ static HRESULT WINAPI MimeMessage_FindNext(
LPFINDBODY pFindBody, LPFINDBODY pFindBody,
LPHBODY phBody) LPHBODY phBody)
{ {
MimeMessage *This = (MimeMessage *)iface;
body_t *body;
HRESULT hr;
TRACE("(%p)->(%p, %p)\n", iface, pFindBody, phBody); TRACE("(%p)->(%p, %p)\n", iface, pFindBody, phBody);
return find_next(iface, pFindBody, phBody); hr = find_body( &This->body_tree, UlongToHandle( pFindBody->dwReserved ), &body );
if (hr != S_OK) return MIME_E_NOT_FOUND;
return find_next( iface, body, pFindBody, phBody );
} }
static HRESULT WINAPI MimeMessage_ResolveURL( static HRESULT WINAPI MimeMessage_ResolveURL(
@ -2562,7 +2564,7 @@ HRESULT MimeMessage_create(IUnknown *outer, void **obj)
This->refs = 1; This->refs = 1;
This->stream = NULL; This->stream = NULL;
list_init(&This->body_tree); list_init(&This->body_tree);
This->next_hbody = (HBODY)1; This->next_index = 1;
*obj = &This->lpVtbl; *obj = &This->lpVtbl;
return S_OK; return S_OK;

View file

@ -61,7 +61,6 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
HRESULT WINAPI DllCanUnloadNow(void) HRESULT WINAPI DllCanUnloadNow(void)
{ {
FIXME("\n");
return S_FALSE; return S_FALSE;
} }

View file

@ -324,6 +324,7 @@ HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,DWORD,const WCHAR*,DWORD,con
DWORD*,DWORD*,match_result_t*); DWORD*,DWORD*,match_result_t*);
HRESULT regexp_match(script_ctx_t*,DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*); HRESULT regexp_match(script_ctx_t*,DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*);
HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*); HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*);
HRESULT regexp_string_match(script_ctx_t*,DispatchEx*,BSTR,VARIANT*,jsexcept_t*);
static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i) static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i)
{ {

View file

@ -2384,7 +2384,7 @@ SimpleMatch(REGlobalData *gData, REMatchState *x, REOp op,
RECharSet *charSet; RECharSet *charSet;
const char *opname = reop_names[op]; const char *opname = reop_names[op];
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program, TRACE("\n%06d: %*s%s\n", (int)(pc - gData->regexp->program),
(int)gData->stateStackTop * 2, "", opname); (int)gData->stateStackTop * 2, "", opname);
switch (op) { switch (op) {
@ -2623,7 +2623,7 @@ ExecuteREBytecode(REGlobalData *gData, REMatchState *x)
for (;;) { for (;;) {
const char *opname = reop_names[op]; const char *opname = reop_names[op];
TRACE("\n%06d: %*s%s\n", pc - gData->regexp->program, TRACE("\n%06d: %*s%s\n", (int)(pc - gData->regexp->program),
(int)gData->stateStackTop * 2, "", opname); (int)gData->stateStackTop * 2, "", opname);
if (REOP_IS_SIMPLE(op)) { if (REOP_IS_SIMPLE(op)) {
@ -3637,25 +3637,25 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce
hres = to_string(ctx, arg, ei, &string); hres = to_string(ctx, arg, ei, &string);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
length = SysStringLen(string);
}else { }else {
string = SysAllocStringLen(NULL, 0); string = NULL;
if(!string) length = 0;
return E_OUTOFMEMORY;
} }
if(regexp->last_index < 0) { if(regexp->jsregexp->flags & JSREG_GLOB) {
SysFreeString(string); if(regexp->last_index < 0) {
set_last_index(regexp, 0); SysFreeString(string);
*ret = VARIANT_FALSE; set_last_index(regexp, 0);
if(input) { *ret = VARIANT_FALSE;
*input = NULL; if(input) {
*input = NULL;
}
return S_OK;
} }
return S_OK;
}
length = SysStringLen(string);
if(regexp->jsregexp->flags & JSREG_GLOB)
last_index = regexp->last_index; last_index = regexp->last_index;
}
cp = string + last_index; cp = string + last_index;
hres = regexp_match_next(ctx, &regexp->dispex, REM_RESET_INDEX, string, length, &cp, parens, hres = regexp_match_next(ctx, &regexp->dispex, REM_RESET_INDEX, string, length, &cp, parens,
@ -3878,6 +3878,87 @@ HRESULT create_regexp_var(script_ctx_t *ctx, VARIANT *src_arg, VARIANT *flags_ar
return create_regexp(ctx, src, -1, flags, ret); return create_regexp(ctx, src, -1, flags, ret);
} }
HRESULT regexp_string_match(script_ctx_t *ctx, DispatchEx *re, BSTR str,
VARIANT *retv, jsexcept_t *ei)
{
RegExpInstance *regexp = (RegExpInstance*)re;
match_result_t *match_result;
DWORD match_cnt, i, length;
DispatchEx *array;
VARIANT var;
HRESULT hres;
length = SysStringLen(str);
if(!(regexp->jsregexp->flags & JSREG_GLOB)) {
match_result_t match, *parens = NULL;
DWORD parens_cnt, parens_size = 0;
const WCHAR *cp = str;
hres = regexp_match_next(ctx, &regexp->dispex, 0, str, length, &cp, &parens, &parens_size, &parens_cnt, &match);
if(FAILED(hres))
return hres;
if(retv) {
if(hres == S_OK) {
IDispatch *ret;
hres = create_match_array(ctx, str, &match, parens, parens_cnt, ei, &ret);
if(SUCCEEDED(hres)) {
V_VT(retv) = VT_DISPATCH;
V_DISPATCH(retv) = ret;
}
}else {
V_VT(retv) = VT_NULL;
}
}
heap_free(parens);
return S_OK;
}
hres = regexp_match(ctx, &regexp->dispex, str, length, FALSE, &match_result, &match_cnt);
if(FAILED(hres))
return hres;
if(!match_cnt) {
TRACE("no match\n");
if(retv)
V_VT(retv) = VT_NULL;
return S_OK;
}
hres = create_array(ctx, match_cnt, &array);
if(FAILED(hres))
return hres;
V_VT(&var) = VT_BSTR;
for(i=0; i < match_cnt; i++) {
V_BSTR(&var) = SysAllocStringLen(match_result[i].str, match_result[i].len);
if(!V_BSTR(&var)) {
hres = E_OUTOFMEMORY;
break;
}
hres = jsdisp_propput_idx(array, i, &var, ei, NULL/*FIXME*/);
SysFreeString(V_BSTR(&var));
if(FAILED(hres))
break;
}
heap_free(match_result);
if(SUCCEEDED(hres) && retv) {
V_VT(retv) = VT_DISPATCH;
V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(array);
}else {
jsdisp_release(array);
}
return hres;
}
static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{ {

View file

@ -622,11 +622,9 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{ {
const WCHAR *str; const WCHAR *str;
match_result_t *match_result;
DispatchEx *regexp; DispatchEx *regexp;
DispatchEx *array; VARIANT *arg_var;
VARIANT var, *arg_var; DWORD length;
DWORD length, match_cnt, i;
BSTR val_str = NULL; BSTR val_str = NULL;
HRESULT hres = S_OK; HRESULT hres = S_OK;
@ -645,7 +643,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
case VT_DISPATCH: case VT_DISPATCH:
regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg_var)); regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg_var));
if(regexp) { if(regexp) {
if(regexp->builtin_info->class == JSCLASS_REGEXP) if(is_class(regexp, JSCLASS_REGEXP))
break; break;
jsdisp_release(regexp); jsdisp_release(regexp);
} }
@ -664,54 +662,17 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres)) {
hres = regexp_match(ctx, regexp, str, length, FALSE, &match_result, &match_cnt); if(!val_str)
jsdisp_release(regexp); val_str = SysAllocStringLen(str, length);
if(FAILED(hres)) { if(val_str)
SysFreeString(val_str); hres = regexp_string_match(ctx, regexp, val_str, retv, ei);
return hres; else
}
if(!match_cnt) {
TRACE("no match\n");
if(retv)
V_VT(retv) = VT_NULL;
SysFreeString(val_str);
return S_OK;
}
hres = create_array(ctx, match_cnt, &array);
if(FAILED(hres)) {
SysFreeString(val_str);
return hres;
}
V_VT(&var) = VT_BSTR;
for(i=0; i < match_cnt; i++) {
V_BSTR(&var) = SysAllocStringLen(match_result[i].str, match_result[i].len);
if(!V_BSTR(&var)) {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
break;
}
hres = jsdisp_propput_idx(array, i, &var, ei, NULL/*FIXME*/);
SysFreeString(V_BSTR(&var));
if(FAILED(hres))
break;
} }
heap_free(match_result); jsdisp_release(regexp);
SysFreeString(val_str); SysFreeString(val_str);
if(SUCCEEDED(hres) && retv) {
V_VT(retv) = VT_DISPATCH;
V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(array);
}else {
jsdisp_release(array);
}
return hres; return hres;
} }