aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-04-28 15:28:58 -0700
committerPaul Eggert2011-04-28 15:28:58 -0700
commitc7b270ab8559d9c9ca86ed5887b86b537796042d (patch)
tree45c40100a8557973cf3037009fdd2cdd37a1eb1b /src
parent49b14d65c3f6b0a981ca032c6801d2c39ab1591a (diff)
parenta8346e4904ebdd046bda23b3e16983279fcb2438 (diff)
downloademacs-c7b270ab8559d9c9ca86ed5887b86b537796042d.tar.gz
emacs-c7b270ab8559d9c9ca86ed5887b86b537796042d.zip
Merge from mainline.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/doprnt.c24
-rw-r--r--src/keyboard.c19
-rw-r--r--src/w32.c14
4 files changed, 66 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f9ca67e703d..45d7e7a9044 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -23,6 +23,23 @@
23 23
24 * fns.c (Frandom): Let EMACS_UINT be wider than unsigned long. 24 * fns.c (Frandom): Let EMACS_UINT be wider than unsigned long.
25 25
262011-04-28 Paul Eggert <eggert@cs.ucla.edu>
27
28 * doprnt.c (doprnt): Omit useless test; int overflow check (Bug#8545).
29 (SIZE_MAX): Move defn after all includes, as they might #define it.
30
312011-04-28 Juanma Barranquero <lekktu@gmail.com>
32
33 * w32.c (init_environment): Warn about defaulting HOME to C:\.
34
352011-04-28 Juanma Barranquero <lekktu@gmail.com>
36
37 * keyboard.c (Qdelayed_warnings_hook): Define.
38 (command_loop_1): Run `delayed-warnings-hook'
39 if Vdelayed_warnings_list is non-nil.
40 (syms_of_keyboard) <delayed-warnings-hook>: DEFSYM it.
41 (syms_of_keyboard) <delayed-warnings-list>: DEFVAR_LISP it.
42
262011-04-28 Eli Zaretskii <eliz@gnu.org> 432011-04-28 Eli Zaretskii <eliz@gnu.org>
27 44
28 * doprnt.c (doprnt): Don't return value smaller than the buffer 45 * doprnt.c (doprnt): Don't return value smaller than the buffer
diff --git a/src/doprnt.c b/src/doprnt.c
index 63dba9f5850..e9a68f9d219 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -70,7 +70,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
70 %<flags><width><precision><length>character 70 %<flags><width><precision><length>character
71 71
72 where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length 72 where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length
73 modifier is empty or l or ll. 73 is empty or l or ll. Also, %% in a format stands for a single % in the
74 output. A % that does not introduce a valid %-sequence causes
75 undefined behavior.
74 76
75 The + flag character inserts a + before any positive number, while a space 77 The + flag character inserts a + before any positive number, while a space
76 inserts a space before any positive number; these flags only affect %d, %o, 78 inserts a space before any positive number; these flags only affect %d, %o,
@@ -111,9 +113,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
111#include <unistd.h> 113#include <unistd.h>
112 114
113#include <limits.h> 115#include <limits.h>
114#ifndef SIZE_MAX
115# define SIZE_MAX ((size_t) -1)
116#endif
117 116
118#include "lisp.h" 117#include "lisp.h"
119 118
@@ -122,14 +121,21 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
122 another macro. */ 121 another macro. */
123#include "character.h" 122#include "character.h"
124 123
124#ifndef SIZE_MAX
125# define SIZE_MAX ((size_t) -1)
126#endif
127
125#ifndef DBL_MAX_10_EXP 128#ifndef DBL_MAX_10_EXP
126#define DBL_MAX_10_EXP 308 /* IEEE double */ 129#define DBL_MAX_10_EXP 308 /* IEEE double */
127#endif 130#endif
128 131
129/* Generate output from a format-spec FORMAT, 132/* Generate output from a format-spec FORMAT,
130 terminated at position FORMAT_END. 133 terminated at position FORMAT_END.
134 (*FORMAT_END is not part of the format, but must exist and be readable.)
131 Output goes in BUFFER, which has room for BUFSIZE chars. 135 Output goes in BUFFER, which has room for BUFSIZE chars.
132 If the output does not fit, truncate it to fit. 136 BUFSIZE must be positive. If the output does not fit, truncate it
137 to fit and return BUFSIZE - 1; if this truncates a multibyte
138 sequence, store '\0' into the sequence's first byte.
133 Returns the number of bytes stored into BUFFER, excluding 139 Returns the number of bytes stored into BUFFER, excluding
134 the terminating null byte. Output is always null-terminated. 140 the terminating null byte. Output is always null-terminated.
135 String arguments are passed as C strings. 141 String arguments are passed as C strings.
@@ -198,8 +204,12 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
198 while (fmt < format_end 204 while (fmt < format_end
199 && '0' <= fmt[1] && fmt[1] <= '9') 205 && '0' <= fmt[1] && fmt[1] <= '9')
200 { 206 {
201 if (n >= SIZE_MAX / 10 207 /* Avoid size_t overflow. Avoid int overflow too, as
202 || n * 10 > SIZE_MAX - (fmt[1] - '0')) 208 many sprintfs mishandle widths greater than INT_MAX.
209 This test is simple but slightly conservative: e.g.,
210 (INT_MAX - INT_MAX % 10) is reported as an overflow
211 even when it's not. */
212 if (n >= min (INT_MAX, SIZE_MAX) / 10)
203 error ("Format width or precision too large"); 213 error ("Format width or precision too large");
204 n = n * 10 + fmt[1] - '0'; 214 n = n * 10 + fmt[1] - '0';
205 *string++ = *++fmt; 215 *string++ = *++fmt;
diff --git a/src/keyboard.c b/src/keyboard.c
index fac098ddffd..a94456fce2e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -267,6 +267,8 @@ static Lisp_Object Qpost_command_hook;
267 267
268static Lisp_Object Qdeferred_action_function; 268static Lisp_Object Qdeferred_action_function;
269 269
270static Lisp_Object Qdelayed_warnings_hook;
271
270static Lisp_Object Qinput_method_exit_on_first_char; 272static Lisp_Object Qinput_method_exit_on_first_char;
271static Lisp_Object Qinput_method_use_echo_area; 273static Lisp_Object Qinput_method_use_echo_area;
272 274
@@ -1356,6 +1358,10 @@ command_loop_1 (void)
1356 if (!NILP (echo_area_buffer[0])) 1358 if (!NILP (echo_area_buffer[0]))
1357 resize_echo_area_exactly (); 1359 resize_echo_area_exactly ();
1358 1360
1361 /* If there are warnings waiting, process them. */
1362 if (!NILP (Vdelayed_warnings_list))
1363 safe_run_hooks (Qdelayed_warnings_hook);
1364
1359 if (!NILP (Vdeferred_action_list)) 1365 if (!NILP (Vdeferred_action_list))
1360 safe_run_hooks (Qdeferred_action_function); 1366 safe_run_hooks (Qdeferred_action_function);
1361 } 1367 }
@@ -1573,6 +1579,10 @@ command_loop_1 (void)
1573 if (!NILP (echo_area_buffer[0])) 1579 if (!NILP (echo_area_buffer[0]))
1574 resize_echo_area_exactly (); 1580 resize_echo_area_exactly ();
1575 1581
1582 /* If there are warnings waiting, process them. */
1583 if (!NILP (Vdelayed_warnings_list))
1584 safe_run_hooks (Qdelayed_warnings_hook);
1585
1576 safe_run_hooks (Qdeferred_action_function); 1586 safe_run_hooks (Qdeferred_action_function);
1577 1587
1578 /* If there is a prefix argument, 1588 /* If there is a prefix argument,
@@ -11498,6 +11508,7 @@ syms_of_keyboard (void)
11498 DEFSYM (Qpre_command_hook, "pre-command-hook"); 11508 DEFSYM (Qpre_command_hook, "pre-command-hook");
11499 DEFSYM (Qpost_command_hook, "post-command-hook"); 11509 DEFSYM (Qpost_command_hook, "post-command-hook");
11500 DEFSYM (Qdeferred_action_function, "deferred-action-function"); 11510 DEFSYM (Qdeferred_action_function, "deferred-action-function");
11511 DEFSYM (Qdelayed_warnings_hook, "delayed-warnings-hook");
11501 DEFSYM (Qfunction_key, "function-key"); 11512 DEFSYM (Qfunction_key, "function-key");
11502 DEFSYM (Qmouse_click, "mouse-click"); 11513 DEFSYM (Qmouse_click, "mouse-click");
11503 DEFSYM (Qdrag_n_drop, "drag-n-drop"); 11514 DEFSYM (Qdrag_n_drop, "drag-n-drop");
@@ -12069,6 +12080,14 @@ This function is called with no arguments after each command
12069whenever `deferred-action-list' is non-nil. */); 12080whenever `deferred-action-list' is non-nil. */);
12070 Vdeferred_action_function = Qnil; 12081 Vdeferred_action_function = Qnil;
12071 12082
12083 DEFVAR_LISP ("delayed-warnings-list", Vdelayed_warnings_list,
12084 doc: /* List of warnings to be displayed as soon as possible.
12085Each element must be a list (TYPE MESSAGE [LEVEL [BUFFER-NAME]]),
12086as per the args of `display-warning' (which see).
12087If this variable is non-nil, `delayed-warnings-hook' will be run
12088immediately after running `post-command-hook'. */);
12089 Vdelayed_warnings_list = Qnil;
12090
12072 DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings, 12091 DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings,
12073 doc: /* *Non-nil means show the equivalent key-binding when M-x command has one. 12092 doc: /* *Non-nil means show the equivalent key-binding when M-x command has one.
12074The value can be a length of time to show the message for. 12093The value can be a length of time to show the message for.
diff --git a/src/w32.c b/src/w32.c
index 2fbb3b6cb4c..230ccc8de10 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1561,6 +1561,7 @@ init_environment (char ** argv)
1561 char locale_name[32]; 1561 char locale_name[32];
1562 struct stat ignored; 1562 struct stat ignored;
1563 char default_home[MAX_PATH]; 1563 char default_home[MAX_PATH];
1564 int appdata = 0;
1564 1565
1565 static const struct env_entry 1566 static const struct env_entry
1566 { 1567 {
@@ -1614,7 +1615,10 @@ init_environment (char ** argv)
1614 1615
1615 /* If we can't get the appdata dir, revert to old behavior. */ 1616 /* If we can't get the appdata dir, revert to old behavior. */
1616 if (profile_result == S_OK) 1617 if (profile_result == S_OK)
1617 env_vars[0].def_value = default_home; 1618 {
1619 env_vars[0].def_value = default_home;
1620 appdata = 1;
1621 }
1618 } 1622 }
1619 } 1623 }
1620 1624
@@ -1701,6 +1705,14 @@ init_environment (char ** argv)
1701 lpval = env_vars[i].def_value; 1705 lpval = env_vars[i].def_value;
1702 dwType = REG_EXPAND_SZ; 1706 dwType = REG_EXPAND_SZ;
1703 dont_free = 1; 1707 dont_free = 1;
1708 if (!strcmp (env_vars[i].name, "HOME") && !appdata)
1709 {
1710 Lisp_Object warning[2];
1711 warning[0] = intern ("initialization");
1712 warning[1] = build_string ("Setting HOME to C:\\ by default is deprecated");
1713 Vdelayed_warnings_list = Fcons (Flist (2, warning),
1714 Vdelayed_warnings_list);
1715 }
1704 } 1716 }
1705 1717
1706 if (lpval) 1718 if (lpval)