[comp.sources.bugs] vmail bug+fix

jz@mulga.oz (Justin Zobel) (11/27/87)

The commands 'p' and 'n' dump core if used to page past the end of the
folder list.  Following is a fix.

									jz


*** page.c.orig	Thu Nov  5 11:14:46 1987
--- page.c	Thu Nov  5 11:23:21 1987
***************
*** 174,180 ****
  
  	for( ; count > 0 ; count--) {
  			/* skip other pages of current folder */
! 		for(f=p ; p->next->name == f->name ; p=p->next)
  			;
  		if(p->next == (folder) NULL) {
  			addstatus("last folder", true);
--- 174,180 ----
  
  	for( ; count > 0 ; count--) {
  			/* skip other pages of current folder */
! 		for(f=p ; p->next && p->next->name == f->name ; p=p->next)
  			;
  		if(p->next == (folder) NULL) {
  			addstatus("last folder", true);
***************
*** 219,227 ****
  
  	for( ; count > 0 ; count--) {
  			/* skip other pages of current folder */
! 		for(f=p ; p->prev->name == f->name ; p=p->prev)
  			;
! 		if(curflr->prev == (folder) NULL) {
  			addstatus("first folder", true);
  			break;
  		} else {
--- 219,227 ----
  
  	for( ; count > 0 ; count--) {
  			/* skip other pages of current folder */
! 		for(f=p ; p->prev && p->prev->name == f->name ; p=p->prev)
  			;
! 		if(p->prev == (folder) NULL) {
  			addstatus("first folder", true);
  			break;
  		} else {
***************
*** 243,249 ****
  			addstatus("can't go back that many folders", true);
  		else {
  				/* skip other pages of current folder */
! 			for(f=p ; p->prev->name == f->name ; p=p->prev)
  				;
  			alternate = curflr;
  			curflr = p;
--- 243,249 ----
  			addstatus("can't go back that many folders", true);
  		else {
  				/* skip other pages of current folder */
! 			for(f=p ; p->prev && p->prev->name == f->name ; p=p->prev)
  				;
  			alternate = curflr;
  			curflr = p;

jz@mulga.oz (Justin Zobel) (11/27/87)

Following is a patch to make vmail work properly on a Pyramid.  The flag
PYRAMID must be set on compilation.

									jz


*** init.c	Thu Oct  8 10:32:45 1987
--- init.c	Fri Nov 27 11:20:46 1987
***************
*** 43,48
  	cols = tgetnum("co");
  		/* lines holds no. of lines for headers, ie "li" less STATUS, TITLE */
  	lines = tgetnum("li") - 2;
  	ioctl(0, TIOCGETP, &tty);
  	ioctl(0, TIOCGETP, &chrs);
  	ioctl(0, TIOCGETP, &lchrs);

--- 43,49 -----
  	cols = tgetnum("co");
  		/* lines holds no. of lines for headers, ie "li" less STATUS, TITLE */
  	lines = tgetnum("li") - 2;
+ #ifdef	PYRAMID
  	ioctl(0, TIOCGETP, &tty);
  	ioctl(0, TIOCGETC, &chrs);
  	ioctl(0, TIOCLGET, &lchrs);
***************
*** 44,49
  		/* lines holds no. of lines for headers, ie "li" less STATUS, TITLE */
  	lines = tgetnum("li") - 2;
  	ioctl(0, TIOCGETP, &tty);
  	ioctl(0, TIOCGETP, &chrs);
  	ioctl(0, TIOCGETP, &lchrs);
  

--- 45,54 -----
  	lines = tgetnum("li") - 2;
  #ifdef	PYRAMID
  	ioctl(0, TIOCGETP, &tty);
+ 	ioctl(0, TIOCGETC, &chrs);
+ 	ioctl(0, TIOCLGET, &lchrs);
+ #else
+ 	ioctl(0, TIOCGETP, &tty);
  	ioctl(0, TIOCGETP, &chrs);
  	ioctl(0, TIOCGETP, &lchrs);
  #endif	PYRAMID
***************
*** 46,51
  	ioctl(0, TIOCGETP, &tty);
  	ioctl(0, TIOCGETP, &chrs);
  	ioctl(0, TIOCGETP, &lchrs);
  
  	read_profile(&pargc, pargv, profile, home);
  	process_args(pargc, pargv);

--- 51,57 -----
  	ioctl(0, TIOCGETP, &tty);
  	ioctl(0, TIOCGETP, &chrs);
  	ioctl(0, TIOCGETP, &lchrs);
+ #endif	PYRAMID
  
  	read_profile(&pargc, pargv, profile, home);
  	process_args(pargc, pargv);
***************
*** 74,79
  	signal(SIGTSTP, tstp);
  	signal(SIGINT, tint);
  
  	ioctl(0, TIOCGETP, &t_tty);
  	ioctl(0, TIOCGETP, &t_chrs);
  	ioctl(0, TIOCGETP, &t_lchrs);

--- 80,86 -----
  	signal(SIGTSTP, tstp);
  	signal(SIGINT, tint);
  
+ #ifdef	PYRAMID
  	ioctl(0, TIOCGETP, &t_tty);
  	ioctl(0, TIOCGETC, &t_chrs);
  	ioctl(0, TIOCLGET, &t_lchrs);
***************
*** 75,80
  	signal(SIGINT, tint);
  
  	ioctl(0, TIOCGETP, &t_tty);
  	ioctl(0, TIOCGETP, &t_chrs);
  	ioctl(0, TIOCGETP, &t_lchrs);
  

--- 82,91 -----
  
  #ifdef	PYRAMID
  	ioctl(0, TIOCGETP, &t_tty);
+ 	ioctl(0, TIOCGETC, &t_chrs);
+ 	ioctl(0, TIOCLGET, &t_lchrs);
+ #else
+ 	ioctl(0, TIOCGETP, &t_tty);
  	ioctl(0, TIOCGETP, &t_chrs);
  	ioctl(0, TIOCGETP, &t_lchrs);
  #endif	PYRAMID
***************
*** 77,82
  	ioctl(0, TIOCGETP, &t_tty);
  	ioctl(0, TIOCGETP, &t_chrs);
  	ioctl(0, TIOCGETP, &t_lchrs);
  
  	y = FIRST;
  	display_page();

--- 88,94 -----
  	ioctl(0, TIOCGETP, &t_tty);
  	ioctl(0, TIOCGETP, &t_chrs);
  	ioctl(0, TIOCGETP, &t_lchrs);
+ #endif	PYRAMID
  
  	y = FIRST;
  	display_page();
***************
*** 297,302
  void
  no_control()
  {
  	ioctl(0, TIOCSETP, &tty);
  	ioctl(0, TIOCSETP, &chrs);
  	ioctl(0, TIOCSETP, &lchrs);

--- 309,315 -----
  void
  no_control()
  {
+ #ifdef	PYRAMID
  	ioctl(0, TIOCSETP, &tty);
  	ioctl(0, TIOCSETC, &chrs);
  	ioctl(0, TIOCLSET, &lchrs);
***************
*** 298,303
  no_control()
  {
  	ioctl(0, TIOCSETP, &tty);
  	ioctl(0, TIOCSETP, &chrs);
  	ioctl(0, TIOCSETP, &lchrs);
  }

--- 311,320 -----
  {
  #ifdef	PYRAMID
  	ioctl(0, TIOCSETP, &tty);
+ 	ioctl(0, TIOCSETC, &chrs);
+ 	ioctl(0, TIOCLSET, &lchrs);
+ #else
+ 	ioctl(0, TIOCSETP, &tty);
  	ioctl(0, TIOCSETP, &chrs);
  	ioctl(0, TIOCSETP, &lchrs);
  #endif	PYRAMID
***************
*** 300,305
  	ioctl(0, TIOCSETP, &tty);
  	ioctl(0, TIOCSETP, &chrs);
  	ioctl(0, TIOCSETP, &lchrs);
  }
  
  

--- 317,323 -----
  	ioctl(0, TIOCSETP, &tty);
  	ioctl(0, TIOCSETP, &chrs);
  	ioctl(0, TIOCSETP, &lchrs);
+ #endif	PYRAMID
  }
  
  
***************
*** 309,314
  void
  to_control()
  {
  	ioctl(0, TIOCSETP, &t_tty);
  	ioctl(0, TIOCSETP, &t_chrs);
  	ioctl(0, TIOCSETP, &t_lchrs);

--- 327,333 -----
  void
  to_control()
  {
+ #ifdef	PYRAMID
  	ioctl(0, TIOCSETP, &t_tty);
  	ioctl(0, TIOCSETC, &t_chrs);
  	ioctl(0, TIOCLSET, &t_lchrs);
***************
*** 310,315
  to_control()
  {
  	ioctl(0, TIOCSETP, &t_tty);
  	ioctl(0, TIOCSETP, &t_chrs);
  	ioctl(0, TIOCSETP, &t_lchrs);
  }

--- 329,338 -----
  {
  #ifdef	PYRAMID
  	ioctl(0, TIOCSETP, &t_tty);
+ 	ioctl(0, TIOCSETC, &t_chrs);
+ 	ioctl(0, TIOCLSET, &t_lchrs);
+ #else
+ 	ioctl(0, TIOCSETP, &t_tty);
  	ioctl(0, TIOCSETP, &t_chrs);
  	ioctl(0, TIOCSETP, &t_lchrs);
  #endif	PYRAMID
***************
*** 312,317
  	ioctl(0, TIOCSETP, &t_tty);
  	ioctl(0, TIOCSETP, &t_chrs);
  	ioctl(0, TIOCSETP, &t_lchrs);
  }
  
  

--- 335,341 -----
  	ioctl(0, TIOCSETP, &t_tty);
  	ioctl(0, TIOCSETP, &t_chrs);
  	ioctl(0, TIOCSETP, &t_lchrs);
+ #endif	PYRAMID
  }