Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
exander77 committed Sep 6, 2023
1 parent 3b8e190 commit e3f95ce
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ script:
- $CC -DCRON_USE_LOCAL_TIME ccronexpr.c ccronexpr_test.c -I. -Wall -Wextra -std=c89 -DCRON_TEST_MALLOC -o a.out && TZ="America/Toronto" ./a.out
- $CXX -DCRON_USE_LOCAL_TIME ccronexpr.c ccronexpr_test.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -o a.out && TZ="America/Toronto" ./a.out
- $CXX -DCRON_USE_LOCAL_TIME ccronexpr.c ccronexpr_test.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -DCRON_COMPILE_AS_CXX -o a.out && TZ="America/Toronto" ./a.out
- $CC ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c89 -DCRON_TEST_MALLOC -o a.out && ./a.out
- $CXX ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -o a.out && ./a.out
- $CXX ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -DCRON_COMPILE_AS_CXX -o a.out && ./a.out
- $CC -DCRON_USE_LOCAL_TIME ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c89 -DCRON_TEST_MALLOC -o a.out && TZ="America/Toronto" ./a.out
- $CXX -DCRON_USE_LOCAL_TIME ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -o a.out && TZ="America/Toronto" ./a.out
- $CXX -DCRON_USE_LOCAL_TIME ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -DCRON_COMPILE_AS_CXX -o a.out && TZ="America/Toronto" ./a.out

notifications:
email:
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ Compilation and tests run examples

cl ccronexpr.c ccronexpr_test.c /W4 /D_CRT_SECURE_NO_WARNINGS && ccronexpr.exe


gcc ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c89 -DCRON_TEST_MALLOC -o a.out && ./a.out
g++ ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -o a.out && ./a.out
g++ ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -DCRON_COMPILE_AS_CXX -o a.out && ./a.out

clang ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c89 -DCRON_TEST_MALLOC -o a.out && ./a.out
clang++ ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -o a.out && ./a.out
clang++ ccronexpr.c supertinycron.c -I. -Wall -Wextra -std=c++11 -DCRON_TEST_MALLOC -DCRON_COMPILE_AS_CXX -o a.out && ./a.out

cl ccronexpr.c supertinycron.c /W4 /D_CRT_SECURE_NO_WARNINGS && supertinycron.exe

Examples of supported expressions
---------------------------------

Expand Down
3 changes: 2 additions & 1 deletion ccronexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ static void set_days_of_week(char* field, uint8_t* days_of_week, int8_t* day_in_
cron_del_bit(days_of_week, 7);
}
return_error:
return;
}

static int set_days_of_month(char* field, uint8_t* days_of_month, uint8_t* days_of_week, int8_t* day_in_month, uint8_t* flags, const char** error) {
Expand Down Expand Up @@ -1169,7 +1170,7 @@ void cron_parse_expr(const char* expression, cron_expr* target, const char** err
if (*error) goto return_res;
}
if (len < 7) {
set_years("*", target->years, error);
set_years((char *)"*", target->years, error);
} else {
set_years(fields[pos], target->years, error);
}
Expand Down
25 changes: 22 additions & 3 deletions supertinycron.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
#define VERSION "dev-build"
#endif

#ifdef CRON_TEST_MALLOC
static int cronAllocations = 0;
static int cronTotalAllocations = 0;
static int maxAlloc = 0;
void* cron_malloc(size_t n) {
cronAllocations++;
cronTotalAllocations++;
if (cronAllocations > maxAlloc) {
maxAlloc = cronAllocations;
}
return malloc(n);
}

void cron_free(void* p) {
cronAllocations--;
free(p);
}
#endif

typedef struct {
char* shell;
char* cmd;
Expand Down Expand Up @@ -103,13 +122,13 @@ int cron_system(const char *shell, const char *command) {
}

TinyCronJob optsFromEnv() {
TinyCronJob opts = {0};
TinyCronJob opts;
if (getenv("TINYCRON_VERBOSE") != NULL) {
opts.verbose = 1;
}
opts.shell = getenv("SHELL");
if (!opts.shell) {
opts.shell = "/bin/sh";
opts.shell = (char *)"/bin/sh";
}
return opts;
}
Expand Down Expand Up @@ -224,7 +243,7 @@ int main(int argc, char *argv[]) {
line_len += argc - 3;
line_len += 1;

char *line = malloc(line_len);
char *line = (char *)malloc(line_len);
if (!line) {
perror("malloc");
return EXIT_FAILURE;
Expand Down

0 comments on commit e3f95ce

Please sign in to comment.