summaryrefslogtreecommitdiff
path: root/ex
diff options
context:
space:
mode:
Diffstat (limited to 'ex')
-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
10 files changed, 234 insertions, 18 deletions
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)"