comparison src/insdel.c @ 21246:6c16216d0e69

(insert_from_string_1, replace_range): Use STRING_MULTIBYTE to determine whether string is multibyte.
author Richard M. Stallman <rms@gnu.org>
date Sat, 21 Mar 1998 17:48:54 +0000
parents 50929073a0ba
children 4bd1566d9e1e
comparison
equal deleted inserted replaced
21245:6cde55b7c9de 21246:6c16216d0e69
1087 /* Make OUTGOING_NBYTES describe the text 1087 /* Make OUTGOING_NBYTES describe the text
1088 as it will be inserted in this buffer. */ 1088 as it will be inserted in this buffer. */
1089 1089
1090 if (NILP (current_buffer->enable_multibyte_characters)) 1090 if (NILP (current_buffer->enable_multibyte_characters))
1091 outgoing_nbytes = nchars; 1091 outgoing_nbytes = nchars;
1092 else if (nchars == nbytes) 1092 else if (! STRING_MULTIBYTE (string))
1093 outgoing_nbytes 1093 outgoing_nbytes
1094 = count_size_as_multibyte (&XSTRING (string)->data[pos_byte], 1094 = count_size_as_multibyte (&XSTRING (string)->data[pos_byte],
1095 nbytes); 1095 nbytes);
1096 1096
1097 /* Make sure point-max won't overflow after this insertion. */ 1097 /* Make sure point-max won't overflow after this insertion. */
1109 UNGCPRO; 1109 UNGCPRO;
1110 1110
1111 /* Copy the string text into the buffer, perhaps converting 1111 /* Copy the string text into the buffer, perhaps converting
1112 between single-byte and multibyte. */ 1112 between single-byte and multibyte. */
1113 copy_text (XSTRING (string)->data + pos_byte, GPT_ADDR, nbytes, 1113 copy_text (XSTRING (string)->data + pos_byte, GPT_ADDR, nbytes,
1114 /* If these are equal, it is a single-byte string. 1114 STRING_MULTIBYTE (string),
1115 Its chars are either ASCII, in which case copy_text
1116 won't change it, or single-byte non-ASCII chars,
1117 that need to be changed. */
1118 nchars != nbytes,
1119 ! NILP (current_buffer->enable_multibyte_characters)); 1115 ! NILP (current_buffer->enable_multibyte_characters));
1120 1116
1121 /* We have copied text into the gap, but we have not altered 1117 /* We have copied text into the gap, but we have not altered
1122 PT or PT_BYTE yet. So we can pass PT and PT_BYTE 1118 PT or PT_BYTE yet. So we can pass PT and PT_BYTE
1123 to these functions and get the same results as we would 1119 to these functions and get the same results as we would
1537 /* Make OUTGOING_INSBYTES describe the text 1533 /* Make OUTGOING_INSBYTES describe the text
1538 as it will be inserted in this buffer. */ 1534 as it will be inserted in this buffer. */
1539 1535
1540 if (NILP (current_buffer->enable_multibyte_characters)) 1536 if (NILP (current_buffer->enable_multibyte_characters))
1541 outgoing_insbytes = inschars; 1537 outgoing_insbytes = inschars;
1542 else if (inschars == insbytes) 1538 else if (! STRING_MULTIBYTE (new))
1543 outgoing_insbytes 1539 outgoing_insbytes
1544 = count_size_as_multibyte (XSTRING (new)->data, insbytes); 1540 = count_size_as_multibyte (XSTRING (new)->data, insbytes);
1545 1541
1546 /* Make sure point-max won't overflow after this insertion. */ 1542 /* Make sure point-max won't overflow after this insertion. */
1547 XSETINT (temp, Z_BYTE - nbytes_del + insbytes); 1543 XSETINT (temp, Z_BYTE - nbytes_del + insbytes);
1588 make_gap (insbytes - GAP_SIZE); 1584 make_gap (insbytes - GAP_SIZE);
1589 1585
1590 /* Copy the string text into the buffer, perhaps converting 1586 /* Copy the string text into the buffer, perhaps converting
1591 between single-byte and multibyte. */ 1587 between single-byte and multibyte. */
1592 copy_text (XSTRING (new)->data, GPT_ADDR, insbytes, 1588 copy_text (XSTRING (new)->data, GPT_ADDR, insbytes,
1593 /* If these are equal, it is a single-byte string. 1589 STRING_MULTIBYTE (new),
1594 Its chars are either ASCII, in which case copy_text
1595 won't change it, or single-byte non-ASCII chars,
1596 that need to be changed. */
1597 inschars != insbytes,
1598 ! NILP (current_buffer->enable_multibyte_characters)); 1590 ! NILP (current_buffer->enable_multibyte_characters));
1599 1591
1600 /* We have copied text into the gap, but we have not altered 1592 /* We have copied text into the gap, but we have not altered
1601 PT or PT_BYTE yet. So we can pass PT and PT_BYTE 1593 PT or PT_BYTE yet. So we can pass PT and PT_BYTE
1602 to these functions and get the same results as we would 1594 to these functions and get the same results as we would