Commit Graph

86 Commits

Author SHA1 Message Date
christos
ab35868474 It is ridiculous to truncate files on character conversions without
warning and a chance for recovery. This patch sets the handler to
copy the character, clear the error and proceed instead of bailing
out.

To replicate:
	- unset LANG
	- Create a file that has ~1000 lines. Put a single bad character
	- '\344' in it, around 2/3rds of the file down. Save it.
	- export LANG=en_US.UTF-8
	- edit the file. Notice there is no error for input conversion,
	  since nvi reads the file opportunistically.
	- :w Boom, the file is truncated.

Alternatively, you can put that character in the first line of the file,
and watch the fireworks. If you like to restore the previous behavior
compile with -DERROR_ON_CONVERT

XXX: Pullup to 6, 5 etc.
2013-01-23 18:51:51 +00:00
spz
c168ad8961 Use after free (Coverity 273146) 2012-07-15 09:13:59 +00:00
joerg
8c3e60d97f Don't use loops with empty body. 2012-02-25 00:13:00 +00:00
christos
1ed18fbd3b PR/45881: Chavdar Ivanov: nvi copy command copies empty lines.
Move ENTIRE_LINE definition to common.h and have interested parties use it.
2012-01-27 16:41:22 +00:00
christos
236ed3e463 remove error(1) line. 2012-01-21 19:56:46 +00:00
christos
ab450fcb83 make the previous patch compile. 2012-01-21 19:49:56 +00:00
christos
e36a3ef194 PR/10367: Second part.
Restore lost fix:
http://mail-index.netbsd.org/source-changes/2001/09/09/0043.html

Fix a test condition for EOF.
2012-01-21 19:35:02 +00:00
christos
2a21cd4999 PR/10367:
Restore lost fix:
    http://mail-index.netbsd.org/source-changes/2001/09/09/0042.html

Define ENTIRE_LINE to be -1 instead of 0 since we may want to copy 0 characters.
(and use ENTIRE_LINE instead of 0 where appropriate)

This fixes a bug in the dw command with for example:

<cursor>
a b c

~
~
if you hit dw there, only the empty line would be killed but both the empty
line and the subsequent one would be pasted when asked for with P for example.
2012-01-21 19:32:37 +00:00
christos
f5b6285b2a undo previous, it is wrong. 2012-01-21 19:29:41 +00:00
christos
9e2c491108 PR/10367: Mason Loring Bliss: fix delete word near end of file. Patch
from tnozaki.
2012-01-21 17:12:56 +00:00
tnozaki
10248e78d8 use ARG_CHAR_T instead of CHAR_T for integer promotion. 2011-11-23 19:25:27 +00:00
tnozaki
87c8bc2121 use e_key_t instead of u_int. 2011-11-23 19:18:53 +00:00
tnozaki
5a00661245 don't use WEOF directly, for --disable-widechar. 2011-11-23 15:43:39 +00:00
tnozaki
3392bf8c1a don't use L prefix directly, for --disable-widechar. 2011-11-23 14:14:43 +00:00
tnozaki
b70d1274ae reliability fix, merge libc/regex fix to avoid memory exhaust problem. 2011-11-19 17:45:11 +00:00
tnozaki
0556aba958 use ARG_CHAR_T instead of CHAR_T for integer promotion. 2011-11-16 14:24:43 +00:00
tnozaki
dcbcd554a0 nvi cannot display international character(west european accented chars).
reported by Ian D. Leroux at current-users, thanks a lot!
2011-11-14 13:29:07 +00:00
wiz
f4eb12076c add dircategory/direntry for vi, so texinfo stops complaining 2011-11-13 19:53:53 +00:00
jdc
72b200e799 Work around PR#43839, by calling resizeterm() on SIGWINCH. 2011-09-24 18:57:46 +00:00
joerg
3c101252bb Use __dead 2011-09-16 16:13:41 +00:00
christos
112264be37 fix raw string formats 2011-08-17 12:56:55 +00:00
mrg
3cdf6fedc7 initialise from_cs[1] instead of from_cs[0] twice. from GCC 4.5.3. 2011-06-22 03:57:46 +00:00
tnozaki
80356df9b8 1. fix PR/44455, nonprintable character doesn't show hex-visual
under big endian.
2. ":set octal" with nonprintable character causes nbwcurses move error.
3. moving (big)words by wW/eE/bB can't handle non-ascii characters.
4. toggle uppercase/lowercase by ~ can't handle non-ascii characters.
5. don't feed CHAR_T(=wchar_t) to is* function directly.
   is* funcs with over UCHAR_MAX value may cause undefined behavior.
   some ctype implementation(such as FreeBSD) return unexpected
   result(same result as isw* func).
6. using non-ascii digit character with count/line number of ex/vi
   command may causes unexpeced result.
2011-03-21 14:53:02 +00:00
schnoebe
041d7f637f bin/44088
Change the initialization state of gtagsmode to 0, (unset).

This brings about least astonishment for users, permittings tags
functionality to work as expected.
2010-11-14 20:53:54 +00:00
christos
cefc0995de PR/44006: Ralph G: vi: CTRL-A does not handle end-of-word correctly
End-of-word was not included in search regexp leading to false positives.
http://patches.ubuntu.com/by-release/extracted/debian/n/nvi/1.81.6-7/15search_word.dpatch
2010-10-28 18:12:47 +00:00
wiz
eb06495b27 refering -> referring, per PR 43814. 2010-08-30 10:41:54 +00:00
tnozaki
50eb6aadde cast isblank(3)'s argument to unsigned char. 2010-05-13 17:52:11 +00:00
roy
98eb889579 Userland now builds and uses terminfo instead of termcap.
OK: core@, jdc@
2010-02-03 15:34:37 +00:00
mlelstv
c96a848326 Use wide char versions of tolower/toupper/islower/isupper where
appropriate. Fixes ~ command on big-endian architectures.
2009-12-23 12:44:21 +00:00
tnozaki
b95326704e don't use pathname directly as msgq()'s first argument of format string. 2009-11-24 13:12:01 +00:00
dsl
b87a655a0d Fix all formats for 64bit builds 2009-11-15 18:43:28 +00:00
dsl
08ad4f398f Need %zu for size_t 2009-11-15 18:23:08 +00:00
christos
55e651517c one more printf like function, and fix the lossage. 2009-11-14 23:40:11 +00:00
christos
1070653ee5 Add a gcc printf attribute to the printf functions and fix the lossage caught. 2009-11-14 23:31:37 +00:00
tnozaki
6114d6b7fd fix format string bug, filename may contain % character, don't use it as format string. 2009-11-14 20:01:20 +00:00
dsl
ba3675f1ae Fix regexp on LP64 systems.
By the time 'states1' was expanded, it became 'char *' so the code tried
to put 64 bits into an int!
Fixed PR/41924
2009-10-31 20:11:53 +00:00
dsl
f4f40b1fe1 Save command in :w !<command> for later :w !!
Fixes PR/8169
2009-10-31 14:30:55 +00:00
tnn
e0331d273d Print a warning if TERM is not set and stdin is a tty. PR bin/42144. 2009-10-20 16:17:07 +00:00
tnozaki
3b1fe73ae9 fix bin/41781, the pattern /\$/ doesn't match a dollar sign anymore by default. 2009-08-30 14:57:51 +00:00
aymeric
46545ebf5c bump to nb5:
. :ESC works again
. #+ and #- work again
2009-08-11 21:42:03 +00:00
aymeric
7963ec5bf2 . adding STRCHR variants to common/multibyte.h for the benefit of
. making #+ and #- work again in vi/v_increment.c
2009-08-11 21:28:02 +00:00
aymeric
b8018f6743 in v_ecl(), copy the converter from the shadow screen initialized in
v_ecl_init(), so that history can be displayed and edited.

Which means, :ESC works again.
2009-08-11 21:24:49 +00:00
lukem
86814cdb3c Crank version to nb4 2009-08-07 16:32:43 +00:00
lukem
ddff3f7108 Rename "expandtabs" to "expandtab" to match documentation (and vim,
where I got the idea from).
Actually implement the "et" abbreviation for expandtab.
2009-08-07 16:19:53 +00:00
tnozaki
41a9bd5969 fix reliability issue.
if wcwidth(3) return -1, nvi may crash by memory fault.
2009-04-19 02:28:19 +00:00
tnozaki
4bdba43474 fix PR/41136: \<word search doesn't work in vi
don't reuse RCHAR_T(=wchar_t)'s bits, CSI wchar_t is opaque object.
2009-04-12 14:47:51 +00:00
jld
09d4e48298 Make vi's '@' command work again; a precedence warning fix in r1.2 added
parens in the wrong place such that '@' did nothing.  Needs pullup to -5.

Reported by Ed Ravin; fixes PR 41134.
2009-04-04 01:13:42 +00:00
tnozaki
63b0517c27 fix following wregexp bug reported in current-user:
- . doesn't match anything
  - [] groups containing more than one character don't match anything
introduced by -Wsign-compare fix.
2009-02-22 11:34:53 +00:00
christos
7842bfc111 check for memcpy too 2009-01-27 16:50:08 +00:00
lukem
53fcdb3604 sign-compare fixes for amd64 2009-01-22 10:33:58 +00:00