Mercurial > octave-nkf
changeset 20287:7fa170cc14fe stable
Return correct hex value for printf when used with string inputs (bug #45263).
* oct-stream.cc (ok_for_signed_int_conv): Return true for strings.
* ov-ch-mat.cc (int64_scalar_value, uint64_scalar_value): New functions to
return int64 or uint64 values from a character matrix octave_value.
ov-ch-mat.h: (int64_scalar_value, uint64_scalar_value): Declare new functions
in header file.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 09 Jun 2015 16:25:45 -0700 |
parents | c4f436483e49 |
children | 0d94ec291ee6 507ccf8f10ed |
files | libinterp/corefcn/oct-stream.cc libinterp/octave-value/ov-ch-mat.cc libinterp/octave-value/ov-ch-mat.h |
diffstat | 3 files changed, 42 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc Tue Jun 09 16:16:44 2015 -0700 +++ b/libinterp/corefcn/oct-stream.cc Tue Jun 09 16:25:45 2015 -0700 @@ -2435,7 +2435,7 @@ uint64_t limit = std::numeric_limits<int64_t>::max (); if (val.is_string ()) - return false; + return true; else if (val.is_integer_type ()) { if (val.is_uint64_type ()) @@ -2463,7 +2463,7 @@ ok_for_unsigned_int_conv (const octave_value& val) { if (val.is_string ()) - return false; + return true; else if (val.is_integer_type ()) { // Easier than dispatching here...
--- a/libinterp/octave-value/ov-ch-mat.cc Tue Jun 09 16:16:44 2015 -0700 +++ b/libinterp/octave-value/ov-ch-mat.cc Tue Jun 09 16:25:45 2015 -0700 @@ -87,6 +87,42 @@ return retval; } +octave_int64 +octave_char_matrix::int64_scalar_value () const +{ + octave_int64 retval = 0; + + if (rows () > 0 && columns () > 0) + { + gripe_implicit_conversion ("Octave:array-to-scalar", + "character matrix", "int64 scalar"); + + retval = octave_int64 (matrix (0, 0)); + } + else + gripe_invalid_conversion ("character matrix", "int64 scalar"); + + return retval; +} + +octave_uint64 +octave_char_matrix::uint64_scalar_value () const +{ + octave_uint64 retval = 0; + + if (rows () > 0 && columns () > 0) + { + gripe_implicit_conversion ("Octave:array-to-scalar", + "character matrix", "uint64 scalar"); + + retval = octave_uint64 (matrix (0, 0)); + } + else + gripe_invalid_conversion ("character matrix", "uint64 scalar"); + + return retval; +} + Complex octave_char_matrix::complex_value (bool) const {
--- a/libinterp/octave-value/ov-ch-mat.h Tue Jun 09 16:16:44 2015 -0700 +++ b/libinterp/octave-value/ov-ch-mat.h Tue Jun 09 16:25:45 2015 -0700 @@ -36,6 +36,7 @@ #include "ov.h" #include "ov-base.h" #include "ov-base-mat.h" +#include "ov-int64.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" @@ -105,6 +106,9 @@ float float_scalar_value (bool frc_str_conv = false) const { return float_value (frc_str_conv); } + octave_int64 int64_scalar_value () const; + octave_uint64 uint64_scalar_value () const; + Matrix matrix_value (bool = false) const { return Matrix (charMatrix (matrix)); }