mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
lineedit: don't violate API if we do simple fgets
ash: cosmetic style fixes, no code changes
This commit is contained in:
parent
a96425fe82
commit
9cb220be9d
@ -1343,8 +1343,10 @@ int read_line_input(const char *prompt, char *command, int maxsize, line_input_t
|
|||||||
int len;
|
int len;
|
||||||
parse_and_put_prompt(prompt);
|
parse_and_put_prompt(prompt);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fgets(command, maxsize, stdin);
|
if (fgets(command, maxsize, stdin) == NULL)
|
||||||
len = strlen(command);
|
len = -1; /* EOF or error */
|
||||||
|
else
|
||||||
|
len = strlen(command);
|
||||||
DEINIT_S();
|
DEINIT_S();
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -8553,7 +8553,7 @@ preadfd(void)
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
if (nr < 0 && errno == 0) {
|
if (nr < 0 && errno == 0) {
|
||||||
/* Ctrl+D presend */
|
/* Ctrl+D pressed */
|
||||||
nr = 0;
|
nr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8564,8 +8564,8 @@ preadfd(void)
|
|||||||
if (nr < 0) {
|
if (nr < 0) {
|
||||||
if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
|
if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
|
||||||
int flags = fcntl(0, F_GETFL);
|
int flags = fcntl(0, F_GETFL);
|
||||||
if (flags >= 0 && flags & O_NONBLOCK) {
|
if (flags >= 0 && (flags & O_NONBLOCK)) {
|
||||||
flags &=~ O_NONBLOCK;
|
flags &= ~O_NONBLOCK;
|
||||||
if (fcntl(0, F_SETFL, flags) >= 0) {
|
if (fcntl(0, F_SETFL, flags) >= 0) {
|
||||||
out2str("sh: turning off NDELAY mode\n");
|
out2str("sh: turning off NDELAY mode\n");
|
||||||
goto retry;
|
goto retry;
|
||||||
|
Loading…
Reference in New Issue
Block a user