1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 07:33:16 +02:00

Merge remote-tracking branch 'origin/master' into flakes

This commit is contained in:
Eelco Dolstra 2019-11-06 10:44:21 +01:00
commit 88c452d160
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
17 changed files with 155 additions and 83 deletions

View file

@ -178,6 +178,19 @@ Strings argvToStrings(int argc, char * * argv)
return args;
}
Strings editorFor(Pos pos)
{
auto editor = getEnv("EDITOR", "cat");
auto args = tokenizeString<Strings>(editor);
if (pos.line > 0 && (
editor.find("emacs") != std::string::npos ||
editor.find("nano") != std::string::npos ||
editor.find("vim") != std::string::npos))
args.push_back(fmt("+%d", pos.line));
args.push_back(pos.file);
return args;
}
std::string renderLabels(const Strings & labels)
{
std::string res;

View file

@ -5,6 +5,7 @@
#include <memory>
#include "util.hh"
#include "nixexpr.hh"
namespace nix {
@ -241,6 +242,9 @@ public:
Strings argvToStrings(int argc, char * * argv);
/* Helper function to generate args that invoke $EDITOR on filename:lineno */
Strings editorFor(Pos pos);
/* Helper function for rendering argument labels. */
std::string renderLabels(const Strings & labels);

View file

@ -1572,7 +1572,11 @@ std::unique_ptr<InterruptCallback> createInterruptCallback(std::function<void()>
AutoCloseFD createUnixDomainSocket(const Path & path, mode_t mode)
{
AutoCloseFD fdSocket = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
AutoCloseFD fdSocket = socket(PF_UNIX, SOCK_STREAM
#ifdef SOCK_CLOEXEC
| SOCK_CLOEXEC
#endif
, 0);
if (!fdSocket)
throw SysError("cannot create Unix domain socket");