Mercurial > octave
diff libinterp/corefcn/file-io.cc @ 21633:dcf8922b724b
Deprecate printf, puts, and scanf. Make fputs a M-file.
* libinterp/corefcn/file-io.cc: extracted printf, puts, and scanf to M-files.
* scripts/deprecated/printf.m: new function, equivalent to version file-io.cc.
* scripts/deprecated/puts.m: new function, equivalent to version file-io.cc.
* scripts/deprecated/scanf.m: new function, equivalent to version file-io.cc.
* scripts/deprecated/module.mk: added printf, puts, and scanf.
* scripts/io/fputs.m: new function, equivalent to version file-io.cc.
* scripts/io/module.mk: added fputs.
* doc/interpreter/io.txi: adapted documentation to current implementation.
* NEWS: announced changes.
* doc/interpreter/basics.txi: replaced printf by fprintf.
* doc/interpreter/stmt.txi: replaced printf by fprintf.
* doc/interpreter/var.txi: replaced printf by fprintf.
* doc/refcard/refcard.tex: removed printf and scanf.
* examples/code/@FIRfilter/display.m: replaced printf by fprintf.
* examples/code/@polynomial/display.m: replaced printf by fprintf.
* scripts/@ftp/display.m: replaced printf by fprintf.
* scripts/general/inputParser.m: replaced printf by fprintf.
* scripts/general/methods.m: replaced printf by fprintf.
* scripts/general/profexplore.m: replaced printf by fprintf.
* scripts/general/profshow.m: replaced printf by fprintf.
* scripts/help/help.m: replaced puts by fputs and printf by fprintf.
* scripts/help/lookfor.m: replaced puts by fputs and printf by fprintf.
* scripts/help/which.m: replaced printf by fprintf.
* scripts/image/imformats.m: replaced printf by fprintf.
* scripts/io/beep.m: replaced puts by fputs.
* scripts/io/textread.m: replaced printf by fprintf.
* scripts/java/javaclasspath.m: replaced printf by fprintf.
* scripts/java/javamem.m: replaced printf by fprintf.
* scripts/miscellaneous/dir.m: replaced printf by fprintf.
* scripts/miscellaneous/dos.m: replaced printf by fprintf.
* scripts/miscellaneous/fact.m: replaced printf by fprintf.
* scripts/miscellaneous/info.m: replaced printf by fprintf.
* scripts/miscellaneous/license.m: replaced printf by fprintf.
* scripts/miscellaneous/ls.m: replaced puts by fputs.
* scripts/miscellaneous/menu.m: replaced printf by fprintf.
* scripts/miscellaneous/mkoctfile.m: replaced printf by fprintf.
* scripts/miscellaneous/private/display_info_file.m:
* scripts/miscellaneous/unix.m: replaced printf by fprintf.
* scripts/miscellaneous/ver.m: replaced printf by fprintf.
* scripts/miscellaneous/what.m: replaced printf by fprintf.
* scripts/ode/ode23.m: replaced printf by fprintf.
* scripts/ode/ode45.m: replaced printf by fprintf.
* scripts/optimization/fminbnd.m: replaced printf by fprintf.
* scripts/optimization/optimset.m: replaced puts by fputs and printf by fprintf.
* scripts/optimization/sqp.m: replaced printf by fprintf.
* scripts/pkg/pkg.m: replaced printf by fprintf.
* scripts/pkg/private/describe.m: replaced printf by fprintf.
* scripts/pkg/private/install.m: replaced printf by fprintf.
* scripts/pkg/private/installed_packages.m: replaced printf by fprintf.
* scripts/pkg/private/list_forge_packages.m: replaced puts by fputs and printf by fprintf.
* scripts/pkg/private/rebuild.m: replaced printf by fprintf.
* scripts/plot/util/__gnuplot_drawnow__.m: replaced puts by fputs and printf by fprintf.
* scripts/signal/stft.m: replaced printf by fprintf.
* scripts/sparse/bicg.m: replaced printf by fprintf.
* scripts/sparse/bicgstab.m: replaced printf by fprintf.
* scripts/sparse/cgs.m: replaced printf by fprintf.
* scripts/sparse/pcg.m: replaced printf by fprintf.
* scripts/sparse/pcr.m: replaced printf by fprintf.
* scripts/sparse/qmr.m: replaced printf by fprintf.
* scripts/statistics/models/logistic_regression.m: replaced printf by fprintf.
* scripts/statistics/tests/anova.m: replaced printf by fprintf.
* scripts/statistics/tests/bartlett_test.m: replaced printf by fprintf.
* scripts/statistics/tests/chisquare_test_homogeneity.m: replaced printf by fprintf.
* scripts/statistics/tests/chisquare_test_independence.m: replaced printf by fprintf.
* scripts/statistics/tests/cor_test.m: replaced printf by fprintf.
* scripts/statistics/tests/f_test_regression.m: replaced printf by fprintf.
* scripts/statistics/tests/hotelling_test.m: replaced printf by fprintf.
* scripts/statistics/tests/hotelling_test_2.m: replaced printf by fprintf.
* scripts/statistics/tests/kolmogorov_smirnov_test.m: replaced printf by fprintf.
* scripts/statistics/tests/kolmogorov_smirnov_test_2.m: replaced printf by fprintf.
* scripts/statistics/tests/kruskal_wallis_test.m: replaced printf by fprintf.
* scripts/statistics/tests/manova.m: replaced printf by fprintf.
* scripts/statistics/tests/mcnemar_test.m: replaced printf by fprintf.
* scripts/statistics/tests/prop_test_2.m: replaced printf by fprintf.
* scripts/statistics/tests/run_test.m: replaced printf by fprintf.
* scripts/statistics/tests/sign_test.m: replaced printf by fprintf.
* scripts/statistics/tests/t_test.m: replaced printf by fprintf.
* scripts/statistics/tests/t_test_2.m: replaced printf by fprintf.
* scripts/statistics/tests/t_test_regression.m: replaced printf by fprintf.
* scripts/statistics/tests/u_test.m: replaced printf by fprintf.
* scripts/statistics/tests/var_test.m: replaced printf by fprintf.
* scripts/statistics/tests/welch_test.m: replaced printf by fprintf.
* scripts/statistics/tests/wilcoxon_test.m: replaced printf by fprintf.
* scripts/statistics/tests/z_test.m: replaced printf by fprintf.
* scripts/statistics/tests/z_test_2.m: replaced printf by fprintf.
* scripts/strings/strtok.m: replaced printf by fprintf.
* scripts/testfun/__run_test_suite__.m: replaced puts by fputs and printf by fprintf.
* scripts/testfun/demo.m: replaced printf by fprintf.
* scripts/testfun/example.m: replaced printf by fprintf.
* scripts/testfun/private/compare_plot_demos.m: replaced printf by fprintf.
* scripts/testfun/rundemos.m: replaced printf by fprintf.
* scripts/testfun/runtests.m: replaced puts by fputs and printf by fprintf.
* scripts/testfun/speed.m: replaced printf by fprintf.
* scripts/testfun/test.m: replaced printf by fprintf.
* scripts/time/calendar.m: replaced puts by fputs and printf by fprintf.
* test/io.tst: replaced printf by fprintf.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Wed, 20 Apr 2016 17:53:10 +0200 |
parents | 3cadca91e390 |
children | 96518f623c91 |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Wed Apr 20 09:19:06 2016 +0200 +++ b/libinterp/corefcn/file-io.cc Wed Apr 20 17:53:10 2016 +0200 @@ -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, printf, sprintf, fopen}\n\ +@seealso{fputs, fdisp, fwrite, fscanf, sprintf, fopen}\n\ @end deftypefn") { static std::string who = "fprintf"; @@ -824,99 +824,6 @@ 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\ @@ -930,7 +837,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{printf, fprintf, sscanf}\n\ +@seealso{fprintf, sscanf}\n\ @end deftypefn") { static std::string who = "sprintf"; @@ -1027,7 +934,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, scanf, sscanf, fopen}\n\ +@seealso{fgets, fgetl, fread, sscanf, fopen}\n\ @end deftypefn") { static std::string who = "fscanf"; @@ -1090,7 +997,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, scanf, sprintf}\n\ +@seealso{fscanf, sprintf}\n\ @end deftypefn") { static std::string who = "sscanf"; @@ -1138,27 +1045,6 @@ 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) {