Skip to content

Commit 9bbee6a

Browse files
committed
Fix conversions between char and int
1 parent 93b2db9 commit 9bbee6a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

linenoise.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static int completeLine(struct linenoiseState *ls, int keypressed) {
435435
}
436436

437437
freeCompletions(&lc);
438-
return c; /* Return last read character */
438+
return (unsigned char)c; /* Return last read character */
439439
}
440440

441441
/* Register a callback function to be called for tab-completion. */
@@ -931,6 +931,7 @@ char *linenoiseEditFeed(struct linenoiseState *l) {
931931

932932
char c;
933933
int nread;
934+
int ret;
934935
char seq[3];
935936

936937
nread = read(l->ifd,&c,1);
@@ -940,11 +941,12 @@ char *linenoiseEditFeed(struct linenoiseState *l) {
940941
* there was an error reading from fd. Otherwise it will return the
941942
* character that should be handled next. */
942943
if ((l->in_completion || c == 9) && completionCallback != NULL) {
943-
c = completeLine(l,c);
944+
ret = completeLine(l,(unsigned char)c);
944945
/* Return on errors */
945-
if (c < 0) return NULL;
946+
if (ret < 0) return NULL;
946947
/* Read next character when 0 */
947-
if (c == 0) return linenoiseEditMore;
948+
if (ret == 0) return linenoiseEditMore;
949+
c = (char)ret;
948950
}
949951

950952
switch(c) {

0 commit comments

Comments
 (0)