changeset 173:c74bb6e6c838

[project @ 1993-10-21 22:43:36 by jwe]
author jwe
date Thu, 21 Oct 1993 22:43:36 +0000
parents 0597476bbe6d
children ef33b132b192
files info/Makefile.in info/indices.c info/indices.h info/info.c info/session.c info/signals.c info/termdep.h info/terminal.c
diffstat 8 files changed, 270 insertions(+), 157 deletions(-) [+]
line wrap: on
line diff
--- a/info/Makefile.in	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/Makefile.in	Thu Oct 21 22:43:36 1993 +0000
@@ -17,49 +17,25 @@
 
 #### Start of system configuration section. ####
 
-srcdir = @srcdir@
-VPATH  = $(srcdir):$(common)
+TOPDIR = ..
 
-common = $(srcdir)/../libtxi
-
-CC = @CC@
+include $(TOPDIR)/Makeconf
 
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
+srcdir = @srcdir@
+VPATH  = @srcdir@:@srcdir@/../src
 
-LN	= ln
-RM	= rm -f
-TAR	= tar
-MKDIR	= mkdir
-MAKEINFO= ../makeinfo/makeinfo
-COMPRESS= compress
+common = @srcdir@/../src
 
-DEFS = @DEFS@
+MAKEINFO= makeinfo
 
 LDEFS = -DNAMED_FUNCTIONS=1 -DDEFAULT_INFOPATH='"$(DEFAULT_INFOPATH)"'
 
 TERMLIBS = @TERMLIBS@
-LIBS = $(TERMLIBS) -L../libtxi -ltxi @LIBS@
+LIBS = $(TERMLIBS) @LIBS@
 LOADLIBES = $(LIBS)
 
 SHELL = /bin/sh
 
-CFLAGS = -g
-LDFLAGS = -g
-
-prefix = /usr/local
-exec_prefix = $(prefix)
-bindir = $(exec_prefix)/bin
-# Prefix for each installed program, normally empty or `g'.
-binprefix = 
-libdir = $(prefix)/lib
-# Prefix for each installed man page, normally empty or `g'.
-manprefix = 
-mandir = $(prefix)/man/man1
-manext = 1
-infodir = $(prefix)/info
-
 #### End of system configuration section. ####
 
 SRCS =	dir.c		display.c	echo_area.c	filesys.c \
@@ -67,7 +43,8 @@
 	m-x.c		nodes.c		search.c	session.c \
 	signals.c	terminal.c	tilde.c		window.c \
 	xmalloc.c	indices.c	makedoc.c	nodemenu.c \
-	footnotes.c	dribble.c	variables.c	gc.c
+	footnotes.c	dribble.c	variables.c	gc.c \
+	error.c
 
 HDRS =	display.h	doc.h		echo_area.h	filesys.h \
 	general.h	getopt.h	info-utils.h	info.h \
@@ -76,10 +53,16 @@
 	indices.h	window.h	footnotes.h	dribble.h \
 	variables.h	gc.h
 
-OBJS =	dir.o display.o doc.o echo_area.o filesys.o info-utils.o info.o \
+DISTFILES = $(SRCS) $(HDRS)
+
+GETOPT_OBJS = getopt.o getopt1.o
+
+LIBOBJS = dir.o display.o doc.o echo_area.o filesys.o info-utils.o \
 	infodoc.o infomap.o m-x.o nodes.o search.o session.o signals.o \
 	terminal.o tilde.o window.o indices.o xmalloc.o nodemenu.o \
-	footnotes.o dribble.o variables.o gc.o 
+	footnotes.o dribble.o variables.o gc.o error.o
+
+OBJS = info.o $(LIBOBJS) $(GETOPT_OBJS)
 
 # The names of files which declare info commands.
 CMDFILES = $(srcdir)/session.c $(srcdir)/echo_area.c $(srcdir)/infodoc.c \
@@ -91,24 +74,30 @@
 MAKEDOC_SOURCE = makedoc.c xmalloc.c
 
 .c.o:
-	$(CC) -c $(CPPFLAGS) $(LDEFS) $(DEFS) -I. -I$(srcdir) -I$(common) $(CFLAGS) $<
+	$(CC) -c $(CPPFLAGS) $(LDEFS) -I$(common) $(ALL_CFLAGS) $<
 
-all: info info.info info-stnd.info
+all: ../libinfo.a # info.info info-stnd.info
 sub-all: all
 
 install: all
-	$(INSTALL_PROGRAM) info $(bindir)/info
-	-d=$(srcdir); test -f ./info.info && d=.; $(INSTALL_DATA) $$d/info.info $(infodir)/info.info
-	-d=$(srcdir); test -f ./info-stnd.info && d=.; $(INSTALL_DATA) $$d/info-stnd.info $(infodir)/info-stnd.info
-	-$(INSTALL_DATA) $(srcdir)/info.1 $(mandir)/info.$(manext)
+	$(INSTALL_PROGRAM) info $(datadir)/info
+#	-d=$(srcdir); test -f ./info.info && d=.; \
+#	    $(INSTALL_DATA) $$d/info.info $(infodir)/info.info
+#	-d=$(srcdir); test -f ./info-stnd.info && d=.; \
+#	    $(INSTALL_DATA) $$d/info-stnd.info $(infodir)/info-stnd.info
+#	-$(INSTALL_DATA) $(srcdir)/info.1 $(mandir)/info.$(manext)
 
 uninstall:
-	rm -f $(bindir)/info
-	rm -f $(infodir)/info.info
-	rm -f $(infodir)/info-stnd.info
-	rm -f $(mandir)/info.$(manext)
+	rm -f $(libexecdir)/info
+#	rm -f $(infodir)/info.info
+#	rm -f $(infodir)/info-stnd.info
+#	rm -f $(mandir)/info.$(manext)
 
-info: $(OBJS) ../libtxi/libtxi.a
+../libinfo.a: $(LIBOBJS)
+	$(AR) $(ARFLAGS) ../libinfo.a $(LIBOBJS)
+	$(RANLIB) ../libinfo.a
+
+info: $(OBJS)
 	$(CC) $(LDFLAGS) -o info $(OBJS) $(LOADLIBES)
 
 info.info: info.texi
@@ -117,7 +106,7 @@
 info-stnd.info: info-stnd.texi
 	$(MAKEINFO) --no-split -I$(srcdir) info-stnd.texi
 
-makedoc: $(MAKEDOC_OBJECTS) ../libtxi/libtxi.a
+makedoc: $(MAKEDOC_OBJECTS)
 	$(CC) $(LDFLAGS) -o makedoc $(MAKEDOC_OBJECTS) $(LOADLIBES)
 
 Makefile: $(srcdir)/Makefile.in ../config.status
@@ -135,6 +124,14 @@
 	rm -f funs.h doc.c
 	rm -f info.info info-stnd.info
 
+local-dist:
+	ln $(DISTFILES) ../`cat ../.fname`/info
+.PHONY: local-dist
+
+dist:
+	ln $(DISTFILES) ../`cat ../.fname`/info
+.PHONY: dist
+
 TAGS: $(SRCS) makedoc-TAGS
 	etags $(SRCS)
 	cat makedoc-TAGS >>TAGS && rm -f makedoc-TAGS
--- a/info/indices.c	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/indices.c	Thu Oct 21 22:43:36 1993 +0000
@@ -176,6 +176,15 @@
 DECLARE_INFO_COMMAND (info_index_search,
    "Look up a string in the index for this file")
 {
+  do_info_index_search (window, count, 0);
+}
+
+void
+do_info_index_search (window, count, search_string)
+     WINDOW *window;
+     int count;
+     char *search_string;
+{
   FILE_BUFFER *fb;
   char *line;
 
@@ -204,35 +213,40 @@
       return;
     }
 
-  /* Okay, there is an index.  Let the user select one of the members of it. */
-  line =
-    info_read_maybe_completing (window, "Index entry: ", index_index);
-
-  window = active_window;
+  if (search_string && *search_string)
+    line = savestring (search_string);
+  else
+    {
+      /* Okay, there is an index.  Let the user select one of the
+	 members of it. */ 
+      line = info_read_maybe_completing (window, "Index entry: ", index_index);
 
-  /* User aborted? */
-  if (!line)
-    {
-      info_abort_key (active_window, 1, 0);
-      return;
-    }
+      window = active_window;
+
+      /* User aborted? */
+      if (!line)
+	{
+	  info_abort_key (active_window, 1, 0);
+	  return;
+	}
 
-  /* Empty line means move to the Index node. */
-  if (!*line)
-    {
-      free (line);
-
-      if (initial_index_filename && initial_index_nodename)
+      /* Empty line means move to the Index node. */
+      if (!*line)
 	{
-	  NODE *node;
+	  free (line);
+
+	  if (initial_index_filename && initial_index_nodename)
+	    {
+	      NODE *node;
 
-	  node =
-	    info_get_node (initial_index_filename, initial_index_nodename);
-	  set_remembered_pagetop_and_point (window);
-	  window_set_node_of_window (window, node);
-	  remember_window_and_node (window, node);
-	  window_clear_echo_area ();
-	  return;
+	      node =
+		info_get_node (initial_index_filename, initial_index_nodename);
+	      set_remembered_pagetop_and_point (window);
+	      window_set_node_of_window (window, node);
+	      remember_window_and_node (window, node);
+	      window_clear_echo_area ();
+	      return;
+	    }
 	}
     }
 
@@ -267,6 +281,53 @@
   }
 }
 
+int
+index_entry_exists (window, string)
+     WINDOW *window;
+     char *string;
+{
+  register int i;
+  FILE_BUFFER *fb;
+
+  /* If there is no previous search string, the user hasn't built an index
+     yet. */
+  if (!string)
+    return 0;
+
+  fb = file_buffer_of_window (window);
+  if (!initial_index_filename ||
+      (strcmp (initial_index_filename, fb->filename) != 0))
+    {
+      info_free_references (index_index);
+      index_index = info_indices_of_file_buffer (fb);
+    }
+
+  /* If there is no index, that is an error. */
+  if (!index_index)
+    return 0;
+
+  for (i = 0; (i > -1) && (index_index[i]); i++)
+    if (strcmp (string, index_index[i]->label) == 0)
+      break;
+
+  /* If that failed, look for the next substring match. */
+  if ((i < 0) || (!index_index[i]))
+    {
+      for (i = 0; (i > -1) && (index_index[i]); i++)
+	if (string_in_line (string, index_index[i]->label) != -1)
+	  break;
+
+      if ((i > -1) && (index_index[i]))
+	string_in_line (string, index_index[i]->label);
+    }
+
+  /* If that failed, return 0. */
+  if ((i < 0) || (!index_index[i]))
+    return 0;
+
+  return 1;
+}
+
 DECLARE_INFO_COMMAND (info_next_index_match,
  "Go to the next matching index item from the last `\\[index-search]' command")
 {
@@ -664,4 +725,3 @@
   if (!info_error_was_printed)
     window_clear_echo_area ();
 }
-
--- a/info/indices.h	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/indices.h	Thu Oct 21 22:43:36 1993 +0000
@@ -35,5 +35,6 @@
 
 /* User visible functions declared in indices.c. */
 extern void info_index_search (), info_next_index_match ();
+extern void do_info_index_search ();
 
 #endif /* !_INDICES_H_ */
--- a/info/info.c	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/info.c	Thu Oct 21 22:43:36 1993 +0000
@@ -23,19 +23,23 @@
 
 #include "info.h"
 #include "dribble.h"
+#include "terminal.h"
 #include "getopt.h"
 
-/* The version numbers of this version of Info. */
-int info_major_version = 2;
-int info_minor_version = 10;
-int info_patch_level = 1;
-
 /* Non-zero means search all indices for APROPOS_SEARCH_STRING. */
 static int apropos_p = 0;
 
 /* Variable containing the string to search for when apropos_p is non-zero. */
 static char *apropos_search_string = (char *)NULL;
 
+/* Non-zero means search all indices for INDEX_SEARCH_STRING.  Unlike
+   apropos, this puts the user at the node, running info. */
+static int index_search_p = 0;
+
+/* Variable containing the string to search for when index_search_p is
+   non-zero. */ 
+static char *index_search_string = (char *)NULL;
+
 /* Non-zero means print version info only. */
 static int print_version_p = 0;
 
@@ -67,6 +71,7 @@
 #define APROPOS_OPTION 1
 #define DRIBBLE_OPTION 2
 #define RESTORE_OPTION 3
+#define IDXSRCH_OPTION 4
 static struct option long_options[] = {
   { "apropos", 1, 0, APROPOS_OPTION },
   { "directory", 1, 0, 'd' },
@@ -78,15 +83,13 @@
   { "version", 0, &print_version_p, 1 },
   { "dribble", 1, 0, DRIBBLE_OPTION },
   { "restore", 1, 0, RESTORE_OPTION },
+  { "index-search", 1, 0, IDXSRCH_OPTION },
   {NULL, 0, NULL, 0}
 };
 
 /* String describing the shorthand versions of the long options found above. */
 static char *short_options = "d:n:f:o:s";
 
-/* When non-zero, the Info window system has been initialized. */
-int info_windows_initialized_p = 0;
-
 /* Some "forward" declarations. */
 static void usage (), info_short_help (), remember_info_program_name ();
 
@@ -182,6 +185,13 @@
 	  info_set_input_from_file (optarg);
 	  break;
 
+	  /* User has specified a string to search all indices for. */
+	case IDXSRCH_OPTION:
+	  index_search_p = 1;
+	  maybe_free (index_search_string);
+	  index_search_string = savestring (optarg);
+	  break;
+
 	default:
 	  usage ();
 	}
@@ -276,6 +286,37 @@
       exit (0);
     }
 
+  /* If the user specified `--index-search string', start the info
+     session in the node corresponding to the first match. */
+  if (index_search_p)
+    {
+      int status = 0;
+
+      initialize_info_session (initial_node, 0);
+
+      if (index_entry_exists (windows, index_search_string))
+	{
+	  terminal_clear_screen ();
+	  terminal_prep_terminal ();
+	  display_update_display (windows);
+	  info_last_executed_command = (VFunction *)NULL;
+
+	  do_info_index_search (windows, 0, index_search_string);
+
+	  info_read_and_dispatch ();
+
+	  terminal_unprep_terminal ();
+	}
+      else
+	{
+	  fprintf (stderr, "no entries found\n");
+	  status = 13;
+	}
+
+      close_dribble_file (); 
+      exit (status);
+    }
+
   /* If there are arguments remaining, they are the names of menu items
      in sequential info files starting from the first one loaded.  That
      file name is either "dir", or the contents of user_filename if one
@@ -391,28 +432,6 @@
   exit (0);
 }
 
-/* Return a string describing the current version of Info. */
-char *
-version_string ()
-{
-  static char *vstring = (char *)NULL;
-
-  if (!vstring)
-    {
-      vstring = (char *)xmalloc (50);
-      sprintf (vstring, "%d.%d", info_major_version, info_minor_version);
-      if (info_patch_level)
-	sprintf (vstring + strlen (vstring), "-p%d", info_patch_level);
-    }
-  return (vstring);
-}
-
-/* **************************************************************** */
-/*								    */
-/*		   Error Handling for Info			    */
-/*								    */
-/* **************************************************************** */
-
 static char *program_name = (char *)NULL;
 
 static void
@@ -425,51 +444,6 @@
   program_name = savestring (filename);
 }
 
-/* Non-zero if an error has been signalled. */
-int info_error_was_printed = 0;
-
-/* Non-zero means ring terminal bell on errors. */
-int info_error_rings_bell_p = 1;
-
-/* Print FORMAT with ARG1 and ARG2.  If the window system was initialized,
-   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_was_printed = 1;
-
-  if (!info_windows_initialized_p || display_inhibited)
-    {
-      fprintf (stderr, "%s: ", program_name);
-      fprintf (stderr, format, arg1, arg2);
-      fprintf (stderr, "\n");
-      fflush (stderr);
-    }
-  else
-    {
-      if (!echo_area_is_active)
-	{
-	  if (info_error_rings_bell_p)
-	    terminal_ring_bell ();
-	  window_message_in_echo_area (format, arg1, arg2);
-	}
-      else
-	{
-	  NODE *temp;
-
-	  temp = build_message_node (format, arg1, arg2);
-	  if (info_error_rings_bell_p)
-	    terminal_ring_bell ();
-	  inform_in_echo_area (temp->contents);
-	  free (temp->contents);
-	  free (temp);
-	}
-    }
-}
-
 /* Produce a very brief descripton of the available options and exit with
    an error. */
 static void
--- a/info/session.c	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/session.c	Thu Oct 21 22:43:36 1993 +0000
@@ -62,6 +62,7 @@
 void remember_window_and_node (), forget_window_and_nodes ();
 void initialize_info_session (), info_session ();
 void display_startup_message_and_start ();
+void finish_info_session ();
 
 /* Begin an info session finding the nodes specified by FILENAME and NODENAMES.
    For each loaded node, create a new window.  Always split the largest of the
@@ -86,7 +87,7 @@
       /* If this is the first node, initialize the info session. */
       if (!window)
 	{
-	  initialize_info_session (node);
+	  initialize_info_session (node, 1);
 	  window = active_window;
 	}
       else
@@ -139,7 +140,7 @@
      char *format;
      void *arg;
 {
-  initialize_info_session (initial_node);
+  initialize_info_session (initial_node, 1);
   info_error (format, arg, (void *)NULL);
   info_session ();
 }
@@ -149,11 +150,18 @@
 begin_info_session (initial_node)
      NODE *initial_node;
 {
-  initialize_info_session (initial_node);
+  initialize_info_session (initial_node, 1);
   display_startup_message_and_start ();
 }
 
 void
+finish_info_session ()
+{
+  close_dribble_file ();
+  clear_info_signal_handler ();
+}
+
+void
 display_startup_message_and_start ()
 {
   char *format;
@@ -251,8 +259,9 @@
 /* Initialize the first info session by starting the terminal, window,
    and display systems. */
 void
-initialize_info_session (node)
+initialize_info_session (node, clear_screen)
      NODE *node;
+     int clear_screen;
 {
   char *getenv (), *term_name;
 
@@ -267,7 +276,8 @@
       info_error (TERM_TOO_DUMB, term_name);
       exit (1);
     }
-  terminal_clear_screen ();
+  if (clear_screen)
+    terminal_clear_screen ();
   initialize_info_keymaps ();
   window_initialize_windows (screenwidth, screenheight);
   initialize_info_signal_handler ();
@@ -3645,11 +3655,15 @@
      char *keyseq;
 {
   char *rep;
+  char *format;
 
   rep = pretty_keyseq (keyseq);
 
+  format = replace_in_documentation
+    ("Unknown command (%s).  Type \"\\[quit]\" to quit, \"\\[get-help-window]\" for help.");
+
   if (!echo_area_is_active)
-    info_error ("Unknown command (%s).", rep);
+    info_error (format, rep); 
   else
     {
       char *temp;
--- a/info/signals.c	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/signals.c	Thu Oct 21 22:43:36 1993 +0000
@@ -91,6 +91,24 @@
 #endif
 }
 
+void
+clear_info_signal_handler ()
+{
+#if defined (SIGTSTP)
+  signal (SIGTSTP, old_TSTP);
+  signal (SIGTTOU, old_TTOU);
+  signal (SIGTTIN, old_TTIN);
+#endif /* SIGTSTP */
+
+#if defined (SIGWINCH)
+  signal (SIGWINCH, old_WINCH);
+#endif
+
+#if defined (SIGINT)
+  signal (SIGINT, old_INT);
+#endif
+}
+
 static void
 redisplay_after_signal ()
 {
--- a/info/termdep.h	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/termdep.h	Thu Oct 21 22:43:36 1993 +0000
@@ -27,7 +27,22 @@
 #include <fcntl.h>
 #endif /* !HAVE_SYS_FCNTL_H */
 
-#if defined (HAVE_TERMIO_H)
+#if defined (HAVE_TERMIOS_H)
+
+#include <termios.h>
+#include <string.h>
+#if defined (HAVE_SYS_PTEM_H)
+#if !defined (M_XENIX)
+#include <sys/stream.h>
+#include <sys/ptem.h>
+#undef TIOCGETC
+#else /* M_XENIX */
+#define tchars tc
+#endif /* M_XENIX */
+#endif /* HAVE_SYS_PTEM_H */
+
+#elif defined (HAVE_TERMIO_H)
+
 #include <termio.h>
 #include <string.h>
 #if defined (HAVE_SYS_PTEM_H)
@@ -39,10 +54,13 @@
 #define tchars tc
 #endif /* M_XENIX */
 #endif /* HAVE_SYS_PTEM_H */
+
 #else /* !HAVE_TERMIO_H */
+
 #include <sys/file.h>
 #include <sgtty.h>
 #include <strings.h>
+
 #endif /* !HAVE_TERMIO_H */
 
 #if defined (HAVE_SYS_TTOLD_H)
--- a/info/terminal.c	Thu Oct 21 22:43:36 1993 +0000
+++ b/info/terminal.c	Thu Oct 21 22:43:36 1993 +0000
@@ -595,7 +595,10 @@
 struct ltchars original_ltchars;
 #endif
 
-#if defined (HAVE_TERMIO_H)
+#if defined (HAVE_TERMIOS_H)
+/* A buffer containing the terminal mode flags upon entry to info. */
+struct termios original_termios, ttybuff;
+#elif defined (HAVE_TERMIO_H)
 /* A buffer containing the terminal mode flags upon entry to info. */
 struct termio original_termio, ttybuff;
 #else /* !HAVE_TERMIO_H */
@@ -619,7 +622,27 @@
 
   tty = fileno (stdin);
 
-#if defined (HAVE_TERMIO_H)
+#if defined (HAVE_TERMIOS_H)
+
+  tcgetattr (tty, &original_termios);
+  tcgetattr (tty, &ttybuff);
+  ttybuff.c_iflag &= (~ISTRIP & ~INLCR & ~IGNCR & ~ICRNL & ~IXON);
+  ttybuff.c_oflag &= (~ONLCR & ~OCRNL);
+  ttybuff.c_lflag &= (~ICANON & ~ECHO);
+
+  ttybuff.c_cc[VMIN] = 1;
+  ttybuff.c_cc[VTIME] = 0;
+
+  if (ttybuff.c_cc[VINTR] = '\177')
+    ttybuff.c_cc[VINTR] = -1;
+
+  if (ttybuff.c_cc[VQUIT] = '\177')
+    ttybuff.c_cc[VQUIT] = -1;
+
+  tcsetattr (tty, TCSAFLUSH, &ttybuff);
+
+#elif defined (HAVE_TERMIO_H)
+
   ioctl (tty, TCGETA, &original_termio);
   ioctl (tty, TCGETA, &ttybuff);
   ttybuff.c_iflag &= (~ISTRIP & ~INLCR & ~IGNCR & ~ICRNL & ~IXON);
@@ -702,6 +725,7 @@
   ttybuff.sg_flags &= ~ECHO;
   ttybuff.sg_flags |= CBREAK;
   ioctl (tty, TIOCSETN, &ttybuff);
+
 #endif /* !HAVE_TERMIO_H */
 }
 
@@ -720,9 +744,16 @@
 
   tty = fileno (stdin);
 
-#if defined (HAVE_TERMIO_H)
+#if defined (HAVE_TERMIOS_H)
+
+  tcsetattr (tty, TCSAFLUSH, &original_termios);
+
+#elif defined (HAVE_TERMIO_H)
+
   ioctl (tty, TCSETA, &original_termio);
+
 #else /* !HAVE_TERMIO_H */
+
   ioctl (tty, TIOCGETP, &ttybuff);
   ttybuff.sg_flags = original_tty_flags;
   ioctl (tty, TIOCSETN, &ttybuff);