FreeCalypso > hg > freecalypso-reveng
comparison blobstat/grokmap.c @ 294:ff2a6433687f
blobstat: code finished, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 21 Sep 2019 21:17:29 +0000 |
parents | 23e5b940cb8b |
children | 99f72069d867 |
comparison
equal
deleted
inserted
replaced
293:23e5b940cb8b | 294:ff2a6433687f |
---|---|
27 } | 27 } |
28 return(0); | 28 return(0); |
29 } | 29 } |
30 | 30 |
31 static void | 31 static void |
32 getline() | 32 get_line() |
33 { | 33 { |
34 char *cp; | 34 char *cp; |
35 | 35 |
36 if (!fgets(linebuf, sizeof linebuf, mapfile)) { | 36 if (!fgets(linebuf, sizeof linebuf, mapfile)) { |
37 fprintf(stderr, "%s: premature EOF\n", filename_for_errs); | 37 fprintf(stderr, "%s: premature EOF\n", filename_for_errs); |
131 int c, i; | 131 int c, i; |
132 int uninit; | 132 int uninit; |
133 char libname[1024], *member; | 133 char libname[1024], *member; |
134 struct category *cat; | 134 struct category *cat; |
135 | 135 |
136 getline(); | 136 get_line(); |
137 if (!linebuf[0]) | 137 if (!linebuf[0]) |
138 return(1); | 138 return(1); |
139 if (!valid_section_name_char(linebuf[0], 1)) { | 139 if (!valid_section_name_char(linebuf[0], 1)) { |
140 inv_outsec_line: | 140 inv_outsec_line: |
141 fprintf(stderr, | 141 fprintf(stderr, |
151 goto inv_outsec_line; | 151 goto inv_outsec_line; |
152 } | 152 } |
153 if (!c) { | 153 if (!c) { |
154 if (i < 8) | 154 if (i < 8) |
155 goto inv_outsec_line; | 155 goto inv_outsec_line; |
156 getline(); | 156 get_line(); |
157 for (i = 0; i < 8; i++) | 157 for (i = 0; i < 8; i++) |
158 if (linebuf[i] != ' ') | 158 if (linebuf[i] != ' ') |
159 goto inv_outsec_line; | 159 goto inv_outsec_line; |
160 } else { | 160 } else { |
161 if (i > 7) | 161 if (i > 7) |
183 goto inv_outsec_line; | 183 goto inv_outsec_line; |
184 uninit = !strcmp(linebuf + 38, "UNINITIALIZED"); | 184 uninit = !strcmp(linebuf + 38, "UNINITIALIZED"); |
185 /* input section lines */ | 185 /* input section lines */ |
186 libname[0] = '\0'; | 186 libname[0] = '\0'; |
187 for (;;) { | 187 for (;;) { |
188 getline(); | 188 get_line(); |
189 if (!linebuf[0]) | 189 if (!linebuf[0]) |
190 break; | 190 break; |
191 if (!parse_input_section_line(libname, &member)) | 191 if (!parse_input_section_line(libname, &member)) |
192 continue; | 192 continue; |
193 if (!libname[0]) { | 193 if (!libname[0]) { |
215 if (!mapfile) { | 215 if (!mapfile) { |
216 perror(filename); | 216 perror(filename); |
217 exit(1); | 217 exit(1); |
218 } | 218 } |
219 do | 219 do |
220 getline(); | 220 get_line(); |
221 while (strcmp(linebuf, "SECTION ALLOCATION MAP")); | 221 while (strcmp(linebuf, "SECTION ALLOCATION MAP")); |
222 /* 4 fixed info lines */ | 222 /* 4 fixed info lines */ |
223 getline(); | 223 get_line(); |
224 if (linebuf[0]) { | 224 if (linebuf[0]) { |
225 bad_sectionmap_hdr: | 225 bad_sectionmap_hdr: |
226 fprintf(stderr, | 226 fprintf(stderr, |
227 "%s line %d: wrong lines after SECTION ALLOCATION MAP\n", | 227 "%s line %d: wrong lines after SECTION ALLOCATION MAP\n", |
228 filename_for_errs, lineno); | 228 filename_for_errs, lineno); |
229 exit(1); | 229 exit(1); |
230 } | 230 } |
231 getline(); | 231 get_line(); |
232 if (strcmp(linebuf, | 232 if (strcmp(linebuf, |
233 " output attributes/")) | 233 " output attributes/")) |
234 goto bad_sectionmap_hdr; | 234 goto bad_sectionmap_hdr; |
235 getline(); | 235 get_line(); |
236 if (strcmp(linebuf, | 236 if (strcmp(linebuf, |
237 "section page origin length input sections")) | 237 "section page origin length input sections")) |
238 goto bad_sectionmap_hdr; | 238 goto bad_sectionmap_hdr; |
239 getline(); | 239 get_line(); |
240 if (strcmp(linebuf, | 240 if (strcmp(linebuf, |
241 "-------- ---- ---------- ---------- ----------------")) | 241 "-------- ---- ---------- ---------- ----------------")) |
242 goto bad_sectionmap_hdr; | 242 goto bad_sectionmap_hdr; |
243 while (!process_output_section()) | 243 while (!process_output_section()) |
244 ; | 244 ; |