Subject: quit with modified files

From: Scott Schwartz <[email-masked]>
Date: Mon, 24 May 1993 14:48:36 -0400

Is this a bug?

	; sam -d
	B /etc/fstab
	 -. /etc/fstab
	i
	a
	b
	c
	.
	B /etc/motd
	 -. /etc/motd
	n
	 -  
	'-  /etc/fstab
	 -. /etc/motd
	q
	;

---

From: Chris Siebenmann <cks>
Date: Tue, 25 May 1993 19:07:35 -0400

It's a bug. It happens if you call in a clean file and immediately
try to quit; edit() in sam/sam.c doesn't set the global dirty file state
quite right. I've attached a patch.

	- cks
*** /tmp/,RCSt1a04954	Tue May 25 19:05:06 1993
--- sam/sam.c	Tue May 25 18:47:16 1993
***************
*** 331,337 ****
  		f->ndot.r.p1 = addr.r.p2, f->ndot.r.p2 = addr.r.p2+p;
  	else
  		f->ndot.r.p1 = f->ndot.r.p2 = 0;
! 	quitok = f->closeok = empty;
  	state(f, empty && !nulls? Clean : Dirty);
  	if(cmd == 'e')
  		filename(f);
--- 331,337 ----
  		f->ndot.r.p1 = addr.r.p2, f->ndot.r.p2 = addr.r.p2+p;
  	else
  		f->ndot.r.p1 = f->ndot.r.p2 = 0;
! 	quitok = quitok ? (f->closeok = empty) : FALSE;
  	state(f, empty && !nulls? Clean : Dirty);
  	if(cmd == 'e')
  		filename(f);

---

From: Scott Schwartz <[email-masked]>
Date: Wed, 26 May 1993 20:21:12 -0400

Thanks for the patch Chris.  But now I have a second question. :-)
Consider this:

	; sam/sam -d                 
	B /etc/fstab
	 -. /etc/fstab
	i
	foo
	.
	D /etc/fstab
	?changes to "/etc/fstab"
	B /etc/svdtab
	 -. /etc/svdtab
	D /etc/fstab
	q

In other words, the second close attempt on a file will always succeed,
even if other operations have taken place in the meantime.  That seems
rather aggressive to me; when the man page talks about a ``subsequent
D'', I expected that it meant an immediately subsequent one.