ox 2.10.0 → 2.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1967ed8377e3a3e7ccdb8b6e14a21e5dbd0c7f435b87474c422cf3572d639a9
4
- data.tar.gz: cdb5712d31fd0641c9f444e8ea205fb18c3ccb246ba651d31b8dbd34db7ba579
3
+ metadata.gz: f6e57cf5b8fbaa41d750b25f77a81d329f58465115db0c628dd97ba4b0bf97b3
4
+ data.tar.gz: df2f0ba360c0c6f5ea0ac23496ce133a8008c78c5a2a7e3a9078b7138ee957b9
5
5
  SHA512:
6
- metadata.gz: 52f78021c4525f0c88548c2ce87a2a660d0ce60ea72ffef159611a4b39b883ce497adebf3a13c22f3c744325f4c463c4493ab66b3efbda7c975e99b0d46e7c71
7
- data.tar.gz: b505855a76c09de2bb9c07b821b509e1d8d58ee3ce45816db6612086b10bb748dfe1c9ca07da8baab077a5ffdbc33cd3ed773fbd14f9cb7e8c2108b2e935797e
6
+ metadata.gz: 2dbff602131c14cde1d7b754165fee62867f5b27956c01de1a52a119f651bcaa8457e92c900cc2a121f74cfdcfbadbeec74a9f144e450f1b24805bd0167e3d14
7
+ data.tar.gz: 40392d27cec2d85d4df7deae4870da0da2fabf3a96b761a4f8e95d0813b99763c5dd7cdb76a4c8a139ccf613868a04d7ded091fa68db1e89fdfa5ee49b118a6e
@@ -1,4 +1,8 @@
1
1
 
2
+ ## 2.10.1 - May 27, 2019
3
+
4
+ - Remove extra space from doctype dump.
5
+
2
6
  ## 2.10.0 - August 26, 2018
3
7
 
4
8
  - `:element_key_mod` and `:attr_key_mod` options were added to allow keys to
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Ox gem
2
2
  A fast XML parser and Object marshaller as a Ruby gem.
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/ohler55/ox.png?branch=master)](http://travis-ci.org/ohler55/ox)
4
+ [![Build Status](https://secure.travis-ci.org/ohler55/ox.svg?branch=master)](http://travis-ci.org/ohler55/ox) [![TideLift](https://tidelift.com/badges/github/ohler55/ox)](https://tidelift.com/subscription/pkg/rubygems-ox?utm_source=rubygems-ox&utm_medium=referral&utm_campaign=readme)
5
5
 
6
6
  ## Installation
7
7
  gem install ox
@@ -20,8 +20,9 @@ A fast XML parser and Object marshaller as a Ruby gem.
20
20
 
21
21
  [Follow @peterohler on Twitter](http://twitter.com/#!/peterohler) for announcements and news about the Ox gem.
22
22
 
23
- ## Build Status
23
+ ## Support
24
24
 
25
+ [Get supported Ox with a Tidelift Subscription.](https://tidelift.com/subscription/pkg/rubygems-ox?utm_source=rubygems-ox&utm_medium=referral&utm_campaign=readme)
25
26
 
26
27
  ## Links of Interest
27
28
 
@@ -3,20 +3,20 @@
3
3
  * All rights reserved.
4
4
  */
5
5
 
6
- #ifndef __OX_ATTR_H__
7
- #define __OX_ATTR_H__
6
+ #ifndef OX_ATTR_H
7
+ #define OX_ATTR_H
8
8
 
9
9
  #include "ox.h"
10
10
 
11
11
  #define ATTR_STACK_INC 8
12
12
 
13
- typedef struct _Attr {
13
+ typedef struct _attr {
14
14
  const char *name;
15
15
  const char *value;
16
16
  } *Attr;
17
17
 
18
- typedef struct _AttrStack {
19
- struct _Attr base[ATTR_STACK_INC];
18
+ typedef struct _attrStack {
19
+ struct _attr base[ATTR_STACK_INC];
20
20
  Attr head; /* current stack */
21
21
  Attr end; /* stack end */
22
22
  Attr tail; /* pointer to one past last element name on stack */
@@ -25,7 +25,7 @@ typedef struct _AttrStack {
25
25
  inline static void
26
26
  attr_stack_init(AttrStack stack) {
27
27
  stack->head = stack->base;
28
- stack->end = stack->base + sizeof(stack->base) / sizeof(struct _Attr);
28
+ stack->end = stack->base + sizeof(stack->base) / sizeof(struct _attr);
29
29
  stack->tail = stack->head;
30
30
  stack->head->name = 0;
31
31
  }
@@ -50,10 +50,10 @@ attr_stack_push(AttrStack stack, const char *name, const char *value) {
50
50
  size_t toff = stack->tail - stack->head;
51
51
 
52
52
  if (stack->base == stack->head) {
53
- stack->head = ALLOC_N(struct _Attr, len + ATTR_STACK_INC);
54
- memcpy(stack->head, stack->base, sizeof(struct _Attr) * len);
53
+ stack->head = ALLOC_N(struct _attr, len + ATTR_STACK_INC);
54
+ memcpy(stack->head, stack->base, sizeof(struct _attr) * len);
55
55
  } else {
56
- REALLOC_N(stack->head, struct _Attr, len + ATTR_STACK_INC);
56
+ REALLOC_N(stack->head, struct _attr, len + ATTR_STACK_INC);
57
57
  }
58
58
  stack->tail = stack->head + toff;
59
59
  stack->end = stack->head + len + ATTR_STACK_INC;
@@ -81,4 +81,4 @@ attr_stack_pop(AttrStack stack) {
81
81
  return 0;
82
82
  }
83
83
 
84
- #endif /* __OX_ATTR_H__ */
84
+ #endif /* OX_ATTR_H */
@@ -3,8 +3,8 @@
3
3
  * All rights reserved.
4
4
  */
5
5
 
6
- #ifndef __BASE64_H__
7
- #define __BASE64_H__
6
+ #ifndef BASE64_H
7
+ #define BASE64_H
8
8
 
9
9
  typedef unsigned char uchar;
10
10
 
@@ -15,4 +15,4 @@ extern unsigned long b64_orig_size(const char *text);
15
15
  extern void to_base64(const uchar *src, int len, char *b64);
16
16
  extern void from_base64(const char *b64, uchar *str);
17
17
 
18
- #endif /* __BASE64_H__ */
18
+ #endif /* BASE64_H */
@@ -1,21 +1,21 @@
1
1
  /* buf.h
2
2
  * Copyright (c) 2014, Peter Ohler
3
3
  * All rights reserved.
4
- *
4
+ *
5
5
  * Redistribution and use in source and binary forms, with or without
6
6
  * modification, are permitted provided that the following conditions are met:
7
- *
7
+ *
8
8
  * - Redistributions of source code must retain the above copyright notice, this
9
9
  * list of conditions and the following disclaimer.
10
- *
10
+ *
11
11
  * - Redistributions in binary form must reproduce the above copyright notice,
12
12
  * this list of conditions and the following disclaimer in the documentation
13
13
  * and/or other materials provided with the distribution.
14
- *
14
+ *
15
15
  * - Neither the name of Peter Ohler nor the names of its contributors may be
16
16
  * used to endorse or promote products derived from this software without
17
17
  * specific prior written permission.
18
- *
18
+ *
19
19
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
20
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
21
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -28,13 +28,13 @@
28
28
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
  */
30
30
 
31
- #ifndef __OX_BUF_H__
32
- #define __OX_BUF_H__
31
+ #ifndef OX_BUF_H
32
+ #define OX_BUF_H
33
33
 
34
34
  #include <stdbool.h>
35
35
  #include <unistd.h>
36
36
 
37
- typedef struct _Buf {
37
+ typedef struct _buf {
38
38
  char *head;
39
39
  char *end;
40
40
  char *tail;
@@ -108,7 +108,7 @@ buf_append_string(Buf buf, const char *s, size_t slen) {
108
108
  }
109
109
  buf->tail += slen;
110
110
  }
111
-
111
+
112
112
  inline static void
113
113
  buf_append(Buf buf, char c) {
114
114
  if (buf->err) {
@@ -157,4 +157,4 @@ buf_finish(Buf buf) {
157
157
  }
158
158
  }
159
159
 
160
- #endif /* __OX_BUF_H__ */
160
+ #endif /* OX_BUF_H */
@@ -14,7 +14,7 @@
14
14
 
15
15
  #define MAX_DEPTH 128
16
16
 
17
- typedef struct _Element {
17
+ typedef struct _element {
18
18
  char *name;
19
19
  char buf[64];
20
20
  int len;
@@ -22,13 +22,13 @@ typedef struct _Element {
22
22
  bool non_text_child;
23
23
  } *Element;
24
24
 
25
- typedef struct _Builder {
26
- struct _Buf buf;
25
+ typedef struct _builder {
26
+ struct _buf buf;
27
27
  int indent;
28
28
  char encoding[64];
29
29
  int depth;
30
30
  FILE *file;
31
- struct _Element stack[MAX_DEPTH];
31
+ struct _element stack[MAX_DEPTH];
32
32
  long line;
33
33
  long col;
34
34
  long pos;
@@ -348,7 +348,7 @@ to_s(Builder b) {
348
348
  */
349
349
  static VALUE
350
350
  builder_new(int argc, VALUE *argv, VALUE self) {
351
- Builder b = ALLOC(struct _Builder);
351
+ Builder b = ALLOC(struct _builder);
352
352
  int indent = ox_default_options.indent;
353
353
  long buf_size = 0;
354
354
 
@@ -403,7 +403,7 @@ builder_new(int argc, VALUE *argv, VALUE self) {
403
403
  */
404
404
  static VALUE
405
405
  builder_file(int argc, VALUE *argv, VALUE self) {
406
- Builder b = ALLOC(struct _Builder);
406
+ Builder b = ALLOC(struct _builder);
407
407
  int indent = ox_default_options.indent;
408
408
  long buf_size = 0;
409
409
  FILE *f;
@@ -465,7 +465,7 @@ builder_file(int argc, VALUE *argv, VALUE self) {
465
465
  */
466
466
  static VALUE
467
467
  builder_io(int argc, VALUE *argv, VALUE self) {
468
- Builder b = ALLOC(struct _Builder);
468
+ Builder b = ALLOC(struct _builder);
469
469
  int indent = ox_default_options.indent;
470
470
  long buf_size = 0;
471
471
  int fd;
@@ -13,13 +13,13 @@
13
13
 
14
14
  #include "cache.h"
15
15
 
16
- struct _Cache {
16
+ struct _cache {
17
17
  /* The key is a length byte followed by the key as a string. If the key is longer than 254 characters then the
18
18
  length is 255. The key can be for a premature value and in that case the length byte is greater than the length
19
19
  of the key. */
20
20
  char *key;
21
21
  VALUE value;
22
- struct _Cache *slots[16];
22
+ struct _cache *slots[16];
23
23
  };
24
24
 
25
25
  static void slot_print(Cache cache, unsigned int depth);
@@ -36,7 +36,7 @@ static char* form_key(const char *s) {
36
36
 
37
37
  void
38
38
  ox_cache_new(Cache *cache) {
39
- *cache = ALLOC(struct _Cache);
39
+ *cache = ALLOC(struct _cache);
40
40
  (*cache)->key = 0;
41
41
  (*cache)->value = Qundef;
42
42
  memset((*cache)->slots, 0, sizeof((*cache)->slots));
@@ -63,7 +63,7 @@ ox_cache_get(Cache cache, const char *key, VALUE **slot, const char **keyp) {
63
63
  int depth = (int)(k - (unsigned char*)key + 1);
64
64
 
65
65
  cache = *cp;
66
-
66
+
67
67
  if ('\0' == *(k + 1)) { /* exact match */
68
68
  if (0 == cache->key) { /* nothing in this spot so take it */
69
69
  cache->key = form_key(key);
@@ -73,7 +73,7 @@ ox_cache_get(Cache cache, const char *key, VALUE **slot, const char **keyp) {
73
73
  } else { /* have to move the current premature key/value deeper */
74
74
  unsigned char *ck = (unsigned char*)(cache->key + depth + 1);
75
75
  Cache orig = *cp;
76
-
76
+
77
77
  cp = (*cp)->slots + (*ck >> 4);
78
78
  ox_cache_new(cp);
79
79
  cp = (*cp)->slots + (*ck & 0x0F);
@@ -90,7 +90,7 @@ ox_cache_get(Cache cache, const char *key, VALUE **slot, const char **keyp) {
90
90
  } else {
91
91
  unsigned char *ck = (unsigned char*)(cache->key + depth + 1);
92
92
  Cache orig = *cp;
93
-
93
+
94
94
  cp = (*cp)->slots + (*ck >> 4);
95
95
  ox_cache_new(cp);
96
96
  cp = (*cp)->slots + (*ck & 0x0F);
@@ -3,12 +3,12 @@
3
3
  * All rights reserved.
4
4
  */
5
5
 
6
- #ifndef __OX_CACHE_H__
7
- #define __OX_CACHE_H__
6
+ #ifndef OX_CACHE_H
7
+ #define OX_CACHE_H
8
8
 
9
9
  #include "ruby.h"
10
10
 
11
- typedef struct _Cache *Cache;
11
+ typedef struct _cache *Cache;
12
12
 
13
13
  extern void ox_cache_new(Cache *cache);
14
14
 
@@ -16,4 +16,4 @@ extern VALUE ox_cache_get(Cache cache, const char *key, VALUE **slot, const c
16
16
 
17
17
  extern void ox_cache_print(Cache cache);
18
18
 
19
- #endif /* __OX_CACHE_H__ */
19
+ #endif /* OX_CACHE_H */
@@ -18,11 +18,11 @@
18
18
  #define DEPTH 16
19
19
 
20
20
  typedef union {
21
- struct _Cache8 *child;
21
+ struct _cache8 *child;
22
22
  slot_t value;
23
23
  } Bucket;
24
24
 
25
- struct _Cache8 {
25
+ struct _cache8 {
26
26
  Bucket buckets[SLOT_CNT];
27
27
  };
28
28
 
@@ -33,8 +33,8 @@ void
33
33
  ox_cache8_new(Cache8 *cache) {
34
34
  Bucket *b;
35
35
  int i;
36
-
37
- *cache = ALLOC(struct _Cache8);
36
+
37
+ *cache = ALLOC(struct _cache8);
38
38
  for (i = SLOT_CNT, b = (*cache)->buckets; 0 < i; i--, b++) {
39
39
  b->value = 0;
40
40
  }
@@ -66,7 +66,7 @@ ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot) {
66
66
  int i;
67
67
  sid_t k8 = (sid_t)key;
68
68
  sid_t k;
69
-
69
+
70
70
  for (i = 64 - BITS; 0 < i; i -= BITS) {
71
71
  k = (k8 >> i) & MASK;
72
72
  b = cache->buckets + k;
@@ -3,13 +3,13 @@
3
3
  * All rights reserved.
4
4
  */
5
5
 
6
- #ifndef __OX_CACHE8_H__
7
- #define __OX_CACHE8_H__
6
+ #ifndef OX_CACHE8_H
7
+ #define OX_CACHE8_H
8
8
 
9
9
  #include "ruby.h"
10
10
  #include "stdint.h"
11
11
 
12
- typedef struct _Cache8 *Cache8;
12
+ typedef struct _cache8 *Cache8;
13
13
  typedef uint64_t slot_t;
14
14
  typedef uint64_t sid_t;
15
15
 
@@ -20,4 +20,4 @@ extern slot_t ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot);
20
20
 
21
21
  //extern void ox_cache8_print(Cache8 cache);
22
22
 
23
- #endif /* __OX_CACHE8_H__ */
23
+ #endif /* OX_CACHE8_H */
@@ -18,24 +18,24 @@
18
18
 
19
19
  typedef unsigned long ulong;
20
20
 
21
- typedef struct _Str {
21
+ typedef struct _str {
22
22
  const char *str;
23
23
  size_t len;
24
24
  } *Str;
25
25
 
26
- typedef struct _Element {
27
- struct _Str clas;
28
- struct _Str attr;
26
+ typedef struct _element {
27
+ struct _str clas;
28
+ struct _str attr;
29
29
  unsigned long id;
30
30
  int indent; /* < 0 indicates no \n */
31
31
  int closed;
32
32
  char type;
33
33
  } *Element;
34
34
 
35
- typedef struct _Out {
36
- void (*w_start)(struct _Out *out, Element e);
37
- void (*w_end)(struct _Out *out, Element e);
38
- void (*w_time)(struct _Out *out, VALUE obj);
35
+ typedef struct _out {
36
+ void (*w_start)(struct _out *out, Element e);
37
+ void (*w_end)(struct _out *out, Element e);
38
+ void (*w_time)(struct _out *out, VALUE obj);
39
39
  char *buf;
40
40
  char *end;
41
41
  char *cur;
@@ -235,7 +235,7 @@ check_circular(Out out, VALUE obj, Element e) {
235
235
  slot_t *slot;
236
236
  slot_t id;
237
237
  int result;
238
-
238
+
239
239
  if (0 == (id = ox_cache8_get(out->circ_cache, obj, &slot))) {
240
240
  out->circ_cnt++;
241
241
  id = out->circ_cnt;
@@ -256,7 +256,7 @@ static void
256
256
  grow(Out out, size_t len) {
257
257
  size_t size = out->end - out->buf;
258
258
  long pos = out->cur - out->buf;
259
-
259
+
260
260
  size *= 2;
261
261
  if (size <= len * 2 + pos) {
262
262
  size += len;
@@ -297,7 +297,7 @@ dump_start(Out out, Element e) {
297
297
  char buf[32];
298
298
  char *end = buf + sizeof(buf) - 1;
299
299
  const char *s = ulong2str(e->id, end);
300
-
300
+
301
301
  fill_attr(out, 'i', s, end - s);
302
302
  }
303
303
  if (e->closed) {
@@ -341,7 +341,7 @@ dump_value(Out out, const char *value, size_t size) {
341
341
  inline static void
342
342
  dump_str_value(Out out, const char *value, size_t size, const char *table) {
343
343
  size_t xsize = xml_str_len((const uchar*)value, size, table);
344
-
344
+
345
345
  if (out->end - out->cur <= (long)xsize) {
346
346
  grow(out, xsize);
347
347
  }
@@ -591,7 +591,7 @@ dump_first_obj(VALUE obj, Out out) {
591
591
 
592
592
  static void
593
593
  dump_obj(ID aid, VALUE obj, int depth, Out out) {
594
- struct _Element e;
594
+ struct _element e;
595
595
  VALUE prev_obj = out->obj;
596
596
  char value_buf[64];
597
597
  int cnt;
@@ -660,7 +660,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
660
660
  out->w_start(out, &e);
661
661
  if (0 < cnt) {
662
662
  unsigned int od = out->depth;
663
-
663
+
664
664
  out->depth = depth + 1;
665
665
  rb_hash_foreach(obj, dump_hash, (VALUE)out);
666
666
  out->depth = od;
@@ -938,7 +938,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
938
938
  case T_BIGNUM:
939
939
  {
940
940
  volatile VALUE rs = rb_big2str(obj, 10);
941
-
941
+
942
942
  e.type = BignumCode;
943
943
  out->w_start(out, &e);
944
944
  dump_value(out, StringValuePtr(rs), RSTRING_LEN(rs));
@@ -1018,7 +1018,7 @@ static int
1018
1018
  dump_hash(VALUE key, VALUE value, Out out) {
1019
1019
  dump_obj(0, key, out->depth, out);
1020
1020
  dump_obj(0, value, out->depth, out);
1021
-
1021
+
1022
1022
  return ST_CONTINUE;
1023
1023
  }
1024
1024
 
@@ -1069,7 +1069,7 @@ dump_gen_element(VALUE obj, int depth, Out out) {
1069
1069
  long nlen = RSTRING_LEN(rname);
1070
1070
  size_t size;
1071
1071
  int indent;
1072
-
1072
+
1073
1073
  if (0 > out->indent) {
1074
1074
  indent = -1;
1075
1075
  } else if (0 == out->indent) {
@@ -1093,7 +1093,7 @@ dump_gen_element(VALUE obj, int depth, Out out) {
1093
1093
  }
1094
1094
  if (Qnil != nodes && 0 < RARRAY_LEN(nodes)) {
1095
1095
  int do_indent;
1096
-
1096
+
1097
1097
  *out->cur++ = '>';
1098
1098
  do_indent = dump_gen_nodes(nodes, depth, out);
1099
1099
  if (out->end - out->cur <= (long)size) {
@@ -1122,7 +1122,7 @@ dump_gen_instruct(VALUE obj, int depth, Out out) {
1122
1122
  long nlen = RSTRING_LEN(rname);
1123
1123
  long clen = 0;
1124
1124
  size_t size;
1125
-
1125
+
1126
1126
  if (T_STRING == rb_type(rcontent)) {
1127
1127
  content = StringValuePtr(rcontent);
1128
1128
  clen = RSTRING_LEN(rcontent);
@@ -1150,7 +1150,7 @@ static int
1150
1150
  dump_gen_nodes(VALUE obj, int depth, Out out) {
1151
1151
  long cnt = RARRAY_LEN(obj);
1152
1152
  int indent_needed = 1;
1153
-
1153
+
1154
1154
  if (0 < cnt) {
1155
1155
  const VALUE *np = RARRAY_PTR(obj);
1156
1156
  VALUE clas;
@@ -1176,7 +1176,7 @@ dump_gen_nodes(VALUE obj, int depth, Out out) {
1176
1176
  } else if (ox_cdata_clas == clas) {
1177
1177
  dump_gen_val_node(*np, d2, "<![CDATA[", 9, "]]>", 3, out);
1178
1178
  } else if (ox_doctype_clas == clas) {
1179
- dump_gen_val_node(*np, d2, "<!DOCTYPE ", 10, " >", 2, out);
1179
+ dump_gen_val_node(*np, d2, "<!DOCTYPE ", 10, ">", 1, out);
1180
1180
  } else {
1181
1181
  rb_raise(rb_eTypeError, "Unexpected class, %s, while dumping generic XML\n", rb_class2name(clas));
1182
1182
  }
@@ -1295,17 +1295,17 @@ dump_obj_to_xml(VALUE obj, Options copts, Out out) {
1295
1295
 
1296
1296
  char*
1297
1297
  ox_write_obj_to_str(VALUE obj, Options copts) {
1298
- struct _Out out;
1299
-
1298
+ struct _out out;
1299
+
1300
1300
  dump_obj_to_xml(obj, copts, &out);
1301
1301
  return out.buf;
1302
1302
  }
1303
1303
 
1304
1304
  void
1305
1305
  ox_write_obj_to_file(VALUE obj, const char *path, Options copts) {
1306
- struct _Out out;
1306
+ struct _out out;
1307
1307
  size_t size;
1308
- FILE *f;
1308
+ FILE *f;
1309
1309
 
1310
1310
  dump_obj_to_xml(obj, copts, &out);
1311
1311
  size = out.cur - out.buf;