From: Stefan Monnier Date: Tue, 2 Jul 2019 19:48:25 +0000 (-0400) Subject: * src/coding.c (decode_coding_gap): Remove `chars` argument. X-Git-Tag: emacs-27.0.90~2121 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1c88af362f038c010f1a5c63e0ed5a431ba5d5a7;p=emacs.git * src/coding.c (decode_coding_gap): Remove `chars` argument. * src/json.c (Fjson_insert): * src/fileio.c (Finsert_file_contents): * src/coding.h (decode_coding_gap): Adjust accordingly. --- diff --git a/src/coding.c b/src/coding.c index 5b9bfa17dd2..59589caee61 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7892,23 +7892,26 @@ coding_restore_undo_list (Lisp_Object arg) bset_undo_list (buf, undo_list); } +/* Decode the *last* BYTES of the gap and insert them at point. */ void -decode_coding_gap (struct coding_system *coding, - ptrdiff_t chars, ptrdiff_t bytes) +decode_coding_gap (struct coding_system *coding, ptrdiff_t bytes) { ptrdiff_t count = SPECPDL_INDEX (); Lisp_Object attrs; + eassert (GPT_BYTE == PT_BYTE); + coding->src_object = Fcurrent_buffer (); - coding->src_chars = chars; + coding->src_chars = bytes; coding->src_bytes = bytes; - coding->src_pos = -chars; + coding->src_pos = -bytes; coding->src_pos_byte = -bytes; - coding->src_multibyte = chars < bytes; + coding->src_multibyte = false; coding->dst_object = coding->src_object; coding->dst_pos = PT; coding->dst_pos_byte = PT_BYTE; - coding->dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); + eassert (coding->dst_multibyte + == !NILP (BVAR (current_buffer, enable_multibyte_characters))); coding->head_ascii = -1; coding->detected_utf8_bytes = coding->detected_utf8_chars = -1; @@ -7922,7 +7925,7 @@ decode_coding_gap (struct coding_system *coding, && NILP (CODING_ATTR_POST_READ (attrs)) && NILP (get_translation_table (attrs, 0, NULL))) { - chars = coding->head_ascii; + ptrdiff_t chars = coding->head_ascii; if (chars < 0) chars = check_ascii (coding); if (chars != bytes) diff --git a/src/coding.h b/src/coding.h index 619ca29c8e4..70690d42d30 100644 --- a/src/coding.h +++ b/src/coding.h @@ -697,8 +697,7 @@ extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); extern Lisp_Object complement_process_encoding_system (Lisp_Object); extern Lisp_Object make_string_from_utf8 (const char *, ptrdiff_t); -extern void decode_coding_gap (struct coding_system *, - ptrdiff_t, ptrdiff_t); +extern void decode_coding_gap (struct coding_system *, ptrdiff_t); extern void decode_coding_object (struct coding_system *, Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, Lisp_Object); diff --git a/src/fileio.c b/src/fileio.c index ed1d2aedf37..7f4478a9448 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4538,7 +4538,7 @@ by calling `format-decode', which see. */) Z_BYTE -= inserted; ZV -= inserted; Z -= inserted; - decode_coding_gap (&coding, inserted, inserted); + decode_coding_gap (&coding, inserted); inserted = coding.produced_char; coding_system = CODING_ID_NAME (coding.id); } diff --git a/src/json.c b/src/json.c index 48820a1cb04..4c897d4be04 100644 --- a/src/json.c +++ b/src/json.c @@ -769,7 +769,7 @@ usage: (json-insert OBJECT &rest ARGS) */) Z_BYTE -= inserted_bytes; ZV -= inserted_bytes; Z -= inserted_bytes; - decode_coding_gap (&coding, inserted_bytes, inserted_bytes); + decode_coding_gap (&coding, inserted_bytes); inserted = coding.produced_char; } else