From: Alan Third <alan@idiocy.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 44349@debbugs.gnu.org, Philipp Stephani <p.stephani2@gmail.com>
Subject: bug#44349: 28.0.50; Assertion failure on macOS when resizing frame
Date: Fri, 27 Nov 2020 22:24:29 +0000 [thread overview]
Message-ID: <20201127222429.GD26836@breton.holly.idiocy.org> (raw)
In-Reply-To: <83a6w2gwxz.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]
On Sat, Oct 31, 2020 at 06:52:08PM +0200, Eli Zaretskii wrote:
> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Sat, 31 Oct 2020 17:43:57 +0100
> > Cc: 44349@debbugs.gnu.org
> >
> > Am Sa., 31. Okt. 2020 um 17:35 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
> > >
> > > > From: Philipp Stephani <p.stephani2@gmail.com>
> > > > Date: Sat, 31 Oct 2020 16:57:54 +0100
> > > >
> > > > > doprnt.c:493: Emacs fatal error: assertion failed: ASCII_CHAR_P (fmtchar)
> > > > > Fatal error 6: Aborted
> > > > > Abort trap: 6
> > >
> > > I cannot say I understand why that assertion is there.
> >
> > Line 81 of doprnt.c states that non-ASCII characters aren't supported.
>
> I don't see why we would want to enforce that, it sounds like a grave
> limitation. Maybe I'm missing some background here. The version we
> have on emacs-27 does support non-ASCII characters in the format.
Patch attached.
I can't see any other special cases that need to be handled and all my
tests worked, so I think this is all that's needed.
--
Alan Third
[-- Attachment #2: 0001-Allow-doprint-to-handle-multibyte-chars-in-format-bu.patch --]
[-- Type: text/plain, Size: 2101 bytes --]
From 7bf4318f34c77e90c76944ee28693a895baf1807 Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Fri, 27 Nov 2020 22:11:47 +0000
Subject: [PATCH] Allow doprint to handle multibyte chars in format (bug#44349)
* src/doprnt.c (doprnt): Handle the case where fmtchar is the start of
a multibyte character.
---
src/doprnt.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/doprnt.c b/src/doprnt.c
index 9316497720..841b8249c7 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -77,8 +77,7 @@
where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length
is empty or l or the value of the pD or pI or PRIdMAX (sans "d") macros.
A % that does not introduce a valid %-sequence causes undefined behavior.
- ASCII bytes in FORMAT other than % are copied through as-is;
- non-ASCII bytes should not appear in FORMAT.
+ Bytes in FORMAT other than % are copied through as-is.
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,
@@ -486,14 +485,30 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
src = uLSQM, srclen = sizeof uLSQM - 1;
else if (EQ (quoting_style, Qcurve) && fmtchar == '\'')
src = uRSQM, srclen = sizeof uRSQM - 1;
- else
+ else if (! LEADING_CODE_P (fmtchar))
{
if (EQ (quoting_style, Qstraight) && fmtchar == '`')
fmtchar = '\'';
- eassert (ASCII_CHAR_P (fmtchar));
+
*bufptr++ = fmtchar;
continue;
}
+ else
+ {
+ src = fmt0;
+ srclen = BYTES_BY_CHAR_HEAD (fmtchar);
+
+ /* doprnt_non_null_end doesn't know about multibyte
+ characters so can truncate format in the middle of one.
+ If that happens just ignore that character. */
+ for ( ; *fmt != 0 && fmt < src + srclen ; fmt++);
+
+ if (fmt < src + srclen)
+ {
+ *bufptr++ = '\0';
+ break;
+ }
+ }
if (bufsize < srclen)
{
--
2.26.1
next prev parent reply other threads:[~2020-11-27 22:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-31 15:51 bug#44349: 28.0.50; Assertion failure on macOS when resizing frame Philipp
2020-10-31 15:57 ` Philipp Stephani
2020-10-31 16:03 ` Philipp Stephani
2020-10-31 16:35 ` Eli Zaretskii
2020-10-31 16:43 ` Philipp Stephani
2020-10-31 16:52 ` Eli Zaretskii
2020-11-27 22:24 ` Alan Third [this message]
2020-11-28 7:51 ` Eli Zaretskii
2020-11-28 22:06 ` Alan Third
2020-11-29 10:27 ` Lars Ingebrigtsen
2020-11-29 15:10 ` Eli Zaretskii
2020-11-29 17:16 ` Alan Third
2020-11-29 17:23 ` Eli Zaretskii
2020-11-29 17:43 ` Alan Third
2020-11-01 0:55 ` Alan Third
2020-11-01 0:58 ` Alan Third
2020-11-01 1:00 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201127222429.GD26836@breton.holly.idiocy.org \
--to=alan@idiocy.org \
--cc=44349@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=p.stephani2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).