1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-02-08 20:58:58 +00:00

Clean up failable requests in more places

* lisp/term/haiku-win.el (haiku-get-numeric-enum): Fix build.

* src/xterm.c (x_clean_failable_requests): Avoid redundant
memcpy if first == last.
(x_ignore_errors_for_next_request): Fix check for last request.
(x_check_errors, x_had_errors_p): Clean up failable requests
here.
This commit is contained in:
Po Lu 2022-06-29 15:09:17 +08:00
parent 7fa37d7a14
commit 60af986f38
2 changed files with 39 additions and 22 deletions

View File

@ -174,25 +174,26 @@ VALUE as a unibyte string, or nil if VALUE was not a string."
(insert "\n")))
(buffer-string))))))
(defun haiku-get-numeric-enum (name)
"Return the numeric value of the system enumerator NAME."
(or (get name 'haiku-numeric-enum)
(let ((value 0)
(offset 0)
(string (symbol-name name)))
(cl-loop for octet across string
do (progn
(when (or (< octet 0)
(> octet 255))
(error "Out of range octet: %d" octet))
(setq value
(logior value
(lsh octet
(- (* (1- (length string)) 8)
offset))))
(setq offset (+ offset 8))))
(prog1 value
(put name 'haiku-enumerator-id value)))))
(eval-and-compile
(defun haiku-get-numeric-enum (name)
"Return the numeric value of the system enumerator NAME."
(or (get name 'haiku-numeric-enum)
(let ((value 0)
(offset 0)
(string (symbol-name name)))
(cl-loop for octet across string
do (progn
(when (or (< octet 0)
(> octet 255))
(error "Out of range octet: %d" octet))
(setq value
(logior value
(lsh octet
(- (* (1- (length string)) 8)
offset))))
(setq offset (+ offset 8))))
(prog1 value
(put name 'haiku-enumerator-id value))))))
(defmacro haiku-numeric-enum (name)
"Expand to the numeric value NAME as a system identifier."

View File

@ -23010,8 +23010,9 @@ x_clean_failable_requests (struct x_display_info *dpyinfo)
break;
}
memmove (&dpyinfo->failable_requests, first,
sizeof *first * (last - first));
if (first != last)
memmove (&dpyinfo->failable_requests, first,
sizeof *first * (last - first));
dpyinfo->next_failable_request = (dpyinfo->failable_requests
+ (last - first));
@ -23025,7 +23026,7 @@ x_ignore_errors_for_next_request (struct x_display_info *dpyinfo)
request = dpyinfo->next_failable_request;
max = dpyinfo->failable_requests + N_FAILABLE_REQUESTS;
if (request > max)
if (request >= max)
{
/* There is no point in making this extra sync if all requests
are known to have been fully processed. */
@ -23119,6 +23120,7 @@ x_uncatch_errors (void)
void
x_check_errors (Display *dpy, const char *format)
{
struct x_display_info *dpyinfo;
char *string;
/* This shouldn't happen, since x_check_errors should be called
@ -23134,6 +23136,12 @@ x_check_errors (Display *dpy, const char *format)
> x_error_message->first_request))
XSync (dpy, False);
dpyinfo = x_display_info_for_display (dpy);
/* Clean the array of failable requests, since a sync happened. */
if (dpyinfo)
x_clean_failable_requests (dpyinfo);
if (x_error_message->string)
{
string = alloca (strlen (x_error_message->string) + 1);
@ -23149,6 +23157,8 @@ x_check_errors (Display *dpy, const char *format)
bool
x_had_errors_p (Display *dpy)
{
struct x_display_info *dpyinfo;
/* This shouldn't happen, since x_check_errors should be called
immediately inside an x_catch_errors block. */
if (dpy != x_error_message->dpy)
@ -23161,6 +23171,12 @@ x_had_errors_p (Display *dpy)
> x_error_message->first_request))
XSync (dpy, False);
dpyinfo = x_display_info_for_display (dpy);
/* Clean the array of failable requests, since a sync happened. */
if (dpyinfo)
x_clean_failable_requests (dpyinfo);
return !!x_error_message->string;
}