1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 08:31:16 +02:00

Move some .drv parsing functions out of util

This commit is contained in:
Eelco Dolstra 2016-09-14 10:54:57 +02:00
parent 2c8c103ef8
commit e07c0dcf5c
3 changed files with 46 additions and 55 deletions

View file

@ -1087,47 +1087,6 @@ bool hasSuffix(const string & s, const string & suffix)
}
void expect(std::istream & str, const string & s)
{
char s2[s.size()];
str.read(s2, s.size());
if (string(s2, s.size()) != s)
throw FormatError(format("expected string %1%") % s);
}
string parseString(std::istream & str)
{
string res;
expect(str, "\"");
int c;
while ((c = str.get()) != '"')
if (c == '\\') {
c = str.get();
if (c == 'n') res += '\n';
else if (c == 'r') res += '\r';
else if (c == 't') res += '\t';
else res += c;
}
else res += c;
return res;
}
bool endOfList(std::istream & str)
{
if (str.peek() == ',') {
str.get();
return false;
}
if (str.peek() == ']') {
str.get();
return true;
}
return false;
}
string decodeOctalEscaped(const string & s)
{
string r;