import nvi 2.2.0-3bbdfe4

This commit is contained in:
Baptiste Daroussin 2021-05-21 22:50:50 +02:00
commit 6680e5a52f
25 changed files with 607 additions and 471 deletions

View File

@ -7,3 +7,8 @@ extern.h
version.h version.h
tags tags
build/ build/
# Ignore files by the GNU Global source code tagging system.
/GPATH
/GRTAGS
/GTAGS

View File

@ -13,20 +13,28 @@ project(nvi2 C)
include(CheckIncludeFiles) include(CheckIncludeFiles)
include(CheckFunctionExists) include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckStructHasMember) include(CheckStructHasMember)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
include(CheckCCompilerFlag)
mark_as_advanced(CMAKE_INSTALL_PREFIX) mark_as_advanced(CMAKE_INSTALL_PREFIX)
option(USE_WIDECHAR "Enable wide character support" ON) option(USE_WIDECHAR "Enable wide character support" ON)
option(USE_ICONV "Enable iconv support" ON) option(USE_ICONV "Enable iconv support" ON)
add_compile_options(-fcolor-diagnostics) check_c_compiler_flag(-fcolor-diagnostics USE_FCOLOR_DIAGNOSTICS)
if(USE_FCOLOR_DIAGNOSTICS)
add_compile_options(-fcolor-diagnostics)
endif()
add_compile_options($<$<CONFIG:Debug>:-Wall>) add_compile_options($<$<CONFIG:Debug>:-Wall>)
add_compile_options($<$<CONFIG:Debug>:-Wno-parentheses>) add_compile_options($<$<CONFIG:Debug>:-Wno-parentheses>)
add_compile_options($<$<CONFIG:Debug>:-Wno-uninitialized>) add_compile_options($<$<CONFIG:Debug>:-Wno-uninitialized>)
add_compile_options($<$<CONFIG:Debug>:-Wmissing-prototypes>) add_compile_options($<$<CONFIG:Debug>:-Wmissing-prototypes>)
add_compile_options($<$<CONFIG:Debug>:-Wsystem-headers>) if (NOT APPLE)
add_compile_options($<$<CONFIG:Debug>:-Wsystem-headers>)
endif()
add_compile_options($<$<CONFIG:Release>:-Wuninitialized>) add_compile_options($<$<CONFIG:Release>:-Wuninitialized>)
add_compile_options($<$<CONFIG:Release>:-Wno-dangling-else>) add_compile_options($<$<CONFIG:Release>:-Wno-dangling-else>)
add_compile_options(-Wstack-protector -fstack-protector) add_compile_options(-Wstack-protector -fstack-protector)
@ -126,6 +134,11 @@ if(NOT RESOLV_IN_LIBC)
target_link_libraries(nvi PRIVATE ${RESOLV_LIBRARY}) target_link_libraries(nvi PRIVATE ${RESOLV_LIBRARY})
endif() endif()
check_symbol_exists(asprintf "stdio.h" ASPRINTF_IN_STDIO_H)
if(NOT ASPRINTF_IN_STDIO_H)
target_compile_definitions(nvi PRIVATE _GNU_SOURCE)
endif()
if(USE_WIDECHAR) if(USE_WIDECHAR)
find_library(CURSES_LIBRARY NAMES ncursesw cursesw curses HINTS /usr/lib) find_library(CURSES_LIBRARY NAMES ncursesw cursesw curses HINTS /usr/lib)
find_library(TERMINFO_LIBRARY NAMES tinfow terminfo HINTS /usr/lib) find_library(TERMINFO_LIBRARY NAMES tinfow terminfo HINTS /usr/lib)
@ -142,7 +155,10 @@ else()
target_compile_options(nvi PRIVATE -Wno-pointer-sign) target_compile_options(nvi PRIVATE -Wno-pointer-sign)
endif() endif()
target_link_libraries(nvi PRIVATE ${CURSES_LIBRARY} ${TERMINFO_LIBRARY}) target_link_libraries(nvi PRIVATE ${CURSES_LIBRARY})
if(TERMINFO_LIBRARY)
target_link_libraries(nvi PRIVATE ${TERMINFO_LIBRARY})
endif()
if(USE_ICONV) if(USE_ICONV)
check_function_exists(iconv ICONV_IN_LIBC) check_function_exists(iconv ICONV_IN_LIBC)
@ -189,6 +205,18 @@ check_function_exists(dbopen DBOPEN_IN_LIBC)
if(NOT DBOPEN_IN_LIBC) if(NOT DBOPEN_IN_LIBC)
target_link_libraries(nvi PRIVATE db1) target_link_libraries(nvi PRIVATE db1)
endif() 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()
check_include_files(libutil.h HAVE_LIBUTIL_H) check_include_files(libutil.h HAVE_LIBUTIL_H)
check_include_files(ncurses.h HAVE_NCURSES_H) check_include_files(ncurses.h HAVE_NCURSES_H)
@ -196,6 +224,10 @@ check_include_files(ncursesw/ncurses.h HAVE_NCURSESW_NCURSES_H)
check_include_files(pty.h HAVE_PTY_H) check_include_files(pty.h HAVE_PTY_H)
check_include_files(term.h HAVE_TERM_H) check_include_files(term.h HAVE_TERM_H)
check_struct_has_member("struct dirent" d_namlen dirent.h HAVE_DIRENT_D_NAMLEN LANGUAGE C) check_struct_has_member("struct dirent" d_namlen dirent.h HAVE_DIRENT_D_NAMLEN LANGUAGE C)
check_struct_has_member("struct stat" st_mtimespec
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
check_struct_has_member("struct stat" st_mtim
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
configure_file(files/config.h.in config.h) configure_file(files/config.h.in config.h)

View File

@ -7,9 +7,6 @@
* See the LICENSE file for redistribution information. * See the LICENSE file for redistribution information.
*/ */
#ifdef USE_WIDECHAR
#define _XOPEN_SOURCE_EXTENDED
#endif
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif defined HAVE_NCURSES_H #elif defined HAVE_NCURSES_H

View File

@ -317,10 +317,10 @@ cl_resize(SCR *sp, size_t lines, size_t columns)
argv[0] = &a; argv[0] = &a;
argv[1] = &b; argv[1] = &b;
a.len = SPRINTF(b1, sizeof(b1), L("lines=%lu"), (u_long)lines); a.len = SPRINTF(b1, SIZE(b1), L("lines=%lu"), (u_long)lines);
if (opts_set(sp, argv, NULL)) if (opts_set(sp, argv, NULL))
return (1); return (1);
a.len = SPRINTF(b1, sizeof(b1), L("columns=%lu"), (u_long)columns); a.len = SPRINTF(b1, SIZE(b1), L("columns=%lu"), (u_long)columns);
if (opts_set(sp, argv, NULL)) if (opts_set(sp, argv, NULL))
return (1); return (1);
return (0); return (0);

View File

@ -1,31 +0,0 @@
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);

View File

@ -11,10 +11,10 @@
#define TCSASOFT 0 #define TCSASOFT 0
#endif #endif
#ifdef __linux__ #ifdef DB_H_ABS_PATH
#include "/usr/include/db1/db.h" /* Only include db1. */ #include DB_H_ABS_PATH
#else #else
#include <db.h> /* Only include db1. */ #include <db.h>
#endif #endif
#include <regex.h> /* May refer to the bundled regex. */ #include <regex.h> /* May refer to the bundled regex. */

View File

@ -28,7 +28,7 @@ typedef int iconv_t;
#define KEY_NEEDSWIDE(sp, ch) \ #define KEY_NEEDSWIDE(sp, ch) \
(INTISWIDE(ch) && KEY_LEN(sp, ch) <= 4) (INTISWIDE(ch) && KEY_LEN(sp, ch) <= 4)
#define KEY_COL(sp, ch) \ #define KEY_COL(sp, ch) \
(KEY_NEEDSWIDE(sp, ch) ? CHAR_WIDTH(sp, ch) : KEY_LEN(sp, ch)) (KEY_NEEDSWIDE(sp, ch) ? XCHAR_WIDTH(sp, ch) : KEY_LEN(sp, ch))
enum { IC_FE_CHAR2INT, IC_FE_INT2CHAR, IC_IE_CHAR2INT, IC_IE_TO_UTF16 }; enum { IC_FE_CHAR2INT, IC_FE_INT2CHAR, IC_IE_CHAR2INT, IC_IE_TO_UTF16 };

View File

@ -199,7 +199,14 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
if (!LF_ISSET(FS_OPENERR)) if (!LF_ISSET(FS_OPENERR))
F_SET(frp, FR_NEWFILE); F_SET(frp, FR_NEWFILE);
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
ep->mtim = sb.st_mtimespec;
#elif defined HAVE_STRUCT_STAT_ST_MTIM
ep->mtim = sb.st_mtim; ep->mtim = sb.st_mtim;
#else
ep->mtim.tv_sec = sb.st_mtime;
ep->mtim.tv_nsec = 0;
#endif
} else { } else {
/* /*
* XXX * XXX
@ -218,7 +225,14 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
ep->mdev = sb.st_dev; ep->mdev = sb.st_dev;
ep->minode = sb.st_ino; ep->minode = sb.st_ino;
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
ep->mtim = sb.st_mtimespec;
#elif defined HAVE_STRUCT_STAT_ST_MTIM
ep->mtim = sb.st_mtim; ep->mtim = sb.st_mtim;
#else
ep->mtim.tv_sec = sb.st_mtime;
ep->mtim.tv_nsec = 0;
#endif
if (!S_ISREG(sb.st_mode)) if (!S_ISREG(sb.st_mode))
msgq_str(sp, M_ERR, oname, msgq_str(sp, M_ERR, oname,
@ -796,7 +810,13 @@ file_write(SCR *sp, MARK *fm, MARK *tm, char *name, int flags)
if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) && if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) &&
((F_ISSET(ep, F_DEVSET) && ((F_ISSET(ep, F_DEVSET) &&
(sb.st_dev != ep->mdev || sb.st_ino != ep->minode)) || (sb.st_dev != ep->mdev || sb.st_ino != ep->minode)) ||
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
timespeccmp(&sb.st_mtimespec, &ep->mtim, !=))) {
#elif defined HAVE_STRUCT_STAT_ST_MTIM
timespeccmp(&sb.st_mtim, &ep->mtim, !=))) { timespeccmp(&sb.st_mtim, &ep->mtim, !=))) {
#else
sb.st_mtime != ep->mtim.tv_sec)) {
#endif
msgq_str(sp, M_ERR, name, LF_ISSET(FS_POSSIBLE) ? msgq_str(sp, M_ERR, name, LF_ISSET(FS_POSSIBLE) ?
"250|%s: file modified more recently than this copy; use ! to override" : "250|%s: file modified more recently than this copy; use ! to override" :
"251|%s: file modified more recently than this copy"); "251|%s: file modified more recently than this copy");
@ -895,7 +915,14 @@ file_write(SCR *sp, MARK *fm, MARK *tm, char *name, int flags)
ep->mdev = sb.st_dev; ep->mdev = sb.st_dev;
ep->minode = sb.st_ino; ep->minode = sb.st_ino;
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
ep->mtim = sb.st_mtimespec;
#elif defined HAVE_STRUCT_STAT_ST_MTIM
ep->mtim = sb.st_mtim; ep->mtim = sb.st_mtim;
#else
ep->mtim.tv_sec = sb.st_mtime;
ep->mtim.tv_nsec = 0;
#endif
} }
} }

View File

@ -1,131 +0,0 @@
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 *, ...);

View File

@ -22,8 +22,8 @@
sp->conv.input2int(sp, n, nlen, &(cw), &wlen, &w) sp->conv.input2int(sp, n, nlen, &(cw), &wlen, &w)
#define CONST #define CONST
#define INTISWIDE(c) (wctob(c) == EOF) #define INTISWIDE(c) (wctob(c) == EOF)
#define CHAR_WIDTH(sp, ch) wcwidth(ch) #define XCHAR_WIDTH(sp, ch) wcwidth(ch)
#define CAN_PRINT(sp, ch) (CHAR_WIDTH(sp, ch) > 0) #define CAN_PRINT(sp, ch) (XCHAR_WIDTH(sp, ch) > 0)
#else #else
#define FILE2INT5(sp,buf,n,nlen,w,wlen) \ #define FILE2INT5(sp,buf,n,nlen,w,wlen) \
(w = n, wlen = nlen, 0) (w = n, wlen = nlen, 0)
@ -37,7 +37,7 @@
(w = n, wlen = nlen, 0) (w = n, wlen = nlen, 0)
#define CONST const #define CONST const
#define INTISWIDE(c) 0 #define INTISWIDE(c) 0
#define CHAR_WIDTH(sp, ch) 1 #define XCHAR_WIDTH(sp, ch) 1
#define CAN_PRINT(sp, ch) isprint(ch) #define CAN_PRINT(sp, ch) isprint(ch)
#endif #endif
#define FILE2INT(sp,n,nlen,w,wlen) \ #define FILE2INT(sp,n,nlen,w,wlen) \

View File

@ -97,4 +97,8 @@ enum optdisp { NO_DISPLAY, ALL_DISPLAY, CHANGED_DISPLAY, SELECT_DISPLAY };
/* Options array. */ /* Options array. */
extern OPTLIST const optlist[]; extern OPTLIST const optlist[];
#ifdef O_PATH
#undef O_PATH /* bits/fcntl-linux.h may have defined O_PATH. */
#endif
#include "options_def.h" #include "options_def.h"

View File

@ -701,7 +701,13 @@ rcv_read(SCR *sp, FREF *frp)
/* If we've found more than one, take the most recent. */ /* If we've found more than one, take the most recent. */
(void)fstat(fileno(fp), &sb); (void)fstat(fileno(fp), &sb);
if (recp == NULL || if (recp == NULL ||
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
timespeccmp(&rec_mtim, &sb.st_mtimespec, <)) {
#elif defined HAVE_STRUCT_STAT_ST_MTIM
timespeccmp(&rec_mtim, &sb.st_mtim, <)) { timespeccmp(&rec_mtim, &sb.st_mtim, <)) {
#else
rec_mtim.tv_sec < sb.st_mtime) {
#endif
p = recp; p = recp;
t = pathp; t = pathp;
recp = recpath; recp = recpath;
@ -710,7 +716,13 @@ rcv_read(SCR *sp, FREF *frp)
free(p); free(p);
free(t); free(t);
} }
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
rec_mtim = sb.st_mtimespec;
#elif defined HAVE_STRUCT_STAT_ST_MTIM
rec_mtim = sb.st_mtim; rec_mtim = sb.st_mtim;
#else
rec_mtim.tv_sec = sb.st_mtime;
#endif
if (sv_fd != -1) if (sv_fd != -1)
(void)close(sv_fd); (void)close(sv_fd);
sv_fd = dup(fileno(fp)); sv_fd = dup(fileno(fp));

View File

@ -2266,7 +2266,8 @@ ex_comm_search(CHAR_T *name, size_t len)
return (NULL); return (NULL);
if (cp->name[0] != name[0]) if (cp->name[0] != name[0])
continue; continue;
if (!MEMCMP(name, cp->name, len)) if (STRLEN(cp->name) >= len &&
!MEMCMP(name, cp->name, len))
return (cp); return (cp);
} }
return (NULL); return (NULL);

View File

@ -261,7 +261,14 @@ cscope_add(SCR *sp, EXCMD *cmdp, CHAR_T *dname)
csc->dname = csc->buf; csc->dname = csc->buf;
csc->dlen = len; csc->dlen = len;
memcpy(csc->dname, np, len); memcpy(csc->dname, np, len);
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
csc->mtim = sb.st_mtimespec;
#elif defined HAVE_STRUCT_STAT_ST_MTIM
csc->mtim = sb.st_mtim; csc->mtim = sb.st_mtim;
#else
csc->mtim.tv_sec = sb.st_mtime;
csc->mtim.tv_nsec = 0;
#endif
/* Get the search paths for the cscope. */ /* Get the search paths for the cscope. */
if (get_paths(sp, csc)) if (get_paths(sp, csc))
@ -812,8 +819,15 @@ csc_file(SCR *sp, CSC *csc, char *name, char **dirp, size_t *dlenp, int *isolder
free(buf); free(buf);
*dirp = *pp; *dirp = *pp;
*dlenp = strlen(*pp); *dlenp = strlen(*pp);
#if defined HAVE_STRUCT_STAT_ST_MTIMESPEC
*isolderp = timespeccmp(
&sb.st_mtimespec, &csc->mtim, <);
#elif defined HAVE_STRUCT_STAT_ST_MTIM
*isolderp = timespeccmp( *isolderp = timespeccmp(
&sb.st_mtim, &csc->mtim, <); &sb.st_mtim, &csc->mtim, <);
#else
*isolderp = sb.st_mtime < csc->mtim.tv_sec;
#endif
return; return;
} }
free(buf); free(buf);

View File

@ -1,131 +0,0 @@
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 *);

View File

@ -1809,7 +1809,8 @@ Display buffers, Cscope connections, screens or tags.
.Op Ar +cmd .Op Ar +cmd
.Op Ar file .Op Ar file
.Xc .Xc
Edit a different file. Edit a different file. The capitalized command opens a new screen below the
current screen.
.Pp .Pp
.It Xo .It Xo
.Cm exu Ns Op Cm sage .Cm exu Ns Op Cm sage
@ -1832,7 +1833,8 @@ Display and optionally change the file name.
.Xc .Xc
.Nm vi .Nm vi
mode only. mode only.
Foreground the specified screen. Foreground the specified screen. The capitalized command opens a new screen
below the current screen.
.Pp .Pp
.It Xo .It Xo
.Op Ar range .Op Ar range
@ -1919,7 +1921,8 @@ Write the abbreviations, editor options and maps to the specified
.Op Cm !\& .Op Cm !\&
.Op Ar .Op Ar
.Xc .Xc
Edit the next file from the argument list. Edit the next file from the argument list. The capitalized command opens a
new screen below the current screen.
.\" .Pp .\" .Pp
.\" .It Xo .\" .It Xo
.\" .Op Ar line .\" .Op Ar line
@ -1940,7 +1943,8 @@ option.
.Cm rev Ns Op Cm ious Ns .Cm rev Ns Op Cm ious Ns
.Op Cm !\& .Op Cm !\&
.Xc .Xc
Edit the previous file from the argument list. Edit the previous file from the argument list. The capitalized command opens
a new screen below the current screen.
.Pp .Pp
.It Xo .It Xo
.Op Ar range .Op Ar range
@ -2103,7 +2107,8 @@ character is usually
.Op Cm !\& .Op Cm !\&
.Ar tagstring .Ar tagstring
.Xc .Xc
Edit the file containing the specified tag. Edit the file containing the specified tag. The capitalized command opens a
new screen below the current screen.
.Pp .Pp
.It Xo .It Xo
.Cm tagn Ns Op Cm ext Ns .Cm tagn Ns Op Cm ext Ns
@ -2166,15 +2171,15 @@ Enter
.Nm vi . .Nm vi .
.Pp .Pp
.It Xo .It Xo
.Op Cm Vi Ns .Cm Vi Ns
.Cm i Ns Op Cm sual Ns .Op Cm sual Ns
.Op Cm !\& .Op Cm !\&
.Op Ar +cmd .Op Ar +cmd
.Op Ar file .Op Ar file
.Xc .Xc
.Nm vi .Nm vi
mode only. mode only. Edit a different file by opening a new screen below the current
Edit a new file. screen.
.Pp .Pp
.It Xo .It Xo
.Cm viu Ns Op Cm sage .Cm viu Ns Op Cm sage
@ -2185,6 +2190,14 @@ Display usage for a
command. command.
.Pp .Pp
.It Xo .It Xo
.Cm vs Ns Op Cm plit
.Op Ar +cmd
.Op Ar file
.Xc
Edit a different file by opening a new screen to the right of the current
screen.
.Pp
.It Xo
.Op Ar range .Op Ar range
.Cm w Ns Op Cm rite Ns .Cm w Ns Op Cm rite Ns
.Op Cm !\& .Op Cm !\&
@ -2194,8 +2207,7 @@ command.
.It Xo .It Xo
.Op Ar range .Op Ar range
.Cm w Ns Op Cm rite .Cm w Ns Op Cm rite
.Op Cm !\& .Cm !\& Ns Ar shell-command
.Op Ar file
.Xc .Xc
.It Xo .It Xo
.Op Ar range .Op Ar range
@ -2209,7 +2221,21 @@ command.
.Op >> .Op >>
.Op Ar file .Op Ar file
.Xc .Xc
Write the file. Write the entire file, or
.Ar range .
.Sq !\&
overwrites a different, preexisting file.
.Sq >>
appends to a file that may preexist. Whitespace followed by
.Sq !\&
pipes the file to
.Ar shell-command .
.Cm wn
moves to the next file if writing succeeds.
.Cm wq
exits the editor if writing succeeds, unless there are more files to edit;
.Sq !\&
exits regardless.
.Pp .Pp
.It Xo .It Xo
.Op Ar range .Op Ar range

View File

@ -1,145 +0,0 @@
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);

View File

@ -198,7 +198,7 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
/* If we cross 0, signed numbers lose their sign. */ /* If we cross 0, signed numbers lose their sign. */
if (lval == 0 && ntype == fmt[SDEC]) if (lval == 0 && ntype == fmt[SDEC])
ntype = fmt[DEC]; ntype = fmt[DEC];
nlen = SPRINTF(nbuf, sizeof(nbuf), ntype, lval); nlen = SPRINTF(nbuf, SIZE(nbuf), ntype, lval);
} else { } else {
if ((nret = nget_uslong(&ulval, t, NULL, base)) != NUM_OK) if ((nret = nget_uslong(&ulval, t, NULL, base)) != NUM_OK)
goto err; goto err;
@ -220,7 +220,7 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
if (base == 16) if (base == 16)
wlen -= 2; wlen -= 2;
nlen = SPRINTF(nbuf, sizeof(nbuf), ntype, wlen, ulval); nlen = SPRINTF(nbuf, SIZE(nbuf), ntype, wlen, ulval);
} }
/* Build the new line. */ /* Build the new line. */

View File

@ -427,7 +427,7 @@ empty: (void)gp->scr_addstr(sp,
FLUSH; FLUSH;
/* don't display half a wide character */ /* don't display half a wide character */
if (is_partial && CHAR_WIDTH(sp, ch) > 1) { if (is_partial && XCHAR_WIDTH(sp, ch) > 1) {
*cbp++ = ' '; *cbp++ = ' ';
break; break;
} }

View File

@ -16,7 +16,7 @@ VIEW= nview
PROG= nvi PROG= nvi
CFLAGS+= -D__REGEX_PRIVATE CFLAGS+= -D__REGEX_PRIVATE -D_XOPEN_SOURCE_EXTENDED=1
LINKS= ${BINDIR}/${VI} ${BINDIR}/${EX} ${BINDIR}/${VI} ${BINDIR}/${VIEW} LINKS= ${BINDIR}/${VI} ${BINDIR}/${EX} ${BINDIR}/${VI} ${BINDIR}/${VIEW}
LINKS+= ${BINDIR}/${VI} ${BINDIR}/vi ${BINDIR}/${EX} ${BINDIR}/ex LINKS+= ${BINDIR}/${VI} ${BINDIR}/vi ${BINDIR}/${EX} ${BINDIR}/ex
@ -32,7 +32,8 @@ MLINKS+=vi.1 nex.1 vi.1 nview.1 vi.1 nvi.1
.PATH: ${SRCDIR}/vi .PATH: ${SRCDIR}/vi
.PATH: ${SRCDIR}/regex .PATH: ${SRCDIR}/regex
CFLAGS+=-I${.CURDIR} -I${SRCDIR} -I${SRCDIR}/regex CFLAGS+=-I${.CURDIR} -I${SRCDIR} -I${SRCDIR}/regex \
-I${.CURDIR}/ex
LIBADD= util ncursesw LIBADD= util ncursesw

View File

@ -15,5 +15,14 @@
/* Define if you have <ncurses.h> */ /* Define if you have <ncurses.h> */
#define HAVE_NCURSES_H #define HAVE_NCURSES_H
/* Define if you have <ncursesw/ncurses.h> */
/* #undef HAVE_NCURSESW_NCURSES_H */
/* Define if you have <pty.h> */
/* #undef HAVE_PTY_H */
/* Define if you have <term.h> */ /* Define if you have <term.h> */
#define HAVE_TERM_H #define HAVE_TERM_H
/* Define if struct dirent has field d_namlen */
#define HAVE_DIRENT_D_NAMLEN

View File

@ -1 +1,3 @@
/* $FreeBSD$ */
#define VI_VERSION "2.2.0 (2020-08-01)" #define VI_VERSION "2.2.0 (2020-08-01)"

444
usr.bin/vi/extern.h Normal file
View File

@ -0,0 +1,444 @@
#ifdef CL_IN_EX /* cl.h */
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);
#endif
#ifdef EXP /* ex.h */
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 *);
#endif
#ifdef V_ABS /* vi.h */
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);
#endif /* common.h */
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 *, ...);