ox 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ox might be problematic. Click here for more details.
- data/ext/ox/gen_load.c +30 -42
 - data/ext/ox/parse.c +0 -2
 - data/lib/ox/version.rb +1 -1
 - metadata +1 -1
 
    
        data/ext/ox/gen_load.c
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                 
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       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 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       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 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
                     
     | 
| 
       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)) {
         
     | 
    
        data/ext/ox/parse.c
    CHANGED
    
    | 
         @@ -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
         
     | 
    
        data/lib/ox/version.rb
    CHANGED