[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "info --vi-keys foo" inciting a segfault in info
From: |
Colin Watson |
Subject: |
Re: "info --vi-keys foo" inciting a segfault in info |
Date: |
Sun, 26 Aug 2001 22:46:50 +0100 |
User-agent: |
Mutt/1.2.5i |
On Sun, Aug 26, 2001 at 02:50:03PM +0300, Eli Zaretskii wrote:
> On Tue, 14 Aug 2001, Colin Watson wrote:
> > (gdb) frame
> > #2 0x08051221 in where_is_internal (map=0x40634800,
> > function=0x805c004 <info_move_to_window_line>) at infodoc.c:793
> > 793 sprintf (where_is_rep + where_is_rep_index, "%s ",
> > (gdb) p where_is_rep
> > $4 = 0x40590f9c "ESC ESC C-x C-x C-x C-x ESC ESC C-x C-x C-x C-x C-x ESC
> > ESC C-x C-x ESC C-x ESC ESC C-x ESC ESC [ 3 "
> > (gdb) p where_is_rep_index
> > $5 = 98
>
> How did you come up with such a monstrous escape sequence?
I just followed the procedure in the bug report - 'info --vi-keys
libc:exit', then hit 'h'. The escape sequence it's currently looking at
(judging from the stack) is actually just 'ESC ESC [ 3'.
> Also, how come info_move_to_window_line has a key binding under
> --vi-keys? I don't seem to see that in Texinfo 4.0b's vi-like keymap
> (see infomap.c).
Nor do I ...
> Anyway, I think the following changes should fix this; please try:
>
> 2001-08-26 Eli Zaretskii <address@hidden>
>
> * info/infodoc.c (where_is_make_room): New function.
> (where_is, where_is_internal): Use it to reallocate where_is_rep
> if there's not enough room in it to put the printed representation
> of a key.
Unfortunately not, sorry - that made no difference.
Noticing that where_is_rep_index isn't always reset when (I think) it
should be, that is each time where_is_internal() is called from
create_internal_info_help_node(), this patch cured the segfault for me.
However, I may be hiding some problems with the vi-like keymap in the
process.
Speaking of which, 'h' is normally backward and 'l' forward in vi rather
than the other way round.
How about this patch?
2001-08-26 Colin Watson <address@hidden>
* info/infodoc.c (where_is_no_mx): New function, split from
where_is.
(create_internal_info_help_node): Use it to ensure that
where_is_rep_index is reset each time we start to generate the
printed representation of a key.
* info/infomap.c (initialize_vi_like_keymaps): Exchange
functions of ESC-h and ESC-l in echo area.
--- info/infodoc.c.orig Sun Aug 26 21:21:40 2001
+++ info/infodoc.c Sun Aug 26 22:09:12 2001
@@ -133,7 +133,7 @@ static char *info_help_keys_text[][2] =
NULL
};
-static char *where_is (), *where_is_internal ();
+static char *where_is (), *where_is_no_mx (), *where_is_internal ();
void
dump_map_to_message_buffer (prefix, map)
@@ -270,8 +270,8 @@ create_internal_info_help_node (help_is_
{
VFunction *func = function_doc_array[i].func;
- if ((!where_is_internal (info_keymap, func)) &&
- (!where_is_internal (echo_area_keymap, func)))
+ if ((!where_is_no_mx (info_keymap, func)) &&
+ (!where_is_no_mx (echo_area_keymap, func)))
{
if (!printed_one_mx)
{
@@ -752,17 +752,23 @@ where_is_make_room (offset, size)
}
static char *
-where_is (map, function)
+where_is_no_mx (map, function)
Keymap map;
VFunction *function;
{
- char *rep;
-
if (!where_is_rep_size)
where_is_rep = (char *)xmalloc (where_is_rep_size = 100);
where_is_rep_index = 0;
- rep = where_is_internal (map, function);
+ return where_is_internal (map, function);
+}
+
+static char *
+where_is (map, function)
+ Keymap map;
+ VFunction *function;
+{
+ char *rep = where_is_no_mx (map, function);
/* If it couldn't be found, return "M-x Foo". */
if (!rep)
--- info/infomap.c.orig Sun Aug 26 22:19:08 2001
+++ info/infomap.c Sun Aug 26 22:21:19 2001
@@ -476,8 +476,8 @@ initialize_vi_like_keymaps ()
map['b'].function = ea_backward_word;
map['d'].function = ea_kill_word;
map['f'].function = ea_forward_word;
- map['h'].function = ea_forward;
- map['l'].function = ea_backward;
+ map['h'].function = ea_backward;
+ map['l'].function = ea_forward;
map['w'].function = ea_forward_word;
map['x'].function = ea_delete;
map['X'].function = ea_kill_word;
Cheers,
--
Colin Watson address@hidden