# HG changeset patch # User John W. Eaton # Date 1262592019 18000 # Node ID 5813ec5077b568b705a536907d219ac0e44b76e5 # Parent 4e6b245d4eb78a5715e90873291cffd3e4ad535f don't allow e, i, j, inf, or nan to be commands diff -r 4e6b245d4eb7 -r 5813ec5077b5 src/ChangeLog --- a/src/ChangeLog Mon Jan 04 02:11:07 2010 -0500 +++ b/src/ChangeLog Mon Jan 04 03:00:19 2010 -0500 @@ -1,3 +1,8 @@ +2010-01-04 John W. Eaton + + * lex.ll (can_be_command): New function. + (handle_identifier): Use it. + 2010-01-04 Marco Atzeri * Makefile.am (install-oct): Write $(DESTDIR)$(...), not diff -r 4e6b245d4eb7 -r 5813ec5077b5 src/lex.ll --- a/src/lex.ll Mon Jan 04 02:11:07 2010 -0500 +++ b/src/lex.ll Mon Jan 04 03:00:19 2010 -0500 @@ -2833,6 +2833,19 @@ } static bool +can_be_command (const std::string& tok) +{ + // Don't allow these names to be treated as commands to avoid + // surprises when parsing things like "NaN ^2". + + return ! (tok == "e" + || tok == "I" || tok == "i" + || tok == "J" || tok == "j" + || tok == "Inf" || tok == "inf" + || tok == "NaN" || tok == "nan"); +} + +static bool looks_like_command_arg (void) { bool retval = true; @@ -3251,7 +3264,8 @@ if (! is_variable (tok)) { - if (at_bos && spc_gobbled && looks_like_command_arg ()) + if (at_bos && spc_gobbled && can_be_command (tok) + && looks_like_command_arg ()) { BEGIN (COMMAND_START); }