Skip to content

Commit

Permalink
Merge pull request #680 from ruby/pz-tabs-to-spaces
Browse files Browse the repository at this point in the history
Convert tabs to spaces in C files
  • Loading branch information
tenderlove authored Aug 9, 2024
2 parents 6bb8d08 + e7d64c9 commit 537f18d
Show file tree
Hide file tree
Showing 3 changed files with 371 additions and 371 deletions.
2 changes: 1 addition & 1 deletion ext/psych/psych.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ VALUE mPsych;
void Init_psych(void)
{
#ifdef HAVE_RB_EXT_RACTOR_SAFE
RB_EXT_RACTOR_SAFE(true);
RB_EXT_RACTOR_SAFE(true);
#endif
mPsych = rb_define_module("Psych");

Expand Down
216 changes: 108 additions & 108 deletions ext/psych/psych_emitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static ID id_canonical;
static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
{
if(!yaml_emitter_emit(emitter, event))
rb_raise(rb_eRuntimeError, "%s", emitter->problem);
rb_raise(rb_eRuntimeError, "%s", emitter->problem);
}

static int writer(void *ctx, unsigned char *buffer, size_t size)
Expand Down Expand Up @@ -82,13 +82,13 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);

if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
line_width = rb_funcall(options, id_line_width, 0);
indent = rb_funcall(options, id_indentation, 0);
canonical = rb_funcall(options, id_canonical, 0);
line_width = rb_funcall(options, id_line_width, 0);
indent = rb_funcall(options, id_indentation, 0);
canonical = rb_funcall(options, id_canonical, 0);

yaml_emitter_set_width(emitter, NUM2INT(line_width));
yaml_emitter_set_indent(emitter, NUM2INT(indent));
yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
yaml_emitter_set_width(emitter, NUM2INT(line_width));
yaml_emitter_set_indent(emitter, NUM2INT(indent));
yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
}

rb_ivar_set(self, id_io, io);
Expand Down Expand Up @@ -156,56 +156,56 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
Check_Type(version, T_ARRAY);

if(RARRAY_LEN(version) > 0) {
VALUE major = rb_ary_entry(version, (long)0);
VALUE minor = rb_ary_entry(version, (long)1);
VALUE major = rb_ary_entry(version, (long)0);
VALUE minor = rb_ary_entry(version, (long)1);

version_directive.major = NUM2INT(major);
version_directive.minor = NUM2INT(minor);
version_directive.major = NUM2INT(major);
version_directive.minor = NUM2INT(minor);
}

if(RTEST(tags)) {
long i = 0;
long len;
rb_encoding * encoding = rb_utf8_encoding();

Check_Type(tags, T_ARRAY);

len = RARRAY_LEN(tags);
head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
tail = head;

for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
VALUE tuple = RARRAY_AREF(tags, i);
VALUE name;
VALUE value;

Check_Type(tuple, T_ARRAY);

if(RARRAY_LEN(tuple) < 2) {
xfree(head);
rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
}
name = RARRAY_AREF(tuple, 0);
value = RARRAY_AREF(tuple, 1);
StringValue(name);
StringValue(value);
name = rb_str_export_to_enc(name, encoding);
value = rb_str_export_to_enc(value, encoding);

tail->handle = (yaml_char_t *)StringValueCStr(name);
tail->prefix = (yaml_char_t *)StringValueCStr(value);

tail++;
}
long i = 0;
long len;
rb_encoding * encoding = rb_utf8_encoding();

Check_Type(tags, T_ARRAY);

len = RARRAY_LEN(tags);
head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
tail = head;

for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
VALUE tuple = RARRAY_AREF(tags, i);
VALUE name;
VALUE value;

Check_Type(tuple, T_ARRAY);

if(RARRAY_LEN(tuple) < 2) {
xfree(head);
rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
}
name = RARRAY_AREF(tuple, 0);
value = RARRAY_AREF(tuple, 1);
StringValue(name);
StringValue(value);
name = rb_str_export_to_enc(name, encoding);
value = rb_str_export_to_enc(value, encoding);

tail->handle = (yaml_char_t *)StringValueCStr(name);
tail->prefix = (yaml_char_t *)StringValueCStr(value);

tail++;
}
}

yaml_document_start_event_initialize(
&event,
(RARRAY_LEN(version) > 0) ? &version_directive : NULL,
head,
tail,
imp ? 1 : 0
);
&event,
(RARRAY_LEN(version) > 0) ? &version_directive : NULL,
head,
tail,
imp ? 1 : 0
);

emit(emitter, &event);

Expand Down Expand Up @@ -241,14 +241,14 @@ static VALUE end_document(VALUE self, VALUE imp)
* See Psych::Handler#scalar
*/
static VALUE scalar(
VALUE self,
VALUE value,
VALUE anchor,
VALUE tag,
VALUE plain,
VALUE quoted,
VALUE style
) {
VALUE self,
VALUE value,
VALUE anchor,
VALUE tag,
VALUE plain,
VALUE quoted,
VALUE style
) {
yaml_emitter_t * emitter;
yaml_event_t event;
rb_encoding *encoding;
Expand All @@ -261,25 +261,25 @@ static VALUE scalar(
value = rb_str_export_to_enc(value, encoding);

if(!NIL_P(anchor)) {
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, encoding);
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, encoding);
}

if(!NIL_P(tag)) {
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
}

yaml_scalar_event_initialize(
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
(yaml_char_t*)StringValuePtr(value),
(int)RSTRING_LEN(value),
plain ? 1 : 0,
quoted ? 1 : 0,
(yaml_scalar_style_t)NUM2INT(style)
);
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
(yaml_char_t*)StringValuePtr(value),
(int)RSTRING_LEN(value),
plain ? 1 : 0,
quoted ? 1 : 0,
(yaml_scalar_style_t)NUM2INT(style)
);

emit(emitter, &event);

Expand All @@ -294,36 +294,36 @@ static VALUE scalar(
* See Psych::Handler#start_sequence
*/
static VALUE start_sequence(
VALUE self,
VALUE anchor,
VALUE tag,
VALUE implicit,
VALUE style
) {
VALUE self,
VALUE anchor,
VALUE tag,
VALUE implicit,
VALUE style
) {
yaml_emitter_t * emitter;
yaml_event_t event;

rb_encoding * encoding = rb_utf8_encoding();

if(!NIL_P(anchor)) {
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, encoding);
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, encoding);
}

if(!NIL_P(tag)) {
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
}

TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);

yaml_sequence_start_event_initialize(
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
implicit ? 1 : 0,
(yaml_sequence_style_t)NUM2INT(style)
);
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
implicit ? 1 : 0,
(yaml_sequence_style_t)NUM2INT(style)
);

emit(emitter, &event);

Expand Down Expand Up @@ -357,12 +357,12 @@ static VALUE end_sequence(VALUE self)
* See Psych::Handler#start_mapping
*/
static VALUE start_mapping(
VALUE self,
VALUE anchor,
VALUE tag,
VALUE implicit,
VALUE style
) {
VALUE self,
VALUE anchor,
VALUE tag,
VALUE implicit,
VALUE style
) {
yaml_emitter_t * emitter;
yaml_event_t event;
rb_encoding *encoding;
Expand All @@ -372,22 +372,22 @@ static VALUE start_mapping(
encoding = rb_utf8_encoding();

if(!NIL_P(anchor)) {
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, encoding);
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, encoding);
}

if(!NIL_P(tag)) {
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
}

yaml_mapping_start_event_initialize(
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
implicit ? 1 : 0,
(yaml_mapping_style_t)NUM2INT(style)
);
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
implicit ? 1 : 0,
(yaml_mapping_style_t)NUM2INT(style)
);

emit(emitter, &event);

Expand Down Expand Up @@ -426,14 +426,14 @@ static VALUE alias(VALUE self, VALUE anchor)
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);

if(!NIL_P(anchor)) {
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
}

yaml_alias_event_initialize(
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
);
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
);

emit(emitter, &event);

Expand Down
Loading

0 comments on commit 537f18d

Please sign in to comment.