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 "rterror.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 |
> |
extern int |
22 |
> |
fgetid( /* read an id up to char in dls from fp */ |
23 |
> |
ID *idp, |
24 |
> |
char *dls, |
25 |
> |
register FILE *fp |
26 |
> |
) |
27 |
|
{ |
28 |
|
char dset[256/8]; |
29 |
|
char buf[MAXSTR]; |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
< |
int |
70 |
< |
findid(idl, idp, insert) /* find (or insert) id in list */ |
71 |
< |
register IDLIST *idl; |
72 |
< |
ID *idp; |
73 |
< |
int insert; |
69 |
> |
extern int |
70 |
> |
findid( /* find (or insert) id in list */ |
71 |
> |
register IDLIST *idl, |
72 |
> |
ID *idp, |
73 |
> |
int insert |
74 |
> |
) |
75 |
|
{ |
76 |
|
int upper, lower; |
77 |
|
register int cm, i; |
95 |
|
if (idl->id == NULL) |
96 |
|
goto memerr; |
97 |
|
} else { /* grow old list */ |
98 |
< |
idl->id = (ID *)realloc((char *)idl->id,(idl->nids+1)*sizeof(ID)); |
98 |
> |
idl->id = (ID *)realloc((void *)idl->id,(idl->nids+1)*sizeof(ID)); |
99 |
|
if (idl->id == NULL) |
100 |
|
goto memerr; |
101 |
|
for (i = idl->nids; i > upper; i--) { |
113 |
|
memerr: |
114 |
|
eputs("Out of memory in findid\n"); |
115 |
|
quit(1); |
116 |
+ |
return -1; /* pro forma return */ |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
< |
int |
121 |
< |
idcmp(id1, id2) /* compare two identifiers */ |
122 |
< |
register ID *id1, *id2; |
120 |
> |
static int |
121 |
> |
idcmp( /* compare two identifiers */ |
122 |
> |
register ID *id1, |
123 |
> |
register ID *id2 |
124 |
> |
) |
125 |
|
{ |
126 |
|
/* names are greater than numbers */ |
127 |
|
if (id1->name == NULL) |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
< |
write_quals(qlp, idl, fp) /* write out qualifier lists */ |
141 |
< |
QLIST *qlp; |
142 |
< |
IDLIST idl[]; |
143 |
< |
FILE *fp; |
140 |
> |
extern void |
141 |
> |
write_quals( /* write out qualifier lists */ |
142 |
> |
QLIST *qlp, |
143 |
> |
IDLIST idl[], |
144 |
> |
FILE *fp |
145 |
> |
) |
146 |
|
{ |
147 |
|
int i; |
148 |
|
|
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
< |
fputidlist(qp, fp) /* put id list out to fp */ |
159 |
< |
IDLIST *qp; |
160 |
< |
FILE *fp; |
158 |
> |
static void |
159 |
> |
fputidlist( /* put id list out to fp */ |
160 |
> |
IDLIST *qp, |
161 |
> |
FILE *fp |
162 |
> |
) |
163 |
|
{ |
164 |
|
int fi; |
165 |
|
register int i; |
185 |
|
|
186 |
|
|
187 |
|
RULEHD * |
188 |
< |
getmapping(file, qlp) /* read in mapping file */ |
189 |
< |
char *file; |
190 |
< |
QLIST *qlp; |
188 |
> |
getmapping( /* read in mapping file */ |
189 |
> |
char *file, |
190 |
> |
QLIST *qlp |
191 |
> |
) |
192 |
|
{ |
193 |
|
char *err; |
194 |
|
register int c; |
280 |
|
memerr: |
281 |
|
eputs("Out of memory in getmapping\n"); |
282 |
|
quit(1); |
283 |
+ |
return NULL; /* pro forma return */ |
284 |
|
} |
285 |
|
|
286 |
|
|
287 |
< |
int |
288 |
< |
qtype(qnm, qlp) /* return number for qualifier name */ |
289 |
< |
char *qnm; |
290 |
< |
register QLIST *qlp; |
287 |
> |
static int |
288 |
> |
qtype( /* return number for qualifier name */ |
289 |
> |
char *qnm, |
290 |
> |
register QLIST *qlp |
291 |
> |
) |
292 |
|
{ |
293 |
|
register int i; |
294 |
|
|
299 |
|
} |
300 |
|
|
301 |
|
|
302 |
< |
matchid(it, im) /* see if we match an id */ |
303 |
< |
register ID *it; |
304 |
< |
register IDMATCH *im; |
302 |
> |
extern int |
303 |
> |
matchid( /* see if we match an id */ |
304 |
> |
register ID *it, |
305 |
> |
register IDMATCH *im |
306 |
> |
) |
307 |
|
{ |
308 |
|
if (it->name == NULL) { |
309 |
|
if (im->nam != NULL) |