lineedit: don't violate API if we do simple fgets
authorDenis Vlasenko <vda.linux@googlemail.com>
Sun, 9 Dec 2007 10:03:28 +0000 (10:03 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Sun, 9 Dec 2007 10:03:28 +0000 (10:03 -0000)
ash: cosmetic style fixes, no code changes

libbb/lineedit.c
shell/ash.c

index 1397409ccb9bba16d514689ecec803311b4becc3..a0f190fd4b055feaabf30009be6019b67e57e31a 100644 (file)
@@ -1343,8 +1343,10 @@ int read_line_input(const char *prompt, char *command, int maxsize, line_input_t
                int len;
                parse_and_put_prompt(prompt);
                fflush(stdout);
-               fgets(command, maxsize, stdin);
-               len = strlen(command);
+               if (fgets(command, maxsize, stdin) == NULL)
+                       len = -1; /* EOF or error */
+               else
+                       len = strlen(command);
                DEINIT_S();
                return len;
        }
index 9b9fe5b6db1604ad6437f2833c01bec469deef95..4c8a28911e596534bb20d5f93d600219be6640bd 100644 (file)
@@ -8553,7 +8553,7 @@ preadfd(void)
                        goto retry;
                }
                if (nr < 0 && errno == 0) {
-                       /* Ctrl+D presend */
+                       /* Ctrl+D pressed */
                        nr = 0;
                }
        }
@@ -8564,8 +8564,8 @@ preadfd(void)
        if (nr < 0) {
                if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
                        int flags = fcntl(0, F_GETFL);
-                       if (flags >= 0 && flags & O_NONBLOCK) {
-                               flags &=O_NONBLOCK;
+                       if (flags >= 0 && (flags & O_NONBLOCK)) {
+                               flags &= ~O_NONBLOCK;
                                if (fcntl(0, F_SETFL, flags) >= 0) {
                                        out2str("sh: turning off NDELAY mode\n");
                                        goto retry;