Mercurial > hg > octave-nkf
changeset 16311:9c4ac8f25a8c
textscan.m, textread.m: fix wrong code assessing EOL char(s), remove duplicate code
author | Philip Nienhuis <prnienhuis@users.sf.net> |
---|---|
date | Fri, 15 Mar 2013 09:54:53 +0100 |
parents | e7f6c479ce1c |
children | d81ef5e64cf1 6aafe87a3144 |
files | scripts/io/textread.m scripts/io/textscan.m |
diffstat | 2 files changed, 5 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/io/textread.m +++ b/scripts/io/textread.m @@ -116,12 +116,12 @@ ## Determine EOL from file. Search for EOL candidates in first BUFLENGTH chars eol_srch_len = min (length (str), BUFLENGTH); ## First try DOS (CRLF) - if (! isempty (strfind ("\r\n", str(1 : eol_srch_len)))) + if (! isempty (strfind (str(1 : eol_srch_len), "\r\n"))) eol_char = "\r\n"; ## Perhaps old Macintosh? (CR) - elseif (! isempty (strfind ("\r", str(1 : eol_srch_len)))) + elseif (! isempty (strfind (str(1 : eol_srch_len), "\r"))) eol_char = "\r"; - ## Otherwise, use plain UNIX (LF) + ## Otherwise, use plain *nix (LF) else eol_char = "\n"; endif
--- a/scripts/io/textscan.m +++ b/scripts/io/textscan.m @@ -211,10 +211,10 @@ ## Determine EOL from file. Search for EOL candidates in first BUFLENGTH chars eol_srch_len = min (length (str), BUFLENGTH); ## First try DOS (CRLF) - if (! isempty (strfind ("\r\n", str(1 : eol_srch_len)))) + if (! isempty (strfind (str(1 : eol_srch_len), "\r\n"))) eol_char = "\r\n"; ## Perhaps old Macintosh? (CR) - elseif (! isempty (strfind ("\r", str(1 : eol_srch_len)))) + elseif (! isempty (strfind (str(1 : eol_srch_len), "\r"))) eol_char = "\r"; ## Otherwise, use plain UNIX (LF) else @@ -267,9 +267,6 @@ endif endif - ## Determine the number of data fields - num_fields = numel (strfind (format, "%")) - numel (strfind (format, "%*")); - ## Strip trailing EOL to avoid returning stray missing values (f. strread). ## However, in case of CollectOutput request, presence of EOL is required eol_at_end = strcmp (str(end-length (eol_char) + 1 : end), eol_char);