# HG changeset patch # User Rik # Date 1425058271 28800 # Node ID ed5ee3f610db95d7f6061fcab95dcd7e7b35510d # Parent 815db217f6f45077d88830ba7233ceebd2016594 Correct tests using std::string::find_XXX which did not use std::string::npos. * symtab.cc (find_function): For old-style class syntax, avoid setting method == dispatch if there is no dir_sep_str. * __osmesa_print__.cc: Correctly check for pipe command versus filename. * audioread.cc: Correctly find extension of file after '.'. diff -r 815db217f6f4 -r ed5ee3f610db libinterp/corefcn/symtab.cc --- a/libinterp/corefcn/symtab.cc Fri Feb 27 11:24:12 2015 -0500 +++ b/libinterp/corefcn/symtab.cc Fri Feb 27 09:31:11 2015 -0800 @@ -1280,9 +1280,10 @@ std::string dispatch_type = name.substr (1, name.find_first_of (file_ops::dir_sep_str ()) - 1); - std::string method = - name.substr (name.find_last_of (file_ops::dir_sep_str ()) + 1, - std::string::npos); + std::string method; + size_t pos = name.find_last_of (file_ops::dir_sep_str ()); + if (pos != std::string::npos) + method = name.substr (pos + 1); retval = find_method (method, dispatch_type); } diff -r 815db217f6f4 -r ed5ee3f610db libinterp/dldfcn/__osmesa_print__.cc --- a/libinterp/dldfcn/__osmesa_print__.cc Fri Feb 27 11:24:12 2015 -0500 +++ b/libinterp/dldfcn/__osmesa_print__.cc Fri Feb 27 09:31:11 2015 -0800 @@ -183,7 +183,7 @@ if (! error_state) { size_t pos = file.find_first_not_of ("|"); - if (pos > 0) + if (pos != std::string::npos) { // create process and pipe gl2ps output to it std::string cmd = file.substr (pos); diff -r 815db217f6f4 -r ed5ee3f610db libinterp/dldfcn/audioread.cc --- a/libinterp/dldfcn/audioread.cc Fri Feb 27 11:24:12 2015 -0500 +++ b/libinterp/dldfcn/audioread.cc Fri Feb 27 09:31:11 2015 -0800 @@ -331,7 +331,10 @@ if (error_state) return retval; - std::string ext = filename.substr (filename.find_last_of (".") + 1); + std::string ext; + std::size_t dotpos = filename.find_last_of ("."); + if (dotpos != std::string::npos) + ext = filename.substr (dotpos + 1); std::transform (ext.begin (), ext.end (), ext.begin (), ::tolower); sf_count_t items_to_write = audio.rows () * audio.columns ();