From bug-octave-request at bevo dot che dot wisc dot edu Thu Nov 21 13:36:30 2002 Subject: 'clear' command and % comments at end of line -- behavior changes from 2.1.36 to 2.1.39 From: "John W. Eaton" To: Peter Van Wieren Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 21 Nov 2002 13:36:15 -0600 On 21-Nov-2002, Peter Van Wieren wrote: | In debugging a octave '.m' script, I have found that when using 'clear' | octave no longer ignores comments at the end of a line denoted by the | '%' character. Was this intended ?. As of version 2.1.36 octave | ignores the comment, in 2.1.39 it does not - thus the 'delete variables' | comment unexpectedly deletes all variables in memory. | | | For example, below I have run the following four lines in 2.1.36 , and | 2.1.39 | x = y = z = 1 ; | whos -v | clear x y % delete variables | whos -v Here is a patch. The only downside that I can see if that you will no longer be able to write help # or help % and commands like cd #foo or ls %file will no longer work. OTOH, you can always use forms like cd ("#foo") or ls "%file" if this is a problem. jwe src/ChangeLog: 2002-11-21 John W. Eaton * lex.l (): If yytext begins with # or %, don't recognize it as a string. Index: src/lex.l =================================================================== RCS file: /usr/local/cvsroot/octave/src/lex.l,v retrieving revision 1.188 diff -u -r1.188 lex.l --- src/lex.l 19 Nov 2002 00:33:40 -0000 1.188 +++ src/lex.l 21 Nov 2002 19:31:53 -0000 at @ -267,7 +267,7 @@ return handle_string (yytext[0], true); } -[^ \t\n\;\,\"\'][^ \t\n\;\,]*{S}* { +[^#% \t\n\;\,\"\'][^ \t\n\;\,]*{S}* { std::string tok = strip_trailing_whitespace (yytext); TOK_PUSH_AND_RETURN (tok, STRING); } ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------