1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-24 12:02:15 +03:00

rename assert to kak_assert to avoid collisions

This commit is contained in:
Maxime Coste 2013-04-09 20:04:11 +02:00
parent 34b8604f90
commit 5adee4a6a7
33 changed files with 146 additions and 150 deletions

View File

@ -12,17 +12,13 @@ void on_assert_failed(const char* message);
#define TOSTRING(X) STRINGIFY(X)
#define COMMA ,
#ifdef assert
#undef assert
#endif
#ifdef KAK_DEBUG
#define assert(condition) \
#define kak_assert(condition) \
if (not (condition)) \
on_assert_failed("assert failed \"" #condition \
"\" at " __FILE__ ":" TOSTRING(__LINE__))
#else
#define assert(condition)
#define kak_assert(condition)
#endif

View File

@ -32,7 +32,7 @@ Buffer::Buffer(String name, Flags flags, std::vector<String> lines)
m_lines.reserve(lines.size());
for (auto& line : lines)
{
assert(not line.empty() and line.back() == '\n');
kak_assert(not line.empty() and line.back() == '\n');
m_lines.emplace_back(Line{ pos, std::move(line) });
pos += m_lines.back().length();
}
@ -59,7 +59,7 @@ Buffer::~Buffer()
}
BufferManager::instance().unregister_buffer(*this);
assert(m_change_listeners.empty());
kak_assert(m_change_listeners.empty());
}
String Buffer::display_name() const
@ -77,7 +77,7 @@ BufferIterator Buffer::iterator_at(const BufferCoord& line_and_column,
ByteCount Buffer::line_length(LineCount line) const
{
assert(line < line_count());
kak_assert(line < line_count());
ByteCount end = (line < line_count() - 1) ?
m_lines[line + 1].start : character_count();
return end - m_lines[line].start;
@ -99,7 +99,7 @@ BufferCoord Buffer::clamp(const BufferCoord& line_and_column,
BufferIterator Buffer::iterator_at_line_begin(LineCount line) const
{
line = Kakoune::clamp(line, 0_line, line_count()-1);
assert(line_length(line) > 0);
kak_assert(line_length(line) > 0);
return BufferIterator(*this, { line, 0 });
}
@ -111,7 +111,7 @@ BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) co
BufferIterator Buffer::iterator_at_line_end(LineCount line) const
{
line = Kakoune::clamp(line, 0_line, line_count()-1);
assert(line_length(line) > 0);
kak_assert(line_length(line) > 0);
return ++BufferIterator(*this, { line, line_length(line) - 1 });
}
@ -197,7 +197,7 @@ struct Buffer::Modification
{
case Insert: inverse_type = Erase; break;
case Erase: inverse_type = Insert; break;
default: assert(false);
default: kak_assert(false);
}
return {inverse_type, position, content};
}
@ -222,7 +222,7 @@ bool Buffer::redo()
if (m_history_cursor == m_history.end())
return false;
assert(m_current_undo_group.empty());
kak_assert(m_current_undo_group.empty());
for (const Modification& modification : *m_history_cursor)
apply_modification(modification);
@ -235,12 +235,12 @@ void Buffer::check_invariant() const
{
#ifdef KAK_DEBUG
ByteCount start = 0;
assert(not m_lines.empty());
kak_assert(not m_lines.empty());
for (auto& line : m_lines)
{
assert(line.start == start);
assert(line.length() > 0);
assert(line.content.back() == '\n');
kak_assert(line.start == start);
kak_assert(line.length() > 0);
kak_assert(line.content.back() == '\n');
start += line.length();
}
#endif
@ -248,7 +248,7 @@ void Buffer::check_invariant() const
void Buffer::do_insert(const BufferIterator& pos, const String& content)
{
assert(pos.is_valid());
kak_assert(pos.is_valid());
if (content.empty())
return;
@ -327,8 +327,8 @@ void Buffer::do_insert(const BufferIterator& pos, const String& content)
void Buffer::do_erase(const BufferIterator& begin, const BufferIterator& end)
{
assert(begin.is_valid());
assert(end.is_valid());
kak_assert(begin.is_valid());
kak_assert(end.is_valid());
++m_timestamp;
const ByteCount length = end - begin;
String prefix = m_lines[begin.line()].content.substr(0, begin.column());
@ -360,7 +360,7 @@ void Buffer::apply_modification(const Modification& modification)
if (not pos.is_end() and pos.column() == m_lines[pos.line()].length())
pos = { pos.buffer(), { pos.line() + 1, 0 }};
assert(pos.is_valid());
kak_assert(pos.is_valid());
switch (modification.type)
{
case Modification::Insert:
@ -372,12 +372,12 @@ void Buffer::apply_modification(const Modification& modification)
{
ByteCount count = content.length();
BufferIterator end = pos + count;
assert(string(pos, end) == content);
kak_assert(string(pos, end) == content);
do_erase(pos, end);
break;
}
default:
assert(false);
kak_assert(false);
}
}

View File

@ -9,12 +9,12 @@ namespace Kakoune
inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord)
: m_buffer(&buffer), m_coord(coord)
{
assert(is_valid());
kak_assert(is_valid());
}
inline const Buffer& BufferIterator::buffer() const
{
assert(m_buffer);
kak_assert(m_buffer);
return *m_buffer;
}
@ -30,7 +30,7 @@ inline bool BufferIterator::is_valid() const
inline void BufferIterator::clamp(bool avoid_eol)
{
assert(m_buffer);
kak_assert(m_buffer);
m_coord = m_buffer->clamp(m_coord, avoid_eol);
}
@ -46,25 +46,25 @@ inline bool BufferIterator::operator!=(const BufferIterator& iterator) const
inline bool BufferIterator::operator<(const BufferIterator& iterator) const
{
assert(m_buffer == iterator.m_buffer);
kak_assert(m_buffer == iterator.m_buffer);
return (m_coord < iterator.m_coord);
}
inline bool BufferIterator::operator<=(const BufferIterator& iterator) const
{
assert(m_buffer == iterator.m_buffer);
kak_assert(m_buffer == iterator.m_buffer);
return (m_coord <= iterator.m_coord);
}
inline bool BufferIterator::operator>(const BufferIterator& iterator) const
{
assert(m_buffer == iterator.m_buffer);
kak_assert(m_buffer == iterator.m_buffer);
return (m_coord > iterator.m_coord);
}
inline bool BufferIterator::operator>=(const BufferIterator& iterator) const
{
assert(m_buffer == iterator.m_buffer);
kak_assert(m_buffer == iterator.m_buffer);
return (m_coord >= iterator.m_coord);
}
@ -75,20 +75,20 @@ inline char BufferIterator::operator*() const
inline ByteCount BufferIterator::offset() const
{
assert(m_buffer);
kak_assert(m_buffer);
return line() >= m_buffer->line_count() ?
m_buffer->character_count() : m_buffer->m_lines[line()].start + column();
}
inline size_t BufferIterator::operator-(const BufferIterator& iterator) const
{
assert(m_buffer == iterator.m_buffer);
kak_assert(m_buffer == iterator.m_buffer);
return (size_t)(int)(offset() - iterator.offset());
}
inline BufferIterator BufferIterator::operator+(ByteCount size) const
{
assert(m_buffer);
kak_assert(m_buffer);
if (size >= 0)
{
ByteCount o = std::min(m_buffer->character_count(), offset() + size);
@ -105,7 +105,7 @@ inline BufferIterator BufferIterator::operator+(ByteCount size) const
inline BufferIterator BufferIterator::operator-(ByteCount size) const
{
assert(m_buffer);
kak_assert(m_buffer);
if (size >= 0)
{
ByteCount o = std::max(0_byte, offset() - size);
@ -114,7 +114,7 @@ inline BufferIterator BufferIterator::operator-(ByteCount size) const
if (m_buffer->m_lines[i].start <= o)
return BufferIterator(*m_buffer, { i, o - m_buffer->m_lines[i].start });
}
assert(false);
kak_assert(false);
}
return operator+(-size);
}
@ -175,22 +175,22 @@ inline BufferIterator BufferIterator::operator--(int)
inline BufferIterator& BufferIterator::operator=(const BufferCoord& coord)
{
m_coord = coord;
assert(is_valid());
kak_assert(is_valid());
return *this;
}
inline bool BufferIterator::is_begin() const
{
assert(m_buffer);
kak_assert(m_buffer);
return m_coord.line == 0 and m_coord.column == 0;
}
inline bool BufferIterator::is_end() const
{
assert(m_buffer);
kak_assert(m_buffer);
if (m_coord.line == m_buffer->line_count())
{
assert(m_coord.column == 0);
kak_assert(m_coord.column == 0);
return true;
}
return offset() == m_buffer->character_count();

View File

@ -43,7 +43,7 @@ void BufferManager::unregister_buffer(Buffer& buffer)
return;
}
}
assert(false);
kak_assert(false);
}
Buffer* BufferManager::get_buffer_ifp(const String& name)
@ -71,7 +71,7 @@ void BufferManager::set_last_used_buffer(Buffer& buffer)
auto it = m_buffers.begin();
while (*it != &buffer and it != m_buffers.end())
++it;
assert(it != m_buffers.end());
kak_assert(it != m_buffers.end());
m_buffers.erase(it);
m_buffers.emplace(m_buffers.begin(), &buffer);
}

View File

@ -19,7 +19,7 @@ struct ClientManager::Client
input_handler(*user_interface),
name(std::move(name))
{
assert(not this->name.empty());
kak_assert(not this->name.empty());
context().change_editor(window);
}
Client(Client&&) = delete;
@ -106,7 +106,7 @@ void ClientManager::remove_client_by_context(Context& context)
return;
}
}
assert(false);
kak_assert(false);
}
Window& ClientManager::get_unused_window_for_buffer(Buffer& buffer)

View File

@ -34,7 +34,7 @@ String color_to_str(const Color& color)
case Color::Cyan: return "cyan";
case Color::White: return "white";
}
assert(false);
kak_assert(false);
return "default";
}

View File

@ -324,7 +324,7 @@ Completions CommandManager::complete(const Context& context,
return result;
}
assert(not tokens.empty());
kak_assert(not tokens.empty());
if (tokens[0].type() != Token::Type::Raw)
return Completions();
@ -357,7 +357,7 @@ CandidateList PerArgumentCommandCompleter::operator()(const Context& context,
return CandidateList();
// it is possible to try to complete a new argument
assert(token_to_complete <= params.size());
kak_assert(token_to_complete <= params.size());
const String& argument = token_to_complete < params.size() ?
params[token_to_complete] : String();

View File

@ -66,7 +66,7 @@ Buffer* open_fifo(const String& name , const String& filename, Context& context)
ClientManager::instance().redraw_clients();
if (count <= 0)
{
assert(buffer->flags() & Buffer::Flags::Fifo);
kak_assert(buffer->flags() & Buffer::Flags::Fifo);
buffer->flags() &= ~Buffer::Flags::Fifo;
close(watcher.fd());
delete &watcher;
@ -804,7 +804,7 @@ public:
Key get_key() override
{
assert(m_pos < m_keys.size());
kak_assert(m_pos < m_keys.size());
return m_keys[m_pos++];
}
bool is_key_available() override { return m_pos < m_keys.size(); }

View File

@ -15,7 +15,7 @@ static Buffer& get_or_create_debug_buffer()
if (not buffer)
buffer = new Buffer(debug_buffer_name, Buffer::Flags::NoUndo);
assert(buffer);
kak_assert(buffer);
return *buffer;
}

View File

@ -7,9 +7,9 @@ namespace Kakoune
DisplayLine::iterator DisplayLine::split(iterator it, BufferIterator pos)
{
assert(it->content.type() == AtomContent::BufferRange);
assert(it->content.begin() < pos);
assert(it->content.end() > pos);
kak_assert(it->content.type() == AtomContent::BufferRange);
kak_assert(it->content.begin() < pos);
kak_assert(it->content.end() > pos);
DisplayAtom atom = *it;
atom.content.m_end = pos;
@ -68,8 +68,8 @@ void DisplayBuffer::compute_range()
m_range.second = atom.content.end();
}
}
assert(m_range.first.is_valid() and m_range.second.is_valid());
assert(m_range.first <= m_range.second);
kak_assert(m_range.first.is_valid() and m_range.second.is_valid());
kak_assert(m_range.first <= m_range.second);
}
void DisplayBuffer::optimize()

View File

@ -54,7 +54,7 @@ public:
case ReplacedBufferRange:
return m_text;
}
assert(false);
kak_assert(false);
return 0;
}
@ -68,25 +68,25 @@ public:
case ReplacedBufferRange:
return m_text.char_length();
}
assert(false);
kak_assert(false);
return 0;
}
const BufferIterator& begin() const
{
assert(has_buffer_range());
kak_assert(has_buffer_range());
return m_begin;
}
const BufferIterator& end() const
{
assert(has_buffer_range());
kak_assert(has_buffer_range());
return m_end;
}
void replace(String text)
{
assert(m_type == BufferRange);
kak_assert(m_type == BufferRange);
m_type = ReplacedBufferRange;
m_text = std::move(text);
}

View File

@ -24,7 +24,7 @@ void DynamicSelectionList::check_invariant() const
const Buffer* buf = &buffer();
for (auto& sel : *this)
{
assert(buf == &sel.buffer());
kak_assert(buf == &sel.buffer());
sel.check_invariant();
}
#endif
@ -70,7 +70,7 @@ struct UpdateInsert
{
BufferCoord coord = it.coord();
if (assume_different_line)
assert(begin.line < coord.line);
kak_assert(begin.line < coord.line);
if (not assume_greater_than_begin and coord < begin)
return;
if (not assume_different_line and begin.line == coord.line)
@ -91,7 +91,7 @@ struct UpdateErase
if (not assume_greater_than_begin and coord < begin)
return;
if (assume_different_line)
assert(end.line < coord.line);
kak_assert(end.line < coord.line);
if (not assume_different_line and coord <= end)
coord = it.buffer().clamp(begin);
else

View File

@ -72,7 +72,7 @@ static BufferIterator prepare_insert(Buffer& buffer, const Selection& sel,
return pos;
}
}
assert(false);
kak_assert(false);
return BufferIterator{};
}
@ -162,7 +162,7 @@ static void sort_and_merge_overlapping(SelectionList& selections, size_t& main_s
void Editor::move_selections(CharCount offset, SelectMode mode)
{
assert(mode == SelectMode::Replace or mode == SelectMode::Extend);
kak_assert(mode == SelectMode::Replace or mode == SelectMode::Extend);
for (auto& sel : m_selections)
{
auto last = sel.last();
@ -178,7 +178,7 @@ void Editor::move_selections(CharCount offset, SelectMode mode)
void Editor::move_selections(LineCount offset, SelectMode mode)
{
assert(mode == SelectMode::Replace or mode == SelectMode::Extend);
kak_assert(mode == SelectMode::Replace or mode == SelectMode::Extend);
for (auto& sel : m_selections)
{
BufferCoord pos = sel.last().coord();
@ -257,7 +257,7 @@ void Editor::select(const Selection& selection, SelectMode mode)
sort_and_merge_overlapping(m_selections, m_main_sel);
}
else
assert(false);
kak_assert(false);
check_invariant();
}
@ -352,15 +352,15 @@ public:
void on_insert(const BufferIterator& begin, const BufferIterator& end)
{
assert(begin.is_valid());
assert(end.is_valid());
kak_assert(begin.is_valid());
kak_assert(end.is_valid());
m_first = begin;
m_last = utf8::previous(end);
}
void on_erase(const BufferIterator& begin, const BufferIterator& end)
{
assert(begin.is_valid());
kak_assert(begin.is_valid());
m_first = begin;
if (m_first >= m_buffer.end())
m_first = utf8::previous(m_buffer.end());
@ -405,11 +405,11 @@ bool Editor::redo()
void Editor::check_invariant() const
{
#ifdef KAK_DEBUG
assert(not m_selections.empty());
assert(m_main_sel < m_selections.size());
kak_assert(not m_selections.empty());
kak_assert(m_main_sel < m_selections.size());
m_selections.check_invariant();
buffer().check_invariant();
assert(std::is_sorted(m_selections.begin(), m_selections.end(), compare_selections));
kak_assert(std::is_sorted(m_selections.begin(), m_selections.end(), compare_selections));
#endif
}
@ -420,7 +420,7 @@ void Editor::begin_edition()
void Editor::end_edition()
{
assert(m_edition_level > 0);
kak_assert(m_edition_level > 0);
if (m_edition_level == 1)
m_buffer->commit_undo_group();
@ -479,7 +479,7 @@ IncrementalInserter::IncrementalInserter(Editor& editor, InsertMode mode)
last = first;
break;
case InsertMode::InsertAtNextLineBegin:
assert(false); // not implemented
kak_assert(false); // not implemented
break;
}
if (first.underlying_iterator().is_end())

View File

@ -40,8 +40,8 @@ EventManager::EventManager()
EventManager::~EventManager()
{
assert(m_fd_watchers.empty());
assert(m_timers.empty());
kak_assert(m_fd_watchers.empty());
kak_assert(m_timers.empty());
}
void EventManager::handle_next_events()

View File

@ -44,7 +44,7 @@ void expand_tabulations(Buffer& buffer, Selection& selection, String& content)
for (auto line_it = buffer.iterator_at_line_begin(position);
line_it != position; ++line_it)
{
assert(*line_it != '\n');
kak_assert(*line_it != '\n');
if (*line_it == '\t')
column += tabstop - (column % tabstop);
else

View File

@ -20,7 +20,7 @@ class FunctionRegistry
public:
void register_func(const String& name, const FunctionType& function)
{
assert(not m_functions.contains(name));
kak_assert(not m_functions.contains(name));
m_functions.append(std::make_pair(name, function));
}

View File

@ -239,7 +239,7 @@ void expand_tabulations(const OptionManager& options, DisplayBuffer& display_buf
for (auto line_it = it.buffer().iterator_at_line_begin(it);
line_it != it; ++line_it)
{
assert(*line_it != '\n');
kak_assert(*line_it != '\n');
if (*line_it == '\t')
column += tabstop - (column % tabstop);
else

View File

@ -127,7 +127,7 @@ public:
void insert_from(CharCount start, const String& str)
{
assert(start <= m_cursor_pos);
kak_assert(start <= m_cursor_pos);
m_line = m_line.substr(0, start) + str
+ m_line.substr(m_cursor_pos);
m_cursor_pos = start + str.char_length();
@ -148,7 +148,7 @@ private:
static DisplayLine line_with_cursor(const String& str, CharCount cursor_pos)
{
assert(cursor_pos <= str.char_length());
kak_assert(cursor_pos <= str.char_length());
if (cursor_pos == str.char_length())
return DisplayLine{-1, { {str, get_color("StatusLine")},
{" "_str, get_color("StatusCursor")} }};
@ -654,7 +654,7 @@ private:
if (not m_completions.is_valid())
return false;
assert(cursor >= m_completions.begin);
kak_assert(cursor >= m_completions.begin);
m_matching_candidates = m_completions.candidates;
m_current_candidate = m_matching_candidates.size();
@ -799,7 +799,7 @@ void InputHandler::repeat_last_insert()
m_mode.reset(new InputModes::Insert(*this, m_last_insert.first));
for (auto& key : keys)
m_mode->on_key(key);
assert(dynamic_cast<InputModes::Normal*>(m_mode.get()) != nullptr);
kak_assert(dynamic_cast<InputModes::Normal*>(m_mode.get()) != nullptr);
}
void InputHandler::prompt(const String& prompt, ColorPair prompt_colors,
@ -857,7 +857,7 @@ void InputHandler::handle_available_inputs()
void InputHandler::start_recording(char reg)
{
assert(m_recording_reg == 0);
kak_assert(m_recording_reg == 0);
m_recorded_keys = "";
m_recording_reg = reg;
}
@ -869,7 +869,7 @@ bool InputHandler::is_recording() const
void InputHandler::stop_recording()
{
assert(m_recording_reg != 0);
kak_assert(m_recording_reg != 0);
RegisterManager::instance()[m_recording_reg] = memoryview<String>(m_recorded_keys);
m_recording_reg = 0;
}

View File

@ -8,7 +8,7 @@ Key canonicalize_ifn(Key key)
{
if (key.key > 0 and key.key < 27)
{
assert(key.modifiers == Key::Modifiers::None);
kak_assert(key.modifiers == Key::Modifiers::None);
key.modifiers = Key::Modifiers::Control;
key.key = key.key - 1 + 'a';
}

View File

@ -324,7 +324,7 @@ static InsertMode adapt_for_linewise(InsertMode mode)
if (mode == InsertMode::Replace)
return InsertMode::Replace;
assert(false);
kak_assert(false);
return InsertMode::Insert;
}
@ -409,7 +409,7 @@ void do_join(Context& context)
{
SelectionList res = select_all_matches(sel, Regex{"\n\\h*"});
// remove last end of line if selected
assert(std::is_sorted(res.begin(), res.end(),
kak_assert(std::is_sorted(res.begin(), res.end(),
[](const Selection& lhs, const Selection& rhs)
{ return lhs.begin() < rhs.begin(); }));
if (not res.empty() and res.back().end() == sel.buffer().end())
@ -614,7 +614,7 @@ String runtime_directory()
char buffer[2048];
#if defined(__linux__)
ssize_t res = readlink("/proc/self/exe", buffer, 2048);
assert(res != -1);
kak_assert(res != -1);
buffer[res] = '\0';
#elif defined(__APPLE__)
uint32_t bufsize = 2048;

View File

@ -302,7 +302,7 @@ void NCursesUI::print_status(const DisplayLine& status)
void NCursesUI::draw_menu()
{
assert(m_menu_win);
kak_assert(m_menu_win);
auto menu_fg = get_color_pair(m_menu_fg);
auto menu_bg = get_color_pair(m_menu_bg);
@ -347,8 +347,8 @@ void NCursesUI::menu_show(const memoryview<String>& choices,
DisplayCoord anchor, ColorPair fg, ColorPair bg,
MenuStyle style)
{
assert(m_menu_win == nullptr);
assert(m_choices.empty());
kak_assert(m_menu_win == nullptr);
kak_assert(m_choices.empty());
m_menu_fg = fg;
m_menu_bg = bg;
@ -470,7 +470,7 @@ static DisplayCoord compute_pos(const DisplayCoord& anchor,
void NCursesUI::info_show(const String& content, DisplayCoord anchor,
ColorPair colors, MenuStyle style)
{
assert(m_info_win == nullptr);
kak_assert(m_info_win == nullptr);
DisplayCoord size = compute_needed_size(content);
if (style == MenuStyle::Prompt)

View File

@ -20,19 +20,19 @@ OptionManager::~OptionManager()
if (m_parent)
m_parent->unregister_watcher(*this);
assert(m_watchers.empty());
kak_assert(m_watchers.empty());
}
void OptionManager::register_watcher(OptionManagerWatcher& watcher)
{
assert(not contains(m_watchers, &watcher));
kak_assert(not contains(m_watchers, &watcher));
m_watchers.push_back(&watcher);
}
void OptionManager::unregister_watcher(OptionManagerWatcher& watcher)
{
auto it = find(m_watchers.begin(), m_watchers.end(), &watcher);
assert(it != m_watchers.end());
kak_assert(it != m_watchers.end());
m_watchers.erase(it);
}

View File

@ -43,7 +43,7 @@ ParametersParser::ParametersParser(const ParameterList& params,
bool ParametersParser::has_option(const String& name) const
{
assert(m_options.find(name) != m_options.end());
kak_assert(m_options.find(name) != m_options.end());
for (auto& param : m_params)
{
if (param[0] == '-' and param.substr(1_byte) == name)
@ -59,8 +59,8 @@ const String& ParametersParser::option_value(const String& name) const
{
#ifdef KAK_DEBUG
auto it = m_options.find(name);
assert(it != m_options.end());
assert(it->second == true);
kak_assert(it != m_options.end());
kak_assert(it->second == true);
#endif
for (size_t i = 0; i < m_params.size(); ++i)
@ -82,7 +82,7 @@ size_t ParametersParser::positional_count() const
const String& ParametersParser::operator[] (size_t index) const
{
assert(index < positional_count());
kak_assert(index < positional_count());
return m_params[m_positional_indices[index]];
}

View File

@ -97,19 +97,19 @@ struct ParametersParser
bool operator==(const iterator& other) const
{
assert(&m_parser == &other.m_parser);
kak_assert(&m_parser == &other.m_parser);
return m_index == other.m_index;
}
bool operator!=(const iterator& other) const
{
assert(&m_parser == &other.m_parser);
kak_assert(&m_parser == &other.m_parser);
return m_index != other.m_index;
}
bool operator<(const iterator& other) const
{
assert(&m_parser == &other.m_parser);
kak_assert(&m_parser == &other.m_parser);
return m_index < other.m_index;
}

View File

@ -66,7 +66,7 @@ Register& RegisterManager::operator[](char reg)
void RegisterManager::register_dynamic_register(char reg, RegisterRetriever function)
{
auto& reg_ptr = m_registers[reg];
assert(not reg_ptr);
kak_assert(not reg_ptr);
reg_ptr.reset(new DynamicRegister(std::move(function)));
}

View File

@ -133,7 +133,7 @@ String read<String>(int socket)
if (length == 0)
return String{};
char buffer[2048];
assert(length < 2048);
kak_assert(length < 2048);
read(socket, buffer, (int)length);
return String(buffer, buffer+(int)length);
}

View File

@ -32,10 +32,10 @@ String Range::content() const
void Range::check_invariant() const
{
#ifdef KAK_DEBUG
assert(m_first.is_valid());
assert(m_last.is_valid());
assert(utf8::is_character_start(m_first));
assert(utf8::is_character_start(m_last));
kak_assert(m_first.is_valid());
kak_assert(m_last.is_valid());
kak_assert(utf8::is_character_start(m_first));
kak_assert(utf8::is_character_start(m_last));
#endif
}

View File

@ -92,8 +92,8 @@ String ShellManager::pipe(const String& input,
else if (match[2].matched)
name = String(match[2].first, match[2].second);
else
assert(false);
assert(name.length() > 0);
kak_assert(false);
kak_assert(name.length() > 0);
auto local_var = env_vars.find(name);
if (local_var != env_vars.end())

View File

@ -11,43 +11,43 @@ void test_buffer()
Buffer empty_buffer("empty", Buffer::Flags::None, {});
Buffer buffer("test", Buffer::Flags::None, { "allo ?\n", "mais que fais la police\n", " hein ?\n", " youpi\n" });
assert(buffer.line_count() == 4);
kak_assert(buffer.line_count() == 4);
BufferIterator i = buffer.begin();
assert(*i == 'a');
kak_assert(*i == 'a');
i += 6;
assert(i.coord() == BufferCoord{0 COMMA 6});
kak_assert(i.coord() == BufferCoord{0 COMMA 6});
i += 1;
assert(i.coord() == BufferCoord{1 COMMA 0});
kak_assert(i.coord() == BufferCoord{1 COMMA 0});
--i;
assert(i.coord() == BufferCoord{0 COMMA 6});
kak_assert(i.coord() == BufferCoord{0 COMMA 6});
++i;
assert(i.coord() == BufferCoord{1 COMMA 0});
kak_assert(i.coord() == BufferCoord{1 COMMA 0});
buffer.insert(i, "tchou kanaky\n");
assert(buffer.line_count() == 5);
kak_assert(buffer.line_count() == 5);
BufferIterator begin = buffer.iterator_at({ 4, 1 });
BufferIterator end = buffer.iterator_at({ 4, 5 }) + 1;
String str = buffer.string(begin, end);
assert(str == "youpi");
kak_assert(str == "youpi");
// check insert at end behaviour: auto add end of line if necessary
begin = buffer.end() - 1;
buffer.insert(buffer.end(), "tchou");
assert(buffer.string(begin+1, buffer.end()) == "tchou\n");
kak_assert(buffer.string(begin+1, buffer.end()) == "tchou\n");
begin = buffer.end() - 1;
buffer.insert(buffer.end(), "kanaky\n");
assert(buffer.string(begin+1, buffer.end()) == "kanaky\n");
kak_assert(buffer.string(begin+1, buffer.end()) == "kanaky\n");
buffer.commit_undo_group();
buffer.erase(begin+1, buffer.end());
buffer.insert(buffer.end(), "mutch\n");
buffer.commit_undo_group();
buffer.undo();
assert(buffer.string(buffer.end() - 7, buffer.end()) == "kanaky\n");
kak_assert(buffer.string(buffer.end() - 7, buffer.end()) == "kanaky\n");
buffer.redo();
assert(buffer.string(buffer.end() - 6, buffer.end()) == "mutch\n");
kak_assert(buffer.string(buffer.end() - 6, buffer.end()) == "mutch\n");
}
void test_editor()
@ -61,7 +61,7 @@ void test_editor()
editor.multi_select(std::bind(select_all_matches, std::placeholders::_1, Regex{"\\n\\h*"}));
for (auto& sel : editor.selections())
{
assert(*sel.begin() == '\n');
kak_assert(*sel.begin() == '\n');
editor.buffer().erase(sel.begin(), sel.end());
}
}
@ -70,7 +70,7 @@ void test_editor()
Selection sel{ buffer.iterator_at_line_begin(2_line), buffer.end() };
editor.select(sel, SelectMode::Replace);
editor.insert("",InsertMode::Replace);
assert(not editor.main_selection().first().is_end());
kak_assert(not editor.main_selection().first().is_end());
}
void test_incremental_inserter()
@ -81,35 +81,35 @@ void test_incremental_inserter()
editor.select(buffer.begin());
{
IncrementalInserter inserter(editor, InsertMode::OpenLineAbove);
assert(editor.is_editing());
assert(editor.selections().size() == 1);
assert(editor.selections().front().first() == buffer.begin());
assert(editor.selections().front().last() == buffer.begin());
assert(*buffer.begin() == L'\n');
kak_assert(editor.is_editing());
kak_assert(editor.selections().size() == 1);
kak_assert(editor.selections().front().first() == buffer.begin());
kak_assert(editor.selections().front().last() == buffer.begin());
kak_assert(*buffer.begin() == L'\n');
}
assert(not editor.is_editing());
kak_assert(not editor.is_editing());
}
void test_utf8()
{
String str = "maïs mélange bientôt";
assert(utf8::distance(str.begin(), str.end()) == 20);
assert(utf8::codepoint(str.begin() + 2) == 0x00EF);
kak_assert(utf8::distance(str.begin(), str.end()) == 20);
kak_assert(utf8::codepoint(str.begin() + 2) == 0x00EF);
}
void test_string()
{
assert(int_to_str(124) == "124");
assert(int_to_str(-129) == "-129");
assert(int_to_str(0) == "0");
kak_assert(int_to_str(124) == "124");
kak_assert(int_to_str(-129) == "-129");
kak_assert(int_to_str(0) == "0");
assert(String("youpi ") + "matin" == "youpi matin");
kak_assert(String("youpi ") + "matin" == "youpi matin");
std::vector<String> splited = split("youpi:matin::tchou", ':');
assert(splited[0] == "youpi");
assert(splited[1] == "matin");
assert(splited[2] == "");
assert(splited[3] == "tchou");
kak_assert(splited[0] == "youpi");
kak_assert(splited[1] == "matin");
kak_assert(splited[2] == "");
kak_assert(splited[3] == "tchou");
}
void test_keys()
@ -124,7 +124,7 @@ void test_keys()
for (auto& key : keys)
keys_as_str += key_to_str(key);
auto parsed_keys = parse_keys(keys_as_str);
assert(keys == parsed_keys);
kak_assert(keys == parsed_keys);
}
void run_unit_tests()

View File

@ -95,7 +95,7 @@ namespace InvalidBytePolicy
struct Assert
{
Codepoint operator()(char byte) const { assert(false); return byte; }
Codepoint operator()(char byte) const { kak_assert(false); return byte; }
};
struct Pass

View File

@ -100,7 +100,7 @@ public:
CharCount operator-(utf8_iterator other) const
{
//assert(other < *this);
//kak_assert(other < *this);
check_invariant();
other.check_invariant();
CharCount dist = 0;
@ -124,7 +124,7 @@ protected:
void check_invariant() const
{
// always point to a character first byte;
// assert(is_character_start(it));
// kak_assert(is_character_start(it));
}
private:

View File

@ -41,13 +41,13 @@ public:
protected:
Singleton()
{
assert(not ms_instance);
kak_assert(not ms_instance);
ms_instance = static_cast<T*>(this);
}
~Singleton()
{
assert(ms_instance == this);
kak_assert(ms_instance == this);
ms_instance = nullptr;
}
@ -134,10 +134,10 @@ class SafeCountable
public:
#ifdef KAK_DEBUG
SafeCountable() : m_count(0) {}
~SafeCountable() { assert(m_count == 0); }
~SafeCountable() { kak_assert(m_count == 0); }
void inc_safe_count() const { ++m_count; }
void dec_safe_count() const { --m_count; assert(m_count >= 0); }
void dec_safe_count() const { --m_count; kak_assert(m_count >= 0); }
private:
mutable int m_count;

View File

@ -149,7 +149,7 @@ void Window::scroll_to_keep_cursor_visible_ifn()
if (last != buffer().end())
{
// the cursor should always be visible.
assert(false);
kak_assert(false);
}
}