[dev] [st][PATCH 3/4] Remove duplicated code in strhandle

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Sun, 2 Feb 2014 19:57:43 +0100

The error condition was duplicated in two different switches.
This new version centralized the error handling in only one place.

Signed-off-by: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
---
 st.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/st.c b/st.c
index 21afb52..c59bf1d 100644
--- a/st.c
+++ b/st.c
_AT_@ -2152,20 +2152,21 @@ csireset(void) {
 void
 strhandle(void) {
 	char *p = NULL;
-	int i, j, narg;
+	int j, narg, par;
 
 	strparse();
 	narg = strescseq.narg;
+	par = atoi(strescseq.args[0]);
 
 	switch(strescseq.type) {
 	case ']': /* OSC -- Operating System Command */
-		switch(i = atoi(strescseq.args[0])) {
+		switch(par) {
 		case 0:
 		case 1:
 		case 2:
 			if(narg > 1)
 				xsettitle(strescseq.args[1]);
-			break;
+			return;
 		case 4: /* color set */
 			if(narg < 3)
 				break;
_AT_@ -2182,25 +2183,20 @@ strhandle(void) {
 				 */
 				redraw(0);
 			}
-			break;
-		default:
-			fprintf(stderr, "erresc: unknown str ");
-			strdump();
-			break;
+			return;
 		}
 		break;
 	case 'k': /* old title set compatibility */
 		xsettitle(strescseq.args[0]);
-		break;
+		return;
 	case 'P': /* DSC -- Device Control String */
 	case '_': /* APC -- Application Program Command */
 	case '^': /* PM -- Privacy Message */
-	default:
-		fprintf(stderr, "erresc: unknown str ");
-		strdump();
-		/* die(""); */
-		break;
+		return;
 	}
+
+	fprintf(stderr, "erresc: unknown str ");
+	strdump();
 }
 
 void
-- 
1.8.5.3
Received on Sun Feb 02 2014 - 19:57:43 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 02 2014 - 20:00:29 CET