diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-04-02 16:22:57 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-04-02 16:22:57 +0200 |
commit | 85d7b857fb8ca8e3c03d4abb3368a0966760630c (patch) | |
tree | a16163e557bcae3af41bde7d2d771d64ca248a97 /protocols/yahoo/yahoo_util.c | |
parent | 875ad4201402b1a8f80ba22a6cdcdb152c6e5510 (diff) | |
parent | dd345753c1742905c9f81aa71d8b09109fbc5456 (diff) |
Merge trunk.
Diffstat (limited to 'protocols/yahoo/yahoo_util.c')
-rw-r--r-- | protocols/yahoo/yahoo_util.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/protocols/yahoo/yahoo_util.c b/protocols/yahoo/yahoo_util.c index 7babfa49..5375205f 100644 --- a/protocols/yahoo/yahoo_util.c +++ b/protocols/yahoo/yahoo_util.c @@ -68,13 +68,15 @@ char ** y_strsplit(char * str, char * sep, int nelem) char *s, *p; int i=0; int l = strlen(sep); - if(nelem < 0) { + if(nelem <= 0) { char * s; nelem=0; - for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++) - ; - if(strcmp(str+strlen(str)-l, sep)) - nelem++; + if (*str) { + for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++) + ; + if(strcmp(str+strlen(str)-l, sep)) + nelem++; + } } vector = y_new(char *, nelem + 1); @@ -86,7 +88,7 @@ char ** y_strsplit(char * str, char * sep, int nelem) vector[i][len] = '\0'; } - if(i<nelem) /* str didn't end with sep */ + if(i<nelem && *str) /* str didn't end with sep, and str isn't empty */ vector[i++] = strdup(p); vector[i] = NULL; |