[gnu.g++] Two more patches for ET++

tom@tnosoes.UUCP (Tom Vijlbrief) (06/29/89)

Here are two more patches to make ET++ work with g++:

In Object.C add the ifdef to solve a compiler bug:
Bug discovered when compiling miniedit and draw. These work
perfectly now!!
===========================

void Object::FlushChanges()
{
    Collection *col= (Collection*) DelayedChanges.AtKey(this);
    if (col) {
        ObjInt *ref= (ObjInt*)col->At(0);
        if (ref->GetValue() == 0) {
            flags &= ~cObjDelayChanges;
            ChangeMessage *cm;
            Iter next(col);
            next(); // overread reference count
            while (cm= (ChangeMessage*) next())
                ChangedWhat(cm->GetWhat());
            col->FreeAll();
#ifdef __GNUG__
            Collection *tmpcol= (Collection*)DelayedChanges.RemoveKey(this);
            delete tmpcol;
#else
            delete DelayedChanges.RemoveKey(this);
#endif
        }
        else
            (*ref)--;
    }
}

============================
In the 'C' file sunwindow.c a function is called
with the wrong number of parameters.
Isn't C++ great!  :-)
=================================

static void PolyDot(port, pr, dx, dy, pts, n, pattern, mode, psz)
register struct SunWindowPort *port;
register struct pixrect *pr;
register int n;
int dx, dy, pattern, mode, psz;
register struct pr_pos *pts;
{
    register int i, x, y;
    register struct pr_pos *p;
    register struct pixrect *patpr, *penpr= 0;
    int oox, ooy, rop, Mode;

    rop= PolyTab[mode][pat2ix(pattern)].rop;
    if (psz <= 1)
        Mode= PolyTab[mode][pat2ix(pattern)].mode11;
    else {
        if (psz > 2 && psz < MAXPENS) {
            if (pens[psz] == 0)
                pens[psz]= MakePen(psz);
            penpr= pens[psz];
        }
        Mode= PolyTab[mode][pat2ix(pattern)].modeNN;
    }
#ifdef __GNUC__
    patpr= GetPattern(pattern,dx,dy);
#else
    patpr= GetPattern(pattern);
#endif
 
    if (pr) {
        if (penpr)
=======================================
===============================================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23				Phone: +31 34 63 562 11
3769 ZG  Soesterberg			E-mail: tnosoes!tom@mcvax.cwi.nl
The Netherlands				    or:	uunet!mcvax!tnosoes!tom
===============================================================================

tom@tnosoes.UUCP (Tom Vijlbrief) (06/30/89)

Four more double expression evaluation compilerbugs.

System.C:
=============================================
static void RemoveDeleted(ObjList *ol)
{
    if (ol->Size() <= 0)
	return;
    Iter next(ol);
    register SysEvtHandler *eh;
    
    while (eh= (SysEvtHandler*) next())
	if (eh->ShouldRemove())
#ifdef __GNUG__
	    { ObjPtr tmpp= ol->RemovePtr(eh); delete tmpp; }
#else
	    delete ol->RemovePtr(eh);
#endif
}
=============================================
Alert.C
===========================================

int Alert::Show(char* fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    int ret;

    if (image->IsKindOf(Cluster))
	((Cluster*)image)->SetModified();
    char *buf= strvprintf(fmt, ap);
    if (gWinInit) {
#ifdef __GNUG__
	{ Text *tmpp= ((StaticTextView*)text)->SetText(new StyledText(gSysFont, buf));
	  delete tmpp;
	}
#else
	delete ((StaticTextView*)text)->SetText(new StyledText(gSysFont, buf));
#endif
	// GetWindow()->contentRect.extent= gPoint0;
	CalcLayout(FALSE);
	ret= Dialog::Show();
    } else {
====================================================
Mark.C (near line 140)
=======================================================
	    else if (at < m->pos && at + n >= m->pos + m->len) {
		m->state = eStateDeleted;
		m->len = 0;
		m->pos = at;
		m->ChangedWhat((void*) eMarkDeleted);
		if (doRemove)
#ifdef __GNUG__
		    { ObjPtr tmpp= Remove(m); delete tmpp; }
#else
		    delete Remove(m);
#endif
	    }

	    // ^ | ^  |
	    else if (at < m->pos && at + n > m->pos) {
		m->len = m->pos+m->len - (at +n); 
===============================================================================
CodeTextView.C (two times)
=======================================================
	}
	prevCh= c;
    }
#ifdef __GNUG__
    TextRunArray *tmpp= stext->SetStyles(st); delete tmpp;
#else
    delete stext->SetStyles(st);
#endif
}

void CodeTextView::SetDefaultStyle()
{
    if (!text->IsKindOf(StyledText)) 
	return;
    StyledText *stext= (StyledText*)text;
    TextRunArray *st= new TextRunArray(stext);
    st->Insert(plainStyle, 0, 0, stext->Size());
#ifdef __GNUG__
    TextRunArray *tmpp= stext->SetStyles(st); delete tmpp;
#else
    delete stext->SetStyles(st);
#endif
}

=================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23				Phone: +31 34 63 562 11
3769 ZG  Soesterberg			E-mail: tnosoes!tom@mcvax.cwi.nl
The Netherlands				    or:	uunet!mcvax!tnosoes!tom
===============================================================================