diff options
Diffstat (limited to 'src/editfns.c')
-rw-r--r-- | src/editfns.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/editfns.c b/src/editfns.c index 4dcf7cbe6ef..4fe50ac31d7 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -74,6 +74,7 @@ static Lisp_Object format_time_string (char const *, ptrdiff_t, struct timespec, static long int tm_gmtoff (struct tm *); static int tm_diff (struct tm *, struct tm *); static void update_buffer_properties (ptrdiff_t, ptrdiff_t); +static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); #ifndef HAVE_TM_GMTOFF # define HAVE_TM_GMTOFF false @@ -3958,7 +3959,7 @@ usage: (message FORMAT-STRING &rest ARGS) */) } else { - Lisp_Object val = styled_format (nargs, args, true, false); + Lisp_Object val = Fformat_message (nargs, args); message3 (val); return val; } @@ -3984,7 +3985,7 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) } else { - Lisp_Object val = styled_format (nargs, args, true, false); + Lisp_Object val = Fformat_message (nargs, args); Lisp_Object pane, menu; pane = list1 (Fcons (build_string ("OK"), Qt)); @@ -4140,7 +4141,7 @@ produced text. usage: (format STRING &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { - return styled_format (nargs, args, false, true); + return styled_format (nargs, args, false); } DEFUN ("format-message", Fformat_message, Sformat_message, 1, MANY, 0, @@ -4156,16 +4157,13 @@ and right quote replacement characters are specified by usage: (format-message STRING &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { - return styled_format (nargs, args, true, true); + return styled_format (nargs, args, true); } -/* Implement ‘format-message’ if MESSAGE is true, ‘format’ otherwise. - If NEW_RESULT, the result is a new string; otherwise, the result - may be one of the arguments. */ +/* Implement ‘format-message’ if MESSAGE is true, ‘format’ otherwise. */ -Lisp_Object -styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, - bool new_result) +static Lisp_Object +styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) { ptrdiff_t n; /* The number of the next arg to substitute. */ char initial_buffer[4000]; @@ -4195,9 +4193,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, /* The start and end bytepos in the output string. */ ptrdiff_t start, end; - /* Whether the argument is a newly created string. */ - bool_bf new_string : 1; - /* Whether the argument is a string with intervals. */ bool_bf intervals : 1; } *info; @@ -4241,6 +4236,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, ptrdiff_t ispec; ptrdiff_t nspec = 0; + /* True if a string needs to be allocated to hold the result. */ + bool new_result = false; + /* If we start out planning a unibyte result, then discover it has to be multibyte, we jump back to retry. */ retry: @@ -4360,7 +4358,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, if (nspec < ispec) { spec->argument = args[n]; - spec->new_string = false; spec->intervals = false; nspec = ispec; } @@ -4378,7 +4375,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, { Lisp_Object noescape = conversion == 'S' ? Qnil : Qt; spec->argument = arg = Fprin1_to_string (arg, noescape); - spec->new_string = true; if (STRING_MULTIBYTE (arg) && ! multibyte) { multibyte = true; @@ -4397,7 +4393,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, goto retry; } spec->argument = arg = Fchar_to_string (arg); - spec->new_string = true; } if (!EQ (arg, args[n])) @@ -4421,7 +4416,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, if (conversion == 's') { if (format == end && format - format_start == 2 - && (!new_result || spec->new_string) && ! string_intervals (args[0])) return arg; |