about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/attr-path.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/libexpr/attr-path.cc')
-rw-r--r--third_party/nix/src/libexpr/attr-path.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/third_party/nix/src/libexpr/attr-path.cc b/third_party/nix/src/libexpr/attr-path.cc
index edab0b6df97f..3d4e9c1e1096 100644
--- a/third_party/nix/src/libexpr/attr-path.cc
+++ b/third_party/nix/src/libexpr/attr-path.cc
@@ -16,16 +16,18 @@ static Strings parseAttrPath(const string& s) {
     } else if (*i == '"') {
       ++i;
       while (1) {
-        if (i == s.end())
+        if (i == s.end()) {
           throw Error(format("missing closing quote in selection path '%1%'") %
                       s);
+        }
         if (*i == '"') {
           break;
         }
         cur.push_back(*i++);
       }
-    } else
+    } else {
       cur.push_back(*i);
+    }
     ++i;
   }
   if (!cur.empty()) {
@@ -62,33 +64,38 @@ Value* findAlongAttrPath(EvalState& state, const string& attrPath,
        according to what is specified in the attrPath. */
 
     if (apType == apAttr) {
-      if (v->type != tAttrs)
+      if (v->type != tAttrs) {
         throw TypeError(format("the expression selected by the selection path "
                                "'%1%' should be a set but is %2%") %
                         attrPath % showType(*v));
+      }
 
-      if (attr.empty())
+      if (attr.empty()) {
         throw Error(format("empty attribute name in selection path '%1%'") %
                     attrPath);
+      }
 
       Bindings::iterator a = v->attrs->find(state.symbols.create(attr));
-      if (a == v->attrs->end())
+      if (a == v->attrs->end()) {
         throw Error(
             format("attribute '%1%' in selection path '%2%' not found") % attr %
             attrPath);
+      }
       v = &*a->value;
     }
 
     else if (apType == apIndex) {
-      if (!v->isList())
+      if (!v->isList()) {
         throw TypeError(format("the expression selected by the selection path "
                                "'%1%' should be a list but is %2%") %
                         attrPath % showType(*v));
+      }
 
-      if (attrIndex >= v->listSize())
+      if (attrIndex >= v->listSize()) {
         throw Error(
             format("list index %1% in selection path '%2%' is out of range") %
             attrIndex % attrPath);
+      }
 
       v = v->listElems()[attrIndex];
     }