ox 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ox might be problematic. Click here for more details.

@@ -38,6 +38,7 @@
38
38
  #include "ox.h"
39
39
 
40
40
  static void instruct(PInfo pi, const char *target, Attr attrs);
41
+ static void create_prolog_doc(PInfo pi, const char *target, Attr attrs);
41
42
  static void nomode_instruct(PInfo pi, const char *target, Attr attrs);
42
43
  static void add_doctype(PInfo pi, const char *docType);
43
44
  static void add_comment(PInfo pi, const char *comment);
@@ -85,29 +86,36 @@ struct _ParseCallbacks _ox_nomode_callbacks = {
85
86
  ParseCallbacks ox_nomode_callbacks = &_ox_nomode_callbacks;
86
87
 
87
88
  static void
88
- instruct(PInfo pi, const char *target, Attr attrs) {
89
- if (0 == strcmp("xml", target)) {
90
- VALUE doc;
91
- VALUE ah;
92
- VALUE nodes;
89
+ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
90
+ VALUE doc;
91
+ VALUE ah;
92
+ VALUE nodes;
93
93
 
94
- if (0 != pi->h) { // top level object
95
- rb_raise(rb_eEncodingError, "Prolog must be the first element in an XML document.\n");
96
- }
97
- pi->h = pi->helpers;
98
- doc = rb_obj_alloc(ox_document_clas);
99
- ah = rb_hash_new();
100
- for (; 0 != attrs->name; attrs++) {
101
- rb_hash_aset(ah, ID2SYM(rb_intern(attrs->name)), rb_str_new2(attrs->value));
102
- if (0 == strcmp("encoding", attrs->name)) {
103
- pi->encoding = rb_enc_find(attrs->value);
104
- }
94
+ if (0 != pi->h) { // top level object
95
+ rb_raise(rb_eEncodingError, "Prolog must be the first element in an XML document.\n");
96
+ }
97
+ pi->h = pi->helpers;
98
+ doc = rb_obj_alloc(ox_document_clas);
99
+ ah = rb_hash_new();
100
+ for (; 0 != attrs->name; attrs++) {
101
+ rb_hash_aset(ah, ID2SYM(rb_intern(attrs->name)), rb_str_new2(attrs->value));
102
+ if (0 == strcmp("encoding", attrs->name)) {
103
+ pi->encoding = rb_enc_find(attrs->value);
105
104
  }
106
- nodes = rb_ary_new();
107
- rb_ivar_set(doc, attributes_id, ah);
108
- rb_ivar_set(doc, nodes_id, nodes);
109
- pi->h->obj = nodes;
110
- pi->obj = doc;
105
+ }
106
+ nodes = rb_ary_new();
107
+ rb_ivar_set(doc, attributes_id, ah);
108
+ rb_ivar_set(doc, nodes_id, nodes);
109
+ pi->h->obj = nodes;
110
+ pi->obj = doc;
111
+ }
112
+
113
+
114
+
115
+ static void
116
+ instruct(PInfo pi, const char *target, Attr attrs) {
117
+ if (0 == strcmp("xml", target)) {
118
+ create_prolog_doc(pi, target, attrs);
111
119
  } else if (0 == strcmp("ox", target)) {
112
120
  for (; 0 != attrs->name; attrs++) {
113
121
  if (0 == strcmp("version", attrs->name)) {
@@ -127,27 +135,7 @@ instruct(PInfo pi, const char *target, Attr attrs) {
127
135
  static void
128
136
  nomode_instruct(PInfo pi, const char *target, Attr attrs) {
129
137
  if (0 == strcmp("xml", target)) {
130
- VALUE doc;
131
- VALUE ah;
132
- VALUE nodes;
133
-
134
- if (0 != pi->h) { // top level object
135
- rb_raise(rb_eEncodingError, "Prolog must be the first element in an XML document.\n");
136
- }
137
- pi->h = pi->helpers;
138
- doc = rb_obj_alloc(ox_document_clas);
139
- ah = rb_hash_new();
140
- for (; 0 != attrs->name; attrs++) {
141
- rb_hash_aset(ah, ID2SYM(rb_intern(attrs->name)), rb_str_new2(attrs->value));
142
- if (0 == strcmp("encoding", attrs->name)) {
143
- pi->encoding = rb_enc_find(attrs->value);
144
- }
145
- }
146
- nodes = rb_ary_new();
147
- rb_ivar_set(doc, attributes_id, ah);
148
- rb_ivar_set(doc, nodes_id, nodes);
149
- pi->h->obj = nodes;
150
- pi->obj = doc;
138
+ create_prolog_doc(pi, target, attrs);
151
139
  } else if (0 == strcmp("ox", target)) {
152
140
  for (; 0 != attrs->name; attrs++) {
153
141
  if (0 == strcmp("version", attrs->name)) {
@@ -47,8 +47,6 @@ static char* read_quoted_value(PInfo pi);
47
47
  static int read_coded_char(PInfo pi);
48
48
  static void next_non_white(PInfo pi);
49
49
 
50
- static int validateProlog = 1;
51
-
52
50
  /* This XML parser is a single pass, destructive, callback parser. It is a
53
51
  * single pass parse since it only make one pass over the characters in the
54
52
  * XML document string. It is destructive because it re-uses the content of
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 1.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Peter Ohler