libbb/lineedit: restore ^D handling for unicode
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 28 Sep 2009 22:00:12 +0000 (00:00 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 28 Sep 2009 22:00:12 +0000 (00:00 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/lineedit.c

index 3689b4b5d306774f9eeb16e3dad3359327d0f8a1..9b112bccffc377e07dff5bcc9186f20bee1db16b 100644 (file)
@@ -114,8 +114,8 @@ struct lineedit_statics {
        unsigned cmdedit_prmt_len; /* length of prompt (without colors etc) */
 
        unsigned cursor;
-       unsigned command_len;
-       /* *int* maxsize: we want x in "if (x > S.maxsize)"
+       int command_len; /* must be signed */
+       /* signed maxsize: we want x in "if (x > S.maxsize)"
         * to _not_ be promoted to unsigned */
        int maxsize;
        CHAR_T *command_ps;
@@ -2124,7 +2124,9 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
 #undef command
 
 #if ENABLE_FEATURE_ASSUME_UNICODE
-       command_len = save_string(command, maxsize - 1);
+       command[0] = '\0';
+       if (command_len > 0)
+               command_len = save_string(command, maxsize - 1);
        free(command_ps);
 #endif