diff options
author | Christoph Lohmann <20h@r-36.net> | 2013-02-23 21:17:25 +0100 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2013-02-23 21:17:25 +0100 |
commit | 1b6c6535c10172facb350f4b8fef442f7f8ddc5a (patch) | |
tree | 47384df50fff44857b62fb6e41321f04ae6b421b | |
parent | 800800a3bba020f1e71e821b31c1ad037aab64ee (diff) | |
download | st-1b6c6535c10172facb350f4b8fef442f7f8ddc5a.tar.gz st-1b6c6535c10172facb350f4b8fef442f7f8ddc5a.tar.bz2 |
Replace parse_int with atoi().
-rw-r--r-- | st.c | 31 |
1 files changed, 8 insertions, 23 deletions
@@ -302,7 +302,6 @@ static void execsh(void); static void sigchld(int); static void run(void); -static inline int parse_int(char *); static void csidump(void); static void csihandle(void); static void csiparse(void); @@ -941,7 +940,7 @@ brelease(XEvent *e) { void bmotion(XEvent *e) { - int oldey, oldex; + int oldey, oldex, oldsby, oldsey; if(IS_SET(MODE_MOUSE)) { mousereport(e); @@ -953,10 +952,12 @@ bmotion(XEvent *e) { oldey = sel.ey; oldex = sel.ex; + oldsby = sel.b.y; + oldsey = sel.e.y; getbuttoninfo(e); if(oldey != sel.ey || oldex != sel.ex) { - tsetdirt(sel.b.y, sel.e.y); + tsetdirt(MIN(sel.b.y, oldsby), MAX(sel.e.y, oldsey)); } } @@ -1857,22 +1858,6 @@ csireset(void) { memset(&csiescseq, 0, sizeof(csiescseq)); } -inline int -parse_int(char *s) { - int x = 0; - char c; - while(isdigit(c = *s)) { - if((INT_MAX - c + '0') / 10 >= x) { - x = x * 10 + c - '0'; - } else - return -1; - s++; - } - if(*s != '\0') - return -1; - return x; -} - void strhandle(void) { char *p = NULL; @@ -1887,7 +1872,7 @@ strhandle(void) { switch(strescseq.type) { case ']': /* OSC -- Operating System Command */ - switch(i = parse_int(strescseq.args[0])) { + switch(i = atoi(strescseq.args[0])) { case 0: case 1: case 2: @@ -1903,10 +1888,10 @@ strhandle(void) { p = strescseq.args[2]; /* fall through */ case 104: /* color reset, here p = NULL */ - j = (narg > 1) ? parse_int(strescseq.args[1]) : -1; - if (!xsetcolorname(j, p)) + j = (narg > 1) ? atoi(strescseq.args[1]) : -1; + if (!xsetcolorname(j, p)) { fprintf(stderr, "erresc: invalid color %s\n", p); - else { + } else { redraw(0); /* TODO if defaultbg color is changed, borders are dirty */ } break; |