summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Waters <gwatersdev@gmail.com>2020-08-02 21:41:23 -0400
committerGeorge Waters <gwatersdev@gmail.com>2020-08-09 13:14:02 -0400
commit41ccbbd4e92437a5d4153759e244067a869da277 (patch)
tree3eebfbf1dec29e38445bf872b3c153f599d5fd1d
parent71ce480dbbf8999b964214a5465640ffa038a0c2 (diff)
Fix failed unix build
-rw-r--r--lib/mp-readline/readline.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/mp-readline/readline.c b/lib/mp-readline/readline.c
index 042694162..070fb8676 100644
--- a/lib/mp-readline/readline.c
+++ b/lib/mp-readline/readline.c
@@ -58,6 +58,14 @@ STATIC char *str_dup_maybe(const char *str) {
return s2;
}
+STATIC int count_cont_bytes(char *start, char *end) {
+ int count = 0;
+ for (char *pos = start; pos < end; pos++) {
+ count += UTF8_IS_CONT(*pos);
+ }
+ return count;
+}
+
// By default assume terminal which implements VT100 commands...
#ifndef MICROPY_HAL_HAS_VT100
#define MICROPY_HAL_HAS_VT100 (1)
@@ -99,14 +107,6 @@ typedef struct _readline_t {
STATIC readline_t rl;
-int readline_count_cont_byte(char *start, char *end) {
- int count = 0;
- for (char *pos = start; pos < end; pos++) {
- count += UTF8_IS_CONT(*pos);
- }
- return count;
-}
-
int readline_process_char(int c) {
size_t last_line_len = rl.line->len;
int cont_chars = 0;
@@ -275,7 +275,7 @@ up_arrow_key:
// up arrow
if (rl.hist_cur + 1 < (int)READLINE_HIST_SIZE && MP_STATE_PORT(readline_hist)[rl.hist_cur + 1] != NULL) {
// Check for continuation characters through the cursor_pos
- cont_chars = readline_count_cont_byte(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
+ cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
// increase hist num
rl.hist_cur += 1;
// set line to history
@@ -293,7 +293,7 @@ down_arrow_key:
// down arrow
if (rl.hist_cur >= 0) {
// Check for continuation characters through the cursor_pos
- cont_chars = readline_count_cont_byte(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
+ cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
// decrease hist num
rl.hist_cur -= 1;
// set line to history
@@ -391,7 +391,7 @@ delete_key:
mp_hal_erase_line_from_cursor(last_line_len - rl.cursor_pos);
}
// Check for continuation characters from the new cursor_pos to the EOL
- cont_chars = readline_count_cont_byte(rl.line->buf+rl.cursor_pos+redraw_step_forward, rl.line->buf+rl.line->len);
+ cont_chars = count_cont_bytes(rl.line->buf+rl.cursor_pos+redraw_step_forward, rl.line->buf+rl.line->len);
// draw new chars
mp_hal_stdout_tx_strn(rl.line->buf + rl.cursor_pos, rl.line->len - rl.cursor_pos);
// move cursor forward if needed (already moved forward by length of line, so move it back)