=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/primitive.c,v retrieving revision 1.17 retrieving revision 1.23 diff -u -p -r1.17 -r1.23 --- OpenXM/src/kan96xx/Kan/primitive.c 2004/09/16 02:22:03 1.17 +++ OpenXM/src/kan96xx/Kan/primitive.c 2016/03/31 03:22:54 1.23 @@ -1,16 +1,20 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.16 2004/09/12 10:58:28 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.22 2013/11/06 06:44:48 takayama Exp $ */ /* primitive.c */ /* The functions in this module were in stackmachine.c */ #include +#include +#include #include #include "datatype.h" #include "stackm.h" #include "extern.h" +#include "extern2.h" #include "gradedset.h" #include "kclass.h" #include #include +#include "../plugin/mysig.h" int PrintDollar = 1; /* flag for printObject() */ int PrintComma = 1; /* flag for printObject() */ @@ -200,6 +204,9 @@ void printObject(ob,nl,fp) case Sdouble: fprintf(fp," "); break; + case SbyteArray: + fprintf(fp," "); + break; default: fprintf(fp,"",ob.tag); break; @@ -294,6 +301,9 @@ void printObject(ob,nl,fp) case Sdouble: fprintf(fp,"%f",KopDouble(ob)); break; + case SbyteArray: + printObject(byteArrayToArray(ob),nl,fp); /* Todo: I should save memory.*/ + break; default: fprintf(fp,"[Unknown object tag.]"); break; @@ -416,12 +426,12 @@ void KdefinePrimitiveFunctions() { int executePrimitive(ob) struct object ob; { - struct object ob1; - struct object ob2; - struct object ob3; - struct object ob4; - struct object ob5; - struct object rob; + struct object ob1 = OINIT; + struct object ob2 = OINIT; + struct object ob3 = OINIT; + struct object ob4 = OINIT; + struct object ob5 = OINIT; + struct object rob = OINIT; struct object obArray[OB_ARRAY_MAX]; struct object obArray2[OB_ARRAY_MAX]; int size; @@ -434,11 +444,11 @@ int executePrimitive(ob) FILE *fp; char *fname; int rank; - struct object oMat; + struct object oMat = OINIT; static int timerStart = 1; static struct tms before, after; static time_t before_real, after_real; - struct object oInput; + struct object oInput = OINIT; char *str; int ccflag = 0; extern int KeepInput; @@ -446,6 +456,7 @@ int executePrimitive(ob) extern struct ring *CurrentRingp; extern TimerOn; extern SecureMode; + extern int RestrictedMode; infixOn = 0; @@ -453,6 +464,18 @@ int executePrimitive(ob) fprintf(Fstack,"In execute %d\n",ob.lc.ival); printOperandStack(); } + if (RestrictedMode) { + switch(ob.lc.ival) { + case SleftBrace: + case SrightBrace: + case Sexec: + break; + default: + fprintf(stderr,"primitive No = %d : ", ob.lc.ival); + errorStackmachine("You cannot use this primitive in the RestrictedMode.\n"); + } + } + if (GotoP) return(0); switch (ob.lc.ival) { /* Postscript primitives :stack */ @@ -501,6 +524,11 @@ int executePrimitive(ob) } Kpush(ob3); break; + case SbyteArray: + n = getByteArraySize(ob2); + ob3 = newByteArray(n,ob2); + Kpush(ob3); + break; default: Kpush(ob2); break; @@ -643,6 +671,17 @@ int executePrimitive(ob) errorStackmachine("Index is out of bound. (put)\n"); } break; + case SbyteArray: + i = ob2.lc.ival; + size = getByteArraySize(ob3); + if ((0 <= i) && (i 0) { - signal(SIGALRM,ctrlC); alarm((unsigned int) n); + mysignal(SIGALRM,ctrlC); alarm((unsigned int) n); status = executeExecutableArray(ob1,(char *)NULL,0); cancelAlarm(); }else{