diff options
| author | Joakim Verona | 2011-08-27 19:45:48 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-08-27 19:45:48 +0200 |
| commit | 9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4 (patch) | |
| tree | e94476d49f15747fcb9409d773702e88201855a4 /src/xterm.c | |
| parent | c7489583c30031c0ecfae9d20b20c149ca1935e9 (diff) | |
| parent | b75258b32810f3690442bddef2e10eef126d2d25 (diff) | |
| download | emacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.tar.gz emacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.zip | |
upstream
Diffstat (limited to 'src/xterm.c')
| -rw-r--r-- | src/xterm.c | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/src/xterm.c b/src/xterm.c index cefb98a476d..be456a61a6f 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1662,19 +1662,18 @@ x_color_cells (Display *dpy, int *ncells) | |||
| 1662 | if (dpyinfo->color_cells == NULL) | 1662 | if (dpyinfo->color_cells == NULL) |
| 1663 | { | 1663 | { |
| 1664 | Screen *screen = dpyinfo->screen; | 1664 | Screen *screen = dpyinfo->screen; |
| 1665 | int ncolor_cells = XDisplayCells (dpy, XScreenNumberOfScreen (screen)); | ||
| 1665 | int i; | 1666 | int i; |
| 1666 | 1667 | ||
| 1667 | dpyinfo->ncolor_cells | 1668 | dpyinfo->color_cells = xnmalloc (ncolor_cells, |
| 1668 | = XDisplayCells (dpy, XScreenNumberOfScreen (screen)); | 1669 | sizeof *dpyinfo->color_cells); |
| 1669 | dpyinfo->color_cells | 1670 | dpyinfo->ncolor_cells = ncolor_cells; |
| 1670 | = (XColor *) xmalloc (dpyinfo->ncolor_cells | ||
| 1671 | * sizeof *dpyinfo->color_cells); | ||
| 1672 | 1671 | ||
| 1673 | for (i = 0; i < dpyinfo->ncolor_cells; ++i) | 1672 | for (i = 0; i < ncolor_cells; ++i) |
| 1674 | dpyinfo->color_cells[i].pixel = i; | 1673 | dpyinfo->color_cells[i].pixel = i; |
| 1675 | 1674 | ||
| 1676 | XQueryColors (dpy, dpyinfo->cmap, | 1675 | XQueryColors (dpy, dpyinfo->cmap, |
| 1677 | dpyinfo->color_cells, dpyinfo->ncolor_cells); | 1676 | dpyinfo->color_cells, ncolor_cells); |
| 1678 | } | 1677 | } |
| 1679 | 1678 | ||
| 1680 | *ncells = dpyinfo->ncolor_cells; | 1679 | *ncells = dpyinfo->ncolor_cells; |
| @@ -4233,7 +4232,7 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name, | |||
| 4233 | x_send_scroll_bar_event and x_scroll_bar_to_input_event. */ | 4232 | x_send_scroll_bar_event and x_scroll_bar_to_input_event. */ |
| 4234 | 4233 | ||
| 4235 | static struct window **scroll_bar_windows; | 4234 | static struct window **scroll_bar_windows; |
| 4236 | static size_t scroll_bar_windows_size; | 4235 | static ptrdiff_t scroll_bar_windows_size; |
| 4237 | 4236 | ||
| 4238 | 4237 | ||
| 4239 | /* Send a client message with message type Xatom_Scrollbar for a | 4238 | /* Send a client message with message type Xatom_Scrollbar for a |
| @@ -4248,7 +4247,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) | |||
| 4248 | XClientMessageEvent *ev = (XClientMessageEvent *) &event; | 4247 | XClientMessageEvent *ev = (XClientMessageEvent *) &event; |
| 4249 | struct window *w = XWINDOW (window); | 4248 | struct window *w = XWINDOW (window); |
| 4250 | struct frame *f = XFRAME (w->frame); | 4249 | struct frame *f = XFRAME (w->frame); |
| 4251 | size_t i; | 4250 | ptrdiff_t i; |
| 4252 | 4251 | ||
| 4253 | BLOCK_INPUT; | 4252 | BLOCK_INPUT; |
| 4254 | 4253 | ||
| @@ -4269,16 +4268,15 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) | |||
| 4269 | 4268 | ||
| 4270 | if (i == scroll_bar_windows_size) | 4269 | if (i == scroll_bar_windows_size) |
| 4271 | { | 4270 | { |
| 4272 | size_t new_size = max (10, 2 * scroll_bar_windows_size); | 4271 | ptrdiff_t old_nbytes = |
| 4273 | size_t nbytes = new_size * sizeof *scroll_bar_windows; | 4272 | scroll_bar_windows_size * sizeof *scroll_bar_windows; |
| 4274 | size_t old_nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; | 4273 | ptrdiff_t nbytes; |
| 4275 | 4274 | enum { XClientMessageEvent_MAX = 0x7fffffff }; | |
| 4276 | if ((size_t) -1 / sizeof *scroll_bar_windows < new_size) | 4275 | scroll_bar_windows = |
| 4277 | memory_full (SIZE_MAX); | 4276 | xpalloc (scroll_bar_windows, &scroll_bar_windows_size, 1, |
| 4278 | scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows, | 4277 | XClientMessageEvent_MAX, sizeof *scroll_bar_windows); |
| 4279 | nbytes); | 4278 | nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; |
| 4280 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); | 4279 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); |
| 4281 | scroll_bar_windows_size = new_size; | ||
| 4282 | } | 4280 | } |
| 4283 | 4281 | ||
| 4284 | scroll_bar_windows[i] = w; | 4282 | scroll_bar_windows[i] = w; |
| @@ -5856,11 +5854,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 5856 | } inev; | 5854 | } inev; |
| 5857 | int count = 0; | 5855 | int count = 0; |
| 5858 | int do_help = 0; | 5856 | int do_help = 0; |
| 5859 | int nbytes = 0; | 5857 | ptrdiff_t nbytes = 0; |
| 5860 | struct frame *f = NULL; | 5858 | struct frame *f = NULL; |
| 5861 | struct coding_system coding; | 5859 | struct coding_system coding; |
| 5862 | XEvent event = *eventptr; | 5860 | XEvent event = *eventptr; |
| 5863 | Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; | 5861 | Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; |
| 5862 | USE_SAFE_ALLOCA; | ||
| 5864 | 5863 | ||
| 5865 | *finish = X_EVENT_NORMAL; | 5864 | *finish = X_EVENT_NORMAL; |
| 5866 | 5865 | ||
| @@ -6556,7 +6555,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6556 | } | 6555 | } |
| 6557 | 6556 | ||
| 6558 | { /* Raw bytes, not keysym. */ | 6557 | { /* Raw bytes, not keysym. */ |
| 6559 | register int i; | 6558 | ptrdiff_t i; |
| 6560 | int nchars, len; | 6559 | int nchars, len; |
| 6561 | 6560 | ||
| 6562 | for (i = 0, nchars = 0; i < nbytes; i++) | 6561 | for (i = 0, nchars = 0; i < nbytes; i++) |
| @@ -6569,7 +6568,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6569 | if (nchars < nbytes) | 6568 | if (nchars < nbytes) |
| 6570 | { | 6569 | { |
| 6571 | /* Decode the input data. */ | 6570 | /* Decode the input data. */ |
| 6572 | int require; | ||
| 6573 | 6571 | ||
| 6574 | /* The input should be decoded with `coding_system' | 6572 | /* The input should be decoded with `coding_system' |
| 6575 | which depends on which X*LookupString function | 6573 | which depends on which X*LookupString function |
| @@ -6582,9 +6580,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6582 | gives us composition information. */ | 6580 | gives us composition information. */ |
| 6583 | coding.common_flags &= ~CODING_ANNOTATION_MASK; | 6581 | coding.common_flags &= ~CODING_ANNOTATION_MASK; |
| 6584 | 6582 | ||
| 6585 | require = MAX_MULTIBYTE_LENGTH * nbytes; | 6583 | SAFE_NALLOCA (coding.destination, MAX_MULTIBYTE_LENGTH, |
| 6586 | coding.destination = alloca (require); | 6584 | nbytes); |
| 6587 | coding.dst_bytes = require; | 6585 | coding.dst_bytes = MAX_MULTIBYTE_LENGTH * nbytes; |
| 6588 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6586 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 6589 | decode_coding_c_string (&coding, copy_bufptr, nbytes, Qnil); | 6587 | decode_coding_c_string (&coding, copy_bufptr, nbytes, Qnil); |
| 6590 | nbytes = coding.produced; | 6588 | nbytes = coding.produced; |
| @@ -7043,6 +7041,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 7043 | count++; | 7041 | count++; |
| 7044 | } | 7042 | } |
| 7045 | 7043 | ||
| 7044 | SAFE_FREE (); | ||
| 7046 | *eventptr = event; | 7045 | *eventptr = event; |
| 7047 | return count; | 7046 | return count; |
| 7048 | } | 7047 | } |
| @@ -9872,6 +9871,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 9872 | struct x_display_info *dpyinfo; | 9871 | struct x_display_info *dpyinfo; |
| 9873 | XrmDatabase xrdb; | 9872 | XrmDatabase xrdb; |
| 9874 | Mouse_HLInfo *hlinfo; | 9873 | Mouse_HLInfo *hlinfo; |
| 9874 | ptrdiff_t lim; | ||
| 9875 | 9875 | ||
| 9876 | BLOCK_INPUT; | 9876 | BLOCK_INPUT; |
| 9877 | 9877 | ||
| @@ -10094,12 +10094,15 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10094 | XSetAfterFunction (x_current_display, x_trace_wire); | 10094 | XSetAfterFunction (x_current_display, x_trace_wire); |
| 10095 | #endif /* ! 0 */ | 10095 | #endif /* ! 0 */ |
| 10096 | 10096 | ||
| 10097 | lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@"; | ||
| 10098 | if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name)) | ||
| 10099 | memory_full (SIZE_MAX); | ||
| 10097 | dpyinfo->x_id_name | 10100 | dpyinfo->x_id_name |
| 10098 | = (char *) xmalloc (SBYTES (Vinvocation_name) | 10101 | = (char *) xmalloc (SBYTES (Vinvocation_name) |
| 10099 | + SBYTES (Vsystem_name) | 10102 | + SBYTES (Vsystem_name) |
| 10100 | + 2); | 10103 | + 2); |
| 10101 | sprintf (dpyinfo->x_id_name, "%s@%s", | 10104 | strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), |
| 10102 | SSDATA (Vinvocation_name), SSDATA (Vsystem_name)); | 10105 | SSDATA (Vsystem_name)); |
| 10103 | 10106 | ||
| 10104 | /* Figure out which modifier bits mean what. */ | 10107 | /* Figure out which modifier bits mean what. */ |
| 10105 | x_find_modifier_meanings (dpyinfo); | 10108 | x_find_modifier_meanings (dpyinfo); |