Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
9836030d
Commit
9836030d
authored
Jul 02, 2019
by
Stefan Monnier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* src/json.c (Fjson_insert): Don't temporarily insert invalid bytes in buffer
parent
fe3676fe
Pipeline
#2231
failed with stage
in 51 minutes and 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
src/json.c
src/json.c
+8
-9
No files found.
src/json.c
View file @
9836030d
...
...
@@ -739,9 +739,6 @@ usage: (json-insert OBJECT &rest ARGS) */)
ptrdiff_t
inserted_bytes
=
data
.
inserted_bytes
;
if
(
inserted_bytes
>
0
)
{
/* Make the inserted text part of the buffer, as unibyte text. */
insert_from_gap_1
(
inserted_bytes
,
inserted_bytes
,
false
);
/* If required, decode the stuff we've read into the gap. */
struct
coding_system
coding
;
/* JSON strings are UTF-8 encoded strings. If for some reason
...
...
@@ -753,17 +750,19 @@ usage: (json-insert OBJECT &rest ARGS) */)
!
NILP
(
BVAR
(
current_buffer
,
enable_multibyte_characters
));
if
(
CODING_MAY_REQUIRE_DECODING
(
&
coding
))
{
move_gap_both
(
PT
,
PT_BYTE
);
GAP_SIZE
+=
inserted_bytes
;
ZV_BYTE
-=
inserted_bytes
;
Z_BYTE
-=
inserted_bytes
;
ZV
-=
inserted_bytes
;
Z
-=
inserted_bytes
;
/* Now we have all the new bytes at the beginning of the gap,
but `decode_coding_gap` needs them at the end of the gap, so
we need to move them. */
memmove
(
GAP_END_ADDR
-
inserted_bytes
,
GPT_ADDR
,
inserted_bytes
);
decode_coding_gap
(
&
coding
,
inserted_bytes
);
inserted
=
coding
.
produced_char
;
}
else
{
/* Make the inserted text part of the buffer, as unibyte text. */
eassert
(
NILP
(
BVAR
(
current_buffer
,
enable_multibyte_characters
)));
insert_from_gap_1
(
inserted_bytes
,
inserted_bytes
,
false
);
/* The target buffer is unibyte, so we don't need to decode. */
invalidate_buffer_caches
(
current_buffer
,
PT
,
PT
+
inserted_bytes
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment