From b08d7f62825ad34f72387593f965a0a5f604d36a Mon Sep 17 00:00:00 2001 From: Peter Ohler Date: Wed, 16 Aug 2023 19:06:13 -0400 Subject: [PATCH] clang-format --- ext/oj/dump_compat.c | 46 ++++++++++++++++++++++---------------------- ext/oj/oj.c | 20 +++++++++---------- ext/oj/oj.h | 32 +++++++++++++++--------------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ext/oj/dump_compat.c b/ext/oj/dump_compat.c index bfe535ba..156f894e 100644 --- a/ext/oj/dump_compat.c +++ b/ext/oj/dump_compat.c @@ -851,36 +851,36 @@ static DumpFunc compat_funcs[] = { }; static void set_state_depth(VALUE state, int depth) { - if (0 == rb_const_defined(rb_cObject, rb_intern("JSON"))) { - rb_require("oj/json"); - } - { - VALUE json_module = rb_const_get_at(rb_cObject, rb_intern("JSON")); - VALUE ext = rb_const_get(json_module, rb_intern("Ext")); - VALUE generator = rb_const_get(ext, rb_intern("Generator")); - VALUE state_class = rb_const_get(generator, rb_intern("State")); - - if (state_class == rb_obj_class(state)) { - rb_funcall(state, rb_intern("depth="), 1, INT2NUM(depth)); - } - } + if (0 == rb_const_defined(rb_cObject, rb_intern("JSON"))) { + rb_require("oj/json"); + } + { + VALUE json_module = rb_const_get_at(rb_cObject, rb_intern("JSON")); + VALUE ext = rb_const_get(json_module, rb_intern("Ext")); + VALUE generator = rb_const_get(ext, rb_intern("Generator")); + VALUE state_class = rb_const_get(generator, rb_intern("State")); + + if (state_class == rb_obj_class(state)) { + rb_funcall(state, rb_intern("depth="), 1, INT2NUM(depth)); + } + } } void oj_dump_compat_val(VALUE obj, int depth, Out out, bool as_ok) { int type = rb_type(obj); TRACE(out->opts->trace, "dump", obj, depth, TraceIn); - // The max_nesting logic is that an empty Array or Hash is assumed to have - // content so the max_nesting should fail but a non-collection value is - // okay. That means a check for a collectable value is needed before - // raising. + // The max_nesting logic is that an empty Array or Hash is assumed to have + // content so the max_nesting should fail but a non-collection value is + // okay. That means a check for a collectable value is needed before + // raising. if (out->opts->dump_opts.max_depth <= depth) { - if (RUBY_T_ARRAY == type || RUBY_T_HASH == type) { - if (0 < out->argc) { - set_state_depth(*out->argv, depth); - } - raise_json_err("Too deeply nested", "NestingError"); - } + if (RUBY_T_ARRAY == type || RUBY_T_HASH == type) { + if (0 < out->argc) { + set_state_depth(*out->argv, depth); + } + raise_json_err("Too deeply nested", "NestingError"); + } } if (0 < type && type <= RUBY_T_FIXNUM) { DumpFunc f = compat_funcs[type]; diff --git a/ext/oj/oj.c b/ext/oj/oj.c index 4cfac940..03d57aa7 100644 --- a/ext/oj/oj.c +++ b/ext/oj/oj.c @@ -955,16 +955,16 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts) { copts->sym_key = (Qtrue == v) ? Yes : No; } else if (oj_max_nesting_sym == k) { - if (Qtrue == v) { - copts->dump_opts.max_depth = 100; - } else if (Qfalse == v || Qnil == v) { - copts->dump_opts.max_depth = MAX_DEPTH; - } else if (T_FIXNUM == rb_type(v)) { - copts->dump_opts.max_depth = NUM2INT(v); - if (0 >= copts->dump_opts.max_depth) { - copts->dump_opts.max_depth = MAX_DEPTH; - } - } + if (Qtrue == v) { + copts->dump_opts.max_depth = 100; + } else if (Qfalse == v || Qnil == v) { + copts->dump_opts.max_depth = MAX_DEPTH; + } else if (T_FIXNUM == rb_type(v)) { + copts->dump_opts.max_depth = NUM2INT(v); + if (0 >= copts->dump_opts.max_depth) { + copts->dump_opts.max_depth = MAX_DEPTH; + } + } } else if (float_format_sym == k) { rb_check_type(v, T_STRING); if (6 < (int)RSTRING_LEN(v)) { diff --git a/ext/oj/oj.h b/ext/oj/oj.h index cdbaee57..f994e4bc 100644 --- a/ext/oj/oj.h +++ b/ext/oj/oj.h @@ -181,22 +181,22 @@ typedef struct _rOptTable { } *ROptTable; typedef struct _out { - char stack_buffer[4096]; - char *buf; - char *end; - char *cur; - Cache8 circ_cache; - slot_t circ_cnt; - int indent; - int depth; // used by dump_hash - Options opts; - uint32_t hash_cnt; - bool allocated; - bool omit_nil; - bool omit_null_byte; - int argc; - VALUE *argv; - ROptTable ropts; + char stack_buffer[4096]; + char *buf; + char *end; + char *cur; + Cache8 circ_cache; + slot_t circ_cnt; + int indent; + int depth; // used by dump_hash + Options opts; + uint32_t hash_cnt; + bool allocated; + bool omit_nil; + bool omit_null_byte; + int argc; + VALUE *argv; + ROptTable ropts; } *Out; typedef struct _strWriter {