Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Fix casting for flags with "&= ~"
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Sep 1, 2010
1 parent 4e6f21e commit dba855b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ext/date_ext/date_ext.c
Expand Up @@ -648,7 +648,7 @@ int rhrd__fill_from_hash(rhrd_t *d, VALUE hash) {
if(!rhrd__valid_commercial(d, d->year, 1, NUM2LONG(rwday), RHR_NO_RAISE)) {
return 1;
}
d->flags &= ~RHR_HAVE_CIVIL;
d->flags &= (unsigned char)~RHR_HAVE_CIVIL;
return 0;
} else if (RTEST(rwnum0)) {
d->jd = rhrd__weeknum_to_jd(year, NUM2LONG(rwnum0), RTEST(rwday) ? NUM2LONG(rwday) : (RTEST(rcwday) ? rhrd__mod(NUM2LONG(rcwday), 7) : 0), 0);
Expand Down Expand Up @@ -697,7 +697,7 @@ int rhrd__fill_from_hash(rhrd_t *d, VALUE hash) {
wday = NUM2LONG(rwday);
rhrd__today(d);
d->jd += wday - rhrd__jd_to_wday(d->jd);
d->flags &= ~RHR_HAVE_CIVIL;
d->flags &= (unsigned char)~RHR_HAVE_CIVIL;
return 0;
} else {
return -1;
Expand Down
8 changes: 4 additions & 4 deletions ext/date_ext/date_ext.h
Expand Up @@ -71,10 +71,10 @@ so that no calculations can overflow.
#define RHR_DAY_MIN 8
#endif

#define RHR_HAVE_JD ((unsigned char)1)
#define RHR_HAVE_CIVIL ((unsigned char)2)
#define RHR_HAVE_NANOS ((unsigned char)4)
#define RHR_HAVE_HMS ((unsigned char)8)
#define RHR_HAVE_JD 1
#define RHR_HAVE_CIVIL 2
#define RHR_HAVE_NANOS 4
#define RHR_HAVE_HMS 8

#define RHR_NO_RAISE 0
#define RHR_OVERLIMIT_RAISE 1
Expand Down
6 changes: 3 additions & 3 deletions ext/date_ext/datetime.c
Expand Up @@ -142,7 +142,7 @@ void rhrdt__set_time(rhrdt_t *dt, long h, long m, long s, double offset) {
if (h == 24 && m == 0 && s == 0) {
RHRDT_FILL_JD(dt)
dt->jd++;
dt->flags &= ~RHR_HAVE_CIVIL;
dt->flags &= (unsigned char)~RHR_HAVE_CIVIL;
h = 0;
} else if (h < 0 || m < 0 || s < 0 || h > 23 || m > 59 || s > 59) {
rb_raise(rb_eArgError, "invalid time: %ld hours, %ld minutes, %ld seconds", h, m, s);
Expand Down Expand Up @@ -397,7 +397,7 @@ VALUE rhrdt__add_months(VALUE self, long n) {
x = rhrd__days_in_month(newd->year, newd->month);
newd->day = (unsigned char)(d->day > x ? x : d->day);
RHR_CHECK_CIVIL(newd)
newd->flags &= ~RHR_HAVE_JD;
newd->flags &= (unsigned char)~RHR_HAVE_JD;
return new;
}

Expand Down Expand Up @@ -1924,7 +1924,7 @@ VALUE rhrdt__add_years(VALUE self, long n) {
}

RHR_CHECK_CIVIL(newd)
newd->flags &= ~RHR_HAVE_JD;
newd->flags &= (unsigned char)~RHR_HAVE_JD;
return new;
}

Expand Down

0 comments on commit dba855b

Please sign in to comment.