msxml3: IXMLDOMText_get_text return trimmed text when XML_TEXT_NODE
Alexandre Julliard
julliard at winehq.org
Thu Sep 2 05:10:26 CDT 2010
Alexandre Goujon <ale.goujon at gmail.com> writes:
> @@ -181,6 +181,30 @@ static inline BSTR bstr_from_xmlChar(const xmlChar *str)
> return ret;
> }
>
> +static inline BSTR bstr_trim(const BSTR str)
> +{
> + UINT i, j, len = SysStringLen(str);
> + BSTR new_str = NULL;
> +
> + /* str empty or NULL */
> + if(!len)
> + goto err;
> +
> + for(i=0; isspaceW(str[i]) && i<len; i++);
> + for(j=len-1; isspaceW(str[j]) && j>=i; j--);
> +
> + new_str = SysAllocStringLen(str+i, j-i+1);
> + if(!new_str)
> + goto err;
> +
> + SysFreeString(str);
> + return new_str;
> +
> + err:
> + SysFreeString(str);
> + return SysAllocStringLen(NULL, 0);
> +}
That's ugly and inefficient, especially since the common case is to not
modify it.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list