]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/io_tty_process_input: remove a special case
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 16 Sep 2020 11:10:44 +0000 (13:10 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 2 Oct 2020 06:50:27 +0000 (08:50 +0200)
After changes in this MR, sending an empty newline evaluates in lua
as nil, and that seems fine.  Let's drop this piece of code;
it was broken now anyway (incorrect `io_mode_text` part).

daemon/io.c

index 4fb10c1b7c5ac907265a3f47f2cc4e69b9afa0f2..1e55134718226887048f24b5133baa857fa56354 100644 (file)
@@ -501,18 +501,6 @@ void io_tty_process_input(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu
        }
        commands[nread] = '\0';
 
-       const char *delim = args->quiet ? "" : "> ";
-
-       /* No command, just new line */
-       if (nread == 1 && (data->mode == io_mode_text) == false && commands[nread-1] == '\0' && data->blen == 0) {
-               if (stream_fd != STDIN_FILENO) {
-                       fprintf(out, "%s", delim);
-               }
-               if (stream_fd == STDIN_FILENO || VERBOSE_STATUS) {
-                       fprintf(stdout, "%s", delim);
-               }
-       }
-
        char *boundary = "\n\0";
        cmd = strtok(commands, "\n");
        /* strtok skip '\n' but we need process alone '\n' too */
@@ -576,7 +564,9 @@ void io_tty_process_input(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu
                        fwrite(message, len_s, 1, out);
                        goto next_iter;
                }
+
                /* Log to remote socket if connected */
+               const char *delim = args->quiet ? "" : "> ";
                if (stream_fd != STDIN_FILENO) {
                        if (VERBOSE_STATUS)
                                fprintf(stdout, "%s\n", cmd); /* Duplicate command to logs */