aboutsummaryrefslogtreecommitdiff
path: root/text-objects.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-04-05 13:00:38 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-04-08 22:54:36 +0200
commitdf762bf0bbdf373a53fdfd5f90b730fe6f7850bb (patch)
treeb74a06e14f5f2ac109c9a23985968e945f656877 /text-objects.c
parent391720cb430ad74d01dacb1cd53c06d6283aba4e (diff)
downloadvis-df762bf0bbdf373a53fdfd5f90b730fe6f7850bb.tar.gz
vis-df762bf0bbdf373a53fdfd5f90b730fe6f7850bb.tar.xz
text: simplify \r\n handling
Diffstat (limited to 'text-objects.c')
-rw-r--r--text-objects.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/text-objects.c b/text-objects.c
index fee8235..3b55b2d 100644
--- a/text-objects.c
+++ b/text-objects.c
@@ -18,11 +18,11 @@ Filerange text_object_entire_inner(Text *txt, size_t pos) {
char c;
Filerange r = text_object_entire(txt, pos);
Iterator it = text_iterator_get(txt, r.start);
- while (text_iterator_byte_get(&it, &c) && (c == '\r' || c == '\n'))
- text_iterator_byte_next(&it, NULL);
+ if (text_iterator_char_get(&it, &c) && c == '\n')
+ while (text_iterator_char_next(&it, &c) && c == '\n');
r.start = it.pos;
it = text_iterator_get(txt, r.end);
- while (text_iterator_byte_prev(&it, &c) && (c == '\r' || c == '\n'));
+ while (text_iterator_char_prev(&it, &c) && c == '\n');
r.end = it.pos;
return text_range_linewise(txt, &r);
}
@@ -282,7 +282,7 @@ Filerange text_object_indentation(Text *txt, size_t pos) {
size_t start = bol;
size_t end = text_line_next(txt, bol);
size_t line_indent = sol - bol;
- bool line_empty = text_byte_get(txt, bol, &c) && (c == '\r' || c == '\n');
+ bool line_empty = text_char_get(txt, bol, &c) && c == '\n';
char *buf = text_bytes_alloc0(txt, bol, line_indent);
char *tmp = malloc(line_indent);
@@ -298,7 +298,7 @@ Filerange text_object_indentation(Text *txt, size_t pos) {
size_t indent = sol - bol;
if (indent < line_indent)
break;
- bool empty = text_byte_get(txt, bol, &c) && (c == '\r' || c == '\n');
+ bool empty = text_char_get(txt, bol, &c) && c == '\n';
if (line_empty && !empty)
break;
if (line_indent == 0 && empty)
@@ -315,7 +315,7 @@ Filerange text_object_indentation(Text *txt, size_t pos) {
size_t indent = sol - bol;
if (indent < line_indent)
break;
- bool empty = text_byte_get(txt, bol, &c) && (c == '\r' || c == '\n');
+ bool empty = text_char_get(txt, bol, &c) && c == '\n';
if (line_empty && !empty)
break;
if (line_indent == 0 && empty)