mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
* Strip off the `.nix' suffix from the attribute name for files in
~/.nix-defexpr, otherwise the attribute cannot be selected with the `-A' option. Useful if you want to stick a Nix expression directly in ~/.nix-defexpr.
This commit is contained in:
parent
cc826dc03e
commit
b428adc267
5 changed files with 27 additions and 6 deletions
|
@ -257,6 +257,7 @@ Hash hashString(HashType ht, const string & s)
|
|||
start(ht, ctx);
|
||||
update(ht, ctx, (const unsigned char *) s.c_str(), s.length());
|
||||
finish(ht, ctx, hash.hash);
|
||||
//printMsg(lvlError, format("hashString %1% --> %2%:\n%3%\n===========END======") % s.size() % printHash(hash) % s);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
|
@ -1046,6 +1046,12 @@ bool string2Int(const string & s, long long & n)
|
|||
}
|
||||
|
||||
|
||||
bool hasSuffix(const string & s, const string & suffix)
|
||||
{
|
||||
return s.size() >= suffix.size() && string(s, s.size() - suffix.size()) == suffix;
|
||||
}
|
||||
|
||||
|
||||
void ignoreException()
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -294,6 +294,10 @@ bool string2Int(const string & s, int & n);
|
|||
bool string2Int(const string & s, long long & n);
|
||||
|
||||
|
||||
/* Return true iff `s' ends in `suffix'. */
|
||||
bool hasSuffix(const string & s, const string & suffix);
|
||||
|
||||
|
||||
/* Exception handling in destructors: print an error message, then
|
||||
ignore the exception. */
|
||||
void ignoreException();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue