nokolexbor 0.2.5 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/ext/nokolexbor/CMakeLists.txt +7 -4
  3. data/ext/nokolexbor/config.h.cmake.in +2 -0
  4. data/ext/nokolexbor/extconf.rb +47 -25
  5. data/ext/nokolexbor/libxml/SAX2.h +4 -4
  6. data/ext/nokolexbor/libxml/chvalid.h +21 -21
  7. data/ext/nokolexbor/libxml/dict.h +13 -13
  8. data/ext/nokolexbor/libxml/globals.h +202 -202
  9. data/ext/nokolexbor/libxml/hash.h +25 -25
  10. data/ext/nokolexbor/libxml/parser.h +5 -5
  11. data/ext/nokolexbor/libxml/parserInternals.h +4 -4
  12. data/ext/nokolexbor/libxml/pattern.h +14 -14
  13. data/ext/nokolexbor/libxml/threads.h +15 -15
  14. data/ext/nokolexbor/libxml/tree.h +5 -5
  15. data/ext/nokolexbor/libxml/xmlerror.h +5 -5
  16. data/ext/nokolexbor/libxml/xmlmemory.h +16 -16
  17. data/ext/nokolexbor/libxml/xmlstring.h +30 -30
  18. data/ext/nokolexbor/libxml/xpath.h +43 -43
  19. data/ext/nokolexbor/libxml/xpathInternals.h +128 -128
  20. data/ext/nokolexbor/memory.c +6 -6
  21. data/ext/nokolexbor/nl_cdata.c +44 -0
  22. data/ext/nokolexbor/nl_comment.c +44 -0
  23. data/ext/nokolexbor/nl_document.c +23 -9
  24. data/ext/nokolexbor/nl_node.c +191 -178
  25. data/ext/nokolexbor/nl_node_set.c +38 -73
  26. data/ext/nokolexbor/nl_text.c +44 -0
  27. data/ext/nokolexbor/nl_xpath_context.c +33 -42
  28. data/ext/nokolexbor/nokolexbor.c +7 -3
  29. data/ext/nokolexbor/nokolexbor.h +9 -7
  30. data/ext/nokolexbor/private/buf.h +1 -1
  31. data/ext/nokolexbor/private/error.h +3 -3
  32. data/ext/nokolexbor/xml_SAX2.c +8 -8
  33. data/ext/nokolexbor/xml_buf.c +19 -19
  34. data/ext/nokolexbor/xml_chvalid.c +25 -25
  35. data/ext/nokolexbor/xml_dict.c +69 -69
  36. data/ext/nokolexbor/xml_encoding.c +2 -2
  37. data/ext/nokolexbor/xml_error.c +51 -51
  38. data/ext/nokolexbor/xml_globals.c +329 -329
  39. data/ext/nokolexbor/xml_hash.c +131 -131
  40. data/ext/nokolexbor/xml_memory.c +25 -25
  41. data/ext/nokolexbor/xml_parser.c +3 -3
  42. data/ext/nokolexbor/xml_parserInternals.c +15 -15
  43. data/ext/nokolexbor/xml_pattern.c +103 -103
  44. data/ext/nokolexbor/xml_string.c +93 -93
  45. data/ext/nokolexbor/xml_threads.c +61 -61
  46. data/ext/nokolexbor/xml_tree.c +12 -12
  47. data/ext/nokolexbor/xml_xpath.c +1194 -1203
  48. data/lib/nokolexbor/document.rb +92 -1
  49. data/lib/nokolexbor/node.rb +64 -0
  50. data/lib/nokolexbor/node_set.rb +6 -5
  51. data/lib/nokolexbor/version.rb +1 -1
  52. data/lib/nokolexbor.rb +21 -1
  53. data/patches/0001-lexbor-support-text-pseudo-element.patch +1 -1
  54. metadata +7 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4f935c5e81aed7b5d964e7332a9abeaa1f44dec7e2532f01c89dfd17df14ded
4
- data.tar.gz: 91c58aca5a9b16a3cfa7e2436dfb86feeb777daa3615b8b3a95b234981cc67d0
3
+ metadata.gz: 6bfa3062e8718581cd8aabef75f0084a6626bd90301c9db4957ee975215edec1
4
+ data.tar.gz: 243f5c217c85750f63bfc0dcb8af575c019d3f2fd920f41769c0affc8a219802
5
5
  SHA512:
6
- metadata.gz: af6ae7b07bde270ea275a5b21221c7e90923f195a6a62ed7b85174f1d9f31f017661dc50c7d8dd1c3d39096a5c1ecbb3469f4496f2e628a3b7026f82ca3994c5
7
- data.tar.gz: eea3a38dcbd81cdb7c54996248d6eaa2d2c51b964d79d3131ba04594dd449a141b32b225bc7a879844c92418f3c04e6b63c77c9c6bef86f8ee619fa6a47b03a3
6
+ metadata.gz: e66b390ef696ed5cafa480065e8ac8fc66ce98d86a7cb15f2f59d8acb7df21381942e5fe6f0244e3b9c7bf54787131c5241a49faeaba328eb49e65af0ac3216c
7
+ data.tar.gz: d266e2a7c49a202aec4112667807158b54878cc014b42fc32492fc0977c06db76b1a5ded827d9810f2e7966ba3e5068fe54ab89915a4c56e499181ddc190b6d7
@@ -1,8 +1,11 @@
1
- cmake_minimum_required(VERSION 3.0)
1
+ cmake_minimum_required(VERSION 2.8.12)
2
2
 
3
- set(VERSION "2.11.0")
4
-
5
- project(libxml2 VERSION ${VERSION} LANGUAGES C)
3
+ IF(CMAKE_VERSION VERSION_LESS "3.0")
4
+ project(libxml2)
5
+ ELSE()
6
+ cmake_policy(SET CMP0048 NEW)
7
+ project(libxml2 VERSION "2.11.0")
8
+ ENDIF()
6
9
 
7
10
  include(CheckFunctionExists)
8
11
  include(CheckIncludeFiles)
@@ -11,7 +11,9 @@
11
11
  #cmakedefine HAVE_PTHREAD_H 1
12
12
 
13
13
  /* Define to 1 if you have the `rand_r' function. */
14
+ #ifndef _WIN32
14
15
  #cmakedefine HAVE_RAND_R 1
16
+ #endif
15
17
 
16
18
  /* Define to 1 if you have the <stdint.h> header file. */
17
19
  #cmakedefine HAVE_STDINT_H 1
@@ -1,21 +1,60 @@
1
1
  require 'mkmf'
2
2
  require 'timeout'
3
3
 
4
+ if ENV["CC"]
5
+ RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
6
+ end
7
+
8
+ # From: https://stackoverflow.com/questions/2108727
9
+ # Cross-platform way of finding an executable in the $PATH.
10
+ #
11
+ # which('ruby') #=> /usr/bin/ruby
12
+ def which(cmd)
13
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
14
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
15
+ exts.each { |ext|
16
+ exe = File.join(path, "#{cmd}#{ext}")
17
+ return exe if File.executable? exe
18
+ }
19
+ end
20
+ return nil
21
+ end
22
+
4
23
  cmake_flags = [ ENV["CMAKE_FLAGS"] ]
5
- cmake_flags << "-DLEXBOR_BUILD_TESTS_CPP=OFF"
6
- cmake_flags << "-DLEXBOR_BUILD_SHARED=OFF"
7
- cmake_flags << "-DLEXBOR_BUILD_STATIC=ON"
24
+ cmake_flags << "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
25
+ # Set system name explicitly when cross-compiling
26
+ cmake_flags << "-DCMAKE_SYSTEM_NAME=Windows -DWIN32=1" if Gem.win_platform?
27
+ # On Windows, Ruby-DevKit is MSYS-based, so ensure to use MSYS Makefiles.
28
+ cmake_flags << "-G \"MSYS Makefiles\"" if Gem.win_platform? && !ENV['NOKOLEXBOR_CROSS_COMPILE']
29
+
30
+ if ENV['NOKOLEXBOR_CROSS_COMPILE']
31
+ # use the same toolchain for cross-compiling lexbor
32
+ ['CC', 'CXX'].each do |env|
33
+ if RbConfig::CONFIG[env]
34
+ ENV[env] = RbConfig::CONFIG[env]
35
+ end
36
+ end
37
+ {'RANLIB' => 'RANLIB', 'AR' => 'AR', 'LD' => 'LINKER'}.each do |env, cmake_opt|
38
+ if RbConfig::CONFIG[env]
39
+ cmake_flags << "-DCMAKE_#{cmake_opt}=#{which(RbConfig::CONFIG[env])}"
40
+ end
41
+ end
42
+ end
43
+
44
+ lexbor_cmake_flags = cmake_flags + ["-DLEXBOR_BUILD_TESTS_CPP=OFF"]
45
+ lexbor_cmake_flags << "-DLEXBOR_BUILD_SHARED=OFF"
46
+ lexbor_cmake_flags << "-DLEXBOR_BUILD_STATIC=ON"
8
47
 
9
48
  if ENV['NOKOLEXBOR_DEBUG'] || ENV['NOKOLEXBOR_ASAN']
10
49
  CONFIG["optflags"] = "-O0"
11
50
  CONFIG["debugflags"] = "-ggdb3"
12
- cmake_flags << "-DLEXBOR_OPTIMIZATION_LEVEL='-O0 -g'"
51
+ lexbor_cmake_flags << "-DLEXBOR_OPTIMIZATION_LEVEL='-O0 -g'"
13
52
  end
14
53
 
15
54
  if ENV['NOKOLEXBOR_ASAN']
16
55
  $LDFLAGS << " -fsanitize=address"
17
56
  $CFLAGS << " -fsanitize=address -DNOKOLEXBOR_ASAN"
18
- cmake_flags << "-DLEXBOR_BUILD_WITH_ASAN=ON"
57
+ lexbor_cmake_flags << "-DLEXBOR_BUILD_WITH_ASAN=ON"
19
58
  end
20
59
 
21
60
  append_cflags("-DLEXBOR_STATIC")
@@ -35,7 +74,7 @@ end
35
74
 
36
75
  def self.run_cmake(timeout, args)
37
76
  # Set to process group so we can kill it and its children
38
- pgroup = Gem.win_platform? ? :new_pgroup : :pgroup
77
+ pgroup = (Gem.win_platform? && !ENV['NOKOLEXBOR_CROSS_COMPILE']) ? :new_pgroup : :pgroup
39
78
  pid = Process.spawn("cmake #{args}", pgroup => true)
40
79
 
41
80
  Timeout.timeout(timeout) do
@@ -50,21 +89,6 @@ rescue Timeout::Error
50
89
  raise CMakeTimeout.new("cmake has exceeded its timeout of #{timeout}s")
51
90
  end
52
91
 
53
- # From: https://stackoverflow.com/questions/2108727
54
- # Cross-platform way of finding an executable in the $PATH.
55
- #
56
- # which('ruby') #=> /usr/bin/ruby
57
- def which(cmd)
58
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
59
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
60
- exts.each { |ext|
61
- exe = File.join(path, "#{cmd}#{ext}")
62
- return exe if File.executable? exe
63
- }
64
- end
65
- return nil
66
- end
67
-
68
92
  # From: https://github.com/flavorjones/mini_portile/blob/main/lib/mini_portile2/mini_portile.rb#L94
69
93
  def apply_patch(patch_file, chdir)
70
94
  case
@@ -109,9 +133,7 @@ Dir.chdir(LEXBOR_DIR) do
109
133
  Dir.mkdir("build") if !Dir.exist?("build")
110
134
 
111
135
  Dir.chdir("build") do
112
- # On Windows, Ruby-DevKit is MSYS-based, so ensure to use MSYS Makefiles.
113
- generator = "-G \"MSYS Makefiles\"" if Gem.win_platform?
114
- run_cmake(10 * 60, ".. -DCMAKE_INSTALL_PREFIX:PATH=#{INSTALL_DIR} #{cmake_flags.join(' ')} #{generator}")
136
+ run_cmake(10 * 60, ".. -DCMAKE_INSTALL_PREFIX:PATH=#{INSTALL_DIR} #{lexbor_cmake_flags.join(' ')}")
115
137
  sys("#{MAKE} install")
116
138
  end
117
139
  end
@@ -121,7 +143,7 @@ Dir.chdir(EXT_DIR) do
121
143
  Dir.mkdir("build") if !Dir.exist?("build")
122
144
 
123
145
  Dir.chdir("build") do
124
- run_cmake(10 * 60, "..#{Gem.win_platform? ? " -DLIBXML2_WITH_THREADS=OFF" : ""}")
146
+ run_cmake(10 * 60, ".. #{cmake_flags.join(' ')} #{Gem.win_platform? ? "-DLIBXML2_WITH_THREADS=OFF" : ""}")
125
147
  end
126
148
  end
127
149
 
@@ -21,17 +21,17 @@
21
21
  extern "C" {
22
22
  #endif
23
23
  XMLPUBFUN const xmlChar * XMLCALL
24
- xmlSAX2GetPublicId (void *ctx);
24
+ nl_xmlSAX2GetPublicId (void *ctx);
25
25
  XMLPUBFUN const xmlChar * XMLCALL
26
- xmlSAX2GetSystemId (void *ctx);
26
+ nl_xmlSAX2GetSystemId (void *ctx);
27
27
  XMLPUBFUN void XMLCALL
28
28
  xmlSAX2SetDocumentLocator (void *ctx,
29
29
  xmlSAXLocatorPtr loc);
30
30
 
31
31
  XMLPUBFUN int XMLCALL
32
- xmlSAX2GetLineNumber (void *ctx);
32
+ nl_xmlSAX2GetLineNumber (void *ctx);
33
33
  XMLPUBFUN int XMLCALL
34
- xmlSAX2GetColumnNumber (void *ctx);
34
+ nl_xmlSAX2GetColumnNumber (void *ctx);
35
35
 
36
36
  XMLPUBFUN int XMLCALL
37
37
  xmlSAX2IsStandalone (void *ctx);
@@ -52,7 +52,7 @@ struct _xmlChRangeGroup {
52
52
  * Range checking routine
53
53
  */
54
54
  XMLPUBFUN int XMLCALL
55
- xmlCharInRange(unsigned int val, const xmlChRangeGroup *group);
55
+ nl_xmlCharInRange(unsigned int val, const xmlChRangeGroup *group);
56
56
 
57
57
 
58
58
  /**
@@ -75,9 +75,9 @@ XMLPUBFUN int XMLCALL
75
75
  */
76
76
  #define xmlIsBaseCharQ(c) (((c) < 0x100) ? \
77
77
  xmlIsBaseChar_ch((c)) : \
78
- xmlCharInRange((c), &xmlIsBaseCharGroup))
78
+ nl_xmlCharInRange((c), &nl_xmlIsBaseCharGroup))
79
79
 
80
- XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup;
80
+ XMLPUBVAR const xmlChRangeGroup nl_xmlIsBaseCharGroup;
81
81
 
82
82
  /**
83
83
  * xmlIsBlank_ch:
@@ -121,7 +121,7 @@ XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup;
121
121
  ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \
122
122
  ((0x10000 <= (c)) && ((c) <= 0x10ffff))))
123
123
 
124
- XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup;
124
+ XMLPUBVAR const xmlChRangeGroup nl_xmlIsCharGroup;
125
125
 
126
126
  /**
127
127
  * xmlIsCombiningQ:
@@ -131,9 +131,9 @@ XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup;
131
131
  */
132
132
  #define xmlIsCombiningQ(c) (((c) < 0x100) ? \
133
133
  0 : \
134
- xmlCharInRange((c), &xmlIsCombiningGroup))
134
+ nl_xmlCharInRange((c), &nl_xmlIsCombiningGroup))
135
135
 
136
- XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup;
136
+ XMLPUBVAR const xmlChRangeGroup nl_xmlIsCombiningGroup;
137
137
 
138
138
  /**
139
139
  * xmlIsDigit_ch:
@@ -151,9 +151,9 @@ XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup;
151
151
  */
152
152
  #define xmlIsDigitQ(c) (((c) < 0x100) ? \
153
153
  xmlIsDigit_ch((c)) : \
154
- xmlCharInRange((c), &xmlIsDigitGroup))
154
+ nl_xmlCharInRange((c), &nl_xmlIsDigitGroup))
155
155
 
156
- XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup;
156
+ XMLPUBVAR const xmlChRangeGroup nl_xmlIsDigitGroup;
157
157
 
158
158
  /**
159
159
  * xmlIsExtender_ch:
@@ -171,9 +171,9 @@ XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup;
171
171
  */
172
172
  #define xmlIsExtenderQ(c) (((c) < 0x100) ? \
173
173
  xmlIsExtender_ch((c)) : \
174
- xmlCharInRange((c), &xmlIsExtenderGroup))
174
+ nl_xmlCharInRange((c), &nl_xmlIsExtenderGroup))
175
175
 
176
- XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup;
176
+ XMLPUBVAR const xmlChRangeGroup nl_xmlIsExtenderGroup;
177
177
 
178
178
  /**
179
179
  * xmlIsIdeographicQ:
@@ -187,8 +187,8 @@ XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup;
187
187
  ((c) == 0x3007) || \
188
188
  ((0x3021 <= (c)) && ((c) <= 0x3029))))
189
189
 
190
- XMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup;
191
- XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];
190
+ XMLPUBVAR const xmlChRangeGroup nl_xmlIsIdeographicGroup;
191
+ XMLPUBVAR const unsigned char nl_xmlIsPubidChar_tab[256];
192
192
 
193
193
  /**
194
194
  * xmlIsPubidChar_ch:
@@ -196,7 +196,7 @@ XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];
196
196
  *
197
197
  * Automatically generated by genChRanges.py
198
198
  */
199
- #define xmlIsPubidChar_ch(c) (xmlIsPubidChar_tab[(c)])
199
+ #define xmlIsPubidChar_ch(c) (nl_xmlIsPubidChar_tab[(c)])
200
200
 
201
201
  /**
202
202
  * xmlIsPubidCharQ:
@@ -208,21 +208,21 @@ XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];
208
208
  xmlIsPubidChar_ch((c)) : 0)
209
209
 
210
210
  XMLPUBFUN int XMLCALL
211
- xmlIsBaseChar(unsigned int ch);
211
+ nl_xmlIsBaseChar(unsigned int ch);
212
212
  XMLPUBFUN int XMLCALL
213
- xmlIsBlank(unsigned int ch);
213
+ nl_xmlIsBlank(unsigned int ch);
214
214
  XMLPUBFUN int XMLCALL
215
- xmlIsChar(unsigned int ch);
215
+ nl_xmlIsChar(unsigned int ch);
216
216
  XMLPUBFUN int XMLCALL
217
- xmlIsCombining(unsigned int ch);
217
+ nl_xmlIsCombining(unsigned int ch);
218
218
  XMLPUBFUN int XMLCALL
219
- xmlIsDigit(unsigned int ch);
219
+ nl_xmlIsDigit(unsigned int ch);
220
220
  XMLPUBFUN int XMLCALL
221
- xmlIsExtender(unsigned int ch);
221
+ nl_xmlIsExtender(unsigned int ch);
222
222
  XMLPUBFUN int XMLCALL
223
- xmlIsIdeographic(unsigned int ch);
223
+ nl_xmlIsIdeographic(unsigned int ch);
224
224
  XMLPUBFUN int XMLCALL
225
- xmlIsPubidChar(unsigned int ch);
225
+ nl_xmlIsPubidChar(unsigned int ch);
226
226
 
227
227
  #ifdef __cplusplus
228
228
  }
@@ -28,52 +28,52 @@ typedef xmlDict *xmlDictPtr;
28
28
  * Initializer
29
29
  */
30
30
  XML_DEPRECATED
31
- XMLPUBFUN int XMLCALL xmlInitializeDict(void);
31
+ XMLPUBFUN int XMLCALL nl_xmlInitializeDict(void);
32
32
 
33
33
  /*
34
34
  * Constructor and destructor.
35
35
  */
36
36
  XMLPUBFUN xmlDictPtr XMLCALL
37
- xmlDictCreate (void);
37
+ nl_xmlDictCreate (void);
38
38
  XMLPUBFUN size_t XMLCALL
39
- xmlDictSetLimit (xmlDictPtr dict,
39
+ nl_xmlDictSetLimit (xmlDictPtr dict,
40
40
  size_t limit);
41
41
  XMLPUBFUN size_t XMLCALL
42
- xmlDictGetUsage (xmlDictPtr dict);
42
+ nl_xmlDictGetUsage (xmlDictPtr dict);
43
43
  XMLPUBFUN xmlDictPtr XMLCALL
44
- xmlDictCreateSub(xmlDictPtr sub);
44
+ nl_xmlDictCreateSub(xmlDictPtr sub);
45
45
  XMLPUBFUN int XMLCALL
46
- xmlDictReference(xmlDictPtr dict);
46
+ nl_xmlDictReference(xmlDictPtr dict);
47
47
  XMLPUBFUN void XMLCALL
48
- xmlDictFree (xmlDictPtr dict);
48
+ nl_xmlDictFree (xmlDictPtr dict);
49
49
 
50
50
  /*
51
51
  * Lookup of entry in the dictionary.
52
52
  */
53
53
  XMLPUBFUN const xmlChar * XMLCALL
54
- xmlDictLookup (xmlDictPtr dict,
54
+ nl_xmlDictLookup (xmlDictPtr dict,
55
55
  const xmlChar *name,
56
56
  int len);
57
57
  XMLPUBFUN const xmlChar * XMLCALL
58
- xmlDictExists (xmlDictPtr dict,
58
+ nl_xmlDictExists (xmlDictPtr dict,
59
59
  const xmlChar *name,
60
60
  int len);
61
61
  XMLPUBFUN const xmlChar * XMLCALL
62
- xmlDictQLookup (xmlDictPtr dict,
62
+ nl_xmlDictQLookup (xmlDictPtr dict,
63
63
  const xmlChar *prefix,
64
64
  const xmlChar *name);
65
65
  XMLPUBFUN int XMLCALL
66
- xmlDictOwns (xmlDictPtr dict,
66
+ nl_xmlDictOwns (xmlDictPtr dict,
67
67
  const xmlChar *str);
68
68
  XMLPUBFUN int XMLCALL
69
- xmlDictSize (xmlDictPtr dict);
69
+ nl_xmlDictSize (xmlDictPtr dict);
70
70
 
71
71
  /*
72
72
  * Cleanup function
73
73
  */
74
74
  XML_DEPRECATED
75
75
  XMLPUBFUN void XMLCALL
76
- xmlDictCleanup (void);
76
+ nl_xmlDictCleanup (void);
77
77
 
78
78
  #ifdef __cplusplus
79
79
  }