|
24 | 24 |
|
25 | 25 | #include "calendarspec.h" |
26 | 26 |
|
| 27 | +#define BITS_WEEKDAYS 127 |
| 28 | + |
27 | 29 | static void free_chain(CalendarComponent *c) { |
28 | 30 | CalendarComponent *n; |
29 | 31 |
|
@@ -120,7 +122,7 @@ static void fix_year(CalendarComponent *c) { |
120 | 122 | int calendar_spec_normalize(CalendarSpec *c) { |
121 | 123 | assert(c); |
122 | 124 |
|
123 | | - if (c->weekdays_bits <= 0 || c->weekdays_bits >= 127) |
| 125 | + if (c->weekdays_bits <= 0 || c->weekdays_bits >= BITS_WEEKDAYS) |
124 | 126 | c->weekdays_bits = -1; |
125 | 127 |
|
126 | 128 | fix_year(c->year); |
@@ -154,7 +156,7 @@ _pure_ static bool chain_valid(CalendarComponent *c, int from, int to) { |
154 | 156 | _pure_ bool calendar_spec_valid(CalendarSpec *c) { |
155 | 157 | assert(c); |
156 | 158 |
|
157 | | - if (c->weekdays_bits > 127) |
| 159 | + if (c->weekdays_bits > BITS_WEEKDAYS) |
158 | 160 | return false; |
159 | 161 |
|
160 | 162 | if (!chain_valid(c->year, 1970, 2199)) |
@@ -194,7 +196,7 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) { |
194 | 196 |
|
195 | 197 | assert(f); |
196 | 198 | assert(c); |
197 | | - assert(c->weekdays_bits > 0 && c->weekdays_bits <= 127); |
| 199 | + assert(c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS); |
198 | 200 |
|
199 | 201 | for (x = 0, l = -1; x < (int) ELEMENTSOF(days); x++) { |
200 | 202 |
|
@@ -259,7 +261,7 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) { |
259 | 261 | if (!f) |
260 | 262 | return -ENOMEM; |
261 | 263 |
|
262 | | - if (c->weekdays_bits > 0 && c->weekdays_bits <= 127) { |
| 264 | + if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) { |
263 | 265 | format_weekdays(f, c); |
264 | 266 | fputc(' ', f); |
265 | 267 | } |
@@ -880,7 +882,7 @@ static bool matches_weekday(int weekdays_bits, const struct tm *tm) { |
880 | 882 | struct tm t; |
881 | 883 | int k; |
882 | 884 |
|
883 | | - if (weekdays_bits < 0 || weekdays_bits >= 127) |
| 885 | + if (weekdays_bits < 0 || weekdays_bits >= BITS_WEEKDAYS) |
884 | 886 | return true; |
885 | 887 |
|
886 | 888 | t = *tm; |
|
0 commit comments