From bug-request at octave dot org Wed Dec 7 14:38:38 2005 Subject: Re: str2num.m can't handle LF character. From: "John W. Eaton" To: Bill Denney Cc: "Frederick (Rick) A Niles" , bug@octave.org Date: Wed, 7 Dec 2005 15:38:28 -0500 On 7-Dec-2005, Bill Denney wrote: | I don't think that this is actually an error. str2num should just convert | strings to numbers. If you give it a string that is not strictly numeric | (including all numeric notation such as 1e5-3j), it is supposed to return | empty. | | The problem sounds like it is with how your file is being read. I agree that it would be best if everyone would translate text files appropriately. Then Octave would only have to handle '\n' as the newline character. Things would be simpler. But we would also see a lot of messages from people who don't know (or care) about EOL translation, and would just complain that Octave sucks because it can't read their simple files. There are already a number of checks for \r\n and \r as EOL characters. I think the following patch will help. I don't see how it could hurt very much, but maybe I'm missing something. jwe src/ChangeLog: 2005-12-07 John W. Eaton * lex.l (NL): Also accept '\r'. Index: src/lex.l =================================================================== RCS file: /cvs/octave/src/lex.l,v retrieving revision 1.228 diff -u -r1.228 lex.l --- src/lex.l 21 May 2005 08:31:52 -0000 1.228 +++ src/lex.l 7 Dec 2005 20:25:52 -0000 at @ -275,7 +275,7 @@ D [0-9] S [ \t] -NL ((\n)|(\r\n)) +NL ((\n)|(\r)|(\r\n)) SNL ({S}|{NL}) EL (\.\.\.) BS (\\) ------------------------------------------------------------- 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 -------------------------------------------------------------