Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "ruby.h"


      #define MATCH(A,B) ((equal[A] & equal[B]) != 0)
    


      int equal[256] = {
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 1,14, 4,11, 0, 0, 8, 7, 0, 0,10, 0, 5,15, 0,
          0, 0, 9,12, 2, 2,13, 3, 0, 6, 0, 0, 0, 0, 0, 0,
          0, 1,14, 4,11, 0, 0, 8, 7, 0, 0,10, 0, 5,15, 0,
          0, 0, 9,12, 2, 2,13, 3, 0, 6, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
      };
    

# line 39 "./backtrack_inline.rb"
static VALUE backtrack(VALUE self, VALUE _ss, VALUE _s, VALUE _p, VALUE _mm, VALUE _ins, VALUE _del) {
  char * ss = StringValuePtr(_ss);
  char * s = StringValuePtr(_s);
  char * p = StringValuePtr(_p);
  int mm = FIX2INT(_mm);
  int ins = FIX2INT(_ins);
  int del = FIX2INT(_del);

          int r = 0;

          while (*s && MATCH(*s, *p)) ++s, ++p;

          if (!*p)
              return INT2FIX((s - ss) - 1);
          else
          {
              if (mm && *s && *p && (r = backtrack(ss, s + 1, p + 1, mm - 1, ins, del))) return INT2FIX(r);
              if (ins && *s &&      (r = backtrack(ss, s + 1, p, mm, ins - 1, del)))     return INT2FIX(r);
              if (del && *p &&      (r = backtrack(ss, s, p + 1, mm, ins, del - 1)))     return INT2FIX(r);
          }

          return INT2FIX(0);
      }
    

# line 61 "./backtrack_inline.rb"
static VALUE patscan(VALUE self, VALUE _p, VALUE _mm, VALUE _ins, VALUE _del) {
  char * p = StringValuePtr(_p);
  int mm = FIX2INT(_mm);
  int ins = FIX2INT(_ins);
  int del = FIX2INT(_del);

          char* s = StringValuePtr(rb_iv_get(self, "@seq"));
          char* ss;
          int   end;

          for (ss = s; *s; ++s)
          {
              end = backtrack(ss, s, p, mm, ins, del);

              if (end)
                 return INT2FIX(end);
          }
       }
    


#ifdef __cplusplus
extern "C" {
#endif
  void Init_Inline_Scan_ec30() {
    VALUE c = rb_cObject;
    c = rb_const_get(c, rb_intern("Scan"));

    rb_define_method(c, "backtrack", (VALUE(*)(ANYARGS))backtrack, 6);
    rb_define_method(c, "patscan", (VALUE(*)(ANYARGS))patscan, 4);

  }
#ifdef __cplusplus
}
#endif