Commit Graph

136 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 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
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
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 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
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
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 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
rin 3a5fc74837 Fix cursor movement for the case of USE_WIDECHAR != "yes", where the argument
of INTISWIDE() is not evaluated.
2017-11-14 12:20:55 +00:00
rin d3727deea0 Protect iconv stuffs by USE_WIDECHAR in addition to USE_ICONV. 2017-11-13 04:21:55 +00:00
rin 2b97f00020 Use mvwchgat(3), which is not a macro in general (and in our case). 2017-11-13 01:51:47 +00:00
rin aee2cbfef0 Make sure to cast arguments of ISFOO and TOFOO macros into UCHAR_T. 2017-11-13 01:40:37 +00:00
rin 94d00a62d3 Use ISBLANK macro instead of isblank(3). 2017-11-13 01:37:48 +00:00
rin 0446123c92 Remove duplicate definition for ISUPPER.
No binary changes.
2017-11-13 01:34:59 +00:00
christos ac02d96ecd PR/52671: Ralph Geier, return the wide character when changing case (because
it could be wide).
2017-11-12 16:33:31 +00:00
rin 2d83cf0dc9 _POSIX_VDISABLE exceeds CHAR_MAX. We thus need to cast it to CHAR_T for the
case where USE_WIDECHAR != "yes", i.e., CHAR_T is char.
2017-11-12 15:33:03 +00:00
rin b72c72dd34 db_recno_t aka recno_t is uint32_t 2017-11-12 15:27:53 +00:00
rin b6e834eb55 No need to cast endp in both cases of USE_WIDECHAR == "yes" nor "no".
Note that RCHAR_T is intended to use for bundled regex, not for nvi itself.
2017-11-12 15:26:33 +00:00
rin b2095b2c80 Fix argument type of put() in common_extern.h 2017-11-12 15:23:51 +00:00
rin 4cf2a28bf8 Add missing encoding conversion before printing it. 2017-11-12 15:22:09 +00:00
christos 874da4738d Instead of opening the file and using popen(3), pass the file descriptor
to sendmail directory. Idea and code from Todd Miller.
2017-11-10 20:01:11 +00:00
rin 59b9a29460 Restore the initial state at the end of line.
This matters for stateful encodings like iso-2022-jp.
Fix taken from yamt via nvi2.
2017-11-10 18:08:11 +00:00