1
1
/* info.c -- Display nodes of Info files in multiple windows.
2
$Id: info.c,v 1.20 2007/09/01 00:05:23 karl Exp $
2
$Id: info.c,v 1.33 2008/08/14 17:36:13 karl Exp $
4
4
Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
5
2004, 2005, 2007 Free Software Foundation, Inc.
5
2004, 2005, 2007, 2008 Free Software Foundation, Inc.
7
7
This program is free software: you can redistribute it and/or modify
8
8
it under the terms of the GNU General Public License as published by
57
57
/* Array of the names of nodes that the user specified with "--node" on the
59
static char **user_nodenames = (char **)NULL;
59
static char **user_nodenames = NULL;
60
60
static int user_nodenames_index = 0;
61
61
static int user_nodenames_slots = 0;
63
63
/* String specifying the first file to load. This string can only be set
64
64
by the user specifying "--file" on the command line. */
65
static char *user_filename = (char *)NULL;
65
static char *user_filename = NULL;
67
67
/* String specifying the name of the file to dump nodes to. This value is
68
68
filled if the user speficies "--output" on the command line. */
69
static char *user_output_filename = (char *)NULL;
69
static char *user_output_filename = NULL;
71
71
/* Non-zero indicates that when "--output" is specified, all of the menu
72
72
items of the specified nodes (and their subnodes as well) should be
94
94
/* Structure describing the options that Info accepts. We pass this structure
95
95
to getopt_long (). If you add or otherwise change this structure, you must
96
96
also change the string which follows it. */
97
#define APROPOS_OPTION 1
98
97
#define DRIBBLE_OPTION 2
99
98
#define RESTORE_OPTION 3
100
99
#define IDXSRCH_OPTION 4
101
100
static struct option long_options[] = {
102
{ "apropos", 1, 0, APROPOS_OPTION },
101
{ "apropos", 1, 0, 'k' },
103
102
{ "directory", 1, 0, 'd' },
104
103
{ "dribble", 1, 0, DRIBBLE_OPTION },
105
104
{ "file", 1, 0, 'f' },
110
109
{ "output", 1, 0, 'o' },
111
110
{ "raw-escapes", 0, &raw_escapes_p, 1 },
112
111
{ "no-raw-escapes", 0, &raw_escapes_p, 0 },
112
{ "show-malformed-multibytes", 0, &show_malformed_multibyte_p, 1 },
113
{ "no-show-malformed-multibytes", 0, &show_malformed_multibyte_p, 0 },
113
114
{ "restore", 1, 0, RESTORE_OPTION },
114
115
{ "show-options", 0, 0, 'O' },
115
116
{ "subnodes", 0, &dump_subnodes, 1 },
153
154
#ifdef HAVE_SETLOCALE
154
155
/* Set locale via LC_ALL. */
155
156
setlocale (LC_ALL, "");
157
/* But don't use translated messages in the case when
158
string width and length can differ */
161
setenv("LANGUAGE", "C", 1);
162
setenv("LANG", "C", 1);
164
setlocale (LC_MESSAGES, "C");
166
setenv("LC_CTYPE", "C", 1);
167
setenv("LC_ALL", "C", 1);
169
157
#endif /* HAVE_SETLOCALE */
171
159
#ifdef ENABLE_NLS
411
399
const char *errstr;
412
400
char *errarg1, *errarg2;
414
NODE *new_initial_node = info_follow_menus (initial_node, argv + optind,
401
NODE *new_initial_node;
403
/* If they say info -O info, we want to show them the invocation node
404
for standalone info; there's nothing useful in info.texi. */
405
if (goto_invocation_p && argv[optind]
406
&& mbscasecmp (argv[optind], "info") == 0)
407
argv[optind] = "info-stnd";
409
new_initial_node = info_follow_menus (initial_node, argv + optind,
415
410
&errstr, &errarg1, &errarg2);
417
412
if (new_initial_node && new_initial_node != initial_node)
438
433
dump_node_to_file (initial_node, user_output_filename,
441
info_error ((char *) errstr, errarg1, errarg2);
436
info_error (errstr, errarg1, errarg2);
447
begin_info_session_with_error (initial_node, (char *) errstr,
442
begin_info_session_with_error (initial_node, errstr,
448
443
errarg1, errarg2);
449
444
/* If the user specified `--index-search=STRING' or
450
445
--show-options, start the info session in the node
561
556
then the message is printed in the echo area. Otherwise, a message is
562
557
output to stderr. */
564
info_error (char *format, void *arg1, void *arg2)
559
info_error (const char *format, void *arg1, void *arg2)
566
561
info_error_was_printed = 1;
568
563
if (!info_windows_initialized_p || display_inhibited)
570
565
fprintf (stderr, "%s: ", program_name);
571
fprintf (stderr, format, arg1, arg2);
567
fprintf (stderr, format, arg1, arg2);
569
/* If we're passed a string, just print it. Otherwise a % in a
570
filename gets treated as a format specifier. */
571
fputs (format, stderr);
572
572
fprintf (stderr, "\n");
600
598
info_short_help (void)
603
static const char speech_friendly_string[] = N_("\
604
-b, --speech-friendly be friendly to speech synthesizers.\n");
606
static const char speech_friendly_string[] = "";
611
601
Usage: %s [OPTION]... [MENU-ITEM...]\n\
613
Read documentation in Info format.\n\
603
Read documentation in Info format.\n"), program_name);
616
--apropos=STRING look up STRING in all indices of all manuals.\n\
608
-k, --apropos=STRING look up STRING in all indices of all manuals.\n\
617
609
-d, --directory=DIR add DIR to INFOPATH.\n\
618
610
--dribble=FILENAME remember user keystrokes in FILENAME.\n\
619
-f, --file=FILENAME specify Info file to visit.\n\
611
-f, --file=FILENAME specify Info file to visit."));
620
614
-h, --help display this help and exit.\n\
621
615
--index-search=STRING go to node pointed by index entry STRING.\n\
622
616
-n, --node=NODENAME specify nodes in first visited Info file.\n\
623
-o, --output=FILENAME output selected nodes to FILENAME.\n\
617
-o, --output=FILENAME output selected nodes to FILENAME."));
624
620
-R, --raw-escapes output \"raw\" ANSI escapes (default).\n\
625
621
--no-raw-escapes output escapes as literal text.\n\
626
622
--restore=FILENAME read initial keystrokes from FILENAME.\n\
627
-O, --show-options, --usage go to command-line options node.\n%s\
623
-O, --show-options, --usage go to command-line options node."));
627
-b, --speech-friendly be friendly to speech synthesizers."));
628
631
--subnodes recursively output menu items.\n\
629
-w, --where, --location print physical location of Info file.\n\
630
632
--vi-keys use vi-like and less-like key bindings.\n\
631
633
--version display version information and exit.\n\
634
-w, --where, --location print physical location of Info file."));
633
637
The first non-option argument, if present, is the menu entry to start from;\n\
634
638
it is searched for in all `dir' files along INFOPATH.\n\
635
639
If it is not present, info merges all `dir' files and shows the result.\n\
636
640
Any remaining arguments are treated as the names of menu\n\
637
items relative to the initial node visited.\n\
641
items relative to the initial node visited."));
644
For a summary of key bindings, type h within Info."));
640
648
info show top-level dir menu\n\
649
info info show the general manual for Info readers\n\
650
info info-stnd show the manual specific to this Info program\n\
641
651
info emacs start at emacs node from top-level dir\n\
642
652
info emacs buffers start at buffers node within emacs manual\n\
643
653
info --show-options emacs start at node with emacs' command line options\n\
644
654
info --subnodes -o out.txt emacs dump entire manual to out.txt\n\
645
info -f ./foo.info show file ./foo.info, not searching dir\n\
647
program_name, speech_friendly_string);
655
info -f ./foo.info show file ./foo.info, not searching dir"));
650
658
Email bug reports to bug-texinfo@gnu.org,\n\