🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #1151

Re: Vi bug with fix

#1151
From: Wayne Krone
Date: Fri, 02 Sep 1988 04:12
80 lines
2470 bytes
> 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])
Technical Details
Message-ID: <3900003@hpirs.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hpda!hpcupt1!hpirs!wk
References: <1264@unisoft.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hpda!hpcupt1!hpirs!wk
From: wk@hpirs.HP.COM (Wayne Krone)
Newsgroups: comp.bugs.4bsd
Subject: Re: Vi bug with fix
Message-ID: <3900003@hpirs.HP.COM>
Date: 2 Sep 88 04:12:11 GMT
References: <1264@unisoft.UUCP>
Organization: Hewlett Packard, Cupertino
Lines: 79