X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/0f4556f12c8f75078501c9d1338ae7648a97f975..95f51977ddc18faa2e212f30c00a39540b39f325:/usr/src/usr.lib/libI77/wrtfmt.c diff --git a/usr/src/usr.lib/libI77/wrtfmt.c b/usr/src/usr.lib/libI77/wrtfmt.c index 4dbaa5d9ba..9607e62065 100644 --- a/usr/src/usr.lib/libI77/wrtfmt.c +++ b/usr/src/usr.lib/libI77/wrtfmt.c @@ -1,6 +1,12 @@ /* -char id_wrtfmt[] = "@(#)wrtfmt.c 1.7"; + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. * + * @(#)wrtfmt.c 5.1 6/7/85 + */ + +/* * formatted write routines */ @@ -8,6 +14,7 @@ char id_wrtfmt[] = "@(#)wrtfmt.c 1.7"; #include "format.h" extern char *icvt(); +extern char *s_init; #define abs(x) (x<0?-x:x) @@ -20,20 +27,23 @@ w_ed(p,ptr,len) char *ptr; struct syl *p; ftnlen len; case IM: return(wrt_IM(ptr,p->p1,p->p2,len)); case L: - return(wrt_L(ptr,p->p1)); + return(wrt_L(ptr,p->p1,len)); case A: - p->p1 = len; /* cheap trick */ + return(wrt_AW(ptr,len,len)); case AW: return(wrt_AW(ptr,p->p1,len)); case D: + return(wrt_E(ptr,p->p1,p->p2,2,len,'d')); case DE: - return(wrt_E(ptr,p->p1,p->p2,p->p3,len,'d')); + return(wrt_E(ptr,p->p1,(p->p2)&0xff,((p->p2)>>8)&0xff,len,'d')); case E: + return(wrt_E(ptr,p->p1,p->p2,2,len,'e')); case EE: - return(wrt_E(ptr,p->p1,p->p2,p->p3,len,'e')); + return(wrt_E(ptr,p->p1,(p->p2)&0xff,((p->p2)>>8)&0xff,len,'e')); case G: + return(wrt_G(ptr,p->p1,p->p2,2,len)); case GE: - return(wrt_G(ptr,p->p1,p->p2,p->p3,len)); + return(wrt_G(ptr,p->p1,(p->p2)&0xff,((p->p2)>>8)&0xff,len)); case F: return(wrt_F(ptr,p->p1,p->p2,len)); default: @@ -66,14 +76,15 @@ w_ned(p,ptr) char *ptr; struct syl *p; tab = YES; return(OK); case APOS: - return(wrt_AP(p->p1)); + return(wrt_AP(&s_init[p->p1])); case H: - return(wrt_H(p->p1,p->p2)); + return(wrt_H(p->p1,&s_init[p->p2])); default: return(errno=F_ERFMT); } } +LOCAL wr_mvcur() { int n; if(tab) return((*dotab)()); @@ -82,6 +93,7 @@ wr_mvcur() return(cursor=0); } +LOCAL wrt_IM(ui,w,m,len) uint *ui; ftnlen len; { int ndigit,sign,spare,i,xsign,n; long x; @@ -112,6 +124,7 @@ wrt_IM(ui,w,m,len) uint *ui; ftnlen len; return(OK); } +LOCAL wrt_AP(p) { char *s,quote; int n; @@ -126,6 +139,7 @@ wrt_AP(p) return(OK); } +LOCAL wrt_H(a,b) { char *s=(char *)b; int n; @@ -134,14 +148,19 @@ wrt_H(a,b) return(OK); } -wrt_L(l,len) ftnint *l; +wrt_L(l,width,len) uint *l; ftnlen len; { int i,n; - for(i=0;iis; + else + i = l->il; + if(i) PUT('t') else PUT('f') return(OK); } +LOCAL wrt_AW(p,w,len) char * p; ftnlen len; { int n; while(w>len) @@ -160,7 +179,10 @@ wrt_E(p,w,d,e,len,expch) ufloat *p; ftnlen len; char expch; if((len==sizeof(float)?p->pf:p->pd)==0.0) { + n = cblank; + cblank = 1; /* force '0' fill */ wrt_F(p,w-(e+2),d,len); + cblank = n; PUT(expch) PUT('+') /* for(i=0;i<(e-1);i++)PUT(' ') @@ -222,6 +244,7 @@ E_badfield: return(OK); } +LOCAL wrt_G(p,w,d,e,len) ufloat *p; ftnlen len; { double uplim = 1.0, x; int i,oldscale,n,j,ne;