*/
void
-gset(void *p1, void *val, int n, int typ)
-{ if (val==0)
+gset(void *p1, void *val, int n, int typ) {
+
+ if (val==0)
val = aet_types[typ].dflt;
- switch (typ){
+
+ switch (typ){
#define GSET(p,n,typ,val) {typ x = *((typ *) val); GSET1(p,n,typ,x)}
-#define GSET1(p,n,typ,val) while (n-- > 0) \
+#define GSET1(p,n,typ,val) while (n-- > 0) \
{ *((typ *) p) = val; \
- p = p + sizeof(typ); \
- } break;
-
- case aet_object: GSET(p1,n,object,val);
- case aet_ch: GSET(p1,n,char,val);
- /* Note n is number of fixnum WORDS for bit */
- case aet_bit: GSET(p1,n,fixnum,val);
- case aet_fix: GSET(p1,n,fixnum,val);
- case aet_sf: GSET(p1,n,shortfloat,val);
- case aet_lf: GSET(p1,n,longfloat,val);
- case aet_char: GSET(p1,n,char,val);
- case aet_uchar: GSET(p1,n,unsigned char,val);
- case aet_short: GSET(p1,n,short,val);
- case aet_ushort: GSET(p1,n,unsigned short,val);
- default: FEerror("bad elttype",0);
- }
+ p = p + sizeof(typ); \
+ } break;
+
+ case aet_object: GSET(p1,n,object,val);
+ case aet_ch: GSET(p1,n,char,val);
+ /* Note n is number of fixnum WORDS for bit */
+ case aet_bit: GSET(p1,n,fixnum,val);
+ case aet_fix: GSET(p1,n,fixnum,val);
+ case aet_sf: GSET(p1,n,shortfloat,val);
+ case aet_lf: GSET(p1,n,longfloat,val);
+ case aet_char: GSET(p1,n,char,val);
+ case aet_uchar: GSET(p1,n,unsigned char,val);
+ case aet_short: GSET(p1,n,short,val);
+ case aet_ushort: GSET(p1,n,unsigned short,val);
+ default: FEerror("bad elttype",0);
}
+}
#define W_SIZE (BV_BITS*sizeof(fixnum))
int n1=fix(n1o),nc;
if (VFUN_NARGS==4)
{ n1 = x->v.v_dim - i1;}
- if (typ1==aet_bit)
- {if (i1 % CHAR_SIZE)
- badcopy:
- FEerror("Bit copies only if aligned",0);
- else
- {int rest=n1%CHAR_SIZE;
- if (rest!=0 )
- {if (typ2!=aet_bit)
- goto badcopy;
- {while(rest> 0)
- { fSaset1(y,i2+n1-rest,(fLrow_major_aref(x,i1+n1-rest)));
- rest--;}
- }}
- i1=i1/CHAR_SIZE ;
- n1=n1/CHAR_SIZE;
- typ1=aet_char;
- }};
- if (typ2==aet_bit)
- {if (i2 % CHAR_SIZE)
- goto badcopy;
- i2=i2/CHAR_SIZE ;}
- if ((typ1 ==aet_object ||
- typ2 ==aet_object) && typ1 != typ2)
+ if (typ1==aet_bit) {
+ if (i1 % CHAR_SIZE)
+ badcopy:
+ FEerror("Bit copies only if aligned",0);
+ else {
+ int rest=n1%CHAR_SIZE;
+ if (rest!=0) {
+ if (typ2!=aet_bit)
+ goto badcopy;
+ while(rest> 0) {
+ fSaset1(y,i2+n1-rest,(fLrow_major_aref(x,i1+n1-rest)));
+ rest--;
+ }
+ }
+ i1=i1/CHAR_SIZE ;
+ n1=n1/CHAR_SIZE;
+ typ1=aet_char;
+ }
+ }
+
+ if (typ2==aet_bit) {
+ if (i2 % CHAR_SIZE)
+ goto badcopy;
+ i2=i2/CHAR_SIZE ;
+ }
+
+ if ((typ1 ==aet_object || typ2 ==aet_object) && typ1 != typ2)
FEerror("Can't copy between different array types",0);
nc=n1 * aet_sizes[(int)typ1];
- if (i1+n1 > x->a.a_dim
- || ((y->a.a_dim - i2) *aet_sizes[(int)typ2]) < nc)
+ if (i1+n1 > x->a.a_dim || ((y->a.a_dim - i2) *aet_sizes[(int)typ2]) < nc)
FEerror("Copy out of bounds",0);
bcopy(x->ust.ust_self + (i1*aet_sizes[(int)typ1]),
y->ust.ust_self + (i2*aet_sizes[(int)typ2]),
nc);
+
return x;
+
}
/* X is the header of an array. This supplies the body which
vsystem(const char *command) {
unsigned j,n=strlen(command)+1;
- char *z=alloca(n),**p1,**pp,*c;
+ char *z,*c;
+ const char *x1[]={"/bin/sh","-c",NULL,NULL},*spc=" \n\t",**p1,**pp;
int s;
pid_t pid;
- memcpy(z,command,n);
- for (j=1,c=z;strtok(c," \n\t");c=NULL,j++);
+ if (strpbrk(command,"\"'$<>"))
- memcpy(z,command,n);
- p1=alloca(j*sizeof(*p1));
- for (pp=p1,c=z;(*pp=strtok(c," \n\t"));c=NULL,pp++);
+ (p1=x1)[2]=command;
+
+ else {
+
+ z=alloca(n);
+ memcpy(z,command,n);
+ for (j=1,c=z;strtok(c,spc);c=NULL,j++);
+
+ memcpy(z,command,n);
+ p1=alloca(j*sizeof(*p1));
+ for (pp=p1,c=z;(*pp=strtok(c,spc));c=NULL,pp++);
+
+ }
if (!(pid=vfork())) {
- execvp(*p1,p1);
- _exit(2);
+ errno=0;
+ execvp(*p1,(void *)p1);
+ _exit(128|(errno&0x7f));
}
massert(pid>0);
massert(pid==waitpid(pid,&s,0));
+ if ((s>>8)&128)
+ emsg("execvp failure when executing '%s': %s\n",command,strerror((s>>8)&0x7f));
+
return s;
}