Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions src/nxt_time_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ nxt_term_parse(const u_char *p, size_t len, nxt_bool_t seconds)
enum {
st_first_digit = 0,
st_digit,
st_letter,
st_space,
} state;

Expand Down Expand Up @@ -354,22 +353,17 @@ nxt_term_parse(const u_char *p, size_t len, nxt_bool_t seconds)
state = st_first_digit;
}

if (state != st_letter) {
/* Values below '0' become >= 208. */
c = ch - '0';

/* Values below '0' become >= 208. */
c = ch - '0';

if (c <= 9) {
val = val * 10 + c;
state = st_digit;
continue;
}

if (state == st_first_digit) {
return -1;
}
if (c <= 9) {
val = val * 10 + c;
state = st_digit;
continue;
}

state = st_letter;
if (state == st_first_digit) {
return -1;
}

switch (ch) {
Expand Down
1 change: 1 addition & 0 deletions src/test/nxt_term_parse_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static const nxt_term_parse_test_t terms[] = {
{ nxt_string("1w d"), 0, -1 },
{ nxt_string("w"), 0, -1 },
{ nxt_string("1d 1w"), 0, -1 },
{ nxt_string("1 "), 1, 1 },
{ nxt_string("25d"), 0, -2 },
{ nxt_string("300"), 1, 300 },
{ nxt_string("300"), 0, 300000 },
Expand Down