1
#ifndef NALL_STRING_SPLIT_HPP
2
#define NALL_STRING_SPLIT_HPP
6
void lstring::split(const char *key, const char *src, unsigned limit) {
9
int ssl = strlen(src), ksl = strlen(key);
10
int lp = 0, split_count = 0;
12
for(int i = 0; i <= ssl - ksl;) {
13
if(!memcmp(src + i, key, ksl)) {
14
strlcpy(operator[](split_count++), src + lp, i - lp + 1);
21
operator[](split_count++) = src + lp;
24
void lstring::qsplit(const char *key, const char *src, unsigned limit) {
27
int ssl = strlen(src), ksl = strlen(key);
28
int lp = 0, split_count = 0;
30
for(int i = 0; i <= ssl - ksl;) {
33
if(x == '\"' || x == '\'') {
34
int z = i++; //skip opening quote
35
while(i < ssl && src[i] != x) i++;
36
if(i >= ssl) i = z; //failed match, rewind i
38
i++; //skip closing quote
39
continue; //restart in case next char is also a quote
43
if(!memcmp(src + i, key, ksl)) {
44
strlcpy(operator[](split_count++), src + lp, i - lp + 1);
51
operator[](split_count++) = src + lp;