comparison libinterp/parse-tree/oct-parse.yy @ 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
2282 parser.bison_error (s); 2282 parser.bison_error (s);
2283 } 2283 }
2284 2284
2285 namespace octave 2285 namespace octave
2286 { 2286 {
2287 size_t 2287 std::size_t
2288 base_parser::parent_scope_info::size (void) const 2288 base_parser::parent_scope_info::size (void) const
2289 { 2289 {
2290 return m_info.size (); 2290 return m_info.size ();
2291 } 2291 }
2292 2292
2316 // tree structure of names, or we can just store the set of 2316 // tree structure of names, or we can just store the set of
2317 // full names of all the functions, which must be unique. 2317 // full names of all the functions, which must be unique.
2318 2318
2319 std::string full_name; 2319 std::string full_name;
2320 2320
2321 for (size_t i = 0; i < size()-1; i++) 2321 for (std::size_t i = 0; i < size()-1; i++)
2322 { 2322 {
2323 const value_type& elt = m_info[i]; 2323 const value_type& elt = m_info[i];
2324 2324
2325 if (name == elt.second) 2325 if (name == elt.second)
2326 return false; 2326 return false;
3636 // preprocessed when we get here? It seems to only be a 3636 // preprocessed when we get here? It seems to only be a
3637 // problem with relative filenames. 3637 // problem with relative filenames.
3638 3638
3639 std::string nm = m_lexer.m_fcn_file_name; 3639 std::string nm = m_lexer.m_fcn_file_name;
3640 3640
3641 size_t pos = nm.find_last_of (sys::file_ops::dir_sep_chars ()); 3641 std::size_t pos = nm.find_last_of (sys::file_ops::dir_sep_chars ());
3642 3642
3643 if (pos != std::string::npos) 3643 if (pos != std::string::npos)
3644 nm = m_lexer.m_fcn_file_name.substr (pos+1); 3644 nm = m_lexer.m_fcn_file_name.substr (pos+1);
3645 3645
3646 if (nm != id_name) 3646 if (nm != id_name)
3877 3877
3878 std::string cls_name = id->name (); 3878 std::string cls_name = id->name ();
3879 3879
3880 std::string nm = m_lexer.m_fcn_file_name; 3880 std::string nm = m_lexer.m_fcn_file_name;
3881 3881
3882 size_t pos = nm.find_last_of (sys::file_ops::dir_sep_chars ()); 3882 std::size_t pos = nm.find_last_of (sys::file_ops::dir_sep_chars ());
3883 3883
3884 if (pos != std::string::npos) 3884 if (pos != std::string::npos)
3885 nm = m_lexer.m_fcn_file_name.substr (pos+1); 3885 nm = m_lexer.m_fcn_file_name.substr (pos+1);
3886 3886
3887 if (nm != cls_name) 3887 if (nm != cls_name)
4398 } 4398 }
4399 4399
4400 std::string va_type = (type == tree_parameter_list::in 4400 std::string va_type = (type == tree_parameter_list::in
4401 ? "varargin" : "varargout"); 4401 ? "varargin" : "varargout");
4402 4402
4403 size_t len = lst->length (); 4403 std::size_t len = lst->length ();
4404 4404
4405 if (len > 0) 4405 if (len > 0)
4406 { 4406 {
4407 tree_decl_elt *elt = lst->back (); 4407 tree_decl_elt *elt = lst->back ();
4408 4408
4741 { 4741 {
4742 // FIXME: we could do better if we just cached lines from the 4742 // FIXME: we could do better if we just cached lines from the
4743 // input file in a list. See also functions for managing input 4743 // input file in a list. See also functions for managing input
4744 // buffers in lex.ll. 4744 // buffers in lex.ll.
4745 4745
4746 size_t len = curr_line.length (); 4746 std::size_t len = curr_line.length ();
4747 4747
4748 if (curr_line[len-1] == '\n') 4748 if (curr_line[len-1] == '\n')
4749 curr_line.resize (len-1); 4749 curr_line.resize (len-1);
4750 4750
4751 // Print the line, maybe with a pointer near the error token. 4751 // Print the line, maybe with a pointer near the error token.
5072 5072
5073 full_file = fcn_file_in_path (nm); 5073 full_file = fcn_file_in_path (nm);
5074 5074
5075 std::string file = full_file; 5075 std::string file = full_file;
5076 5076
5077 size_t file_len = file.length (); 5077 std::size_t file_len = file.length ();
5078 5078
5079 if ((file_len > 4 && file.substr (file_len-4) == ".oct") 5079 if ((file_len > 4 && file.substr (file_len-4) == ".oct")
5080 || (file_len > 4 && file.substr (file_len-4) == ".mex") 5080 || (file_len > 4 && file.substr (file_len-4) == ".mex")
5081 || (file_len > 2 && file.substr (file_len-2) == ".m")) 5081 || (file_len > 2 && file.substr (file_len-2) == ".m"))
5082 { 5082 {
5083 file = sys::env::base_pathname (file); 5083 file = sys::env::base_pathname (file);
5084 file = file.substr (0, file.find_last_of ('.')); 5084 file = file.substr (0, file.find_last_of ('.'));
5085 5085
5086 size_t pos = file.find_last_of (sys::file_ops::dir_sep_str ()); 5086 std::size_t pos = file.find_last_of (sys::file_ops::dir_sep_str ());
5087 if (pos != std::string::npos) 5087 if (pos != std::string::npos)
5088 file = file.substr (pos+1); 5088 file = file.substr (pos+1);
5089 } 5089 }
5090 5090
5091 if (! file.empty ()) 5091 if (! file.empty ())
5128 5128
5129 unwind_protect frame; 5129 unwind_protect frame;
5130 5130
5131 std::string nm = file_name; 5131 std::string nm = file_name;
5132 5132
5133 size_t nm_len = nm.length (); 5133 std::size_t nm_len = nm.length ();
5134 5134
5135 std::string file; 5135 std::string file;
5136 5136
5137 bool relative_lookup = false; 5137 bool relative_lookup = false;
5138 5138
5143 || (nm_len > 2 && nm.substr (nm_len-2) == ".m")) 5143 || (nm_len > 2 && nm.substr (nm_len-2) == ".m"))
5144 { 5144 {
5145 nm = sys::env::base_pathname (file); 5145 nm = sys::env::base_pathname (file);
5146 nm = nm.substr (0, nm.find_last_of ('.')); 5146 nm = nm.substr (0, nm.find_last_of ('.'));
5147 5147
5148 size_t pos = nm.find_last_of (sys::file_ops::dir_sep_str ()); 5148 std::size_t pos = nm.find_last_of (sys::file_ops::dir_sep_str ());
5149 if (pos != std::string::npos) 5149 if (pos != std::string::npos)
5150 nm = nm.substr (pos+1); 5150 nm = nm.substr (pos+1);
5151 } 5151 }
5152 5152
5153 relative_lookup = ! sys::env::absolute_pathname (file); 5153 relative_lookup = ! sys::env::absolute_pathname (file);
5911 5911
5912 full_file = octave::sys::env::make_absolute (full_file); 5912 full_file = octave::sys::env::make_absolute (full_file);
5913 5913
5914 std::string dir_name; 5914 std::string dir_name;
5915 5915
5916 size_t file_len = file.length (); 5916 std::size_t file_len = file.length ();
5917 5917
5918 if ((file_len > 4 && file.substr (file_len-4) == ".oct") 5918 if ((file_len > 4 && file.substr (file_len-4) == ".oct")
5919 || (file_len > 4 && file.substr (file_len-4) == ".mex") 5919 || (file_len > 4 && file.substr (file_len-4) == ".mex")
5920 || (file_len > 2 && file.substr (file_len-2) == ".m")) 5920 || (file_len > 2 && file.substr (file_len-2) == ".m"))
5921 { 5921 {
5922 file = octave::sys::env::base_pathname (file); 5922 file = octave::sys::env::base_pathname (file);
5923 file = file.substr (0, file.find_last_of ('.')); 5923 file = file.substr (0, file.find_last_of ('.'));
5924 5924
5925 size_t pos = file.find_last_of (octave::sys::file_ops::dir_sep_str ()); 5925 std::size_t pos = file.find_last_of (octave::sys::file_ops::dir_sep_str ());
5926 if (pos != std::string::npos) 5926 if (pos != std::string::npos)
5927 { 5927 {
5928 dir_name = file.substr (0, pos); 5928 dir_name = file.substr (0, pos);
5929 file = file.substr (pos+1); 5929 file = file.substr (pos+1);
5930 } 5930 }