Skip to content
Snippets Groups Projects
Commit 49a13cbb authored by James K. Lowden's avatar James K. Lowden :anchor:
Browse files

bugfix for crash with REPLACE/COPY pair

parent 83a3fccb
No related branches found
No related tags found
No related merge requests found
...@@ -918,7 +918,8 @@ parse_copy_directive( filespan_t& mfile ) { ...@@ -918,7 +918,8 @@ parse_copy_directive( filespan_t& mfile ) {
const_cast<char*>(copy_stmt.pend)); const_cast<char*>(copy_stmt.pend));
} }
mfile.cur = const_cast<char*>(copy_stmt.pend); mfile.eol = const_cast<char*>(copy_stmt.pend);
mfile.next_line();
} }
return outcome; return outcome;
} }
...@@ -996,12 +997,16 @@ parse_replace_text( filespan_t& mfile, size_t current_lineno ) { ...@@ -996,12 +997,16 @@ parse_replace_text( filespan_t& mfile, size_t current_lineno ) {
} }
// Report findings. // Report findings.
for( size_t i=0; false && i < cm.size(); i++ ) { if( yy_flex_debug ) {
warnx("%zu: '%.*s'", warnx("%zu expressions", std::count(pattern, pattern + sizeof(pattern), '('));
i, int i = 0;
cm[i].matched? int(cm[i].length()) : 0, for( const auto& m : cm ) {
cm[i].matched? cm[i].first : ""); if( m.matched )
} warnx("%s:%d: %2d: '%.*s'", __func__, __LINE__,
i, int(m.length()), m.first);
i++;
}
}
assert(cm.size() > 7); assert(cm.size() > 7);
......
...@@ -183,14 +183,24 @@ using dts::regex_search; ...@@ -183,14 +183,24 @@ using dts::regex_search;
#endif #endif
struct span_t { struct span_t {
protected:
void verify() const {
if( !p ) {
warnx("span_t::span_t: p is NULL");
} else if( ! (p <= pend) ) {
warnx("span_t::span_t: p %p > pend %p", p, pend);
}
assert(p && p <= pend);
}
public:
const char *p, *pend; const char *p, *pend;
span_t() : p(NULL), pend(NULL) {} span_t() : p(NULL), pend(NULL) {}
span_t( size_t len, const char *data ) : p(data), pend(data + len) { span_t( size_t len, const char *data ) : p(data), pend(data + len) {
assert(p && p <= pend); verify();
} }
span_t( const char *data, const char *eodata ) : p(data), pend(eodata) { span_t( const char *data, const char *eodata ) : p(data), pend(eodata) {
assert(p && p <= pend); verify();
} }
span_t& operator=( const csub_match& cm ) { span_t& operator=( const csub_match& cm ) {
p = cm.first; p = cm.first;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment