diff options
author | ru <ru@FreeBSD.org> | 2005-05-23 10:46:22 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-05-23 10:46:22 +0000 |
commit | 425ad50cfed598b20942bc8eaac772f6d5fdabb3 (patch) | |
tree | 0022d81c487eda4aa731483f5895aa1161e784dc /contrib/texinfo/info/info.c | |
parent | 5e20a003d4bd6f445f8c9d88f1fcb0697ef8c54d (diff) | |
parent | 212fa58b27874a1ac997e85e3f696ffad810e44c (diff) | |
download | FreeBSD-src-425ad50cfed598b20942bc8eaac772f6d5fdabb3.zip FreeBSD-src-425ad50cfed598b20942bc8eaac772f6d5fdabb3.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r146515,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/texinfo/info/info.c')
-rw-r--r-- | contrib/texinfo/info/info.c | 100 |
1 files changed, 65 insertions, 35 deletions
diff --git a/contrib/texinfo/info/info.c b/contrib/texinfo/info/info.c index 5fceb74..79dd024 100644 --- a/contrib/texinfo/info/info.c +++ b/contrib/texinfo/info/info.c @@ -1,8 +1,8 @@ /* info.c -- Display nodes of Info files in multiple windows. - $Id: info.c,v 1.7 2003/05/19 13:10:59 karl Exp $ + $Id: info.c,v 1.11 2004/04/11 17:56:45 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, + 2004 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 @@ -77,8 +77,11 @@ 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; +/* Non-zero means don't remove ANSI escape sequences. */ +int raw_escapes_p = 1; + +/* Non-zero means print the absolute location of the file to be loaded. */ +static int print_where_p = 0; #ifdef __MSDOS__ /* Non-zero indicates that screen output should be made 'speech-friendly'. @@ -103,15 +106,18 @@ static struct option long_options[] = { { "file", 1, 0, 'f' }, { "help", 0, &print_help_p, 1 }, { "index-search", 1, 0, IDXSRCH_OPTION }, + { "location", 0, &print_where_p, 1 }, { "node", 1, 0, 'n' }, { "output", 1, 0, 'o' }, { "raw-escapes", 0, &raw_escapes_p, 1 }, + { "no-raw-escapes", 0, &raw_escapes_p, 0 }, { "restore", 1, 0, RESTORE_OPTION }, { "show-options", 0, 0, 'O' }, { "subnodes", 0, &dump_subnodes, 1 }, { "usage", 0, 0, 'O' }, { "version", 0, &print_version_p, 1 }, { "vi-keys", 0, &vi_keys_p, 1 }, + { "where", 0, &print_where_p, 1 }, #ifdef __MSDOS__ { "speech-friendly", 0, &speech_friendly, 1 }, #endif @@ -120,18 +126,17 @@ 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:ho:ORsb"; +static char *short_options = "d:n:f:ho:ORswb"; #else -static char *short_options = "d:n:f:ho:ORs"; +static char *short_options = "d:n:f:ho:ORws"; #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 (); -static void init_messages (); -extern void add_file_directory_to_path (); +static void info_short_help (void); +static void init_messages (void); /* **************************************************************** */ @@ -141,9 +146,7 @@ extern void add_file_directory_to_path (); /* **************************************************************** */ int -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { int getopt_long_index; /* Index returned by getopt_long (). */ NODE *initial_node; /* First node loaded by Info. */ @@ -153,9 +156,11 @@ main (argc, argv) setlocale (LC_ALL, ""); #endif +#ifdef ENABLE_NLS /* Set the text message domain. */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); +#endif init_messages (); @@ -229,6 +234,11 @@ main (argc, argv) dump_subnodes = 1; break; + /* For compatibility with man, -w is --where. */ + case 'w': + print_where_p = 1; + break; + #ifdef __MSDOS__ /* User wants speech-friendly output. */ case 'b': @@ -281,11 +291,10 @@ main (argc, argv) { printf ("%s (GNU %s) %s\n", program_name, PACKAGE, VERSION); puts (""); - printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\ -There is NO warranty. You may redistribute this software\n\ + puts ("Copyright (C) 2004 Free Software Foundation, Inc."); + printf (_("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"), - "2003"); +For more information about these matters, see the files named COPYING.\n")); xexit (0); } @@ -322,7 +331,13 @@ For more information about these matters, see the files named COPYING.\n"), { info_add_path (DEFAULT_INFOPATH, INFOPATH_PREPEND); #ifdef INFODIR /* from the Makefile */ - info_add_path (INFODIR, INFOPATH_PREPEND); + info_add_path (INFODIR, INFOPATH_PREPEND); +#endif +#ifdef INFODIR2 /* from the Makefile, too */ +# ifdef INFODIR + if (!STREQ (INFODIR, INFODIR2)) +# endif + info_add_path (INFODIR2, INFOPATH_PREPEND); #endif } } @@ -349,10 +364,10 @@ For more information about these matters, see the files named COPYING.\n"), if (!initial_node) { if (info_recent_file_error) - info_error (info_recent_file_error); + info_error (info_recent_file_error, NULL, NULL); else - info_error (msg_cant_find_node, - user_nodenames ? user_nodenames[0] : "Top"); + info_error ((char *) msg_cant_find_node, + user_nodenames ? user_nodenames[0] : "Top", NULL); xexit (1); } @@ -364,7 +379,9 @@ For more information about these matters, see the files named COPYING.\n"), { free (initial_node); - if (user_output_filename) + if (print_where_p) + printf ("%s\n", user_filename ? user_filename : "unknown?!"); + else if (user_output_filename) dump_nodes_to_file (user_filename, user_nodenames, user_output_filename, dump_subnodes); else @@ -378,13 +395,27 @@ For more information about these matters, see the files named COPYING.\n"), file name is either "dir", or the contents of user_filename if one was specified. */ { - char *errstr, *errarg1, *errarg2; + const char *errstr; + char *errarg1, *errarg2; + NODE *new_initial_node = info_follow_menus (initial_node, argv + optind, - &errstr, &errarg1, &errarg2); + &errstr, &errarg1, &errarg2); if (new_initial_node && new_initial_node != initial_node) initial_node = new_initial_node; + if (print_where_p) + { + if (initial_node->parent) + printf ("%s\n", initial_node->parent); + else if (initial_node->filename + && !is_dir_name (filename_non_directory (initial_node->filename))) + printf ("%s\n", initial_node->filename); + else + xexit (1); + xexit (0); + } + /* 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. */ @@ -394,14 +425,14 @@ For more information about these matters, see the files named COPYING.\n"), dump_node_to_file (initial_node, user_output_filename, dump_subnodes); else - info_error (errstr, errarg1, errarg2); + info_error ((char *) errstr, errarg1, errarg2); } else { if (errstr) - begin_info_session_with_error (initial_node, errstr, - errarg1, errarg2); + begin_info_session_with_error (initial_node, (char *) errstr, + errarg1, errarg2); /* If the user specified `--index-search=STRING' or --show-options, start the info session in the node corresponding to what they want. */ @@ -483,8 +514,7 @@ For more information about these matters, see the files named COPYING.\n"), } void -add_file_directory_to_path (filename) - char *filename; +add_file_directory_to_path (char *filename) { char *directory_name = xstrdup (filename); char *temp = filename_non_directory (directory_name); @@ -518,9 +548,7 @@ int info_error_rings_bell_p = 1; then the message is printed in the echo area. Otherwise, a message is output to stderr. */ void -info_error (format, arg1, arg2) - char *format; - void *arg1, *arg2; +info_error (char *format, void *arg1, void *arg2) { info_error_was_printed = 1; @@ -556,7 +584,7 @@ info_error (format, arg1, arg2) /* Produce a scaled down description of the available options to Info. */ static void -info_short_help () +info_short_help (void) { #ifdef __MSDOS__ static const char speech_friendly_string[] = N_("\ @@ -580,10 +608,12 @@ Options:\n\ --index-search=STRING go to node pointed by index entry STRING.\n\ -n, --node=NODENAME specify nodes in first visited Info file.\n\ -o, --output=FILENAME output selected nodes to FILENAME.\n\ - -R, --raw-escapes don't remove ANSI escapes from man pages.\n\ + -R, --raw-escapes output \"raw\" ANSI escapes (default).\n\ + --no-raw-escapes output escapes as literal text.\n\ --restore=FILENAME read initial keystrokes from FILENAME.\n\ -O, --show-options, --usage go to command-line options node.\n%s\ --subnodes recursively output menu items.\n\ + -w, --where, --location print physical location of Info file.\n\ --vi-keys use vi-like and less-like key bindings.\n\ --version display version information and exit.\n\ \n\ @@ -634,7 +664,7 @@ const char *msg_win_too_small; const char *msg_cant_make_help; static void -init_messages () +init_messages (void) { msg_cant_find_node = _("Cannot find node `%s'."); msg_cant_file_node = _("Cannot find node `(%s)%s'."); |