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 <stdarg.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.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)
|
static HRESULT WINAPI textstream_ReadLine(ITextStream *iface, BSTR *text)
|
||||||
{
|
{
|
||||||
struct textstream *This = impl_from_ITextStream(iface);
|
struct textstream *This = impl_from_ITextStream(iface);
|
||||||
VARIANT_BOOL eos;
|
unsigned int skip = 0;
|
||||||
HRESULT hr;
|
const WCHAR *nl;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
FIXME("(%p)->(%p): stub\n", This, text);
|
TRACE("(%p)->(%p)\n", This, text);
|
||||||
|
|
||||||
if (!text)
|
if (!text)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
@ -511,15 +513,28 @@ static HRESULT WINAPI textstream_ReadLine(ITextStream *iface, BSTR *text)
|
||||||
if (textstream_check_iomode(This, IORead))
|
if (textstream_check_iomode(This, IORead))
|
||||||
return CTL_E_BADFILEMODE;
|
return CTL_E_BADFILEMODE;
|
||||||
|
|
||||||
/* check for EOF */
|
while (!(nl = wmemchr(This->read_buf, '\n', This->read_buf_size)) && !This->eof)
|
||||||
hr = ITextStream_get_AtEndOfStream(iface, &eos);
|
{
|
||||||
if (FAILED(hr))
|
if (FAILED(hr = read_more_data(This)))
|
||||||
return hr;
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
if (eos == VARIANT_TRUE)
|
if (This->eof && !This->read_buf_size)
|
||||||
return CTL_E_ENDOFFILE;
|
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)
|
static HRESULT WINAPI textstream_ReadAll(ITextStream *iface, BSTR *text)
|
||||||
|
|
|
@ -1732,10 +1732,8 @@ static void test_ReadAll(void)
|
||||||
|
|
||||||
str = NULL;
|
str = NULL;
|
||||||
hr = ITextStream_ReadLine(stream, &str);
|
hr = ITextStream_ReadLine(stream, &str);
|
||||||
todo_wine {
|
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
ok(str != NULL, "got %p\n", str);
|
ok(str != NULL, "got %p\n", str);
|
||||||
}
|
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
lstrcpyW(buffW, secondlineW);
|
lstrcpyW(buffW, secondlineW);
|
||||||
|
@ -1743,7 +1741,6 @@ todo_wine {
|
||||||
str = NULL;
|
str = NULL;
|
||||||
hr = ITextStream_ReadAll(stream, &str);
|
hr = ITextStream_ReadAll(stream, &str);
|
||||||
ok(hr == S_FALSE || broken(hr == S_OK) /* win2k */, "got 0x%08x\n", hr);
|
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));
|
ok(!lstrcmpW(buffW, str), "got %s\n", wine_dbgstr_w(str));
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
ITextStream_Release(stream);
|
ITextStream_Release(stream);
|
||||||
|
@ -1880,10 +1877,8 @@ static void test_Read(void)
|
||||||
|
|
||||||
str = NULL;
|
str = NULL;
|
||||||
hr = ITextStream_ReadLine(stream, &str);
|
hr = ITextStream_ReadLine(stream, &str);
|
||||||
todo_wine {
|
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
ok(str != NULL, "got %p\n", str);
|
ok(str != NULL, "got %p\n", str);
|
||||||
}
|
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
lstrcpyW(buffW, secondlineW);
|
lstrcpyW(buffW, secondlineW);
|
||||||
|
@ -1891,7 +1886,6 @@ todo_wine {
|
||||||
str = NULL;
|
str = NULL;
|
||||||
hr = ITextStream_Read(stream, 100, &str);
|
hr = ITextStream_Read(stream, 100, &str);
|
||||||
ok(hr == S_FALSE || broken(hr == S_OK) /* win2k */, "got 0x%08x\n", hr);
|
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));
|
ok(!lstrcmpW(buffW, str), "got %s\n", wine_dbgstr_w(str));
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
ITextStream_Release(stream);
|
ITextStream_Release(stream);
|
||||||
|
|
Loading…
Reference in New Issue