[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Obsolete warning IDs
From: |
John W. Eaton |
Subject: |
Re: Obsolete warning IDs |
Date: |
Tue, 8 Nov 2011 13:25:13 -0500 |
On 8-Nov-2011, Rik wrote:
| On 11/05/2011 01:07 PM, John W. Eaton wrote:
| > imag-to-real and num-to-str are used in various matrix functions, so
| > they should probably not be removed. But if they are used
| > inconsistently, then maybe we should decide whether to try to be
| > consistent or just remove the warnings. I guess it depends on whether
| > the inconsistent warnings are helpful.
| I couldn't get these warnings to "fire" which is why I thought they might
| need deletion. The documentation for num-to-str in warning_ids even gives
| an example --- that doesn't do anything.
|
| [ "f", 111, 111 ]
The num-to-str warning is still present for character string + numeric
cat op functions, but those don't seem to be called because the cat
function in data.cc and the matrix building code in pt-mat.cc are both
intercepting these kinds of concatenation and not calling the
individual op functions. I think we could bring back the warning
fairly easily (see diff attached below).
For imag-to-real, try
warning on Octave:imag-to-real
eye (1+i)
| > reload-forces-clear is used in dynamic-ld.cc, so it should probably
| > not be removed.
| I couldn't figure out a way to get this one to fire either. I tried
| setting breakpoints but I never got the code to execute. This could be
| wrapped up in the whole inability to clear command-line functions. When I
| created a test file with multiple functions in it, and either executed or
| sourced it, the list of functions were reported as command-line functions
| rather than having come from a file. This warning is supposedly about
| multiple functions coming from the same filename and that information may
| have been lost.
I think this warning only happens when reloading a .oct file that
contains multiple function definitions.
| I would vote for removing the obsolete warning from 2002 and 2005 that you
| identified in a previous e-mail.
OK, I'll try to do that soon unless someone has a good reason to not
do it.
jwe
diff --git a/src/data.cc b/src/data.cc
--- a/src/data.cc
+++ b/src/data.cc
@@ -1670,6 +1670,7 @@
bool all_sq_strings_p = true;
bool all_dq_strings_p = true;
+ bool all_strings_p = true;
bool all_real_p = true;
bool all_cmplx_p = true;
bool any_sparse_p = false;
@@ -1693,6 +1694,8 @@
all_sq_strings_p = false;
if (all_dq_strings_p && ! args(i).is_dq_string ())
all_dq_strings_p = false;
+ if (all_strings_p && ! (args(i).is_dq_string () ||
args(i).is_sq_string ()))
+ all_strings_p = false;
if (all_real_p && ! args(i).is_real_type ())
all_real_p = false;
if (all_cmplx_p && ! (args(i).is_complex_type () ||
args(i).is_real_type ()))
@@ -1746,7 +1749,8 @@
{
char type = all_dq_strings_p ? '"' : '\'';
- maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p);
+ maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p,
+ all_strings_p);
charNDArray result = do_single_type_concat<charNDArray> (args, dim);
diff --git a/src/pt-mat.cc b/src/pt-mat.cc
--- a/src/pt-mat.cc
+++ b/src/pt-mat.cc
@@ -723,11 +723,16 @@
}
void
-maybe_warn_string_concat (bool all_dq_strings_p, bool all_sq_strings_p)
+maybe_warn_string_concat (bool all_dq_strings_p, bool all_sq_strings_p,
+ bool all_strings_p)
{
if (! (all_dq_strings_p || all_sq_strings_p))
warning_with_id ("Octave:string-concat",
"concatenation of different character string types may
have unintended consequences");
+
+ if (! all_strings_p)
+ warning_with_id ("Octave:num-to-str",
+ "concatenation of character string with non-character
data");
}
template<class TYPE, class T>
@@ -980,6 +985,7 @@
bool all_sq_strings_p = false;
bool all_dq_strings_p = false;
+ bool all_strings_p = false;
bool all_empty_p = false;
bool all_real_p = false;
bool any_sparse_p = false;
@@ -993,6 +999,7 @@
dim_vector dv = tmp.dims ();
all_sq_strings_p = tmp.all_sq_strings_p ();
all_dq_strings_p = tmp.all_dq_strings_p ();
+ all_strings_p = tmp.all_strings_p ();
all_empty_p = tmp.all_empty_p ();
all_real_p = tmp.all_real_p ();
any_sparse_p = tmp.any_sparse_p ();
@@ -1035,7 +1042,8 @@
{
char type = all_dq_strings_p ? '"' : '\'';
- maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p);
+ maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p,
+ all_strings_p);
charNDArray result (dv, Vstring_fill_char);
diff --git a/src/pt-mat.h b/src/pt-mat.h
--- a/src/pt-mat.h
+++ b/src/pt-mat.h
@@ -84,7 +84,8 @@
get_concat_class (const std::string& c1, const std::string& c2);
extern void
-maybe_warn_string_concat (bool all_dq_strings_p, bool all_sq_strings_p);
+maybe_warn_string_concat (bool all_dq_strings_p, bool all_sq_strings_p,
+ bool all_strings_p);
extern std::string
get_concat_class (const std::string& c1, const std::string& c2);