summaryrefslogtreecommitdiffstats
path: root/contrib/texinfo/info
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/texinfo/info')
-rw-r--r--contrib/texinfo/info/display.c25
-rw-r--r--contrib/texinfo/info/indices.c7
-rw-r--r--contrib/texinfo/info/info-utils.c25
-rw-r--r--contrib/texinfo/info/info-utils.h7
-rw-r--r--contrib/texinfo/info/info.c53
-rw-r--r--contrib/texinfo/info/info.h37
-rw-r--r--contrib/texinfo/info/infodoc.c12
-rw-r--r--contrib/texinfo/info/infokey.c25
-rw-r--r--contrib/texinfo/info/infomap.c8
-rw-r--r--contrib/texinfo/info/man.c8
-rw-r--r--contrib/texinfo/info/nodemenu.c8
-rw-r--r--contrib/texinfo/info/nodes.c35
-rw-r--r--contrib/texinfo/info/session.c139
-rw-r--r--contrib/texinfo/info/window.c8
14 files changed, 249 insertions, 148 deletions
diff --git a/contrib/texinfo/info/display.c b/contrib/texinfo/info/display.c
index aba4a4b..07fb3d5 100644
--- a/contrib/texinfo/info/display.c
+++ b/contrib/texinfo/info/display.c
@@ -1,7 +1,7 @@
/* display.c -- How to display Info windows.
- $Id: display.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: display.c,v 1.4 2003/05/13 16:20:44 karl Exp $
- Copyright (C) 1993, 97 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1997, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -136,7 +136,7 @@ display_update_one_window (win)
for (; nodetext < last_node_char; nodetext++)
{
- char *rep, *rep_carried_over, rep_temp[2];
+ char *rep = NULL, *rep_carried_over, rep_temp[2];
int replen;
if (isprint (*nodetext))
@@ -152,6 +152,15 @@ display_update_one_window (win)
{
replen = win->width - pl_index + pl_ignore;
}
+ else if (*nodetext == '\0'
+ && (nodetext + 1) < last_node_char
+ && *(nodetext + 1) == '\b')
+ {
+ /* Found new style image tag/cookie \0\b[ or \0\b]
+ Just skip for now. */
+ nodetext++;
+ continue;
+ }
else
{
rep = printed_representation (*nodetext, pl_index);
@@ -211,7 +220,7 @@ display_update_one_window (win)
to the next line. */
for (i = 0; pl_index < (win->width + pl_ignore - 1);)
printed_line[pl_index++] = rep[i++];
-
+
rep_carried_over = rep + i;
/* If printing the last character in this window couldn't
@@ -233,8 +242,10 @@ display_update_one_window (win)
entry = display[line_index + win->first_row];
/* If the screen line is inversed, then we have to clear
- the line from the screen first. Why, I don't know. */
- if (entry->inverse
+ the line from the screen first. Why, I don't know.
+ (But don't do this if we have no visible entries, as can
+ happen if the window is shrunk very small.) */
+ if ((entry && entry->inverse)
/* Need to erase the line if it has escape sequences. */
|| (raw_escapes_p && strchr (entry->text, '\033') != 0))
{
@@ -322,7 +333,7 @@ display_update_one_window (win)
printed_line[0] = '\0';
begin = nodetext;
-
+
while ((nodetext < last_node_char) && (*nodetext != '\n'))
nodetext++;
}
diff --git a/contrib/texinfo/info/indices.c b/contrib/texinfo/info/indices.c
index 4e3a3be..29cd2e2 100644
--- a/contrib/texinfo/info/indices.c
+++ b/contrib/texinfo/info/indices.c
@@ -1,7 +1,8 @@
/* indices.c -- deal with an Info file index.
- $Id: indices.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: indices.c,v 1.2 2003/02/11 16:39:06 karl Exp $
- Copyright (C) 1993, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1997, 1998, 1999, 2002, 2003 Free Software
+ Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -390,7 +391,7 @@ DECLARE_INFO_COMMAND (info_next_index_match,
/* Report to the user on what we have found. */
{
register int j;
- char *name = _("CAN'T SEE THIS");
+ const char *name = _("CAN'T SEE THIS");
char *match;
for (j = 0; index_nodenames[j]; j++)
diff --git a/contrib/texinfo/info/info-utils.c b/contrib/texinfo/info/info-utils.c
index 611ca15..d018cbd 100644
--- a/contrib/texinfo/info/info-utils.c
+++ b/contrib/texinfo/info/info-utils.c
@@ -1,7 +1,7 @@
/* info-utils.c -- miscellanous.
- $Id: info-utils.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: info-utils.c,v 1.2 2003/03/06 23:22:23 karl Exp $
- Copyright (C) 1993, 98 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1998, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -355,6 +355,27 @@ info_concatenate_references (ref1, ref2)
return (result);
}
+
+
+/* Copy a reference structure. Since we tend to free everything at
+ every opportunity, we don't share any points, but copy everything into
+ new memory. */
+REFERENCE *
+info_copy_reference (src)
+ REFERENCE *src;
+{
+ REFERENCE *dest = xmalloc (sizeof (REFERENCE));
+ dest->label = src->label ? xstrdup (src->label) : NULL;
+ dest->filename = src->filename ? xstrdup (src->filename) : NULL;
+ dest->nodename = src->nodename ? xstrdup (src->nodename) : NULL;
+ dest->start = src->start;
+ dest->end = src->end;
+
+ return dest;
+}
+
+
+
/* Free the data associated with REFERENCES. */
void
info_free_references (references)
diff --git a/contrib/texinfo/info/info-utils.h b/contrib/texinfo/info/info-utils.h
index 5475fda..6ff0581 100644
--- a/contrib/texinfo/info/info-utils.h
+++ b/contrib/texinfo/info/info-utils.h
@@ -1,7 +1,7 @@
/* info-utils.h -- Exported functions and variables from info-utils.c.
- $Id: info-utils.h,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: info-utils.h,v 1.2 2003/03/06 23:21:48 karl Exp $
- Copyright (C) 1993, 1996, 1998, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1996, 1998, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -83,6 +83,9 @@ extern REFERENCE **info_menu_items ();
and REF2 arrays are freed, but their contents are not. */
REFERENCE **info_concatenate_references ();
+/* Copy an existing reference into new memory. */
+extern REFERENCE *info_copy_reference ();
+
/* Free the data associated with REFERENCES. */
extern void info_free_references ();
diff --git a/contrib/texinfo/info/info.c b/contrib/texinfo/info/info.c
index 5d1be7f..5fceb74 100644
--- a/contrib/texinfo/info/info.c
+++ b/contrib/texinfo/info/info.c
@@ -1,5 +1,5 @@
/* info.c -- Display nodes of Info files in multiple windows.
- $Id: info.c,v 1.2 2003/01/19 18:45:59 karl Exp $
+ $Id: info.c,v 1.7 2003/05/19 13:10:59 karl Exp $
Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
@@ -120,16 +120,16 @@ static struct option long_options[] = {
/* String describing the shorthand versions of the long options found above. */
#ifdef __MSDOS__
-static char *short_options = "d:n:f:o:ORsb";
+static char *short_options = "d:n:f:ho:ORsb";
#else
-static char *short_options = "d:n:f:o:ORs";
+static char *short_options = "d:n:f:ho:ORs";
#endif
/* When non-zero, the Info window system has been initialized. */
int info_windows_initialized_p = 0;
/* Some "forward" declarations. */
-static void info_short_help (), remember_info_program_name ();
+static void info_short_help ();
static void init_messages ();
extern void add_file_directory_to_path ();
@@ -158,7 +158,7 @@ main (argc, argv)
textdomain (PACKAGE);
init_messages ();
-
+
while (1)
{
int option_character;
@@ -166,7 +166,7 @@ main (argc, argv)
option_character = getopt_long
(argc, argv, short_options, long_options, &getopt_long_index);
- /* getopt_long () returns EOF when there are no more long options. */
+ /* getopt_long returns EOF when there are no more long options. */
if (option_character == EOF)
break;
@@ -199,6 +199,11 @@ main (argc, argv)
user_filename = xstrdup (optarg);
break;
+ /* Treat -h like --help. */
+ case 'h':
+ print_help_p = 1;
+ break;
+
/* User is specifying the name of a file to output to. */
case 'o':
if (user_output_filename)
@@ -473,6 +478,8 @@ For more information about these matters, see the files named COPYING.\n"),
xexit (0);
}
+
+ return 0; /* Avoid bogus warnings. */
}
void
@@ -558,7 +565,7 @@ info_short_help ()
static const char speech_friendly_string[] = "";
#endif
-
+
printf (_("\
Usage: %s [OPTION]... [MENU-ITEM...]\n\
\n\
@@ -609,22 +616,22 @@ Texinfo home page: http://www.gnu.org/software/texinfo/"));
use them that way. This also has the advantage that there's only one
copy of the strings. */
-char *msg_cant_find_node;
-char *msg_cant_file_node;
-char *msg_cant_find_window;
-char *msg_cant_find_point;
-char *msg_cant_kill_last;
-char *msg_no_menu_node;
-char *msg_no_foot_node;
-char *msg_no_xref_node;
-char *msg_no_pointer;
-char *msg_unknown_command;
-char *msg_term_too_dumb;
-char *msg_at_node_bottom;
-char *msg_at_node_top;
-char *msg_one_window;
-char *msg_win_too_small;
-char *msg_cant_make_help;
+const char *msg_cant_find_node;
+const char *msg_cant_file_node;
+const char *msg_cant_find_window;
+const char *msg_cant_find_point;
+const char *msg_cant_kill_last;
+const char *msg_no_menu_node;
+const char *msg_no_foot_node;
+const char *msg_no_xref_node;
+const char *msg_no_pointer;
+const char *msg_unknown_command;
+const char *msg_term_too_dumb;
+const char *msg_at_node_bottom;
+const char *msg_at_node_top;
+const char *msg_one_window;
+const char *msg_win_too_small;
+const char *msg_cant_make_help;
static void
init_messages ()
diff --git a/contrib/texinfo/info/info.h b/contrib/texinfo/info/info.h
index 6e58b17..90b82e4 100644
--- a/contrib/texinfo/info/info.h
+++ b/contrib/texinfo/info/info.h
@@ -1,7 +1,8 @@
/* info.h -- Header file which includes all of the other headers.
- $Id: info.h,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: info.h,v 1.2 2003/02/11 16:39:06 karl Exp $
- Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003 Free Software
+ Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -128,22 +129,22 @@ extern int raw_escapes_p;
extern void info_error ();
/* Error message defines. */
-extern char *msg_cant_find_node;
-extern char *msg_cant_file_node;
-extern char *msg_cant_find_window;
-extern char *msg_cant_find_point;
-extern char *msg_cant_kill_last;
-extern char *msg_no_menu_node;
-extern char *msg_no_foot_node;
-extern char *msg_no_xref_node;
-extern char *msg_no_pointer;
-extern char *msg_unknown_command;
-extern char *msg_term_too_dumb;
-extern char *msg_at_node_bottom;
-extern char *msg_at_node_top;
-extern char *msg_one_window;
-extern char *msg_win_too_small;
-extern char *msg_cant_make_help;
+extern const char *msg_cant_find_node;
+extern const char *msg_cant_file_node;
+extern const char *msg_cant_find_window;
+extern const char *msg_cant_find_point;
+extern const char *msg_cant_kill_last;
+extern const char *msg_no_menu_node;
+extern const char *msg_no_foot_node;
+extern const char *msg_no_xref_node;
+extern const char *msg_no_pointer;
+extern const char *msg_unknown_command;
+extern const char *msg_term_too_dumb;
+extern const char *msg_at_node_bottom;
+extern const char *msg_at_node_top;
+extern const char *msg_one_window;
+extern const char *msg_win_too_small;
+extern const char *msg_cant_make_help;
extern char *filename_non_directory (); /* Found in info-utils.c. */
diff --git a/contrib/texinfo/info/infodoc.c b/contrib/texinfo/info/infodoc.c
index 830d8c0..5c25323 100644
--- a/contrib/texinfo/info/infodoc.c
+++ b/contrib/texinfo/info/infodoc.c
@@ -1,7 +1,7 @@
/* infodoc.c -- functions which build documentation nodes.
- $Id: infodoc.c,v 1.5 2002/11/06 00:40:08 karl Exp $
+ $Id: infodoc.c,v 1.6 2003/05/13 16:22:11 karl Exp $
- Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002 Free Software
+ Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -37,7 +37,7 @@ static NODE *internal_info_help_node = (NODE *)NULL;
static char *internal_info_help_node_contents = (char *)NULL;
/* The (more or less) static text which appears in the internal info
- help node. The actual key bindings are inserted. Keep the
+ help node. The actual key bindings are inserted. Keep the
underlines (****, etc.) in the same N_ call as the text lines they
refer to, so translations can make the number of *'s or -'s match. */
#if defined(INFOKEY)
@@ -300,7 +300,7 @@ create_internal_info_help_node (help_is_only_window_p)
? _(info_internal_help_text[i])
: info_internal_help_text[i];
char *key = info_help_keys_text[i][vi_keys_p];
-
+
/* If we have only one window (because the window size was too
small to split it), CTRL-x 0 doesn't work to `quit' help. */
if (STREQ (key, "CTRL-x 0") && help_is_only_window_p)
@@ -439,7 +439,7 @@ info_find_or_create_help_window ()
to quit help), true if help will be one of several visible windows
(so CTRL-x 0 must be used to quit help). */
help_is_only_window_p
- = (help_window && !windows->next
+ = ((help_window && !windows->next)
|| !help_window && eligible->height < HELP_SPLIT_SIZE);
create_internal_info_help_node (help_is_only_window_p);
@@ -1112,7 +1112,7 @@ where_is_internal (map, cmd)
where_is_internal without setting where_is_rep_index to zero. This
was found by Mandrake and reported by Thierry Vignaud
<tvignaud@mandrakesoft.com> around April 24, 2002.
-
+
I think the best fix is to make where_is_rep_index another
parameter to this recursively-called function, instead of a static
variable. But this [!INFOKEY] branch of the code is not enabled
diff --git a/contrib/texinfo/info/infokey.c b/contrib/texinfo/info/infokey.c
index f31c98a..4cb6518 100644
--- a/contrib/texinfo/info/infokey.c
+++ b/contrib/texinfo/info/infokey.c
@@ -1,5 +1,5 @@
/* infokey.c -- compile ~/.infokey to ~/.info.
- $Id: infokey.c,v 1.3 2003/01/19 18:46:27 karl Exp $
+ $Id: infokey.c,v 1.4 2003/05/13 16:26:02 karl Exp $
Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
@@ -86,7 +86,6 @@ main (argc, argv)
char **argv;
{
int getopt_long_index; /* Index returned by getopt_long (). */
- NODE *initial_node; /* First node loaded by Info. */
#ifdef HAVE_SETLOCALE
/* Set locale via LC_ALL. */
@@ -233,7 +232,7 @@ For more information about these matters, see the files named COPYING.\n"),
fclose (inf);
}
- xexit (0);
+ return 0;
}
static char *
@@ -289,18 +288,18 @@ mkpath (dir, file)
#info
#echo-area
#var
-
+
The sections may occur in any order. Each section may be
omitted completely. If the 'info' section is the first in the
file, its '#info' line may be omitted.
-
+
The 'info' and 'echo-area' sections
-----------------------------------
Each line in the 'info' or 'echo-area' sections has the
following syntax:
key-sequence SPACE action-name [ SPACE [ # comment ] ] \n
-
+
Where SPACE is one or more white space characters excluding
newline, "action-name" is the name of a GNU Info command,
"comment" is any sequence of characters excluding newline, and
@@ -319,7 +318,7 @@ mkpath (dir, file)
\r indicates a single CR;
\t indicates a single TAB;
\b indicates a single BACKSPACE;
-
+
4. \ku indicates the Up Arrow key;
\kd indicates the Down Arrow key;
\kl indicates the Left Arrow key;
@@ -345,17 +344,17 @@ mkpath (dir, file)
If the following line:
#stop
-
+
occurs anywhere in an 'info' or 'echo-area' section, that
indicates to GNU Info to suppress all of its default key
bindings in that context.
-
+
The 'var' section
-----------------
Each line in the 'var' section has the following syntax:
variable-name = value \n
-
+
Where "variable-name" is the name of a GNU Info variable and
"value" is the value that GNU Info will assign to that variable
when commencing execution. There must be no white space in the
@@ -567,7 +566,7 @@ compile (fp, filename, sections)
seqstate = special_key;
break;
default:
- /* Backslash followed by any other char
+ /* Backslash followed by any other char
just means that char. */
To_seq (c);
seqstate = normal;
@@ -683,7 +682,7 @@ compile (fp, filename, sections)
error = 1;
}
break;
-
+
case got_action:
if (c == '#')
state = in_trailing_comment;
@@ -720,7 +719,7 @@ compile (fp, filename, sections)
error = 1;
}
break;
-
+
case get_value:
if (c == '\n')
{
diff --git a/contrib/texinfo/info/infomap.c b/contrib/texinfo/info/infomap.c
index de82f69..82fd490 100644
--- a/contrib/texinfo/info/infomap.c
+++ b/contrib/texinfo/info/infomap.c
@@ -1,5 +1,5 @@
/* infomap.c -- keymaps for Info.
- $Id: infomap.c,v 1.5 2003/01/24 19:04:54 karl Exp $
+ $Id: infomap.c,v 1.7 2003/05/13 16:27:04 karl Exp $
Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003 Free Software
Foundation, Inc.
@@ -132,7 +132,7 @@ remove_function_keyseq (function, keyseq, rootmap)
function->keys = k->next;
}
#endif /* INFOKEY */
-
+
/* Return a new keymap which is a copy of MAP. */
Keymap
keymap_copy_keymap (map, rootmap, newroot)
@@ -1493,7 +1493,7 @@ fetch_user_maps()
#endif
if (filename == NULL || (f = open(filename, O_RDONLY)) == (-1))
{
- if (filename)
+ if (filename && errno != ENOENT)
{
info_error(filesys_error_string(filename, errno));
free(filename);
@@ -1667,7 +1667,6 @@ section_to_keymaps(map, table, len)
unsigned char *p;
unsigned char *seq;
unsigned int seqlen;
- KEYMAP_ENTRY ke;
enum { getseq, gotseq, getaction } state = getseq;
stop = len > 0 ? table[0] : 0;
@@ -1780,7 +1779,6 @@ initialize_info_keymaps ()
int i;
int suppress_info_default_bindings = 0;
int suppress_ea_default_bindings = 0;
- Keymap map;
if (!info_keymap)
{
diff --git a/contrib/texinfo/info/man.c b/contrib/texinfo/info/man.c
index bbde1ac..1590b78 100644
--- a/contrib/texinfo/info/man.c
+++ b/contrib/texinfo/info/man.c
@@ -1,7 +1,7 @@
/* man.c: How to read and format man files.
- $Id: man.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: man.c,v 1.2 2003/05/13 16:37:54 karl Exp $
- Copyright (C) 1995, 1997, 1998, 1999, 2000, 2002 Free Software
+ Copyright (C) 1995, 1997, 1998, 1999, 2000, 2002, 2003 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -160,7 +160,7 @@ create_manpage_file_buffer ()
file_buffer->filesize = 0;
file_buffer->contents = (char *)NULL;
file_buffer->flags = (N_IsInternal | N_CannotGC | N_IsManPage);
-
+
return (file_buffer);
}
@@ -401,7 +401,7 @@ clean_manpage (manpage)
/* A malformed man page could have a \b as its first character,
in which case decrementing j by 2 will cause us to write into
newpage[-1], smashing the hidden info stored there by malloc. */
- if (manpage[i] == '\b' || manpage[i] == '\f' && j > 0)
+ if (manpage[i] == '\b' || (manpage[i] == '\f' && j > 0))
j -= 2;
else if (!raw_escapes_p)
{
diff --git a/contrib/texinfo/info/nodemenu.c b/contrib/texinfo/info/nodemenu.c
index dad5137..4de2cfa 100644
--- a/contrib/texinfo/info/nodemenu.c
+++ b/contrib/texinfo/info/nodemenu.c
@@ -1,7 +1,7 @@
/* nodemenu.c -- produce a menu of all visited nodes.
- $Id: nodemenu.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: nodemenu.c,v 1.3 2003/05/13 16:37:54 karl Exp $
- Copyright (C) 1993, 1997, 1998, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1997, 1998, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
#include "info.h"
/* Return a line describing the format of a node information line. */
-static char *
+static const char *
nodemenu_format_info ()
{
return (_("\n\
@@ -101,7 +101,7 @@ format_node_info (node)
if (node->filename && *(node->filename))
{
len = pad_to (51, line_buffer);
- sprintf (line_buffer + len, node->filename);
+ strcpy (line_buffer + len, node->filename);
}
return xstrdup (line_buffer);
diff --git a/contrib/texinfo/info/nodes.c b/contrib/texinfo/info/nodes.c
index 0554ec7..a0b58cf 100644
--- a/contrib/texinfo/info/nodes.c
+++ b/contrib/texinfo/info/nodes.c
@@ -1,7 +1,8 @@
/* nodes.c -- how to get an Info file and node.
- $Id: nodes.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: nodes.c,v 1.2 2003/05/13 16:37:54 karl Exp $
- Copyright (C) 1993, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1998, 1999, 2000, 2002, 2003 Free Software
+ Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -869,19 +870,19 @@ find_node_of_anchor (file_buffer, tag)
int anchor_pos, node_pos;
TAG *node_tag;
NODE *node;
-
+
/* Look through the tag list for the anchor. */
for (anchor_pos = 0; file_buffer->tags[anchor_pos]; anchor_pos++)
{
TAG *t = file_buffer->tags[anchor_pos];
if (t->nodestart == tag->nodestart)
- break;
+ break;
}
-
+
/* Should not happen, because we should always find the anchor. */
if (!file_buffer->tags[anchor_pos])
return NULL;
-
+
/* We've found the anchor. Look backwards in the tag table for the
preceding node (we're assuming the tags are given in order),
skipping over any preceding anchors. */
@@ -889,20 +890,20 @@ find_node_of_anchor (file_buffer, tag)
node_pos >= 0 && file_buffer->tags[node_pos]->nodelen == 0;
node_pos--)
;
-
+
/* An info file with an anchor before any nodes is pathological, but
it's possible, so don't crash. */
if (node_pos < 0)
return NULL;
-
+
/* We have the tag for the node that contained the anchor tag. */
- node_tag = file_buffer->tags[node_pos];
+ node_tag = file_buffer->tags[node_pos];
/* Look up the node name in the tag table to get the actual node.
This is a recursive call, but it can't recurse again, because we
call it with a real node. */
node = info_node_of_file_buffer_tags (file_buffer, node_tag->nodename);
-
+
/* Start displaying the node at the anchor position. */
if (node)
{ /* The nodestart for real nodes is three characters before the `F'
@@ -921,11 +922,11 @@ find_node_of_anchor (file_buffer, tag)
the screen), which looks wrong. */
if (node->display_pos >= node->nodelen)
node->display_pos = node->nodelen - 1;
-
+
/* Don't search in the node for the xref text, it's not there. */
node->flags |= N_FromAnchor;
}
-
+
return node;
}
@@ -944,8 +945,8 @@ info_node_of_file_buffer_tags (file_buffer, nodename)
if (!file_buffer->tags) {
return NULL;
}
-
- for (i = 0; (tag = file_buffer->tags[i]); i++)
+
+ for (i = 0; (tag = file_buffer->tags[i]); i++)
if (strcmp (nodename, tag->nodename) == 0)
{
FILE_BUFFER *subfile = info_find_file_internal (tag->filename,
@@ -1036,7 +1037,7 @@ info_node_of_file_buffer_tags (file_buffer, nodename)
free (node);
node = find_node_of_anchor (file_buffer, tag);
}
-
+
else
{
/* Since we know the length of this node, we have already
@@ -1098,7 +1099,7 @@ forget_info_file (filename)
if (!info_loaded_files)
return;
- for (i = 0; file_buffer = info_loaded_files[i]; i++)
+ for (i = 0; (file_buffer = info_loaded_files[i]); i++)
if (FILENAME_CMP (filename, file_buffer->filename) == 0
|| FILENAME_CMP (filename, file_buffer->fullpath) == 0)
{
@@ -1107,7 +1108,7 @@ forget_info_file (filename)
if (file_buffer->contents)
free (file_buffer->contents);
-
+
/* free_file_buffer_tags () also kills the subfiles list, since
the subfiles list is only of use in conjunction with tags. */
free_file_buffer_tags (file_buffer);
diff --git a/contrib/texinfo/info/session.c b/contrib/texinfo/info/session.c
index 7cf95fa..cff7d75 100644
--- a/contrib/texinfo/info/session.c
+++ b/contrib/texinfo/info/session.c
@@ -1,8 +1,8 @@
/* session.c -- user windowing interface to Info.
- $Id: session.c,v 1.3 2003/01/24 19:05:53 karl Exp $
+ $Id: session.c,v 1.8 2003/03/22 17:41:16 karl Exp $
- Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free
- Software Foundation, Inc.
+ Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2008,6 +2008,73 @@ DECLARE_INFO_COMMAND (info_menu_digit, _("Select this menu item"))
return;
}
+
+
+/* Return a pointer to the xref in XREF_LIST that is nearest to POS, or
+ NULL if XREF_LIST is empty. That is, if POS is within any of the
+ given xrefs, return that one. Otherwise, return the one with the
+ nearest beginning or end. If there are two that are equidistant,
+ prefer the one forward. The return is in newly-allocated memory,
+ since the caller frees it.
+
+ This is called from info_menu_or_ref_item with XREF_LIST being all
+ the xrefs in the node, and POS being point. The ui function that
+ starts it all off is select-reference-this-line.
+
+ This is not the same logic as in info.el. Info-get-token prefers
+ searching backwards to searching forwards, and has a hardwired search
+ limit of 200 chars (in Emacs 21.2). */
+
+static REFERENCE **
+nearest_xref (xref_list, pos)
+ REFERENCE **xref_list;
+ long pos;
+{
+ int this_xref;
+ int nearest = -1;
+ long best_delta = -1;
+
+ for (this_xref = 0; xref_list[this_xref]; this_xref++)
+ {
+ long delta;
+ REFERENCE *xref = xref_list[this_xref];
+ if (xref->start <= pos && pos <= xref->end)
+ { /* POS is within this xref, we're done */
+ nearest = this_xref;
+ break;
+ }
+
+ /* See how far POS is from this xref. Take into account the
+ `*Note' that begins the xref, since as far as the user is
+ concerned, that's where it starts. */
+ delta = MIN (labs (pos - (xref->start - strlen (INFO_XREF_LABEL))),
+ labs (pos - xref->end));
+
+ /* It's the <= instead of < that makes us choose the forward xref
+ of POS if two are equidistant. Of course, because of all the
+ punctuation surrounding xrefs, it's not necessarily obvious
+ where one ends. */
+ if (delta <= best_delta || best_delta < 0)
+ {
+ nearest = this_xref;
+ best_delta = delta;
+ }
+ }
+
+ /* Maybe there was no list to search through. */
+ if (nearest < 0)
+ return NULL;
+
+ /* Ok, we have a nearest xref, make a list of it. */
+ {
+ REFERENCE **ret = xmalloc (sizeof (REFERENCE *) * 2);
+ ret[0] = info_copy_reference (xref_list[nearest]);
+ ret[1] = NULL;
+ return ret;
+ }
+}
+
+
/* Read a menu or followed reference from the user defaulting to the
reference found on the current line, and select that node. The
reading is done with completion. BUILDER is the function used
@@ -2021,10 +2088,10 @@ info_menu_or_ref_item (window, count, key, builder, ask_p)
REFERENCE **(*builder) ();
int ask_p;
{
- REFERENCE **menu, *entry, *defentry = (REFERENCE *)NULL;
char *line;
-
- menu = (*builder) (window->node);
+ REFERENCE *entry;
+ REFERENCE *defentry = NULL;
+ REFERENCE **menu = (*builder) (window->node);
if (!menu)
{
@@ -2038,10 +2105,8 @@ info_menu_or_ref_item (window, count, key, builder, ask_p)
/* Default the selected reference to the one which is on the line that
point is in. */
{
- REFERENCE **refs = (REFERENCE **)NULL;
- int point_line;
-
- point_line = window_line_of_point (window);
+ REFERENCE **refs = NULL;
+ int point_line = window_line_of_point (window);
if (point_line != -1)
{
@@ -2070,45 +2135,35 @@ info_menu_or_ref_item (window, count, key, builder, ask_p)
refs = manpage_xrefs_in_binding (window->node, &binding);
else
#endif /* HANDLE_MAN_PAGES */
- {
- refs = info_xrefs (&binding);
- if (!refs && point_line > 0)
- {
- /* People get annoyed that Info cannot find an xref
- which starts on a previous line and ends on this
- one. So if we fail to find a reference on this
- line, let's try the one before. */
- binding.start =
- window->line_starts[point_line - 1] - binding.buffer;
- refs = info_xrefs (&binding);
- }
- }
+ refs = nearest_xref (menu, window->point);
}
- if (refs)
+ if (refs && refs[0])
{
- if ((strcmp (refs[0]->label, "Menu") != 0) ||
- (builder == info_xrefs_of_node))
+ if (strcmp (refs[0]->label, "Menu") != 0
+ || builder == info_xrefs_of_node)
{
int which = 0;
- /* Find the closest reference to point. */
- if (builder == info_xrefs_of_node)
+ /* For xrefs, find the closest reference to point,
+ unless we only have one reference (as we will if
+ we've called nearest_xref above). It would be better
+ to have only one piece of code, but the conditions
+ when we call this are tangled. */
+ if (builder == info_xrefs_of_node && refs[1])
{
int closest = -1;
for (; refs[which]; which++)
{
- if ((window->point >= refs[which]->start) &&
- (window->point <= refs[which]->end))
+ if (window->point >= refs[which]->start
+ && window->point <= refs[which]->end)
{
closest = which;
break;
}
else if (window->point < refs[which]->start)
- {
- break;
- }
+ break;
}
if (closest == -1)
which--;
@@ -2138,9 +2193,9 @@ info_menu_or_ref_item (window, count, key, builder, ask_p)
/* Build the prompt string. */
if (defentry)
- prompt = (char *)xmalloc (20 + strlen (defentry->label));
+ prompt = (char *)xmalloc (99 + strlen (defentry->label));
else
- prompt = (char *)xmalloc (20);
+ prompt = (char *)xmalloc (99);
if (builder == info_menu_of_node)
{
@@ -2433,7 +2488,8 @@ NODE *
info_follow_menus (initial_node, menus, errstr, errarg1, errarg2)
NODE *initial_node;
char **menus;
- char **errstr, **errarg1, **errarg2;
+ const char **errstr;
+ char **errarg1, **errarg2;
{
NODE *node = NULL;
*errstr = *errarg1 = *errarg2 = NULL;
@@ -2796,7 +2852,7 @@ program_name_from_file_name (file_name)
DECLARE_INFO_COMMAND (info_goto_invocation_node,
_("Find the node describing program invocation"))
{
- char *invocation_prompt = _("Find Invocation node of [%s]: ");
+ const char *invocation_prompt = _("Find Invocation node of [%s]: ");
char *program_name, *line;
char *default_program_name, *prompt, *file_name;
NODE *top_node;
@@ -3848,7 +3904,8 @@ show_isearch_prompt (dir, string, failing_p)
int failing_p;
{
register int i;
- char *prefix, *prompt, *p_rep;
+ const char *prefix;
+ char *prompt, *p_rep;
int prompt_len, p_rep_index, p_rep_size;
if (dir < 0)
@@ -3877,8 +3934,10 @@ show_isearch_prompt (dir, string, failing_p)
p_rep_index += strlen (rep);
}
- prompt_len = strlen (prefix) + p_rep_index + 20;
- prompt = (char *)xmalloc (prompt_len);
+ prompt_len = strlen (prefix) + p_rep_index + 1;
+ if (failing_p)
+ prompt_len += strlen (_("Failing "));
+ prompt = xmalloc (prompt_len);
sprintf (prompt, "%s%s%s", failing_p ? _("Failing ") : "", prefix,
p_rep ? p_rep : "");
diff --git a/contrib/texinfo/info/window.c b/contrib/texinfo/info/window.c
index 8a626f0..93b9644 100644
--- a/contrib/texinfo/info/window.c
+++ b/contrib/texinfo/info/window.c
@@ -1,8 +1,8 @@
/* window.c -- windows in Info.
- $Id: window.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: window.c,v 1.2 2003/02/11 16:39:06 karl Exp $
- Copyright (C) 1993, 1997, 1998, 2001, 2002 Free Software Foundation,
- Inc.
+ Copyright (C) 1993, 1997, 1998, 2001, 2002, 2003 Free Software
+ Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1144,7 +1144,7 @@ window_make_modeline (window)
int modeline_len = 0;
char *parent = NULL, *filename = "*no file*";
char *nodename = "*no node*";
- char *update_message = NULL;
+ const char *update_message = NULL;
NODE *node = window->node;
if (node)
OpenPOWER on IntegriCloud