aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2025-08-06command-line arguments are no longer passed via the unnamed buffer, but via ↵Robin Haberkorn1-3/+12
special Q-registers ^Ax * The unnamed buffer is also used for reading from --stdin, so you couldn't practically combine --stdin with passing command-line arguments to macros. * The old approach of passing command-line arguments via lines in the unnamed buffer was flawed anyway as it wouldn't work with filenames containing LF. This is just a very ancient feature, written when there weren't even long Q-reg names in SciTECO. * You can now e.g. pipe into SciTECO and edit what was read interactively, e.g. `dmesg | sciteco -i`. You can practically use SciTECO as a pager. * htbl.tes is now a command-line filter (uses -qio). * grosciteco.tes reads Troff intermediate code from stdin, so we no longer need "*.intermediate" temporary files. * added a getopt.tes test case to the testsuite. * This change unfortunately breaks most macros accepting command-line arguments, even if they used getopt.tes. It also requires updating ~/.teco_ini - see fallback.teco_ini.
2025-08-03testsuite: use --quiet and test output of stdio commands more thoroughlyRobin Haberkorn1-27/+46
* All test suite commands are now invoked with --quiet. When having to check the stdout of the test runs, you now longer have to filter "Info:" lines out or include them in the expout. * Use expout to compare the outputs of the stdio commands instead of just counting the number of output lines. * The <EO> command check is simplified by doing the arithmetics in SciTECO. * test the --stdin and --stdout options as well
2025-08-02fixed serious bug with certain alternative string termination chars in ↵Robin Haberkorn1-0/+3
commands with multiple string arguments * When `@`-modifying a command with several string arguments and choosing `{` as the alternative string termination character, the parser would get totally confused. Any sequence of `{` would be ignored and only the first non-`{` would become the termination character. Consequently you also couldn't choose a new terminator after the closing `}`. So even a documented code example from sciteco(7) wouldn't work. The same was true when using $ (escape) or ^A as the alternative termination character. * We can now correctly parse e.g. `@FR{foo}{bar}` or `@FR$foo$bar$` (even though the latter one is quite pointless). * has probably been broken forever (has been broken even before v2.0). * Whitespace is now ignored in front of alternative termination characters as in TECO-64, so we can also write `@S /foo/` or even ``` @^Um { !* blabla *! } ``` I wanted to disallow whitespace termination characters, so the alternative would have been to throw an error. The new implementation at least adds some functionality. * Avoid redundancies when parsing no-op characters via teco_is_noop(). I assume that this is inlined and drawn into any jump-table what would be generated for the switch-statement in teco_state_start_input(). * Alternative termination characters are still case-folded, even if they are Unicode glyphs, so `@IЖfooж` would work and insert `foo`. This should perhaps be restricted to ANSI characters?
2025-08-01fixed the test suite on Mac OSRobin Haberkorn1-1/+1
`echo -n` is not POSIX and obviously not supported on Mac OS' standard shell.
2025-08-01implemented the ^W command for refreshing the screen in loops, for sleeping ↵Robin Haberkorn1-1/+1
and also the CTRL+L immediate editing command * ^W can be added to loops in order to view progress in interactive mode. It also sleeps for a given number of milliseconds (10ms by default). * In batch mode it is therefore the sleep command. * Since CTRL+W is an immediate editing command, you will usually type it Caret+W. ASCII 23 however will also be accepted. * While ^W only updates the screen, you can force a complete redraw by pressing CTRL+L. This is what most terminal applications use for redrawing. It will make it harder to insert ASCII 12, but this is seldom necessary since it is a form feed. ^L (ASCII 12 and the upcaret variant ) is still a whitespace character and therefore treated as a NOP. * DEC TECO had CTRL+W as the refresh immediate editing command. Video TECO uses <ET> as a regular command for refreshign in loops. I'd rather keep ET reserved as a potential terminal configuration command as in DEC TECO, though.
2025-07-31added -v/--version and <EO> commandRobin Haberkorn2-0/+8
* DEC TECO had an <EO> command. In contrast to DEC TECO's implementation, the value reported by <EO> encodes a major.minor.micro semantic version.
2025-07-31implemented ^H command for returning the current time since midnight: ↵Robin Haberkorn1-2/+2
partially replaces ^B * :^H and ::^H now return the timestamps, while ^B only returns the date. * Pressing CTRL+H will rubout, so you will usually write it in upcaret mode.
2025-07-31implemented ^T command: allows typing by code and getting characters from ↵Robin Haberkorn1-0/+7
stdin or the user * n:^T always prints bytes (cf. :^A) * ^T without arguments returns a codepoint or byte from stdin. In interactive mode, this currentply places a cursor in the message line and waits for a keypress.
2025-07-28=/==/===: fixed detection of execution from the end of the command-lineRobin Haberkorn1-0/+2
In particular, fixes the test case `3<255=>` which would print only one number in interactive mode.
2025-07-27fixed using the command-line replacement register (ESC) in batch mode: was ↵Robin Haberkorn1-0/+9
causing assertions when entering interactive mode Also added a regression test case.
2025-07-27fixed a,b,c^Uq...$: The arguments where written in the wrong (reverse) orderRobin Haberkorn1-2/+2
* When writing UTF-8, we must first peek in reverse order since we can only write from left to right. * When writing in raw ANSI, we can immediately pop the values from the stack but must write in reverse.
2025-07-26properly document some functions in expressions.c and simplified codeRobin Haberkorn1-0/+2
* Practically all calls to teco_expressions_args() must be preceded by teco_expressions_eval(). * In code paths where we know that teco_expressions_args() > 0, it is safe to call teco_expressions_pop_num(0) instead of teco_expressions_pop_num_calc(). This is both easier and faster. * teco_expressions_pop_num_calc() is for simple applications where you just want to get a command argument with default (implied) values. Since it includes teco_expressions_eval(), we can avoid superfluous calls. * -EC...$ turned out to be broken and is fixed now. A test case has been added.
2025-07-26implemented the <T> (typeout) command for printing to the terminal from the ↵Robin Haberkorn1-0/+9
current buffer * refactored some code that is common with Xq into teco_get_range_args().
2025-07-26support :=/:==/:=== commands: print number without trailing linefeedRobin Haberkorn1-0/+4
2025-07-26implemented the <^A> command for printing arbitrary stringsRobin Haberkorn1-0/+6
* Greatly improved usability as a scripting language. * The command is in DEC TECO, but in contrast to DEC TECO, we also support string building constructs in ^A. * Required some refactoring: As we want it to write everything verbatim to stdout, the per-interface method is now teco_interface_msg_literal() and it has to deal with unprintable characters. When displaying in the UI, we use teco_curses_format_str() and TecoGtkLabel functions/widgets to deal with possible control codes. * Numbers printed with `=` have to be written with a trailing linefeed, which would also be visible as a reverse "LF" in the UI. Not sure whether this is acceptable - the alternative would be to strip the strings before displaying them. * Messages written to stdout are also auto-flushed at the moment. In the future we might want to put flushing under control of the language. Perhaps :^A could inhibit the flushing.
2025-07-21support <==> and <===> for printing octal and hexadecimal numbersRobin Haberkorn1-1/+10
* These are famously in DEC TECO-11, but also in Video TECO. * The implementation is tricky. They need to use lookahead states, but this would be inacceptable during interactive execution. Therefore only if executing from the end of the command line `==` and `===` are allowed to print multiple values. The number is therefore also not popped form the stack immediately but only peeked. It's popped only when it has been decided that the command has ended. * This may break existing macros that use multiple `=` in a row to print multiple values from the stack. You will now e.g. have to insert whitespace to separate such `=` commands.
2025-07-20document bug: you cannot currently use `{` and `}` to insert anything after ↵Robin Haberkorn1-1/+9
$$ into the commandline
2025-07-19special Q-registers `$` (working directory) and the clipboard registers now ↵Robin Haberkorn1-0/+5
support the append operation (:Xq, :^Uq...) Works via a default implementation in the "external" Q-register "class" by first querying the string, appending and re-setting it.
2025-07-19fixed <EF> and <EW> with invalid buffer ids (was crashing)Robin Haberkorn1-0/+6
* regression introduced in 2baa14add6d9976c29b27cf4470bb458a0198694
2025-07-19<EW> now accepts a numeric argument to specify the buffer to saveRobin Haberkorn1-0/+7
* In this case we always save the given buffer and never the current Q-Register. * The current Q-Register is only saved without any numeric argument. The same semantics make sense for <EF> so that Q*EF closes the current buffer even when editing a Q-Register. * This variant is present in Video TECO.
2025-07-18support <:]q> (pop Q-Register) for getting a success/failure booleanRobin Haberkorn1-0/+1
* Could be used to check whether the stack is currently empty, although peeking would be cumbersome: `:]q"S [q !...! | !...! '` * This is from DEC TECO-11.
2025-07-18fixed minor memory leaks of per-state data in teco_machine_main_tRobin Haberkorn1-0/+10
* These were leaked e.g. in case of end-of-macro errors, but also in case of syntax highlighting (teco_lexer_style()). I considered to solve this by overwriting more of the end_of_macro_cb, but it didn't turn out to be trivial always. * Considering that the union in teco_machine_main_t saved only 3 machine words of memory, I decided to sacrifice those for more robust memory management. * teco_machine_qregspec_t cannot be directly embedded into teco_machine_main_t due to recursive dependencies with teco_machine_stringbuilding_t. It could now and should perhaps be allocated only once in teco_machine_main_init(), but it would require more refactoring.
2025-07-13implemented <ER> command for reading a file into the current bufferRobin Haberkorn1-0/+6
* This command exists in Video TECO. In Video TECO it also supports reading multiple files with a glob pattern -- we do not support that as I am not convinced of its usefulness. * teco_view_load() has been extended, so it can read into dot without discarding the existing document.
2025-07-11<EF> supports a numeric buffer id nowRobin Haberkorn1-0/+6
* ED hooks are not executed in this case * <EF> is now allowed even when editing a Q-Reg, unless you try to close the current buffer
2025-07-04implemented <^B> for returning the current dateRobin Haberkorn1-0/+5
* It is encoded with the same formula as on VAX/VMS on TECO-11, on TECOC and TECO-64. * As an extension, when colon-modified it returns the number of seconds since the epoch. It might be even more useful to return the microseconds since the epoch, but that would require 64-bit integers, which can theoretically be disabled at build time.
2025-07-03implemented ^E<code> string building constructs for embedding bytes and ↵Robin Haberkorn1-1/+5
codepoints in a strtoul()-like manner
2025-06-27fixed ^S/^Y for <Gq> and <EN>Robin Haberkorn1-0/+3
* We must call teco_interface_bytes2glyphs() only ever with byte offsets that already exist in the buffer. * regression, introduced in aaa1d51a4c85fcc627e88ef7cf5292d9c5f5f840
2025-06-08^S/^Y calculates the glyph offsets earlierRobin Haberkorn1-1/+3
* Previously, deleting text after a text match or insertion could result in wrong ^S/^Y results. In particular, the amount of characters deleted by <FD> at the end of a buffer couldn't be queried. * This also fixes the M#rf (reflow paragraph) macro.
2025-06-07added <FN> as a search-and-replace variant of <N>Robin Haberkorn1-0/+7
* This is not in Video TECO, but TECO-11 has a search-and-replace variant of <N>. <N> however is a search-over-page-boundary command in TECO-11, which has been repurposed as search-over-buffer-boundary in Video TECO and SciTECO. * <N> and <FN> no longer call the edit hook after *every* invocation, but only if the current buffer changes. This is not really relevant with the current default hook from fallback.teco_ini, but might be depending on the use case. * Added testcases both for <N> and <FN>.
2025-06-01<nA> and <nQq> now return -1 in case the index n is out of rangeRobin Haberkorn1-0/+5
* The old behavior of throwing an error was inherited from Video TECO. * The command is now more similar to TECO-11. * Since -1 is taken, invalid and incomplete UTF-8 byte sequences are now reported as -2/-3. I wasn't really able to provoke -3, though.
2025-05-24<EI> has been repurposed and is the macro file inclusion (indirect file) ↵Robin Haberkorn1-3/+3
command now * Improves DEC TECO-11 compatibility. * <EM> is still supported as a synonym, but considered deprecated and is no longer documented. A warning is printed when invoked. It can be repurposed at any time in the future. * `EI$` is not yet supported. I am unsure whether this makes any sense.
2025-05-23<^C> is a plain "return" command now, while <^C^C> exits from the programRobin Haberkorn1-4/+13
* This may break existing macros! ^C is now essentially a synonym for $$ and may not terminate the program when called from a non-toplevel macro frame. However it improves compatibility with TECO-11. * In contrast to TECO-11, ^C^C (exit) can be typed completely in upcaret mode. Otherwise it wouldn't have been possible to use the exit command in ASCII-only scripts. * The implementation of ^C^C uses a lookahead state similar to ^[ (escape). ^C does not return immediately, but the following character determines whether it will perform a return or exit. It's one of the rare cases in SciTECO where this is possible and safe since ^C is also disallowed on the command-line to avoid undesired command-line terminations after ^C interruptions. (You can only use $$ to terminate the command-line interactively.)
2025-05-18allow process exit status to be determined by macrosRobin Haberkorn1-8/+14
* Any value left on the numeric stack now determines the exit code. This ensures you can call n^C as the SciTECO version of exit(n). It will also work with n$$ in the top level macro. But you don't necessarily need any of these commands. * Could be useful in shell scripting as in `sciteco -e "@EB/file/ :@S/foo/\"F1'"` to fail `foo` is not found.
2025-05-13revised test suite: got rid of most escaping for the TECO code snippetsRobin Haberkorn2-172/+179
* Test cases where hard to read since there was a layer of shell and M4 escaping -- sometimes with the help of quadrigraphs -- to preserve the original TECO characters. * We introduced TE_CHECK() and TE_CHECK_CMDLINE() M4 macros which care about shell escaping automatically. * If all TECO code is double quoted with [[ and ]], single square and round brackets are preserved as well. * Only in case of using *unbalanced* single square brackets, you have to take action and add `![!` or `!]!` TECO comments to balance them out. This is still better than quadrigraphs. * The $ESCAPE and $RUBOUT environment variables are replaced by equivalent M4 macros, so they can be used with TE_CHECK_CMDLINE(). * Other references to shell variables have been resolved by exporting them into the environment (as in the case of $srcdir) or by introducing new M4 macros (TE_MAXINTxx, TE_MININTxx). * The $WORDS_EXAMPLE variable has been got rid of by writing it into a temporary file instead. There is some redundancy -- in principle an M4 macro could have also been used. * This leaves only 6 remaining usages of AT_CHECK() for invoking SciTECO, mainly for testing opener.tes, where we have to pass in command line arguments. In theory most of them could be avoided as well by preparing the unnamed buffer appropriately. However the way that command line parameters are passed will be changed sooner or later. * This uses GNU M4 extensions, but Autoconf requires that anyway.
2025-05-03disallow command-line termination ($$) while editing the command-line ↵Robin Haberkorn1-0/+5
replacement register (after `{`) I found that terminating the command-line while editing the replacement register, leaves you in a hard-to-recover state. You can/should no longer call `}`, so you would have to go back to the last buffer (Q*U*). Instead, this is now checked against and a test case has also been added.
2025-05-03fixed teco_doc_undo_exchange(): use reference counting nowRobin Haberkorn1-1/+16
* When popping from the Q-Register stack to local Q-Registers in macro calls, problems would arise when rubbing out that macro call since we would eventually restore a pointer that has been permanently freed along with the local Q-Registers. * Naturally this could result in everything from Valgrind warnings to crashes. * Added test case. * There is still a test case that fails when run under `--valgrind`, but it's apparently due to a glib-internal memory leak.
2025-04-27opener.tes: Fixed +line,column syntaxRobin Haberkorn2-6/+18
* After detecting +line[,column] constructs, the next argument is not parsed as a potential filename:line[:column] construct. * This code turned out to be tricky to get right, so I added a test case. Standard library modules can well be checked in the test suite since we have $SCITECOPATH pointing to the source tree's lib/ directory. * Make sure that relevant variables from atlocal.in are really exported into the process environment. This was also broken for the Glib debug options.
2025-04-13fixed undoing bitfields on WindowsRobin Haberkorn1-0/+6
* It turns out that `bool` (_Bool) in bitfields may cause padding to the next 32-bit word. This was only observed on MinGW. I am not entirely sure why, although the C standard does not guarantee much with regard to bitfield memory layout and there are 64-bit available due to passing anyway. Actually, they could also be layed out in a different order. * I am now consistently using guint instead of `bool` in bitfields to prevent any potential surprises. * The way that guint was aliased with bitfield structs for undoing teco_machine_main_t and teco_machine_qregspec_t flags was therefore insecure. It was not guaranteed that the __flags field really "captures" all of the bit field. Even with `guint v : 1` fields, this was not guaranteed. We would have required a static assertion for robustness. Alternatively, we could have declared a `gsize __flags` variable as well. This __should__ be safe since gsize should always be pointer sized and correspond to the platform's alignment. However, it's also not 100% guaranteed. Using classic ANSI C enums with bit operations to encode multiple fields and flags into a single integer also doesn't look very attractive. * Instead, we now define scalar types with their own teco_undo_push() shortcuts for the bitfield structs. This is in one way simpler and much more robust, but on the other hand complicates access to the flag variables. * It's a good question whether a `struct __attribute__((packed))` bitfield with guint fields would be a reliable replacement for flag enums, that are communicated with the "outside" (TECO) world. I am not going to risk it until GCC gives any guarantees, though. For the time being, bitfields are only used internally where the concrete memory layout (bit positions) is not crucial. * This fixes the test suite and therefore probably CI and nightly builds on Windows. * Test case: Rub out `@I//` or `@Xq` until before the `@`. The parser doesn't know that `@` is still set and allows all sorts of commands where `@` should be forbidden. * It's unknown how long this has been broken on Windows - quite possibly since v2.0.
2025-04-10testsuite: check whether comparisons for equality really work with the ↵Robin Haberkorn1-0/+11
`a-b"=` idiom * There might theoretically be problems with the uncommon one's complement or magnitude representation of negative integers, but it's practically impossible to meet those in the wild. * Still, we do some checks now, so we will at least notice any exotic architectures. * Also, documented the `a^#b"=` idiom for checking for equality. It's longer to type, but faster and will also work for floats. For floats it will be the only permissible idiom for checking for bitwise equality as `a-b` can be 0 even if a!=b (if the difference is very small). Changing the `-` semantics is out of the question.
2025-04-10fixed formatting of the smallest possible integerRobin Haberkorn2-0/+16
* In other words, fixed `-9223372036854775808\` on --with-teco-integer=64 (which is the default). * The reason is that ABS(G_MININT64) == G_MININT64 since -G_MININT64 == G_MININT64. It is therefore important not to call ABS() on arbitrary teco_int_t's.
2025-04-09tightened rules for specifying modifiersRobin Haberkorn1-7/+8
* Instead of separate stand-alone commands, they are now allowed only immediately in front of the commands that accept them. * The order is still insignificant if both `@` and `:` are accepted. * The number of colon modifiers is now also checked. We basically get this for free. * `@` has syntactic significance, so it could not be set conditionally anyway. Still, it was possible to provoke bugs were `@` was interpreted conditionally as in `@ 2<I/foo/$>`. * Even when not causing bugs, a mistyped `@` would often influence the __next__ command, causing unexpected behavior, for instance when typing `@(233C)W`. * While it was theoretically possible to set `:` conditionally, it could also be "passed through" accidentally to some command where it wasn't expected as in `:Ifoo$ C`. I do not know of any real useful application or idiom of a conditionally set `:`. If there would happen to be some kind of useful application, `:'` and `:|` could be re-allowed easily, though. * I was condidering introducing a common parser state for modified commands, but that would have been tricky and introduce a lot of redundant command lists. So instead, we now simply everywhere check for excess modifiers. To simplify this task, teco_machine_main_transition_t now contains flags signaling whether the transition is allowed with `@` or `:` modifiers set. It currently only has to be checked in the start state, after `E` and `F`.
2025-04-08improved rubbing out commands with modifiersRobin Haberkorn2-6/+35
* This was actually broken if the command is preceded by `@` and `:` characters, which are __not__ modifiers. E.g. `Q:@I/foo^W` would have rubbed out the `:` register as well. * Also, since it was all done in teco_state_process_edit_cmd(), it would also rub out modifier characters from within string arguments, E.g. `@I/::^EQ^W` * Real commands now have their own ^W rubout implementation, while the generic fallback just rubs out until the start state is re-established. This fails to rub out modifiers as in `@I/^W`, though. * Real command characters now use the common TECO_DEFINE_STATE_COMMAND(). * Added test cases for CTRL+W rub out. A few control characters are now portably available to tests via environment variables `$ESCAPE`, `$RUBOUT` and `$RUBOUT_WORD`.
2025-03-29bumped target release to v2.4.0 and updated README and TODORobin Haberkorn1-0/+8
* Added a test case for the known bug of out-of-place modifiers. Well, this is a syntactic shortcoming rather than a true bug. But I did run into it more than once.
2025-03-29added `@W`, `@P`, `@V` and `@Y` command variantsRobin Haberkorn1-4/+4
* They swap the default order of skipping characters. For positive arguments: first non-word chars, then word chars. * This is especially useful after executing the non-at-modified versions. For instance, at the beginning of a word, `@W` jumps to its end. `@V` would delete the remainder of the word. * Since they have to evaluate the at-modifier, which has syntactic significance, the command implementations can no longer use transition tables, so they are in the switch-statements instead.
2025-03-22added `P` command as a reverse form of `W`Robin Haberkorn1-2/+1
* All the movement commands have shortcuts for their negative forms: `R` instead of `-C`, `B` instead of `-L`. Therefore there was always the need for a `-W` shortcut as well. * `P` is a good choice because it is a file IO command in TECO-11, that does not make sense supporting. In Video TECO it toggles between display windows (ie. split screens) and I do not plan to support multiple windows in SciTECO. * Added to the cheat sheet.
2025-03-22harmonized all word-movement and deletion commands: they move/delete until ↵Robin Haberkorn1-5/+6
the beginning of words now * All commands and their documentations were inconsistent. * ^W rubbed out to the beginning of words. * Shift+Right (fnkeys.tes) moved to the beginning of the next word if invoked at the beginning of a word and to the end of the next word otherwise. * <W> (and <V> and <Y> by extension) moved to the end of the next word. * The cheat sheet would claim that <W> moves to the beginning of the next word. * Video TECO's <W> command would differ again from everything else. With positive arguments, it moved to the beginning of words, while with negative it moved to end of words. I decided not to copy this behavior. * It has been decided to adopt a consistent beginning-of-words policy. -W therefore differs from Video TECO in moving to the beginning of the current or previous word. * teco_find_words() is now based on parsing the document pointer, instead of relying on SCI_WORDENDPOSITION, since the latter cannot actually be used to skip strictly non-word characters. This requires a constant amount of Scintilla messages but will require fewer messages only when moving for more than 3 words. * The semantics of <W> are therefore now consistent with Vim and Emacs as well. * Shift+Right/Left is still based on SCI_WORDENDPOSITION, so it's behavior differs slightly from <W> for instance at the end of lines, as it will stop at linebreaks. * Unfortunately, these changes will break lots of macros, among others the M#rf, M#sp and git.blame macros ("Useful macros" from the wiki).
2025-03-21fixed rubout of Q-Register specificationsRobin Haberkorn1-0/+6
* This was a regression introduced by 257a0bf128e109442dce91c4aaa1d97fed17ad1a. * The undo token that frees newly allocated teco_machine_qregspec_t must actually reset the pointer as well since any subsequent token, pushed by teco_undo_qregspec_own(), will expect a valid pointer. * Could have been done via ctx->expectqreg = NULL; teco_undo_qregspec_own(ctx->expectqreg); but using a special clear function requires less memory and is easier to understand. * Added test case. This wouldn't always crash, but should definitely show up in Valgrind.
2025-03-19fixed leaking data on ruboutRobin Haberkorn1-0/+3
* Objects, that are restored with TECO_DEFINE_UNDO_OBJECT_OWN(), could actually leak memory on rubout since the old object was not deleted when overwriting it. * Now that it is, it is crucial to at least nullify objects/pointers after calling the corresponding push-function. These conditions are now explicitly documented. * The test suite now runs successfully under Valgrind even with full leak checking.
2025-03-17test suite: perform leak checking when run under ValgrindRobin Haberkorn1-1/+1
This became the default in later Valgrind versions. With leak checking, the test suite does not currently run cleanly.
2025-03-13rewrote <W> command on the same basis as <V> and <Y>Robin Haberkorn2-2/+11
* <W> was also using keyboard movement commands. * This fixes an inconsistency between the handling of punctuation characters, e.g. "(word" followed by -W vs. Y.