summaryrefslogtreecommitdiff
path: root/usr.bin/vi
AgeCommit message (Collapse)Author
2024-04-25Don't divide by zero (empty files)Job Snijders
While there, also increase buf[] OK claudio@
2024-04-25add percentage to ruler after recent changes;Jason McIntyre
2024-04-24In ruler show the current line number as a percentage of the total linesJob Snijders
OK claudio@
2024-02-15fix fd leaks in error pathsJonathan Gray
ok miod@
2024-02-14avoid use after free of frp and frp->tnameJonathan Gray
found by smatch, ok miod@ millert@
2024-02-12Add showfilename set optionJob Snijders
Pressing control-G all the time to understand 'what file is in what window' might be tedious. Instead, offer a configurable option (default off) to display the file name in the lower left corner. OK millert@ otto@
2023-09-07Treat consecutive paragraph indicators as different paragraphsTobias Heider
Consecutive empty lines count toward the same state, so there're 2x states (to get in and out). ^L and .PP are counted as text, hitting those in the text should be treated as getting out of a paragraph and then getting in. From Walter Alejandro Iglesias and Zhihao Yuan in nvi2 ok bluhm@
2023-06-23Fix a bug in ex's 's' command with the 'c' flag when 'number' is off.Todd C. Miller
The underlining was positioned in the wrong place. This fixes the problem and matches historic ex behavior. OK op@
2023-01-29Fix ^^D and 0^D description; pointed out by Tomas Rippl; ok jmc@Otto Moerbeek
2022-12-26spelling fixes; from paul tagliamonteJason McIntyre
amendments to his diff are noted on tech
2022-12-10ex_range: fix handling of escaped backslashes.Todd C. Miller
If there are two consecutive backslashes, skip past both so the second is not mistakenly treated as an escape character. This is consistent with how escaped backslashes are treated in ex_substitute() and global(). From Bosco G. G.
2022-04-22escape the word "An" in an Rs/Re block, since it can beJason McIntyre
interpreted as a macro;
2022-04-22Check tkp->output != NULL before taking strlen for both command mappingsTheo Buehler
and input mappings. This adds a missing check for command mappings and simplifies the input mappings. ok millert
2022-04-22vi: apply expandtab to the output of a ! commandTodd C. Miller
This is consistent with vim's expandtab behavior. From nvi2 (Craig Leres). OK tb@
2022-04-21v_event_get: check qp->output for NULL before passing to e_memcmp().Todd C. Miller
Other users of qp->output already include a NULL check. Avoids a crash when cursor key support is disabled in cl/cl_term.c. From Jeremy Mates. OK tb@
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
2022-02-20Fix vi recovery mode.Theo Buehler
From trondd, tested by various ok afresh1
2021-10-25vi(1): fix use after free with unsaved bufferDave Voutila
Issuing a zero-arg ex_edit command (:e) while using a named buffer with no backing file caused vi(1)/ex(1) to free the strings representing the buffer name and the name of the temporary file. This change detects the situation and only frees the newly allocated EXF structure (ep). Reported on bugs@ by kn@. OK millert@
2021-10-24For open/openat, if the flags parameter does not contain O_CREAT, theTheo de Raadt
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert
2021-09-02Make all signal handler functions async-signal-safeIngo Schwarze
by deleting the redundant "killersig" struct member and using the existing sig_atomic_t cl_sigterm variable instead. While here, garbage collect the h_hup() signal handler which is essentially identical to h_term(). This also gets rid of the last #define & #undef in cl_main.c. OK martijn@, and also tested by Tim <trondd at kagu hyphen tsuchi dot com>.
2021-09-01As a first step towards safe signal handling, improve the h_int()Ingo Schwarze
and h_winch() signal handlers to make one single store to a sig_atomic_t variable. Note that the h_hup() and h_term() signal handlers are still unsafe after this commit because they also set the "killersig" (how fitting!) field in a global struct. Despite storing information in static global variables rather than in structs passed around as arguments, this patch does not cause a change in behaviour because there is always exactly one GS object, initialized using gs_init() called from the top of main(), and screen_init() stores a pointer to this one and only GS object in the .gp member of each and every SCR object. Talk about useless abstraction... Problem pointed out by deraadt@. Patch from Tim <trondd at kagu hyphen tsuchi dot com> on tech@. OK deraadt@.
2021-04-13Require that the argument to the window option be non-zero.Todd C. Miller
A zero-row window would not be usable (no room to edit) and the code is full of assumptions that "sp->t_rows - 1" >= 0. From Erik Ruotsalainen, fixes a bug reported by Paul de Weerd.
2021-04-13Ignore expandtab setting when in command mode.Todd C. Miller
Fixes things like searching for a literal tab character when expandtab is enabled. From nvi2 (leres). OK martijn@
2021-03-08Add some references, most of these were removed when we stopped buildingJonathan Gray
and installing USD/SMM/PSD docs. jmc@ agrees with the direction, ok millert@ on an earlier diff
2021-01-26satisfy -fno-common by repairing one enum declTheo de Raadt
ok mortimer
2020-05-24Correct one statement about how the 'm' command works, talk lessIngo Schwarze
about ancient terminals, employ the more usual term "caret" rather than "up-arrow", and fix a few minor nits. Patch from Andras Farkas <deepbluemistake at gmail dot com>. Just committing right away because we don't currently install this file, but maybe we might in the future.
2020-04-30Add an expandtab option, similar to what vim supports.Todd C. Miller
If set, expands tabs to spaces in insert mode as well as when shifting and indenting/outdenting. If quoted with ^V, a literal tab is inserted. Adapted from NetBSD, but this implementation more closely matches vim's behavior. OK dlg@
2019-10-04better link "set" and "SET OPTIONS";Jason McIntyre
original diff from sven falempin, tweaked a bit by myself; ok sthen
2019-07-22In secure mode (-S), skip sending mail when executing the :pre[serve]Ingo Schwarze
command or when dying from SIGTERM. This way, creating the recovery file works again without re-adding "proc exec" to the pledge(2). As reported by Jesper Wallin <jesper at ifconfig dot se>, this got broken by common/main.c rev. 1.29 (Nov 19, 2015). The general direction of the fix was suggested by brynet@. OK brynet@ and no opposition when shown on tech@
2019-05-21Also apply stricter pledge when secure mode is set via rc file or command.Martijn van Duren
Pointed out by jesper <at> ifconfig <dot> se OK brynet@
2019-01-24Fix a crash on long lines when switching to another file byTodd C. Miller
setting SC_SCR_CENTER which will cause the offsets in HMAP to be reset when painting the screen. OK martijn@ otto@
2018-09-17Use the strict pragma for better warnings.Todd C. Miller
2018-07-13Remove cscope leftover and a stray comma.Anthony J. Bentley
From "kshe" on tech@.
2018-07-13Unused variable.Kenneth R Westerback
ok martijn@ henning@
2018-07-11Remove an old and false comment. REALLOC now free(3)s the code if reallocMartijn van Duren
fails. OK millert@
2018-02-12Simplify documentation of split-screen mode, avoiding abuse of []Ingo Schwarze
to sometimes mean "character set", which conflicts with the normal meaning of "optional element" in manual pages. While here, add a few related clarifications and tweak a few details. Triggered by a minor bug report from <trondd at kagu-tsuchi dot com>, and by bentley@ subsequently pointing out the abuse of []. Patch using input from jmc@, who also agreed with some previous versions.
2018-02-03The recover script should have the same sanity checks as recover.c.Todd C. Miller
Specifically, open files with O_NONBLOCK and enforce a mode of 0600.
2017-12-14Enable the awk scripts to generate ex_def.h and options_def.h.Martijn van Duren
These scripts generate the enums required for the ex commands and vi options. Before these lists had to be maintained either by hand or someone had to stumble upon these scripts and figure out how to use them. By enabling them these headers are now always in sync based on the comments in the corresponding source files, which are a lot harder to miss during an update than an extra file. Update the awk scripts to the new enum style introduced by bentley@ with his update on options_def.h r1.7 Feedback Makefile semantics by espie@ Original diff and OK tb@ OK millert@
2017-11-26Fix segfault which could be triggered by deleting a backwards sentence ifRicardo Mestre
cursor's current line was blank: echo "\nfoo" > a && vi a d( Same fix applied by rin@NetBSD, via nvi2 project. OK tom@ martijn@ tb@ millert@
2017-11-10When tracing is compiled in make sure it flushes its content to disk asMartijn van Duren
soon as the TRACE function is called. This helps while debugging crashes. Noticed and annoyed by while debugging the SIGTERM crash I just submitted. OK millert@ and tb@
2017-11-10Fix a use after free when sending SIGHUP or SIGTERM to vi when in editingMartijn van Duren
mode. Found while testing previous commit by millert@ OK millert@ and tb@
2017-11-10Add rcv_openat() function that does the open, makes sure it is aTodd C. Miller
regular file with the expected permissions and locks it. Inspired by changes in NetBSD by Christos. OK martijn@
2017-11-10Avoid using system(3) when running "sendmail -t". We already haveTodd C. Miller
the recover file fd open so just run sendmail with stdin set to the recover file. OK martijn@
2017-08-22Do not treat comma as part of the command modifier.anton
ok schwarze@
2017-07-31Silence some warnings generated by clang.Martijn van Duren
Original diff by espie@ with some minor tweaks by myself. OK espie@ and florian@
2017-07-20Replace usage of strtol() with strtonum().anton
ok bentley@ deraadt@ millert@ tb@
2017-07-05avoid double space caused by end-of-sentence detection; requested by jmc@Ingo Schwarze
2017-07-05nits about trailing punctuation found with mandoc -TlintIngo Schwarze
2017-07-03markup fixes;Jason McIntyre
2017-07-03Remove settings that were unimplemented for 20 years; update STANDARDS.Anthony J. Bentley
ok jmc@ natano@