Skip to content

Commit

Permalink
Run tool/lint.sh for C files in spec/ruby/optional/capi and fix forma…
Browse files Browse the repository at this point in the history
…tting
  • Loading branch information
andrykonchin authored and eregon committed Aug 2, 2023
1 parent e4bb761 commit e6c6b96
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 60 deletions.
8 changes: 4 additions & 4 deletions optional/capi/ext/class_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static VALUE class_spec_rb_class_new_instance_kw(VALUE self, VALUE args, VALUE k
#endif

static VALUE class_spec_rb_class_real(VALUE self, VALUE object) {
if(rb_type_p(object, T_FIXNUM)) {
if (rb_type_p(object, T_FIXNUM)) {
return INT2FIX(rb_class_real(FIX2INT(object)));
} else {
return rb_class_real(CLASS_OF(object));
Expand Down Expand Up @@ -116,19 +116,19 @@ VALUE class_spec_define_attr(VALUE self, VALUE klass, VALUE sym, VALUE read, VAL
}

static VALUE class_spec_rb_define_class(VALUE self, VALUE name, VALUE super) {
if(NIL_P(super)) super = 0;
if (NIL_P(super)) super = 0;
return rb_define_class(RSTRING_PTR(name), super);
}

static VALUE class_spec_rb_define_class_under(VALUE self, VALUE outer,
VALUE name, VALUE super) {
if(NIL_P(super)) super = 0;
if (NIL_P(super)) super = 0;
return rb_define_class_under(outer, RSTRING_PTR(name), super);
}

static VALUE class_spec_rb_define_class_id_under(VALUE self, VALUE outer,
VALUE name, VALUE super) {
if(NIL_P(super)) super = 0;
if (NIL_P(super)) super = 0;
return rb_define_class_id_under(outer, SYM2ID(name), super);
}

Expand Down
2 changes: 1 addition & 1 deletion optional/capi/ext/debug_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static VALUE rb_debug_inspector_frame_iseq_get_callback(const rb_debug_inspector
return rb_debug_inspector_frame_iseq_get(dc, NUM2LONG((VALUE) ptr));
}

static VALUE debug_spec_callback_data(VALUE self){
static VALUE debug_spec_callback_data(VALUE self) {
return callback_data;
}

Expand Down
8 changes: 4 additions & 4 deletions optional/capi/ext/encoding_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static VALUE encoding_spec_MBCLEN_CHARFOUND_P(VALUE self, VALUE obj) {
}

static VALUE encoding_spec_ENC_CODERANGE_ASCIIONLY(VALUE self, VALUE obj) {
if(ENC_CODERANGE_ASCIIONLY(obj)) {
if (ENC_CODERANGE_ASCIIONLY(obj)) {
return Qtrue;
} else {
return Qfalse;
Expand Down Expand Up @@ -61,13 +61,13 @@ static VALUE encoding_spec_rb_filesystem_encindex(VALUE self) {

static VALUE encoding_spec_rb_default_internal_encoding(VALUE self) {
rb_encoding* enc = rb_default_internal_encoding();
if(enc == 0) return Qnil;
if (enc == 0) return Qnil;
return rb_str_new2(enc->name);
}

static VALUE encoding_spec_rb_default_external_encoding(VALUE self) {
rb_encoding* enc = rb_default_external_encoding();
if(enc == 0) return Qnil;
if (enc == 0) return Qnil;
return rb_str_new2(enc->name);
}

Expand All @@ -86,7 +86,7 @@ static VALUE encoding_spec_rb_enc_associate_index(VALUE self, VALUE obj, VALUE i
static VALUE encoding_spec_rb_enc_compatible(VALUE self, VALUE a, VALUE b) {
rb_encoding* enc = rb_enc_compatible(a, b);

if(!enc) return INT2FIX(0);
if (!enc) return INT2FIX(0);

return rb_enc_from_encoding(enc);
}
Expand Down
2 changes: 1 addition & 1 deletion optional/capi/ext/exception_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ VALUE exception_spec_rb_exc_new3(VALUE self, VALUE str) {
}

VALUE exception_spec_rb_exc_raise(VALUE self, VALUE exc) {
if (self != Qundef) rb_exc_raise(exc);
if (self != Qundef) rb_exc_raise(exc);
return Qnil;
}

Expand Down
2 changes: 1 addition & 1 deletion optional/capi/ext/gc_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static VALUE gc_spec_rb_gc(VALUE self) {
return Qnil;
}

static VALUE gc_spec_rb_gc_latest_gc_info(VALUE self, VALUE hash_or_key){
static VALUE gc_spec_rb_gc_latest_gc_info(VALUE self, VALUE hash_or_key) {
return rb_gc_latest_gc_info(hash_or_key);
}

Expand Down
5 changes: 2 additions & 3 deletions optional/capi/ext/integer_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ extern "C" {
#endif

static VALUE integer_spec_rb_integer_pack(VALUE self, VALUE value,
VALUE words, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags)
{
VALUE words, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags) {
int result = rb_integer_pack(value, (void*)RSTRING_PTR(words), FIX2INT(numwords),
FIX2INT(wordsize), FIX2INT(nails), FIX2INT(flags));
return INT2FIX(result);
}

RUBY_EXTERN VALUE rb_int_positive_pow(long x, unsigned long y); /* internal.h, used in ripper */

static VALUE integer_spec_rb_int_positive_pow(VALUE self, VALUE a, VALUE b){
static VALUE integer_spec_rb_int_positive_pow(VALUE self, VALUE a, VALUE b) {
return rb_int_positive_pow(FIX2INT(a), FIX2INT(b));
}

Expand Down
8 changes: 4 additions & 4 deletions optional/capi/ext/io_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) {
rb_sys_fail("set_non_blocking failed");

#ifndef SET_NON_BLOCKING_FAILS_ALWAYS
if(RTEST(read_p)) {
if (RTEST(read_p)) {
if (read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) {
return Qnil;
}
Expand All @@ -145,7 +145,7 @@ VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) {

ret = rb_io_wait_readable(fd);

if(RTEST(read_p)) {
if (RTEST(read_p)) {
ssize_t r = read(fd, buf, RB_IO_WAIT_READABLE_BUF);
if (r != RB_IO_WAIT_READABLE_BUF) {
perror("read");
Expand Down Expand Up @@ -185,7 +185,7 @@ VALUE io_spec_rb_io_maybe_wait_readable(VALUE self, VALUE error, VALUE io, VALUE
rb_sys_fail("set_non_blocking failed");

#ifndef SET_NON_BLOCKING_FAILS_ALWAYS
if(RTEST(read_p)) {
if (RTEST(read_p)) {
if (read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) {
return Qnil;
}
Expand All @@ -197,7 +197,7 @@ VALUE io_spec_rb_io_maybe_wait_readable(VALUE self, VALUE error, VALUE io, VALUE
// main part
ret = rb_io_maybe_wait_readable(NUM2INT(error), io, timeout);

if(RTEST(read_p)) {
if (RTEST(read_p)) {
ssize_t r = read(fd, buf, RB_IO_WAIT_READABLE_BUF);
if (r != RB_IO_WAIT_READABLE_BUF) {
perror("read");
Expand Down
8 changes: 4 additions & 4 deletions optional/capi/ext/kernel_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static VALUE kernel_spec_rb_eval_string_protect(VALUE self, VALUE str, VALUE ary

VALUE kernel_spec_rb_sys_fail(VALUE self, VALUE msg) {
errno = 1;
if(msg == Qnil) {
if (msg == Qnil) {
rb_sys_fail(0);
} else if (self != Qundef) {
rb_sys_fail(StringValuePtr(msg));
Expand All @@ -229,7 +229,7 @@ VALUE kernel_spec_rb_sys_fail(VALUE self, VALUE msg) {
}

VALUE kernel_spec_rb_syserr_fail(VALUE self, VALUE err, VALUE msg) {
if(msg == Qnil) {
if (msg == Qnil) {
rb_syserr_fail(NUM2INT(err), NULL);
} else if (self != Qundef) {
rb_syserr_fail(NUM2INT(err), StringValuePtr(msg));
Expand Down Expand Up @@ -292,9 +292,9 @@ static VALUE kernel_spec_rb_yield_values2(VALUE self, VALUE ary) {
}

static VALUE do_rec(VALUE obj, VALUE arg, int is_rec) {
if(is_rec) {
if (is_rec) {
return obj;
} else if(arg == Qtrue) {
} else if (arg == Qtrue) {
return rb_exec_recursive(do_rec, obj, Qnil);
} else {
return Qnil;
Expand Down
36 changes: 18 additions & 18 deletions optional/capi/ext/object_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,126 +218,126 @@ static VALUE so_check_type(VALUE self, VALUE obj, VALUE other) {
}

static VALUE so_is_type_nil(VALUE self, VALUE obj) {
if(TYPE(obj) == T_NIL) {
if (TYPE(obj) == T_NIL) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_type_object(VALUE self, VALUE obj) {
if(TYPE(obj) == T_OBJECT) {
if (TYPE(obj) == T_OBJECT) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_type_array(VALUE self, VALUE obj) {
if(TYPE(obj) == T_ARRAY) {
if (TYPE(obj) == T_ARRAY) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_type_module(VALUE self, VALUE obj) {
if(TYPE(obj) == T_MODULE) {
if (TYPE(obj) == T_MODULE) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_type_class(VALUE self, VALUE obj) {
if(TYPE(obj) == T_CLASS) {
if (TYPE(obj) == T_CLASS) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_type_data(VALUE self, VALUE obj) {
if(TYPE(obj) == T_DATA) {
if (TYPE(obj) == T_DATA) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_rb_type_p_nil(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_NIL)) {
if (rb_type_p(obj, T_NIL)) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_rb_type_p_object(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_OBJECT)) {
if (rb_type_p(obj, T_OBJECT)) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_rb_type_p_array(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_ARRAY)) {
if (rb_type_p(obj, T_ARRAY)) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_rb_type_p_module(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_MODULE)) {
if (rb_type_p(obj, T_MODULE)) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_rb_type_p_class(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_CLASS)) {
if (rb_type_p(obj, T_CLASS)) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_rb_type_p_data(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_DATA)) {
if (rb_type_p(obj, T_DATA)) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_rb_type_p_file(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_FILE)) {
if (rb_type_p(obj, T_FILE)) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_builtin_type_object(VALUE self, VALUE obj) {
if(BUILTIN_TYPE(obj) == T_OBJECT) {
if (BUILTIN_TYPE(obj) == T_OBJECT) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_builtin_type_array(VALUE self, VALUE obj) {
if(BUILTIN_TYPE(obj) == T_ARRAY) {
if (BUILTIN_TYPE(obj) == T_ARRAY) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_builtin_type_module(VALUE self, VALUE obj) {
if(BUILTIN_TYPE(obj) == T_MODULE) {
if (BUILTIN_TYPE(obj) == T_MODULE) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_builtin_type_class(VALUE self, VALUE obj) {
if(BUILTIN_TYPE(obj) == T_CLASS) {
if (BUILTIN_TYPE(obj) == T_CLASS) {
return Qtrue;
}
return Qfalse;
}

static VALUE so_is_builtin_type_data(VALUE self, VALUE obj) {
if(BUILTIN_TYPE(obj) == T_DATA) {
if (BUILTIN_TYPE(obj) == T_DATA) {
return Qtrue;
}
return Qfalse;
Expand Down
2 changes: 1 addition & 1 deletion optional/capi/ext/range_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern "C" {

VALUE range_spec_rb_range_new(int argc, VALUE* argv, VALUE self) {
int exclude_end = 0;
if(argc == 3) {
if (argc == 3) {
exclude_end = RTEST(argv[2]);
}
return rb_range_new(argv[0], argv[1], exclude_end);
Expand Down
Loading

0 comments on commit e6c6b96

Please sign in to comment.