nokogiri 1.4.1-java → 1.4.2-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (115) hide show
  1. data/CHANGELOG.ja.rdoc +45 -0
  2. data/CHANGELOG.rdoc +53 -1
  3. data/Manifest.txt +3 -3
  4. data/README.ja.rdoc +1 -1
  5. data/README.rdoc +11 -5
  6. data/Rakefile +13 -79
  7. data/ext/nokogiri/extconf.rb +22 -74
  8. data/ext/nokogiri/html_document.c +17 -8
  9. data/ext/nokogiri/html_element_description.c +20 -16
  10. data/ext/nokogiri/html_entity_lookup.c +2 -2
  11. data/ext/nokogiri/html_sax_parser_context.c +10 -8
  12. data/ext/nokogiri/libcharset-1.dll +0 -0
  13. data/ext/nokogiri/libexslt.dll +0 -0
  14. data/ext/nokogiri/libiconv-2.dll +0 -0
  15. data/ext/nokogiri/libxml2.dll +0 -0
  16. data/ext/nokogiri/libxslt.dll +0 -0
  17. data/ext/nokogiri/nokogiri.c +0 -1
  18. data/ext/nokogiri/nokogiri.h +33 -28
  19. data/ext/nokogiri/xml_attr.c +7 -5
  20. data/ext/nokogiri/xml_attribute_decl.c +5 -2
  21. data/ext/nokogiri/xml_cdata.c +4 -2
  22. data/ext/nokogiri/xml_comment.c +4 -2
  23. data/ext/nokogiri/xml_document.c +93 -15
  24. data/ext/nokogiri/xml_document.h +0 -1
  25. data/ext/nokogiri/xml_document_fragment.c +4 -2
  26. data/ext/nokogiri/xml_dtd.c +18 -8
  27. data/ext/nokogiri/xml_element_content.c +2 -2
  28. data/ext/nokogiri/xml_entity_decl.c +15 -2
  29. data/ext/nokogiri/xml_entity_reference.c +4 -2
  30. data/ext/nokogiri/xml_io.c +1 -1
  31. data/ext/nokogiri/xml_namespace.c +5 -3
  32. data/ext/nokogiri/xml_node.c +353 -114
  33. data/ext/nokogiri/xml_node_set.c +35 -22
  34. data/ext/nokogiri/xml_node_set.h +1 -1
  35. data/ext/nokogiri/xml_processing_instruction.c +4 -2
  36. data/ext/nokogiri/xml_reader.c +119 -47
  37. data/ext/nokogiri/xml_relax_ng.c +21 -12
  38. data/ext/nokogiri/xml_sax_parser.c +6 -3
  39. data/ext/nokogiri/xml_sax_parser.h +13 -17
  40. data/ext/nokogiri/xml_sax_parser_context.c +8 -6
  41. data/ext/nokogiri/xml_sax_push_parser.c +7 -6
  42. data/ext/nokogiri/xml_schema.c +62 -13
  43. data/ext/nokogiri/xml_syntax_error.c +18 -12
  44. data/ext/nokogiri/xml_syntax_error.h +1 -1
  45. data/ext/nokogiri/xml_text.c +4 -2
  46. data/ext/nokogiri/xml_xpath_context.c +60 -23
  47. data/ext/nokogiri/xslt_stylesheet.c +14 -3
  48. data/ext/nokogiri/zlib1.dll +0 -0
  49. data/lib/nokogiri.rb +17 -0
  50. data/lib/nokogiri/css/generated_parser.rb +72 -62
  51. data/lib/nokogiri/css/generated_tokenizer.rb +23 -24
  52. data/lib/nokogiri/css/parser.y +3 -1
  53. data/lib/nokogiri/css/tokenizer.rex +3 -3
  54. data/lib/nokogiri/css/xpath_visitor.rb +8 -3
  55. data/lib/nokogiri/ffi/html/sax/parser_context.rb +3 -3
  56. data/lib/nokogiri/ffi/libxml.rb +16 -2
  57. data/lib/nokogiri/ffi/structs/common_node.rb +15 -3
  58. data/lib/nokogiri/ffi/structs/xml_document.rb +13 -4
  59. data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +3 -2
  60. data/lib/nokogiri/ffi/weak_bucket.rb +40 -0
  61. data/lib/nokogiri/ffi/xml/document.rb +27 -0
  62. data/lib/nokogiri/ffi/xml/entity_decl.rb +9 -0
  63. data/lib/nokogiri/ffi/xml/node.rb +142 -61
  64. data/lib/nokogiri/ffi/xml/node_set.rb +15 -12
  65. data/lib/nokogiri/ffi/xml/reader.rb +5 -0
  66. data/lib/nokogiri/ffi/xml/schema.rb +17 -0
  67. data/lib/nokogiri/ffi/xml/syntax_error.rb +4 -4
  68. data/lib/nokogiri/ffi/xml/xpath.rb +0 -10
  69. data/lib/nokogiri/ffi/xml/xpath_context.rb +22 -9
  70. data/lib/nokogiri/ffi/xslt/stylesheet.rb +3 -0
  71. data/lib/nokogiri/html/document.rb +5 -3
  72. data/lib/nokogiri/html/document_fragment.rb +28 -7
  73. data/lib/nokogiri/nokogiri.rb +1 -0
  74. data/lib/nokogiri/version.rb +6 -2
  75. data/lib/nokogiri/version_warning.rb +6 -3
  76. data/lib/nokogiri/xml.rb +1 -1
  77. data/lib/nokogiri/xml/builder.rb +35 -22
  78. data/lib/nokogiri/xml/document.rb +44 -12
  79. data/lib/nokogiri/xml/document_fragment.rb +16 -12
  80. data/lib/nokogiri/xml/entity_decl.rb +4 -0
  81. data/lib/nokogiri/xml/node.rb +152 -95
  82. data/lib/nokogiri/xml/node_set.rb +2 -1
  83. data/lib/nokogiri/xml/sax/push_parser.rb +1 -1
  84. data/lib/nokogiri/xml/schema.rb +1 -5
  85. data/lib/nokogiri/xml/syntax_error.rb +4 -0
  86. data/lib/nokogiri/xml/text.rb +9 -0
  87. data/lib/nokogiri/xml/xpath/syntax_error.rb +3 -0
  88. data/tasks/cross_compile.rb +157 -0
  89. data/tasks/test.rb +0 -6
  90. data/test/css/test_xpath_visitor.rb +9 -0
  91. data/test/helper.rb +49 -11
  92. data/test/html/sax/test_parser.rb +11 -1
  93. data/test/html/test_document.rb +8 -0
  94. data/test/html/test_document_fragment.rb +14 -2
  95. data/test/html/test_element_description.rb +5 -1
  96. data/test/html/test_node.rb +5 -66
  97. data/test/test_reader.rb +28 -0
  98. data/test/test_xslt_transforms.rb +14 -0
  99. data/test/xml/test_builder.rb +43 -0
  100. data/test/xml/test_cdata.rb +12 -0
  101. data/test/xml/test_document.rb +74 -39
  102. data/test/xml/test_document_fragment.rb +36 -0
  103. data/test/xml/test_entity_decl.rb +37 -0
  104. data/test/xml/test_node.rb +192 -65
  105. data/test/xml/test_node_reparenting.rb +253 -236
  106. data/test/xml/test_node_set.rb +67 -0
  107. data/test/xml/test_text.rb +8 -0
  108. data/test/xml/test_xpath.rb +32 -0
  109. metadata +119 -48
  110. data.tar.gz.sig +0 -0
  111. data/ext/nokogiri/iconv.dll +0 -0
  112. data/ext/nokogiri/xml_xpath.c +0 -53
  113. data/ext/nokogiri/xml_xpath.h +0 -11
  114. data/lib/nokogiri/xml/fragment_handler.rb +0 -79
  115. metadata.gz.sig +0 -0
@@ -9,12 +9,13 @@
9
9
  static VALUE new(int argc, VALUE *argv, VALUE klass)
10
10
  {
11
11
  VALUE uri, external_id, rest, rb_doc;
12
+ htmlDocPtr doc;
12
13
 
13
14
  rb_scan_args(argc, argv, "0*", &rest);
14
15
  uri = rb_ary_entry(rest, (long)0);
15
16
  external_id = rb_ary_entry(rest, (long)1);
16
17
 
17
- htmlDocPtr doc = htmlNewDoc(
18
+ doc = htmlNewDoc(
18
19
  RTEST(uri) ? (const xmlChar *)StringValuePtr(uri) : NULL,
19
20
  RTEST(external_id) ? (const xmlChar *)StringValuePtr(external_id) : NULL
20
21
  );
@@ -39,11 +40,13 @@ static VALUE read_io( VALUE klass,
39
40
  const char * c_url = NIL_P(url) ? NULL : StringValuePtr(url);
40
41
  const char * c_enc = NIL_P(encoding) ? NULL : StringValuePtr(encoding);
41
42
  VALUE error_list = rb_ary_new();
43
+ VALUE document;
44
+ htmlDocPtr doc;
42
45
 
43
46
  xmlResetLastError();
44
47
  xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
45
48
 
46
- htmlDocPtr doc = htmlReadIO(
49
+ doc = htmlReadIO(
47
50
  io_read_callback,
48
51
  io_close_callback,
49
52
  (void *)io,
@@ -54,9 +57,11 @@ static VALUE read_io( VALUE klass,
54
57
  xmlSetStructuredErrorFunc(NULL, NULL);
55
58
 
56
59
  if(doc == NULL) {
60
+ xmlErrorPtr error;
61
+
57
62
  xmlFreeDoc(doc);
58
63
 
59
- xmlErrorPtr error = xmlGetLastError();
64
+ error = xmlGetLastError();
60
65
  if(error)
61
66
  rb_exc_raise(Nokogiri_wrap_xml_syntax_error((VALUE)NULL, error));
62
67
  else
@@ -65,7 +70,7 @@ static VALUE read_io( VALUE klass,
65
70
  return Qnil;
66
71
  }
67
72
 
68
- VALUE document = Nokogiri_wrap_xml_document(klass, doc);
73
+ document = Nokogiri_wrap_xml_document(klass, doc);
69
74
  rb_iv_set(document, "@errors", error_list);
70
75
  return document;
71
76
  }
@@ -86,19 +91,23 @@ static VALUE read_memory( VALUE klass,
86
91
  const char * c_buffer = StringValuePtr(string);
87
92
  const char * c_url = NIL_P(url) ? NULL : StringValuePtr(url);
88
93
  const char * c_enc = NIL_P(encoding) ? NULL : StringValuePtr(encoding);
89
- int len = RSTRING_LEN(string);
94
+ int len = (int)RSTRING_LEN(string);
90
95
  VALUE error_list = rb_ary_new();
96
+ VALUE document;
97
+ htmlDocPtr doc;
91
98
 
92
99
  xmlResetLastError();
93
100
  xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
94
101
 
95
- htmlDocPtr doc = htmlReadMemory(c_buffer, len, c_url, c_enc, (int)NUM2INT(options));
102
+ doc = htmlReadMemory(c_buffer, len, c_url, c_enc, (int)NUM2INT(options));
96
103
  xmlSetStructuredErrorFunc(NULL, NULL);
97
104
 
98
105
  if(doc == NULL) {
106
+ xmlErrorPtr error;
107
+
99
108
  xmlFreeDoc(doc);
100
109
 
101
- xmlErrorPtr error = xmlGetLastError();
110
+ error = xmlGetLastError();
102
111
  if(error)
103
112
  rb_exc_raise(Nokogiri_wrap_xml_syntax_error((VALUE)NULL, error));
104
113
  else
@@ -107,7 +116,7 @@ static VALUE read_memory( VALUE klass,
107
116
  return Qnil;
108
117
  }
109
118
 
110
- VALUE document = Nokogiri_wrap_xml_document(klass, doc);
119
+ document = Nokogiri_wrap_xml_document(klass, doc);
111
120
  rb_iv_set(document, "@errors", error_list);
112
121
  return document;
113
122
  }
@@ -9,16 +9,17 @@
9
9
  static VALUE required_attributes(VALUE self)
10
10
  {
11
11
  htmlElemDesc * description;
12
+ VALUE list;
13
+ int i;
14
+
12
15
  Data_Get_Struct(self, htmlElemDesc, description);
13
16
 
14
- VALUE list = rb_ary_new();
17
+ list = rb_ary_new();
15
18
 
16
19
  if(NULL == description->attrs_req) return list;
17
20
 
18
- int i = 0;
19
- while(description->attrs_req[i]) {
21
+ for(i = 0; description->attrs_depr[i]; i++) {
20
22
  rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_req[i]));
21
- i++;
22
23
  }
23
24
 
24
25
  return list;
@@ -33,16 +34,17 @@ static VALUE required_attributes(VALUE self)
33
34
  static VALUE deprecated_attributes(VALUE self)
34
35
  {
35
36
  htmlElemDesc * description;
37
+ VALUE list;
38
+ int i;
39
+
36
40
  Data_Get_Struct(self, htmlElemDesc, description);
37
41
 
38
- VALUE list = rb_ary_new();
42
+ list = rb_ary_new();
39
43
 
40
44
  if(NULL == description->attrs_depr) return list;
41
45
 
42
- int i = 0;
43
- while(description->attrs_depr[i]) {
46
+ for(i = 0; description->attrs_depr[i]; i++) {
44
47
  rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_depr[i]));
45
- i++;
46
48
  }
47
49
 
48
50
  return list;
@@ -57,16 +59,17 @@ static VALUE deprecated_attributes(VALUE self)
57
59
  static VALUE optional_attributes(VALUE self)
58
60
  {
59
61
  htmlElemDesc * description;
62
+ VALUE list;
63
+ int i;
64
+
60
65
  Data_Get_Struct(self, htmlElemDesc, description);
61
66
 
62
- VALUE list = rb_ary_new();
67
+ list = rb_ary_new();
63
68
 
64
69
  if(NULL == description->attrs_opt) return list;
65
70
 
66
- int i = 0;
67
- while(description->attrs_opt[i]) {
71
+ for(i = 0; description->attrs_opt[i]; i++) {
68
72
  rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_opt[i]));
69
- i++;
70
73
  }
71
74
 
72
75
  return list;
@@ -95,16 +98,17 @@ static VALUE default_sub_element(VALUE self)
95
98
  static VALUE sub_elements(VALUE self)
96
99
  {
97
100
  htmlElemDesc * description;
101
+ VALUE list;
102
+ int i;
103
+
98
104
  Data_Get_Struct(self, htmlElemDesc, description);
99
105
 
100
- VALUE list = rb_ary_new();
106
+ list = rb_ary_new();
101
107
 
102
108
  if(NULL == description->subelts) return list;
103
109
 
104
- int i = 0;
105
- while(description->subelts[i]) {
110
+ for(i = 0; description->subelts[i]; i++) {
106
111
  rb_ary_push(list, NOKOGIRI_STR_NEW2(description->subelts[i]));
107
- i++;
108
112
  }
109
113
 
110
114
  return list;
@@ -10,11 +10,11 @@ static VALUE get(VALUE self, VALUE key)
10
10
  {
11
11
  const htmlEntityDesc * desc =
12
12
  htmlEntityLookup((const xmlChar *)StringValuePtr(key));
13
+ VALUE klass, args[3];
13
14
 
14
15
  if(NULL == desc) return Qnil;
15
- VALUE klass = rb_const_get(mNokogiriHtml, rb_intern("EntityDescription"));
16
+ klass = rb_const_get(mNokogiriHtml, rb_intern("EntityDescription"));
16
17
 
17
- VALUE args[3];
18
18
  args[0] = INT2NUM((long)desc->value);
19
19
  args[1] = NOKOGIRI_STR_NEW2(desc->name);
20
20
  args[2] = NOKOGIRI_STR_NEW2(desc->desc);
@@ -15,19 +15,21 @@ static void deallocate(xmlParserCtxtPtr ctxt)
15
15
 
16
16
  static VALUE parse_memory(VALUE klass, VALUE data, VALUE encoding)
17
17
  {
18
+ htmlParserCtxtPtr ctxt;
19
+
18
20
  if(NIL_P(data)) rb_raise(rb_eArgError, "data cannot be nil");
19
21
  if(!(int)RSTRING_LEN(data))
20
22
  rb_raise(rb_eRuntimeError, "data cannot be empty");
21
23
 
22
- htmlParserCtxtPtr ctxt = htmlCreateMemoryParserCtxt(
24
+ ctxt = htmlCreateMemoryParserCtxt(
23
25
  StringValuePtr(data),
24
26
  (int)RSTRING_LEN(data)
25
27
  );
26
28
 
27
29
  if(RTEST(encoding)) {
28
- xmlCharEncoding enc = xmlParseCharEncoding(StringValuePtr(encoding));
29
- if(enc != XML_CHAR_ENCODING_ERROR) {
30
- xmlSwitchEncoding(ctxt, enc);
30
+ xmlCharEncodingHandlerPtr enc = xmlFindCharEncodingHandler(StringValuePtr(encoding));
31
+ if(enc != NULL) {
32
+ xmlSwitchToEncoding(ctxt, enc);
31
33
  if(ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
32
34
  rb_raise(rb_eRuntimeError, "Unsupported encoding %s",
33
35
  StringValuePtr(encoding));
@@ -49,16 +51,16 @@ static VALUE parse_file(VALUE klass, VALUE filename, VALUE encoding)
49
51
 
50
52
  static VALUE parse_with(VALUE self, VALUE sax_handler)
51
53
  {
54
+ htmlParserCtxtPtr ctxt;
55
+ htmlSAXHandlerPtr sax;
56
+
52
57
  if(!rb_obj_is_kind_of(sax_handler, cNokogiriXmlSaxParser))
53
58
  rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::SAX::Parser");
54
59
 
55
- htmlParserCtxtPtr ctxt;
56
60
  Data_Get_Struct(self, htmlParserCtxt, ctxt);
57
-
58
- htmlSAXHandlerPtr sax;
59
61
  Data_Get_Struct(sax_handler, htmlSAXHandler, sax);
60
62
 
61
- // Free the sax handler since we'll assign our own
63
+ /* Free the sax handler since we'll assign our own */
62
64
  if(ctxt->sax && ctxt->sax != (xmlSAXHandlerPtr)&xmlDefaultSAXHandler)
63
65
  xmlFree(ctxt->sax);
64
66
 
Binary file
Binary file
Binary file
@@ -73,7 +73,6 @@ void Init_nokogiri()
73
73
  init_xml_comment();
74
74
  init_xml_node_set();
75
75
  init_xml_xpath_context();
76
- init_xml_xpath();
77
76
  init_xml_sax_parser_context();
78
77
  init_xml_sax_parser();
79
78
  init_xml_sax_push_parser();
@@ -2,8 +2,22 @@
2
2
  #define NOKOGIRI_NATIVE
3
3
 
4
4
  #include <stdlib.h>
5
+ #include <string.h>
5
6
  #include <assert.h>
7
+ #include <stdarg.h>
8
+
9
+ #ifdef USE_INCLUDED_VASPRINTF
10
+ int vasprintf (char **strp, const char *fmt, va_list ap);
11
+ #else
12
+
13
+ #define _GNU_SOURCE
14
+ # include <stdio.h>
15
+ #undef _GNU_SOURCE
16
+
17
+ #endif
18
+
6
19
  #include <libxml/parser.h>
20
+ #include <libxml/entities.h>
7
21
  #include <libxml/parserInternals.h>
8
22
  #include <libxml/xpath.h>
9
23
  #include <libxml/xpathInternals.h>
@@ -15,16 +29,10 @@
15
29
  #include <libxml/relaxng.h>
16
30
  #include <ruby.h>
17
31
 
18
- #ifdef USE_INCLUDED_VASPRINTF
19
- int vasprintf (char **strp, const char *fmt, va_list ap);
32
+ #ifdef HAVE_RUBY_ENCODING_H
33
+ #include <ruby/st.h>
20
34
  #else
21
-
22
- #ifndef _GNU_SOURCE
23
- #define _GNU_SOURCE
24
- #endif
25
-
26
- # include <stdio.h>
27
-
35
+ #include <st.h>
28
36
  #endif
29
37
 
30
38
  int is_2_6_16(void) ;
@@ -39,33 +47,31 @@ int is_2_6_16(void) ;
39
47
  # endif
40
48
  #endif
41
49
 
50
+ #ifndef NORETURN
51
+ # if defined(__GNUC__)
52
+ # define NORETURN(name) __attribute__((noreturn)) name
53
+ # else
54
+ # define NORETURN(name) name
55
+ # endif
56
+ #endif
57
+
42
58
  #ifdef HAVE_RUBY_ENCODING_H
43
59
 
44
60
  #include <ruby/encoding.h>
45
61
 
46
62
  #define NOKOGIRI_STR_NEW2(str) \
47
- ({ \
48
- VALUE _string = rb_str_new2((const char *)str); \
49
- int _enc = rb_enc_find_index("UTF-8"); \
50
- rb_enc_associate_index(_string, _enc); \
51
- _string; \
52
- })
63
+ NOKOGIRI_STR_NEW(str, strlen((const char *)(str)))
53
64
 
54
65
  #define NOKOGIRI_STR_NEW(str, len) \
55
- ({ \
56
- VALUE _string = rb_str_new((const char *)str, (long)len); \
57
- int _enc = rb_enc_find_index("UTF-8"); \
58
- rb_enc_associate_index(_string, _enc); \
59
- _string; \
60
- })
66
+ rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
61
67
 
62
68
  #else
63
69
 
64
70
  #define NOKOGIRI_STR_NEW2(str) \
65
- rb_str_new2((const char *)str)
71
+ rb_str_new2((const char *)(str))
66
72
 
67
73
  #define NOKOGIRI_STR_NEW(str, len) \
68
- rb_str_new((const char *)str, (long)len)
74
+ rb_str_new((const char *)(str), (long)(len))
69
75
  #endif
70
76
 
71
77
  #define RBSTR_OR_QNIL(_str) \
@@ -84,7 +90,6 @@ int is_2_6_16(void) ;
84
90
  #include <xml_document_fragment.h>
85
91
  #include <xml_comment.h>
86
92
  #include <xml_node_set.h>
87
- #include <xml_xpath.h>
88
93
  #include <xml_dtd.h>
89
94
  #include <xml_attribute_decl.h>
90
95
  #include <xml_element_decl.h>
@@ -112,10 +117,10 @@ extern VALUE mNokogiriHtmlSax ;
112
117
  extern VALUE mNokogiriXslt ;
113
118
 
114
119
  #define NOKOGIRI_ROOT_NODE(_node) \
115
- ({ \
116
- nokogiriTuplePtr tuple = (nokogiriTuplePtr)(_node->doc->_private); \
117
- st_insert(tuple->unlinkedNodes, (st_data_t)_node, (st_data_t)_node); \
118
- })
120
+ st_insert(((nokogiriTuplePtr)(_node)->doc->_private)->unlinkedNodes, (st_data_t)(_node), (st_data_t)(_node))
121
+
122
+ #define NOKOGIRI_ROOT_NSDEF(_nsDef, _doc) \
123
+ st_insert(((nokogiriTuplePtr)(_doc)->_private)->unlinkedNodes, (st_data_t)(_nsDef), (st_data_t)(_nsDef))
119
124
 
120
125
  #ifdef DEBUG
121
126
 
@@ -19,21 +19,21 @@ static VALUE set_value(VALUE self, VALUE content)
19
19
  xmlChar *buffer;
20
20
  xmlNode *tmp;
21
21
 
22
- // Encode our content
22
+ /* Encode our content */
23
23
  buffer = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValuePtr(content));
24
24
 
25
25
  attr->children = xmlStringGetNodeList(attr->doc, buffer);
26
26
  attr->last = NULL;
27
27
  tmp = attr->children;
28
28
 
29
- // Loop through the children
29
+ /* Loop through the children */
30
30
  for(tmp = attr->children; tmp; tmp = tmp->next) {
31
31
  tmp->parent = (xmlNode *)attr;
32
32
  tmp->doc = attr->doc;
33
33
  if(tmp->next == NULL) attr->last = tmp;
34
34
  }
35
35
 
36
- // Free up memory
36
+ /* Free up memory */
37
37
  xmlFree(buffer);
38
38
  }
39
39
 
@@ -52,12 +52,14 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
52
52
  VALUE document;
53
53
  VALUE name;
54
54
  VALUE rest;
55
+ xmlAttrPtr node;
56
+ VALUE rb_node;
55
57
 
56
58
  rb_scan_args(argc, argv, "2*", &document, &name, &rest);
57
59
 
58
60
  Data_Get_Struct(document, xmlDoc, xml_doc);
59
61
 
60
- xmlAttrPtr node = xmlNewDocProp(
62
+ node = xmlNewDocProp(
61
63
  xml_doc,
62
64
  (const xmlChar *)StringValuePtr(name),
63
65
  NULL
@@ -65,7 +67,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
65
67
 
66
68
  NOKOGIRI_ROOT_NODE((xmlNodePtr)node);
67
69
 
68
- VALUE rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
70
+ rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
69
71
  rb_obj_call_init(rb_node, argc, argv);
70
72
 
71
73
  if(rb_block_given_p()) rb_yield(rb_node);
@@ -37,10 +37,13 @@ static VALUE default_value(VALUE self)
37
37
  static VALUE enumeration(VALUE self)
38
38
  {
39
39
  xmlAttributePtr node;
40
+ xmlEnumerationPtr enm;
41
+ VALUE list;
42
+
40
43
  Data_Get_Struct(self, xmlAttribute, node);
41
44
 
42
- VALUE list = rb_ary_new();
43
- xmlEnumerationPtr enm = node->tree;
45
+ list = rb_ary_new();
46
+ enm = node->tree;
44
47
 
45
48
  while(enm) {
46
49
  rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
@@ -9,15 +9,17 @@
9
9
  static VALUE new(int argc, VALUE *argv, VALUE klass)
10
10
  {
11
11
  xmlDocPtr xml_doc;
12
+ xmlNodePtr node;
12
13
  VALUE doc;
13
14
  VALUE content;
14
15
  VALUE rest;
16
+ VALUE rb_node;
15
17
 
16
18
  rb_scan_args(argc, argv, "2*", &doc, &content, &rest);
17
19
 
18
20
  Data_Get_Struct(doc, xmlDoc, xml_doc);
19
21
 
20
- xmlNodePtr node = xmlNewCDataBlock(
22
+ node = xmlNewCDataBlock(
21
23
  xml_doc->doc,
22
24
  NIL_P(content) ? NULL : (const xmlChar *)StringValuePtr(content),
23
25
  NIL_P(content) ? 0 : (int)RSTRING_LEN(content)
@@ -25,7 +27,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
25
27
 
26
28
  NOKOGIRI_ROOT_NODE(node);
27
29
 
28
- VALUE rb_node = Nokogiri_wrap_xml_node(klass, node);
30
+ rb_node = Nokogiri_wrap_xml_node(klass, node);
29
31
  rb_obj_call_init(rb_node, argc, argv);
30
32
 
31
33
  if(rb_block_given_p()) rb_yield(rb_node);