aboutsummaryrefslogtreecommitdiff
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
parent21d905c076735783b41eec55f31d933129fd9f22 (diff)
downloadst-patched-a8d5870073af14aa08032ab8520c5fe17bb8a1e8.tar.bz2
st-patched-a8d5870073af14aa08032ab8520c5fe17bb8a1e8.tar.xz
st-patched-a8d5870073af14aa08032ab8520c5fe17bb8a1e8.zip
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.
-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) {
2152void 2152void
2153strhandle(void) { 2153strhandle(void) {
2154 char *p = NULL; 2154 char *p = NULL;
2155 int i, j, narg; 2155 int j, narg, par;
2156 2156
2157 strparse(); 2157 strparse();
2158 narg = strescseq.narg; 2158 narg = strescseq.narg;
2159 par = atoi(strescseq.args[0]);
2159 2160
2160 switch(strescseq.type) { 2161 switch(strescseq.type) {
2161 case ']': /* OSC -- Operating System Command */ 2162 case ']': /* OSC -- Operating System Command */
2162 switch(i = atoi(strescseq.args[0])) { 2163 switch(par) {
2163 case 0: 2164 case 0:
2164 case 1: 2165 case 1:
2165 case 2: 2166 case 2:
2166 if(narg > 1) 2167 if(narg > 1)
2167 xsettitle(strescseq.args[1]); 2168 xsettitle(strescseq.args[1]);
2168 break; 2169 return;
2169 case 4: /* color set */ 2170 case 4: /* color set */
2170 if(narg < 3) 2171 if(narg < 3)
2171 break; 2172 break;
@@ -2182,25 +2183,20 @@ strhandle(void) {
2182 */ 2183 */
2183 redraw(0); 2184 redraw(0);
2184 } 2185 }
2185 break; 2186 return;
2186 default:
2187 fprintf(stderr, "erresc: unknown str ");
2188 strdump();
2189 break;
2190 } 2187 }
2191 break; 2188 break;
2192 case 'k': /* old title set compatibility */ 2189 case 'k': /* old title set compatibility */
2193 xsettitle(strescseq.args[0]); 2190 xsettitle(strescseq.args[0]);
2194 break; 2191 return;
2195 case 'P': /* DSC -- Device Control String */ 2192 case 'P': /* DSC -- Device Control String */
2196 case '_': /* APC -- Application Program Command */ 2193 case '_': /* APC -- Application Program Command */
2197 case '^': /* PM -- Privacy Message */ 2194 case '^': /* PM -- Privacy Message */
2198 default: 2195 return;
2199 fprintf(stderr, "erresc: unknown str ");
2200 strdump();
2201 /* die(""); */
2202 break;
2203 } 2196 }
2197
2198 fprintf(stderr, "erresc: unknown str ");
2199 strdump();
2204} 2200}
2205 2201
2206void 2202void