Mercurial > hg > octave-max
changeset 10052:5813ec5077b5
don't allow e, i, j, inf, or nan to be commands
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 04 Jan 2010 03:00:19 -0500 |
parents | 4e6b245d4eb7 |
children | 830986c43dee |
files | src/ChangeLog src/lex.ll |
diffstat | 2 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-01-04 John W. Eaton <jwe@octave.org> + + * lex.ll (can_be_command): New function. + (handle_identifier): Use it. + 2010-01-04 Marco Atzeri <marco_atzeri@yahoo.it> * Makefile.am (install-oct): Write $(DESTDIR)$(...), not
--- a/src/lex.ll +++ b/src/lex.ll @@ -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); }