mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Moved strspn and strcspn to the string library.
svn path=/trunk/; revision=4878
This commit is contained in:
parent
e9f3a8740c
commit
48be1aeb7d
11 changed files with 58 additions and 96 deletions
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.55 2003/05/27 20:01:30 hbirr Exp $
|
||||
# $Id: makefile,v 1.56 2003/06/09 20:23:06 hbirr Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
|
@ -398,7 +398,6 @@ STDLIB_OBJECTS = \
|
|||
STRING_OBJECTS = \
|
||||
$(PATH_TO_MSVCRT)/string/memicmp.o \
|
||||
$(PATH_TO_MSVCRT)/string/strcoll.o \
|
||||
$(PATH_TO_MSVCRT)/string/strcspn.o \
|
||||
$(PATH_TO_MSVCRT)/string/strdup.o \
|
||||
string/strerror.o \
|
||||
$(PATH_TO_MSVCRT)/string/stricmp.o \
|
||||
|
@ -407,7 +406,6 @@ STRING_OBJECTS = \
|
|||
$(PATH_TO_MSVCRT)/string/strpbrk.o \
|
||||
$(PATH_TO_MSVCRT)/string/strrev.o \
|
||||
$(PATH_TO_MSVCRT)/string/strset.o \
|
||||
$(PATH_TO_MSVCRT)/string/strspn.o \
|
||||
$(PATH_TO_MSVCRT)/string/strstr.o \
|
||||
string/strtok.o \
|
||||
$(PATH_TO_MSVCRT)/string/strupr.o \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.35 2003/05/27 20:07:53 hbirr Exp $
|
||||
# $Id: Makefile,v 1.36 2003/06/09 20:23:06 hbirr Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
|
@ -402,7 +402,6 @@ STDLIB_OBJECTS = \
|
|||
STRING_OBJECTS = \
|
||||
string/memicmp.o \
|
||||
string/strcoll.o \
|
||||
string/strcspn.o \
|
||||
string/strdup.o \
|
||||
string/strerror.o \
|
||||
string/stricmp.o \
|
||||
|
@ -412,7 +411,6 @@ STRING_OBJECTS = \
|
|||
string/strpbrk.o \
|
||||
string/strrev.o\
|
||||
string/strset.o \
|
||||
string/strspn.o \
|
||||
string/strstr.o \
|
||||
string/strtok.o \
|
||||
string/strupr.o \
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
size_t strcspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p, *spanp;
|
||||
char c, sc;
|
||||
|
||||
for (p = s1;;)
|
||||
{
|
||||
c = *p++;
|
||||
spanp = s2;
|
||||
do {
|
||||
if ((sc = *spanp++) == c)
|
||||
return p - 1 - s1;
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <msvcrt/string.h>
|
||||
|
||||
size_t
|
||||
strspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p = s1, *spanp;
|
||||
char c, sc;
|
||||
|
||||
cont:
|
||||
c = *p++;
|
||||
for (spanp = s2; (sc = *spanp++) != 0;)
|
||||
if (sc == c)
|
||||
goto cont;
|
||||
return (p - 1 - s1);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.85 2003/06/07 11:33:13 ekohl Exp $
|
||||
# $Id: makefile,v 1.86 2003/06/09 20:23:06 hbirr Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
|
@ -55,11 +55,10 @@ STDLIB_OBJECTS = stdlib/abs.o stdlib/atoi.o stdlib/atoi64.o stdlib/atol.o \
|
|||
|
||||
STRING_OBJECTS = string/ctype.o \
|
||||
string/memicmp.o\
|
||||
string/strcspn.o \
|
||||
string/stricmp.o \
|
||||
string/strlwr.o \
|
||||
string/strnicmp.o \
|
||||
string/strpbrk.o string/strspn.o \
|
||||
string/strpbrk.o \
|
||||
string/strstr.o string/strupr.o string/wstring.o
|
||||
|
||||
ARCH_OBJECTS = \
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <string.h>
|
||||
|
||||
size_t
|
||||
strcspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p, *spanp;
|
||||
char c, sc;
|
||||
|
||||
for (p = s1;;)
|
||||
{
|
||||
c = *p++;
|
||||
spanp = s2;
|
||||
do {
|
||||
if ((sc = *spanp++) == c)
|
||||
return p - 1 - s1;
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <string.h>
|
||||
|
||||
size_t
|
||||
strspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p = s1, *spanp;
|
||||
char c, sc;
|
||||
|
||||
cont:
|
||||
c = *p++;
|
||||
for (spanp = s2; (sc = *spanp++) != 0;)
|
||||
if (sc == c)
|
||||
goto cont;
|
||||
return (p - 1 - s1);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.3 2003/06/01 19:23:18 hbirr Exp $
|
||||
# $Id: Makefile,v 1.4 2003/06/09 20:23:06 hbirr Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
|
@ -29,12 +29,14 @@ TARGET_OBJECTS = \
|
|||
strchr.o \
|
||||
strcmp.o \
|
||||
strcpy.o \
|
||||
strcspn.o \
|
||||
strlen.o \
|
||||
strncat.o \
|
||||
strncmp.o \
|
||||
strncpy.o \
|
||||
strnlen.o \
|
||||
strrchr.o \
|
||||
strspn.o \
|
||||
wcscat.o \
|
||||
wcschr.o \
|
||||
wcscmp.o \
|
||||
|
|
26
reactos/lib/string/strcspn.c
Normal file
26
reactos/lib/string/strcspn.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* $Id: strcspn.c,v 1.1 2003/06/09 20:23:06 hbirr Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
size_t strcspn(const char *s1, const char *s2)
|
||||
{
|
||||
unsigned long char_map[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
register unsigned char* str = (unsigned char*)s1;
|
||||
|
||||
while (*s2)
|
||||
{
|
||||
char_map[*(unsigned char*)s2 / 32] |= (1 << (*(unsigned char*)s2 % 32));
|
||||
s2++;
|
||||
}
|
||||
|
||||
while (*str)
|
||||
{
|
||||
if (char_map[*str / 32] & (1 << (*str % 32)))
|
||||
break;
|
||||
str++;
|
||||
}
|
||||
|
||||
return str - (unsigned char*)s1;
|
||||
}
|
25
reactos/lib/string/strspn.c
Normal file
25
reactos/lib/string/strspn.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* $Id: strspn.c,v 1.1 2003/06/09 20:23:06 hbirr Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
size_t strspn(const char *s1, const char *s2)
|
||||
{
|
||||
unsigned long char_map[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
register unsigned char* str = (unsigned char*)s1;
|
||||
|
||||
while (*s2)
|
||||
{
|
||||
char_map[*(unsigned char*)s2 / 32] |= (1 << (*(unsigned char*)s2 % 32));
|
||||
s2++;
|
||||
}
|
||||
|
||||
while (*str)
|
||||
{
|
||||
if (!(char_map[*str / 32] & (1 << (*str % 32))))
|
||||
break;
|
||||
str++;
|
||||
}
|
||||
return str - (unsigned char*)s1;
|
||||
}
|
|
@ -117,21 +117,6 @@ char *_strupr(char *x)
|
|||
return x;
|
||||
}
|
||||
|
||||
size_t strspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p = s1, *spanp;
|
||||
char c, sc;
|
||||
|
||||
cont:
|
||||
c = *p++;
|
||||
for (spanp = s2; (sc = *spanp++) != 0;)
|
||||
if (sc == c)
|
||||
goto cont;
|
||||
|
||||
return (p - 1 - s1);
|
||||
}
|
||||
|
||||
|
||||
char *strstr(const char *s, const char *find)
|
||||
{
|
||||
char c, sc;
|
||||
|
|
Loading…
Reference in a new issue