| 1 |
– |
/* Copyright (c) 1990 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* Translator utilities |
| 6 |
|
* |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
|
#include <stdio.h> |
| 11 |
+ |
#include <stdlib.h> |
| 12 |
+ |
#include <string.h> |
| 13 |
|
|
| 14 |
+ |
#include "standard.h" |
| 15 |
|
#include "trans.h" |
| 16 |
|
|
| 17 |
+ |
static int idcmp(ID *id1, ID *id2); |
| 18 |
+ |
static void fputidlist(IDLIST *qp, FILE *fp); |
| 19 |
+ |
static int qtype(char *qnm, register QLIST *qlp); |
| 20 |
|
|
| 21 |
< |
fgetid(idp, dls, fp) /* read an id up to char in dls from fp */ |
| 22 |
< |
ID *idp; |
| 23 |
< |
char *dls; |
| 24 |
< |
register FILE *fp; |
| 21 |
> |
fgetid( /* read an id up to char in dls from fp */ |
| 22 |
> |
ID *idp, |
| 23 |
> |
char *dls, |
| 24 |
> |
register FILE *fp |
| 25 |
> |
) |
| 26 |
|
{ |
| 27 |
|
char dset[256/8]; |
| 28 |
|
char buf[MAXSTR]; |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
int |
| 69 |
< |
findid(idl, idp, insert) /* find (or insert) id in list */ |
| 70 |
< |
register IDLIST *idl; |
| 71 |
< |
ID *idp; |
| 72 |
< |
int insert; |
| 69 |
> |
findid( /* find (or insert) id in list */ |
| 70 |
> |
register IDLIST *idl, |
| 71 |
> |
ID *idp, |
| 72 |
> |
int insert |
| 73 |
> |
) |
| 74 |
|
{ |
| 75 |
|
int upper, lower; |
| 76 |
|
register int cm, i; |
| 94 |
|
if (idl->id == NULL) |
| 95 |
|
goto memerr; |
| 96 |
|
} else { /* grow old list */ |
| 97 |
< |
idl->id = (ID *)realloc((char *)idl->id,(idl->nids+1)*sizeof(ID)); |
| 97 |
> |
idl->id = (ID *)realloc((void *)idl->id,(idl->nids+1)*sizeof(ID)); |
| 98 |
|
if (idl->id == NULL) |
| 99 |
|
goto memerr; |
| 100 |
|
for (i = idl->nids; i > upper; i--) { |
| 112 |
|
memerr: |
| 113 |
|
eputs("Out of memory in findid\n"); |
| 114 |
|
quit(1); |
| 115 |
+ |
return -1; /* pro forma return */ |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
|
| 119 |
< |
int |
| 120 |
< |
idcmp(id1, id2) /* compare two identifiers */ |
| 121 |
< |
register ID *id1, *id2; |
| 119 |
> |
static int |
| 120 |
> |
idcmp( /* compare two identifiers */ |
| 121 |
> |
register ID *id1, |
| 122 |
> |
register ID *id2 |
| 123 |
> |
) |
| 124 |
|
{ |
| 125 |
|
/* names are greater than numbers */ |
| 126 |
|
if (id1->name == NULL) |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
|
| 139 |
< |
write_quals(qlp, idl, fp) /* write out qualifier lists */ |
| 140 |
< |
QLIST *qlp; |
| 141 |
< |
IDLIST idl[]; |
| 142 |
< |
FILE *fp; |
| 139 |
> |
void |
| 140 |
> |
write_quals( /* write out qualifier lists */ |
| 141 |
> |
QLIST *qlp, |
| 142 |
> |
IDLIST idl[], |
| 143 |
> |
FILE *fp |
| 144 |
> |
) |
| 145 |
|
{ |
| 146 |
|
int i; |
| 147 |
|
|
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
|
| 157 |
< |
fputidlist(qp, fp) /* put id list out to fp */ |
| 158 |
< |
IDLIST *qp; |
| 159 |
< |
FILE *fp; |
| 157 |
> |
static void |
| 158 |
> |
fputidlist( /* put id list out to fp */ |
| 159 |
> |
IDLIST *qp, |
| 160 |
> |
FILE *fp |
| 161 |
> |
) |
| 162 |
|
{ |
| 163 |
|
int fi; |
| 164 |
|
register int i; |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
RULEHD * |
| 187 |
< |
getmapping(file, qlp) /* read in mapping file */ |
| 188 |
< |
char *file; |
| 189 |
< |
QLIST *qlp; |
| 187 |
> |
getmapping( /* read in mapping file */ |
| 188 |
> |
char *file, |
| 189 |
> |
QLIST *qlp |
| 190 |
> |
) |
| 191 |
|
{ |
| 192 |
|
char *err; |
| 193 |
|
register int c; |
| 279 |
|
memerr: |
| 280 |
|
eputs("Out of memory in getmapping\n"); |
| 281 |
|
quit(1); |
| 282 |
+ |
return NULL; /* pro forma return */ |
| 283 |
|
} |
| 284 |
|
|
| 285 |
|
|
| 286 |
< |
int |
| 287 |
< |
qtype(qnm, qlp) /* return number for qualifier name */ |
| 288 |
< |
char *qnm; |
| 289 |
< |
register QLIST *qlp; |
| 286 |
> |
static int |
| 287 |
> |
qtype( /* return number for qualifier name */ |
| 288 |
> |
char *qnm, |
| 289 |
> |
register QLIST *qlp |
| 290 |
> |
) |
| 291 |
|
{ |
| 292 |
|
register int i; |
| 293 |
|
|
| 298 |
|
} |
| 299 |
|
|
| 300 |
|
|
| 301 |
< |
matchid(it, im) /* see if we match an id */ |
| 302 |
< |
register ID *it; |
| 303 |
< |
register IDMATCH *im; |
| 301 |
> |
int |
| 302 |
> |
matchid( /* see if we match an id */ |
| 303 |
> |
register ID *it, |
| 304 |
> |
register IDMATCH *im |
| 305 |
> |
) |
| 306 |
|
{ |
| 307 |
|
if (it->name == NULL) { |
| 308 |
|
if (im->nam != NULL) |