ox 1.5.7 → 1.5.8

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.

@@ -61,50 +61,50 @@ enum st_retval {ST_CONTINUE = 0, ST_STOP = 1, ST_DELETE = 2, ST_CHECK};
61
61
 
62
62
  #define raise_error(msg, xml, current) _ox_raise_error(msg, xml, current, __FILE__, __LINE__)
63
63
 
64
- #define MAX_TEXT_LEN 4096
65
- #define MAX_ATTRS 1024
66
- #define MAX_DEPTH 1024
67
-
68
- #define SILENT 0
69
- #define TRACE 1
70
- #define DEBUG 2
71
-
72
- #define XSD_DATE 0x0001
73
- #define WITH_XML 0x0002
74
- #define WITH_INST 0x0004
75
- #define WITH_DTD 0x0008
76
- #define CIRCULAR 0x0010
77
-
78
- #define XSD_DATE_SET 0x0100
79
- #define WITH_XML_SET 0x0200
80
- #define WITH_INST_SET 0x0400
81
- #define WITH_DTD_SET 0x0800
82
- #define CIRCULAR_SET 0x1000
64
+ #define MAX_TEXT_LEN 4096
65
+ #define MAX_ATTRS 1024
66
+ #define MAX_DEPTH 1024
67
+
68
+ #define SILENT 0
69
+ #define TRACE 1
70
+ #define DEBUG 2
71
+
72
+ #define XSD_DATE 0x0001
73
+ #define WITH_XML 0x0002
74
+ #define WITH_INST 0x0004
75
+ #define WITH_DTD 0x0008
76
+ #define CIRCULAR 0x0010
77
+
78
+ #define XSD_DATE_SET 0x0100
79
+ #define WITH_XML_SET 0x0200
80
+ #define WITH_INST_SET 0x0400
81
+ #define WITH_DTD_SET 0x0800
82
+ #define CIRCULAR_SET 0x1000
83
83
 
84
84
  typedef enum {
85
- UseObj = 1,
86
- UseAttr = 2,
87
- UseAttrSet = 3,
88
- UseArray = 4,
89
- UseAMember = 5,
90
- UseHash = 6,
91
- UseHashKey = 7,
92
- UseHashVal = 8,
93
- UseRange = 9,
85
+ UseObj = 1,
86
+ UseAttr = 2,
87
+ UseAttrSet = 3,
88
+ UseArray = 4,
89
+ UseAMember = 5,
90
+ UseHash = 6,
91
+ UseHashKey = 7,
92
+ UseHashVal = 8,
93
+ UseRange = 9,
94
94
  UseRangeAttr= 10,
95
- UseRaw = 11,
95
+ UseRaw = 11,
96
96
  } Use;
97
97
 
98
98
  typedef enum {
99
99
  StrictEffort = 's',
100
100
  TolerantEffort = 't',
101
- AutoEffort = 'a',
102
- NoEffort = 0,
101
+ AutoEffort = 'a',
102
+ NoEffort = 0,
103
103
  } Effort;
104
104
 
105
105
  typedef enum {
106
- Yes = 'y',
107
- No = 'n',
106
+ Yes = 'y',
107
+ No = 'n',
108
108
  NotSet = 0
109
109
  } YesNo;
110
110
 
@@ -116,97 +116,97 @@ typedef enum {
116
116
  } LoadMode;
117
117
 
118
118
  typedef enum {
119
- NoCode = 0,
120
- ArrayCode = 'a',
119
+ NoCode = 0,
120
+ ArrayCode = 'a',
121
121
  String64Code = 'b', // base64 encoded String
122
- ClassCode = 'c',
122
+ ClassCode = 'c',
123
123
  Symbol64Code = 'd', // base64 encoded Symbol
124
- DateCode = 'D',
124
+ DateCode = 'D',
125
125
  ExceptionCode = 'e',
126
- FloatCode = 'f',
127
- RegexpCode = 'g',
128
- HashCode = 'h',
129
- FixnumCode = 'i',
130
- BignumCode = 'j',
131
- KeyCode = 'k', // indicates the value is a hash key, kind of a hack
126
+ FloatCode = 'f',
127
+ RegexpCode = 'g',
128
+ HashCode = 'h',
129
+ FixnumCode = 'i',
130
+ BignumCode = 'j',
131
+ KeyCode = 'k', // indicates the value is a hash key, kind of a hack
132
132
  RationalCode = 'l',
133
- SymbolCode = 'm',
133
+ SymbolCode = 'm',
134
134
  FalseClassCode = 'n',
135
- ObjectCode = 'o',
136
- RefCode = 'p',
137
- RangeCode = 'r',
138
- StringCode = 's',
139
- TimeCode = 't',
140
- StructCode = 'u',
141
- ComplexCode = 'v',
142
- RawCode = 'x',
135
+ ObjectCode = 'o',
136
+ RefCode = 'p',
137
+ RangeCode = 'r',
138
+ StringCode = 's',
139
+ TimeCode = 't',
140
+ StructCode = 'u',
141
+ ComplexCode = 'v',
142
+ RawCode = 'x',
143
143
  TrueClassCode = 'y',
144
144
  NilClassCode = 'z',
145
145
  } Type;
146
146
 
147
147
  typedef struct _Attr {
148
- const char *name;
149
- const char *value;
148
+ const char *name;
149
+ const char *value;
150
150
  } *Attr;
151
151
 
152
152
  typedef struct _Helper {
153
- ID var; /* Object var ID */
154
- VALUE obj; /* object created or Qundef if not appropriate */
155
- Type type; /* type of object in obj */
153
+ ID var; /* Object var ID */
154
+ VALUE obj; /* object created or Qundef if not appropriate */
155
+ Type type; /* type of object in obj */
156
156
  } *Helper;
157
157
 
158
- typedef struct _PInfo *PInfo;
158
+ typedef struct _PInfo *PInfo;
159
159
 
160
160
  typedef struct _ParseCallbacks {
161
- void (*instruct)(PInfo pi, const char *target, Attr attrs);
162
- void (*add_doctype)(PInfo pi, const char *docType);
163
- void (*add_comment)(PInfo pi, const char *comment);
164
- void (*add_cdata)(PInfo pi, const char *cdata, size_t len);
165
- void (*add_text)(PInfo pi, char *text, int closed);
166
- void (*add_element)(PInfo pi, const char *ename, Attr attrs, int hasChildren);
167
- void (*end_element)(PInfo pi, const char *ename);
161
+ void (*instruct)(PInfo pi, const char *target, Attr attrs);
162
+ void (*add_doctype)(PInfo pi, const char *docType);
163
+ void (*add_comment)(PInfo pi, const char *comment);
164
+ void (*add_cdata)(PInfo pi, const char *cdata, size_t len);
165
+ void (*add_text)(PInfo pi, char *text, int closed);
166
+ void (*add_element)(PInfo pi, const char *ename, Attr attrs, int hasChildren);
167
+ void (*end_element)(PInfo pi, const char *ename);
168
168
  } *ParseCallbacks;
169
169
 
170
170
  typedef struct _CircArray {
171
- VALUE obj_array[1024];
172
- VALUE *objs;
173
- unsigned long size; // allocated size or initial array size
174
- unsigned long cnt;
171
+ VALUE obj_array[1024];
172
+ VALUE *objs;
173
+ unsigned long size; // allocated size or initial array size
174
+ unsigned long cnt;
175
175
  } *CircArray;
176
176
 
177
+ typedef struct _Options {
178
+ char encoding[64]; // encoding, stored in the option to avoid GC invalidation in default values
179
+ int indent; // indention for dump, default 2
180
+ int trace; // trace level
181
+ char with_dtd; // YesNo
182
+ char with_xml; // YesNo
183
+ char with_instruct; // YesNo
184
+ char circular; // YesNo
185
+ char xsd_date; // YesNo
186
+ char mode; // LoadMode
187
+ char effort; // Effort
188
+ char sym_keys; // symbolize keys
189
+ } *Options;
190
+
177
191
  /* parse information structure */
178
192
  struct _PInfo {
179
- struct _Helper helpers[MAX_DEPTH];
180
- Helper h; /* current helper or 0 if not set */
181
- char *str; /* buffer being read from */
182
- char *s; /* current position in buffer */
183
- VALUE obj;
184
- ParseCallbacks pcb;
185
- CircArray circ_array;
193
+ struct _Helper helpers[MAX_DEPTH];
194
+ Helper h; /* current helper or 0 if not set */
195
+ char *str; /* buffer being read from */
196
+ char *s; /* current position in buffer */
197
+ VALUE obj;
198
+ ParseCallbacks pcb;
199
+ CircArray circ_array;
186
200
  #ifdef HAVE_RUBY_ENCODING_H
187
- rb_encoding *encoding;
201
+ rb_encoding *encoding;
188
202
  #else
189
203
  void *encoding;
190
204
  #endif
191
- unsigned long id; /* set for text types when cirs_array is set */
192
- int trace;
193
- Effort effort;
205
+ unsigned long id; /* set for text types when cirs_array is set */
206
+ Options options;
194
207
  };
195
208
 
196
- typedef struct _Options {
197
- char encoding[64]; // encoding, stored in the option to avoid GC invalidation in default values
198
- int indent; // indention for dump, default 2
199
- int trace; // trace level
200
- char with_dtd; // YesNo
201
- char with_xml; // YesNo
202
- char with_instruct; // YesNo
203
- char circular; // YesNo
204
- char xsd_date; // YesNo
205
- char mode; // LoadMode
206
- char effort; // Effort
207
- } *Options;
208
-
209
- extern VALUE ox_parse(char *xml, ParseCallbacks pcb, char **endp, int trace, Effort effort);
209
+ extern VALUE ox_parse(char *xml, ParseCallbacks pcb, char **endp, Options options);
210
210
  extern void _ox_raise_error(const char *msg, const char *xml, const char *current, const char* file, int line);
211
211
 
212
212
  extern void ox_sax_parse(VALUE handler, VALUE io, int convert);
@@ -216,9 +216,9 @@ extern void ox_sax_define(void);
216
216
  extern char* ox_write_obj_to_str(VALUE obj, Options copts);
217
217
  extern void ox_write_obj_to_file(VALUE obj, const char *path, Options copts);
218
218
 
219
- extern struct _Options ox_default_options;
219
+ extern struct _Options ox_default_options;
220
220
 
221
- extern VALUE Ox;
221
+ extern VALUE Ox;
222
222
 
223
223
  extern ID ox_at_id;
224
224
  extern ID ox_at_value_id;
@@ -258,24 +258,24 @@ extern ID ox_tv_nsec_id;
258
258
  extern ID ox_tv_usec_id;
259
259
  extern ID ox_value_id;
260
260
 
261
- extern VALUE ox_date_class;
262
- extern VALUE ox_empty_string;
263
- extern VALUE ox_encoding_sym;
264
- extern VALUE ox_struct_class;
265
- extern VALUE ox_time_class;
261
+ extern VALUE ox_date_class;
262
+ extern VALUE ox_empty_string;
263
+ extern VALUE ox_encoding_sym;
264
+ extern VALUE ox_struct_class;
265
+ extern VALUE ox_time_class;
266
266
  extern VALUE ox_stringio_class;
267
- extern VALUE ox_zero_fixnum;
268
-
269
- extern VALUE ox_document_clas;
270
- extern VALUE ox_element_clas;
271
- extern VALUE ox_bag_clas;
272
- extern VALUE ox_comment_clas;
273
- extern VALUE ox_doctype_clas;
274
- extern VALUE ox_cdata_clas;
275
-
276
- extern Cache ox_symbol_cache;
277
- extern Cache ox_class_cache;
278
- extern Cache ox_attr_cache;
267
+ extern VALUE ox_zero_fixnum;
268
+
269
+ extern VALUE ox_document_clas;
270
+ extern VALUE ox_element_clas;
271
+ extern VALUE ox_bag_clas;
272
+ extern VALUE ox_comment_clas;
273
+ extern VALUE ox_doctype_clas;
274
+ extern VALUE ox_cdata_clas;
275
+
276
+ extern Cache ox_symbol_cache;
277
+ extern Cache ox_class_cache;
278
+ extern Cache ox_attr_cache;
279
279
 
280
280
  #if defined(__cplusplus)
281
281
  #if 0
@@ -96,14 +96,14 @@ next_white(PInfo pi) {
96
96
  }
97
97
 
98
98
  VALUE
99
- ox_parse(char *xml, ParseCallbacks pcb, char **endp, int trace, Effort effort) {
99
+ ox_parse(char *xml, ParseCallbacks pcb, char **endp, Options options) {
100
100
  struct _PInfo pi;
101
101
  int body_read = 0;
102
102
 
103
103
  if (0 == xml) {
104
104
  raise_error("Invalid arg, xml string can not be null", xml, 0);
105
105
  }
106
- if (DEBUG <= trace) {
106
+ if (DEBUG <= options->trace) {
107
107
  printf("Parsing xml:\n%s\n", xml);
108
108
  }
109
109
  /* initialize parse info */
@@ -114,8 +114,7 @@ ox_parse(char *xml, ParseCallbacks pcb, char **endp, int trace, Effort effort) {
114
114
  pi.obj = Qnil;
115
115
  pi.circ_array = 0;
116
116
  pi.encoding = 0;
117
- pi.trace = trace;
118
- pi.effort = effort;
117
+ pi.options = options;
119
118
  while (1) {
120
119
  next_non_white(&pi); // skip white space
121
120
  if ('\0' == *pi.s) {
@@ -632,7 +631,7 @@ static char*
632
631
  read_quoted_value(PInfo pi) {
633
632
  char *value = 0;
634
633
 
635
- if ('"' == *pi->s || ('\'' == *pi->s && StrictEffort != pi->effort)) {
634
+ if ('"' == *pi->s || ('\'' == *pi->s && StrictEffort != pi->options->effort)) {
636
635
  char term = *pi->s;
637
636
 
638
637
  pi->s++; // skip quote character
@@ -644,7 +643,7 @@ read_quoted_value(PInfo pi) {
644
643
  }
645
644
  *pi->s = '\0'; // terminate value
646
645
  pi->s++; // move past quote
647
- } else if (StrictEffort == pi->effort) {
646
+ } else if (StrictEffort == pi->options->effort) {
648
647
  raise_error("invalid format, expected a quote character", pi->str, pi->s);
649
648
  } else {
650
649
  value = pi->s;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '1.5.7'
4
+ VERSION = '1.5.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 1.5.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-13 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! "A fast XML parser and object serializer that uses only standard C
15
15
  lib.\n \nOptimized XML (Ox), as the name implies was written to provide