Changeset 162
- Timestamp:
- 04/08/2008 00:11:36 (4 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
Rakefile (modified) (1 diff)
-
ext/hpricot_scan/hpricot_scan.rl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Rakefile
r159 r162 121 121 desc "Generates the C scanner code with Ragel." 122 122 task :ragel => [:ragel_version] do 123 sh %{ragel ext/hpricot_scan/hpricot_scan.rl | #{@ragel_v >= 5.18 ? 'rlgen-cd' : 'rlcodegen'} -G2 -o ext/hpricot_scan/hpricot_scan.c} 123 if @ragel_v >= 6.1 124 sh %{ragel ext/hpricot_scan/hpricot_scan.rl -G2 -o ext/hpricot_scan/hpricot_scan.c} 125 else 126 STDERR.puts "Ragel 6.1 or greater is required." 127 exit(1) 128 end 124 129 end 125 130 126 131 desc "Generates the Java scanner code with Ragel." 127 132 task :ragel_java => [:ragel_version] do 128 sh %{ragel -J ext/hpricot_scan/hpricot_scan.java.rl | #{@ragel_v >= 5.18 ? 'rlgen-java' : 'rlcodegen'} -o ext/hpricot_scan/HpricotScanService.java} 133 if @ragel_v >= 6.1 134 sh %{ragel -J ext/hpricot_scan/hpricot_scan.java.rl -G2 -o ext/hpricot_scan/HpricotScanService.java} 135 else 136 STDERR.puts "Ragel 6.1 or greater is required." 137 exit(1) 138 end 129 139 end 130 140 -
trunk/ext/hpricot_scan/hpricot_scan.rl
r158 r162 23 23 24 24 #define ELE(N) \ 25 if (t okend > tokstart|| text == 1) { \25 if (te > ts || text == 1) { \ 26 26 VALUE raw_string = Qnil; \ 27 27 ele_open = 0; text = 0; \ 28 if (t okstart!= 0 && sym_##N != sym_cdata && sym_##N != sym_text && sym_##N != sym_procins && sym_##N != sym_comment) { \29 raw_string = rb_str_new(t okstart, tokend-tokstart); \28 if (ts != 0 && sym_##N != sym_cdata && sym_##N != sym_text && sym_##N != sym_procins && sym_##N != sym_comment) { \ 29 raw_string = rb_str_new(ts, te-ts); \ 30 30 } \ 31 31 rb_yield_tokens(sym_##N, tag, attr, raw_string, taint); \ … … 40 40 #define CAT(N, E) if (NIL_P(N)) { SET(N, E); } else { rb_str_cat(N, mark_##N, E - mark_##N); } 41 41 42 #define SLIDE(N) if ( mark_##N > t okstart ) mark_##N = buf + (mark_##N - tokstart);42 #define SLIDE(N) if ( mark_##N > ts ) mark_##N = buf + (mark_##N - ts); 43 43 44 44 #define ATTR(K, V) \ … … 53 53 if (ele_open == 1) { \ 54 54 ele_open = 0; \ 55 if (t okstart> 0) { \56 mark_tag = t okstart; \55 if (ts > 0) { \ 56 mark_tag = ts; \ 57 57 } \ 58 58 } else { \ … … 136 136 { 137 137 int cs, act, have = 0, nread = 0, curline = 1, text = 0; 138 char *t okstart = 0, *tokend = 0, *buf = NULL;138 char *ts = 0, *te = 0, *buf = NULL, *eof = NULL; 139 139 140 140 VALUE attr = Qnil, tag = Qnil, akey = Qnil, aval = Qnil, bufsize = Qnil; … … 217 217 { 218 218 ele_open = 0; 219 if (t okstart> 0) {220 mark_tag = t okstart;221 t okstart= 0;219 if (ts > 0) { 220 mark_tag = ts; 221 ts = 0; 222 222 text = 1; 223 223 } 224 224 } 225 225 226 if ( t okstart== 0 )226 if ( ts == 0 ) 227 227 { 228 228 have = 0; 229 /* text nodes have no t okstartbecause each byte is parsed alone */229 /* text nodes have no ts because each byte is parsed alone */ 230 230 if ( mark_tag != NULL && text == 1 ) 231 231 { … … 247 247 else 248 248 { 249 have = pe - t okstart;250 memmove( buf, t okstart, have );249 have = pe - ts; 250 memmove( buf, ts, have ); 251 251 SLIDE(tag); 252 252 SLIDE(akey); 253 253 SLIDE(aval); 254 t okend = buf + (tokend - tokstart);255 t okstart= buf;254 te = buf + (te - ts); 255 ts = buf; 256 256 } 257 257 }
