6 static char *
rcsid=
"@(#)$Id$";
11 #define g_marked(p) (bpointerof(p)->h.mark) 12 #define s_marked(p) (bpointerof(p)->h.smark) 13 #define p_marked(p) (bpointerof(p)->h.pmark) 14 #define g_mark_on(p) (bpointerof(p)->h.mark=1) 15 #define s_mark_on(p) (bpointerof(p)->h.smark=1) 16 #define p_mark_on(p) (bpointerof(p)->h.pmark=1) 17 #define g_mark_off(p) (bpointerof(p)->h.mark=0) 18 #define s_mark_off(p) (bpointerof(p)->h.smark=0) 19 #define p_mark_off(p) (bpointerof(p)->h.pmark=0) 20 #define to_upper(c) (islower(c) ? ((c)-'a'+'A') : (c)) 21 #define to_lower(c) (isupper(c) ? ((c)-'A'+'a') : (c)) 41 pkgname=ccar(pkg->c.pkg.names);
45 while (l-->0) { c= *s++;
writech(f,to_lower(c));}
46 else while (l-->0) {
writech(f,*s++);}
54 register pointer pkg,pkgname,pkgs,pnam;
63 if (pkg==curpkg)
return;
72 ccar(pkgs)->c.pkg.symvector, &hash))
75 else pkgs=ccdr(pkgs); }
76 else if (sym==cursym)
return;
87 {
register unsigned char *
s;
89 register int i,
l,c,down,escape=0,alldigits=1;
90 int base=
intval(Spevalof(PRINTBASE));
96 printf(
"printsym: illegal pname %p\n",pnm);
101 if (!ctx->slashflag) {
102 for (i=0; i<
l; i++) {
106 else if (Spevalof(QREADTABLE)->c.rdtab.macro->c.vec.v[c] !=
NIL)
108 if (!
is_digit(c,base)) alldigits=0;}
109 if ((escape=(escape | alldigits)))
writech(f,
'|');}
112 if (!ctx->slashflag) {
113 while (i<l && i<256) {
116 b[i++]=((!escape && down)?to_lower(c):c);
121 while (i<l && i<256) { c= *s++; b[i++]=to_lower(c);}
134 {
if (!ctx->slashflag) {
137 if (*str==
'"' || *str==
'\\')
writech(f,
'\\');
154 int base, field1, field2;
156 register int i=65,digit,sign,j;
160 if (num<0) { sign= -1; num= -num;}
else sign=0;
162 #if (WORD_SIZE == 64) 163 digit= (
unsigned long)num % base;
164 num=(
unsigned long)num / base;
166 digit= (unsigned)num % base;
167 num=(unsigned)num / base;
169 if (base<=10 || digit<10) work[--i]=
'0'+digit;
170 else if (downcase) work[--i]=
'a'+digit-10;
171 else work[--i]=
'A'+digit-10;}
174 if (field2> 65-i+1) j=field1-field2;
else j=field1-(65-i+1);}
176 if (field2> 65-i) j=field1-field2;
else j=field1-(65-i);}
189 double absnum,fraction;
190 register int i,len,intpart;
191 extern double fabs();
196 if ((absnum<0.0001) || (absnum>1.0e+05)) {
197 sprintf(work,
"%1.6e",num); len=strlen(work);}
200 fraction=absnum-intpart;
202 else if (intpart<10) i=5;
203 else if (intpart<100) i=4;
204 else if (intpart<1000) i=3;
205 else if (intpart<10000) i=2;
207 sprintf(work,
"%1.*f",i,num);
209 while (len>2 && work[len-1]==
'0' && work[len-2]!=
'.') len--;}
216 sprintf(work,
"#x%x",val);
230 static void printbig(ctx, big, f, base, field1,field2)
233 int base, field1,field2;
255 if (field2<digits) i=field1-digits;
else i=field1-field2;
257 while (i-- > 0)
writech(f,
' ');
261 while (i-- > 0)
writech(f,
'0');
263 while (digits-- > 0) {
267 if (downcase) x=x+
'a'-10;
274 void printnum(ctx, nump, strm, base, field1, field2)
281 if (isint(nump))
printint(ctx,
intval(nump), strm, base, field1, field2);
283 else if (pisbignum(nump))
printbig(ctx,nump, strm, base, field1, field2);
284 else if (pisratio(nump))
printratio(ctx, nump, strm, base);
306 nm=ccar(p->c.pkg.names);
315 if (isnum(p) || (pissymbol(p) && p->c.sym.homepkg !=
NIL) )
return;
318 if (pissymbol(p))
return;
320 if (elmtypeof(p)<ELM_POINTER)
return;
322 for (i=0; i<
s; i++)
printmark(ctx,p->c.vec.v[i]); }
325 for (i=0; i<
s; i++)
printmark(ctx,p->c.obj.iv[i]);}
327 else if (s_marked(p))
return;
330 ckpush(p->c.obj.iv[0]);
331 pointer_update(p->c.obj.iv[0],
makeint(++
ix));
337 x=Spevalof(PRLENGTH);
338 if (isint(x))
return(
intval(x));
348 eltype=elmtypeof(vec);
355 writech(f,(vec->c.ivec.iv[i/WORD_SIZE] & x)?
'1':
'0');
358 if (i % WORD_SIZE==0) x=1;}
366 printstr(ctx,n,vec->c.str.chars,f);
break;
369 while (i<n && prlength>0) {
379 while (i<n && prlength>0) {
388 printstr(ctx,vecsize(vec),vec->c.ivec.iv[0],f);
394 printsym(ctx,classof(vec)->c.cls.name,f);
398 while (i<n && prlength>0) {
399 prin1(ctx,vec->c.vec.v[i++],f,prlevel);
409 {
switch(elmtypeof(vec)) {
412 #if (WORD_SIZE == 64) 413 bitmask=1L << (index % 64);
414 writech(f,(vec->c.ivec.iv[index/64] & bitmask)?
'1':
'0');
416 bitmask=1 << (index % 32);
417 writech(f,(vec->c.str.chars[index/32] & bitmask)?
'1':
'0');
421 case ELM_BYTE:
case ELM_CHAR:
422 printint(ctx,vec->c.str.chars[index],f,
intval(Spevalof(PRINTBASE)),
430 printflt(vec->c.fvec.fv[index],f);
break;
432 prin1(ctx,vec->c.vec.v[index],f,prlevel);
440 {
register int i,
n,next;
441 n=
intval(a->c.ary.dim[axis]);
444 for (i=0; i<
n; i++) {
445 next=
prinary(ctx,f,prlevel,a,rank,axis+1,index);
450 if (rank==1 && isint(a->c.ary.fillpointer)) n=
intval(a->c.ary.fillpointer);
451 for (i=0; i<
n; i++) {
452 prinelm(ctx,f,prlevel-1,a->c.ary.entity,index+i);
460 register
int prlevel;
462 register int i,j,
rank,etype,size=1,
index;
464 rank=
intval(a->c.ary.rank);
465 etype=elmtypeof(a->c.ary.entity);
466 sprintf(buf,
"#%d%c",rank,(etype==ELM_FLOAT)?
'f':
467 (etype==ELM_INT)?
'i':
'a');
477 register
int prlevel;
478 {
register pointer rest=ccdr(x);
481 if (fobj==
QUOTE && islist(rest) && ccdr(rest)==
NIL) {
483 prin1(ctx,ccar(rest),f,prlevel-1);
485 else if (fobj==
FUNCTION && islist(rest) && ccdr(rest)==
NIL) {
487 prin1(ctx,ccar(rest),f,prlevel-1);
490 prin1(ctx,fobj,f,prlevel);
492 while (islist(x) && !s_marked(x)) {
498 prin1(ctx,ccar(x),f,prlevel);
517 while (i<s && prlength>0) {
521 if (i==0)
prin1(ctx,fobj,f,prlevel);
522 else prin1(ctx,x->c.obj.iv[i],f,prlevel);
540 while (i<s && prlength-->0) {
542 if (i==0)
prin1(ctx,fobj,f,prlevel);
543 else prin1(ctx,x->c.obj.iv[i],f,prlevel);
552 register
int prlevel;
554 register int shareix=0;
557 if (prlevel<=0) {
writech(f,
'#');
return;}
558 if (isnum(x)) {
printnum(ctx,x,f,
intval(Spevalof(PRINTBASE)),0,0);
return;}
559 else if (x==UNBOUND) {
writestr(f,(
byte *)
"***UNBOUND***",13);
return;}
561 #if vax || sun4 || news || mips || i386 || alpha || x86_64 || ARM 567 else if (pisbignum(x)) {
574 shareix=
intval(x->c.obj.iv[0]);
575 sprintf(
ixbuf,
"#%d=",shareix);
577 fobj=ixvec[shareix]; }
584 else if (pissymbol(x)) {
printsym(ctx,x,f);
return;}
585 else if (pisvector(x))
printvector(ctx,x,f,fobj,prlevel-1);
586 else if (Spevalof(PROBJECT)!=
NIL)
prinxobj(ctx,x,f,fobj,prlevel-1);
589 else csend(ctx,x,K_PRIN1,1,f);
595 if (isnum(p))
return;
596 if (!s_marked(p) && !p_marked(p))
return;
598 if (p_marked(p)) fprintf(stderr,
"smarked?\n");
599 else pointer_update(p->c.obj.iv[0],ixvec[
intval(p->c.obj.iv[0])]);
600 s_mark_off(p); p_mark_off(p);
601 if (pissymbol(p))
return;
602 else if (pisvector(p)) {
603 if (elmtypeof(p)<ELM_POINTER)
return;
618 prlevel=Spevalof(PRLEVEL);
619 if (isint(prlevel)) iprlevel=
intval(prlevel);
else iprlevel=65536;
620 if (Spevalof(PRCIRCLE)!=
NIL) {
621 ixvec=ctx->vsp;
ix=0; vpush(0);
627 prin1(ctx,obj,stream,iprlevel);
633 else prin1(ctx,obj,stream,iprlevel);
context * euscontexts[MAXTHREAD]
static char buf[CHAR_SIZE]
eusinteger_t div_int_big(eusinteger_t c, pointer x)
eusinteger_t big_sign(pointer)
static void printpkg(pointer p, pointer f)
static void prinelm(context *ctx, pointer f, int prlevel, pointer vec, int index)
int rank(int n, int p, MATRIX s)
static void printmark(context *ctx, pointer p)
static void printhex(int val, pointer f)
static void printratio(context *ctx, pointer rat, pointer f, int base)
static void printarray(context *ctx, pointer a, pointer f, int prlevel)
pointer csend(context *,...)
static void prinxobj(context *ctx, pointer x, pointer f, pointer fobj, int prlevel)
static pointer printsym(context *ctx, pointer sym, pointer f)
static void printstr(context *ctx, int leng, byte *str, pointer f)
enum ch_attr charattr[256]
int writestr(pointer, byte *, int)
static void symprefix(pointer sym, pointer f)
static int getprlength(context *ctx)
eusinteger_t big_zerop(pointer x)
static void printstructure(context *ctx, pointer x, pointer f, pointer fobj, int prlevel)
static pointer printvector(context *ctx, pointer vec, pointer f, pointer leng, int prlevel)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
static void printobj(context *ctx, pointer obj, pointer f)
void printnum(context *ctx, pointer nump, pointer strm, int base, int field1, int field2)
static void prin1(context *, pointer, pointer, int)
static void printlist(context *ctx, pointer x, pointer f, pointer fobj, int prlevel)
void printint(context *ctx, eusinteger_t num, pointer f, int base, int field1, int field2)
static pointer printflt(double num, pointer f)
static void printunmark(pointer p)
pointer prinx(context *ctx, pointer obj, pointer stream)
int writech(pointer, int)
static void print_symbol_prefix(context *ctx, pointer f, pointer pkg, char *colon)
enum ch_type chartype[256]
struct class_desc classtab[MAXCLASS]
static int prinary(context *ctx, pointer f, int prlevel, pointer a, int rank, int axis, int index)
static void printbig(context *ctx, pointer big, pointer f, int base, int field1, int field2)