# HG changeset patch # User John W. Eaton # Date 1433892345 25200 # Node ID 7fa170cc14fec67c0ef9d96eef2ae8faca77793c # Parent c4f436483e49180d1bb52b627fac3395d1d41d55 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. diff -r c4f436483e49 -r 7fa170cc14fe libinterp/corefcn/oct-stream.cc --- 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::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... diff -r c4f436483e49 -r 7fa170cc14fe libinterp/octave-value/ov-ch-mat.cc --- 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 { diff -r c4f436483e49 -r 7fa170cc14fe libinterp/octave-value/ov-ch-mat.h --- 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)); }