Mercurial > emacs
comparison src/insdel.c @ 25764:72f00825a576
(copy_text): Removed unused variables.
(count_combining_after, count_combining_after, insert_1_both,
insert_from_string_1, insert_from_buffer_1, check_markers): Ditto.
(adjust_after_replace, replace_range): Add parentheses to logical
expressions. Remove unused variables.
(CHECK_BYTE_COMBINING_FOR_INSERT): Add parentheses to logical
expression.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sun, 19 Sep 1999 21:46:46 +0000 |
parents | 0a7261c1d487 |
children | b7aa6ac26872 |
comparison
equal
deleted
inserted
replaced
25763:20d4d2a42062 | 25764:72f00825a576 |
---|---|
79 else | 79 else |
80 | 80 |
81 void | 81 void |
82 check_markers () | 82 check_markers () |
83 { | 83 { |
84 register Lisp_Object tail, prev, next; | 84 register Lisp_Object tail; |
85 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); | 85 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
86 | 86 |
87 tail = BUF_MARKERS (current_buffer); | 87 tail = BUF_MARKERS (current_buffer); |
88 | 88 |
89 while (XSYMBOL (tail) != XSYMBOL (Qnil)) | 89 while (XSYMBOL (tail) != XSYMBOL (Qnil)) |
681 } | 681 } |
682 else if (from_multibyte) | 682 else if (from_multibyte) |
683 { | 683 { |
684 int nchars = 0; | 684 int nchars = 0; |
685 int bytes_left = nbytes; | 685 int bytes_left = nbytes; |
686 Lisp_Object tbl = Qnil, temp; | 686 Lisp_Object tbl = Qnil; |
687 | 687 |
688 /* We set the variable tbl to the reverse table of | 688 /* We set the variable tbl to the reverse table of |
689 Vnonascii_translation_table in advance. */ | 689 Vnonascii_translation_table in advance. */ |
690 if (CHAR_TABLE_P (Vnonascii_translation_table)) | 690 if (CHAR_TABLE_P (Vnonascii_translation_table)) |
691 { | 691 { |
966 count_combining_after (string, length, pos, pos_byte) | 966 count_combining_after (string, length, pos, pos_byte) |
967 unsigned char *string; | 967 unsigned char *string; |
968 int length; | 968 int length; |
969 int pos, pos_byte; | 969 int pos, pos_byte; |
970 { | 970 { |
971 int opos = pos, opos_byte = pos_byte; | 971 int opos_byte = pos_byte; |
972 int i; | 972 int i; |
973 int c, bytes; | 973 int bytes; |
974 unsigned char *bufp; | 974 unsigned char *bufp; |
975 | 975 |
976 if (NILP (current_buffer->enable_multibyte_characters)) | 976 if (NILP (current_buffer->enable_multibyte_characters)) |
977 return 0; | 977 return 0; |
978 | 978 |
1080 | 1080 |
1081 /* If we are going to combine bytes at POS which is at a narrowed | 1081 /* If we are going to combine bytes at POS which is at a narrowed |
1082 region boundary, signal an error. */ | 1082 region boundary, signal an error. */ |
1083 #define CHECK_BYTE_COMBINING_FOR_INSERT(pos) \ | 1083 #define CHECK_BYTE_COMBINING_FOR_INSERT(pos) \ |
1084 do { \ | 1084 do { \ |
1085 if (combined_before_bytes && pos == BEGV \ | 1085 if ((combined_before_bytes && pos == BEGV) \ |
1086 || combined_after_bytes && pos == ZV) \ | 1086 || (combined_after_bytes && pos == ZV)) \ |
1087 byte_combining_error (); \ | 1087 byte_combining_error (); \ |
1088 } while (0) | 1088 } while (0) |
1089 | 1089 |
1090 | 1090 |
1091 /* Insert a sequence of NCHARS chars which occupy NBYTES bytes | 1091 /* Insert a sequence of NCHARS chars which occupy NBYTES bytes |
1096 insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) | 1096 insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) |
1097 register unsigned char *string; | 1097 register unsigned char *string; |
1098 register int nchars, nbytes; | 1098 register int nchars, nbytes; |
1099 int inherit, prepare, before_markers; | 1099 int inherit, prepare, before_markers; |
1100 { | 1100 { |
1101 register Lisp_Object temp; | |
1102 int combined_before_bytes, combined_after_bytes; | 1101 int combined_before_bytes, combined_after_bytes; |
1103 | 1102 |
1104 if (NILP (current_buffer->enable_multibyte_characters)) | 1103 if (NILP (current_buffer->enable_multibyte_characters)) |
1105 nchars = nbytes; | 1104 nchars = nbytes; |
1106 | 1105 |
1259 inherit, before_markers) | 1258 inherit, before_markers) |
1260 Lisp_Object string; | 1259 Lisp_Object string; |
1261 register int pos, pos_byte, nchars, nbytes; | 1260 register int pos, pos_byte, nchars, nbytes; |
1262 int inherit, before_markers; | 1261 int inherit, before_markers; |
1263 { | 1262 { |
1264 register Lisp_Object temp; | |
1265 struct gcpro gcpro1; | 1263 struct gcpro gcpro1; |
1266 int outgoing_nbytes = nbytes; | 1264 int outgoing_nbytes = nbytes; |
1267 int combined_before_bytes, combined_after_bytes; | 1265 int combined_before_bytes, combined_after_bytes; |
1268 int adjusted_nchars; | |
1269 INTERVAL intervals; | 1266 INTERVAL intervals; |
1270 | 1267 |
1271 /* Make OUTGOING_NBYTES describe the text | 1268 /* Make OUTGOING_NBYTES describe the text |
1272 as it will be inserted in this buffer. */ | 1269 as it will be inserted in this buffer. */ |
1273 | 1270 |
1435 int from_byte = buf_charpos_to_bytepos (buf, from); | 1432 int from_byte = buf_charpos_to_bytepos (buf, from); |
1436 int to_byte = buf_charpos_to_bytepos (buf, from + nchars); | 1433 int to_byte = buf_charpos_to_bytepos (buf, from + nchars); |
1437 int incoming_nbytes = to_byte - from_byte; | 1434 int incoming_nbytes = to_byte - from_byte; |
1438 int outgoing_nbytes = incoming_nbytes; | 1435 int outgoing_nbytes = incoming_nbytes; |
1439 int combined_before_bytes, combined_after_bytes; | 1436 int combined_before_bytes, combined_after_bytes; |
1440 int adjusted_nchars; | |
1441 INTERVAL intervals; | 1437 INTERVAL intervals; |
1442 | 1438 |
1443 /* Make OUTGOING_NBYTES describe the text | 1439 /* Make OUTGOING_NBYTES describe the text |
1444 as it will be inserted in this buffer. */ | 1440 as it will be inserted in this buffer. */ |
1445 | 1441 |
1667 { | 1663 { |
1668 nchars_del = XSTRING (prev_text)->size; | 1664 nchars_del = XSTRING (prev_text)->size; |
1669 nbytes_del = STRING_BYTES (XSTRING (prev_text)); | 1665 nbytes_del = STRING_BYTES (XSTRING (prev_text)); |
1670 } | 1666 } |
1671 | 1667 |
1672 if (combine_before && from == BEGV | 1668 if ((combine_before && from == BEGV) |
1673 || combined_after_bytes && from == ZV) | 1669 || (combined_after_bytes && from == ZV)) |
1674 { | 1670 { |
1675 /* We can't combine bytes nor signal an error here. So, let's | 1671 /* We can't combine bytes nor signal an error here. So, let's |
1676 pretend that the new text is just a single space. */ | 1672 pretend that the new text is just a single space. */ |
1677 len = len_byte = 1; | 1673 len = len_byte = 1; |
1678 combined_before_bytes = combined_after_bytes = 0; | 1674 combined_before_bytes = combined_after_bytes = 0; |
1697 if (! EQ (current_buffer->undo_list, Qt)) | 1693 if (! EQ (current_buffer->undo_list, Qt)) |
1698 record_delete (from + nchars_del, deletion); | 1694 record_delete (from + nchars_del, deletion); |
1699 } | 1695 } |
1700 | 1696 |
1701 if (combined_before_bytes | 1697 if (combined_before_bytes |
1702 || len_byte == 0 && combined_after_bytes > 0) | 1698 || (len_byte == 0 && combined_after_bytes > 0)) |
1703 { | 1699 { |
1704 Lisp_Object deletion; | 1700 Lisp_Object deletion; |
1705 deletion = Qnil; | 1701 deletion = Qnil; |
1706 | 1702 |
1707 if (! EQ (current_buffer->undo_list, Qt)) | 1703 if (! EQ (current_buffer->undo_list, Qt)) |
1748 offset_intervals (current_buffer, from, len - nchars_del); | 1744 offset_intervals (current_buffer, from, len - nchars_del); |
1749 } | 1745 } |
1750 #endif | 1746 #endif |
1751 | 1747 |
1752 { | 1748 { |
1753 int pos = PT, pos_byte = PT_BYTE; | |
1754 | |
1755 if (from < PT) | 1749 if (from < PT) |
1756 adjust_point (len - nchars_del, len_byte - nbytes_del); | 1750 adjust_point (len - nchars_del, len_byte - nbytes_del); |
1757 | 1751 |
1758 if (combined_after_bytes) | 1752 if (combined_after_bytes) |
1759 { | 1753 { |
1821 int from_byte, to_byte; | 1815 int from_byte, to_byte; |
1822 int nbytes_del, nchars_del; | 1816 int nbytes_del, nchars_del; |
1823 register Lisp_Object temp; | 1817 register Lisp_Object temp; |
1824 struct gcpro gcpro1; | 1818 struct gcpro gcpro1; |
1825 int combined_before_bytes, combined_after_bytes; | 1819 int combined_before_bytes, combined_after_bytes; |
1826 int adjusted_inschars; | |
1827 INTERVAL intervals; | 1820 INTERVAL intervals; |
1828 int outgoing_insbytes = insbytes; | 1821 int outgoing_insbytes = insbytes; |
1829 Lisp_Object deletion; | 1822 Lisp_Object deletion; |
1830 | 1823 |
1831 CHECK_MARKERS (); | 1824 CHECK_MARKERS (); |
1925 combined_before_bytes | 1918 combined_before_bytes |
1926 = count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte); | 1919 = count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte); |
1927 combined_after_bytes | 1920 combined_after_bytes |
1928 = count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte); | 1921 = count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte); |
1929 | 1922 |
1930 if (combined_before_bytes && from == BEGV | 1923 if ((combined_before_bytes && from == BEGV) |
1931 || combined_after_bytes && from == ZV) | 1924 || (combined_after_bytes && from == ZV)) |
1932 { | 1925 { |
1933 /* Bytes are being combined across the region boundary. We | 1926 /* Bytes are being combined across the region boundary. We |
1934 should avoid it. We recover the original contents before | 1927 should avoid it. We recover the original contents before |
1935 signaling an error. */ | 1928 signaling an error. */ |
1936 bcopy (XSTRING (deletion)->data, GPT_ADDR, nbytes_del); | 1929 bcopy (XSTRING (deletion)->data, GPT_ADDR, nbytes_del); |