Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
exander77 committed Sep 7, 2023
1 parent 11d304b commit 534ad99
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (MSVC)
target_compile_definitions(ccronexpr PRIVATE _CRT_SECURE_NO_WARNINGS)
else ()
# Strict compilation
target_compile_options(ccronexpr PRIVATE -ansi -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wcast-qual -Wconversion -pedantic-errors)
target_compile_options(ccronexpr PRIVATE -ansi -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wcast-qual -Wconversion -Wno-unused-parameter -pedantic-errors)
endif ()

# Tests
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ifeq ($(strip $(UNCOMMITTED_CHANGES)),)
else
VERSION := $(VERSION)-dev-build
endif
CFLAGS = -Wextra -std=c89 -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-z,norelro -Wno-unused-parameter -static -DVERSION=\"$(VERSION)\" -DCRON_USE_LOCAL_TIME
CFLAGS = -Wextra -std=c89 -s -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-z,norelro -static -DVERSION=\"$(VERSION)\" -DCRON_USE_LOCAL_TIME
SOURCES = supertinycron.c ccronexpr.c ccronexpr_test.c
OBJECTS = supertinycron.o ccronexpr.o
Expand Down
12 changes: 6 additions & 6 deletions ccronexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ static int do_nextprev(
int (*do_)(cron_expr* expr, struct tm* calendar, int dot),
int (*find_day)(struct tm* calendar, uint8_t* days_of_month, int8_t* day_in_month, int day_of_month, uint8_t* days_of_week, int day_of_week, uint8_t* flags, int* resets, int* res_out),
int (*find_offset)(uint8_t* bits, int max, int value, int offset, struct tm* calendar, int field, int nextField, int* lower_orders, int* res_out),
cron_expr* expr, struct tm* calendar, int dot, int offset) {
cron_expr* expr, struct tm* calendar, int dot) {
int i;
int res = 0;
int resets[CRON_CF_ARR_LEN];
Expand Down Expand Up @@ -628,7 +628,7 @@ static int do_nextprev(
update_month = find(expr->months, CRON_MAX_MONTHS, month, calendar, CRON_CF_MONTH, CRON_CF_YEAR, resets, &res);
if (0 != res) goto return_result;
if (month != update_month) {
if ((calendar->tm_year - dot)*offset > CRON_MAX_YEARS_DIFF) {
if (abs(calendar->tm_year - dot) > CRON_MAX_YEARS_DIFF) {
res = -1;
goto return_result;
}
Expand All @@ -651,7 +651,7 @@ static int do_nextprev(
}

static int do_next(cron_expr* expr, struct tm* calendar, int dot) {
return do_nextprev(find_next, do_next, find_next_day, find_next_offset, expr, calendar, dot, 1);
return do_nextprev(find_next, do_next, find_next_day, find_next_offset, expr, calendar, dot);
}

static int to_upper(char* str) {
Expand Down Expand Up @@ -1299,10 +1299,10 @@ static int find_prev_offset(uint8_t* bits, int max, int value, int offset, struc
next_value = prev_set_bit(bits, max - 1, value, &notfound);
}
if (notfound || next_value != value) {
err = set_field(calendar, field, next_value);
if (err) goto return_error;
err = reset_all_max(calendar, lower_orders);
if (err) goto return_error;
err = set_field(calendar, field, next_value);
if (err) goto return_error;
}
return next_value;

Expand Down Expand Up @@ -1335,7 +1335,7 @@ static int find_prev_day(struct tm* calendar, uint8_t* days_of_month, int8_t* da
}

static int do_prev(cron_expr* expr, struct tm* calendar, int dot) {
return do_nextprev(find_prev, do_prev, find_prev_day, find_prev_offset, expr, calendar, dot, -1);
return do_nextprev(find_prev, do_prev, find_prev_day, find_prev_offset, expr, calendar, dot);
}

time_t cron_prev(cron_expr* expr, time_t date) {
Expand Down
2 changes: 1 addition & 1 deletion ccronexpr_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void test_expr() {
check_fn(cron_next, "0 0 0 ? 4-5 *", "2022-03-31_00:00:00", "2022-04-01_00:00:00", __LINE__);

check_fn(cron_next, "* * * 29 2 *", "2021-12-07_12:00:00", "2024-02-29_00:00:00", __LINE__);
/*check_fn(cron_prev, "* * * 29 2 *", "2021-12-07_12:00:00", "2024-02-29_00:00:00", __LINE__);*/
check_fn(cron_prev, "* * * 29 2 *", "2021-12-07_12:00:00", "2020-02-29_23:59:59", __LINE__);
}

void test_parse() {
Expand Down

0 comments on commit 534ad99

Please sign in to comment.