diff src/ov-fcn-handle.cc @ 8946:e7e928088e90

fix CRLF issues with text-mode reading in windows when loading ascii data
author Benjamin Lindner <lindnerb@users.sourceforge.net>
date Tue, 10 Mar 2009 01:01:50 -0400
parents eb63fbe60fab
children c6463412aebb
line wrap: on
line diff
--- a/src/ov-fcn-handle.cc	Mon Mar 09 17:13:58 2009 -0400
+++ b/src/ov-fcn-handle.cc	Tue Mar 10 01:01:50 2009 -0400
@@ -55,9 +55,10 @@
 #include "oct-env.h"
 
 #include "byte-swap.h"
+#include "ls-ascii-helper.h"
+#include "ls-hdf5.h"
 #include "ls-oct-ascii.h"
 #include "ls-oct-binary.h"
-#include "ls-hdf5.h"
 #include "ls-utils.h"
 
 DEFINE_OCTAVE_ALLOCATOR (octave_fcn_handle);
@@ -297,34 +298,25 @@
 
   if (nm == "@<anonymous>")
     {
-      octave_idx_type len = 0;
-      char c;
-      std::ostringstream buf;
+      skip_preceeding_newline (is);
 
-      // Skip preceeding newline(s).
-      while (is.get (c) && c == '\n')
-	/* do nothing */;
+      std::string buf;
 
       if (is)
 	{
-	  buf << c;
 
 	  // Get a line of text whitespace characters included, leaving
 	  // newline in the stream.
+	  buf = read_until_newline (is, true);
 
-	  while (is.peek () != '\n')
-	    {
-	      is.get (c);
-	      if (! is)
-		break;
-	      buf << c;
-	    }
 	}
 
       pos = is.tellg ();
 
       symbol_table::scope_id local_scope = symbol_table::alloc_scope ();
 
+      octave_idx_type len = 0;
+
       if (extract_keyword (is, "length", len, true) && len >= 0)
 	{
 	  if (len > 0)
@@ -363,7 +355,7 @@
 
 	  int parse_status;
 	  octave_value anon_fcn_handle = 
-	    eval_string (buf.str (), true, parse_status);
+	    eval_string (buf, true, parse_status);
 
 	  if (parse_status == 0)
 	    {