1. 12 Feb, 2012 1 commit
    • Glenn Morris's avatar
      Yet more syncing of xselect docs and argument specs · bd7da63e
      Glenn Morris authored
      * src/xselect.c (Fx_own_selection_internal)
      (Fx_get_selection_internal, Fx_disown_selection_internal)
      (Fx_selection_owner_p, Fx_selection_exists_p): Doc fixes.
      * src/nsselect.m (Fx_own_selection_internal)
      (Fx_disown_selection_internal, Fx_selection_exists_p)
      (Fx_selection_owner_p, Fx_get_selection_internal):
      Sync docs and argument specs with the xselect.c versions.
      * lisp/term/pc-win.el (x-selection-owner-p, x-own-selection-internal)
      (x-disown-selection-internal, x-get-selection-internal):
      Sync docs with the xselect.c versions.
      bd7da63e
  2. 11 Jan, 2012 1 commit
  3. 05 Jan, 2012 1 commit
  4. 14 Dec, 2011 1 commit
  5. 05 Dec, 2011 1 commit
  6. 15 Nov, 2011 1 commit
  7. 16 Sep, 2011 1 commit
  8. 14 Sep, 2011 1 commit
  9. 09 Sep, 2011 1 commit
  10. 16 Aug, 2011 1 commit
    • Paul Eggert's avatar
      Simplify previous changes. · a69fbedb
      Paul Eggert authored
      * image.c (x_allocate_bitmap_record, cache_image):
      * xselect.c (Fx_register_dnd_atom):
      Simplify previous changes by using xpalloc.
      a69fbedb
  11. 06 Aug, 2011 1 commit
  12. 05 Aug, 2011 1 commit
  13. 29 Jul, 2011 1 commit
    • Paul Eggert's avatar
      * xselect.c: Integer and memory overflow issues. · 864d7ce7
      Paul Eggert authored
      (X_LONG_SIZE, X_USHRT_MAX, X_ULONG_MAX): New macros.
      Use them to make the following changes clearer.
      (MAX_SELECTION_QUANTUM): Make the other bounds on this value clearer.
      This change doesn't affect the value now, but it may help remind
      future maintainers not to raise the value too much later.
      (SELECTION_QUANTUM): Remove, replacing with ...
      (selection_quantum): ... new function, which avoids overflow.
      All uses changed.
      (struct selection_data.size): Now ptrdiff_t, not int, to avoid
      assumption that selection length fits in 'int'.
      (x_reply_selection_request, x_handle_selection_request)
      (x_get_window_property, receive_incremental_selection)
      (x_get_window_property_as_lisp_data, selection_data_to_lisp_data)
      (lisp_data_to_selection_data, clean_local_selection_data):
      Use ptrdiff_t, not int, to record length of selection.
      (x_reply_selection_request, x_get_window_property)
      (receive_incremental_selection, x_property_data_to_lisp):
      Redo calculations to avoid overflow.
      (x_reply_selection_request): When sending hint, ceiling it at
      X_ULONG_MAX rather than relying on wraparound overflow to send
      something.
      (x_get_window_property, receive_incremental_selection)
      (lisp_data_to_selection_data, x_property_data_to_lisp):
      Check for size-calculation overflow.
      (x_get_window_property, receive_incremental_selection)
      (lisp_data_to_selection_data, Fx_register_dnd_atom):
      Don't store size until memory allocation succeeds.
      (x_get_window_property): Plug memory leak on memory exhaustion.
      Don't double-block input; malloc is safe here.  Don't assume 2**34
      - 4 fits in unsigned long.  Add an xassert to check
      XGetWindowProperty overflow.  Be more careful about overflow
      calculations, and distinguish size from memory overflow better.
      (receive_incremental_selection): When tracing, don't assume
      unsigned int is less than INT_MAX.
      (x_selection_data_to_lisp_data): Remove unnecessary (and in theory
      harmful) conversions of unsigned short to int.
      (lisp_data_to_selection_data): Don't assume that integers
      in the range -65535 through -1 fit in an X unsigned short.
      Don't assume that ULONG_MAX == X_ULONG_MAX.  Don't store into
      result parameters unless successful.  Rely on cons_to_unsigned
      to report problems with elements; the old code wasn't right anyway.
      (x_check_property_data): Check for int overflow; we cannot use
      a wider type due to X limits.
      (x_handle_dnd_message): Use unsigned int, to avoid int overflow.
      864d7ce7
  14. 13 Jul, 2011 1 commit
    • Johan Bockgård's avatar
      Fix execution of x selection hooks. · cd18e7e3
      Johan Bockgård authored
      * xselect.c (Qx_lost_selection_functions)
      (Qx_sent_selection_functions): New vars.
      (syms_of_xselect): DEFSYM them.
      (x_handle_selection_request): Pass Qx_sent_selection_functions
      rather than Vx_sent_selection_functions to Frun_hook_with_args.
      (x_handle_selection_clear,x_clear_frame_selections):
      Pass Qx_lost_selection_functions rather than
      Vx_lost_selection_functions to Frun_hook_with_args.
      cd18e7e3
  15. 07 Jul, 2011 1 commit
    • Paul Eggert's avatar
      * xselect.c: Integer signedness and overflow fixes. · ac82cc6a
      Paul Eggert authored
      (Fx_register_dnd_atom, x_handle_dnd_message):
      Use ptrdiff_t, not size_t, since we prefer signed.
      (Fx_register_dnd_atom): Check for ptrdiff_t (and size_t) overflow.
      * xterm.h (struct x_display_info): Use ptrdiff_t, not size_t, for
      x_dnd_atoms_size and x_dnd_atoms_length.
      ac82cc6a
  16. 21 Jun, 2011 1 commit
  17. 06 Jun, 2011 1 commit
    • Paul Eggert's avatar
      Check for overflow when converting integer to cons and back. · be44ca6c
      Paul Eggert authored
      * charset.c (Fdefine_charset_internal, Fdecode_char):
      Use cons_to_unsigned to catch overflow.
      (Fencode_char): Use INTEGER_TO_CONS.
      * composite.h (LGLYPH_CODE): Use cons_to_unsigned.
      (LGLYPH_SET_CODE): Use INTEGER_TO_CONS.
      * data.c (long_to_cons, cons_to_long): Remove.
      (cons_to_unsigned, cons_to_signed): New functions.
      These signal an error for invalid or out-of-range values.
      * dired.c (Ffile_attributes): Use INTEGER_TO_CONS.
      * fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER.
      * font.c (Ffont_variation_glyphs):
      * fontset.c (Finternal_char_font): Use INTEGER_TO_CONS.
      * lisp.h: Include <intprops.h>.
      (INTEGER_TO_CONS, CONS_TO_INTEGER): New macros.
      (cons_to_signed, cons_to_unsigned): New decls.
      (long_to_cons, cons_to_long): Remove decls.
      * undo.c (record_first_change): Use INTEGER_TO_CONS.
      (Fprimitive_undo): Use CONS_TO_INTEGER.
      * xfns.c (Fx_window_property): Likewise.
      * xselect.c: Include <limits.h>.
      (x_own_selection, selection_data_to_lisp_data):
      Use INTEGER_TO_CONS.
      (x_handle_selection_request, x_handle_selection_clear)
      (x_get_foreign_selection, Fx_disown_selection_internal)
      (Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER.
      (lisp_data_to_selection_data): Use cons_to_unsigned.
      (x_fill_property_data): Use cons_to_signed.
      Report values out of range.
      be44ca6c
  18. 04 Jun, 2011 2 commits
  19. 03 Jun, 2011 3 commits
    • Paul Eggert's avatar
      * xselect.c: Include <limits.h>. · aa76b908
      Paul Eggert authored
      aa76b908
    • Paul Eggert's avatar
      Check for overflow when converting integer to cons and back. · 201f31ae
      Paul Eggert authored
      * charset.c (Fdefine_charset_internal, Fdecode_char):
      Use cons_to_unsigned to catch overflow.
      (Fencode_char): Use INTEGER_TO_CONS.
      * composite.h (LGLYPH_CODE): Use cons_to_unsigned.
      (LGLYPH_SET_CODE): Use INTEGER_TO_CONS.
      * data.c (long_to_cons, cons_to_long): Remove.
      (cons_to_unsigned, cons_to_signed): New functions.
      These signal an error for invalid or out-of-range values.
      * dired.c (Ffile_attributes): Use INTEGER_TO_CONS.
      * fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER.
      * font.c (Ffont_variation_glyphs):
      * fontset.c (Finternal_char_font): Use INTEGER_TO_CONS.
      * lisp.h (INTEGER_TO_CONS, CONS_TO_INTEGER): New macros.
      (cons_to_signed, cons_to_unsigned): New decls.
      (long_to_cons, cons_to_long): Remove decls.
      * undo.c (record_first_change): Use INTEGER_TO_CONS.
      (Fprimitive_undo): Use CONS_TO_INTEGER.
      * xfns.c (Fx_window_property): Likewise.
      * xselect.c (x_own_selection, selection_data_to_lisp_data):
      Use INTEGER_TO_CONS.
      (x_handle_selection_request, x_handle_selection_clear)
      (x_get_foreign_selection, Fx_disown_selection_internal)
      (Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER.
      (lisp_data_to_selection_data): Use cons_to_unsigned.
      (x_fill_property_data): Use cons_to_signed.  Report values out of range.
      201f31ae
    • Paul Eggert's avatar
      * xselect.c: Use 'unsigned' more consistently. · 9ca05932
      Paul Eggert authored
      (selection_data_to_lisp_data, lisp_data_to_selection_data):
      Use 'unsigned' consistently when computing sizes of unsigned objects.
      9ca05932
  20. 29 May, 2011 2 commits
    • Paul Eggert's avatar
      Minor fixes prompted by GCC 4.6.0 warnings. · 0196f88a
      Paul Eggert authored
      * xselect.c (converted_selections, conversion_fail_tag): Now static.
      0196f88a
    • Chong Yidong's avatar
      Move clipboard-manager functionality out of hooks. · 1dd3c2d9
      Chong Yidong authored
      * lisp/select.el: Don't perform clipboard-manager saving in hooks;
      leave the hooks empty.
      
      * src/emacs.c (Fkill_emacs): Call x_clipboard_manager_save_all.
      * src/frame.c (delete_frame): Call x_clipboard_manager_save_frame.
      
      * src/xselect.c (x_clipboard_manager_save_frame)
      (x_clipboard_manager_save_all): New functions.
      (Fx_clipboard_manager_save): Lisp function deleted.
      
      * src/xterm.h: Update prototype.
      1dd3c2d9
  21. 27 May, 2011 3 commits
    • Stefan Monnier's avatar
    • Paul Eggert's avatar
      * xselect.c: Fix minor problems prompted by GCC 4.6.0 warnings. · fb1ac845
      Paul Eggert authored
      (x_handle_selection_request, frame_for_x_selection): Remove unused vars.
      (x_clipboard_manager_save): Now static.
      (Fx_clipboard_manager_save): Rename local to avoid shadowing.
      fb1ac845
    • Chong Yidong's avatar
      Support X clipboard managers. · a9f737ee
      Chong Yidong authored
      * lisp/select.el (xselect-convert-to-targets): Add MULTIPLE target to list.
      (xselect-convert-to-save-targets): New function.
      
      * src/xselect.c: Support for clipboard managers.
      (Vselection_alist): Move to termhooks.h as terminal-local var.
      (LOCAL_SELECTION): New macro.
      (x_atom_to_symbol): Handle x_display_info_for_display fail case.
      (symbol_to_x_atom): Remove gratuitous arg.
      (x_handle_selection_request, lisp_data_to_selection_data)
      (x_get_foreign_selection, Fx_register_dnd_atom): Callers changed.
      (x_own_selection, x_get_local_selection, x_convert_selection): New
      arg, specifying work frame.  Use terminal-local Vselection_alist.
      (some_frame_on_display): Delete unused function.
      (Fx_own_selection_internal, Fx_get_selection_internal)
      (Fx_disown_selection_internal, Fx_selection_owner_p)
      (Fx_selection_exists_p): New optional frame arg.
      (frame_for_x_selection, Fx_clipboard_manager_save): New functions.
      (x_handle_selection_clear): Don't treat other terminals with the
      same keyboard specially.  Use the terminal-local Vselection_alist.
      (x_clear_frame_selections): Use Frun_hook_with_args.
      
      * src/termhooks.h (Vselection_alist): Make it terminal-local.
      
      * src/terminal.c (create_terminal): Initialize it.
      
      * src/xterm.c (x_term_init): Intern ATOM and CLIPBOARD_MANAGER atoms.
      
      * src/xterm.h: Add support for those atoms.
      a9f737ee
  22. 26 May, 2011 2 commits
    • Chong Yidong's avatar
    • Chong Yidong's avatar
      * src/xselect.c: ICCCM-compliant handling of MULTIPLE targets. · e067f0c1
      Chong Yidong authored
      (converted_selections, conversion_fail_tag): New global variables.
      (x_selection_request_lisp_error): Free the above.
      (x_get_local_selection): Remove unnecessary code.
      (x_reply_selection_request): Args changed; handle arbitrary array
      of converted selections stored in converted_selections.  Separate
      the XChangeProperty and SelectionNotify steps.
      (x_handle_selection_request): Rewrite to handle MULTIPLE target.
      (x_convert_selection): New function.
      (x_handle_selection_event): Simplify.
      (x_get_foreign_selection): Don't ignore incoming requests while
      waiting for an answer; this will fail when we implement
      SAVE_TARGETS, and seems unnecessary anyway.
      (selection_data_to_lisp_data): Recognize ATOM_PAIR type.
      (Vx_sent_selection_functions): Doc fix.
      e067f0c1
  23. 22 May, 2011 3 commits
  24. 12 May, 2011 2 commits
  25. 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
       XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons.
       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.
       (XVECTORLIKE_HEADER_SIZE): Renamed from XVECTOR_HEADER_SIZE.
       All uses changed.
       (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR.
       (XSETTYPED_PVECTYPE): New macro, specifying the name of the size
       member.
       (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.
       (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR
       and XVECTOR_HEADER_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.
      14fe7b53
  26. 25 Apr, 2011 2 commits
    • Paul Eggert's avatar
      * lisp.h: (XVECTOR_SIZE): Remove. All uses replaced with ASIZE. · 77b37c05
      Paul Eggert authored
      (ASIZE): Now contains previous implementation of XVECTOR_SIZE
      instead of invoking XVECTOR_SIZE.
      77b37c05
    • Paul Eggert's avatar
      lisp.h: Fix a problem with aliasing and vector headers. · eab3844f
      Paul Eggert authored
      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
      XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons.
      * 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.
      (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR.
      (XSETTYPED_PVECTYPE): New macro, specifying the name of the size
      member.
      (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.
      (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR
      and XVECTOR_HEADER_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.
      * 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".
      * buffer.h (struct buffer): Likewise.
      * font.h (struct font_spec, struct font_entity, struct font): Likewise.
      * frame.h (struct frame): Likewise.
      * process.h (struct Lisp_Process): Likewise.
      * termhooks.h (struct terminal): Likewise.
      * window.c (struct save_window_data, struct saved_window): Likewise.
      * window.h (struct window): Likewise.
      * alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector):
      Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems.
      * buffer.c (init_buffer_once): Likewise.
      * lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a
      special case.
      * process.c (Fformat_network_address): Use local var for size,
      for brevity.
      eab3844f
  27. 19 Apr, 2011 3 commits
    • Paul Eggert's avatar
      Avoid 0 flag with %p printf format. · 6f04d126
      Paul Eggert authored
      6f04d126
    • Paul Eggert's avatar
      * xfns.c (Fx_window_property): Simplify a bit, · 2172544b
      Paul Eggert authored
      to make a bit faster and to avoid GCC 4.6.0 warning.
      * xselect.c (x_get_window_property, x_handle_dnd_message): Likewise.
      2172544b
    • Paul Eggert's avatar
      Replace pEd with more-general pI, and fix some printf arg casts. · c2982e87
      Paul Eggert authored
      * lisp.h (pI): New macro, generalizing old pEd macro to other
      conversion specifiers.  For example, use "...%"pI"d..." rather
      than "...%"pEd"...".
      (pEd): Remove.  All uses replaced with similar uses of pI.
      * src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h: Likewise.
      * alloc.c (check_pure_size): Don't overflow by converting size to int.
      * bidi.c (bidi_dump_cached_states): Use pI to avoid cast.
      * data.c (Fnumber_to_string): Use pI instead of if-then-else-abort.
      * dbusbind.c (xd_append_arg): Use pI to avoid cast.
      (Fdbus_method_return_internal, Fdbus_method_error_internal): Likewise.
      * font.c (font_unparse_xlfd): Avoid potential buffer overrun on
      64-bit hosts.
      (font_unparse_xlfd, font_unparse_fcname): Use pI to avoid casts.
      * keyboard.c (record_char, modify_event_symbol): Use pI to avoid casts.
      * print.c (safe_debug_print, print_object): Likewise.
      (print_object): Don't overflow by converting EMACS_INT or EMACS_UINT
      to int.
      Use pI instead of if-then-else-abort.  Use %p to avoid casts.
      * process.c (Fmake_network_process): Use pI to avoid cast.
      * region-cache.c (pp_cache): Likewise.
      * xdisp.c (decode_mode_spec): Likewise.
      * xrdb.c (x_load_resources) [USE_MOTIF]: Use pI to avoid undefined
      behavior on 64-bit hosts with printf arg.
      * xselect.c (x_queue_event): Use %p to avoid casts.
      (x_stop_queuing_selection_requests): Likewise.
      (x_get_window_property): Don't truncate byte count to an 'int'
      when tracing.
      c2982e87