In the original TeX program, the `tally` variable is increased whenever `print_char` is called (except when character `s` is newline), regardless of `selector`.
However, in `tprint` function of LuaTeX, `tally` is only called when `selector` is `pseudo`. This leads to incorrect indentation of the second line, for example the following TeX file ```tex \errorcontextlines=10000 \def\c{1 \errorerror 2} \def\b #1 {7 #1 8} \def\a{5 \b {3 \c 4} 6} \hbox{7 \a 8} \stop ``` would lead to the following error (observe that the `<argument>` line is wrong): ``` \c ->1 \errorerror 2 <argument> 3 \c 4 \b #1 ->7 #1 8 \a ->5 \b {3 \c 4} 6 l.5 \hbox{7 \a 8} ``` I have two ideas how to fix it. One is to add `strlen(sss)` to `tally` regardless. The other is the following. This would still be incorrect if `selector` is `no_print` or `term_only`, however I think these cases will not happen. ```diff diff --git a/source/texk/web2c/luatexdir/tex/printing.c b/source/texk/web2c/luatexdir/tex/printing.c index 8a52700..b628280 100644 --- a/source/texk/web2c/luatexdir/tex/printing.c +++ b/source/texk/web2c/luatexdir/tex/printing.c @@ -498,6 +498,7 @@ void tprint(const char *sss) t_flush_buffer(log_file,file_offset); } } + tally++; } if (*buffer) { buffer[i++] = '\0'; ``` I'm not sure which option is faster (on one hand the `strlen()` option need a separate loop, on the other hand it's a built-in library function so it should be fast?) Regardless, if performance doesn't matter that much, I think `strlen()` option is better. ------ On an academical note, there is still a small difference between LuaTeX and PDFTeX with the following patch. With the following TeX code ```tex \errorcontextlines=10000 \newlinechar=`u \def\c{1 \errorerror 2} \def\b #1 {7 #1 8} \def\a{5 \b {3 \c 4} 6} \hbox{7 \a 8} \stop ``` then the output of LuaTeX would contains ``` <arg ment> 3 \c 4 ``` with 16 spaces before `4`, while PDFTeX only has 15 spaces before `4`. In practice, chances are nobody cares. For performance reason it's fine to ignore this case.