comparison libinterp/corefcn/pr-output.cc @ 29654:d13d090cb03a stable

use std::size_t and std::ptrdiff_t in C++ code (bug #60471) Files affected: make_int.cc, file-editor-tab.cc, octave-qscintilla.cc, Cell.cc, Cell.h, call-stack.cc, call-stack.h, cellfun.cc, data.cc, debug.cc, dlmread.cc, error.cc, event-queue.h, fcn-info.cc, fcn-info.h, file-io.cc, ft-text-renderer.cc, gl2ps-print.cc, graphics.cc, graphics.in.h, help.cc, hex2num.cc, input.cc, latex-text-renderer.cc, load-path.cc, load-save.cc, load-save.h, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat5.cc, ls-oct-text.cc, mex.cc, mexproto.h, mxarray.h, oct-map.cc, oct-stream.cc, oct-stream.h, pager.cc, pager.h, pr-output.cc, regexp.cc, settings.h, stack-frame.cc, stack-frame.h, strfns.cc, syminfo.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, sysdep.cc, toplev.cc, utils.cc, utils.h, variables.cc, __fltk_uigetfile__.cc, __init_fltk__.cc, audioread.cc, gzip.cc, cdef-class.cc, cdef-manager.cc, cdef-method.cc, cdef-object.cc, cdef-object.h, ov-base-diag.cc, ov-base-diag.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-fcn-handle.cc, ov-java.cc, ov-lazy-idx.h, ov-perm.cc, ov-perm.h, ov-range.h, ov-str-mat.cc, ov-struct.cc, ov-struct.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, octave.cc, bp-table.cc, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.h, lex.h, lex.ll, oct-lvalue.cc, oct-parse.yy, parse.h, profiler.h, pt-eval.cc, pt-eval.h, pt-jit.cc, pt-jit.h, pt-pr-code.cc, pt-tm-const.cc, pt-tm-const.h, Array.h, CMatrix.cc, DiagArray2.h, PermMatrix.h, Sparse.h, dMatrix.cc, fCMatrix.cc, fMatrix.cc, bsxfun-defs.cc, oct-fftw.cc, oct-fftw.h, randpoisson.cc, sparse-chol.cc, mx-inlines.cc, file-ops.cc, lo-sysdep.cc, oct-env.cc, oct-time.cc, action-container.cc, action-container.h, base-list.h, caseless-str.h, cmd-edit.cc, cmd-hist.cc, data-conv.cc, data-conv.h, f77-fcn.h, file-info.cc, file-info.h, kpse.cc, kpse.h, lo-cutils.h, lo-hash.h, lo-regexp.cc, oct-base64.cc, oct-base64.h, oct-binmap.h, oct-glob.cc, oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sparse.h, oct-string.cc, quit.cc, unwind-prot.h, url-transfer.cc, main.in.cc, mkoctfile.in.cc, and shared-fcns.h. (grafted from aef11bb4e6d1f303ad9de5688fcb7244ef48867e)
author John W. Eaton <jwe@octave.org>
date Wed, 28 Apr 2021 22:57:42 -0400
parents 0a5b15007766
children 32f4357ac8d9
comparison
equal deleted inserted replaced
29652:5068a97f0f39 29654:d13d090cb03a
1423 os.flags (std::ios::right | std::ios::hex); 1423 os.flags (std::ios::right | std::ios::hex);
1424 1424
1425 if (hex_format > 1 1425 if (hex_format > 1
1426 || flt_fmt == octave::mach_info::flt_fmt_ieee_big_endian) 1426 || flt_fmt == octave::mach_info::flt_fmt_ieee_big_endian)
1427 { 1427 {
1428 for (size_t i = 0; i < sizeof (T); i++) 1428 for (std::size_t i = 0; i < sizeof (T); i++)
1429 os << std::setw (2) << static_cast<int> (tmp.i[i]); 1429 os << std::setw (2) << static_cast<int> (tmp.i[i]);
1430 } 1430 }
1431 else 1431 else
1432 { 1432 {
1433 for (int i = sizeof (T) - 1; i >= 0; i--) 1433 for (int i = sizeof (T) - 1; i >= 0; i--)
1442 octave::mach_info::float_format flt_fmt 1442 octave::mach_info::float_format flt_fmt
1443 = octave::mach_info::native_float_format (); 1443 = octave::mach_info::native_float_format ();
1444 1444
1445 if (flt_fmt == octave::mach_info::flt_fmt_ieee_big_endian) 1445 if (flt_fmt == octave::mach_info::flt_fmt_ieee_big_endian)
1446 { 1446 {
1447 for (size_t i = 0; i < sizeof (T); i++) 1447 for (std::size_t i = 0; i < sizeof (T); i++)
1448 PRINT_CHAR_BITS (os, tmp.i[i]); 1448 PRINT_CHAR_BITS (os, tmp.i[i]);
1449 } 1449 }
1450 else 1450 else
1451 { 1451 {
1452 if (bit_format > 1) 1452 if (bit_format > 1)
1453 { 1453 {
1454 for (size_t i = 0; i < sizeof (T); i++) 1454 for (std::size_t i = 0; i < sizeof (T); i++)
1455 PRINT_CHAR_BITS_SWAPPED (os, tmp.i[i]); 1455 PRINT_CHAR_BITS_SWAPPED (os, tmp.i[i]);
1456 } 1456 }
1457 else 1457 else
1458 { 1458 {
1459 for (int i = sizeof (T) - 1; i >= 0; i--) 1459 for (int i = sizeof (T) - 1; i >= 0; i--)
2810 2810
2811 template <typename T> 2811 template <typename T>
2812 static inline void 2812 static inline void
2813 pr_int (std::ostream& os, const T& d, int fw = 0) 2813 pr_int (std::ostream& os, const T& d, int fw = 0)
2814 { 2814 {
2815 size_t sz = d.byte_size (); 2815 std::size_t sz = d.byte_size ();
2816 const unsigned char *tmpi = d.iptr (); 2816 const unsigned char *tmpi = d.iptr ();
2817 2817
2818 // Unless explicitly asked for, always print in big-endian 2818 // Unless explicitly asked for, always print in big-endian
2819 // format for hex and bit formats. 2819 // format for hex and bit formats.
2820 // 2820 //
2831 else 2831 else
2832 os.flags (std::ios::right | std::ios::hex); 2832 os.flags (std::ios::right | std::ios::hex);
2833 2833
2834 if (hex_format > 1 || octave::mach_info::words_big_endian ()) 2834 if (hex_format > 1 || octave::mach_info::words_big_endian ())
2835 { 2835 {
2836 for (size_t i = 0; i < sz; i++) 2836 for (std::size_t i = 0; i < sz; i++)
2837 os << std::setw (2) << static_cast<int> (tmpi[i]); 2837 os << std::setw (2) << static_cast<int> (tmpi[i]);
2838 } 2838 }
2839 else 2839 else
2840 { 2840 {
2841 for (int i = sz - 1; i >= 0; i--) 2841 for (int i = sz - 1; i >= 0; i--)
2844 } 2844 }
2845 else if (bit_format) 2845 else if (bit_format)
2846 { 2846 {
2847 if (octave::mach_info::words_big_endian ()) 2847 if (octave::mach_info::words_big_endian ())
2848 { 2848 {
2849 for (size_t i = 0; i < sz; i++) 2849 for (std::size_t i = 0; i < sz; i++)
2850 PRINT_CHAR_BITS (os, tmpi[i]); 2850 PRINT_CHAR_BITS (os, tmpi[i]);
2851 } 2851 }
2852 else 2852 else
2853 { 2853 {
2854 if (bit_format > 1) 2854 if (bit_format > 1)
2855 { 2855 {
2856 for (size_t i = 0; i < sz; i++) 2856 for (std::size_t i = 0; i < sz; i++)
2857 PRINT_CHAR_BITS_SWAPPED (os, tmpi[i]); 2857 PRINT_CHAR_BITS_SWAPPED (os, tmpi[i]);
2858 } 2858 }
2859 else 2859 else
2860 { 2860 {
2861 for (int i = sz - 1; i >= 0; i--) 2861 for (int i = sz - 1; i >= 0; i--)
3262 arg.print (buf); 3262 arg.print (buf);
3263 std::string s = buf.str (); 3263 std::string s = buf.str ();
3264 3264
3265 std::list<std::string> lst; 3265 std::list<std::string> lst;
3266 3266
3267 size_t n = 0; 3267 std::size_t n = 0;
3268 size_t s_len = s.length (); 3268 std::size_t s_len = s.length ();
3269 3269
3270 while (n < s_len) 3270 while (n < s_len)
3271 { 3271 {
3272 size_t m = s.find ('\n', n); 3272 std::size_t m = s.find ('\n', n);
3273 3273
3274 if (m == std::string::npos) 3274 if (m == std::string::npos)
3275 { 3275 {
3276 lst.push_back (s.substr (n)); 3276 lst.push_back (s.substr (n));
3277 break; 3277 break;