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

* Don't use the ATerm library for parsing/printing .drv files.

This commit is contained in:
Eelco Dolstra 2010-04-19 13:46:58 +00:00
parent 55b5ddd3ca
commit efc7a579e8
14 changed files with 174 additions and 330 deletions

View file

@ -1006,6 +1006,47 @@ 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 Error(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;
}
void ignoreException()
{
try {