From: Mikko Rasa Date: Wed, 8 Jun 2011 06:41:03 +0000 (+0300) Subject: Use unsigned char as element of Regex::Code X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=00e36d6bf092b98dfa413578d9af58d61cedbc13;p=libs%2Fcore.git Use unsigned char as element of Regex::Code --- diff --git a/source/strings/regex.cpp b/source/strings/regex.cpp index 03bf7dd..bfd25c7 100644 --- a/source/strings/regex.cpp +++ b/source/strings/regex.cpp @@ -22,7 +22,7 @@ T read_int(Msp::Regex::Code::const_iterator &c) { T result = 0; for(unsigned i=0; i(*c++)<(mask), 32); + result.append(mask, 32); } iter = end; @@ -360,7 +360,7 @@ bool Regex::run(const string &str, const string::const_iterator &begin, RegMatch { int c; if(i!=str.end()) - c = static_cast(*i); + c = *i; else c = -1; @@ -506,7 +506,7 @@ string Regex::disassemble() const string decompiled = disassemble_instruction(i); string bytes; for(; j!=i; ++j) - bytes += format(" %02X", static_cast(*j)&0xFF); + bytes += format(" %02X", *j); result += format("%3d:%-9s ", offset, bytes); if(bytes.size()>9) result += "\n "; @@ -545,24 +545,24 @@ string Regex::disassemble_instruction(Code::const_iterator &i) const return "MATCH_END"; case MATCH_CHAR: { - char c = *i++; + unsigned char c = *i++; if(c>=0x20 && c<=0x7E) return format("MATCH_CHAR '%c'", c); else - return format("MATCH_CHAR %d", static_cast(c)&0xFF); + return format("MATCH_CHAR %d", c); } break; case MATCH_RANGE: { int begin = *i++; int end = *i++; - return format("MATCH_RANGE %d-%d", begin&0xFF, end&0xFF); + return format("MATCH_RANGE %d-%d", begin, end); } case MATCH_MASK: { string result = "MATCH_MASK"; for(unsigned j=0; j<32; ++j) - result += format(" %02X", static_cast(*i++)&0xFF); + result += format(" %02X", *i++); return result; } case MATCH_ANY: diff --git a/source/strings/regex.h b/source/strings/regex.h index 8226c44..5b809ab 100644 --- a/source/strings/regex.h +++ b/source/strings/regex.h @@ -61,7 +61,7 @@ The MATCH_ANY instruction consumes the input character and always succeeds. class Regex { private: - typedef std::string Code; + typedef std::basic_string Code; typedef unsigned short Count; typedef short Offset; typedef unsigned short Index;