From f16fe2af8d59fef156c29077a240a832d3e60ef2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 10 Jun 2010 10:29:50 +0000 Subject: [PATCH] * builtins.toXML: propagate the string context. This is a regression from the old ATerm-based evaluator. --- src/libexpr/eval.cc | 14 +++++++++----- src/libexpr/eval.hh | 2 ++ src/libexpr/value-to-xml.cc | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index f95df5e4d..eb1d8d432 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -902,12 +902,18 @@ string EvalState::forceString(Value & v) } -string EvalState::forceString(Value & v, PathSet & context) +void copyContext(const Value & v, PathSet & context) { - string s = forceString(v); if (v.string.context) for (const char * * p = v.string.context; *p; ++p) context.insert(*p); +} + + +string EvalState::forceString(Value & v, PathSet & context) +{ + string s = forceString(v); + copyContext(v, context); return s; } @@ -938,9 +944,7 @@ string EvalState::coerceToString(Value & v, PathSet & context, string s; if (v.type == tString) { - if (v.string.context) - for (const char * * p = v.string.context; *p; ++p) - context.insert(*p); + copyContext(v, context); return v.string.s; } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 65c689a50..0cdf0b283 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -161,6 +161,8 @@ void mkString(Value & v, const char * s); void mkString(Value & v, const string & s, const PathSet & context = PathSet()); void mkPath(Value & v, const char * s); +void copyContext(const Value & v, PathSet & context); + typedef std::map DrvHashes; diff --git a/src/libexpr/value-to-xml.cc b/src/libexpr/value-to-xml.cc index e751fd300..8955a8a33 100644 --- a/src/libexpr/value-to-xml.cc +++ b/src/libexpr/value-to-xml.cc @@ -69,6 +69,7 @@ static void printValueAsXML(EvalState & state, bool strict, bool location, case tString: /* !!! show the context? */ + copyContext(v, context); doc.writeEmptyElement("string", singletonAttrs("value", v.string.s)); break;