TECO-64
TECO-64 copied to clipboard
Goto gets NCA error when buffer is empty
I found the bug when testing part of squ.tes
from TECOC lib, below has a minimal example to reproduce the error.
The conditions needed to reproduce the bug I found are:
- The goto and label is inside a macro register
-
^YK
has been called inside the macro level - When the goto
O
is called the buffer is empty
In most of the case in squ.tes
when the macro is called the buffer wouldn't be empty, but I have tested the same example in TECOC and it
has no problem even when the buffer is empty.
As a side note rewrite goto using loop '< >' can work around this issue.
This bug reproduces both on macOS (built with Clang) and Linux (built with GCC).
*eitest.tes``
Delete CR/LF (Y/N) <N>? 12^U?NCA Negative argument to comma
^D ! set decimal !
0ED ! set edit mode zero !
0^X ! set search mode zero !
0,128ET ! set abort-on-error !
! R get Response from user !
@^UR*
^YX0
^YK ! kill last inserted string XXX: if move outside macro won't reproduce !
.U1 ! num 1 <- current point !
ZJ ! go to end !
.U2 ! num 2 <- save buffer end pos !
! display the prompt on a new, clean, line !
!PMPT!
13^T10^T ! type <CR><LF> !
:G0 ! type str 0 !
Q2,ZT ! and input so far !
!GETCH!
^TU0 ! read char to num 0 !
Q0-21 "E ! if char = ^U !
Q2,ZK ! XXX: when the buffer is empty !
! XXX: the goto would fail by ?NCA !
@O!PMPT! ! go to PROMPT !
' ! fi !
Q0-27 "E ! if char = <ESC> !
13^T 10^T ! type <CR> <LF> !
@O!DONE! ! go to DONE XXX: if input is empty this would also fail !
' ! fi !
Q0@I// ! insert input char to buffer !
@O!GETCH! ! go to GETCH !
!DONE!
Q1J ! restore to original buffer position !
* ! end of ^UR !
@I+Delete CR/LF (Y/N) <N>? + ! str 0 <- display prompt !
MR
HT
^[^[