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.zip | |
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); | |||
| 302 | static void sigchld(int); | 302 | static void sigchld(int); |
| 303 | static void run(void); | 303 | static void run(void); |
| 304 | 304 | ||
| 305 | static inline int parse_int(char *); | ||
| 306 | static void csidump(void); | 305 | static void csidump(void); |
| 307 | static void csihandle(void); | 306 | static void csihandle(void); |
| 308 | static void csiparse(void); | 307 | static void csiparse(void); |
| @@ -941,7 +940,7 @@ brelease(XEvent *e) { | |||
| 941 | 940 | ||
| 942 | void | 941 | void |
| 943 | bmotion(XEvent *e) { | 942 | bmotion(XEvent *e) { |
| 944 | int oldey, oldex; | 943 | int oldey, oldex, oldsby, oldsey; |
| 945 | 944 | ||
| 946 | if(IS_SET(MODE_MOUSE)) { | 945 | if(IS_SET(MODE_MOUSE)) { |
| 947 | mousereport(e); | 946 | mousereport(e); |
| @@ -953,10 +952,12 @@ bmotion(XEvent *e) { | |||
| 953 | 952 | ||
| 954 | oldey = sel.ey; | 953 | oldey = sel.ey; |
| 955 | oldex = sel.ex; | 954 | oldex = sel.ex; |
| 955 | oldsby = sel.b.y; | ||
| 956 | oldsey = sel.e.y; | ||
| 956 | getbuttoninfo(e); | 957 | getbuttoninfo(e); |
| 957 | 958 | ||
| 958 | if(oldey != sel.ey || oldex != sel.ex) { | 959 | if(oldey != sel.ey || oldex != sel.ex) { |
| 959 | tsetdirt(sel.b.y, sel.e.y); | 960 | tsetdirt(MIN(sel.b.y, oldsby), MAX(sel.e.y, oldsey)); |
| 960 | } | 961 | } |
| 961 | } | 962 | } |
| 962 | 963 | ||
| @@ -1857,22 +1858,6 @@ csireset(void) { | |||
| 1857 | memset(&csiescseq, 0, sizeof(csiescseq)); | 1858 | memset(&csiescseq, 0, sizeof(csiescseq)); |
| 1858 | } | 1859 | } |
| 1859 | 1860 | ||
| 1860 | inline int | ||
| 1861 | parse_int(char *s) { | ||
| 1862 | int x = 0; | ||
| 1863 | char c; | ||
| 1864 | while(isdigit(c = *s)) { | ||
| 1865 | if((INT_MAX - c + '0') / 10 >= x) { | ||
| 1866 | x = x * 10 + c - '0'; | ||
| 1867 | } else | ||
| 1868 | return -1; | ||
| 1869 | s++; | ||
| 1870 | } | ||
| 1871 | if(*s != '\0') | ||
| 1872 | return -1; | ||
| 1873 | return x; | ||
| 1874 | } | ||
| 1875 | |||
| 1876 | void | 1861 | void |
| 1877 | strhandle(void) { | 1862 | strhandle(void) { |
| 1878 | char *p = NULL; | 1863 | char *p = NULL; |
| @@ -1887,7 +1872,7 @@ strhandle(void) { | |||
| 1887 | 1872 | ||
| 1888 | switch(strescseq.type) { | 1873 | switch(strescseq.type) { |
| 1889 | case ']': /* OSC -- Operating System Command */ | 1874 | case ']': /* OSC -- Operating System Command */ |
| 1890 | switch(i = parse_int(strescseq.args[0])) { | 1875 | switch(i = atoi(strescseq.args[0])) { |
| 1891 | case 0: | 1876 | case 0: |
| 1892 | case 1: | 1877 | case 1: |
| 1893 | case 2: | 1878 | case 2: |
| @@ -1903,10 +1888,10 @@ strhandle(void) { | |||
| 1903 | p = strescseq.args[2]; | 1888 | p = strescseq.args[2]; |
| 1904 | /* fall through */ | 1889 | /* fall through */ |
| 1905 | case 104: /* color reset, here p = NULL */ | 1890 | case 104: /* color reset, here p = NULL */ |
| 1906 | j = (narg > 1) ? parse_int(strescseq.args[1]) : -1; | 1891 | j = (narg > 1) ? atoi(strescseq.args[1]) : -1; |
| 1907 | if (!xsetcolorname(j, p)) | 1892 | if (!xsetcolorname(j, p)) { |
| 1908 | fprintf(stderr, "erresc: invalid color %s\n", p); | 1893 | fprintf(stderr, "erresc: invalid color %s\n", p); |
| 1909 | else { | 1894 | } else { |
| 1910 | redraw(0); /* TODO if defaultbg color is changed, borders are dirty */ | 1895 | redraw(0); /* TODO if defaultbg color is changed, borders are dirty */ |
| 1911 | } | 1896 | } |
| 1912 | break; | 1897 | break; |
