From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48615 invoked by alias); 7 Oct 2018 19:45:48 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 48547 invoked by uid 9795); 7 Oct 2018 19:45:45 -0000 Date: Sun, 07 Oct 2018 19:45:00 -0000 Message-ID: <20181007194545.48515.qmail@sourceware.org> From: jturney@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.893-9-g155eacb X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 5bbeca954a98f2936f58f289f23e9dca66540eb0 X-Git-Newrev: 155eacb61d9e1a89d8f317e35ee956e7d74c90c9 X-SW-Source: 2018-q4/txt/msg00003.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=155eacb61d9e1a89d8f317e35ee956e7d74c90c9 commit 155eacb61d9e1a89d8f317e35ee956e7d74c90c9 Author: Achim Gratz Date: Sun Sep 2 18:40:33 2018 +0200 excise "using namespace std;" and explicitly use a "std::" prefix throughout instead https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=2ec74bb7542aacffec4acc09c1b497f34cd54858 commit 2ec74bb7542aacffec4acc09c1b497f34cd54858 Author: Jon Turney Date: Thu Oct 4 19:07:14 2018 +0100 Avoid potential null deref in check_for_cached() Packages for which we don't know a filename can't possibly be cached. See https://cygwin.com/ml/cygwin/2018-10/msg00033.html Diff: --- IniDBBuilderPackage.cc | 2 - LogFile.cc | 14 ++--- LogSingleton.cc | 12 ++--- PickView.cc | 10 ++-- choose.cc | 2 - compress_bz.cc | 10 ++-- compress_gz.cc | 7 +-- compress_xz.cc | 8 ++-- csu_util/version_compare.cc | 5 +-- download.cc | 11 +++- filemanip.cc | 6 +-- find.cc | 2 - geturl.cc | 24 ++++----- inilintmain.cc | 5 +- install.cc | 18 +++---- io_stream.cc | 10 ++-- io_stream_file.cc | 2 - libgetopt++/src/BoolOption.cc | 20 ++++---- libgetopt++/src/OptionSet.cc | 48 +++++++++---------- libgetopt++/src/StringArrayOption.cc | 14 ++--- libgetopt++/src/StringOption.cc | 20 ++++---- main.cc | 20 ++++---- package_db.cc | 12 ++--- package_meta.cc | 87 ++++++++++++++++------------------ postinstall.cc | 30 +++++------ prereq.h | 2 - root.cc | 8 +-- site.cc | 33 +++++-------- tests/UserSettingTest.cc | 2 - tests/UserSettingsTest.cc | 2 - 30 files changed, 195 insertions(+), 251 deletions(-) diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc index cde99a8..96517e9 100644 --- a/IniDBBuilderPackage.cc +++ b/IniDBBuilderPackage.cc @@ -29,8 +29,6 @@ #include "PackageSpecification.h" #include -using namespace std; - IniDBBuilderPackage::IniDBBuilderPackage (IniParseFeedback const &aFeedback) : currentSpec (0), _feedback (aFeedback), minimum_version_checked(FALSE) {} diff --git a/LogFile.cc b/LogFile.cc index 6590023..6b9e971 100644 --- a/LogFile.cc +++ b/LogFile.cc @@ -36,8 +36,6 @@ static BoolOption VerboseOutput (false, 'v', "verbose", "Verbose output"); -using namespace std; - /* private helper class */ class filedef { @@ -71,9 +69,9 @@ static LogEnt *currEnt = 0; int LogFile::exit_msg = 0; -typedef set FileSet; +typedef std::set FileSet; static FileSet files; -static stringbuf *theStream; +static std::stringbuf *theStream; LogFile * LogFile::createLogFile() @@ -198,11 +196,11 @@ LogFile::log_save (int babble, const std::string& filename, bool append) been_here = 0; } -ostream & +std::ostream & LogFile::operator() (log_level theLevel) { if (theLevel < 1 || theLevel > 2) - throw new invalid_argument("Invalid log_level"); + throw new std::invalid_argument("Invalid log_level"); if (!theStream) theStream = new std::stringbuf; rdbuf (theStream); @@ -215,12 +213,12 @@ LogFile::operator() (log_level theLevel) void LogFile::endEntry() { - string buf = theStream->str(); + std::string buf = theStream->str(); delete theStream; /* also write to stdout */ if ((currEnt->level >= LOG_PLAIN) || VerboseOutput) - cout << buf << endl; + std::cout << buf << std::endl; if (!currEnt) { diff --git a/LogSingleton.cc b/LogSingleton.cc index a103a20..73b8fb6 100644 --- a/LogSingleton.cc +++ b/LogSingleton.cc @@ -17,12 +17,10 @@ #include #include -using namespace std; - /* Helper functions */ /* End of a Log comment */ -ostream& endLog(ostream& outs) +std::ostream& endLog(std::ostream& outs) { /* Doesn't seem to be any way around this */ dynamic_cast(outs).endEntry(); @@ -33,9 +31,9 @@ ostream& endLog(ostream& outs) LogSingleton * LogSingleton::theInstance(0); -LogSingleton::LogSingleton(std::streambuf* aStream) : ios (aStream), ostream (aStream) +LogSingleton::LogSingleton(std::streambuf* aStream) : std::ios (aStream), std::ostream (aStream) { - ios::init (aStream); + std::ios::init (aStream); } LogSingleton::~LogSingleton(){} @@ -43,7 +41,7 @@ LogSingleton & LogSingleton::GetInstance() { if (!theInstance) - throw new invalid_argument ("No instance has been set!"); + throw new std::invalid_argument ("No instance has been set!"); return *theInstance; } @@ -55,7 +53,7 @@ LogSingleton::SetInstance(LogSingleton &newInstance) #if 0 // Logging class. Default logging level is PLAIN. -class LogSingleton : public ostream +class LogSingleton : public std::ostream { public: // Singleton support diff --git a/PickView.cc b/PickView.cc index c583eea..f8875e4 100644 --- a/PickView.cc +++ b/PickView.cc @@ -28,8 +28,6 @@ #include "LogSingleton.h" #include "Exception.h" -using namespace std; - static PickView::Header pkg_headers[] = { {"Current", 0, 0, true}, {"New", 0, 0, true}, @@ -248,9 +246,9 @@ PickView::mode_caption (views mode) /* meant to be called on packagemeta::categories */ bool -isObsolete (set &categories) +isObsolete (std::set &categories) { - set ::const_iterator i; + std::set ::const_iterator i; for (i = categories.begin (); i != categories.end (); ++i) if (isObsolete (*i)) @@ -295,7 +293,7 @@ PickView::insert_category (Category *cat, bool collapsed) return; PickCategoryLine & catline = *new PickCategoryLine (*this, *cat, 1, collapsed); int packageCount = 0; - for (vector ::iterator i = cat->second.begin (); + for (std::vector ::iterator i = cat->second.begin (); i != cat->second.end () ; ++i) { if (packageFilterString.empty () \ @@ -439,7 +437,7 @@ PickView::init_headers (HDC dc) if (pkg.installed) note_width (headers, dc, pkg.installed.Canonical_version (), HMARGIN, current_col); - for (set::iterator i = pkg.versions.begin (); + for (std::set::iterator i = pkg.versions.begin (); i != pkg.versions.end (); ++i) { if (*i != pkg.installed) diff --git a/choose.cc b/choose.cc index 51d2fb6..98671c1 100644 --- a/choose.cc +++ b/choose.cc @@ -64,8 +64,6 @@ static BoolOption CleanOrphansOption (false, 'o', "delete-orphans", "Remove orph static BoolOption ForceCurrentOption (false, 'f', "force-current", "Select the current version for all packages"); static BoolOption PruneInstallOption (false, 'Y', "prune-install", "Prune the installation to only the requested packages"); -using namespace std; - extern ThreeBarProgressPage Progress; HWND ChooserPage::ins_dialog; diff --git a/compress_bz.cc b/compress_bz.cc index 037cd74..18773d4 100644 --- a/compress_bz.cc +++ b/compress_bz.cc @@ -19,7 +19,7 @@ #include "compress_bz.h" #include -using namespace std; + #include #include @@ -142,7 +142,7 @@ compress_bz::read (void *buffer, size_t len) ssize_t compress_bz::write (const void *buffer, size_t len) { - throw new logic_error ("compress_bz::write is not implemented"); + throw new std::logic_error ("compress_bz::write is not implemented"); } ssize_t compress_bz::peek (void *buffer, size_t len) @@ -186,15 +186,15 @@ long compress_bz::tell () { if (writing) - throw new logic_error ("compress_bz::tell is not implemented " - "in writing mode"); + throw new std::logic_error ("compress_bz::tell is not implemented " + "in writing mode"); return position; } int compress_bz::seek (long where, io_stream_seek_t whence) { - throw new logic_error ("compress_bz::seek is not implemented"); + throw new std::logic_error ("compress_bz::seek is not implemented"); } int diff --git a/compress_gz.cc b/compress_gz.cc index 7686adf..55a015e 100644 --- a/compress_gz.cc +++ b/compress_gz.cc @@ -21,7 +21,7 @@ #include "compress_gz.h" #include -using namespace std; + #include #include #include @@ -32,7 +32,6 @@ using namespace std; #define COMMENT 0x10 /* bit 4 set: file comment present */ #define RESERVED 0xE0 /* bits 5..7: reserved */ - /* TODO make this a static member and federate the magic logic */ static int gz_magic[2] = { 0x1f, 0x8b }; /* gzip magic header */ @@ -408,13 +407,13 @@ compress_gz::peek (void *buffer, size_t len) long compress_gz::tell () { - throw new logic_error("compress_gz::tell is not implemented"); + throw new std::logic_error("compress_gz::tell is not implemented"); } int compress_gz::seek (long where, io_stream_seek_t whence) { - throw new logic_error("compress_gz::seek is not implemented"); + throw new std::logic_error("compress_gz::seek is not implemented"); } int diff --git a/compress_xz.cc b/compress_xz.cc index 1480c6c..a5167d6 100644 --- a/compress_xz.cc +++ b/compress_xz.cc @@ -21,7 +21,7 @@ #include "LogSingleton.h" #include -using namespace std; + #include #include #include @@ -227,7 +227,7 @@ compress_xz::read (void *buffer, size_t len) ssize_t compress_xz::write (const void *buffer, size_t len) { - throw new logic_error("compress_xz::write is not implemented"); + throw new std::logic_error("compress_xz::write is not implemented"); } ssize_t @@ -261,13 +261,13 @@ compress_xz::peek (void *buffer, size_t len) long compress_xz::tell () { - throw new logic_error("compress_xz::tell is not implemented"); + throw new std::logic_error("compress_xz::tell is not implemented"); } int compress_xz::seek (long where, io_stream_seek_t whence) { - throw new logic_error("compress_xz::seek is not implemented"); + throw new std::logic_error("compress_xz::seek is not implemented"); } int diff --git a/csu_util/version_compare.cc b/csu_util/version_compare.cc index beb98e5..687a8d3 100644 --- a/csu_util/version_compare.cc +++ b/csu_util/version_compare.cc @@ -14,8 +14,6 @@ #include "version_compare.h" -using namespace std; - static inline bool isdigit(char c) { return (c >= '0' && c <= '9'); } /* Sort two version numbers, comparing equivalently seperated strings of @@ -27,7 +25,7 @@ static inline bool isdigit(char c) { return (c >= '0' && c <= '9'); } * * Inspired but not equivalent to rpmvercmp(). */ -int version_compare (string a, string b) +int version_compare (std::string a, std::string b) { if (a == b) return 0; @@ -89,7 +87,6 @@ int version_compare (string a, string b) #include #include -using namespace std; struct version_pair { diff --git a/download.cc b/download.cc index 0cb3352..e1512b4 100644 --- a/download.cc +++ b/download.cc @@ -45,8 +45,6 @@ #include "Exception.h" -using namespace std; - extern ThreeBarProgressPage Progress; // Return true if selected checks pass, false if they don't and the @@ -84,9 +82,16 @@ int check_for_cached (packagesource & pkgsource, HWND owner, bool mirror_mode, bool check_hash) { + /* If the packagesource doesn't have a filename, it can't possibly be in the + cache */ + if (!pkgsource.Canonical()) + { + return 0; + } + /* Note that the cache dir is represented by a mirror site of file://local_dir */ std::string prefix = "file://" + local_dir + "/"; - std::string fullname = prefix + (pkgsource.Canonical() ? pkgsource.Canonical() : ""); + std::string fullname = prefix + pkgsource.Canonical(); if (mirror_mode) { diff --git a/filemanip.cc b/filemanip.cc index 265a2a7..48f5117 100644 --- a/filemanip.cc +++ b/filemanip.cc @@ -27,8 +27,6 @@ #include "io.h" #include "fcntl.h" -using namespace std; - /* legacy wrapper. * Clients should use io_stream.get_size() */ size_t @@ -60,7 +58,7 @@ find_tar_ext (const char *path) /* Parse a filename into package, version, and extension components. */ int -parse_filename (const string &fn, fileparse & f) +parse_filename (const std::string &fn, fileparse & f) { char *p, *ver; int n; @@ -71,7 +69,7 @@ parse_filename (const string &fn, fileparse & f) f.pkg = ""; f.what = ""; - f.tail = fn.substr (n, string::npos); + f.tail = fn.substr (n, std::string::npos); p = new_cstr_char_array (fn.substr (0, n)); char const *ext; diff --git a/find.cc b/find.cc index 39badf1..9d4f627 100644 --- a/find.cc +++ b/find.cc @@ -24,8 +24,6 @@ #include "FindVisitor.h" #include -using namespace std; - Find::Find(const std::string& starting_dir) : h(INVALID_HANDLE_VALUE) { diff --git a/geturl.cc b/geturl.cc index 1c1d1c6..78b7ce7 100644 --- a/geturl.cc +++ b/geturl.cc @@ -44,8 +44,6 @@ #include "LogSingleton.h" -using namespace std; - extern ThreeBarProgressPage Progress; static int max_bytes = 0; @@ -57,12 +55,12 @@ long long int total_download_bytes_sofar = 0; static DWORD start_tics; static void -init_dialog (const string &url, int length) +init_dialog (const std::string &url, int length) { if (is_local_install) return; - string::size_type divide = url.find_last_of('/'); + std::string::size_type divide = url.find_last_of('/'); max_bytes = length; Progress.SetText1("Downloading..."); Progress.SetText2((url.substr(divide + 1) + " from " @@ -106,7 +104,7 @@ progress (int bytes) } static void -getUrlToStream (const string &_url, io_stream *output) +getUrlToStream (const std::string &_url, io_stream *output) { is_local_install = (source == IDC_SOURCE_LOCALDIR); init_dialog (_url, 0); @@ -147,7 +145,7 @@ getUrlToStream (const string &_url, io_stream *output) } io_stream * -get_url_to_membuf (const string &_url, HWND owner) +get_url_to_membuf (const std::string &_url, HWND owner) { io_stream_memory *membuf = new io_stream_memory (); try @@ -173,31 +171,31 @@ get_url_to_membuf (const string &_url, HWND owner) } // predicate: url has no '\0''s in it. -string -get_url_to_string (const string &_url, HWND owner) +std::string +get_url_to_string (const std::string &_url, HWND owner) { io_stream *stream = get_url_to_membuf (_url, owner); if (!stream) - return string(); + return std::string(); size_t bytes = stream->get_size (); if (!bytes) { /* zero length, or error retrieving length */ delete stream; Log (LOG_BABBLE) << "get_url_to_string(): couldn't retrieve buffer size, or zero length buffer" << endLog; - return string(); + return std::string(); } char temp [bytes + 1]; /* membufs are quite safe */ stream->read (temp, bytes); temp [bytes] = '\0'; delete stream; - return string(temp); + return std::string(temp); } int -get_url_to_file (const string &_url, - const string &_filename, +get_url_to_file (const std::string &_url, + const std::string &_filename, int expected_length, HWND owner) { diff --git a/inilintmain.cc b/inilintmain.cc index 72298d6..33239fb 100644 --- a/inilintmain.cc +++ b/inilintmain.cc @@ -16,17 +16,16 @@ #include "getopt++/GetOption.h" #include #include -using namespace std; extern int yylineno; -static ostringstream error_buf; +static std::ostringstream error_buf; static int error_count = 0; extern int yyerror (const std::string& s) { - ostringstream buf; + std::ostringstream buf; buf << "setup.ini line " << yylineno << ": "; buf << s << endl; cout << buf; diff --git a/install.cc b/install.cc index b5adcc6..d1fb2dd 100644 --- a/install.cc +++ b/install.cc @@ -60,8 +60,6 @@ #include "Exception.h" #include "processlist.h" -using namespace std; - extern ThreeBarProgressPage Progress; static long long int total_bytes = 0; @@ -185,7 +183,7 @@ Installer::uninstallOne (packagemeta & pkg) /* Insert the paths of all parent directories of line into dirs. */ size_t idx = line.length(); - while ((idx = line.find_last_of('/', idx-1)) != string::npos) + while ((idx = line.find_last_of('/', idx-1)) != std::string::npos) { std::string dir_path = line.substr(0, idx); bool was_new = dirs.insert(dir_path).second; @@ -225,7 +223,7 @@ Installer::uninstallOne (packagemeta & pkg) /* An STL set maintains itself in sorted order. Thus, iterating over it * in reverse order will ensure we process directories depth-first. */ - set::const_iterator it = dirs.end(); + std::set::const_iterator it = dirs.end(); while (it != dirs.begin()) { it--; @@ -814,7 +812,7 @@ do_install_thread (HINSTANCE h, HWND owner) /* Writes Cygwin/setup/rootdir registry value */ create_install_root (); - vector install_q, uninstall_q, sourceinstall_q; + std::vector install_q, uninstall_q, sourceinstall_q; packagedb db; const SolverTransactionList &t = db.solution.transactions(); @@ -885,7 +883,7 @@ do_install_thread (HINSTANCE h, HWND owner) /* start with uninstalls - remove files that new packages may replace */ Progress.SetBar2(0); - for (vector ::iterator i = uninstall_q.begin (); + for (std::vector ::iterator i = uninstall_q.begin (); i != uninstall_q.end (); ++i) { packagemeta *pkgm = db.findBinary (PackageSpecification(i->Name())); @@ -895,7 +893,7 @@ do_install_thread (HINSTANCE h, HWND owner) } Progress.SetBar2(0); - for (vector ::iterator i = uninstall_q.begin (); + for (std::vector ::iterator i = uninstall_q.begin (); i != uninstall_q.end (); ++i) { packagemeta *pkgm = db.findBinary (PackageSpecification(i->Name())); @@ -904,7 +902,7 @@ do_install_thread (HINSTANCE h, HWND owner) Progress.SetBar2(std::distance(uninstall_q.begin(), i) + 1, uninstall_q.size()); } - for (vector ::iterator i = install_q.begin (); + for (std::vector ::iterator i = install_q.begin (); i != install_q.end (); ++i) { packageversion & pkg = *i; @@ -914,7 +912,7 @@ do_install_thread (HINSTANCE h, HWND owner) myInstaller.installOne (*pkgm, pkg, *pkg.source(), "cygfile://", "/", owner); } - catch (exception *e) + catch (std::exception *e) { if (yesno (owner, IDS_INSTALL_ERROR, e->what()) != IDYES) { @@ -926,7 +924,7 @@ do_install_thread (HINSTANCE h, HWND owner) } } - for (vector ::iterator i = sourceinstall_q.begin (); + for (std::vector ::iterator i = sourceinstall_q.begin (); i != sourceinstall_q.end (); ++i) { packagemeta *pkgm = db.findSource (PackageSpecification(i->Name())); diff --git a/io_stream.cc b/io_stream.cc index 36970ca..b77346b 100644 --- a/io_stream.cc +++ b/io_stream.cc @@ -28,9 +28,7 @@ #include #include "String++.h" -using namespace std; - -typedef map providersType; +typedef std::map providersType; static providersType *providers; static size_t longestPrefix = 0; static int inited = 0; @@ -46,7 +44,7 @@ io_stream::registerProvider (IOStreamProvider &theProvider, } theProvider.key = urlPrefix; if (providers->find (urlPrefix) != providers->end()) - throw new invalid_argument ("urlPrefix already registered!"); + throw new std::invalid_argument ("urlPrefix already registered!"); (*providers)[urlPrefix] = &theProvider; if (urlPrefix.size() > longestPrefix) longestPrefix = urlPrefix.size(); @@ -83,7 +81,7 @@ io_stream::factory (io_stream * parent) } #define url_scheme_not_registered(name) \ - throw new invalid_argument ((std::string("URL Scheme for '")+ \ + throw new std::invalid_argument ((std::string("URL Scheme for '")+ \ name+"' not registered!").c_str()) io_stream * @@ -131,7 +129,7 @@ io_stream::mklink (const std::string& from, const std::string& to, if (!top) url_scheme_not_registered (to); if (fromp != top) - throw new invalid_argument ("Attempt to link across url providers."); + throw new std::invalid_argument ("Attempt to link across url providers."); return fromp->mklink (&from.c_str()[fromp->key.size()], &to.c_str()[top->key.size()], linktype); } diff --git a/io_stream_file.cc b/io_stream_file.cc index 650ac90..938d2d9 100644 --- a/io_stream_file.cc +++ b/io_stream_file.cc @@ -27,8 +27,6 @@ #include "IOStreamProvider.h" #include "LogSingleton.h" -using namespace std; - /* completely private iostream registration class */ class FileProvider : public IOStreamProvider { diff --git a/libgetopt++/src/BoolOption.cc b/libgetopt++/src/BoolOption.cc index 7604713..4b26553 100644 --- a/libgetopt++/src/BoolOption.cc +++ b/libgetopt++/src/BoolOption.cc @@ -15,12 +15,10 @@ #include -using namespace std; - -BoolOption::BoolOption(bool const defaultvalue, char shortopt, - char const *longopt, string const &shorthelp, - OptionSet &owner) : _value (defaultvalue) , - _ovalue (defaultvalue), _shortopt(shortopt), +BoolOption::BoolOption(bool const defaultvalue, char shortopt, + char const *longopt, std::string const &shorthelp, + OptionSet &owner) : _value (defaultvalue) , + _ovalue (defaultvalue), _shortopt(shortopt), _longopt (longopt), _shorthelp (shorthelp) { owner.Register (this); @@ -28,25 +26,25 @@ BoolOption::BoolOption(bool const defaultvalue, char shortopt, BoolOption::~ BoolOption () {}; -string const +std::string const BoolOption::shortOption () const { - return string() + _shortopt; + return std::string() + _shortopt; } -string const +std::string const BoolOption::longOption () const { return _longopt; } -string const +std::string const BoolOption::shortHelp () const { return _shorthelp; } -Option::Result +Option::Result BoolOption::Process (char const *) { _value = !_ovalue; diff --git a/libgetopt++/src/OptionSet.cc b/libgetopt++/src/OptionSet.cc index 81ffeae..a8f02e8 100644 --- a/libgetopt++/src/OptionSet.cc +++ b/libgetopt++/src/OptionSet.cc @@ -24,10 +24,8 @@ #include #include -using namespace std; - bool -OptionSet::isOption(string::size_type pos) const +OptionSet::isOption(std::string::size_type pos) const { return pos == 1 || pos == 2; } @@ -35,8 +33,8 @@ OptionSet::isOption(string::size_type pos) const void OptionSet::processOne() { - string &option (argv[0]); - string::size_type pos = option.find_first_not_of("-"); + std::string &option (argv[0]); + std::string::size_type pos = option.find_first_not_of("-"); if (!isOption(pos)) { /* Push the non option into storage */ @@ -52,7 +50,7 @@ OptionSet::processOne() } Option * -OptionSet::findOption(string &option, string::size_type const &pos) const +OptionSet::findOption(std::string &option, std::string::size_type const &pos) const { Option *theOption = NULL; @@ -87,7 +85,7 @@ OptionSet::doNoArgumentOption(std::string &option, std::string::size_type const } if (pos == 2) { - if (option.find("=") != string::npos) + if (option.find("=") != std::string::npos) /* How best to provide failure state ? */ return false; } @@ -96,13 +94,13 @@ OptionSet::doNoArgumentOption(std::string &option, std::string::size_type const /* TODO: factor this better */ void -OptionSet::doOption(string &option, string::size_type const &pos) +OptionSet::doOption(std::string &option, std::string::size_type const &pos) { lastResult = Option::Failed; option.erase(0, pos); Option *theOption = findOption(option, pos); char const *optionValue = NULL; - string value; + std::string value; if (theOption == NULL) return; @@ -120,7 +118,7 @@ OptionSet::doOption(string &option, string::size_type const &pos) /* Value in next argv */ if (argv.size() > 1) { - string::size_type maybepos = argv[1].find_first_not_of("-"); + std::string::size_type maybepos = argv[1].find_first_not_of("-"); if (!isOption(maybepos)) { /* not an option */ @@ -141,9 +139,9 @@ OptionSet::doOption(string &option, string::size_type const &pos) } if (pos == 2) { - string::size_type vpos = option.find("="); + std::string::size_type vpos = option.find("="); - if (vpos != string::npos) { + if (vpos != std::string::npos) { /* How best to provide failure state ? */ if (vpos == option.size() - 1) @@ -155,7 +153,7 @@ OptionSet::doOption(string &option, string::size_type const &pos) /* Value in next argv */ if (argv.size() > 1) { - string::size_type maybepos = argv[1].find_first_not_of("-"); + std::string::size_type maybepos = argv[1].find_first_not_of("-"); if (!isOption(maybepos)) { value = argv[1]; @@ -181,7 +179,7 @@ OptionSet::doOption(string &option, string::size_type const &pos) /* but there aren't any */ return; - string::size_type maybepos = argv[1].find_first_not_of("-"); + std::string::size_type maybepos = argv[1].find_first_not_of("-"); if (isOption(maybepos)) /* The next argv is an option */ @@ -201,9 +199,9 @@ OptionSet::doOption(string &option, string::size_type const &pos) } if (pos == 2) { - string::size_type vpos = option.find("="); + std::string::size_type vpos = option.find("="); - if (vpos != string::npos) { + if (vpos != std::string::npos) { /* How best to provide failure state ? */ if (vpos == option.size() - 1) @@ -217,7 +215,7 @@ OptionSet::doOption(string &option, string::size_type const &pos) /* but there aren't any */ return; - string::size_type maybepos = argv[1].find_first_not_of("-"); + std::string::size_type maybepos = argv[1].find_first_not_of("-"); if (isOption(maybepos)) /* The next argv is an option */ @@ -245,9 +243,9 @@ void OptionSet::Init() { options = std::vector