scrrun: Add ITextStream::ReadLine implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c80e16ae19
commit
14de44513f
|
@ -21,6 +21,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -499,10 +500,11 @@ static HRESULT WINAPI textstream_Read(ITextStream *iface, LONG len, BSTR *text)
|
|||
static HRESULT WINAPI textstream_ReadLine(ITextStream *iface, BSTR *text)
|
||||
{
|
||||
struct textstream *This = impl_from_ITextStream(iface);
|
||||
VARIANT_BOOL eos;
|
||||
HRESULT hr;
|
||||
unsigned int skip = 0;
|
||||
const WCHAR *nl;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
FIXME("(%p)->(%p): stub\n", This, text);
|
||||
TRACE("(%p)->(%p)\n", This, text);
|
||||
|
||||
if (!text)
|
||||
return E_POINTER;
|
||||
|
@ -511,15 +513,28 @@ static HRESULT WINAPI textstream_ReadLine(ITextStream *iface, BSTR *text)
|
|||
if (textstream_check_iomode(This, IORead))
|
||||
return CTL_E_BADFILEMODE;
|
||||
|
||||
/* check for EOF */
|
||||
hr = ITextStream_get_AtEndOfStream(iface, &eos);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
while (!(nl = wmemchr(This->read_buf, '\n', This->read_buf_size)) && !This->eof)
|
||||
{
|
||||
if (FAILED(hr = read_more_data(This)))
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (eos == VARIANT_TRUE)
|
||||
if (This->eof && !This->read_buf_size)
|
||||
return CTL_E_ENDOFFILE;
|
||||
|
||||
return E_NOTIMPL;
|
||||
if (!nl)
|
||||
{
|
||||
nl = This->read_buf + This->read_buf_size;
|
||||
hr = S_FALSE;
|
||||
}
|
||||
else if (nl > This->read_buf && nl[-1] == '\r')
|
||||
{
|
||||
nl--;
|
||||
skip = 2;
|
||||
}
|
||||
else skip = 1;
|
||||
|
||||
return read_from_buffer(This, nl - This->read_buf, text, skip) ? hr : E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI textstream_ReadAll(ITextStream *iface, BSTR *text)
|
||||
|
|
|
@ -1732,10 +1732,8 @@ static void test_ReadAll(void)
|
|||
|
||||
str = NULL;
|
||||
hr = ITextStream_ReadLine(stream, &str);
|
||||
todo_wine {
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(str != NULL, "got %p\n", str);
|
||||
}
|
||||
SysFreeString(str);
|
||||
|
||||
lstrcpyW(buffW, secondlineW);
|
||||
|
@ -1743,7 +1741,6 @@ todo_wine {
|
|||
str = NULL;
|
||||
hr = ITextStream_ReadAll(stream, &str);
|
||||
ok(hr == S_FALSE || broken(hr == S_OK) /* win2k */, "got 0x%08x\n", hr);
|
||||
todo_wine
|
||||
ok(!lstrcmpW(buffW, str), "got %s\n", wine_dbgstr_w(str));
|
||||
SysFreeString(str);
|
||||
ITextStream_Release(stream);
|
||||
|
@ -1880,10 +1877,8 @@ static void test_Read(void)
|
|||
|
||||
str = NULL;
|
||||
hr = ITextStream_ReadLine(stream, &str);
|
||||
todo_wine {
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(str != NULL, "got %p\n", str);
|
||||
}
|
||||
SysFreeString(str);
|
||||
|
||||
lstrcpyW(buffW, secondlineW);
|
||||
|
@ -1891,7 +1886,6 @@ todo_wine {
|
|||
str = NULL;
|
||||
hr = ITextStream_Read(stream, 100, &str);
|
||||
ok(hr == S_FALSE || broken(hr == S_OK) /* win2k */, "got 0x%08x\n", hr);
|
||||
todo_wine
|
||||
ok(!lstrcmpW(buffW, str), "got %s\n", wine_dbgstr_w(str));
|
||||
SysFreeString(str);
|
||||
ITextStream_Release(stream);
|
||||
|
|
Loading…
Reference in New Issue