ox 1.5.8 → 1.5.9

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.

@@ -42,12 +42,11 @@
42
42
 
43
43
  typedef struct _SaxDrive {
44
44
  char base_buf[0x00010000];
45
- //char base_buf[0x00000010];
46
45
  char *buf;
47
46
  char *buf_end;
48
47
  char *cur;
49
- char *read_end; // one past last character read
50
- char *str; // start of current string being read
48
+ char *read_end; /* one past last character read */
49
+ char *str; /* start of current string being read */
51
50
  int line;
52
51
  int col;
53
52
  VALUE handler;
@@ -104,7 +103,7 @@ static int read_from_str(SaxDrive dr);
104
103
 
105
104
  static VALUE sax_value_class;
106
105
 
107
- // This is only for CentOS 5.4 with Ruby 1.9.3-p0 and for OS X 10.6.
106
+ /* This is only for CentOS 5.4 with Ruby 1.9.3-p0 and for OS X 10.6. */
108
107
  #ifdef NEEDS_STPCPY
109
108
  char *stpncpy(char *dest, const char *src, size_t n) {
110
109
  size_t cnt = strlen(src) + 1;
@@ -244,8 +243,8 @@ ox_sax_parse(VALUE handler, VALUE io, int convert) {
244
243
  inline static int
245
244
  respond_to(VALUE obj, ID method) {
246
245
  #ifdef JRUBY_RUBY
247
- // There is a bug in JRuby where rb_respond_to() returns true (1) even if
248
- // a method is private.
246
+ /* There is a bug in JRuby where rb_respond_to() returns true (1) even if
247
+ * a method is private. */
249
248
  {
250
249
  VALUE args[1];
251
250
 
@@ -299,7 +298,7 @@ sax_drive_init(SaxDrive dr, VALUE handler, VALUE io, int convert) {
299
298
  }
300
299
  dr->buf = dr->base_buf;
301
300
  *dr->buf = '\0';
302
- dr->buf_end = dr->buf + sizeof(dr->base_buf) - 1; // 1 less to make debugging easier
301
+ dr->buf_end = dr->buf + sizeof(dr->base_buf) - 1; /* 1 less to make debugging easier */
303
302
  dr->cur = dr->buf;
304
303
  dr->read_end = dr->buf;
305
304
  dr->str = 0;
@@ -348,8 +347,8 @@ sax_drive_read(SaxDrive dr) {
348
347
  } else {
349
348
  shift = dr->str - dr->buf;
350
349
  }
351
- //printf("\n*** shift: %lu\n", shift);
352
- if (0 == shift) { // no space left so allocate more
350
+ /*printf("\n*** shift: %lu\n", shift); */
351
+ if (0 == shift) { /* no space left so allocate more */
353
352
  char *old = dr->buf;
354
353
  size_t size = dr->buf_end - dr->buf;
355
354
 
@@ -403,45 +402,45 @@ read_children(SaxDrive dr, int first) {
403
402
  char c;
404
403
 
405
404
  while (!err) {
406
- dr->str = dr->cur; // protect the start
405
+ dr->str = dr->cur; /* protect the start */
407
406
  if ('\0' == (c = next_non_white(dr))) {
408
407
  if (!first) {
409
408
  sax_drive_error(dr, "invalid format, element not terminated", 1);
410
409
  err = 1;
411
410
  }
412
- break; // normal completion if first
411
+ break; /* normal completion if first */
413
412
  }
414
413
  if ('<' != c) {
415
- if (first) { // all top level entities start with <
414
+ if (first) { /* all top level entities start with < */
416
415
  sax_drive_error(dr, "invalid format, expected <", 1);
417
- break; // unrecoverable
416
+ break; /* unrecoverable */
418
417
  }
419
- if (0 != (err = read_text(dr))) { // finished when < is reached
418
+ if (0 != (err = read_text(dr))) { /* finished when < is reached */
420
419
  break;
421
420
  }
422
421
  }
423
- dr->str = dr->cur; // protect the start for elements
422
+ dr->str = dr->cur; /* protect the start for elements */
424
423
  c = sax_drive_get(dr);
425
424
  switch (c) {
426
- case '?': // instructions (xml or otherwise)
425
+ case '?': /* instructions (xml or otherwise) */
427
426
  if (!first || element_read || doctype_read) {
428
427
  sax_drive_error(dr, "invalid format, instruction must come before elements", 0);
429
428
  }
430
429
  err = read_instruction(dr);
431
430
  break;
432
- case '!': // comment or doctype
431
+ case '!': /* comment or doctype */
433
432
  dr->str = dr->cur;
434
433
  c = sax_drive_get(dr);
435
434
  if ('\0' == c) {
436
435
  sax_drive_error(dr, "invalid format, DOCTYPE or comment not terminated", 1);
437
436
  err = 1;
438
437
  } else if ('-' == c) {
439
- c = sax_drive_get(dr); // skip first - and get next character
438
+ c = sax_drive_get(dr); /* skip first - and get next character */
440
439
  if ('-' != c) {
441
440
  sax_drive_error(dr, "invalid format, bad comment format", 1);
442
441
  err = 1;
443
442
  } else {
444
- c = sax_drive_get(dr); // skip second -
443
+ c = sax_drive_get(dr); /* skip second - */
445
444
  err = read_comment(dr);
446
445
  }
447
446
  } else {
@@ -464,7 +463,7 @@ read_children(SaxDrive dr, int first) {
464
463
  }
465
464
  }
466
465
  break;
467
- case '/': // element end
466
+ case '/': /* element end */
468
467
  return ('\0' == read_name_token(dr));
469
468
  break;
470
469
  case '\0':
@@ -472,7 +471,7 @@ read_children(SaxDrive dr, int first) {
472
471
  err = 1;
473
472
  break;
474
473
  default:
475
- dr->cur--; // safe since no read occurred after getting last character
474
+ dr->cur--; /* safe since no read occurred after getting last character */
476
475
  if (first && element_read) {
477
476
  sax_drive_error(dr, "invalid format, multiple top level elements", 0);
478
477
  }
@@ -518,7 +517,7 @@ static int
518
517
  read_doctype(SaxDrive dr) {
519
518
  char c;
520
519
 
521
- dr->str = dr->cur - 1; // mark the start
520
+ dr->str = dr->cur - 1; /* mark the start */
522
521
  while ('>' != (c = sax_drive_get(dr))) {
523
522
  if ('\0' == c) {
524
523
  sax_drive_error(dr, "invalid format, doctype terminated unexpectedly", 1);
@@ -544,8 +543,8 @@ read_cdata(SaxDrive dr) {
544
543
  char c;
545
544
  int end = 0;
546
545
 
547
- dr->cur--; // back up to the start in case the cdata is empty
548
- dr->str = dr->cur; // mark the start
546
+ dr->cur--; /* back up to the start in case the cdata is empty */
547
+ dr->str = dr->cur; /* mark the start */
549
548
  while (1) {
550
549
  c = sax_drive_get(dr);
551
550
  if (']' == c) {
@@ -586,7 +585,7 @@ read_comment(SaxDrive dr) {
586
585
  char c;
587
586
  int end = 0;
588
587
 
589
- dr->str = dr->cur - 1; // mark the start
588
+ dr->str = dr->cur - 1; /* mark the start */
590
589
  while (1) {
591
590
  c = sax_drive_get(dr);
592
591
  if ('-' == c) {
@@ -690,7 +689,7 @@ static int
690
689
  read_text(SaxDrive dr) {
691
690
  char c;
692
691
 
693
- dr->str = dr->cur - 1; // mark the start
692
+ dr->str = dr->cur - 1; /* mark the start */
694
693
  while ('<' != (c = sax_drive_get(dr))) {
695
694
  if ('\0' == c) {
696
695
  sax_drive_error(dr, "invalid format, text terminated unexpectedly", 1);
@@ -727,7 +726,7 @@ read_attrs(SaxDrive dr, char c, char termc, char term2, int is_xml) {
727
726
  VALUE name = Qnil;
728
727
  int is_encoding = 0;
729
728
 
730
- dr->str = dr->cur; // lock it down
729
+ dr->str = dr->cur; /* lock it down */
731
730
  if (is_white(c)) {
732
731
  c = next_non_white(dr);
733
732
  }
@@ -743,7 +742,7 @@ read_attrs(SaxDrive dr, char c, char termc, char term2, int is_xml) {
743
742
  if (is_xml && 0 == strcmp("encoding", dr->str)) {
744
743
  is_encoding = 1;
745
744
  }
746
- // TBD use symbol cache
745
+ /* TBD use symbol cache */
747
746
  if (dr->has_attr || dr->has_attr_value) {
748
747
  name = str2sym(dr->str, dr);
749
748
  }
@@ -792,7 +791,7 @@ static char
792
791
  read_name_token(SaxDrive dr) {
793
792
  char c;
794
793
 
795
- dr->str = dr->cur; // make sure the start doesn't get compacted out
794
+ dr->str = dr->cur; /* make sure the start doesn't get compacted out */
796
795
  c = sax_drive_get(dr);
797
796
  if (is_white(c)) {
798
797
  c = next_non_white(dr);
@@ -812,7 +811,7 @@ read_name_token(SaxDrive dr) {
812
811
  *(dr->cur - 1) = '\0';
813
812
  return c;
814
813
  case '\0':
815
- // documents never terminate after a name token
814
+ /* documents never terminate after a name token */
816
815
  sax_drive_error(dr, "invalid format, document not terminated", 1);
817
816
  return '\0';
818
817
  default:
@@ -848,16 +847,16 @@ read_quoted_value(SaxDrive dr) {
848
847
  sax_drive_error(dr, "invalid format, attibute value not in quotes", 1);
849
848
  }
850
849
  }
851
- *(dr->cur - 1) = '\0'; // terminate value
850
+ *(dr->cur - 1) = '\0'; /* terminate value */
852
851
  return 0;
853
852
  }
854
853
 
855
854
  static VALUE
856
855
  rescue_cb(VALUE rdr, VALUE err) {
857
856
  #ifndef JRUBY_RUBY
858
- // JRuby seems to play by a different set if rules. It passes in an Fixnum
859
- // instead of an error like other Rubies. For now assume all errors are
860
- // EOF and deal with the results further down the line.
857
+ /* JRuby seems to play by a different set if rules. It passes in an Fixnum
858
+ * instead of an error like other Rubies. For now assume all errors are
859
+ * EOF and deal with the results further down the line. */
861
860
  #if (defined(RUBINIUS_RUBY) || (1 == RUBY_VERSION_MAJOR && 8 == RUBY_VERSION_MINOR))
862
861
  if (rb_obj_class(err) != rb_eTypeError) {
863
862
  #else
@@ -884,7 +883,7 @@ partial_io_cb(VALUE rdr) {
884
883
  rstr = rb_funcall2(dr->io, ox_readpartial_id, 1, args);
885
884
  str = StringValuePtr(rstr);
886
885
  cnt = strlen(str);
887
- //printf("*** read %lu bytes, str: '%s'\n", cnt, str);
886
+ /*printf("*** read %lu bytes, str: '%s'\n", cnt, str); */
888
887
  strcpy(dr->cur, str);
889
888
  dr->read_end = dr->cur + cnt;
890
889
 
@@ -900,11 +899,11 @@ io_cb(VALUE rdr) {
900
899
  size_t cnt;
901
900
 
902
901
  args[0] = ULONG2NUM(dr->buf_end - dr->cur);
903
- //args[0] = SIZET2NUM(dr->buf_end - dr->cur);
902
+ /*args[0] = SIZET2NUM(dr->buf_end - dr->cur); */
904
903
  rstr = rb_funcall2(dr->io, ox_read_id, 1, args);
905
904
  str = StringValuePtr(rstr);
906
905
  cnt = strlen(str);
907
- //printf("*** read %lu bytes, str: '%s'\n", cnt, str);
906
+ /*printf("*** read %lu bytes, str: '%s'\n", cnt, str); */
908
907
  strcpy(dr->cur, str);
909
908
  dr->read_end = dr->cur + cnt;
910
909
 
@@ -945,7 +944,7 @@ read_from_str(SaxDrive dr) {
945
944
  long cnt;
946
945
 
947
946
  if ('\0' == *dr->in_str) {
948
- // done
947
+ /* done */
949
948
  return -1;
950
949
  }
951
950
  s = stpncpy(dr->cur, dr->in_str, max);
@@ -1190,7 +1189,7 @@ sax_value_as_time(VALUE self) {
1190
1189
  Qnil == (t = parse_xsd_time(str))) {
1191
1190
  VALUE args[1];
1192
1191
 
1193
- //printf("**** time parse\n");
1192
+ /*printf("**** time parse\n"); */
1194
1193
  *args = rb_str_new2(str);
1195
1194
  t = rb_funcall2(ox_time_class, ox_parse_id, 1, args);
1196
1195
  }
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '1.5.8'
4
+ VERSION = '1.5.9'
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.8
4
+ version: 1.5.9
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-06-26 00:00:00.000000000 Z
12
+ date: 2012-08-07 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