comparison src/file-io.cc @ 3737:b736f8b8f0a1

[project @ 2000-11-16 18:01:08 by jwe]
author jwe
date Thu, 16 Nov 2000 18:01:10 +0000
parents 3796444c54a3
children 13905c3a24af
comparison
equal deleted inserted replaced
3736:ac4609ffc702 3737:b736f8b8f0a1
628 print_usage ("ftell"); 628 print_usage ("ftell");
629 629
630 return retval; 630 return retval;
631 } 631 }
632 632
633 DEFUN (fprintf, args, , 633 DEFUN (fprintf, args, nargout,
634 "-*- texinfo -*-\n\ 634 "-*- texinfo -*-\n\
635 @deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\ 635 @deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\
636 This function is just like @code{printf}, except that the output is\n\ 636 This function is just like @code{printf}, except that the output is\n\
637 written to the stream @var{fid} instead of @code{stdout}.\n\ 637 written to the stream @var{fid} instead of @code{stdout}.\n\
638 @end deftypefn") 638 @end deftypefn")
639 { 639 {
640 double retval = -1.0; 640 double retval = -1.0;
641 bool return_char_count = true;
641 642
642 int nargin = args.length (); 643 int nargin = args.length ();
643 644
644 if (nargin > 1 || (nargin > 0 && args(0).is_string ())) 645 if (nargin > 1 || (nargin > 0 && args(0).is_string ()))
645 { 646 {
646 octave_stream os; 647 octave_stream os;
647 int fmt_n = 0; 648 int fmt_n = 0;
648 649
649 if (args(0).is_string ()) 650 if (args(0).is_string ())
650 os = octave_stream_list::lookup (1, "fprintf"); 651 {
652 os = octave_stream_list::lookup (1, "fprintf");
653
654 // For compatibility with Matlab, which does not return the
655 // character count when behaving like printf (no file id
656 // parameter).
657
658 return_char_count = (nargout != 0);
659 }
651 else 660 else
652 { 661 {
653 fmt_n = 1; 662 fmt_n = 1;
654 os = octave_stream_list::lookup (args(0), "fprintf"); 663 os = octave_stream_list::lookup (args(0), "fprintf");
655 } 664 }
677 } 686 }
678 } 687 }
679 else 688 else
680 print_usage ("fprintf"); 689 print_usage ("fprintf");
681 690
682 return retval; 691 if (return_char_count)
692 return retval;
693 else
694 return octave_value();
683 } 695 }
684 696
685 DEFUN (fputs, args, , 697 DEFUN (fputs, args, ,
686 "-*- texinfo -*-\n\ 698 "-*- texinfo -*-\n\
687 @deftypefn {Built-in Function} {} fputs (@var{fid}, @var{string})\n\ 699 @deftypefn {Built-in Function} {} fputs (@var{fid}, @var{string})\n\