From bug-octave-request at bevo dot che dot wisc dot edu Thu Jan 21 22:20:12 1999 Subject: Ungraceful exit on strange error From: "John W. Eaton" To: o dot s dot sands at ieee dot org Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 21 Jan 1999 22:20:33 -0600 (CST) On 21-Jan-1999, sands2 at home dot com wrote: | Octave 2.0.13.93 on a i686-linux-pc dumps core rather harshly | when .... | | implicit_str_to_num_ok=0 | | and ... | | k=9 | evalstring=sprintf("save -mat-binary p%04d.mat",k) | eval(evalstring) | | if | implicit_str_to_num_ok=1 | | then everything works as expected. | | I'm only complaining about the | ungraceful handling of this error. Please try the following patch. Thanks, jwe Thu Jan 21 22:15:23 1999 John W. Eaton * load-save.cc (save_mat_binary_data): Check for string type first, then range, then the rest. *** src/load-save.cc~ Wed Nov 11 14:10:25 1998 --- src/load-save.cc Thu Jan 21 22:15:22 1999 *************** *** 2031,2037 **** os.write (&name_len, 4); os << name << '\0'; ! if (tc.is_real_scalar ()) { double tmp = tc.double_value (); os.write (&tmp, 8); --- 2031,2058 ---- os.write (&name_len, 4); os << name << '\0'; ! if (tc.is_string ()) ! { ! begin_unwind_frame ("save_mat_binary_data"); ! unwind_protect_int (Vimplicit_str_to_num_ok); ! Vimplicit_str_to_num_ok = 1; ! Matrix m = tc.matrix_value (); ! os.write (m.data (), 8 * len); ! run_unwind_frame ("save_mat_binary_data"); ! } ! else if (tc.is_range ()) ! { ! Range r = tc.range_value (); ! double base = r.base (); ! double inc = r.inc (); ! int nel = r.nelem (); ! for (int i = 0; i < nel; i++) ! { ! double x = base + i * inc; ! os.write (&x, 8); ! } ! } ! else if (tc.is_real_scalar ()) { double tmp = tc.double_value (); os.write (&tmp, 8); *************** *** 2053,2079 **** os.write (m.data (), 8 * len); m = ::imag(m_cmplx); os.write (m.data (), 8 * len); - } - else if (tc.is_string ()) - { - begin_unwind_frame ("save_mat_binary_data"); - unwind_protect_int (Vimplicit_str_to_num_ok); - Vimplicit_str_to_num_ok = 1; - Matrix m = tc.matrix_value (); - os.write (m.data (), 8 * len); - run_unwind_frame ("save_mat_binary_data"); - } - else if (tc.is_range ()) - { - Range r = tc.range_value (); - double base = r.base (); - double inc = r.inc (); - int nel = r.nelem (); - for (int i = 0; i < nel; i++) - { - double x = base + i * inc; - os.write (&x, 8); - } } else { --- 2074,2079 ----