/* The start and end bytepos in the output string. */
ptrdiff_t start, end;
+ /* The start of the spec in the format string. */
+ ptrdiff_t fbeg;
+
/* Whether the argument is a string with intervals. */
bool_bf intervals : 1;
} *info;
char conversion = *format++;
memset (&discarded[format0 - format_start], 1,
format - format0 - (conversion == '%'));
+ info[ispec].fbeg = format0 - format_start;
if (conversion == '%')
{
new_result = true;
else if (discarded[bytepos] == 1)
{
position++;
- if (fieldn < nspec && translated == info[fieldn].start)
+ if (fieldn < nspec
+ && position > info[fieldn].fbeg
+ && translated == info[fieldn].start)
{
translated += info[fieldn].end - info[fieldn].start;
fieldn++;
else if (discarded[bytepos] == 1)
{
position++;
- if (fieldn < nspec && translated == info[fieldn].start)
+ if (fieldn < nspec
+ && position > info[fieldn].fbeg
+ && translated == info[fieldn].start)
{
translated += info[fieldn].end - info[fieldn].start;
fieldn++;
(format "%-10s" (concat (propertize "01" 'face 'bold)
(propertize "23" 'face 'underline)
(propertize "45" 'face 'italic)))
- #("012345 " 0 2 (face bold) 2 4 (face underline) 4 10 (face italic)))))
+ #("012345 "
+ 0 2 (face bold) 2 4 (face underline) 4 10 (face italic))))
+ ;; Bug #32404
+ (should (ert-equal-including-properties
+ (format (concat (propertize "%s" 'face 'bold)
+ ""
+ (propertize "%s" 'face 'error))
+ "foo" "bar")
+ #("foobar" 0 3 (face bold) 3 6 (face error))))
+ (should (ert-equal-including-properties
+ (format (concat "%s" (propertize "%s" 'face 'error)) "foo" "bar")
+ #("foobar" 3 6 (face error))))
+ (should (ert-equal-including-properties
+ (format (concat "%s " (propertize "%s" 'face 'error)) "foo" "bar")
+ #("foo bar" 4 7 (face error)))))
;; Tests for bug#5131.
(defun transpose-test-reverse-word (start end)