From bug-octave-request at bevo dot che dot wisc dot edu Thu Nov 16 11:58:23 2000 Subject: fprintf retval From: "John W. Eaton" To: Paul Kienzle Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 16 Nov 2000 11:58:16 -0600 On 14-Nov-2000, Paul Kienzle wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: pkienzle | Subject: fprintf retval | | Bug report for Octave 2.1.31 configured for %OCTAVE_CANONICAL_HOST_TYPE% | | Description: | ----------- | | fprintf('format', values) should not return a value if none is requested | for compatibility with matlab. Otherwise, running code written for | matlab which prints to the screen but forgets the semi-colons (because | matlab doesn't require it) has ans=### sprinkled throughout the output. OK, I made this change. Thanks, jwe | Repeat-By: | --------- | | fprintf('hello') | | Fix: | --- | | | *** src/file-io.cc 2000/10/05 12:32:11 1.1 | --- src/file-io.cc 2000/11/14 10:07:34 | *************** from the beginning of the file at var{fid} | *** 630,636 **** | return retval; | } | | ! DEFUN (fprintf, args, , | "-*- texinfo -*-\n\ | at deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\ | This function is just like at code{printf}, except that the output is\n\ | --- 630,636 ---- | return retval; | } | | ! DEFUN (fprintf, args, nargout, | "-*- texinfo -*-\n\ | at deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\ | This function is just like at code{printf}, except that the output is\n\ | *************** written to the stream at var{fid} instead | *** 638,643 **** | --- 638,644 ---- | at end deftypefn") | { | double retval = -1.0; | + bool do_return = true; | | int nargin = args.length (); | | *************** written to the stream at var{fid} instead | *** 646,653 **** | octave_stream os; | int fmt_n = 0; | | ! if (args(0).is_string ()) | ! os = octave_stream_list::lookup (1, "fprintf"); | else | { | fmt_n = 1; | --- 647,657 ---- | octave_stream os; | int fmt_n = 0; | | ! if (args(0).is_string ()) | ! { | ! os = octave_stream_list::lookup (1, "fprintf"); | ! do_return = (nargout != 0); | ! } | else | { | fmt_n = 1; | *************** written to the stream at var{fid} instead | *** 679,685 **** | else | print_usage ("fprintf"); | | ! return retval; | } | | DEFUN (fputs, args, , | --- 683,692 ---- | else | print_usage ("fprintf"); | | ! if (do_return) | ! return retval; | ! else | ! return octave_value(); | } | | DEFUN (fputs, args, , | | ------------------------------------------------------------- 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 -------------------------------------------------------------