Commit bfed7386 authored by Caleb C. Sander's avatar Caleb C. Sander
Browse files

Insert matching ), ], and } characters

No related merge requests found
Showing with 14 additions and 7 deletions
+14 -7
...@@ -1862,14 +1862,21 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1862,14 +1862,21 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
continue; continue;
/* Make room for the new character and copy it into the line. */ /* Make room for the new character and copy it into the line. */
openfile->current->data = charealloc(openfile->current->data, char matching_char =
current_len + char_len + 1); *onechar == '(' ? ')' :
charmove(openfile->current->data + openfile->current_x + char_len, *onechar == '[' ? ']' :
openfile->current->data + openfile->current_x, *onechar == '{' ? '}' : '\0';
size_t insert_length = matching_char ? char_len + 1 : char_len;
openfile->current->data =
charealloc(openfile->current->data, current_len + insert_length + 1);
char *insert_start = openfile->current->data + openfile->current_x;
charmove(insert_start + insert_length, insert_start,
current_len - openfile->current_x + 1); current_len - openfile->current_x + 1);
strncpy(openfile->current->data + openfile->current_x, onechar, strncpy(insert_start, onechar, char_len);
char_len); if (matching_char) {
current_len += char_len; insert_start[char_len] = matching_char;
}
current_len += insert_length;
openfile->totsize++; openfile->totsize++;
set_modified(); set_modified();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment