diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-04-08 16:24:33 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-04-08 16:24:33 +0000 |
commit | b667555541a4d65bb9dae6f0e0f240e6a05b148e (patch) | |
tree | b3ae5c92f04ae68fbf9580d6efcf1a1510851495 /readline-6.2/rlmbutil.h | |
parent | 2011-04-08 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-addon-packages-b667555541a4d65bb9dae6f0e0f240e6a05b148e.tar.bz2 |
2011-04-08 Joel Sherrill <joel.sherrill@oarcorp.com>
* RTEMS_Makefiles/Makefile.readline-6.2, readline-6.2/CHANGELOG,
readline-6.2/CHANGES, readline-6.2/COPYING, readline-6.2/INSTALL,
readline-6.2/MANIFEST, readline-6.2/Makefile.in, readline-6.2/NEWS,
readline-6.2/README, readline-6.2/USAGE, readline-6.2/aclocal.m4,
readline-6.2/ansi_stdlib.h, readline-6.2/bind.c,
readline-6.2/callback.c, readline-6.2/chardefs.h,
readline-6.2/compat.c, readline-6.2/complete.c,
readline-6.2/config.h.in, readline-6.2/configure,
readline-6.2/configure.in, readline-6.2/display.c,
readline-6.2/emacs_keymap.c, readline-6.2/funmap.c,
readline-6.2/histexpand.c, readline-6.2/histfile.c,
readline-6.2/histlib.h, readline-6.2/history.c,
readline-6.2/history.h, readline-6.2/histsearch.c,
readline-6.2/input.c, readline-6.2/isearch.c, readline-6.2/keymaps.c,
readline-6.2/keymaps.h, readline-6.2/kill.c, readline-6.2/macro.c,
readline-6.2/mbutil.c, readline-6.2/misc.c, readline-6.2/nls.c,
readline-6.2/parens.c, readline-6.2/patchlevel,
readline-6.2/posixdir.h, readline-6.2/posixjmp.h,
readline-6.2/posixselect.h, readline-6.2/posixstat.h,
readline-6.2/readline.c, readline-6.2/readline.h,
readline-6.2/rlconf.h, readline-6.2/rldefs.h,
readline-6.2/rlmbutil.h, readline-6.2/rlprivate.h,
readline-6.2/rlshell.h, readline-6.2/rlstdc.h, readline-6.2/rltty.c,
readline-6.2/rltty.h, readline-6.2/rltypedefs.h,
readline-6.2/rlwinsize.h, readline-6.2/savestring.c,
readline-6.2/search.c, readline-6.2/shell.c, readline-6.2/signals.c,
readline-6.2/tcap.h, readline-6.2/terminal.c, readline-6.2/text.c,
readline-6.2/tilde.c, readline-6.2/tilde.h, readline-6.2/undo.c,
readline-6.2/util.c, readline-6.2/vi_keymap.c,
readline-6.2/vi_mode.c, readline-6.2/xfree.c, readline-6.2/xmalloc.c,
readline-6.2/xmalloc.h, readline-6.2/doc/Makefile.in,
readline-6.2/doc/fdl.texi, readline-6.2/doc/history.0,
readline-6.2/doc/history.3, readline-6.2/doc/history.dvi,
readline-6.2/doc/history.html, readline-6.2/doc/history.info,
readline-6.2/doc/history.pdf, readline-6.2/doc/history.ps,
readline-6.2/doc/history.texi, readline-6.2/doc/history_3.ps,
readline-6.2/doc/hstech.texi, readline-6.2/doc/hsuser.texi,
readline-6.2/doc/readline.0, readline-6.2/doc/readline.3,
readline-6.2/doc/readline.dvi, readline-6.2/doc/readline.html,
readline-6.2/doc/readline.info, readline-6.2/doc/readline.pdf,
readline-6.2/doc/readline.ps, readline-6.2/doc/readline_3.ps,
readline-6.2/doc/rlman.texi, readline-6.2/doc/rltech.texi,
readline-6.2/doc/rluser.texi, readline-6.2/doc/rluserman.dvi,
readline-6.2/doc/rluserman.html, readline-6.2/doc/rluserman.info,
readline-6.2/doc/rluserman.pdf, readline-6.2/doc/rluserman.ps,
readline-6.2/doc/rluserman.texi, readline-6.2/doc/texi2dvi,
readline-6.2/doc/texi2html, readline-6.2/doc/texinfo.tex,
readline-6.2/doc/version.texi, readline-6.2/examples/Inputrc,
readline-6.2/examples/Makefile.in,
readline-6.2/examples/excallback.c, readline-6.2/examples/fileman.c,
readline-6.2/examples/histexamp.c, readline-6.2/examples/manexamp.c,
readline-6.2/examples/readlinebuf.h,
readline-6.2/examples/rl-fgets.c, readline-6.2/examples/rl.c,
readline-6.2/examples/rlcat.c, readline-6.2/examples/rlevent.c,
readline-6.2/examples/rlptytest.c, readline-6.2/examples/rltest.c,
readline-6.2/examples/rlversion.c,
readline-6.2/examples/rlwrap-0.30.tar.gz,
readline-6.2/examples/autoconf/BASH_CHECK_LIB_TERMCAP,
readline-6.2/examples/autoconf/RL_LIB_READLINE_VERSION,
readline-6.2/examples/autoconf/wi_LIB_READLINE,
readline-6.2/examples/rlfe/ChangeLog,
readline-6.2/examples/rlfe/Makefile.in,
readline-6.2/examples/rlfe/README,
readline-6.2/examples/rlfe/config.h.in,
readline-6.2/examples/rlfe/configure,
readline-6.2/examples/rlfe/configure.in,
readline-6.2/examples/rlfe/extern.h, readline-6.2/examples/rlfe/os.h,
readline-6.2/examples/rlfe/pty.c, readline-6.2/examples/rlfe/rlfe.c,
readline-6.2/examples/rlfe/screen.h, readline-6.2/shlib/Makefile.in,
readline-6.2/support/config.guess, readline-6.2/support/config.rpath,
readline-6.2/support/config.sub, readline-6.2/support/install.sh,
readline-6.2/support/mkdirs, readline-6.2/support/mkdist,
readline-6.2/support/mkinstalldirs,
readline-6.2/support/shlib-install, readline-6.2/support/shobj-conf,
readline-6.2/support/wcwidth.c: New files.
Diffstat (limited to 'readline-6.2/rlmbutil.h')
-rw-r--r-- | readline-6.2/rlmbutil.h | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/readline-6.2/rlmbutil.h b/readline-6.2/rlmbutil.h new file mode 100644 index 0000000..7716a70 --- /dev/null +++ b/readline-6.2/rlmbutil.h @@ -0,0 +1,154 @@ +/* rlmbutil.h -- utility functions for multibyte characters. */ + +/* Copyright (C) 2001-2009 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + +#if !defined (_RL_MBUTIL_H_) +#define _RL_MBUTIL_H_ + +#include "rlstdc.h" + +/************************************************/ +/* check multibyte capability for I18N code */ +/************************************************/ + +/* For platforms which support the ISO C amendement 1 functionality we + support user defined character classes. */ + /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */ +#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined (HAVE_LOCALE_H) +# include <wchar.h> +# include <wctype.h> +# if defined (HAVE_ISWCTYPE) && \ + defined (HAVE_ISWLOWER) && \ + defined (HAVE_ISWUPPER) && \ + defined (HAVE_MBSRTOWCS) && \ + defined (HAVE_MBRTOWC) && \ + defined (HAVE_MBRLEN) && \ + defined (HAVE_TOWLOWER) && \ + defined (HAVE_TOWUPPER) && \ + defined (HAVE_WCHAR_T) && \ + defined (HAVE_WCWIDTH) + /* system is supposed to support XPG5 */ +# define HANDLE_MULTIBYTE 1 +# endif +#endif + +/* If we don't want multibyte chars even on a system that supports them, let + the configuring user turn multibyte support off. */ +#if defined (NO_MULTIBYTE_SUPPORT) +# undef HANDLE_MULTIBYTE +#endif + +/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ +#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T) +# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0) +# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0) +# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0) +# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) +# define mbrlen(s, n, ps) (mbrlen) (s, n, 0) +# define mbstate_t int +#endif + +/* Make sure MB_LEN_MAX is at least 16 on systems that claim to be able to + handle multibyte chars (some systems define MB_LEN_MAX as 1) */ +#ifdef HANDLE_MULTIBYTE +# include <limits.h> +# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16) +# undef MB_LEN_MAX +# endif +# if !defined (MB_LEN_MAX) +# define MB_LEN_MAX 16 +# endif +#endif + +/************************************************/ +/* end of multibyte capability checks for I18N */ +/************************************************/ + +/* + * Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar: + * + * MB_FIND_ANY find any multibyte character + * MB_FIND_NONZERO find a non-zero-width multibyte character + */ + +#define MB_FIND_ANY 0x00 +#define MB_FIND_NONZERO 0x01 + +extern int _rl_find_prev_mbchar PARAMS((char *, int, int)); +extern int _rl_find_next_mbchar PARAMS((char *, int, int, int)); + +#ifdef HANDLE_MULTIBYTE + +extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *)); +extern int _rl_get_char_len PARAMS((char *, mbstate_t *)); +extern int _rl_adjust_point PARAMS((char *, int, mbstate_t *)); + +extern int _rl_read_mbchar PARAMS((char *, int)); +extern int _rl_read_mbstring PARAMS((int, char *, int)); + +extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int)); + +extern wchar_t _rl_char_value PARAMS((char *, int)); +extern int _rl_walphabetic PARAMS((wchar_t)); + +#define _rl_to_wupper(wc) (iswlower (wc) ? towupper (wc) : (wc)) +#define _rl_to_wlower(wc) (iswupper (wc) ? towlower (wc) : (wc)) + +#define MB_NEXTCHAR(b,s,c,f) \ + ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \ + ? _rl_find_next_mbchar ((b), (s), (c), (f)) \ + : ((s) + (c))) +#define MB_PREVCHAR(b,s,f) \ + ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \ + ? _rl_find_prev_mbchar ((b), (s), (f)) \ + : ((s) - 1)) + +#define MB_INVALIDCH(x) ((x) == (size_t)-1 || (x) == (size_t)-2) +#define MB_NULLWCH(x) ((x) == 0) + +#else /* !HANDLE_MULTIBYTE */ + +#undef MB_LEN_MAX +#undef MB_CUR_MAX + +#define MB_LEN_MAX 1 +#define MB_CUR_MAX 1 + +#define _rl_find_prev_mbchar(b, i, f) (((i) == 0) ? (i) : ((i) - 1)) +#define _rl_find_next_mbchar(b, i1, i2, f) ((i1) + (i2)) + +#define _rl_char_value(buf,ind) ((buf)[(ind)]) + +#define _rl_walphabetic(c) (rl_alphabetic (c)) + +#define _rl_to_wupper(c) (_rl_to_upper (c)) +#define _rl_to_wlower(c) (_rl_to_lower (c)) + +#define MB_NEXTCHAR(b,s,c,f) ((s) + (c)) +#define MB_PREVCHAR(b,s,f) ((s) - 1) + +#define MB_INVALIDCH(x) (0) +#define MB_NULLWCH(x) (0) + +#endif /* !HANDLE_MULTIBYTE */ + +extern int rl_byte_oriented; + +#endif /* _RL_MBUTIL_H_ */ |