diff options
| author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2015-03-20 06:46:59 +0000 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2015-03-20 07:29:28 +0000 |
| commit | 288f80cb06b442ef0f55ea62bbceb3260338bf7a (patch) | |
| tree | 1f3c3a9193e6fcae98f8769a9a39d9cb96e54c94 /st.c | |
| parent | Merge remote-tracking branch 'origin/master' (diff) | |
| download | st-288f80cb06b442ef0f55ea62bbceb3260338bf7a.tar.gz st-288f80cb06b442ef0f55ea62bbceb3260338bf7a.zip | |
Remove strsep() call
strsep() is not a POSIX function, and it means that every system
needs different defines to expose it. If the prototype of strsep
is not exposed then an ugly int/pointer is done and it might mean
a crash. The best solution?, to remove the strsep and make a custom
loop. If C programmers cannot do this kind of loops without calling
a library function, then maybe we should move all the suckless
software to Java.
Diffstat (limited to '')
| -rw-r--r-- | st.c | 15 |
1 files changed, 13 insertions, 2 deletions
| @@ -2272,12 +2272,23 @@ strhandle(void) { | |||
| 2272 | 2272 | ||
| 2273 | void | 2273 | void |
| 2274 | strparse(void) { | 2274 | strparse(void) { |
| 2275 | int c; | ||
| 2275 | char *p = strescseq.buf; | 2276 | char *p = strescseq.buf; |
| 2276 | 2277 | ||
| 2277 | strescseq.narg = 0; | 2278 | strescseq.narg = 0; |
| 2278 | strescseq.buf[strescseq.len] = '\0'; | 2279 | strescseq.buf[strescseq.len] = '\0'; |
| 2279 | while(p && strescseq.narg < STR_ARG_SIZ) | 2280 | |
| 2280 | strescseq.args[strescseq.narg++] = strsep(&p, ";"); | 2281 | if(*p == '\0') |
| 2282 | return; | ||
| 2283 | |||
| 2284 | while(strescseq.narg < STR_ARG_SIZ) { | ||
| 2285 | strescseq.args[strescseq.narg++] = p; | ||
| 2286 | while((c = *p) != ';' && c != '\0') | ||
| 2287 | ++p; | ||
| 2288 | if(c == '\0') | ||
| 2289 | return; | ||
| 2290 | *p++ = '\0'; | ||
| 2291 | } | ||
| 2281 | } | 2292 | } |
| 2282 | 2293 | ||
| 2283 | void | 2294 | void |
