2
0
Fork 0

[core] Fix pattern range parser, fix docroot_nth callback

personal/stbuehler/wip
Stefan Bühler 2010-10-05 14:37:33 +02:00
parent 9b554dc931
commit 01f0c1606f
2 changed files with 7 additions and 3 deletions

View File

@ -50,6 +50,7 @@ static gboolean parse_range(liServer *srv, liPatternPart *part, const gchar **st
return FALSE;
}
part->data.range.from = val;
c = endc;
}
part->data.range.to = part->data.range.from;
@ -69,6 +70,7 @@ static gboolean parse_range(liServer *srv, liPatternPart *part, const gchar **st
return FALSE;
}
part->data.range.to = val;
c = endc;
}
}

View File

@ -180,21 +180,23 @@ static void core_docroot_nth_cb(GString *pattern_result, guint to, guint from, g
if (0 == ctx->split_len) return;
from = MAX(from, ctx->split_len);
to = MAX(to, ctx->split_len);
from = MIN(from, ctx->split_len);
to = MIN(to, ctx->split_len);
if (from <= to) {
for (i = from; i <= to; i++) {
if (first) {
first = FALSE;
} else {
g_string_append_len(pattern_result, CONST_STR_LEN("."));
}
g_string_append(pattern_result, ctx->splits[ctx->split_len - i]);
}
} else {
for (i = from+1; i-- >= to; ) {
for (i = from; i >= to; i--) { /* to > 0, so no underflow in i possible */
if (first) {
first = FALSE;
} else {
g_string_append_len(pattern_result, CONST_STR_LEN("."));
}
g_string_append(pattern_result, ctx->splits[ctx->split_len - i]);