]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/calendarspec.c
tree-wide: sort includes
[thirdparty/systemd.git] / src / basic / calendarspec.c
index a2296f4709b2573ee09f0930e92b4481757ee256..157ae1fb74b327000f68c7d42357e1f5acdfad88 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#include "alloc-util.h"
 #include "calendarspec.h"
+#include "fileio.h"
+#include "string-util.h"
 
 #define BITS_WEEKDAYS   127
 
@@ -559,7 +562,7 @@ static int parse_date(const char **p, CalendarSpec *c) {
         return -EINVAL;
 }
 
-static int parse_time(const char **p, CalendarSpec *c) {
+static int parse_calendar_time(const char **p, CalendarSpec *c) {
         CalendarComponent *h = NULL, *m = NULL, *s = NULL;
         const char *t;
         int r;
@@ -649,6 +652,7 @@ fail:
 int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
         CalendarSpec *c;
         int r;
+        const char *utc;
 
         assert(p);
         assert(spec);
@@ -660,9 +664,11 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
         if (!c)
                 return -ENOMEM;
 
-        c->utc = endswith_no_case(p, "UTC");
-        if (c->utc)
-                p = strndupa(p, strlen(p) - strlen(" UTC"));
+        utc = endswith_no_case(p, " UTC");
+        if (utc) {
+                c->utc = true;
+                p = strndupa(p, utc - p);
+        }
 
         if (strcaseeq(p, "minutely")) {
                 r = const_chain(0, &c->second);
@@ -796,7 +802,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
                 if (r < 0)
                         goto fail;
 
-                r = parse_time(&p, c);
+                r = parse_calendar_time(&p, c);
                 if (r < 0)
                         goto fail;