[tex-k] Bug in tex.ch (?-prompt)
Heiko Oberdiek
oberdiek at uni-freiburg.de
Tue May 4 06:15:01 CEST 2004
Hello,
I tried pdftex-1.20a-rc2 and run into a problem with the "?" prompt
after errors. User input is ignored.
Example:
\csname\relax
\end
TeX respondes with:
| ! Missing \endcsname inserted.
| <to be read again>
| \relax
| l.1 \csname\relax
|
| ?
Regardless of user input (eg. 'h', 'f', 'x', ...) TeX behaves
as only the "return" key is pressed:
| No pages of output.
| Transcript written on test.log
Looking at the code:
tex.web, "Get user's advice". For testing I added 'print("RETURN")':
| @ @<Get user's advice...@>=
| loop at +begin continue: clear_for_error_prompt; prompt_input("? ");
| @.?\relax@>
| if last=first then begin print("RETURN"); return; end;
| c:=buffer[first];
| if c>="a" then c:=c+"A"-"a"; {convert to uppercase}
| @<Interpret code |c| and |return| if done@>;
| end
So "RETURN" is printed always, proving that "last=first"
regardless of the length of user input.
Next step: "prompt_input" calls "term_input":
| @d prompt_input(#)==begin wake_up_terminal; print(#); term_input;
| end {prints a string and gets a line of input}
In "term_input" the "EQUAL" lines are for testing:
| @p procedure term_input; {gets a line from the terminal}
| var k:0..buf_size; {index into |buffer|}
| begin update_terminal; {now the user sees the prompt for sure}
| if not input_ln(term_in,true) then fatal_error("End of file on the terminal!");
| @.End of file on the terminal@>
| if last<>first then print(" <NOT EQUAL-1> ") else print(" <EQUAL-1> ");
| term_offset:=0; {the user's line ended with \<\rm return>}
| decr(selector); {prepare to echo the input}
| if last<>first then for k:=first to last-1 do print(buffer[k]);
| print_ln; incr(selector); {restore previous status}
| if last<>first then print(" <NOT EQUAL-2> ") else print(" <EQUAL-2> ");
| end;
Result: " <NOT EQUAL-1> <EQUAL-2> "
In the differences between tex.ch of teTeX-src-beta-2.96.1.20040322
and tex.ch from pdftex-1.20a-rc2 I found:
+ @x [5.71] encTeX - native buffer printing
+ if last<>first then for k:=first to last-1 do print(buffer[k]);
+ @y
+ while first < last do begin print_buffer(first) end;
+ @z
and
+ @ The |print_buffer| procedure prints one character from |buffer|[|i|].
+ It also increases |i| to the next character in the buffer.
So apparently "first" is incremented until it is equal to "last".
Then this causes the early return in "Get user's advice".
Fix suggestion for the lines in tex.ch:
@x [5.71] encTeX - native buffer printing
if last<>first then for k:=first to last-1 do print(buffer[k]);
@y
if last<>first then for k:=first to last-1 do print_buffer(k);
@z
Yours sincerely
Heiko <oberdiek at uni-freiburg.de>
--
More information about the tex-k
mailing list