add icmp statistics printing
[unix-history] / usr / src / usr.bin / ex / ex_vget.c
index 8d0a4a5..5640277 100644 (file)
@@ -1,5 +1,5 @@
-/* Copyright (c) 1980 Regents of the University of California */
-static char *sccsid = "@(#)ex_vget.c   4.2 %G%";
+/* Copyright (c) 1981 Regents of the University of California */
+static char *sccsid = "@(#)ex_vget.c   6.3 %G%";
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
@@ -15,7 +15,7 @@ static char *sccsid = "@(#)ex_vget.c  4.2 %G%";
  * Return the key.
  */
 ungetkey(c)
  * Return the key.
  */
 ungetkey(c)
-       char c;
+       int c;          /* mjm: char --> int */
 {
 
        if (Peekkey != ATTN)
 {
 
        if (Peekkey != ATTN)
@@ -27,7 +27,7 @@ ungetkey(c)
  */
 getkey()
 {
  */
 getkey()
 {
-       register char c;
+       register int c;         /* mjm: char --> int */
 
        do {
                c = getbr();
 
        do {
                c = getbr();
@@ -64,6 +64,7 @@ getbr()
        char ch;
        register int c, d;
        register char *colp;
        char ch;
        register int c, d;
        register char *colp;
+       int cnt;
 #define BEEHIVE
 #ifdef BEEHIVE
        static char Peek2key;
 #define BEEHIVE
 #ifdef BEEHIVE
        static char Peek2key;
@@ -101,7 +102,7 @@ getATTN:
        }
        flusho();
 again:
        }
        flusho();
 again:
-       if (read(slevel == 0 ? 0 : ttyindes, &ch, 1) != 1) {
+       if ((c=read(slevel == 0 ? 0 : ttyindes, &ch, 1)) != 1) {
                if (errno == EINTR)
                        goto getATTN;
                error("Input read error");
                if (errno == EINTR)
                        goto getATTN;
                error("Input read error");
@@ -251,7 +252,7 @@ readecho(c)
                vglobp = INS;
        }
        OP = Pline; Pline = normline;
                vglobp = INS;
        }
        OP = Pline; Pline = normline;
-       ignore(vgetline(0, genbuf + 1, &waste));
+       ignore(vgetline(0, genbuf + 1, &waste, c));
        if (Outchar == termchar)
                putchar('\n');
        vscrap();
        if (Outchar == termchar)
                putchar('\n');
        vscrap();
@@ -455,7 +456,7 @@ map(c,maps)
                                        if ((c=='#' ? peekkey() : fastpeekkey()) == 0) {
 #ifdef MDEBUG
                                                if (trace)
                                        if ((c=='#' ? peekkey() : fastpeekkey()) == 0) {
 #ifdef MDEBUG
                                                if (trace)
-                                                       fprintf(trace,"fpk=0: return '%c'",c);
+                                                       fprintf(trace,"fpk=0: will return '%c'",c);
 #endif
                                                /*
                                                 * Nothing waiting.  Push back
 #endif
                                                /*
                                                 * Nothing waiting.  Push back
@@ -467,7 +468,15 @@ map(c,maps)
                                                 * to undo part of an insertion
                                                 * so if in input mode don't.
                                                 */
                                                 * to undo part of an insertion
                                                 * so if in input mode don't.
                                                 */
+#ifdef MDEBUG
+                                               if (trace)
+                                                       fprintf(trace, "Call macpush, b %d %d %d\n", b[0], b[1], b[2]);
+#endif
                                                macpush(&b[1],maps == arrows);
                                                macpush(&b[1],maps == arrows);
+#ifdef MDEBUG
+                                               if (trace)
+                                                       fprintf(trace, "return %d\n", c);       
+#endif
                                                return(c);
                                        }
                                        *q = getkey();
                                                return(c);
                                        }
                                        *q = getkey();
@@ -511,11 +520,7 @@ int canundo;
 
        if (st==0 || *st==0)
                return;
 
        if (st==0 || *st==0)
                return;
-#ifdef notdef
-       if (!value(UNDOMACRO))
-               canundo = 0;
-#endif
-#ifdef TRACE
+#ifdef MDEBUG
        if (trace)
                fprintf(trace, "macpush(%s), canundo=%d\n",st,canundo);
 #endif
        if (trace)
                fprintf(trace, "macpush(%s), canundo=%d\n",st,canundo);
 #endif
@@ -565,6 +570,7 @@ vudump(s)
 char *s;
 {
        register line *p;
 char *s;
 {
        register line *p;
+       char savelb[1024];
 
        if (!trace) return;
 
 
        if (!trace) return;
 
@@ -572,10 +578,16 @@ char *s;
                s, undkind, vundkind, lineno(unddel), lineno(undap1), lineno(undap2));
        fprintf(trace, "  undadot=%d, dot=%d, dol=%d, unddol=%d, truedol=%d\n",
                lineno(undadot), lineno(dot), lineno(dol), lineno(unddol), lineno(truedol));
                s, undkind, vundkind, lineno(unddel), lineno(undap1), lineno(undap2));
        fprintf(trace, "  undadot=%d, dot=%d, dol=%d, unddol=%d, truedol=%d\n",
                lineno(undadot), lineno(dot), lineno(dol), lineno(unddol), lineno(truedol));
-       fprintf(trace, "  [");
-       for (p=zero+1; p<=truedol; p++)
+       fprintf(trace, "  [\n");
+       CP(savelb, linebuf);
+       fprintf(trace, "linebuf = '%s'\n", linebuf);
+       for (p=zero+1; p<=truedol; p++) {
                fprintf(trace, "%o ", *p);
                fprintf(trace, "%o ", *p);
+               getline(*p);
+               fprintf(trace, "'%s'\n", linebuf);
+       }
        fprintf(trace, "]\n");
        fprintf(trace, "]\n");
+       CP(linebuf, savelb);
 }
 #endif
 
 }
 #endif
 
@@ -622,9 +634,19 @@ fastpeekkey()
         * as separate.  notimeout is provided for people who dislike such
         * nondeterminism.
         */
         * as separate.  notimeout is provided for people who dislike such
         * nondeterminism.
         */
+#ifdef MDEBUG
+       if (trace)
+               fprintf(trace,"\nfastpeekkey: ",c);
+#endif
        if (value(TIMEOUT) && inopen >= 0) {
                signal(SIGALRM, trapalarm);
        if (value(TIMEOUT) && inopen >= 0) {
                signal(SIGALRM, trapalarm);
+#ifdef MDEBUG
+               alarm(10);
+               if (trace)
+                       fprintf(trace, "set alarm ");
+#else
                alarm(1);
                alarm(1);
+#endif
        }
        CATCH
                c = peekkey();
        }
        CATCH
                c = peekkey();
@@ -637,7 +659,7 @@ fastpeekkey()
                c = 0;
 #ifdef MDEBUG
        if (trace)
                c = 0;
 #ifdef MDEBUG
        if (trace)
-               fprintf(trace,"[TOUT]",c);
+               fprintf(trace,"[TIMEOUT]",c);
 #endif
        ENDCATCH
 #ifdef MDEBUG
 #endif
        ENDCATCH
 #ifdef MDEBUG