aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2015-05-30 11:17:56 -0700
committerPaul Eggert2015-05-30 11:19:31 -0700
commit75f8653bfe0da39acca9dbcb8b021ad033ac6ae9 (patch)
tree13d34ab47fac65374d374a7ea8e9d9b220b16f3f
parent85aa6ede9fe1b8165a99a4046dd8262ec93a02d5 (diff)
downloademacs-75f8653bfe0da39acca9dbcb8b021ad033ac6ae9.tar.gz
emacs-75f8653bfe0da39acca9dbcb8b021ad033ac6ae9.zip
Don't misencode C-generated messages
Also, be more consistent about calls to 'Fmessage' vs 'message'. * src/alloc.c (Fgc_status): Prefer AUTO_STRING to build_string for Fmessage call. * src/data.c (Fmake_variable_buffer_local) (Fmake_local_variable, Fmake_variable_frame_local): * src/doc.c (store_function_docstring): Use Fmessage, not message, since the argument can contain non-ASCII characters, and this can cause the resulting message to be incorrectly encoded for the current environment. * src/fns.c (maybe_resize_hash_table): * src/xselect.c (x_clipboard_manager_save_all): Use message, not Fmessage, since Fmessage's power isn't needed here. * src/process.c (Fmake_network_process): Reword message to avoid %s. * src/xdisp.c (vmessage): Document restrictions on message contents. (message_nolog) [false]: Remove unused code.
-rw-r--r--src/alloc.c6
-rw-r--r--src/data.c27
-rw-r--r--src/doc.c9
-rw-r--r--src/fns.c3
-rw-r--r--src/process.c3
-rw-r--r--src/xdisp.c24
-rw-r--r--src/xselect.c3
7 files changed, 36 insertions, 39 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 030c6e06ba8..14baf291bd8 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4542,9 +4542,9 @@ DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "",
4542 Lisp_Object zombie_list = Qnil; 4542 Lisp_Object zombie_list = Qnil;
4543 for (int i = 0; i < min (MAX_ZOMBIES, nzombies); i++) 4543 for (int i = 0; i < min (MAX_ZOMBIES, nzombies); i++)
4544 zombie_list = Fcons (zombies[i], zombie_list); 4544 zombie_list = Fcons (zombies[i], zombie_list);
4545 return CALLN (Fmessage, 4545 AUTO_STRING (format, ("%d GCs, avg live/zombies = %.2f/%.2f (%f%%),"
4546 build_string ("%d GCs, avg live/zombies = %.2f/%.2f" 4546 " max %d/%d\nzombies: %S"));
4547 " (%f%%), max %d/%d\nzombies: %S"), 4547 return CALLN (Fmessage, format,
4548 make_number (ngcs), make_float (avg_live), 4548 make_number (ngcs), make_float (avg_live),
4549 make_float (avg_zombies), 4549 make_float (avg_zombies),
4550 make_float (avg_zombies / avg_live / 100), 4550 make_float (avg_zombies / avg_live / 100),
diff --git a/src/data.c b/src/data.c
index c96841aebbf..7bc080fdf84 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1647,8 +1647,10 @@ The function `default-value' gets the default value and `set-default' sets it.
1647 Lisp_Object symbol; 1647 Lisp_Object symbol;
1648 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ 1648 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */
1649 if (let_shadows_global_binding_p (symbol)) 1649 if (let_shadows_global_binding_p (symbol))
1650 message ("Making %s buffer-local while let-bound!", 1650 {
1651 SDATA (SYMBOL_NAME (variable))); 1651 AUTO_STRING (format, "Making %s buffer-local while let-bound!");
1652 CALLN (Fmessage, format, SYMBOL_NAME (variable));
1653 }
1652 } 1654 }
1653 } 1655 }
1654 1656
@@ -1730,9 +1732,11 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1730 Lisp_Object symbol; 1732 Lisp_Object symbol;
1731 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ 1733 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */
1732 if (let_shadows_global_binding_p (symbol)) 1734 if (let_shadows_global_binding_p (symbol))
1733 message ("Making %s local to %s while let-bound!", 1735 {
1734 SDATA (SYMBOL_NAME (variable)), 1736 AUTO_STRING (format, "Making %s local to %s while let-bound!");
1735 SDATA (BVAR (current_buffer, name))); 1737 CALLN (Fmessage, format, SYMBOL_NAME (variable),
1738 BVAR (current_buffer, name));
1739 }
1736 } 1740 }
1737 } 1741 }
1738 1742
@@ -1742,8 +1746,11 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1742 if (NILP (tem)) 1746 if (NILP (tem))
1743 { 1747 {
1744 if (let_shadows_buffer_binding_p (sym)) 1748 if (let_shadows_buffer_binding_p (sym))
1745 message ("Making %s buffer-local while locally let-bound!", 1749 {
1746 SDATA (SYMBOL_NAME (variable))); 1750 AUTO_STRING (format,
1751 "Making %s buffer-local while locally let-bound!");
1752 CALLN (Fmessage, format, SYMBOL_NAME (variable));
1753 }
1747 1754
1748 /* Swap out any local binding for some other buffer, and make 1755 /* Swap out any local binding for some other buffer, and make
1749 sure the current value is permanently recorded, if it's the 1756 sure the current value is permanently recorded, if it's the
@@ -1908,8 +1915,10 @@ frame-local bindings). */)
1908 Lisp_Object symbol; 1915 Lisp_Object symbol;
1909 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ 1916 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */
1910 if (let_shadows_global_binding_p (symbol)) 1917 if (let_shadows_global_binding_p (symbol))
1911 message ("Making %s frame-local while let-bound!", 1918 {
1912 SDATA (SYMBOL_NAME (variable))); 1919 AUTO_STRING (format, "Making %s frame-local while let-bound!");
1920 CALLN (Fmessage, format, SYMBOL_NAME (variable));
1921 }
1913 } 1922 }
1914 return variable; 1923 return variable;
1915} 1924}
diff --git a/src/doc.c b/src/doc.c
index 32d65563fd9..f1ba64359a6 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -516,8 +516,13 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
516 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) 516 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
517 ASET (fun, COMPILED_DOC_STRING, make_number (offset)); 517 ASET (fun, COMPILED_DOC_STRING, make_number (offset));
518 else 518 else
519 message ("No docstring slot for %s", 519 {
520 SYMBOLP (obj) ? SSDATA (SYMBOL_NAME (obj)) : "<anonymous>"); 520 AUTO_STRING (format, "No docstring slot for %s");
521 CALLN (Fmessage, format,
522 (SYMBOLP (obj)
523 ? SYMBOL_NAME (obj)
524 : build_string ("<anonymous>")));
525 }
521 } 526 }
522} 527}
523 528
diff --git a/src/fns.c b/src/fns.c
index 51f61d23881..939760b7394 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3954,8 +3954,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3954#ifdef ENABLE_CHECKING 3954#ifdef ENABLE_CHECKING
3955 if (HASH_TABLE_P (Vpurify_flag) 3955 if (HASH_TABLE_P (Vpurify_flag)
3956 && XHASH_TABLE (Vpurify_flag) == h) 3956 && XHASH_TABLE (Vpurify_flag) == h)
3957 CALLN (Fmessage, build_string ("Growing hash table to: %d"), 3957 message ("Growing hash table to: %"pI"d", new_size);
3958 make_number (new_size));
3959#endif 3958#endif
3960 3959
3961 set_hash_key_and_value (h, larger_vector (h->key_and_value, 3960 set_hash_key_and_value (h, larger_vector (h->key_and_value,
diff --git a/src/process.c b/src/process.c
index ce78d818e29..bb068943b4a 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3292,8 +3292,7 @@ usage: (make-network-process &rest ARGS) */)
3292 { 3292 {
3293 if (!NILP (host)) 3293 if (!NILP (host))
3294 { 3294 {
3295 message (":family local ignores the :host \"%s\" property", 3295 message (":family local ignores the :host property");
3296 SDATA (host));
3297 contact = Fplist_put (contact, QChost, Qnil); 3296 contact = Fplist_put (contact, QChost, Qnil);
3298 host = Qnil; 3297 host = Qnil;
3299 } 3298 }
diff --git a/src/xdisp.c b/src/xdisp.c
index 87f110e667d..358d7b5e4a7 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10223,7 +10223,11 @@ message_with_string (const char *m, Lisp_Object string, bool log)
10223 10223
10224 10224
10225/* Dump an informative message to the minibuf. If M is 0, clear out 10225/* Dump an informative message to the minibuf. If M is 0, clear out
10226 any existing message, and let the mini-buffer text show through. */ 10226 any existing message, and let the mini-buffer text show through.
10227
10228 The message must be safe ASCII only. If strings may contain escape
10229 sequences or non-ASCII characters, convert them to Lisp strings and
10230 use Fmessage. */
10227 10231
10228static void ATTRIBUTE_FORMAT_PRINTF (1, 0) 10232static void ATTRIBUTE_FORMAT_PRINTF (1, 0)
10229vmessage (const char *m, va_list ap) 10233vmessage (const char *m, va_list ap)
@@ -10291,24 +10295,6 @@ message (const char *m, ...)
10291} 10295}
10292 10296
10293 10297
10294#if false
10295/* The non-logging version of message. */
10296
10297void
10298message_nolog (const char *m, ...)
10299{
10300 Lisp_Object old_log_max;
10301 va_list ap;
10302 va_start (ap, m);
10303 old_log_max = Vmessage_log_max;
10304 Vmessage_log_max = Qnil;
10305 vmessage (m, ap);
10306 Vmessage_log_max = old_log_max;
10307 va_end (ap);
10308}
10309#endif
10310
10311
10312/* Display the current message in the current mini-buffer. This is 10298/* Display the current message in the current mini-buffer. This is
10313 only called from error handlers in process.c, and is not time 10299 only called from error handlers in process.c, and is not time
10314 critical. */ 10300 critical. */
diff --git a/src/xselect.c b/src/xselect.c
index 1570c4fef9c..2a865e7cb8c 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2208,8 +2208,7 @@ x_clipboard_manager_save_all (void)
2208 local_frame = XCAR (XCDR (XCDR (XCDR (local_selection)))); 2208 local_frame = XCAR (XCDR (XCDR (XCDR (local_selection))));
2209 if (FRAME_LIVE_P (XFRAME (local_frame))) 2209 if (FRAME_LIVE_P (XFRAME (local_frame)))
2210 { 2210 {
2211 AUTO_STRING (saving, "Saving clipboard to X clipboard manager..."); 2211 message ("Saving clipboard to X clipboard manager...");
2212 Fmessage (1, &saving);
2213 internal_condition_case_1 (x_clipboard_manager_save, local_frame, 2212 internal_condition_case_1 (x_clipboard_manager_save, local_frame,
2214 Qt, x_clipboard_manager_error_2); 2213 Qt, x_clipboard_manager_error_2);
2215 } 2214 }