diff options
Diffstat (limited to 'contrib/texinfo/info/info.c')
-rw-r--r-- | contrib/texinfo/info/info.c | 100 |
1 files changed, 63 insertions, 37 deletions
diff --git a/contrib/texinfo/info/info.c b/contrib/texinfo/info/info.c index 4f4999c..33aacdf 100644 --- a/contrib/texinfo/info/info.c +++ b/contrib/texinfo/info/info.c @@ -1,7 +1,8 @@ /* info.c -- Display nodes of Info files in multiple windows. - $Id: info.c,v 1.41 1999/09/25 16:10:04 karl Exp $ + $Id: info.c,v 1.53 2002/03/02 15:18:58 karl Exp $ - Copyright (C) 1993, 96, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1993, 96, 97, 98, 99, 2000, 01, 02 + 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 @@ -76,6 +77,9 @@ int dump_subnodes = 0; /* Non-zero means make default keybindings be loosely modeled on vi(1). */ int vi_keys_p = 0; +/* Non-zero means don't remove ANSI escape sequences from man pages. */ +int raw_escapes_p = 0; + #ifdef __MSDOS__ /* Non-zero indicates that screen output should be made 'speech-friendly'. Since on MSDOS the usual behavior is to write directly to the video @@ -99,6 +103,7 @@ static struct option long_options[] = { { "file", 1, 0, 'f' }, { "subnodes", 0, &dump_subnodes, 1 }, { "output", 1, 0, 'o' }, + { "raw-escapes", 0, &raw_escapes_p, 1 }, { "show-options", 0, 0, 'O' }, { "usage", 0, 0, 'O' }, { "vi-keys", 0, &vi_keys_p, 1 }, @@ -115,9 +120,9 @@ 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:Osb"; +static char *short_options = "d:n:f:o:ORsb"; #else -static char *short_options = "d:n:f:o:Os"; +static char *short_options = "d:n:f:o:ORs"; #endif /* When non-zero, the Info window system has been initialized. */ @@ -126,6 +131,7 @@ int info_windows_initialized_p = 0; /* Some "forward" declarations. */ static void info_short_help (), remember_info_program_name (); static void init_messages (); +extern void add_file_directory_to_path (); /* **************************************************************** */ @@ -206,6 +212,12 @@ main (argc, argv) goto_invocation_p = 1; break; + /* User has specified that she wants the escape sequences + in man pages to be passed thru unaltered. */ + case 'R': + raw_escapes_p = 1; + break; + /* User is specifying that she wishes to dump the subnodes of the node that she is dumping. */ case 's': @@ -213,7 +225,7 @@ main (argc, argv) break; #ifdef __MSDOS__ - /* User specifies that she wants speech-friendly output. */ + /* User wants speech-friendly output. */ case 'b': speech_friendly = 1; break; @@ -268,7 +280,7 @@ main (argc, argv) 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.\n"), - "1999"); + "2002"); xexit (0); } @@ -313,25 +325,7 @@ For more information about these matters, see the files named COPYING.\n"), /* If the user specified a particular filename, add the path of that file to the contents of INFOPATH. */ if (user_filename) - { - char *directory_name = xstrdup (user_filename); - char *temp = filename_non_directory (directory_name); - - if (temp != directory_name) - { - if (HAVE_DRIVE (directory_name) && temp == directory_name + 2) - { - /* The directory of "d:foo" is stored as "d:.", to avoid - mixing it with "d:/" when a slash is appended. */ - *temp = '.'; - temp += 2; - } - temp[-1] = 0; - info_add_path (directory_name, INFOPATH_PREPEND); - } - - free (directory_name); - } + add_file_directory_to_path (user_filename); /* If the user wants to search every known index for a given string, do that now, and report the results. */ @@ -382,13 +376,14 @@ For more information about these matters, see the files named COPYING.\n"), char *errstr, *errarg1, *errarg2; NODE *new_initial_node = info_follow_menus (initial_node, argv + optind, &errstr, &errarg1, &errarg2); + if (new_initial_node && new_initial_node != initial_node) initial_node = new_initial_node; /* If the user specified that this node should be output, then do that now. Otherwise, start the Info session with this node. Or act accordingly if the initial node was not found. */ - if (user_output_filename) + if (user_output_filename && !goto_invocation_p) { if (!errstr) dump_node_to_file (initial_node, user_output_filename, @@ -447,7 +442,13 @@ For more information about these matters, see the files named COPYING.\n"), free (program); } - info_read_and_dispatch (); + if (user_output_filename) + { + dump_node_to_file (windows->node, user_output_filename, + dump_subnodes); + } + else + info_read_and_dispatch (); /* On program exit, leave the cursor at the bottom of the window, and restore the terminal IO. */ @@ -474,6 +475,29 @@ For more information about these matters, see the files named COPYING.\n"), } } +void +add_file_directory_to_path (filename) + char *filename; +{ + char *directory_name = xstrdup (filename); + char *temp = filename_non_directory (directory_name); + + if (temp != directory_name) + { + if (HAVE_DRIVE (directory_name) && temp == directory_name + 2) + { + /* The directory of "d:foo" is stored as "d:.", to avoid + mixing it with "d:/" when a slash is appended. */ + *temp = '.'; + temp += 2; + } + temp[-1] = 0; + info_add_path (directory_name, INFOPATH_PREPEND); + } + + free (directory_name); +} + /* Error handling. */ @@ -527,6 +551,14 @@ info_error (format, arg1, arg2) static void info_short_help () { +#ifdef __MSDOS__ + static const char speech_friendly_string[] = N_("\ + --speech-friendly be friendly to speech synthesizers.\n"); +#else + static const char speech_friendly_string[] = ""; +#endif + + printf (_("\ Usage: %s [OPTION]... [MENU-ITEM...]\n\ \n\ @@ -541,9 +573,10 @@ Options:\n\ --index-search=STRING go to node pointed by index entry STRING.\n\ --node=NODENAME specify nodes in first visited Info file.\n\ --output=FILENAME output selected nodes to FILENAME.\n\ + --raw-escapes don't remove ANSI escapes from man pages.\n\ --restore=FILENAME read initial keystrokes from FILENAME.\n\ - --show-options, --usage go to command-line options node.\n\ - --subnodes recursively output menu items.\n%s\ + --show-options, --usage go to command-line options node.\n%s\ + --subnodes recursively output menu items.\n\ --vi-keys use vi-like and less-like key bindings.\n\ --version display version information and exit.\n\ \n\ @@ -563,14 +596,7 @@ Examples:\n\ Email bug reports to bug-texinfo@gnu.org,\n\ general questions and discussion to help-texinfo@gnu.org.\n\ "), - program_name, -#ifdef __MSDOS__ -"\ - --speech-friendly be friendly to speech synthesizers.\n" -#else -"" -#endif - ); + program_name, speech_friendly_string); xexit (0); } |