ox 2.14.14 → 2.14.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/ox/err.c CHANGED
@@ -3,13 +3,12 @@
3
3
  * All rights reserved.
4
4
  */
5
5
 
6
- #include <stdarg.h>
7
-
8
6
  #include "err.h"
9
7
 
10
- void
11
- ox_err_set(Err e, VALUE clas, const char *format, ...) {
12
- va_list ap;
8
+ #include <stdarg.h>
9
+
10
+ void ox_err_set(Err e, VALUE clas, const char *format, ...) {
11
+ va_list ap;
13
12
 
14
13
  va_start(ap, format);
15
14
  e->clas = clas;
@@ -26,18 +25,22 @@ ox_err_raise(Err e) {
26
25
  rb_raise(e->clas, "%s", e->msg);
27
26
  }
28
27
 
29
- void
30
- _ox_err_set_with_location(Err err, const char *msg, const char *xml, const char *current, const char* file, int line) {
31
- int xline = 1;
32
- int col = 1;
28
+ void _ox_err_set_with_location(Err err,
29
+ const char *msg,
30
+ const char *xml,
31
+ const char *current,
32
+ const char *file,
33
+ int line) {
34
+ int xline = 1;
35
+ int col = 1;
33
36
 
34
37
  for (; xml < current && '\n' != *current; current--) {
35
- col++;
38
+ col++;
36
39
  }
37
40
  for (; xml < current; current--) {
38
- if ('\n' == *current) {
39
- xline++;
40
- }
41
+ if ('\n' == *current) {
42
+ xline++;
43
+ }
41
44
  }
42
45
  ox_err_set(err, ox_parse_error_class, "%s at line %d, column %d [%s:%d]\n", msg, xline, col, file, line);
43
46
  }
data/ext/ox/err.h CHANGED
@@ -11,26 +11,25 @@
11
11
  #define set_error(err, msg, xml, current) _ox_err_set_with_location(err, msg, xml, current, __FILE__, __LINE__)
12
12
 
13
13
  typedef struct _err {
14
- VALUE clas;
15
- char msg[128];
14
+ VALUE clas;
15
+ char msg[128];
16
16
  } *Err;
17
17
 
18
- extern VALUE ox_arg_error_class;
19
- extern VALUE ox_parse_error_class;
20
- extern VALUE ox_syntax_error_class;
18
+ extern VALUE ox_arg_error_class;
19
+ extern VALUE ox_parse_error_class;
20
+ extern VALUE ox_syntax_error_class;
21
21
 
22
- extern void ox_err_set(Err e, VALUE clas, const char *format, ...);
23
- extern void _ox_err_set_with_location(Err err, const char *msg, const char *xml, const char *current, const char* file, int line);
24
- extern void ox_err_raise(Err e);
22
+ extern void ox_err_set(Err e, VALUE clas, const char *format, ...);
23
+ extern void
24
+ _ox_err_set_with_location(Err err, const char *msg, const char *xml, const char *current, const char *file, int line);
25
+ extern void ox_err_raise(Err e);
25
26
 
26
- inline static void
27
- err_init(Err e) {
27
+ inline static void err_init(Err e) {
28
28
  e->clas = Qnil;
29
29
  *e->msg = '\0';
30
30
  }
31
31
 
32
- inline static int
33
- err_has(Err e) {
32
+ inline static int err_has(Err e) {
34
33
  return (Qnil != e->clas);
35
34
  }
36
35
 
data/ext/ox/extconf.rb CHANGED
@@ -4,7 +4,7 @@ extension_name = 'ox'
4
4
  dir_config(extension_name)
5
5
 
6
6
  parts = RUBY_DESCRIPTION.split(' ')
7
- type = parts[0].downcase()
7
+ type = parts[0].downcase
8
8
  type = 'ree' if 'ruby' == type && RUBY_DESCRIPTION.include?('Ruby Enterprise Edition')
9
9
  platform = RUBY_PLATFORM
10
10
  version = RUBY_VERSION.split('.')
@@ -16,10 +16,10 @@ dflags = {
16
16
  'RUBY_VERSION' => RUBY_VERSION,
17
17
  'RUBY_VERSION_MAJOR' => version[0],
18
18
  'RUBY_VERSION_MINOR' => version[1],
19
- 'RUBY_VERSION_MICRO' => version[2],
19
+ 'RUBY_VERSION_MICRO' => version[2]
20
20
  }
21
21
 
22
- dflags.each do |k,v|
22
+ dflags.each do |k, v|
23
23
  if v.nil?
24
24
  $CPPFLAGS += " -D#{k}"
25
25
  else
@@ -27,19 +27,14 @@ dflags.each do |k,v|
27
27
  end
28
28
  end
29
29
  $CPPFLAGS += ' -Wall'
30
- #puts "*** $CPPFLAGS: #{$CPPFLAGS}"
30
+ # puts "*** $CPPFLAGS: #{$CPPFLAGS}"
31
31
  CONFIG['warnflags'].slice!(/ -Wsuggest-attribute=format/)
32
32
  CONFIG['warnflags'].slice!(/ -Wdeclaration-after-statement/)
33
33
  CONFIG['warnflags'].slice!(/ -Wmissing-noreturn/)
34
34
 
35
- have_func('rb_time_timespec')
36
- have_func('rb_struct_alloc_noinit')
37
- have_func('rb_obj_encoding')
38
- have_func('rb_ivar_foreach')
39
35
  have_func('rb_ext_ractor_safe', 'ruby.h')
40
36
  have_func('pthread_mutex_init')
41
37
  have_func('rb_enc_interned_str')
42
- have_func('rb_time_nano_new')
43
38
  have_func('index')
44
39
 
45
40
  have_header('ruby/st.h')
@@ -49,4 +44,4 @@ have_struct_member('struct tm', 'tm_gmtoff')
49
44
 
50
45
  create_makefile(extension_name)
51
46
 
52
- %x{make clean}
47
+ `make clean`
data/ext/ox/gen_load.c CHANGED
@@ -3,32 +3,32 @@
3
3
  * All rights reserved.
4
4
  */
5
5
 
6
- #include <stdlib.h>
7
6
  #include <errno.h>
7
+ #include <stdarg.h>
8
8
  #include <stdio.h>
9
+ #include <stdlib.h>
9
10
  #include <string.h>
10
- #include <stdarg.h>
11
11
 
12
+ #include "intern.h"
13
+ #include "ox.h"
12
14
  #include "ruby.h"
13
15
  #include "ruby/encoding.h"
14
- #include "ox.h"
15
- #include "intern.h"
16
16
 
17
- static void instruct(PInfo pi, const char *target, Attr attrs, const char *content);
18
- static void create_doc(PInfo pi);
19
- static void create_prolog_doc(PInfo pi, const char *target, Attr attrs);
20
- static void nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content);
21
- static void add_doctype(PInfo pi, const char *docType);
22
- static void add_comment(PInfo pi, const char *comment);
23
- static void add_cdata(PInfo pi, const char *cdata, size_t len);
24
- static void add_text(PInfo pi, char *text, int closed);
25
- static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren);
26
- static void end_element(PInfo pi, const char *ename);
27
- static void add_instruct(PInfo pi, const char *name, Attr attrs, const char *content);
28
-
29
- extern ParseCallbacks ox_obj_callbacks;
30
-
31
- struct _parseCallbacks _ox_gen_callbacks = {
17
+ static void instruct(PInfo pi, const char *target, Attr attrs, const char *content);
18
+ static void create_doc(PInfo pi);
19
+ static void create_prolog_doc(PInfo pi, const char *target, Attr attrs);
20
+ static void nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content);
21
+ static void add_doctype(PInfo pi, const char *docType);
22
+ static void add_comment(PInfo pi, const char *comment);
23
+ static void add_cdata(PInfo pi, const char *cdata, size_t len);
24
+ static void add_text(PInfo pi, char *text, int closed);
25
+ static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren);
26
+ static void end_element(PInfo pi, const char *ename);
27
+ static void add_instruct(PInfo pi, const char *name, Attr attrs, const char *content);
28
+
29
+ extern ParseCallbacks ox_obj_callbacks;
30
+
31
+ struct _parseCallbacks _ox_gen_callbacks = {
32
32
  instruct, /* instruct, */
33
33
  add_doctype,
34
34
  add_comment,
@@ -39,9 +39,9 @@ struct _parseCallbacks _ox_gen_callbacks = {
39
39
  NULL,
40
40
  };
41
41
 
42
- ParseCallbacks ox_gen_callbacks = &_ox_gen_callbacks;
42
+ ParseCallbacks ox_gen_callbacks = &_ox_gen_callbacks;
43
43
 
44
- struct _parseCallbacks _ox_limited_callbacks = {
44
+ struct _parseCallbacks _ox_limited_callbacks = {
45
45
  0,
46
46
  0,
47
47
  0,
@@ -52,9 +52,9 @@ struct _parseCallbacks _ox_limited_callbacks = {
52
52
  NULL,
53
53
  };
54
54
 
55
- ParseCallbacks ox_limited_callbacks = &_ox_limited_callbacks;
55
+ ParseCallbacks ox_limited_callbacks = &_ox_limited_callbacks;
56
56
 
57
- struct _parseCallbacks _ox_nomode_callbacks = {
57
+ struct _parseCallbacks _ox_nomode_callbacks = {
58
58
  nomode_instruct,
59
59
  add_doctype,
60
60
  add_comment,
@@ -65,18 +65,15 @@ struct _parseCallbacks _ox_nomode_callbacks = {
65
65
  NULL,
66
66
  };
67
67
 
68
- ParseCallbacks ox_nomode_callbacks = &_ox_nomode_callbacks;
68
+ ParseCallbacks ox_nomode_callbacks = &_ox_nomode_callbacks;
69
69
 
70
- static void
71
- create_doc(PInfo pi) {
72
- VALUE doc;
73
- VALUE nodes;
70
+ static void create_doc(PInfo pi) {
71
+ VALUE doc;
72
+ VALUE nodes;
74
73
 
75
74
  helper_stack_init(&pi->helpers);
76
75
  doc = rb_obj_alloc(ox_document_clas);
77
- #ifdef RB_GC_GUARD
78
76
  RB_GC_GUARD(doc);
79
- #endif
80
77
  nodes = rb_ary_new();
81
78
  rb_ivar_set(doc, ox_attributes_id, rb_hash_new());
82
79
  rb_ivar_set(doc, ox_nodes_id, nodes);
@@ -84,45 +81,44 @@ create_doc(PInfo pi) {
84
81
  pi->obj = doc;
85
82
  }
86
83
 
87
- static void
88
- create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
89
- volatile VALUE doc;
90
- volatile VALUE ah;
91
- volatile VALUE nodes;
92
- volatile VALUE sym;
84
+ static void create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
85
+ volatile VALUE doc;
86
+ volatile VALUE ah;
87
+ volatile VALUE nodes;
88
+ volatile VALUE sym;
93
89
 
94
90
  if (!helper_stack_empty(&pi->helpers)) { /* top level object */
95
91
  ox_err_set(&pi->err, ox_syntax_error_class, "Prolog must be the first element in an XML document.\n");
96
- return;
92
+ return;
97
93
  }
98
94
  doc = rb_obj_alloc(ox_document_clas);
99
- ah = rb_hash_new();
95
+ ah = rb_hash_new();
100
96
  for (; 0 != attrs->name; attrs++) {
101
- if (Qnil != pi->options->attr_key_mod) {
102
- sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
103
- rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
104
- } else if (Yes == pi->options->sym_keys) {
105
- if (0 != pi->options->rb_enc) {
106
- VALUE rstr = rb_str_new2(attrs->name);
107
-
108
- rb_enc_associate(rstr, pi->options->rb_enc);
109
- sym = rb_funcall(rstr, ox_to_sym_id, 0);
110
- } else {
111
- sym = ID2SYM(rb_intern(attrs->name));
112
- }
113
- sym = ID2SYM(rb_intern(attrs->name));
114
- rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
115
- } else {
116
- volatile VALUE rstr = rb_str_new2(attrs->name);
117
-
118
- if (0 != pi->options->rb_enc) {
119
- rb_enc_associate(rstr, pi->options->rb_enc);
120
- }
121
- rb_hash_aset(ah, rstr, rb_str_new2(attrs->value));
122
- }
123
- if (0 == strcmp("encoding", attrs->name)) {
124
- pi->options->rb_enc = rb_enc_find(attrs->value);
125
- }
97
+ if (Qnil != pi->options->attr_key_mod) {
98
+ sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
99
+ rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
100
+ } else if (Yes == pi->options->sym_keys) {
101
+ if (0 != pi->options->rb_enc) {
102
+ VALUE rstr = rb_str_new2(attrs->name);
103
+
104
+ rb_enc_associate(rstr, pi->options->rb_enc);
105
+ sym = rb_str_intern(rstr);
106
+ } else {
107
+ sym = ID2SYM(rb_intern(attrs->name));
108
+ }
109
+ sym = ID2SYM(rb_intern(attrs->name));
110
+ rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
111
+ } else {
112
+ volatile VALUE rstr = rb_str_new2(attrs->name);
113
+
114
+ if (0 != pi->options->rb_enc) {
115
+ rb_enc_associate(rstr, pi->options->rb_enc);
116
+ }
117
+ rb_hash_aset(ah, rstr, rb_str_new2(attrs->value));
118
+ }
119
+ if (0 == strcmp("encoding", attrs->name)) {
120
+ pi->options->rb_enc = rb_enc_find(attrs->value);
121
+ }
126
122
  }
127
123
  nodes = rb_ary_new();
128
124
  rb_ivar_set(doc, ox_attributes_id, ah);
@@ -131,50 +127,57 @@ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
131
127
  pi->obj = doc;
132
128
  }
133
129
 
134
- static void
135
- instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
130
+ static void instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
136
131
  if (0 == strcmp("xml", target)) {
137
132
  create_prolog_doc(pi, target, attrs);
138
133
  } else if (0 == strcmp("ox", target)) {
139
134
  for (; 0 != attrs->name; attrs++) {
140
135
  if (0 == strcmp("version", attrs->name)) {
141
136
  if (0 != strcmp("1.0", attrs->value)) {
142
- ox_err_set(&pi->err, ox_syntax_error_class, "Only Ox XML Object version 1.0 supported, not %s.\n", attrs->value);
143
- return;
137
+ ox_err_set(&pi->err,
138
+ ox_syntax_error_class,
139
+ "Only Ox XML Object version 1.0 supported, not %s.\n",
140
+ attrs->value);
141
+ return;
144
142
  }
145
143
  }
146
144
  /* ignore other instructions */
147
145
  }
148
146
  } else {
149
- add_instruct(pi, target, attrs, content);
147
+ add_instruct(pi, target, attrs, content);
150
148
  }
151
149
  }
152
150
 
153
- static void
154
- nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
151
+ static void nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
155
152
  if (0 == strcmp("xml", target)) {
156
153
  create_prolog_doc(pi, target, attrs);
157
154
  } else if (0 == strcmp("ox", target)) {
158
155
  for (; 0 != attrs->name; attrs++) {
159
156
  if (0 == strcmp("version", attrs->name)) {
160
157
  if (0 != strcmp("1.0", attrs->value)) {
161
- ox_err_set(&pi->err, ox_syntax_error_class, "Only Ox XML Object version 1.0 supported, not %s.\n", attrs->value);
162
- return;
158
+ ox_err_set(&pi->err,
159
+ ox_syntax_error_class,
160
+ "Only Ox XML Object version 1.0 supported, not %s.\n",
161
+ attrs->value);
162
+ return;
163
163
  }
164
164
  } else if (0 == strcmp("mode", attrs->name)) {
165
165
  if (0 == strcmp("object", attrs->value)) {
166
166
  pi->pcb = ox_obj_callbacks;
167
167
  pi->obj = Qnil;
168
- helper_stack_init(&pi->helpers);
168
+ helper_stack_init(&pi->helpers);
169
169
  } else if (0 == strcmp("generic", attrs->value)) {
170
170
  pi->pcb = ox_gen_callbacks;
171
171
  } else if (0 == strcmp("limited", attrs->value)) {
172
172
  pi->pcb = ox_limited_callbacks;
173
173
  pi->obj = Qnil;
174
- helper_stack_init(&pi->helpers);
174
+ helper_stack_init(&pi->helpers);
175
175
  } else {
176
- ox_err_set(&pi->err, ox_syntax_error_class, "%s is not a valid processing instruction mode.\n", attrs->value);
177
- return;
176
+ ox_err_set(&pi->err,
177
+ ox_syntax_error_class,
178
+ "%s is not a valid processing instruction mode.\n",
179
+ attrs->value);
180
+ return;
178
181
  }
179
182
  }
180
183
  }
@@ -185,71 +188,66 @@ nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
185
188
  }
186
189
  }
187
190
 
188
- static void
189
- add_doctype(PInfo pi, const char *docType) {
190
- VALUE n = rb_obj_alloc(ox_doctype_clas);
191
- VALUE s = rb_str_new2(docType);
191
+ static void add_doctype(PInfo pi, const char *docType) {
192
+ VALUE n = rb_obj_alloc(ox_doctype_clas);
193
+ VALUE s = rb_str_new2(docType);
192
194
 
193
195
  if (0 != pi->options->rb_enc) {
194
196
  rb_enc_associate(s, pi->options->rb_enc);
195
197
  }
196
198
  rb_ivar_set(n, ox_at_value_id, s);
197
199
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
198
- create_doc(pi);
200
+ create_doc(pi);
199
201
  }
200
202
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, n);
201
203
  }
202
204
 
203
- static void
204
- add_comment(PInfo pi, const char *comment) {
205
- VALUE n = rb_obj_alloc(ox_comment_clas);
206
- VALUE s = rb_str_new2(comment);
205
+ static void add_comment(PInfo pi, const char *comment) {
206
+ VALUE n = rb_obj_alloc(ox_comment_clas);
207
+ VALUE s = rb_str_new2(comment);
207
208
 
208
209
  if (0 != pi->options->rb_enc) {
209
210
  rb_enc_associate(s, pi->options->rb_enc);
210
211
  }
211
212
  rb_ivar_set(n, ox_at_value_id, s);
212
213
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
213
- create_doc(pi);
214
+ create_doc(pi);
214
215
  }
215
216
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, n);
216
217
  }
217
218
 
218
- static void
219
- add_cdata(PInfo pi, const char *cdata, size_t len) {
220
- VALUE n = rb_obj_alloc(ox_cdata_clas);
221
- VALUE s = rb_str_new2(cdata);
219
+ static void add_cdata(PInfo pi, const char *cdata, size_t len) {
220
+ VALUE n = rb_obj_alloc(ox_cdata_clas);
221
+ VALUE s = rb_str_new2(cdata);
222
222
 
223
223
  if (0 != pi->options->rb_enc) {
224
224
  rb_enc_associate(s, pi->options->rb_enc);
225
225
  }
226
226
  rb_ivar_set(n, ox_at_value_id, s);
227
227
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
228
- create_doc(pi);
228
+ create_doc(pi);
229
229
  }
230
230
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, n);
231
231
  }
232
232
 
233
- static void
234
- add_text(PInfo pi, char *text, int closed) {
235
- VALUE s = rb_str_new2(text);
233
+ static void add_text(PInfo pi, char *text, int closed) {
234
+ VALUE s = rb_str_new2(text);
236
235
 
237
236
  if (0 != pi->options->rb_enc) {
238
237
  rb_enc_associate(s, pi->options->rb_enc);
239
238
  }
240
239
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
241
- create_doc(pi);
240
+ create_doc(pi);
242
241
  }
243
242
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, s);
244
243
  }
245
244
 
246
- static void
247
- add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
248
- VALUE e;
249
- VALUE s = rb_str_new2(ename);
245
+ static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
246
+ VALUE e;
247
+ VALUE s = rb_str_new2(ename);
250
248
 
251
249
  if (Qnil != pi->options->element_key_mod) {
252
- s = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, s);
250
+ s = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, s);
253
251
  }
254
252
  if (0 != pi->options->rb_enc) {
255
253
  rb_enc_associate(s, pi->options->rb_enc);
@@ -257,18 +255,18 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
257
255
  e = rb_obj_alloc(ox_element_clas);
258
256
  rb_ivar_set(e, ox_at_value_id, s);
259
257
  if (0 != attrs->name) {
260
- volatile VALUE ah = rb_hash_new();
258
+ volatile VALUE ah = rb_hash_new();
261
259
 
262
260
  for (; 0 != attrs->name; attrs++) {
263
- volatile VALUE sym;
264
-
265
- if (Qnil != pi->options->attr_key_mod) {
266
- sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
267
- } else if (Yes == pi->options->sym_keys) {
268
- sym = ox_sym_intern(attrs->name, strlen(attrs->name), NULL);
269
- } else {
270
- sym = ox_str_intern(attrs->name, strlen(attrs->name), NULL);
271
- }
261
+ volatile VALUE sym;
262
+
263
+ if (Qnil != pi->options->attr_key_mod) {
264
+ sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
265
+ } else if (Yes == pi->options->sym_keys) {
266
+ sym = ox_sym_intern(attrs->name, strlen(attrs->name), NULL);
267
+ } else {
268
+ sym = ox_str_intern(attrs->name, strlen(attrs->name), NULL);
269
+ }
272
270
  s = rb_str_new2(attrs->value);
273
271
  if (0 != pi->options->rb_enc) {
274
272
  rb_enc_associate(s, pi->options->rb_enc);
@@ -278,59 +276,57 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
278
276
  rb_ivar_set(e, ox_attributes_id, ah);
279
277
  }
280
278
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
281
- pi->obj = e;
279
+ pi->obj = e;
282
280
  } else {
283
- rb_ary_push(helper_stack_peek(&pi->helpers)->obj, e);
281
+ rb_ary_push(helper_stack_peek(&pi->helpers)->obj, e);
284
282
  }
285
283
  if (hasChildren) {
286
- VALUE nodes = rb_ary_new();
284
+ VALUE nodes = rb_ary_new();
287
285
 
288
286
  rb_ivar_set(e, ox_nodes_id, nodes);
289
- helper_stack_push(&pi->helpers, 0, nodes, NoCode);
287
+ helper_stack_push(&pi->helpers, 0, nodes, NoCode);
290
288
  } else {
291
- helper_stack_push(&pi->helpers, 0, Qnil, NoCode); // will be popped in end_element
289
+ helper_stack_push(&pi->helpers, 0, Qnil, NoCode); // will be popped in end_element
292
290
  }
293
291
  }
294
292
 
295
- static void
296
- end_element(PInfo pi, const char *ename) {
293
+ static void end_element(PInfo pi, const char *ename) {
297
294
  if (!helper_stack_empty(&pi->helpers)) {
298
- helper_stack_pop(&pi->helpers);
295
+ helper_stack_pop(&pi->helpers);
299
296
  }
300
297
  }
301
298
 
302
- static void
303
- add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
304
- VALUE inst;
305
- VALUE s = rb_str_new2(name);
306
- VALUE c = Qnil;
299
+ static void add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
300
+ VALUE inst;
301
+ VALUE s = rb_str_new2(name);
302
+ VALUE c = Qnil;
307
303
 
308
304
  if (0 != content) {
309
- c = rb_str_new2(content);
305
+ c = rb_str_new2(content);
310
306
  }
311
307
  if (0 != pi->options->rb_enc) {
312
308
  rb_enc_associate(s, pi->options->rb_enc);
313
- if (0 != content) {
314
- rb_enc_associate(c, pi->options->rb_enc);
315
- }
309
+ if (0 != content) {
310
+ rb_enc_associate(c, pi->options->rb_enc);
311
+ }
316
312
  }
317
313
  inst = rb_obj_alloc(ox_instruct_clas);
318
314
  rb_ivar_set(inst, ox_at_value_id, s);
319
315
  if (0 != content) {
320
- rb_ivar_set(inst, ox_at_content_id, c);
316
+ rb_ivar_set(inst, ox_at_content_id, c);
321
317
  } else if (0 != attrs->name) {
322
- volatile VALUE ah = rb_hash_new();
318
+ volatile VALUE ah = rb_hash_new();
323
319
 
324
320
  for (; 0 != attrs->name; attrs++) {
325
- volatile VALUE sym;
326
-
327
- if (Qnil != pi->options->attr_key_mod) {
328
- sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
329
- } else if (Yes == pi->options->sym_keys) {
330
- sym = ox_sym_intern(attrs->name, strlen(attrs->name), NULL);
331
- } else {
332
- sym = ox_str_intern(attrs->name, strlen(attrs->name), NULL);
333
- }
321
+ volatile VALUE sym;
322
+
323
+ if (Qnil != pi->options->attr_key_mod) {
324
+ sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
325
+ } else if (Yes == pi->options->sym_keys) {
326
+ sym = ox_sym_intern(attrs->name, strlen(attrs->name), NULL);
327
+ } else {
328
+ sym = ox_str_intern(attrs->name, strlen(attrs->name), NULL);
329
+ }
334
330
  s = rb_str_new2(attrs->value);
335
331
  if (0 != pi->options->rb_enc) {
336
332
  rb_enc_associate(s, pi->options->rb_enc);
@@ -340,7 +336,7 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
340
336
  rb_ivar_set(inst, ox_attributes_id, ah);
341
337
  }
342
338
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
343
- create_doc(pi);
339
+ create_doc(pi);
344
340
  }
345
341
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, inst);
346
342
  }