diff options
author | Kenichi Handa <handa@m17n.org> | 2000-07-27 06:02:29 +0000 |
---|---|---|
committer | Kenichi Handa <handa@m17n.org> | 2000-07-27 06:02:29 +0000 |
commit | 2f729392ecb74812b10b3caa126866f21f4a9b4c (patch) | |
tree | 7fb82044eb5d7277117277302980eceb930f46f2 /src/fns.c | |
parent | 05e6f5dcf672b220bd759beded0cae38ceb8a10b (diff) | |
download | emacs-2f729392ecb74812b10b3caa126866f21f4a9b4c.tar.gz |
(char_table_ref_and_index): New function.
Diffstat (limited to 'src/fns.c')
-rw-r--r-- | src/fns.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/fns.c b/src/fns.c index 6106599a6ba..542a613a418 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2427,6 +2427,41 @@ The key is always a possible IDX argument to `aref'.") map_char_table (NULL, function, char_table, char_table, 0, indices); return Qnil; } + +/* Return a value for character C in char-table TABLE. Store the + actual index for that value in *IDX. Ignore the default value of + TABLE. */ + +Lisp_Object +char_table_ref_and_index (table, c, idx) + Lisp_Object table; + int c, *idx; +{ + int charset, c1, c2; + Lisp_Object elt; + + if (SINGLE_BYTE_CHAR_P (c)) + { + *idx = c; + return XCHAR_TABLE (table)->contents[c]; + } + SPLIT_CHAR (c, charset, c1, c2); + elt = XCHAR_TABLE (table)->contents[charset + 128]; + *idx = MAKE_CHAR (charset, 0, 0); + if (!SUB_CHAR_TABLE_P (elt)) + return elt; + if (c1 < 32 || NILP (XCHAR_TABLE (elt)->contents[c1])) + return XCHAR_TABLE (elt)->defalt; + elt = XCHAR_TABLE (elt)->contents[c1]; + *idx = MAKE_CHAR (charset, c1, 0); + if (!SUB_CHAR_TABLE_P (elt)) + return elt; + if (c2 < 32 || NILP (XCHAR_TABLE (elt)->contents[c2])) + return XCHAR_TABLE (elt)->defalt; + *idx = c; + return XCHAR_TABLE (elt)->contents[c2]; +} + /* ARGSUSED */ Lisp_Object |