=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/cpexpr.c,v retrieving revision 1.11 retrieving revision 1.15 diff -u -p -r1.11 -r1.15 --- OpenXM_contrib2/asir2000/io/cpexpr.c 2001/04/20 02:34:23 1.11 +++ OpenXM_contrib2/asir2000/io/cpexpr.c 2003/02/14 22:29:15 1.15 @@ -44,7 +44,7 @@ * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. - * $OpenXM: OpenXM_contrib2/asir2000/io/cpexpr.c,v 1.10 2001/03/15 05:52:12 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/cpexpr.c,v 1.14 2002/09/02 05:16:07 noro Exp $ */ #include "ca.h" #include "parse.h" @@ -85,6 +85,8 @@ extern int hex_output,fortran_output,double_output,rea #define PRINTEOP length_eop #define PRINTQOP length_qop #define PRINTUP length_up +#define PRINTUM length_um +#define PRINTSF length_sf void PRINTEXPR(); void PRINTNUM(); @@ -107,22 +109,26 @@ void PRINTERR(); void PRINTCPLX(); void PRINTLM(); void PRINTLF(); +void PRINTUP(); +void PRINTUM(); void PRINTUP2(); +void PRINTFOP(); +void PRINTEOP(); +void PRINTLOP(); +void PRINTQOP(); +void PRINTSF(); static int total_length; -int estimate_length(vl,p) -VL vl; -pointer p; +int estimate_length(VL vl,pointer p) { total_length = 0; PRINTEXPR(vl,p); return total_length; } -#if PARI -void PRINTBF(a) -BF a; +#if defined(PARI) +void PRINTBF(BF a) { char *str; char *GENtostr(); @@ -139,9 +145,7 @@ BF a; } #endif -void PRINTEXPR(vl,p) -VL vl; -pointer p; +void PRINTEXPR(VL vl,pointer p) { if ( !p ) { total_length++; @@ -188,8 +192,7 @@ pointer p; } } -void PRINTN(n) -N n; +void PRINTN(N n) { double ceil(); @@ -201,8 +204,7 @@ N n; total_length += (int)(ceil(0.31*((double)(BSH*PL(n))))+1); } -void PRINTNUM(q) -Num q; +void PRINTNUM(Num q) { if ( !q ) { PUTS("0"); @@ -226,7 +228,7 @@ Num q; case N_A: PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")"); break; -#if PARI +#if defined(PARI) case N_B: PRINTBF((BF)q); break; #endif @@ -249,13 +251,15 @@ Num q; case N_GFS: total_length += 13; /* XXX */ break; + case N_GFSN: + PRINTUM(BDY((GFSN)q)); + break; default: break; } } -void PRINTCPLX(a) -C a; +void PRINTCPLX(C a) { PUTS("("); if ( a->r ) @@ -268,13 +272,10 @@ C a; PUTS(")"); } -void PRINTP(vl,p) -VL vl; -P p; +void PRINTP(VL vl,P p) { V v; DCP dc; - int t; if ( !p ) PUTS("0"); @@ -326,9 +327,7 @@ P p; extern int hideargs; -void PRINTV(vl,v) -VL vl; -V v; +void PRINTV(VL vl,V v) { PF pf; PFAD ad; @@ -339,8 +338,8 @@ V v; else if ( (vid)v->attr == V_PF ) { pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad; if ( !strcmp(NAME(pf),"pow") ) { - PUTS("("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("("); - PRINTR(vl,(R)ad[1].arg); PUTS(")"); + PUTS("(("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("("); + PRINTR(vl,(R)ad[1].arg); PUTS("))"); } else if ( !pf->argc ) PUTS(NAME(pf)); else { @@ -384,9 +383,7 @@ V v; } } -void PRINTR(vl,a) -VL vl; -R a; +void PRINTR(VL vl,R a) { if ( !a ) PUTS("0"); @@ -400,9 +397,7 @@ R a; } } -void PRINTVECT(vl,vect) -VL vl; -VECT vect; +void PRINTVECT(VL vl,VECT vect) { int i; pointer *ptr; @@ -414,9 +409,7 @@ VECT vect; PUTS("]"); } -void PRINTMAT(vl,mat) -VL vl; -MAT mat; +void PRINTMAT(VL vl,MAT mat) { int i,j,r,c; pointer *ptr; @@ -432,9 +425,7 @@ MAT mat; } } -void PRINTLIST(vl,list) -VL vl; -LIST list; +void PRINTLIST(VL vl,LIST list) { NODE tnode; @@ -447,8 +438,7 @@ LIST list; PUTS("]"); } -void PRINTSTR(str) -STRING str; +void PRINTSTR(STRING str) { char *p; @@ -460,9 +450,7 @@ STRING str; } } -void PRINTCOMP(vl,c) -VL vl; -COMP c; +void PRINTCOMP(VL vl,COMP c) { int n,i; @@ -476,9 +464,7 @@ COMP c; PUTS("}"); } -void PRINTDP(vl,d) -VL vl; -DP d; +void PRINTDP(VL vl,DP d) { int n,i; MP m; @@ -496,16 +482,12 @@ DP d; } } -void PRINTUI(vl,u) -VL vl; -USINT u; +void PRINTUI(VL vl,USINT u) { total_length += 10; } -void PRINTGF2MAT(vl,mat) -VL vl; -GF2MAT mat; +void PRINTGF2MAT(VL vl,GF2MAT mat) { int row,col,w,i,j,k,m; unsigned int t; @@ -528,12 +510,9 @@ GF2MAT mat; } } -void PRINTGFMMAT(vl,mat) -VL vl; -GFMMAT mat; +void PRINTGFMMAT(VL vl,GFMMAT mat) { int row,col,i,j; - unsigned int t; unsigned int **b; row = mat->row; @@ -548,31 +527,24 @@ GFMMAT mat; } } -void PRINTBYTEARRAY(vl,array) -VL vl; -BYTEARRAY array; +void PRINTBYTEARRAY(VL vl,BYTEARRAY array) { /* |xx xx ... xx| */ total_length += 1+3*array->len; } -void PRINTQUOTE(vl,quote) -VL vl; -QUOTE quote; +void PRINTQUOTE(VL vl,QUOTE quote) { /* <...quoted...> */ total_length += 20; } -void PRINTERR(vl,e) -VL vl; -ERR e; +void PRINTERR(VL vl,ERR e) { PUTS("error("); PRINTEXPR(vl,e->body); PUTS(")"); } -void PRINTUP2(p) -UP2 p; +void PRINTUP2(UP2 p) { int d,i; @@ -604,9 +576,7 @@ UP2 p; } } -void PRINTLF(vl,f) -VL vl; -F f; +void PRINTLF(VL vl,F f) { switch ( FOP(f) ) { case AL_TRUE: @@ -632,9 +602,7 @@ F f; } } -PRINTFOP(vl,f) -VL vl; -F f; +void PRINTFOP(VL vl,F f) { char *op; NODE n; @@ -647,9 +615,7 @@ F f; } } -PRINTEOP(vl,f) -VL vl; -F f; +void PRINTEOP(VL vl,F f) { oFOP op; char *sop; @@ -674,9 +640,7 @@ F f; PUTS(")"); } -PRINTLOP(vl,f) -VL vl; -F f; +void PRINTLOP(VL vl,F f) { char *op; @@ -700,9 +664,7 @@ F f; PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0"); } -PRINTQOP(vl,f) -VL vl; -F f; +void PRINTQOP(VL vl,F f) { char *op; @@ -712,8 +674,7 @@ F f; PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")"); } -PRINTUP(n) -UP n; +void PRINTUP(UP n) { int i,d; @@ -746,4 +707,45 @@ UP n; } PUTS(")"); } +} + +void PRINTUM(UM n) +{ + int i,d; + + if ( !n ) + PUTS("0"); + else if ( !n->d ) + PRINTSF(n->c[0]); + else { + d = n->d; + PUTS("("); + if ( !d ) { + PRINTSF(n->c[d]); + } else if ( d == 1 ) { + PRINTSF(n->c[d]); + PUTS("*@s"); + } else { + PRINTSF(n->c[d]); + PUTS("*@s"); PRINTHAT; total_length += 13; + } + for ( i = d-1; i >= 0; i-- ) { + if ( n->c[i] ) { + PUTS("+("); PRINTSF(n->c[i]); PUTS(")"); + if ( i >= 2 ) { + PUTS("*@s"); PRINTHAT; total_length += 13; + } else if ( i == 1 ) + PUTS("*@s"); + } + } + PUTS(")"); + } +} + +void PRINTSF(unsigned int i) +{ + if ( !i ) { + PUTS("0"); + } else + total_length += 15; }