From: Po Lu Date: Wed, 15 Feb 2023 05:38:53 +0000 (+0800) Subject: Fix small bugs X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b875a2eaf31d3e9db0ae70bc6a1ed4c9bcd573ff;p=emacs.git Fix small bugs * src/androidterm.c (android_handle_ime_event): Pacify compiler warnings. * src/textconv.c (really_set_composing_text) (handle_pending_conversion_events, get_extracted_text): Fix reentrancy problems and uses of uninitialized values. --- diff --git a/src/androidterm.c b/src/androidterm.c index a44bae954da..767b7d8240c 100644 --- a/src/androidterm.c +++ b/src/androidterm.c @@ -572,7 +572,7 @@ android_decode_utf16 (unsigned short *utf16, size_t n) static void android_handle_ime_event (union android_event *event, struct frame *f) { - Lisp_Object text; + Lisp_Object text UNINIT; /* First, decode the text if necessary. */ @@ -4811,6 +4811,8 @@ NATIVE_NAME (setSelection) (JNIEnv *env, jobject object, jshort window, event.ime.position = start; event.ime.text = NULL; event.ime.counter = ++edit_counter; + + android_write_event (&event); } /* Structure describing the context for `getSelection'. */ diff --git a/src/textconv.c b/src/textconv.c index b62ed7d1365..a39748457d3 100644 --- a/src/textconv.c +++ b/src/textconv.c @@ -583,6 +583,8 @@ really_set_composing_text (struct frame *f, ptrdiff_t position, Fpoint (), Qnil); Fset_marker_insertion_type (f->conversion.compose_region_end, Qt); + + start = position; } else { @@ -875,14 +877,25 @@ handle_pending_conversion_events (void) /* Test if F has any outstanding conversion events. Then process them in bottom to up order. */ - for (action = f->conversion.actions; action; action = next) + while (true) { /* Redisplay in between if there is more than one - action. */ + action. + + This can read input. This function must be reentrant + here. */ if (handled) redisplay (); + /* Reload action. */ + action = f->conversion.actions; + + /* If there are no more actions, break. */ + + if (!action) + break; + /* Unlink this action. */ next = action->next; f->conversion.actions = next; @@ -1134,7 +1147,7 @@ get_extracted_text (struct frame *f, ptrdiff_t n, /* Detect overflow. */ - if (!(start <= PT <= end)) + if (!(start <= PT && PT <= end)) goto finish; /* Convert the character positions to byte positions. */