[luatex] A bug in show_context second line indentation

user202729 at protonmail.com user202729 at protonmail.com
Fri Oct 18 14:01:41 CEST 2024


`strlen()` is the C library function right? So it's not UTF8-aware and will just return the number of bytes needed to represent the string in UTF8.

Meanwhile I was puzzled why the `*3` is necessary.


Sent with Proton Mail secure email.

On Friday, October 18th, 2024 at 6:48 PM, luigi scarso <luigi.scarso at gmail.com> wrote:

> 
> 
> On Fri, 18 Oct 2024 at 12:06, Hartmut Henkel via luatex <luatex at tug.org> wrote:
> 
> > Hi Luigi,
> > 
> > On Fri, 18 Oct 2024, luigi scarso wrote:
> > > On Thu, 17 Oct 2024 at 18:06, user202729--- via luatex <luatex at tug.org> wrote:
> > > b/source/texk/web2c/luatexdir/tex/printing.c
> > > index 8a52700..8ae11b4 100644
> > > --- a/source/texk/web2c/luatexdir/tex/printing.c
> > > +++ b/source/texk/web2c/luatexdir/tex/printing.c
> > > @@ -482,7 +482,8 @@ void tprint(const char *sss)
> > > }
> > > /*tex What is left is the 3 term/log settings. */
> > > if (dolog || doterm) {
> > > - buffer = xmalloc(strlen(sss)*3);
> > > + size_t len = strlen(sss);
> > > + buffer = xmalloc(len*3);
> > 
> > only looking here by accident, but google tells that UTF-8 is 1 to 4
> > bytes. So is "len*3" safe?
> 
> 
> Indeed this is (one of the) issue(s) because that part is a mix of the traditional no-UNICODE (pdf)TeX and luatex, that manages UTF-8.
> The |pseudo| buffer for |show_contex| is a bit complicated.
> 
> --
> luigi



More information about the luatex mailing list.