summaryrefslogtreecommitdiff
path: root/wcsmbs
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-11-18 02:59:57 +0000
committerUlrich Drepper <drepper@redhat.com>1999-11-18 02:59:57 +0000
commit35946fb706d6333c5c11663fd0b46c1e9116ae0f (patch)
tree9dd3397b3e3b8214bf8a05773489ba854c97d065 /wcsmbs
parent404127bca0508b64a40b6e77161cd555124408fa (diff)
downloadglibc-35946fb706d6333c5c11663fd0b46c1e9116ae0f.tar.gz
Update.
* wcsmbs/wcswidth.c (wcswidth): Don't forget to decrement counter n.
Diffstat (limited to 'wcsmbs')
-rw-r--r--wcsmbs/wcswidth.c4
-rw-r--r--wcsmbs/wcwidth.h5
2 files changed, 5 insertions, 4 deletions
diff --git a/wcsmbs/wcswidth.c b/wcsmbs/wcswidth.c
index 2828b800da..78fc427276 100644
--- a/wcsmbs/wcswidth.c
+++ b/wcsmbs/wcswidth.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -26,7 +26,7 @@ wcswidth (const wchar_t *s, size_t n)
{
int result = 0;
- while (n > 0 && *s != L'\0')
+ while (n-- > 0 && *s != L'\0')
{
int now = internal_wcwidth (*s);
if (now == -1)
diff --git a/wcsmbs/wcwidth.h b/wcsmbs/wcwidth.h
index 4c561f94d7..b8627c54f0 100644
--- a/wcsmbs/wcwidth.h
+++ b/wcsmbs/wcwidth.h
@@ -1,5 +1,5 @@
/* Internal header containing implementation of wcwidth() function.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <wchar.h>
+#include <wctype.h>
#include "../wctype/cname-lookup.h"
/* Array containing width information. */
@@ -33,7 +34,7 @@ internal_wcwidth (wint_t ch)
return 0;
idx = cname_lookup (ch);
- if (idx == ~((size_t) 0))
+ if (idx == ~((size_t) 0) || (__ctype32_b[idx] & _ISwprint) == 0)
return -1;
return (int) __ctype_width[idx];