| 74 | 
  | 
 | 
| 75 | 
  | 
/************************** INITIALIZATION ROUTINES ***********************/ | 
| 76 | 
  | 
 | 
| 77 | 
< | 
char * | 
| 77 | 
> | 
const char * | 
| 78 | 
  | 
formstr(                                /* return format identifier */ | 
| 79 | 
  | 
        int  f | 
| 80 | 
  | 
) | 
| 102 | 
  | 
                sprintf(errmsg, "duplicate modifier '%s'", modn); | 
| 103 | 
  | 
                error(USER, errmsg); | 
| 104 | 
  | 
        } | 
| 105 | 
– | 
        if (nmods >= MAXMODLIST) { | 
| 106 | 
– | 
                sprintf(errmsg, "too many modifiers (%d limit)", MAXMODLIST); | 
| 107 | 
– | 
                error(INTERNAL, errmsg); | 
| 108 | 
– | 
        } | 
| 105 | 
  | 
        if (!strcmp(modn, VOIDID)) { | 
| 106 | 
  | 
                sprintf(errmsg, "cannot track '%s' modifier", VOIDID); | 
| 107 | 
  | 
                error(USER, errmsg); | 
| 108 | 
  | 
        } | 
| 109 | 
+ | 
        if (nmods >= modasiz) {         /* need bigger modifier array */ | 
| 110 | 
+ | 
                modasiz += modasiz/2 + 64; | 
| 111 | 
+ | 
                if (modname == NULL) | 
| 112 | 
+ | 
                        modname = (char **)malloc(modasiz*sizeof(char *)); | 
| 113 | 
+ | 
                else | 
| 114 | 
+ | 
                        modname = (char **)realloc(modname, modasiz*sizeof(char *)); | 
| 115 | 
+ | 
                if (modname == NULL) | 
| 116 | 
+ | 
                        error(SYSTEM, "Out of memory in addmodifier()"); | 
| 117 | 
+ | 
        } | 
| 118 | 
  | 
        modname[nmods++] = modn;        /* XXX assumes static string */ | 
| 119 | 
  | 
        lep->key = modn;                /* XXX assumes static string */ | 
| 120 | 
  | 
        if (binv == NULL) | 
| 159 | 
  | 
void | 
| 160 | 
  | 
addmodfile(char *fname, char *outf, char *prms, char *binv, int bincnt) | 
| 161 | 
  | 
{ | 
| 162 | 
< | 
        char    *mname[MAXMODLIST]; | 
| 163 | 
< | 
        int     i; | 
| 164 | 
< | 
                                        /* find the file & store strings */ | 
| 165 | 
< | 
        i = wordfile(mname, MAXMODLIST, getpath(fname, getrlibpath(), R_OK)); | 
| 166 | 
< | 
        if (i < 0) { | 
| 167 | 
< | 
                sprintf(errmsg, "cannot find modifier file '%s'", fname); | 
| 162 | 
> | 
        char    *path = getpath(fname, getrlibpath(), R_OK); | 
| 163 | 
> | 
        char    mod[MAXSTR]; | 
| 164 | 
> | 
        FILE    *fp; | 
| 165 | 
> | 
 | 
| 166 | 
> | 
        if (path == NULL || (fp = fopen(path, "r")) == NULL) { | 
| 167 | 
> | 
                if (path == NULL) | 
| 168 | 
> | 
                        sprintf(errmsg, "cannot find modifier file '%s'", fname); | 
| 169 | 
> | 
                else | 
| 170 | 
> | 
                        sprintf(errmsg, "cannot load modifier file '%s'", path); | 
| 171 | 
  | 
                error(SYSTEM, errmsg); | 
| 172 | 
  | 
        } | 
| 173 | 
< | 
        if (i >= MAXMODLIST-1) { | 
| 174 | 
< | 
                sprintf(errmsg, "too many modifiers (%d limit) in file '%s'", | 
| 175 | 
< | 
                                MAXMODLIST-1, fname); | 
| 168 | 
< | 
                error(INTERNAL, errmsg); | 
| 169 | 
< | 
        } | 
| 170 | 
< | 
        for (i = 0; mname[i]; i++)      /* add each one */ | 
| 171 | 
< | 
                addmodifier(mname[i], outf, prms, binv, bincnt); | 
| 173 | 
> | 
        while (fgetword(mod, sizeof(mod), fp) != NULL) | 
| 174 | 
> | 
                addmodifier(savqstr(mod), outf, prms, binv, bincnt); | 
| 175 | 
> | 
        fclose(fp); | 
| 176 | 
  | 
} | 
| 177 | 
  | 
 | 
| 178 | 
  | 
 |