aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-08-25 18:41:31 -0700
committerPaul Eggert2015-08-25 19:00:20 -0700
commit71781c31a4860e56434643296eaa303ca43386bb (patch)
tree271e4e378ac38caa3212d8e2025186715b5e1802 /src
parentef4c2eac6c6e1df8f40efde52d737d911cf2dcf9 (diff)
downloademacs-71781c31a4860e56434643296eaa303ca43386bb.tar.gz
emacs-71781c31a4860e56434643296eaa303ca43386bb.zip
format-message now curves ` and '
That way, the caller doesn’t have to use curved quotes to get diagnostics that match the text-quoting-style preferences. Suggested by Dmitry Gutov in: http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00893.html This means we no longer need %qs, so remove that format. While we’re at it, fix an unlikely bug and lessen the pressure on the garbage collector by processing the string once rather than twice in the usual case. * doc/lispref/strings.texi (Formatting Strings): * etc/NEWS: Document this. * lisp/subr.el (format-message): Remove; now done in C. * src/callint.c (Fcall_interactively): * src/editfns.c (Fmessage, Fmessage_box): Use Fformat_message instead of Finternal__text_restyle followed by Fformat. * src/doc.c (LSQM, RSQM): Remove; all uses changed to use uLSQM and uRSQM. (Fsubstitute_command_keys): Prefer AUTO_STRING to build_string when pure ASCII now suffices. Fix unlikely bug when parsing unibyte string containing non-ASCII bytes. Use inline code rather than memcpy, as it’s a tiny number of bytes. (Finternal__text_restyle): Remove; no longer used. (syms_of_doc): Don’t declare it. * src/editfns.c (Fformat): Rewrite in terms of new function ‘styled_format’. (Fformat_message): New function, moved here from subr.el. (styled_format): New function, with the old guts of Fformat, except it now optionally transliterates quotes, and it transliterates traditional grave accent and apostrophe quoting as well. Remove recently-added q flag; no longer needed or used. (syms_of_editfns): Define format-message. * src/lisp.h (uLSQM0, uLSQM1, uLSQM2, uRSQM0, uRSQM1, uRSQM2): Remove; no longer need to be global symbols. * src/xdisp.c (vadd_to_log): Use Fformat_message, not Fformat, so that callers can use `%s'. * src/image.c (image_size_error, xbm_load_image, xbm_load) (xpm_load, pbm_load, png_load_body, jpeg_load_body, tiff_load) (gif_load, imagemagick_load_image, imagemagick_load, svg_load) (svg_load_image, gs_load, x_kill_gs_process): * src/lread.c (load_warn_old_style_backquotes): * src/xfaces.c (load_pixmap): * src/xselect.c (x_clipboard_manager_error_1): Use `%s' instead of %qs in formats.
Diffstat (limited to 'src')
-rw-r--r--src/callint.c3
-rw-r--r--src/doc.c115
-rw-r--r--src/editfns.c183
-rw-r--r--src/image.c108
-rw-r--r--src/lisp.h7
-rw-r--r--src/lread.c2
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xfaces.c2
-rw-r--r--src/xselect.c2
9 files changed, 174 insertions, 250 deletions
diff --git a/src/callint.c b/src/callint.c
index be0fb1a84df..e39f4dff2e4 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -511,9 +511,8 @@ invoke it. If KEYS is omitted or nil, the return value of
511 for (i = 2; *tem; i++) 511 for (i = 2; *tem; i++)
512 { 512 {
513 visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); 513 visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n"));
514 visargs[1] = Finternal__text_restyle (visargs[1]);
515 if (strchr (SSDATA (visargs[1]), '%')) 514 if (strchr (SSDATA (visargs[1]), '%'))
516 callint_message = Fformat (i - 1, visargs + 1); 515 callint_message = Fformat_message (i - 1, visargs + 1);
517 else 516 else
518 callint_message = visargs[1]; 517 callint_message = visargs[1];
519 518
diff --git a/src/doc.c b/src/doc.c
index 7a298e28631..637200f648e 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -684,10 +684,7 @@ the same file name is found in the `doc-directory'. */)
684 return unbind_to (count, Qnil); 684 return unbind_to (count, Qnil);
685} 685}
686 686
687/* Curved quotation marks. */ 687/* Return true if text quoting style should default to quote `like this'. */
688static unsigned char const LSQM[] = { uLSQM0, uLSQM1, uLSQM2 };
689static unsigned char const RSQM[] = { uRSQM0, uRSQM1, uRSQM2 };
690
691static bool 688static bool
692default_to_grave_quoting_style (void) 689default_to_grave_quoting_style (void)
693{ 690{
@@ -925,14 +922,13 @@ Otherwise, return a new string. */)
925 if (NILP (tem)) 922 if (NILP (tem))
926 { 923 {
927 name = Fsymbol_name (name); 924 name = Fsymbol_name (name);
928 insert1 (Fsubstitute_command_keys 925 AUTO_STRING (msg_prefix, "\nUses keymap `");
929 (build_string ("\nUses keymap "uLSQM))); 926 insert1 (Fsubstitute_command_keys (msg_prefix));
930 insert_from_string (name, 0, 0, 927 insert_from_string (name, 0, 0,
931 SCHARS (name), 928 SCHARS (name),
932 SBYTES (name), 1); 929 SBYTES (name), 1);
933 insert1 (Fsubstitute_command_keys 930 AUTO_STRING (msg_suffix, "', which is not currently defined.\n");
934 (build_string 931 insert1 (Fsubstitute_command_keys (msg_suffix));
935 (uRSQM", which is not currently defined.\n")));
936 if (start[-1] == '<') keymap = Qnil; 932 if (start[-1] == '<') keymap = Qnil;
937 } 933 }
938 else if (start[-1] == '<') 934 else if (start[-1] == '<')
@@ -972,9 +968,9 @@ Otherwise, return a new string. */)
972 else if ((strp[0] == '`' || strp[0] == '\'') 968 else if ((strp[0] == '`' || strp[0] == '\'')
973 && quoting_style == CURVE_QUOTING_STYLE) 969 && quoting_style == CURVE_QUOTING_STYLE)
974 { 970 {
975 start = strp[0] == '`' ? LSQM : RSQM; 971 start = (unsigned char const *) (strp[0] == '`' ? uLSQM : uRSQM);
976 length = 1; 972 length = 1;
977 length_byte = 3; 973 length_byte = sizeof uLSQM - 1;
978 idx = strp - SDATA (string) + 1; 974 idx = strp - SDATA (string) + 1;
979 goto subst; 975 goto subst;
980 } 976 }
@@ -985,29 +981,28 @@ Otherwise, return a new string. */)
985 nchars++; 981 nchars++;
986 changed = true; 982 changed = true;
987 } 983 }
988 else if (strp[0] == uLSQM0 && strp[1] == uLSQM1 984 else if (! multibyte)
989 && (strp[2] == uLSQM2 || strp[2] == uRSQM2)
990 && quoting_style != CURVE_QUOTING_STYLE)
991 {
992 *bufp++ = (strp[2] == uLSQM2 && quoting_style == GRAVE_QUOTING_STYLE
993 ? '`' : '\'');
994 strp += 3;
995 nchars++;
996 changed = true;
997 }
998 else if (! multibyte) /* just copy other chars */
999 *bufp++ = *strp++, nchars++; 985 *bufp++ = *strp++, nchars++;
1000 else 986 else
1001 { 987 {
1002 int len; 988 int len;
1003 989 int ch = STRING_CHAR_AND_LENGTH (strp, len);
1004 STRING_CHAR_AND_LENGTH (strp, len); 990 if ((ch == LEFT_SINGLE_QUOTATION_MARK
1005 if (len == 1) 991 || ch == RIGHT_SINGLE_QUOTATION_MARK)
1006 *bufp = *strp; 992 && quoting_style != CURVE_QUOTING_STYLE)
993 {
994 *bufp++ = ((ch == LEFT_SINGLE_QUOTATION_MARK
995 && quoting_style == GRAVE_QUOTING_STYLE)
996 ? '`' : '\'');
997 strp += len;
998 changed = true;
999 }
1007 else 1000 else
1008 memcpy (bufp, strp, len); 1001 {
1009 strp += len; 1002 do
1010 bufp += len; 1003 *bufp++ = *strp++;
1004 while (--len != 0);
1005 }
1011 nchars++; 1006 nchars++;
1012 } 1007 }
1013 } 1008 }
@@ -1019,67 +1014,6 @@ Otherwise, return a new string. */)
1019 xfree (buf); 1014 xfree (buf);
1020 RETURN_UNGCPRO (tem); 1015 RETURN_UNGCPRO (tem);
1021} 1016}
1022
1023DEFUN ("internal--text-restyle", Finternal__text_restyle,
1024 Sinternal__text_restyle, 1, 1, 0,
1025 doc: /* Return STRING, possibly substituting quote characters.
1026
1027In the result, replace each curved single quote (\\=‘ and \\=’) by
1028left and right quote characters as specified by ‘text-quoting-style’.
1029
1030Return the original STRING in the common case where no changes are needed.
1031Otherwise, return a new string. */)
1032 (Lisp_Object string)
1033{
1034 bool changed = false;
1035
1036 CHECK_STRING (string);
1037 if (! STRING_MULTIBYTE (string))
1038 return string;
1039
1040 enum text_quoting_style quoting_style = text_quoting_style ();
1041 if (quoting_style == CURVE_QUOTING_STYLE)
1042 return string;
1043
1044 ptrdiff_t bsize = SBYTES (string);
1045 unsigned char const *strp = SDATA (string);
1046 unsigned char const *strlim = strp + bsize;
1047 USE_SAFE_ALLOCA;
1048 char *buf = SAFE_ALLOCA (bsize);
1049 char *bufp = buf;
1050 ptrdiff_t nchars = 0;
1051
1052 while (strp < strlim)
1053 {
1054 unsigned char const *cp = strp;
1055 switch (STRING_CHAR_ADVANCE (strp))
1056 {
1057 case LEFT_SINGLE_QUOTATION_MARK:
1058 *bufp++ = quoting_style == GRAVE_QUOTING_STYLE ? '`': '\'';
1059 changed = true;
1060 break;
1061
1062 case RIGHT_SINGLE_QUOTATION_MARK:
1063 *bufp++ = '\'';
1064 changed = true;
1065 break;
1066
1067 default:
1068 do
1069 *bufp++ = *cp++;
1070 while (cp != strp);
1071
1072 break;
1073 }
1074
1075 nchars++;
1076 }
1077
1078 Lisp_Object result
1079 = changed ? make_string_from_bytes (buf, nchars, bufp - buf) : string;
1080 SAFE_FREE ();
1081 return result;
1082}
1083 1017
1084void 1018void
1085syms_of_doc (void) 1019syms_of_doc (void)
@@ -1113,5 +1047,4 @@ displayable, and like ‘grave’ otherwise. */);
1113 defsubr (&Sdocumentation_property); 1047 defsubr (&Sdocumentation_property);
1114 defsubr (&Ssnarf_documentation); 1048 defsubr (&Ssnarf_documentation);
1115 defsubr (&Ssubstitute_command_keys); 1049 defsubr (&Ssubstitute_command_keys);
1116 defsubr (&Sinternal__text_restyle);
1117} 1050}
diff --git a/src/editfns.c b/src/editfns.c
index da7d554fd94..2703a5dbcb9 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -72,6 +72,7 @@ static Lisp_Object format_time_string (char const *, ptrdiff_t, struct timespec,
72static long int tm_gmtoff (struct tm *); 72static long int tm_gmtoff (struct tm *);
73static int tm_diff (struct tm *, struct tm *); 73static int tm_diff (struct tm *, struct tm *);
74static void update_buffer_properties (ptrdiff_t, ptrdiff_t); 74static void update_buffer_properties (ptrdiff_t, ptrdiff_t);
75static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool);
75 76
76#ifndef HAVE_TM_GMTOFF 77#ifndef HAVE_TM_GMTOFF
77# define HAVE_TM_GMTOFF false 78# define HAVE_TM_GMTOFF false
@@ -3696,8 +3697,7 @@ usage: (message FORMAT-STRING &rest ARGS) */)
3696 } 3697 }
3697 else 3698 else
3698 { 3699 {
3699 args[0] = Finternal__text_restyle (args[0]); 3700 Lisp_Object val = Fformat_message (nargs, args);
3700 Lisp_Object val = Fformat (nargs, args);
3701 message3 (val); 3701 message3 (val);
3702 return val; 3702 return val;
3703 } 3703 }
@@ -3722,8 +3722,7 @@ usage: (message-box FORMAT-STRING &rest ARGS) */)
3722 } 3722 }
3723 else 3723 else
3724 { 3724 {
3725 args[0] = Finternal__text_restyle (args[0]); 3725 Lisp_Object val = Fformat_message (nargs, args);
3726 Lisp_Object val = Fformat (nargs, args);
3727 Lisp_Object pane, menu; 3726 Lisp_Object pane, menu;
3728 struct gcpro gcpro1; 3727 struct gcpro gcpro1;
3729 3728
@@ -3822,7 +3821,7 @@ specifiers, as follows:
3822 3821
3823 %<flags><width><precision>character 3822 %<flags><width><precision>character
3824 3823
3825where flags is [+ #-0q]+, width is [0-9]+, and precision is .[0-9]+ 3824where flags is [+ #-0]+, width is [0-9]+, and precision is .[0-9]+
3826 3825
3827The + flag character inserts a + before any positive number, while a 3826The + flag character inserts a + before any positive number, while a
3828space inserts a space before any positive number; these flags only 3827space inserts a space before any positive number; these flags only
@@ -3835,9 +3834,6 @@ The # flag means to use an alternate display form for %o, %x, %X, %e,
3835for %e, %f, and %g, it causes a decimal point to be included even if 3834for %e, %f, and %g, it causes a decimal point to be included even if
3836the precision is zero. 3835the precision is zero.
3837 3836
3838The q flag means to quote the printed representation as per
3839‘text-quoting-style’. E.g., "%qs" is equivalent to "‘%s’".
3840
3841The width specifier supplies a lower limit for the length of the 3837The width specifier supplies a lower limit for the length of the
3842printed representation. The padding, if any, normally goes on the 3838printed representation. The padding, if any, normally goes on the
3843left, but it goes on the right if the - flag is present. The padding 3839left, but it goes on the right if the - flag is present. The padding
@@ -3853,6 +3849,31 @@ specifier truncates the string to the given width.
3853usage: (format STRING &rest OBJECTS) */) 3849usage: (format STRING &rest OBJECTS) */)
3854 (ptrdiff_t nargs, Lisp_Object *args) 3850 (ptrdiff_t nargs, Lisp_Object *args)
3855{ 3851{
3852 return styled_format (nargs, args, false);
3853}
3854
3855DEFUN ("format-message", Fformat_message, Sformat_message, 1, MANY, 0,
3856 doc: /* Format a string out of a format-string and arguments.
3857The first argument is a format control string.
3858The other arguments are substituted into it to make the result, a string.
3859
3860This acts like ‘format’, except it also replaces each left single
3861quotation mark (\\=‘) and grave accent (\\=`) by a left quote, and each
3862right single quotation mark (\\=’) and apostrophe (\\=') by a right quote.
3863The left and right quote replacement characters are specified by
3864‘text-quoting-style’.
3865
3866usage: (format-message STRING &rest OBJECTS) */)
3867 (ptrdiff_t nargs, Lisp_Object *args)
3868{
3869 return styled_format (nargs, args, true);
3870}
3871
3872/* Implement ‘format-message’ if MESSAGE is true, ‘format’ otherwise. */
3873
3874static Lisp_Object
3875styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
3876{
3856 ptrdiff_t n; /* The number of the next arg to substitute. */ 3877 ptrdiff_t n; /* The number of the next arg to substitute. */
3857 char initial_buffer[4000]; 3878 char initial_buffer[4000];
3858 char *buf = initial_buffer; 3879 char *buf = initial_buffer;
@@ -3917,7 +3938,8 @@ usage: (format STRING &rest OBJECTS) */)
3917 3938
3918 /* Try to determine whether the result should be multibyte. 3939 /* Try to determine whether the result should be multibyte.
3919 This is not always right; sometimes the result needs to be multibyte 3940 This is not always right; sometimes the result needs to be multibyte
3920 because of an object that we will pass through prin1, 3941 because of an object that we will pass through prin1.
3942 or because a grave accent or apostrophe is requoted,
3921 and in that case, we won't know it here. */ 3943 and in that case, we won't know it here. */
3922 multibyte_format = STRING_MULTIBYTE (args[0]); 3944 multibyte_format = STRING_MULTIBYTE (args[0]);
3923 multibyte = multibyte_format; 3945 multibyte = multibyte_format;
@@ -3925,7 +3947,7 @@ usage: (format STRING &rest OBJECTS) */)
3925 if (STRINGP (args[n]) && STRING_MULTIBYTE (args[n])) 3947 if (STRINGP (args[n]) && STRING_MULTIBYTE (args[n]))
3926 multibyte = 1; 3948 multibyte = 1;
3927 3949
3928 enum text_quoting_style quoting_style = text_quoting_style (); 3950 int quoting_style = message ? text_quoting_style () : -1;
3929 3951
3930 /* If we start out planning a unibyte result, 3952 /* If we start out planning a unibyte result,
3931 then discover it has to be multibyte, we jump back to retry. */ 3953 then discover it has to be multibyte, we jump back to retry. */
@@ -3945,11 +3967,13 @@ usage: (format STRING &rest OBJECTS) */)
3945 /* The values of N and FORMAT when the loop body is entered. */ 3967 /* The values of N and FORMAT when the loop body is entered. */
3946 ptrdiff_t n0 = n; 3968 ptrdiff_t n0 = n;
3947 char *format0 = format; 3969 char *format0 = format;
3970 char const *convsrc = format;
3971 unsigned char format_char = *format++;
3948 3972
3949 /* Bytes needed to represent the output of this conversion. */ 3973 /* Bytes needed to represent the output of this conversion. */
3950 ptrdiff_t convbytes; 3974 ptrdiff_t convbytes = 1;
3951 3975
3952 if (*format == '%') 3976 if (format_char == '%')
3953 { 3977 {
3954 /* General format specifications look like 3978 /* General format specifications look like
3955 3979
@@ -3974,23 +3998,21 @@ usage: (format STRING &rest OBJECTS) */)
3974 bool space_flag = false; 3998 bool space_flag = false;
3975 bool sharp_flag = false; 3999 bool sharp_flag = false;
3976 bool zero_flag = false; 4000 bool zero_flag = false;
3977 bool quote_flag = false;
3978 ptrdiff_t field_width; 4001 ptrdiff_t field_width;
3979 bool precision_given; 4002 bool precision_given;
3980 uintmax_t precision = UINTMAX_MAX; 4003 uintmax_t precision = UINTMAX_MAX;
3981 char *num_end; 4004 char *num_end;
3982 char conversion; 4005 char conversion;
3983 4006
3984 while (1) 4007 for (; ; format++)
3985 { 4008 {
3986 switch (*++format) 4009 switch (*format)
3987 { 4010 {
3988 case '-': minus_flag = true; continue; 4011 case '-': minus_flag = true; continue;
3989 case '+': plus_flag = true; continue; 4012 case '+': plus_flag = true; continue;
3990 case ' ': space_flag = true; continue; 4013 case ' ': space_flag = true; continue;
3991 case '#': sharp_flag = true; continue; 4014 case '#': sharp_flag = true; continue;
3992 case '0': zero_flag = true; continue; 4015 case '0': zero_flag = true; continue;
3993 case 'q': quote_flag = true; continue;
3994 } 4016 }
3995 break; 4017 break;
3996 } 4018 }
@@ -4014,11 +4036,10 @@ usage: (format STRING &rest OBJECTS) */)
4014 error ("Format string ends in middle of format specifier"); 4036 error ("Format string ends in middle of format specifier");
4015 4037
4016 memset (&discarded[format0 - format_start], 1, format - format0); 4038 memset (&discarded[format0 - format_start], 1, format - format0);
4017 conversion = *format; 4039 conversion = *format++;
4018 if (conversion == '%') 4040 if (conversion == '%')
4019 goto copy_char; 4041 goto copy_char;
4020 discarded[format - format_start] = 1; 4042 discarded[format - format_start] = 1;
4021 format++;
4022 4043
4023 ++n; 4044 ++n;
4024 if (! (n < nargs)) 4045 if (! (n < nargs))
@@ -4118,20 +4139,6 @@ usage: (format STRING &rest OBJECTS) */)
4118 if (convbytes && multibyte && ! STRING_MULTIBYTE (args[n])) 4139 if (convbytes && multibyte && ! STRING_MULTIBYTE (args[n]))
4119 convbytes = count_size_as_multibyte (SDATA (args[n]), nbytes); 4140 convbytes = count_size_as_multibyte (SDATA (args[n]), nbytes);
4120 4141
4121 if (quote_flag)
4122 {
4123 convbytes += 2;
4124 if (quoting_style == CURVE_QUOTING_STYLE)
4125 {
4126 if (!multibyte)
4127 {
4128 multibyte = true;
4129 goto retry;
4130 }
4131 convbytes += 4;
4132 }
4133 }
4134
4135 padding = width < field_width ? field_width - width : 0; 4142 padding = width < field_width ? field_width - width : 0;
4136 4143
4137 if (max_bufsize - padding <= convbytes) 4144 if (max_bufsize - padding <= convbytes)
@@ -4139,27 +4146,6 @@ usage: (format STRING &rest OBJECTS) */)
4139 convbytes += padding; 4146 convbytes += padding;
4140 if (convbytes <= buf + bufsize - p) 4147 if (convbytes <= buf + bufsize - p)
4141 { 4148 {
4142
4143 if (quote_flag)
4144 {
4145 switch (quoting_style)
4146 {
4147 case CURVE_QUOTING_STYLE:
4148 memcpy (p, uLSQM, 3);
4149 p += 3;
4150 break;
4151
4152 case GRAVE_QUOTING_STYLE:
4153 *p++ = '`';
4154 break;
4155
4156 case STRAIGHT_QUOTING_STYLE:
4157 *p++ = '\'';
4158 break;
4159 }
4160 nchars++;
4161 }
4162
4163 if (! minus_flag) 4149 if (! minus_flag)
4164 { 4150 {
4165 memset (p, ' ', padding); 4151 memset (p, ' ', padding);
@@ -4189,22 +4175,6 @@ usage: (format STRING &rest OBJECTS) */)
4189 nchars += padding; 4175 nchars += padding;
4190 } 4176 }
4191 4177
4192 if (quote_flag)
4193 {
4194 switch (quoting_style)
4195 {
4196 case CURVE_QUOTING_STYLE:
4197 memcpy (p, uRSQM, 3);
4198 p += 3;
4199 break;
4200
4201 default:
4202 *p++ = '\'';
4203 break;
4204 }
4205 nchars++;
4206 }
4207
4208 /* If this argument has text properties, record where 4178 /* If this argument has text properties, record where
4209 in the result string it appears. */ 4179 in the result string it appears. */
4210 if (string_intervals (args[n])) 4180 if (string_intervals (args[n]))
@@ -4464,44 +4434,72 @@ usage: (format STRING &rest OBJECTS) */)
4464 } 4434 }
4465 } 4435 }
4466 else 4436 else
4467 copy_char:
4468 { 4437 {
4469 /* Copy a single character from format to buf. */ 4438 /* Named constants for the UTF-8 encodings of U+2018 LEFT SINGLE
4439 QUOTATION MARK and U+2019 RIGHT SINGLE QUOTATION MARK. */
4440 enum
4441 {
4442 uLSQM0 = 0xE2, uLSQM1 = 0x80, uLSQM2 = 0x98,
4443 /* uRSQM0 = 0xE2, uRSQM1 = 0x80, */ uRSQM2 = 0x99
4444 };
4470 4445
4471 char *src = format;
4472 unsigned char str[MAX_MULTIBYTE_LENGTH]; 4446 unsigned char str[MAX_MULTIBYTE_LENGTH];
4473 4447
4474 if (multibyte_format) 4448 if ((format_char == '`' || format_char == '\'')
4449 && quoting_style == CURVE_QUOTING_STYLE)
4475 { 4450 {
4476 /* Copy a whole multibyte character. */ 4451 if (! multibyte)
4477 if (p > buf 4452 {
4478 && !ASCII_CHAR_P (*((unsigned char *) p - 1)) 4453 multibyte = true;
4479 && !CHAR_HEAD_P (*format)) 4454 goto retry;
4480 maybe_combine_byte = 1; 4455 }
4481 4456 convsrc = format_char == '`' ? uLSQM : uRSQM;
4482 do 4457 convbytes = 3;
4483 format++; 4458 }
4484 while (! CHAR_HEAD_P (*format)); 4459 else if (format_char == '`' && quoting_style == STRAIGHT_QUOTING_STYLE)
4485 4460 convsrc = "'";
4486 convbytes = format - src; 4461 else if (format_char == uLSQM0 && CURVE_QUOTING_STYLE < quoting_style
4487 memset (&discarded[src + 1 - format_start], 2, convbytes - 1); 4462 && multibyte_format
4463 && (unsigned char) format[0] == uLSQM1
4464 && ((unsigned char) format[1] == uLSQM2
4465 || (unsigned char) format[1] == uRSQM2))
4466 {
4467 convsrc = (((unsigned char) format[1] == uLSQM2
4468 && quoting_style == GRAVE_QUOTING_STYLE)
4469 ? "`" : "'");
4470 format += 2;
4471 memset (&discarded[format0 + 1 - format_start], 2, 2);
4488 } 4472 }
4489 else 4473 else
4490 { 4474 {
4491 unsigned char uc = *format++; 4475 /* Copy a single character from format to buf. */
4492 if (! multibyte || ASCII_CHAR_P (uc)) 4476 if (multibyte_format)
4493 convbytes = 1; 4477 {
4494 else 4478 /* Copy a whole multibyte character. */
4479 if (p > buf
4480 && !ASCII_CHAR_P (*((unsigned char *) p - 1))
4481 && !CHAR_HEAD_P (format_char))
4482 maybe_combine_byte = 1;
4483
4484 while (! CHAR_HEAD_P (*format))
4485 format++;
4486
4487 convbytes = format - format0;
4488 memset (&discarded[format0 + 1 - format_start], 2,
4489 convbytes - 1);
4490 }
4491 else if (multibyte && !ASCII_CHAR_P (format_char))
4495 { 4492 {
4496 int c = BYTE8_TO_CHAR (uc); 4493 int c = BYTE8_TO_CHAR (format_char);
4497 convbytes = CHAR_STRING (c, str); 4494 convbytes = CHAR_STRING (c, str);
4498 src = (char *) str; 4495 convsrc = (char *) str;
4499 } 4496 }
4500 } 4497 }
4501 4498
4499 copy_char:
4502 if (convbytes <= buf + bufsize - p) 4500 if (convbytes <= buf + bufsize - p)
4503 { 4501 {
4504 memcpy (p, src, convbytes); 4502 memcpy (p, convsrc, convbytes);
4505 p += convbytes; 4503 p += convbytes;
4506 nchars++; 4504 nchars++;
4507 continue; 4505 continue;
@@ -5213,6 +5211,7 @@ functions if all the text being accessed has this property. */);
5213 defsubr (&Smessage_or_box); 5211 defsubr (&Smessage_or_box);
5214 defsubr (&Scurrent_message); 5212 defsubr (&Scurrent_message);
5215 defsubr (&Sformat); 5213 defsubr (&Sformat);
5214 defsubr (&Sformat_message);
5216 5215
5217 defsubr (&Sinsert_buffer_substring); 5216 defsubr (&Sinsert_buffer_substring);
5218 defsubr (&Scompare_buffer_substrings); 5217 defsubr (&Scompare_buffer_substrings);
diff --git a/src/image.c b/src/image.c
index 63089a9a8fb..743d230ed3b 100644
--- a/src/image.c
+++ b/src/image.c
@@ -647,7 +647,7 @@ image_error (const char *format, ...)
647static void 647static void
648image_size_error (void) 648image_size_error (void)
649{ 649{
650 image_error ("Invalid image size (see %qs)", "max-image-size"); 650 image_error ("Invalid image size (see `%s')", "max-image-size");
651} 651}
652 652
653 653
@@ -2952,13 +2952,13 @@ xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
2952 if (img->pixmap == NO_PIXMAP) 2952 if (img->pixmap == NO_PIXMAP)
2953 { 2953 {
2954 x_clear_image (f, img); 2954 x_clear_image (f, img);
2955 image_error ("Unable to create X pixmap for %qs", img->spec); 2955 image_error ("Unable to create X pixmap for `%s'", img->spec);
2956 } 2956 }
2957 else 2957 else
2958 success_p = 1; 2958 success_p = 1;
2959 } 2959 }
2960 else 2960 else
2961 image_error ("Error loading XBM image %qs", img->spec); 2961 image_error ("Error loading XBM image `%s'", img->spec);
2962 2962
2963 return success_p; 2963 return success_p;
2964} 2964}
@@ -2996,7 +2996,7 @@ xbm_load (struct frame *f, struct image *img)
2996 Lisp_Object file = x_find_image_fd (file_name, &fd); 2996 Lisp_Object file = x_find_image_fd (file_name, &fd);
2997 if (!STRINGP (file)) 2997 if (!STRINGP (file))
2998 { 2998 {
2999 image_error ("Cannot find image file %qs", file_name); 2999 image_error ("Cannot find image file `%s'", file_name);
3000 return 0; 3000 return 0;
3001 } 3001 }
3002 3002
@@ -3004,7 +3004,7 @@ xbm_load (struct frame *f, struct image *img)
3004 unsigned char *contents = slurp_file (fd, &size); 3004 unsigned char *contents = slurp_file (fd, &size);
3005 if (contents == NULL) 3005 if (contents == NULL)
3006 { 3006 {
3007 image_error ("Error loading XBM image %qs", file); 3007 image_error ("Error loading XBM image `%s'", file);
3008 return 0; 3008 return 0;
3009 } 3009 }
3010 3010
@@ -3116,7 +3116,7 @@ xbm_load (struct frame *f, struct image *img)
3116 success_p = 1; 3116 success_p = 1;
3117 else 3117 else
3118 { 3118 {
3119 image_error ("Unable to create pixmap for XBM image %qs", 3119 image_error ("Unable to create pixmap for XBM image `%s'",
3120 img->spec); 3120 img->spec);
3121 x_clear_image (f, img); 3121 x_clear_image (f, img);
3122 } 3122 }
@@ -3639,7 +3639,7 @@ xpm_load (struct frame *f, struct image *img)
3639 Lisp_Object file = x_find_image_file (specified_file); 3639 Lisp_Object file = x_find_image_file (specified_file);
3640 if (!STRINGP (file)) 3640 if (!STRINGP (file))
3641 { 3641 {
3642 image_error ("Cannot find image file %qs", specified_file); 3642 image_error ("Cannot find image file `%s'", specified_file);
3643#ifdef ALLOC_XPM_COLORS 3643#ifdef ALLOC_XPM_COLORS
3644 xpm_free_color_cache (); 3644 xpm_free_color_cache ();
3645#endif 3645#endif
@@ -3671,7 +3671,7 @@ xpm_load (struct frame *f, struct image *img)
3671 Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL); 3671 Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL);
3672 if (!STRINGP (buffer)) 3672 if (!STRINGP (buffer))
3673 { 3673 {
3674 image_error ("Invalid image data %qs", buffer); 3674 image_error ("Invalid image data `%s'", buffer);
3675#ifdef ALLOC_XPM_COLORS 3675#ifdef ALLOC_XPM_COLORS
3676 xpm_free_color_cache (); 3676 xpm_free_color_cache ();
3677#endif 3677#endif
@@ -4302,7 +4302,7 @@ xpm_load (struct frame *f,
4302 Lisp_Object file = x_find_image_fd (file_name, &fd); 4302 Lisp_Object file = x_find_image_fd (file_name, &fd);
4303 if (!STRINGP (file)) 4303 if (!STRINGP (file))
4304 { 4304 {
4305 image_error ("Cannot find image file %qs", file_name); 4305 image_error ("Cannot find image file `%s'", file_name);
4306 return 0; 4306 return 0;
4307 } 4307 }
4308 4308
@@ -4310,7 +4310,7 @@ xpm_load (struct frame *f,
4310 unsigned char *contents = slurp_file (fd, &size); 4310 unsigned char *contents = slurp_file (fd, &size);
4311 if (contents == NULL) 4311 if (contents == NULL)
4312 { 4312 {
4313 image_error ("Error loading XPM image %qs", file); 4313 image_error ("Error loading XPM image `%s'", file);
4314 return 0; 4314 return 0;
4315 } 4315 }
4316 4316
@@ -4324,7 +4324,7 @@ xpm_load (struct frame *f,
4324 data = image_spec_value (img->spec, QCdata, NULL); 4324 data = image_spec_value (img->spec, QCdata, NULL);
4325 if (!STRINGP (data)) 4325 if (!STRINGP (data))
4326 { 4326 {
4327 image_error ("Invalid image data %qs", data); 4327 image_error ("Invalid image data `%s'", data);
4328 return 0; 4328 return 0;
4329 } 4329 }
4330 success_p = xpm_load_image (f, img, SDATA (data), 4330 success_p = xpm_load_image (f, img, SDATA (data),
@@ -5278,7 +5278,7 @@ pbm_load (struct frame *f, struct image *img)
5278 Lisp_Object file = x_find_image_fd (specified_file, &fd); 5278 Lisp_Object file = x_find_image_fd (specified_file, &fd);
5279 if (!STRINGP (file)) 5279 if (!STRINGP (file))
5280 { 5280 {
5281 image_error ("Cannot find image file %qs", specified_file); 5281 image_error ("Cannot find image file `%s'", specified_file);
5282 return 0; 5282 return 0;
5283 } 5283 }
5284 5284
@@ -5286,7 +5286,7 @@ pbm_load (struct frame *f, struct image *img)
5286 contents = slurp_file (fd, &size); 5286 contents = slurp_file (fd, &size);
5287 if (contents == NULL) 5287 if (contents == NULL)
5288 { 5288 {
5289 image_error ("Error reading %qs", file); 5289 image_error ("Error reading `%s'", file);
5290 return 0; 5290 return 0;
5291 } 5291 }
5292 5292
@@ -5299,7 +5299,7 @@ pbm_load (struct frame *f, struct image *img)
5299 data = image_spec_value (img->spec, QCdata, NULL); 5299 data = image_spec_value (img->spec, QCdata, NULL);
5300 if (!STRINGP (data)) 5300 if (!STRINGP (data))
5301 { 5301 {
5302 image_error ("Invalid image data %qs", data); 5302 image_error ("Invalid image data `%s'", data);
5303 return 0; 5303 return 0;
5304 } 5304 }
5305 p = SDATA (data); 5305 p = SDATA (data);
@@ -5309,7 +5309,7 @@ pbm_load (struct frame *f, struct image *img)
5309 /* Check magic number. */ 5309 /* Check magic number. */
5310 if (end - p < 2 || *p++ != 'P') 5310 if (end - p < 2 || *p++ != 'P')
5311 { 5311 {
5312 image_error ("Not a PBM image: %qs", img->spec); 5312 image_error ("Not a PBM image: `%s'", img->spec);
5313 error: 5313 error:
5314 xfree (contents); 5314 xfree (contents);
5315 img->pixmap = NO_PIXMAP; 5315 img->pixmap = NO_PIXMAP;
@@ -5343,7 +5343,7 @@ pbm_load (struct frame *f, struct image *img)
5343 break; 5343 break;
5344 5344
5345 default: 5345 default:
5346 image_error ("Not a PBM image: %qs", img->spec); 5346 image_error ("Not a PBM image: `%s'", img->spec);
5347 goto error; 5347 goto error;
5348 } 5348 }
5349 5349
@@ -5442,7 +5442,7 @@ pbm_load (struct frame *f, struct image *img)
5442 x_destroy_x_image (ximg); 5442 x_destroy_x_image (ximg);
5443#endif 5443#endif
5444 x_clear_image (f, img); 5444 x_clear_image (f, img);
5445 image_error ("Invalid image size in image %qs", 5445 image_error ("Invalid image size in image `%s'",
5446 img->spec); 5446 img->spec);
5447 goto error; 5447 goto error;
5448 } 5448 }
@@ -5477,7 +5477,7 @@ pbm_load (struct frame *f, struct image *img)
5477 x_destroy_x_image (ximg); 5477 x_destroy_x_image (ximg);
5478#endif 5478#endif
5479 x_clear_image (f, img); 5479 x_clear_image (f, img);
5480 image_error ("Invalid image size in image %qs", img->spec); 5480 image_error ("Invalid image size in image `%s'", img->spec);
5481 goto error; 5481 goto error;
5482 } 5482 }
5483 5483
@@ -5520,7 +5520,7 @@ pbm_load (struct frame *f, struct image *img)
5520#else 5520#else
5521 x_destroy_x_image (ximg); 5521 x_destroy_x_image (ximg);
5522#endif 5522#endif
5523 image_error ("Invalid pixel value in image %qs", img->spec); 5523 image_error ("Invalid pixel value in image `%s'", img->spec);
5524 goto error; 5524 goto error;
5525 } 5525 }
5526 5526
@@ -5916,7 +5916,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5916 Lisp_Object file = x_find_image_fd (specified_file, &fd); 5916 Lisp_Object file = x_find_image_fd (specified_file, &fd);
5917 if (!STRINGP (file)) 5917 if (!STRINGP (file))
5918 { 5918 {
5919 image_error ("Cannot find image file %qs", specified_file); 5919 image_error ("Cannot find image file `%s'", specified_file);
5920 return 0; 5920 return 0;
5921 } 5921 }
5922 5922
@@ -5924,7 +5924,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5924 fp = fdopen (fd, "rb"); 5924 fp = fdopen (fd, "rb");
5925 if (!fp) 5925 if (!fp)
5926 { 5926 {
5927 image_error ("Cannot open image file %qs", file); 5927 image_error ("Cannot open image file `%s'", file);
5928 return 0; 5928 return 0;
5929 } 5929 }
5930 5930
@@ -5933,7 +5933,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5933 || png_sig_cmp (sig, 0, sizeof sig)) 5933 || png_sig_cmp (sig, 0, sizeof sig))
5934 { 5934 {
5935 fclose (fp); 5935 fclose (fp);
5936 image_error ("Not a PNG file: %qs", file); 5936 image_error ("Not a PNG file: `%s'", file);
5937 return 0; 5937 return 0;
5938 } 5938 }
5939 } 5939 }
@@ -5941,7 +5941,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5941 { 5941 {
5942 if (!STRINGP (specified_data)) 5942 if (!STRINGP (specified_data))
5943 { 5943 {
5944 image_error ("Invalid image data %qs", specified_data); 5944 image_error ("Invalid image data `%s'", specified_data);
5945 return 0; 5945 return 0;
5946 } 5946 }
5947 5947
@@ -5954,7 +5954,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5954 if (tbr.len < sizeof sig 5954 if (tbr.len < sizeof sig
5955 || png_sig_cmp (tbr.bytes, 0, sizeof sig)) 5955 || png_sig_cmp (tbr.bytes, 0, sizeof sig))
5956 { 5956 {
5957 image_error ("Not a PNG image: %qs", img->spec); 5957 image_error ("Not a PNG image: `%s'", img->spec);
5958 return 0; 5958 return 0;
5959 } 5959 }
5960 5960
@@ -6681,20 +6681,20 @@ jpeg_load_body (struct frame *f, struct image *img,
6681 Lisp_Object file = x_find_image_fd (specified_file, &fd); 6681 Lisp_Object file = x_find_image_fd (specified_file, &fd);
6682 if (!STRINGP (file)) 6682 if (!STRINGP (file))
6683 { 6683 {
6684 image_error ("Cannot find image file %qs", specified_file); 6684 image_error ("Cannot find image file `%s'", specified_file);
6685 return 0; 6685 return 0;
6686 } 6686 }
6687 6687
6688 fp = fdopen (fd, "rb"); 6688 fp = fdopen (fd, "rb");
6689 if (fp == NULL) 6689 if (fp == NULL)
6690 { 6690 {
6691 image_error ("Cannot open %qs", file); 6691 image_error ("Cannot open `%s'", file);
6692 return 0; 6692 return 0;
6693 } 6693 }
6694 } 6694 }
6695 else if (!STRINGP (specified_data)) 6695 else if (!STRINGP (specified_data))
6696 { 6696 {
6697 image_error ("Invalid image data %qs", specified_data); 6697 image_error ("Invalid image data `%s'", specified_data);
6698 return 0; 6698 return 0;
6699 } 6699 }
6700 6700
@@ -6710,7 +6710,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6710 { 6710 {
6711 char buf[JMSG_LENGTH_MAX]; 6711 char buf[JMSG_LENGTH_MAX];
6712 mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf); 6712 mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf);
6713 image_error ("Error reading JPEG image %qs: %s", 6713 image_error ("Error reading JPEG image `%s': %s",
6714 img->spec, build_string (buf)); 6714 img->spec, build_string (buf));
6715 break; 6715 break;
6716 } 6716 }
@@ -7196,7 +7196,7 @@ tiff_load (struct frame *f, struct image *img)
7196 Lisp_Object file = x_find_image_file (specified_file); 7196 Lisp_Object file = x_find_image_file (specified_file);
7197 if (!STRINGP (file)) 7197 if (!STRINGP (file))
7198 { 7198 {
7199 image_error ("Cannot find image file %qs", specified_file); 7199 image_error ("Cannot find image file `%s'", specified_file);
7200 return 0; 7200 return 0;
7201 } 7201 }
7202 7202
@@ -7209,7 +7209,7 @@ tiff_load (struct frame *f, struct image *img)
7209 tiff = TIFFOpen (SSDATA (encoded_file), "r"); 7209 tiff = TIFFOpen (SSDATA (encoded_file), "r");
7210 if (tiff == NULL) 7210 if (tiff == NULL)
7211 { 7211 {
7212 image_error ("Cannot open %qs", file); 7212 image_error ("Cannot open `%s'", file);
7213 return 0; 7213 return 0;
7214 } 7214 }
7215 } 7215 }
@@ -7217,7 +7217,7 @@ tiff_load (struct frame *f, struct image *img)
7217 { 7217 {
7218 if (!STRINGP (specified_data)) 7218 if (!STRINGP (specified_data))
7219 { 7219 {
7220 image_error ("Invalid image data %qs", specified_data); 7220 image_error ("Invalid image data `%s'", specified_data);
7221 return 0; 7221 return 0;
7222 } 7222 }
7223 7223
@@ -7237,7 +7237,7 @@ tiff_load (struct frame *f, struct image *img)
7237 7237
7238 if (!tiff) 7238 if (!tiff)
7239 { 7239 {
7240 image_error ("Cannot open memory source for %qs", img->spec); 7240 image_error ("Cannot open memory source for `%s'", img->spec);
7241 return 0; 7241 return 0;
7242 } 7242 }
7243 } 7243 }
@@ -7249,7 +7249,7 @@ tiff_load (struct frame *f, struct image *img)
7249 if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t) 7249 if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t)
7250 && TIFFSetDirectory (tiff, ino))) 7250 && TIFFSetDirectory (tiff, ino)))
7251 { 7251 {
7252 image_error ("Invalid image number %qs in image %qs", 7252 image_error ("Invalid image number `%s' in image `%s'",
7253 image, img->spec); 7253 image, img->spec);
7254 TIFFClose (tiff); 7254 TIFFClose (tiff);
7255 return 0; 7255 return 0;
@@ -7293,7 +7293,7 @@ tiff_load (struct frame *f, struct image *img)
7293 TIFFClose (tiff); 7293 TIFFClose (tiff);
7294 if (!rc) 7294 if (!rc)
7295 { 7295 {
7296 image_error ("Error reading TIFF image %qs", img->spec); 7296 image_error ("Error reading TIFF image `%s'", img->spec);
7297 xfree (buf); 7297 xfree (buf);
7298 return 0; 7298 return 0;
7299 } 7299 }
@@ -7629,7 +7629,7 @@ gif_load (struct frame *f, struct image *img)
7629 Lisp_Object file = x_find_image_file (specified_file); 7629 Lisp_Object file = x_find_image_file (specified_file);
7630 if (!STRINGP (file)) 7630 if (!STRINGP (file))
7631 { 7631 {
7632 image_error ("Cannot find image file %qs", specified_file); 7632 image_error ("Cannot find image file `%s'", specified_file);
7633 return 0; 7633 return 0;
7634 } 7634 }
7635 7635
@@ -7643,14 +7643,14 @@ gif_load (struct frame *f, struct image *img)
7643 gif = DGifOpenFileName (SSDATA (encoded_file)); 7643 gif = DGifOpenFileName (SSDATA (encoded_file));
7644 if (gif == NULL) 7644 if (gif == NULL)
7645 { 7645 {
7646 image_error ("Cannot open %qs", file); 7646 image_error ("Cannot open `%s'", file);
7647 return 0; 7647 return 0;
7648 } 7648 }
7649#else 7649#else
7650 gif = DGifOpenFileName (SSDATA (encoded_file), &gif_err); 7650 gif = DGifOpenFileName (SSDATA (encoded_file), &gif_err);
7651 if (gif == NULL) 7651 if (gif == NULL)
7652 { 7652 {
7653 image_error ("Cannot open %qs: %s", 7653 image_error ("Cannot open `%s': %s",
7654 file, build_string (GifErrorString (gif_err))); 7654 file, build_string (GifErrorString (gif_err)));
7655 return 0; 7655 return 0;
7656 } 7656 }
@@ -7660,7 +7660,7 @@ gif_load (struct frame *f, struct image *img)
7660 { 7660 {
7661 if (!STRINGP (specified_data)) 7661 if (!STRINGP (specified_data))
7662 { 7662 {
7663 image_error ("Invalid image data %qs", specified_data); 7663 image_error ("Invalid image data `%s'", specified_data);
7664 return 0; 7664 return 0;
7665 } 7665 }
7666 7666
@@ -7674,14 +7674,14 @@ gif_load (struct frame *f, struct image *img)
7674 gif = DGifOpen (&memsrc, gif_read_from_memory); 7674 gif = DGifOpen (&memsrc, gif_read_from_memory);
7675 if (!gif) 7675 if (!gif)
7676 { 7676 {
7677 image_error ("Cannot open memory source %qs", img->spec); 7677 image_error ("Cannot open memory source `%s'", img->spec);
7678 return 0; 7678 return 0;
7679 } 7679 }
7680#else 7680#else
7681 gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err); 7681 gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err);
7682 if (!gif) 7682 if (!gif)
7683 { 7683 {
7684 image_error ("Cannot open memory source %qs: %s", 7684 image_error ("Cannot open memory source `%s': %s",
7685 img->spec, build_string (GifErrorString (gif_err))); 7685 img->spec, build_string (GifErrorString (gif_err)));
7686 return 0; 7686 return 0;
7687 } 7687 }
@@ -7700,7 +7700,7 @@ gif_load (struct frame *f, struct image *img)
7700 rc = DGifSlurp (gif); 7700 rc = DGifSlurp (gif);
7701 if (rc == GIF_ERROR || gif->ImageCount <= 0) 7701 if (rc == GIF_ERROR || gif->ImageCount <= 0)
7702 { 7702 {
7703 image_error ("Error reading %qs", img->spec); 7703 image_error ("Error reading `%s'", img->spec);
7704 gif_close (gif, NULL); 7704 gif_close (gif, NULL);
7705 return 0; 7705 return 0;
7706 } 7706 }
@@ -7711,7 +7711,7 @@ gif_load (struct frame *f, struct image *img)
7711 idx = INTEGERP (image_number) ? XFASTINT (image_number) : 0; 7711 idx = INTEGERP (image_number) ? XFASTINT (image_number) : 0;
7712 if (idx < 0 || idx >= gif->ImageCount) 7712 if (idx < 0 || idx >= gif->ImageCount)
7713 { 7713 {
7714 image_error ("Invalid image number %qs in image %qs", 7714 image_error ("Invalid image number `%s' in image `%s'",
7715 image_number, img->spec); 7715 image_number, img->spec);
7716 gif_close (gif, NULL); 7716 gif_close (gif, NULL);
7717 return 0; 7717 return 0;
@@ -7984,10 +7984,10 @@ gif_load (struct frame *f, struct image *img)
7984 char *error_text = GifErrorString (gif_err); 7984 char *error_text = GifErrorString (gif_err);
7985 7985
7986 if (error_text) 7986 if (error_text)
7987 image_error ("Error closing %qs: %s", 7987 image_error ("Error closing `%s': %s",
7988 img->spec, build_string (error_text)); 7988 img->spec, build_string (error_text));
7989#else 7989#else
7990 image_error ("Error closing %qs", img->spec); 7990 image_error ("Error closing `%s'", img->spec);
7991#endif 7991#endif
7992 } 7992 }
7993 7993
@@ -8528,7 +8528,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8528 8528
8529 if (ino < 0 || ino >= MagickGetNumberImages (image_wand)) 8529 if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
8530 { 8530 {
8531 image_error ("Invalid image number %qs in image %qs", image, img->spec); 8531 image_error ("Invalid image number `%s' in image `%s'", image, img->spec);
8532 DestroyMagickWand (image_wand); 8532 DestroyMagickWand (image_wand);
8533 return 0; 8533 return 0;
8534 } 8534 }
@@ -8797,7 +8797,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8797 8797
8798 MagickWandTerminus (); 8798 MagickWandTerminus ();
8799 /* TODO more cleanup. */ 8799 /* TODO more cleanup. */
8800 image_error ("Error parsing IMAGEMAGICK image %qs", img->spec); 8800 image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec);
8801 return 0; 8801 return 0;
8802} 8802}
8803 8803
@@ -8819,7 +8819,7 @@ imagemagick_load (struct frame *f, struct image *img)
8819 Lisp_Object file = x_find_image_file (file_name); 8819 Lisp_Object file = x_find_image_file (file_name);
8820 if (!STRINGP (file)) 8820 if (!STRINGP (file))
8821 { 8821 {
8822 image_error ("Cannot find image file %qs", file_name); 8822 image_error ("Cannot find image file `%s'", file_name);
8823 return 0; 8823 return 0;
8824 } 8824 }
8825 file = ENCODE_FILE (file); 8825 file = ENCODE_FILE (file);
@@ -8837,7 +8837,7 @@ imagemagick_load (struct frame *f, struct image *img)
8837 data = image_spec_value (img->spec, QCdata, NULL); 8837 data = image_spec_value (img->spec, QCdata, NULL);
8838 if (!STRINGP (data)) 8838 if (!STRINGP (data))
8839 { 8839 {
8840 image_error ("Invalid image data %qs", data); 8840 image_error ("Invalid image data `%s'", data);
8841 return 0; 8841 return 0;
8842 } 8842 }
8843 success_p = imagemagick_load_image (f, img, SDATA (data), 8843 success_p = imagemagick_load_image (f, img, SDATA (data),
@@ -9098,7 +9098,7 @@ svg_load (struct frame *f, struct image *img)
9098 Lisp_Object file = x_find_image_fd (file_name, &fd); 9098 Lisp_Object file = x_find_image_fd (file_name, &fd);
9099 if (!STRINGP (file)) 9099 if (!STRINGP (file))
9100 { 9100 {
9101 image_error ("Cannot find image file %qs", file_name); 9101 image_error ("Cannot find image file `%s'", file_name);
9102 return 0; 9102 return 0;
9103 } 9103 }
9104 9104
@@ -9107,7 +9107,7 @@ svg_load (struct frame *f, struct image *img)
9107 unsigned char *contents = slurp_file (fd, &size); 9107 unsigned char *contents = slurp_file (fd, &size);
9108 if (contents == NULL) 9108 if (contents == NULL)
9109 { 9109 {
9110 image_error ("Error loading SVG image %qs", file); 9110 image_error ("Error loading SVG image `%s'", file);
9111 return 0; 9111 return 0;
9112 } 9112 }
9113 /* If the file was slurped into memory properly, parse it. */ 9113 /* If the file was slurped into memory properly, parse it. */
@@ -9124,7 +9124,7 @@ svg_load (struct frame *f, struct image *img)
9124 data = image_spec_value (img->spec, QCdata, NULL); 9124 data = image_spec_value (img->spec, QCdata, NULL);
9125 if (!STRINGP (data)) 9125 if (!STRINGP (data))
9126 { 9126 {
9127 image_error ("Invalid image data %qs", data); 9127 image_error ("Invalid image data `%s'", data);
9128 return 0; 9128 return 0;
9129 } 9129 }
9130 original_filename = BVAR (current_buffer, filename); 9130 original_filename = BVAR (current_buffer, filename);
@@ -9323,7 +9323,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9323 g_object_unref (rsvg_handle); 9323 g_object_unref (rsvg_handle);
9324 /* FIXME: Use error->message so the user knows what is the actual 9324 /* FIXME: Use error->message so the user knows what is the actual
9325 problem with the image. */ 9325 problem with the image. */
9326 image_error ("Error parsing SVG image %qs", img->spec); 9326 image_error ("Error parsing SVG image `%s'", img->spec);
9327 g_error_free (err); 9327 g_error_free (err);
9328 return 0; 9328 return 0;
9329} 9329}
@@ -9497,7 +9497,7 @@ gs_load (struct frame *f, struct image *img)
9497 9497
9498 if (!img->pixmap) 9498 if (!img->pixmap)
9499 { 9499 {
9500 image_error ("Unable to create pixmap for %qs" , img->spec); 9500 image_error ("Unable to create pixmap for `%s'" , img->spec);
9501 return 0; 9501 return 0;
9502 } 9502 }
9503 9503
@@ -9609,7 +9609,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9609#endif 9609#endif
9610 } 9610 }
9611 else 9611 else
9612 image_error ("Cannot get X image of %qs; colors will not be freed", 9612 image_error ("Cannot get X image of `%s'; colors will not be freed",
9613 img->spec); 9613 img->spec);
9614 9614
9615 unblock_input (); 9615 unblock_input ();
diff --git a/src/lisp.h b/src/lisp.h
index d3dcaecd2bb..bb25ebd9be3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4300,13 +4300,6 @@ extern void set_initial_environment (void);
4300extern void syms_of_callproc (void); 4300extern void syms_of_callproc (void);
4301 4301
4302/* Defined in doc.c. */ 4302/* Defined in doc.c. */
4303enum
4304 {
4305 /* Named constants for the UTF-8 encodings of U+2018 LEFT SINGLE
4306 QUOTATION MARK and U+2019 RIGHT SINGLE QUOTATION MARK. */
4307 uLSQM0 = 0xE2, uLSQM1 = 0x80, uLSQM2 = 0x98,
4308 uRSQM0 = 0xE2, uRSQM1 = 0x80, uRSQM2 = 0x99
4309 };
4310enum text_quoting_style 4303enum text_quoting_style
4311 { 4304 {
4312 /* Use curved single quotes ‘like this’. */ 4305 /* Use curved single quotes ‘like this’. */
diff --git a/src/lread.c b/src/lread.c
index c342218c532..21b2f9c1866 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -947,7 +947,7 @@ load_warn_old_style_backquotes (Lisp_Object file)
947{ 947{
948 if (!NILP (Vold_style_backquotes)) 948 if (!NILP (Vold_style_backquotes))
949 { 949 {
950 AUTO_STRING (format, "Loading %qs: old-style backquotes detected!"); 950 AUTO_STRING (format, "Loading `%s': old-style backquotes detected!");
951 CALLN (Fmessage, format, file); 951 CALLN (Fmessage, format, file);
952 } 952 }
953} 953}
diff --git a/src/xdisp.c b/src/xdisp.c
index 8be74977b43..f75293618e8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9838,7 +9838,7 @@ vadd_to_log (char const *format, va_list ap)
9838 struct gcpro gcpro1, gcpro2; 9838 struct gcpro gcpro1, gcpro2;
9839 GCPRO2 (args[1], msg); 9839 GCPRO2 (args[1], msg);
9840 gcpro1.nvars = form_nargs; 9840 gcpro1.nvars = form_nargs;
9841 msg = Fformat (nargs, args); 9841 msg = Fformat_message (nargs, args);
9842 9842
9843 ptrdiff_t len = SBYTES (msg) + 1; 9843 ptrdiff_t len = SBYTES (msg) + 1;
9844 USE_SAFE_ALLOCA; 9844 USE_SAFE_ALLOCA;
diff --git a/src/xfaces.c b/src/xfaces.c
index b599e6af715..ce300e7ef23 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -797,7 +797,7 @@ load_pixmap (struct frame *f, Lisp_Object name)
797 797
798 if (bitmap_id < 0) 798 if (bitmap_id < 0)
799 { 799 {
800 add_to_log ("Invalid or undefined bitmap %qs", name); 800 add_to_log ("Invalid or undefined bitmap `%s'", name);
801 bitmap_id = 0; 801 bitmap_id = 0;
802 } 802 }
803 else 803 else
diff --git a/src/xselect.c b/src/xselect.c
index d4d4dc04b8d..3e5778de17e 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2148,7 +2148,7 @@ static Lisp_Object
2148x_clipboard_manager_error_1 (Lisp_Object err) 2148x_clipboard_manager_error_1 (Lisp_Object err)
2149{ 2149{
2150 AUTO_STRING (format, "X clipboard manager error: %s\n\ 2150 AUTO_STRING (format, "X clipboard manager error: %s\n\
2151If the problem persists, set %qs to nil."); 2151If the problem persists, set `%s' to nil.");
2152 AUTO_STRING (varname, "x-select-enable-clipboard-manager"); 2152 AUTO_STRING (varname, "x-select-enable-clipboard-manager");
2153 CALLN (Fmessage, format, CAR (CDR (err)), varname); 2153 CALLN (Fmessage, format, CAR (CDR (err)), varname);
2154 return Qnil; 2154 return Qnil;