aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2014-01-31 17:04:18 +0100
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-02-02 19:42:01 +0100
commita8d5870073af14aa08032ab8520c5fe17bb8a1e8 (patch)
tree2049ab201b85e13af9e9d9e2092175732f359d9c /st.c
parent21d905c076735783b41eec55f31d933129fd9f22 (diff)
downloadst-a8d5870073af14aa08032ab8520c5fe17bb8a1e8.tar.gz
st-a8d5870073af14aa08032ab8520c5fe17bb8a1e8.tar.bz2
Remove duplicated code in strhandle
The error condition was duplicated in two different switches. This new version centralized the error handling in only one place.
Diffstat (limited to 'st.c')
-rw-r--r--st.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/st.c b/st.c
index 21afb52..c59bf1d 100644
--- a/st.c
+++ b/st.c
@@ -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;
@@ -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