nuke some of the dbg

This commit is contained in:
tg 2006-11-05 19:56:20 +00:00
parent a3331fd8e9
commit 45f1602850

79
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.53 2006/11/05 19:48:58 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.54 2006/11/05 19:56:20 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -56,7 +56,7 @@ static int x_file_glob(int, const char *, int, char ***);
static int x_command_glob(int, const char *, int, char ***); static int x_command_glob(int, const char *, int, char ***);
static int x_locate_word(const char *, int, int, int *, int *); static int x_locate_word(const char *, int, int, int *, int *);
#if 1 #if 0
static void D(const char *, ...) static void D(const char *, ...)
__attribute__((__format__ (printf, 1, 2))); __attribute__((__format__ (printf, 1, 2)));
static void static void
@ -1604,12 +1604,10 @@ x_insert(int c)
static int left = 0, pos, save_arg; static int left = 0, pos, save_arg;
static char str[4]; static char str[4];
D("{%d}", left);
/* /*
* Should allow tab and control chars. * Should allow tab and control chars.
*/ */
if (c == 0) { if (c == 0) {
D("->0 ");
left = 0; left = 0;
x_e_putc2(7); x_e_putc2(7);
return KSTD; return KSTD;
@ -1619,12 +1617,10 @@ x_insert(int c)
str[pos++] = c; str[pos++] = c;
left--; left--;
if (!left) { if (!left) {
D("%02X]", c);
str[pos] = '\0'; str[pos] = '\0';
x_arg = save_arg; x_arg = save_arg;
goto x_insert_write; goto x_insert_write;
} }
D("%02X|", c);
return (KSTD); return (KSTD);
} }
if (left) { if (left) {
@ -1639,15 +1635,12 @@ x_insert(int c)
else if ((c >= 0xE0) && (c < 0xF0)) else if ((c >= 0xE0) && (c < 0xF0))
left = 2; left = 2;
if (left) { if (left) {
D("[%02X|", c);
save_arg = x_arg; save_arg = x_arg;
pos = 1; pos = 1;
str[0] = c; str[0] = c;
return (KSTD); return (KSTD);
} }
D("<%02X>", c); }
} else
D("|%02X}", c);
left = 0; left = 0;
str[0] = c; str[0] = c;
str[1] = '\0'; str[1] = '\0';
@ -1692,7 +1685,6 @@ x_ins(char *s)
char *cp = xcp; char *cp = xcp;
int adj = x_adj_done; int adj = x_adj_done;
D(" x_ins(%s) ", s);
if (x_do_ins(s, strlen(s)) < 0) if (x_do_ins(s, strlen(s)) < 0)
return -1; return -1;
/* /*
@ -1704,13 +1696,11 @@ x_ins(char *s)
x_adj_ok = (xcp >= xlp); x_adj_ok = (xcp >= xlp);
x_zots(cp); x_zots(cp);
if (adj == x_adj_done) { /* has x_adjust() been called? */ if (adj == x_adj_done) { /* has x_adjust() been called? */
D("H xlp=%td xcp=%td ", xlp-xbuf, xcp-xbuf); /* no */ /* no */
for (cp = xlp; cp > xcp; ) { cp = xlp;
D(":"); while (cp > xcp)
x_bs2(cp = utf_backch(cp)); x_bs2(cp = utf_backch(cp));
} }
}
D("I");
x_adj_ok = 1; x_adj_ok = 1;
return 0; return 0;
} }
@ -1918,38 +1908,20 @@ x_fword(int move)
static void static void
x_goto(char *cp) x_goto(char *cp)
{ {
D("A");
if (cp < xbuf)
D(" cp < xbuf ");
D("A1");
if (cp > xep)
D(" cp > xep ");
D("A2 xbp=%td xcp=%td tgp=%td ", xbp-xbuf, xcp-xbuf, cp-xbuf);
if (Flag(FUTFHACK)) if (Flag(FUTFHACK))
while ((cp > xbuf) && ((*cp & 0xC0) == 0x80)) { while ((cp > xbuf) && ((*cp & 0xC0) == 0x80))
--cp; --cp;
D("A2a xbp=%td xcp=%td tgp=%td ", xbp-xbuf, xcp-xbuf, cp-xbuf);
}
if (cp < xbp || cp >= utf_getcpfromcols(xbp, x_displen)) { if (cp < xbp || cp >= utf_getcpfromcols(xbp, x_displen)) {
D("A3");
/* we are heading off screen */ /* we are heading off screen */
xcp = cp; xcp = cp;
x_adjust(); x_adjust();
D("A3a");
} else if (cp < xcp) { /* move back */ } else if (cp < xcp) { /* move back */
D("A4"); while (cp < xcp)
while (cp < xcp) {
D("A4a %td %td ", cp-xbuf, xcp-xbuf);
x_bs2(xcp = utf_backch(xcp)); x_bs2(xcp = utf_backch(xcp));
}
} else if (cp > xcp) { /* move forward */ } else if (cp > xcp) { /* move forward */
D("A5"); while (cp > xcp)
while (cp > xcp) {
D("A5a");
x_zotc3(&xcp); x_zotc3(&xcp);
} }
}
D("B");
} }
static void static void
@ -1958,7 +1930,6 @@ x_bs2(char *cp)
int i; int i;
i = x_size2(cp, NULL); i = x_size2(cp, NULL);
D("M");
while (i--) while (i--)
x_e_putc2('\b'); x_e_putc2('\b');
} }
@ -1967,10 +1938,8 @@ static int
x_size_str(char *cp) x_size_str(char *cp)
{ {
int size = 0; int size = 0;
D("C");
while (*cp) while (*cp)
size += x_size2(cp, &cp); size += x_size2(cp, &cp);
D("D");
return size; return size;
} }
@ -1995,20 +1964,9 @@ x_zots(char *str)
{ {
int adj = x_adj_done; int adj = x_adj_done;
D("E");
x_lastcp(); x_lastcp();
D("F"); while (*str && str < xlp && adj == x_adj_done)
if (!*str)
D("-");
if (adj != x_adj_done)
D("%d!%d", adj, x_adj_done);
if (str >= xlp)
D(" str=%td xlp=%td ", str-xbuf, xlp-xbuf);
while (*str && str < xlp && adj == x_adj_done) {
D("'");
x_zotc3(&str); x_zotc3(&str);
}
D("G");
} }
static void static void
@ -2210,14 +2168,10 @@ x_load_hist(char **hp)
xbp = xbuf; xbp = xbuf;
xep = xcp = xbuf + strlen(xbuf); xep = xcp = xbuf + strlen(xbuf);
xlp_valid = false; xlp_valid = false;
D("J");
if (xep <= x_lastcp()) { if (xep <= x_lastcp()) {
D("K %d ", oldsize);
x_redraw(oldsize); x_redraw(oldsize);
} }
D("L");
x_goto(xep); x_goto(xep);
D("M");
} }
static int static int
@ -2436,7 +2390,6 @@ x_redraw(int limit)
i = '<'; i = '<';
x_e_putc2(i); x_e_putc2(i);
j++; j++;
D("N");
while (j--) while (j--)
x_e_putc2('\b'); x_e_putc2('\b');
} }
@ -3020,7 +2973,6 @@ do_complete(int flags, /* XCF_{COMMAND,FILE,COMMAND_FILE} */
static void static void
x_adjust(void) x_adjust(void)
{ {
D(" x_adjust ");
x_adj_done++; /* flag the fact that we were called. */ x_adj_done++; /* flag the fact that we were called. */
/* /*
* we had a problem if the prompt length > xx_cols / 2 * we had a problem if the prompt length > xx_cols / 2
@ -3031,7 +2983,6 @@ x_adjust(void)
while ((xbp > xbuf) && ((*xbp & 0xC0) == 0x80)) while ((xbp > xbuf) && ((*xbp & 0xC0) == 0x80))
--xbp; --xbp;
xlp_valid = false; xlp_valid = false;
D("xbp=%td xcp=%td ", xbp-xbuf, xcp-xbuf);
x_redraw(xx_cols); x_redraw(xx_cols);
x_flush(); x_flush();
} }
@ -3069,9 +3020,7 @@ x_e_putc2(int c)
if (c == '\r' || c == '\n') if (c == '\r' || c == '\n')
x_col = 0; x_col = 0;
if (!x_col && (c == '\b')) if (x_col < xx_cols) {
D("O2 ");
if ((x_col < xx_cols) && (x_col || (c != '\b'))) {
if (Flag(FUTFHACK) && (c > 0x7F)) { if (Flag(FUTFHACK) && (c > 0x7F)) {
char utf_tmp[3]; char utf_tmp[3];
size_t x; size_t x;
@ -3101,7 +3050,6 @@ x_e_putc2(int c)
break; break;
} }
} }
D("\nx_e_putc:col=%d(%d) ", x_col, xx_cols - 2);
if (x_adj_ok && (x_col < 0 || x_col >= (xx_cols - 2))) if (x_adj_ok && (x_col < 0 || x_col >= (xx_cols - 2)))
x_adjust(); x_adjust();
} }
@ -3113,9 +3061,7 @@ x_e_putc3(const char **cp)
if (c == '\r' || c == '\n') if (c == '\r' || c == '\n')
x_col = 0; x_col = 0;
if (!x_col && (c == '\b')) if (x_col < xx_cols) {
D("O3 ");
if ((x_col < xx_cols) && (x_col || (c != '\b'))) {
if (Flag(FUTFHACK) && (c > 0x7F)) { if (Flag(FUTFHACK) && (c > 0x7F)) {
char *cp2; char *cp2;
@ -3140,7 +3086,6 @@ x_e_putc3(const char **cp)
break; break;
} }
} }
D("\nx_e_putc:col=%d(%d) ", x_col, xx_cols - 2);
if (x_adj_ok && (x_col < 0 || x_col >= (xx_cols - 2))) if (x_adj_ok && (x_col < 0 || x_col >= (xx_cols - 2)))
x_adjust(); x_adjust();
} }