ox 2.14.14 → 2.14.15

Sign up to get free protection for your applications and to get access to all the features.
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,7 +27,7 @@ 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/)
@@ -49,4 +49,4 @@ have_struct_member('struct tm', 'tm_gmtoff')
49
49
 
50
50
  create_makefile(extension_name)
51
51
 
52
- %x{make clean}
52
+ `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,12 +65,11 @@ 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);
@@ -84,45 +83,44 @@ create_doc(PInfo pi) {
84
83
  pi->obj = doc;
85
84
  }
86
85
 
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;
86
+ static void create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
87
+ volatile VALUE doc;
88
+ volatile VALUE ah;
89
+ volatile VALUE nodes;
90
+ volatile VALUE sym;
93
91
 
94
92
  if (!helper_stack_empty(&pi->helpers)) { /* top level object */
95
93
  ox_err_set(&pi->err, ox_syntax_error_class, "Prolog must be the first element in an XML document.\n");
96
- return;
94
+ return;
97
95
  }
98
96
  doc = rb_obj_alloc(ox_document_clas);
99
- ah = rb_hash_new();
97
+ ah = rb_hash_new();
100
98
  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
- }
99
+ if (Qnil != pi->options->attr_key_mod) {
100
+ sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
101
+ rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
102
+ } else if (Yes == pi->options->sym_keys) {
103
+ if (0 != pi->options->rb_enc) {
104
+ VALUE rstr = rb_str_new2(attrs->name);
105
+
106
+ rb_enc_associate(rstr, pi->options->rb_enc);
107
+ sym = rb_funcall(rstr, ox_to_sym_id, 0);
108
+ } else {
109
+ sym = ID2SYM(rb_intern(attrs->name));
110
+ }
111
+ sym = ID2SYM(rb_intern(attrs->name));
112
+ rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
113
+ } else {
114
+ volatile VALUE rstr = rb_str_new2(attrs->name);
115
+
116
+ if (0 != pi->options->rb_enc) {
117
+ rb_enc_associate(rstr, pi->options->rb_enc);
118
+ }
119
+ rb_hash_aset(ah, rstr, rb_str_new2(attrs->value));
120
+ }
121
+ if (0 == strcmp("encoding", attrs->name)) {
122
+ pi->options->rb_enc = rb_enc_find(attrs->value);
123
+ }
126
124
  }
127
125
  nodes = rb_ary_new();
128
126
  rb_ivar_set(doc, ox_attributes_id, ah);
@@ -131,50 +129,57 @@ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
131
129
  pi->obj = doc;
132
130
  }
133
131
 
134
- static void
135
- instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
132
+ static void instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
136
133
  if (0 == strcmp("xml", target)) {
137
134
  create_prolog_doc(pi, target, attrs);
138
135
  } else if (0 == strcmp("ox", target)) {
139
136
  for (; 0 != attrs->name; attrs++) {
140
137
  if (0 == strcmp("version", attrs->name)) {
141
138
  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;
139
+ ox_err_set(&pi->err,
140
+ ox_syntax_error_class,
141
+ "Only Ox XML Object version 1.0 supported, not %s.\n",
142
+ attrs->value);
143
+ return;
144
144
  }
145
145
  }
146
146
  /* ignore other instructions */
147
147
  }
148
148
  } else {
149
- add_instruct(pi, target, attrs, content);
149
+ add_instruct(pi, target, attrs, content);
150
150
  }
151
151
  }
152
152
 
153
- static void
154
- nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
153
+ static void nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
155
154
  if (0 == strcmp("xml", target)) {
156
155
  create_prolog_doc(pi, target, attrs);
157
156
  } else if (0 == strcmp("ox", target)) {
158
157
  for (; 0 != attrs->name; attrs++) {
159
158
  if (0 == strcmp("version", attrs->name)) {
160
159
  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;
160
+ ox_err_set(&pi->err,
161
+ ox_syntax_error_class,
162
+ "Only Ox XML Object version 1.0 supported, not %s.\n",
163
+ attrs->value);
164
+ return;
163
165
  }
164
166
  } else if (0 == strcmp("mode", attrs->name)) {
165
167
  if (0 == strcmp("object", attrs->value)) {
166
168
  pi->pcb = ox_obj_callbacks;
167
169
  pi->obj = Qnil;
168
- helper_stack_init(&pi->helpers);
170
+ helper_stack_init(&pi->helpers);
169
171
  } else if (0 == strcmp("generic", attrs->value)) {
170
172
  pi->pcb = ox_gen_callbacks;
171
173
  } else if (0 == strcmp("limited", attrs->value)) {
172
174
  pi->pcb = ox_limited_callbacks;
173
175
  pi->obj = Qnil;
174
- helper_stack_init(&pi->helpers);
176
+ helper_stack_init(&pi->helpers);
175
177
  } else {
176
- ox_err_set(&pi->err, ox_syntax_error_class, "%s is not a valid processing instruction mode.\n", attrs->value);
177
- return;
178
+ ox_err_set(&pi->err,
179
+ ox_syntax_error_class,
180
+ "%s is not a valid processing instruction mode.\n",
181
+ attrs->value);
182
+ return;
178
183
  }
179
184
  }
180
185
  }
@@ -185,71 +190,66 @@ nomode_instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
185
190
  }
186
191
  }
187
192
 
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);
193
+ static void add_doctype(PInfo pi, const char *docType) {
194
+ VALUE n = rb_obj_alloc(ox_doctype_clas);
195
+ VALUE s = rb_str_new2(docType);
192
196
 
193
197
  if (0 != pi->options->rb_enc) {
194
198
  rb_enc_associate(s, pi->options->rb_enc);
195
199
  }
196
200
  rb_ivar_set(n, ox_at_value_id, s);
197
201
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
198
- create_doc(pi);
202
+ create_doc(pi);
199
203
  }
200
204
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, n);
201
205
  }
202
206
 
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);
207
+ static void add_comment(PInfo pi, const char *comment) {
208
+ VALUE n = rb_obj_alloc(ox_comment_clas);
209
+ VALUE s = rb_str_new2(comment);
207
210
 
208
211
  if (0 != pi->options->rb_enc) {
209
212
  rb_enc_associate(s, pi->options->rb_enc);
210
213
  }
211
214
  rb_ivar_set(n, ox_at_value_id, s);
212
215
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
213
- create_doc(pi);
216
+ create_doc(pi);
214
217
  }
215
218
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, n);
216
219
  }
217
220
 
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);
221
+ static void add_cdata(PInfo pi, const char *cdata, size_t len) {
222
+ VALUE n = rb_obj_alloc(ox_cdata_clas);
223
+ VALUE s = rb_str_new2(cdata);
222
224
 
223
225
  if (0 != pi->options->rb_enc) {
224
226
  rb_enc_associate(s, pi->options->rb_enc);
225
227
  }
226
228
  rb_ivar_set(n, ox_at_value_id, s);
227
229
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
228
- create_doc(pi);
230
+ create_doc(pi);
229
231
  }
230
232
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, n);
231
233
  }
232
234
 
233
- static void
234
- add_text(PInfo pi, char *text, int closed) {
235
- VALUE s = rb_str_new2(text);
235
+ static void add_text(PInfo pi, char *text, int closed) {
236
+ VALUE s = rb_str_new2(text);
236
237
 
237
238
  if (0 != pi->options->rb_enc) {
238
239
  rb_enc_associate(s, pi->options->rb_enc);
239
240
  }
240
241
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
241
- create_doc(pi);
242
+ create_doc(pi);
242
243
  }
243
244
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, s);
244
245
  }
245
246
 
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);
247
+ static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
248
+ VALUE e;
249
+ VALUE s = rb_str_new2(ename);
250
250
 
251
251
  if (Qnil != pi->options->element_key_mod) {
252
- s = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, s);
252
+ s = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, s);
253
253
  }
254
254
  if (0 != pi->options->rb_enc) {
255
255
  rb_enc_associate(s, pi->options->rb_enc);
@@ -257,18 +257,18 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
257
257
  e = rb_obj_alloc(ox_element_clas);
258
258
  rb_ivar_set(e, ox_at_value_id, s);
259
259
  if (0 != attrs->name) {
260
- volatile VALUE ah = rb_hash_new();
260
+ volatile VALUE ah = rb_hash_new();
261
261
 
262
262
  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
- }
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
+ }
272
272
  s = rb_str_new2(attrs->value);
273
273
  if (0 != pi->options->rb_enc) {
274
274
  rb_enc_associate(s, pi->options->rb_enc);
@@ -278,59 +278,57 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
278
278
  rb_ivar_set(e, ox_attributes_id, ah);
279
279
  }
280
280
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
281
- pi->obj = e;
281
+ pi->obj = e;
282
282
  } else {
283
- rb_ary_push(helper_stack_peek(&pi->helpers)->obj, e);
283
+ rb_ary_push(helper_stack_peek(&pi->helpers)->obj, e);
284
284
  }
285
285
  if (hasChildren) {
286
- VALUE nodes = rb_ary_new();
286
+ VALUE nodes = rb_ary_new();
287
287
 
288
288
  rb_ivar_set(e, ox_nodes_id, nodes);
289
- helper_stack_push(&pi->helpers, 0, nodes, NoCode);
289
+ helper_stack_push(&pi->helpers, 0, nodes, NoCode);
290
290
  } else {
291
- helper_stack_push(&pi->helpers, 0, Qnil, NoCode); // will be popped in end_element
291
+ helper_stack_push(&pi->helpers, 0, Qnil, NoCode); // will be popped in end_element
292
292
  }
293
293
  }
294
294
 
295
- static void
296
- end_element(PInfo pi, const char *ename) {
295
+ static void end_element(PInfo pi, const char *ename) {
297
296
  if (!helper_stack_empty(&pi->helpers)) {
298
- helper_stack_pop(&pi->helpers);
297
+ helper_stack_pop(&pi->helpers);
299
298
  }
300
299
  }
301
300
 
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;
301
+ static void add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
302
+ VALUE inst;
303
+ VALUE s = rb_str_new2(name);
304
+ VALUE c = Qnil;
307
305
 
308
306
  if (0 != content) {
309
- c = rb_str_new2(content);
307
+ c = rb_str_new2(content);
310
308
  }
311
309
  if (0 != pi->options->rb_enc) {
312
310
  rb_enc_associate(s, pi->options->rb_enc);
313
- if (0 != content) {
314
- rb_enc_associate(c, pi->options->rb_enc);
315
- }
311
+ if (0 != content) {
312
+ rb_enc_associate(c, pi->options->rb_enc);
313
+ }
316
314
  }
317
315
  inst = rb_obj_alloc(ox_instruct_clas);
318
316
  rb_ivar_set(inst, ox_at_value_id, s);
319
317
  if (0 != content) {
320
- rb_ivar_set(inst, ox_at_content_id, c);
318
+ rb_ivar_set(inst, ox_at_content_id, c);
321
319
  } else if (0 != attrs->name) {
322
- volatile VALUE ah = rb_hash_new();
320
+ volatile VALUE ah = rb_hash_new();
323
321
 
324
322
  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
- }
323
+ volatile VALUE sym;
324
+
325
+ if (Qnil != pi->options->attr_key_mod) {
326
+ sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
327
+ } else if (Yes == pi->options->sym_keys) {
328
+ sym = ox_sym_intern(attrs->name, strlen(attrs->name), NULL);
329
+ } else {
330
+ sym = ox_str_intern(attrs->name, strlen(attrs->name), NULL);
331
+ }
334
332
  s = rb_str_new2(attrs->value);
335
333
  if (0 != pi->options->rb_enc) {
336
334
  rb_enc_associate(s, pi->options->rb_enc);
@@ -340,7 +338,7 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
340
338
  rb_ivar_set(inst, ox_attributes_id, ah);
341
339
  }
342
340
  if (helper_stack_empty(&pi->helpers)) { /* top level object */
343
- create_doc(pi);
341
+ create_doc(pi);
344
342
  }
345
343
  rb_ary_push(helper_stack_peek(&pi->helpers)->obj, inst);
346
344
  }