public inbox for cygwin-apps-cvs@sourceware.org help / color / mirror / Atom feed
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 Date: Sun, 07 Oct 2018 19:45:00 -0000 [thread overview] Message-ID: <20181007194545.48515.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=155eacb61d9e1a89d8f317e35ee956e7d74c90c9 commit 155eacb61d9e1a89d8f317e35ee956e7d74c90c9 Author: Achim Gratz <Stromeko@Stromeko.DE> 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 <jon.turney@dronecode.org.uk> 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 <algorithm> -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<filedef> FileSet; +typedef std::set<filedef> 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 <stdexcept> #include <stdarg.h> -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<LogSingleton &>(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 <std::string, casecompare_lt_op> &categories) +isObsolete (std::set <std::string, casecompare_lt_op> &categories) { - set <std::string, casecompare_lt_op>::const_iterator i; + std::set <std::string, casecompare_lt_op>::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 <packagemeta *>::iterator i = cat->second.begin (); + for (std::vector <packagemeta *>::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<packageversion>::iterator i = pkg.versions.begin (); + for (std::set<packageversion>::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 <stdexcept> -using namespace std; + #include <errno.h> #include <string.h> @@ -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 <stdexcept> -using namespace std; + #include <errno.h> #include <memory.h> #include <malloc.h> @@ -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 <stdexcept> -using namespace std; + #include <errno.h> #include <memory.h> #include <malloc.h> @@ -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 <iostream> #include <iomanip> -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 <stdexcept> -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 <iostream> #include <sstream> -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<string>::const_iterator it = dirs.end(); + std::set<std::string>::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 <packageversion> install_q, uninstall_q, sourceinstall_q; + std::vector <packageversion> 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 <packageversion>::iterator i = uninstall_q.begin (); + for (std::vector <packageversion>::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 <packageversion>::iterator i = uninstall_q.begin (); + for (std::vector <packageversion>::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 <packageversion>::iterator i = install_q.begin (); + for (std::vector <packageversion>::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 <packageversion>::iterator i = sourceinstall_q.begin (); + for (std::vector <packageversion>::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 <map> #include "String++.h" -using namespace std; - -typedef map <std::string, IOStreamProvider *, casecompare_lt_op> providersType; +typedef std::map <std::string, IOStreamProvider *, casecompare_lt_op> 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 <getopt++/BoolOption.h> -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 <iostream> #include <algorithm> -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<Option *> (); - argv = std::vector<string> (); - nonoptions = std::vector<string> (); - remainingargv = std::vector<string> (); + argv = std::vector<std::string> (); + nonoptions = std::vector<std::string> (); + remainingargv = std::vector<std::string> (); nonOptionHandler = NULL; } @@ -272,7 +270,7 @@ OptionSet::process (Option *aNonOptionHandler) case Option::Stop: if (argv.size() > 1) { // dies: copy(argv.begin() + 1, argv.end(), remainingargv.begin()); - for (std::vector<string>::iterator i = argv.begin() + 1; i != argv.end(); ++i) + for (std::vector<std::string>::iterator i = argv.begin() + 1; i != argv.end(); ++i) remainingargv.push_back(*i); } return true; @@ -294,7 +292,7 @@ OptionSet::Process (int argc, char **argV, Option *nonOptionHandler) remainingargv.clear(); for (int counter = 1; counter < argc; ++counter) - argv.push_back(string(argV[counter])); + argv.push_back(std::string(argV[counter])); return process(nonOptionHandler); } @@ -324,7 +322,7 @@ comp_long_option(const Option *a, const Option *b) } void -OptionSet::ParameterUsage (ostream &aStream) +OptionSet::ParameterUsage (std::ostream &aStream) { std::sort(options.begin(), options.end(), comp_long_option); for_each (options.begin(), options.end(), DefaultFormatter (aStream)); @@ -336,13 +334,13 @@ OptionSet::optionsInSet() const return options; } -std::vector<string> const & +std::vector<std::string> const & OptionSet::nonOptions() const { return nonoptions; } -std::vector<string> const & +std::vector<std::string> const & OptionSet::remainingArgv() const { return remainingargv; diff --git a/libgetopt++/src/StringArrayOption.cc b/libgetopt++/src/StringArrayOption.cc index 79ba88c..7cbee20 100644 --- a/libgetopt++/src/StringArrayOption.cc +++ b/libgetopt++/src/StringArrayOption.cc @@ -14,10 +14,8 @@ #include <getopt++/StringArrayOption.h> -using namespace std; - StringArrayOption::StringArrayOption(char shortopt, - char const *longopt, string const &shorthelp, + char const *longopt, std::string const &shorthelp, OptionSet &owner) : _optional(Required), _shortopt(shortopt), _longopt (longopt), _shorthelp (shorthelp) @@ -27,19 +25,19 @@ StringArrayOption::StringArrayOption(char shortopt, StringArrayOption::~ StringArrayOption () {}; -string const +std::string const StringArrayOption::shortOption () const { - return string() + _shortopt + ":"; + return std::string() + _shortopt + ":"; } -string const +std::string const StringArrayOption::longOption () const { return _longopt; } -string const +std::string const StringArrayOption::shortHelp () const { return _shorthelp; @@ -56,7 +54,7 @@ StringArrayOption::Process (char const *optarg) return Failed; } -StringArrayOption::operator vector<string> () const +StringArrayOption::operator std::vector<std::string> () const { return _value; } diff --git a/libgetopt++/src/StringOption.cc b/libgetopt++/src/StringOption.cc index 210b00a..d359236 100644 --- a/libgetopt++/src/StringOption.cc +++ b/libgetopt++/src/StringOption.cc @@ -15,11 +15,9 @@ #include <getopt++/StringOption.h> -using namespace std; - -StringOption::StringOption(string const defaultvalue, char shortopt, - char const *longopt, string const &shorthelp, - bool const optional, OptionSet &owner) : +StringOption::StringOption(std::string const defaultvalue, char shortopt, + char const *longopt, std::string const &shorthelp, + bool const optional, OptionSet &owner) : _value (defaultvalue) , _shortopt(shortopt), _longopt (longopt), _shorthelp (shorthelp) { @@ -32,25 +30,25 @@ StringOption::StringOption(string const defaultvalue, char shortopt, StringOption::~ StringOption () {}; -string const +std::string const StringOption::shortOption () const { - return string() + _shortopt + ":"; + return std::string() + _shortopt + ":"; } -string const +std::string const StringOption::longOption () const { return _longopt; } -string const +std::string const StringOption::shortHelp () const { return _shorthelp; } -Option::Result +Option::Result StringOption::Process (char const *optarg) { if (optarg) @@ -60,7 +58,7 @@ StringOption::Process (char const *optarg) return Failed; } -StringOption::operator const string& () const +StringOption::operator const std::string& () const { return _value; } diff --git a/main.cc b/main.cc index 1374fb6..caa213f 100644 --- a/main.cc +++ b/main.cc @@ -84,8 +84,6 @@ bool is_new_install = false; std::string SetupArch; std::string SetupIniDir; -using namespace std; - HINSTANCE hinstance; static StringOption Arch ("", 'a', "arch", "Architecture to install (x86_64 or x86)", false); @@ -108,9 +106,9 @@ set_cout () if (AttachConsole ((DWORD) -1)) { - ofstream *conout = new ofstream ("conout$"); - cout.rdbuf (conout->rdbuf ()); - cout.flush (); + std::ofstream *conout = new std::ofstream ("conout$"); + std::cout.rdbuf (conout->rdbuf ()); + std::cout.flush (); } } @@ -237,7 +235,7 @@ WinMain (HINSTANCE h, else if (HelpOption) help_option = true; - if (!((string) Arch).size ()) + if (!((std::string) Arch).size ()) { #ifdef __x86_64__ is_64bit = true; @@ -245,16 +243,16 @@ WinMain (HINSTANCE h, is_64bit = false; #endif } - else if (((string) Arch).find ("64") != string::npos) + else if (((std::string) Arch).find ("64") != std::string::npos) is_64bit = true; - else if (((string) Arch).find ("32") != string::npos - || ((string) Arch).find ("x86") != string::npos) + else if (((std::string) Arch).find ("32") != std::string::npos + || ((std::string) Arch).find ("x86") != std::string::npos) is_64bit = false; else { - char buff[80 + ((string) Arch).size ()]; + char buff[80 + ((std::string) Arch).size ()]; sprintf (buff, "Invalid option for --arch: \"%s\"", - ((string) Arch).c_str ()); + ((std::string) Arch).c_str ()); fprintf (stderr, "*** %s\n", buff); mbox (NULL, buff, "Invalid option", MB_ICONEXCLAMATION | MB_OK); exit (1); diff --git a/package_db.cc b/package_db.cc index b74aafd..8b8e120 100644 --- a/package_db.cc +++ b/package_db.cc @@ -44,8 +44,6 @@ static BoolOption MirrorOption (false, 'm', "mirror-mode", "Skip package availability check when installing from local directory (requires local directory to be clean mirror!)"); -using namespace std; - packagedb::packagedb () { } @@ -333,7 +331,7 @@ packagedb::findBinary (PackageSpecification const &spec) const if (n != packages.end()) { packagemeta & pkgm = *(n->second); - for (set<packageversion>::iterator i=pkgm.versions.begin(); + for (std::set<packageversion>::iterator i=pkgm.versions.begin(); i != pkgm.versions.end(); ++i) if (spec.satisfies (*i)) return &pkgm; @@ -348,7 +346,7 @@ packagedb::findBinaryVersion (PackageSpecification const &spec) const if (n != packages.end()) { packagemeta & pkgm = *(n->second); - for (set<packageversion>::iterator i=pkgm.versions.begin(); + for (std::set<packageversion>::iterator i=pkgm.versions.begin(); i != pkgm.versions.end(); ++i) if (spec.satisfies (*i)) return *i; @@ -363,7 +361,7 @@ packagedb::findSource (PackageSpecification const &spec) const if (n != sourcePackages.end()) { packagemeta & pkgm = *(n->second); - for (set<packageversion>::iterator i = pkgm.versions.begin(); + for (std::set<packageversion>::iterator i = pkgm.versions.begin(); i != pkgm.versions.end(); ++i) if (spec.satisfies (*i)) return &pkgm; @@ -378,7 +376,7 @@ packagedb::findSourceVersion (PackageSpecification const &spec) const if (n != sourcePackages.end()) { packagemeta & pkgm = *(n->second); - for (set<packageversion>::iterator i = pkgm.versions.begin(); + for (std::set<packageversion>::iterator i = pkgm.versions.begin(); i != pkgm.versions.end(); ++i) if (spec.satisfies (*i)) return *i; @@ -696,7 +694,7 @@ packagedb::fixup_source_package_ids() { packagemeta &pkgm = *(i->second); - for (set<packageversion>::iterator i = pkgm.versions.begin(); + for (std::set<packageversion>::iterator i = pkgm.versions.begin(); i != pkgm.versions.end(); ++i) { /* If spkg_id is already known for this package, there's nothing to diff --git a/package_meta.cc b/package_meta.cc index a7f4cfd..ab1e175 100644 --- a/package_meta.cc +++ b/package_meta.cc @@ -17,7 +17,6 @@ #include <string> #include <set> -using namespace std; #include <stdio.h> #include <stdlib.h> @@ -44,8 +43,6 @@ using namespace std; #include "Exception.h" #include "resource.h" -using namespace std; - static StringArrayOption DeletePackageOption ('x', "remove-packages", "Specify packages to uninstall"); static StringArrayOption DeleteCategoryOption ('c', "remove-categories", "Specify categories to uninstall"); static StringArrayOption PackageOption ('P', "packages", "Specify packages to install"); @@ -93,7 +90,7 @@ packagemeta::packagemeta (packagemeta const &rhs) : exp (rhs.exp), desired (rhs.desired) { - + } packagemeta::_actions & packagemeta::_actions::operator++ () @@ -104,12 +101,12 @@ packagemeta::_actions & packagemeta::_actions::operator++ () return *this; } -template<class T> struct removeCategory : public unary_function<T, void> +template<class T> struct removeCategory : public std::unary_function<T, void> { removeCategory(packagemeta *pkg) : _pkg (pkg) {} - void operator() (T x) + void operator() (T x) { - vector <packagemeta *> &aList = packagedb::categories[x]; + std::vector <packagemeta *> &aList = packagedb::categories[x]; aList.erase (find (aList.begin(), aList.end(), _pkg)); } packagemeta *_pkg; @@ -152,7 +149,7 @@ packagemeta::add_version (const SolverPool::addPackageData &inpkgdata) We rely on this by adding packages from installed.db last. */ - for (set <packageversion>::iterator i = versions.begin(); + for (std::set <packageversion>::iterator i = versions.begin(); i != versions.end(); i++) { @@ -254,8 +251,7 @@ packagemeta::isBlacklisted(const packageversion &version) const void packagemeta::set_installed_version (const std::string &version) { - set<packageversion>::iterator i; - for (i = versions.begin(); i != versions.end(); i++) + for (std::set<packageversion>::iterator i = versions.begin(); i != versions.end(); i++) { if (version.compare(i->Canonical_version()) == 0) { @@ -277,9 +273,9 @@ packagemeta::add_category (const std::string& cat) categories.insert (cat); } -struct StringConcatenator : public unary_function<const std::string, void>{ +struct StringConcatenator : public std::unary_function<const std::string, void>{ StringConcatenator(std::string aString) : gap(aString){} - void operator()(const std::string& aString) + void operator()(const std::string& aString) { if (result.size() != 0) result += gap; @@ -292,20 +288,20 @@ struct StringConcatenator : public unary_function<const std::string, void>{ const std::string packagemeta::getReadableCategoryList () const { - return for_each(categories.begin(), categories.end(), + return for_each(categories.begin(), categories.end(), visit_if ( - StringConcatenator(", "), bind1st(not_equal_to<std::string>(), "All")) + StringConcatenator(", "), bind1st(std::not_equal_to<std::string>(), "All")) ).visitor.result; } static void -parseNames (std::set<string> &parsed, std::string &option) +parseNames (std::set<std::string> &parsed, std::string &option) { - string tname; + std::string tname; /* Split up the packages listed in the option. */ - string::size_type loc = option.find (",", 0); - while (loc != string::npos) + std::string::size_type loc = option.find (",", 0); + while (loc != std::string::npos) { tname = option.substr (0, loc); option = option.substr (loc + 1); @@ -322,24 +318,24 @@ parseNames (std::set<string> &parsed, std::string &option) bool packagemeta::isManuallyWanted() const { static bool parsed_yet = false; - static std::set<string> parsed_names; + static std::set<std::string> parsed_names; hasManualSelections |= parsed_names.size (); - static std::set<string> parsed_categories; + static std::set<std::string> parsed_categories; hasManualSelections |= parsed_categories.size (); bool bReturn = false; - /* First time through, we parse all the names out from the + /* First time through, we parse all the names out from the option string and store them away in an STL set. */ if (!parsed_yet) { - vector<string> packages_options = PackageOption; - vector<string> categories_options = CategoryOption; - for (vector<string>::iterator n = packages_options.begin (); + std::vector<std::string> packages_options = PackageOption; + std::vector<std::string> categories_options = CategoryOption; + for (std::vector<std::string>::iterator n = packages_options.begin (); n != packages_options.end (); ++n) { parseNames (parsed_names, *n); } - for (vector<string>::iterator n = categories_options.begin (); + for (std::vector<std::string>::iterator n = categories_options.begin (); n != categories_options.end (); ++n) { parseNames (parsed_categories, *n); @@ -351,7 +347,7 @@ bool packagemeta::isManuallyWanted() const a lookup in the cache of already-parsed names. */ bReturn = parsed_names.find(name) != parsed_names.end(); - /* If we didn't select the package manually, did we select any + /* If we didn't select the package manually, did we select any of the categories it is in? */ if (!bReturn && parsed_categories.size ()) { @@ -363,7 +359,7 @@ bool packagemeta::isManuallyWanted() const bReturn = true; } } - + if (bReturn) Log (LOG_BABBLE) << "Added manual package " << name << endLog; return bReturn; @@ -372,9 +368,9 @@ bool packagemeta::isManuallyWanted() const bool packagemeta::isManuallyDeleted() const { static bool parsed_yet = false; - static std::set<string> parsed_delete; + static std::set<std::string> parsed_delete; hasManualSelections |= parsed_delete.size (); - static std::set<string> parsed_delete_categories; + static std::set<std::string> parsed_delete_categories; hasManualSelections |= parsed_delete_categories.size (); bool bReturn = false; @@ -382,14 +378,14 @@ bool packagemeta::isManuallyDeleted() const option string and store them away in an STL set. */ if (!parsed_yet) { - vector<string> delete_options = DeletePackageOption; - vector<string> categories_options = DeleteCategoryOption; - for (vector<string>::iterator n = delete_options.begin (); + std::vector<std::string> delete_options = DeletePackageOption; + std::vector<std::string> categories_options = DeleteCategoryOption; + for (std::vector<std::string>::iterator n = delete_options.begin (); n != delete_options.end (); ++n) { parseNames (parsed_delete, *n); } - for (vector<string>::iterator n = categories_options.begin (); + for (std::vector<std::string>::iterator n = categories_options.begin (); n != categories_options.end (); ++n) { parseNames (parsed_delete_categories, *n); @@ -422,8 +418,7 @@ bool packagemeta::isManuallyDeleted() const const std::string packagemeta::SDesc () const { - set<packageversion>::iterator i; - for (i = versions.begin(); i != versions.end(); i++) + for (std::set<packageversion>::iterator i = versions.begin(); i != versions.end(); i++) { if (i->SDesc().size()) return i->SDesc (); @@ -433,7 +428,7 @@ packagemeta::SDesc () const } /* Return an appropriate caption given the current action. */ -std::string +std::string packagemeta::action_caption () const { if (!desired && installed) @@ -455,7 +450,7 @@ packagemeta::action_caption () const void packagemeta::set_action (trusts const trust) { - set<packageversion>::iterator i; + std::set<packageversion>::iterator i; /* Keep the picked settings of the former desired version, if any, and make sure at least one of them is picked. If both are unpicked, pick the @@ -607,7 +602,7 @@ packagemeta::srcpick (bool picked) bool packagemeta::accessible () const { - for (set<packageversion>::iterator i=versions.begin(); + for (std::set<packageversion>::iterator i=versions.begin(); i != versions.end(); ++i) if (i->accessible()) return true; @@ -617,7 +612,7 @@ packagemeta::accessible () const bool packagemeta::sourceAccessible () const { - for (set<packageversion>::iterator i=versions.begin(); + for (std::set<packageversion>::iterator i=versions.begin(); i != versions.end(); ++i) { packageversion bin=*i; @@ -631,7 +626,7 @@ packagemeta::sourceAccessible () const bool packagemeta::isBinary () const { - for (set<packageversion>::iterator i=versions.begin(); + for (std::set<packageversion>::iterator i=versions.begin(); i != versions.end(); ++i) if ((i->Type() == package_binary) && (i->accessible() || (*i == installed))) return true; @@ -642,8 +637,8 @@ packagemeta::isBinary () const void packagemeta::logAllVersions () const { - for (set<packageversion>::iterator i = versions.begin(); - i != versions.end(); ++i) + for (std::set<packageversion>::iterator i = versions.begin(); + i != versions.end(); ++i) { Log (LOG_BABBLE) << " [" << trustLabel(*i) << "] ver=" << i->Canonical_version() << endLog; @@ -674,7 +669,7 @@ packagemeta::logAllVersions () const #endif } -std::string +std::string packagemeta::trustLabel(packageversion const &aVersion) const { if (aVersion == curr) @@ -750,7 +745,7 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode) n != db.packages.end (); ++n) { packagemeta & pkg = *(n->second); - set<packageversion>::iterator i = pkg.versions.begin (); + std::set<packageversion>::iterator i = pkg.versions.begin (); while (i != pkg.versions.end ()) { /* scan doesn't alter operator == for packageversions */ @@ -787,8 +782,8 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode) referenced are unselectable anyway. */ } -void -packagemeta::addToCategoryBase() +void +packagemeta::addToCategoryBase() { add_category ("Base"); } diff --git a/postinstall.cc b/postinstall.cc index 3cd6ff0..b4e0981 100644 --- a/postinstall.cc +++ b/postinstall.cc @@ -32,8 +32,6 @@ #include <algorithm> #include <sstream> -using namespace std; - extern ThreeBarProgressPage Progress; extern PostInstallResultsPage PostInstallResults; @@ -44,7 +42,7 @@ extern PostInstallResultsPage PostInstallResults; class RunFindVisitor : public FindVisitor { public: - RunFindVisitor (vector<Script> *scripts, const std::string& stratum = "") + RunFindVisitor (std::vector<Script> *scripts, const std::string& stratum = "") : _scripts(scripts), stratum(stratum) {} @@ -61,14 +59,14 @@ protected: RunFindVisitor (RunFindVisitor const &); RunFindVisitor & operator= (RunFindVisitor const &); private: - vector<Script> *_scripts; + std::vector<Script> *_scripts; const std::string stratum; }; class PerpetualFindVisitor : public FindVisitor { public: - PerpetualFindVisitor (vector<Script> *scripts, const string& stratum) + PerpetualFindVisitor (std::vector<Script> *scripts, const std::string& stratum) : _scripts(scripts), stratum(stratum) {} @@ -85,7 +83,7 @@ protected: PerpetualFindVisitor (PerpetualFindVisitor const &); PerpetualFindVisitor & operator= (PerpetualFindVisitor const &); private: - vector<Script> *_scripts; + std::vector<Script> *_scripts; const std::string stratum; }; @@ -96,7 +94,7 @@ private: class RunScript { public: - RunScript(const std::string& name, const vector<Script> &scripts) : _name(name), _scripts(scripts), _cnt(0) + RunScript(const std::string& name, const std::vector<Script> &scripts) : _name(name), _scripts(scripts), _cnt(0) { Progress.SetText2 (name.c_str()); Progress.SetBar1 (0, _scripts.size()); @@ -140,7 +138,7 @@ public: } private: std::string _name; - const vector<Script> &_scripts; + const std::vector<Script> &_scripts; int _cnt; }; @@ -154,7 +152,7 @@ do_postinstall_thread (HINSTANCE h, HWND owner) Progress.SetBar2 (0, 1); packagedb db; - vector<packagemeta*> packages; + std::vector<packagemeta*> packages; PackageDBConnectedIterator i = db.connectedBegin (); while (i != db.connectedEnd ()) { @@ -172,7 +170,7 @@ do_postinstall_thread (HINSTANCE h, HWND owner) { const std::string sit(1, *it); // Look for any scripts in /etc/postinstall which should always be run - vector<Script> perpetual; + std::vector<Script> perpetual; PerpetualFindVisitor myPerpetualVisitor (&perpetual, sit); Find (postinst).accept (myPerpetualVisitor); // sort the list alphabetically, assumes ASCII names only @@ -186,14 +184,14 @@ do_postinstall_thread (HINSTANCE h, HWND owner) // run those scripts now int numpkg = packages.size() + 1; int k = 0; - for (vector <packagemeta *>::iterator i = packages.begin (); i != packages.end (); ++i) + for (std::vector <packagemeta *>::iterator i = packages.begin (); i != packages.end (); ++i) { packagemeta & pkg = **i; - vector<Script> installed = pkg.scripts(); - vector<Script> run; + std::vector<Script> installed = pkg.scripts(); + std::vector<Script> run; // extract non-perpetual scripts for the current stratum - for (vector <Script>::iterator j = installed.begin(); j != installed.end(); j++) + for (std::vector <Script>::iterator j = installed.begin(); j != installed.end(); j++) { if ((*j).not_p(sit)) run.push_back(*j); @@ -206,11 +204,11 @@ do_postinstall_thread (HINSTANCE h, HWND owner) } // Look for runnable non-perpetual scripts in /etc/postinstall. // This happens when a script from a previous install failed to run. - vector<Script> scripts; + std::vector<Script> scripts; RunFindVisitor myVisitor (&scripts, sit); Find (postinst).accept (myVisitor); // Remove anything which we just tried to run (so we don't try twice) - for (vector <packagemeta *>::iterator i = packages.begin (); i != packages.end (); ++i) + for (std::vector <packagemeta *>::iterator i = packages.begin (); i != packages.end (); ++i) { packagemeta & pkg = **i; for (std::vector<Script>::const_iterator j = pkg.scripts().begin(); diff --git a/prereq.h b/prereq.h index 749d3eb..2f4da7d 100644 --- a/prereq.h +++ b/prereq.h @@ -6,8 +6,6 @@ #include "PackageTrust.h" #include "package_meta.h" -using namespace std; - // keeps the map sorted by name struct packagemeta_ltcomp { diff --git a/root.cc b/root.cc index e339d89..cf2bc32 100644 --- a/root.cc +++ b/root.cc @@ -38,8 +38,6 @@ #include "getopt++/StringOption.h" -using namespace std; - StringOption RootOption ("", 'R', "root", "Root installation directory", false); static ControlAdjuster::ControlInfo RootControlsInfo[] = { @@ -58,7 +56,7 @@ static ControlAdjuster::ControlInfo RootControlsInfo[] = { static int su[] = { IDC_ROOT_SYSTEM, IDC_ROOT_USER, 0 }; -static string orig_root_dir; +static std::string orig_root_dir; void RootPage::check_if_enable_next (HWND h) @@ -262,8 +260,8 @@ RootPage::Create () void RootPage::OnInit () { - if (((string)RootOption).size()) - set_root_dir((string)RootOption); + if (((std::string)RootOption).size()) + set_root_dir((std::string)RootOption); if (!get_root_dir ().size()) read_mounts (std::string ()); orig_root_dir = get_root_dir(); diff --git a/site.cc b/site.cc index b609ecf..ccffef5 100644 --- a/site.cc +++ b/site.cc @@ -41,11 +41,8 @@ #include "Exception.h" #include "String++.h" -using namespace std; - extern ThreeBarProgressPage Progress; - /* What to do if dropped mirrors are selected. */ @@ -76,11 +73,9 @@ SitePage::SitePage () #include "getopt++/BoolOption.h" #include "UserSettings.h" -using namespace std; - bool cache_is_usable; bool cache_needs_writing; -string cache_warn_urls; +std::string cache_warn_urls; /* Selected sites */ SiteList site_list; @@ -101,10 +96,10 @@ extern BoolOption UnsupportedOption; SiteSetting::SiteSetting (): saved (false) { - vector<string> SiteOptionStrings = SiteOption; + std::vector<std::string> SiteOptionStrings = SiteOption; if (SiteOptionStrings.size()) { - for (vector<string>::const_iterator n = SiteOptionStrings.begin (); + for (std::vector<std::string>::const_iterator n = SiteOptionStrings.begin (); n != SiteOptionStrings.end (); ++n) registerSavedSite (n->c_str ()); } @@ -141,10 +136,10 @@ SiteSetting::~SiteSetting () save (); } -site_list_type::site_list_type (const string &_url, - const string &_servername, - const string &_area, - const string &_location, +site_list_type::site_list_type (const std::string &_url, + const std::string &_servername, + const std::string &_area, + const std::string &_location, bool _from_mirrors_lst) { url = _url; @@ -158,14 +153,14 @@ site_list_type::site_list_type (const string &_url, url.append("/"); /* displayed_url is protocol and site name part of url */ - string::size_type path_offset = url.find ("/", url.find ("//") + 2); + std::string::size_type path_offset = url.find ("/", url.find ("//") + 2); displayed_url = url.substr(0, path_offset); /* the sorting key is hostname components in reverse order (to sort by country code) plus the url (to ensure uniqueness) */ - key = string(); - string::size_type last_idx = displayed_url.length () - 1; - string::size_type idx = url.find_last_of("./", last_idx); + key = std::string(); + std::string::size_type last_idx = displayed_url.length () - 1; + std::string::size_type idx = url.find_last_of("./", last_idx); if (last_idx - idx == 3) { /* Sort non-country TLDs (.com, .net, ...) together. */ @@ -177,7 +172,7 @@ site_list_type::site_list_type (const string &_url, key += " "; last_idx = idx - 1; idx = url.find_last_of("./", last_idx); - if (idx == string::npos) + if (idx == std::string::npos) idx = 0; } while (idx > 0); key += url; @@ -340,7 +335,7 @@ get_site_list (HINSTANCE h, HWND owner) if (LoadString (h, IDS_MIRROR_LST, mirror_url, sizeof (mirror_url)) <= 0) return 1; - string mirrors = OnlySiteOption ? string ("") : get_url_to_string (mirror_url, owner); + std::string mirrors = OnlySiteOption ? std::string ("") : get_url_to_string (mirror_url, owner); if (mirrors.size()) cache_needs_writing = true; else @@ -536,7 +531,6 @@ int check_dropped_mirrors (HWND h) void write_cache_list (io_stream *f, const SiteList& theSites) { - string s; for (SiteList::const_iterator n = theSites.begin (); n != theSites.end (); ++n) if (n->from_mirrors_lst) @@ -546,7 +540,6 @@ void write_cache_list (io_stream *f, const SiteList& theSites) void save_cache_file (int cache_action) { - string s; io_stream *f = UserSettings::instance().open ("mirrors-lst"); if (f) { diff --git a/tests/UserSettingTest.cc b/tests/UserSettingTest.cc index 6eb4127..7890468 100644 --- a/tests/UserSettingTest.cc +++ b/tests/UserSettingTest.cc @@ -34,8 +34,6 @@ static const char *cvsid = #include "UserSetting.h" #include "UserSettings.h" -using namespace std; - class TestSetting : public UserSetting { public: TestSetting(); diff --git a/tests/UserSettingsTest.cc b/tests/UserSettingsTest.cc index b481ea9..08e6952 100644 --- a/tests/UserSettingsTest.cc +++ b/tests/UserSettingsTest.cc @@ -34,8 +34,6 @@ static const char *cvsid = #include "UserSetting.h" #include "UserSettings.h" -using namespace std; - int main (int argc, char **argv) {
reply other threads:[~2018-10-07 19:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20181007194545.48515.qmail@sourceware.org \ --to=jturney@sourceware.org \ --cc=cygwin-apps-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).