summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore14
-rw-r--r--CMakeLists.txt67
-rw-r--r--README2
-rw-r--r--cl/cl.h2
-rw-r--r--cl/extern.h31
-rw-r--r--common/common.h13
-rw-r--r--common/cut.c5
-rw-r--r--common/extern.h131
-rw-r--r--common/line.c4
-rw-r--r--common/options.c39
-rw-r--r--common/options_def.h86
-rw-r--r--common/put.c46
-rw-r--r--common/recover.c2
-rw-r--r--ex/ex.c2
-rw-r--r--ex/ex.h5
-rw-r--r--ex/ex_append.c21
-rw-r--r--ex/ex_bang.c4
-rw-r--r--ex/ex_def.h76
-rw-r--r--ex/ex_move.c2
-rw-r--r--ex/ex_put.c2
-rw-r--r--ex/ex_shift.c8
-rw-r--r--ex/extern.h131
-rw-r--r--ex/version.h1
-rw-r--r--vi/extern.h145
-rw-r--r--vi/v_put.c34
-rw-r--r--vi/vi.h2
26 files changed, 740 insertions, 135 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 2b79229e57e0..000000000000
--- a/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-*.swp
-*~
-*.orig
-*.core
-extern.h
-*_def.h
-version.h
-tags
-build/
-
-# Ignore files by the GNU Global source code tagging system.
-/GPATH
-/GRTAGS
-/GTAGS
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9451eaa89799..cdb5ed4eb32f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,10 +42,6 @@ add_compile_options(-Wstrict-aliasing -fstrict-aliasing)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-set(MAIN_PROTOS
- cl/extern.h common/extern.h ex/extern.h vi/extern.h
- common/options_def.h ex/ex_def.h ex/version.h)
-
set(CL_SRCS
cl/cl_funcs.c cl/cl_main.c cl/cl_read.c cl/cl_screen.c cl/cl_term.c)
@@ -81,44 +77,59 @@ set(VI_SRCS
set(REGEX_SRCS
regex/regcomp.c regex/regerror.c regex/regexec.c regex/regfree.c)
+set(GENERATED_HDRS
+ ${CMAKE_CURRENT_BINARY_DIR}/cl_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/common_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/vi_extern.h
+ ${CMAKE_CURRENT_BINARY_DIR}/options_def.h
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_def.h
+ ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+
# commands to generate the public headers
set(extract_protos sed -n 's/^ \\* PUBLIC: \\\(.*\\\)/\\1/p')
set(extract_version sed -n
's/^.*version \\\([^\)]*\)\\\).*/\#define VI_VERSION \\\"\\1\\\"/p')
-add_custom_command(OUTPUT cl/extern.h
- COMMAND ${extract_protos} ${CL_SRCS} > cl/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cl_extern.h
+ COMMAND ${extract_protos} ${CL_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/cl_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${CL_SRCS})
-add_custom_command(OUTPUT common/extern.h
- COMMAND ${extract_protos} ${COMMON_SRCS} > common/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_extern.h
+ COMMAND ${extract_protos} ${COMMON_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/common_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${COMMON_SRCS})
-add_custom_command(OUTPUT ex/extern.h
- COMMAND ${extract_protos} ${EX_SRCS} > ex/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ex_extern.h
+ COMMAND ${extract_protos} ${EX_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${EX_SRCS})
-add_custom_command(OUTPUT vi/extern.h
- COMMAND ${extract_protos} ${VI_SRCS} > vi/extern.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vi_extern.h
+ COMMAND ${extract_protos} ${VI_SRCS} >
+ ${CMAKE_CURRENT_BINARY_DIR}/vi_extern.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${VI_SRCS})
-add_custom_command(OUTPUT common/options_def.h
- COMMAND awk -f common/options.awk
- common/options.c > common/options_def.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/options_def.h
+ COMMAND awk -f common/options.awk common/options.c >
+ ${CMAKE_CURRENT_BINARY_DIR}/options_def.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS common/options.c)
-add_custom_command(OUTPUT ex/ex_def.h
- COMMAND awk -f ex/ex.awk ex/ex_cmd.c > ex/ex_def.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ex_def.h
+ COMMAND awk -f ex/ex.awk ex/ex_cmd.c >
+ ${CMAKE_CURRENT_BINARY_DIR}/ex_def.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ex/ex_cmd.c)
-add_custom_command(OUTPUT ex/version.h
- COMMAND ${extract_version} README > ex/version.h
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ COMMAND ${extract_version} README >
+ ${CMAKE_CURRENT_BINARY_DIR}/version.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS README)
add_executable(nvi)
-target_sources(nvi PRIVATE ${MAIN_PROTOS} ${CL_SRCS} ${COMMON_SRCS}
- ${EX_SRCS} ${VI_SRCS})
+target_sources(nvi PRIVATE ${CL_SRCS} ${COMMON_SRCS} ${EX_SRCS} ${VI_SRCS}
+ ${GENERATED_HDRS})
target_compile_definitions(nvi PRIVATE $<$<CONFIG:Debug>:DEBUG>
$<$<CONFIG:Debug>:COMLOG>)
@@ -208,18 +219,8 @@ check_function_exists(dbopen DBOPEN_IN_LIBC)
if(NOT DBOPEN_IN_LIBC)
target_link_libraries(nvi PRIVATE db1)
endif()
-if (APPLE)
- # Avoid using an incompatible db.h installed to /usr/local (since this is
- # part of the default search path on macOS)
- set(DB_H_GUESS "${CMAKE_OSX_SYSROOT}/usr/include/db.h")
- if (NOT EXISTS ${DB_H_GUESS})
- message(FATAL_ERROR "Could not find db.h at the expected path (${DB_H_GUESS}).")
- endif()
- add_definitions("-DDB_H_ABS_PATH=<${DB_H_GUESS}>")
-else()
- find_path(DB_INCLUDE_DIR db.h PATH_SUFFIXES db1)
- target_include_directories(nvi PRIVATE ${DB_INCLUDE_DIR})
-endif()
+find_path(DB_INCLUDE_DIR db.h PATH_SUFFIXES db1)
+target_include_directories(nvi PRIVATE ${DB_INCLUDE_DIR})
check_include_files(libutil.h HAVE_LIBUTIL_H)
check_include_files(ncurses.h HAVE_NCURSES_H)
diff --git a/README b/README
index 9e638d952444..d2c26a91bdf0 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This is version 2.2.1 (2023-09-25) of nex/nvi, a reimplementation of the ex/vi
+This is version 2.2.2 (2025-10-08) of nex/nvi, a reimplementation of the ex/vi
text editors originally distributed as part of the Fourth Berkeley
Software Distribution (4BSD), by the University of California, Berkeley.
diff --git a/cl/cl.h b/cl/cl.h
index a04c9e9f1b0d..18fa98b6881f 100644
--- a/cl/cl.h
+++ b/cl/cl.h
@@ -77,4 +77,4 @@ typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t;
#define RCNO(sp, cno) (cno)
#define RLNO(sp, lno) (lno)
-#include "extern.h"
+#include "cl_extern.h"
diff --git a/cl/extern.h b/cl/extern.h
new file mode 100644
index 000000000000..7b01ccd3f8cf
--- /dev/null
+++ b/cl/extern.h
@@ -0,0 +1,31 @@
+int cl_waddstr(SCR *, const CHAR_T *, size_t);
+int cl_addstr(SCR *, const char *, size_t);
+int cl_attr(SCR *, scr_attr_t, int);
+int cl_baud(SCR *, u_long *);
+int cl_bell(SCR *);
+int cl_clrtoeol(SCR *);
+int cl_cursor(SCR *, size_t *, size_t *);
+int cl_deleteln(SCR *);
+int cl_discard(SCR *, SCR **);
+int cl_ex_adjust(SCR *, exadj_t);
+int cl_insertln(SCR *);
+int cl_keyval(SCR *, scr_keyval_t, CHAR_T *, int *);
+int cl_move(SCR *, size_t, size_t);
+int cl_refresh(SCR *, int);
+int cl_rename(SCR *, char *, int);
+void cl_setname(GS *, char *);
+int cl_split(SCR *, SCR *);
+int cl_suspend(SCR *, int *);
+void cl_usage(void);
+int sig_init(GS *, SCR *);
+int cl_event(SCR *, EVENT *, u_int32_t, int);
+int cl_screen(SCR *, u_int32_t);
+int cl_quit(GS *);
+int cl_getcap(SCR *, char *, char **);
+int cl_term_init(SCR *);
+int cl_term_end(GS *);
+int cl_fmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
+int cl_optchange(SCR *, int, char *, u_long *);
+int cl_omesg(SCR *, CL_PRIVATE *, int);
+int cl_ssize(SCR *, int, size_t *, size_t *, int *);
+int cl_putchar(int);
diff --git a/common/common.h b/common/common.h
index fd97a4655cf5..a04b26ed8eb0 100644
--- a/common/common.h
+++ b/common/common.h
@@ -11,11 +11,7 @@
#define TCSASOFT 0
#endif
-#ifdef DB_H_ABS_PATH
-#include DB_H_ABS_PATH
-#else
#include <db.h>
-#endif
#include <regex.h> /* May refer to the bundled regex. */
#include <stdint.h>
@@ -92,4 +88,11 @@ typedef enum { SEQ_ABBREV, SEQ_COMMAND, SEQ_INPUT } seq_t;
#include "log.h"
#include "mem.h"
-#include "extern.h"
+#include "common_extern.h"
+
+#ifndef SLIST_REMOVE_AFTER
+#define SLIST_REMOVE_AFTER(elm, field) do { \
+ SLIST_NEXT(elm, field) = \
+ SLIST_NEXT(SLIST_NEXT(elm, field), field); \
+} while (0)
+#endif
diff --git a/common/cut.c b/common/cut.c
index 7d74f764a6d9..4b00d7c7b174 100644
--- a/common/cut.c
+++ b/common/cut.c
@@ -68,6 +68,10 @@ cut(SCR *sp, CHAR_T *namep, MARK *fm, MARK *tm, int flags)
recno_t lno;
int append, copy_one, copy_def;
+ /* Check if the line numbers are out-of-band */
+ if (fm->lno == OOBLNO || tm->lno == OOBLNO)
+ return (1);
+
/*
* If the user specified a buffer, put it there. (This may require
* a copy into the numeric buffers. We do the copy so that we don't
@@ -175,6 +179,7 @@ cut_line_err:
text_lfree(cbp->textq);
cbp->len = 0;
cbp->flags = 0;
+ sp->gp->dcbp = NULL;
return (1);
}
diff --git a/common/extern.h b/common/extern.h
new file mode 100644
index 000000000000..c887696080de
--- /dev/null
+++ b/common/extern.h
@@ -0,0 +1,131 @@
+char * codeset(void);
+void conv_init(SCR *, SCR *);
+int conv_enc(SCR *, int, char *);
+void conv_end(SCR *);
+int cut(SCR *, CHAR_T *, MARK *, MARK *, int);
+int cut_line(SCR *, recno_t, size_t, size_t, CB *);
+void cut_close(GS *);
+TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t);
+void text_lfree(TEXTH *);
+void text_free(TEXT *);
+int del(SCR *, MARK *, MARK *, int);
+int looks_utf8(const char *, size_t);
+int looks_utf16(const char *, size_t);
+int decode_utf8(const char *);
+int decode_utf16(const char *, int);
+FREF *file_add(SCR *, char *);
+int file_init(SCR *, FREF *, char *, int);
+int file_end(SCR *, EXF *, int);
+int file_write(SCR *, MARK *, MARK *, char *, int);
+int file_m1(SCR *, int, int);
+int file_m2(SCR *, int);
+int file_m3(SCR *, int);
+int file_aw(SCR *, int);
+void set_alt_name(SCR *, char *);
+lockr_t file_lock(SCR *, char *, int, int);
+int v_key_init(SCR *);
+void v_key_ilookup(SCR *);
+size_t v_key_len(SCR *, ARG_CHAR_T);
+char *v_key_name(SCR *, ARG_CHAR_T);
+e_key_t v_key_val(SCR *, ARG_CHAR_T);
+int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int);
+int v_event_get(SCR *, EVENT *, int, u_int32_t);
+void v_event_err(SCR *, EVENT *);
+int v_event_flush(SCR *, u_int);
+int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *);
+int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *);
+int db_delete(SCR *, recno_t);
+int db_append(SCR *, int, recno_t, CHAR_T *, size_t);
+int db_insert(SCR *, recno_t, CHAR_T *, size_t);
+int db_set(SCR *, recno_t, CHAR_T *, size_t);
+int db_exist(SCR *, recno_t);
+int db_last(SCR *, recno_t *);
+int db_rget(SCR *, recno_t, char **, size_t *);
+int db_rset(SCR *, recno_t, char *, size_t);
+void db_err(SCR *, recno_t);
+int log_init(SCR *, EXF *);
+int log_end(SCR *, EXF *);
+int log_cursor(SCR *);
+int log_line(SCR *, recno_t, u_int);
+int log_mark(SCR *, LMARK *);
+int log_backward(SCR *, MARK *);
+int log_setline(SCR *);
+int log_forward(SCR *, MARK *);
+int editor(GS *, int, char *[]);
+void v_end(GS *);
+int mark_init(SCR *, EXF *);
+int mark_end(SCR *, EXF *);
+int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t);
+int mark_set(SCR *, ARG_CHAR_T, MARK *, int);
+int mark_insdel(SCR *, lnop_t, recno_t);
+void msgq(SCR *, mtype_t, const char *, ...);
+void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *);
+void msgq_str(SCR *, mtype_t, const char *, const char *);
+void mod_rpt(SCR *);
+void msgq_status(SCR *, recno_t, u_int);
+int msg_open(SCR *, char *);
+void msg_close(GS *);
+const char *msg_cmsg(SCR *, cmsg_t, size_t *);
+const char *msg_cat(SCR *, const char *, size_t *);
+char *msg_print(SCR *, const char *, int *);
+int opts_init(SCR *, int *);
+int opts_set(SCR *, ARGS *[], char *);
+int o_set(SCR *, int, u_int, char *, u_long);
+int opts_empty(SCR *, int, int);
+void opts_dump(SCR *, enum optdisp);
+int opts_save(SCR *, FILE *);
+OPTLIST const *opts_search(CHAR_T *);
+void opts_nomatch(SCR *, CHAR_T *);
+int opts_copy(SCR *, SCR *);
+void opts_free(SCR *);
+int f_altwerase(SCR *, OPTION *, char *, u_long *);
+int f_columns(SCR *, OPTION *, char *, u_long *);
+int f_lines(SCR *, OPTION *, char *, u_long *);
+int f_lisp(SCR *, OPTION *, char *, u_long *);
+int f_msgcat(SCR *, OPTION *, char *, u_long *);
+int f_print(SCR *, OPTION *, char *, u_long *);
+int f_readonly(SCR *, OPTION *, char *, u_long *);
+int f_recompile(SCR *, OPTION *, char *, u_long *);
+int f_reformat(SCR *, OPTION *, char *, u_long *);
+int f_ttywerase(SCR *, OPTION *, char *, u_long *);
+int f_w300(SCR *, OPTION *, char *, u_long *);
+int f_w1200(SCR *, OPTION *, char *, u_long *);
+int f_w9600(SCR *, OPTION *, char *, u_long *);
+int f_window(SCR *, OPTION *, char *, u_long *);
+int f_encoding(SCR *, OPTION *, char *, u_long *);
+int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int);
+int rcv_tmp(SCR *, EXF *, char *);
+int rcv_init(SCR *);
+int rcv_sync(SCR *, u_int);
+int rcv_list(SCR *);
+int rcv_read(SCR *, FREF *);
+int screen_init(GS *, SCR *, SCR **);
+int screen_end(SCR *);
+SCR *screen_next(SCR *);
+int f_search(SCR *,
+ MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int);
+int b_search(SCR *,
+ MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int);
+void search_busy(SCR *, busy_t);
+int seq_set(SCR *, CHAR_T *,
+ size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int);
+int seq_delete(SCR *, CHAR_T *, size_t, seq_t);
+int seq_free(SEQ *);
+SEQ *seq_find
+ (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *);
+void seq_close(GS *);
+int seq_dump(SCR *, seq_t, int);
+int seq_save(SCR *, FILE *, char *, seq_t);
+int e_memcmp(CHAR_T *, EVENT *, size_t);
+void *binc(SCR *, void *, size_t *, size_t);
+int nonblank(SCR *, recno_t, size_t *);
+char *join(char *, char *);
+char *expanduser(char *);
+char *quote(char *);
+char *v_strdup(SCR *, const char *, size_t);
+CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t);
+enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int);
+enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int);
+void timepoint_steady(struct timespec *);
+void timepoint_system(struct timespec *);
+void TRACE(SCR *, const char *, ...);
diff --git a/common/line.c b/common/line.c
index 06d9a3e692d1..d1b7cb51e247 100644
--- a/common/line.c
+++ b/common/line.c
@@ -51,7 +51,7 @@ db_eget(SCR *sp,
* line in an empty file, find the last line of the file; db_last
* fails loudly.
*/
- if ((lno == 0 || lno == 1) && db_last(sp, &l1))
+ if ((lno == OOBLNO || lno == 1) && db_last(sp, &l1))
return (1);
/* If the file isn't empty, fail loudly. */
@@ -92,7 +92,7 @@ db_get(SCR *sp,
* have to have an OOB condition for the look-aside into the input
* buffer anyway.
*/
- if (lno == 0)
+ if (lno == OOBLNO)
goto err1;
/* Check for no underlying file. */
diff --git a/common/options.c b/common/options.c
index 87d5c5a88521..d54bf1d508d2 100644
--- a/common/options.c
+++ b/common/options.c
@@ -317,14 +317,13 @@ opts_init(SCR *sp, int *oargs)
argv[1] = &b;
/* Set numeric and string default values. */
-#define OI(indx, str) do { \
- a.len = STRLEN(str); \
- if (STRCMP((CHAR_T*)str, b2) != 0) \
- (void)MEMCPY(b2, str, a.len+1); \
- if (opts_set(sp, argv, NULL)) { \
- optindx = indx; \
+#define OI(indx, ...) do { \
+ size_t len = SPRINTF(b2, SIZE(b2), __VA_ARGS__); \
+ if (len < 0 || len >= SIZE(b2) || opts_set(sp, argv, NULL)) { \
+ optindx = indx; \
goto err; \
} \
+ a.len = len; \
} while (0)
/*
* Indirect global options to global space. Specifically, set up
@@ -345,9 +344,7 @@ opts_init(SCR *sp, int *oargs)
F_SET(&sp->opts[O_SECURE], OPT_GLOBAL);
/* Initialize string values. */
- (void)SPRINTF(b2, SIZE(b2),
- L("cdpath=%s"), (s = getenv("CDPATH")) == NULL ? ":" : s);
- OI(O_CDPATH, b2);
+ OI(O_CDPATH, L("cdpath=%s"), (s = getenv("CDPATH")) == NULL ? ":" : s);
OI(O_CEDIT, L("cedit=\033"));
/*
@@ -357,32 +354,26 @@ opts_init(SCR *sp, int *oargs)
* are two ways to change this -- the user can set either the directory
* option or the TMPDIR environmental variable.
*/
- (void)SPRINTF(b2, SIZE(b2),
+ OI(O_TMPDIR,
L("directory=%s"), (s = getenv("TMPDIR")) == NULL ? _PATH_TMP : s);
- OI(O_TMPDIR, b2);
OI(O_ESCAPETIME, L("escapetime=6"));
OI(O_FILEC, L("filec=\t"));
OI(O_KEYTIME, L("keytime=6"));
OI(O_MATCHCHARS, L("matchchars=()[]{}"));
OI(O_MATCHTIME, L("matchtime=7"));
- (void)SPRINTF(b2, SIZE(b2), L("msgcat=%s"), _PATH_MSGCAT);
- OI(O_MSGCAT, b2);
+ OI(O_MSGCAT, L("msgcat=%s"), _PATH_MSGCAT);
OI(O_REPORT, L("report=5"));
OI(O_PARAGRAPHS, L("paragraphs=IPLPPPQPP LIpplpipbp"));
- (void)SPRINTF(b2, SIZE(b2), L("path=%s"), "");
- OI(O_PATH, b2);
- (void)SPRINTF(b2, SIZE(b2), L("recdir=%s"), NVI_PATH_PRESERVE);
- OI(O_RECDIR, b2);
+ OI(O_PATH, L("path=%s"), "");
+ OI(O_RECDIR, L("recdir=%s"), NVI_PATH_PRESERVE);
OI(O_SECTIONS, L("sections=NHSHH HUnhsh"));
- (void)SPRINTF(b2, SIZE(b2),
+ OI(O_SHELL,
L("shell=%s"), (s = getenv("SHELL")) == NULL ? _PATH_BSHELL : s);
- OI(O_SHELL, b2);
OI(O_SHELLMETA, L("shellmeta=~{[*?$`'\"\\"));
OI(O_SHIFTWIDTH, L("shiftwidth=8"));
OI(O_SIDESCROLL, L("sidescroll=16"));
OI(O_TABSTOP, L("tabstop=8"));
- (void)SPRINTF(b2, SIZE(b2), L("tags=%s"), _PATH_TAGS);
- OI(O_TAGS, b2);
+ OI(O_TAGS, L("tags=%s"), _PATH_TAGS);
/*
* XXX
@@ -391,8 +382,7 @@ opts_init(SCR *sp, int *oargs)
*/
if ((v = (O_VAL(sp, O_LINES) - 1) / 2) == 0)
v = 1;
- (void)SPRINTF(b2, SIZE(b2), L("scroll=%ld"), v);
- OI(O_SCROLL, b2);
+ OI(O_SCROLL, L("scroll=%ld"), v);
/*
* The default window option values are:
@@ -412,8 +402,7 @@ opts_init(SCR *sp, int *oargs)
else if ((v = O_VAL(sp, O_LINES) - 1) == 0)
v = 1;
- (void)SPRINTF(b2, SIZE(b2), L("window=%lu"), v);
- OI(O_WINDOW, b2);
+ OI(O_WINDOW, L("window=%lu"), v);
/*
* Set boolean default values, and copy all settings into the default
diff --git a/common/options_def.h b/common/options_def.h
new file mode 100644
index 000000000000..15104845c380
--- /dev/null
+++ b/common/options_def.h
@@ -0,0 +1,86 @@
+#define O_ALTNOTATION 0
+#define O_ALTWERASE 1
+#define O_AUTOINDENT 2
+#define O_AUTOPRINT 3
+#define O_AUTOWRITE 4
+#define O_BACKUP 5
+#define O_BEAUTIFY 6
+#define O_CDPATH 7
+#define O_CEDIT 8
+#define O_COLUMNS 9
+#define O_COMBINED 10
+#define O_COMMENT 11
+#define O_TMPDIR 12
+#define O_EDCOMPATIBLE 13
+#define O_ERRORBELLS 14
+#define O_ESCAPETIME 15
+#define O_EXPANDTAB 16
+#define O_EXRC 17
+#define O_EXTENDED 18
+#define O_FILEC 19
+#define O_FILEENCODING 20
+#define O_FLASH 21
+#define O_HARDTABS 22
+#define O_ICLOWER 23
+#define O_IGNORECASE 24
+#define O_INPUTENCODING 25
+#define O_KEYTIME 26
+#define O_LEFTRIGHT 27
+#define O_LINES 28
+#define O_LISP 29
+#define O_LIST 30
+#define O_LOCKFILES 31
+#define O_MAGIC 32
+#define O_MATCHCHARS 33
+#define O_MATCHTIME 34
+#define O_MESG 35
+#define O_MODELINE 36
+#define O_MSGCAT 37
+#define O_NOPRINT 38
+#define O_NUMBER 39
+#define O_OCTAL 40
+#define O_OPEN 41
+#define O_OPTIMIZE 42
+#define O_PARAGRAPHS 43
+#define O_PATH 44
+#define O_PRINT 45
+#define O_PROMPT 46
+#define O_READONLY 47
+#define O_RECDIR 48
+#define O_REDRAW 49
+#define O_REMAP 50
+#define O_REPORT 51
+#define O_RULER 52
+#define O_SCROLL 53
+#define O_SEARCHINCR 54
+#define O_SECTIONS 55
+#define O_SECURE 56
+#define O_SHELL 57
+#define O_SHELLMETA 58
+#define O_SHIFTWIDTH 59
+#define O_SHOWFILENAME 60
+#define O_SHOWMATCH 61
+#define O_SHOWMODE 62
+#define O_SIDESCROLL 63
+#define O_SLOWOPEN 64
+#define O_SOURCEANY 65
+#define O_TABSTOP 66
+#define O_TAGLENGTH 67
+#define O_TAGS 68
+#define O_TERM 69
+#define O_TERSE 70
+#define O_TILDEOP 71
+#define O_TIMEOUT 72
+#define O_TTYWERASE 73
+#define O_VERBOSE 74
+#define O_W1200 75
+#define O_W300 76
+#define O_W9600 77
+#define O_WARN 78
+#define O_WINDOW 79
+#define O_WINDOWNAME 80
+#define O_WRAPLEN 81
+#define O_WRAPMARGIN 82
+#define O_WRAPSCAN 83
+#define O_WRITEANY 84
+#define O_OPTIONCOUNT 85
diff --git a/common/put.c b/common/put.c
index f39948808e7d..9862682c9bbb 100644
--- a/common/put.c
+++ b/common/put.c
@@ -26,16 +26,16 @@
* put --
* Put text buffer contents into the file.
*
- * PUBLIC: int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int);
+ * PUBLIC: int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int, int);
*/
int
-put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append)
+put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append, int cnt)
{
CHAR_T name;
TEXT *ltp, *tp;
recno_t lno;
size_t blen, clen, len;
- int rval;
+ int rval, i, isempty;
CHAR_T *bp, *t;
CHAR_T *p;
@@ -77,11 +77,16 @@ put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append)
if (cp->lno == 1) {
if (db_last(sp, &lno))
return (1);
- if (lno == 0) {
- for (; tp != NULL;
- ++lno, ++sp->rptlines[L_ADDED], tp = TAILQ_NEXT(tp, q))
- if (db_append(sp, 1, lno, tp->lb, tp->len))
- return (1);
+ if (lno == 0 && F_ISSET(cbp, CB_LMODE)) {
+ for (i = cnt; i > 0; i--) {
+ for (; tp != NULL;
+ ++lno, ++sp->rptlines[L_ADDED],
+ tp = TAILQ_NEXT(tp, q))
+ if (db_append(sp, 1, lno, tp->lb,
+ tp->len))
+ return (1);
+ tp = TAILQ_FIRST(cbp->textq);
+ }
rp->lno = 1;
rp->cno = 0;
return (0);
@@ -92,10 +97,14 @@ put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append)
if (F_ISSET(cbp, CB_LMODE)) {
lno = append ? cp->lno : cp->lno - 1;
rp->lno = lno + 1;
- for (; tp != NULL;
- ++lno, ++sp->rptlines[L_ADDED], tp = TAILQ_NEXT(tp, q))
- if (db_append(sp, 1, lno, tp->lb, tp->len))
- return (1);
+ for (i = cnt; i > 0; i--) {
+ for (; tp != NULL;
+ ++lno, ++sp->rptlines[L_ADDED],
+ tp = TAILQ_NEXT(tp, q))
+ if (db_append(sp, 1, lno, tp->lb, tp->len))
+ return (1);
+ tp = TAILQ_FIRST(cbp->textq);
+ }
rp->cno = 0;
(void)nonblank(sp, rp->lno, &rp->cno);
return (0);
@@ -111,8 +120,11 @@ put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append)
* Get the first line.
*/
lno = cp->lno;
- if (db_get(sp, lno, DBG_FATAL, &p, &len))
- return (1);
+ if (db_eget(sp, lno, &p, &len, &isempty)) {
+ if (!isempty)
+ return (1);
+ len = 0;
+ }
GET_SPACE_RETW(sp, bp, blen, tp->len + len + 1);
t = bp;
@@ -126,8 +138,10 @@ put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append)
/* First line from the CB. */
if (tp->len != 0) {
- MEMCPY(t, tp->lb, tp->len);
- t += tp->len;
+ for (i = cnt; i > 0; i--) {
+ MEMCPY(t, tp->lb, tp->len);
+ t += tp->len;
+ }
}
/* Calculate length left in the original line. */
diff --git a/common/recover.c b/common/recover.c
index cf222bfb5200..7b3a1791f74d 100644
--- a/common/recover.c
+++ b/common/recover.c
@@ -34,8 +34,8 @@
#include <time.h>
#include <unistd.h>
-#include "../ex/version.h"
#include "common.h"
+#include "version.h"
#include "pathnames.h"
/*
diff --git a/ex/ex.c b/ex/ex.c
index 900678e942eb..697fc3297525 100644
--- a/ex/ex.c
+++ b/ex/ex.c
@@ -773,6 +773,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
* no longer useful.
*/
vi_address = ecp->clen != 0 && ecp->cp[0] != '\n';
+ ecp->trailing = 0;
for (p = ecp->cp; ecp->clen > 0; --ecp->clen, ++ecp->cp) {
ch = ecp->cp[0];
if (IS_ESCAPE(sp, ecp, ch) && ecp->clen > 1) {
@@ -788,6 +789,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
ch = tmp;
}
} else if (ch == '\n' || ch == '|') {
+ ecp->trailing = 1;
if (ch == '\n')
F_SET(ecp, E_NEWLINE);
--ecp->clen;
diff --git a/ex/ex.h b/ex/ex.h
index b2d8ad0f4fef..c6de31e2477d 100644
--- a/ex/ex.h
+++ b/ex/ex.h
@@ -99,7 +99,8 @@ struct _excmd {
#define AGV_GLOBAL 0x04 /* global command. */
#define AGV_V 0x08 /* v command. */
#define AGV_ALL (AGV_AT | AGV_AT_NORANGE | AGV_GLOBAL | AGV_V)
- u_int8_t agv_flags;
+ u_int8_t agv_flags : 4;
+ u_int8_t trailing : 1; /* Command had trailing | or \n. */
/* Clear the structure before each ex command. */
#define CLEAR_EX_CMD(cmdp) do { \
@@ -228,4 +229,4 @@ typedef enum {
} tagmsg_t;
#include "ex_def.h"
-#include "extern.h"
+#include "ex_extern.h"
diff --git a/ex/ex_append.c b/ex/ex_append.c
index 5b9a1697e974..f7c8ac65183b 100644
--- a/ex/ex_append.c
+++ b/ex/ex_append.c
@@ -149,17 +149,15 @@ ex_aci(SCR *sp, EXCMD *cmdp, enum which cmd)
for (p = cmdp->save_cmd,
len = cmdp->save_cmdlen; len > 0; p = t) {
for (t = p; len > 0 && t[0] != '\n'; ++t, --len);
- if (t != p || len == 0) {
- if (F_ISSET(sp, SC_EX_GLOBAL) &&
- t - p == 1 && p[0] == '.') {
- ++t;
- if (len > 0)
- --len;
- break;
- }
- if (db_append(sp, 1, lno++, p, t - p))
- return (1);
+ if (F_ISSET(sp, SC_EX_GLOBAL) &&
+ t - p == 1 && p[0] == '.') {
+ ++t;
+ if (len > 0)
+ --len;
+ break;
}
+ if (db_append(sp, 1, lno++, p, t - p))
+ return (1);
if (len != 0) {
++t;
if (--len == 0 &&
@@ -181,6 +179,9 @@ ex_aci(SCR *sp, EXCMD *cmdp, enum which cmd)
if (len != 0)
cmdp->save_cmd = t;
cmdp->save_cmdlen = len;
+ } else if (cmdp->trailing) {
+ if (db_append(sp, 1, lno++, NULL, 0))
+ return 1;
}
if (F_ISSET(sp, SC_EX_GLOBAL)) {
diff --git a/ex/ex_bang.c b/ex/ex_bang.c
index c5744708664a..08122f4173d2 100644
--- a/ex/ex_bang.c
+++ b/ex/ex_bang.c
@@ -174,8 +174,8 @@ ex_bang(SCR *sp, EXCMD *cmdp)
if (!F_ISSET(sp, SC_VI) && !F_ISSET(sp, SC_EX_SILENT))
(void)ex_puts(sp, "!\n");
- /* Apply expandtab to the new text */
- if (O_ISSET(sp, O_EXPANDTAB))
+ /* If addresses were specified, apply expandtab to the new text */
+ if (cmdp->addrcnt != 0 && O_ISSET(sp, O_EXPANDTAB))
ex_retab(sp, cmdp);
/*
diff --git a/ex/ex_def.h b/ex/ex_def.h
new file mode 100644
index 000000000000..7afb7b19d677
--- /dev/null
+++ b/ex/ex_def.h
@@ -0,0 +1,76 @@
+#define C_SCROLL 0
+#define C_BANG 1
+#define C_HASH 2
+#define C_SUBAGAIN 3
+#define C_STAR 4
+#define C_SHIFTL 5
+#define C_EQUAL 6
+#define C_SHIFTR 7
+#define C_AT 8
+#define C_APPEND 9
+#define C_ABBR 10
+#define C_ARGS 11
+#define C_BG 12
+#define C_CHANGE 13
+#define C_CD 14
+#define C_CHDIR 15
+#define C_COPY 16
+#define C_CSCOPE 17
+#define C_DELETE 18
+#define C_DISPLAY 19
+#define C_EDIT 20
+#define C_EX 21
+#define C_EXUSAGE 22
+#define C_FILE 23
+#define C_FG 24
+#define C_GLOBAL 25
+#define C_HELP 26
+#define C_INSERT 27
+#define C_JOIN 28
+#define C_K 29
+#define C_LIST 30
+#define C_MOVE 31
+#define C_MARK 32
+#define C_MAP 33
+#define C_MKEXRC 34
+#define C_NEXT 35
+#define C_NUMBER 36
+#define C_OPEN 37
+#define C_PRINT 38
+#define C_PRESERVE 39
+#define C_PREVIOUS 40
+#define C_PUT 41
+#define C_QUIT 42
+#define C_READ 43
+#define C_RECOVER 44
+#define C_RESIZE 45
+#define C_REWIND 46
+#define C_SUBSTITUTE 47
+#define C_SCRIPT 48
+#define C_SET 49
+#define C_SHELL 50
+#define C_SOURCE 51
+#define C_STOP 52
+#define C_SUSPEND 53
+#define C_T 54
+#define C_TAG 55
+#define C_TAGNEXT 56
+#define C_TAGPOP 57
+#define C_TAGPREV 58
+#define C_TAGTOP 59
+#define C_UNDO 60
+#define C_UNABBREVIATE 61
+#define C_UNMAP 62
+#define C_V 63
+#define C_VERSION 64
+#define C_VISUAL_EX 65
+#define C_VISUAL_VI 66
+#define C_VIUSAGE 67
+#define C_VSPLIT 68
+#define C_WRITE 69
+#define C_WN 70
+#define C_WQ 71
+#define C_XIT 72
+#define C_YANK 73
+#define C_Z 74
+#define C_SUBTILDE 75
diff --git a/ex/ex_move.c b/ex/ex_move.c
index d910a7530f81..d4895b81c5cc 100644
--- a/ex/ex_move.c
+++ b/ex/ex_move.c
@@ -57,7 +57,7 @@ ex_copy(SCR *sp, EXCMD *cmdp)
/* Put the text into place. */
tm.lno = cmdp->lineno;
tm.cno = 0;
- if (put(sp, &cb, NULL, &tm, &m, 1))
+ if (put(sp, &cb, NULL, &tm, &m, 1, 1))
rval = 1;
else {
/*
diff --git a/ex/ex_put.c b/ex/ex_put.c
index c45fc551bfd1..ff8d05604565 100644
--- a/ex/ex_put.c
+++ b/ex/ex_put.c
@@ -38,7 +38,7 @@ ex_put(SCR *sp, EXCMD *cmdp)
m.cno = sp->cno;
if (put(sp, NULL,
FL_ISSET(cmdp->iflags, E_C_BUFFER) ? &cmdp->buffer : NULL,
- &cmdp->addr1, &m, 1))
+ &cmdp->addr1, &m, 1, 1))
return (1);
sp->lno = m.lno;
sp->cno = m.cno;
diff --git a/ex/ex_shift.c b/ex/ex_shift.c
index 97c7840a9a02..f7190b2e8688 100644
--- a/ex/ex_shift.c
+++ b/ex/ex_shift.c
@@ -79,8 +79,12 @@ shift(SCR *sp, EXCMD *cmdp, enum which rl)
return (0);
}
- /* Copy the lines being shifted into the unnamed buffer. */
- if (cut(sp, NULL, &cmdp->addr1, &cmdp->addr2, CUT_LINEMODE))
+ /*
+ * When not doing re-expand tabs, copy the lines being shifted into
+ * the unnamed buffer.
+ */
+ if (rl != RETAB &&
+ cut(sp, NULL, &cmdp->addr1, &cmdp->addr2, CUT_LINEMODE))
return (1);
/*
diff --git a/ex/extern.h b/ex/extern.h
new file mode 100644
index 000000000000..9d7b1d674c3c
--- /dev/null
+++ b/ex/extern.h
@@ -0,0 +1,131 @@
+int ex(SCR **);
+int ex_cmd(SCR *);
+int ex_range(SCR *, EXCMD *, int *);
+int ex_is_abbrev(CHAR_T *, size_t);
+int ex_is_unmap(CHAR_T *, size_t);
+void ex_badaddr
+ (SCR *, EXCMDLIST const *, enum badaddr, enum nresult);
+int ex_abbr(SCR *, EXCMD *);
+int ex_unabbr(SCR *, EXCMD *);
+int ex_append(SCR *, EXCMD *);
+int ex_change(SCR *, EXCMD *);
+int ex_insert(SCR *, EXCMD *);
+int ex_next(SCR *, EXCMD *);
+int ex_prev(SCR *, EXCMD *);
+int ex_rew(SCR *, EXCMD *);
+int ex_args(SCR *, EXCMD *);
+char **ex_buildargv(SCR *, EXCMD *, char *);
+int argv_init(SCR *, EXCMD *);
+int argv_exp0(SCR *, EXCMD *, CHAR_T *, size_t);
+int argv_exp1(SCR *, EXCMD *, CHAR_T *, size_t, int);
+int argv_exp2(SCR *, EXCMD *, CHAR_T *, size_t);
+int argv_exp3(SCR *, EXCMD *, CHAR_T *, size_t);
+int argv_flt_ex(SCR *, EXCMD *, CHAR_T *, size_t);
+int argv_free(SCR *);
+int argv_flt_path(SCR *, EXCMD *, CHAR_T *, size_t);
+CHAR_T *argv_esc(SCR *, EXCMD *, CHAR_T *, size_t);
+CHAR_T *argv_uesc(SCR *, EXCMD *, CHAR_T *, size_t);
+int ex_at(SCR *, EXCMD *);
+int ex_bang(SCR *, EXCMD *);
+int ex_cd(SCR *, EXCMD *);
+int ex_cscope(SCR *, EXCMD *);
+int cscope_end(SCR *);
+int cscope_display(SCR *);
+int cscope_search(SCR *, TAGQ *, TAG *);
+int ex_delete(SCR *, EXCMD *);
+int ex_display(SCR *, EXCMD *);
+int ex_edit(SCR *, EXCMD *);
+int ex_equal(SCR *, EXCMD *);
+int ex_file(SCR *, EXCMD *);
+int ex_filter(SCR *,
+ EXCMD *, MARK *, MARK *, MARK *, CHAR_T *, enum filtertype);
+int ex_global(SCR *, EXCMD *);
+int ex_v(SCR *, EXCMD *);
+int ex_g_insdel(SCR *, lnop_t, recno_t);
+int ex_screen_copy(SCR *, SCR *);
+int ex_screen_end(SCR *);
+int ex_optchange(SCR *, int, char *, u_long *);
+int ex_exrc(SCR *);
+int ex_run_str(SCR *, char *, CHAR_T *, size_t, int, int);
+int ex_join(SCR *, EXCMD *);
+int ex_map(SCR *, EXCMD *);
+int ex_unmap(SCR *, EXCMD *);
+int ex_mark(SCR *, EXCMD *);
+int ex_mkexrc(SCR *, EXCMD *);
+int ex_copy(SCR *, EXCMD *);
+int ex_move(SCR *, EXCMD *);
+int ex_open(SCR *, EXCMD *);
+int ex_preserve(SCR *, EXCMD *);
+int ex_recover(SCR *, EXCMD *);
+int ex_list(SCR *, EXCMD *);
+int ex_number(SCR *, EXCMD *);
+int ex_pr(SCR *, EXCMD *);
+int ex_print(SCR *, EXCMD *, MARK *, MARK *, u_int32_t);
+int ex_ldisplay(SCR *, const CHAR_T *, size_t, size_t, u_int);
+int ex_scprint(SCR *, MARK *, MARK *);
+int ex_printf(SCR *, const char *, ...);
+int ex_puts(SCR *, const char *);
+int ex_fflush(SCR *sp);
+int ex_put(SCR *, EXCMD *);
+int ex_quit(SCR *, EXCMD *);
+int ex_read(SCR *, EXCMD *);
+int ex_readfp(SCR *, char *, FILE *, MARK *, recno_t *, int);
+int ex_bg(SCR *, EXCMD *);
+int ex_fg(SCR *, EXCMD *);
+int ex_resize(SCR *, EXCMD *);
+int ex_sdisplay(SCR *);
+int ex_script(SCR *, EXCMD *);
+int sscr_exec(SCR *, recno_t);
+int sscr_input(SCR *);
+int sscr_end(SCR *);
+int ex_set(SCR *, EXCMD *);
+int ex_shell(SCR *, EXCMD *);
+int ex_exec_proc(SCR *, EXCMD *, char *, const char *, int);
+int proc_wait(SCR *, long, const char *, int, int);
+int ex_shiftl(SCR *, EXCMD *);
+int ex_shiftr(SCR *, EXCMD *);
+int ex_retab(SCR *, EXCMD *);
+int ex_source(SCR *, EXCMD *);
+int ex_stop(SCR *, EXCMD *);
+int ex_s(SCR *, EXCMD *);
+int ex_subagain(SCR *, EXCMD *);
+int ex_subtilde(SCR *, EXCMD *);
+int re_compile(SCR *,
+ CHAR_T *, size_t, CHAR_T **, size_t *, regex_t *, u_int);
+void re_error(SCR *, int, regex_t *);
+int ex_tag_first(SCR *, CHAR_T *);
+int ex_tag_push(SCR *, EXCMD *);
+int ex_tag_next(SCR *, EXCMD *);
+int ex_tag_prev(SCR *, EXCMD *);
+int ex_tag_nswitch(SCR *, TAG *, int);
+int ex_tag_Nswitch(SCR *, TAG *, int);
+int ex_tag_pop(SCR *, EXCMD *);
+int ex_tag_top(SCR *, EXCMD *);
+int ex_tag_display(SCR *);
+int ex_tag_copy(SCR *, SCR *);
+int tagq_free(SCR *, TAGQ *);
+int tagq_push(SCR*, TAGQ*, int, int );
+void tag_msg(SCR *, tagmsg_t, char *);
+int ex_tagf_alloc(SCR *, char *);
+int ex_tag_free(SCR *);
+int ex_txt(SCR *, TEXTH *, ARG_CHAR_T, u_int32_t);
+int ex_undo(SCR *, EXCMD *);
+int ex_help(SCR *, EXCMD *);
+int ex_usage(SCR *, EXCMD *);
+int ex_viusage(SCR *, EXCMD *);
+void ex_cinit(SCR *, EXCMD *, int, int, recno_t, recno_t, int);
+int ex_getline(SCR *, FILE *, size_t *);
+int ex_ncheck(SCR *, int);
+int ex_init(SCR *);
+void ex_wemsg(SCR *, CHAR_T *, exm_t);
+void ex_emsg(SCR *, char *, exm_t);
+int ex_version(SCR *, EXCMD *);
+int ex_visual(SCR *, EXCMD *);
+int ex_wn(SCR *, EXCMD *);
+int ex_wq(SCR *, EXCMD *);
+int ex_write(SCR *, EXCMD *);
+int ex_xit(SCR *, EXCMD *);
+int ex_writefp(SCR *,
+ char *, FILE *, MARK *, MARK *, u_long *, u_long *, int);
+int ex_yank(SCR *, EXCMD *);
+int ex_z(SCR *, EXCMD *);
diff --git a/ex/version.h b/ex/version.h
new file mode 100644
index 000000000000..1c18911cc593
--- /dev/null
+++ b/ex/version.h
@@ -0,0 +1 @@
+#define VI_VERSION "2.2.1 (2023-09-25)"
diff --git a/vi/extern.h b/vi/extern.h
new file mode 100644
index 000000000000..8e145c6318ef
--- /dev/null
+++ b/vi/extern.h
@@ -0,0 +1,145 @@
+int cs_init(SCR *, VCS *);
+int cs_next(SCR *, VCS *);
+int cs_fspace(SCR *, VCS *);
+int cs_fblank(SCR *, VCS *);
+int cs_prev(SCR *, VCS *);
+int cs_bblank(SCR *, VCS *);
+int v_at(SCR *, VICMD *);
+int v_chrepeat(SCR *, VICMD *);
+int v_chrrepeat(SCR *, VICMD *);
+int v_cht(SCR *, VICMD *);
+int v_chf(SCR *, VICMD *);
+int v_chT(SCR *, VICMD *);
+int v_chF(SCR *, VICMD *);
+int v_delete(SCR *, VICMD *);
+int v_again(SCR *, VICMD *);
+int v_exmode(SCR *, VICMD *);
+int v_join(SCR *, VICMD *);
+int v_shiftl(SCR *, VICMD *);
+int v_shiftr(SCR *, VICMD *);
+int v_suspend(SCR *, VICMD *);
+int v_switch(SCR *, VICMD *);
+int v_tagpush(SCR *, VICMD *);
+int v_tagpop(SCR *, VICMD *);
+int v_filter(SCR *, VICMD *);
+int v_ex(SCR *, VICMD *);
+int v_ecl_exec(SCR *);
+int v_increment(SCR *, VICMD *);
+int v_screen_copy(SCR *, SCR *);
+int v_screen_end(SCR *);
+int v_optchange(SCR *, int, char *, u_long *);
+int v_iA(SCR *, VICMD *);
+int v_ia(SCR *, VICMD *);
+int v_iI(SCR *, VICMD *);
+int v_ii(SCR *, VICMD *);
+int v_iO(SCR *, VICMD *);
+int v_io(SCR *, VICMD *);
+int v_change(SCR *, VICMD *);
+int v_Replace(SCR *, VICMD *);
+int v_subst(SCR *, VICMD *);
+int v_left(SCR *, VICMD *);
+int v_cfirst(SCR *, VICMD *);
+int v_first(SCR *, VICMD *);
+int v_ncol(SCR *, VICMD *);
+int v_zero(SCR *, VICMD *);
+int v_mark(SCR *, VICMD *);
+int v_bmark(SCR *, VICMD *);
+int v_fmark(SCR *, VICMD *);
+int v_emark(SCR *, VICMD *);
+int v_match(SCR *, VICMD *);
+int v_buildmcs(SCR *, char *);
+int v_paragraphf(SCR *, VICMD *);
+int v_paragraphb(SCR *, VICMD *);
+int v_buildps(SCR *, char *, char *);
+int v_Put(SCR *, VICMD *);
+int v_put(SCR *, VICMD *);
+int v_redraw(SCR *, VICMD *);
+int v_replace(SCR *, VICMD *);
+int v_right(SCR *, VICMD *);
+int v_dollar(SCR *, VICMD *);
+int v_screen(SCR *, VICMD *);
+int v_lgoto(SCR *, VICMD *);
+int v_home(SCR *, VICMD *);
+int v_middle(SCR *, VICMD *);
+int v_bottom(SCR *, VICMD *);
+int v_up(SCR *, VICMD *);
+int v_cr(SCR *, VICMD *);
+int v_down(SCR *, VICMD *);
+int v_hpageup(SCR *, VICMD *);
+int v_hpagedown(SCR *, VICMD *);
+int v_pagedown(SCR *, VICMD *);
+int v_pageup(SCR *, VICMD *);
+int v_lineup(SCR *, VICMD *);
+int v_linedown(SCR *, VICMD *);
+int v_searchb(SCR *, VICMD *);
+int v_searchf(SCR *, VICMD *);
+int v_searchN(SCR *, VICMD *);
+int v_searchn(SCR *, VICMD *);
+int v_searchw(SCR *, VICMD *);
+int v_correct(SCR *, VICMD *, int);
+int v_sectionf(SCR *, VICMD *);
+int v_sectionb(SCR *, VICMD *);
+int v_sentencef(SCR *, VICMD *);
+int v_sentenceb(SCR *, VICMD *);
+int v_status(SCR *, VICMD *);
+int v_tcmd(SCR *, VICMD *, ARG_CHAR_T, u_int);
+int v_txt(SCR *, VICMD *, MARK *,
+ const CHAR_T *, size_t, ARG_CHAR_T, recno_t, u_long, u_int32_t);
+int v_txt_auto(SCR *, recno_t, TEXT *, size_t, TEXT *);
+int v_ulcase(SCR *, VICMD *);
+int v_mulcase(SCR *, VICMD *);
+int v_Undo(SCR *, VICMD *);
+int v_undo(SCR *, VICMD *);
+void v_eof(SCR *, MARK *);
+void v_eol(SCR *, MARK *);
+void v_nomove(SCR *);
+void v_sof(SCR *, MARK *);
+void v_sol(SCR *);
+int v_isempty(CHAR_T *, size_t);
+void v_emsg(SCR *, char *, vim_t);
+int v_wordW(SCR *, VICMD *);
+int v_wordw(SCR *, VICMD *);
+int v_wordE(SCR *, VICMD *);
+int v_worde(SCR *, VICMD *);
+int v_wordB(SCR *, VICMD *);
+int v_wordb(SCR *, VICMD *);
+int v_xchar(SCR *, VICMD *);
+int v_Xchar(SCR *, VICMD *);
+int v_yank(SCR *, VICMD *);
+int v_z(SCR *, VICMD *);
+int vs_crel(SCR *, long);
+int v_zexit(SCR *, VICMD *);
+int vi(SCR **);
+int v_curword(SCR *);
+int vs_line(SCR *, SMAP *, size_t *, size_t *);
+int vs_number(SCR *);
+void vs_busy(SCR *, const char *, busy_t);
+void vs_home(SCR *);
+void vs_update(SCR *, const char *, const CHAR_T *);
+void vs_msg(SCR *, mtype_t, char *, size_t);
+int vs_ex_resolve(SCR *, int *);
+int vs_resolve(SCR *, SCR *, int);
+int vs_repaint(SCR *, EVENT *);
+int vs_refresh(SCR *, int);
+int vs_column(SCR *, size_t *);
+size_t vs_screens(SCR *, recno_t, size_t *);
+size_t vs_columns(SCR *, CHAR_T *, recno_t, size_t *, size_t *);
+size_t vs_rcm(SCR *, recno_t, int);
+size_t vs_colpos(SCR *, recno_t, size_t);
+int vs_change(SCR *, recno_t, lnop_t);
+int vs_sm_fill(SCR *, recno_t, pos_t);
+int vs_sm_scroll(SCR *, MARK *, recno_t, scroll_t);
+int vs_sm_1up(SCR *);
+int vs_sm_1down(SCR *);
+int vs_sm_next(SCR *, SMAP *, SMAP *);
+int vs_sm_prev(SCR *, SMAP *, SMAP *);
+int vs_sm_cursor(SCR *, SMAP **);
+int vs_sm_position(SCR *, MARK *, u_long, pos_t);
+recno_t vs_sm_nlines(SCR *, SMAP *, recno_t, size_t);
+int vs_split(SCR *, SCR *, int);
+int vs_vsplit(SCR *, SCR *);
+int vs_discard(SCR *, SCR **);
+int vs_fg(SCR *, SCR **, CHAR_T *, int);
+int vs_bg(SCR *);
+int vs_swap(SCR *, SCR **, char *);
+int vs_resize(SCR *, long, adj_t);
diff --git a/vi/v_put.c b/vi/v_put.c
index 16011167ce5d..f22537668550 100644
--- a/vi/v_put.c
+++ b/vi/v_put.c
@@ -41,15 +41,12 @@ v_Put(SCR *sp, VICMD *vp)
* Historic vi did not support a count with the 'p' and 'P'
* commands. It's useful, so we do.
*/
- for (cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1; cnt--;) {
- if (put(sp, NULL,
- F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
- &vp->m_start, &vp->m_final, 0))
- return (1);
- vp->m_start = vp->m_final;
- if (INTERRUPTED(sp))
- return (1);
- }
+ cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1;
+ if (put(sp, NULL,
+ F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
+ &vp->m_start, &vp->m_final, 0, cnt))
+ return (1);
+
return (0);
}
@@ -71,16 +68,17 @@ v_put(SCR *sp, VICMD *vp)
* !!!
* Historic vi did not support a count with the 'p' and 'P'
* commands. It's useful, so we do.
+ *
+ * The cursor placement of an individual 'p' and 'P' used to
+ * affect the content when a count is presented. Now we let
+ * the command implementation be count-aware instead.
*/
- for (cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1; cnt--;) {
- if (put(sp, NULL,
- F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
- &vp->m_start, &vp->m_final, 1))
- return (1);
- vp->m_start = vp->m_final;
- if (INTERRUPTED(sp))
- return (1);
- }
+ cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1;
+ if (put(sp, NULL,
+ F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
+ &vp->m_start, &vp->m_final, 1, cnt))
+ return (1);
+
return (0);
}
diff --git a/vi/vi.h b/vi/vi.h
index fbeceab23790..eff5a99807e7 100644
--- a/vi/vi.h
+++ b/vi/vi.h
@@ -381,4 +381,4 @@ typedef enum {
VIM_NOCOM, VIM_NOCOM_B, VIM_USAGE, VIM_WRESIZE
} vim_t;
-#include "extern.h"
+#include "vi_extern.h"