diff options
author | ache <ache@FreeBSD.org> | 2004-10-18 07:02:42 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2004-10-18 07:02:42 +0000 |
commit | 0a8076ac56fc245cdfb48a1ac83798a3d6086c30 (patch) | |
tree | f78c1227a8143a263e4974d6bf25cf0ccde0e716 /contrib/libreadline/mbutil.c | |
parent | 001407b3a64c7fac1489a2ad6eeb2d23254b3e19 (diff) | |
download | FreeBSD-src-0a8076ac56fc245cdfb48a1ac83798a3d6086c30.zip FreeBSD-src-0a8076ac56fc245cdfb48a1ac83798a3d6086c30.tar.gz |
Virgin import of GNU Readline 5.0
Diffstat (limited to 'contrib/libreadline/mbutil.c')
-rw-r--r-- | contrib/libreadline/mbutil.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/contrib/libreadline/mbutil.c b/contrib/libreadline/mbutil.c index 8794d02..9a8f17c 100644 --- a/contrib/libreadline/mbutil.c +++ b/contrib/libreadline/mbutil.c @@ -1,6 +1,6 @@ /* mbutil.c -- readline multibyte character utility functions */ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001-2004 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -92,12 +92,12 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) /* if this is true, means that seed was not pointed character started byte. So correct the point and consume count */ if (seed < point) - count --; + count--; while (count > 0) { tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps); - if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2) + if (MB_INVALIDCH ((size_t)tmp)) { /* invalid bytes. asume a byte represents a character */ point++; @@ -105,9 +105,8 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) /* reset states. */ memset(&ps, 0, sizeof(mbstate_t)); } - else if (tmp == (size_t)0) - /* found '\0' char */ - break; + else if (MB_NULLWCH (tmp)) + break; /* found wide '\0' */ else { /* valid bytes */ @@ -160,7 +159,7 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero) while (point < seed) { tmp = mbrtowc (&wc, string + point, length - point, &ps); - if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2) + if (MB_INVALIDCH ((size_t)tmp)) { /* in this case, bytes are invalid or shorted to compose multibyte char, so assume that the first byte represents @@ -169,8 +168,12 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero) /* clear the state of the byte sequence, because in this case effect of mbstate is undefined */ memset(&ps, 0, sizeof (mbstate_t)); + + /* Since we're assuming that this byte represents a single + non-zero-width character, don't forget about it. */ + prev = point; } - else if (tmp == 0) + else if (MB_NULLWCH (tmp)) break; /* Found '\0' char. Can this happen? */ else { @@ -273,7 +276,7 @@ _rl_adjust_point(string, point, ps) while (pos < point) { tmp = mbrlen (string + pos, length - pos, ps); - if((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2) + if (MB_INVALIDCH ((size_t)tmp)) { /* in this case, bytes are invalid or shorted to compose multibyte char, so assume that the first byte represents @@ -284,7 +287,7 @@ _rl_adjust_point(string, point, ps) if (ps) memset (ps, 0, sizeof (mbstate_t)); } - else if (tmp == 0) + else if (MB_NULLWCH (tmp)) pos++; else pos += tmp; |