diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-06-02 19:53:11 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-06-02 19:53:11 +0000 |
commit | b585548dfee1bf12c63894c751f1449636e32565 (patch) | |
tree | bcbd184e617b100148159cd85b9d3db88a7b6e25 /src/libutil | |
parent | 49ad315c0357116787ef45a1249009b6bc00301f (diff) | |
parent | 1892355766af57868f74a9efd75aa279b29a04f6 (diff) |
Merge remote-tracking branch 'upstream/master' into indexed-store-path-outputs
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/error.hh | 9 | ||||
-rw-r--r-- | src/libutil/json.cc | 1 | ||||
-rw-r--r-- | src/libutil/ref.hh | 2 | ||||
-rw-r--r-- | src/libutil/url.cc | 18 | ||||
-rw-r--r-- | src/libutil/url.hh | 15 | ||||
-rw-r--r-- | src/libutil/util.cc | 2 |
6 files changed, 45 insertions, 2 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh index f4706e3ed..a53e9802e 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -98,6 +98,15 @@ struct ErrPos { } }; +std::optional<LinesOfCode> getCodeLines(const ErrPos & errPos); + +void printCodeLines(std::ostream & out, + const std::string & prefix, + const ErrPos & errPos, + const LinesOfCode & loc); + +void printAtPos(const ErrPos & pos, std::ostream & out); + struct Trace { std::optional<ErrPos> pos; hintformat hint; diff --git a/src/libutil/json.cc b/src/libutil/json.cc index 3a981376f..b0a5d7e75 100644 --- a/src/libutil/json.cc +++ b/src/libutil/json.cc @@ -1,6 +1,7 @@ #include "json.hh" #include <iomanip> +#include <cstdint> #include <cstring> namespace nix { diff --git a/src/libutil/ref.hh b/src/libutil/ref.hh index f9578afc7..bf26321db 100644 --- a/src/libutil/ref.hh +++ b/src/libutil/ref.hh @@ -7,7 +7,7 @@ namespace nix { /* A simple non-nullable reference-counted pointer. Actually a wrapper - around std::shared_ptr that prevents non-null constructions. */ + around std::shared_ptr that prevents null constructions. */ template<typename T> class ref { diff --git a/src/libutil/url.cc b/src/libutil/url.cc index f6232d255..5b7abeb49 100644 --- a/src/libutil/url.cc +++ b/src/libutil/url.cc @@ -1,6 +1,7 @@ #include "url.hh" #include "url-parts.hh" #include "util.hh" +#include "split.hh" namespace nix { @@ -136,4 +137,21 @@ bool ParsedURL::operator ==(const ParsedURL & other) const && fragment == other.fragment; } +/** + * Parse a URL scheme of the form '(applicationScheme\+)?transportScheme' + * into a tuple '(applicationScheme, transportScheme)' + * + * > parseUrlScheme("http") == ParsedUrlScheme{ {}, "http"} + * > parseUrlScheme("tarball+http") == ParsedUrlScheme{ {"tarball"}, "http"} + */ +ParsedUrlScheme parseUrlScheme(std::string_view scheme) +{ + auto application = splitPrefixTo(scheme, '+'); + auto transport = scheme; + return ParsedUrlScheme { + .application = application, + .transport = transport, + }; +} + } diff --git a/src/libutil/url.hh b/src/libutil/url.hh index 6e77142e3..2a9fb34c1 100644 --- a/src/libutil/url.hh +++ b/src/libutil/url.hh @@ -27,4 +27,19 @@ std::map<std::string, std::string> decodeQuery(const std::string & query); ParsedURL parseURL(const std::string & url); +/* + * Although that’s not really standardized anywhere, an number of tools + * use a scheme of the form 'x+y' in urls, where y is the “transport layer” + * scheme, and x is the “application layer” scheme. + * + * For example git uses `git+https` to designate remotes using a Git + * protocol over http. + */ +struct ParsedUrlScheme { + std::optional<std::string_view> application; + std::string_view transport; +}; + +ParsedUrlScheme parseUrlScheme(std::string_view scheme); + } diff --git a/src/libutil/util.cc b/src/libutil/util.cc index d4d78329d..1c19938a8 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1818,7 +1818,7 @@ AutoCloseFD createUnixDomainSocket(const Path & path, mode_t mode) if (chmod(path.c_str(), mode) == -1) throw SysError("changing permissions on '%1%'", path); - if (listen(fdSocket.get(), 5) == -1) + if (listen(fdSocket.get(), 100) == -1) throw SysError("cannot listen on socket '%1%'", path); return fdSocket; |