mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-29 04:26:32 +03:00
Reformat for 4-space indentation
Specifically, with clang-format --style='{ IndentWidth: 4, BreakBeforeBraces: Mozilla, ColumnLimit: 120, PointerAlignment: Middle }' which was the clang-format invocation that produced the fewest diffs on the nix source out of ~20 that I tried.
This commit is contained in:
parent
74f05df671
commit
4af8dbf896
3 changed files with 534 additions and 529 deletions
|
@ -21,61 +21,63 @@ using nix::Strings;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
// From nix/src/libexpr/attr-path.cc
|
// From nix/src/libexpr/attr-path.cc
|
||||||
Strings parseAttrPath(const string &s) {
|
Strings parseAttrPath(const string & s)
|
||||||
Strings res;
|
{
|
||||||
string cur;
|
Strings res;
|
||||||
string::const_iterator i = s.begin();
|
string cur;
|
||||||
while (i != s.end()) {
|
string::const_iterator i = s.begin();
|
||||||
if (*i == '.') {
|
while (i != s.end()) {
|
||||||
res.push_back(cur);
|
if (*i == '.') {
|
||||||
cur.clear();
|
res.push_back(cur);
|
||||||
} else if (*i == '"') {
|
cur.clear();
|
||||||
++i;
|
} else if (*i == '"') {
|
||||||
while (1) {
|
++i;
|
||||||
if (i == s.end())
|
while (1) {
|
||||||
throw Error(format("missing closing quote in selection path '%1%'") %
|
if (i == s.end())
|
||||||
s);
|
throw Error(format("missing closing quote in selection path '%1%'") % s);
|
||||||
if (*i == '"')
|
if (*i == '"')
|
||||||
break;
|
break;
|
||||||
cur.push_back(*i++);
|
cur.push_back(*i++);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
cur.push_back(*i);
|
cur.push_back(*i);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
if (!cur.empty())
|
if (!cur.empty())
|
||||||
res.push_back(cur);
|
res.push_back(cur);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// From nix/src/nix/repl.cc
|
// From nix/src/nix/repl.cc
|
||||||
bool isVarName(const string &s) {
|
bool isVarName(const string & s)
|
||||||
if (s.size() == 0)
|
{
|
||||||
return false;
|
if (s.size() == 0)
|
||||||
char c = s[0];
|
return false;
|
||||||
if ((c >= '0' && c <= '9') || c == '-' || c == '\'')
|
char c = s[0];
|
||||||
return false;
|
if ((c >= '0' && c <= '9') || c == '-' || c == '\'')
|
||||||
for (auto &i : s)
|
return false;
|
||||||
if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') ||
|
for (auto & i : s)
|
||||||
(i >= '0' && i <= '9') || i == '_' || i == '-' || i == '\''))
|
if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (i >= '0' && i <= '9') || i == '_' || i == '-' ||
|
||||||
return false;
|
i == '\''))
|
||||||
return true;
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// From nix/src/nix/repl.cc
|
// From nix/src/nix/repl.cc
|
||||||
std::ostream &printStringValue(std::ostream &str, const char *string) {
|
std::ostream & printStringValue(std::ostream & str, const char * string)
|
||||||
str << "\"";
|
{
|
||||||
for (const char *i = string; *i; i++)
|
str << "\"";
|
||||||
if (*i == '\"' || *i == '\\')
|
for (const char * i = string; *i; i++)
|
||||||
str << "\\" << *i;
|
if (*i == '\"' || *i == '\\')
|
||||||
else if (*i == '\n')
|
str << "\\" << *i;
|
||||||
str << "\\n";
|
else if (*i == '\n')
|
||||||
else if (*i == '\r')
|
str << "\\n";
|
||||||
str << "\\r";
|
else if (*i == '\r')
|
||||||
else if (*i == '\t')
|
str << "\\r";
|
||||||
str << "\\t";
|
else if (*i == '\t')
|
||||||
else
|
str << "\\t";
|
||||||
str << *i;
|
else
|
||||||
str << "\"";
|
str << *i;
|
||||||
return str;
|
str << "\"";
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
#include <nix/types.hh>
|
#include <nix/types.hh>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
nix::Strings parseAttrPath(const std::string &s);
|
nix::Strings parseAttrPath(const std::string & s);
|
||||||
bool isVarName(const std::string &s);
|
bool isVarName(const std::string & s);
|
||||||
std::ostream &printStringValue(std::ostream &str, const char *string);
|
std::ostream & printStringValue(std::ostream & str, const char * string);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue