Commit Graph

170 Commits

Author SHA1 Message Date
maya acbe8419a2 Remove documentation for long removed -F option
Suggested by Robert Whitlock in PR bin/58177

I've sent this patch to the nvi maintainers but the response suggested
patching this downstream, as there would be no further releases of nvi.
2024-04-29 00:50:42 +00:00
mrg f8570f8a97 fix simple mis-matched function prototype and definitions.
most of these are like, eg

   void foo(int[2]);

with either of these

   void foo(int*) { ... }
   void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
2023-08-01 07:04:14 +00:00
gutteridge a3205d7c90 search.c: correctly handle escaped backslashes
Addresses PR bin/57106 from Bosco G. G., who supplied the patch.
(This was also committed in the nvi2 sources:
e7054267a3)
2023-02-13 23:08:43 +00:00
rin 5b02012073 Fix search for collating symbols in form of [[.foo.]], as in a similar
manner as already done for POSIX character classes by upstream:

fd5795cc98 (diff-42d58222b328681b9923634991312932089876a0242f78cf488157aa24969c1a)

(We already have this change since initial import to external/bsd/nvi.)

Found by tnozaki. Thanks!
2021-05-17 04:01:57 +00:00
rin b55bfb6bcb Misc cleanups:
- built-in regex is required only when ${USE_WIDECHAR} == "yes"

- -DUSE_WIDECHAR cpp flag should be determined by ${USE_WIDECHAR},
  not ${USE_BUILTIN_REGEX}

- reduce .if -- .endif block for clarity
2021-02-26 02:54:21 +00:00
christos b1db991946 Put back local regex (thanks Rin) 2021-02-26 00:41:56 +00:00
christos fdd5a50616 we don't need the extra copy wide-regex anymore. 2021-02-25 21:56:35 +00:00
rin 926200353e PR bin/55468
Fix crash due to out-of-bounds access with Ctrl-W.

PR is only for nottywerase, but also fix ttywerase case, taken from
OpenBSD via nvi2:

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/vi/vi/v_txt.c#rev1.23
5d5365d358

Also, comment there is no worry for altwerase specific code, which
seems suspicious at a glance.

Reported by Azuma OKAMOTO.
Thanks for detailed explanation how to reproduce the problem!
2020-07-07 10:58:43 +00:00
joerg ca74eb1fe1 Don't let clang warn about comparing pointers with string literals. 2020-04-20 13:04:10 +00:00
martin 43c6dc4bfb Remove no longer needed workaround for PR/54656. 2020-04-12 17:28:57 +00:00
christos 85b0082cfe PR/54656: Martin Husemann: gcc-8 miscompiles ex_filter.c even with -O1, make
it -O0. The tm argument gets passed in as non-null and it is non-null after
the command execution, but then becomes null and causes a null dereference.
2019-10-29 21:14:37 +00:00
kamil 77a1ad5f00 Switch the iconv(3) prototype to the POSIX conformant variation
Remove const from the 2nd argument.

const char ** and char ** are incompatible types and it was a cost to keep
the technically incompatible form for a more purist variation. NetBSD was
almost the last alive OS to still keep the const argument (known leftovers:
Minix and Illumos).

Keep the const form for the internal purposes inside citrus and rump.

Address the build breakage fallout in the same change.

There are no ABI changes.

Change accepted by core@.
2019-10-24 18:17:14 +00:00
mrg a83f6c1317 msg:
avoid passing the same pointer in multiple arguments for restrict
marked arguments:
- sigaction() wants separate in/out
- use memmove() not memcpy() for overlapping regions (this may fix
  a real bug in nvi -- but it seems unlikely)
- select() wants separate read/write/except
- sigprocmask() wants separate set/oset
2019-10-04 09:01:59 +00:00
rin 1224954747 Add missing break. 2019-07-24 08:37:59 +00:00
uwe d4b53fab79 Fix unnamed/named edito.
From adr at sdf dot org.
2019-06-17 15:26:09 +00:00
mrg 1fcf7be45f - use -Wno-error=implicit-fallthrough with GCC7. 2019-02-04 04:05:15 +00:00
pgoyette d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
rin ed5ee5bf48 Fix description for -r option reflecting the actual behavior.
Suggested by christos on current-users.
2018-09-14 13:19:15 +00:00
rin a05b1d7076 Use wp and wlen instead of ip and ilen for consistency.
No binary changes intended.
2018-08-07 11:41:23 +00:00
rin 5006b3769f Remove unnecessary buffer allocation and memcpy.
Partially taken from nvi2.
2018-08-07 11:25:45 +00:00
rin f459985261 Add imctrl and imkey options, inspired by cannactrl and fepkey options in
nvi-m17n by itojun.

If imctrl option is set, input method is controlled by using escape
sequences compatible to Tera Term and RLogin. The state of input method in
commands specified by imkey option is saved and restored automatically.
Input method is then deactivated on returning to command mode.
2018-08-07 08:05:47 +00:00
rin ae6aff383c As described in comments, we treat non-spacing chars as single-width ones. 2018-08-01 02:48:47 +00:00
kamil 54b8bd3463 Include <stddef.h> for offsetof(3) 2018-06-25 18:36:36 +00:00
kamil 17b10cd3f4 Specify SANITIZER_RENAME_SYMBOL in nvi
Rename local versions of regcomp regerror regexec regfree in order to
remove symbol clash with libc.
2018-06-25 18:00:34 +00:00
kamil 626dd188a2 Avoid unportable offsetof(3) calculation in nvi in log1.c
Detected with MKSANITIZER/UBSan.
2018-06-25 17:42:34 +00:00
kamil b3019d4b3d Correct previous change to CHAR_T_OFFSET
The intended operation is offsetof(), not alignof().

Noted by <christos>
2018-06-16 21:00:12 +00:00
kamil 4e2759a682 Do not cause Undefined Behavior in vi(1)
Replace unportable manual calculation of alignof() that causes UB, with
a GCC extension __alignof__.

This fixes a problem reported by UBSan with the MKSANITIZER distribution.
2018-06-16 18:54:52 +00:00
christos 2357fc5dd5 use SUBDIR.roff suggested by uwe@ 2018-06-10 17:55:11 +00:00
rin 65b076fb4d Make sure that every wide char occupies at least one display width:
- Replace non-printable multibyte char with ?-symbol.
  - Put space before non-spacing char.

Fix problems reported in PR bin/53164 and
PR bin/53323, that are because we did not take into account non-printable
multibyte char of wctob(wc) == EOF && wcwidth(wc) == -1.
2018-06-03 08:08:36 +00:00
christos bf7113376a Create a new bsd.hostinit.mk file and put the build definitions for all host
programs there; make all Makefiles that use bsd.hostprog.mk include it.
Namely turn off MKREPRO and don't make lint, man pages, info files etc.
Remove the Makefile.inc files that contained these same settings, and
remove the settings from Makefile.host
2018-05-01 19:59:42 +00:00
rin 91b8b0444c PR bin/53164: Comment why we abort here. 2018-04-10 12:44:41 +00:00
mrg b9c2640a34 fix GCC 6.4 issues (finally a couple that aren't actual bugs,
but only weird code?):

amd's amfs_program_exec() has a missing {} issue.

flex's check_options() has odd inconsistent identation that
trips the new ident checker.

ntpd's oncore_check_leap_sec() and oncore_set_traim() have
missing {} issues.

sntp's optionLoadNested() an identation weirdness that
trips the new ident checker.

vi's cl_attr() has a wrong {} issue, and its vs_paint() has
an identation weirdness that trips the new ident checker.
2018-02-04 09:15:44 +00:00
jmcneill 76fae9132e When testing to see if a signal handler was previously installed in
h_winch, test sa_handler against all SIG_* actions defined in sys/signal.h
instead of just 0. Corrects an issue where vi crashes after a window is
resized.
2017-12-06 17:16:14 +00:00
rin 1597af3dd8 Compare ap->len wide chars, not ap->len bytes. 2017-12-01 20:01:31 +00:00
rin c14a835e62 Check format strings for ex_printf. 2017-12-01 18:39:49 +00:00
rin a90a8d8c63 Remove ex_printf duplicate with ex_extern.h. 2017-12-01 18:35:58 +00:00
rin 59cd10f512 Fix missing of "search wrapped" message when searching from the last char of
file, taken from nvi2:
a59e892d23
2017-11-22 16:17:30 +00:00
rin f8052d784e Fix backward memcpy in :e +cmd, taken from nvi2 (and OpenBSD):
7ab02500a2
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/vi/ex/ex.c#rev1.21
2017-11-22 13:13:18 +00:00
rin a07ca21052 Fix segmentation fault in corner case of backward sentence deletion,
taken from nvi2 (and Debian Bug report #193498):
e84d40ec20
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=193498
2017-11-22 12:47:30 +00:00
rin 7419ae3a04 Use ISMULTIWIDTH() macro. No binary changes. 2017-11-21 07:48:07 +00:00
rin a8ee716c25 A boundary between single- and multi-width chars is regarded as a word boundary.
Suggested on tech-userland@ without any objections.
2017-11-21 07:43:47 +00:00
rin f10703c63c Fix screen corruption by rewriting only a part of a multi-width character. 2017-11-21 06:35:22 +00:00
rin b6a6fbff71 Bump WARNS to 5. Add -Wno-old-style-definition to regex.c for gcc. 2017-11-21 02:47:14 +00:00
rin 63e761a651 Enable -Wuninitialized -Wformat-security for clang. 2017-11-21 02:45:03 +00:00
rin 0c92db7399 We always need -Wno-format-nonliteral for v_increment.c whether compiler is
gcc or clang.
2017-11-21 02:44:13 +00:00
rin a1deadaca4 Cosmetic changes. No functional changes. 2017-11-21 02:42:08 +00:00
rin 4fc00db461 Enable to compile & run without USE_ICONV. 2017-11-21 02:36:45 +00:00
rin d43bd23851 Fix resource leaks due to missing of iconv_close(3). 2017-11-21 02:11:44 +00:00
rin 03a096c4f1 Fix -Wsign-compare issue for BINC_GOTO in a similar manner to BINC_RET. 2017-11-21 02:04:39 +00:00
rin bd6bbecf8a Fix use of uninitialized variable, found by clang. 2017-11-21 02:00:29 +00:00