summaryrefslogtreecommitdiffstats
path: root/contrib/libreadline/mbutil.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2006-03-27 22:47:12 +0000
committerache <ache@FreeBSD.org>2006-03-27 22:47:12 +0000
commit8aeb9782f4a5d98c23b918bdae2477810088d0d1 (patch)
tree5e38d670d1899750fd24e8f171fd03d714ab0681 /contrib/libreadline/mbutil.c
parent17222c720e12474e93a40d68fd9646bad49690a7 (diff)
downloadFreeBSD-src-8aeb9782f4a5d98c23b918bdae2477810088d0d1.zip
FreeBSD-src-8aeb9782f4a5d98c23b918bdae2477810088d0d1.tar.gz
Virgin import of GNU Readline 5.1
Diffstat (limited to 'contrib/libreadline/mbutil.c')
-rw-r--r--contrib/libreadline/mbutil.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/contrib/libreadline/mbutil.c b/contrib/libreadline/mbutil.c
index 695845a..17dde53 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-2004 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2005 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.
@@ -77,18 +77,20 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
char *string;
int seed, count, find_non_zero;
{
- size_t tmp = 0;
+ size_t tmp;
mbstate_t ps;
- int point = 0;
+ int point;
wchar_t wc;
+ tmp = 0;
+
memset(&ps, 0, sizeof (mbstate_t));
if (seed < 0)
seed = 0;
if (count <= 0)
return seed;
- point = seed + _rl_adjust_point(string, seed, &ps);
+ point = seed + _rl_adjust_point (string, seed, &ps);
/* if this is true, means that seed was not pointed character
started byte. So correct the point and consume count */
if (seed < point)
@@ -134,7 +136,8 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
break;
}
}
- return point;
+
+ return point;
}
static int
@@ -313,6 +316,28 @@ _rl_is_mbchar_matched (string, seed, end, mbchar, length)
return 0;
return 1;
}
+
+wchar_t
+_rl_char_value (buf, ind)
+ char *buf;
+ int ind;
+{
+ size_t tmp;
+ wchar_t wc;
+ mbstate_t ps;
+ int l;
+
+ if (MB_LEN_MAX == 1 || rl_byte_oriented)
+ return ((wchar_t) buf[ind]);
+ l = strlen (buf);
+ if (ind >= l - 1)
+ return ((wchar_t) buf[ind]);
+ memset (&ps, 0, sizeof (mbstate_t));
+ tmp = mbrtowc (&wc, buf + ind, l - ind, &ps);
+ if (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp))
+ return ((wchar_t) buf[ind]);
+ return wc;
+}
#endif /* HANDLE_MULTIBYTE */
/* Find next `count' characters started byte point of the specified seed.
OpenPOWER on IntegriCloud