# HG changeset patch # User jwe # Date 1199732085 0 # Node ID fab9bc33b9495aeeb4873ea7f360952b546f75a9 # Parent 8470a6b0b76941ccdd2fe40beed8a19dd8ec763e [project @ 2008-01-07 18:54:45 by jwe] diff -r 8470a6b0b769 -r fab9bc33b949 scripts/ChangeLog --- a/scripts/ChangeLog Mon Jan 07 17:57:24 2008 +0000 +++ b/scripts/ChangeLog Mon Jan 07 18:54:45 2008 +0000 @@ -1,3 +1,8 @@ +2008-01-07 John W. Eaton + + * miscellaneous/copyfile.m, miscellaneous/movefile.m: + Error if glob call fails to match any files. + 2008-01-04 Thomas Treichl * strings/strtrim.m: Doc fix. diff -r 8470a6b0b769 -r fab9bc33b949 scripts/miscellaneous/copyfile.m --- a/scripts/miscellaneous/copyfile.m Mon Jan 07 17:57:24 2008 +0000 +++ b/scripts/miscellaneous/copyfile.m Mon Jan 07 18:54:45 2008 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2005, 2006, 2007 John W. Eaton +## Copyright (C) 2005, 2006, 2007, 2008 John W. Eaton ## ## This file is part of Octave. ## @@ -76,6 +76,9 @@ ## Protect the file name(s). f1 = glob (f1); + if (isempty (f1)) + error ("copyfile: no files to move"); + endif p1 = sprintf ("\"%s\" ", f1{:}); p2 = tilde_expand (f2); diff -r 8470a6b0b769 -r fab9bc33b949 scripts/miscellaneous/movefile.m --- a/scripts/miscellaneous/movefile.m Mon Jan 07 17:57:24 2008 +0000 +++ b/scripts/miscellaneous/movefile.m Mon Jan 07 18:54:45 2008 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2005, 2006, 2007 John W. Eaton +## Copyright (C) 2005, 2006, 2007, 2008 John W. Eaton ## ## This file is part of Octave. ## @@ -75,6 +75,9 @@ ## Protect the file name(s). f1 = glob (f1); + if (isempty (f1)) + error ("movefile: no files to move"); + endif p1 = sprintf ("\"%s\" ", f1{:}); p2 = tilde_expand (f2); diff -r 8470a6b0b769 -r fab9bc33b949 src/ChangeLog --- a/src/ChangeLog Mon Jan 07 17:57:24 2008 +0000 +++ b/src/ChangeLog Mon Jan 07 18:54:45 2008 +0000 @@ -1,5 +1,14 @@ 2008-01-07 John W. Eaton + * gripes.cc (gripe_wrong_type_arg (const std::string&, const + octave_value&, bool)): New function. + * gripes.h: Provide decl. + + * oct-stream.cc (printf_value_cache::printf_value_cache): + Reject structs, cells, objects, and lists. + (octave_base_stream::do_printf): Quit early if printf_value_cache + constructor fails. + * parse.y (make_anon_fcn_handle): Don't attempt to convert expression to assignment to __retval__. diff -r 8470a6b0b769 -r fab9bc33b949 src/gripes.cc --- a/src/gripes.cc Mon Jan 07 17:57:24 2008 +0000 +++ b/src/gripes.cc Mon Jan 07 18:54:45 2008 +0000 @@ -156,6 +156,13 @@ } void +gripe_wrong_type_arg (const std::string& name, const octave_value& tc, + bool is_error) +{ + gripe_wrong_type_arg (name.c_str (), tc, is_error); +} + +void gripe_wrong_type_arg_for_unary_op (const octave_value& op) { std::string type = op.type_name (); diff -r 8470a6b0b769 -r fab9bc33b949 src/gripes.h --- a/src/gripes.h Mon Jan 07 17:57:24 2008 +0000 +++ b/src/gripes.h Mon Jan 07 18:54:45 2008 +0000 @@ -91,6 +91,10 @@ bool is_error = true); extern OCTINTERP_API void +gripe_wrong_type_arg (const std::string& name, const octave_value& tc, + bool is_error = true); + +extern OCTINTERP_API void gripe_wrong_type_arg_for_unary_op (const octave_value& op); extern OCTINTERP_API void diff -r 8470a6b0b769 -r fab9bc33b949 src/oct-stream.cc --- a/src/oct-stream.cc Mon Jan 07 17:57:24 2008 +0000 +++ b/src/oct-stream.cc Mon Jan 07 18:54:45 2008 +0000 @@ -47,6 +47,7 @@ #include "quit.h" #include "error.h" +#include "gripes.h" #include "input.h" #include "oct-stdstrm.h" #include "oct-stream.h" @@ -2276,10 +2277,23 @@ enum state { ok, conversion_error }; - printf_value_cache (const octave_value_list& args) + printf_value_cache (const octave_value_list& args, const std::string& who) : values (args), val_idx (0), elt_idx (0), n_vals (values.length ()), n_elts (0), data (0), - curr_state (ok) { } + curr_state (ok) + { + for (octave_idx_type i = 0; i < values.length (); i++) + { + octave_value val = values(i); + + if (val.is_map () || val.is_cell () || val.is_object () + || val.is_list ()) + { + gripe_wrong_type_arg (who, val); + break; + } + } + } ~printf_value_cache (void) { } @@ -2527,7 +2541,10 @@ const printf_format_elt *elt = fmt_list.first (); - printf_value_cache val_cache (args); + printf_value_cache val_cache (args, who); + + if (error_state) + return retval; for (;;) {