[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/07: daemon: int2String -> std::to_string.
From: |
Ludovic Courtès |
Subject: |
03/07: daemon: int2String -> std::to_string. |
Date: |
Wed, 02 Dec 2015 17:39:09 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit 79aa1a83054af1600ba235ddf305337b5df78271
Author: Eelco Dolstra <address@hidden>
Date: Wed Dec 2 16:51:00 2015 +0200
daemon: int2String -> std::to_string.
---
nix/libutil/archive.cc | 2 +-
nix/libutil/util.cc | 2 +-
nix/libutil/util.hh | 7 -------
nix/nix-daemon/nix-daemon.cc | 18 +++++++++---------
4 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/nix/libutil/archive.cc b/nix/libutil/archive.cc
index 6856ea0..4e3d993 100644
--- a/nix/libutil/archive.cc
+++ b/nix/libutil/archive.cc
@@ -256,7 +256,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;
}
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 14026ab..c077544 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -433,7 +433,7 @@ Nest::~Nest()
static string escVerbosity(Verbosity level)
{
- return int2String((int) level);
+ return std::to_string((int) level);
}
diff --git a/nix/libutil/util.hh b/nix/libutil/util.hh
index 24e16ba..8fa1efb 100644
--- a/nix/libutil/util.hh
+++ b/nix/libutil/util.hh
@@ -337,13 +337,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);
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 10159db..bd9eebe 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -441,8 +441,8 @@ static void performOp(bool trusted, unsigned int
clientVersion,
startWork();
TunnelSource source(from);
- /* Unlike Nix, always require a signature, even for "trusted"
- users. */
+ /* Unlike Nix, always require a signature, even for "trusted"
+ users. */
Paths paths = store->importPaths(true, source);
stopWork();
writeStrings(paths, to);
@@ -538,8 +538,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) {
@@ -548,7 +548,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) {
@@ -819,7 +819,7 @@ static void daemonLoop()
/* 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;
}
@@ -906,10 +906,10 @@ static void daemonLoop()
clientPid = cred.pid;
struct passwd * pw = getpwuid(cred.uid);
- string user = pw ? pw->pw_name : int2String(cred.uid);
+ string user = pw ? pw->pw_name : std::to_string(cred.uid);
struct group * gr = getgrgid(cred.gid);
- string group = gr ? gr->gr_name : int2String(cred.gid);
+ string group = gr ? gr->gr_name : std::to_string(cred.gid);
Strings trustedUsers = settings.get("trusted-users",
Strings({"root"}));
Strings allowedUsers = settings.get("allowed-users",
Strings({"*"}));
@@ -937,7 +937,7 @@ static void daemonLoop()
/* For debugging, stuff the pid into argv[1]. */
if (clientPid != -1 && argvSaved[1]) {
- string processName = int2String(clientPid);
+ string processName = std::to_string(clientPid);
strncpy(argvSaved[1], processName.c_str(),
strlen(argvSaved[1]));
}
- branch master updated (18b3151 -> 708d907), Ludovic Courtès, 2015/12/02
- 04/07: daemon: Support SHA-512 hashes., Ludovic Courtès, 2015/12/02
- 03/07: daemon: int2String -> std::to_string.,
Ludovic Courtès <=
- 07/07: daemon: Add 'buildMode' parameter to 'buildPaths' RPC., Ludovic Courtès, 2015/12/02
- 06/07: daemon: optimizePath: Detect some .links corruptions., Ludovic Courtès, 2015/12/02
- 05/07: daemon: Fix namespace issue., Ludovic Courtès, 2015/12/02
- 02/07: daemon: Filter build-chroot-dirs entries that conflict with derivation outputs., Ludovic Courtès, 2015/12/02
- 01/07: daemon: Prevent .chroot from being GC'ed when using LocalStore::buildDerivation(), Ludovic Courtès, 2015/12/02