about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/names.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
commit867055133d3f487e52dd44149f76347c2c28bf10 (patch)
treec367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/libexpr/names.cc
parentc6a31838cd7e88ebcb01422b329a499d04ab4b6b (diff)
style(3p/nix): Add braces around single-line conditionals r/771
These were not caught by the previous clang-tidy invocation, but were
instead sorted out using amber[0] as such:

    ambr --regex 'if (\(.+\))\s([a-z].*;)' 'if $1 { $2 }'

[0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libexpr/names.cc')
-rw-r--r--third_party/nix/src/libexpr/names.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/third_party/nix/src/libexpr/names.cc b/third_party/nix/src/libexpr/names.cc
index f7752f2bf8..92bd06308c 100644
--- a/third_party/nix/src/libexpr/names.cc
+++ b/third_party/nix/src/libexpr/names.cc
@@ -28,9 +28,13 @@ bool DrvName::matches(DrvName& n) {
     if (!regex)
       regex = std::unique_ptr<std::regex>(
           new std::regex(name, std::regex::extended));
-    if (!std::regex_match(n.name, *regex)) return false;
+    if (!std::regex_match(n.name, *regex)) {
+      return false;
+    }
+  }
+  if (version != "" && version != n.version) {
+    return false;
   }
-  if (version != "" && version != n.version) return false;
   return true;
 }
 
@@ -39,7 +43,9 @@ string nextComponent(string::const_iterator& p,
   /* Skip any dots and dashes (component separators). */
   while (p != end && (*p == '.' || *p == '-')) ++p;
 
-  if (p == end) return "";
+  if (p == end) {
+    return "";
+  }
 
   /* If the first character is a digit, consume the longest sequence
      of digits.  Otherwise, consume the longest sequence of