Mercurial > hg > xemacs-beta
comparison src/buffer.h @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | e121b013d1f0 |
children | 41ff10fd062f |
comparison
equal
deleted
inserted
replaced
184:bcd2674570bf | 185:3d6bfa290dbd |
---|---|
74 extent-parent and extent-children. | 74 extent-parent and extent-children. |
75 */ | 75 */ |
76 | 76 |
77 struct buffer_text | 77 struct buffer_text |
78 { | 78 { |
79 Bufbyte *beg; /* Actual address of buffer contents. */ | 79 Bufbyte *beg; /* Actual address of buffer contents. */ |
80 Bytind gpt; /* Index of gap in buffer. */ | 80 Bytind gpt; /* Index of gap in buffer. */ |
81 Bytind z; /* Index of end of buffer. */ | 81 Bytind z; /* Index of end of buffer. */ |
82 Bufpos bufz; /* Equivalent as a Bufpos. */ | 82 Bufpos bufz; /* Equivalent as a Bufpos. */ |
83 int gap_size; /* Size of buffer's gap */ | 83 int gap_size; /* Size of buffer's gap */ |
84 int end_gap_size; /* Size of buffer's end gap */ | 84 int end_gap_size; /* Size of buffer's end gap */ |
625 place where we would normally put them. */ | 625 place where we would normally put them. */ |
626 | 626 |
627 /* None of these are lvalues. Use the settor macros below to change | 627 /* None of these are lvalues. Use the settor macros below to change |
628 the positions. */ | 628 the positions. */ |
629 | 629 |
630 /* Beginning of buffer. */ | 630 /* Beginning of buffer. */ |
631 #define BI_BUF_BEG(buf) ((Bytind) 1) | 631 #define BI_BUF_BEG(buf) ((Bytind) 1) |
632 #define BUF_BEG(buf) ((Bufpos) 1) | 632 #define BUF_BEG(buf) ((Bufpos) 1) |
633 | 633 |
634 /* Beginning of accessible range of buffer. */ | 634 /* Beginning of accessible range of buffer. */ |
635 #define BI_BUF_BEGV(buf) ((buf)->begv + 0) | 635 #define BI_BUF_BEGV(buf) ((buf)->begv + 0) |
636 #define BUF_BEGV(buf) ((buf)->bufbegv + 0) | 636 #define BUF_BEGV(buf) ((buf)->bufbegv + 0) |
637 | 637 |
638 /* End of accessible range of buffer. */ | 638 /* End of accessible range of buffer. */ |
639 #define BI_BUF_ZV(buf) ((buf)->zv + 0) | 639 #define BI_BUF_ZV(buf) ((buf)->zv + 0) |
640 #define BUF_ZV(buf) ((buf)->bufzv + 0) | 640 #define BUF_ZV(buf) ((buf)->bufzv + 0) |
641 | 641 |
642 /* End of buffer. */ | 642 /* End of buffer. */ |
643 #define BI_BUF_Z(buf) ((buf)->text->z + 0) | 643 #define BI_BUF_Z(buf) ((buf)->text->z + 0) |
644 #define BUF_Z(buf) ((buf)->text->bufz + 0) | 644 #define BUF_Z(buf) ((buf)->text->bufz + 0) |
645 | 645 |
646 /* Point. */ | 646 /* Point. */ |
647 #define BI_BUF_PT(buf) ((buf)->pt + 0) | 647 #define BI_BUF_PT(buf) ((buf)->pt + 0) |
1015 size up to 384K, i.e. indexing the first 192K non-negative | 1015 size up to 384K, i.e. indexing the first 192K non-negative |
1016 numbers, while still using shorts in the array.) This also | 1016 numbers, while still using shorts in the array.) This also |
1017 means that the size of the known region can be at most | 1017 means that the size of the known region can be at most |
1018 64K for width-three characters. | 1018 64K for width-three characters. |
1019 */ | 1019 */ |
1020 | 1020 |
1021 extern short three_to_one_table[]; | 1021 extern short three_to_one_table[]; |
1022 | 1022 |
1023 INLINE int real_bufpos_to_bytind (struct buffer *buf, Bufpos x); | 1023 INLINE int real_bufpos_to_bytind (struct buffer *buf, Bufpos x); |
1024 INLINE int | 1024 INLINE int |
1025 real_bufpos_to_bytind (struct buffer *buf, Bufpos x) | 1025 real_bufpos_to_bytind (struct buffer *buf, Bufpos x) |
1162 rarely done in time-critical functions, and so the slight | 1162 rarely done in time-critical functions, and so the slight |
1163 extra time required for alloca() and copy is well-worth the | 1163 extra time required for alloca() and copy is well-worth the |
1164 safety of knowing your string data won't be relocated out from | 1164 safety of knowing your string data won't be relocated out from |
1165 under you. | 1165 under you. |
1166 */ | 1166 */ |
1167 | 1167 |
1168 | 1168 |
1169 /* Maybe convert charptr's data into ext-format and store the result in | 1169 /* Maybe convert charptr's data into ext-format and store the result in |
1170 alloca()'ed space. | 1170 alloca()'ed space. |
1171 | 1171 |
1172 You may wonder why this is written in this fashion and not as a | 1172 You may wonder why this is written in this fashion and not as a |
1173 function call. With a little trickery it could certainly be | 1173 function call. With a little trickery it could certainly be |
1174 written this way, but it won't work because of those DAMN GCC WANKERS | 1174 written this way, but it won't work because of those DAMN GCC WANKERS |
1175 who couldn't be bothered to handle alloca() properly on the x86 | 1175 who couldn't be bothered to handle alloca() properly on the x86 |
1176 architecture. (If you put a call to alloca() in the argument to | 1176 architecture. (If you put a call to alloca() in the argument to |
1177 a function call, the stack space gets allocated right in the | 1177 a function call, the stack space gets allocated right in the |
1178 middle of the arguments to the function call and you are unbelievably | 1178 middle of the arguments to the function call and you are unbelievably |
1179 hosed.) */ | 1179 hosed.) */ |
1180 | 1180 |
1181 #ifdef MULE | 1181 #ifdef MULE |
1182 | 1182 |
1183 #define GET_CHARPTR_EXT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here) \ | 1183 #define GET_CHARPTR_EXT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here) \ |
1184 do \ | 1184 do \ |
1185 { \ | 1185 { \ |
1255 GET_CHARPTR_EXT_DATA_ALLOCA (ptr, len, FORMAT_CTEXT, stick_value_here, \ | 1255 GET_CHARPTR_EXT_DATA_ALLOCA (ptr, len, FORMAT_CTEXT, stick_value_here, \ |
1256 stick_len_here) | 1256 stick_len_here) |
1257 | 1257 |
1258 /* Maybe convert external charptr's data into internal format and store | 1258 /* Maybe convert external charptr's data into internal format and store |
1259 the result in alloca()'ed space. | 1259 the result in alloca()'ed space. |
1260 | 1260 |
1261 You may wonder why this is written in this fashion and not as a | 1261 You may wonder why this is written in this fashion and not as a |
1262 function call. With a little trickery it could certainly be | 1262 function call. With a little trickery it could certainly be |
1263 written this way, but it won't work because of those DAMN GCC WANKERS | 1263 written this way, but it won't work because of those DAMN GCC WANKERS |
1264 who couldn't be bothered to handle alloca() properly on the x86 | 1264 who couldn't be bothered to handle alloca() properly on the x86 |
1265 architecture. (If you put a call to alloca() in the argument to | 1265 architecture. (If you put a call to alloca() in the argument to |
1266 a function call, the stack space gets allocated right in the | 1266 a function call, the stack space gets allocated right in the |
1267 middle of the arguments to the function call and you are unbelievably | 1267 middle of the arguments to the function call and you are unbelievably |
1268 hosed.) */ | 1268 hosed.) */ |
1269 | 1269 |
1270 #ifdef MULE | 1270 #ifdef MULE |
1271 | 1271 |
1272 #define GET_CHARPTR_INT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here)\ | 1272 #define GET_CHARPTR_INT_DATA_ALLOCA(ptr, len, fmt, stick_value_here, stick_len_here)\ |
1273 do \ | 1273 do \ |
1274 { \ | 1274 { \ |
1454 | 1454 |
1455 /*----------------------------------------------------------------------*/ | 1455 /*----------------------------------------------------------------------*/ |
1456 /* Settor macros for important positions in a buffer */ | 1456 /* Settor macros for important positions in a buffer */ |
1457 /*----------------------------------------------------------------------*/ | 1457 /*----------------------------------------------------------------------*/ |
1458 | 1458 |
1459 /* Set beginning of accessible range of buffer. */ | 1459 /* Set beginning of accessible range of buffer. */ |
1460 #define SET_BOTH_BUF_BEGV(buf, val, bival) \ | 1460 #define SET_BOTH_BUF_BEGV(buf, val, bival) \ |
1461 do \ | 1461 do \ |
1462 { \ | 1462 { \ |
1463 (buf)->begv = (bival); \ | 1463 (buf)->begv = (bival); \ |
1464 (buf)->bufbegv = (val); \ | 1464 (buf)->bufbegv = (val); \ |
1465 } while (0) | 1465 } while (0) |
1466 | 1466 |
1467 /* Set end of accessible range of buffer. */ | 1467 /* Set end of accessible range of buffer. */ |
1468 #define SET_BOTH_BUF_ZV(buf, val, bival) \ | 1468 #define SET_BOTH_BUF_ZV(buf, val, bival) \ |
1469 do \ | 1469 do \ |
1470 { \ | 1470 { \ |
1471 (buf)->zv = (bival); \ | 1471 (buf)->zv = (bival); \ |
1472 (buf)->bufzv = (val); \ | 1472 (buf)->bufzv = (val); \ |
1622 | 1622 |
1623 /* Allocation of buffer data. */ | 1623 /* Allocation of buffer data. */ |
1624 | 1624 |
1625 #ifdef REL_ALLOC | 1625 #ifdef REL_ALLOC |
1626 | 1626 |
1627 char *r_alloc (char **, unsigned long); | 1627 char *r_alloc (unsigned char **, unsigned long); |
1628 char *r_re_alloc (char **, unsigned long); | 1628 char *r_re_alloc (unsigned char **, unsigned long); |
1629 void r_alloc_free (void **); | 1629 void r_alloc_free (unsigned char **); |
1630 | 1630 |
1631 #define BUFFER_ALLOC(data,size) \ | 1631 #define BUFFER_ALLOC(data, size) \ |
1632 ((Bufbyte *) r_alloc ((char **) &data, (size) * sizeof(Bufbyte))) | 1632 ((Bufbyte *) r_alloc ((unsigned char **) &data, (size) * sizeof(Bufbyte))) |
1633 #define BUFFER_REALLOC(data,size) \ | 1633 #define BUFFER_REALLOC(data, size) \ |
1634 ((Bufbyte *) r_re_alloc ((char **) &data, (size) * sizeof(Bufbyte))) | 1634 ((Bufbyte *) r_re_alloc ((unsigned char **) &data, (size) * sizeof(Bufbyte))) |
1635 #define BUFFER_FREE(data) r_alloc_free ((void **) &(data)) | 1635 #define BUFFER_FREE(data) r_alloc_free ((unsigned char **) &(data)) |
1636 #define R_ALLOC_DECLARE(var,data) r_alloc_declare (&(var), data) | 1636 #define R_ALLOC_DECLARE(var,data) r_alloc_declare (&(var), data) |
1637 | 1637 |
1638 #else /* !REL_ALLOC */ | 1638 #else /* !REL_ALLOC */ |
1639 | 1639 |
1640 #define BUFFER_ALLOC(data,size)\ | 1640 #define BUFFER_ALLOC(data,size)\ |
1641 (data = (Bufbyte *) xmalloc ((size) * sizeof(Bufbyte))) | 1641 ((void) (data = xnew_array (Bufbyte, size))) |
1642 #define BUFFER_REALLOC(data,size)\ | 1642 #define BUFFER_REALLOC(data,size)\ |
1643 ((Bufbyte *) xrealloc (data, (size) * sizeof(Bufbyte))) | 1643 ((Bufbyte *) xrealloc (data, (size) * sizeof(Bufbyte))) |
1644 /* Avoid excess parentheses, or syntax errors may rear their heads. */ | 1644 /* Avoid excess parentheses, or syntax errors may rear their heads. */ |
1645 #define BUFFER_FREE(data) xfree (data) | 1645 #define BUFFER_FREE(data) xfree (data) |
1646 #define R_ALLOC_DECLARE(var,data) | 1646 #define R_ALLOC_DECLARE(var,data) |
1665 Charcount len); | 1665 Charcount len); |
1666 int bufbyte_string_displayed_columns (CONST Bufbyte *str, Bytecount len); | 1666 int bufbyte_string_displayed_columns (CONST Bufbyte *str, Bytecount len); |
1667 int emchar_string_displayed_columns (CONST Emchar *str, Charcount len); | 1667 int emchar_string_displayed_columns (CONST Emchar *str, Charcount len); |
1668 void convert_bufbyte_string_into_emchar_dynarr (CONST Bufbyte *str, | 1668 void convert_bufbyte_string_into_emchar_dynarr (CONST Bufbyte *str, |
1669 Bytecount len, | 1669 Bytecount len, |
1670 emchar_dynarr *dyn); | 1670 Emchar_dynarr *dyn); |
1671 int convert_bufbyte_string_into_emchar_string (CONST Bufbyte *str, | 1671 int convert_bufbyte_string_into_emchar_string (CONST Bufbyte *str, |
1672 Bytecount len, | 1672 Bytecount len, |
1673 Emchar *arr); | 1673 Emchar *arr); |
1674 void convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels, | 1674 void convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels, |
1675 bufbyte_dynarr *dyn); | 1675 Bufbyte_dynarr *dyn); |
1676 Bufbyte *convert_emchar_string_into_malloced_string (Emchar *arr, int nels, | 1676 Bufbyte *convert_emchar_string_into_malloced_string (Emchar *arr, int nels, |
1677 Bytecount *len_out); | 1677 Bytecount *len_out); |
1678 | 1678 |
1679 /* flags for get_buffer_pos_char(), get_buffer_range_char(), etc. */ | 1679 /* flags for get_buffer_pos_char(), get_buffer_range_char(), etc. */ |
1680 /* At most one of GB_COERCE_RANGE and GB_NO_ERROR_IF_BAD should be | 1680 /* At most one of GB_COERCE_RANGE and GB_NO_ERROR_IF_BAD should be |