]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
commit readline-20150807 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 10 Aug 2015 13:38:01 +0000 (09:38 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 10 Aug 2015 13:38:01 +0000 (09:38 -0400)
12 files changed:
colors.c
colors.h
complete.c
examples/fileman.c
examples/rl.c
examples/rlbasic.c
examples/rlversion.c
readline.c
readline.h
rlprivate.h
search.c
vi_mode.c

index 963dc12e65dc117fd13176289dd57524e28245a0..d4bcb32ed7caeda527e823492dc2937242bea06a 100644 (file)
--- a/colors.c
+++ b/colors.c
@@ -120,7 +120,7 @@ _rl_print_prefix_color (void)
   
 /* Returns whether any color sequence was printed. */
 bool
-_rl_print_color_indicator (char *f)
+_rl_print_color_indicator (const char *f)
 {
   enum indicator_no colored_filetype;
   COLOR_EXT_TYPE *ext; /* Color extension */
index 5c77af9d42104661c035bfd549f29ea478a41f72..ec627747d8e2e72c888f02f8169880217fb9b5e3 100644 (file)
--- a/colors.h
+++ b/colors.h
@@ -120,7 +120,7 @@ enum filetype
 extern void _rl_put_indicator (const struct bin_str *ind);
 extern void _rl_set_normal_color (void);
 extern bool _rl_print_prefix_color (void);
-extern bool _rl_print_color_indicator (char *f);
+extern bool _rl_print_color_indicator (const char *f);
 extern void _rl_prep_non_filename_text (void);
 
 #endif /* !_COLORS_H_ */
index f905c09f6944993d662d95361f06c825c433e882..d0bbe7df7b74b5357b0be23d8341fbb7f080277a 100644 (file)
@@ -111,7 +111,7 @@ static int stat_char PARAMS((char *));
 #endif
 
 #if defined (COLOR_SUPPORT)
-static int colored_stat_start PARAMS((char *));
+static int colored_stat_start PARAMS((const char *));
 static void colored_stat_end PARAMS((void));
 static int colored_prefix_start PARAMS((void));
 static void colored_prefix_end PARAMS((void));
@@ -676,7 +676,7 @@ stat_char (filename)
 #if defined (COLOR_SUPPORT)
 static int
 colored_stat_start (filename)
-     char *filename;
+     const char *filename;
 {
   _rl_set_normal_color ();
   return (_rl_print_color_indicator (filename));
index f7eed8a982fdf86f54822fcffdc28acee4cfb98b..c821df033aa8b42702d016bc767f66d4f676d1f8 100644 (file)
 
 extern char *xmalloc PARAMS((size_t));
 
+void initialize_readline PARAMS((void));
+void too_dangerous PARAMS((char *));
+
+int execute_line PARAMS((char *));
+int valid_argument PARAMS((char *, char *));
+
 /* The names of functions that actually do the manipulation. */
 int com_list PARAMS((char *));
 int com_view PARAMS((char *));
@@ -119,6 +125,7 @@ dupstr (s)
   return (r);
 }
 
+int
 main (argc, argv)
      int argc;
      char **argv;
@@ -241,6 +248,7 @@ char **fileman_completion PARAMS((const char *, int, int));
 /* Tell the GNU Readline library how to complete.  We want to try to complete
    on command names if this is the first word in the line, or on filenames
    if not. */
+void
 initialize_readline ()
 {
   /* Allow conditional parsing of the ~/.inputrc file. */
@@ -317,6 +325,7 @@ command_generator (text, state)
 static char syscom[1024];
 
 /* List the file(s) named in arg. */
+int
 com_list (arg)
      char *arg;
 {
@@ -327,6 +336,7 @@ com_list (arg)
   return (system (syscom));
 }
 
+int
 com_view (arg)
      char *arg;
 {
@@ -342,6 +352,7 @@ com_view (arg)
   return (system (syscom));
 }
 
+int
 com_rename (arg)
      char *arg;
 {
@@ -349,6 +360,7 @@ com_rename (arg)
   return (1);
 }
 
+int
 com_stat (arg)
      char *arg;
 {
@@ -377,6 +389,7 @@ com_stat (arg)
   return (0);
 }
 
+int
 com_delete (arg)
      char *arg;
 {
@@ -386,6 +399,7 @@ com_delete (arg)
 
 /* Print out help for ARG, or for all of the commands if ARG is
    not present. */
+int
 com_help (arg)
      char *arg;
 {
@@ -425,6 +439,7 @@ com_help (arg)
 }
 
 /* Change to the directory ARG. */
+int
 com_cd (arg)
      char *arg;
 {
@@ -439,6 +454,7 @@ com_cd (arg)
 }
 
 /* Print out the current working directory. */
+int
 com_pwd (ignore)
      char *ignore;
 {
@@ -456,6 +472,7 @@ com_pwd (ignore)
 }
 
 /* The user wishes to quit using this program.  Just set DONE non-zero. */
+int
 com_quit (arg)
      char *arg;
 {
@@ -464,6 +481,7 @@ com_quit (arg)
 }
 
 /* Function which tells you that you can't do this. */
+void
 too_dangerous (caller)
      char *caller;
 {
index 845a4b176d74ae7539c4b89347266ae2db5bc7b2..a5cf276cb943afcf88a12691c2d7c160dcb11262 100644 (file)
@@ -28,6 +28,7 @@
 #  include <config.h>
 #endif
 
+#include <unistd.h>
 #include <stdio.h>
 #include <sys/types.h>
 
index 8fc66abdef3d9b9ddb472440a4212de973d9c2a4..6a9601f52a699caa033273abf85e9689406ad07a 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
+#include <string.h>
 
 #if defined (READLINE_LIBRARY)
 #  include "readline.h"
index 88f4cd7fe4fd75ad239e6190691dfd0e61830705..f36567becf463b1c587fce0b327569493fa083f9 100644 (file)
@@ -41,6 +41,7 @@ extern void exit();
 #  include <readline/readline.h>
 #endif
 
+int
 main()
 {
        printf ("%s\n", rl_library_version ? rl_library_version : "unknown");
index ce72501d4b43f79e4ab9cee4978cfd8edb218935..71f666ce3e1e9f97196325cca3f4e9ca246bab5f 100644 (file)
@@ -930,6 +930,16 @@ _rl_dispatch_subseq (key, map, got_subseq)
          /* Allocate new context here.  Use linked contexts (linked through
             cxt->ocxt) to simulate recursion */
 #if defined (READLINE_CALLBACKS)
+#  if defined (VI_MODE)
+         /* If we're redoing a vi mode command and we know there is a shadowed
+            function corresponding to this key, just call it -- all the redoable
+            vi mode commands already have all the input they need, and rl_vi_redo
+            assumes that one call to rl_dispatch is sufficient to complete the
+            command. */
+         if (_rl_vi_redoing && RL_ISSTATE (RL_STATE_CALLBACK) &&
+             map[ANYOTHERKEY].function != 0)
+           return (_rl_subseq_result (-2, map, key, got_subseq));
+#  endif
          if (RL_ISSTATE (RL_STATE_CALLBACK))
            {
              /* Return 0 only the first time, to indicate success to
@@ -992,6 +1002,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
        }
       break;
     }
+
 #if defined (VI_MODE)
   if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
       key != ANYOTHERKEY &&
@@ -1037,7 +1048,9 @@ _rl_subseq_result (r, map, key, got_subseq)
 
          m[key].type = type;
          m[key].function = func;
-         r = _rl_dispatch (key, m);
+         /* Don't change _rl_dispatching_keymap, set it here */
+         _rl_dispatching_keymap = map;         /* previous map */
+         r = _rl_dispatch_subseq (key, m, 0);
          m[key].type = nt;
          m[key].function = nf;
        }
index 8d71f9a7d0b27c818b0044d852fc0c2f68c8cb76..6b63ae4b23d72a120011aa5d75af8faa91ddc002 100644 (file)
@@ -873,7 +873,7 @@ extern int rl_inhibit_completion;
 #define RL_STATE_CHARSEARCH    0x0800000       /* vi mode char search */
 #define RL_STATE_REDISPLAYING  0x1000000       /* updating terminal display */
 
-#define RL_STATE_DONE          0x1000000       /* done; accepted line */
+#define RL_STATE_DONE          0x2000000       /* done; accepted line */
 
 #define RL_SETSTATE(x)         (rl_readline_state |= (x))
 #define RL_UNSETSTATE(x)       (rl_readline_state &= ~(x))
index 8064f9ffb702e76cec3d39b5b452abadd986de63..fb3644ea0877c599f59abcdfcf87e72ef5330531 100644 (file)
@@ -558,6 +558,7 @@ extern int _rl_undo_group_level;
 
 /* vi_mode.c */
 extern int _rl_vi_last_command;
+extern int _rl_vi_redoing;
 extern _rl_vimotion_cxt *_rl_vimvcxt;
 
 #endif /* _RL_PRIVATE_H_ */
index c9bc6b1c3261a2284ff98fd9e14263bb4fbbe2b7..cf2ae8f7fdc9a61043e754fc25a30b043ebf46a0 100644 (file)
--- a/search.c
+++ b/search.c
@@ -58,7 +58,7 @@ _rl_search_cxt *_rl_nscxt = 0;
 extern HIST_ENTRY *_rl_saved_line_for_history;
 
 /* Functions imported from the rest of the library. */
-extern int _rl_free_history_entry PARAMS((HIST_ENTRY *));
+extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
 
 static char *noninc_search_string = (char *) NULL;
 static int noninc_history_pos;
index dcde2fbd01fda10a4e666d790221ec2a3fa5a348..f4cce5db4405df3aa4c214fff47069ad9b880f1f 100644 (file)
--- a/vi_mode.c
+++ b/vi_mode.c
@@ -67,6 +67,9 @@ int _rl_vi_last_command = 'i';        /* default `.' puts you in insert mode */
 
 _rl_vimotion_cxt *_rl_vimvcxt = 0;
 
+/* Non-zero indicates we are redoing a vi-mode command with `.' */
+int _rl_vi_redoing;
+
 /* Non-zero means enter insertion mode. */
 static int _rl_vi_doing_insert;
 
@@ -100,8 +103,6 @@ static int _rl_vi_last_replacement;
 
 static int _rl_vi_last_key_before_insert;
 
-static int vi_redoing;
-
 /* Text modification commands.  These are the `redoable' commands. */
 static const char * const vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
 
@@ -241,7 +242,7 @@ rl_vi_redo (count, c)
     }
 
   r = 0;
-  vi_redoing = 1;
+  _rl_vi_redoing = 1;
   /* If we're redoing an insert with `i', stuff in the inserted text
      and do not go into insertion mode. */
   if (_rl_vi_last_command == 'i' && vi_insert_buffer && *vi_insert_buffer)
@@ -287,7 +288,8 @@ rl_vi_redo (count, c)
     }
   else
     r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
-  vi_redoing = 0;
+
+  _rl_vi_redoing = 0;
 
   return (r);
 }
@@ -1335,12 +1337,12 @@ rl_vi_delete_to (count, key)
       _rl_vimvcxt->motion = '$';
       r = rl_domove_motion_callback (_rl_vimvcxt);
     }
-  else if (vi_redoing && _rl_vi_last_motion != 'd')    /* `dd' is special */
+  else if (_rl_vi_redoing && _rl_vi_last_motion != 'd')        /* `dd' is special */
     {
       _rl_vimvcxt->motion = _rl_vi_last_motion;
       r = rl_domove_motion_callback (_rl_vimvcxt);
     }
-  else if (vi_redoing)         /* handle redoing `dd' here */
+  else if (_rl_vi_redoing)             /* handle redoing `dd' here */
     {
       _rl_vimvcxt->motion = _rl_vi_last_motion;
       rl_mark = rl_end;
@@ -1385,7 +1387,7 @@ vi_change_dispatch (m)
   if ((_rl_to_upper (m->motion) == 'W') && rl_point < m->start)
     rl_point = m->start;
 
-  if (vi_redoing)
+  if (_rl_vi_redoing)
     {
       if (vi_insert_buffer && *vi_insert_buffer)
        rl_begin_undo_group ();
@@ -1425,12 +1427,12 @@ rl_vi_change_to (count, key)
       _rl_vimvcxt->motion = '$';
       r = rl_domove_motion_callback (_rl_vimvcxt);
     }
-  else if (vi_redoing && _rl_vi_last_motion != 'c')    /* `cc' is special */
+  else if (_rl_vi_redoing && _rl_vi_last_motion != 'c')        /* `cc' is special */
     {
       _rl_vimvcxt->motion = _rl_vi_last_motion;
       r = rl_domove_motion_callback (_rl_vimvcxt);
     }
-  else if (vi_redoing)         /* handle redoing `cc' here */
+  else if (_rl_vi_redoing)             /* handle redoing `cc' here */
     {
       _rl_vimvcxt->motion = _rl_vi_last_motion;
       rl_mark = rl_end;
@@ -1494,12 +1496,12 @@ rl_vi_yank_to (count, key)
       _rl_vimvcxt->motion = '$';
       r = rl_domove_motion_callback (_rl_vimvcxt);
     }
-  else if (vi_redoing && _rl_vi_last_motion != 'y')    /* `yy' is special */
+  else if (_rl_vi_redoing && _rl_vi_last_motion != 'y')        /* `yy' is special */
     {
       _rl_vimvcxt->motion = _rl_vi_last_motion;
       r = rl_domove_motion_callback (_rl_vimvcxt);
     }
-  else if (vi_redoing)                 /* handle redoing `yy' here */
+  else if (_rl_vi_redoing)                     /* handle redoing `yy' here */
     {
       _rl_vimvcxt->motion = _rl_vi_last_motion;
       rl_mark = rl_end;
@@ -1719,7 +1721,7 @@ rl_vi_char_search (count, key)
          break;
        }
 
-      if (vi_redoing)
+      if (_rl_vi_redoing)
        {
          /* set target and tlen below */
        }
@@ -1955,7 +1957,7 @@ rl_vi_change_char (count, key)
   int c;
   char mb[MB_LEN_MAX];
 
-  if (vi_redoing)
+  if (_rl_vi_redoing)
     {
       c = _rl_vi_last_replacement;
       mb[0] = c;
@@ -1983,7 +1985,7 @@ rl_vi_subst (count, key)
      int count, key;
 {
   /* If we are redoing, rl_vi_change_to will stuff the last motion char */
-  if (vi_redoing == 0)
+  if (_rl_vi_redoing == 0)
     rl_stuff_char ((key == 'S') ? 'c' : 'l');  /* `S' == `cc', `s' == `cl' */
 
   return (rl_vi_change_to (count, 'c'));