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 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 =~ /win32/ ? 'nmake' : 'make')
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
- sh %{cd ext/hpricot_scan; 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}
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)
@@ -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("&#1114111;"), "&#%i;", n); */
112
- extern const char ruby_digitmap[];
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->ptr;
170
- for (i = array->len; --i >= 0; tmp++)
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->ptr;
176
- for (i = array->len; --i >= 0; tmp++)
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';