1. 04 Dec, 2011 2 commits
    • Andreas Schwab's avatar
      Don't call Lisp in signal handler · 6c07aac2
      Andreas Schwab authored
      * emacs.c (Qkill_emacs): Define.
      (syms_of_emacs): Initialize it.
      * keyboard.c (interrupt_signal): Don't call Fkill_emacs here, set
      Qquit_flag to `kill-emacs' instead.
      (quit_throw_to_read_char): Add parameter `from_signal'.  All
      callers changed.  Call Fkill_emacs if requested and safe.
      * lisp.h (QUIT): Call Fkill_emacs if requested.
    • Paul Eggert's avatar
      Spelling fixes. · c80e3b4a
      Paul Eggert authored
  2. 01 Dec, 2011 1 commit
  3. 28 Nov, 2011 1 commit
  4. 20 Nov, 2011 2 commits
  5. 19 Nov, 2011 1 commit
  6. 17 Nov, 2011 1 commit
  7. 14 Nov, 2011 2 commits
  8. 11 Nov, 2011 1 commit
  9. 06 Nov, 2011 1 commit
  10. 28 Oct, 2011 1 commit
  11. 25 Oct, 2011 1 commit
  12. 03 Oct, 2011 1 commit
  13. 09 Sep, 2011 1 commit
  14. 29 Aug, 2011 1 commit
    • Paul Eggert's avatar
      sprintf-related integer and memory overflow issues. · 62f19c19
      Paul Eggert authored
      * doprnt.c (doprnt): Support printing ptrdiff_t and intmax_t values.
      (esprintf, esnprintf, exprintf, evxprintf): New functions.
      * keyboard.c (command_loop_level): Now EMACS_INT, not int.
      (cmd_error): kbd macro iterations count is now EMACS_INT, not int.
      (modify_event_symbol): Do not assume that the length of
      name_alist_or_stem is safe to alloca and fits in int.
      (Fexecute_extended_command): Likewise for function name and binding.
      (Frecursion_depth): Wrap around reliably on integer overflow.
      * keymap.c (push_key_description): First arg is now EMACS_INT, not int,
      since some callers pass EMACS_INT values.
      (Fsingle_key_description): Don't crash if symbol name contains more
      than MAX_ALLOCA bytes.
      * minibuf.c (minibuf_level): Now EMACS_INT, not int.
      (get_minibuffer): Arg is now EMACS_INT, not int.
      * lisp.h (get_minibuffer, push_key_description): Reflect API changes.
      (esprintf, esnprintf, exprintf, evxprintf): New decls.
      * window.h (command_loop_level, minibuf_level): Reflect API changes.
  15. 19 Aug, 2011 1 commit
  16. 04 Aug, 2011 1 commit
    • Jan Djärv's avatar
      Check for pthread and use it if found. · ae9e757a
      Jan Djärv authored
      * configure.in (HAVE_PTHREAD): Add check for -lpthread.
      (HAVE_GTK_AND_PTHREAD): Remove.
      * src/Makefile.in (LIB_PTHREAD): New variable.
      (LIBES): Add LIB_PTHREAD (Bug#9216).
      * src/alloc.c, src/emacs.c, src/gmalloc.c, src/gtkutil.c, src/keyboard.c, src/syssignal.h:
      Rename HAVE_GTK_AND_PTHREAD to HAVE_PTHREAD (Bug#9216).
  17. 29 Jul, 2011 1 commit
    • Paul Eggert's avatar
      * keyboard.c: Integer and memory overflow fixes. · 34db673b
      Paul Eggert authored
      (read_char, menu_bar_items, tool_bar_items, read_char_x_menu_prompt)
      (read_char_minibuf_menu_width, read_char_minibuf_menu_prompt)
      (follow_key, read_key_sequence): Use ptrdiff_t, not int, to count maps.
      (read_char_minibuf_menu_prompt): Check for overflow in size
      calculations.  Don't update size until allocation succeeds.  Redo
      calculations to avoid overflow.
      * keyboard.h: Change prototypes to match the above.
  18. 17 Jul, 2011 1 commit
    • Paul Eggert's avatar
      * keyboard.c: Overflow, signedness and related fixes. · b13995db
      Paul Eggert authored
      (make_lispy_movement): Use same integer type in forward decl
      that is used in the definition.
      (read_key_sequence, keyremap_step):
      Change bufsize argument back to int, undoing my 2011-03-30 change.
      We prefer signed types, and int is wide enough here.
      (parse_tool_bar_item): Don't assume tool_bar_max_label_size is less
      than TYPE_MAXIMUM (EMACS_INT) / 2.  Don't let the label size grow
      larger than STRING_BYTES_BOUND.  Use ptrdiff_t for Emacs string
      length, not size_t.  Use ptrdiff_t for index, not int.
      (keyremap_step, read_key_sequence): Redo bufsize check to avoid
      possibility of integer overflow.
  19. 14 Jul, 2011 1 commit
  20. 07 Jul, 2011 1 commit
  21. 02 Jul, 2011 2 commits
    • Chong Yidong's avatar
      Fix corner case in prefix-arg handling for mouse events (Bug#1586). · 7a8e04f7
      Chong Yidong authored
      * src/keyboard.c (command_loop_1): If a down-mouse event is unbound,
      leave any prefix arg for the up event.
    • Stefan Monnier's avatar
      Add multiple inheritance to keymaps. · 3349e122
      Stefan Monnier authored
      * src/keymap.c (Fmake_composed_keymap): New function.
      (Fset_keymap_parent): Simplify.
      (fix_submap_inheritance): Remove.
      (access_keymap_1): New function extracted from access_keymap to handle
      embedded parents and handle lists of maps.
      (access_keymap): Use it.
      (Fkeymap_prompt, map_keymap_internal, map_keymap, store_in_keymap)
      (Fcopy_keymap): Handle embedded parents.
      (Fcommand_remapping, define_as_prefix): Simplify.
      (Fkey_binding): Simplify.
      (syms_of_keymap): Move minibuffer-local-completion-map,
      minibuffer-local-must-match-map, and
      minibuffer-local-filename-must-match-map to Elisp.
      (syms_of_keymap): Defsubr make-composed-keymap.
      * src/keyboard.c (menu_bar_items): Use map_keymap_canonical.
      (parse_menu_item): Trivial simplification.
      * lisp/subr.el (remq): Don't allocate if it's not needed.
      (keymap--menu-item-binding, keymap--menu-item-with-binding)
      (keymap--merge-bindings): New functions.
      (keymap-canonicalize): Use them to refine the canonicalization.
      * lisp/minibuffer.el (minibuffer-local-completion-map)
      (minibuffer-local-must-match-map): Move initialization from C.
      (minibuffer-local-filename-completion-map): Move initialization from C;
      don't inherit from anything here.
      (minibuffer-local-filename-must-match-map): Make obsolete.
      (completing-read-default): Use make-composed-keymap to combine
      minibuffer-local-filename-completion-map with either
      minibuffer-local-must-match-map or
  22. 20 Jun, 2011 1 commit
  23. 14 Jun, 2011 1 commit
    • Paul Eggert's avatar
      Variadic C functions now count arguments with ptrdiff_t. · f66c7cf8
      Paul Eggert authored
      This partly undoes my 2011-03-30 change, which replaced int with size_t.
      Back then I didn't know that the Emacs coding style prefers signed int.
      Also, in the meantime I found a few more instances where arguments
      were being counted with int, which may truncate counts on 64-bit
      machines, or EMACS_INT, which may be unnecessarily wide.
      * lisp.h (struct Lisp_Subr.function.aMANY)
      (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call):
      Arg counts are now ptrdiff_t, not size_t.
      All variadic functions and their callers changed accordingly.
      (struct gcpro.nvars): Now size_t, not size_t.  All uses changed.
      * bytecode.c (exec_byte_code): Check maxdepth for overflow,
      to avoid potential buffer overrun.  Don't assume arg counts fit in 'int'.
      * callint.c (Fcall_interactively): Check arg count for overflow,
      to avoid potential buffer overrun.  Use signed char, not 'int',
      for 'varies' array, so that we needn't bother to check its size
      calculation for overflow.
      * editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args.
      * eval.c (apply_lambda):
      * fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length.
      (struct textprop_rec.argnum): Now ptrdiff_t, not int.  All uses changed.
      (mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args.
  24. 13 Jun, 2011 1 commit
  25. 12 Jun, 2011 2 commits
    • Paul Eggert's avatar
      Remove incorrect casts to 'unsigned' that lose info on 64-bit hosts. · d37ca623
      Paul Eggert authored
      These casts should not be needed on 32-bit hosts, either.
      * keyboard.c (read_char):
      * lread.c (Fload): Remove casts to unsigned.
    • Paul Eggert's avatar
      * lisp.h (UNSIGNED_CMP): New macro. · ea204efb
      Paul Eggert authored
      This fixes comparison bugs on 64-bit hosts.
      (ASCII_CHAR_P): Use it.
      * casefiddle.c (casify_object):
      * character.h (ASCII_BYTE_P, CHAR_VALID_P):
      * composite.h (COMPOSITION_ENCODE_RULE_VALID):
      * dispextern.h (FACE_FROM_ID):
      * keyboard.c (read_char): Use UNSIGNED_CMP.
  26. 01 Jun, 2011 1 commit
    • Paul Eggert's avatar
      Minor fixes for signed vs unsigned integers. · ccd9a01a
      Paul Eggert authored
      * character.h (MAYBE_UNIFY_CHAR):
      * charset.c (maybe_unify_char):
      * keyboard.c (read_char, reorder_modifiers):
      XINT -> XFASTINT, since the integer must be nonnegative.
      * ftfont.c (ftfont_spec_pattern):
      * keymap.c (access_keymap, silly_event_symbol_error):
      XUINT -> XFASTINT, since the integer must be nonnegative.
      (Fsingle_key_description, preferred_sequence_p): XUINT -> XINT,
      since it makes no difference and we prefer signed.
      * keyboard.c (record_char): Use XUINT when all the neighbors do.
      (access_keymap): NATNUMP -> INTEGERP, since the integer must be
  27. 28 May, 2011 2 commits
    • Paul Eggert's avatar
      [ChangeLog] · 55d4c1b2
      Paul Eggert authored
      Use 'inline', not 'INLINE'.
      * configure.in, autogen/config.in (INLINE): Remove.
      Use 'inline', not 'INLINE'.
      * etags.c (hash): Now inline unconditionally.
      * make-docfile.c (put_char): inline, not INLINE.
      Use 'inline', not 'INLINE'.
      * config.nt (INLINE): Remove.
      Use 'inline', not 'INLINE'.
      * alloc.c, fontset.c (INLINE): Remove.
      * alloc.c, bidi.c, charset.c, coding.c, dispnew.c, fns.c, image.c:
      * intervals.c, keyboard.c, process.c, syntax.c, textprop.c, w32term.c:
      * xdisp.c, xfaces.c, xterm.c: Replace all uses of INLINE with inline.
      * gmalloc.c (register_heapinfo): Use inline unconditionally.
      * lisp.h (LISP_MAKE_RVALUE): Use inline, not __inline__.
    • Eli Zaretskii's avatar
      Fix cursor motion across display strings covering reordered text. · 0e14fe90
      Eli Zaretskii authored
       src/xdisp.c (set_cursor_from_row): Set start and stop points
       according to the row's direction when priming the loop that looks
       for the glyph on which to display cursor.
       (single_display_spec_intangible_p): Function deleted.
       (display_prop_intangible_p): Reimplement to call
       handle_display_spec instead of single_display_spec_intangible_p.
       Accept 3 additional arguments needed by handle_display_spec.  This
       fixes incorrect cursor motion across display property with complex
       values: lists, `(when COND...)' forms, etc.
       (single_display_spec_string_p): Support property values that are
       lists with the argument STRING its top-level element.
       (display_prop_string_p): Fix the condition for processing a
       property that is a list to be consistent with handle_display_spec.
       src/keyboard.c (adjust_point_for_property): Adjust the call to
       display_prop_intangible_p to its new signature.
       src/dispextern.h (display_prop_intangible_p): Adjust prototype.
  28. 12 May, 2011 2 commits
    • Paul Eggert's avatar
      Be more systematic about user-interface timestamps. · 08dc5ae6
      Paul Eggert authored
      Before, the code sometimes used 'Time', sometimes 'unsigned long',
      and sometimes 'EMACS_UINT', to represent these timestamps.  This
      change causes it to use 'Time' uniformly, as that's what X uses.
      This makes the code easier to follow, and makes it easier to catch
      integer overflow bugs such as Bug#8664.
      * frame.c (Fmouse_position, Fmouse_pixel_position):
      Use Time, not unsigned long, for user-interface timestamps.
      * keyboard.c (last_event_timestamp, kbd_buffer_get_event): Likewise.
      (button_down_time, make_lispy_position, make_lispy_movement): Likewise.
      * keyboard.h (last_event_timestamp): Likewise.
      * menu.c (Fx_popup_menu) [!HAVE_X_WINDOWS]: Likewise.
      * menu.h (xmenu_show): Likewise.
      * term.c (term_mouse_position): Likewise.
      * termhooks.h (struct input_event.timestamp): Likewise.
      (struct terminal.mouse_position_hook): Likewise.
      * xmenu.c (create_and_show_popup_menu, xmenu_show): Likewise.
      * xterm.c (XTmouse_position, x_scroll_bar_report_motion): Likewise.
      * systime.h (Time): New decl.  Pull it in from <X11/X.h> if
      HAVE_X_WINDOWS, otherwise define it as unsigned long, which is
      what it was before.
      * menu.h, termhooks.h: Include "systime.h", for Time.
    • Paul Eggert's avatar
      * keyboard.c (make_lispy_event): Fix problem in integer overflow. · 8e55734a
      Paul Eggert authored
      Don't assume that the difference between two unsigned long values
      can fit into an integer.  At this point, we know button_down_time
      <= event->timestamp, so the difference must be nonnegative, so
      there's no need to cast the result if double-click-time is
      nonnegative, as it should be; check that it's nonnegative, just in
      case.  This bug is triggered when events are more than 2**31 ms
      apart (about 25 days).
  29. 09 May, 2011 1 commit
    • Eli Zaretskii's avatar
      Backport revisions... · 14fe7b53
      Eli Zaretskii authored
      Backport revisions 2011-04-24T05:30:24Z!eggert@cs.ucla.edu..2011-04-25T19:40:22Z!eggert@cs.ucla.edu (inclusive) from trunk (bug#8623)
      	The next log entry shows the actual changes by Paul Eggert.
       Fix a problem with aliasing and vector headers.
       GCC 4.6.0 optimizes based on type-based alias analysis.  For
       example, if b is of type struct buffer * and v of type struct
       Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size
       != &v->size, and therefore "v->size = 1; b->size = 2; return
       v->size;" must therefore return 1.  This assumption is incorrect
       for Emacs, since it type-puns struct Lisp_Vector * with many other
       types.  To fix this problem, this patch adds a new type struct
       vector_header that documents the constraints on layout of vectors
       and pseudovectors, and helps optimizing compilers not get fooled
       by Emacs's type punning.  It also adds the macros XSETTYPED_PVECTYPE
       src/lisp.h (XVECTOR_SIZE): New convenience macro.  All previous uses of
       XVECTOR (foo)->size replaced to use this macro, to avoid the hassle
       of writing XVECTOR (foo)->header.size.
       src/lisp.h: Say "vectorlike header" rather than "vector header.
       (struct vectorlike_header): Rename from struct vector_header.
       All uses changed.
       (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR.
       (XSETTYPED_PVECTYPE): New macro, specifying the name of the size
       (XSETPVECTYPE): Rewrite in terms of new macro.
       (XSETPVECTYPESIZE): New macro, specifying both type and size.
       This is a bit clearer, and further avoids the possibility of
       undesirable aliasing.
       (XSETTYPED_PSEUDOVECTOR): New macro, specifying the size.
       (XSETSUBR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XSIZE,
       since Lisp_Subr is a special case (no "next" field).
       (ASIZE): Rewrite in terms of XVECTOR_SIZE.
       (struct vector_header): New type.
       (TYPED_PSEUDOVECTORP): New macro, also specifying the C type of the
       object, to help avoid aliasing.
       (PSEUDOVECTORP): Rewrite in terms of TYPED_PSEUDOVECTORP.
       (SUBRP): Likewise, since Lisp_Subr is a special case.
       src/lisp.h (struct Lisp_Vector, struct Lisp_Char_Table):
       (struct Lisp_Sub_Char_Table, struct Lisp_Bool_Vector):
       (struct Lisp_Hash_Table): Combine first two members into a single
       struct vector_header member.  All uses of "size" and "next" members
       changed to be "header.size" and "header.next".
       src/buffer.h (struct buffer): Likewise.
       src/font.h (struct font_spec, struct font_entity, struct font): Likewise.
       src/frame.h (struct frame): Likewise.
       src/process.h (struct Lisp_Process): Likewise.
       src/termhooks.h (struct terminal): Likewise.
       src/window.c (struct save_window_data, struct saved_window): Likewise.
       src/window.h (struct window): Likewise.
       src/alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector):
       Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems.
       src/buffer.c (init_buffer_once): Likewise.
       src/lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a
       special case.
       src/process.c (Fformat_network_address): Use local var for size,
       for brevity.
       src/fns.c (vector): Remove; this old hack is no longer needed.
       src/bytecode.c (exec_byte_code): Don't use XVECTOR before CHECK_VECTOR.
  30. 28 Apr, 2011 1 commit
    • Juanma Barranquero's avatar
      Add delayed warnings support. · 638f053a
      Juanma Barranquero authored
      * etc/NEWS: Document `delayed-warnings-list' and `delayed-warnings-hook'.
      * lisp/subr.el (display-delayed-warnings): New function.
        (delayed-warnings-hook): New variable.
      * src/keyboard.c (Qdelayed_warnings_hook): Define.
        (command_loop_1): Run `delayed-warnings-hook' if Vdelayed_warnings_list
        is non-nil.
        (syms_of_keyboard) <delayed-warnings-hook>: DEFSYM it.
        (syms_of_keyboard) <delayed-warnings-list>: DEFVAR_LISP it.
  31. 26 Apr, 2011 3 commits