Mercurial > jwe > octave
changeset 22862:e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
* symtab.cc, call-stack.cc, comment-list.cc, defun.cc, dynamic-ld.cc,
error.cc, ft-text-renderer.cc, gl2ps-print.cc, graphics.cc, help.cc,
interpreter.cc, load-path.cc, load-save.cc, ls-mat5.cc, oct-errno.in.cc,
oct-map.cc, oct-stream.cc, octave-link.cc, profiler.cc, regexp.cc, strfind.cc,
symtab.h, txt-eng.h, urlwrite.cc, variables.cc:
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/call-stack.cc Mon Dec 05 13:04:12 2016 -0800 @@ -419,17 +419,14 @@ octave_idx_type k = 0; - for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin (); - p != frames.end (); p++) + for (const auto& frm : frames) { - const stack_frame& elt = *p; - - scope(k) = elt.m_scope; - context(k) = elt.m_context; - file(k) = elt.fcn_file_name (); - name(k) = elt.fcn_name (print_subfn); - line(k) = elt.m_line; - column(k) = elt.m_column; + scope(k) = frm.m_scope; + context(k) = frm.m_context; + file(k) = frm.fcn_file_name (); + name(k) = frm.fcn_name (print_subfn); + line(k) = frm.m_line; + column(k) = frm.m_column; k++; }
--- a/libinterp/corefcn/comment-list.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/comment-list.cc Mon Dec 05 13:04:12 2016 -0800 @@ -34,12 +34,8 @@ { octave_comment_list *new_cl = new octave_comment_list (); - for (const_iterator p = begin (); p != end (); p++) - { - const octave_comment_elt elt = *p; - - new_cl->append (elt); - } + for (const auto& elt : *this) + new_cl->append (elt); return new_cl; }
--- a/libinterp/corefcn/defun.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/defun.cc Mon Dec 05 13:04:12 2016 -0800 @@ -153,17 +153,17 @@ { const std::list<octave_lvalue> *lvalue_list = octave_builtin::curr_lvalue_list; + if (iout >= std::max (nargout, 1)) return false; else if (lvalue_list) { int k = 0; - for (std::list<octave_lvalue>::const_iterator p = lvalue_list->begin (); - p != lvalue_list->end (); p++) + for (const auto& lval : *lvalue_list) { if (k == iout) - return ! p->is_black_hole (); - k += p->numel (); + return ! lval.is_black_hole (); + k += lval.numel (); if (k > iout) break; } @@ -182,14 +182,13 @@ if (lvalue_list) { int k = 0; - for (std::list<octave_lvalue>::const_iterator p = lvalue_list->begin (); - p != lvalue_list->end () && k < nout; p++) + for (const auto& lval : *lvalue_list) { - if (p->is_black_hole ()) + if (lval.is_black_hole ()) isargout[k++] = false; else { - int l = std::min (k + p->numel (), + int l = std::min (k + lval.numel (), static_cast<octave_idx_type> (nout)); while (k < l) isargout[k++] = true;
--- a/libinterp/corefcn/dynamic-ld.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/dynamic-ld.cc Mon Dec 05 13:04:12 2016 -0800 @@ -127,11 +127,11 @@ { octave::dynamic_library retval; - for (const_iterator p = lib_list.begin (); p != lib_list.end (); p++) + for (const auto& lib : lib_list) { - if (p->file_name () == file_name) + if (lib.file_name () == file_name) { - retval = *p; + retval = lib; break; } } @@ -143,8 +143,8 @@ octave_shlib_list::do_display (void) const { std::cerr << "current shared libraries:" << std::endl; - for (const_iterator p = lib_list.begin (); p != lib_list.end (); p++) - std::cerr << " " << p->file_name () << std::endl; + for (const auto& lib : lib_list) + std::cerr << " " << lib.file_name () << std::endl; } bool
--- a/libinterp/corefcn/error.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/error.cc Mon Dec 05 13:04:12 2016 -0800 @@ -285,14 +285,11 @@ if (nframes > 0) pr_where_1 (os, "%s: called from\n", who); - for (std::list<error_stack_frame>::const_iterator p = frames.begin (); - p != frames.end (); p++) + for (const auto& frm : frames) { - const error_stack_frame& elt = *p; - - std::string fcn_name = elt.name; - int line = elt.line; - int column = elt.column; + std::string fcn_name = frm.name; + int line = frm.line; + int column = frm.column; if (line > 0) { @@ -318,16 +315,13 @@ call_stack_frames.unique (); std::list<error_stack_frame> frames; - for (std::list<octave_call_stack::stack_frame>::const_iterator p = call_stack_frames.begin (); - p != call_stack_frames.end (); p++) + for (const auto& frm : call_stack_frames) { - const octave_call_stack::stack_frame& elt = *p; - error_stack_frame frame; - frame.name = elt.fcn_name (); - frame.line = elt.line (); - frame.column = elt.column (); + frame.name = frm.fcn_name (); + frame.line = frm.line (); + frame.column = frm.column (); frames.push_back (frame); }
--- a/libinterp/corefcn/ft-text-renderer.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/ft-text-renderer.cc Mon Dec 05 13:04:12 2016 -0800 @@ -601,16 +601,15 @@ break; default: - for (std::list<Matrix>::const_iterator it = line_bbox.begin (); - it != line_bbox.end (); ++it) + for (const auto& lbox : line_bbox) { if (bbox.is_empty ()) - bbox = it->extract (0, 0, 0, 3); + bbox = lbox.extract (0, 0, 0, 3); else { - bbox(1) -= (*it)(3); - bbox(3) += (*it)(3); - bbox(2) = octave::math::max (bbox(2), (*it)(2)); + bbox(1) -= lbox(3); + bbox(3) += lbox(3); + bbox(2) = octave::math::max (bbox(2), lbox(2)); } } break; @@ -1075,10 +1074,10 @@ int saved_xoffset = xoffset; int max_xoffset = xoffset; - for (text_element_combined::iterator it = e.begin (); it != e.end (); ++it) + for (auto *txt_elt : e) { xoffset = saved_xoffset; - (*it)->accept (*this); + txt_elt->accept (*this); max_xoffset = octave::math::max (xoffset, max_xoffset); }
--- a/libinterp/corefcn/gl2ps-print.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/gl2ps-print.cc Mon Dec 05 13:04:12 2016 -0800 @@ -374,26 +374,26 @@ Matrix box, double rotation, std::list<octave::text_renderer::string>& lst) { - for (std::list<octave::text_renderer::string>::iterator p = lst.begin (); - p != lst.end (); p++) + for (auto& txtobj : lst) { // Get pixel coordinates ColumnVector coord_pix = get_transform ().transform (x, y, z, false); // Translate and rotate double rot = rotation * 4.0 * atan (1.0) / 180; - coord_pix(0) += ((*p).get_x () + box(0))*cos (rot) - - ((*p).get_y () + box(1))*sin (rot); - coord_pix(1) -= ((*p).get_y () + box(1))*cos (rot) - + ((*p).get_x () + box(0))*sin (rot);; + coord_pix(0) += (txtobj.get_x () + box(0))*cos (rot) + - (txtobj.get_y () + box(1))*sin (rot); + coord_pix(1) -= (txtobj.get_y () + box(1))*cos (rot) + + (txtobj.get_x () + box(0))*sin (rot); // Turn coordinates back into current gl coordinates - ColumnVector coord = - get_transform ().untransform (coord_pix(0), coord_pix(1), - coord_pix(2), false); - (*p).set_x (coord(0)); - (*p).set_y (coord(1)); - (*p).set_z (coord(2)); + ColumnVector coord = get_transform ().untransform (coord_pix(0), + coord_pix(1), + coord_pix(2), + false); + txtobj.set_x (coord(0)); + txtobj.set_y (coord(1)); + txtobj.set_z (coord(2)); } } } @@ -647,7 +647,7 @@ glRasterPos3d (x, y, z); - // Escape parenthesis until gl2ps does it (see bug ##45301). + // Escape parentheses until gl2ps does it (see bug #45301). if (term.find ("svg") == std::string::npos && term.find ("tex") == std::string::npos) { @@ -663,13 +663,12 @@ // Translate and rotate coordinates in order to use bottom-left alignment fix_strlist_position (x, y, z, bbox, rotation, lst); - for (std::list<octave::text_renderer::string>::iterator p = lst.begin (); - p != lst.end (); p++) + for (const auto& txtobj : lst) { - fontname = select_font ((*p).get_name (), - (*p).get_weight () == "bold", - (*p).get_angle () == "italic"); - if ((*p).get_code ()) + fontname = select_font (txtobj.get_name (), + txtobj.get_weight () == "bold", + txtobj.get_angle () == "italic"); + if (txtobj.get_code ()) { // This is only one character represented by a uint32 (utf8) code. // We replace it by the corresponding character in the @@ -677,18 +676,18 @@ if (term.find ("svg") == std::string::npos) { fontname = "Symbol"; - str = code_to_symbol ((*p).get_code ()); + str = code_to_symbol (txtobj.get_code ()); } else { std::stringstream ss; - ss << (*p).get_code (); + ss << txtobj.get_code (); str = "&#" + ss.str () + ";"; } } else { - str = (*p).get_string (); + str = txtobj.get_string (); // Escape parenthesis until gl2ps does it (see bug ##45301). if (term.find ("svg") == std::string::npos) { @@ -697,9 +696,9 @@ } } - set_color ((*p).get_color ()); - glRasterPos3d ((*p).get_x (), (*p).get_y (), (*p).get_z ()); - gl2psTextOpt (str.c_str (), fontname.c_str (), (*p).get_size (), + set_color (txtobj.get_color ()); + glRasterPos3d (txtobj.get_x (), txtobj.get_y (), txtobj.get_z ()); + gl2psTextOpt (str.c_str (), fontname.c_str (), txtobj.get_size (), GL2PS_TEXT_BL, rotation); }
--- a/libinterp/corefcn/graphics.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/graphics.cc Mon Dec 05 13:04:12 2016 -0800 @@ -1214,22 +1214,22 @@ radio_values::values_as_string (void) const { std::string retval; - for (std::set<caseless_str>::const_iterator it = possible_vals.begin (); - it != possible_vals.end (); it++) + + for (const auto& val : possible_vals) { if (retval.empty ()) { - if (*it == default_value ()) - retval = "{" + *it + "}"; + if (val == default_value ()) + retval = "{" + val + "}"; else - retval = *it; + retval = val; } else { - if (*it == default_value ()) - retval += " | {" + *it + "}"; + if (val == default_value ()) + retval += " | {" + val + "}"; else - retval += " | " + *it; + retval += " | " + val; } } @@ -1244,9 +1244,10 @@ { octave_idx_type i = 0; Cell retval (nelem (), 1); - for (std::set<caseless_str>::const_iterator it = possible_vals.begin (); - it != possible_vals.end (); it++) - retval(i++) = std::string (*it); + + for (const auto& val : possible_vals) + retval(i++) = std::string (val); + return retval; } @@ -2215,10 +2216,8 @@ { std::string prefix = prefix_arg + p->first; - const pval_map_type pval_map = p->second; - - for (const auto& prop_val_p : pval_map) - m.assign (prefix + prop_val_p.first, prop_val_p.second); + for (const auto& prop_val : p->second) + m.assign (prefix + prop_val.first, prop_val.second); } return m; @@ -2904,17 +2903,13 @@ property_list::pval_map_type pval; go.build_user_defaults_map (pval, go_name); - for (property_list::pval_map_const_iterator p = pval.begin (); - p != pval.end (); p++) - { - factory_pval[p->first] = p->second; - } + for (const auto& p : pval) + factory_pval[p.first] = p.second; // Reset defaults - for (property_list::pval_map_const_iterator it = factory_pval.begin (); - it != factory_pval.end (); it++) - { - std::string pname = it->first; + for (const auto& p : factory_pval) + { + std::string pname = p.first; // Don't reset internal properties and handle_properties if (! go.has_readonly_property (pname) @@ -2923,16 +2918,15 @@ { // Store *mode prop/val in order to set them last if (pname.find ("mode") == (pname.length () - 4)) - pval[pname] = it->second; + pval[pname] = p.second; else - go.set (pname, it->second); + go.set (pname, p.second); } } // set *mode properties - for (property_list::pval_map_const_iterator it = pval.begin (); - it != pval.end (); it++) - go.set (it->first, it->second); + for (const auto& p : pval) + go.set (p.first, p.second); } // --------------------------------------------------------------------- @@ -2949,13 +2943,13 @@ { const property_list::pval_map_type pval_map = plist->second; - for (const auto& prop_val_p : pval_map) - { - std::string pname = prop_val_p.first; + for (const auto& prop_val : pval_map) + { + std::string pname = prop_val.first; try { - bgo.set (pname, prop_val_p.second); + bgo.set (pname, prop_val.second); } catch (octave::execution_exception& e) { @@ -3251,7 +3245,7 @@ { octave_map m = get (true).map_value (); - for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++) + for (const auto& pm : m) { // FIXME: there has to be a better way. I think we want to // ask whether it is OK to delete the listener for the given @@ -3269,7 +3263,7 @@ try { - property p = get_properties ().get_property (pa->first); + property p = get_properties ().get_property (pm.first); if (p.ok ()) p.delete_listener (); @@ -3289,12 +3283,12 @@ if (it != local_defaults.end ()) { - property_list::pval_map_type pval = it->second; - for (const auto& prop_val_p : pval) - { - std::string pname = prop_val_p.first; + property_list::pval_map_type pval_lst = it->second; + for (const auto& prop_val : pval_lst) + { + std::string pname = prop_val.first; if (def.find (pname) == def.end ()) - def[pname] = prop_val_p.second; + def[pname] = prop_val.second; } } @@ -3331,23 +3325,23 @@ std::string base_graphics_object::values_as_string (void) { - std::string retval; - if (! valid_object ()) error ("base_graphics_object::values_as_string: invalid graphics object"); + std::string retval; octave_map m = get ().map_value (); graphics_object go = gh_manager::get_object (get_handle ()); - for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++) - { - if (pa->first != "children" && ! go.has_readonly_property (pa->first)) - { - property p = get_properties ().get_property (pa->first); + for (const auto& pm : m) + { + const auto& pname = pm.first; + if (pname != "children" && ! go.has_readonly_property (pname)) + { + property p = get_properties ().get_property (pname); if (p.ok () && ! p.is_hidden ()) { - retval += "\n\t" + std::string (pa->first) + ": "; + retval += "\n\t" + std::string (pname) + ": "; if (p.is_radio ()) retval += p.values_as_string (); } @@ -3398,13 +3392,12 @@ octave_scalar_map m = get ().scalar_map_value (); graphics_object go = gh_manager::get_object (get_handle ()); - for (octave_scalar_map::const_iterator pa = m.begin (); - pa != m.end (); pa++) - { - if (pa->first != "children" - && ! go.has_readonly_property (pa->first)) - { - property p = get_properties ().get_property (pa->first); + for (const auto& pm : m) + { + const auto& pname = pm.first; + if (pname != "children" && ! go.has_readonly_property (pname)) + { + property p = get_properties ().get_property (pname); if (p.ok () && ! p.is_hidden ()) {
--- a/libinterp/corefcn/help.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/help.cc Mon Dec 05 13:04:12 2016 -0800 @@ -208,11 +208,9 @@ // Loop over them. size_t i = 0; - for (std::list<std::string>::const_iterator p = names.begin (); - p != names.end (); p++) - retval(i++) = *p; + for (const auto& nm : names) + retval(i++) = nm; - retval.resize (i); return retval; } @@ -706,13 +704,12 @@ // loop over them. size_t i = 0; - for (std::list<std::string>::const_iterator p = names.begin (); - p != names.end (); p++) + for (const auto& nm : names) { - std::map<std::string, octave_value>::const_iterator q = h.find (*p); - if (q != h.end () && - ! q->second.user_function_value ()->is_nested_function ()) - retval(i++) = octave_value (new octave_fcn_handle (q->second, *p)); + std::map<std::string, octave_value>::const_iterator nm_fcn = h.find (nm); + if (nm_fcn != h.end () && + ! nm_fcn->second.user_function_value ()->is_nested_function ()) + retval(i++) = octave_value (new octave_fcn_handle (nm_fcn->second, nm)); } // remove pre-allocation for nested functions
--- a/libinterp/corefcn/interpreter.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/interpreter.cc Mon Dec 05 13:04:12 2016 -0800 @@ -267,12 +267,12 @@ { bool found = false; - for (std::list<std::string>::iterator p = octave_atexit_functions.begin (); - p != octave_atexit_functions.end (); p++) + for (auto it = octave_atexit_functions.begin (); + it != octave_atexit_functions.end (); it++) { - if (*p == fname) + if (*it == fname) { - octave_atexit_functions.erase (p); + octave_atexit_functions.erase (it); found = true; break; } @@ -583,9 +583,8 @@ std::list<std::string> command_line_path = options.command_line_path (); - for (std::list<std::string>::const_iterator it = command_line_path.begin (); - it != command_line_path.end (); it++) - load_path::set_command_line_path (*it); + for (const auto& pth : command_line_path) + load_path::set_command_line_path (pth); std::string exec_path = options.exec_path (); if (! exec_path.empty ())
--- a/libinterp/corefcn/load-path.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/load-path.cc Mon Dec 05 13:04:12 2016 -0800 @@ -395,11 +395,9 @@ { bool retval = false; - for (const_dir_info_list_iterator i = dir_info_list.begin (); - i != dir_info_list.end (); - i++) + for (const auto& d : dir_info_list) { - if (same_file (dir, i->dir_name)) + if (same_file (dir, d.dir_name)) { retval = true; break; @@ -436,20 +434,20 @@ continue; else { - for (file_info_list_iterator p = file_info_list.begin (); - p != file_info_list.end (); - p++) + for (auto fi_it = file_info_list.begin (); + fi_it != file_info_list.end (); + fi_it++) { - if (p->dir_name == dir_name) + if (fi_it->dir_name == dir_name) { - file_info fi = *p; - - file_info_list.erase (p); + file_info fi_tmp = *fi_it; + + file_info_list.erase (fi_it); if (at_end) - file_info_list.push_back (fi); + file_info_list.push_back (fi_tmp); else - file_info_list.push_front (fi); + file_info_list.push_front (fi_tmp); break; } @@ -461,38 +459,36 @@ void load_path::loader::move_method_map (const std::string& dir_name, bool at_end) { - for (method_map_iterator i = method_map.begin (); - i != method_map.end (); - i++) + for (auto& cls_fnmap : method_map) { - std::string class_name = i->first; - - fcn_map_type& fm = i->second; + std::string class_name = cls_fnmap.first; + + fcn_map_type& fn_map = cls_fnmap.second; std::string full_dir_name = octave::sys::file_ops::concat (dir_name, "@" + class_name); - for (fcn_map_iterator q = fm.begin (); q != fm.end (); q++) + for (auto& nm_filst : fn_map) { - file_info_list_type& file_info_list = q->second; + file_info_list_type& file_info_list = nm_filst.second; if (file_info_list.size () == 1) continue; else { - for (file_info_list_iterator p = file_info_list.begin (); - p != file_info_list.end (); p++) + for (auto fi_it = file_info_list.begin (); + fi_it != file_info_list.end (); fi_it++) { - if (p->dir_name == full_dir_name) + if (fi_it->dir_name == full_dir_name) { - file_info fi = *p; - - file_info_list.erase (p); + file_info fi_tmp = *fi_it; + + file_info_list.erase (fi_it); if (at_end) - file_info_list.push_back (fi); + file_info_list.push_back (fi_tmp); else - file_info_list.push_front (fi); + file_info_list.push_front (fi_tmp); break; } @@ -529,15 +525,14 @@ dir_info::package_dir_map_type package_dir_map = di.package_dir_map; - for (dir_info::const_package_dir_map_iterator p = package_dir_map.begin (); - p != package_dir_map.end (); ++p) + for (const auto& pkg_di : package_dir_map) { - std::string full_name = p->first; + std::string full_name = pkg_di.first; if (! pname.empty ()) full_name = pname + "." + full_name; - move (p->second, at_end, full_name); + move (pkg_di.second, at_end, full_name); } } @@ -674,10 +669,9 @@ init_dirs = elts_set; else { - for (std::set<std::string>::const_iterator it = init_dirs.begin (); - it != init_dirs.end (); it++) + for (const auto& init_dir : init_dirs) { - if (elts_set.find (*it) == elts_set.end ()) + if (elts_set.find (init_dir) == elts_set.end ()) { warning_with_id ("Octave:remove-init-dir", "default load path altered. Some built-in functions may not be found. Try restoredefaultpath() to recover it."); @@ -695,19 +689,18 @@ do_clear (); - for (std::list<std::string>::const_iterator i = elts.begin (); - i != elts.end (); i++) - do_append (*i, warn); + for (const auto& elt : elts) + do_append (elt, warn); // Restore add hook and execute for all newly added directories. frame.run_first (); - for (dir_info_list_iterator i = dir_info_list.begin (); - i != dir_info_list.end (); - i++) + // FIXME: Shouldn't the test for add_hook be outside the for loop? + // Why not use const here? Does add_hook change dir_info_list? + for (auto& di : dir_info_list) { if (add_hook) - add_hook (i->dir_name); + add_hook (di.dir_name); } // Always prepend current directory. @@ -824,13 +817,13 @@ file_info_list_type& file_info_list = fcn_map[base]; - for (file_info_list_iterator p = file_info_list.begin (); - p != file_info_list.end (); - p++) + for (auto fi_it = file_info_list.begin (); + fi_it != file_info_list.end (); + fi_it++) { - if (p->dir_name == dir) + if (fi_it->dir_name == dir) { - file_info_list.erase (p); + file_info_list.erase (fi_it); if (file_info_list.empty ()) fcn_map.erase (fname); @@ -853,35 +846,32 @@ void load_path::loader::remove_method_map (const std::string& dir) { - for (method_map_iterator i = method_map.begin (); - i != method_map.end (); - i++) + for (auto& cls_fnmap : method_map) { - std::string class_name = i->first; - - fcn_map_type& fm = i->second; + std::string class_name = cls_fnmap.first; + + fcn_map_type& fn_map = cls_fnmap.second; std::string full_dir_name = octave::sys::file_ops::concat (dir, "@" + class_name); - for (fcn_map_iterator q = fm.begin (); q != fm.end (); q++) + for (auto& nm_filst : fn_map) { - file_info_list_type& file_info_list = q->second; + file_info_list_type& file_info_list = nm_filst.second; if (file_info_list.size () == 1) continue; else { - for (file_info_list_iterator p = file_info_list.begin (); - p != file_info_list.end (); p++) + for (auto fi_it = file_info_list.begin (); + fi_it != file_info_list.end (); fi_it++) { - if (p->dir_name == full_dir_name) + if (fi_it->dir_name == full_dir_name) { - file_info_list.erase (p); - + file_info_list.erase (fi_it); // FIXME: if there are no other elements, we - // should remove this element of fm but calling - // erase here would invalidate the iterator q. + // should remove this element of fn_map but calling + // erase here would invalidate the iterator fi_it. break; } @@ -941,15 +931,14 @@ dir_info::package_dir_map_type package_dir_map = di.package_dir_map; - for (dir_info::const_package_dir_map_iterator p = package_dir_map.begin (); - p != package_dir_map.end (); ++p) + for (const auto& pkg_di : package_dir_map) { - std::string full_name = p->first; + std::string full_name = pkg_di.first; if (! pname.empty ()) full_name = pname + "." + full_name; - remove (p->second, full_name); + remove (pkg_di.second, full_name); } } @@ -980,12 +969,8 @@ loader_map.clear (); - for (dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (auto& di : dir_info_list) { - dir_info& di = *p; - di.update (); add (di, true, "", true); @@ -1118,12 +1103,8 @@ { const file_info_list_type& file_info_list = p->second; - for (const_file_info_list_iterator i = file_info_list.begin (); - i != file_info_list.end (); - i++) + for (const auto& fi : file_info_list) { - const file_info& fi = *i; - retval = octave::sys::file_ops::concat (fi.dir_name, fcn); if (check_file_type (retval, type, fi.types, @@ -1194,12 +1175,8 @@ { const file_info_list_type& file_info_list = p->second; - for (const_file_info_list_iterator i = file_info_list.begin (); - i != file_info_list.end (); - i++) + for (const auto& fi : file_info_list) { - const file_info& fi = *i; - retval = octave::sys::file_ops::concat (fi.dir_name, meth); bool found = check_file_type (retval, type, fi.types, @@ -1226,14 +1203,12 @@ // update (); - const_method_map_iterator q = method_map.find (class_name); - - if (q != method_map.end ()) + const_method_map_iterator mtd_map_it = method_map.find (class_name); + + if (mtd_map_it != method_map.end ()) { - const fcn_map_type& m = q->second; - - for (const_fcn_map_iterator p = m.begin (); p != m.end (); p++) - retval.push_back (p->first); + for (const auto& nm_filst : mtd_map_it->second) + retval.push_back (nm_filst.first); } if (! retval.empty ()) @@ -1245,11 +1220,9 @@ bool load_path::is_package (const std::string& name) const { - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto& di : dir_info_list) { - if (p->is_package (name)) + if (di.is_package (name)) return true; } @@ -1265,9 +1238,8 @@ default_loader.overloads (meth, retval); - for (const_loader_map_iterator l = loader_map.begin (); - l != loader_map.end (); ++l) - l->second.overloads (meth, retval); + for (const auto& nm_ldr : loader_map) + nm_ldr.second.overloads (meth, retval); return retval; } @@ -1276,14 +1248,13 @@ load_path::loader::overloads (const std::string& meth, std::list<std::string>& l) const { - for (const_method_map_iterator q = method_map.begin (); - q != method_map.end (); q++) + for (const auto& cls_fnmap : method_map) { - const fcn_map_type& m = q->second; + const fcn_map_type& m = cls_fnmap.second; if (m.find (meth) != m.end ()) { - std::string class_name = q->first; + std::string class_name = cls_fnmap.first; if (! prefix.empty ()) class_name = prefix + "." + class_name; @@ -1354,12 +1325,9 @@ { // Given name has a directory separator, so append it to each // element of the load path in turn. - - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto& di : dir_info_list) { - std::string tfile = octave::sys::file_ops::concat (p->dir_name, file); + std::string tfile = octave::sys::file_ops::concat (di.dir_name, file); octave::sys::file_stat fs (tfile); @@ -1370,19 +1338,16 @@ else { // Look in cache. - - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto & di : dir_info_list) { - string_vector all_files = p->all_files; + string_vector all_files = di.all_files; octave_idx_type len = all_files.numel (); for (octave_idx_type i = 0; i < len; i++) { if (all_files[i] == file) - return octave::sys::file_ops::concat (p->dir_name, file); + return octave::sys::file_ops::concat (di.dir_name, file); } } } @@ -1406,15 +1371,14 @@ } else { - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto& di : dir_info_list) { - std::string dname = octave::sys::env::make_absolute (p->dir_name); + std::string dname = octave::sys::env::make_absolute (di.dir_name); size_t dname_len = dname.length (); - if (dname.substr (dname_len - 1) == octave::sys::file_ops::dir_sep_str ()) + if (dname.substr (dname_len - 1) + == octave::sys::file_ops::dir_sep_str ()) { dname = dname.substr (0, dname_len - 1); dname_len--; @@ -1426,10 +1390,10 @@ && octave::sys::file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) && dir == dname.substr (dname_len - dir_len)) { - octave::sys::file_stat fs (p->dir_name); + octave::sys::file_stat fs (di.dir_name); if (fs.exists () && fs.is_dir ()) - return p->dir_name; + return di.dir_name; } } } @@ -1453,15 +1417,14 @@ } else { - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto& di : dir_info_list) { - std::string dname = octave::sys::env::make_absolute (p->dir_name); + std::string dname = octave::sys::env::make_absolute (di.dir_name); size_t dname_len = dname.length (); - if (dname.substr (dname_len - 1) == octave::sys::file_ops::dir_sep_str ()) + if (dname.substr (dname_len - 1) + == octave::sys::file_ops::dir_sep_str ()) { dname = dname.substr (0, dname_len - 1); dname_len--; @@ -1473,10 +1436,10 @@ && octave::sys::file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) && dir == dname.substr (dname_len - dir_len)) { - octave::sys::file_stat fs (p->dir_name); + octave::sys::file_stat fs (di.dir_name); if (fs.exists () && fs.is_dir ()) - retlist.push_back (p->dir_name); + retlist.push_back (di.dir_name); } } } @@ -1514,11 +1477,10 @@ } else { - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto& di : dir_info_list) { - std::string tfile = octave::sys::file_ops::concat (p->dir_name, file); + std::string tfile; + tfile = octave::sys::file_ops::concat (di.dir_name, file); octave::sys::file_stat fs (tfile); @@ -1533,11 +1495,9 @@ rel_flist.resize (rel_flen); - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto& di : dir_info_list) { - string_vector all_files = p->all_files; + string_vector all_files = di.all_files; octave_idx_type len = all_files.numel (); @@ -1547,7 +1507,7 @@ { if (all_files[i] == rel_flist[j]) { - dir_name = p->dir_name; + dir_name = di.dir_name; file_name = rel_flist[j]; goto done; @@ -1594,11 +1554,10 @@ } else { - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); - p++) + for (const auto& di : dir_info_list) { - std::string tfile = octave::sys::file_ops::concat (p->dir_name, file); + std::string tfile; + tfile = octave::sys::file_ops::concat (di.dir_name, file); octave::sys::file_stat fs (tfile); @@ -1613,10 +1572,9 @@ rel_flist.resize (rel_flen); - for (const_dir_info_list_iterator p = dir_info_list.begin (); - p != dir_info_list.end (); p++) + for (const auto& di : dir_info_list) { - string_vector all_files = p->all_files; + string_vector all_files = di.all_files; octave_idx_type len = all_files.numel (); @@ -1625,8 +1583,8 @@ for (octave_idx_type j = 0; j < rel_flen; j++) { if (all_files[i] == rel_flist[j]) - retlist.push_back (octave::sys::file_ops::concat (p->dir_name, - rel_flist[j])); + retlist.push_back (octave::sys::file_ops::concat (di.dir_name, + rel_flist[j])); } } } @@ -1643,10 +1601,8 @@ octave_idx_type k = 0; - for (const_dir_info_list_iterator i = dir_info_list.begin (); - i != dir_info_list.end (); - i++) - retval[k++] = i->dir_name; + for (const auto& di : dir_info_list) + retval[k++] = di.dir_name; return retval; } @@ -1656,10 +1612,8 @@ { std::list<std::string> retval; - for (const_dir_info_list_iterator i = dir_info_list.begin (); - i != dir_info_list.end (); - i++) - retval.push_back (i->dir_name); + for (const auto& di : dir_info_list) + retval.push_back (di.dir_name); return retval; } @@ -1707,10 +1661,8 @@ octave_idx_type count = 0; - for (const_fcn_map_iterator p = fcn_map.begin (); - p != fcn_map.end (); - p++) - retval[count++] = p->first; + for (const auto& nm_filst : fcn_map) + retval[count++] = nm_filst.first; return retval; } @@ -1765,13 +1717,11 @@ print_fcn_list (std::ostream& os, const load_path::dir_info::fcn_file_map_type& lst) { - for (load_path::dir_info::const_fcn_file_map_iterator p = lst.begin (); - p != lst.end (); - p++) + for (const auto& nm_typ : lst) { - os << " " << p->first << " ("; - - print_types (os, p->second); + os << " " << nm_typ.first << " ("; + + print_types (os, nm_typ.second); os << ")\n"; } @@ -1786,13 +1736,11 @@ octave_idx_type count = 0; - for (load_path::dir_info::const_fcn_file_map_iterator p = lst.begin (); - p != lst.end (); - p++) + for (const auto& nm_typ : lst) { - std::string nm = p->first; - - int types = p->second; + std::string nm = nm_typ.first; + + int types = nm_typ.second; if (types & load_path::OCT_FILE) nm += ".oct"; @@ -1810,31 +1758,28 @@ void load_path::do_display (std::ostream& os) const { - for (const_dir_info_list_iterator i = dir_info_list.begin (); - i != dir_info_list.end (); - i++) + for (const auto& di : dir_info_list) { - string_vector fcn_files = i->fcn_files; + string_vector fcn_files = di.fcn_files; if (! fcn_files.empty ()) { - os << "\n*** function files in " << i->dir_name << ":\n\n"; + os << "\n*** function files in " << di.dir_name << ":\n\n"; fcn_files.list_in_columns (os); } const dir_info::method_file_map_type& method_file_map - = i->method_file_map; + = di.method_file_map; if (! method_file_map.empty ()) { - for (dir_info::const_method_file_map_iterator - p = method_file_map.begin (); p != method_file_map.end (); p++) + for (const auto& cls_ci : method_file_map) { - os << "\n*** methods in " << i->dir_name - << "/@" << p->first << ":\n\n"; - - const dir_info::class_info& ci = p->second; + os << "\n*** methods in " << di.dir_name + << "/@" << cls_ci.first << ":\n\n"; + + const dir_info::class_info& ci = cls_ci.second; string_vector method_files = get_file_list (ci.method_file_map); @@ -1845,9 +1790,8 @@ default_loader.display (os); - for (const_loader_map_iterator l = loader_map.begin (); - l != loader_map.end (); ++l) - l->second.display (os); + for (const auto& nm_ldr : loader_map) + nm_ldr.second.display (os); } // True if a path is contained in a path list separated by path_sep_char @@ -1880,15 +1824,14 @@ dir_info::package_dir_map_type package_dir_map = di.package_dir_map; - for (dir_info::const_package_dir_map_iterator p = package_dir_map.begin (); - p != package_dir_map.end (); ++p) + for (const auto& pkg_di : package_dir_map) { - std::string full_name = p->first; + std::string full_name = pkg_di.first; if (! pname.empty ()) full_name = pname + "." + full_name; - add (p->second, at_end, full_name); + add (pkg_di.second, at_end, full_name); } } @@ -2012,34 +1955,28 @@ // <CLASS_NAME, CLASS_INFO> dir_info::method_file_map_type method_file_map = di.method_file_map; - for (dir_info::const_method_file_map_iterator q = method_file_map.begin (); - q != method_file_map.end (); - q++) + for (const auto& cls_ci : method_file_map) { - std::string class_name = q->first; + std::string class_name = cls_ci.first; fcn_map_type& fm = method_map[class_name]; std::string full_dir_name = octave::sys::file_ops::concat (dir_name, "@" + class_name); - const dir_info::class_info& ci = q->second; + const dir_info::class_info& ci = cls_ci.second; // <FCN_NAME, TYPES> const dir_info::fcn_file_map_type& m = ci.method_file_map; - for (dir_info::const_fcn_file_map_iterator p = m.begin (); - p != m.end (); - p++) + for (const auto& nm_typ : m) { - std::string base = p->first; - - int types = p->second; + std::string base = nm_typ.first; + int types = nm_typ.second; file_info_list_type& file_info_list = fm[base]; file_info_list_iterator p2 = file_info_list.begin (); - while (p2 != file_info_list.end ()) { if (p2->dir_name == full_dir_name) @@ -2060,7 +1997,6 @@ else { // FIXME: is this possible? - file_info& fi = *p2; fi.types = types; @@ -2080,65 +2016,53 @@ { os << "*** loader: " << (prefix.empty () ? "<top-level>" : prefix) << "\n\n"; - for (std::list<std::string>::const_iterator s = dir_list.begin (); - s != dir_list.end (); ++s) - os << *s << "\n"; + for (const auto& dir : dir_list) + os << dir << "\n"; os << "\n"; - for (const_private_fcn_map_iterator i = private_fcn_map.begin (); - i != private_fcn_map.end (); i++) + for (const auto& dir_fnlst : private_fcn_map) { os << "\n*** private functions in " - << octave::sys::file_ops::concat (i->first, "private") << ":\n\n"; - - print_fcn_list (os, i->second); + << octave::sys::file_ops::concat (dir_fnlst.first, "private") << ":\n\n"; + + print_fcn_list (os, dir_fnlst.second); } #if defined (DEBUG_LOAD_PATH) - for (const_fcn_map_iterator i = fcn_map.begin (); - i != fcn_map.end (); - i++) + for (const auto& nm_filst : fcn_map) { - os << i->first << ":\n"; - - const file_info_list_type& file_info_list = i->second; - - for (const_file_info_list_iterator p = file_info_list.begin (); - p != file_info_list.end (); - p++) + os << nm_filst.first << ":\n"; + + const file_info_list_type& file_info_list = nm_filst.second; + + for (const auto& finfo : file_info_list) { - os << " " << p->dir_name << " ("; - - print_types (os, p->types); + os << " " << finfo.dir_name << " ("; + + print_types (os, finfo.types); os << ")\n"; } } - for (const_method_map_iterator i = method_map.begin (); - i != method_map.end (); - i++) + for (const auto& cls_fnmap : method_map) { - os << "CLASS " << i->first << ":\n"; - - const fcn_map_type& fm = i->second; - - for (const_fcn_map_iterator q = fm.begin (); - q != fm.end (); - q++) + os << "CLASS " << cls_fnmap.first << ":\n"; + + const fcn_map_type& fm = cls_fnmap.second; + + for (const auto& nm_fnlst : fcn_map) { - os << " " << q->first << ":\n"; - - const file_info_list_type& file_info_list = q->second; - - for (const_file_info_list_iterator p = file_info_list.begin (); - p != file_info_list.end (); - p++) + os << " " << nm_fnlst.first << ":\n"; + + const file_info_list_type& file_info_list = nm_fnlst.second; + + for (const auto& finfo : file_info_list) { - os << " " << p->dir_name << " ("; - - print_types (os, p->types); + os << " " << finfo.dir_name << " ("; + + print_types (os, finfo.types); os << ")\n"; } @@ -2202,11 +2126,10 @@ { std::list<std::string> retval; - for (const_loader_map_iterator l = loader_map.begin (); - l != loader_map.end (); ++l) + for (const auto& dir_ldr : loader_map) { - if (! only_top_level || l->first.find ('.') == std::string::npos) - retval.push_back (l->first); + if (! only_top_level || dir_ldr.first.find ('.') == std::string::npos) + retval.push_back (dir_ldr.first); } return retval; @@ -2478,10 +2401,8 @@ if (! append) std::reverse (dir_elts.begin (), dir_elts.end ()); - for (const auto& p : dir_elts) + for (auto dir : dir_elts) { - std::string dir = p; - // Remove duplicate directory separators dir.erase (std::unique (dir.begin (), dir.end (), [](char l, char r) @@ -2545,12 +2466,8 @@ std::string arg = args(i).xstring_value ("rmpath: all arguments must be strings"); std::list<std::string> dir_elts = split_path (arg); - for (std::list<std::string>::const_iterator p = dir_elts.begin (); - p != dir_elts.end (); - p++) + for (const auto& dir : dir_elts) { - std::string dir = *p; - //dir = regexprep (dir_elts{j}, '//+', "/"); //dir = regexprep (dir, '/$', "");
--- a/libinterp/corefcn/load-save.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/load-save.cc Mon Dec 05 13:04:12 2016 -0800 @@ -978,13 +978,13 @@ size_t saved = 0; - for (octave_scalar_map::const_iterator p = m.begin (); p != m.end (); p++) + for (octave_scalar_map::const_iterator it = m.begin (); it != m.end (); it++) { std::string empty_str; - if (pat.match (m.key (p))) + if (pat.match (m.key (it))) { - do_save (os, m.contents (p), m.key (p), empty_str, + do_save (os, m.contents (it), m.key (it), empty_str, 0, fmt, save_as_floats); saved++; @@ -1005,12 +1005,9 @@ size_t saved = 0; - typedef std::list<symbol_table::symbol_record>::const_iterator - const_vars_iterator; - - for (const_vars_iterator p = vars.begin (); p != vars.end (); p++) + for (const auto& var : vars) { - do_save (os, *p, fmt, save_as_floats); + do_save (os, var, fmt, save_as_floats); saved++; } @@ -1321,18 +1318,15 @@ double save_mem_size = 0; - typedef std::list<symbol_table::symbol_record>::const_iterator - const_vars_iterator; - - for (const_vars_iterator p = vars.begin (); p != vars.end (); p++) + for (const auto& var : vars) { - octave_value val = p->varval (); + octave_value val = var.varval (); if (val.is_defined ()) { - std::string name = p->name (); + std::string name = var.name (); std::string help; - bool global = p->is_global (); + bool global = var.is_global (); double val_size = val.byte_size () / 1024;
--- a/libinterp/corefcn/ls-mat5.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/ls-mat5.cc Mon Dec 05 13:04:12 2016 -0800 @@ -2190,8 +2190,8 @@ { const Cell elts = m.contents (i); - ret += 8 + save_mat5_element_length (elts(j), "", - save_as_floats, mat7_format); + ret += 8 + save_mat5_element_length (elts(j), "", save_as_floats, + mat7_format); } } }
--- a/libinterp/corefcn/oct-errno.in.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/oct-errno.in.cc Mon Dec 05 13:04:12 2016 -0800 @@ -330,11 +330,9 @@ { octave_scalar_map retval; - for (std::map<std::string, int>::const_iterator p = errno_tbl.begin (); - p != errno_tbl.end (); - p++) + for (const auto& p : errno_tbl) { - retval.assign (p->first, p->second); + retval.assign (p.first, p.second); } return retval;
--- a/libinterp/corefcn/oct-map.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/oct-map.cc Mon Dec 05 13:04:12 2016 -0800 @@ -94,10 +94,10 @@ octave_idx_type n = p->second; make_unique (); rep->erase (field); - for (fields_rep::iterator q = rep->begin (); q != rep->end (); q++) + for (auto& fld_idx : *rep) { - if (q->second >= n) - q->second--; + if (fld_idx.second >= n) + fld_idx.second--; } return n; @@ -112,10 +112,10 @@ make_unique (); octave_idx_type i = 0; - for (fields_rep::iterator q = rep->begin (); q != rep->end (); q++) + for (auto& fld_idx : *rep) { - octave_idx_type j = q->second; - q->second = i; + octave_idx_type j = fld_idx.second; + fld_idx.second = i; perm(i++) = j; } } @@ -161,8 +161,8 @@ octave_idx_type n = nfields (); string_vector retval(n); - for (iterator p = begin (); p != end (); p++) - retval.xelem (p->second) = p->first; + for (auto& fld_idx : *this) + retval.xelem (fld_idx.second) = fld_idx.first; return retval; } @@ -1294,7 +1294,7 @@ { for (const_iterator pa = begin (); pa != end (); pa++) { - const_iterator pb = rb.seek (key(pa)); + const_iterator pb = rb.seek (key (pa)); if (pb == rb.end ()) error ("field name mismatch in structure concatenation");
--- a/libinterp/corefcn/oct-stream.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/oct-stream.cc Mon Dec 05 13:04:12 2016 -0800 @@ -2646,16 +2646,15 @@ if (collect_output) { int prev_type = -1; - for (std::list<octave_value>::iterator col = out.begin (); - col != out.end (); col++) + for (const auto& col : out) { - if (col->type_id () == prev_type + if (col.type_id () == prev_type || (fmt_list.set_from_first && prev_type != -1)) - merge_with_prev [conv++] = true; + merge_with_prev[conv++] = true; else - merge_with_prev [conv++] = false; - - prev_type = col->type_id (); + merge_with_prev[conv++] = false; + + prev_type = col.type_id (); } } @@ -2672,9 +2671,8 @@ if (row == 0 || row >= size) { size += size+1; - for (std::list<octave_value>::iterator col = out.begin (); - col != out.end (); col++) - *col = (*col).resize (dim_vector (size, 1), 0); + for (auto& col : out) + col = col.resize (dim_vector (size, 1), 0); } row_idx(0) = row; @@ -2719,16 +2717,16 @@ if (! collect_output) { retval = Cell (dim_vector (1, out.size ())); - for (std::list<octave_value>::iterator col = out.begin (); - col != out.end (); col++, i++) + for (auto& col : out) { // trim last columns if that was requested if (i == done_after && uneven_columns) dv = dim_vector (std::max (valid_rows - 1, 0), 1); ra_idx(1) = i; - retval = do_cat_op (retval, octave_value (Cell (col->resize (dv,0))), + retval = do_cat_op (retval, octave_value (Cell (col.resize (dv,0))), ra_idx); + i++; } } else // group adjacent cells of the same type into a single cell @@ -2739,10 +2737,9 @@ conv = 0; retval = Cell (); - for (std::list<octave_value>::iterator col = out.begin (); - col != out.end (); col++) + for (auto& col : out) { - if (! merge_with_prev [conv++]) // including first time + if (! merge_with_prev[conv++]) // including first time { if (prev_type != -1) { @@ -2750,14 +2747,14 @@ retval = do_cat_op (retval, octave_value (Cell (cur)), ra_idx); } - cur = octave_value (col->resize (dv,0)); + cur = octave_value (col.resize (dv,0)); group_size = 1; - prev_type = col->type_id (); + prev_type = col.type_id (); } else { ra_idx(1) = group_size++; - cur = do_cat_op (cur, octave_value (col->resize (dv,0)), + cur = do_cat_op (cur, octave_value (col.resize (dv,0)), ra_idx); } } @@ -7528,13 +7525,13 @@ << " number mode arch name\n" << " ------ ---- ---- ----\n"; - for (ostrl_map::const_iterator p = list.begin (); p != list.end (); p++) + for (const auto& fid_strm : list) { - octave_stream os = p->second; + octave_stream os = fid_strm.second; buf << " " << std::setiosflags (std::ios::right) - << std::setw (4) << p->first << " " + << std::setw (4) << fid_strm.first << " " // reset necessary in addition to setiosflags since this is one stmt. << std::resetiosflags (std::ios::adjustfield) << std::setiosflags (std::ios::left) @@ -7559,11 +7556,11 @@ int num_open = 0; - for (ostrl_map::const_iterator p = list.begin (); p != list.end (); p++) + for (const auto& fid_strm : list) { // Skip stdin, stdout, and stderr. - if (p->first > 2 && p->second) - retval(0,num_open++) = p->first; + if (fid_strm.first > 2 && fid_strm.second) + retval(0, num_open++) = fid_strm.first; } retval.resize ((num_open > 0), num_open); @@ -7580,16 +7577,16 @@ { std::string nm = fid.string_value (); - for (ostrl_map::const_iterator p = list.begin (); p != list.end (); p++) + for (const auto& fid_strm : list) { // stdin, stdout, and stderr are unnamed. - if (p->first > 2) + if (fid_strm.first > 2) { - octave_stream os = p->second; + octave_stream os = fid_strm.second; if (os && os.name () == nm) { - retval = p->first; + retval = fid_strm.first; break; } }
--- a/libinterp/corefcn/octave-link.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/octave-link.cc Mon Dec 05 13:04:12 2016 -0800 @@ -235,13 +235,12 @@ else { int idx = 0; - for (std::list<std::string>::iterator it = items_lst.begin (); - it != items_lst.end (); it++) + for (auto& str : items_lst) { if (idx != 2) - retval(idx++) = *it; + retval(idx++) = str; else - retval(idx++) = atoi (it->c_str ()); + retval(idx++) = atoi (str.c_str ()); } } } @@ -311,11 +310,8 @@ nel = items_lst.size (); Matrix items (dim_vector (1, nel)); octave_idx_type i = 0; - for (std::list<int>::iterator it = items_lst.begin (); - it != items_lst.end (); it++) - { - items.xelem(i++) = *it; - } + for (const auto& int_el : items_lst) + items.xelem(i++) = int_el; return ovl (items, result.second); } @@ -364,11 +360,8 @@ nel = items_lst.size (); Cell items (dim_vector (nel, 1)); octave_idx_type i = 0; - for (std::list<std::string>::iterator it = items_lst.begin (); - it != items_lst.end (); it++) - { - items.xelem(i++) = *it; - } + for (const auto& str_el : items_lst) + items.xelem(i++) = str_el; return ovl (items); }
--- a/libinterp/corefcn/profiler.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/profiler.cc Mon Dec 05 13:04:12 2016 -0800 @@ -45,11 +45,9 @@ RowVector retval (n); octave_idx_type i = 0; - for (function_set::const_iterator p = list.begin (); p != list.end (); ++p) - { - retval(i) = *p; - ++i; - } + for (const auto& nm : list) + retval(i++) = nm; + assert (i == n); return retval; @@ -61,8 +59,8 @@ profile_data_accumulator::tree_node::~tree_node () { - for (child_map::iterator i = children.begin (); i != children.end (); ++i) - delete i->second; + for (auto& idx_tnode : children) + delete idx_tnode.second; } profile_data_accumulator::tree_node* @@ -122,9 +120,8 @@ } // Recurse on children. - for (child_map::const_iterator i = children.begin (); - i != children.end (); ++i) - i->second->build_flat (data); + for (const auto& idx_tnode : children) + idx_tnode.second->build_flat (data); } octave_value @@ -144,13 +141,12 @@ Cell rv_children (n, 1); octave_idx_type i = 0; - for (child_map::const_iterator p = children.begin (); - p != children.end (); ++p) + for (const auto& idx_tnode : children) { - const tree_node& entry = *p->second; + const tree_node& entry = *idx_tnode.second; double child_total = entry.time; - rv_indices(i) = octave_value (p->first); + rv_indices(i) = octave_value (idx_tnode.first); rv_times(i) = octave_value (entry.time); rv_calls(i) = octave_value (entry.calls); rv_children(i) = entry.get_hierarchical (&child_total);
--- a/libinterp/corefcn/regexp.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/regexp.cc Mon Dec 05 13:04:12 2016 -0800 @@ -380,10 +380,9 @@ Cell tmp (dim_vector (1, sz)); i = 0; - for (octave::regexp::match_data::const_iterator p = rx_lst.begin (); - p != rx_lst.end (); p++) + for (const auto& match_data : rx_lst) { - string_vector named_tokens = p->named_tokens (); + string_vector named_tokens = match_data.named_tokens (); tmp(i++) = named_tokens(j); } @@ -433,16 +432,15 @@ size_t sp_start = 0; i = 0; - for (octave::regexp::match_data::const_iterator p = rx_lst.begin (); - p != rx_lst.end (); p++) + for (const auto& match_data : rx_lst) { - double s = p->start (); - double e = p->end (); + double s = match_data.start (); + double e = match_data.end (); - string_vector tmp = p->tokens (); + string_vector tmp = match_data.tokens (); tokens(i) = Cell (dim_vector (1, tmp.numel ()), tmp); - match_string(i) = p->match_string (); - token_extents(i) = p->token_extents (); + match_string(i) = match_data.match_string (); + token_extents(i) = match_data.token_extents (); end(i) = e; start(i) = s; split(i) = buffer.substr (sp_start, s-sp_start-1);
--- a/libinterp/corefcn/strfind.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/strfind.cc Mon Dec 05 13:04:12 2016 -0800 @@ -138,11 +138,8 @@ octave_idx_type one = 1; Array<octave_idx_type> result (dim_vector (std::min (one, nmatch), nmatch)); octave_idx_type k = 0; - for (std::deque<octave_idx_type>::const_iterator iter = accum.begin (); - iter != accum.end (); iter++) - { - result.xelem (k++) = *iter; - } + for (const auto& idx : accum) + result.xelem (k++) = idx; return result; }
--- a/libinterp/corefcn/symtab.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/symtab.cc Mon Dec 05 13:04:12 2016 -0800 @@ -1133,34 +1133,30 @@ if (! subfunctions.empty ()) { - for (scope_val_const_iterator p = subfunctions.begin (); - p != subfunctions.end (); p++) - os << tprefix << "subfunction: " << fcn_file_name (p->second) - << " [" << p->first << "]\n"; + for (const auto& scope_val : subfunctions) + os << tprefix << "subfunction: " << fcn_file_name (scope_val.second) + << " [" << scope_val.first << "]\n"; } if (! private_functions.empty ()) { - for (str_val_const_iterator p = private_functions.begin (); - p != private_functions.end (); p++) - os << tprefix << "private: " << fcn_file_name (p->second) - << " [" << p->first << "]\n"; + for (const auto& str_val : private_functions) + os << tprefix << "private: " << fcn_file_name (str_val.second) + << " [" << str_val.first << "]\n"; } if (! class_constructors.empty ()) { - for (str_val_const_iterator p = class_constructors.begin (); - p != class_constructors.end (); p++) - os << tprefix << "constructor: " << fcn_file_name (p->second) - << " [" << p->first << "]\n"; + for (const auto& str_val : class_constructors) + os << tprefix << "constructor: " << fcn_file_name (str_val.second) + << " [" << str_val.first << "]\n"; } if (! class_methods.empty ()) { - for (str_val_const_iterator p = class_methods.begin (); - p != class_methods.end (); p++) - os << tprefix << "method: " << fcn_file_name (p->second) - << " [" << p->first << "]\n"; + for (const auto& str_val : class_methods) + os << tprefix << "method: " << fcn_file_name (str_val.second) + << " [" << str_val.first << "]\n"; } } @@ -1335,11 +1331,10 @@ { os << "*** dumping global symbol table\n\n"; - for (global_table_const_iterator p = global_table.begin (); - p != global_table.end (); p++) + for (const auto& str_val : global_table) { - std::string nm = p->first; - octave_value val = p->second; + std::string nm = str_val.first; + octave_value val = str_val.second; os << " " << nm << " "; val.dump (os); @@ -1356,9 +1351,8 @@ os << "*** dumping globally visible functions from symbol table\n" << " (c=commandline, b=built-in)\n\n"; - for (fcn_table_const_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) - p->second.dump (os, " "); + for (const auto& nm_fi : fcn_table) + nm_fi.second.dump (os, " "); os << "\n"; } @@ -1372,11 +1366,10 @@ // better if we had a map from scope to list of subfunctions // stored with the function. Do we? - for (fcn_table_const_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) + for (const auto& nm_fi : fcn_table) { std::pair<std::string, octave_value> tmp - = p->second.subfunction_defined_in_scope (scope); + = nm_fi.second.subfunction_defined_in_scope (scope); std::string nm = tmp.first; @@ -1470,10 +1463,10 @@ { std::list<workspace_element> retval; - for (table_const_iterator p = table.begin (); p != table.end (); p++) + for (const auto& nm_sr : table) { - std::string nm = p->first; - symbol_record sr = p->second; + std::string nm = nm_sr.first; + symbol_record sr = nm_sr.second; if (! sr.is_hidden ()) { @@ -1526,11 +1519,10 @@ { os << " persistent variables in this scope:\n\n"; - for (persistent_table_const_iterator p = persistent_table.begin (); - p != persistent_table.end (); p++) + for (const auto& nm_val : persistent_table) { - std::string nm = p->first; - octave_value val = p->second; + std::string nm = nm_val.first; + octave_value val = nm_val.second; os << " " << nm << " "; val.dump (os); @@ -1545,8 +1537,8 @@ os << " other symbols in this scope (l=local; a=auto; f=formal\n" << " h=hidden; i=inherited; g=global; p=persistent)\n\n"; - for (table_const_iterator p = table.begin (); p != table.end (); p++) - p->second.dump (os, " "); + for (const auto& nm_sr : table) + nm_sr.second.dump (os, " "); os << "\n"; } @@ -1557,15 +1549,14 @@ clear_all (true); // Delete all possibly remaining scopes. - for (all_instances_iterator iter = all_instances.begin (); - iter != all_instances.end (); iter++) + for (auto& scope_stp : all_instances) { // First zero the table entry to avoid possible duplicate delete. - symbol_table *inst = iter->second; - iter->second = 0; + symbol_table *inst = scope_stp.second; + scope_stp.second = 0; - // Now delete the scope. Note that there may be side effects, such as - // deleting other scopes. + // Now delete the scope. + // Note that there may be side effects, such as deleting other scopes. delete inst; } @@ -1585,12 +1576,12 @@ if (nest_parent) { // fix bad symbol_records - for (table_iterator ti = table.begin (); ti != table.end (); ++ti) + for (auto& nm_sr : table) { - symbol_record &ours = ti->second; + symbol_record &ours = nm_sr.second; symbol_record parents; if (! ours.is_formal () - && nest_parent->look_nonlocal (ti->first, parents)) + && nest_parent->look_nonlocal (nm_sr.first, parents)) { if (ours.is_global () || ours.is_persistent ()) error ("global and persistent may only be used in the topmost level in which a nested variable is used"); @@ -1598,7 +1589,7 @@ if (! ours.is_formal ()) { ours.invalidate (); - ti->second = parents; + nm_sr.second = parents; } } else @@ -1608,13 +1599,12 @@ else if (nest_children.size ()) { static_workspace = true; - for (table_iterator ti = table.begin (); ti != table.end (); ++ti) - ti->second.set_curr_fcn (curr_fcn); + for (auto& nm_sr : table) + nm_sr.second.set_curr_fcn (curr_fcn); } - for (std::vector<symbol_table*>::iterator iter = nest_children.begin (); - iter != nest_children.end (); ++iter) - (*iter)->do_update_nest (); + for (auto& symtab_p : nest_children) + symtab_p->do_update_nest (); } DEFUN (ignore_function_time_stamp, args, nargout, @@ -1731,9 +1721,8 @@ std::list<symbol_table::scope_id> lst = symbol_table::scopes (); - for (std::list<symbol_table::scope_id>::const_iterator p = lst.begin (); - p != lst.end (); p++) - symbol_table::dump (octave_stdout, *p); + for (const auto& scope_id : lst) + symbol_table::dump (octave_stdout, scope_id); } else { @@ -1751,9 +1740,8 @@ octave_idx_type k = 0; - for (std::list<symbol_table::scope_id>::const_iterator - p = lst.begin (); p != lst.end (); p++) - v.xelem (k++) = *p; + for (const auto& scope_id : lst) + v.xelem (k++) = scope_id; retval = v; }
--- a/libinterp/corefcn/symtab.h Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/symtab.h Mon Dec 05 13:04:12 2016 -0800 @@ -157,8 +157,8 @@ { std::list<scope_id> retval; - for (set_const_iterator p = in_use.begin (); p != in_use.end (); p++) - retval.push_back (*p); + for (const auto& scope_id : in_use) + retval.push_back (scope_id); retval.sort (); @@ -1182,16 +1182,16 @@ static void erase_subfunctions_in_scope (scope_id scope) { - for (fcn_table_iterator q = fcn_table.begin (); q != fcn_table.end (); q++) - q->second.erase_subfunction (scope); + for (auto& nm_finfo : fcn_table) + nm_finfo.second.erase_subfunction (scope); } static void mark_subfunctions_in_scope_as_private (scope_id scope, const std::string& class_name) { - for (fcn_table_iterator q = fcn_table.begin (); q != fcn_table.end (); q++) - q->second.mark_subfunction_in_scope_as_private (scope, class_name); + for (auto& nm_finfo : fcn_table) + nm_finfo.second.mark_subfunction_in_scope_as_private (scope, class_name); } static scope_id dup_scope (scope_id scope) @@ -1653,8 +1653,8 @@ static void clear_functions (bool force = false) { - for (fcn_table_iterator p = fcn_table.begin (); p != fcn_table.end (); p++) - p->second.clear (force); + for (auto& nm_finfo : fcn_table) + nm_finfo.second.clear (force); } static void clear_function (const std::string& name) @@ -1692,10 +1692,10 @@ { glob_match pattern (pat); - for (fcn_table_iterator p = fcn_table.begin (); p != fcn_table.end (); p++) + for (auto& nm_finfo : fcn_table) { - if (pattern.match (p->first)) - p->second.clear_user_function (); + if (pattern.match (nm_finfo.first)) + nm_finfo.second.clear_user_function (); } } @@ -1765,12 +1765,8 @@ static void clear_mex_functions (void) { - for (fcn_table_iterator p = fcn_table.begin (); p != fcn_table.end (); p++) - { - fcn_info& finfo = p->second; - - finfo.clear_mex_function (); - } + for (auto& nm_finfo : fcn_table) + nm_finfo.second.clear_mex_function (); } static bool set_class_relationship (const std::string& sup_class, @@ -1907,16 +1903,14 @@ glob_match pat (pattern); - for (global_table_const_iterator p = global_table.begin (); - p != global_table.end (); p++) + for (const auto& nm_val : global_table) { - // We generate a list of symbol_record objects so that - // the results from glob_variables and glob_global_variables - // may be handled the same way. - - if (pat.match (p->first)) + // We generate a list of symbol_record objects so that the results from + // glob_variables and glob_global_variables may be handled the same + // way. + if (pat.match (nm_val.first)) retval.push_back (symbol_record (xglobal_scope, - p->first, p->second, + nm_val.first, nm_val.second, symbol_record::global)); } @@ -1930,16 +1924,14 @@ octave::regexp pat (pattern); - for (global_table_const_iterator p = global_table.begin (); - p != global_table.end (); p++) + for (const auto& nm_val : global_table) { - // We generate a list of symbol_record objects so that - // the results from regexp_variables and regexp_global_variables - // may be handled the same way. - - if (pat.is_match (p->first)) + // We generate a list of symbol_record objects so that the results from + // regexp_variables and regexp_global_variables may be handled the same + // way. + if (pat.is_match (nm_val.first)) retval.push_back (symbol_record (xglobal_scope, - p->first, p->second, + nm_val.first, nm_val.second, symbol_record::global)); } @@ -1983,11 +1975,10 @@ { std::list<std::string> retval; - for (fcn_table_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) + for (const auto& nm_finfo : fcn_table) { - if (p->second.is_user_function_defined ()) - retval.push_back (p->first); + if (nm_finfo.second.is_user_function_defined ()) + retval.push_back (nm_finfo.first); } if (! retval.empty ()) @@ -2000,9 +1991,8 @@ { std::list<std::string> retval; - for (global_table_const_iterator p = global_table.begin (); - p != global_table.end (); p++) - retval.push_back (p->first); + for (const auto& nm_val : global_table) + retval.push_back (nm_val.first); retval.sort (); @@ -2027,13 +2017,12 @@ { std::list<std::string> retval; - for (fcn_table_const_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) + for (const auto& nm_finfo : fcn_table) { - octave_value fcn = p->second.find_built_in_function (); + octave_value fcn = nm_finfo.second.find_built_in_function (); if (fcn.is_defined ()) - retval.push_back (p->first); + retval.push_back (nm_finfo.first); } if (! retval.empty ()) @@ -2046,13 +2035,12 @@ { std::list<std::string> retval; - for (fcn_table_const_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) + for (const auto& nm_finfo : fcn_table) { - octave_value fcn = p->second.find_cmdline_function (); + octave_value fcn = nm_finfo.second.find_cmdline_function (); if (fcn.is_defined ()) - retval.push_back (p->first); + retval.push_back (nm_finfo.first); } if (! retval.empty ()) @@ -2111,16 +2099,14 @@ static void lock_subfunctions (scope_id scope = xcurrent_scope) { - for (fcn_table_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) - p->second.lock_subfunction (scope); + for (auto& nm_finfo : fcn_table) + nm_finfo.second.lock_subfunction (scope); } static void unlock_subfunctions (scope_id scope = xcurrent_scope) { - for (fcn_table_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) - p->second.unlock_subfunction (scope); + for (auto& nm_finfo : fcn_table) + nm_finfo.second.unlock_subfunction (scope); } static std::map<std::string, octave_value> @@ -2128,11 +2114,10 @@ { std::map<std::string, octave_value> retval; - for (fcn_table_const_iterator p = fcn_table.begin (); - p != fcn_table.end (); p++) + for (const auto& nm_finfo : fcn_table) { std::pair<std::string, octave_value> tmp - = p->second.subfunction_defined_in_scope (scope); + = nm_finfo.second.subfunction_defined_in_scope (scope); std::string nm = tmp.first; @@ -2170,14 +2155,13 @@ if (it != parent_map.end ()) retval = it->second; - for (std::list<std::string>::const_iterator lit = retval.begin (); - lit != retval.end (); lit++) + for (const auto& nm : retval) { // Search for parents of parents and append them to the list. // FIXME: should we worry about a circular inheritance graph? - std::list<std::string> parents = parent_classes (*lit); + std::list<std::string> parents = parent_classes (nm); if (! parents.empty ()) retval.insert (retval.end (), parents.begin (), parents.end ()); @@ -2384,9 +2368,9 @@ void do_dup_scope (symbol_table& new_symbol_table) const { - for (table_const_iterator p = table.begin (); p != table.end (); p++) - new_symbol_table.insert_symbol_record (p->second.dup (new_symbol_table - .my_scope)); + for (const auto& nm_sr : table) + new_symbol_table.insert_symbol_record (nm_sr.second.dup (new_symbol_table + .my_scope)); } symbol_record do_find_symbol (const std::string& name) @@ -2401,9 +2385,9 @@ void do_inherit (symbol_table& donor_table, context_id donor_context) { - for (table_iterator p = table.begin (); p != table.end (); p++) + for (auto& nm_sr : table) { - symbol_record& sr = p->second; + symbol_record& sr = nm_sr.second; if (! (sr.is_automatic () || sr.is_formal ())) { @@ -2566,37 +2550,37 @@ void do_push_context (void) { - for (table_iterator p = table.begin (); p != table.end (); p++) - p->second.push_context (my_scope); + for (auto& nm_sr : table) + nm_sr.second.push_context (my_scope); } void do_pop_context (void) { - table_iterator p = table.begin (); - - while (p != table.end ()) + table_iterator tbl_it = table.begin (); + + while (tbl_it != table.end ()) { - if (p->second.pop_context (my_scope) == 0) - table.erase (p++); + if (tbl_it->second.pop_context (my_scope) == 0) + table.erase (tbl_it++); else - p++; + tbl_it++; } } void do_clear_variables (void) { - for (table_iterator p = table.begin (); p != table.end (); p++) - p->second.clear (my_scope); + for (auto& nm_sr : table) + nm_sr.second.clear (my_scope); } void do_clear_objects (void) { - for (table_iterator p = table.begin (); p != table.end (); p++) + for (auto& nm_sr : table) { - symbol_record& sr = p->second; + symbol_record& sr = nm_sr.second; octave_value val = sr.varval (); if (val.is_object ()) - p->second.clear (my_scope); + nm_sr.second.clear (my_scope); } } @@ -2631,9 +2615,9 @@ { glob_match pattern (pat); - for (table_iterator p = table.begin (); p != table.end (); p++) + for (auto& nm_sr : table) { - symbol_record& sr = p->second; + symbol_record& sr = nm_sr.second; if (sr.is_global () && pattern.match (sr.name ())) sr.unmark_global (); @@ -2654,9 +2638,9 @@ { glob_match pattern (pat); - for (table_iterator p = table.begin (); p != table.end (); p++) + for (auto& nm_sr : table) { - symbol_record& sr = p->second; + symbol_record& sr = nm_sr.second; if (sr.is_defined () || sr.is_global ()) { @@ -2670,9 +2654,9 @@ { octave::regexp pattern (pat); - for (table_iterator p = table.begin (); p != table.end (); p++) + for (auto& nm_sr : table) { - symbol_record& sr = p->second; + symbol_record& sr = nm_sr.second; if (sr.is_defined () || sr.is_global ()) { @@ -2703,9 +2687,9 @@ { std::list<symbol_record> retval; - for (table_const_iterator p = table.begin (); p != table.end (); p++) + for (const auto& nm_sr : table) { - const symbol_record& sr = p->second; + const symbol_record& sr = nm_sr.second; if ((defined_only && ! sr.is_defined (context)) || (sr.xstorage_class () & exclude)) @@ -2724,11 +2708,11 @@ glob_match pat (pattern); - for (table_const_iterator p = table.begin (); p != table.end (); p++) + for (const auto& nm_sr : table) { - if (pat.match (p->first)) + if (pat.match (nm_sr.first)) { - const symbol_record& sr = p->second; + const symbol_record& sr = nm_sr.second; if (vars_only && ! sr.is_variable ()) continue; @@ -2747,11 +2731,11 @@ octave::regexp pat (pattern); - for (table_const_iterator p = table.begin (); p != table.end (); p++) + for (const auto& nm_sr : table) { - if (pat.is_match (p->first)) + if (pat.is_match (nm_sr.first)) { - const symbol_record& sr = p->second; + const symbol_record& sr = nm_sr.second; if (vars_only && ! sr.is_variable ()) continue; @@ -2767,10 +2751,10 @@ { std::list<std::string> retval; - for (table_const_iterator p = table.begin (); p != table.end (); p++) + for (const auto& nm_sr : table) { - if (p->second.is_variable ()) - retval.push_back (p->first); + if (nm_sr.second.is_variable ()) + retval.push_back (nm_sr.first); } retval.sort ();
--- a/libinterp/corefcn/txt-eng.h Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/txt-eng.h Mon Dec 05 13:04:12 2016 -0800 @@ -321,10 +321,9 @@ virtual void visit (text_element_list& e) { - for (text_element_list::iterator it = e.begin (); - it != e.end (); ++it) + for (auto& el_p : e) { - (*it)->accept (*this); + el_p->accept (*this); } }
--- a/libinterp/corefcn/urlwrite.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/urlwrite.cc Mon Dec 05 13:04:12 2016 -0800 @@ -198,9 +198,9 @@ Matrix retval (1, handle_map.size ()); octave_idx_type i = 0; - for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++) + for (const auto& h_obj : handle_map) { - curl_handle h = p->first; + curl_handle h = h_obj.first; retval(i++) = h.value (); }
--- a/libinterp/corefcn/variables.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/variables.cc Mon Dec 05 13:04:12 2016 -0800 @@ -1390,12 +1390,11 @@ octave_stdout << "\n"; - for (std::list<symbol_info>::const_iterator p = lst.begin (); - p != lst.end (); p++) + for (const auto& syminfo : lst) { - p->display_line (os, params); - - octave_value val = p->varval; + syminfo.display_line (os, params); + + octave_value val = syminfo.varval; elements += val.numel (); bytes += val.byte_size (); @@ -1451,18 +1450,17 @@ // Calculating necessary spacing for name column, // bytes column, elements column and class column - for (std::list<symbol_info>::const_iterator p = lst.begin (); - p != lst.end (); p++) + for (const auto& syminfo : lst) { std::stringstream ss1, ss2; std::string str; - str = p->name; + str = syminfo.name; param_length(pos_n) = ((str.length () > static_cast<size_t> (param_length(pos_n))) ? str.length () : param_length(pos_n)); - octave_value val = p->varval; + octave_value val = syminfo.varval; str = val.type_name (); param_length(pos_t) = ((str.length () @@ -1553,10 +1551,9 @@ int first = param.first_parameter_length; int total = param.parameter_length; - for (std::list<symbol_info>::const_iterator p = lst.begin (); - p != lst.end (); p++) + for (const auto& syminfo : lst) { - octave_value val = p->varval; + octave_value val = syminfo.varval; std::string dims_str = get_dims_str (val); int first1 = dims_str.find ('x'); int total1 = dims_str.length (); @@ -1717,15 +1714,14 @@ ? symbol_table::regexp_global_variables (pat) : symbol_table::regexp_variables (pat); - for (std::list<symbol_table::symbol_record>::const_iterator - p = tmp.begin (); p != tmp.end (); p++) + for (const auto& symrec : tmp) { - if (p->is_variable ()) + if (symrec.is_variable ()) { if (verbose) - symbol_stats.append (*p); + symbol_stats.append (symrec); else - symbol_names.push_back (p->name ()); + symbol_names.push_back (symrec.name ()); } } } @@ -1769,15 +1765,14 @@ ? symbol_table::glob_global_variables (pat) : symbol_table::glob_variables (pat); - for (std::list<symbol_table::symbol_record>::const_iterator - p = tmp.begin (); p != tmp.end (); p++) + for (const auto& symrec : tmp) { - if (p->is_variable ()) + if (symrec.is_variable ()) { if (verbose) - symbol_stats.append (*p); + symbol_stats.append (symrec); else - symbol_names.push_back (p->name ()); + symbol_names.push_back (symrec.name ()); } } }