# HG changeset patch # User jwe # Date 1094909503 0 # Node ID 19b73a80e1d9fe947f52767ec595ecd9da8b7857 # Parent 352d228d409b199726a76a38832fca9e7599e7c9 [project @ 2004-09-11 13:31:43 by jwe] diff -r 352d228d409b -r 19b73a80e1d9 src/ChangeLog --- a/src/ChangeLog Sat Sep 11 13:05:39 2004 +0000 +++ b/src/ChangeLog Sat Sep 11 13:31:43 2004 +0000 @@ -1,3 +1,11 @@ +2004-09-11 John W. Eaton + + * ov-fcn-handle.cc (octave_fcn_handle::save_ascii): + Write directly to OS. + (octave_fcn_handle::load_ascii, octave_fcn_handle::load_binary, + octave_fcn_handle::load_hdf5): Check parse status after calling + eval_string. Don't dereference fh unless it is valid. + 2004-09-11 David Bateman * ov-fcn-handle.cc (octave_fcn_handle::save_ascii, diff -r 352d228d409b -r 19b73a80e1d9 src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Sat Sep 11 13:05:39 2004 +0000 +++ b/src/ov-fcn-handle.cc Sat Sep 11 13:31:43 2004 +0000 @@ -101,12 +101,11 @@ octave_fcn_handle::save_ascii (std::ostream& os, bool&, bool) { os << nm << "\n"; + if (nm == "@") { - OSSTREAM buf; - print_raw (buf, true); - os << OSSTREAM_STR (buf) << "\n" << OSSTREAM_ENDS; - OSSTREAM_FREEZE (buf); + print_raw (os, true); + os << "\n"; } return true; @@ -116,20 +115,23 @@ octave_fcn_handle::load_ascii (std::istream& is) { is >> nm; + if (nm == "@") { char c; OSSTREAM buf; - // Skip preceeding newline(s) - while (is.get (c) && c == '\n'); + // Skip preceeding newline(s). + while (is.get (c) && c == '\n') + /* do nothing */; if (is) { buf << c; // Get a line of text whitespace characters included, leaving - // newline in the stream + // newline in the stream. + while (is.peek () != '\n') { is.get (c); @@ -142,11 +144,20 @@ buf << OSSTREAM_ENDS; int parse_status; - octave_value anon_fcn_handle = eval_string (OSSTREAM_C_STR (buf), + octave_value anon_fcn_handle = eval_string (OSSTREAM_STR (buf), true, parse_status); OSSTREAM_FREEZE (buf); - fcn = anon_fcn_handle.fcn_handle_value () -> fcn; + if (parse_status == 0) + { + octave_fcn_handle *fh = anon_fcn_handle.fcn_handle_value (); + if (fh) + fcn = fh->fcn; + else + return false; + } + else + return false; } else { @@ -207,7 +218,16 @@ int parse_status; octave_value anon_fcn_handle = eval_string (ctmp2, true, parse_status); - fcn = anon_fcn_handle.fcn_handle_value () -> fcn; + if (parse_status == 0) + { + octave_fcn_handle *fh = anon_fcn_handle.fcn_handle_value (); + if (fh) + fcn = fh->fcn; + else + return false; + } + else + return false; } else { @@ -252,7 +272,8 @@ data_hid = H5Dcreate (group_hid, "nm", type_hid, space_hid, H5P_DEFAULT); if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) nm.c_str ()) < 0) + H5P_DEFAULT, + static_cast (nm.c_str ())) < 0) { H5Sclose (space_hid); H5Tclose (type_hid); @@ -279,7 +300,8 @@ data_hid = H5Dcreate (group_hid, "fcn", type_hid, space_hid, H5P_DEFAULT); if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) stmp.c_str ()) < 0) + H5P_DEFAULT, + static_cast (stmp.c_str ())) < 0) { H5Sclose (space_hid); H5Tclose (type_hid); @@ -430,7 +452,16 @@ int parse_status; octave_value anon_fcn_handle = eval_string (fcn_tmp, true, parse_status); - fcn = anon_fcn_handle.fcn_handle_value () -> fcn; + if (parse_status == 0) + { + octave_fcn_handle *fh = anon_fcn_handle.fcn_handle_value (); + if (fh) + fcn = fh->fcn; + else + return false; + } + else + return false; } else { @@ -459,7 +490,7 @@ { tree_print_code tpc (os); - // FCN is const becuase this member function is, so we can't + // FCN is const because this member function is, so we can't // use it to call user_function_value, so we make a copy first. octave_value ftmp = fcn;