Project

General

Profile

Feature #11796 ยป reduce_get_stat.patch

ksss (Yuki Kurihara), 12/09/2015 02:33 PM

View differences:

file.c
5115 5115
static VALUE
5116 5116
rb_stat_r(VALUE obj)
5117 5117
{
5118
    struct stat *st = get_stat(obj);
5118
    struct stat *st;
5119 5119

  
5120 5120
#ifdef USE_GETEUID
5121 5121
    if (geteuid() == 0) return Qtrue;
5122 5122
#endif
5123
    st = get_stat(obj);
5123 5124
#ifdef S_IRUSR
5124 5125
    if (rb_stat_owned(obj))
5125 5126
	return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
......
5148 5149
static VALUE
5149 5150
rb_stat_R(VALUE obj)
5150 5151
{
5151
    struct stat *st = get_stat(obj);
5152
    struct stat *st;
5152 5153

  
5153 5154
#ifdef USE_GETEUID
5154 5155
    if (getuid() == 0) return Qtrue;
5155 5156
#endif
5157
    st = get_stat(obj);
5156 5158
#ifdef S_IRUSR
5157 5159
    if (rb_stat_rowned(obj))
5158 5160
	return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
5159 5161
#endif
5160 5162
#ifdef S_IRGRP
5161
    if (rb_group_member(get_stat(obj)->st_gid))
5163
    if (rb_group_member(st->st_gid))
5162 5164
	return st->st_mode & S_IRGRP ? Qtrue : Qfalse;
5163 5165
#endif
5164 5166
#ifdef S_IROTH
......
5208 5210
static VALUE
5209 5211
rb_stat_w(VALUE obj)
5210 5212
{
5211
    struct stat *st = get_stat(obj);
5213
    struct stat *st;
5212 5214

  
5213 5215
#ifdef USE_GETEUID
5214 5216
    if (geteuid() == 0) return Qtrue;
5215 5217
#endif
5218
    st = get_stat(obj)
5216 5219
#ifdef S_IWUSR
5217 5220
    if (rb_stat_owned(obj))
5218 5221
	return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
......
5241 5244
static VALUE
5242 5245
rb_stat_W(VALUE obj)
5243 5246
{
5244
    struct stat *st = get_stat(obj);
5247
    struct stat *st;
5245 5248

  
5246 5249
#ifdef USE_GETEUID
5247 5250
    if (getuid() == 0) return Qtrue;
5248 5251
#endif
5252
    st = get_stat(obj);
5249 5253
#ifdef S_IWUSR
5250 5254
    if (rb_stat_rowned(obj))
5251 5255
	return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
5252 5256
#endif
5253 5257
#ifdef S_IWGRP
5254
    if (rb_group_member(get_stat(obj)->st_gid))
5258
    if (rb_group_member(st->st_gid))
5255 5259
	return st->st_mode & S_IWGRP ? Qtrue : Qfalse;
5256 5260
#endif
5257 5261
#ifdef S_IWOTH
......
5347 5351
	return st->st_mode & S_IXUSR ? Qtrue : Qfalse;
5348 5352
#endif
5349 5353
#ifdef S_IXGRP
5350
    if (rb_group_member(get_stat(obj)->st_gid))
5354
    if (rb_group_member(st->st_gid))
5351 5355
	return st->st_mode & S_IXGRP ? Qtrue : Qfalse;
5352 5356
#endif
5353 5357
#ifdef S_IXOTH