From 6ce05ab58ec6993022e89488a4b759adc6476dde Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Thu, 8 Sep 2005 04:27:02 +0000 Subject: [PATCH] Don't duplicate string and ctype functions 2 (or even 3) times... we have stringlib for that svn path=/trunk/; revision=17733 --- reactos/lib/kjs/ksrc/compat.c | 4 - reactos/lib/ntdll/ntdll.xml | 11 +- reactos/lib/ntdll/string/strlwr.c | 25 --- reactos/lib/ntdll/string/strupr.c | 26 --- reactos/lib/{ntdll => }/string/ctype.c | 15 +- reactos/lib/{ntdll => }/string/memicmp.c | 4 +- reactos/lib/{ntdll => }/string/stricmp.c | 4 +- reactos/lib/string/string.xml | 12 ++ reactos/lib/string/strlwr.c | 17 ++ reactos/lib/{ntdll => }/string/strnicmp.c | 5 +- reactos/lib/string/strrev.c | 24 +++ reactos/lib/string/strset.c | 33 ++++ reactos/lib/{ntdll => }/string/strstr.c | 3 +- reactos/lib/string/strupr.c | 17 ++ reactos/lib/string/wcsnset.c | 17 ++ reactos/lib/string/wcsrev.c | 22 +++ reactos/lib/{ntdll => }/string/wstring.c | 18 +-- reactos/ntoskrnl/ntoskrnl.xml | 3 - reactos/ntoskrnl/rtl/string.c | 163 ------------------- reactos/ntoskrnl/rtl/wstring.c | 189 ---------------------- 20 files changed, 155 insertions(+), 457 deletions(-) delete mode 100644 reactos/lib/ntdll/string/strlwr.c delete mode 100644 reactos/lib/ntdll/string/strupr.c rename reactos/lib/{ntdll => }/string/ctype.c (95%) rename reactos/lib/{ntdll => }/string/memicmp.c (77%) rename reactos/lib/{ntdll => }/string/stricmp.c (81%) create mode 100644 reactos/lib/string/strlwr.c rename reactos/lib/{ntdll => }/string/strnicmp.c (79%) create mode 100644 reactos/lib/string/strrev.c create mode 100644 reactos/lib/string/strset.c rename reactos/lib/{ntdll => }/string/strstr.c (79%) create mode 100644 reactos/lib/string/strupr.c create mode 100644 reactos/lib/string/wcsnset.c create mode 100644 reactos/lib/string/wcsrev.c rename reactos/lib/{ntdll => }/string/wstring.c (80%) delete mode 100644 reactos/ntoskrnl/rtl/string.c delete mode 100644 reactos/ntoskrnl/rtl/wstring.c diff --git a/reactos/lib/kjs/ksrc/compat.c b/reactos/lib/kjs/ksrc/compat.c index ff1d6f672ea..0b6cf250833 100644 --- a/reactos/lib/kjs/ksrc/compat.c +++ b/reactos/lib/kjs/ksrc/compat.c @@ -12,10 +12,6 @@ void _assert( const char *expr, const char *file, int line ) { __kernel_abort(); } -int isalnum( int x ) { return isalpha(x) || isdigit(x); } -int iscntrl( int x ) { return 32 > x; } -int ispunct( int x ) { return !isspace(x) && !isalnum(x) && !iscntrl(x) && !isspace(x); } - static int belongs_to_base( int x, int base ) { if( x >= '0' && '9' >= x ) { if( base > x - '0' ) return x - '0'; diff --git a/reactos/lib/ntdll/ntdll.xml b/reactos/lib/ntdll/ntdll.xml index db6ef03f265..4dba6ef8b4d 100644 --- a/reactos/lib/ntdll/ntdll.xml +++ b/reactos/lib/ntdll/ntdll.xml @@ -12,6 +12,7 @@ intrlck string -lgcc + -nostdlib -nostartfiles api.c @@ -62,16 +63,6 @@ wtoi.c wtol.c - - ctype.c - memicmp.c - stricmp.c - strlwr.c - strnicmp.c - strstr.c - strupr.c - wstring.c - ntdll.rc diff --git a/reactos/lib/ntdll/string/strlwr.c b/reactos/lib/ntdll/string/strlwr.c deleted file mode 100644 index f783dc02a7a..00000000000 --- a/reactos/lib/ntdll/string/strlwr.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 - -/* - * @implemented - */ -char * _strlwr(char *x) -{ - char *y=x; - - while (*y) { - *y=tolower(*y); - y++; - } - return x; -} diff --git a/reactos/lib/ntdll/string/strupr.c b/reactos/lib/ntdll/string/strupr.c deleted file mode 100644 index 0904349e0bd..00000000000 --- a/reactos/lib/ntdll/string/strupr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - -/* - * @implemented - */ -char *_strupr(char *x) -{ - char *y=x; - - while (*y) { - *y=toupper(*y); - y++; - } - return x; -} diff --git a/reactos/lib/ntdll/string/ctype.c b/reactos/lib/string/ctype.c similarity index 95% rename from reactos/lib/ntdll/string/ctype.c rename to reactos/lib/string/ctype.c index d327a836f96..06d011c3ebd 100644 --- a/reactos/lib/ntdll/string/ctype.c +++ b/reactos/lib/string/ctype.c @@ -1,16 +1,5 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: lib/ntdll/rtl/ctype.c - * PURPOSE: Character type and conversion functions - * PROGRAMMERS: ??? - * Eric Kohl - * HISTORY: ???: Created - * 29/12/1999: Added missing functions and changed - * all functions to use ctype table - */ -#include +#include +#include #undef _pctype diff --git a/reactos/lib/ntdll/string/memicmp.c b/reactos/lib/string/memicmp.c similarity index 77% rename from reactos/lib/ntdll/string/memicmp.c rename to reactos/lib/string/memicmp.c index d888264c07d..26a27f1812b 100644 --- a/reactos/lib/ntdll/string/memicmp.c +++ b/reactos/lib/string/memicmp.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include +#include /* * @implemented diff --git a/reactos/lib/ntdll/string/stricmp.c b/reactos/lib/string/stricmp.c similarity index 81% rename from reactos/lib/ntdll/string/stricmp.c rename to reactos/lib/string/stricmp.c index 7edba7a8bcc..caaf2798311 100644 --- a/reactos/lib/ntdll/string/stricmp.c +++ b/reactos/lib/string/stricmp.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include +#include /* * @implemented diff --git a/reactos/lib/string/string.xml b/reactos/lib/string/string.xml index 07d0aa5ef8f..d5cb133a8b2 100644 --- a/reactos/lib/string/string.xml +++ b/reactos/lib/string/string.xml @@ -59,9 +59,21 @@ The current implemention of rbuild generates a dependency rule for each occurence of a file. --> + ctype.c memccpy.c memcmp.c + memicmp.c strcspn.c + stricmp.c + strnicmp.c + strlwr.c + strrev.c + strset.c + strstr.c + strupr.c strpbrk.c strspn.c + wstring.c + wcsrev.c + wcsnset.c diff --git a/reactos/lib/string/strlwr.c b/reactos/lib/string/strlwr.c new file mode 100644 index 00000000000..c19a78ac4bb --- /dev/null +++ b/reactos/lib/string/strlwr.c @@ -0,0 +1,17 @@ +#include +#include + + +/* + * @implemented + */ +char * _strlwr(char *x) +{ + char *y=x; + + while (*y) { + *y=tolower(*y); + y++; + } + return x; +} diff --git a/reactos/lib/ntdll/string/strnicmp.c b/reactos/lib/string/strnicmp.c similarity index 79% rename from reactos/lib/ntdll/string/strnicmp.c rename to reactos/lib/string/strnicmp.c index 5befa7a4231..749d4db22f2 100644 --- a/reactos/lib/ntdll/string/strnicmp.c +++ b/reactos/lib/string/strnicmp.c @@ -1,7 +1,8 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include +#include /* + * @implemented */ int _strnicmp(const char *s1, const char *s2, size_t n) diff --git a/reactos/lib/string/strrev.c b/reactos/lib/string/strrev.c new file mode 100644 index 00000000000..4f3b64a2ee5 --- /dev/null +++ b/reactos/lib/string/strrev.c @@ -0,0 +1,24 @@ +#include + +/* + * @implemented + */ +char * _strrev(char *s) +{ + char *e; + char a; + + e = s; + while (*e) + e++; + + while (s + +/* + * @implemented + */ +char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill) +{ + char *t = szToFill; + int i = 0; + while (*szToFill != 0 && i < (int) sizeMaxFill) + { + *szToFill = szFill; + szToFill++; + i++; + + } + return t; +} + +/* + * @implemented + */ +char* _strset(char* szToFill, int szFill) +{ + char *t = szToFill; + while (*szToFill != 0) + { + *szToFill = szFill; + szToFill++; + + } + return t; +} diff --git a/reactos/lib/ntdll/string/strstr.c b/reactos/lib/string/strstr.c similarity index 79% rename from reactos/lib/ntdll/string/strstr.c rename to reactos/lib/string/strstr.c index 77441645823..4482a519fbb 100644 --- a/reactos/lib/ntdll/string/strstr.c +++ b/reactos/lib/string/strstr.c @@ -1,5 +1,4 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include +#include /* * @implemented diff --git a/reactos/lib/string/strupr.c b/reactos/lib/string/strupr.c new file mode 100644 index 00000000000..3825993e0eb --- /dev/null +++ b/reactos/lib/string/strupr.c @@ -0,0 +1,17 @@ +#include +#include + + +/* + * @implemented + */ +char *_strupr(char *x) +{ + char *y=x; + + while (*y) { + *y=toupper(*y); + y++; + } + return x; +} diff --git a/reactos/lib/string/wcsnset.c b/reactos/lib/string/wcsnset.c new file mode 100644 index 00000000000..4fd7c955fc0 --- /dev/null +++ b/reactos/lib/string/wcsnset.c @@ -0,0 +1,17 @@ +#include + +/* + * @implemented + */ +wchar_t *_wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill) +{ + wchar_t *t = wsToFill; + int i = 0; + while( *wsToFill != 0 && i < (int) sizeMaxFill) + { + *wsToFill = wcFill; + wsToFill++; + i++; + } + return t; +} diff --git a/reactos/lib/string/wcsrev.c b/reactos/lib/string/wcsrev.c new file mode 100644 index 00000000000..6728f225957 --- /dev/null +++ b/reactos/lib/string/wcsrev.c @@ -0,0 +1,22 @@ +#include + +/* + * @implemented + */ +wchar_t *_wcsrev(wchar_t *s) +{ + wchar_t *e; + wchar_t a; + e=s; + while (*e) + e++; + while (s - +#include +#include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/ntoskrnl/ntoskrnl.xml b/reactos/ntoskrnl/ntoskrnl.xml index 99d4a50e1a2..92bb1687fc1 100644 --- a/reactos/ntoskrnl/ntoskrnl.xml +++ b/reactos/ntoskrnl/ntoskrnl.xml @@ -314,7 +314,6 @@ atom.c capture.c - ctype.c debug.c libsupp.c misc.c @@ -323,10 +322,8 @@ regio.c sprintf.c stdlib.c - string.c strtok.c swprintf.c - wstring.c access.c diff --git a/reactos/ntoskrnl/rtl/string.c b/reactos/ntoskrnl/rtl/string.c deleted file mode 100644 index 67012306fe5..00000000000 --- a/reactos/ntoskrnl/rtl/string.c +++ /dev/null @@ -1,163 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/rtl/string.c - * PURPOSE: Ascii string functions - * - * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de) - */ - -/* INCLUDES *****************************************************************/ - -#include -#include - -/* FUNCTIONS *****************************************************************/ - -int _stricmp(const char *s1, const char *s2) -{ - while (toupper(*s1) == toupper(*s2)) - { - if (*s1 == 0) - return 0; - s1++; - s2++; - } - return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2)); -} - - -/* - * @implemented - */ -char * _strlwr(char *x) -{ - char *y=x; - - while (*y) - { - *y=tolower(*y); - y++; - } - return x; -} - - -/* - * @implemented - */ -int _strnicmp(const char *s1, const char *s2, size_t n) -{ - if (n == 0) - return 0; - do - { - if (toupper(*s1) != toupper(*s2++)) - return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)--s2); - if (*s1++ == 0) - break; - } - while (--n != 0); - return 0; -} - -/* - * @implemented - */ -char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill) -{ - char *t = szToFill; - int i = 0; - while (*szToFill != 0 && i < (int) sizeMaxFill) - { - *szToFill = szFill; - szToFill++; - i++; - - } - return t; -} - - -/* - * @implemented - */ -char * _strrev(char *s) -{ - char *e; - char a; - - e = s; - while (*e) - e++; - - while (s -#define NDEBUG -#include - -/* FUNCTIONS *****************************************************************/ - -int _wcsicmp (const wchar_t* cs, const wchar_t* ct) -{ - while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct)) - { - cs++; - ct++; - } - return *cs - *ct; -} - -/* - * @implemented - */ -wchar_t *_wcslwr (wchar_t *x) -{ - wchar_t *y=x; - - while (*y) - { - *y=towlower(*y); - y++; - } - return x; -} - - -/* - * @implemented - */ -int _wcsnicmp (const wchar_t * cs,const wchar_t * ct,size_t count) -{ - if (count == 0) - return 0; - do { - if (towupper(*cs) != towupper(*ct++)) - return towupper(*cs) - towupper(*--ct); - if (*cs++ == 0) - break; - } while (--count != 0); - return 0; -} - - -/* - * @implemented - */ -wchar_t *_wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill) -{ - wchar_t *t = wsToFill; - int i = 0; - while( *wsToFill != 0 && i < (int) sizeMaxFill) - { - *wsToFill = wcFill; - wsToFill++; - i++; - } - return t; -} - - -/* - * @implemented - */ -wchar_t *_wcsrev(wchar_t *s) -{ - wchar_t *e; - wchar_t a; - e=s; - while (*e) - e++; - while (s