scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 4222cda40a32d6f958820ce6da4505e74c27cbd9
parent 9f205208845d91f9d66bb2e697259490cb5bab3f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 26 Sep 2018 07:11:41 +0100

[lib/c] Several small fixes

Cast to avoid const discard warnings are removed becuase they
generated an error. Casts are dangerous since they disable
all the type checking done by the compiler. At this point
it is preferible to have the warning.

Diffstat:
Mlib/c/bsearch.c | 4++--
Mlib/c/gmtime.c | 4++--
Mlib/c/libc.h | 4+++-
3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/c/bsearch.c b/lib/c/bsearch.c @@ -6,7 +6,7 @@ bsearch(const void *key, const void *ary, size_t n, size_t size, { int t; size_t mid, low, high; - const char *cur, *base = ary; + char *cur, *base = ary; low = 0; high = n - 1; @@ -15,7 +15,7 @@ bsearch(const void *key, const void *ary, size_t n, size_t size, cur = base + mid*size; if ((t = (*cmp)(key, cur)) == 0) - return (void *) cur; + return cur; else if (t > 0) low = mid + 1; else diff --git a/lib/c/gmtime.c b/lib/c/gmtime.c @@ -18,8 +18,8 @@ gmtime(const time_t *t) tm.tm_wday = (day + THU) % 7; /* 1/1/1970 was Thursday */ - for (i = EPOCH; day >= _yeardays(i); ++i) - day -= _yeardays(i); + for (i = EPOCH; day >= _daysyear(i); ++i) + day -= _daysyear(i); tm.tm_year = i - 1900; tm.tm_yday = day; diff --git a/lib/c/libc.h b/lib/c/libc.h @@ -11,7 +11,7 @@ #define DEC 11 #define EPOCH 1970 -#define FEBDAYS(y) ((_yeardays(y) == 366) ? 29 : 28) +#define FEBDAYS(y) ((_daysyear(y) == 366) ? 29 : 28) #define SECMIN 60 #define SECHOUR (60 * SECMIN) /* 3600 */ #define SECDAY (24 * SECHOUR) /* 86400 */ @@ -28,6 +28,8 @@ struct tzone { int isdst; }; +struct tm; + extern struct tzone *_tzone(struct tm *tm); extern int _daysyear(int year); extern int _newyear(int year);