Mercurial > octave
changeset 26574:7f5bbd5ac5a5
maint: merge stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 18 Jan 2019 13:51:23 -0800 |
parents | 16f18b0ef642 (current diff) ad70a85f702b (diff) |
children | 7a4cc07905ce |
files | libinterp/corefcn/ft-text-renderer.cc liboctave/array/Array.h |
diffstat | 16 files changed, 127 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/ft-text-renderer.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/libinterp/corefcn/ft-text-renderer.cc Fri Jan 18 13:51:23 2019 -0800 @@ -367,8 +367,9 @@ ft_text_renderer (void) : base_text_renderer (), font (), bbox (1, 4, 0.0), halign (0), xoffset (0), line_yoffset (0), yoffset (0), mode (MODE_BBOX), - color (dim_vector (1, 3), 0), line_xoffset (0), m_ymin (0), m_ymax (0), - m_deltax (0), m_max_fontsize (0) + color (dim_vector (1, 3), 0), m_do_strlist (false), m_strlist (), + line_xoffset (0), m_ymin (0), m_ymax (0), m_deltax (0), + m_max_fontsize (0) { } // No copying! @@ -521,7 +522,8 @@ uint8NDArray color; // A list of parsed strings to be used for printing. - std::list<text_renderer::string> strlist; + bool m_do_strlist; + std::list<text_renderer::string> m_strlist; // The X offset of the baseline for the current line. int line_xoffset; @@ -853,9 +855,16 @@ // First run text_to_pixels which will also build the string list + m_strlist = std::list<text_renderer::string> (); + + octave::unwind_protect frame; + frame.protect_var (m_do_strlist); + frame.protect_var (m_strlist); + m_do_strlist = true; + text_to_pixels (txt, pxls, box, ha, va, rot, interp, false); - lst = strlist; + lst = m_strlist; } void @@ -885,38 +894,44 @@ // character int mblen = octave_u8_strmbtouc_wrapper (&u32_c, c + icurr); n -= mblen; - - if (u32_c == 10) + + if (m_do_strlist && mode == MODE_RENDER) { - // Finish previous string in strlist before processing - // the newline character - fs.set_y (line_yoffset + yoffset); - fs.set_color (color); + if (u32_c == 10) + { + // Finish previous string in m_strlist before processing + // the newline character + fs.set_y (line_yoffset + yoffset); + fs.set_color (color); - std::string s = str.substr (ibegin, icurr - ibegin); - if (! s.empty ()) - { - fs.set_string (s); - fs.set_y (line_yoffset + yoffset); - fs.set_xdata (xdata); - fs.set_family (fname); - strlist.push_back (fs); + std::string s = str.substr (ibegin, icurr - ibegin); + if (! s.empty ()) + { + fs.set_string (s); + fs.set_y (line_yoffset + yoffset); + fs.set_xdata (xdata); + fs.set_family (fname); + m_strlist.push_back (fs); + } } + else + xdata.push_back (xoffset); } - else - xdata.push_back (xoffset); glyph_index = process_character (u32_c, previous); - if (u32_c == 10) { previous = 0; - // Start a new string in strlist - ibegin = icurr+1; - xdata.clear (); - fs = text_renderer::string (str.substr (ibegin), font, - line_xoffset, yoffset); + + if (m_do_strlist && mode == MODE_RENDER) + { + // Start a new string in m_strlist + ibegin = icurr+1; + xdata.clear (); + fs = text_renderer::string (str.substr (ibegin), font, + line_xoffset, yoffset); + } } else previous = glyph_index; @@ -924,13 +939,13 @@ icurr += mblen; } - if (! fs.get_string ().empty ()) + if (m_do_strlist && mode == MODE_RENDER && ! fs.get_string ().empty ()) { fs.set_y (line_yoffset + yoffset); fs.set_color (color); fs.set_xdata (xdata); fs.set_family (fname); - strlist.push_back (fs); + m_strlist.push_back (fs); } } } @@ -1079,18 +1094,21 @@ if (code != text_element_symbol::invalid_code && font.is_valid ()) { process_character (code); - fs.set_code (code); - fs.set_xdata (xdata); + if (m_do_strlist && mode == MODE_RENDER) + { + fs.set_code (code); + fs.set_xdata (xdata); + } } else if (font.is_valid ()) ::warning ("ignoring unknown symbol: %d", e.get_symbol ()); - if (fs.get_code ()) + if (m_do_strlist && mode == MODE_RENDER && fs.get_code ()) { fs.set_y (line_yoffset + yoffset); fs.set_color (color); fs.set_family (font.get_face ()->family_name); - strlist.push_back (fs); + m_strlist.push_back (fs); } } @@ -1115,6 +1133,7 @@ { set_mode (MODE_BBOX); set_color (Matrix (1, 3, 0.0)); + m_strlist = std::list<text_renderer::string> (); } void @@ -1139,8 +1158,6 @@ box = bbox; set_mode (MODE_RENDER); - // Clear the list of parsed strings - strlist.clear (); if (pixels.numel () > 0) {
--- a/liboctave/array/Array-util.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/array/Array-util.cc Fri Jan 18 13:51:23 2019 -0800 @@ -565,7 +565,7 @@ e.set_var (); std::string msg = e.message (); (*current_liboctave_error_with_id_handler) - (e.err_id (), msg.c_str ()); + (e.err_id (), "%s", msg.c_str ()); } } // idxa known to be valid.
--- a/liboctave/array/Array.h Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/array/Array.h Fri Jan 18 13:51:23 2019 -0800 @@ -828,7 +828,7 @@ std::string new_dims_str = dimensions.str (); (*current_liboctave_error_handler) - ("reshape: can't reshape %i elements into %s array", + ("reshape: can't reshape %zi elements into %s array", a.size (), new_dims_str.c_str ()); }
--- a/liboctave/array/MatrixType.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/array/MatrixType.cc Fri Jan 18 13:51:23 2019 -0800 @@ -26,6 +26,7 @@ # include "config.h" #endif +#include <cinttypes> #include <vector> #include "MatrixType.h" @@ -865,12 +866,14 @@ else if (typ == MatrixType::Banded) (*current_liboctave_warning_with_id_handler) ("Octave:matrix-type-info", - "banded sparse matrix %d-1-%d (density %f)", + "banded sparse matrix %" OCTAVE_IDX_TYPE_FORMAT "-1-" + "%" OCTAVE_IDX_TYPE_FORMAT " (density %f)", lower_band, upper_band, bandden); else if (typ == MatrixType::Banded_Hermitian) (*current_liboctave_warning_with_id_handler) ("Octave:matrix-type-info", - "banded hermitian/symmetric sparse matrix %d-1-%d (density %f)", + "banded hermitian/symmetric sparse matrix %" OCTAVE_IDX_TYPE_FORMAT + "-1-%" OCTAVE_IDX_TYPE_FORMAT " (density %f)", lower_band, upper_band, bandden); else if (typ == MatrixType::Hermitian) (*current_liboctave_warning_with_id_handler)
--- a/liboctave/array/Sparse.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/array/Sparse.cc Fri Jan 18 13:51:23 2019 -0800 @@ -27,6 +27,7 @@ // this file. #include <cassert> +#include <cinttypes> #include <algorithm> #include <istream> @@ -294,14 +295,16 @@ if (nr < 0) nr = r.extent (0); else if (r.extent (nr) > nr) - (*current_liboctave_error_handler) ("sparse: row index %d out of bound %d", - r.extent (nr), nr); + (*current_liboctave_error_handler) + ("sparse: row index %" OCTAVE_IDX_TYPE_FORMAT "out of bound " + "%" OCTAVE_IDX_TYPE_FORMAT, r.extent (nr), nr); if (nc < 0) nc = c.extent (0); else if (c.extent (nc) > nc) (*current_liboctave_error_handler) - ("sparse: column index %d out of bound %d", r.extent (nc), nc); + ("sparse: column index %" OCTAVE_IDX_TYPE_FORMAT " out of bound " + "%" OCTAVE_IDX_TYPE_FORMAT, r.extent (nc), nc); dimensions = dim_vector (nr, nc); @@ -735,14 +738,16 @@ T Sparse<T>::range_error (const char *fcn, octave_idx_type n) const { - (*current_liboctave_error_handler) ("%s (%d): range error", fcn, n); + (*current_liboctave_error_handler) ("%s (%" OCTAVE_IDX_TYPE_FORMAT "): " + "range error", fcn, n); } template <typename T> T& Sparse<T>::range_error (const char *fcn, octave_idx_type n) { - (*current_liboctave_error_handler) ("%s (%d): range error", fcn, n); + (*current_liboctave_error_handler) ("%s (%" OCTAVE_IDX_TYPE_FORMAT "): " + "range error", fcn, n); } template <typename T> @@ -750,14 +755,18 @@ Sparse<T>::range_error (const char *fcn, octave_idx_type i, octave_idx_type j) const { - (*current_liboctave_error_handler) ("%s (%d, %d): range error", fcn, i, j); + (*current_liboctave_error_handler) + ("%s (%" OCTAVE_IDX_TYPE_FORMAT ", %" OCTAVE_IDX_TYPE_FORMAT "): " + "range error", fcn, i, j); } template <typename T> T& Sparse<T>::range_error (const char *fcn, octave_idx_type i, octave_idx_type j) { - (*current_liboctave_error_handler) ("%s (%d, %d): range error", fcn, i, j); + (*current_liboctave_error_handler) + ("%s (%" OCTAVE_IDX_TYPE_FORMAT ", %" OCTAVE_IDX_TYPE_FORMAT "): " + "range error", fcn, i, j); } template <typename T> @@ -781,7 +790,7 @@ std::string buf_str = buf.str (); - (*current_liboctave_error_handler) (buf_str.c_str ()); + (*current_liboctave_error_handler) ("%s", buf_str.c_str ()); } template <typename T> @@ -804,7 +813,7 @@ std::string buf_str = buf.str (); - (*current_liboctave_error_handler) (buf_str.c_str ()); + (*current_liboctave_error_handler) ("%s", buf_str.c_str ()); } template <typename T> @@ -2728,7 +2737,7 @@ std::string err_field; is >> err_field; (*current_liboctave_error_handler) - ("invalid sparse matrix: element %d: " + ("invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT ": " "Symbols '%s' is not an integer format", i+1, err_field.c_str ()); } @@ -2738,8 +2747,8 @@ is.setstate (std::ios::failbit); (*current_liboctave_error_handler) - ("invalid sparse matrix: element %d: " - "row index = %d out of range", + ("invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT ": " + "row index = %" OCTAVE_IDX_TYPE_FORMAT " out of range", i+1, itmp + 1); } @@ -2748,8 +2757,8 @@ is.setstate (std::ios::failbit); (*current_liboctave_error_handler) - ("invalid sparse matrix: element %d: " - "column index = %d out of range", + ("invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT ": " + "column index = %" OCTAVE_IDX_TYPE_FORMAT " out of range", i+1, jtmp + 1); } @@ -2758,8 +2767,9 @@ is.setstate (std::ios::failbit); (*current_liboctave_error_handler) - ("invalid sparse matrix: element %d:" - "column indices must appear in ascending order (%d < %d)", + ("invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT ":" + "column indices must appear in ascending order " + "(%" OCTAVE_IDX_TYPE_FORMAT " < %" OCTAVE_IDX_TYPE_FORMAT ")", i+1, jtmp, jold); } else if (jtmp > jold) @@ -2772,9 +2782,9 @@ is.setstate (std::ios::failbit); (*current_liboctave_error_handler) - ("invalid sparse matrix: element %d: " + ("invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT ": " "row indices must appear in ascending order in each column " - "(%d < %d)", + "(%" OCTAVE_IDX_TYPE_FORMAT " < %" OCTAVE_IDX_TYPE_FORMAT ")", i+1, iold, itmp); }
--- a/liboctave/array/idx-vector.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/array/idx-vector.cc Fri Jan 18 13:51:23 2019 -0800 @@ -26,6 +26,7 @@ # include "config.h" #endif +#include <cinttypes> #include <cstdlib> #include <ostream> @@ -1285,7 +1286,7 @@ if (! resize_ok && extent (z_len) > z_len) { (*current_liboctave_error_handler) - ("invalid matrix index = %d", extent (z_len)); + ("invalid matrix index = %" OCTAVE_IDX_TYPE_FORMAT, extent (z_len)); // FIXME: Should we call this before calling error_handler? rep->err = true; chkerr ();
--- a/liboctave/numeric/DASPK.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/numeric/DASPK.cc Fri Jan 18 13:51:23 2019 -0800 @@ -24,6 +24,7 @@ # include "config.h" #endif +#include <cinttypes> #include <sstream> #include "DASPK.h" @@ -359,7 +360,8 @@ lid = 40 + n; else (*current_liboctave_error_handler) - ("daspk: invalid value for eiq: %d", eiq); + ("daspk: invalid value for eiq: " + "%" OCTAVE_IDX_TYPE_FORMAT, eiq); for (F77_INT i = 0; i < n; i++) iwork(lid+i) = (av(i) ? -1 : 1); @@ -404,7 +406,8 @@ lid = 40 + n; else (*current_liboctave_error_handler) - ("daspk: invalid value for eiq: %d", eiq); + ("daspk: invalid value for eiq: %" OCTAVE_IDX_TYPE_FORMAT, + eiq); for (F77_INT i = 0; i < n; i++) iwork(lid+i) = (av(i) ? -1 : 1); @@ -533,7 +536,8 @@ default: integration_error = true; (*current_liboctave_error_handler) - ("unrecognized value of istate (= %d) returned from ddaspk", istate); + ("unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT ") " + "returned from ddaspk", istate); break; }
--- a/liboctave/numeric/DASRT.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/numeric/DASRT.cc Fri Jan 18 13:51:23 2019 -0800 @@ -24,6 +24,7 @@ # include "config.h" #endif +#include <cinttypes> #include <sstream> #include "DASRT.h" @@ -374,8 +375,8 @@ default: integration_error = true; (*current_liboctave_error_handler) - ("unrecognized value of istate (= %d) returned from ddasrt", - istate); + ("unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT ") " + "returned from ddasrt", istate); break; } }
--- a/liboctave/numeric/DASSL.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/numeric/DASSL.cc Fri Jan 18 13:51:23 2019 -0800 @@ -24,6 +24,7 @@ # include "config.h" #endif +#include <cinttypes> #include <sstream> #include "DASSL.h" @@ -337,8 +338,8 @@ default: integration_error = true; (*current_liboctave_error_handler) - ("unrecognized value of istate (= %d) returned from ddassl", - istate); + ("unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT ") " + "returned from ddassl", istate); break; }
--- a/liboctave/numeric/LSODE.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/numeric/LSODE.cc Fri Jan 18 13:51:23 2019 -0800 @@ -24,6 +24,7 @@ # include "config.h" #endif +#include <cinttypes> #include <sstream> #include "LSODE.h" @@ -302,7 +303,8 @@ default: integration_error = true; (*current_liboctave_error_handler) - ("unrecognized value of istate (= %d) returned from lsode", istate); + ("unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT ") " + "returned from lsode", istate); break; }
--- a/liboctave/numeric/oct-norm.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/numeric/oct-norm.cc Fri Jan 18 13:51:23 2019 -0800 @@ -501,7 +501,7 @@ res = higham (m, p, sqrteps, max_norm_iter, x); } else - (*current_liboctave_error_handler) (p_less1_gripe); + (*current_liboctave_error_handler) ("%s", p_less1_gripe); return res; } @@ -522,7 +522,7 @@ res = higham (m, p, sqrteps, max_norm_iter, x); } else - (*current_liboctave_error_handler) (p_less1_gripe); + (*current_liboctave_error_handler) ("%s", p_less1_gripe); return res; }
--- a/liboctave/util/f77-fcn.c Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/util/f77-fcn.c Fri Jan 18 13:51:23 2019 -0800 @@ -53,7 +53,7 @@ slen = strlen (s); } - (*current_liboctave_error_handler) ("%.*s", slen, s); + (*current_liboctave_error_handler) ("%.*s", (int) slen, s); F77_NORETURN (0) }
--- a/liboctave/util/lo-array-errwarn.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/util/lo-array-errwarn.cc Fri Jan 18 13:51:23 2019 -0800 @@ -24,6 +24,7 @@ # include "config.h" #endif +#include <cinttypes> #include <cmath> #include <sstream> @@ -66,7 +67,8 @@ const char *err_id = error_id_nonconformant_args; (*current_liboctave_error_with_id_handler) - (err_id, "%s: nonconformant arguments (op1 len: %d, op2 len: %d)", + (err_id, "%s: nonconformant arguments (op1 len: %" OCTAVE_IDX_TYPE_FORMAT + ", op2 len: % " OCTAVE_IDX_TYPE_FORMAT ")", op, op1_len, op2_len); } @@ -78,7 +80,9 @@ const char *err_id = error_id_nonconformant_args; (*current_liboctave_error_with_id_handler) - (err_id, "%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", + (err_id, "%s: nonconformant arguments " + "(op1 is %" OCTAVE_IDX_TYPE_FORMAT "x%" OCTAVE_IDX_TYPE_FORMAT ", " + "op2 is %" OCTAVE_IDX_TYPE_FORMAT"x%" OCTAVE_IDX_TYPE_FORMAT ")", op, op1_nr, op1_nc, op2_nr, op2_nc); } @@ -103,7 +107,8 @@ const char *err_id = error_id_index_out_of_bounds; (*current_liboctave_error_with_id_handler) - (err_id, "A(%s) = []: index out of bounds: value %d out of bound %d", + (err_id, "A(%s) = []: index out of bounds: value %" OCTAVE_IDX_TYPE_FORMAT + " out of bound %" OCTAVE_IDX_TYPE_FORMAT, is1d ? "I" : "..,I,..", idx, ext); }
--- a/liboctave/util/lo-error.h Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/util/lo-error.h Fri Jan 18 13:51:23 2019 -0800 @@ -53,14 +53,18 @@ /* Would be nice to make these pointers private, but we want to share them among all the liboctave classes. */ +OCTAVE_FORMAT_PRINTF (1, 2) OCTAVE_NORETURN OCTAVE_API extern liboctave_error_handler current_liboctave_error_handler; +OCTAVE_FORMAT_PRINTF (2, 3) OCTAVE_NORETURN OCTAVE_API extern liboctave_error_with_id_handler current_liboctave_error_with_id_handler; +OCTAVE_FORMAT_PRINTF (1, 2) OCTAVE_API extern liboctave_warning_handler current_liboctave_warning_handler; +OCTAVE_FORMAT_PRINTF (2, 3) OCTAVE_API extern liboctave_warning_with_id_handler current_liboctave_warning_with_id_handler;
--- a/liboctave/util/lo-utils.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/util/lo-utils.cc Fri Jan 18 13:51:23 2019 -0800 @@ -233,7 +233,8 @@ break; default: - (*current_liboctave_error_handler) ("read_inf_nan_na: invalid character '%c'"); + (*current_liboctave_error_handler) + ("read_inf_nan_na: invalid character '%c'", c0); } return val;
--- a/liboctave/util/sparse-util.cc Thu Jan 17 19:55:17 2019 -0800 +++ b/liboctave/util/sparse-util.cc Fri Jan 18 13:51:23 2019 -0800 @@ -25,6 +25,7 @@ # include "config.h" #endif +#include <cinttypes> #include <cstdarg> #include <cstdio> @@ -101,8 +102,9 @@ if (c[j] > nnz) (*current_liboctave_error_handler) - ("invalid sparse matrix: cidx[%d] = %d " - "exceeds number of nonzero elements", j, c[j]+1); + ("invalid sparse matrix: cidx[%" OCTAVE_IDX_TYPE_FORMAT "] = " + "%" OCTAVE_IDX_TYPE_FORMAT " exceeds number of nonzero elements", + j, c[j]+1); if (c[j] != jold) { @@ -115,7 +117,8 @@ if (r[i] >= nrows) (*current_liboctave_error_handler) - ("invalid sparse matrix: ridx[%d] = %d out of range", + ("invalid sparse matrix: ridx[%" OCTAVE_IDX_TYPE_FORMAT + "] = %" OCTAVE_IDX_TYPE_FORMAT " out of range", i, r[i]+1); }