summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-01-08 22:30:15 +0000
committerMaxime Coste <mawww@kakoune.org>2017-01-08 22:39:01 +0000
commitdcd8f6ef0105578e10dc18975871bc59154e008c (patch)
tree2e0e2e11d4afcf9c351c3a7dd8c9847b253d3017
parent9dfd17a5bc584a66711707044bdf27ff57e7aebb (diff)
Apply clang-tidy modernize to the codebase
-rw-r--r--src/alias_registry.cc2
-rw-r--r--src/assert.cc2
-rw-r--r--src/backtrace.cc2
-rw-r--r--src/buffer.hh4
-rw-r--r--src/client.cc6
-rw-r--r--src/client.hh2
-rw-r--r--src/command_manager.cc2
-rw-r--r--src/commands.cc9
-rw-r--r--src/display_buffer.cc2
-rw-r--r--src/event_manager.hh2
-rw-r--r--src/exception.hh2
-rw-r--r--src/file.cc6
-rw-r--r--src/highlighter.hh4
-rw-r--r--src/highlighters.cc2
-rw-r--r--src/input_handler.cc25
-rw-r--r--src/insert_completer.cc11
-rw-r--r--src/insert_completer.hh2
-rw-r--r--src/keys.cc8
-rw-r--r--src/main.cc4
-rw-r--r--src/ncurses_ui.cc2
-rw-r--r--src/ncurses_ui.hh2
-rw-r--r--src/normal.cc20
-rw-r--r--src/option_manager.hh4
-rw-r--r--src/optional.hh2
-rw-r--r--src/register_manager.hh2
-rw-r--r--src/remote.cc6
-rw-r--r--src/selection.cc8
-rw-r--r--src/selectors.cc2
-rw-r--r--src/shared_string.hh2
-rw-r--r--src/shell_manager.cc4
-rw-r--r--src/string.hh2
-rw-r--r--src/unicode.hh4
-rw-r--r--src/user_interface.hh2
-rw-r--r--src/value.hh2
-rw-r--r--src/window.hh2
-rw-r--r--src/word_db.hh2
36 files changed, 86 insertions, 79 deletions
diff --git a/src/alias_registry.cc b/src/alias_registry.cc
index 2822c6c0..3e73df9c 100644
--- a/src/alias_registry.cc
+++ b/src/alias_registry.cc
@@ -44,7 +44,7 @@ Vector<StringView> AliasRegistry::aliases_for(StringView command) const
for (auto& alias : m_aliases)
{
if (alias.value == command)
- res.push_back(alias.key);
+ res.emplace_back(alias.key);
}
return res;
diff --git a/src/assert.cc b/src/assert.cc
index 157ed949..1e5542ee 100644
--- a/src/assert.cc
+++ b/src/assert.cc
@@ -10,7 +10,7 @@
#include <sys/types.h>
#include <unistd.h>
-#include <stdlib.h>
+#include <cstdlib>
namespace Kakoune
{
diff --git a/src/backtrace.cc b/src/backtrace.cc
index 2fc99e8e..950770e9 100644
--- a/src/backtrace.cc
+++ b/src/backtrace.cc
@@ -11,7 +11,7 @@
#endif
#if defined(__linux__) || defined(__APPLE__)
-# include <stdlib.h>
+# include <cstdlib>
#endif
namespace Kakoune
diff --git a/src/buffer.hh b/src/buffer.hh
index 4db6f32a..c30f93f9 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -10,7 +10,7 @@
#include "value.hh"
#include "vector.hh"
-#include <time.h>
+#include <ctime>
namespace Kakoune
{
@@ -118,7 +118,7 @@ public:
timespec fs_timestamp = InvalidTime);
Buffer(const Buffer&) = delete;
Buffer& operator= (const Buffer&) = delete;
- ~Buffer();
+ ~Buffer() override;
Flags flags() const { return m_flags; }
Flags& flags() { return m_flags; }
diff --git a/src/client.cc b/src/client.cc
index 0230ff4f..f4e9e37b 100644
--- a/src/client.cc
+++ b/src/client.cc
@@ -12,9 +12,11 @@
#include "user_interface.hh"
#include "window.hh"
-#include <signal.h>
+#include <csignal>
#include <unistd.h>
+#include <utility>
+
namespace Kakoune
{
@@ -26,7 +28,7 @@ Client::Client(std::unique_ptr<UserInterface>&& ui,
: m_ui{std::move(ui)}, m_window{std::move(window)},
m_input_handler{std::move(selections), Context::Flags::None,
std::move(name)},
- m_env_vars(env_vars)
+ m_env_vars(std::move(env_vars))
{
m_window->set_client(this);
diff --git a/src/client.hh b/src/client.hh
index 087b6f98..97d134ed 100644
--- a/src/client.hh
+++ b/src/client.hh
@@ -30,7 +30,7 @@ public:
SelectionList selections,
EnvVarMap env_vars,
String name);
- ~Client();
+ ~Client() override;
Client(Client&&) = delete;
diff --git a/src/command_manager.cc b/src/command_manager.cc
index 8927c361..b3c5c862 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -635,7 +635,7 @@ Completions CommandManager::complete(const Context& context,
for (auto it = tokens.begin() + cmd_idx + 1; it != tokens.end(); ++it)
params.push_back(it->content());
if (tok_idx == tokens.size())
- params.push_back("");
+ params.emplace_back("");
Completions completions = offset_pos(command_it->second.completer(
context, flags, params, tok_idx - cmd_idx - 1,
cursor_pos_in_token), start);
diff --git a/src/commands.cc b/src/commands.cc
index 62b35c9d..c7d09ffd 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -28,6 +28,7 @@
#include "window.hh"
#include <functional>
+#include <utility>
#include <sys/types.h>
#include <sys/stat.h>
@@ -121,8 +122,8 @@ static Completions complete_buffer_name(const Context& context, CompletionFlags
{
struct RankedMatchAndBuffer : RankedMatch
{
- RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b)
- : RankedMatch{m}, buffer{b} {}
+ RankedMatchAndBuffer(RankedMatch m, const Buffer* b)
+ : RankedMatch{std::move(m)}, buffer{b} {}
using RankedMatch::operator==;
using RankedMatch::operator<;
@@ -976,7 +977,7 @@ void define_command(const ParametersParser& parser, Context& context, const Shel
shell_context).first;
candidates.clear();
for (auto c : output | split<StringView>('\n'))
- candidates.push_back({c.str(), used_letters(c)});
+ candidates.emplace_back(c.str(), used_letters(c));
token = token_to_complete;
}
@@ -1330,7 +1331,7 @@ const CommandDesc declare_option_cmd = {
if (parser[0] == "int")
opt = &reg.declare_option<int>(parser[1], docstring, 0, flags);
else if (parser[0] == "bool")
- opt = &reg.declare_option<bool>(parser[1], docstring, 0, flags);
+ opt = &reg.declare_option<bool>(parser[1], docstring, false, flags);
else if (parser[0] == "str")
opt = &reg.declare_option<String>(parser[1], docstring, "", flags);
else if (parser[0] == "regex")
diff --git a/src/display_buffer.cc b/src/display_buffer.cc
index cd7468d9..e6c74c8b 100644
--- a/src/display_buffer.cc
+++ b/src/display_buffer.cc
@@ -164,7 +164,7 @@ void DisplayLine::push_back(DisplayAtom atom)
DisplayLine::iterator DisplayLine::erase(iterator beg, iterator end)
{
- iterator res = m_atoms.erase(beg, end);
+ auto res = m_atoms.erase(beg, end);
compute_range();
return res;
}
diff --git a/src/event_manager.hh b/src/event_manager.hh
index 3d222f48..f4fa503e 100644
--- a/src/event_manager.hh
+++ b/src/event_manager.hh
@@ -9,7 +9,7 @@
#include <functional>
#include <sys/select.h>
-#include <signal.h>
+#include <csignal>
namespace Kakoune
{
diff --git a/src/exception.hh b/src/exception.hh
index 43ff4e68..4967e15b 100644
--- a/src/exception.hh
+++ b/src/exception.hh
@@ -8,7 +8,7 @@ namespace Kakoune
struct exception
{
- virtual ~exception() {}
+ virtual ~exception() = default;
virtual StringView what() const;
};
diff --git a/src/file.cc b/src/file.cc
index 68ac6d12..6c55050c 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -8,12 +8,12 @@
#include "string.hh"
#include "unicode.hh"
-#include <errno.h>
+#include <cerrno>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
-#include <stdlib.h>
+#include <cstdlib>
#include <sys/select.h>
#if defined(__FreeBSD__)
@@ -470,7 +470,7 @@ CandidateList complete_command(StringView prefix, ByteCount cursor_pos)
return candidates(matches, dirname);
}
- typedef decltype(stat::st_mtim) TimeSpec;
+ using TimeSpec = decltype(stat::st_mtim);
struct CommandCache
{
diff --git a/src/highlighter.hh b/src/highlighter.hh
index 2845f9ad..23f273a1 100644
--- a/src/highlighter.hh
+++ b/src/highlighter.hh
@@ -34,7 +34,7 @@ using HighlighterAndId = std::pair<String, std::unique_ptr<Highlighter>>;
struct Highlighter
{
- virtual ~Highlighter() {}
+ virtual ~Highlighter() = default;
virtual void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range) = 0;
virtual bool has_children() const { return false; }
@@ -48,7 +48,7 @@ template<typename Func>
struct SimpleHighlighter : public Highlighter
{
SimpleHighlighter(Func func) : m_func(std::move(func)) {}
- virtual void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range) override
+ void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range) override
{
m_func(context, flags, display_buffer, range);
}
diff --git a/src/highlighters.cc b/src/highlighters.cc
index 3b761fcc..fdb85c69 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -397,7 +397,7 @@ public:
m_face_getter(std::move(face_getter)),
m_highlighter(Regex{}, FacesSpec{}) {}
- void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range)
+ void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range) override
{
if (flags != HighlightFlags::Highlight)
return;
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 75491041..efeddfb9 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -1,3 +1,5 @@
+#include <utility>
+
#include "input_handler.hh"
#include "buffer_manager.hh"
@@ -21,7 +23,7 @@ class InputMode : public RefCountable
{
public:
InputMode(InputHandler& input_handler) : m_input_handler(input_handler) {}
- virtual ~InputMode() {}
+ ~InputMode() override = default;
InputMode(const InputMode&) = delete;
InputMode& operator=(const InputMode&) = delete;
@@ -282,13 +284,13 @@ public:
AtomList atoms = { { to_string(context().selections().size()) + " sel", get_face("StatusLineInfo") } };
if (m_params.count != 0)
{
- atoms.push_back({ " param=", get_face("StatusLineInfo") });
- atoms.push_back({ to_string(m_params.count), get_face("StatusLineValue") });
+ atoms.emplace_back(" param=", get_face("StatusLineInfo"));
+ atoms.emplace_back(to_string(m_params.count), get_face("StatusLineValue"));
}
if (m_params.reg)
{
- atoms.push_back({ " reg=", get_face("StatusLineInfo") });
- atoms.push_back({ StringView(m_params.reg).str(), get_face("StatusLineValue") });
+ atoms.emplace_back(" reg=", get_face("StatusLineInfo"));
+ atoms.emplace_back(StringView(m_params.reg).str(), get_face("StatusLineValue"));
}
return atoms;
}
@@ -513,7 +515,7 @@ public:
Menu(InputHandler& input_handler, Vector<DisplayLine> choices,
MenuCallback callback)
: InputMode(input_handler),
- m_callback(callback), m_choices(choices.begin(), choices.end()),
+ m_callback(std::move(callback)), m_choices(choices.begin(), choices.end()),
m_selected(m_choices.begin())
{
if (not context().has_client())
@@ -677,7 +679,7 @@ public:
String initstr, Face face, PromptFlags flags,
Completer completer, PromptCallback callback)
: InputMode(input_handler), m_prompt(prompt.str()), m_prompt_face(face),
- m_flags(flags), m_completer(completer), m_callback(callback),
+ m_flags(flags), m_completer(std::move(completer)), m_callback(std::move(callback)),
m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()}
{
m_history_it = ms_history[m_prompt].end();
@@ -1009,7 +1011,7 @@ public:
get_face("Error") });
}
- ~Insert()
+ ~Insert() override
{
auto& selections = context().selections();
for (auto& sel : selections)
@@ -1057,7 +1059,7 @@ public:
if (sel.cursor() == BufferCoord{0,0})
continue;
auto pos = sel.cursor();
- sels.push_back({ buffer.char_prev(pos) });
+ sels.emplace_back(buffer.char_prev(pos));
}
if (not sels.empty())
SelectionList{buffer, std::move(sels)}.erase();
@@ -1066,7 +1068,7 @@ public:
{
Vector<Selection> sels;
for (auto& sel : context().selections())
- sels.push_back({ sel.cursor() });
+ sels.emplace_back(sel.cursor());
SelectionList{buffer, std::move(sels)}.erase();
}
else if (key == Key::Left)
@@ -1315,8 +1317,7 @@ InputHandler::InputHandler(SelectionList selections, Context::Flags flags, Strin
current_mode().on_enabled();
}
-InputHandler::~InputHandler()
-{}
+InputHandler::~InputHandler() = default;
void InputHandler::push_mode(InputMode* new_mode)
{
diff --git a/src/insert_completer.cc b/src/insert_completer.cc
index 43d512a6..239da7cc 100644
--- a/src/insert_completer.cc
+++ b/src/insert_completer.cc
@@ -14,6 +14,7 @@
#include "user_interface.hh"
#include <numeric>
+#include <utility>
namespace Kakoune
{
@@ -113,8 +114,8 @@ InsertCompletion complete_word(const SelectionList& sels, const OptionManager& o
struct RankedMatchAndBuffer : RankedMatch
{
- RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b)
- : RankedMatch{m}, buffer{b} {}
+ RankedMatchAndBuffer(RankedMatch m, const Buffer* b)
+ : RankedMatch{std::move(m)}, buffer{b} {}
using RankedMatch::operator==;
using RankedMatch::operator<;
@@ -400,11 +401,11 @@ void InsertCompleter::select(int offset, Vector<Key>& keystrokes)
}
for (auto i = 0_byte; i < prefix_len; ++i)
- keystrokes.push_back(Key::Backspace);
+ keystrokes.emplace_back(Key::Backspace);
for (auto i = 0_byte; i < suffix_len; ++i)
- keystrokes.push_back(Key::Delete);
+ keystrokes.emplace_back(Key::Delete);
for (auto& c : candidate.completion)
- keystrokes.push_back(c);
+ keystrokes.emplace_back(c);
}
void InsertCompleter::update()
diff --git a/src/insert_completer.hh b/src/insert_completer.hh
index ac1fa22b..bb3a6caf 100644
--- a/src/insert_completer.hh
+++ b/src/insert_completer.hh
@@ -78,7 +78,7 @@ public:
InsertCompleter(Context& context);
InsertCompleter(const InsertCompleter&) = delete;
InsertCompleter& operator=(const InsertCompleter&) = delete;
- ~InsertCompleter();
+ ~InsertCompleter() override;
void select(int offset, Vector<Key>& keystrokes);
void update();
diff --git a/src/keys.cc b/src/keys.cc
index c9031732..193d4d52 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -64,14 +64,14 @@ KeyList parse_keys(StringView str)
{
if (*it != '<')
{
- result.push_back({Key::Modifiers::None, *it});
+ result.emplace_back(Key::Modifiers::None, *it);
continue;
}
Utf8It end_it = std::find(it, str_end, '>');
if (end_it == str_end)
{
- result.push_back({Key::Modifiers::None, *it});
+ result.emplace_back(Key::Modifiers::None, *it);
continue;
}
@@ -95,12 +95,12 @@ KeyList parse_keys(StringView str)
if (name_it != end(keynamemap))
result.push_back(canonicalize_ifn({ modifier, name_it->key }));
else if (desc.char_length() == 1)
- result.push_back(Key{ modifier, desc[0_char] });
+ result.emplace_back(modifier, desc[0_char]);
else if (to_lower(desc[0_byte]) == 'f' and desc.length() <= 3)
{
int val = str_to_int(desc.substr(1_byte));
if (val >= 1 and val <= 12)
- result.push_back(Key{ modifier, Key::F1 + (val - 1) });
+ result.emplace_back(modifier, Key::F1 + (val - 1));
else
throw runtime_error("Only F1 through F12 are supported");
}
diff --git a/src/main.cc b/src/main.cc
index a6e81f30..a0fa3f09 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -384,7 +384,7 @@ std::unique_ptr<UserInterface> create_local_ui(UIType ui_type)
});
}
- ~LocalUI()
+ ~LocalUI() override
{
set_signal_handler(SIGHUP, m_old_sighup);
set_signal_handler(SIGTSTP, m_old_sigtstp);
@@ -733,7 +733,7 @@ int main(int argc, char* argv[])
Vector<String> params;
for (size_t i = 1; i < argc; ++i)
- params.push_back(argv[i]);
+ params.emplace_back(argv[i]);
const ParameterDesc param_desc{
SwitchMap{ { "c", { true, "connect to given session" } },
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc
index ee5a4241..5c0df88b 100644
--- a/src/ncurses_ui.cc
+++ b/src/ncurses_ui.cc
@@ -13,7 +13,7 @@
#include <ncurses.h>
#include <fcntl.h>
-#include <signal.h>
+#include <csignal>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh
index a25dbd64..379d8a33 100644
--- a/src/ncurses_ui.hh
+++ b/src/ncurses_ui.hh
@@ -17,7 +17,7 @@ class NCursesUI : public UserInterface
{
public:
NCursesUI();
- ~NCursesUI();
+ ~NCursesUI() override;
NCursesUI(const NCursesUI&) = delete;
NCursesUI& operator=(const NCursesUI&) = delete;
diff --git a/src/normal.cc b/src/normal.cc
index 2f80e851..761af327 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -609,8 +609,8 @@ void paste_all(Context& context, NormalParams params)
ByteCount pos = 0;
for (auto offset : offsets)
{
- result.push_back({ buffer.advance(ins_pos, pos),
- buffer.advance(ins_pos, offset-1) });
+ result.emplace_back(buffer.advance(ins_pos, pos),
+ buffer.advance(ins_pos, offset-1));
pos = offset;
}
}
@@ -819,7 +819,7 @@ void join_lines_select_spaces(Context& context, NormalParams)
{
auto begin = buffer.iterator_at({line, buffer[line].length()-1});
auto end = std::find_if_not(begin+1, buffer.end(), is_horizontal_blank);
- selections.push_back({begin.coord(), (end-1).coord()});
+ selections.emplace_back(begin.coord(), (end-1).coord());
}
}
if (selections.empty())
@@ -905,7 +905,7 @@ void indent(Context& context, NormalParams)
for (auto line = std::max(last_line, sel.min().line); line < sel.max().line+1; ++line)
{
if (indent_empty or buffer[line].length() > 1)
- sels.push_back({line, line});
+ sels.emplace_back(line, line);
}
// avoid reindenting the same line if multiple selections are on it
last_line = sel.max().line+1;
@@ -946,12 +946,12 @@ void deindent(Context& context, NormalParams)
else
{
if (deindent_incomplete and width != 0)
- sels.push_back({ line, BufferCoord{line, column-1} });
+ sels.emplace_back(line, BufferCoord{line, column-1});
break;
}
if (width == indent_width)
{
- sels.push_back({ line, BufferCoord{line, column} });
+ sels.emplace_back(line, BufferCoord{line, column});
break;
}
}
@@ -1367,8 +1367,8 @@ void tabs_to_spaces(Context& context, NormalParams params)
{
ColumnCount col = get_column(buffer, opt_tabstop, it.coord());
ColumnCount end_col = (col / tabstop + 1) * tabstop;
- tabs.push_back({ it.coord() });
- spaces.push_back(String{ ' ', end_col - col });
+ tabs.emplace_back(it.coord());
+ spaces.emplace_back(' ', end_col - col);
}
}
}
@@ -1399,9 +1399,9 @@ void spaces_to_tabs(Context& context, NormalParams params)
++col;
}
if ((col % tabstop) == 0)
- spaces.push_back({spaces_beg.coord(), (spaces_end-1).coord()});
+ spaces.emplace_back(spaces_beg.coord(), (spaces_end-1).coord());
else if (spaces_end != end and *spaces_end == '\t')
- spaces.push_back({spaces_beg.coord(), spaces_end.coord()});
+ spaces.emplace_back(spaces_beg.coord(), spaces_end.coord());
it = spaces_end;
}
else
diff --git a/src/option_manager.hh b/src/option_manager.hh
index ed0c1ed0..9cd31278 100644
--- a/src/option_manager.hh
+++ b/src/option_manager.hh
@@ -71,7 +71,7 @@ protected:
class OptionManagerWatcher
{
public:
- virtual ~OptionManagerWatcher() {}
+ virtual ~OptionManagerWatcher() = default;
virtual void on_option_changed(const Option& option) = 0;
};
@@ -80,7 +80,7 @@ class OptionManager : private OptionManagerWatcher
{
public:
OptionManager(OptionManager& parent);
- ~OptionManager();
+ ~OptionManager() override;
Option& operator[] (StringView name);
const Option& operator[] (StringView name) const;
diff --git a/src/optional.hh b/src/optional.hh
index 54c72a89..623d6b23 100644
--- a/src/optional.hh
+++ b/src/optional.hh
@@ -3,6 +3,8 @@
#include "assert.hh"
+#include <utility>
+
namespace Kakoune
{
diff --git a/src/register_manager.hh b/src/register_manager.hh
index 84bf0a60..d5bc1ec3 100644
--- a/src/register_manager.hh
+++ b/src/register_manager.hh
@@ -16,7 +16,7 @@ class Context;
class Register
{
public:
- virtual ~Register() {}
+ virtual ~Register() = default;
virtual Register& operator=(ConstArrayView<String> values) = 0;
virtual ConstArrayView<String> values(const Context& context) = 0;
diff --git a/src/remote.cc b/src/remote.cc
index 06259b67..016ba23c 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -186,7 +186,7 @@ public:
{
T object;
alignas(T) char data[sizeof(T)];
- U() {}
+ U() {};
~U() { object.~T(); }
} u;
read(u.data, sizeof(T));
@@ -297,7 +297,7 @@ class RemoteUI : public UserInterface
{
public:
RemoteUI(int socket, DisplayCoord dimensions);
- ~RemoteUI();
+ ~RemoteUI() override;
void menu_show(ConstArrayView<DisplayLine> choices,
DisplayCoord anchor, Face fg, Face bg,
@@ -654,7 +654,7 @@ private:
auto init_cmds = m_reader.read<String>();
auto dimensions = m_reader.read<DisplayCoord>();
auto env_vars = m_reader.read_idmap<String, MemoryDomain::EnvVars>();
- RemoteUI* ui = new RemoteUI{sock, dimensions};
+ auto* ui = new RemoteUI{sock, dimensions};
if (auto* client = ClientManager::instance().create_client(
std::unique_ptr<UserInterface>(ui),
std::move(env_vars), init_cmds, {}))
diff --git a/src/selection.cc b/src/selection.cc
index 9a7d7eb7..5501bbd0 100644
--- a/src/selection.cc
+++ b/src/selection.cc
@@ -277,9 +277,9 @@ Vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp)
for (; change_it != forward_end; ++change_it)
{
if (change_it->type == Buffer::Change::Insert)
- ranges.push_back({ change_it->begin, change_it->end });
+ ranges.emplace_back(change_it->begin, change_it->end);
else
- ranges.push_back({ change_it->begin });
+ ranges.emplace_back(change_it->begin);
changes_tracker.update(*change_it);
}
}
@@ -298,9 +298,9 @@ Vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp)
change.end = changes_tracker.get_new_coord(change.end);
if (change.type == Buffer::Change::Insert)
- ranges.push_back({ change.begin, change.end });
+ ranges.emplace_back(change.begin, change.end);
else
- ranges.push_back({ change.begin });
+ ranges.emplace_back(change.begin);
changes_tracker.update(change);
}
change_it = backward_end;
diff --git a/src/selectors.cc b/src/selectors.cc
index 2ef2c2b5..97e7fd33 100644
--- a/src/selectors.cc
+++ b/src/selectors.cc
@@ -185,7 +185,7 @@ Selection select_matching(const Buffer& buffer, const Selection& selection)
{
Vector<Codepoint> matching_pairs = { '(', ')', '{', '}', '[', ']', '<', '>' };
Utf8Iterator it{buffer.iterator_at(selection.cursor()), buffer};
- Vector<Codepoint>::iterator match = matching_pairs.end();
+ auto match = matching_pairs.end();
while (not is_eol(*it))
{
match = std::find(matching_pairs.begin(), matching_pairs.end(), *it);
diff --git a/src/shared_string.hh b/src/shared_string.hh
index 49bbdb4c..a13f042f 100644
--- a/src/shared_string.hh
+++ b/src/shared_string.hh
@@ -35,7 +35,7 @@ struct StringData : UseMemoryDomain<MemoryDomain::SharedString>
{
const int len = (int)str.length() + (back != 0 ? 1 : 0);
void* ptr = StringData::operator new(sizeof(StringData) + len + 1);
- StringData* res = new (ptr) StringData(0, len);
+ auto* res = new (ptr) StringData(0, len);
std::copy(str.begin(), str.end(), res->data());
if (back != 0)
res->data()[len-1] = back;
diff --git a/src/shell_manager.cc b/src/shell_manager.cc
index f6623db3..57b6dad3 100644
--- a/src/shell_manager.cc
+++ b/src/shell_manager.cc
@@ -13,7 +13,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <stdlib.h>
+#include <cstdlib>
extern char **environ;
@@ -24,7 +24,7 @@ ShellManager::ShellManager()
{
// Get a guaranteed to be POSIX shell binary
{
- auto size = confstr(_CS_PATH, 0, 0);
+ auto size = confstr(_CS_PATH, nullptr, 0);
String path; path.resize(size-1, 0);
confstr(_CS_PATH, path.data(), size);
for (auto dir : StringView{path} | split<StringView>(':'))
diff --git a/src/string.hh b/src/string.hh
index 28c193b8..8ce6ded5 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -8,7 +8,7 @@
#include "utf8.hh"
#include "vector.hh"
-#include <string.h>
+#include <cstring>
#include <climits>
namespace Kakoune
diff --git a/src/unicode.hh b/src/unicode.hh
index 1c96e1cd..2fcba68c 100644
--- a/src/unicode.hh
+++ b/src/unicode.hh
@@ -1,8 +1,8 @@
#ifndef unicode_hh_INCLUDED
#define unicode_hh_INCLUDED
-#include <wctype.h>
-#include <wchar.h>
+#include <cwctype>
+#include <cwchar>
#include <locale>
#include "units.hh"
diff --git a/src/user_interface.hh b/src/user_interface.hh
index 95dc9650..a6a65885 100644
--- a/src/user_interface.hh
+++ b/src/user_interface.hh
@@ -39,7 +39,7 @@ using OnKeyCallback = std::function<void(Key key)>;
class UserInterface
{
public:
- virtual ~UserInterface() {}
+ virtual ~UserInterface() = default;
virtual void menu_show(ConstArrayView<DisplayLine> choices,
DisplayCoord anchor, Face fg, Face bg,
diff --git a/src/value.hh b/src/value.hh
index cb47ad9b..941c3ffb 100644
--- a/src/value.hh
+++ b/src/value.hh
@@ -52,7 +52,7 @@ struct Value
private:
struct Concept
{
- virtual ~Concept() {}
+ virtual ~Concept() = default;
virtual const std::type_info& type() const = 0;
};
diff --git a/src/window.hh b/src/window.hh
index d4359864..4e40dd62 100644
--- a/src/window.hh
+++ b/src/window.hh
@@ -16,7 +16,7 @@ class Window : public SafeCountable, public OptionManagerWatcher, public Scope
{
public:
Window(Buffer& buffer);
- ~Window();
+ ~Window() override;
const DisplayCoord& position() const { return m_position; }
void set_position(DisplayCoord position);
diff --git a/src/word_db.hh b/src/word_db.hh
index c23d266e..07b56f34 100644
--- a/src/word_db.hh
+++ b/src/word_db.hh
@@ -17,7 +17,7 @@ class WordDB : public OptionManagerWatcher
{
public:
WordDB(const Buffer& buffer);
- ~WordDB();
+ ~WordDB() override;
WordDB(const WordDB&) = delete;
WordDB(WordDB&&);