Doxygen Source Code Documentation
fmt.c File Reference
#include "f2c.h"#include "fio.h"#include "fmt.h"Go to the source code of this file.
| Defines | |
| #define | skip(s) while(*s==' ') s++ | 
| #define | SYLMX 300 | 
| #define | GLITCH '\2' | 
| #define | STKSZ 10 | 
| Functions | |
| char * | ap_end (char *s) | 
| op_gen (int a, int b, int c, int d) | |
| char * | f_list (char *) | 
| char * | gt_num (char *s, int *n) | 
| char * | f_s (char *s, int curloc) | 
| ne_d (char *s, char **p) | |
| e_d (char *s, char **p) | |
| char * | i_tem (char *s) | 
| pars_f (char *s) | |
| type_f (int n) | |
| integer | do_fio (ftnint *number, char *ptr, ftnlen len) | 
| en_fio (Void) | |
| VOID | fmt_bg (Void) | 
| Variables | |
| int | f__cursor | 
| int | f__scale | 
| flag | f__cblank | 
| flag | f__cplus | 
| syl | f__syl [SYLMX] | 
| int | f__parenlvl | 
| int | f__pc | 
| int | f__revloc | 
| int | f__cnt [STKSZ] | 
| int | f__ret [STKSZ] | 
| int | f__cp | 
| int | f__rp | 
| flag | f__workdone | 
| flag | f__nonl | 
Define Documentation
| 
 | 
| 
 Definition at line 17 of file fmt.c. Referenced by ne_d(). | 
| 
 | 
| 
 Definition at line 4 of file fmt.c. Referenced by e_d(), f_list(), f_s(), ge_header(), main(), memplot_to_postscript(), memplot_to_RGB_sef(), memplot_to_X11_sef(), mpeg2_skip(), mri_read(), mri_try_7D(), mri_try_mri(), mri_try_pgm(), nextdata(), processEvents(), qh_matchduplicates(), qh_matchneighbor(), qh_setequal_except(), read_ge_header(), read_ge_image(), and T3D_check_outliers(). | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
Function Documentation
| 
 | 
| 
 Definition at line 27 of file fmt.c. References f__fatal(). Referenced by ne_d(). 
 00029 {       char quote;
00030         quote= *s++;
00031         for(;*s;s++)
00032         {       if(*s!=quote) continue;
00033                 if(*++s!=quote) return(s);
00034         }
00035         if(f__elist->cierr) {
00036                 errno = 100;
00037                 return(NULL);
00038         }
00039         f__fatal(100, "bad string");
00040         /*NOTREACHED*/ return 0;
00041 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 387 of file fmt.c. References BN, BZ, COLON, err, errfl, f__cblank, f__cnt, f__cp, f__cplus, f__nonl, f__pc, f__ret, f__rp, f__scale, f__workdone, GOTO, i, NED, NONL, syl::op, syl::p1, RET1, REVERT, S, SP, STACK, and type_f(). Referenced by en_fio(), ff_(), get_token__(), MAIN__(), parser_(), set_(), zzaxxx_(), zzaxyy_(), and zzlabl_(). 
 00389 {       struct syl *p;
00390         int n,i;
00391         for(i=0;i<*number;i++,ptr+=len)
00392         {
00393 loop:   switch(type_f((p= &f__syl[f__pc])->op))
00394         {
00395         default:
00396                 fprintf(stderr,"unknown code in do_fio: %d\n%s\n",
00397                         p->op,f__fmtbuf);
00398                 err(f__elist->cierr,100,"do_fio");
00399         case NED:
00400                 if((*f__doned)(p))
00401                 {       f__pc++;
00402                         goto loop;
00403                 }
00404                 f__pc++;
00405                 continue;
00406         case ED:
00407                 if(f__cnt[f__cp]<=0)
00408                 {       f__cp--;
00409                         f__pc++;
00410                         goto loop;
00411                 }
00412                 if(ptr==NULL)
00413                         return((*f__doend)());
00414                 f__cnt[f__cp]--;
00415                 f__workdone=1;
00416                 if((n=(*f__doed)(p,ptr,len))>0)
00417                         errfl(f__elist->cierr,errno,"fmt");
00418                 if(n<0)
00419                         err(f__elist->ciend,(EOF),"fmt");
00420                 continue;
00421         case STACK:
00422                 f__cnt[++f__cp]=p->p1;
00423                 f__pc++;
00424                 goto loop;
00425         case RET1:
00426                 f__ret[++f__rp]=p->p1;
00427                 f__pc++;
00428                 goto loop;
00429         case GOTO:
00430                 if(--f__cnt[f__cp]<=0)
00431                 {       f__cp--;
00432                         f__rp--;
00433                         f__pc++;
00434                         goto loop;
00435                 }
00436                 f__pc=1+f__ret[f__rp--];
00437                 goto loop;
00438         case REVERT:
00439                 f__rp=f__cp=0;
00440                 f__pc = p->p1;
00441                 if(ptr==NULL)
00442                         return((*f__doend)());
00443                 if(!f__workdone) return(0);
00444                 if((n=(*f__dorevert)()) != 0) return(n);
00445                 goto loop;
00446         case COLON:
00447                 if(ptr==NULL)
00448                         return((*f__doend)());
00449                 f__pc++;
00450                 goto loop;
00451         case NONL:
00452                 f__nonl = 1;
00453                 f__pc++;
00454                 goto loop;
00455         case S:
00456         case SS:
00457                 f__cplus=0;
00458                 f__pc++;
00459                 goto loop;
00460         case SP:
00461                 f__cplus = 1;
00462                 f__pc++;
00463                 goto loop;
00464         case P: f__scale=p->p1;
00465                 f__pc++;
00466                 goto loop;
00467         case BN:
00468                 f__cblank=0;
00469                 f__pc++;
00470                 goto loop;
00471         case BZ:
00472                 f__cblank=1;
00473                 f__pc++;
00474                 goto loop;
00475         }
00476         }
00477         return(0);
00478 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 190 of file fmt.c. References AW, f__pc, gt_num(), i, IM, L, O, OM, op_gen(), p, skip, STACK, and ZM. Referenced by i_tem(). 
 00192 {       int i,im,n,w,d,e,found=0,x=0;
00193         char *sv=s;
00194         s=gt_num(s,&n);
00195         (void) op_gen(STACK,n,0,0);
00196         switch(*s++)
00197         {
00198         default: break;
00199         case 'E':
00200         case 'e':       x=1;
00201         case 'G':
00202         case 'g':
00203                 found=1;
00204                 s=gt_num(s,&w);
00205                 if(w==0) break;
00206                 if(*s=='.')
00207                 {       s++;
00208                         s=gt_num(s,&d);
00209                 }
00210                 else d=0;
00211                 if(*s!='E' && *s != 'e')
00212                         (void) op_gen(x==1?E:G,w,d,0);  /* default is Ew.dE2 */
00213                 else
00214                 {       s++;
00215                         s=gt_num(s,&e);
00216                         (void) op_gen(x==1?EE:GE,w,d,e);
00217                 }
00218                 break;
00219         case 'O':
00220         case 'o':
00221                 i = O;
00222                 im = OM;
00223                 goto finish_I;
00224         case 'Z':
00225         case 'z':
00226                 i = Z;
00227                 im = ZM;
00228                 goto finish_I;
00229         case 'L':
00230         case 'l':
00231                 found=1;
00232                 s=gt_num(s,&w);
00233                 if(w==0) break;
00234                 (void) op_gen(L,w,0,0);
00235                 break;
00236         case 'A':
00237         case 'a':
00238                 found=1;
00239                 skip(s);
00240                 if(*s>='0' && *s<='9')
00241                 {       s=gt_num(s,&w);
00242                         if(w==0) break;
00243                         (void) op_gen(AW,w,0,0);
00244                         break;
00245                 }
00246                 (void) op_gen(A,0,0,0);
00247                 break;
00248         case 'F':
00249         case 'f':
00250                 found=1;
00251                 s=gt_num(s,&w);
00252                 if(w==0) break;
00253                 if(*s=='.')
00254                 {       s++;
00255                         s=gt_num(s,&d);
00256                 }
00257                 else d=0;
00258                 (void) op_gen(F,w,d,0);
00259                 break;
00260         case 'D':
00261         case 'd':
00262                 found=1;
00263                 s=gt_num(s,&w);
00264                 if(w==0) break;
00265                 if(*s=='.')
00266                 {       s++;
00267                         s=gt_num(s,&d);
00268                 }
00269                 else d=0;
00270                 (void) op_gen(D,w,d,0);
00271                 break;
00272         case 'I':
00273         case 'i':
00274                 i = I;
00275                 im = IM;
00276  finish_I:
00277                 found=1;
00278                 s=gt_num(s,&w);
00279                 if(w==0) break;
00280                 if(*s!='.')
00281                 {       (void) op_gen(i,w,0,0);
00282                         break;
00283                 }
00284                 s++;
00285                 s=gt_num(s,&d);
00286                 (void) op_gen(im,w,d,0);
00287                 break;
00288         }
00289         if(found==0)
00290         {       f__pc--; /*unSTACK*/
00291                 *p=sv;
00292                 return(0);
00293         }
00294         *p=s;
00295         return(1);
00296 }
 | 
| 
 | 
| 
 Definition at line 479 of file fmt.c. References do_fio(). 
 00480 {       ftnint one=1;
00481         return(do_fio(&one,(char *)NULL,(ftnint)0));
00482 }
 | 
| 
 | 
| 
 Definition at line 314 of file fmt.c. References f__parenlvl, f__revloc, GOTO, i_tem(), op_gen(), REVERT, and skip. Referenced by f_s(). 
 00316 {
00317         for(;*s!=0;)
00318         {       skip(s);
00319                 if((s=i_tem(s))==NULL) return(NULL);
00320                 skip(s);
00321                 if(*s==',') s++;
00322                 else if(*s==')')
00323                 {       if(--f__parenlvl==0)
00324                         {
00325                                 (void) op_gen(REVERT,f__revloc,0,0);
00326                                 return(++s);
00327                         }
00328                         (void) op_gen(GOTO,0,0,0);
00329                         return(++s);
00330                 }
00331         }
00332         return(NULL);
00333 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 84 of file fmt.c. References f__parenlvl, f__revloc, f_list(), op_gen(), RET1, and skip. Referenced by i_tem(), and pars_f(). 
 | 
| 
 | 
| 
 Definition at line 484 of file fmt.c. References f__cnt, f__cp, f__cursor, f__pc, f__ret, f__rp, and f__workdone. 
 | 
| 
 | ||||||||||||
| 
 Definition at line 63 of file fmt.c. Referenced by e_d(), i_tem(), and ne_d(). 
 | 
| 
 | 
| 
 Definition at line 300 of file fmt.c. References e_d(), f_s(), gt_num(), ne_d(), op_gen(), and STACK. Referenced by f_list(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 104 of file fmt.c. References ap_end(), APOS, BN, BZ, COLON, GLITCH, gt_num(), NONL, op_gen(), p, syl::p2, S, SLASH, SP, TL, and TR. Referenced by i_tem(). 
 00106 {       int n,x,sign=0;
00107         struct syl *sp;
00108         switch(*s)
00109         {
00110         default:
00111                 return(0);
00112         case ':': (void) op_gen(COLON,0,0,0); break;
00113         case '$':
00114                 (void) op_gen(NONL, 0, 0, 0); break;
00115         case 'B':
00116         case 'b':
00117                 if(*++s=='z' || *s == 'Z') (void) op_gen(BZ,0,0,0);
00118                 else (void) op_gen(BN,0,0,0);
00119                 break;
00120         case 'S':
00121         case 's':
00122                 if(*(s+1)=='s' || *(s+1) == 'S')
00123                 {       x=SS;
00124                         s++;
00125                 }
00126                 else if(*(s+1)=='p' || *(s+1) == 'P')
00127                 {       x=SP;
00128                         s++;
00129                 }
00130                 else x=S;
00131                 (void) op_gen(x,0,0,0);
00132                 break;
00133         case '/': (void) op_gen(SLASH,0,0,0); break;
00134         case '-': sign=1;
00135         case '+':       s++;    /*OUTRAGEOUS CODING TRICK*/
00136         case '0': case '1': case '2': case '3': case '4':
00137         case '5': case '6': case '7': case '8': case '9':
00138                 s=gt_num(s,&n);
00139                 switch(*s)
00140                 {
00141                 default:
00142                         return(0);
00143                 case 'P':
00144                 case 'p': if(sign) n= -n; (void) op_gen(P,n,0,0); break;
00145                 case 'X':
00146                 case 'x': (void) op_gen(X,n,0,0); break;
00147                 case 'H':
00148                 case 'h':
00149                         sp = &f__syl[op_gen(H,n,0,0)];
00150                         *(char **)&sp->p2 = s + 1;
00151                         s+=n;
00152                         break;
00153                 }
00154                 break;
00155         case GLITCH:
00156         case '"':
00157         case '\'':
00158                 sp = &f__syl[op_gen(APOS,0,0,0)];
00159                 *(char **)&sp->p2 = s;
00160                 if((*p = ap_end(s)) == NULL)
00161                         return(0);
00162                 return(1);
00163         case 'T':
00164         case 't':
00165                 if(*(s+1)=='l' || *(s+1) == 'L')
00166                 {       x=TL;
00167                         s++;
00168                 }
00169                 else if(*(s+1)=='r'|| *(s+1) == 'R')
00170                 {       x=TR;
00171                         s++;
00172                 }
00173                 else x=T;
00174                 s=gt_num(s+1,&n);
00175                 s--;
00176                 (void) op_gen(x,n,0,0);
00177                 break;
00178         case 'X':
00179         case 'x': (void) op_gen(X,1,0,0); break;
00180         case 'P':
00181         case 'p': (void) op_gen(P,1,0,0); break;
00182         }
00183         s++;
00184         *p=s;
00185         return(1);
00186 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 45 of file fmt.c. References a, c, f__pc, syl::op, syl::p1, syl::p2, syl::p3, and sig_die(). Referenced by e_d(), f_list(), f_s(), i_tem(), and ne_d(). 
 | 
| 
 | 
| 
 Definition at line 338 of file fmt.c. References f__parenlvl, f__pc, f__revloc, and f_s(). Referenced by c_si(), s_rdfe(), s_rsfe(), s_wdfe(), and s_wsfe(). 
 00340 {
00341         f__parenlvl=f__revloc=f__pc=0;
00342         if(f_s(s,0) == NULL)
00343         {
00344                 return(-1);
00345         }
00346         return(0);
00347 }
 | 
| 
 | 
| 
 Definition at line 355 of file fmt.c. References APOS, AW, E, EE, GE, GOTO, IM, L, O, OM, RET1, REVERT, SLASH, STACK, TL, TR, and ZM. Referenced by do_fio(). 
 00357 {
00358         switch(n)
00359         {
00360         default:
00361                 return(n);
00362         case RET1:
00363                 return(RET1);
00364         case REVERT: return(REVERT);
00365         case GOTO: return(GOTO);
00366         case STACK: return(STACK);
00367         case X:
00368         case SLASH:
00369         case APOS: case H:
00370         case T: case TL: case TR:
00371                 return(NED);
00372         case F:
00373         case I:
00374         case IM:
00375         case A: case AW:
00376         case O: case OM:
00377         case L:
00378         case E: case EE: case D:
00379         case G: case GE:
00380         case Z: case ZM:
00381                 return(ED);
00382         }
00383 }
 | 
Variable Documentation
| 
 | 
| 
 Definition at line 20 of file fmt.c. Referenced by do_fio(). | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 Definition at line 20 of file fmt.c. Referenced by do_fio(). | 
| 
 | 
| 
 Definition at line 19 of file fmt.c. Referenced by fmt_bg(). | 
| 
 | 
| 
 Definition at line 350 of file fmt.c. Referenced by do_fio(). | 
| 
 | 
| 
 | 
| 
 | 
| 
 Definition at line 22 of file fmt.c. Referenced by do_fio(), e_d(), fmt_bg(), op_gen(), and pars_f(). | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 Definition at line 19 of file fmt.c. Referenced by do_fio(). | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  