fpjohnston / teco-64 Goto Github PK
View Code? Open in Web Editor NEWEnhanced and portable version of TECO text editor in C.
Enhanced and portable version of TECO text editor in C.
If the search buffer is empty (that is, there has been no previous search yet), and a user executes an N command without a text argument, TECO will crash, as shown in the following example on Linux:
teco -n -C foo.baz
*N``
Segmentation fault (core dumped)
This does not occur when using an equivalent S command. In that case, a search failure (SRH) error is issued, which is what should happen with the N command.
Making env_sys.o
../src/env_sys.c: In function 'teco_env':
../src/env_sys.c:225:13: error: a label can only be part of a statement and a declaration is not a statement
225 | pid_t pid = tcgetpgrp(STDIN_FILENO);
| ^~~~~
make: *** [Makefile:411: env_sys.o] Error 1
https://stackoverflow.com/questions/8384388/variable-declaration-after-goto-label
*iZZZZZ`j``
*0A=``
90
*(0A*2)=``
180
*(0A+(0A))=``
180
*(0A==(0A))=``
0
*(0A==90)=``
0
*((0A)==(1A))=``
0
The last three expressions should give -1
(true)
this problem is specifically with variable in the formnA
as other variables such as (Z==Z)
does give expected results.
When using this sequence of commands:
From the Linux command shell (testfile.txt is an existing, non empty text file).
#> teco testfile.txt
*
* 5,7:w`-w``
will split the screen in two halves as expected, but no text is visible.
One needs to press <CTRK/K> to switch the background of the video mode screen white
and the text black, which is confusing and not expected.
Line 73 in 2eaf629
There is an undocumented extension command from TECOC,
::FStext1$text2$
, accept no numeric arguments, functioning the same as .,.+1:FCtext1$text2%
, that is replace only if the string immediately after the point matches, and return search status. (The source code comment in TECOC is a bit wrong because it forgets that FS
took two text arguments)
https://github.com/blakemcbride/TECOC/blob/b4a96395a18c7e64ccaef0e25fdde3b7ef33ac4b/src/exef.c#L226
There is a file on my harddisk:
-rw-r--r-- 1 tuxic users 67105 2023-11-05 17:50 Tecotest.txt
When I start teco like this
teco
which is an alias to teco-64 (system is a up-to-date Gentoo Linux, rolling release).
and give this command:
EBTecotest.txt``
everything seems to be fine (no error message or any message at all).
When giving
P``
teco crashes with:
[1] 27531 segmentation fault teco-64
$ make -d
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
Reading makefiles...
Reading makefile `Makefile'...
Reading makefile `etc/make/sources.mk' (search path) (no ~ expansion)...
Reading makefile `etc/make/display.mk' (search path) (no ~ expansion)...
etc/make/display.mk:36: *** missing separator. Stop.
I try to replace some UTF-8 characters in a file use FS
command: (save the text below to a file and call EI
)
0J<@FS/ᴇ/E/;>
^[^[
This works with TECOC since I guess that is 8bit clean. However this failed to work with TECO-64.
Neither using ^Q
to quote would work:
0J<@FS/^Qᴇ/E/;>
^[^[
I also tried to put ^Q
before every byte of ᴇ
but had no luck. Input ᴇ
using 225i180i135i
works so I'm surprised searching UTF-8 would not work.
Is this a limitation of TECO-64 or there is a way to work around this?
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:
^YK
has been called inside the macro levelO
is called the buffer is emptyIn 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
^[^[
This might be more of a feature request than bug report.
A interesting phrase I found in squ.tes
has interleaved loop and conditional constructs
< D .-Z; 0A"D > '
and the effect is delete digits from current point until there is no more. (although the ?UTC
would be thrown at run time if noun digit is encountered in TECOC)
Apparently the traditional TECO treats control flow commands as anchor points to go to, where TECO-64 works differently.
Consulting the Standard TECO user guide, I was wondering the lack of unconditional exit from loop construct, and if interleave loop with conditional is allow then I would not be surprised the "intentional" omitting of such construct.
How about an "install" target for the makefile?
The TECO manual does say nth tag in n@O/tag1,tag2,.../
, however TECO C does use 0 origin for computed goto, that is n=1 selects tag2
. In my opinion TECO-64 got it right. Maybe a feature flag can be added to facilitate this.
This function is not POSIX and not part of my SDK.
TECO is able to edit binary files, but doing so in display mode may not work as expected, due to the fact that the code currently expects the edit buffer to include some line delimiters. This may be addressed eventually, but for now please be aware of this limitation.
Thank you very much for rebuilding the legend! :)
I am running Gentoo Linux.
gcc
gcc (Gentoo 12.3.1_p20230825 p2) 12.3.1 20230825
glibc
2.38-r6
binutils
2.41-r2
ldd
ldd (Gentoo 2.38-r6 (patchset 6)) 2.38
To compile teco-64 I did a 'make' in the root of the clone repo and got this error message:
gcc -o bin/teco @obj/objects.lis -l ncurses -Ofast -s
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: obj/display.o: undefined reference to symbol 'TABSIZE'
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:68: bin/teco] Error 1
[1] 18699 exit 2 make
Beside this, the compiler suit works fine - Gentoo is a source-only distro, you need to compile everything locally.
How can I compile teco-64 successfully?
And a fix is provided:
diff --git a/src/flag_cmd.c b/src/flag_cmd.c
index e73646a2..9ede57df 100644
--- a/src/flag_cmd.c
+++ b/src/flag_cmd.c
@@ -514,9 +514,13 @@ bool scan_flag1(struct cmd *cmd)
confirm(cmd, NO_N);
struct ifile *ifile = &ifiles[istream];
- int_t eof = feof(ifile->fp) ? -1 : 0;
+ if (ifile->fp == NULL)
+ store_val(0);
+ else {
+ int_t eof = feof(ifile->fp) ? -1 : 0;
- store_val(eof);
+ store_val(eof);
+ }
return true;
}
I am using GENTOO Linux, the newest version of TECO-64 sources, and sys-libs/ncurses-6.4_p20230401, sys-libs/glibc-2.38-r7.
I compiled TECO-64 myself.
When starting video mode like this:
5,7:w`-w``
<CTRL/K>
I get a white background with black characters (see previous issue).
Lets make it colorful!
@F2/blue/green/``
...nothing happens.
<CTRL/K>
The colors had changed!...but the color combo is bad for my eyes. Let's change them again:
@F2/white/blue/``
Nothing happens.
<CTRL/K>
Got stuck...nothing changed.
This is not expected/
I am sure, this is a definitely a bug, but I am completely unsure, whether it is my bug or a slight glitch in teco.
From the command line from within teco:
@^Uv/5,7:w`-w`/``
and executed via
mv``
works fine.
Putting the same into init.tec results in this error message:
?ILL Invalid command '<^P>'
[1] 7897 exit 1 teco-64
Making errors.o
../src/errors.c: In function 'print_error':
../src/errors.c:253:21: error: 'ulong' undeclared (first use in this
function); did you mean 'u_long'?
253 | (ulong)cmd_line);
| ^~~~~
| u_long
../src/errors.c:253:21: note: each undeclared identifier is reported
only once for each function it appears in
../src/errors.c:253:27: error: expected ')' before 'cmd_line'
253 | (ulong)cmd_line);
| ^~~~~~~~
| )
../src/errors.c: In function 'throw':
../src/errors.c:458:1: warning: 'noreturn' function does return
458 | }
| ^
make: *** [Makefile:420: errors.o] Error 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.