Scrub pwd.h and grp.h handling so we don't have to play any
[oweals/busybox.git] / shell / cmdedit.c
index d57e4c12bb085794b002768b34d58ad519bd8a13..c5f2e9da2e7e66d322cfad57169807eccd0c8db0 100644 (file)
@@ -82,7 +82,7 @@
 
 #ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
 #       ifndef TEST
-#               include "pwd.h"
+#               include "pwd_.h"
 #       else
 #               include <pwd.h>
 #       endif  /* TEST */
@@ -207,7 +207,8 @@ static void cmdedit_reset_term(void)
                handlers_sets &= ~SET_WCHG_HANDLERS;
        }
        fflush(stdout);
-#ifdef CONFIG_FEATURE_CLEAN_UP
+#if 0
+//#ifdef CONFIG_FEATURE_CLEAN_UP
        if (his_front) {
                struct history *n;
 
@@ -769,7 +770,7 @@ static char **exe_n_cwd_tab_completion(char *command, int *num_matches,
                                        goto cont;
                                str_found = add_quote_for_spec_chars(found);
                                if (type == FIND_FILE_ONLY ||
-                                       (type == FIND_EXE_ONLY && is_execute(&st) == TRUE))
+                                       (type == FIND_EXE_ONLY && is_execute(&st)))
                                        strcat(str_found, " ");
                        }
                        /* Add it to the list */
@@ -799,8 +800,8 @@ static int match_compare(const void *a, const void *b)
 #define QUOT    (UCHAR_MAX+1)
 
 #define collapse_pos(is, in) { \
-       memcpy(int_buf+is, int_buf+in, (BUFSIZ+1-is-in)*sizeof(int)); \
-       memcpy(pos_buf+is, pos_buf+in, (BUFSIZ+1-is-in)*sizeof(int)); }
+       memcpy(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
+       memcpy(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
 
 static int find_match(char *matchBuf, int *len_with_quotes)
 {
@@ -980,7 +981,7 @@ static void input_tab(int *lastWasTab)
                }
                return;
        }
-       if (*lastWasTab == FALSE) {
+       if (! *lastWasTab) {
 
                char *tmp;
                int len_found;
@@ -1263,6 +1264,20 @@ prepare_to_die:
                        input_tab(&lastWasTab);
 #endif
                        break;
+               case 11:
+                       /* Control-k -- clear to end of line */  
+                       *(command + cursor) = 0;
+                       len = cursor;
+                       printf("\033[J");
+                       break;
+               case 12: 
+                       {
+                               /* Control-l -- clear screen */
+                               int old_cursor = cursor;
+                               printf("\033[H");
+                               redraw(0, len-old_cursor);
+                       }
+                       break;
                case 14:
                        /* Control-n -- Get next command in history */
                        if (hp && hp->n && hp->n->s) {
@@ -1288,7 +1303,6 @@ prepare_to_die:
                                redraw(cmdedit_y, len -= cursor);
                        }
                        break;
-
                case ESC:{
                        /* escape sequence follows */
                        if (safe_read(0, &c, 1) < 1)