RtlUnicodeStringToInteger prototype (resending)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I sent this to wine-patches on the 25th, but it never appeared in the archive;
is that list moderated?
- Dan

Changelog:
* dlls/ntdll/{,tests/}rtlstr.c - fix prototype for RtlUnicodeToInteger
Dan Kegel

License: LGPL

Index: dlls/ntdll/rtlstr.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/rtlstr.c,v
retrieving revision 1.25
diff -u -r1.25 rtlstr.c
--- dlls/ntdll/rtlstr.c 12 Nov 2002 02:17:34 -0000 1.25
+++ dlls/ntdll/rtlstr.c 25 Dec 2002 18:52:54 -0000
@@ -843,17 +843,17 @@
*/
NTSTATUS WINAPI RtlUnicodeStringToInteger(
const UNICODE_STRING *str,
- int base,
- int * pdest)
+ ULONG base,
+ PULONG pdest)
{
LPWSTR lpwstr = str->Buffer;
WCHAR wchCurrent = 0;
int CharsParsed = 0;
- int RunningTotal = 0;
+ ULONG RunningTotal = 0;
char bMinus = 0;

/* no checking done on UNICODE_STRING and int* in native DLL either */
- TRACE("(%p, %d, %p)", str, base, pdest);
+ TRACE("(%p, %lu, %p)", str, base, pdest);

switch (base)
{
@@ -895,8 +895,7 @@
wchCurrent = '0' + 10 + wchCurrent - 'A';
if ((wchCurrent - '0') >= base || wchCurrent < '0')
{
- *pdest = bMinus ? -RunningTotal: RunningTotal;
- return STATUS_SUCCESS;
+ break;
}
/*
* increase significance of previous digits each time
@@ -905,6 +904,6 @@
RunningTotal = wchCurrent - '0' + RunningTotal * base;
}

- *pdest = bMinus ? -RunningTotal : RunningTotal;
+ *pdest = bMinus ? ((~RunningTotal)+1UL) : RunningTotal;
return STATUS_SUCCESS;
}
Index: dlls/ntdll/tests/rtlstr.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/tests/rtlstr.c,v
retrieving revision 1.2
diff -u -r1.2 rtlstr.c
--- dlls/ntdll/tests/rtlstr.c 19 Dec 2002 21:15:41 -0000 1.2
+++ dlls/ntdll/tests/rtlstr.c 25 Dec 2002 18:52:54 -0000
@@ -66,7 +66,7 @@
/* more function pointers here */

/*static DWORD (WINAPI *pRtlIsTextUnicode)(LPVOID, DWORD, DWORD *);*/
-static NTSTATUS (WINAPI *pRtlUnicodeStringToInteger)(const UNICODE_STRING *, int, int *);
+static NTSTATUS (WINAPI *pRtlUnicodeStringToInteger)(const UNICODE_STRING *, ULONG, PULONG);

static void InitFunctionPtrs()
{
@@ -123,7 +123,7 @@

static void test_RtlUnicodeStringToInteger(void)
{
- int dest = 0;
+ ULONG dest = 0;
int i;
DWORD result;

@@ -131,6 +131,7 @@
static const WCHAR stringwithint[][12] = {
{'1','0','1','1','1','0','1','1','0','0',0},
{'1','2','3','4','5','6','7',0},
+ {'-','2','1','4','7','4','8','3','6','4','7',0},
{'2','1','4','7','4','8','3','6','4','8',0},
{'-','2','1','4','7','4','8','3','6','4','8',0},
{'-','2','1','4',0},
@@ -141,11 +142,12 @@
{'0','x','1','2','3','4','5',0},
{'1','x','3','4',0}
};
- static const int expectedresults[] = {
+ static const ULONG expectedresults[] = {
1011101100,
1234567,
- 2147483648,
- 2147483648,
+ -2147483647,
+ 2147483648UL,
+ 2147483648UL, /* 2 ^ 31 === - (2 ^ 31) */
-214,
214,
214,
@@ -155,34 +157,37 @@
1
};
/* these are for stringwithint[0]: */
- static const int expectedresultsbase[] = {
+ static const ULONG expectedresultsbase[] = {
748, /* base 2 */
136610368, /* base 8 */
1011101100, /* base 10 */
286265600, /* base 16 */
};
-
- for (i = 0; i < sizeof(expectedresults) / sizeof(int); i++)
+
+ /* check assumption made in -0 test case */
+ ok((2147483648UL == ((~2147483648UL) + 1UL)), "LONG is not 32 bits?");
+
+ for (i = 0; i < sizeof(expectedresults) / sizeof(expectedresults[0]); i++)
{
dest = 0xdeadbeef;
pRtlInitUnicodeString(&uni, stringwithint[i]);
result = pRtlUnicodeStringToInteger(&uni, 0, &dest);
ok(result == 0, "call failed: RtlUnicodeStringToInteger(\"%S\", %d, [out])", uni.Buffer, 0);
- ok(dest == expectedresults[i], "didn't return expected value (test %d): expected: %d, got: %d}", i, expectedresults[i], dest);
+ ok(dest == expectedresults[i], "didn't return expected value (test %d): expected: %lu, got: %lu}", i, expectedresults[i], dest);
}
pRtlInitUnicodeString(&uni, stringwithint[0]);
result = pRtlUnicodeStringToInteger(&uni, 2, &dest);
ok(result == 0, "call failed: RtlUnicodeStringToInteger(\"%S\", %d, [out])", uni.Buffer, 2);
- ok(dest == expectedresultsbase[0], "didn't return expected value: \"%S\"; expected: %d, got: %d}", uni.Buffer, expectedresultsbase[0], dest);
+ ok(dest == expectedresultsbase[0], "didn't return expected value: \"%S\"; expected: %lu, got: %ld}", uni.Buffer, expectedresultsbase[0], dest);
result = pRtlUnicodeStringToInteger(&uni, 8, &dest);
ok(result == 0, "call failed: RtlUnicodeStringToInteger(\"%S\", %d, [out])", uni.Buffer, 8);
- ok(dest == expectedresultsbase[1], "didn't return expected value: \"%S\"; expected: %d, got: %d}", uni.Buffer, expectedresultsbase[1], dest);
+ ok(dest == expectedresultsbase[1], "didn't return expected value: \"%S\"; expected: %lu, got: %ld}", uni.Buffer, expectedresultsbase[1], dest);
result = pRtlUnicodeStringToInteger(&uni, 10, &dest);
ok(result == 0, "call failed: RtlUnicodeStringToInteger(\"%S\", %d, [out])", uni.Buffer, 10);
- ok(dest == expectedresultsbase[2], "didn't return expected value: \"%S\"; expected: %d, got: %d}", uni.Buffer, expectedresultsbase[2], dest);
+ ok(dest == expectedresultsbase[2], "didn't return expected value: \"%S\"; expected: %lu, got: %ld}", uni.Buffer, expectedresultsbase[2], dest);
result = pRtlUnicodeStringToInteger(&uni, 16, &dest);
ok(result == 0, "call failed: RtlUnicodeStringToInteger(\"%S\", %d, [out])", uni.Buffer, 16);
- ok(dest == expectedresultsbase[3], "didn't return expected value: \"%S\"; expected: %d, got: %d}", uni.Buffer, expectedresultsbase[3], dest);
+ ok(dest == expectedresultsbase[3], "didn't return expected value: \"%S\"; expected: %lu, got: %ld}", uni.Buffer, expectedresultsbase[3], dest);
}

START_TEST(rtlstr)





[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux