41 lines
1.1 KiB
Diff
41 lines
1.1 KiB
Diff
|
Based on e73c78c27511b03c7abc55aed87896092c0de699 Mon Sep 17 00:00:00 2001
|
||
|
From: Lennart Poettering <lennart@poettering.net>
|
||
|
Date: Fri, 24 Oct 2014 19:07:26 +0200
|
||
|
Subject: [PATCH] time: also support 'infinity' syntax in parse_nsec()
|
||
|
|
||
|
Let's make parse_usec() and parse_nsec() work similar
|
||
|
---
|
||
|
src/shared/time-util.c | 14 +++++++++++++-
|
||
|
1 file changed, 13 insertions(+), 1 deletion(-)
|
||
|
|
||
|
--- src/shared/time-util.c
|
||
|
+++ src/shared/time-util.c
|
||
|
@@ -773,7 +773,7 @@ int parse_nsec(const char *t, nsec_t *nsec) {
|
||
|
{ "", 1ULL }, /* default is nsec */
|
||
|
};
|
||
|
|
||
|
- const char *p;
|
||
|
+ const char *p, *s;
|
||
|
nsec_t r = 0;
|
||
|
bool something = false;
|
||
|
|
||
|
@@ -781,6 +781,18 @@ int parse_nsec(const char *t, nsec_t *nsec) {
|
||
|
assert(nsec);
|
||
|
|
||
|
p = t;
|
||
|
+
|
||
|
+ p += strspn(p, WHITESPACE);
|
||
|
+ s = startswith(p, "infinity");
|
||
|
+ if (s) {
|
||
|
+ s += strspn(s, WHITESPACE);
|
||
|
+ if (!*s != 0)
|
||
|
+ return -EINVAL;
|
||
|
+
|
||
|
+ *nsec = ((nsec_t) -1);
|
||
|
+ return 0;
|
||
|
+ }
|
||
|
+
|
||
|
for (;;) {
|
||
|
long long l, z = 0;
|
||
|
char *e;
|