From bug-octave-request at bevo dot che dot wisc dot edu Tue Dec 17 17:27:38 2002 Subject: Unidentified subject! From: "John W. Eaton" To: Johannes Martin Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 17 Dec 2002 17:27:01 -0600 On 17-Dec-2002, Johannes Martin wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: jmartin | Subject: fprintf() aborts with error message | | Bug report for Octave 2.1.36 configured for i686-pc-linux-gnu | | Description: | ----------- | | fprintf("") fails with error message | | Repeat-By: | --------- | | octave:1> fprintf("") | error: fprintf: internal error handling format | Expected behaviour (Octave 2.0.16.92) | octave:3> fprintf("") | ans = -1 | | This is still true for Octave 2.1.40. Please try the following patch. With it, Octave will not print anything for fprintf ("") and it will return 0 (it should only return -1 on a failure, so the old behavior was buggy too). Thanks, jwe 2002-12-17 John W. Eaton * oct-stream.cc (printf_format_list::printf_format_list): Handle empty format string. Index: src/oct-stream.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/oct-stream.cc,v retrieving revision 1.77 diff -c -r1.77 oct-stream.cc *** src/oct-stream.cc 6 Nov 2002 20:38:50 -0000 1.77 --- src/oct-stream.cc 17 Dec 2002 23:26:34 -0000 *************** *** 586,645 **** bool have_more = true; bool empty_buf = true; ! while (i < n) { ! have_more = true; ! if (! buf) ! { ! buf = new OSSTREAM (); ! empty_buf = true; ! } ! switch (s[i]) { ! case '%': ! { ! if (empty_buf) { ! process_conversion (s, i, n, args, flags, fw, prec, ! type, modifier, num_elts); ! have_more = (buf != 0); } ! else ! add_elt_to_list (args, flags, fw, prec, type, modifier, ! num_elts); ! } ! break; ! ! default: ! { ! args = 0; ! flags = ""; ! fw = 0; ! prec = 0; ! modifier = '\0'; ! type = '\0'; ! *buf << s[i++]; ! empty_buf = false; ! } ! break; ! } ! if (nconv < 0) ! { ! have_more = false; ! break; } - } ! if (have_more) ! add_elt_to_list (args, flags, fw, prec, type, modifier, num_elts); ! list.resize (num_elts); ! delete buf; } printf_format_list::~printf_format_list (void) --- 586,657 ---- bool have_more = true; bool empty_buf = true; ! if (n == 0) { ! printf_format_elt *elt ! = new printf_format_elt ("", args, fw, prec, flags, type, modifier); ! list(num_elts++) = elt; ! list.resize (num_elts); ! } ! else ! { ! while (i < n) { ! have_more = true; ! ! if (! buf) ! { ! buf = new OSSTREAM (); ! empty_buf = true; ! } ! ! switch (s[i]) ! { ! case '%': { ! if (empty_buf) ! { ! process_conversion (s, i, n, args, flags, fw, prec, ! type, modifier, num_elts); ! ! have_more = (buf != 0); ! } ! else ! add_elt_to_list (args, flags, fw, prec, type, modifier, ! num_elts); ! } ! break; ! default: ! { ! args = 0; ! flags = ""; ! fw = 0; ! prec = 0; ! modifier = '\0'; ! type = '\0'; ! *buf << s[i++]; ! empty_buf = false; } ! break; ! } ! if (nconv < 0) ! { ! have_more = false; ! break; ! } } ! if (have_more) ! add_elt_to_list (args, flags, fw, prec, type, modifier, num_elts); ! list.resize (num_elts); ! delete buf; ! } } printf_format_list::~printf_format_list (void) ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------