adamh-hpricot 0.6.171 → 0.6.210
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/ext/fast_xs/fast_xs.c +11 -5
- data/ext/hpricot_scan/hpricot_css.c +2109 -2105
- data/ext/hpricot_scan/hpricot_scan.c +188 -139
- data/ext/hpricot_scan/hpricot_scan.rl +65 -14
- data/lib/hpricot/builder.rb +17 -10
- data/lib/hpricot/elements.rb +10 -10
- data/lib/hpricot/htmlinfo.rb +19 -0
- data/lib/hpricot/parse.rb +3 -1
- data/lib/hpricot/tag.rb +13 -1
- data/test/files/boingboing.html +1 -1
- data/test/test_builder.rb +4 -4
- data/test/test_parser.rb +18 -9
- data/test/test_preserved.rb +6 -2
- metadata +2 -2
data/Rakefile
CHANGED
@@ -108,7 +108,7 @@ end
|
|
108
108
|
|
109
109
|
file ext_so => ext_files do
|
110
110
|
Dir.chdir(ext) do
|
111
|
-
sh(RUBY_PLATFORM =~ /
|
111
|
+
sh(RUBY_PLATFORM =~ /mswin/ ? 'nmake' : 'make')
|
112
112
|
end
|
113
113
|
cp ext_so, "lib"
|
114
114
|
end
|
@@ -147,7 +147,8 @@ desc "Generates the C scanner code with Ragel."
|
|
147
147
|
task :ragel => [:ragel_version] do
|
148
148
|
if @ragel_v >= 6.1
|
149
149
|
@ragel_c_code_generation_style = RAGEL_C_CODE_GENERATION_STYLES[DEFAULT_RAGEL_C_CODE_GENERATION]
|
150
|
-
|
150
|
+
console_sep = (ENV['COMSPEC'] =~ /cmd\.exe/) ? '&' : ';'
|
151
|
+
sh %{cd ext/hpricot_scan #{console_sep} ragel hpricot_scan.rl -#{@ragel_c_code_generation_style} -o hpricot_scan.c && ragel hpricot_css.rl -#{@ragel_c_code_generation_style} -o hpricot_css.c}
|
151
152
|
else
|
152
153
|
STDERR.puts "Ragel 6.1 or greater is required."
|
153
154
|
exit(1)
|
data/ext/fast_xs/fast_xs.c
CHANGED
@@ -4,6 +4,12 @@
|
|
4
4
|
#include <assert.h>
|
5
5
|
/* #include <stdio.h> */
|
6
6
|
|
7
|
+
#ifndef RARRAY_LEN
|
8
|
+
#define RARRAY_LEN(arr) RARRAY(arr)->len
|
9
|
+
#define RSTRING_LEN(str) RSTRING(str)->len
|
10
|
+
#define RSTRING_PTR(str) RSTRING(str)->ptr
|
11
|
+
#endif
|
12
|
+
|
7
13
|
static ID unpack_id;
|
8
14
|
static VALUE U_fmt, C_fmt;
|
9
15
|
|
@@ -109,7 +115,7 @@ static long escape(char *buf, int n)
|
|
109
115
|
|
110
116
|
if (VALID_VALUE(n)) {
|
111
117
|
/* return snprintf(buf, sizeof(""), "&#%i;", n); */
|
112
|
-
|
118
|
+
RUBY_EXTERN const char ruby_digitmap[];
|
113
119
|
int rv = 3; /* &#; */
|
114
120
|
buf += bytes_for(n);
|
115
121
|
*--buf = ';';
|
@@ -166,14 +172,14 @@ VALUE fast_xs(VALUE self)
|
|
166
172
|
|
167
173
|
array = RARRAY(rb_rescue(unpack_utf8, self, unpack_uchar, self));
|
168
174
|
|
169
|
-
tmp = array
|
170
|
-
for (i = array
|
175
|
+
tmp = RARRAY_PTR(array);
|
176
|
+
for (i = RARRAY_LEN(array); --i >= 0; tmp++)
|
171
177
|
s_len += escaped_len(NUM2INT(*tmp));
|
172
178
|
|
173
179
|
c = s = alloca(s_len + 1);
|
174
180
|
|
175
|
-
tmp = array
|
176
|
-
for (i = array
|
181
|
+
tmp = RARRAY_PTR(array);
|
182
|
+
for (i = RARRAY_LEN(array); --i >= 0; tmp++)
|
177
183
|
c += escape(c, NUM2INT(*tmp));
|
178
184
|
|
179
185
|
*c = '\0';
|