diff options
| author | Paul Eggert | 2011-09-03 16:03:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-09-03 16:03:38 -0700 |
| commit | b49e353d9d01adbe60bc5d0b1658b4ef978b0b06 (patch) | |
| tree | 9f2ffa6f7a6562abf661a4951012b488ad8b1ae7 /src | |
| parent | 74b880cbc18bd0194c7b1fc44c4a983ee05adae2 (diff) | |
| parent | bc3200871917d5c54c8c4299a06bf8f8ba2ea02d (diff) | |
| download | emacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.tar.gz emacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.zip | |
Merge from trunk.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 1021 | ||||
| -rw-r--r-- | src/Makefile.in | 5 | ||||
| -rw-r--r-- | src/alloc.c | 106 | ||||
| -rw-r--r-- | src/bidi.c | 257 | ||||
| -rw-r--r-- | src/bidimirror.h | 365 | ||||
| -rw-r--r-- | src/biditype.h | 447 | ||||
| -rw-r--r-- | src/buffer.c | 101 | ||||
| -rw-r--r-- | src/callproc.c | 14 | ||||
| -rw-r--r-- | src/category.c | 2 | ||||
| -rw-r--r-- | src/ccl.c | 41 | ||||
| -rw-r--r-- | src/character.c | 10 | ||||
| -rw-r--r-- | src/character.h | 22 | ||||
| -rw-r--r-- | src/charset.c | 89 | ||||
| -rw-r--r-- | src/charset.h | 4 | ||||
| -rw-r--r-- | src/chartab.c | 29 | ||||
| -rw-r--r-- | src/cmds.c | 5 | ||||
| -rw-r--r-- | src/coding.c | 17 | ||||
| -rw-r--r-- | src/coding.h | 2 | ||||
| -rw-r--r-- | src/composite.c | 69 | ||||
| -rw-r--r-- | src/composite.h | 12 | ||||
| -rw-r--r-- | src/deps.mk | 2 | ||||
| -rw-r--r-- | src/dispextern.h | 43 | ||||
| -rw-r--r-- | src/dispnew.c | 134 | ||||
| -rw-r--r-- | src/doc.c | 37 | ||||
| -rw-r--r-- | src/editfns.c | 21 | ||||
| -rw-r--r-- | src/emacs.c | 41 | ||||
| -rw-r--r-- | src/eval.c | 65 | ||||
| -rw-r--r-- | src/fileio.c | 6 | ||||
| -rw-r--r-- | src/fns.c | 18 | ||||
| -rw-r--r-- | src/fontset.c | 10 | ||||
| -rw-r--r-- | src/frame.c | 38 | ||||
| -rw-r--r-- | src/frame.h | 4 | ||||
| -rw-r--r-- | src/fringe.c | 13 | ||||
| -rw-r--r-- | src/ftfont.c | 38 | ||||
| -rw-r--r-- | src/gmalloc.c | 64 | ||||
| -rw-r--r-- | src/gnutls.c | 416 | ||||
| -rw-r--r-- | src/gtkutil.c | 53 | ||||
| -rw-r--r-- | src/gtkutil.h | 7 | ||||
| -rw-r--r-- | src/image.c | 327 | ||||
| -rw-r--r-- | src/indent.c | 27 | ||||
| -rw-r--r-- | src/keyboard.c | 103 | ||||
| -rw-r--r-- | src/keyboard.h | 2 | ||||
| -rw-r--r-- | src/keymap.c | 48 | ||||
| -rw-r--r-- | src/keymap.h | 2 | ||||
| -rw-r--r-- | src/lisp.h | 31 | ||||
| -rw-r--r-- | src/lread.c | 48 | ||||
| -rw-r--r-- | src/macros.c | 4 | ||||
| -rw-r--r-- | src/makefile.w32-in | 3 | ||||
| -rw-r--r-- | src/minibuf.c | 2 | ||||
| -rw-r--r-- | src/nsfns.m | 42 | ||||
| -rw-r--r-- | src/nsfont.m | 2 | ||||
| -rw-r--r-- | src/nsmenu.m | 2 | ||||
| -rw-r--r-- | src/nsterm.h | 7 | ||||
| -rw-r--r-- | src/nsterm.m | 29 | ||||
| -rw-r--r-- | src/process.c | 121 | ||||
| -rw-r--r-- | src/regex.c | 11 | ||||
| -rw-r--r-- | src/region-cache.c | 84 | ||||
| -rw-r--r-- | src/region-cache.h | 12 | ||||
| -rw-r--r-- | src/scroll.c | 34 | ||||
| -rw-r--r-- | src/search.c | 61 | ||||
| -rw-r--r-- | src/syntax.c | 5 | ||||
| -rw-r--r-- | src/sysdep.c | 8 | ||||
| -rw-r--r-- | src/syssignal.h | 2 | ||||
| -rw-r--r-- | src/term.c | 175 | ||||
| -rw-r--r-- | src/termcap.c | 17 | ||||
| -rw-r--r-- | src/termhooks.h | 6 | ||||
| -rw-r--r-- | src/tparam.c | 26 | ||||
| -rw-r--r-- | src/unexcw.c | 5 | ||||
| -rw-r--r-- | src/unexmacosx.c | 37 | ||||
| -rw-r--r-- | src/w32term.c | 16 | ||||
| -rw-r--r-- | src/window.c | 20 | ||||
| -rw-r--r-- | src/xdisp.c | 639 | ||||
| -rw-r--r-- | src/xfaces.c | 178 | ||||
| -rw-r--r-- | src/xfns.c | 39 | ||||
| -rw-r--r-- | src/xgselect.c | 7 | ||||
| -rw-r--r-- | src/xml.c | 1 | ||||
| -rw-r--r-- | src/xrdb.c | 16 | ||||
| -rw-r--r-- | src/xselect.c | 316 | ||||
| -rw-r--r-- | src/xsmfns.c | 4 | ||||
| -rw-r--r-- | src/xterm.c | 93 |
80 files changed, 3539 insertions, 2701 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9e8aedfd36b..f3953630803 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,918 @@ | |||
| 1 | 2011-09-03 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * Require libxml/parser.h to avoid compilation warning. | ||
| 4 | |||
| 5 | * emacs.c (shut_down_emacs): Call xmlCleanupParser on shutdown. | ||
| 6 | |||
| 7 | * xml.c (parse_region): Don't call xmlCleanupParser after parsing, | ||
| 8 | since this reportedly can destroy thread storage. | ||
| 9 | |||
| 10 | 2011-08-30 Chong Yidong <cyd@stupidchicken.com> | ||
| 11 | |||
| 12 | * syntax.c (find_defun_start): Update all cache variables if | ||
| 13 | exiting early (Bug#9401). | ||
| 14 | |||
| 15 | 2011-08-30 Eli Zaretskii <eliz@gnu.org> | ||
| 16 | |||
| 17 | * image.c (x_bitmap_pixmap): Cast to int to avoid compiler warnings. | ||
| 18 | |||
| 19 | * xdisp.c (produce_stretch_glyph): No longer static, compiled also | ||
| 20 | when HAVE_WINDOW_SYSTEM is not defined. Support both GUI and TTY | ||
| 21 | frames. Call tty_append_glyph in the TTY case. (Bug#9402) | ||
| 22 | |||
| 23 | * term.c (tty_append_glyph): New function. | ||
| 24 | (produce_stretch_glyph): Static function and its prototype deleted. | ||
| 25 | |||
| 26 | * dispextern.h (produce_stretch_glyph, tty_append_glyph): Add | ||
| 27 | prototypes. | ||
| 28 | |||
| 29 | 2011-08-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 30 | |||
| 31 | * image.c (parse_image_spec): Check for nonnegative, not for positive, | ||
| 32 | when checking :margin (Bug#9390). | ||
| 33 | (IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR): | ||
| 34 | Renamed from IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, | ||
| 35 | so that the name doesn't mislead. All uses changed. | ||
| 36 | |||
| 37 | 2011-08-28 Johan Bockgård <bojohan@gnu.org> | ||
| 38 | |||
| 39 | * term.c (init_tty) [HAVE_GPM]: Move mouse settings after | ||
| 40 | set_tty_hooks. | ||
| 41 | |||
| 42 | 2011-08-27 Eli Zaretskii <eliz@gnu.org> | ||
| 43 | |||
| 44 | * xdisp.c (move_it_to): Don't bail out early when reaching | ||
| 45 | position beyond to_charpos, if we are scanning backwards. | ||
| 46 | (move_it_vertically_backward): When DY == 0, make sure we get to | ||
| 47 | the first character in the line after the newline. | ||
| 48 | |||
| 49 | 2011-08-27 Paul Eggert <eggert@cs.ucla.edu> | ||
| 50 | |||
| 51 | * ccl.c: Improve and simplify overflow checking (Bug#9196). | ||
| 52 | (ccl_driver): Do not generate an out-of-range pointer. | ||
| 53 | (Fccl_execute_on_string): Remove unnecessary check for | ||
| 54 | integer overflow, noted by Stefan Monnier in | ||
| 55 | <http://lists.gnu.org/archive/html/emacs-devel/2011-08/msg00979.html>. | ||
| 56 | Remove a FIXME that didn't need fixing. | ||
| 57 | Simplify the newly-introduced buffer reallocation code. | ||
| 58 | |||
| 59 | 2011-08-27 Juanma Barranquero <lekktu@gmail.com> | ||
| 60 | |||
| 61 | * makefile.w32-in ($(BLD)/alloc.$(O)): Depend on lib/verify.h. | ||
| 62 | |||
| 63 | 2011-08-26 Paul Eggert <eggert@cs.ucla.edu> | ||
| 64 | |||
| 65 | Integer and memory overflow issues (Bug#9196). | ||
| 66 | |||
| 67 | * doc.c (get_doc_string): Rework so that | ||
| 68 | get_doc_string_buffer_size is the actual buffer size, rather than | ||
| 69 | being 1 less than the actual buffer size; this makes xpalloc more | ||
| 70 | convenient. | ||
| 71 | |||
| 72 | * image.c (x_allocate_bitmap_record, cache_image): | ||
| 73 | * xselect.c (Fx_register_dnd_atom): | ||
| 74 | Simplify previous changes by using xpalloc. | ||
| 75 | |||
| 76 | * buffer.c (overlay_str_len): Now ptrdiff_t, not EMACS_INT, | ||
| 77 | since either will do and ptrdiff_t is convenient with xpalloc. | ||
| 78 | |||
| 79 | * charset.c (charset_table_size) | ||
| 80 | (struct charset_sort_data.priority): Now ptrdiff_t. | ||
| 81 | (charset_compare): Don't overflow if priorities differ greatly. | ||
| 82 | (Fsort_charsets): Don't assume list length fits in int. | ||
| 83 | Check for size-calculation overflow when allocating sort data. | ||
| 84 | (syms_of_charset): Allocate an initial charset table that is | ||
| 85 | just under 64 KiB, to avoid problems with glibc malloc and mmap. | ||
| 86 | |||
| 87 | * cmds.c (internal_self_insert): Check for size-calculation overflow. | ||
| 88 | |||
| 89 | * composite.h (struct composition.glyph_len): Now int, not unsigned. | ||
| 90 | The actual value is always <= INT_MAX, and leaving it unsigned made | ||
| 91 | overflow checking harder. | ||
| 92 | |||
| 93 | * dispextern.h (struct glyph_matrix.rows_allocated) | ||
| 94 | (struct face_cache.size): Now ptrdiff_t, for convenience in use | ||
| 95 | with xpalloc. The values are still always <= INT_MAX. | ||
| 96 | |||
| 97 | * indent.c (compute_motion): Adjust to region_cache_forward sig change. | ||
| 98 | |||
| 99 | * lisp.h (xnmalloc, xnrealloc, xpalloc): New decls. | ||
| 100 | (SAFE_NALLOCA): New macro. | ||
| 101 | |||
| 102 | * region-cache.c (struct boundary.pos, find_cache_boundary) | ||
| 103 | (move_cache_gap, insert_cache_boundary, delete_cache_boundaries) | ||
| 104 | (set_cache_region, invalidate_region_cache) | ||
| 105 | (revalidate_region_cache, know_region_cache, region_cache_forward) | ||
| 106 | (region_cache_backward, pp_cache): | ||
| 107 | Use ptrdiff_t, not EMACS_INT, since either will do. This is needed | ||
| 108 | so that ptrdiff_t * can be passed to xpalloc. | ||
| 109 | (struct region_cache): Similarly, for gap_start, gap_len, cache_len, | ||
| 110 | beg_unchanged, end_unchanged, buffer_beg, buffer_end members. | ||
| 111 | (pp_cache): Don't assume cache_len fits in int. | ||
| 112 | * region-cache.h: Adjust extern decls to match. | ||
| 113 | |||
| 114 | * search.c (scan_buffer, Freplace_match): Use ptrdiff_t, not | ||
| 115 | EMACS_INT, since either will do, for xpalloc. | ||
| 116 | |||
| 117 | * alloc.c: Include verify.h, and check that int fits in ptrdiff_t. | ||
| 118 | (xnmalloc, xnrealloc, xpalloc): New functions. | ||
| 119 | |||
| 120 | * bidi.c (bidi_shelve_header_size): New constant. | ||
| 121 | (bidi_cache_ensure_space, bidi_shelve_cache): Use it. | ||
| 122 | (bidi_cache_ensure_space): Avoid integer overflow when allocating. | ||
| 123 | |||
| 124 | * bidi.c (bidi_cache_shrink): | ||
| 125 | * buffer.c (overlays_at, overlays_in, record_overlay_string) | ||
| 126 | (overlay_strings): | ||
| 127 | Don't update size of array until after memory allocation succeeds, | ||
| 128 | because xmalloc/xrealloc may not return. | ||
| 129 | (struct sortstrlist.bytes): Now ptrdiff_t, as EMACS_INT doesn't help | ||
| 130 | now that we have proper integer overflow checking. | ||
| 131 | (record_overlay_string, overlay_strings): Catch overflows when | ||
| 132 | calculating size of overlay_str_buf. | ||
| 133 | |||
| 134 | * callproc.c (Fcall_process): Check for size overflow when | ||
| 135 | calculating size of args2. | ||
| 136 | (child_setup): Avoid overflow by using size_t rather than ptrdiff_t. | ||
| 137 | Normally we prefer signed values, but sticking with ptrdiff_t would | ||
| 138 | require adding more-complicated checks. | ||
| 139 | |||
| 140 | * ccl.c (Fccl_execute_on_string): Check for memory overflow. | ||
| 141 | Use ptrdiff_t rather than EMACS_INT where ptrdiff_t will do. | ||
| 142 | Redo buffer-overflow calculations to avoid integer overflow. | ||
| 143 | Add a FIXME comment where memory seems to be over-allocated. | ||
| 144 | |||
| 145 | * character.c (Fstring): Check for size-calculation overflow. | ||
| 146 | |||
| 147 | * coding.c (produce_chars): Redo buffer-overflow calculations to avoid | ||
| 148 | unnecessary integer overflow. Check for size overflow. | ||
| 149 | (encode_coding_object): Don't update size until xmalloc succeeds. | ||
| 150 | |||
| 151 | * composite.c (get_composition_id): Check for overflow in glyph | ||
| 152 | length calculations. | ||
| 153 | |||
| 154 | Integer and memory overflow fixes for display code. | ||
| 155 | * dispextern.h (struct glyph_pool.nglyphs): Now ptrdiff_t, not int. | ||
| 156 | * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool) | ||
| 157 | (scrolling_window): Check for overflow in size calculations. | ||
| 158 | (line_draw_cost, realloc_glyph_pool, add_row_entry): | ||
| 159 | Don't assume glyph table len fits in int. | ||
| 160 | (struct row_entry.bucket, row_entry_pool_size, row_entry_idx) | ||
| 161 | (row_table_size): Now ptrdiff_t, not int. | ||
| 162 | (scrolling_window): Avoid overflow in size calculations. | ||
| 163 | Don't update size until allocation succeeds. | ||
| 164 | * fns.c (concat): Check for overflow in size calculations. | ||
| 165 | (next_almost_prime): Verify NEXT_ALMOST_PRIME_LIMIT. | ||
| 166 | * lisp.h (RANGED_INTEGERP, TYPE_RANGED_INTEGERP): New macros. | ||
| 167 | (NEXT_ALMOST_PRIME_LIMIT): New constant. | ||
| 168 | |||
| 169 | * doc.c (get_doc_string_buffer_size): Now ptrdiff_t, not int. | ||
| 170 | (get_doc_string): Check for size calculation overflow. | ||
| 171 | Don't update size until allocation succeeds. | ||
| 172 | (get_doc_string, Fsubstitute_command_keys): Use ptrdiff_t, not | ||
| 173 | EMACS_INT, where ptrdiff_t will do. | ||
| 174 | (Fsubstitute_command_keys): Check for string overflow. | ||
| 175 | |||
| 176 | * editfns.c (set_time_zone_rule): Don't assume environment length | ||
| 177 | fits in int. | ||
| 178 | (message_length): Now ptrdiff_t, not int. | ||
| 179 | (Fmessage_box): Don't update size until allocation succeeds. | ||
| 180 | Don't assume message length fits in int. | ||
| 181 | (Fformat): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t will do. | ||
| 182 | |||
| 183 | * emacs.c (main): Do not reallocate argv, since there is a null at | ||
| 184 | the end that can be overwritten, and this way there's no need to | ||
| 185 | worry about size-calculation overflow. | ||
| 186 | (sort_args): Check for size-calculation overflow. | ||
| 187 | |||
| 188 | * eval.c (init_eval_once, grow_specpdl): Don't update size until | ||
| 189 | alloc succeeds. | ||
| 190 | (call_debugger, grow_specpdl): Redo calculations to avoid overflow. | ||
| 191 | |||
| 192 | * frame.c (set_menu_bar_lines, x_set_frame_parameters) | ||
| 193 | (x_set_scroll_bar_width, x_figure_window_size): | ||
| 194 | Check for integer overflow. | ||
| 195 | (x_set_alpha): Do not assume XINT fits in int. | ||
| 196 | |||
| 197 | * frame.h (struct frame): Use int, not EMACS_INT, where int works. | ||
| 198 | This is for the members text_lines, text_cols, total_lines, total_cols, | ||
| 199 | where the system imposes an 'int' limit. | ||
| 200 | |||
| 201 | * fringe.c (Fdefine_fringe_bitmap): | ||
| 202 | Don't update size until alloc works. | ||
| 203 | |||
| 204 | * ftfont.c (ftfont_get_open_type_spec, setup_otf_gstring) | ||
| 205 | (ftfont_shape_by_flt): Check for integer overflow in size calculations. | ||
| 206 | |||
| 207 | * gtkutil.c (get_utf8_string, xg_store_widget_in_map): | ||
| 208 | Check for size-calculation overflow. | ||
| 209 | (get_utf8_string): Use ptrdiff_t, not size_t, where either will | ||
| 210 | do, as we prefer signed integers. | ||
| 211 | (id_to_widget.max_size, id_to_widget.used) | ||
| 212 | (xg_store_widget_in_map, xg_remove_widget_from_map) | ||
| 213 | (xg_get_widget_from_map, xg_get_scroll_id_for_window) | ||
| 214 | (xg_remove_scroll_bar, xg_update_scrollbar_pos): | ||
| 215 | Use and return ptrdiff_t, not int. | ||
| 216 | (xg_gtk_scroll_destroy): Don't assume ptrdiff_t fits in int. | ||
| 217 | * gtkutil.h: Change prototypes to match the above. | ||
| 218 | |||
| 219 | * image.c (RANGED_INTEGERP, TYPE_RANGED_INTEGERP): Remove; these | ||
| 220 | are duplicate now that they've been promoted to lisp.h. | ||
| 221 | (x_allocate_bitmap_record, x_alloc_image_color) | ||
| 222 | (make_image_cache, cache_image, xpm_load): | ||
| 223 | Don't update size until alloc is done. | ||
| 224 | (xpm_load, lookup_rgb_color, lookup_pixel_color, x_to_xcolors) | ||
| 225 | (x_detect_edges): | ||
| 226 | Check for size calculation overflow. | ||
| 227 | (ct_colors_allocated_max): New constant. | ||
| 228 | (x_to_xcolors, x_detect_edges): Reorder multiplicands to avoid | ||
| 229 | overflow. | ||
| 230 | |||
| 231 | * keyboard.c (read_char, menu_bar_items, tool_bar_items) | ||
| 232 | (read_char_x_menu_prompt, read_char_minibuf_menu_width) | ||
| 233 | (read_char_minibuf_menu_prompt, follow_key, read_key_sequence): | ||
| 234 | Use ptrdiff_t, not int, to count maps. | ||
| 235 | (read_char_minibuf_menu_prompt): Check for overflow in size | ||
| 236 | calculations. Don't update size until allocation succeeds. Redo | ||
| 237 | calculations to avoid overflow. | ||
| 238 | * keyboard.h: Change prototypes to match the above. | ||
| 239 | |||
| 240 | * keymap.c (cmm_size, current_minor_maps): Use ptrdiff_t, not int, | ||
| 241 | to count maps. | ||
| 242 | (current_minor_maps): Check for size calculation overflow. | ||
| 243 | * keymap.h: Change prototypes to match the above. | ||
| 244 | |||
| 245 | * lread.c (read1, init_obarray): Don't update size until alloc done. | ||
| 246 | |||
| 247 | * macros.c (Fstart_kbd_macro): Don't update size until alloc done. | ||
| 248 | (store_kbd_macro_char): Reorder multiplicands to avoid overflow. | ||
| 249 | |||
| 250 | * nsterm.h (struct ns_color_table.size, struct ns_color_table.avail): | ||
| 251 | Now ptrdiff_t, not int. | ||
| 252 | * nsterm.m (ns_index_color): Use ptrdiff_t, not int, for table indexes. | ||
| 253 | (ns_draw_fringe_bitmap): Rewrite to avoid overflow. | ||
| 254 | |||
| 255 | * process.c (Fnetwork_interface_list): Check for overflow | ||
| 256 | in size calculation. | ||
| 257 | |||
| 258 | * region-cache.c (move_cache_gap): Check for size calculation overflow. | ||
| 259 | |||
| 260 | * scroll.c (do_line_insertion_deletion_costs): Check for size calc | ||
| 261 | overflow. Don't bother calling xmalloc when xrealloc will do. | ||
| 262 | |||
| 263 | * search.c (Freplace_match): Check for size calculation overflow. | ||
| 264 | (Fset_match_data): Don't assume list lengths fit in 'int'. | ||
| 265 | |||
| 266 | * sysdep.c (system_process_attributes): Use ptrdiff_t, not int, | ||
| 267 | for command line length. Do not attempt to address one before the | ||
| 268 | beginning of an array, as that's not portable. | ||
| 269 | |||
| 270 | * term.c (max_frame_lines): Remove; unused. | ||
| 271 | (encode_terminal_src_size, encode_terminal_dst_size): Now ptrdiff_t, | ||
| 272 | not int. | ||
| 273 | (encode_terminal_code, calculate_costs): Check for size | ||
| 274 | calculation overflow. | ||
| 275 | (encode_terminal_code): Use ptrdiff_t, not int, to record glyph | ||
| 276 | table lengths and related sizes. Don't update size until alloc | ||
| 277 | done. Redo calculations to avoid overflow. | ||
| 278 | (calculate_costs): Don't bother calling xmalloc when xrealloc will do. | ||
| 279 | |||
| 280 | * termcap.c (tgetent): Use ptrdiff_t, not int, to record results of | ||
| 281 | subtracting pointers. | ||
| 282 | (gobble_line): Check for overflow more carefully. Don't update size | ||
| 283 | until alloc done. | ||
| 284 | |||
| 285 | * tparam.c (tparam1): Use ptrdiff_t, not int, for sizes. | ||
| 286 | Don't update size until alloc done. | ||
| 287 | Redo size calculations to avoid overflow. | ||
| 288 | Check for size calculation overflow. | ||
| 289 | (main) [DEBUG]: Fix typo in invoking tparam1. | ||
| 290 | |||
| 291 | * xdisp.c (store_mode_line_noprop_char, x_consider_frame_title): | ||
| 292 | Use ptrdiff_t, not int, for sizes. | ||
| 293 | (store_mode_line_noprop_char): Don't update size until alloc done. | ||
| 294 | |||
| 295 | * xfaces.c (lface_id_to_name_size, Finternal_make_lisp_face): | ||
| 296 | Use ptrdiff_t, not int, for sizes. | ||
| 297 | (Finternal_make_lisp_face, cache_face): | ||
| 298 | Check for size calculation overflow. | ||
| 299 | (cache_face): Treat size calculation overflows as if they were | ||
| 300 | memory exhaustion (the usual treatment), rather than aborting. | ||
| 301 | |||
| 302 | * xfns.c (x_encode_text, x_set_name_internal) | ||
| 303 | (Fx_change_window_property): Use ptrdiff_t, not int, to count | ||
| 304 | sizes, since they can exceed INT_MAX in size. Check for size | ||
| 305 | calculation overflow. | ||
| 306 | |||
| 307 | * xgselect.c (gfds_size): Now ptrdiff_t, for convenience with xpalloc. | ||
| 308 | (xg_select): Check for size calculation overflow. | ||
| 309 | Don't update size until alloc done. | ||
| 310 | |||
| 311 | * xrdb.c (get_environ_db): Don't assume path length fits in int, | ||
| 312 | as sprintf is limited to int lengths. | ||
| 313 | |||
| 314 | * xselect.c (X_LONG_SIZE, X_SHRT_MAX, X_SHRT_MIN, X_LONG_MAX) | ||
| 315 | (X_LONG_MIN): New macros. | ||
| 316 | Use them to make the following changes clearer. | ||
| 317 | (MAX_SELECTION_QUANTUM): Make the other bounds on this value clearer. | ||
| 318 | This change doesn't affect the value now, but it may help remind | ||
| 319 | future maintainers not to raise the value too much later. | ||
| 320 | (SELECTION_QUANTUM): Remove, replacing with ... | ||
| 321 | (selection_quantum): ... new function, which avoids overflow. | ||
| 322 | All uses changed. | ||
| 323 | (struct selection_data.size): Now ptrdiff_t, not int, to avoid | ||
| 324 | assumption that selection length fits in 'int'. | ||
| 325 | (x_reply_selection_request, x_handle_selection_request) | ||
| 326 | (x_get_window_property, receive_incremental_selection) | ||
| 327 | (x_get_window_property_as_lisp_data, selection_data_to_lisp_data) | ||
| 328 | (lisp_data_to_selection_data, clean_local_selection_data): | ||
| 329 | Use ptrdiff_t, not int, to record length of selection. | ||
| 330 | (x_reply_selection_request, x_get_window_property) | ||
| 331 | (receive_incremental_selection, x_property_data_to_lisp): | ||
| 332 | Redo calculations to avoid overflow. | ||
| 333 | (x_reply_selection_request): When sending hint, ceiling it at | ||
| 334 | X_LONG_MAX rather than relying on wraparound overflow to send | ||
| 335 | something. | ||
| 336 | (x_get_window_property, receive_incremental_selection) | ||
| 337 | (lisp_data_to_selection_data, x_property_data_to_lisp): | ||
| 338 | Check for size-calculation overflow. | ||
| 339 | (x_get_window_property, receive_incremental_selection) | ||
| 340 | (lisp_data_to_selection_data, Fx_register_dnd_atom): | ||
| 341 | Don't store size until memory allocation succeeds. | ||
| 342 | (x_get_window_property): Plug memory leak on memory exhaustion. | ||
| 343 | Don't double-block input; malloc is safe here. Don't assume 2**34 | ||
| 344 | - 4 fits in unsigned long. Add an xassert to check | ||
| 345 | XGetWindowProperty overflow. Be more careful about overflow | ||
| 346 | calculations, and distinguish size from memory overflow better. | ||
| 347 | (receive_incremental_selection): When tracing, don't assume | ||
| 348 | unsigned int is less than INT_MAX. | ||
| 349 | (x_selection_data_to_lisp_data): Remove unnecessary (and in theory | ||
| 350 | harmful) conversions of unsigned short to int. | ||
| 351 | (lisp_data_to_selection_data): Don't assume that integers | ||
| 352 | in the range -65535 through -1 fit in an X unsigned short. | ||
| 353 | Don't assume that ULONG_MAX == X_ULONG_MAX. Don't store into | ||
| 354 | result parameters unless successful. Rely on cons_to_unsigned | ||
| 355 | to report problems with elements; the old code wasn't right anyway. | ||
| 356 | (x_check_property_data): Check for int overflow; we cannot use | ||
| 357 | a wider type due to X limits. | ||
| 358 | (x_handle_dnd_message): Use unsigned int, to avoid int overflow. | ||
| 359 | |||
| 360 | * xsmfns.c (smc_save_yourself_CB): Check for size calc overflow. | ||
| 361 | |||
| 362 | * xterm.c (x_color_cells, x_send_scrollbar_event, handle_one_xevent) | ||
| 363 | (x_term_init): Check for size calculation overflow. | ||
| 364 | (x_color_cells): Don't store size until memory allocation succeeds. | ||
| 365 | (handle_one_xevent): Use ptrdiff_t, not int, for byte counts. | ||
| 366 | Don't assume alloca size is less than MAX_ALLOCA. | ||
| 367 | (x_term_init): Don't assume length fits in int (sprintf is limited | ||
| 368 | to int size). | ||
| 369 | |||
| 370 | Use ptrdiff_t for composition IDs. | ||
| 371 | * character.c (lisp_string_width): | ||
| 372 | * composite.c (composition_table_size, n_compositions) | ||
| 373 | (get_composition_id, composition_gstring_from_id): | ||
| 374 | * dispextern.h (struct glyph_string.cmp_id, struct composition_it.id): | ||
| 375 | * xdisp.c (BUILD_COMPOSITE_GLYPH_STRING): | ||
| 376 | * window.c (Frecenter): | ||
| 377 | Use ptrdiff_t, not int, for composition IDs. | ||
| 378 | * composite.c (get_composition_id): Check for integer overflow. | ||
| 379 | * composite.h: Adjust prototypes to match the above changes. | ||
| 380 | |||
| 381 | Use ptrdiff_t for hash table indexes. | ||
| 382 | * category.c (hash_get_category_set): | ||
| 383 | * ccl.c (ccl_driver): | ||
| 384 | * charset.h (struct charset.hash_index, CHECK_CHARSET_GET_ID): | ||
| 385 | * coding.c (coding_system_charset_list, detect_coding_system): | ||
| 386 | * coding.h (struct coding_system.id): | ||
| 387 | * composite.c (get_composition_id, gstring_lookup_cache): | ||
| 388 | * fns.c (hash_lookup, hash_put, Fgethash, Fputhash): | ||
| 389 | * image.c (xpm_get_color_table_h): | ||
| 390 | * lisp.h (hash_lookup, hash_put): | ||
| 391 | * minibuf.c (Ftest_completion): | ||
| 392 | Use ptrdiff_t for hash table indexes, not int (which is too | ||
| 393 | narrow, on 64-bit hosts) or EMACS_INT (which is too wide, on | ||
| 394 | 32-bit --with-wide-int hosts). | ||
| 395 | |||
| 396 | * charset.c (Fdefine_charset_internal): Check for integer overflow. | ||
| 397 | Add a FIXME comment about memory leaks. | ||
| 398 | (syms_of_charset): Don't assume xmalloc returns. | ||
| 399 | |||
| 400 | Don't assume that stated character widths fit in int. | ||
| 401 | * character.c (Fchar_width, c_string_width, lisp_string_width): | ||
| 402 | * character.h (CHAR_WIDTH): | ||
| 403 | * indent.c (MULTIBYTE_BYTES_WIDTH): | ||
| 404 | Use sanitize_char_width to avoid undefined and/or bad behavior | ||
| 405 | with outlandish widths. | ||
| 406 | * character.h (sanitize_tab_width): Renamed from sanitize_width, | ||
| 407 | now that we have two such functions. All uses changed. | ||
| 408 | (sanitize_char_width): New inline function. | ||
| 409 | |||
| 410 | Don't assume that tab-width fits in int. | ||
| 411 | * character.h (sanitize_width): New inline function. | ||
| 412 | (SANE_TAB_WIDTH): New macro. | ||
| 413 | (ASCII_CHAR_WIDTH): Use it. | ||
| 414 | * indent.c (sane_tab_width): Remove. All uses replaced by | ||
| 415 | SANE_TAB_WIDTH (current_buffer). | ||
| 416 | * xdisp.c (init_iterator): Use SANE_TAB_WIDTH. | ||
| 417 | |||
| 418 | * fileio.c: Integer overflow issues with file modes. | ||
| 419 | (Fset_file_modes, auto_save_1): Don't assume EMACS_INT fits in int. | ||
| 420 | |||
| 421 | * charset.c (read_hex): New arg OVERFLOW. All uses changed. | ||
| 422 | Remove unreachable code. | ||
| 423 | (read_hex, load_charset_map_from_file): Check for integer overflow. | ||
| 424 | |||
| 425 | * xterm.c: don't go over XClientMessageEvent limit | ||
| 426 | (scroll_bar_windows_size): Now ptrdiff_t, as we prefer signed. | ||
| 427 | (x_send_scroll_bar_event): Likewise. Check that the size does not | ||
| 428 | exceed limits imposed by XClientMessageEvent, as well as the usual | ||
| 429 | ptrdiff_t and size_t limits. | ||
| 430 | |||
| 431 | * keyboard.c: Overflow, signedness and related fixes. | ||
| 432 | (make_lispy_movement): Use same integer type in forward decl | ||
| 433 | that is used in the definition. | ||
| 434 | (read_key_sequence, keyremap_step): | ||
| 435 | Change bufsize argument back to int, undoing my 2011-03-30 change. | ||
| 436 | We prefer signed types, and int is wide enough here. | ||
| 437 | (parse_tool_bar_item): Don't assume tool_bar_max_label_size is less | ||
| 438 | than TYPE_MAXIMUM (EMACS_INT) / 2. Don't let the label size grow | ||
| 439 | larger than STRING_BYTES_BOUND. Use ptrdiff_t for Emacs string | ||
| 440 | length, not size_t. Use ptrdiff_t for index, not int. | ||
| 441 | (keyremap_step, read_key_sequence): Redo bufsize check to avoid | ||
| 442 | possibility of integer overflow. | ||
| 443 | |||
| 444 | Overflow, signedness and related fixes for images. | ||
| 445 | |||
| 446 | * dispextern.h (struct it.stack[0].u.image.image_id) | ||
| 447 | (struct_it.image_id, struct image.id, struct image_cache.size) | ||
| 448 | (struct image_cache.used, struct image_cache.ref_count): | ||
| 449 | * gtkutil.c (update_frame_tool_bar): | ||
| 450 | * image.c (x_reference_bitmap, Fimage_size, Fimage_mask_p) | ||
| 451 | (Fimage_metadata, free_image_cache, clear_image_cache, lookup_image) | ||
| 452 | (cache_image, mark_image_cache, x_kill_gs_process, Flookup_image): | ||
| 453 | * nsmenu.m (update_frame_tool_bar): | ||
| 454 | * xdisp.c (calc_pixel_width_or_height): | ||
| 455 | * xfns.c (image_cache_refcount): | ||
| 456 | Image IDs are now ptrdiff_t, not int, to avoid arbitrary limits | ||
| 457 | on typical 64-bit hosts. | ||
| 458 | |||
| 459 | * image.c (RANGED_INTEGERP, TYPE_RANGED_INTEGERP): New macros. | ||
| 460 | (x_bitmap_pixmap, x_create_x_image_and_pixmap): | ||
| 461 | Omit unnecessary casts to int. | ||
| 462 | (parse_image_spec): Check that integers fall into 'int' range | ||
| 463 | when the callers expect that. | ||
| 464 | (image_ascent): Redo ascent calculation to avoid int overflow. | ||
| 465 | (clear_image_cache): Avoid overflow when sqrt (INT_MAX) < nimages. | ||
| 466 | (lookup_image): Remove unnecessary tests. | ||
| 467 | (xbm_image_p): Locals are now of int, not EMACS_INT, | ||
| 468 | since parse_image_check makes sure they fit into int. | ||
| 469 | (png_load, gif_load, svg_load_image): | ||
| 470 | Prefer int to unsigned where either will do. | ||
| 471 | (tiff_handler): New function, combining the cores of the | ||
| 472 | old tiff_error_handler and tiff_warning_handler. This | ||
| 473 | function is rewritten to use vsnprintf and thereby avoid | ||
| 474 | stack buffer overflows. It uses only the features of vsnprintf | ||
| 475 | that are common to both POSIX and native Microsoft. | ||
| 476 | (tiff_error_handler, tiff_warning_handler): Use it. | ||
| 477 | (tiff_load, gif_load, imagemagick_load_image): | ||
| 478 | Don't assume :index value fits in 'int'. | ||
| 479 | (gif_load): Omit unnecessary cast to double, and avoid double-rounding. | ||
| 480 | (imagemagick_load_image): Check that crop parameters fit into | ||
| 481 | the integer types that MagickCropImage accepts. Don't assume | ||
| 482 | Vimagemagick_render_type has a nonnegative value. Don't assume | ||
| 483 | size_t fits in 'long'. | ||
| 484 | (gs_load): Use printmax_t to print the widest integers possible. | ||
| 485 | Check for integer overflow when computing image height and width. | ||
| 486 | |||
| 487 | 2011-08-26 Eli Zaretskii <eliz@gnu.org> | ||
| 488 | |||
| 489 | * xdisp.c (redisplay_window): Don't force window start if point | ||
| 490 | will be invisible in the resulting window. (Bug#9324) | ||
| 491 | |||
| 492 | 2011-08-25 Eli Zaretskii <eliz@gnu.org> | ||
| 493 | |||
| 494 | * xdisp.c (compute_display_string_pos): Return 2 in DISP_PROP when | ||
| 495 | the display spec is of the form `(space ...)'. | ||
| 496 | (handle_display_spec): Return the value returned by | ||
| 497 | handle_single_display_spec, not just 1 or zero. | ||
| 498 | (handle_single_display_spec): If the display spec is of the form | ||
| 499 | `(space ...)', and specifies display in the text area, return 2 | ||
| 500 | rather than 1. | ||
| 501 | (try_cursor_movement): Check for the need to scroll more | ||
| 502 | accurately, and prefer exact match for point under bidi. Don't | ||
| 503 | advance `row' beyond the last row of the window. | ||
| 504 | |||
| 505 | * dispextern.h (struct bidi_it): Rename the disp_prop_p member | ||
| 506 | into disp_prop; all users changed. | ||
| 507 | |||
| 508 | * bidi.c (bidi_fetch_char): If compute_display_string_pos returns | ||
| 509 | DISP_PROP = 2, substitute the u+2029 PARAGRAPH SEPARATOR character | ||
| 510 | for the text covered by the display property. | ||
| 511 | |||
| 512 | 2011-08-25 Chong Yidong <cyd@stupidchicken.com> | ||
| 513 | |||
| 514 | * buffer.c (Fbury_buffer_internal): Rename from Funrecord_buffer. | ||
| 515 | Change return value to nil. | ||
| 516 | (Frecord_buffer): Delete unused function. | ||
| 517 | |||
| 518 | 2011-08-24 Eli Zaretskii <eliz@gnu.org> | ||
| 519 | |||
| 520 | * xdisp.c (Fcurrent_bidi_paragraph_direction): For unibyte | ||
| 521 | buffers, return left-to-right. | ||
| 522 | (set_cursor_from_row): Consider candidate row a win if its glyph | ||
| 523 | represents a newline and point is on that newline. Fixes cursor | ||
| 524 | positioning on the newline at EOL of R2L text within L2R | ||
| 525 | paragraph, and vice versa. | ||
| 526 | (try_cursor_movement): Check continued rows, in addition to | ||
| 527 | continuation rows. Fixes unwarranted scroll when point enters a | ||
| 528 | continued line of R2L text within an L2R paragraph, or vice versa. | ||
| 529 | (cursor_row_p): Consider the case of point being equal to | ||
| 530 | MATRIX_ROW_END_CHARPOS. Prevents cursor being stuck when moving | ||
| 531 | from the end of a short line to the beginning of a continued line | ||
| 532 | of R2L text within L2R paragraph. | ||
| 533 | (RECORD_MAX_MIN_POS): For max_pos, use IT_CHARPOS even for | ||
| 534 | composed characters. | ||
| 535 | |||
| 536 | * bidi.c (bidi_check_type): Use xassert. | ||
| 537 | (bidi_cache_iterator_state): Update the disp_pos and disp_prop_p | ||
| 538 | members. | ||
| 539 | |||
| 540 | 2011-08-23 Eli Zaretskii <eliz@gnu.org> | ||
| 541 | |||
| 542 | * bidi.c (bidi_get_type): Abort if we get zero as the bidi type of | ||
| 543 | a character. | ||
| 544 | |||
| 545 | 2011-08-23 Chong Yidong <cyd@stupidchicken.com> | ||
| 546 | |||
| 547 | * nsfont.m (ns_otf_to_script): Fix typo. | ||
| 548 | |||
| 549 | 2011-08-22 Kenichi Handa <handa@m17n.org> | ||
| 550 | |||
| 551 | * chartab.c (Fset_char_table_extra_slot): Do not inhibit setting a | ||
| 552 | extra slot even if the purpose is char-code-property-table. | ||
| 553 | |||
| 554 | 2011-08-23 Eli Zaretskii <eliz@gnu.org> | ||
| 555 | |||
| 556 | * xdisp.c (redisplay_window): When computing centering_position, | ||
| 557 | account for the height of the header line. (Bug#8874) | ||
| 558 | |||
| 559 | * dispnew.c (buffer_posn_from_coords): Use buf_charpos_to_bytepos | ||
| 560 | instead of CHAR_TO_BYTE. Fixes a crash when a completion | ||
| 561 | candidate is selected by the mouse, and that candidate has a | ||
| 562 | composed character under the mouse. | ||
| 563 | |||
| 564 | * xdisp.c (x_produce_glyphs): Set it->nglyphs to 1. Fixes pixel | ||
| 565 | coordinates reported by pos-visible-in-window-p for a composed | ||
| 566 | character in column zero. | ||
| 567 | |||
| 568 | 2011-08-23 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 569 | |||
| 570 | * cmds.c (Fself_insert_command): Mention post-self-insert-hook. | ||
| 571 | |||
| 572 | 2011-08-22 Eli Zaretskii <eliz@gnu.org> | ||
| 573 | |||
| 574 | * xdisp.c (BUFFER_POS_REACHED_P): If this is a composition, | ||
| 575 | consider it a hit if to_charpos is anywhere in the range of the | ||
| 576 | composed buffer positions. | ||
| 577 | |||
| 578 | 2011-08-22 Chong Yidong <cyd@stupidchicken.com> | ||
| 579 | |||
| 580 | * image.c (gif_load): Don't assume that each subimage has the same | ||
| 581 | dimensions as the base image. Handle disposal method that is | ||
| 582 | "undefined" by the gif spec (Bug#9335). | ||
| 583 | |||
| 584 | 2011-08-20 Chong Yidong <cyd@stupidchicken.com> | ||
| 585 | |||
| 586 | * eval.c (Fsignal): Handle `debug' symbol in error handler (Bug#9329). | ||
| 587 | (Fcondition_case): Document `debug' symbol in error handler. | ||
| 588 | |||
| 589 | 2011-08-19 Eli Zaretskii <eliz@gnu.org> | ||
| 590 | |||
| 591 | * xfaces.c (face_at_buffer_position): Avoid repeated evaluation of | ||
| 592 | face ID by FACE_FROM_ID, and avoid a crash when mouse is moved | ||
| 593 | from an Org mode buffer to a Speedbar frame. | ||
| 594 | |||
| 595 | * xdisp.c (RECORD_MAX_MIN_POS): If the display element comes from | ||
| 596 | a composition, take its buffer position from IT->cmp_it.charpos. | ||
| 597 | Fixes cursor positioning at the beginning of a line that begins | ||
| 598 | with a composed character. | ||
| 599 | |||
| 600 | 2011-08-18 Eli Zaretskii <eliz@gnu.org> | ||
| 601 | |||
| 602 | * bidi.c (bidi_get_type): If bidi_type_table reports zero as the | ||
| 603 | character bidirectional type, use STRONG_L instead. Fixes crashes | ||
| 604 | in a buffer produced by `describe-categories'. | ||
| 605 | |||
| 606 | * dispextern.h (struct bidi_it): Move disp_pos and disp_prop_p | ||
| 607 | members before the level stack, so they would be saved and | ||
| 608 | restored when copying iterator state. Fixes incorrect reordering | ||
| 609 | around TABs covered by display properties. | ||
| 610 | |||
| 611 | 2011-08-18 Andreas Schwab <schwab@linux-m68k.org> | ||
| 612 | |||
| 613 | * process.c (Fnetwork_interface_list): Correctly determine buffer | ||
| 614 | size. | ||
| 615 | |||
| 616 | 2011-08-17 Chong Yidong <cyd@stupidchicken.com> | ||
| 617 | |||
| 618 | * eval.c (internal_condition_case, internal_condition_case_1) | ||
| 619 | (internal_condition_case_2, internal_condition_case_n): | ||
| 620 | Remove unnecessary aborts (Bug#9081). | ||
| 621 | |||
| 622 | 2011-08-17 Eli Zaretskii <eliz@gnu.org> | ||
| 623 | |||
| 624 | * lread.c (Fload) [DOS_NT]: If `openp' returns -2, but the file | ||
| 625 | has no `load' handler, try opening the file locally. (Bug#9311) | ||
| 626 | |||
| 627 | 2011-08-16 Ken Brown <kbrown@cornell.edu> | ||
| 628 | |||
| 629 | * gmalloc.c: Expand comment. | ||
| 630 | |||
| 631 | 2011-08-16 Eli Zaretskii <eliz@gnu.org> | ||
| 632 | |||
| 633 | * xdisp.c (set_cursor_from_row): Don't accept a previous candidate | ||
| 634 | if it fails the cursor_row_p test. Fixes cursor positioning at ZV. | ||
| 635 | |||
| 636 | 2011-08-16 Ken Brown <kbrown@cornell.edu> | ||
| 637 | |||
| 638 | Fix memory allocation problems in Cygwin build (Bug#9273). | ||
| 639 | |||
| 640 | * unexcw.c ( __malloc_initialized): Declare external variable. | ||
| 641 | (fixup_executable): Force the dumped emacs to reinitialize malloc. | ||
| 642 | |||
| 643 | * gmalloc.c [CYGWIN] (bss_sbrk_heapbase, bss_sbrk_heapinfo): | ||
| 644 | New variables. | ||
| 645 | (malloc_initialize_1) [CYGWIN]: Prepare for reinitializing the | ||
| 646 | dumped emacs. | ||
| 647 | (_free_internal_nolock) [CYGWIN]: Ignore requests to free storage | ||
| 648 | in the static heap. | ||
| 649 | [CYGWIN] (special_realloc): New function. | ||
| 650 | (_realloc_internal_nolock) [CYGWIN]: Use the new function on | ||
| 651 | requests to realloc storage in the static heap. | ||
| 652 | |||
| 653 | 2011-08-15 Paul Eggert <eggert@cs.ucla.edu> | ||
| 654 | |||
| 655 | * bidi.c (bidi_initialize): Remove unused local. | ||
| 656 | |||
| 657 | 2011-08-15 Eli Zaretskii <eliz@gnu.org> | ||
| 658 | |||
| 659 | * biditype.h: File removed. | ||
| 660 | |||
| 661 | * bidimirror.h: File removed. | ||
| 662 | |||
| 663 | * deps.mk (bidi.o): Remove biditype.h and | ||
| 664 | bidimirror.h. | ||
| 665 | |||
| 666 | * makefile.w32-in ($(BLD)/bidi.$(O)): Remove biditype.h and | ||
| 667 | bidimirror.h. | ||
| 668 | |||
| 669 | * dispextern.h: Fix a typo in the comment to bidi_type_t. | ||
| 670 | |||
| 671 | * chartab.c: Improve commentary for the uniprop_table API. | ||
| 672 | |||
| 673 | * bidi.c (bidi_paragraph_init): Support zero value of | ||
| 674 | bidi_ignore_explicit_marks_for_paragraph_level. | ||
| 675 | (bidi_initialize): Use uniprop_table instead of including | ||
| 676 | biditype.h and bidimirror.h. | ||
| 677 | |||
| 678 | * xdisp.c (move_it_in_display_line_to): Don't reset pixel | ||
| 679 | coordinates of the iterator when restoring from ppos_it. | ||
| 680 | (Bug#9296) | ||
| 681 | |||
| 682 | 2011-08-14 Kenichi Handa <handa@m17n.org> | ||
| 683 | |||
| 684 | * process.c (create_process): Call setup_process_coding_systems | ||
| 685 | after the pid of the process is set to -1 (Bug#8162). | ||
| 686 | |||
| 687 | 2011-08-14 Eli Zaretskii <eliz@gnu.org> | ||
| 688 | |||
| 689 | * xdisp.c (move_it_in_display_line_to): Don't invoke | ||
| 690 | IT_RESET_X_ASCENT_DESCENT when iterator position was restored from | ||
| 691 | ppos_it. Fixes vertical cursor motion when line beginning is | ||
| 692 | covered by an image. (Bug#9296) | ||
| 693 | |||
| 694 | 2011-08-14 Jan Djärv <jan.h.d@swipnet.se> | ||
| 695 | |||
| 696 | * nsterm.h (ns_run_ascript): Declare. | ||
| 697 | (NSAPP_DATA2_RUNASSCRIPT): Define. | ||
| 698 | |||
| 699 | * nsfns.m (as_script, as_result, as_status): New static variables. | ||
| 700 | (ns_run_ascript): New function. | ||
| 701 | (Fns_do_applescript): Set variables as_*. Make an NSApplicationDefined | ||
| 702 | event with data2 set to NSAPP_DATA2_RUNASSCRIPT, post it and then start | ||
| 703 | the event loop. Get status from as_status (Bug#7276). | ||
| 704 | |||
| 705 | * nsterm.m (sendEvent): If event is NSApplicationDefined and | ||
| 706 | data2 is NSAPP_DATA2_RUNASSCRIPT, call ns_run_ascript and then exit | ||
| 707 | the event loop (Bug#7276). | ||
| 708 | |||
| 709 | 2011-08-14 Andreas Schwab <schwab@linux-m68k.org> | ||
| 710 | |||
| 711 | * gnutls.c (QCgnutls_bootprop_priority) | ||
| 712 | (QCgnutls_bootprop_trustfiles, QCgnutls_bootprop_keylist) | ||
| 713 | (QCgnutls_bootprop_crlfiles, QCgnutls_bootprop_callbacks) | ||
| 714 | (QCgnutls_bootprop_loglevel, QCgnutls_bootprop_hostname) | ||
| 715 | (QCgnutls_bootprop_min_prime_bits, QCgnutls_bootprop_verify_flags) | ||
| 716 | (QCgnutls_bootprop_verify_hostname_error) | ||
| 717 | (QCgnutls_bootprop_callbacks_verify): Rename from | ||
| 718 | Qgnutls_bootprop_..., all uses changed. | ||
| 719 | |||
| 720 | * xfaces.c (QCignore_defface): Rename from Qignore_defface, all | ||
| 721 | uses changed. | ||
| 722 | |||
| 723 | 2011-08-14 Paul Eggert <eggert@cs.ucla.edu> | ||
| 724 | |||
| 725 | * xfaces.c (Qframe_set_background_mode): Now static. | ||
| 726 | * dispextern.h (Qframe_set_background_mode): Remove decl. | ||
| 727 | |||
| 728 | * process.c (Fnetwork_interface_info): Declare local only if needed. | ||
| 729 | |||
| 730 | 2011-08-13 Jan Djärv <jan.h.d@swipnet.se> | ||
| 731 | |||
| 732 | * process.c: Include ifaddrs.h and net/if_dl.h if available (Bug#8477). | ||
| 733 | (Fnetwork_interface_list): Allocate in increments of bytes instead | ||
| 734 | of sizeof (struct ifreq). Iterate over ifconf.ifc_req by counting | ||
| 735 | bytes (Bug#8477). Count bytes correctly when ifr_addr is a struct | ||
| 736 | sockaddr. | ||
| 737 | (struct ifflag_def): notrailers is smart on OSX. | ||
| 738 | (Fnetwork_interface_info): Handle case when ifr_flags is negative. | ||
| 739 | Get hardware address with getifaddrs if available. | ||
| 740 | |||
| 741 | 2011-08-12 Eli Zaretskii <eliz@gnu.org> | ||
| 742 | |||
| 743 | * xdisp.c (iterate_out_of_display_property): xassert that | ||
| 744 | IT->position is set to within IT->object's boundaries. Break from | ||
| 745 | the loop as soon as EOB is reached; avoids infloops in redisplay | ||
| 746 | when IT->position is set up wrongly due to some bug. | ||
| 747 | Set IT->current to match the bidi iterator unconditionally. | ||
| 748 | (push_display_prop): Allow GET_FROM_STRING as IT->method on | ||
| 749 | entry. Force push_it to save on the stack the current | ||
| 750 | buffer/string position, to be restored by pop_it. Fix flags in | ||
| 751 | the iterator structure wrt the object coming from a display | ||
| 752 | property, as `line-prefix' and `wrap-prefix' are not ``replacing'' | ||
| 753 | properties. (Bug#9284) | ||
| 754 | |||
| 755 | 2011-08-09 Andreas Schwab <schwab@linux-m68k.org> | ||
| 756 | |||
| 757 | * fontset.c (fontset_get_font_group): Add proper type checks. | ||
| 758 | (Bug#9172) | ||
| 759 | |||
| 760 | 2011-08-09 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 761 | |||
| 762 | * unexmacosx.c (print_load_command_name): Add cases LC_FUNCTION_STARTS | ||
| 763 | and LC_VERSION_MIN_MACOSX. | ||
| 764 | (copy_linkedit_data) [LC_FUNCTION_STARTS]: New function. | ||
| 765 | (dump_it) [LC_FUNCTION_STARTS]: Use it. | ||
| 766 | |||
| 767 | 2011-08-08 Eli Zaretskii <eliz@gnu.org> | ||
| 768 | |||
| 769 | * xdisp.c (forward_to_next_line_start): Allow to use the | ||
| 770 | no-display-properties-and-no-overlays under bidi display. | ||
| 771 | Set disp_pos in the bidi iterator to avoid searches for display | ||
| 772 | properties and overlays. | ||
| 773 | |||
| 774 | 2011-08-08 Chong Yidong <cyd@stupidchicken.com> | ||
| 775 | |||
| 776 | * editfns.c (Fset_time_zone_rule): Document relationship with the | ||
| 777 | setenv function. | ||
| 778 | |||
| 779 | * ftfont.c (ftfont_pattern_entity): Copy the extras argument to | ||
| 780 | the font entity extracted from the cache (Bug#8109). | ||
| 781 | |||
| 782 | 2011-08-07 Chong Yidong <cyd@stupidchicken.com> | ||
| 783 | |||
| 784 | * composite.c (autocmp_chars): Don't reset point. That is done by | ||
| 785 | restore_point_unwind (Bug#5984). | ||
| 786 | |||
| 787 | 2011-08-07 Juri Linkov <juri@jurta.org> | ||
| 788 | |||
| 789 | * editfns.c (Fformat_time_string): Doc fix, add tag `usage:' | ||
| 790 | to show the arg `TIME' instead of `TIMEVAL'. | ||
| 791 | |||
| 792 | 2011-08-06 Eli Zaretskii <eliz@gnu.org> | ||
| 793 | |||
| 794 | * xdisp.c (set_cursor_from_row): Fix cursor positioning when a | ||
| 795 | display property strides EOL and includes a newline, as in | ||
| 796 | longlines-mode. (Bug#9254) | ||
| 797 | (move_it_in_display_line_to): Fix vertical-motion in a buffer with | ||
| 798 | word-wrap under bidirectional display. (Bug#9224) | ||
| 799 | |||
| 800 | * bidi.c (bidi_unshelve_cache): Don't reset the cache if JUST_FREE | ||
| 801 | is non-zero, even if the data buffer is NULL. Fixes a crash in | ||
| 802 | vertical-motion with longlines-mode. (Bug#9254) | ||
| 803 | |||
| 804 | 2011-08-05 Eli Zaretskii <eliz@gnu.org> | ||
| 805 | |||
| 806 | * bidi.c <bidi_cache_total_alloc>: Now static. | ||
| 807 | (bidi_initialize): Initialize bidi_cache_total_alloc. | ||
| 808 | |||
| 809 | * xdisp.c (display_line): Release buffer allocated for shelved bidi | ||
| 810 | cache. (Bug#9221) | ||
| 811 | |||
| 812 | * bidi.c (bidi_shelve_cache, bidi_unshelve_cache): Track total | ||
| 813 | amount allocated this far in `bidi_cache_total_alloc'. | ||
| 814 | (bidi_unshelve_cache): Accept an additional argument JUST_FREE; if | ||
| 815 | non-zero, only free the data buffer without restoring the cache | ||
| 816 | contents. All callers changed. | ||
| 817 | |||
| 818 | * dispextern.h (bidi_unshelve_cache): Update prototype. | ||
| 819 | |||
| 820 | * xdisp.c (SAVE_IT, pos_visible_p, move_it_in_display_line_to) | ||
| 821 | (move_it_in_display_line, move_it_to) | ||
| 822 | (move_it_vertically_backward, move_it_by_lines): Replace the call | ||
| 823 | to xfree to an equivalent call to bidi_unshelve_cache. | ||
| 824 | (move_it_in_display_line_to): Fix logic of returning | ||
| 825 | MOVE_POS_MATCH_OR_ZV in the bidi case. (Bug#9224) | ||
| 826 | |||
| 827 | 2011-08-05 Eli Zaretskii <eliz@gnu.org> | ||
| 828 | |||
| 829 | * xdisp.c (set_cursor_from_row): Prefer the candidate glyph that | ||
| 830 | came from a string character with a `cursor' property. (Bug#9229) | ||
| 831 | |||
| 832 | 2011-08-04 Jan Djärv <jan.h.d@swipnet.se> | ||
| 833 | |||
| 834 | * Makefile.in (LIB_PTHREAD): New variable. | ||
| 835 | (LIBES): Add LIB_PTHREAD (Bug#9216). | ||
| 836 | |||
| 837 | * alloc.c, emacs.c, gmalloc.c, gtkutil.c, keyboard.c, syssignal.h: | ||
| 838 | Rename HAVE_GTK_AND_PTHREAD to HAVE_PTHREAD (Bug#9216). | ||
| 839 | |||
| 840 | 2011-08-04 Andreas Schwab <schwab@linux-m68k.org> | ||
| 841 | |||
| 842 | * regex.c (re_iswctype): Remove some redundant boolean | ||
| 843 | conversions. | ||
| 844 | |||
| 845 | 2011-08-04 Jan Djärv <jan.h.d@swipnet.se> | ||
| 846 | |||
| 847 | * xterm.c (x_find_topmost_parent): New function. | ||
| 848 | (x_set_frame_alpha): Find topmost parent window with | ||
| 849 | x_find_topmost_parent and set the property there also (bug#9181). | ||
| 850 | (handle_one_xevent): Call x_set_frame_alpha on ReparentNotify. | ||
| 851 | |||
| 852 | 2011-08-04 Paul Eggert <eggert@cs.ucla.edu> | ||
| 853 | |||
| 854 | * callproc.c (Fcall_process): Avoid vfork clobbering | ||
| 855 | the local vars buffer, coding_systems, current_dir. | ||
| 856 | |||
| 857 | 2011-08-03 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 858 | |||
| 859 | * keymap.c (Fmake_composed_keymap): Move to subr.el. | ||
| 860 | |||
| 861 | 2011-08-03 Paul Eggert <eggert@cs.ucla.edu> | ||
| 862 | |||
| 863 | * fontset.c (dump_fontset) [FONTSET_DEBUG]: Declare EXTERNALLY_VISIBLE | ||
| 864 | so that it is not optimized away. | ||
| 865 | |||
| 866 | * xdisp.c (compute_display_string_pos): Remove unused local. | ||
| 867 | |||
| 868 | 2011-08-02 Eli Zaretskii <eliz@gnu.org> | ||
| 869 | |||
| 870 | Fix slow cursor motion and scrolling in large buffers with | ||
| 871 | selective display, like Org Mode buffers. (Bug#9218) | ||
| 872 | |||
| 873 | * dispextern.h (struct bidi_it): New member disp_prop_p. | ||
| 874 | |||
| 875 | * xdisp.c: Remove one-slot cache of display string positions. | ||
| 876 | (compute_display_string_pos): Accept an additional argument | ||
| 877 | DISP_PROP_P; callers changed. Scan at most 5K characters forward | ||
| 878 | for a display string or property. If found, set DISP_PROP_P | ||
| 879 | non-zero. | ||
| 880 | |||
| 881 | * bidi.c (bidi_fetch_char): Accept an additional argument | ||
| 882 | DISP_PROP_P, and pass it to compute_display_string_pos. | ||
| 883 | Only handle text covered by a display string if DISP_PROP_P is returned | ||
| 884 | non-zero. All callers of bidi_fetch_char changed. | ||
| 885 | |||
| 886 | 2011-08-02 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 887 | |||
| 888 | * keymap.c (Fdefine_key): Fix Lisp_Object/int mixup; apply some CSE. | ||
| 889 | |||
| 890 | 2010-12-03 Don March <don@ohspite.net> | ||
| 891 | |||
| 892 | * keymap.c (Fdefine_key): Fix non-prefix key error message when | ||
| 893 | last character M-[char] is translated to ESC [char] (bug#7541). | ||
| 894 | |||
| 895 | 2011-08-02 Kenichi Handa <handa@m17n.org> | ||
| 896 | |||
| 897 | * lisp.h (uniprop_table): Extern it. | ||
| 898 | |||
| 899 | * chartab.c (uniprop_table): Make it non-static. | ||
| 900 | |||
| 901 | 2011-08-01 Eli Zaretskii <eliz@gnu.org> | ||
| 902 | |||
| 903 | * xdisp.c (forward_to_next_line_start): Accept additional argument | ||
| 904 | BIDI_IT_PREV, and store into it the state of the bidi iterator had | ||
| 905 | on the newline. | ||
| 906 | (reseat_at_next_visible_line_start): Use the bidi iterator state | ||
| 907 | returned by forward_to_next_line_start to restore the state of | ||
| 908 | it->bidi_it after backing up to previous newline. (Bug#9212) | ||
| 909 | |||
| 910 | 2011-07-30 Andreas Schwab <schwab@linux-m68k.org> | ||
| 911 | |||
| 912 | * regex.c (re_comp): Protoize. | ||
| 913 | (re_exec): Fix return type. | ||
| 914 | (regexec): Fix type of `ret'. (Bug#9203) | ||
| 915 | |||
| 1 | 2011-07-29 Paul Eggert <eggert@cs.ucla.edu> | 916 | 2011-07-29 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 917 | ||
| 3 | * Makefile.in (gl-stamp): move-if-change now in build-aux (Bug#9169). | 918 | * Makefile.in (gl-stamp): move-if-change now in build-aux (Bug#9169). |
| @@ -315,8 +1230,8 @@ | |||
| 315 | 1230 | ||
| 316 | * xdisp.c (move_it_in_display_line_to): Record the best matching | 1231 | * xdisp.c (move_it_in_display_line_to): Record the best matching |
| 317 | position for TO_CHARPOS while scanning the line, and restore it on | 1232 | position for TO_CHARPOS while scanning the line, and restore it on |
| 318 | exit if none of the characters scanned was an exact match. Fixes | 1233 | exit if none of the characters scanned was an exact match. |
| 319 | vertical-motion and pos-visible-in-window-p under bidi redisplay | 1234 | Fixes vertical-motion and pos-visible-in-window-p under bidi redisplay |
| 320 | when exact match is impossible due to invisible text, and the | 1235 | when exact match is impossible due to invisible text, and the |
| 321 | lines are truncated. | 1236 | lines are truncated. |
| 322 | 1237 | ||
| @@ -501,8 +1416,8 @@ | |||
| 501 | (reseat_to_string): Initialize bidi_it->string.s and | 1416 | (reseat_to_string): Initialize bidi_it->string.s and |
| 502 | bidi_it->string.schars. | 1417 | bidi_it->string.schars. |
| 503 | (Fcurrent_bidi_paragraph_direction): Initialize itb.string.s to | 1418 | (Fcurrent_bidi_paragraph_direction): Initialize itb.string.s to |
| 504 | NULL (avoids a crash in bidi_paragraph_init). Initialize | 1419 | NULL (avoids a crash in bidi_paragraph_init). |
| 505 | itb.string.lstring. | 1420 | Initialize itb.string.lstring. |
| 506 | (init_iterator): Call bidi_init_it only of a valid | 1421 | (init_iterator): Call bidi_init_it only of a valid |
| 507 | buffer position was specified. Initialize paragraph_embedding to | 1422 | buffer position was specified. Initialize paragraph_embedding to |
| 508 | L2R. | 1423 | L2R. |
| @@ -518,12 +1433,12 @@ | |||
| 518 | (init_iterator, reseat_1, reseat_to_string): Initialize the | 1433 | (init_iterator, reseat_1, reseat_to_string): Initialize the |
| 519 | string.bufpos member to 0 (zero, for compatibility with IT_CHARPOS | 1434 | string.bufpos member to 0 (zero, for compatibility with IT_CHARPOS |
| 520 | when iterating on a string not from display properties). | 1435 | when iterating on a string not from display properties). |
| 521 | (compute_display_string_pos, compute_display_string_end): Fix | 1436 | (compute_display_string_pos, compute_display_string_end): |
| 522 | calculation of the object to scan. Fixes an error when using | 1437 | Fix calculation of the object to scan. Fixes an error when using |
| 523 | arrow keys. | 1438 | arrow keys. |
| 524 | (next_element_from_buffer): Don't abort when IT_CHARPOS is before | 1439 | (next_element_from_buffer): Don't abort when IT_CHARPOS is before |
| 525 | base_level_stop; instead, set base_level_stop to BEGV. Fixes | 1440 | base_level_stop; instead, set base_level_stop to BEGV. |
| 526 | crashes in vertical-motion. | 1441 | Fixes crashes in vertical-motion. |
| 527 | (next_element_from_buffer): Improve commentary for when | 1442 | (next_element_from_buffer): Improve commentary for when |
| 528 | the iterator is before prev_stop. | 1443 | the iterator is before prev_stop. |
| 529 | (init_iterator): Initialize bidi_p from the default value of | 1444 | (init_iterator): Initialize bidi_p from the default value of |
| @@ -536,8 +1451,8 @@ | |||
| 536 | (next_element_from_string): Support bidi reordering of Lisp | 1451 | (next_element_from_string): Support bidi reordering of Lisp |
| 537 | strings. | 1452 | strings. |
| 538 | (handle_stop_backwards): Support Lisp strings as well. | 1453 | (handle_stop_backwards): Support Lisp strings as well. |
| 539 | (display_string): Support display of R2L glyph rows. Use | 1454 | (display_string): Support display of R2L glyph rows. |
| 540 | IT_STRING_CHARPOS when displaying from a Lisp string. | 1455 | Use IT_STRING_CHARPOS when displaying from a Lisp string. |
| 541 | (init_iterator): Don't initialize it->bidi_p for strings | 1456 | (init_iterator): Don't initialize it->bidi_p for strings |
| 542 | here. | 1457 | here. |
| 543 | (reseat_to_string): Initialize it->bidi_p for strings here. | 1458 | (reseat_to_string): Initialize it->bidi_p for strings here. |
| @@ -619,8 +1534,8 @@ | |||
| 619 | displayed in margins. (Bug#8133) (Bug#8867) | 1534 | displayed in margins. (Bug#8133) (Bug#8867) |
| 620 | Return MOVE_POS_MATCH_OR_ZV only if iterator position is past | 1535 | Return MOVE_POS_MATCH_OR_ZV only if iterator position is past |
| 621 | TO_CHARPOS. | 1536 | TO_CHARPOS. |
| 622 | (pos_visible_p): Support positions in bidi-reordered lines. Save | 1537 | (pos_visible_p): Support positions in bidi-reordered lines. |
| 623 | and restore bidi cache. | 1538 | Save and restore bidi cache. |
| 624 | 1539 | ||
| 625 | * bidi.c (bidi_level_of_next_char): clen should be EMACS_NT, not int. | 1540 | * bidi.c (bidi_level_of_next_char): clen should be EMACS_NT, not int. |
| 626 | (bidi_paragraph_info): Delete unused struct. | 1541 | (bidi_paragraph_info): Delete unused struct. |
| @@ -640,8 +1555,8 @@ | |||
| 640 | `len' according to what STRING_CHAR_AND_LENGTH expects. | 1555 | `len' according to what STRING_CHAR_AND_LENGTH expects. |
| 641 | (bidi_paragraph_init, bidi_resolve_explicit_1) | 1556 | (bidi_paragraph_init, bidi_resolve_explicit_1) |
| 642 | (bidi_resolve_explicit, bidi_resolve_weak) | 1557 | (bidi_resolve_explicit, bidi_resolve_weak) |
| 643 | (bidi_level_of_next_char, bidi_move_to_visually_next): Support | 1558 | (bidi_level_of_next_char, bidi_move_to_visually_next): |
| 644 | iteration over a string. | 1559 | Support iteration over a string. |
| 645 | (bidi_set_sor_type, bidi_resolve_explicit_1) | 1560 | (bidi_set_sor_type, bidi_resolve_explicit_1) |
| 646 | (bidi_resolve_explicit, bidi_type_of_next_char): ignore_bn_limit | 1561 | (bidi_resolve_explicit, bidi_type_of_next_char): ignore_bn_limit |
| 647 | can now be zero (for strings); special values 0 and -1 were | 1562 | can now be zero (for strings); special values 0 and -1 were |
| @@ -672,20 +1587,20 @@ | |||
| 672 | (bidi_cache_fetch_state, bidi_cache_search) | 1587 | (bidi_cache_fetch_state, bidi_cache_search) |
| 673 | (bidi_cache_find_level_change, bidi_cache_ensure_space) | 1588 | (bidi_cache_find_level_change, bidi_cache_ensure_space) |
| 674 | (bidi_cache_iterator_state, bidi_cache_find) | 1589 | (bidi_cache_iterator_state, bidi_cache_find) |
| 675 | (bidi_find_other_level_edge, bidi_cache_start_stack): All | 1590 | (bidi_find_other_level_edge, bidi_cache_start_stack): |
| 676 | variables related to cache indices are now EMACS_INT. | 1591 | All variables related to cache indices are now EMACS_INT. |
| 677 | 1592 | ||
| 678 | * dispextern.h (struct bidi_string_data): New structure. | 1593 | * dispextern.h (struct bidi_string_data): New structure. |
| 679 | (struct bidi_it): New member `string'. Make flag members be 1-bit | 1594 | (struct bidi_it): New member `string'. Make flag members be 1-bit |
| 680 | fields, and put them last in the struct. | 1595 | fields, and put them last in the struct. |
| 681 | (compute_display_string_pos, compute_display_string_end): Update | 1596 | (compute_display_string_pos, compute_display_string_end): |
| 682 | prototypes. | 1597 | Update prototypes. |
| 683 | (bidi_push_it, bidi_pop_it): Add prototypes. | 1598 | (bidi_push_it, bidi_pop_it): Add prototypes. |
| 684 | (struct iterator_stack_entry): New members bidi_p, | 1599 | (struct iterator_stack_entry): New members bidi_p, |
| 685 | paragraph_embedding, and from_disp_prop_p. | 1600 | paragraph_embedding, and from_disp_prop_p. |
| 686 | (struct it): Member bidi_p is now a bit field 1 bit wide. | 1601 | (struct it): Member bidi_p is now a bit field 1 bit wide. |
| 687 | (bidi_shelve_cache, bidi_unshelve_cache): Declare | 1602 | (bidi_shelve_cache, bidi_unshelve_cache): |
| 688 | prototypes. | 1603 | Declare prototypes. |
| 689 | 1604 | ||
| 690 | * .gdbinit (xvectype, xvector, xcompiled, xchartable, xboolvector) | 1605 | * .gdbinit (xvectype, xvector, xcompiled, xchartable, xboolvector) |
| 691 | (xpr, xfont, xbacktrace): Use "header.size" when accessing vectors | 1606 | (xpr, xfont, xbacktrace): Use "header.size" when accessing vectors |
| @@ -967,7 +1882,7 @@ | |||
| 967 | (char_table_set_range): Adjuted for the above change. | 1882 | (char_table_set_range): Adjuted for the above change. |
| 968 | (map_sub_char_table): Delete args default_val and parent. Add arg | 1883 | (map_sub_char_table): Delete args default_val and parent. Add arg |
| 969 | top. Give decoded values to a Lisp function. | 1884 | top. Give decoded values to a Lisp function. |
| 970 | (map_char_table): Adjusted for the above change. Give decoded | 1885 | (map_char_table): Adjust for the above change. Give decoded |
| 971 | values to a Lisp function. Gcpro more variables. | 1886 | values to a Lisp function. Gcpro more variables. |
| 972 | (uniprop_table_uncompress) | 1887 | (uniprop_table_uncompress) |
| 973 | (uniprop_decode_value_run_length): New functions. | 1888 | (uniprop_decode_value_run_length): New functions. |
| @@ -984,10 +1899,10 @@ | |||
| 984 | and Sput_unicode_property_internal. Defvar_lisp | 1899 | and Sput_unicode_property_internal. Defvar_lisp |
| 985 | char-code-property-alist. | 1900 | char-code-property-alist. |
| 986 | 1901 | ||
| 987 | * composite.c (CHAR_COMPOSABLE_P): Adjusted for the change of | 1902 | * composite.c (CHAR_COMPOSABLE_P): Adjust for the change of |
| 988 | Vunicode_category_table. | 1903 | Vunicode_category_table. |
| 989 | 1904 | ||
| 990 | * font.c (font_range): Adjusted for the change of | 1905 | * font.c (font_range): Adjust for the change of |
| 991 | Vunicode_category_table. | 1906 | Vunicode_category_table. |
| 992 | 1907 | ||
| 993 | 2011-07-07 Dan Nicolaescu <dann@ics.uci.edu> | 1908 | 2011-07-07 Dan Nicolaescu <dann@ics.uci.edu> |
| @@ -1016,14 +1931,14 @@ | |||
| 1016 | (store_monospaced_changed): Add comment. Call dpyinfo_valid. | 1931 | (store_monospaced_changed): Add comment. Call dpyinfo_valid. |
| 1017 | (struct xsettings): Move font inside HAVE_XFT. | 1932 | (struct xsettings): Move font inside HAVE_XFT. |
| 1018 | (GSETTINGS_TOOL_BAR_STYLE, GSETTINGS_FONT_NAME): New defines. | 1933 | (GSETTINGS_TOOL_BAR_STYLE, GSETTINGS_FONT_NAME): New defines. |
| 1019 | (GSETTINGS_MONO_FONT): Renamed from SYSTEM_MONO_FONT. | 1934 | (GSETTINGS_MONO_FONT): Rename from SYSTEM_MONO_FONT. |
| 1020 | Move inside HAVE_XFT. | 1935 | Move inside HAVE_XFT. |
| 1021 | (something_changed_gsettingsCB): Renamed from something_changedCB. | 1936 | (something_changed_gsettingsCB): Rename from something_changedCB. |
| 1022 | Check for changes in GSETTINGS_TOOL_BAR_STYLE and GSETTINGS_FONT_NAME | 1937 | Check for changes in GSETTINGS_TOOL_BAR_STYLE and GSETTINGS_FONT_NAME |
| 1023 | also. | 1938 | also. |
| 1024 | (GCONF_TOOL_BAR_STYLE, GCONF_FONT_NAME): New defines. | 1939 | (GCONF_TOOL_BAR_STYLE, GCONF_FONT_NAME): New defines. |
| 1025 | (GCONF_MONO_FONT): Renamed from SYSTEM_MONO_FONT. Move inside HAVE_XFT. | 1940 | (GCONF_MONO_FONT): Rename from SYSTEM_MONO_FONT. Move inside HAVE_XFT. |
| 1026 | (something_changed_gconfCB): Renamed from something_changedCB. | 1941 | (something_changed_gconfCB): Rename from something_changedCB. |
| 1027 | Check for changes in GCONF_TOOL_BAR_STYLE and GCONF_FONT_NAME also. | 1942 | Check for changes in GCONF_TOOL_BAR_STYLE and GCONF_FONT_NAME also. |
| 1028 | (parse_settings): Move check for font inside HAVE_XFT. | 1943 | (parse_settings): Move check for font inside HAVE_XFT. |
| 1029 | (read_settings, apply_xft_settings): Add comment. | 1944 | (read_settings, apply_xft_settings): Add comment. |
| @@ -1036,8 +1951,8 @@ | |||
| 1036 | (init_gconf): Add comment. Get values for GCONF_TOOL_BAR_STYLE | 1951 | (init_gconf): Add comment. Get values for GCONF_TOOL_BAR_STYLE |
| 1037 | and GCONF_FONT_NAME. Move check for fonts within HAVE_XFT. | 1952 | and GCONF_FONT_NAME. Move check for fonts within HAVE_XFT. |
| 1038 | (xsettings_initialize): Call init_gsettings last. | 1953 | (xsettings_initialize): Call init_gsettings last. |
| 1039 | (xsettings_get_system_font, xsettings_get_system_normal_font): Add | 1954 | (xsettings_get_system_font, xsettings_get_system_normal_font): |
| 1040 | comment. | 1955 | Add comment. |
| 1041 | 1956 | ||
| 1042 | 2011-07-05 Paul Eggert <eggert@cs.ucla.edu> | 1957 | 2011-07-05 Paul Eggert <eggert@cs.ucla.edu> |
| 1043 | 1958 | ||
| @@ -1220,7 +2135,7 @@ | |||
| 1220 | (syms_of_xsettings): Initialize gsettings_client, gsettings_obj | 2135 | (syms_of_xsettings): Initialize gsettings_client, gsettings_obj |
| 1221 | to NULL. | 2136 | to NULL. |
| 1222 | 2137 | ||
| 1223 | * Makefile.in (SETTINGS_CFLAGS, SETTINGS_LIBS): Renamed from | 2138 | * Makefile.in (SETTINGS_CFLAGS, SETTINGS_LIBS): Rename from |
| 1224 | GCONF_CFLAGS/LIBS. | 2139 | GCONF_CFLAGS/LIBS. |
| 1225 | 2140 | ||
| 1226 | 2011-06-29 Martin Rudalics <rudalics@gmx.at> | 2141 | 2011-06-29 Martin Rudalics <rudalics@gmx.at> |
| @@ -1967,7 +2882,7 @@ | |||
| 1967 | 2882 | ||
| 1968 | * character.c, coding.c, doprnt.c, editfns.c, eval.c: | 2883 | * character.c, coding.c, doprnt.c, editfns.c, eval.c: |
| 1969 | All uses of STRING_BYTES_MAX replaced by STRING_BYTES_BOUND. | 2884 | All uses of STRING_BYTES_MAX replaced by STRING_BYTES_BOUND. |
| 1970 | * lisp.h (STRING_BYTES_BOUND): Renamed from STRING_BYTES_MAX. | 2885 | * lisp.h (STRING_BYTES_BOUND): Rename from STRING_BYTES_MAX. |
| 1971 | 2886 | ||
| 1972 | * character.c (string_escape_byte8): Fix nbytes/nchars typo. | 2887 | * character.c (string_escape_byte8): Fix nbytes/nchars typo. |
| 1973 | 2888 | ||
| @@ -2076,8 +2991,8 @@ | |||
| 2076 | Qclone_number. Remove external declaration of Qdelete_window. | 2991 | Qclone_number. Remove external declaration of Qdelete_window. |
| 2077 | (Fbuffer_list): Rewrite doc-string. Minor restructuring of | 2992 | (Fbuffer_list): Rewrite doc-string. Minor restructuring of |
| 2078 | code. | 2993 | code. |
| 2079 | (Fget_buffer_create, Fmake_indirect_buffer, Frename_buffer): Run | 2994 | (Fget_buffer_create, Fmake_indirect_buffer, Frename_buffer): |
| 2080 | Qbuffer_list_update_hook if allowed. | 2995 | Run Qbuffer_list_update_hook if allowed. |
| 2081 | (Fother_buffer): Rewrite doc-string. Major rewrite for new | 2996 | (Fother_buffer): Rewrite doc-string. Major rewrite for new |
| 2082 | buffer list implementation. | 2997 | buffer list implementation. |
| 2083 | (other_buffer_safely): New function. | 2998 | (other_buffer_safely): New function. |
| @@ -2088,8 +3003,8 @@ | |||
| 2088 | (record_buffer): Inhibit quitting and rewrite using quittable | 3003 | (record_buffer): Inhibit quitting and rewrite using quittable |
| 2089 | functions. Run Qbuffer_list_update_hook if allowed. | 3004 | functions. Run Qbuffer_list_update_hook if allowed. |
| 2090 | (Frecord_buffer, Funrecord_buffer): New functions. | 3005 | (Frecord_buffer, Funrecord_buffer): New functions. |
| 2091 | (switch_to_buffer_1, Fswitch_to_buffer): Remove. Move | 3006 | (switch_to_buffer_1, Fswitch_to_buffer): Remove. |
| 2092 | switch-to-buffer to window.el. | 3007 | Move switch-to-buffer to window.el. |
| 2093 | (bury-buffer): Move to window.el. | 3008 | (bury-buffer): Move to window.el. |
| 2094 | (Vbuffer_list_update_hook): New variable. | 3009 | (Vbuffer_list_update_hook): New variable. |
| 2095 | 3010 | ||
| @@ -2117,8 +3032,8 @@ | |||
| 2117 | (select_window_norecord, select_frame_norecord): Move in front | 3032 | (select_window_norecord, select_frame_norecord): Move in front |
| 2118 | of run_window_configuration_change_hook. Remove now obsolete | 3033 | of run_window_configuration_change_hook. Remove now obsolete |
| 2119 | declarations. | 3034 | declarations. |
| 2120 | (Fset_window_buffer): Rewrite doc-string. Call | 3035 | (Fset_window_buffer): Rewrite doc-string. |
| 2121 | Qrecord_window_buffer. | 3036 | Call Qrecord_window_buffer. |
| 2122 | (keys_of_window): Move binding for other-window to window.el. | 3037 | (keys_of_window): Move binding for other-window to window.el. |
| 2123 | 3038 | ||
| 2124 | 2011-06-11 Chong Yidong <cyd@stupidchicken.com> | 3039 | 2011-06-11 Chong Yidong <cyd@stupidchicken.com> |
| @@ -2200,8 +3115,8 @@ | |||
| 2200 | orig_total_lines. | 3115 | orig_total_lines. |
| 2201 | (Fdelete_window, delete_window): Remove. Window deletion is | 3116 | (Fdelete_window, delete_window): Remove. Window deletion is |
| 2202 | handled by window.el. | 3117 | handled by window.el. |
| 2203 | (window_loop): Remove DELETE_OTHER_WINDOWS case. Replace | 3118 | (window_loop): Remove DELETE_OTHER_WINDOWS case. |
| 2204 | Fdelete_window calls with calls to Qdelete_window. | 3119 | Replace Fdelete_window calls with calls to Qdelete_window. |
| 2205 | (Fdelete_other_windows): Remove. Deleting other windows is | 3120 | (Fdelete_other_windows): Remove. Deleting other windows is |
| 2206 | handled by window.el. | 3121 | handled by window.el. |
| 2207 | (window_fixed_size_p): Remove. Fixed-sizeness of windows is | 3122 | (window_fixed_size_p): Remove. Fixed-sizeness of windows is |
| @@ -2224,8 +3139,8 @@ | |||
| 2224 | (grow_mini_window, shrink_mini_window): Implement by calling | 3139 | (grow_mini_window, shrink_mini_window): Implement by calling |
| 2225 | Qresize_root_window_vertically, resize_window_check and | 3140 | Qresize_root_window_vertically, resize_window_check and |
| 2226 | resize_window_apply. | 3141 | resize_window_apply. |
| 2227 | (saved_window, Fset_window_configuration, save_window_save): Do | 3142 | (saved_window, Fset_window_configuration, save_window_save): |
| 2228 | not handle orig_top_line, orig_total_lines, and | 3143 | Do not handle orig_top_line, orig_total_lines, and |
| 2229 | resize_proportionally. | 3144 | resize_proportionally. |
| 2230 | (window_min_height, window_min_width): Move to window.el. | 3145 | (window_min_height, window_min_width): Move to window.el. |
| 2231 | (keys_of_window): Move bindings for delete-other-windows, | 3146 | (keys_of_window): Move bindings for delete-other-windows, |
| @@ -2245,8 +3160,8 @@ | |||
| 2245 | * xdisp.c (init_xdisp): Don't use set_window_height but set | 3160 | * xdisp.c (init_xdisp): Don't use set_window_height but set |
| 2246 | heights directly. | 3161 | heights directly. |
| 2247 | 3162 | ||
| 2248 | * xfns.c (x_set_menu_bar_lines, x_set_tool_bar_lines): Use | 3163 | * xfns.c (x_set_menu_bar_lines, x_set_tool_bar_lines): |
| 2249 | resize_frame_windows instead of change_window_heights and run | 3164 | Use resize_frame_windows instead of change_window_heights and run |
| 2250 | run_window_configuration_change_hook. | 3165 | run_window_configuration_change_hook. |
| 2251 | 3166 | ||
| 2252 | * w32fns.c (x_set_tool_bar_lines): Use resize_frame_windows | 3167 | * w32fns.c (x_set_tool_bar_lines): Use resize_frame_windows |
| @@ -2268,8 +3183,8 @@ | |||
| 2268 | (Frun_window_configuration_change_hook, make_parent_window) | 3183 | (Frun_window_configuration_change_hook, make_parent_window) |
| 2269 | (resize_window_check, resize_window_apply, Fresize_window_apply) | 3184 | (resize_window_check, resize_window_apply, Fresize_window_apply) |
| 2270 | (resize_frame_windows, Fsplit_window_internal) | 3185 | (resize_frame_windows, Fsplit_window_internal) |
| 2271 | (Fdelete_window_internal, Fresize_mini_window_internal): New | 3186 | (Fdelete_window_internal, Fresize_mini_window_internal): |
| 2272 | functions. | 3187 | New functions. |
| 2273 | (syms_of_window): New variables Vwindow_splits and Vwindow_nest. | 3188 | (syms_of_window): New variables Vwindow_splits and Vwindow_nest. |
| 2274 | 3189 | ||
| 2275 | 2011-06-08 Martin Rudalics <rudalics@gmx.at> | 3190 | 2011-06-08 Martin Rudalics <rudalics@gmx.at> |
| @@ -2289,8 +3204,8 @@ | |||
| 2289 | (Fwindow_nest, Fset_window_nest, Fwindow_new_total) | 3204 | (Fwindow_nest, Fset_window_nest, Fwindow_new_total) |
| 2290 | (Fwindow_normal_size, Fwindow_new_normal, Fwindow_prev_buffers) | 3205 | (Fwindow_normal_size, Fwindow_new_normal, Fwindow_prev_buffers) |
| 2291 | (Fset_window_prev_buffers, Fwindow_next_buffers) | 3206 | (Fset_window_prev_buffers, Fwindow_next_buffers) |
| 2292 | (Fset_window_next_buffers, Fset_window_clone_number): New | 3207 | (Fset_window_next_buffers, Fset_window_clone_number): |
| 2293 | functions. | 3208 | New functions. |
| 2294 | (Fwindow_hscroll, Fwindow_at, Fwindow_point, Fwindow_start) | 3209 | (Fwindow_hscroll, Fwindow_at, Fwindow_point, Fwindow_start) |
| 2295 | (Fwindow_end, Fwindow_line_height, Fset_window_dedicated_p): | 3210 | (Fwindow_end, Fwindow_line_height, Fset_window_dedicated_p): |
| 2296 | Doc-string fixes. | 3211 | Doc-string fixes. |
| @@ -2316,10 +3231,10 @@ | |||
| 2316 | (Fwindow_top_line, window_body_lines, Fwindow_body_size) | 3231 | (Fwindow_top_line, window_body_lines, Fwindow_body_size) |
| 2317 | (Fwindow_list_1): New functions. | 3232 | (Fwindow_list_1): New functions. |
| 2318 | (window_box_text_cols): Replace with window_body_cols. | 3233 | (window_box_text_cols): Replace with window_body_cols. |
| 2319 | (Fwindow_width, Fscroll_left, Fscroll_right): Use | 3234 | (Fwindow_width, Fscroll_left, Fscroll_right): |
| 2320 | window_body_cols instead of window_box_text_cols. | 3235 | Use window_body_cols instead of window_box_text_cols. |
| 2321 | (delete_window, Fset_window_configuration): Call | 3236 | (delete_window, Fset_window_configuration): |
| 2322 | delete_all_subwindows with window as argument. | 3237 | Call delete_all_subwindows with window as argument. |
| 2323 | (delete_all_subwindows): Take a window as argument and not a | 3238 | (delete_all_subwindows): Take a window as argument and not a |
| 2324 | structure. Rewrite. | 3239 | structure. Rewrite. |
| 2325 | (window_loop): Remove handling of GET_LRU_WINDOW and | 3240 | (window_loop): Remove handling of GET_LRU_WINDOW and |
| @@ -2330,8 +3245,8 @@ | |||
| 2330 | window_box_text_cols. delete_all_subwindows now takes a | 3245 | window_box_text_cols. delete_all_subwindows now takes a |
| 2331 | Lisp_Object as argument. | 3246 | Lisp_Object as argument. |
| 2332 | 3247 | ||
| 2333 | * indent.c (compute_motion, Fcompute_motion): Use | 3248 | * indent.c (compute_motion, Fcompute_motion): |
| 2334 | window_body_cols instead of window_box_text_cols. | 3249 | Use window_body_cols instead of window_box_text_cols. |
| 2335 | 3250 | ||
| 2336 | * frame.c (delete_frame): Call delete_all_subwindows with root | 3251 | * frame.c (delete_frame): Call delete_all_subwindows with root |
| 2337 | window as argument. | 3252 | window as argument. |
diff --git a/src/Makefile.in b/src/Makefile.in index 67a5175b798..3be10c388c7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -130,6 +130,9 @@ START_FILES = @START_FILES@ | |||
| 130 | ## -lm, or empty. | 130 | ## -lm, or empty. |
| 131 | LIB_MATH=@LIB_MATH@ | 131 | LIB_MATH=@LIB_MATH@ |
| 132 | 132 | ||
| 133 | ## -lpthreads, or empty. | ||
| 134 | LIB_PTHREAD=@LIB_PTHREAD@ | ||
| 135 | |||
| 133 | LIBTIFF=@LIBTIFF@ | 136 | LIBTIFF=@LIBTIFF@ |
| 134 | LIBJPEG=@LIBJPEG@ | 137 | LIBJPEG=@LIBJPEG@ |
| 135 | LIBPNG=@LIBPNG@ | 138 | LIBPNG=@LIBPNG@ |
| @@ -385,7 +388,7 @@ LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ | |||
| 385 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ | 388 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ |
| 386 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ | 389 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
| 387 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ | 390 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ |
| 388 | $(LIBGNUTLS_LIBS) $(LIB_PTHREAD_SIGMASK) \ | 391 | $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \ |
| 389 | $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) | 392 | $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) |
| 390 | 393 | ||
| 391 | all: emacs$(EXEEXT) $(OTHER_FILES) | 394 | all: emacs$(EXEEXT) $(OTHER_FILES) |
diff --git a/src/alloc.c b/src/alloc.c index b96fc1f0642..2d256800466 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -24,7 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 24 | 24 | ||
| 25 | #include <signal.h> | 25 | #include <signal.h> |
| 26 | 26 | ||
| 27 | #ifdef HAVE_GTK_AND_PTHREAD | 27 | #ifdef HAVE_PTHREAD |
| 28 | #include <pthread.h> | 28 | #include <pthread.h> |
| 29 | #endif | 29 | #endif |
| 30 | 30 | ||
| @@ -46,6 +46,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 46 | #include "syssignal.h" | 46 | #include "syssignal.h" |
| 47 | #include "termhooks.h" /* For struct terminal. */ | 47 | #include "termhooks.h" /* For struct terminal. */ |
| 48 | #include <setjmp.h> | 48 | #include <setjmp.h> |
| 49 | #include <verify.h> | ||
| 49 | 50 | ||
| 50 | /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd | 51 | /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd |
| 51 | memory. Can do this only if using gmalloc.c. */ | 52 | memory. Can do this only if using gmalloc.c. */ |
| @@ -84,13 +85,15 @@ extern size_t __malloc_extra_blocks; | |||
| 84 | #endif /* not DOUG_LEA_MALLOC */ | 85 | #endif /* not DOUG_LEA_MALLOC */ |
| 85 | 86 | ||
| 86 | #if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT | 87 | #if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT |
| 87 | #ifdef HAVE_GTK_AND_PTHREAD | 88 | #ifdef HAVE_PTHREAD |
| 88 | 89 | ||
| 89 | /* When GTK uses the file chooser dialog, different backends can be loaded | 90 | /* When GTK uses the file chooser dialog, different backends can be loaded |
| 90 | dynamically. One such a backend is the Gnome VFS backend that gets loaded | 91 | dynamically. One such a backend is the Gnome VFS backend that gets loaded |
| 91 | if you run Gnome. That backend creates several threads and also allocates | 92 | if you run Gnome. That backend creates several threads and also allocates |
| 92 | memory with malloc. | 93 | memory with malloc. |
| 93 | 94 | ||
| 95 | Also, gconf and gsettings may create several threads. | ||
| 96 | |||
| 94 | If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* | 97 | If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* |
| 95 | functions below are called from malloc, there is a chance that one | 98 | functions below are called from malloc, there is a chance that one |
| 96 | of these threads preempts the Emacs main thread and the hook variables | 99 | of these threads preempts the Emacs main thread and the hook variables |
| @@ -122,12 +125,12 @@ static pthread_mutex_t alloc_mutex; | |||
| 122 | } \ | 125 | } \ |
| 123 | while (0) | 126 | while (0) |
| 124 | 127 | ||
| 125 | #else /* ! defined HAVE_GTK_AND_PTHREAD */ | 128 | #else /* ! defined HAVE_PTHREAD */ |
| 126 | 129 | ||
| 127 | #define BLOCK_INPUT_ALLOC BLOCK_INPUT | 130 | #define BLOCK_INPUT_ALLOC BLOCK_INPUT |
| 128 | #define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT | 131 | #define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT |
| 129 | 132 | ||
| 130 | #endif /* ! defined HAVE_GTK_AND_PTHREAD */ | 133 | #endif /* ! defined HAVE_PTHREAD */ |
| 131 | #endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */ | 134 | #endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */ |
| 132 | 135 | ||
| 133 | /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer | 136 | /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer |
| @@ -731,6 +734,93 @@ xfree (POINTER_TYPE *block) | |||
| 731 | } | 734 | } |
| 732 | 735 | ||
| 733 | 736 | ||
| 737 | /* Other parts of Emacs pass large int values to allocator functions | ||
| 738 | expecting ptrdiff_t. This is portable in practice, but check it to | ||
| 739 | be safe. */ | ||
| 740 | verify (INT_MAX <= PTRDIFF_MAX); | ||
| 741 | |||
| 742 | |||
| 743 | /* Allocate an array of NITEMS items, each of size ITEM_SIZE. | ||
| 744 | Signal an error on memory exhaustion, and block interrupt input. */ | ||
| 745 | |||
| 746 | void * | ||
| 747 | xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size) | ||
| 748 | { | ||
| 749 | xassert (0 <= nitems && 0 < item_size); | ||
| 750 | if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems) | ||
| 751 | memory_full (SIZE_MAX); | ||
| 752 | return xmalloc (nitems * item_size); | ||
| 753 | } | ||
| 754 | |||
| 755 | |||
| 756 | /* Reallocate an array PA to make it of NITEMS items, each of size ITEM_SIZE. | ||
| 757 | Signal an error on memory exhaustion, and block interrupt input. */ | ||
| 758 | |||
| 759 | void * | ||
| 760 | xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size) | ||
| 761 | { | ||
| 762 | xassert (0 <= nitems && 0 < item_size); | ||
| 763 | if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems) | ||
| 764 | memory_full (SIZE_MAX); | ||
| 765 | return xrealloc (pa, nitems * item_size); | ||
| 766 | } | ||
| 767 | |||
| 768 | |||
| 769 | /* Grow PA, which points to an array of *NITEMS items, and return the | ||
| 770 | location of the reallocated array, updating *NITEMS to reflect its | ||
| 771 | new size. The new array will contain at least NITEMS_INCR_MIN more | ||
| 772 | items, but will not contain more than NITEMS_MAX items total. | ||
| 773 | ITEM_SIZE is the size of each item, in bytes. | ||
| 774 | |||
| 775 | ITEM_SIZE and NITEMS_INCR_MIN must be positive. *NITEMS must be | ||
| 776 | nonnegative. If NITEMS_MAX is -1, it is treated as if it were | ||
| 777 | infinity. | ||
| 778 | |||
| 779 | If PA is null, then allocate a new array instead of reallocating | ||
| 780 | the old one. Thus, to grow an array A without saving its old | ||
| 781 | contents, invoke xfree (A) immediately followed by xgrowalloc (0, | ||
| 782 | &NITEMS, ...). | ||
| 783 | |||
| 784 | Block interrupt input as needed. If memory exhaustion occurs, set | ||
| 785 | *NITEMS to zero if PA is null, and signal an error (i.e., do not | ||
| 786 | return). */ | ||
| 787 | |||
| 788 | void * | ||
| 789 | xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, | ||
| 790 | ptrdiff_t nitems_max, ptrdiff_t item_size) | ||
| 791 | { | ||
| 792 | /* The approximate size to use for initial small allocation | ||
| 793 | requests. This is the largest "small" request for the GNU C | ||
| 794 | library malloc. */ | ||
| 795 | enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; | ||
| 796 | |||
| 797 | /* If the array is tiny, grow it to about (but no greater than) | ||
| 798 | DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%. */ | ||
| 799 | ptrdiff_t n = *nitems; | ||
| 800 | ptrdiff_t tiny_max = DEFAULT_MXFAST / item_size - n; | ||
| 801 | ptrdiff_t half_again = n >> 1; | ||
| 802 | ptrdiff_t incr_estimate = max (tiny_max, half_again); | ||
| 803 | |||
| 804 | /* Adjust the increment according to three constraints: NITEMS_INCR_MIN, | ||
| 805 | NITEMS_MAX, and what the C language can represent safely. */ | ||
| 806 | ptrdiff_t C_language_max = min (PTRDIFF_MAX, SIZE_MAX) / item_size; | ||
| 807 | ptrdiff_t n_max = (0 <= nitems_max && nitems_max < C_language_max | ||
| 808 | ? nitems_max : C_language_max); | ||
| 809 | ptrdiff_t nitems_incr_max = n_max - n; | ||
| 810 | ptrdiff_t incr = max (nitems_incr_min, min (incr_estimate, nitems_incr_max)); | ||
| 811 | |||
| 812 | xassert (0 < item_size && 0 < nitems_incr_min && 0 <= n && -1 <= nitems_max); | ||
| 813 | if (! pa) | ||
| 814 | *nitems = 0; | ||
| 815 | if (nitems_incr_max < incr) | ||
| 816 | memory_full (SIZE_MAX); | ||
| 817 | n += incr; | ||
| 818 | pa = xrealloc (pa, n * item_size); | ||
| 819 | *nitems = n; | ||
| 820 | return pa; | ||
| 821 | } | ||
| 822 | |||
| 823 | |||
| 734 | /* Like strdup, but uses xmalloc. */ | 824 | /* Like strdup, but uses xmalloc. */ |
| 735 | 825 | ||
| 736 | char * | 826 | char * |
| @@ -1265,7 +1355,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2) | |||
| 1265 | } | 1355 | } |
| 1266 | 1356 | ||
| 1267 | 1357 | ||
| 1268 | #ifdef HAVE_GTK_AND_PTHREAD | 1358 | #ifdef HAVE_PTHREAD |
| 1269 | /* Called from Fdump_emacs so that when the dumped Emacs starts, it has a | 1359 | /* Called from Fdump_emacs so that when the dumped Emacs starts, it has a |
| 1270 | normal malloc. Some thread implementations need this as they call | 1360 | normal malloc. Some thread implementations need this as they call |
| 1271 | malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then | 1361 | malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then |
| @@ -1278,7 +1368,7 @@ reset_malloc_hooks (void) | |||
| 1278 | __malloc_hook = old_malloc_hook; | 1368 | __malloc_hook = old_malloc_hook; |
| 1279 | __realloc_hook = old_realloc_hook; | 1369 | __realloc_hook = old_realloc_hook; |
| 1280 | } | 1370 | } |
| 1281 | #endif /* HAVE_GTK_AND_PTHREAD */ | 1371 | #endif /* HAVE_PTHREAD */ |
| 1282 | 1372 | ||
| 1283 | 1373 | ||
| 1284 | /* Called from main to set up malloc to use our hooks. */ | 1374 | /* Called from main to set up malloc to use our hooks. */ |
| @@ -1286,7 +1376,7 @@ reset_malloc_hooks (void) | |||
| 1286 | void | 1376 | void |
| 1287 | uninterrupt_malloc (void) | 1377 | uninterrupt_malloc (void) |
| 1288 | { | 1378 | { |
| 1289 | #ifdef HAVE_GTK_AND_PTHREAD | 1379 | #ifdef HAVE_PTHREAD |
| 1290 | #ifdef DOUG_LEA_MALLOC | 1380 | #ifdef DOUG_LEA_MALLOC |
| 1291 | pthread_mutexattr_t attr; | 1381 | pthread_mutexattr_t attr; |
| 1292 | 1382 | ||
| @@ -1300,7 +1390,7 @@ uninterrupt_malloc (void) | |||
| 1300 | and the bundled gmalloc.c doesn't require it. */ | 1390 | and the bundled gmalloc.c doesn't require it. */ |
| 1301 | pthread_mutex_init (&alloc_mutex, NULL); | 1391 | pthread_mutex_init (&alloc_mutex, NULL); |
| 1302 | #endif /* !DOUG_LEA_MALLOC */ | 1392 | #endif /* !DOUG_LEA_MALLOC */ |
| 1303 | #endif /* HAVE_GTK_AND_PTHREAD */ | 1393 | #endif /* HAVE_PTHREAD */ |
| 1304 | 1394 | ||
| 1305 | if (__free_hook != emacs_blocked_free) | 1395 | if (__free_hook != emacs_blocked_free) |
| 1306 | old_free_hook = __free_hook; | 1396 | old_free_hook = __free_hook; |
diff --git a/src/bidi.c b/src/bidi.c index 697ebb92856..bb29647ea88 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -79,6 +79,11 @@ typedef enum { | |||
| 79 | STRONG | 79 | STRONG |
| 80 | } bidi_category_t; | 80 | } bidi_category_t; |
| 81 | 81 | ||
| 82 | /* UAX#9 says to search only for L, AL, or R types of characters, and | ||
| 83 | ignore RLE, RLO, LRE, and LRO, when determining the base paragraph | ||
| 84 | level. Yudit indeed ignores them. This variable is therefore set | ||
| 85 | by default to ignore them, but setting it to zero will take them | ||
| 86 | into account. */ | ||
| 82 | extern int bidi_ignore_explicit_marks_for_paragraph_level EXTERNALLY_VISIBLE; | 87 | extern int bidi_ignore_explicit_marks_for_paragraph_level EXTERNALLY_VISIBLE; |
| 83 | int bidi_ignore_explicit_marks_for_paragraph_level = 1; | 88 | int bidi_ignore_explicit_marks_for_paragraph_level = 1; |
| 84 | 89 | ||
| @@ -103,6 +108,12 @@ bidi_get_type (int ch, bidi_dir_t override) | |||
| 103 | abort (); | 108 | abort (); |
| 104 | 109 | ||
| 105 | default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); | 110 | default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); |
| 111 | /* Every valid character code, even those that are unassigned by the | ||
| 112 | UCD, have some bidi-class property, according to | ||
| 113 | DerivedBidiClass.txt file. Therefore, if we ever get UNKNOWN_BT | ||
| 114 | (= zero) code from CHAR_TABLE_REF, that's a bug. */ | ||
| 115 | if (default_type == UNKNOWN_BT) | ||
| 116 | abort (); | ||
| 106 | 117 | ||
| 107 | if (override == NEUTRAL_DIR) | 118 | if (override == NEUTRAL_DIR) |
| 108 | return default_type; | 119 | return default_type; |
| @@ -135,11 +146,10 @@ bidi_get_type (int ch, bidi_dir_t override) | |||
| 135 | } | 146 | } |
| 136 | } | 147 | } |
| 137 | 148 | ||
| 138 | static void | 149 | static inline void |
| 139 | bidi_check_type (bidi_type_t type) | 150 | bidi_check_type (bidi_type_t type) |
| 140 | { | 151 | { |
| 141 | if (type < UNKNOWN_BT || type > NEUTRAL_ON) | 152 | xassert (UNKNOWN_BT <= type && type <= NEUTRAL_ON); |
| 142 | abort (); | ||
| 143 | } | 153 | } |
| 144 | 154 | ||
| 145 | /* Given a bidi TYPE of a character, return its category. */ | 155 | /* Given a bidi TYPE of a character, return its category. */ |
| @@ -306,6 +316,21 @@ static ptrdiff_t bidi_cache_last_idx; /* slot of last cache hit */ | |||
| 306 | static ptrdiff_t bidi_cache_start = 0; /* start of cache for this | 316 | static ptrdiff_t bidi_cache_start = 0; /* start of cache for this |
| 307 | "stack" level */ | 317 | "stack" level */ |
| 308 | 318 | ||
| 319 | /* 5-slot stack for saving the start of the previous level of the | ||
| 320 | cache. xdisp.c maintains a 5-slot stack for its iterator state, | ||
| 321 | and we need the same size of our stack. */ | ||
| 322 | static ptrdiff_t bidi_cache_start_stack[IT_STACK_SIZE]; | ||
| 323 | static int bidi_cache_sp; | ||
| 324 | |||
| 325 | /* Size of header used by bidi_shelve_cache. */ | ||
| 326 | enum | ||
| 327 | { | ||
| 328 | bidi_shelve_header_size = | ||
| 329 | (sizeof (bidi_cache_idx) + sizeof (bidi_cache_start_stack) | ||
| 330 | + sizeof (bidi_cache_sp) + sizeof (bidi_cache_start) | ||
| 331 | + sizeof (bidi_cache_last_idx)) | ||
| 332 | }; | ||
| 333 | |||
| 309 | /* Reset the cache state to the empty state. We only reset the part | 334 | /* Reset the cache state to the empty state. We only reset the part |
| 310 | of the cache relevant to iteration of the current object. Previous | 335 | of the cache relevant to iteration of the current object. Previous |
| 311 | objects, which are pushed on the display iterator's stack, are left | 336 | objects, which are pushed on the display iterator's stack, are left |
| @@ -328,9 +353,9 @@ bidi_cache_shrink (void) | |||
| 328 | { | 353 | { |
| 329 | if (bidi_cache_size > BIDI_CACHE_CHUNK) | 354 | if (bidi_cache_size > BIDI_CACHE_CHUNK) |
| 330 | { | 355 | { |
| 331 | bidi_cache_size = BIDI_CACHE_CHUNK; | ||
| 332 | bidi_cache = | 356 | bidi_cache = |
| 333 | (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz); | 357 | (struct bidi_it *) xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz); |
| 358 | bidi_cache_size = BIDI_CACHE_CHUNK; | ||
| 334 | } | 359 | } |
| 335 | bidi_cache_reset (); | 360 | bidi_cache_reset (); |
| 336 | } | 361 | } |
| @@ -463,21 +488,19 @@ bidi_cache_ensure_space (ptrdiff_t idx) | |||
| 463 | /* Enlarge the cache as needed. */ | 488 | /* Enlarge the cache as needed. */ |
| 464 | if (idx >= bidi_cache_size) | 489 | if (idx >= bidi_cache_size) |
| 465 | { | 490 | { |
| 466 | ptrdiff_t new_size; | ||
| 467 | |||
| 468 | /* The bidi cache cannot be larger than the largest Lisp string | 491 | /* The bidi cache cannot be larger than the largest Lisp string |
| 469 | or buffer. */ | 492 | or buffer. */ |
| 470 | ptrdiff_t string_or_buffer_bound = | 493 | ptrdiff_t string_or_buffer_bound = |
| 471 | max (BUF_BYTES_MAX, STRING_BYTES_BOUND); | 494 | max (BUF_BYTES_MAX, STRING_BYTES_BOUND); |
| 472 | 495 | ||
| 473 | /* Also, it cannot be larger than what C can represent. */ | 496 | /* Also, it cannot be larger than what C can represent. */ |
| 474 | ptrdiff_t c_bound = min (PTRDIFF_MAX, SIZE_MAX) / elsz; | 497 | ptrdiff_t c_bound = |
| 498 | (min (PTRDIFF_MAX, SIZE_MAX) - bidi_shelve_header_size) / elsz; | ||
| 475 | 499 | ||
| 476 | if (min (string_or_buffer_bound, c_bound) <= idx) | 500 | bidi_cache = |
| 477 | memory_full (SIZE_MAX); | 501 | xpalloc (bidi_cache, &bidi_cache_size, |
| 478 | new_size = idx - idx % BIDI_CACHE_CHUNK + BIDI_CACHE_CHUNK; | 502 | max (BIDI_CACHE_CHUNK, idx - bidi_cache_size + 1), |
| 479 | bidi_cache = (struct bidi_it *) xrealloc (bidi_cache, new_size * elsz); | 503 | min (string_or_buffer_bound, c_bound), elsz); |
| 480 | bidi_cache_size = new_size; | ||
| 481 | } | 504 | } |
| 482 | } | 505 | } |
| 483 | 506 | ||
| @@ -529,6 +552,8 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) | |||
| 529 | bidi_cache[idx].next_for_neutral = bidi_it->next_for_neutral; | 552 | bidi_cache[idx].next_for_neutral = bidi_it->next_for_neutral; |
| 530 | bidi_cache[idx].next_for_ws = bidi_it->next_for_ws; | 553 | bidi_cache[idx].next_for_ws = bidi_it->next_for_ws; |
| 531 | bidi_cache[idx].ignore_bn_limit = bidi_it->ignore_bn_limit; | 554 | bidi_cache[idx].ignore_bn_limit = bidi_it->ignore_bn_limit; |
| 555 | bidi_cache[idx].disp_pos = bidi_it->disp_pos; | ||
| 556 | bidi_cache[idx].disp_prop = bidi_it->disp_prop; | ||
| 532 | } | 557 | } |
| 533 | 558 | ||
| 534 | bidi_cache_last_idx = idx; | 559 | bidi_cache_last_idx = idx; |
| @@ -568,11 +593,6 @@ bidi_peek_at_next_level (struct bidi_it *bidi_it) | |||
| 568 | /*********************************************************************** | 593 | /*********************************************************************** |
| 569 | Pushing and popping the bidi iterator state | 594 | Pushing and popping the bidi iterator state |
| 570 | ***********************************************************************/ | 595 | ***********************************************************************/ |
| 571 | /* 5-slot stack for saving the start of the previous level of the | ||
| 572 | cache. xdisp.c maintains a 5-slot stack for its iterator state, | ||
| 573 | and we need the same size of our stack. */ | ||
| 574 | static ptrdiff_t bidi_cache_start_stack[IT_STACK_SIZE]; | ||
| 575 | static int bidi_cache_sp; | ||
| 576 | 596 | ||
| 577 | /* Push the bidi iterator state in preparation for reordering a | 597 | /* Push the bidi iterator state in preparation for reordering a |
| 578 | different object, e.g. display string found at certain buffer | 598 | different object, e.g. display string found at certain buffer |
| @@ -620,20 +640,24 @@ bidi_pop_it (struct bidi_it *bidi_it) | |||
| 620 | bidi_cache_last_idx = -1; | 640 | bidi_cache_last_idx = -1; |
| 621 | } | 641 | } |
| 622 | 642 | ||
| 643 | static ptrdiff_t bidi_cache_total_alloc; | ||
| 644 | |||
| 623 | /* Stash away a copy of the cache and its control variables. */ | 645 | /* Stash away a copy of the cache and its control variables. */ |
| 624 | void * | 646 | void * |
| 625 | bidi_shelve_cache (void) | 647 | bidi_shelve_cache (void) |
| 626 | { | 648 | { |
| 627 | unsigned char *databuf; | 649 | unsigned char *databuf; |
| 650 | ptrdiff_t alloc; | ||
| 628 | 651 | ||
| 652 | /* Empty cache. */ | ||
| 629 | if (bidi_cache_idx == 0) | 653 | if (bidi_cache_idx == 0) |
| 630 | return NULL; | 654 | return NULL; |
| 631 | 655 | ||
| 632 | databuf = xmalloc (sizeof (bidi_cache_idx) | 656 | alloc = (bidi_shelve_header_size |
| 633 | + bidi_cache_idx * sizeof (struct bidi_it) | 657 | + bidi_cache_idx * sizeof (struct bidi_it)); |
| 634 | + sizeof (bidi_cache_start_stack) | 658 | databuf = xmalloc (alloc); |
| 635 | + sizeof (bidi_cache_sp) + sizeof (bidi_cache_start) | 659 | bidi_cache_total_alloc += alloc; |
| 636 | + sizeof (bidi_cache_last_idx)); | 660 | |
| 637 | memcpy (databuf, &bidi_cache_idx, sizeof (bidi_cache_idx)); | 661 | memcpy (databuf, &bidi_cache_idx, sizeof (bidi_cache_idx)); |
| 638 | memcpy (databuf + sizeof (bidi_cache_idx), | 662 | memcpy (databuf + sizeof (bidi_cache_idx), |
| 639 | bidi_cache, bidi_cache_idx * sizeof (struct bidi_it)); | 663 | bidi_cache, bidi_cache_idx * sizeof (struct bidi_it)); |
| @@ -657,45 +681,65 @@ bidi_shelve_cache (void) | |||
| 657 | return databuf; | 681 | return databuf; |
| 658 | } | 682 | } |
| 659 | 683 | ||
| 660 | /* Restore the cache state from a copy stashed away by bidi_shelve_cache. */ | 684 | /* Restore the cache state from a copy stashed away by |
| 685 | bidi_shelve_cache, and free the buffer used to stash that copy. | ||
| 686 | JUST_FREE non-zero means free the buffer, but don't restore the | ||
| 687 | cache; used when the corresponding iterator is discarded instead of | ||
| 688 | being restored. */ | ||
| 661 | void | 689 | void |
| 662 | bidi_unshelve_cache (void *databuf) | 690 | bidi_unshelve_cache (void *databuf, int just_free) |
| 663 | { | 691 | { |
| 664 | unsigned char *p = databuf; | 692 | unsigned char *p = databuf; |
| 665 | 693 | ||
| 666 | if (!p) | 694 | if (!p) |
| 667 | { | 695 | { |
| 668 | /* A NULL pointer means an empty cache. */ | 696 | if (!just_free) |
| 669 | bidi_cache_start = 0; | 697 | { |
| 670 | bidi_cache_sp = 0; | 698 | /* A NULL pointer means an empty cache. */ |
| 671 | bidi_cache_reset (); | 699 | bidi_cache_start = 0; |
| 700 | bidi_cache_sp = 0; | ||
| 701 | bidi_cache_reset (); | ||
| 702 | } | ||
| 672 | } | 703 | } |
| 673 | else | 704 | else |
| 674 | { | 705 | { |
| 675 | memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx)); | 706 | if (just_free) |
| 676 | bidi_cache_ensure_space (bidi_cache_idx); | 707 | { |
| 677 | memcpy (bidi_cache, p + sizeof (bidi_cache_idx), | 708 | ptrdiff_t idx; |
| 678 | bidi_cache_idx * sizeof (struct bidi_it)); | 709 | |
| 679 | memcpy (bidi_cache_start_stack, | 710 | memcpy (&idx, p, sizeof (bidi_cache_idx)); |
| 680 | p + sizeof (bidi_cache_idx) | 711 | bidi_cache_total_alloc -= |
| 681 | + bidi_cache_idx * sizeof (struct bidi_it), | 712 | bidi_shelve_header_size + idx * sizeof (struct bidi_it); |
| 682 | sizeof (bidi_cache_start_stack)); | 713 | } |
| 683 | memcpy (&bidi_cache_sp, | 714 | else |
| 684 | p + sizeof (bidi_cache_idx) | 715 | { |
| 685 | + bidi_cache_idx * sizeof (struct bidi_it) | 716 | memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx)); |
| 686 | + sizeof (bidi_cache_start_stack), | 717 | bidi_cache_ensure_space (bidi_cache_idx); |
| 687 | sizeof (bidi_cache_sp)); | 718 | memcpy (bidi_cache, p + sizeof (bidi_cache_idx), |
| 688 | memcpy (&bidi_cache_start, | 719 | bidi_cache_idx * sizeof (struct bidi_it)); |
| 689 | p + sizeof (bidi_cache_idx) | 720 | memcpy (bidi_cache_start_stack, |
| 690 | + bidi_cache_idx * sizeof (struct bidi_it) | 721 | p + sizeof (bidi_cache_idx) |
| 691 | + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp), | 722 | + bidi_cache_idx * sizeof (struct bidi_it), |
| 692 | sizeof (bidi_cache_start)); | 723 | sizeof (bidi_cache_start_stack)); |
| 693 | memcpy (&bidi_cache_last_idx, | 724 | memcpy (&bidi_cache_sp, |
| 694 | p + sizeof (bidi_cache_idx) | 725 | p + sizeof (bidi_cache_idx) |
| 695 | + bidi_cache_idx * sizeof (struct bidi_it) | 726 | + bidi_cache_idx * sizeof (struct bidi_it) |
| 696 | + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp) | 727 | + sizeof (bidi_cache_start_stack), |
| 697 | + sizeof (bidi_cache_start), | 728 | sizeof (bidi_cache_sp)); |
| 698 | sizeof (bidi_cache_last_idx)); | 729 | memcpy (&bidi_cache_start, |
| 730 | p + sizeof (bidi_cache_idx) | ||
| 731 | + bidi_cache_idx * sizeof (struct bidi_it) | ||
| 732 | + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp), | ||
| 733 | sizeof (bidi_cache_start)); | ||
| 734 | memcpy (&bidi_cache_last_idx, | ||
| 735 | p + sizeof (bidi_cache_idx) | ||
| 736 | + bidi_cache_idx * sizeof (struct bidi_it) | ||
| 737 | + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp) | ||
| 738 | + sizeof (bidi_cache_start), | ||
| 739 | sizeof (bidi_cache_last_idx)); | ||
| 740 | bidi_cache_total_alloc -= | ||
| 741 | bidi_shelve_header_size + bidi_cache_idx * sizeof (struct bidi_it); | ||
| 742 | } | ||
| 699 | 743 | ||
| 700 | xfree (p); | 744 | xfree (p); |
| 701 | } | 745 | } |
| @@ -708,26 +752,16 @@ bidi_unshelve_cache (void *databuf) | |||
| 708 | static void | 752 | static void |
| 709 | bidi_initialize (void) | 753 | bidi_initialize (void) |
| 710 | { | 754 | { |
| 711 | 755 | bidi_type_table = uniprop_table (intern ("bidi-class")); | |
| 712 | #include "biditype.h" | 756 | if (NILP (bidi_type_table)) |
| 713 | #include "bidimirror.h" | 757 | abort (); |
| 714 | |||
| 715 | int i; | ||
| 716 | |||
| 717 | bidi_type_table = Fmake_char_table (Qnil, make_number (STRONG_L)); | ||
| 718 | staticpro (&bidi_type_table); | 758 | staticpro (&bidi_type_table); |
| 719 | 759 | ||
| 720 | for (i = 0; i < sizeof bidi_type / sizeof bidi_type[0]; i++) | 760 | bidi_mirror_table = uniprop_table (intern ("mirroring")); |
| 721 | char_table_set_range (bidi_type_table, bidi_type[i].from, bidi_type[i].to, | 761 | if (NILP (bidi_mirror_table)) |
| 722 | make_number (bidi_type[i].type)); | 762 | abort (); |
| 723 | |||
| 724 | bidi_mirror_table = Fmake_char_table (Qnil, Qnil); | ||
| 725 | staticpro (&bidi_mirror_table); | 763 | staticpro (&bidi_mirror_table); |
| 726 | 764 | ||
| 727 | for (i = 0; i < sizeof bidi_mirror / sizeof bidi_mirror[0]; i++) | ||
| 728 | char_table_set (bidi_mirror_table, bidi_mirror[i].from, | ||
| 729 | make_number (bidi_mirror[i].to)); | ||
| 730 | |||
| 731 | Qparagraph_start = intern ("paragraph-start"); | 765 | Qparagraph_start = intern ("paragraph-start"); |
| 732 | staticpro (&Qparagraph_start); | 766 | staticpro (&Qparagraph_start); |
| 733 | paragraph_start_re = Fsymbol_value (Qparagraph_start); | 767 | paragraph_start_re = Fsymbol_value (Qparagraph_start); |
| @@ -742,6 +776,7 @@ bidi_initialize (void) | |||
| 742 | staticpro (¶graph_separate_re); | 776 | staticpro (¶graph_separate_re); |
| 743 | 777 | ||
| 744 | bidi_cache_sp = 0; | 778 | bidi_cache_sp = 0; |
| 779 | bidi_cache_total_alloc = 0; | ||
| 745 | 780 | ||
| 746 | bidi_initialized = 1; | 781 | bidi_initialized = 1; |
| 747 | } | 782 | } |
| @@ -792,6 +827,7 @@ bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, int frame_window_p, | |||
| 792 | bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; | 827 | bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; |
| 793 | bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ | 828 | bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ |
| 794 | bidi_it->disp_pos = -1; /* invalid/unknown */ | 829 | bidi_it->disp_pos = -1; /* invalid/unknown */ |
| 830 | bidi_it->disp_prop = 0; | ||
| 795 | /* We can only shrink the cache if we are at the bottom level of its | 831 | /* We can only shrink the cache if we are at the bottom level of its |
| 796 | "stack". */ | 832 | "stack". */ |
| 797 | if (bidi_cache_start == 0) | 833 | if (bidi_cache_start == 0) |
| @@ -871,17 +907,21 @@ bidi_char_at_pos (EMACS_INT bytepos, const unsigned char *s, int unibyte) | |||
| 871 | 907 | ||
| 872 | /* Fetch and return the character at BYTEPOS/CHARPOS. If that | 908 | /* Fetch and return the character at BYTEPOS/CHARPOS. If that |
| 873 | character is covered by a display string, treat the entire run of | 909 | character is covered by a display string, treat the entire run of |
| 874 | covered characters as a single character u+FFFC, and return their | 910 | covered characters as a single character, either u+2029 or u+FFFC, |
| 875 | combined length in CH_LEN and NCHARS. DISP_POS specifies the | 911 | and return their combined length in CH_LEN and NCHARS. DISP_POS |
| 876 | character position of the next display string, or -1 if not yet | 912 | specifies the character position of the next display string, or -1 |
| 877 | computed. When the next character is at or beyond that position, | 913 | if not yet computed. When the next character is at or beyond that |
| 878 | the function updates DISP_POS with the position of the next display | 914 | position, the function updates DISP_POS with the position of the |
| 879 | string. STRING->s is the C string to iterate, or NULL if iterating | 915 | next display string. DISP_PROP non-zero means that there's really |
| 880 | over a buffer or a Lisp string; in the latter case, STRING->lstring | 916 | a display string at DISP_POS, as opposed to when we searched till |
| 881 | is the Lisp string. */ | 917 | DISP_POS without finding one. If DISP_PROP is 2, it means the |
| 918 | display spec is of the form `(space ...)', which is replaced with | ||
| 919 | u+2029 to handle it as a paragraph separator. STRING->s is the C | ||
| 920 | string to iterate, or NULL if iterating over a buffer or a Lisp | ||
| 921 | string; in the latter case, STRING->lstring is the Lisp string. */ | ||
| 882 | static inline int | 922 | static inline int |
| 883 | bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | 923 | bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, |
| 884 | struct bidi_string_data *string, | 924 | int *disp_prop, struct bidi_string_data *string, |
| 885 | int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars) | 925 | int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars) |
| 886 | { | 926 | { |
| 887 | int ch; | 927 | int ch; |
| @@ -894,7 +934,8 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 894 | if (charpos < endpos && charpos > *disp_pos) | 934 | if (charpos < endpos && charpos > *disp_pos) |
| 895 | { | 935 | { |
| 896 | SET_TEXT_POS (pos, charpos, bytepos); | 936 | SET_TEXT_POS (pos, charpos, bytepos); |
| 897 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p); | 937 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p, |
| 938 | disp_prop); | ||
| 898 | } | 939 | } |
| 899 | 940 | ||
| 900 | /* Fetch the character at BYTEPOS. */ | 941 | /* Fetch the character at BYTEPOS. */ |
| @@ -904,8 +945,9 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 904 | *ch_len = 1; | 945 | *ch_len = 1; |
| 905 | *nchars = 1; | 946 | *nchars = 1; |
| 906 | *disp_pos = endpos; | 947 | *disp_pos = endpos; |
| 948 | *disp_prop = 0; | ||
| 907 | } | 949 | } |
| 908 | else if (charpos >= *disp_pos) | 950 | else if (charpos >= *disp_pos && *disp_prop) |
| 909 | { | 951 | { |
| 910 | EMACS_INT disp_end_pos; | 952 | EMACS_INT disp_end_pos; |
| 911 | 953 | ||
| @@ -913,9 +955,23 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 913 | property. Hopefully, it will never be needed. */ | 955 | property. Hopefully, it will never be needed. */ |
| 914 | if (charpos > *disp_pos) | 956 | if (charpos > *disp_pos) |
| 915 | abort (); | 957 | abort (); |
| 916 | /* Return the Unicode Object Replacement Character to represent | 958 | /* Text covered by `display' properties and overlays with |
| 917 | the entire run of characters covered by the display string. */ | 959 | display properties or display strings is handled as a single |
| 918 | ch = 0xFFFC; | 960 | character that represents the entire run of characters |
| 961 | covered by the display property. */ | ||
| 962 | if (*disp_prop == 2) | ||
| 963 | { | ||
| 964 | /* `(space ...)' display specs are handled as paragraph | ||
| 965 | separators for the purposes of the reordering; see UAX#9 | ||
| 966 | section 3 and clause HL1 in section 4.3 there. */ | ||
| 967 | ch = 0x2029; | ||
| 968 | } | ||
| 969 | else | ||
| 970 | { | ||
| 971 | /* All other display specs are handled as the Unicode Object | ||
| 972 | Replacement Character. */ | ||
| 973 | ch = 0xFFFC; | ||
| 974 | } | ||
| 919 | disp_end_pos = compute_display_string_end (*disp_pos, string); | 975 | disp_end_pos = compute_display_string_end (*disp_pos, string); |
| 920 | *nchars = disp_end_pos - *disp_pos; | 976 | *nchars = disp_end_pos - *disp_pos; |
| 921 | if (*nchars <= 0) | 977 | if (*nchars <= 0) |
| @@ -972,10 +1028,12 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 972 | 1028 | ||
| 973 | /* If we just entered a run of characters covered by a display | 1029 | /* If we just entered a run of characters covered by a display |
| 974 | string, compute the position of the next display string. */ | 1030 | string, compute the position of the next display string. */ |
| 975 | if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos) | 1031 | if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos |
| 1032 | && *disp_prop) | ||
| 976 | { | 1033 | { |
| 977 | SET_TEXT_POS (pos, charpos + *nchars, bytepos + *ch_len); | 1034 | SET_TEXT_POS (pos, charpos + *nchars, bytepos + *ch_len); |
| 978 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p); | 1035 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p, |
| 1036 | disp_prop); | ||
| 979 | } | 1037 | } |
| 980 | 1038 | ||
| 981 | return ch; | 1039 | return ch; |
| @@ -1083,6 +1141,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) | |||
| 1083 | int ch; | 1141 | int ch; |
| 1084 | EMACS_INT ch_len, nchars; | 1142 | EMACS_INT ch_len, nchars; |
| 1085 | EMACS_INT pos, disp_pos = -1; | 1143 | EMACS_INT pos, disp_pos = -1; |
| 1144 | int disp_prop = 0; | ||
| 1086 | bidi_type_t type; | 1145 | bidi_type_t type; |
| 1087 | const unsigned char *s; | 1146 | const unsigned char *s; |
| 1088 | 1147 | ||
| @@ -1130,15 +1189,12 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) | |||
| 1130 | bytepos = pstartbyte; | 1189 | bytepos = pstartbyte; |
| 1131 | if (!string_p) | 1190 | if (!string_p) |
| 1132 | pos = BYTE_TO_CHAR (bytepos); | 1191 | pos = BYTE_TO_CHAR (bytepos); |
| 1133 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, &bidi_it->string, | 1192 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, &disp_prop, |
| 1193 | &bidi_it->string, | ||
| 1134 | bidi_it->frame_window_p, &ch_len, &nchars); | 1194 | bidi_it->frame_window_p, &ch_len, &nchars); |
| 1135 | type = bidi_get_type (ch, NEUTRAL_DIR); | 1195 | type = bidi_get_type (ch, NEUTRAL_DIR); |
| 1136 | 1196 | ||
| 1137 | for (pos += nchars, bytepos += ch_len; | 1197 | for (pos += nchars, bytepos += ch_len; |
| 1138 | /* NOTE: UAX#9 says to search only for L, AL, or R types | ||
| 1139 | of characters, and ignore RLE, RLO, LRE, and LRO. | ||
| 1140 | However, I'm not sure it makes sense to omit those 4; | ||
| 1141 | should try with and without that to see the effect. */ | ||
| 1142 | (bidi_get_category (type) != STRONG) | 1198 | (bidi_get_category (type) != STRONG) |
| 1143 | || (bidi_ignore_explicit_marks_for_paragraph_level | 1199 | || (bidi_ignore_explicit_marks_for_paragraph_level |
| 1144 | && (type == RLE || type == RLO | 1200 | && (type == RLE || type == RLO |
| @@ -1157,14 +1213,19 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) | |||
| 1157 | && bidi_at_paragraph_end (pos, bytepos) >= -1) | 1213 | && bidi_at_paragraph_end (pos, bytepos) >= -1) |
| 1158 | break; | 1214 | break; |
| 1159 | /* Fetch next character and advance to get past it. */ | 1215 | /* Fetch next character and advance to get past it. */ |
| 1160 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, &bidi_it->string, | 1216 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, |
| 1217 | &disp_prop, &bidi_it->string, | ||
| 1161 | bidi_it->frame_window_p, &ch_len, &nchars); | 1218 | bidi_it->frame_window_p, &ch_len, &nchars); |
| 1162 | pos += nchars; | 1219 | pos += nchars; |
| 1163 | bytepos += ch_len; | 1220 | bytepos += ch_len; |
| 1164 | } | 1221 | } |
| 1165 | if (type == STRONG_R || type == STRONG_AL) /* P3 */ | 1222 | if ((type == STRONG_R || type == STRONG_AL) /* P3 */ |
| 1223 | || (!bidi_ignore_explicit_marks_for_paragraph_level | ||
| 1224 | && (type == RLO || type == RLE))) | ||
| 1166 | bidi_it->paragraph_dir = R2L; | 1225 | bidi_it->paragraph_dir = R2L; |
| 1167 | else if (type == STRONG_L) | 1226 | else if (type == STRONG_L |
| 1227 | || (!bidi_ignore_explicit_marks_for_paragraph_level | ||
| 1228 | && (type == LRO || type == LRE))) | ||
| 1168 | bidi_it->paragraph_dir = L2R; | 1229 | bidi_it->paragraph_dir = L2R; |
| 1169 | if (!string_p | 1230 | if (!string_p |
| 1170 | && no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR) | 1231 | && no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR) |
| @@ -1290,6 +1351,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) | |||
| 1290 | bidi_it->ch_len = 1; | 1351 | bidi_it->ch_len = 1; |
| 1291 | bidi_it->nchars = 1; | 1352 | bidi_it->nchars = 1; |
| 1292 | bidi_it->disp_pos = (string_p ? bidi_it->string.schars : ZV); | 1353 | bidi_it->disp_pos = (string_p ? bidi_it->string.schars : ZV); |
| 1354 | bidi_it->disp_prop = 0; | ||
| 1293 | } | 1355 | } |
| 1294 | else | 1356 | else |
| 1295 | { | 1357 | { |
| @@ -1297,8 +1359,8 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) | |||
| 1297 | display string, treat the entire run of covered characters as | 1359 | display string, treat the entire run of covered characters as |
| 1298 | a single character u+FFFC. */ | 1360 | a single character u+FFFC. */ |
| 1299 | curchar = bidi_fetch_char (bidi_it->bytepos, bidi_it->charpos, | 1361 | curchar = bidi_fetch_char (bidi_it->bytepos, bidi_it->charpos, |
| 1300 | &bidi_it->disp_pos, &bidi_it->string, | 1362 | &bidi_it->disp_pos, &bidi_it->disp_prop, |
| 1301 | bidi_it->frame_window_p, | 1363 | &bidi_it->string, bidi_it->frame_window_p, |
| 1302 | &bidi_it->ch_len, &bidi_it->nchars); | 1364 | &bidi_it->ch_len, &bidi_it->nchars); |
| 1303 | } | 1365 | } |
| 1304 | bidi_it->ch = curchar; | 1366 | bidi_it->ch = curchar; |
| @@ -2032,12 +2094,13 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) | |||
| 2032 | struct bidi_string_data bs = bidi_it->string; | 2094 | struct bidi_string_data bs = bidi_it->string; |
| 2033 | bidi_type_t chtype; | 2095 | bidi_type_t chtype; |
| 2034 | int fwp = bidi_it->frame_window_p; | 2096 | int fwp = bidi_it->frame_window_p; |
| 2097 | int dpp = bidi_it->disp_prop; | ||
| 2035 | 2098 | ||
| 2036 | if (bidi_it->nchars <= 0) | 2099 | if (bidi_it->nchars <= 0) |
| 2037 | abort (); | 2100 | abort (); |
| 2038 | do { | 2101 | do { |
| 2039 | ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &bs, fwp, | 2102 | ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs, |
| 2040 | &clen, &nc); | 2103 | fwp, &clen, &nc); |
| 2041 | if (ch == '\n' || ch == BIDI_EOB /* || ch == LINESEP_CHAR */) | 2104 | if (ch == '\n' || ch == BIDI_EOB /* || ch == LINESEP_CHAR */) |
| 2042 | chtype = NEUTRAL_B; | 2105 | chtype = NEUTRAL_B; |
| 2043 | else | 2106 | else |
diff --git a/src/bidimirror.h b/src/bidimirror.h deleted file mode 100644 index 477f983ad64..00000000000 --- a/src/bidimirror.h +++ /dev/null | |||
| @@ -1,365 +0,0 @@ | |||
| 1 | struct { | ||
| 2 | int from, to; | ||
| 3 | } bidi_mirror[] = { | ||
| 4 | { 0x0028, 0x0029 }, | ||
| 5 | { 0x0029, 0x0028 }, | ||
| 6 | { 0x003C, 0x003E }, | ||
| 7 | { 0x003E, 0x003C }, | ||
| 8 | { 0x005B, 0x005D }, | ||
| 9 | { 0x005D, 0x005B }, | ||
| 10 | { 0x007B, 0x007D }, | ||
| 11 | { 0x007D, 0x007B }, | ||
| 12 | { 0x00AB, 0x00BB }, | ||
| 13 | { 0x00BB, 0x00AB }, | ||
| 14 | { 0x0F3A, 0x0F3B }, | ||
| 15 | { 0x0F3B, 0x0F3A }, | ||
| 16 | { 0x0F3C, 0x0F3D }, | ||
| 17 | { 0x0F3D, 0x0F3C }, | ||
| 18 | { 0x169B, 0x169C }, | ||
| 19 | { 0x169C, 0x169B }, | ||
| 20 | { 0x2039, 0x203A }, | ||
| 21 | { 0x203A, 0x2039 }, | ||
| 22 | { 0x2045, 0x2046 }, | ||
| 23 | { 0x2046, 0x2045 }, | ||
| 24 | { 0x207D, 0x207E }, | ||
| 25 | { 0x207E, 0x207D }, | ||
| 26 | { 0x208D, 0x208E }, | ||
| 27 | { 0x208E, 0x208D }, | ||
| 28 | { 0x2208, 0x220B }, | ||
| 29 | { 0x2209, 0x220C }, | ||
| 30 | { 0x220A, 0x220D }, | ||
| 31 | { 0x220B, 0x2208 }, | ||
| 32 | { 0x220C, 0x2209 }, | ||
| 33 | { 0x220D, 0x220A }, | ||
| 34 | { 0x2215, 0x29F5 }, | ||
| 35 | { 0x223C, 0x223D }, | ||
| 36 | { 0x223D, 0x223C }, | ||
| 37 | { 0x2243, 0x22CD }, | ||
| 38 | { 0x2252, 0x2253 }, | ||
| 39 | { 0x2253, 0x2252 }, | ||
| 40 | { 0x2254, 0x2255 }, | ||
| 41 | { 0x2255, 0x2254 }, | ||
| 42 | { 0x2264, 0x2265 }, | ||
| 43 | { 0x2265, 0x2264 }, | ||
| 44 | { 0x2266, 0x2267 }, | ||
| 45 | { 0x2267, 0x2266 }, | ||
| 46 | { 0x2268, 0x2269 }, | ||
| 47 | { 0x2269, 0x2268 }, | ||
| 48 | { 0x226A, 0x226B }, | ||
| 49 | { 0x226B, 0x226A }, | ||
| 50 | { 0x226E, 0x226F }, | ||
| 51 | { 0x226F, 0x226E }, | ||
| 52 | { 0x2270, 0x2271 }, | ||
| 53 | { 0x2271, 0x2270 }, | ||
| 54 | { 0x2272, 0x2273 }, | ||
| 55 | { 0x2273, 0x2272 }, | ||
| 56 | { 0x2274, 0x2275 }, | ||
| 57 | { 0x2275, 0x2274 }, | ||
| 58 | { 0x2276, 0x2277 }, | ||
| 59 | { 0x2277, 0x2276 }, | ||
| 60 | { 0x2278, 0x2279 }, | ||
| 61 | { 0x2279, 0x2278 }, | ||
| 62 | { 0x227A, 0x227B }, | ||
| 63 | { 0x227B, 0x227A }, | ||
| 64 | { 0x227C, 0x227D }, | ||
| 65 | { 0x227D, 0x227C }, | ||
| 66 | { 0x227E, 0x227F }, | ||
| 67 | { 0x227F, 0x227E }, | ||
| 68 | { 0x2280, 0x2281 }, | ||
| 69 | { 0x2281, 0x2280 }, | ||
| 70 | { 0x2282, 0x2283 }, | ||
| 71 | { 0x2283, 0x2282 }, | ||
| 72 | { 0x2284, 0x2285 }, | ||
| 73 | { 0x2285, 0x2284 }, | ||
| 74 | { 0x2286, 0x2287 }, | ||
| 75 | { 0x2287, 0x2286 }, | ||
| 76 | { 0x2288, 0x2289 }, | ||
| 77 | { 0x2289, 0x2288 }, | ||
| 78 | { 0x228A, 0x228B }, | ||
| 79 | { 0x228B, 0x228A }, | ||
| 80 | { 0x228F, 0x2290 }, | ||
| 81 | { 0x2290, 0x228F }, | ||
| 82 | { 0x2291, 0x2292 }, | ||
| 83 | { 0x2292, 0x2291 }, | ||
| 84 | { 0x2298, 0x29B8 }, | ||
| 85 | { 0x22A2, 0x22A3 }, | ||
| 86 | { 0x22A3, 0x22A2 }, | ||
| 87 | { 0x22A6, 0x2ADE }, | ||
| 88 | { 0x22A8, 0x2AE4 }, | ||
| 89 | { 0x22A9, 0x2AE3 }, | ||
| 90 | { 0x22AB, 0x2AE5 }, | ||
| 91 | { 0x22B0, 0x22B1 }, | ||
| 92 | { 0x22B1, 0x22B0 }, | ||
| 93 | { 0x22B2, 0x22B3 }, | ||
| 94 | { 0x22B3, 0x22B2 }, | ||
| 95 | { 0x22B4, 0x22B5 }, | ||
| 96 | { 0x22B5, 0x22B4 }, | ||
| 97 | { 0x22B6, 0x22B7 }, | ||
| 98 | { 0x22B7, 0x22B6 }, | ||
| 99 | { 0x22C9, 0x22CA }, | ||
| 100 | { 0x22CA, 0x22C9 }, | ||
| 101 | { 0x22CB, 0x22CC }, | ||
| 102 | { 0x22CC, 0x22CB }, | ||
| 103 | { 0x22CD, 0x2243 }, | ||
| 104 | { 0x22D0, 0x22D1 }, | ||
| 105 | { 0x22D1, 0x22D0 }, | ||
| 106 | { 0x22D6, 0x22D7 }, | ||
| 107 | { 0x22D7, 0x22D6 }, | ||
| 108 | { 0x22D8, 0x22D9 }, | ||
| 109 | { 0x22D9, 0x22D8 }, | ||
| 110 | { 0x22DA, 0x22DB }, | ||
| 111 | { 0x22DB, 0x22DA }, | ||
| 112 | { 0x22DC, 0x22DD }, | ||
| 113 | { 0x22DD, 0x22DC }, | ||
| 114 | { 0x22DE, 0x22DF }, | ||
| 115 | { 0x22DF, 0x22DE }, | ||
| 116 | { 0x22E0, 0x22E1 }, | ||
| 117 | { 0x22E1, 0x22E0 }, | ||
| 118 | { 0x22E2, 0x22E3 }, | ||
| 119 | { 0x22E3, 0x22E2 }, | ||
| 120 | { 0x22E4, 0x22E5 }, | ||
| 121 | { 0x22E5, 0x22E4 }, | ||
| 122 | { 0x22E6, 0x22E7 }, | ||
| 123 | { 0x22E7, 0x22E6 }, | ||
| 124 | { 0x22E8, 0x22E9 }, | ||
| 125 | { 0x22E9, 0x22E8 }, | ||
| 126 | { 0x22EA, 0x22EB }, | ||
| 127 | { 0x22EB, 0x22EA }, | ||
| 128 | { 0x22EC, 0x22ED }, | ||
| 129 | { 0x22ED, 0x22EC }, | ||
| 130 | { 0x22F0, 0x22F1 }, | ||
| 131 | { 0x22F1, 0x22F0 }, | ||
| 132 | { 0x22F2, 0x22FA }, | ||
| 133 | { 0x22F3, 0x22FB }, | ||
| 134 | { 0x22F4, 0x22FC }, | ||
| 135 | { 0x22F6, 0x22FD }, | ||
| 136 | { 0x22F7, 0x22FE }, | ||
| 137 | { 0x22FA, 0x22F2 }, | ||
| 138 | { 0x22FB, 0x22F3 }, | ||
| 139 | { 0x22FC, 0x22F4 }, | ||
| 140 | { 0x22FD, 0x22F6 }, | ||
| 141 | { 0x22FE, 0x22F7 }, | ||
| 142 | { 0x2308, 0x2309 }, | ||
| 143 | { 0x2309, 0x2308 }, | ||
| 144 | { 0x230A, 0x230B }, | ||
| 145 | { 0x230B, 0x230A }, | ||
| 146 | { 0x2329, 0x232A }, | ||
| 147 | { 0x232A, 0x2329 }, | ||
| 148 | { 0x2768, 0x2769 }, | ||
| 149 | { 0x2769, 0x2768 }, | ||
| 150 | { 0x276A, 0x276B }, | ||
| 151 | { 0x276B, 0x276A }, | ||
| 152 | { 0x276C, 0x276D }, | ||
| 153 | { 0x276D, 0x276C }, | ||
| 154 | { 0x276E, 0x276F }, | ||
| 155 | { 0x276F, 0x276E }, | ||
| 156 | { 0x2770, 0x2771 }, | ||
| 157 | { 0x2771, 0x2770 }, | ||
| 158 | { 0x2772, 0x2773 }, | ||
| 159 | { 0x2773, 0x2772 }, | ||
| 160 | { 0x2774, 0x2775 }, | ||
| 161 | { 0x2775, 0x2774 }, | ||
| 162 | { 0x27C3, 0x27C4 }, | ||
| 163 | { 0x27C4, 0x27C3 }, | ||
| 164 | { 0x27C5, 0x27C6 }, | ||
| 165 | { 0x27C6, 0x27C5 }, | ||
| 166 | { 0x27C8, 0x27C9 }, | ||
| 167 | { 0x27C9, 0x27C8 }, | ||
| 168 | { 0x27D5, 0x27D6 }, | ||
| 169 | { 0x27D6, 0x27D5 }, | ||
| 170 | { 0x27DD, 0x27DE }, | ||
| 171 | { 0x27DE, 0x27DD }, | ||
| 172 | { 0x27E2, 0x27E3 }, | ||
| 173 | { 0x27E3, 0x27E2 }, | ||
| 174 | { 0x27E4, 0x27E5 }, | ||
| 175 | { 0x27E5, 0x27E4 }, | ||
| 176 | { 0x27E6, 0x27E7 }, | ||
| 177 | { 0x27E7, 0x27E6 }, | ||
| 178 | { 0x27E8, 0x27E9 }, | ||
| 179 | { 0x27E9, 0x27E8 }, | ||
| 180 | { 0x27EA, 0x27EB }, | ||
| 181 | { 0x27EB, 0x27EA }, | ||
| 182 | { 0x27EC, 0x27ED }, | ||
| 183 | { 0x27ED, 0x27EC }, | ||
| 184 | { 0x27EE, 0x27EF }, | ||
| 185 | { 0x27EF, 0x27EE }, | ||
| 186 | { 0x2983, 0x2984 }, | ||
| 187 | { 0x2984, 0x2983 }, | ||
| 188 | { 0x2985, 0x2986 }, | ||
| 189 | { 0x2986, 0x2985 }, | ||
| 190 | { 0x2987, 0x2988 }, | ||
| 191 | { 0x2988, 0x2987 }, | ||
| 192 | { 0x2989, 0x298A }, | ||
| 193 | { 0x298A, 0x2989 }, | ||
| 194 | { 0x298B, 0x298C }, | ||
| 195 | { 0x298C, 0x298B }, | ||
| 196 | { 0x298D, 0x2990 }, | ||
| 197 | { 0x298E, 0x298F }, | ||
| 198 | { 0x298F, 0x298E }, | ||
| 199 | { 0x2990, 0x298D }, | ||
| 200 | { 0x2991, 0x2992 }, | ||
| 201 | { 0x2992, 0x2991 }, | ||
| 202 | { 0x2993, 0x2994 }, | ||
| 203 | { 0x2994, 0x2993 }, | ||
| 204 | { 0x2995, 0x2996 }, | ||
| 205 | { 0x2996, 0x2995 }, | ||
| 206 | { 0x2997, 0x2998 }, | ||
| 207 | { 0x2998, 0x2997 }, | ||
| 208 | { 0x29B8, 0x2298 }, | ||
| 209 | { 0x29C0, 0x29C1 }, | ||
| 210 | { 0x29C1, 0x29C0 }, | ||
| 211 | { 0x29C4, 0x29C5 }, | ||
| 212 | { 0x29C5, 0x29C4 }, | ||
| 213 | { 0x29CF, 0x29D0 }, | ||
| 214 | { 0x29D0, 0x29CF }, | ||
| 215 | { 0x29D1, 0x29D2 }, | ||
| 216 | { 0x29D2, 0x29D1 }, | ||
| 217 | { 0x29D4, 0x29D5 }, | ||
| 218 | { 0x29D5, 0x29D4 }, | ||
| 219 | { 0x29D8, 0x29D9 }, | ||
| 220 | { 0x29D9, 0x29D8 }, | ||
| 221 | { 0x29DA, 0x29DB }, | ||
| 222 | { 0x29DB, 0x29DA }, | ||
| 223 | { 0x29F5, 0x2215 }, | ||
| 224 | { 0x29F8, 0x29F9 }, | ||
| 225 | { 0x29F9, 0x29F8 }, | ||
| 226 | { 0x29FC, 0x29FD }, | ||
| 227 | { 0x29FD, 0x29FC }, | ||
| 228 | { 0x2A2B, 0x2A2C }, | ||
| 229 | { 0x2A2C, 0x2A2B }, | ||
| 230 | { 0x2A2D, 0x2A2E }, | ||
| 231 | { 0x2A2E, 0x2A2D }, | ||
| 232 | { 0x2A34, 0x2A35 }, | ||
| 233 | { 0x2A35, 0x2A34 }, | ||
| 234 | { 0x2A3C, 0x2A3D }, | ||
| 235 | { 0x2A3D, 0x2A3C }, | ||
| 236 | { 0x2A64, 0x2A65 }, | ||
| 237 | { 0x2A65, 0x2A64 }, | ||
| 238 | { 0x2A79, 0x2A7A }, | ||
| 239 | { 0x2A7A, 0x2A79 }, | ||
| 240 | { 0x2A7D, 0x2A7E }, | ||
| 241 | { 0x2A7E, 0x2A7D }, | ||
| 242 | { 0x2A7F, 0x2A80 }, | ||
| 243 | { 0x2A80, 0x2A7F }, | ||
| 244 | { 0x2A81, 0x2A82 }, | ||
| 245 | { 0x2A82, 0x2A81 }, | ||
| 246 | { 0x2A83, 0x2A84 }, | ||
| 247 | { 0x2A84, 0x2A83 }, | ||
| 248 | { 0x2A8B, 0x2A8C }, | ||
| 249 | { 0x2A8C, 0x2A8B }, | ||
| 250 | { 0x2A91, 0x2A92 }, | ||
| 251 | { 0x2A92, 0x2A91 }, | ||
| 252 | { 0x2A93, 0x2A94 }, | ||
| 253 | { 0x2A94, 0x2A93 }, | ||
| 254 | { 0x2A95, 0x2A96 }, | ||
| 255 | { 0x2A96, 0x2A95 }, | ||
| 256 | { 0x2A97, 0x2A98 }, | ||
| 257 | { 0x2A98, 0x2A97 }, | ||
| 258 | { 0x2A99, 0x2A9A }, | ||
| 259 | { 0x2A9A, 0x2A99 }, | ||
| 260 | { 0x2A9B, 0x2A9C }, | ||
| 261 | { 0x2A9C, 0x2A9B }, | ||
| 262 | { 0x2AA1, 0x2AA2 }, | ||
| 263 | { 0x2AA2, 0x2AA1 }, | ||
| 264 | { 0x2AA6, 0x2AA7 }, | ||
| 265 | { 0x2AA7, 0x2AA6 }, | ||
| 266 | { 0x2AA8, 0x2AA9 }, | ||
| 267 | { 0x2AA9, 0x2AA8 }, | ||
| 268 | { 0x2AAA, 0x2AAB }, | ||
| 269 | { 0x2AAB, 0x2AAA }, | ||
| 270 | { 0x2AAC, 0x2AAD }, | ||
| 271 | { 0x2AAD, 0x2AAC }, | ||
| 272 | { 0x2AAF, 0x2AB0 }, | ||
| 273 | { 0x2AB0, 0x2AAF }, | ||
| 274 | { 0x2AB3, 0x2AB4 }, | ||
| 275 | { 0x2AB4, 0x2AB3 }, | ||
| 276 | { 0x2ABB, 0x2ABC }, | ||
| 277 | { 0x2ABC, 0x2ABB }, | ||
| 278 | { 0x2ABD, 0x2ABE }, | ||
| 279 | { 0x2ABE, 0x2ABD }, | ||
| 280 | { 0x2ABF, 0x2AC0 }, | ||
| 281 | { 0x2AC0, 0x2ABF }, | ||
| 282 | { 0x2AC1, 0x2AC2 }, | ||
| 283 | { 0x2AC2, 0x2AC1 }, | ||
| 284 | { 0x2AC3, 0x2AC4 }, | ||
| 285 | { 0x2AC4, 0x2AC3 }, | ||
| 286 | { 0x2AC5, 0x2AC6 }, | ||
| 287 | { 0x2AC6, 0x2AC5 }, | ||
| 288 | { 0x2ACD, 0x2ACE }, | ||
| 289 | { 0x2ACE, 0x2ACD }, | ||
| 290 | { 0x2ACF, 0x2AD0 }, | ||
| 291 | { 0x2AD0, 0x2ACF }, | ||
| 292 | { 0x2AD1, 0x2AD2 }, | ||
| 293 | { 0x2AD2, 0x2AD1 }, | ||
| 294 | { 0x2AD3, 0x2AD4 }, | ||
| 295 | { 0x2AD4, 0x2AD3 }, | ||
| 296 | { 0x2AD5, 0x2AD6 }, | ||
| 297 | { 0x2AD6, 0x2AD5 }, | ||
| 298 | { 0x2ADE, 0x22A6 }, | ||
| 299 | { 0x2AE3, 0x22A9 }, | ||
| 300 | { 0x2AE4, 0x22A8 }, | ||
| 301 | { 0x2AE5, 0x22AB }, | ||
| 302 | { 0x2AEC, 0x2AED }, | ||
| 303 | { 0x2AED, 0x2AEC }, | ||
| 304 | { 0x2AF7, 0x2AF8 }, | ||
| 305 | { 0x2AF8, 0x2AF7 }, | ||
| 306 | { 0x2AF9, 0x2AFA }, | ||
| 307 | { 0x2AFA, 0x2AF9 }, | ||
| 308 | { 0x2E02, 0x2E03 }, | ||
| 309 | { 0x2E03, 0x2E02 }, | ||
| 310 | { 0x2E04, 0x2E05 }, | ||
| 311 | { 0x2E05, 0x2E04 }, | ||
| 312 | { 0x2E09, 0x2E0A }, | ||
| 313 | { 0x2E0A, 0x2E09 }, | ||
| 314 | { 0x2E0C, 0x2E0D }, | ||
| 315 | { 0x2E0D, 0x2E0C }, | ||
| 316 | { 0x2E1C, 0x2E1D }, | ||
| 317 | { 0x2E1D, 0x2E1C }, | ||
| 318 | { 0x2E20, 0x2E21 }, | ||
| 319 | { 0x2E21, 0x2E20 }, | ||
| 320 | { 0x2E22, 0x2E23 }, | ||
| 321 | { 0x2E23, 0x2E22 }, | ||
| 322 | { 0x2E24, 0x2E25 }, | ||
| 323 | { 0x2E25, 0x2E24 }, | ||
| 324 | { 0x2E26, 0x2E27 }, | ||
| 325 | { 0x2E27, 0x2E26 }, | ||
| 326 | { 0x2E28, 0x2E29 }, | ||
| 327 | { 0x2E29, 0x2E28 }, | ||
| 328 | { 0x3008, 0x3009 }, | ||
| 329 | { 0x3009, 0x3008 }, | ||
| 330 | { 0x300A, 0x300B }, | ||
| 331 | { 0x300B, 0x300A }, | ||
| 332 | { 0x300C, 0x300D }, | ||
| 333 | { 0x300D, 0x300C }, | ||
| 334 | { 0x300E, 0x300F }, | ||
| 335 | { 0x300F, 0x300E }, | ||
| 336 | { 0x3010, 0x3011 }, | ||
| 337 | { 0x3011, 0x3010 }, | ||
| 338 | { 0x3014, 0x3015 }, | ||
| 339 | { 0x3015, 0x3014 }, | ||
| 340 | { 0x3016, 0x3017 }, | ||
| 341 | { 0x3017, 0x3016 }, | ||
| 342 | { 0x3018, 0x3019 }, | ||
| 343 | { 0x3019, 0x3018 }, | ||
| 344 | { 0x301A, 0x301B }, | ||
| 345 | { 0x301B, 0x301A }, | ||
| 346 | { 0xFE59, 0xFE5A }, | ||
| 347 | { 0xFE5A, 0xFE59 }, | ||
| 348 | { 0xFE5B, 0xFE5C }, | ||
| 349 | { 0xFE5C, 0xFE5B }, | ||
| 350 | { 0xFE5D, 0xFE5E }, | ||
| 351 | { 0xFE5E, 0xFE5D }, | ||
| 352 | { 0xFE64, 0xFE65 }, | ||
| 353 | { 0xFE65, 0xFE64 }, | ||
| 354 | { 0xFF08, 0xFF09 }, | ||
| 355 | { 0xFF09, 0xFF08 }, | ||
| 356 | { 0xFF1C, 0xFF1E }, | ||
| 357 | { 0xFF1E, 0xFF1C }, | ||
| 358 | { 0xFF3B, 0xFF3D }, | ||
| 359 | { 0xFF3D, 0xFF3B }, | ||
| 360 | { 0xFF5B, 0xFF5D }, | ||
| 361 | { 0xFF5D, 0xFF5B }, | ||
| 362 | { 0xFF5F, 0xFF60 }, | ||
| 363 | { 0xFF60, 0xFF5F }, | ||
| 364 | { 0xFF62, 0xFF63 }, | ||
| 365 | { 0xFF63, 0xFF62 } }; | ||
diff --git a/src/biditype.h b/src/biditype.h deleted file mode 100644 index 868aabd9ea6..00000000000 --- a/src/biditype.h +++ /dev/null | |||
| @@ -1,447 +0,0 @@ | |||
| 1 | struct { | ||
| 2 | int from, to; | ||
| 3 | bidi_type_t type; | ||
| 4 | } bidi_type[] = { | ||
| 5 | { 0x0000, 0x0008, WEAK_BN }, | ||
| 6 | { 0x0009, 0x0009, NEUTRAL_S }, | ||
| 7 | { 0x000A, 0x000A, NEUTRAL_B }, | ||
| 8 | { 0x000B, 0x000B, NEUTRAL_S }, | ||
| 9 | { 0x000C, 0x000C, NEUTRAL_WS }, | ||
| 10 | { 0x000D, 0x000D, NEUTRAL_B }, | ||
| 11 | { 0x000E, 0x001B, WEAK_BN }, | ||
| 12 | { 0x001C, 0x001E, NEUTRAL_B }, | ||
| 13 | { 0x001F, 0x001F, NEUTRAL_S }, | ||
| 14 | { 0x0020, 0x0020, NEUTRAL_WS }, | ||
| 15 | { 0x0021, 0x0022, NEUTRAL_ON }, | ||
| 16 | { 0x0023, 0x0025, WEAK_ET }, | ||
| 17 | { 0x0026, 0x002A, NEUTRAL_ON }, | ||
| 18 | { 0x002B, 0x002B, WEAK_ES }, | ||
| 19 | { 0x002C, 0x002C, WEAK_CS }, | ||
| 20 | { 0x002D, 0x002D, WEAK_ES }, | ||
| 21 | { 0x002E, 0x002F, WEAK_CS }, | ||
| 22 | { 0x0030, 0x0039, WEAK_EN }, | ||
| 23 | { 0x003A, 0x003A, WEAK_CS }, | ||
| 24 | { 0x003B, 0x0040, NEUTRAL_ON }, | ||
| 25 | { 0x005B, 0x0060, NEUTRAL_ON }, | ||
| 26 | { 0x007B, 0x007E, NEUTRAL_ON }, | ||
| 27 | { 0x007F, 0x0084, WEAK_BN }, | ||
| 28 | { 0x0085, 0x0085, NEUTRAL_B }, | ||
| 29 | { 0x0086, 0x009F, WEAK_BN }, | ||
| 30 | { 0x00A0, 0x00A0, WEAK_CS }, | ||
| 31 | { 0x00A1, 0x00A1, NEUTRAL_ON }, | ||
| 32 | { 0x00A2, 0x00A5, WEAK_ET }, | ||
| 33 | { 0x00A6, 0x00A9, NEUTRAL_ON }, | ||
| 34 | { 0x00AB, 0x00AC, NEUTRAL_ON }, | ||
| 35 | { 0x00AD, 0x00AD, WEAK_BN }, | ||
| 36 | { 0x00AE, 0x00AF, NEUTRAL_ON }, | ||
| 37 | { 0x00B0, 0x00B1, WEAK_ET }, | ||
| 38 | { 0x00B2, 0x00B3, WEAK_EN }, | ||
| 39 | { 0x00B4, 0x00B4, NEUTRAL_ON }, | ||
| 40 | { 0x00B6, 0x00B8, NEUTRAL_ON }, | ||
| 41 | { 0x00B9, 0x00B9, WEAK_EN }, | ||
| 42 | { 0x00BB, 0x00BF, NEUTRAL_ON }, | ||
| 43 | { 0x00D7, 0x00D7, NEUTRAL_ON }, | ||
| 44 | { 0x00F7, 0x00F7, NEUTRAL_ON }, | ||
| 45 | { 0x02B9, 0x02BA, NEUTRAL_ON }, | ||
| 46 | { 0x02C2, 0x02CF, NEUTRAL_ON }, | ||
| 47 | { 0x02D2, 0x02DF, NEUTRAL_ON }, | ||
| 48 | { 0x02E5, 0x02ED, NEUTRAL_ON }, | ||
| 49 | { 0x02EF, 0x02FF, NEUTRAL_ON }, | ||
| 50 | { 0x0300, 0x036F, WEAK_NSM }, | ||
| 51 | { 0x0374, 0x0375, NEUTRAL_ON }, | ||
| 52 | { 0x037E, 0x0385, NEUTRAL_ON }, | ||
| 53 | { 0x0387, 0x0387, NEUTRAL_ON }, | ||
| 54 | { 0x03F6, 0x03F6, NEUTRAL_ON }, | ||
| 55 | { 0x0483, 0x0489, WEAK_NSM }, | ||
| 56 | { 0x058A, 0x058A, NEUTRAL_ON }, | ||
| 57 | { 0x0591, 0x05BD, WEAK_NSM }, | ||
| 58 | { 0x05BE, 0x05BE, STRONG_R }, | ||
| 59 | { 0x05BF, 0x05BF, WEAK_NSM }, | ||
| 60 | { 0x05C0, 0x05C0, STRONG_R }, | ||
| 61 | { 0x05C1, 0x05C2, WEAK_NSM }, | ||
| 62 | { 0x05C3, 0x05C3, STRONG_R }, | ||
| 63 | { 0x05C4, 0x05C5, WEAK_NSM }, | ||
| 64 | { 0x05C6, 0x05C6, STRONG_R }, | ||
| 65 | { 0x05C7, 0x05C7, WEAK_NSM }, | ||
| 66 | { 0x05D0, 0x05F4, STRONG_R }, | ||
| 67 | { 0x0600, 0x0603, WEAK_AN }, | ||
| 68 | { 0x0606, 0x0607, NEUTRAL_ON }, | ||
| 69 | { 0x0608, 0x0608, STRONG_AL }, | ||
| 70 | { 0x0609, 0x060A, WEAK_ET }, | ||
| 71 | { 0x060B, 0x060B, STRONG_AL }, | ||
| 72 | { 0x060C, 0x060C, WEAK_CS }, | ||
| 73 | { 0x060D, 0x060D, STRONG_AL }, | ||
| 74 | { 0x060E, 0x060F, NEUTRAL_ON }, | ||
| 75 | { 0x0610, 0x061A, WEAK_NSM }, | ||
| 76 | { 0x061B, 0x064A, STRONG_AL }, | ||
| 77 | { 0x064B, 0x065F, WEAK_NSM }, | ||
| 78 | { 0x0660, 0x0669, WEAK_AN }, | ||
| 79 | { 0x066A, 0x066A, WEAK_ET }, | ||
| 80 | { 0x066B, 0x066C, WEAK_AN }, | ||
| 81 | { 0x066D, 0x066F, STRONG_AL }, | ||
| 82 | { 0x0670, 0x0670, WEAK_NSM }, | ||
| 83 | { 0x0671, 0x06D5, STRONG_AL }, | ||
| 84 | { 0x06D6, 0x06DC, WEAK_NSM }, | ||
| 85 | { 0x06DD, 0x06DD, WEAK_AN }, | ||
| 86 | { 0x06DE, 0x06DE, NEUTRAL_ON }, | ||
| 87 | { 0x06DF, 0x06E4, WEAK_NSM }, | ||
| 88 | { 0x06E5, 0x06E6, STRONG_AL }, | ||
| 89 | { 0x06E7, 0x06E8, WEAK_NSM }, | ||
| 90 | { 0x06E9, 0x06E9, NEUTRAL_ON }, | ||
| 91 | { 0x06EA, 0x06ED, WEAK_NSM }, | ||
| 92 | { 0x06EE, 0x06EF, STRONG_AL }, | ||
| 93 | { 0x06F0, 0x06F9, WEAK_EN }, | ||
| 94 | { 0x06FA, 0x070D, STRONG_AL }, | ||
| 95 | { 0x070F, 0x070F, WEAK_AN }, | ||
| 96 | { 0x0710, 0x0710, STRONG_AL }, | ||
| 97 | { 0x0711, 0x0711, WEAK_NSM }, | ||
| 98 | { 0x0712, 0x072F, STRONG_AL }, | ||
| 99 | { 0x0730, 0x074A, WEAK_NSM }, | ||
| 100 | { 0x074D, 0x07A5, STRONG_AL }, | ||
| 101 | { 0x07A6, 0x07B0, WEAK_NSM }, | ||
| 102 | { 0x07B1, 0x07B1, STRONG_AL }, | ||
| 103 | { 0x07C0, 0x07EA, STRONG_R }, | ||
| 104 | { 0x07EB, 0x07F3, WEAK_NSM }, | ||
| 105 | { 0x07F4, 0x07F5, STRONG_R }, | ||
| 106 | { 0x07F6, 0x07F9, NEUTRAL_ON }, | ||
| 107 | { 0x07FA, 0x0815, STRONG_R }, | ||
| 108 | { 0x0816, 0x0819, WEAK_NSM }, | ||
| 109 | { 0x081A, 0x081A, STRONG_R }, | ||
| 110 | { 0x081B, 0x0823, WEAK_NSM }, | ||
| 111 | { 0x0824, 0x0824, STRONG_R }, | ||
| 112 | { 0x0825, 0x0827, WEAK_NSM }, | ||
| 113 | { 0x0828, 0x0828, STRONG_R }, | ||
| 114 | { 0x0829, 0x082D, WEAK_NSM }, | ||
| 115 | { 0x0830, 0x0858, STRONG_R }, | ||
| 116 | { 0x0859, 0x085B, WEAK_NSM }, | ||
| 117 | { 0x085E, 0x085E, STRONG_R }, | ||
| 118 | { 0x0900, 0x0902, WEAK_NSM }, | ||
| 119 | { 0x093A, 0x093A, WEAK_NSM }, | ||
| 120 | { 0x093C, 0x093C, WEAK_NSM }, | ||
| 121 | { 0x0941, 0x0948, WEAK_NSM }, | ||
| 122 | { 0x094D, 0x094D, WEAK_NSM }, | ||
| 123 | { 0x0951, 0x0957, WEAK_NSM }, | ||
| 124 | { 0x0962, 0x0963, WEAK_NSM }, | ||
| 125 | { 0x0981, 0x0981, WEAK_NSM }, | ||
| 126 | { 0x09BC, 0x09BC, WEAK_NSM }, | ||
| 127 | { 0x09C1, 0x09C4, WEAK_NSM }, | ||
| 128 | { 0x09CD, 0x09CD, WEAK_NSM }, | ||
| 129 | { 0x09E2, 0x09E3, WEAK_NSM }, | ||
| 130 | { 0x09F2, 0x09F3, WEAK_ET }, | ||
| 131 | { 0x09FB, 0x09FB, WEAK_ET }, | ||
| 132 | { 0x0A01, 0x0A02, WEAK_NSM }, | ||
| 133 | { 0x0A3C, 0x0A3C, WEAK_NSM }, | ||
| 134 | { 0x0A41, 0x0A51, WEAK_NSM }, | ||
| 135 | { 0x0A70, 0x0A71, WEAK_NSM }, | ||
| 136 | { 0x0A75, 0x0A82, WEAK_NSM }, | ||
| 137 | { 0x0ABC, 0x0ABC, WEAK_NSM }, | ||
| 138 | { 0x0AC1, 0x0AC8, WEAK_NSM }, | ||
| 139 | { 0x0ACD, 0x0ACD, WEAK_NSM }, | ||
| 140 | { 0x0AE2, 0x0AE3, WEAK_NSM }, | ||
| 141 | { 0x0AF1, 0x0AF1, WEAK_ET }, | ||
| 142 | { 0x0B01, 0x0B01, WEAK_NSM }, | ||
| 143 | { 0x0B3C, 0x0B3C, WEAK_NSM }, | ||
| 144 | { 0x0B3F, 0x0B3F, WEAK_NSM }, | ||
| 145 | { 0x0B41, 0x0B44, WEAK_NSM }, | ||
| 146 | { 0x0B4D, 0x0B56, WEAK_NSM }, | ||
| 147 | { 0x0B62, 0x0B63, WEAK_NSM }, | ||
| 148 | { 0x0B82, 0x0B82, WEAK_NSM }, | ||
| 149 | { 0x0BC0, 0x0BC0, WEAK_NSM }, | ||
| 150 | { 0x0BCD, 0x0BCD, WEAK_NSM }, | ||
| 151 | { 0x0BF3, 0x0BF8, NEUTRAL_ON }, | ||
| 152 | { 0x0BF9, 0x0BF9, WEAK_ET }, | ||
| 153 | { 0x0BFA, 0x0BFA, NEUTRAL_ON }, | ||
| 154 | { 0x0C3E, 0x0C40, WEAK_NSM }, | ||
| 155 | { 0x0C46, 0x0C56, WEAK_NSM }, | ||
| 156 | { 0x0C62, 0x0C63, WEAK_NSM }, | ||
| 157 | { 0x0C78, 0x0C7E, NEUTRAL_ON }, | ||
| 158 | { 0x0CBC, 0x0CBC, WEAK_NSM }, | ||
| 159 | { 0x0CCC, 0x0CCD, WEAK_NSM }, | ||
| 160 | { 0x0CE2, 0x0CE3, WEAK_NSM }, | ||
| 161 | { 0x0D41, 0x0D44, WEAK_NSM }, | ||
| 162 | { 0x0D4D, 0x0D4D, WEAK_NSM }, | ||
| 163 | { 0x0D62, 0x0D63, WEAK_NSM }, | ||
| 164 | { 0x0DCA, 0x0DCA, WEAK_NSM }, | ||
| 165 | { 0x0DD2, 0x0DD6, WEAK_NSM }, | ||
| 166 | { 0x0E31, 0x0E31, WEAK_NSM }, | ||
| 167 | { 0x0E34, 0x0E3A, WEAK_NSM }, | ||
| 168 | { 0x0E3F, 0x0E3F, WEAK_ET }, | ||
| 169 | { 0x0E47, 0x0E4E, WEAK_NSM }, | ||
| 170 | { 0x0EB1, 0x0EB1, WEAK_NSM }, | ||
| 171 | { 0x0EB4, 0x0EBC, WEAK_NSM }, | ||
| 172 | { 0x0EC8, 0x0ECD, WEAK_NSM }, | ||
| 173 | { 0x0F18, 0x0F19, WEAK_NSM }, | ||
| 174 | { 0x0F35, 0x0F35, WEAK_NSM }, | ||
| 175 | { 0x0F37, 0x0F37, WEAK_NSM }, | ||
| 176 | { 0x0F39, 0x0F39, WEAK_NSM }, | ||
| 177 | { 0x0F3A, 0x0F3D, NEUTRAL_ON }, | ||
| 178 | { 0x0F71, 0x0F7E, WEAK_NSM }, | ||
| 179 | { 0x0F80, 0x0F84, WEAK_NSM }, | ||
| 180 | { 0x0F86, 0x0F87, WEAK_NSM }, | ||
| 181 | { 0x0F8D, 0x0FBC, WEAK_NSM }, | ||
| 182 | { 0x0FC6, 0x0FC6, WEAK_NSM }, | ||
| 183 | { 0x102D, 0x1030, WEAK_NSM }, | ||
| 184 | { 0x1032, 0x1037, WEAK_NSM }, | ||
| 185 | { 0x1039, 0x103A, WEAK_NSM }, | ||
| 186 | { 0x103D, 0x103E, WEAK_NSM }, | ||
| 187 | { 0x1058, 0x1059, WEAK_NSM }, | ||
| 188 | { 0x105E, 0x1060, WEAK_NSM }, | ||
| 189 | { 0x1071, 0x1074, WEAK_NSM }, | ||
| 190 | { 0x1082, 0x1082, WEAK_NSM }, | ||
| 191 | { 0x1085, 0x1086, WEAK_NSM }, | ||
| 192 | { 0x108D, 0x108D, WEAK_NSM }, | ||
| 193 | { 0x109D, 0x109D, WEAK_NSM }, | ||
| 194 | { 0x135D, 0x135F, WEAK_NSM }, | ||
| 195 | { 0x1390, 0x1399, NEUTRAL_ON }, | ||
| 196 | { 0x1400, 0x1400, NEUTRAL_ON }, | ||
| 197 | { 0x1680, 0x1680, NEUTRAL_WS }, | ||
| 198 | { 0x169B, 0x169C, NEUTRAL_ON }, | ||
| 199 | { 0x1712, 0x1714, WEAK_NSM }, | ||
| 200 | { 0x1732, 0x1734, WEAK_NSM }, | ||
| 201 | { 0x1752, 0x1753, WEAK_NSM }, | ||
| 202 | { 0x1772, 0x1773, WEAK_NSM }, | ||
| 203 | { 0x17B7, 0x17BD, WEAK_NSM }, | ||
| 204 | { 0x17C6, 0x17C6, WEAK_NSM }, | ||
| 205 | { 0x17C9, 0x17D3, WEAK_NSM }, | ||
| 206 | { 0x17DB, 0x17DB, WEAK_ET }, | ||
| 207 | { 0x17DD, 0x17DD, WEAK_NSM }, | ||
| 208 | { 0x17F0, 0x180A, NEUTRAL_ON }, | ||
| 209 | { 0x180B, 0x180D, WEAK_NSM }, | ||
| 210 | { 0x180E, 0x180E, NEUTRAL_WS }, | ||
| 211 | { 0x18A9, 0x18A9, WEAK_NSM }, | ||
| 212 | { 0x1920, 0x1922, WEAK_NSM }, | ||
| 213 | { 0x1927, 0x1928, WEAK_NSM }, | ||
| 214 | { 0x1932, 0x1932, WEAK_NSM }, | ||
| 215 | { 0x1939, 0x193B, WEAK_NSM }, | ||
| 216 | { 0x1940, 0x1945, NEUTRAL_ON }, | ||
| 217 | { 0x19DE, 0x19FF, NEUTRAL_ON }, | ||
| 218 | { 0x1A17, 0x1A18, WEAK_NSM }, | ||
| 219 | { 0x1A56, 0x1A56, WEAK_NSM }, | ||
| 220 | { 0x1A58, 0x1A60, WEAK_NSM }, | ||
| 221 | { 0x1A62, 0x1A62, WEAK_NSM }, | ||
| 222 | { 0x1A65, 0x1A6C, WEAK_NSM }, | ||
| 223 | { 0x1A73, 0x1A7F, WEAK_NSM }, | ||
| 224 | { 0x1B00, 0x1B03, WEAK_NSM }, | ||
| 225 | { 0x1B34, 0x1B34, WEAK_NSM }, | ||
| 226 | { 0x1B36, 0x1B3A, WEAK_NSM }, | ||
| 227 | { 0x1B3C, 0x1B3C, WEAK_NSM }, | ||
| 228 | { 0x1B42, 0x1B42, WEAK_NSM }, | ||
| 229 | { 0x1B6B, 0x1B73, WEAK_NSM }, | ||
| 230 | { 0x1B80, 0x1B81, WEAK_NSM }, | ||
| 231 | { 0x1BA2, 0x1BA5, WEAK_NSM }, | ||
| 232 | { 0x1BA8, 0x1BA9, WEAK_NSM }, | ||
| 233 | { 0x1BE6, 0x1BE6, WEAK_NSM }, | ||
| 234 | { 0x1BE8, 0x1BE9, WEAK_NSM }, | ||
| 235 | { 0x1BED, 0x1BED, WEAK_NSM }, | ||
| 236 | { 0x1BEF, 0x1BF1, WEAK_NSM }, | ||
| 237 | { 0x1C2C, 0x1C33, WEAK_NSM }, | ||
| 238 | { 0x1C36, 0x1C37, WEAK_NSM }, | ||
| 239 | { 0x1CD0, 0x1CD2, WEAK_NSM }, | ||
| 240 | { 0x1CD4, 0x1CE0, WEAK_NSM }, | ||
| 241 | { 0x1CE2, 0x1CE8, WEAK_NSM }, | ||
| 242 | { 0x1CED, 0x1CED, WEAK_NSM }, | ||
| 243 | { 0x1DC0, 0x1DFF, WEAK_NSM }, | ||
| 244 | { 0x1FBD, 0x1FBD, NEUTRAL_ON }, | ||
| 245 | { 0x1FBF, 0x1FC1, NEUTRAL_ON }, | ||
| 246 | { 0x1FCD, 0x1FCF, NEUTRAL_ON }, | ||
| 247 | { 0x1FDD, 0x1FDF, NEUTRAL_ON }, | ||
| 248 | { 0x1FED, 0x1FEF, NEUTRAL_ON }, | ||
| 249 | { 0x1FFD, 0x1FFE, NEUTRAL_ON }, | ||
| 250 | { 0x2000, 0x200A, NEUTRAL_WS }, | ||
| 251 | { 0x200B, 0x200D, WEAK_BN }, | ||
| 252 | { 0x200F, 0x200F, STRONG_R }, | ||
| 253 | { 0x2010, 0x2027, NEUTRAL_ON }, | ||
| 254 | { 0x2028, 0x2028, NEUTRAL_WS }, | ||
| 255 | { 0x2029, 0x2029, NEUTRAL_B }, | ||
| 256 | { 0x202A, 0x202A, LRE }, | ||
| 257 | { 0x202B, 0x202B, RLE }, | ||
| 258 | { 0x202C, 0x202C, PDF }, | ||
| 259 | { 0x202D, 0x202D, LRO }, | ||
| 260 | { 0x202E, 0x202E, RLO }, | ||
| 261 | { 0x202F, 0x202F, WEAK_CS }, | ||
| 262 | { 0x2030, 0x2034, WEAK_ET }, | ||
| 263 | { 0x2035, 0x2043, NEUTRAL_ON }, | ||
| 264 | { 0x2044, 0x2044, WEAK_CS }, | ||
| 265 | { 0x2045, 0x205E, NEUTRAL_ON }, | ||
| 266 | { 0x205F, 0x205F, NEUTRAL_WS }, | ||
| 267 | { 0x2060, 0x206F, WEAK_BN }, | ||
| 268 | { 0x2070, 0x2070, WEAK_EN }, | ||
| 269 | { 0x2074, 0x2079, WEAK_EN }, | ||
| 270 | { 0x207A, 0x207B, WEAK_ES }, | ||
| 271 | { 0x207C, 0x207E, NEUTRAL_ON }, | ||
| 272 | { 0x2080, 0x2089, WEAK_EN }, | ||
| 273 | { 0x208A, 0x208B, WEAK_ES }, | ||
| 274 | { 0x208C, 0x208E, NEUTRAL_ON }, | ||
| 275 | { 0x20A0, 0x20B9, WEAK_ET }, | ||
| 276 | { 0x20D0, 0x20F0, WEAK_NSM }, | ||
| 277 | { 0x2100, 0x2101, NEUTRAL_ON }, | ||
| 278 | { 0x2103, 0x2106, NEUTRAL_ON }, | ||
| 279 | { 0x2108, 0x2109, NEUTRAL_ON }, | ||
| 280 | { 0x2114, 0x2114, NEUTRAL_ON }, | ||
| 281 | { 0x2116, 0x2118, NEUTRAL_ON }, | ||
| 282 | { 0x211E, 0x2123, NEUTRAL_ON }, | ||
| 283 | { 0x2125, 0x2125, NEUTRAL_ON }, | ||
| 284 | { 0x2127, 0x2127, NEUTRAL_ON }, | ||
| 285 | { 0x2129, 0x2129, NEUTRAL_ON }, | ||
| 286 | { 0x212E, 0x212E, WEAK_ET }, | ||
| 287 | { 0x213A, 0x213B, NEUTRAL_ON }, | ||
| 288 | { 0x2140, 0x2144, NEUTRAL_ON }, | ||
| 289 | { 0x214A, 0x214D, NEUTRAL_ON }, | ||
| 290 | { 0x2150, 0x215F, NEUTRAL_ON }, | ||
| 291 | { 0x2189, 0x2211, NEUTRAL_ON }, | ||
| 292 | { 0x2212, 0x2212, WEAK_ES }, | ||
| 293 | { 0x2213, 0x2213, WEAK_ET }, | ||
| 294 | { 0x2214, 0x2335, NEUTRAL_ON }, | ||
| 295 | { 0x237B, 0x2394, NEUTRAL_ON }, | ||
| 296 | { 0x2396, 0x2487, NEUTRAL_ON }, | ||
| 297 | { 0x2488, 0x249B, WEAK_EN }, | ||
| 298 | { 0x24EA, 0x26AB, NEUTRAL_ON }, | ||
| 299 | { 0x26AD, 0x27FF, NEUTRAL_ON }, | ||
| 300 | { 0x2900, 0x2B59, NEUTRAL_ON }, | ||
| 301 | { 0x2CE5, 0x2CEA, NEUTRAL_ON }, | ||
| 302 | { 0x2CEF, 0x2CF1, WEAK_NSM }, | ||
| 303 | { 0x2CF9, 0x2CFF, NEUTRAL_ON }, | ||
| 304 | { 0x2D7F, 0x2D7F, WEAK_NSM }, | ||
| 305 | { 0x2DE0, 0x2DFF, WEAK_NSM }, | ||
| 306 | { 0x2E00, 0x2FFB, NEUTRAL_ON }, | ||
| 307 | { 0x3000, 0x3000, NEUTRAL_WS }, | ||
| 308 | { 0x3001, 0x3004, NEUTRAL_ON }, | ||
| 309 | { 0x3008, 0x3020, NEUTRAL_ON }, | ||
| 310 | { 0x302A, 0x302F, WEAK_NSM }, | ||
| 311 | { 0x3030, 0x3030, NEUTRAL_ON }, | ||
| 312 | { 0x3036, 0x3037, NEUTRAL_ON }, | ||
| 313 | { 0x303D, 0x303F, NEUTRAL_ON }, | ||
| 314 | { 0x3099, 0x309A, WEAK_NSM }, | ||
| 315 | { 0x309B, 0x309C, NEUTRAL_ON }, | ||
| 316 | { 0x30A0, 0x30A0, NEUTRAL_ON }, | ||
| 317 | { 0x30FB, 0x30FB, NEUTRAL_ON }, | ||
| 318 | { 0x31C0, 0x31E3, NEUTRAL_ON }, | ||
| 319 | { 0x321D, 0x321E, NEUTRAL_ON }, | ||
| 320 | { 0x3250, 0x325F, NEUTRAL_ON }, | ||
| 321 | { 0x327C, 0x327E, NEUTRAL_ON }, | ||
| 322 | { 0x32B1, 0x32BF, NEUTRAL_ON }, | ||
| 323 | { 0x32CC, 0x32CF, NEUTRAL_ON }, | ||
| 324 | { 0x3377, 0x337A, NEUTRAL_ON }, | ||
| 325 | { 0x33DE, 0x33DF, NEUTRAL_ON }, | ||
| 326 | { 0x33FF, 0x33FF, NEUTRAL_ON }, | ||
| 327 | { 0x4DC0, 0x4DFF, NEUTRAL_ON }, | ||
| 328 | { 0xA490, 0xA4C6, NEUTRAL_ON }, | ||
| 329 | { 0xA60D, 0xA60F, NEUTRAL_ON }, | ||
| 330 | { 0xA66F, 0xA672, WEAK_NSM }, | ||
| 331 | { 0xA673, 0xA673, NEUTRAL_ON }, | ||
| 332 | { 0xA67C, 0xA67D, WEAK_NSM }, | ||
| 333 | { 0xA67E, 0xA67F, NEUTRAL_ON }, | ||
| 334 | { 0xA6F0, 0xA6F1, WEAK_NSM }, | ||
| 335 | { 0xA700, 0xA721, NEUTRAL_ON }, | ||
| 336 | { 0xA788, 0xA788, NEUTRAL_ON }, | ||
| 337 | { 0xA802, 0xA802, WEAK_NSM }, | ||
| 338 | { 0xA806, 0xA806, WEAK_NSM }, | ||
| 339 | { 0xA80B, 0xA80B, WEAK_NSM }, | ||
| 340 | { 0xA825, 0xA826, WEAK_NSM }, | ||
| 341 | { 0xA828, 0xA82B, NEUTRAL_ON }, | ||
| 342 | { 0xA838, 0xA839, WEAK_ET }, | ||
| 343 | { 0xA874, 0xA877, NEUTRAL_ON }, | ||
| 344 | { 0xA8C4, 0xA8C4, WEAK_NSM }, | ||
| 345 | { 0xA8E0, 0xA8F1, WEAK_NSM }, | ||
| 346 | { 0xA926, 0xA92D, WEAK_NSM }, | ||
| 347 | { 0xA947, 0xA951, WEAK_NSM }, | ||
| 348 | { 0xA980, 0xA982, WEAK_NSM }, | ||
| 349 | { 0xA9B3, 0xA9B3, WEAK_NSM }, | ||
| 350 | { 0xA9B6, 0xA9B9, WEAK_NSM }, | ||
| 351 | { 0xA9BC, 0xA9BC, WEAK_NSM }, | ||
| 352 | { 0xAA29, 0xAA2E, WEAK_NSM }, | ||
| 353 | { 0xAA31, 0xAA32, WEAK_NSM }, | ||
| 354 | { 0xAA35, 0xAA36, WEAK_NSM }, | ||
| 355 | { 0xAA43, 0xAA43, WEAK_NSM }, | ||
| 356 | { 0xAA4C, 0xAA4C, WEAK_NSM }, | ||
| 357 | { 0xAAB0, 0xAAB0, WEAK_NSM }, | ||
| 358 | { 0xAAB2, 0xAAB4, WEAK_NSM }, | ||
| 359 | { 0xAAB7, 0xAAB8, WEAK_NSM }, | ||
| 360 | { 0xAABE, 0xAABF, WEAK_NSM }, | ||
| 361 | { 0xAAC1, 0xAAC1, WEAK_NSM }, | ||
| 362 | { 0xABE5, 0xABE5, WEAK_NSM }, | ||
| 363 | { 0xABE8, 0xABE8, WEAK_NSM }, | ||
| 364 | { 0xABED, 0xABED, WEAK_NSM }, | ||
| 365 | { 0xFB1D, 0xFB1D, STRONG_R }, | ||
| 366 | { 0xFB1E, 0xFB1E, WEAK_NSM }, | ||
| 367 | { 0xFB1F, 0xFB28, STRONG_R }, | ||
| 368 | { 0xFB29, 0xFB29, WEAK_ES }, | ||
| 369 | { 0xFB2A, 0xFB4F, STRONG_R }, | ||
| 370 | { 0xFB50, 0xFD3D, STRONG_AL }, | ||
| 371 | { 0xFD3E, 0xFD3F, NEUTRAL_ON }, | ||
| 372 | { 0xFD50, 0xFDFC, STRONG_AL }, | ||
| 373 | { 0xFDFD, 0xFDFD, NEUTRAL_ON }, | ||
| 374 | { 0xFE00, 0xFE0F, WEAK_NSM }, | ||
| 375 | { 0xFE10, 0xFE19, NEUTRAL_ON }, | ||
| 376 | { 0xFE20, 0xFE26, WEAK_NSM }, | ||
| 377 | { 0xFE30, 0xFE4F, NEUTRAL_ON }, | ||
| 378 | { 0xFE50, 0xFE50, WEAK_CS }, | ||
| 379 | { 0xFE51, 0xFE51, NEUTRAL_ON }, | ||
| 380 | { 0xFE52, 0xFE52, WEAK_CS }, | ||
| 381 | { 0xFE54, 0xFE54, NEUTRAL_ON }, | ||
| 382 | { 0xFE55, 0xFE55, WEAK_CS }, | ||
| 383 | { 0xFE56, 0xFE5E, NEUTRAL_ON }, | ||
| 384 | { 0xFE5F, 0xFE5F, WEAK_ET }, | ||
| 385 | { 0xFE60, 0xFE61, NEUTRAL_ON }, | ||
| 386 | { 0xFE62, 0xFE63, WEAK_ES }, | ||
| 387 | { 0xFE64, 0xFE68, NEUTRAL_ON }, | ||
| 388 | { 0xFE69, 0xFE6A, WEAK_ET }, | ||
| 389 | { 0xFE6B, 0xFE6B, NEUTRAL_ON }, | ||
| 390 | { 0xFE70, 0xFEFC, STRONG_AL }, | ||
| 391 | { 0xFEFF, 0xFEFF, WEAK_BN }, | ||
| 392 | { 0xFF01, 0xFF02, NEUTRAL_ON }, | ||
| 393 | { 0xFF03, 0xFF05, WEAK_ET }, | ||
| 394 | { 0xFF06, 0xFF0A, NEUTRAL_ON }, | ||
| 395 | { 0xFF0B, 0xFF0B, WEAK_ES }, | ||
| 396 | { 0xFF0C, 0xFF0C, WEAK_CS }, | ||
| 397 | { 0xFF0D, 0xFF0D, WEAK_ES }, | ||
| 398 | { 0xFF0E, 0xFF0F, WEAK_CS }, | ||
| 399 | { 0xFF10, 0xFF19, WEAK_EN }, | ||
| 400 | { 0xFF1A, 0xFF1A, WEAK_CS }, | ||
| 401 | { 0xFF1B, 0xFF20, NEUTRAL_ON }, | ||
| 402 | { 0xFF3B, 0xFF40, NEUTRAL_ON }, | ||
| 403 | { 0xFF5B, 0xFF65, NEUTRAL_ON }, | ||
| 404 | { 0xFFE0, 0xFFE1, WEAK_ET }, | ||
| 405 | { 0xFFE2, 0xFFE4, NEUTRAL_ON }, | ||
| 406 | { 0xFFE5, 0xFFE6, WEAK_ET }, | ||
| 407 | { 0xFFE8, 0xFFFD, NEUTRAL_ON }, | ||
| 408 | { 0x10101, 0x10101, NEUTRAL_ON }, | ||
| 409 | { 0x10140, 0x1019B, NEUTRAL_ON }, | ||
| 410 | { 0x101FD, 0x101FD, WEAK_NSM }, | ||
| 411 | { 0x10800, 0x1091B, STRONG_R }, | ||
| 412 | { 0x1091F, 0x1091F, NEUTRAL_ON }, | ||
| 413 | { 0x10920, 0x10A00, STRONG_R }, | ||
| 414 | { 0x10A01, 0x10A0F, WEAK_NSM }, | ||
| 415 | { 0x10A10, 0x10A33, STRONG_R }, | ||
| 416 | { 0x10A38, 0x10A3F, WEAK_NSM }, | ||
| 417 | { 0x10A40, 0x10B35, STRONG_R }, | ||
| 418 | { 0x10B39, 0x10B3F, NEUTRAL_ON }, | ||
| 419 | { 0x10B40, 0x10C48, STRONG_R }, | ||
| 420 | { 0x10E60, 0x10E7E, WEAK_AN }, | ||
| 421 | { 0x11001, 0x11001, WEAK_NSM }, | ||
| 422 | { 0x11038, 0x11046, WEAK_NSM }, | ||
| 423 | { 0x11052, 0x11065, NEUTRAL_ON }, | ||
| 424 | { 0x11080, 0x11081, WEAK_NSM }, | ||
| 425 | { 0x110B3, 0x110B6, WEAK_NSM }, | ||
| 426 | { 0x110B9, 0x110BA, WEAK_NSM }, | ||
| 427 | { 0x1D167, 0x1D169, WEAK_NSM }, | ||
| 428 | { 0x1D173, 0x1D17A, WEAK_BN }, | ||
| 429 | { 0x1D17B, 0x1D182, WEAK_NSM }, | ||
| 430 | { 0x1D185, 0x1D18B, WEAK_NSM }, | ||
| 431 | { 0x1D1AA, 0x1D1AD, WEAK_NSM }, | ||
| 432 | { 0x1D200, 0x1D241, NEUTRAL_ON }, | ||
| 433 | { 0x1D242, 0x1D244, WEAK_NSM }, | ||
| 434 | { 0x1D245, 0x1D356, NEUTRAL_ON }, | ||
| 435 | { 0x1D6DB, 0x1D6DB, NEUTRAL_ON }, | ||
| 436 | { 0x1D715, 0x1D715, NEUTRAL_ON }, | ||
| 437 | { 0x1D74F, 0x1D74F, NEUTRAL_ON }, | ||
| 438 | { 0x1D789, 0x1D789, NEUTRAL_ON }, | ||
| 439 | { 0x1D7C3, 0x1D7C3, NEUTRAL_ON }, | ||
| 440 | { 0x1D7CE, 0x1D7FF, WEAK_EN }, | ||
| 441 | { 0x1F000, 0x1F0DF, NEUTRAL_ON }, | ||
| 442 | { 0x1F100, 0x1F10A, WEAK_EN }, | ||
| 443 | { 0x1F300, 0x1F48B, NEUTRAL_ON }, | ||
| 444 | { 0x1F48D, 0x1F523, NEUTRAL_ON }, | ||
| 445 | { 0x1F525, 0x1F773, NEUTRAL_ON }, | ||
| 446 | { 0xE0001, 0xE007F, WEAK_BN }, | ||
| 447 | { 0xE0100, 0xE01EF, WEAK_NSM } }; | ||
diff --git a/src/buffer.c b/src/buffer.c index 45d6fa36d04..37d2975c8c7 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1698,27 +1698,16 @@ record_buffer (Lisp_Object buffer) | |||
| 1698 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 1698 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 1699 | } | 1699 | } |
| 1700 | 1700 | ||
| 1701 | DEFUN ("record-buffer", Frecord_buffer, Srecord_buffer, 1, 1, 0, | ||
| 1702 | doc: /* Move BUFFER to the front of the buffer list. | ||
| 1703 | Return BUFFER. */) | ||
| 1704 | (Lisp_Object buffer) | ||
| 1705 | { | ||
| 1706 | CHECK_BUFFER (buffer); | ||
| 1707 | |||
| 1708 | record_buffer (buffer); | ||
| 1709 | |||
| 1710 | return buffer; | ||
| 1711 | } | ||
| 1712 | 1701 | ||
| 1713 | /* Move BUFFER to the end of the buffer (a)lists. Do nothing if the | 1702 | /* Move BUFFER to the end of the buffer (a)lists. Do nothing if the |
| 1714 | buffer is killed. For the selected frame's buffer list this moves | 1703 | buffer is killed. For the selected frame's buffer list this moves |
| 1715 | BUFFER to its end even if it was never shown in that frame. If | 1704 | BUFFER to its end even if it was never shown in that frame. If |
| 1716 | this happens we have a feature, hence `unrecord-buffer' should be | 1705 | this happens we have a feature, hence `unrecord-buffer' should be |
| 1717 | called only when BUFFER was shown in the selected frame. */ | 1706 | called only when BUFFER was shown in the selected frame. */ |
| 1718 | 1707 | ||
| 1719 | DEFUN ("unrecord-buffer", Funrecord_buffer, Sunrecord_buffer, 1, 1, 0, | 1708 | DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal, |
| 1720 | doc: /* Move BUFFER to the end of the buffer list. | 1709 | 1, 1, 0, |
| 1721 | Return BUFFER. */) | 1710 | doc: /* Move BUFFER to the end of the buffer list. */) |
| 1722 | (Lisp_Object buffer) | 1711 | (Lisp_Object buffer) |
| 1723 | { | 1712 | { |
| 1724 | Lisp_Object aelt, aelt_cons, tem; | 1713 | Lisp_Object aelt, aelt_cons, tem; |
| @@ -1746,7 +1735,7 @@ Return BUFFER. */) | |||
| 1746 | if (!NILP (Vrun_hooks)) | 1735 | if (!NILP (Vrun_hooks)) |
| 1747 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 1736 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 1748 | 1737 | ||
| 1749 | return buffer; | 1738 | return Qnil; |
| 1750 | } | 1739 | } |
| 1751 | 1740 | ||
| 1752 | DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, | 1741 | DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, |
| @@ -2568,13 +2557,10 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, | |||
| 2568 | Either make it bigger, or don't store any more in it. */ | 2557 | Either make it bigger, or don't store any more in it. */ |
| 2569 | if (extend) | 2558 | if (extend) |
| 2570 | { | 2559 | { |
| 2571 | if ((OVERLAY_COUNT_MAX - 4) / 2 < len) | 2560 | vec = xpalloc (vec, len_ptr, 1, OVERLAY_COUNT_MAX, |
| 2572 | memory_full (SIZE_MAX); | 2561 | sizeof *vec); |
| 2573 | /* Make it work with an initial len == 0. */ | ||
| 2574 | len = len * 2 + 4; | ||
| 2575 | *len_ptr = len; | ||
| 2576 | vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); | ||
| 2577 | *vec_ptr = vec; | 2562 | *vec_ptr = vec; |
| 2563 | len = *len_ptr; | ||
| 2578 | } | 2564 | } |
| 2579 | else | 2565 | else |
| 2580 | inhibit_storing = 1; | 2566 | inhibit_storing = 1; |
| @@ -2611,13 +2597,10 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, | |||
| 2611 | { | 2597 | { |
| 2612 | if (extend) | 2598 | if (extend) |
| 2613 | { | 2599 | { |
| 2614 | if ((OVERLAY_COUNT_MAX - 4) / 2 < len) | 2600 | vec = xpalloc (vec, len_ptr, 1, OVERLAY_COUNT_MAX, |
| 2615 | memory_full (SIZE_MAX); | 2601 | sizeof *vec); |
| 2616 | /* Make it work with an initial len == 0. */ | ||
| 2617 | len = len * 2 + 4; | ||
| 2618 | *len_ptr = len; | ||
| 2619 | vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); | ||
| 2620 | *vec_ptr = vec; | 2602 | *vec_ptr = vec; |
| 2603 | len = *len_ptr; | ||
| 2621 | } | 2604 | } |
| 2622 | else | 2605 | else |
| 2623 | inhibit_storing = 1; | 2606 | inhibit_storing = 1; |
| @@ -2708,13 +2691,10 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend, | |||
| 2708 | Either make it bigger, or don't store any more in it. */ | 2691 | Either make it bigger, or don't store any more in it. */ |
| 2709 | if (extend) | 2692 | if (extend) |
| 2710 | { | 2693 | { |
| 2711 | if ((OVERLAY_COUNT_MAX - 4) / 2 < len) | 2694 | vec = xpalloc (vec, len_ptr, 1, OVERLAY_COUNT_MAX, |
| 2712 | memory_full (SIZE_MAX); | 2695 | sizeof *vec); |
| 2713 | /* Make it work with an initial len == 0. */ | ||
| 2714 | len = len * 2 + 4; | ||
| 2715 | *len_ptr = len; | ||
| 2716 | vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); | ||
| 2717 | *vec_ptr = vec; | 2696 | *vec_ptr = vec; |
| 2697 | len = *len_ptr; | ||
| 2718 | } | 2698 | } |
| 2719 | else | 2699 | else |
| 2720 | inhibit_storing = 1; | 2700 | inhibit_storing = 1; |
| @@ -2756,13 +2736,10 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend, | |||
| 2756 | { | 2736 | { |
| 2757 | if (extend) | 2737 | if (extend) |
| 2758 | { | 2738 | { |
| 2759 | if ((OVERLAY_COUNT_MAX - 4) / 2 < len) | 2739 | vec = xpalloc (vec, len_ptr, 1, OVERLAY_COUNT_MAX, |
| 2760 | memory_full (SIZE_MAX); | 2740 | sizeof *vec); |
| 2761 | /* Make it work with an initial len == 0. */ | ||
| 2762 | len = len * 2 + 4; | ||
| 2763 | *len_ptr = len; | ||
| 2764 | vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); | ||
| 2765 | *vec_ptr = vec; | 2741 | *vec_ptr = vec; |
| 2742 | len = *len_ptr; | ||
| 2766 | } | 2743 | } |
| 2767 | else | 2744 | else |
| 2768 | inhibit_storing = 1; | 2745 | inhibit_storing = 1; |
| @@ -2944,7 +2921,7 @@ struct sortstrlist | |||
| 2944 | struct sortstr *buf; /* An array that expands as needed; never freed. */ | 2921 | struct sortstr *buf; /* An array that expands as needed; never freed. */ |
| 2945 | ptrdiff_t size; /* Allocated length of that array. */ | 2922 | ptrdiff_t size; /* Allocated length of that array. */ |
| 2946 | ptrdiff_t used; /* How much of the array is currently in use. */ | 2923 | ptrdiff_t used; /* How much of the array is currently in use. */ |
| 2947 | EMACS_INT bytes; /* Total length of the strings in buf. */ | 2924 | ptrdiff_t bytes; /* Total length of the strings in buf. */ |
| 2948 | }; | 2925 | }; |
| 2949 | 2926 | ||
| 2950 | /* Buffers for storing information about the overlays touching a given | 2927 | /* Buffers for storing information about the overlays touching a given |
| @@ -2955,7 +2932,7 @@ static struct sortstrlist overlay_heads, overlay_tails; | |||
| 2955 | static unsigned char *overlay_str_buf; | 2932 | static unsigned char *overlay_str_buf; |
| 2956 | 2933 | ||
| 2957 | /* Allocated length of overlay_str_buf. */ | 2934 | /* Allocated length of overlay_str_buf. */ |
| 2958 | static EMACS_INT overlay_str_len; | 2935 | static ptrdiff_t overlay_str_len; |
| 2959 | 2936 | ||
| 2960 | /* A comparison function suitable for passing to qsort. */ | 2937 | /* A comparison function suitable for passing to qsort. */ |
| 2961 | static int | 2938 | static int |
| @@ -2977,17 +2954,7 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, | |||
| 2977 | EMACS_INT nbytes; | 2954 | EMACS_INT nbytes; |
| 2978 | 2955 | ||
| 2979 | if (ssl->used == ssl->size) | 2956 | if (ssl->used == ssl->size) |
| 2980 | { | 2957 | ssl->buf = xpalloc (ssl->buf, &ssl->size, 5, -1, sizeof *ssl->buf); |
| 2981 | if (min (PTRDIFF_MAX, SIZE_MAX) / (sizeof (struct sortstr) * 2) | ||
| 2982 | < ssl->size) | ||
| 2983 | memory_full (SIZE_MAX); | ||
| 2984 | else if (0 < ssl->size) | ||
| 2985 | ssl->size *= 2; | ||
| 2986 | else | ||
| 2987 | ssl->size = 5; | ||
| 2988 | ssl->buf = ((struct sortstr *) | ||
| 2989 | xrealloc (ssl->buf, ssl->size * sizeof (struct sortstr))); | ||
| 2990 | } | ||
| 2991 | ssl->buf[ssl->used].string = str; | 2958 | ssl->buf[ssl->used].string = str; |
| 2992 | ssl->buf[ssl->used].string2 = str2; | 2959 | ssl->buf[ssl->used].string2 = str2; |
| 2993 | ssl->buf[ssl->used].size = size; | 2960 | ssl->buf[ssl->used].size = size; |
| @@ -3002,6 +2969,8 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, | |||
| 3002 | else | 2969 | else |
| 3003 | nbytes = SBYTES (str); | 2970 | nbytes = SBYTES (str); |
| 3004 | 2971 | ||
| 2972 | if (INT_ADD_OVERFLOW (ssl->bytes, nbytes)) | ||
| 2973 | memory_full (SIZE_MAX); | ||
| 3005 | ssl->bytes += nbytes; | 2974 | ssl->bytes += nbytes; |
| 3006 | 2975 | ||
| 3007 | if (STRINGP (str2)) | 2976 | if (STRINGP (str2)) |
| @@ -3014,6 +2983,8 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, | |||
| 3014 | else | 2983 | else |
| 3015 | nbytes = SBYTES (str2); | 2984 | nbytes = SBYTES (str2); |
| 3016 | 2985 | ||
| 2986 | if (INT_ADD_OVERFLOW (ssl->bytes, nbytes)) | ||
| 2987 | memory_full (SIZE_MAX); | ||
| 3017 | ssl->bytes += nbytes; | 2988 | ssl->bytes += nbytes; |
| 3018 | } | 2989 | } |
| 3019 | } | 2990 | } |
| @@ -3107,14 +3078,15 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) | |||
| 3107 | Lisp_Object tem; | 3078 | Lisp_Object tem; |
| 3108 | EMACS_INT i; | 3079 | EMACS_INT i; |
| 3109 | unsigned char *p; | 3080 | unsigned char *p; |
| 3110 | EMACS_INT total = overlay_heads.bytes + overlay_tails.bytes; | 3081 | ptrdiff_t total; |
| 3111 | 3082 | ||
| 3083 | if (INT_ADD_OVERFLOW (overlay_heads.bytes, overlay_tails.bytes)) | ||
| 3084 | memory_full (SIZE_MAX); | ||
| 3085 | total = overlay_heads.bytes + overlay_tails.bytes; | ||
| 3112 | if (total > overlay_str_len) | 3086 | if (total > overlay_str_len) |
| 3113 | { | 3087 | overlay_str_buf = xpalloc (overlay_str_buf, &overlay_str_len, |
| 3114 | overlay_str_len = total; | 3088 | total - overlay_str_len, -1, 1); |
| 3115 | overlay_str_buf = (unsigned char *)xrealloc (overlay_str_buf, | 3089 | |
| 3116 | total); | ||
| 3117 | } | ||
| 3118 | p = overlay_str_buf; | 3090 | p = overlay_str_buf; |
| 3119 | for (i = overlay_tails.used; --i >= 0;) | 3091 | for (i = overlay_tails.used; --i >= 0;) |
| 3120 | { | 3092 | { |
| @@ -6034,8 +6006,7 @@ Functions running this hook are `get-buffer-create', | |||
| 6034 | defsubr (&Sother_buffer); | 6006 | defsubr (&Sother_buffer); |
| 6035 | defsubr (&Sbuffer_enable_undo); | 6007 | defsubr (&Sbuffer_enable_undo); |
| 6036 | defsubr (&Skill_buffer); | 6008 | defsubr (&Skill_buffer); |
| 6037 | defsubr (&Srecord_buffer); | 6009 | defsubr (&Sbury_buffer_internal); |
| 6038 | defsubr (&Sunrecord_buffer); | ||
| 6039 | defsubr (&Sset_buffer_major_mode); | 6010 | defsubr (&Sset_buffer_major_mode); |
| 6040 | defsubr (&Scurrent_buffer); | 6011 | defsubr (&Scurrent_buffer); |
| 6041 | defsubr (&Sset_buffer); | 6012 | defsubr (&Sset_buffer); |
diff --git a/src/callproc.c b/src/callproc.c index f148f6233d4..1bdb57a27d0 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -252,7 +252,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 252 | val = Qraw_text; | 252 | val = Qraw_text; |
| 253 | else | 253 | else |
| 254 | { | 254 | { |
| 255 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); | 255 | SAFE_NALLOCA (args2, 1, nargs + 1); |
| 256 | args2[0] = Qcall_process; | 256 | args2[0] = Qcall_process; |
| 257 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 257 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 258 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); | 258 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
| @@ -603,6 +603,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 603 | 603 | ||
| 604 | /* vfork, and prevent local vars from being clobbered by the vfork. */ | 604 | /* vfork, and prevent local vars from being clobbered by the vfork. */ |
| 605 | { | 605 | { |
| 606 | Lisp_Object volatile buffer_volatile = buffer; | ||
| 607 | Lisp_Object volatile coding_systems_volatile = coding_systems; | ||
| 608 | Lisp_Object volatile current_dir_volatile = current_dir; | ||
| 606 | int volatile fd1_volatile = fd1; | 609 | int volatile fd1_volatile = fd1; |
| 607 | int volatile fd_error_volatile = fd_error; | 610 | int volatile fd_error_volatile = fd_error; |
| 608 | int volatile fd_output_volatile = fd_output; | 611 | int volatile fd_output_volatile = fd_output; |
| @@ -611,6 +614,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 611 | 614 | ||
| 612 | pid = vfork (); | 615 | pid = vfork (); |
| 613 | 616 | ||
| 617 | buffer = buffer_volatile; | ||
| 618 | coding_systems = coding_systems_volatile; | ||
| 619 | current_dir = current_dir_volatile; | ||
| 614 | fd1 = fd1_volatile; | 620 | fd1 = fd1_volatile; |
| 615 | fd_error = fd_error_volatile; | 621 | fd_error = fd_error_volatile; |
| 616 | fd_output = fd_output_volatile; | 622 | fd_output = fd_output_volatile; |
| @@ -720,7 +726,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 720 | { | 726 | { |
| 721 | ptrdiff_t i; | 727 | ptrdiff_t i; |
| 722 | 728 | ||
| 723 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); | 729 | SAFE_NALLOCA (args2, 1, nargs + 1); |
| 724 | args2[0] = Qcall_process; | 730 | args2[0] = Qcall_process; |
| 725 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 731 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 726 | coding_systems | 732 | coding_systems |
| @@ -1018,7 +1024,7 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 1018 | else | 1024 | else |
| 1019 | { | 1025 | { |
| 1020 | USE_SAFE_ALLOCA; | 1026 | USE_SAFE_ALLOCA; |
| 1021 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); | 1027 | SAFE_NALLOCA (args2, 1, nargs + 1); |
| 1022 | args2[0] = Qcall_process_region; | 1028 | args2[0] = Qcall_process_region; |
| 1023 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 1029 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 1024 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); | 1030 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
| @@ -1147,7 +1153,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L | |||
| 1147 | cleaned up in the usual way. */ | 1153 | cleaned up in the usual way. */ |
| 1148 | { | 1154 | { |
| 1149 | register char *temp; | 1155 | register char *temp; |
| 1150 | register int i; | 1156 | size_t i; /* size_t, because ptrdiff_t might overflow here! */ |
| 1151 | 1157 | ||
| 1152 | i = SBYTES (current_dir); | 1158 | i = SBYTES (current_dir); |
| 1153 | #ifdef MSDOS | 1159 | #ifdef MSDOS |
diff --git a/src/category.c b/src/category.c index 08eadb04730..a822bb654b0 100644 --- a/src/category.c +++ b/src/category.c | |||
| @@ -67,7 +67,7 @@ static Lisp_Object | |||
| 67 | hash_get_category_set (Lisp_Object table, Lisp_Object category_set) | 67 | hash_get_category_set (Lisp_Object table, Lisp_Object category_set) |
| 68 | { | 68 | { |
| 69 | struct Lisp_Hash_Table *h; | 69 | struct Lisp_Hash_Table *h; |
| 70 | EMACS_INT i; | 70 | ptrdiff_t i; |
| 71 | EMACS_UINT hash; | 71 | EMACS_UINT hash; |
| 72 | 72 | ||
| 73 | if (NILP (XCHAR_TABLE (table)->extras[1])) | 73 | if (NILP (XCHAR_TABLE (table)->extras[1])) |
| @@ -1303,7 +1303,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size | |||
| 1303 | 1303 | ||
| 1304 | case CCL_LookupIntConstTbl: | 1304 | case CCL_LookupIntConstTbl: |
| 1305 | { | 1305 | { |
| 1306 | EMACS_INT eop; | 1306 | ptrdiff_t eop; |
| 1307 | struct Lisp_Hash_Table *h; | 1307 | struct Lisp_Hash_Table *h; |
| 1308 | GET_CCL_RANGE (eop, ccl_prog, ic++, 0, | 1308 | GET_CCL_RANGE (eop, ccl_prog, ic++, 0, |
| 1309 | (VECTORP (Vtranslation_hash_table_vector) | 1309 | (VECTORP (Vtranslation_hash_table_vector) |
| @@ -1329,7 +1329,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size | |||
| 1329 | 1329 | ||
| 1330 | case CCL_LookupCharConstTbl: | 1330 | case CCL_LookupCharConstTbl: |
| 1331 | { | 1331 | { |
| 1332 | EMACS_INT eop; | 1332 | ptrdiff_t eop; |
| 1333 | struct Lisp_Hash_Table *h; | 1333 | struct Lisp_Hash_Table *h; |
| 1334 | GET_CCL_RANGE (eop, ccl_prog, ic++, 0, | 1334 | GET_CCL_RANGE (eop, ccl_prog, ic++, 0, |
| 1335 | (VECTORP (Vtranslation_hash_table_vector) | 1335 | (VECTORP (Vtranslation_hash_table_vector) |
| @@ -1770,7 +1770,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size | |||
| 1770 | } | 1770 | } |
| 1771 | 1771 | ||
| 1772 | msglen = strlen (msg); | 1772 | msglen = strlen (msg); |
| 1773 | if (dst + msglen <= dst_end) | 1773 | if (msglen <= dst_end - dst) |
| 1774 | { | 1774 | { |
| 1775 | for (i = 0; i < msglen; i++) | 1775 | for (i = 0; i < msglen; i++) |
| 1776 | *dst++ = msg[i]; | 1776 | *dst++ = msg[i]; |
| @@ -2061,12 +2061,13 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY | |||
| 2061 | Lisp_Object val; | 2061 | Lisp_Object val; |
| 2062 | struct ccl_program ccl; | 2062 | struct ccl_program ccl; |
| 2063 | int i; | 2063 | int i; |
| 2064 | EMACS_INT outbufsize; | 2064 | ptrdiff_t outbufsize; |
| 2065 | unsigned char *outbuf, *outp; | 2065 | unsigned char *outbuf, *outp; |
| 2066 | EMACS_INT str_chars, str_bytes; | 2066 | ptrdiff_t str_chars, str_bytes; |
| 2067 | #define CCL_EXECUTE_BUF_SIZE 1024 | 2067 | #define CCL_EXECUTE_BUF_SIZE 1024 |
| 2068 | int source[CCL_EXECUTE_BUF_SIZE], destination[CCL_EXECUTE_BUF_SIZE]; | 2068 | int source[CCL_EXECUTE_BUF_SIZE], destination[CCL_EXECUTE_BUF_SIZE]; |
| 2069 | EMACS_INT consumed_chars, consumed_bytes, produced_chars; | 2069 | ptrdiff_t consumed_chars, consumed_bytes, produced_chars; |
| 2070 | int buf_magnification; | ||
| 2070 | 2071 | ||
| 2071 | if (setup_ccl_program (&ccl, ccl_prog) < 0) | 2072 | if (setup_ccl_program (&ccl, ccl_prog) < 0) |
| 2072 | error ("Invalid CCL program"); | 2073 | error ("Invalid CCL program"); |
| @@ -2093,6 +2094,10 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY | |||
| 2093 | ccl.ic = i; | 2094 | ccl.ic = i; |
| 2094 | } | 2095 | } |
| 2095 | 2096 | ||
| 2097 | buf_magnification = ccl.buf_magnification ? ccl.buf_magnification : 1; | ||
| 2098 | |||
| 2099 | if ((min (PTRDIFF_MAX, SIZE_MAX) - 256) / buf_magnification < str_bytes) | ||
| 2100 | memory_full (SIZE_MAX); | ||
| 2096 | outbufsize = (ccl.buf_magnification | 2101 | outbufsize = (ccl.buf_magnification |
| 2097 | ? str_bytes * ccl.buf_magnification + 256 | 2102 | ? str_bytes * ccl.buf_magnification + 256 |
| 2098 | : str_bytes + 256); | 2103 | : str_bytes + 256); |
| @@ -2122,31 +2127,25 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY | |||
| 2122 | src_size = j; | 2127 | src_size = j; |
| 2123 | while (1) | 2128 | while (1) |
| 2124 | { | 2129 | { |
| 2130 | int max_expansion = NILP (unibyte_p) ? MAX_MULTIBYTE_LENGTH : 1; | ||
| 2131 | ptrdiff_t offset, shortfall; | ||
| 2125 | ccl_driver (&ccl, src, destination, src_size, CCL_EXECUTE_BUF_SIZE, | 2132 | ccl_driver (&ccl, src, destination, src_size, CCL_EXECUTE_BUF_SIZE, |
| 2126 | Qnil); | 2133 | Qnil); |
| 2127 | produced_chars += ccl.produced; | 2134 | produced_chars += ccl.produced; |
| 2135 | offset = outp - outbuf; | ||
| 2136 | shortfall = ccl.produced * max_expansion - (outbufsize - offset); | ||
| 2137 | if (0 < shortfall) | ||
| 2138 | { | ||
| 2139 | outbuf = xpalloc (outbuf, &outbufsize, shortfall, -1, 1); | ||
| 2140 | outp = outbuf + offset; | ||
| 2141 | } | ||
| 2128 | if (NILP (unibyte_p)) | 2142 | if (NILP (unibyte_p)) |
| 2129 | { | 2143 | { |
| 2130 | if (outp - outbuf + MAX_MULTIBYTE_LENGTH * ccl.produced | ||
| 2131 | > outbufsize) | ||
| 2132 | { | ||
| 2133 | EMACS_INT offset = outp - outbuf; | ||
| 2134 | outbufsize += MAX_MULTIBYTE_LENGTH * ccl.produced; | ||
| 2135 | outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); | ||
| 2136 | outp = outbuf + offset; | ||
| 2137 | } | ||
| 2138 | for (j = 0; j < ccl.produced; j++) | 2144 | for (j = 0; j < ccl.produced; j++) |
| 2139 | CHAR_STRING_ADVANCE (destination[j], outp); | 2145 | CHAR_STRING_ADVANCE (destination[j], outp); |
| 2140 | } | 2146 | } |
| 2141 | else | 2147 | else |
| 2142 | { | 2148 | { |
| 2143 | if (outp - outbuf + ccl.produced > outbufsize) | ||
| 2144 | { | ||
| 2145 | EMACS_INT offset = outp - outbuf; | ||
| 2146 | outbufsize += ccl.produced; | ||
| 2147 | outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); | ||
| 2148 | outp = outbuf + offset; | ||
| 2149 | } | ||
| 2150 | for (j = 0; j < ccl.produced; j++) | 2149 | for (j = 0; j < ccl.produced; j++) |
| 2151 | *outp++ = destination[j]; | 2150 | *outp++ = destination[j]; |
| 2152 | } | 2151 | } |
diff --git a/src/character.c b/src/character.c index 8e9b3e3775e..fb9b8a9b93e 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -326,7 +326,7 @@ usage: (char-width CHAR) */) | |||
| 326 | disp = dp ? DISP_CHAR_VECTOR (dp, c) : Qnil; | 326 | disp = dp ? DISP_CHAR_VECTOR (dp, c) : Qnil; |
| 327 | 327 | ||
| 328 | if (VECTORP (disp)) | 328 | if (VECTORP (disp)) |
| 329 | width = ASIZE (disp); | 329 | width = sanitize_char_width (ASIZE (disp)); |
| 330 | else | 330 | else |
| 331 | width = CHAR_WIDTH (c); | 331 | width = CHAR_WIDTH (c); |
| 332 | 332 | ||
| @@ -358,7 +358,7 @@ c_string_width (const unsigned char *str, EMACS_INT len, int precision, | |||
| 358 | { | 358 | { |
| 359 | val = DISP_CHAR_VECTOR (dp, c); | 359 | val = DISP_CHAR_VECTOR (dp, c); |
| 360 | if (VECTORP (val)) | 360 | if (VECTORP (val)) |
| 361 | thiswidth = ASIZE (val); | 361 | thiswidth = sanitize_char_width (ASIZE (val)); |
| 362 | else | 362 | else |
| 363 | thiswidth = CHAR_WIDTH (c); | 363 | thiswidth = CHAR_WIDTH (c); |
| 364 | } | 364 | } |
| @@ -423,7 +423,7 @@ lisp_string_width (Lisp_Object string, EMACS_INT precision, | |||
| 423 | { | 423 | { |
| 424 | EMACS_INT chars, bytes, thiswidth; | 424 | EMACS_INT chars, bytes, thiswidth; |
| 425 | Lisp_Object val; | 425 | Lisp_Object val; |
| 426 | int cmp_id; | 426 | ptrdiff_t cmp_id; |
| 427 | EMACS_INT ignore, end; | 427 | EMACS_INT ignore, end; |
| 428 | 428 | ||
| 429 | if (find_composition (i, -1, &ignore, &end, &val, string) | 429 | if (find_composition (i, -1, &ignore, &end, &val, string) |
| @@ -451,7 +451,7 @@ lisp_string_width (Lisp_Object string, EMACS_INT precision, | |||
| 451 | { | 451 | { |
| 452 | val = DISP_CHAR_VECTOR (dp, c); | 452 | val = DISP_CHAR_VECTOR (dp, c); |
| 453 | if (VECTORP (val)) | 453 | if (VECTORP (val)) |
| 454 | thiswidth = ASIZE (val); | 454 | thiswidth = sanitize_char_width (ASIZE (val)); |
| 455 | else | 455 | else |
| 456 | thiswidth = CHAR_WIDTH (c); | 456 | thiswidth = CHAR_WIDTH (c); |
| 457 | } | 457 | } |
| @@ -902,7 +902,7 @@ usage: (string &rest CHARACTERS) */) | |||
| 902 | Lisp_Object str; | 902 | Lisp_Object str; |
| 903 | USE_SAFE_ALLOCA; | 903 | USE_SAFE_ALLOCA; |
| 904 | 904 | ||
| 905 | SAFE_ALLOCA (buf, unsigned char *, MAX_MULTIBYTE_LENGTH * n); | 905 | SAFE_NALLOCA (buf, MAX_MULTIBYTE_LENGTH, n); |
| 906 | p = buf; | 906 | p = buf; |
| 907 | 907 | ||
| 908 | for (i = 0; i < n; i++) | 908 | for (i = 0; i < n; i++) |
diff --git a/src/character.h b/src/character.h index 063b5147dc9..09bcf17ab96 100644 --- a/src/character.h +++ b/src/character.h | |||
| @@ -556,6 +556,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 556 | } while (0) | 556 | } while (0) |
| 557 | 557 | ||
| 558 | 558 | ||
| 559 | /* Return a non-outlandish value for the tab width. */ | ||
| 560 | |||
| 561 | #define SANE_TAB_WIDTH(buf) \ | ||
| 562 | sanitize_tab_width (XFASTINT (BVAR (buf, tab_width))) | ||
| 563 | static inline int | ||
| 564 | sanitize_tab_width (EMACS_INT width) | ||
| 565 | { | ||
| 566 | return 0 < width && width <= 1000 ? width : 8; | ||
| 567 | } | ||
| 568 | |||
| 559 | /* Return the width of ASCII character C. The width is measured by | 569 | /* Return the width of ASCII character C. The width is measured by |
| 560 | how many columns C will occupy on the screen when displayed in the | 570 | how many columns C will occupy on the screen when displayed in the |
| 561 | current buffer. */ | 571 | current buffer. */ |
| @@ -563,12 +573,20 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 563 | #define ASCII_CHAR_WIDTH(c) \ | 573 | #define ASCII_CHAR_WIDTH(c) \ |
| 564 | (c < 0x20 \ | 574 | (c < 0x20 \ |
| 565 | ? (c == '\t' \ | 575 | ? (c == '\t' \ |
| 566 | ? XFASTINT (BVAR (current_buffer, tab_width)) \ | 576 | ? SANE_TAB_WIDTH (current_buffer) \ |
| 567 | : (c == '\n' ? 0 : (NILP (BVAR (current_buffer, ctl_arrow)) ? 4 : 2))) \ | 577 | : (c == '\n' ? 0 : (NILP (BVAR (current_buffer, ctl_arrow)) ? 4 : 2))) \ |
| 568 | : (c < 0x7f \ | 578 | : (c < 0x7f \ |
| 569 | ? 1 \ | 579 | ? 1 \ |
| 570 | : ((NILP (BVAR (current_buffer, ctl_arrow)) ? 4 : 2)))) | 580 | : ((NILP (BVAR (current_buffer, ctl_arrow)) ? 4 : 2)))) |
| 571 | 581 | ||
| 582 | /* Return a non-outlandish value for a character width. */ | ||
| 583 | |||
| 584 | static inline int | ||
| 585 | sanitize_char_width (EMACS_INT width) | ||
| 586 | { | ||
| 587 | return 0 <= width && width <= 1000 ? width : 1000; | ||
| 588 | } | ||
| 589 | |||
| 572 | /* Return the width of character C. The width is measured by how many | 590 | /* Return the width of character C. The width is measured by how many |
| 573 | columns C will occupy on the screen when displayed in the current | 591 | columns C will occupy on the screen when displayed in the current |
| 574 | buffer. */ | 592 | buffer. */ |
| @@ -576,7 +594,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 576 | #define CHAR_WIDTH(c) \ | 594 | #define CHAR_WIDTH(c) \ |
| 577 | (ASCII_CHAR_P (c) \ | 595 | (ASCII_CHAR_P (c) \ |
| 578 | ? ASCII_CHAR_WIDTH (c) \ | 596 | ? ASCII_CHAR_WIDTH (c) \ |
| 579 | : XINT (CHAR_TABLE_REF (Vchar_width_table, c))) | 597 | : sanitize_char_width (XINT (CHAR_TABLE_REF (Vchar_width_table, c)))) |
| 580 | 598 | ||
| 581 | /* If C is a variation selector, return the index numnber of the | 599 | /* If C is a variation selector, return the index numnber of the |
| 582 | variation selector (1..256). Otherwise, return 0. */ | 600 | variation selector (1..256). Otherwise, return 0. */ |
diff --git a/src/charset.c b/src/charset.c index 55234aa76aa..6967b9df611 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -61,7 +61,7 @@ Lisp_Object Vcharset_hash_table; | |||
| 61 | /* Table of struct charset. */ | 61 | /* Table of struct charset. */ |
| 62 | struct charset *charset_table; | 62 | struct charset *charset_table; |
| 63 | 63 | ||
| 64 | static int charset_table_size; | 64 | static ptrdiff_t charset_table_size; |
| 65 | static int charset_table_used; | 65 | static int charset_table_used; |
| 66 | 66 | ||
| 67 | Lisp_Object Qcharsetp; | 67 | Lisp_Object Qcharsetp; |
| @@ -419,7 +419,7 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries, | |||
| 419 | paying attention to comment character '#'. */ | 419 | paying attention to comment character '#'. */ |
| 420 | 420 | ||
| 421 | static inline unsigned | 421 | static inline unsigned |
| 422 | read_hex (FILE *fp, int *eof) | 422 | read_hex (FILE *fp, int *eof, int *overflow) |
| 423 | { | 423 | { |
| 424 | int c; | 424 | int c; |
| 425 | unsigned n; | 425 | unsigned n; |
| @@ -441,15 +441,16 @@ read_hex (FILE *fp, int *eof) | |||
| 441 | *eof = 1; | 441 | *eof = 1; |
| 442 | return 0; | 442 | return 0; |
| 443 | } | 443 | } |
| 444 | *eof = 0; | ||
| 445 | n = 0; | 444 | n = 0; |
| 446 | if (c == 'x') | 445 | while (isxdigit (c = getc (fp))) |
| 447 | while ((c = getc (fp)) != EOF && isxdigit (c)) | 446 | { |
| 447 | if (UINT_MAX >> 4 < n) | ||
| 448 | *overflow = 1; | ||
| 448 | n = ((n << 4) | 449 | n = ((n << 4) |
| 449 | | (c <= '9' ? c - '0' : c <= 'F' ? c - 'A' + 10 : c - 'a' + 10)); | 450 | | (c - ('0' <= c && c <= '9' ? '0' |
| 450 | else | 451 | : 'A' <= c && c <= 'F' ? 'A' - 10 |
| 451 | while ((c = getc (fp)) != EOF && isdigit (c)) | 452 | : 'a' - 10))); |
| 452 | n = (n * 10) + c - '0'; | 453 | } |
| 453 | if (c != EOF) | 454 | if (c != EOF) |
| 454 | ungetc (c, fp); | 455 | ungetc (c, fp); |
| 455 | return n; | 456 | return n; |
| @@ -479,7 +480,6 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int co | |||
| 479 | unsigned max_code = CHARSET_MAX_CODE (charset); | 480 | unsigned max_code = CHARSET_MAX_CODE (charset); |
| 480 | int fd; | 481 | int fd; |
| 481 | FILE *fp; | 482 | FILE *fp; |
| 482 | int eof; | ||
| 483 | Lisp_Object suffixes; | 483 | Lisp_Object suffixes; |
| 484 | struct charset_map_entries *head, *entries; | 484 | struct charset_map_entries *head, *entries; |
| 485 | int n_entries, count; | 485 | int n_entries, count; |
| @@ -504,22 +504,27 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int co | |||
| 504 | memset (entries, 0, sizeof (struct charset_map_entries)); | 504 | memset (entries, 0, sizeof (struct charset_map_entries)); |
| 505 | 505 | ||
| 506 | n_entries = 0; | 506 | n_entries = 0; |
| 507 | eof = 0; | ||
| 508 | while (1) | 507 | while (1) |
| 509 | { | 508 | { |
| 510 | unsigned from, to; | 509 | unsigned from, to, c; |
| 511 | int c; | ||
| 512 | int idx; | 510 | int idx; |
| 511 | int eof = 0, overflow = 0; | ||
| 513 | 512 | ||
| 514 | from = read_hex (fp, &eof); | 513 | from = read_hex (fp, &eof, &overflow); |
| 515 | if (eof) | 514 | if (eof) |
| 516 | break; | 515 | break; |
| 517 | if (getc (fp) == '-') | 516 | if (getc (fp) == '-') |
| 518 | to = read_hex (fp, &eof); | 517 | to = read_hex (fp, &eof, &overflow); |
| 519 | else | 518 | else |
| 520 | to = from; | 519 | to = from; |
| 521 | c = (int) read_hex (fp, &eof); | 520 | if (eof) |
| 521 | break; | ||
| 522 | c = read_hex (fp, &eof, &overflow); | ||
| 523 | if (eof) | ||
| 524 | break; | ||
| 522 | 525 | ||
| 526 | if (overflow) | ||
| 527 | continue; | ||
| 523 | if (from < min_code || to > max_code || from > to || c > MAX_CHAR) | 528 | if (from < min_code || to > max_code || from > to || c > MAX_CHAR) |
| 524 | continue; | 529 | continue; |
| 525 | 530 | ||
| @@ -1145,13 +1150,25 @@ usage: (define-charset-internal ...) */) | |||
| 1145 | hash_code); | 1150 | hash_code); |
| 1146 | if (charset_table_used == charset_table_size) | 1151 | if (charset_table_used == charset_table_size) |
| 1147 | { | 1152 | { |
| 1148 | struct charset *new_table | 1153 | /* Ensure that charset IDs fit into 'int' as well as into the |
| 1149 | = (struct charset *) xmalloc (sizeof (struct charset) | 1154 | restriction imposed by fixnums. Although the 'int' restriction |
| 1150 | * (charset_table_size + 16)); | 1155 | could be removed, too much other code would need altering; for |
| 1151 | memcpy (new_table, charset_table, | 1156 | example, the IDs are stuffed into struct |
| 1152 | sizeof (struct charset) * charset_table_size); | 1157 | coding_system.charbuf[i] entries, which are 'int'. */ |
| 1153 | charset_table_size += 16; | 1158 | int old_size = charset_table_size; |
| 1159 | struct charset *new_table = | ||
| 1160 | xpalloc (0, &charset_table_size, 1, | ||
| 1161 | min (INT_MAX, MOST_POSITIVE_FIXNUM), | ||
| 1162 | sizeof *charset_table); | ||
| 1163 | memcpy (new_table, charset_table, old_size * sizeof *new_table); | ||
| 1154 | charset_table = new_table; | 1164 | charset_table = new_table; |
| 1165 | /* FIXME: Doesn't this leak memory? The old charset_table becomes | ||
| 1166 | unreachable. It could be that this is intentional, because the | ||
| 1167 | old charset table may be in a dumped emacs, and reallocating such | ||
| 1168 | a table may not work. If the memory leak is intentional, a | ||
| 1169 | comment should be added to explain this. If not, the old | ||
| 1170 | charset_table should be freed, by passing it as the 1st argument | ||
| 1171 | to xpalloc and removing the memcpy. */ | ||
| 1155 | } | 1172 | } |
| 1156 | id = charset_table_used++; | 1173 | id = charset_table_used++; |
| 1157 | new_definition_p = 1; | 1174 | new_definition_p = 1; |
| @@ -2210,14 +2227,16 @@ struct charset_sort_data | |||
| 2210 | { | 2227 | { |
| 2211 | Lisp_Object charset; | 2228 | Lisp_Object charset; |
| 2212 | int id; | 2229 | int id; |
| 2213 | int priority; | 2230 | ptrdiff_t priority; |
| 2214 | }; | 2231 | }; |
| 2215 | 2232 | ||
| 2216 | static int | 2233 | static int |
| 2217 | charset_compare (const void *d1, const void *d2) | 2234 | charset_compare (const void *d1, const void *d2) |
| 2218 | { | 2235 | { |
| 2219 | const struct charset_sort_data *data1 = d1, *data2 = d2; | 2236 | const struct charset_sort_data *data1 = d1, *data2 = d2; |
| 2220 | return (data1->priority - data2->priority); | 2237 | if (data1->priority != data2->priority) |
| 2238 | return data1->priority < data2->priority ? -1 : 1; | ||
| 2239 | return 0; | ||
| 2221 | } | 2240 | } |
| 2222 | 2241 | ||
| 2223 | DEFUN ("sort-charsets", Fsort_charsets, Ssort_charsets, 1, 1, 0, | 2242 | DEFUN ("sort-charsets", Fsort_charsets, Ssort_charsets, 1, 1, 0, |
| @@ -2227,7 +2246,8 @@ See also `charset-priority-list' and `set-charset-priority'. */) | |||
| 2227 | (Lisp_Object charsets) | 2246 | (Lisp_Object charsets) |
| 2228 | { | 2247 | { |
| 2229 | Lisp_Object len = Flength (charsets); | 2248 | Lisp_Object len = Flength (charsets); |
| 2230 | int n = XFASTINT (len), i, j, done; | 2249 | ptrdiff_t n = XFASTINT (len), i, j; |
| 2250 | int done; | ||
| 2231 | Lisp_Object tail, elt, attrs; | 2251 | Lisp_Object tail, elt, attrs; |
| 2232 | struct charset_sort_data *sort_data; | 2252 | struct charset_sort_data *sort_data; |
| 2233 | int id, min_id = INT_MAX, max_id = INT_MIN; | 2253 | int id, min_id = INT_MAX, max_id = INT_MIN; |
| @@ -2235,7 +2255,7 @@ See also `charset-priority-list' and `set-charset-priority'. */) | |||
| 2235 | 2255 | ||
| 2236 | if (n == 0) | 2256 | if (n == 0) |
| 2237 | return Qnil; | 2257 | return Qnil; |
| 2238 | SAFE_ALLOCA (sort_data, struct charset_sort_data *, sizeof (*sort_data) * n); | 2258 | SAFE_NALLOCA (sort_data, 1, n); |
| 2239 | for (tail = charsets, i = 0; CONSP (tail); tail = XCDR (tail), i++) | 2259 | for (tail = charsets, i = 0; CONSP (tail); tail = XCDR (tail), i++) |
| 2240 | { | 2260 | { |
| 2241 | elt = XCAR (tail); | 2261 | elt = XCAR (tail); |
| @@ -2310,6 +2330,17 @@ init_charset_once (void) | |||
| 2310 | void | 2330 | void |
| 2311 | syms_of_charset (void) | 2331 | syms_of_charset (void) |
| 2312 | { | 2332 | { |
| 2333 | /* Allocate an initial charset table that is just under 64 KiB in size. | ||
| 2334 | This should be large enough so that the charset table need not be | ||
| 2335 | reallocated during an initial bootstrap. Allocating anything larger than | ||
| 2336 | 64 KiB in an initial run may not work, because glibc malloc might use | ||
| 2337 | mmap for larger allocations, and these don't work well across dumped | ||
| 2338 | systems. */ | ||
| 2339 | enum { | ||
| 2340 | initial_malloc_max = (1 << 16) - 1, | ||
| 2341 | charset_table_size_init = initial_malloc_max / sizeof (struct charset) | ||
| 2342 | }; | ||
| 2343 | |||
| 2313 | DEFSYM (Qcharsetp, "charsetp"); | 2344 | DEFSYM (Qcharsetp, "charsetp"); |
| 2314 | 2345 | ||
| 2315 | DEFSYM (Qascii, "ascii"); | 2346 | DEFSYM (Qascii, "ascii"); |
| @@ -2342,9 +2373,9 @@ syms_of_charset (void) | |||
| 2342 | Vcharset_hash_table = Fmake_hash_table (2, args); | 2373 | Vcharset_hash_table = Fmake_hash_table (2, args); |
| 2343 | } | 2374 | } |
| 2344 | 2375 | ||
| 2345 | charset_table_size = 128; | 2376 | charset_table = (struct charset *) xmalloc (sizeof (struct charset) |
| 2346 | charset_table = ((struct charset *) | 2377 | * charset_table_size_init); |
| 2347 | xmalloc (sizeof (struct charset) * charset_table_size)); | 2378 | charset_table_size = charset_table_size_init; |
| 2348 | charset_table_used = 0; | 2379 | charset_table_used = 0; |
| 2349 | 2380 | ||
| 2350 | defsubr (&Scharsetp); | 2381 | defsubr (&Scharsetp); |
diff --git a/src/charset.h b/src/charset.h index c2a52a38e7e..be02bc0feae 100644 --- a/src/charset.h +++ b/src/charset.h | |||
| @@ -148,7 +148,7 @@ struct charset | |||
| 148 | int id; | 148 | int id; |
| 149 | 149 | ||
| 150 | /* Index to Vcharset_hash_table. */ | 150 | /* Index to Vcharset_hash_table. */ |
| 151 | EMACS_INT hash_index; | 151 | ptrdiff_t hash_index; |
| 152 | 152 | ||
| 153 | /* Dimension of the charset: 1, 2, 3, or 4. */ | 153 | /* Dimension of the charset: 1, 2, 3, or 4. */ |
| 154 | int dimension; | 154 | int dimension; |
| @@ -341,7 +341,7 @@ extern int emacs_mule_charset[256]; | |||
| 341 | number of the charset. Otherwise, signal an error. */ | 341 | number of the charset. Otherwise, signal an error. */ |
| 342 | #define CHECK_CHARSET_GET_ID(x, id) \ | 342 | #define CHECK_CHARSET_GET_ID(x, id) \ |
| 343 | do { \ | 343 | do { \ |
| 344 | int idx; \ | 344 | ptrdiff_t idx; \ |
| 345 | \ | 345 | \ |
| 346 | if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0) \ | 346 | if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0) \ |
| 347 | wrong_type_argument (Qcharsetp, (x)); \ | 347 | wrong_type_argument (Qcharsetp, (x)); \ |
diff --git a/src/chartab.c b/src/chartab.c index efe23eca83f..1d4ac04312a 100644 --- a/src/chartab.c +++ b/src/chartab.c | |||
| @@ -589,8 +589,6 @@ DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot, | |||
| 589 | (Lisp_Object char_table, Lisp_Object n, Lisp_Object value) | 589 | (Lisp_Object char_table, Lisp_Object n, Lisp_Object value) |
| 590 | { | 590 | { |
| 591 | CHECK_CHAR_TABLE (char_table); | 591 | CHECK_CHAR_TABLE (char_table); |
| 592 | if (EQ (XCHAR_TABLE (char_table)->purpose, Qchar_code_property_table)) | ||
| 593 | error ("Can't change extra-slot of char-code-property-table"); | ||
| 594 | CHECK_NUMBER (n); | 592 | CHECK_NUMBER (n); |
| 595 | if (XINT (n) < 0 | 593 | if (XINT (n) < 0 |
| 596 | || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table))) | 594 | || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table))) |
| @@ -1095,22 +1093,31 @@ map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), | |||
| 1095 | 1093 | ||
| 1096 | /* Unicode character property tables. | 1094 | /* Unicode character property tables. |
| 1097 | 1095 | ||
| 1098 | This section provides a convenient and efficient way to get a | 1096 | This section provides a convenient and efficient way to get Unicode |
| 1099 | Unicode character property from C code (from Lisp, you must use | 1097 | character properties of characters from C code (from Lisp, you must |
| 1100 | get-char-code-property). | 1098 | use get-char-code-property). |
| 1101 | 1099 | ||
| 1102 | The typical usage is to get a char-table for a specific property at | 1100 | The typical usage is to get a char-table object for a specific |
| 1103 | a proper initialization time as this: | 1101 | property like this (use of the "bidi-class" property below is just |
| 1102 | an example): | ||
| 1104 | 1103 | ||
| 1105 | Lisp_Object bidi_class_table = uniprop_table (intern ("bidi-class")); | 1104 | Lisp_Object bidi_class_table = uniprop_table (intern ("bidi-class")); |
| 1106 | 1105 | ||
| 1107 | and get a property value for character CH as this: | 1106 | (uniprop_table can return nil if it fails to find data for the |
| 1107 | named property, or if it fails to load the appropriate Lisp support | ||
| 1108 | file, so the return value should be tested to be non-nil, before it | ||
| 1109 | is used.) | ||
| 1108 | 1110 | ||
| 1109 | Lisp_Object bidi_class = CHAR_TABLE_REF (CH, bidi_class_table); | 1111 | To get a property value for character CH use CHAR_TABLE_REF: |
| 1112 | |||
| 1113 | Lisp_Object bidi_class = CHAR_TABLE_REF (bidi_class_table, CH); | ||
| 1110 | 1114 | ||
| 1111 | In this case, what you actually get is an index number to the | 1115 | In this case, what you actually get is an index number to the |
| 1112 | vector of property values (symbols nil, L, R, etc). | 1116 | vector of property values (symbols nil, L, R, etc). |
| 1113 | 1117 | ||
| 1118 | The full list of Unicode character properties supported by Emacs is | ||
| 1119 | documented in the ELisp manual, in the node "Character Properties". | ||
| 1120 | |||
| 1114 | A table for Unicode character property has these characteristics: | 1121 | A table for Unicode character property has these characteristics: |
| 1115 | 1122 | ||
| 1116 | o The purpose is `char-code-property-table', which implies that the | 1123 | o The purpose is `char-code-property-table', which implies that the |
| @@ -1122,7 +1129,7 @@ map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), | |||
| 1122 | means that we don't have to decode values. | 1129 | means that we don't have to decode values. |
| 1123 | 1130 | ||
| 1124 | o The third extra slot is a Lisp function, an index (integer) to | 1131 | o The third extra slot is a Lisp function, an index (integer) to |
| 1125 | the array uniprop_enncoder[], or nil. If it is a Lisp function, we | 1132 | the array uniprop_encoder[], or nil. If it is a Lisp function, we |
| 1126 | can't use such a table from C (at the moment). If it is nil, it | 1133 | can't use such a table from C (at the moment). If it is nil, it |
| 1127 | means that we don't have to encode values. */ | 1134 | means that we don't have to encode values. */ |
| 1128 | 1135 | ||
| @@ -1310,7 +1317,7 @@ uniprop_get_encoder (Lisp_Object table) | |||
| 1310 | function may load a Lisp file and thus may cause | 1317 | function may load a Lisp file and thus may cause |
| 1311 | garbage-collection. */ | 1318 | garbage-collection. */ |
| 1312 | 1319 | ||
| 1313 | static Lisp_Object | 1320 | Lisp_Object |
| 1314 | uniprop_table (Lisp_Object prop) | 1321 | uniprop_table (Lisp_Object prop) |
| 1315 | { | 1322 | { |
| 1316 | Lisp_Object val, table, result; | 1323 | Lisp_Object val, table, result; |
diff --git a/src/cmds.c b/src/cmds.c index f49cfc221be..5a155ac77a5 100644 --- a/src/cmds.c +++ b/src/cmds.c | |||
| @@ -271,7 +271,8 @@ Whichever character you type to run this command is inserted. | |||
| 271 | Before insertion, `expand-abbrev' is executed if the inserted character does | 271 | Before insertion, `expand-abbrev' is executed if the inserted character does |
| 272 | not have word syntax and the previous character in the buffer does. | 272 | not have word syntax and the previous character in the buffer does. |
| 273 | After insertion, the value of `auto-fill-function' is called if the | 273 | After insertion, the value of `auto-fill-function' is called if the |
| 274 | `auto-fill-chars' table has a non-nil value for the inserted character. */) | 274 | `auto-fill-chars' table has a non-nil value for the inserted character. |
| 275 | At the end, it runs `post-self-insert-hook'. */) | ||
| 275 | (Lisp_Object n) | 276 | (Lisp_Object n) |
| 276 | { | 277 | { |
| 277 | int remove_boundary = 1; | 278 | int remove_boundary = 1; |
| @@ -471,7 +472,7 @@ internal_self_insert (int c, EMACS_INT n) | |||
| 471 | { | 472 | { |
| 472 | USE_SAFE_ALLOCA; | 473 | USE_SAFE_ALLOCA; |
| 473 | char *strn, *p; | 474 | char *strn, *p; |
| 474 | SAFE_ALLOCA (strn, char *, n * len); | 475 | SAFE_NALLOCA (strn, len, n); |
| 475 | for (p = strn; n > 0; n--, p += len) | 476 | for (p = strn; n > 0; n--, p += len) |
| 476 | memcpy (p, str, len); | 477 | memcpy (p, str, len); |
| 477 | insert_and_inherit (strn, p - strn); | 478 | insert_and_inherit (strn, p - strn); |
diff --git a/src/coding.c b/src/coding.c index 65c8a767c2b..5fd59d394d9 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -5838,7 +5838,7 @@ coding_charset_list (struct coding_system *coding) | |||
| 5838 | Lisp_Object | 5838 | Lisp_Object |
| 5839 | coding_system_charset_list (Lisp_Object coding_system) | 5839 | coding_system_charset_list (Lisp_Object coding_system) |
| 5840 | { | 5840 | { |
| 5841 | int id; | 5841 | ptrdiff_t id; |
| 5842 | Lisp_Object attrs, charset_list; | 5842 | Lisp_Object attrs, charset_list; |
| 5843 | 5843 | ||
| 5844 | CHECK_CODING_SYSTEM_GET_ID (coding_system, id); | 5844 | CHECK_CODING_SYSTEM_GET_ID (coding_system, id); |
| @@ -6683,8 +6683,12 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6683 | break; | 6683 | break; |
| 6684 | } | 6684 | } |
| 6685 | 6685 | ||
| 6686 | if (dst + MAX_MULTIBYTE_LENGTH * to_nchars > dst_end) | 6686 | if ((dst_end - dst) / MAX_MULTIBYTE_LENGTH < to_nchars) |
| 6687 | { | 6687 | { |
| 6688 | if (((min (PTRDIFF_MAX, SIZE_MAX) - (buf_end - buf)) | ||
| 6689 | / MAX_MULTIBYTE_LENGTH) | ||
| 6690 | < to_nchars) | ||
| 6691 | memory_full (SIZE_MAX); | ||
| 6688 | dst = alloc_destination (coding, | 6692 | dst = alloc_destination (coding, |
| 6689 | buf_end - buf | 6693 | buf_end - buf |
| 6690 | + MAX_MULTIBYTE_LENGTH * to_nchars, | 6694 | + MAX_MULTIBYTE_LENGTH * to_nchars, |
| @@ -7888,11 +7892,10 @@ encode_coding_object (struct coding_system *coding, | |||
| 7888 | } | 7892 | } |
| 7889 | else if (EQ (dst_object, Qt)) | 7893 | else if (EQ (dst_object, Qt)) |
| 7890 | { | 7894 | { |
| 7895 | ptrdiff_t dst_bytes = max (1, coding->src_chars); | ||
| 7891 | coding->dst_object = Qnil; | 7896 | coding->dst_object = Qnil; |
| 7892 | coding->dst_bytes = coding->src_chars; | 7897 | coding->destination = (unsigned char *) xmalloc (dst_bytes); |
| 7893 | if (coding->dst_bytes == 0) | 7898 | coding->dst_bytes = dst_bytes; |
| 7894 | coding->dst_bytes = 1; | ||
| 7895 | coding->destination = (unsigned char *) xmalloc (coding->dst_bytes); | ||
| 7896 | coding->dst_multibyte = 0; | 7899 | coding->dst_multibyte = 0; |
| 7897 | } | 7900 | } |
| 7898 | else | 7901 | else |
| @@ -8076,7 +8079,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8076 | Lisp_Object attrs, eol_type; | 8079 | Lisp_Object attrs, eol_type; |
| 8077 | Lisp_Object val = Qnil; | 8080 | Lisp_Object val = Qnil; |
| 8078 | struct coding_system coding; | 8081 | struct coding_system coding; |
| 8079 | int id; | 8082 | ptrdiff_t id; |
| 8080 | struct coding_detection_info detect_info; | 8083 | struct coding_detection_info detect_info; |
| 8081 | enum coding_category base_category; | 8084 | enum coding_category base_category; |
| 8082 | int null_byte_found = 0, eight_bit_found = 0; | 8085 | int null_byte_found = 0, eight_bit_found = 0; |
diff --git a/src/coding.h b/src/coding.h index 85e153dcc3a..fdf9b762e75 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -415,7 +415,7 @@ struct coding_system | |||
| 415 | setup_coding_system. At the early stage of building time, this | 415 | setup_coding_system. At the early stage of building time, this |
| 416 | value is -1 in the array coding_categories to indicate that no | 416 | value is -1 in the array coding_categories to indicate that no |
| 417 | coding-system of that category is yet defined. */ | 417 | coding-system of that category is yet defined. */ |
| 418 | int id; | 418 | ptrdiff_t id; |
| 419 | 419 | ||
| 420 | /* Flag bits of the coding system. The meaning of each bit is common | 420 | /* Flag bits of the coding system. The meaning of each bit is common |
| 421 | to all types of coding systems. */ | 421 | to all types of coding systems. */ |
diff --git a/src/composite.c b/src/composite.c index d402d5ad0c4..2a3fbe29552 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -142,10 +142,10 @@ Lisp_Object Qcomposition; | |||
| 142 | struct composition **composition_table; | 142 | struct composition **composition_table; |
| 143 | 143 | ||
| 144 | /* The current size of `composition_table'. */ | 144 | /* The current size of `composition_table'. */ |
| 145 | static int composition_table_size; | 145 | static ptrdiff_t composition_table_size; |
| 146 | 146 | ||
| 147 | /* Number of compositions currently made. */ | 147 | /* Number of compositions currently made. */ |
| 148 | int n_compositions; | 148 | ptrdiff_t n_compositions; |
| 149 | 149 | ||
| 150 | /* Hash table for compositions. The key is COMPONENTS-VEC of | 150 | /* Hash table for compositions. The key is COMPONENTS-VEC of |
| 151 | `composition' property. The value is the corresponding | 151 | `composition' property. The value is the corresponding |
| @@ -172,19 +172,30 @@ Lisp_Object composition_temp; | |||
| 172 | 172 | ||
| 173 | If the composition is invalid, return -1. */ | 173 | If the composition is invalid, return -1. */ |
| 174 | 174 | ||
| 175 | int | 175 | ptrdiff_t |
| 176 | get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, | 176 | get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, |
| 177 | Lisp_Object prop, Lisp_Object string) | 177 | Lisp_Object prop, Lisp_Object string) |
| 178 | { | 178 | { |
| 179 | Lisp_Object id, length, components, key, *key_contents; | 179 | Lisp_Object id, length, components, key, *key_contents; |
| 180 | int glyph_len; | 180 | ptrdiff_t glyph_len; |
| 181 | struct Lisp_Hash_Table *hash_table = XHASH_TABLE (composition_hash_table); | 181 | struct Lisp_Hash_Table *hash_table = XHASH_TABLE (composition_hash_table); |
| 182 | EMACS_INT hash_index; | 182 | ptrdiff_t hash_index; |
| 183 | EMACS_UINT hash_code; | 183 | EMACS_UINT hash_code; |
| 184 | enum composition_method method; | ||
| 184 | struct composition *cmp; | 185 | struct composition *cmp; |
| 185 | EMACS_INT i; | 186 | EMACS_INT i; |
| 186 | int ch; | 187 | int ch; |
| 187 | 188 | ||
| 189 | /* Maximum length of a string of glyphs. XftGlyphExtents limits | ||
| 190 | this to INT_MAX, and Emacs limits it further. Divide INT_MAX - 1 | ||
| 191 | by 2 because x_produce_glyphs computes glyph_len * 2 + 1. Divide | ||
| 192 | the size by MAX_MULTIBYTE_LENGTH because encode_terminal_code | ||
| 193 | multiplies glyph_len by MAX_MULTIBYTE_LENGTH. */ | ||
| 194 | enum { | ||
| 195 | GLYPH_LEN_MAX = min ((INT_MAX - 1) / 2, | ||
| 196 | min (PTRDIFF_MAX, SIZE_MAX) / MAX_MULTIBYTE_LENGTH) | ||
| 197 | }; | ||
| 198 | |||
| 188 | /* PROP should be | 199 | /* PROP should be |
| 189 | Form-A: ((LENGTH . COMPONENTS) . MODIFICATION-FUNC) | 200 | Form-A: ((LENGTH . COMPONENTS) . MODIFICATION-FUNC) |
| 190 | or | 201 | or |
| @@ -258,21 +269,9 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, | |||
| 258 | /* This composition is a new one. We must register it. */ | 269 | /* This composition is a new one. We must register it. */ |
| 259 | 270 | ||
| 260 | /* Check if we have sufficient memory to store this information. */ | 271 | /* Check if we have sufficient memory to store this information. */ |
| 261 | if (composition_table_size == 0) | 272 | if (composition_table_size <= n_compositions) |
| 262 | { | 273 | composition_table = xpalloc (composition_table, &composition_table_size, |
| 263 | composition_table_size = 256; | 274 | 1, -1, sizeof *composition_table); |
| 264 | composition_table | ||
| 265 | = (struct composition **) xmalloc (sizeof (composition_table[0]) | ||
| 266 | * composition_table_size); | ||
| 267 | } | ||
| 268 | else if (composition_table_size <= n_compositions) | ||
| 269 | { | ||
| 270 | composition_table_size += 256; | ||
| 271 | composition_table | ||
| 272 | = (struct composition **) xrealloc (composition_table, | ||
| 273 | sizeof (composition_table[0]) | ||
| 274 | * composition_table_size); | ||
| 275 | } | ||
| 276 | 275 | ||
| 277 | key_contents = XVECTOR (key)->contents; | 276 | key_contents = XVECTOR (key)->contents; |
| 278 | 277 | ||
| @@ -316,20 +315,26 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, | |||
| 316 | /* Register the composition in composition_hash_table. */ | 315 | /* Register the composition in composition_hash_table. */ |
| 317 | hash_index = hash_put (hash_table, key, id, hash_code); | 316 | hash_index = hash_put (hash_table, key, id, hash_code); |
| 318 | 317 | ||
| 318 | method = (NILP (components) | ||
| 319 | ? COMPOSITION_RELATIVE | ||
| 320 | : ((INTEGERP (components) || STRINGP (components)) | ||
| 321 | ? COMPOSITION_WITH_ALTCHARS | ||
| 322 | : COMPOSITION_WITH_RULE_ALTCHARS)); | ||
| 323 | |||
| 324 | glyph_len = (method == COMPOSITION_WITH_RULE_ALTCHARS | ||
| 325 | ? (ASIZE (key) + 1) / 2 | ||
| 326 | : ASIZE (key)); | ||
| 327 | |||
| 328 | if (GLYPH_LEN_MAX < glyph_len) | ||
| 329 | memory_full (SIZE_MAX); | ||
| 330 | |||
| 319 | /* Register the composition in composition_table. */ | 331 | /* Register the composition in composition_table. */ |
| 320 | cmp = (struct composition *) xmalloc (sizeof (struct composition)); | 332 | cmp = (struct composition *) xmalloc (sizeof (struct composition)); |
| 321 | 333 | ||
| 322 | cmp->method = (NILP (components) | 334 | cmp->method = method; |
| 323 | ? COMPOSITION_RELATIVE | ||
| 324 | : ((INTEGERP (components) || STRINGP (components)) | ||
| 325 | ? COMPOSITION_WITH_ALTCHARS | ||
| 326 | : COMPOSITION_WITH_RULE_ALTCHARS)); | ||
| 327 | cmp->hash_index = hash_index; | 335 | cmp->hash_index = hash_index; |
| 328 | glyph_len = (cmp->method == COMPOSITION_WITH_RULE_ALTCHARS | ||
| 329 | ? (ASIZE (key) + 1) / 2 | ||
| 330 | : ASIZE (key)); | ||
| 331 | cmp->glyph_len = glyph_len; | 336 | cmp->glyph_len = glyph_len; |
| 332 | cmp->offsets = (short *) xmalloc (sizeof (short) * glyph_len * 2); | 337 | cmp->offsets = xnmalloc (glyph_len, 2 * sizeof *cmp->offsets); |
| 333 | cmp->font = NULL; | 338 | cmp->font = NULL; |
| 334 | 339 | ||
| 335 | if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS) | 340 | if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS) |
| @@ -656,7 +661,7 @@ static Lisp_Object | |||
| 656 | gstring_lookup_cache (Lisp_Object header) | 661 | gstring_lookup_cache (Lisp_Object header) |
| 657 | { | 662 | { |
| 658 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); | 663 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); |
| 659 | EMACS_INT i = hash_lookup (h, header, NULL); | 664 | ptrdiff_t i = hash_lookup (h, header, NULL); |
| 660 | 665 | ||
| 661 | return (i >= 0 ? HASH_VALUE (h, i) : Qnil); | 666 | return (i >= 0 ? HASH_VALUE (h, i) : Qnil); |
| 662 | } | 667 | } |
| @@ -691,7 +696,7 @@ composition_gstring_put_cache (Lisp_Object gstring, EMACS_INT len) | |||
| 691 | } | 696 | } |
| 692 | 697 | ||
| 693 | Lisp_Object | 698 | Lisp_Object |
| 694 | composition_gstring_from_id (int id) | 699 | composition_gstring_from_id (ptrdiff_t id) |
| 695 | { | 700 | { |
| 696 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); | 701 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); |
| 697 | 702 | ||
| @@ -960,8 +965,6 @@ autocmp_chars (Lisp_Object rule, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT | |||
| 960 | args[4] = font_object; | 965 | args[4] = font_object; |
| 961 | args[5] = string; | 966 | args[5] = string; |
| 962 | lgstring = safe_call (6, args); | 967 | lgstring = safe_call (6, args); |
| 963 | if (NILP (string)) | ||
| 964 | TEMP_SET_PT_BOTH (pt, pt_byte); | ||
| 965 | } | 968 | } |
| 966 | return unbind_to (count, lgstring); | 969 | return unbind_to (count, lgstring); |
| 967 | } | 970 | } |
diff --git a/src/composite.h b/src/composite.h index 8cedfdbe352..c57e2a0e9b3 100644 --- a/src/composite.h +++ b/src/composite.h | |||
| @@ -170,7 +170,7 @@ extern Lisp_Object composition_temp; | |||
| 170 | 170 | ||
| 171 | struct composition { | 171 | struct composition { |
| 172 | /* Number of glyphs of the composition components. */ | 172 | /* Number of glyphs of the composition components. */ |
| 173 | unsigned glyph_len; | 173 | int glyph_len; |
| 174 | 174 | ||
| 175 | /* Width, ascent, and descent pixels of the composition. */ | 175 | /* Width, ascent, and descent pixels of the composition. */ |
| 176 | short pixel_width, ascent, descent; | 176 | short pixel_width, ascent, descent; |
| @@ -193,7 +193,7 @@ struct composition { | |||
| 193 | void *font; | 193 | void *font; |
| 194 | 194 | ||
| 195 | /* Pointer to an array of x-offset and y-offset (by pixels) of | 195 | /* Pointer to an array of x-offset and y-offset (by pixels) of |
| 196 | glyphs. This points to a sufficient memory space (sizeof (int) * | 196 | glyphs. This points to a sufficient memory space (sizeof (short) * |
| 197 | glyph_len * 2) that is allocated when the composition is | 197 | glyph_len * 2) that is allocated when the composition is |
| 198 | registered in composition_table. X-offset and Y-offset of Nth | 198 | registered in composition_table. X-offset and Y-offset of Nth |
| 199 | glyph are (2N)th and (2N+1)th elements respectively. */ | 199 | glyph are (2N)th and (2N+1)th elements respectively. */ |
| @@ -204,7 +204,7 @@ struct composition { | |||
| 204 | COMPOSITION-ID. */ | 204 | COMPOSITION-ID. */ |
| 205 | extern struct composition **composition_table; | 205 | extern struct composition **composition_table; |
| 206 | /* Number of the currently registered compositions. */ | 206 | /* Number of the currently registered compositions. */ |
| 207 | extern int n_compositions; | 207 | extern ptrdiff_t n_compositions; |
| 208 | 208 | ||
| 209 | /* Mask bits for CHECK_MASK arg to update_compositions. | 209 | /* Mask bits for CHECK_MASK arg to update_compositions. |
| 210 | For a change in the region FROM and TO, check compositions ... */ | 210 | For a change in the region FROM and TO, check compositions ... */ |
| @@ -216,8 +216,8 @@ extern int n_compositions; | |||
| 216 | 216 | ||
| 217 | extern Lisp_Object Qcomposition; | 217 | extern Lisp_Object Qcomposition; |
| 218 | extern Lisp_Object composition_hash_table; | 218 | extern Lisp_Object composition_hash_table; |
| 219 | extern int get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT, | 219 | extern ptrdiff_t get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT, |
| 220 | Lisp_Object, Lisp_Object); | 220 | Lisp_Object, Lisp_Object); |
| 221 | extern int find_composition (EMACS_INT, EMACS_INT, EMACS_INT *, EMACS_INT *, | 221 | extern int find_composition (EMACS_INT, EMACS_INT, EMACS_INT *, EMACS_INT *, |
| 222 | Lisp_Object *, Lisp_Object); | 222 | Lisp_Object *, Lisp_Object); |
| 223 | extern void update_compositions (EMACS_INT, EMACS_INT, int); | 223 | extern void update_compositions (EMACS_INT, EMACS_INT, int); |
| @@ -299,7 +299,7 @@ struct face; | |||
| 299 | struct font_metrics; | 299 | struct font_metrics; |
| 300 | 300 | ||
| 301 | extern Lisp_Object composition_gstring_put_cache (Lisp_Object, EMACS_INT); | 301 | extern Lisp_Object composition_gstring_put_cache (Lisp_Object, EMACS_INT); |
| 302 | extern Lisp_Object composition_gstring_from_id (int); | 302 | extern Lisp_Object composition_gstring_from_id (ptrdiff_t); |
| 303 | extern int composition_gstring_p (Lisp_Object); | 303 | extern int composition_gstring_p (Lisp_Object); |
| 304 | extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT, | 304 | extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT, |
| 305 | struct font_metrics *); | 305 | struct font_metrics *); |
diff --git a/src/deps.mk b/src/deps.mk index 080144ae1e5..c61b01a95c4 100644 --- a/src/deps.mk +++ b/src/deps.mk | |||
| @@ -39,7 +39,7 @@ | |||
| 39 | atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \ | 39 | atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \ |
| 40 | globals.h ../lib/unistd.h $(config_h) | 40 | globals.h ../lib/unistd.h $(config_h) |
| 41 | bidi.o: bidi.c buffer.h character.h dispextern.h msdos.h lisp.h \ | 41 | bidi.o: bidi.c buffer.h character.h dispextern.h msdos.h lisp.h \ |
| 42 | biditype.h bidimirror.h globals.h $(config_h) | 42 | globals.h $(config_h) |
| 43 | buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \ | 43 | buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \ |
| 44 | $(INTERVALS_H) blockinput.h atimer.h systime.h character.h ../lib/unistd.h \ | 44 | $(INTERVALS_H) blockinput.h atimer.h systime.h character.h ../lib/unistd.h \ |
| 45 | indent.h keyboard.h coding.h keymap.h frame.h lisp.h globals.h $(config_h) | 45 | indent.h keyboard.h coding.h keymap.h frame.h lisp.h globals.h $(config_h) |
diff --git a/src/dispextern.h b/src/dispextern.h index dc44c698164..831803f58f4 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -575,7 +575,7 @@ struct glyph_pool | |||
| 575 | struct glyph *glyphs; | 575 | struct glyph *glyphs; |
| 576 | 576 | ||
| 577 | /* Allocated size of `glyphs'. */ | 577 | /* Allocated size of `glyphs'. */ |
| 578 | int nglyphs; | 578 | ptrdiff_t nglyphs; |
| 579 | 579 | ||
| 580 | /* Number of rows and columns in a matrix. */ | 580 | /* Number of rows and columns in a matrix. */ |
| 581 | int nrows, ncolumns; | 581 | int nrows, ncolumns; |
| @@ -625,7 +625,7 @@ struct glyph_matrix | |||
| 625 | struct glyph_row *rows; | 625 | struct glyph_row *rows; |
| 626 | 626 | ||
| 627 | /* Number of elements allocated for the vector rows above. */ | 627 | /* Number of elements allocated for the vector rows above. */ |
| 628 | int rows_allocated; | 628 | ptrdiff_t rows_allocated; |
| 629 | 629 | ||
| 630 | /* The number of rows used by the window if all lines were displayed | 630 | /* The number of rows used by the window if all lines were displayed |
| 631 | with the smallest possible character height. */ | 631 | with the smallest possible character height. */ |
| @@ -1240,7 +1240,7 @@ struct glyph_string | |||
| 1240 | struct composition *cmp; | 1240 | struct composition *cmp; |
| 1241 | 1241 | ||
| 1242 | /* If not negative, this string describes a compos. */ | 1242 | /* If not negative, this string describes a compos. */ |
| 1243 | int cmp_id; | 1243 | ptrdiff_t cmp_id; |
| 1244 | 1244 | ||
| 1245 | /* Start and end glyph indices in a glyph-string. */ | 1245 | /* Start and end glyph indices in a glyph-string. */ |
| 1246 | int cmp_from, cmp_to; | 1246 | int cmp_from, cmp_to; |
| @@ -1708,7 +1708,8 @@ struct face_cache | |||
| 1708 | struct face **faces_by_id; | 1708 | struct face **faces_by_id; |
| 1709 | 1709 | ||
| 1710 | /* The allocated size, and number of used slots of faces_by_id. */ | 1710 | /* The allocated size, and number of used slots of faces_by_id. */ |
| 1711 | int size, used; | 1711 | ptrdiff_t size; |
| 1712 | int used; | ||
| 1712 | 1713 | ||
| 1713 | /* Flag indicating that attributes of the `menu' face have been | 1714 | /* Flag indicating that attributes of the `menu' face have been |
| 1714 | changed. */ | 1715 | changed. */ |
| @@ -1776,7 +1777,7 @@ extern int face_change_count; | |||
| 1776 | 3 bits for it, so we cannot use there values larger than 7. | 1777 | 3 bits for it, so we cannot use there values larger than 7. |
| 1777 | 1778 | ||
| 1778 | The order of members must be in sync with the 8th element of the | 1779 | The order of members must be in sync with the 8th element of the |
| 1779 | member of unidata-prop-alist (in admin/unidata/unidata-getn.el) for | 1780 | member of unidata-prop-alist (in admin/unidata/unidata-gen.el) for |
| 1780 | Unicode character property `bidi-class'. */ | 1781 | Unicode character property `bidi-class'. */ |
| 1781 | typedef enum { | 1782 | typedef enum { |
| 1782 | UNKNOWN_BT = 0, | 1783 | UNKNOWN_BT = 0, |
| @@ -1859,6 +1860,10 @@ struct bidi_it { | |||
| 1859 | EMACS_INT ignore_bn_limit; /* position until which to ignore BNs */ | 1860 | EMACS_INT ignore_bn_limit; /* position until which to ignore BNs */ |
| 1860 | bidi_dir_t sor; /* direction of start-of-run in effect */ | 1861 | bidi_dir_t sor; /* direction of start-of-run in effect */ |
| 1861 | int scan_dir; /* direction of text scan, 1: forw, -1: back */ | 1862 | int scan_dir; /* direction of text scan, 1: forw, -1: back */ |
| 1863 | EMACS_INT disp_pos; /* position of display string after ch */ | ||
| 1864 | int disp_prop; /* if non-zero, there really is a | ||
| 1865 | `display' property/string at disp_pos; | ||
| 1866 | if 2, the property is a `space' spec */ | ||
| 1862 | int stack_idx; /* index of current data on the stack */ | 1867 | int stack_idx; /* index of current data on the stack */ |
| 1863 | /* Note: Everything from here on is not copied/saved when the bidi | 1868 | /* Note: Everything from here on is not copied/saved when the bidi |
| 1864 | iterator state is saved, pushed, or popped. So only put here | 1869 | iterator state is saved, pushed, or popped. So only put here |
| @@ -1867,7 +1872,6 @@ struct bidi_it { | |||
| 1867 | struct bidi_string_data string; /* string to reorder */ | 1872 | struct bidi_string_data string; /* string to reorder */ |
| 1868 | bidi_dir_t paragraph_dir; /* current paragraph direction */ | 1873 | bidi_dir_t paragraph_dir; /* current paragraph direction */ |
| 1869 | EMACS_INT separator_limit; /* where paragraph separator should end */ | 1874 | EMACS_INT separator_limit; /* where paragraph separator should end */ |
| 1870 | EMACS_INT disp_pos; /* position of display string after ch */ | ||
| 1871 | unsigned first_elt : 1; /* if non-zero, examine current char first */ | 1875 | unsigned first_elt : 1; /* if non-zero, examine current char first */ |
| 1872 | unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */ | 1876 | unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */ |
| 1873 | unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */ | 1877 | unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */ |
| @@ -2056,7 +2060,7 @@ struct composition_it | |||
| 2056 | EMACS_INT stop_pos; | 2060 | EMACS_INT stop_pos; |
| 2057 | /* ID number of the composition or glyph-string. If negative, we | 2061 | /* ID number of the composition or glyph-string. If negative, we |
| 2058 | are not iterating over a composition now. */ | 2062 | are not iterating over a composition now. */ |
| 2059 | int id; | 2063 | ptrdiff_t id; |
| 2060 | /* If non-negative, character that triggers the automatic | 2064 | /* If non-negative, character that triggers the automatic |
| 2061 | composition at `stop_pos', and this is an automatic composition. | 2065 | composition at `stop_pos', and this is an automatic composition. |
| 2062 | If negative, this is a static composition. This is set to -2 | 2066 | If negative, this is a static composition. This is set to -2 |
| @@ -2246,7 +2250,7 @@ struct it | |||
| 2246 | struct { | 2250 | struct { |
| 2247 | Lisp_Object object; | 2251 | Lisp_Object object; |
| 2248 | struct it_slice slice; | 2252 | struct it_slice slice; |
| 2249 | int image_id; | 2253 | ptrdiff_t image_id; |
| 2250 | } image; | 2254 | } image; |
| 2251 | /* method == GET_FROM_COMPOSITION */ | 2255 | /* method == GET_FROM_COMPOSITION */ |
| 2252 | struct { | 2256 | struct { |
| @@ -2376,7 +2380,7 @@ struct it | |||
| 2376 | enum glyphless_display_method glyphless_method; | 2380 | enum glyphless_display_method glyphless_method; |
| 2377 | 2381 | ||
| 2378 | /* If what == IT_IMAGE, the id of the image to display. */ | 2382 | /* If what == IT_IMAGE, the id of the image to display. */ |
| 2379 | int image_id; | 2383 | ptrdiff_t image_id; |
| 2380 | 2384 | ||
| 2381 | /* Values from `slice' property. */ | 2385 | /* Values from `slice' property. */ |
| 2382 | struct it_slice slice; | 2386 | struct it_slice slice; |
| @@ -2826,7 +2830,7 @@ struct image | |||
| 2826 | EMACS_UINT hash; | 2830 | EMACS_UINT hash; |
| 2827 | 2831 | ||
| 2828 | /* Image id of this image. */ | 2832 | /* Image id of this image. */ |
| 2829 | int id; | 2833 | ptrdiff_t id; |
| 2830 | 2834 | ||
| 2831 | /* Hash collision chain. */ | 2835 | /* Hash collision chain. */ |
| 2832 | struct image *next, *prev; | 2836 | struct image *next, *prev; |
| @@ -2845,13 +2849,13 @@ struct image_cache | |||
| 2845 | struct image **images; | 2849 | struct image **images; |
| 2846 | 2850 | ||
| 2847 | /* Allocated size of `images'. */ | 2851 | /* Allocated size of `images'. */ |
| 2848 | unsigned size; | 2852 | ptrdiff_t size; |
| 2849 | 2853 | ||
| 2850 | /* Number of images in the cache. */ | 2854 | /* Number of images in the cache. */ |
| 2851 | unsigned used; | 2855 | ptrdiff_t used; |
| 2852 | 2856 | ||
| 2853 | /* Reference count (number of frames sharing this cache). */ | 2857 | /* Reference count (number of frames sharing this cache). */ |
| 2854 | int refcount; | 2858 | ptrdiff_t refcount; |
| 2855 | }; | 2859 | }; |
| 2856 | 2860 | ||
| 2857 | 2861 | ||
| @@ -2976,7 +2980,7 @@ extern int bidi_mirror_char (int); | |||
| 2976 | extern void bidi_push_it (struct bidi_it *); | 2980 | extern void bidi_push_it (struct bidi_it *); |
| 2977 | extern void bidi_pop_it (struct bidi_it *); | 2981 | extern void bidi_pop_it (struct bidi_it *); |
| 2978 | extern void *bidi_shelve_cache (void); | 2982 | extern void *bidi_shelve_cache (void); |
| 2979 | extern void bidi_unshelve_cache (void *); | 2983 | extern void bidi_unshelve_cache (void *, int); |
| 2980 | 2984 | ||
| 2981 | /* Defined in xdisp.c */ | 2985 | /* Defined in xdisp.c */ |
| 2982 | 2986 | ||
| @@ -3035,9 +3039,12 @@ extern Lisp_Object lookup_glyphless_char_display (int, struct it *); | |||
| 3035 | extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object, | 3039 | extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object, |
| 3036 | struct font *, int, int *); | 3040 | struct font *, int, int *); |
| 3037 | extern EMACS_INT compute_display_string_pos (struct text_pos *, | 3041 | extern EMACS_INT compute_display_string_pos (struct text_pos *, |
| 3038 | struct bidi_string_data *, int); | 3042 | struct bidi_string_data *, |
| 3043 | int, int *); | ||
| 3039 | extern EMACS_INT compute_display_string_end (EMACS_INT, | 3044 | extern EMACS_INT compute_display_string_end (EMACS_INT, |
| 3040 | struct bidi_string_data *); | 3045 | struct bidi_string_data *); |
| 3046 | extern void produce_stretch_glyph (struct it *); | ||
| 3047 | |||
| 3041 | 3048 | ||
| 3042 | #ifdef HAVE_WINDOW_SYSTEM | 3049 | #ifdef HAVE_WINDOW_SYSTEM |
| 3043 | 3050 | ||
| @@ -3117,7 +3124,7 @@ void w32_reset_fringes (void); | |||
| 3117 | extern int x_bitmap_height (struct frame *, ptrdiff_t); | 3124 | extern int x_bitmap_height (struct frame *, ptrdiff_t); |
| 3118 | extern int x_bitmap_width (struct frame *, ptrdiff_t); | 3125 | extern int x_bitmap_width (struct frame *, ptrdiff_t); |
| 3119 | extern int x_bitmap_pixmap (struct frame *, ptrdiff_t); | 3126 | extern int x_bitmap_pixmap (struct frame *, ptrdiff_t); |
| 3120 | extern void x_reference_bitmap (struct frame *, int); | 3127 | extern void x_reference_bitmap (struct frame *, ptrdiff_t); |
| 3121 | extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *, | 3128 | extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *, |
| 3122 | unsigned int, unsigned int); | 3129 | unsigned int, unsigned int); |
| 3123 | extern ptrdiff_t x_create_bitmap_from_file (struct frame *, Lisp_Object); | 3130 | extern ptrdiff_t x_create_bitmap_from_file (struct frame *, Lisp_Object); |
| @@ -3138,7 +3145,7 @@ void clear_image_caches (Lisp_Object); | |||
| 3138 | void mark_image_cache (struct image_cache *); | 3145 | void mark_image_cache (struct image_cache *); |
| 3139 | int valid_image_p (Lisp_Object); | 3146 | int valid_image_p (Lisp_Object); |
| 3140 | void prepare_image_for_display (struct frame *, struct image *); | 3147 | void prepare_image_for_display (struct frame *, struct image *); |
| 3141 | int lookup_image (struct frame *, Lisp_Object); | 3148 | ptrdiff_t lookup_image (struct frame *, Lisp_Object); |
| 3142 | 3149 | ||
| 3143 | unsigned long image_background (struct image *, struct frame *, | 3150 | unsigned long image_background (struct image *, struct frame *, |
| 3144 | XImagePtr_or_DC ximg); | 3151 | XImagePtr_or_DC ximg); |
| @@ -3199,7 +3206,6 @@ int merge_faces (struct frame *, Lisp_Object, EMACS_INT, int); | |||
| 3199 | int compute_char_face (struct frame *, int, Lisp_Object); | 3206 | int compute_char_face (struct frame *, int, Lisp_Object); |
| 3200 | void free_all_realized_faces (Lisp_Object); | 3207 | void free_all_realized_faces (Lisp_Object); |
| 3201 | extern Lisp_Object Qforeground_color, Qbackground_color; | 3208 | extern Lisp_Object Qforeground_color, Qbackground_color; |
| 3202 | extern Lisp_Object Qframe_set_background_mode; | ||
| 3203 | extern char unspecified_fg[], unspecified_bg[]; | 3209 | extern char unspecified_fg[], unspecified_bg[]; |
| 3204 | 3210 | ||
| 3205 | /* Defined in xfns.c */ | 3211 | /* Defined in xfns.c */ |
| @@ -3333,6 +3339,7 @@ extern struct terminal *get_named_tty (const char *); | |||
| 3333 | EXFUN (Ftty_type, 1); | 3339 | EXFUN (Ftty_type, 1); |
| 3334 | extern void create_tty_output (struct frame *); | 3340 | extern void create_tty_output (struct frame *); |
| 3335 | extern struct terminal *init_tty (const char *, const char *, int); | 3341 | extern struct terminal *init_tty (const char *, const char *, int); |
| 3342 | extern void tty_append_glyph (struct it *); | ||
| 3336 | 3343 | ||
| 3337 | 3344 | ||
| 3338 | /* Defined in scroll.c */ | 3345 | /* Defined in scroll.c */ |
diff --git a/src/dispnew.c b/src/dispnew.c index b2f416701c3..e96583e0025 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -499,12 +499,12 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y | |||
| 499 | /* Enlarge MATRIX->rows if necessary. New rows are cleared. */ | 499 | /* Enlarge MATRIX->rows if necessary. New rows are cleared. */ |
| 500 | if (matrix->rows_allocated < dim.height) | 500 | if (matrix->rows_allocated < dim.height) |
| 501 | { | 501 | { |
| 502 | ptrdiff_t size = dim.height * sizeof (struct glyph_row); | 502 | int old_alloc = matrix->rows_allocated; |
| 503 | new_rows = dim.height - matrix->rows_allocated; | 503 | new_rows = dim.height - matrix->rows_allocated; |
| 504 | matrix->rows = (struct glyph_row *) xrealloc (matrix->rows, size); | 504 | matrix->rows = xpalloc (matrix->rows, &matrix->rows_allocated, |
| 505 | memset (matrix->rows + matrix->rows_allocated, 0, | 505 | new_rows, INT_MAX, sizeof *matrix->rows); |
| 506 | new_rows * sizeof *matrix->rows); | 506 | memset (matrix->rows + old_alloc, 0, |
| 507 | matrix->rows_allocated = dim.height; | 507 | (matrix->rows_allocated - old_alloc) * sizeof *matrix->rows); |
| 508 | } | 508 | } |
| 509 | else | 509 | else |
| 510 | new_rows = 0; | 510 | new_rows = 0; |
| @@ -576,9 +576,8 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y | |||
| 576 | while (row < end) | 576 | while (row < end) |
| 577 | { | 577 | { |
| 578 | row->glyphs[LEFT_MARGIN_AREA] | 578 | row->glyphs[LEFT_MARGIN_AREA] |
| 579 | = (struct glyph *) xrealloc (row->glyphs[LEFT_MARGIN_AREA], | 579 | = xnrealloc (row->glyphs[LEFT_MARGIN_AREA], |
| 580 | (dim.width | 580 | dim.width, sizeof (struct glyph)); |
| 581 | * sizeof (struct glyph))); | ||
| 582 | 581 | ||
| 583 | /* The mode line never has marginal areas. */ | 582 | /* The mode line never has marginal areas. */ |
| 584 | if (row == matrix->rows + dim.height - 1 | 583 | if (row == matrix->rows + dim.height - 1 |
| @@ -1217,7 +1216,7 @@ line_draw_cost (struct glyph_matrix *matrix, int vpos) | |||
| 1217 | struct glyph *end = beg + row->used[TEXT_AREA]; | 1216 | struct glyph *end = beg + row->used[TEXT_AREA]; |
| 1218 | int len; | 1217 | int len; |
| 1219 | Lisp_Object *glyph_table_base = GLYPH_TABLE_BASE; | 1218 | Lisp_Object *glyph_table_base = GLYPH_TABLE_BASE; |
| 1220 | int glyph_table_len = GLYPH_TABLE_LENGTH; | 1219 | ptrdiff_t glyph_table_len = GLYPH_TABLE_LENGTH; |
| 1221 | 1220 | ||
| 1222 | /* Ignore trailing and leading spaces if we can. */ | 1221 | /* Ignore trailing and leading spaces if we can. */ |
| 1223 | if (!FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */ | 1222 | if (!FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */ |
| @@ -1391,7 +1390,7 @@ free_glyph_pool (struct glyph_pool *pool) | |||
| 1391 | static int | 1390 | static int |
| 1392 | realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) | 1391 | realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) |
| 1393 | { | 1392 | { |
| 1394 | int needed; | 1393 | ptrdiff_t needed; |
| 1395 | int changed_p; | 1394 | int changed_p; |
| 1396 | 1395 | ||
| 1397 | changed_p = (pool->glyphs == 0 | 1396 | changed_p = (pool->glyphs == 0 |
| @@ -1399,24 +1398,17 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) | |||
| 1399 | || matrix_dim.width != pool->ncolumns); | 1398 | || matrix_dim.width != pool->ncolumns); |
| 1400 | 1399 | ||
| 1401 | /* Enlarge the glyph pool. */ | 1400 | /* Enlarge the glyph pool. */ |
| 1402 | needed = matrix_dim.width * matrix_dim.height; | 1401 | needed = matrix_dim.width; |
| 1402 | if (INT_MULTIPLY_OVERFLOW (needed, matrix_dim.height)) | ||
| 1403 | memory_full (SIZE_MAX); | ||
| 1404 | needed *= matrix_dim.height; | ||
| 1403 | if (needed > pool->nglyphs) | 1405 | if (needed > pool->nglyphs) |
| 1404 | { | 1406 | { |
| 1405 | ptrdiff_t size = needed * sizeof (struct glyph); | 1407 | ptrdiff_t old_nglyphs = pool->nglyphs; |
| 1406 | 1408 | pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs, | |
| 1407 | if (pool->glyphs) | 1409 | needed - old_nglyphs, -1, sizeof *pool->glyphs); |
| 1408 | { | 1410 | memset (pool->glyphs + old_nglyphs, 0, |
| 1409 | pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size); | 1411 | (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs); |
| 1410 | memset (pool->glyphs + pool->nglyphs, 0, | ||
| 1411 | size - pool->nglyphs * sizeof (struct glyph)); | ||
| 1412 | } | ||
| 1413 | else | ||
| 1414 | { | ||
| 1415 | pool->glyphs = (struct glyph *) xmalloc (size); | ||
| 1416 | memset (pool->glyphs, 0, size); | ||
| 1417 | } | ||
| 1418 | |||
| 1419 | pool->nglyphs = needed; | ||
| 1420 | } | 1412 | } |
| 1421 | 1413 | ||
| 1422 | /* Remember the number of rows and columns because (a) we use them | 1414 | /* Remember the number of rows and columns because (a) we use them |
| @@ -4166,7 +4158,7 @@ struct row_entry | |||
| 4166 | int new_line_number; | 4158 | int new_line_number; |
| 4167 | 4159 | ||
| 4168 | /* Bucket index of this row_entry in the hash table row_table. */ | 4160 | /* Bucket index of this row_entry in the hash table row_table. */ |
| 4169 | int bucket; | 4161 | ptrdiff_t bucket; |
| 4170 | 4162 | ||
| 4171 | /* The row described by this entry. */ | 4163 | /* The row described by this entry. */ |
| 4172 | struct glyph_row *row; | 4164 | struct glyph_row *row; |
| @@ -4180,29 +4172,29 @@ struct row_entry | |||
| 4180 | that we need a larger one. */ | 4172 | that we need a larger one. */ |
| 4181 | 4173 | ||
| 4182 | static struct row_entry *row_entry_pool; | 4174 | static struct row_entry *row_entry_pool; |
| 4183 | static int row_entry_pool_size; | 4175 | static ptrdiff_t row_entry_pool_size; |
| 4184 | 4176 | ||
| 4185 | /* Index of next free entry in row_entry_pool. */ | 4177 | /* Index of next free entry in row_entry_pool. */ |
| 4186 | 4178 | ||
| 4187 | static int row_entry_idx; | 4179 | static ptrdiff_t row_entry_idx; |
| 4188 | 4180 | ||
| 4189 | /* The hash table used during scrolling, and the table's size. This | 4181 | /* The hash table used during scrolling, and the table's size. This |
| 4190 | table is used to quickly identify equal rows in the desired and | 4182 | table is used to quickly identify equal rows in the desired and |
| 4191 | current matrix. */ | 4183 | current matrix. */ |
| 4192 | 4184 | ||
| 4193 | static struct row_entry **row_table; | 4185 | static struct row_entry **row_table; |
| 4194 | static int row_table_size; | 4186 | static ptrdiff_t row_table_size; |
| 4195 | 4187 | ||
| 4196 | /* Vectors of pointers to row_entry structures belonging to the | 4188 | /* Vectors of pointers to row_entry structures belonging to the |
| 4197 | current and desired matrix, and the size of the vectors. */ | 4189 | current and desired matrix, and the size of the vectors. */ |
| 4198 | 4190 | ||
| 4199 | static struct row_entry **old_lines, **new_lines; | 4191 | static struct row_entry **old_lines, **new_lines; |
| 4200 | static int old_lines_size, new_lines_size; | 4192 | static ptrdiff_t old_lines_size, new_lines_size; |
| 4201 | 4193 | ||
| 4202 | /* A pool to allocate run structures from, and its size. */ | 4194 | /* A pool to allocate run structures from, and its size. */ |
| 4203 | 4195 | ||
| 4204 | static struct run *run_pool; | 4196 | static struct run *run_pool; |
| 4205 | static int runs_size; | 4197 | static ptrdiff_t runs_size; |
| 4206 | 4198 | ||
| 4207 | /* A vector of runs of lines found during scrolling. */ | 4199 | /* A vector of runs of lines found during scrolling. */ |
| 4208 | 4200 | ||
| @@ -4214,7 +4206,7 @@ static inline struct row_entry * | |||
| 4214 | add_row_entry (struct glyph_row *row) | 4206 | add_row_entry (struct glyph_row *row) |
| 4215 | { | 4207 | { |
| 4216 | struct row_entry *entry; | 4208 | struct row_entry *entry; |
| 4217 | int i = row->hash % row_table_size; | 4209 | ptrdiff_t i = row->hash % row_table_size; |
| 4218 | 4210 | ||
| 4219 | entry = row_table[i]; | 4211 | entry = row_table[i]; |
| 4220 | while (entry && !row_equal_p (entry->row, row, 1)) | 4212 | while (entry && !row_equal_p (entry->row, row, 1)) |
| @@ -4267,9 +4259,10 @@ scrolling_window (struct window *w, int header_line_p) | |||
| 4267 | struct glyph_matrix *desired_matrix = w->desired_matrix; | 4259 | struct glyph_matrix *desired_matrix = w->desired_matrix; |
| 4268 | struct glyph_matrix *current_matrix = w->current_matrix; | 4260 | struct glyph_matrix *current_matrix = w->current_matrix; |
| 4269 | int yb = window_text_bottom_y (w); | 4261 | int yb = window_text_bottom_y (w); |
| 4270 | int i, j, first_old, first_new, last_old, last_new; | 4262 | ptrdiff_t i; |
| 4271 | int nruns, n, run_idx; | 4263 | int j, first_old, first_new, last_old, last_new; |
| 4272 | ptrdiff_t nbytes; | 4264 | int nruns, run_idx; |
| 4265 | ptrdiff_t n; | ||
| 4273 | struct row_entry *entry; | 4266 | struct row_entry *entry; |
| 4274 | struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); | 4267 | struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); |
| 4275 | 4268 | ||
| @@ -4354,45 +4347,59 @@ scrolling_window (struct window *w, int header_line_p) | |||
| 4354 | if (last_new == first_new) | 4347 | if (last_new == first_new) |
| 4355 | return 0; | 4348 | return 0; |
| 4356 | 4349 | ||
| 4350 | /* Check for integer overflow in size calculation. | ||
| 4351 | |||
| 4352 | If next_almost_prime checks (N) for divisibility by 2..10, then | ||
| 4353 | it can return at most N + 10, e.g., next_almost_prime (1) == 11. | ||
| 4354 | So, set next_almost_prime_increment_max to 10. | ||
| 4355 | |||
| 4356 | It's just a coincidence that next_almost_prime_increment_max == | ||
| 4357 | NEXT_ALMOST_PRIME_LIMIT - 1. If NEXT_ALMOST_PRIME_LIMIT were | ||
| 4358 | 13, then next_almost_prime_increment_max would be 14, e.g., | ||
| 4359 | because next_almost_prime (113) would be 127. */ | ||
| 4360 | { | ||
| 4361 | verify (NEXT_ALMOST_PRIME_LIMIT == 11); | ||
| 4362 | enum { next_almost_prime_increment_max = 10 }; | ||
| 4363 | ptrdiff_t row_table_max = | ||
| 4364 | (min (PTRDIFF_MAX, SIZE_MAX) / (3 * sizeof *row_table) | ||
| 4365 | - next_almost_prime_increment_max); | ||
| 4366 | ptrdiff_t current_nrows_max = row_table_max - desired_matrix->nrows; | ||
| 4367 | if (current_nrows_max < current_matrix->nrows) | ||
| 4368 | memory_full (SIZE_MAX); | ||
| 4369 | } | ||
| 4370 | |||
| 4357 | /* Reallocate vectors, tables etc. if necessary. */ | 4371 | /* Reallocate vectors, tables etc. if necessary. */ |
| 4358 | 4372 | ||
| 4359 | if (current_matrix->nrows > old_lines_size) | 4373 | if (current_matrix->nrows > old_lines_size) |
| 4360 | { | 4374 | old_lines = xpalloc (old_lines, &old_lines_size, |
| 4361 | old_lines_size = current_matrix->nrows; | 4375 | current_matrix->nrows - old_lines_size, |
| 4362 | nbytes = old_lines_size * sizeof *old_lines; | 4376 | INT_MAX, sizeof *old_lines); |
| 4363 | old_lines = (struct row_entry **) xrealloc (old_lines, nbytes); | ||
| 4364 | } | ||
| 4365 | 4377 | ||
| 4366 | if (desired_matrix->nrows > new_lines_size) | 4378 | if (desired_matrix->nrows > new_lines_size) |
| 4367 | { | 4379 | new_lines = xpalloc (new_lines, &new_lines_size, |
| 4368 | new_lines_size = desired_matrix->nrows; | 4380 | desired_matrix->nrows - new_lines_size, |
| 4369 | nbytes = new_lines_size * sizeof *new_lines; | 4381 | INT_MAX, sizeof *new_lines); |
| 4370 | new_lines = (struct row_entry **) xrealloc (new_lines, nbytes); | ||
| 4371 | } | ||
| 4372 | 4382 | ||
| 4373 | n = desired_matrix->nrows + current_matrix->nrows; | 4383 | n = desired_matrix->nrows; |
| 4374 | if (3 * n > row_table_size) | 4384 | n += current_matrix->nrows; |
| 4385 | if (row_table_size < 3 * n) | ||
| 4375 | { | 4386 | { |
| 4376 | row_table_size = next_almost_prime (3 * n); | 4387 | ptrdiff_t size = next_almost_prime (3 * n); |
| 4377 | nbytes = row_table_size * sizeof *row_table; | 4388 | row_table = xnrealloc (row_table, size, sizeof *row_table); |
| 4378 | row_table = (struct row_entry **) xrealloc (row_table, nbytes); | 4389 | row_table_size = size; |
| 4379 | memset (row_table, 0, nbytes); | 4390 | memset (row_table, 0, size * sizeof *row_table); |
| 4380 | } | 4391 | } |
| 4381 | 4392 | ||
| 4382 | if (n > row_entry_pool_size) | 4393 | if (n > row_entry_pool_size) |
| 4383 | { | 4394 | row_entry_pool = xpalloc (row_entry_pool, &row_entry_pool_size, |
| 4384 | row_entry_pool_size = n; | 4395 | n - row_entry_pool_size, |
| 4385 | nbytes = row_entry_pool_size * sizeof *row_entry_pool; | 4396 | -1, sizeof *row_entry_pool); |
| 4386 | row_entry_pool = (struct row_entry *) xrealloc (row_entry_pool, nbytes); | ||
| 4387 | } | ||
| 4388 | 4397 | ||
| 4389 | if (desired_matrix->nrows > runs_size) | 4398 | if (desired_matrix->nrows > runs_size) |
| 4390 | { | 4399 | { |
| 4400 | runs = xnrealloc (runs, desired_matrix->nrows, sizeof *runs); | ||
| 4401 | run_pool = xnrealloc (run_pool, desired_matrix->nrows, sizeof *run_pool); | ||
| 4391 | runs_size = desired_matrix->nrows; | 4402 | runs_size = desired_matrix->nrows; |
| 4392 | nbytes = runs_size * sizeof *runs; | ||
| 4393 | runs = (struct run **) xrealloc (runs, nbytes); | ||
| 4394 | nbytes = runs_size * sizeof *run_pool; | ||
| 4395 | run_pool = (struct run *) xrealloc (run_pool, nbytes); | ||
| 4396 | } | 4403 | } |
| 4397 | 4404 | ||
| 4398 | nruns = run_idx = 0; | 4405 | nruns = run_idx = 0; |
| @@ -5282,7 +5289,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p | |||
| 5282 | argument is ZV to prevent move_it_in_display_line from matching | 5289 | argument is ZV to prevent move_it_in_display_line from matching |
| 5283 | based on buffer positions. */ | 5290 | based on buffer positions. */ |
| 5284 | move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X); | 5291 | move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X); |
| 5285 | bidi_unshelve_cache (itdata); | 5292 | bidi_unshelve_cache (itdata, 0); |
| 5286 | 5293 | ||
| 5287 | Fset_buffer (old_current_buffer); | 5294 | Fset_buffer (old_current_buffer); |
| 5288 | 5295 | ||
| @@ -5307,7 +5314,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p | |||
| 5307 | if (STRINGP (it.string)) | 5314 | if (STRINGP (it.string)) |
| 5308 | BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); | 5315 | BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); |
| 5309 | else | 5316 | else |
| 5310 | BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos)); | 5317 | BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer), |
| 5318 | CHARPOS (pos->pos)); | ||
| 5311 | } | 5319 | } |
| 5312 | 5320 | ||
| 5313 | #ifdef HAVE_WINDOW_SYSTEM | 5321 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -39,7 +39,7 @@ Lisp_Object Qfunction_documentation; | |||
| 39 | extern Lisp_Object Qclosure; | 39 | extern Lisp_Object Qclosure; |
| 40 | /* Buffer used for reading from documentation file. */ | 40 | /* Buffer used for reading from documentation file. */ |
| 41 | static char *get_doc_string_buffer; | 41 | static char *get_doc_string_buffer; |
| 42 | static int get_doc_string_buffer_size; | 42 | static ptrdiff_t get_doc_string_buffer_size; |
| 43 | 43 | ||
| 44 | static unsigned char *read_bytecode_pointer; | 44 | static unsigned char *read_bytecode_pointer; |
| 45 | static Lisp_Object Fdocumentation_property (Lisp_Object, Lisp_Object, | 45 | static Lisp_Object Fdocumentation_property (Lisp_Object, Lisp_Object, |
| @@ -166,20 +166,19 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition) | |||
| 166 | p = get_doc_string_buffer; | 166 | p = get_doc_string_buffer; |
| 167 | while (1) | 167 | while (1) |
| 168 | { | 168 | { |
| 169 | EMACS_INT space_left = (get_doc_string_buffer_size | 169 | ptrdiff_t space_left = (get_doc_string_buffer_size - 1 |
| 170 | - (p - get_doc_string_buffer)); | 170 | - (p - get_doc_string_buffer)); |
| 171 | int nread; | 171 | int nread; |
| 172 | 172 | ||
| 173 | /* Allocate or grow the buffer if we need to. */ | 173 | /* Allocate or grow the buffer if we need to. */ |
| 174 | if (space_left == 0) | 174 | if (space_left <= 0) |
| 175 | { | 175 | { |
| 176 | EMACS_INT in_buffer = p - get_doc_string_buffer; | 176 | ptrdiff_t in_buffer = p - get_doc_string_buffer; |
| 177 | get_doc_string_buffer_size += 16 * 1024; | 177 | get_doc_string_buffer = |
| 178 | get_doc_string_buffer | 178 | xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size, |
| 179 | = (char *) xrealloc (get_doc_string_buffer, | 179 | 16 * 1024, -1, 1); |
| 180 | get_doc_string_buffer_size + 1); | ||
| 181 | p = get_doc_string_buffer + in_buffer; | 180 | p = get_doc_string_buffer + in_buffer; |
| 182 | space_left = (get_doc_string_buffer_size | 181 | space_left = (get_doc_string_buffer_size - 1 |
| 183 | - (p - get_doc_string_buffer)); | 182 | - (p - get_doc_string_buffer)); |
| 184 | } | 183 | } |
| 185 | 184 | ||
| @@ -713,16 +712,16 @@ a new string, without any text properties, is returned. */) | |||
| 713 | int changed = 0; | 712 | int changed = 0; |
| 714 | register unsigned char *strp; | 713 | register unsigned char *strp; |
| 715 | register char *bufp; | 714 | register char *bufp; |
| 716 | EMACS_INT idx; | 715 | ptrdiff_t idx; |
| 717 | EMACS_INT bsize; | 716 | ptrdiff_t bsize; |
| 718 | Lisp_Object tem; | 717 | Lisp_Object tem; |
| 719 | Lisp_Object keymap; | 718 | Lisp_Object keymap; |
| 720 | unsigned char *start; | 719 | unsigned char *start; |
| 721 | EMACS_INT length, length_byte; | 720 | ptrdiff_t length, length_byte; |
| 722 | Lisp_Object name; | 721 | Lisp_Object name; |
| 723 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 722 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 724 | int multibyte; | 723 | int multibyte; |
| 725 | EMACS_INT nchars; | 724 | ptrdiff_t nchars; |
| 726 | 725 | ||
| 727 | if (NILP (string)) | 726 | if (NILP (string)) |
| 728 | return Qnil; | 727 | return Qnil; |
| @@ -774,7 +773,7 @@ a new string, without any text properties, is returned. */) | |||
| 774 | } | 773 | } |
| 775 | else if (strp[0] == '\\' && strp[1] == '[') | 774 | else if (strp[0] == '\\' && strp[1] == '[') |
| 776 | { | 775 | { |
| 777 | EMACS_INT start_idx; | 776 | ptrdiff_t start_idx; |
| 778 | int follow_remap = 1; | 777 | int follow_remap = 1; |
| 779 | 778 | ||
| 780 | changed = 1; | 779 | changed = 1; |
| @@ -813,7 +812,9 @@ a new string, without any text properties, is returned. */) | |||
| 813 | 812 | ||
| 814 | if (NILP (tem)) /* but not on any keys */ | 813 | if (NILP (tem)) /* but not on any keys */ |
| 815 | { | 814 | { |
| 816 | EMACS_INT offset = bufp - buf; | 815 | ptrdiff_t offset = bufp - buf; |
| 816 | if (STRING_BYTES_BOUND - 4 < bsize) | ||
| 817 | string_overflow (); | ||
| 817 | buf = (char *) xrealloc (buf, bsize += 4); | 818 | buf = (char *) xrealloc (buf, bsize += 4); |
| 818 | bufp = buf + offset; | 819 | bufp = buf + offset; |
| 819 | memcpy (bufp, "M-x ", 4); | 820 | memcpy (bufp, "M-x ", 4); |
| @@ -836,7 +837,7 @@ a new string, without any text properties, is returned. */) | |||
| 836 | else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<')) | 837 | else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<')) |
| 837 | { | 838 | { |
| 838 | struct buffer *oldbuf; | 839 | struct buffer *oldbuf; |
| 839 | EMACS_INT start_idx; | 840 | ptrdiff_t start_idx; |
| 840 | /* This is for computing the SHADOWS arg for describe_map_tree. */ | 841 | /* This is for computing the SHADOWS arg for describe_map_tree. */ |
| 841 | Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil); | 842 | Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil); |
| 842 | Lisp_Object earlier_maps; | 843 | Lisp_Object earlier_maps; |
| @@ -907,7 +908,9 @@ a new string, without any text properties, is returned. */) | |||
| 907 | length_byte = SBYTES (tem); | 908 | length_byte = SBYTES (tem); |
| 908 | subst: | 909 | subst: |
| 909 | { | 910 | { |
| 910 | EMACS_INT offset = bufp - buf; | 911 | ptrdiff_t offset = bufp - buf; |
| 912 | if (STRING_BYTES_BOUND - length_byte < bsize) | ||
| 913 | string_overflow (); | ||
| 911 | buf = (char *) xrealloc (buf, bsize += length_byte); | 914 | buf = (char *) xrealloc (buf, bsize += length_byte); |
| 912 | bufp = buf + offset; | 915 | bufp = buf + offset; |
| 913 | memcpy (bufp, start, length_byte); | 916 | memcpy (bufp, start, length_byte); |
diff --git a/src/editfns.c b/src/editfns.c index 577263c5aea..6759016766f 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1695,7 +1695,9 @@ The modifiers are `E' and `O'. For certain characters X, | |||
| 1695 | %EX is a locale's alternative version of %X; | 1695 | %EX is a locale's alternative version of %X; |
| 1696 | %OX is like %X, but uses the locale's number symbols. | 1696 | %OX is like %X, but uses the locale's number symbols. |
| 1697 | 1697 | ||
| 1698 | For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | 1698 | For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". |
| 1699 | |||
| 1700 | usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */) | ||
| 1699 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) | 1701 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) |
| 1700 | { | 1702 | { |
| 1701 | time_t value; | 1703 | time_t value; |
| @@ -2051,7 +2053,12 @@ static char *initial_tz; | |||
| 2051 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, | 2053 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, |
| 2052 | doc: /* Set the local time zone using TZ, a string specifying a time zone rule. | 2054 | doc: /* Set the local time zone using TZ, a string specifying a time zone rule. |
| 2053 | If TZ is nil, use implementation-defined default time zone information. | 2055 | If TZ is nil, use implementation-defined default time zone information. |
| 2054 | If TZ is t, use Universal Time. */) | 2056 | If TZ is t, use Universal Time. |
| 2057 | |||
| 2058 | Instead of calling this function, you typically want (setenv "TZ" TZ). | ||
| 2059 | That changes both the environment of the Emacs process and the | ||
| 2060 | variable `process-environment', whereas `set-time-zone-rule' affects | ||
| 2061 | only the former. */) | ||
| 2055 | (Lisp_Object tz) | 2062 | (Lisp_Object tz) |
| 2056 | { | 2063 | { |
| 2057 | const char *tzstring; | 2064 | const char *tzstring; |
| @@ -2100,7 +2107,7 @@ static char set_time_zone_rule_tz2[] = "TZ=GMT+1"; | |||
| 2100 | void | 2107 | void |
| 2101 | set_time_zone_rule (const char *tzstring) | 2108 | set_time_zone_rule (const char *tzstring) |
| 2102 | { | 2109 | { |
| 2103 | int envptrs; | 2110 | ptrdiff_t envptrs; |
| 2104 | char **from, **to, **newenv; | 2111 | char **from, **to, **newenv; |
| 2105 | 2112 | ||
| 2106 | /* Make the ENVIRON vector longer with room for TZSTRING. */ | 2113 | /* Make the ENVIRON vector longer with room for TZSTRING. */ |
| @@ -3350,7 +3357,7 @@ usage: (save-restriction &rest BODY) */) | |||
| 3350 | static char *message_text; | 3357 | static char *message_text; |
| 3351 | 3358 | ||
| 3352 | /* Allocated length of that buffer. */ | 3359 | /* Allocated length of that buffer. */ |
| 3353 | static int message_length; | 3360 | static ptrdiff_t message_length; |
| 3354 | 3361 | ||
| 3355 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, | 3362 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, |
| 3356 | doc: /* Display a message at the bottom of the screen. | 3363 | doc: /* Display a message at the bottom of the screen. |
| @@ -3432,8 +3439,8 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) | |||
| 3432 | } | 3439 | } |
| 3433 | if (SBYTES (val) > message_length) | 3440 | if (SBYTES (val) > message_length) |
| 3434 | { | 3441 | { |
| 3442 | message_text = (char *) xrealloc (message_text, SBYTES (val)); | ||
| 3435 | message_length = SBYTES (val); | 3443 | message_length = SBYTES (val); |
| 3436 | message_text = (char *)xrealloc (message_text, message_length); | ||
| 3437 | } | 3444 | } |
| 3438 | memcpy (message_text, SDATA (val), SBYTES (val)); | 3445 | memcpy (message_text, SDATA (val), SBYTES (val)); |
| 3439 | message2 (message_text, SBYTES (val), | 3446 | message2 (message_text, SBYTES (val), |
| @@ -3882,7 +3889,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3882 | : -1)), | 3889 | : -1)), |
| 3883 | 3890 | ||
| 3884 | /* Maximum number of bytes generated by any format, if | 3891 | /* Maximum number of bytes generated by any format, if |
| 3885 | precision is no more than DBL_USEFUL_PRECISION_MAX. | 3892 | precision is no more than USEFUL_PRECISION_MAX. |
| 3886 | On all practical hosts, %f is the worst case. */ | 3893 | On all practical hosts, %f is the worst case. */ |
| 3887 | SPRINTF_BUFSIZE = | 3894 | SPRINTF_BUFSIZE = |
| 3888 | sizeof "-." + (DBL_MAX_10_EXP + 1) + USEFUL_PRECISION_MAX, | 3895 | sizeof "-." + (DBL_MAX_10_EXP + 1) + USEFUL_PRECISION_MAX, |
| @@ -4158,7 +4165,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 4158 | character. CONVBYTES says how much room is needed. Allocate | 4165 | character. CONVBYTES says how much room is needed. Allocate |
| 4159 | enough room (and then some) and do it again. */ | 4166 | enough room (and then some) and do it again. */ |
| 4160 | { | 4167 | { |
| 4161 | EMACS_INT used = p - buf; | 4168 | ptrdiff_t used = p - buf; |
| 4162 | 4169 | ||
| 4163 | if (max_bufsize - used < convbytes) | 4170 | if (max_bufsize - used < convbytes) |
| 4164 | string_overflow (); | 4171 | string_overflow (); |
diff --git a/src/emacs.c b/src/emacs.c index 39870ec0079..4cc476290c0 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -82,6 +82,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 82 | #include <sys/personality.h> | 82 | #include <sys/personality.h> |
| 83 | #endif | 83 | #endif |
| 84 | 84 | ||
| 85 | #ifdef HAVE_LIBXML2 | ||
| 86 | #include <libxml/parser.h> | ||
| 87 | #endif | ||
| 88 | |||
| 85 | #ifndef O_RDWR | 89 | #ifndef O_RDWR |
| 86 | #define O_RDWR 2 | 90 | #define O_RDWR 2 |
| 87 | #endif | 91 | #endif |
| @@ -1120,7 +1124,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1120 | #if defined (USG5) && defined (INTERRUPT_INPUT) | 1124 | #if defined (USG5) && defined (INTERRUPT_INPUT) |
| 1121 | setpgrp (); | 1125 | setpgrp (); |
| 1122 | #endif | 1126 | #endif |
| 1123 | #if defined (HAVE_GTK_AND_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC) | 1127 | #if defined (HAVE_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC) |
| 1124 | { | 1128 | { |
| 1125 | extern void malloc_enable_thread (void); | 1129 | extern void malloc_enable_thread (void); |
| 1126 | 1130 | ||
| @@ -1358,24 +1362,17 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1358 | /* If we have the form --display=NAME, | 1362 | /* If we have the form --display=NAME, |
| 1359 | convert it into -d name. | 1363 | convert it into -d name. |
| 1360 | This requires inserting a new element into argv. */ | 1364 | This requires inserting a new element into argv. */ |
| 1361 | if (displayname != 0 && skip_args - count_before == 1) | 1365 | if (displayname && count_before < skip_args) |
| 1362 | { | 1366 | { |
| 1363 | char **new = (char **) xmalloc (sizeof (char *) * (argc + 2)); | 1367 | if (skip_args == count_before + 1) |
| 1364 | int j; | 1368 | { |
| 1365 | 1369 | memmove (argv + count_before + 3, argv + count_before + 2, | |
| 1366 | for (j = 0; j < count_before + 1; j++) | 1370 | (argc - (count_before + 2)) * sizeof *argv); |
| 1367 | new[j] = argv[j]; | 1371 | argv[count_before + 2] = displayname; |
| 1368 | new[count_before + 1] = (char *) "-d"; | 1372 | argc++; |
| 1369 | new[count_before + 2] = displayname; | 1373 | } |
| 1370 | for (j = count_before + 2; j <argc; j++) | 1374 | argv[count_before + 1] = (char *) "-d"; |
| 1371 | new[j + 1] = argv[j]; | ||
| 1372 | argv = new; | ||
| 1373 | argc++; | ||
| 1374 | } | 1375 | } |
| 1375 | /* Change --display to -d, when its arg is separate. */ | ||
| 1376 | else if (displayname != 0 && skip_args > count_before | ||
| 1377 | && argv[count_before + 1][1] == '-') | ||
| 1378 | argv[count_before + 1] = (char *) "-d"; | ||
| 1379 | 1376 | ||
| 1380 | if (! no_site_lisp) | 1377 | if (! no_site_lisp) |
| 1381 | { | 1378 | { |
| @@ -1838,8 +1835,8 @@ sort_args (int argc, char **argv) | |||
| 1838 | 0 for an option that takes no arguments, | 1835 | 0 for an option that takes no arguments, |
| 1839 | 1 for an option that takes one argument, etc. | 1836 | 1 for an option that takes one argument, etc. |
| 1840 | -1 for an ordinary non-option argument. */ | 1837 | -1 for an ordinary non-option argument. */ |
| 1841 | int *options = (int *) xmalloc (sizeof (int) * argc); | 1838 | int *options = xnmalloc (argc, sizeof *options); |
| 1842 | int *priority = (int *) xmalloc (sizeof (int) * argc); | 1839 | int *priority = xnmalloc (argc, sizeof *priority); |
| 1843 | int to = 1; | 1840 | int to = 1; |
| 1844 | int incoming_used = 1; | 1841 | int incoming_used = 1; |
| 1845 | int from; | 1842 | int from; |
| @@ -2104,6 +2101,10 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff) | |||
| 2104 | #ifdef HAVE_NS | 2101 | #ifdef HAVE_NS |
| 2105 | ns_term_shutdown (sig); | 2102 | ns_term_shutdown (sig); |
| 2106 | #endif | 2103 | #endif |
| 2104 | |||
| 2105 | #ifdef HAVE_LIBXML2 | ||
| 2106 | xmlCleanupParser (); | ||
| 2107 | #endif | ||
| 2107 | } | 2108 | } |
| 2108 | 2109 | ||
| 2109 | 2110 | ||
| @@ -2185,7 +2186,7 @@ You must run Emacs in batch mode in order to dump it. */) | |||
| 2185 | memory_warnings (my_edata, malloc_warning); | 2186 | memory_warnings (my_edata, malloc_warning); |
| 2186 | } | 2187 | } |
| 2187 | #endif /* not WINDOWSNT */ | 2188 | #endif /* not WINDOWSNT */ |
| 2188 | #if defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT | 2189 | #if defined (HAVE_PTHREAD) && !defined SYNC_INPUT |
| 2189 | /* Pthread may call malloc before main, and then we will get an endless | 2190 | /* Pthread may call malloc before main, and then we will get an endless |
| 2190 | loop, because pthread_self (see alloc.c) calls malloc the first time | 2191 | loop, because pthread_self (see alloc.c) calls malloc the first time |
| 2191 | it is called on some systems. */ | 2192 | it is called on some systems. */ |
diff --git a/src/eval.c b/src/eval.c index ef169e80e27..e722b53fb72 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -133,8 +133,9 @@ static Lisp_Object Ffetch_bytecode (Lisp_Object); | |||
| 133 | void | 133 | void |
| 134 | init_eval_once (void) | 134 | init_eval_once (void) |
| 135 | { | 135 | { |
| 136 | specpdl_size = 50; | 136 | enum { size = 50 }; |
| 137 | specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); | 137 | specpdl = (struct specbinding *) xmalloc (size * sizeof (struct specbinding)); |
| 138 | specpdl_size = size; | ||
| 138 | specpdl_ptr = specpdl; | 139 | specpdl_ptr = specpdl; |
| 139 | /* Don't forget to update docs (lispref node "Local Variables"). */ | 140 | /* Don't forget to update docs (lispref node "Local Variables"). */ |
| 140 | max_specpdl_size = 1300; /* 1000 is not enough for CEDET's c-by.el. */ | 141 | max_specpdl_size = 1300; /* 1000 is not enough for CEDET's c-by.el. */ |
| @@ -192,7 +193,7 @@ call_debugger (Lisp_Object arg) | |||
| 192 | if (lisp_eval_depth + 40 > max_lisp_eval_depth) | 193 | if (lisp_eval_depth + 40 > max_lisp_eval_depth) |
| 193 | max_lisp_eval_depth = lisp_eval_depth + 40; | 194 | max_lisp_eval_depth = lisp_eval_depth + 40; |
| 194 | 195 | ||
| 195 | if (SPECPDL_INDEX () + 100 > max_specpdl_size) | 196 | if (max_specpdl_size - 100 < SPECPDL_INDEX ()) |
| 196 | max_specpdl_size = SPECPDL_INDEX () + 100; | 197 | max_specpdl_size = SPECPDL_INDEX () + 100; |
| 197 | 198 | ||
| 198 | #ifdef HAVE_WINDOW_SYSTEM | 199 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -1357,8 +1358,12 @@ A handler is applicable to an error | |||
| 1357 | if CONDITION-NAME is one of the error's condition names. | 1358 | if CONDITION-NAME is one of the error's condition names. |
| 1358 | If an error happens, the first applicable handler is run. | 1359 | If an error happens, the first applicable handler is run. |
| 1359 | 1360 | ||
| 1360 | The car of a handler may be a list of condition names | 1361 | The car of a handler may be a list of condition names instead of a |
| 1361 | instead of a single condition name. Then it handles all of them. | 1362 | single condition name; then it handles all of them. If the special |
| 1363 | condition name `debug' is present in this list, it allows another | ||
| 1364 | condition in the list to run the debugger if `debug-on-error' and the | ||
| 1365 | other usual mechanisms says it should (otherwise, `condition-case' | ||
| 1366 | suppresses the debugger). | ||
| 1362 | 1367 | ||
| 1363 | When a handler handles an error, control returns to the `condition-case' | 1368 | When a handler handles an error, control returns to the `condition-case' |
| 1364 | and it executes the handler's BODY... | 1369 | and it executes the handler's BODY... |
| @@ -1461,13 +1466,6 @@ internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers, | |||
| 1461 | struct catchtag c; | 1466 | struct catchtag c; |
| 1462 | struct handler h; | 1467 | struct handler h; |
| 1463 | 1468 | ||
| 1464 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1465 | we will get the wrong results if some are not closed now. */ | ||
| 1466 | #if HAVE_X_WINDOWS | ||
| 1467 | if (x_catching_errors ()) | ||
| 1468 | abort (); | ||
| 1469 | #endif | ||
| 1470 | |||
| 1471 | c.tag = Qnil; | 1469 | c.tag = Qnil; |
| 1472 | c.val = Qnil; | 1470 | c.val = Qnil; |
| 1473 | c.backlist = backtrace_list; | 1471 | c.backlist = backtrace_list; |
| @@ -1506,13 +1504,6 @@ internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg, | |||
| 1506 | struct catchtag c; | 1504 | struct catchtag c; |
| 1507 | struct handler h; | 1505 | struct handler h; |
| 1508 | 1506 | ||
| 1509 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1510 | we will get the wrong results if some are not closed now. */ | ||
| 1511 | #if HAVE_X_WINDOWS | ||
| 1512 | if (x_catching_errors ()) | ||
| 1513 | abort (); | ||
| 1514 | #endif | ||
| 1515 | |||
| 1516 | c.tag = Qnil; | 1507 | c.tag = Qnil; |
| 1517 | c.val = Qnil; | 1508 | c.val = Qnil; |
| 1518 | c.backlist = backtrace_list; | 1509 | c.backlist = backtrace_list; |
| @@ -1555,13 +1546,6 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object), | |||
| 1555 | struct catchtag c; | 1546 | struct catchtag c; |
| 1556 | struct handler h; | 1547 | struct handler h; |
| 1557 | 1548 | ||
| 1558 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1559 | we will get the wrong results if some are not closed now. */ | ||
| 1560 | #if HAVE_X_WINDOWS | ||
| 1561 | if (x_catching_errors ()) | ||
| 1562 | abort (); | ||
| 1563 | #endif | ||
| 1564 | |||
| 1565 | c.tag = Qnil; | 1549 | c.tag = Qnil; |
| 1566 | c.val = Qnil; | 1550 | c.val = Qnil; |
| 1567 | c.backlist = backtrace_list; | 1551 | c.backlist = backtrace_list; |
| @@ -1604,13 +1588,6 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), | |||
| 1604 | struct catchtag c; | 1588 | struct catchtag c; |
| 1605 | struct handler h; | 1589 | struct handler h; |
| 1606 | 1590 | ||
| 1607 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1608 | we will get the wrong results if some are not closed now. */ | ||
| 1609 | #if HAVE_X_WINDOWS | ||
| 1610 | if (x_catching_errors ()) | ||
| 1611 | abort (); | ||
| 1612 | #endif | ||
| 1613 | |||
| 1614 | c.tag = Qnil; | 1591 | c.tag = Qnil; |
| 1615 | c.val = Qnil; | 1592 | c.val = Qnil; |
| 1616 | c.backlist = backtrace_list; | 1593 | c.backlist = backtrace_list; |
| @@ -1727,6 +1704,10 @@ See also the function `condition-case'. */) | |||
| 1727 | && (!NILP (Vdebug_on_signal) | 1704 | && (!NILP (Vdebug_on_signal) |
| 1728 | /* If no handler is present now, try to run the debugger. */ | 1705 | /* If no handler is present now, try to run the debugger. */ |
| 1729 | || NILP (clause) | 1706 | || NILP (clause) |
| 1707 | /* A `debug' symbol in the handler list disables the normal | ||
| 1708 | suppression of the debugger. */ | ||
| 1709 | || (CONSP (clause) && CONSP (XCAR (clause)) | ||
| 1710 | && !NILP (Fmemq (Qdebug, XCAR (clause)))) | ||
| 1730 | /* Special handler that means "print a message and run debugger | 1711 | /* Special handler that means "print a message and run debugger |
| 1731 | if requested". */ | 1712 | if requested". */ |
| 1732 | || EQ (h->handler, Qerror))) | 1713 | || EQ (h->handler, Qerror))) |
| @@ -3274,17 +3255,21 @@ static void | |||
| 3274 | grow_specpdl (void) | 3255 | grow_specpdl (void) |
| 3275 | { | 3256 | { |
| 3276 | register int count = SPECPDL_INDEX (); | 3257 | register int count = SPECPDL_INDEX (); |
| 3277 | if (specpdl_size >= max_specpdl_size) | 3258 | int max_size = |
| 3259 | min (max_specpdl_size, | ||
| 3260 | min (max (PTRDIFF_MAX, SIZE_MAX) / sizeof (struct specbinding), | ||
| 3261 | INT_MAX)); | ||
| 3262 | int size; | ||
| 3263 | if (max_size <= specpdl_size) | ||
| 3278 | { | 3264 | { |
| 3279 | if (max_specpdl_size < 400) | 3265 | if (max_specpdl_size < 400) |
| 3280 | max_specpdl_size = 400; | 3266 | max_size = max_specpdl_size = 400; |
| 3281 | if (specpdl_size >= max_specpdl_size) | 3267 | if (max_size <= specpdl_size) |
| 3282 | signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); | 3268 | signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); |
| 3283 | } | 3269 | } |
| 3284 | specpdl_size *= 2; | 3270 | size = specpdl_size < max_size / 2 ? 2 * specpdl_size : max_size; |
| 3285 | if (specpdl_size > max_specpdl_size) | 3271 | specpdl = xnrealloc (specpdl, size, sizeof *specpdl); |
| 3286 | specpdl_size = max_specpdl_size; | 3272 | specpdl_size = size; |
| 3287 | specpdl = (struct specbinding *) xrealloc (specpdl, specpdl_size * sizeof (struct specbinding)); | ||
| 3288 | specpdl_ptr = specpdl + count; | 3273 | specpdl_ptr = specpdl + count; |
| 3289 | } | 3274 | } |
| 3290 | 3275 | ||
diff --git a/src/fileio.c b/src/fileio.c index 61713689351..60ee35bb399 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2912,7 +2912,7 @@ symbolic notation, like the `chmod' command from GNU Coreutils. */) | |||
| 2912 | 2912 | ||
| 2913 | encoded_absname = ENCODE_FILE (absname); | 2913 | encoded_absname = ENCODE_FILE (absname); |
| 2914 | 2914 | ||
| 2915 | if (chmod (SSDATA (encoded_absname), XINT (mode)) < 0) | 2915 | if (chmod (SSDATA (encoded_absname), XINT (mode) & 07777) < 0) |
| 2916 | report_file_error ("Doing chmod", Fcons (absname, Qnil)); | 2916 | report_file_error ("Doing chmod", Fcons (absname, Qnil)); |
| 2917 | 2917 | ||
| 2918 | return Qnil; | 2918 | return Qnil; |
| @@ -5114,11 +5114,11 @@ auto_save_1 (void) | |||
| 5114 | { | 5114 | { |
| 5115 | if (stat (SSDATA (BVAR (current_buffer, filename)), &st) >= 0) | 5115 | if (stat (SSDATA (BVAR (current_buffer, filename)), &st) >= 0) |
| 5116 | /* But make sure we can overwrite it later! */ | 5116 | /* But make sure we can overwrite it later! */ |
| 5117 | auto_save_mode_bits = st.st_mode | 0600; | 5117 | auto_save_mode_bits = (st.st_mode | 0600) & 0777; |
| 5118 | else if ((modes = Ffile_modes (BVAR (current_buffer, filename)), | 5118 | else if ((modes = Ffile_modes (BVAR (current_buffer, filename)), |
| 5119 | INTEGERP (modes))) | 5119 | INTEGERP (modes))) |
| 5120 | /* Remote files don't cooperate with stat. */ | 5120 | /* Remote files don't cooperate with stat. */ |
| 5121 | auto_save_mode_bits = XINT (modes) | 0600; | 5121 | auto_save_mode_bits = (XINT (modes) | 0600) & 0777; |
| 5122 | } | 5122 | } |
| 5123 | 5123 | ||
| 5124 | return | 5124 | return |
| @@ -602,7 +602,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args, | |||
| 602 | 602 | ||
| 603 | prev = Qnil; | 603 | prev = Qnil; |
| 604 | if (STRINGP (val)) | 604 | if (STRINGP (val)) |
| 605 | SAFE_ALLOCA (textprops, struct textprop_rec *, sizeof (struct textprop_rec) * nargs); | 605 | SAFE_NALLOCA (textprops, 1, nargs); |
| 606 | 606 | ||
| 607 | for (argnum = 0; argnum < nargs; argnum++) | 607 | for (argnum = 0; argnum < nargs; argnum++) |
| 608 | { | 608 | { |
| @@ -3395,11 +3395,13 @@ check_hash_table (Lisp_Object obj) | |||
| 3395 | 3395 | ||
| 3396 | 3396 | ||
| 3397 | /* Value is the next integer I >= N, N >= 0 which is "almost" a prime | 3397 | /* Value is the next integer I >= N, N >= 0 which is "almost" a prime |
| 3398 | number. */ | 3398 | number. A number is "almost" a prime number if it is not divisible |
| 3399 | by any integer in the range 2 .. (NEXT_ALMOST_PRIME_LIMIT - 1). */ | ||
| 3399 | 3400 | ||
| 3400 | EMACS_INT | 3401 | EMACS_INT |
| 3401 | next_almost_prime (EMACS_INT n) | 3402 | next_almost_prime (EMACS_INT n) |
| 3402 | { | 3403 | { |
| 3404 | verify (NEXT_ALMOST_PRIME_LIMIT == 11); | ||
| 3403 | for (n |= 1; ; n += 2) | 3405 | for (n |= 1; ; n += 2) |
| 3404 | if (n % 3 != 0 && n % 5 != 0 && n % 7 != 0) | 3406 | if (n % 3 != 0 && n % 5 != 0 && n % 7 != 0) |
| 3405 | return n; | 3407 | return n; |
| @@ -3787,11 +3789,11 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) | |||
| 3787 | the hash code of KEY. Value is the index of the entry in H | 3789 | the hash code of KEY. Value is the index of the entry in H |
| 3788 | matching KEY, or -1 if not found. */ | 3790 | matching KEY, or -1 if not found. */ |
| 3789 | 3791 | ||
| 3790 | EMACS_INT | 3792 | ptrdiff_t |
| 3791 | hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash) | 3793 | hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash) |
| 3792 | { | 3794 | { |
| 3793 | EMACS_UINT hash_code; | 3795 | EMACS_UINT hash_code; |
| 3794 | EMACS_INT start_of_bucket; | 3796 | ptrdiff_t start_of_bucket; |
| 3795 | Lisp_Object idx; | 3797 | Lisp_Object idx; |
| 3796 | 3798 | ||
| 3797 | hash_code = h->hashfn (h, key); | 3799 | hash_code = h->hashfn (h, key); |
| @@ -3821,11 +3823,11 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash) | |||
| 3821 | HASH is a previously computed hash code of KEY. | 3823 | HASH is a previously computed hash code of KEY. |
| 3822 | Value is the index of the entry in H matching KEY. */ | 3824 | Value is the index of the entry in H matching KEY. */ |
| 3823 | 3825 | ||
| 3824 | EMACS_INT | 3826 | ptrdiff_t |
| 3825 | hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, | 3827 | hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, |
| 3826 | EMACS_UINT hash) | 3828 | EMACS_UINT hash) |
| 3827 | { | 3829 | { |
| 3828 | EMACS_INT start_of_bucket, i; | 3830 | ptrdiff_t start_of_bucket, i; |
| 3829 | 3831 | ||
| 3830 | xassert ((hash & ~INTMASK) == 0); | 3832 | xassert ((hash & ~INTMASK) == 0); |
| 3831 | 3833 | ||
| @@ -4482,7 +4484,7 @@ If KEY is not found, return DFLT which defaults to nil. */) | |||
| 4482 | (Lisp_Object key, Lisp_Object table, Lisp_Object dflt) | 4484 | (Lisp_Object key, Lisp_Object table, Lisp_Object dflt) |
| 4483 | { | 4485 | { |
| 4484 | struct Lisp_Hash_Table *h = check_hash_table (table); | 4486 | struct Lisp_Hash_Table *h = check_hash_table (table); |
| 4485 | EMACS_INT i = hash_lookup (h, key, NULL); | 4487 | ptrdiff_t i = hash_lookup (h, key, NULL); |
| 4486 | return i >= 0 ? HASH_VALUE (h, i) : dflt; | 4488 | return i >= 0 ? HASH_VALUE (h, i) : dflt; |
| 4487 | } | 4489 | } |
| 4488 | 4490 | ||
| @@ -4494,7 +4496,7 @@ VALUE. In any case, return VALUE. */) | |||
| 4494 | (Lisp_Object key, Lisp_Object value, Lisp_Object table) | 4496 | (Lisp_Object key, Lisp_Object value, Lisp_Object table) |
| 4495 | { | 4497 | { |
| 4496 | struct Lisp_Hash_Table *h = check_hash_table (table); | 4498 | struct Lisp_Hash_Table *h = check_hash_table (table); |
| 4497 | EMACS_INT i; | 4499 | ptrdiff_t i; |
| 4498 | EMACS_UINT hash; | 4500 | EMACS_UINT hash; |
| 4499 | 4501 | ||
| 4500 | i = hash_lookup (h, key, &hash); | 4502 | i = hash_lookup (h, key, &hash); |
diff --git a/src/fontset.c b/src/fontset.c index 3091f43d6e9..c8ae1e74848 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -447,7 +447,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) | |||
| 447 | /* Return a font-group (actually a cons (-1 . FONT-GROUP-VECTOR)) for | 447 | /* Return a font-group (actually a cons (-1 . FONT-GROUP-VECTOR)) for |
| 448 | character C in FONTSET. If C is -1, return a fallback font-group. | 448 | character C in FONTSET. If C is -1, return a fallback font-group. |
| 449 | If C is not -1, the value may be Qt (FONTSET doesn't have a font | 449 | If C is not -1, the value may be Qt (FONTSET doesn't have a font |
| 450 | for C even in the fallback group, or 0 (a font for C may be found | 450 | for C even in the fallback group), or 0 (a font for C may be found |
| 451 | only in the fallback group). */ | 451 | only in the fallback group). */ |
| 452 | 452 | ||
| 453 | static Lisp_Object | 453 | static Lisp_Object |
| @@ -465,7 +465,9 @@ fontset_get_font_group (Lisp_Object fontset, int c) | |||
| 465 | if (! NILP (font_group)) | 465 | if (! NILP (font_group)) |
| 466 | return font_group; | 466 | return font_group; |
| 467 | base_fontset = FONTSET_BASE (fontset); | 467 | base_fontset = FONTSET_BASE (fontset); |
| 468 | if (c >= 0) | 468 | if (NILP (base_fontset)) |
| 469 | font_group = Qnil; | ||
| 470 | else if (c >= 0) | ||
| 469 | font_group = char_table_ref_and_range (base_fontset, c, &from, &to); | 471 | font_group = char_table_ref_and_range (base_fontset, c, &from, &to); |
| 470 | else | 472 | else |
| 471 | font_group = FONTSET_FALLBACK (base_fontset); | 473 | font_group = FONTSET_FALLBACK (base_fontset); |
| @@ -476,6 +478,8 @@ fontset_get_font_group (Lisp_Object fontset, int c) | |||
| 476 | char_table_set_range (fontset, from, to, font_group); | 478 | char_table_set_range (fontset, from, to, font_group); |
| 477 | return font_group; | 479 | return font_group; |
| 478 | } | 480 | } |
| 481 | if (!VECTORP (font_group)) | ||
| 482 | return font_group; | ||
| 479 | font_group = Fcopy_sequence (font_group); | 483 | font_group = Fcopy_sequence (font_group); |
| 480 | for (i = 0; i < ASIZE (font_group); i++) | 484 | for (i = 0; i < ASIZE (font_group); i++) |
| 481 | if (! NILP (AREF (font_group, i))) | 485 | if (! NILP (AREF (font_group, i))) |
| @@ -2100,6 +2104,8 @@ DEFUN ("fontset-list", Ffontset_list, Sfontset_list, 0, 0, 0, | |||
| 2100 | 2104 | ||
| 2101 | #ifdef FONTSET_DEBUG | 2105 | #ifdef FONTSET_DEBUG |
| 2102 | 2106 | ||
| 2107 | Lisp_Object dump_fontset (Lisp_Object) EXTERNALLY_VISIBLE; | ||
| 2108 | |||
| 2103 | Lisp_Object | 2109 | Lisp_Object |
| 2104 | dump_fontset (Lisp_Object fontset) | 2110 | dump_fontset (Lisp_Object fontset) |
| 2105 | { | 2111 | { |
diff --git a/src/frame.c b/src/frame.c index 19ce78dfd9c..711109a70c6 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -160,7 +160,7 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) | |||
| 160 | if (FRAME_MINIBUF_ONLY_P (f)) | 160 | if (FRAME_MINIBUF_ONLY_P (f)) |
| 161 | return; | 161 | return; |
| 162 | 162 | ||
| 163 | if (INTEGERP (value)) | 163 | if (TYPE_RANGED_INTEGERP (int, value)) |
| 164 | nlines = XINT (value); | 164 | nlines = XINT (value); |
| 165 | else | 165 | else |
| 166 | nlines = 0; | 166 | nlines = 0; |
| @@ -2992,7 +2992,7 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 2992 | f->size_hint_flags &= ~ (XNegative | YNegative); | 2992 | f->size_hint_flags &= ~ (XNegative | YNegative); |
| 2993 | if (EQ (left, Qminus)) | 2993 | if (EQ (left, Qminus)) |
| 2994 | f->size_hint_flags |= XNegative; | 2994 | f->size_hint_flags |= XNegative; |
| 2995 | else if (INTEGERP (left)) | 2995 | else if (TYPE_RANGED_INTEGERP (int, left)) |
| 2996 | { | 2996 | { |
| 2997 | leftpos = XINT (left); | 2997 | leftpos = XINT (left); |
| 2998 | if (leftpos < 0) | 2998 | if (leftpos < 0) |
| @@ -3000,21 +3000,21 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 3000 | } | 3000 | } |
| 3001 | else if (CONSP (left) && EQ (XCAR (left), Qminus) | 3001 | else if (CONSP (left) && EQ (XCAR (left), Qminus) |
| 3002 | && CONSP (XCDR (left)) | 3002 | && CONSP (XCDR (left)) |
| 3003 | && INTEGERP (XCAR (XCDR (left)))) | 3003 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (left)), INT_MAX)) |
| 3004 | { | 3004 | { |
| 3005 | leftpos = - XINT (XCAR (XCDR (left))); | 3005 | leftpos = - XINT (XCAR (XCDR (left))); |
| 3006 | f->size_hint_flags |= XNegative; | 3006 | f->size_hint_flags |= XNegative; |
| 3007 | } | 3007 | } |
| 3008 | else if (CONSP (left) && EQ (XCAR (left), Qplus) | 3008 | else if (CONSP (left) && EQ (XCAR (left), Qplus) |
| 3009 | && CONSP (XCDR (left)) | 3009 | && CONSP (XCDR (left)) |
| 3010 | && INTEGERP (XCAR (XCDR (left)))) | 3010 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left)))) |
| 3011 | { | 3011 | { |
| 3012 | leftpos = XINT (XCAR (XCDR (left))); | 3012 | leftpos = XINT (XCAR (XCDR (left))); |
| 3013 | } | 3013 | } |
| 3014 | 3014 | ||
| 3015 | if (EQ (top, Qminus)) | 3015 | if (EQ (top, Qminus)) |
| 3016 | f->size_hint_flags |= YNegative; | 3016 | f->size_hint_flags |= YNegative; |
| 3017 | else if (INTEGERP (top)) | 3017 | else if (TYPE_RANGED_INTEGERP (int, top)) |
| 3018 | { | 3018 | { |
| 3019 | toppos = XINT (top); | 3019 | toppos = XINT (top); |
| 3020 | if (toppos < 0) | 3020 | if (toppos < 0) |
| @@ -3022,14 +3022,14 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 3022 | } | 3022 | } |
| 3023 | else if (CONSP (top) && EQ (XCAR (top), Qminus) | 3023 | else if (CONSP (top) && EQ (XCAR (top), Qminus) |
| 3024 | && CONSP (XCDR (top)) | 3024 | && CONSP (XCDR (top)) |
| 3025 | && INTEGERP (XCAR (XCDR (top)))) | 3025 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (top)), INT_MAX)) |
| 3026 | { | 3026 | { |
| 3027 | toppos = - XINT (XCAR (XCDR (top))); | 3027 | toppos = - XINT (XCAR (XCDR (top))); |
| 3028 | f->size_hint_flags |= YNegative; | 3028 | f->size_hint_flags |= YNegative; |
| 3029 | } | 3029 | } |
| 3030 | else if (CONSP (top) && EQ (XCAR (top), Qplus) | 3030 | else if (CONSP (top) && EQ (XCAR (top), Qplus) |
| 3031 | && CONSP (XCDR (top)) | 3031 | && CONSP (XCDR (top)) |
| 3032 | && INTEGERP (XCAR (XCDR (top)))) | 3032 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top)))) |
| 3033 | { | 3033 | { |
| 3034 | toppos = XINT (XCAR (XCDR (top))); | 3034 | toppos = XINT (XCAR (XCDR (top))); |
| 3035 | } | 3035 | } |
| @@ -3481,7 +3481,7 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3481 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); | 3481 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); |
| 3482 | do_pending_window_change (0); | 3482 | do_pending_window_change (0); |
| 3483 | } | 3483 | } |
| 3484 | else if (INTEGERP (arg) && XINT (arg) > 0 | 3484 | else if (RANGED_INTEGERP (1, arg, INT_MAX) |
| 3485 | && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) | 3485 | && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) |
| 3486 | { | 3486 | { |
| 3487 | if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM) | 3487 | if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM) |
| @@ -3520,7 +3520,7 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3520 | { | 3520 | { |
| 3521 | double alpha = 1.0; | 3521 | double alpha = 1.0; |
| 3522 | double newval[2]; | 3522 | double newval[2]; |
| 3523 | int i, ialpha; | 3523 | int i; |
| 3524 | Lisp_Object item; | 3524 | Lisp_Object item; |
| 3525 | 3525 | ||
| 3526 | for (i = 0; i < 2; i++) | 3526 | for (i = 0; i < 2; i++) |
| @@ -3544,7 +3544,7 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 3544 | } | 3544 | } |
| 3545 | else if (INTEGERP (item)) | 3545 | else if (INTEGERP (item)) |
| 3546 | { | 3546 | { |
| 3547 | ialpha = XINT (item); | 3547 | EMACS_INT ialpha = XINT (item); |
| 3548 | if (ialpha < 0 || 100 < ialpha) | 3548 | if (ialpha < 0 || 100 < ialpha) |
| 3549 | args_out_of_range (make_number (0), make_number (100)); | 3549 | args_out_of_range (make_number (0), make_number (100)); |
| 3550 | else | 3550 | else |
| @@ -4031,11 +4031,15 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4031 | if (!EQ (tem0, Qunbound)) | 4031 | if (!EQ (tem0, Qunbound)) |
| 4032 | { | 4032 | { |
| 4033 | CHECK_NUMBER (tem0); | 4033 | CHECK_NUMBER (tem0); |
| 4034 | if (! (0 <= XINT (tem0) && XINT (tem0) <= INT_MAX)) | ||
| 4035 | xsignal1 (Qargs_out_of_range, tem0); | ||
| 4034 | FRAME_LINES (f) = XINT (tem0); | 4036 | FRAME_LINES (f) = XINT (tem0); |
| 4035 | } | 4037 | } |
| 4036 | if (!EQ (tem1, Qunbound)) | 4038 | if (!EQ (tem1, Qunbound)) |
| 4037 | { | 4039 | { |
| 4038 | CHECK_NUMBER (tem1); | 4040 | CHECK_NUMBER (tem1); |
| 4041 | if (! (0 <= XINT (tem1) && XINT (tem1) <= INT_MAX)) | ||
| 4042 | xsignal1 (Qargs_out_of_range, tem1); | ||
| 4039 | SET_FRAME_COLS (f, XINT (tem1)); | 4043 | SET_FRAME_COLS (f, XINT (tem1)); |
| 4040 | } | 4044 | } |
| 4041 | if (!NILP (tem2) && !EQ (tem2, Qunbound)) | 4045 | if (!NILP (tem2) && !EQ (tem2, Qunbound)) |
| @@ -4066,12 +4070,10 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4066 | ? tool_bar_button_relief | 4070 | ? tool_bar_button_relief |
| 4067 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); | 4071 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); |
| 4068 | 4072 | ||
| 4069 | if (INTEGERP (Vtool_bar_button_margin) | 4073 | if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX)) |
| 4070 | && XINT (Vtool_bar_button_margin) > 0) | ||
| 4071 | margin = XFASTINT (Vtool_bar_button_margin); | 4074 | margin = XFASTINT (Vtool_bar_button_margin); |
| 4072 | else if (CONSP (Vtool_bar_button_margin) | 4075 | else if (CONSP (Vtool_bar_button_margin) |
| 4073 | && INTEGERP (XCDR (Vtool_bar_button_margin)) | 4076 | && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin), INT_MAX)) |
| 4074 | && XINT (XCDR (Vtool_bar_button_margin)) > 0) | ||
| 4075 | margin = XFASTINT (XCDR (Vtool_bar_button_margin)); | 4077 | margin = XFASTINT (XCDR (Vtool_bar_button_margin)); |
| 4076 | else | 4078 | else |
| 4077 | margin = 0; | 4079 | margin = 0; |
| @@ -4097,14 +4099,14 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4097 | } | 4099 | } |
| 4098 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus) | 4100 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus) |
| 4099 | && CONSP (XCDR (tem0)) | 4101 | && CONSP (XCDR (tem0)) |
| 4100 | && INTEGERP (XCAR (XCDR (tem0)))) | 4102 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem0)), INT_MAX)) |
| 4101 | { | 4103 | { |
| 4102 | f->top_pos = - XINT (XCAR (XCDR (tem0))); | 4104 | f->top_pos = - XINT (XCAR (XCDR (tem0))); |
| 4103 | window_prompting |= YNegative; | 4105 | window_prompting |= YNegative; |
| 4104 | } | 4106 | } |
| 4105 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus) | 4107 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus) |
| 4106 | && CONSP (XCDR (tem0)) | 4108 | && CONSP (XCDR (tem0)) |
| 4107 | && INTEGERP (XCAR (XCDR (tem0)))) | 4109 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0)))) |
| 4108 | { | 4110 | { |
| 4109 | f->top_pos = XINT (XCAR (XCDR (tem0))); | 4111 | f->top_pos = XINT (XCAR (XCDR (tem0))); |
| 4110 | } | 4112 | } |
| @@ -4125,14 +4127,14 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) | |||
| 4125 | } | 4127 | } |
| 4126 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus) | 4128 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus) |
| 4127 | && CONSP (XCDR (tem1)) | 4129 | && CONSP (XCDR (tem1)) |
| 4128 | && INTEGERP (XCAR (XCDR (tem1)))) | 4130 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem1)), INT_MAX)) |
| 4129 | { | 4131 | { |
| 4130 | f->left_pos = - XINT (XCAR (XCDR (tem1))); | 4132 | f->left_pos = - XINT (XCAR (XCDR (tem1))); |
| 4131 | window_prompting |= XNegative; | 4133 | window_prompting |= XNegative; |
| 4132 | } | 4134 | } |
| 4133 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus) | 4135 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus) |
| 4134 | && CONSP (XCDR (tem1)) | 4136 | && CONSP (XCDR (tem1)) |
| 4135 | && INTEGERP (XCAR (XCDR (tem1)))) | 4137 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1)))) |
| 4136 | { | 4138 | { |
| 4137 | f->left_pos = XINT (XCAR (XCDR (tem1))); | 4139 | f->left_pos = XINT (XCAR (XCDR (tem1))); |
| 4138 | } | 4140 | } |
diff --git a/src/frame.h b/src/frame.h index 8dccfb8540a..3775403810f 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -258,11 +258,11 @@ struct frame | |||
| 258 | 258 | ||
| 259 | /* Size of this frame, excluding fringes, scroll bars etc., | 259 | /* Size of this frame, excluding fringes, scroll bars etc., |
| 260 | in units of canonical characters. */ | 260 | in units of canonical characters. */ |
| 261 | EMACS_INT text_lines, text_cols; | 261 | int text_lines, text_cols; |
| 262 | 262 | ||
| 263 | /* Total size of this frame (i.e. its native window), in units of | 263 | /* Total size of this frame (i.e. its native window), in units of |
| 264 | canonical characters. */ | 264 | canonical characters. */ |
| 265 | EMACS_INT total_lines, total_cols; | 265 | int total_lines, total_cols; |
| 266 | 266 | ||
| 267 | /* New text height and width for pending size change. | 267 | /* New text height and width for pending size change. |
| 268 | 0 if no change pending. */ | 268 | 0 if no change pending. */ |
diff --git a/src/fringe.c b/src/fringe.c index a4dc9433aff..5878c541247 100644 --- a/src/fringe.c +++ b/src/fringe.c | |||
| @@ -1610,22 +1610,25 @@ If BITMAP already exists, the existing definition is replaced. */) | |||
| 1610 | 1610 | ||
| 1611 | if (n == max_fringe_bitmaps) | 1611 | if (n == max_fringe_bitmaps) |
| 1612 | { | 1612 | { |
| 1613 | if ((max_fringe_bitmaps + 20) > MAX_FRINGE_BITMAPS) | 1613 | int bitmaps = max_fringe_bitmaps + 20; |
| 1614 | if (MAX_FRINGE_BITMAPS < bitmaps) | ||
| 1614 | error ("No free fringe bitmap slots"); | 1615 | error ("No free fringe bitmap slots"); |
| 1615 | 1616 | ||
| 1616 | i = max_fringe_bitmaps; | 1617 | i = max_fringe_bitmaps; |
| 1617 | max_fringe_bitmaps += 20; | ||
| 1618 | fringe_bitmaps | 1618 | fringe_bitmaps |
| 1619 | = ((struct fringe_bitmap **) | 1619 | = ((struct fringe_bitmap **) |
| 1620 | xrealloc (fringe_bitmaps, max_fringe_bitmaps * sizeof (struct fringe_bitmap *))); | 1620 | xrealloc (fringe_bitmaps, bitmaps * sizeof *fringe_bitmaps)); |
| 1621 | fringe_faces | 1621 | fringe_faces |
| 1622 | = (Lisp_Object *) xrealloc (fringe_faces, max_fringe_bitmaps * sizeof (Lisp_Object)); | 1622 | = (Lisp_Object *) xrealloc (fringe_faces, |
| 1623 | bitmaps * sizeof *fringe_faces); | ||
| 1623 | 1624 | ||
| 1624 | for (; i < max_fringe_bitmaps; i++) | 1625 | for (i = max_fringe_bitmaps; i < bitmaps; i++) |
| 1625 | { | 1626 | { |
| 1626 | fringe_bitmaps[i] = NULL; | 1627 | fringe_bitmaps[i] = NULL; |
| 1627 | fringe_faces[i] = Qnil; | 1628 | fringe_faces[i] = Qnil; |
| 1628 | } | 1629 | } |
| 1630 | |||
| 1631 | max_fringe_bitmaps = bitmaps; | ||
| 1629 | } | 1632 | } |
| 1630 | } | 1633 | } |
| 1631 | 1634 | ||
diff --git a/src/ftfont.c b/src/ftfont.c index 4e313a89021..7858a31be21 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -214,6 +214,10 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) | |||
| 214 | 214 | ||
| 215 | for (i = 0; i < FONT_OBJLIST_INDEX; i++) | 215 | for (i = 0; i < FONT_OBJLIST_INDEX; i++) |
| 216 | ASET (val, i, AREF (entity, i)); | 216 | ASET (val, i, AREF (entity, i)); |
| 217 | |||
| 218 | ASET (val, FONT_EXTRA_INDEX, Fcopy_sequence (extra)); | ||
| 219 | font_put_extra (val, QCfont_entity, key); | ||
| 220 | |||
| 217 | return val; | 221 | return val; |
| 218 | } | 222 | } |
| 219 | entity = font_make_entity (); | 223 | entity = font_make_entity (); |
| @@ -682,7 +686,10 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec) | |||
| 682 | if (NILP (val)) | 686 | if (NILP (val)) |
| 683 | continue; | 687 | continue; |
| 684 | len = Flength (val); | 688 | len = Flength (val); |
| 685 | spec->features[i] = malloc (sizeof (int) * XINT (len)); | 689 | spec->features[i] = |
| 690 | (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len) | ||
| 691 | ? 0 | ||
| 692 | : malloc (sizeof (int) * XINT (len))); | ||
| 686 | if (! spec->features[i]) | 693 | if (! spec->features[i]) |
| 687 | { | 694 | { |
| 688 | if (i > 0 && spec->features[0]) | 695 | if (i > 0 && spec->features[0]) |
| @@ -1761,15 +1768,10 @@ static OTF_GlyphString otf_gstring; | |||
| 1761 | static void | 1768 | static void |
| 1762 | setup_otf_gstring (int size) | 1769 | setup_otf_gstring (int size) |
| 1763 | { | 1770 | { |
| 1764 | if (otf_gstring.size == 0) | 1771 | if (otf_gstring.size < size) |
| 1765 | { | ||
| 1766 | otf_gstring.glyphs = (OTF_Glyph *) xmalloc (sizeof (OTF_Glyph) * size); | ||
| 1767 | otf_gstring.size = size; | ||
| 1768 | } | ||
| 1769 | else if (otf_gstring.size < size) | ||
| 1770 | { | 1772 | { |
| 1771 | otf_gstring.glyphs = xrealloc (otf_gstring.glyphs, | 1773 | otf_gstring.glyphs = xnrealloc (otf_gstring.glyphs, |
| 1772 | sizeof (OTF_Glyph) * size); | 1774 | size, sizeof (OTF_Glyph)); |
| 1773 | otf_gstring.size = size; | 1775 | otf_gstring.size = size; |
| 1774 | } | 1776 | } |
| 1775 | otf_gstring.used = size; | 1777 | otf_gstring.used = size; |
| @@ -2445,17 +2447,19 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, | |||
| 2445 | } | 2447 | } |
| 2446 | } | 2448 | } |
| 2447 | 2449 | ||
| 2450 | if (INT_MAX / 2 < len) | ||
| 2451 | memory_full (SIZE_MAX); | ||
| 2452 | |||
| 2448 | if (gstring.allocated == 0) | 2453 | if (gstring.allocated == 0) |
| 2449 | { | 2454 | { |
| 2450 | gstring.allocated = len * 2; | ||
| 2451 | gstring.glyph_size = sizeof (MFLTGlyph); | 2455 | gstring.glyph_size = sizeof (MFLTGlyph); |
| 2452 | gstring.glyphs = xmalloc (sizeof (MFLTGlyph) * gstring.allocated); | 2456 | gstring.glyphs = xnmalloc (len * 2, sizeof (MFLTGlyph)); |
| 2457 | gstring.allocated = len * 2; | ||
| 2453 | } | 2458 | } |
| 2454 | else if (gstring.allocated < len * 2) | 2459 | else if (gstring.allocated < len * 2) |
| 2455 | { | 2460 | { |
| 2461 | gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, sizeof (MFLTGlyph)); | ||
| 2456 | gstring.allocated = len * 2; | 2462 | gstring.allocated = len * 2; |
| 2457 | gstring.glyphs = xrealloc (gstring.glyphs, | ||
| 2458 | sizeof (MFLTGlyph) * gstring.allocated); | ||
| 2459 | } | 2463 | } |
| 2460 | memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); | 2464 | memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); |
| 2461 | for (i = 0; i < len; i++) | 2465 | for (i = 0; i < len; i++) |
| @@ -2504,9 +2508,11 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, | |||
| 2504 | int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt); | 2508 | int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt); |
| 2505 | if (result != -2) | 2509 | if (result != -2) |
| 2506 | break; | 2510 | break; |
| 2507 | gstring.allocated += gstring.allocated; | 2511 | if (INT_MAX / 2 < gstring.allocated) |
| 2508 | gstring.glyphs = xrealloc (gstring.glyphs, | 2512 | memory_full (SIZE_MAX); |
| 2509 | sizeof (MFLTGlyph) * gstring.allocated); | 2513 | gstring.glyphs = xnrealloc (gstring.glyphs, |
| 2514 | gstring.allocated, 2 * sizeof (MFLTGlyph)); | ||
| 2515 | gstring.allocated *= 2; | ||
| 2510 | } | 2516 | } |
| 2511 | if (gstring.used > LGSTRING_GLYPH_LEN (lgstring)) | 2517 | if (gstring.used > LGSTRING_GLYPH_LEN (lgstring)) |
| 2512 | return Qnil; | 2518 | return Qnil; |
diff --git a/src/gmalloc.c b/src/gmalloc.c index fa4aa1fdf6a..d49259b8ed7 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -37,7 +37,7 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 37 | #include <config.h> | 37 | #include <config.h> |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #ifdef HAVE_GTK_AND_PTHREAD | 40 | #ifdef HAVE_PTHREAD |
| 41 | #define USE_PTHREAD | 41 | #define USE_PTHREAD |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| @@ -351,10 +351,21 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 351 | #endif | 351 | #endif |
| 352 | #include <errno.h> | 352 | #include <errno.h> |
| 353 | 353 | ||
| 354 | /* How to really get more memory. */ | 354 | /* On Cygwin there are two heaps. temacs uses the static heap |
| 355 | #if defined(CYGWIN) | 355 | (defined in sheap.c and managed with bss_sbrk), and the dumped |
| 356 | emacs uses the Cygwin heap (managed with sbrk). When emacs starts | ||
| 357 | on Cygwin, it reinitializes malloc, and we save the old info for | ||
| 358 | use by free and realloc if they're called with a pointer into the | ||
| 359 | static heap. | ||
| 360 | |||
| 361 | Currently (2011-08-16) the Cygwin build doesn't use ralloc.c; if | ||
| 362 | this is changed in the future, we'll have to similarly deal with | ||
| 363 | reinitializing ralloc. */ | ||
| 364 | #ifdef CYGWIN | ||
| 356 | extern __ptr_t bss_sbrk PP ((ptrdiff_t __size)); | 365 | extern __ptr_t bss_sbrk PP ((ptrdiff_t __size)); |
| 357 | extern int bss_sbrk_did_unexec; | 366 | extern int bss_sbrk_did_unexec; |
| 367 | char *bss_sbrk_heapbase; /* _heapbase for static heap */ | ||
| 368 | malloc_info *bss_sbrk_heapinfo; /* _heapinfo for static heap */ | ||
| 358 | #endif | 369 | #endif |
| 359 | __ptr_t (*__morecore) PP ((__malloc_ptrdiff_t __size)) = __default_morecore; | 370 | __ptr_t (*__morecore) PP ((__malloc_ptrdiff_t __size)) = __default_morecore; |
| 360 | 371 | ||
| @@ -584,6 +595,16 @@ malloc_initialize_1 () | |||
| 584 | mcheck (NULL); | 595 | mcheck (NULL); |
| 585 | #endif | 596 | #endif |
| 586 | 597 | ||
| 598 | #ifdef CYGWIN | ||
| 599 | if (bss_sbrk_did_unexec) | ||
| 600 | /* we're reinitializing the dumped emacs */ | ||
| 601 | { | ||
| 602 | bss_sbrk_heapbase = _heapbase; | ||
| 603 | bss_sbrk_heapinfo = _heapinfo; | ||
| 604 | memset (_fraghead, 0, BLOCKLOG * sizeof (struct list)); | ||
| 605 | } | ||
| 606 | #endif | ||
| 607 | |||
| 587 | if (__malloc_initialize_hook) | 608 | if (__malloc_initialize_hook) |
| 588 | (*__malloc_initialize_hook) (); | 609 | (*__malloc_initialize_hook) (); |
| 589 | 610 | ||
| @@ -1054,6 +1075,12 @@ _free_internal_nolock (ptr) | |||
| 1054 | if (ptr == NULL) | 1075 | if (ptr == NULL) |
| 1055 | return; | 1076 | return; |
| 1056 | 1077 | ||
| 1078 | #ifdef CYGWIN | ||
| 1079 | if (ptr < _heapbase) | ||
| 1080 | /* We're being asked to free something in the static heap. */ | ||
| 1081 | return; | ||
| 1082 | #endif | ||
| 1083 | |||
| 1057 | PROTECT_MALLOC_STATE (0); | 1084 | PROTECT_MALLOC_STATE (0); |
| 1058 | 1085 | ||
| 1059 | LOCK_ALIGNED_BLOCKS (); | 1086 | LOCK_ALIGNED_BLOCKS (); |
| @@ -1349,6 +1376,31 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 1349 | 1376 | ||
| 1350 | #define min(A, B) ((A) < (B) ? (A) : (B)) | 1377 | #define min(A, B) ((A) < (B) ? (A) : (B)) |
| 1351 | 1378 | ||
| 1379 | /* On Cygwin the dumped emacs may try to realloc storage allocated in | ||
| 1380 | the static heap. We just malloc space in the new heap and copy the | ||
| 1381 | data. */ | ||
| 1382 | #ifdef CYGWIN | ||
| 1383 | __ptr_t | ||
| 1384 | special_realloc (ptr, size) | ||
| 1385 | __ptr_t ptr; | ||
| 1386 | __malloc_size_t size; | ||
| 1387 | { | ||
| 1388 | __ptr_t result; | ||
| 1389 | int type; | ||
| 1390 | __malloc_size_t block, oldsize; | ||
| 1391 | |||
| 1392 | block = ((char *) ptr - bss_sbrk_heapbase) / BLOCKSIZE + 1; | ||
| 1393 | type = bss_sbrk_heapinfo[block].busy.type; | ||
| 1394 | oldsize = | ||
| 1395 | type == 0 ? bss_sbrk_heapinfo[block].busy.info.size * BLOCKSIZE | ||
| 1396 | : (__malloc_size_t) 1 << type; | ||
| 1397 | result = _malloc_internal_nolock (size); | ||
| 1398 | if (result != NULL) | ||
| 1399 | memcpy (result, ptr, min (oldsize, size)); | ||
| 1400 | return result; | ||
| 1401 | } | ||
| 1402 | #endif | ||
| 1403 | |||
| 1352 | /* Debugging hook for realloc. */ | 1404 | /* Debugging hook for realloc. */ |
| 1353 | __ptr_t (*__realloc_hook) PP ((__ptr_t __ptr, __malloc_size_t __size)); | 1405 | __ptr_t (*__realloc_hook) PP ((__ptr_t __ptr, __malloc_size_t __size)); |
| 1354 | 1406 | ||
| @@ -1375,6 +1427,12 @@ _realloc_internal_nolock (ptr, size) | |||
| 1375 | else if (ptr == NULL) | 1427 | else if (ptr == NULL) |
| 1376 | return _malloc_internal_nolock (size); | 1428 | return _malloc_internal_nolock (size); |
| 1377 | 1429 | ||
| 1430 | #ifdef CYGWIN | ||
| 1431 | if (ptr < _heapbase) | ||
| 1432 | /* ptr points into the static heap */ | ||
| 1433 | return special_realloc (ptr, size); | ||
| 1434 | #endif | ||
| 1435 | |||
| 1378 | block = BLOCK (ptr); | 1436 | block = BLOCK (ptr); |
| 1379 | 1437 | ||
| 1380 | PROTECT_MALLOC_STATE (0); | 1438 | PROTECT_MALLOC_STATE (0); |
diff --git a/src/gnutls.c b/src/gnutls.c index fc651d2c7e4..0743ef3f4ee 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -42,19 +42,19 @@ static Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again, | |||
| 42 | static int gnutls_global_initialized; | 42 | static int gnutls_global_initialized; |
| 43 | 43 | ||
| 44 | /* The following are for the property list of `gnutls-boot'. */ | 44 | /* The following are for the property list of `gnutls-boot'. */ |
| 45 | static Lisp_Object Qgnutls_bootprop_priority; | 45 | static Lisp_Object QCgnutls_bootprop_priority; |
| 46 | static Lisp_Object Qgnutls_bootprop_trustfiles; | 46 | static Lisp_Object QCgnutls_bootprop_trustfiles; |
| 47 | static Lisp_Object Qgnutls_bootprop_keylist; | 47 | static Lisp_Object QCgnutls_bootprop_keylist; |
| 48 | static Lisp_Object Qgnutls_bootprop_crlfiles; | 48 | static Lisp_Object QCgnutls_bootprop_crlfiles; |
| 49 | static Lisp_Object Qgnutls_bootprop_callbacks; | 49 | static Lisp_Object QCgnutls_bootprop_callbacks; |
| 50 | static Lisp_Object Qgnutls_bootprop_loglevel; | 50 | static Lisp_Object QCgnutls_bootprop_loglevel; |
| 51 | static Lisp_Object Qgnutls_bootprop_hostname; | 51 | static Lisp_Object QCgnutls_bootprop_hostname; |
| 52 | static Lisp_Object Qgnutls_bootprop_min_prime_bits; | 52 | static Lisp_Object QCgnutls_bootprop_min_prime_bits; |
| 53 | static Lisp_Object Qgnutls_bootprop_verify_flags; | 53 | static Lisp_Object QCgnutls_bootprop_verify_flags; |
| 54 | static Lisp_Object Qgnutls_bootprop_verify_hostname_error; | 54 | static Lisp_Object QCgnutls_bootprop_verify_hostname_error; |
| 55 | 55 | ||
| 56 | /* Callback keys for `gnutls-boot'. Unused currently. */ | 56 | /* Callback keys for `gnutls-boot'. Unused currently. */ |
| 57 | static Lisp_Object Qgnutls_bootprop_callbacks_verify; | 57 | static Lisp_Object QCgnutls_bootprop_callbacks_verify; |
| 58 | 58 | ||
| 59 | static void gnutls_log_function (int, const char *); | 59 | static void gnutls_log_function (int, const char *); |
| 60 | static void gnutls_log_function2 (int, const char*, const char*); | 60 | static void gnutls_log_function2 (int, const char*, const char*); |
| @@ -72,41 +72,41 @@ static void gnutls_log_function2 (int, const char*, const char*); | |||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | DEF_GNUTLS_FN (gnutls_alert_description_t, gnutls_alert_get, | 74 | DEF_GNUTLS_FN (gnutls_alert_description_t, gnutls_alert_get, |
| 75 | (gnutls_session_t)); | 75 | (gnutls_session_t)); |
| 76 | DEF_GNUTLS_FN (const char *, gnutls_alert_get_name, | 76 | DEF_GNUTLS_FN (const char *, gnutls_alert_get_name, |
| 77 | (gnutls_alert_description_t)); | 77 | (gnutls_alert_description_t)); |
| 78 | DEF_GNUTLS_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int)); | 78 | DEF_GNUTLS_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int)); |
| 79 | DEF_GNUTLS_FN (int, gnutls_anon_allocate_client_credentials, | 79 | DEF_GNUTLS_FN (int, gnutls_anon_allocate_client_credentials, |
| 80 | (gnutls_anon_client_credentials_t *)); | 80 | (gnutls_anon_client_credentials_t *)); |
| 81 | DEF_GNUTLS_FN (void, gnutls_anon_free_client_credentials, | 81 | DEF_GNUTLS_FN (void, gnutls_anon_free_client_credentials, |
| 82 | (gnutls_anon_client_credentials_t)); | 82 | (gnutls_anon_client_credentials_t)); |
| 83 | DEF_GNUTLS_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t)); | 83 | DEF_GNUTLS_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t)); |
| 84 | DEF_GNUTLS_FN (int, gnutls_certificate_allocate_credentials, | 84 | DEF_GNUTLS_FN (int, gnutls_certificate_allocate_credentials, |
| 85 | (gnutls_certificate_credentials_t *)); | 85 | (gnutls_certificate_credentials_t *)); |
| 86 | DEF_GNUTLS_FN (void, gnutls_certificate_free_credentials, | 86 | DEF_GNUTLS_FN (void, gnutls_certificate_free_credentials, |
| 87 | (gnutls_certificate_credentials_t)); | 87 | (gnutls_certificate_credentials_t)); |
| 88 | DEF_GNUTLS_FN (const gnutls_datum_t *, gnutls_certificate_get_peers, | 88 | DEF_GNUTLS_FN (const gnutls_datum_t *, gnutls_certificate_get_peers, |
| 89 | (gnutls_session_t, unsigned int *)); | 89 | (gnutls_session_t, unsigned int *)); |
| 90 | DEF_GNUTLS_FN (void, gnutls_certificate_set_verify_flags, | 90 | DEF_GNUTLS_FN (void, gnutls_certificate_set_verify_flags, |
| 91 | (gnutls_certificate_credentials_t, unsigned int)); | 91 | (gnutls_certificate_credentials_t, unsigned int)); |
| 92 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_crl_file, | 92 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_crl_file, |
| 93 | (gnutls_certificate_credentials_t, const char *, | 93 | (gnutls_certificate_credentials_t, const char *, |
| 94 | gnutls_x509_crt_fmt_t)); | 94 | gnutls_x509_crt_fmt_t)); |
| 95 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_key_file, | 95 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_key_file, |
| 96 | (gnutls_certificate_credentials_t, const char *, const char *, | 96 | (gnutls_certificate_credentials_t, const char *, const char *, |
| 97 | gnutls_x509_crt_fmt_t)); | 97 | gnutls_x509_crt_fmt_t)); |
| 98 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_trust_file, | 98 | DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_trust_file, |
| 99 | (gnutls_certificate_credentials_t, const char *, | 99 | (gnutls_certificate_credentials_t, const char *, |
| 100 | gnutls_x509_crt_fmt_t)); | 100 | gnutls_x509_crt_fmt_t)); |
| 101 | DEF_GNUTLS_FN (gnutls_certificate_type_t, gnutls_certificate_type_get, | 101 | DEF_GNUTLS_FN (gnutls_certificate_type_t, gnutls_certificate_type_get, |
| 102 | (gnutls_session_t)); | 102 | (gnutls_session_t)); |
| 103 | DEF_GNUTLS_FN (int, gnutls_certificate_verify_peers2, | 103 | DEF_GNUTLS_FN (int, gnutls_certificate_verify_peers2, |
| 104 | (gnutls_session_t, unsigned int *)); | 104 | (gnutls_session_t, unsigned int *)); |
| 105 | DEF_GNUTLS_FN (int, gnutls_credentials_set, | 105 | DEF_GNUTLS_FN (int, gnutls_credentials_set, |
| 106 | (gnutls_session_t, gnutls_credentials_type_t, void *)); | 106 | (gnutls_session_t, gnutls_credentials_type_t, void *)); |
| 107 | DEF_GNUTLS_FN (void, gnutls_deinit, (gnutls_session_t)); | 107 | DEF_GNUTLS_FN (void, gnutls_deinit, (gnutls_session_t)); |
| 108 | DEF_GNUTLS_FN (void, gnutls_dh_set_prime_bits, | 108 | DEF_GNUTLS_FN (void, gnutls_dh_set_prime_bits, |
| 109 | (gnutls_session_t, unsigned int)); | 109 | (gnutls_session_t, unsigned int)); |
| 110 | DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int)); | 110 | DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int)); |
| 111 | DEF_GNUTLS_FN (int, gnutls_global_init, (void)); | 111 | DEF_GNUTLS_FN (int, gnutls_global_init, (void)); |
| 112 | DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); | 112 | DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); |
| @@ -118,27 +118,27 @@ DEF_GNUTLS_FN (void, gnutls_global_set_mem_functions, | |||
| 118 | DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); | 118 | DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); |
| 119 | DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); | 119 | DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); |
| 120 | DEF_GNUTLS_FN (int, gnutls_priority_set_direct, | 120 | DEF_GNUTLS_FN (int, gnutls_priority_set_direct, |
| 121 | (gnutls_session_t, const char *, const char **)); | 121 | (gnutls_session_t, const char *, const char **)); |
| 122 | DEF_GNUTLS_FN (size_t, gnutls_record_check_pending, (gnutls_session_t)); | 122 | DEF_GNUTLS_FN (size_t, gnutls_record_check_pending, (gnutls_session_t)); |
| 123 | DEF_GNUTLS_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t)); | 123 | DEF_GNUTLS_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t)); |
| 124 | DEF_GNUTLS_FN (ssize_t, gnutls_record_send, | 124 | DEF_GNUTLS_FN (ssize_t, gnutls_record_send, |
| 125 | (gnutls_session_t, const void *, size_t)); | 125 | (gnutls_session_t, const void *, size_t)); |
| 126 | DEF_GNUTLS_FN (const char *, gnutls_strerror, (int)); | 126 | DEF_GNUTLS_FN (const char *, gnutls_strerror, (int)); |
| 127 | DEF_GNUTLS_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int)); | 127 | DEF_GNUTLS_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int)); |
| 128 | DEF_GNUTLS_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int)); | 128 | DEF_GNUTLS_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int)); |
| 129 | DEF_GNUTLS_FN (void, gnutls_transport_set_ptr2, | 129 | DEF_GNUTLS_FN (void, gnutls_transport_set_ptr2, |
| 130 | (gnutls_session_t, gnutls_transport_ptr_t, | 130 | (gnutls_session_t, gnutls_transport_ptr_t, |
| 131 | gnutls_transport_ptr_t)); | 131 | gnutls_transport_ptr_t)); |
| 132 | DEF_GNUTLS_FN (void, gnutls_transport_set_pull_function, | 132 | DEF_GNUTLS_FN (void, gnutls_transport_set_pull_function, |
| 133 | (gnutls_session_t, gnutls_pull_func)); | 133 | (gnutls_session_t, gnutls_pull_func)); |
| 134 | DEF_GNUTLS_FN (void, gnutls_transport_set_push_function, | 134 | DEF_GNUTLS_FN (void, gnutls_transport_set_push_function, |
| 135 | (gnutls_session_t, gnutls_push_func)); | 135 | (gnutls_session_t, gnutls_push_func)); |
| 136 | DEF_GNUTLS_FN (int, gnutls_x509_crt_check_hostname, | 136 | DEF_GNUTLS_FN (int, gnutls_x509_crt_check_hostname, |
| 137 | (gnutls_x509_crt_t, const char *)); | 137 | (gnutls_x509_crt_t, const char *)); |
| 138 | DEF_GNUTLS_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); | 138 | DEF_GNUTLS_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); |
| 139 | DEF_GNUTLS_FN (int, gnutls_x509_crt_import, | 139 | DEF_GNUTLS_FN (int, gnutls_x509_crt_import, |
| 140 | (gnutls_x509_crt_t, const gnutls_datum_t *, | 140 | (gnutls_x509_crt_t, const gnutls_datum_t *, |
| 141 | gnutls_x509_crt_fmt_t)); | 141 | gnutls_x509_crt_fmt_t)); |
| 142 | DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); | 142 | DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); |
| 143 | 143 | ||
| 144 | static int | 144 | static int |
| @@ -196,7 +196,7 @@ init_gnutls_functions (Lisp_Object libraries) | |||
| 196 | max_log_level = global_gnutls_log_level; | 196 | max_log_level = global_gnutls_log_level; |
| 197 | 197 | ||
| 198 | GNUTLS_LOG2 (1, max_log_level, "GnuTLS library loaded:", | 198 | GNUTLS_LOG2 (1, max_log_level, "GnuTLS library loaded:", |
| 199 | SDATA (Fget (Qgnutls_dll, QCloaded_from))); | 199 | SDATA (Fget (Qgnutls_dll, QCloaded_from))); |
| 200 | return 1; | 200 | return 1; |
| 201 | } | 201 | } |
| 202 | 202 | ||
| @@ -267,29 +267,29 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) | |||
| 267 | { | 267 | { |
| 268 | #ifdef WINDOWSNT | 268 | #ifdef WINDOWSNT |
| 269 | /* On W32 we cannot transfer socket handles between different runtime | 269 | /* On W32 we cannot transfer socket handles between different runtime |
| 270 | libraries, so we tell GnuTLS to use our special push/pull | 270 | libraries, so we tell GnuTLS to use our special push/pull |
| 271 | functions. */ | 271 | functions. */ |
| 272 | fn_gnutls_transport_set_ptr2 (state, | 272 | fn_gnutls_transport_set_ptr2 (state, |
| 273 | (gnutls_transport_ptr_t) proc, | 273 | (gnutls_transport_ptr_t) proc, |
| 274 | (gnutls_transport_ptr_t) proc); | 274 | (gnutls_transport_ptr_t) proc); |
| 275 | fn_gnutls_transport_set_push_function (state, &emacs_gnutls_push); | 275 | fn_gnutls_transport_set_push_function (state, &emacs_gnutls_push); |
| 276 | fn_gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); | 276 | fn_gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); |
| 277 | 277 | ||
| 278 | /* For non blocking sockets or other custom made pull/push | 278 | /* For non blocking sockets or other custom made pull/push |
| 279 | functions the gnutls_transport_set_lowat must be called, with | 279 | functions the gnutls_transport_set_lowat must be called, with |
| 280 | a zero low water mark value. (GnuTLS 2.10.4 documentation) | 280 | a zero low water mark value. (GnuTLS 2.10.4 documentation) |
| 281 | 281 | ||
| 282 | (Note: this is probably not strictly necessary as the lowat | 282 | (Note: this is probably not strictly necessary as the lowat |
| 283 | value is only used when no custom pull/push functions are | 283 | value is only used when no custom pull/push functions are |
| 284 | set.) */ | 284 | set.) */ |
| 285 | fn_gnutls_transport_set_lowat (state, 0); | 285 | fn_gnutls_transport_set_lowat (state, 0); |
| 286 | #else | 286 | #else |
| 287 | /* This is how GnuTLS takes sockets: as file descriptors passed | 287 | /* This is how GnuTLS takes sockets: as file descriptors passed |
| 288 | in. For an Emacs process socket, infd and outfd are the | 288 | in. For an Emacs process socket, infd and outfd are the |
| 289 | same but we use this two-argument version for clarity. */ | 289 | same but we use this two-argument version for clarity. */ |
| 290 | fn_gnutls_transport_set_ptr2 (state, | 290 | fn_gnutls_transport_set_ptr2 (state, |
| 291 | (gnutls_transport_ptr_t) (long) proc->infd, | 291 | (gnutls_transport_ptr_t) (long) proc->infd, |
| 292 | (gnutls_transport_ptr_t) (long) proc->outfd); | 292 | (gnutls_transport_ptr_t) (long) proc->outfd); |
| 293 | #endif | 293 | #endif |
| 294 | 294 | ||
| 295 | proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; | 295 | proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; |
| @@ -352,12 +352,12 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte) | |||
| 352 | rtnval = fn_gnutls_record_send (state, buf, nbyte); | 352 | rtnval = fn_gnutls_record_send (state, buf, nbyte); |
| 353 | 353 | ||
| 354 | if (rtnval < 0) | 354 | if (rtnval < 0) |
| 355 | { | 355 | { |
| 356 | if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED) | 356 | if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED) |
| 357 | continue; | 357 | continue; |
| 358 | else | 358 | else |
| 359 | break; | 359 | break; |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | buf += rtnval; | 362 | buf += rtnval; |
| 363 | nbyte -= rtnval; | 363 | nbyte -= rtnval; |
| @@ -716,17 +716,17 @@ one trustfile (usually a CA bundle). */) | |||
| 716 | return gnutls_make_error (GNUTLS_EMACS_ERROR_NOT_LOADED); | 716 | return gnutls_make_error (GNUTLS_EMACS_ERROR_NOT_LOADED); |
| 717 | } | 717 | } |
| 718 | 718 | ||
| 719 | hostname = Fplist_get (proplist, Qgnutls_bootprop_hostname); | 719 | hostname = Fplist_get (proplist, QCgnutls_bootprop_hostname); |
| 720 | priority_string = Fplist_get (proplist, Qgnutls_bootprop_priority); | 720 | priority_string = Fplist_get (proplist, QCgnutls_bootprop_priority); |
| 721 | trustfiles = Fplist_get (proplist, Qgnutls_bootprop_trustfiles); | 721 | trustfiles = Fplist_get (proplist, QCgnutls_bootprop_trustfiles); |
| 722 | keylist = Fplist_get (proplist, Qgnutls_bootprop_keylist); | 722 | keylist = Fplist_get (proplist, QCgnutls_bootprop_keylist); |
| 723 | crlfiles = Fplist_get (proplist, Qgnutls_bootprop_crlfiles); | 723 | crlfiles = Fplist_get (proplist, QCgnutls_bootprop_crlfiles); |
| 724 | /* callbacks = Fplist_get (proplist, Qgnutls_bootprop_callbacks); */ | 724 | /* callbacks = Fplist_get (proplist, QCgnutls_bootprop_callbacks); */ |
| 725 | loglevel = Fplist_get (proplist, Qgnutls_bootprop_loglevel); | 725 | loglevel = Fplist_get (proplist, QCgnutls_bootprop_loglevel); |
| 726 | verify_flags = Fplist_get (proplist, Qgnutls_bootprop_verify_flags); | 726 | verify_flags = Fplist_get (proplist, QCgnutls_bootprop_verify_flags); |
| 727 | /* verify_error = Fplist_get (proplist, Qgnutls_bootprop_verify_error); */ | 727 | /* verify_error = Fplist_get (proplist, QCgnutls_bootprop_verify_error); */ |
| 728 | verify_hostname_error = Fplist_get (proplist, Qgnutls_bootprop_verify_hostname_error); | 728 | verify_hostname_error = Fplist_get (proplist, QCgnutls_bootprop_verify_hostname_error); |
| 729 | prime_bits = Fplist_get (proplist, Qgnutls_bootprop_min_prime_bits); | 729 | prime_bits = Fplist_get (proplist, QCgnutls_bootprop_min_prime_bits); |
| 730 | 730 | ||
| 731 | if (!STRINGP (hostname)) | 731 | if (!STRINGP (hostname)) |
| 732 | error ("gnutls-boot: invalid :hostname parameter"); | 732 | error ("gnutls-boot: invalid :hostname parameter"); |
| @@ -756,26 +756,26 @@ one trustfile (usually a CA bundle). */) | |||
| 756 | 756 | ||
| 757 | if (EQ (type, Qgnutls_x509pki)) | 757 | if (EQ (type, Qgnutls_x509pki)) |
| 758 | { | 758 | { |
| 759 | GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials"); | 759 | GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials"); |
| 760 | x509_cred = XPROCESS (proc)->gnutls_x509_cred; | 760 | x509_cred = XPROCESS (proc)->gnutls_x509_cred; |
| 761 | fn_gnutls_certificate_free_credentials (x509_cred); | 761 | fn_gnutls_certificate_free_credentials (x509_cred); |
| 762 | } | 762 | } |
| 763 | else if (EQ (type, Qgnutls_anon)) | 763 | else if (EQ (type, Qgnutls_anon)) |
| 764 | { | 764 | { |
| 765 | GNUTLS_LOG (2, max_log_level, "deallocating anon credentials"); | 765 | GNUTLS_LOG (2, max_log_level, "deallocating anon credentials"); |
| 766 | anon_cred = XPROCESS (proc)->gnutls_anon_cred; | 766 | anon_cred = XPROCESS (proc)->gnutls_anon_cred; |
| 767 | fn_gnutls_anon_free_client_credentials (anon_cred); | 767 | fn_gnutls_anon_free_client_credentials (anon_cred); |
| 768 | } | 768 | } |
| 769 | else | 769 | else |
| 770 | { | 770 | { |
| 771 | error ("unknown credential type"); | 771 | error ("unknown credential type"); |
| 772 | ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; | 772 | ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; |
| 773 | } | 773 | } |
| 774 | 774 | ||
| 775 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) | 775 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) |
| 776 | { | 776 | { |
| 777 | GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials"); | 777 | GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials"); |
| 778 | Fgnutls_deinit (proc); | 778 | Fgnutls_deinit (proc); |
| 779 | } | 779 | } |
| 780 | } | 780 | } |
| 781 | 781 | ||
| @@ -790,20 +790,20 @@ one trustfile (usually a CA bundle). */) | |||
| 790 | fn_gnutls_certificate_allocate_credentials (&x509_cred); | 790 | fn_gnutls_certificate_allocate_credentials (&x509_cred); |
| 791 | 791 | ||
| 792 | if (NUMBERP (verify_flags)) | 792 | if (NUMBERP (verify_flags)) |
| 793 | { | 793 | { |
| 794 | gnutls_verify_flags = XINT (verify_flags); | 794 | gnutls_verify_flags = XINT (verify_flags); |
| 795 | GNUTLS_LOG (2, max_log_level, "setting verification flags"); | 795 | GNUTLS_LOG (2, max_log_level, "setting verification flags"); |
| 796 | } | 796 | } |
| 797 | else if (NILP (verify_flags)) | 797 | else if (NILP (verify_flags)) |
| 798 | { | 798 | { |
| 799 | /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ | 799 | /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ |
| 800 | GNUTLS_LOG (2, max_log_level, "using default verification flags"); | 800 | GNUTLS_LOG (2, max_log_level, "using default verification flags"); |
| 801 | } | 801 | } |
| 802 | else | 802 | else |
| 803 | { | 803 | { |
| 804 | /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ | 804 | /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ |
| 805 | GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags"); | 805 | GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags"); |
| 806 | } | 806 | } |
| 807 | fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); | 807 | fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); |
| 808 | } | 808 | } |
| 809 | else if (EQ (type, Qgnutls_anon)) | 809 | else if (EQ (type, Qgnutls_anon)) |
| @@ -828,76 +828,76 @@ one trustfile (usually a CA bundle). */) | |||
| 828 | for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail)) | 828 | for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail)) |
| 829 | { | 829 | { |
| 830 | Lisp_Object trustfile = Fcar (tail); | 830 | Lisp_Object trustfile = Fcar (tail); |
| 831 | if (STRINGP (trustfile)) | 831 | if (STRINGP (trustfile)) |
| 832 | { | 832 | { |
| 833 | GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ", | 833 | GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ", |
| 834 | SSDATA (trustfile)); | 834 | SSDATA (trustfile)); |
| 835 | ret = fn_gnutls_certificate_set_x509_trust_file | 835 | ret = fn_gnutls_certificate_set_x509_trust_file |
| 836 | (x509_cred, | 836 | (x509_cred, |
| 837 | SSDATA (trustfile), | 837 | SSDATA (trustfile), |
| 838 | file_format); | 838 | file_format); |
| 839 | 839 | ||
| 840 | if (ret < GNUTLS_E_SUCCESS) | 840 | if (ret < GNUTLS_E_SUCCESS) |
| 841 | return gnutls_make_error (ret); | 841 | return gnutls_make_error (ret); |
| 842 | } | 842 | } |
| 843 | else | 843 | else |
| 844 | { | 844 | { |
| 845 | error ("Sorry, GnuTLS can't use non-string trustfile %s", | 845 | error ("Sorry, GnuTLS can't use non-string trustfile %s", |
| 846 | SDATA (trustfile)); | 846 | SDATA (trustfile)); |
| 847 | } | 847 | } |
| 848 | } | 848 | } |
| 849 | 849 | ||
| 850 | for (tail = crlfiles; !NILP (tail); tail = Fcdr (tail)) | 850 | for (tail = crlfiles; !NILP (tail); tail = Fcdr (tail)) |
| 851 | { | 851 | { |
| 852 | Lisp_Object crlfile = Fcar (tail); | 852 | Lisp_Object crlfile = Fcar (tail); |
| 853 | if (STRINGP (crlfile)) | 853 | if (STRINGP (crlfile)) |
| 854 | { | 854 | { |
| 855 | GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ", | 855 | GNUTLS_LOG2 (1, max_log_level, "setting the CRL file: ", |
| 856 | SSDATA (crlfile)); | 856 | SSDATA (crlfile)); |
| 857 | ret = fn_gnutls_certificate_set_x509_crl_file | 857 | ret = fn_gnutls_certificate_set_x509_crl_file |
| 858 | (x509_cred, | 858 | (x509_cred, |
| 859 | SSDATA (crlfile), | 859 | SSDATA (crlfile), |
| 860 | file_format); | 860 | file_format); |
| 861 | 861 | ||
| 862 | if (ret < GNUTLS_E_SUCCESS) | 862 | if (ret < GNUTLS_E_SUCCESS) |
| 863 | return gnutls_make_error (ret); | 863 | return gnutls_make_error (ret); |
| 864 | } | 864 | } |
| 865 | else | 865 | else |
| 866 | { | 866 | { |
| 867 | error ("Sorry, GnuTLS can't use non-string CRL file %s", | 867 | error ("Sorry, GnuTLS can't use non-string CRL file %s", |
| 868 | SDATA (crlfile)); | 868 | SDATA (crlfile)); |
| 869 | } | 869 | } |
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | for (tail = keylist; !NILP (tail); tail = Fcdr (tail)) | 872 | for (tail = keylist; !NILP (tail); tail = Fcdr (tail)) |
| 873 | { | 873 | { |
| 874 | Lisp_Object keyfile = Fcar (Fcar (tail)); | 874 | Lisp_Object keyfile = Fcar (Fcar (tail)); |
| 875 | Lisp_Object certfile = Fcar (Fcdr (tail)); | 875 | Lisp_Object certfile = Fcar (Fcdr (tail)); |
| 876 | if (STRINGP (keyfile) && STRINGP (certfile)) | 876 | if (STRINGP (keyfile) && STRINGP (certfile)) |
| 877 | { | 877 | { |
| 878 | GNUTLS_LOG2 (1, max_log_level, "setting the client key file: ", | 878 | GNUTLS_LOG2 (1, max_log_level, "setting the client key file: ", |
| 879 | SSDATA (keyfile)); | 879 | SSDATA (keyfile)); |
| 880 | GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ", | 880 | GNUTLS_LOG2 (1, max_log_level, "setting the client cert file: ", |
| 881 | SSDATA (certfile)); | 881 | SSDATA (certfile)); |
| 882 | ret = fn_gnutls_certificate_set_x509_key_file | 882 | ret = fn_gnutls_certificate_set_x509_key_file |
| 883 | (x509_cred, | 883 | (x509_cred, |
| 884 | SSDATA (certfile), | 884 | SSDATA (certfile), |
| 885 | SSDATA (keyfile), | 885 | SSDATA (keyfile), |
| 886 | file_format); | 886 | file_format); |
| 887 | 887 | ||
| 888 | if (ret < GNUTLS_E_SUCCESS) | 888 | if (ret < GNUTLS_E_SUCCESS) |
| 889 | return gnutls_make_error (ret); | 889 | return gnutls_make_error (ret); |
| 890 | } | 890 | } |
| 891 | else | 891 | else |
| 892 | { | 892 | { |
| 893 | if (STRINGP (keyfile)) | 893 | if (STRINGP (keyfile)) |
| 894 | error ("Sorry, GnuTLS can't use non-string client cert file %s", | 894 | error ("Sorry, GnuTLS can't use non-string client cert file %s", |
| 895 | SDATA (certfile)); | 895 | SDATA (certfile)); |
| 896 | else | 896 | else |
| 897 | error ("Sorry, GnuTLS can't use non-string client key file %s", | 897 | error ("Sorry, GnuTLS can't use non-string client key file %s", |
| 898 | SDATA (keyfile)); | 898 | SDATA (keyfile)); |
| 899 | } | 899 | } |
| 900 | } | 900 | } |
| 901 | } | 901 | } |
| 902 | 902 | ||
| 903 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; | 903 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; |
| @@ -925,19 +925,19 @@ one trustfile (usually a CA bundle). */) | |||
| 925 | { | 925 | { |
| 926 | priority_string_ptr = SSDATA (priority_string); | 926 | priority_string_ptr = SSDATA (priority_string); |
| 927 | GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:", | 927 | GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:", |
| 928 | priority_string_ptr); | 928 | priority_string_ptr); |
| 929 | } | 929 | } |
| 930 | else | 930 | else |
| 931 | { | 931 | { |
| 932 | GNUTLS_LOG2 (1, max_log_level, "using default priority string:", | 932 | GNUTLS_LOG2 (1, max_log_level, "using default priority string:", |
| 933 | priority_string_ptr); | 933 | priority_string_ptr); |
| 934 | } | 934 | } |
| 935 | 935 | ||
| 936 | GNUTLS_LOG (1, max_log_level, "setting the priority string"); | 936 | GNUTLS_LOG (1, max_log_level, "setting the priority string"); |
| 937 | 937 | ||
| 938 | ret = fn_gnutls_priority_set_direct (state, | 938 | ret = fn_gnutls_priority_set_direct (state, |
| 939 | priority_string_ptr, | 939 | priority_string_ptr, |
| 940 | NULL); | 940 | NULL); |
| 941 | 941 | ||
| 942 | if (ret < GNUTLS_E_SUCCESS) | 942 | if (ret < GNUTLS_E_SUCCESS) |
| 943 | return gnutls_make_error (ret); | 943 | return gnutls_make_error (ret); |
| @@ -990,44 +990,44 @@ one trustfile (usually a CA bundle). */) | |||
| 990 | 990 | ||
| 991 | if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID) | 991 | if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID) |
| 992 | message ("%s certificate could not be verified.", | 992 | message ("%s certificate could not be verified.", |
| 993 | c_hostname); | 993 | c_hostname); |
| 994 | 994 | ||
| 995 | if (peer_verification & GNUTLS_CERT_REVOKED) | 995 | if (peer_verification & GNUTLS_CERT_REVOKED) |
| 996 | GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):", | 996 | GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):", |
| 997 | c_hostname); | 997 | c_hostname); |
| 998 | 998 | ||
| 999 | if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND) | 999 | if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND) |
| 1000 | GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:", | 1000 | GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:", |
| 1001 | c_hostname); | 1001 | c_hostname); |
| 1002 | 1002 | ||
| 1003 | if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA) | 1003 | if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA) |
| 1004 | GNUTLS_LOG2 (1, max_log_level, "certificate signer is not a CA:", | 1004 | GNUTLS_LOG2 (1, max_log_level, "certificate signer is not a CA:", |
| 1005 | c_hostname); | 1005 | c_hostname); |
| 1006 | 1006 | ||
| 1007 | if (peer_verification & GNUTLS_CERT_INSECURE_ALGORITHM) | 1007 | if (peer_verification & GNUTLS_CERT_INSECURE_ALGORITHM) |
| 1008 | GNUTLS_LOG2 (1, max_log_level, | 1008 | GNUTLS_LOG2 (1, max_log_level, |
| 1009 | "certificate was signed with an insecure algorithm:", | 1009 | "certificate was signed with an insecure algorithm:", |
| 1010 | c_hostname); | 1010 | c_hostname); |
| 1011 | 1011 | ||
| 1012 | if (peer_verification & GNUTLS_CERT_NOT_ACTIVATED) | 1012 | if (peer_verification & GNUTLS_CERT_NOT_ACTIVATED) |
| 1013 | GNUTLS_LOG2 (1, max_log_level, "certificate is not yet activated:", | 1013 | GNUTLS_LOG2 (1, max_log_level, "certificate is not yet activated:", |
| 1014 | c_hostname); | 1014 | c_hostname); |
| 1015 | 1015 | ||
| 1016 | if (peer_verification & GNUTLS_CERT_EXPIRED) | 1016 | if (peer_verification & GNUTLS_CERT_EXPIRED) |
| 1017 | GNUTLS_LOG2 (1, max_log_level, "certificate has expired:", | 1017 | GNUTLS_LOG2 (1, max_log_level, "certificate has expired:", |
| 1018 | c_hostname); | 1018 | c_hostname); |
| 1019 | 1019 | ||
| 1020 | if (peer_verification != 0) | 1020 | if (peer_verification != 0) |
| 1021 | { | 1021 | { |
| 1022 | if (NILP (verify_hostname_error)) | 1022 | if (NILP (verify_hostname_error)) |
| 1023 | { | 1023 | { |
| 1024 | GNUTLS_LOG2 (1, max_log_level, "certificate validation failed:", | 1024 | GNUTLS_LOG2 (1, max_log_level, "certificate validation failed:", |
| 1025 | c_hostname); | 1025 | c_hostname); |
| 1026 | } | 1026 | } |
| 1027 | else | 1027 | else |
| 1028 | { | 1028 | { |
| 1029 | error ("Certificate validation failed %s, verification code %d", | 1029 | error ("Certificate validation failed %s, verification code %d", |
| 1030 | c_hostname, peer_verification); | 1030 | c_hostname, peer_verification); |
| 1031 | } | 1031 | } |
| 1032 | } | 1032 | } |
| 1033 | 1033 | ||
| @@ -1039,41 +1039,41 @@ one trustfile (usually a CA bundle). */) | |||
| 1039 | ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert); | 1039 | ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert); |
| 1040 | 1040 | ||
| 1041 | if (ret < GNUTLS_E_SUCCESS) | 1041 | if (ret < GNUTLS_E_SUCCESS) |
| 1042 | return gnutls_make_error (ret); | 1042 | return gnutls_make_error (ret); |
| 1043 | 1043 | ||
| 1044 | gnutls_verify_cert_list = | 1044 | gnutls_verify_cert_list = |
| 1045 | fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); | 1045 | fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); |
| 1046 | 1046 | ||
| 1047 | if (NULL == gnutls_verify_cert_list) | 1047 | if (NULL == gnutls_verify_cert_list) |
| 1048 | { | 1048 | { |
| 1049 | error ("No x509 certificate was found!\n"); | 1049 | error ("No x509 certificate was found!\n"); |
| 1050 | } | 1050 | } |
| 1051 | 1051 | ||
| 1052 | /* We only check the first certificate in the given chain. */ | 1052 | /* We only check the first certificate in the given chain. */ |
| 1053 | ret = fn_gnutls_x509_crt_import (gnutls_verify_cert, | 1053 | ret = fn_gnutls_x509_crt_import (gnutls_verify_cert, |
| 1054 | &gnutls_verify_cert_list[0], | 1054 | &gnutls_verify_cert_list[0], |
| 1055 | GNUTLS_X509_FMT_DER); | 1055 | GNUTLS_X509_FMT_DER); |
| 1056 | 1056 | ||
| 1057 | if (ret < GNUTLS_E_SUCCESS) | 1057 | if (ret < GNUTLS_E_SUCCESS) |
| 1058 | { | 1058 | { |
| 1059 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); | 1059 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); |
| 1060 | return gnutls_make_error (ret); | 1060 | return gnutls_make_error (ret); |
| 1061 | } | 1061 | } |
| 1062 | 1062 | ||
| 1063 | if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) | 1063 | if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) |
| 1064 | { | 1064 | { |
| 1065 | if (NILP (verify_hostname_error)) | 1065 | if (NILP (verify_hostname_error)) |
| 1066 | { | 1066 | { |
| 1067 | GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:", | 1067 | GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:", |
| 1068 | c_hostname); | 1068 | c_hostname); |
| 1069 | } | 1069 | } |
| 1070 | else | 1070 | else |
| 1071 | { | 1071 | { |
| 1072 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); | 1072 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); |
| 1073 | error ("The x509 certificate does not match \"%s\"", | 1073 | error ("The x509 certificate does not match \"%s\"", |
| 1074 | c_hostname); | 1074 | c_hostname); |
| 1075 | } | 1075 | } |
| 1076 | } | 1076 | } |
| 1077 | 1077 | ||
| 1078 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); | 1078 | fn_gnutls_x509_crt_deinit (gnutls_verify_cert); |
| 1079 | } | 1079 | } |
| @@ -1105,7 +1105,7 @@ This function may also return `gnutls-e-again', or | |||
| 1105 | state = XPROCESS (proc)->gnutls_state; | 1105 | state = XPROCESS (proc)->gnutls_state; |
| 1106 | 1106 | ||
| 1107 | ret = fn_gnutls_bye (state, | 1107 | ret = fn_gnutls_bye (state, |
| 1108 | NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); | 1108 | NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); |
| 1109 | 1109 | ||
| 1110 | return gnutls_make_error (ret); | 1110 | return gnutls_make_error (ret); |
| 1111 | } | 1111 | } |
| @@ -1119,33 +1119,33 @@ syms_of_gnutls (void) | |||
| 1119 | DEFSYM (Qgnutls_code, "gnutls-code"); | 1119 | DEFSYM (Qgnutls_code, "gnutls-code"); |
| 1120 | DEFSYM (Qgnutls_anon, "gnutls-anon"); | 1120 | DEFSYM (Qgnutls_anon, "gnutls-anon"); |
| 1121 | DEFSYM (Qgnutls_x509pki, "gnutls-x509pki"); | 1121 | DEFSYM (Qgnutls_x509pki, "gnutls-x509pki"); |
| 1122 | DEFSYM (Qgnutls_bootprop_hostname, ":hostname"); | 1122 | DEFSYM (QCgnutls_bootprop_hostname, ":hostname"); |
| 1123 | DEFSYM (Qgnutls_bootprop_priority, ":priority"); | 1123 | DEFSYM (QCgnutls_bootprop_priority, ":priority"); |
| 1124 | DEFSYM (Qgnutls_bootprop_trustfiles, ":trustfiles"); | 1124 | DEFSYM (QCgnutls_bootprop_trustfiles, ":trustfiles"); |
| 1125 | DEFSYM (Qgnutls_bootprop_keylist, ":keylist"); | 1125 | DEFSYM (QCgnutls_bootprop_keylist, ":keylist"); |
| 1126 | DEFSYM (Qgnutls_bootprop_crlfiles, ":crlfiles"); | 1126 | DEFSYM (QCgnutls_bootprop_crlfiles, ":crlfiles"); |
| 1127 | DEFSYM (Qgnutls_bootprop_callbacks, ":callbacks"); | 1127 | DEFSYM (QCgnutls_bootprop_callbacks, ":callbacks"); |
| 1128 | DEFSYM (Qgnutls_bootprop_callbacks_verify, "verify"); | 1128 | DEFSYM (QCgnutls_bootprop_callbacks_verify, "verify"); |
| 1129 | DEFSYM (Qgnutls_bootprop_min_prime_bits, ":min-prime-bits"); | 1129 | DEFSYM (QCgnutls_bootprop_min_prime_bits, ":min-prime-bits"); |
| 1130 | DEFSYM (Qgnutls_bootprop_loglevel, ":loglevel"); | 1130 | DEFSYM (QCgnutls_bootprop_loglevel, ":loglevel"); |
| 1131 | DEFSYM (Qgnutls_bootprop_verify_flags, ":verify-flags"); | 1131 | DEFSYM (QCgnutls_bootprop_verify_flags, ":verify-flags"); |
| 1132 | DEFSYM (Qgnutls_bootprop_verify_hostname_error, ":verify-hostname-error"); | 1132 | DEFSYM (QCgnutls_bootprop_verify_hostname_error, ":verify-hostname-error"); |
| 1133 | 1133 | ||
| 1134 | DEFSYM (Qgnutls_e_interrupted, "gnutls-e-interrupted"); | 1134 | DEFSYM (Qgnutls_e_interrupted, "gnutls-e-interrupted"); |
| 1135 | Fput (Qgnutls_e_interrupted, Qgnutls_code, | 1135 | Fput (Qgnutls_e_interrupted, Qgnutls_code, |
| 1136 | make_number (GNUTLS_E_INTERRUPTED)); | 1136 | make_number (GNUTLS_E_INTERRUPTED)); |
| 1137 | 1137 | ||
| 1138 | DEFSYM (Qgnutls_e_again, "gnutls-e-again"); | 1138 | DEFSYM (Qgnutls_e_again, "gnutls-e-again"); |
| 1139 | Fput (Qgnutls_e_again, Qgnutls_code, | 1139 | Fput (Qgnutls_e_again, Qgnutls_code, |
| 1140 | make_number (GNUTLS_E_AGAIN)); | 1140 | make_number (GNUTLS_E_AGAIN)); |
| 1141 | 1141 | ||
| 1142 | DEFSYM (Qgnutls_e_invalid_session, "gnutls-e-invalid-session"); | 1142 | DEFSYM (Qgnutls_e_invalid_session, "gnutls-e-invalid-session"); |
| 1143 | Fput (Qgnutls_e_invalid_session, Qgnutls_code, | 1143 | Fput (Qgnutls_e_invalid_session, Qgnutls_code, |
| 1144 | make_number (GNUTLS_E_INVALID_SESSION)); | 1144 | make_number (GNUTLS_E_INVALID_SESSION)); |
| 1145 | 1145 | ||
| 1146 | DEFSYM (Qgnutls_e_not_ready_for_handshake, "gnutls-e-not-ready-for-handshake"); | 1146 | DEFSYM (Qgnutls_e_not_ready_for_handshake, "gnutls-e-not-ready-for-handshake"); |
| 1147 | Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code, | 1147 | Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code, |
| 1148 | make_number (GNUTLS_E_APPLICATION_ERROR_MIN)); | 1148 | make_number (GNUTLS_E_APPLICATION_ERROR_MIN)); |
| 1149 | 1149 | ||
| 1150 | defsubr (&Sgnutls_get_initstage); | 1150 | defsubr (&Sgnutls_get_initstage); |
| 1151 | defsubr (&Sgnutls_errorp); | 1151 | defsubr (&Sgnutls_errorp); |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 8826b08851a..c39119c8151 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -487,7 +487,8 @@ get_utf8_string (const char *str) | |||
| 487 | if (!utf8_str) | 487 | if (!utf8_str) |
| 488 | { | 488 | { |
| 489 | /* Probably some control characters in str. Escape them. */ | 489 | /* Probably some control characters in str. Escape them. */ |
| 490 | size_t nr_bad = 0; | 490 | ptrdiff_t len; |
| 491 | ptrdiff_t nr_bad = 0; | ||
| 491 | gsize bytes_read; | 492 | gsize bytes_read; |
| 492 | gsize bytes_written; | 493 | gsize bytes_written; |
| 493 | unsigned char *p = (unsigned char *)str; | 494 | unsigned char *p = (unsigned char *)str; |
| @@ -511,7 +512,10 @@ get_utf8_string (const char *str) | |||
| 511 | } | 512 | } |
| 512 | if (cp) g_free (cp); | 513 | if (cp) g_free (cp); |
| 513 | 514 | ||
| 514 | up = utf8_str = xmalloc (strlen (str) + nr_bad * 4 + 1); | 515 | len = strlen (str); |
| 516 | if ((min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4 < nr_bad) | ||
| 517 | memory_full (SIZE_MAX); | ||
| 518 | up = utf8_str = xmalloc (len + nr_bad * 4 + 1); | ||
| 515 | p = (unsigned char *)str; | 519 | p = (unsigned char *)str; |
| 516 | 520 | ||
| 517 | while (! (cp = g_locale_to_utf8 ((char *)p, -1, &bytes_read, | 521 | while (! (cp = g_locale_to_utf8 ((char *)p, -1, &bytes_read, |
| @@ -1907,12 +1911,12 @@ xg_get_file_name (FRAME_PTR f, | |||
| 1907 | int filesel_done = 0; | 1911 | int filesel_done = 0; |
| 1908 | xg_get_file_func func; | 1912 | xg_get_file_func func; |
| 1909 | 1913 | ||
| 1910 | #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) | 1914 | #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) |
| 1911 | /* I really don't know why this is needed, but without this the GLIBC add on | 1915 | /* I really don't know why this is needed, but without this the GLIBC add on |
| 1912 | library linuxthreads hangs when the Gnome file chooser backend creates | 1916 | library linuxthreads hangs when the Gnome file chooser backend creates |
| 1913 | threads. */ | 1917 | threads. */ |
| 1914 | sigblock (sigmask (__SIGRTMIN)); | 1918 | sigblock (sigmask (__SIGRTMIN)); |
| 1915 | #endif /* HAVE_GTK_AND_PTHREAD */ | 1919 | #endif /* HAVE_PTHREAD */ |
| 1916 | 1920 | ||
| 1917 | #ifdef HAVE_GTK_FILE_SELECTION_NEW | 1921 | #ifdef HAVE_GTK_FILE_SELECTION_NEW |
| 1918 | 1922 | ||
| @@ -1932,7 +1936,7 @@ xg_get_file_name (FRAME_PTR f, | |||
| 1932 | 1936 | ||
| 1933 | filesel_done = xg_dialog_run (f, w); | 1937 | filesel_done = xg_dialog_run (f, w); |
| 1934 | 1938 | ||
| 1935 | #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) | 1939 | #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) |
| 1936 | sigunblock (sigmask (__SIGRTMIN)); | 1940 | sigunblock (sigmask (__SIGRTMIN)); |
| 1937 | #endif | 1941 | #endif |
| 1938 | 1942 | ||
| @@ -1960,9 +1964,9 @@ xg_get_font_name (FRAME_PTR f, const char *default_name) | |||
| 1960 | char *fontname = NULL; | 1964 | char *fontname = NULL; |
| 1961 | int done = 0; | 1965 | int done = 0; |
| 1962 | 1966 | ||
| 1963 | #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) | 1967 | #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) |
| 1964 | sigblock (sigmask (__SIGRTMIN)); | 1968 | sigblock (sigmask (__SIGRTMIN)); |
| 1965 | #endif /* HAVE_GTK_AND_PTHREAD */ | 1969 | #endif /* HAVE_PTHREAD */ |
| 1966 | 1970 | ||
| 1967 | w = gtk_font_selection_dialog_new ("Pick a font"); | 1971 | w = gtk_font_selection_dialog_new ("Pick a font"); |
| 1968 | if (!default_name) | 1972 | if (!default_name) |
| @@ -1974,7 +1978,7 @@ xg_get_font_name (FRAME_PTR f, const char *default_name) | |||
| 1974 | 1978 | ||
| 1975 | done = xg_dialog_run (f, w); | 1979 | done = xg_dialog_run (f, w); |
| 1976 | 1980 | ||
| 1977 | #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) | 1981 | #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) |
| 1978 | sigunblock (sigmask (__SIGRTMIN)); | 1982 | sigunblock (sigmask (__SIGRTMIN)); |
| 1979 | #endif | 1983 | #endif |
| 1980 | 1984 | ||
| @@ -3296,8 +3300,8 @@ static int scroll_bar_width_for_theme; | |||
| 3296 | static struct | 3300 | static struct |
| 3297 | { | 3301 | { |
| 3298 | GtkWidget **widgets; | 3302 | GtkWidget **widgets; |
| 3299 | int max_size; | 3303 | ptrdiff_t max_size; |
| 3300 | int used; | 3304 | ptrdiff_t used; |
| 3301 | } id_to_widget; | 3305 | } id_to_widget; |
| 3302 | 3306 | ||
| 3303 | /* Grow this much every time we need to allocate more */ | 3307 | /* Grow this much every time we need to allocate more */ |
| @@ -3306,17 +3310,20 @@ static struct | |||
| 3306 | 3310 | ||
| 3307 | /* Store the widget pointer W in id_to_widget and return the integer index. */ | 3311 | /* Store the widget pointer W in id_to_widget and return the integer index. */ |
| 3308 | 3312 | ||
| 3309 | static int | 3313 | static ptrdiff_t |
| 3310 | xg_store_widget_in_map (GtkWidget *w) | 3314 | xg_store_widget_in_map (GtkWidget *w) |
| 3311 | { | 3315 | { |
| 3312 | int i; | 3316 | ptrdiff_t i; |
| 3313 | 3317 | ||
| 3314 | if (id_to_widget.max_size == id_to_widget.used) | 3318 | if (id_to_widget.max_size == id_to_widget.used) |
| 3315 | { | 3319 | { |
| 3316 | int new_size = id_to_widget.max_size + ID_TO_WIDGET_INCR; | 3320 | ptrdiff_t new_size; |
| 3321 | if (TYPE_MAXIMUM (Window) - ID_TO_WIDGET_INCR < id_to_widget.max_size) | ||
| 3322 | memory_full (SIZE_MAX); | ||
| 3317 | 3323 | ||
| 3318 | id_to_widget.widgets = xrealloc (id_to_widget.widgets, | 3324 | new_size = id_to_widget.max_size + ID_TO_WIDGET_INCR; |
| 3319 | sizeof (GtkWidget *)*new_size); | 3325 | id_to_widget.widgets = xnrealloc (id_to_widget.widgets, |
| 3326 | new_size, sizeof (GtkWidget *)); | ||
| 3320 | 3327 | ||
| 3321 | for (i = id_to_widget.max_size; i < new_size; ++i) | 3328 | for (i = id_to_widget.max_size; i < new_size; ++i) |
| 3322 | id_to_widget.widgets[i] = 0; | 3329 | id_to_widget.widgets[i] = 0; |
| @@ -3345,7 +3352,7 @@ xg_store_widget_in_map (GtkWidget *w) | |||
| 3345 | Called when scroll bar is destroyed. */ | 3352 | Called when scroll bar is destroyed. */ |
| 3346 | 3353 | ||
| 3347 | static void | 3354 | static void |
| 3348 | xg_remove_widget_from_map (int idx) | 3355 | xg_remove_widget_from_map (ptrdiff_t idx) |
| 3349 | { | 3356 | { |
| 3350 | if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) | 3357 | if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) |
| 3351 | { | 3358 | { |
| @@ -3357,7 +3364,7 @@ xg_remove_widget_from_map (int idx) | |||
| 3357 | /* Get the widget pointer at IDX from id_to_widget. */ | 3364 | /* Get the widget pointer at IDX from id_to_widget. */ |
| 3358 | 3365 | ||
| 3359 | static GtkWidget * | 3366 | static GtkWidget * |
| 3360 | xg_get_widget_from_map (int idx) | 3367 | xg_get_widget_from_map (ptrdiff_t idx) |
| 3361 | { | 3368 | { |
| 3362 | if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) | 3369 | if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) |
| 3363 | return id_to_widget.widgets[idx]; | 3370 | return id_to_widget.widgets[idx]; |
| @@ -3396,10 +3403,10 @@ xg_get_default_scrollbar_width (void) | |||
| 3396 | /* Return the scrollbar id for X Window WID on display DPY. | 3403 | /* Return the scrollbar id for X Window WID on display DPY. |
| 3397 | Return -1 if WID not in id_to_widget. */ | 3404 | Return -1 if WID not in id_to_widget. */ |
| 3398 | 3405 | ||
| 3399 | int | 3406 | ptrdiff_t |
| 3400 | xg_get_scroll_id_for_window (Display *dpy, Window wid) | 3407 | xg_get_scroll_id_for_window (Display *dpy, Window wid) |
| 3401 | { | 3408 | { |
| 3402 | int idx; | 3409 | ptrdiff_t idx; |
| 3403 | GtkWidget *w; | 3410 | GtkWidget *w; |
| 3404 | 3411 | ||
| 3405 | w = xg_win_to_widget (dpy, wid); | 3412 | w = xg_win_to_widget (dpy, wid); |
| @@ -3421,7 +3428,7 @@ xg_get_scroll_id_for_window (Display *dpy, Window wid) | |||
| 3421 | static void | 3428 | static void |
| 3422 | xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data) | 3429 | xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data) |
| 3423 | { | 3430 | { |
| 3424 | int id = (intptr_t) data; | 3431 | intptr_t id = (intptr_t) data; |
| 3425 | xg_remove_widget_from_map (id); | 3432 | xg_remove_widget_from_map (id); |
| 3426 | } | 3433 | } |
| 3427 | 3434 | ||
| @@ -3496,7 +3503,7 @@ xg_create_scroll_bar (FRAME_PTR f, | |||
| 3496 | /* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ | 3503 | /* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ |
| 3497 | 3504 | ||
| 3498 | void | 3505 | void |
| 3499 | xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id) | 3506 | xg_remove_scroll_bar (FRAME_PTR f, ptrdiff_t scrollbar_id) |
| 3500 | { | 3507 | { |
| 3501 | GtkWidget *w = xg_get_widget_from_map (scrollbar_id); | 3508 | GtkWidget *w = xg_get_widget_from_map (scrollbar_id); |
| 3502 | if (w) | 3509 | if (w) |
| @@ -3515,7 +3522,7 @@ xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id) | |||
| 3515 | 3522 | ||
| 3516 | void | 3523 | void |
| 3517 | xg_update_scrollbar_pos (FRAME_PTR f, | 3524 | xg_update_scrollbar_pos (FRAME_PTR f, |
| 3518 | int scrollbar_id, | 3525 | ptrdiff_t scrollbar_id, |
| 3519 | int top, | 3526 | int top, |
| 3520 | int left, | 3527 | int left, |
| 3521 | int width, | 3528 | int width, |
| @@ -4429,7 +4436,7 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 4429 | int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); | 4436 | int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); |
| 4430 | int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); | 4437 | int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); |
| 4431 | int idx; | 4438 | int idx; |
| 4432 | int img_id; | 4439 | ptrdiff_t img_id; |
| 4433 | int icon_size = 0; | 4440 | int icon_size = 0; |
| 4434 | struct image *img = NULL; | 4441 | struct image *img = NULL; |
| 4435 | Lisp_Object image; | 4442 | Lisp_Object image; |
diff --git a/src/gtkutil.h b/src/gtkutil.h index 769e56da917..2dfb3a5ed6c 100644 --- a/src/gtkutil.h +++ b/src/gtkutil.h | |||
| @@ -114,17 +114,17 @@ extern int xg_event_is_for_menubar (FRAME_PTR f, XEvent *event); | |||
| 114 | 114 | ||
| 115 | extern int xg_have_tear_offs (void); | 115 | extern int xg_have_tear_offs (void); |
| 116 | 116 | ||
| 117 | extern int xg_get_scroll_id_for_window (Display *dpy, Window wid); | 117 | extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid); |
| 118 | 118 | ||
| 119 | extern void xg_create_scroll_bar (FRAME_PTR f, | 119 | extern void xg_create_scroll_bar (FRAME_PTR f, |
| 120 | struct scroll_bar *bar, | 120 | struct scroll_bar *bar, |
| 121 | GCallback scroll_callback, | 121 | GCallback scroll_callback, |
| 122 | GCallback end_callback, | 122 | GCallback end_callback, |
| 123 | const char *scroll_bar_name); | 123 | const char *scroll_bar_name); |
| 124 | extern void xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id); | 124 | extern void xg_remove_scroll_bar (FRAME_PTR f, ptrdiff_t scrollbar_id); |
| 125 | 125 | ||
| 126 | extern void xg_update_scrollbar_pos (FRAME_PTR f, | 126 | extern void xg_update_scrollbar_pos (FRAME_PTR f, |
| 127 | int scrollbar_id, | 127 | ptrdiff_t scrollbar_id, |
| 128 | int top, | 128 | int top, |
| 129 | int left, | 129 | int left, |
| 130 | int width, | 130 | int width, |
| @@ -185,4 +185,3 @@ extern int xg_ignore_gtk_scrollbar; | |||
| 185 | 185 | ||
| 186 | #endif /* USE_GTK */ | 186 | #endif /* USE_GTK */ |
| 187 | #endif /* GTKUTIL_H */ | 187 | #endif /* GTKUTIL_H */ |
| 188 | |||
diff --git a/src/image.c b/src/image.c index d1091aec6f3..c5dcbb32e5d 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -196,6 +196,7 @@ x_bitmap_width (FRAME_PTR f, ptrdiff_t id) | |||
| 196 | int | 196 | int |
| 197 | x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id) | 197 | x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id) |
| 198 | { | 198 | { |
| 199 | /* HAVE_NTGUI needs the explicit cast here. */ | ||
| 199 | return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; | 200 | return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; |
| 200 | } | 201 | } |
| 201 | #endif | 202 | #endif |
| @@ -216,15 +217,6 @@ x_allocate_bitmap_record (FRAME_PTR f) | |||
| 216 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 217 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 217 | ptrdiff_t i; | 218 | ptrdiff_t i; |
| 218 | 219 | ||
| 219 | if (dpyinfo->bitmaps == NULL) | ||
| 220 | { | ||
| 221 | dpyinfo->bitmaps_size = 10; | ||
| 222 | dpyinfo->bitmaps | ||
| 223 | = (Bitmap_Record *) xmalloc (dpyinfo->bitmaps_size * sizeof (Bitmap_Record)); | ||
| 224 | dpyinfo->bitmaps_last = 1; | ||
| 225 | return 1; | ||
| 226 | } | ||
| 227 | |||
| 228 | if (dpyinfo->bitmaps_last < dpyinfo->bitmaps_size) | 220 | if (dpyinfo->bitmaps_last < dpyinfo->bitmaps_size) |
| 229 | return ++dpyinfo->bitmaps_last; | 221 | return ++dpyinfo->bitmaps_last; |
| 230 | 222 | ||
| @@ -232,20 +224,16 @@ x_allocate_bitmap_record (FRAME_PTR f) | |||
| 232 | if (dpyinfo->bitmaps[i].refcount == 0) | 224 | if (dpyinfo->bitmaps[i].refcount == 0) |
| 233 | return i + 1; | 225 | return i + 1; |
| 234 | 226 | ||
| 235 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Bitmap_Record) / 2 | 227 | dpyinfo->bitmaps = |
| 236 | < dpyinfo->bitmaps_size) | 228 | xpalloc (dpyinfo->bitmaps, &dpyinfo->bitmaps_size, |
| 237 | memory_full (SIZE_MAX); | 229 | 10, -1, sizeof *dpyinfo->bitmaps); |
| 238 | dpyinfo->bitmaps_size *= 2; | ||
| 239 | dpyinfo->bitmaps | ||
| 240 | = (Bitmap_Record *) xrealloc (dpyinfo->bitmaps, | ||
| 241 | dpyinfo->bitmaps_size * sizeof (Bitmap_Record)); | ||
| 242 | return ++dpyinfo->bitmaps_last; | 230 | return ++dpyinfo->bitmaps_last; |
| 243 | } | 231 | } |
| 244 | 232 | ||
| 245 | /* Add one reference to the reference count of the bitmap with id ID. */ | 233 | /* Add one reference to the reference count of the bitmap with id ID. */ |
| 246 | 234 | ||
| 247 | void | 235 | void |
| 248 | x_reference_bitmap (FRAME_PTR f, int id) | 236 | x_reference_bitmap (FRAME_PTR f, ptrdiff_t id) |
| 249 | { | 237 | { |
| 250 | ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount; | 238 | ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount; |
| 251 | } | 239 | } |
| @@ -704,7 +692,7 @@ enum image_value_type | |||
| 704 | IMAGE_STRING_OR_NIL_VALUE, | 692 | IMAGE_STRING_OR_NIL_VALUE, |
| 705 | IMAGE_SYMBOL_VALUE, | 693 | IMAGE_SYMBOL_VALUE, |
| 706 | IMAGE_POSITIVE_INTEGER_VALUE, | 694 | IMAGE_POSITIVE_INTEGER_VALUE, |
| 707 | IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, | 695 | IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, |
| 708 | IMAGE_NON_NEGATIVE_INTEGER_VALUE, | 696 | IMAGE_NON_NEGATIVE_INTEGER_VALUE, |
| 709 | IMAGE_ASCENT_VALUE, | 697 | IMAGE_ASCENT_VALUE, |
| 710 | IMAGE_INTEGER_VALUE, | 698 | IMAGE_INTEGER_VALUE, |
| @@ -807,29 +795,30 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, | |||
| 807 | break; | 795 | break; |
| 808 | 796 | ||
| 809 | case IMAGE_POSITIVE_INTEGER_VALUE: | 797 | case IMAGE_POSITIVE_INTEGER_VALUE: |
| 810 | if (!INTEGERP (value) || XINT (value) <= 0) | 798 | if (! RANGED_INTEGERP (1, value, INT_MAX)) |
| 811 | return 0; | 799 | return 0; |
| 812 | break; | 800 | break; |
| 813 | 801 | ||
| 814 | case IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR: | 802 | case IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR: |
| 815 | if (INTEGERP (value) && XINT (value) >= 0) | 803 | if (RANGED_INTEGERP (0, value, INT_MAX)) |
| 816 | break; | 804 | break; |
| 817 | if (CONSP (value) | 805 | if (CONSP (value) |
| 818 | && INTEGERP (XCAR (value)) && INTEGERP (XCDR (value)) | 806 | && RANGED_INTEGERP (0, XCAR (value), INT_MAX) |
| 819 | && XINT (XCAR (value)) >= 0 && XINT (XCDR (value)) >= 0) | 807 | && RANGED_INTEGERP (0, XCDR (value), INT_MAX)) |
| 820 | break; | 808 | break; |
| 821 | return 0; | 809 | return 0; |
| 822 | 810 | ||
| 823 | case IMAGE_ASCENT_VALUE: | 811 | case IMAGE_ASCENT_VALUE: |
| 824 | if (SYMBOLP (value) && EQ (value, Qcenter)) | 812 | if (SYMBOLP (value) && EQ (value, Qcenter)) |
| 825 | break; | 813 | break; |
| 826 | else if (INTEGERP (value) | 814 | else if (RANGED_INTEGERP (0, value, 100)) |
| 827 | && XINT (value) >= 0 | ||
| 828 | && XINT (value) <= 100) | ||
| 829 | break; | 815 | break; |
| 830 | return 0; | 816 | return 0; |
| 831 | 817 | ||
| 832 | case IMAGE_NON_NEGATIVE_INTEGER_VALUE: | 818 | case IMAGE_NON_NEGATIVE_INTEGER_VALUE: |
| 819 | /* Unlike the other integer-related cases, this one does not | ||
| 820 | verify that VALUE fits in 'int'. This is because callers | ||
| 821 | want EMACS_INT. */ | ||
| 833 | if (!INTEGERP (value) || XINT (value) < 0) | 822 | if (!INTEGERP (value) || XINT (value) < 0) |
| 834 | return 0; | 823 | return 0; |
| 835 | break; | 824 | break; |
| @@ -849,7 +838,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, | |||
| 849 | break; | 838 | break; |
| 850 | 839 | ||
| 851 | case IMAGE_INTEGER_VALUE: | 840 | case IMAGE_INTEGER_VALUE: |
| 852 | if (!INTEGERP (value)) | 841 | if (! TYPE_RANGED_INTEGERP (int, value)) |
| 853 | return 0; | 842 | return 0; |
| 854 | break; | 843 | break; |
| 855 | 844 | ||
| @@ -919,7 +908,7 @@ or omitted means use the selected frame. */) | |||
| 919 | if (valid_image_p (spec)) | 908 | if (valid_image_p (spec)) |
| 920 | { | 909 | { |
| 921 | struct frame *f = check_x_frame (frame); | 910 | struct frame *f = check_x_frame (frame); |
| 922 | int id = lookup_image (f, spec); | 911 | ptrdiff_t id = lookup_image (f, spec); |
| 923 | struct image *img = IMAGE_FROM_ID (f, id); | 912 | struct image *img = IMAGE_FROM_ID (f, id); |
| 924 | int width = img->width + 2 * img->hmargin; | 913 | int width = img->width + 2 * img->hmargin; |
| 925 | int height = img->height + 2 * img->vmargin; | 914 | int height = img->height + 2 * img->vmargin; |
| @@ -949,7 +938,7 @@ or omitted means use the selected frame. */) | |||
| 949 | if (valid_image_p (spec)) | 938 | if (valid_image_p (spec)) |
| 950 | { | 939 | { |
| 951 | struct frame *f = check_x_frame (frame); | 940 | struct frame *f = check_x_frame (frame); |
| 952 | int id = lookup_image (f, spec); | 941 | ptrdiff_t id = lookup_image (f, spec); |
| 953 | struct image *img = IMAGE_FROM_ID (f, id); | 942 | struct image *img = IMAGE_FROM_ID (f, id); |
| 954 | if (img->mask) | 943 | if (img->mask) |
| 955 | mask = Qt; | 944 | mask = Qt; |
| @@ -972,7 +961,7 @@ or omitted means use the selected frame. */) | |||
| 972 | if (valid_image_p (spec)) | 961 | if (valid_image_p (spec)) |
| 973 | { | 962 | { |
| 974 | struct frame *f = check_x_frame (frame); | 963 | struct frame *f = check_x_frame (frame); |
| 975 | int id = lookup_image (f, spec); | 964 | ptrdiff_t id = lookup_image (f, spec); |
| 976 | struct image *img = IMAGE_FROM_ID (f, id); | 965 | struct image *img = IMAGE_FROM_ID (f, id); |
| 977 | ext = img->lisp_data; | 966 | ext = img->lisp_data; |
| 978 | } | 967 | } |
| @@ -1125,7 +1114,7 @@ image_ascent (struct image *img, struct face *face, struct glyph_slice *slice) | |||
| 1125 | ascent = height / 2; | 1114 | ascent = height / 2; |
| 1126 | } | 1115 | } |
| 1127 | else | 1116 | else |
| 1128 | ascent = (int) (height * img->ascent / 100.0); | 1117 | ascent = height * (img->ascent / 100.0); |
| 1129 | 1118 | ||
| 1130 | return ascent; | 1119 | return ascent; |
| 1131 | } | 1120 | } |
| @@ -1371,11 +1360,12 @@ x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name, | |||
| 1371 | { | 1360 | { |
| 1372 | /* This isn't called frequently so we get away with simply | 1361 | /* This isn't called frequently so we get away with simply |
| 1373 | reallocating the color vector to the needed size, here. */ | 1362 | reallocating the color vector to the needed size, here. */ |
| 1374 | ++img->ncolors; | 1363 | ptrdiff_t ncolors = img->ncolors + 1; |
| 1375 | img->colors = | 1364 | img->colors = |
| 1376 | (unsigned long *) xrealloc (img->colors, | 1365 | (unsigned long *) xrealloc (img->colors, |
| 1377 | img->ncolors * sizeof *img->colors); | 1366 | ncolors * sizeof *img->colors); |
| 1378 | img->colors[img->ncolors - 1] = color.pixel; | 1367 | img->colors[ncolors - 1] = color.pixel; |
| 1368 | img->ncolors = ncolors; | ||
| 1379 | result = color.pixel; | 1369 | result = color.pixel; |
| 1380 | } | 1370 | } |
| 1381 | else | 1371 | else |
| @@ -1403,8 +1393,9 @@ make_image_cache (void) | |||
| 1403 | int size; | 1393 | int size; |
| 1404 | 1394 | ||
| 1405 | memset (c, 0, sizeof *c); | 1395 | memset (c, 0, sizeof *c); |
| 1406 | c->size = 50; | 1396 | size = 50; |
| 1407 | c->images = (struct image **) xmalloc (c->size * sizeof *c->images); | 1397 | c->images = (struct image **) xmalloc (size * sizeof *c->images); |
| 1398 | c->size = size; | ||
| 1408 | size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | 1399 | size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
| 1409 | c->buckets = (struct image **) xmalloc (size); | 1400 | c->buckets = (struct image **) xmalloc (size); |
| 1410 | memset (c->buckets, 0, size); | 1401 | memset (c->buckets, 0, size); |
| @@ -1470,7 +1461,7 @@ free_image_cache (struct frame *f) | |||
| 1470 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 1461 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1471 | if (c) | 1462 | if (c) |
| 1472 | { | 1463 | { |
| 1473 | int i; | 1464 | ptrdiff_t i; |
| 1474 | 1465 | ||
| 1475 | /* Cache should not be referenced by any frame when freed. */ | 1466 | /* Cache should not be referenced by any frame when freed. */ |
| 1476 | xassert (c->refcount == 0); | 1467 | xassert (c->refcount == 0); |
| @@ -1500,7 +1491,7 @@ clear_image_cache (struct frame *f, Lisp_Object filter) | |||
| 1500 | 1491 | ||
| 1501 | if (c) | 1492 | if (c) |
| 1502 | { | 1493 | { |
| 1503 | int i, nfreed = 0; | 1494 | ptrdiff_t i, nfreed = 0; |
| 1504 | 1495 | ||
| 1505 | /* Block input so that we won't be interrupted by a SIGIO | 1496 | /* Block input so that we won't be interrupted by a SIGIO |
| 1506 | while being in an inconsistent state. */ | 1497 | while being in an inconsistent state. */ |
| @@ -1524,8 +1515,8 @@ clear_image_cache (struct frame *f, Lisp_Object filter) | |||
| 1524 | { | 1515 | { |
| 1525 | /* Free cache based on timestamp. */ | 1516 | /* Free cache based on timestamp. */ |
| 1526 | EMACS_TIME t; | 1517 | EMACS_TIME t; |
| 1527 | time_t old; | 1518 | double old, delay; |
| 1528 | int delay, nimages = 0; | 1519 | ptrdiff_t nimages = 0; |
| 1529 | 1520 | ||
| 1530 | for (i = 0; i < c->used; ++i) | 1521 | for (i = 0; i < c->used; ++i) |
| 1531 | if (c->images[i]) | 1522 | if (c->images[i]) |
| @@ -1533,9 +1524,10 @@ clear_image_cache (struct frame *f, Lisp_Object filter) | |||
| 1533 | 1524 | ||
| 1534 | /* If the number of cached images has grown unusually large, | 1525 | /* If the number of cached images has grown unusually large, |
| 1535 | decrease the cache eviction delay (Bug#6230). */ | 1526 | decrease the cache eviction delay (Bug#6230). */ |
| 1536 | delay = XFASTINT (Vimage_cache_eviction_delay); | 1527 | delay = XINT (Vimage_cache_eviction_delay); |
| 1537 | if (nimages > 40) | 1528 | if (nimages > 40) |
| 1538 | delay = max (1, 1600 * delay / (nimages*nimages)); | 1529 | delay = 1600 * delay / nimages / nimages; |
| 1530 | delay = max (delay, 1); | ||
| 1539 | 1531 | ||
| 1540 | EMACS_GET_TIME (t); | 1532 | EMACS_GET_TIME (t); |
| 1541 | old = EMACS_SECS (t) - delay; | 1533 | old = EMACS_SECS (t) - delay; |
| @@ -1711,7 +1703,7 @@ postprocess_image (struct frame *f, struct image *img) | |||
| 1711 | /* Return the id of image with Lisp specification SPEC on frame F. | 1703 | /* Return the id of image with Lisp specification SPEC on frame F. |
| 1712 | SPEC must be a valid Lisp image specification (see valid_image_p). */ | 1704 | SPEC must be a valid Lisp image specification (see valid_image_p). */ |
| 1713 | 1705 | ||
| 1714 | int | 1706 | ptrdiff_t |
| 1715 | lookup_image (struct frame *f, Lisp_Object spec) | 1707 | lookup_image (struct frame *f, Lisp_Object spec) |
| 1716 | { | 1708 | { |
| 1717 | struct image *img; | 1709 | struct image *img; |
| @@ -1770,15 +1762,12 @@ lookup_image (struct frame *f, Lisp_Object spec) | |||
| 1770 | img->ascent = CENTERED_IMAGE_ASCENT; | 1762 | img->ascent = CENTERED_IMAGE_ASCENT; |
| 1771 | 1763 | ||
| 1772 | margin = image_spec_value (spec, QCmargin, NULL); | 1764 | margin = image_spec_value (spec, QCmargin, NULL); |
| 1773 | if (INTEGERP (margin) && XINT (margin) >= 0) | 1765 | if (INTEGERP (margin)) |
| 1774 | img->vmargin = img->hmargin = XFASTINT (margin); | 1766 | img->vmargin = img->hmargin = XFASTINT (margin); |
| 1775 | else if (CONSP (margin) && INTEGERP (XCAR (margin)) | 1767 | else if (CONSP (margin)) |
| 1776 | && INTEGERP (XCDR (margin))) | ||
| 1777 | { | 1768 | { |
| 1778 | if (XINT (XCAR (margin)) > 0) | 1769 | img->hmargin = XFASTINT (XCAR (margin)); |
| 1779 | img->hmargin = XFASTINT (XCAR (margin)); | 1770 | img->vmargin = XFASTINT (XCDR (margin)); |
| 1780 | if (XINT (XCDR (margin)) > 0) | ||
| 1781 | img->vmargin = XFASTINT (XCDR (margin)); | ||
| 1782 | } | 1771 | } |
| 1783 | 1772 | ||
| 1784 | relief = image_spec_value (spec, QCrelief, NULL); | 1773 | relief = image_spec_value (spec, QCrelief, NULL); |
| @@ -1825,7 +1814,7 @@ static void | |||
| 1825 | cache_image (struct frame *f, struct image *img) | 1814 | cache_image (struct frame *f, struct image *img) |
| 1826 | { | 1815 | { |
| 1827 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 1816 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1828 | int i; | 1817 | ptrdiff_t i; |
| 1829 | 1818 | ||
| 1830 | /* Find a free slot in c->images. */ | 1819 | /* Find a free slot in c->images. */ |
| 1831 | for (i = 0; i < c->used; ++i) | 1820 | for (i = 0; i < c->used; ++i) |
| @@ -1834,13 +1823,7 @@ cache_image (struct frame *f, struct image *img) | |||
| 1834 | 1823 | ||
| 1835 | /* If no free slot found, maybe enlarge c->images. */ | 1824 | /* If no free slot found, maybe enlarge c->images. */ |
| 1836 | if (i == c->used && c->used == c->size) | 1825 | if (i == c->used && c->used == c->size) |
| 1837 | { | 1826 | c->images = xpalloc (c->images, &c->size, 1, -1, sizeof *c->images); |
| 1838 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *c->images / 2 < c->size) | ||
| 1839 | memory_full (SIZE_MAX); | ||
| 1840 | c->size *= 2; | ||
| 1841 | c->images = (struct image **) xrealloc (c->images, | ||
| 1842 | c->size * sizeof *c->images); | ||
| 1843 | } | ||
| 1844 | 1827 | ||
| 1845 | /* Add IMG to c->images, and assign IMG an id. */ | 1828 | /* Add IMG to c->images, and assign IMG an id. */ |
| 1846 | c->images[i] = img; | 1829 | c->images[i] = img; |
| @@ -1879,7 +1862,7 @@ mark_image_cache (struct image_cache *c) | |||
| 1879 | { | 1862 | { |
| 1880 | if (c) | 1863 | if (c) |
| 1881 | { | 1864 | { |
| 1882 | int i; | 1865 | ptrdiff_t i; |
| 1883 | for (i = 0; i < c->used; ++i) | 1866 | for (i = 0; i < c->used; ++i) |
| 1884 | if (c->images[i]) | 1867 | if (c->images[i]) |
| 1885 | mark_image (c->images[i]); | 1868 | mark_image (c->images[i]); |
| @@ -2076,7 +2059,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth, | |||
| 2076 | DWORD err = GetLastError (); | 2059 | DWORD err = GetLastError (); |
| 2077 | Lisp_Object errcode; | 2060 | Lisp_Object errcode; |
| 2078 | /* All system errors are < 10000, so the following is safe. */ | 2061 | /* All system errors are < 10000, so the following is safe. */ |
| 2079 | XSETINT (errcode, (int) err); | 2062 | XSETINT (errcode, err); |
| 2080 | image_error ("Unable to create bitmap, error code %d", errcode, Qnil); | 2063 | image_error ("Unable to create bitmap, error code %d", errcode, Qnil); |
| 2081 | x_destroy_x_image (*ximg); | 2064 | x_destroy_x_image (*ximg); |
| 2082 | return 0; | 2065 | return 0; |
| @@ -2274,7 +2257,7 @@ static const struct image_keyword xbm_format[XBM_LAST] = | |||
| 2274 | {":foreground", IMAGE_STRING_OR_NIL_VALUE, 0}, | 2257 | {":foreground", IMAGE_STRING_OR_NIL_VALUE, 0}, |
| 2275 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0}, | 2258 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0}, |
| 2276 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 2259 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 2277 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 2260 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 2278 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 2261 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 2279 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 2262 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 2280 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 2263 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -2355,7 +2338,7 @@ xbm_image_p (Lisp_Object object) | |||
| 2355 | else | 2338 | else |
| 2356 | { | 2339 | { |
| 2357 | Lisp_Object data; | 2340 | Lisp_Object data; |
| 2358 | EMACS_INT width, height; | 2341 | int width, height; |
| 2359 | 2342 | ||
| 2360 | /* Entries for `:width', `:height' and `:data' must be present. */ | 2343 | /* Entries for `:width', `:height' and `:data' must be present. */ |
| 2361 | if (!kw[XBM_WIDTH].count | 2344 | if (!kw[XBM_WIDTH].count |
| @@ -3069,7 +3052,7 @@ static const struct image_keyword xpm_format[XPM_LAST] = | |||
| 3069 | {":file", IMAGE_STRING_VALUE, 0}, | 3052 | {":file", IMAGE_STRING_VALUE, 0}, |
| 3070 | {":data", IMAGE_STRING_VALUE, 0}, | 3053 | {":data", IMAGE_STRING_VALUE, 0}, |
| 3071 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 3054 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 3072 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 3055 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 3073 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 3056 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 3074 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 3057 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 3075 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 3058 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -3587,9 +3570,8 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3587 | #endif /* HAVE_NTGUI */ | 3570 | #endif /* HAVE_NTGUI */ |
| 3588 | 3571 | ||
| 3589 | /* Remember allocated colors. */ | 3572 | /* Remember allocated colors. */ |
| 3573 | img->colors = xnmalloc (attrs.nalloc_pixels, sizeof *img->colors); | ||
| 3590 | img->ncolors = attrs.nalloc_pixels; | 3574 | img->ncolors = attrs.nalloc_pixels; |
| 3591 | img->colors = (unsigned long *) xmalloc (img->ncolors | ||
| 3592 | * sizeof *img->colors); | ||
| 3593 | for (i = 0; i < attrs.nalloc_pixels; ++i) | 3575 | for (i = 0; i < attrs.nalloc_pixels; ++i) |
| 3594 | { | 3576 | { |
| 3595 | img->colors[i] = attrs.alloc_pixels[i]; | 3577 | img->colors[i] = attrs.alloc_pixels[i]; |
| @@ -3813,8 +3795,8 @@ xpm_get_color_table_h (Lisp_Object color_table, | |||
| 3813 | int chars_len) | 3795 | int chars_len) |
| 3814 | { | 3796 | { |
| 3815 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); | 3797 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); |
| 3816 | int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len), | 3798 | ptrdiff_t i = |
| 3817 | NULL); | 3799 | hash_lookup (table, make_unibyte_string (chars_start, chars_len), NULL); |
| 3818 | 3800 | ||
| 3819 | return i >= 0 ? HASH_VALUE (table, i) : Qnil; | 3801 | return i >= 0 ? HASH_VALUE (table, i) : Qnil; |
| 3820 | } | 3802 | } |
| @@ -4163,6 +4145,12 @@ static struct ct_color **ct_table; | |||
| 4163 | /* Number of entries in the color table. */ | 4145 | /* Number of entries in the color table. */ |
| 4164 | 4146 | ||
| 4165 | static int ct_colors_allocated; | 4147 | static int ct_colors_allocated; |
| 4148 | enum | ||
| 4149 | { | ||
| 4150 | ct_colors_allocated_max = | ||
| 4151 | min (INT_MAX, | ||
| 4152 | min (PTRDIFF_MAX, SIZE_MAX) / sizeof (unsigned long)) | ||
| 4153 | }; | ||
| 4166 | 4154 | ||
| 4167 | /* Initialize the color table. */ | 4155 | /* Initialize the color table. */ |
| 4168 | 4156 | ||
| @@ -4249,7 +4237,14 @@ lookup_rgb_color (struct frame *f, int r, int g, int b) | |||
| 4249 | XColor color; | 4237 | XColor color; |
| 4250 | Colormap cmap; | 4238 | Colormap cmap; |
| 4251 | int rc; | 4239 | int rc; |
| 4240 | #else | ||
| 4241 | COLORREF color; | ||
| 4242 | #endif | ||
| 4252 | 4243 | ||
| 4244 | if (ct_colors_allocated_max <= ct_colors_allocated) | ||
| 4245 | return FRAME_FOREGROUND_PIXEL (f); | ||
| 4246 | |||
| 4247 | #ifdef HAVE_X_WINDOWS | ||
| 4253 | color.red = r; | 4248 | color.red = r; |
| 4254 | color.green = g; | 4249 | color.green = g; |
| 4255 | color.blue = b; | 4250 | color.blue = b; |
| @@ -4271,7 +4266,6 @@ lookup_rgb_color (struct frame *f, int r, int g, int b) | |||
| 4271 | return FRAME_FOREGROUND_PIXEL (f); | 4266 | return FRAME_FOREGROUND_PIXEL (f); |
| 4272 | 4267 | ||
| 4273 | #else | 4268 | #else |
| 4274 | COLORREF color; | ||
| 4275 | #ifdef HAVE_NTGUI | 4269 | #ifdef HAVE_NTGUI |
| 4276 | color = PALETTERGB (r, g, b); | 4270 | color = PALETTERGB (r, g, b); |
| 4277 | #else | 4271 | #else |
| @@ -4312,6 +4306,9 @@ lookup_pixel_color (struct frame *f, unsigned long pixel) | |||
| 4312 | Colormap cmap; | 4306 | Colormap cmap; |
| 4313 | int rc; | 4307 | int rc; |
| 4314 | 4308 | ||
| 4309 | if (ct_colors_allocated_max <= ct_colors_allocated) | ||
| 4310 | return FRAME_FOREGROUND_PIXEL (f); | ||
| 4311 | |||
| 4315 | #ifdef HAVE_X_WINDOWS | 4312 | #ifdef HAVE_X_WINDOWS |
| 4316 | cmap = FRAME_X_COLORMAP (f); | 4313 | cmap = FRAME_X_COLORMAP (f); |
| 4317 | color.pixel = pixel; | 4314 | color.pixel = pixel; |
| @@ -4450,7 +4447,9 @@ x_to_xcolors (struct frame *f, struct image *img, int rgb_p) | |||
| 4450 | HGDIOBJ prev; | 4447 | HGDIOBJ prev; |
| 4451 | #endif /* HAVE_NTGUI */ | 4448 | #endif /* HAVE_NTGUI */ |
| 4452 | 4449 | ||
| 4453 | colors = (XColor *) xmalloc (img->width * img->height * sizeof *colors); | 4450 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *colors / img->width < img->height) |
| 4451 | memory_full (SIZE_MAX); | ||
| 4452 | colors = (XColor *) xmalloc (sizeof *colors * img->width * img->height); | ||
| 4454 | 4453 | ||
| 4455 | #ifndef HAVE_NTGUI | 4454 | #ifndef HAVE_NTGUI |
| 4456 | /* Get the X image IMG->pixmap. */ | 4455 | /* Get the X image IMG->pixmap. */ |
| @@ -4602,7 +4601,9 @@ x_detect_edges (struct frame *f, struct image *img, int *matrix, int color_adjus | |||
| 4602 | 4601 | ||
| 4603 | #define COLOR(A, X, Y) ((A) + (Y) * img->width + (X)) | 4602 | #define COLOR(A, X, Y) ((A) + (Y) * img->width + (X)) |
| 4604 | 4603 | ||
| 4605 | new = (XColor *) xmalloc (img->width * img->height * sizeof *new); | 4604 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *new / img->width < img->height) |
| 4605 | memory_full (SIZE_MAX); | ||
| 4606 | new = (XColor *) xmalloc (sizeof *new * img->width * img->height); | ||
| 4606 | 4607 | ||
| 4607 | for (y = 0; y < img->height; ++y) | 4608 | for (y = 0; y < img->height; ++y) |
| 4608 | { | 4609 | { |
| @@ -4980,7 +4981,7 @@ static const struct image_keyword pbm_format[PBM_LAST] = | |||
| 4980 | {":file", IMAGE_STRING_VALUE, 0}, | 4981 | {":file", IMAGE_STRING_VALUE, 0}, |
| 4981 | {":data", IMAGE_STRING_VALUE, 0}, | 4982 | {":data", IMAGE_STRING_VALUE, 0}, |
| 4982 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 4983 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 4983 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 4984 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 4984 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 4985 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 4985 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 4986 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 4986 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 4987 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -5395,7 +5396,7 @@ static const struct image_keyword png_format[PNG_LAST] = | |||
| 5395 | {":data", IMAGE_STRING_VALUE, 0}, | 5396 | {":data", IMAGE_STRING_VALUE, 0}, |
| 5396 | {":file", IMAGE_STRING_VALUE, 0}, | 5397 | {":file", IMAGE_STRING_VALUE, 0}, |
| 5397 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 5398 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 5398 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 5399 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 5399 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 5400 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 5400 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 5401 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 5401 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 5402 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -5880,7 +5881,7 @@ png_load (struct frame *f, struct image *img) | |||
| 5880 | 5881 | ||
| 5881 | for (x = 0; x < width; ++x) | 5882 | for (x = 0; x < width; ++x) |
| 5882 | { | 5883 | { |
| 5883 | unsigned r, g, b; | 5884 | int r, g, b; |
| 5884 | 5885 | ||
| 5885 | r = *p++ << 8; | 5886 | r = *p++ << 8; |
| 5886 | g = *p++ << 8; | 5887 | g = *p++ << 8; |
| @@ -6015,7 +6016,7 @@ static const struct image_keyword jpeg_format[JPEG_LAST] = | |||
| 6015 | {":data", IMAGE_STRING_VALUE, 0}, | 6016 | {":data", IMAGE_STRING_VALUE, 0}, |
| 6016 | {":file", IMAGE_STRING_VALUE, 0}, | 6017 | {":file", IMAGE_STRING_VALUE, 0}, |
| 6017 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 6018 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 6018 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 6019 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 6019 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 6020 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 6020 | {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 6021 | {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 6021 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 6022 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -6565,7 +6566,7 @@ static const struct image_keyword tiff_format[TIFF_LAST] = | |||
| 6565 | {":data", IMAGE_STRING_VALUE, 0}, | 6566 | {":data", IMAGE_STRING_VALUE, 0}, |
| 6566 | {":file", IMAGE_STRING_VALUE, 0}, | 6567 | {":file", IMAGE_STRING_VALUE, 0}, |
| 6567 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 6568 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 6568 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 6569 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 6569 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 6570 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 6570 | {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 6571 | {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 6571 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 6572 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -6745,17 +6746,29 @@ tiff_size_of_memory (thandle_t data) | |||
| 6745 | } | 6746 | } |
| 6746 | 6747 | ||
| 6747 | 6748 | ||
| 6749 | static void tiff_handler (const char *, const char *, const char *, va_list) | ||
| 6750 | ATTRIBUTE_FORMAT_PRINTF (3, 0); | ||
| 6751 | static void | ||
| 6752 | tiff_handler (const char *log_format, const char *title, | ||
| 6753 | const char *format, va_list ap) | ||
| 6754 | { | ||
| 6755 | /* doprnt is not suitable here, as TIFF handlers are called from | ||
| 6756 | libtiff and are passed arbitrary printf directives. Instead, use | ||
| 6757 | vsnprintf, taking care to be portable to nonstandard environments | ||
| 6758 | where vsnprintf returns -1 on buffer overflow. Since it's just a | ||
| 6759 | log entry, it's OK to truncate it. */ | ||
| 6760 | char buf[4000]; | ||
| 6761 | int len = vsnprintf (buf, sizeof buf, format, ap); | ||
| 6762 | add_to_log (log_format, build_string (title), | ||
| 6763 | make_string (buf, max (0, min (len, sizeof buf - 1)))); | ||
| 6764 | } | ||
| 6765 | |||
| 6748 | static void tiff_error_handler (const char *, const char *, va_list) | 6766 | static void tiff_error_handler (const char *, const char *, va_list) |
| 6749 | ATTRIBUTE_FORMAT_PRINTF (2, 0); | 6767 | ATTRIBUTE_FORMAT_PRINTF (2, 0); |
| 6750 | static void | 6768 | static void |
| 6751 | tiff_error_handler (const char *title, const char *format, va_list ap) | 6769 | tiff_error_handler (const char *title, const char *format, va_list ap) |
| 6752 | { | 6770 | { |
| 6753 | char buf[512]; | 6771 | tiff_handler ("TIFF error: %s %s", title, format, ap); |
| 6754 | int len; | ||
| 6755 | |||
| 6756 | len = sprintf (buf, "TIFF error: %s ", title); | ||
| 6757 | vsprintf (buf + len, format, ap); | ||
| 6758 | add_to_log (buf, Qnil, Qnil); | ||
| 6759 | } | 6772 | } |
| 6760 | 6773 | ||
| 6761 | 6774 | ||
| @@ -6764,12 +6777,7 @@ static void tiff_warning_handler (const char *, const char *, va_list) | |||
| 6764 | static void | 6777 | static void |
| 6765 | tiff_warning_handler (const char *title, const char *format, va_list ap) | 6778 | tiff_warning_handler (const char *title, const char *format, va_list ap) |
| 6766 | { | 6779 | { |
| 6767 | char buf[512]; | 6780 | tiff_handler ("TIFF warning: %s %s", title, format, ap); |
| 6768 | int len; | ||
| 6769 | |||
| 6770 | len = sprintf (buf, "TIFF warning: %s ", title); | ||
| 6771 | vsprintf (buf + len, format, ap); | ||
| 6772 | add_to_log (buf, Qnil, Qnil); | ||
| 6773 | } | 6781 | } |
| 6774 | 6782 | ||
| 6775 | 6783 | ||
| @@ -6845,8 +6853,9 @@ tiff_load (struct frame *f, struct image *img) | |||
| 6845 | image = image_spec_value (img->spec, QCindex, NULL); | 6853 | image = image_spec_value (img->spec, QCindex, NULL); |
| 6846 | if (INTEGERP (image)) | 6854 | if (INTEGERP (image)) |
| 6847 | { | 6855 | { |
| 6848 | int ino = XFASTINT (image); | 6856 | EMACS_INT ino = XFASTINT (image); |
| 6849 | if (!fn_TIFFSetDirectory (tiff, ino)) | 6857 | if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t) |
| 6858 | && fn_TIFFSetDirectory (tiff, ino))) | ||
| 6850 | { | 6859 | { |
| 6851 | image_error ("Invalid image number `%s' in image `%s'", | 6860 | image_error ("Invalid image number `%s' in image `%s'", |
| 6852 | image, img->spec); | 6861 | image, img->spec); |
| @@ -6994,7 +7003,7 @@ static const struct image_keyword gif_format[GIF_LAST] = | |||
| 6994 | {":data", IMAGE_STRING_VALUE, 0}, | 7003 | {":data", IMAGE_STRING_VALUE, 0}, |
| 6995 | {":file", IMAGE_STRING_VALUE, 0}, | 7004 | {":file", IMAGE_STRING_VALUE, 0}, |
| 6996 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 7005 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 6997 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 7006 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 6998 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 7007 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 6999 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7008 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 7000 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7009 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -7139,13 +7148,12 @@ gif_load (struct frame *f, struct image *img) | |||
| 7139 | ColorMapObject *gif_color_map; | 7148 | ColorMapObject *gif_color_map; |
| 7140 | unsigned long pixel_colors[256]; | 7149 | unsigned long pixel_colors[256]; |
| 7141 | GifFileType *gif; | 7150 | GifFileType *gif; |
| 7142 | int image_height, image_width; | ||
| 7143 | gif_memory_source memsrc; | 7151 | gif_memory_source memsrc; |
| 7144 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 7152 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 7145 | Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); | 7153 | Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); |
| 7146 | Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); | 7154 | Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); |
| 7147 | unsigned long bgcolor = 0; | 7155 | unsigned long bgcolor = 0; |
| 7148 | int idx; | 7156 | EMACS_INT idx; |
| 7149 | 7157 | ||
| 7150 | if (NILP (specified_data)) | 7158 | if (NILP (specified_data)) |
| 7151 | { | 7159 | { |
| @@ -7216,19 +7224,13 @@ gif_load (struct frame *f, struct image *img) | |||
| 7216 | } | 7224 | } |
| 7217 | } | 7225 | } |
| 7218 | 7226 | ||
| 7219 | img->corners[TOP_CORNER] = gif->SavedImages[idx].ImageDesc.Top; | 7227 | width = img->width = gif->SWidth; |
| 7220 | img->corners[LEFT_CORNER] = gif->SavedImages[idx].ImageDesc.Left; | 7228 | height = img->height = gif->SHeight; |
| 7221 | image_height = gif->SavedImages[idx].ImageDesc.Height; | ||
| 7222 | img->corners[BOT_CORNER] = img->corners[TOP_CORNER] + image_height; | ||
| 7223 | image_width = gif->SavedImages[idx].ImageDesc.Width; | ||
| 7224 | img->corners[RIGHT_CORNER] = img->corners[LEFT_CORNER] + image_width; | ||
| 7225 | 7229 | ||
| 7226 | width = img->width = max (gif->SWidth, | 7230 | img->corners[TOP_CORNER] = gif->SavedImages[0].ImageDesc.Top; |
| 7227 | max (gif->Image.Left + gif->Image.Width, | 7231 | img->corners[LEFT_CORNER] = gif->SavedImages[0].ImageDesc.Left; |
| 7228 | img->corners[RIGHT_CORNER])); | 7232 | img->corners[BOT_CORNER] = img->corners[TOP_CORNER] + height; |
| 7229 | height = img->height = max (gif->SHeight, | 7233 | img->corners[RIGHT_CORNER] = img->corners[LEFT_CORNER] + width; |
| 7230 | max (gif->Image.Top + gif->Image.Height, | ||
| 7231 | img->corners[BOT_CORNER])); | ||
| 7232 | 7234 | ||
| 7233 | if (!check_image_size (f, width, height)) | 7235 | if (!check_image_size (f, width, height)) |
| 7234 | { | 7236 | { |
| @@ -7283,6 +7285,10 @@ gif_load (struct frame *f, struct image *img) | |||
| 7283 | unsigned char *raster = (unsigned char *) subimage->RasterBits; | 7285 | unsigned char *raster = (unsigned char *) subimage->RasterBits; |
| 7284 | int transparency_color_index = -1; | 7286 | int transparency_color_index = -1; |
| 7285 | int disposal = 0; | 7287 | int disposal = 0; |
| 7288 | int subimg_width = subimage->ImageDesc.Width; | ||
| 7289 | int subimg_height = subimage->ImageDesc.Height; | ||
| 7290 | int subimg_top = subimage->ImageDesc.Top; | ||
| 7291 | int subimg_left = subimage->ImageDesc.Left; | ||
| 7286 | 7292 | ||
| 7287 | /* Find the Graphic Control Extension block for this sub-image. | 7293 | /* Find the Graphic Control Extension block for this sub-image. |
| 7288 | Extract the disposal method and transparency color. */ | 7294 | Extract the disposal method and transparency color. */ |
| @@ -7306,6 +7312,13 @@ gif_load (struct frame *f, struct image *img) | |||
| 7306 | if (j == 0) | 7312 | if (j == 0) |
| 7307 | disposal = 2; | 7313 | disposal = 2; |
| 7308 | 7314 | ||
| 7315 | /* For disposal == 0, the spec says "No disposal specified. The | ||
| 7316 | decoder is not required to take any action." In practice, it | ||
| 7317 | seems we need to treat this like "keep in place", see e.g. | ||
| 7318 | http://upload.wikimedia.org/wikipedia/commons/3/37/Clock.gif */ | ||
| 7319 | if (disposal == 0) | ||
| 7320 | disposal = 1; | ||
| 7321 | |||
| 7309 | /* Allocate subimage colors. */ | 7322 | /* Allocate subimage colors. */ |
| 7310 | memset (pixel_colors, 0, sizeof pixel_colors); | 7323 | memset (pixel_colors, 0, sizeof pixel_colors); |
| 7311 | gif_color_map = subimage->ImageDesc.ColorMap; | 7324 | gif_color_map = subimage->ImageDesc.ColorMap; |
| @@ -7333,34 +7346,34 @@ gif_load (struct frame *f, struct image *img) | |||
| 7333 | int row, pass; | 7346 | int row, pass; |
| 7334 | 7347 | ||
| 7335 | for (y = 0, row = interlace_start[0], pass = 0; | 7348 | for (y = 0, row = interlace_start[0], pass = 0; |
| 7336 | y < image_height; | 7349 | y < subimg_height; |
| 7337 | y++, row += interlace_increment[pass]) | 7350 | y++, row += interlace_increment[pass]) |
| 7338 | { | 7351 | { |
| 7339 | if (row >= image_height) | 7352 | if (row >= subimg_height) |
| 7340 | { | 7353 | { |
| 7341 | row = interlace_start[++pass]; | 7354 | row = interlace_start[++pass]; |
| 7342 | while (row >= image_height) | 7355 | while (row >= subimg_height) |
| 7343 | row = interlace_start[++pass]; | 7356 | row = interlace_start[++pass]; |
| 7344 | } | 7357 | } |
| 7345 | 7358 | ||
| 7346 | for (x = 0; x < image_width; x++) | 7359 | for (x = 0; x < subimg_width; x++) |
| 7347 | { | 7360 | { |
| 7348 | int c = raster[y * image_width + x]; | 7361 | int c = raster[y * subimg_width + x]; |
| 7349 | if (transparency_color_index != c || disposal != 1) | 7362 | if (transparency_color_index != c || disposal != 1) |
| 7350 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], | 7363 | XPutPixel (ximg, x + subimg_left, row + subimg_top, |
| 7351 | row + img->corners[TOP_CORNER], pixel_colors[c]); | 7364 | pixel_colors[c]); |
| 7352 | } | 7365 | } |
| 7353 | } | 7366 | } |
| 7354 | } | 7367 | } |
| 7355 | else | 7368 | else |
| 7356 | { | 7369 | { |
| 7357 | for (y = 0; y < image_height; ++y) | 7370 | for (y = 0; y < subimg_height; ++y) |
| 7358 | for (x = 0; x < image_width; ++x) | 7371 | for (x = 0; x < subimg_width; ++x) |
| 7359 | { | 7372 | { |
| 7360 | int c = raster[y * image_width + x]; | 7373 | int c = raster[y * subimg_width + x]; |
| 7361 | if (transparency_color_index != c || disposal != 1) | 7374 | if (transparency_color_index != c || disposal != 1) |
| 7362 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], | 7375 | XPutPixel (ximg, x + subimg_left, y + subimg_top, |
| 7363 | y + img->corners[TOP_CORNER], pixel_colors[c]); | 7376 | pixel_colors[c]); |
| 7364 | } | 7377 | } |
| 7365 | } | 7378 | } |
| 7366 | } | 7379 | } |
| @@ -7375,7 +7388,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7375 | img->lisp_data = Qnil; | 7388 | img->lisp_data = Qnil; |
| 7376 | if (gif->SavedImages[idx].ExtensionBlockCount > 0) | 7389 | if (gif->SavedImages[idx].ExtensionBlockCount > 0) |
| 7377 | { | 7390 | { |
| 7378 | unsigned int delay = 0; | 7391 | int delay = 0; |
| 7379 | ExtensionBlock *ext = gif->SavedImages[idx].ExtensionBlocks; | 7392 | ExtensionBlock *ext = gif->SavedImages[idx].ExtensionBlocks; |
| 7380 | for (i = 0; i < gif->SavedImages[idx].ExtensionBlockCount; i++, ext++) | 7393 | for (i = 0; i < gif->SavedImages[idx].ExtensionBlockCount; i++, ext++) |
| 7381 | /* Append (... FUNCTION "BYTES") */ | 7394 | /* Append (... FUNCTION "BYTES") */ |
| @@ -7396,7 +7409,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7396 | if (delay) | 7409 | if (delay) |
| 7397 | img->lisp_data | 7410 | img->lisp_data |
| 7398 | = Fcons (Qdelay, | 7411 | = Fcons (Qdelay, |
| 7399 | Fcons (make_float (((double) delay) * 0.01), | 7412 | Fcons (make_float (delay / 100.0), |
| 7400 | img->lisp_data)); | 7413 | img->lisp_data)); |
| 7401 | } | 7414 | } |
| 7402 | 7415 | ||
| @@ -7475,7 +7488,7 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] = | |||
| 7475 | {":data", IMAGE_STRING_VALUE, 0}, | 7488 | {":data", IMAGE_STRING_VALUE, 0}, |
| 7476 | {":file", IMAGE_STRING_VALUE, 0}, | 7489 | {":file", IMAGE_STRING_VALUE, 0}, |
| 7477 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 7490 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 7478 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 7491 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 7479 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 7492 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 7480 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7493 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 7481 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7494 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -7572,10 +7585,10 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7572 | Lisp_Object image; | 7585 | Lisp_Object image; |
| 7573 | Lisp_Object value; | 7586 | Lisp_Object value; |
| 7574 | Lisp_Object crop; | 7587 | Lisp_Object crop; |
| 7575 | long ino; | 7588 | EMACS_INT ino; |
| 7576 | int desired_width, desired_height; | 7589 | int desired_width, desired_height; |
| 7577 | double rotation; | 7590 | double rotation; |
| 7578 | int imagemagick_rendermethod; | 7591 | EMACS_INT imagemagick_rendermethod; |
| 7579 | int pixelwidth; | 7592 | int pixelwidth; |
| 7580 | ImageInfo *image_info; | 7593 | ImageInfo *image_info; |
| 7581 | ExceptionInfo *exception; | 7594 | ExceptionInfo *exception; |
| @@ -7602,7 +7615,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7602 | status = MagickPingImageBlob (ping_wand, contents, size); | 7615 | status = MagickPingImageBlob (ping_wand, contents, size); |
| 7603 | } | 7616 | } |
| 7604 | 7617 | ||
| 7605 | if (ino >= MagickGetNumberImages (ping_wand)) | 7618 | if (! (0 <= ino && ino < MagickGetNumberImages (ping_wand))) |
| 7606 | { | 7619 | { |
| 7607 | image_error ("Invalid image number `%s' in image `%s'", | 7620 | image_error ("Invalid image number `%s' in image `%s'", |
| 7608 | image, img->spec); | 7621 | image, img->spec); |
| @@ -7677,28 +7690,28 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7677 | efficient. */ | 7690 | efficient. */ |
| 7678 | crop = image_spec_value (img->spec, QCcrop, NULL); | 7691 | crop = image_spec_value (img->spec, QCcrop, NULL); |
| 7679 | 7692 | ||
| 7680 | if (CONSP (crop) && INTEGERP (XCAR (crop))) | 7693 | if (CONSP (crop) && TYPE_RANGED_INTEGERP (size_t, XCAR (crop))) |
| 7681 | { | 7694 | { |
| 7682 | /* After some testing, it seems MagickCropImage is the fastest crop | 7695 | /* After some testing, it seems MagickCropImage is the fastest crop |
| 7683 | function in ImageMagick. This crop function seems to do less copying | 7696 | function in ImageMagick. This crop function seems to do less copying |
| 7684 | than the alternatives, but it still reads the entire image into memory | 7697 | than the alternatives, but it still reads the entire image into memory |
| 7685 | before croping, which is aparently difficult to avoid when using | 7698 | before cropping, which is apparently difficult to avoid when using |
| 7686 | imagemagick. */ | 7699 | imagemagick. */ |
| 7687 | int w, h; | 7700 | size_t crop_width = XINT (XCAR (crop)); |
| 7688 | w = XFASTINT (XCAR (crop)); | ||
| 7689 | crop = XCDR (crop); | 7701 | crop = XCDR (crop); |
| 7690 | if (CONSP (crop) && INTEGERP (XCAR (crop))) | 7702 | if (CONSP (crop) && TYPE_RANGED_INTEGERP (size_t, XCAR (crop))) |
| 7691 | { | 7703 | { |
| 7692 | h = XFASTINT (XCAR (crop)); | 7704 | size_t crop_height = XINT (XCAR (crop)); |
| 7693 | crop = XCDR (crop); | 7705 | crop = XCDR (crop); |
| 7694 | if (CONSP (crop) && INTEGERP (XCAR (crop))) | 7706 | if (CONSP (crop) && TYPE_RANGED_INTEGERP (ssize_t, XCAR (crop))) |
| 7695 | { | 7707 | { |
| 7696 | x = XFASTINT (XCAR (crop)); | 7708 | ssize_t crop_x = XINT (XCAR (crop)); |
| 7697 | crop = XCDR (crop); | 7709 | crop = XCDR (crop); |
| 7698 | if (CONSP (crop) && INTEGERP (XCAR (crop))) | 7710 | if (CONSP (crop) && TYPE_RANGED_INTEGERP (ssize_t, XCAR (crop))) |
| 7699 | { | 7711 | { |
| 7700 | y = XFASTINT (XCAR (crop)); | 7712 | ssize_t crop_y = XINT (XCAR (crop)); |
| 7701 | MagickCropImage (image_wand, w, h, x, y); | 7713 | MagickCropImage (image_wand, crop_width, crop_height, |
| 7714 | crop_x, crop_y); | ||
| 7702 | } | 7715 | } |
| 7703 | } | 7716 | } |
| 7704 | } | 7717 | } |
| @@ -7744,9 +7757,11 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7744 | 7757 | ||
| 7745 | init_color_table (); | 7758 | init_color_table (); |
| 7746 | imagemagick_rendermethod = (INTEGERP (Vimagemagick_render_type) | 7759 | imagemagick_rendermethod = (INTEGERP (Vimagemagick_render_type) |
| 7747 | ? XFASTINT (Vimagemagick_render_type) : 0); | 7760 | ? XINT (Vimagemagick_render_type) : 0); |
| 7748 | if (imagemagick_rendermethod == 0) | 7761 | if (imagemagick_rendermethod == 0) |
| 7749 | { | 7762 | { |
| 7763 | size_t image_height; | ||
| 7764 | |||
| 7750 | /* Try to create a x pixmap to hold the imagemagick pixmap. */ | 7765 | /* Try to create a x pixmap to hold the imagemagick pixmap. */ |
| 7751 | if (!x_create_x_image_and_pixmap (f, width, height, 0, | 7766 | if (!x_create_x_image_and_pixmap (f, width, height, 0, |
| 7752 | &ximg, &img->pixmap)) | 7767 | &ximg, &img->pixmap)) |
| @@ -7775,7 +7790,8 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7775 | goto imagemagick_error; | 7790 | goto imagemagick_error; |
| 7776 | } | 7791 | } |
| 7777 | 7792 | ||
| 7778 | for (y = 0; y < (long) MagickGetImageHeight (image_wand); y++) | 7793 | image_height = MagickGetImageHeight (image_wand); |
| 7794 | for (y = 0; y < image_height; y++) | ||
| 7779 | { | 7795 | { |
| 7780 | pixels = PixelGetNextIteratorRow (iterator, &width); | 7796 | pixels = PixelGetNextIteratorRow (iterator, &width); |
| 7781 | if (pixels == (PixelWand **) NULL) | 7797 | if (pixels == (PixelWand **) NULL) |
| @@ -7995,7 +8011,7 @@ static const struct image_keyword svg_format[SVG_LAST] = | |||
| 7995 | {":data", IMAGE_STRING_VALUE, 0}, | 8011 | {":data", IMAGE_STRING_VALUE, 0}, |
| 7996 | {":file", IMAGE_STRING_VALUE, 0}, | 8012 | {":file", IMAGE_STRING_VALUE, 0}, |
| 7997 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 8013 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 7998 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 8014 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 7999 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 8015 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 8000 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 8016 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 8001 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 8017 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -8281,10 +8297,10 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8281 | { | 8297 | { |
| 8282 | for (x = 0; x < width; ++x) | 8298 | for (x = 0; x < width; ++x) |
| 8283 | { | 8299 | { |
| 8284 | unsigned red; | 8300 | int red; |
| 8285 | unsigned green; | 8301 | int green; |
| 8286 | unsigned blue; | 8302 | int blue; |
| 8287 | unsigned opacity; | 8303 | int opacity; |
| 8288 | 8304 | ||
| 8289 | red = *pixels++; | 8305 | red = *pixels++; |
| 8290 | green = *pixels++; | 8306 | green = *pixels++; |
| @@ -8390,7 +8406,7 @@ static const struct image_keyword gs_format[GS_LAST] = | |||
| 8390 | {":loader", IMAGE_FUNCTION_VALUE, 0}, | 8406 | {":loader", IMAGE_FUNCTION_VALUE, 0}, |
| 8391 | {":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE, 1}, | 8407 | {":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE, 1}, |
| 8392 | {":ascent", IMAGE_ASCENT_VALUE, 0}, | 8408 | {":ascent", IMAGE_ASCENT_VALUE, 0}, |
| 8393 | {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 8409 | {":margin", IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0}, |
| 8394 | {":relief", IMAGE_INTEGER_VALUE, 0}, | 8410 | {":relief", IMAGE_INTEGER_VALUE, 0}, |
| 8395 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 8411 | {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| 8396 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 8412 | {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
| @@ -8465,7 +8481,8 @@ gs_image_p (Lisp_Object object) | |||
| 8465 | static int | 8481 | static int |
| 8466 | gs_load (struct frame *f, struct image *img) | 8482 | gs_load (struct frame *f, struct image *img) |
| 8467 | { | 8483 | { |
| 8468 | char buffer[100]; | 8484 | uprintmax_t printnum1, printnum2; |
| 8485 | char buffer[sizeof " " + INT_STRLEN_BOUND (printmax_t)]; | ||
| 8469 | Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width; | 8486 | Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width; |
| 8470 | Lisp_Object frame; | 8487 | Lisp_Object frame; |
| 8471 | double in_width, in_height; | 8488 | double in_width, in_height; |
| @@ -8477,16 +8494,19 @@ gs_load (struct frame *f, struct image *img) | |||
| 8477 | info. */ | 8494 | info. */ |
| 8478 | pt_width = image_spec_value (img->spec, QCpt_width, NULL); | 8495 | pt_width = image_spec_value (img->spec, QCpt_width, NULL); |
| 8479 | in_width = INTEGERP (pt_width) ? XFASTINT (pt_width) / 72.0 : 0; | 8496 | in_width = INTEGERP (pt_width) ? XFASTINT (pt_width) / 72.0 : 0; |
| 8480 | img->width = in_width * FRAME_X_DISPLAY_INFO (f)->resx; | 8497 | in_width *= FRAME_X_DISPLAY_INFO (f)->resx; |
| 8481 | pt_height = image_spec_value (img->spec, QCpt_height, NULL); | 8498 | pt_height = image_spec_value (img->spec, QCpt_height, NULL); |
| 8482 | in_height = INTEGERP (pt_height) ? XFASTINT (pt_height) / 72.0 : 0; | 8499 | in_height = INTEGERP (pt_height) ? XFASTINT (pt_height) / 72.0 : 0; |
| 8483 | img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy; | 8500 | in_height *= FRAME_X_DISPLAY_INFO (f)->resy; |
| 8484 | 8501 | ||
| 8485 | if (!check_image_size (f, img->width, img->height)) | 8502 | if (! (in_width <= INT_MAX && in_height <= INT_MAX |
| 8503 | && check_image_size (f, in_width, in_height))) | ||
| 8486 | { | 8504 | { |
| 8487 | image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); | 8505 | image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); |
| 8488 | return 0; | 8506 | return 0; |
| 8489 | } | 8507 | } |
| 8508 | img->width = in_width; | ||
| 8509 | img->height = in_height; | ||
| 8490 | 8510 | ||
| 8491 | /* Create the pixmap. */ | 8511 | /* Create the pixmap. */ |
| 8492 | xassert (img->pixmap == NO_PIXMAP); | 8512 | xassert (img->pixmap == NO_PIXMAP); |
| @@ -8511,14 +8531,14 @@ gs_load (struct frame *f, struct image *img) | |||
| 8511 | if successful. We do not record_unwind_protect here because | 8531 | if successful. We do not record_unwind_protect here because |
| 8512 | other places in redisplay like calling window scroll functions | 8532 | other places in redisplay like calling window scroll functions |
| 8513 | don't either. Let the Lisp loader use `unwind-protect' instead. */ | 8533 | don't either. Let the Lisp loader use `unwind-protect' instead. */ |
| 8514 | sprintf (buffer, "%lu %lu", | 8534 | printnum1 = FRAME_X_WINDOW (f); |
| 8515 | (unsigned long) FRAME_X_WINDOW (f), | 8535 | printnum2 = img->pixmap; |
| 8516 | (unsigned long) img->pixmap); | 8536 | sprintf (buffer, "%"pMu" %"pMu, printnum1, printnum2); |
| 8517 | window_and_pixmap_id = build_string (buffer); | 8537 | window_and_pixmap_id = build_string (buffer); |
| 8518 | 8538 | ||
| 8519 | sprintf (buffer, "%lu %lu", | 8539 | printnum1 = FRAME_FOREGROUND_PIXEL (f); |
| 8520 | FRAME_FOREGROUND_PIXEL (f), | 8540 | printnum2 = FRAME_BACKGROUND_PIXEL (f); |
| 8521 | FRAME_BACKGROUND_PIXEL (f)); | 8541 | sprintf (buffer, "%"pMu" %"pMu, printnum1, printnum2); |
| 8522 | pixel_colors = build_string (buffer); | 8542 | pixel_colors = build_string (buffer); |
| 8523 | 8543 | ||
| 8524 | XSETFRAME (frame, f); | 8544 | XSETFRAME (frame, f); |
| @@ -8543,7 +8563,8 @@ void | |||
| 8543 | x_kill_gs_process (Pixmap pixmap, struct frame *f) | 8563 | x_kill_gs_process (Pixmap pixmap, struct frame *f) |
| 8544 | { | 8564 | { |
| 8545 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 8565 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 8546 | int class, i; | 8566 | int class; |
| 8567 | ptrdiff_t i; | ||
| 8547 | struct image *img; | 8568 | struct image *img; |
| 8548 | 8569 | ||
| 8549 | /* Find the image containing PIXMAP. */ | 8570 | /* Find the image containing PIXMAP. */ |
| @@ -8647,7 +8668,7 @@ DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0, | |||
| 8647 | DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") | 8668 | DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") |
| 8648 | (Lisp_Object spec) | 8669 | (Lisp_Object spec) |
| 8649 | { | 8670 | { |
| 8650 | int id = -1; | 8671 | ptrdiff_t id = -1; |
| 8651 | 8672 | ||
| 8652 | if (valid_image_p (spec)) | 8673 | if (valid_image_p (spec)) |
| 8653 | id = lookup_image (SELECTED_FRAME (), spec); | 8674 | id = lookup_image (SELECTED_FRAME (), spec); |
diff --git a/src/indent.c b/src/indent.c index aaeaaf591ef..313315e9081 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -284,7 +284,7 @@ skip_invisible (EMACS_INT pos, EMACS_INT *next_boundary_p, EMACS_INT to, Lisp_Ob | |||
| 284 | else \ | 284 | else \ |
| 285 | { \ | 285 | { \ |
| 286 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, ch))) \ | 286 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, ch))) \ |
| 287 | width = ASIZE (DISP_CHAR_VECTOR (dp, ch)); \ | 287 | width = sanitize_char_width (ASIZE (DISP_CHAR_VECTOR (dp, ch))); \ |
| 288 | else \ | 288 | else \ |
| 289 | width = CHAR_WIDTH (ch); \ | 289 | width = CHAR_WIDTH (ch); \ |
| 290 | } \ | 290 | } \ |
| @@ -318,15 +318,6 @@ invalidate_current_column (void) | |||
| 318 | last_known_column_point = 0; | 318 | last_known_column_point = 0; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | /* Return a non-outlandish value for the tab width. */ | ||
| 322 | |||
| 323 | static int | ||
| 324 | sane_tab_width (void) | ||
| 325 | { | ||
| 326 | EMACS_INT n = XFASTINT (BVAR (current_buffer, tab_width)); | ||
| 327 | return 0 < n && n <= 1000 ? n : 8; | ||
| 328 | } | ||
| 329 | |||
| 330 | EMACS_INT | 321 | EMACS_INT |
| 331 | current_column (void) | 322 | current_column (void) |
| 332 | { | 323 | { |
| @@ -335,7 +326,7 @@ current_column (void) | |||
| 335 | register int tab_seen; | 326 | register int tab_seen; |
| 336 | EMACS_INT post_tab; | 327 | EMACS_INT post_tab; |
| 337 | register int c; | 328 | register int c; |
| 338 | int tab_width = sane_tab_width (); | 329 | int tab_width = SANE_TAB_WIDTH (current_buffer); |
| 339 | int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); | 330 | int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); |
| 340 | register struct Lisp_Char_Table *dp = buffer_display_table (); | 331 | register struct Lisp_Char_Table *dp = buffer_display_table (); |
| 341 | 332 | ||
| @@ -515,7 +506,7 @@ check_display_width (EMACS_INT pos, EMACS_INT col, EMACS_INT *endpos) | |||
| 515 | static void | 506 | static void |
| 516 | scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) | 507 | scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) |
| 517 | { | 508 | { |
| 518 | int tab_width = sane_tab_width (); | 509 | int tab_width = SANE_TAB_WIDTH (current_buffer); |
| 519 | register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); | 510 | register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); |
| 520 | register struct Lisp_Char_Table *dp = buffer_display_table (); | 511 | register struct Lisp_Char_Table *dp = buffer_display_table (); |
| 521 | int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); | 512 | int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| @@ -732,7 +723,7 @@ string_display_width (Lisp_Object string, Lisp_Object beg, Lisp_Object end) | |||
| 732 | register int tab_seen; | 723 | register int tab_seen; |
| 733 | int post_tab; | 724 | int post_tab; |
| 734 | register int c; | 725 | register int c; |
| 735 | int tab_width = sane_tab_width (); | 726 | int tab_width = SANE_TAB_WIDTH (current_buffer); |
| 736 | int ctl_arrow = !NILP (current_buffer->ctl_arrow); | 727 | int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
| 737 | register struct Lisp_Char_Table *dp = buffer_display_table (); | 728 | register struct Lisp_Char_Table *dp = buffer_display_table (); |
| 738 | int b, e; | 729 | int b, e; |
| @@ -808,7 +799,7 @@ The return value is COLUMN. */) | |||
| 808 | { | 799 | { |
| 809 | EMACS_INT mincol; | 800 | EMACS_INT mincol; |
| 810 | register EMACS_INT fromcol; | 801 | register EMACS_INT fromcol; |
| 811 | int tab_width = sane_tab_width (); | 802 | int tab_width = SANE_TAB_WIDTH (current_buffer); |
| 812 | 803 | ||
| 813 | CHECK_NUMBER (column); | 804 | CHECK_NUMBER (column); |
| 814 | if (NILP (minimum)) | 805 | if (NILP (minimum)) |
| @@ -867,7 +858,7 @@ static EMACS_INT | |||
| 867 | position_indentation (register int pos_byte) | 858 | position_indentation (register int pos_byte) |
| 868 | { | 859 | { |
| 869 | register EMACS_INT column = 0; | 860 | register EMACS_INT column = 0; |
| 870 | int tab_width = sane_tab_width (); | 861 | int tab_width = SANE_TAB_WIDTH (current_buffer); |
| 871 | register unsigned char *p; | 862 | register unsigned char *p; |
| 872 | register unsigned char *stop; | 863 | register unsigned char *stop; |
| 873 | unsigned char *start; | 864 | unsigned char *start; |
| @@ -1116,7 +1107,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_ | |||
| 1116 | register EMACS_INT pos; | 1107 | register EMACS_INT pos; |
| 1117 | EMACS_INT pos_byte; | 1108 | EMACS_INT pos_byte; |
| 1118 | register int c = 0; | 1109 | register int c = 0; |
| 1119 | int tab_width = sane_tab_width (); | 1110 | int tab_width = SANE_TAB_WIDTH (current_buffer); |
| 1120 | register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); | 1111 | register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); |
| 1121 | register struct Lisp_Char_Table *dp = window_display_table (win); | 1112 | register struct Lisp_Char_Table *dp = window_display_table (win); |
| 1122 | EMACS_INT selective | 1113 | EMACS_INT selective |
| @@ -1432,7 +1423,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_ | |||
| 1432 | the text character-by-character. */ | 1423 | the text character-by-character. */ |
| 1433 | if (current_buffer->width_run_cache && pos >= next_width_run) | 1424 | if (current_buffer->width_run_cache && pos >= next_width_run) |
| 1434 | { | 1425 | { |
| 1435 | EMACS_INT run_end; | 1426 | ptrdiff_t run_end; |
| 1436 | int common_width | 1427 | int common_width |
| 1437 | = region_cache_forward (current_buffer, | 1428 | = region_cache_forward (current_buffer, |
| 1438 | current_buffer->width_run_cache, | 1429 | current_buffer->width_run_cache, |
| @@ -2135,7 +2126,7 @@ whether or not it is currently displayed in some window. */) | |||
| 2135 | } | 2126 | } |
| 2136 | 2127 | ||
| 2137 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 2128 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 2138 | bidi_unshelve_cache (itdata); | 2129 | bidi_unshelve_cache (itdata, 0); |
| 2139 | } | 2130 | } |
| 2140 | 2131 | ||
| 2141 | if (BUFFERP (old_buffer)) | 2132 | if (BUFFERP (old_buffer)) |
diff --git a/src/keyboard.c b/src/keyboard.c index 7e144b80a09..ab93e0ccd24 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 44 | #include "process.h" | 44 | #include "process.h" |
| 45 | #include <errno.h> | 45 | #include <errno.h> |
| 46 | 46 | ||
| 47 | #ifdef HAVE_GTK_AND_PTHREAD | 47 | #ifdef HAVE_PTHREAD |
| 48 | #include <pthread.h> | 48 | #include <pthread.h> |
| 49 | #endif | 49 | #endif |
| 50 | #ifdef MSDOS | 50 | #ifdef MSDOS |
| @@ -435,16 +435,16 @@ static void (*keyboard_init_hook) (void); | |||
| 435 | static int read_avail_input (int); | 435 | static int read_avail_input (int); |
| 436 | static void get_input_pending (int *, int); | 436 | static void get_input_pending (int *, int); |
| 437 | static int readable_events (int); | 437 | static int readable_events (int); |
| 438 | static Lisp_Object read_char_x_menu_prompt (int, Lisp_Object *, | 438 | static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, |
| 439 | Lisp_Object, int *); | 439 | Lisp_Object, int *); |
| 440 | static Lisp_Object read_char_minibuf_menu_prompt (int, int, | 440 | static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t, |
| 441 | Lisp_Object *); | 441 | Lisp_Object *); |
| 442 | static Lisp_Object make_lispy_event (struct input_event *); | 442 | static Lisp_Object make_lispy_event (struct input_event *); |
| 443 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | 443 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
| 444 | static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, | 444 | static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, |
| 445 | enum scroll_bar_part, | 445 | enum scroll_bar_part, |
| 446 | Lisp_Object, Lisp_Object, | 446 | Lisp_Object, Lisp_Object, |
| 447 | unsigned long); | 447 | Time); |
| 448 | #endif | 448 | #endif |
| 449 | static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object, | 449 | static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object, |
| 450 | Lisp_Object, const char *const *, | 450 | Lisp_Object, const char *const *, |
| @@ -1300,7 +1300,7 @@ some_mouse_moved (void) | |||
| 1300 | /* This is the actual command reading loop, | 1300 | /* This is the actual command reading loop, |
| 1301 | sans error-handling encapsulation. */ | 1301 | sans error-handling encapsulation. */ |
| 1302 | 1302 | ||
| 1303 | static int read_key_sequence (Lisp_Object *, size_t, Lisp_Object, | 1303 | static int read_key_sequence (Lisp_Object *, int, Lisp_Object, |
| 1304 | int, int, int); | 1304 | int, int, int); |
| 1305 | void safe_run_hooks (Lisp_Object); | 1305 | void safe_run_hooks (Lisp_Object); |
| 1306 | static void adjust_point_for_property (EMACS_INT, int); | 1306 | static void adjust_point_for_property (EMACS_INT, int); |
| @@ -2267,7 +2267,8 @@ do { if (polling_stopped_here) start_polling (); \ | |||
| 2267 | Value is t if we showed a menu and the user rejected it. */ | 2267 | Value is t if we showed a menu and the user rejected it. */ |
| 2268 | 2268 | ||
| 2269 | Lisp_Object | 2269 | Lisp_Object |
| 2270 | read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event, | 2270 | read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, |
| 2271 | Lisp_Object prev_event, | ||
| 2271 | int *used_mouse_menu, struct timeval *end_time) | 2272 | int *used_mouse_menu, struct timeval *end_time) |
| 2272 | { | 2273 | { |
| 2273 | volatile Lisp_Object c; | 2274 | volatile Lisp_Object c; |
| @@ -7405,7 +7406,7 @@ menu_bar_items (Lisp_Object old) | |||
| 7405 | { | 7406 | { |
| 7406 | /* The number of keymaps we're scanning right now, and the number of | 7407 | /* The number of keymaps we're scanning right now, and the number of |
| 7407 | keymaps we have allocated space for. */ | 7408 | keymaps we have allocated space for. */ |
| 7408 | int nmaps; | 7409 | ptrdiff_t nmaps; |
| 7409 | 7410 | ||
| 7410 | /* maps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] | 7411 | /* maps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] |
| 7411 | in the current keymaps, or nil where it is not a prefix. */ | 7412 | in the current keymaps, or nil where it is not a prefix. */ |
| @@ -7413,7 +7414,7 @@ menu_bar_items (Lisp_Object old) | |||
| 7413 | 7414 | ||
| 7414 | Lisp_Object def, tail; | 7415 | Lisp_Object def, tail; |
| 7415 | 7416 | ||
| 7416 | int mapno; | 7417 | ptrdiff_t mapno; |
| 7417 | Lisp_Object oquit; | 7418 | Lisp_Object oquit; |
| 7418 | 7419 | ||
| 7419 | /* In order to build the menus, we need to call the keymap | 7420 | /* In order to build the menus, we need to call the keymap |
| @@ -7458,7 +7459,7 @@ menu_bar_items (Lisp_Object old) | |||
| 7458 | recognized when the menu-bar (or mode-line) is updated, | 7459 | recognized when the menu-bar (or mode-line) is updated, |
| 7459 | which does not normally happen after every command. */ | 7460 | which does not normally happen after every command. */ |
| 7460 | Lisp_Object tem; | 7461 | Lisp_Object tem; |
| 7461 | int nminor; | 7462 | ptrdiff_t nminor; |
| 7462 | nminor = current_minor_maps (NULL, &tmaps); | 7463 | nminor = current_minor_maps (NULL, &tmaps); |
| 7463 | maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); | 7464 | maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); |
| 7464 | nmaps = 0; | 7465 | nmaps = 0; |
| @@ -7962,7 +7963,7 @@ Lisp_Object | |||
| 7962 | tool_bar_items (Lisp_Object reuse, int *nitems) | 7963 | tool_bar_items (Lisp_Object reuse, int *nitems) |
| 7963 | { | 7964 | { |
| 7964 | Lisp_Object *maps; | 7965 | Lisp_Object *maps; |
| 7965 | int nmaps, i; | 7966 | ptrdiff_t nmaps, i; |
| 7966 | Lisp_Object oquit; | 7967 | Lisp_Object oquit; |
| 7967 | Lisp_Object *tmaps; | 7968 | Lisp_Object *tmaps; |
| 7968 | 7969 | ||
| @@ -8002,7 +8003,7 @@ tool_bar_items (Lisp_Object reuse, int *nitems) | |||
| 8002 | recognized when the tool-bar (or mode-line) is updated, | 8003 | recognized when the tool-bar (or mode-line) is updated, |
| 8003 | which does not normally happen after every command. */ | 8004 | which does not normally happen after every command. */ |
| 8004 | Lisp_Object tem; | 8005 | Lisp_Object tem; |
| 8005 | int nminor; | 8006 | ptrdiff_t nminor; |
| 8006 | nminor = current_minor_maps (NULL, &tmaps); | 8007 | nminor = current_minor_maps (NULL, &tmaps); |
| 8007 | maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); | 8008 | maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); |
| 8008 | nmaps = 0; | 8009 | nmaps = 0; |
| @@ -8274,10 +8275,11 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item) | |||
| 8274 | Lisp_Object tcapt = PROP (TOOL_BAR_ITEM_CAPTION); | 8275 | Lisp_Object tcapt = PROP (TOOL_BAR_ITEM_CAPTION); |
| 8275 | const char *label = SYMBOLP (tkey) ? SSDATA (SYMBOL_NAME (tkey)) : ""; | 8276 | const char *label = SYMBOLP (tkey) ? SSDATA (SYMBOL_NAME (tkey)) : ""; |
| 8276 | const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : ""; | 8277 | const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : ""; |
| 8277 | EMACS_INT max_lbl = 2 * tool_bar_max_label_size; | 8278 | ptrdiff_t max_lbl = |
| 8279 | 2 * max (0, min (tool_bar_max_label_size, STRING_BYTES_BOUND / 2)); | ||
| 8278 | char *buf = (char *) xmalloc (max_lbl + 1); | 8280 | char *buf = (char *) xmalloc (max_lbl + 1); |
| 8279 | Lisp_Object new_lbl; | 8281 | Lisp_Object new_lbl; |
| 8280 | size_t caption_len = strlen (capt); | 8282 | ptrdiff_t caption_len = strlen (capt); |
| 8281 | 8283 | ||
| 8282 | if (caption_len <= max_lbl && capt[0] != '\0') | 8284 | if (caption_len <= max_lbl && capt[0] != '\0') |
| 8283 | { | 8285 | { |
| @@ -8290,7 +8292,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item) | |||
| 8290 | 8292 | ||
| 8291 | if (strlen (label) <= max_lbl && label[0] != '\0') | 8293 | if (strlen (label) <= max_lbl && label[0] != '\0') |
| 8292 | { | 8294 | { |
| 8293 | int j; | 8295 | ptrdiff_t j; |
| 8294 | if (label != buf) | 8296 | if (label != buf) |
| 8295 | strcpy (buf, label); | 8297 | strcpy (buf, label); |
| 8296 | 8298 | ||
| @@ -8399,10 +8401,10 @@ append_tool_bar_item (void) | |||
| 8399 | and do auto-saving in the inner call of read_char. */ | 8401 | and do auto-saving in the inner call of read_char. */ |
| 8400 | 8402 | ||
| 8401 | static Lisp_Object | 8403 | static Lisp_Object |
| 8402 | read_char_x_menu_prompt (int nmaps, Lisp_Object *maps, Lisp_Object prev_event, | 8404 | read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, |
| 8403 | int *used_mouse_menu) | 8405 | Lisp_Object prev_event, int *used_mouse_menu) |
| 8404 | { | 8406 | { |
| 8405 | int mapno; | 8407 | ptrdiff_t mapno; |
| 8406 | 8408 | ||
| 8407 | if (used_mouse_menu) | 8409 | if (used_mouse_menu) |
| 8408 | *used_mouse_menu = 0; | 8410 | *used_mouse_menu = 0; |
| @@ -8430,7 +8432,7 @@ read_char_x_menu_prompt (int nmaps, Lisp_Object *maps, Lisp_Object prev_event, | |||
| 8430 | Lisp_Object *realmaps | 8432 | Lisp_Object *realmaps |
| 8431 | = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); | 8433 | = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); |
| 8432 | Lisp_Object value; | 8434 | Lisp_Object value; |
| 8433 | int nmaps1 = 0; | 8435 | ptrdiff_t nmaps1 = 0; |
| 8434 | 8436 | ||
| 8435 | /* Use the maps that are not nil. */ | 8437 | /* Use the maps that are not nil. */ |
| 8436 | for (mapno = 0; mapno < nmaps; mapno++) | 8438 | for (mapno = 0; mapno < nmaps; mapno++) |
| @@ -8481,17 +8483,18 @@ read_char_x_menu_prompt (int nmaps, Lisp_Object *maps, Lisp_Object prev_event, | |||
| 8481 | We make this bigger when necessary, and never free it. */ | 8483 | We make this bigger when necessary, and never free it. */ |
| 8482 | static char *read_char_minibuf_menu_text; | 8484 | static char *read_char_minibuf_menu_text; |
| 8483 | /* Size of that buffer. */ | 8485 | /* Size of that buffer. */ |
| 8484 | static int read_char_minibuf_menu_width; | 8486 | static ptrdiff_t read_char_minibuf_menu_width; |
| 8485 | 8487 | ||
| 8486 | static Lisp_Object | 8488 | static Lisp_Object |
| 8487 | read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) | 8489 | read_char_minibuf_menu_prompt (int commandflag, |
| 8490 | ptrdiff_t nmaps, Lisp_Object *maps) | ||
| 8488 | { | 8491 | { |
| 8489 | int mapno; | 8492 | ptrdiff_t mapno; |
| 8490 | register Lisp_Object name; | 8493 | register Lisp_Object name; |
| 8491 | int nlength; | 8494 | ptrdiff_t nlength; |
| 8492 | /* FIXME: Use the minibuffer's frame width. */ | 8495 | /* FIXME: Use the minibuffer's frame width. */ |
| 8493 | int width = FRAME_COLS (SELECTED_FRAME ()) - 4; | 8496 | ptrdiff_t width = FRAME_COLS (SELECTED_FRAME ()) - 4; |
| 8494 | int idx = -1; | 8497 | ptrdiff_t idx = -1; |
| 8495 | int nobindings = 1; | 8498 | int nobindings = 1; |
| 8496 | Lisp_Object rest, vector; | 8499 | Lisp_Object rest, vector; |
| 8497 | char *menu; | 8500 | char *menu; |
| @@ -8516,16 +8519,13 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) | |||
| 8516 | 8519 | ||
| 8517 | /* Make sure we have a big enough buffer for the menu text. */ | 8520 | /* Make sure we have a big enough buffer for the menu text. */ |
| 8518 | width = max (width, SBYTES (name)); | 8521 | width = max (width, SBYTES (name)); |
| 8519 | if (read_char_minibuf_menu_text == 0) | 8522 | if (STRING_BYTES_BOUND - 4 < width) |
| 8523 | memory_full (SIZE_MAX); | ||
| 8524 | if (width + 4 > read_char_minibuf_menu_width) | ||
| 8520 | { | 8525 | { |
| 8521 | read_char_minibuf_menu_width = width + 4; | ||
| 8522 | read_char_minibuf_menu_text = (char *) xmalloc (width + 4); | ||
| 8523 | } | ||
| 8524 | else if (width + 4 > read_char_minibuf_menu_width) | ||
| 8525 | { | ||
| 8526 | read_char_minibuf_menu_width = width + 4; | ||
| 8527 | read_char_minibuf_menu_text | 8526 | read_char_minibuf_menu_text |
| 8528 | = (char *) xrealloc (read_char_minibuf_menu_text, width + 4); | 8527 | = (char *) xrealloc (read_char_minibuf_menu_text, width + 4); |
| 8528 | read_char_minibuf_menu_width = width + 4; | ||
| 8529 | } | 8529 | } |
| 8530 | menu = read_char_minibuf_menu_text; | 8530 | menu = read_char_minibuf_menu_text; |
| 8531 | 8531 | ||
| @@ -8544,7 +8544,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) | |||
| 8544 | while (1) | 8544 | while (1) |
| 8545 | { | 8545 | { |
| 8546 | int notfirst = 0; | 8546 | int notfirst = 0; |
| 8547 | int i = nlength; | 8547 | ptrdiff_t i = nlength; |
| 8548 | Lisp_Object obj; | 8548 | Lisp_Object obj; |
| 8549 | Lisp_Object orig_defn_macro; | 8549 | Lisp_Object orig_defn_macro; |
| 8550 | 8550 | ||
| @@ -8643,7 +8643,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) | |||
| 8643 | < width | 8643 | < width |
| 8644 | || !notfirst) | 8644 | || !notfirst) |
| 8645 | { | 8645 | { |
| 8646 | int thiswidth; | 8646 | ptrdiff_t thiswidth; |
| 8647 | 8647 | ||
| 8648 | /* Punctuate between strings. */ | 8648 | /* Punctuate between strings. */ |
| 8649 | if (notfirst) | 8649 | if (notfirst) |
| @@ -8659,9 +8659,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) | |||
| 8659 | if (! char_matches) | 8659 | if (! char_matches) |
| 8660 | { | 8660 | { |
| 8661 | /* Add as much of string as fits. */ | 8661 | /* Add as much of string as fits. */ |
| 8662 | thiswidth = SCHARS (desc); | 8662 | thiswidth = min (SCHARS (desc), width - i); |
| 8663 | if (thiswidth + i > width) | ||
| 8664 | thiswidth = width - i; | ||
| 8665 | memcpy (menu + i, SDATA (desc), thiswidth); | 8663 | memcpy (menu + i, SDATA (desc), thiswidth); |
| 8666 | i += thiswidth; | 8664 | i += thiswidth; |
| 8667 | strcpy (menu + i, " = "); | 8665 | strcpy (menu + i, " = "); |
| @@ -8669,9 +8667,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) | |||
| 8669 | } | 8667 | } |
| 8670 | 8668 | ||
| 8671 | /* Add as much of string as fits. */ | 8669 | /* Add as much of string as fits. */ |
| 8672 | thiswidth = SCHARS (s); | 8670 | thiswidth = min (SCHARS (s), width - i); |
| 8673 | if (thiswidth + i > width) | ||
| 8674 | thiswidth = width - i; | ||
| 8675 | memcpy (menu + i, SDATA (s), thiswidth); | 8671 | memcpy (menu + i, SDATA (s), thiswidth); |
| 8676 | i += thiswidth; | 8672 | i += thiswidth; |
| 8677 | menu[i] = 0; | 8673 | menu[i] = 0; |
| @@ -8746,10 +8742,10 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) | |||
| 8746 | NEXT may be the same array as CURRENT. */ | 8742 | NEXT may be the same array as CURRENT. */ |
| 8747 | 8743 | ||
| 8748 | static int | 8744 | static int |
| 8749 | follow_key (Lisp_Object key, int nmaps, Lisp_Object *current, Lisp_Object *defs, | 8745 | follow_key (Lisp_Object key, ptrdiff_t nmaps, Lisp_Object *current, |
| 8750 | Lisp_Object *next) | 8746 | Lisp_Object *defs, Lisp_Object *next) |
| 8751 | { | 8747 | { |
| 8752 | int i, first_binding; | 8748 | ptrdiff_t i, first_binding; |
| 8753 | 8749 | ||
| 8754 | first_binding = nmaps; | 8750 | first_binding = nmaps; |
| 8755 | for (i = nmaps - 1; i >= 0; i--) | 8751 | for (i = nmaps - 1; i >= 0; i--) |
| @@ -8849,7 +8845,7 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, | |||
| 8849 | The return value is non-zero if the remapping actually took place. */ | 8845 | The return value is non-zero if the remapping actually took place. */ |
| 8850 | 8846 | ||
| 8851 | static int | 8847 | static int |
| 8852 | keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey, | 8848 | keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, |
| 8853 | int input, int doit, int *diff, Lisp_Object prompt) | 8849 | int input, int doit, int *diff, Lisp_Object prompt) |
| 8854 | { | 8850 | { |
| 8855 | Lisp_Object next, key; | 8851 | Lisp_Object next, key; |
| @@ -8871,7 +8867,7 @@ keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey, | |||
| 8871 | 8867 | ||
| 8872 | *diff = len - (fkey->end - fkey->start); | 8868 | *diff = len - (fkey->end - fkey->start); |
| 8873 | 8869 | ||
| 8874 | if (input + *diff >= bufsize) | 8870 | if (bufsize - input <= *diff) |
| 8875 | error ("Key sequence too long"); | 8871 | error ("Key sequence too long"); |
| 8876 | 8872 | ||
| 8877 | /* Shift the keys that follow fkey->end. */ | 8873 | /* Shift the keys that follow fkey->end. */ |
| @@ -8942,7 +8938,7 @@ keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey, | |||
| 8942 | from the selected window's buffer. */ | 8938 | from the selected window's buffer. */ |
| 8943 | 8939 | ||
| 8944 | static int | 8940 | static int |
| 8945 | read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | 8941 | read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, |
| 8946 | int dont_downcase_last, int can_return_switch_frame, | 8942 | int dont_downcase_last, int can_return_switch_frame, |
| 8947 | int fix_current_buffer) | 8943 | int fix_current_buffer) |
| 8948 | { | 8944 | { |
| @@ -8959,8 +8955,8 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | |||
| 8959 | 8955 | ||
| 8960 | /* The number of keymaps we're scanning right now, and the number of | 8956 | /* The number of keymaps we're scanning right now, and the number of |
| 8961 | keymaps we have allocated space for. */ | 8957 | keymaps we have allocated space for. */ |
| 8962 | int nmaps; | 8958 | ptrdiff_t nmaps; |
| 8963 | int nmaps_allocated = 0; | 8959 | ptrdiff_t nmaps_allocated = 0; |
| 8964 | 8960 | ||
| 8965 | /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in | 8961 | /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in |
| 8966 | the current keymaps. */ | 8962 | the current keymaps. */ |
| @@ -8984,7 +8980,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | |||
| 8984 | /* The index in submaps[] of the first keymap that has a binding for | 8980 | /* The index in submaps[] of the first keymap that has a binding for |
| 8985 | this key sequence. In other words, the lowest i such that | 8981 | this key sequence. In other words, the lowest i such that |
| 8986 | submaps[i] is non-nil. */ | 8982 | submaps[i] is non-nil. */ |
| 8987 | int first_binding; | 8983 | ptrdiff_t first_binding; |
| 8988 | /* Index of the first key that has no binding. | 8984 | /* Index of the first key that has no binding. |
| 8989 | It is useless to try fkey.start larger than that. */ | 8985 | It is useless to try fkey.start larger than that. */ |
| 8990 | int first_unbound; | 8986 | int first_unbound; |
| @@ -9145,8 +9141,8 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | |||
| 9145 | } | 9141 | } |
| 9146 | else | 9142 | else |
| 9147 | { | 9143 | { |
| 9148 | int nminor; | 9144 | ptrdiff_t nminor; |
| 9149 | int total; | 9145 | ptrdiff_t total; |
| 9150 | Lisp_Object *maps; | 9146 | Lisp_Object *maps; |
| 9151 | 9147 | ||
| 9152 | nminor = current_minor_maps (0, &maps); | 9148 | nminor = current_minor_maps (0, &maps); |
| @@ -9212,7 +9208,8 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | |||
| 9212 | echo_local_start and keys_local_start allow us to throw away | 9208 | echo_local_start and keys_local_start allow us to throw away |
| 9213 | just one key. */ | 9209 | just one key. */ |
| 9214 | int echo_local_start IF_LINT (= 0); | 9210 | int echo_local_start IF_LINT (= 0); |
| 9215 | int keys_local_start, local_first_binding; | 9211 | int keys_local_start; |
| 9212 | ptrdiff_t local_first_binding; | ||
| 9216 | 9213 | ||
| 9217 | eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); | 9214 | eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); |
| 9218 | eassert (indec.start <= indec.end); | 9215 | eassert (indec.start <= indec.end); |
| @@ -9549,7 +9546,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | |||
| 9549 | && (NILP (fake_prefixed_keys) | 9546 | && (NILP (fake_prefixed_keys) |
| 9550 | || NILP (Fmemq (key, fake_prefixed_keys)))) | 9547 | || NILP (Fmemq (key, fake_prefixed_keys)))) |
| 9551 | { | 9548 | { |
| 9552 | if (t + 1 >= bufsize) | 9549 | if (bufsize - t <= 1) |
| 9553 | error ("Key sequence too long"); | 9550 | error ("Key sequence too long"); |
| 9554 | 9551 | ||
| 9555 | keybuf[t] = posn; | 9552 | keybuf[t] = posn; |
| @@ -9630,7 +9627,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, | |||
| 9630 | insert the dummy prefix event `menu-bar'. */ | 9627 | insert the dummy prefix event `menu-bar'. */ |
| 9631 | if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) | 9628 | if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) |
| 9632 | { | 9629 | { |
| 9633 | if (t + 1 >= bufsize) | 9630 | if (bufsize - t <= 1) |
| 9634 | error ("Key sequence too long"); | 9631 | error ("Key sequence too long"); |
| 9635 | keybuf[t] = posn; | 9632 | keybuf[t] = posn; |
| 9636 | keybuf[t+1] = key; | 9633 | keybuf[t+1] = key; |
diff --git a/src/keyboard.h b/src/keyboard.h index 69c804c873d..d4339d0529b 100644 --- a/src/keyboard.h +++ b/src/keyboard.h | |||
| @@ -440,7 +440,7 @@ struct input_event; | |||
| 440 | 440 | ||
| 441 | extern Lisp_Object parse_modifiers (Lisp_Object); | 441 | extern Lisp_Object parse_modifiers (Lisp_Object); |
| 442 | extern Lisp_Object reorder_modifiers (Lisp_Object); | 442 | extern Lisp_Object reorder_modifiers (Lisp_Object); |
| 443 | extern Lisp_Object read_char (int, int, Lisp_Object *, Lisp_Object, | 443 | extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object, |
| 444 | int *, EMACS_TIME *); | 444 | int *, EMACS_TIME *); |
| 445 | extern int parse_solitary_modifier (Lisp_Object symbol); | 445 | extern int parse_solitary_modifier (Lisp_Object symbol); |
| 446 | 446 | ||
diff --git a/src/keymap.c b/src/keymap.c index 0169276bef9..32b531daac4 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -150,17 +150,6 @@ in case you use it as a menu with `x-popup-menu'. */) | |||
| 150 | return Fcons (Qkeymap, Qnil); | 150 | return Fcons (Qkeymap, Qnil); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | DEFUN ("make-composed-keymap", Fmake_composed_keymap, Smake_composed_keymap, | ||
| 154 | 0, MANY, 0, | ||
| 155 | doc: /* Construct and return a new keymap composed of KEYMAPS. | ||
| 156 | When looking up a key in the returned map, the key is looked in each | ||
| 157 | keymap in turn until a binding is found. | ||
| 158 | usage: (make-composed-keymap &rest KEYMAPS) */) | ||
| 159 | (ptrdiff_t nargs, Lisp_Object *args) | ||
| 160 | { | ||
| 161 | return Fcons (Qkeymap, Flist (nargs, args)); | ||
| 162 | } | ||
| 163 | |||
| 164 | /* This function is used for installing the standard key bindings | 153 | /* This function is used for installing the standard key bindings |
| 165 | at initialization time. | 154 | at initialization time. |
| 166 | 155 | ||
| @@ -1216,13 +1205,20 @@ binding KEY to DEF is added at the front of KEYMAP. */) | |||
| 1216 | 1205 | ||
| 1217 | keymap = get_keymap (cmd, 0, 1); | 1206 | keymap = get_keymap (cmd, 0, 1); |
| 1218 | if (!CONSP (keymap)) | 1207 | if (!CONSP (keymap)) |
| 1219 | /* We must use Fkey_description rather than just passing key to | 1208 | { |
| 1220 | error; key might be a vector, not a string. */ | 1209 | const char *trailing_esc = ((EQ (c, meta_prefix_char) && metized) |
| 1221 | error ("Key sequence %s starts with non-prefix key %s", | 1210 | ? (idx == 0 ? "ESC" : " ESC") |
| 1222 | SDATA (Fkey_description (key, Qnil)), | 1211 | : ""); |
| 1223 | SDATA (Fkey_description (Fsubstring (key, make_number (0), | 1212 | |
| 1224 | make_number (idx)), | 1213 | /* We must use Fkey_description rather than just passing key to |
| 1225 | Qnil))); | 1214 | error; key might be a vector, not a string. */ |
| 1215 | error ("Key sequence %s starts with non-prefix key %s%s", | ||
| 1216 | SDATA (Fkey_description (key, Qnil)), | ||
| 1217 | SDATA (Fkey_description (Fsubstring (key, make_number (0), | ||
| 1218 | make_number (idx)), | ||
| 1219 | Qnil)), | ||
| 1220 | trailing_esc); | ||
| 1221 | } | ||
| 1226 | } | 1222 | } |
| 1227 | } | 1223 | } |
| 1228 | 1224 | ||
| @@ -1403,7 +1399,7 @@ silly_event_symbol_error (Lisp_Object c) | |||
| 1403 | some systems, static gets macro-defined to be the empty string. | 1399 | some systems, static gets macro-defined to be the empty string. |
| 1404 | Ickypoo. */ | 1400 | Ickypoo. */ |
| 1405 | static Lisp_Object *cmm_modes = NULL, *cmm_maps = NULL; | 1401 | static Lisp_Object *cmm_modes = NULL, *cmm_maps = NULL; |
| 1406 | static int cmm_size = 0; | 1402 | static ptrdiff_t cmm_size = 0; |
| 1407 | 1403 | ||
| 1408 | /* Store a pointer to an array of the currently active minor modes in | 1404 | /* Store a pointer to an array of the currently active minor modes in |
| 1409 | *modeptr, a pointer to an array of the keymaps of the currently | 1405 | *modeptr, a pointer to an array of the keymaps of the currently |
| @@ -1423,10 +1419,10 @@ static int cmm_size = 0; | |||
| 1423 | loop. Instead, we'll use realloc/malloc and silently truncate the | 1419 | loop. Instead, we'll use realloc/malloc and silently truncate the |
| 1424 | list, let the key sequence be read, and hope some other piece of | 1420 | list, let the key sequence be read, and hope some other piece of |
| 1425 | code signals the error. */ | 1421 | code signals the error. */ |
| 1426 | int | 1422 | ptrdiff_t |
| 1427 | current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | 1423 | current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) |
| 1428 | { | 1424 | { |
| 1429 | int i = 0; | 1425 | ptrdiff_t i = 0; |
| 1430 | int list_number = 0; | 1426 | int list_number = 0; |
| 1431 | Lisp_Object alist, assoc, var, val; | 1427 | Lisp_Object alist, assoc, var, val; |
| 1432 | Lisp_Object emulation_alists; | 1428 | Lisp_Object emulation_alists; |
| @@ -1469,9 +1465,16 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | |||
| 1469 | 1465 | ||
| 1470 | if (i >= cmm_size) | 1466 | if (i >= cmm_size) |
| 1471 | { | 1467 | { |
| 1472 | int newsize, allocsize; | 1468 | ptrdiff_t newsize, allocsize; |
| 1473 | Lisp_Object *newmodes, *newmaps; | 1469 | Lisp_Object *newmodes, *newmaps; |
| 1474 | 1470 | ||
| 1471 | /* Check for size calculation overflow. Other code | ||
| 1472 | (e.g., read_key_sequence) adds 3 to the count | ||
| 1473 | later, so subtract 3 from the limit here. */ | ||
| 1474 | if (min (PTRDIFF_MAX, SIZE_MAX) / (2 * sizeof *newmodes) - 3 | ||
| 1475 | < cmm_size) | ||
| 1476 | break; | ||
| 1477 | |||
| 1475 | newsize = cmm_size == 0 ? 30 : cmm_size * 2; | 1478 | newsize = cmm_size == 0 ? 30 : cmm_size * 2; |
| 1476 | allocsize = newsize * sizeof *newmodes; | 1479 | allocsize = newsize * sizeof *newmodes; |
| 1477 | 1480 | ||
| @@ -3754,7 +3757,6 @@ be preferred. */); | |||
| 3754 | defsubr (&Sset_keymap_parent); | 3757 | defsubr (&Sset_keymap_parent); |
| 3755 | defsubr (&Smake_keymap); | 3758 | defsubr (&Smake_keymap); |
| 3756 | defsubr (&Smake_sparse_keymap); | 3759 | defsubr (&Smake_sparse_keymap); |
| 3757 | defsubr (&Smake_composed_keymap); | ||
| 3758 | defsubr (&Smap_keymap_internal); | 3760 | defsubr (&Smap_keymap_internal); |
| 3759 | defsubr (&Smap_keymap); | 3761 | defsubr (&Smap_keymap); |
| 3760 | defsubr (&Scopy_keymap); | 3762 | defsubr (&Scopy_keymap); |
diff --git a/src/keymap.h b/src/keymap.h index 2c826b64e1f..ec9d4cadbb1 100644 --- a/src/keymap.h +++ b/src/keymap.h | |||
| @@ -38,7 +38,7 @@ extern Lisp_Object get_keymap (Lisp_Object, int, int); | |||
| 38 | EXFUN (Fset_keymap_parent, 2); | 38 | EXFUN (Fset_keymap_parent, 2); |
| 39 | extern int describe_map_tree (Lisp_Object, int, Lisp_Object, Lisp_Object, | 39 | extern int describe_map_tree (Lisp_Object, int, Lisp_Object, Lisp_Object, |
| 40 | const char *, int, int, int, int); | 40 | const char *, int, int, int, int); |
| 41 | extern int current_minor_maps (Lisp_Object **, Lisp_Object **); | 41 | extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **); |
| 42 | extern void initial_define_key (Lisp_Object, int, const char *); | 42 | extern void initial_define_key (Lisp_Object, int, const char *); |
| 43 | extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); | 43 | extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); |
| 44 | extern void syms_of_keymap (void); | 44 | extern void syms_of_keymap (void); |
diff --git a/src/lisp.h b/src/lisp.h index 1e141dbb5d0..99555118047 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1704,6 +1704,11 @@ typedef struct { | |||
| 1704 | #define NUMBERP(x) (INTEGERP (x) || FLOATP (x)) | 1704 | #define NUMBERP(x) (INTEGERP (x) || FLOATP (x)) |
| 1705 | #define NATNUMP(x) (INTEGERP (x) && XINT (x) >= 0) | 1705 | #define NATNUMP(x) (INTEGERP (x) && XINT (x) >= 0) |
| 1706 | 1706 | ||
| 1707 | #define RANGED_INTEGERP(lo, x, hi) \ | ||
| 1708 | (INTEGERP (x) && (lo) <= XINT (x) && XINT (x) <= (hi)) | ||
| 1709 | #define TYPE_RANGED_INTEGERP(type, x) \ | ||
| 1710 | RANGED_INTEGERP (TYPE_MINIMUM (type), x, TYPE_MAXIMUM (type)) | ||
| 1711 | |||
| 1707 | #define INTEGERP(x) (LISP_INT_TAG_P (XTYPE ((x)))) | 1712 | #define INTEGERP(x) (LISP_INT_TAG_P (XTYPE ((x)))) |
| 1708 | #define SYMBOLP(x) (XTYPE ((x)) == Lisp_Symbol) | 1713 | #define SYMBOLP(x) (XTYPE ((x)) == Lisp_Symbol) |
| 1709 | #define MISCP(x) (XTYPE ((x)) == Lisp_Misc) | 1714 | #define MISCP(x) (XTYPE ((x)) == Lisp_Misc) |
| @@ -2551,6 +2556,7 @@ extern void syms_of_syntax (void); | |||
| 2551 | 2556 | ||
| 2552 | /* Defined in fns.c */ | 2557 | /* Defined in fns.c */ |
| 2553 | extern Lisp_Object QCrehash_size, QCrehash_threshold; | 2558 | extern Lisp_Object QCrehash_size, QCrehash_threshold; |
| 2559 | enum { NEXT_ALMOST_PRIME_LIMIT = 11 }; | ||
| 2554 | extern EMACS_INT next_almost_prime (EMACS_INT); | 2560 | extern EMACS_INT next_almost_prime (EMACS_INT); |
| 2555 | extern Lisp_Object larger_vector (Lisp_Object, EMACS_INT, Lisp_Object); | 2561 | extern Lisp_Object larger_vector (Lisp_Object, EMACS_INT, Lisp_Object); |
| 2556 | extern void sweep_weak_hash_tables (void); | 2562 | extern void sweep_weak_hash_tables (void); |
| @@ -2562,8 +2568,8 @@ EMACS_UINT sxhash (Lisp_Object, int); | |||
| 2562 | Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object, | 2568 | Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object, |
| 2563 | Lisp_Object, Lisp_Object, Lisp_Object, | 2569 | Lisp_Object, Lisp_Object, Lisp_Object, |
| 2564 | Lisp_Object); | 2570 | Lisp_Object); |
| 2565 | EMACS_INT hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); | 2571 | ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); |
| 2566 | EMACS_INT hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, | 2572 | ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, |
| 2567 | EMACS_UINT); | 2573 | EMACS_UINT); |
| 2568 | void init_weak_hash_tables (void); | 2574 | void init_weak_hash_tables (void); |
| 2569 | extern void init_fns (void); | 2575 | extern void init_fns (void); |
| @@ -2861,6 +2867,7 @@ extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Ob | |||
| 2861 | Lisp_Object, Lisp_Object, | 2867 | Lisp_Object, Lisp_Object, |
| 2862 | Lisp_Object, struct charset *, | 2868 | Lisp_Object, struct charset *, |
| 2863 | unsigned, unsigned); | 2869 | unsigned, unsigned); |
| 2870 | extern Lisp_Object uniprop_table (Lisp_Object); | ||
| 2864 | extern void syms_of_chartab (void); | 2871 | extern void syms_of_chartab (void); |
| 2865 | 2872 | ||
| 2866 | /* Defined in print.c */ | 2873 | /* Defined in print.c */ |
| @@ -3568,6 +3575,9 @@ extern int immediate_quit; /* Nonzero means ^G can quit instantly */ | |||
| 3568 | extern POINTER_TYPE *xmalloc (size_t); | 3575 | extern POINTER_TYPE *xmalloc (size_t); |
| 3569 | extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); | 3576 | extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); |
| 3570 | extern void xfree (POINTER_TYPE *); | 3577 | extern void xfree (POINTER_TYPE *); |
| 3578 | extern void *xnmalloc (ptrdiff_t, ptrdiff_t); | ||
| 3579 | extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t); | ||
| 3580 | extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t); | ||
| 3571 | 3581 | ||
| 3572 | extern char *xstrdup (const char *); | 3582 | extern char *xstrdup (const char *); |
| 3573 | 3583 | ||
| @@ -3685,6 +3695,23 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3685 | } \ | 3695 | } \ |
| 3686 | } while (0) | 3696 | } while (0) |
| 3687 | 3697 | ||
| 3698 | /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * | ||
| 3699 | NITEMS items, each of the same type as *BUF. MULTIPLIER must | ||
| 3700 | positive. The code is tuned for MULTIPLIER being a constant. */ | ||
| 3701 | |||
| 3702 | #define SAFE_NALLOCA(buf, multiplier, nitems) \ | ||
| 3703 | do { \ | ||
| 3704 | if ((nitems) <= MAX_ALLOCA / sizeof *(buf) / (multiplier)) \ | ||
| 3705 | (buf) = alloca (sizeof *(buf) * (multiplier) * (nitems)); \ | ||
| 3706 | else \ | ||
| 3707 | { \ | ||
| 3708 | (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \ | ||
| 3709 | sa_must_free = 1; \ | ||
| 3710 | record_unwind_protect (safe_alloca_unwind, \ | ||
| 3711 | make_save_value (buf, 0)); \ | ||
| 3712 | } \ | ||
| 3713 | } while (0) | ||
| 3714 | |||
| 3688 | /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ | 3715 | /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ |
| 3689 | 3716 | ||
| 3690 | #define SAFE_FREE() \ | 3717 | #define SAFE_FREE() \ |
diff --git a/src/lread.c b/src/lread.c index 78ff195e990..d24da729df6 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1124,6 +1124,22 @@ Return t if the file exists and loads successfully. */) | |||
| 1124 | handler = Ffind_file_name_handler (found, Qload); | 1124 | handler = Ffind_file_name_handler (found, Qload); |
| 1125 | if (! NILP (handler)) | 1125 | if (! NILP (handler)) |
| 1126 | return call5 (handler, Qload, found, noerror, nomessage, Qt); | 1126 | return call5 (handler, Qload, found, noerror, nomessage, Qt); |
| 1127 | #ifdef DOS_NT | ||
| 1128 | /* Tramp has to deal with semi-broken packages that prepend | ||
| 1129 | drive letters to remote files. For that reason, Tramp | ||
| 1130 | catches file operations that test for file existence, which | ||
| 1131 | makes openp think X:/foo.elc files are remote. However, | ||
| 1132 | Tramp does not catch `load' operations for such files, so we | ||
| 1133 | end up with a nil as the `load' handler above. If we would | ||
| 1134 | continue with fd = -2, we will behave wrongly, and in | ||
| 1135 | particular try reading a .elc file in the "rt" mode instead | ||
| 1136 | of "rb". See bug #9311 for the results. To work around | ||
| 1137 | this, we try to open the file locally, and go with that if it | ||
| 1138 | succeeds. */ | ||
| 1139 | fd = emacs_open (SSDATA (ENCODE_FILE (found)), O_RDONLY, 0); | ||
| 1140 | if (fd == -1) | ||
| 1141 | fd = -2; | ||
| 1142 | #endif | ||
| 1127 | } | 1143 | } |
| 1128 | 1144 | ||
| 1129 | /* Check if we're stuck in a recursive load cycle. | 1145 | /* Check if we're stuck in a recursive load cycle. |
| @@ -1247,9 +1263,17 @@ Return t if the file exists and loads successfully. */) | |||
| 1247 | GCPRO3 (file, found, hist_file_name); | 1263 | GCPRO3 (file, found, hist_file_name); |
| 1248 | 1264 | ||
| 1249 | #ifdef WINDOWSNT | 1265 | #ifdef WINDOWSNT |
| 1250 | emacs_close (fd); | ||
| 1251 | efound = ENCODE_FILE (found); | 1266 | efound = ENCODE_FILE (found); |
| 1252 | stream = fopen (SSDATA (efound), fmode); | 1267 | /* If we somehow got here with fd == -2, meaning the file is deemed |
| 1268 | to be remote, don't even try to reopen the file locally; just | ||
| 1269 | force a failure instead. */ | ||
| 1270 | if (fd >= 0) | ||
| 1271 | { | ||
| 1272 | emacs_close (fd); | ||
| 1273 | stream = fopen (SSDATA (efound), fmode); | ||
| 1274 | } | ||
| 1275 | else | ||
| 1276 | stream = NULL; | ||
| 1253 | #else /* not WINDOWSNT */ | 1277 | #else /* not WINDOWSNT */ |
| 1254 | stream = fdopen (fd, fmode); | 1278 | stream = fdopen (fd, fmode); |
| 1255 | #endif /* not WINDOWSNT */ | 1279 | #endif /* not WINDOWSNT */ |
| @@ -2613,14 +2637,14 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2613 | 2637 | ||
| 2614 | if (saved_doc_string_size == 0) | 2638 | if (saved_doc_string_size == 0) |
| 2615 | { | 2639 | { |
| 2640 | saved_doc_string = (char *) xmalloc (nskip + extra); | ||
| 2616 | saved_doc_string_size = nskip + extra; | 2641 | saved_doc_string_size = nskip + extra; |
| 2617 | saved_doc_string = (char *) xmalloc (saved_doc_string_size); | ||
| 2618 | } | 2642 | } |
| 2619 | if (nskip > saved_doc_string_size) | 2643 | if (nskip > saved_doc_string_size) |
| 2620 | { | 2644 | { |
| 2621 | saved_doc_string_size = nskip + extra; | ||
| 2622 | saved_doc_string = (char *) xrealloc (saved_doc_string, | 2645 | saved_doc_string = (char *) xrealloc (saved_doc_string, |
| 2623 | saved_doc_string_size); | 2646 | nskip + extra); |
| 2647 | saved_doc_string_size = nskip + extra; | ||
| 2624 | } | 2648 | } |
| 2625 | 2649 | ||
| 2626 | saved_doc_string_position = file_tell (instream); | 2650 | saved_doc_string_position = file_tell (instream); |
| @@ -2883,7 +2907,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2883 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 2907 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 2884 | memory_full (SIZE_MAX); | 2908 | memory_full (SIZE_MAX); |
| 2885 | read_buffer = (char *) xrealloc (read_buffer, | 2909 | read_buffer = (char *) xrealloc (read_buffer, |
| 2886 | read_buffer_size *= 2); | 2910 | read_buffer_size * 2); |
| 2911 | read_buffer_size *= 2; | ||
| 2887 | p = read_buffer + offset; | 2912 | p = read_buffer + offset; |
| 2888 | end = read_buffer + read_buffer_size; | 2913 | end = read_buffer + read_buffer_size; |
| 2889 | } | 2914 | } |
| @@ -3026,7 +3051,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3026 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3051 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3027 | memory_full (SIZE_MAX); | 3052 | memory_full (SIZE_MAX); |
| 3028 | read_buffer = (char *) xrealloc (read_buffer, | 3053 | read_buffer = (char *) xrealloc (read_buffer, |
| 3029 | read_buffer_size *= 2); | 3054 | read_buffer_size * 2); |
| 3055 | read_buffer_size *= 2; | ||
| 3030 | p = read_buffer + offset; | 3056 | p = read_buffer + offset; |
| 3031 | end = read_buffer + read_buffer_size; | 3057 | end = read_buffer + read_buffer_size; |
| 3032 | } | 3058 | } |
| @@ -3056,7 +3082,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3056 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3082 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3057 | memory_full (SIZE_MAX); | 3083 | memory_full (SIZE_MAX); |
| 3058 | read_buffer = (char *) xrealloc (read_buffer, | 3084 | read_buffer = (char *) xrealloc (read_buffer, |
| 3059 | read_buffer_size *= 2); | 3085 | read_buffer_size * 2); |
| 3086 | read_buffer_size *= 2; | ||
| 3060 | p = read_buffer + offset; | 3087 | p = read_buffer + offset; |
| 3061 | end = read_buffer + read_buffer_size; | 3088 | end = read_buffer + read_buffer_size; |
| 3062 | } | 3089 | } |
| @@ -3938,6 +3965,7 @@ void | |||
| 3938 | init_obarray (void) | 3965 | init_obarray (void) |
| 3939 | { | 3966 | { |
| 3940 | Lisp_Object oblength; | 3967 | Lisp_Object oblength; |
| 3968 | ptrdiff_t size = 100 + MAX_MULTIBYTE_LENGTH; | ||
| 3941 | 3969 | ||
| 3942 | XSETFASTINT (oblength, OBARRAY_SIZE); | 3970 | XSETFASTINT (oblength, OBARRAY_SIZE); |
| 3943 | 3971 | ||
| @@ -3970,8 +3998,8 @@ init_obarray (void) | |||
| 3970 | 3998 | ||
| 3971 | DEFSYM (Qvariable_documentation, "variable-documentation"); | 3999 | DEFSYM (Qvariable_documentation, "variable-documentation"); |
| 3972 | 4000 | ||
| 3973 | read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH; | 4001 | read_buffer = (char *) xmalloc (size); |
| 3974 | read_buffer = (char *) xmalloc (read_buffer_size); | 4002 | read_buffer_size = size; |
| 3975 | } | 4003 | } |
| 3976 | 4004 | ||
| 3977 | void | 4005 | void |
diff --git a/src/macros.c b/src/macros.c index 60f30c3fbbe..f6cd3a3ccad 100644 --- a/src/macros.c +++ b/src/macros.c | |||
| @@ -62,9 +62,9 @@ macro before appending to it. */) | |||
| 62 | 62 | ||
| 63 | if (!current_kboard->kbd_macro_buffer) | 63 | if (!current_kboard->kbd_macro_buffer) |
| 64 | { | 64 | { |
| 65 | current_kboard->kbd_macro_bufsize = 30; | ||
| 66 | current_kboard->kbd_macro_buffer | 65 | current_kboard->kbd_macro_buffer |
| 67 | = (Lisp_Object *)xmalloc (30 * sizeof (Lisp_Object)); | 66 | = (Lisp_Object *)xmalloc (30 * sizeof (Lisp_Object)); |
| 67 | current_kboard->kbd_macro_bufsize = 30; | ||
| 68 | } | 68 | } |
| 69 | update_mode_lines++; | 69 | update_mode_lines++; |
| 70 | if (NILP (append)) | 70 | if (NILP (append)) |
| @@ -202,7 +202,7 @@ store_kbd_macro_char (Lisp_Object c) | |||
| 202 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *kb->kbd_macro_buffer / 2 | 202 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *kb->kbd_macro_buffer / 2 |
| 203 | < kb->kbd_macro_bufsize) | 203 | < kb->kbd_macro_bufsize) |
| 204 | memory_full (SIZE_MAX); | 204 | memory_full (SIZE_MAX); |
| 205 | nbytes = kb->kbd_macro_bufsize * 2 * sizeof *kb->kbd_macro_buffer; | 205 | nbytes = kb->kbd_macro_bufsize * (2 * sizeof *kb->kbd_macro_buffer); |
| 206 | kb->kbd_macro_buffer | 206 | kb->kbd_macro_buffer |
| 207 | = (Lisp_Object *) xrealloc (kb->kbd_macro_buffer, nbytes); | 207 | = (Lisp_Object *) xrealloc (kb->kbd_macro_buffer, nbytes); |
| 208 | kb->kbd_macro_bufsize *= 2; | 208 | kb->kbd_macro_bufsize *= 2; |
diff --git a/src/makefile.w32-in b/src/makefile.w32-in index fd29dec9096..53cb5f857ab 100644 --- a/src/makefile.w32-in +++ b/src/makefile.w32-in | |||
| @@ -469,6 +469,7 @@ $(BLD)/alloc.$(O) : \ | |||
| 469 | $(SRC)/syssignal.h \ | 469 | $(SRC)/syssignal.h \ |
| 470 | $(SRC)/w32.h \ | 470 | $(SRC)/w32.h \ |
| 471 | $(NT_INC)/unistd.h \ | 471 | $(NT_INC)/unistd.h \ |
| 472 | $(GNU_LIB)/verify.h \ | ||
| 472 | $(BLOCKINPUT_H) \ | 473 | $(BLOCKINPUT_H) \ |
| 473 | $(CHARACTER_H) \ | 474 | $(CHARACTER_H) \ |
| 474 | $(CONFIG_H) \ | 475 | $(CONFIG_H) \ |
| @@ -493,8 +494,6 @@ $(BLD)/atimer.$(O) : \ | |||
| 493 | 494 | ||
| 494 | $(BLD)/bidi.$(O) : \ | 495 | $(BLD)/bidi.$(O) : \ |
| 495 | $(SRC)/bidi.c \ | 496 | $(SRC)/bidi.c \ |
| 496 | $(SRC)/bidimirror.h \ | ||
| 497 | $(SRC)/biditype.h \ | ||
| 498 | $(SRC)/buffer.h \ | 497 | $(SRC)/buffer.h \ |
| 499 | $(CHARACTER_H) \ | 498 | $(CHARACTER_H) \ |
| 500 | $(CONFIG_H) \ | 499 | $(CONFIG_H) \ |
diff --git a/src/minibuf.c b/src/minibuf.c index 7e59cf157b5..eb564a10ec6 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -1723,7 +1723,7 @@ the values STRING, PREDICATE and `lambda'. */) | |||
| 1723 | (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate) | 1723 | (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate) |
| 1724 | { | 1724 | { |
| 1725 | Lisp_Object regexps, tail, tem = Qnil; | 1725 | Lisp_Object regexps, tail, tem = Qnil; |
| 1726 | EMACS_INT i = 0; | 1726 | ptrdiff_t i = 0; |
| 1727 | 1727 | ||
| 1728 | CHECK_STRING (string); | 1728 | CHECK_STRING (string); |
| 1729 | 1729 | ||
diff --git a/src/nsfns.m b/src/nsfns.m index 85246a4c25f..a09011d8461 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -97,6 +97,9 @@ Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object); | |||
| 97 | 97 | ||
| 98 | extern BOOL ns_in_resize; | 98 | extern BOOL ns_in_resize; |
| 99 | 99 | ||
| 100 | /* Static variables to handle applescript execution. */ | ||
| 101 | static Lisp_Object as_script, *as_result; | ||
| 102 | static int as_status; | ||
| 100 | 103 | ||
| 101 | /* ========================================================================== | 104 | /* ========================================================================== |
| 102 | 105 | ||
| @@ -2052,6 +2055,15 @@ ns_do_applescript (Lisp_Object script, Lisp_Object *result) | |||
| 2052 | return 0; | 2055 | return 0; |
| 2053 | } | 2056 | } |
| 2054 | 2057 | ||
| 2058 | /* Helper function called from sendEvent to run applescript | ||
| 2059 | from within the main event loop. */ | ||
| 2060 | |||
| 2061 | void | ||
| 2062 | ns_run_ascript (void) | ||
| 2063 | { | ||
| 2064 | as_status = ns_do_applescript (as_script, as_result); | ||
| 2065 | } | ||
| 2066 | |||
| 2055 | DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0, | 2067 | DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0, |
| 2056 | doc: /* Execute AppleScript SCRIPT and return the result. | 2068 | doc: /* Execute AppleScript SCRIPT and return the result. |
| 2057 | If compilation and execution are successful, the resulting script value | 2069 | If compilation and execution are successful, the resulting script value |
| @@ -2061,12 +2073,37 @@ In case the execution fails, an error is signaled. */) | |||
| 2061 | { | 2073 | { |
| 2062 | Lisp_Object result; | 2074 | Lisp_Object result; |
| 2063 | int status; | 2075 | int status; |
| 2076 | NSEvent *nxev; | ||
| 2064 | 2077 | ||
| 2065 | CHECK_STRING (script); | 2078 | CHECK_STRING (script); |
| 2066 | check_ns (); | 2079 | check_ns (); |
| 2067 | 2080 | ||
| 2068 | BLOCK_INPUT; | 2081 | BLOCK_INPUT; |
| 2069 | status = ns_do_applescript (script, &result); | 2082 | |
| 2083 | as_script = script; | ||
| 2084 | as_result = &result; | ||
| 2085 | |||
| 2086 | /* executing apple script requires the event loop to run, otherwise | ||
| 2087 | errors aren't returned and executeAndReturnError hangs forever. | ||
| 2088 | Post an event that runs applescript and then start the event loop. | ||
| 2089 | The event loop is exited when the script is done. */ | ||
| 2090 | nxev = [NSEvent otherEventWithType: NSApplicationDefined | ||
| 2091 | location: NSMakePoint (0, 0) | ||
| 2092 | modifierFlags: 0 | ||
| 2093 | timestamp: 0 | ||
| 2094 | windowNumber: [[NSApp mainWindow] windowNumber] | ||
| 2095 | context: [NSApp context] | ||
| 2096 | subtype: 0 | ||
| 2097 | data1: 0 | ||
| 2098 | data2: NSAPP_DATA2_RUNASSCRIPT]; | ||
| 2099 | |||
| 2100 | [NSApp postEvent: nxev atStart: NO]; | ||
| 2101 | [NSApp run]; | ||
| 2102 | |||
| 2103 | status = as_status; | ||
| 2104 | as_status = 0; | ||
| 2105 | as_script = Qnil; | ||
| 2106 | as_result = 0; | ||
| 2070 | UNBLOCK_INPUT; | 2107 | UNBLOCK_INPUT; |
| 2071 | if (status == 0) | 2108 | if (status == 0) |
| 2072 | return result; | 2109 | return result; |
| @@ -2670,4 +2707,7 @@ be used as the image of the icon representing the frame. */); | |||
| 2670 | /* used only in fontset.c */ | 2707 | /* used only in fontset.c */ |
| 2671 | check_window_system_func = check_ns; | 2708 | check_window_system_func = check_ns; |
| 2672 | 2709 | ||
| 2710 | as_status = 0; | ||
| 2711 | as_script = Qnil; | ||
| 2712 | as_result = 0; | ||
| 2673 | } | 2713 | } |
diff --git a/src/nsfont.m b/src/nsfont.m index 60f8c5321aa..c4d9123faef 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -303,7 +303,7 @@ static NSString | |||
| 303 | { | 303 | { |
| 304 | Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist); | 304 | Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist); |
| 305 | return CONSP (script) | 305 | return CONSP (script) |
| 306 | ? [NSString stringWithUTF8String: SDATA (SYMBOL_NAME XCDR ((script)))] | 306 | ? [NSString stringWithUTF8String: SDATA (SYMBOL_NAME (XCDR ((script))))] |
| 307 | : @""; | 307 | : @""; |
| 308 | } | 308 | } |
| 309 | 309 | ||
diff --git a/src/nsmenu.m b/src/nsmenu.m index 6bde229ed4d..951282910ac 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -1014,7 +1014,7 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1014 | BOOL enabled_p = !NILP (TOOLPROP (TOOL_BAR_ITEM_ENABLED_P)); | 1014 | BOOL enabled_p = !NILP (TOOLPROP (TOOL_BAR_ITEM_ENABLED_P)); |
| 1015 | BOOL selected_p = !NILP (TOOLPROP (TOOL_BAR_ITEM_SELECTED_P)); | 1015 | BOOL selected_p = !NILP (TOOLPROP (TOOL_BAR_ITEM_SELECTED_P)); |
| 1016 | int idx; | 1016 | int idx; |
| 1017 | int img_id; | 1017 | ptrdiff_t img_id; |
| 1018 | struct image *img; | 1018 | struct image *img; |
| 1019 | Lisp_Object image; | 1019 | Lisp_Object image; |
| 1020 | Lisp_Object helpObj; | 1020 | Lisp_Object helpObj; |
diff --git a/src/nsterm.h b/src/nsterm.h index 6ea9161c922..188ec732e82 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -416,8 +416,8 @@ struct ns_bitmap_record | |||
| 416 | /* this to map between emacs color indices and NSColor objects */ | 416 | /* this to map between emacs color indices and NSColor objects */ |
| 417 | struct ns_color_table | 417 | struct ns_color_table |
| 418 | { | 418 | { |
| 419 | unsigned int size; | 419 | ptrdiff_t size; |
| 420 | unsigned int avail; | 420 | ptrdiff_t avail; |
| 421 | #ifdef __OBJC__ | 421 | #ifdef __OBJC__ |
| 422 | NSColor **colors; | 422 | NSColor **colors; |
| 423 | NSMutableSet *empty_indices; | 423 | NSMutableSet *empty_indices; |
| @@ -795,6 +795,9 @@ extern void x_set_tool_bar_lines (struct frame *f, | |||
| 795 | extern void x_activate_menubar (struct frame *); | 795 | extern void x_activate_menubar (struct frame *); |
| 796 | extern void free_frame_menubar (struct frame *); | 796 | extern void free_frame_menubar (struct frame *); |
| 797 | 797 | ||
| 798 | #define NSAPP_DATA2_RUNASSCRIPT 10 | ||
| 799 | extern void ns_run_ascript (void); | ||
| 800 | |||
| 798 | extern void ns_init_paths (void); | 801 | extern void ns_init_paths (void); |
| 799 | extern void syms_of_nsterm (void); | 802 | extern void syms_of_nsterm (void); |
| 800 | extern void syms_of_nsfns (void); | 803 | extern void syms_of_nsfns (void); |
diff --git a/src/nsterm.m b/src/nsterm.m index d4b1a3f8473..4c9574c35ba 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1341,7 +1341,7 @@ unsigned long | |||
| 1341 | ns_index_color (NSColor *color, struct frame *f) | 1341 | ns_index_color (NSColor *color, struct frame *f) |
| 1342 | { | 1342 | { |
| 1343 | struct ns_color_table *color_table = FRAME_NS_DISPLAY_INFO (f)->color_table; | 1343 | struct ns_color_table *color_table = FRAME_NS_DISPLAY_INFO (f)->color_table; |
| 1344 | int idx; | 1344 | ptrdiff_t idx; |
| 1345 | NSNumber *index; | 1345 | NSNumber *index; |
| 1346 | 1346 | ||
| 1347 | if (!color_table->colors) | 1347 | if (!color_table->colors) |
| @@ -1356,7 +1356,7 @@ ns_index_color (NSColor *color, struct frame *f) | |||
| 1356 | 1356 | ||
| 1357 | /* do we already have this color ? */ | 1357 | /* do we already have this color ? */ |
| 1358 | { | 1358 | { |
| 1359 | int i; | 1359 | ptrdiff_t i; |
| 1360 | for (i = 1; i < color_table->avail; i++) | 1360 | for (i = 1; i < color_table->avail; i++) |
| 1361 | { | 1361 | { |
| 1362 | if (color_table->colors[i] && [color_table->colors[i] isEqual: color]) | 1362 | if (color_table->colors[i] && [color_table->colors[i] isEqual: color]) |
| @@ -1371,17 +1371,14 @@ ns_index_color (NSColor *color, struct frame *f) | |||
| 1371 | { | 1371 | { |
| 1372 | index = [color_table->empty_indices anyObject]; | 1372 | index = [color_table->empty_indices anyObject]; |
| 1373 | [color_table->empty_indices removeObject: index]; | 1373 | [color_table->empty_indices removeObject: index]; |
| 1374 | idx = [index unsignedIntValue]; | 1374 | idx = [index unsignedLongValue]; |
| 1375 | } | 1375 | } |
| 1376 | else | 1376 | else |
| 1377 | { | 1377 | { |
| 1378 | if (color_table->avail == color_table->size) | 1378 | if (color_table->avail == color_table->size) |
| 1379 | { | 1379 | color_table->colors = |
| 1380 | color_table->size += NS_COLOR_CAPACITY; | 1380 | xpalloc (color_table->colors, &color_table->size, 1, |
| 1381 | color_table->colors | 1381 | min (ULONG_MAX, PTRDIFF_MAX), sizeof *color_table->colors); |
| 1382 | = (NSColor **)xrealloc (color_table->colors, | ||
| 1383 | color_table->size * sizeof (NSColor *)); | ||
| 1384 | } | ||
| 1385 | idx = color_table->avail++; | 1382 | idx = color_table->avail++; |
| 1386 | } | 1383 | } |
| 1387 | 1384 | ||
| @@ -2321,7 +2318,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, | |||
| 2321 | if (!img) | 2318 | if (!img) |
| 2322 | { | 2319 | { |
| 2323 | unsigned short *bits = p->bits + p->dh; | 2320 | unsigned short *bits = p->bits + p->dh; |
| 2324 | int len = 8 * p->h/8; | 2321 | int len = p->h; |
| 2325 | int i; | 2322 | int i; |
| 2326 | unsigned char *cbits = xmalloc (len); | 2323 | unsigned char *cbits = xmalloc (len); |
| 2327 | 2324 | ||
| @@ -4257,6 +4254,16 @@ ns_term_shutdown (int sig) | |||
| 4257 | /* NSTRACE (sendEvent); */ | 4254 | /* NSTRACE (sendEvent); */ |
| 4258 | /*fprintf (stderr, "received event of type %d\t%d\n", type);*/ | 4255 | /*fprintf (stderr, "received event of type %d\t%d\n", type);*/ |
| 4259 | 4256 | ||
| 4257 | #ifdef NS_IMPL_COCOA | ||
| 4258 | if (type == NSApplicationDefined | ||
| 4259 | && [theEvent data2] == NSAPP_DATA2_RUNASSCRIPT) | ||
| 4260 | { | ||
| 4261 | ns_run_ascript (); | ||
| 4262 | [self stop: self]; | ||
| 4263 | return; | ||
| 4264 | } | ||
| 4265 | #endif | ||
| 4266 | |||
| 4260 | if (type == NSCursorUpdate && window == nil) | 4267 | if (type == NSCursorUpdate && window == nil) |
| 4261 | { | 4268 | { |
| 4262 | fprintf (stderr, "Dropping external cursor update event.\n"); | 4269 | fprintf (stderr, "Dropping external cursor update event.\n"); |
| @@ -4857,7 +4864,7 @@ ns_term_shutdown (int sig) | |||
| 4857 | } | 4864 | } |
| 4858 | } | 4865 | } |
| 4859 | 4866 | ||
| 4860 | 4867 | ||
| 4861 | #if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | 4868 | #if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 |
| 4862 | /* if we get here we should send the key for input manager processing */ | 4869 | /* if we get here we should send the key for input manager processing */ |
| 4863 | if (firstTime && [[NSInputManager currentInputManager] | 4870 | if (firstTime && [[NSInputManager currentInputManager] |
diff --git a/src/process.c b/src/process.c index 236c27e5c3a..a8088322147 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -58,6 +58,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 58 | #include <net/if.h> | 58 | #include <net/if.h> |
| 59 | #endif /* HAVE_NET_IF_H */ | 59 | #endif /* HAVE_NET_IF_H */ |
| 60 | 60 | ||
| 61 | #if defined(HAVE_IFADDRS_H) | ||
| 62 | /* Must be after net/if.h */ | ||
| 63 | #include <ifaddrs.h> | ||
| 64 | |||
| 65 | /* We only use structs from this header when we use getifaddrs. */ | ||
| 66 | #if defined(HAVE_NET_IF_DL_H) | ||
| 67 | #include <net/if_dl.h> | ||
| 68 | #endif | ||
| 69 | |||
| 70 | #endif | ||
| 71 | |||
| 61 | #ifdef NEED_BSDTTY | 72 | #ifdef NEED_BSDTTY |
| 62 | #include <bsdtty.h> | 73 | #include <bsdtty.h> |
| 63 | #endif | 74 | #endif |
| @@ -1632,7 +1643,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1632 | 1643 | ||
| 1633 | XPROCESS (process)->pty_flag = pty_flag; | 1644 | XPROCESS (process)->pty_flag = pty_flag; |
| 1634 | XPROCESS (process)->status = Qrun; | 1645 | XPROCESS (process)->status = Qrun; |
| 1635 | setup_process_coding_systems (process); | ||
| 1636 | 1646 | ||
| 1637 | /* Delay interrupts until we have a chance to store | 1647 | /* Delay interrupts until we have a chance to store |
| 1638 | the new fork's pid in its process structure */ | 1648 | the new fork's pid in its process structure */ |
| @@ -1667,6 +1677,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1667 | processes to get their return values scrambled. */ | 1677 | processes to get their return values scrambled. */ |
| 1668 | XPROCESS (process)->pid = -1; | 1678 | XPROCESS (process)->pid = -1; |
| 1669 | 1679 | ||
| 1680 | /* This must be called after the above line because it may signal an | ||
| 1681 | error. */ | ||
| 1682 | setup_process_coding_systems (process); | ||
| 1683 | |||
| 1670 | BLOCK_INPUT; | 1684 | BLOCK_INPUT; |
| 1671 | 1685 | ||
| 1672 | { | 1686 | { |
| @@ -3557,46 +3571,53 @@ format; see the description of ADDRESS in `make-network-process'. */) | |||
| 3557 | (void) | 3571 | (void) |
| 3558 | { | 3572 | { |
| 3559 | struct ifconf ifconf; | 3573 | struct ifconf ifconf; |
| 3560 | struct ifreq *ifreqs = NULL; | 3574 | struct ifreq *ifreq; |
| 3561 | int ifaces = 0; | 3575 | void *buf = NULL; |
| 3562 | int buf_size, s; | 3576 | ptrdiff_t buf_size = 512; |
| 3577 | int s, i; | ||
| 3563 | Lisp_Object res; | 3578 | Lisp_Object res; |
| 3564 | 3579 | ||
| 3565 | s = socket (AF_INET, SOCK_STREAM, 0); | 3580 | s = socket (AF_INET, SOCK_STREAM, 0); |
| 3566 | if (s < 0) | 3581 | if (s < 0) |
| 3567 | return Qnil; | 3582 | return Qnil; |
| 3568 | 3583 | ||
| 3569 | again: | 3584 | do |
| 3570 | ifaces += 25; | ||
| 3571 | buf_size = ifaces * sizeof (ifreqs[0]); | ||
| 3572 | ifreqs = (struct ifreq *)xrealloc(ifreqs, buf_size); | ||
| 3573 | if (!ifreqs) | ||
| 3574 | { | 3585 | { |
| 3575 | close (s); | 3586 | buf = xpalloc (buf, &buf_size, 1, INT_MAX, 1); |
| 3576 | return Qnil; | 3587 | ifconf.ifc_buf = buf; |
| 3577 | } | 3588 | ifconf.ifc_len = buf_size; |
| 3578 | 3589 | if (ioctl (s, SIOCGIFCONF, &ifconf)) | |
| 3579 | ifconf.ifc_len = buf_size; | 3590 | { |
| 3580 | ifconf.ifc_req = ifreqs; | 3591 | close (s); |
| 3581 | if (ioctl (s, SIOCGIFCONF, &ifconf)) | 3592 | xfree (buf); |
| 3582 | { | 3593 | return Qnil; |
| 3583 | close (s); | 3594 | } |
| 3584 | return Qnil; | ||
| 3585 | } | 3595 | } |
| 3586 | 3596 | while (ifconf.ifc_len == buf_size); | |
| 3587 | if (ifconf.ifc_len == buf_size) | ||
| 3588 | goto again; | ||
| 3589 | 3597 | ||
| 3590 | close (s); | 3598 | close (s); |
| 3591 | ifaces = ifconf.ifc_len / sizeof (ifreqs[0]); | ||
| 3592 | 3599 | ||
| 3593 | res = Qnil; | 3600 | res = Qnil; |
| 3594 | while (--ifaces >= 0) | 3601 | ifreq = ifconf.ifc_req; |
| 3602 | while ((char *) ifreq < (char *) ifconf.ifc_req + ifconf.ifc_len) | ||
| 3595 | { | 3603 | { |
| 3596 | struct ifreq *ifq = &ifreqs[ifaces]; | 3604 | struct ifreq *ifq = ifreq; |
| 3605 | #ifdef HAVE_STRUCT_IFREQ_IFR_ADDR_SA_LEN | ||
| 3606 | #define SIZEOF_IFREQ(sif) \ | ||
| 3607 | ((sif)->ifr_addr.sa_len < sizeof (struct sockaddr) \ | ||
| 3608 | ? sizeof (*(sif)) : sizeof ((sif)->ifr_name) + (sif)->ifr_addr.sa_len) | ||
| 3609 | |||
| 3610 | int len = SIZEOF_IFREQ (ifq); | ||
| 3611 | #else | ||
| 3612 | int len = sizeof (*ifreq); | ||
| 3613 | #endif | ||
| 3597 | char namebuf[sizeof (ifq->ifr_name) + 1]; | 3614 | char namebuf[sizeof (ifq->ifr_name) + 1]; |
| 3615 | i += len; | ||
| 3616 | ifreq = (struct ifreq *) ((char *) ifreq + len); | ||
| 3617 | |||
| 3598 | if (ifq->ifr_addr.sa_family != AF_INET) | 3618 | if (ifq->ifr_addr.sa_family != AF_INET) |
| 3599 | continue; | 3619 | continue; |
| 3620 | |||
| 3600 | memcpy (namebuf, ifq->ifr_name, sizeof (ifq->ifr_name)); | 3621 | memcpy (namebuf, ifq->ifr_name, sizeof (ifq->ifr_name)); |
| 3601 | namebuf[sizeof (ifq->ifr_name)] = 0; | 3622 | namebuf[sizeof (ifq->ifr_name)] = 0; |
| 3602 | res = Fcons (Fcons (build_string (namebuf), | 3623 | res = Fcons (Fcons (build_string (namebuf), |
| @@ -3605,6 +3626,7 @@ format; see the description of ADDRESS in `make-network-process'. */) | |||
| 3605 | res); | 3626 | res); |
| 3606 | } | 3627 | } |
| 3607 | 3628 | ||
| 3629 | xfree (buf); | ||
| 3608 | return res; | 3630 | return res; |
| 3609 | } | 3631 | } |
| 3610 | #endif /* SIOCGIFCONF */ | 3632 | #endif /* SIOCGIFCONF */ |
| @@ -3642,8 +3664,13 @@ static const struct ifflag_def ifflag_table[] = { | |||
| 3642 | { IFF_PROMISC, "promisc" }, | 3664 | { IFF_PROMISC, "promisc" }, |
| 3643 | #endif | 3665 | #endif |
| 3644 | #ifdef IFF_NOTRAILERS | 3666 | #ifdef IFF_NOTRAILERS |
| 3667 | #ifdef NS_IMPL_COCOA | ||
| 3668 | /* Really means smart, notrailers is obsolete */ | ||
| 3669 | { IFF_NOTRAILERS, "smart" }, | ||
| 3670 | #else | ||
| 3645 | { IFF_NOTRAILERS, "notrailers" }, | 3671 | { IFF_NOTRAILERS, "notrailers" }, |
| 3646 | #endif | 3672 | #endif |
| 3673 | #endif | ||
| 3647 | #ifdef IFF_ALLMULTI | 3674 | #ifdef IFF_ALLMULTI |
| 3648 | { IFF_ALLMULTI, "allmulti" }, | 3675 | { IFF_ALLMULTI, "allmulti" }, |
| 3649 | #endif | 3676 | #endif |
| @@ -3696,6 +3723,10 @@ FLAGS is the current flags of the interface. */) | |||
| 3696 | Lisp_Object elt; | 3723 | Lisp_Object elt; |
| 3697 | int s; | 3724 | int s; |
| 3698 | int any = 0; | 3725 | int any = 0; |
| 3726 | #if (! (defined SIOCGIFHWADDR && defined HAVE_STRUCT_IFREQ_IFR_HWADDR) \ | ||
| 3727 | && defined HAVE_GETIFADDRS && defined LLADDR) | ||
| 3728 | struct ifaddrs *ifap; | ||
| 3729 | #endif | ||
| 3699 | 3730 | ||
| 3700 | CHECK_STRING (ifname); | 3731 | CHECK_STRING (ifname); |
| 3701 | 3732 | ||
| @@ -3714,6 +3745,12 @@ FLAGS is the current flags of the interface. */) | |||
| 3714 | const struct ifflag_def *fp; | 3745 | const struct ifflag_def *fp; |
| 3715 | int fnum; | 3746 | int fnum; |
| 3716 | 3747 | ||
| 3748 | /* If flags is smaller than int (i.e. short) it may have the high bit set | ||
| 3749 | due to IFF_MULTICAST. In that case, sign extending it into | ||
| 3750 | an int is wrong. */ | ||
| 3751 | if (flags < 0 && sizeof (rq.ifr_flags) < sizeof (flags)) | ||
| 3752 | flags = (unsigned short) rq.ifr_flags; | ||
| 3753 | |||
| 3717 | any = 1; | 3754 | any = 1; |
| 3718 | for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++) | 3755 | for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++) |
| 3719 | { | 3756 | { |
| @@ -3747,7 +3784,38 @@ FLAGS is the current flags of the interface. */) | |||
| 3747 | p->contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]); | 3784 | p->contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]); |
| 3748 | elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr); | 3785 | elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr); |
| 3749 | } | 3786 | } |
| 3787 | #elif defined(HAVE_GETIFADDRS) && defined(LLADDR) | ||
| 3788 | if (getifaddrs (&ifap) != -1) | ||
| 3789 | { | ||
| 3790 | Lisp_Object hwaddr = Fmake_vector (make_number (6), Qnil); | ||
| 3791 | register struct Lisp_Vector *p = XVECTOR (hwaddr); | ||
| 3792 | struct ifaddrs *it; | ||
| 3793 | |||
| 3794 | for (it = ifap; it != NULL; it = it->ifa_next) | ||
| 3795 | { | ||
| 3796 | struct sockaddr_dl *sdl = (struct sockaddr_dl*) it->ifa_addr; | ||
| 3797 | unsigned char linkaddr[6]; | ||
| 3798 | int n; | ||
| 3799 | |||
| 3800 | if (it->ifa_addr->sa_family != AF_LINK | ||
| 3801 | || strcmp (it->ifa_name, SSDATA (ifname)) != 0 | ||
| 3802 | || sdl->sdl_alen != 6) | ||
| 3803 | continue; | ||
| 3804 | |||
| 3805 | memcpy (linkaddr, LLADDR(sdl), sdl->sdl_alen); | ||
| 3806 | for (n = 0; n < 6; n++) | ||
| 3807 | p->contents[n] = make_number (linkaddr[n]); | ||
| 3808 | |||
| 3809 | elt = Fcons (make_number (it->ifa_addr->sa_family), hwaddr); | ||
| 3810 | break; | ||
| 3811 | } | ||
| 3812 | } | ||
| 3813 | #ifdef HAVE_FREEIFADDRS | ||
| 3814 | freeifaddrs (ifap); | ||
| 3750 | #endif | 3815 | #endif |
| 3816 | |||
| 3817 | #endif /* HAVE_GETIFADDRS && LLADDR */ | ||
| 3818 | |||
| 3751 | res = Fcons (elt, res); | 3819 | res = Fcons (elt, res); |
| 3752 | 3820 | ||
| 3753 | elt = Qnil; | 3821 | elt = Qnil; |
| @@ -5093,6 +5161,9 @@ read_process_output (Lisp_Object proc, register int channel) | |||
| 5093 | p->decoding_carryover = coding->carryover_bytes; | 5161 | p->decoding_carryover = coding->carryover_bytes; |
| 5094 | } | 5162 | } |
| 5095 | if (SBYTES (text) > 0) | 5163 | if (SBYTES (text) > 0) |
| 5164 | /* FIXME: It's wrong to wrap or not based on debug-on-error, and | ||
| 5165 | sometimes it's simply wrong to wrap (e.g. when called from | ||
| 5166 | accept-process-output). */ | ||
| 5096 | internal_condition_case_1 (read_process_output_call, | 5167 | internal_condition_case_1 (read_process_output_call, |
| 5097 | Fcons (outstream, | 5168 | Fcons (outstream, |
| 5098 | Fcons (proc, Fcons (text, Qnil))), | 5169 | Fcons (proc, Fcons (text, Qnil))), |
diff --git a/src/regex.c b/src/regex.c index 862f848976c..d1b835621d9 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -2106,9 +2106,9 @@ re_iswctype (int ch, re_wctype_t cc) | |||
| 2106 | case RECC_UPPER: return ISUPPER (ch) != 0; | 2106 | case RECC_UPPER: return ISUPPER (ch) != 0; |
| 2107 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | 2107 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; |
| 2108 | case RECC_ASCII: return IS_REAL_ASCII (ch) != 0; | 2108 | case RECC_ASCII: return IS_REAL_ASCII (ch) != 0; |
| 2109 | case RECC_NONASCII: return !IS_REAL_ASCII (ch) != 0; | 2109 | case RECC_NONASCII: return !IS_REAL_ASCII (ch); |
| 2110 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | 2110 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; |
| 2111 | case RECC_MULTIBYTE: return !ISUNIBYTE (ch) != 0; | 2111 | case RECC_MULTIBYTE: return !ISUNIBYTE (ch); |
| 2112 | case RECC_WORD: return ISWORD (ch) != 0; | 2112 | case RECC_WORD: return ISWORD (ch) != 0; |
| 2113 | case RECC_ERROR: return false; | 2113 | case RECC_ERROR: return false; |
| 2114 | default: | 2114 | default: |
| @@ -6381,8 +6381,7 @@ char * | |||
| 6381 | regcomp/regexec below without link errors. */ | 6381 | regcomp/regexec below without link errors. */ |
| 6382 | weak_function | 6382 | weak_function |
| 6383 | # endif | 6383 | # endif |
| 6384 | re_comp (s) | 6384 | re_comp (const char *s) |
| 6385 | const char *s; | ||
| 6386 | { | 6385 | { |
| 6387 | reg_errcode_t ret; | 6386 | reg_errcode_t ret; |
| 6388 | 6387 | ||
| @@ -6421,7 +6420,7 @@ re_comp (s) | |||
| 6421 | } | 6420 | } |
| 6422 | 6421 | ||
| 6423 | 6422 | ||
| 6424 | regoff_t | 6423 | int |
| 6425 | # ifdef _LIBC | 6424 | # ifdef _LIBC |
| 6426 | weak_function | 6425 | weak_function |
| 6427 | # endif | 6426 | # endif |
| @@ -6558,7 +6557,7 @@ reg_errcode_t | |||
| 6558 | regexec (const regex_t *__restrict preg, const char *__restrict string, | 6557 | regexec (const regex_t *__restrict preg, const char *__restrict string, |
| 6559 | size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) | 6558 | size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) |
| 6560 | { | 6559 | { |
| 6561 | reg_errcode_t ret; | 6560 | regoff_t ret; |
| 6562 | struct re_registers regs; | 6561 | struct re_registers regs; |
| 6563 | regex_t private_preg; | 6562 | regex_t private_preg; |
| 6564 | size_t len = strlen (string); | 6563 | size_t len = strlen (string); |
diff --git a/src/region-cache.c b/src/region-cache.c index d701f4d71b0..ed7a07a6709 100644 --- a/src/region-cache.c +++ b/src/region-cache.c | |||
| @@ -63,7 +63,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 63 | revalidate_region_cache to see how this helps. */ | 63 | revalidate_region_cache to see how this helps. */ |
| 64 | 64 | ||
| 65 | struct boundary { | 65 | struct boundary { |
| 66 | EMACS_INT pos; | 66 | ptrdiff_t pos; |
| 67 | int value; | 67 | int value; |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| @@ -73,16 +73,16 @@ struct region_cache { | |||
| 73 | struct boundary *boundaries; | 73 | struct boundary *boundaries; |
| 74 | 74 | ||
| 75 | /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */ | 75 | /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */ |
| 76 | EMACS_INT gap_start, gap_len; | 76 | ptrdiff_t gap_start, gap_len; |
| 77 | 77 | ||
| 78 | /* The number of elements allocated to boundaries, not including the | 78 | /* The number of elements allocated to boundaries, not including the |
| 79 | gap. */ | 79 | gap. */ |
| 80 | EMACS_INT cache_len; | 80 | ptrdiff_t cache_len; |
| 81 | 81 | ||
| 82 | /* The areas that haven't changed since the last time we cleaned out | 82 | /* The areas that haven't changed since the last time we cleaned out |
| 83 | invalid entries from the cache. These overlap when the buffer is | 83 | invalid entries from the cache. These overlap when the buffer is |
| 84 | entirely unchanged. */ | 84 | entirely unchanged. */ |
| 85 | EMACS_INT beg_unchanged, end_unchanged; | 85 | ptrdiff_t beg_unchanged, end_unchanged; |
| 86 | 86 | ||
| 87 | /* The first and last positions in the buffer. Because boundaries | 87 | /* The first and last positions in the buffer. Because boundaries |
| 88 | store their positions relative to the start (BEG) and end (Z) of | 88 | store their positions relative to the start (BEG) and end (Z) of |
| @@ -92,7 +92,7 @@ struct region_cache { | |||
| 92 | 92 | ||
| 93 | Yes, buffer_beg is always 1. It's there for symmetry with | 93 | Yes, buffer_beg is always 1. It's there for symmetry with |
| 94 | buffer_end and the BEG and BUF_BEG macros. */ | 94 | buffer_end and the BEG and BUF_BEG macros. */ |
| 95 | EMACS_INT buffer_beg, buffer_end; | 95 | ptrdiff_t buffer_beg, buffer_end; |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | /* Return the position of boundary i in cache c. */ | 98 | /* Return the position of boundary i in cache c. */ |
| @@ -173,17 +173,17 @@ free_region_cache (struct region_cache *c) | |||
| 173 | This operation should be logarithmic in the number of cache | 173 | This operation should be logarithmic in the number of cache |
| 174 | entries. It would be nice if it took advantage of locality of | 174 | entries. It would be nice if it took advantage of locality of |
| 175 | reference, too, by searching entries near the last entry found. */ | 175 | reference, too, by searching entries near the last entry found. */ |
| 176 | static EMACS_INT | 176 | static ptrdiff_t |
| 177 | find_cache_boundary (struct region_cache *c, EMACS_INT pos) | 177 | find_cache_boundary (struct region_cache *c, ptrdiff_t pos) |
| 178 | { | 178 | { |
| 179 | EMACS_INT low = 0, high = c->cache_len; | 179 | ptrdiff_t low = 0, high = c->cache_len; |
| 180 | 180 | ||
| 181 | while (low + 1 < high) | 181 | while (low + 1 < high) |
| 182 | { | 182 | { |
| 183 | /* mid is always a valid index, because low < high and ">> 1" | 183 | /* mid is always a valid index, because low < high and ">> 1" |
| 184 | rounds down. */ | 184 | rounds down. */ |
| 185 | EMACS_INT mid = (low + high) >> 1; | 185 | ptrdiff_t mid = (low >> 1) + (high >> 1) + (low & high & 1); |
| 186 | EMACS_INT boundary = BOUNDARY_POS (c, mid); | 186 | ptrdiff_t boundary = BOUNDARY_POS (c, mid); |
| 187 | 187 | ||
| 188 | if (pos < boundary) | 188 | if (pos < boundary) |
| 189 | high = mid; | 189 | high = mid; |
| @@ -208,13 +208,13 @@ find_cache_boundary (struct region_cache *c, EMACS_INT pos) | |||
| 208 | /* Move the gap of cache C to index POS, and make sure it has space | 208 | /* Move the gap of cache C to index POS, and make sure it has space |
| 209 | for at least MIN_SIZE boundaries. */ | 209 | for at least MIN_SIZE boundaries. */ |
| 210 | static void | 210 | static void |
| 211 | move_cache_gap (struct region_cache *c, EMACS_INT pos, EMACS_INT min_size) | 211 | move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size) |
| 212 | { | 212 | { |
| 213 | /* Copy these out of the cache and into registers. */ | 213 | /* Copy these out of the cache and into registers. */ |
| 214 | EMACS_INT gap_start = c->gap_start; | 214 | ptrdiff_t gap_start = c->gap_start; |
| 215 | EMACS_INT gap_len = c->gap_len; | 215 | ptrdiff_t gap_len = c->gap_len; |
| 216 | EMACS_INT buffer_beg = c->buffer_beg; | 216 | ptrdiff_t buffer_beg = c->buffer_beg; |
| 217 | EMACS_INT buffer_end = c->buffer_end; | 217 | ptrdiff_t buffer_end = c->buffer_end; |
| 218 | 218 | ||
| 219 | if (pos < 0 | 219 | if (pos < 0 |
| 220 | || pos > c->cache_len) | 220 | || pos > c->cache_len) |
| @@ -246,17 +246,11 @@ move_cache_gap (struct region_cache *c, EMACS_INT pos, EMACS_INT min_size) | |||
| 246 | when the portion after the gap is smallest. */ | 246 | when the portion after the gap is smallest. */ |
| 247 | if (gap_len < min_size) | 247 | if (gap_len < min_size) |
| 248 | { | 248 | { |
| 249 | EMACS_INT i; | 249 | ptrdiff_t i; |
| 250 | |||
| 251 | /* Always make at least NEW_CACHE_GAP elements, as long as we're | ||
| 252 | expanding anyway. */ | ||
| 253 | if (min_size < NEW_CACHE_GAP) | ||
| 254 | min_size = NEW_CACHE_GAP; | ||
| 255 | 250 | ||
| 256 | c->boundaries = | 251 | c->boundaries = |
| 257 | (struct boundary *) xrealloc (c->boundaries, | 252 | xpalloc (c->boundaries, &c->cache_len, min_size, -1, |
| 258 | ((min_size + c->cache_len) | 253 | sizeof *c->boundaries); |
| 259 | * sizeof (*c->boundaries))); | ||
| 260 | 254 | ||
| 261 | /* Some systems don't provide a version of the copy routine that | 255 | /* Some systems don't provide a version of the copy routine that |
| 262 | can be trusted to shift memory upward into an overlapping | 256 | can be trusted to shift memory upward into an overlapping |
| @@ -293,7 +287,7 @@ move_cache_gap (struct region_cache *c, EMACS_INT pos, EMACS_INT min_size) | |||
| 293 | /* Insert a new boundary in cache C; it will have cache index I, | 287 | /* Insert a new boundary in cache C; it will have cache index I, |
| 294 | and have the specified POS and VALUE. */ | 288 | and have the specified POS and VALUE. */ |
| 295 | static void | 289 | static void |
| 296 | insert_cache_boundary (struct region_cache *c, EMACS_INT i, EMACS_INT pos, | 290 | insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos, |
| 297 | int value) | 291 | int value) |
| 298 | { | 292 | { |
| 299 | /* i must be a valid cache index. */ | 293 | /* i must be a valid cache index. */ |
| @@ -331,9 +325,9 @@ insert_cache_boundary (struct region_cache *c, EMACS_INT i, EMACS_INT pos, | |||
| 331 | 325 | ||
| 332 | static void | 326 | static void |
| 333 | delete_cache_boundaries (struct region_cache *c, | 327 | delete_cache_boundaries (struct region_cache *c, |
| 334 | EMACS_INT start, EMACS_INT end) | 328 | ptrdiff_t start, ptrdiff_t end) |
| 335 | { | 329 | { |
| 336 | EMACS_INT len = end - start; | 330 | ptrdiff_t len = end - start; |
| 337 | 331 | ||
| 338 | /* Gotta be in range. */ | 332 | /* Gotta be in range. */ |
| 339 | if (start < 0 | 333 | if (start < 0 |
| @@ -384,7 +378,7 @@ delete_cache_boundaries (struct region_cache *c, | |||
| 384 | /* Set the value in cache C for the region START..END to VALUE. */ | 378 | /* Set the value in cache C for the region START..END to VALUE. */ |
| 385 | static void | 379 | static void |
| 386 | set_cache_region (struct region_cache *c, | 380 | set_cache_region (struct region_cache *c, |
| 387 | EMACS_INT start, EMACS_INT end, int value) | 381 | ptrdiff_t start, ptrdiff_t end, int value) |
| 388 | { | 382 | { |
| 389 | if (start > end) | 383 | if (start > end) |
| 390 | abort (); | 384 | abort (); |
| @@ -407,8 +401,8 @@ set_cache_region (struct region_cache *c, | |||
| 407 | index of the earliest boundary after the last character in | 401 | index of the earliest boundary after the last character in |
| 408 | start..end. (This tortured terminology is intended to answer | 402 | start..end. (This tortured terminology is intended to answer |
| 409 | all the "< or <=?" sort of questions.) */ | 403 | all the "< or <=?" sort of questions.) */ |
| 410 | EMACS_INT start_ix = find_cache_boundary (c, start); | 404 | ptrdiff_t start_ix = find_cache_boundary (c, start); |
| 411 | EMACS_INT end_ix = find_cache_boundary (c, end - 1) + 1; | 405 | ptrdiff_t end_ix = find_cache_boundary (c, end - 1) + 1; |
| 412 | 406 | ||
| 413 | /* We must remember the value established by the last boundary | 407 | /* We must remember the value established by the last boundary |
| 414 | before end; if that boundary's domain stretches beyond end, | 408 | before end; if that boundary's domain stretches beyond end, |
| @@ -486,7 +480,7 @@ set_cache_region (struct region_cache *c, | |||
| 486 | args to pass are the same before and after such an operation.) */ | 480 | args to pass are the same before and after such an operation.) */ |
| 487 | void | 481 | void |
| 488 | invalidate_region_cache (struct buffer *buf, struct region_cache *c, | 482 | invalidate_region_cache (struct buffer *buf, struct region_cache *c, |
| 489 | EMACS_INT head, EMACS_INT tail) | 483 | ptrdiff_t head, ptrdiff_t tail) |
| 490 | { | 484 | { |
| 491 | /* Let chead = c->beg_unchanged, and | 485 | /* Let chead = c->beg_unchanged, and |
| 492 | ctail = c->end_unchanged. | 486 | ctail = c->end_unchanged. |
| @@ -624,7 +618,7 @@ revalidate_region_cache (struct buffer *buf, struct region_cache *c) | |||
| 624 | corresponds to the modified region of the buffer. */ | 618 | corresponds to the modified region of the buffer. */ |
| 625 | else | 619 | else |
| 626 | { | 620 | { |
| 627 | EMACS_INT modified_ix; | 621 | ptrdiff_t modified_ix; |
| 628 | 622 | ||
| 629 | /* These positions are correct, relative to both the cache basis | 623 | /* These positions are correct, relative to both the cache basis |
| 630 | and the buffer basis. */ | 624 | and the buffer basis. */ |
| @@ -693,7 +687,7 @@ revalidate_region_cache (struct buffer *buf, struct region_cache *c) | |||
| 693 | no newlines", in the case of the line cache). */ | 687 | no newlines", in the case of the line cache). */ |
| 694 | void | 688 | void |
| 695 | know_region_cache (struct buffer *buf, struct region_cache *c, | 689 | know_region_cache (struct buffer *buf, struct region_cache *c, |
| 696 | EMACS_INT start, EMACS_INT end) | 690 | ptrdiff_t start, ptrdiff_t end) |
| 697 | { | 691 | { |
| 698 | revalidate_region_cache (buf, c); | 692 | revalidate_region_cache (buf, c); |
| 699 | 693 | ||
| @@ -708,14 +702,14 @@ know_region_cache (struct buffer *buf, struct region_cache *c, | |||
| 708 | position after POS where the knownness changes. */ | 702 | position after POS where the knownness changes. */ |
| 709 | int | 703 | int |
| 710 | region_cache_forward (struct buffer *buf, struct region_cache *c, | 704 | region_cache_forward (struct buffer *buf, struct region_cache *c, |
| 711 | EMACS_INT pos, EMACS_INT *next) | 705 | ptrdiff_t pos, ptrdiff_t *next) |
| 712 | { | 706 | { |
| 713 | revalidate_region_cache (buf, c); | 707 | revalidate_region_cache (buf, c); |
| 714 | 708 | ||
| 715 | { | 709 | { |
| 716 | EMACS_INT i = find_cache_boundary (c, pos); | 710 | ptrdiff_t i = find_cache_boundary (c, pos); |
| 717 | int i_value = BOUNDARY_VALUE (c, i); | 711 | int i_value = BOUNDARY_VALUE (c, i); |
| 718 | EMACS_INT j; | 712 | ptrdiff_t j; |
| 719 | 713 | ||
| 720 | /* Beyond the end of the buffer is unknown, by definition. */ | 714 | /* Beyond the end of the buffer is unknown, by definition. */ |
| 721 | if (pos >= BUF_Z (buf)) | 715 | if (pos >= BUF_Z (buf)) |
| @@ -744,7 +738,7 @@ region_cache_forward (struct buffer *buf, struct region_cache *c, | |||
| 744 | the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest | 738 | the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest |
| 745 | position before POS where the knownness changes. */ | 739 | position before POS where the knownness changes. */ |
| 746 | int region_cache_backward (struct buffer *buf, struct region_cache *c, | 740 | int region_cache_backward (struct buffer *buf, struct region_cache *c, |
| 747 | EMACS_INT pos, EMACS_INT *next) | 741 | ptrdiff_t pos, ptrdiff_t *next) |
| 748 | { | 742 | { |
| 749 | revalidate_region_cache (buf, c); | 743 | revalidate_region_cache (buf, c); |
| 750 | 744 | ||
| @@ -757,9 +751,9 @@ int region_cache_backward (struct buffer *buf, struct region_cache *c, | |||
| 757 | } | 751 | } |
| 758 | 752 | ||
| 759 | { | 753 | { |
| 760 | EMACS_INT i = find_cache_boundary (c, pos - 1); | 754 | ptrdiff_t i = find_cache_boundary (c, pos - 1); |
| 761 | int i_value = BOUNDARY_VALUE (c, i); | 755 | int i_value = BOUNDARY_VALUE (c, i); |
| 762 | EMACS_INT j; | 756 | ptrdiff_t j; |
| 763 | 757 | ||
| 764 | if (next) | 758 | if (next) |
| 765 | { | 759 | { |
| @@ -785,18 +779,18 @@ void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE; | |||
| 785 | void | 779 | void |
| 786 | pp_cache (struct region_cache *c) | 780 | pp_cache (struct region_cache *c) |
| 787 | { | 781 | { |
| 788 | int i; | 782 | ptrdiff_t i; |
| 789 | EMACS_INT beg_u = c->buffer_beg + c->beg_unchanged; | 783 | ptrdiff_t beg_u = c->buffer_beg + c->beg_unchanged; |
| 790 | EMACS_INT end_u = c->buffer_end - c->end_unchanged; | 784 | ptrdiff_t end_u = c->buffer_end - c->end_unchanged; |
| 791 | 785 | ||
| 792 | fprintf (stderr, | 786 | fprintf (stderr, |
| 793 | "basis: %"pI"d..%"pI"d modified: %"pI"d..%"pI"d\n", | 787 | "basis: %"pD"d..%"pD"d modified: %"pD"d..%"pD"d\n", |
| 794 | c->buffer_beg, c->buffer_end, | 788 | c->buffer_beg, c->buffer_end, |
| 795 | beg_u, end_u); | 789 | beg_u, end_u); |
| 796 | 790 | ||
| 797 | for (i = 0; i < c->cache_len; i++) | 791 | for (i = 0; i < c->cache_len; i++) |
| 798 | { | 792 | { |
| 799 | EMACS_INT pos = BOUNDARY_POS (c, i); | 793 | ptrdiff_t pos = BOUNDARY_POS (c, i); |
| 800 | 794 | ||
| 801 | putc (((pos < beg_u) ? 'v' | 795 | putc (((pos < beg_u) ? 'v' |
| 802 | : (pos == beg_u) ? '-' | 796 | : (pos == beg_u) ? '-' |
| @@ -806,6 +800,6 @@ pp_cache (struct region_cache *c) | |||
| 806 | : (pos == end_u) ? '-' | 800 | : (pos == end_u) ? '-' |
| 807 | : ' '), | 801 | : ' '), |
| 808 | stderr); | 802 | stderr); |
| 809 | fprintf (stderr, "%"pI"d : %d\n", pos, BOUNDARY_VALUE (c, i)); | 803 | fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i)); |
| 810 | } | 804 | } |
| 811 | } | 805 | } |
diff --git a/src/region-cache.h b/src/region-cache.h index ea767ed0dc3..8e1be716776 100644 --- a/src/region-cache.h +++ b/src/region-cache.h | |||
| @@ -72,7 +72,7 @@ void free_region_cache (struct region_cache *); | |||
| 72 | no newlines", in the case of the line cache). */ | 72 | no newlines", in the case of the line cache). */ |
| 73 | extern void know_region_cache (struct buffer *BUF, | 73 | extern void know_region_cache (struct buffer *BUF, |
| 74 | struct region_cache *CACHE, | 74 | struct region_cache *CACHE, |
| 75 | EMACS_INT START, EMACS_INT END); | 75 | ptrdiff_t START, ptrdiff_t END); |
| 76 | 76 | ||
| 77 | /* Indicate that a section of BUF has changed, to invalidate CACHE. | 77 | /* Indicate that a section of BUF has changed, to invalidate CACHE. |
| 78 | HEAD is the number of chars unchanged at the beginning of the buffer. | 78 | HEAD is the number of chars unchanged at the beginning of the buffer. |
| @@ -84,7 +84,7 @@ extern void know_region_cache (struct buffer *BUF, | |||
| 84 | args to pass are the same before and after such an operation.) */ | 84 | args to pass are the same before and after such an operation.) */ |
| 85 | extern void invalidate_region_cache (struct buffer *BUF, | 85 | extern void invalidate_region_cache (struct buffer *BUF, |
| 86 | struct region_cache *CACHE, | 86 | struct region_cache *CACHE, |
| 87 | EMACS_INT HEAD, EMACS_INT TAIL); | 87 | ptrdiff_t HEAD, ptrdiff_t TAIL); |
| 88 | 88 | ||
| 89 | /* The scanning functions. | 89 | /* The scanning functions. |
| 90 | 90 | ||
| @@ -100,13 +100,13 @@ extern void invalidate_region_cache (struct buffer *BUF, | |||
| 100 | position after POS where the knownness changes. */ | 100 | position after POS where the knownness changes. */ |
| 101 | extern int region_cache_forward (struct buffer *BUF, | 101 | extern int region_cache_forward (struct buffer *BUF, |
| 102 | struct region_cache *CACHE, | 102 | struct region_cache *CACHE, |
| 103 | EMACS_INT POS, | 103 | ptrdiff_t POS, |
| 104 | EMACS_INT *NEXT); | 104 | ptrdiff_t *NEXT); |
| 105 | 105 | ||
| 106 | /* Return true if the text immediately before POS in BUF is known, for | 106 | /* Return true if the text immediately before POS in BUF is known, for |
| 107 | the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest | 107 | the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest |
| 108 | position before POS where the knownness changes. */ | 108 | position before POS where the knownness changes. */ |
| 109 | extern int region_cache_backward (struct buffer *BUF, | 109 | extern int region_cache_backward (struct buffer *BUF, |
| 110 | struct region_cache *CACHE, | 110 | struct region_cache *CACHE, |
| 111 | EMACS_INT POS, | 111 | ptrdiff_t POS, |
| 112 | EMACS_INT *NEXT); | 112 | ptrdiff_t *NEXT); |
diff --git a/src/scroll.c b/src/scroll.c index 6291936a541..05f6fdf85f0 100644 --- a/src/scroll.c +++ b/src/scroll.c | |||
| @@ -969,32 +969,14 @@ do_line_insertion_deletion_costs (FRAME_PTR frame, | |||
| 969 | const char *cleanup_string, | 969 | const char *cleanup_string, |
| 970 | int coefficient) | 970 | int coefficient) |
| 971 | { | 971 | { |
| 972 | if (FRAME_INSERT_COST (frame) != 0) | 972 | FRAME_INSERT_COST (frame) = |
| 973 | { | 973 | xnrealloc (FRAME_INSERT_COST (frame), FRAME_LINES (frame), sizeof (int)); |
| 974 | FRAME_INSERT_COST (frame) = | 974 | FRAME_DELETEN_COST (frame) = |
| 975 | (int *) xrealloc (FRAME_INSERT_COST (frame), | 975 | xnrealloc (FRAME_DELETEN_COST (frame), FRAME_LINES (frame), sizeof (int)); |
| 976 | FRAME_LINES (frame) * sizeof (int)); | 976 | FRAME_INSERTN_COST (frame) = |
| 977 | FRAME_DELETEN_COST (frame) = | 977 | xnrealloc (FRAME_INSERTN_COST (frame), FRAME_LINES (frame), sizeof (int)); |
| 978 | (int *) xrealloc (FRAME_DELETEN_COST (frame), | 978 | FRAME_DELETE_COST (frame) = |
| 979 | FRAME_LINES (frame) * sizeof (int)); | 979 | xnrealloc (FRAME_DELETE_COST (frame), FRAME_LINES (frame), sizeof (int)); |
| 980 | FRAME_INSERTN_COST (frame) = | ||
| 981 | (int *) xrealloc (FRAME_INSERTN_COST (frame), | ||
| 982 | FRAME_LINES (frame) * sizeof (int)); | ||
| 983 | FRAME_DELETE_COST (frame) = | ||
| 984 | (int *) xrealloc (FRAME_DELETE_COST (frame), | ||
| 985 | FRAME_LINES (frame) * sizeof (int)); | ||
| 986 | } | ||
| 987 | else | ||
| 988 | { | ||
| 989 | FRAME_INSERT_COST (frame) = | ||
| 990 | (int *) xmalloc (FRAME_LINES (frame) * sizeof (int)); | ||
| 991 | FRAME_DELETEN_COST (frame) = | ||
| 992 | (int *) xmalloc (FRAME_LINES (frame) * sizeof (int)); | ||
| 993 | FRAME_INSERTN_COST (frame) = | ||
| 994 | (int *) xmalloc (FRAME_LINES (frame) * sizeof (int)); | ||
| 995 | FRAME_DELETE_COST (frame) = | ||
| 996 | (int *) xmalloc (FRAME_LINES (frame) * sizeof (int)); | ||
| 997 | } | ||
| 998 | 980 | ||
| 999 | ins_del_costs (frame, | 981 | ins_del_costs (frame, |
| 1000 | ins_line_string, multi_ins_string, | 982 | ins_line_string, multi_ins_string, |
diff --git a/src/search.c b/src/search.c index a56df784cd2..d892792cbaa 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -683,7 +683,7 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, | |||
| 683 | to see where we can avoid some scanning. */ | 683 | to see where we can avoid some scanning. */ |
| 684 | if (target == '\n' && newline_cache) | 684 | if (target == '\n' && newline_cache) |
| 685 | { | 685 | { |
| 686 | EMACS_INT next_change; | 686 | ptrdiff_t next_change; |
| 687 | immediate_quit = 0; | 687 | immediate_quit = 0; |
| 688 | while (region_cache_forward | 688 | while (region_cache_forward |
| 689 | (current_buffer, newline_cache, start_byte, &next_change)) | 689 | (current_buffer, newline_cache, start_byte, &next_change)) |
| @@ -755,7 +755,7 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, | |||
| 755 | /* Consult the newline cache, if appropriate. */ | 755 | /* Consult the newline cache, if appropriate. */ |
| 756 | if (target == '\n' && newline_cache) | 756 | if (target == '\n' && newline_cache) |
| 757 | { | 757 | { |
| 758 | EMACS_INT next_change; | 758 | ptrdiff_t next_change; |
| 759 | immediate_quit = 0; | 759 | immediate_quit = 0; |
| 760 | while (region_cache_backward | 760 | while (region_cache_backward |
| 761 | (current_buffer, newline_cache, start_byte, &next_change)) | 761 | (current_buffer, newline_cache, start_byte, &next_change)) |
| @@ -2640,15 +2640,17 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2640 | perform substitution on the replacement string. */ | 2640 | perform substitution on the replacement string. */ |
| 2641 | if (NILP (literal)) | 2641 | if (NILP (literal)) |
| 2642 | { | 2642 | { |
| 2643 | EMACS_INT length = SBYTES (newtext); | 2643 | ptrdiff_t length = SBYTES (newtext); |
| 2644 | unsigned char *substed; | 2644 | unsigned char *substed; |
| 2645 | EMACS_INT substed_alloc_size, substed_len; | 2645 | ptrdiff_t substed_alloc_size, substed_len; |
| 2646 | int buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); | 2646 | int buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 2647 | int str_multibyte = STRING_MULTIBYTE (newtext); | 2647 | int str_multibyte = STRING_MULTIBYTE (newtext); |
| 2648 | int really_changed = 0; | 2648 | int really_changed = 0; |
| 2649 | 2649 | ||
| 2650 | substed_alloc_size = length * 2 + 100; | 2650 | substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length |
| 2651 | substed = (unsigned char *) xmalloc (substed_alloc_size + 1); | 2651 | ? STRING_BYTES_BOUND |
| 2652 | : length * 2 + 100); | ||
| 2653 | substed = (unsigned char *) xmalloc (substed_alloc_size); | ||
| 2652 | substed_len = 0; | 2654 | substed_len = 0; |
| 2653 | 2655 | ||
| 2654 | /* Go thru NEWTEXT, producing the actual text to insert in | 2656 | /* Go thru NEWTEXT, producing the actual text to insert in |
| @@ -2659,7 +2661,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2659 | { | 2661 | { |
| 2660 | unsigned char str[MAX_MULTIBYTE_LENGTH]; | 2662 | unsigned char str[MAX_MULTIBYTE_LENGTH]; |
| 2661 | const unsigned char *add_stuff = NULL; | 2663 | const unsigned char *add_stuff = NULL; |
| 2662 | EMACS_INT add_len = 0; | 2664 | ptrdiff_t add_len = 0; |
| 2663 | int idx = -1; | 2665 | int idx = -1; |
| 2664 | 2666 | ||
| 2665 | if (str_multibyte) | 2667 | if (str_multibyte) |
| @@ -2723,7 +2725,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2723 | set up ADD_STUFF and ADD_LEN to point to it. */ | 2725 | set up ADD_STUFF and ADD_LEN to point to it. */ |
| 2724 | if (idx >= 0) | 2726 | if (idx >= 0) |
| 2725 | { | 2727 | { |
| 2726 | EMACS_INT begbyte = CHAR_TO_BYTE (search_regs.start[idx]); | 2728 | ptrdiff_t begbyte = CHAR_TO_BYTE (search_regs.start[idx]); |
| 2727 | add_len = CHAR_TO_BYTE (search_regs.end[idx]) - begbyte; | 2729 | add_len = CHAR_TO_BYTE (search_regs.end[idx]) - begbyte; |
| 2728 | if (search_regs.start[idx] < GPT && GPT < search_regs.end[idx]) | 2730 | if (search_regs.start[idx] < GPT && GPT < search_regs.end[idx]) |
| 2729 | move_gap (search_regs.start[idx]); | 2731 | move_gap (search_regs.start[idx]); |
| @@ -2734,12 +2736,11 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2734 | is invariably ADD_LEN bytes starting at ADD_STUFF. */ | 2736 | is invariably ADD_LEN bytes starting at ADD_STUFF. */ |
| 2735 | 2737 | ||
| 2736 | /* Make sure SUBSTED is big enough. */ | 2738 | /* Make sure SUBSTED is big enough. */ |
| 2737 | if (substed_len + add_len >= substed_alloc_size) | 2739 | if (substed_alloc_size - substed_len < add_len) |
| 2738 | { | 2740 | substed = |
| 2739 | substed_alloc_size = substed_len + add_len + 500; | 2741 | xpalloc (substed, &substed_alloc_size, |
| 2740 | substed = (unsigned char *) xrealloc (substed, | 2742 | add_len - (substed_alloc_size - substed_len), |
| 2741 | substed_alloc_size + 1); | 2743 | STRING_BYTES_BOUND, 1); |
| 2742 | } | ||
| 2743 | 2744 | ||
| 2744 | /* Now add to the end of SUBSTED. */ | 2745 | /* Now add to the end of SUBSTED. */ |
| 2745 | if (add_stuff) | 2746 | if (add_stuff) |
| @@ -2973,7 +2974,7 @@ LIST should have been created by calling `match-data' previously. | |||
| 2973 | If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) | 2974 | If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) |
| 2974 | (register Lisp_Object list, Lisp_Object reseat) | 2975 | (register Lisp_Object list, Lisp_Object reseat) |
| 2975 | { | 2976 | { |
| 2976 | register int i; | 2977 | ptrdiff_t i; |
| 2977 | register Lisp_Object marker; | 2978 | register Lisp_Object marker; |
| 2978 | 2979 | ||
| 2979 | if (running_asynch_code) | 2980 | if (running_asynch_code) |
| @@ -2987,31 +2988,21 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) | |||
| 2987 | 2988 | ||
| 2988 | /* Allocate registers if they don't already exist. */ | 2989 | /* Allocate registers if they don't already exist. */ |
| 2989 | { | 2990 | { |
| 2990 | int length = XFASTINT (Flength (list)) / 2; | 2991 | ptrdiff_t length = XFASTINT (Flength (list)) / 2; |
| 2991 | 2992 | ||
| 2992 | if (length > search_regs.num_regs) | 2993 | if (length > search_regs.num_regs) |
| 2993 | { | 2994 | { |
| 2994 | if (search_regs.num_regs == 0) | 2995 | ptrdiff_t num_regs = search_regs.num_regs; |
| 2995 | { | 2996 | search_regs.start = |
| 2996 | search_regs.start | 2997 | xpalloc (search_regs.start, &num_regs, length - num_regs, |
| 2997 | = (regoff_t *) xmalloc (length * sizeof (regoff_t)); | 2998 | min (PTRDIFF_MAX, UINT_MAX), sizeof (regoff_t)); |
| 2998 | search_regs.end | 2999 | search_regs.end = |
| 2999 | = (regoff_t *) xmalloc (length * sizeof (regoff_t)); | 3000 | xrealloc (search_regs.end, num_regs * sizeof (regoff_t)); |
| 3000 | } | 3001 | |
| 3001 | else | 3002 | for (i = search_regs.num_regs; i < num_regs; i++) |
| 3002 | { | ||
| 3003 | search_regs.start | ||
| 3004 | = (regoff_t *) xrealloc (search_regs.start, | ||
| 3005 | length * sizeof (regoff_t)); | ||
| 3006 | search_regs.end | ||
| 3007 | = (regoff_t *) xrealloc (search_regs.end, | ||
| 3008 | length * sizeof (regoff_t)); | ||
| 3009 | } | ||
| 3010 | |||
| 3011 | for (i = search_regs.num_regs; i < length; i++) | ||
| 3012 | search_regs.start[i] = -1; | 3003 | search_regs.start[i] = -1; |
| 3013 | 3004 | ||
| 3014 | search_regs.num_regs = length; | 3005 | search_regs.num_regs = num_regs; |
| 3015 | } | 3006 | } |
| 3016 | 3007 | ||
| 3017 | for (i = 0; CONSP (list); i++) | 3008 | for (i = 0; CONSP (list); i++) |
diff --git a/src/syntax.c b/src/syntax.c index 8c2d5ded21f..3e51099794b 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -398,7 +398,12 @@ find_defun_start (EMACS_INT pos, EMACS_INT pos_byte) | |||
| 398 | 398 | ||
| 399 | if (!open_paren_in_column_0_is_defun_start) | 399 | if (!open_paren_in_column_0_is_defun_start) |
| 400 | { | 400 | { |
| 401 | find_start_value = BEGV; | ||
| 401 | find_start_value_byte = BEGV_BYTE; | 402 | find_start_value_byte = BEGV_BYTE; |
| 403 | find_start_buffer = current_buffer; | ||
| 404 | find_start_modiff = MODIFF; | ||
| 405 | find_start_begv = BEGV; | ||
| 406 | find_start_pos = pos; | ||
| 402 | return BEGV; | 407 | return BEGV; |
| 403 | } | 408 | } |
| 404 | 409 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 4bd1f54b9e6..57fff94f552 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2640,7 +2640,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2640 | ssize_t nread; | 2640 | ssize_t nread; |
| 2641 | const char *cmd = NULL; | 2641 | const char *cmd = NULL; |
| 2642 | char *cmdline = NULL; | 2642 | char *cmdline = NULL; |
| 2643 | size_t cmdsize = 0, cmdline_size; | 2643 | ptrdiff_t cmdsize = 0, cmdline_size; |
| 2644 | unsigned char c; | 2644 | unsigned char c; |
| 2645 | int proc_id, ppid, uid, gid, pgrp, sess, tty, tpgid, thcount; | 2645 | int proc_id, ppid, uid, gid, pgrp, sess, tty, tpgid, thcount; |
| 2646 | unsigned long long u_time, s_time, cutime, cstime, start; | 2646 | unsigned long long u_time, s_time, cutime, cstime, start; |
| @@ -2822,8 +2822,10 @@ system_process_attributes (Lisp_Object pid) | |||
| 2822 | if (fd >= 0) | 2822 | if (fd >= 0) |
| 2823 | { | 2823 | { |
| 2824 | char ch; | 2824 | char ch; |
| 2825 | for (cmdline_size = 0; emacs_read (fd, &ch, 1) == 1; cmdline_size++) | 2825 | for (cmdline_size = 0; cmdline_size < STRING_BYTES_BOUND; cmdline_size++) |
| 2826 | { | 2826 | { |
| 2827 | if (emacs_read (fd, &ch, 1) != 1) | ||
| 2828 | break; | ||
| 2827 | c = ch; | 2829 | c = ch; |
| 2828 | if (isspace (c) || c == '\\') | 2830 | if (isspace (c) || c == '\\') |
| 2829 | cmdline_size++; /* for later quoting, see below */ | 2831 | cmdline_size++; /* for later quoting, see below */ |
| @@ -2844,7 +2846,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2844 | nread = 0; | 2846 | nread = 0; |
| 2845 | } | 2847 | } |
| 2846 | /* We don't want trailing null characters. */ | 2848 | /* We don't want trailing null characters. */ |
| 2847 | for (p = cmdline + nread - 1; p > cmdline && !*p; p--) | 2849 | for (p = cmdline + nread; p > cmdline + 1 && !p[-1]; p--) |
| 2848 | nread--; | 2850 | nread--; |
| 2849 | for (p = cmdline; p < cmdline + nread; p++) | 2851 | for (p = cmdline; p < cmdline + nread; p++) |
| 2850 | { | 2852 | { |
diff --git a/src/syssignal.h b/src/syssignal.h index c5c749407cc..7533a5a64fd 100644 --- a/src/syssignal.h +++ b/src/syssignal.h | |||
| @@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 18 | 18 | ||
| 19 | extern void init_signals (void); | 19 | extern void init_signals (void); |
| 20 | 20 | ||
| 21 | #if defined (HAVE_GTK_AND_PTHREAD) || defined (HAVE_NS) | 21 | #ifdef HAVE_PTHREAD |
| 22 | #include <pthread.h> | 22 | #include <pthread.h> |
| 23 | /* If defined, asynchronous signals delivered to a non-main thread are | 23 | /* If defined, asynchronous signals delivered to a non-main thread are |
| 24 | forwarded to the main thread. */ | 24 | forwarded to the main thread. */ |
diff --git a/src/term.c b/src/term.c index 22056451cb9..837ab399152 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -136,10 +136,6 @@ enum no_color_bit | |||
| 136 | 136 | ||
| 137 | static int max_frame_cols; | 137 | static int max_frame_cols; |
| 138 | 138 | ||
| 139 | /* The largest frame height in any call to calculate_costs. */ | ||
| 140 | |||
| 141 | static int max_frame_lines; | ||
| 142 | |||
| 143 | /* Non-zero if we have dropped our controlling tty and therefore | 139 | /* Non-zero if we have dropped our controlling tty and therefore |
| 144 | should not open a frame on stdout. */ | 140 | should not open a frame on stdout. */ |
| 145 | static int no_controlling_tty; | 141 | static int no_controlling_tty; |
| @@ -497,8 +493,8 @@ tty_clear_end_of_line (struct frame *f, int first_unused_hpos) | |||
| 497 | static unsigned char *encode_terminal_src; | 493 | static unsigned char *encode_terminal_src; |
| 498 | static unsigned char *encode_terminal_dst; | 494 | static unsigned char *encode_terminal_dst; |
| 499 | /* Allocated sizes of the above buffers. */ | 495 | /* Allocated sizes of the above buffers. */ |
| 500 | static int encode_terminal_src_size; | 496 | static ptrdiff_t encode_terminal_src_size; |
| 501 | static int encode_terminal_dst_size; | 497 | static ptrdiff_t encode_terminal_dst_size; |
| 502 | 498 | ||
| 503 | /* Encode SRC_LEN glyphs starting at SRC to terminal output codes. | 499 | /* Encode SRC_LEN glyphs starting at SRC to terminal output codes. |
| 504 | Set CODING->produced to the byte-length of the resulting byte | 500 | Set CODING->produced to the byte-length of the resulting byte |
| @@ -509,8 +505,8 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 509 | { | 505 | { |
| 510 | struct glyph *src_end = src + src_len; | 506 | struct glyph *src_end = src + src_len; |
| 511 | unsigned char *buf; | 507 | unsigned char *buf; |
| 512 | int nchars, nbytes, required; | 508 | ptrdiff_t nchars, nbytes, required; |
| 513 | register int tlen = GLYPH_TABLE_LENGTH; | 509 | ptrdiff_t tlen = GLYPH_TABLE_LENGTH; |
| 514 | register Lisp_Object *tbase = GLYPH_TABLE_BASE; | 510 | register Lisp_Object *tbase = GLYPH_TABLE_BASE; |
| 515 | Lisp_Object charset_list; | 511 | Lisp_Object charset_list; |
| 516 | 512 | ||
| @@ -518,13 +514,13 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 518 | multibyte-form. But, it may be enlarged on demand if | 514 | multibyte-form. But, it may be enlarged on demand if |
| 519 | Vglyph_table contains a string or a composite glyph is | 515 | Vglyph_table contains a string or a composite glyph is |
| 520 | encountered. */ | 516 | encountered. */ |
| 521 | required = MAX_MULTIBYTE_LENGTH * src_len; | 517 | if (min (PTRDIFF_MAX, SIZE_MAX) / MAX_MULTIBYTE_LENGTH < src_len) |
| 518 | memory_full (SIZE_MAX); | ||
| 519 | required = src_len; | ||
| 520 | required *= MAX_MULTIBYTE_LENGTH; | ||
| 522 | if (encode_terminal_src_size < required) | 521 | if (encode_terminal_src_size < required) |
| 523 | { | 522 | { |
| 524 | if (encode_terminal_src) | 523 | encode_terminal_src = xrealloc (encode_terminal_src, required); |
| 525 | encode_terminal_src = xrealloc (encode_terminal_src, required); | ||
| 526 | else | ||
| 527 | encode_terminal_src = xmalloc (required); | ||
| 528 | encode_terminal_src_size = required; | 524 | encode_terminal_src_size = required; |
| 529 | } | 525 | } |
| 530 | 526 | ||
| @@ -544,19 +540,21 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 544 | if (src->u.cmp.automatic) | 540 | if (src->u.cmp.automatic) |
| 545 | { | 541 | { |
| 546 | gstring = composition_gstring_from_id (src->u.cmp.id); | 542 | gstring = composition_gstring_from_id (src->u.cmp.id); |
| 547 | required = src->slice.cmp.to + 1 - src->slice.cmp.from; | 543 | required = src->slice.cmp.to - src->slice.cmp.from + 1; |
| 548 | } | 544 | } |
| 549 | else | 545 | else |
| 550 | { | 546 | { |
| 551 | cmp = composition_table[src->u.cmp.id]; | 547 | cmp = composition_table[src->u.cmp.id]; |
| 552 | required = MAX_MULTIBYTE_LENGTH * cmp->glyph_len; | 548 | required = cmp->glyph_len; |
| 549 | required *= MAX_MULTIBYTE_LENGTH; | ||
| 553 | } | 550 | } |
| 554 | 551 | ||
| 555 | if (encode_terminal_src_size < nbytes + required) | 552 | if (encode_terminal_src_size - nbytes < required) |
| 556 | { | 553 | { |
| 557 | encode_terminal_src_size = nbytes + required; | 554 | encode_terminal_src = |
| 558 | encode_terminal_src = xrealloc (encode_terminal_src, | 555 | xpalloc (encode_terminal_src, &encode_terminal_src_size, |
| 559 | encode_terminal_src_size); | 556 | required - (encode_terminal_src_size - nbytes), |
| 557 | -1, 1); | ||
| 560 | buf = encode_terminal_src + nbytes; | 558 | buf = encode_terminal_src + nbytes; |
| 561 | } | 559 | } |
| 562 | 560 | ||
| @@ -627,11 +625,11 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 627 | if (NILP (string)) | 625 | if (NILP (string)) |
| 628 | { | 626 | { |
| 629 | nbytes = buf - encode_terminal_src; | 627 | nbytes = buf - encode_terminal_src; |
| 630 | if (encode_terminal_src_size < nbytes + MAX_MULTIBYTE_LENGTH) | 628 | if (encode_terminal_src_size - nbytes < MAX_MULTIBYTE_LENGTH) |
| 631 | { | 629 | { |
| 632 | encode_terminal_src_size = nbytes + MAX_MULTIBYTE_LENGTH; | 630 | encode_terminal_src = |
| 633 | encode_terminal_src = xrealloc (encode_terminal_src, | 631 | xpalloc (encode_terminal_src, &encode_terminal_src_size, |
| 634 | encode_terminal_src_size); | 632 | MAX_MULTIBYTE_LENGTH, -1, 1); |
| 635 | buf = encode_terminal_src + nbytes; | 633 | buf = encode_terminal_src + nbytes; |
| 636 | } | 634 | } |
| 637 | if (CHAR_BYTE8_P (c) | 635 | if (CHAR_BYTE8_P (c) |
| @@ -659,11 +657,13 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 659 | if (! STRING_MULTIBYTE (string)) | 657 | if (! STRING_MULTIBYTE (string)) |
| 660 | string = string_to_multibyte (string); | 658 | string = string_to_multibyte (string); |
| 661 | nbytes = buf - encode_terminal_src; | 659 | nbytes = buf - encode_terminal_src; |
| 662 | if (encode_terminal_src_size < nbytes + SBYTES (string)) | 660 | if (encode_terminal_src_size - nbytes < SBYTES (string)) |
| 663 | { | 661 | { |
| 664 | encode_terminal_src_size = nbytes + SBYTES (string); | 662 | encode_terminal_src = |
| 665 | encode_terminal_src = xrealloc (encode_terminal_src, | 663 | xpalloc (encode_terminal_src, &encode_terminal_src_size, |
| 666 | encode_terminal_src_size); | 664 | (SBYTES (string) |
| 665 | - (encode_terminal_src_size - nbytes)), | ||
| 666 | -1, 1); | ||
| 667 | buf = encode_terminal_src + nbytes; | 667 | buf = encode_terminal_src + nbytes; |
| 668 | } | 668 | } |
| 669 | memcpy (buf, SDATA (string), SBYTES (string)); | 669 | memcpy (buf, SDATA (string), SBYTES (string)); |
| @@ -684,12 +684,9 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 684 | coding->source = encode_terminal_src; | 684 | coding->source = encode_terminal_src; |
| 685 | if (encode_terminal_dst_size == 0) | 685 | if (encode_terminal_dst_size == 0) |
| 686 | { | 686 | { |
| 687 | encode_terminal_dst = xrealloc (encode_terminal_dst, | ||
| 688 | encode_terminal_src_size); | ||
| 687 | encode_terminal_dst_size = encode_terminal_src_size; | 689 | encode_terminal_dst_size = encode_terminal_src_size; |
| 688 | if (encode_terminal_dst) | ||
| 689 | encode_terminal_dst = xrealloc (encode_terminal_dst, | ||
| 690 | encode_terminal_dst_size); | ||
| 691 | else | ||
| 692 | encode_terminal_dst = xmalloc (encode_terminal_dst_size); | ||
| 693 | } | 690 | } |
| 694 | coding->destination = encode_terminal_dst; | 691 | coding->destination = encode_terminal_dst; |
| 695 | coding->dst_bytes = encode_terminal_dst_size; | 692 | coding->dst_bytes = encode_terminal_dst_size; |
| @@ -1156,21 +1153,17 @@ calculate_costs (struct frame *frame) | |||
| 1156 | char_ins_del_vector (i.e., char_ins_del_cost) isn't used because | 1153 | char_ins_del_vector (i.e., char_ins_del_cost) isn't used because |
| 1157 | X turns off char_ins_del_ok. */ | 1154 | X turns off char_ins_del_ok. */ |
| 1158 | 1155 | ||
| 1159 | max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); | ||
| 1160 | max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); | 1156 | max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); |
| 1157 | if ((min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) - 1) / 2 | ||
| 1158 | < max_frame_cols) | ||
| 1159 | memory_full (SIZE_MAX); | ||
| 1161 | 1160 | ||
| 1162 | if (char_ins_del_vector != 0) | 1161 | char_ins_del_vector = |
| 1163 | char_ins_del_vector | 1162 | xrealloc (char_ins_del_vector, |
| 1164 | = (int *) xrealloc (char_ins_del_vector, | 1163 | (sizeof (int) + 2 * sizeof (int) * max_frame_cols)); |
| 1165 | (sizeof (int) | ||
| 1166 | + 2 * max_frame_cols * sizeof (int))); | ||
| 1167 | else | ||
| 1168 | char_ins_del_vector | ||
| 1169 | = (int *) xmalloc (sizeof (int) | ||
| 1170 | + 2 * max_frame_cols * sizeof (int)); | ||
| 1171 | 1164 | ||
| 1172 | memset (char_ins_del_vector, 0, | 1165 | memset (char_ins_del_vector, 0, |
| 1173 | (sizeof (int) + 2 * max_frame_cols * sizeof (int))); | 1166 | (sizeof (int) + 2 * sizeof (int) * max_frame_cols)); |
| 1174 | 1167 | ||
| 1175 | 1168 | ||
| 1176 | if (f && (!tty->TS_ins_line && !tty->TS_del_line)) | 1169 | if (f && (!tty->TS_ins_line && !tty->TS_del_line)) |
| @@ -1447,7 +1440,6 @@ term_get_fkeys_1 (void) | |||
| 1447 | Character Display Information | 1440 | Character Display Information |
| 1448 | ***********************************************************************/ | 1441 | ***********************************************************************/ |
| 1449 | static void append_glyph (struct it *); | 1442 | static void append_glyph (struct it *); |
| 1450 | static void produce_stretch_glyph (struct it *); | ||
| 1451 | static void append_composite_glyph (struct it *); | 1443 | static void append_composite_glyph (struct it *); |
| 1452 | static void produce_composite_glyph (struct it *); | 1444 | static void produce_composite_glyph (struct it *); |
| 1453 | static void append_glyphless_glyph (struct it *, int, const char *); | 1445 | static void append_glyphless_glyph (struct it *, int, const char *); |
| @@ -1519,6 +1511,14 @@ append_glyph (struct it *it) | |||
| 1519 | } | 1511 | } |
| 1520 | } | 1512 | } |
| 1521 | 1513 | ||
| 1514 | /* For external use. */ | ||
| 1515 | void | ||
| 1516 | tty_append_glyph (struct it *it) | ||
| 1517 | { | ||
| 1518 | append_glyph (it); | ||
| 1519 | } | ||
| 1520 | |||
| 1521 | |||
| 1522 | /* Produce glyphs for the display element described by IT. *IT | 1522 | /* Produce glyphs for the display element described by IT. *IT |
| 1523 | specifies what we want to produce a glyph for (character, image, ...), | 1523 | specifies what we want to produce a glyph for (character, image, ...), |
| 1524 | and where in the glyph matrix we currently are (glyph row and hpos). | 1524 | and where in the glyph matrix we currently are (glyph row and hpos). |
| @@ -1645,83 +1645,6 @@ produce_glyphs (struct it *it) | |||
| 1645 | it->descent = it->max_descent = it->phys_descent = it->max_phys_descent = 1; | 1645 | it->descent = it->max_descent = it->phys_descent = it->max_phys_descent = 1; |
| 1646 | } | 1646 | } |
| 1647 | 1647 | ||
| 1648 | |||
| 1649 | /* Produce a stretch glyph for iterator IT. IT->object is the value | ||
| 1650 | of the glyph property displayed. The value must be a list | ||
| 1651 | `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs | ||
| 1652 | being recognized: | ||
| 1653 | |||
| 1654 | 1. `:width WIDTH' specifies that the space should be WIDTH * | ||
| 1655 | canonical char width wide. WIDTH may be an integer or floating | ||
| 1656 | point number. | ||
| 1657 | |||
| 1658 | 2. `:align-to HPOS' specifies that the space should be wide enough | ||
| 1659 | to reach HPOS, a value in canonical character units. */ | ||
| 1660 | |||
| 1661 | static void | ||
| 1662 | produce_stretch_glyph (struct it *it) | ||
| 1663 | { | ||
| 1664 | /* (space :width WIDTH ...) */ | ||
| 1665 | Lisp_Object prop, plist; | ||
| 1666 | int width = 0, align_to = -1; | ||
| 1667 | int zero_width_ok_p = 0; | ||
| 1668 | double tem; | ||
| 1669 | |||
| 1670 | /* List should start with `space'. */ | ||
| 1671 | xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); | ||
| 1672 | plist = XCDR (it->object); | ||
| 1673 | |||
| 1674 | /* Compute the width of the stretch. */ | ||
| 1675 | if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) | ||
| 1676 | && calc_pixel_width_or_height (&tem, it, prop, 0, 1, 0)) | ||
| 1677 | { | ||
| 1678 | /* Absolute width `:width WIDTH' specified and valid. */ | ||
| 1679 | zero_width_ok_p = 1; | ||
| 1680 | width = (int)(tem + 0.5); | ||
| 1681 | } | ||
| 1682 | else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) | ||
| 1683 | && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to)) | ||
| 1684 | { | ||
| 1685 | if (it->glyph_row == NULL || !it->glyph_row->mode_line_p) | ||
| 1686 | align_to = (align_to < 0 | ||
| 1687 | ? 0 | ||
| 1688 | : align_to - window_box_left_offset (it->w, TEXT_AREA)); | ||
| 1689 | else if (align_to < 0) | ||
| 1690 | align_to = window_box_left_offset (it->w, TEXT_AREA); | ||
| 1691 | width = max (0, (int)(tem + 0.5) + align_to - it->current_x); | ||
| 1692 | zero_width_ok_p = 1; | ||
| 1693 | } | ||
| 1694 | else | ||
| 1695 | /* Nothing specified -> width defaults to canonical char width. */ | ||
| 1696 | width = FRAME_COLUMN_WIDTH (it->f); | ||
| 1697 | |||
| 1698 | if (width <= 0 && (width < 0 || !zero_width_ok_p)) | ||
| 1699 | width = 1; | ||
| 1700 | |||
| 1701 | if (width > 0 && it->line_wrap != TRUNCATE | ||
| 1702 | && it->current_x + width > it->last_visible_x) | ||
| 1703 | width = it->last_visible_x - it->current_x - 1; | ||
| 1704 | |||
| 1705 | if (width > 0 && it->glyph_row) | ||
| 1706 | { | ||
| 1707 | Lisp_Object o_object = it->object; | ||
| 1708 | Lisp_Object object = it->stack[it->sp - 1].string; | ||
| 1709 | int n = width; | ||
| 1710 | |||
| 1711 | if (!STRINGP (object)) | ||
| 1712 | object = it->w->buffer; | ||
| 1713 | it->object = object; | ||
| 1714 | it->char_to_display = ' '; | ||
| 1715 | it->pixel_width = it->len = 1; | ||
| 1716 | while (n--) | ||
| 1717 | append_glyph (it); | ||
| 1718 | it->object = o_object; | ||
| 1719 | } | ||
| 1720 | it->pixel_width = width; | ||
| 1721 | it->nglyphs = width; | ||
| 1722 | } | ||
| 1723 | |||
| 1724 | |||
| 1725 | /* Append glyphs to IT's glyph_row for the composition IT->cmp_id. | 1648 | /* Append glyphs to IT's glyph_row for the composition IT->cmp_id. |
| 1726 | Called from produce_composite_glyph for terminal frames if | 1649 | Called from produce_composite_glyph for terminal frames if |
| 1727 | IT->glyph_row != NULL. IT->face_id contains the character's | 1650 | IT->glyph_row != NULL. IT->face_id contains the character's |
| @@ -3145,11 +3068,6 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3145 | encode_terminal_src_size = 0; | 3068 | encode_terminal_src_size = 0; |
| 3146 | encode_terminal_dst_size = 0; | 3069 | encode_terminal_dst_size = 0; |
| 3147 | 3070 | ||
| 3148 | #ifdef HAVE_GPM | ||
| 3149 | terminal->mouse_position_hook = term_mouse_position; | ||
| 3150 | tty->mouse_highlight.mouse_face_window = Qnil; | ||
| 3151 | #endif | ||
| 3152 | |||
| 3153 | 3071 | ||
| 3154 | #ifndef DOS_NT | 3072 | #ifndef DOS_NT |
| 3155 | set_tty_hooks (terminal); | 3073 | set_tty_hooks (terminal); |
| @@ -3409,6 +3327,11 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3409 | tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ | 3327 | tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ |
| 3410 | #endif /* DOS_NT */ | 3328 | #endif /* DOS_NT */ |
| 3411 | 3329 | ||
| 3330 | #ifdef HAVE_GPM | ||
| 3331 | terminal->mouse_position_hook = term_mouse_position; | ||
| 3332 | tty->mouse_highlight.mouse_face_window = Qnil; | ||
| 3333 | #endif | ||
| 3334 | |||
| 3412 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 3335 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); |
| 3413 | init_kboard (terminal->kboard); | 3336 | init_kboard (terminal->kboard); |
| 3414 | KVAR (terminal->kboard, Vwindow_system) = Qnil; | 3337 | KVAR (terminal->kboard, Vwindow_system) = Qnil; |
diff --git a/src/termcap.c b/src/termcap.c index 96b9303d62d..6f24817fa72 100644 --- a/src/termcap.c +++ b/src/termcap.c | |||
| @@ -480,7 +480,7 @@ tgetent (char *bp, const char *name) | |||
| 480 | /* If BP is malloc'd by us, make sure it is big enough. */ | 480 | /* If BP is malloc'd by us, make sure it is big enough. */ |
| 481 | if (malloc_size) | 481 | if (malloc_size) |
| 482 | { | 482 | { |
| 483 | int offset1 = bp1 - bp, offset2 = tc_search_point - bp; | 483 | ptrdiff_t offset1 = bp1 - bp, offset2 = tc_search_point - bp; |
| 484 | malloc_size = offset1 + buf.size; | 484 | malloc_size = offset1 + buf.size; |
| 485 | bp = termcap_name = (char *) xrealloc (bp, malloc_size); | 485 | bp = termcap_name = (char *) xrealloc (bp, malloc_size); |
| 486 | bp1 = termcap_name + offset1; | 486 | bp1 = termcap_name + offset1; |
| @@ -619,7 +619,6 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) | |||
| 619 | register char *end; | 619 | register char *end; |
| 620 | register int nread; | 620 | register int nread; |
| 621 | register char *buf = bufp->beg; | 621 | register char *buf = bufp->beg; |
| 622 | register char *tem; | ||
| 623 | 622 | ||
| 624 | if (!append_end) | 623 | if (!append_end) |
| 625 | append_end = bufp->ptr; | 624 | append_end = bufp->ptr; |
| @@ -636,14 +635,14 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) | |||
| 636 | { | 635 | { |
| 637 | if (bufp->full == bufp->size) | 636 | if (bufp->full == bufp->size) |
| 638 | { | 637 | { |
| 639 | if ((PTRDIFF_MAX - 1) / 2 < bufp->size) | 638 | ptrdiff_t ptr_offset = bufp->ptr - buf; |
| 640 | memory_full (SIZE_MAX); | 639 | ptrdiff_t append_end_offset = append_end - buf; |
| 641 | bufp->size *= 2; | ||
| 642 | /* Add 1 to size to ensure room for terminating null. */ | 640 | /* Add 1 to size to ensure room for terminating null. */ |
| 643 | tem = (char *) xrealloc (buf, bufp->size + 1); | 641 | ptrdiff_t size = bufp->size + 1; |
| 644 | bufp->ptr = (bufp->ptr - buf) + tem; | 642 | bufp->beg = buf = xpalloc (buf, &size, 1, -1, 1); |
| 645 | append_end = (append_end - buf) + tem; | 643 | bufp->size = size - 1; |
| 646 | bufp->beg = buf = tem; | 644 | bufp->ptr = buf + ptr_offset; |
| 645 | append_end = buf + append_end_offset; | ||
| 647 | } | 646 | } |
| 648 | } | 647 | } |
| 649 | else | 648 | else |
diff --git a/src/termhooks.h b/src/termhooks.h index 6a58517a85a..63d166b6418 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -288,12 +288,12 @@ enum { | |||
| 288 | /* The next four modifier bits are used also in keyboard events at | 288 | /* The next four modifier bits are used also in keyboard events at |
| 289 | the Lisp level. | 289 | the Lisp level. |
| 290 | 290 | ||
| 291 | It's probably not the greatest idea to use the 2^23 bit for any | 291 | It's probably not the greatest idea to use the 2^28 bit for any |
| 292 | modifier. It may or may not be the sign bit, depending on | 292 | modifier. It may or may not be the sign bit, depending on |
| 293 | VALBITS, so using it to represent a modifier key means that | 293 | FIXNUM_BITS, so using it to represent a modifier key means that |
| 294 | characters thus modified have different integer equivalents | 294 | characters thus modified have different integer equivalents |
| 295 | depending on the architecture they're running on. Oh, and | 295 | depending on the architecture they're running on. Oh, and |
| 296 | applying XINT to a character whose 2^23 bit is set sign-extends | 296 | applying XINT to a character whose 2^28 bit is set might sign-extend |
| 297 | it, so you get a bunch of bits in the mask you didn't want. | 297 | it, so you get a bunch of bits in the mask you didn't want. |
| 298 | 298 | ||
| 299 | The CHAR_ macros are defined in lisp.h. */ | 299 | The CHAR_ macros are defined in lisp.h. */ |
diff --git a/src/tparam.c b/src/tparam.c index ed28cd7397f..ac21667d65b 100644 --- a/src/tparam.c +++ b/src/tparam.c | |||
| @@ -79,24 +79,25 @@ tparam1 (const char *string, char *outstring, int len, | |||
| 79 | register const char *p = string; | 79 | register const char *p = string; |
| 80 | register char *op = outstring; | 80 | register char *op = outstring; |
| 81 | char *outend; | 81 | char *outend; |
| 82 | int outlen = 0; | 82 | char *new = 0; |
| 83 | ptrdiff_t outlen = 0; | ||
| 83 | 84 | ||
| 84 | register int tem; | 85 | register int tem; |
| 85 | int *old_argp = argp; /* can move */ | 86 | int *old_argp = argp; /* can move */ |
| 86 | int *fixed_argp = argp; /* never moves */ | 87 | int *fixed_argp = argp; /* never moves */ |
| 87 | int explicit_param_p = 0; /* set by %p */ | 88 | int explicit_param_p = 0; /* set by %p */ |
| 88 | int doleft = 0; | 89 | ptrdiff_t doleft = 0; |
| 89 | int doup = 0; | 90 | ptrdiff_t doup = 0; |
| 91 | ptrdiff_t append_len = 0; | ||
| 90 | 92 | ||
| 91 | outend = outstring + len; | 93 | outend = outstring + len; |
| 92 | 94 | ||
| 93 | while (1) | 95 | while (1) |
| 94 | { | 96 | { |
| 95 | /* If the buffer might be too short, make it bigger. */ | 97 | /* If the buffer might be too short, make it bigger. */ |
| 96 | if (op + 5 >= outend) | 98 | while (outend - op - append_len <= 5) |
| 97 | { | 99 | { |
| 98 | register char *new; | 100 | ptrdiff_t offset = op - outstring; |
| 99 | int offset = op - outstring; | ||
| 100 | 101 | ||
| 101 | if (outlen == 0) | 102 | if (outlen == 0) |
| 102 | { | 103 | { |
| @@ -106,8 +107,7 @@ tparam1 (const char *string, char *outstring, int len, | |||
| 106 | } | 107 | } |
| 107 | else | 108 | else |
| 108 | { | 109 | { |
| 109 | outlen *= 2; | 110 | new = xpalloc (outstring, &outlen, 1, -1, 1); |
| 110 | new = (char *) xrealloc (outstring, outlen); | ||
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | op = new + offset; | 113 | op = new + offset; |
| @@ -167,11 +167,15 @@ tparam1 (const char *string, char *outstring, int len, | |||
| 167 | and this is one of them, increment it. */ | 167 | and this is one of them, increment it. */ |
| 168 | while (tem == 0 || tem == '\n' || tem == '\t') | 168 | while (tem == 0 || tem == '\n' || tem == '\t') |
| 169 | { | 169 | { |
| 170 | ptrdiff_t append_len_incr; | ||
| 170 | tem++; | 171 | tem++; |
| 171 | if (argp == old_argp) | 172 | if (argp == old_argp) |
| 172 | doup++, outend -= strlen (up); | 173 | doup++, append_len_incr = strlen (up); |
| 173 | else | 174 | else |
| 174 | doleft++, outend -= strlen (left); | 175 | doleft++, append_len_incr = strlen (left); |
| 176 | if (INT_ADD_OVERFLOW (append_len, append_len_incr)) | ||
| 177 | memory_full (SIZE_MAX); | ||
| 178 | append_len += append_len_incr; | ||
| 175 | } | 179 | } |
| 176 | } | 180 | } |
| 177 | *op++ = tem ? tem : 0200; | 181 | *op++ = tem ? tem : 0200; |
| @@ -273,7 +277,7 @@ main (int argc, char **argv) | |||
| 273 | args[0] = atoi (argv[2]); | 277 | args[0] = atoi (argv[2]); |
| 274 | args[1] = atoi (argv[3]); | 278 | args[1] = atoi (argv[3]); |
| 275 | args[2] = atoi (argv[4]); | 279 | args[2] = atoi (argv[4]); |
| 276 | tparam1 (argv[1], buf, "LEFT", "UP", args); | 280 | tparam1 (argv[1], buf, 50, "LEFT", "UP", args); |
| 277 | printf ("%s\n", buf); | 281 | printf ("%s\n", buf); |
| 278 | return 0; | 282 | return 0; |
| 279 | } | 283 | } |
diff --git a/src/unexcw.c b/src/unexcw.c index f643c196de0..62df82ec3bc 100644 --- a/src/unexcw.c +++ b/src/unexcw.c | |||
| @@ -33,6 +33,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 33 | 33 | ||
| 34 | extern int bss_sbrk_did_unexec; | 34 | extern int bss_sbrk_did_unexec; |
| 35 | 35 | ||
| 36 | extern int __malloc_initialized; | ||
| 37 | |||
| 36 | /* emacs symbols that indicate where bss and data end for emacs internals */ | 38 | /* emacs symbols that indicate where bss and data end for emacs internals */ |
| 37 | extern char my_endbss[]; | 39 | extern char my_endbss[]; |
| 38 | extern char my_edata[]; | 40 | extern char my_edata[]; |
| @@ -210,9 +212,12 @@ fixup_executable (int fd) | |||
| 210 | lseek (fd, (long) (exe_header->section_header[i].s_scnptr), | 212 | lseek (fd, (long) (exe_header->section_header[i].s_scnptr), |
| 211 | SEEK_SET); | 213 | SEEK_SET); |
| 212 | assert (ret != -1); | 214 | assert (ret != -1); |
| 215 | /* force the dumped emacs to reinitialize malloc */ | ||
| 216 | __malloc_initialized = 0; | ||
| 213 | ret = | 217 | ret = |
| 214 | write (fd, (char *) start_address, | 218 | write (fd, (char *) start_address, |
| 215 | my_endbss - (char *) start_address); | 219 | my_endbss - (char *) start_address); |
| 220 | __malloc_initialized = 1; | ||
| 216 | assert (ret == (my_endbss - (char *) start_address)); | 221 | assert (ret == (my_endbss - (char *) start_address)); |
| 217 | if (debug_unexcw) | 222 | if (debug_unexcw) |
| 218 | printf (" .bss, mem start 0x%08x mem length %d\n", | 223 | printf (" .bss, mem start 0x%08x mem length %d\n", |
diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 04e3edf463e..0751eeacb9b 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c | |||
| @@ -599,6 +599,16 @@ print_load_command_name (int lc) | |||
| 599 | printf ("LC_DYLD_INFO_ONLY"); | 599 | printf ("LC_DYLD_INFO_ONLY"); |
| 600 | break; | 600 | break; |
| 601 | #endif | 601 | #endif |
| 602 | #ifdef LC_VERSION_MIN_MACOSX | ||
| 603 | case LC_VERSION_MIN_MACOSX: | ||
| 604 | printf ("LC_VERSION_MIN_MACOSX"); | ||
| 605 | break; | ||
| 606 | #endif | ||
| 607 | #ifdef LC_FUNCTION_STARTS | ||
| 608 | case LC_FUNCTION_STARTS: | ||
| 609 | printf ("LC_FUNCTION_STARTS"); | ||
| 610 | break; | ||
| 611 | #endif | ||
| 602 | default: | 612 | default: |
| 603 | printf ("unknown "); | 613 | printf ("unknown "); |
| 604 | } | 614 | } |
| @@ -1135,6 +1145,28 @@ copy_dyld_info (struct load_command *lc, long delta) | |||
| 1135 | } | 1145 | } |
| 1136 | #endif | 1146 | #endif |
| 1137 | 1147 | ||
| 1148 | #ifdef LC_FUNCTION_STARTS | ||
| 1149 | /* Copy a LC_FUNCTION_STARTS load command from the input file to the | ||
| 1150 | output file, adjusting the data offset field. */ | ||
| 1151 | static void | ||
| 1152 | copy_linkedit_data (struct load_command *lc, long delta) | ||
| 1153 | { | ||
| 1154 | struct linkedit_data_command *ldp = (struct linkedit_data_command *) lc; | ||
| 1155 | |||
| 1156 | if (ldp->dataoff > 0) | ||
| 1157 | ldp->dataoff += delta; | ||
| 1158 | |||
| 1159 | printf ("Writing "); | ||
| 1160 | print_load_command_name (lc->cmd); | ||
| 1161 | printf (" command\n"); | ||
| 1162 | |||
| 1163 | if (!unexec_write (curr_header_offset, lc, lc->cmdsize)) | ||
| 1164 | unexec_error ("cannot write linkedit data command to header"); | ||
| 1165 | |||
| 1166 | curr_header_offset += lc->cmdsize; | ||
| 1167 | } | ||
| 1168 | #endif | ||
| 1169 | |||
| 1138 | /* Copy other kinds of load commands from the input file to the output | 1170 | /* Copy other kinds of load commands from the input file to the output |
| 1139 | file, ones that do not require adjustments of file offsets. */ | 1171 | file, ones that do not require adjustments of file offsets. */ |
| 1140 | static void | 1172 | static void |
| @@ -1207,6 +1239,11 @@ dump_it (void) | |||
| 1207 | copy_dyld_info (lca[i], linkedit_delta); | 1239 | copy_dyld_info (lca[i], linkedit_delta); |
| 1208 | break; | 1240 | break; |
| 1209 | #endif | 1241 | #endif |
| 1242 | #ifdef LC_FUNCTION_STARTS | ||
| 1243 | case LC_FUNCTION_STARTS: | ||
| 1244 | copy_linkedit_data (lca[i], linkedit_delta); | ||
| 1245 | break; | ||
| 1246 | #endif | ||
| 1210 | default: | 1247 | default: |
| 1211 | copy_other (lca[i]); | 1248 | copy_other (lca[i]); |
| 1212 | break; | 1249 | break; |
diff --git a/src/w32term.c b/src/w32term.c index b7c0d61b633..98c4a391953 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -1439,7 +1439,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | |||
| 1439 | 1439 | ||
| 1440 | Nominally, highlight colors for `3d' faces are calculated by | 1440 | Nominally, highlight colors for `3d' faces are calculated by |
| 1441 | brightening an object's color by a constant scale factor, but this | 1441 | brightening an object's color by a constant scale factor, but this |
| 1442 | doesn't yield good results for dark colors, so for colors who's | 1442 | doesn't yield good results for dark colors, so for colors whose |
| 1443 | brightness is less than this value (on a scale of 0-255) have to | 1443 | brightness is less than this value (on a scale of 0-255) have to |
| 1444 | use an additional additive factor. | 1444 | use an additional additive factor. |
| 1445 | 1445 | ||
| @@ -1618,8 +1618,9 @@ x_setup_relief_colors (struct glyph_string *s) | |||
| 1618 | 1618 | ||
| 1619 | static void | 1619 | static void |
| 1620 | w32_draw_relief_rect (struct frame *f, | 1620 | w32_draw_relief_rect (struct frame *f, |
| 1621 | int left_x, int top_y, int right_x, int bottom_y, int width, | 1621 | int left_x, int top_y, int right_x, int bottom_y, |
| 1622 | int raised_p, int top_p, int bot_p, int left_p, int right_p, | 1622 | int width, int raised_p, |
| 1623 | int top_p, int bot_p, int left_p, int right_p, | ||
| 1623 | RECT *clip_rect) | 1624 | RECT *clip_rect) |
| 1624 | { | 1625 | { |
| 1625 | int i; | 1626 | int i; |
| @@ -1880,7 +1881,8 @@ x_draw_image_relief (struct glyph_string *s) | |||
| 1880 | if (s->hl == DRAW_IMAGE_SUNKEN | 1881 | if (s->hl == DRAW_IMAGE_SUNKEN |
| 1881 | || s->hl == DRAW_IMAGE_RAISED) | 1882 | || s->hl == DRAW_IMAGE_RAISED) |
| 1882 | { | 1883 | { |
| 1883 | thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief : DEFAULT_TOOL_BAR_BUTTON_RELIEF; | 1884 | thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief |
| 1885 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF; | ||
| 1884 | raised_p = s->hl == DRAW_IMAGE_RAISED; | 1886 | raised_p = s->hl == DRAW_IMAGE_RAISED; |
| 1885 | } | 1887 | } |
| 1886 | else | 1888 | else |
| @@ -3486,7 +3488,7 @@ my_destroy_window (struct frame * f, HWND hwnd) | |||
| 3486 | 3488 | ||
| 3487 | /* Create a scroll bar and return the scroll bar vector for it. W is | 3489 | /* Create a scroll bar and return the scroll bar vector for it. W is |
| 3488 | the Emacs window on which to create the scroll bar. TOP, LEFT, | 3490 | the Emacs window on which to create the scroll bar. TOP, LEFT, |
| 3489 | WIDTH and HEIGHT are.the pixel coordinates and dimensions of the | 3491 | WIDTH and HEIGHT are the pixel coordinates and dimensions of the |
| 3490 | scroll bar. */ | 3492 | scroll bar. */ |
| 3491 | 3493 | ||
| 3492 | static struct scroll_bar * | 3494 | static struct scroll_bar * |
| @@ -3872,7 +3874,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, | |||
| 3872 | si.fMask = SIF_POS; | 3874 | si.fMask = SIF_POS; |
| 3873 | si.nPos = y; | 3875 | si.nPos = y; |
| 3874 | /* Remember apparent position (we actually lag behind the real | 3876 | /* Remember apparent position (we actually lag behind the real |
| 3875 | position, so don't set that directly. */ | 3877 | position, so don't set that directly). */ |
| 3876 | last_scroll_bar_drag_pos = y; | 3878 | last_scroll_bar_drag_pos = y; |
| 3877 | 3879 | ||
| 3878 | SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); | 3880 | SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); |
| @@ -4771,7 +4773,7 @@ w32_read_socket (struct terminal *terminal, int expected, | |||
| 4771 | pending_autoraise_frame = 0; | 4773 | pending_autoraise_frame = 0; |
| 4772 | } | 4774 | } |
| 4773 | 4775 | ||
| 4774 | /* Check which frames are still visisble, if we have enqueued any user | 4776 | /* Check which frames are still visible, if we have enqueued any user |
| 4775 | events or been notified of events that may affect visibility. We | 4777 | events or been notified of events that may affect visibility. We |
| 4776 | do this here because there doesn't seem to be any direct | 4778 | do this here because there doesn't seem to be any direct |
| 4777 | notification from Windows that the visibility of a window has | 4779 | notification from Windows that the visibility of a window has |
diff --git a/src/window.c b/src/window.c index 3f5a743f5c6..96b1144acf2 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -1379,7 +1379,7 @@ if it isn't already recorded. */) | |||
| 1379 | if (it.current_y < it.last_visible_y) | 1379 | if (it.current_y < it.last_visible_y) |
| 1380 | move_it_past_eol (&it); | 1380 | move_it_past_eol (&it); |
| 1381 | value = make_number (IT_CHARPOS (it)); | 1381 | value = make_number (IT_CHARPOS (it)); |
| 1382 | bidi_unshelve_cache (itdata); | 1382 | bidi_unshelve_cache (itdata, 0); |
| 1383 | 1383 | ||
| 1384 | if (old_buffer) | 1384 | if (old_buffer) |
| 1385 | set_buffer_internal (old_buffer); | 1385 | set_buffer_internal (old_buffer); |
| @@ -4273,7 +4273,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4273 | } | 4273 | } |
| 4274 | 4274 | ||
| 4275 | start = it.current.pos; | 4275 | start = it.current.pos; |
| 4276 | bidi_unshelve_cache (itdata); | 4276 | bidi_unshelve_cache (itdata, 0); |
| 4277 | } | 4277 | } |
| 4278 | else if (auto_window_vscroll_p) | 4278 | else if (auto_window_vscroll_p) |
| 4279 | { | 4279 | { |
| @@ -4417,7 +4417,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4417 | } | 4417 | } |
| 4418 | else | 4418 | else |
| 4419 | { | 4419 | { |
| 4420 | bidi_unshelve_cache (itdata); | 4420 | bidi_unshelve_cache (itdata, 0); |
| 4421 | if (noerror) | 4421 | if (noerror) |
| 4422 | return; | 4422 | return; |
| 4423 | else if (n < 0) /* could happen with empty buffers */ | 4423 | else if (n < 0) /* could happen with empty buffers */ |
| @@ -4434,7 +4434,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4434 | w->vscroll = 0; | 4434 | w->vscroll = 0; |
| 4435 | else | 4435 | else |
| 4436 | { | 4436 | { |
| 4437 | bidi_unshelve_cache (itdata); | 4437 | bidi_unshelve_cache (itdata, 0); |
| 4438 | if (noerror) | 4438 | if (noerror) |
| 4439 | return; | 4439 | return; |
| 4440 | else | 4440 | else |
| @@ -4583,7 +4583,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4583 | SET_PT_BOTH (charpos, bytepos); | 4583 | SET_PT_BOTH (charpos, bytepos); |
| 4584 | } | 4584 | } |
| 4585 | } | 4585 | } |
| 4586 | bidi_unshelve_cache (itdata); | 4586 | bidi_unshelve_cache (itdata, 0); |
| 4587 | } | 4587 | } |
| 4588 | 4588 | ||
| 4589 | 4589 | ||
| @@ -5010,7 +5010,7 @@ displayed_window_lines (struct window *w) | |||
| 5010 | start_display (&it, w, start); | 5010 | start_display (&it, w, start); |
| 5011 | move_it_vertically (&it, height); | 5011 | move_it_vertically (&it, height); |
| 5012 | bottom_y = line_bottom_y (&it); | 5012 | bottom_y = line_bottom_y (&it); |
| 5013 | bidi_unshelve_cache (itdata); | 5013 | bidi_unshelve_cache (itdata, 0); |
| 5014 | 5014 | ||
| 5015 | /* rms: On a non-window display, | 5015 | /* rms: On a non-window display, |
| 5016 | the value of it.vpos at the bottom of the screen | 5016 | the value of it.vpos at the bottom of the screen |
| @@ -5069,7 +5069,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5069 | && (!EQ (Vrecenter_redisplay, Qtty) | 5069 | && (!EQ (Vrecenter_redisplay, Qtty) |
| 5070 | || !NILP (Ftty_type (selected_frame)))) | 5070 | || !NILP (Ftty_type (selected_frame)))) |
| 5071 | { | 5071 | { |
| 5072 | int i; | 5072 | ptrdiff_t i; |
| 5073 | 5073 | ||
| 5074 | /* Invalidate pixel data calculated for all compositions. */ | 5074 | /* Invalidate pixel data calculated for all compositions. */ |
| 5075 | for (i = 0; i < n_compositions; i++) | 5075 | for (i = 0; i < n_compositions; i++) |
| @@ -5116,7 +5116,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5116 | move_it_vertically_backward (&it, window_box_height (w) / 2); | 5116 | move_it_vertically_backward (&it, window_box_height (w) / 2); |
| 5117 | charpos = IT_CHARPOS (it); | 5117 | charpos = IT_CHARPOS (it); |
| 5118 | bytepos = IT_BYTEPOS (it); | 5118 | bytepos = IT_BYTEPOS (it); |
| 5119 | bidi_unshelve_cache (itdata); | 5119 | bidi_unshelve_cache (itdata, 0); |
| 5120 | } | 5120 | } |
| 5121 | else if (iarg < 0) | 5121 | else if (iarg < 0) |
| 5122 | { | 5122 | { |
| @@ -5164,7 +5164,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5164 | } | 5164 | } |
| 5165 | if (h <= 0) | 5165 | if (h <= 0) |
| 5166 | { | 5166 | { |
| 5167 | bidi_unshelve_cache (itdata); | 5167 | bidi_unshelve_cache (itdata, 0); |
| 5168 | return Qnil; | 5168 | return Qnil; |
| 5169 | } | 5169 | } |
| 5170 | 5170 | ||
| @@ -5187,7 +5187,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5187 | charpos = IT_CHARPOS (it); | 5187 | charpos = IT_CHARPOS (it); |
| 5188 | bytepos = IT_BYTEPOS (it); | 5188 | bytepos = IT_BYTEPOS (it); |
| 5189 | 5189 | ||
| 5190 | bidi_unshelve_cache (itdata); | 5190 | bidi_unshelve_cache (itdata, 0); |
| 5191 | } | 5191 | } |
| 5192 | else | 5192 | else |
| 5193 | { | 5193 | { |
diff --git a/src/xdisp.c b/src/xdisp.c index 84c75bd91d9..1716cc82188 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -604,7 +604,7 @@ int current_mode_line_height, current_header_line_height; | |||
| 604 | #define SAVE_IT(ITCOPY,ITORIG,CACHE) \ | 604 | #define SAVE_IT(ITCOPY,ITORIG,CACHE) \ |
| 605 | do { \ | 605 | do { \ |
| 606 | if (CACHE) \ | 606 | if (CACHE) \ |
| 607 | xfree (CACHE); \ | 607 | bidi_unshelve_cache (CACHE, 1); \ |
| 608 | ITCOPY = ITORIG; \ | 608 | ITCOPY = ITORIG; \ |
| 609 | CACHE = bidi_shelve_cache(); \ | 609 | CACHE = bidi_shelve_cache(); \ |
| 610 | } while (0) | 610 | } while (0) |
| @@ -613,7 +613,7 @@ int current_mode_line_height, current_header_line_height; | |||
| 613 | do { \ | 613 | do { \ |
| 614 | if (pITORIG != pITCOPY) \ | 614 | if (pITORIG != pITCOPY) \ |
| 615 | *(pITORIG) = *(pITCOPY); \ | 615 | *(pITORIG) = *(pITCOPY); \ |
| 616 | bidi_unshelve_cache (CACHE); \ | 616 | bidi_unshelve_cache (CACHE, 0); \ |
| 617 | CACHE = NULL; \ | 617 | CACHE = NULL; \ |
| 618 | } while (0) | 618 | } while (0) |
| 619 | 619 | ||
| @@ -899,7 +899,7 @@ static void init_to_row_start (struct it *, struct window *, | |||
| 899 | static int init_to_row_end (struct it *, struct window *, | 899 | static int init_to_row_end (struct it *, struct window *, |
| 900 | struct glyph_row *); | 900 | struct glyph_row *); |
| 901 | static void back_to_previous_line_start (struct it *); | 901 | static void back_to_previous_line_start (struct it *); |
| 902 | static int forward_to_next_line_start (struct it *, int *); | 902 | static int forward_to_next_line_start (struct it *, int *, struct bidi_it *); |
| 903 | static struct text_pos string_pos_nchars_ahead (struct text_pos, | 903 | static struct text_pos string_pos_nchars_ahead (struct text_pos, |
| 904 | Lisp_Object, EMACS_INT); | 904 | Lisp_Object, EMACS_INT); |
| 905 | static struct text_pos string_pos (EMACS_INT, Lisp_Object); | 905 | static struct text_pos string_pos (EMACS_INT, Lisp_Object); |
| @@ -1341,9 +1341,9 @@ pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y, | |||
| 1341 | *vpos = it2.vpos; | 1341 | *vpos = it2.vpos; |
| 1342 | } | 1342 | } |
| 1343 | else | 1343 | else |
| 1344 | xfree (it2data); | 1344 | bidi_unshelve_cache (it2data, 1); |
| 1345 | } | 1345 | } |
| 1346 | bidi_unshelve_cache (itdata); | 1346 | bidi_unshelve_cache (itdata, 0); |
| 1347 | 1347 | ||
| 1348 | if (old_buffer) | 1348 | if (old_buffer) |
| 1349 | set_buffer_internal_1 (old_buffer); | 1349 | set_buffer_internal_1 (old_buffer); |
| @@ -2478,10 +2478,7 @@ init_iterator (struct it *it, struct window *w, | |||
| 2478 | else if (INTEGERP (w->redisplay_end_trigger)) | 2478 | else if (INTEGERP (w->redisplay_end_trigger)) |
| 2479 | it->redisplay_end_trigger_charpos = XINT (w->redisplay_end_trigger); | 2479 | it->redisplay_end_trigger_charpos = XINT (w->redisplay_end_trigger); |
| 2480 | 2480 | ||
| 2481 | /* Correct bogus values of tab_width. */ | 2481 | it->tab_width = SANE_TAB_WIDTH (current_buffer); |
| 2482 | it->tab_width = XINT (BVAR (current_buffer, tab_width)); | ||
| 2483 | if (it->tab_width <= 0 || it->tab_width > 1000) | ||
| 2484 | it->tab_width = 8; | ||
| 2485 | 2482 | ||
| 2486 | /* Are lines in the display truncated? */ | 2483 | /* Are lines in the display truncated? */ |
| 2487 | if (base_face_id != DEFAULT_FACE_ID | 2484 | if (base_face_id != DEFAULT_FACE_ID |
| @@ -2627,7 +2624,7 @@ init_iterator (struct it *it, struct window *w, | |||
| 2627 | it->paragraph_embedding = R2L; | 2624 | it->paragraph_embedding = R2L; |
| 2628 | else | 2625 | else |
| 2629 | it->paragraph_embedding = NEUTRAL_DIR; | 2626 | it->paragraph_embedding = NEUTRAL_DIR; |
| 2630 | bidi_unshelve_cache (NULL); | 2627 | bidi_unshelve_cache (NULL, 0); |
| 2631 | bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), | 2628 | bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), |
| 2632 | &it->bidi_it); | 2629 | &it->bidi_it); |
| 2633 | } | 2630 | } |
| @@ -3134,13 +3131,10 @@ next_overlay_change (EMACS_INT pos) | |||
| 3134 | return endpos; | 3131 | return endpos; |
| 3135 | } | 3132 | } |
| 3136 | 3133 | ||
| 3137 | /* Record one cached display string position found recently by | 3134 | /* How many characters forward to search for a display property or |
| 3138 | compute_display_string_pos. */ | 3135 | display string. Enough for a screenful of 100 lines x 50 |
| 3139 | static EMACS_INT cached_disp_pos; | 3136 | characters in a line. */ |
| 3140 | static EMACS_INT cached_prev_pos = -1; | 3137 | #define MAX_DISP_SCAN 5000 |
| 3141 | static struct buffer *cached_disp_buffer; | ||
| 3142 | static int cached_disp_modiff; | ||
| 3143 | static int cached_disp_overlay_modiff; | ||
| 3144 | 3138 | ||
| 3145 | /* Return the character position of a display string at or after | 3139 | /* Return the character position of a display string at or after |
| 3146 | position specified by POSITION. If no display string exists at or | 3140 | position specified by POSITION. If no display string exists at or |
| @@ -3149,21 +3143,30 @@ static int cached_disp_overlay_modiff; | |||
| 3149 | text property whose value is a string. STRING is data about the | 3143 | text property whose value is a string. STRING is data about the |
| 3150 | string to iterate; if STRING->lstring is nil, we are iterating a | 3144 | string to iterate; if STRING->lstring is nil, we are iterating a |
| 3151 | buffer. FRAME_WINDOW_P is non-zero when we are displaying a window | 3145 | buffer. FRAME_WINDOW_P is non-zero when we are displaying a window |
| 3152 | on a GUI frame. */ | 3146 | on a GUI frame. DISP_PROP is set to zero if we searched |
| 3147 | MAX_DISP_SCAN characters forward without finding any display | ||
| 3148 | strings, non-zero otherwise. It is set to 2 if the display string | ||
| 3149 | uses any kind of `(space ...)' spec that will produce a stretch of | ||
| 3150 | white space in the text area. */ | ||
| 3153 | EMACS_INT | 3151 | EMACS_INT |
| 3154 | compute_display_string_pos (struct text_pos *position, | 3152 | compute_display_string_pos (struct text_pos *position, |
| 3155 | struct bidi_string_data *string, int frame_window_p) | 3153 | struct bidi_string_data *string, |
| 3154 | int frame_window_p, int *disp_prop) | ||
| 3156 | { | 3155 | { |
| 3157 | /* OBJECT = nil means current buffer. */ | 3156 | /* OBJECT = nil means current buffer. */ |
| 3158 | Lisp_Object object = | 3157 | Lisp_Object object = |
| 3159 | (string && STRINGP (string->lstring)) ? string->lstring : Qnil; | 3158 | (string && STRINGP (string->lstring)) ? string->lstring : Qnil; |
| 3160 | Lisp_Object pos, spec; | 3159 | Lisp_Object pos, spec, limpos; |
| 3161 | int string_p = (string && (STRINGP (string->lstring) || string->s)); | 3160 | int string_p = (string && (STRINGP (string->lstring) || string->s)); |
| 3162 | EMACS_INT eob = string_p ? string->schars : ZV; | 3161 | EMACS_INT eob = string_p ? string->schars : ZV; |
| 3163 | EMACS_INT begb = string_p ? 0 : BEGV; | 3162 | EMACS_INT begb = string_p ? 0 : BEGV; |
| 3164 | EMACS_INT bufpos, charpos = CHARPOS (*position); | 3163 | EMACS_INT bufpos, charpos = CHARPOS (*position); |
| 3164 | EMACS_INT lim = | ||
| 3165 | (charpos < eob - MAX_DISP_SCAN) ? charpos + MAX_DISP_SCAN : eob; | ||
| 3165 | struct text_pos tpos; | 3166 | struct text_pos tpos; |
| 3166 | struct buffer *b; | 3167 | int rv = 0; |
| 3168 | |||
| 3169 | *disp_prop = 1; | ||
| 3167 | 3170 | ||
| 3168 | if (charpos >= eob | 3171 | if (charpos >= eob |
| 3169 | /* We don't support display properties whose values are strings | 3172 | /* We don't support display properties whose values are strings |
| @@ -3171,38 +3174,9 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3171 | || string->from_disp_str | 3174 | || string->from_disp_str |
| 3172 | /* C strings cannot have display properties. */ | 3175 | /* C strings cannot have display properties. */ |
| 3173 | || (string->s && !STRINGP (object))) | 3176 | || (string->s && !STRINGP (object))) |
| 3174 | return eob; | ||
| 3175 | |||
| 3176 | /* Check the cached values. */ | ||
| 3177 | if (!STRINGP (object)) | ||
| 3178 | { | 3177 | { |
| 3179 | if (NILP (object)) | 3178 | *disp_prop = 0; |
| 3180 | b = current_buffer; | 3179 | return eob; |
| 3181 | else | ||
| 3182 | b = XBUFFER (object); | ||
| 3183 | if (b == cached_disp_buffer | ||
| 3184 | && BUF_MODIFF (b) == cached_disp_modiff | ||
| 3185 | && BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff | ||
| 3186 | && !b->clip_changed) | ||
| 3187 | { | ||
| 3188 | if (cached_prev_pos >= 0 | ||
| 3189 | && cached_prev_pos < charpos && charpos <= cached_disp_pos) | ||
| 3190 | return cached_disp_pos; | ||
| 3191 | /* Handle overstepping either end of the known interval. */ | ||
| 3192 | if (charpos > cached_disp_pos) | ||
| 3193 | cached_prev_pos = cached_disp_pos; | ||
| 3194 | else /* charpos <= cached_prev_pos */ | ||
| 3195 | cached_prev_pos = max (charpos - 1, 0); | ||
| 3196 | } | ||
| 3197 | |||
| 3198 | /* Record new values in the cache. */ | ||
| 3199 | if (b != cached_disp_buffer) | ||
| 3200 | { | ||
| 3201 | cached_disp_buffer = b; | ||
| 3202 | cached_prev_pos = max (charpos - 1, 0); | ||
| 3203 | } | ||
| 3204 | cached_disp_modiff = BUF_MODIFF (b); | ||
| 3205 | cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b); | ||
| 3206 | } | 3180 | } |
| 3207 | 3181 | ||
| 3208 | /* If the character at CHARPOS is where the display string begins, | 3182 | /* If the character at CHARPOS is where the display string begins, |
| @@ -3218,34 +3192,38 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3218 | || !EQ (Fget_char_property (make_number (charpos - 1), Qdisplay, | 3192 | || !EQ (Fget_char_property (make_number (charpos - 1), Qdisplay, |
| 3219 | object), | 3193 | object), |
| 3220 | spec)) | 3194 | spec)) |
| 3221 | && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, | 3195 | && (rv = handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, |
| 3222 | frame_window_p)) | 3196 | frame_window_p))) |
| 3223 | { | 3197 | { |
| 3224 | if (!STRINGP (object)) | 3198 | if (rv == 2) |
| 3225 | cached_disp_pos = charpos; | 3199 | *disp_prop = 2; |
| 3226 | return charpos; | 3200 | return charpos; |
| 3227 | } | 3201 | } |
| 3228 | 3202 | ||
| 3229 | /* Look forward for the first character with a `display' property | 3203 | /* Look forward for the first character with a `display' property |
| 3230 | that will replace the underlying text when displayed. */ | 3204 | that will replace the underlying text when displayed. */ |
| 3205 | limpos = make_number (lim); | ||
| 3231 | do { | 3206 | do { |
| 3232 | pos = Fnext_single_char_property_change (pos, Qdisplay, object, Qnil); | 3207 | pos = Fnext_single_char_property_change (pos, Qdisplay, object, limpos); |
| 3233 | CHARPOS (tpos) = XFASTINT (pos); | 3208 | CHARPOS (tpos) = XFASTINT (pos); |
| 3209 | if (CHARPOS (tpos) >= lim) | ||
| 3210 | { | ||
| 3211 | *disp_prop = 0; | ||
| 3212 | break; | ||
| 3213 | } | ||
| 3234 | if (STRINGP (object)) | 3214 | if (STRINGP (object)) |
| 3235 | BYTEPOS (tpos) = string_char_to_byte (object, CHARPOS (tpos)); | 3215 | BYTEPOS (tpos) = string_char_to_byte (object, CHARPOS (tpos)); |
| 3236 | else | 3216 | else |
| 3237 | BYTEPOS (tpos) = CHAR_TO_BYTE (CHARPOS (tpos)); | 3217 | BYTEPOS (tpos) = CHAR_TO_BYTE (CHARPOS (tpos)); |
| 3238 | if (CHARPOS (tpos) >= eob) | ||
| 3239 | break; | ||
| 3240 | spec = Fget_char_property (pos, Qdisplay, object); | 3218 | spec = Fget_char_property (pos, Qdisplay, object); |
| 3241 | if (!STRINGP (object)) | 3219 | if (!STRINGP (object)) |
| 3242 | bufpos = CHARPOS (tpos); | 3220 | bufpos = CHARPOS (tpos); |
| 3243 | } while (NILP (spec) | 3221 | } while (NILP (spec) |
| 3244 | || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, | 3222 | || !(rv = handle_display_spec (NULL, spec, object, Qnil, &tpos, |
| 3245 | frame_window_p)); | 3223 | bufpos, frame_window_p))); |
| 3224 | if (rv == 2) | ||
| 3225 | *disp_prop = 2; | ||
| 3246 | 3226 | ||
| 3247 | if (!STRINGP (object)) | ||
| 3248 | cached_disp_pos = CHARPOS (tpos); | ||
| 3249 | return CHARPOS (tpos); | 3227 | return CHARPOS (tpos); |
| 3250 | } | 3228 | } |
| 3251 | 3229 | ||
| @@ -4106,7 +4084,9 @@ handle_display_prop (struct it *it) | |||
| 4106 | /* Subroutine of handle_display_prop. Returns non-zero if the display | 4084 | /* Subroutine of handle_display_prop. Returns non-zero if the display |
| 4107 | specification in SPEC is a replacing specification, i.e. it would | 4085 | specification in SPEC is a replacing specification, i.e. it would |
| 4108 | replace the text covered by `display' property with something else, | 4086 | replace the text covered by `display' property with something else, |
| 4109 | such as an image or a display string. | 4087 | such as an image or a display string. If SPEC includes any kind or |
| 4088 | `(space ...) specification, the value is 2; this is used by | ||
| 4089 | compute_display_string_pos, which see. | ||
| 4110 | 4090 | ||
| 4111 | See handle_single_display_spec for documentation of arguments. | 4091 | See handle_single_display_spec for documentation of arguments. |
| 4112 | frame_window_p is non-zero if the window being redisplayed is on a | 4092 | frame_window_p is non-zero if the window being redisplayed is on a |
| @@ -4123,6 +4103,7 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4123 | EMACS_INT bufpos, int frame_window_p) | 4103 | EMACS_INT bufpos, int frame_window_p) |
| 4124 | { | 4104 | { |
| 4125 | int replacing_p = 0; | 4105 | int replacing_p = 0; |
| 4106 | int rv; | ||
| 4126 | 4107 | ||
| 4127 | if (CONSP (spec) | 4108 | if (CONSP (spec) |
| 4128 | /* Simple specerties. */ | 4109 | /* Simple specerties. */ |
| @@ -4141,11 +4122,11 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4141 | { | 4122 | { |
| 4142 | for (; CONSP (spec); spec = XCDR (spec)) | 4123 | for (; CONSP (spec); spec = XCDR (spec)) |
| 4143 | { | 4124 | { |
| 4144 | if (handle_single_display_spec (it, XCAR (spec), object, overlay, | 4125 | if ((rv = handle_single_display_spec (it, XCAR (spec), object, |
| 4145 | position, bufpos, replacing_p, | 4126 | overlay, position, bufpos, |
| 4146 | frame_window_p)) | 4127 | replacing_p, frame_window_p))) |
| 4147 | { | 4128 | { |
| 4148 | replacing_p = 1; | 4129 | replacing_p = rv; |
| 4149 | /* If some text in a string is replaced, `position' no | 4130 | /* If some text in a string is replaced, `position' no |
| 4150 | longer points to the position of `object'. */ | 4131 | longer points to the position of `object'. */ |
| 4151 | if (!it || STRINGP (object)) | 4132 | if (!it || STRINGP (object)) |
| @@ -4157,11 +4138,11 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4157 | { | 4138 | { |
| 4158 | int i; | 4139 | int i; |
| 4159 | for (i = 0; i < ASIZE (spec); ++i) | 4140 | for (i = 0; i < ASIZE (spec); ++i) |
| 4160 | if (handle_single_display_spec (it, AREF (spec, i), object, overlay, | 4141 | if ((rv = handle_single_display_spec (it, AREF (spec, i), object, |
| 4161 | position, bufpos, replacing_p, | 4142 | overlay, position, bufpos, |
| 4162 | frame_window_p)) | 4143 | replacing_p, frame_window_p))) |
| 4163 | { | 4144 | { |
| 4164 | replacing_p = 1; | 4145 | replacing_p = rv; |
| 4165 | /* If some text in a string is replaced, `position' no | 4146 | /* If some text in a string is replaced, `position' no |
| 4166 | longer points to the position of `object'. */ | 4147 | longer points to the position of `object'. */ |
| 4167 | if (!it || STRINGP (object)) | 4148 | if (!it || STRINGP (object)) |
| @@ -4170,9 +4151,10 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4170 | } | 4151 | } |
| 4171 | else | 4152 | else |
| 4172 | { | 4153 | { |
| 4173 | if (handle_single_display_spec (it, spec, object, overlay, | 4154 | if ((rv = handle_single_display_spec (it, spec, object, overlay, |
| 4174 | position, bufpos, 0, frame_window_p)) | 4155 | position, bufpos, 0, |
| 4175 | replacing_p = 1; | 4156 | frame_window_p))) |
| 4157 | replacing_p = rv; | ||
| 4176 | } | 4158 | } |
| 4177 | 4159 | ||
| 4178 | return replacing_p; | 4160 | return replacing_p; |
| @@ -4548,8 +4530,17 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4548 | 4530 | ||
| 4549 | if (valid_p && !display_replaced_p) | 4531 | if (valid_p && !display_replaced_p) |
| 4550 | { | 4532 | { |
| 4533 | int retval = 1; | ||
| 4534 | |||
| 4551 | if (!it) | 4535 | if (!it) |
| 4552 | return 1; | 4536 | { |
| 4537 | /* Callers need to know whether the display spec is any kind | ||
| 4538 | of `(space ...)' spec that is about to affect text-area | ||
| 4539 | display. */ | ||
| 4540 | if (CONSP (value) && EQ (XCAR (value), Qspace) && NILP (location)) | ||
| 4541 | retval = 2; | ||
| 4542 | return retval; | ||
| 4543 | } | ||
| 4553 | 4544 | ||
| 4554 | /* Save current settings of IT so that we can restore them | 4545 | /* Save current settings of IT so that we can restore them |
| 4555 | when we are finished with the glyph property value. */ | 4546 | when we are finished with the glyph property value. */ |
| @@ -4607,6 +4598,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4607 | it->method = GET_FROM_STRETCH; | 4598 | it->method = GET_FROM_STRETCH; |
| 4608 | it->object = value; | 4599 | it->object = value; |
| 4609 | *position = it->position = start_pos; | 4600 | *position = it->position = start_pos; |
| 4601 | retval = 1 + (it->area == TEXT_AREA); | ||
| 4610 | } | 4602 | } |
| 4611 | #ifdef HAVE_WINDOW_SYSTEM | 4603 | #ifdef HAVE_WINDOW_SYSTEM |
| 4612 | else | 4604 | else |
| @@ -4624,7 +4616,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4624 | } | 4616 | } |
| 4625 | #endif /* HAVE_WINDOW_SYSTEM */ | 4617 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 4626 | 4618 | ||
| 4627 | return 1; | 4619 | return retval; |
| 4628 | } | 4620 | } |
| 4629 | 4621 | ||
| 4630 | /* Invalid property or property not supported. Restore | 4622 | /* Invalid property or property not supported. Restore |
| @@ -5354,6 +5346,8 @@ iterate_out_of_display_property (struct it *it) | |||
| 5354 | EMACS_INT eob = (buffer_p ? ZV : it->end_charpos); | 5346 | EMACS_INT eob = (buffer_p ? ZV : it->end_charpos); |
| 5355 | EMACS_INT bob = (buffer_p ? BEGV : 0); | 5347 | EMACS_INT bob = (buffer_p ? BEGV : 0); |
| 5356 | 5348 | ||
| 5349 | xassert (eob >= CHARPOS (it->position) && CHARPOS (it->position) >= bob); | ||
| 5350 | |||
| 5357 | /* Maybe initialize paragraph direction. If we are at the beginning | 5351 | /* Maybe initialize paragraph direction. If we are at the beginning |
| 5358 | of a new paragraph, next_element_from_buffer may not have a | 5352 | of a new paragraph, next_element_from_buffer may not have a |
| 5359 | chance to do that. */ | 5353 | chance to do that. */ |
| @@ -5362,7 +5356,8 @@ iterate_out_of_display_property (struct it *it) | |||
| 5362 | /* prev_stop can be zero, so check against BEGV as well. */ | 5356 | /* prev_stop can be zero, so check against BEGV as well. */ |
| 5363 | while (it->bidi_it.charpos >= bob | 5357 | while (it->bidi_it.charpos >= bob |
| 5364 | && it->prev_stop <= it->bidi_it.charpos | 5358 | && it->prev_stop <= it->bidi_it.charpos |
| 5365 | && it->bidi_it.charpos < CHARPOS (it->position)) | 5359 | && it->bidi_it.charpos < CHARPOS (it->position) |
| 5360 | && it->bidi_it.charpos < eob) | ||
| 5366 | bidi_move_to_visually_next (&it->bidi_it); | 5361 | bidi_move_to_visually_next (&it->bidi_it); |
| 5367 | /* Record the stop_pos we just crossed, for when we cross it | 5362 | /* Record the stop_pos we just crossed, for when we cross it |
| 5368 | back, maybe. */ | 5363 | back, maybe. */ |
| @@ -5371,14 +5366,11 @@ iterate_out_of_display_property (struct it *it) | |||
| 5371 | /* If we ended up not where pop_it put us, resync IT's | 5366 | /* If we ended up not where pop_it put us, resync IT's |
| 5372 | positional members with the bidi iterator. */ | 5367 | positional members with the bidi iterator. */ |
| 5373 | if (it->bidi_it.charpos != CHARPOS (it->position)) | 5368 | if (it->bidi_it.charpos != CHARPOS (it->position)) |
| 5374 | { | 5369 | SET_TEXT_POS (it->position, it->bidi_it.charpos, it->bidi_it.bytepos); |
| 5375 | SET_TEXT_POS (it->position, | 5370 | if (buffer_p) |
| 5376 | it->bidi_it.charpos, it->bidi_it.bytepos); | 5371 | it->current.pos = it->position; |
| 5377 | if (buffer_p) | 5372 | else |
| 5378 | it->current.pos = it->position; | 5373 | it->current.string_pos = it->position; |
| 5379 | else | ||
| 5380 | it->current.string_pos = it->position; | ||
| 5381 | } | ||
| 5382 | } | 5374 | } |
| 5383 | 5375 | ||
| 5384 | /* Restore IT's settings from IT->stack. Called, for example, when no | 5376 | /* Restore IT's settings from IT->stack. Called, for example, when no |
| @@ -5494,6 +5486,9 @@ back_to_previous_line_start (struct it *it) | |||
| 5494 | continuously over the text). Otherwise, don't change the value | 5486 | continuously over the text). Otherwise, don't change the value |
| 5495 | of *SKIPPED_P. | 5487 | of *SKIPPED_P. |
| 5496 | 5488 | ||
| 5489 | If BIDI_IT_PREV is non-NULL, store into it the state of the bidi | ||
| 5490 | iterator on the newline, if it was found. | ||
| 5491 | |||
| 5497 | Newlines may come from buffer text, overlay strings, or strings | 5492 | Newlines may come from buffer text, overlay strings, or strings |
| 5498 | displayed via the `display' property. That's the reason we can't | 5493 | displayed via the `display' property. That's the reason we can't |
| 5499 | simply use find_next_newline_no_quit. | 5494 | simply use find_next_newline_no_quit. |
| @@ -5506,7 +5501,8 @@ back_to_previous_line_start (struct it *it) | |||
| 5506 | leads to wrong cursor motion. */ | 5501 | leads to wrong cursor motion. */ |
| 5507 | 5502 | ||
| 5508 | static int | 5503 | static int |
| 5509 | forward_to_next_line_start (struct it *it, int *skipped_p) | 5504 | forward_to_next_line_start (struct it *it, int *skipped_p, |
| 5505 | struct bidi_it *bidi_it_prev) | ||
| 5510 | { | 5506 | { |
| 5511 | EMACS_INT old_selective; | 5507 | EMACS_INT old_selective; |
| 5512 | int newline_found_p, n; | 5508 | int newline_found_p, n; |
| @@ -5518,6 +5514,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p) | |||
| 5518 | && it->c == '\n' | 5514 | && it->c == '\n' |
| 5519 | && CHARPOS (it->position) == IT_CHARPOS (*it)) | 5515 | && CHARPOS (it->position) == IT_CHARPOS (*it)) |
| 5520 | { | 5516 | { |
| 5517 | if (it->bidi_p && bidi_it_prev) | ||
| 5518 | *bidi_it_prev = it->bidi_it; | ||
| 5521 | set_iterator_to_next (it, 0); | 5519 | set_iterator_to_next (it, 0); |
| 5522 | it->c = 0; | 5520 | it->c = 0; |
| 5523 | return 1; | 5521 | return 1; |
| @@ -5539,6 +5537,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p) | |||
| 5539 | if (!get_next_display_element (it)) | 5537 | if (!get_next_display_element (it)) |
| 5540 | return 0; | 5538 | return 0; |
| 5541 | newline_found_p = it->what == IT_CHARACTER && it->c == '\n'; | 5539 | newline_found_p = it->what == IT_CHARACTER && it->c == '\n'; |
| 5540 | if (newline_found_p && it->bidi_p && bidi_it_prev) | ||
| 5541 | *bidi_it_prev = it->bidi_it; | ||
| 5542 | set_iterator_to_next (it, 0); | 5542 | set_iterator_to_next (it, 0); |
| 5543 | } | 5543 | } |
| 5544 | 5544 | ||
| @@ -5552,19 +5552,42 @@ forward_to_next_line_start (struct it *it, int *skipped_p) | |||
| 5552 | 5552 | ||
| 5553 | xassert (!STRINGP (it->string)); | 5553 | xassert (!STRINGP (it->string)); |
| 5554 | 5554 | ||
| 5555 | /* If we are not bidi-reordering, and there isn't any `display' | 5555 | /* If there isn't any `display' property in sight, and no |
| 5556 | property in sight, and no overlays, we can just use the | 5556 | overlays, we can just use the position of the newline in |
| 5557 | position of the newline in buffer text. */ | 5557 | buffer text. */ |
| 5558 | if (!it->bidi_p | 5558 | if (it->stop_charpos >= limit |
| 5559 | && (it->stop_charpos >= limit | 5559 | || ((pos = Fnext_single_property_change (make_number (start), |
| 5560 | || ((pos = Fnext_single_property_change (make_number (start), | 5560 | Qdisplay, Qnil, |
| 5561 | Qdisplay, Qnil, | 5561 | make_number (limit)), |
| 5562 | make_number (limit)), | 5562 | NILP (pos)) |
| 5563 | NILP (pos)) | 5563 | && next_overlay_change (start) == ZV)) |
| 5564 | && next_overlay_change (start) == ZV))) | 5564 | { |
| 5565 | { | 5565 | if (!it->bidi_p) |
| 5566 | IT_CHARPOS (*it) = limit; | 5566 | { |
| 5567 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (limit); | 5567 | IT_CHARPOS (*it) = limit; |
| 5568 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (limit); | ||
| 5569 | } | ||
| 5570 | else | ||
| 5571 | { | ||
| 5572 | struct bidi_it bprev; | ||
| 5573 | |||
| 5574 | /* Help bidi.c avoid expensive searches for display | ||
| 5575 | properties and overlays, by telling it that there are | ||
| 5576 | none up to `limit'. */ | ||
| 5577 | if (it->bidi_it.disp_pos < limit) | ||
| 5578 | { | ||
| 5579 | it->bidi_it.disp_pos = limit; | ||
| 5580 | it->bidi_it.disp_prop = 0; | ||
| 5581 | } | ||
| 5582 | do { | ||
| 5583 | bprev = it->bidi_it; | ||
| 5584 | bidi_move_to_visually_next (&it->bidi_it); | ||
| 5585 | } while (it->bidi_it.charpos != limit); | ||
| 5586 | IT_CHARPOS (*it) = limit; | ||
| 5587 | IT_BYTEPOS (*it) = it->bidi_it.bytepos; | ||
| 5588 | if (bidi_it_prev) | ||
| 5589 | *bidi_it_prev = bprev; | ||
| 5590 | } | ||
| 5568 | *skipped_p = newline_found_p = 1; | 5591 | *skipped_p = newline_found_p = 1; |
| 5569 | } | 5592 | } |
| 5570 | else | 5593 | else |
| @@ -5573,6 +5596,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p) | |||
| 5573 | && !newline_found_p) | 5596 | && !newline_found_p) |
| 5574 | { | 5597 | { |
| 5575 | newline_found_p = ITERATOR_AT_END_OF_LINE_P (it); | 5598 | newline_found_p = ITERATOR_AT_END_OF_LINE_P (it); |
| 5599 | if (newline_found_p && it->bidi_p && bidi_it_prev) | ||
| 5600 | *bidi_it_prev = it->bidi_it; | ||
| 5576 | set_iterator_to_next (it, 0); | 5601 | set_iterator_to_next (it, 0); |
| 5577 | } | 5602 | } |
| 5578 | } | 5603 | } |
| @@ -5636,7 +5661,7 @@ back_to_previous_visible_line_start (struct it *it) | |||
| 5636 | pos = --IT_CHARPOS (it2); | 5661 | pos = --IT_CHARPOS (it2); |
| 5637 | --IT_BYTEPOS (it2); | 5662 | --IT_BYTEPOS (it2); |
| 5638 | it2.sp = 0; | 5663 | it2.sp = 0; |
| 5639 | bidi_unshelve_cache (NULL); | 5664 | bidi_unshelve_cache (NULL, 0); |
| 5640 | it2.string_from_display_prop_p = 0; | 5665 | it2.string_from_display_prop_p = 0; |
| 5641 | it2.from_disp_prop_p = 0; | 5666 | it2.from_disp_prop_p = 0; |
| 5642 | if (handle_display_prop (&it2) == HANDLED_RETURN | 5667 | if (handle_display_prop (&it2) == HANDLED_RETURN |
| @@ -5696,8 +5721,9 @@ static void | |||
| 5696 | reseat_at_next_visible_line_start (struct it *it, int on_newline_p) | 5721 | reseat_at_next_visible_line_start (struct it *it, int on_newline_p) |
| 5697 | { | 5722 | { |
| 5698 | int newline_found_p, skipped_p = 0; | 5723 | int newline_found_p, skipped_p = 0; |
| 5724 | struct bidi_it bidi_it_prev; | ||
| 5699 | 5725 | ||
| 5700 | newline_found_p = forward_to_next_line_start (it, &skipped_p); | 5726 | newline_found_p = forward_to_next_line_start (it, &skipped_p, &bidi_it_prev); |
| 5701 | 5727 | ||
| 5702 | /* Skip over lines that are invisible because they are indented | 5728 | /* Skip over lines that are invisible because they are indented |
| 5703 | more than the value of IT->selective. */ | 5729 | more than the value of IT->selective. */ |
| @@ -5708,7 +5734,8 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p) | |||
| 5708 | { | 5734 | { |
| 5709 | xassert (IT_BYTEPOS (*it) == BEGV | 5735 | xassert (IT_BYTEPOS (*it) == BEGV |
| 5710 | || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n'); | 5736 | || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n'); |
| 5711 | newline_found_p = forward_to_next_line_start (it, &skipped_p); | 5737 | newline_found_p = |
| 5738 | forward_to_next_line_start (it, &skipped_p, &bidi_it_prev); | ||
| 5712 | } | 5739 | } |
| 5713 | 5740 | ||
| 5714 | /* Position on the newline if that's what's requested. */ | 5741 | /* Position on the newline if that's what's requested. */ |
| @@ -5724,11 +5751,14 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p) | |||
| 5724 | --IT_STRING_BYTEPOS (*it); | 5751 | --IT_STRING_BYTEPOS (*it); |
| 5725 | } | 5752 | } |
| 5726 | else | 5753 | else |
| 5727 | /* Setting this flag will cause | 5754 | { |
| 5728 | bidi_move_to_visually_next not to advance, but | 5755 | /* We need to restore the bidi iterator to the state |
| 5729 | instead deliver the current character (newline), | 5756 | it had on the newline, and resync the IT's |
| 5730 | which is what the ON_NEWLINE_P flag wants. */ | 5757 | position with that. */ |
| 5731 | it->bidi_it.first_elt = 1; | 5758 | it->bidi_it = bidi_it_prev; |
| 5759 | IT_STRING_CHARPOS (*it) = it->bidi_it.charpos; | ||
| 5760 | IT_STRING_BYTEPOS (*it) = it->bidi_it.bytepos; | ||
| 5761 | } | ||
| 5732 | } | 5762 | } |
| 5733 | } | 5763 | } |
| 5734 | else if (IT_CHARPOS (*it) > BEGV) | 5764 | else if (IT_CHARPOS (*it) > BEGV) |
| @@ -5738,9 +5768,14 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p) | |||
| 5738 | --IT_CHARPOS (*it); | 5768 | --IT_CHARPOS (*it); |
| 5739 | --IT_BYTEPOS (*it); | 5769 | --IT_BYTEPOS (*it); |
| 5740 | } | 5770 | } |
| 5741 | /* With bidi iteration, the call to `reseat' will cause | 5771 | else |
| 5742 | bidi_move_to_visually_next deliver the current character, | 5772 | { |
| 5743 | the newline, instead of advancing. */ | 5773 | /* We need to restore the bidi iterator to the state it |
| 5774 | had on the newline and resync IT with that. */ | ||
| 5775 | it->bidi_it = bidi_it_prev; | ||
| 5776 | IT_CHARPOS (*it) = it->bidi_it.charpos; | ||
| 5777 | IT_BYTEPOS (*it) = it->bidi_it.bytepos; | ||
| 5778 | } | ||
| 5744 | reseat (it, it->current.pos, 0); | 5779 | reseat (it, it->current.pos, 0); |
| 5745 | } | 5780 | } |
| 5746 | } | 5781 | } |
| @@ -5836,7 +5871,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p) | |||
| 5836 | { | 5871 | { |
| 5837 | bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), | 5872 | bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), |
| 5838 | &it->bidi_it); | 5873 | &it->bidi_it); |
| 5839 | bidi_unshelve_cache (NULL); | 5874 | bidi_unshelve_cache (NULL, 0); |
| 5840 | it->bidi_it.paragraph_dir = NEUTRAL_DIR; | 5875 | it->bidi_it.paragraph_dir = NEUTRAL_DIR; |
| 5841 | it->bidi_it.string.s = NULL; | 5876 | it->bidi_it.string.s = NULL; |
| 5842 | it->bidi_it.string.lstring = Qnil; | 5877 | it->bidi_it.string.lstring = Qnil; |
| @@ -7684,7 +7719,12 @@ move_it_in_display_line_to (struct it *it, | |||
| 7684 | ((op & MOVE_TO_POS) != 0 \ | 7719 | ((op & MOVE_TO_POS) != 0 \ |
| 7685 | && BUFFERP (it->object) \ | 7720 | && BUFFERP (it->object) \ |
| 7686 | && (IT_CHARPOS (*it) == to_charpos \ | 7721 | && (IT_CHARPOS (*it) == to_charpos \ |
| 7687 | || (!it->bidi_p && IT_CHARPOS (*it) > to_charpos)) \ | 7722 | || (!it->bidi_p && IT_CHARPOS (*it) > to_charpos) \ |
| 7723 | || (it->what == IT_COMPOSITION \ | ||
| 7724 | && ((IT_CHARPOS (*it) > to_charpos \ | ||
| 7725 | && to_charpos >= it->cmp_it.charpos) \ | ||
| 7726 | || (IT_CHARPOS (*it) < to_charpos \ | ||
| 7727 | && to_charpos <= it->cmp_it.charpos)))) \ | ||
| 7688 | && (it->method == GET_FROM_BUFFER \ | 7728 | && (it->method == GET_FROM_BUFFER \ |
| 7689 | || (it->method == GET_FROM_DISPLAY_VECTOR \ | 7729 | || (it->method == GET_FROM_DISPLAY_VECTOR \ |
| 7690 | && it->dpvec + it->current.dpvec_index + 1 >= it->dpend))) | 7730 | && it->dpvec + it->current.dpvec_index + 1 >= it->dpend))) |
| @@ -8017,13 +8057,23 @@ move_it_in_display_line_to (struct it *it, | |||
| 8017 | positions smaller than TO_CHARPOS, return | 8057 | positions smaller than TO_CHARPOS, return |
| 8018 | MOVE_POS_MATCH_OR_ZV, like the unidirectional display | 8058 | MOVE_POS_MATCH_OR_ZV, like the unidirectional display |
| 8019 | did. */ | 8059 | did. */ |
| 8020 | if ((op & MOVE_TO_POS) != 0 | 8060 | if (it->bidi_p && (op & MOVE_TO_POS) != 0) |
| 8021 | && !saw_smaller_pos | ||
| 8022 | && IT_CHARPOS (*it) > to_charpos) | ||
| 8023 | { | 8061 | { |
| 8024 | result = MOVE_POS_MATCH_OR_ZV; | 8062 | if (!saw_smaller_pos && IT_CHARPOS (*it) > to_charpos) |
| 8025 | if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV) | 8063 | { |
| 8026 | RESTORE_IT (it, &ppos_it, ppos_data); | 8064 | if (IT_CHARPOS (ppos_it) < ZV) |
| 8065 | { | ||
| 8066 | RESTORE_IT (it, &ppos_it, ppos_data); | ||
| 8067 | result = MOVE_POS_MATCH_OR_ZV; | ||
| 8068 | } | ||
| 8069 | else | ||
| 8070 | goto buffer_pos_reached; | ||
| 8071 | } | ||
| 8072 | else if (it->line_wrap == WORD_WRAP && atpos_it.sp >= 0 | ||
| 8073 | && IT_CHARPOS (*it) > to_charpos) | ||
| 8074 | goto buffer_pos_reached; | ||
| 8075 | else | ||
| 8076 | result = MOVE_NEWLINE_OR_CR; | ||
| 8027 | } | 8077 | } |
| 8028 | else | 8078 | else |
| 8029 | result = MOVE_NEWLINE_OR_CR; | 8079 | result = MOVE_NEWLINE_OR_CR; |
| @@ -8062,13 +8112,13 @@ move_it_in_display_line_to (struct it *it, | |||
| 8062 | character positions smaller than TO_CHARPOS, | 8112 | character positions smaller than TO_CHARPOS, |
| 8063 | return MOVE_POS_MATCH_OR_ZV, like the | 8113 | return MOVE_POS_MATCH_OR_ZV, like the |
| 8064 | unidirectional display did. */ | 8114 | unidirectional display did. */ |
| 8065 | || ((op & MOVE_TO_POS) != 0 | 8115 | || (it->bidi_p && (op & MOVE_TO_POS) != 0 |
| 8066 | && !saw_smaller_pos | 8116 | && !saw_smaller_pos |
| 8067 | && IT_CHARPOS (*it) > to_charpos)) | 8117 | && IT_CHARPOS (*it) > to_charpos)) |
| 8068 | { | 8118 | { |
| 8069 | result = MOVE_POS_MATCH_OR_ZV; | 8119 | if (!at_eob_p && IT_CHARPOS (ppos_it) < ZV) |
| 8070 | if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV) | ||
| 8071 | RESTORE_IT (it, &ppos_it, ppos_data); | 8120 | RESTORE_IT (it, &ppos_it, ppos_data); |
| 8121 | result = MOVE_POS_MATCH_OR_ZV; | ||
| 8072 | break; | 8122 | break; |
| 8073 | } | 8123 | } |
| 8074 | if (ITERATOR_AT_END_OF_LINE_P (it)) | 8124 | if (ITERATOR_AT_END_OF_LINE_P (it)) |
| @@ -8077,13 +8127,13 @@ move_it_in_display_line_to (struct it *it, | |||
| 8077 | break; | 8127 | break; |
| 8078 | } | 8128 | } |
| 8079 | } | 8129 | } |
| 8080 | else if ((op & MOVE_TO_POS) != 0 | 8130 | else if (it->bidi_p && (op & MOVE_TO_POS) != 0 |
| 8081 | && !saw_smaller_pos | 8131 | && !saw_smaller_pos |
| 8082 | && IT_CHARPOS (*it) > to_charpos) | 8132 | && IT_CHARPOS (*it) > to_charpos) |
| 8083 | { | 8133 | { |
| 8084 | result = MOVE_POS_MATCH_OR_ZV; | 8134 | if (IT_CHARPOS (ppos_it) < ZV) |
| 8085 | if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV) | ||
| 8086 | RESTORE_IT (it, &ppos_it, ppos_data); | 8135 | RESTORE_IT (it, &ppos_it, ppos_data); |
| 8136 | result = MOVE_POS_MATCH_OR_ZV; | ||
| 8087 | break; | 8137 | break; |
| 8088 | } | 8138 | } |
| 8089 | result = MOVE_LINE_TRUNCATED; | 8139 | result = MOVE_LINE_TRUNCATED; |
| @@ -8104,13 +8154,13 @@ move_it_in_display_line_to (struct it *it, | |||
| 8104 | done: | 8154 | done: |
| 8105 | 8155 | ||
| 8106 | if (atpos_data) | 8156 | if (atpos_data) |
| 8107 | xfree (atpos_data); | 8157 | bidi_unshelve_cache (atpos_data, 1); |
| 8108 | if (atx_data) | 8158 | if (atx_data) |
| 8109 | xfree (atx_data); | 8159 | bidi_unshelve_cache (atx_data, 1); |
| 8110 | if (wrap_data) | 8160 | if (wrap_data) |
| 8111 | xfree (wrap_data); | 8161 | bidi_unshelve_cache (wrap_data, 1); |
| 8112 | if (ppos_data) | 8162 | if (ppos_data) |
| 8113 | xfree (ppos_data); | 8163 | bidi_unshelve_cache (ppos_data, 1); |
| 8114 | 8164 | ||
| 8115 | /* Restore the iterator settings altered at the beginning of this | 8165 | /* Restore the iterator settings altered at the beginning of this |
| 8116 | function. */ | 8166 | function. */ |
| @@ -8145,7 +8195,7 @@ move_it_in_display_line (struct it *it, | |||
| 8145 | (it, -1, prev_x, MOVE_TO_X); | 8195 | (it, -1, prev_x, MOVE_TO_X); |
| 8146 | } | 8196 | } |
| 8147 | else | 8197 | else |
| 8148 | xfree (save_data); | 8198 | bidi_unshelve_cache (save_data, 1); |
| 8149 | } | 8199 | } |
| 8150 | else | 8200 | else |
| 8151 | move_it_in_display_line_to (it, to_charpos, to_x, op); | 8201 | move_it_in_display_line_to (it, to_charpos, to_x, op); |
| @@ -8310,7 +8360,14 @@ move_it_to (struct it *it, EMACS_INT to_charpos, int to_x, int to_y, int to_vpos | |||
| 8310 | else if (BUFFERP (it->object) | 8360 | else if (BUFFERP (it->object) |
| 8311 | && (it->method == GET_FROM_BUFFER | 8361 | && (it->method == GET_FROM_BUFFER |
| 8312 | || it->method == GET_FROM_STRETCH) | 8362 | || it->method == GET_FROM_STRETCH) |
| 8313 | && IT_CHARPOS (*it) >= to_charpos) | 8363 | && IT_CHARPOS (*it) >= to_charpos |
| 8364 | /* Under bidi iteration, a call to set_iterator_to_next | ||
| 8365 | can scan far beyond to_charpos if the initial | ||
| 8366 | portion of the next line needs to be reordered. In | ||
| 8367 | that case, give move_it_in_display_line_to another | ||
| 8368 | chance below. */ | ||
| 8369 | && !(it->bidi_p | ||
| 8370 | && it->bidi_it.scan_dir == -1)) | ||
| 8314 | skip = MOVE_POS_MATCH_OR_ZV; | 8371 | skip = MOVE_POS_MATCH_OR_ZV; |
| 8315 | else | 8372 | else |
| 8316 | skip = move_it_in_display_line_to (it, to_charpos, -1, MOVE_TO_POS); | 8373 | skip = move_it_in_display_line_to (it, to_charpos, -1, MOVE_TO_POS); |
| @@ -8404,7 +8461,7 @@ move_it_to (struct it *it, EMACS_INT to_charpos, int to_x, int to_y, int to_vpos | |||
| 8404 | } | 8461 | } |
| 8405 | 8462 | ||
| 8406 | if (backup_data) | 8463 | if (backup_data) |
| 8407 | xfree (backup_data); | 8464 | bidi_unshelve_cache (backup_data, 1); |
| 8408 | 8465 | ||
| 8409 | TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached)); | 8466 | TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached)); |
| 8410 | } | 8467 | } |
| @@ -8445,7 +8502,8 @@ move_it_vertically_backward (struct it *it, int dy) | |||
| 8445 | reseat_1 (it, it->current.pos, 1); | 8502 | reseat_1 (it, it->current.pos, 1); |
| 8446 | 8503 | ||
| 8447 | /* We are now surely at a line start. */ | 8504 | /* We are now surely at a line start. */ |
| 8448 | it->current_x = it->hpos = 0; | 8505 | it->current_x = it->hpos = 0; /* FIXME: this is incorrect when bidi |
| 8506 | reordering is in effect. */ | ||
| 8449 | it->continuation_lines_width = 0; | 8507 | it->continuation_lines_width = 0; |
| 8450 | 8508 | ||
| 8451 | /* Move forward and see what y-distance we moved. First move to the | 8509 | /* Move forward and see what y-distance we moved. First move to the |
| @@ -8479,11 +8537,26 @@ move_it_vertically_backward (struct it *it, int dy) | |||
| 8479 | if (dy == 0) | 8537 | if (dy == 0) |
| 8480 | { | 8538 | { |
| 8481 | /* DY == 0 means move to the start of the screen line. The | 8539 | /* DY == 0 means move to the start of the screen line. The |
| 8482 | value of nlines is > 0 if continuation lines were involved. */ | 8540 | value of nlines is > 0 if continuation lines were involved, |
| 8541 | or if the original IT position was at start of a line. */ | ||
| 8483 | RESTORE_IT (it, it, it2data); | 8542 | RESTORE_IT (it, it, it2data); |
| 8484 | if (nlines > 0) | 8543 | if (nlines > 0) |
| 8485 | move_it_by_lines (it, nlines); | 8544 | move_it_by_lines (it, nlines); |
| 8486 | xfree (it3data); | 8545 | /* The above code moves us to some position NLINES down, |
| 8546 | usually to its first glyph (leftmost in an L2R line), but | ||
| 8547 | that's not necessarily the start of the line, under bidi | ||
| 8548 | reordering. We want to get to the character position | ||
| 8549 | that is immediately after the newline of the previous | ||
| 8550 | line. */ | ||
| 8551 | if (it->bidi_p && IT_CHARPOS (*it) > BEGV | ||
| 8552 | && FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n') | ||
| 8553 | { | ||
| 8554 | EMACS_INT nl_pos = | ||
| 8555 | find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1); | ||
| 8556 | |||
| 8557 | move_it_to (it, nl_pos, -1, -1, -1, MOVE_TO_POS); | ||
| 8558 | } | ||
| 8559 | bidi_unshelve_cache (it3data, 1); | ||
| 8487 | } | 8560 | } |
| 8488 | else | 8561 | else |
| 8489 | { | 8562 | { |
| @@ -8679,7 +8752,7 @@ move_it_by_lines (struct it *it, int dvpos) | |||
| 8679 | if (IT_CHARPOS (*it) >= start_charpos) | 8752 | if (IT_CHARPOS (*it) >= start_charpos) |
| 8680 | RESTORE_IT (it, &it2, it2data); | 8753 | RESTORE_IT (it, &it2, it2data); |
| 8681 | else | 8754 | else |
| 8682 | xfree (it2data); | 8755 | bidi_unshelve_cache (it2data, 1); |
| 8683 | } | 8756 | } |
| 8684 | else | 8757 | else |
| 8685 | RESTORE_IT (it, it, it2data); | 8758 | RESTORE_IT (it, it, it2data); |
| @@ -10387,13 +10460,14 @@ static void | |||
| 10387 | store_mode_line_noprop_char (char c) | 10460 | store_mode_line_noprop_char (char c) |
| 10388 | { | 10461 | { |
| 10389 | /* If output position has reached the end of the allocated buffer, | 10462 | /* If output position has reached the end of the allocated buffer, |
| 10390 | double the buffer's size. */ | 10463 | increase the buffer's size. */ |
| 10391 | if (mode_line_noprop_ptr == mode_line_noprop_buf_end) | 10464 | if (mode_line_noprop_ptr == mode_line_noprop_buf_end) |
| 10392 | { | 10465 | { |
| 10393 | int len = MODE_LINE_NOPROP_LEN (0); | 10466 | ptrdiff_t len = MODE_LINE_NOPROP_LEN (0); |
| 10394 | int new_size = 2 * len * sizeof *mode_line_noprop_buf; | 10467 | ptrdiff_t size = len; |
| 10395 | mode_line_noprop_buf = (char *) xrealloc (mode_line_noprop_buf, new_size); | 10468 | mode_line_noprop_buf = |
| 10396 | mode_line_noprop_buf_end = mode_line_noprop_buf + new_size; | 10469 | xpalloc (mode_line_noprop_buf, &size, 1, STRING_BYTES_BOUND, 1); |
| 10470 | mode_line_noprop_buf_end = mode_line_noprop_buf + size; | ||
| 10397 | mode_line_noprop_ptr = mode_line_noprop_buf + len; | 10471 | mode_line_noprop_ptr = mode_line_noprop_buf + len; |
| 10398 | } | 10472 | } |
| 10399 | 10473 | ||
| @@ -10455,9 +10529,9 @@ x_consider_frame_title (Lisp_Object frame) | |||
| 10455 | /* Do we have more than one visible frame on this X display? */ | 10529 | /* Do we have more than one visible frame on this X display? */ |
| 10456 | Lisp_Object tail; | 10530 | Lisp_Object tail; |
| 10457 | Lisp_Object fmt; | 10531 | Lisp_Object fmt; |
| 10458 | int title_start; | 10532 | ptrdiff_t title_start; |
| 10459 | char *title; | 10533 | char *title; |
| 10460 | int len; | 10534 | ptrdiff_t len; |
| 10461 | struct it it; | 10535 | struct it it; |
| 10462 | int count = SPECPDL_INDEX (); | 10536 | int count = SPECPDL_INDEX (); |
| 10463 | 10537 | ||
| @@ -13295,6 +13369,9 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, | |||
| 13295 | /* Last buffer position covered by an overlay string with an integer | 13369 | /* Last buffer position covered by an overlay string with an integer |
| 13296 | `cursor' property. */ | 13370 | `cursor' property. */ |
| 13297 | EMACS_INT bpos_covered = 0; | 13371 | EMACS_INT bpos_covered = 0; |
| 13372 | /* Non-zero means the display string on which to display the cursor | ||
| 13373 | comes from a text property, not from an overlay. */ | ||
| 13374 | int string_from_text_prop = 0; | ||
| 13298 | 13375 | ||
| 13299 | /* Skip over glyphs not having an object at the start and the end of | 13376 | /* Skip over glyphs not having an object at the start and the end of |
| 13300 | the row. These are special glyphs like truncation marks on | 13377 | the row. These are special glyphs like truncation marks on |
| @@ -13613,9 +13690,14 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, | |||
| 13613 | { | 13690 | { |
| 13614 | Lisp_Object str; | 13691 | Lisp_Object str; |
| 13615 | EMACS_INT tem; | 13692 | EMACS_INT tem; |
| 13693 | /* If the display property covers the newline, we | ||
| 13694 | need to search for it one position farther. */ | ||
| 13695 | EMACS_INT lim = pos_after | ||
| 13696 | + (pos_after == MATRIX_ROW_END_CHARPOS (row) + delta); | ||
| 13616 | 13697 | ||
| 13698 | string_from_text_prop = 0; | ||
| 13617 | str = glyph->object; | 13699 | str = glyph->object; |
| 13618 | tem = string_buffer_position_lim (str, pos, pos_after, 0); | 13700 | tem = string_buffer_position_lim (str, pos, lim, 0); |
| 13619 | if (tem == 0 /* from overlay */ | 13701 | if (tem == 0 /* from overlay */ |
| 13620 | || pos <= tem) | 13702 | || pos <= tem) |
| 13621 | { | 13703 | { |
| @@ -13639,7 +13721,10 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, | |||
| 13639 | EMACS_INT strpos = glyph->charpos; | 13721 | EMACS_INT strpos = glyph->charpos; |
| 13640 | 13722 | ||
| 13641 | if (tem) | 13723 | if (tem) |
| 13642 | cursor = glyph; | 13724 | { |
| 13725 | cursor = glyph; | ||
| 13726 | string_from_text_prop = 1; | ||
| 13727 | } | ||
| 13643 | for ( ; | 13728 | for ( ; |
| 13644 | (row->reversed_p ? glyph > stop : glyph < stop) | 13729 | (row->reversed_p ? glyph > stop : glyph < stop) |
| 13645 | && EQ (glyph->object, str); | 13730 | && EQ (glyph->object, str); |
| @@ -13714,14 +13799,14 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, | |||
| 13714 | w->cursor.vpos >= 0 | 13799 | w->cursor.vpos >= 0 |
| 13715 | /* that candidate is not the row we are processing */ | 13800 | /* that candidate is not the row we are processing */ |
| 13716 | && MATRIX_ROW (matrix, w->cursor.vpos) != row | 13801 | && MATRIX_ROW (matrix, w->cursor.vpos) != row |
| 13717 | /* the row we are processing is part of a continued line */ | ||
| 13718 | && (row->continued_p || MATRIX_ROW_CONTINUATION_LINE_P (row)) | ||
| 13719 | /* Make sure cursor.vpos specifies a row whose start and end | 13802 | /* Make sure cursor.vpos specifies a row whose start and end |
| 13720 | charpos occlude point. This is because some callers of this | 13803 | charpos occlude point, and it is valid candidate for being a |
| 13721 | function leave cursor.vpos at the row where the cursor was | 13804 | cursor-row. This is because some callers of this function |
| 13722 | displayed during the last redisplay cycle. */ | 13805 | leave cursor.vpos at the row where the cursor was displayed |
| 13806 | during the last redisplay cycle. */ | ||
| 13723 | && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old | 13807 | && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old |
| 13724 | && pt_old < MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))) | 13808 | && pt_old <= MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) |
| 13809 | && cursor_row_p (MATRIX_ROW (matrix, w->cursor.vpos))) | ||
| 13725 | { | 13810 | { |
| 13726 | struct glyph *g1 = | 13811 | struct glyph *g1 = |
| 13727 | MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; | 13812 | MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; |
| @@ -13730,18 +13815,39 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, | |||
| 13730 | if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)) | 13815 | if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)) |
| 13731 | return 0; | 13816 | return 0; |
| 13732 | /* Keep the candidate whose buffer position is the closest to | 13817 | /* Keep the candidate whose buffer position is the closest to |
| 13733 | point. */ | 13818 | point or has the `cursor' property. */ |
| 13734 | if (/* previous candidate is a glyph in TEXT_AREA of that row */ | 13819 | if (/* previous candidate is a glyph in TEXT_AREA of that row */ |
| 13735 | w->cursor.hpos >= 0 | 13820 | w->cursor.hpos >= 0 |
| 13736 | && w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos) | 13821 | && w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos) |
| 13737 | && BUFFERP (g1->object) | 13822 | && ((BUFFERP (g1->object) |
| 13738 | && (g1->charpos == pt_old /* an exact match always wins */ | 13823 | && (g1->charpos == pt_old /* an exact match always wins */ |
| 13739 | || (BUFFERP (glyph->object) | 13824 | || (BUFFERP (glyph->object) |
| 13740 | && eabs (g1->charpos - pt_old) | 13825 | && eabs (g1->charpos - pt_old) |
| 13741 | < eabs (glyph->charpos - pt_old)))) | 13826 | < eabs (glyph->charpos - pt_old)))) |
| 13827 | /* previous candidate is a glyph from a string that has | ||
| 13828 | a non-nil `cursor' property */ | ||
| 13829 | || (STRINGP (g1->object) | ||
| 13830 | && (!NILP (Fget_char_property (make_number (g1->charpos), | ||
| 13831 | Qcursor, g1->object)) | ||
| 13832 | /* pevious candidate is from the same display | ||
| 13833 | string as this one, and the display string | ||
| 13834 | came from a text property */ | ||
| 13835 | || (EQ (g1->object, glyph->object) | ||
| 13836 | && string_from_text_prop) | ||
| 13837 | /* this candidate is from newline and its | ||
| 13838 | position is not an exact match */ | ||
| 13839 | || (INTEGERP (glyph->object) | ||
| 13840 | && glyph->charpos != pt_old))))) | ||
| 13742 | return 0; | 13841 | return 0; |
| 13743 | /* If this candidate gives an exact match, use that. */ | 13842 | /* If this candidate gives an exact match, use that. */ |
| 13744 | if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) | 13843 | if (!((BUFFERP (glyph->object) && glyph->charpos == pt_old) |
| 13844 | /* If this candidate is a glyph created for the | ||
| 13845 | terminating newline of a line, and point is on that | ||
| 13846 | newline, it wins because it's an exact match. */ | ||
| 13847 | || (!row->continued_p | ||
| 13848 | && INTEGERP (glyph->object) | ||
| 13849 | && glyph->charpos == 0 | ||
| 13850 | && pt_old == MATRIX_ROW_END_CHARPOS (row) - 1)) | ||
| 13745 | /* Otherwise, keep the candidate that comes from a row | 13851 | /* Otherwise, keep the candidate that comes from a row |
| 13746 | spanning less buffer positions. This may win when one or | 13852 | spanning less buffer positions. This may win when one or |
| 13747 | both candidate positions are on glyphs that came from | 13853 | both candidate positions are on glyphs that came from |
| @@ -14508,22 +14614,43 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste | |||
| 14508 | 14614 | ||
| 14509 | do | 14615 | do |
| 14510 | { | 14616 | { |
| 14617 | int at_zv_p = 0, exact_match_p = 0; | ||
| 14618 | |||
| 14511 | if (MATRIX_ROW_START_CHARPOS (row) <= PT | 14619 | if (MATRIX_ROW_START_CHARPOS (row) <= PT |
| 14512 | && PT <= MATRIX_ROW_END_CHARPOS (row) | 14620 | && PT <= MATRIX_ROW_END_CHARPOS (row) |
| 14513 | && cursor_row_p (row)) | 14621 | && cursor_row_p (row)) |
| 14514 | rv |= set_cursor_from_row (w, row, w->current_matrix, | 14622 | rv |= set_cursor_from_row (w, row, w->current_matrix, |
| 14515 | 0, 0, 0, 0); | 14623 | 0, 0, 0, 0); |
| 14516 | /* As soon as we've found the first suitable row | 14624 | /* As soon as we've found the exact match for point, |
| 14517 | whose ends_at_zv_p flag is set, we are done. */ | 14625 | or the first suitable row whose ends_at_zv_p flag |
| 14518 | if (rv | 14626 | is set, we are done. */ |
| 14519 | && MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p) | 14627 | at_zv_p = |
| 14628 | MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p; | ||
| 14629 | if (!at_zv_p) | ||
| 14630 | { | ||
| 14631 | struct glyph_row *candidate = | ||
| 14632 | MATRIX_ROW (w->current_matrix, w->cursor.vpos); | ||
| 14633 | struct glyph *g = | ||
| 14634 | candidate->glyphs[TEXT_AREA] + w->cursor.hpos; | ||
| 14635 | EMACS_INT endpos = MATRIX_ROW_END_CHARPOS (candidate); | ||
| 14636 | |||
| 14637 | exact_match_p = | ||
| 14638 | (BUFFERP (g->object) && g->charpos == PT) | ||
| 14639 | || (INTEGERP (g->object) | ||
| 14640 | && (g->charpos == PT | ||
| 14641 | || (g->charpos == 0 && endpos - 1 == PT))); | ||
| 14642 | } | ||
| 14643 | if (rv && (at_zv_p || exact_match_p)) | ||
| 14520 | { | 14644 | { |
| 14521 | rc = CURSOR_MOVEMENT_SUCCESS; | 14645 | rc = CURSOR_MOVEMENT_SUCCESS; |
| 14522 | break; | 14646 | break; |
| 14523 | } | 14647 | } |
| 14648 | if (MATRIX_ROW_BOTTOM_Y (row) == last_y) | ||
| 14649 | break; | ||
| 14524 | ++row; | 14650 | ++row; |
| 14525 | } | 14651 | } |
| 14526 | while ((MATRIX_ROW_CONTINUATION_LINE_P (row) | 14652 | while (((MATRIX_ROW_CONTINUATION_LINE_P (row) |
| 14653 | || row->continued_p) | ||
| 14527 | && MATRIX_ROW_BOTTOM_Y (row) <= last_y) | 14654 | && MATRIX_ROW_BOTTOM_Y (row) <= last_y) |
| 14528 | || (MATRIX_ROW_START_CHARPOS (row) == PT | 14655 | || (MATRIX_ROW_START_CHARPOS (row) == PT |
| 14529 | && MATRIX_ROW_BOTTOM_Y (row) < last_y)); | 14656 | && MATRIX_ROW_BOTTOM_Y (row) < last_y)); |
| @@ -14531,7 +14658,9 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste | |||
| 14531 | loop before all the candidates were examined, signal | 14658 | loop before all the candidates were examined, signal |
| 14532 | to the caller that this method failed. */ | 14659 | to the caller that this method failed. */ |
| 14533 | if (rc != CURSOR_MOVEMENT_SUCCESS | 14660 | if (rc != CURSOR_MOVEMENT_SUCCESS |
| 14534 | && (!rv || MATRIX_ROW_CONTINUATION_LINE_P (row))) | 14661 | && !(rv |
| 14662 | && !MATRIX_ROW_CONTINUATION_LINE_P (row) | ||
| 14663 | && !row->continued_p)) | ||
| 14535 | rc = CURSOR_MOVEMENT_MUST_SCROLL; | 14664 | rc = CURSOR_MOVEMENT_MUST_SCROLL; |
| 14536 | else if (rv) | 14665 | else if (rv) |
| 14537 | rc = CURSOR_MOVEMENT_SUCCESS; | 14666 | rc = CURSOR_MOVEMENT_SUCCESS; |
| @@ -14991,6 +15120,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 14991 | || (XFASTINT (w->last_modified) >= MODIFF | 15120 | || (XFASTINT (w->last_modified) >= MODIFF |
| 14992 | && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF))) | 15121 | && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF))) |
| 14993 | { | 15122 | { |
| 15123 | int d1, d2, d3, d4, d5, d6; | ||
| 14994 | 15124 | ||
| 14995 | /* If first window line is a continuation line, and window start | 15125 | /* If first window line is a continuation line, and window start |
| 14996 | is inside the modified region, but the first change is before | 15126 | is inside the modified region, but the first change is before |
| @@ -15012,7 +15142,14 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 15012 | compute_window_start_on_continuation_line. (See also | 15142 | compute_window_start_on_continuation_line. (See also |
| 15013 | bug#197). */ | 15143 | bug#197). */ |
| 15014 | && XMARKER (w->start)->buffer == current_buffer | 15144 | && XMARKER (w->start)->buffer == current_buffer |
| 15015 | && compute_window_start_on_continuation_line (w)) | 15145 | && compute_window_start_on_continuation_line (w) |
| 15146 | /* It doesn't make sense to force the window start like we | ||
| 15147 | do at label force_start if it is already known that point | ||
| 15148 | will not be visible in the resulting window, because | ||
| 15149 | doing so will move point from its correct position | ||
| 15150 | instead of scrolling the window to bring point into view. | ||
| 15151 | See bug#9324. */ | ||
| 15152 | && pos_visible_p (w, PT, &d1, &d2, &d3, &d4, &d5, &d6)) | ||
| 15016 | { | 15153 | { |
| 15017 | w->force_start = Qt; | 15154 | w->force_start = Qt; |
| 15018 | SET_TEXT_POS_FROM_MARKER (startp, w->start); | 15155 | SET_TEXT_POS_FROM_MARKER (startp, w->start); |
| @@ -15189,7 +15326,8 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 15189 | if (pt_offset) | 15326 | if (pt_offset) |
| 15190 | centering_position -= pt_offset; | 15327 | centering_position -= pt_offset; |
| 15191 | centering_position -= | 15328 | centering_position -= |
| 15192 | FRAME_LINE_HEIGHT (f) * (1 + margin + (last_line_misfit != 0)); | 15329 | FRAME_LINE_HEIGHT (f) * (1 + margin + (last_line_misfit != 0)) |
| 15330 | + WINDOW_HEADER_LINE_HEIGHT (w); | ||
| 15193 | /* Don't let point enter the scroll margin near top of | 15331 | /* Don't let point enter the scroll margin near top of |
| 15194 | the window. */ | 15332 | the window. */ |
| 15195 | if (centering_position < margin * FRAME_LINE_HEIGHT (f)) | 15333 | if (centering_position < margin * FRAME_LINE_HEIGHT (f)) |
| @@ -17953,7 +18091,8 @@ cursor_row_p (struct glyph_row *row) | |||
| 17953 | { | 18091 | { |
| 17954 | int result = 1; | 18092 | int result = 1; |
| 17955 | 18093 | ||
| 17956 | if (PT == CHARPOS (row->end.pos)) | 18094 | if (PT == CHARPOS (row->end.pos) |
| 18095 | || PT == MATRIX_ROW_END_CHARPOS (row)) | ||
| 17957 | { | 18096 | { |
| 17958 | /* Suppose the row ends on a string. | 18097 | /* Suppose the row ends on a string. |
| 17959 | Unless the row is continued, that means it ends on a newline | 18098 | Unless the row is continued, that means it ends on a newline |
| @@ -18014,16 +18153,25 @@ cursor_row_p (struct glyph_row *row) | |||
| 18014 | 18153 | ||
| 18015 | 18154 | ||
| 18016 | 18155 | ||
| 18017 | /* Push the display property PROP so that it will be rendered at the | 18156 | /* Push the property PROP so that it will be rendered at the current |
| 18018 | current position in IT. Return 1 if PROP was successfully pushed, | 18157 | position in IT. Return 1 if PROP was successfully pushed, 0 |
| 18019 | 0 otherwise. */ | 18158 | otherwise. Called from handle_line_prefix to handle the |
| 18159 | `line-prefix' and `wrap-prefix' properties. */ | ||
| 18020 | 18160 | ||
| 18021 | static int | 18161 | static int |
| 18022 | push_display_prop (struct it *it, Lisp_Object prop) | 18162 | push_display_prop (struct it *it, Lisp_Object prop) |
| 18023 | { | 18163 | { |
| 18024 | xassert (it->method == GET_FROM_BUFFER); | 18164 | struct text_pos pos = |
| 18165 | (it->method == GET_FROM_STRING) ? it->current.string_pos : it->current.pos; | ||
| 18025 | 18166 | ||
| 18026 | push_it (it, NULL); | 18167 | xassert (it->method == GET_FROM_BUFFER |
| 18168 | || it->method == GET_FROM_STRING); | ||
| 18169 | |||
| 18170 | /* We need to save the current buffer/string position, so it will be | ||
| 18171 | restored by pop_it, because iterate_out_of_display_property | ||
| 18172 | depends on that being set correctly, but some situations leave | ||
| 18173 | it->position not yet set when this function is called. */ | ||
| 18174 | push_it (it, &pos); | ||
| 18027 | 18175 | ||
| 18028 | if (STRINGP (prop)) | 18176 | if (STRINGP (prop)) |
| 18029 | { | 18177 | { |
| @@ -18042,11 +18190,9 @@ push_display_prop (struct it *it, Lisp_Object prop) | |||
| 18042 | it->stop_charpos = 0; | 18190 | it->stop_charpos = 0; |
| 18043 | it->prev_stop = 0; | 18191 | it->prev_stop = 0; |
| 18044 | it->base_level_stop = 0; | 18192 | it->base_level_stop = 0; |
| 18045 | it->string_from_display_prop_p = 1; | ||
| 18046 | it->from_disp_prop_p = 1; | ||
| 18047 | 18193 | ||
| 18048 | /* Force paragraph direction to be that of the parent | 18194 | /* Force paragraph direction to be that of the parent |
| 18049 | buffer. */ | 18195 | buffer/string. */ |
| 18050 | if (it->bidi_p && it->bidi_it.paragraph_dir == R2L) | 18196 | if (it->bidi_p && it->bidi_it.paragraph_dir == R2L) |
| 18051 | it->paragraph_embedding = it->bidi_it.paragraph_dir; | 18197 | it->paragraph_embedding = it->bidi_it.paragraph_dir; |
| 18052 | else | 18198 | else |
| @@ -18059,7 +18205,7 @@ push_display_prop (struct it *it, Lisp_Object prop) | |||
| 18059 | it->bidi_it.string.s = NULL; | 18205 | it->bidi_it.string.s = NULL; |
| 18060 | it->bidi_it.string.schars = it->end_charpos; | 18206 | it->bidi_it.string.schars = it->end_charpos; |
| 18061 | it->bidi_it.string.bufpos = IT_CHARPOS (*it); | 18207 | it->bidi_it.string.bufpos = IT_CHARPOS (*it); |
| 18062 | it->bidi_it.string.from_disp_str = 1; | 18208 | it->bidi_it.string.from_disp_str = it->string_from_display_prop_p; |
| 18063 | it->bidi_it.string.unibyte = !it->multibyte_p; | 18209 | it->bidi_it.string.unibyte = !it->multibyte_p; |
| 18064 | bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it); | 18210 | bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it); |
| 18065 | } | 18211 | } |
| @@ -18329,15 +18475,22 @@ display_line (struct it *it) | |||
| 18329 | #define RECORD_MAX_MIN_POS(IT) \ | 18475 | #define RECORD_MAX_MIN_POS(IT) \ |
| 18330 | do \ | 18476 | do \ |
| 18331 | { \ | 18477 | { \ |
| 18332 | if (IT_CHARPOS (*(IT)) < min_pos) \ | 18478 | int composition_p = (IT)->what == IT_COMPOSITION; \ |
| 18479 | EMACS_INT current_pos = \ | ||
| 18480 | composition_p ? (IT)->cmp_it.charpos \ | ||
| 18481 | : IT_CHARPOS (*(IT)); \ | ||
| 18482 | EMACS_INT current_bpos = \ | ||
| 18483 | composition_p ? CHAR_TO_BYTE (current_pos) \ | ||
| 18484 | : IT_BYTEPOS (*(IT)); \ | ||
| 18485 | if (current_pos < min_pos) \ | ||
| 18333 | { \ | 18486 | { \ |
| 18334 | min_pos = IT_CHARPOS (*(IT)); \ | 18487 | min_pos = current_pos; \ |
| 18335 | min_bpos = IT_BYTEPOS (*(IT)); \ | 18488 | min_bpos = current_bpos; \ |
| 18336 | } \ | 18489 | } \ |
| 18337 | if (IT_CHARPOS (*(IT)) > max_pos) \ | 18490 | if (IT_CHARPOS (*it) > max_pos) \ |
| 18338 | { \ | 18491 | { \ |
| 18339 | max_pos = IT_CHARPOS (*(IT)); \ | 18492 | max_pos = IT_CHARPOS (*it); \ |
| 18340 | max_bpos = IT_BYTEPOS (*(IT)); \ | 18493 | max_bpos = IT_BYTEPOS (*it); \ |
| 18341 | } \ | 18494 | } \ |
| 18342 | } \ | 18495 | } \ |
| 18343 | while (0) | 18496 | while (0) |
| @@ -18784,6 +18937,9 @@ display_line (struct it *it) | |||
| 18784 | } | 18937 | } |
| 18785 | } | 18938 | } |
| 18786 | 18939 | ||
| 18940 | if (wrap_data) | ||
| 18941 | bidi_unshelve_cache (wrap_data, 1); | ||
| 18942 | |||
| 18787 | /* If line is not empty and hscrolled, maybe insert truncation glyphs | 18943 | /* If line is not empty and hscrolled, maybe insert truncation glyphs |
| 18788 | at the left window margin. */ | 18944 | at the left window margin. */ |
| 18789 | if (it->first_visible_x | 18945 | if (it->first_visible_x |
| @@ -18941,7 +19097,8 @@ See also `bidi-paragraph-direction'. */) | |||
| 18941 | buf = XBUFFER (buffer); | 19097 | buf = XBUFFER (buffer); |
| 18942 | } | 19098 | } |
| 18943 | 19099 | ||
| 18944 | if (NILP (BVAR (buf, bidi_display_reordering))) | 19100 | if (NILP (BVAR (buf, bidi_display_reordering)) |
| 19101 | || NILP (BVAR (buf, enable_multibyte_characters))) | ||
| 18945 | return Qleft_to_right; | 19102 | return Qleft_to_right; |
| 18946 | else if (!NILP (BVAR (buf, bidi_paragraph_direction))) | 19103 | else if (!NILP (BVAR (buf, bidi_paragraph_direction))) |
| 18947 | return BVAR (buf, bidi_paragraph_direction); | 19104 | return BVAR (buf, bidi_paragraph_direction); |
| @@ -21268,7 +21425,7 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, | |||
| 21268 | if (FRAME_WINDOW_P (it->f) | 21425 | if (FRAME_WINDOW_P (it->f) |
| 21269 | && valid_image_p (prop)) | 21426 | && valid_image_p (prop)) |
| 21270 | { | 21427 | { |
| 21271 | int id = lookup_image (it->f, prop); | 21428 | ptrdiff_t id = lookup_image (it->f, prop); |
| 21272 | struct image *img = IMAGE_FROM_ID (it->f, id); | 21429 | struct image *img = IMAGE_FROM_ID (it->f, id); |
| 21273 | 21430 | ||
| 21274 | return OK_PIXELS (width_p ? img->width : img->height); | 21431 | return OK_PIXELS (width_p ? img->width : img->height); |
| @@ -22140,7 +22297,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) | |||
| 22140 | do { \ | 22297 | do { \ |
| 22141 | int face_id = (row)->glyphs[area][START].face_id; \ | 22298 | int face_id = (row)->glyphs[area][START].face_id; \ |
| 22142 | struct face *base_face = FACE_FROM_ID (f, face_id); \ | 22299 | struct face *base_face = FACE_FROM_ID (f, face_id); \ |
| 22143 | int cmp_id = (row)->glyphs[area][START].u.cmp.id; \ | 22300 | ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \ |
| 22144 | struct composition *cmp = composition_table[cmp_id]; \ | 22301 | struct composition *cmp = composition_table[cmp_id]; \ |
| 22145 | XChar2b *char2b; \ | 22302 | XChar2b *char2b; \ |
| 22146 | struct glyph_string *first_s IF_LINT (= NULL); \ | 22303 | struct glyph_string *first_s IF_LINT (= NULL); \ |
| @@ -22929,6 +23086,7 @@ append_stretch_glyph (struct it *it, Lisp_Object object, | |||
| 22929 | IT_EXPAND_MATRIX_WIDTH (it, area); | 23086 | IT_EXPAND_MATRIX_WIDTH (it, area); |
| 22930 | } | 23087 | } |
| 22931 | 23088 | ||
| 23089 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 22932 | 23090 | ||
| 22933 | /* Produce a stretch glyph for iterator IT. IT->object is the value | 23091 | /* Produce a stretch glyph for iterator IT. IT->object is the value |
| 22934 | of the glyph property displayed. The value must be a list | 23092 | of the glyph property displayed. The value must be a list |
| @@ -22961,19 +23119,28 @@ append_stretch_glyph (struct it *it, Lisp_Object object, | |||
| 22961 | of the stretch should be used for the ascent of the stretch. | 23119 | of the stretch should be used for the ascent of the stretch. |
| 22962 | ASCENT must be in the range 0 <= ASCENT <= 100. */ | 23120 | ASCENT must be in the range 0 <= ASCENT <= 100. */ |
| 22963 | 23121 | ||
| 22964 | static void | 23122 | void |
| 22965 | produce_stretch_glyph (struct it *it) | 23123 | produce_stretch_glyph (struct it *it) |
| 22966 | { | 23124 | { |
| 22967 | /* (space :width WIDTH :height HEIGHT ...) */ | 23125 | /* (space :width WIDTH :height HEIGHT ...) */ |
| 22968 | Lisp_Object prop, plist; | 23126 | Lisp_Object prop, plist; |
| 22969 | int width = 0, height = 0, align_to = -1; | 23127 | int width = 0, height = 0, align_to = -1; |
| 22970 | int zero_width_ok_p = 0, zero_height_ok_p = 0; | 23128 | int zero_width_ok_p = 0; |
| 22971 | int ascent = 0; | 23129 | int ascent = 0; |
| 22972 | double tem; | 23130 | double tem; |
| 22973 | struct face *face = FACE_FROM_ID (it->f, it->face_id); | 23131 | struct face *face = NULL; |
| 22974 | struct font *font = face->font ? face->font : FRAME_FONT (it->f); | 23132 | struct font *font = NULL; |
| 22975 | 23133 | ||
| 22976 | PREPARE_FACE_FOR_DISPLAY (it->f, face); | 23134 | #ifdef HAVE_WINDOW_SYSTEM |
| 23135 | int zero_height_ok_p = 0; | ||
| 23136 | |||
| 23137 | if (FRAME_WINDOW_P (it->f)) | ||
| 23138 | { | ||
| 23139 | face = FACE_FROM_ID (it->f, it->face_id); | ||
| 23140 | font = face->font ? face->font : FRAME_FONT (it->f); | ||
| 23141 | PREPARE_FACE_FOR_DISPLAY (it->f, face); | ||
| 23142 | } | ||
| 23143 | #endif | ||
| 22977 | 23144 | ||
| 22978 | /* List should start with `space'. */ | 23145 | /* List should start with `space'. */ |
| 22979 | xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); | 23146 | xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); |
| @@ -22987,8 +23154,9 @@ produce_stretch_glyph (struct it *it) | |||
| 22987 | zero_width_ok_p = 1; | 23154 | zero_width_ok_p = 1; |
| 22988 | width = (int)tem; | 23155 | width = (int)tem; |
| 22989 | } | 23156 | } |
| 22990 | else if (prop = Fplist_get (plist, QCrelative_width), | 23157 | #ifdef HAVE_WINDOW_SYSTEM |
| 22991 | NUMVAL (prop) > 0) | 23158 | else if (FRAME_WINDOW_P (it->f) |
| 23159 | && (prop = Fplist_get (plist, QCrelative_width), NUMVAL (prop) > 0)) | ||
| 22992 | { | 23160 | { |
| 22993 | /* Relative width `:relative-width FACTOR' specified and valid. | 23161 | /* Relative width `:relative-width FACTOR' specified and valid. |
| 22994 | Compute the width of the characters having the `glyph' | 23162 | Compute the width of the characters having the `glyph' |
| @@ -23011,6 +23179,7 @@ produce_stretch_glyph (struct it *it) | |||
| 23011 | x_produce_glyphs (&it2); | 23179 | x_produce_glyphs (&it2); |
| 23012 | width = NUMVAL (prop) * it2.pixel_width; | 23180 | width = NUMVAL (prop) * it2.pixel_width; |
| 23013 | } | 23181 | } |
| 23182 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 23014 | else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) | 23183 | else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) |
| 23015 | && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to)) | 23184 | && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to)) |
| 23016 | { | 23185 | { |
| @@ -23030,33 +23199,40 @@ produce_stretch_glyph (struct it *it) | |||
| 23030 | if (width <= 0 && (width < 0 || !zero_width_ok_p)) | 23199 | if (width <= 0 && (width < 0 || !zero_width_ok_p)) |
| 23031 | width = 1; | 23200 | width = 1; |
| 23032 | 23201 | ||
| 23202 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 23033 | /* Compute height. */ | 23203 | /* Compute height. */ |
| 23034 | if ((prop = Fplist_get (plist, QCheight), !NILP (prop)) | 23204 | if (FRAME_WINDOW_P (it->f)) |
| 23035 | && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) | ||
| 23036 | { | 23205 | { |
| 23037 | height = (int)tem; | 23206 | if ((prop = Fplist_get (plist, QCheight), !NILP (prop)) |
| 23038 | zero_height_ok_p = 1; | 23207 | && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) |
| 23039 | } | 23208 | { |
| 23040 | else if (prop = Fplist_get (plist, QCrelative_height), | 23209 | height = (int)tem; |
| 23041 | NUMVAL (prop) > 0) | 23210 | zero_height_ok_p = 1; |
| 23042 | height = FONT_HEIGHT (font) * NUMVAL (prop); | 23211 | } |
| 23043 | else | 23212 | else if (prop = Fplist_get (plist, QCrelative_height), |
| 23044 | height = FONT_HEIGHT (font); | 23213 | NUMVAL (prop) > 0) |
| 23214 | height = FONT_HEIGHT (font) * NUMVAL (prop); | ||
| 23215 | else | ||
| 23216 | height = FONT_HEIGHT (font); | ||
| 23045 | 23217 | ||
| 23046 | if (height <= 0 && (height < 0 || !zero_height_ok_p)) | 23218 | if (height <= 0 && (height < 0 || !zero_height_ok_p)) |
| 23047 | height = 1; | 23219 | height = 1; |
| 23048 | 23220 | ||
| 23049 | /* Compute percentage of height used for ascent. If | 23221 | /* Compute percentage of height used for ascent. If |
| 23050 | `:ascent ASCENT' is present and valid, use that. Otherwise, | 23222 | `:ascent ASCENT' is present and valid, use that. Otherwise, |
| 23051 | derive the ascent from the font in use. */ | 23223 | derive the ascent from the font in use. */ |
| 23052 | if (prop = Fplist_get (plist, QCascent), | 23224 | if (prop = Fplist_get (plist, QCascent), |
| 23053 | NUMVAL (prop) > 0 && NUMVAL (prop) <= 100) | 23225 | NUMVAL (prop) > 0 && NUMVAL (prop) <= 100) |
| 23054 | ascent = height * NUMVAL (prop) / 100.0; | 23226 | ascent = height * NUMVAL (prop) / 100.0; |
| 23055 | else if (!NILP (prop) | 23227 | else if (!NILP (prop) |
| 23056 | && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) | 23228 | && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) |
| 23057 | ascent = min (max (0, (int)tem), height); | 23229 | ascent = min (max (0, (int)tem), height); |
| 23230 | else | ||
| 23231 | ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font); | ||
| 23232 | } | ||
| 23058 | else | 23233 | else |
| 23059 | ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font); | 23234 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 23235 | height = 1; | ||
| 23060 | 23236 | ||
| 23061 | if (width > 0 && it->line_wrap != TRUNCATE | 23237 | if (width > 0 && it->line_wrap != TRUNCATE |
| 23062 | && it->current_x + width > it->last_visible_x) | 23238 | && it->current_x + width > it->last_visible_x) |
| @@ -23064,20 +23240,37 @@ produce_stretch_glyph (struct it *it) | |||
| 23064 | 23240 | ||
| 23065 | if (width > 0 && height > 0 && it->glyph_row) | 23241 | if (width > 0 && height > 0 && it->glyph_row) |
| 23066 | { | 23242 | { |
| 23243 | Lisp_Object o_object = it->object; | ||
| 23067 | Lisp_Object object = it->stack[it->sp - 1].string; | 23244 | Lisp_Object object = it->stack[it->sp - 1].string; |
| 23245 | int n = width; | ||
| 23246 | |||
| 23068 | if (!STRINGP (object)) | 23247 | if (!STRINGP (object)) |
| 23069 | object = it->w->buffer; | 23248 | object = it->w->buffer; |
| 23070 | append_stretch_glyph (it, object, width, height, ascent); | 23249 | #ifdef HAVE_WINDOW_SYSTEM |
| 23250 | if (FRAME_WINDOW_P (it->f)) | ||
| 23251 | { | ||
| 23252 | append_stretch_glyph (it, object, width, height, ascent); | ||
| 23253 | it->ascent = it->phys_ascent = ascent; | ||
| 23254 | it->descent = it->phys_descent = height - it->ascent; | ||
| 23255 | it->nglyphs = width > 0 && height > 0 ? 1 : 0; | ||
| 23256 | take_vertical_position_into_account (it); | ||
| 23257 | } | ||
| 23258 | else | ||
| 23259 | #endif | ||
| 23260 | { | ||
| 23261 | it->object = object; | ||
| 23262 | it->char_to_display = ' '; | ||
| 23263 | it->pixel_width = it->len = 1; | ||
| 23264 | while (n--) | ||
| 23265 | tty_append_glyph (it); | ||
| 23266 | it->object = o_object; | ||
| 23267 | it->pixel_width = width; | ||
| 23268 | } | ||
| 23071 | } | 23269 | } |
| 23072 | |||
| 23073 | it->pixel_width = width; | ||
| 23074 | it->ascent = it->phys_ascent = ascent; | ||
| 23075 | it->descent = it->phys_descent = height - it->ascent; | ||
| 23076 | it->nglyphs = width > 0 && height > 0 ? 1 : 0; | ||
| 23077 | |||
| 23078 | take_vertical_position_into_account (it); | ||
| 23079 | } | 23270 | } |
| 23080 | 23271 | ||
| 23272 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 23273 | |||
| 23081 | /* Calculate line-height and line-spacing properties. | 23274 | /* Calculate line-height and line-spacing properties. |
| 23082 | An integer value specifies explicit pixel value. | 23275 | An integer value specifies explicit pixel value. |
| 23083 | A float value specifies relative value to current face height. | 23276 | A float value specifies relative value to current face height. |
| @@ -23992,6 +24185,8 @@ x_produce_glyphs (struct it *it) | |||
| 23992 | Lisp_Object gstring; | 24185 | Lisp_Object gstring; |
| 23993 | struct font_metrics metrics; | 24186 | struct font_metrics metrics; |
| 23994 | 24187 | ||
| 24188 | it->nglyphs = 1; | ||
| 24189 | |||
| 23995 | gstring = composition_gstring_from_id (it->cmp_it.id); | 24190 | gstring = composition_gstring_from_id (it->cmp_it.id); |
| 23996 | it->pixel_width | 24191 | it->pixel_width |
| 23997 | = composition_gstring_width (gstring, it->cmp_it.from, it->cmp_it.to, | 24192 | = composition_gstring_width (gstring, it->cmp_it.from, it->cmp_it.to, |
diff --git a/src/xfaces.c b/src/xfaces.c index 52b125b42e6..431ca07b8df 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -293,7 +293,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 293 | 293 | ||
| 294 | /* Non-zero if face attribute ATTR is `ignore-defface'. */ | 294 | /* Non-zero if face attribute ATTR is `ignore-defface'. */ |
| 295 | 295 | ||
| 296 | #define IGNORE_DEFFACE_P(ATTR) EQ ((ATTR), Qignore_defface) | 296 | #define IGNORE_DEFFACE_P(ATTR) EQ ((ATTR), QCignore_defface) |
| 297 | 297 | ||
| 298 | /* Value is the number of elements of VECTOR. */ | 298 | /* Value is the number of elements of VECTOR. */ |
| 299 | 299 | ||
| @@ -332,14 +332,14 @@ static Lisp_Object Qultra_expanded; | |||
| 332 | static Lisp_Object Qreleased_button, Qpressed_button; | 332 | static Lisp_Object Qreleased_button, Qpressed_button; |
| 333 | static Lisp_Object QCstyle, QCcolor, QCline_width; | 333 | static Lisp_Object QCstyle, QCcolor, QCline_width; |
| 334 | Lisp_Object Qunspecified; /* used in dosfns.c */ | 334 | Lisp_Object Qunspecified; /* used in dosfns.c */ |
| 335 | static Lisp_Object Qignore_defface; | 335 | static Lisp_Object QCignore_defface; |
| 336 | 336 | ||
| 337 | char unspecified_fg[] = "unspecified-fg", unspecified_bg[] = "unspecified-bg"; | 337 | char unspecified_fg[] = "unspecified-fg", unspecified_bg[] = "unspecified-bg"; |
| 338 | 338 | ||
| 339 | /* The name of the function to call when the background of the frame | 339 | /* The name of the function to call when the background of the frame |
| 340 | has changed, frame_set_background_mode. */ | 340 | has changed, frame_set_background_mode. */ |
| 341 | 341 | ||
| 342 | Lisp_Object Qframe_set_background_mode; | 342 | static Lisp_Object Qframe_set_background_mode; |
| 343 | 343 | ||
| 344 | /* Names of basic faces. */ | 344 | /* Names of basic faces. */ |
| 345 | 345 | ||
| @@ -403,7 +403,7 @@ static int next_lface_id; | |||
| 403 | /* A vector mapping Lisp face Id's to face names. */ | 403 | /* A vector mapping Lisp face Id's to face names. */ |
| 404 | 404 | ||
| 405 | static Lisp_Object *lface_id_to_name; | 405 | static Lisp_Object *lface_id_to_name; |
| 406 | static int lface_id_to_name_size; | 406 | static ptrdiff_t lface_id_to_name_size; |
| 407 | 407 | ||
| 408 | /* TTY color-related functions (defined in tty-colors.el). */ | 408 | /* TTY color-related functions (defined in tty-colors.el). */ |
| 409 | 409 | ||
| @@ -458,11 +458,11 @@ struct table_entry; | |||
| 458 | struct named_merge_point; | 458 | struct named_merge_point; |
| 459 | 459 | ||
| 460 | static void map_tty_color (struct frame *, struct face *, | 460 | static void map_tty_color (struct frame *, struct face *, |
| 461 | enum lface_attribute_index, int *); | 461 | enum lface_attribute_index, int *); |
| 462 | static Lisp_Object resolve_face_name (Lisp_Object, int); | 462 | static Lisp_Object resolve_face_name (Lisp_Object, int); |
| 463 | static void set_font_frame_param (Lisp_Object, Lisp_Object); | 463 | static void set_font_frame_param (Lisp_Object, Lisp_Object); |
| 464 | static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *, | 464 | static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *, |
| 465 | int, struct named_merge_point *); | 465 | int, struct named_merge_point *); |
| 466 | static ptrdiff_t load_pixmap (struct frame *, Lisp_Object, | 466 | static ptrdiff_t load_pixmap (struct frame *, Lisp_Object, |
| 467 | unsigned *, unsigned *); | 467 | unsigned *, unsigned *); |
| 468 | static struct frame *frame_or_selected_frame (Lisp_Object, int); | 468 | static struct frame *frame_or_selected_frame (Lisp_Object, int); |
| @@ -470,9 +470,9 @@ static void load_face_colors (struct frame *, struct face *, Lisp_Object *); | |||
| 470 | static void free_face_colors (struct frame *, struct face *); | 470 | static void free_face_colors (struct frame *, struct face *); |
| 471 | static int face_color_gray_p (struct frame *, const char *); | 471 | static int face_color_gray_p (struct frame *, const char *); |
| 472 | static struct face *realize_face (struct face_cache *, Lisp_Object *, | 472 | static struct face *realize_face (struct face_cache *, Lisp_Object *, |
| 473 | int); | 473 | int); |
| 474 | static struct face *realize_non_ascii_face (struct frame *, Lisp_Object, | 474 | static struct face *realize_non_ascii_face (struct frame *, Lisp_Object, |
| 475 | struct face *); | 475 | struct face *); |
| 476 | static struct face *realize_x_face (struct face_cache *, Lisp_Object *); | 476 | static struct face *realize_x_face (struct face_cache *, Lisp_Object *); |
| 477 | static struct face *realize_tty_face (struct face_cache *, Lisp_Object *); | 477 | static struct face *realize_tty_face (struct face_cache *, Lisp_Object *); |
| 478 | static int realize_basic_faces (struct frame *); | 478 | static int realize_basic_faces (struct frame *); |
| @@ -488,11 +488,11 @@ static void clear_face_gcs (struct face_cache *); | |||
| 488 | static void free_face_cache (struct face_cache *); | 488 | static void free_face_cache (struct face_cache *); |
| 489 | static int face_fontset (Lisp_Object *); | 489 | static int face_fontset (Lisp_Object *); |
| 490 | static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*, | 490 | static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*, |
| 491 | struct named_merge_point *); | 491 | struct named_merge_point *); |
| 492 | static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, | 492 | static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, |
| 493 | int, struct named_merge_point *); | 493 | int, struct named_merge_point *); |
| 494 | static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object, | 494 | static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object, |
| 495 | int); | 495 | int); |
| 496 | static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int); | 496 | static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int); |
| 497 | static struct face *make_realized_face (Lisp_Object *); | 497 | static struct face *make_realized_face (Lisp_Object *); |
| 498 | static void cache_face (struct face_cache *, struct face *, unsigned); | 498 | static void cache_face (struct face_cache *, struct face *, unsigned); |
| @@ -623,7 +623,8 @@ x_free_colors (struct frame *f, long unsigned int *pixels, int npixels) | |||
| 623 | is called. */ | 623 | is called. */ |
| 624 | 624 | ||
| 625 | void | 625 | void |
| 626 | x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap, long unsigned int *pixels, int npixels) | 626 | x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap, |
| 627 | long unsigned int *pixels, int npixels) | ||
| 627 | { | 628 | { |
| 628 | struct x_display_info *dpyinfo = x_display_info_for_display (dpy); | 629 | struct x_display_info *dpyinfo = x_display_info_for_display (dpy); |
| 629 | int class = dpyinfo->visual->class; | 630 | int class = dpyinfo->visual->class; |
| @@ -698,8 +699,8 @@ x_free_gc (struct frame *f, GC gc) | |||
| 698 | 699 | ||
| 699 | static inline GC | 700 | static inline GC |
| 700 | x_create_gc (struct frame *f, | 701 | x_create_gc (struct frame *f, |
| 701 | unsigned long mask, | 702 | unsigned long mask, |
| 702 | XGCValues *xgcv) | 703 | XGCValues *xgcv) |
| 703 | { | 704 | { |
| 704 | GC gc = xmalloc (sizeof (*gc)); | 705 | GC gc = xmalloc (sizeof (*gc)); |
| 705 | if (gc) | 706 | if (gc) |
| @@ -792,7 +793,7 @@ init_frame_faces (struct frame *f) | |||
| 792 | if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f)) | 793 | if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f)) |
| 793 | #endif | 794 | #endif |
| 794 | if (!realize_basic_faces (f)) | 795 | if (!realize_basic_faces (f)) |
| 795 | abort (); | 796 | abort (); |
| 796 | } | 797 | } |
| 797 | 798 | ||
| 798 | 799 | ||
| @@ -963,7 +964,8 @@ the pixmap. Bits are stored row by row, each row occupies | |||
| 963 | if these pointers are not null. */ | 964 | if these pointers are not null. */ |
| 964 | 965 | ||
| 965 | static ptrdiff_t | 966 | static ptrdiff_t |
| 966 | load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr, unsigned int *h_ptr) | 967 | load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr, |
| 968 | unsigned int *h_ptr) | ||
| 967 | { | 969 | { |
| 968 | ptrdiff_t bitmap_id; | 970 | ptrdiff_t bitmap_id; |
| 969 | 971 | ||
| @@ -1057,7 +1059,8 @@ parse_rgb_list (Lisp_Object rgb_list, XColor *color) | |||
| 1057 | returned in it. */ | 1059 | returned in it. */ |
| 1058 | 1060 | ||
| 1059 | static int | 1061 | static int |
| 1060 | tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, XColor *std_color) | 1062 | tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, |
| 1063 | XColor *std_color) | ||
| 1061 | { | 1064 | { |
| 1062 | Lisp_Object frame, color_desc; | 1065 | Lisp_Object frame, color_desc; |
| 1063 | 1066 | ||
| @@ -1153,7 +1156,8 @@ tty_defined_color (struct frame *f, const char *color_name, | |||
| 1153 | This does the right thing for any type of frame. */ | 1156 | This does the right thing for any type of frame. */ |
| 1154 | 1157 | ||
| 1155 | static int | 1158 | static int |
| 1156 | defined_color (struct frame *f, const char *color_name, XColor *color_def, int alloc) | 1159 | defined_color (struct frame *f, const char *color_name, XColor *color_def, |
| 1160 | int alloc) | ||
| 1157 | { | 1161 | { |
| 1158 | if (!FRAME_WINDOW_P (f)) | 1162 | if (!FRAME_WINDOW_P (f)) |
| 1159 | return tty_defined_color (f, color_name, color_def, alloc); | 1163 | return tty_defined_color (f, color_name, color_def, alloc); |
| @@ -1240,7 +1244,8 @@ face_color_gray_p (struct frame *f, const char *color_name) | |||
| 1240 | color. */ | 1244 | color. */ |
| 1241 | 1245 | ||
| 1242 | static int | 1246 | static int |
| 1243 | face_color_supported_p (struct frame *f, const char *color_name, int background_p) | 1247 | face_color_supported_p (struct frame *f, const char *color_name, |
| 1248 | int background_p) | ||
| 1244 | { | 1249 | { |
| 1245 | Lisp_Object frame; | 1250 | Lisp_Object frame; |
| 1246 | XColor not_used; | 1251 | XColor not_used; |
| @@ -1313,7 +1318,8 @@ COLOR must be a valid color name. */) | |||
| 1313 | these colors. */ | 1318 | these colors. */ |
| 1314 | 1319 | ||
| 1315 | unsigned long | 1320 | unsigned long |
| 1316 | load_color (struct frame *f, struct face *face, Lisp_Object name, enum lface_attribute_index target_index) | 1321 | load_color (struct frame *f, struct face *face, Lisp_Object name, |
| 1322 | enum lface_attribute_index target_index) | ||
| 1317 | { | 1323 | { |
| 1318 | XColor color; | 1324 | XColor color; |
| 1319 | 1325 | ||
| @@ -1721,7 +1727,8 @@ fonts to match. The first MAXIMUM fonts are reported. | |||
| 1721 | The optional fifth argument WIDTH, if specified, is a number of columns | 1727 | The optional fifth argument WIDTH, if specified, is a number of columns |
| 1722 | occupied by a character of a font. In that case, return only fonts | 1728 | occupied by a character of a font. In that case, return only fonts |
| 1723 | the WIDTH times as wide as FACE on FRAME. */) | 1729 | the WIDTH times as wide as FACE on FRAME. */) |
| 1724 | (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame, Lisp_Object maximum, Lisp_Object width) | 1730 | (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame, |
| 1731 | Lisp_Object maximum, Lisp_Object width) | ||
| 1725 | { | 1732 | { |
| 1726 | struct frame *f; | 1733 | struct frame *f; |
| 1727 | int size, avgwidth IF_LINT (= 0); | 1734 | int size, avgwidth IF_LINT (= 0); |
| @@ -2059,7 +2066,8 @@ resolve_face_name (Lisp_Object face_name, int signal_p) | |||
| 2059 | signal an error if FACE_NAME is not a valid face name. If SIGNAL_P | 2066 | signal an error if FACE_NAME is not a valid face name. If SIGNAL_P |
| 2060 | is zero, value is nil if FACE_NAME is not a valid face name. */ | 2067 | is zero, value is nil if FACE_NAME is not a valid face name. */ |
| 2061 | static inline Lisp_Object | 2068 | static inline Lisp_Object |
| 2062 | lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name, int signal_p) | 2069 | lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name, |
| 2070 | int signal_p) | ||
| 2063 | { | 2071 | { |
| 2064 | Lisp_Object lface; | 2072 | Lisp_Object lface; |
| 2065 | 2073 | ||
| @@ -2101,7 +2109,8 @@ lface_from_face_name (struct frame *f, Lisp_Object face_name, int signal_p) | |||
| 2101 | Otherwise, value is zero if FACE_NAME is not a face. */ | 2109 | Otherwise, value is zero if FACE_NAME is not a face. */ |
| 2102 | 2110 | ||
| 2103 | static inline int | 2111 | static inline int |
| 2104 | get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name, Lisp_Object *attrs, int signal_p) | 2112 | get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name, |
| 2113 | Lisp_Object *attrs, int signal_p) | ||
| 2105 | { | 2114 | { |
| 2106 | Lisp_Object lface; | 2115 | Lisp_Object lface; |
| 2107 | 2116 | ||
| @@ -2122,7 +2131,9 @@ get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name, Lisp_Obje | |||
| 2122 | Otherwise, value is zero if FACE_NAME is not a face. */ | 2131 | Otherwise, value is zero if FACE_NAME is not a face. */ |
| 2123 | 2132 | ||
| 2124 | static inline int | 2133 | static inline int |
| 2125 | get_lface_attributes (struct frame *f, Lisp_Object face_name, Lisp_Object *attrs, int signal_p, struct named_merge_point *named_merge_points) | 2134 | get_lface_attributes (struct frame *f, Lisp_Object face_name, |
| 2135 | Lisp_Object *attrs, int signal_p, | ||
| 2136 | struct named_merge_point *named_merge_points) | ||
| 2126 | { | 2137 | { |
| 2127 | Lisp_Object face_remapping; | 2138 | Lisp_Object face_remapping; |
| 2128 | 2139 | ||
| @@ -2165,7 +2176,7 @@ lface_fully_specified_p (Lisp_Object *attrs) | |||
| 2165 | for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | 2176 | for (i = 1; i < LFACE_VECTOR_SIZE; ++i) |
| 2166 | if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX) | 2177 | if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX) |
| 2167 | if ((UNSPECIFIEDP (attrs[i]) || IGNORE_DEFFACE_P (attrs[i]))) | 2178 | if ((UNSPECIFIEDP (attrs[i]) || IGNORE_DEFFACE_P (attrs[i]))) |
| 2168 | break; | 2179 | break; |
| 2169 | 2180 | ||
| 2170 | return i == LFACE_VECTOR_SIZE; | 2181 | return i == LFACE_VECTOR_SIZE; |
| 2171 | } | 2182 | } |
| @@ -2178,7 +2189,8 @@ lface_fully_specified_p (Lisp_Object *attrs) | |||
| 2178 | of FORCE_P. */ | 2189 | of FORCE_P. */ |
| 2179 | 2190 | ||
| 2180 | static int | 2191 | static int |
| 2181 | set_lface_from_font (struct frame *f, Lisp_Object lface, Lisp_Object font_object, int force_p) | 2192 | set_lface_from_font (struct frame *f, Lisp_Object lface, |
| 2193 | Lisp_Object font_object, int force_p) | ||
| 2182 | { | 2194 | { |
| 2183 | Lisp_Object val; | 2195 | Lisp_Object val; |
| 2184 | struct font *font = XFONT_OBJECT (font_object); | 2196 | struct font *font = XFONT_OBJECT (font_object); |
| @@ -2288,7 +2300,8 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid) | |||
| 2288 | other places. */ | 2300 | other places. */ |
| 2289 | 2301 | ||
| 2290 | static inline void | 2302 | static inline void |
| 2291 | merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, struct named_merge_point *named_merge_points) | 2303 | merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, |
| 2304 | struct named_merge_point *named_merge_points) | ||
| 2292 | { | 2305 | { |
| 2293 | int i; | 2306 | int i; |
| 2294 | 2307 | ||
| @@ -2355,7 +2368,8 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, struct | |||
| 2355 | merging succeeded. */ | 2368 | merging succeeded. */ |
| 2356 | 2369 | ||
| 2357 | static int | 2370 | static int |
| 2358 | merge_named_face (struct frame *f, Lisp_Object face_name, Lisp_Object *to, struct named_merge_point *named_merge_points) | 2371 | merge_named_face (struct frame *f, Lisp_Object face_name, Lisp_Object *to, |
| 2372 | struct named_merge_point *named_merge_points) | ||
| 2359 | { | 2373 | { |
| 2360 | struct named_merge_point named_merge_point; | 2374 | struct named_merge_point named_merge_point; |
| 2361 | 2375 | ||
| @@ -2405,7 +2419,8 @@ merge_named_face (struct frame *f, Lisp_Object face_name, Lisp_Object *to, struc | |||
| 2405 | specifications. */ | 2419 | specifications. */ |
| 2406 | 2420 | ||
| 2407 | static int | 2421 | static int |
| 2408 | merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to, int err_msgs, struct named_merge_point *named_merge_points) | 2422 | merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to, |
| 2423 | int err_msgs, struct named_merge_point *named_merge_points) | ||
| 2409 | { | 2424 | { |
| 2410 | int ok = 1; /* Succeed without an error? */ | 2425 | int ok = 1; /* Succeed without an error? */ |
| 2411 | 2426 | ||
| @@ -2667,12 +2682,10 @@ Value is a vector of face attributes. */) | |||
| 2667 | The mapping from Lisp face to Lisp face id is given by the | 2682 | The mapping from Lisp face to Lisp face id is given by the |
| 2668 | property `face' of the Lisp face name. */ | 2683 | property `face' of the Lisp face name. */ |
| 2669 | if (next_lface_id == lface_id_to_name_size) | 2684 | if (next_lface_id == lface_id_to_name_size) |
| 2670 | { | 2685 | lface_id_to_name = |
| 2671 | int new_size = max (50, 2 * lface_id_to_name_size); | 2686 | xpalloc (lface_id_to_name, &lface_id_to_name_size, 1, |
| 2672 | int sz = new_size * sizeof *lface_id_to_name; | 2687 | min (INT_MAX, MOST_POSITIVE_FIXNUM), |
| 2673 | lface_id_to_name = (Lisp_Object *) xrealloc (lface_id_to_name, sz); | 2688 | sizeof *lface_id_to_name); |
| 2674 | lface_id_to_name_size = new_size; | ||
| 2675 | } | ||
| 2676 | 2689 | ||
| 2677 | lface_id_to_name[next_lface_id] = face; | 2690 | lface_id_to_name[next_lface_id] = face; |
| 2678 | Fput (face, Qface, make_number (next_lface_id)); | 2691 | Fput (face, Qface, make_number (next_lface_id)); |
| @@ -2838,7 +2851,7 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2838 | The value of that attribute will be inherited from some other | 2851 | The value of that attribute will be inherited from some other |
| 2839 | face during face merging. See internal_merge_in_global_face. */ | 2852 | face during face merging. See internal_merge_in_global_face. */ |
| 2840 | if (UNSPECIFIEDP (value)) | 2853 | if (UNSPECIFIEDP (value)) |
| 2841 | value = Qignore_defface; | 2854 | value = QCignore_defface; |
| 2842 | } | 2855 | } |
| 2843 | else | 2856 | else |
| 2844 | { | 2857 | { |
| @@ -2885,7 +2898,8 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2885 | { | 2898 | { |
| 2886 | /* The default face must have an absolute size. */ | 2899 | /* The default face must have an absolute size. */ |
| 2887 | if (!INTEGERP (value) || XINT (value) <= 0) | 2900 | if (!INTEGERP (value) || XINT (value) <= 0) |
| 2888 | signal_error ("Default face height not absolute and positive", value); | 2901 | signal_error ("Default face height not absolute and positive", |
| 2902 | value); | ||
| 2889 | } | 2903 | } |
| 2890 | else | 2904 | else |
| 2891 | { | 2905 | { |
| @@ -2895,7 +2909,8 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2895 | make_number (10), | 2909 | make_number (10), |
| 2896 | Qnil); | 2910 | Qnil); |
| 2897 | if (!INTEGERP (test) || XINT (test) <= 0) | 2911 | if (!INTEGERP (test) || XINT (test) <= 0) |
| 2898 | signal_error ("Face height does not produce a positive integer", value); | 2912 | signal_error ("Face height does not produce a positive integer", |
| 2913 | value); | ||
| 2899 | } | 2914 | } |
| 2900 | } | 2915 | } |
| 2901 | 2916 | ||
| @@ -2974,7 +2989,7 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2974 | int valid_p; | 2989 | int valid_p; |
| 2975 | 2990 | ||
| 2976 | /* Allow t meaning a simple box of width 1 in foreground color | 2991 | /* Allow t meaning a simple box of width 1 in foreground color |
| 2977 | of the face. */ | 2992 | of the face. */ |
| 2978 | if (EQ (value, Qt)) | 2993 | if (EQ (value, Qt)) |
| 2979 | value = make_number (1); | 2994 | value = make_number (1); |
| 2980 | 2995 | ||
| @@ -3319,7 +3334,8 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 3319 | has been assigned the value NEW_VALUE. */ | 3334 | has been assigned the value NEW_VALUE. */ |
| 3320 | 3335 | ||
| 3321 | void | 3336 | void |
| 3322 | update_face_from_frame_parameter (struct frame *f, Lisp_Object param, Lisp_Object new_value) | 3337 | update_face_from_frame_parameter (struct frame *f, Lisp_Object param, |
| 3338 | Lisp_Object new_value) | ||
| 3323 | { | 3339 | { |
| 3324 | Lisp_Object face = Qnil; | 3340 | Lisp_Object face = Qnil; |
| 3325 | Lisp_Object lface; | 3341 | Lisp_Object lface; |
| @@ -3633,7 +3649,7 @@ the only relative value that users see is `unspecified'. | |||
| 3633 | However, for :height, floating point values are also relative. */) | 3649 | However, for :height, floating point values are also relative. */) |
| 3634 | (Lisp_Object attribute, Lisp_Object value) | 3650 | (Lisp_Object attribute, Lisp_Object value) |
| 3635 | { | 3651 | { |
| 3636 | if (EQ (value, Qunspecified) || (EQ (value, Qignore_defface))) | 3652 | if (EQ (value, Qunspecified) || (EQ (value, QCignore_defface))) |
| 3637 | return Qt; | 3653 | return Qt; |
| 3638 | else if (EQ (attribute, QCheight)) | 3654 | else if (EQ (attribute, QCheight)) |
| 3639 | return INTEGERP (value) ? Qnil : Qt; | 3655 | return INTEGERP (value) ? Qnil : Qt; |
| @@ -3648,7 +3664,7 @@ If VALUE1 or VALUE2 are absolute (see `face-attribute-relative-p'), then | |||
| 3648 | the result will be absolute, otherwise it will be relative. */) | 3664 | the result will be absolute, otherwise it will be relative. */) |
| 3649 | (Lisp_Object attribute, Lisp_Object value1, Lisp_Object value2) | 3665 | (Lisp_Object attribute, Lisp_Object value1, Lisp_Object value2) |
| 3650 | { | 3666 | { |
| 3651 | if (EQ (value1, Qunspecified) || EQ (value1, Qignore_defface)) | 3667 | if (EQ (value1, Qunspecified) || EQ (value1, QCignore_defface)) |
| 3652 | return value2; | 3668 | return value2; |
| 3653 | else if (EQ (attribute, QCheight)) | 3669 | else if (EQ (attribute, QCheight)) |
| 3654 | return merge_face_heights (value1, value2, value1); | 3670 | return merge_face_heights (value1, value2, value1); |
| @@ -4052,7 +4068,7 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2) | |||
| 4052 | xassert (lface_fully_specified_p (lface1) | 4068 | xassert (lface_fully_specified_p (lface1) |
| 4053 | && lface_fully_specified_p (lface2)); | 4069 | && lface_fully_specified_p (lface2)); |
| 4054 | return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]), | 4070 | return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]), |
| 4055 | SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0 | 4071 | SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0 |
| 4056 | && xstrcasecmp (SSDATA (lface1[LFACE_FOUNDRY_INDEX]), | 4072 | && xstrcasecmp (SSDATA (lface1[LFACE_FOUNDRY_INDEX]), |
| 4057 | SSDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0 | 4073 | SSDATA (lface2[LFACE_FOUNDRY_INDEX])) == 0 |
| 4058 | && EQ (lface1[LFACE_HEIGHT_INDEX], lface2[LFACE_HEIGHT_INDEX]) | 4074 | && EQ (lface1[LFACE_HEIGHT_INDEX], lface2[LFACE_HEIGHT_INDEX]) |
| @@ -4064,7 +4080,7 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2) | |||
| 4064 | || (STRINGP (lface1[LFACE_FONTSET_INDEX]) | 4080 | || (STRINGP (lface1[LFACE_FONTSET_INDEX]) |
| 4065 | && STRINGP (lface2[LFACE_FONTSET_INDEX]) | 4081 | && STRINGP (lface2[LFACE_FONTSET_INDEX]) |
| 4066 | && ! xstrcasecmp (SSDATA (lface1[LFACE_FONTSET_INDEX]), | 4082 | && ! xstrcasecmp (SSDATA (lface1[LFACE_FONTSET_INDEX]), |
| 4067 | SSDATA (lface2[LFACE_FONTSET_INDEX])))) | 4083 | SSDATA (lface2[LFACE_FONTSET_INDEX])))) |
| 4068 | ); | 4084 | ); |
| 4069 | } | 4085 | } |
| 4070 | 4086 | ||
| @@ -4169,10 +4185,10 @@ color_distance (XColor *x, XColor *y) | |||
| 4169 | /* This formula is from a paper title `Colour metric' by Thiadmer Riemersma. | 4185 | /* This formula is from a paper title `Colour metric' by Thiadmer Riemersma. |
| 4170 | Quoting from that paper: | 4186 | Quoting from that paper: |
| 4171 | 4187 | ||
| 4172 | This formula has results that are very close to L*u*v* (with the | 4188 | This formula has results that are very close to L*u*v* (with the |
| 4173 | modified lightness curve) and, more importantly, it is a more even | 4189 | modified lightness curve) and, more importantly, it is a more even |
| 4174 | algorithm: it does not have a range of colours where it suddenly | 4190 | algorithm: it does not have a range of colours where it suddenly |
| 4175 | gives far from optimal results. | 4191 | gives far from optimal results. |
| 4176 | 4192 | ||
| 4177 | See <http://www.compuphase.com/cmetric.htm> for more info. */ | 4193 | See <http://www.compuphase.com/cmetric.htm> for more info. */ |
| 4178 | 4194 | ||
| @@ -4410,15 +4426,8 @@ cache_face (struct face_cache *c, struct face *face, unsigned int hash) | |||
| 4410 | if (i == c->used) | 4426 | if (i == c->used) |
| 4411 | { | 4427 | { |
| 4412 | if (c->used == c->size) | 4428 | if (c->used == c->size) |
| 4413 | { | 4429 | c->faces_by_id = xpalloc (c->faces_by_id, &c->size, 1, MAX_FACE_ID, |
| 4414 | int new_size, sz; | 4430 | sizeof *c->faces_by_id); |
| 4415 | new_size = min (2 * c->size, MAX_FACE_ID); | ||
| 4416 | if (new_size == c->size) | ||
| 4417 | abort (); /* Alternatives? ++kfs */ | ||
| 4418 | sz = new_size * sizeof *c->faces_by_id; | ||
| 4419 | c->faces_by_id = (struct face **) xrealloc (c->faces_by_id, sz); | ||
| 4420 | c->size = new_size; | ||
| 4421 | } | ||
| 4422 | c->used++; | 4431 | c->used++; |
| 4423 | } | 4432 | } |
| 4424 | 4433 | ||
| @@ -4702,7 +4711,8 @@ face_with_height (struct frame *f, int face_id, int height) | |||
| 4702 | default face. FACE_ID is assumed to be already realized. */ | 4711 | default face. FACE_ID is assumed to be already realized. */ |
| 4703 | 4712 | ||
| 4704 | int | 4713 | int |
| 4705 | lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id, int signal_p) | 4714 | lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id, |
| 4715 | int signal_p) | ||
| 4706 | { | 4716 | { |
| 4707 | Lisp_Object attrs[LFACE_VECTOR_SIZE]; | 4717 | Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
| 4708 | Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; | 4718 | Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; |
| @@ -4758,7 +4768,8 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector, | |||
| 4758 | \(2) `close in spirit' to what the attributes specify, if not exact. */ | 4768 | \(2) `close in spirit' to what the attributes specify, if not exact. */ |
| 4759 | 4769 | ||
| 4760 | static int | 4770 | static int |
| 4761 | x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face *def_face) | 4771 | x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, |
| 4772 | struct face *def_face) | ||
| 4762 | { | 4773 | { |
| 4763 | Lisp_Object *def_attrs = def_face->lface; | 4774 | Lisp_Object *def_attrs = def_face->lface; |
| 4764 | 4775 | ||
| @@ -4859,7 +4870,8 @@ x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face * | |||
| 4859 | substitution of a `dim' face for italic. */ | 4870 | substitution of a `dim' face for italic. */ |
| 4860 | 4871 | ||
| 4861 | static int | 4872 | static int |
| 4862 | tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face *def_face) | 4873 | tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, |
| 4874 | struct face *def_face) | ||
| 4863 | { | 4875 | { |
| 4864 | int weight; | 4876 | int weight; |
| 4865 | Lisp_Object val, fg, bg; | 4877 | Lisp_Object val, fg, bg; |
| @@ -5011,7 +5023,8 @@ tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face | |||
| 5011 | /* See if the capabilities we selected above are supported, with the | 5023 | /* See if the capabilities we selected above are supported, with the |
| 5012 | given colors. */ | 5024 | given colors. */ |
| 5013 | if (test_caps != 0 && | 5025 | if (test_caps != 0 && |
| 5014 | ! tty_capable_p (FRAME_TTY (f), test_caps, fg_tty_color.pixel, bg_tty_color.pixel)) | 5026 | ! tty_capable_p (FRAME_TTY (f), test_caps, fg_tty_color.pixel, |
| 5027 | bg_tty_color.pixel)) | ||
| 5015 | return 0; | 5028 | return 0; |
| 5016 | 5029 | ||
| 5017 | 5030 | ||
| @@ -5283,8 +5296,8 @@ realize_basic_faces (struct frame *f) | |||
| 5283 | { | 5296 | { |
| 5284 | FRAME_FACE_CACHE (f)->menu_face_changed_p = 0; | 5297 | FRAME_FACE_CACHE (f)->menu_face_changed_p = 0; |
| 5285 | #ifdef USE_X_TOOLKIT | 5298 | #ifdef USE_X_TOOLKIT |
| 5286 | if (FRAME_WINDOW_P (f)) | 5299 | if (FRAME_WINDOW_P (f)) |
| 5287 | x_update_menu_appearance (f); | 5300 | x_update_menu_appearance (f); |
| 5288 | #endif | 5301 | #endif |
| 5289 | } | 5302 | } |
| 5290 | 5303 | ||
| @@ -5404,14 +5417,14 @@ realize_default_face (struct frame *f) | |||
| 5404 | if (FRAME_X_P (f) && face->font != FRAME_FONT (f)) | 5417 | if (FRAME_X_P (f) && face->font != FRAME_FONT (f)) |
| 5405 | { | 5418 | { |
| 5406 | /* This can happen when making a frame on a display that does | 5419 | /* This can happen when making a frame on a display that does |
| 5407 | not support the default font. */ | 5420 | not support the default font. */ |
| 5408 | if (!face->font) | 5421 | if (!face->font) |
| 5409 | return 0; | 5422 | return 0; |
| 5410 | 5423 | ||
| 5411 | /* Otherwise, the font specified for the frame was not | 5424 | /* Otherwise, the font specified for the frame was not |
| 5412 | acceptable as a font for the default face (perhaps because | 5425 | acceptable as a font for the default face (perhaps because |
| 5413 | auto-scaled fonts are rejected), so we must adjust the frame | 5426 | auto-scaled fonts are rejected), so we must adjust the frame |
| 5414 | font. */ | 5427 | font. */ |
| 5415 | x_set_font (f, LFACE_FONT (lface), Qnil); | 5428 | x_set_font (f, LFACE_FONT (lface), Qnil); |
| 5416 | } | 5429 | } |
| 5417 | #endif /* HAVE_X_WINDOWS */ | 5430 | #endif /* HAVE_X_WINDOWS */ |
| @@ -5502,7 +5515,8 @@ realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id) | |||
| 5502 | no-font. */ | 5515 | no-font. */ |
| 5503 | 5516 | ||
| 5504 | static struct face * | 5517 | static struct face * |
| 5505 | realize_non_ascii_face (struct frame *f, Lisp_Object font_object, struct face *base_face) | 5518 | realize_non_ascii_face (struct frame *f, Lisp_Object font_object, |
| 5519 | struct face *base_face) | ||
| 5506 | { | 5520 | { |
| 5507 | struct face_cache *cache = FRAME_FACE_CACHE (f); | 5521 | struct face_cache *cache = FRAME_FACE_CACHE (f); |
| 5508 | struct face *face; | 5522 | struct face *face; |
| @@ -5621,7 +5635,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs) | |||
| 5621 | else if (INTEGERP (box)) | 5635 | else if (INTEGERP (box)) |
| 5622 | { | 5636 | { |
| 5623 | /* Simple box of specified line width in foreground color of the | 5637 | /* Simple box of specified line width in foreground color of the |
| 5624 | face. */ | 5638 | face. */ |
| 5625 | xassert (XINT (box) != 0); | 5639 | xassert (XINT (box) != 0); |
| 5626 | face->box = FACE_SIMPLE_BOX; | 5640 | face->box = FACE_SIMPLE_BOX; |
| 5627 | face->box_line_width = XINT (box); | 5641 | face->box_line_width = XINT (box); |
| @@ -5743,7 +5757,8 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs) | |||
| 5743 | default foreground/background colors. */ | 5757 | default foreground/background colors. */ |
| 5744 | 5758 | ||
| 5745 | static void | 5759 | static void |
| 5746 | map_tty_color (struct frame *f, struct face *face, enum lface_attribute_index idx, int *defaulted) | 5760 | map_tty_color (struct frame *f, struct face *face, |
| 5761 | enum lface_attribute_index idx, int *defaulted) | ||
| 5747 | { | 5762 | { |
| 5748 | Lisp_Object frame, color, def; | 5763 | Lisp_Object frame, color, def; |
| 5749 | int foreground_p = idx == LFACE_FOREGROUND_INDEX; | 5764 | int foreground_p = idx == LFACE_FOREGROUND_INDEX; |
| @@ -5799,7 +5814,7 @@ map_tty_color (struct frame *f, struct face *face, enum lface_attribute_index id | |||
| 5799 | face->lface[idx] = tty_color_name (f, pixel); | 5814 | face->lface[idx] = tty_color_name (f, pixel); |
| 5800 | *defaulted = 1; | 5815 | *defaulted = 1; |
| 5801 | } | 5816 | } |
| 5802 | } | 5817 | } |
| 5803 | #endif /* MSDOS */ | 5818 | #endif /* MSDOS */ |
| 5804 | } | 5819 | } |
| 5805 | 5820 | ||
| @@ -5984,9 +5999,18 @@ face_at_buffer_position (struct window *w, EMACS_INT pos, | |||
| 5984 | 5999 | ||
| 5985 | *endptr = endpos; | 6000 | *endptr = endpos; |
| 5986 | 6001 | ||
| 5987 | default_face = FACE_FROM_ID (f, base_face_id >= 0 ? base_face_id | 6002 | { |
| 5988 | : NILP (Vface_remapping_alist) ? DEFAULT_FACE_ID | 6003 | int face_id; |
| 5989 | : lookup_basic_face (f, DEFAULT_FACE_ID)); | 6004 | |
| 6005 | if (base_face_id >= 0) | ||
| 6006 | face_id = base_face_id; | ||
| 6007 | else if (NILP (Vface_remapping_alist)) | ||
| 6008 | face_id = DEFAULT_FACE_ID; | ||
| 6009 | else | ||
| 6010 | face_id = lookup_basic_face (f, DEFAULT_FACE_ID); | ||
| 6011 | |||
| 6012 | default_face = FACE_FROM_ID (f, face_id); | ||
| 6013 | } | ||
| 5990 | 6014 | ||
| 5991 | /* Optimize common cases where we can use the default face. */ | 6015 | /* Optimize common cases where we can use the default face. */ |
| 5992 | if (noverlays == 0 | 6016 | if (noverlays == 0 |
| @@ -6460,7 +6484,7 @@ syms_of_xfaces (void) | |||
| 6460 | DEFSYM (Qbackground_color, "background-color"); | 6484 | DEFSYM (Qbackground_color, "background-color"); |
| 6461 | DEFSYM (Qforeground_color, "foreground-color"); | 6485 | DEFSYM (Qforeground_color, "foreground-color"); |
| 6462 | DEFSYM (Qunspecified, "unspecified"); | 6486 | DEFSYM (Qunspecified, "unspecified"); |
| 6463 | DEFSYM (Qignore_defface, ":ignore-defface"); | 6487 | DEFSYM (QCignore_defface, ":ignore-defface"); |
| 6464 | 6488 | ||
| 6465 | DEFSYM (Qface_alias, "face-alias"); | 6489 | DEFSYM (Qface_alias, "face-alias"); |
| 6466 | DEFSYM (Qdefault, "default"); | 6490 | DEFSYM (Qdefault, "default"); |
| @@ -6598,7 +6622,7 @@ face definitions. For instance, the mode my-mode could define a face | |||
| 6598 | `my-mode-default', and then in the mode setup function, do: | 6622 | `my-mode-default', and then in the mode setup function, do: |
| 6599 | 6623 | ||
| 6600 | (set (make-local-variable 'face-remapping-alist) | 6624 | (set (make-local-variable 'face-remapping-alist) |
| 6601 | '((default my-mode-default)))). | 6625 | '((default my-mode-default)))). |
| 6602 | 6626 | ||
| 6603 | Because Emacs normally only redraws screen areas when the underlying | 6627 | Because Emacs normally only redraws screen areas when the underlying |
| 6604 | buffer contents change, you may need to call `redraw-display' after | 6628 | buffer contents change, you may need to call `redraw-display' after |
diff --git a/src/xfns.c b/src/xfns.c index eec19b9d275..9a3d5fcda83 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -145,7 +145,8 @@ static Lisp_Object Qcompound_text, Qcancel_timer; | |||
| 145 | Lisp_Object Qfont_param; | 145 | Lisp_Object Qfont_param; |
| 146 | 146 | ||
| 147 | #if GLYPH_DEBUG | 147 | #if GLYPH_DEBUG |
| 148 | static int image_cache_refcount, dpyinfo_refcount; | 148 | static ptrdiff_t image_cache_refcount; |
| 149 | static int dpyinfo_refcount; | ||
| 149 | #endif | 150 | #endif |
| 150 | 151 | ||
| 151 | #if defined (USE_GTK) && defined (HAVE_FREETYPE) | 152 | #if defined (USE_GTK) && defined (HAVE_FREETYPE) |
| @@ -1470,7 +1471,8 @@ x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object old | |||
| 1470 | the result should be `COMPOUND_TEXT'. */ | 1471 | the result should be `COMPOUND_TEXT'. */ |
| 1471 | 1472 | ||
| 1472 | static unsigned char * | 1473 | static unsigned char * |
| 1473 | x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, int *text_bytes, int *stringp, int *freep) | 1474 | x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, |
| 1475 | ptrdiff_t *text_bytes, int *stringp, int *freep) | ||
| 1474 | { | 1476 | { |
| 1475 | int result = string_xstring_p (string); | 1477 | int result = string_xstring_p (string); |
| 1476 | struct coding_system coding; | 1478 | struct coding_system coding; |
| @@ -1488,8 +1490,8 @@ x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, in | |||
| 1488 | coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK); | 1490 | coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK); |
| 1489 | /* We suppress producing escape sequences for composition. */ | 1491 | /* We suppress producing escape sequences for composition. */ |
| 1490 | coding.common_flags &= ~CODING_ANNOTATION_MASK; | 1492 | coding.common_flags &= ~CODING_ANNOTATION_MASK; |
| 1493 | coding.destination = xnmalloc (SCHARS (string), 2); | ||
| 1491 | coding.dst_bytes = SCHARS (string) * 2; | 1494 | coding.dst_bytes = SCHARS (string) * 2; |
| 1492 | coding.destination = (unsigned char *) xmalloc (coding.dst_bytes); | ||
| 1493 | encode_coding_object (&coding, string, 0, 0, | 1495 | encode_coding_object (&coding, string, 0, 0, |
| 1494 | SCHARS (string), SBYTES (string), Qnil); | 1496 | SCHARS (string), SBYTES (string), Qnil); |
| 1495 | *text_bytes = coding.produced; | 1497 | *text_bytes = coding.produced; |
| @@ -1511,7 +1513,8 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name) | |||
| 1511 | BLOCK_INPUT; | 1513 | BLOCK_INPUT; |
| 1512 | { | 1514 | { |
| 1513 | XTextProperty text, icon; | 1515 | XTextProperty text, icon; |
| 1514 | int bytes, stringp; | 1516 | ptrdiff_t bytes; |
| 1517 | int stringp; | ||
| 1515 | int do_free_icon_value = 0, do_free_text_value = 0; | 1518 | int do_free_icon_value = 0, do_free_text_value = 0; |
| 1516 | Lisp_Object coding_system; | 1519 | Lisp_Object coding_system; |
| 1517 | Lisp_Object encoded_name; | 1520 | Lisp_Object encoded_name; |
| @@ -1550,6 +1553,8 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name) | |||
| 1550 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); | 1553 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
| 1551 | text.format = 8; | 1554 | text.format = 8; |
| 1552 | text.nitems = bytes; | 1555 | text.nitems = bytes; |
| 1556 | if (text.nitems != bytes) | ||
| 1557 | error ("Window name too large"); | ||
| 1553 | 1558 | ||
| 1554 | if (!STRINGP (f->icon_name)) | 1559 | if (!STRINGP (f->icon_name)) |
| 1555 | { | 1560 | { |
| @@ -1565,6 +1570,8 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name) | |||
| 1565 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); | 1570 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
| 1566 | icon.format = 8; | 1571 | icon.format = 8; |
| 1567 | icon.nitems = bytes; | 1572 | icon.nitems = bytes; |
| 1573 | if (icon.nitems != bytes) | ||
| 1574 | error ("Icon name too large"); | ||
| 1568 | 1575 | ||
| 1569 | encoded_icon_name = ENCODE_UTF_8 (f->icon_name); | 1576 | encoded_icon_name = ENCODE_UTF_8 (f->icon_name); |
| 1570 | } | 1577 | } |
| @@ -4193,21 +4200,19 @@ FRAME. Default is to change on the edit X window. */) | |||
| 4193 | 4200 | ||
| 4194 | if (CONSP (value)) | 4201 | if (CONSP (value)) |
| 4195 | { | 4202 | { |
| 4203 | ptrdiff_t elsize; | ||
| 4204 | |||
| 4196 | nelements = x_check_property_data (value); | 4205 | nelements = x_check_property_data (value); |
| 4197 | if (nelements == -1) | 4206 | if (nelements == -1) |
| 4198 | error ("Bad data in VALUE, must be number, string or cons"); | 4207 | error ("Bad data in VALUE, must be number, string or cons"); |
| 4199 | 4208 | ||
| 4200 | if (element_format == 8) | 4209 | /* The man page for XChangeProperty: |
| 4201 | data = (unsigned char *) xmalloc (nelements); | 4210 | "If the specified format is 32, the property data must be a |
| 4202 | else if (element_format == 16) | 4211 | long array." |
| 4203 | data = (unsigned char *) xmalloc (nelements*2); | 4212 | This applies even if long is more than 32 bits. The X library |
| 4204 | else /* format == 32 */ | 4213 | converts to 32 bits before sending to the X server. */ |
| 4205 | /* The man page for XChangeProperty: | 4214 | elsize = element_format == 32 ? sizeof (long) : element_format >> 3; |
| 4206 | "If the specified format is 32, the property data must be a | 4215 | data = xnmalloc (nelements, elsize); |
| 4207 | long array." | ||
| 4208 | This applies even if long is more than 64 bits. The X library | ||
| 4209 | converts to 32 bits before sending to the X server. */ | ||
| 4210 | data = (unsigned char *) xmalloc (nelements * sizeof(long)); | ||
| 4211 | 4216 | ||
| 4212 | x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format); | 4217 | x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format); |
| 4213 | } | 4218 | } |
| @@ -4215,7 +4220,9 @@ FRAME. Default is to change on the edit X window. */) | |||
| 4215 | { | 4220 | { |
| 4216 | CHECK_STRING (value); | 4221 | CHECK_STRING (value); |
| 4217 | data = SDATA (value); | 4222 | data = SDATA (value); |
| 4218 | nelements = SCHARS (value); | 4223 | if (INT_MAX < SBYTES (value)) |
| 4224 | error ("VALUE too long"); | ||
| 4225 | nelements = SBYTES (value); | ||
| 4219 | } | 4226 | } |
| 4220 | 4227 | ||
| 4221 | BLOCK_INPUT; | 4228 | BLOCK_INPUT; |
diff --git a/src/xgselect.c b/src/xgselect.c index 9ccdd37489f..339ec475117 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -29,7 +29,7 @@ along with GNU Emacs. If not, see <http§://www.gnu.org/licenses/>. */ | |||
| 29 | #include <setjmp.h> | 29 | #include <setjmp.h> |
| 30 | 30 | ||
| 31 | static GPollFD *gfds; | 31 | static GPollFD *gfds; |
| 32 | static int gfds_size; | 32 | static ptrdiff_t gfds_size; |
| 33 | 33 | ||
| 34 | int | 34 | int |
| 35 | xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | 35 | xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, |
| @@ -54,10 +54,9 @@ xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | |||
| 54 | do { | 54 | do { |
| 55 | if (n_gfds > gfds_size) | 55 | if (n_gfds > gfds_size) |
| 56 | { | 56 | { |
| 57 | while (n_gfds > gfds_size) | ||
| 58 | gfds_size *= 2; | ||
| 59 | xfree (gfds); | 57 | xfree (gfds); |
| 60 | gfds = xmalloc (sizeof (*gfds) * gfds_size); | 58 | gfds = xpalloc (0, &gfds_size, n_gfds - gfds_size, INT_MAX, |
| 59 | sizeof *gfds); | ||
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | n_gfds = g_main_context_query (context, | 62 | n_gfds = g_main_context_query (context, |
| @@ -141,7 +141,6 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html | |||
| 141 | Fcons (Qnil, Fnreverse (Fcons (r, result)))); | 141 | Fcons (Qnil, Fnreverse (Fcons (r, result)))); |
| 142 | 142 | ||
| 143 | xmlFreeDoc (doc); | 143 | xmlFreeDoc (doc); |
| 144 | xmlCleanupParser (); | ||
| 145 | } | 144 | } |
| 146 | 145 | ||
| 147 | return result; | 146 | return result; |
diff --git a/src/xrdb.c b/src/xrdb.c index 6a16e3260bd..63f06738b98 100644 --- a/src/xrdb.c +++ b/src/xrdb.c | |||
| @@ -426,24 +426,22 @@ get_environ_db (void) | |||
| 426 | { | 426 | { |
| 427 | XrmDatabase db; | 427 | XrmDatabase db; |
| 428 | char *p; | 428 | char *p; |
| 429 | char *path = 0, *home = 0; | 429 | char *path = 0; |
| 430 | const char *host; | ||
| 431 | 430 | ||
| 432 | if ((p = getenv ("XENVIRONMENT")) == NULL) | 431 | if ((p = getenv ("XENVIRONMENT")) == NULL) |
| 433 | { | 432 | { |
| 434 | home = gethomedir (); | 433 | static char const xdefaults[] = ".Xdefaults-"; |
| 435 | host = get_system_name (); | 434 | char *home = gethomedir (); |
| 436 | path = (char *) xmalloc (strlen (home) | 435 | char const *host = get_system_name (); |
| 437 | + sizeof (".Xdefaults-") | 436 | ptrdiff_t pathsize = strlen (home) + sizeof xdefaults + strlen (host); |
| 438 | + strlen (host)); | 437 | path = (char *) xrealloc (home, pathsize); |
| 439 | sprintf (path, "%s%s%s", home, ".Xdefaults-", host); | 438 | strcat (strcat (path, xdefaults), host); |
| 440 | p = path; | 439 | p = path; |
| 441 | } | 440 | } |
| 442 | 441 | ||
| 443 | db = XrmGetFileDatabase (p); | 442 | db = XrmGetFileDatabase (p); |
| 444 | 443 | ||
| 445 | xfree (path); | 444 | xfree (path); |
| 446 | xfree (home); | ||
| 447 | 445 | ||
| 448 | return db; | 446 | return db; |
| 449 | } | 447 | } |
diff --git a/src/xselect.c b/src/xselect.c index f63977a73de..77bda79007c 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -66,22 +66,15 @@ static Lisp_Object wait_for_property_change_unwind (Lisp_Object); | |||
| 66 | static void wait_for_property_change (struct prop_location *); | 66 | static void wait_for_property_change (struct prop_location *); |
| 67 | static Lisp_Object x_get_foreign_selection (Lisp_Object, Lisp_Object, | 67 | static Lisp_Object x_get_foreign_selection (Lisp_Object, Lisp_Object, |
| 68 | Lisp_Object, Lisp_Object); | 68 | Lisp_Object, Lisp_Object); |
| 69 | static void x_get_window_property (Display *, Window, Atom, | ||
| 70 | unsigned char **, int *, | ||
| 71 | Atom *, int *, unsigned long *, int); | ||
| 72 | static void receive_incremental_selection (Display *, Window, Atom, | ||
| 73 | Lisp_Object, unsigned, | ||
| 74 | unsigned char **, int *, | ||
| 75 | Atom *, int *, unsigned long *); | ||
| 76 | static Lisp_Object x_get_window_property_as_lisp_data (Display *, | 69 | static Lisp_Object x_get_window_property_as_lisp_data (Display *, |
| 77 | Window, Atom, | 70 | Window, Atom, |
| 78 | Lisp_Object, Atom); | 71 | Lisp_Object, Atom); |
| 79 | static Lisp_Object selection_data_to_lisp_data (Display *, | 72 | static Lisp_Object selection_data_to_lisp_data (Display *, |
| 80 | const unsigned char *, | 73 | const unsigned char *, |
| 81 | int, Atom, int); | 74 | ptrdiff_t, Atom, int); |
| 82 | static void lisp_data_to_selection_data (Display *, Lisp_Object, | 75 | static void lisp_data_to_selection_data (Display *, Lisp_Object, |
| 83 | unsigned char **, Atom *, | 76 | unsigned char **, Atom *, |
| 84 | unsigned *, int *, int *); | 77 | ptrdiff_t *, int *, int *); |
| 85 | static Lisp_Object clean_local_selection_data (Lisp_Object); | 78 | static Lisp_Object clean_local_selection_data (Lisp_Object); |
| 86 | 79 | ||
| 87 | /* Printing traces to stderr. */ | 80 | /* Printing traces to stderr. */ |
| @@ -114,15 +107,39 @@ static Lisp_Object Qcompound_text_with_extensions; | |||
| 114 | static Lisp_Object Qforeign_selection; | 107 | static Lisp_Object Qforeign_selection; |
| 115 | static Lisp_Object Qx_lost_selection_functions, Qx_sent_selection_functions; | 108 | static Lisp_Object Qx_lost_selection_functions, Qx_sent_selection_functions; |
| 116 | 109 | ||
| 110 | /* Bytes needed to represent 'long' data. This is as per libX11; it | ||
| 111 | is not necessarily sizeof (long). */ | ||
| 112 | #define X_LONG_SIZE 4 | ||
| 113 | |||
| 114 | /* Extreme 'short' and 'long' values suitable for libX11. */ | ||
| 115 | #define X_SHRT_MAX 0x7fff | ||
| 116 | #define X_SHRT_MIN (-1 - X_SHRT_MAX) | ||
| 117 | #define X_LONG_MAX 0x7fffffff | ||
| 118 | #define X_LONG_MIN (-1 - X_LONG_MAX) | ||
| 119 | |||
| 117 | /* If this is a smaller number than the max-request-size of the display, | 120 | /* If this is a smaller number than the max-request-size of the display, |
| 118 | emacs will use INCR selection transfer when the selection is larger | 121 | emacs will use INCR selection transfer when the selection is larger |
| 119 | than this. The max-request-size is usually around 64k, so if you want | 122 | than this. The max-request-size is usually around 64k, so if you want |
| 120 | emacs to use incremental selection transfers when the selection is | 123 | emacs to use incremental selection transfers when the selection is |
| 121 | smaller than that, set this. I added this mostly for debugging the | 124 | smaller than that, set this. I added this mostly for debugging the |
| 122 | incremental transfer stuff, but it might improve server performance. */ | 125 | incremental transfer stuff, but it might improve server performance. |
| 123 | #define MAX_SELECTION_QUANTUM 0xFFFFFF | ||
| 124 | 126 | ||
| 125 | #define SELECTION_QUANTUM(dpy) ((XMaxRequestSize(dpy) << 2) - 100) | 127 | This value cannot exceed INT_MAX / max (X_LONG_SIZE, sizeof (long)) |
| 128 | because it is multiplied by X_LONG_SIZE and by sizeof (long) in | ||
| 129 | subscript calculations. Similarly for PTRDIFF_MAX - 1 or SIZE_MAX | ||
| 130 | - 1 in place of INT_MAX. */ | ||
| 131 | #define MAX_SELECTION_QUANTUM \ | ||
| 132 | ((int) min (0xFFFFFF, (min (INT_MAX, min (PTRDIFF_MAX, SIZE_MAX) - 1) \ | ||
| 133 | / max (X_LONG_SIZE, sizeof (long))))) | ||
| 134 | |||
| 135 | static int | ||
| 136 | selection_quantum (Display *display) | ||
| 137 | { | ||
| 138 | long mrs = XMaxRequestSize (display); | ||
| 139 | return (mrs < MAX_SELECTION_QUANTUM / X_LONG_SIZE + 25 | ||
| 140 | ? (mrs - 25) * X_LONG_SIZE | ||
| 141 | : MAX_SELECTION_QUANTUM); | ||
| 142 | } | ||
| 126 | 143 | ||
| 127 | #define LOCAL_SELECTION(selection_symbol,dpyinfo) \ | 144 | #define LOCAL_SELECTION(selection_symbol,dpyinfo) \ |
| 128 | assq_no_quit (selection_symbol, dpyinfo->terminal->Vselection_alist) | 145 | assq_no_quit (selection_symbol, dpyinfo->terminal->Vselection_alist) |
| @@ -477,7 +494,7 @@ static struct x_display_info *selection_request_dpyinfo; | |||
| 477 | struct selection_data | 494 | struct selection_data |
| 478 | { | 495 | { |
| 479 | unsigned char *data; | 496 | unsigned char *data; |
| 480 | unsigned int size; | 497 | ptrdiff_t size; |
| 481 | int format; | 498 | int format; |
| 482 | Atom type; | 499 | Atom type; |
| 483 | int nofree; | 500 | int nofree; |
| @@ -581,14 +598,11 @@ x_reply_selection_request (struct input_event *event, struct x_display_info *dpy | |||
| 581 | XSelectionEvent *reply = &(reply_base.xselection); | 598 | XSelectionEvent *reply = &(reply_base.xselection); |
| 582 | Display *display = SELECTION_EVENT_DISPLAY (event); | 599 | Display *display = SELECTION_EVENT_DISPLAY (event); |
| 583 | Window window = SELECTION_EVENT_REQUESTOR (event); | 600 | Window window = SELECTION_EVENT_REQUESTOR (event); |
| 584 | int bytes_remaining; | 601 | ptrdiff_t bytes_remaining; |
| 585 | int max_bytes = SELECTION_QUANTUM (display); | 602 | int max_bytes = selection_quantum (display); |
| 586 | int count = SPECPDL_INDEX (); | 603 | int count = SPECPDL_INDEX (); |
| 587 | struct selection_data *cs; | 604 | struct selection_data *cs; |
| 588 | 605 | ||
| 589 | if (max_bytes > MAX_SELECTION_QUANTUM) | ||
| 590 | max_bytes = MAX_SELECTION_QUANTUM; | ||
| 591 | |||
| 592 | reply->type = SelectionNotify; | 606 | reply->type = SelectionNotify; |
| 593 | reply->display = display; | 607 | reply->display = display; |
| 594 | reply->requestor = window; | 608 | reply->requestor = window; |
| @@ -616,11 +630,12 @@ x_reply_selection_request (struct input_event *event, struct x_display_info *dpy | |||
| 616 | if (cs->property == None) | 630 | if (cs->property == None) |
| 617 | continue; | 631 | continue; |
| 618 | 632 | ||
| 619 | bytes_remaining = cs->size * (cs->format / 8); | 633 | bytes_remaining = cs->size; |
| 634 | bytes_remaining *= cs->format >> 3; | ||
| 620 | if (bytes_remaining <= max_bytes) | 635 | if (bytes_remaining <= max_bytes) |
| 621 | { | 636 | { |
| 622 | /* Send all the data at once, with minimal handshaking. */ | 637 | /* Send all the data at once, with minimal handshaking. */ |
| 623 | TRACE1 ("Sending all %d bytes", bytes_remaining); | 638 | TRACE1 ("Sending all %"pD"d bytes", bytes_remaining); |
| 624 | XChangeProperty (display, window, cs->property, | 639 | XChangeProperty (display, window, cs->property, |
| 625 | cs->type, cs->format, PropModeReplace, | 640 | cs->type, cs->format, PropModeReplace, |
| 626 | cs->data, cs->size); | 641 | cs->data, cs->size); |
| @@ -630,7 +645,7 @@ x_reply_selection_request (struct input_event *event, struct x_display_info *dpy | |||
| 630 | /* Send an INCR tag to initiate incremental transfer. */ | 645 | /* Send an INCR tag to initiate incremental transfer. */ |
| 631 | long value[1]; | 646 | long value[1]; |
| 632 | 647 | ||
| 633 | TRACE2 ("Start sending %d bytes incrementally (%s)", | 648 | TRACE2 ("Start sending %"pD"d bytes incrementally (%s)", |
| 634 | bytes_remaining, XGetAtomName (display, cs->property)); | 649 | bytes_remaining, XGetAtomName (display, cs->property)); |
| 635 | cs->wait_object | 650 | cs->wait_object |
| 636 | = expect_property_change (display, window, cs->property, | 651 | = expect_property_change (display, window, cs->property, |
| @@ -638,7 +653,7 @@ x_reply_selection_request (struct input_event *event, struct x_display_info *dpy | |||
| 638 | 653 | ||
| 639 | /* XChangeProperty expects an array of long even if long is | 654 | /* XChangeProperty expects an array of long even if long is |
| 640 | more than 32 bits. */ | 655 | more than 32 bits. */ |
| 641 | value[0] = bytes_remaining; | 656 | value[0] = min (bytes_remaining, X_LONG_MAX); |
| 642 | XChangeProperty (display, window, cs->property, | 657 | XChangeProperty (display, window, cs->property, |
| 643 | dpyinfo->Xatom_INCR, 32, PropModeReplace, | 658 | dpyinfo->Xatom_INCR, 32, PropModeReplace, |
| 644 | (unsigned char *) value, 1); | 659 | (unsigned char *) value, 1); |
| @@ -672,7 +687,8 @@ x_reply_selection_request (struct input_event *event, struct x_display_info *dpy | |||
| 672 | int had_errors = x_had_errors_p (display); | 687 | int had_errors = x_had_errors_p (display); |
| 673 | UNBLOCK_INPUT; | 688 | UNBLOCK_INPUT; |
| 674 | 689 | ||
| 675 | bytes_remaining = cs->size * format_bytes; | 690 | bytes_remaining = cs->size; |
| 691 | bytes_remaining *= format_bytes; | ||
| 676 | 692 | ||
| 677 | /* Wait for the requester to ack by deleting the property. | 693 | /* Wait for the requester to ack by deleting the property. |
| 678 | This can run Lisp code (process handlers) or signal. */ | 694 | This can run Lisp code (process handlers) or signal. */ |
| @@ -810,7 +826,7 @@ x_handle_selection_request (struct input_event *event) | |||
| 810 | non-None property. */ | 826 | non-None property. */ |
| 811 | Window requestor = SELECTION_EVENT_REQUESTOR (event); | 827 | Window requestor = SELECTION_EVENT_REQUESTOR (event); |
| 812 | Lisp_Object multprop; | 828 | Lisp_Object multprop; |
| 813 | int j, nselections; | 829 | ptrdiff_t j, nselections; |
| 814 | 830 | ||
| 815 | if (property == None) goto DONE; | 831 | if (property == None) goto DONE; |
| 816 | multprop | 832 | multprop |
| @@ -1269,19 +1285,28 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | |||
| 1269 | 1285 | ||
| 1270 | static void | 1286 | static void |
| 1271 | x_get_window_property (Display *display, Window window, Atom property, | 1287 | x_get_window_property (Display *display, Window window, Atom property, |
| 1272 | unsigned char **data_ret, int *bytes_ret, | 1288 | unsigned char **data_ret, ptrdiff_t *bytes_ret, |
| 1273 | Atom *actual_type_ret, int *actual_format_ret, | 1289 | Atom *actual_type_ret, int *actual_format_ret, |
| 1274 | unsigned long *actual_size_ret, int delete_p) | 1290 | unsigned long *actual_size_ret, int delete_p) |
| 1275 | { | 1291 | { |
| 1276 | int total_size; | 1292 | ptrdiff_t total_size; |
| 1277 | unsigned long bytes_remaining; | 1293 | unsigned long bytes_remaining; |
| 1278 | int offset = 0; | 1294 | ptrdiff_t offset = 0; |
| 1295 | unsigned char *data = 0; | ||
| 1279 | unsigned char *tmp_data = 0; | 1296 | unsigned char *tmp_data = 0; |
| 1280 | int result; | 1297 | int result; |
| 1281 | int buffer_size = SELECTION_QUANTUM (display); | 1298 | int buffer_size = selection_quantum (display); |
| 1299 | |||
| 1300 | /* Wide enough to avoid overflow in expressions using it. */ | ||
| 1301 | ptrdiff_t x_long_size = X_LONG_SIZE; | ||
| 1282 | 1302 | ||
| 1283 | if (buffer_size > MAX_SELECTION_QUANTUM) | 1303 | /* Maximum value for TOTAL_SIZE. It cannot exceed PTRDIFF_MAX - 1 |
| 1284 | buffer_size = MAX_SELECTION_QUANTUM; | 1304 | and SIZE_MAX - 1, for an extra byte at the end. And it cannot |
| 1305 | exceed LONG_MAX * X_LONG_SIZE, for XGetWindowProperty. */ | ||
| 1306 | ptrdiff_t total_size_max = | ||
| 1307 | ((min (PTRDIFF_MAX, SIZE_MAX) - 1) / x_long_size < LONG_MAX | ||
| 1308 | ? min (PTRDIFF_MAX, SIZE_MAX) - 1 | ||
| 1309 | : LONG_MAX * x_long_size); | ||
| 1285 | 1310 | ||
| 1286 | BLOCK_INPUT; | 1311 | BLOCK_INPUT; |
| 1287 | 1312 | ||
| @@ -1292,49 +1317,44 @@ x_get_window_property (Display *display, Window window, Atom property, | |||
| 1292 | actual_size_ret, | 1317 | actual_size_ret, |
| 1293 | &bytes_remaining, &tmp_data); | 1318 | &bytes_remaining, &tmp_data); |
| 1294 | if (result != Success) | 1319 | if (result != Success) |
| 1295 | { | 1320 | goto done; |
| 1296 | UNBLOCK_INPUT; | ||
| 1297 | *data_ret = 0; | ||
| 1298 | *bytes_ret = 0; | ||
| 1299 | return; | ||
| 1300 | } | ||
| 1301 | 1321 | ||
| 1302 | /* This was allocated by Xlib, so use XFree. */ | 1322 | /* This was allocated by Xlib, so use XFree. */ |
| 1303 | XFree ((char *) tmp_data); | 1323 | XFree ((char *) tmp_data); |
| 1304 | 1324 | ||
| 1305 | if (*actual_type_ret == None || *actual_format_ret == 0) | 1325 | if (*actual_type_ret == None || *actual_format_ret == 0) |
| 1306 | { | 1326 | goto done; |
| 1307 | UNBLOCK_INPUT; | ||
| 1308 | return; | ||
| 1309 | } | ||
| 1310 | 1327 | ||
| 1311 | total_size = bytes_remaining + 1; | 1328 | if (total_size_max < bytes_remaining) |
| 1312 | *data_ret = (unsigned char *) xmalloc (total_size); | 1329 | goto size_overflow; |
| 1330 | total_size = bytes_remaining; | ||
| 1331 | data = malloc (total_size + 1); | ||
| 1332 | if (! data) | ||
| 1333 | goto memory_exhausted; | ||
| 1313 | 1334 | ||
| 1314 | /* Now read, until we've gotten it all. */ | 1335 | /* Now read, until we've gotten it all. */ |
| 1315 | while (bytes_remaining) | 1336 | while (bytes_remaining) |
| 1316 | { | 1337 | { |
| 1317 | #ifdef TRACE_SELECTION | 1338 | ptrdiff_t bytes_gotten; |
| 1318 | unsigned long last = bytes_remaining; | 1339 | int bytes_per_item; |
| 1319 | #endif | ||
| 1320 | result | 1340 | result |
| 1321 | = XGetWindowProperty (display, window, property, | 1341 | = XGetWindowProperty (display, window, property, |
| 1322 | (long)offset/4, (long)buffer_size/4, | 1342 | offset / X_LONG_SIZE, |
| 1343 | buffer_size / X_LONG_SIZE, | ||
| 1323 | False, | 1344 | False, |
| 1324 | AnyPropertyType, | 1345 | AnyPropertyType, |
| 1325 | actual_type_ret, actual_format_ret, | 1346 | actual_type_ret, actual_format_ret, |
| 1326 | actual_size_ret, &bytes_remaining, &tmp_data); | 1347 | actual_size_ret, &bytes_remaining, &tmp_data); |
| 1327 | 1348 | ||
| 1328 | TRACE2 ("Read %lu bytes from property %s", | ||
| 1329 | last - bytes_remaining, | ||
| 1330 | XGetAtomName (display, property)); | ||
| 1331 | |||
| 1332 | /* If this doesn't return Success at this point, it means that | 1349 | /* If this doesn't return Success at this point, it means that |
| 1333 | some clod deleted the selection while we were in the midst of | 1350 | some clod deleted the selection while we were in the midst of |
| 1334 | reading it. Deal with that, I guess.... */ | 1351 | reading it. Deal with that, I guess.... */ |
| 1335 | if (result != Success) | 1352 | if (result != Success) |
| 1336 | break; | 1353 | break; |
| 1337 | 1354 | ||
| 1355 | bytes_per_item = *actual_format_ret >> 3; | ||
| 1356 | xassert (*actual_size_ret <= buffer_size / bytes_per_item); | ||
| 1357 | |||
| 1338 | /* The man page for XGetWindowProperty says: | 1358 | /* The man page for XGetWindowProperty says: |
| 1339 | "If the returned format is 32, the returned data is represented | 1359 | "If the returned format is 32, the returned data is represented |
| 1340 | as a long array and should be cast to that type to obtain the | 1360 | as a long array and should be cast to that type to obtain the |
| @@ -1348,32 +1368,61 @@ x_get_window_property (Display *display, Window window, Atom property, | |||
| 1348 | The bytes and offsets passed to XGetWindowProperty refers to the | 1368 | The bytes and offsets passed to XGetWindowProperty refers to the |
| 1349 | property and those are indeed in 32 bit quantities if format is 32. */ | 1369 | property and those are indeed in 32 bit quantities if format is 32. */ |
| 1350 | 1370 | ||
| 1371 | bytes_gotten = *actual_size_ret; | ||
| 1372 | bytes_gotten *= bytes_per_item; | ||
| 1373 | |||
| 1374 | TRACE2 ("Read %"pD"d bytes from property %s", | ||
| 1375 | bytes_gotten, XGetAtomName (display, property)); | ||
| 1376 | |||
| 1377 | if (total_size - offset < bytes_gotten) | ||
| 1378 | { | ||
| 1379 | unsigned char *data1; | ||
| 1380 | ptrdiff_t remaining_lim = total_size_max - offset - bytes_gotten; | ||
| 1381 | if (remaining_lim < 0 || remaining_lim < bytes_remaining) | ||
| 1382 | goto size_overflow; | ||
| 1383 | total_size = offset + bytes_gotten + bytes_remaining; | ||
| 1384 | data1 = realloc (data, total_size + 1); | ||
| 1385 | if (! data1) | ||
| 1386 | goto memory_exhausted; | ||
| 1387 | data = data1; | ||
| 1388 | } | ||
| 1389 | |||
| 1351 | if (32 < BITS_PER_LONG && *actual_format_ret == 32) | 1390 | if (32 < BITS_PER_LONG && *actual_format_ret == 32) |
| 1352 | { | 1391 | { |
| 1353 | unsigned long i; | 1392 | unsigned long i; |
| 1354 | int *idata = (int *) ((*data_ret) + offset); | 1393 | int *idata = (int *) (data + offset); |
| 1355 | long *ldata = (long *) tmp_data; | 1394 | long *ldata = (long *) tmp_data; |
| 1356 | 1395 | ||
| 1357 | for (i = 0; i < *actual_size_ret; ++i) | 1396 | for (i = 0; i < *actual_size_ret; ++i) |
| 1358 | { | 1397 | idata[i] = ldata[i]; |
| 1359 | idata[i]= (int) ldata[i]; | ||
| 1360 | offset += 4; | ||
| 1361 | } | ||
| 1362 | } | 1398 | } |
| 1363 | else | 1399 | else |
| 1364 | { | 1400 | memcpy (data + offset, tmp_data, bytes_gotten); |
| 1365 | *actual_size_ret *= *actual_format_ret / 8; | 1401 | |
| 1366 | memcpy ((*data_ret) + offset, tmp_data, *actual_size_ret); | 1402 | offset += bytes_gotten; |
| 1367 | offset += *actual_size_ret; | ||
| 1368 | } | ||
| 1369 | 1403 | ||
| 1370 | /* This was allocated by Xlib, so use XFree. */ | 1404 | /* This was allocated by Xlib, so use XFree. */ |
| 1371 | XFree ((char *) tmp_data); | 1405 | XFree ((char *) tmp_data); |
| 1372 | } | 1406 | } |
| 1373 | 1407 | ||
| 1374 | XFlush (display); | 1408 | XFlush (display); |
| 1409 | data[offset] = '\0'; | ||
| 1410 | |||
| 1411 | done: | ||
| 1375 | UNBLOCK_INPUT; | 1412 | UNBLOCK_INPUT; |
| 1413 | *data_ret = data; | ||
| 1376 | *bytes_ret = offset; | 1414 | *bytes_ret = offset; |
| 1415 | return; | ||
| 1416 | |||
| 1417 | size_overflow: | ||
| 1418 | free (data); | ||
| 1419 | UNBLOCK_INPUT; | ||
| 1420 | memory_full (SIZE_MAX); | ||
| 1421 | |||
| 1422 | memory_exhausted: | ||
| 1423 | free (data); | ||
| 1424 | UNBLOCK_INPUT; | ||
| 1425 | memory_full (total_size + 1); | ||
| 1377 | } | 1426 | } |
| 1378 | 1427 | ||
| 1379 | /* Use xfree, not XFree, to free the data obtained with this function. */ | 1428 | /* Use xfree, not XFree, to free the data obtained with this function. */ |
| @@ -1382,16 +1431,19 @@ static void | |||
| 1382 | receive_incremental_selection (Display *display, Window window, Atom property, | 1431 | receive_incremental_selection (Display *display, Window window, Atom property, |
| 1383 | Lisp_Object target_type, | 1432 | Lisp_Object target_type, |
| 1384 | unsigned int min_size_bytes, | 1433 | unsigned int min_size_bytes, |
| 1385 | unsigned char **data_ret, int *size_bytes_ret, | 1434 | unsigned char **data_ret, |
| 1435 | ptrdiff_t *size_bytes_ret, | ||
| 1386 | Atom *type_ret, int *format_ret, | 1436 | Atom *type_ret, int *format_ret, |
| 1387 | unsigned long *size_ret) | 1437 | unsigned long *size_ret) |
| 1388 | { | 1438 | { |
| 1389 | int offset = 0; | 1439 | ptrdiff_t offset = 0; |
| 1390 | struct prop_location *wait_object; | 1440 | struct prop_location *wait_object; |
| 1441 | if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes) | ||
| 1442 | memory_full (SIZE_MAX); | ||
| 1443 | *data_ret = (unsigned char *) xmalloc (min_size_bytes); | ||
| 1391 | *size_bytes_ret = min_size_bytes; | 1444 | *size_bytes_ret = min_size_bytes; |
| 1392 | *data_ret = (unsigned char *) xmalloc (*size_bytes_ret); | ||
| 1393 | 1445 | ||
| 1394 | TRACE1 ("Read %d bytes incrementally", min_size_bytes); | 1446 | TRACE1 ("Read %u bytes incrementally", min_size_bytes); |
| 1395 | 1447 | ||
| 1396 | /* At this point, we have read an INCR property. | 1448 | /* At this point, we have read an INCR property. |
| 1397 | Delete the property to ack it. | 1449 | Delete the property to ack it. |
| @@ -1416,7 +1468,7 @@ receive_incremental_selection (Display *display, Window window, Atom property, | |||
| 1416 | while (1) | 1468 | while (1) |
| 1417 | { | 1469 | { |
| 1418 | unsigned char *tmp_data; | 1470 | unsigned char *tmp_data; |
| 1419 | int tmp_size_bytes; | 1471 | ptrdiff_t tmp_size_bytes; |
| 1420 | 1472 | ||
| 1421 | TRACE0 (" Wait for property change"); | 1473 | TRACE0 (" Wait for property change"); |
| 1422 | wait_for_property_change (wait_object); | 1474 | wait_for_property_change (wait_object); |
| @@ -1429,7 +1481,7 @@ receive_incremental_selection (Display *display, Window window, Atom property, | |||
| 1429 | &tmp_data, &tmp_size_bytes, | 1481 | &tmp_data, &tmp_size_bytes, |
| 1430 | type_ret, format_ret, size_ret, 1); | 1482 | type_ret, format_ret, size_ret, 1); |
| 1431 | 1483 | ||
| 1432 | TRACE1 (" Read increment of %d bytes", tmp_size_bytes); | 1484 | TRACE1 (" Read increment of %"pD"d bytes", tmp_size_bytes); |
| 1433 | 1485 | ||
| 1434 | if (tmp_size_bytes == 0) /* we're done */ | 1486 | if (tmp_size_bytes == 0) /* we're done */ |
| 1435 | { | 1487 | { |
| @@ -1452,11 +1504,10 @@ receive_incremental_selection (Display *display, Window window, Atom property, | |||
| 1452 | XFlush (display); | 1504 | XFlush (display); |
| 1453 | UNBLOCK_INPUT; | 1505 | UNBLOCK_INPUT; |
| 1454 | 1506 | ||
| 1455 | if (*size_bytes_ret < offset + tmp_size_bytes) | 1507 | if (*size_bytes_ret - offset < tmp_size_bytes) |
| 1456 | { | 1508 | *data_ret = xpalloc (*data_ret, size_bytes_ret, |
| 1457 | *size_bytes_ret = offset + tmp_size_bytes; | 1509 | tmp_size_bytes - (*size_bytes_ret - offset), |
| 1458 | *data_ret = (unsigned char *) xrealloc (*data_ret, *size_bytes_ret); | 1510 | -1, 1); |
| 1459 | } | ||
| 1460 | 1511 | ||
| 1461 | memcpy ((*data_ret) + offset, tmp_data, tmp_size_bytes); | 1512 | memcpy ((*data_ret) + offset, tmp_data, tmp_size_bytes); |
| 1462 | offset += tmp_size_bytes; | 1513 | offset += tmp_size_bytes; |
| @@ -1482,7 +1533,7 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1482 | int actual_format; | 1533 | int actual_format; |
| 1483 | unsigned long actual_size; | 1534 | unsigned long actual_size; |
| 1484 | unsigned char *data = 0; | 1535 | unsigned char *data = 0; |
| 1485 | int bytes = 0; | 1536 | ptrdiff_t bytes = 0; |
| 1486 | Lisp_Object val; | 1537 | Lisp_Object val; |
| 1487 | struct x_display_info *dpyinfo = x_display_info_for_display (display); | 1538 | struct x_display_info *dpyinfo = x_display_info_for_display (display); |
| 1488 | 1539 | ||
| @@ -1574,7 +1625,7 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1574 | 1625 | ||
| 1575 | static Lisp_Object | 1626 | static Lisp_Object |
| 1576 | selection_data_to_lisp_data (Display *display, const unsigned char *data, | 1627 | selection_data_to_lisp_data (Display *display, const unsigned char *data, |
| 1577 | int size, Atom type, int format) | 1628 | ptrdiff_t size, Atom type, int format) |
| 1578 | { | 1629 | { |
| 1579 | struct x_display_info *dpyinfo = x_display_info_for_display (display); | 1630 | struct x_display_info *dpyinfo = x_display_info_for_display (display); |
| 1580 | 1631 | ||
| @@ -1607,7 +1658,7 @@ selection_data_to_lisp_data (Display *display, const unsigned char *data, | |||
| 1607 | /* Treat ATOM_PAIR type similar to list of atoms. */ | 1658 | /* Treat ATOM_PAIR type similar to list of atoms. */ |
| 1608 | || type == dpyinfo->Xatom_ATOM_PAIR) | 1659 | || type == dpyinfo->Xatom_ATOM_PAIR) |
| 1609 | { | 1660 | { |
| 1610 | int i; | 1661 | ptrdiff_t i; |
| 1611 | /* On a 64 bit machine sizeof(Atom) == sizeof(long) == 8. | 1662 | /* On a 64 bit machine sizeof(Atom) == sizeof(long) == 8. |
| 1612 | But the callers of these function has made sure the data for | 1663 | But the callers of these function has made sure the data for |
| 1613 | format == 32 is an array of int. Thus, use int instead | 1664 | format == 32 is an array of int. Thus, use int instead |
| @@ -1634,28 +1685,29 @@ selection_data_to_lisp_data (Display *display, const unsigned char *data, | |||
| 1634 | else if (format == 32 && size == sizeof (int)) | 1685 | else if (format == 32 && size == sizeof (int)) |
| 1635 | return INTEGER_TO_CONS (((unsigned int *) data) [0]); | 1686 | return INTEGER_TO_CONS (((unsigned int *) data) [0]); |
| 1636 | else if (format == 16 && size == sizeof (short)) | 1687 | else if (format == 16 && size == sizeof (short)) |
| 1637 | return make_number ((int) (((unsigned short *) data) [0])); | 1688 | return make_number (((unsigned short *) data) [0]); |
| 1638 | 1689 | ||
| 1639 | /* Convert any other kind of data to a vector of numbers, represented | 1690 | /* Convert any other kind of data to a vector of numbers, represented |
| 1640 | as above (as an integer, or a cons of two 16 bit integers.) | 1691 | as above (as an integer, or a cons of two 16 bit integers.) |
| 1641 | */ | 1692 | */ |
| 1642 | else if (format == 16) | 1693 | else if (format == 16) |
| 1643 | { | 1694 | { |
| 1644 | int i; | 1695 | ptrdiff_t i; |
| 1645 | Lisp_Object v; | 1696 | Lisp_Object v; |
| 1646 | v = Fmake_vector (make_number (size / 2), make_number (0)); | 1697 | v = Fmake_vector (make_number (size / 2), make_number (0)); |
| 1647 | for (i = 0; i < size / 2; i++) | 1698 | for (i = 0; i < size / 2; i++) |
| 1648 | { | 1699 | { |
| 1649 | int j = (int) ((unsigned short *) data) [i]; | 1700 | EMACS_INT j = ((unsigned short *) data) [i]; |
| 1650 | Faset (v, make_number (i), make_number (j)); | 1701 | Faset (v, make_number (i), make_number (j)); |
| 1651 | } | 1702 | } |
| 1652 | return v; | 1703 | return v; |
| 1653 | } | 1704 | } |
| 1654 | else | 1705 | else |
| 1655 | { | 1706 | { |
| 1656 | int i; | 1707 | ptrdiff_t i; |
| 1657 | Lisp_Object v = Fmake_vector (make_number (size / 4), make_number (0)); | 1708 | Lisp_Object v = Fmake_vector (make_number (size / X_LONG_SIZE), |
| 1658 | for (i = 0; i < size / 4; i++) | 1709 | make_number (0)); |
| 1710 | for (i = 0; i < size / X_LONG_SIZE; i++) | ||
| 1659 | { | 1711 | { |
| 1660 | unsigned int j = ((unsigned int *) data) [i]; | 1712 | unsigned int j = ((unsigned int *) data) [i]; |
| 1661 | Faset (v, make_number (i), INTEGER_TO_CONS (j)); | 1713 | Faset (v, make_number (i), INTEGER_TO_CONS (j)); |
| @@ -1670,7 +1722,7 @@ selection_data_to_lisp_data (Display *display, const unsigned char *data, | |||
| 1670 | static void | 1722 | static void |
| 1671 | lisp_data_to_selection_data (Display *display, Lisp_Object obj, | 1723 | lisp_data_to_selection_data (Display *display, Lisp_Object obj, |
| 1672 | unsigned char **data_ret, Atom *type_ret, | 1724 | unsigned char **data_ret, Atom *type_ret, |
| 1673 | unsigned int *size_ret, | 1725 | ptrdiff_t *size_ret, |
| 1674 | int *format_ret, int *nofree_ret) | 1726 | int *format_ret, int *nofree_ret) |
| 1675 | { | 1727 | { |
| 1676 | Lisp_Object type = Qnil; | 1728 | Lisp_Object type = Qnil; |
| @@ -1707,22 +1759,20 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1707 | } | 1759 | } |
| 1708 | else if (SYMBOLP (obj)) | 1760 | else if (SYMBOLP (obj)) |
| 1709 | { | 1761 | { |
| 1762 | *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1); | ||
| 1710 | *format_ret = 32; | 1763 | *format_ret = 32; |
| 1711 | *size_ret = 1; | 1764 | *size_ret = 1; |
| 1712 | *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1); | ||
| 1713 | (*data_ret) [sizeof (Atom)] = 0; | 1765 | (*data_ret) [sizeof (Atom)] = 0; |
| 1714 | (*(Atom **) data_ret) [0] = symbol_to_x_atom (dpyinfo, obj); | 1766 | (*(Atom **) data_ret) [0] = symbol_to_x_atom (dpyinfo, obj); |
| 1715 | if (NILP (type)) type = QATOM; | 1767 | if (NILP (type)) type = QATOM; |
| 1716 | } | 1768 | } |
| 1717 | else if (INTEGERP (obj) | 1769 | else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX)) |
| 1718 | && XINT (obj) < 0xFFFF | ||
| 1719 | && XINT (obj) > -0xFFFF) | ||
| 1720 | { | 1770 | { |
| 1771 | *data_ret = (unsigned char *) xmalloc (sizeof (short) + 1); | ||
| 1721 | *format_ret = 16; | 1772 | *format_ret = 16; |
| 1722 | *size_ret = 1; | 1773 | *size_ret = 1; |
| 1723 | *data_ret = (unsigned char *) xmalloc (sizeof (short) + 1); | ||
| 1724 | (*data_ret) [sizeof (short)] = 0; | 1774 | (*data_ret) [sizeof (short)] = 0; |
| 1725 | (*(short **) data_ret) [0] = (short) XINT (obj); | 1775 | (*(short **) data_ret) [0] = XINT (obj); |
| 1726 | if (NILP (type)) type = QINTEGER; | 1776 | if (NILP (type)) type = QINTEGER; |
| 1727 | } | 1777 | } |
| 1728 | else if (INTEGERP (obj) | 1778 | else if (INTEGERP (obj) |
| @@ -1731,11 +1781,11 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1731 | || (CONSP (XCDR (obj)) | 1781 | || (CONSP (XCDR (obj)) |
| 1732 | && INTEGERP (XCAR (XCDR (obj))))))) | 1782 | && INTEGERP (XCAR (XCDR (obj))))))) |
| 1733 | { | 1783 | { |
| 1784 | *data_ret = (unsigned char *) xmalloc (sizeof (long) + 1); | ||
| 1734 | *format_ret = 32; | 1785 | *format_ret = 32; |
| 1735 | *size_ret = 1; | 1786 | *size_ret = 1; |
| 1736 | *data_ret = (unsigned char *) xmalloc (sizeof (long) + 1); | ||
| 1737 | (*data_ret) [sizeof (long)] = 0; | 1787 | (*data_ret) [sizeof (long)] = 0; |
| 1738 | (*(unsigned long **) data_ret) [0] = cons_to_unsigned (obj, ULONG_MAX); | 1788 | (*(long **) data_ret) [0] = cons_to_signed (obj, X_LONG_MIN, X_LONG_MAX); |
| 1739 | if (NILP (type)) type = QINTEGER; | 1789 | if (NILP (type)) type = QINTEGER; |
| 1740 | } | 1790 | } |
| 1741 | else if (VECTORP (obj)) | 1791 | else if (VECTORP (obj)) |
| @@ -1744,50 +1794,55 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1744 | a set of 16 or 32 bit INTEGERs; | 1794 | a set of 16 or 32 bit INTEGERs; |
| 1745 | or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...] | 1795 | or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...] |
| 1746 | */ | 1796 | */ |
| 1747 | int i; | 1797 | ptrdiff_t i; |
| 1798 | ptrdiff_t size = ASIZE (obj); | ||
| 1748 | 1799 | ||
| 1749 | if (SYMBOLP (XVECTOR (obj)->contents [0])) | 1800 | if (SYMBOLP (XVECTOR (obj)->contents [0])) |
| 1750 | /* This vector is an ATOM set */ | 1801 | /* This vector is an ATOM set */ |
| 1751 | { | 1802 | { |
| 1752 | if (NILP (type)) type = QATOM; | 1803 | if (NILP (type)) type = QATOM; |
| 1753 | *size_ret = ASIZE (obj); | 1804 | for (i = 0; i < size; i++) |
| 1754 | *format_ret = 32; | ||
| 1755 | for (i = 0; i < *size_ret; i++) | ||
| 1756 | if (!SYMBOLP (XVECTOR (obj)->contents [i])) | 1805 | if (!SYMBOLP (XVECTOR (obj)->contents [i])) |
| 1757 | signal_error ("All elements of selection vector must have same type", obj); | 1806 | signal_error ("All elements of selection vector must have same type", obj); |
| 1758 | 1807 | ||
| 1759 | *data_ret = (unsigned char *) xmalloc ((*size_ret) * sizeof (Atom)); | 1808 | *data_ret = xnmalloc (size, sizeof (Atom)); |
| 1760 | for (i = 0; i < *size_ret; i++) | 1809 | *format_ret = 32; |
| 1810 | *size_ret = size; | ||
| 1811 | for (i = 0; i < size; i++) | ||
| 1761 | (*(Atom **) data_ret) [i] | 1812 | (*(Atom **) data_ret) [i] |
| 1762 | = symbol_to_x_atom (dpyinfo, XVECTOR (obj)->contents [i]); | 1813 | = symbol_to_x_atom (dpyinfo, XVECTOR (obj)->contents [i]); |
| 1763 | } | 1814 | } |
| 1764 | else | 1815 | else |
| 1765 | /* This vector is an INTEGER set, or something like it */ | 1816 | /* This vector is an INTEGER set, or something like it */ |
| 1766 | { | 1817 | { |
| 1767 | int data_size = 2; | 1818 | int format = 16; |
| 1768 | *size_ret = ASIZE (obj); | 1819 | int data_size = sizeof (short); |
| 1769 | if (NILP (type)) type = QINTEGER; | 1820 | if (NILP (type)) type = QINTEGER; |
| 1770 | *format_ret = 16; | 1821 | for (i = 0; i < size; i++) |
| 1771 | for (i = 0; i < *size_ret; i++) | 1822 | { |
| 1772 | if (CONSP (XVECTOR (obj)->contents [i])) | 1823 | intmax_t v = cons_to_signed (XVECTOR (obj)->contents[i], |
| 1773 | *format_ret = 32; | 1824 | X_LONG_MIN, X_LONG_MAX); |
| 1774 | else if (!INTEGERP (XVECTOR (obj)->contents [i])) | 1825 | if (X_SHRT_MIN <= v && v <= X_SHRT_MAX) |
| 1775 | signal_error (/* Qselection_error */ | 1826 | { |
| 1776 | "Elements of selection vector must be integers or conses of integers", | 1827 | /* Use sizeof (long) even if it is more than 32 bits. |
| 1777 | obj); | 1828 | See comment in x_get_window_property and |
| 1778 | 1829 | x_fill_property_data. */ | |
| 1779 | /* Use sizeof(long) even if it is more than 32 bits. See comment | 1830 | data_size = sizeof (long); |
| 1780 | in x_get_window_property and x_fill_property_data. */ | 1831 | format = 32; |
| 1781 | 1832 | } | |
| 1782 | if (*format_ret == 32) data_size = sizeof(long); | 1833 | } |
| 1783 | *data_ret = (unsigned char *) xmalloc (*size_ret * data_size); | 1834 | *data_ret = xnmalloc (size, data_size); |
| 1784 | for (i = 0; i < *size_ret; i++) | 1835 | *format_ret = format; |
| 1785 | if (*format_ret == 32) | 1836 | *size_ret = size; |
| 1786 | (*((unsigned long **) data_ret)) [i] = | 1837 | for (i = 0; i < size; i++) |
| 1787 | cons_to_unsigned (XVECTOR (obj)->contents [i], ULONG_MAX); | 1838 | { |
| 1788 | else | 1839 | long v = cons_to_signed (XVECTOR (obj)->contents[i], |
| 1789 | (*((unsigned short **) data_ret)) [i] = | 1840 | X_LONG_MIN, X_LONG_MAX); |
| 1790 | cons_to_unsigned (XVECTOR (obj)->contents [i], USHRT_MAX); | 1841 | if (format == 32) |
| 1842 | (*((long **) data_ret)) [i] = v; | ||
| 1843 | else | ||
| 1844 | (*((short **) data_ret)) [i] = v; | ||
| 1845 | } | ||
| 1791 | } | 1846 | } |
| 1792 | } | 1847 | } |
| 1793 | else | 1848 | else |
| @@ -1817,8 +1872,8 @@ clean_local_selection_data (Lisp_Object obj) | |||
| 1817 | } | 1872 | } |
| 1818 | if (VECTORP (obj)) | 1873 | if (VECTORP (obj)) |
| 1819 | { | 1874 | { |
| 1820 | int i; | 1875 | ptrdiff_t i; |
| 1821 | int size = ASIZE (obj); | 1876 | ptrdiff_t size = ASIZE (obj); |
| 1822 | Lisp_Object copy; | 1877 | Lisp_Object copy; |
| 1823 | if (size == 1) | 1878 | if (size == 1) |
| 1824 | return clean_local_selection_data (XVECTOR (obj)->contents [0]); | 1879 | return clean_local_selection_data (XVECTOR (obj)->contents [0]); |
| @@ -2213,6 +2268,8 @@ x_check_property_data (Lisp_Object data) | |||
| 2213 | else if (CONSP (o) && | 2268 | else if (CONSP (o) && |
| 2214 | (! NUMBERP (XCAR (o)) || ! NUMBERP (XCDR (o)))) | 2269 | (! NUMBERP (XCAR (o)) || ! NUMBERP (XCDR (o)))) |
| 2215 | return -1; | 2270 | return -1; |
| 2271 | if (size == INT_MAX) | ||
| 2272 | return -1; | ||
| 2216 | size++; | 2273 | size++; |
| 2217 | } | 2274 | } |
| 2218 | 2275 | ||
| @@ -2294,8 +2351,11 @@ Lisp_Object | |||
| 2294 | x_property_data_to_lisp (struct frame *f, const unsigned char *data, | 2351 | x_property_data_to_lisp (struct frame *f, const unsigned char *data, |
| 2295 | Atom type, int format, long unsigned int size) | 2352 | Atom type, int format, long unsigned int size) |
| 2296 | { | 2353 | { |
| 2354 | ptrdiff_t format_bytes = format >> 3; | ||
| 2355 | if (PTRDIFF_MAX / format_bytes < size) | ||
| 2356 | memory_full (SIZE_MAX); | ||
| 2297 | return selection_data_to_lisp_data (FRAME_X_DISPLAY (f), | 2357 | return selection_data_to_lisp_data (FRAME_X_DISPLAY (f), |
| 2298 | data, size*format/8, type, format); | 2358 | data, size * format_bytes, type, format); |
| 2299 | } | 2359 | } |
| 2300 | 2360 | ||
| 2301 | /* Get the mouse position in frame relative coordinates. */ | 2361 | /* Get the mouse position in frame relative coordinates. */ |
| @@ -2401,15 +2461,9 @@ FRAME is on. If FRAME is nil, the selected frame is used. */) | |||
| 2401 | return Qnil; | 2461 | return Qnil; |
| 2402 | 2462 | ||
| 2403 | if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size) | 2463 | if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size) |
| 2404 | { | 2464 | dpyinfo->x_dnd_atoms = |
| 2405 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *dpyinfo->x_dnd_atoms / 2 | 2465 | xpalloc (dpyinfo->x_dnd_atoms, &dpyinfo->x_dnd_atoms_size, |
| 2406 | < dpyinfo->x_dnd_atoms_size) | 2466 | 1, -1, sizeof *dpyinfo->x_dnd_atoms); |
| 2407 | memory_full (SIZE_MAX); | ||
| 2408 | dpyinfo->x_dnd_atoms_size *= 2; | ||
| 2409 | dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms, | ||
| 2410 | sizeof (*dpyinfo->x_dnd_atoms) | ||
| 2411 | * dpyinfo->x_dnd_atoms_size); | ||
| 2412 | } | ||
| 2413 | 2467 | ||
| 2414 | dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom; | 2468 | dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom; |
| 2415 | return Qnil; | 2469 | return Qnil; |
| @@ -2444,7 +2498,7 @@ x_handle_dnd_message (struct frame *f, XClientMessageEvent *event, struct x_disp | |||
| 2444 | if (32 < BITS_PER_LONG && event->format == 32) | 2498 | if (32 < BITS_PER_LONG && event->format == 32) |
| 2445 | { | 2499 | { |
| 2446 | for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ | 2500 | for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ |
| 2447 | idata[i] = (int) event->data.l[i]; | 2501 | idata[i] = event->data.l[i]; |
| 2448 | data = (unsigned char *) idata; | 2502 | data = (unsigned char *) idata; |
| 2449 | } | 2503 | } |
| 2450 | 2504 | ||
diff --git a/src/xsmfns.c b/src/xsmfns.c index cb56ae648d1..55daec73307 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -223,9 +223,11 @@ smc_save_yourself_CB (SmcConn smcConn, | |||
| 223 | props[props_idx]->name = xstrdup (SmRestartCommand); | 223 | props[props_idx]->name = xstrdup (SmRestartCommand); |
| 224 | props[props_idx]->type = xstrdup (SmLISTofARRAY8); | 224 | props[props_idx]->type = xstrdup (SmLISTofARRAY8); |
| 225 | /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */ | 225 | /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */ |
| 226 | if (INT_MAX - 3 < initial_argc) | ||
| 227 | memory_full (SIZE_MAX); | ||
| 226 | i = 3 + initial_argc; | 228 | i = 3 + initial_argc; |
| 227 | props[props_idx]->num_vals = i; | 229 | props[props_idx]->num_vals = i; |
| 228 | vp = (SmPropValue *) xmalloc (i * sizeof(*vp)); | 230 | vp = xnmalloc (i, sizeof *vp); |
| 229 | props[props_idx]->vals = vp; | 231 | props[props_idx]->vals = vp; |
| 230 | props[props_idx]->vals[vp_idx].length = strlen (emacs_program); | 232 | props[props_idx]->vals[vp_idx].length = strlen (emacs_program); |
| 231 | props[props_idx]->vals[vp_idx++].value = emacs_program; | 233 | props[props_idx]->vals[vp_idx++].value = emacs_program; |
diff --git a/src/xterm.c b/src/xterm.c index 20516ee9d6f..c07caec6c78 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -442,6 +442,27 @@ x_display_info_for_display (Display *dpy) | |||
| 442 | return 0; | 442 | return 0; |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | static Window | ||
| 446 | x_find_topmost_parent (struct frame *f) | ||
| 447 | { | ||
| 448 | struct x_output *x = f->output_data.x; | ||
| 449 | Window win = None, wi = x->parent_desc; | ||
| 450 | Display *dpy = FRAME_X_DISPLAY (f); | ||
| 451 | |||
| 452 | while (wi != FRAME_X_DISPLAY_INFO (f)->root_window) | ||
| 453 | { | ||
| 454 | Window root; | ||
| 455 | Window *children; | ||
| 456 | unsigned int nchildren; | ||
| 457 | |||
| 458 | win = wi; | ||
| 459 | XQueryTree (dpy, win, &root, &wi, &children, &nchildren); | ||
| 460 | XFree (children); | ||
| 461 | } | ||
| 462 | |||
| 463 | return win; | ||
| 464 | } | ||
| 465 | |||
| 445 | #define OPAQUE 0xffffffff | 466 | #define OPAQUE 0xffffffff |
| 446 | 467 | ||
| 447 | void | 468 | void |
| @@ -453,6 +474,7 @@ x_set_frame_alpha (struct frame *f) | |||
| 453 | double alpha = 1.0; | 474 | double alpha = 1.0; |
| 454 | double alpha_min = 1.0; | 475 | double alpha_min = 1.0; |
| 455 | unsigned long opac; | 476 | unsigned long opac; |
| 477 | Window parent; | ||
| 456 | 478 | ||
| 457 | if (dpyinfo->x_highlight_frame == f) | 479 | if (dpyinfo->x_highlight_frame == f) |
| 458 | alpha = f->alpha[0]; | 480 | alpha = f->alpha[0]; |
| @@ -473,6 +495,19 @@ x_set_frame_alpha (struct frame *f) | |||
| 473 | 495 | ||
| 474 | opac = alpha * OPAQUE; | 496 | opac = alpha * OPAQUE; |
| 475 | 497 | ||
| 498 | x_catch_errors (dpy); | ||
| 499 | |||
| 500 | /* If there is a parent from the window manager, put the property there | ||
| 501 | also, to work around broken window managers that fail to do that. | ||
| 502 | Do this unconditionally as this function is called on reparent when | ||
| 503 | alpha has not changed on the frame. */ | ||
| 504 | |||
| 505 | parent = x_find_topmost_parent (f); | ||
| 506 | if (parent != None) | ||
| 507 | XChangeProperty (dpy, parent, dpyinfo->Xatom_net_wm_window_opacity, | ||
| 508 | XA_CARDINAL, 32, PropModeReplace, | ||
| 509 | (unsigned char *) &opac, 1L); | ||
| 510 | |||
| 476 | /* return unless necessary */ | 511 | /* return unless necessary */ |
| 477 | { | 512 | { |
| 478 | unsigned char *data; | 513 | unsigned char *data; |
| @@ -480,7 +515,6 @@ x_set_frame_alpha (struct frame *f) | |||
| 480 | int rc, format; | 515 | int rc, format; |
| 481 | unsigned long n, left; | 516 | unsigned long n, left; |
| 482 | 517 | ||
| 483 | x_catch_errors (dpy); | ||
| 484 | rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_wm_window_opacity, | 518 | rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_wm_window_opacity, |
| 485 | 0L, 1L, False, XA_CARDINAL, | 519 | 0L, 1L, False, XA_CARDINAL, |
| 486 | &actual, &format, &n, &left, | 520 | &actual, &format, &n, &left, |
| @@ -1625,19 +1659,18 @@ x_color_cells (Display *dpy, int *ncells) | |||
| 1625 | if (dpyinfo->color_cells == NULL) | 1659 | if (dpyinfo->color_cells == NULL) |
| 1626 | { | 1660 | { |
| 1627 | Screen *screen = dpyinfo->screen; | 1661 | Screen *screen = dpyinfo->screen; |
| 1662 | int ncolor_cells = XDisplayCells (dpy, XScreenNumberOfScreen (screen)); | ||
| 1628 | int i; | 1663 | int i; |
| 1629 | 1664 | ||
| 1630 | dpyinfo->ncolor_cells | 1665 | dpyinfo->color_cells = xnmalloc (ncolor_cells, |
| 1631 | = XDisplayCells (dpy, XScreenNumberOfScreen (screen)); | 1666 | sizeof *dpyinfo->color_cells); |
| 1632 | dpyinfo->color_cells | 1667 | dpyinfo->ncolor_cells = ncolor_cells; |
| 1633 | = (XColor *) xmalloc (dpyinfo->ncolor_cells | ||
| 1634 | * sizeof *dpyinfo->color_cells); | ||
| 1635 | 1668 | ||
| 1636 | for (i = 0; i < dpyinfo->ncolor_cells; ++i) | 1669 | for (i = 0; i < ncolor_cells; ++i) |
| 1637 | dpyinfo->color_cells[i].pixel = i; | 1670 | dpyinfo->color_cells[i].pixel = i; |
| 1638 | 1671 | ||
| 1639 | XQueryColors (dpy, dpyinfo->cmap, | 1672 | XQueryColors (dpy, dpyinfo->cmap, |
| 1640 | dpyinfo->color_cells, dpyinfo->ncolor_cells); | 1673 | dpyinfo->color_cells, ncolor_cells); |
| 1641 | } | 1674 | } |
| 1642 | 1675 | ||
| 1643 | *ncells = dpyinfo->ncolor_cells; | 1676 | *ncells = dpyinfo->ncolor_cells; |
| @@ -4190,7 +4223,7 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name, | |||
| 4190 | x_send_scroll_bar_event and x_scroll_bar_to_input_event. */ | 4223 | x_send_scroll_bar_event and x_scroll_bar_to_input_event. */ |
| 4191 | 4224 | ||
| 4192 | static struct window **scroll_bar_windows; | 4225 | static struct window **scroll_bar_windows; |
| 4193 | static size_t scroll_bar_windows_size; | 4226 | static ptrdiff_t scroll_bar_windows_size; |
| 4194 | 4227 | ||
| 4195 | 4228 | ||
| 4196 | /* Send a client message with message type Xatom_Scrollbar for a | 4229 | /* Send a client message with message type Xatom_Scrollbar for a |
| @@ -4205,7 +4238,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) | |||
| 4205 | XClientMessageEvent *ev = (XClientMessageEvent *) &event; | 4238 | XClientMessageEvent *ev = (XClientMessageEvent *) &event; |
| 4206 | struct window *w = XWINDOW (window); | 4239 | struct window *w = XWINDOW (window); |
| 4207 | struct frame *f = XFRAME (w->frame); | 4240 | struct frame *f = XFRAME (w->frame); |
| 4208 | size_t i; | 4241 | ptrdiff_t i; |
| 4209 | 4242 | ||
| 4210 | BLOCK_INPUT; | 4243 | BLOCK_INPUT; |
| 4211 | 4244 | ||
| @@ -4226,16 +4259,15 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) | |||
| 4226 | 4259 | ||
| 4227 | if (i == scroll_bar_windows_size) | 4260 | if (i == scroll_bar_windows_size) |
| 4228 | { | 4261 | { |
| 4229 | size_t new_size = max (10, 2 * scroll_bar_windows_size); | 4262 | ptrdiff_t old_nbytes = |
| 4230 | size_t nbytes = new_size * sizeof *scroll_bar_windows; | 4263 | scroll_bar_windows_size * sizeof *scroll_bar_windows; |
| 4231 | size_t old_nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; | 4264 | ptrdiff_t nbytes; |
| 4232 | 4265 | enum { XClientMessageEvent_MAX = 0x7fffffff }; | |
| 4233 | if ((size_t) -1 / sizeof *scroll_bar_windows < new_size) | 4266 | scroll_bar_windows = |
| 4234 | memory_full (SIZE_MAX); | 4267 | xpalloc (scroll_bar_windows, &scroll_bar_windows_size, 1, |
| 4235 | scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows, | 4268 | XClientMessageEvent_MAX, sizeof *scroll_bar_windows); |
| 4236 | nbytes); | 4269 | nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; |
| 4237 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); | 4270 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); |
| 4238 | scroll_bar_windows_size = new_size; | ||
| 4239 | } | 4271 | } |
| 4240 | 4272 | ||
| 4241 | scroll_bar_windows[i] = w; | 4273 | scroll_bar_windows[i] = w; |
| @@ -5813,11 +5845,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 5813 | } inev; | 5845 | } inev; |
| 5814 | int count = 0; | 5846 | int count = 0; |
| 5815 | int do_help = 0; | 5847 | int do_help = 0; |
| 5816 | int nbytes = 0; | 5848 | ptrdiff_t nbytes = 0; |
| 5817 | struct frame *f = NULL; | 5849 | struct frame *f = NULL; |
| 5818 | struct coding_system coding; | 5850 | struct coding_system coding; |
| 5819 | XEvent event = *eventptr; | 5851 | XEvent event = *eventptr; |
| 5820 | Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; | 5852 | Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; |
| 5853 | USE_SAFE_ALLOCA; | ||
| 5821 | 5854 | ||
| 5822 | *finish = X_EVENT_NORMAL; | 5855 | *finish = X_EVENT_NORMAL; |
| 5823 | 5856 | ||
| @@ -6088,6 +6121,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6088 | /* Perhaps reparented due to a WM restart. Reset this. */ | 6121 | /* Perhaps reparented due to a WM restart. Reset this. */ |
| 6089 | FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN; | 6122 | FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN; |
| 6090 | FRAME_X_DISPLAY_INFO (f)->net_supported_window = 0; | 6123 | FRAME_X_DISPLAY_INFO (f)->net_supported_window = 0; |
| 6124 | |||
| 6125 | x_set_frame_alpha (f); | ||
| 6091 | } | 6126 | } |
| 6092 | goto OTHER; | 6127 | goto OTHER; |
| 6093 | 6128 | ||
| @@ -6511,7 +6546,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6511 | } | 6546 | } |
| 6512 | 6547 | ||
| 6513 | { /* Raw bytes, not keysym. */ | 6548 | { /* Raw bytes, not keysym. */ |
| 6514 | register int i; | 6549 | ptrdiff_t i; |
| 6515 | int nchars, len; | 6550 | int nchars, len; |
| 6516 | 6551 | ||
| 6517 | for (i = 0, nchars = 0; i < nbytes; i++) | 6552 | for (i = 0, nchars = 0; i < nbytes; i++) |
| @@ -6524,7 +6559,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6524 | if (nchars < nbytes) | 6559 | if (nchars < nbytes) |
| 6525 | { | 6560 | { |
| 6526 | /* Decode the input data. */ | 6561 | /* Decode the input data. */ |
| 6527 | int require; | ||
| 6528 | 6562 | ||
| 6529 | /* The input should be decoded with `coding_system' | 6563 | /* The input should be decoded with `coding_system' |
| 6530 | which depends on which X*LookupString function | 6564 | which depends on which X*LookupString function |
| @@ -6537,9 +6571,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6537 | gives us composition information. */ | 6571 | gives us composition information. */ |
| 6538 | coding.common_flags &= ~CODING_ANNOTATION_MASK; | 6572 | coding.common_flags &= ~CODING_ANNOTATION_MASK; |
| 6539 | 6573 | ||
| 6540 | require = MAX_MULTIBYTE_LENGTH * nbytes; | 6574 | SAFE_NALLOCA (coding.destination, MAX_MULTIBYTE_LENGTH, |
| 6541 | coding.destination = alloca (require); | 6575 | nbytes); |
| 6542 | coding.dst_bytes = require; | 6576 | coding.dst_bytes = MAX_MULTIBYTE_LENGTH * nbytes; |
| 6543 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6577 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 6544 | decode_coding_c_string (&coding, copy_bufptr, nbytes, Qnil); | 6578 | decode_coding_c_string (&coding, copy_bufptr, nbytes, Qnil); |
| 6545 | nbytes = coding.produced; | 6579 | nbytes = coding.produced; |
| @@ -6998,6 +7032,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6998 | count++; | 7032 | count++; |
| 6999 | } | 7033 | } |
| 7000 | 7034 | ||
| 7035 | SAFE_FREE (); | ||
| 7001 | *eventptr = event; | 7036 | *eventptr = event; |
| 7002 | return count; | 7037 | return count; |
| 7003 | } | 7038 | } |
| @@ -9822,6 +9857,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 9822 | struct x_display_info *dpyinfo; | 9857 | struct x_display_info *dpyinfo; |
| 9823 | XrmDatabase xrdb; | 9858 | XrmDatabase xrdb; |
| 9824 | Mouse_HLInfo *hlinfo; | 9859 | Mouse_HLInfo *hlinfo; |
| 9860 | ptrdiff_t lim; | ||
| 9825 | 9861 | ||
| 9826 | BLOCK_INPUT; | 9862 | BLOCK_INPUT; |
| 9827 | 9863 | ||
| @@ -10040,12 +10076,15 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10040 | XSetAfterFunction (x_current_display, x_trace_wire); | 10076 | XSetAfterFunction (x_current_display, x_trace_wire); |
| 10041 | #endif /* ! 0 */ | 10077 | #endif /* ! 0 */ |
| 10042 | 10078 | ||
| 10079 | lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@"; | ||
| 10080 | if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name)) | ||
| 10081 | memory_full (SIZE_MAX); | ||
| 10043 | dpyinfo->x_id_name | 10082 | dpyinfo->x_id_name |
| 10044 | = (char *) xmalloc (SBYTES (Vinvocation_name) | 10083 | = (char *) xmalloc (SBYTES (Vinvocation_name) |
| 10045 | + SBYTES (Vsystem_name) | 10084 | + SBYTES (Vsystem_name) |
| 10046 | + 2); | 10085 | + 2); |
| 10047 | sprintf (dpyinfo->x_id_name, "%s@%s", | 10086 | strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), |
| 10048 | SSDATA (Vinvocation_name), SSDATA (Vsystem_name)); | 10087 | SSDATA (Vsystem_name)); |
| 10049 | 10088 | ||
| 10050 | /* Figure out which modifier bits mean what. */ | 10089 | /* Figure out which modifier bits mean what. */ |
| 10051 | x_find_modifier_meanings (dpyinfo); | 10090 | x_find_modifier_meanings (dpyinfo); |