[ros-diffs] [fireball] 30283: - Sync some changes in strings from libcntpr. - Move string implementation (in "header" files) into /string dir. - Copy over libcntpr-specific implementations into _nt.c files (for now, later they could do with a define). - libcntpr's is now almost fully syncronized and could be merged into the tree except for "except" directory.

fireball at svn.reactos.org fireball at svn.reactos.org
Thu Nov 8 22:06:21 CET 2007


Author: fireball
Date: Fri Nov  9 00:06:20 2007
New Revision: 30283

URL: http://svn.reactos.org/svn/reactos?rev=30283&view=rev
Log:
- Sync some changes in strings from libcntpr.
- Move string implementation (in "header" files) into /string dir.
- Copy over libcntpr-specific implementations into _nt.c files (for now, later they could do with a define).
- libcntpr's is now almost fully syncronized and could be merged into the tree except for "except" directory.

Added:
    trunk/reactos/lib/sdk/crt/string/mbstowcs_nt.c
      - copied unchanged from r30261, trunk/reactos/lib/sdk/libcntpr/string/mbstowcs.c
    trunk/reactos/lib/sdk/crt/string/tcscat.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcscat.h
    trunk/reactos/lib/sdk/crt/string/tcschr.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcschr.h
    trunk/reactos/lib/sdk/crt/string/tcscmp.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcscmp.h
    trunk/reactos/lib/sdk/crt/string/tcscpy.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcscpy.h
    trunk/reactos/lib/sdk/crt/string/tcslen.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcslen.h
    trunk/reactos/lib/sdk/crt/string/tcsncat.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcsncat.h
    trunk/reactos/lib/sdk/crt/string/tcsncmp.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcsncmp.h
    trunk/reactos/lib/sdk/crt/string/tcsncpy.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcsncpy.h
    trunk/reactos/lib/sdk/crt/string/tcsnlen.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcsnlen.h
    trunk/reactos/lib/sdk/crt/string/tcsrchr.h
      - copied unchanged from r30261, trunk/reactos/lib/sdk/crt/include/internal/tcsrchr.h
    trunk/reactos/lib/sdk/crt/string/wcstombs_nt.c
      - copied unchanged from r30261, trunk/reactos/lib/sdk/libcntpr/string/wcstombs.c
Removed:
    trunk/reactos/lib/sdk/crt/include/internal/tcscat.h
    trunk/reactos/lib/sdk/crt/include/internal/tcschr.h
    trunk/reactos/lib/sdk/crt/include/internal/tcscmp.h
    trunk/reactos/lib/sdk/crt/include/internal/tcscpy.h
    trunk/reactos/lib/sdk/crt/include/internal/tcslen.h
    trunk/reactos/lib/sdk/crt/include/internal/tcsncat.h
    trunk/reactos/lib/sdk/crt/include/internal/tcsncmp.h
    trunk/reactos/lib/sdk/crt/include/internal/tcsncpy.h
    trunk/reactos/lib/sdk/crt/include/internal/tcsnlen.h
    trunk/reactos/lib/sdk/crt/include/internal/tcsrchr.h
Modified:
    trunk/reactos/lib/sdk/crt/string/itoa.c
    trunk/reactos/lib/sdk/crt/string/itow.c
    trunk/reactos/lib/sdk/crt/string/strcat.c
    trunk/reactos/lib/sdk/crt/string/strchr.c
    trunk/reactos/lib/sdk/crt/string/strcmp.c
    trunk/reactos/lib/sdk/crt/string/strcpy.c
    trunk/reactos/lib/sdk/crt/string/stricmp.c
    trunk/reactos/lib/sdk/crt/string/strlen.c
    trunk/reactos/lib/sdk/crt/string/strlwr.c
    trunk/reactos/lib/sdk/crt/string/strncat.c
    trunk/reactos/lib/sdk/crt/string/strncmp.c
    trunk/reactos/lib/sdk/crt/string/strncpy.c
    trunk/reactos/lib/sdk/crt/string/strnicmp.c
    trunk/reactos/lib/sdk/crt/string/strnlen.c
    trunk/reactos/lib/sdk/crt/string/strrchr.c
    trunk/reactos/lib/sdk/crt/string/strset.c
    trunk/reactos/lib/sdk/crt/string/strstr.c
    trunk/reactos/lib/sdk/crt/string/strtol.c
    trunk/reactos/lib/sdk/crt/string/strtoul.c
    trunk/reactos/lib/sdk/crt/string/strtoull.c
    trunk/reactos/lib/sdk/crt/string/wcscat.c
    trunk/reactos/lib/sdk/crt/string/wcschr.c
    trunk/reactos/lib/sdk/crt/string/wcscmp.c
    trunk/reactos/lib/sdk/crt/string/wcscpy.c
    trunk/reactos/lib/sdk/crt/string/wcslen.c
    trunk/reactos/lib/sdk/crt/string/wcsncat.c
    trunk/reactos/lib/sdk/crt/string/wcsncmp.c
    trunk/reactos/lib/sdk/crt/string/wcsncpy.c
    trunk/reactos/lib/sdk/crt/string/wcsnlen.c
    trunk/reactos/lib/sdk/crt/string/wcsrchr.c
    trunk/reactos/lib/sdk/crt/string/wcstol.c
    trunk/reactos/lib/sdk/crt/string/wcstoul.c
    trunk/reactos/lib/sdk/crt/string/wtoi64.c
    trunk/reactos/lib/sdk/crt/string/wtol.c

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcscat.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcscat.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcscat.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcscat.h (removed)
@@ -1,17 +1,0 @@
-/* $Id$
- */
-
-#include <tchar.h>
-
-_TCHAR * _tcscat(_TCHAR * s, const _TCHAR * append)
-{
- _TCHAR * save = s;
-
- for(; *s; ++s);
-
- while((*s++ = *append++));
-
- return save;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcschr.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcschr.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcschr.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcschr.h (removed)
@@ -1,22 +1,0 @@
-/* $Id$
- */
-
-#include <tchar.h>
-
-_TCHAR * _tcschr(const _TCHAR * s, _XINT c)
-{
- _TCHAR cc = c;
-
- while(*s)
- {
-  if(*s == cc) return (_TCHAR *)s;
-
-  s++;
- }
-
- if(cc == 0) return (_TCHAR *)s;
-
- return 0;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcscmp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcscmp.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcscmp.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcscmp.h (removed)
@@ -1,19 +1,0 @@
-/* $Id$
- */
-
-#include <tchar.h>
-
-int _tcscmp(const _TCHAR* s1, const _TCHAR* s2)
-{
- while(*s1 == *s2)
- {
-  if(*s1 == 0) return 0;
-
-  s1 ++;
-  s2 ++;
- }
-
- return *s1 - *s2;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcscpy.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcscpy.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcscpy.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcscpy.h (removed)
@@ -1,13 +1,0 @@
-/* $Id$
- */
-
-#include <tchar.h>
-
-_TCHAR * _tcscpy(_TCHAR * to, const _TCHAR * from)
-{
- _TCHAR *save = to;
-
- for (; (*to = *from); ++from, ++to);
-
- return save;
-}

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcslen.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcslen.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcslen.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcslen.h (removed)
@@ -1,18 +1,0 @@
-/* $Id$
- */
-
-#include <stddef.h>
-#include <tchar.h>
-
-size_t _tcslen(const _TCHAR * str)
-{
- const _TCHAR * s;
-
- if(str == 0) return 0;
-
- for(s = str; *s; ++ s);
-
- return s - str;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcsncat.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcsncat.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcsncat.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcsncat.h (removed)
@@ -1,30 +1,0 @@
-/* $Id$
- */
-
-#include <stddef.h>
-#include <tchar.h>
-
-_TCHAR * _tcsncat(_TCHAR * dst, const _TCHAR * src, size_t n)
-{
- if(n != 0)
- {
-  _TCHAR * d = dst;
-  const _TCHAR * s = src;
-
-  while(*d != 0) ++ d;
-
-  do
-  {
-   if((*d = *s++) == 0) break;
-
-   ++ d;
-  }
-  while (--n != 0);
-
-  *d = 0;
- }
-
- return dst;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcsncmp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcsncmp.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcsncmp.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcsncmp.h (removed)
@@ -1,21 +1,0 @@
-/* $Id$
- */
-
-#include <stddef.h>
-#include <tchar.h>
-
-int _tcsncmp(const _TCHAR * s1, const _TCHAR * s2, size_t n)
-{
- if(n == 0) return 0;
-
- do
- {
-  if(*s1 != *s2 ++) return *s1 - *-- s2;
-  if(*s1 ++ == 0) break;
- }
- while (-- n != 0);
-
- return 0;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcsncpy.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcsncpy.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcsncpy.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcsncpy.h (removed)
@@ -1,28 +1,0 @@
-/* $Id$
- */
-
-#include <stddef.h>
-#include <tchar.h>
-
-_TCHAR * _tcsncpy(_TCHAR * dst, const _TCHAR * src, size_t n)
-{
- if(n != 0)
- {
-  _TCHAR * d = dst;
-  const _TCHAR * s = src;
-
-  do
-  {
-   if((*d ++ = *s ++) == 0)
-   {
-    while (-- n != 0) *d ++ = 0;
-    break;
-   }
-  }
-  while(-- n != 0);
- }
-
- return dst;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcsnlen.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcsnlen.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcsnlen.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcsnlen.h (removed)
@@ -1,18 +1,0 @@
-/* $Id$
- */
-
-#include <stddef.h>
-#include <tchar.h>
-
-int _tcsnlen(const _TCHAR * str, size_t count)
-{
- const _TCHAR * s;
-
- if(str == 0) return 0;
-
- for(s = str; *s && count; ++ s, -- count);
-
- return s - str;
-}
-
-/* EOF */

Removed: trunk/reactos/lib/sdk/crt/include/internal/tcsrchr.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/internal/tcsrchr.h?rev=30282&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/tcsrchr.h (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/tcsrchr.h (removed)
@@ -1,22 +1,0 @@
-/* $Id$
- */
-
-#include <tchar.h>
-
-_TCHAR * _tcsrchr(const _TCHAR * s, _XINT c)
-{
- _TCHAR cc = c;
- const _TCHAR * sp = (_TCHAR *)0;
-
- while(*s)
- {
-  if(*s == cc) sp = s;
-  s ++;
- }
-
- if(cc == 0) sp = s;
-
- return (_TCHAR *)sp;
-}
-
-/* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/itoa.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/itoa.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/itoa.c (original)
+++ trunk/reactos/lib/sdk/crt/string/itoa.c Fri Nov  9 00:06:20 2007
@@ -1,112 +1,144 @@
 /*
  * COPYRIGHT:   See COPYING in the top level directory
  * PROJECT:     ReactOS system libraries
- * FILE:        lib/msvcrt/stdlib/itoa.c
- * PURPOSE:     converts a integer to ascii
- * PROGRAMER:
+ * FILE:        lib/crt/??????
+ * PURPOSE:     Unknown
+ * PROGRAMER:   Unknown
  * UPDATE HISTORY:
- *              1995: Created
- *              1998: Added ltoa by Ariadne
+ *              25/11/05: Added license header
  */
-/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-
 #include <precomp.h>
 
 /*
  * @implemented
+ * copy _i64toa from wine cvs 2006 month 05 day 21
  */
-char* _itoa(int value, char* string, int radix)
+char *
+_i64toa(__int64 value, char *string, int radix)
 {
-  char tmp[33];
-  char* tp = tmp;
-  int i;
-  unsigned v;
-  int sign;
-  char* sp;
+    ULONGLONG  val;
+    int negative;
+    char buffer[65];
+    char *pos;
+    int digit;
 
-  if (radix > 36 || radix <= 1)
-  {
-    __set_errno(EDOM);
-    return 0;
-  }
+    if (value < 0 && radix == 10) {
+	negative = 1;
+        val = -value;
+    } else {
+	negative = 0;
+        val = value;
+    } /* if */
 
-  sign = (radix == 10 && value < 0);
-  if (sign)
-    v = -value;
-  else
-    v = (unsigned)value;
-  while (v || tp == tmp)
-  {
-    i = v % radix;
-    v = v / radix;
-    if (i < 10)
-      *tp++ = i+'0';
-    else
-      *tp++ = i + 'a' - 10;
-  }
+    pos = &buffer[64];
+    *pos = '\0';
 
-  if (string == 0)
-    string = (char*)malloc((tp-tmp)+sign+1);
-  sp = string;
+    do {
+	digit = val % radix;
+	val = val / radix;
+	if (digit < 10) {
+	    *--pos = '0' + digit;
+	} else {
+	    *--pos = 'a' + digit - 10;
+	} /* if */
+    } while (val != 0L);
 
-  if (sign)
-    *sp++ = '-';
-  while (tp > tmp)
-    *sp++ = *--tp;
-  *sp = 0;
-  return string;
+    if (negative) {
+	*--pos = '-';
+    } /* if */
+
+    memcpy(string, pos, &buffer[64] - pos + 1);
+    return string;
 }
+
+
+/*
+ * @implemented
+ * copy _i64toa from wine cvs 2006 month 05 day 21
+ */
+char *
+_ui64toa(unsigned __int64 value, char *string, int radix)
+{
+    char buffer[65];
+    char *pos;
+    int digit;
+
+    pos = &buffer[64];
+    *pos = '\0';
+
+    do {
+	digit = value % radix;
+	value = value / radix;
+	if (digit < 10) {
+	    *--pos = '0' + digit;
+	} else {
+	    *--pos = 'a' + digit - 10;
+	} /* if */
+    } while (value != 0L);
+
+    memcpy(string, pos, &buffer[64] - pos + 1);
+    return string;
+}
+
 
 /*
  * @implemented
  */
-char* _ltoa(long value, char* string, int radix)
+char *
+_itoa(int value, char *string, int radix)
 {
-  char tmp[33];
-  char* tp = tmp;
-  long i;
-  unsigned long v;
-  int sign;
-  char* sp;
+  return _ltoa(value, string, radix);
+}
 
-  if (radix > 36 || radix <= 1)
-  {
-     __set_errno(EDOM);
-    return 0;
-  }
-
-  sign = (radix == 10 && value < 0);
-  if (sign)
-    v = -value;
-  else
-    v = (unsigned long)value;
-  while (v || tp == tmp)
-  {
-    i = v % radix;
-    v = v / radix;
-    if (i < 10)
-      *tp++ = i+'0';
-    else
-      *tp++ = i + 'a' - 10;
-  }
-
-  if (string == 0)
-    string = (char*)malloc((tp-tmp)+sign+1);
-  sp = string;
-
-  if (sign)
-    *sp++ = '-';
-  while (tp > tmp)
-    *sp++ = *--tp;
-  *sp = 0;
-  return string;
-}
 
 /*
  * @implemented
- * copy it from wine 0.9.0 with small modifcations do check for NULL
  */
-char* ultoa(unsigned long value, char* string, int radix)
+char *
+_ltoa(long value, char *string, int radix)
+{
+    unsigned long val;
+    int negative;
+    char buffer[33];
+    char *pos;
+    int digit;
+
+    if (value < 0 && radix == 10) {
+	negative = 1;
+        val = -value;
+    } else {
+	negative = 0;
+        val = value;
+    } /* if */
+
+    pos = &buffer[32];
+    *pos = '\0';
+
+    do {
+	digit = val % radix;
+	val = val / radix;
+	if (digit < 10) {
+	    *--pos = '0' + digit;
+	} else {
+	    *--pos = 'a' + digit - 10;
+	} /* if */
+    } while (val != 0L);
+
+    if (negative) {
+	*--pos = '-';
+    } /* if */
+
+    memcpy(string, pos, &buffer[32] - pos + 1);
+    return string;
+}
+
+
+/*
+ * @implemented
+ *  copy it from wine 0.9.0 with small modifcations do check for NULL
+ */
+char *
+_ultoa(unsigned long value, char *string, int radix)
 {
     char buffer[33];
     char *pos;
@@ -131,5 +163,6 @@
     } while (value != 0L);
 
     memcpy(string, pos, &buffer[32] - pos + 1);
+
     return string;
 }

Modified: trunk/reactos/lib/sdk/crt/string/itow.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/itow.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/itow.c (original)
+++ trunk/reactos/lib/sdk/crt/string/itow.c Fri Nov  9 00:06:20 2007
@@ -1,16 +1,11 @@
-/* $Id$
- *
+/*
  * COPYRIGHT:   See COPYING in the top level directory
  * PROJECT:     ReactOS system libraries
- * FILE:        lib/msvcrt/stdlib/itow.c
+ * FILE:        lib/sdk/crt/itow.c
  * PURPOSE:     converts a integer to wchar_t
  * PROGRAMER:
  * UPDATE HISTORY:
- *              1995: Created
- *              1998: Added ltoa by Ariadne
- *              2000: derived from ./itoa.c by ea
  */
-/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 
 #include <precomp.h>
 
@@ -18,18 +13,96 @@
  * @implemented
  * from wine cvs 2006-05-21
  */
-wchar_t* _itow(int value, wchar_t* string, int radix)
+wchar_t *
+_i64tow(__int64 value, wchar_t *string, int radix)
 {
-   return _ltow(value, string, radix);
+    ULONGLONG val;
+    int negative;
+    WCHAR buffer[65];
+    PWCHAR pos;
+    WCHAR digit;
+
+    if (value < 0 && radix == 10) {
+	negative = 1;
+        val = -value;
+    } else {
+	negative = 0;
+        val = value;
+    } /* if */
+
+    pos = &buffer[64];
+    *pos = '\0';
+
+    do {
+	digit = val % radix;
+	val = val / radix;
+	if (digit < 10) {
+	    *--pos = '0' + digit;
+	} else {
+	    *--pos = 'a' + digit - 10;
+	} /* if */
+    } while (val != 0L);
+
+    if (negative) {
+	*--pos = '-';
+    } /* if */
+
+    if (string != NULL) {
+	memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
+    } /* if */
+    return string;
 }
+
+
+/*
+ * @implemented
+ */
+wchar_t *
+_ui64tow(unsigned __int64 value, wchar_t *string, int radix)
+{
+    WCHAR buffer[65];
+    PWCHAR pos;
+    WCHAR digit;
+
+    pos = &buffer[64];
+    *pos = '\0';
+
+    do {
+	digit = value % radix;
+	value = value / radix;
+	if (digit < 10) {
+	    *--pos = '0' + digit;
+	} else {
+	    *--pos = 'a' + digit - 10;
+	} /* if */
+    } while (value != 0L);
+
+    if (string != NULL) {
+	memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
+    } /* if */
+    return string;
+}
+
 
 /*
  * @implemented
  * from wine cvs 2006-05-21
  */
-wchar_t* _ltow(long value, wchar_t* string, int radix)
+wchar_t *
+_itow(int value, wchar_t *string, int radix)
 {
-     unsigned long val;
+  return _ltow(value, string, radix);
+}
+
+
+/*
+ * @implemented
+ * from wine cvs 2006-05-21
+ */
+wchar_t *
+_ltow(long value, wchar_t *string, int radix)
+{
+    unsigned long val;
     int negative;
     WCHAR buffer[33];
     PWCHAR pos;
@@ -60,17 +133,19 @@
 	*--pos = '-';
     } /* if */
 
-    if (str != NULL) {
+    if (string != NULL) {
 	memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR));
     } /* if */
     return string;
 }
 
+
 /*
  * @implemented
  * from wine cvs 2006-05-21
  */
-wchar_t* _ultow(unsigned long value, wchar_t* string, int radix)
+wchar_t *
+_ultow(unsigned long value, wchar_t *string, int radix)
 {
     WCHAR buffer[33];
     PWCHAR pos;

Modified: trunk/reactos/lib/sdk/crt/string/strcat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strcat.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strcat.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strcat.c Fri Nov  9 00:06:20 2007
@@ -2,6 +2,6 @@
  */
 
 #include <string.h>
-#include "internal/tcscat.h"
+#include "tcscat.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strchr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strchr.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strchr.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strchr.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _XINT int
 #include <string.h>
-#include "internal/tcschr.h"
+#include "tcschr.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strcmp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strcmp.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strcmp.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strcmp.c Fri Nov  9 00:06:20 2007
@@ -2,6 +2,6 @@
  */
 
 #include <string.h>
-#include "internal/tcscmp.h"
+#include "tcscmp.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strcpy.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strcpy.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strcpy.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strcpy.c Fri Nov  9 00:06:20 2007
@@ -2,6 +2,6 @@
  */
 
 #include <string.h>
-#include "internal/tcscpy.h"
+#include "tcscpy.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/stricmp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/stricmp.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/stricmp.c (original)
+++ trunk/reactos/lib/sdk/crt/string/stricmp.c Fri Nov  9 00:06:20 2007
@@ -1,4 +1,3 @@
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
 
 /*

Modified: trunk/reactos/lib/sdk/crt/string/strlen.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strlen.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strlen.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strlen.c Fri Nov  9 00:06:20 2007
@@ -2,6 +2,6 @@
  */
 
 #include <string.h>
-#include "internal/tcslen.h"
+#include "tcslen.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strlwr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strlwr.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strlwr.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strlwr.c Fri Nov  9 00:06:20 2007
@@ -1,12 +1,3 @@
-/*
- * The C RunTime DLL
- *
- * Implements C run-time functionality as known from UNIX.
- *
- * Copyright 1996,1998 Marcus Meissner
- * Copyright 1996 Jukka Iivonen
- * Copyright 1997 Uwe Bonnes
- */
 
 #include <precomp.h>
 

Modified: trunk/reactos/lib/sdk/crt/string/strncat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strncat.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strncat.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strncat.c Fri Nov  9 00:06:20 2007
@@ -2,6 +2,6 @@
  */
 
 #include <string.h>
-#include "internal/tcsncat.h"
+#include "tcsncat.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strncmp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strncmp.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strncmp.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strncmp.c Fri Nov  9 00:06:20 2007
@@ -2,6 +2,6 @@
  */
 
 #include <string.h>
-#include "internal/tcsncmp.h"
+#include "tcsncmp.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strncpy.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strncpy.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strncpy.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strncpy.c Fri Nov  9 00:06:20 2007
@@ -1,6 +1,6 @@
 /* $Id$
  */
 #include <string.h>
-#include "internal/tcsncpy.h"
+#include "tcsncpy.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strnicmp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strnicmp.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strnicmp.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strnicmp.c Fri Nov  9 00:06:20 2007
@@ -1,4 +1,3 @@
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
 
 /*

Modified: trunk/reactos/lib/sdk/crt/string/strnlen.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strnlen.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strnlen.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strnlen.c Fri Nov  9 00:06:20 2007
@@ -2,6 +2,6 @@
  */
 
 #include <string.h>
-#include "internal/tcsnlen.h"
+#include "tcsnlen.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strrchr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strrchr.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strrchr.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strrchr.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _XINT int
 #include <string.h>
-#include "internal/tcsrchr.h"
+#include "tcsrchr.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/strset.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strset.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strset.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strset.c Fri Nov  9 00:06:20 2007
@@ -13,11 +13,11 @@
 /*
  * @implemented
  */
-char* _strnset (char* szToFill, int szFill, size_t sizeMaxFill)
+char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill)
 {
 	char *t = szToFill;
-	size_t i = 0;
-	while( *szToFill != 0 && i < sizeMaxFill)
+	int i = 0;
+	while (*szToFill != 0 && i < (int) sizeMaxFill)
 	{
 		*szToFill = szFill;
 		szToFill++;
@@ -30,10 +30,10 @@
 /*
  * @implemented
  */
-char* _strset (char* szToFill, int szFill)
+char* _strset(char* szToFill, int szFill)
 {
 	char *t = szToFill;
-	while( *szToFill != 0 )
+	while (*szToFill != 0)
 	{
 		*szToFill = szFill;
 		szToFill++;

Modified: trunk/reactos/lib/sdk/crt/string/strstr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strstr.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strstr.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strstr.c Fri Nov  9 00:06:20 2007
@@ -8,14 +8,12 @@
  *              25/11/05: Added license header
  */
 
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
-
-
 /*
  * @implemented
  */
-char *strstr(const char *s, const char *find)
+char *
+strstr(const char *s, const char *find)
 {
   char c, sc;
   size_t len;
@@ -31,5 +29,5 @@
     } while (strncmp(s, find, len) != 0);
     s--;
   }
-  return (char *)s;
+  return (char *)((size_t)s);
 }

Modified: trunk/reactos/lib/sdk/crt/string/strtol.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strtol.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strtol.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strtol.c Fri Nov  9 00:06:20 2007
@@ -1,4 +1,3 @@
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
 
 /*
@@ -80,11 +79,10 @@
   if (any < 0)
   {
     acc = neg ? LONG_MIN : LONG_MAX;
-    __set_errno(ERANGE);
   }
   else if (neg)
     acc = -acc;
   if (endptr != 0)
-    *endptr = any ? (char *)s - 1 : (char *)nptr;
+    *endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
   return acc;
 }

Modified: trunk/reactos/lib/sdk/crt/string/strtoul.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strtoul.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strtoul.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strtoul.c Fri Nov  9 00:06:20 2007
@@ -1,4 +1,3 @@
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
 #include <ctype.h>
 
@@ -64,11 +63,10 @@
   if (any < 0)
   {
     acc = ULONG_MAX;
-    __set_errno(ERANGE);
   }
   else if (neg)
     acc = -acc;
   if (endptr != 0)
-    *endptr = any ? (char *)s - 1 : (char *)nptr;
+    *endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
   return acc;
 }

Modified: trunk/reactos/lib/sdk/crt/string/strtoull.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strtoull.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strtoull.c (original)
+++ trunk/reactos/lib/sdk/crt/string/strtoull.c Fri Nov  9 00:06:20 2007
@@ -1,24 +1,12 @@
-/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
 
-#if defined (_MSC_VER)
-#define UINT64_MAX	0xffffffffffffffff
-#endif
-
-/*
- * Convert a string to an unsigned long integer.
- *
- * Ignores `locale' stuff.  Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
-UINT64
+unsigned long long
 strtoull(const char *nptr, char **endptr, int base)
 {
   const char *s = nptr;
-  UINT64 acc;
+  unsigned long long acc;
   int c;
-  UINT64 cutoff;
+  unsigned long long cutoff;
   int neg = 0, any, cutlim;
 
   /*
@@ -43,8 +31,8 @@
   }
   if (base == 0)
     base = c == '0' ? 8 : 10;
-  cutoff = UINT64_MAX / base;
-  cutlim = (int)(UINT64_MAX % base);
+  cutoff = (unsigned long long)ULLONG_MAX / (unsigned long long)base;
+  cutlim = (unsigned long long)ULLONG_MAX % (unsigned long long)base;
   for (acc = 0, any = 0;; c = *s++)
   {
     if (isdigit(c))
@@ -65,12 +53,11 @@
   }
   if (any < 0)
   {
-    acc = UINT64_MAX;
-    __set_errno ( ERANGE );
+    acc = ULLONG_MAX;
   }
   else if (neg)
     acc = -acc;
   if (endptr != 0)
-    *endptr = any ? (char *)s - 1 : (char *)nptr;
+    *endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
   return acc;
 }

Modified: trunk/reactos/lib/sdk/crt/string/wcscat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcscat.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcscat.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcscat.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcscat.h"
+#include "tcscat.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcschr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcschr.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcschr.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcschr.c Fri Nov  9 00:06:20 2007
@@ -4,6 +4,6 @@
 #define _UNICODE
 #define _XINT wchar_t
 #include <wchar.h>
-#include "internal/tcschr.h"
+#include "tcschr.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcscmp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcscmp.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcscmp.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcscmp.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcscmp.h"
+#include "tcscmp.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcscpy.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcscpy.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcscpy.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcscpy.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcscpy.h"
+#include "tcscpy.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcslen.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcslen.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcslen.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcslen.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcslen.h"
+#include "tcslen.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcsncat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcsncat.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcsncat.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcsncat.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcsncat.h"
+#include "tcsncat.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcsncmp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcsncmp.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcsncmp.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcsncmp.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcsncmp.h"
+#include "tcsncmp.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcsncpy.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcsncpy.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcsncpy.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcsncpy.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcsncpy.h"
+#include "tcsncpy.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcsnlen.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcsnlen.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcsnlen.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcsnlen.c Fri Nov  9 00:06:20 2007
@@ -3,6 +3,6 @@
 
 #define _UNICODE
 #include <wchar.h>
-#include "internal/tcsnlen.h"
+#include "tcsnlen.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcsrchr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcsrchr.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcsrchr.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcsrchr.c Fri Nov  9 00:06:20 2007
@@ -4,6 +4,6 @@
 #define _UNICODE
 #define _XINT wchar_t
 #include <wchar.h>
-#include "internal/tcsrchr.h"
+#include "tcsrchr.h"
 
 /* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wcstol.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcstol.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcstol.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcstol.c Fri Nov  9 00:06:20 2007
@@ -9,37 +9,89 @@
  */
 
 #include <precomp.h>
-
 /*
  * @implemented
  */
-long wcstol(const wchar_t *cp,wchar_t **endp,int base)
+long
+wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
 {
-	long result = 0,value;
-	int sign = 1;
+  const wchar_t *s = nptr;
+  unsigned long acc;
+  int c;
+  unsigned long cutoff;
+  int neg = 0, any, cutlim;
 
-	if ( *cp == L'-' ) {
-		sign = -1;
-		cp++;
-	}
+  /*
+   * Skip white space and pick up leading +/- sign if any.
+   * If base is 0, allow 0x for hex and 0 for octal, else
+   * assume decimal; if base is already 16, allow 0x.
+   */
+  do {
+    c = *s++;
+  } while (iswctype(c, _SPACE));
+  if (c == '-')
+  {
+    neg = 1;
+    c = *s++;
+  }
+  else if (c == L'+')
+    c = *s++;
+  if ((base == 0 || base == 16) &&
+      c == L'0' && (*s == L'x' || *s == L'X'))
+  {
+    c = s[1];
+    s += 2;
+    base = 16;
+  }
+  if (base == 0)
+    base = c == L'0' ? 8 : 10;
 
-	if (!base) {
-		base = 10;
-		if (*cp == L'0') {
-			base = 8;
-			cp++;
-			if ((*cp == L'x') && iswxdigit(cp[1])) {
-				cp++;
-				base = 16;
-			}
-		}
-	}
-	while (iswxdigit(*cp) && (value = iswdigit(*cp) ? *cp-L'0' : (iswlower(*cp)
-	    ? towupper(*cp) : *cp)-L'A'+10) < base) {
-		result = result*base + value;
-		cp++;
-	}
-	if (endp)
-		*endp = (wchar_t *)cp;
-	return result * sign;
+  /*
+   * Compute the cutoff value between legal numbers and illegal
+   * numbers.  That is the largest legal value, divided by the
+   * base.  An input number that is greater than this value, if
+   * followed by a legal input character, is too big.  One that
+   * is equal to this value may be valid or not; the limit
+   * between valid and invalid numbers is then based on the last
+   * digit.  For instance, if the range for longs is
+   * [-2147483648..2147483647] and the input base is 10,
+   * cutoff will be set to 214748364 and cutlim to either
+   * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+   * a value > 214748364, or equal but the next digit is > 7 (or 8),
+   * the number is too big, and we will return a range error.
+   *
+   * Set any if any `digits' consumed; make it negative to indicate
+   * overflow.
+   */
+  cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+  cutlim = cutoff % (unsigned long)base;
+  cutoff /= (unsigned long)base;
+  for (acc = 0, any = 0;; c = *s++)
+  {
+    if (iswctype(c, _DIGIT))
+      c -= L'0';
+    else if (iswctype(c, _ALPHA))
+      c -= iswctype(c, _UPPER) ? L'A' - 10 : L'a' - 10;
+    else
+      break;
+    if (c >= base)
+      break;
+    if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+      any = -1;
+    else
+    {
+      any = 1;
+      acc *= base;
+      acc += c;
+    }
+  }
+  if (any < 0)
+  {
+    acc = neg ? LONG_MIN : LONG_MAX;
+  }
+  else if (neg)
+    acc = -acc;
+  if (endptr != 0)
+    *endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr);
+  return acc;
 }

Modified: trunk/reactos/lib/sdk/crt/string/wcstoul.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcstoul.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcstoul.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wcstoul.c Fri Nov  9 00:06:20 2007
@@ -1,5 +1,5 @@
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
+
 
 /*
  * Convert a unicode string to an unsigned long integer.
@@ -23,7 +23,7 @@
    */
   do {
     c = *s++;
-  } while (iswspace(c));
+  } while (iswctype(c, _SPACE));
   if (c == L'-')
   {
     neg = 1;
@@ -44,10 +44,10 @@
   cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
   for (acc = 0, any = 0;; c = *s++)
   {
-    if (iswdigit(c))
+    if (iswctype(c, _DIGIT))
       c -= L'0';
-    else if (iswalpha(c))
-      c -= iswupper(c) ? L'A' - 10 : L'a' - 10;
+    else if (iswctype(c, _ALPHA))
+      c -= iswctype(c, _UPPER) ? L'A' - 10 : L'a' - 10;
     else
       break;
     if (c >= base)
@@ -63,38 +63,10 @@
   if (any < 0)
   {
     acc = ULONG_MAX;
-    __set_errno(ERANGE);
   }
   else if (neg)
     acc = -acc;
   if (endptr != 0)
-    *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr;
+    *endptr = any ? (wchar_t *)((size_t)s - 1) : (wchar_t *)((size_t)nptr);
   return acc;
 }
-
-#if 0
-unsigned long wcstoul(const wchar_t *cp,wchar_t **endp,int base)
-{
-	unsigned long result = 0,value;
-
-	if (!base) {
-		base = 10;
-		if (*cp == L'0') {
-			base = 8;
-			cp++;
-			if ((*cp == L'x') && iswxdigit(cp[1])) {
-				cp++;
-				base = 16;
-			}
-		}
-	}
-	while (iswxdigit(*cp) && (value = iswdigit(*cp) ? *cp-L'0' : (iswlower(*cp)
-	    ? towupper(*cp) : *cp)-L'A'+10) < base) {
-		result = result*base + value;
-		cp++;
-	}
-	if (endp)
-		*endp = (wchar_t *)cp;
-	return result;
-}
-#endif

Modified: trunk/reactos/lib/sdk/crt/string/wtoi64.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wtoi64.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wtoi64.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wtoi64.c Fri Nov  9 00:06:20 2007
@@ -13,27 +13,33 @@
 /*
  * @implemented
  */
-__int64 _wtoi64(const wchar_t* nptr)
+__int64
+_wtoi64 (const wchar_t *nptr)
 {
-    wchar_t* s = (wchar_t*)nptr;
-    __int64 acc = 0;
-    int neg = 0;
+   int c;
+   __int64 value;
+   int sign;
 
-    while (iswspace((int)*s))
-        s++;
-    if (*s == '-') {
-        neg = 1;
-        s++;
-    }
-    else if (*s == '+')
-        s++;
+   while (iswctype((int)*nptr, _SPACE))
+        ++nptr;
 
-    while (iswdigit((int)*s)) {
-        acc = 10 * acc + ((int)*s - '0');
-        s++;
-    }
+   c = (int)*nptr++;
+   sign = c;
+   if (c == L'-' || c == L'+')
+        c = (int)*nptr++;
 
-    if (neg)
-        acc *= -1;
-    return acc;
+   value = 0;
+
+   while (iswctype(c, _DIGIT))
+     {
+        value = 10 * value + (c - L'0');
+        c = (int)*nptr++;
+     }
+
+   if (sign == L'-')
+       return -value;
+   else
+       return value;
 }
+
+/* EOF */

Modified: trunk/reactos/lib/sdk/crt/string/wtol.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wtol.c?rev=30283&r1=30282&r2=30283&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wtol.c (original)
+++ trunk/reactos/lib/sdk/crt/string/wtol.c Fri Nov  9 00:06:20 2007
@@ -1,6 +1,35 @@
+#include <string.h>
+#include <ctype.h>
+#include <basetsd.h>
 
-#define _UNICODE
-#define UNICODE
+/* Implementation comes from wine/dlls/ntdll/wcstring.c */
 
-#include "atol.c"
+/*
+ * @implemented
+ */
+long
+_wtol(const wchar_t *str)
+{
+    unsigned long RunningTotal = 0;
+    char bMinus = 0;
 
+    while (iswctype(*str, _SPACE) ) {
+        str++;
+    } /* while */
+
+    if (*str == L'+') {
+        str++;
+    } else if (*str == L'-') {
+        bMinus = 1;
+        str++;
+    } /* if */
+
+    while (*str >= L'0' && *str <= L'9') {
+        RunningTotal = RunningTotal * 10 + *str - L'0';
+        str++;
+    } /* while */
+
+    return bMinus ? -RunningTotal : RunningTotal;
+}
+
+




More information about the Ros-diffs mailing list