diff options
| author | Paul Eggert | 2012-11-17 07:15:49 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-11-17 07:15:49 -0800 |
| commit | a631d0e04747884855aa460cb903d1fd2ff106f4 (patch) | |
| tree | e316cab6161062e84239ec80fcdc23cfc16c1379 /src | |
| parent | d76afb936dc9cf6a7be48162ebb3c7114e65412a (diff) | |
| download | emacs-a631d0e04747884855aa460cb903d1fd2ff106f4.tar.gz emacs-a631d0e04747884855aa460cb903d1fd2ff106f4.zip | |
Fix problems in ns port found by static checking.
* nsterm.m: Include <pthread.h>, for pthread_mutex_lock etc.
(hold_event, setPosition:portion:whole:): Send SIGIO only to self,
not to process group.
(ns_select): Use emacs_write, not write, as that's more robust
in the presence of signals.
(fd_handler:): Check for read errors.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/nsterm.m | 22 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 695fbab5813..1194fe099fa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Fix problems in ns port found by static checking. | ||
| 4 | * nsterm.m: Include <pthread.h>, for pthread_mutex_lock etc. | ||
| 5 | (hold_event, setPosition:portion:whole:): Send SIGIO only to self, | ||
| 6 | not to process group. | ||
| 7 | (ns_select): Use emacs_write, not write, as that's more robust | ||
| 8 | in the presence of signals. | ||
| 9 | (fd_handler:): Check for read errors. | ||
| 10 | |||
| 1 | 2012-11-16 Glenn Morris <rgm@gnu.org> | 11 | 2012-11-16 Glenn Morris <rgm@gnu.org> |
| 2 | 12 | ||
| 3 | * editfns.c (Fmessage): Mention message-log-max. (Bug#12849) | 13 | * editfns.c (Fmessage): Mention message-log-max. (Bug#12849) |
diff --git a/src/nsterm.m b/src/nsterm.m index 7c66708e7cb..3640ac0c5e8 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -31,6 +31,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 31 | #include <config.h> | 31 | #include <config.h> |
| 32 | 32 | ||
| 33 | #include <math.h> | 33 | #include <math.h> |
| 34 | #include <pthread.h> | ||
| 34 | #include <sys/types.h> | 35 | #include <sys/types.h> |
| 35 | #include <time.h> | 36 | #include <time.h> |
| 36 | #include <signal.h> | 37 | #include <signal.h> |
| @@ -331,7 +332,7 @@ hold_event (struct input_event *event) | |||
| 331 | 332 | ||
| 332 | hold_event_q.q[hold_event_q.nr++] = *event; | 333 | hold_event_q.q[hold_event_q.nr++] = *event; |
| 333 | /* Make sure ns_read_socket is called, i.e. we have input. */ | 334 | /* Make sure ns_read_socket is called, i.e. we have input. */ |
| 334 | kill (0, SIGIO); | 335 | raise (SIGIO); |
| 335 | } | 336 | } |
| 336 | 337 | ||
| 337 | static Lisp_Object | 338 | static Lisp_Object |
| @@ -3389,7 +3390,7 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) | |||
| 3389 | if ([NSApp modalWindow] != nil) | 3390 | if ([NSApp modalWindow] != nil) |
| 3390 | return -1; | 3391 | return -1; |
| 3391 | 3392 | ||
| 3392 | if (hold_event_q.nr > 0) | 3393 | if (hold_event_q.nr > 0) |
| 3393 | { | 3394 | { |
| 3394 | int i; | 3395 | int i; |
| 3395 | for (i = 0; i < hold_event_q.nr; ++i) | 3396 | for (i = 0; i < hold_event_q.nr; ++i) |
| @@ -3504,7 +3505,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, | |||
| 3504 | 3505 | ||
| 3505 | /* Inform fd_handler that select should be called */ | 3506 | /* Inform fd_handler that select should be called */ |
| 3506 | c = 'g'; | 3507 | c = 'g'; |
| 3507 | write (selfds[1], &c, 1); | 3508 | emacs_write (selfds[1], &c, 1); |
| 3508 | } | 3509 | } |
| 3509 | else if (nr == 0 && timeout) | 3510 | else if (nr == 0 && timeout) |
| 3510 | { | 3511 | { |
| @@ -3537,7 +3538,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, | |||
| 3537 | if (nr > 0 && readfds) | 3538 | if (nr > 0 && readfds) |
| 3538 | { | 3539 | { |
| 3539 | c = 's'; | 3540 | c = 's'; |
| 3540 | write (selfds[1], &c, 1); | 3541 | emacs_write (selfds[1], &c, 1); |
| 3541 | } | 3542 | } |
| 3542 | unblock_input (); | 3543 | unblock_input (); |
| 3543 | 3544 | ||
| @@ -4576,11 +4577,8 @@ not_in_argv (NSString *arg) | |||
| 4576 | 4577 | ||
| 4577 | FD_SET (selfds[0], &fds); | 4578 | FD_SET (selfds[0], &fds); |
| 4578 | result = select (selfds[0]+1, &fds, NULL, NULL, NULL); | 4579 | result = select (selfds[0]+1, &fds, NULL, NULL, NULL); |
| 4579 | if (result > 0) | 4580 | if (result > 0 && read (selfds[0], &c, 1) == 1 && c == 'g') |
| 4580 | { | 4581 | waiting = 0; |
| 4581 | read (selfds[0], &c, 1); | ||
| 4582 | if (c == 'g') waiting = 0; | ||
| 4583 | } | ||
| 4584 | } | 4582 | } |
| 4585 | else | 4583 | else |
| 4586 | { | 4584 | { |
| @@ -4620,8 +4618,8 @@ not_in_argv (NSString *arg) | |||
| 4620 | { | 4618 | { |
| 4621 | if (FD_ISSET (selfds[0], &readfds)) | 4619 | if (FD_ISSET (selfds[0], &readfds)) |
| 4622 | { | 4620 | { |
| 4623 | read (selfds[0], &c, 1); | 4621 | if (read (selfds[0], &c, 1) == 1 && c == 's') |
| 4624 | if (c == 's') waiting = 1; | 4622 | waiting = 1; |
| 4625 | } | 4623 | } |
| 4626 | else | 4624 | else |
| 4627 | { | 4625 | { |
| @@ -6696,7 +6694,7 @@ not_in_argv (NSString *arg) | |||
| 6696 | /* Events may come here even if the event loop is not running. | 6694 | /* Events may come here even if the event loop is not running. |
| 6697 | If we don't enter the event loop, the scroll bar will not update. | 6695 | If we don't enter the event loop, the scroll bar will not update. |
| 6698 | So send SIGIO to ourselves. */ | 6696 | So send SIGIO to ourselves. */ |
| 6699 | if (apploopnr == 0) kill (0, SIGIO); | 6697 | if (apploopnr == 0) raise (SIGIO); |
| 6700 | 6698 | ||
| 6701 | return self; | 6699 | return self; |
| 6702 | } | 6700 | } |