Skip to content

Commit

Permalink
fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sheimi committed Oct 22, 2012
1 parent 8d63e82 commit fa4c438
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions include/file_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ struct RegexEntry {
string handler;

friend inline istream& operator>>(istream& is, RegexEntry& t) {
is >> t.regex;
char buffer[256];
is.getline(buffer, 256);
string buffer_tmp(buffer);
t.regex = buffer_tmp;
is.getline(buffer, 256);
while (string(buffer).substr(0, 4) != "====") {
t.handler.append(buffer);
is.getline(buffer, 256);
Expand All @@ -28,12 +30,14 @@ struct RegexEntry {
}

friend inline ostream& operator<<(ostream& os, const RegexEntry& t) {
os << "/*" << endl;
os << "====" << endl;
os << "regex: " << t.regex << endl;
os << "regex: \'" << t.regex << "'"<< endl;
os << "priority: " << t.priority << endl;
os << "hander: " << endl;
os << t.handler << endl;
os << "====" << endl;
os << "*/" << endl;
return os;
}
};
Expand Down
1 change: 1 addition & 0 deletions include/mylex.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <boost/foreach.hpp>

#endif
2 changes: 2 additions & 0 deletions src/dfa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ void DFA::_c_state_change(ostream& os, DFAState* state) {
}
cout << " default:" << endl;
if (state->is_end) {
cout << " fseek(shm_file, -1, SEEK_CUR);" << endl;
cout << " buffer_index--;buffer[buffer_index] = '\\0';" << endl;
_c_state_end(os, state->end_id);
_c_state_reset(os);
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/file_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ void RegexEntry::to_c(ostream& os) {

FileParser::FileParser(string& filename) {
ifstream ifs(filename.c_str());
char buffer[32];
ifs.getline(buffer, 32);
stringstream ss(buffer);
int N;
ifs >> N;
ss >> N;
for (int i = 0; i < N; i++) {
RegexEntry re;
ifs >> re;
Expand Down

0 comments on commit fa4c438

Please sign in to comment.