Changeset 9684 for trunk/src/NTDLL/rtlstr.c
- Timestamp:
- Jan 16, 2003, 4:22:42 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/NTDLL/rtlstr.c
r8690 r9684 36 36 #define RtlAllocateHeap HeapAlloc 37 37 #define RtlFreeHeap HeapFree 38 #ifdef __EMX__ 39 #define min(a,b) (((a) < (b)) ? (a) : (b)) 40 #define max(a,b) (((a) > (b)) ? (a) : (b)) 38 41 #endif 42 #endif 43 39 44 40 45 UINT NlsAnsiCodePage = 1252; … … 841 846 return len; 842 847 } 848 849 /************************************************************************** 850 * RtlUnicodeStringToInteger (NTDLL.@) 851 * 852 * Convert a text buffer into its integer form 853 */ 854 NTSTATUS WINAPI RtlUnicodeStringToInteger( 855 const UNICODE_STRING *str, 856 int base, 857 int * pdest) 858 { 859 LPWSTR lpwstr = str->Buffer; 860 WCHAR wchCurrent = 0; 861 int CharsParsed = 0; 862 int RunningTotal = 0; 863 char bMinus = 0; 864 865 /* no checking done on UNICODE_STRING and int* in native DLL either */ 866 TRACE("(%p, %d, %p)", str, base, pdest); 867 868 switch (base) 869 { 870 case 0: 871 base = 10; 872 break; 873 case 2: 874 case 8: 875 case 10: 876 case 16: 877 break; 878 default: 879 return STATUS_INVALID_PARAMETER; 880 } 881 882 if ((str->Length) >= 4 && (base == 10) && (*lpwstr == '0') && (*(lpwstr+1) == 'x')) 883 { 884 lpwstr+=2; 885 base = 16; 886 } 887 888 *pdest = 0; 889 for (; (CharsParsed*sizeof(WCHAR) < str->Length) && (*lpwstr <= ' '); lpwstr++) 890 CharsParsed++; 891 892 if (*lpwstr == '+') 893 lpwstr++; 894 else if (*lpwstr == '-') 895 { 896 bMinus = 1; 897 lpwstr++; 898 } 899 900 for (; (CharsParsed*sizeof(WCHAR) < str->Length) && (*lpwstr != '\0'); lpwstr++) 901 { 902 CharsParsed++; 903 wchCurrent = *lpwstr; 904 if (wchCurrent >= 'A') 905 wchCurrent = '0' + 10 + wchCurrent - 'A'; 906 if ((wchCurrent - '0') >= base || wchCurrent < '0') 907 { 908 *pdest = bMinus ? -RunningTotal: RunningTotal; 909 return STATUS_SUCCESS; 910 } 911 /* 912 * increase significance of previous digits each time 913 * we find another valid one and add on this valid one 914 */ 915 RunningTotal = wchCurrent - '0' + RunningTotal * base; 916 } 917 918 *pdest = bMinus ? -RunningTotal : RunningTotal; 919 return STATUS_SUCCESS; 920 }
Note:
See TracChangeset
for help on using the changeset viewer.