From: Benjamin Mako Hill Date: Mon, 2 May 2011 17:59:02 +0000 (-0400) Subject: fix bug and invoke regex search in first revision X-Git-Url: https://projects.mako.cc/source/wikiq/commitdiff_plain/4a2a815f4bd260376ac2f758d796fc4fbe549924?hp=23bc9bfafc9312bd4f8bb72f22e38c087ef0b0fa fix bug and invoke regex search in first revision Regex search was only being called in diffs. Of course, if something is added in the very first revision, it will never show up in a diff. This was resulting in deletions that don't show up as additions. I've patched the code so that the first revision is treated as one big addition. --- diff --git a/wikiq.cpp b/wikiq.cpp index 57d97fa..ee10644 100644 --- a/wikiq.cpp +++ b/wikiq.cpp @@ -254,7 +254,9 @@ write_row(revisionData *data) vector regex_matches_adds; vector regex_matches_dels; - if (!data->last_text_tokens.empty()) { + if (data->last_text_tokens.empty()) { + additions = data->text; + } else { // do the diff dtl::Diff< string, vector > d(data->last_text_tokens, text_tokens); @@ -274,25 +276,22 @@ write_row(revisionData *data) break; } } - - if (!additions.empty()) { - //cout << "ADD: " << additions << endl; - for (vector::iterator r = data->regexes.begin(); r != data->regexes.end(); ++r) { - pcrecpp::RE& regex = *r; - regex_matches_adds.push_back(regex.PartialMatch(additions)); - } + } + + if (!additions.empty()) { + //cout << "ADD: " << additions << endl; + for (vector::iterator r = data->regexes.begin(); r != data->regexes.end(); ++r) { + pcrecpp::RE& regex = *r; + regex_matches_adds.push_back(regex.PartialMatch(additions)); } + } - if (!deletions.empty()) { - //cout << "DEL: " << deletions << endl; - for (vector::iterator r = data->regexes.begin(); r != data->regexes.end(); ++r) { - pcrecpp::RE& regex = *r; - regex_matches_dels.push_back(regex.PartialMatch(deletions)); - } + if (!deletions.empty()) { + //cout << "DEL: " << deletions << endl; + for (vector::iterator r = data->regexes.begin(); r != data->regexes.end(); ++r) { + pcrecpp::RE& regex = *r; + regex_matches_dels.push_back(regex.PartialMatch(deletions)); } - - // apply regex to the diff - } data->last_text_tokens = text_tokens;