Fix dangerous parser use

Jean-Marc discovered a possible data loss caused by Parser::getChar().
This is now fixed, and Parser::getChar() is removed, since it is no longer
needed and easy to use it in the wrong way.
This commit is contained in:
Georg Baum 2013-02-16 14:16:42 +01:00
parent 7ac59e7b99
commit 5f3cd55f1d
3 changed files with 3 additions and 16 deletions

View File

@ -413,14 +413,6 @@ bool Parser::good()
}
char Parser::getChar()
{
if (!good())
error("The input stream is not well...");
return get_token().character();
}
bool Parser::hasOpt()
{
// An optional argument can occur in any of the following forms:

View File

@ -282,11 +282,6 @@ public:
std::string verbatim_item();
///
std::string verbatimOption();
/*!
* Returns the character of the current token and increments
* the token position.
*/
char getChar();
///
void error(std::string const & msg);
/// The previous token.

View File

@ -2105,10 +2105,10 @@ void parse_macro(Parser & p, ostream & os, Context & context)
// followed by number?
if (p.next_token().cat() == catOther) {
char c = p.getChar();
paramtext += c;
string s = p.get_token().asInput();
paramtext += s;
// number = current arity + 1?
if (c == arity + '0' + 1)
if (s.size() == 1 && s[0] == arity + '0' + 1)
++arity;
else
simple = false;