Implemented RtlUnicodeStringToInteger (bugs removed)

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

 



Hi,

Sorry about sending the last patch 3 times. Hopefully, I'll do better with
this one.
Alexandre: please don't apply the last patch - this one is fully tested and
bug free(!)
I have also found out what the previously unknown middle parameter was and
now handle it correctly. Test patch to follow

Changelog
- implemented RtlUnicodeStringToInteger
? wine/dlls/ntdll/tests/rtlstr.c
Index: wine/dlls/ntdll/ntdll.spec
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/ntdll.spec,v
retrieving revision 1.79
diff -u -r1.79 ntdll.spec
--- wine/dlls/ntdll/ntdll.spec	10 Oct 2002 17:55:48 -0000	1.79
+++ wine/dlls/ntdll/ntdll.spec	5 Nov 2002 21:49:11 -0000
@@ -528,7 +528,7 @@
 @ stdcall RtlUnicodeStringToAnsiSize(ptr) RtlUnicodeStringToAnsiSize
 @ stdcall RtlUnicodeStringToAnsiString(ptr ptr long) RtlUnicodeStringToAnsiString
 @ stub RtlUnicodeStringToCountedOemString
-@ stub RtlUnicodeStringToInteger
+@ stdcall RtlUnicodeStringToInteger(ptr long ptr) RtlUnicodeStringToInteger
 @ stdcall RtlUnicodeStringToOemSize(ptr) RtlUnicodeStringToOemSize
 @ stdcall RtlUnicodeStringToOemString(ptr ptr long) RtlUnicodeStringToOemString
 @ stub RtlUnicodeToCustomCPN
Index: wine/dlls/ntdll/rtlstr.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/rtlstr.c,v
retrieving revision 1.24
diff -u -r1.24 rtlstr.c
--- wine/dlls/ntdll/rtlstr.c	12 Sep 2002 22:07:03 -0000	1.24
+++ wine/dlls/ntdll/rtlstr.c	5 Nov 2002 21:49:12 -0000
@@ -835,3 +835,74 @@
 		*pf = out_flags;
 	return len;
 }
+
+/**************************************************************************
+ *	RtlUnicodeStringToInteger (NTDLL.@)
+ *
+ *	Convert a text buffer into its integer form
+ */
+NTSTATUS WINAPI RtlUnicodeStringToInteger(
+	const UNICODE_STRING *str,
+	int base,
+	int * pdest)
+{
+	LPWSTR lpwstr = str->Buffer;
+	WCHAR wchCurrent = 0;
+	int CharsParsed = 0;
+	int RunningTotal = 0;
+	char bMinus = 0;
+
+	// no checking done on UNICODE_STRING and int* in native DLL either
+	TRACE("(%p, %d, %p)", str, base, pdest);
+
+	switch (base)
+	{
+		case 0:
+			base = 10;
+			break;
+		case 2:
+		case 8:
+		case 10:
+		case 16:
+			break;
+		default:
+			return STATUS_INVALID_PARAMETER;
+	}
+
+	if ((str->Length) >= 4 && (base == 10) && (*lpwstr == '0') && (*(lpwstr+1) == 'x'))
+	{
+		lpwstr+=2;
+		base = 16;
+	}
+
+	*pdest = 0;
+	for (; (CharsParsed*2 < str->Length) && (*lpwstr <= ' '); lpwstr++)
+		CharsParsed++;
+
+	if (*lpwstr == '+')
+		lpwstr++;
+	else if (*lpwstr == '-')
+	{
+		bMinus = 1;
+		lpwstr++;
+	}
+
+	for (; (CharsParsed*2 < str->Length) && (*lpwstr != '\0'); lpwstr++)
+	{
+		CharsParsed++;
+		wchCurrent = *lpwstr;
+		if (wchCurrent >= 'A')
+			wchCurrent = '0' + 10 + wchCurrent - 'A';
+		if ((wchCurrent - '0') >= base || wchCurrent < '0')
+		{
+			*pdest = bMinus ? -RunningTotal: RunningTotal;
+			return STATUS_SUCCESS;
+		}
+		// increase significance of previous digits each time
+		// we find another valid one and add on this valid one
+		RunningTotal = wchCurrent - '0' + RunningTotal * base;
+	}
+
+	*pdest = bMinus ? -RunningTotal : RunningTotal;
+	return STATUS_SUCCESS;
+}

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

  Powered by Linux