comparison src/editfns.c @ 21257:205a5aa4aa2f

(Fchar_to_string): Use make_string_from_bytes. (Fformat): Use make_specified_string. (make_buffer_string_both): Use make_uninit_string if buffer is unibyte.
author Richard M. Stallman <rms@gnu.org>
date Sat, 21 Mar 1998 18:05:29 +0000
parents 6cde55b7c9de
children e9f7d8708bae
comparison
equal deleted inserted replaced
21256:0fda3f197f9c 21257:205a5aa4aa2f
120 else if (NILP (Vuser_full_name)) 120 else if (NILP (Vuser_full_name))
121 Vuser_full_name = build_string ("unknown"); 121 Vuser_full_name = build_string ("unknown");
122 } 122 }
123 123
124 DEFUN ("char-to-string", Fchar_to_string, Schar_to_string, 1, 1, 0, 124 DEFUN ("char-to-string", Fchar_to_string, Schar_to_string, 1, 1, 0,
125 "Convert arg CHAR to a string containing multi-byte form of that character.") 125 "Convert arg CHAR to a string containing that character.")
126 (character) 126 (character)
127 Lisp_Object character; 127 Lisp_Object character;
128 { 128 {
129 int len; 129 int len;
130 unsigned char workbuf[4], *str; 130 unsigned char workbuf[4], *str;
131 131
132 CHECK_NUMBER (character, 0); 132 CHECK_NUMBER (character, 0);
133 133
134 len = CHAR_STRING (XFASTINT (character), workbuf, str); 134 len = CHAR_STRING (XFASTINT (character), workbuf, str);
135 return make_multibyte_string (str, 1, len); 135 return make_string_from_bytes (str, 1, len);
136 } 136 }
137 137
138 DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0, 138 DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0,
139 "Convert arg STRING to a character, the first character of that string.\n\ 139 "Convert arg STRING to a character, the first character of that string.\n\
140 A multibyte character is handled correctly.") 140 A multibyte character is handled correctly.")
1474 Lisp_Object result, tem, tem1; 1474 Lisp_Object result, tem, tem1;
1475 1475
1476 if (start < GPT && GPT < end) 1476 if (start < GPT && GPT < end)
1477 move_gap (start); 1477 move_gap (start);
1478 1478
1479 result = make_uninit_multibyte_string (end - start, end_byte - start_byte); 1479 if (! NILP (current_buffer->enable_multibyte_characters))
1480 result = make_uninit_multibyte_string (end - start, end_byte - start_byte);
1481 else
1482 result = make_uninit_string (end - start);
1480 bcopy (BYTE_POS_ADDR (start_byte), XSTRING (result)->data, 1483 bcopy (BYTE_POS_ADDR (start_byte), XSTRING (result)->data,
1481 end_byte - start_byte); 1484 end_byte - start_byte);
1482 1485
1483 /* If desired, update and copy the text properties. */ 1486 /* If desired, update and copy the text properties. */
1484 #ifdef USE_TEXT_PROPERTIES 1487 #ifdef USE_TEXT_PROPERTIES
2489 } 2492 }
2490 else 2493 else
2491 *p++ = *format++, nchars++; 2494 *p++ = *format++, nchars++;
2492 } 2495 }
2493 2496
2494 val = make_multibyte_string (buf, nchars, p - buf); 2497 val = make_specified_string (buf, nchars, p - buf, multibyte);
2495 2498
2496 /* If we allocated BUF with malloc, free it too. */ 2499 /* If we allocated BUF with malloc, free it too. */
2497 if (total >= 1000) 2500 if (total >= 1000)
2498 xfree (buf); 2501 xfree (buf);
2499 2502