int2String() -> std::to_string()

This commit is contained in:
Eelco Dolstra 2015-10-29 13:26:55 +01:00
parent 71039becd1
commit 5c28943e8f
9 changed files with 17 additions and 24 deletions

View file

@ -1392,7 +1392,7 @@ string EvalState::coerceToString(const Pos & pos, Value & v, PathSet & context,
shell scripting convenience, just like `null'. */
if (v.type == tBool && v.boolean) return "1";
if (v.type == tBool && !v.boolean) return "";
if (v.type == tInt) return int2String(v.integer);
if (v.type == tInt) return std::to_string(v.integer);
if (v.type == tNull) return "";
if (v.isList()) {

View file

@ -1732,7 +1732,7 @@ void DerivationGoal::startBuilder()
if (passAsFile.find(i.first) == passAsFile.end()) {
env[i.first] = i.second;
} else {
Path p = tmpDir + "/.attr-" + int2String(fileNr++);
Path p = tmpDir + "/.attr-" + std::to_string(fileNr++);
writeFile(p, i.second);
filesToChown.insert(p);
env[i.first + "Path"] = p;
@ -2142,7 +2142,7 @@ void DerivationGoal::startBuilder()
CLONE_PARENT are not allowed together. */
child = clone(childEntry, stack + stackSize, flags & ~CLONE_NEWPID, this);
if (child == -1) throw SysError("cloning builder process");
writeFull(builderOut.writeSide, int2String(child) + "\n");
writeFull(builderOut.writeSide, std::to_string(child) + "\n");
_exit(0);
}, options);
if (helper.wait(true) != 0)

View file

@ -240,7 +240,7 @@ Path downloadFileCached(const string & url, bool unpack)
assert(!storePath.empty());
replaceSymlink(storePath, fileLink);
writeFile(dataFile, url + "\n" + res.etag + "\n" + int2String(time(0)) + "\n");
writeFile(dataFile, url + "\n" + res.etag + "\n" + std::to_string(time(0)) + "\n");
} catch (DownloadError & e) {
if (storePath.empty()) throw;
printMsg(lvlError, format("warning: %1%; using cached result") % e.msg());

View file

@ -243,7 +243,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
if (i != names.end()) {
printMsg(lvlDebug, format("case collision between %1% and %2%") % i->first % name);
name += caseHackSuffix;
name += int2String(++i->second);
name += std::to_string(++i->second);
} else
names[name] = 0;
}

View file

@ -453,7 +453,7 @@ Nest::~Nest()
static string escVerbosity(Verbosity level)
{
return int2String((int) level);
return std::to_string((int) level);
}

View file

@ -356,13 +356,6 @@ template<class N> bool string2Int(const string & s, N & n)
return str && str.get() == EOF;
}
template<class N> string int2String(N n)
{
std::ostringstream str;
str << n;
return str.str();
}
/* Return true iff `s' ends in `suffix'. */
bool hasSuffix(const string & s, const string & suffix);

View file

@ -416,8 +416,8 @@ static void performOp(bool trusted, unsigned int clientVersion,
settings.keepGoing = readInt(from) != 0;
settings.set("build-fallback", readInt(from) ? "true" : "false");
verbosity = (Verbosity) readInt(from);
settings.set("build-max-jobs", int2String(readInt(from)));
settings.set("build-max-silent-time", int2String(readInt(from)));
settings.set("build-max-jobs", std::to_string(readInt(from)));
settings.set("build-max-silent-time", std::to_string(readInt(from)));
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
settings.useBuildHook = readInt(from) != 0;
if (GET_PROTOCOL_MINOR(clientVersion) >= 4) {
@ -426,7 +426,7 @@ static void performOp(bool trusted, unsigned int clientVersion,
settings.printBuildTrace = readInt(from) != 0;
}
if (GET_PROTOCOL_MINOR(clientVersion) >= 6)
settings.set("build-cores", int2String(readInt(from)));
settings.set("build-cores", std::to_string(readInt(from)));
if (GET_PROTOCOL_MINOR(clientVersion) >= 10)
settings.set("build-use-substitutes", readInt(from) ? "true" : "false");
if (GET_PROTOCOL_MINOR(clientVersion) >= 12) {
@ -720,7 +720,7 @@ static void daemonLoop(char * * argv)
/* Handle socket-based activation by systemd. */
if (getEnv("LISTEN_FDS") != "") {
if (getEnv("LISTEN_PID") != int2String(getpid()) || getEnv("LISTEN_FDS") != "1")
if (getEnv("LISTEN_PID") != std::to_string(getpid()) || getEnv("LISTEN_FDS") != "1")
throw Error("unexpected systemd environment variables");
fdSocket = SD_LISTEN_FDS_START;
}
@ -796,10 +796,10 @@ static void daemonLoop(char * * argv)
PeerInfo peer = getPeerInfo(remote);
struct passwd * pw = peer.uidKnown ? getpwuid(peer.uid) : 0;
string user = pw ? pw->pw_name : int2String(peer.uid);
string user = pw ? pw->pw_name : std::to_string(peer.uid);
struct group * gr = peer.gidKnown ? getgrgid(peer.gid) : 0;
string group = gr ? gr->gr_name : int2String(peer.gid);
string group = gr ? gr->gr_name : std::to_string(peer.gid);
Strings trustedUsers = settings.get("trusted-users", Strings({"root"}));
Strings allowedUsers = settings.get("allowed-users", Strings({"*"}));
@ -811,7 +811,7 @@ static void daemonLoop(char * * argv)
throw Error(format("user %1% is not allowed to connect to the Nix daemon") % user);
printMsg(lvlInfo, format((string) "accepted connection from pid %1%, user %2%" + (trusted ? " (trusted)" : ""))
% (peer.pidKnown ? int2String(peer.pid) : "<unknown>")
% (peer.pidKnown ? std::to_string(peer.pid) : "<unknown>")
% (peer.uidKnown ? user : "<unknown>"));
/* Fork a child to handle the connection. */
@ -832,7 +832,7 @@ static void daemonLoop(char * * argv)
/* For debugging, stuff the pid into argv[1]. */
if (peer.pidKnown && argv[1]) {
string processName = int2String(peer.pid);
string processName = std::to_string(peer.pid);
strncpy(argv[1], processName.c_str(), strlen(argv[1]));
}

View file

@ -79,7 +79,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
printGCWarning();
else {
Path rootName = gcRoot;
if (++rootNr > 1) rootName += "-" + int2String(rootNr);
if (++rootNr > 1) rootName += "-" + std::to_string(rootNr);
drvPath = addPermRoot(*store, drvPath, rootName, indirectRoot);
}
std::cout << format("%1%%2%\n") % drvPath % (outputName != "out" ? "!" + outputName : "");

View file

@ -81,7 +81,7 @@ static PathSet realisePath(Path path, bool build = true)
printGCWarning();
else {
Path rootName = gcRoot;
if (rootNr > 1) rootName += "-" + int2String(rootNr);
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
if (i->first != "out") rootName += "-" + i->first;
outPath = addPermRoot(*store, outPath, rootName, indirectRoot);
}
@ -98,7 +98,7 @@ static PathSet realisePath(Path path, bool build = true)
else {
Path rootName = gcRoot;
rootNr++;
if (rootNr > 1) rootName += "-" + int2String(rootNr);
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
path = addPermRoot(*store, path, rootName, indirectRoot);
}
return singleton<PathSet>(path);