Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conversions between char and int #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -931,6 +931,7 @@ char *linenoiseEditFeed(struct linenoiseState *l) {

char c;
int nread;
int ret;
char seq[3];

nread = read(l->ifd,&c,1);
Expand All @@ -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) {
Expand Down