Skip to content

Commit

Permalink
generalized st_mode mask
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Dec 29, 2011
1 parent f78d2ec commit a3ff36a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions file.c
Expand Up @@ -231,6 +231,8 @@ rb_stat_cmp(VALUE self, SEL sel, VALUE other)
return Qnil;
}

#define ST2UINT(val) ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))

/*
* call-seq:
* stat.dev -> fixnum
Expand Down Expand Up @@ -328,11 +330,7 @@ rb_stat_ino(VALUE self, SEL sel)
static VALUE
rb_stat_mode(VALUE self, SEL sel)
{
#ifdef __BORLANDC__
return UINT2NUM((unsigned short)(get_stat(self)->st_mode));
#else
return UINT2NUM(get_stat(self)->st_mode);
#endif
return UINT2NUM(ST2UINT(get_stat(self)->st_mode));
}

/*
Expand Down

0 comments on commit a3ff36a

Please sign in to comment.