summaryrefslogtreecommitdiff
path: root/ed.chared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ed.chared.c')
-rw-r--r--ed.chared.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/ed.chared.c b/ed.chared.c
index 8d00326c3db1..c56d00eb0a6f 100644
--- a/ed.chared.c
+++ b/ed.chared.c
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.103 2015/08/19 14:29:55 christos Exp $ */
/*
* ed.chared.c: Character editing functions.
*/
@@ -72,7 +72,7 @@
#include "sh.h"
-RCSID("$tcsh: ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $")
+RCSID("$tcsh: ed.chared.c,v 3.103 2015/08/19 14:29:55 christos Exp $")
#include "ed.h"
#include "tw.h"
@@ -93,7 +93,7 @@ RCSID("$tcsh: ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $")
* from: Gert-Jan Vons <vons@cesar.crbca1.sinet.slb.com>
*/
#define C_CLASS_WHITE 1
-#define C_CLASS_ALNUM 2
+#define C_CLASS_WORD 2
#define C_CLASS_OTHER 3
static Char *InsertPos = InputBuf; /* Where insertion starts */
@@ -290,7 +290,7 @@ c_preword(Char *p, Char *low, int n, Char *delim)
/*
* c_to_class() returns the class of the given character.
*
- * This is used to make the c_prev_word() and c_next_word() functions
+ * This is used to make the c_prev_word(), c_next_word() and c_eword() functions
* work like vi's, which classify characters. A word is a sequence of
* characters belonging to the same class, classes being defined as
* follows:
@@ -305,8 +305,8 @@ c_to_class(Char ch)
if (Isspace(ch))
return C_CLASS_WHITE;
- if (Isdigit(ch) || Isalpha(ch) || ch == '_')
- return C_CLASS_ALNUM;
+ if (isword(ch))
+ return C_CLASS_WORD;
return C_CLASS_OTHER;
}
@@ -828,15 +828,24 @@ c_eword(Char *p, Char *high, int n)
p++;
while (n--) {
- while ((p < high) && Isspace(*p))
- p++;
+ int c_class;
- if (isword(*p))
- while ((p < high) && isword(*p))
- p++;
- else
- while ((p < high) && !(Isspace(*p) || isword(*p)))
- p++;
+ if (p >= high)
+ break;
+
+ /* scan until end of current word (may be all whitespace!) */
+ c_class = c_to_class(*p);
+ while ((p < high) && c_class == c_to_class(*p))
+ p++;
+
+ /* if this was a non_whitespace word, we're ready */
+ if (c_class != C_CLASS_WHITE)
+ continue;
+
+ /* otherwise, move to the end of the word just found */
+ c_class = c_to_class(*p);
+ while ((p < high) && c_class == c_to_class(*p))
+ p++;
}
p--;
@@ -941,7 +950,7 @@ c_push_kill(Char *start, Char *end)
/* Save InputBuf etc in SavedBuf etc for restore after cmd exec */
static void
-c_save_inputbuf()
+c_save_inputbuf(void)
{
SavedBuf.len = 0;
Strbuf_append(&SavedBuf, InputBuf);
@@ -953,7 +962,7 @@ c_save_inputbuf()
}
CCRETVAL
-GetHistLine()
+GetHistLine(void)
{
struct Hist *hp;
int h;
@@ -3025,7 +3034,7 @@ e_uppercase(Char c)
/*ARGSUSED*/
CCRETVAL
-e_capitolcase(Char c)
+e_capitalcase(Char c)
{
Char *cp, *end;
@@ -3387,7 +3396,7 @@ e_stuff_char(Char c)
(void) Cookedmode();
(void) xwrite(SHIN, "\n", 1);
- len = one_wctomb(buf, c & CHAR);
+ len = one_wctomb(buf, c);
for (i = 0; i < len; i++)
(void) ioctl(SHIN, TIOCSTI, (ioctl_t) &buf[i]);