aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorStefan Monnier2003-04-17 21:52:01 +0000
committerStefan Monnier2003-04-17 21:52:01 +0000
commitd895183d11c0908edb7aef3e2885480cfe1ac5ae (patch)
tree7e32f260145fa48977be3062f44b40bbe2998314 /src/buffer.h
parent92cc28b2f89d83fbcd712450abfbf4e138d2e06f (diff)
downloademacs-d895183d11c0908edb7aef3e2885480cfe1ac5ae.tar.gz
emacs-d895183d11c0908edb7aef3e2885480cfe1ac5ae.zip
Don't hardcode BEG==1.
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 7dd1e967afd..7abd8e95e39 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -62,16 +62,16 @@ Boston, MA 02111-1307, USA. */
62#define PT_ADDR (BYTE_POS_ADDR (current_buffer->pt_byte)) 62#define PT_ADDR (BYTE_POS_ADDR (current_buffer->pt_byte))
63 63
64/* Address of beginning of gap in buffer. */ 64/* Address of beginning of gap in buffer. */
65#define GPT_ADDR (current_buffer->text->beg + current_buffer->text->gpt_byte - 1) 65#define GPT_ADDR (current_buffer->text->beg + current_buffer->text->gpt_byte - BEG_BYTE)
66 66
67/* Address of end of gap in buffer. */ 67/* Address of end of gap in buffer. */
68#define GAP_END_ADDR (current_buffer->text->beg + current_buffer->text->gpt_byte + current_buffer->text->gap_size - 1) 68#define GAP_END_ADDR (current_buffer->text->beg + current_buffer->text->gpt_byte + current_buffer->text->gap_size - BEG_BYTE)
69 69
70/* Address of end of accessible range of buffer. */ 70/* Address of end of accessible range of buffer. */
71#define ZV_ADDR (BYTE_POS_ADDR (current_buffer->zv_byte)) 71#define ZV_ADDR (BYTE_POS_ADDR (current_buffer->zv_byte))
72 72
73/* Address of end of buffer. */ 73/* Address of end of buffer. */
74#define Z_ADDR (current_buffer->text->beg + current_buffer->text->gap_size + current_buffer->text->z_byte - 1) 74#define Z_ADDR (current_buffer->text->beg + current_buffer->text->gap_size + current_buffer->text->z_byte - BEG_BYTE)
75 75
76/* Size of gap. */ 76/* Size of gap. */
77#define GAP_SIZE (current_buffer->text->gap_size) 77#define GAP_SIZE (current_buffer->text->gap_size)
@@ -102,8 +102,8 @@ Boston, MA 02111-1307, USA. */
102 Note that many of these evaluate the buffer argument more than once. */ 102 Note that many of these evaluate the buffer argument more than once. */
103 103
104/* Position of beginning of buffer. */ 104/* Position of beginning of buffer. */
105#define BUF_BEG(buf) (1) 105#define BUF_BEG(buf) (BEG)
106#define BUF_BEG_BYTE(buf) (1) 106#define BUF_BEG_BYTE(buf) (BEG_BYTE)
107 107
108/* Position of beginning of accessible range of buffer. */ 108/* Position of beginning of accessible range of buffer. */
109#define BUF_BEGV(buf) ((buf)->begv) 109#define BUF_BEGV(buf) ((buf)->begv)
@@ -129,13 +129,13 @@ Boston, MA 02111-1307, USA. */
129#define BUF_BEG_ADDR(buf) ((buf)->text->beg) 129#define BUF_BEG_ADDR(buf) ((buf)->text->beg)
130 130
131/* Address of beginning of gap of buffer. */ 131/* Address of beginning of gap of buffer. */
132#define BUF_GPT_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt_byte - 1) 132#define BUF_GPT_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt_byte - BEG_BYTE)
133 133
134/* Address of end of buffer. */ 134/* Address of end of buffer. */
135#define BUF_Z_ADDR(buf) ((buf)->text->beg + (buf)->text->gap_size + (buf)->text->z_byte - 1) 135#define BUF_Z_ADDR(buf) ((buf)->text->beg + (buf)->text->gap_size + (buf)->text->z_byte - BEG_BYTE)
136 136
137/* Address of end of gap in buffer. */ 137/* Address of end of gap in buffer. */
138#define BUF_GAP_END_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt_byte + (buf)->text->gap_size - 1) 138#define BUF_GAP_END_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt_byte + (buf)->text->gap_size - BEG_BYTE)
139 139
140/* Size of gap. */ 140/* Size of gap. */
141#define BUF_GAP_SIZE(buf) ((buf)->text->gap_size) 141#define BUF_GAP_SIZE(buf) ((buf)->text->gap_size)
@@ -280,14 +280,14 @@ else
280/* Return the address of byte position N in current buffer. */ 280/* Return the address of byte position N in current buffer. */
281 281
282#define BYTE_POS_ADDR(n) \ 282#define BYTE_POS_ADDR(n) \
283 (((n) >= GPT_BYTE ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1) 283 (((n) >= GPT_BYTE ? GAP_SIZE : 0) + (n) + BEG_ADDR - BEG_BYTE)
284 284
285/* Return the address of char position N. */ 285/* Return the address of char position N. */
286 286
287#define CHAR_POS_ADDR(n) \ 287#define CHAR_POS_ADDR(n) \
288 (((n) >= GPT ? GAP_SIZE : 0) \ 288 (((n) >= GPT ? GAP_SIZE : 0) \
289 + buf_charpos_to_bytepos (current_buffer, n) \ 289 + buf_charpos_to_bytepos (current_buffer, n) \
290 + BEG_ADDR - 1) 290 + BEG_ADDR - BEG_BYTE)
291 291
292/* Convert a character position to a byte position. */ 292/* Convert a character position to a byte position. */
293 293
@@ -303,8 +303,8 @@ else
303 303
304#define PTR_BYTE_POS(ptr) \ 304#define PTR_BYTE_POS(ptr) \
305((ptr) - (current_buffer)->text->beg \ 305((ptr) - (current_buffer)->text->beg \
306 - (ptr - (current_buffer)->text->beg < (unsigned) GPT_BYTE ? 0 : GAP_SIZE) \ 306 - (ptr - (current_buffer)->text->beg <= (unsigned) (GPT_BYTE - BEG_BYTE) ? 0 : GAP_SIZE) \
307 + 1) 307 + BEG_BYTE)
308 308
309/* Return character at position POS. */ 309/* Return character at position POS. */
310 310
@@ -327,7 +327,7 @@ extern int _fetch_multibyte_char_len;
327 327
328#define FETCH_MULTIBYTE_CHAR(pos) \ 328#define FETCH_MULTIBYTE_CHAR(pos) \
329 (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0) \ 329 (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0) \
330 + (pos) + BEG_ADDR - 1), \ 330 + (pos) + BEG_ADDR - BEG_BYTE), \
331 _fetch_multibyte_char_len \ 331 _fetch_multibyte_char_len \
332 = ((pos) >= GPT_BYTE ? ZV_BYTE : GPT_BYTE) - (pos), \ 332 = ((pos) >= GPT_BYTE ? ZV_BYTE : GPT_BYTE) - (pos), \
333 STRING_CHAR (_fetch_multibyte_char_p, _fetch_multibyte_char_len)) 333 STRING_CHAR (_fetch_multibyte_char_p, _fetch_multibyte_char_len))
@@ -340,14 +340,14 @@ extern int _fetch_multibyte_char_len;
340 Note that both arguments can be computed more than once. */ 340 Note that both arguments can be computed more than once. */
341 341
342#define BUF_BYTE_ADDRESS(buf, pos) \ 342#define BUF_BYTE_ADDRESS(buf, pos) \
343((buf)->text->beg + (pos) - 1 \ 343((buf)->text->beg + (pos) - BEG_BYTE \
344 + ((pos) >= (buf)->text->gpt_byte ? (buf)->text->gap_size : 0)) 344 + ((pos) >= (buf)->text->gpt_byte ? (buf)->text->gap_size : 0))
345 345
346/* Return the address of character at char position POS in buffer BUF. 346/* Return the address of character at char position POS in buffer BUF.
347 Note that both arguments can be computed more than once. */ 347 Note that both arguments can be computed more than once. */
348 348
349#define BUF_CHAR_ADDRESS(buf, pos) \ 349#define BUF_CHAR_ADDRESS(buf, pos) \
350((buf)->text->beg + buf_charpos_to_bytepos ((buf), (pos)) - 1 \ 350((buf)->text->beg + buf_charpos_to_bytepos ((buf), (pos)) - BEG_BYTE \
351 + ((pos) >= (buf)->text->gpt ? (buf)->text->gap_size : 0)) 351 + ((pos) >= (buf)->text->gpt ? (buf)->text->gap_size : 0))
352 352
353/* Convert PTR, the address of a char in buffer BUF, 353/* Convert PTR, the address of a char in buffer BUF,
@@ -355,9 +355,9 @@ extern int _fetch_multibyte_char_len;
355 355
356#define BUF_PTR_BYTE_POS(buf, ptr) \ 356#define BUF_PTR_BYTE_POS(buf, ptr) \
357((ptr) - (buf)->text->beg \ 357((ptr) - (buf)->text->beg \
358 - (ptr - (buf)->text->beg < (unsigned) BUF_GPT_BYTE ((buf)) \ 358 - (ptr - (buf)->text->beg <= (unsigned) (BUF_GPT_BYTE ((buf)) - BEG_BYTE)\
359 ? 0 : BUF_GAP_SIZE ((buf))) \ 359 ? 0 : BUF_GAP_SIZE ((buf))) \
360 + 1) 360 + BEG_BYTE)
361 361
362/* Return the character at byte position POS in buffer BUF. */ 362/* Return the character at byte position POS in buffer BUF. */
363 363
@@ -378,7 +378,7 @@ extern int _fetch_multibyte_char_len;
378#define BUF_FETCH_MULTIBYTE_CHAR(buf, pos) \ 378#define BUF_FETCH_MULTIBYTE_CHAR(buf, pos) \
379 (_fetch_multibyte_char_p \ 379 (_fetch_multibyte_char_p \
380 = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) \ 380 = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) \
381 + (pos) + BUF_BEG_ADDR (buf) - 1), \ 381 + (pos) + BUF_BEG_ADDR (buf) - BEG_BYTE), \
382 _fetch_multibyte_char_len \ 382 _fetch_multibyte_char_len \
383 = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_ZV_BYTE (buf) : BUF_GPT_BYTE (buf)) \ 383 = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_ZV_BYTE (buf) : BUF_GPT_BYTE (buf)) \
384 - (pos)), \ 384 - (pos)), \