Annotation of OpenXM_contrib2/asir2000/engine/ndbug.c, Revision 1.1
1.1 ! noro 1: #include "nd.h"
! 2:
! 3: ND nd_add_q(ND p1,ND p2)
! 4: {
! 5: int n,c,can;
! 6: ND r;
! 7: NM m1,m2,mr0,mr,s;
! 8: Q t;
! 9:
! 10: if ( !p1 ) return p2;
! 11: else if ( !p2 ) return p1;
! 12: else {
! 13: can = 0;
! 14: for ( n = NV(p1), m1 = BDY(p1), m2 = BDY(p2), mr0 = 0; m1 && m2; ) {
! 15: c = DL_COMPARE(DL(m1),DL(m2));
! 16: switch ( c ) {
! 17: case 0:
! 18: addq(CQ(m1),CQ(m2),&t);
! 19: s = m1; m1 = NEXT(m1);
! 20: if ( t ) {
! 21: can++; NEXTNM2(mr0,mr,s); CQ(mr) = (t);
! 22: } else {
! 23: can += 2; FREENM(s);
! 24: }
! 25: s = m2; m2 = NEXT(m2); FREENM(s);
! 26: break;
! 27: case 1:
! 28: s = m1; m1 = NEXT(m1); NEXTNM2(mr0,mr,s);
! 29: break;
! 30: case -1:
! 31: s = m2; m2 = NEXT(m2); NEXTNM2(mr0,mr,s);
! 32: break;
! 33: }
! 34: }
! 35: if ( !mr0 )
! 36: if ( m1 ) mr0 = m1;
! 37: else if ( m2 ) mr0 = m2;
! 38: else return 0;
! 39: else if ( m1 ) NEXT(mr) = m1;
! 40: else if ( m2 ) NEXT(mr) = m2;
! 41: else NEXT(mr) = 0;
! 42: BDY(p1) = mr0;
! 43: SG(p1) = MAX(SG(p1),SG(p2));
! 44: LEN(p1) = LEN(p1)+LEN(p2)-can;
! 45: FREEND(p2);
! 46: return p1;
! 47: }
! 48: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>