# HG changeset patch # User Mike Miller # Date 1461175563 25200 # Node ID 96518f623c91090c10dc0f6e7b5b2f998968bbc5 # Parent dcf8922b724b91579887abd62dfcc0392b02c159 Backed out changeset dcf8922b724b diff -r dcf8922b724b -r 96518f623c91 NEWS --- a/NEWS Wed Apr 20 17:53:10 2016 +0200 +++ b/NEWS Wed Apr 20 11:06:03 2016 -0700 @@ -71,10 +71,6 @@ ** The textscan function is now built-in and is much faster and much more Matlab-compatible than the previous m-file version. - ** The fputs function now allows to ommit the file descriptor to - print the string to stdout and returns the number of bytes written - to the file descriptor or stdout, respectively. - ** Dialog boxes, errordlg, helpdlg, inputdlg, errordlg, listdlg, msgbox, questdlg, and warndlg, now exclusively use QT. Java based versions are removed. @@ -104,9 +100,6 @@ mahalanobis | mahal in Octave-Forge statistics pkg md5sum | hash octve_config_info | __octave_config_info__ - printf | fprintf - puts | fputs - scanf | fscanf sleep | pause usleep | pause wavread | audioread diff -r dcf8922b724b -r 96518f623c91 doc/interpreter/basics.txi --- a/doc/interpreter/basics.txi Wed Apr 20 17:53:10 2016 +0200 +++ b/doc/interpreter/basics.txi Wed Apr 20 11:06:03 2016 -0700 @@ -310,12 +310,12 @@ @example @group -fprintf ("%s", program_name ()); +printf ("%s", program_name ()); arg_list = argv (); for i = 1:nargin - fprintf (" %s", arg_list@{i@}); + printf (" %s", arg_list@{i@}); endfor -fprintf ("\n"); +printf ("\n"); @end group @end example @@ -1038,7 +1038,7 @@ printf ("%s", program_name ()); arg_list = argv (); for i = 1:nargin - fprintf (" %s", arg_list@{i@}); + printf (" %s", arg_list@{i@}); endfor printf ("\n"); @end group diff -r dcf8922b724b -r 96518f623c91 doc/interpreter/func.txi --- a/doc/interpreter/func.txi Wed Apr 20 17:53:10 2016 +0200 +++ b/doc/interpreter/func.txi Wed Apr 20 11:06:03 2016 -0700 @@ -108,12 +108,12 @@ @example @group function wakeup - fprintf ("\a"); + printf ("\a"); endfunction @end group @end example -The @code{fprintf} statement (@pxref{Input and Output}) simply tells +The @code{printf} statement (@pxref{Input and Output}) simply tells Octave to print the string @qcode{"@xbackslashchar{}a"}. The special character @samp{\a} stands for the alert character (ASCII 7). @xref{Strings}. @@ -143,7 +143,7 @@ @example @group function wakeup (message) - fprintf ("\a%s\n", message); + printf ("\a%s\n", message); endfunction @end group @end example @@ -157,7 +157,7 @@ @noindent will cause Octave to ring your terminal's bell and print the message @samp{Rise and shine!}, followed by a newline character (the @samp{\n} -in the first argument to the @code{fprintf} statement). +in the first argument to the @code{printf} statement). In most cases, you will also want to get some information back from the functions you define. Here is the syntax for writing a function that @@ -488,7 +488,7 @@ @group function print_arguments (varargin) for i = 1:length (varargin) - fprintf ("Input argument %d: ", i); + printf ("Input argument %d: ", i); disp (varargin@{i@}); endfor endfunction @@ -620,7 +620,7 @@ return; endif endfor - fprintf ("no nonzero elements found\n"); + printf ("no nonzero elements found\n"); endfunction @end group @end example @@ -664,7 +664,7 @@ @example @group function hello (who = "World") - fprintf ("Hello, %s!\n", who); + printf ("Hello, %s!\n", who); endfunction @end group @end example @@ -825,15 +825,15 @@ @example @group function f () - fprintf ("in f, calling g\n"); + printf ("in f, calling g\n"); g () endfunction function g () - fprintf ("in g, calling h\n"); + printf ("in g, calling h\n"); h () endfunction function h () - fprintf ("in h\n") + printf ("in h\n") endfunction @end group @end example @@ -1096,8 +1096,8 @@ function count_calls () mlock (); persistent calls = 0; - fprintf ("'count_calls' has been called %d times\n", - ++calls); + printf ("'count_calls' has been called %d times\n", + ++calls); endfunction count_calls (); diff -r dcf8922b724b -r 96518f623c91 doc/interpreter/io.txi --- a/doc/interpreter/io.txi Wed Apr 20 17:53:10 2016 +0200 +++ b/doc/interpreter/io.txi Wed Apr 20 11:06:03 2016 -0700 @@ -88,11 +88,12 @@ Normally, no output is displayed by the pager until just before Octave is ready to print the top level prompt, or read from the standard input -(for example, by using the @code{fscanf} function). This means that there -may be some delay before any output appears on your screen if you have -asked Octave to perform a significant amount of work with a single -command statement. The function @code{fflush} may be used to force output -to be sent to the pager (or any other stream) immediately. +(for example, by using the @code{fscanf} or @code{scanf} functions). +This means that there may be some delay before any output appears on +your screen if you have asked Octave to perform a significant amount of +work with a single command statement. The function @code{fflush} may be +used to force output to be sent to the pager (or any other stream) +immediately. You can select the program to run as the pager using the @env{PAGER} function, and you can turn paging off by using the function @@ -332,12 +333,28 @@ @node Simple Output @subsection Simple Output -The function @code{fputs} is the most simple way to write an unformatted -string to either @code{stdout} or to a file, that has been opened for -writing. +Once a file has been opened for writing a string can be written to the +file using the @code{fputs} function. The following example shows +how to write the string @samp{Free Software is needed for Free Science} +to the file @samp{free.txt}. + +@example +@group +filename = "free.txt"; +fid = fopen (filename, "w"); +fputs (fid, "Free Software is needed for Free Science"); +fclose (fid); +@end group +@end example @DOCSTRING(fputs) +A function much similar to @code{fputs} is available for writing data +to the screen. The @code{puts} function works just like @code{fputs} +except it doesn't take a file pointer as its input. + +@DOCSTRING(puts) + @node Line-Oriented Input @subsection Line-Oriented Input @@ -367,18 +384,25 @@ @node Formatted Output @subsection Formatted Output -This section describes how to call the @code{fprintf} and @code{sprintf} -functions. These functions are available for formatted output. They are +This section describes how to call @code{printf} and related functions. + +The following functions are available for formatted output. They are modeled after the C language functions of the same name, but they interpret the format template differently in order to improve the performance of printing vector and matrix values. +Implementation Note: For compatibility with @sc{matlab}, escape sequences in +the template string (e.g., @qcode{"@xbackslashchar{}n"} => newline) are +expanded even when the template string is defined with single quotes. + +@DOCSTRING(printf) + @DOCSTRING(fprintf) @DOCSTRING(sprintf) -@code{fprintf} and @code{sprintf} can be used to print any number of -arguments. The template string argument you supply in a call provides +The @code{printf} function can be used to print any number of arguments. +The template string argument you supply in a call provides information not only about the number of additional arguments, but also about their types and what style should be used for printing them. @@ -386,14 +410,14 @@ output stream as-is, while @dfn{conversion specifications} introduced by a @samp{%} character in the template cause subsequent arguments to be formatted and written to the output stream. For example, -@cindex conversion specifications (@code{fprintf}) +@cindex conversion specifications (@code{printf}) @example @group pct = 37; filename = "foo.txt"; -fprintf ("Processed %d%% of '%s'.\nPlease be patient.\n", - pct, filename); +printf ("Processed %d%% of '%s'.\nPlease be patient.\n", + pct, filename); @end group @end example @@ -443,7 +467,7 @@ @example @group -fprintf ("%4.2f %10.2e %8.4g\n", hilb (3)); +printf ("%4.2f %10.2e %8.4g\n", hilb (3)); @print{} 1.00 5.00e-01 0.3333 @print{} 0.50 3.33e-01 0.25 @@ -459,7 +483,7 @@ @example @group -fprintf ("%4.2f %10.2e %8.4g\n", [1, 2], [3, 4]); +printf ("%4.2f %10.2e %8.4g\n", [1, 2], [3, 4]); @print{} 1.00 2.00e+00 3 @print{} 4.00 @@ -472,13 +496,14 @@ @subsection Output Conversion Syntax This section provides details about the precise syntax of conversion -specifications that can appear in a @code{fprintf} or @code{sprintf} -template string. +specifications that can appear in a @code{printf} template +string. Characters in the template string that are not part of a conversion specification are printed as-is to the output stream. -The conversion specifications in a template string have the general form: +The conversion specifications in a @code{printf} template string have +the general form: @example % @var{flags} @var{width} @r{[} . @var{precision} @r{]} @var{type} @var{conversion} @@ -498,7 +523,7 @@ @item Zero or more @dfn{flag characters} that modify the normal behavior of the conversion specification. -@cindex flag character (@code{fprintf}) +@cindex flag character (@code{printf}) @item An optional decimal integer specifying the @dfn{minimum field width}. @@ -507,7 +532,7 @@ value; if the normal conversion produces more characters than this, the field is @emph{not} truncated. Normally, the output is right-justified within the field. -@cindex minimum field width (@code{fprintf}) +@cindex minimum field width (@code{printf}) You can also specify a field width of @samp{*}. This means that the next argument in the argument list (before the actual value to be @@ -521,7 +546,7 @@ written for the numeric conversions. If the precision is specified, it consists of a period (@samp{.}) followed optionally by a decimal integer (which defaults to zero if omitted). -@cindex precision (@code{fprintf}) +@cindex precision (@code{printf}) You can also specify a precision of @samp{*}. This means that the next argument in the argument list (before the actual value to be printed) is @@ -530,8 +555,8 @@ @item An optional @dfn{type modifier character}. This character is ignored by -Octave's @code{fprintf} function, but is recognized to provide -compatibility with the C language @code{fprintf}. +Octave's @code{printf} function, but is recognized to provide +compatibility with the C language @code{printf}. @item A character that specifies the conversion to be applied. @@ -544,7 +569,7 @@ @node Table of Output Conversions @subsection Table of Output Conversions -@cindex output conversions, for @code{fprintf} +@cindex output conversions, for @code{printf} Here is a table summarizing what all the different conversions do: @@ -552,7 +577,7 @@ @item @samp{%d}, @samp{%i} Print an integer as a signed decimal number. @xref{Integer Conversions}, for details. @samp{%d} and @samp{%i} are synonymous for -output, but are different when used with @code{fscanf} for input +output, but are different when used with @code{scanf} for input (@pxref{Table of Input Conversions}). @item @samp{%o} @@ -598,15 +623,16 @@ a bare percentage sign @samp{%} with no subsequent conversion character. Octave will emit an error and stop if it sees such code. When the string variable to be processed cannot be guaranteed to be free of potential format -codes it is better to use the two argument form of @code{fprintf} and -@code{sprintf} and set the format string to @code{%s}. Alternatively, -the function @code{disp} can be used. +codes it is better to use the two argument form of any of the @code{printf} +functions and set the format string to @code{%s}. Alternatively, for code +which is not required to be backwards-compatible with @sc{matlab} the +Octave function @code{puts} or @code{disp} can be used. @example @group -fprintf (strvar); # Unsafe if strvar contains format codes -fprintf ("%s", strvar); # Safe -disp (strvar); # Safe +printf (strvar); # Unsafe if strvar contains format codes +printf ("%s", strvar); # Safe +puts (strvar); # Safe @end group @end example @@ -737,8 +763,7 @@ @node Other Output Conversions @subsection Other Output Conversions -This section describes miscellaneous conversions for @code{fprintf} and -@code{sprintf}. +This section describes miscellaneous conversions for @code{printf}. The @samp{%c} conversion prints a single character. The @samp{-} flag can be used to specify left-justification in the field, but no @@ -746,7 +771,7 @@ For example: @example -fprintf ("%c%c%c%c%c", "h", "e", "l", "l", "o"); +printf ("%c%c%c%c%c", "h", "e", "l", "l", "o"); @end example @noindent @@ -761,7 +786,7 @@ are defined for this conversion. For example: @example -fprintf ("%3s%-6s", "no", "where"); +printf ("%3s%-6s", "no", "where"); @end example @noindent @@ -770,34 +795,36 @@ @node Formatted Input @subsection Formatted Input -Octave provides the @code{fscanf} and @code{sscanf} functions to read -formatted input. There are two forms of each of these functions. One -can be used to extract vectors of data from a file, and the other is -more `C-like'. +Octave provides the @code{scanf}, @code{fscanf}, and @code{sscanf} +functions to read formatted input. There are two forms of each of these +functions. One can be used to extract vectors of data from a file, and +the other is more `C-like'. @DOCSTRING(fscanf) +@DOCSTRING(scanf) + @DOCSTRING(sscanf) -Calls to @code{fscanf} are superficially similar to calls to -@code{fprintf} in that arbitrary arguments are read under the control of +Calls to @code{scanf} are superficially similar to calls to +@code{printf} in that arbitrary arguments are read under the control of a template string. While the syntax of the conversion specifications in -the template is very similar to that for @code{fprintf}, the +the template is very similar to that for @code{printf}, the interpretation of the template is oriented more towards free-format input and simple pattern matching, rather than fixed-field formatting. -For example, most @code{fscanf} conversions skip over any amount of +For example, most @code{scanf} conversions skip over any amount of ``white space'' (including spaces, tabs, and newlines) in the input file, and there is no concept of precision for the numeric input conversions as there is for the corresponding output conversions. Ordinarily, non-whitespace characters in the template are expected to match characters in the input stream exactly. -@cindex conversion specifications (@code{fscanf}) +@cindex conversion specifications (@code{scanf}) -When a @dfn{matching failure} occurs, @code{fscanf} returns immediately, +When a @dfn{matching failure} occurs, @code{scanf} returns immediately, leaving the first non-matching character as the next character to be -read from the stream, and @code{fscanf} returns all the items that were +read from the stream, and @code{scanf} returns all the items that were successfully converted. -@cindex matching failure, in @code{fscanf} +@cindex matching failure, in @code{scanf} The formatted input functions are not used as frequently as the formatted output functions. Partly, this is because it takes some care @@ -807,7 +834,7 @@ @node Input Conversion Syntax @subsection Input Conversion Syntax -A @code{fscanf} template string is a string that contains ordinary +A @code{scanf} template string is a string that contains ordinary multibyte characters interspersed with conversion specifications that start with @samp{%}. @@ -822,7 +849,7 @@ specifications must match characters in the input stream exactly; if this is not the case, a matching failure occurs. -The conversion specifications in a @code{fscanf} template string +The conversion specifications in a @code{scanf} template string have the general form: @example @@ -835,12 +862,12 @@ @itemize @bullet @item An optional @dfn{flag character} @samp{*}, which says to ignore the text -read for this specification. When @code{fscanf} finds a conversion +read for this specification. When @code{scanf} finds a conversion specification that uses this flag, it reads input as directed by the rest of the conversion specification, but it discards this input, does not return any value, and does not increment the count of successful assignments. -@cindex flag character (@code{fscanf}) +@cindex flag character (@code{scanf}) @item An optional decimal integer that specifies the @dfn{maximum field @@ -850,12 +877,12 @@ characters, and these discarded characters don't count towards the maximum field width. Conversions that do not discard initial whitespace are explicitly documented. -@cindex maximum field width (@code{fscanf}) +@cindex maximum field width (@code{scanf}) @item An optional type modifier character. This character is ignored by -Octave's @code{fscanf} function, but is recognized to provide -compatibility with the C language @code{fscanf}. +Octave's @code{scanf} function, but is recognized to provide +compatibility with the C language @code{scanf}. @item A character that specifies the conversion to be applied. @@ -868,7 +895,7 @@ @node Table of Input Conversions @subsection Table of Input Conversions -@cindex input conversions, for @code{fscanf} +@cindex input conversions, for @code{scanf} Here is a table that summarizes the various conversion specifications: @@ -922,7 +949,7 @@ @node Numeric Input Conversions @subsection Numeric Input Conversions -This section describes the @code{fscanf} conversions for reading numeric +This section describes the @code{scanf} conversions for reading numeric values. The @samp{%d} conversion matches an optionally signed integer in decimal @@ -942,13 +969,13 @@ The @samp{%X} conversion is identical to the @samp{%x} conversion. They both permit either uppercase or lowercase letters to be used as digits. -Unlike the C language @code{fscanf}, Octave ignores the @samp{h}, +Unlike the C language @code{scanf}, Octave ignores the @samp{h}, @samp{l}, and @samp{L} modifiers. @node String Input Conversions @subsection String Input Conversions -This section describes the @code{fscanf} input conversions for reading +This section describes the @code{scanf} input conversions for reading string and character values: @samp{%s} and @samp{%c}. The @samp{%c} conversion is the simplest: it matches a fixed number of @@ -1064,3 +1091,4 @@ fseek (myfile, marker, SEEK_SET); @end group @end example + diff -r dcf8922b724b -r 96518f623c91 doc/interpreter/stmt.txi --- a/doc/interpreter/stmt.txi Wed Apr 20 17:53:10 2016 +0200 +++ b/doc/interpreter/stmt.txi Wed Apr 20 11:06:03 2016 -0700 @@ -115,16 +115,16 @@ @example @group if (rem (x, 2) == 0) - fprintf ("x is even\n"); + printf ("x is even\n"); else - fprintf ("x is odd\n"); + printf ("x is odd\n"); endif @end group @end example In this example, if the expression @code{rem (x, 2) == 0} is true (that is, the value of @code{x} is divisible by 2), then the first -@code{fprintf} statement is evaluated, otherwise the second @code{fprintf} +@code{printf} statement is evaluated, otherwise the second @code{printf} statement is evaluated. The third and most general form of the @code{if} statement allows @@ -152,20 +152,20 @@ statement. In the following example, if the first condition is true (that is, the -value of @code{x} is divisible by 2), then the first @code{fprintf} +value of @code{x} is divisible by 2), then the first @code{printf} statement is executed. If it is false, then the second condition is tested, and if it is true (that is, the value of @code{x} is divisible -by 3), then the second @code{fprintf} statement is executed. Otherwise, -the third @code{fprintf} statement is performed. +by 3), then the second @code{printf} statement is executed. Otherwise, +the third @code{printf} statement is performed. @example @group if (rem (x, 2) == 0) - fprintf ("x is even\n"); + printf ("x is even\n"); elseif (rem (x, 3) == 0) - fprintf ("x is odd and divisible by 3\n"); + printf ("x is odd and divisible by 3\n"); else - fprintf ("x is odd\n"); + printf ("x is odd\n"); endif @end group @end example @@ -296,9 +296,9 @@ A = 7; switch (A) case @{ 6, 7 @} - fprintf ("variable is either 6 or 7\n"); + printf ("variable is either 6 or 7\n"); otherwise - fprintf ("variable is neither 6 nor 7\n"); + printf ("variable is neither 6 nor 7\n"); endswitch @end group @end example @@ -684,9 +684,9 @@ div++; endwhile if (rem (num, div) == 0) - fprintf ("Smallest divisor of %d is %d\n", num, div) + printf ("Smallest divisor of %d is %d\n", num, div) else - fprintf ("%d is prime\n", num); + printf ("%d is prime\n", num); endif @end group @end example @@ -707,12 +707,12 @@ div = 2; while (1) if (rem (num, div) == 0) - fprintf ("Smallest divisor of %d is %d\n", num, div); + printf ("Smallest divisor of %d is %d\n", num, div); break; endif div++; if (div*div > num) - fprintf ("%d is prime\n", num); + printf ("%d is prime\n", num); break; endif endwhile @@ -746,7 +746,7 @@ if (rem (x, 2) != 0) continue; endif - fprintf ("%d\n", x); + printf ("%d\n", x); endfor @end group @end example @@ -763,7 +763,7 @@ @group for x = vec if (rem (x, 2) == 0) - fprintf ("%d\n", x); + printf ("%d\n", x); endif endfor @end group diff -r dcf8922b724b -r 96518f623c91 doc/interpreter/var.txi --- a/doc/interpreter/var.txi Wed Apr 20 17:53:10 2016 +0200 +++ b/doc/interpreter/var.txi Wed Apr 20 11:06:03 2016 -0700 @@ -193,8 +193,8 @@ @group function count_calls () persistent calls = 0; - fprintf ("'count_calls' has been called %d times\n", - ++calls); + printf ("'count_calls' has been called %d times\n", + ++calls); endfunction for i = 1:3 @@ -248,8 +248,8 @@ if (isempty (calls)) calls = 0; endif - fprintf ("'count_calls' has been called %d times\n", - ++calls); + printf ("'count_calls' has been called %d times\n", + ++calls); endfunction @end group @end example diff -r dcf8922b724b -r 96518f623c91 doc/refcard/refcard.tex --- a/doc/refcard/refcard.tex Wed Apr 20 17:53:10 2016 +0200 +++ b/doc/refcard/refcard.tex Wed Apr 20 11:06:03 2016 -0700 @@ -877,8 +877,10 @@ \altsec C-style Input and Output; fopen ({\it name}, {\it mode})&open file {\it name}\cr fclose ({\it file})&close {\it file}\cr +printf ({\it fmt}, ...)&formatted output to {\tt stdout}\cr fprintf ({\it file}, {\it fmt}, ...)&formatted output to {\it file}\cr sprintf ({\it fmt}, ...)&formatted output to string\cr +scanf ({\it fmt})&formatted input from {\tt stdin}\cr fscanf ({\it file}, {\it fmt})&formatted input from {\it file}\cr sscanf ({\it str}, {\it fmt})&formatted input from {\it string}\cr fgets ({\it file}, {\it len})&read {\it len\/} characters from {\it file\/}\cr diff -r dcf8922b724b -r 96518f623c91 examples/code/@FIRfilter/display.m --- a/examples/code/@FIRfilter/display.m Wed Apr 20 17:53:10 2016 +0200 +++ b/examples/code/@FIRfilter/display.m Wed Apr 20 11:06:03 2016 -0700 @@ -1,4 +1,4 @@ function display (f) - fprintf ("%s.polynomial", inputname (1)); + printf ("%s.polynomial", inputname (1)); display (f.polynomial); endfunction diff -r dcf8922b724b -r 96518f623c91 examples/code/@polynomial/display.m --- a/examples/code/@polynomial/display.m Wed Apr 20 17:53:10 2016 +0200 +++ b/examples/code/@polynomial/display.m Wed Apr 20 11:06:03 2016 -0700 @@ -1,6 +1,6 @@ function display (p) - fprintf ("%s =", inputname (1)); + printf ("%s =", inputname (1)); a = p.poly; first = true; @@ -9,28 +9,28 @@ if (first) first = false; elseif (a(i) > 0 || isnan (a(i))) - fprintf (" +"); + printf (" +"); endif if (a(i) < 0) - fprintf (" -"); + printf (" -"); endif if (i == 1) - fprintf (" %.5g", abs (a(i))); + printf (" %.5g", abs (a(i))); elseif (abs (a(i)) != 1) - fprintf (" %.5g *", abs (a(i))); + printf (" %.5g *", abs (a(i))); endif if (i > 1) - fprintf (" X"); + printf (" X"); endif if (i > 2) - fprintf (" ^ %d", i - 1); + printf (" ^ %d", i - 1); endif endif endfor if (first) - fprintf (" 0"); + printf (" 0"); endif - fprintf ("\n"); + printf ("\n"); endfunction diff -r dcf8922b724b -r 96518f623c91 libinterp/corefcn/file-io.cc --- a/libinterp/corefcn/file-io.cc Wed Apr 20 17:53:10 2016 +0200 +++ b/libinterp/corefcn/file-io.cc Wed Apr 20 11:06:03 2016 -0700 @@ -780,7 +780,7 @@ Implementation Note: For compatibility with @sc{matlab}, escape sequences in\n\ the template string (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are\n\ expanded even when the template string is defined with single quotes.\n\ -@seealso{fputs, fdisp, fwrite, fscanf, sprintf, fopen}\n\ +@seealso{fputs, fdisp, fwrite, fscanf, printf, sprintf, fopen}\n\ @end deftypefn") { static std::string who = "fprintf"; @@ -824,6 +824,99 @@ return ovl (); } +DEFUN (printf, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {} {} printf (@var{template}, @dots{})\n\ +Print optional arguments under the control of the template string\n\ +@var{template} to the stream @code{stdout} and return the number of\n\ +characters printed.\n\ +@ifclear OCTAVE_MANUAL\n\ +\n\ +See the Formatted Output section of the GNU Octave manual for a\n\ +complete description of the syntax of the template string.\n\ +@end ifclear\n\ +\n\ +Implementation Note: For compatibility with @sc{matlab}, escape sequences in\n\ +the template string (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are\n\ +expanded even when the template string is defined with single quotes.\n\ +@seealso{fprintf, sprintf, scanf}\n\ +@end deftypefn") +{ + static std::string who = "printf"; + + int nargin = args.length (); + + if (nargin == 0) + print_usage (); + + int result; + + if (! args(0).is_string ()) + error ("%s: format TEMPLATE must be a string", who.c_str ()); + + octave_value_list tmp_args; + + if (nargin > 1) + { + tmp_args.resize (nargin-1, octave_value ()); + + for (int i = 1; i < nargin; i++) + tmp_args(i-1) = args(i); + } + + result = stdout_stream.printf (args(0), tmp_args, who); + + if (nargout > 0) + return ovl (result); + else + return ovl (); +} + +DEFUN (fputs, args, , + "-*- texinfo -*-\n\ +@deftypefn {} {} fputs (@var{fid}, @var{string})\n\ +@deftypefnx {} {@var{status} =} fputs (@var{fid}, @var{string})\n\ +Write the string @var{string} to the file with file descriptor @var{fid}.\n\ +\n\ +The string is written to the file with no additional formatting. Use\n\ +@code{fdisp} instead to automatically append a newline character appropriate\n\ +for the local machine.\n\ +\n\ +Return a non-negative number on success or EOF on error.\n\ +@seealso{fdisp, fprintf, fwrite, fopen}\n\ +@end deftypefn") +{ + static std::string who = "fputs"; + + if (args.length () != 2) + print_usage (); + + octave_stream os = octave_stream_list::lookup (args(0), who); + + return ovl (os.puts (args(1), who)); +} + +DEFUN (puts, args, , + "-*- texinfo -*-\n\ +@deftypefn {} {} puts (@var{string})\n\ +@deftypefnx {} {@var{status} =} puts (@var{string})\n\ +Write a string to the standard output with no formatting.\n\ +\n\ +The string is written verbatim to the standard output. Use @code{disp} to\n\ +automatically append a newline character appropriate for the local machine.\n\ +\n\ +Return a non-negative number on success and EOF on error.\n\ +@seealso{fputs, disp}\n\ +@end deftypefn") +{ + static std::string who = "puts"; + + if (args.length () != 1) + print_usage (); + + return ovl (stdout_stream.puts (args(0), who)); +} + DEFUN (sprintf, args, , "-*- texinfo -*-\n\ @deftypefn {} {} sprintf (@var{template}, @dots{})\n\ @@ -837,7 +930,7 @@ Implementation Note: For compatibility with @sc{matlab}, escape sequences in\n\ the template string (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are\n\ expanded even when the template string is defined with single quotes.\n\ -@seealso{fprintf, sscanf}\n\ +@seealso{printf, fprintf, sscanf}\n\ @end deftypefn") { static std::string who = "sprintf"; @@ -934,7 +1027,7 @@ See the Formatted Input section of the GNU Octave manual for a\n\ complete description of the syntax of the template string.\n\ @end ifclear\n\ -@seealso{fgets, fgetl, fread, sscanf, fopen}\n\ +@seealso{fgets, fgetl, fread, scanf, sscanf, fopen}\n\ @end deftypefn") { static std::string who = "fscanf"; @@ -997,7 +1090,7 @@ Reaching the end of the string is treated as an end-of-file condition. In\n\ addition to the values returned by @code{fscanf}, the index of the next\n\ character to be read is returned in @var{pos}.\n\ -@seealso{fscanf, sprintf}\n\ +@seealso{fscanf, scanf, sprintf}\n\ @end deftypefn") { static std::string who = "sscanf"; @@ -1045,6 +1138,27 @@ return retval; } +DEFUN (scanf, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size})\n\ +@deftypefnx {} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}]] =} scanf (@var{template}, \"C\")\n\ +This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\ +\n\ +It is currently not useful to call @code{scanf} in interactive programs.\n\ +@seealso{fscanf, sscanf, printf}\n\ +@end deftypefn") +{ + int nargin = args.length (); + + octave_value_list tmp_args (nargin+1, octave_value ()); + + tmp_args (0) = 0.0; + for (int i = 0; i < nargin; i++) + tmp_args(i+1) = args(i); + + return Ffscanf (tmp_args, nargout); +} + static octave_value_list textscan_internal (const std::string& who, const octave_value_list& args) { diff -r dcf8922b724b -r 96518f623c91 libinterp/dldfcn/__init_gnuplot__.cc --- a/libinterp/dldfcn/__init_gnuplot__.cc Wed Apr 20 17:53:10 2016 +0200 +++ b/libinterp/dldfcn/__init_gnuplot__.cc Wed Apr 20 11:06:03 2016 -0700 @@ -151,7 +151,7 @@ octave_value_list args; Matrix fids = pstream.matrix_value (); - Ffprintf (ovl (fids(0), "%s", "\nquit;\n")); + Ffputs (ovl (fids(0), "\nquit;\n")); Ffflush (ovl (fids(0))); Fpclose (ovl (fids(0))); diff -r dcf8922b724b -r 96518f623c91 scripts/@ftp/display.m --- a/scripts/@ftp/display.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/@ftp/display.m Wed Apr 20 11:06:03 2016 -0700 @@ -17,11 +17,11 @@ ## . function display (obj) - fprintf ("FTP Object\n"); - fprintf (" host: %s\n", obj.host); - fprintf (" user: %s\n", obj.username); - fprintf (" dir: %s\n", __ftp_pwd__ (obj.curlhandle)); - fprintf (" mode: %s\n", __ftp_mode__ (obj.curlhandle)); + printf ("FTP Object\n"); + printf (" host: %s\n", obj.host); + printf (" user: %s\n", obj.username); + printf (" dir: %s\n", __ftp_pwd__ (obj.curlhandle)); + printf (" mode: %s\n", __ftp_mode__ (obj.curlhandle)); endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/deprecated/module.mk --- a/scripts/deprecated/module.mk Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/deprecated/module.mk Wed Apr 20 11:06:03 2016 -0700 @@ -20,10 +20,7 @@ scripts/deprecated/octave_config_info.m \ scripts/deprecated/octave_tmp_file_name.m \ scripts/deprecated/playaudio.m \ - scripts/deprecated/printf.m \ - scripts/deprecated/puts.m \ scripts/deprecated/saveaudio.m \ - scripts/deprecated/scanf.m \ scripts/deprecated/setaudio.m \ scripts/deprecated/sleep.m \ scripts/deprecated/syl.m \ diff -r dcf8922b724b -r 96518f623c91 scripts/deprecated/printf.m --- a/scripts/deprecated/printf.m Wed Apr 20 17:53:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -## Copyright (C) 1993-2016 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {} {} fprintf (@var{template}, @dots{}) -## -## @code{printf} is deprecated and will be removed in Octave version 4.6. -## Use @code{fprintf} for the equivalent functionality. -## -## Print optional arguments under the control of the template string -## @var{template} to the stream @code{stdout} and return the number of -## characters printed. -## @ifclear OCTAVE_MANUAL -## -## See the Formatted Output section of the GNU Octave manual for a -## complete description of the syntax of the template string. -## @end ifclear -## -## Implementation Note: For compatibility with @sc{matlab}, escape sequences in -## the template string (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are -## expanded even when the template string is defined with single quotes. -## -## @seealso{fprintf, sprintf, fscanf, sscanf} -## @end deftypefn - -## Deprecated in version 4.2 - -function varargout = printf (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "printf is obsolete and will be removed from a future version of Octave, please use fprintf instead"); - endif - - if (nargin < 1) - print_usage (); - endif - - varargout = fprintf (varargin); - -endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/deprecated/puts.m --- a/scripts/deprecated/puts.m Wed Apr 20 17:53:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -## Copyright (C) 1993-2016 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {} {} puts (@var{string}) -## @deftypefnx {} {@var{numbytes} =} puts (@var{string}) -## -## @code{puts} is deprecated and will be removed in Octave version 4.6. -## Use @code{fputs} for the equivalent functionality. -## -## Write a string to the standard output with no formatting. -## -## The string is written verbatim to the standard output. Use @code{disp} to -## automatically append a newline character appropriate for the local machine. -## -## The optional output returns the number of bytes written to stdout. -## -## @seealso{fputs, disp} -## @end deftypefn - -## Deprecated in version 4.2 - -function numbytes = puts (str) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "puts is obsolete and will be removed from a future version of Octave, please use fputs instead"); - endif - - numbytes = fputs (stdout (), str); - -endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/deprecated/scanf.m --- a/scripts/deprecated/scanf.m Wed Apr 20 17:53:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -## Copyright (C) 1993-2016 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size}) -## @deftypefnx {} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}]] =} scanf (@var{template}, \"C\") -## -## @code{scanf} is deprecated and will be removed in Octave version 4.6. -## Use @code{fscanf (stdin, @dots{})} for the equivalent functionality. -## -## This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}. -## -## It is currently not useful to call @code{scanf} in interactive programs. -## @seealso{fscanf, sscanf, fprintf, sprintf} -## @end deftypefn - -## Deprecated in version 4.2 - -function varargout = scanf (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "scanf is obsolete and will be removed from a future version of Octave, please use fscanf instead"); - endif - - if (nargin < 1) - print_usage (); - endif - - varargout = fscanf (stdin (), varargin); - -endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/general/inputParser.m --- a/scripts/general/inputParser.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/general/inputParser.m Wed Apr 20 11:06:03 2016 -0700 @@ -410,15 +410,15 @@ if (nargin > 1) print_usage (); endif - fprintf ("inputParser object with properties:\n\n"); + printf ("inputParser object with properties:\n\n"); b2s = @(x) ifelse (any (x), "true", "false"); - fprintf ([" CaseSensitive : %s\n FunctionName : %s\n" ... + printf ([" CaseSensitive : %s\n FunctionName : %s\n" ... " KeepUnmatched : %s\n PartialMatching : %s\n" ... " StructExpand : %s\n\n"], b2s (this.CaseSensitive), b2s (this.FunctionName), b2s (this.KeepUnmatched), b2s (this.PartialMatching), b2s (this.StructExpand)); - fprintf ("Defined parameters:\n\n {%s}\n", + printf ("Defined parameters:\n\n {%s}\n", strjoin (this.Parameters, ", ")); endfunction endmethods diff -r dcf8922b724b -r 96518f623c91 scripts/general/methods.m --- a/scripts/general/methods.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/general/methods.m Wed Apr 20 11:06:03 2016 -0700 @@ -62,7 +62,7 @@ if (nargout == 0) classname = ifelse (ischar (obj), obj, class (obj)); - fprintf ("Methods for class %s:\n", classname); + printf ("Methods for class %s:\n", classname); disp (list_in_columns (mtds_list)); else mtds = mtds_list; diff -r dcf8922b724b -r 96518f623c91 scripts/general/profexplore.m --- a/scripts/general/profexplore.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/general/profexplore.m Wed Apr 20 11:06:03 2016 -0700 @@ -68,16 +68,16 @@ while (true) - fprintf ("\n%s", parents); + printf ("\n%s", parents); strings = cell (length (tree), 1); for i = 1 : length (tree) strings{i} = sprintf ("%s: %d calls, %.3f total, %.3f self", ... fcn_table(tree(i).Index).FunctionName, ... tree(i).NumCalls, ... tree(i).TotalTime, tree(i).SelfTime); - fprintf ("%s%d) %s\n", prefix, i, strings{i}); + printf ("%s%d) %s\n", prefix, i, strings{i}); endfor - fprintf ("\n"); + printf ("\n"); cmd = input ("profexplore> ", "s"); option = fix (str2double (cmd)); @@ -86,15 +86,15 @@ rv = 0; return; elseif (strcmp (cmd, "help")) - fprintf ("\nCommands for profile explorer:\n\n"); - fprintf ("exit Return to Octave prompt.\n"); - fprintf ("quit Return to Octave prompt.\n"); - fprintf ("help Display this help message.\n"); - fprintf ("up [N] Go up N levels, where N is an integer. Default is 1.\n"); - fprintf ("N Go down a level into option N.\n"); + printf ("\nCommands for profile explorer:\n\n"); + printf ("exit Return to Octave prompt.\n"); + printf ("quit Return to Octave prompt.\n"); + printf ("help Display this help message.\n"); + printf ("up [N] Go up N levels, where N is an integer. Default is 1.\n"); + printf ("N Go down a level into option N.\n"); elseif (! isnan (option)) if (option < 1 || option > length (tree)) - fprintf ("The chosen option is out of range!\n"); + printf ("The chosen option is out of range!\n"); else newParents = sprintf ("%s%s%s\n", parents, prefix, strings{option}); newPrefix = sprintf ("%s ", prefix); @@ -126,11 +126,11 @@ endif endif - fprintf ("Invalid 'up' command. Type 'help' for further"); - fprintf (" information.\n"); + printf ("Invalid 'up' command. Type 'help' for further"); + printf (" information.\n"); else - fprintf ("Unrecognized input. Type 'help' to get a list of possible"); - fprintf (" commands.\n"); + printf ("Unrecognized input. Type 'help' to get a list of possible"); + printf (" commands.\n"); endif endwhile diff -r dcf8922b724b -r 96518f623c91 scripts/general/profshow.m --- a/scripts/general/profshow.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/general/profshow.m Wed Apr 20 11:06:03 2016 -0700 @@ -76,9 +76,9 @@ headerFormat = sprintf ("%%4s %%%ds %%4s %%12s %%10s %%12s\n", nameLen); rowFormat = sprintf ("%%4d %%%ds %%4s %%12.3f %%10.2f %%12d\n", nameLen); - fprintf (headerFormat, ... + printf (headerFormat, ... "#", "Function", "Attr", "Time (s)", "Time (%)", "Calls"); - fprintf ("%s\n", repmat ("-", 1, nameLen + 2 * 5 + 11 + 2 * 13)); + printf ("%s\n", repmat ("-", 1, nameLen + 2 * 5 + 11 + 2 * 13)); for i = 1 : n row = data.FunctionTable(p(i)); @@ -87,7 +87,7 @@ if (row.IsRecursive) attr = "R"; endif - fprintf (rowFormat, p(i), row.FunctionName, attr, + printf (rowFormat, p(i), row.FunctionName, attr, row.TotalTime, timePercent, row.NumCalls); endfor diff -r dcf8922b724b -r 96518f623c91 scripts/help/help.m --- a/scripts/help/help.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/help/help.m Wed Apr 20 11:06:03 2016 -0700 @@ -64,7 +64,7 @@ For more information visit http://www.octave.org.\n\n"; if (nargout == 0) - fputs (text); + puts (text); else retval = text; endif @@ -74,7 +74,7 @@ if (strcmp (name, "--list")) list = do_list_functions (); if (nargout == 0) - fprintf ("%s", list); + printf ("%s", list); else retval = list; endif @@ -84,7 +84,7 @@ if (strcmp (name, ".")) list = do_list_operators (); if (nargout == 0) - fprintf ("%s", list); + printf ("%s", list); else retval = list; endif @@ -118,7 +118,7 @@ if (nargout == 0) which (name); - fprintf ("\n%s\n%s", text, __additional_help_message__ ()); + printf ("\n%s\n%s", text, __additional_help_message__ ()); else retval = text; endif @@ -189,13 +189,13 @@ if (status != 0) warning ("help: Texinfo formatting filter exited abnormally; raw Texinfo source of help text follows...\n"); endif - fprintf ("%s:\n\n%s\n", fname, text); + printf ("%s:\n\n%s\n", fname, text); endif endfor if (found) - fputs (__additional_help_message__ ()); + puts (__additional_help_message__ ()); else msg = feval (missing_function_hook, name); @@ -216,3 +216,4 @@ %!error help (42) %!error help ("abc", "def") %!error <'_! UNLIKELY_FCN! _' not found> help ("_! UNLIKELY_FCN! _") + diff -r dcf8922b724b -r 96518f623c91 scripts/help/lookfor.m --- a/scripts/help/lookfor.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/help/lookfor.m Wed Apr 20 11:06:03 2016 -0700 @@ -164,14 +164,14 @@ for k = 1:length (fcnlist) f = fcnlist{k}; f(end+1:indent-1) = " "; - fputs ([f " "]); + puts ([f " "]); lf = length (f); desc = strtrim (strrep (help_text{k}, "\n", " ")); ldesc = length (desc); - fprintf ("%s\n", desc(1:min (ldesc, desc_width - (lf - indent)))); + printf ("%s\n", desc(1:min (ldesc, desc_width - (lf - indent)))); for start = (desc_width - (lf - indent) + 1):desc_width:ldesc stop = min (start + desc_width, ldesc); - fprintf ("%s%s\n", indent_space, strtrim (desc (start:stop))); + printf ("%s%s\n", indent_space, strtrim (desc (start:stop))); endfor endfor else @@ -194,3 +194,4 @@ fcns = help_texts = {}; endif endfunction + diff -r dcf8922b724b -r 96518f623c91 scripts/help/which.m --- a/scripts/help/which.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/help/which.m Wed Apr 20 11:06:03 2016 -0700 @@ -46,18 +46,18 @@ if (nargout == 0) for i = 1:nargin if (m(i).is_variable) - fprintf ("'%s' is a variable\n", m(i).name); + printf ("'%s' is a variable\n", m(i).name); elseif (isempty (m(i).file)) if (! isempty (m(i).type)) - fprintf ("'%s' is a %s\n", + printf ("'%s' is a %s\n", m(i).name, m(i).type); endif else if (isempty (m(i).type)) - fprintf ("'%s' is the file %s\n", + printf ("'%s' is the file %s\n", m(i).name, m(i).file); else - fprintf ("'%s' is a %s from the file %s\n", + printf ("'%s' is a %s from the file %s\n", m(i).name, m(i).type, m(i).file); endif endif diff -r dcf8922b724b -r 96518f623c91 scripts/image/imformats.m --- a/scripts/image/imformats.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/image/imformats.m Wed Apr 20 11:06:03 2016 -0700 @@ -311,7 +311,7 @@ descriptions = {formats.description}; table = cat (2, extensions(:), yes_no_cols, descriptions(:)); - fprintf ([template "\n"], table'{:}); + printf ([template "\n"], table'{:}); endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/io/beep.m --- a/scripts/io/beep.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/io/beep.m Wed Apr 20 11:06:03 2016 -0700 @@ -23,7 +23,7 @@ ## This function sends the alarm character @qcode{"@xbackslashchar{}a"} to ## the terminal. Depending on the user's configuration this may produce an ## audible beep, a visual bell, or nothing at all. -## @seealso{fputs, fprintf} +## @seealso{puts, fputs, printf, fprintf} ## @end deftypefn ## Author: jwe @@ -34,9 +34,10 @@ print_usage (); endif - fputs ("\a"); + puts ("\a"); endfunction %!error (beep (1)) + diff -r dcf8922b724b -r 96518f623c91 scripts/io/fputs.m --- a/scripts/io/fputs.m Wed Apr 20 17:53:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -## Copyright (C) 1993-2016 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {} {} fputs (@var{string}) -## @deftypefnx {} {} fputs (@var{fid}, @var{string}) -## @deftypefnx {} {@var{numbytes} =} fputs (@dots{}) -## -## Write the string @var{string} to the file with file descriptor @var{fid}. -## If the file descriptor @var{fid} is ommited, the string is written to -## stdout. -## -## The string is written to the file with no additional formatting. Use -## @code{fprintf} for formatting the output string. -## -## The optional output returns the number of bytes written to @var{fid} or -## stdout, respectively. -## -## Examples: -## -## Printing the string @samp{Some text} directly to stdout. -## @example -## @group -## fputs ("Some text"); -## @end group -## @end example -## -## The following example shows how to write the string -## @samp{Free Software is needed for Free Science} to the file -## @samp{free.txt}. -## -## @example -## @group -## filename = "free.txt"; -## fid = fopen (filename, "w"); -## fputs (fid, "Free Software is needed for Free Science"); -## fclose (fid); -## @end group -## @end example -## -## @seealso{fprintf, fwrite, fopen, stdout} -## @end deftypefn - -function numbytes = fputs (varargin) - - narginchk (1, 2); - - fid = stdout (); - str = varargin{1}; - if (nargin == 2) - fid = varargin{1}; - str = varargin{2}; - endif - - numbytes = fprintf (fid, "%s", str); - -endfunction - -%!assert (fputs (1, 1), 1) -%!error fputs () -%!error fputs (1, "foo", 3) diff -r dcf8922b724b -r 96518f623c91 scripts/io/module.mk --- a/scripts/io/module.mk Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/io/module.mk Wed Apr 20 11:06:03 2016 -0700 @@ -6,7 +6,6 @@ scripts/io/csvwrite.m \ scripts/io/dlmwrite.m \ scripts/io/fileread.m \ - scripts/io/fputs.m \ scripts/io/importdata.m \ scripts/io/is_valid_file_id.m \ scripts/io/strread.m \ diff -r dcf8922b724b -r 96518f623c91 scripts/io/textread.m --- a/scripts/io/textread.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/io/textread.m Wed Apr 20 11:06:03 2016 -0700 @@ -127,7 +127,7 @@ nlines = Inf; endif if (nlines < 1) - fprintf ("textread: N = 0, no data read\n"); + printf ("textread: N = 0, no data read\n"); varargout = cell (1, nargout); return; endif diff -r dcf8922b724b -r 96518f623c91 scripts/java/javaclasspath.m --- a/scripts/java/javaclasspath.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/java/javaclasspath.m Wed Apr 20 11:06:03 2016 -0700 @@ -113,11 +113,11 @@ ## Display cell array of paths function disp_path_list (which, path_list) - fprintf (" %s JAVA PATH\n\n", which); + printf (" %s JAVA PATH\n\n", which); if (numel (path_list) > 0) - fprintf (" %s\n", path_list{:}); + printf (" %s\n", path_list{:}); else - fprintf (" - empty -\n"); + printf (" - empty -\n"); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/java/javamem.m --- a/scripts/java/javamem.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/java/javamem.m Wed Apr 20 11:06:03 2016 -0700 @@ -73,16 +73,16 @@ jvmem{3} = rt.freeMemory (); if (nargout == 0) - fprintf ("\nJava virtual machine (JVM) memory info:\n"); - fprintf ("Maximum available memory: %5d MiB;\n", + printf ("\nJava virtual machine (JVM) memory info:\n"); + printf ("Maximum available memory: %5d MiB;\n", jvmem{1} / 1024 / 1024); - fprintf (" (...running garbage collector...)\n"); - fprintf ("OK, current status:\n"); - fprintf ("Total memory in virtual machine: %5d MiB;\n", + printf (" (...running garbage collector...)\n"); + printf ("OK, current status:\n"); + printf ("Total memory in virtual machine: %5d MiB;\n", jvmem{2} / 1024 / 1024); - fprintf ("Free memory in virtual machine: %5d MiB;\n", + printf ("Free memory in virtual machine: %5d MiB;\n", jvmem{3} / 1024 / 1024); - fprintf ("%d CPUs available.\n", rt.availableProcessors ()); + printf ("%d CPUs available.\n", rt.availableProcessors ()); else jmem = jvmem; endif diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/dir.m --- a/scripts/miscellaneous/dir.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/dir.m Wed Apr 20 11:06:03 2016 -0700 @@ -148,7 +148,7 @@ retval = info; elseif (numel (info) > 0) ## Print the structure to the screen. - fprintf ("%s", list_in_columns ({info.name})); + printf ("%s", list_in_columns ({info.name})); else warning ("dir: nonexistent directory '%s'", directory); endif diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/dos.m --- a/scripts/miscellaneous/dos.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/dos.m Wed Apr 20 11:06:03 2016 -0700 @@ -42,7 +42,7 @@ elseif (! isunix ()) [status, text] = system (command); if (nargin > 1 || nargout == 0) - fprintf ("%s\n", text); + printf ("%s\n", text); endif endif diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/fact.m --- a/scripts/miscellaneous/fact.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/fact.m Wed Apr 20 11:06:03 2016 -0700 @@ -262,7 +262,7 @@ truth = w; else w = wordwrap (w); - fprintf ("%s", w); + printf ("%s", w); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/info.m --- a/scripts/miscellaneous/info.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/info.m Wed Apr 20 11:06:03 2016 -0700 @@ -23,7 +23,7 @@ function info () - fprintf ("\n\ + printf ("\n\ Additional information about GNU Octave is available at\n\ http://www.octave.org\n\ \n\ diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/license.m --- a/scripts/miscellaneous/license.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/license.m Wed Apr 20 11:06:03 2016 -0700 @@ -88,7 +88,7 @@ features = features(strcmp (features, feature)); endif if (nargout == 0) - fprintf ("%s\n", features{:}); + printf ("%s\n", features{:}); else retval = struct ("feature", features, "user", get_username ()); endif diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/ls.m --- a/scripts/miscellaneous/ls.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/ls.m Wed Apr 20 11:06:03 2016 -0700 @@ -98,7 +98,7 @@ if (status != 0) error ("ls: command exited abnormally with status %d\n", status); elseif (nargout == 0) - fputs (output); + puts (output); else retval = strvcat (regexp (output, "[\r\n]+", "split"){:}); endif @@ -131,3 +131,4 @@ %!error ls (1) ## Test below is valid, but produces confusing output on screen %!#error ls ("-!") + diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/menu.m --- a/scripts/miscellaneous/menu.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/menu.m Wed Apr 20 11:06:03 2016 -0700 @@ -70,19 +70,19 @@ page_screen_output (0, "local"); if (! isempty (title)) - fprintf ("%s\n", title); + printf ("%s\n", title); endif nopt = numel (varargin); while (1) for i = 1:nopt - fprintf (" [%2d] %s\n", i, varargin{i}); + printf (" [%2d] %s\n", i, varargin{i}); endfor - fprintf ("\n"); + printf ("\n"); s = input ("Select a number: ", "s"); choice = sscanf (s, "%d"); if (! isscalar (choice) || choice < 1 || choice > nopt) - fprintf ("\nerror: input invalid or out of range\n\n"); + printf ("\nerror: input invalid or out of range\n\n"); choice = 0; else break; diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/mkoctfile.m --- a/scripts/miscellaneous/mkoctfile.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/mkoctfile.m Wed Apr 20 11:06:03 2016 -0700 @@ -164,7 +164,7 @@ if (nargout > 0) [output, status] = deal (out, sys); else - fprintf ("%s", out); + printf ("%s", out); endif if (sys != 0) diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/private/display_info_file.m --- a/scripts/miscellaneous/private/display_info_file.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/private/display_info_file.m Wed Apr 20 11:06:03 2016 -0700 @@ -48,8 +48,9 @@ fid = fopen (filepath, "r"); while (ischar (line = fgets (fid))) - fputs (line); + puts (line); endwhile fclose (fid); endfunction + diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/unix.m --- a/scripts/miscellaneous/unix.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/unix.m Wed Apr 20 11:06:03 2016 -0700 @@ -42,7 +42,7 @@ elseif (isunix ()) [status, text] = system (command); if (nargin > 1 || nargout == 0) - fprintf ("%s\n", text); + printf ("%s\n", text); endif endif diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/ver.m --- a/scripts/miscellaneous/ver.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/ver.m Wed Apr 20 11:06:03 2016 -0700 @@ -75,7 +75,7 @@ ["Operating System: " os_string] hbar}; - fprintf ("%s\n", desc{:}); + printf ("%s\n", desc{:}); if (isempty (package)) pkg ("list"); diff -r dcf8922b724b -r 96518f623c91 scripts/miscellaneous/what.m --- a/scripts/miscellaneous/what.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/miscellaneous/what.m Wed Apr 20 11:06:03 2016 -0700 @@ -137,7 +137,7 @@ function __display_filenames__ (msg, p, f) if (length (f) > 0) - fprintf ("%s %s:\n\n", msg, p); + printf ("%s %s:\n\n", msg, p); maxlen = max (cellfun ("length", f)); ncols = max (1, floor (terminal_size ()(2) / (maxlen + 3))); @@ -151,7 +151,7 @@ if (length (args) < ncols) args(end+1 : ncols) = {""}; endif - fprintf (fmt, args{:}); + printf (fmt, args{:}); endfor endif diff -r dcf8922b724b -r 96518f623c91 scripts/ode/ode23.m --- a/scripts/ode/ode23.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/ode/ode23.m Wed Apr 20 11:06:03 2016 -0700 @@ -361,9 +361,9 @@ nlinsols = 0; # no. of solutions of linear systems ## Print cost statistics if no output argument is given if (nargout == 0) - fprintf ("Number of successful steps: %d\n", nsteps); - fprintf ("Number of failed attempts: %d\n", nfailed); - fprintf ("Number of function calls: %d\n", nfevals); + printf ("Number of successful steps: %d\n", nsteps); + printf ("Number of failed attempts: %d\n", nfailed); + printf ("Number of function calls: %d\n", nfevals); endif else havestats = false; diff -r dcf8922b724b -r 96518f623c91 scripts/ode/ode45.m --- a/scripts/ode/ode45.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/ode/ode45.m Wed Apr 20 11:06:03 2016 -0700 @@ -346,9 +346,9 @@ nlinsols = 0; # no. of linear systems solutions ## Print cost statistics if no output argument is given if (nargout == 0) - fprintf ("Number of successful steps: %d\n", nsteps); - fprintf ("Number of failed attempts: %d\n", nfailed); - fprintf ("Number of function calls: %d\n", nfevals); + printf ("Number of successful steps: %d\n", nsteps); + printf ("Number of failed attempts: %d\n", nfailed); + printf ("Number of function calls: %d\n", nfevals); endif else havestats = false; diff -r dcf8922b724b -r 96518f623c91 scripts/optimization/fminbnd.m --- a/scripts/optimization/fminbnd.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/optimization/fminbnd.m Wed Apr 20 11:06:03 2016 -0700 @@ -260,32 +260,32 @@ ## A hack for printing a formatted table function print_formatted_table (table) - fprintf ("\n Func-count x f(x) Procedure\n"); + printf ("\n Func-count x f(x) Procedure\n"); for row=table - fprintf("%5.5s %7.7s %8.8s\t%s\n", + printf("%5.5s %7.7s %8.8s\t%s\n", int2str (row.funccount), num2str (row.x,"%.5f"), num2str (row.fx,"%.6f"), row.procedure); endfor - fprintf ("\n"); + printf ("\n"); endfunction ## Print either a success termination message or bad news function print_exit_msg (info, opt=struct()) - fprintf (""); + printf (""); switch (info) case 1 - fprintf ("Optimization terminated:\n"); - fprintf (" the current x satisfies the termination criteria using OPTIONS.TolX of %e\n", opt.TolX); + printf ("Optimization terminated:\n"); + printf (" the current x satisfies the termination criteria using OPTIONS.TolX of %e\n", opt.TolX); case 0 - fprintf ("Exiting: Maximum number of iterations has been exceeded\n"); - fprintf (" - increase MaxIter option.\n"); - fprintf (" Current function value: %.6f\n", opt.fx); + printf ("Exiting: Maximum number of iterations has been exceeded\n"); + printf (" - increase MaxIter option.\n"); + printf (" Current function value: %.6f\n", opt.fx); case -1 "FIXME"; # FIXME: what's the message MATLAB prints for this case? otherwise error ("fminbnd: internal error, info return code was %d", info); endswitch - fprintf ("\n"); + printf ("\n"); endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/optimization/optimset.m --- a/scripts/optimization/optimset.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/optimization/optimset.m Wed Apr 20 11:06:03 2016 -0700 @@ -122,9 +122,9 @@ if (nargs == 0) if (nargout == 0) ## Display possibilities. - fputs ("\nAll possible optimization options:\n\n"); - fprintf (" %s\n", opts{:}); - fputs ("\n"); + puts ("\nAll possible optimization options:\n\n"); + printf (" %s\n", opts{:}); + puts ("\n"); else ## Return struct with all options initialized to [] retval = cell2struct (repmat ({[]}, size (opts)), opts, 2); @@ -189,3 +189,4 @@ %!error optimset ("%NOT_A_REAL_FUNCTION_NAME%") %!warning optimset ("foobar", 13); %!warning optimset ("Max", 10); + diff -r dcf8922b724b -r 96518f623c91 scripts/optimization/sqp.m --- a/scripts/optimization/sqp.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/optimization/sqp.m Wed Apr 20 11:06:03 2016 -0700 @@ -721,9 +721,9 @@ function report (iter, qp_iter, alpha, nfun, obj) if (nargin == 0) - fprintf (" Itn ItQP Step Nfun Objective\n"); + printf (" Itn ItQP Step Nfun Objective\n"); else - fprintf ("%5d %4d %8.1g %5d %13.6e\n", iter, qp_iter, alpha, nfun, obj); + printf ("%5d %4d %8.1g %5d %13.6e\n", iter, qp_iter, alpha, nfun, obj); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/pkg/pkg.m Wed Apr 20 11:06:03 2016 -0700 @@ -421,8 +421,8 @@ case "prefix" if (isempty (files) && ! nargout) - fprintf ("Installation prefix: %s\n", prefix); - fprintf ("Architecture dependent prefix: %s\n", archprefix); + printf ("Installation prefix: %s\n", prefix); + printf ("Architecture dependent prefix: %s\n", archprefix); elseif (isempty (files) && nargout) local_packages = prefix; global_packages = archprefix; diff -r dcf8922b724b -r 96518f623c91 scripts/pkg/private/describe.m --- a/scripts/pkg/private/describe.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/pkg/private/describe.m Wed Apr 20 11:06:03 2016 -0700 @@ -140,17 +140,17 @@ function print_package_description (pkg_name, pkg_ver, pkg_idx_struct, pkg_desc, status, verbose) - fprintf ("---\nPackage name:\n\t%s\n", pkg_name); - fprintf ("Version:\n\t%s\n", pkg_ver); - fprintf ("Short description:\n\t%s\n", pkg_desc); - fprintf ("Status:\n\t%s\n", status); + printf ("---\nPackage name:\n\t%s\n", pkg_name); + printf ("Version:\n\t%s\n", pkg_ver); + printf ("Short description:\n\t%s\n", pkg_desc); + printf ("Status:\n\t%s\n", status); if (verbose) - fprintf ("---\nProvides:\n"); + printf ("---\nProvides:\n"); for i = 1:length (pkg_idx_struct) if (! isempty (pkg_idx_struct{i}.functions)) - fprintf ("%s\n", pkg_idx_struct{i}.category); + printf ("%s\n", pkg_idx_struct{i}.category); for j = 1:length (pkg_idx_struct{i}.functions) - fprintf ("\t%s\n", pkg_idx_struct{i}.functions{j}); + printf ("\t%s\n", pkg_idx_struct{i}.functions{j}); endfor endif endfor diff -r dcf8922b724b -r 96518f623c91 scripts/pkg/private/install.m --- a/scripts/pkg/private/install.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/pkg/private/install.m Wed Apr 20 11:06:03 2016 -0700 @@ -67,7 +67,7 @@ tmpdir = tempname (); tmpdirs{end+1} = tmpdir; if (verbose) - fprintf ("mkdir (%s)\n", tmpdir); + printf ("mkdir (%s)\n", tmpdir); endif [status, msg] = mkdir (tmpdir); if (status != 1) @@ -76,7 +76,7 @@ ## Uncompress the package. if (verbose) - fprintf ("untar (%s, %s)\n", tgz, tmpdir); + printf ("untar (%s, %s)\n", tgz, tmpdir); endif untar (tgz, tmpdir); @@ -276,9 +276,9 @@ rmdir (descriptions{i}.dir, "s"); endfor if (global_install) - fprintf ("error: couldn't append to %s\n", global_list); + printf ("error: couldn't append to %s\n", global_list); else - fprintf ("error: couldn't append to %s\n", local_list); + printf ("error: couldn't append to %s\n", local_list); endif rethrow (lasterror ()); end_try_catch @@ -296,7 +296,7 @@ ## without creating it such as giving an invalid filename for the package if (exist ("desc", "var") && exist (fullfile (desc.dir, "packinfo", "NEWS"), "file")) - fprintf ("For information about changes from previous versions of the %s package, run 'news %s'.\n", + printf ("For information about changes from previous versions of the %s package, run 'news %s'.\n", desc.name, desc.name); endif endfunction @@ -419,9 +419,9 @@ endif if (! all (isspace ([archindependent{:}]))) if (verbose) - fprintf ("copyfile"); - fprintf (" %s", archindependent{:}); - fprintf ("%s\n", instdir); + printf ("copyfile"); + printf (" %s", archindependent{:}); + printf ("%s\n", instdir); endif [status, output] = copyfile (archindependent, instdir); if (status != 1) @@ -431,9 +431,9 @@ endif if (! all (isspace ([archdependent{:}]))) if (verbose) - fprintf ("copyfile"); - fprintf (" %s", archdependent{:}); - fprintf (" %s\n", archdir); + printf ("copyfile"); + printf (" %s", archdependent{:}); + printf (" %s\n", archdir); endif if (! exist (archdir, "dir")) mkdir (archdir); diff -r dcf8922b724b -r 96518f623c91 scripts/pkg/private/installed_packages.m --- a/scripts/pkg/private/installed_packages.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/pkg/private/installed_packages.m Wed Apr 20 11:06:03 2016 -0700 @@ -93,9 +93,9 @@ num_packages = numel (installed_pkgs_lst); if (num_packages == 0) if (isempty (pkgname)) - fprintf ("no packages installed.\n"); + printf ("no packages installed.\n"); else - fprintf ("package %s is not installed.\n", pkgname{1}); + printf ("package %s is not installed.\n", pkgname{1}); endif return; endif @@ -118,11 +118,11 @@ ## Print a header. header = sprintf ("%s | %s | %s\n", h1, h2, h3); - fprintf (header); + printf (header); tmp = sprintf (repmat ("-", 1, length (header) - 1)); tmp(length(h1)+2) = "+"; tmp(length(h1)+length(h2)+5) = "+"; - fprintf ("%s\n", tmp); + printf ("%s\n", tmp); ## Print the packages. format = sprintf ("%%%ds %%1s| %%%ds | %%s\n", @@ -145,7 +145,7 @@ else cur_loaded = " "; endif - fprintf (format, cur_name, cur_loaded, cur_version, cur_dir); + printf (format, cur_name, cur_loaded, cur_version, cur_dir); endfor endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/pkg/private/list_forge_packages.m --- a/scripts/pkg/private/list_forge_packages.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/pkg/private/list_forge_packages.m Wed Apr 20 11:06:03 2016 -0700 @@ -31,14 +31,15 @@ endif if (nargout == 0) page_screen_output (false, "local"); - fputs ("OctaveForge provides these packages:\n"); + puts ("OctaveForge provides these packages:\n"); for i = 1:length (list) try ver = get_forge_pkg (list{i}); catch ver = "unknown"; end_try_catch - fprintf (" %s %s\n", list{i}, ver); + printf (" %s %s\n", list{i}, ver); endfor endif endfunction + diff -r dcf8922b724b -r 96518f623c91 scripts/pkg/private/rebuild.m --- a/scripts/pkg/private/rebuild.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/pkg/private/rebuild.m Wed Apr 20 11:06:03 2016 -0700 @@ -44,7 +44,7 @@ for k = 1:length (dirlist) descfile = fullfile (prefix, dirlist{k}, "packinfo", "DESCRIPTION"); if (verbose) - fprintf ("recreating package description from %s\n", dirlist{k}); + printf ("recreating package description from %s\n", dirlist{k}); endif if (exist (descfile, "file")) desc = get_description (descfile); diff -r dcf8922b724b -r 96518f623c91 scripts/plot/util/__gnuplot_drawnow__.m --- a/scripts/plot/util/__gnuplot_drawnow__.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/plot/util/__gnuplot_drawnow__.m Wed Apr 20 11:06:03 2016 -0700 @@ -98,7 +98,7 @@ if (a(1) == 12) a = a(2:end); # avoid ^L at the beginning endif - fputs (a); + puts (a); endif unlink (dumb_tmp_file); endif @@ -414,3 +414,4 @@ ## No test needed for internal helper function. %!assert (1) + diff -r dcf8922b724b -r 96518f623c91 scripts/signal/stft.m --- a/scripts/signal/stft.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/signal/stft.m Wed Apr 20 11:06:03 2016 -0700 @@ -85,7 +85,7 @@ ncoef = 2 * num_coef; if (win_size > ncoef) win_size = ncoef; - fprintf ("stft: window size adjusted to %f\n", win_size); + printf ("stft: window size adjusted to %f\n", win_size); endif num_win = fix ((rows (x) - win_size) / inc); diff -r dcf8922b724b -r 96518f623c91 scripts/sparse/bicg.m --- a/scripts/sparse/bicg.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/sparse/bicg.m Wed Apr 20 11:06:03 2016 -0700 @@ -178,19 +178,19 @@ if (res1 < tol) flag = 0; if (nargout < 2) - fprintf ("bicg converged at iteration %i ", k); - fprintf ("to a solution with relative residual %e\n", res1); + printf ("bicg converged at iteration %i ", k); + printf ("to a solution with relative residual %e\n", res1); endif break; endif if (res0 <= res1) flag = 3; - fprintf ("bicg stopped at iteration %i ", k); - fprintf ("without converging to the desired tolerance %e\n", tol); - fprintf ("because the method stagnated.\n"); - fprintf ("The iterate returned (number %i) ", k-1); - fprintf ("has relative residual %e\n", res0); + printf ("bicg stopped at iteration %i ", k); + printf ("without converging to the desired tolerance %e\n", tol); + printf ("because the method stagnated.\n"); + printf ("The iterate returned (number %i) ", k-1); + printf ("has relative residual %e\n", res0); break endif res0 = res1; @@ -201,17 +201,17 @@ if (k == maxit) flag = 1; - fprintf ("bicg stopped at iteration %i ", maxit); - fprintf ("without converging to the desired tolerance %e\n", tol); - fprintf ("because the maximum number of iterations was reached. "); - fprintf ("The iterate returned (number %i) has ", maxit); - fprintf ("relative residual %e\n", res1); + printf ("bicg stopped at iteration %i ", maxit); + printf ("without converging to the desired tolerance %e\n", tol); + printf ("because the maximum number of iterations was reached. "); + printf ("The iterate returned (number %i) has ", maxit); + printf ("relative residual %e\n", res1); endif else flag = 0; if (nargout < 2) - fprintf ("bicg converged after 0 interations\n"); + printf ("bicg converged after 0 interations\n"); endif endif diff -r dcf8922b724b -r 96518f623c91 scripts/sparse/bicgstab.m --- a/scripts/sparse/bicgstab.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/sparse/bicgstab.m Wed Apr 20 11:06:03 2016 -0700 @@ -180,20 +180,20 @@ if (nargout < 2) if (flag == 0) - fprintf ("bicgstab converged at iteration %i ", iter); - fprintf ("to a solution with relative residual %e\n", relres); + printf ("bicgstab converged at iteration %i ", iter); + printf ("to a solution with relative residual %e\n", relres); elseif (flag == 3) - fprintf ("bicgstab stopped at iteration %i ", iter); - fprintf ("without converging to the desired tolerance %e\n", tol); - fprintf ("because the method stagnated.\n"); - fprintf ("The iterate returned (number %i) ", iter); - fprintf ("has relative residual %e\n", relres); + printf ("bicgstab stopped at iteration %i ", iter); + printf ("without converging to the desired tolerance %e\n", tol); + printf ("because the method stagnated.\n"); + printf ("The iterate returned (number %i) ", iter); + printf ("has relative residual %e\n", relres); else - fprintf ("bicgstab stopped at iteration %i ", iter); - fprintf ("without converging to the desired toleranc %e\n", tol); - fprintf ("because the maximum number of iterations was reached.\n"); - fprintf ("The iterate returned (number %i) ", iter); - fprintf ("has relative residual %e\n", relres); + printf ("bicgstab stopped at iteration %i ", iter); + printf ("without converging to the desired toleranc %e\n", tol); + printf ("because the maximum number of iterations was reached.\n"); + printf ("The iterate returned (number %i) ", iter); + printf ("has relative residual %e\n", relres); endif endif diff -r dcf8922b724b -r 96518f623c91 scripts/sparse/cgs.m --- a/scripts/sparse/cgs.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/sparse/cgs.m Wed Apr 20 11:06:03 2016 -0700 @@ -165,15 +165,15 @@ if (nargout < 1) if (flag == 0) - fprintf ("cgs converged at iteration %i to a solution with relative residual %e\n", + printf ("cgs converged at iteration %i to a solution with relative residual %e\n", iter, relres); elseif (flag == 3) - fprintf (["cgs stopped at iteration %i without converging to the desired tolerance %e\n", + printf (["cgs stopped at iteration %i without converging to the desired tolerance %e\n", "because the method stagnated.\n", "The iterate returned (number %i) has relative residual %e\n"], iter, tol, iter, relres); else - fprintf (["cgs stopped at iteration %i without converging to the desired tolerance %e\n", + printf (["cgs stopped at iteration %i without converging to the desired tolerance %e\n", "because the maximum number of iterations was reached.\n", "The iterate returned (number %i) has relative residual %e\n"], iter, tol, iter, relres); diff -r dcf8922b724b -r 96518f623c91 scripts/sparse/pcg.m --- a/scripts/sparse/pcg.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/sparse/pcg.m Wed Apr 20 11:06:03 2016 -0700 @@ -395,7 +395,7 @@ %! A = diag ([1:N]); b = rand (N, 1); %! y = A \ b; # y is the true solution %! x = pcg (A, b); -%! fprintf ("The solution relative error is %g\n", norm (x - y) / norm (y)); +%! printf ("The solution relative error is %g\n", norm (x - y) / norm (y)); %! %! ## You shouldn't be afraid if pcg issues some warning messages in this %! ## example: watch out in the second example, why it takes N iterations @@ -409,7 +409,7 @@ %! A = diag ([1:N]); b = rand (N, 1); %! X = A \ b; # X is the true solution %! [x, flag, relres, iter, resvec] = pcg (A, b); -%! fprintf ("The solution relative error is %g\n", norm (x - X) / norm (X)); +%! printf ("The solution relative error is %g\n", norm (x - X) / norm (X)); %! title ("Convergence history"); %! semilogy ([0:iter], resvec / resvec(1), "o-g"); %! xlabel ("Iteration"); ylabel ("log(||b-Ax||/||b||)"); @@ -423,9 +423,9 @@ %! A = hilb (N); b = rand (N, 1); %! X = A \ b; # X is the true solution %! [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], 200); -%! fprintf ("The solution relative error is %g\n", norm (x - X) / norm (X)); -%! fprintf ("Condition number estimate is %g\n", eigest(2) / eigest(1)); -%! fprintf ("Actual condition number is %g\n", cond (A)); +%! printf ("The solution relative error is %g\n", norm (x - X) / norm (X)); +%! printf ("Condition number estimate is %g\n", eigest(2) / eigest(1)); +%! printf ("Actual condition number is %g\n", cond (A)); %! title ("Convergence history"); %! semilogy ([0:iter], resvec, ["o-g";"+-r"]); %! xlabel ("Iteration"); ylabel ("log(||b-Ax||)"); @@ -446,11 +446,11 @@ %! b = rand (N, 1); %! X = A \ b; # X is the true solution %! maxit = 80; -%! fprintf ("System condition number is %g\n", cond (A)); +%! printf ("System condition number is %g\n", cond (A)); %! ## No preconditioner: the convergence is very slow! %! %! [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit); -%! fprintf ("System condition number estimate is %g\n", eigest(2) / eigest(1)); +%! printf ("System condition number estimate is %g\n", eigest(2) / eigest(1)); %! title ("Convergence history"); %! semilogy ([0:iter], resvec(:,1), "o-g"); %! xlabel ("Iteration"); ylabel ("log(||b-Ax||)"); @@ -461,7 +461,7 @@ %! %! M = diag (diag (A)); # Jacobi preconditioner %! [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit, M); -%! fprintf ("JACOBI preconditioned system condition number estimate is %g\n", eigest(2) / eigest(1)); +%! printf ("JACOBI preconditioned system condition number estimate is %g\n", eigest(2) / eigest(1)); %! hold on; %! semilogy ([0:iter], resvec(:,1), "o-r"); %! legend ("NO preconditioning: absolute residual", ... @@ -475,7 +475,7 @@ %! M(i:i+k-1, i:i+k-1) = A(i:i+k-1, i:i+k-1); %! endfor %! [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit, M); -%! fprintf ("BLOCK JACOBI preconditioned system condition number estimate is %g\n", eigest(2) / eigest(1)); +%! printf ("BLOCK JACOBI preconditioned system condition number estimate is %g\n", eigest(2) / eigest(1)); %! semilogy ([0:iter], resvec(:,1), "o-b"); %! legend ("NO preconditioning: absolute residual", ... %! "JACOBI preconditioner: absolute residual", ... diff -r dcf8922b724b -r 96518f623c91 scripts/sparse/pcr.m --- a/scripts/sparse/pcr.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/sparse/pcr.m Wed Apr 20 11:06:03 2016 -0700 @@ -312,7 +312,7 @@ %! A = diag (linspace (-3.1,3,N)); b = rand (N,1); %! y = A \ b; # y is the true solution %! x = pcr (A,b); -%! fprintf ("The solution relative error is %g\n", norm (x-y) / norm (y)); +%! printf ("The solution relative error is %g\n", norm (x-y) / norm (y)); %! %! ## You shouldn't be afraid if PCR issues some warning messages in this %! ## example: watch out in the second example, why it takes N iterations @@ -326,7 +326,7 @@ %! A = diag (linspace (-3.1,30,N)); b = rand (N,1); %! X = A \ b; # X is the true solution %! [x, flag, relres, iter, resvec] = pcr (A,b); -%! fprintf ("The solution relative error is %g\n", norm (x-X) / norm (X)); +%! printf ("The solution relative error is %g\n", norm (x-X) / norm (X)); %! clf; %! title ("Convergence history"); %! xlabel ("Iteration"); ylabel ("log(||b-Ax||/||b||)"); @@ -342,10 +342,10 @@ %! N = 10; %! A = hilb (N); A(1,1) = -A(1,1); b = rand (N,1); %! X = A \ b; # X is the true solution -%! fprintf ("Condition number of A is %g\n", cond (A)); +%! printf ("Condition number of A is %g\n", cond (A)); %! [x, flag, relres, iter, resvec] = pcr (A,b,[],200); %! if (flag == 3) -%! fprintf ("PCR breakdown. System matrix is [close to] singular\n"); +%! printf ("PCR breakdown. System matrix is [close to] singular\n"); %! end %! clf; %! title ("Convergence history"); @@ -371,7 +371,7 @@ %! b = rand (2*N,1); %! X = A \ b; # X is the true solution %! maxit = 80; -%! fprintf ("System condition number is %g\n", cond (A)); +%! printf ("System condition number is %g\n", cond (A)); %! ## No preconditioner: the convergence is very slow! %! %! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit); diff -r dcf8922b724b -r 96518f623c91 scripts/sparse/qmr.m --- a/scripts/sparse/qmr.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/sparse/qmr.m Wed Apr 20 11:06:03 2016 -0700 @@ -242,23 +242,23 @@ relres = res1; if (flag == 1) if (nargout < 2) - fprintf ("qmr stopped at iteration %i ", iter); - fprintf ("without converging to the desired tolerance %e\n", tol); - fprintf ("because the maximum number of iterations was reached. "); - fprintf ("The iterate returned (number %i) has ", maxit); - fprintf ("relative residual %e\n", res1); + printf ("qmr stopped at iteration %i ", iter); + printf ("without converging to the desired tolerance %e\n", tol); + printf ("because the maximum number of iterations was reached. "); + printf ("The iterate returned (number %i) has ", maxit); + printf ("relative residual %e\n", res1); endif elseif (flag == 3) if (nargout < 2) - fprintf ("qmr stopped at iteration %i ", iter); - fprintf (" without converging to the desired tolerance %e\n", tol); - fprintf ("because the method stagnated.\n"); - fprintf ("The iterate returned (number %i) ", iter); - fprintf ("has relative residual %e\n", res1); + printf ("qmr stopped at iteration %i ", iter); + printf (" without converging to the desired tolerance %e\n", tol); + printf ("because the method stagnated.\n"); + printf ("The iterate returned (number %i) ", iter); + printf ("has relative residual %e\n", res1); endif elseif (nargout < 2) - fprintf ("qmr converged at iteration %i ", iter); - fprintf ("to a solution with relative residual %e\n", res1); + printf ("qmr converged at iteration %i ", iter); + printf ("to a solution with relative residual %e\n", res1); endif else print usage(); diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/models/logistic_regression.m --- a/scripts/statistics/models/logistic_regression.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/models/logistic_regression.m Wed Apr 20 11:06:03 2016 -0700 @@ -161,21 +161,21 @@ beta = tb((nz + 1) : (nz + nx), 1); if (print >= 1) - fprintf ("\n"); - fprintf ("Logistic Regression Results:\n"); - fprintf ("\n"); - fprintf ("Number of Iterations: %d\n", iter); - fprintf ("Deviance: %f\n", dev); - fprintf ("Parameter Estimates:\n"); - fprintf (" Theta S.E.\n"); + printf ("\n"); + printf ("Logistic Regression Results:\n"); + printf ("\n"); + printf ("Number of Iterations: %d\n", iter); + printf ("Deviance: %f\n", dev); + printf ("Parameter Estimates:\n"); + printf (" Theta S.E.\n"); se = sqrt (diag (inv (-d2l))); for i = 1 : nz - fprintf (" %8.4f %8.4f\n", tb (i), se (i)); + printf (" %8.4f %8.4f\n", tb (i), se (i)); endfor if (nx > 0) - fprintf (" Beta S.E.\n"); + printf (" Beta S.E.\n"); for i = (nz + 1) : (nz + nx) - fprintf (" %8.4f %8.4f\n", tb (i), se (i)); + printf (" %8.4f %8.4f\n", tb (i), se (i)); endfor endif endif diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/anova.m --- a/scripts/statistics/tests/anova.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/anova.m Wed Apr 20 11:06:03 2016 -0700 @@ -93,19 +93,19 @@ if (nargout == 0) ## This eventually needs to be done more cleanly ... - fprintf ("\n"); - fprintf ("One-way ANOVA Table:\n"); - fprintf ("\n"); - fprintf ("Source of Variation Sum of Squares df Empirical Var\n"); - fprintf ("*********************************************************\n"); - fprintf ("Between Groups %15.4f %4d %13.4f\n", SSB, df_b, v_b); - fprintf ("Within Groups %15.4f %4d %13.4f\n", SSW, df_w, v_w); - fprintf ("---------------------------------------------------------\n"); - fprintf ("Total %15.4f %4d\n", SST, n - 1); - fprintf ("\n"); - fprintf ("Test Statistic f %15.4f\n", f); - fprintf ("p-value %15.4f\n", pval); - fprintf ("\n"); + printf ("\n"); + printf ("One-way ANOVA Table:\n"); + printf ("\n"); + printf ("Source of Variation Sum of Squares df Empirical Var\n"); + printf ("*********************************************************\n"); + printf ("Between Groups %15.4f %4d %13.4f\n", SSB, df_b, v_b); + printf ("Within Groups %15.4f %4d %13.4f\n", SSW, df_w, v_w); + printf ("---------------------------------------------------------\n"); + printf ("Total %15.4f %4d\n", SST, n - 1); + printf ("\n"); + printf ("Test Statistic f %15.4f\n", f); + printf ("p-value %15.4f\n", pval); + printf ("\n"); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/bartlett_test.m --- a/scripts/statistics/tests/bartlett_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/bartlett_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -61,7 +61,7 @@ pval = 1 - chi2cdf (chisq, df); if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/chisquare_test_homogeneity.m --- a/scripts/statistics/tests/chisquare_test_homogeneity.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/chisquare_test_homogeneity.m Wed Apr 20 11:06:03 2016 -0700 @@ -62,7 +62,7 @@ pval = 1 - chi2cdf (chisq, df); if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/chisquare_test_independence.m --- a/scripts/statistics/tests/chisquare_test_independence.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/chisquare_test_independence.m Wed Apr 20 11:06:03 2016 -0700 @@ -48,7 +48,7 @@ pval = 1 - chi2cdf (chisq, df); if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/cor_test.m --- a/scripts/statistics/tests/cor_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/cor_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -129,7 +129,7 @@ t.alternative = alt; if (nargout == 0) - fprintf ("pval: %g\n", t.pval); + printf ("pval: %g\n", t.pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/f_test_regression.m --- a/scripts/statistics/tests/f_test_regression.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/f_test_regression.m Wed Apr 20 11:06:03 2016 -0700 @@ -71,7 +71,7 @@ pval = 1 - fcdf (f, df_num, df_den); if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/hotelling_test.m --- a/scripts/statistics/tests/hotelling_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/hotelling_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -66,7 +66,7 @@ pval = 1 - fcdf ((n-p) * Tsq / (p * (n-1)), p, n-p); if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/hotelling_test_2.m --- a/scripts/statistics/tests/hotelling_test_2.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/hotelling_test_2.m Wed Apr 20 11:06:03 2016 -0700 @@ -80,7 +80,7 @@ p, n_x + n_y - p - 1); if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/kolmogorov_smirnov_test.m --- a/scripts/statistics/tests/kolmogorov_smirnov_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -106,7 +106,7 @@ endif if (nargout == 0) - fprintf ("pval: %g\n", pval); + printf ("pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/kolmogorov_smirnov_test_2.m --- a/scripts/statistics/tests/kolmogorov_smirnov_test_2.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/kolmogorov_smirnov_test_2.m Wed Apr 20 11:06:03 2016 -0700 @@ -98,7 +98,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/kruskal_wallis_test.m --- a/scripts/statistics/tests/kruskal_wallis_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/kruskal_wallis_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -89,7 +89,7 @@ pval = 1 - chi2cdf (k, df); if (nargout == 0) - fprintf ("pval: %g\n", pval); + printf ("pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/manova.m --- a/scripts/statistics/tests/manova.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/manova.m Wed Apr 20 11:06:03 2016 -0700 @@ -136,30 +136,30 @@ df_den = theta * (2 * v + theta + 1); PB_pval = 1 - fcdf (PB * df_den / df_num, df_num, df_den); - fprintf ("\n"); - fprintf ("One-way MANOVA Table:\n"); - fprintf ("\n"); - fprintf ("Test Test Statistic Approximate p\n"); - fprintf ("**************************************************\n"); - fprintf ("Wilks %10.4f %10.9f \n", Lambda, W_pval_1); - fprintf (" %10.9f \n", W_pval_2); - fprintf ("Hotelling-Lawley %10.4f %10.9f \n", HL, HL_pval); - fprintf ("Pillai-Bartlett %10.4f %10.9f \n", PB, PB_pval); - fprintf ("\n"); + printf ("\n"); + printf ("One-way MANOVA Table:\n"); + printf ("\n"); + printf ("Test Test Statistic Approximate p\n"); + printf ("**************************************************\n"); + printf ("Wilks %10.4f %10.9f \n", Lambda, W_pval_1); + printf (" %10.9f \n", W_pval_2); + printf ("Hotelling-Lawley %10.4f %10.9f \n", HL, HL_pval); + printf ("Pillai-Bartlett %10.4f %10.9f \n", PB, PB_pval); + printf ("\n"); endif - fprintf ("\n"); - fprintf ("MANOVA Results:\n"); - fprintf ("\n"); - fprintf ("# of groups: %d\n", k); - fprintf ("# of samples: %d\n", n); - fprintf ("# of variables: %d\n", p); - fprintf ("\n"); - fprintf ("Wilks' Lambda: %5.4f\n", Lambda); - fprintf ("Approximate p: %10.9f (chisquare approximation)\n", W_pval_1); - fprintf (" %10.9f (F approximation)\n", W_pval_2); - fprintf ("\n"); + printf ("\n"); + printf ("MANOVA Results:\n"); + printf ("\n"); + printf ("# of groups: %d\n", k); + printf ("# of samples: %d\n", n); + printf ("# of variables: %d\n", p); + printf ("\n"); + printf ("Wilks' Lambda: %5.4f\n", Lambda); + printf ("Approximate p: %10.9f (chisquare approximation)\n", W_pval_1); + printf (" %10.9f (F approximation)\n", W_pval_2); + printf ("\n"); endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/mcnemar_test.m --- a/scripts/statistics/tests/mcnemar_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/mcnemar_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -58,7 +58,7 @@ pval = 1 - chi2cdf (chisq, df); if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/prop_test_2.m --- a/scripts/statistics/tests/prop_test_2.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/prop_test_2.m Wed Apr 20 11:06:03 2016 -0700 @@ -75,7 +75,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/run_test.m --- a/scripts/statistics/tests/run_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/run_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -54,7 +54,7 @@ pval = chi2cdf (chisq, 6); if (nargout == 0) - fprintf ("pval: %g\n", pval); + printf ("pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/sign_test.m --- a/scripts/statistics/tests/sign_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/sign_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -78,7 +78,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/t_test.m --- a/scripts/statistics/tests/t_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/t_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -77,7 +77,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/t_test_2.m --- a/scripts/statistics/tests/t_test_2.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/t_test_2.m Wed Apr 20 11:06:03 2016 -0700 @@ -78,7 +78,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/t_test_regression.m --- a/scripts/statistics/tests/t_test_regression.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/t_test_regression.m Wed Apr 20 11:06:03 2016 -0700 @@ -92,7 +92,7 @@ endif if (nargout == 0) - fprintf ("pval: %g\n", pval); + printf ("pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/u_test.m --- a/scripts/statistics/tests/u_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/u_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -81,7 +81,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/var_test.m --- a/scripts/statistics/tests/var_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/var_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -74,7 +74,7 @@ endif if (nargout == 0) - fprintf ("pval: %g\n", pval); + printf ("pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/welch_test.m --- a/scripts/statistics/tests/welch_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/welch_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -80,7 +80,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/wilcoxon_test.m --- a/scripts/statistics/tests/wilcoxon_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/wilcoxon_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -87,7 +87,7 @@ endif if (nargout == 0) - fprintf (" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/z_test.m --- a/scripts/statistics/tests/z_test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/z_test.m Wed Apr 20 11:06:03 2016 -0700 @@ -83,7 +83,7 @@ s = ["Z-test of mean(x) == %g against mean(x) %s %g,\n", ... "with known var(x) == %g:\n", ... " pval = %g\n"]; - fprintf (s, m, alt, m, v, pval); + printf (s, m, alt, m, v, pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/statistics/tests/z_test_2.m --- a/scripts/statistics/tests/z_test_2.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/statistics/tests/z_test_2.m Wed Apr 20 11:06:03 2016 -0700 @@ -84,7 +84,7 @@ "mean(x) %s mean(y),\n", ... "with known var(x) == %g and var(y) == %g:\n", ... " pval = %g\n"]; - fprintf (s, alt, v_x, v_y, pval); + printf (s, alt, v_x, v_y, pval); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/strings/strtok.m --- a/scripts/strings/strtok.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/strings/strtok.m Wed Apr 20 11:06:03 2016 -0700 @@ -145,13 +145,13 @@ %! s = "14*27+31" %! while (1) %! [t, s] = strtok (s, "+-*/"); -%! fprintf ("<%s>", t); +%! printf ("<%s>", t); %! if (isempty (s)) %! break; %! endif -%! fprintf ("<%s>", s(1)); +%! printf ("<%s>", s(1)); %! endwhile -%! fprintf ("\n"); +%! printf ("\n"); %! % ---------------------------------------------------- %! % Demonstrates processing of an entire string split on %! % a variety of delimiters. Tokens and delimiters are diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/__run_test_suite__.m --- a/scripts/testfun/__run_test_suite__.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/__run_test_suite__.m Wed Apr 20 11:06:03 2016 -0700 @@ -54,7 +54,7 @@ endif test ("", "explain", fid); dp = dn = dxf = dsk = 0; - fputs ("\nIntegrated test scripts:\n\n"); + puts ("\nIntegrated test scripts:\n\n"); for i = 1:length (fcndirs) [p, n, xf, sk] = run_test_script (fid, fcndirs{i}); dp += p; @@ -62,7 +62,7 @@ dxf += xf; dsk += sk; endfor - fputs ("\nFixed test scripts:\n\n"); + puts ("\nFixed test scripts:\n\n"); for i = 1:length (fixedtestdirs) [p, n, xf, sk] = run_test_dir (fid, fixedtestdirs{i}); dp += p; @@ -70,30 +70,30 @@ dxf += xf; dsk += sk; endfor - fputs ("\nSummary:\n\n"); + puts ("\nSummary:\n\n"); nfail = dn - dp - dxf; - fprintf (" PASS %6d\n", dp); - fprintf (" FAIL %6d\n", nfail); + printf (" PASS %6d\n", dp); + printf (" FAIL %6d\n", nfail); if (dxf > 0) - fprintf (" XFAIL %6d\n", dxf); + printf (" XFAIL %6d\n", dxf); endif if (dsk > 0) - fprintf (" SKIPPED %6d\n", dsk); + printf (" SKIPPED %6d\n", dsk); endif - fputs ("\n"); - fprintf ("See the file %s for additional details.\n", logfile); + puts ("\n"); + printf ("See the file %s for additional details.\n", logfile); if (dxf > 0) - fputs ("\n"); - fputs ("Expected failures (listed as XFAIL above) are known bugs.\n"); - fputs ("Please help improve Octave by contributing fixes for them.\n"); + puts ("\n"); + puts ("Expected failures (listed as XFAIL above) are known bugs.\n"); + puts ("Please help improve Octave by contributing fixes for them.\n"); endif if (dsk > 0) - fputs ("\n"); - fputs ("Tests are most often skipped because the features they require\n"); - fputs ("have been disabled. Features are most often disabled because\n"); - fputs ("they require dependencies that were not present when Octave\n"); - fputs ("was built. The configure script should have printed a summary\n"); - fputs ("at the end of its run indicating which dependencies were not found.\n"); + puts ("\n"); + puts ("Tests are most often skipped because the features they require\n"); + puts ("have been disabled. Features are most often disabled because\n"); + puts ("they require dependencies that were not present when Octave\n"); + puts ("was built. The configure script should have printed a summary\n"); + puts ("at the end of its run indicating which dependencies were not found.\n"); endif ## Weed out deprecated and private functions @@ -104,8 +104,8 @@ report_files_with_no_tests (files_with_tests, files_with_no_tests, ".m"); - fputs ("\nPlease help improve Octave by contributing tests for these files\n"); - fprintf ("(see the list in the file %s).\n\n", logfile); + puts ("\nPlease help improve Octave by contributing tests for these files\n"); + printf ("(see the list in the file %s).\n\n", logfile); fprintf (fid, "\nFiles with no tests:\n\n%s", list_in_columns (files_with_no_tests, 80)); @@ -130,24 +130,24 @@ function print_test_file_name (nm) filler = repmat (".", 1, 60-length (nm)); - fprintf (" %s %s", nm, filler); + printf (" %s %s", nm, filler); endfunction function print_pass_fail (p, n, xf, sk) if ((n + sk) > 0) - fprintf (" PASS %4d/%-4d", p, n); + printf (" PASS %4d/%-4d", p, n); nfail = n - p - xf; if (nfail > 0) - fprintf ("\n%71s %3d", "FAIL ", nfail); + printf ("\n%71s %3d", "FAIL ", nfail); endif if (sk > 0) - fprintf ("\n%71s %3d", "SKIP ", sk); + printf ("\n%71s %3d", "SKIP ", sk); endif if (xf > 0) - fprintf ("\n%71s %3d", "XFAIL", xf); + printf ("\n%71s %3d", "XFAIL", xf); endif endif - fputs ("\n"); + puts ("\n"); endfunction function retval = has_functions (f) @@ -273,7 +273,7 @@ endif endif endfor - ## fprintf("%s%s -> passes %d of %d tests\n", ident, d, dp, dn); + ## printf("%s%s -> passes %d of %d tests\n", ident, d, dp, dn); endfunction function n = num_elts_matching_pattern (lst, pat) @@ -285,9 +285,10 @@ n_with = num_elts_matching_pattern (with, pat); n_without = num_elts_matching_pattern (without, pat); n_tot = n_with + n_without; - fprintf ("\n%d (of %d) %s files have no tests.\n", n_without, n_tot, typ); + printf ("\n%d (of %d) %s files have no tests.\n", n_without, n_tot, typ); endfunction ## No test coverage for internal function. It is tested through calling fcn. %!assert (1) + diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/demo.m --- a/scripts/testfun/demo.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/demo.m Wed Apr 20 11:06:03 2016 -0700 @@ -138,11 +138,11 @@ ## Use an environment without variables eval (["function __demo__ ()\n" block "\nendfunction"]); ## Display the code that will be executed before executing it - fprintf ("%s example %d:%s\n\n", name, doidx(i), block); + printf ("%s example %d:%s\n\n", name, doidx(i), block); __demo__; catch ## Let the programmer know which demo failed. - fprintf ("%s example %d: failed\n%s\n", name, doidx(i), lasterr ()); + printf ("%s example %d: failed\n%s\n", name, doidx(i), lasterr ()); end_try_catch clear __demo__; endfor diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/example.m --- a/scripts/testfun/example.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/example.m Wed Apr 20 11:06:03 2016 -0700 @@ -86,7 +86,7 @@ for i = 1:length (doidx) block = code(idx(doidx(i)):idx(doidx(i)+1)-1); - fprintf ("%s example %d:%s\n\n", name, doidx(i), block); + printf ("%s example %d:%s\n\n", name, doidx(i), block); endfor endif diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/private/compare_plot_demos.m --- a/scripts/testfun/private/compare_plot_demos.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/private/compare_plot_demos.m Wed Apr 20 11:06:03 2016 -0700 @@ -98,7 +98,7 @@ try eval (fcn_name); catch - fprintf ("Error running plot demos for ""%s"" toolkit\n", + printf ("Error running plot demos for ""%s"" toolkit\n", arg.toolkits{n}); disp (lasterror); end_try_catch @@ -113,8 +113,8 @@ html_compare_plot_demos (arg.toolkits); else ## We need to run matlab manually before the html page can be created - fprintf ('\nNow run %s in Matlab.\nAfter this run html_compare_plot_demos,\n', arg.fcn_file); - fprintf ('for example html_compare_plot_demos ({"fltk", "gnuplot", "matlab"}), to create the html page.\n'); + printf ('\nNow run %s in Matlab.\nAfter this run html_compare_plot_demos,\n', arg.fcn_file); + printf ('for example html_compare_plot_demos ({"fltk", "gnuplot", "matlab"}), to create the html page.\n'); endif endfunction diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/rundemos.m Wed Apr 20 11:06:03 2016 -0700 @@ -73,7 +73,7 @@ try demo (f); catch - fprintf ("error: %s\n\n", lasterror ().message); + printf ("error: %s\n\n", lasterror ().message); end_try_catch if (i != numel (flist)) input ("Press to continue: ", "s"); diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/runtests.m --- a/scripts/testfun/runtests.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/runtests.m Wed Apr 20 11:06:03 2016 -0700 @@ -65,7 +65,7 @@ flist = readdir (directory); dirs = {}; no_tests = {}; - fprintf ("Processing files in %s:\n\n", directory); + printf ("Processing files in %s:\n\n", directory); fflush (stdout); for i = 1:numel (flist) f = flist{i}; @@ -88,8 +88,8 @@ endif endfor if (! isempty (no_tests)) - fprintf ("\nThe following files in %s have no tests:\n\n", directory); - fprintf ("%s", list_in_columns (no_tests)); + printf ("\nThe following files in %s have no tests:\n\n", directory); + printf ("%s", list_in_columns (no_tests)); endif ## Recurse into class directories since they are implied in the path @@ -134,24 +134,25 @@ function print_pass_fail (n, p, xf) if (n > 0) - fprintf (" PASS %4d/%-4d", p, n); + printf (" PASS %4d/%-4d", p, n); nfail = n - p; if (nfail > 0) if (nfail != xf) - fprintf (" FAIL %d", nfail - xf); + printf (" FAIL %d", nfail - xf); else - fprintf (" XFAIL %d", xf); + printf (" XFAIL %d", xf); endif endif endif - fputs ("\n"); + puts ("\n"); endfunction function print_test_file_name (nm) filler = repmat (".", 1, 55-length (nm)); - fprintf (" %s %s", nm, filler); + printf (" %s %s", nm, filler); endfunction %!error runtests ("foo", 1) %!error runtests ("#_TOTALLY_/_INVALID_/_PATHNAME_#") + diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/speed.m --- a/scripts/testfun/speed.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/speed.m Wed Apr 20 11:06:03 2016 -0700 @@ -211,7 +211,7 @@ eval (__init); if (do_display) - fprintf ("n%i = %i ", k, n); + printf ("n%i = %i ", k, n); fflush (stdout); endif @@ -301,7 +301,7 @@ ylabel ("best execution time (ms)"); ratio = mean (__torig ./ __tnew); - fprintf ("\n\nMean runtime ratio = %.3g for '%s' vs '%s'\n", + printf ("\n\nMean runtime ratio = %.3g for '%s' vs '%s'\n", ratio, __f2, __f1); endif @@ -337,9 +337,9 @@ endif ## Display nicely formatted complexity. - fprintf ("\nFor %s:\n", __f1); - fprintf (" asymptotic power: %s\n", order); - fprintf (" approximate time per operation: %s\n", time); + printf ("\nFor %s:\n", __f1); + printf (" asymptotic power: %s\n", order); + printf (" approximate time per operation: %s\n", time); endif diff -r dcf8922b724b -r 96518f623c91 scripts/testfun/test.m --- a/scripts/testfun/test.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/testfun/test.m Wed Apr 20 11:06:03 2016 -0700 @@ -651,19 +651,19 @@ if (nargout == 0) if (__tests || __xfail || __xskip) if (__xfail) - fprintf ("PASSES %d out of %d test%s (%d expected failure%s)\n", + printf ("PASSES %d out of %d test%s (%d expected failure%s)\n", __successes, __tests, ifelse (__tests > 1, "s", ""), __xfail, ifelse (__xfail > 1, "s", "")); else - fprintf ("PASSES %d out of %d test%s\n", __successes, __tests, + printf ("PASSES %d out of %d test%s\n", __successes, __tests, ifelse (__tests > 1, "s", "")); endif if (__xskip) - fprintf ("Skipped %d test%s due to missing features\n", __xskip, + printf ("Skipped %d test%s due to missing features\n", __xskip, ifelse (__xskip > 1, "s", "")); endif else - fprintf ("%s%s has no tests available\n", __signal_empty, __file); + printf ("%s%s has no tests available\n", __signal_empty, __file); endif elseif (__grabdemo) __n = __demo_code; diff -r dcf8922b724b -r 96518f623c91 scripts/time/calendar.m --- a/scripts/time/calendar.m Wed Apr 20 17:53:10 2016 +0200 +++ b/scripts/time/calendar.m Wed Apr 20 11:06:03 2016 -0700 @@ -80,9 +80,9 @@ ## Display the calendar. s.year = y - 1900; s.mon = m - 1; - fputs (strftime (" %b %Y\n", s)); - fputs (" S M Tu W Th F S\n"); - fputs (str); + puts (strftime (" %b %Y\n", s)); + puts (" S M Tu W Th F S\n"); + puts (str); endif endfunction @@ -101,3 +101,4 @@ ## Test input validation %!error calendar (1,2,3) + diff -r dcf8922b724b -r 96518f623c91 test/io.tst --- a/test/io.tst Wed Apr 20 17:53:10 2016 +0200 +++ b/test/io.tst Wed Apr 20 11:06:03 2016 -0700 @@ -262,6 +262,17 @@ %!error load ("") +%% FIXME: This test is disabled as it writes to stdout and there is no easy +%% way to recover output. Need to spawn new octave process and pipe stdout +%% somewhere to treat this case. +%!#test +%! puts ("foo\n"); + +%!assert (puts (1),-1) + +%!error puts () +%!error puts (1, 2) + %!assert (sscanf ('123456', '%10c'), '123456') %!assert (sscanf ('123456', '%10s'), '123456') @@ -324,8 +335,8 @@ %! assert (x, 8); %! assert (str, "test:1"); -%!error fprintf (1) -%!error fprintf () +%!error printf (1) +%!error printf () %!test %! [s, msg, status] = sprintf ("%s: %d\n", "test", 1); @@ -505,6 +516,11 @@ %! endif %! unlink (nm); +%!assert (fputs (1, 1),-1) + +%!error fputs () +%!error fputs (1, "foo", 1) + %!error fgetl ("foo", 1) %!error fgetl ()