Resove conflicts.

This commit is contained in:
Mark Murray 1999-01-14 19:56:32 +00:00
parent 1c3cb5788b
commit 1631f00d83
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42664
9 changed files with 5040 additions and 4578 deletions

View File

@ -5,7 +5,7 @@
Source files groveled to make this file include:
./session.c
./echo_area.c
./echo-area.c
./infodoc.c
./m-x.c
./indices.c
@ -52,7 +52,6 @@ FUNCTION_DOC function_doc_array[] = {
{ info_up_node, "up-node", "Select the `Up' node" },
{ info_last_node, "last-node", "Select the last node in this file" },
{ info_first_node, "first-node", "Select the first node in this file" },
{ info_history_node, "history-node", "Select the most recently selected node" },
{ info_last_menu_item, "last-menu-item", "Select the last item in this node's menu" },
{ info_menu_digit, "menu-digit", "Select this menu item" },
{ info_menu_item, "menu-item", "Read a menu item and select its node" },
@ -63,6 +62,7 @@ FUNCTION_DOC function_doc_array[] = {
{ info_man, "man", "Read a manpage reference and select it" },
{ info_top_node, "top-node", "Select the node `Top' in this file" },
{ info_dir_node, "dir-node", "Select the node `(dir)'" },
{ info_history_node, "history-node", "Select the most recently selected node" },
{ info_kill_node, "kill-node", "Kill this node" },
{ info_view_file, "view-file", "Read the name of a file and select it" },
{ info_print_node, "print-node", "Pipe the contents of this node through INFO_PRINT_COMMAND" },
@ -80,7 +80,7 @@ FUNCTION_DOC function_doc_array[] = {
{ info_add_digit_to_numeric_arg, "add-digit-to-numeric-arg", "Add this digit to the current numeric argument" },
{ info_universal_argument, "universal-argument", "Start (or multiply by 4) the current numeric argument" },
{ info_numeric_arg_digit_loop, "numeric-arg-digit-loop", "Internally used by \\[universal-argument]" },
/* Commands found in "./echo_area.c". */
/* Commands found in "./echo-area.c". */
{ ea_forward, "echo-area-forward", "Move forward a character" },
{ ea_backward, "echo-area-backward", "Move backward a character" },
{ ea_beg_of_line, "echo-area-beg-of-line", "Move to the start of this line" },

View File

@ -29,7 +29,6 @@ extern void info_prev_node ();
extern void info_up_node ();
extern void info_last_node ();
extern void info_first_node ();
extern void info_history_node ();
extern void info_last_menu_item ();
extern void info_menu_digit ();
extern void info_menu_item ();
@ -40,6 +39,7 @@ extern void info_goto_node ();
extern void info_man ();
extern void info_top_node ();
extern void info_dir_node ();
extern void info_history_node ();
extern void info_kill_node ();
extern void info_view_file ();
extern void info_print_node ();
@ -58,7 +58,7 @@ extern void info_add_digit_to_numeric_arg ();
extern void info_universal_argument ();
extern void info_numeric_arg_digit_loop ();
/* Functions declared in "./echo_area.c". */
/* Functions declared in "./echo-area.c". */
extern void ea_forward ();
extern void ea_backward ();
extern void ea_beg_of_line ();

View File

@ -1,9 +1,7 @@
/* infomap.c -- Keymaps for Info. */
/* infomap.c -- Keymaps for Info.
$Id: infomap.c,v 1.7 1997/07/31 20:37:32 karl Exp $
/* This file is part of GNU Info, a program for reading online documentation
stored in Info format.
Copyright (C) 1993 Free Software Foundation, Inc.
Copyright (C) 1993, 97 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
@ -21,16 +19,10 @@
Written by Brian Fox (bfox@ai.mit.edu). */
#include "stdio.h"
#include "ctype.h"
#include "info.h"
#include "infomap.h"
#include "funs.h"
#include "info.h"
static void add_function_key(char *, VFunction *, Keymap);
extern char *term_ku, *term_kd, *term_kr, *term_kl;
extern char *term_kP, *term_kN, *term_kh, *term_kH;
#include "terminal.h"
/* Return a new keymap which has all the uppercase letters mapped to run
the function info_do_lowercase_version (). */
@ -88,18 +80,65 @@ keymap_discard_keymap (map)
for (i = 0; i < 256; i++)
{
switch (map[i].type)
{
case ISFUNC:
break;
{
case ISFUNC:
break;
case ISKMAP:
keymap_discard_keymap ((Keymap)map[i].function);
break;
case ISKMAP:
keymap_discard_keymap ((Keymap)map[i].function);
break;
}
}
}
}
/* Conditionally bind key sequence. */
int
keymap_bind_keyseq (map, keyseq, keyentry)
Keymap map;
const unsigned char *keyseq;
KEYMAP_ENTRY *keyentry;
{
register Keymap m = map;
register const unsigned char *s = keyseq;
register int c;
if (s == NULL || *s == '\0') return 0;
while ((c = *s++) != '\0')
{
switch (m[c].type)
{
case ISFUNC:
if (!(m[c].function == NULL ||
(m != map && m[c].function == info_do_lowercase_version)))
return 0;
if (*s != '\0')
{
m[c].type = ISKMAP;
m[c].function = (VFunction *)keymap_make_keymap ();
}
break;
case ISKMAP:
if (*s == '\0')
return 0;
break;
}
if (*s != '\0')
{
m = (Keymap)m[c].function;
}
else
{
m[c] = *keyentry;
}
}
return 1;
}
/* Initialize the standard info keymaps. */
Keymap info_keymap = (Keymap)NULL;
@ -123,15 +162,15 @@ initialize_info_keymaps ()
echo_area_keymap[ESC].function = (VFunction *)keymap_make_keymap ();
echo_area_keymap[Control ('x')].type = ISKMAP;
echo_area_keymap[Control ('x')].function =
(VFunction *)keymap_make_keymap ();
(VFunction *)keymap_make_keymap ();
}
/* Bind numeric arg functions for both echo area and info window maps. */
for (i = '0'; i < '9' + 1; i++)
{
((Keymap) info_keymap[ESC].function)[i].function =
((Keymap) echo_area_keymap[ESC].function)[i].function =
info_add_digit_to_numeric_arg;
((Keymap) echo_area_keymap[ESC].function)[i].function =
info_add_digit_to_numeric_arg;
}
((Keymap) info_keymap[ESC].function)['-'].function =
((Keymap) echo_area_keymap[ESC].function)['-'].function =
@ -188,6 +227,31 @@ initialize_info_keymaps ()
map['o'].function = info_next_window;
map[DEL].function = ea_backward_kill_line;
/* Arrow key bindings for echo area keymaps. It seems that some
terminals do not match their termcap entries, so it's best to just
define everything with both of the usual prefixes. */
map = echo_area_keymap;
keymap_bind_keyseq (map, term_ku, &map[Control ('p')]); /* up */
keymap_bind_keyseq (map, "\033OA", &map[Control ('p')]);
keymap_bind_keyseq (map, "\033[A", &map[Control ('p')]);
keymap_bind_keyseq (map, term_kd, &map[Control ('n')]); /* down */
keymap_bind_keyseq (map, "\033OB", &map[Control ('n')]);
keymap_bind_keyseq (map, "\033[B", &map[Control ('n')]);
keymap_bind_keyseq (map, term_kr, &map[Control ('f')]); /* right */
keymap_bind_keyseq (map, "\033OC", &map[Control ('f')]);
keymap_bind_keyseq (map, "\033[C", &map[Control ('f')]);
keymap_bind_keyseq (map, term_kl, &map[Control ('b')]); /* left */
keymap_bind_keyseq (map, "\033OD", &map[Control ('b')]);
keymap_bind_keyseq (map, "\033[D", &map[Control ('b')]);
map = (Keymap)echo_area_keymap[ESC].function;
keymap_bind_keyseq (map, term_kl, &map['b']); /* left */
keymap_bind_keyseq (map, "\033OA", &map['b']);
keymap_bind_keyseq (map, "\033[A", &map['b']);
keymap_bind_keyseq (map, term_kr, &map['f']); /* right */
keymap_bind_keyseq (map, "\033OB", &map['f']);
keymap_bind_keyseq (map, "\033[B", &map['f']);
/* Bind commands for Info window keymaps. */
map = info_keymap;
map[TAB].function = info_move_to_next_xref;
@ -271,58 +335,34 @@ initialize_info_keymaps ()
map['t'].function = info_tile_windows;
map['w'].function = info_toggle_wrap;
/* Add functions for the arrow keys, PageUp, PageDown, Home, HomeDown */
add_function_key(term_ku, info_prev_line, info_keymap);
add_function_key(term_kd, info_next_line, info_keymap);
add_function_key(term_kl, info_backward_char, info_keymap);
add_function_key(term_kr, info_forward_char, info_keymap);
add_function_key(term_kP, info_scroll_backward, info_keymap);
add_function_key(term_kN, info_scroll_forward, info_keymap);
add_function_key(term_kh, info_beginning_of_node, info_keymap);
add_function_key(term_kH, info_end_of_node, info_keymap);
}
/* Arrow key bindings for Info windows keymap. */
map = info_keymap;
keymap_bind_keyseq (map, term_kN, &map[Control ('v')]); /* pagedown */
keymap_bind_keyseq (map, term_ku, &map[Control ('p')]); /* up */
keymap_bind_keyseq (map, "\033OA", &map[Control ('p')]);
keymap_bind_keyseq (map, "\033[A", &map[Control ('p')]);
keymap_bind_keyseq (map, term_kd, &map[Control ('n')]); /* down */
keymap_bind_keyseq (map, "\033OB", &map[Control ('n')]);
keymap_bind_keyseq (map, "\033[B", &map[Control ('n')]);
keymap_bind_keyseq (map, term_kr, &map[Control ('f')]); /* right */
keymap_bind_keyseq (map, "\033OC", &map[Control ('f')]);
keymap_bind_keyseq (map, "\033[C", &map[Control ('f')]);
keymap_bind_keyseq (map, term_kl, &map[Control ('b')]); /* left */
keymap_bind_keyseq (map, "\033OD", &map[Control ('b')]);
keymap_bind_keyseq (map, "\033[D", &map[Control ('b')]);
static void add_function_key(char *esc_seq, VFunction *func, Keymap map)
{
char *end_str, *p;
if (!esc_seq)
return; /* don't add keys which don't exist */
end_str = esc_seq + strlen(esc_seq);
for (p = esc_seq; p < end_str; p++)
{
if (isupper(*p))
*p = tolower(*p);
switch (map[*p].type)
{
case ISKMAP: /* Go one level down. Also has the effect
that we're not overwriting a previous
binding if we're at the end of p */
map = (Keymap)map[*p].function;
break;
case ISFUNC: /* two possibilities here:
1. map[*p].function == NULL means we have
a virgin keymap to fill;
2. else this entry is already taken */
if (map[*p].function == NULL)
{
if (p == end_str - 1)
{
map[*p].function = func;
return;
}
map[*p].type = ISKMAP;
map[*p].function = (VFunction *)keymap_make_keymap();
map = (Keymap)map[*p].function;
} else
return;
break;
default: /* can't happen */
info_error("unknown keymap type (%d).", map[*p].type);
break;
}
}
return;
map = (Keymap)info_keymap[ESC].function;
keymap_bind_keyseq (map, term_kl, &map['b']); /* left */
keymap_bind_keyseq (map, "\033OA", &map['b']);
keymap_bind_keyseq (map, "\033[A", &map['b']);
keymap_bind_keyseq (map, term_kr, &map['f']); /* right */
keymap_bind_keyseq (map, "\033OB", &map['f']);
keymap_bind_keyseq (map, "\033[B", &map['f']);
keymap_bind_keyseq (map, term_kN, &map[Control ('v')]); /* pagedown */
/* The alternative to this definition of a `main map' key in the
`ESC map' section, is something like:
keymap_bind_keyseq (map, term_kP, &((KeyMap)map[ESC].function).map['v']);
*/
keymap_bind_keyseq (info_keymap/*sic*/, term_kP, &map['v']); /* pageup */
}

View File

@ -1,9 +1,7 @@
/* nodemenu.c -- Produce a menu of all visited nodes. */
/* nodemenu.c -- Produce a menu of all visited nodes.
$Id: nodemenu.c,v 1.7 1997/07/24 21:30:30 karl Exp $
/* This file is part of GNU Info, a program for reading online documentation
stored in Info format.
Copyright (C) 1993 Free Software Foundation, Inc.
Copyright (C) 1993, 97 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
@ -27,10 +25,10 @@
static char *
nodemenu_format_info ()
{
return ("\n\
return (_("\n\
* Menu:\n\
(File)Node Lines Size Containing File\n\
---------- ----- ---- ---------------");
---------- ----- ---- ---------------"));
}
/* Produce a formatted line of information about NODE. Here is what we want
@ -41,7 +39,7 @@ nodemenu_format_info ()
---------- ----- ---- ---------------
* (emacs)Buffers:: 48 2230 /usr/gnu/info/emacs/emacs-1
* (autoconf)Writing configure.in:: 123 58789 /usr/gnu/info/autoconf/autoconf-1
* (dir)Top:: 40 589 /usr/gnu/info/dir
* (dir)Top:: 40 589 /usr/gnu/info/dir
*/
static char *
format_node_info (node)
@ -58,7 +56,7 @@ format_node_info (node)
{
parent = filename_non_directory (node->parent);
if (!parent)
parent = node->parent;
parent = node->parent;
}
else
parent = (char *)NULL;
@ -72,15 +70,15 @@ format_node_info (node)
char *file = (char *)NULL;
if (parent)
file = parent;
file = parent;
else
file = filename_non_directory (containing_file);
file = filename_non_directory (containing_file);
if (!file)
file = containing_file;
file = containing_file;
if (!*file)
file = "dir";
file = "dir";
sprintf (line_buffer, "* (%s)%s::", file, node->nodename);
}
@ -92,7 +90,7 @@ format_node_info (node)
for (i = 0; i < node->nodelen; i++)
if (node->contents[i] == '\n')
lines++;
lines++;
sprintf (line_buffer + len, "%d", lines);
}
@ -106,7 +104,7 @@ format_node_info (node)
sprintf (line_buffer + len, node->filename);
}
return (strdup (line_buffer));
return xstrdup (line_buffer);
}
/* Little string comparison routine for qsort (). */
@ -137,26 +135,26 @@ get_visited_nodes (filter_func)
if (!info_windows)
return ((NODE *)NULL);
for (iw_index = 0; info_win = info_windows[iw_index]; iw_index++)
for (iw_index = 0; (info_win = info_windows[iw_index]); iw_index++)
{
for (i = 0; i < info_win->nodes_index; i++)
{
node = info_win->nodes[i];
{
node = info_win->nodes[i];
/* We skip mentioning "*Node Menu*" nodes. */
if (internal_info_node_p (node) &&
(strcmp (node->nodename, nodemenu_nodename) == 0))
continue;
/* We skip mentioning "*Node Menu*" nodes. */
if (internal_info_node_p (node) &&
(strcmp (node->nodename, nodemenu_nodename) == 0))
continue;
if (node && (!filter_func || (*filter_func) (node)))
{
char *line;
if (node && (!filter_func || (*filter_func) (node)))
{
char *line;
line = format_node_info (node);
add_pointer_to_array
(line, lines_index, lines, lines_slots, 20, char *);
}
}
line = format_node_info (node);
add_pointer_to_array
(line, lines_index, lines, lines_slots, 20, char *);
}
}
}
/* Sort the array of information lines, if there are any. */
@ -169,22 +167,22 @@ get_visited_nodes (filter_func)
/* Delete duplicates. */
for (i = 0, newlen = 1; i < lines_index - 1; i++)
{
if (strcmp (lines[i], lines[i + 1]) == 0)
{
free (lines[i]);
lines[i] = (char *)NULL;
}
else
newlen++;
}
{
if (strcmp (lines[i], lines[i + 1]) == 0)
{
free (lines[i]);
lines[i] = (char *)NULL;
}
else
newlen++;
}
/* We have free ()'d and marked all of the duplicate slots.
Copy the live slots rather than pruning the dead slots. */
Copy the live slots rather than pruning the dead slots. */
temp = (char **)xmalloc ((1 + newlen) * sizeof (char *));
for (i = 0, j = 0; i < lines_index; i++)
if (lines[i])
temp[j++] = lines[i];
if (lines[i])
temp[j++] = lines[i];
temp[j] = (char *)NULL;
free (lines);
@ -196,8 +194,8 @@ get_visited_nodes (filter_func)
printf_to_message_buffer
("%s", replace_in_documentation
("Here is the menu of nodes you have recently visited.\n\
Select one from this menu, or use `\\[history-node]' in another window.\n"));
(_("Here is the menu of nodes you have recently visited.\n\
Select one from this menu, or use `\\[history-node]' in another window.\n")));
printf_to_message_buffer ("%s\n", nodemenu_format_info ());
@ -216,7 +214,7 @@ Select one from this menu, or use `\\[history-node]' in another window.\n"));
}
DECLARE_INFO_COMMAND (list_visited_nodes,
"Make a window containing a menu of all of the currently visited nodes")
_("Make a window containing a menu of all of the currently visited nodes"))
{
WINDOW *new;
NODE *node;
@ -229,14 +227,20 @@ DECLARE_INFO_COMMAND (list_visited_nodes,
node = new->node;
if (internal_info_node_p (node) &&
(strcmp (node->nodename, nodemenu_nodename) == 0))
break;
(strcmp (node->nodename, nodemenu_nodename) == 0))
break;
}
/* If we couldn't find an existing window, try to use the next window
in the chain. */
if (!new && window->next)
new = window->next;
if (!new)
{
if (window->next)
new = window->next;
/* If there is more than one window, wrap around. */
else if (window != windows)
new = windows;
}
/* If we still don't have a window, make a new one to contain the list. */
if (!new)
@ -258,10 +262,16 @@ DECLARE_INFO_COMMAND (list_visited_nodes,
node = get_visited_nodes ((Function *)NULL);
name_internal_node (node, nodemenu_nodename);
#if 0
/* Even if this is an internal node, we don't want the window
system to treat it specially. So we turn off the internalness
of it here. */
/* Why? We depend on internal_info_node_p returning true, so we must
not remove the flag. Otherwise, the *Node Menu* nodes themselves
appear in the node menu. --Andreas Schwab
<schwab@issan.informatik.uni-dortmund.de>. */
node->flags &= ~N_IsInternal;
#endif
/* If this window is already showing a node menu, reuse the existing node
slot. */
@ -270,7 +280,7 @@ DECLARE_INFO_COMMAND (list_visited_nodes,
#if defined (NOTDEF)
if (internal_info_node_p (new->node) &&
(strcmp (new->node->nodename, nodemenu_nodename) == 0))
(strcmp (new->node->nodename, nodemenu_nodename) == 0))
remember_me = 0;
#endif /* NOTDEF */
@ -284,7 +294,7 @@ DECLARE_INFO_COMMAND (list_visited_nodes,
}
DECLARE_INFO_COMMAND (select_visited_node,
"Select a node which has been previously visited in a visible window")
_("Select a node which has been previously visited in a visible window"))
{
char *line;
NODE *node;
@ -296,7 +306,7 @@ DECLARE_INFO_COMMAND (select_visited_node,
free (node);
line =
info_read_completing_in_echo_area (window, "Select visited node: ", menu);
info_read_completing_in_echo_area (window, _("Select visited node: "), menu);
window = active_window;
@ -316,9 +326,9 @@ DECLARE_INFO_COMMAND (select_visited_node,
entry = info_get_labeled_reference (line, menu);
if (!entry)
info_error ("The reference disappeared! (%s).", line);
info_error (_("The reference disappeared! (%s)."), line);
else
info_select_reference (window, entry);
info_select_reference (window, entry);
}
free (line);

File diff suppressed because it is too large Load Diff

View File

@ -25,9 +25,9 @@
#include "signals.h"
/* **************************************************************** */
/* */
/* Pretending That We Have POSIX Signals */
/* */
/* */
/* Pretending That We Have POSIX Signals */
/* */
/* **************************************************************** */
#if !defined (HAVE_SIGPROCMASK) && defined (HAVE_SIGSETMASK)
@ -57,36 +57,32 @@ sigprocmask (operation, newset, oldset)
#endif /* !HAVE_SIGPROCMASK && HAVE_SIGSETMASK */
/* **************************************************************** */
/* */
/* Signal Handling for Info */
/* */
/* */
/* Signal Handling for Info */
/* */
/* **************************************************************** */
typedef void SigHandlerType;
typedef SigHandlerType SigHandler ();
typedef RETSIGTYPE signal_handler ();
static SigHandlerType info_signal_handler ();
static SigHandler *old_TSTP, *old_TTOU, *old_TTIN;
static SigHandler *old_WINCH, *old_INT, *old_CONT;
static RETSIGTYPE info_signal_handler ();
static signal_handler *old_TSTP, *old_TTOU, *old_TTIN;
static signal_handler *old_WINCH, *old_INT;
void
initialize_info_signal_handler ()
{
#if defined (SIGTSTP)
old_TSTP = (SigHandler *) signal (SIGTSTP, info_signal_handler);
old_TTOU = (SigHandler *) signal (SIGTTOU, info_signal_handler);
old_TTIN = (SigHandler *) signal (SIGTTIN, info_signal_handler);
old_TSTP = (signal_handler *) signal (SIGTSTP, info_signal_handler);
old_TTOU = (signal_handler *) signal (SIGTTOU, info_signal_handler);
old_TTIN = (signal_handler *) signal (SIGTTIN, info_signal_handler);
#endif /* SIGTSTP */
#if defined (SIGWINCH)
old_WINCH = (SigHandler *) signal (SIGWINCH, info_signal_handler);
#if defined (SIGCONT)
old_CONT = (SigHandler *) signal (SIGCONT, info_signal_handler);
#endif /* SIGCONT */
#endif /* SIGWINCH */
old_WINCH = (signal_handler *) signal (SIGWINCH, info_signal_handler);
#endif
#if defined (SIGINT)
old_INT = (SigHandler *) signal (SIGINT, info_signal_handler);
old_INT = (signal_handler *) signal (SIGINT, info_signal_handler);
#endif
}
@ -101,11 +97,11 @@ redisplay_after_signal ()
fflush (stdout);
}
static SigHandlerType
static RETSIGTYPE
info_signal_handler (sig)
int sig;
{
SigHandler **old_signal_handler;
signal_handler **old_signal_handler;
switch (sig)
{
@ -119,33 +115,33 @@ info_signal_handler (sig)
#endif
{
#if defined (SIGTSTP)
if (sig == SIGTSTP)
old_signal_handler = &old_TSTP;
if (sig == SIGTTOU)
old_signal_handler = &old_TTOU;
if (sig == SIGTTIN)
old_signal_handler = &old_TTIN;
if (sig == SIGTSTP)
old_signal_handler = &old_TSTP;
if (sig == SIGTTOU)
old_signal_handler = &old_TTOU;
if (sig == SIGTTIN)
old_signal_handler = &old_TTIN;
#endif /* SIGTSTP */
if (sig == SIGINT)
old_signal_handler = &old_INT;
if (sig == SIGINT)
old_signal_handler = &old_INT;
/* For stop signals, restore the terminal IO, leave the cursor
at the bottom of the window, and stop us. */
terminal_goto_xy (0, screenheight - 1);
terminal_clear_to_eol ();
fflush (stdout);
terminal_unprep_terminal ();
signal (sig, *old_signal_handler);
UNBLOCK_SIGNAL (sig);
kill (getpid (), sig);
/* For stop signals, restore the terminal IO, leave the cursor
at the bottom of the window, and stop us. */
terminal_goto_xy (0, screenheight - 1);
terminal_clear_to_eol ();
fflush (stdout);
terminal_unprep_terminal ();
signal (sig, *old_signal_handler);
UNBLOCK_SIGNAL (sig);
kill (getpid (), sig);
/* The program is returning now. Restore our signal handler,
turn on terminal handling, redraw the screen, and place the
cursor where it belongs. */
terminal_prep_terminal ();
*old_signal_handler = (SigHandler *) signal (sig, info_signal_handler);
redisplay_after_signal ();
fflush (stdout);
/* The program is returning now. Restore our signal handler,
turn on terminal handling, redraw the screen, and place the
cursor where it belongs. */
terminal_prep_terminal ();
*old_signal_handler = (signal_handler *) signal (sig, info_signal_handler);
redisplay_after_signal ();
fflush (stdout);
}
break;
@ -161,23 +157,23 @@ info_signal_handler (sig)
#if defined (SIGWINCH)
case SIGWINCH:
{
/* Turn off terminal IO, tell our parent that the window has changed,
then reinitialize the terminal and rebuild our windows. */
old_signal_handler = &old_WINCH;
terminal_goto_xy (0, 0);
fflush (stdout);
terminal_unprep_terminal ();
signal (sig, *old_signal_handler);
UNBLOCK_SIGNAL (sig);
kill (getpid (), sig);
/* Turn off terminal IO, tell our parent that the window has changed,
then reinitialize the terminal and rebuild our windows. */
old_signal_handler = &old_WINCH;
terminal_goto_xy (0, 0);
fflush (stdout);
terminal_unprep_terminal ();
signal (sig, *old_signal_handler);
UNBLOCK_SIGNAL (sig);
kill (getpid (), sig);
/* After our old signal handler returns... */
terminal_get_screen_size ();
terminal_prep_terminal ();
display_initialize_display (screenwidth, screenheight);
window_new_screen_size (screenwidth, screenheight, (VFunction *)NULL);
*old_signal_handler = (SigHandler *) signal (sig, info_signal_handler);
redisplay_after_signal ();
/* After our old signal handler returns... */
terminal_get_screen_size ();
terminal_prep_terminal ();
display_initialize_display (screenwidth, screenheight);
window_new_screen_size (screenwidth, screenheight, (VFunction *)NULL);
*old_signal_handler = (signal_handler *) signal (sig, info_signal_handler);
redisplay_after_signal ();
}
break;
#endif /* SIGWINCH */

View File

@ -1,12 +1,8 @@
/* terminal.c -- How to handle the physical terminal for Info. */
/* terminal.c -- How to handle the physical terminal for Info.
$Id: terminal.c,v 1.9 1998/02/22 00:05:15 karl Exp $
/* This file is part of GNU Info, a program for reading online documentation
stored in Info format.
This file has appeared in prior works by the Free Software Foundation;
thus it carries copyright dates from 1988 through 1993.
Copyright (C) 1988, 89, 90, 91, 92, 93, 96 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 90, 91, 92, 93, 96, 97, 98
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
@ -24,20 +20,33 @@
Written by Brian Fox (bfox@ai.mit.edu). */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "info.h"
#include "terminal.h"
#include "termdep.h"
extern void *xmalloc (), *xrealloc ();
#include <sys/types.h>
#include <signal.h>
/* The Unix termcap interface code. */
#ifdef HAVE_NCURSES_TERMCAP_H
#include <ncurses/termcap.h>
#else
#ifdef HAVE_TERMCAP_H
#include <termcap.h>
#else
/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC.
Unfortunately, PC is a global variable used by the termcap library. */
#undef PC
/* Termcap requires these variables, whether we access them or not. */
char *BC, *UP;
char PC; /* Pad character */
short ospeed; /* Terminal output baud rate */
extern int tgetnum (), tgetflag (), tgetent ();
extern char *tgetstr (), *tgoto ();
extern char *getenv ();
extern void tputs ();
#endif /* not HAVE_TERMCAP_H */
#endif /* not HAVE_NCURSES_TERMCAP_H */
/* Function "hooks". If you make one of these point to a function, that
function is called when appropriate instead of its namesake. Your
@ -61,20 +70,11 @@ VFunction *terminal_write_chars_hook = (VFunction *)NULL;
VFunction *terminal_scroll_terminal_hook = (VFunction *)NULL;
/* **************************************************************** */
/* */
/* Terminal and Termcap */
/* */
/* */
/* Terminal and Termcap */
/* */
/* **************************************************************** */
/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC.
Unfortunately, PC is a global variable used by the termcap library. */
#undef PC
/* TERMCAP requires these variables, whether we access them or not. */
char PC;
char *BC, *UP;
short ospeed;
/* A buffer which holds onto the current terminal description, and a pointer
used to float within it. */
static char *term_buffer = (char *)NULL;
@ -85,6 +85,8 @@ static char *term_goto, *term_clreol, *term_cr, *term_clrpag;
static char *term_begin_use, *term_end_use;
static char *term_AL, *term_DL, *term_al, *term_dl;
static char *term_keypad_on, *term_keypad_off;
/* How to go up a line. */
static char *term_up;
@ -115,11 +117,15 @@ static char *term_ks;
/* The string to turn off keypad transmit mode, if this term has one. */
static char *term_ke;
static void
/* Although I can't find any documentation that says this is supposed to
return its argument, all the code I've looked at (termutils, less)
does so, so fine. */
static int
output_character_function (c)
int c;
{
putc (c, stdout);
return c;
}
/* Macro to send STRING to the terminal. */
@ -129,29 +135,65 @@ output_character_function (c)
tputs (string, 1, output_character_function); \
} while (0)
/* Tell the terminal that we will be doing cursor addressable motion. */
/* Tell the terminal that we will be doing cursor addressable motion. */
static void
terminal_begin_using_terminal ()
{
RETSIGTYPE (*sigsave) ();
if (term_keypad_on)
send_to_terminal (term_keypad_on);
if (!term_begin_use || !*term_begin_use)
return;
#ifdef SIGWINCH
sigsave = signal (SIGWINCH, SIG_IGN);
#endif
send_to_terminal (term_begin_use);
if (term_ks)
send_to_terminal(term_ks);
/* Without this fflush and sleep, running info in a shelltool or
cmdtool (TERM=sun-cmd) with scrollbars loses -- the scrollbars are
not restored properly.
From: strube@physik3.gwdg.de (Hans Werner Strube). */
fflush (stdout);
sleep (1);
#ifdef SIGWINCH
signal (SIGWINCH, sigsave);
#endif
}
/* Tell the terminal that we will not be doing any more cursor addressable
motion. */
/* Tell the terminal that we will not be doing any more cursor
addressable motion. */
static void
terminal_end_using_terminal ()
{
if (term_ke)
send_to_terminal(term_ke);
RETSIGTYPE (*sigsave) ();
if (term_keypad_off)
send_to_terminal (term_keypad_off);
if (!term_end_use || !*term_end_use)
return;
#ifdef SIGWINCH
sigsave = signal (SIGWINCH, SIG_IGN);
#endif
send_to_terminal (term_end_use);
fflush (stdout);
sleep (1);
#ifdef SIGWINCH
signal (SIGWINCH, sigsave);
#endif
}
/* **************************************************************** */
/* */
/* Necessary Terminal Functions */
/* */
/* */
/* Necessary Terminal Functions */
/* */
/* **************************************************************** */
/* The functions and variables on this page implement the user visible
@ -180,11 +222,8 @@ char *term_ku = (char *)NULL;
char *term_kd = (char *)NULL;
char *term_kr = (char *)NULL;
char *term_kl = (char *)NULL;
char *term_kP = (char *)NULL;
char *term_kN = (char *)NULL;
char *term_kh = (char *)NULL;
char *term_kH = (char *)NULL;
char *term_kP = (char *)NULL; /* page-up */
char *term_kN = (char *)NULL; /* page-down */
/* Move the cursor to the terminal location of X and Y. */
void
@ -196,7 +235,7 @@ terminal_goto_xy (x, y)
else
{
if (term_goto)
tputs (tgoto (term_goto, x, y), 1, output_character_function);
tputs (tgoto (term_goto, x, y), 1, output_character_function);
}
}
@ -224,7 +263,7 @@ terminal_write_chars (string, nchars)
else
{
if (nchars)
fwrite (string, 1, nchars, stdout);
fwrite (string, 1, nchars, stdout);
}
}
@ -310,9 +349,9 @@ terminal_ring_bell ()
else
{
if (terminal_has_visible_bell_p && terminal_use_visible_bell_p)
send_to_terminal (visible_bell);
send_to_terminal (visible_bell);
else
send_to_terminal (audible_bell);
send_to_terminal (audible_bell);
}
}
@ -334,7 +373,7 @@ terminal_delete_lines (start, count)
else
{
while (count--)
tputs (term_dl, lines, output_character_function);
tputs (term_dl, lines, output_character_function);
}
fflush (stdout);
@ -359,7 +398,7 @@ terminal_insert_lines (start, count)
else
{
while (count--)
tputs (term_al, lines, output_character_function);
tputs (term_al, lines, output_character_function);
}
fflush (stdout);
@ -385,22 +424,22 @@ terminal_scroll_terminal (start, end, amount)
else
{
/* If we are scrolling down, delete AMOUNT lines at END. Then insert
AMOUNT lines at START. */
AMOUNT lines at START. */
if (amount > 0)
{
terminal_delete_lines (end, amount);
terminal_insert_lines (start, amount);
}
{
terminal_delete_lines (end, amount);
terminal_insert_lines (start, amount);
}
/* If we are scrolling up, delete AMOUNT lines before START. This
actually does the upwards scroll. Then, insert AMOUNT lines
after the already scrolled region (i.e., END - AMOUNT). */
actually does the upwards scroll. Then, insert AMOUNT lines
after the already scrolled region (i.e., END - AMOUNT). */
if (amount < 0)
{
int abs_amount = -amount;
terminal_delete_lines (start - abs_amount, abs_amount);
terminal_insert_lines (end - abs_amount, abs_amount);
}
{
int abs_amount = -amount;
terminal_delete_lines (start - abs_amount, abs_amount);
terminal_insert_lines (end - abs_amount, abs_amount);
}
}
}
@ -430,55 +469,55 @@ terminal_get_screen_size ()
#if defined (TIOCGWINSZ)
{
struct winsize window_size;
struct winsize window_size;
if (ioctl (fileno (stdout), TIOCGWINSZ, &window_size) == 0)
{
screenwidth = (int) window_size.ws_col;
screenheight = (int) window_size.ws_row;
}
if (ioctl (fileno (stdout), TIOCGWINSZ, &window_size) == 0)
{
screenwidth = (int) window_size.ws_col;
screenheight = (int) window_size.ws_row;
}
}
#endif /* TIOCGWINSZ */
#endif /* TIOCGWINSZ */
/* Environment variable COLUMNS overrides setting of "co". */
if (screenwidth <= 0)
{
char *sw = getenv ("COLUMNS");
{
char *sw = getenv ("COLUMNS");
if (sw)
screenwidth = atoi (sw);
if (sw)
screenwidth = atoi (sw);
if (screenwidth <= 0)
screenwidth = tgetnum ("co");
}
if (screenwidth <= 0)
screenwidth = tgetnum ("co");
}
/* Environment variable LINES overrides setting of "li". */
if (screenheight <= 0)
{
char *sh = getenv ("LINES");
{
char *sh = getenv ("LINES");
if (sh)
screenheight = atoi (sh);
if (sh)
screenheight = atoi (sh);
if (screenheight <= 0)
screenheight = tgetnum ("li");
}
if (screenheight <= 0)
screenheight = tgetnum ("li");
}
/* If all else fails, default to 80x24 terminal. */
if (screenwidth <= 0)
screenwidth = 80;
screenwidth = 80;
if (screenheight <= 0)
screenheight = 24;
screenheight = 24;
}
}
/* Initialize the terminal which is known as TERMINAL_NAME. If this terminal
doesn't have cursor addressability, TERMINAL_IS_DUMB_P becomes non-zero.
The variables SCREENHEIGHT and SCREENWIDTH are set to the dimensions that
this terminal actually has. The variable TERMINAL_HAS_META_P becomes non-
zero if this terminal supports a Meta key. Finally, the terminal screen is
cleared. */
/* Initialize the terminal which is known as TERMINAL_NAME. If this
terminal doesn't have cursor addressability, `terminal_is_dumb_p'
becomes nonzero. The variables SCREENHEIGHT and SCREENWIDTH are set
to the dimensions that this terminal actually has. The variable
TERMINAL_HAS_META_P becomes nonzero if this terminal supports a Meta
key. Finally, the terminal screen is cleared. */
void
terminal_initialize_terminal (terminal_name)
char *terminal_name;
@ -516,7 +555,7 @@ terminal_initialize_terminal (terminal_name)
term_cr = "\r";
term_up = term_dn = audible_bell = visible_bell = (char *)NULL;
term_ku = term_kd = term_kl = term_kr = (char *)NULL;
term_kP = term_kN = term_kh = term_kH = (char *)NULL;
term_kP = term_kN = (char *)NULL;
return;
}
@ -534,7 +573,7 @@ terminal_initialize_terminal (terminal_name)
}
#else
ospeed = B9600;
#endif /* !TIOCGETP */
#endif /* !TIOCGETP */
term_cr = tgetstr ("cr", &buffer);
term_clreol = tgetstr ("ce", &buffer);
@ -570,6 +609,9 @@ terminal_initialize_terminal (terminal_name)
term_begin_use = tgetstr ("ti", &buffer);
term_end_use = tgetstr ("te", &buffer);
term_keypad_on = tgetstr ("ks", &buffer);
term_keypad_off = tgetstr ("ke", &buffer);
/* Check to see if this terminal has a meta key. */
terminal_has_meta_p = (tgetflag ("km") || tgetflag ("MT"));
if (terminal_has_meta_p)
@ -588,26 +630,19 @@ terminal_initialize_terminal (terminal_name)
term_kd = tgetstr ("kd", &buffer);
term_kr = tgetstr ("kr", &buffer);
term_kl = tgetstr ("kl", &buffer);
term_kP = tgetstr ("kP", &buffer);
term_kN = tgetstr ("kN", &buffer);
term_kh = tgetstr ("kh", &buffer);
term_kH = tgetstr ("kH", &buffer);
/* Enable keypad and cursor keys if ks defined */
term_ks = tgetstr ("ks", &buffer);
term_ke = tgetstr ("ke", &buffer);
/* If this terminal is not cursor addressable, then it is really dumb. */
if (!term_goto)
terminal_is_dumb_p = 1;
terminal_begin_using_terminal ();
}
/* **************************************************************** */
/* */
/* How to Read Characters From the Terminal */
/* */
/* */
/* How to Read Characters From the Terminal */
/* */
/* **************************************************************** */
#if defined (TIOCGETC)
@ -648,6 +683,8 @@ terminal_prep_terminal ()
return;
}
terminal_begin_using_terminal ();
tty = fileno (stdin);
#if defined (HAVE_TERMIOS_H)
@ -662,7 +699,14 @@ terminal_prep_terminal ()
#if defined (HAVE_TERMIOS_H) || defined (HAVE_TERMIO_H)
ttybuff.c_iflag &= (~ISTRIP & ~INLCR & ~IGNCR & ~ICRNL & ~IXON);
ttybuff.c_oflag &= (~ONLCR);
/* These output flags are not part of POSIX, so only use them if they
are defined. */
#ifdef ONLCR
ttybuff.c_oflag &= ~ONLCR ;
#endif
#ifdef OCRNL
ttybuff.c_oflag &= ~OCRNL;
#endif
ttybuff.c_lflag &= (~ICANON & ~ECHO);
ttybuff.c_cc[VMIN] = 1;
@ -673,7 +717,12 @@ terminal_prep_terminal ()
if (ttybuff.c_cc[VQUIT] == '\177')
ttybuff.c_cc[VQUIT] = -1;
#endif
#ifdef VLNEXT
if (ttybuff.c_cc[VLNEXT] == '\026')
ttybuff.c_cc[VLNEXT] = -1;
#endif /* VLNEXT */
#endif /* TERMIOS or TERMIO */
#if defined (HAVE_TERMIOS_H)
tcsetattr (tty, TCSANOW, &ttybuff);
@ -737,9 +786,9 @@ terminal_prep_terminal ()
temp = original_ltchars;
/* Make the interrupt keys go away. Just enough to make people happy. */
temp.t_lnextc = -1; /* C-v. */
temp.t_dsuspc = -1; /* C-y. */
temp.t_flushc = -1; /* C-o. */
temp.t_lnextc = -1; /* C-v. */
temp.t_dsuspc = -1; /* C-y. */
temp.t_flushc = -1; /* C-o. */
ioctl (tty, TIOCSLTC, &temp);
}
# endif /* TIOCGLTC */

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +1,27 @@
/* install-info -- create Info directory entry(ies) for an Info file.
Copyright (C) 1996 Free Software Foundation, Inc.
$Id: install-info.c,v 1.21 1998/03/01 15:38:45 karl Exp $
$Id: install-info.c,v 1.12 1996/10/03 23:13:36 karl Exp $
Copyright (C) 1996, 97, 98 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/
#define INSTALL_INFO_VERSION_STRING "GNU install-info (Texinfo 3.9) 1.2"
#include <stdio.h>
#include <errno.h>
#include "system.h"
#include <getopt.h>
#include <sys/types.h>
/* Get O_RDONLY. */
#ifdef HAVE_SYS_FCNTL_H
#include <sys/fcntl.h>
#else
#include <fcntl.h>
#endif /* !HAVE_SYS_FCNTL_H */
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#ifdef HAVE_LIBZ
#include <zlib.h>
#endif
/* Name this program was invoked with. */
@ -47,9 +37,8 @@ struct spec_entry;
/* Data structures. */
/* Record info about a single line from a file
as read into core. */
/* Record info about a single line from a file as read into core. */
struct line_data
{
/* The start of the line. */
@ -66,9 +55,9 @@ struct line_data
int delete;
};
/* This is used for a list of the specified menu section names
in which entries should be added. */
struct spec_section
{
struct spec_section *next;
@ -78,16 +67,16 @@ struct spec_section
int missing;
};
/* This is used for a list of the entries specified to be added. */
/* This is used for a list of the entries specified to be added. */
struct spec_entry
{
struct spec_entry *next;
char *text;
};
/* This is used for a list of nodes found by parsing the dir file. */
/* This is used for a list of nodes found by parsing the dir file. */
struct node
{
struct node *next;
@ -108,9 +97,9 @@ struct node
struct menu_section *last_section;
};
/* This is used for a list of sections found in a node's menu.
Each struct node has such a list in the sections field. */
struct menu_section
{
struct menu_section *next;
@ -124,7 +113,6 @@ struct menu_section
/* Memory allocation and string operations. */
/* Like malloc but get fatal error if memory is exhausted. */
void *
xmalloc (size)
unsigned int size;
@ -132,12 +120,11 @@ xmalloc (size)
extern void *malloc ();
void *result = malloc (size);
if (result == NULL)
fatal ("virtual memory exhausted", 0);
fatal (_("virtual memory exhausted"), 0);
return result;
}
/* Like malloc but get fatal error if memory is exhausted. */
/* Like realloc but get fatal error if memory is exhausted. */
void *
xrealloc (obj, size)
void *obj;
@ -146,12 +133,12 @@ xrealloc (obj, size)
extern void *realloc ();
void *result = realloc (obj, size);
if (result == NULL)
fatal ("virtual memory exhausted", 0);
fatal (_("virtual memory exhausted"), 0);
return result;
}
/* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */
/* Return a newly-allocated string
whose contents concatenate those of S1, S2, S3. */
char *
concat (s1, s2, s3)
char *s1, *s2, *s3;
@ -185,7 +172,7 @@ copy_string (string, size)
/* Error message functions. */
/* Print error message. `s1' is printf control string, `s2' is arg for it. */
/* Print error message. S1 is printf control string, S2 and S3 args for it. */
/* VARARGS1 */
void
@ -194,7 +181,7 @@ error (s1, s2, s3)
{
fprintf (stderr, "%s: ", progname);
fprintf (stderr, s1, s2, s3);
fprintf (stderr, "\n");
putc ('\n', stderr);
}
/* VARARGS1 */
@ -202,9 +189,9 @@ void
warning (s1, s2, s3)
char *s1, *s2, *s3;
{
fprintf (stderr, "%s: Warning: ", progname);
fprintf (stderr, _("%s: warning: "), progname);
fprintf (stderr, s1, s2, s3);
fprintf (stderr, "\n");
putc ('\n', stderr);
}
/* Print error message and exit. */
@ -223,7 +210,7 @@ void
pfatal_with_name (name)
char *name;
{
char *s = concat ("", strerror (errno), " for %s");
char *s = concat ("", strerror (errno), _(" for %s"));
fatal (s, name);
}
@ -292,7 +279,7 @@ extract_menu_file_name (item_text)
void
suggest_asking_for_help ()
{
fprintf (stderr, "\tTry `%s --help' for a complete list of options.\n",
fprintf (stderr, _("\tTry `%s --help' for a complete list of options.\n"),
progname);
exit (1);
}
@ -300,8 +287,9 @@ suggest_asking_for_help ()
void
print_help ()
{
printf ("%s [OPTION]... [INFO-FILE [DIR-FILE]]\n\
Install INFO-FILE in the Info directory file DIR-FILE.\n\
printf (_("Usage: %s [OPTION]... [INFO-FILE [DIR-FILE]]\n\
\n\
Install INFO-FILE in the Info directory file DIR-FILE.\n\
\n\
Options:\n\
--delete Delete existing entries in INFO-FILE;\n\
@ -334,33 +322,80 @@ Options:\n\
from information in the Info file itself.\n\
--version Display version information and exit.\n\
\n\
Email bug reports to bug-texinfo@prep.ai.mit.edu.\n\
", progname);
Email bug reports to bug-texinfo@gnu.org.\n\
"), progname);
}
/* If DIRFILE does not exist, create a minimal one (or abort). If it
already exists, do nothing. */
void
ensure_dirfile_exists (dirfile)
char *dirfile;
{
int desc = open (dirfile, O_RDONLY);
if (desc < 0 && errno == ENOENT)
{
FILE *f;
char *readerr = strerror (errno);
close (desc);
f = fopen (dirfile, "w");
if (f)
{
fputs (_("This is the file .../info/dir, which contains the\n\
topmost node of the Info hierarchy, called (dir)Top.\n\
The first time you invoke Info you start off looking at this node.\n\
\n\
File: dir,\tNode: Top,\tThis is the top of the INFO tree\n\
\n\
This (the Directory node) gives a menu of major topics.\n\
Typing \"q\" exits, \"?\" lists all Info commands, \"d\" returns here,\n\
\"h\" gives a primer for first-timers,\n\
\"mEmacs<Return>\" visits the Emacs manual, etc.\n\
\n\
In Emacs, you can click mouse button 2 on a menu item or cross reference\n\
to select it.\n\
\n\
* Menu:\n\
"), f);
if (fclose (f) < 0)
pfatal_with_name (dirfile);
}
else
{
/* Didn't exist, but couldn't open for writing. */
fprintf (stderr,
_("%s: could not read (%s) and could not create (%s)\n"),
dirfile, readerr, strerror (errno));
exit (1);
}
}
else
close (desc); /* It already existed, so fine. */
}
/* This table defines all the long-named options, says whether they
use an argument, and maps them into equivalent single-letter options. */
struct option longopts[] =
{
{ "delete", no_argument, NULL, 'r' },
{ "defentry", required_argument, NULL, 'E' },
{ "defsection", required_argument, NULL, 'S' },
{ "dir-file", required_argument, NULL, 'd' },
{ "entry", required_argument, NULL, 'e' },
{ "forceentry", required_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
{ "info-dir", required_argument, NULL, 'D' },
{ "info-file", required_argument, NULL, 'i' },
{ "item", required_argument, NULL, 'e' },
{ "quiet", no_argument, NULL, 'q' },
{ "remove", no_argument, NULL, 'r' },
{ "section", required_argument, NULL, 's' },
{ "version", no_argument, NULL, 'V' },
{ "delete", no_argument, NULL, 'r' },
{ "dir-file", required_argument, NULL, 'd' },
{ "entry", required_argument, NULL, 'e' },
{ "help", no_argument, NULL, 'h' },
{ "info-dir", required_argument, NULL, 'D' },
{ "info-file", required_argument, NULL, 'i' },
{ "item", required_argument, NULL, 'e' },
{ "quiet", no_argument, NULL, 'q' },
{ "remove", no_argument, NULL, 'r' },
{ "section", required_argument, NULL, 's' },
{ "version", no_argument, NULL, 'V' },
{ 0 }
};
int
main (argc, argv)
int argc;
char **argv;
@ -407,6 +442,15 @@ main (argc, argv)
progname = argv[0];
#ifdef HAVE_SETLOCALE
/* Set locale via LC_ALL. */
setlocale (LC_ALL, "");
#endif
/* Set the text message domain. */
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
while (1)
{
int opt = getopt_long (argc, argv, "i:d:e:s:hHr", longopts, 0);
@ -427,7 +471,7 @@ main (argc, argv)
case 'd':
if (dirfile)
{
fprintf (stderr, "%s: Specify the Info directory only once.\n",
fprintf (stderr, _("%s: Specify the Info directory only once.\n"),
progname);
suggest_asking_for_help ();
}
@ -437,7 +481,7 @@ main (argc, argv)
case 'D':
if (dirfile)
{
fprintf (stderr, "%s: Specify the Info directory only once.\n",
fprintf (stderr, _("%s: Specify the Info directory only once.\n"),
progname);
suggest_asking_for_help ();
}
@ -476,7 +520,7 @@ main (argc, argv)
case 'i':
if (infile)
{
fprintf (stderr, "%s: Specify the Info file only once.\n",
fprintf (stderr, _("%s: Specify the Info file only once.\n"),
progname);
suggest_asking_for_help ();
}
@ -507,12 +551,13 @@ main (argc, argv)
break;
case 'V':
puts (INSTALL_INFO_VERSION_STRING);
puts ("Copyright (C) 1996 Free Software Foundation, Inc.\n\
printf ("install-info (GNU %s) %s\n", PACKAGE, VERSION);
printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\
There is NO warranty. You may redistribute this software\n\
under the terms of the GNU General Public License.\n\
For more information about these matters, see the files named COPYING.");
exit (0);
For more information about these matters, see the files named COPYING.\n"),
"1998");
exit (0);
default:
suggest_asking_for_help ();
@ -530,13 +575,13 @@ For more information about these matters, see the files named COPYING.");
else if (dirfile == 0)
dirfile = argv[optind];
else
error ("excess command line argument `%s'", argv[optind]);
error (_("excess command line argument `%s'"), argv[optind]);
}
if (!infile)
fatal ("No input file specified");
fatal (_("No input file specified; try --help for more information."));
if (!dirfile)
fatal ("No dir file specified");
fatal (_("No dir file specified; try --help for more information."));
/* Read the Info file and parse it into lines. */
@ -595,7 +640,7 @@ For more information about these matters, see the files named COPYING.");
&& sizeof ("START-INFO-DIR-ENTRY") - 1 == input_lines[i].size)
{
if (start_of_this_entry != 0)
fatal ("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY");
fatal (_("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY"));
start_of_this_entry = input_lines[i + 1].start;
}
if (!strncmp ("END-INFO-DIR-ENTRY", input_lines[i].start,
@ -621,18 +666,26 @@ For more information about these matters, see the files named COPYING.");
start_of_this_entry = 0;
}
else
fatal ("END-INFO-DIR-ENTRY without matching START-INFO-DIR-ENTRY");
fatal (_("END-INFO-DIR-ENTRY without matching START-INFO-DIR-ENTRY"));
}
}
if (start_of_this_entry != 0)
fatal ("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY");
fatal (_("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY"));
}
if (!delete_flag)
if (entries_to_add == 0)
fatal ("no info dir entry in `%s'", infile);
{ /* No need to abort here, the original info file may not have
the requisite Texinfo commands. This is not something an
installer should have to correct (it's a problem for the
maintainer), and there's no need to cause subsequent parts of
`make install' to fail. */
warning (_("no info dir entry in `%s'"), infile);
exit (0);
}
/* Now read in the Info dir file. */
ensure_dirfile_exists (dirfile);
dir_data = readfile (dirfile, &dir_size);
dir_lines = findlines (dir_data, dir_size, &dir_nlines);
@ -641,7 +694,6 @@ For more information about these matters, see the files named COPYING.");
.info suffix. */
{
unsigned basename_len;
extern char *strrchr ();
char *infile_basename = strrchr (infile, '/');
if (infile_basename)
infile_basename++;
@ -761,10 +813,13 @@ For more information about these matters, see the files named COPYING.");
p++;
if ((dir_lines[i].size
> (p - dir_lines[i].start + infilelen_sans_info))
&& !strncmp(p, infile_sans_info, infilelen_sans_info)
&& ( p[infilelen_sans_info] == ')' ||
strncmp (p + infilelen_sans_info, ".info)", 6) == 0))
dir_lines[i].delete = 1;
&& !strncmp (p, infile_sans_info, infilelen_sans_info)
&& (p[infilelen_sans_info] == ')'
|| !strncmp (p + infilelen_sans_info, ".info)", 6)))
{
dir_lines[i].delete = 1;
something_deleted = 1;
}
}
}
/* Treat lines that start with whitespace
@ -836,7 +891,7 @@ For more information about these matters, see the files named COPYING.");
dir_lines[i].start,
dir_lines[i].size)
&& !dir_lines[i].delete)
fatal ("menu item `%s' already exists, for file `%s'",
fatal (_("menu item `%s' already exists, for file `%s'"),
extract_menu_item_name (entry->text),
extract_menu_file_name (dir_lines[i].start));
if (dir_lines[i].start[0] == '*'
@ -859,7 +914,7 @@ For more information about these matters, see the files named COPYING.");
}
if (delete_flag && !something_deleted && !quiet_flag)
warning ("no entries found for `%s'; nothing deleted", infile);
warning (_("no entries found for `%s'; nothing deleted"), infile);
/* Output the old dir file, interpolating the new sections
and/or new entries where appropriate. */
@ -951,19 +1006,49 @@ readfile (filename, sizep)
char *filename;
int *sizep;
{
int desc;
int data_size = 1024;
char *data = (char *) xmalloc (data_size);
int filled = 0;
int nread = 0;
#ifdef HAVE_LIBZ
int isGZ = 0;
gzFile zdesc;
#endif
int desc = open (filename, O_RDONLY);
desc = open (filename, O_RDONLY);
if (desc < 0)
pfatal_with_name (filename);
#ifdef HAVE_LIBZ
/* The file should always be two bytes long. */
if (read (desc, data, 2) != 2)
pfatal_with_name (filename);
/* Undo that read. */
lseek (desc, 0, SEEK_SET);
/* If we see gzip magic, use gzdopen. */
if (data[0] == '\x1f' && data[1] == '\x8b')
{
isGZ = 1;
zdesc = gzdopen (desc, "r");
if (zdesc == NULL) {
close (desc);
pfatal_with_name (filename);
}
}
#endif /* HAVE_LIBZ */
while (1)
{
nread = read (desc, data + filled, data_size - filled);
#ifdef HAVE_LIBZ
if (isGZ)
nread = gzread (zdesc, data + filled, data_size - filled);
else
#endif
nread = read (desc, data + filled, data_size - filled);
if (nread < 0)
pfatal_with_name (filename);
if (nread == 0)
@ -978,6 +1063,14 @@ readfile (filename, sizep)
}
*sizep = filled;
#ifdef HAVE_LIBZ
if (isGZ)
gzclose (zdesc);
else
#endif
close(desc);
return data;
}