Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
8945:45f8197ffd51 | 8946:e7e928088e90 |
---|---|
53 #include "file-stat.h" | 53 #include "file-stat.h" |
54 #include "load-path.h" | 54 #include "load-path.h" |
55 #include "oct-env.h" | 55 #include "oct-env.h" |
56 | 56 |
57 #include "byte-swap.h" | 57 #include "byte-swap.h" |
58 #include "ls-ascii-helper.h" | |
59 #include "ls-hdf5.h" | |
58 #include "ls-oct-ascii.h" | 60 #include "ls-oct-ascii.h" |
59 #include "ls-oct-binary.h" | 61 #include "ls-oct-binary.h" |
60 #include "ls-hdf5.h" | |
61 #include "ls-utils.h" | 62 #include "ls-utils.h" |
62 | 63 |
63 DEFINE_OCTAVE_ALLOCATOR (octave_fcn_handle); | 64 DEFINE_OCTAVE_ALLOCATOR (octave_fcn_handle); |
64 | 65 |
65 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_fcn_handle, | 66 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_fcn_handle, |
295 | 296 |
296 is >> nm; | 297 is >> nm; |
297 | 298 |
298 if (nm == "@<anonymous>") | 299 if (nm == "@<anonymous>") |
299 { | 300 { |
300 octave_idx_type len = 0; | 301 skip_preceeding_newline (is); |
301 char c; | 302 |
302 std::ostringstream buf; | 303 std::string buf; |
303 | |
304 // Skip preceeding newline(s). | |
305 while (is.get (c) && c == '\n') | |
306 /* do nothing */; | |
307 | 304 |
308 if (is) | 305 if (is) |
309 { | 306 { |
310 buf << c; | |
311 | 307 |
312 // Get a line of text whitespace characters included, leaving | 308 // Get a line of text whitespace characters included, leaving |
313 // newline in the stream. | 309 // newline in the stream. |
314 | 310 buf = read_until_newline (is, true); |
315 while (is.peek () != '\n') | 311 |
316 { | |
317 is.get (c); | |
318 if (! is) | |
319 break; | |
320 buf << c; | |
321 } | |
322 } | 312 } |
323 | 313 |
324 pos = is.tellg (); | 314 pos = is.tellg (); |
325 | 315 |
326 symbol_table::scope_id local_scope = symbol_table::alloc_scope (); | 316 symbol_table::scope_id local_scope = symbol_table::alloc_scope (); |
317 | |
318 octave_idx_type len = 0; | |
327 | 319 |
328 if (extract_keyword (is, "length", len, true) && len >= 0) | 320 if (extract_keyword (is, "length", len, true) && len >= 0) |
329 { | 321 { |
330 if (len > 0) | 322 if (len > 0) |
331 { | 323 { |
361 | 353 |
362 unwind_protect::add (symbol_table::pop_scope); | 354 unwind_protect::add (symbol_table::pop_scope); |
363 | 355 |
364 int parse_status; | 356 int parse_status; |
365 octave_value anon_fcn_handle = | 357 octave_value anon_fcn_handle = |
366 eval_string (buf.str (), true, parse_status); | 358 eval_string (buf, true, parse_status); |
367 | 359 |
368 if (parse_status == 0) | 360 if (parse_status == 0) |
369 { | 361 { |
370 octave_fcn_handle *fh = | 362 octave_fcn_handle *fh = |
371 anon_fcn_handle.fcn_handle_value (); | 363 anon_fcn_handle.fcn_handle_value (); |