Ashim Kapoor: deal with backspace better (#694)
This commit is contained in:
parent
ededbfb10e
commit
12b29e35ad
|
@ -833,9 +833,6 @@ int CheckBufferOverrun::count(const std::string &input_string)
|
|||
case '%':
|
||||
if (flag == 1) flag = 0;
|
||||
break;
|
||||
case '/':
|
||||
input_string_size--;
|
||||
break;
|
||||
}
|
||||
|
||||
if (flag) input_string_size++;
|
||||
|
@ -857,6 +854,21 @@ int CheckBufferOverrun::count(const std::string &input_string)
|
|||
|
||||
}
|
||||
|
||||
// A second iteration through the string to deal with /'s
|
||||
|
||||
std::string::size_type j = 0;
|
||||
|
||||
while (j < input_string.size())
|
||||
{
|
||||
if (input_string[j] == '\\')
|
||||
{
|
||||
input_string_size--;
|
||||
j += 2;
|
||||
continue;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
|
||||
return input_string_size + 1 + digits;
|
||||
}
|
||||
|
|
|
@ -896,7 +896,7 @@ private:
|
|||
ASSERT_EQUALS(3, CheckBufferOverrun::count("%2.2d"));
|
||||
ASSERT_EQUALS(1, CheckBufferOverrun::count("%s"));
|
||||
ASSERT_EQUALS(6, CheckBufferOverrun::count("%-5s"));
|
||||
TODO_ASSERT_EQUALS(2, CheckBufferOverrun::count("\\\""));
|
||||
ASSERT_EQUALS(2, CheckBufferOverrun::count("\\\""));
|
||||
}
|
||||
|
||||
void strncpy1()
|
||||
|
|
Loading…
Reference in New Issue