mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
libexpr: Add and use pathStr
getter
This commit is contained in:
parent
c041d71406
commit
e4df189123
4 changed files with 9 additions and 6 deletions
|
@ -252,7 +252,7 @@ const char * nix_get_path_string(nix_c_context * context, const nix_value * valu
|
||||||
// We could use v.path().to_string().c_str(), but I'm concerned this
|
// We could use v.path().to_string().c_str(), but I'm concerned this
|
||||||
// crashes. Looks like .path() allocates a CanonPath with a copy of the
|
// crashes. Looks like .path() allocates a CanonPath with a copy of the
|
||||||
// string, then it gets the underlying data from that.
|
// string, then it gets the underlying data from that.
|
||||||
return v.payload.path.path;
|
return v.pathStr();
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
|
|
|
@ -2368,7 +2368,7 @@ BackedStringView EvalState::coerceToString(
|
||||||
!canonicalizePath && !copyToStore
|
!canonicalizePath && !copyToStore
|
||||||
? // FIXME: hack to preserve path literals that end in a
|
? // FIXME: hack to preserve path literals that end in a
|
||||||
// slash, as in /foo/${x}.
|
// slash, as in /foo/${x}.
|
||||||
v.payload.path.path
|
v.pathStr()
|
||||||
: copyToStore
|
: copyToStore
|
||||||
? store->printStorePath(copyPathToStore(context, v.path()))
|
? store->printStorePath(copyPathToStore(context, v.path()))
|
||||||
: std::string(v.path().path.abs());
|
: std::string(v.path().path.abs());
|
||||||
|
@ -2643,7 +2643,7 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
|
||||||
ValuePrinter(*this, v2, errorPrintOptions))
|
ValuePrinter(*this, v2, errorPrintOptions))
|
||||||
.debugThrow();
|
.debugThrow();
|
||||||
}
|
}
|
||||||
if (strcmp(v1.payload.path.path, v2.payload.path.path) != 0) {
|
if (strcmp(v1.pathStr(), v2.pathStr()) != 0) {
|
||||||
error<AssertionError>(
|
error<AssertionError>(
|
||||||
"path '%s' is not equal to path '%s'",
|
"path '%s' is not equal to path '%s'",
|
||||||
ValuePrinter(*this, v1, errorPrintOptions),
|
ValuePrinter(*this, v1, errorPrintOptions),
|
||||||
|
@ -2811,7 +2811,7 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
|
||||||
return
|
return
|
||||||
// FIXME: compare accessors by their fingerprint.
|
// FIXME: compare accessors by their fingerprint.
|
||||||
v1.payload.path.accessor == v2.payload.path.accessor
|
v1.payload.path.accessor == v2.payload.path.accessor
|
||||||
&& strcmp(v1.payload.path.path, v2.payload.path.path) == 0;
|
&& strcmp(v1.pathStr(), v2.pathStr()) == 0;
|
||||||
|
|
||||||
case nNull:
|
case nNull:
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -445,7 +445,7 @@ public:
|
||||||
assert(internalType == tPath);
|
assert(internalType == tPath);
|
||||||
return SourcePath(
|
return SourcePath(
|
||||||
ref(payload.path.accessor->shared_from_this()),
|
ref(payload.path.accessor->shared_from_this()),
|
||||||
CanonPath(CanonPath::unchecked_t(), payload.path.path));
|
CanonPath(CanonPath::unchecked_t(), pathStr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view string_view() const
|
std::string_view string_view() const
|
||||||
|
@ -494,6 +494,9 @@ public:
|
||||||
|
|
||||||
FunctionApplicationThunk app() const
|
FunctionApplicationThunk app() const
|
||||||
{ return payload.app; }
|
{ return payload.app; }
|
||||||
|
|
||||||
|
const char * pathStr() const
|
||||||
|
{ return payload.path.path; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -651,7 +651,7 @@ struct CompareValues
|
||||||
// Note: we don't take the accessor into account
|
// Note: we don't take the accessor into account
|
||||||
// since it's not obvious how to compare them in a
|
// since it's not obvious how to compare them in a
|
||||||
// reproducible way.
|
// reproducible way.
|
||||||
return strcmp(v1->payload.path.path, v2->payload.path.path) < 0;
|
return strcmp(v1->pathStr(), v2->pathStr()) < 0;
|
||||||
case nList:
|
case nList:
|
||||||
// Lexicographic comparison
|
// Lexicographic comparison
|
||||||
for (size_t i = 0;; i++) {
|
for (size_t i = 0;; i++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue