From af8e8d27d4a92a961ac696e6170856a66fd6e253 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 28 Jul 2013 16:40:02 +0200 Subject: [PATCH] Minor code cleanups --- src/command_manager.cc | 8 +++++--- src/command_manager.hh | 8 +------- src/main.cc | 2 +- src/remote.cc | 4 ++-- src/shell_manager.cc | 4 ++-- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 2255b7c4..c8e5d05a 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -31,9 +31,11 @@ void CommandManager::register_commands(memoryview command_names, m_commands[command_name] = { command, completer }; } -parse_error::parse_error(const String& error) - : runtime_error{"parse error: " + error} {} - +struct parse_error : runtime_error +{ + parse_error(const String& error) + : runtime_error{"parse error: " + error} {} +}; namespace { diff --git a/src/command_manager.hh b/src/command_manager.hh index c63633ef..9aee1e0c 100644 --- a/src/command_manager.hh +++ b/src/command_manager.hh @@ -14,15 +14,9 @@ namespace Kakoune { -struct parse_error : runtime_error -{ - parse_error(const String& error); -}; - struct Context; using CommandParameters = memoryview; -using Command = std::function; +using Command = std::function; using CommandCompleter = std::function; diff --git a/src/main.cc b/src/main.cc index ad41d843..536ca157 100644 --- a/src/main.cc +++ b/src/main.cc @@ -43,7 +43,7 @@ String runtime_directory() #elif defined(__APPLE__) uint32_t bufsize = 2048; _NSGetExecutablePath(buffer, &bufsize); - char* canonical_path = realpath(buffer, NULL); + char* canonical_path = realpath(buffer, nullptr); strncpy(buffer, canonical_path, 2048); free(canonical_path); #else diff --git a/src/remote.cc b/src/remote.cc index 5776d624..6bb26750 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -327,7 +327,7 @@ bool RemoteUI::is_key_available() tv.tv_sec = 0; tv.tv_usec = 0; - int res = select(sock+1, &rfds, NULL, NULL, &tv); + int res = select(sock+1, &rfds, nullptr, nullptr, &tv); return res == 1; } @@ -500,7 +500,7 @@ private: FD_ZERO(&rfds); FD_SET(socket, &rfds); } - while (select(socket+1, &rfds, NULL, NULL, &tv) == 1); + while (select(socket+1, &rfds, nullptr, nullptr, &tv) == 1); } String m_buffer; diff --git a/src/shell_manager.cc b/src/shell_manager.cc index d293a137..7663e2f8 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -67,7 +67,7 @@ String ShellManager::pipe(const String& input, if (not errorout.empty()) write_debug("shell stderr: <<<\n" + errorout + ">>>"); - waitpid(pid, NULL, 0); + waitpid(pid, nullptr, 0); } else try { @@ -125,7 +125,7 @@ String ShellManager::pipe(const String& input, execparams.push_back(shell.c_str()); for (auto& param : params) execparams.push_back(param.c_str()); - execparams.push_back(NULL); + execparams.push_back(nullptr); execvp(shell.c_str(), (char* const*)execparams.data()); exit(-1);