--- regexp.d.orig 2003-12-07 14:02:00.000000000 +0000 +++ regexp.d 2003-12-07 14:04:22.000000000 +0000 @@ -75,8 +75,6 @@ uint re_nsub; // number of parenthesized subexpression matches regmatch_t[] pmatch; // array [re_nsub + 1] - tchar[] input; // the string to search - // per instance: tchar[] pattern; // source text of the regular expression @@ -98,6 +96,7 @@ private: + tchar[] m_input; // the string to search uint src; // current source index in input[] uint src_start; // starting index for match in input[] uint p; // position of parser in pattern[] @@ -158,6 +157,33 @@ private uint inf = ~0u; /********************************* + * Getter for the input string + */ + +tchar[] input() +{ + return m_input; +}; + +/********************************* + * Setter for the input string + */ + +void input(tchar[] string) +{ + if (m_input != string) + { + m_input = string; + + for (int i = 0; i < pmatch.length; i++) + { + pmatch[i].rm_so = 0; + pmatch[i].rm_eo = 0; + } + } +} + +/********************************* * Throws RegExpError on error */ @@ -388,6 +414,17 @@ j = join(result, ","); i = std.string.cmp(j, "ab,ac"); assert(i == 0); + + r = new RegExp("a[bc]", null); + result = r.match("123ab"); + j = join(result, ","); + i = std.string.cmp(j, "ab"); + assert(i == 0); + + result = r.match("ac"); + j = join(result, ","); + i = std.string.cmp(j, "ac"); + assert(i == 0); } @@ -1214,6 +1251,7 @@ case REend: debug(regexp) printf("\tREend\n"); + void doNothing(){}; doNothing(); return 1; // successful match case REwordboundary: