Mercurial > hg > octave-nkf
changeset 1295:34295bf6aac6
[project @ 1995-05-01 18:24:48 by jwe]
author | jwe |
---|---|
date | Mon, 01 May 1995 18:24:48 +0000 |
parents | 549b0a461fd8 |
children | f93b7fa5e113 |
files | src/help.cc |
diffstat | 1 files changed, 47 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/src/help.cc +++ b/src/help.cc @@ -25,8 +25,13 @@ #include <config.h> #endif +#include <sys/types.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif #include <signal.h> #include <stdlib.h> +#include <string.h> #include <iostream.h> #include <strstream.h> @@ -46,21 +51,6 @@ #include "help.h" #include "defun.h" -#ifdef USE_GNU_INFO -extern "C" -{ -#include "info/info.h" -#include "info/dribble.h" -#include "info/terminal.h" - -extern int initialize_info_session (); -extern int index_entry_exists (); -extern int do_info_index_search (); -extern void finish_info_session (); -extern char *replace_in_documentation (); -} -#endif - extern "C" { // XXX FIXME XXX @@ -521,63 +511,47 @@ #ifdef USE_GNU_INFO static int -try_info (const char *string, int force = 0) +try_info (const char *string) { int status = 0; + static char *cmd_str = 0; + + delete [] cmd_str; + cmd_str = 0; + + ostrstream cmd_buf; + + cmd_buf << "info --file " << user_pref.info_file; + char *directory_name = strsave (user_pref.info_file); - char *temp = filename_non_directory (directory_name); - - if (temp != directory_name) + char *file = strrchr (directory_name, '/'); + if (file) { - *temp = 0; - info_add_path (directory_name, INFOPATH_PREPEND); + file++; + *file = 0; + cmd_buf << " --directory " << directory_name; } - delete [] directory_name; - NODE *initial_node = info_get_node (user_pref.info_file, 0); + if (string) + cmd_buf << " --index-search " << string; - if (! initial_node) - { - warning ("can't find info file!\n"); - status = -1; - } - else - { - status = initialize_info_session (initial_node, 0); + cmd_buf << ends; - if (status == 0 && (force || index_entry_exists (windows, string))) - { - terminal_clear_screen (); - - terminal_prep_terminal (); - - display_update_display (windows); - - info_last_executed_command = 0; + cmd_str = cmd_buf.str (); - if (! force) - do_info_index_search (windows, 0, string); + volatile sig_handler *old_sigint_handler; + old_sigint_handler = signal (SIGINT, SIG_IGN); - char *format = replace_in_documentation - ("Type \"\\[quit]\" to quit, \"\\[get-help-window]\" for help."); - - window_message_in_echo_area (format); - - info_read_and_dispatch (); + status = system (cmd_str); - terminal_goto_xy (0, screenheight - 1); - - terminal_clear_to_eol (); - - terminal_unprep_terminal (); + signal (SIGINT, old_sigint_handler); - status = 1; - } - - finish_info_session (initial_node, 0); - } + if ((status & 0xff) == 0) + status = (signed char) ((status & 0xff00) >> 8); + else + status = 127; return status; } @@ -588,14 +562,7 @@ { #ifdef USE_GNU_INFO if (argc == 1) - { - volatile sig_handler *old_sigint_handler; - old_sigint_handler = signal (SIGINT, SIG_IGN); - - try_info (0, 1); - - signal (SIGINT, old_sigint_handler); - } + try_info (0); else { while (--argc > 0) @@ -605,17 +572,23 @@ if (! *argv || ! **argv) continue; - volatile sig_handler *old_sigint_handler; - old_sigint_handler = signal (SIGINT, SIG_IGN); + int status = try_info (*argv); - if (! try_info (*argv)) + if (status) { - message ("help", "sorry, `%s' is not indexed in the manual", - *argv); - sleep (2); + if (status < 0) + { + message ("help", + "sorry, `%s' is not indexed in the manual", + *argv); + sleep (2); + } + else + { + error ("help: unable to find info!"); + break; + } } - - signal (SIGINT, old_sigint_handler); } } #else