1. 16 Sep, 2011 1 commit
  2. 09 Sep, 2011 1 commit
  3. 29 Aug, 2011 1 commit
  4. 20 Aug, 2011 2 commits
  5. 17 Aug, 2011 1 commit
  6. 05 Aug, 2011 1 commit
  7. 28 Jul, 2011 1 commit
  8. 07 Jul, 2011 1 commit
    • Paul Eggert's avatar
      * doprnt.c: Prefer signed to unsigned when either works. · c2d1e36d
      Paul Eggert authored
      * eval.c (verror):
      * doprnt.c (doprnt):
      * lisp.h (doprnt):
      * xdisp.c (vmessage):
      Use ptrdiff_t, not size_t, when using or implementing doprnt,
      since the sizes cannot exceed ptrdiff_t bounds anyway, and we
      prefer signed arithmetic to avoid comparison confusion.
      * doprnt.c (doprnt): Avoid a "+ 1" that can't overflow,
      but is a bit tricky.
      c2d1e36d
  9. 05 Jul, 2011 1 commit
  10. 04 Jul, 2011 1 commit
  11. 01 Jul, 2011 1 commit
    • Paul Eggert's avatar
      * eval.c (struct backtrace): Simplify and port the data structure. · bbc6b304
      Paul Eggert authored
      Do not assume that "int nargs : BITS_PER_INT - 2;" produces a
      signed bit field, as this assumption is not portable and it makes
      Emacs crash when compiled with Sun C 5.8 on sparc.  Do not use
      "char debug_on_exit : 1" as this is not portable either; instead,
      use the portable "unsigned int debug_on_exit : 1".  Remove unused
      member evalargs.  Remove obsolete comments about cc bombing out.
      bbc6b304
  12. 24 Jun, 2011 1 commit
  13. 15 Jun, 2011 1 commit
  14. 14 Jun, 2011 2 commits
    • Paul Eggert's avatar
    • 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.
      f66c7cf8
  15. 08 Jun, 2011 1 commit
    • Paul Eggert's avatar
      * alloc.c: Catch some string size overflows that we were missing. · c9d624c6
      Paul Eggert authored
      (XMALLOC_OVERRUN_CHECK_SIZE) [!XMALLOC_OVERRUN_CHECK]: Define to 0,
      for convenience in STRING_BYTES_MAX.
      (STRING_BYTES_MAX): New macro, superseding the old one in lisp.h.
      The definition here is exact; the one in lisp.h was approximate.
      (allocate_string_data): Check for string overflow.  This catches
      some instances we weren't catching before.  Also, it catches
      size_t overflow on (unusual) hosts where SIZE_MAX <= min
      (PTRDIFF_MAX, MOST_POSITIVE_FIXNUM), e.g., when size_t is 32 bits
      and ptrdiff_t and EMACS_INT are both 64 bits.
      * character.c, coding.c, doprnt.c, editfns.c, eval.c:
      All uses of STRING_BYTES_MAX replaced by STRING_BYTES_BOUND.
      * lisp.h (STRING_BYTES_BOUND): Renamed from STRING_BYTES_MAX.
      c9d624c6
  16. 06 Jun, 2011 1 commit
    • Paul Eggert's avatar
      Check for buffer and string overflow more precisely. · d1f3d2af
      Paul Eggert authored
      * buffer.h (BUF_BYTES_MAX): New macro.
      * lisp.h (STRING_BYTES_MAX): New macro.
      * alloc.c (Fmake_string):
      * character.c (string_escape_byte8):
      * coding.c (coding_alloc_by_realloc):
      * doprnt.c (doprnt):
      * editfns.c (Fformat):
      * eval.c (verror):
      Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM,
      since they may not be the same number.
      * editfns.c (Finsert_char):
      * fileio.c (Finsert_file_contents):
      Likewise for BUF_BYTES_MAX.
      d1f3d2af
  17. 04 Jun, 2011 1 commit
    • Paul Eggert's avatar
      Check for buffer and string overflow more precisely. · edaa1822
      Paul Eggert authored
      * buffer.h (BUF_BYTES_MAX): New macro.
      * lisp.h (STRING_BYTES_MAX): New macro.
      * alloc.c (Fmake_string):
      * character.c (string_escape_byte8):
      * coding.c (coding_alloc_by_realloc):
      * doprnt.c (doprnt):
      * editfns.c (Fformat):
      * eval.c (verror):
      Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM,
      since they may not be the same number.
      * editfns.c (Finsert_char):
      * fileio.c (Finsert_file_contents):
      Likewise for BUF_BYTES_MAX.
      edaa1822
  18. 30 May, 2011 1 commit
    • Paul Eggert's avatar
      * eval.c (Qdebug): Now static. · ed008a6d
      Paul Eggert authored
      * lisp.h (Qdebug): Remove decl.  This reverts a part of the
      2011-04-26T11:26:05Z!dan.colascione@gmail.com that inadvertently undid part of
      2011-04-14T06:48:41Z!eggert@cs.ucla.edu.
      ed008a6d
  19. 04 May, 2011 2 commits
  20. 29 Apr, 2011 1 commit
  21. 28 Apr, 2011 1 commit
  22. 27 Apr, 2011 1 commit
    • Eli Zaretskii's avatar
      Improve `doprnt' and its usage. (Bug#8545) · 94dcfacf
      Eli Zaretskii authored
       src/doprnt.c (doprnt): Make sure `format' is never accessed beyond
       `format_end'.  Remove support for %l as a conversion specifier.
       Don't use xrealloc.  Improve diagnostics when the %l size modifier
       is used.  Update the commentary.
       src/eval.c (verror): Simplify calculation of size_t.
       src/coding.c (Ffind_operation_coding_system): Fix diagnostic error
       messages.
      94dcfacf
  23. 26 Apr, 2011 1 commit
  24. 25 Apr, 2011 1 commit
    • Eli Zaretskii's avatar
      Improve doprnt and its use in verror. (Bug#8545) · 825cd63c
      Eli Zaretskii authored
       src/doprnt.c (doprnt): Document the set of format control sequences
       supported by the function.  Use SAFE_ALLOCA instead of always
       using `alloca'.
       src/eval.c (verror): Don't limit the buffer size at size_max-1, that
       is one byte too soon.  Don't use xrealloc; instead xfree and
       xmalloc anew.
      825cd63c
  25. 23 Apr, 2011 1 commit
    • Eli Zaretskii's avatar
      Fix doprnt so it could be used safely in `verror'. (Bug#8435) · e6c3da20
      Eli Zaretskii authored
       src/doprnt.c: Include limits.h.
       (SIZE_MAX): New macro.
       (doprnt): Return a size_t value.  2nd arg is now size_t.  Many
       local variables are now size_t instead of int or unsigned.
       Improve overflow protection.  Support `l' modifier for integer
       conversions.  Support %l conversion.  Don't assume an EMACS_INT
       argument for integer conversions and for %c.
       src/lisp.h (doprnt): Restore prototype.
       src/makefile.w32-in ($(BLD)/callint.$(O)): Depend on
       $(SRC)/character.h.
       src/Makefile.in (base_obj): Add back doprnt.o.
       src/deps.mk (doprnt.o): Add back prerequisites.
       (callint.o): Depend on character.h.
       src/eval.c (internal_lisp_condition_case): Include the handler
       representation in the error message.
       (verror): Call doprnt instead of vsnprintf.  Fix an off-by-one bug
       when breaking from the loop.
       src/xdisp.c (vmessage): Call doprnt instead of vsnprintf.
       src/callint.c (Fcall_interactively): When displaying error message
       about invalid control letter, pass the character's codepoint, not
       a pointer to its multibyte form.  Improve display of the character
       in octal and display also its hex code.
       src/character.c (char_string): Use %x to display the (unsigned)
       codepoint of an invalid character, to avoid displaying a bogus
       negative value.
       src/font.c (check_otf_features): Pass SDATA of SYMBOL_NAME to
       `error', not SYMBOL_NAME itself.
       src/coding.c (Fencode_sjis_char, Fencode_big5_char): Use %c for
       character arguments to `error'.
       src/charset.c (check_iso_charset_parameter): Fix incorrect argument
       to `error' in error message about FINAL_CHAR argument.  Make sure
       FINAL_CHAR is a character, and use %c when it is passed as
       argument to `error'.
      e6c3da20
  26. 16 Apr, 2011 1 commit
  27. 14 Apr, 2011 2 commits
  28. 13 Apr, 2011 1 commit
  29. 11 Apr, 2011 3 commits
    • Paul Eggert's avatar
      alloc.c: Import and export fewer symbols, and remove unused items. · 244ed907
      Paul Eggert authored
      * lisp.h (suppress_checking, die): Declare only if ENABLE_CHECKING
      is defined.
      (suppress_checking): Add EXTERNALLY_VISIBLE attribute, so that
      it's not optimized away by whole-program optimization.
      (message_enable_multibyte, free_misc): Remove.
      (catchlist, handlerlist, mark_backtrace):
      Declare only if BYTE_MARK_STACK.
      (mark_byte_stack): Likewise, fixing a ifdef-vs-if typo.
      * alloc.c (pure): Export only if VIRT_ADDR_VARIES is defined.
      (message_enable_multibyte): Remove decl.
      (free_misc, interval_free_list, float_block, float_block_index):
      (n_float_blocks, float_free_list, cons_block, cons_block_index):
      (cons_free_list, last_marked_index):
      Now static.
      (suppress_checking, die): Define only if ENABLE_CHECKING is defined.
      * eval.c (catchlist, handlerlist): Export only if BYTE_MARK_STACK.
      (mark_backtrace): Define only if BYTE_MARK_STACK.
      * xdisp.c (message_enable_multibyte): Now static.
      244ed907
    • Paul Eggert's avatar
      Declare Lisp_Object Q* variables to be 'static' if not exproted. · 955cbe7b
      Paul Eggert authored
      This makes it easier for human readers (and static analyzers)
      to see whether these variables are used from other modules.
      * alloc.c, buffer.c, bytecode.c, callint.c, casetab.c, category.c:
      * ccl.c, character.c, charset.c, cmds.c, coding.c, composite.c:
      * data.c, dbusbind.c, dired.c, editfns.c, eval.c, fileio.c, fns.c:
      * font.c, frame.c, fringe.c, ftfont.c, image.c, keyboard.c, keymap.c:
      * lread.c, macros.c, minibuf.c, print.c, process.c, search.c:
      * sound.c, syntax.c, textprop.c, window.c, xdisp.c, xfaces.c, xfns.c:
      * xmenu.c, xselect.c:
      Declare Q* vars static if they are not used in other modules.
      * ccl.h, character.h, charset.h, coding.h, composite.h, font.h:
      * frame.h, intervals.h, keyboard.h, lisp.h, process.h, syntax.h:
      Remove decls of unexported vars.
      * keyboard.h (EVENT_HEAD_UNMODIFIED): Remove now-unused macro.
      955cbe7b
    • Paul Eggert's avatar
      Make Emacs functions such as Fatom 'static' by default. · 16a97296
      Paul Eggert authored
      This makes it easier for human readers (and static analyzers)
      to see whether these functions can be called from other modules.
      DEFUN now defines a static function.  To make the function external
      so that it can be used in other C modules, use the new macro DEFUE.
      * lisp.h (DEFINE_FUNC): New macro, with the old contents of DEFUN.
      (DEFUN): Rewrite in terms of DEFINE_FUNC.  It now generates a
      static function definition.  Use DEFUE if you want an extern one.
      (DEFUE, INFUN): New macros.
      (Funibyte_char_to_multibyte, Fsyntax_table_p, Finit_image_library):
      (Feval_region, Fbacktrace, Ffetch_bytecode, Fswitch_to_buffer):
      (Ffile_executable_p, Fmake_symbolic_link, Fcommand_execute):
      (Fget_process, Fdocumentation_property, Fbyte_code, Ffile_attributes):
      Remove decls, since these functions are now static.
      (Funintern, Fget_internal_run_time): New decls, since these functions
      were already external.
      * alloc.c, buffer.c, callint.c, callproc.c, casefiddle.c, casetab.c:
      * ccl.c, character.c, chartab.c, cmds.c, coding.c, data.c, dispnew.c:
      * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, floatfns.c:
      * fns.c, font.c, fontset.c, frame.c, image.c, indent.c:
      * keyboard.c, keymap.c, lread.c:
      * macros.c, marker.c, menu.c, minibuf.c, print.c, process.c, search.c:
      * syntax.c, term.c, terminal.c, textprop.c, undo.c:
      * window.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xsettings.c:
      Mark functions with DEFUE instead of DEFUN,
      if they are used in other modules.
      * buffer.c (Fset_buffer_major_mode, Fdelete_overlay): New forward
      decls for now-static functions.
      * buffer.h (Fdelete_overlay): Remove decl.
      * callproc.c (Fgetenv_internal): Mark as internal.
      * composite.c (Fremove_list_of_text_properties): Remove decl.
      (Fcomposition_get_gstring): New forward static decl.
      * composite.h (Fcomposite_get_gstring): Remove decl.
      * dired.c (Ffile_attributes): New forward static decl.
      * doc.c (Fdocumntation_property): New forward static decl.
      * eval.c (Ffetch_bytecode): New forward static decl.
      (Funintern): Remove extern decl; now in .h file where it belongs.
      * fileio.c (Fmake_symbolic_link): New forward static decl.
      * image.c (Finit_image_library): New forward static decl.
      * insdel.c (Fcombine_after_change_execute): Make forward decl static.
      * intervals.h (Fprevious_property_change):
      (Fremove_list_of_text_properties): Remove decls.
      * keyboard.c (Fthis_command_keys): Remove decl.
      (Fcommand_execute): New forward static decl.
      * keymap.c (Flookup_key): New forward static decl.
      (Fcopy_keymap): Now static.
      * keymap.h (Flookup_key): Remove decl.
      * process.c (Fget_process): New forward static decl.
      (Fprocess_datagram_address): Mark as internal.
      * syntax.c (Fsyntax_table_p): New forward static decl.
      (skip_chars): Remove duplicate decl.
      * textprop.c (Fprevious_property_change): New forward static decl.
      * window.c (Fset_window_fringes, Fset_window_scroll_bars):
      Now internal.
      (Fset_window_margins, Fset_window_vscroll): New forward static decls.
      * window.h (Fset_window_vscroll, Fset_window_margins): Remove decls.
      16a97296
  30. 08 Apr, 2011 1 commit
    • Paul Eggert's avatar
      * eval.c: Port to Windows vsnprintf (Bug#8435). · eb3f1cc8
      Paul Eggert authored
      Include <limits.h>.
      (SIZE_MAX): Define if the headers do not.
      (verror): Do not give up if vsnprintf returns a negative count.
      Instead, grow the buffer.  This ports to Windows vsnprintf, which
      does not conform to C99.  Problem reported by Eli Zaretskii.
      Also, simplify the allocation scheme, by avoiding the need for
      calling realloc, and removing the ALLOCATED variable.
      eb3f1cc8
  31. 07 Apr, 2011 3 commits
    • Paul Eggert's avatar
    • Paul Eggert's avatar
      error: Print 32- and 64-bit integers portably (Bug#8435). · 5fdb398c
      Paul Eggert authored
      Without this change, on typical 64-bit hosts error ("...%d...", N)
      was used to print both 32- and 64-bit integers N, which relied on
      undefined behavior.
      * lisp.h, src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h (pEd):
      New macro.
      * lisp.h (error, verror): Mark as printf-like functions.
      * eval.c (verror): Use vsnprintf, not doprnt, to do the real work.
      Report overflow in size calculations when allocating printf buffer.
      Do not truncate output string at its first null byte.
      * xdisp.c (vmessage): Use vsnprintf, not doprnt, to do the real work.
      Truncate the output at a character boundary, since vsnprintf does not
      do that.
      * charset.c (check_iso_charset_parameter): Convert internal
      character to string before calling 'error', since %c now has the
      printf meaning.
      * coding.c (Fdecode_sjis_char, Fdecode_big5_char): Avoid int
      overflow when computing char to be passed to 'error'.  Do not
      pass Lisp_Object to 'error'; pass the integer instead.
      * nsfns.m (Fns_do_applescript): Use int, not long, since it's
      formatted with plain %d.
      5fdb398c
    • Paul Eggert's avatar
  32. 05 Apr, 2011 1 commit