Vi bug with fix

Wayne Krone wk at hpirs.HP.COM
Fri Sep 2 14:12:11 AEST 1988


> Description:
>     Vi dumps core (segmentation violation or bus error) if initializations 
>     contain 'open'.  So does ex.
> 
> Repeat By:
>     setenv EXINIT open
>     vi foo 

I applied this fix and it stops the core dumps (thanks!!).  But, at least
on my implementation, any text inserted into the buffer via the 'open'
command is lost at the point init() is called a second time.  I.e.:

      setenv EXINIT open
      vi
      ithis is a test^[			<-- text inserted during open mode
      Q					<-- quit open mode
					 -- now in vi mode but buffer is empty

Should the 'open' be useful or just not core dump?

Presuming it should work, a fix is to call init() a second time only if
the directory option has been set.  Following are some deltas to Charles'
deltas with this change.

Wayne Krone

********************
To ex.h add:

var	bool	dir_chg;	/* true if directory option reset */

********************
To ex.c modify Charles' changes as follows:

--------------------
Charles' version:
>   				setterm(cp);
>   		}
>   	}
> + 	init(); /* moved up here in case initializations contain open command */
>   	if (setexit() == 0 && !fast && intty) {
>   		if ((globp = getenv("EXINIT")) && *globp)
>   			commands(1,1);

new:
  				setterm(cp);
  		}
  	}
 	init(); /* moved up here in case initializations contain open command */
  	if (setexit() == 0 && !fast && intty) {
+		dir_chg = 0;
  		if ((globp = getenv("EXINIT")) && *globp)
  			commands(1,1);

--------------------
Charles' version:
>   		 */
>   		 if (iownit(".exrc"))
>   			source(".exrc", 1);
> + 		 init();  /* Init again in case user changed dir */
>   	}
>   

new:
  		 */
  		 if (iownit(".exrc"))
  			source(".exrc", 1);
+		 if (dir_chg)
!			 init();  /* Init again if user changed dir */
  	}

********************
To ex_set.c add (~line 106 on 4.2):

                case STRING:
		case OTERM:
+			dir_chg = (op == &options[DIRECTORY]);  /* flag if user changing dir */
			cp = optname;
			while (!setend()) {
				if (cp >= &optname[ONMSZ])



More information about the Comp.bugs.4bsd.ucb-fixes mailing list