summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-11-16 12:18:27 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-11-16 12:18:27 -0600
commit1c26117dff1292fea8c3b15b1892c6bc751b83b6 (patch)
tree14ab0e1e34b27fe4212c8a2a801be94075dfed78 /main
parent24d35ff74afe92bc83134fcf764656a60777d732 (diff)
parent72da2ef9ffb49a1fc550ec91caa1468e285f87e0 (diff)
Merge "cli: Fix ast_el_read_char to work with libedit >= 3.1"
Diffstat (limited to 'main')
-rw-r--r--main/asterisk.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index be6c7cc32..4a6567f73 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2691,7 +2691,11 @@ static void send_rasterisk_connect_commands(void)
}
}
+#ifdef HAVE_LIBEDIT_IS_UNICODE
+static int ast_el_read_char(EditLine *editline, wchar_t *cp)
+#else
static int ast_el_read_char(EditLine *editline, char *cp)
+#endif
{
int num_read = 0;
int lastpos = 0;
@@ -2721,10 +2725,16 @@ static int ast_el_read_char(EditLine *editline, char *cp)
}
if (!ast_opt_exec && fds[1].revents) {
- num_read = read(STDIN_FILENO, cp, 1);
+ char c = '\0';
+ num_read = read(STDIN_FILENO, &c, 1);
if (num_read < 1) {
break;
} else {
+#ifdef HAVE_LIBEDIT_IS_UNICODE
+ *cp = btowc(c);
+#else
+ *cp = c;
+#endif
return (num_read);
}
}
@@ -2768,7 +2778,11 @@ static int ast_el_read_char(EditLine *editline, char *cp)
console_print(buf);
if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (res >= 2 && buf[res-2] == '\n'))) {
+#ifdef HAVE_LIBEDIT_IS_UNICODE
+ *cp = btowc(CC_REFRESH);
+#else
*cp = CC_REFRESH;
+#endif
return(1);
} else {
lastpos = 1;
@@ -2776,7 +2790,12 @@ static int ast_el_read_char(EditLine *editline, char *cp)
}
}
+#ifdef HAVE_LIBEDIT_IS_UNICODE
+ *cp = btowc('\0');
+#else
*cp = '\0';
+#endif
+
return (0);
}