Commit graph

31425 commits

Author SHA1 Message Date
Deniz Dogan
76147d94eb * src/process.c (Fset_process_buffer): Clarify return value in docstring. 2011-06-20 14:54:05 +02:00
Chong Yidong
7d7d00451f Fixes for GLYPH_DEBUG.
* dispnew.c (add_window_display_history): Use BVAR.

* xdisp.c (debug_method_add): Use BVAR.
(check_window_end, dump_glyph_matrix, dump_glyph)
(dump_glyph_row, dump_glyph_string): Convert arglist to ANSI C.

* xfaces.c (check_lface_attrs, check_lface, dump_realized_face):
Likewise.

* xfns.c (Fx_create_frame, x_create_tip_frame): Delay image cache
check till after the cache is created in init_frame_faces.
2011-06-18 15:15:06 -04:00
Stefan Monnier
ff2bc4101a * src/fns.c (Fsafe_length): Yet another int/Lisp_Object mixup. 2011-06-17 11:18:54 -04:00
Paul Eggert
dd3482fe59 * lisp.h: Include <limits.h>, for INT_MAX, LONG_MAX, LLONG_MAX.
Without this, prin1 mishandles Lisp_Misc_Save_Value printing on
hosts with pre-C99 libraries, because pD is wrongly defined to "t".
2011-06-16 15:50:46 -07:00
Paul Eggert
393d71f34c Improve buffer-overflow checking (Bug#8873). 2011-06-16 14:25:42 -07:00
Paul Eggert
1c8e352f7e Improve buffer-overflow checking.
* fileio.c (Finsert_file_contents):
* insdel.c (insert_from_buffer_1, replace_range, replace_range_2):
Remove the old (too-loose) buffer overflow checks.
They weren't needed, since make_gap checks for buffer overflow.
* insdel.c (make_gap_larger): Catch buffer overflows that were missed.
The old code merely checked for Emacs fixnum overflow, and relied
on undefined (wraparound) behavior.  The new code avoids undefined
behavior, and also checks for ptrdiff_t and/or size_t overflow.
2011-06-16 14:18:12 -07:00
Paul Eggert
21d890a4ec * editfns.c: Tune. Don't use wider integers than needed. Don't use alloca.
Use a bigger 'string' buffer.  Rewrite to avoid 'n > 0' test.
2011-06-16 10:44:43 -07:00
Paul Eggert
2e6813b0a5 * editfns.c (Finsert_char): Don't dump core with very negative counts. 2011-06-16 10:25:16 -07:00
Paul Eggert
599a9e4f7c * insdel.c (replace_range): Fix buf overflow when insbytes < outgoing. 2011-06-15 23:57:02 -07:00
Paul Eggert
9956144405 * insdel.c, lisp.h (buffer_overflow): New function.
(insert_from_buffer_1, replace_range, replace_range_2):
* insdel.c (make_gap_larger):
* editfns.c (Finsert_char):
* fileio.c (Finsert_file_contents): Use it, to normalize wording.
2011-06-15 23:48:01 -07:00
Paul Eggert
28177adde9 * buffer.h (BUF_BYTES_MAX): Cast to ptrdiff_t so that it's signed. 2011-06-15 23:19:26 -07:00
Paul Eggert
a7af7fdede Integer overflow and signedness fixes (Bug#8873). 2011-06-15 12:57:25 -07:00
Paul Eggert
b1c46f026d * ccl.c (ASCENDING_ORDER): New macro, to work around GCC bug 43772.
(GET_CCL_RANGE, IN_INT_RANGE): Use it.
2011-06-15 12:40:52 -07:00
Paul Eggert
096a9774c8 * fileio.c (emacs_lseek): Work around GCC bug 43772. 2011-06-15 12:29:18 -07:00
Paul Eggert
a2a0186171 * character.h, charset.h: Use verify_expr, not verify_true. 2011-06-15 11:57:45 -07:00
Paul Eggert
dfc926249a Merge from trunk. 2011-06-15 11:52:30 -07:00
Stefan Monnier
0ac306045f * src/eval.c (Fdefvaralias): Also mark the target as variable-special-p. 2011-06-15 14:36:00 -04:00
Paul Eggert
ff672d2c87 Merge from trunk. 2011-06-15 11:07:38 -07:00
Paul Eggert
e69dafade3 * fileio.c: Don't assume EMACS_INT fits in off_t.
(emacs_lseek): New static function.
(Finsert_file_contents, Fwrite_region): Use it.
Use SEEK_SET, SEEK_CUR, SEEK_END as appropriate.
2011-06-14 18:07:35 -07:00
Paul Eggert
566684ead5 * fns.c (Fload_average): Don't assume 100 * load average fits in int. 2011-06-14 16:18:53 -07:00
Paul Eggert
de41a81069 * fns.c (Fcopy_sequence): Don't assume vector length fits in int. 2011-06-14 15:41:38 -07:00
Paul Eggert
6346d30171 * fns.c (Fnthcdr, Fsort): Don't assume list length fits in int. 2011-06-14 15:39:35 -07:00
Paul Eggert
e6966cd635 * fns.c: Don't overflow int when computing a list length.
(Fsafe_length): Return a float if the value is not representable
as a fixnum.  This shouldn't happen except in contrived situations.
Use same QUIT_COUNT_HEURISTIC as Flength now does.
2011-06-14 15:32:12 -07:00
Paul Eggert
00c604f263 * fns.c (Flength): Don't overflow int when computing a list length.
Use EMACS_INT, not int, to avoid unwanted truncation on 64-bit hosts.
Check for QUIT every 1024 entries rather than every other entry;
that's faster and is responsive enough.  Report an error instead of
overflowing an integer.
2011-06-14 15:01:32 -07:00
Paul Eggert
dd0b0efbab * alloc.c: Check that resized vectors' lengths fit in fixnums.
(header_size, word_size): New constants.
(allocate_vectorlike): Don't check size overflow here.
(allocate_vector): Check it here instead, since this is the only
caller of allocate_vectorlike that could cause overflow.
Check that the new vector's length is representable as a fixnum.
2011-06-14 14:30:16 -07:00
Jan Djärv
c195f2de12 Fix resize and change of scroll bar width for Gtk3.
* configure.in: Add emacsgtkfixed.o to GTK_OBJ if HAVE_GTK3.

* src/emacsgtkfixed.c, src/emacsgtkfixed.h: New files.

* src/gtkutil.c: Include src/emacsgtkfixed.h if HAVE_GTK3.
(int_gtk_range_get_value): Move to the scroll bar part of the file.
(style_changed_cb): Call update_theme_scrollbar_width and call
x_set_scroll_bar_default_width and xg_frame_set_char_size for
all frames.
(xg_create_frame_widgets): Call emacs_fixed_new if HAVE_GTK3 (Bug#8505).
Call gtk_window_set_resizable if HAVE_GTK3.
(x_wm_set_size_hint): Call emacs_fixed_set_min_size with min width
and height if HAVE_GTK3 (Bug#8505).
(scroll_bar_width_for_theme): New variable.
(update_theme_scrollbar_width): New function.
(xg_get_default_scrollbar_width): Move code to
update_theme_scrollbar_width, just return scroll_bar_width_for_theme.
(xg_initialize): Call update_theme_scrollbar_width.

* src/gtkutil.h (xg_get_default_scrollbar_width): Remove argument.

* src/xfns.c (x_set_scroll_bar_default_width): Remove argument to
xg_get_default_scrollbar_width.
2011-06-14 23:08:20 +02:00
Paul Eggert
86fe5cfe4d * fns.c (next_almost_prime): Don't return a multiple of 3 or 5.
The previous code was bogus.  For example, next_almost_prime (32)
returned 39, which is undesirable as it is a multiple of 3; and
next_almost_prime (24) returned 25, which is a multiple of 5 so
why was the code bothering to check for multiples of 7?
2011-06-14 13:57:33 -07:00
Paul Eggert
80e88859ec * bytecode.c (exec_byte_code): Use ptrdiff_t, not int, for vector length. 2011-06-14 13:12:13 -07:00
Paul Eggert
4a2f0ad6c1 * eval.c, doprnt.c (SIZE_MAX): Remove; inttypes.h defines this now. 2011-06-14 13:09:52 -07:00
Paul Eggert
f66c7cf8f7 Variadic C functions now count arguments with ptrdiff_t.
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.
2011-06-14 11:57:19 -07:00
Paul Eggert
a1759b7624 * callint.c (Fcall_interactively): Don't use index var as event count. 2011-06-13 22:51:17 -07:00
Paul Eggert
d96be9fc87 * vm-limit.c (check_memory_limits): Fix incorrect extern function decls.
* mem-limits.h (SIZE): Remove; no longer used.
2011-06-13 21:49:24 -07:00
Paul Eggert
a690a978ec * xterm.c (x_alloc_nearest_color_1): Go back to original algorithm. 2011-06-13 09:08:46 -07:00
Paul Eggert
01103c441a Merge from trunk. 2011-06-13 01:00:15 -07:00
Paul Eggert
5efd304be9 * xterm.c (x_alloc_nearest_color_1): Use a more-precise algorithm
for nearest color, one that neither overflows nor relies on unsigned
arithmetic.
2011-06-13 00:53:14 -07:00
Paul Eggert
578c21e6cb Remove unnecessary casts.
* xterm.c (x_term_init):
* xfns.c (x_set_border_pixel):
* widget.c (create_frame_gcs): Remove casts to unsigned long etc.
These aren't needed now that we assume ANSI C.
2011-06-12 23:53:31 -07:00
Paul Eggert
96f53c6c3d * sound.c (Fplay_sound_internal): Remove cast to unsigned long.
It's more likely to cause problems (due to unsigned overflow)
than to cure them.
2011-06-12 23:49:00 -07:00
Paul Eggert
83c77d31ac * dired.c (Ffile_attributes): Don't use 32-bit hack on 64-bit hosts. 2011-06-12 23:34:04 -07:00
Paul Eggert
ee2079f16e * unexelf.c (unexec): Don't assume BSS addr fits in unsigned. 2011-06-12 22:55:57 -07:00
Paul Eggert
6da655361c * xterm.c (handle_one_xevent): Omit unnecessary casts to unsigned. 2011-06-12 22:49:35 -07:00
Paul Eggert
7147c4a44b * keyboard.c (modify_event_symbol): Don't limit alist len to UINT_MAX. 2011-06-12 22:43:30 -07:00
Paul Eggert
193e32d9a8 * lisp.h (CHAR_TABLE_SET): Omit now-redundant test. 2011-06-12 22:24:58 -07:00
Paul Eggert
e5533da60e * lread.c (Fload): Don't compare a possibly-garbage time_t value. 2011-06-12 22:18:27 -07:00
Paul Eggert
9910e595e7 GLYPH_CODE_FACE returns EMACS_INT, not int.
* dispextern.h (merge_faces):
* xfaces.c (merge_faces):
* xdisp.c (get_next_display_element):
(next_element_from_display_vector): Don't assume EMACS_INT fits in int.
2011-06-12 22:15:27 -07:00
Paul Eggert
2638320e07 * character.h (CHAR_VALID_P): Remove unused parameter.
* fontset.c, lisp.h, xdisp.c: All uses changed.
2011-06-12 21:55:03 -07:00
Paul Eggert
045eb8d982 * editfns.c (Ftranslate_region_internal): Omit redundant test. 2011-06-12 21:27:45 -07:00
Paul Eggert
c1f134b59b * fns.c (concat): Minor tuning based on overflow analysis.
This doesn't fix any bugs.  Use int to hold character, instead
of constantly refetching from Emacs object.  Use XFASTINT, not
XINT, for value known to be a character.  Don't bother comparing
a single byte to 0400, as it's always less.
2011-06-12 19:41:13 -07:00
Paul Eggert
395fcb936e * floatfns.c (Fexpt): Omit unnecessary cast to unsigned. 2011-06-12 19:27:16 -07:00
Paul Eggert
327eeec881 * fileio.c (make_temp_name): Omit unnecessary cast to unsigned. 2011-06-12 19:23:58 -07:00
Paul Eggert
abbd3d23f4 * editfns.c (Ftranslate_region_internal): Use int, not EMACS_INT
for characters.
2011-06-12 19:21:14 -07:00