summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-01-16 18:49:27 +0000
committerMaxime Coste <mawww@kakoune.org>2017-01-16 18:49:27 +0000
commit7316afd17b37f96dbaf9e19d96509eca5d8e407a (patch)
tree312e5e199a2d213cec855c1b32a819a064fbd386 /src
parentc24a636cb9632d03396513f7042d4a585f4a9ed4 (diff)
Use ints instead of unsigned for capture count
Diffstat (limited to 'src')
-rw-r--r--src/normal.cc6
-rw-r--r--src/selectors.cc10
-rw-r--r--src/selectors.hh4
3 files changed, 10 insertions, 10 deletions
diff --git a/src/normal.cc b/src/normal.cc
index c57fbc48..af72e000 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -759,8 +759,8 @@ void use_selection_as_search_pattern(Context& context, NormalParams params)
void select_regex(Context& context, NormalParams params)
{
const char reg = to_lower(params.reg ? params.reg : '/');
- const unsigned capture = (unsigned)params.count;
- auto prompt = capture ? format("select (capture {}):", (int)capture) : "select:"_str;
+ const int capture = params.count;
+ auto prompt = capture ? format("select (capture {}):", capture) : "select:"_str;
auto reg_content = RegisterManager::instance()[reg].values(context);
Vector<String> saved_reg{reg_content.begin(), reg_content.end()};
@@ -786,7 +786,7 @@ void select_regex(Context& context, NormalParams params)
void split_regex(Context& context, NormalParams params)
{
const char reg = to_lower(params.reg ? params.reg : '/');
- unsigned capture = (unsigned)params.count;
+ const int capture = params.count;
auto prompt = capture ? format("split (on capture {}):", (int)capture) : "split:"_str;
auto reg_content = RegisterManager::instance()[reg].values(context);
diff --git a/src/selectors.cc b/src/selectors.cc
index 97e7fd33..598aff70 100644
--- a/src/selectors.cc
+++ b/src/selectors.cc
@@ -841,10 +841,10 @@ template Selection find_next_match<Backward>(const Buffer&, const Selection&, co
using RegexIt = RegexIterator<BufferIterator>;
-void select_all_matches(SelectionList& selections, const Regex& regex, unsigned capture)
+void select_all_matches(SelectionList& selections, const Regex& regex, int capture)
{
- const unsigned mark_count = regex.mark_count();
- if (capture > mark_count)
+ const int mark_count = (int)regex.mark_count();
+ if (capture < 0 or capture > mark_count)
throw runtime_error("invalid capture number");
Vector<Selection> result;
@@ -887,9 +887,9 @@ void select_all_matches(SelectionList& selections, const Regex& regex, unsigned
selections = SelectionList{buffer, std::move(result)};
}
-void split_selections(SelectionList& selections, const Regex& regex, unsigned capture)
+void split_selections(SelectionList& selections, const Regex& regex, int capture)
{
- if (capture > regex.mark_count())
+ if (capture < 0 or capture > (int)regex.mark_count())
throw runtime_error("invalid capture number");
Vector<Selection> result;
diff --git a/src/selectors.hh b/src/selectors.hh
index 0811b8ae..6933a6b2 100644
--- a/src/selectors.hh
+++ b/src/selectors.hh
@@ -87,8 +87,8 @@ bool find_match_in_buffer(const Buffer& buffer, const BufferIterator pos,
template<Direction direction>
Selection find_next_match(const Buffer& buffer, const Selection& sel, const Regex& regex, bool& wrapped);
-void select_all_matches(SelectionList& selections, const Regex& regex, unsigned capture = 0);
-void split_selections(SelectionList& selections, const Regex& separator_regex, unsigned capture = 0);
+void select_all_matches(SelectionList& selections, const Regex& regex, int capture = 0);
+void split_selections(SelectionList& selections, const Regex& separator_regex, int capture = 0);
Selection select_surrounding(const Buffer& buffer, const Selection& selection,
StringView opening, StringView closing, int level,