Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

pread.c File Reference

#include "defs.h"

Go to the source code of this file.


Defines

#define P_space   1
#define P_anum   2
#define P_delim   3
#define P_slash   4
#define TGULP   100
#define checklogical(n)

Functions

void trealloc (Void)
void badchar (int c)
void bad_type (Void)
void badflag (char *tname, char *option)
void detected (char *msg)
void checkreal (int k)
void Pnotboth (Extsym *e)
int numread (register FILE *pf, int *n)
void argverify Argdcl ((int, Extsym *))
void Pbadret Argdcl ((int ftype, Extsym *p))
int readref (register FILE *pf, Extsym *e, int ftype)
int comlen (register FILE *pf)
int Ptoken (FILE *pf, int canend)
int Pftype (Void)
void wanted (int i, char *what)
int Ptype (FILE *pf)
char * trimunder (Void)
void Pbadmsg (char *msg, Extsym *p)
void Pbadret (int ftype, Extsym *p)
void argverify (int ftype, Extsym *p)
void newarg (int ftype, Extsym *p)
int Pfile (char *fname)
void read_Pfiles (char **ffiles)

Variables

char Ptok [128]
char Pct [Table_size]
char * Pfname
long Plineno
int Pbad
int * tfirst
int * tlast
int * tnext
int tmax

Define Documentation

#define checklogical n   
 

Definition at line 143 of file pread.c.

Referenced by Pftype(), and Ptype().

#define P_anum   2
 

Definition at line 33 of file pread.c.

Referenced by comlen(), Pfile(), Ptoken(), Ptype(), and wanted().

#define P_delim   3
 

Definition at line 34 of file pread.c.

Referenced by Pfile(), and Ptoken().

#define P_slash   4
 

Definition at line 35 of file pread.c.

Referenced by Pfile(), and Ptoken().

#define P_space   1
 

Definition at line 32 of file pread.c.

Referenced by Pfile(), and Ptoken().

#define TGULP   100
 

Definition at line 37 of file pread.c.

Referenced by trealloc().


Function Documentation

void Pbadret Argdcl (int ftype, Extsym *p   [static]
 

void argverify Argdcl (int, Extsym *)    [static]
 

void argverify int    ftype,
Extsym   p
[static]
 

Definition at line 755 of file pread.c.

References Extsym::arginfo, Argtype(), Argtypes::atypes, Argtypes::changes, Extsym::extype, i, Argtypes::nargs, Pbadmsg(), Pbadret(), tfirst, tnext, Atype::type, and type_fixup().

Referenced by Pfile(), and readref().

00757 {
00758         Argtypes *at;
00759         register Atype *aty;
00760         int i, j, k;
00761         register int *t, *te;
00762         char buf1[32], buf2[32];
00763 
00764         at = p->arginfo;
00765         if (at->nargs < 0)
00766                 return;
00767         if (p->extype != ftype) {
00768                 Pbadret(ftype, p);
00769                 return;
00770                 }
00771         t = tfirst;
00772         te = tnext;
00773         i = te - t;
00774         if (at->nargs != i) {
00775                 j = at->nargs;
00776                 Pbadmsg("differing numbers of arguments",p);
00777                 fprintf(stderr, "here %d, previously %d\n",
00778                         i, j);
00779                 return;
00780                 }
00781         for(aty = at->atypes; t < te; t++, aty++) {
00782                 if (*t == aty->type)
00783                         continue;
00784                 j = aty->type;
00785                 k = *t;
00786                 if (k >= 300 || k == j)
00787                         continue;
00788                 if (j >= 300) {
00789                         if (k >= 200) {
00790                                 if (k == TYUNKNOWN + 200)
00791                                         continue;
00792                                 if (j % 100 != k - 200
00793                                  && k != TYSUBR + 200
00794                                  && j != TYUNKNOWN + 300
00795                                  && !type_fixup(at,aty,k))
00796                                         goto badtypes;
00797                                 }
00798                         else if (j % 100 % TYSUBR != k % TYSUBR
00799                                         && !type_fixup(at,aty,k))
00800                                 goto badtypes;
00801                         }
00802                 else if (k < 200 || j < 200)
00803                         goto badtypes;
00804                 else if (k == TYUNKNOWN+200)
00805                         continue;
00806                 else if (j != TYUNKNOWN+200)
00807                         {
00808  badtypes:
00809                         Pbadmsg("differing calling sequences",p);
00810                         i = t - tfirst + 1;
00811                         fprintf(stderr,
00812                                 "arg %d: here %s, prevously %s\n",
00813                                 i, Argtype(k,buf1), Argtype(j,buf2));
00814                         return;
00815                         }
00816                 /* We've subsequently learned the right type,
00817                    as in the call on zoo below...
00818 
00819                         subroutine foo(x, zap)
00820                         external zap
00821                         call goo(zap)
00822                         x = zap(3)
00823                         call zoo(zap)
00824                         end
00825                  */
00826                 aty->type = k;
00827                 at->changes = 1;
00828                 }
00829         }

void bad_type Void    [static]
 

Definition at line 69 of file pread.c.

References Pfname, Plineno, and Ptok.

Referenced by Pftype(), and Ptype().

00070 {
00071         fprintf(stderr,
00072                 "unexpected type \"%s\" on line %ld of %s\n",
00073                 Ptok, Plineno, Pfname);
00074         exit(2);
00075         }

void badchar int    c [static]
 

Definition at line 59 of file pread.c.

References c, Pfname, and Plineno.

Referenced by Pfile(), Ptoken(), and Ptype().

00061 {
00062         fprintf(stderr,
00063                 "unexpected character 0x%.2x = '%c' on line %ld of %s\n",
00064                 c, c, Plineno, Pfname);
00065         exit(2);
00066         }

void badflag char *    tname,
char *    option
[static]
 

Definition at line 83 of file pread.c.

References Pbad, Pfname, and Plineno.

Referenced by checkreal().

00085 {
00086         fprintf(stderr, "%s type from `f2c -%s` on line %ld of %s\n",
00087                 tname, option, Plineno, Pfname);
00088         Pbad++;
00089         }

void checkreal int    k [static]
 

Definition at line 151 of file pread.c.

References badflag(), and detected().

Referenced by Pftype().

00153 {
00154         static int warned = 0;
00155         static int seen[2] = {0,0};
00156 
00157         seen[k] = 1;
00158         if (seen[1-k]) {
00159                 if (warned < 2)
00160                         detected("Illegal mixture of -R and -!R ");
00161                 warned = 2;
00162                 return;
00163                 }
00164         if (k == forcedouble || warned)
00165                 return;
00166         warned = 1;
00167         badflag("REAL return", k ? "!R" : "R");
00168         }

int comlen register FILE *    pf [static]
 

Definition at line 297 of file pread.c.

References c, cbuf, Extsym::extstg, L, Extsym::maxleng, mkext1(), P_anum, Pct, Pfname, Plineno, Pnotboth(), readref(), STGCOMMON, STGUNKNOWN, and ungetc().

Referenced by Ptoken().

00299 {
00300         register int c;
00301         register char *s, *se;
00302         char buf[128], cbuf[128];
00303         int refread;
00304         long L;
00305         Extsym *e;
00306 
00307         if ((c = getc(pf)) == EOF)
00308                 return 1;
00309         if (c == ' ') {
00310                 refread = 0;
00311                 s = "comlen ";
00312                 }
00313         else if (c == ':') {
00314                 refread = 1;
00315                 s = "ref: ";
00316                 }
00317         else {
00318  ret0:
00319                 if (c == '*')
00320                         ungetc(c,pf);
00321                 return 0;
00322                 }
00323         while(*s) {
00324                 if ((c = getc(pf)) == EOF)
00325                         return 1;
00326                 if (c != *s++)
00327                         goto ret0;
00328                 }
00329         s = buf;
00330         se = buf + sizeof(buf) - 1;
00331         for(;;) {
00332                 if ((c = getc(pf)) == EOF)
00333                         return 1;
00334                 if (c == ' ')
00335                         break;
00336                 if (s >= se || Pct[c] != P_anum)
00337                         goto ret0;
00338                 *s++ = c;
00339                 }
00340         *s-- = 0;
00341         if (s <= buf || *s != '_')
00342                 return 0;
00343         strcpy(cbuf,buf);
00344         *s-- = 0;
00345         if (*s == '_') {
00346                 *s-- = 0;
00347                 if (s <= buf)
00348                         return 0;
00349                 }
00350         for(L = 0;;) {
00351                 if ((c = getc(pf)) == EOF)
00352                         return 1;
00353                 if (c == ' ')
00354                         break;
00355                 if (c < '0' && c > '9')
00356                         goto ret0;
00357                 L = 10*L + c - '0';
00358                 }
00359         if (!L && !refread)
00360                 return 0;
00361         e = mkext1(buf, cbuf);
00362         if (refread)
00363                 return readref(pf, e, (int)L);
00364         if (e->extstg == STGUNKNOWN) {
00365                 e->extstg = STGCOMMON;
00366                 e->maxleng = L;
00367                 }
00368         else if (e->extstg != STGCOMMON)
00369                 Pnotboth(e);
00370         else if (e->maxleng != L) {
00371                 fprintf(stderr,
00372         "incompatible lengths for common block %s (line %ld of %s)\n",
00373                                     buf, Plineno, Pfname);
00374                 if (e->maxleng < L)
00375                         e->maxleng = L;
00376                 }
00377         return 0;
00378         }

void detected char *    msg [static]
 

Definition at line 96 of file pread.c.

References Pbad, Pfname, and Plineno.

Referenced by checkreal().

00098 {
00099         fprintf(stderr,
00100         "%sdetected on line %ld of %s\n", msg, Plineno, Pfname);
00101         Pbad++;
00102         }

void newarg int    ftype,
Extsym   p
[static]
 

Definition at line 837 of file pread.c.

References Extsym::arginfo, Argtypes::atypes, Argtypes::changes, Atype::cp, Argtypes::defined, Argtypes::dnargs, Extsym::exproto, Extsym::extstg, Extsym::extype, gmem(), i, Argtypes::nargs, Pnotboth(), STGCOMMON, STGEXT, tfirst, tnext, and Atype::type.

Referenced by Pfile().

00839 {
00840         Argtypes *at;
00841         register Atype *aty;
00842         register int *t, *te;
00843         int i, k;
00844 
00845         if (p->extstg == STGCOMMON) {
00846                 Pnotboth(p);
00847                 return;
00848                 }
00849         p->extstg = STGEXT;
00850         p->extype = ftype;
00851         p->exproto = 1;
00852         t = tfirst;
00853         te = tnext;
00854         i = te - t;
00855         k = sizeof(Argtypes) + (i-1)*sizeof(Atype);
00856         at = p->arginfo = (Argtypes *)gmem(k,1);
00857         at->dnargs = at->nargs = i;
00858         at->defined = at->changes = 0;
00859         for(aty = at->atypes; t < te; aty++) {
00860                 aty->type = *t++;
00861                 aty->cp = 0;
00862                 }
00863         }

int numread register FILE *    pf,
int *    n
[static]
 

Definition at line 193 of file pread.c.

References c.

Referenced by readref().

00195 {
00196         register int c, k;
00197 
00198         if ((c = getc(pf)) < '0' || c > '9')
00199                 return c;
00200         k = c - '0';
00201         for(;;) {
00202                 if ((c = getc(pf)) == ' ') {
00203                         *n = k;
00204                         return c;
00205                         }
00206                 if (c < '0' || c > '9')
00207                         break;
00208                 k = 10*k + c - '0';
00209                 }
00210         return c;
00211         }

void Pbadmsg char *    msg,
Extsym   p
[static]
 

Definition at line 723 of file pread.c.

References Extsym::arginfo, Extsym::fextname, Argtypes::nargs, Pbad, Pfname, and Plineno.

Referenced by argverify(), and Pbadret().

00725 {
00726         Pbad++;
00727         fprintf(stderr, "%s for %s (line %ld of %s):\n\t", msg,
00728                 p->fextname, Plineno, Pfname);
00729         p->arginfo->nargs = -1;
00730         }

void Pbadret int    ftype,
Extsym   p
[static]
 

Definition at line 738 of file pread.c.

References Argtype(), Extsym::extype, and Pbadmsg().

Referenced by argverify(), and readref().

00740 {
00741         char buf1[32], buf2[32];
00742 
00743         Pbadmsg("inconsistent types",p);
00744         fprintf(stderr, "here %s, previously %s\n",
00745                 Argtype(ftype+200,buf1),
00746                 Argtype(p->extype+200,buf2));
00747         }

int Pfile char *    fname [static]
 

Definition at line 870 of file pread.c.

References Extsym::arginfo, argverify(), badchar(), Argtypes::defined, i, mkext1(), Argtypes::nargs, newarg(), P_anum, P_delim, P_slash, P_space, Pct, Pfname, Pftype(), Plineno, Ptok, Ptoken(), Ptype(), tfirst, tlast, tnext, trealloc(), trimunder(), and wanted().

Referenced by read_Pfiles().

00872 {
00873         char *s;
00874         int ftype, i;
00875         FILE *pf;
00876         Extsym *p;
00877 
00878         for(s = fname; *s; s++);
00879         if (s - fname < 2
00880         || s[-2] != '.'
00881         || (s[-1] != 'P' && s[-1] != 'p'))
00882                 return 0;
00883 
00884         if (!(pf = fopen(fname, textread))) {
00885                 fprintf(stderr, "can't open %s\n", fname);
00886                 exit(2);
00887                 }
00888         Pfname = fname;
00889         Plineno = 1;
00890         if (!Pct[' ']) {
00891                 for(s = " \t\n\r\v\f"; *s; s++)
00892                         Pct[*s] = P_space;
00893                 for(s = "*,();"; *s; s++)
00894                         Pct[*s] = P_delim;
00895                 for(i = '0'; i <= '9'; i++)
00896                         Pct[i] = P_anum;
00897                 for(s = "abcdefghijklmnopqrstuvwxyz"; i = *s; s++)
00898                         Pct[i] = Pct[i+'A'-'a'] = P_anum;
00899                 Pct['_'] = P_anum;
00900                 Pct['/'] = P_slash;
00901                 }
00902 
00903         for(;;) {
00904                 if (!(i = Ptoken(pf,1)))
00905                         break;
00906                 if (i != P_anum
00907                 || !strcmp(Ptok, "extern") && (i = Ptoken(pf,0)) != P_anum)
00908                         badchar(i);
00909                 ftype = Pftype();
00910  getname:
00911                 if ((i = Ptoken(pf,0)) != P_anum)
00912                         badchar(i);
00913                 p = mkext1(trimunder(), Ptok);
00914 
00915                 if ((i = Ptoken(pf,0)) != '(')
00916                         badchar(i);
00917                 tnext = tfirst;
00918                 while(i = Ptype(pf)) {
00919                         if (tnext >= tlast)
00920                                 trealloc();
00921                         *tnext++ = i;
00922                         }
00923                 if (p->arginfo) {
00924                         argverify(ftype, p);
00925                         if (p->arginfo->nargs < 0)
00926                                 newarg(ftype, p);
00927                         }
00928                 else
00929                         newarg(ftype, p);
00930                 p->arginfo->defined = 1;
00931                 i = Ptoken(pf,0);
00932                 switch(i) {
00933                         case ';':
00934                                 break;
00935                         case ',':
00936                                 goto getname;
00937                         default:
00938                                 wanted(i, "\";\" or \",\"");
00939                         }
00940                 }
00941         fclose(pf);
00942         return 1;
00943         }

int Pftype Void    [static]
 

Definition at line 463 of file pread.c.

References bad_type(), checklogical, checkreal(), Ptok, and TYQUAD.

Referenced by Pfile().

00464 {
00465         switch(Ptok[0]) {
00466                 case 'C':
00467                         if (!strcmp(Ptok+1, "_f"))
00468                                 return TYCOMPLEX;
00469                         break;
00470                 case 'E':
00471                         if (!strcmp(Ptok+1, "_f")) {
00472                                 /* TYREAL under forcedouble */
00473                                 checkreal(1);
00474                                 return TYREAL;
00475                                 }
00476                         break;
00477                 case 'H':
00478                         if (!strcmp(Ptok+1, "_f"))
00479                                 return TYCHAR;
00480                         break;
00481                 case 'Z':
00482                         if (!strcmp(Ptok+1, "_f"))
00483                                 return TYDCOMPLEX;
00484                         break;
00485                 case 'd':
00486                         if (!strcmp(Ptok+1, "oublereal"))
00487                                 return TYDREAL;
00488                         break;
00489                 case 'i':
00490                         if (!strcmp(Ptok+1, "nt"))
00491                                 return TYSUBR;
00492                         if (!strcmp(Ptok+1, "nteger"))
00493                                 return TYLONG;
00494                         if (!strcmp(Ptok+1, "nteger1"))
00495                                 return TYINT1;
00496                         break;
00497                 case 'l':
00498                         if (!strcmp(Ptok+1, "ogical")) {
00499                                 checklogical(1);
00500                                 return TYLOGICAL;
00501                                 }
00502                         if (!strcmp(Ptok+1, "ogical1"))
00503                                 return TYLOGICAL1;
00504 #ifdef TYQUAD
00505                         if (!strcmp(Ptok+1, "ongint"))
00506                                 return TYQUAD;
00507 #endif
00508                         break;
00509                 case 'r':
00510                         if (!strcmp(Ptok+1, "eal")) {
00511                                 checkreal(0);
00512                                 return TYREAL;
00513                                 }
00514                         break;
00515                 case 's':
00516                         if (!strcmp(Ptok+1, "hortint"))
00517                                 return TYSHORT;
00518                         if (!strcmp(Ptok+1, "hortlogical")) {
00519                                 checklogical(0);
00520                                 return TYLOGICAL2;
00521                                 }
00522                         break;
00523                 }
00524         bad_type();
00525         /* NOT REACHED */
00526         return 0;
00527         }

void Pnotboth Extsym   e [static]
 

Definition at line 175 of file pread.c.

References Pbad, Pfname, and Plineno.

Referenced by comlen(), newarg(), and readref().

00177 {
00178         if (e->curno)
00179                 return;
00180         Pbad++;
00181         e->curno = 1;
00182         fprintf(stderr,
00183         "%s cannot be both a procedure and a common block (line %ld of %s)\n",
00184                 e->fextname, Plineno, Pfname);
00185         }

int Ptoken FILE *    pf,
int    canend
[static]
 

Definition at line 386 of file pread.c.

References badchar(), c, comlen(), P_anum, P_delim, P_slash, P_space, Pct, Pfname, Plineno, Ptok, top, and ungetc().

Referenced by Pfile(), and Ptype().

00388 {
00389         register int c;
00390         register char *s, *se;
00391 
00392  top:
00393         for(;;) {
00394                 c = getc(pf);
00395                 if (c == EOF) {
00396                         if (canend)
00397                                 return 0;
00398                         goto badeof;
00399                         }
00400                 if (Pct[c] != P_space)
00401                         break;
00402                 if (c == '\n')
00403                         Plineno++;
00404                 }
00405         switch(Pct[c]) {
00406                 case P_anum:
00407                         if (c == '_')
00408                                 badchar(c);
00409                         s = Ptok;
00410                         se = s + sizeof(Ptok) - 1;
00411                         do {
00412                                 if (s < se)
00413                                         *s++ = c;
00414                                 if ((c = getc(pf)) == EOF) {
00415  badeof:
00416                                         fprintf(stderr,
00417                                         "unexpected end of file in %s\n",
00418                                                 Pfname);
00419                                         exit(2);
00420                                         }
00421                                 }
00422                                 while(Pct[c] == P_anum);
00423                         ungetc(c,pf);
00424                         *s = 0;
00425                         return P_anum;
00426 
00427                 case P_delim:
00428                         return c;
00429 
00430                 case P_slash:
00431                         if ((c = getc(pf)) != '*') {
00432                                 if (c == EOF)
00433                                         goto badeof;
00434                                 badchar('/');
00435                                 }
00436                         if (canend && comlen(pf))
00437                                 goto badeof;
00438                         for(;;) {
00439                                 while((c = getc(pf)) != '*') {
00440                                         if (c == EOF)
00441                                                 goto badeof;
00442                                         if (c == '\n')
00443                                                 Plineno++;
00444                                         }
00445  slashseek:
00446                                 switch(getc(pf)) {
00447                                         case '/':
00448                                                 goto top;
00449                                         case EOF:
00450                                                 goto badeof;
00451                                         case '*':
00452                                                 goto slashseek;
00453                                         }
00454                                 }
00455                 default:
00456                         badchar(c);
00457                 }
00458         /* NOT REACHED */
00459         return 0;
00460         }

int Ptype FILE *    pf [static]
 

Definition at line 552 of file pread.c.

References bad_type(), badchar(), checklogical, i, P_anum, Ptok, Ptoken(), tfirst, tnext, TYFTNLEN, TYQUAD, ungetc(), and wanted().

Referenced by Pfile().

00554 {
00555         int i, rv;
00556 
00557         i = Ptoken(pf,0);
00558         if (i == ')')
00559                 return 0;
00560         if (i != P_anum)
00561                 badchar(i);
00562 
00563         rv = 0;
00564         switch(Ptok[0]) {
00565                 case 'C':
00566                         if (!strcmp(Ptok+1, "_fp"))
00567                                 rv = TYCOMPLEX+200;
00568                         break;
00569                 case 'D':
00570                         if (!strcmp(Ptok+1, "_fp"))
00571                                 rv = TYDREAL+200;
00572                         break;
00573                 case 'E':
00574                 case 'R':
00575                         if (!strcmp(Ptok+1, "_fp"))
00576                                 rv = TYREAL+200;
00577                         break;
00578                 case 'H':
00579                         if (!strcmp(Ptok+1, "_fp"))
00580                                 rv = TYCHAR+200;
00581                         break;
00582                 case 'I':
00583                         if (!strcmp(Ptok+1, "_fp"))
00584                                 rv = TYLONG+200;
00585                         else if (!strcmp(Ptok+1, "1_fp"))
00586                                 rv = TYINT1+200;
00587 #ifdef TYQUAD
00588                         else if (!strcmp(Ptok+1, "8_fp"))
00589                                 rv = TYQUAD+200;
00590 #endif
00591                         break;
00592                 case 'J':
00593                         if (!strcmp(Ptok+1, "_fp"))
00594                                 rv = TYSHORT+200;
00595                         break;
00596                 case 'K':
00597                         checklogical(0);
00598                         goto Logical;
00599                 case 'L':
00600                         checklogical(1);
00601  Logical:
00602                         if (!strcmp(Ptok+1, "_fp"))
00603                                 rv = TYLOGICAL+200;
00604                         else if (!strcmp(Ptok+1, "1_fp"))
00605                                 rv = TYLOGICAL1+200;
00606                         else if (!strcmp(Ptok+1, "2_fp"))
00607                                 rv = TYLOGICAL2+200;
00608                         break;
00609                 case 'S':
00610                         if (!strcmp(Ptok+1, "_fp"))
00611                                 rv = TYSUBR+200;
00612                         break;
00613                 case 'U':
00614                         if (!strcmp(Ptok+1, "_fp"))
00615                                 rv = TYUNKNOWN+300;
00616                         break;
00617                 case 'Z':
00618                         if (!strcmp(Ptok+1, "_fp"))
00619                                 rv = TYDCOMPLEX+200;
00620                         break;
00621                 case 'c':
00622                         if (!strcmp(Ptok+1, "har"))
00623                                 rv = TYCHAR;
00624                         else if (!strcmp(Ptok+1, "omplex"))
00625                                 rv = TYCOMPLEX;
00626                         break;
00627                 case 'd':
00628                         if (!strcmp(Ptok+1, "oublereal"))
00629                                 rv = TYDREAL;
00630                         else if (!strcmp(Ptok+1, "oublecomplex"))
00631                                 rv = TYDCOMPLEX;
00632                         break;
00633                 case 'f':
00634                         if (!strcmp(Ptok+1, "tnlen"))
00635                                 rv = TYFTNLEN+100;
00636                         break;
00637                 case 'i':
00638                         if (!strncmp(Ptok+1, "nteger", 6)) {
00639                                 if (!Ptok[7])
00640                                         rv = TYLONG;
00641                                 else if (Ptok[7] == '1' && !Ptok[8])
00642                                         rv = TYINT1;
00643                                 }
00644                         break;
00645                 case 'l':
00646                         if (!strncmp(Ptok+1, "ogical", 6)) {
00647                                 if (!Ptok[7]) {
00648                                         checklogical(1);
00649                                         rv = TYLOGICAL;
00650                                         }
00651                                 else if (Ptok[7] == '1' && !Ptok[8])
00652                                         rv = TYLOGICAL1;
00653                                 }
00654 #ifdef TYQUAD
00655                         else if (!strcmp(Ptok+1,"ongint"))
00656                                 rv = TYQUAD;
00657 #endif
00658                         break;
00659                 case 'r':
00660                         if (!strcmp(Ptok+1, "eal"))
00661                                 rv = TYREAL;
00662                         break;
00663                 case 's':
00664                         if (!strcmp(Ptok+1, "hortint"))
00665                                 rv = TYSHORT;
00666                         else if (!strcmp(Ptok+1, "hortlogical")) {
00667                                 checklogical(0);
00668                                 rv = TYLOGICAL2;
00669                                 }
00670                         break;
00671                 case 'v':
00672                         if (tnext == tfirst && !strcmp(Ptok+1, "oid")) {
00673                                 if ((i = Ptoken(pf,0)) != /*(*/ ')')
00674                                         wanted(i, /*(*/ "\")\"");
00675                                 return 0;
00676                                 }
00677                 }
00678         if (!rv)
00679                 bad_type();
00680         if (rv < 100 && (i = Ptoken(pf,0)) != '*')
00681                         wanted(i, "\"*\"");
00682         if ((i = Ptoken(pf,0)) == P_anum)
00683                 i = Ptoken(pf,0);       /* skip variable name */
00684         switch(i) {
00685                 case ')':
00686                         ungetc(i,pf);
00687                         break;
00688                 case ',':
00689                         break;
00690                 default:
00691                         wanted(i, "\",\" or \")\"");
00692                 }
00693         return rv;
00694         }

void read_Pfiles char **    ffiles
 

Definition at line 950 of file pread.c.

References Extsym::arginfo, Argtypes::changes, Extsym::extstg, free, Argtypes::nargs, Pfile(), retcode, STGEXT, tfirst, tlast, tmax, and tnext.

Referenced by main().

00952 {
00953         char **f1files, **f1files0, *s;
00954         int k;
00955         register Extsym *e, *ee;
00956         register Argtypes *at;
00957         extern int retcode;
00958 
00959         f1files0 = f1files = ffiles;
00960         while(s = *ffiles++)
00961                 if (!Pfile(s))
00962                         *f1files++ = s;
00963         if (Pbad)
00964                 retcode = 8;
00965         if (tfirst) {
00966                 free((char *)tfirst);
00967                 /* following should be unnecessary, as we won't be back here */
00968                 tfirst = tnext = tlast = 0;
00969                 tmax = 0;
00970                 }
00971         *f1files = 0;
00972         if (f1files == f1files0)
00973                 f1files[1] = 0;
00974 
00975         k = 0;
00976         ee = nextext;
00977         for (e = extsymtab; e < ee; e++)
00978                 if (e->extstg == STGEXT
00979                 && (at = e->arginfo)) {
00980                         if (at->nargs < 0 || at->changes)
00981                                 k++;
00982                         at->changes = 2;
00983                         }
00984         if (k) {
00985                 fprintf(diagfile,
00986                 "%d prototype%s updated while reading prototypes.\n", k,
00987                         k > 1 ? "s" : "");
00988                 }
00989         fflush(diagfile);
00990         }

int readref register FILE *    pf,
Extsym   e,
int    ftype
[static]
 

Definition at line 223 of file pread.c.

References a, Extsym::arginfo, argverify(), Argtypes::atypes, c, Argtypes::changes, Atype::cp, Argtypes::dnargs, Extsym::extstg, Extsym::extype, gmem(), i, Argtypes::nargs, numread(), Pbadret(), Pnotboth(), STGEXT, STGUNKNOWN, tfirst, tlast, tnext, trealloc(), TYFTNLEN, and Atype::type.

Referenced by comlen().

00225 {
00226         register int c, *t;
00227         int i, nargs, type;
00228         Argtypes *at;
00229         Atype *a, *ae;
00230 
00231         if (ftype > TYSUBR)
00232                 return 0;
00233         if ((c = numread(pf, &nargs)) != ' ') {
00234                 if (c != ':')
00235                         return c == EOF;
00236                 /* just a typed external */
00237                 if (e->extstg == STGUNKNOWN) {
00238                         at = 0;
00239                         goto justsym;
00240                         }
00241                 if (e->extstg == STGEXT) {
00242                         if (e->extype != ftype)
00243                                 Pbadret(ftype, e);
00244                         }
00245                 else
00246                         Pnotboth(e);
00247                 return 0;
00248                 }
00249 
00250         tnext = tfirst;
00251         for(i = 0; i < nargs; i++) {
00252                 if ((c = numread(pf, &type)) != ' '
00253                 || type >= 500
00254                 || type != TYFTNLEN + 100 && type % 100 > TYSUBR)
00255                         return c == EOF;
00256                 if (tnext >= tlast)
00257                         trealloc();
00258                 *tnext++ = type;
00259                 }
00260 
00261         if (e->extstg == STGUNKNOWN) {
00262  save_at:
00263                 at = (Argtypes *)
00264                         gmem(sizeof(Argtypes) + (nargs-1)*sizeof(Atype), 1);
00265                 at->dnargs = at->nargs = nargs;
00266                 at->changes = 0;
00267                 t = tfirst;
00268                 a = at->atypes;
00269                 for(ae = a + nargs; a < ae; a++) {
00270                         a->type = *t++;
00271                         a->cp = 0;
00272                         }
00273  justsym:
00274                 e->extstg = STGEXT;
00275                 e->extype = ftype;
00276                 e->arginfo = at;
00277                 }
00278         else if (e->extstg != STGEXT) {
00279                 Pnotboth(e);
00280                 }
00281         else if (!e->arginfo) {
00282                 if (e->extype != ftype)
00283                         Pbadret(ftype, e);
00284                 else
00285                         goto save_at;
00286                 }
00287         else
00288                 argverify(ftype, e);
00289         return 0;
00290         }

void trealloc Void    [static]
 

Definition at line 40 of file pread.c.

References realloc, tfirst, TGULP, tlast, tmax, and tnext.

Referenced by Pfile(), and readref().

00041 {
00042         int k = tmax;
00043         tfirst = (int *)realloc((char *)tfirst,
00044                 (tmax += TGULP)*sizeof(int));
00045         if (!tfirst) {
00046                 fprintf(stderr,
00047                 "Pfile: realloc failure!\n");
00048                 exit(2);
00049                 }
00050         tlast = tfirst + tmax;
00051         tnext = tfirst + k;
00052         }

char* trimunder Void    [static]
 

Definition at line 697 of file pread.c.

References Pfname, Plineno, and Ptok.

Referenced by Pfile().

00698 {
00699         register char *s;
00700         register int n;
00701         static char buf[128];
00702 
00703         s = Ptok + strlen(Ptok) - 1;
00704         if (*s != '_') {
00705                 fprintf(stderr,
00706                         "warning: %s does not end in _ (line %ld of %s)\n",
00707                         Ptok, Plineno, Pfname);
00708                 return Ptok;
00709                 }
00710         if (s[-1] == '_')
00711                 s--;
00712         strncpy(buf, Ptok, n = s - Ptok);
00713         buf[n] = 0;
00714         return buf;
00715         }

void wanted int    i,
char *    what
[static]
 

Definition at line 535 of file pread.c.

References i, P_anum, Pfname, Plineno, and Ptok.

Referenced by Pfile(), and Ptype().

00537 {
00538         if (i != P_anum) {
00539                 Ptok[0] = i;
00540                 Ptok[1] = 0;
00541                 }
00542         fprintf(stderr,"Error: expected %s, not \"%s\" (line %ld of %s)\n",
00543                 what, Ptok, Plineno, Pfname);
00544         exit(2);
00545         }

Variable Documentation

int Pbad [static]
 

Definition at line 29 of file pread.c.

Referenced by badflag(), detected(), Pbadmsg(), and Pnotboth().

char Pct[Table_size] [static]
 

Definition at line 26 of file pread.c.

Referenced by comlen(), Pfile(), and Ptoken().

char* Pfname [static]
 

Definition at line 27 of file pread.c.

Referenced by bad_type(), badchar(), badflag(), comlen(), detected(), Pbadmsg(), Pfile(), Pnotboth(), Ptoken(), trimunder(), and wanted().

long Plineno [static]
 

Definition at line 28 of file pread.c.

Referenced by bad_type(), badchar(), badflag(), comlen(), detected(), Pbadmsg(), Pfile(), Pnotboth(), Ptoken(), trimunder(), and wanted().

char Ptok[128] [static]
 

Definition at line 26 of file pread.c.

Referenced by bad_type(), Pfile(), Pftype(), Ptoken(), Ptype(), trimunder(), and wanted().

int* tfirst [static]
 

Definition at line 30 of file pread.c.

Referenced by argverify(), newarg(), Pfile(), Ptype(), read_Pfiles(), readref(), and trealloc().

int * tlast [static]
 

Definition at line 30 of file pread.c.

Referenced by Pfile(), read_Pfiles(), readref(), and trealloc().

int tmax [static]
 

Definition at line 30 of file pread.c.

Referenced by read_Pfiles(), and trealloc().

int * tnext [static]
 

Definition at line 30 of file pread.c.

Referenced by argverify(), newarg(), Pfile(), Ptype(), read_Pfiles(), readref(), and trealloc().

 

Powered by Plone

This site conforms to the following standards: