forked from lix-project/lix
Merge pull request #6139 from edolstra/no-std-aliases
Remove std aliases
This commit is contained in:
commit
3848a8edb8
23 changed files with 73 additions and 79 deletions
|
@ -208,7 +208,7 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
|
|
||||||
for (auto & m : machines)
|
for (auto & m : machines)
|
||||||
error
|
error
|
||||||
% concatStringsSep<vector<string>>(", ", m.systemTypes)
|
% concatStringsSep<std::vector<string>>(", ", m.systemTypes)
|
||||||
% m.maxJobs
|
% m.maxJobs
|
||||||
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
|
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
|
||||||
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
|
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
|
||||||
|
|
|
@ -266,7 +266,7 @@ void DrvInfo::setMeta(const string & name, Value * v)
|
||||||
|
|
||||||
|
|
||||||
/* Cache for already considered attrsets. */
|
/* Cache for already considered attrsets. */
|
||||||
typedef set<Bindings *> Done;
|
typedef std::set<Bindings *> Done;
|
||||||
|
|
||||||
|
|
||||||
/* Evaluate value `v'. If it evaluates to a set of type `derivation',
|
/* Evaluate value `v'. If it evaluates to a set of type `derivation',
|
||||||
|
|
|
@ -70,9 +70,9 @@ public:
|
||||||
|
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if HAVE_BOEHMGC
|
||||||
typedef list<DrvInfo, traceable_allocator<DrvInfo> > DrvInfos;
|
typedef std::list<DrvInfo, traceable_allocator<DrvInfo> > DrvInfos;
|
||||||
#else
|
#else
|
||||||
typedef list<DrvInfo> DrvInfos;
|
typedef std::list<DrvInfo> DrvInfos;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -335,8 +335,8 @@ struct ExprConcatStrings : Expr
|
||||||
{
|
{
|
||||||
Pos pos;
|
Pos pos;
|
||||||
bool forceString;
|
bool forceString;
|
||||||
vector<std::pair<Pos, Expr *> > * es;
|
std::vector<std::pair<Pos, Expr *> > * es;
|
||||||
ExprConcatStrings(const Pos & pos, bool forceString, vector<std::pair<Pos, Expr *> > * es)
|
ExprConcatStrings(const Pos & pos, bool forceString, std::vector<std::pair<Pos, Expr *> > * es)
|
||||||
: pos(pos), forceString(forceString), es(es) { };
|
: pos(pos), forceString(forceString), es(es) { };
|
||||||
COMMON_METHODS
|
COMMON_METHODS
|
||||||
};
|
};
|
||||||
|
|
|
@ -193,7 +193,7 @@ static Formals * toFormals(ParseData & data, ParserFormals * formals,
|
||||||
|
|
||||||
|
|
||||||
static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols,
|
static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols,
|
||||||
vector<std::pair<Pos, std::variant<Expr *, StringToken> > > & es)
|
std::vector<std::pair<Pos, std::variant<Expr *, StringToken> > > & es)
|
||||||
{
|
{
|
||||||
if (es.empty()) return new ExprString("");
|
if (es.empty()) return new ExprString("");
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strip spaces from each line. */
|
/* Strip spaces from each line. */
|
||||||
vector<std::pair<Pos, Expr *> > * es2 = new vector<std::pair<Pos, Expr *> >;
|
std::vector<std::pair<Pos, Expr *> > * es2 = new std::vector<std::pair<Pos, Expr *> >;
|
||||||
atStartOfLine = true;
|
atStartOfLine = true;
|
||||||
size_t curDropped = 0;
|
size_t curDropped = 0;
|
||||||
size_t n = es.size();
|
size_t n = es.size();
|
||||||
|
@ -415,7 +415,7 @@ expr_op
|
||||||
| expr_op UPDATE expr_op { $$ = new ExprOpUpdate(CUR_POS, $1, $3); }
|
| expr_op UPDATE expr_op { $$ = new ExprOpUpdate(CUR_POS, $1, $3); }
|
||||||
| expr_op '?' attrpath { $$ = new ExprOpHasAttr($1, *$3); }
|
| expr_op '?' attrpath { $$ = new ExprOpHasAttr($1, *$3); }
|
||||||
| expr_op '+' expr_op
|
| expr_op '+' expr_op
|
||||||
{ $$ = new ExprConcatStrings(CUR_POS, false, new vector<std::pair<Pos, Expr *> >({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); }
|
{ $$ = new ExprConcatStrings(CUR_POS, false, new std::vector<std::pair<Pos, Expr *> >({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); }
|
||||||
| expr_op '-' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__sub")), {$1, $3}); }
|
| expr_op '-' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__sub")), {$1, $3}); }
|
||||||
| expr_op '*' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__mul")), {$1, $3}); }
|
| expr_op '*' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__mul")), {$1, $3}); }
|
||||||
| expr_op '/' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__div")), {$1, $3}); }
|
| expr_op '/' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__div")), {$1, $3}); }
|
||||||
|
@ -503,9 +503,9 @@ string_parts_interpolated
|
||||||
: string_parts_interpolated STR
|
: string_parts_interpolated STR
|
||||||
{ $$ = $1; $1->emplace_back(makeCurPos(@2, data), new ExprString(string($2))); }
|
{ $$ = $1; $1->emplace_back(makeCurPos(@2, data), new ExprString(string($2))); }
|
||||||
| string_parts_interpolated DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
|
| string_parts_interpolated DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
|
||||||
| DOLLAR_CURLY expr '}' { $$ = new vector<std::pair<Pos, Expr *> >; $$->emplace_back(makeCurPos(@1, data), $2); }
|
| DOLLAR_CURLY expr '}' { $$ = new std::vector<std::pair<Pos, Expr *> >; $$->emplace_back(makeCurPos(@1, data), $2); }
|
||||||
| STR DOLLAR_CURLY expr '}' {
|
| STR DOLLAR_CURLY expr '}' {
|
||||||
$$ = new vector<std::pair<Pos, Expr *> >;
|
$$ = new std::vector<std::pair<Pos, Expr *> >;
|
||||||
$$->emplace_back(makeCurPos(@1, data), new ExprString(string($1)));
|
$$->emplace_back(makeCurPos(@1, data), new ExprString(string($1)));
|
||||||
$$->emplace_back(makeCurPos(@2, data), $3);
|
$$->emplace_back(makeCurPos(@2, data), $3);
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ path_start
|
||||||
ind_string_parts
|
ind_string_parts
|
||||||
: ind_string_parts IND_STR { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $2); }
|
: ind_string_parts IND_STR { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $2); }
|
||||||
| ind_string_parts DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
|
| ind_string_parts DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
|
||||||
| { $$ = new vector<std::pair<Pos, std::variant<Expr *, StringToken> > >; }
|
| { $$ = new std::vector<std::pair<Pos, std::variant<Expr *, StringToken> > >; }
|
||||||
;
|
;
|
||||||
|
|
||||||
binds
|
binds
|
||||||
|
@ -582,9 +582,9 @@ attrpath
|
||||||
} else
|
} else
|
||||||
$$->push_back(AttrName($3));
|
$$->push_back(AttrName($3));
|
||||||
}
|
}
|
||||||
| attr { $$ = new vector<AttrName>; $$->push_back(AttrName(data->symbols.create($1))); }
|
| attr { $$ = new std::vector<AttrName>; $$->push_back(AttrName(data->symbols.create($1))); }
|
||||||
| string_attr
|
| string_attr
|
||||||
{ $$ = new vector<AttrName>;
|
{ $$ = new std::vector<AttrName>;
|
||||||
ExprString *str = dynamic_cast<ExprString *>($1);
|
ExprString *str = dynamic_cast<ExprString *>($1);
|
||||||
if (str) {
|
if (str) {
|
||||||
$$->push_back(AttrName(data->symbols.create(str->s)));
|
$$->push_back(AttrName(data->symbols.create(str->s)));
|
||||||
|
|
|
@ -574,9 +574,9 @@ struct CompareValues
|
||||||
|
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if HAVE_BOEHMGC
|
||||||
typedef list<Value *, gc_allocator<Value *> > ValueList;
|
typedef std::list<Value *, gc_allocator<Value *> > ValueList;
|
||||||
#else
|
#else
|
||||||
typedef list<Value *> ValueList;
|
typedef std::list<Value *> ValueList;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
|
||||||
// `doneKeys' doesn't need to be a GC root, because its values are
|
// `doneKeys' doesn't need to be a GC root, because its values are
|
||||||
// reachable from res.
|
// reachable from res.
|
||||||
auto cmp = CompareValues(state);
|
auto cmp = CompareValues(state);
|
||||||
set<Value *, decltype(cmp)> doneKeys(cmp);
|
std::set<Value *, decltype(cmp)> doneKeys(cmp);
|
||||||
while (!workSet.empty()) {
|
while (!workSet.empty()) {
|
||||||
Value * e = *(workSet.begin());
|
Value * e = *(workSet.begin());
|
||||||
workSet.pop_front();
|
workSet.pop_front();
|
||||||
|
@ -3649,12 +3649,12 @@ static void prim_replaceStrings(EvalState & state, const Pos & pos, Value * * ar
|
||||||
.errPos = pos
|
.errPos = pos
|
||||||
});
|
});
|
||||||
|
|
||||||
vector<string> from;
|
std::vector<string> from;
|
||||||
from.reserve(args[0]->listSize());
|
from.reserve(args[0]->listSize());
|
||||||
for (auto elem : args[0]->listItems())
|
for (auto elem : args[0]->listItems())
|
||||||
from.emplace_back(state.forceString(*elem, pos));
|
from.emplace_back(state.forceString(*elem, pos));
|
||||||
|
|
||||||
vector<std::pair<string, PathSet>> to;
|
std::vector<std::pair<string, PathSet>> to;
|
||||||
to.reserve(args[1]->listSize());
|
to.reserve(args[1]->listSize());
|
||||||
for (auto elem : args[1]->listItems()) {
|
for (auto elem : args[1]->listItems()) {
|
||||||
PathSet ctx;
|
PathSet ctx;
|
||||||
|
|
|
@ -17,8 +17,8 @@ namespace nix {
|
||||||
class Symbol
|
class Symbol
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const string * s; // pointer into SymbolTable
|
const std::string * s; // pointer into SymbolTable
|
||||||
Symbol(const string * s) : s(s) { };
|
Symbol(const std::string * s) : s(s) { };
|
||||||
friend class SymbolTable;
|
friend class SymbolTable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -72,7 +72,7 @@ class SymbolTable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string_view, Symbol> symbols;
|
std::unordered_map<std::string_view, Symbol> symbols;
|
||||||
std::list<string> store;
|
std::list<std::string> store;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Symbol create(std::string_view s)
|
Symbol create(std::string_view s)
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
auto it = symbols.find(s);
|
auto it = symbols.find(s);
|
||||||
if (it != symbols.end()) return it->second;
|
if (it != symbols.end()) return it->second;
|
||||||
|
|
||||||
const string & rawSym = store.emplace_back(s);
|
auto & rawSym = store.emplace_back(s);
|
||||||
return symbols.emplace(rawSym, Symbol(&rawSym)).first->second;
|
return symbols.emplace(rawSym, Symbol(&rawSym)).first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,20 +77,20 @@ class ExternalValueBase
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Return a simple string describing the type */
|
/* Return a simple string describing the type */
|
||||||
virtual string showType() const = 0;
|
virtual std::string showType() const = 0;
|
||||||
|
|
||||||
/* Return a string to be used in builtins.typeOf */
|
/* Return a string to be used in builtins.typeOf */
|
||||||
virtual string typeOf() const = 0;
|
virtual std::string typeOf() const = 0;
|
||||||
|
|
||||||
/* Coerce the value to a string. Defaults to uncoercable, i.e. throws an
|
/* Coerce the value to a string. Defaults to uncoercable, i.e. throws an
|
||||||
* error
|
* error.
|
||||||
*/
|
*/
|
||||||
virtual string coerceToString(const Pos & pos, PathSet & context, bool copyMore, bool copyToStore) const;
|
virtual std::string coerceToString(const Pos & pos, PathSet & context, bool copyMore, bool copyToStore) const;
|
||||||
|
|
||||||
/* Compare to another value of the same type. Defaults to uncomparable,
|
/* Compare to another value of the same type. Defaults to uncomparable,
|
||||||
* i.e. always false.
|
* i.e. always false.
|
||||||
*/
|
*/
|
||||||
virtual bool operator==(const ExternalValueBase & b) const;
|
virtual bool operator ==(const ExternalValueBase & b) const;
|
||||||
|
|
||||||
/* Print the value as JSON. Defaults to unconvertable, i.e. throws an error */
|
/* Print the value as JSON. Defaults to unconvertable, i.e. throws an error */
|
||||||
virtual void printValueAsJSON(EvalState & state, bool strict,
|
virtual void printValueAsJSON(EvalState & state, bool strict,
|
||||||
|
|
|
@ -1091,7 +1091,7 @@ HookReply DerivationGoal::tryBuildHook()
|
||||||
/* Create the log file and pipe. */
|
/* Create the log file and pipe. */
|
||||||
Path logFile = openLogFile();
|
Path logFile = openLogFile();
|
||||||
|
|
||||||
set<int> fds;
|
std::set<int> fds;
|
||||||
fds.insert(hook->fromHook.readSide.get());
|
fds.insert(hook->fromHook.readSide.get());
|
||||||
fds.insert(hook->builderOut.readSide.get());
|
fds.insert(hook->builderOut.readSide.get());
|
||||||
worker.childStarted(shared_from_this(), fds, false, false);
|
worker.childStarted(shared_from_this(), fds, false, false);
|
||||||
|
|
|
@ -18,8 +18,8 @@ struct CompareGoalPtrs {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Set of goals. */
|
/* Set of goals. */
|
||||||
typedef set<GoalPtr, CompareGoalPtrs> Goals;
|
typedef std::set<GoalPtr, CompareGoalPtrs> Goals;
|
||||||
typedef set<WeakGoalPtr, std::owner_less<WeakGoalPtr>> WeakGoals;
|
typedef std::set<WeakGoalPtr, std::owner_less<WeakGoalPtr>> WeakGoals;
|
||||||
|
|
||||||
/* A map of paths to goals (and the other way around). */
|
/* A map of paths to goals (and the other way around). */
|
||||||
typedef std::map<StorePath, WeakGoalPtr> WeakGoalMap;
|
typedef std::map<StorePath, WeakGoalPtr> WeakGoalMap;
|
||||||
|
|
|
@ -161,7 +161,7 @@ unsigned Worker::getNrLocalBuilds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Worker::childStarted(GoalPtr goal, const set<int> & fds,
|
void Worker::childStarted(GoalPtr goal, const std::set<int> & fds,
|
||||||
bool inBuildSlot, bool respectTimeouts)
|
bool inBuildSlot, bool respectTimeouts)
|
||||||
{
|
{
|
||||||
Child child;
|
Child child;
|
||||||
|
@ -377,7 +377,7 @@ void Worker::waitForInput()
|
||||||
GoalPtr goal = j->goal.lock();
|
GoalPtr goal = j->goal.lock();
|
||||||
assert(goal);
|
assert(goal);
|
||||||
|
|
||||||
set<int> fds2(j->fds);
|
std::set<int> fds2(j->fds);
|
||||||
std::vector<unsigned char> buffer(4096);
|
std::vector<unsigned char> buffer(4096);
|
||||||
for (auto & k : fds2) {
|
for (auto & k : fds2) {
|
||||||
if (pollStatus.at(fdToPollStatus.at(k)).revents) {
|
if (pollStatus.at(fdToPollStatus.at(k)).revents) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct Child
|
||||||
{
|
{
|
||||||
WeakGoalPtr goal;
|
WeakGoalPtr goal;
|
||||||
Goal * goal2; // ugly hackery
|
Goal * goal2; // ugly hackery
|
||||||
set<int> fds;
|
std::set<int> fds;
|
||||||
bool respectTimeouts;
|
bool respectTimeouts;
|
||||||
bool inBuildSlot;
|
bool inBuildSlot;
|
||||||
steady_time_point lastOutput; /* time we last got output on stdout/stderr */
|
steady_time_point lastOutput; /* time we last got output on stdout/stderr */
|
||||||
|
@ -167,7 +167,7 @@ public:
|
||||||
|
|
||||||
/* Registers a running child process. `inBuildSlot' means that
|
/* Registers a running child process. `inBuildSlot' means that
|
||||||
the process counts towards the jobs limit. */
|
the process counts towards the jobs limit. */
|
||||||
void childStarted(GoalPtr goal, const set<int> & fds,
|
void childStarted(GoalPtr goal, const std::set<int> & fds,
|
||||||
bool inBuildSlot, bool respectTimeouts);
|
bool inBuildSlot, bool respectTimeouts);
|
||||||
|
|
||||||
/* Unregisters a running child process. `wakeSleepers' should be
|
/* Unregisters a running child process. `wakeSleepers' should be
|
||||||
|
|
|
@ -292,7 +292,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
typedef std::pair<dev_t, ino_t> Inode;
|
typedef std::pair<dev_t, ino_t> Inode;
|
||||||
typedef set<Inode> InodesSeen;
|
typedef std::set<Inode> InodesSeen;
|
||||||
|
|
||||||
|
|
||||||
/* "Fix", or canonicalise, the meta-data of the files in a store path
|
/* "Fix", or canonicalise, the meta-data of the files in a store path
|
||||||
|
|
|
@ -8,19 +8,19 @@ class Store;
|
||||||
|
|
||||||
struct Machine {
|
struct Machine {
|
||||||
|
|
||||||
const string storeUri;
|
const std::string storeUri;
|
||||||
const std::vector<string> systemTypes;
|
const std::vector<std::string> systemTypes;
|
||||||
const string sshKey;
|
const std::string sshKey;
|
||||||
const unsigned int maxJobs;
|
const unsigned int maxJobs;
|
||||||
const unsigned int speedFactor;
|
const unsigned int speedFactor;
|
||||||
const std::set<string> supportedFeatures;
|
const std::set<std::string> supportedFeatures;
|
||||||
const std::set<string> mandatoryFeatures;
|
const std::set<std::string> mandatoryFeatures;
|
||||||
const std::string sshPublicHostKey;
|
const std::string sshPublicHostKey;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
|
||||||
bool allSupported(const std::set<string> & features) const;
|
bool allSupported(const std::set<std::string> & features) const;
|
||||||
|
|
||||||
bool mandatoryMet(const std::set<string> & features) const;
|
bool mandatoryMet(const std::set<std::string> & features) const;
|
||||||
|
|
||||||
Machine(decltype(storeUri) storeUri,
|
Machine(decltype(storeUri) storeUri,
|
||||||
decltype(systemTypes) systemTypes,
|
decltype(systemTypes) systemTypes,
|
||||||
|
|
|
@ -10,9 +10,9 @@ struct Regex;
|
||||||
|
|
||||||
struct DrvName
|
struct DrvName
|
||||||
{
|
{
|
||||||
string fullName;
|
std::string fullName;
|
||||||
string name;
|
std::string name;
|
||||||
string version;
|
std::string version;
|
||||||
unsigned int hits;
|
unsigned int hits;
|
||||||
|
|
||||||
DrvName();
|
DrvName();
|
||||||
|
@ -25,7 +25,7 @@ private:
|
||||||
std::unique_ptr<Regex> regex;
|
std::unique_ptr<Regex> regex;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef list<DrvName> DrvNames;
|
typedef std::list<DrvName> DrvNames;
|
||||||
|
|
||||||
std::string_view nextComponent(std::string_view::const_iterator & p,
|
std::string_view nextComponent(std::string_view::const_iterator & p,
|
||||||
const std::string_view::const_iterator end);
|
const std::string_view::const_iterator end);
|
||||||
|
|
|
@ -20,7 +20,7 @@ class PathLocks
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef std::pair<int, Path> FDPair;
|
typedef std::pair<int, Path> FDPair;
|
||||||
list<FDPair> fds;
|
std::list<FDPair> fds;
|
||||||
bool deletePaths;
|
bool deletePaths;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -90,7 +90,7 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
|
||||||
if (hash != string::npos)
|
if (hash != string::npos)
|
||||||
line = string(line, 0, hash);
|
line = string(line, 0, hash);
|
||||||
|
|
||||||
vector<string> tokens = tokenizeString<vector<string> >(line);
|
auto tokens = tokenizeString<std::vector<string>>(line);
|
||||||
if (tokens.empty()) continue;
|
if (tokens.empty()) continue;
|
||||||
|
|
||||||
if (tokens.size() < 2)
|
if (tokens.size() < 2)
|
||||||
|
@ -122,7 +122,7 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
|
||||||
|
|
||||||
string name = tokens[0];
|
string name = tokens[0];
|
||||||
|
|
||||||
vector<string>::iterator i = tokens.begin();
|
auto i = tokens.begin();
|
||||||
advance(i, 2);
|
advance(i, 2);
|
||||||
|
|
||||||
set(name, concatStringsSep(" ", Strings(i, tokens.end()))); // FIXME: slow
|
set(name, concatStringsSep(" ", Strings(i, tokens.end()))); // FIXME: slow
|
||||||
|
|
|
@ -11,23 +11,17 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
using std::list;
|
typedef std::list<std::string> Strings;
|
||||||
using std::set;
|
typedef std::set<std::string> StringSet;
|
||||||
using std::vector;
|
typedef std::map<std::string, std::string> StringMap;
|
||||||
using std::string;
|
|
||||||
|
|
||||||
typedef list<string> Strings;
|
|
||||||
typedef set<string> StringSet;
|
|
||||||
typedef std::map<string, string> StringMap;
|
|
||||||
|
|
||||||
/* Paths are just strings. */
|
/* Paths are just strings. */
|
||||||
|
typedef std::string Path;
|
||||||
typedef string Path;
|
|
||||||
typedef std::string_view PathView;
|
typedef std::string_view PathView;
|
||||||
typedef list<Path> Paths;
|
typedef std::list<Path> Paths;
|
||||||
typedef set<Path> PathSet;
|
typedef std::set<Path> PathSet;
|
||||||
|
|
||||||
typedef vector<std::pair<string, string>> Headers;
|
typedef std::vector<std::pair<std::string, std::string>> Headers;
|
||||||
|
|
||||||
/* Helper class to run code at startup. */
|
/* Helper class to run code at startup. */
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -1174,7 +1174,7 @@ void runProgram2(const RunOptions & options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void closeMostFDs(const set<int> & exceptions)
|
void closeMostFDs(const std::set<int> & exceptions)
|
||||||
{
|
{
|
||||||
#if __linux__
|
#if __linux__
|
||||||
try {
|
try {
|
||||||
|
@ -1250,7 +1250,7 @@ template<class C> C tokenizeString(std::string_view s, std::string_view separato
|
||||||
|
|
||||||
template Strings tokenizeString(std::string_view s, std::string_view separators);
|
template Strings tokenizeString(std::string_view s, std::string_view separators);
|
||||||
template StringSet tokenizeString(std::string_view s, std::string_view separators);
|
template StringSet tokenizeString(std::string_view s, std::string_view separators);
|
||||||
template vector<string> tokenizeString(std::string_view s, std::string_view separators);
|
template std::vector<string> tokenizeString(std::string_view s, std::string_view separators);
|
||||||
|
|
||||||
|
|
||||||
string chomp(std::string_view s)
|
string chomp(std::string_view s)
|
||||||
|
|
|
@ -99,7 +99,7 @@ struct DirEntry
|
||||||
: name(name), ino(ino), type(type) { }
|
: name(name), ino(ino), type(type) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<DirEntry> DirEntries;
|
typedef std::vector<DirEntry> DirEntries;
|
||||||
|
|
||||||
DirEntries readDirectory(const Path & path);
|
DirEntries readDirectory(const Path & path);
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ std::vector<char *> stringsToCharPtrs(const Strings & ss);
|
||||||
|
|
||||||
/* Close all file descriptors except those listed in the given set.
|
/* Close all file descriptors except those listed in the given set.
|
||||||
Good practice in child processes. */
|
Good practice in child processes. */
|
||||||
void closeMostFDs(const set<int> & exceptions);
|
void closeMostFDs(const std::set<int> & exceptions);
|
||||||
|
|
||||||
/* Set the close-on-exec flag for the given file descriptor. */
|
/* Set the close-on-exec flag for the given file descriptor. */
|
||||||
void closeOnExec(int fd);
|
void closeOnExec(int fd);
|
||||||
|
|
|
@ -840,7 +840,7 @@ void printTable(Table & table)
|
||||||
{
|
{
|
||||||
auto nrColumns = table.size() > 0 ? table.front().size() : 0;
|
auto nrColumns = table.size() > 0 ? table.front().size() : 0;
|
||||||
|
|
||||||
vector<size_t> widths;
|
std::vector<size_t> widths;
|
||||||
widths.resize(nrColumns);
|
widths.resize(nrColumns);
|
||||||
|
|
||||||
for (auto & i : table) {
|
for (auto & i : table) {
|
||||||
|
@ -907,7 +907,7 @@ static VersionDiff compareVersionAgainstSet(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutPath, bool printMeta)
|
static void queryJSON(Globals & globals, std::vector<DrvInfo> & elems, bool printOutPath, bool printMeta)
|
||||||
{
|
{
|
||||||
JSONObject topObj(cout, true);
|
JSONObject topObj(cout, true);
|
||||||
for (auto & i : elems) {
|
for (auto & i : elems) {
|
||||||
|
@ -1020,7 +1020,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
/* Sort them by name. */
|
/* Sort them by name. */
|
||||||
/* !!! */
|
/* !!! */
|
||||||
vector<DrvInfo> elems;
|
std::vector<DrvInfo> elems;
|
||||||
for (auto & i : elems_) elems.push_back(i);
|
for (auto & i : elems_) elems.push_back(i);
|
||||||
sort(elems.begin(), elems.end(), cmpElemByName);
|
sort(elems.begin(), elems.end(), cmpElemByName);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct NixRepl
|
||||||
Expr * parseString(string s);
|
Expr * parseString(string s);
|
||||||
void evalString(string s, Value & v);
|
void evalString(string s, Value & v);
|
||||||
|
|
||||||
typedef set<Value *> ValuesSeen;
|
typedef std::set<Value *> ValuesSeen;
|
||||||
std::ostream & printValue(std::ostream & str, Value & v, unsigned int maxDepth);
|
std::ostream & printValue(std::ostream & str, Value & v, unsigned int maxDepth);
|
||||||
std::ostream & printValue(std::ostream & str, Value & v, unsigned int maxDepth, ValuesSeen & seen);
|
std::ostream & printValue(std::ostream & str, Value & v, unsigned int maxDepth, ValuesSeen & seen);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,9 +23,9 @@ Path resolveCacheFile(Path lib)
|
||||||
return cacheDir + "/" + lib;
|
return cacheDir + "/" + lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<string> readCacheFile(const Path & file)
|
std::set<std::string> readCacheFile(const Path & file)
|
||||||
{
|
{
|
||||||
return tokenizeString<set<string>>(readFile(file), "\n");
|
return tokenizeString<std::set<std::string>>(readFile(file), "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> runResolver(const Path & filename)
|
std::set<std::string> runResolver(const Path & filename)
|
||||||
|
@ -81,7 +81,7 @@ std::set<std::string> runResolver(const Path & filename)
|
||||||
bool should_swap = magic == MH_CIGAM_64;
|
bool should_swap = magic == MH_CIGAM_64;
|
||||||
ptrdiff_t cmd_offset = mach64_offset + sizeof(mach_header_64);
|
ptrdiff_t cmd_offset = mach64_offset + sizeof(mach_header_64);
|
||||||
|
|
||||||
std::set<string> libs;
|
std::set<std::string> libs;
|
||||||
for (uint32_t i = 0; i < DO_SWAP(should_swap, m_header->ncmds); i++) {
|
for (uint32_t i = 0; i < DO_SWAP(should_swap, m_header->ncmds); i++) {
|
||||||
load_command * cmd = (load_command *) (obj + cmd_offset);
|
load_command * cmd = (load_command *) (obj + cmd_offset);
|
||||||
switch(DO_SWAP(should_swap, cmd->cmd)) {
|
switch(DO_SWAP(should_swap, cmd->cmd)) {
|
||||||
|
@ -110,9 +110,9 @@ Path resolveSymlink(const Path & path)
|
||||||
: concatStrings(dirOf(path), "/", target);
|
: concatStrings(dirOf(path), "/", target);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<string> resolveTree(const Path & path, PathSet & deps)
|
std::set<std::string> resolveTree(const Path & path, PathSet & deps)
|
||||||
{
|
{
|
||||||
std::set<string> results;
|
std::set<std::string> results;
|
||||||
if (!deps.insert(path).second) return {};
|
if (!deps.insert(path).second) return {};
|
||||||
for (auto & lib : runResolver(path)) {
|
for (auto & lib : runResolver(path)) {
|
||||||
results.insert(lib);
|
results.insert(lib);
|
||||||
|
@ -123,7 +123,7 @@ std::set<string> resolveTree(const Path & path, PathSet & deps)
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<string> getPath(const Path & path)
|
std::set<std::string> getPath(const Path & path)
|
||||||
{
|
{
|
||||||
if (hasPrefix(path, "/dev")) return {};
|
if (hasPrefix(path, "/dev")) return {};
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ std::set<string> getPath(const Path & path)
|
||||||
if (pathExists(cacheFile))
|
if (pathExists(cacheFile))
|
||||||
return readCacheFile(cacheFile);
|
return readCacheFile(cacheFile);
|
||||||
|
|
||||||
std::set<string> deps, paths;
|
std::set<std::string> deps, paths;
|
||||||
paths.insert(path);
|
paths.insert(path);
|
||||||
|
|
||||||
Path nextPath(path);
|
Path nextPath(path);
|
||||||
|
@ -180,7 +180,7 @@ int main(int argc, char ** argv)
|
||||||
impurePaths.insert("/usr/lib/libSystem.dylib");
|
impurePaths.insert("/usr/lib/libSystem.dylib");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<string> allPaths;
|
std::set<std::string> allPaths;
|
||||||
|
|
||||||
for (auto & path : impurePaths)
|
for (auto & path : impurePaths)
|
||||||
for (auto & p : getPath(path))
|
for (auto & p : getPath(path))
|
||||||
|
|
Loading…
Reference in a new issue