bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

3 small overwrite-mode bugs


From: jimmy
Subject: 3 small overwrite-mode bugs
Date: 3 Jan 2003 08:00:46 -0000

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib  -g -O2
uname output: Linux ns 2.2.22 #1 Wed Nov 6 12:23:08 EET 2002 i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:

1. After undoing an overwrite-mode self-insert, the cursor is
   positioned on the right of the character restored, not on it.

2. overwrite-mode self-insert with argument is being undone
   character-by-character.

3. overwrite-mode rubout replaces the characters with spaces
   even if the cursor is at end-of-line. When doing overwrite-mode
   self-insert and the cursor is at eoln, it acts as insert-mode
   self-insert because there are no characters to be replaced; so,
   for compliance, overwrite-mode rubout should act as insert-mode
   rubout when executed if eoln. Moreover, there is no point in
   inserting such [trailing] spaces, they are ignored anyway.

Repeat-By:

1. Undo an overwrite-mode self-insert.
2. Undo an overwrite-mode self-insert with argument >= 2.
3. Do rubout in overwrite-mode at eoln.

Fix:

1. Do the _rl_insert_char or rl_insert_text first, rl_delete
   next. The cost is a few bytes more peak memory use.

2. Invoke begin_undo_group before the overwrite character
   loop and end_undo_group after the loop.

3. Only do _rl_insert_char if rl_point < rl_end (note: moving
   the cursor back invalidates this test, but deleting the text up
   to the starting point revalidates it).

diff -Nru3 bash-2.05b/lib/readline/text.c bash/lib/readline/text.c
--- bash-2.05b/lib/readline/text.c      2002-05-30 20:46:13.000000000 +0300
+++ bash/lib/readline/text.c    2002-12-21 09:02:22.000000000 +0200
@@ -801,13 +801,10 @@
     k = _rl_read_mbstring (c, mbkey, MB_LEN_MAX);
 #endif
 
+  rl_begin_undo_group ();
+
   for (i = 0; i < count; i++)
     {
-      rl_begin_undo_group ();
-
-      if (rl_point < rl_end)
-       rl_delete (1, c);
-
 #if defined (HANDLE_MULTIBYTE)
       if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
        rl_insert_text (mbkey);
@@ -815,9 +812,13 @@
 #endif
        _rl_insert_char (1, c);
 
-      rl_end_undo_group ();
+      if (rl_point < rl_end)
+       rl_delete (1, c);
+
     }
 
+  rl_end_undo_group ();
+
   return 0;
 }
 
@@ -934,10 +935,13 @@
   else
     rl_delete_text (opoint, rl_point);
 
-  /* Emacs puts point at the beginning of the sequence of spaces. */
-  opoint = rl_point;
-  _rl_insert_char (l, ' ');
-  rl_point = opoint;
+  if (rl_point < rl_end)
+    {
+      /* Emacs puts point at the beginning of the sequence of spaces. */
+      opoint = rl_point;
+      _rl_insert_char (l, ' ');
+      rl_point = opoint;
+    }
 
   rl_end_undo_group ();
 
--- cut here

Note:

These are readline-4.3 bugs and should be fixed in readline as well.

E-gards: Jimmy





reply via email to

[Prev in Thread] Current Thread [Next in Thread]