diff liboctave/system/file-stat.cc @ 23812:057a894914df

Use C++11 string fcns back() and pop_back() to simplify code. * error.cc (maybe_extract_message): Use "back()" rather than "[length () -1]". * input.cc (base_reader::octave_gets): Use "back()" rather than "[length () -1]". * ls-hdf5.cc (read_hdf5_data)): Use "clear()" rather than "resize (0)" to erase string. * ls-mat-ascii.cc (get_lines_and_columns): Reformat comment. * ls-oct-binary.cc (read_binary_data): Use "clear()" rather than "resize (0)" to erase string. * oct-stream.cc (delimited_stream::getline): Declare and initialize only one variable per line as per Octave coding convention. * oct-stream.cc (textscan_format_list::read_first_row): Use back() and pop_back() to potentially remove last character from string. * strfns.cc (Fstrvcat): Use "empty()" rather than "length() > 0". * sysdep.cc (w32_set_octav_home): Use back() and push_back() to potentially add dir separator to string. * gzip.cc (uchar_array): Space out code for readability. * file-ops.cc (tilde_expand): Call string_vector constructor with size n rather than resize. * file-ops.cc (concat): Use "back()" rather than "[length () -1]". * file-stat.cc (update_internal): Use "back()" rather than "[length () -1]". Use pop_back() rather than resize() to remove last character. * oct-env.cc (do_chdir): Use pop_back() rather than resize() to remove last character. * cmd-edit.cc (do_generate_filename_completions): Reformat comment. * cmd-hist.cc (): Use back() and pop_back() to potentially remove "\n" from end of string. * data-conv.cc (strip_spaces): Initialize string with null character rather than space. * kpse.cc (kpse_tilde_expand): Use "back()" rather than "[length () -1]". * kpse.cc (kpse_expand_kpse_dot, kpse_brace_expand, kpse_path_expand): Use pop_back() to potentially remove last character. * kpse.cc (kpse_brace_expand_element, kpse_element_dir): Use pop_back() to remove last character. * lo-utils.cc (octave_fgetl): Use "back()" rather than "[length () -1]". Use pop_back() rather than resize() to remove last character.
author Rik <rik@octave.org>
date Sun, 30 Jul 2017 09:21:58 -0700
parents 08036a7f3660
children 194eb4bd202b
line wrap: on
line diff
--- a/liboctave/system/file-stat.cc	Sun Jul 30 09:21:39 2017 -0700
+++ b/liboctave/system/file-stat.cc	Sun Jul 30 09:21:58 2017 -0700
@@ -188,10 +188,10 @@
 
 #if defined (__WIN32__)
           // Remove trailing slash.
-          if (sys::file_ops::is_dir_sep (full_file_name[full_file_name.length () - 1])
-              && full_file_name.length () != 1
+          if (full_file_name.length () > 1
+              && sys::file_ops::is_dir_sep (full_file_name.back ())
               && ! (full_file_name.length () == 3 && full_file_name[1] == ':'))
-            full_file_name.resize (full_file_name.length () - 1);
+            full_file_name.pop_back ();
 #endif
 
           const char *cname = full_file_name.c_str ();