GNU bug report logs -
#78590
31.0.50; print_object calls strout unsafely
Previous Next
Full log
Message #23 received at 78590 <at> debbugs.gnu.org (full text, mbox):
> Date: Tue, 27 May 2025 18:46:24 +0000
> From: Pip Cet <pipcet <at> protonmail.com>
> Cc: 78590 <at> debbugs.gnu.org
>
> "Eli Zaretskii" <eliz <at> gnu.org> writes:
>
> >> How about calling Fmapc (printcharfun, string) at that point, from
> >> print_string?
> >
> > If that works, fine. But didn't you say below that print_string does
> > something we don't want to do in this case? Or am I misunderstanding
> > what you mean?
>
> Sorry, that wasn't quite clear. I also forgot to include the proposed
> patch:
Ah, okay, there was indeed an misunderstanding, see below.
> else
> {
> - /* Otherwise, string may be relocated by printing one char.
> - So re-fetch the string address for each character. */
> - ptrdiff_t i;
> - ptrdiff_t size = SCHARS (string);
> - ptrdiff_t size_byte = SBYTES (string);
> - if (size == size_byte)
> - for (i = 0; i < size; i++)
> - printchar (SREF (string, i), printcharfun);
> - else
> - for (i = 0; i < size_byte; )
> - {
> - /* Here, we must convert each multi-byte form to the
> - corresponding character code before handing it to PRINTCHAR. */
> - int len, ch = string_char_and_length (SDATA (string) + i, &len);
> - printchar (ch, printcharfun);
> - i += len;
> - }
> + /* printcharfun is a Lisp function. */
> + Fmapc (printcharfun, string);
What is the rationale for calling Fmapc here? Doesn't it do in this
case what the original code did, but at a price of two additional
levels of function calls? IOW, why did you want to get rid of the
original code above?
I have no other issues with your suggested patch.
This bug report was last modified 18 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.