]> git.netwichtig.de Git - user/henk/code/snooze.git/blobdiff - snooze.c
sv: include runit service files to run cron drop-in scripts
[user/henk/code/snooze.git] / snooze.c
index 283a795fb1507b77d72e2fe28ca8cacad5ff343f..8bbd93fb366b35437a7fa0aef6cf0610e725074b 100644 (file)
--- a/snooze.c
+++ b/snooze.c
@@ -99,7 +99,7 @@ parse(char *expr, char *buf, long bufsiz, int offset)
        while (*s) {
                switch (*s) {
                case '0': case '1': case '2': case '3': case '4':
-                case '5': case '6': case '7': case '8': case '9':
+               case '5': case '6': case '7': case '8': case '9':
                        n = parse_int(&s, -offset, bufsiz);
                        buf[n+offset] = '*';
                        break;
@@ -140,8 +140,8 @@ parse(char *expr, char *buf, long bufsiz, int offset)
 }
 
 char weekday[8] = {0};
-char dayofmonth[31] = {0};
-char month[12] = {0};
+char dayofmonth[32] = {0};
+char month[13] = {0};
 char dayofyear[367] = {0};
 char weekofyear[54] = {0};
 char hour[24] = {0};
@@ -182,11 +182,14 @@ next_day:
                        tm->tm_mday++;
                }
 
+               tm->tm_isdst = -1;
                tm->tm_sec = 0;
                tm->tm_min = 0;
                tm->tm_hour = 0;
 
                t = mktime(tm);
+               tm->tm_isdst = -1;
+
                if (t > from+(366*24*60*60))  // no result within a year
                        return -1;
        }
@@ -241,6 +244,8 @@ main(int argc, char *argv[])
        minute[0] = '*';
        second[0] = '*';
 
+       setvbuf(stdout, 0, _IOLBF, 0);
+
        while ((c = getopt(argc, argv, "+D:W:H:M:S:T:R:d:m:ns:t:vw:")) != -1)
                switch (c) {
                case 'D': parse(optarg, dayofyear, sizeof dayofyear, -1); break;
@@ -252,7 +257,7 @@ main(int argc, char *argv[])
                case 'm': parse(optarg, month, sizeof month, -1); break;
                case 'w': parse(optarg, weekday, sizeof weekday, 0);
                        // special case: sunday is both 0 and 7.
-                       if (weekday[7] == '*') 
+                       if (weekday[7] == '*')
                                weekday[0] = '*';
                        break;
                case 'n': nflag++; break;