=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/plugin/cmo.c,v retrieving revision 1.9 retrieving revision 1.16 diff -u -p -r1.9 -r1.16 --- OpenXM/src/kan96xx/plugin/cmo.c 2001/09/01 01:37:49 1.9 +++ OpenXM/src/kan96xx/plugin/cmo.c 2020/10/04 03:14:07 1.16 @@ -1,4 +1,4 @@ -/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo.c,v 1.8 2001/05/04 01:06:29 takayama Exp $*/ +/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo.c,v 1.15 2016/08/28 02:43:14 takayama Exp $*/ #include #include /* #include */ @@ -47,7 +47,7 @@ extern struct ring *CurrentRingp; extern struct ring *SmallRingp; extern int CmoDMSOutputOption; -struct object NullObjectInCmo; +struct object NullObjectInCmo = OINIT; extern int SerialCurrent; extern int DebugCMO; @@ -162,7 +162,7 @@ dumpCmoBuf(struct cmoBuffer *cb) char *s; if (cb->isStream) { printf("cmoBuffer is directed to a stream.\n"); - return; + return 0; } size = cb->pos; s = (char *)(cb->buf); @@ -173,6 +173,7 @@ dumpCmoBuf(struct cmoBuffer *cb) printf("%3x",(int)(unsigned char)s[i]); } putchar('\n'); + return 0; } /* This obsolete function is used to write data @@ -213,7 +214,7 @@ struct object streamToCmo(struct object of) { int c; unsigned char s[1]; - struct object ob; + struct object ob = OINIT; int file2 = 0; if (of.tag == Sfile) { @@ -625,13 +626,14 @@ POLY cmoGetMonomial32(struct cmoBuffer *cb) /* ------------------------------------- */ void cmoObjectToCmo00(struct object ob) { - struct object rob; + struct object rob = OINIT; cmoint tmp[16]; char tmpc[16]; int i,size; - struct object vlist, vlist0; + struct object vlist = OINIT; + struct object vlist0 = OINIT; int m; - struct object ob2; + struct object ob2 = OINIT; /* NO initialization */ switch(ob.tag) { @@ -660,6 +662,12 @@ void cmoObjectToCmo00(struct object ob) case SuniversalNumber: cmoOutGMPCoeff(ob.lc.universalNumber->val.bigp); break; + case SrationalFunction: + tmp[0] = htonl(CMO_RATIONAL); + cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); + cmoObjectToCmo00(*(Knumerator(ob))); + cmoObjectToCmo00(*(Kdenominator(ob))); + break; case Sdouble: if (sizeof(double) != 8) errorCmo("double is assumed to be 8 bytes."); cmoOutRawInt(CMO_64BIT_MACHINE_DOUBLE); @@ -771,7 +779,7 @@ void cmoObjectToCmo00(struct object ob) struct object cmoObjectToCmo(struct object ob) { - struct object rob; + struct object rob = OINIT; if (DebugCMO) { fprintf(stderr,"cmoObjectToCmo: "); printObject(ob,1,stderr); @@ -799,19 +807,20 @@ int Lisplike = 0; struct object cmoCmoToObject00(struct cmoBuffer *cb) { - struct object rob; - struct object ob1; - struct object ob2; + struct object rob = OINIT; + struct object ob1 = OINIT; + struct object ob2 = OINIT; int tt,ival; int i,size; MP_INT *mi; MP_INT *mi2; struct ring *oldringp; char tmpc[16]; - struct object vlist, vlist0; + struct object vlist = OINIT; + struct object vlist0 = OINIT; int k; int m; - struct object ob; + struct object ob = OINIT; tt = cmoGetIntFromBuf(CMOGET,cb); /* read the tag */ @@ -1058,8 +1067,8 @@ struct object cmoCmoToObject00(struct cmoBuffer *cb) struct object cmoCmoToObject(struct object ob) { - struct object rob; - struct object ob0; + struct object rob = OINIT; + struct object ob0 = OINIT; struct cmoBuffer *cb; if (!(ob.tag == Sclass && ob.lc.ival == CMO)) { rob.tag = Snull; @@ -1083,8 +1092,8 @@ struct object cmoCmoToObject(struct object ob) } struct object cmoListToPoly(struct object ob) { - struct object ob0; - struct object rob; + struct object ob0 = OINIT; + struct object rob = OINIT; int i,n; if (ob.tag == Sarray) { n = getoaSize(ob); @@ -1110,7 +1119,8 @@ struct object cmoListToPoly(struct object ob) { struct object cmoListToPoly2(struct object ob) { int size,i; - struct object ob0,ob1; + struct object ob0 = OINIT; + struct object ob1 = OINIT; POLY f; /* printf("<<");printObject(ob,0,stdout); printf(">>\n"); fflush(stdout); @@ -1151,7 +1161,8 @@ main() { POLY cmoListToPOLY(struct object ob) { int size,i; - struct object ob0,ob1; + struct object ob0 = OINIT; + struct object ob1 = OINIT; POLY f; /* printf("<<");printObject(ob,0,stdout); printf(">>\n"); fflush(stdout); @@ -1190,7 +1201,7 @@ POLY cmoListToPOLY(struct object ob) int Kan_PushBinary(int size,void *data) { struct cmoBuffer cb; - struct object ob; + struct object ob = OINIT; cb.pos = size; cb.rpos = 0; cb.buf = data; @@ -1203,7 +1214,7 @@ int Kan_PushBinary(int size,void *data) void *Kan_PopBinary(int *sizep) { - struct object ob; + struct object ob = OINIT; struct cmoBuffer *cb; ob = KSpop(); ob = cmoObjectToCmo(ob); @@ -1222,7 +1233,7 @@ void *Kan_PopBinary(int *sizep) struct object cmoObjectFromStream(struct object obStream) { struct cmoBuffer cb; - struct object rob; + struct object rob = OINIT; extern DebugCMO; if (obStream.tag != Sfile) { errorCmo("cmoObjectFromStream: Argument must be of type file."); @@ -1240,7 +1251,7 @@ struct object cmoObjectFromStream(struct object obStre struct object cmoObjectFromStream2(FILE2 *fp2) { struct cmoBuffer cb; - struct object rob; + struct object rob = OINIT; cb.isStream=1; cb.fp = fp2; cmoGetIntFromBuf(CMOINITSTREAM,&cb); rob = cmoCmoToObject00(&cb); @@ -1255,7 +1266,7 @@ struct object cmoObjectFromStream2(FILE2 *fp2) struct object cmoObjectToStream(struct object ob, struct object obStream) { - struct object rob; + struct object rob = OINIT; extern int DebugCMO; if (obStream.tag != Sfile) { errorCmo("cmoObjectToStream: Argument must be of type file."); @@ -1272,7 +1283,7 @@ struct object cmoObjectToStream(struct object ob, stru struct object cmoObjectToStream2(struct object ob, FILE2 *fp2) { - struct object rob; + struct object rob = OINIT; cmoOutputToBuf(CMOINITSTREAM,(void *)fp2,0); if (DebugCMO) { fprintf(stderr,"cmoObjectToStream2: "); @@ -1286,8 +1297,8 @@ struct object cmoObjectToStream2(struct object ob, FIL int Kan_pushCMOFromStream(FILE2 *fp) { - struct object ob; - struct object rob; + struct object ob = OINIT; + struct object rob = OINIT; ob.tag = Sfile; ob.rc.voidp = (void *)fp; ob.lc.str = MAGIC2; rob = cmoObjectFromStream(ob); KSpush(rob); @@ -1296,8 +1307,8 @@ int Kan_pushCMOFromStream(FILE2 *fp) int Kan_popCMOToStream(FILE2 *fp,int serial) { - struct object ob; - struct object sob; + struct object ob = OINIT; + struct object sob = OINIT; sob.tag = Sfile; sob.rc.file = (void *)fp; sob.lc.str = MAGIC2; ob = Kpop(); /*outfp2(fp);*/ /* outfp2 is for debugging. see develop/97feb.. 1999, 1/19*/ @@ -1320,16 +1331,16 @@ int Kan_setMathCapToStream(FILE2 *fp,struct object ob) /* It is declared in oxmisc2.h, too. */ struct object newMathCap(struct mathCap *mathcap){ - struct object rob; - struct object ob1; - struct object ob2; - struct object ob3; - struct object obOx; - struct object obSm; - struct object ob3tmp; + struct object rob = OINIT; + struct object ob1 = OINIT; + struct object ob2 = OINIT; + struct object ob3 = OINIT; + struct object obOx = OINIT; + struct object obSm = OINIT; + struct object ob3tmp = OINIT; struct object *obp; int i,j; - struct object mathinfo; + struct object mathinfo = OINIT; rob = newObjectArray(3); @@ -1373,7 +1384,7 @@ void *KSmathCapByStruct(void) /* Return the math cap of kan/sm1 with cmo.c as a mathcap classObject*/ { struct mathCap *mathcap; - struct object ob; + struct object ob = OINIT; char *s1,*s2; struct object *mathinfo; char *sys; @@ -1430,8 +1441,9 @@ void *KSmathCapByStruct(void) mathcap->cmo[19]= CMO_64BIT_MACHINE_DOUBLE; mathcap->cmo[20]= CMO_ARRAY; mathcap->cmo[21]= CMO_RATIONAL; + mathcap->cmo[22]= CMO_QQ; - mathcap->n = 22 ; /* This is the number of cmo object. You can use + mathcap->n = 23 ; /* This is the number of cmo object. You can use cmo upto 1023. see mathcap.h */ mathcap->ox[0] = OX_DATA; @@ -1450,7 +1462,9 @@ void *KSmathCapByStruct(void) mathcap->sm[9] = SM_getsp; mathcap->sm[10] = SM_dupErrors; mathcap->sm[11] = SM_pushCMOtag; - mathcap->smSize = 12; + mathcap->sm[12] = SM_executeFunctionWithOptionalArgument; + mathcap->sm[13] = SM_nop; + mathcap->smSize = 14; return((void *)mathcap); } @@ -1462,11 +1476,11 @@ int cmoOutRawInt(int k) cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); } -warningCmo(char *s) { +void warningCmo(char *s) { fprintf(stderr,"Warning: plugin/cmo.c : %s\n",s); } -errorCmo(char *s) { +void errorCmo(char *s) { fprintf(stderr,"plugin/cmo.c : %s\n",s); errorKan1("%s\n","cmo fatal error. ox servers need SM_control_reset_connection."); /* ErrorPacket is automatically push on the ErrorStack.