# HG changeset patch # User Richard M. Stallman # Date 884387173 0 # Node ID 20957e3ca2f51800abae2fc01aacfc969f3de31d # Parent b382c9ca6c39477a052b59a7d4f128e340c38437 (Fmultibyte_string_p): New function. (Faref): Index string by chars. (Faset): Index multibyte string by chars. diff -r b382c9ca6c39 -r 20957e3ca2f5 src/data.c --- a/src/data.c Fri Jan 09 23:05:12 1998 +0000 +++ b/src/data.c Fri Jan 09 23:06:13 1998 +0000 @@ -263,7 +263,8 @@ return Qnil; } -DEFUN ("atom", Fatom, Satom, 1, 1, 0, "Return t if OBJECT is not a cons cell. This includes nil.") +DEFUN ("atom", Fatom, Satom, 1, 1, 0, + "Return t if OBJECT is not a cons cell. This includes nil.") (object) Lisp_Object object; { @@ -272,7 +273,8 @@ return Qt; } -DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "Return t if OBJECT is a list. This includes nil.") +DEFUN ("listp", Flistp, Slistp, 1, 1, 0, + "Return t if OBJECT is a list. This includes nil.") (object) Lisp_Object object; { @@ -281,7 +283,8 @@ return Qnil; } -DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "Return t if OBJECT is not a list. Lists include nil.") +DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, + "Return t if OBJECT is not a list. Lists include nil.") (object) Lisp_Object object; { @@ -290,7 +293,8 @@ return Qt; } -DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "Return t if OBJECT is a symbol.") +DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, + "Return t if OBJECT is a symbol.") (object) Lisp_Object object; { @@ -299,7 +303,8 @@ return Qnil; } -DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "Return t if OBJECT is a vector.") +DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, + "Return t if OBJECT is a vector.") (object) Lisp_Object object; { @@ -308,7 +313,8 @@ return Qnil; } -DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "Return t if OBJECT is a string.") +DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, + "Return t if OBJECT is a string.") (object) Lisp_Object object; { @@ -317,7 +323,18 @@ return Qnil; } -DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0, "Return t if OBJECT is a char-table.") +DEFUN ("multibyte-string-p", Fmultibyte_string_p, Smultibyte_string_p, + 1, 1, 0, "Return t if OBJECT is a multibyte string.") + (object) + Lisp_Object object; +{ + if (STRINGP (object) && STRING_MULTIBYTE (object)) + return Qt; + return Qnil; +} + +DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0, + "Return t if OBJECT is a char-table.") (object) Lisp_Object object; { @@ -910,7 +927,7 @@ return set_internal (symbol, newval, 0); } -/* Stpre the value NEWVAL into SYMBOL. +/* Store the value NEWVAL into SYMBOL. If BINDFLAG is zero, then if this symbol is supposed to become local in every buffer where it is set, then we make it local. If BINDFLAG is nonzero, we don't do that. */ @@ -1529,10 +1546,17 @@ if (STRINGP (array)) { Lisp_Object val; + int c, idxval_byte; + if (idxval < 0 || idxval >= XSTRING (array)->size) args_out_of_range (array, idx); - XSETFASTINT (val, (unsigned char) XSTRING (array)->data[idxval]); - return val; + if (! STRING_MULTIBYTE (array)) + return make_number ((unsigned char) XSTRING (array)->data[idxval]); + idxval_byte = string_char_to_byte (array, idxval); + + c = STRING_CHAR (&XSTRING (array)->data[idxval_byte], + XSTRING (array)->size_byte - idxval_byte); + return make_number (c); } else if (BOOL_VECTOR_P (array)) { @@ -1717,6 +1741,25 @@ XCHAR_TABLE (array)->contents[code[i]] = newelt; } } + else if (STRING_MULTIBYTE (array)) + { + Lisp_Object val; + int c, idxval_byte, actual_len; + + if (idxval < 0 || idxval >= XSTRING (array)->size) + args_out_of_range (array, idx); + + idxval_byte = string_char_to_byte (array, idxval); + + c = STRING_CHAR_AND_LENGTH (&XSTRING (array)->data[idxval_byte], + XSTRING (array)->size_byte - idxval_byte, + actual_len); + if (actual_len != 1) + error ("Attempt to store a multibyte character into a string"); + + CHECK_NUMBER (newelt, 2); + XSTRING (array)->data[idxval_byte] = XINT (newelt); + } else { if (idxval < 0 || idxval >= XSTRING (array)->size)