fep - patch #1

Kazumasa Utashiro utashiro at sran84.sra.JUNET
Fri Jan 6 12:33:41 AEST 1989


I'm going to post some patches for command 'fep' which was
posted to comp.sources.unix last November.  Patches will
contain 5 parts.  Please apply all of them.

I've received many requests for multiple command aliasing
for cd'ing.  Patch #2 and #3 will make it possible in
following way.

	alias cd 'fep-cd !$; cd !$'

However, I don't recommend to use fep as a front-end for any
kind of shell.  It is much better to use dedicated command
like newcsh, tcsh or ksh.  I'm assuming this command to be
used for each single command.

I got many comments, suggestions and requests for fep.  I
replied to most of them by e-mail, but I couldn't reach some
of them for some e-mail link problem (especially to European
countries).  Please excuse me if you didn't get any response.

			Kazumasa Utashiro
			Software Research Associates, Inc.
			1-1-1 Hirakawa-cho, Chiyoda-ku, Tokyo 102, Japan
				UUCP:	kddlab!srava.sra.junet!utashiro
				ARPA:	utashiro%sra.junet at uunet.uu.net
				JUNET:	utashiro at sra.junet

----------------------------------------------------------------------
Description:

	* Added view-buffer function
	* Added some screen redrawing feature

*** /tmp/,RCSt1008587	Tue Aug 23 01:43:06 1988
--- fep_funcs.c	Mon Aug 22 02:01:12 1988
***************
*** 2,8
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_funcs.c,v 4.0 88/08/05 20:22:12 utashiro Rel $ (SRA)";
  #endif lint
  
  #include <stdio.h>

--- 2,8 -----
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_funcs.c,v 4.2 88/08/16 18:24:00 utashiro Exp $ (SRA)";
  #endif lint
  
  #include <stdio.h>
***************
*** 108,113
  	 "End script"},
  	{fep_repaint,			"repaint",
  	 "Repaint screen"},
  	{show_help,			"help",
  	 "Show help"},
  

--- 108,115 -----
  	 "End script"},
  	{fep_repaint,			"repaint",
  	 "Repaint screen"},
+ 	{view_buffer,			"view-buffer",
+ 	 "View buffer"},
  	{show_help,			"help",
  	 "Show help"},
  
*** /tmp/,RCSt1008597	Tue Aug 23 01:43:13 1988
--- fep_set.c	Mon Aug 22 02:01:15 1988
***************
*** 2,8
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_set.c,v 4.0 88/08/05 20:22:22 utashiro Rel $ (SRA)";
  #endif lint
  
  #include <stdio.h>

--- 2,8 -----
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_set.c,v 4.1 88/08/08 19:24:30 utashiro Exp $ (SRA)";
  #endif lint
  
  #include <stdio.h>
***************
*** 32,37
  	 "History length used by show-history",	(VAR*)0},
  	{"delimiters",		" \t",
  	 "Argument delemiter characters",	(VAR*)0},
  	{NULL,			NULL,
  	 NULL,					(VAR*)0}
  };

--- 32,39 -----
  	 "History length used by show-history",	(VAR*)0},
  	{"delimiters",		" \t",
  	 "Argument delemiter characters",	(VAR*)0},
+ 	{"buffer",		"5120",
+ 	"Output buffer size",			(VAR*)0},
  	{NULL,			NULL,
  	 NULL,					(VAR*)0}
  };
***************
*** 97,104
      char *name;
      char *value;
  {
-     set_only_var (name, value);
- 
      /*
       * Process special variable
       */

--- 99,104 -----
      char *name;
      char *value;
  {
      /*
       * Process special variable
       */
***************
*** 102,110
      /*
       * Process special variable
       */
!     if (eq (name, "history"))
! 	changeHistorySize (lookd_var ("history"));
!     if (eq (name, "prompt")) {
  	free (prompt);
  	prompt = allocAndCopyThere (value);
      }

--- 102,112 -----
      /*
       * Process special variable
       */
!     if (eq (name, "history")) {
! 	if (!changeHistorySize (atoi (value)))
! 	    return (0);
!     }
!     else if (eq (name, "prompt")) {
  	free (prompt);
  	prompt = allocAndCopyThere (value);
      }
***************
*** 108,114
  	free (prompt);
  	prompt = allocAndCopyThere (value);
      }
!     if (eq (name, "editmode")) {
  	if (eq (value, "emacs")) {
  	    editmode = EMACS;
  	    initEmacsBindings (curFuncTab, altFuncTab);

--- 110,116 -----
  	free (prompt);
  	prompt = allocAndCopyThere (value);
      }
!     else if (eq (name, "editmode")) {
  	if (eq (value, "emacs")) {
  	    editmode = EMACS;
  	    initEmacsBindings (curFuncTab, altFuncTab);
***************
*** 120,126
  	else
  	    printf ("%s: Unknown editmode\n", value);
      }
!     if (eq (name, "auto-tty-fix"))
  	auto_tty_fix = ON;
      if (eq (name, "debug"))
  	debug = ON;

--- 122,128 -----
  	else
  	    printf ("%s: Unknown editmode\n", value);
      }
!     else if (eq (name, "auto-tty-fix"))
  	auto_tty_fix = ON;
      else if (eq (name, "debug"))
  	debug = ON;
***************
*** 122,128
      }
      if (eq (name, "auto-tty-fix"))
  	auto_tty_fix = ON;
!     if (eq (name, "debug"))
  	debug = ON;
      if (eq (name, "tty-fix-bell"))
  	tty_fix_bell = ON;

--- 124,130 -----
      }
      else if (eq (name, "auto-tty-fix"))
  	auto_tty_fix = ON;
!     else if (eq (name, "debug"))
  	debug = ON;
      else if (eq (name, "tty-fix-bell"))
  	tty_fix_bell = ON;
***************
*** 124,130
  	auto_tty_fix = ON;
      if (eq (name, "debug"))
  	debug = ON;
!     if (eq (name, "tty-fix-bell"))
  	tty_fix_bell = ON;
      if (eq (name, "delimiters"))
  	delimiters = look_var ("delimiters");

--- 126,132 -----
  	auto_tty_fix = ON;
      else if (eq (name, "debug"))
  	debug = ON;
!     else if (eq (name, "tty-fix-bell"))
  	tty_fix_bell = ON;
      else if (eq (name, "delimiters")) {
  	/* only in this case, variable points allocated area */
***************
*** 126,132
  	debug = ON;
      if (eq (name, "tty-fix-bell"))
  	tty_fix_bell = ON;
!     if (eq (name, "delimiters"))
  	delimiters = look_var ("delimiters");
      if (eq (name, "crt"))
  	lines = atoi (look_var("crt"));

--- 128,136 -----
  	debug = ON;
      else if (eq (name, "tty-fix-bell"))
  	tty_fix_bell = ON;
!     else if (eq (name, "delimiters")) {
! 	/* only in this case, variable points allocated area */
! 	set_only_var (name, value);
  	delimiters = look_var ("delimiters");
      }
      else if (eq (name, "crt"))
***************
*** 128,135
  	tty_fix_bell = ON;
      if (eq (name, "delimiters"))
  	delimiters = look_var ("delimiters");
!     if (eq (name, "crt"))
! 	lines = atoi (look_var("crt"));
  
  }
  

--- 132,142 -----
  	/* only in this case, variable points allocated area */
  	set_only_var (name, value);
  	delimiters = look_var ("delimiters");
!     }
!     else if (eq (name, "crt"))
! 	lines = atoi (value);
!     else if (eq(name, "buffer")) {
! 	int s;
  
  	if ((s = atoi(value)) <= 0)
  	    return;
***************
*** 131,136
      if (eq (name, "crt"))
  	lines = atoi (look_var("crt"));
  
  }
  
  set_only_var (name, value)

--- 138,151 -----
      else if (eq(name, "buffer")) {
  	int s;
  
+ 	if ((s = atoi(value)) <= 0)
+ 	    return;
+ 
+ 	if (!set_buffer (output_buffer, s))
+ 	    return;
+     }
+ 
+     set_only_var (name, value);
  }
  
  set_only_var (name, value)
*** /tmp/,RCSt1008607	Tue Aug 23 01:43:18 1988
--- fep_vi.c	Mon Aug 22 02:01:17 1988
***************
*** 2,8
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_vi.c,v 4.0 88/08/05 20:22:27 utashiro Rel $ (SRA)";
  #endif lint
  
  #include <stdio.h>

--- 2,8 -----
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_vi.c,v 4.2 88/08/16 18:24:05 utashiro Exp $ (SRA)";
  #endif lint
  
  #include <stdio.h>
***************
*** 104,109
  	/* ^X-l    */	{"\\^Xl",	list_file_name},
  	/* ^X-L    */	{"\\^XL",	list_file_name},
  	/* ^X-^L   */	{"\\^X\\^L",	fep_repaint},
  	/* ^X-^X   */	{"\\^X\\^X",	expand_file_name},
  	/* ^X-?    */	{"\\^X?",	show_bindings},
  	/* ^X-^C   */	{"\\^X\\^C",	terminate},

--- 104,110 -----
  	/* ^X-l    */	{"\\^Xl",	list_file_name},
  	/* ^X-L    */	{"\\^XL",	list_file_name},
  	/* ^X-^L   */	{"\\^X\\^L",	fep_repaint},
+ 	/* ^X-^V   */	{"\\^X\\^V",	view_buffer},
  	/* ^X-^X   */	{"\\^X\\^X",	expand_file_name},
  	/* ^X-?    */	{"\\^X?",	show_bindings},
  	/* ^X-^C   */	{"\\^X\\^C",	terminate},
*** /tmp/,RCSt1008639	Tue Aug 23 01:43:27 1988
--- fep_hist.c	Mon Aug 22 02:01:14 1988
***************
*** 2,8
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_hist.c,v 4.0 88/08/05 20:22:14 utashiro Rel $ (SRA)";
  #endif lint
  
  #include <stdio.h>

--- 2,8 -----
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_hist.c,v 4.1 88/08/08 19:24:14 utashiro Exp $ (SRA)";
  #endif lint
  
  #include <stdio.h>
***************
*** 316,321
      if (newsize > 0)
  	newHistTable = (char **)calloc(sizeof(char *), newsize);
  
      newTop = (TailOfHist - newsize < TopOfHist)
  		? TopOfHist : TailOfHist - newsize;
  

--- 316,325 -----
      if (newsize > 0)
  	newHistTable = (char **)calloc(sizeof(char *), newsize);
  
+ 
+     if (newHistTable == 0)
+ 	return (0);
+ 
      newTop = (TailOfHist - newsize < TopOfHist)
  		? TopOfHist : TailOfHist - newsize;
  
***************
*** 346,351
  	printf ("history: top=%d, tail=%d, size=%d\n",
  	    TopOfHist, TailOfHist, HistorySize);
      }
  }
  
  /*

--- 350,358 -----
  	printf ("history: top=%d, tail=%d, size=%d\n",
  	    TopOfHist, TailOfHist, HistorySize);
      }
+ 
+     return (1);
+ 
  }
  
  /*
***************
*** 439,445
  		"%s: Argument or \"history-file\" variables is required\n",
  		argv[0]
  	    );
! 	    recover_edit_line ();
  	    return;
  	}
  	file = mk_home_relative (cp);

--- 446,452 -----
  		"%s: Argument or \"history-file\" variables is required\n",
  		argv[0]
  	    );
! 	    recover_edit_line (1);
  	    return;
  	}
  	file = mk_home_relative (cp);
***************
*** 476,482
      if ((fp = fopen (file, "w")) == NULL) {
  	clear_edit_line ();
  	perror (file);
! 	recover_edit_line ();
  	return;
      }
  

--- 483,489 -----
      if ((fp = fopen (file, "w")) == NULL) {
  	clear_edit_line ();
  	perror (file);
! 	recover_edit_line (1);
  	return;
      }
  
***************
*** 510,516
  		"%s: Argument or \"history-file\" variables is required\n",
  		argv[0]
  	    );
! 	    recover_edit_line ();
  	    return;
  	}
  	file = mk_home_relative (cp);

--- 517,523 -----
  		"%s: Argument or \"history-file\" variables is required\n",
  		argv[0]
  	    );
! 	    recover_edit_line (1);
  	    return;
  	}
  	file = mk_home_relative (cp);
***************
*** 531,537
      if ((fp = fopen (file, "r")) == NULL) {
  	clear_edit_line ();
  	perror (file);
! 	recover_edit_line ();
  	return;
      }
  

--- 538,544 -----
      if ((fp = fopen (file, "r")) == NULL) {
  	clear_edit_line ();
  	perror (file);
! 	recover_edit_line (1);
  	return;
      }
  
*** /tmp/,RCSt1008649	Tue Aug 23 01:43:36 1988
--- fep_com.c	Tue Aug 23 01:29:15 1988
***************
*** 2,8
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_com.c,v 4.0 88/08/05 20:22:02 utashiro Rel $ (SRA)";
  #endif lint
  
  #include <stdio.h>

--- 2,8 -----
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_com.c,v 4.4 88/08/23 01:28:55 utashiro Exp $ (SRA)";
  #endif lint
  
  #include <stdio.h>
***************
*** 18,23
  
  int	tty_fix_bell = OFF;	/* ring bell if the tty mode is changed */
  
  /*
   * Check command line if it call built-in function or not and execute it
   */

--- 18,29 -----
  
  int	tty_fix_bell = OFF;	/* ring bell if the tty mode is changed */
  
+ typedef struct {
+ 	int cur_line;
+ 	int max_line;
+ } MORE;
+ MORE *create_more();
+ 
  /*
   * Check command line if it call built-in function or not and execute it
   */
***************
*** 433,438
      }
  }
  
  int crt, sline;
  
  show_bindings ()

--- 439,452 -----
      }
  }
  
+ putch (c)
+     int c;
+ {
+     putchar (c);
+     fflush (stdout);
+ }
+ 
+ /*
  int crt, sline;
  */
  
***************
*** 434,439
  }
  
  int crt, sline;
  
  show_bindings ()
  {

--- 448,454 -----
  
  /*
  int crt, sline;
+ */
  
  show_bindings ()
  {
***************
*** 437,446
  
  show_bindings ()
  {
!     crt = lookd_var ("crt");
!     if (crt < 0)
! 	crt = 0;
!     sline = 0;
  
      clear_edit_line ();
      (void) showBindingTbl (curFuncTab, "");

--- 452,458 -----
  
  show_bindings ()
  {
!     MORE *m;
  
      m = create_more(lines);
      if (!m) {
***************
*** 442,447
  	crt = 0;
      sline = 0;
  
      clear_edit_line ();
      (void) showBindingTbl (curFuncTab, "");
      recover_edit_line ();

--- 454,465 -----
  {
      MORE *m;
  
+     m = create_more(lines);
+     if (!m) {
+ 	errorBell ();
+ 	return (0);
+     }
+ 
      clear_edit_line ();
      (void) showBindingTbl (m, curFuncTab, "");
      recover_edit_line (1);
***************
*** 443,450
      sline = 0;
  
      clear_edit_line ();
!     (void) showBindingTbl (curFuncTab, "");
!     recover_edit_line ();
  }
  
  showBindingTbl (ft, prefix)

--- 461,471 -----
      }
  
      clear_edit_line ();
!     (void) showBindingTbl (m, curFuncTab, "");
!     recover_edit_line (1);
! 
!     destroy_more(m);
!     return (0);
  }
  
  showBindingTbl (m, ft, prefix)
***************
*** 447,453
      recover_edit_line ();
  }
  
! showBindingTbl (ft, prefix)
      FUNC ft[];
      char *prefix;
  {

--- 468,475 -----
      return (0);
  }
  
! showBindingTbl (m, ft, prefix)
!     MORE *m;
      FUNC ft[];
      char *prefix;
  {
***************
*** 466,472
  
  	    sprintf (pf, "%s%s%c-",
  		prefix, (i == 0 || isctlchar(i)) ? "^" : "", unctl(i));
! 	    if (showBindingTbl (maskIndirect(ft[i]), pf) == 0)
  		break;
  	    continue;
  	}

--- 488,494 -----
  
  	    sprintf (pf, "%s%s%c-",
  		prefix, (i == 0 || isctlchar(i)) ? "^" : "", unctl(i));
! 	    if (showBindingTbl (m, maskIndirect(ft[i]), pf) == 0)
  		break;
  	    continue;
  	}
***************
*** 477,483
  	for (fnte = FunctionNameTable; fnte->func; fnte++) {
  	    if (ft[i] == fnte->func) {
  
! 		if (!check_more())
  		    return (0);
  
  		/*

--- 499,505 -----
  	for (fnte = FunctionNameTable; fnte->func; fnte++) {
  	    if (ft[i] == fnte->func) {
  
! 		if (!more(m))
  		    return (0);
  
  		/*
***************
*** 509,517
  
  show_help ()
  {
!     crt = lines;
!     (crt < 0) && (crt = 0);
!     sline = 0;
  
      clear_edit_line ();
  

--- 531,537 -----
  
  show_help ()
  {
!     MORE *m;
  
      m = create_more(lines);
      if (m == 0) {
***************
*** 513,518
      (crt < 0) && (crt = 0);
      sline = 0;
  
      clear_edit_line ();
  
      check_more()			&&

--- 533,544 -----
  {
      MORE *m;
  
+     m = create_more(lines);
+     if (m == 0) {
+ 	errorBell ();
+ 	return;
+     }
+ 
      clear_edit_line ();
  
      more(m)				&&
***************
*** 515,521
  
      clear_edit_line ();
  
!     check_more()			&&
      (printf ("Functions:\n") || 1)	&&
      showTable (FunctionNameTable)	&&
      check_more()			&&

--- 541,547 -----
  
      clear_edit_line ();
  
!     more(m)				&&
      (printf ("Functions:\n") || 1)	&&
      showTable (m, FunctionNameTable)	&&
      more(m)				&&
***************
*** 517,524
  
      check_more()			&&
      (printf ("Functions:\n") || 1)	&&
!     showTable (FunctionNameTable)	&&
!     check_more()			&&
      (printf ("Commands:\n") || 1)	&&
      showTable (BuiltinFuncTable)	&&
      check_more()			&&

--- 543,550 -----
  
      more(m)				&&
      (printf ("Functions:\n") || 1)	&&
!     showTable (m, FunctionNameTable)	&&
!     more(m)				&&
      (printf ("Commands:\n") || 1)	&&
      showTable (m, BuiltinFuncTable)	&&
      more(m)				&&
***************
*** 520,527
      showTable (FunctionNameTable)	&&
      check_more()			&&
      (printf ("Commands:\n") || 1)	&&
!     showTable (BuiltinFuncTable)	&&
!     check_more()			&&
      (printf ("Variables:\n") || 1)	&&
      showVariables ();
  

--- 546,553 -----
      showTable (m, FunctionNameTable)	&&
      more(m)				&&
      (printf ("Commands:\n") || 1)	&&
!     showTable (m, BuiltinFuncTable)	&&
!     more(m)				&&
      (printf ("Variables:\n") || 1)	&&
      showVariables (m);
  
***************
*** 523,529
      showTable (BuiltinFuncTable)	&&
      check_more()			&&
      (printf ("Variables:\n") || 1)	&&
!     showVariables ();
  
      recover_edit_line ();
  }

--- 549,555 -----
      showTable (m, BuiltinFuncTable)	&&
      more(m)				&&
      (printf ("Variables:\n") || 1)	&&
!     showVariables (m);
  
      recover_edit_line (1);
  }
***************
*** 525,531
      (printf ("Variables:\n") || 1)	&&
      showVariables ();
  
!     recover_edit_line ();
  }
  
  showTable (fnte)

--- 551,557 -----
      (printf ("Variables:\n") || 1)	&&
      showVariables (m);
  
!     recover_edit_line (1);
  }
  
  showTable (m, fnte)
***************
*** 528,534
      recover_edit_line ();
  }
  
! showTable (fnte)
      FunctionTableEnt *fnte;
  {
      int i;

--- 554,561 -----
      recover_edit_line (1);
  }
  
! showTable (m, fnte)
!     MORE *m;
      FunctionTableEnt *fnte;
  {
      int i;
***************
*** 537,543
       * Search function name table
       */
      for (; fnte->func; fnte++) {
! 	if (!check_more())
  	    return (0);
  	printf ("\t%-30s %s\n", fnte->name, fnte->help);
      }

--- 564,570 -----
       * Search function name table
       */
      for (; fnte->func; fnte++) {
! 	if (!more(m))
  	    return (0);
  	printf ("\t%-30s %s\n", fnte->name, fnte->help);
      }
***************
*** 545,551
      return (1);
  }
  
! showVariables ()
  {
      extern VAR default_set_vars[], default_unset_vars[];
      VAR *vp;

--- 572,579 -----
      return (1);
  }
  
! showVariables (m)
!     MORE *m;
  {
      extern VAR default_set_vars[], default_unset_vars[];
      VAR *vp;
***************
*** 553,559
      for (vp = default_set_vars; vp->v_name; ++vp) {
  	if (!vp->v_help)
  	    continue;
! 	if (!check_more())
  	    return (0);
  	printf ("\t%-30s %s\n", vp->v_name, vp->v_help);
      }

--- 581,587 -----
      for (vp = default_set_vars; vp->v_name; ++vp) {
  	if (!vp->v_help)
  	    continue;
! 	if (!more(m))
  	    return (0);
  	printf ("\t%-30s %s\n", vp->v_name, vp->v_help);
      }
***************
*** 561,567
      for (vp = default_unset_vars; vp->v_name; ++vp) {
  	if (!vp->v_help)
  	    continue;
! 	if (!check_more())
  	    return (0);
  	printf ("\t%-30s %s\n", vp->v_name, vp->v_help);
      }

--- 589,595 -----
      for (vp = default_unset_vars; vp->v_name; ++vp) {
  	if (!vp->v_help)
  	    continue;
! 	if (!more(m))
  	    return (0);
  	printf ("\t%-30s %s\n", vp->v_name, vp->v_help);
      }
***************
*** 568,575
      return (1);
  }
  
! putch (c)
!     int c;
  {
      putchar (c);
  }

--- 596,603 -----
      return (1);
  }
  
! MORE *create_more(maxline)
!     int maxline;
  {
      MORE *mp;
  
***************
*** 571,577
  putch (c)
      int c;
  {
!     putchar (c);
  }
  
  check_more()

--- 599,615 -----
  MORE *create_more(maxline)
      int maxline;
  {
!     MORE *mp;
! 
!     mp = (MORE *) malloc (sizeof (MORE));
! 
!     if (mp == 0)
! 	return ((MORE*)0);
!     else {
! 	mp->cur_line = 0;
! 	mp->max_line = maxline;
! 	return (mp);
!     }
  }
  
  destroy_more(mp)
***************
*** 574,580
      putchar (c);
  }
  
! check_more()
  {
  
      if (sline == 0 && look_var ("clear-repaint") && term_clear)

--- 612,619 -----
      }
  }
  
! destroy_more(mp)
!     MORE *mp;
  {
      if (mp)
  	free (mp);
***************
*** 576,581
  
  check_more()
  {
  
      if (sline == 0 && look_var ("clear-repaint") && term_clear)
  	tputs (term_clear, 1, putch);

--- 615,623 -----
  destroy_more(mp)
      MORE *mp;
  {
+     if (mp)
+ 	free (mp);
+ }
  
  more (mp)
      MORE *mp;
***************
*** 577,584
  check_more()
  {
  
!     if (sline == 0 && look_var ("clear-repaint") && term_clear)
! 	tputs (term_clear, 1, putch);
  
      /*
       * Print more message

--- 619,627 -----
  	free (mp);
  }
  
! more (mp)
!     MORE *mp;
! {
  
      /*
       * Print more message
***************
*** 585,592
       */
  #   define PUTMORE	printf (  "--More--");
  #   define DELMORE	printf ("\r        \r");
!     if (crt && ++sline >= crt) {
! 	
  	PUTMORE;
  	fflush (stdout);
  	

--- 628,635 -----
       */
  #   define PUTMORE	printf (  "--More--");
  #   define DELMORE	printf ("\r        \r");
!     if (mp->max_line && ++mp->cur_line >= mp->max_line) {
! 
  	PUTMORE;
  	fflush (stdout);
  	
***************
*** 592,598
  	
  	switch (getcharacter()) {
  	case '\n': case '\r': case 'j':
! 	    --sline;
  	    break;
  
  	case 'd': case CTRL(D):

--- 635,641 -----
  	
  	switch (getcharacter()) {
  	case '\n': case '\r': case 'j':
! 	    --mp->cur_line;
  	    break;
  
  	case 'd': case CTRL(D):
***************
*** 596,602
  	    break;
  
  	case 'd': case CTRL(D):
! 	    sline /= 2;
  	    break;
  
  	case 'q': case 'Q': case CTRL(C):

--- 639,645 -----
  	    break;
  
  	case 'd': case CTRL(D):
! 	    mp->cur_line /= 2;
  	    break;
  
  	case 'q': case 'Q': case CTRL(C):
***************
*** 604,610
  	    return (0);
  
  	default:
! 	    sline = 0;
  	    break;
  	}
  	DELMORE;

--- 647,653 -----
  	    return (0);
  
  	default:
! 	    mp->cur_line = 1;
  	    break;
  	}
  	DELMORE;
***************
*** 609,614
  	}
  	DELMORE;
      }
      return (1);
  }
  

--- 652,661 -----
  	}
  	DELMORE;
      }
+ 
+     if (mp->cur_line == 1 && look_var ("clear-repaint") && term_clear)
+ 	tputs (term_clear, 1, putch);
+ 
      return (1);
  }
  
***************
*** 919,925
      fix_tty();
      if (look_var ("verbose"))
  	printf ("Return to fep\n");
!     recover_edit_line ();
  }
  
  FILE *redirect_fp = NULL;

--- 966,972 -----
      fix_tty();
      if (look_var ("verbose"))
  	printf ("Return to fep\n");
!     recover_edit_line (1);
  }
  
  FILE *redirect_fp = NULL;
***************
*** 1043,1049
  	clear_edit_line ();
  	errorBell ();
  	printf ("script is already running.\n");
! 	recover_edit_line ();
  	return;
      }
  

--- 1090,1096 -----
  	clear_edit_line ();
  	errorBell ();
  	printf ("script is already running.\n");
! 	recover_edit_line (1);
  	return;
      }
  
***************
*** 1050,1056
      if (!name) {
  	clear_edit_line ();
  	printf ("script-file is not set.\n");
! 	recover_edit_line ();
  	return;
      }
  

--- 1097,1103 -----
      if (!name) {
  	clear_edit_line ();
  	printf ("script-file is not set.\n");
! 	recover_edit_line (1);
  	return;
      }
  
***************
*** 1057,1063
      if ((script_fp = fopen (name, "a")) == NULL) {
  	clear_edit_line ();
  	perror (name);
! 	recover_edit_line ();
  	return;
      }
  

--- 1104,1110 -----
      if ((script_fp = fopen (name, "a")) == NULL) {
  	clear_edit_line ();
  	perror (name);
! 	recover_edit_line (1);
  	return;
      }
  
***************
*** 1065,1071
  
      clear_edit_line ();
      printf ("script start (file=\"%s\").\n", script_file);
!     recover_edit_line ();
  }
  
  fep_end_script ()

--- 1112,1118 -----
  
      clear_edit_line ();
      printf ("script start (file=\"%s\").\n", script_file);
!     recover_edit_line (1);
  }
  
  fep_end_script ()
***************
*** 1082,1088
  
      clear_edit_line ();
      printf ("script end (file=\"%s\").\n", script_file);
!     recover_edit_line ();
  
      return;
  }

--- 1129,1135 -----
  
      clear_edit_line ();
      printf ("script end (file=\"%s\").\n", script_file);
!     recover_edit_line (1);
  
      return;
  }
***************
*** 1094,1100
      int line;
      CHAR ch;
      char *crt_hight;
-     char *save_prompt;
      BUFFER *bp = output_buffer;
  
      /*

--- 1141,1146 -----
      int line;
      CHAR ch;
      char *crt_hight;
      BUFFER *bp = output_buffer;
  
      /*
***************
*** 1139,1147
      if (look_var("clear-repaint") && term_clear)
  	tputs (term_clear, 1, putch);
  
!     for (; i < 0; i++) {
! 	char cd;
! 	cd = buf_char (bp, i);
  	putchar (buf_char(bp, i));
      }
  

--- 1185,1191 -----
      if (look_var("clear-repaint") && term_clear)
  	tputs (term_clear, 1, putch);
  
!     for (; i < 0; i++)
  	putchar (buf_char(bp, i));
  
      /*
***************
*** 1143,1149
  	char cd;
  	cd = buf_char (bp, i);
  	putchar (buf_char(bp, i));
-     }
  
      /*
       * In this case, prompt should not be printed.

--- 1187,1192 -----
  
      for (; i < 0; i++)
  	putchar (buf_char(bp, i));
  
      /*
       * In this case, prompt should not be printed.
***************
*** 1149,1158
       * In this case, prompt should not be printed.
       * Saving prompt is ugly solution, but...
       */
!     save_prompt = prompt;
!     prompt = 0;
!     recover_edit_line ();
!     prompt = save_prompt;
      fflush (stdout);
  }
  

--- 1192,1198 -----
       * In this case, prompt should not be printed.
       * Saving prompt is ugly solution, but...
       */
!     recover_edit_line (0);
      fflush (stdout);
  }
  
***************
*** 1156,1161
      fflush (stdout);
  }
  
  #ifdef STAT
  
  #include "fep_stat.h"

--- 1196,1247 -----
      fflush (stdout);
  }
  
+ view_buffer (comline)
+     char *comline;
+ {
+     BUFFER *bp = output_buffer;
+     MORE *m;
+     int maxchar = buf_count (bp);
+     int i;
+     char c;
+ 
+     /*
+      * Skip first line
+      */
+     for (i = 0; (c = buf_char (bp, i)) != (char)-1 && c != '\n'; i++)
+ 	;
+     i += 1;
+ 
+     if (c == -1)
+ 	return (0);
+ 
+     if (!(m = create_more (lines)))
+ 	return (0);
+ 
+     clear_edit_line ();
+     for (; i < maxchar; i++) {
+ 	if (!more(m))
+ 	    break;
+ 	while ((c = buf_char (bp, i)) != (char)-1 && c != '\n') {
+ 	    putchar (c);
+ 	    i++;
+ 	}
+ 	if (c == '\n')
+ 	    putchar ('\n');
+     }
+ 
+     /*
+      * If all output is shown, prompt not to be shown.
+      */
+     if (i < maxchar)
+ 	recover_edit_line (1);
+     else
+ 	recover_edit_line (0);
+ 
+     destroy_more(m);
+     return (0);
+ }
+ 
  #ifdef STAT
  
  #include "fep_stat.h"
***************
*** 1187,1196
  
      printf ("\nI/O Buffer:\n");
      printf ("\tMax  : %d\n", bp->b_max);
!     printf ("\tHiWtr: %d\n", bp->hiwater);
!     printf ("\tCount: %d\n", bp->count);
!     printf ("\tNext : %d\n", bp->next);
!     printf ("\tStart: %d\n", bp->start);
  
  }
  #endif

--- 1273,1281 -----
  
      printf ("\nI/O Buffer:\n");
      printf ("\tMax  : %d\n", bp->b_max);
!     printf ("\tHiWtr: %d\n", bp->b_hiwater);
!     printf ("\tCount: %d\n", bp->b_count);
!     printf ("\tNext : %d\n", bp->b_next);
  
  }
  #endif
*** /tmp/,RCSt1008659	Tue Aug 23 01:43:50 1988
--- fep_edit.c	Mon Aug 22 02:01:12 1988
***************
*** 2,8
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_edit.c,v 4.0 88/08/05 20:22:06 utashiro Rel $ (SRA)";
  #endif lint
  
  #include <stdio.h>

--- 2,8 -----
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_edit.c,v 4.2 88/08/16 18:23:46 utashiro Exp $ (SRA)";
  #endif lint
  
  #include <stdio.h>
***************
*** 77,82
  	/* ^X-^H	*/	{"\\^X\\^H",	show_history},
  	/* ^X-H		*/	{"\\^XH",	show_history},
  	/* ^X-h		*/	{"\\^Xh",	show_history},
  	/* ^X-^K	*/	{"\\^X\\^K",	kill_to_top_of_line},
  	/* ^X-^L	*/	{"\\^X\\^L",	fep_repaint},
  	/* ^X-^C	*/	{"\\^X\\^C",	terminate},

--- 77,83 -----
  	/* ^X-^H	*/	{"\\^X\\^H",	show_history},
  	/* ^X-H		*/	{"\\^XH",	show_history},
  	/* ^X-h		*/	{"\\^Xh",	show_history},
+ 	/* ^X-^V	*/	{"\\^X\\^V",	view_buffer},
  	/* ^X-^K	*/	{"\\^X\\^K",	kill_to_top_of_line},
  	/* ^X-^L	*/	{"\\^X\\^L",	fep_repaint},
  	/* ^X-^C	*/	{"\\^X\\^C",	terminate},
***************
*** 1428,1434
  		cp = "";
  	    (void) clear_edit_line ();
  	    fprintf (stdout, "\"%s\": No match.\r\n", cp);
! 	    (void) recover_edit_line ();
  	}
      }
  

--- 1429,1435 -----
  		cp = "";
  	    (void) clear_edit_line ();
  	    fprintf (stdout, "\"%s\": No match.\r\n", cp);
! 	    (void) recover_edit_line (1);
  	}
      }
  
***************
*** 1471,1477
      errorBell ();
      (void) clear_edit_line ();
      printf ("EOF -- one more eof character to send eof to the process.\n");
!     (void) recover_edit_line ();
  }
  
  /*

--- 1472,1478 -----
      errorBell ();
      (void) clear_edit_line ();
      printf ("EOF -- one more eof character to send eof to the process.\n");
!     (void) recover_edit_line (1);
  }
  
  /*
***************
*** 1484,1490
      if (term_clear) {
  	(void) clear_edit_line ();
  	fputs (term_clear, stdout);
! 	(void) recover_edit_line ();
      }
      else
  	errorBell ();

--- 1485,1491 -----
      if (term_clear) {
  	(void) clear_edit_line ();
  	fputs (term_clear, stdout);
! 	(void) recover_edit_line (1);
      }
      else
  	errorBell ();
***************
*** 1552,1565
   */
  show_history()
  {
-     int saveCP = CurrentPosition;
-     char *cp;
-     char *getHistory ();
-     int showhist;
-     
-     (void) end_of_line ();
-     CurrentPosition = saveCP;
-     fputs("\r\n", stdout);
  
      hist_showHistory (lookd_var ("showhist"));
  

--- 1553,1558 -----
   */
  show_history()
  {
  
      (void) clear_edit_line ();
      hist_showHistory (lookd_var ("showhist"));
***************
*** 1561,1566
      CurrentPosition = saveCP;
      fputs("\r\n", stdout);
  
      hist_showHistory (lookd_var ("showhist"));
  
      fputs (prompt, stdout);

--- 1554,1560 -----
  show_history()
  {
  
+     (void) clear_edit_line ();
      hist_showHistory (lookd_var ("showhist"));
      (void) recover_edit_line (1);
  }
***************
*** 1562,1570
      fputs("\r\n", stdout);
  
      hist_showHistory (lookd_var ("showhist"));
! 
!     fputs (prompt, stdout);
!     (void) print_com_line();
  }
  
  /*

--- 1556,1562 -----
  
      (void) clear_edit_line ();
      hist_showHistory (lookd_var ("showhist"));
!     (void) recover_edit_line (1);
  }
  
  /*
***************
*** 1591,1597
  {
  
      (void) clear_edit_line ();
!     (void) recover_edit_line ();
      return (0);
  }
  

--- 1583,1589 -----
  {
  
      (void) clear_edit_line ();
!     (void) recover_edit_line (1);
      return (0);
  }
  
***************
*** 1803,1809
  
  	(void) clear_edit_line();
  	list_remote_file (host, pattern);
! 	(void) recover_edit_line();
  	return;
      }
  #endif

--- 1795,1801 -----
  
  	(void) clear_edit_line();
  	list_remote_file (host, pattern);
! 	(void) recover_edit_line (1);
  	return;
      }
  #endif
***************
*** 1824,1830
      (void) clear_edit_line();
      ls (dirp, cp);
      closedir(dirp);
!     (void) recover_edit_line();
  
      return (0);
  }

--- 1816,1822 -----
      (void) clear_edit_line();
      ls (dirp, cp);
      closedir(dirp);
!     (void) recover_edit_line (1);
  
      return (0);
  }
***************
*** 1842,1848
      (void) fputs ("\r\n", stdout);
  }
  
! recover_edit_line ()
  {
  
      if (editstatus == NOTEDITING)

--- 1834,1841 -----
      (void) fputs ("\r\n", stdout);
  }
  
! recover_edit_line (put_prompt)
!     int put_prompt;
  {
  
      if (editstatus == NOTEDITING)
***************
*** 1852,1858
  	return;
      CurrentPosition = rememberPosition;
      rememberPosition = -1;
!     if (prompt)
  	fputs (prompt, stdout);
      (void) print_com_line();
  }

--- 1845,1851 -----
  	return;
      CurrentPosition = rememberPosition;
      rememberPosition = -1;
!     if (put_prompt && prompt)
  	fputs (prompt, stdout);
      (void) print_com_line();
  }
*** /tmp/,RCSt1008669	Tue Aug 23 01:44:05 1988
--- fep_defs.h	Mon Aug 22 02:01:11 1988
***************
*** 2,8
  
  #ifndef lint
  # define FEP_DEFS \
!     "$Header: fep_defs.h,v 4.0 88/08/05 20:21:51 utashiro Rel $ (SRA)"
  #endif lint
  
  #define	MAXCOMLEN		512	/* maximum command length */

--- 2,8 -----
  
  #ifndef lint
  # define FEP_DEFS \
!     "$Header: fep_defs.h,v 4.2 88/08/16 18:22:13 utashiro Exp $ (SRA)"
  #endif lint
  
  #define	MAXCOMLEN		512	/* maximum command length */
***************
*** 93,105
  } VAR;
  
  typedef struct {
!     char *buf;			/* buffer */
!     char *last_buf;		/* last i/o done pointer */
!     int b_max;			/* max size */
!     int start;			/* start point */
!     int next;			/* next read point */
!     int count;			/* count */
!     int hiwater;		/* high water mark */
  } BUFFER;
  
  #define buf_count(b) ((b)->count)

--- 93,104 -----
  } VAR;
  
  typedef struct {
! 	char *b_buf;			/* buffer */
! 	char *b_lastbuf;		/* last i/o done pointer */
! 	int b_max;			/* max size */
! 	int b_next;			/* next read point */
! 	int b_count;			/* count */
! 	int b_hiwater;			/* high water mark */
  } BUFFER;
  
  #define buf_count(b) ((b)->b_count)
***************
*** 102,109
      int hiwater;		/* high water mark */
  } BUFFER;
  
! #define buf_count(b) ((b)->count)
! #define buf_remain(b) ((b)->size - (b)->count)
  /*
  char buf_char (b, n)
      BUFFER *b;

--- 101,108 -----
  	int b_hiwater;			/* high water mark */
  } BUFFER;
  
! #define buf_count(b) ((b)->b_count)
! #define buf_remain(b) ((b)->b_size-(b)->b_count)
  /*
  char buf_char (b, n)
      BUFFER *b;
***************
*** 109,126
      BUFFER *b;
      int n;
  {
!     if (n >= 0) {
! 	if (n >= b->count)
! 	    return ((char*)-1);
! 	return (b->buf[(b->start+n)%b->count]);
!     } else {
! 	if (-n >= b->count)
! 	    return (-1);
! 	if (b->next+n >= 0)
! 	    return (b->buf[b->next+n]);
! 	else
! 	    return (b->buf[b->next+n+b->count]);
!     }
  }
  */	    
  #define buf_char(b,n) \

--- 108,121 -----
      BUFFER *b;
      int n;
  {
!     if (n >= b->b_count || -n > b->b_count)
! 	return (-1);
!     if (b->b_next+n >= b->b_count)
! 	return (b->b_buf[b->b_next+n-b->b_count]);
!     else if (b->b_next+n < 0)
! 	return (b->b_buf[b->b_next+n+b->b_count]);
!     else
! 	return (b->b_buf[b->b_next+n]);
  }
  */	    
  #define buf_char(b,n) \
***************
*** 124,135
  }
  */	    
  #define buf_char(b,n) \
! 	(((n)>=0) \
! 	 ?(((n)>=(b)->count) \
! 	   ? ((char)-1) \
! 	   : ((b)->buf[((b)->start+n)%(b)->count])) \
! 	 :((-(n) > (b)->count) \
! 	   ?((char)-1) \
! 	   :((((b)->next+n) >= 0) \
! 	     ? ((b)->buf[(b)->next+(n)]) \
! 	     : ((b)->buf[(b)->next+n+(b)->count]))))

--- 119,128 -----
  }
  */	    
  #define buf_char(b,n) \
! 	(((n) >= (b)->b_count || -(n) > (b)->b_count) \
! 	  ?((char)-1) \
! 	  :((((b)->b_next + (n)) >= (b)->b_count) \
! 	    ?((b)->b_buf[(b)->b_next + (n) - (b)->b_count]) \
! 	    :((((b)->b_next + (n)) < 0) \
! 	      ?((b)->b_buf[(b)->b_next + (n) + (b)->b_count]) \
! 	      :((b)->b_buf[(b)->b_next + (n)]))))
*** /tmp/,RCSt1008683	Tue Aug 23 01:44:10 1988
--- fep_funcs.h	Mon Aug 22 02:01:13 1988
***************
*** 2,8
  
  #ifndef lint
  # define FEP_FUNCS \
!     "$Header: fep_funcs.h,v 4.0 88/08/05 20:21:53 utashiro Rel $ (SRA)"
  #endif lint
  
  /*

--- 2,8 -----
  
  #ifndef lint
  # define FEP_FUNCS \
!     "$Header: fep_funcs.h,v 4.2 88/08/16 18:24:03 utashiro Exp $ (SRA)"
  #endif lint
  
  /*
***************
*** 91,96
  int	fep_else();
  int	fep_endif();
  int	fep_repaint();
  #ifdef STAT
  int	fep_showstat();
  #endif

--- 91,97 -----
  int	fep_else();
  int	fep_endif();
  int	fep_repaint();
+ int	view_buffer();
  #ifdef STAT
  int	fep_showstat();
  #endif
*** /tmp/,RCSt1008697	Tue Aug 23 01:44:17 1988
--- fep_main.c	Mon Aug 22 02:01:15 1988
***************
*** 2,8
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_main.c,v 4.0 88/08/05 20:22:17 utashiro Rel $ (SRA)";
  #endif lint
  
  #include <stdio.h>

--- 2,8 -----
  
  #ifndef lint
  static char rcsid[]=
! "$Header: fep_main.c,v 4.2 88/08/16 18:22:25 utashiro Exp $ (SRA)";
  #endif lint
  
  #include <stdio.h>
***************
*** 239,244
  	    histlen = DFL_HISTLEN;
      }
  
      /*
       * Initialize output buffer.
       */

--- 239,247 -----
  	    histlen = DFL_HISTLEN;
      }
  
+     init_hist (histlen);
+     init_edit_params ();
+ 
      /*
       * Initialize output buffer.
       */
***************
*** 242,252
      /*
       * Initialize output buffer.
       */
!     output_buffer->buf = (char *) malloc (5120);
!     if (output_buffer->buf <= 0) {
! 	fprintf (stderr, "Can't allocate enough momory\n");
! 	kill_process ();
! 	exit (1);
      }
      output_buffer->b_max = 5120;
      output_buffer->hiwater = 4096;

--- 245,260 -----
      /*
       * Initialize output buffer.
       */
!     if (!output_buffer->b_buf) {
! 	int size;
! 
! 	if ((size = atoi (look_var ("buffer"))) <= 0)
! 	    size = 5120;
! 	if (!set_buffer (output_buffer, size)) {
! 	    fprintf (stderr, "Can't allocate enough momory\n");
! 	    kill_process ();
! 	    exit (1);
! 	}
      }
  
      if (ptyflag) {
***************
*** 248,256
  	kill_process ();
  	exit (1);
      }
-     output_buffer->b_max = 5120;
-     output_buffer->hiwater = 4096;
-     output_buffer->count = output_buffer->next = output_buffer->start = 0;
  
      init_hist (histlen);
      init_edit_params ();

--- 256,261 -----
  	    exit (1);
  	}
      }
  
      if (ptyflag) {
  	child_pid = fork ();
***************
*** 252,260
      output_buffer->hiwater = 4096;
      output_buffer->count = output_buffer->next = output_buffer->start = 0;
  
-     init_hist (histlen);
-     init_edit_params ();
- 
      if (ptyflag) {
  	child_pid = fork ();
  	if (child_pid < 0) {

--- 257,262 -----
  	}
      }
  
      if (ptyflag) {
  	child_pid = fork ();
  	if (child_pid < 0) {
***************
*** 369,377
  {
      char c;
      int n;
- /*
-     char buf[INPUT_BUFFER_SIZE];
- */
      int nfound, readfd, writefd = 0, execptfd = 0;
  #ifdef USE_TIMEOUT
      struct timeval **timeout = auto_tty_fix ? timeout_list : notimeout;

--- 371,376 -----
  {
      char c;
      int n;
      int nfound, readfd, writefd = 0, execptfd = 0;
  #ifdef USE_TIMEOUT
      struct timeval **timeout = auto_tty_fix ? timeout_list : notimeout;
***************
*** 405,413
  	/*
  	 * Read from pty.
  	 */
- /*
- 	nbyte = read (master, buf, INPUT_BUFFER_SIZE);
- */
  	nbyte = buf_read (master, output_buffer);
  
  	if (nbyte > 0) {

--- 404,409 -----
  	/*
  	 * Read from pty.
  	 */
  	nbyte = buf_read (master, output_buffer);
  
  	if (nbyte > 0) {
***************
*** 414,423
  	    /*
  	     * Write to stdout
  	     */
! /*
! 	    write (1, buf, nbyte);
! */
! 	    write (1, output_buffer->last_buf, nbyte);
  
  	    /*
  	     * Write to script file

--- 410,416 -----
  	    /*
  	     * Write to stdout
  	     */
! 	    write (1, output_buffer->b_lastbuf, nbyte);
  
  	    /*
  	     * Write to script file
***************
*** 423,432
  	     * Write to script file
  	     */
  	    if (script_fp)
! /*
! 		fwrite (buf, sizeof(CHAR), nbyte, script_fp);
! */
! 		fwrite (output_buffer->last_buf,
  			sizeof(CHAR), nbyte, script_fp);
  
  #ifdef STAT

--- 416,422 -----
  	     * Write to script file
  	     */
  	    if (script_fp)
! 		fwrite (output_buffer->b_lastbuf,
  			sizeof(CHAR), nbyte, script_fp);
  
  #ifdef STAT
***************
*** 493,498
      goto RETRY;
  }
  
  int buf_read (fd, bp)
      int fd;			/* file discriptor */
      BUFFER *bp;			/* buffer pointer */

--- 483,515 -----
      goto RETRY;
  }
  
+ int set_buffer (bp, size)
+     BUFFER *bp;
+     int size;
+ {
+     char *newbuf, *malloc(), *realloc();
+ 
+     if (bp->b_buf)
+ 	newbuf = (char *) realloc (bp->b_buf, size);
+     else {
+ 	newbuf = (char *) malloc (size);
+ 	bp->b_count = bp->b_next = 0;
+     }
+ 
+     if (newbuf == 0)
+ 	return (0);
+ 
+     bp->b_buf = newbuf;
+     bp->b_max = size;
+     bp->b_hiwater = size * 4 / 5;
+ 
+     if (bp->b_next > bp->b_hiwater) {
+ 	bp->b_count = bp->b_next;
+ 	bp->b_next = 0;
+     }
+     return (1);
+ }
+ 	
  int buf_read (fd, bp)
      int fd;			/* file discriptor */
      BUFFER *bp;			/* buffer pointer */
***************
*** 502,508
      /*
       * save previous next pointer
       */
!     bp->last_buf = bp->buf + bp->next;
  
      /*
       * read from fd as possible

--- 519,525 -----
      /*
       * save previous next pointer
       */
!     bp->b_lastbuf = bp->b_buf + bp->b_next;
  
      /*
       * read from fd as possible
***************
*** 507,513
      /*
       * read from fd as possible
       */
!     nbyte = read (fd, bp->buf + bp->next, bp->b_max - bp->next);
  
      /*
       * move next read pointer

--- 524,530 -----
      /*
       * read from fd as possible
       */
!     nbyte = read (fd, bp->b_buf + bp->b_next, bp->b_max - bp->b_next);
  
      /*
       * move next read pointer
***************
*** 512,518
      /*
       * move next read pointer
       */
!     bp->next += nbyte;
  
      /*
       * If count has not reached high-water mark, increment count

--- 529,535 -----
      /*
       * move next read pointer
       */
!     bp->b_next += nbyte;
  
      /*
       * If count has not reached high-water mark, increment count
***************
*** 516,523
  
      /*
       * If count has not reached high-water mark, increment count
!      * by read count, otherwise start pointer should be pushed by
!      * next pointer.
       */
      if (bp->count < bp->hiwater)
  	bp->count += nbyte;

--- 533,539 -----
  
      /*
       * If count has not reached high-water mark, increment count
!      * by read count.
       */
      if (bp->b_count < bp->b_hiwater)
  	bp->b_count += nbyte;
***************
*** 519,528
       * by read count, otherwise start pointer should be pushed by
       * next pointer.
       */
!     if (bp->count < bp->hiwater)
! 	bp->count += nbyte;
!     else
! 	bp->start += nbyte;
  	
      /*
       * If next pointer goes further than high-water mark, discard contents

--- 535,542 -----
       * If count has not reached high-water mark, increment count
       * by read count.
       */
!     if (bp->b_count < bp->b_hiwater)
! 	bp->b_count += nbyte;
  	
      /*
       * If next pointer goes further than high-water mark, discard contents
***************
*** 526,532
  	
      /*
       * If next pointer goes further than high-water mark, discard contents
!      * after next pointer, and move start and next pointer to buffer top.
       */
      if (bp->next > bp->hiwater) {
  	bp->count = bp->next;

--- 540,546 -----
  	
      /*
       * If next pointer goes further than high-water mark, discard contents
!      * after next pointer, and move next pointer to buffer top.
       */
      if (bp->b_next > bp->b_hiwater) {
  	bp->b_count = bp->b_next;
***************
*** 528,537
       * If next pointer goes further than high-water mark, discard contents
       * after next pointer, and move start and next pointer to buffer top.
       */
!     if (bp->next > bp->hiwater) {
! 	bp->count = bp->next;
! 	bp->start = 0;
! 	bp->next = 0;
      }
  
      return (nbyte);

--- 542,550 -----
       * If next pointer goes further than high-water mark, discard contents
       * after next pointer, and move next pointer to buffer top.
       */
!     if (bp->b_next > bp->b_hiwater) {
! 	bp->b_count = bp->b_next;
! 	bp->b_next = 0;
      }
  
      return (nbyte);
***************
*** 548,555
  
      while (nbyte > 0) {
  
! 	slen = min (bp->b_max - bp->next, nbyte);
! 	strncpy (bp->buf + bp->next, s, slen);
  	s += slen;
  	nbyte -= slen;
  	bp->next += slen;

--- 561,568 -----
  
      while (nbyte > 0) {
  
! 	slen = min (bp->b_max - bp->b_next, nbyte);
! 	strncpy (bp->b_buf + bp->b_next, s, slen);
  	s += slen;
  	nbyte -= slen;
  	bp->b_next += slen;
***************
*** 552,558
  	strncpy (bp->buf + bp->next, s, slen);
  	s += slen;
  	nbyte -= slen;
! 	bp->next += slen;
  
  	if (bp->count < bp->hiwater)
  	    bp->count += slen;

--- 565,571 -----
  	strncpy (bp->b_buf + bp->b_next, s, slen);
  	s += slen;
  	nbyte -= slen;
! 	bp->b_next += slen;
  
  	if (bp->b_count < bp->b_hiwater)
  	    bp->b_count += slen;
***************
*** 554,563
  	nbyte -= slen;
  	bp->next += slen;
  
! 	if (bp->count < bp->hiwater)
! 	    bp->count += slen;
! 	else
! 	    bp->start += slen;
  
  	if (bp->next > bp->hiwater) {
  	    bp->count = bp->next;

--- 567,574 -----
  	nbyte -= slen;
  	bp->b_next += slen;
  
! 	if (bp->b_count < bp->b_hiwater)
! 	    bp->b_count += slen;
  
  	if (bp->b_next > bp->b_hiwater) {
  	    bp->b_count = bp->b_next;
***************
*** 559,568
  	else
  	    bp->start += slen;
  
! 	if (bp->next > bp->hiwater) {
! 	    bp->count = bp->next;
! 	    bp->start = 0;
! 	    bp->next = 0;
  	}
      }
  }

--- 570,578 -----
  	if (bp->b_count < bp->b_hiwater)
  	    bp->b_count += slen;
  
! 	if (bp->b_next > bp->b_hiwater) {
! 	    bp->b_count = bp->b_next;
! 	    bp->b_next = 0;
  	}
      }
  }
***************
*** 569,577
  
  swallow_output()
  {
- /*
-     char buf[INPUT_BUFFER_SIZE];
- */
      int readfd = mastermask;
      int r;
      int nbyte;

--- 579,584 -----
  
  swallow_output()
  {
      int readfd = mastermask;
      int r;
      int nbyte;
***************
*** 582,590
  	select (selectnfds, &readfd, 0, 0, TIMEOUT_NOBLOCK) > 0 &&
  	readfd & mastermask
      ) {
- /*
- 	nbyte = read (master, buf, INPUT_BUFFER_SIZE);
- */
  	nbyte = buf_read (master, output_buffer);
  	if (nbyte > 0) {
  /*

--- 589,594 -----
  	select (selectnfds, &readfd, 0, 0, TIMEOUT_NOBLOCK) > 0 &&
  	readfd & mastermask
      ) {
  	nbyte = buf_read (master, output_buffer);
  	if (nbyte > 0) {
  	    write (1, output_buffer->b_lastbuf, nbyte);
***************
*** 587,596
  */
  	nbyte = buf_read (master, output_buffer);
  	if (nbyte > 0) {
! /*
! 	    write (1, buf, nbyte);
! */
! 	    write (1, output_buffer->last_buf, nbyte);
  #ifdef STAT
  	    stat_obyte += nbyte;
  	    stat_nselect++;

--- 591,597 -----
      ) {
  	nbyte = buf_read (master, output_buffer);
  	if (nbyte > 0) {
! 	    write (1, output_buffer->b_lastbuf, nbyte);
  #ifdef STAT
  	    stat_obyte += nbyte;
  	    stat_nselect++;
***************
*** 600,609
  	     * Write to script file
  	     */
  	    if (script_fp)
! /*
! 		fwrite (buf, sizeof(CHAR), nbyte, script_fp);
! */
! 		fwrite (output_buffer->last_buf,
  			sizeof(CHAR), nbyte, script_fp);
  	}
  	else if (nbyte < 0) {

--- 601,607 -----
  	     * Write to script file
  	     */
  	    if (script_fp)
! 		fwrite (output_buffer->b_lastbuf,
  			sizeof(CHAR), nbyte, script_fp);
  	}
  	else if (nbyte < 0) {
***************
*** 898,903
  	}
      }
  }
  
  usageAndExit()
  {

--- 896,902 -----
  	}
      }
  }
+ 
  
  usageAndExit()
  {
*** /tmp/,RCSt1008707	Tue Aug 23 01:44:24 1988
--- Makefile	Mon Aug 22 02:01:07 1988
***************
*** 1,7
  #
  # Copyright (c) 1987, 1988 by Software Research Associates, Inc.
  #
! # $Header: Makefile,v 4.0 88/08/05 20:24:19 utashiro Exp $
  #
  # Options:
  #	KANJI:	SHIFT-JIS kanji code handling on ASCII KANJI UNIX

--- 1,7 -----
  #
  # Copyright (c) 1987, 1988 by Software Research Associates, Inc.
  #
! # $Header: Makefile,v 4.1 88/08/08 19:22:26 utashiro Exp $
  #
  # Options:
  #	KANJI:	SHIFT-JIS kanji code handling on ASCII KANJI UNIX
***************
*** 21,28
  #KANJI	= -DKANJI#		Delete # for KANJI handling
  CONFIG	= $(STAT) $(KANJI)
  
! DEBUG	= -g
! #DEBUG	= -O
  
  CFLAGS	= $(DEBUG) $(CONFIG)
  LDFLAGS = -ltermlib

--- 21,28 -----
  #KANJI	= -DKANJI#		Delete # for KANJI handling
  CONFIG	= $(STAT) $(KANJI)
  
! #DEBUG	= -g
! DEBUG	= -O
  
  CFLAGS	= $(DEBUG) $(CONFIG)
  LDFLAGS = -ltermlib
*** /tmp/,RCSt1008717	Tue Aug 23 01:44:29 1988
--- fep.1	Mon Aug 22 02:01:09 1988
***************
*** 1,5
  .\" Copyright (c) 1987, 1988 by Software Research Associates, Inc.
! .\" $Header: fep.1,v 4.0 88/08/05 20:22:31 utashiro Rel $
  .TH FEP 1L "5 Aug 1988" "SRA Distribution"
  .SH NAME
  fep \(em general purpose front end processor

--- 1,5 -----
  .\" Copyright (c) 1987, 1988 by Software Research Associates, Inc.
! .\" $Header: fep.1,v 4.2 88/08/16 18:22:50 utashiro Exp $
  .TH FEP 1L "5 Aug 1988" "SRA Distribution"
  .SH NAME
  fep \(em general purpose front end processor
***************
*** 51,56
  ^X-^C	terminate
  ^X-^D	send-eof
  ^X-^L	repaint
  ^X-(	start-script
  ^X-)	end-script
  esc-b	backward-word

--- 51,57 -----
  ^X-^C	terminate
  ^X-^D	send-eof
  ^X-^L	repaint
+ ^X-^V	view-buffer
  ^X-(	start-script
  ^X-)	end-script
  esc-b	backward-word
***************
*** 99,104
  ^R	reprint
  ^^	toggle-transparency
  ^X-^B	show-bindings
  ^X-^H	show-history
  ^X-^L	repaint
  ^X-^X	expand-file-name

--- 100,107 -----
  ^R	reprint
  ^^	toggle-transparency
  ^X-^B	show-bindings
+ ^X-^C	terminate
+ ^X-^D	send-eof
  ^X-^H	show-history
  ^X-^L	repaint
  ^X-^X	expand-file-name
***************
*** 102,109
  ^X-^H	show-history
  ^X-^L	repaint
  ^X-^X	expand-file-name
! ^X-^C	terminate
! ^X-^D	send-eof
  ^X-l	list-file-name
  ^X-L	list-file-name
  ^X-?	help

--- 105,111 -----
  ^X-^H	show-history
  ^X-^L	repaint
  ^X-^X	expand-file-name
! ^X-^V	view-buffer
  ^X-l	list-file-name
  ^X-L	list-file-name
  ^X-?	help
***************
*** 308,313
  uses some variables.
  .RS 3n
  .ta 3i
  .IP "\fBeditmode\fP	default: emacs"
  This variable defines the mode for command line editing.
  Key bindings will be set for the appropriate defaults

--- 310,359 -----
  uses some variables.
  .RS 3n
  .ta 3i
+ .\"@@@@@
+ .IP "\fBalarm-on-eof\fP	default: off"
+ If this variable is set
+ AND the function send-eof is not bound to the eof character
+ AND the variable ignore-eof is not set,
+ an alarm message will be displayed once
+ the first time eof is encountered on an empty line.
+ .\"@@@@@
+ .IP "\fBauto-repaint\fP	default: off"
+ If this variable is set, \fIfep\fP automatically repaints the screen
+ after restarting.
+ .\"@@@@@
+ .IP "\fBauto-tty-fix\fP	default: on"
+ If this variable is set,
+ .I fep
+ looks at the tty mode of the sub-command,
+ and if the tty mode has changed,
+ .I fep
+ fixes the tty mode of standard out and
+ sets the transparency flag according to the mode.
+ If this variable is not set, the automatic tty mode check is not done,
+ so you have to change the tty mode and transparency explicitly using the
+ \fItoggle-transparency\fP function.
+ .\"@@@@@
+ .IP "\fBbuffer\fP	default: 5120"
+ Specifies command output buffer size.
+ High-watermark used in buffer management mechanism
+ will be set 4/5 of this count.
+ .\"@@@@@
+ .IP "\fBclear-repaint\fP	default: off"
+ If this variable is set, \fIfep\fP clears the screen before repainting.
+ .\"@@@@@
+ .IP "\fBcommand\fP	default: \fIcommand-name\fR"
+ .I Fep
+ set this variable to the command name of the sub-process when it starts up.
+ .\"@@@@@
+ .IP "\fBcrt\fP	default: terminal size"
+ If set, more message is shown during printing the key bindings
+ on each number of line specified by this variable.
+ .\"@@@@@
+ .IP "\fBdelimiters\fP	default: SPACE & TAB"
+ The contents of this variable are treated as delimiting characters for
+ file name expantion and file name list.
+ .\"@@@@@
  .IP "\fBeditmode\fP	default: emacs"
  This variable defines the mode for command line editing.
  Key bindings will be set for the appropriate defaults
***************
*** 319,324
  and finally reads in the
  .I .feprc
  start-up file.
  .IP "\fBexpand-tilde\fP	default: on"
  .I Fep
  expands "~" to the real home directory name by the expand-file-name function

--- 365,371 -----
  and finally reads in the
  .I .feprc
  start-up file.
+ .\"@@@@@
  .IP "\fBexpand-tilde\fP	default: on"
  .I Fep
  expands "~" to the real home directory name by the expand-file-name function
***************
*** 323,340
  .I Fep
  expands "~" to the real home directory name by the expand-file-name function
  when this variable is set.
! .IP "\fBignore-empty-line\fP	default: on"
! If this variable is set, empty command lines are not saved in the history file.
! .IP "\fBignore-same-line\fP	default: on"
! If this variable is set,
! command lines identical to the previous command line
! are not saved to the history file.
! .IP "\fBalarm-on-eof\fP	default: off"
! If this variable is set
! AND the function send-eof is not bound to the eof character
! AND the variable ignore-eof is not set,
! an alarm message will be displayed once
! the first time eof is encountered on an empty line.
  .IP "\fBhistory\fR	default: 100"
  .I Fep
  maintains a history file of the length specified by this variable.

--- 370,376 -----
  .I Fep
  expands "~" to the real home directory name by the expand-file-name function
  when this variable is set.
! .\"@@@@@
  .IP "\fBhistory\fR	default: 100"
  .I Fep
  maintains a history file of the length specified by this variable.
***************
*** 338,352
  .IP "\fBhistory\fR	default: 100"
  .I Fep
  maintains a history file of the length specified by this variable.
! .IP "\fBsavehist\fR	default: off"
! If
! .I savehist
! is set
! .I fep
! saves the number of history entries specified by
! value of this variable in the file named in the variable
! .I history-file
! on terminating.
  .IP "\fBhistory-file\fP	default: .fephistory"
  Contains the name of the history file for reading from and writing to.
  If the file described by this variable exists,

--- 374,380 -----
  .IP "\fBhistory\fR	default: 100"
  .I Fep
  maintains a history file of the length specified by this variable.
! .\"@@@@@
  .IP "\fBhistory-file\fP	default: .fephistory"
  Contains the name of the history file for reading from and writing to.
  If the file described by this variable exists,
***************
*** 353,362
  .I fep
  will read the file into the history buffer on start up
  and then save the current session's history when it exits.
! .IP "\fBshowhist\fR	default: terminal size"
! This variable specifies the number of history lines to be displayed by the
! .I show-history
! function.
  .IP "\fBignore-eof\fP	default: off"
  .I Fep
  never worries about the eof character if this variable is set.

--- 381,390 -----
  .I fep
  will read the file into the history buffer on start up
  and then save the current session's history when it exits.
! .\"@@@@@
! .IP "\fBignore-empty-line\fP	default: on"
! If this variable is set, empty command lines are not saved in the history file.
! .\"@@@@@
  .IP "\fBignore-eof\fP	default: off"
  .I Fep
  never worries about the eof character if this variable is set.
***************
*** 360,365
  .IP "\fBignore-eof\fP	default: off"
  .I Fep
  never worries about the eof character if this variable is set.
  .IP "\fBnoalias\fP	default: off"
  If set, command aliasing won't be done.
  .IP "\fBcrt\fP	default: terminal size"

--- 388,399 -----
  .IP "\fBignore-eof\fP	default: off"
  .I Fep
  never worries about the eof character if this variable is set.
+ .\"@@@@@
+ .IP "\fBignore-same-line\fP	default: on"
+ If this variable is set,
+ command lines identical to the previous command line
+ are not saved to the history file.
+ .\"@@@@@
  .IP "\fBnoalias\fP	default: off"
  If set, command aliasing won't be done.
  .\"@@@@@
***************
*** 362,405
  never worries about the eof character if this variable is set.
  .IP "\fBnoalias\fP	default: off"
  If set, command aliasing won't be done.
! .IP "\fBcrt\fP	default: terminal size"
! If set, more message is shown during printing the key bindings
! on each number of line specified by this variable.
! .IP "\fBcommand\fP	default: \fIcommand-name\fR"
! .I Fep
! set this variable to the command name of the sub-process when it starts up.
! .IP "\fBshell\fR	default: /bin/sh"
! Describe the command name to be invoked by 
! .IR invoke-shell .
! .IP "\fBauto-tty-fix\fP	default: on"
! If this variable is set,
! .I fep
! looks at the tty mode of the sub-command,
! and if the tty mode has changed,
! .I fep
! fixes the tty mode of standard out and
! sets the transparency flag according to the mode.
! If this variable is not set, the automatic tty mode check is not done,
! so you have to change the tty mode and transparency explicitly using the
! \fItoggle-transparency\fP function.
! .IP "\fBtty-fix-bell\fP	default: off"
! If this variable is set,
! .I fep
! rings the bell when the tty mode is changed.
! .IP "\fBscript-file\fP	default: fepscript"
! This variable is used by the
! .I fep-start-script
! command and by the
! .I start-script
! function.
! .IP "\fBdelimiters\fP	default: SPACE & TAB"
! The contents of this variable are treated as delimiting characters for
! file name expantion and file name list.
! .IP "\fBauto-repaint\fP	default: off"
! If this variable is set, \fIfep\fP automatically repaints the screen
! after restarting.
! .IP "\fBclear-repaint\fP	default: off"
! If this variable is set, \fIfep\fP clears the screen before repainting.
  .IP "\fBprompt\fP	default: see below"
  .I Fep
  outputs a prompt after executing built-in functions.

--- 396,402 -----
  .\"@@@@@
  .IP "\fBnoalias\fP	default: off"
  If set, command aliasing won't be done.
! .\"@@@@@
  .IP "\fBprompt\fP	default: see below"
  .I Fep
  outputs a prompt after executing built-in functions.
***************
*** 428,433
  \h'\w'MMMMM'u'endif
  .fi
  .RE
  .RE
  .PP
  .B Start-Up File

--- 425,462 -----
  \h'\w'MMMMM'u'endif
  .fi
  .RE
+ .ta 3i
+ .\"@@@@@
+ .IP "\fBsavehist\fR	default: off"
+ If
+ .I savehist
+ is set
+ .I fep
+ saves the number of history entries specified by
+ value of this variable in the file named in the variable
+ .I history-file
+ on terminating.
+ .\"@@@@@
+ .IP "\fBscript-file\fP	default: fepscript"
+ This variable is used by the
+ .I fep-start-script
+ command and by the
+ .I start-script
+ function.
+ .\"@@@@@
+ .IP "\fBshell\fR	default: /bin/sh"
+ Describe the command name to be invoked by 
+ .IR invoke-shell .
+ .\"@@@@@
+ .IP "\fBshowhist\fR	default: terminal size"
+ This variable specifies the number of history lines to be displayed by the
+ .I show-history
+ function.
+ .\"@@@@@
+ .IP "\fBtty-fix-bell\fP	default: off"
+ If this variable is set,
+ .I fep
+ rings the bell when the tty mode is changed.
  .RE
  .\" ------------------------------------------------------------ Startup file
  .PP
***************
*** 429,434
  .fi
  .RE
  .RE
  .PP
  .B Start-Up File
  .PP

--- 458,464 -----
  .I fep
  rings the bell when the tty mode is changed.
  .RE
+ .\" ------------------------------------------------------------ Startup file
  .PP
  .B Start-Up File
  .PP
***************
*** 438,443
  It looks for arguments on the command line first,
  and only then reads the ".feprc" file,
  so the file has higher priority.
  .PP
  .B "Functions"
  .PP

--- 468,474 -----
  It looks for arguments on the command line first,
  and only then reads the ".feprc" file,
  so the file has higher priority.
+ .\" ------------------------------------------------------------ Functions
  .PP
  .B "Functions"
  .PP
***************
*** 499,504
  vi-motion	Vi cursor motion commands
  vi-new-line	Vi new line
  vi-num	Vi prefix number
  yank-from-kill-buffer	Yank from kill buffer
  .fi
  .RE

--- 530,536 -----
  vi-motion	Vi cursor motion commands
  vi-new-line	Vi new line
  vi-num	Vi prefix number
+ view-buffer	View buffer
  yank-from-kill-buffer	Yank from kill buffer
  .fi
  .RE



More information about the Comp.sources.bugs mailing list