From 9bbee6a8ac52b2c822d252e55bccb84396fd6aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20D=C3=B8rum?= Date: Tue, 11 Apr 2023 11:01:02 +0200 Subject: [PATCH] Fix conversions between char and int --- linenoise.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linenoise.c b/linenoise.c index 5e8aee57..a7cbc340 100644 --- a/linenoise.c +++ b/linenoise.c @@ -435,7 +435,7 @@ static int completeLine(struct linenoiseState *ls, int keypressed) { } freeCompletions(&lc); - return c; /* Return last read character */ + return (unsigned char)c; /* Return last read character */ } /* Register a callback function to be called for tab-completion. */ @@ -931,6 +931,7 @@ char *linenoiseEditFeed(struct linenoiseState *l) { char c; int nread; + int ret; char seq[3]; nread = read(l->ifd,&c,1); @@ -940,11 +941,12 @@ char *linenoiseEditFeed(struct linenoiseState *l) { * there was an error reading from fd. Otherwise it will return the * character that should be handled next. */ if ((l->in_completion || c == 9) && completionCallback != NULL) { - c = completeLine(l,c); + ret = completeLine(l,(unsigned char)c); /* Return on errors */ - if (c < 0) return NULL; + if (ret < 0) return NULL; /* Read next character when 0 */ - if (c == 0) return linenoiseEditMore; + if (ret == 0) return linenoiseEditMore; + c = (char)ret; } switch(c) {