summaryrefslogtreecommitdiffstats
path: root/contrib/tcsh/ed.inputl.c
diff options
context:
space:
mode:
authormp <mp@FreeBSD.org>2005-04-24 19:41:08 +0000
committermp <mp@FreeBSD.org>2005-04-24 19:41:08 +0000
commit94a109bd814074f290affa8f7698847719d55833 (patch)
tree6daeb0464a7bc8705c0246b7fd98e212b6beed09 /contrib/tcsh/ed.inputl.c
parentbbd1addf8f9452690ad13ce5b875ee4cc9633958 (diff)
downloadFreeBSD-src-94a109bd814074f290affa8f7698847719d55833.zip
FreeBSD-src-94a109bd814074f290affa8f7698847719d55833.tar.gz
Import of tcsh-6.14.00
Diffstat (limited to 'contrib/tcsh/ed.inputl.c')
-rw-r--r--contrib/tcsh/ed.inputl.c94
1 files changed, 63 insertions, 31 deletions
diff --git a/contrib/tcsh/ed.inputl.c b/contrib/tcsh/ed.inputl.c
index 68da69d..fb87f8b 100644
--- a/contrib/tcsh/ed.inputl.c
+++ b/contrib/tcsh/ed.inputl.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.inputl.c,v 3.51 2002/06/25 19:02:11 christos Exp $ */
+/* $Header: /src/pub/tcsh/ed.inputl.c,v 3.57 2004/12/25 21:15:06 christos Exp $ */
/*
* ed.inputl.c: Input line handling.
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: ed.inputl.c,v 3.51 2002/06/25 19:02:11 christos Exp $")
+RCSID("$Id: ed.inputl.c,v 3.57 2004/12/25 21:15:06 christos Exp $")
#include "ed.h"
#include "ed.defns.h" /* for the function names */
@@ -42,9 +42,7 @@ RCSID("$Id: ed.inputl.c,v 3.51 2002/06/25 19:02:11 christos Exp $")
/* ed.inputl -- routines to get a single line from the input. */
-extern bool tellwhat;
-extern bool MapsAreInited;
-extern bool Tty_raw_mode;
+extern int MapsAreInited;
/* mismatched first character */
static Char mismatch[] =
@@ -57,7 +55,7 @@ static int CompleteLine __P((void));
static void RunCommand __P((Char *));
static void doeval1 __P((Char **));
-static bool rotate = 0;
+static int rotate = 0;
static int
@@ -81,7 +79,6 @@ Inputl()
{
CCRETVAL retval;
KEYCMD cmdnum = 0;
- extern KEYCMD NumFuns;
unsigned char tch; /* the place where read() goes */
Char ch;
int num; /* how many chars we have read at NL */
@@ -649,7 +646,7 @@ RunCommand(str)
static int
GetNextCommand(cmdnum, ch)
KEYCMD *cmdnum;
- register Char *ch;
+ Char *ch;
{
KEYCMD cmd = 0;
int num;
@@ -662,6 +659,8 @@ GetNextCommand(cmdnum, ch)
if (
#ifdef DSPMBYTE
_enable_mbdisp &&
+#else
+ MB_LEN_MAX == 1 &&
#endif
!adrof(STRnokanji) && (*ch & META)) {
MetaNext = 0;
@@ -680,7 +679,11 @@ GetNextCommand(cmdnum, ch)
if (*ch < NT_NUM_KEYS)
cmd = CurrentKeyMap[*ch];
else
+#ifdef WINNT_NATIVE
cmd = CurrentKeyMap[(unsigned char) *ch];
+#else
+ cmd = F_INSERT;
+#endif
if (cmd == F_XKEY) {
XmapVal val;
CStr cstr;
@@ -708,14 +711,30 @@ GetNextCommand(cmdnum, ch)
return OKCMD;
}
+static Char ungetchar;
+static int haveungetchar;
+
+void
+UngetNextChar(Char cp)
+{
+ ungetchar = cp;
+ haveungetchar = 1;
+}
+
int
GetNextChar(cp)
- register Char *cp;
+ Char *cp;
{
- register int num_read;
+ int num_read;
int tried = 0;
- unsigned char tcp;
+ char cbuf[MB_LEN_MAX];
+ size_t cbp;
+ if (haveungetchar) {
+ haveungetchar = 0;
+ *cp = ungetchar;
+ return 1;
+ }
for (;;) {
if (MacroLvl < 0) {
if (!Load_input_line())
@@ -738,32 +757,45 @@ GetNextChar(cp)
#ifdef WINNT_NATIVE
__nt_want_vcode = 1;
#endif /* WINNT_NATIVE */
- while ((num_read = read(SHIN, (char *) &tcp, 1)) == -1) {
- if (errno == EINTR)
- continue;
- if (!tried && fixio(SHIN, errno) != -1)
- tried = 1;
- else {
-#ifdef convex
- /* need to print error message in case the file is migrated */
- if (errno != EINTR)
- stderror(ERR_SYSTEM, progname, strerror(errno));
-#endif /* convex */
-#ifdef WINNT_NATIVE
- __nt_want_vcode = 0;
-#endif /* WINNT_NATIVE */
- *cp = '\0';
- return -1;
+#ifdef SIG_WINDOW
+ if (windowchg)
+ (void) check_window_size(0); /* for window systems */
+#endif /* SIG_WINDOW */
+ cbp = 0;
+ for (;;) {
+ while ((num_read = read(SHIN, cbuf + cbp, 1)) == -1) {
+ if (errno == EINTR)
+ continue;
+ if (!tried && fixio(SHIN, errno) != -1)
+ tried = 1;
+ else {
+# ifdef convex
+ /* need to print error message in case the file is migrated */
+ if (errno != EINTR)
+ stderror(ERR_SYSTEM, progname, strerror(errno));
+# endif /* convex */
+# ifdef WINNT_NATIVE
+ __nt_want_vcode = 0;
+# endif /* WINNT_NATIVE */
+ *cp = '\0'; /* Loses possible partial character */
+ return -1;
+ }
}
+ cbp++;
+ if (normal_mbtowc(cp, cbuf, cbp) == -1) {
+ reset_mbtowc();
+ if (cbp < MB_LEN_MAX)
+ continue; /* Maybe a partial character */
+ /* And drop the following bytes, if any */
+ *cp = (unsigned char)*cbuf | INVALID_BYTE;
+ }
+ break;
}
#ifdef WINNT_NATIVE
+ /* This is the part that doesn't work with WIDE_STRINGS */
if (__nt_want_vcode == 2)
*cp = __nt_vcode;
- else
- *cp = tcp;
__nt_want_vcode = 0;
-#else
- *cp = tcp;
#endif /* WINNT_NATIVE */
return num_read;
}
OpenPOWER on IntegriCloud