str_split is unused
This commit is contained in:
parent
85001c6327
commit
02b4008a69
3 changed files with 1 additions and 50 deletions
|
@ -24,8 +24,6 @@ char * inside_slug(char * needle, int needle_len, char *offset);
|
|||
|
||||
char * ltrim_slash(char* str);
|
||||
|
||||
char** str_split(char* a_str, const char a_delim);
|
||||
|
||||
void str_repeat(char *s, char *c, int len);
|
||||
|
||||
void print_indent(int level);
|
||||
|
|
48
src/str.c
48
src/str.c
|
@ -174,54 +174,6 @@ char * ltrim_slash(char* str)
|
|||
return strdup(p);
|
||||
}
|
||||
|
||||
char** str_split(char* a_str, const char a_delim)
|
||||
{
|
||||
char** result = 0;
|
||||
size_t count = 0;
|
||||
char* tmp = a_str;
|
||||
char* last_comma = 0;
|
||||
char delim[2];
|
||||
delim[0] = a_delim;
|
||||
delim[1] = 0;
|
||||
|
||||
/* Count how many elements will be extracted. */
|
||||
while (*tmp)
|
||||
{
|
||||
if (a_delim == *tmp)
|
||||
{
|
||||
count++;
|
||||
last_comma = tmp;
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
|
||||
/* Add space for trailing token. */
|
||||
count += last_comma < (a_str + strlen(a_str) - 1);
|
||||
|
||||
/* Add space for terminating null string so caller
|
||||
knows where the list of returned strings ends. */
|
||||
count++;
|
||||
|
||||
result = malloc(sizeof(char*) * count);
|
||||
|
||||
if (result)
|
||||
{
|
||||
size_t idx = 0;
|
||||
char* token = strtok(a_str, delim);
|
||||
|
||||
while (token)
|
||||
{
|
||||
assert(idx < count);
|
||||
*(result + idx++) = strdup(token);
|
||||
token = strtok(0, delim);
|
||||
}
|
||||
assert(idx == count - 1);
|
||||
*(result + idx) = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void str_repeat(char *s, char *c, int len) {
|
||||
while(len--) {
|
||||
s[len - 1] = *c;
|
||||
|
|
|
@ -386,3 +386,4 @@
|
|||
1400593219,13704926.07
|
||||
1400599508,13991454.07
|
||||
1400599553,13826120.84
|
||||
1400599756,12099437.82
|
||||
|
|
|
Loading…
Reference in a new issue