aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorRichard M. Stallman1998-01-09 23:06:13 +0000
committerRichard M. Stallman1998-01-09 23:06:13 +0000
commit25638b0794d6cee1be02c45ed4b37df1f5d4fbe0 (patch)
tree65a2dbfe361989acf240cb2b1edcb7e7ee4cc8df /src/data.c
parent5f1cd180aafe8339cb2fc168dd425b3be5a024cc (diff)
downloademacs-25638b0794d6cee1be02c45ed4b37df1f5d4fbe0.tar.gz
emacs-25638b0794d6cee1be02c45ed4b37df1f5d4fbe0.zip
(Fmultibyte_string_p): New function.
(Faref): Index string by chars. (Faset): Index multibyte string by chars.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c63
1 files changed, 53 insertions, 10 deletions
diff --git a/src/data.c b/src/data.c
index 2479dc25106..f69f5a0f1b9 100644
--- a/src/data.c
+++ b/src/data.c
@@ -263,7 +263,8 @@ DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, "Return t if OBJECT is a cons cell.")
263 return Qnil; 263 return Qnil;
264} 264}
265 265
266DEFUN ("atom", Fatom, Satom, 1, 1, 0, "Return t if OBJECT is not a cons cell. This includes nil.") 266DEFUN ("atom", Fatom, Satom, 1, 1, 0,
267 "Return t if OBJECT is not a cons cell. This includes nil.")
267 (object) 268 (object)
268 Lisp_Object object; 269 Lisp_Object object;
269{ 270{
@@ -272,7 +273,8 @@ DEFUN ("atom", Fatom, Satom, 1, 1, 0, "Return t if OBJECT is not a cons cell. T
272 return Qt; 273 return Qt;
273} 274}
274 275
275DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "Return t if OBJECT is a list. This includes nil.") 276DEFUN ("listp", Flistp, Slistp, 1, 1, 0,
277 "Return t if OBJECT is a list. This includes nil.")
276 (object) 278 (object)
277 Lisp_Object object; 279 Lisp_Object object;
278{ 280{
@@ -281,7 +283,8 @@ DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "Return t if OBJECT is a list. This in
281 return Qnil; 283 return Qnil;
282} 284}
283 285
284DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "Return t if OBJECT is not a list. Lists include nil.") 286DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0,
287 "Return t if OBJECT is not a list. Lists include nil.")
285 (object) 288 (object)
286 Lisp_Object object; 289 Lisp_Object object;
287{ 290{
@@ -290,7 +293,8 @@ DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "Return t if OBJECT is not a list.
290 return Qt; 293 return Qt;
291} 294}
292 295
293DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "Return t if OBJECT is a symbol.") 296DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0,
297 "Return t if OBJECT is a symbol.")
294 (object) 298 (object)
295 Lisp_Object object; 299 Lisp_Object object;
296{ 300{
@@ -299,7 +303,8 @@ DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "Return t if OBJECT is a symbol."
299 return Qnil; 303 return Qnil;
300} 304}
301 305
302DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "Return t if OBJECT is a vector.") 306DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0,
307 "Return t if OBJECT is a vector.")
303 (object) 308 (object)
304 Lisp_Object object; 309 Lisp_Object object;
305{ 310{
@@ -308,7 +313,8 @@ DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "Return t if OBJECT is a vector."
308 return Qnil; 313 return Qnil;
309} 314}
310 315
311DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "Return t if OBJECT is a string.") 316DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0,
317 "Return t if OBJECT is a string.")
312 (object) 318 (object)
313 Lisp_Object object; 319 Lisp_Object object;
314{ 320{
@@ -317,7 +323,18 @@ DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "Return t if OBJECT is a string."
317 return Qnil; 323 return Qnil;
318} 324}
319 325
320DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0, "Return t if OBJECT is a char-table.") 326DEFUN ("multibyte-string-p", Fmultibyte_string_p, Smultibyte_string_p,
327 1, 1, 0, "Return t if OBJECT is a multibyte string.")
328 (object)
329 Lisp_Object object;
330{
331 if (STRINGP (object) && STRING_MULTIBYTE (object))
332 return Qt;
333 return Qnil;
334}
335
336DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0,
337 "Return t if OBJECT is a char-table.")
321 (object) 338 (object)
322 Lisp_Object object; 339 Lisp_Object object;
323{ 340{
@@ -910,7 +927,7 @@ DEFUN ("set", Fset, Sset, 2, 2, 0,
910 return set_internal (symbol, newval, 0); 927 return set_internal (symbol, newval, 0);
911} 928}
912 929
913/* Stpre the value NEWVAL into SYMBOL. 930/* Store the value NEWVAL into SYMBOL.
914 If BINDFLAG is zero, then if this symbol is supposed to become 931 If BINDFLAG is zero, then if this symbol is supposed to become
915 local in every buffer where it is set, then we make it local. 932 local in every buffer where it is set, then we make it local.
916 If BINDFLAG is nonzero, we don't do that. */ 933 If BINDFLAG is nonzero, we don't do that. */
@@ -1529,10 +1546,17 @@ or a byte-code object. IDX starts at 0.")
1529 if (STRINGP (array)) 1546 if (STRINGP (array))
1530 { 1547 {
1531 Lisp_Object val; 1548 Lisp_Object val;
1549 int c, idxval_byte;
1550
1532 if (idxval < 0 || idxval >= XSTRING (array)->size) 1551 if (idxval < 0 || idxval >= XSTRING (array)->size)
1533 args_out_of_range (array, idx); 1552 args_out_of_range (array, idx);
1534 XSETFASTINT (val, (unsigned char) XSTRING (array)->data[idxval]); 1553 if (! STRING_MULTIBYTE (array))
1535 return val; 1554 return make_number ((unsigned char) XSTRING (array)->data[idxval]);
1555 idxval_byte = string_char_to_byte (array, idxval);
1556
1557 c = STRING_CHAR (&XSTRING (array)->data[idxval_byte],
1558 XSTRING (array)->size_byte - idxval_byte);
1559 return make_number (c);
1536 } 1560 }
1537 else if (BOOL_VECTOR_P (array)) 1561 else if (BOOL_VECTOR_P (array))
1538 { 1562 {
@@ -1717,6 +1741,25 @@ IDX starts at 0.")
1717 XCHAR_TABLE (array)->contents[code[i]] = newelt; 1741 XCHAR_TABLE (array)->contents[code[i]] = newelt;
1718 } 1742 }
1719 } 1743 }
1744 else if (STRING_MULTIBYTE (array))
1745 {
1746 Lisp_Object val;
1747 int c, idxval_byte, actual_len;
1748
1749 if (idxval < 0 || idxval >= XSTRING (array)->size)
1750 args_out_of_range (array, idx);
1751
1752 idxval_byte = string_char_to_byte (array, idxval);
1753
1754 c = STRING_CHAR_AND_LENGTH (&XSTRING (array)->data[idxval_byte],
1755 XSTRING (array)->size_byte - idxval_byte,
1756 actual_len);
1757 if (actual_len != 1)
1758 error ("Attempt to store a multibyte character into a string");
1759
1760 CHECK_NUMBER (newelt, 2);
1761 XSTRING (array)->data[idxval_byte] = XINT (newelt);
1762 }
1720 else 1763 else
1721 { 1764 {
1722 if (idxval < 0 || idxval >= XSTRING (array)->size) 1765 if (idxval < 0 || idxval >= XSTRING (array)->size)