Changeset 244

Show
Ignore:
Timestamp:
02/25/2008 16:37:27 (9 months ago)
Author:
jgarber
Message:

Make SRC work with Ragel >= 6.0. Due to Ragel interface changes, it is not backward-compatible with earlier versions of Ragel.

Location:
branches/superredcloth
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/superredcloth/Rakefile

    r228 r244  
    119119  source = name.sub(/\.c$/, '.rl') 
    120120  file name => [source, "#{ext}/superredcloth_common.rl", "#{ext}/superredcloth.h"] do 
    121     @ragel_v ||= `ragel -v`[/(version )(\S*)/,2].to_f 
    122     sh %{ragel #{source} | #{@ragel_v >= 5.18 ? 'rlgen-cd' : 'rlcodegen'} -G2 -o #{name}} 
     121    @ragel_v ||= `ragel -v`[/(version )(\S*)/,2].split('.').map{|s| s.to_i} 
     122    if @ragel_v[0] >= 6 
     123      sh %{ragel #{source} -G2 -o #{name}} 
     124    else 
     125      STDERR.puts "Ragel 6.0 or greater is required to generate #{name}." 
     126      exit(1) 
     127    end 
    123128  end 
    124129end 
  • branches/superredcloth/ext/superredcloth_scan/superredcloth.h

    r243 r244  
    88 
    99/* function defs */ 
    10 void rb_str_cat_escaped(VALUE str, char *tokstart, char *tokend); 
    11 void rb_str_cat_escaped_for_preformatted(VALUE str, char *tokstart, char *tokend); 
     10void rb_str_cat_escaped(VALUE str, char *ts, char *te); 
     11void rb_str_cat_escaped_for_preformatted(VALUE str, char *ts, char *te); 
    1212VALUE superredcloth_inline(VALUE, char *, char *); 
    1313VALUE superredcloth_inline2(VALUE, VALUE); 
     
    2121 
    2222/* parser macros */ 
    23 #define CAT(H)         rb_str_cat(H, tokstart, tokend-tokstart) 
     23#define CAT(H)         rb_str_cat(H, ts, te-ts) 
    2424#define CLEAR(H)       H = rb_str_new2("") 
    2525#define INLINE(H, T)   rb_str_append(H, rb_funcall(rb_formatter, rb_intern(#T), 1, regs)) 
     
    3939#define AINC(T)        red_inc(regs, ID2SYM(rb_intern(#T))); 
    4040#define STORE(T)  \ 
    41   if (p > reg && reg >= tokstart) { \ 
     41  if (p > reg && reg >= ts) { \ 
    4242    while (reg < p && ( *reg == '\r' || *reg == '\n' ) ) { reg++; } \ 
    4343    while (p > reg && ( *(p - 1) == '\r' || *(p - 1) == '\n' ) ) { p--; } \ 
    4444  } \ 
    45   if (p > reg && reg >= tokstart) { \ 
     45  if (p > reg && reg >= ts) { \ 
    4646    VALUE str = rb_str_new(reg, p-reg); \ 
    4747    rb_hash_aset(regs, ID2SYM(rb_intern(#T)), str); \ 
     
    5151  } 
    5252#define STORE_URL(T) \ 
    53   if (p > reg && reg >= tokstart) { \ 
     53  if (p > reg && reg >= ts) { \ 
    5454    p++; \ 
    5555    char punct = 1; \ 
     
    6363      } \ 
    6464    } \ 
    65     tokend = p; \ 
     65    te = p; \ 
    6666  } \ 
    6767  STORE(T); \ 
  • branches/superredcloth/ext/superredcloth_scan/superredcloth_common.rl

    r230 r244  
    77  action X { regs = rb_hash_new(); reg = NULL; } 
    88  action cat { CAT(block); } 
    9   action esc { rb_str_cat_escaped(block, tokstart, tokend); } 
    10   action esc_pre { rb_str_cat_escaped_for_preformatted(block, tokstart, tokend); } 
     9  action esc { rb_str_cat_escaped(block, ts, te); } 
     10  action esc_pre { rb_str_cat_escaped_for_preformatted(block, ts, te); } 
    1111  action ignore { rb_str_append(block, rb_funcall(rb_formatter, rb_intern("ignore"), 1, regs)); } 
    1212 
  • branches/superredcloth/ext/superredcloth_scan/superredcloth_inline.rl

    r243 r244  
    218218{ 
    219219  int cs, act; 
    220   char *tokstart, *tokend, *reg; 
     220  char *ts, *te, *reg, *eof; 
    221221  VALUE block = rb_str_new2(""); 
    222222  VALUE regs = Qnil; 
     
    230230 
    231231void 
    232 rb_str_cat_escaped(str, tokstart, tokend) 
     232rb_str_cat_escaped(str, ts, te) 
    233233  VALUE str; 
    234   char *tokstart, *tokend; 
    235 { 
    236   char *t = tokstart, *t2 = tokstart, *ch = NULL; 
    237   if (tokend <= tokstart) return; 
    238  
    239   while (t2 < tokend) { 
     234  char *ts, *te; 
     235{ 
     236  char *t = ts, *t2 = ts, *ch = NULL; 
     237  if (te <= ts) return; 
     238 
     239  while (t2 < te) { 
    240240    ch = NULL; 
    241241    switch (*t2) 
     
    264264 
    265265void 
    266 rb_str_cat_escaped_for_preformatted(str, tokstart, tokend) 
     266rb_str_cat_escaped_for_preformatted(str, ts, te) 
    267267  VALUE str; 
    268   char *tokstart, *tokend; 
    269 { 
    270   char *t = tokstart, *t2 = tokstart, *ch = NULL; 
    271   if (tokend <= tokstart) return; 
    272  
    273   while (t2 < tokend) { 
     268  char *ts, *te; 
     269{ 
     270  char *t = ts, *t2 = ts, *ch = NULL; 
     271  if (te <= ts) return; 
     272 
     273  while (t2 < te) { 
    274274    ch = NULL; 
    275275    switch (*t2) 
  • branches/superredcloth/ext/superredcloth_scan/superredcloth_scan.rl

    r241 r244  
    160160{ 
    161161  int cs, act, nest; 
    162   char *tokstart = NULL, *tokend = NULL, *reg = NULL; 
     162  char *ts = NULL, *te = NULL, *reg = NULL, *eof = NULL; 
    163163  VALUE html = rb_str_new2(""); 
    164164  VALUE table = rb_str_new2("");