From dan@mdbs.mdbs.com Tue Apr  4 17:18:52 1995
Received: from cioeserv.cioe.com (cioeserv.cioe.com [204.120.165.36]) by walker (8.6.9/8.6.9) with ESMTP id RAA03819 for <dan@walker.cioe.com>; Tue, 4 Apr 1995 17:18:43 -0500
Received: from speedy.mdbs.com (gw.mdbs.com [204.120.165.62]) by cioeserv.cioe.com (8.6.9/1.34) with SMTP
 	 id QAA04094 for <dan@walker.cioe.com>; Tue, 4 Apr 1995 16:44:52 -0500
Received: from mdbs.mdbs.com by speedy.mdbs.com (5.x/SMI-SVR4)
id AA19436; Tue, 4 Apr 1995 16:51:29 -0500
Received: by mdbs.mdbs.com (4.1/SMI-4.1)
id AA15296; Tue, 4 Apr 95 16:51:30 EST
Date: Tue, 4 Apr 95 16:51:30 EST
From: dan@mdbs.mdbs.com (Daniel Lawrence)
Message-Id: <9504042151.AA15296@mdbs.mdbs.com>
To: dan@walker.cioe.com
Subject: more
Status: RO

!m 350
From 72330.501@compuserve.com Mon Apr  3 23:52:47 1995
Return-Path: <72330.501@compuserve.com>
From: John Gamble <72330.501@compuserve.com>
To: emacs <emacs@mdbs.mdbs.com>
Subject: !while TRUE

To: emacs

Interesting phenomenon:  If the following procedure is placed in your
start-up file (emacs.rc or .emacsrc) then MicroEMACS will choke on the
"!while TRUE" statememt.  But if you create a separate buffer (e.g.,
"test") and run execute-buffer "test", the procedure is defined with no
trouble at all.  Likewise, if you create a separate file, "test.cmd",
and execute-file "test.cmd", the procedure is defined.

Is the startup file run with a different function than the
execute-buffer or execute-file commands?

This function was originally written in the MEWIN.CMD file by Pierre
Perret.

; This macro saves all the modified buffers to their respective
; files
store-procedure save-all-buffers
	set %tmp $cbufname
	!while TRUE
		!force save-file
		!force next-buffer
		!if &seq %tmp $cbufname
			!return
		!endif
	!endwhile
!endm

	-john

net address:	72330.501@compuserve.com
		jgamble@ripco.com
telephone:	(312) 784-VILE

Number of absentee ballots submitted in the 37th ward for the February
28th primary election: 2,848.

Number of absentee ballots so far for the April 4th election, after the
above inspired a criminal probe: 24.
	numbers from the 23 March 1995 Chicago Sun-Times



From dan@mdbs.mdbs.com Tue Apr  4 17:19:09 1995
Received: from cioeserv.cioe.com (cioeserv.cioe.com [204.120.165.36]) by walker (8.6.9/8.6.9) with ESMTP id RAA03823 for <dan@walker.cioe.com>; Tue, 4 Apr 1995 17:18:55 -0500
Received: from speedy.mdbs.com (gw.mdbs.com [204.120.165.62]) by cioeserv.cioe.com (8.6.9/1.34) with SMTP
 	 id QAA04087 for <dan@walker.cioe.com>; Tue, 4 Apr 1995 16:44:30 -0500
Received: from mdbs.mdbs.com by speedy.mdbs.com (5.x/SMI-SVR4)
id AA19432; Tue, 4 Apr 1995 16:51:08 -0500
Received: by mdbs.mdbs.com (4.1/SMI-4.1)
id AA15034; Tue, 4 Apr 95 16:51:09 EST
Date: Tue, 4 Apr 95 16:51:09 EST
From: dan@mdbs.mdbs.com (Daniel Lawrence)
Message-Id: <9504042151.AA15034@mdbs.mdbs.com>
To: dan@walker.cioe.com
Subject: more
Status: RO

From 72330.501@compuserve.com Mon Apr  3 23:51:56 1995
Return-Path: <72330.501@compuserve.com>
From: John Gamble <72330.501@compuserve.com>
To: dan <dan@mdbs.com>
Subject: re-room()

To: dan

You may have already written this, but in case you haven't, here you go.

This is basically your room() function with a couple of changes for
realloc().  I also put in the NULL pointer check at the beginning of the
function, which means all that special conditional code in search.c and
replace.c can go away once the realloc() calls there are replaced.

x/*	RE-ROOM: Allocate memory using realloc()
x		on failure, discard oldest undo information
x		and retry
x*/
x
x#if	PROTO
xvoid *reroom(void *orig_ptr, int nbytes)
x#else
xvoid *reroom(orig_ptr, nbytes)
x
xint nbytes;	/* number of bytes to malloc() */
xvoid *orig_ptr;
x#endif
x{
x	void *ptr;	/* temporary pointer */
x	BUFFER *bp;	/* buffer to dealloc memory from */
x	UNDO_OBJ *up;	/* ptr to undo struct to free */
x	UNDO_OBJ *lp;	/* last undo struct before up */
x
x	/*
x	 * Avoid the whole problem of non-ANSI realloc() functions
x	 * that don't handle NULL pointers correctly by calling
x	 * malloc() (by way of room()) directly if orig_ptr is NULL.
x	 */
x	if (orig_ptr == NULL) return (room(nbytes));
x
x	ptr = (char *)NULL;
x	while (ptr == (char *)NULL) {
x
x		/* attempt to allocate the memory */
x		ptr = realloc(orig_ptr, nbytes);
x		if (ptr != (char *)NULL)
x			return(ptr);
x
x		/* find the oldest visited buffer */
xnextbuf:	bp = getoldb();
x
x		/* no buffers left to check? */
x		if (bp == (BUFFER *)NULL)
x			return((char *)NULL);
x
x		/* any undo info to discard? */
x		if (bp->undo_count == 0) {
x			bp->last_access = 0;
x			goto nextbuf;
x		}
x
x		/* dump the last undo structure */
x		lp = (UNDO_OBJ *)NULL;
x		up = bp->undo_head;
x		while (up->next != (UNDO_OBJ *)NULL) {
x			lp = up;
x			up = up->next;
x		}
x
x		/* dump the oldest undo */
x		free((char *)up);
x		lp->next = (UNDO_OBJ *)NULL;
x		bp->undo_count--;
x	}
x}

	-john

net address:	72330.501@compuserve.com
		jgamble@ripco.com
telephone:	(312) 784-VILE

Number of absentee ballots submitted in the 37th ward for the February
28th primary election: 2,848.

Number of absentee ballots so far for the April 4th election, after the
above inspired a criminal probe: 24.
	numbers from the 23 March 1995 Chicago Sun-Times



From dan@mdbs.mdbs.com Tue Apr  4 17:19:28 1995
Received: from cioeserv.cioe.com (cioeserv.cioe.com [204.120.165.36]) by walker (8.6.9/8.6.9) with ESMTP id RAA03829 for <dan@walker.cioe.com>; Tue, 4 Apr 1995 17:19:13 -0500
Received: from speedy.mdbs.com (gw.mdbs.com [204.120.165.62]) by cioeserv.cioe.com (8.6.9/1.34) with SMTP
 	 id QAA04083 for <dan@walker.cioe.com>; Tue, 4 Apr 1995 16:44:03 -0500
Received: from mdbs.mdbs.com by speedy.mdbs.com (5.x/SMI-SVR4)
id AA19427; Tue, 4 Apr 1995 16:50:41 -0500
Received: by mdbs.mdbs.com (4.1/SMI-4.1)
id AA14765; Tue, 4 Apr 95 16:50:42 EST
Date: Tue, 4 Apr 95 16:50:42 EST
From: dan@mdbs.mdbs.com (Daniel Lawrence)
Message-Id: <9504042150.AA14765@mdbs.mdbs.com>
To: dan@walker.cioe.com
Subject: forwarded
Status: RO

From 72330.501@compuserve.com Mon Apr  3 23:51:27 1995
Return-Path: <72330.501@compuserve.com>
From: John Gamble <72330.501@compuserve.com>
To: dan <dan@mdbs.com>
Subject: OVER mode

To: dan

Before i forget: my work number right now is (708) 267-3885, but don't
bother to put it in your telephone list file, because it will only be
that for this month.  In May my number will probably change again.

I made a fix for the multiple characters in OVER (and REP) mode.  This
is the bug that occurs when you type something like <META>12-, which in
OVER mode only overwrites one character and inserts the other 11.

Find and remove the block of code in execute() in MAIN.C (it starts at
line 804 for me) that goes:
----------------------------------------------------------------
x		/* replace or overwrite mode, not at the end of a string */
x		if (curwp->w_bufp->b_mode & (MDREPL | MDOVER) &&
x			curwp->w_doto < lused(curwp->w_dotp))
x			{
x
x			/* if we are in replace mode, or
x			   (next char is not a tab or we are at a tab stop) */
x			if (curwp->w_bufp->b_mode & MDREPL ||
x				((lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || tabsize == 0) ||
x				getccol(FALSE) % tabsize == (tabsize - 1)))
x				ldelete(1L, FALSE);
x			}
x
x		/* do the appropriate insertion */
x		if (c == '}' && (curbp->b_mode & MDCMOD) != 0)
x			status = insbrace(n, c);
x		else if (c == '#' && (curbp->b_mode & MDCMOD) != 0)
x			status = inspound();
x#if	DBCS
x		else if (is2char(c)) {
x			schar = getkey();
x			status = TRUE;
x			while (n--) {
x				if (linsert(1, c) == FALSE)
x					status = FALSE;
x				if (linsert(1, schar) == FALSE)
x					status = FALSE;
x			}
x		}
x#endif
x
x		else
x			status = linsert(n, c);
x
----------------------------------------------------------------

And replace it with:
----------------------------------------------------------------
x
x#if	DBCS
x		/* Get the second half of a double-byte character.*/
x		if (is2char(c))
x			schar = getkey();
x#endif
x
x		/* replace or overwrite mode, not at the end of a string */
x		if (curwp->w_bufp->b_mode & (MDREPL | MDOVER) &&
x			curwp->w_doto < lused(curwp->w_dotp))
x		{
x			do
x			{
x				/* if we are in replace mode, or
x				   (next char is not a tab or we are at a tab stop) */
x				if (curwp->w_bufp->b_mode & MDREPL ||
x					((lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || tabsize == 0) ||
x					getccol(FALSE) % tabsize == (tabsize - 1)))
x					ldelete(1L, FALSE);
x
x				/* do the appropriate insertion */
x				if (c == '}' && (curbp->b_mode & MDCMOD) != 0)
x					status = insbrace(1, c);
x				else if (c == '#' && (curbp->b_mode & MDCMOD) != 0)
x					status = inspound();
x				else {
x					status = linsert(1, c);
x#if	DBCS
x					/* Insert the second half of a double-byte character.*/
x					if (is2char(c))
x						status = linsert(1, schar);
x#endif
x				}
x			} while (--n > 0 && curwp->w_doto < lused(curwp->w_dotp) && status == TRUE);
x		}
x
x		/* do the appropriate insertion */
x		if (n > 0) {
x			if (c == '}' && (curbp->b_mode & MDCMOD) != 0)
x				status = insbrace(n, c);
x			else if (c == '#' && (curbp->b_mode & MDCMOD) != 0)
x				status = inspound();
x#if	DBCS
x			else if (is2char(c)) {
x				status = TRUE;
x				while (n--) {
x					if (linsert(1, c) == FALSE)
x						status = FALSE;
x					if (linsert(1, schar) == FALSE)
x						status = FALSE;
x				}
x			}
x#endif	
x			else
x				status = linsert(n, c);
x		}
----------------------------------------------------------------

I've tested it under both OVER and REP modes, and it works just fine.  I
have not tested on a machine with double-byte characters, but i believe
it will work correctly, since it is ldelete() that ensures that no half
a double-byte character hangs around.

	-john

net address:	72330.501@compuserve.com
		jgamble@ripco.com
telephone:	(312) 784-VILE

Number of absentee ballots submitted in the 37th ward for the February
28th primary election: 2,848.

Number of absentee ballots so far for the April 4th election, after the
above inspired a criminal probe: 24.
	numbers from the 23 March 1995 Chicago Sun-Times



