Mercurial > octave
diff src/ov-str-mat.cc @ 5758:65208d959bf1
[project @ 2006-04-12 19:23:26 by jwe]
author | jwe |
---|---|
date | Wed, 12 Apr 2006 19:23:26 +0000 |
parents | c7d5a534afa5 |
children | ce79d238f142 |
line wrap: on
line diff
--- a/src/ov-str-mat.cc Wed Apr 12 18:54:25 2006 +0000 +++ b/src/ov-str-mat.cc Wed Apr 12 19:23:26 2006 +0000 @@ -33,20 +33,21 @@ #include "mach-info.h" #include "mx-base.h" +#include "defun.h" +#include "byte-swap.h" +#include "gripes.h" +#include "ls-oct-ascii.h" +#include "ls-hdf5.h" +#include "ls-utils.h" #include "oct-obj.h" #include "oct-stream.h" #include "ops.h" #include "ov-scalar.h" #include "ov-re-mat.h" #include "ov-str-mat.h" -#include "gripes.h" #include "pr-output.h" #include "pt-mat.h" - -#include "byte-swap.h" -#include "ls-oct-ascii.h" -#include "ls-hdf5.h" -#include "ls-utils.h" +#include "utils.h" DEFINE_OCTAVE_ALLOCATOR (octave_char_matrix_str); DEFINE_OCTAVE_ALLOCATOR (octave_char_matrix_sq_str); @@ -54,6 +55,13 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix_str, "string", "char"); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix_sq_str, "sq_string", "char"); +// If TRUE, warn for operations like +// +// octave> 'abc' + 0 +// 97 98 99 +// +static bool Vwarn_str_to_num; + static octave_value * default_numeric_conversion_function (const octave_value& a) { @@ -756,6 +764,35 @@ #endif +static int +warn_str_to_num (void) +{ + Vwarn_str_to_num = check_preference ("warn_str_to_num"); + + return 0; +} + +void +symbols_of_ov_str_mat (void) +{ + DEFVAR (warn_str_to_num, false, warn_str_to_num, + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} warn_str_to_num\n\ +If the value of @code{warn_str_to_num} is nonzero, a warning is printed\n\ +for implicit conversions of strings to their numeric ASCII equivalents.\n\ +For example,\n\ +@example\n\ +@group\n\ +\"abc\" + 0\n\ + @result{} 97 98 99\n\ +@end group\n\ +@end example\n\ +elicits a warning if @code{warn_str_to_num} is nonzero. The default\n\ +value is 0.\n\ +@end defvr"); +} + + /* ;;; Local Variables: *** ;;; mode: C++ ***