summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-10-24 19:07:26 +0200
committerLennart Poettering <lennart@poettering.net>2014-10-24 19:07:31 +0200
commite73c78c27511b03c7abc55aed87896092c0de699 (patch)
tree0c6b88d96e591ca5bac64b9436d34958e222a5fe /src
parentafe3ab588a6b2992efe5a9b22ed038545ba3cdbf (diff)
time: also support 'infinity' syntax in parse_nsec()
Let's make parse_usec() and parse_nsec() work similar
Diffstat (limited to 'src')
-rw-r--r--src/shared/time-util.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index 433c262dfa..4d34362bce 100644
--- a/src/shared/time-util.c
+++ b/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_INFINITY;
+ return 0;
+ }
+
for (;;) {
long long l, z = 0;
char *e;