Changeset 244
- Timestamp:
- 02/25/2008 16:37:27 (9 months ago)
- Location:
- branches/superredcloth
- Files:
-
- 5 modified
-
Rakefile (modified) (1 diff)
-
ext/superredcloth_scan/superredcloth.h (modified) (5 diffs)
-
ext/superredcloth_scan/superredcloth_common.rl (modified) (1 diff)
-
ext/superredcloth_scan/superredcloth_inline.rl (modified) (3 diffs)
-
ext/superredcloth_scan/superredcloth_scan.rl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/superredcloth/Rakefile
r228 r244 119 119 source = name.sub(/\.c$/, '.rl') 120 120 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 123 128 end 124 129 end -
branches/superredcloth/ext/superredcloth_scan/superredcloth.h
r243 r244 8 8 9 9 /* function defs */ 10 void rb_str_cat_escaped(VALUE str, char *t okstart, char *tokend);11 void rb_str_cat_escaped_for_preformatted(VALUE str, char *t okstart, char *tokend);10 void rb_str_cat_escaped(VALUE str, char *ts, char *te); 11 void rb_str_cat_escaped_for_preformatted(VALUE str, char *ts, char *te); 12 12 VALUE superredcloth_inline(VALUE, char *, char *); 13 13 VALUE superredcloth_inline2(VALUE, VALUE); … … 21 21 22 22 /* parser macros */ 23 #define CAT(H) rb_str_cat(H, t okstart, tokend-tokstart)23 #define CAT(H) rb_str_cat(H, ts, te-ts) 24 24 #define CLEAR(H) H = rb_str_new2("") 25 25 #define INLINE(H, T) rb_str_append(H, rb_funcall(rb_formatter, rb_intern(#T), 1, regs)) … … 39 39 #define AINC(T) red_inc(regs, ID2SYM(rb_intern(#T))); 40 40 #define STORE(T) \ 41 if (p > reg && reg >= t okstart) { \41 if (p > reg && reg >= ts) { \ 42 42 while (reg < p && ( *reg == '\r' || *reg == '\n' ) ) { reg++; } \ 43 43 while (p > reg && ( *(p - 1) == '\r' || *(p - 1) == '\n' ) ) { p--; } \ 44 44 } \ 45 if (p > reg && reg >= t okstart) { \45 if (p > reg && reg >= ts) { \ 46 46 VALUE str = rb_str_new(reg, p-reg); \ 47 47 rb_hash_aset(regs, ID2SYM(rb_intern(#T)), str); \ … … 51 51 } 52 52 #define STORE_URL(T) \ 53 if (p > reg && reg >= t okstart) { \53 if (p > reg && reg >= ts) { \ 54 54 p++; \ 55 55 char punct = 1; \ … … 63 63 } \ 64 64 } \ 65 t okend= p; \65 te = p; \ 66 66 } \ 67 67 STORE(T); \ -
branches/superredcloth/ext/superredcloth_scan/superredcloth_common.rl
r230 r244 7 7 action X { regs = rb_hash_new(); reg = NULL; } 8 8 action cat { CAT(block); } 9 action esc { rb_str_cat_escaped(block, t okstart, tokend); }10 action esc_pre { rb_str_cat_escaped_for_preformatted(block, t okstart, tokend); }9 action esc { rb_str_cat_escaped(block, ts, te); } 10 action esc_pre { rb_str_cat_escaped_for_preformatted(block, ts, te); } 11 11 action ignore { rb_str_append(block, rb_funcall(rb_formatter, rb_intern("ignore"), 1, regs)); } 12 12 -
branches/superredcloth/ext/superredcloth_scan/superredcloth_inline.rl
r243 r244 218 218 { 219 219 int cs, act; 220 char *t okstart, *tokend, *reg;220 char *ts, *te, *reg, *eof; 221 221 VALUE block = rb_str_new2(""); 222 222 VALUE regs = Qnil; … … 230 230 231 231 void 232 rb_str_cat_escaped(str, t okstart, tokend)232 rb_str_cat_escaped(str, ts, te) 233 233 VALUE str; 234 char *t okstart, *tokend;235 { 236 char *t = t okstart, *t2 = tokstart, *ch = NULL;237 if (t okend <= tokstart) return;238 239 while (t2 < t okend) {234 char *ts, *te; 235 { 236 char *t = ts, *t2 = ts, *ch = NULL; 237 if (te <= ts) return; 238 239 while (t2 < te) { 240 240 ch = NULL; 241 241 switch (*t2) … … 264 264 265 265 void 266 rb_str_cat_escaped_for_preformatted(str, t okstart, tokend)266 rb_str_cat_escaped_for_preformatted(str, ts, te) 267 267 VALUE str; 268 char *t okstart, *tokend;269 { 270 char *t = t okstart, *t2 = tokstart, *ch = NULL;271 if (t okend <= tokstart) return;272 273 while (t2 < t okend) {268 char *ts, *te; 269 { 270 char *t = ts, *t2 = ts, *ch = NULL; 271 if (te <= ts) return; 272 273 while (t2 < te) { 274 274 ch = NULL; 275 275 switch (*t2) -
branches/superredcloth/ext/superredcloth_scan/superredcloth_scan.rl
r241 r244 160 160 { 161 161 int cs, act, nest; 162 char *t okstart = NULL, *tokend = NULL, *reg= NULL;162 char *ts = NULL, *te = NULL, *reg = NULL, *eof = NULL; 163 163 VALUE html = rb_str_new2(""); 164 164 VALUE table = rb_str_new2("");