Mercurial > emacs
comparison src/data.c @ 20617:20957e3ca2f5
(Fmultibyte_string_p): New function.
(Faref): Index string by chars.
(Faset): Index multibyte string by chars.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 09 Jan 1998 23:06:13 +0000 |
parents | 923e1f635ace |
children | ed9ed828415e |
comparison
equal
deleted
inserted
replaced
20616:b382c9ca6c39 | 20617:20957e3ca2f5 |
---|---|
261 if (CONSP (object)) | 261 if (CONSP (object)) |
262 return Qt; | 262 return Qt; |
263 return Qnil; | 263 return Qnil; |
264 } | 264 } |
265 | 265 |
266 DEFUN ("atom", Fatom, Satom, 1, 1, 0, "Return t if OBJECT is not a cons cell. This includes nil.") | 266 DEFUN ("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 { |
270 if (CONSP (object)) | 271 if (CONSP (object)) |
271 return Qnil; | 272 return Qnil; |
272 return Qt; | 273 return Qt; |
273 } | 274 } |
274 | 275 |
275 DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "Return t if OBJECT is a list. This includes nil.") | 276 DEFUN ("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 { |
279 if (CONSP (object) || NILP (object)) | 281 if (CONSP (object) || NILP (object)) |
280 return Qt; | 282 return Qt; |
281 return Qnil; | 283 return Qnil; |
282 } | 284 } |
283 | 285 |
284 DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "Return t if OBJECT is not a list. Lists include nil.") | 286 DEFUN ("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 { |
288 if (CONSP (object) || NILP (object)) | 291 if (CONSP (object) || NILP (object)) |
289 return Qnil; | 292 return Qnil; |
290 return Qt; | 293 return Qt; |
291 } | 294 } |
292 | 295 |
293 DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "Return t if OBJECT is a symbol.") | 296 DEFUN ("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 { |
297 if (SYMBOLP (object)) | 301 if (SYMBOLP (object)) |
298 return Qt; | 302 return Qt; |
299 return Qnil; | 303 return Qnil; |
300 } | 304 } |
301 | 305 |
302 DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "Return t if OBJECT is a vector.") | 306 DEFUN ("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 { |
306 if (VECTORP (object)) | 311 if (VECTORP (object)) |
307 return Qt; | 312 return Qt; |
308 return Qnil; | 313 return Qnil; |
309 } | 314 } |
310 | 315 |
311 DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "Return t if OBJECT is a string.") | 316 DEFUN ("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 { |
315 if (STRINGP (object)) | 321 if (STRINGP (object)) |
316 return Qt; | 322 return Qt; |
317 return Qnil; | 323 return Qnil; |
318 } | 324 } |
319 | 325 |
320 DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0, "Return t if OBJECT is a char-table.") | 326 DEFUN ("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 | |
336 DEFUN ("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 { |
324 if (CHAR_TABLE_P (object)) | 341 if (CHAR_TABLE_P (object)) |
325 return Qt; | 342 return Qt; |
908 register Lisp_Object symbol, newval; | 925 register Lisp_Object symbol, newval; |
909 { | 926 { |
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. */ |
917 | 934 |
918 Lisp_Object | 935 Lisp_Object |
1527 CHECK_NUMBER (idx, 1); | 1544 CHECK_NUMBER (idx, 1); |
1528 idxval = XINT (idx); | 1545 idxval = XINT (idx); |
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 { |
1539 int val; | 1563 int val; |
1540 | 1564 |
1714 array = temp; | 1738 array = temp; |
1715 } | 1739 } |
1716 } | 1740 } |
1717 XCHAR_TABLE (array)->contents[code[i]] = newelt; | 1741 XCHAR_TABLE (array)->contents[code[i]] = newelt; |
1718 } | 1742 } |
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); | |
1719 } | 1762 } |
1720 else | 1763 else |
1721 { | 1764 { |
1722 if (idxval < 0 || idxval >= XSTRING (array)->size) | 1765 if (idxval < 0 || idxval >= XSTRING (array)->size) |
1723 args_out_of_range (array, idx); | 1766 args_out_of_range (array, idx); |