wrtfmt.c File Reference

#include "f2c.h"
#include "fio.h"
#include "fmt.h"

Include dependency graph for wrtfmt.c:

Go to the source code of this file.

Functions

static int mv_cur (Void)
static int wrt_Z (Uint *n, int w, int minlen, ftnlen len)
static int wrt_I (Uint *n, int w, ftnlen len, register int base)
static int wrt_IM (Uint *n, int w, int m, ftnlen len, int base)
static int wrt_AP (char *s)
static int wrt_H (int a, char *s)
int wrt_L (Uint *n, int len, ftnlen sz)
static int wrt_A (char *p, ftnlen len)
static int wrt_AW (char *p, int w, ftnlen len)
static int wrt_G (ufloat *p, int w, int d, int e, ftnlen len)
int w_ed (struct syl *p, char *ptr, ftnlen len)
int w_ned (struct syl *p)

Variables

icilistf__svic
char * f__icptr


Function Documentation

static int mv_cur ( Void   )  [static]

Definition at line 12 of file wrtfmt.c.

References cilist::cierr, err, f__cursor, f__elist, f__external, f__hiwater, f__putn, f__recpos, f__svic, and icilist::icirlen.

Referenced by w_ed(), wrt_AP(), and wrt_H().

00014 {
00015         int cursor = f__cursor;
00016         f__cursor = 0;
00017         if(f__external == 0) {
00018                 if(cursor < 0) {
00019                         if(f__hiwater < f__recpos)
00020                                 f__hiwater = f__recpos;
00021                         f__recpos += cursor;
00022                         f__icptr += cursor;
00023                         if(f__recpos < 0)
00024                                 err(f__elist->cierr, 110, "left off");
00025                 }
00026                 else if(cursor > 0) {
00027                         if(f__recpos + cursor >= f__svic->icirlen)
00028                                 err(f__elist->cierr, 110, "recend");
00029                         if(f__hiwater <= f__recpos)
00030                                 for(; cursor > 0; cursor--)
00031                                         (*f__putn)(' ');
00032                         else if(f__hiwater <= f__recpos + cursor) {
00033                                 cursor -= f__hiwater - f__recpos;
00034                                 f__icptr += f__hiwater - f__recpos;
00035                                 f__recpos = f__hiwater;
00036                                 for(; cursor > 0; cursor--)
00037                                         (*f__putn)(' ');
00038                         }
00039                         else {
00040                                 f__icptr += cursor;
00041                                 f__recpos += cursor;
00042                         }
00043                 }
00044                 return(0);
00045         }
00046         if (cursor > 0) {
00047                 if(f__hiwater <= f__recpos)
00048                         for(;cursor>0;cursor--) (*f__putn)(' ');
00049                 else if(f__hiwater <= f__recpos + cursor) {
00050                         cursor -= f__hiwater - f__recpos;
00051                         f__recpos = f__hiwater;
00052                         for(; cursor > 0; cursor--)
00053                                 (*f__putn)(' ');
00054                 }
00055                 else {
00056                         f__recpos += cursor;
00057                 }
00058         }
00059         else if (cursor < 0)
00060         {
00061                 if(cursor + f__recpos < 0)
00062                         err(f__elist->cierr,110,"left off");
00063                 if(f__hiwater < f__recpos)
00064                         f__hiwater = f__recpos;
00065                 f__recpos += cursor;
00066         }
00067         return(0);
00068 }

Here is the caller graph for this function:

int w_ed ( struct syl p,
char *  ptr,
ftnlen  len 
)

Definition at line 302 of file wrtfmt.c.

References A, AW, D, E, EE, F, f__cursor, f__fmtbuf, G, GE, I, i, IM, L, mv_cur(), O, OM, p, sig_die(), wrt_A(), wrt_AW(), wrt_E(), wrt_F(), wrt_G(), wrt_I(), wrt_IM(), wrt_L(), wrt_Z(), Z, and ZM.

00304 {
00305         int i;
00306 
00307         if(f__cursor && (i = mv_cur()))
00308                 return i;
00309         switch(p->op)
00310         {
00311         default:
00312                 fprintf(stderr,"w_ed, unexpected code: %d\n", p->op);
00313                 sig_die(f__fmtbuf, 1);
00314         case I: return(wrt_I((Uint *)ptr,p->p1,len, 10));
00315         case IM:
00316                 return(wrt_IM((Uint *)ptr,p->p1,p->p2.i[0],len,10));
00317 
00318                 /* O and OM don't work right for character, double, complex, */
00319                 /* or doublecomplex, and they differ from Fortran 90 in */
00320                 /* showing a minus sign for negative values. */
00321 
00322         case O: return(wrt_I((Uint *)ptr, p->p1, len, 8));
00323         case OM:
00324                 return(wrt_IM((Uint *)ptr,p->p1,p->p2.i[0],len,8));
00325         case L: return(wrt_L((Uint *)ptr,p->p1, len));
00326         case A: return(wrt_A(ptr,len));
00327         case AW:
00328                 return(wrt_AW(ptr,p->p1,len));
00329         case D:
00330         case E:
00331         case EE:
00332                 return(wrt_E((ufloat *)ptr,p->p1,p->p2.i[0],p->p2.i[1],len));
00333         case G:
00334         case GE:
00335                 return(wrt_G((ufloat *)ptr,p->p1,p->p2.i[0],p->p2.i[1],len));
00336         case F: return(wrt_F((ufloat *)ptr,p->p1,p->p2.i[0],len));
00337 
00338                 /* Z and ZM assume 8-bit bytes. */
00339 
00340         case Z: return(wrt_Z((Uint *)ptr,p->p1,0,len));
00341         case ZM:
00342                 return(wrt_Z((Uint *)ptr,p->p1,p->p2.i[0],len));
00343         }
00344 }

Here is the call graph for this function:

int w_ned ( struct syl p  ) 

Definition at line 350 of file wrtfmt.c.

References APOS, f__cursor, f__donewrec, f__fmtbuf, f__recpos, H, p, sig_die(), SLASH, T, TL, TR, wrt_AP(), wrt_H(), and X.

Referenced by s_wdfe(), s_wsfe(), and s_wsfi().

00352 {
00353         switch(p->op)
00354         {
00355         default: fprintf(stderr,"w_ned, unexpected code: %d\n", p->op);
00356                 sig_die(f__fmtbuf, 1);
00357         case SLASH:
00358                 return((*f__donewrec)());
00359         case T: f__cursor = p->p1-f__recpos - 1;
00360                 return(1);
00361         case TL: f__cursor -= p->p1;
00362                 if(f__cursor < -f__recpos)      /* TL1000, 1X */
00363                         f__cursor = -f__recpos;
00364                 return(1);
00365         case TR:
00366         case X:
00367                 f__cursor += p->p1;
00368                 return(1);
00369         case APOS:
00370                 return(wrt_AP(p->p2.s));
00371         case H:
00372                 return(wrt_H(p->p1,p->p2.s));
00373         }
00374 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int wrt_A ( char *  p,
ftnlen  len 
) [static]

Definition at line 245 of file wrtfmt.c.

Referenced by w_ed().

00247 {
00248         while(len-- > 0) (*f__putn)(*p++);
00249         return(0);
00250 }

Here is the caller graph for this function:

static int wrt_AP ( char *  s  )  [static]

Definition at line 194 of file wrtfmt.c.

References f__cursor, f__putn, i, mv_cur(), and quote.

Referenced by w_ned().

00196 {       char quote;
00197         int i;
00198 
00199         if(f__cursor && (i = mv_cur()))
00200                 return i;
00201         quote = *s++;
00202         for(;*s;s++)
00203         {       if(*s!=quote) (*f__putn)(*s);
00204                 else if(*++s==quote) (*f__putn)(*s);
00205                 else return(1);
00206         }
00207         return(1);
00208 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int wrt_AW ( char *  p,
int  w,
ftnlen  len 
) [static]

Definition at line 255 of file wrtfmt.c.

Referenced by w_ed().

00257 {
00258         while(w>len)
00259         {       w--;
00260                 (*f__putn)(' ');
00261         }
00262         while(w-- > 0)
00263                 (*f__putn)(*p++);
00264         return(0);
00265 }

Here is the caller graph for this function:

static int wrt_G ( ufloat p,
int  w,
int  d,
int  e,
ftnlen  len 
) [static]

Definition at line 271 of file wrtfmt.c.

References f__putn, f__scale, i, j, n, p, wrt_E(), wrt_F(), and x.

Referenced by w_ed().

00273 {       double up = 1,x;
00274         int i=0,oldscale,n,j;
00275         x = len==sizeof(real)?p->pf:p->pd;
00276         if(x < 0 ) x = -x;
00277         if(x<.1) {
00278                 if (x != 0.)
00279                         return(wrt_E(p,w,d,e,len));
00280                 i = 1;
00281                 goto have_i;
00282                 }
00283         for(;i<=d;i++,up*=10)
00284         {       if(x>=up) continue;
00285  have_i:
00286                 oldscale = f__scale;
00287                 f__scale = 0;
00288                 if(e==0) n=4;
00289                 else    n=e+2;
00290                 i=wrt_F(p,w-n,d-i,len);
00291                 for(j=0;j<n;j++) (*f__putn)(' ');
00292                 f__scale=oldscale;
00293                 return(i);
00294         }
00295         return(wrt_E(p,w,d,e,len));
00296 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int wrt_H ( int  a,
char *  s 
) [static]

Definition at line 213 of file wrtfmt.c.

References f__cursor, i, and mv_cur().

Referenced by w_ned().

00215 {
00216         int i;
00217 
00218         if(f__cursor && (i = mv_cur()))
00219                 return i;
00220         while(a--) (*f__putn)(*s++);
00221         return(1);
00222 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int wrt_I ( Uint n,
int  w,
ftnlen  len,
register int  base 
) [static]

Definition at line 129 of file wrtfmt.c.

References f__cplus, f__icvt(), f__putn, i, longint, n, ndigit, sign, and x.

Referenced by w_ed().

00131 {       int ndigit,sign,spare,i;
00132         longint x;
00133         char *ans;
00134         if(len==sizeof(integer)) x=n->il;
00135         else if(len == sizeof(char)) x = n->ic;
00136 #ifdef Allow_TYQUAD
00137         else if (len == sizeof(longint)) x = n->ili;
00138 #endif
00139         else x=n->is;
00140         ans=f__icvt(x,&ndigit,&sign, base);
00141         spare=w-ndigit;
00142         if(sign || f__cplus) spare--;
00143         if(spare<0)
00144                 for(i=0;i<w;i++) (*f__putn)('*');
00145         else
00146         {       for(i=0;i<spare;i++) (*f__putn)(' ');
00147                 if(sign) (*f__putn)('-');
00148                 else if(f__cplus) (*f__putn)('+');
00149                 for(i=0;i<ndigit;i++) (*f__putn)(*ans++);
00150         }
00151         return(0);
00152 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int wrt_IM ( Uint n,
int  w,
int  m,
ftnlen  len,
int  base 
) [static]

Definition at line 157 of file wrtfmt.c.

References f__cplus, f__icvt(), f__putn, i, longint, n, ndigit, sign, and x.

Referenced by w_ed().

00159 {       int ndigit,sign,spare,i,xsign;
00160         longint x;
00161         char *ans;
00162         if(sizeof(integer)==len) x=n->il;
00163         else if(len == sizeof(char)) x = n->ic;
00164 #ifdef Allow_TYQUAD
00165         else if (len == sizeof(longint)) x = n->ili;
00166 #endif
00167         else x=n->is;
00168         ans=f__icvt(x,&ndigit,&sign, base);
00169         if(sign || f__cplus) xsign=1;
00170         else xsign=0;
00171         if(ndigit+xsign>w || m+xsign>w)
00172         {       for(i=0;i<w;i++) (*f__putn)('*');
00173                 return(0);
00174         }
00175         if(x==0 && m==0)
00176         {       for(i=0;i<w;i++) (*f__putn)(' ');
00177                 return(0);
00178         }
00179         if(ndigit>=m)
00180                 spare=w-ndigit-xsign;
00181         else
00182                 spare=w-m-xsign;
00183         for(i=0;i<spare;i++) (*f__putn)(' ');
00184         if(sign) (*f__putn)('-');
00185         else if(f__cplus) (*f__putn)('+');
00186         for(i=0;i<m-ndigit;i++) (*f__putn)('0');
00187         for(i=0;i<ndigit;i++) (*f__putn)(*ans++);
00188         return(0);
00189 }

Here is the call graph for this function:

Here is the caller graph for this function:

int wrt_L ( Uint n,
int  len,
ftnlen  sz 
)

Definition at line 228 of file wrtfmt.c.

References f__putn, i, n, and x.

Referenced by lwrt_L(), and w_ed().

00230 {       int i;
00231         long x;
00232         if(sizeof(long)==sz) x=n->il;
00233         else if(sz == sizeof(char)) x = n->ic;
00234         else x=n->is;
00235         for(i=0;i<len-1;i++)
00236                 (*f__putn)(' ');
00237         if(x) (*f__putn)('T');
00238         else (*f__putn)('F');
00239         return(0);
00240 }

Here is the caller graph for this function:

static int wrt_Z ( Uint n,
int  w,
int  minlen,
ftnlen  len 
) [static]

Definition at line 74 of file wrtfmt.c.

References f__putn, i, n, and s.

Referenced by w_ed().

00076 {
00077         register char *s, *se;
00078         register int i, w1;
00079         static int one = 1;
00080         static char hex[] = "0123456789ABCDEF";
00081         s = (char *)n;
00082         --len;
00083         if (*(char *)&one) {
00084                 /* little endian */
00085                 se = s;
00086                 s += len;
00087                 i = -1;
00088                 }
00089         else {
00090                 se = s + len;
00091                 i = 1;
00092                 }
00093         for(;; s += i)
00094                 if (s == se || *s)
00095                         break;
00096         w1 = (i*(se-s) << 1) + 1;
00097         if (*s & 0xf0)
00098                 w1++;
00099         if (w1 > w)
00100                 for(i = 0; i < w; i++)
00101                         (*f__putn)('*');
00102         else {
00103                 if ((minlen -= w1) > 0)
00104                         w1 += minlen;
00105                 while(--w >= w1)
00106                         (*f__putn)(' ');
00107                 while(--minlen >= 0)
00108                         (*f__putn)('0');
00109                 if (!(*s & 0xf0)) {
00110                         (*f__putn)(hex[*s & 0xf]);
00111                         if (s == se)
00112                                 return 0;
00113                         s += i;
00114                         }
00115                 for(;; s += i) {
00116                         (*f__putn)(hex[*s >> 4 & 0xf]);
00117                         (*f__putn)(hex[*s & 0xf]);
00118                         if (s == se)
00119                                 break;
00120                         }
00121                 }
00122         return 0;
00123         }

Here is the caller graph for this function:


Variable Documentation

char* f__icptr

Definition at line 47 of file err.c.

Referenced by rd_ed().

icilist* f__svic

Definition at line 24 of file err.c.

Referenced by c_lir(), c_liw(), c_si(), e_wsfi(), i_getc(), i_ungetc(), mv_cur(), z_getc(), z_putc(), z_rnew(), and z_wnew().


Generated on Sun Mar 4 15:05:54 2007 for Scilab [trunk] by  doxygen 1.5.1