Module Name:    src
Committed By:   christos
Date:           Fri Jul 17 12:28:27 UTC 2009

Modified Files:
        src/lib/libedit: refresh.c

Log Message:
Simplify the code. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libedit/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libedit/refresh.c
diff -u src/lib/libedit/refresh.c:1.31 src/lib/libedit/refresh.c:1.32
--- src/lib/libedit/refresh.c:1.31	Tue May 19 17:45:14 2009
+++ src/lib/libedit/refresh.c	Fri Jul 17 08:28:27 2009
@@ -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 @@
 	/* 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++;
 		}
 	}

Reply via email to