diff options
| author | christos <christos@NetBSD.org> | 2009-07-17 12:28:27 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2009-07-17 12:28:27 +0000 |
| commit | cfb4e5f91797d28eb2a5c8d6419d53aa8710d803 (patch) | |
| tree | d01989047cd95fbb30b47120bdf72629e40f9cd2 /lib/libedit | |
| parent | e2d0108bb831bf2ab2805be364d89ba9313b8aa7 (diff) | |
Simplify the code. No functional change.
Diffstat (limited to 'lib/libedit')
| -rw-r--r-- | lib/libedit/refresh.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c index 4989261e179..baf587a33aa 100644 --- a/lib/libedit/refresh.c +++ b/lib/libedit/refresh.c @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.31 2009/05/19 21:45:14 christos Exp $ */ +/* $NetBSD: refresh.c,v 1.32 2009/07/17 12:28:27 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: refresh.c,v 1.31 2009/05/19 21:45:14 christos Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.32 2009/07/17 12:28:27 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -992,34 +992,28 @@ re_refresh_cursor(EditLine *el) /* do input buffer to el->el_line.cursor */ for (cp = el->el_line.buffer; cp < el->el_line.cursor; cp++) { c = *cp; - h++; /* all chars at least this long */ - if (c == '\n') {/* handle newline in data part too */ + switch (c) { + case '\n': /* handle newline in data part too */ h = 0; v++; - } else { - if (c == '\t') { /* if a tab, to next tab stop */ - while (h & 07) { - h++; - } - } else if (iscntrl((unsigned char) c)) { - /* if control char */ + break; + case '\t': /* if a tab, to next tab stop */ + while (++h & 07) + continue; + break; + default: + if (iscntrl((unsigned char) c)) + h += 2; /* ^x */ + else if (!isprint((unsigned char) c)) + h += 4; /* octal \xxx */ + else h++; - if (h > th) { /* if overflow, compensate */ - h = 1; - v++; - } - } else if (!isprint((unsigned char) c)) { - h += 3; - if (h > th) { /* if overflow, compensate */ - h = h - th; - v++; - } - } + break; } if (h >= th) { /* check, extra long tabs picked up here also */ - h = 0; + h -= th; v++; } } |
