Browse Source

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.
master
Roberto E. Vargas Caballero 9 years ago
parent
commit
288f80cb06
2 changed files with 14 additions and 3 deletions
  1. +1
    -1
      config.mk
  2. +13
    -2
      st.c

+ 1
- 1
config.mk View File

@ -19,7 +19,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXext -lXft \
`pkg-config --libs freetype2` `pkg-config --libs freetype2`
# flags # flags
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600
CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS} CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS}
LDFLAGS += -g ${LIBS} LDFLAGS += -g ${LIBS}


+ 13
- 2
st.c View File

@ -2272,12 +2272,23 @@ strhandle(void) {
void void
strparse(void) { strparse(void) {
int c;
char *p = strescseq.buf; char *p = strescseq.buf;
strescseq.narg = 0; strescseq.narg = 0;
strescseq.buf[strescseq.len] = '\0'; strescseq.buf[strescseq.len] = '\0';
while(p && strescseq.narg < STR_ARG_SIZ)
strescseq.args[strescseq.narg++] = strsep(&p, ";");
if(*p == '\0')
return;
while(strescseq.narg < STR_ARG_SIZ) {
strescseq.args[strescseq.narg++] = p;
while((c = *p) != ';' && c != '\0')
++p;
if(c == '\0')
return;
*p++ = '\0';
}
} }
void void


Loading…
Cancel
Save