Bugfix: escaped % in format did not work

This commit is contained in:
zimoch
2011-02-24 16:12:43 +00:00
parent 2dc0918926
commit 7f1f1c1e65

View File

@ -1073,7 +1073,7 @@ compileString(StreamBuffer& buffer, const char*& source,
// 1) read a line from protocol source and code quoted strings, // 1) read a line from protocol source and code quoted strings,
// numerical bytes, tokens, etc, and replace variables and parameters // numerical bytes, tokens, etc, and replace variables and parameters
// 2) replace the formats in the line // 2) replace the formats in the line
// thus variables can be replaces inside the format info string // thus variables can be replaced inside the format info string
while (1) while (1)
{ {
@ -1088,11 +1088,15 @@ compileString(StreamBuffer& buffer, const char*& source,
if (formatType != NoFormat) if (formatType != NoFormat)
{ {
int nformats=0; int nformats=0;
debug("StreamProtocolParser::Protocol::compileString " char c;
"looking for formats at pos %d in \"%s\"\n", formatpos, buffer.expand(formatpos)()); while ((c = buffer[formatpos]) != '\0')
while ((formatpos = buffer.find('%', formatpos)) != -1)
{ {
if (buffer[formatpos-1] == esc) continue; if (c == esc) {
// ignore escaped %
formatpos+=2;
continue;
}
if (c == '%') {
debug("StreamProtocolParser::Protocol::compileString " debug("StreamProtocolParser::Protocol::compileString "
"format=\"%s\"\n", buffer.expand(formatpos)()); "format=\"%s\"\n", buffer.expand(formatpos)());
nformats++; nformats++;
@ -1113,8 +1117,10 @@ compileString(StreamBuffer& buffer, const char*& source,
debug("StreamProtocolParser::Protocol::compileString " debug("StreamProtocolParser::Protocol::compileString "
"replaced by: \"%s\"\n", buffer.expand(formatpos)()); "replaced by: \"%s\"\n", buffer.expand(formatpos)());
formatpos += formatbuffer.length(); formatpos += formatbuffer.length();
continue;
}
formatpos ++;
} }
formatpos = buffer.length();
debug("StreamProtocolParser::Protocol::compileString " debug("StreamProtocolParser::Protocol::compileString "
"%d formats found in line %d\n", nformats, line); "%d formats found in line %d\n", nformats, line);
} }