aboutsummaryrefslogtreecommitdiff
path: root/ed.chared.c
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2023-01-29 20:46:19 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2023-01-29 20:46:19 +0000
commit143ef44f06822f82a8358d4c02f07102d963fe5f (patch)
treef9080b8a265dd926053ee7ae187e8fa46f3fb5e0 /ed.chared.c
parent174d8b60324d7e8754709f7155e13ca95220b48c (diff)
Diffstat (limited to 'ed.chared.c')
-rw-r--r--ed.chared.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/ed.chared.c b/ed.chared.c
index 2a8689713399..3792000a523d 100644
--- a/ed.chared.c
+++ b/ed.chared.c
@@ -44,8 +44,8 @@
# echo h<press key bound to dabbrev-expande>
# echo hello\ world<cursor>
- The same problem occured if spaces were present in a string withing quotation
- marks. Example:
+ The same problem occurred if spaces were present in a string withing
+ quotation marks. Example:
# echo "hello world"
hello world
@@ -126,7 +126,7 @@ static void c_get_word (Char **, Char **);
#endif
static Char *c_preword (Char *, Char *, int, Char *);
static Char *c_nexword (Char *, Char *, int);
-static Char *c_endword (Char *, Char *, int, Char *);
+static Char *c_endword (Char *, Char *, Char *, int, Char *);
static Char *c_eword (Char *, Char *, int);
static void c_push_kill (Char *, Char *);
static void c_save_inputbuf (void);
@@ -266,7 +266,7 @@ c_preword(Char *p, Char *low, int n, Char *delim)
while (new < p) {
prev = new;
- new = c_endword(prev-1, p, 1, delim); /* Skip to next non-word char */
+ new = c_endword(prev-1, low, p, 1, delim); /* Skip to next non-word char */
new++; /* Step away from end of word */
while (new <= p) { /* Skip trailing non-word chars */
if (!Strchr(delim, *new) || (new > prev && new[-1] == (Char)'\\'))
@@ -788,7 +788,7 @@ c_delfini(void) /* Finish up delete action */
}
static Char *
-c_endword(Char *p, Char *high, int n, Char *delim)
+c_endword(Char *p, Char *low, Char *high, int n, Char *delim)
{
Char inquote = 0;
p++;
@@ -801,13 +801,14 @@ c_endword(Char *p, Char *high, int n, Char *delim)
}
while (p < high) { /* Skip string */
if ((*p == (Char)'\'' || *p == (Char)'"')) { /* Quotation marks? */
- if (inquote || p[-1] != (Char)'\\') { /* Should it be honored? */
+ /* Should it be honored? */
+ if (inquote || (p > low && p[-1] != (Char)'\\')) {
if (inquote == 0) inquote = *p;
else if (inquote == *p) inquote = 0;
}
}
/* Break if unquoted non-word char */
- if (!inquote && Strchr(delim, *p) && p[-1] != (Char)'\\')
+ if (!inquote && Strchr(delim, *p) && p > low && p[-1] != (Char)'\\')
break;
p++;
}
@@ -2205,7 +2206,7 @@ e_dabbrev_expand(Char c)
continue;
} else {
word++;
- len = c_endword(ncp-1, cp, 1, STRshwordsep) - ncp + 1;
+ len = c_endword(ncp-1, InputBuf, cp, 1, STRshwordsep) - ncp + 1;
cp = ncp;
}
if (len > patbuf.len && Strncmp(cp, patbuf.s, patbuf.len) == 0) {
@@ -3567,7 +3568,7 @@ e_load_average(Char c)
#ifdef TIOCSTAT
/*
* Here we pass &c to the ioctl because some os's (NetBSD) expect it
- * there even if they don't use it. (lukem@netbsd.org)
+ * there even if they don't use it. (Luke Mewburn)
*/
if (ioctl(SHIN, TIOCSTAT, (ioctl_t) &c) < 0)
#endif
@@ -3605,7 +3606,7 @@ v_endword(Char c)
return(CC_ERROR);
/* else */
- Cursor = c_endword(Cursor, LastChar, Argument, STRshwspace);
+ Cursor = c_endword(Cursor, InputBuf, LastChar, Argument, STRshwspace);
if (ActionFlag & TCSHOP_DELETE)
{