mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
Merge pull request #32318 from YHNdnzj/skip-leading-char
journal-gatewayd: use skip_leading_chars
This commit is contained in:
@@ -133,7 +133,7 @@ static inline char *truncate_nl(char *s) {
|
||||
return truncate_nl_full(s, NULL);
|
||||
}
|
||||
|
||||
static inline char *skip_leading_chars(const char *s, const char *bad) {
|
||||
static inline char* skip_leading_chars(const char *s, const char *bad) {
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -348,6 +348,9 @@ static int request_parse_range_entries(
|
||||
const char *colon;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(entries_request);
|
||||
|
||||
colon = strchr(entries_request, ':');
|
||||
if (!colon)
|
||||
m->cursor = strdup(entries_request);
|
||||
@@ -376,6 +379,9 @@ static int request_parse_range_time(
|
||||
const char *colon;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(time_request);
|
||||
|
||||
colon = strchr(time_request, ':');
|
||||
if (!colon)
|
||||
return -EINVAL;
|
||||
@@ -440,17 +446,14 @@ static int request_parse_range(
|
||||
return -EINVAL;
|
||||
|
||||
m->n_skip = 0;
|
||||
|
||||
range_after_eq = startswith(range, "entries=");
|
||||
if (range_after_eq) {
|
||||
range_after_eq += strspn(range_after_eq, WHITESPACE);
|
||||
return request_parse_range_entries(m, range_after_eq);
|
||||
}
|
||||
if (range_after_eq)
|
||||
return request_parse_range_entries(m, skip_leading_chars(range_after_eq, /* bad = */ NULL));
|
||||
|
||||
range_after_eq = startswith(range, "realtime=");
|
||||
if (range_after_eq) {
|
||||
range_after_eq += strspn(range_after_eq, WHITESPACE);
|
||||
return request_parse_range_time(m, range_after_eq);
|
||||
}
|
||||
if (range_after_eq)
|
||||
return request_parse_range_time(m, skip_leading_chars(range_after_eq, /* bad = */ NULL));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user