diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-28 15:28:58 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-28 15:28:58 -0700 |
commit | c7b270ab8559d9c9ca86ed5887b86b537796042d (patch) | |
tree | 45c40100a8557973cf3037009fdd2cdd37a1eb1b /src | |
parent | 49b14d65c3f6b0a981ca032c6801d2c39ab1591a (diff) | |
parent | a8346e4904ebdd046bda23b3e16983279fcb2438 (diff) | |
download | emacs-c7b270ab8559d9c9ca86ed5887b86b537796042d.tar.gz emacs-c7b270ab8559d9c9ca86ed5887b86b537796042d.tar.bz2 emacs-c7b270ab8559d9c9ca86ed5887b86b537796042d.zip |
Merge from mainline.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 17 | ||||
-rw-r--r-- | src/doprnt.c | 24 | ||||
-rw-r--r-- | src/keyboard.c | 19 | ||||
-rw-r--r-- | src/w32.c | 14 |
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 @@ * fns.c (Frandom): Let EMACS_UINT be wider than unsigned long. +2011-04-28 Paul Eggert <eggert@cs.ucla.edu> + + * doprnt.c (doprnt): Omit useless test; int overflow check (Bug#8545). + (SIZE_MAX): Move defn after all includes, as they might #define it. + +2011-04-28 Juanma Barranquero <lekktu@gmail.com> + + * w32.c (init_environment): Warn about defaulting HOME to C:\. + +2011-04-28 Juanma Barranquero <lekktu@gmail.com> + + * 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. + 2011-04-28 Eli Zaretskii <eliz@gnu.org> * 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/>. */ %<flags><width><precision><length>character where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length - modifier is empty or l or ll. + is empty or l or ll. Also, %% in a format stands for a single % in the + output. A % that does not introduce a valid %-sequence causes + undefined behavior. The + flag character inserts a + before any positive number, while a space 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/>. */ #include <unistd.h> #include <limits.h> -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif #include "lisp.h" @@ -122,14 +121,21 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ another macro. */ #include "character.h" +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + #ifndef DBL_MAX_10_EXP #define DBL_MAX_10_EXP 308 /* IEEE double */ #endif /* Generate output from a format-spec FORMAT, terminated at position FORMAT_END. + (*FORMAT_END is not part of the format, but must exist and be readable.) Output goes in BUFFER, which has room for BUFSIZE chars. - If the output does not fit, truncate it to fit. + BUFSIZE must be positive. If the output does not fit, truncate it + to fit and return BUFSIZE - 1; if this truncates a multibyte + sequence, store '\0' into the sequence's first byte. Returns the number of bytes stored into BUFFER, excluding the terminating null byte. Output is always null-terminated. String arguments are passed as C strings. @@ -198,8 +204,12 @@ doprnt (char *buffer, register size_t bufsize, const char *format, while (fmt < format_end && '0' <= fmt[1] && fmt[1] <= '9') { - if (n >= SIZE_MAX / 10 - || n * 10 > SIZE_MAX - (fmt[1] - '0')) + /* Avoid size_t overflow. Avoid int overflow too, as + many sprintfs mishandle widths greater than INT_MAX. + This test is simple but slightly conservative: e.g., + (INT_MAX - INT_MAX % 10) is reported as an overflow + even when it's not. */ + if (n >= min (INT_MAX, SIZE_MAX) / 10) error ("Format width or precision too large"); n = n * 10 + fmt[1] - '0'; *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; static Lisp_Object Qdeferred_action_function; +static Lisp_Object Qdelayed_warnings_hook; + static Lisp_Object Qinput_method_exit_on_first_char; static Lisp_Object Qinput_method_use_echo_area; @@ -1356,6 +1358,10 @@ command_loop_1 (void) if (!NILP (echo_area_buffer[0])) resize_echo_area_exactly (); + /* If there are warnings waiting, process them. */ + if (!NILP (Vdelayed_warnings_list)) + safe_run_hooks (Qdelayed_warnings_hook); + if (!NILP (Vdeferred_action_list)) safe_run_hooks (Qdeferred_action_function); } @@ -1573,6 +1579,10 @@ command_loop_1 (void) if (!NILP (echo_area_buffer[0])) resize_echo_area_exactly (); + /* If there are warnings waiting, process them. */ + if (!NILP (Vdelayed_warnings_list)) + safe_run_hooks (Qdelayed_warnings_hook); + safe_run_hooks (Qdeferred_action_function); /* If there is a prefix argument, @@ -11498,6 +11508,7 @@ syms_of_keyboard (void) DEFSYM (Qpre_command_hook, "pre-command-hook"); DEFSYM (Qpost_command_hook, "post-command-hook"); DEFSYM (Qdeferred_action_function, "deferred-action-function"); + DEFSYM (Qdelayed_warnings_hook, "delayed-warnings-hook"); DEFSYM (Qfunction_key, "function-key"); DEFSYM (Qmouse_click, "mouse-click"); DEFSYM (Qdrag_n_drop, "drag-n-drop"); @@ -12069,6 +12080,14 @@ This function is called with no arguments after each command whenever `deferred-action-list' is non-nil. */); Vdeferred_action_function = Qnil; + DEFVAR_LISP ("delayed-warnings-list", Vdelayed_warnings_list, + doc: /* List of warnings to be displayed as soon as possible. +Each element must be a list (TYPE MESSAGE [LEVEL [BUFFER-NAME]]), +as per the args of `display-warning' (which see). +If this variable is non-nil, `delayed-warnings-hook' will be run +immediately after running `post-command-hook'. */); + Vdelayed_warnings_list = Qnil; + DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings, doc: /* *Non-nil means show the equivalent key-binding when M-x command has one. The 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) char locale_name[32]; struct stat ignored; char default_home[MAX_PATH]; + int appdata = 0; static const struct env_entry { @@ -1614,7 +1615,10 @@ init_environment (char ** argv) /* If we can't get the appdata dir, revert to old behavior. */ if (profile_result == S_OK) - env_vars[0].def_value = default_home; + { + env_vars[0].def_value = default_home; + appdata = 1; + } } } @@ -1701,6 +1705,14 @@ init_environment (char ** argv) lpval = env_vars[i].def_value; dwType = REG_EXPAND_SZ; dont_free = 1; + if (!strcmp (env_vars[i].name, "HOME") && !appdata) + { + Lisp_Object warning[2]; + warning[0] = intern ("initialization"); + warning[1] = build_string ("Setting HOME to C:\\ by default is deprecated"); + Vdelayed_warnings_list = Fcons (Flist (2, warning), + Vdelayed_warnings_list); + } } if (lpval) |