diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 186 | ||||
-rw-r--r-- | src/alloc.c | 5 | ||||
-rw-r--r-- | src/bidi.c | 3 | ||||
-rw-r--r-- | src/category.c | 4 | ||||
-rw-r--r-- | src/ccl.c | 57 | ||||
-rw-r--r-- | src/character.c | 2 | ||||
-rw-r--r-- | src/character.h | 8 | ||||
-rw-r--r-- | src/charset.c | 29 | ||||
-rw-r--r-- | src/charset.h | 7 | ||||
-rw-r--r-- | src/chartab.c | 45 | ||||
-rw-r--r-- | src/cm.c | 9 | ||||
-rw-r--r-- | src/cm.h | 33 | ||||
-rw-r--r-- | src/coding.c | 203 | ||||
-rw-r--r-- | src/config.in | 3 | ||||
-rw-r--r-- | src/deps.mk | 4 | ||||
-rw-r--r-- | src/dispextern.h | 8 | ||||
-rw-r--r-- | src/fontset.c | 17 | ||||
-rw-r--r-- | src/fringe.c | 12 | ||||
-rw-r--r-- | src/lisp.h | 26 | ||||
-rw-r--r-- | src/scroll.c | 13 | ||||
-rw-r--r-- | src/term.c | 80 | ||||
-rw-r--r-- | src/termchar.h | 93 | ||||
-rw-r--r-- | src/terminal.c | 5 | ||||
-rw-r--r-- | src/tparam.c | 16 | ||||
-rw-r--r-- | src/tparam.h | 31 | ||||
-rw-r--r-- | src/window.c | 53 | ||||
-rw-r--r-- | src/window.h | 1 | ||||
-rw-r--r-- | src/xdisp.c | 51 | ||||
-rw-r--r-- | src/xfaces.c | 88 | ||||
-rw-r--r-- | src/xfns.c | 52 | ||||
-rw-r--r-- | src/xmenu.c | 22 | ||||
-rw-r--r-- | src/xrdb.c | 8 | ||||
-rw-r--r-- | src/xselect.c | 34 | ||||
-rw-r--r-- | src/xterm.c | 193 | ||||
-rw-r--r-- | src/xterm.h | 1 |
35 files changed, 732 insertions, 670 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c4af193d1b..5991d9e066 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,189 @@ +2011-03-11 Paul Eggert <[email protected]> + + Minor changes for problems found by GCC 4.5.2's static checks. + + * fringe.c (update_window_fringes): Mark locals as initialized + (Bug#8227). + (destroy_fringe_bitmap, init_fringe_bitmap): Now static. + + * alloc.c (mark_fringe_data): Move decl from here ... + * lisp.h (mark_fringe_data) [HAVE_WINDOW_SYSTEM]: ... to here, + to check its interface. + (init_fringe_once): Do not declare unless HAVE_WINDOW_SYSTEM. + + * fontset.c (free_realized_fontset): Now static. + (Fset_fontset_font): Rename local to avoid shadowing. + (fontset_font): Mark local as initialized. + (FONTSET_SPEC, FONTSET_REPERTORY, RFONT_DEF_REPERTORY): Remove; unused. + + * xrdb.c: Include "xterm.h", to check x_load_resources's interface. + + * xselect.c (x_disown_buffer_selections): Remove; not used. + (TRACE3) [!defined TRACE_SELECTION]: Remove; not used. + (x_own_selection, Fx_disown_selection_internal): Rename locals + to avoid shadowing. + (x_handle_dnd_message): Remove local to avoid shadowing. + + * lisp.h (GCPRO1_VAR, UNGCPRO_VAR): New macros, + so that the caller can use some name other than gcpro1. + (GCPRO1, UNGCPRO): Reimplement in terms of the new macros. + * xfns.c (Fx_create_frame, x_create_tip_frame, Fx_show_tip): + (Fx_backspace_delete_keys_p): + Use them to avoid shadowing, and rename vars to avoid shadowing. + (x_decode_color, x_set_name, x_window): Now static. + (Fx_create_frame): Add braces to silence GCC warning. + (Fx_file_dialog, Fx_select_font): Fix pointer signedness. + (x_real_positions, xg_set_icon_from_xpm_data, x_create_tip_frame): + Remove unused locals. + (Fx_create_frame, x_create_tip_frame, Fx_show_tip): + (Fx_backspace_delete_keys_p): Rename locals to avoid shadowing. + Some of these renamings use the new GCPRO1_VAR and UNGCPRO_VAR + macros. + + * xterm.h (x_mouse_leave): New decl. + + * xterm.c (x_copy_dpy_color, x_focus_on_frame, x_unfocus_frame): + Remove unused functions. + (x_shift_glyphs_for_insert, XTflash, XTring_bell): + (x_calc_absolute_position): Now static. + (XTread_socket): Don't define label "out" unless it's used. + Don't declare local "event" unless it's used. + (x_iconify_frame, x_free_frame_resources): Don't declare locals + unless they are used. + (XEMBED_VERSION, xembed_set_info): Don't define unless needed. + (x_fatal_error_signal): Remove; not used. + (x_draw_image_foreground, redo_mouse_highlight, XTmouse_position): + (x_scroll_bar_report_motion, handle_one_xevent, x_draw_bar_cursor): + (x_error_catcher, x_connection_closed, x_error_handler): + (x_error_quitter, xembed_send_message, x_iconify_frame): + (my_log_handler): Rename locals to avoid shadowing. + (x_delete_glyphs, x_ins_del_lines): Mark with NO_RETURN. + (x_connection_closed): Tell GCC not to suggest NO_RETURN. + + * xfaces.c (clear_face_cache, Fx_list_fonts, Fface_font): Rename + or move locals to avoid shadowing. + (tty_defined_color, merge_face_heights): Now static. + (free_realized_faces_for_fontset): Remove; not used. + (Fx_list_fonts): Mark variable that gcc -Wuninitialized + does not deduce is never used uninitialized. + (STRDUPA, LSTRDUPA, FONT_POINT_SIZE_QUANTUM): Remove; not used. + (LFACEP): Define only if XASSERTS, as it's not needed otherwise. + + * terminal.c (store_terminal_param): Now static. + + * xmenu.c (menu_highlight_callback): Now static. + (set_frame_menubar): Remove unused local. + (xmenu_show): Rename parameter to avoid shadowing. + (xmenu_show, xdialog_show, xmenu_show): Make local pointers "const" + since they might point to immutable storage. + (next_menubar_widget_id): Declare only if USE_X_TOOLKIT, + since it's unused otherwise. + + * xdisp.c (produce_glyphless_glyph): Initialize lower_xoff. + Add a FIXME, since the code still doesn't look right. (Bug#8215) + (Fcurrent_bidi_paragraph_direction): Simplify slightly; this + avoids a gcc -Wuninitialized diagnostic. + (display_line, BUILD_COMPOSITE_GLYPH_STRING, draw_glyphs): + (note_mouse_highlight): Mark variables that gcc -Wuninitialized + does not deduce are never used uninitialized. + + * lisp.h (IF_LINT): New macro, copied from ../lib-src/emacsclient.c. + + * xdisp.c (redisplay_window): Rename local to avoid shadowing. + * window.c (window_loop, size_window): + (run_window_configuration_change_hook, enlarge_window): Likewise. + + * window.c (display_buffer): Now static. + (size_window): Mark variables that gcc -Wuninitialized + does not deduce are never used uninitialized. + * window.h (check_all_windows): New decl, to forestall + gcc -Wmissing-prototypes diagnostic. + * dispextern.h (bidi_dump_cached_states): Likewise. + + * charset.h (CHECK_CHARSET_GET_CHARSET): Rename locals to avoid + shadowing. + * charset.c (map_charset_for_dump, Fchar_charset): Likewise. + Include <limits.h>. + (Fsort_charsets): Redo min/max calculation to shorten the code a bit + and to avoid gcc -Wuninitialized warning. + (load_charset_map): Mark variables that gcc -Wuninitialized + does not deduce are never used uninitialized. + (load_charset): Abort instead of using uninitialized var (Bug#8229). + + * coding.c (coding_set_source, coding_set_destination): + Use "else { /* comment */ }" rather than "else /* comment */;" + for clarity, and to avoid gcc -Wempty-body warning. + (Fdefine_coding_system_internal): Don't redeclare 'i' inside + a block, when the outer 'i' will do. + (decode_coding_utf_8, decode_coding_utf_16, detect_coding_emacs_mule): + (emacs_mule_char, decode_coding_emacs_mule, detect_coding_iso_2022): + (decode_coding_iso_2022, decode_coding_sjis, decode_coding_big5): + (decode_coding_raw_text, decode_coding_charset, get_translation_table): + (Fdecode_sjis_char, Fdefine_coding_system_internal): + Rename locals to avoid shadowing. + * character.h (FETCH_STRING_CHAR_ADVANCE): Likewise. + * coding.c (emacs_mule_char, encode_invocation_designation): + Now static, since they're not used elsewhere. + (decode_coding_iso_2022): Add "default: abort ();" as a safety check. + (decode_coding_object, encode_coding_object, detect_coding_system): + (decode_coding_emacs_mule): Mark variables that gcc + -Wuninitialized does not deduce are never used uninitialized. + (detect_coding_iso_2022): Initialize a local variable that might + be used uninitialized. Leave a FIXME because it's not clear that + this initialization is needed. (Bug#8211) + (ISO_CODE_LF, ISO_CODE_CR, CODING_ISO_FLAG_EUC_TW_SHIFT): + (ONE_MORE_BYTE_NO_CHECK, UTF_BOM, UTF_16_INVALID_P): + (SHIFT_OUT_OK, ENCODE_CONTROL_SEQUENCE_INTRODUCER): + (ENCODE_DIRECTION_R2L, ENCODE_DIRECTION_L2R): + Remove unused macros. + + * category.c (hash_get_category_set): Remove unused local var. + (copy_category_table): Now static, since it's not used elsewhere. + * character.c (string_count_byte8): Likewise. + + * ccl.c (CCL_WRITE_STRING, CCL_ENCODE_CHAR, Fccl_execute_on_string): + (Fregister_code_conversion_map): Rename locals to avoid shadowing. + + * chartab.c (copy_sub_char_table): Now static, since it's not used + elsewhere. + (sub_char_table_ref_and_range, char_table_ref_and_range): + Rename locals to avoid shadowing. + (ASET_RANGE, GET_SUB_CHAR_TABLE): Remove unused macros. + + * bidi.c (bidi_check_type): Now static, since it's not used elsewhere. + (BIDI_BOB): Remove unused macro. + + * cm.c (cmgoto): Mark variables that gcc -Wuninitialized does not + deduce are never used uninitialized. + * term.c (encode_terminal_code): Likewise. + + * term.c (encode_terminal_code): Now static. Remove unused local. + + * tparam.h: New file. + * term.c, tparam.h: Include it. + * deps.mk (term.o, tparam.o): Depend on tparam.h. + * term.c (tputs, tgetent, tgetflag, tgetnum, tparam, tgetstr): + Move these decls to tparam.h, and make them agree with what + is actually in tparam.c. The previous trick of using incompatible + decls in different modules does not conform to the C standard. + All callers of tparam changed to use tparam's actual API. + * tparam.c (tparam1, tparam, tgoto): + Use const pointers where appropriate. + + * cm.c (calccost, cmgoto): Use const pointers where appropriate. + * cm.h (struct cm): Likewise. + * dispextern.h (do_line_insertion_deletion_costs): Likewise. + * scroll.c (ins_del_costs, do_line_insertion_deletion_costs): Likewise. + * term.c (tty_ins_del_lines, calculate_costs, struct fkey_table): + (term_get_fkeys_1, append_glyphless_glyph, produce_glyphless_glyph): + (turn_on_face, init_tty): Likewise. + * termchar.h (struct tty_display_info): Likewise. + + * term.c (term_mouse_position): Rename local to avoid shadowing. + + * alloc.c (mark_ttys): Move decl from here ... + * lisp.h (mark_ttys): ... to here, so that it's checked against defn. + 2011-03-11 Andreas Schwab <[email protected]> * .gdbinit (pwinx, xbuffer): Fix access to buffer name. diff --git a/src/alloc.c b/src/alloc.c index d7006ca6bf..6c92f36ca7 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -271,16 +271,11 @@ Lisp_Object Qpost_gc_hook; static void mark_buffer (Lisp_Object); static void mark_terminals (void); extern void mark_kboards (void); -extern void mark_ttys (void); extern void mark_backtrace (void); static void gc_sweep (void); static void mark_glyph_matrix (struct glyph_matrix *); static void mark_face_cache (struct face_cache *); -#ifdef HAVE_WINDOW_SYSTEM -extern void mark_fringe_data (void); -#endif /* HAVE_WINDOW_SYSTEM */ - static struct Lisp_String *allocate_string (void); static void compact_small_strings (void); static void free_large_strings (void); diff --git a/src/bidi.c b/src/bidi.c index eeacf65bd5..3457e17743 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -72,7 +72,6 @@ static Lisp_Object bidi_type_table, bidi_mirror_table; #define RLO_CHAR 0x202E #define BIDI_EOB -1 -#define BIDI_BOB -2 /* FIXME: Is this needed? */ /* Local data structures. (Look in dispextern.h for the rest.) */ @@ -180,7 +179,7 @@ bidi_get_type (int ch, bidi_dir_t override) } } -void +static void bidi_check_type (bidi_type_t type) { if (type < UNKNOWN_BT || type > NEUTRAL_ON) diff --git a/src/category.c b/src/category.c index bcd73d3a48..cc7ff88474 100644 --- a/src/category.c +++ b/src/category.c @@ -61,7 +61,6 @@ static Lisp_Object hash_get_category_set (Lisp_Object, Lisp_Object); static Lisp_Object hash_get_category_set (Lisp_Object table, Lisp_Object category_set) { - Lisp_Object val; struct Lisp_Hash_Table *h; int i; unsigned hash; @@ -228,7 +227,7 @@ copy_category_entry (Lisp_Object table, Lisp_Object c, Lisp_Object val) the original and the copy. This function is called recursively by binding TABLE to a sub char table. */ -Lisp_Object +static Lisp_Object copy_category_table (Lisp_Object table) { table = copy_char_table (table); @@ -538,4 +537,3 @@ See the documentation of the variable `word-combining-categories'. */); category_table_version = 0; } - @@ -758,18 +758,18 @@ while(0) buffer. */ #define CCL_WRITE_STRING(len) \ do { \ - int i; \ + int ccli; \ if (!dst) \ CCL_INVALID_CMD; \ else if (dst + len <= dst_end) \ { \ if (XFASTINT (ccl_prog[ic]) & 0x1000000) \ - for (i = 0; i < len; i++) \ - *dst++ = XFASTINT (ccl_prog[ic + i]) & 0xFFFFFF; \ + for (ccli = 0; ccli < len; ccli++) \ + *dst++ = XFASTINT (ccl_prog[ic + ccli]) & 0xFFFFFF; \ else \ - for (i = 0; i < len; i++) \ - *dst++ = ((XFASTINT (ccl_prog[ic + (i / 3)])) \ - >> ((2 - (i % 3)) * 8)) & 0xFF; \ + for (ccli = 0; ccli < len; ccli++) \ + *dst++ = ((XFASTINT (ccl_prog[ic + (ccli / 3)])) \ + >> ((2 - (ccli % 3)) * 8)) & 0xFF; \ } \ else \ CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ @@ -806,15 +806,15 @@ while(0) #define CCL_ENCODE_CHAR(c, charset_list, id, encoded) \ do { \ - unsigned code; \ + unsigned ncode; \ \ - charset = char_charset ((c), (charset_list), &code); \ + charset = char_charset ((c), (charset_list), &ncode); \ if (! charset && ! NILP (charset_list)) \ - charset = char_charset ((c), Qnil, &code); \ + charset = char_charset ((c), Qnil, &ncode); \ if (charset) \ { \ (id) = CHARSET_ID (charset); \ - (encoded) = code; \ + (encoded) = ncode; \ } \ } while (0) @@ -2092,22 +2092,22 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY { const unsigned char *p = SDATA (str) + consumed_bytes; const unsigned char *endp = SDATA (str) + str_bytes; - int i = 0; + int j = 0; int *src, src_size; if (endp - p == str_chars - consumed_chars) - while (i < CCL_EXECUTE_BUF_SIZE && p < endp) - source[i++] = *p++; + while (j < CCL_EXECUTE_BUF_SIZE && p < endp) + source[j++] = *p++; else - while (i < CCL_EXECUTE_BUF_SIZE && p < endp) - source[i++] = STRING_CHAR_ADVANCE (p); - consumed_chars += i; + while (j < CCL_EXECUTE_BUF_SIZE && p < endp) + source[j++] = STRING_CHAR_ADVANCE (p); + consumed_chars += j; consumed_bytes = p - SDATA (str); if (consumed_bytes == str_bytes) ccl.last_block = NILP (contin); src = source; - src_size = i; + src_size = j; while (1) { ccl_driver (&ccl, src, destination, src_size, CCL_EXECUTE_BUF_SIZE, @@ -2123,8 +2123,8 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); outp = outbuf + offset; } - for (i = 0; i < ccl.produced; i++) - CHAR_STRING_ADVANCE (destination[i], outp); + for (j = 0; j < ccl.produced; j++) + CHAR_STRING_ADVANCE (destination[j], outp); } else { @@ -2135,8 +2135,8 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); outp = outbuf + offset; } - for (i = 0; i < ccl.produced; i++) - *outp++ = destination[i]; + for (j = 0; j < ccl.produced; j++) + *outp++ = destination[j]; } src += ccl.consumed; src_size -= ccl.consumed; @@ -2253,7 +2253,7 @@ Return index number of the registered map. */) { int len = ASIZE (Vcode_conversion_map_vector); int i; - Lisp_Object index; + Lisp_Object idx; CHECK_SYMBOL (symbol); CHECK_VECTOR (map); @@ -2267,11 +2267,11 @@ Return index number of the registered map. */) if (EQ (symbol, XCAR (slot))) { - index = make_number (i); + idx = make_number (i); XSETCDR (slot, map); Fput (symbol, Qcode_conversion_map, map); - Fput (symbol, Qcode_conversion_map_id, index); - return index; + Fput (symbol, Qcode_conversion_map_id, idx); + return idx; } } @@ -2279,11 +2279,11 @@ Return index number of the registered map. */) Vcode_conversion_map_vector = larger_vector (Vcode_conversion_map_vector, len * 2, Qnil); - index = make_number (i); + idx = make_number (i); Fput (symbol, Qcode_conversion_map, map); - Fput (symbol, Qcode_conversion_map_id, index); + Fput (symbol, Qcode_conversion_map_id, idx); ASET (Vcode_conversion_map_vector, i, Fcons (symbol, map)); - return index; + return idx; } @@ -2341,4 +2341,3 @@ used by CCL. */); defsubr (&Sregister_ccl_program); defsubr (&Sregister_code_conversion_map); } - diff --git a/src/character.c b/src/character.c index 6f3312fec2..fdaf22f04f 100644 --- a/src/character.c +++ b/src/character.c @@ -786,7 +786,7 @@ str_to_unibyte (const unsigned char *src, unsigned char *dst, EMACS_INT chars, i } -EMACS_INT +static EMACS_INT string_count_byte8 (Lisp_Object string) { int multibyte = STRING_MULTIBYTE (string); diff --git a/src/character.h b/src/character.h index fb29ced66b..d29ab41557 100644 --- a/src/character.h +++ b/src/character.h @@ -356,11 +356,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ CHARIDX++; \ if (STRING_MULTIBYTE (STRING)) \ { \ - unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \ - int len; \ + unsigned char *string_ptr = &SDATA (STRING)[BYTEIDX]; \ + int string_len; \ \ - OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \ - BYTEIDX += len; \ + OUTPUT = STRING_CHAR_AND_LENGTH (string_ptr, string_len); \ + BYTEIDX += string_len; \ } \ else \ { \ diff --git a/src/charset.c b/src/charset.c index 3624e740ac..d82b29ae44 100644 --- a/src/charset.c +++ b/src/charset.c @@ -29,6 +29,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <unistd.h> #include <ctype.h> +#include <limits.h> #include <sys/types.h> #include <setjmp.h> #include "lisp.h" @@ -250,7 +251,7 @@ struct charset_map_entries static void load_charset_map (struct charset *charset, struct charset_map_entries *entries, int n_entries, int control_flag) { - Lisp_Object vec, table; + Lisp_Object vec IF_LINT (= Qnil), table IF_LINT (= Qnil); unsigned max_code = CHARSET_MAX_CODE (charset); int ascii_compatible_p = charset->ascii_compatible_p; int min_char, max_char, nonascii_min_char; @@ -629,8 +630,12 @@ load_charset (struct charset *charset, int control_flag) if (CHARSET_METHOD (charset) == CHARSET_METHOD_MAP) map = CHARSET_MAP (charset); - else if (CHARSET_UNIFIED_P (charset)) - map = CHARSET_UNIFY_MAP (charset); + else + { + if (! CHARSET_UNIFIED_P (charset)) + abort (); + map = CHARSET_UNIFY_MAP (charset); + } if (STRINGP (map)) load_charset_map_from_file (charset, map, control_flag); else @@ -668,9 +673,9 @@ map_charset_for_dump (void (*c_function) (Lisp_Object, Lisp_Object), Lisp_Object while (1) { - int index = GET_TEMP_CHARSET_WORK_ENCODER (c); + int idx = GET_TEMP_CHARSET_WORK_ENCODER (c); - if (index >= from_idx && index <= to_idx) + if (idx >= from_idx && idx <= to_idx) { if (NILP (XCAR (range))) XSETCAR (range, make_number (c)); @@ -2066,10 +2071,10 @@ that case, find the charset from what supported by that coding system. */) for (; CONSP (restriction); restriction = XCDR (restriction)) { - struct charset *charset; + struct charset *rcharset; - CHECK_CHARSET_GET_CHARSET (XCAR (restriction), charset); - if (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset)) + CHECK_CHARSET_GET_CHARSET (XCAR (restriction), rcharset); + if (ENCODE_CHAR (rcharset, c) != CHARSET_INVALID_CODE (rcharset)) return XCAR (restriction); } return Qnil; @@ -2250,7 +2255,7 @@ See also `charset-priority-list' and `set-charset-priority'. */) int n = XFASTINT (len), i, j, done; Lisp_Object tail, elt, attrs; struct charset_sort_data *sort_data; - int id, min_id, max_id; + int id, min_id = INT_MAX, max_id = INT_MIN; USE_SAFE_ALLOCA; if (n == 0) @@ -2262,11 +2267,9 @@ See also `charset-priority-list' and `set-charset-priority'. */) CHECK_CHARSET_GET_ATTR (elt, attrs); sort_data[i].charset = elt; sort_data[i].id = id = XINT (CHARSET_ATTR_ID (attrs)); - if (i == 0) - min_id = max_id = id; - else if (id < min_id) + if (id < min_id) min_id = id; - else if (id > max_id) + if (id > max_id) max_id = id; } for (done = 0, tail = Vcharset_ordered_list, i = 0; diff --git a/src/charset.h b/src/charset.h index 1fc552a5bd..8c87ffe6c3 100644 --- a/src/charset.h +++ b/src/charset.h @@ -358,9 +358,9 @@ extern int emacs_mule_charset[256]; #define CHECK_CHARSET_GET_CHARSET(x, charset) \ do { \ - int id; \ - CHECK_CHARSET_GET_ID (x, id); \ - charset = CHARSET_FROM_ID (id); \ + int csid; \ + CHECK_CHARSET_GET_ID (x, csid); \ + charset = CHARSET_FROM_ID (csid); \ } while (0) @@ -541,4 +541,3 @@ extern void map_charset_chars (void (*) (Lisp_Object, Lisp_Object), struct charset *, unsigned, unsigned); #endif /* EMACS_CHARSET_H */ - diff --git a/src/chartab.c b/src/chartab.c index cd8aa784eb..85aa5932ac 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -118,7 +118,7 @@ char_table_ascii (Lisp_Object table) return XSUB_CHAR_TABLE (sub)->contents[0]; } -Lisp_Object +static Lisp_Object copy_sub_char_table (Lisp_Object table) { Lisp_Object copy; @@ -216,16 +216,16 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp int depth = XINT (tbl->depth); int min_char = XINT (tbl->min_char); int max_char = min_char + chartab_chars[depth - 1] - 1; - int index = CHARTAB_IDX (c, depth, min_char), idx; + int chartab_idx = CHARTAB_IDX (c, depth, min_char), idx; Lisp_Object val; - val = tbl->contents[index]; + val = tbl->contents[chartab_idx]; if (SUB_CHAR_TABLE_P (val)) val = sub_char_table_ref_and_range (val, c, from, to, defalt); else if (NILP (val)) val = defalt; - idx = index; + idx = chartab_idx; while (idx > 0 && *from < min_char + idx * chartab_chars[depth]) { Lisp_Object this_val; @@ -244,13 +244,13 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp break; } } - while ((c = min_char + (index + 1) * chartab_chars[depth]) <= max_char + while ((c = min_char + (chartab_idx + 1) * chartab_chars[depth]) <= max_char && *to >= c) { Lisp_Object this_val; - index++; - this_val = tbl->contents[index]; + chartab_idx++; + this_val = tbl->contents[chartab_idx]; if (SUB_CHAR_TABLE_P (this_val)) this_val = sub_char_table_ref_and_range (this_val, c, from, to, defalt); else if (NILP (this_val)) @@ -275,10 +275,10 @@ Lisp_Object char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); - int index = CHARTAB_IDX (c, 0, 0), idx; + int chartab_idx = CHARTAB_IDX (c, 0, 0), idx; Lisp_Object val; - val = tbl->contents[index]; + val = tbl->contents[chartab_idx]; if (*from < 0) *from = 0; if (*to < 0) @@ -288,7 +288,7 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) else if (NILP (val)) val = tbl->defalt; - idx = index; + idx = chartab_idx; while (*from < idx * chartab_chars[0]) { Lisp_Object this_val; @@ -308,13 +308,13 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) break; } } - while (*to >= (index + 1) * chartab_chars[0]) + while (*to >= (chartab_idx + 1) * chartab_chars[0]) { Lisp_Object this_val; - index++; - c = index * chartab_chars[0]; - this_val = tbl->contents[index]; + chartab_idx++; + c = chartab_idx * chartab_chars[0]; + this_val = tbl->contents[chartab_idx]; if (SUB_CHAR_TABLE_P (this_val)) this_val = sub_char_table_ref_and_range (this_val, c, from, to, tbl->defalt); @@ -331,20 +331,6 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) } -#define ASET_RANGE(ARRAY, FROM, TO, LIMIT, VAL) \ - do { \ - int limit = (TO) < (LIMIT) ? (TO) : (LIMIT); \ - for (; (FROM) < limit; (FROM)++) (ARRAY)->contents[(FROM)] = (VAL); \ - } while (0) - -#define GET_SUB_CHAR_TABLE(TABLE, SUBTABLE, IDX, DEPTH, MIN_CHAR) \ - do { \ - (SUBTABLE) = (TABLE)->contents[(IDX)]; \ - if (!SUB_CHAR_TABLE_P (SUBTABLE)) \ - (SUBTABLE) = make_sub_char_table ((DEPTH), (MIN_CHAR), (SUBTABLE)); \ - } while (0) - - static void sub_char_table_set (Lisp_Object table, int c, Lisp_Object val) { @@ -951,7 +937,7 @@ map_sub_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), map_charset_chars. */ void -map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), +map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), Lisp_Object function, Lisp_Object table, Lisp_Object arg, struct charset *charset, unsigned from, unsigned to) @@ -1012,4 +998,3 @@ syms_of_chartab (void) defsubr (&Soptimize_char_table); defsubr (&Smap_char_table); } - @@ -199,7 +199,7 @@ calccost (struct tty_display_info *tty, tabx, tab2x, tabcost; - register char *p; + register const char *p; /* If have just wrapped on a terminal with xn, don't believe the cursor position: give up here @@ -330,9 +330,9 @@ cmgoto (struct tty_display_info *tty, int row, int col) llcost, relcost, directcost; - int use; - char *p, - *dcm; + int use IF_LINT (= 0); + char *p; + const char *dcm; /* First the degenerate case */ if (row == curY (tty) && col == curX (tty)) /* already there */ @@ -460,4 +460,3 @@ Wcm_init (struct tty_display_info *tty) return - 2; return 0; } - @@ -35,25 +35,25 @@ struct cm int cm_curX; /* Current column */ /* Capabilities from termcap */ - char *cm_up; /* up (up) */ - char *cm_down; /* down (do) */ - char *cm_left; /* left (le) */ - char *cm_right; /* right (nd) */ - char *cm_home; /* home (ho) */ - char *cm_cr; /* carriage return (cr) */ - char *cm_ll; /* last line (ll) */ - char *cm_tab; /* tab (ta) */ - char *cm_backtab; /* backtab (bt) */ + const char *cm_up; /* up (up) */ + const char *cm_down; /* down (do) */ + const char *cm_left; /* left (le) */ + const char *cm_right; /* right (nd) */ + const char *cm_home; /* home (ho) */ + const char *cm_cr; /* carriage return (cr) */ + const char *cm_ll; /* last line (ll) */ + const char *cm_tab; /* tab (ta) */ + const char *cm_backtab; /* backtab (bt) */ char *cm_abs; /* absolute (cm) */ - char *cm_habs; /* horizontal absolute (ch) */ - char *cm_vabs; /* vertical absolute (cv) */ + const char *cm_habs; /* horizontal absolute (ch) */ + const char *cm_vabs; /* vertical absolute (cv) */ #if 0 - char *cm_ds; /* "don't send" string (ds) */ + const char *cm_ds; /* "don't send" string (ds) */ #endif - char *cm_multiup; /* multiple up (UP) */ - char *cm_multidown; /* multiple down (DO) */ - char *cm_multileft; /* multiple left (LE) */ - char *cm_multiright; /* multiple right (RI) */ + const char *cm_multiup; /* multiple up (UP) */ + const char *cm_multidown; /* multiple down (DO) */ + const char *cm_multileft; /* multiple left (LE) */ + const char *cm_multiright; /* multiple right (RI) */ int cm_cols; /* number of cols on screen (co) */ int cm_rows; /* number of rows on screen (li) */ int cm_tabwidth; /* tab width (it) */ @@ -168,4 +168,3 @@ extern void cmcostinit (struct tty_display_info *); extern void cmgoto (struct tty_display_info *, int, int); extern void Wcm_clear (struct tty_display_info *); extern int Wcm_init (struct tty_display_info *); - diff --git a/src/coding.c b/src/coding.c index f6310369ad..9a6a4484e5 100644 --- a/src/coding.c +++ b/src/coding.c @@ -395,8 +395,6 @@ Lisp_Object Vbig5_coding_system; /* Control characters of ISO2022. */ /* code */ /* function */ -#define ISO_CODE_LF 0x0A /* line-feed */ -#define ISO_CODE_CR 0x0D /* carriage-return */ #define ISO_CODE_SO 0x0E /* shift-out */ #define ISO_CODE_SI 0x0F /* shift-in */ #define ISO_CODE_SS2_7 0x19 /* single-shift-2 for 7-bit code */ @@ -479,7 +477,7 @@ enum iso_code_class_type #define CODING_ISO_FLAG_COMPOSITION 0x2000 -#define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 +/* #define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 */ #define CODING_ISO_FLAG_USE_ROMAN 0x8000 @@ -721,25 +719,6 @@ static struct coding_system coding_categories[coding_category_max]; } while (0) -#define ONE_MORE_BYTE_NO_CHECK(c) \ - do { \ - c = *src++; \ - if (multibytep && (c & 0x80)) \ - { \ - if ((c & 0xFE) == 0xC0) \ - c = ((c & 1) << 6) | *src++; \ - else \ - { \ - src--; \ - c = - string_char (src, &src, NULL); \ - record_conversion_result \ - (coding, CODING_RESULT_INVALID_SRC); \ - } \ - } \ - consumed_chars++; \ - } while (0) - - /* Store a byte C in the place pointed by DST and increment DST to the next free point, and increment PRODUCED_CHARS. The caller should assure that C is 0..127, and declare and set the variable `dst' @@ -1051,9 +1030,10 @@ coding_set_source (struct coding_system *coding) coding->source = SDATA (coding->src_object) + coding->src_pos_byte; } else - /* Otherwise, the source is C string and is never relocated - automatically. Thus we don't have to update anything. */ - ; + { + /* Otherwise, the source is C string and is never relocated + automatically. Thus we don't have to update anything. */ + } } static void @@ -1079,9 +1059,10 @@ coding_set_destination (struct coding_system *coding) } } else - /* Otherwise, the destination is C string and is never relocated - automatically. Thus we don't have to update anything. */ - ; + { + /* Otherwise, the destination is C string and is never relocated + automatically. Thus we don't have to update anything. */ + } } @@ -1217,7 +1198,6 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes, #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) -#define UTF_BOM 0xFEFF #define UTF_8_BOM_1 0xEF #define UTF_8_BOM_2 0xBB #define UTF_8_BOM_3 0xBF @@ -1318,7 +1298,7 @@ decode_coding_utf_8 (struct coding_system *coding) int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_8_BOM (coding); Lisp_Object attr, charset_list; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -1379,7 +1359,7 @@ decode_coding_utf_8 (struct coding_system *coding) } else if (UTF_8_1_OCTET_P (c1)) { - if (eol_crlf && c1 == '\r') + if (eol_dos && c1 == '\r') ONE_MORE_BYTE (byte_after_cr); c = c1; } @@ -1533,11 +1513,6 @@ encode_coding_utf_8 (struct coding_system *coding) #define UTF_16_LOW_SURROGATE_P(val) \ (((val) & 0xFC00) == 0xDC00) -#define UTF_16_INVALID_P(val) \ - (((val) == 0xFFFE) \ - || ((val) == 0xFFFF) \ - || UTF_16_LOW_SURROGATE_P (val)) - static int detect_coding_utf_16 (struct coding_system *coding, @@ -1637,7 +1612,7 @@ decode_coding_utf_16 (struct coding_system *coding) enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); int surrogate = CODING_UTF_16_SURROGATE (coding); Lisp_Object attr, charset_list; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr1 = -1, byte_after_cr2 = -1; @@ -1734,7 +1709,7 @@ decode_coding_utf_16 (struct coding_system *coding) CODING_UTF_16_SURROGATE (coding) = surrogate = c; else { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') { ONE_MORE_BYTE (byte_after_cr1); ONE_MORE_BYTE (byte_after_cr2); @@ -1918,17 +1893,17 @@ detect_coding_emacs_mule (struct coding_system *coding, it because analyzing it is too heavy for detecting. But, at least, we check that the composite character constitutes of more than 4 bytes. */ - const unsigned char *src_base; + const unsigned char *src_start; repeat: - src_base = src; + src_start = src; do { ONE_MORE_BYTE (c); } while (c >= 0xA0); - if (src - src_base <= 4) + if (src - src_start <= 4) break; found = CATEGORY_MASK_EMACS_MULE; if (c == 0x80) @@ -1980,7 +1955,7 @@ detect_coding_emacs_mule (struct coding_system *coding, the decoded character or rule. If an invalid byte is found, return -1. If SRC is too short, return -2. */ -int +static int emacs_mule_char (struct coding_system *coding, const unsigned char *src, int *nbytes, int *nchars, int *id, struct composition_status *cmp_status) @@ -1988,7 +1963,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, const unsigned char *src_end = coding->source + coding->src_bytes; const unsigned char *src_base = src; int multibytep = coding->src_multibyte; - int charset_id; + int charset_ID; unsigned code; int c; int consumed_chars = 0; @@ -1998,7 +1973,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, if (c < 0) { c = -c; - charset_id = emacs_mule_charset[0]; + charset_ID = emacs_mule_charset[0]; } else { @@ -2034,7 +2009,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, switch (emacs_mule_bytes[c]) { case 2: - if ((charset_id = emacs_mule_charset[c]) < 0) + if ((charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2047,7 +2022,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, || c == EMACS_MULE_LEADING_CODE_PRIVATE_12) { ONE_MORE_BYTE (c); - if (c < 0xA0 || (charset_id = emacs_mule_charset[c]) < 0) + if (c < 0xA0 || (charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2056,7 +2031,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, } else { - if ((charset_id = emacs_mule_charset[c]) < 0) + if ((charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2071,7 +2046,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, case 4: ONE_MORE_BYTE (c); - if (c < 0 || (charset_id = emacs_mule_charset[c]) < 0) + if (c < 0 || (charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2085,21 +2060,21 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, case 1: code = c; - charset_id = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit; + charset_ID = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit; break; default: abort (); } CODING_DECODE_CHAR (coding, src, src_base, src_end, - CHARSET_FROM_ID (charset_id), code, c); + CHARSET_FROM_ID (charset_ID), code, c); if (c < 0) goto invalid_code; } *nbytes = src - src_base; *nchars = consumed_chars; if (id) - *id = charset_id; + *id = charset_ID; return (mseq_found ? -c : c); no_more_source: @@ -2372,7 +2347,7 @@ decode_coding_emacs_mule (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; @@ -2390,7 +2365,7 @@ decode_coding_emacs_mule (struct coding_system *coding) while (1) { - int c, id; + int c, id IF_LINT (= 0); src_base = src; consumed_chars_base = consumed_chars; @@ -2422,7 +2397,7 @@ decode_coding_emacs_mule (struct coding_system *coding) if (c < 0x80) { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); id = charset_ascii; if (cmp_status->state != COMPOSING_NO) @@ -2435,7 +2410,7 @@ decode_coding_emacs_mule (struct coding_system *coding) } else { - int nchars, nbytes; + int nchars IF_LINT (= 0), nbytes IF_LINT (= 0); /* emacs_mule_char can load a charset map from a file, which allocates a large structure and might cause buffer text to be relocated as result. Thus, we need to remember the @@ -2903,10 +2878,6 @@ enum iso_code_class_type iso_code_class[256]; ((id) <= (coding)->max_charset_id \ && (coding)->safe_charsets[id] != 255) - -#define SHIFT_OUT_OK(category) \ - (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) - static void setup_iso_safe_charsets (Lisp_Object attrs) { @@ -2983,7 +2954,12 @@ detect_coding_iso_2022 (struct coding_system *coding, const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; int single_shifting = 0; - int id; + + /* FIXME: Does ID need to be initialized here? The "End of composition" + code below does not initialize ID even though ID is used + afterwards, and perhaps that is a bug. */ + int id = 0; + int c, c1; int consumed_chars = 0; int i; @@ -3158,7 +3134,7 @@ detect_coding_iso_2022 (struct coding_system *coding, if (! single_shifting && ! (rejected & CATEGORY_MASK_ISO_8_2)) { - int i = 1; + int len = 1; while (src < src_end) { src_base = src; @@ -3168,20 +3144,20 @@ detect_coding_iso_2022 (struct coding_system *coding, src = src_base; break; } - i++; + len++; } - if (i & 1 && src < src_end) + if (len & 1 && src < src_end) { rejected |= CATEGORY_MASK_ISO_8_2; if (composition_count >= 0) - composition_count += i; + composition_count += len; } else { found |= CATEGORY_MASK_ISO_8_2; if (composition_count >= 0) - composition_count += i / 2; + composition_count += len / 2; } } break; @@ -3309,10 +3285,10 @@ detect_coding_iso_2022 (struct coding_system *coding, } \ else /* new format (after ver.21) */ \ { \ - int c; \ + int b; \ \ - ONE_MORE_BYTE (c); \ - rule = COMPOSITION_ENCODE_RULE (rule - 81, c - 32); \ + ONE_MORE_BYTE (b); \ + rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ if (rule >= 0) \ rule += 0x100; /* to destinguish it from the old format */ \ nbytes = 2; \ @@ -3504,7 +3480,7 @@ decode_coding_iso_2022 (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; int i; @@ -3624,7 +3600,7 @@ decode_coding_iso_2022 (struct coding_system *coding) break; case ISO_control_0: - if (eol_crlf && c1 == '\r') + if (eol_dos && c1 == '\r') ONE_MORE_BYTE (byte_after_cr); MAYBE_FINISH_COMPOSITION (); charset = CHARSET_FROM_ID (charset_ascii); @@ -3897,6 +3873,10 @@ decode_coding_iso_2022 (struct coding_system *coding) } continue; } + break; + + default: + abort (); } if (cmp_status->state == COMPOSING_NO @@ -4029,7 +4009,6 @@ decode_coding_iso_2022 (struct coding_system *coding) const char *intermediate_char_94 = "()*+"; \ const char *intermediate_char_96 = ",-./"; \ int revision = -1; \ - int c; \ \ if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION) \ revision = CHARSET_ISO_REVISION (charset); \ @@ -4042,11 +4021,12 @@ decode_coding_iso_2022 (struct coding_system *coding) EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC); \ if (CHARSET_DIMENSION (charset) == 1) \ { \ + int b; \ if (! CHARSET_ISO_CHARS_96 (charset)) \ - c = intermediate_char_94[reg]; \ + b = intermediate_char_94[reg]; \ else \ - c = intermediate_char_96[reg]; \ - EMIT_ONE_ASCII_BYTE (c); \ + b = intermediate_char_96[reg]; \ + EMIT_ONE_ASCII_BYTE (b); \ } \ else \ { \ @@ -4226,7 +4206,7 @@ decode_coding_iso_2022 (struct coding_system *coding) to use CHARSET. The element `spec.iso_2022' of *CODING is updated. Return new DST. */ -unsigned char * +static unsigned char * encode_invocation_designation (struct charset *charset, struct coding_system *coding, unsigned char *dst, int *p_nchars) @@ -4289,30 +4269,6 @@ encode_invocation_designation (struct charset *charset, return dst; } -/* The following three macros produce codes for indicating direction - of text. */ -#define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ - do { \ - if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS) \ - EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '['); \ - else \ - EMIT_ONE_BYTE (ISO_CODE_CSI); \ - } while (0) - - -#define ENCODE_DIRECTION_R2L() \ - do { \ - ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ - EMIT_TWO_ASCII_BYTES ('2', ']'); \ - } while (0) - - -#define ENCODE_DIRECTION_L2R() \ - do { \ - ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ - EMIT_TWO_ASCII_BYTES ('0', ']'); \ - } while (0) - /* Produce codes for designation and invocation to reset the graphic planes and registers to initial state. */ @@ -4707,7 +4663,7 @@ decode_coding_sjis (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -4742,7 +4698,7 @@ decode_coding_sjis (struct coding_system *coding) goto invalid_code; if (c < 0x80) { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); charset = charset_roman; } @@ -4824,7 +4780,7 @@ decode_coding_big5 (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -4857,7 +4813,7 @@ decode_coding_big5 (struct coding_system *coding) goto invalid_code; if (c < 0x80) { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); charset = charset_roman; } @@ -5261,13 +5217,13 @@ encode_coding_ccl (struct coding_system *coding) static void decode_coding_raw_text (struct coding_system *coding) { - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); coding->chars_at_source = 1; coding->consumed_char = coding->src_chars; coding->consumed = coding->src_bytes; - if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r') + if (eol_dos && coding->source[coding->src_bytes - 1] == '\r') { coding->consumed_char--; coding->consumed--; @@ -5480,7 +5436,7 @@ decode_coding_charset (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -5514,7 +5470,7 @@ decode_coding_charset (struct coding_system *coding) else { ONE_MORE_BYTE (c); - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); } if (c < 0) @@ -6607,15 +6563,15 @@ get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) } else if (CONSP (translation_table)) { - Lisp_Object tail, val; + Lisp_Object tail; for (tail = translation_table; CONSP (tail); tail = XCDR (tail)) if (CHAR_TABLE_P (XCAR (tail)) && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1) { - val = XCHAR_TABLE (XCAR (tail))->extras[1]; - if (NATNUMP (val) && *max_lookup < XFASTINT (val)) - *max_lookup = XFASTINT (val); + Lisp_Object tailval = XCHAR_TABLE (XCAR (tail))->extras[1]; + if (NATNUMP (tailval) && *max_lookup < XFASTINT (tailval)) + *max_lookup = XFASTINT (tailval); } } } @@ -7652,12 +7608,12 @@ decode_coding_object (struct coding_system *coding, Lisp_Object dst_object) { int count = SPECPDL_INDEX (); - unsigned char *destination; - EMACS_INT dst_bytes; + unsigned char *destination IF_LINT (= NULL); + EMACS_INT dst_bytes IF_LINT (= 0); EMACS_INT chars = to - from; EMACS_INT bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte; + int saved_pt = -1, saved_pt_byte IF_LINT (= 0); int need_marker_adjustment = 0; Lisp_Object old_deactivate_mark; @@ -7845,7 +7801,7 @@ encode_coding_object (struct coding_system *coding, EMACS_INT chars = to - from; EMACS_INT bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte; + int saved_pt = -1, saved_pt_byte IF_LINT (= 0); int need_marker_adjustment = 0; int kill_src_buffer = 0; Lisp_Object old_deactivate_mark; @@ -8178,8 +8134,8 @@ detect_coding_system (const unsigned char *src, base_category = XINT (CODING_ATTR_CATEGORY (attrs)); if (base_category == coding_category_undecided) { - enum coding_category category; - struct coding_system *this; + enum coding_category category IF_LINT (= 0); + struct coding_system *this IF_LINT (= NULL); int c, i; /* Skip all ASCII bytes except for a few ISO2022 controls. */ @@ -9112,10 +9068,10 @@ Return the corresponding character. */) } else { - int s1 = c >> 8, s2 = c & 0xFF; + int c1 = c >> 8, c2 = c & 0xFF; - if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF - || s2 < 0x40 || s2 == 0x7F || s2 > 0xFC) + if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF + || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) error ("Invalid code: %d", code); SJIS_TO_JIS (c); charset = charset_kanji; @@ -9798,7 +9754,6 @@ usage: (define-coding-system-internal ...) */) else if (EQ (coding_type, Qiso_2022)) { Lisp_Object initial, reg_usage, request, flags; - int i; if (nargs < coding_arg_iso2022_max) goto short_args; @@ -9830,12 +9785,12 @@ usage: (define-coding-system-internal ...) */) for (tail = request; ! NILP (tail); tail = Fcdr (tail)) { int id; - Lisp_Object tmp; + Lisp_Object tmp1; val = Fcar (tail); CHECK_CONS (val); - tmp = XCAR (val); - CHECK_CHARSET_GET_ID (tmp, id); + tmp1 = XCAR (val); + CHECK_CHARSET_GET_ID (tmp1, id); CHECK_NATNUM_CDR (val); if (XINT (XCDR (val)) >= 4) error ("Invalid graphic register number: %d", XINT (XCDR (val))); diff --git a/src/config.in b/src/config.in index 8889213b78..fbd3ee9338 100644 --- a/src/config.in +++ b/src/config.in @@ -1206,6 +1206,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ # define __restrict__ #endif +/* Define to `unsigned int' if <sys/types.h> does not define. */ +#undef size_t + /* Define to any substitute for sys_siglist. */ #undef sys_siglist diff --git a/src/deps.mk b/src/deps.mk index 77994bcaad..2b162b07bb 100644 --- a/src/deps.mk +++ b/src/deps.mk @@ -190,13 +190,13 @@ sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ term.o: term.c termchar.h termhooks.h termopts.h lisp.h globals.h $(config_h) \ cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \ xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \ - systty.h syssignal.h $(INTERVALS_H) buffer.h ../lib/unistd.h + systty.h syssignal.h tparam.h $(INTERVALS_H) buffer.h ../lib/unistd.h termcap.o: termcap.c lisp.h $(config_h) terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \ keyboard.h lisp.h globals.h $(config_h) dispextern.h composite.h systime.h \ msdos.h terminfo.o: terminfo.c lisp.h globals.h $(config_h) -tparam.o: tparam.c lisp.h $(config_h) +tparam.o: tparam.c tparam.h lisp.h $(config_h) undo.o: undo.c buffer.h commands.h window.h dispextern.h msdos.h \ lisp.h globals.h $(config_h) unexaix.o: unexaix.c lisp.h $(config_h) diff --git a/src/dispextern.h b/src/dispextern.h index 37ae7ee5fd..9843dfd1fc 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2944,6 +2944,7 @@ enum tool_bar_item_image extern void bidi_init_it (EMACS_INT, EMACS_INT, struct bidi_it *); extern void bidi_move_to_visually_next (struct bidi_it *); +extern void bidi_dump_cached_states (void); extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *, int); extern int bidi_mirror_char (int); @@ -3325,9 +3326,10 @@ extern struct terminal *init_tty (const char *, const char *, int); extern int scrolling_max_lines_saved (int, int, int *, int *, int *); extern int scroll_cost (struct frame *, int, int, int); -extern void do_line_insertion_deletion_costs (struct frame *, char *, - char *, char *, char *, - char *, char *, int); +extern void do_line_insertion_deletion_costs (struct frame *, const char *, + const char *, const char *, + const char *, const char *, + const char *, int); void scrolling_1 (struct frame *, int, int, int, int *, int *, int *, int *, int); diff --git a/src/fontset.c b/src/fontset.c index f297fd10a7..b5d8a0db43 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -233,14 +233,14 @@ fontset_id_valid_p (int id) /* Macros to access special values of (base) FONTSET. */ #define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1] #define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4] -#define FONTSET_SPEC(fontset) XCHAR_TABLE (fontset)->extras[5] +/* #define FONTSET_SPEC(fontset) XCHAR_TABLE (fontset)->extras[5] */ /* Macros to access special values of (realized) FONTSET. */ #define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2] #define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3] #define FONTSET_OBJLIST(fontset) XCHAR_TABLE (fontset)->extras[4] #define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5] -#define FONTSET_REPERTORY(fontset) XCHAR_TABLE (fontset)->extras[6] +/* #define FONTSET_REPERTORY(fontset) XCHAR_TABLE (fontset)->extras[6] */ #define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7] /* For both base and realized fontset. */ @@ -266,7 +266,6 @@ fontset_id_valid_p (int id) ASET ((rfont_def), 0, make_number (face_id)) #define RFONT_DEF_FONT_DEF(rfont_def) AREF (rfont_def, 1) #define RFONT_DEF_SPEC(rfont_def) FONT_DEF_SPEC (AREF (rfont_def, 1)) -#define RFONT_DEF_REPERTORY(rfont_def) FONT_DEF_REPERTORY (AREF (rfont_def, 1)) #define RFONT_DEF_OBJECT(rfont_def) AREF (rfont_def, 2) #define RFONT_DEF_SET_OBJECT(rfont_def, object) \ ASET ((rfont_def), 2, (object)) @@ -713,7 +712,7 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fa static Lisp_Object fontset_font (Lisp_Object fontset, int c, struct face *face, int id) { - Lisp_Object rfont_def, default_rfont_def; + Lisp_Object rfont_def, default_rfont_def IF_LINT (= Qnil); Lisp_Object base_fontset; /* Try a font-group of FONTSET. */ @@ -836,7 +835,7 @@ fontset_ascii (int id) return elt; } -void +static void free_realized_fontset (FRAME_PTR f, Lisp_Object fontset) { Lisp_Object tail; @@ -1583,14 +1582,14 @@ appended. By default, FONT-SPEC overrides the previous settings. */) if (ascii_changed) { - Lisp_Object tail, frame, alist; + Lisp_Object tail, fr, alist; int fontset_id = XINT (FONTSET_ID (fontset)); FONTSET_ASCII (fontset) = fontname; name = FONTSET_NAME (fontset); - FOR_EACH_FRAME (tail, frame) + FOR_EACH_FRAME (tail, fr) { - FRAME_PTR f = XFRAME (frame); + FRAME_PTR f = XFRAME (fr); Lisp_Object font_object; struct face *face; @@ -1607,7 +1606,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */) { update_auto_fontset_alist (font_object, fontset); alist = Fcons (Fcons (Qfont, Fcons (name, font_object)), Qnil); - Fmodify_frame_parameters (frame, alist); + Fmodify_frame_parameters (fr, alist); } } } diff --git a/src/fringe.c b/src/fringe.c index d42d6467f3..82fc38aee8 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -913,7 +913,12 @@ update_window_fringes (struct window *w, int keep_current_p) int bitmap_cache[MAX_BITMAP_CACHE]; int top_ind_rn, bot_ind_rn; int top_ind_min_y, bot_ind_max_y; - int top_row_ends_at_zv_p, bot_row_ends_at_zv_p; + + /* top_ind_rn is set to a nonnegative value whenver + row->indicate_bob_p is set, so it's OK that top_row_ends_at_zv_p + is not initialized here. Similarly for bot_ind_rn, + row->indicate_eob_p and bot_row_ends_at_zv_p. */ + int top_row_ends_at_zv_p IF_LINT (= 0), bot_row_ends_at_zv_p IF_LINT (= 0); if (w->pseudo_window_p) return 0; @@ -1380,7 +1385,7 @@ compute_fringe_widths (struct frame *f, int redraw) /* Free resources used by a user-defined bitmap. */ -void +static void destroy_fringe_bitmap (int n) { struct fringe_bitmap **fbp; @@ -1448,7 +1453,7 @@ static const unsigned char swap_nibble[16] = { 0x3, 0xb, 0x7, 0xf}; /* 0011 1011 0111 1111 */ #endif /* HAVE_X_WINDOWS */ -void +static void init_fringe_bitmap (int which, struct fringe_bitmap *fb, int once_p) { if (once_p || fb->dynamic) @@ -1831,4 +1836,3 @@ w32_reset_fringes (void) #endif /* HAVE_NTGUI */ #endif /* HAVE_WINDOW_SYSTEM */ - diff --git a/src/lisp.h b/src/lisp.h index e38d6a8ec3..113585320a 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2150,12 +2150,15 @@ struct gcpro || GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS) +#define GCPRO1(varname) GCPRO1_VAR (varname, gcpro1) +#define UNGCPRO UNGCPRO_VAR (gcpro1) + #if GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS /* Do something silly with gcproN vars just so gcc shuts up. */ /* You get warnings from MIPSPro... */ -#define GCPRO1(varname) ((void) gcpro1) +#define GCPRO1_VAR(varname, gcpro1) ((void) gcpro1) #define GCPRO2(varname1, varname2)(((void) gcpro2, (void) gcpro1)) #define GCPRO3(varname1, varname2, varname3) \ (((void) gcpro3, (void) gcpro2, (void) gcpro1)) @@ -2165,13 +2168,13 @@ struct gcpro (((void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1)) #define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \ (((void) gcpro6, (void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1)) -#define UNGCPRO ((void) 0) +#define UNGCPRO_VAR(gcpro1) ((void) 0) #else /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */ #ifndef DEBUG_GCPRO -#define GCPRO1(varname) \ +#define GCPRO1_VAR(varname, gcpro1) \ {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \ gcprolist = &gcpro1; } @@ -2210,13 +2213,13 @@ struct gcpro gcpro6.next = &gcpro5; gcpro6.var = &varname6; gcpro6.nvars = 1; \ gcprolist = &gcpro6; } -#define UNGCPRO (gcprolist = gcpro1.next) +#define UNGCPRO_VAR(gcpro1) (gcprolist = gcpro1.next) #else extern int gcpro_level; -#define GCPRO1(varname) \ +#define GCPRO1_VAR(varname, gcpro1) \ {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \ gcpro1.level = gcpro_level++; \ gcprolist = &gcpro1; } @@ -2266,7 +2269,7 @@ extern int gcpro_level; gcpro6.level = gcpro_level++; \ gcprolist = &gcpro6; } -#define UNGCPRO \ +#define UNGCPRO_VAR(gcpro1) \ ((--gcpro_level != gcpro1.level) \ ? (abort (), 0) \ : ((gcprolist = gcpro1.next), 0)) @@ -2537,7 +2540,10 @@ extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y); /* Defined in fringe.c */ extern void syms_of_fringe (void); extern void init_fringe (void); +#ifdef HAVE_WINDOW_SYSTEM +extern void mark_fringe_data (void); extern void init_fringe_once (void); +#endif /* HAVE_WINDOW_SYSTEM */ /* Defined in image.c */ extern Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data; @@ -3378,6 +3384,7 @@ extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, /* Defined in term.c */ extern int *char_ins_del_vector; +extern void mark_ttys (void); extern void syms_of_term (void); extern void fatal (const char *msgid, ...) NO_RETURN; @@ -3524,6 +3531,13 @@ extern void init_system_name (void); && (circular_list_error ((list)), 1))) \ : 0))) +/* Use this to suppress gcc's `...may be used before initialized' warnings. */ +#ifdef lint +# define IF_LINT(Code) Code +#else +# define IF_LINT(Code) /* empty */ +#endif + /* The ubiquitous min and max macros. */ #ifdef max diff --git a/src/scroll.c b/src/scroll.c index 1343b89c41..33af18d209 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -938,8 +938,8 @@ line_ins_del (FRAME_PTR frame, int ov1, int pf1, int ovn, int pfn, register int static void ins_del_costs (FRAME_PTR frame, - char *one_line_string, char *multi_string, - char *setup_string, char *cleanup_string, + const char *one_line_string, const char *multi_string, + const char *setup_string, const char *cleanup_string, int *costvec, int *ncostvec, int coefficient) { @@ -994,9 +994,12 @@ ins_del_costs (FRAME_PTR frame, void do_line_insertion_deletion_costs (FRAME_PTR frame, - char *ins_line_string, char *multi_ins_string, - char *del_line_string, char *multi_del_string, - char *setup_string, char *cleanup_string, + const char *ins_line_string, + const char *multi_ins_string, + const char *del_line_string, + const char *multi_del_string, + const char *setup_string, + const char *cleanup_string, int coefficient) { if (FRAME_INSERT_COST (frame) != 0) diff --git a/src/term.c b/src/term.c index f082bb40e8..e78e2e6881 100644 --- a/src/term.c +++ b/src/term.c @@ -32,6 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "lisp.h" #include "termchar.h" #include "termopts.h" +#include "tparam.h" #include "buffer.h" #include "character.h" #include "charset.h" @@ -53,18 +54,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ static int been_here = -1; #endif -/* For now, don't try to include termcap.h. On some systems, - configure finds a non-standard termcap.h that the main build - won't find. */ -extern void tputs (const char *, int, int (*)(int)); -extern int tgetent (char *, const char *); -extern int tgetflag (char *id); -extern int tgetnum (char *id); - -char *tparam (char *, char *, int, int, ...); - -extern char *tgetstr (char *, char **); - #include "cm.h" #ifdef HAVE_X_WINDOWS #include "xterm.h" @@ -262,7 +251,7 @@ tty_set_scroll_region (struct frame *f, int start, int stop) struct tty_display_info *tty = FRAME_TTY (f); if (tty->TS_set_scroll_region) - buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1); + buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1, 0, 0); else if (tty->TS_set_scroll_region_1) buf = tparam (tty->TS_set_scroll_region_1, 0, 0, FRAME_LINES (f), start, @@ -512,7 +501,7 @@ static int encode_terminal_dst_size; Set CODING->produced to the byte-length of the resulting byte sequence, and return a pointer to that byte sequence. */ -unsigned char * +static unsigned char * encode_terminal_code (struct glyph *src, int src_len, struct coding_system *coding) { struct glyph *src_end = src + src_len; @@ -544,8 +533,8 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi { if (src->type == COMPOSITE_GLYPH) { - struct composition *cmp; - Lisp_Object gstring; + struct composition *cmp IF_LINT (= NULL); + Lisp_Object gstring IF_LINT (= Qnil); int i; nbytes = buf - encode_terminal_src; @@ -606,7 +595,7 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi else if (! CHAR_GLYPH_PADDING_P (*src)) { GLYPH g; - int c; + int c IF_LINT (= 0); Lisp_Object string; string = Qnil; @@ -664,8 +653,6 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi } else { - unsigned char *p = SDATA (string); - if (! STRING_MULTIBYTE (string)) string = string_to_multibyte (string); nbytes = buf - encode_terminal_src; @@ -861,7 +848,7 @@ tty_insert_glyphs (struct frame *f, struct glyph *start, int len) if (tty->TS_ins_multi_chars) { - buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); + buf = tparam (tty->TS_ins_multi_chars, 0, 0, len, 0, 0, 0); OUTPUT1 (tty, buf); xfree (buf); if (start) @@ -957,7 +944,7 @@ tty_delete_glyphs (struct frame *f, int n) if (tty->TS_del_multi_chars) { - buf = tparam (tty->TS_del_multi_chars, 0, 0, n); + buf = tparam (tty->TS_del_multi_chars, 0, 0, n, 0, 0, 0); OUTPUT1 (tty, buf); xfree (buf); } @@ -974,9 +961,10 @@ static void tty_ins_del_lines (struct frame *f, int vpos, int n) { struct tty_display_info *tty = FRAME_TTY (f); - char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; - char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; - char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; + const char *multi = + n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; + const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; + const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; register int i = n > 0 ? n : -n; register char *buf; @@ -999,7 +987,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n) { raw_cursor_to (f, vpos, 0); tty_background_highlight (tty); - buf = tparam (multi, 0, 0, i); + buf = tparam (multi, 0, 0, i, 0, 0, 0); OUTPUT (tty, buf); xfree (buf); } @@ -1151,9 +1139,9 @@ calculate_costs (struct frame *frame) if (FRAME_TERMCAP_P (frame)) { struct tty_display_info *tty = FRAME_TTY (frame); - register char *f = (tty->TS_set_scroll_region - ? tty->TS_set_scroll_region - : tty->TS_set_scroll_region_1); + register const char *f = (tty->TS_set_scroll_region + ? tty->TS_set_scroll_region + : tty->TS_set_scroll_region_1); FRAME_SCROLL_REGION_COST (frame) = string_cost (f); @@ -1207,7 +1195,7 @@ calculate_costs (struct frame *frame) } struct fkey_table { - char *cap, *name; + const char *cap, *name; }; /* Termcap capability names that correspond directly to X keysyms. @@ -1365,9 +1353,9 @@ term_get_fkeys_1 (void) "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. */ { - char *k_semi = tgetstr ("k;", address); - char *k0 = tgetstr ("k0", address); - char *k0_name = "f10"; + const char *k_semi = tgetstr ("k;", address); + const char *k0 = tgetstr ("k0", address); + const char *k0_name = "f10"; if (k_semi) { @@ -1460,7 +1448,7 @@ static void append_glyph (struct it *); static void produce_stretch_glyph (struct it *); static void append_composite_glyph (struct it *); static void produce_composite_glyph (struct it *); -static void append_glyphless_glyph (struct it *, int, char *); +static void append_glyphless_glyph (struct it *, int, const char *); static void produce_glyphless_glyph (struct it *, int, Lisp_Object); /* Append glyphs to IT's glyph_row. Called from produce_glyphs for @@ -1828,7 +1816,7 @@ produce_composite_glyph (struct it *it) comes from it->nglyphs bytes). */ static void -append_glyphless_glyph (struct it *it, int face_id, char *str) +append_glyphless_glyph (struct it *it, int face_id, const char *str) { struct glyph *glyph, *end; int i; @@ -1903,7 +1891,8 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) { int face_id; int len; - char buf[9], *str = " "; + char buf[9]; + char const *str = " "; /* Get a face ID for the glyph by utilizing a cache (the same way as done for `escape-glyph' in get_next_display_element). */ @@ -2122,12 +2111,13 @@ turn_on_face (struct frame *f, int face_id) if (tty->TN_max_colors > 0) { - char *ts, *p; + const char *ts; + char *p; ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; if (fg >= 0 && ts) { - p = tparam (ts, NULL, 0, (int) fg); + p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); OUTPUT (tty, p); xfree (p); } @@ -2135,7 +2125,7 @@ turn_on_face (struct frame *f, int face_id) ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; if (bg >= 0 && ts) { - p = tparam (ts, NULL, 0, (int) bg); + p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); OUTPUT (tty, p); xfree (p); } @@ -2698,14 +2688,14 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) Set *bar_window to Qnil, and *x and *y to the column and row of the character cell the mouse is over. - Set *time to the time the mouse was at the returned position. + Set *timeptr to the time the mouse was at the returned position. This clears mouse_moved until the next motion event arrives. */ static void term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, - Lisp_Object *y, unsigned long *time) + Lisp_Object *y, unsigned long *timeptr) { struct timeval now; @@ -2718,7 +2708,7 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, XSETINT (*x, last_mouse_x); XSETINT (*y, last_mouse_y); gettimeofday(&now, 0); - *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); + *timeptr = (now.tv_sec * 1000) + (now.tv_usec / 1000); } /* Prepare a mouse-event in *RESULT for placement in the input queue. @@ -3532,10 +3522,10 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ If it were in the termcap entry, it would confuse other programs. */ if (!tty->TS_set_window) { - p = tty->TS_termcap_modes; - while (*p && strcmp (p, "\033v ")) - p++; - if (*p) + const char *m = tty->TS_termcap_modes; + while (*m && strcmp (m, "\033v ")) + m++; + if (*m) tty->TS_set_window = "\033v%C %C %C %C "; } /* Termcap entry often fails to have :in: flag */ diff --git a/src/termchar.h b/src/termchar.h index 277a96932b..035974a8ce 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -84,58 +84,58 @@ struct tty_display_info /* Strings, numbers and flags taken from the termcap entry. */ - char *TS_ins_line; /* "al" */ - char *TS_ins_multi_lines; /* "AL" (one parameter, # lines to insert) */ - char *TS_bell; /* "bl" */ - char *TS_clr_to_bottom; /* "cd" */ - char *TS_clr_line; /* "ce", clear to end of line */ - char *TS_clr_frame; /* "cl" */ - char *TS_set_scroll_region; /* "cs" (2 params, first line and last line) */ - char *TS_set_scroll_region_1; /* "cS" (4 params: total lines, + const char *TS_ins_line; /* "al" */ + const char *TS_ins_multi_lines; /* "AL" (one parameter, # lines to insert) */ + const char *TS_bell; /* "bl" */ + const char *TS_clr_to_bottom; /* "cd" */ + const char *TS_clr_line; /* "ce", clear to end of line */ + const char *TS_clr_frame; /* "cl" */ + const char *TS_set_scroll_region; /* "cs" (2 params, first line and last line) */ + const char *TS_set_scroll_region_1; /* "cS" (4 params: total lines, lines above scroll region, lines below it, total lines again) */ - char *TS_del_char; /* "dc" */ - char *TS_del_multi_chars; /* "DC" (one parameter, # chars to delete) */ - char *TS_del_line; /* "dl" */ - char *TS_del_multi_lines; /* "DL" (one parameter, # lines to delete) */ - char *TS_delete_mode; /* "dm", enter character-delete mode */ - char *TS_end_delete_mode; /* "ed", leave character-delete mode */ - char *TS_end_insert_mode; /* "ei", leave character-insert mode */ - char *TS_ins_char; /* "ic" */ - char *TS_ins_multi_chars; /* "IC" (one parameter, # chars to insert) */ - char *TS_insert_mode; /* "im", enter character-insert mode */ - char *TS_pad_inserted_char; /* "ip". Just padding, no commands. */ - char *TS_end_keypad_mode; /* "ke" */ - char *TS_keypad_mode; /* "ks" */ - char *TS_pad_char; /* "pc", char to use as padding */ - char *TS_repeat; /* "rp" (2 params, # times to repeat + const char *TS_del_char; /* "dc" */ + const char *TS_del_multi_chars; /* "DC" (one parameter, # chars to delete) */ + const char *TS_del_line; /* "dl" */ + const char *TS_del_multi_lines; /* "DL" (one parameter, # lines to delete) */ + const char *TS_delete_mode; /* "dm", enter character-delete mode */ + const char *TS_end_delete_mode; /* "ed", leave character-delete mode */ + const char *TS_end_insert_mode; /* "ei", leave character-insert mode */ + const char *TS_ins_char; /* "ic" */ + const char *TS_ins_multi_chars; /* "IC" (one parameter, # chars to insert) */ + const char *TS_insert_mode; /* "im", enter character-insert mode */ + const char *TS_pad_inserted_char; /* "ip". Just padding, no commands. */ + const char *TS_end_keypad_mode; /* "ke" */ + const char *TS_keypad_mode; /* "ks" */ + const char *TS_pad_char; /* "pc", char to use as padding */ + const char *TS_repeat; /* "rp" (2 params, # times to repeat and character to be repeated) */ - char *TS_end_standout_mode; /* "se" */ - char *TS_fwd_scroll; /* "sf" */ - char *TS_standout_mode; /* "so" */ - char *TS_rev_scroll; /* "sr" */ - char *TS_end_termcap_modes; /* "te" */ - char *TS_termcap_modes; /* "ti" */ - char *TS_visible_bell; /* "vb" */ - char *TS_cursor_normal; /* "ve" */ - char *TS_cursor_visible; /* "vs" */ - char *TS_cursor_invisible; /* "vi" */ - char *TS_set_window; /* "wi" (4 params, start and end of window, + const char *TS_end_standout_mode; /* "se" */ + const char *TS_fwd_scroll; /* "sf" */ + const char *TS_standout_mode; /* "so" */ + const char *TS_rev_scroll; /* "sr" */ + const char *TS_end_termcap_modes; /* "te" */ + const char *TS_termcap_modes; /* "ti" */ + const char *TS_visible_bell; /* "vb" */ + const char *TS_cursor_normal; /* "ve" */ + const char *TS_cursor_visible; /* "vs" */ + const char *TS_cursor_invisible; /* "vi" */ + const char *TS_set_window; /* "wi" (4 params, start and end of window, each as vpos and hpos) */ - char *TS_enter_bold_mode; /* "md" -- turn on bold (extra bright mode). */ - char *TS_enter_dim_mode; /* "mh" -- turn on half-bright mode. */ - char *TS_enter_blink_mode; /* "mb" -- enter blinking mode. */ - char *TS_enter_reverse_mode; /* "mr" -- enter reverse video mode. */ - char *TS_exit_underline_mode; /* "us" -- start underlining. */ - char *TS_enter_underline_mode; /* "ue" -- end underlining. */ + const char *TS_enter_bold_mode; /* "md" -- turn on bold (extra bright mode). */ + const char *TS_enter_dim_mode; /* "mh" -- turn on half-bright mode. */ + const char *TS_enter_blink_mode; /* "mb" -- enter blinking mode. */ + const char *TS_enter_reverse_mode; /* "mr" -- enter reverse video mode. */ + const char *TS_exit_underline_mode; /* "us" -- start underlining. */ + const char *TS_enter_underline_mode; /* "ue" -- end underlining. */ /* "as"/"ae" -- start/end alternate character set. Not really supported, yet. */ - char *TS_enter_alt_charset_mode; - char *TS_exit_alt_charset_mode; + const char *TS_enter_alt_charset_mode; + const char *TS_exit_alt_charset_mode; - char *TS_exit_attribute_mode; /* "me" -- switch appearances off. */ + const char *TS_exit_attribute_mode; /* "me" -- switch appearances off. */ /* Value of the "NC" (no_color_video) capability, or 0 if not present. */ int TN_no_color_video; @@ -147,12 +147,12 @@ struct tty_display_info int TN_max_pairs; /* "op" -- SVr4 set default pair to its original value. */ - char *TS_orig_pair; + const char *TS_orig_pair; /* "AF"/"AB" or "Sf"/"Sb"-- set ANSI or SVr4 foreground/background color. 1 param, the color index. */ - char *TS_set_foreground; - char *TS_set_background; + const char *TS_set_foreground; + const char *TS_set_background; int TF_hazeltine; /* termcap hz flag. */ int TF_insmode_motion; /* termcap mi flag: can move while in insert mode. */ @@ -210,4 +210,3 @@ extern struct tty_display_info *tty_list; : (abort(), (struct tty_display_info *) 0)) #define CURTTY() FRAME_TTY (SELECTED_FRAME()) - diff --git a/src/terminal.c b/src/terminal.c index 309cc0095e..c5185601fb 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -109,7 +109,7 @@ void raw_cursor_to (struct frame *f, int row, int col) { if (FRAME_TERMINAL (f)->raw_cursor_to_hook) - (*FRAME_TERMINAL (f)->raw_cursor_to_hook) (f, row, col); + (*FRAME_TERMINAL (f)->raw_cursor_to_hook) (f, row, col); } /* Erase operations */ @@ -444,7 +444,7 @@ selected frame's terminal). */) /* Set the value of terminal parameter PARAMETER in terminal D to VALUE. Return the previous value. */ -Lisp_Object +static Lisp_Object store_terminal_param (struct terminal *t, Lisp_Object parameter, Lisp_Object value) { Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist); @@ -569,4 +569,3 @@ or some time later. */); Fprovide (intern_c_string ("multi-tty"), Qnil); } - diff --git a/src/tparam.c b/src/tparam.c index fcbb63881e..6aae0b97db 100644 --- a/src/tparam.c +++ b/src/tparam.c @@ -21,6 +21,7 @@ Boston, MA 02110-1301, USA. */ #include <config.h> #include <setjmp.h> #include "lisp.h" /* for xmalloc */ +#include "tparam.h" #ifndef NULL #define NULL (char *) 0 @@ -38,11 +39,12 @@ Boston, MA 02110-1301, USA. */ The fourth and following args to tparam serve as the parameter values. */ -static char *tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp); +static char *tparam1 (char const *string, char *outstring, int len, + char *up, char *left, int *argp); -/* VARARGS 2 */ char * -tparam (char *string, char *outstring, int len, int arg0, int arg1, int arg2, int arg3) +tparam (const char *string, char *outstring, int len, + int arg0, int arg1, int arg2, int arg3) { int arg[4]; @@ -59,7 +61,7 @@ char *UP; static char tgoto_buf[50]; char * -tgoto (char *cm, int hpos, int vpos) +tgoto (const char *cm, int hpos, int vpos) { int args[2]; if (!cm) @@ -70,10 +72,11 @@ tgoto (char *cm, int hpos, int vpos) } static char * -tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp) +tparam1 (const char *string, char *outstring, int len, + char *up, char *left, register int *argp) { register int c; - register char *p = string; + register const char *p = string; register char *op = outstring; char *outend; int outlen = 0; @@ -277,4 +280,3 @@ main (argc, argv) } #endif /* DEBUG */ - diff --git a/src/tparam.h b/src/tparam.h new file mode 100644 index 0000000000..3cd3e6053c --- /dev/null +++ b/src/tparam.h @@ -0,0 +1,31 @@ +/* Interface definitions for termcap entries. + +Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + + +/* Don't try to include termcap.h. On some systems, configure finds a + non-standard termcap.h that the main build won't find. */ + +void tputs (const char *, int, int (*) (int)); +int tgetent (char *, const char *); +int tgetflag (const char *); +int tgetnum (const char *); +char *tgetstr (const char *, char **); +char *tgoto (const char *, int, int); + +char *tparam (const char *, char *, int, int, int, int, int); diff --git a/src/window.c b/src/window.c index 7c55be972b..eaa910571e 100644 --- a/src/window.c +++ b/src/window.c @@ -2209,13 +2209,13 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame case DELETE_BUFFER_WINDOWS: if (EQ (w->buffer, obj)) { - struct frame *f = XFRAME (WINDOW_FRAME (w)); + struct frame *fr = XFRAME (WINDOW_FRAME (w)); /* If this window is dedicated, and in a frame of its own, kill the frame. */ - if (EQ (window, FRAME_ROOT_WINDOW (f)) + if (EQ (window, FRAME_ROOT_WINDOW (fr)) && !NILP (w->dedicated) - && other_visible_frames (f)) + && other_visible_frames (fr)) { /* Skip the other windows on this frame. There might be one, the minibuffer! */ @@ -2267,16 +2267,16 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame if (EQ (w->buffer, obj)) { Lisp_Object buffer; - struct frame *f = XFRAME (w->frame); + struct frame *fr = XFRAME (w->frame); /* Find another buffer to show in this window. */ buffer = Fother_buffer (obj, Qnil, w->frame); /* If this window is dedicated, and in a frame of its own, kill the frame. */ - if (EQ (window, FRAME_ROOT_WINDOW (f)) + if (EQ (window, FRAME_ROOT_WINDOW (fr)) && !NILP (w->dedicated) - && other_visible_frames (f)) + && other_visible_frames (fr)) { /* Skip the other windows on this frame. There might be one, the minibuffer! */ @@ -2290,11 +2290,11 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame } else if (!NILP (w->dedicated) && !NILP (w->parent)) { - Lisp_Object window; - XSETWINDOW (window, w); + Lisp_Object window_to_delete; + XSETWINDOW (window_to_delete, w); /* If this window is dedicated and not the only window in its frame, then kill it. */ - Fdelete_window (window); + Fdelete_window (window_to_delete); } else { @@ -3124,7 +3124,7 @@ size_window (Lisp_Object window, int size, int width_p, int nodelete_p, int firs } else if (!NILP (*forward)) { - int fixed_size, each, extra, n; + int fixed_size, each IF_LINT (= 0), extra IF_LINT (= 0), n; int resize_fixed_p, nfixed; int last_pos, first_pos, nchildren, total; int *new_sizes = NULL; @@ -3170,11 +3170,11 @@ size_window (Lisp_Object window, int size, int width_p, int nodelete_p, int firs last_pos = first_pos; for (n = 0, child = *forward; !NILP (child); child = c->next, ++n) { - int new_size, old_size; + int new_child_size, old_child_size; c = XWINDOW (child); - old_size = WINDOW_TOTAL_SIZE (c, width_p); - new_size = old_size; + old_child_size = WINDOW_TOTAL_SIZE (c, width_p); + new_child_size = old_child_size; /* The top or left edge position of this child equals the bottom or right edge of its predecessor. */ @@ -3186,18 +3186,20 @@ size_window (Lisp_Object window, int size, int width_p, int nodelete_p, int firs /* If this child can be resized, do it. */ if (resize_fixed_p || !window_fixed_size_p (c, width_p, 0)) { - new_size = new_sizes ? new_sizes[n] : old_size + each + extra; + new_child_size = + new_sizes ? new_sizes[n] : old_child_size + each + extra; extra = 0; } /* Set new size. Note that size_window also propagates edge positions to children, so it's not a no-op if we didn't change the child's size. */ - size_window (child, new_size, width_p, 1, first_only, last_only); + size_window (child, new_child_size, width_p, 1, + first_only, last_only); /* Remember the bottom/right edge position of this child; it will be used to set the top/left edge of the next child. */ - last_pos += new_size; + last_pos += new_child_size; } xfree (new_sizes); @@ -3325,12 +3327,12 @@ run_window_configuration_change_hook (struct frame *f) if (!NILP (Flocal_variable_p (Qwindow_configuration_change_hook, buffer))) { - int count = SPECPDL_INDEX (); + int count1 = SPECPDL_INDEX (); record_unwind_protect (select_window_norecord, Fselected_window ()); select_window_norecord (window); run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, buffer)); - unbind_to (count, Qnil); + unbind_to (count1, Qnil); } } } @@ -3602,7 +3604,7 @@ select_frame_norecord (Lisp_Object frame) ? Fselect_frame (frame, Qt) : selected_frame; } -Lisp_Object +static Lisp_Object display_buffer (Lisp_Object buffer, Lisp_Object not_this_window_p, Lisp_Object override_frame) { return call3 (Qdisplay_buffer, buffer, not_this_window_p, override_frame); @@ -4119,7 +4121,7 @@ enlarge_window (Lisp_Object window, int delta, int horiz_flag) { /* If trying to grow this window to or beyond size of the parent, just delete all the sibling windows. */ - Lisp_Object start, tem, next; + Lisp_Object start, tem; start = XWINDOW (parent)->vchild; if (NILP (start)) @@ -4129,9 +4131,9 @@ enlarge_window (Lisp_Object window, int delta, int horiz_flag) tem = XWINDOW (window)->next; while (! NILP (tem)) { - next = XWINDOW (tem)->next; + Lisp_Object next1 = XWINDOW (tem)->next; delete_window (tem); - tem = next; + tem = next1; } /* Delete any siblings that come after WINDOW. @@ -4140,9 +4142,9 @@ enlarge_window (Lisp_Object window, int delta, int horiz_flag) tem = start; while (! EQ (tem, window)) { - next = XWINDOW (tem)->next; + Lisp_Object next1 = XWINDOW (tem)->next; delete_window (tem); - tem = next; + tem = next1; } } else @@ -5520,7 +5522,7 @@ and redisplay normally--don't erase and redraw the frame. */) struct buffer *obuf = current_buffer; int center_p = 0; EMACS_INT charpos, bytepos; - int iarg; + int iarg IF_LINT (= 0); int this_scroll_margin; /* If redisplay is suppressed due to an error, try again. */ @@ -7224,4 +7226,3 @@ keys_of_window (void) initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); initial_define_key (meta_map, 'v', "scroll-down-command"); } - diff --git a/src/window.h b/src/window.h index 690fd9a50f..f788e126d6 100644 --- a/src/window.h +++ b/src/window.h @@ -778,6 +778,7 @@ extern void freeze_window_starts (struct frame *, int); extern void grow_mini_window (struct window *, int); extern void shrink_mini_window (struct window *); extern int window_relative_x_coord (struct window *, enum window_part, int); +extern void check_all_windows (void); void run_window_configuration_change_hook (struct frame *f); diff --git a/src/xdisp.c b/src/xdisp.c index e62b491ad3..f2477a2eca 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14163,11 +14163,11 @@ redisplay_window (Lisp_Object window, int just_this_one_p) { /* The function returns -1 if new fonts were loaded, 1 if successful, 0 if not successful. */ - int rc = try_scrolling (window, just_this_one_p, + int ss = try_scrolling (window, just_this_one_p, scroll_conservatively, emacs_scroll_step, temp_scroll_step, last_line_misfit); - switch (rc) + switch (ss) { case SCROLLING_SUCCESS: goto done; @@ -17229,14 +17229,16 @@ display_line (struct it *it) struct glyph_row *row = it->glyph_row; Lisp_Object overlay_arrow_string; struct it wrap_it; - int may_wrap = 0, wrap_x; - int wrap_row_used = -1, wrap_row_ascent, wrap_row_height; - int wrap_row_phys_ascent, wrap_row_phys_height; - int wrap_row_extra_line_spacing; - EMACS_INT wrap_row_min_pos, wrap_row_min_bpos; - EMACS_INT wrap_row_max_pos, wrap_row_max_bpos; + int may_wrap = 0, wrap_x IF_LINT (= 0); + int wrap_row_used = -1; + int wrap_row_ascent IF_LINT (= 0), wrap_row_height IF_LINT (= 0); + int wrap_row_phys_ascent IF_LINT (= 0), wrap_row_phys_height IF_LINT (= 0); + int wrap_row_extra_line_spacing IF_LINT (= 0); + EMACS_INT wrap_row_min_pos IF_LINT (= 0), wrap_row_min_bpos IF_LINT (= 0); + EMACS_INT wrap_row_max_pos IF_LINT (= 0), wrap_row_max_bpos IF_LINT (= 0); int cvpos; - EMACS_INT min_pos = ZV + 1, min_bpos, max_pos = 0, max_bpos; + EMACS_INT min_pos = ZV + 1, max_pos = 0; + EMACS_INT min_bpos IF_LINT (= 0), max_bpos IF_LINT (= 0); /* We always start displaying at hpos zero even if hscrolled. */ xassert (it->hpos == 0 && it->current_x == 0); @@ -17910,16 +17912,13 @@ paragraphs, text begins at the right margin and is read from right to left. See also `bidi-paragraph-direction'. */) (Lisp_Object buffer) { - struct buffer *buf; - struct buffer *old; + struct buffer *buf = current_buffer; + struct buffer *old = buf; - if (NILP (buffer)) - buf = current_buffer; - else + if (! NILP (buffer)) { CHECK_BUFFER (buffer); buf = XBUFFER (buffer); - old = current_buffer; } if (NILP (BVAR (buf, bidi_display_reordering))) @@ -17936,8 +17935,7 @@ See also `bidi-paragraph-direction'. */) EMACS_INT bytepos = BUF_PT_BYTE (buf); int c; - if (buf != current_buffer) - set_buffer_temp (buf); + set_buffer_temp (buf); /* bidi_paragraph_init finds the base direction of the paragraph by searching forward from paragraph start. We need the base direction of the current or _previous_ paragraph, so we need @@ -17965,8 +17963,7 @@ See also `bidi-paragraph-direction'. */) itb.paragraph_dir = NEUTRAL_DIR; bidi_paragraph_init (NEUTRAL_DIR, &itb, 1); - if (buf != current_buffer) - set_buffer_temp (old); + set_buffer_temp (old); switch (itb.paragraph_dir) { case L2R: @@ -21090,7 +21087,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) int cmp_id = (row)->glyphs[area][START].u.cmp.id; \ struct composition *cmp = composition_table[cmp_id]; \ XChar2b *char2b; \ - struct glyph_string *first_s; \ + struct glyph_string *first_s IF_LINT (= NULL); \ int n; \ \ char2b = (XChar2b *) alloca ((sizeof *char2b) * cmp->glyph_len); \ @@ -21294,7 +21291,8 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row, { struct glyph_string *h, *t; Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); - int mouse_beg_col, mouse_end_col, check_mouse_face = 0; + int mouse_beg_col IF_LINT (= 0), mouse_end_col IF_LINT (= 0); + int check_mouse_face = 0; int dummy_x = 0; /* If mouse highlighting is on, we may need to draw adjacent @@ -22290,7 +22288,13 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) if (metrics_upper.width >= metrics_lower.width) lower_xoff = (width - metrics_lower.width) / 2; else - upper_xoff = (width - metrics_upper.width) / 2; + { + /* FIXME: This code doesn't look right. It formerly was + missing the "lower_xoff = 0;", which couldn't have + been right since it left lower_xoff uninitialized. */ + lower_xoff = 0; + upper_xoff = (width - metrics_upper.width) / 2; + } } /* +5 is for horizontal bars of a box plus 1-pixel spaces at @@ -25451,7 +25455,8 @@ note_mouse_highlight (struct frame *f, int x, int y) { /* The mouse-highlighting, if any, comes from an overlay or text property in the buffer. */ - Lisp_Object buffer, cover_string; + Lisp_Object buffer IF_LINT (= Qnil); + Lisp_Object cover_string IF_LINT (= Qnil); if (STRINGP (object)) { diff --git a/src/xfaces.c b/src/xfaces.c index 4cc47c8505..50bcab3c6a 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -297,16 +297,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR)) -/* Make a copy of string S on the stack using alloca. Value is a pointer - to the copy. */ - -#define STRDUPA(S) strcpy ((char *) alloca (strlen ((S)) + 1), (S)) - -/* Make a copy of the contents of Lisp string S on the stack using - alloca. Value is a pointer to the copy. */ - -#define LSTRDUPA(S) STRDUPA (SDATA ((S))) - /* Size of hash table of realized faces in face caches (should be a prime number). */ @@ -847,7 +837,6 @@ clear_face_cache (int clear_fonts_p) { #ifdef HAVE_WINDOW_SYSTEM Lisp_Object tail, frame; - struct frame *f; if (clear_fonts_p || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) @@ -875,7 +864,7 @@ clear_face_cache (int clear_fonts_p) /* Clear GCs of realized faces. */ FOR_EACH_FRAME (tail, frame) { - f = XFRAME (frame); + struct frame *f = XFRAME (frame); if (FRAME_WINDOW_P (f)) clear_face_gcs (FRAME_FACE_CACHE (f)); } @@ -1113,7 +1102,7 @@ tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, XColor /* A version of defined_color for non-X frames. */ -int +static int tty_defined_color (struct frame *f, const char *color_name, XColor *color_def, int alloc) { @@ -1721,7 +1710,7 @@ the WIDTH times as wide as FACE on FRAME. */) (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame, Lisp_Object maximum, Lisp_Object width) { struct frame *f; - int size, avgwidth; + int size, avgwidth IF_LINT (= 0); check_x (); CHECK_STRING (pattern); @@ -1754,14 +1743,14 @@ the WIDTH times as wide as FACE on FRAME. */) /* This is of limited utility since it works with character widths. Keep it for compatibility. --gerd. */ int face_id = lookup_named_face (f, face, 0); - struct face *face = (face_id < 0 - ? NULL - : FACE_FROM_ID (f, face_id)); + struct face *width_face = (face_id < 0 + ? NULL + : FACE_FROM_ID (f, face_id)); - if (face && face->font) + if (width_face && width_face->font) { - size = face->font->pixel_size; - avgwidth = face->font->average_width; + size = width_face->font->pixel_size; + avgwidth = width_face->font->average_width; } else { @@ -1838,6 +1827,7 @@ the WIDTH times as wide as FACE on FRAME. */) #define LFACE_INHERIT(LFACE) AREF ((LFACE), LFACE_INHERIT_INDEX) #define LFACE_FONTSET(LFACE) AREF ((LFACE), LFACE_FONTSET_INDEX) +#if XASSERTS /* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */ @@ -1845,6 +1835,7 @@ the WIDTH times as wide as FACE on FRAME. */) (VECTORP (LFACE) \ && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE \ && EQ (AREF (LFACE, 0), Qface)) +#endif #if GLYPH_DEBUG @@ -2252,7 +2243,7 @@ set_lface_from_font (struct frame *f, Lisp_Object lface, Lisp_Object font_object `relative' heights; the returned value is always an absolute height unless both FROM and TO are relative. */ -Lisp_Object +static Lisp_Object merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid) { Lisp_Object result = invalid; @@ -3869,19 +3860,19 @@ return the font name used for CHARACTER. */) { struct frame *f = frame_or_selected_frame (frame, 1); int face_id = lookup_named_face (f, face, 1); - struct face *face = FACE_FROM_ID (f, face_id); + struct face *fface = FACE_FROM_ID (f, face_id); - if (! face) + if (! fface) return Qnil; #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f) && !NILP (character)) { CHECK_CHARACTER (character); - face_id = FACE_FOR_CHAR (f, face, XINT (character), -1, Qnil); - face = FACE_FROM_ID (f, face_id); + face_id = FACE_FOR_CHAR (f, fface, XINT (character), -1, Qnil); + fface = FACE_FROM_ID (f, face_id); } - return (face->font - ? face->font->props[FONT_NAME_INDEX] + return (fface->font + ? fface->font->props[FONT_NAME_INDEX] : Qnil); #else /* !HAVE_WINDOW_SYSTEM */ return build_string (FRAME_MSDOS_P (f) @@ -4313,45 +4304,6 @@ free_realized_faces (struct face_cache *c) } -/* Free all realized faces that are using FONTSET on frame F. */ - -void -free_realized_faces_for_fontset (struct frame *f, int fontset) -{ - struct face_cache *cache = FRAME_FACE_CACHE (f); - struct face *face; - int i; - - /* We must block input here because we can't process X events safely - while only some faces are freed, or when the frame's current - matrix still references freed faces. */ - BLOCK_INPUT; - - for (i = 0; i < cache->used; i++) - { - face = cache->faces_by_id[i]; - if (face - && face->fontset == fontset) - { - uncache_face (cache, face); - free_realized_face (f, face); - } - } - - /* Must do a thorough redisplay the next time. Mark current - matrices as invalid because they will reference faces freed - above. This function is also called when a frame is destroyed. - In this case, the root window of F is nil. */ - if (WINDOWP (f->root_window)) - { - clear_current_matrices (f); - ++windows_or_buffers_changed; - } - - UNBLOCK_INPUT; -} - - /* Free all realized faces on FRAME or on all frames if FRAME is nil. This is done after attributes of a named face have been changed, because we can't tell which realized faces depend on that face. */ @@ -5287,10 +5239,6 @@ be found. Value is ALIST. */) #ifdef HAVE_WINDOW_SYSTEM -/* Ignore the difference of font point size less than this value. */ - -#define FONT_POINT_SIZE_QUANTUM 5 - /* Return the fontset id of the base fontset name or alias name given by the fontset attribute of ATTRS. Value is -1 if the fontset attribute of ATTRS doesn't name a fontset. */ diff --git a/src/xfns.c b/src/xfns.c index deb0e192a5..3f0bd2a7d6 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -461,7 +461,7 @@ x_real_positions (FRAME_PTR f, int *xptr, int *yptr) Window win = f->output_data.x->parent_desc; Atom actual_type; unsigned long actual_size, bytes_remaining; - int i, rc, actual_format; + int rc, actual_format; struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); long max_len = 400; Display *dpy = FRAME_X_DISPLAY (f); @@ -648,7 +648,7 @@ x_defined_color (struct frame *f, const char *color_name, is a monochrome frame, return MONO_COLOR regardless of what ARG says. Signal an error if color can't be allocated. */ -int +static int x_decode_color (FRAME_PTR f, Lisp_Object color_name, int mono_color) { XColor cdef; @@ -746,7 +746,6 @@ xg_set_icon (FRAME_PTR f, Lisp_Object file) int xg_set_icon_from_xpm_data (FRAME_PTR f, const char **data) { - int result = 0; GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data); if (!pixbuf) @@ -1635,7 +1634,7 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name) suggesting a new name, which lisp code should override; if F->explicit_name is set, ignore the new name; otherwise, set it. */ -void +static void x_set_name (struct frame *f, Lisp_Object name, int explicit) { /* Make sure that requests from lisp code override requests from @@ -2620,7 +2619,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) #else /* not USE_X_TOOLKIT */ #ifdef USE_GTK -void +static void x_window (FRAME_PTR f) { if (! xg_create_frame_widgets (f)) @@ -2660,7 +2659,7 @@ x_window (FRAME_PTR f) #else /*! USE_GTK */ /* Create and set up the X window for frame F. */ -void +static void x_window (struct frame *f) { XClassHint class_hints; @@ -3184,7 +3183,7 @@ This function is an internal primitive--use `make-frame' instead. */) to get the color reference counts right, so initialize them! */ { Lisp_Object black; - struct gcpro gcpro1; + struct gcpro inner_gcpro1; /* Function x_decode_color can signal an error. Make sure to initialize color slots so that we won't try @@ -3197,7 +3196,7 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_data.x->mouse_pixel = -1; black = build_string ("black"); - GCPRO1 (black); + GCPRO1_VAR (black, inner_gcpro1); FRAME_FOREGROUND_PIXEL (f) = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); FRAME_BACKGROUND_PIXEL (f) @@ -3210,7 +3209,7 @@ This function is an internal primitive--use `make-frame' instead. */) = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); f->output_data.x->mouse_pixel = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); - UNGCPRO; + UNGCPRO_VAR (inner_gcpro1); } /* Specify the parent under which to make this X window. */ @@ -3448,8 +3447,9 @@ This function is an internal primitive--use `make-frame' instead. */) else if (! NILP (visibility)) x_make_frame_visible (f); else - /* Must have been Qnil. */ - ; + { + /* Must have been Qnil. */ + } } BLOCK_INPUT; @@ -4577,7 +4577,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object text) { struct frame *f; - Lisp_Object frame, tem; + Lisp_Object frame; Lisp_Object name; long window_prompting = 0; int width, height; @@ -4651,7 +4651,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, to get the color reference counts right, so initialize them! */ { Lisp_Object black; - struct gcpro gcpro1; + struct gcpro inner_gcpro1; /* Function x_decode_color can signal an error. Make sure to initialize color slots so that we won't try @@ -4664,7 +4664,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, f->output_data.x->mouse_pixel = -1; black = build_string ("black"); - GCPRO1 (black); + GCPRO1_VAR (black, inner_gcpro1); FRAME_FOREGROUND_PIXEL (f) = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); FRAME_BACKGROUND_PIXEL (f) @@ -4677,7 +4677,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); f->output_data.x->mouse_pixel = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); - UNGCPRO; + UNGCPRO_VAR (inner_gcpro1); } /* Set the name; the functions to which we pass f expect the name to @@ -5035,7 +5035,7 @@ Text larger than the specified size is clipped. */) && !NILP (Fequal (last_string, string)) && !NILP (Fequal (last_parms, parms))) { - struct frame *f = XFRAME (tip_frame); + struct frame *tip_f = XFRAME (tip_frame); /* Only DX and DY have changed. */ if (!NILP (tip_timer)) @@ -5046,9 +5046,9 @@ Text larger than the specified size is clipped. */) } BLOCK_INPUT; - compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f), - FRAME_PIXEL_HEIGHT (f), &root_x, &root_y); - XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), + compute_tip_xy (tip_f, parms, dx, dy, FRAME_PIXEL_WIDTH (tip_f), + FRAME_PIXEL_HEIGHT (tip_f), &root_x, &root_y); + XMoveWindow (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f), root_x, root_y); UNBLOCK_INPUT; goto start_timer; @@ -5565,11 +5565,11 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) BLOCK_INPUT; if (STRINGP (default_filename)) - cdef_file = SDATA (default_filename); + cdef_file = SSDATA (default_filename); else - cdef_file = SDATA (dir); + cdef_file = SSDATA (dir); - fn = xg_get_file_name (f, SDATA (prompt), cdef_file, + fn = xg_get_file_name (f, SSDATA (prompt), cdef_file, ! NILP (mustmatch), ! NILP (only_dir_p)); @@ -5625,12 +5625,12 @@ If FRAME is omitted or nil, it defaults to the selected frame. */) XSETFONT (font, FRAME_FONT (f)); font_param = Ffont_get (font, intern (":name")); if (STRINGP (font_param)) - default_name = xstrdup (SDATA (font_param)); + default_name = xstrdup (SSDATA (font_param)); else { font_param = Fframe_parameter (frame, Qfont_param); if (STRINGP (font_param)) - default_name = xstrdup (SDATA (font_param)); + default_name = xstrdup (SSDATA (font_param)); } if (default_name == NULL && x_last_font_name != NULL) @@ -5694,7 +5694,7 @@ present and mapped to the usual X keysyms. */) struct frame *f = check_x_frame (frame); Display *dpy = FRAME_X_DISPLAY (f); Lisp_Object have_keys; - int major, minor, op, event, error; + int major, minor, op, event, error_code; BLOCK_INPUT; @@ -5710,7 +5710,7 @@ present and mapped to the usual X keysyms. */) /* Check that the server supports XKB. */ major = XkbMajorVersion; minor = XkbMinorVersion; - if (!XkbQueryExtension (dpy, &op, &event, &error, &major, &minor)) + if (!XkbQueryExtension (dpy, &op, &event, &error_code, &major, &minor)) { UNBLOCK_INPUT; return Qlambda; diff --git a/src/xmenu.c b/src/xmenu.c index 8967437a37..eab7bb03f2 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -124,11 +124,11 @@ static int update_frame_menubar (struct frame *); Xt on behalf of one of the widget sets. */ static int popup_activated_flag; -static int next_menubar_widget_id; - #ifdef USE_X_TOOLKIT +static int next_menubar_widget_id; + /* Return the frame whose ->output_data.x->id equals ID, or 0 if none. */ static struct frame * @@ -723,7 +723,7 @@ show_help_event (FRAME_PTR f, xt_or_gtk_widget widget, Lisp_Object help) unhighlighting. */ #ifdef USE_GTK -void +static void menu_highlight_callback (GtkWidget *widget, gpointer call_data) { xg_menu_item_cb_data *cb_data; @@ -742,7 +742,7 @@ menu_highlight_callback (GtkWidget *widget, gpointer call_data) show_help_event (cb_data->cl_data->f, widget, help); } #else -void +static void menu_highlight_callback (Widget widget, LWLIB_ID id, void *call_data) { struct frame *f; @@ -1175,8 +1175,6 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) } else { - GtkWidget *wvbox = f->output_data.x->vbox_widget; - menubar_widget = xg_create_widget ("menubar", "menubar", f, first_wv, G_CALLBACK (menubar_selection_callback), @@ -1600,7 +1598,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, Lisp_Object xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, - Lisp_Object title, const char **error, EMACS_UINT timestamp) + Lisp_Object title, const char **error_name, EMACS_UINT timestamp) { int i; widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; @@ -1615,11 +1613,11 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, if (! FRAME_X_P (f)) abort (); - *error = NULL; + *error_name = NULL; if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) { - *error = "Empty menu"; + *error_name = "Empty menu"; return Qnil; } @@ -1664,7 +1662,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, { /* Create a new pane. */ Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); @@ -2012,7 +2010,7 @@ xdialog_show (FRAME_PTR f, representing the text label and buttons. */ { Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; pane_string = (NILP (pane_name) @@ -2307,7 +2305,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, { /* Create a new pane. */ Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; maxlines = max (maxlines, lines); lines = 0; diff --git a/src/xrdb.c b/src/xrdb.c index 9fb3f3474f..63e5851979 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -28,6 +28,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <setjmp.h> +#include "lisp.h" + +/* This may include sys/types.h, and that somehow loses + if this is not done before the other system files. */ +#include "xterm.h" + #include <X11/Xlib.h> #include <X11/Xatom.h> #include <X11/X.h> @@ -38,8 +44,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #include <sys/stat.h> -#include "lisp.h" - #ifdef USE_MOTIF /* For Vdouble_click_time. */ #include "keyboard.h" diff --git a/src/xselect.c b/src/xselect.c index a502a74f90..5254fa9683 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -97,7 +97,6 @@ static Lisp_Object clean_local_selection_data (Lisp_Object); #define TRACE0(fmt) (void) 0 #define TRACE1(fmt, a0) (void) 0 #define TRACE2(fmt, a0, a1) (void) 0 -#define TRACE3(fmt, a0, a1) (void) 0 #endif @@ -330,7 +329,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value) struct frame *sf = SELECTED_FRAME (); Window selecting_window; Display *display; - Time time = last_event_timestamp; + Time timestamp = last_event_timestamp; Atom selection_atom; struct x_display_info *dpyinfo; @@ -346,7 +345,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value) BLOCK_INPUT; x_catch_errors (display); - XSetSelectionOwner (display, selection_atom, selecting_window, time); + XSetSelectionOwner (display, selection_atom, selecting_window, timestamp); x_check_errors (display, "Can't set selection: %s"); x_uncatch_errors (); UNBLOCK_INPUT; @@ -357,7 +356,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value) Lisp_Object selection_data; Lisp_Object prev_value; - selection_time = long_to_cons ((unsigned long) time); + selection_time = long_to_cons ((unsigned long) timestamp); selection_data = list4 (selection_name, selection_value, selection_time, selected_frame); prev_value = assq_no_quit (selection_name, Vselection_alist); @@ -2085,7 +2084,7 @@ DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal, Sx_disown_selection_internal, 1, 2, 0, doc: /* If we own the selection SELECTION, disown it. Disowning it means there is no such selection. */) - (Lisp_Object selection, Lisp_Object time) + (Lisp_Object selection, Lisp_Object time_object) { Time timestamp; Atom selection_atom; @@ -2104,10 +2103,10 @@ Disowning it means there is no such selection. */) display = FRAME_X_DISPLAY (sf); dpyinfo = FRAME_X_DISPLAY_INFO (sf); CHECK_SYMBOL (selection); - if (NILP (time)) + if (NILP (time_object)) timestamp = last_event_timestamp; else - timestamp = cons_to_long (time); + timestamp = cons_to_long (time_object); if (NILP (assq_no_quit (selection, Vselection_alist))) return Qnil; /* Don't disown the selection when we're not the owner. */ @@ -2131,26 +2130,6 @@ Disowning it means there is no such selection. */) return Qt; } -/* Get rid of all the selections in buffer BUFFER. - This is used when we kill a buffer. */ - -void -x_disown_buffer_selections (Lisp_Object buffer) -{ - Lisp_Object tail; - struct buffer *buf = XBUFFER (buffer); - - for (tail = Vselection_alist; CONSP (tail); tail = XCDR (tail)) - { - Lisp_Object elt, value; - elt = XCAR (tail); - value = XCDR (elt); - if (CONSP (value) && MARKERP (XCAR (value)) - && XMARKER (XCAR (value))->buffer == buf) - Fx_disown_selection_internal (XCAR (elt), Qnil); - } -} - DEFUN ("x-selection-owner-p", Fx_selection_owner_p, Sx_selection_owner_p, 0, 1, 0, doc: /* Whether the current Emacs process owns the given X Selection. @@ -2455,7 +2434,6 @@ x_handle_dnd_message (struct frame *f, XClientMessageEvent *event, struct x_disp if (event->format == 32 && event->format < BITS_PER_LONG) { - int i; for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ idata[i] = (int) event->data.l[i]; data = (unsigned char *) idata; diff --git a/src/xterm.c b/src/xterm.c index bb792d8b9a..fd7ffd68e6 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -279,10 +279,6 @@ Lisp_Object Qx_gtk_map_stock; /* Some functions take this as char *, not const char *. */ static char emacs_class[] = EMACS_CLASS; -/* XEmbed implementation. */ - -#define XEMBED_VERSION 0 - enum xembed_info { XEMBED_MAPPED = 1 << 0 @@ -321,6 +317,7 @@ static void XTframe_up_to_date (struct frame *); static void XTset_terminal_modes (struct terminal *); static void XTreset_terminal_modes (struct terminal *); static void x_clear_frame (struct frame *); +static void x_ins_del_lines (struct frame *, int, int) NO_RETURN; static void frame_highlight (struct frame *); static void frame_unhighlight (struct frame *); static void x_new_focus_frame (struct x_display_info *, struct frame *); @@ -877,6 +874,7 @@ static void x_draw_glyph_string_foreground (struct glyph_string *); static void x_draw_composite_glyph_string_foreground (struct glyph_string *); static void x_draw_glyph_string_box (struct glyph_string *); static void x_draw_glyph_string (struct glyph_string *); +static void x_delete_glyphs (struct frame *, int) NO_RETURN; static void x_compute_glyph_string_overhangs (struct glyph_string *); static void x_set_cursor_gc (struct glyph_string *); static void x_set_mode_line_face_gc (struct glyph_string *); @@ -1791,27 +1789,6 @@ x_copy_color (struct frame *f, long unsigned int pixel) } -/* Allocate color PIXEL on display DPY. PIXEL must already be allocated. - It's necessary to do this instead of just using PIXEL directly to - get color reference counts right. */ - -unsigned long -x_copy_dpy_color (Display *dpy, Colormap cmap, long unsigned int pixel) -{ - XColor color; - - color.pixel = pixel; - BLOCK_INPUT; - XQueryColor (dpy, cmap, &color); - XAllocColor (dpy, cmap, &color); - UNBLOCK_INPUT; -#ifdef DEBUG_X_COLORS - register_color (pixel); -#endif - return color.pixel; -} - - /* Brightness beyond which a color won't have its highlight brightness boosted. @@ -2260,12 +2237,12 @@ x_draw_image_foreground (struct glyph_string *s) nothing here for mouse-face. */ if (s->hl == DRAW_CURSOR) { - int r = s->img->relief; - if (r < 0) r = -r; + int relief = s->img->relief; + if (relief < 0) relief = -relief; XDrawRectangle (s->display, s->window, s->gc, - x - r, y - r, - s->slice.width + r*2 - 1, - s->slice.height + r*2 - 1); + x - relief, y - relief, + s->slice.width + relief*2 - 1, + s->slice.height + relief*2 - 1); } } } @@ -2907,7 +2884,7 @@ x_draw_glyph_string (struct glyph_string *s) /* Shift display to make room for inserted glyphs. */ -void +static void x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height, int shift_by) { XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_X_WINDOW (f), @@ -3011,7 +2988,7 @@ timeval_subtract (struct timeval *result, struct timeval x, struct timeval y) return x.tv_sec < y.tv_sec; } -void +static void XTflash (struct frame *f) { BLOCK_INPUT; @@ -3202,7 +3179,7 @@ XTtoggle_invisible_pointer (FRAME_PTR f, int invisible) /* Make audible bell. */ -void +static void XTring_bell (struct frame *f) { if (FRAME_X_DISPLAY (f)) @@ -3816,7 +3793,7 @@ redo_mouse_highlight (void) mouse is on, *BAR_WINDOW to nil, and *X and *Y to the character cell the mouse is over. - Set *TIME to the server time-stamp for the time at which the mouse + Set *TIMESTAMP to the server time-stamp for the time at which the mouse was at this position. Don't store anything if we don't have a valid set of values to report. @@ -3825,14 +3802,16 @@ redo_mouse_highlight (void) movement. */ static void -XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, long unsigned int *time) +XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, + enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, + long unsigned int *timestamp) { FRAME_PTR f1; BLOCK_INPUT; if (! NILP (last_mouse_scroll_bar) && insist == 0) - x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); + x_scroll_bar_report_motion (fp, bar_window, part, x, y, timestamp); else { Window root; @@ -4005,7 +3984,7 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, enum scrol *fp = f1; XSETINT (*x, win_x); XSETINT (*y, win_y); - *time = last_mouse_movement_time; + *timestamp = last_mouse_movement_time; } } } @@ -5557,7 +5536,9 @@ x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) on the scroll bar. */ static void -x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, long unsigned int *time) +x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window, + enum scroll_bar_part *part, Lisp_Object *x, + Lisp_Object *y, long unsigned int *timestamp) { struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); Window w = bar->x_window; @@ -5617,7 +5598,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window, enum scroll_ last_mouse_scroll_bar = Qnil; } - *time = last_mouse_movement_time; + *timestamp = last_mouse_movement_time; UNBLOCK_INPUT; } @@ -5791,7 +5772,8 @@ static void xembed_send_message (struct frame *f, Time time, We return the number of characters stored into the buffer. */ static int -handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, struct input_event *hold_quit) +handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, + int *finish, struct input_event *hold_quit) { union { struct input_event ie; @@ -5802,7 +5784,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, int nbytes = 0; struct frame *f = NULL; struct coding_system coding; - XEvent event = *eventp; + XEvent event = *eventptr; Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; *finish = X_EVENT_NORMAL; @@ -6502,7 +6484,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, { /* Raw bytes, not keysym. */ register int i; - register int c; int nchars, len; for (i = 0, nchars = 0; i < nbytes; i++) @@ -6542,14 +6523,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, character events. */ for (i = 0; i < nbytes; i += len) { + int ch; if (nchars == nbytes) - c = copy_bufptr[i], len = 1; + ch = copy_bufptr[i], len = 1; else - c = STRING_CHAR_AND_LENGTH (copy_bufptr + i, len); - inev.ie.kind = (SINGLE_BYTE_CHAR_P (c) + ch = STRING_CHAR_AND_LENGTH (copy_bufptr + i, len); + inev.ie.kind = (SINGLE_BYTE_CHAR_P (ch) ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT); - inev.ie.code = c; + inev.ie.code = ch; kbd_buffer_store_event_hold (&inev.ie, hold_quit); } @@ -6988,7 +6970,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, count++; } - *eventp = event; + *eventptr = event; return count; } @@ -7028,7 +7010,6 @@ static int XTread_socket (struct terminal *terminal, int expected, struct input_event *hold_quit) { int count = 0; - XEvent event; int event_found = 0; if (interrupt_input_blocked) @@ -7062,6 +7043,7 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold while (XPending (terminal->display_info.x->display)) { int finish; + XEvent event; XNextEvent (terminal->display_info.x->display, &event); @@ -7079,6 +7061,8 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold goto out; } + out:; + #else /* USE_GTK */ /* For GTK we must use the GTK event loop. But XEvents gets passed @@ -7105,8 +7089,6 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold } #endif /* USE_GTK */ - out:; - /* On some systems, an X bug causes Emacs to get no more events when the window is destroyed. Detect that. (1994.) */ if (! event_found) @@ -7242,9 +7224,9 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text the bar might not be in the window. */ if (cursor_glyph->type == IMAGE_GLYPH) { - struct glyph_row *row; - row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos); - draw_phys_cursor_glyph (w, row, DRAW_CURSOR); + struct glyph_row *r; + r = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos); + draw_phys_cursor_glyph (w, r, DRAW_CURSOR); } else { @@ -7533,9 +7515,9 @@ static struct x_error_message_stack *x_error_message; x_catch_errors is in effect. */ static void -x_error_catcher (Display *display, XErrorEvent *error) +x_error_catcher (Display *display, XErrorEvent *event) { - XGetErrorText (display, error->error_code, + XGetErrorText (display, event->error_code, x_error_message->string, X_ERROR_MESSAGE_SIZE); } @@ -7684,17 +7666,6 @@ x_connection_signal (int signalnum) /* If we don't have an argument, */ static char *error_msg; -/* Function installed as fatal_error_signal_hook in - x_connection_closed. Print the X error message, and exit normally, - instead of dumping core when XtCloseDisplay fails. */ - -static void -x_fatal_error_signal (void) -{ - fprintf (stderr, "%s\n", error_msg); - exit (70); -} - /* Handle the loss of connection to display DPY. ERROR_MESSAGE is the text of an error message that lead to the connection loss. */ @@ -7703,7 +7674,7 @@ x_connection_closed (Display *dpy, const char *error_message) { struct x_display_info *dpyinfo = x_display_info_for_display (dpy); Lisp_Object frame, tail; - int index = SPECPDL_INDEX (); + int idx = SPECPDL_INDEX (); error_msg = (char *) alloca (strlen (error_message) + 1); strcpy (error_msg, error_message); @@ -7798,8 +7769,12 @@ For details, see etc/PROBLEMS.\n", sigunblock (sigmask (SIGALRM)); TOTALLY_UNBLOCK_INPUT; - unbind_to (index, Qnil); + unbind_to (idx, Qnil); clear_waiting_for_input (); + + /* Tell GCC not to suggest attribute 'noreturn' for this function. */ + IF_LINT (if (! terminal_list) return; ) + /* Here, we absolutely have to use a non-local exit (e.g. signal, throw, longjmp), because returning from this function would get us back into Xlib's code which will directly call `exit'. */ @@ -7814,12 +7789,12 @@ static void x_error_quitter (Display *, XErrorEvent *); It calls x_error_quitter or x_error_catcher. */ static int -x_error_handler (Display *display, XErrorEvent *error) +x_error_handler (Display *display, XErrorEvent *event) { if (x_error_message) - x_error_catcher (display, error); + x_error_catcher (display, event); else - x_error_quitter (display, error); + x_error_quitter (display, event); return 0; } @@ -7833,22 +7808,22 @@ x_error_handler (Display *display, XErrorEvent *error) after x_error_handler prevents inlining into the former. */ static void NO_INLINE -x_error_quitter (Display *display, XErrorEvent *error) +x_error_quitter (Display *display, XErrorEvent *event) { char buf[256], buf1[356]; /* Ignore BadName errors. They can happen because of fonts or colors that are not defined. */ - if (error->error_code == BadName) + if (event->error_code == BadName) return; /* Note that there is no real way portable across R3/R4 to get the original error handler. */ - XGetErrorText (display, error->error_code, buf, sizeof (buf)); + XGetErrorText (display, event->error_code, buf, sizeof (buf)); sprintf (buf1, "X protocol error: %s on protocol request %d", - buf, error->request_code); + buf, event->request_code); x_connection_closed (display, buf1); } @@ -8135,7 +8110,7 @@ xim_close_dpy (struct x_display_info *dpyinfo) /* Calculate the absolute position in frame F from its current recorded position values and gravity. */ -void +static void x_calc_absolute_position (struct frame *f) { int flags = f->size_hint_flags; @@ -8878,31 +8853,6 @@ x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) UNBLOCK_INPUT; } -/* focus shifting, raising and lowering. */ - -void -x_focus_on_frame (struct frame *f) -{ -#if 0 - /* I don't think that the ICCCM allows programs to do things like this - without the interaction of the window manager. Whatever you end up - doing with this code, do it to x_unfocus_frame too. */ - XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - RevertToPointerRoot, CurrentTime); -#endif /* ! 0 */ -} - -void -x_unfocus_frame (struct frame *f) -{ -#if 0 - /* Look at the remarks in x_focus_on_frame. */ - if (FRAME_X_DISPLAY_INFO (f)->x_focus_frame == f) - XSetInputFocus (FRAME_X_DISPLAY (f), PointerRoot, - RevertToPointerRoot, CurrentTime); -#endif /* ! 0 */ -} - /* Raise frame F. */ void @@ -8963,6 +8913,12 @@ XTframe_raise_lower (FRAME_PTR f, int raise_flag) /* XEmbed implementation. */ +#if defined USE_X_TOOLKIT || ! defined USE_GTK + +/* XEmbed implementation. */ + +#define XEMBED_VERSION 0 + static void xembed_set_info (struct frame *f, enum xembed_info flags) { @@ -8976,9 +8932,11 @@ xembed_set_info (struct frame *f, enum xembed_info flags) dpyinfo->Xatom_XEMBED_INFO, dpyinfo->Xatom_XEMBED_INFO, 32, PropModeReplace, (unsigned char *) data, 2); } +#endif /* defined USE_X_TOOLKIT || ! defined USE_GTK */ static void -xembed_send_message (struct frame *f, Time time, enum xembed_message message, long int detail, long int data1, long int data2) +xembed_send_message (struct frame *f, Time t, enum xembed_message msg, + long int detail, long int data1, long int data2) { XEvent event; @@ -8986,8 +8944,8 @@ xembed_send_message (struct frame *f, Time time, enum xembed_message message, lo event.xclient.window = FRAME_X_OUTPUT (f)->parent_desc; event.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_XEMBED; event.xclient.format = 32; - event.xclient.data.l[0] = time; - event.xclient.data.l[1] = message; + event.xclient.data.l[0] = t; + event.xclient.data.l[1] = msg; event.xclient.data.l[2] = detail; event.xclient.data.l[3] = data1; event.xclient.data.l[4] = data2; @@ -9228,7 +9186,9 @@ x_make_frame_invisible (struct frame *f) void x_iconify_frame (struct frame *f) { +#ifdef USE_X_TOOLKIT int result; +#endif Lisp_Object type; /* Don't keep the highlight on an invisible frame. */ @@ -9311,19 +9271,19 @@ x_iconify_frame (struct frame *f) /* X11R4: send a ClientMessage to the window manager using the WM_CHANGE_STATE type. */ { - XEvent message; + XEvent msg; - message.xclient.window = FRAME_X_WINDOW (f); - message.xclient.type = ClientMessage; - message.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_change_state; - message.xclient.format = 32; - message.xclient.data.l[0] = IconicState; + msg.xclient.window = FRAME_X_WINDOW (f); + msg.xclient.type = ClientMessage; + msg.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_change_state; + msg.xclient.format = 32; + msg.xclient.data.l[0] = IconicState; if (! XSendEvent (FRAME_X_DISPLAY (f), DefaultRootWindow (FRAME_X_DISPLAY (f)), False, SubstructureRedirectMask | SubstructureNotifyMask, - &message)) + &msg)) { UNBLOCK_INPUT_RESIGNAL; error ("Can't notify window manager of iconification"); @@ -9355,9 +9315,11 @@ void x_free_frame_resources (struct frame *f) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); + Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; +#ifdef USE_X_TOOLKIT Lisp_Object bar; struct scroll_bar *b; - Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; +#endif BLOCK_INPUT; @@ -9813,10 +9775,11 @@ x_display_ok (const char *display) #ifdef USE_GTK static void -my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) +my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, + const gchar *msg, gpointer user_data) { - if (!strstr (message, "g_set_prgname")) - fprintf (stderr, "%s-WARNING **: %s\n", log_domain, message); + if (!strstr (msg, "g_set_prgname")) + fprintf (stderr, "%s-WARNING **: %s\n", log_domain, msg); } #endif diff --git a/src/xterm.h b/src/xterm.h index ee17cfe2bd..15630e902e 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -990,6 +990,7 @@ extern int x_alloc_nearest_color (struct frame *, Colormap, XColor *); extern void x_query_colors (struct frame *f, XColor *, int); extern void x_query_color (struct frame *f, XColor *); extern void x_clear_area (Display *, Window, int, int, int, int, int); +extern void x_mouse_leave (struct x_display_info *); extern void set_vertical_scroll_bar (struct window *); extern int x_dispatch_event (XEvent *, Display *); |