Changeset 162

Show
Ignore:
Timestamp:
04/08/2008 00:11:36 (4 months ago)
Author:
why
Message:
  • Rakefile: use Ragel 6.1 or greater from now on.
Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/Rakefile

    r159 r162  
    121121desc "Generates the C scanner code with Ragel." 
    122122task :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 
    124129end 
    125130 
    126131desc "Generates the Java scanner code with Ragel." 
    127132task :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 
    129139end 
    130140 
  • trunk/ext/hpricot_scan/hpricot_scan.rl

    r158 r162  
    2323 
    2424#define ELE(N) \ 
    25   if (tokend > tokstart || text == 1) { \ 
     25  if (te > ts || text == 1) { \ 
    2626    VALUE raw_string = Qnil; \ 
    2727    ele_open = 0; text = 0; \ 
    28     if (tokstart != 0 && sym_##N != sym_cdata && sym_##N != sym_text && sym_##N != sym_procins && sym_##N != sym_comment) { \ 
    29       raw_string = rb_str_new(tokstart, 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); \ 
    3030    } \ 
    3131    rb_yield_tokens(sym_##N, tag, attr, raw_string, taint); \ 
     
    4040#define CAT(N, E) if (NIL_P(N)) { SET(N, E); } else { rb_str_cat(N, mark_##N, E - mark_##N); } 
    4141 
    42 #define SLIDE(N) if ( mark_##N > tokstart ) mark_##N = buf + (mark_##N - tokstart); 
     42#define SLIDE(N) if ( mark_##N > ts ) mark_##N = buf + (mark_##N - ts); 
    4343 
    4444#define ATTR(K, V) \ 
     
    5353      if (ele_open == 1) { \ 
    5454        ele_open = 0; \ 
    55         if (tokstart > 0) { \ 
    56           mark_tag = tokstart; \ 
     55        if (ts > 0) { \ 
     56          mark_tag = ts; \ 
    5757        } \ 
    5858      } else { \ 
     
    136136{ 
    137137  int cs, act, have = 0, nread = 0, curline = 1, text = 0; 
    138   char *tokstart = 0, *tokend = 0, *buf = NULL; 
     138  char *ts = 0, *te = 0, *buf = NULL, *eof = NULL; 
    139139 
    140140  VALUE attr = Qnil, tag = Qnil, akey = Qnil, aval = Qnil, bufsize = Qnil; 
     
    217217    { 
    218218      ele_open = 0; 
    219       if (tokstart > 0) { 
    220         mark_tag = tokstart; 
    221         tokstart = 0; 
     219      if (ts > 0) { 
     220        mark_tag = ts; 
     221        ts = 0; 
    222222        text = 1; 
    223223      } 
    224224    } 
    225225 
    226     if ( tokstart == 0 ) 
     226    if ( ts == 0 ) 
    227227    { 
    228228      have = 0; 
    229       /* text nodes have no tokstart because each byte is parsed alone */ 
     229      /* text nodes have no ts because each byte is parsed alone */ 
    230230      if ( mark_tag != NULL && text == 1 ) 
    231231      { 
     
    247247    else 
    248248    { 
    249       have = pe - tokstart; 
    250       memmove( buf, tokstart, have ); 
     249      have = pe - ts; 
     250      memmove( buf, ts, have ); 
    251251      SLIDE(tag); 
    252252      SLIDE(akey); 
    253253      SLIDE(aval); 
    254       tokend = buf + (tokend - tokstart); 
    255       tokstart = buf; 
     254      te = buf + (te - ts); 
     255      ts = buf; 
    256256    } 
    257257  }