summaryrefslogtreecommitdiff
path: root/mbutil.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-23 19:14:15 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-23 19:14:15 -0500
commit6bac173ff2ec52b8e03b6e4cec67fffa5e4e3826 (patch)
tree90a88e8b0194af1bb4a7f7d7987e2f170a524345 /mbutil.c
parentfc06b0af27b485addc67a148e5e5ca061c2efdb6 (diff)
downloadreadline-6bac173ff2ec52b8e03b6e4cec67fffa5e4e3826.tar.gz
Readline-5.1 import
Diffstat (limited to 'mbutil.c')
-rw-r--r--mbutil.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/mbutil.c b/mbutil.c
index 695845a..17dde53 100644
--- a/mbutil.c
+++ b/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.