+ Fixes
[opsoft.git] / silentbob / gclib / src / deprecated_dsplit.cxx
blobe4501dd1aa363bc92e06402d1e50615f97902237
1 /*
2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
5 */
7 #include <gclib/gclib.h>
8 #include <gclib/gclib_c.h>
10 /* 2005 */
11 __export DArray * Dsplit (char * STR, char *ch)
13 DArray * ret = new DArray(128);
14 char * S;
15 char * buf = strdup (STR);
16 char * ptr = buf;
17 int ch_len;
19 if (buf == NULL)
20 return NULL;
22 if (!STR || !ch) {
23 delete ret;
24 return NULL;
27 ch_len = strlen (ch);
28 while((S = strstr (ptr, ch)) && S) {
29 *S = 0;
30 S += ch_len;
31 ret->add (strdup (ptr));
32 ptr = S;
35 if (strlen (ptr))
36 ret->add (strdup (ptr));
38 free (buf);
39 return ret;