From 35d6372510105dac02121424a88221c5737dd020 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Wed, 29 Apr 1998 00:20:14 +0000 Subject: [PATCH] (insert_1_both): Call prepare_to_modify_buffer before moving or making gap. (insert_from_string_1): Don't check max buffer size here. --- src/insdel.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/insdel.c b/src/insdel.c index 813e98cff9c..9c01c333f0b 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -1020,14 +1020,17 @@ insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) if (NILP (current_buffer->enable_multibyte_characters)) nchars = nbytes; + if (prepare) + /* Do this before moving and increasing the gap, + because the before-change hooks might move the gap + or make it smaller. */ + prepare_to_modify_buffer (PT, PT, NULL); + if (PT != GPT) move_gap_both (PT, PT_BYTE); if (GAP_SIZE < nbytes) make_gap (nbytes - GAP_SIZE); - if (prepare) - prepare_to_modify_buffer (PT, PT, NULL); - combined_before_bytes = count_combining_before (string, nbytes, PT, PT_BYTE); combined_after_bytes @@ -1179,12 +1182,10 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, = count_size_as_multibyte (&XSTRING (string)->data[pos_byte], nbytes); - /* Make sure point-max won't overflow after this insertion. */ - XSETINT (temp, outgoing_nbytes + Z); - if (outgoing_nbytes + Z != XINT (temp)) - error ("Maximum buffer size exceeded"); - GCPRO1 (string); + /* Do this before moving and increasing the gap, + because the before-change hooks might move the gap + or make it smaller. */ prepare_to_modify_buffer (PT, PT, NULL); if (PT != GPT) @@ -1342,6 +1343,9 @@ insert_from_buffer_1 (buf, from, nchars, inherit) if (outgoing_nbytes + Z != XINT (temp)) error ("Maximum buffer size exceeded"); + /* Do this before moving and increasing the gap, + because the before-change hooks might move the gap + or make it smaller. */ prepare_to_modify_buffer (PT, PT, NULL); if (PT != GPT) -- 2.39.2