diff options
| author | Karl Heuer | 1997-02-20 06:50:03 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-02-20 06:50:03 +0000 |
| commit | 469ff68001addb673e16e6f18a120152b9a1d15f (patch) | |
| tree | c24dfb52df62f5da162d50cf580370e5102f1914 /src | |
| parent | 81d0083108ca961a734237c61b77f68583fb6f52 (diff) | |
| download | emacs-469ff68001addb673e16e6f18a120152b9a1d15f.tar.gz emacs-469ff68001addb673e16e6f18a120152b9a1d15f.zip | |
Include charset.h.
(gap_left, gap_right): Put an anchor `\0' at the end of GAP.
(adjust_markers_for_insert): If any markers are adjusted, check
and fix the order of overlays in overlays_before.
(make_gap): Allocate an extra byte and set to `\0' for anchoring.
(insert1, insert_from_buffer_1): Put an anchor `\0' at the head of
GAP.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/insdel.c b/src/insdel.c index b3bc81467fd..d3c652bce53 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 23 | #include "lisp.h" | 23 | #include "lisp.h" |
| 24 | #include "intervals.h" | 24 | #include "intervals.h" |
| 25 | #include "buffer.h" | 25 | #include "buffer.h" |
| 26 | #include "charset.h" | ||
| 26 | #include "window.h" | 27 | #include "window.h" |
| 27 | #include "blockinput.h" | 28 | #include "blockinput.h" |
| 28 | 29 | ||
| @@ -153,6 +154,7 @@ gap_left (pos, newgap) | |||
| 153 | or may be where a quit was detected. */ | 154 | or may be where a quit was detected. */ |
| 154 | adjust_markers (pos + 1, GPT, GAP_SIZE); | 155 | adjust_markers (pos + 1, GPT, GAP_SIZE); |
| 155 | GPT = pos + 1; | 156 | GPT = pos + 1; |
| 157 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 156 | QUIT; | 158 | QUIT; |
| 157 | } | 159 | } |
| 158 | 160 | ||
| @@ -231,6 +233,7 @@ gap_right (pos) | |||
| 231 | 233 | ||
| 232 | adjust_markers (GPT + GAP_SIZE, pos + 1 + GAP_SIZE, - GAP_SIZE); | 234 | adjust_markers (GPT + GAP_SIZE, pos + 1 + GAP_SIZE, - GAP_SIZE); |
| 233 | GPT = pos + 1; | 235 | GPT = pos + 1; |
| 236 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 234 | QUIT; | 237 | QUIT; |
| 235 | } | 238 | } |
| 236 | 239 | ||
| @@ -290,6 +293,7 @@ adjust_markers_for_insert (pos, amount) | |||
| 290 | register int pos, amount; | 293 | register int pos, amount; |
| 291 | { | 294 | { |
| 292 | Lisp_Object marker; | 295 | Lisp_Object marker; |
| 296 | int adjusted = 0; | ||
| 293 | 297 | ||
| 294 | marker = BUF_MARKERS (current_buffer); | 298 | marker = BUF_MARKERS (current_buffer); |
| 295 | 299 | ||
| @@ -297,9 +301,16 @@ adjust_markers_for_insert (pos, amount) | |||
| 297 | { | 301 | { |
| 298 | register struct Lisp_Marker *m = XMARKER (marker); | 302 | register struct Lisp_Marker *m = XMARKER (marker); |
| 299 | if (m->insertion_type && m->bufpos == pos) | 303 | if (m->insertion_type && m->bufpos == pos) |
| 300 | m->bufpos += amount; | 304 | { |
| 305 | m->bufpos += amount; | ||
| 306 | adjusted = 1; | ||
| 307 | } | ||
| 301 | marker = m->chain; | 308 | marker = m->chain; |
| 302 | } | 309 | } |
| 310 | if (adjusted) | ||
| 311 | /* Adjusting only markers whose insertion-type is t may result in | ||
| 312 | disordered overlays in the slot `overlays_before'. */ | ||
| 313 | fix_overlays_before (current_buffer, pos, pos + amount); | ||
| 303 | } | 314 | } |
| 304 | 315 | ||
| 305 | /* Add the specified amount to point. This is used only when the value | 316 | /* Add the specified amount to point. This is used only when the value |
| @@ -339,7 +350,8 @@ make_gap (increment) | |||
| 339 | error ("Buffer exceeds maximum size"); | 350 | error ("Buffer exceeds maximum size"); |
| 340 | 351 | ||
| 341 | BLOCK_INPUT; | 352 | BLOCK_INPUT; |
| 342 | result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment)); | 353 | /* We allocate extra 1-byte `\0' at the tail for anchoring a search. */ |
| 354 | result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment + 1)); | ||
| 343 | 355 | ||
| 344 | if (result == 0) | 356 | if (result == 0) |
| 345 | { | 357 | { |
| @@ -370,6 +382,9 @@ make_gap (increment) | |||
| 370 | GAP_SIZE += old_gap_size; | 382 | GAP_SIZE += old_gap_size; |
| 371 | GPT = real_gap_loc; | 383 | GPT = real_gap_loc; |
| 372 | 384 | ||
| 385 | /* Put an anchor. */ | ||
| 386 | *(Z_ADDR) = 0; | ||
| 387 | |||
| 373 | Vinhibit_quit = tem; | 388 | Vinhibit_quit = tem; |
| 374 | } | 389 | } |
| 375 | 390 | ||
| @@ -432,6 +447,7 @@ insert_1 (string, length, inherit, prepare) | |||
| 432 | GPT += length; | 447 | GPT += length; |
| 433 | ZV += length; | 448 | ZV += length; |
| 434 | Z += length; | 449 | Z += length; |
| 450 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 435 | adjust_overlays_for_insert (PT, length); | 451 | adjust_overlays_for_insert (PT, length); |
| 436 | adjust_markers_for_insert (PT, length); | 452 | adjust_markers_for_insert (PT, length); |
| 437 | adjust_point (length); | 453 | adjust_point (length); |
| @@ -500,6 +516,7 @@ insert_from_string_1 (string, pos, length, inherit) | |||
| 500 | GPT += length; | 516 | GPT += length; |
| 501 | ZV += length; | 517 | ZV += length; |
| 502 | Z += length; | 518 | Z += length; |
| 519 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 503 | adjust_overlays_for_insert (PT, length); | 520 | adjust_overlays_for_insert (PT, length); |
| 504 | adjust_markers_for_insert (PT, length); | 521 | adjust_markers_for_insert (PT, length); |
| 505 | 522 | ||
| @@ -576,6 +593,7 @@ insert_from_buffer_1 (buf, pos, length, inherit) | |||
| 576 | GPT += length; | 593 | GPT += length; |
| 577 | ZV += length; | 594 | ZV += length; |
| 578 | Z += length; | 595 | Z += length; |
| 596 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 579 | adjust_overlays_for_insert (PT, length); | 597 | adjust_overlays_for_insert (PT, length); |
| 580 | adjust_markers_for_insert (PT, length); | 598 | adjust_markers_for_insert (PT, length); |
| 581 | adjust_point (length); | 599 | adjust_point (length); |
| @@ -590,9 +608,12 @@ insert_from_buffer_1 (buf, pos, length, inherit) | |||
| 590 | 608 | ||
| 591 | void | 609 | void |
| 592 | insert_char (c) | 610 | insert_char (c) |
| 593 | unsigned char c; | 611 | int c; |
| 594 | { | 612 | { |
| 595 | insert (&c, 1); | 613 | unsigned char workbuf[4], *str; |
| 614 | int len = CHAR_STRING (c, workbuf, str); | ||
| 615 | |||
| 616 | insert (str, len); | ||
| 596 | } | 617 | } |
| 597 | 618 | ||
| 598 | /* Insert the null-terminated string S before point */ | 619 | /* Insert the null-terminated string S before point */ |
| @@ -714,6 +735,7 @@ del_range_1 (from, to, prepare) | |||
| 714 | ZV -= numdel; | 735 | ZV -= numdel; |
| 715 | Z -= numdel; | 736 | Z -= numdel; |
| 716 | GPT = from; | 737 | GPT = from; |
| 738 | *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 717 | 739 | ||
| 718 | if (GPT - BEG < beg_unchanged) | 740 | if (GPT - BEG < beg_unchanged) |
| 719 | beg_unchanged = GPT - BEG; | 741 | beg_unchanged = GPT - BEG; |