diff options
Diffstat (limited to 'wcsmbs')
-rw-r--r-- | wcsmbs/Makefile | 3 | ||||
-rw-r--r-- | wcsmbs/wcsatcliff.c | 20 | ||||
-rw-r--r-- | wcsmbs/wcsnlen.c | 13 |
3 files changed, 30 insertions, 6 deletions
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index 4afbc4cac4..907bb25580 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -43,7 +43,8 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \ isoc99_swscanf isoc99_vswscanf tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \ - tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 + tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \ + wcsatcliff include ../Rules diff --git a/wcsmbs/wcsatcliff.c b/wcsmbs/wcsatcliff.c new file mode 100644 index 0000000000..22db60763f --- /dev/null +++ b/wcsmbs/wcsatcliff.c @@ -0,0 +1,20 @@ +#include <wchar.h> + +#define WCSTEST 1 +#define L(c) L##c +#define CHAR wchar_t +#define MEMSET wmemset +#define STRLEN wcslen +#define STRNLEN wcsnlen +#define STRCHR wcschr +#define STRRCHR wcsrchr +#define STRCPY wcscpy +#define STRNCPY wcsncpy +#define MEMCMP wmemcmp +#define STPCPY wcpcpy +#define STPNCPY wcpncpy +#define MEMCPY wmemcpy +#define MEMPCPY wmempcpy + + +#include "../string/stratcliff.c" diff --git a/wcsmbs/wcsnlen.c b/wcsmbs/wcsnlen.c index 3cfbccad91..94abf1e574 100644 --- a/wcsmbs/wcsnlen.c +++ b/wcsmbs/wcsnlen.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -28,13 +28,16 @@ __wcsnlen (s, maxlen) { size_t len = 0; - while (s[len] != L'\0' && maxlen > 0) + while (maxlen > 0 && s[len] != L'\0') { - if (s[++len] == L'\0' || --maxlen == 0) + ++len; + if (--maxlen == 0 || s[len] == L'\0') return len; - if (s[++len] == L'\0' || --maxlen == 0) + ++len; + if (--maxlen == 0 || s[len] == L'\0') return len; - if (s[++len] == L'\0' || --maxlen == 0) + ++len; + if (--maxlen == 0 || s[len] == L'\0') return len; ++len; --maxlen; |