mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 12:10:59 +01:00
Fixed backwards compatible hack & added state creation call after build
This commit is contained in:
parent
73995157e3
commit
86b053dd80
5 changed files with 67 additions and 16 deletions
|
|
@ -974,5 +974,38 @@ string bool2string(const bool b)
|
|||
return "false";
|
||||
}
|
||||
|
||||
bool string2bool(const string & s)
|
||||
{
|
||||
if(s == "true")
|
||||
return true;
|
||||
else if(s == "false")
|
||||
return false;
|
||||
else{
|
||||
throw Error(format("cannot convert string: `%1%' to bool") % s);
|
||||
quickExit(1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
string triml(const string & s) {
|
||||
string news = s;
|
||||
int pos(0);
|
||||
for ( ; news[pos]==' ' || news[pos]=='\t'; ++pos );
|
||||
news.erase(0, pos);
|
||||
return news;
|
||||
}
|
||||
|
||||
string trimr(const string & s) {
|
||||
string news = s;
|
||||
int pos(news.size());
|
||||
for ( ; pos && news[pos-1]==' ' || news[pos]=='\t'; --pos );
|
||||
news.erase(pos, news.size()-pos);
|
||||
return news;
|
||||
}
|
||||
|
||||
string trim(const string & s) {
|
||||
return triml(trimr(s));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,10 +279,18 @@ bool statusOk(int status);
|
|||
string int2String(int n);
|
||||
bool string2Int(const string & s, int & n);
|
||||
|
||||
/* Parse a bool to a string */
|
||||
/* Parse a bool to a string and back */
|
||||
string bool2string(const bool b);
|
||||
bool string2bool(const string & s);
|
||||
|
||||
//return modified string s with spaces trimmed from left
|
||||
string triml(const string & s);
|
||||
//return modified string s with spaces trimmed from right
|
||||
string trimr(const string & s);
|
||||
//return modified string s with spaces trimmed from edges
|
||||
string trim(const string & s);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* !__UTIL_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue