libxml-ruby 2.1.2-x86-mingw32 → 2.2.0-x86-mingw32
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.
- data/HISTORY +7 -0
- data/ext/libxml/libxml.c +0 -15
- data/ext/libxml/ruby_libxml.h +0 -3
- data/ext/libxml/ruby_xml_attr.c +2 -2
- data/ext/libxml/ruby_xml_attr_decl.c +2 -2
- data/ext/libxml/ruby_xml_document.c +7 -5
- data/ext/libxml/ruby_xml_dtd.c +3 -3
- data/ext/libxml/ruby_xml_encoding.c +25 -4
- data/ext/libxml/ruby_xml_encoding.h +4 -1
- data/ext/libxml/ruby_xml_namespace.c +2 -11
- data/ext/libxml/ruby_xml_node.c +11 -11
- data/ext/libxml/ruby_xml_parser_context.c +8 -8
- data/ext/libxml/ruby_xml_reader.c +13 -13
- data/ext/libxml/ruby_xml_version.h +4 -4
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +3 -3
- data/ext/libxml/ruby_xml_xpath_object.c +1 -1
- data/lib/1.8/libxml_ruby.so +0 -0
- data/lib/1.9/libxml_ruby.so +0 -0
- data/test/new_main.rb +29 -0
- data/test/tc_attr.rb +4 -4
- data/test/tc_document.rb +0 -14
- data/test/tc_document_write.rb +6 -11
- data/test/tc_encoding.rb +119 -0
- data/test/tc_node.rb +12 -72
- data/test/tc_parser.rb +2 -2
- data/test/test_suite.rb +1 -0
- metadata +7 -4
    
        data/HISTORY
    CHANGED
    
    | @@ -1,5 +1,12 @@ | |
| 1 1 | 
             
            = Release History
         | 
| 2 2 |  | 
| 3 | 
            +
            == 2.2.0 / 2011-08-09 Charlie Savage
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            * Update encoding support for Ruby 1.9 so that libxml-ruby returns
         | 
| 6 | 
            +
              strings encoded in UTF-8.  This change was required since libxml internally
         | 
| 7 | 
            +
              stores strings in UTF-8.  The exceptions to this rule are the #to_s methods
         | 
| 8 | 
            +
              which return UTF-8 by default but can return other encodings if requested.
         | 
| 9 | 
            +
             | 
| 3 10 | 
             
            == 2.1.2 / 2011-08-03 Charlie Savage
         | 
| 4 11 |  | 
| 5 12 | 
             
            * Fix segmentation fault that could occur when an XPathContext was marked
         | 
    
        data/ext/libxml/libxml.c
    CHANGED
    
    | @@ -21,21 +21,6 @@ static void rxml_init_memory(void) | |
| 21 21 | 
             
              );*/
         | 
| 22 22 | 
             
            }
         | 
| 23 23 |  | 
| 24 | 
            -
            VALUE rxml_str_new2(const char* xstr, const char* xencoding)
         | 
| 25 | 
            -
            {
         | 
| 26 | 
            -
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 27 | 
            -
              if (xencoding)
         | 
| 28 | 
            -
              {
         | 
| 29 | 
            -
                xmlCharEncoding xmlEncoding = xmlParseCharEncoding(xencoding);
         | 
| 30 | 
            -
                VALUE encoding = rxml_xml_encoding_to_rb_encoding(mXMLEncoding, xmlEncoding);
         | 
| 31 | 
            -
                rb_encoding* xencodingPtr = (rb_encoding*) RDATA(encoding)->data;
         | 
| 32 | 
            -
                return rb_external_str_new_with_enc(xstr, strlen(xstr), xencodingPtr);
         | 
| 33 | 
            -
              }
         | 
| 34 | 
            -
            #endif
         | 
| 35 | 
            -
              return rb_str_new2(xstr);
         | 
| 36 | 
            -
            }
         | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 24 | 
             
            void Init_libxml_ruby(void)
         | 
| 40 25 | 
             
            {
         | 
| 41 26 | 
             
            /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
         | 
    
        data/ext/libxml/ruby_libxml.h
    CHANGED
    
    
    
        data/ext/libxml/ruby_xml_attr.c
    CHANGED
    
    | @@ -166,7 +166,7 @@ static VALUE rxml_attr_name_get(VALUE self) | |
| 166 166 | 
             
              if (xattr->name == NULL)
         | 
| 167 167 | 
             
                return Qnil;
         | 
| 168 168 | 
             
              else
         | 
| 169 | 
            -
                return  | 
| 169 | 
            +
                return rxml_new_cstr((const char*) xattr->name, NULL);
         | 
| 170 170 | 
             
            }
         | 
| 171 171 |  | 
| 172 172 | 
             
            /*
         | 
| @@ -285,7 +285,7 @@ VALUE rxml_attr_value_get(VALUE self) | |
| 285 285 |  | 
| 286 286 | 
             
              if (value != NULL)
         | 
| 287 287 | 
             
              {
         | 
| 288 | 
            -
                result =  | 
| 288 | 
            +
                result = rxml_new_cstr((const char*) value, NULL);
         | 
| 289 289 | 
             
                xmlFree(value);
         | 
| 290 290 | 
             
              }
         | 
| 291 291 | 
             
              return result;
         | 
| @@ -54,7 +54,7 @@ static VALUE rxml_attr_decl_name_get(VALUE self) | |
| 54 54 | 
             
              if (xattr->name == NULL)
         | 
| 55 55 | 
             
                return Qnil;
         | 
| 56 56 | 
             
              else
         | 
| 57 | 
            -
                return  | 
| 57 | 
            +
                return rxml_new_cstr((const char*) xattr->name, xattr->doc->encoding);
         | 
| 58 58 | 
             
            }
         | 
| 59 59 |  | 
| 60 60 | 
             
            /*
         | 
| @@ -135,7 +135,7 @@ VALUE rxml_attr_decl_value_get(VALUE self) | |
| 135 135 | 
             
              Data_Get_Struct(self, xmlAttribute, xattr);
         | 
| 136 136 |  | 
| 137 137 | 
             
              if (xattr->defaultValue)
         | 
| 138 | 
            -
                return  | 
| 138 | 
            +
                return rxml_new_cstr((const char *)xattr->defaultValue, NULL);
         | 
| 139 139 | 
             
              else
         | 
| 140 140 | 
             
                return Qnil;
         | 
| 141 141 | 
             
            }
         | 
| @@ -174,7 +174,7 @@ static VALUE rxml_document_canonicalize(int argc, VALUE *argv, VALUE self) | |
| 174 174 |  | 
| 175 175 | 
             
              if (buffer)
         | 
| 176 176 | 
             
              {
         | 
| 177 | 
            -
                result =  | 
| 177 | 
            +
                result = rxml_new_cstr((const char*) buffer, NULL);
         | 
| 178 178 | 
             
                xmlFree(buffer);
         | 
| 179 179 | 
             
              }
         | 
| 180 180 |  | 
| @@ -349,10 +349,12 @@ static VALUE rxml_document_rb_encoding_get(VALUE self) | |
| 349 349 | 
             
            {
         | 
| 350 350 | 
             
              xmlDocPtr xdoc;
         | 
| 351 351 | 
             
              const char *xencoding;
         | 
| 352 | 
            +
              rb_encoding* rbencoding;
         | 
| 352 353 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 353 354 |  | 
| 354 355 | 
             
              xencoding = (const char*)xdoc->encoding;
         | 
| 355 | 
            -
               | 
| 356 | 
            +
              rbencoding = rxml_xml_encoding_to_rb_encoding(mXMLEncoding, xmlParseCharEncoding(xencoding));
         | 
| 357 | 
            +
              return rb_enc_from_encoding(rbencoding);
         | 
| 356 358 | 
             
            }
         | 
| 357 359 | 
             
            #endif 
         | 
| 358 360 |  | 
| @@ -734,7 +736,7 @@ static VALUE rxml_document_to_s(int argc, VALUE *argv, VALUE self) | |
| 734 736 | 
             
              Data_Get_Struct(self, xmlDoc, xdoc);
         | 
| 735 737 | 
             
              xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, xencoding, indent);
         | 
| 736 738 |  | 
| 737 | 
            -
              result =  | 
| 739 | 
            +
              result = rxml_new_cstr((const char*) buffer, xencoding);
         | 
| 738 740 | 
             
              xmlFree(buffer);
         | 
| 739 741 | 
             
              return result;
         | 
| 740 742 | 
             
            }
         | 
| @@ -753,7 +755,7 @@ static VALUE rxml_document_url_get(VALUE self) | |
| 753 755 | 
             
              if (xdoc->URL == NULL)
         | 
| 754 756 | 
             
                return (Qnil);
         | 
| 755 757 | 
             
              else
         | 
| 756 | 
            -
                return ( | 
| 758 | 
            +
                return (rxml_new_cstr((const char*) xdoc->URL, NULL));
         | 
| 757 759 | 
             
            }
         | 
| 758 760 |  | 
| 759 761 | 
             
            /*
         | 
| @@ -770,7 +772,7 @@ static VALUE rxml_document_version_get(VALUE self) | |
| 770 772 | 
             
              if (xdoc->version == NULL)
         | 
| 771 773 | 
             
                return (Qnil);
         | 
| 772 774 | 
             
              else
         | 
| 773 | 
            -
                return ( | 
| 775 | 
            +
                return (rxml_new_cstr((const char*) xdoc->version, NULL));
         | 
| 774 776 | 
             
            }
         | 
| 775 777 |  | 
| 776 778 | 
             
            /*
         | 
    
        data/ext/libxml/ruby_xml_dtd.c
    CHANGED
    
    | @@ -90,7 +90,7 @@ static VALUE rxml_dtd_external_id_get(VALUE self) | |
| 90 90 | 
             
              if (xdtd->ExternalID == NULL)
         | 
| 91 91 | 
             
                return (Qnil);
         | 
| 92 92 | 
             
              else
         | 
| 93 | 
            -
                return ( | 
| 93 | 
            +
                return (rxml_new_cstr((const char*) xdtd->ExternalID, NULL));
         | 
| 94 94 | 
             
            }
         | 
| 95 95 |  | 
| 96 96 | 
             
            /*
         | 
| @@ -108,7 +108,7 @@ static VALUE rxml_dtd_name_get(VALUE self) | |
| 108 108 | 
             
              if (xdtd->name == NULL)
         | 
| 109 109 | 
             
                return (Qnil);
         | 
| 110 110 | 
             
              else
         | 
| 111 | 
            -
                return ( | 
| 111 | 
            +
                return (rxml_new_cstr((const char*) xdtd->name, NULL));
         | 
| 112 112 | 
             
            }
         | 
| 113 113 |  | 
| 114 114 |  | 
| @@ -127,7 +127,7 @@ static VALUE rxml_dtd_uri_get(VALUE self) | |
| 127 127 | 
             
              if (xdtd->SystemID == NULL)
         | 
| 128 128 | 
             
                return (Qnil);
         | 
| 129 129 | 
             
              else
         | 
| 130 | 
            -
                return ( | 
| 130 | 
            +
                return (rxml_new_cstr((const char*) xdtd->SystemID, NULL));
         | 
| 131 131 | 
             
            }
         | 
| 132 132 |  | 
| 133 133 | 
             
            /*
         | 
| @@ -71,7 +71,7 @@ static VALUE rxml_encoding_to_s(VALUE klass, VALUE encoding) | |
| 71 71 | 
             
              if (!xencoding)
         | 
| 72 72 | 
             
                return Qnil;
         | 
| 73 73 | 
             
              else
         | 
| 74 | 
            -
                return  | 
| 74 | 
            +
                return rxml_new_cstr(xencoding, xencoding);
         | 
| 75 75 | 
             
            }
         | 
| 76 76 |  | 
| 77 77 | 
             
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| @@ -79,7 +79,7 @@ static VALUE rxml_encoding_to_s(VALUE klass, VALUE encoding) | |
| 79 79 | 
             
             * Converts an xmlCharEncoding enum value into a Ruby Encoding object (available
         | 
| 80 80 | 
             
             * on Ruby 1.9.* and higher).
         | 
| 81 81 | 
             
             */
         | 
| 82 | 
            -
             | 
| 82 | 
            +
            rb_encoding* rxml_xml_encoding_to_rb_encoding(VALUE klass, xmlCharEncoding xmlEncoding)
         | 
| 83 83 | 
             
            {
         | 
| 84 84 | 
             
              const char* encodingName;
         | 
| 85 85 |  | 
| @@ -148,7 +148,7 @@ VALUE rxml_xml_encoding_to_rb_encoding(VALUE klass, xmlCharEncoding xmlEncoding) | |
| 148 148 | 
             
                  break;
         | 
| 149 149 | 
             
              }
         | 
| 150 150 |  | 
| 151 | 
            -
              return  | 
| 151 | 
            +
              return rb_enc_find(encodingName);
         | 
| 152 152 | 
             
            }
         | 
| 153 153 |  | 
| 154 154 | 
             
            /*
         | 
| @@ -160,10 +160,31 @@ VALUE rxml_xml_encoding_to_rb_encoding(VALUE klass, xmlCharEncoding xmlEncoding) | |
| 160 160 | 
             
             */
         | 
| 161 161 | 
             
            VALUE rxml_encoding_to_rb_encoding(VALUE klass, VALUE encoding)
         | 
| 162 162 | 
             
            {
         | 
| 163 | 
            -
               | 
| 163 | 
            +
              xmlCharEncoding xmlEncoding = (xmlCharEncoding)NUM2INT(encoding);
         | 
| 164 | 
            +
              rb_encoding* rbencoding = rxml_xml_encoding_to_rb_encoding(klass, xmlEncoding);
         | 
| 165 | 
            +
              return rb_enc_from_encoding(rbencoding);
         | 
| 164 166 | 
             
            }
         | 
| 165 167 | 
             
            #endif
         | 
| 166 168 |  | 
| 169 | 
            +
             | 
| 170 | 
            +
            VALUE rxml_new_cstr(const char* xstr, const char* xencoding)
         | 
| 171 | 
            +
            {
         | 
| 172 | 
            +
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 173 | 
            +
              rb_encoding* rbencoding;
         | 
| 174 | 
            +
              if (xencoding)
         | 
| 175 | 
            +
              {
         | 
| 176 | 
            +
                xmlCharEncoding xmlEncoding = xmlParseCharEncoding(xencoding);
         | 
| 177 | 
            +
                rbencoding = rxml_xml_encoding_to_rb_encoding(mXMLEncoding, xmlEncoding);
         | 
| 178 | 
            +
              }
         | 
| 179 | 
            +
              else
         | 
| 180 | 
            +
              {
         | 
| 181 | 
            +
                rbencoding = rb_utf8_encoding();
         | 
| 182 | 
            +
              }
         | 
| 183 | 
            +
              return rb_external_str_new_with_enc(xstr, strlen(xstr), rbencoding);
         | 
| 184 | 
            +
            #endif
         | 
| 185 | 
            +
              return rb_str_new2(xstr);
         | 
| 186 | 
            +
            }
         | 
| 187 | 
            +
             | 
| 167 188 | 
             
            void rxml_init_encoding(void)
         | 
| 168 189 | 
             
            {
         | 
| 169 190 | 
             
              mXMLEncoding = rb_define_module_under(mXML, "Encoding");
         | 
| @@ -7,8 +7,11 @@ extern VALUE mXMLEncoding; | |
| 7 7 |  | 
| 8 8 | 
             
            void rxml_init_encoding();
         | 
| 9 9 |  | 
| 10 | 
            +
            // Ruby 1.8/1.9 encoding compatibility
         | 
| 11 | 
            +
            VALUE rxml_new_cstr(const char* xstr, const char* xencoding);
         | 
| 12 | 
            +
             | 
| 10 13 | 
             
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 11 | 
            -
             | 
| 14 | 
            +
            rb_encoding* rxml_xml_encoding_to_rb_encoding(VALUE klass, xmlCharEncoding xmlEncoding);
         | 
| 12 15 | 
             
            #endif
         | 
| 13 16 |  | 
| 14 17 | 
             
            #endif
         | 
| @@ -34,15 +34,6 @@ VALUE rxml_namespace_wrap(xmlNsPtr xns) | |
| 34 34 | 
             
              return Data_Wrap_Struct(cXMLNamespace, NULL, NULL, xns);
         | 
| 35 35 | 
             
            }
         | 
| 36 36 |  | 
| 37 | 
            -
            static VALUE rxml_namespace_string(xmlNsPtr xns, const char* buffer)
         | 
| 38 | 
            -
            {
         | 
| 39 | 
            -
               const char* xencoding = NULL;
         | 
| 40 | 
            -
            #if LIBXML_VERSION >= 20628
         | 
| 41 | 
            -
               xencoding = xns->context ? xns->context->encoding : NULL;
         | 
| 42 | 
            -
            #endif
         | 
| 43 | 
            -
              return rxml_str_new2(buffer, xencoding);
         | 
| 44 | 
            -
            }
         | 
| 45 | 
            -
             | 
| 46 37 |  | 
| 47 38 | 
             
            /*
         | 
| 48 39 | 
             
             * call-seq:
         | 
| @@ -90,7 +81,7 @@ static VALUE rxml_namespace_href_get(VALUE self) | |
| 90 81 | 
             
              if (xns->href == NULL)
         | 
| 91 82 | 
             
                return Qnil;
         | 
| 92 83 | 
             
              else
         | 
| 93 | 
            -
                return  | 
| 84 | 
            +
                return rxml_new_cstr((const char*) xns->href, NULL);
         | 
| 94 85 | 
             
            }
         | 
| 95 86 |  | 
| 96 87 | 
             
            /*
         | 
| @@ -125,7 +116,7 @@ static VALUE rxml_namespace_prefix_get(VALUE self) | |
| 125 116 | 
             
              if (xns->prefix == NULL)
         | 
| 126 117 | 
             
                return Qnil;
         | 
| 127 118 | 
             
              else
         | 
| 128 | 
            -
                return  | 
| 119 | 
            +
                return rxml_new_cstr((const char*) xns->prefix, NULL);
         | 
| 129 120 | 
             
            }
         | 
| 130 121 |  | 
| 131 122 | 
             
            /*
         | 
    
        data/ext/libxml/ruby_xml_node.c
    CHANGED
    
    | @@ -300,7 +300,7 @@ static VALUE rxml_node_base_uri_get(VALUE self) | |
| 300 300 | 
             
              base_uri = xmlNodeGetBase(xnode->doc, xnode);
         | 
| 301 301 | 
             
              if (base_uri)
         | 
| 302 302 | 
             
              {
         | 
| 303 | 
            -
                result =  | 
| 303 | 
            +
                result = rxml_new_cstr((const char*) base_uri, NULL);
         | 
| 304 304 | 
             
                xmlFree(base_uri);
         | 
| 305 305 | 
             
              }
         | 
| 306 306 |  | 
| @@ -344,7 +344,7 @@ static VALUE rxml_node_content_get(VALUE self) | |
| 344 344 | 
             
              content = xmlNodeGetContent(xnode);
         | 
| 345 345 | 
             
              if (content)
         | 
| 346 346 | 
             
              {
         | 
| 347 | 
            -
                result =  | 
| 347 | 
            +
                result = rxml_new_cstr((const char *) content, NULL);
         | 
| 348 348 | 
             
                xmlFree(content);
         | 
| 349 349 | 
             
              }
         | 
| 350 350 |  | 
| @@ -391,7 +391,7 @@ static VALUE rxml_node_content_stripped_get(VALUE self) | |
| 391 391 | 
             
              content = xmlNodeGetContent(xnode);
         | 
| 392 392 | 
             
              if (content)
         | 
| 393 393 | 
             
              {
         | 
| 394 | 
            -
                result =  | 
| 394 | 
            +
                result = rxml_new_cstr((const char*) content, NULL);
         | 
| 395 395 | 
             
                xmlFree(content);
         | 
| 396 396 | 
             
              }
         | 
| 397 397 | 
             
              return (result);
         | 
| @@ -582,9 +582,9 @@ static VALUE rxml_node_to_s(int argc, VALUE *argv, VALUE self) | |
| 582 582 | 
             
              xmlOutputBufferFlush(output);
         | 
| 583 583 |  | 
| 584 584 | 
             
              if (output->conv)
         | 
| 585 | 
            -
                result =  | 
| 585 | 
            +
                result = rxml_new_cstr((const char*) output->conv->content, xencoding);
         | 
| 586 586 | 
             
              else
         | 
| 587 | 
            -
                result =  | 
| 587 | 
            +
                result = rxml_new_cstr((const char*) output->buffer->content, xencoding);
         | 
| 588 588 |  | 
| 589 589 | 
             
              xmlOutputBufferClose(output);
         | 
| 590 590 |  | 
| @@ -688,7 +688,7 @@ static VALUE rxml_node_lang_get(VALUE self) | |
| 688 688 |  | 
| 689 689 | 
             
              if (lang)
         | 
| 690 690 | 
             
              {
         | 
| 691 | 
            -
                result =  | 
| 691 | 
            +
                result = rxml_new_cstr((const char*) lang, NULL);
         | 
| 692 692 | 
             
                xmlFree(lang);
         | 
| 693 693 | 
             
              }
         | 
| 694 694 |  | 
| @@ -821,11 +821,11 @@ static VALUE rxml_node_xlink_type_name(VALUE self) | |
| 821 821 | 
             
              case XLINK_TYPE_NONE:
         | 
| 822 822 | 
             
                return (Qnil);
         | 
| 823 823 | 
             
              case XLINK_TYPE_SIMPLE:
         | 
| 824 | 
            -
                return ( | 
| 824 | 
            +
                return (rxml_new_cstr("simple", NULL));
         | 
| 825 825 | 
             
              case XLINK_TYPE_EXTENDED:
         | 
| 826 | 
            -
                return ( | 
| 826 | 
            +
                return (rxml_new_cstr("extended", NULL));
         | 
| 827 827 | 
             
              case XLINK_TYPE_EXTENDED_SET:
         | 
| 828 | 
            -
                return ( | 
| 828 | 
            +
                return (rxml_new_cstr("extended_set", NULL));
         | 
| 829 829 | 
             
              default:
         | 
| 830 830 | 
             
                rb_fatal("Unknowng xlink type, %d", xlt);
         | 
| 831 831 | 
             
              }
         | 
| @@ -876,7 +876,7 @@ static VALUE rxml_node_name_get(VALUE self) | |
| 876 876 | 
             
              if (xnode->name == NULL)
         | 
| 877 877 | 
             
                return (Qnil);
         | 
| 878 878 | 
             
              else
         | 
| 879 | 
            -
                return ( | 
| 879 | 
            +
                return (rxml_new_cstr((const char*) name, NULL));
         | 
| 880 880 | 
             
            }
         | 
| 881 881 |  | 
| 882 882 | 
             
            /*
         | 
| @@ -968,7 +968,7 @@ static VALUE rxml_node_path(VALUE self) | |
| 968 968 | 
             
              if (path == NULL)
         | 
| 969 969 | 
             
                return (Qnil);
         | 
| 970 970 | 
             
              else
         | 
| 971 | 
            -
                return ( | 
| 971 | 
            +
                return (rxml_new_cstr((const char*) path, NULL));
         | 
| 972 972 | 
             
            }
         | 
| 973 973 |  | 
| 974 974 | 
             
            /*
         | 
| @@ -188,7 +188,7 @@ static VALUE rxml_parser_context_base_uri_get(VALUE self) | |
| 188 188 | 
             
              Data_Get_Struct(self, xmlParserCtxt, ctxt);
         | 
| 189 189 |  | 
| 190 190 | 
             
              if (ctxt->input && ctxt->input->filename)
         | 
| 191 | 
            -
                return  | 
| 191 | 
            +
                return rxml_new_cstr(ctxt->input->filename, ctxt->encoding);
         | 
| 192 192 | 
             
              else
         | 
| 193 193 | 
             
                return Qnil;
         | 
| 194 194 | 
             
            }
         | 
| @@ -229,7 +229,7 @@ static VALUE rxml_parser_context_data_directory_get(VALUE self) | |
| 229 229 | 
             
              if (ctxt->directory == NULL)
         | 
| 230 230 | 
             
                return (Qnil);
         | 
| 231 231 | 
             
              else
         | 
| 232 | 
            -
                return ( | 
| 232 | 
            +
                return (rxml_new_cstr(ctxt->directory, ctxt->encoding));
         | 
| 233 233 | 
             
            }
         | 
| 234 234 |  | 
| 235 235 | 
             
            /*
         | 
| @@ -487,7 +487,7 @@ static VALUE rxml_parser_context_name_node_get(VALUE self) | |
| 487 487 | 
             
              if (ctxt->name == NULL)
         | 
| 488 488 | 
             
                return (Qnil);
         | 
| 489 489 | 
             
              else
         | 
| 490 | 
            -
                return ( | 
| 490 | 
            +
                return (rxml_new_cstr((const char*) ctxt->name, ctxt->encoding));
         | 
| 491 491 | 
             
            }
         | 
| 492 492 |  | 
| 493 493 | 
             
            /*
         | 
| @@ -514,7 +514,7 @@ static VALUE rxml_parser_context_name_tab_get(VALUE self) | |
| 514 514 | 
             
                if (ctxt->nameTab[i] == NULL)
         | 
| 515 515 | 
             
                  continue;
         | 
| 516 516 | 
             
                else
         | 
| 517 | 
            -
                  rb_ary_push(tab_ary,  | 
| 517 | 
            +
                  rb_ary_push(tab_ary, rxml_new_cstr((const char*) ctxt->nameTab[i], ctxt->encoding));
         | 
| 518 518 | 
             
              }
         | 
| 519 519 |  | 
| 520 520 | 
             
              return (tab_ary);
         | 
| @@ -780,7 +780,7 @@ static VALUE rxml_parser_context_subset_name_get(VALUE self) | |
| 780 780 | 
             
              if (ctxt->intSubName == NULL)
         | 
| 781 781 | 
             
                return (Qnil);
         | 
| 782 782 | 
             
              else
         | 
| 783 | 
            -
                return ( | 
| 783 | 
            +
                return (rxml_new_cstr((const char*) ctxt->intSubName, ctxt->encoding));
         | 
| 784 784 | 
             
            }
         | 
| 785 785 |  | 
| 786 786 | 
             
            /*
         | 
| @@ -799,7 +799,7 @@ static VALUE rxml_parser_context_subset_external_uri_get(VALUE self) | |
| 799 799 | 
             
              if (ctxt->extSubURI == NULL)
         | 
| 800 800 | 
             
                return (Qnil);
         | 
| 801 801 | 
             
              else
         | 
| 802 | 
            -
                return ( | 
| 802 | 
            +
                return (rxml_new_cstr((const char*) ctxt->extSubURI, ctxt->encoding));
         | 
| 803 803 | 
             
            }
         | 
| 804 804 |  | 
| 805 805 | 
             
            /*
         | 
| @@ -818,7 +818,7 @@ static VALUE rxml_parser_context_subset_external_system_id_get(VALUE self) | |
| 818 818 | 
             
              if (ctxt->extSubSystem == NULL)
         | 
| 819 819 | 
             
                return (Qnil);
         | 
| 820 820 | 
             
              else
         | 
| 821 | 
            -
                return ( | 
| 821 | 
            +
                return (rxml_new_cstr((const char*) ctxt->extSubSystem, ctxt->encoding));
         | 
| 822 822 | 
             
            }
         | 
| 823 823 |  | 
| 824 824 | 
             
            /*
         | 
| @@ -903,7 +903,7 @@ static VALUE rxml_parser_context_version_get(VALUE self) | |
| 903 903 | 
             
              if (ctxt->version == NULL)
         | 
| 904 904 | 
             
                return (Qnil);
         | 
| 905 905 | 
             
              else
         | 
| 906 | 
            -
                return ( | 
| 906 | 
            +
                return (rxml_new_cstr((const char*) ctxt->version, ctxt->encoding));
         | 
| 907 907 | 
             
            }
         | 
| 908 908 |  | 
| 909 909 | 
             
            /*
         | 
| @@ -489,7 +489,7 @@ static VALUE rxml_reader_read_inner_xml(VALUE self) | |
| 489 489 | 
             
              if (xml)
         | 
| 490 490 | 
             
              {
         | 
| 491 491 | 
             
                const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 492 | 
            -
                result =  | 
| 492 | 
            +
                result = rxml_new_cstr((const char*) xml, xencoding);
         | 
| 493 493 | 
             
                xmlFree(xml);
         | 
| 494 494 | 
             
              }
         | 
| 495 495 |  | 
| @@ -515,7 +515,7 @@ static VALUE rxml_reader_read_outer_xml(VALUE self) | |
| 515 515 | 
             
              if (xml)
         | 
| 516 516 | 
             
              {
         | 
| 517 517 | 
             
                const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 518 | 
            -
                result =  | 
| 518 | 
            +
                result = rxml_new_cstr((const char*) xml, xencoding);
         | 
| 519 519 | 
             
                xmlFree(xml);
         | 
| 520 520 | 
             
              }
         | 
| 521 521 |  | 
| @@ -553,7 +553,7 @@ static VALUE rxml_reader_read_string(VALUE self) | |
| 553 553 | 
             
              if (xml)
         | 
| 554 554 | 
             
              {
         | 
| 555 555 | 
             
                const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 556 | 
            -
                result =  | 
| 556 | 
            +
                result = rxml_new_cstr((const char*) xml, xencoding);
         | 
| 557 557 | 
             
                xmlFree(xml);
         | 
| 558 558 | 
             
              }
         | 
| 559 559 |  | 
| @@ -612,7 +612,7 @@ static VALUE rxml_reader_name(VALUE self) | |
| 612 612 | 
             
              const xmlChar *result = xmlTextReaderConstName(xReader);
         | 
| 613 613 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 614 614 |  | 
| 615 | 
            -
              return (result == NULL ? Qnil :  | 
| 615 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 616 616 | 
             
            }
         | 
| 617 617 |  | 
| 618 618 | 
             
            /*
         | 
| @@ -627,7 +627,7 @@ static VALUE rxml_reader_local_name(VALUE self) | |
| 627 627 | 
             
              const xmlChar *result = xmlTextReaderConstLocalName(xReader);
         | 
| 628 628 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 629 629 |  | 
| 630 | 
            -
              return (result == NULL ? Qnil :  | 
| 630 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 631 631 | 
             
            }
         | 
| 632 632 |  | 
| 633 633 | 
             
            /*
         | 
| @@ -680,7 +680,7 @@ static VALUE rxml_reader_base_uri(VALUE self) | |
| 680 680 | 
             
              const xmlChar *result = xmlTextReaderConstBaseUri(xReader);
         | 
| 681 681 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 682 682 |  | 
| 683 | 
            -
              return (result == NULL ? Qnil :  | 
| 683 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 684 684 | 
             
            }
         | 
| 685 685 |  | 
| 686 686 | 
             
            /*
         | 
| @@ -695,7 +695,7 @@ static VALUE rxml_reader_namespace_uri(VALUE self) | |
| 695 695 | 
             
              const xmlChar *result = xmlTextReaderConstNamespaceUri(xReader);
         | 
| 696 696 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 697 697 |  | 
| 698 | 
            -
              return (result == NULL ? Qnil :  | 
| 698 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 699 699 | 
             
            }
         | 
| 700 700 |  | 
| 701 701 | 
             
            /*
         | 
| @@ -710,7 +710,7 @@ static VALUE rxml_reader_value(VALUE self) | |
| 710 710 | 
             
              const xmlChar *result = xmlTextReaderConstValue(xReader);
         | 
| 711 711 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 712 712 |  | 
| 713 | 
            -
              return (result == NULL ? Qnil :  | 
| 713 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 714 714 | 
             
            }
         | 
| 715 715 |  | 
| 716 716 | 
             
            /*
         | 
| @@ -725,7 +725,7 @@ static VALUE rxml_reader_prefix(VALUE self) | |
| 725 725 | 
             
              const xmlChar *result = xmlTextReaderConstPrefix(xReader);
         | 
| 726 726 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 727 727 |  | 
| 728 | 
            -
              return (result == NULL ? Qnil :  | 
| 728 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 729 729 | 
             
            }
         | 
| 730 730 |  | 
| 731 731 | 
             
            /*
         | 
| @@ -781,7 +781,7 @@ static VALUE rxml_reader_xml_lang(VALUE self) | |
| 781 781 | 
             
              const xmlChar *result = xmlTextReaderConstXmlLang(xReader);
         | 
| 782 782 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 783 783 |  | 
| 784 | 
            -
              return (result == NULL ? Qnil :  | 
| 784 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 785 785 | 
             
            }
         | 
| 786 786 |  | 
| 787 787 | 
             
            /*
         | 
| @@ -796,7 +796,7 @@ static VALUE rxml_reader_xml_version(VALUE self) | |
| 796 796 | 
             
              const xmlChar *result = xmlTextReaderConstXmlVersion(xReader);
         | 
| 797 797 | 
             
              const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
         | 
| 798 798 |  | 
| 799 | 
            -
              return (result == NULL ? Qnil :  | 
| 799 | 
            +
              return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
         | 
| 800 800 | 
             
            }
         | 
| 801 801 |  | 
| 802 802 | 
             
            /*
         | 
| @@ -849,7 +849,7 @@ static VALUE rxml_reader_attribute(VALUE self, VALUE key) | |
| 849 849 |  | 
| 850 850 | 
             
              if (xattr)
         | 
| 851 851 | 
             
              {
         | 
| 852 | 
            -
                result =  | 
| 852 | 
            +
                result = rxml_new_cstr(xattr, xencoding);
         | 
| 853 853 | 
             
                xmlFree(xattr);
         | 
| 854 854 | 
             
              }
         | 
| 855 855 | 
             
              return result;
         | 
| @@ -871,7 +871,7 @@ static VALUE rxml_reader_lookup_namespace(VALUE self, VALUE prefix) | |
| 871 871 |  | 
| 872 872 | 
             
              if (xnamespace)
         | 
| 873 873 | 
             
              {
         | 
| 874 | 
            -
                result =  | 
| 874 | 
            +
                result = rxml_new_cstr((const char*)xnamespace, (const char*)xencoding);
         | 
| 875 875 | 
             
                xmlFree((void *)xnamespace);
         | 
| 876 876 | 
             
              }
         | 
| 877 877 | 
             
              return result;
         | 
| @@ -1,9 +1,9 @@ | |
| 1 1 | 
             
            /* Don't nuke this block!  It is used for automatically updating the
         | 
| 2 2 | 
             
             * versions below. VERSION = string formatting, VERNUM = numbered
         | 
| 3 3 | 
             
             * version for inline testing: increment both or none at all.*/
         | 
| 4 | 
            -
            #define RUBY_LIBXML_VERSION  "2. | 
| 5 | 
            -
            #define RUBY_LIBXML_VERNUM    | 
| 4 | 
            +
            #define RUBY_LIBXML_VERSION  "2.2.0"
         | 
| 5 | 
            +
            #define RUBY_LIBXML_VERNUM   220
         | 
| 6 6 | 
             
            #define RUBY_LIBXML_VER_MAJ   2
         | 
| 7 | 
            -
            #define RUBY_LIBXML_VER_MIN    | 
| 8 | 
            -
            #define RUBY_LIBXML_VER_MIC    | 
| 7 | 
            +
            #define RUBY_LIBXML_VER_MIN   2
         | 
| 8 | 
            +
            #define RUBY_LIBXML_VER_MIC   0
         | 
| 9 9 | 
             
            #define RUBY_LIBXML_VER_PATCH 0
         | 
    
        data/ext/libxml/ruby_xml_xpath.c
    CHANGED
    
    | @@ -104,7 +104,7 @@ rxml_xpath_to_value(xmlXPathContextPtr xctxt, xmlXPathObjectPtr xobject) { | |
| 104 104 | 
             
                  xmlXPathFreeObject(xobject);
         | 
| 105 105 | 
             
                  break;
         | 
| 106 106 | 
             
                case XPATH_STRING:
         | 
| 107 | 
            -
                  result =  | 
| 107 | 
            +
                  result = rxml_new_cstr((const char*)xobject->stringval, xctxt->doc->encoding);
         | 
| 108 108 | 
             
                  xmlXPathFreeObject(xobject);
         | 
| 109 109 | 
             
                  break;
         | 
| 110 110 | 
             
                default:
         | 
| @@ -159,8 +159,8 @@ static VALUE rxml_xpath_context_register_namespaces_from_node(VALUE self, | |
| 159 159 | 
             
                   Skip it for now. */
         | 
| 160 160 | 
             
                  if (xns->prefix)
         | 
| 161 161 | 
             
                  {
         | 
| 162 | 
            -
                    VALUE prefix =  | 
| 163 | 
            -
                    VALUE uri =  | 
| 162 | 
            +
                    VALUE prefix = rxml_new_cstr((const char*)xns->prefix, xctxt->doc->encoding);
         | 
| 163 | 
            +
                    VALUE uri = rxml_new_cstr((const char*)xns->href, xctxt->doc->encoding);
         | 
| 164 164 | 
             
                    rxml_xpath_context_register_namespace(self, prefix, uri);
         | 
| 165 165 | 
             
                  }
         | 
| 166 166 | 
             
                  xns = xns->next;
         | 
| @@ -215,7 +215,7 @@ static VALUE rxml_xpath_context_register_namespaces(VALUE self, VALUE nslist) | |
| 215 215 | 
             
                {
         | 
| 216 216 | 
             
                  rprefix = rb_str_new(StringValuePtr(nslist), (int) ((long) cp
         | 
| 217 217 | 
             
                      - (long) StringValuePtr(nslist)));
         | 
| 218 | 
            -
                  ruri =  | 
| 218 | 
            +
                  ruri = rxml_new_cstr(&cp[1], xctxt->doc->encoding);
         | 
| 219 219 | 
             
                }
         | 
| 220 220 | 
             
                /* Should test the results of this */
         | 
| 221 221 | 
             
                rxml_xpath_context_register_namespace(self, rprefix, ruri);
         | 
| @@ -292,7 +292,7 @@ static VALUE rxml_xpath_object_string(VALUE self) | |
| 292 292 | 
             
              if (rxpop->xpop->stringval == NULL)
         | 
| 293 293 | 
             
                return Qnil;
         | 
| 294 294 |  | 
| 295 | 
            -
              return  | 
| 295 | 
            +
              return rxml_new_cstr((const char*) rxpop->xpop->stringval, rxpop->xdoc->encoding);
         | 
| 296 296 | 
             
            }
         | 
| 297 297 |  | 
| 298 298 | 
             
            /*
         | 
    
        data/lib/1.8/libxml_ruby.so
    CHANGED
    
    | Binary file | 
    
        data/lib/1.9/libxml_ruby.so
    CHANGED
    
    | Binary file | 
    
        data/test/new_main.rb
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            string1 = "(ISC)²"
         | 
| 4 | 
            +
            puts string1.encoding
         | 
| 5 | 
            +
            puts string1.bytes.to_a.join(' ')
         | 
| 6 | 
            +
            puts string1
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            puts ""
         | 
| 9 | 
            +
            string2 = string1.encode('iso-8859-1')
         | 
| 10 | 
            +
            puts string2.encoding
         | 
| 11 | 
            +
            puts string2.bytes.to_a.join(' ')
         | 
| 12 | 
            +
            puts string2
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            puts ""
         | 
| 15 | 
            +
            string3 = string1.force_encoding('iso-8859-1').encode('utf-8')
         | 
| 16 | 
            +
            puts string3.encoding
         | 
| 17 | 
            +
            puts string3.bytes.to_a.join(' ')
         | 
| 18 | 
            +
            puts string3
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            #UTF-8
         | 
| 21 | 
            +
            #40 73 83 67 41 194 178
         | 
| 22 | 
            +
            #(ISC)²
         | 
| 23 | 
            +
            #
         | 
| 24 | 
            +
            #ISO-8859-1
         | 
| 25 | 
            +
            #40 73 83 67 41 178
         | 
| 26 | 
            +
            #(ISC)²
         | 
| 27 | 
            +
             | 
| 28 | 
            +
             | 
| 29 | 
            +
            #40 73 83 67 41 195 130 194 178
         | 
    
        data/test/tc_attr.rb
    CHANGED
    
    | @@ -48,7 +48,7 @@ class AttrNodeTest < Test::Unit::TestCase | |
| 48 48 | 
             
              def test_name
         | 
| 49 49 | 
             
                attribute = city_member.attributes.get_attribute('name')
         | 
| 50 50 | 
             
                assert_equal('name', attribute.name)
         | 
| 51 | 
            -
                assert_equal(Encoding:: | 
| 51 | 
            +
                assert_equal(Encoding::UTF_8, attribute.name.encoding) if defined?(Encoding)
         | 
| 52 52 |  | 
| 53 53 | 
             
                attribute = city_member.attributes.get_attribute('href')
         | 
| 54 54 | 
             
                assert_equal('href', attribute.name)
         | 
| @@ -64,7 +64,7 @@ class AttrNodeTest < Test::Unit::TestCase | |
| 64 64 | 
             
              def test_value
         | 
| 65 65 | 
             
                attribute = city_member.attributes.get_attribute('name')
         | 
| 66 66 | 
             
                assert_equal('Cambridge', attribute.value)
         | 
| 67 | 
            -
                assert_equal(Encoding:: | 
| 67 | 
            +
                assert_equal(Encoding::UTF_8, attribute.value.encoding) if defined?(Encoding)
         | 
| 68 68 |  | 
| 69 69 | 
             
                attribute = city_member.attributes.get_attribute('href')
         | 
| 70 70 | 
             
                assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
         | 
| @@ -74,12 +74,12 @@ class AttrNodeTest < Test::Unit::TestCase | |
| 74 74 | 
             
                attribute = city_member.attributes.get_attribute('name')
         | 
| 75 75 | 
             
                attribute.value = 'London'
         | 
| 76 76 | 
             
                assert_equal('London', attribute.value)
         | 
| 77 | 
            -
                assert_equal(Encoding:: | 
| 77 | 
            +
                assert_equal(Encoding::UTF_8, attribute.value.encoding) if defined?(Encoding)
         | 
| 78 78 |  | 
| 79 79 | 
             
                attribute = city_member.attributes.get_attribute('href')
         | 
| 80 80 | 
             
                attribute.value = 'http://i.have.changed'
         | 
| 81 81 | 
             
                assert_equal('http://i.have.changed', attribute.value)
         | 
| 82 | 
            -
                assert_equal(Encoding:: | 
| 82 | 
            +
                assert_equal(Encoding::UTF_8, attribute.value.encoding) if defined?(Encoding)
         | 
| 83 83 | 
             
              end
         | 
| 84 84 |  | 
| 85 85 | 
             
              def test_set_nil
         | 
    
        data/test/tc_document.rb
    CHANGED
    
    | @@ -88,20 +88,6 @@ class TestDocument < Test::Unit::TestCase | |
| 88 88 | 
             
                             @doc.to_s(:indent => false))
         | 
| 89 89 | 
             
              end
         | 
| 90 90 |  | 
| 91 | 
            -
              def test_encoding
         | 
| 92 | 
            -
                doc = XML::Document.new
         | 
| 93 | 
            -
                assert_equal(XML::Encoding::NONE, doc.encoding)
         | 
| 94 | 
            -
                assert_equal(Encoding::ASCII_8BIT, doc.rb_encoding) if defined?(Encoding)
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.xml'))
         | 
| 97 | 
            -
                doc = XML::Document.file(file)
         | 
| 98 | 
            -
                assert_equal(XML::Encoding::UTF_8, doc.encoding)
         | 
| 99 | 
            -
                assert_equal(Encoding::UTF_8, doc.rb_encoding) if defined?(Encoding)
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                doc.encoding = XML::Encoding::ISO_8859_1
         | 
| 102 | 
            -
                assert_equal(XML::Encoding::ISO_8859_1, doc.encoding)
         | 
| 103 | 
            -
                assert_equal(Encoding::ISO8859_1, doc.rb_encoding) if defined?(Encoding)
         | 
| 104 | 
            -
              end
         | 
| 105 91 |  | 
| 106 92 | 
             
              def test_doc_node_type
         | 
| 107 93 | 
             
                assert_equal(XML::Node::DOCUMENT_NODE, XML::Document.new.node_type)
         | 
    
        data/test/tc_document_write.rb
    CHANGED
    
    | @@ -6,17 +6,7 @@ require 'test/unit' | |
| 6 6 |  | 
| 7 7 | 
             
            class TestDocumentWrite < Test::Unit::TestCase
         | 
| 8 8 | 
             
              def setup
         | 
| 9 | 
            -
                 | 
| 10 | 
            -
              end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              def teardown
         | 
| 13 | 
            -
                XML.default_keep_blanks = true
         | 
| 14 | 
            -
                @doc = nil
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
              def load_encoding(name)
         | 
| 18 | 
            -
                @encoding = Encoding.find(name) if defined?(Encoding)
         | 
| 19 | 
            -
                @file_name = "model/bands.#{name.downcase}.xml"
         | 
| 9 | 
            +
                @file_name = "model/bands.utf-8.xml"
         | 
| 20 10 |  | 
| 21 11 | 
             
                # Strip spaces to make testing easier
         | 
| 22 12 | 
             
                XML.default_keep_blanks = false
         | 
| @@ -24,6 +14,11 @@ class TestDocumentWrite < Test::Unit::TestCase | |
| 24 14 | 
             
                @doc = XML::Document.file(file)
         | 
| 25 15 | 
             
              end
         | 
| 26 16 |  | 
| 17 | 
            +
              def teardown
         | 
| 18 | 
            +
                XML.default_keep_blanks = true
         | 
| 19 | 
            +
                @doc = nil
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 27 22 | 
             
              # ---  to_s tests  ---
         | 
| 28 23 | 
             
              def test_to_s_default
         | 
| 29 24 | 
             
                # Default to_s has indentation
         | 
    
        data/test/tc_encoding.rb
    ADDED
    
    | @@ -0,0 +1,119 @@ | |
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            if defined?(Encoding)
         | 
| 4 | 
            +
            require './test_helper'
         | 
| 5 | 
            +
            require 'test/unit'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Code  UTF8        Latin1      Hex
         | 
| 8 | 
            +
            # m      109          109        6D
         | 
| 9 | 
            +
            # ö      195 182      246        C3 B6 / F6
         | 
| 10 | 
            +
            # t      116          116        74
         | 
| 11 | 
            +
            # l      108          108        6C
         | 
| 12 | 
            +
            # e      101          101        65
         | 
| 13 | 
            +
            # y      121          121        79
         | 
| 14 | 
            +
            # _       95           95        5F
         | 
| 15 | 
            +
            # c       99           99        63
         | 
| 16 | 
            +
            # r      114          114        72
         | 
| 17 | 
            +
            # ü      195 188      252        C3 BC / FC
         | 
| 18 | 
            +
            # e      101          101        65
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            # See:
         | 
| 21 | 
            +
            #  http://en.wikipedia.org/wiki/ISO/IEC_8859-1
         | 
| 22 | 
            +
            #  http://en.wikipedia.org/wiki/List_of_Unicode_characters
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            class TestEncoding < Test::Unit::TestCase
         | 
| 25 | 
            +
              def setup
         | 
| 26 | 
            +
                Encoding.default_internal = nil
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def load_encoding(encoding)
         | 
| 30 | 
            +
                @encoding = encoding
         | 
| 31 | 
            +
                file_name = "model/bands.#{@encoding.name.downcase}.xml"
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                # Strip spaces to make testing easier
         | 
| 34 | 
            +
                XML.default_keep_blanks = false
         | 
| 35 | 
            +
                file = File.join(File.dirname(__FILE__), file_name)
         | 
| 36 | 
            +
                @doc = XML::Document.file(file)
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
              
         | 
| 39 | 
            +
              def test_encoding
         | 
| 40 | 
            +
                doc = XML::Document.new
         | 
| 41 | 
            +
                assert_equal(XML::Encoding::NONE, doc.encoding)
         | 
| 42 | 
            +
                assert_equal(Encoding::ASCII_8BIT, doc.rb_encoding) if defined?(Encoding)
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.xml'))
         | 
| 45 | 
            +
                doc = XML::Document.file(file)
         | 
| 46 | 
            +
                assert_equal(XML::Encoding::UTF_8, doc.encoding)
         | 
| 47 | 
            +
                assert_equal(Encoding::UTF_8, doc.rb_encoding) if defined?(Encoding)
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                doc.encoding = XML::Encoding::ISO_8859_1
         | 
| 50 | 
            +
                assert_equal(XML::Encoding::ISO_8859_1, doc.encoding)
         | 
| 51 | 
            +
                assert_equal(Encoding::ISO8859_1, doc.rb_encoding) if defined?(Encoding)
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              def test_no_internal_encoding_iso_8859_1
         | 
| 55 | 
            +
                Encoding.default_internal = nil
         | 
| 56 | 
            +
                load_encoding(Encoding::ISO_8859_1)
         | 
| 57 | 
            +
                node = @doc.root.children.first
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                name = node.name
         | 
| 60 | 
            +
                assert_equal(Encoding::UTF_8, name.encoding)
         | 
| 61 | 
            +
                assert_equal("m\u00F6tley_cr\u00FCe", name)
         | 
| 62 | 
            +
                assert_equal("109 195 182 116 108 101 121 95 99 114 195 188 101",
         | 
| 63 | 
            +
                             name.bytes.to_a.join(" "))
         | 
| 64 | 
            +
                assert_equal("M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.",
         | 
| 65 | 
            +
                             node.content)
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                name = name.encode(Encoding::ISO_8859_1)
         | 
| 68 | 
            +
                assert_equal(Encoding::ISO_8859_1, name.encoding)
         | 
| 69 | 
            +
                assert_equal("m\xF6tley_cr\xFCe".force_encoding(Encoding::ISO_8859_1), name)
         | 
| 70 | 
            +
                assert_equal("109 246 116 108 101 121 95 99 114 252 101",
         | 
| 71 | 
            +
                             name.bytes.to_a.join(" "))
         | 
| 72 | 
            +
                assert_equal("M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.".force_encoding(Encoding::ISO_8859_1),
         | 
| 73 | 
            +
                            node.content.encode(Encoding::ISO_8859_1))
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
              def test_internal_encoding_iso_8859_1
         | 
| 77 | 
            +
                Encoding.default_internal = Encoding::ISO_8859_1
         | 
| 78 | 
            +
                load_encoding(Encoding::ISO_8859_1)
         | 
| 79 | 
            +
                node = @doc.root.children.first
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                name = node.name
         | 
| 82 | 
            +
                assert_equal(Encoding::ISO_8859_1, name.encoding)
         | 
| 83 | 
            +
                assert_equal("109 246 116 108 101 121 95 99 114 252 101",
         | 
| 84 | 
            +
                             name.bytes.to_a.join(" "))
         | 
| 85 | 
            +
                assert_equal("m\xF6tley_cr\xFCe".force_encoding(Encoding::ISO_8859_1), name)
         | 
| 86 | 
            +
                assert_equal("109 246 116 108 101 121 95 99 114 252 101",
         | 
| 87 | 
            +
                             name.bytes.to_a.join(" "))
         | 
| 88 | 
            +
                assert_equal("M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.".force_encoding(Encoding::ISO_8859_1),
         | 
| 89 | 
            +
                            node.content.encode(Encoding::ISO_8859_1))
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              def test_no_internal_encoding_utf_8
         | 
| 93 | 
            +
                Encoding.default_internal = nil
         | 
| 94 | 
            +
                load_encoding(Encoding::UTF_8)
         | 
| 95 | 
            +
                node = @doc.root.children.first
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                name = node.name
         | 
| 98 | 
            +
                assert_equal(@encoding, name.encoding)
         | 
| 99 | 
            +
                assert_equal("109 195 182 116 108 101 121 95 99 114 195 188 101",
         | 
| 100 | 
            +
                             name.bytes.to_a.join(" "))
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                name = name.encode(Encoding::ISO_8859_1)
         | 
| 103 | 
            +
                assert_equal(Encoding::ISO_8859_1, name.encoding)
         | 
| 104 | 
            +
                assert_equal("109 246 116 108 101 121 95 99 114 252 101",
         | 
| 105 | 
            +
                             name.bytes.to_a.join(" "))
         | 
| 106 | 
            +
              end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
              def test_internal_encoding_utf_8
         | 
| 109 | 
            +
                Encoding.default_internal = Encoding::ISO_8859_1
         | 
| 110 | 
            +
                load_encoding(Encoding::UTF_8)
         | 
| 111 | 
            +
                node = @doc.root.children.first
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                name = node.name
         | 
| 114 | 
            +
                assert_equal(Encoding::ISO_8859_1, name.encoding)
         | 
| 115 | 
            +
                assert_equal("109 246 116 108 101 121 95 99 114 252 101",
         | 
| 116 | 
            +
                             name.bytes.to_a.join(" "))
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
            end
         | 
| 119 | 
            +
            end
         | 
    
        data/test/tc_node.rb
    CHANGED
    
    | @@ -5,23 +5,18 @@ require 'test/unit' | |
| 5 5 |  | 
| 6 6 | 
             
            class TestNode < Test::Unit::TestCase
         | 
| 7 7 | 
             
              def setup
         | 
| 8 | 
            -
                 | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
              
         | 
| 11 | 
            -
              def teardown
         | 
| 12 | 
            -
                XML.default_keep_blanks = true
         | 
| 13 | 
            -
                @doc = nil
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              def load_encoding(name)
         | 
| 17 | 
            -
                @encoding = Encoding.find(name) if defined?(Encoding)
         | 
| 18 | 
            -
                @file_name = "model/bands.#{name.downcase}.xml"
         | 
| 8 | 
            +
                @file_name = "model/bands.utf-8.xml"
         | 
| 19 9 |  | 
| 20 10 | 
             
                # Strip spaces to make testing easier
         | 
| 21 11 | 
             
                XML.default_keep_blanks = false
         | 
| 22 12 | 
             
                file = File.join(File.dirname(__FILE__), @file_name)
         | 
| 23 13 | 
             
                @doc = XML::Document.file(file)
         | 
| 24 14 | 
             
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              def teardown
         | 
| 17 | 
            +
                XML.default_keep_blanks = true
         | 
| 18 | 
            +
                @doc = nil
         | 
| 19 | 
            +
              end
         | 
| 25 20 |  | 
| 26 21 | 
             
              def nodes
         | 
| 27 22 | 
             
                # Find all nodes with a country attributes
         | 
| @@ -65,7 +60,7 @@ class TestNode < Test::Unit::TestCase | |
| 65 60 | 
             
                assert_instance_of(XML::Node, @doc.root.child)
         | 
| 66 61 |  | 
| 67 62 | 
             
                if defined?(Encoding)
         | 
| 68 | 
            -
                  assert_equal( | 
| 63 | 
            +
                  assert_equal(Encoding::UTF_8, @doc.root.child.name.encoding)
         | 
| 69 64 | 
             
                  assert_equal("m\u00F6tley_cr\u00FCe", @doc.root.child.name)
         | 
| 70 65 | 
             
                else
         | 
| 71 66 | 
             
                  assert_equal("m\303\266tley_cr\303\274e", @doc.root.child.name)
         | 
| @@ -79,25 +74,8 @@ class TestNode < Test::Unit::TestCase | |
| 79 74 | 
             
              end
         | 
| 80 75 |  | 
| 81 76 | 
             
              def test_name
         | 
| 82 | 
            -
                 | 
| 83 | 
            -
             | 
| 84 | 
            -
                  assert_equal("m\u00F6tley_cr\u00FCe", nodes[0].name)
         | 
| 85 | 
            -
                else
         | 
| 86 | 
            -
                  assert_equal("m\303\266tley_cr\303\274e", nodes[0].name)
         | 
| 87 | 
            -
                end
         | 
| 88 | 
            -
                assert_equal("iron_maiden", nodes[1].name)
         | 
| 89 | 
            -
              end
         | 
| 90 | 
            -
             | 
| 91 | 
            -
              def test_name_iso_8859_1
         | 
| 92 | 
            -
                load_encoding("iso-8859-1")
         | 
| 93 | 
            -
                
         | 
| 94 | 
            -
                if defined?(Encoding)
         | 
| 95 | 
            -
                  assert_equal(@encoding, nodes[0].name.encoding)
         | 
| 96 | 
            -
                  assert_equal("m\303\266tley_cr\303\274e".force_encoding(@encoding), nodes[0].name)
         | 
| 97 | 
            -
                else
         | 
| 98 | 
            -
                  assert_equal("m\303\266tley_cr\303\274e", nodes[0].name)
         | 
| 99 | 
            -
                end
         | 
| 100 | 
            -
                assert_equal("iron_maiden", nodes[1].name)
         | 
| 77 | 
            +
                node = @doc.root.children.last
         | 
| 78 | 
            +
                assert_equal("iron_maiden", node.name)
         | 
| 101 79 | 
             
              end
         | 
| 102 80 |  | 
| 103 81 | 
             
              def test_node_find
         | 
| @@ -140,47 +118,9 @@ class TestNode < Test::Unit::TestCase | |
| 140 118 | 
             
              end
         | 
| 141 119 |  | 
| 142 120 | 
             
              def test_content
         | 
| 143 | 
            -
                 | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
                               @doc.root.content)
         | 
| 147 | 
            -
             | 
| 148 | 
            -
                  first = @doc.root.child
         | 
| 149 | 
            -
                  assert_equal("M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.",
         | 
| 150 | 
            -
                               first.content)
         | 
| 151 | 
            -
                  assert_equal("Iron Maiden is a British heavy metal band formed in 1975.", first.next.content)
         | 
| 152 | 
            -
                else
         | 
| 153 | 
            -
                  assert_equal("M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.Iron Maiden is a British heavy metal band formed in 1975.",
         | 
| 154 | 
            -
                               @doc.root.content)
         | 
| 155 | 
            -
             | 
| 156 | 
            -
                  first = @doc.root.child
         | 
| 157 | 
            -
                  assert_equal("M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.",
         | 
| 158 | 
            -
                               first.content)
         | 
| 159 | 
            -
                  assert_equal("Iron Maiden is a British heavy metal band formed in 1975.",
         | 
| 160 | 
            -
                               first.next.content)
         | 
| 161 | 
            -
                end
         | 
| 162 | 
            -
              end
         | 
| 163 | 
            -
             | 
| 164 | 
            -
              def test_content_iso_8859_1
         | 
| 165 | 
            -
                load_encoding("iso-8859-1")
         | 
| 166 | 
            -
                if defined?(Encoding)
         | 
| 167 | 
            -
                  assert_equal(@encoding, @doc.root.content.encoding)
         | 
| 168 | 
            -
                  assert_equal("M\xC3\xB6tley Cr\xC3\xBCe is an American heavy metal band formed in Los Angeles, California in 1981.Iron Maiden is a British heavy metal band formed in 1975.".force_encoding(@encoding),
         | 
| 169 | 
            -
                               @doc.root.content)
         | 
| 170 | 
            -
             | 
| 171 | 
            -
                  first = @doc.root.child
         | 
| 172 | 
            -
                  assert_equal("M\xC3\xB6tley Cr\xC3\xBCe is an American heavy metal band formed in Los Angeles, California in 1981.".force_encoding(@encoding),
         | 
| 173 | 
            -
                               first.content)
         | 
| 174 | 
            -
                  assert_equal("Iron Maiden is a British heavy metal band formed in 1975.", first.next.content)
         | 
| 175 | 
            -
                else
         | 
| 176 | 
            -
                  assert_equal("M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.Iron Maiden is a British heavy metal band formed in 1975.",
         | 
| 177 | 
            -
                               @doc.root.content)
         | 
| 178 | 
            -
             | 
| 179 | 
            -
                  first = @doc.root.child
         | 
| 180 | 
            -
                  assert_equal("M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.",
         | 
| 181 | 
            -
                               first.content)
         | 
| 182 | 
            -
                  assert_equal("Iron Maiden is a British heavy metal band formed in 1975.", first.next.content)
         | 
| 183 | 
            -
                end
         | 
| 121 | 
            +
                node = @doc.root.last
         | 
| 122 | 
            +
                assert_equal("Iron Maiden is a British heavy metal band formed in 1975.",
         | 
| 123 | 
            +
                             node.content)
         | 
| 184 124 | 
             
              end
         | 
| 185 125 |  | 
| 186 126 | 
             
              def test_base
         | 
    
        data/test/tc_parser.rb
    CHANGED
    
    | @@ -227,8 +227,8 @@ class TestParser < Test::Unit::TestCase | |
| 227 227 | 
             
                doc = parser.parse
         | 
| 228 228 | 
             
                node = doc.find_first('//metal')
         | 
| 229 229 | 
             
                if defined?(Encoding)
         | 
| 230 | 
            -
                  assert_equal(Encoding:: | 
| 231 | 
            -
                  assert_equal("m\303\266tley_cr\303\274e" | 
| 230 | 
            +
                  assert_equal(Encoding::UTF_8, node.content.encoding)
         | 
| 231 | 
            +
                  assert_equal("m\303\266tley_cr\303\274e", node.content)
         | 
| 232 232 | 
             
                else
         | 
| 233 233 | 
             
                  assert_equal("m\303\266tley_cr\303\274e", node.content)
         | 
| 234 234 | 
             
                end
         | 
    
        data/test/test_suite.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: libxml-ruby
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 7
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 2
         | 
| 8 | 
            -
              - 1
         | 
| 9 8 | 
             
              - 2
         | 
| 10 | 
            -
               | 
| 9 | 
            +
              - 0
         | 
| 10 | 
            +
              version: 2.2.0
         | 
| 11 11 | 
             
            platform: x86-mingw32
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Ross Bamform
         | 
| @@ -20,7 +20,7 @@ autorequire: | |
| 20 20 | 
             
            bindir: bin
         | 
| 21 21 | 
             
            cert_chain: []
         | 
| 22 22 |  | 
| 23 | 
            -
            date: 2011-08- | 
| 23 | 
            +
            date: 2011-08-09 00:00:00 Z
         | 
| 24 24 | 
             
            dependencies: []
         | 
| 25 25 |  | 
| 26 26 | 
             
            description: "    The Libxml-Ruby project provides Ruby language bindings for the GNOME\n    Libxml2 XML toolkit. It is free software, released under the MIT License.\n    Libxml-ruby's primary advantage over REXML is performance - if speed\n    is your need, these are good libraries to consider, as demonstrated\n    by the informal benchmark below.\n"
         | 
| @@ -156,6 +156,7 @@ files: | |
| 156 156 | 
             
            - test/model/shiporder.xsd
         | 
| 157 157 | 
             
            - test/model/soap.xml
         | 
| 158 158 | 
             
            - test/model/xinclude.xml
         | 
| 159 | 
            +
            - test/new_main.rb
         | 
| 159 160 | 
             
            - test/tc_attr.rb
         | 
| 160 161 | 
             
            - test/tc_attributes.rb
         | 
| 161 162 | 
             
            - test/tc_attr_decl.rb
         | 
| @@ -163,6 +164,7 @@ files: | |
| 163 164 | 
             
            - test/tc_document.rb
         | 
| 164 165 | 
             
            - test/tc_document_write.rb
         | 
| 165 166 | 
             
            - test/tc_dtd.rb
         | 
| 167 | 
            +
            - test/tc_encoding.rb
         | 
| 166 168 | 
             
            - test/tc_error.rb
         | 
| 167 169 | 
             
            - test/tc_gc.rb
         | 
| 168 170 | 
             
            - test/tc_html_parser.rb
         | 
| @@ -241,6 +243,7 @@ test_files: | |
| 241 243 | 
             
            - test/tc_document.rb
         | 
| 242 244 | 
             
            - test/tc_document_write.rb
         | 
| 243 245 | 
             
            - test/tc_dtd.rb
         | 
| 246 | 
            +
            - test/tc_encoding.rb
         | 
| 244 247 | 
             
            - test/tc_error.rb
         | 
| 245 248 | 
             
            - test/tc_gc.rb
         | 
| 246 249 | 
             
            - test/tc_html_parser.rb
         |