summaryrefslogtreecommitdiff
path: root/usr.bin/vi/common
AgeCommit message (Collapse)Author
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-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-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-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-01-26satisfy -fno-common by repairing one enum declTheo de Raadt
ok mortimer
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-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@
2018-07-11Remove an old and false comment. REALLOC now free(3)s the code if reallocMartijn van Duren
fails. OK millert@
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-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-03Remove settings that were unimplemented for 20 years; update STANDARDS.Anthony J. Bentley
ok jmc@ natano@
2017-06-30Add mdoc(7) macros to vi's built-in lists of roff paragraph/section macros.Anthony J. Bentley
ok jmc@, no objection schwarze@
2017-06-24Fix a check in ADD_SPACE_{GOTO,RET} that potentially allowed for aMartijn van Duren
NULL-dereference. OK tom@
2017-06-12Use openat() and unlinkat() instead of chdir()ing to the recovery dir.Todd C. Miller
Since we use flock() and not fcntl() locking we can open the recovery file read-only. OK martijn@
2017-04-26Remove extraneous ", NULL" in the assignment of msgstr which wasTodd C. Miller
leftover from when msg_cat() was removed. From Anton Lindqvist
2017-04-18free(NULL) is ok so use it; from Michael W. BombardieriTheo de Raadt
2017-01-20Nuke some excess whitespace.Kenneth R Westerback
2016-12-18Use %zu/%d to print size_t/ssize_t. Cast recno_t (a.k.a. u_int32_t)Kenneth R Westerback
to (unsigned long) to match %lu formats. Makes gcc happier and quieter. ok deraadt@
2016-08-27Pull in <sys/time.h> for struct timespec and timevalPhilip Guenther
ok deraadt@
2016-08-14Kill '#if defined(DEBUG) && 0' blocks that used %qPhilip Guenther
ok bentley@ on principle
2016-08-01Remove vi's "directory" option and TMPDIR support.Anthony J. Bentley
ok jung@
2016-06-29If /tmp/vi.recover doesn't exist, don't create it. Warn onceTheo Buehler
that it doesn't exist, afterwards fail silently. ok millert
2016-05-27Revert CHAR_T removal. Some signedness flaws were introduced.Martijn van Duren
Found the hard way by jca@
2016-05-07Free memory if realloc fails. The application is most likely to terminate afterMartijn van Duren
a failure, but if it does not we better clean up after ourselfs. OK deraadt@ and stefan@
2016-05-02Remove CHAR_T in favor of native types.Martijn van Duren
schwarze@ agrees with the direction. Few tweaks and OK tb@
2016-02-03Remove needless alias macros for malloc and calloc. No binary change. Immcc
got this upstreamed a few weeks ago. ok tb (less a few style tweaks), martijn (who suggested style tweaks)
2016-01-30replace tail with basenamemartijn
OK tb@
2016-01-30replace progname variable in gs structure with getprognamemartijn
OK zhuk@ and tb@
2016-01-27remove v_estr in favor of warn and warnxmartijn
OK schwarze@, zhuk@ fine with me tb@
2016-01-20Remove ARG_CHAR_T, a relic from when the code was written K&R style.Anthony J. Bentley
ok millert@ schwarze@
2016-01-09decls before code; from Martijn van DurenTheo de Raadt
2016-01-06Remove the msg_cat() function and adjust its former callers.Todd C. Miller
From Martijn van Duren
2016-01-06Remove the numeric identifiers at the beginning of the messagesTodd C. Miller
which used to be used as the message number to lookup in the catalog. From Martijn van Duren
2016-01-06Remove the message catalog DB. This removes the msg_open() andTodd C. Miller
msg_close() functions along with the msgcat command. From Martijn van Duren
2015-12-07Remove needless type casts and corresponding type parameters frommmcc
allocation macros. No binary change. ok tb@
2015-11-24Turn on filename tab completion in vi by default.Anthony J. Bentley
From FreeBSD. ok claudio@ tb@
2015-11-20vi -S doesn't need proc or exec.Anthony J. Bentley
ok tb@
2015-11-19"tty proc exec", not "proc exec tty"Anthony J. Bentley
2015-11-19Remove cscope support in vi.Anthony J. Bentley
It makes no sense to keep support for a non-base tool in base, especially for a feature that few if any people use.
2015-11-15Vi needs flock, for those who haven't set nolock in .exrc for years...Anthony J. Bentley
Pointed out by Theo Buehler.
2015-11-15Basic pledge for vi.Anthony J. Bentley
ok deraadt@