Fixed time parsing in shutdown when there is a + in front of a 0 time offset.
Commands with a postiive time offset (+1) would work but +0 fails. This has been corrected by Arkadiusz Miskiewicz.
This commit is contained in:
parent
7ca2d2413f
commit
462a92ce2a
@ -777,16 +777,18 @@ int main(int argc, char **argv)
|
|||||||
if (!strcmp(when, "now")) strcpy(when, "0");
|
if (!strcmp(when, "now")) strcpy(when, "0");
|
||||||
|
|
||||||
sp = when;
|
sp = when;
|
||||||
if (when[0] == '+') sp++;
|
/* Validate time argument. */
|
||||||
/* Decode shutdown time. */
|
|
||||||
for ( ; *sp; sp++) {
|
for ( ; *sp; sp++) {
|
||||||
if (*sp != ':' && (*sp < '0' || *sp > '9'))
|
if (*sp != '+' && *sp != ':' && (*sp < '0' || *sp > '9'))
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
sp = when;
|
||||||
|
/* Decode shutdown time. */
|
||||||
|
if (when[0] == '+') sp++;
|
||||||
if (strchr(when, ':') == NULL) {
|
if (strchr(when, ':') == NULL) {
|
||||||
/* Time in minutes. */
|
/* Time in minutes. */
|
||||||
wt = atoi(when);
|
wt = atoi(sp);
|
||||||
if (wt == 0 && when[0] != '0') usage();
|
if (wt == 0 && sp[0] != '0') usage();
|
||||||
} else {
|
} else {
|
||||||
if (sscanf(when, "%d:%2d", &hours, &mins) != 2) usage();
|
if (sscanf(when, "%d:%2d", &hours, &mins) != 2) usage();
|
||||||
/* Time in hh:mm format. */
|
/* Time in hh:mm format. */
|
||||||
|
Loading…
Reference in New Issue
Block a user