Use data() instead of c_str() where appropriate
This commit is contained in:
parent
ec2827f5fc
commit
d5a5a83ad4
9 changed files with 18 additions and 18 deletions
|
@ -1379,7 +1379,7 @@ HookReply DerivationGoal::tryBuildHook()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s += "\n";
|
s += "\n";
|
||||||
writeToStderr((unsigned char *) s.c_str(), s.size());
|
writeToStderr((unsigned char *) s.data(), s.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(format("hook reply is `%1%'") % reply);
|
debug(format("hook reply is `%1%'") % reply);
|
||||||
|
@ -2036,12 +2036,12 @@ void DerivationGoal::handleChildOutput(int fd, const string & data)
|
||||||
(!hook && fd == builderOut.readSide))
|
(!hook && fd == builderOut.readSide))
|
||||||
{
|
{
|
||||||
if (verbosity >= buildVerbosity)
|
if (verbosity >= buildVerbosity)
|
||||||
writeToStderr((unsigned char *) data.c_str(), data.size());
|
writeToStderr((unsigned char *) data.data(), data.size());
|
||||||
writeFull(fdLogFile, (unsigned char *) data.c_str(), data.size());
|
writeFull(fdLogFile, (unsigned char *) data.data(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hook && fd == hook->fromHook.readSide)
|
if (hook && fd == hook->fromHook.readSide)
|
||||||
writeToStderr((unsigned char *) data.c_str(), data.size());
|
writeToStderr((unsigned char *) data.data(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2409,7 +2409,7 @@ void SubstitutionGoal::handleChildOutput(int fd, const string & data)
|
||||||
{
|
{
|
||||||
assert(fd == logPipe.readSide);
|
assert(fd == logPipe.readSide);
|
||||||
if (verbosity >= buildVerbosity)
|
if (verbosity >= buildVerbosity)
|
||||||
writeToStderr((unsigned char *) data.c_str(), data.size());
|
writeToStderr((unsigned char *) data.data(), data.size());
|
||||||
/* Don't write substitution output to a log file for now. We
|
/* Don't write substitution output to a log file for now. We
|
||||||
probably should, though. */
|
probably should, though. */
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ void LocalStore::addTempRoot(const Path & path)
|
||||||
lockFile(fdTempRoots, ltWrite, true);
|
lockFile(fdTempRoots, ltWrite, true);
|
||||||
|
|
||||||
string s = path + '\0';
|
string s = path + '\0';
|
||||||
writeFull(fdTempRoots, (const unsigned char *) s.c_str(), s.size());
|
writeFull(fdTempRoots, (const unsigned char *) s.data(), s.size());
|
||||||
|
|
||||||
/* Downgrade to a read lock. */
|
/* Downgrade to a read lock. */
|
||||||
debug(format("downgrading to read lock on `%1%'") % fnTempRoots);
|
debug(format("downgrading to read lock on `%1%'") % fnTempRoots);
|
||||||
|
|
|
@ -69,7 +69,7 @@ void RefScanSink::operator () (const unsigned char * data, size_t len)
|
||||||
fragment, so search in the concatenation of the tail of the
|
fragment, so search in the concatenation of the tail of the
|
||||||
previous fragment and the start of the current fragment. */
|
previous fragment and the start of the current fragment. */
|
||||||
string s = tail + string((const char *) data, len > refLength ? refLength : len);
|
string s = tail + string((const char *) data, len > refLength ? refLength : len);
|
||||||
search((const unsigned char *) s.c_str(), s.size(), hashes, seen);
|
search((const unsigned char *) s.data(), s.size(), hashes, seen);
|
||||||
|
|
||||||
search(data, len, hashes, seen);
|
search(data, len, hashes, seen);
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,7 @@ void RemoteStore::processStderr(Sink * sink, Source * source)
|
||||||
if (msg == STDERR_WRITE) {
|
if (msg == STDERR_WRITE) {
|
||||||
string s = readString(from);
|
string s = readString(from);
|
||||||
if (!sink) throw Error("no sink");
|
if (!sink) throw Error("no sink");
|
||||||
(*sink)((const unsigned char *) s.c_str(), s.size());
|
(*sink)((const unsigned char *) s.data(), s.size());
|
||||||
}
|
}
|
||||||
else if (msg == STDERR_READ) {
|
else if (msg == STDERR_READ) {
|
||||||
if (!source) throw Error("no source");
|
if (!source) throw Error("no source");
|
||||||
|
@ -521,7 +521,7 @@ void RemoteStore::processStderr(Sink * sink, Source * source)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
string s = readString(from);
|
string s = readString(from);
|
||||||
writeToStderr((const unsigned char *) s.c_str(), s.size());
|
writeToStderr((const unsigned char *) s.data(), s.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg == STDERR_ERROR) {
|
if (msg == STDERR_ERROR) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ string printHash32(const Hash & hash)
|
||||||
Hash hash2(hash);
|
Hash hash2(hash);
|
||||||
unsigned int len = hashLength32(hash);
|
unsigned int len = hashLength32(hash);
|
||||||
|
|
||||||
const char * chars = base32Chars.c_str();
|
const char * chars = base32Chars.data();
|
||||||
|
|
||||||
string s(len, '0');
|
string s(len, '0');
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ Hash parseHash32(HashType ht, const string & s)
|
||||||
{
|
{
|
||||||
Hash hash(ht);
|
Hash hash(ht);
|
||||||
|
|
||||||
const char * chars = base32Chars.c_str();
|
const char * chars = base32Chars.data();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < s.length(); ++i) {
|
for (unsigned int i = 0; i < s.length(); ++i) {
|
||||||
char c = s[i];
|
char c = s[i];
|
||||||
|
@ -271,7 +271,7 @@ Hash hashString(HashType ht, const string & s)
|
||||||
Ctx ctx;
|
Ctx ctx;
|
||||||
Hash hash(ht);
|
Hash hash(ht);
|
||||||
start(ht, ctx);
|
start(ht, ctx);
|
||||||
update(ht, ctx, (const unsigned char *) s.c_str(), s.length());
|
update(ht, ctx, (const unsigned char *) s.data(), s.length());
|
||||||
finish(ht, ctx, hash.hash);
|
finish(ht, ctx, hash.hash);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ void writeString(const unsigned char * buf, size_t len, Sink & sink)
|
||||||
|
|
||||||
void writeString(const string & s, Sink & sink)
|
void writeString(const string & s, Sink & sink)
|
||||||
{
|
{
|
||||||
writeString((const unsigned char *) s.c_str(), s.size(), sink);
|
writeString((const unsigned char *) s.data(), s.size(), sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,7 @@ void writeFile(const Path & path, const string & s)
|
||||||
AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666);
|
AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
throw SysError(format("opening file `%1%'") % path);
|
throw SysError(format("opening file `%1%'") % path);
|
||||||
writeFull(fd, (unsigned char *) s.c_str(), s.size());
|
writeFull(fd, (unsigned char *) s.data(), s.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ string readLine(int fd)
|
||||||
void writeLine(int fd, string s)
|
void writeLine(int fd, string s)
|
||||||
{
|
{
|
||||||
s += '\n';
|
s += '\n';
|
||||||
writeFull(fd, (const unsigned char *) s.c_str(), s.size());
|
writeFull(fd, (const unsigned char *) s.data(), s.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ void printMsg_(Verbosity level, const format & f)
|
||||||
prefix = "\033[" + escVerbosity(level) + "s";
|
prefix = "\033[" + escVerbosity(level) + "s";
|
||||||
string s = (format("%1%%2%\n") % prefix % f.str()).str();
|
string s = (format("%1%%2%\n") % prefix % f.str()).str();
|
||||||
try {
|
try {
|
||||||
writeToStderr((const unsigned char *) s.c_str(), s.size());
|
writeToStderr((const unsigned char *) s.data(), s.size());
|
||||||
} catch (SysError & e) {
|
} catch (SysError & e) {
|
||||||
/* Ignore failing writes to stderr if we're in an exception
|
/* Ignore failing writes to stderr if we're in an exception
|
||||||
handler, otherwise throw an exception. We need to ignore
|
handler, otherwise throw an exception. We need to ignore
|
||||||
|
|
|
@ -432,7 +432,7 @@ static void opReadLog(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
/* !!! Make this run in O(1) memory. */
|
/* !!! Make this run in O(1) memory. */
|
||||||
string log = readFile(logPath);
|
string log = readFile(logPath);
|
||||||
writeFull(STDOUT_FILENO, (const unsigned char *) log.c_str(), log.size());
|
writeFull(STDOUT_FILENO, (const unsigned char *) log.data(), log.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ static void sigPollHandler(int sigNo)
|
||||||
catch (Error & e) {
|
catch (Error & e) {
|
||||||
/* Shouldn't happen. */
|
/* Shouldn't happen. */
|
||||||
string s = "impossible: " + e.msg() + '\n';
|
string s = "impossible: " + e.msg() + '\n';
|
||||||
write(STDERR_FILENO, s.c_str(), s.size());
|
write(STDERR_FILENO, s.data(), s.size());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue