Skip to content

Commit 87057d4

Browse files
committed
Fix incorrect tokenization of sequential delimited groups.
1 parent 3a46f95 commit 87057d4

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

source/tclie.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ static inline bool tclie_is_space(const char c)
121121
}
122122

123123
#if TCLIE_PATTERN_MATCH
124-
static bool tclie_pattern_compare(const char *target,
125-
size_t target_len,
124+
static bool tclie_pattern_compare(const char *target, size_t target_len,
126125
const char *subject)
127126
{
128127
assert(target);
@@ -180,6 +179,7 @@ static bool tclie_pattern_tokenize(const char *str, const size_t len,
180179
struct {
181180
bool active;
182181
int count;
182+
int total_count;
183183
tclie_token_delim_t delim;
184184
} delim = {0};
185185

@@ -208,6 +208,7 @@ static bool tclie_pattern_tokenize(const char *str, const size_t len,
208208
if (!delim.active && tclie_pattern_delim(*str, &delim.delim)) {
209209
delim.active = true;
210210
delim.count = 0;
211+
delim.total_count++;
211212
}
212213

213214
if (delim.active) {
@@ -235,7 +236,8 @@ static bool tclie_pattern_tokenize(const char *str, const size_t len,
235236
if (*count >= max_tokens)
236237
return false;
237238

238-
if (str_len >= 2 && tclie_pattern_delim(*start, &delim.delim) &&
239+
if (str_len >= 2 && delim.total_count == 1 &&
240+
tclie_pattern_delim(*start, &delim.delim) &&
239241
start[str_len - 1] == delim.delim.stop) {
240242
start++;
241243
str_len -= 2;

0 commit comments

Comments
 (0)