fix(3p/nix): Fix incorrectly braced conditionals and loops
Fixes mistakes introduced by clang-tidy in the previous commit.
This commit is contained in:
		
							parent
							
								
									b490742a51
								
							
						
					
					
						commit
						09cbc431cc
					
				
					 16 changed files with 62 additions and 61 deletions
				
			
		
							
								
								
									
										18
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -820,15 +820,12 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
 | 
			
		|||
      newBnds->sort();
 | 
			
		||||
      v.attrs = newBnds;
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    for (auto& i : attrs)
 | 
			
		||||
      v.attrs->push_back(
 | 
			
		||||
          Attr(i.first, i.second.e->maybeThunk(state, env), &i.second.pos));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  else {
 | 
			
		||||
    for
 | 
			
		||||
  }
 | 
			
		||||
  (auto& i
 | 
			
		||||
   : attrs) v.attrs->push_back(Attr(i.first, i.second.e->maybeThunk(state, env),
 | 
			
		||||
                                    &i.second.pos));
 | 
			
		||||
 | 
			
		||||
  /* Dynamic attrs apply *after* rec and __overrides. */
 | 
			
		||||
  for (auto& i : dynamicAttrs) {
 | 
			
		||||
    Value nameVal;
 | 
			
		||||
| 
						 | 
				
			
			@ -1350,9 +1347,8 @@ void ExprConcatStrings::eval(EvalState& state, Env& env, Value& v) {
 | 
			
		|||
    auto path = canonPath(s.str());
 | 
			
		||||
    mkPath(v, path.c_str());
 | 
			
		||||
  } else {
 | 
			
		||||
    mkString
 | 
			
		||||
    mkString(v, s.str(), context);
 | 
			
		||||
  }
 | 
			
		||||
  (v, s.str(), context);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ExprPos::eval(EvalState& state, Env& env, Value& v) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1378,9 +1374,7 @@ void EvalState::forceValueDeep(Value& v) {
 | 
			
		|||
                         i.name, *i.pos);
 | 
			
		||||
          throw;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    else if (v.isList()) {
 | 
			
		||||
    } else if (v.isList()) {
 | 
			
		||||
      for (size_t n = 0; n < v.listSize(); ++n) recurse(*v.listElems()[n]);
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										7
									
								
								third_party/nix/src/libexpr/get-drvs.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								third_party/nix/src/libexpr/get-drvs.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -387,11 +387,10 @@ static void getDerivations(EvalState& state, Value& vIn,
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  else {
 | 
			
		||||
    throw
 | 
			
		||||
    throw TypeError(
 | 
			
		||||
        "expression does not evaluate to a derivation (or a set or list of "
 | 
			
		||||
        "those)");
 | 
			
		||||
  }
 | 
			
		||||
  TypeError(
 | 
			
		||||
      "expression does not evaluate to a derivation (or a set or list of "
 | 
			
		||||
      "those)");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void getDerivations(EvalState& state, Value& v, const string& pathPrefix,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										3
									
								
								third_party/nix/src/libexpr/json-to-value.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third_party/nix/src/libexpr/json-to-value.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -42,9 +42,8 @@ static string parseJSONString(const char*& s) {
 | 
			
		|||
        throw JSONParseError("invalid escaped character in JSON string");
 | 
			
		||||
      s++;
 | 
			
		||||
    } else {
 | 
			
		||||
      res
 | 
			
		||||
      res += *s++;
 | 
			
		||||
    }
 | 
			
		||||
    += *s++;
 | 
			
		||||
  }
 | 
			
		||||
  s++;
 | 
			
		||||
  return res;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										3
									
								
								third_party/nix/src/libexpr/names.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third_party/nix/src/libexpr/names.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -71,9 +71,8 @@ static bool componentsLT(const string& c1, const string& c2) {
 | 
			
		|||
  } else if (c1Num) {
 | 
			
		||||
    return false;
 | 
			
		||||
  } else {
 | 
			
		||||
    return
 | 
			
		||||
    return c1 < c2;
 | 
			
		||||
  }
 | 
			
		||||
  c1 < c2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int compareVersions(const string& v1, const string& v2) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								third_party/nix/src/libexpr/nixexpr.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								third_party/nix/src/libexpr/nixexpr.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -256,16 +256,20 @@ void ExprAttrs::bindVars(const StaticEnv& env) {
 | 
			
		|||
    dynamicEnv = &newEnv;
 | 
			
		||||
 | 
			
		||||
    unsigned int displ = 0;
 | 
			
		||||
    for (auto& i : attrs) newEnv.vars[i.first] = i.second.displ = displ++;
 | 
			
		||||
    for (auto& i : attrs) {
 | 
			
		||||
      newEnv.vars[i.first] = i.second.displ = displ++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (auto& i : attrs)
 | 
			
		||||
    for (auto& i : attrs) {
 | 
			
		||||
      i.second.e->bindVars(i.second.inherited ? env : newEnv);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  else {
 | 
			
		||||
    for
 | 
			
		||||
    for (auto& i : attrs) {
 | 
			
		||||
      i.second.e->bindVars(env);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  (auto& i : attrs) i.second.e->bindVars(env);
 | 
			
		||||
 | 
			
		||||
  for (auto& i : dynamicAttrs) {
 | 
			
		||||
    i.nameExpr->bindVars(*dynamicEnv);
 | 
			
		||||
| 
						 | 
				
			
			@ -282,10 +286,14 @@ void ExprLambda::bindVars(const StaticEnv& env) {
 | 
			
		|||
 | 
			
		||||
  unsigned int displ = 0;
 | 
			
		||||
 | 
			
		||||
  if (!arg.empty()) newEnv.vars[arg] = displ++;
 | 
			
		||||
  if (!arg.empty()) {
 | 
			
		||||
    newEnv.vars[arg] = displ++;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (matchAttrs) {
 | 
			
		||||
    for (auto& i : formals->formals) newEnv.vars[i.name] = displ++;
 | 
			
		||||
    for (auto& i : formals->formals) {
 | 
			
		||||
      newEnv.vars[i.name] = displ++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (auto& i : formals->formals)
 | 
			
		||||
      if (i.def) i.def->bindVars(newEnv);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										7
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1966,9 +1966,9 @@ static void prim_concatStringSep(EvalState& state, const Pos& pos, Value** args,
 | 
			
		|||
    if (first) {
 | 
			
		||||
      first = false;
 | 
			
		||||
    } else {
 | 
			
		||||
      res
 | 
			
		||||
      res += sep;
 | 
			
		||||
    }
 | 
			
		||||
    += sep;
 | 
			
		||||
 | 
			
		||||
    res += state.coerceToString(pos, *args[1]->listElems()[n], context);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2103,9 +2103,8 @@ void fetch(EvalState& state, const Pos& pos, Value** args, Value& v,
 | 
			
		|||
      throw EvalError(format("'url' argument required, at %1%") % pos);
 | 
			
		||||
 | 
			
		||||
  } else {
 | 
			
		||||
    request
 | 
			
		||||
    request.uri = state.forceStringNoCtx(*args[0], pos);
 | 
			
		||||
  }
 | 
			
		||||
  .uri = state.forceStringNoCtx(*args[0], pos);
 | 
			
		||||
 | 
			
		||||
  state.checkURI(request.uri);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -228,9 +228,8 @@ static void prim_fetchGit(EvalState& state, const Pos& pos, Value** args,
 | 
			
		|||
      throw EvalError(format("'url' argument required, at %1%") % pos);
 | 
			
		||||
 | 
			
		||||
  } else {
 | 
			
		||||
    url
 | 
			
		||||
    url = state.coerceToString(pos, *args[0], context, false, false);
 | 
			
		||||
  }
 | 
			
		||||
  = state.coerceToString(pos, *args[0], context, false, false);
 | 
			
		||||
 | 
			
		||||
  // FIXME: git externals probably can be used to bypass the URI
 | 
			
		||||
  // whitelist. Ah well.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -204,9 +204,8 @@ static void prim_fetchMercurial(EvalState& state, const Pos& pos, Value** args,
 | 
			
		|||
      throw EvalError(format("'url' argument required, at %1%") % pos);
 | 
			
		||||
 | 
			
		||||
  } else {
 | 
			
		||||
    url
 | 
			
		||||
    url = state.coerceToString(pos, *args[0], context, false, false);
 | 
			
		||||
  }
 | 
			
		||||
  = state.coerceToString(pos, *args[0], context, false, false);
 | 
			
		||||
 | 
			
		||||
  // FIXME: git externals probably can be used to bypass the URI
 | 
			
		||||
  // whitelist. Ah well.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								third_party/nix/src/libexpr/value-to-xml.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								third_party/nix/src/libexpr/value-to-xml.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -137,15 +137,20 @@ static void printValueAsXML(EvalState& state, bool strict, bool location,
 | 
			
		|||
 | 
			
		||||
      if (v.lambda.fun->matchAttrs) {
 | 
			
		||||
        XMLAttrs attrs;
 | 
			
		||||
        if (!v.lambda.fun->arg.empty()) attrs["name"] = v.lambda.fun->arg;
 | 
			
		||||
        if (v.lambda.fun->formals->ellipsis) attrs["ellipsis"] = "1";
 | 
			
		||||
        if (!v.lambda.fun->arg.empty()) {
 | 
			
		||||
          attrs["name"] = v.lambda.fun->arg;
 | 
			
		||||
        }
 | 
			
		||||
        if (v.lambda.fun->formals->ellipsis) {
 | 
			
		||||
          attrs["ellipsis"] = "1";
 | 
			
		||||
        }
 | 
			
		||||
        XMLOpenElement _(doc, "attrspat", attrs);
 | 
			
		||||
        for (auto& i : v.lambda.fun->formals->formals)
 | 
			
		||||
        for (auto& i : v.lambda.fun->formals->formals) {
 | 
			
		||||
          doc.writeEmptyElement("attr", singletonAttrs("name", i.name));
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        doc
 | 
			
		||||
        doc.writeEmptyElement("varpat",
 | 
			
		||||
                              singletonAttrs("name", v.lambda.fun->arg));
 | 
			
		||||
      }
 | 
			
		||||
      .writeEmptyElement("varpat", singletonAttrs("name", v.lambda.fun->arg));
 | 
			
		||||
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue