Mercurial > hg > index.cgi
comparison lwasm/input.c @ 2:7317fbe024af
Clean up insane number of compiler warnings under -Wall
author | lost@l-w.ca |
---|---|
date | Thu, 20 Jan 2011 22:39:46 -0700 |
parents | 2c24602be78f |
children | 127e5b1e01c0 |
comparison
equal
deleted
inserted
replaced
1:96c4dc89016e | 2:7317fbe024af |
---|---|
30 #include <string.h> | 30 #include <string.h> |
31 | 31 |
32 #include <lw_alloc.h> | 32 #include <lw_alloc.h> |
33 #include <lw_stringlist.h> | 33 #include <lw_stringlist.h> |
34 #include <lw_string.h> | 34 #include <lw_string.h> |
35 #include <lw_error.h> | |
36 | |
35 #include "lwasm.h" | 37 #include "lwasm.h" |
36 | 38 |
37 /* | 39 /* |
38 Data type for storing input buffers | 40 Data type for storing input buffers |
39 */ | 41 */ |
80 /* take apart fn into path and filename then push the path */ | 82 /* take apart fn into path and filename then push the path */ |
81 /* onto the current file path stack */ | 83 /* onto the current file path stack */ |
82 | 84 |
83 /* also add it to the list of files included */ | 85 /* also add it to the list of files included */ |
84 char *dn, *dp; | 86 char *dn, *dp; |
85 int o; | 87 // int o; |
86 | 88 |
87 dn = lw_strdup(fn); | 89 dn = lw_strdup(fn); |
88 lw_stack_push(as -> includelist, dn); | 90 lw_stack_push(as -> includelist, dn); |
89 | 91 |
90 dn = lw_strdup(fn); | 92 dn = lw_strdup(fn); |
175 return; | 177 return; |
176 } | 178 } |
177 | 179 |
178 /* relative path, check relative to "current file" directory */ | 180 /* relative path, check relative to "current file" directory */ |
179 p = lw_stack_top(as -> file_dir); | 181 p = lw_stack_top(as -> file_dir); |
180 0 == asprintf(&p2, "%s/%s", p, s); | 182 (void)(0 == asprintf(&p2, "%s/%s", p, s)); |
181 debug_message(as, 1, "Open: (cd) %s\n", p2); | 183 debug_message(as, 1, "Open: (cd) %s\n", p2); |
182 IS -> data = fopen(p2, "rb"); | 184 IS -> data = fopen(p2, "rb"); |
183 if (IS -> data) | 185 if (IS -> data) |
184 { | 186 { |
185 input_pushpath(as, p2); | 187 input_pushpath(as, p2); |
189 debug_message(as, 2, "Failed to open: (cd) %s (%s)\n", p2, strerror(errno)); | 191 debug_message(as, 2, "Failed to open: (cd) %s (%s)\n", p2, strerror(errno)); |
190 lw_free(p2); | 192 lw_free(p2); |
191 | 193 |
192 /* now check relative to entries in the search path */ | 194 /* now check relative to entries in the search path */ |
193 lw_stringlist_reset(as -> include_list); | 195 lw_stringlist_reset(as -> include_list); |
194 while (p = lw_stringlist_current(as -> include_list)) | 196 while ((p = lw_stringlist_current(as -> include_list))) |
195 { | 197 { |
196 0 == asprintf(&p2, "%s/%s", p, s); | 198 (void)(0 == asprintf(&p2, "%s/%s", p, s)); |
197 debug_message(as, 1, "Open (sp): %s\n", p2); | 199 debug_message(as, 1, "Open (sp): %s\n", p2); |
198 IS -> data = fopen(p2, "rb"); | 200 IS -> data = fopen(p2, "rb"); |
199 if (IS -> data) | 201 if (IS -> data) |
200 { | 202 { |
201 input_pushpath(as, p2); | 203 input_pushpath(as, p2); |
224 lw_error("Cannot figure out how to open '%s'.", t -> filespec); | 226 lw_error("Cannot figure out how to open '%s'.", t -> filespec); |
225 } | 227 } |
226 | 228 |
227 FILE *input_open_standalone(asmstate_t *as, char *s) | 229 FILE *input_open_standalone(asmstate_t *as, char *s) |
228 { | 230 { |
229 char *s2; | 231 // char *s2; |
230 FILE *fp; | 232 FILE *fp; |
231 char *p, *p2; | 233 char *p, *p2; |
232 | 234 |
233 /* first check for absolute path and if so, skip path */ | 235 /* first check for absolute path and if so, skip path */ |
234 if (*s == '/') | 236 if (*s == '/') |
243 return fp; | 245 return fp; |
244 } | 246 } |
245 | 247 |
246 /* relative path, check relative to "current file" directory */ | 248 /* relative path, check relative to "current file" directory */ |
247 p = lw_stack_top(as -> file_dir); | 249 p = lw_stack_top(as -> file_dir); |
248 0 == asprintf(&p2, "%s/%s", p, s); | 250 (void)(0 == asprintf(&p2, "%s/%s", p, s)); |
249 debug_message(as, 2, "Open file (st cd) %s", p2); | 251 debug_message(as, 2, "Open file (st cd) %s", p2); |
250 fp = fopen(p2, "rb"); | 252 fp = fopen(p2, "rb"); |
251 if (fp) | 253 if (fp) |
252 { | 254 { |
253 lw_free(p2); | 255 lw_free(p2); |
255 } | 257 } |
256 lw_free(p2); | 258 lw_free(p2); |
257 | 259 |
258 /* now check relative to entries in the search path */ | 260 /* now check relative to entries in the search path */ |
259 lw_stringlist_reset(as -> include_list); | 261 lw_stringlist_reset(as -> include_list); |
260 while (p = lw_stringlist_current(as -> include_list)) | 262 while ((p = lw_stringlist_current(as -> include_list))) |
261 { | 263 { |
262 0 == asprintf(&p2, "%s/%s", p, s); | 264 (void)(0 == asprintf(&p2, "%s/%s", p, s)); |
263 debug_message(as, 2, "Open file (st ip) %s", p2); | 265 debug_message(as, 2, "Open file (st ip) %s", p2); |
264 fp = fopen(p2, "rb"); | 266 fp = fopen(p2, "rb"); |
265 if (fp) | 267 if (fp) |
266 { | 268 { |
267 lw_free(p2); | 269 lw_free(p2); |
400 } | 402 } |
401 } | 403 } |
402 | 404 |
403 default: | 405 default: |
404 lw_error("Problem reading from unknown input type"); | 406 lw_error("Problem reading from unknown input type"); |
407 return NULL; | |
405 } | 408 } |
406 } | 409 } |
407 | 410 |
408 char *input_curspec(asmstate_t *as) | 411 char *input_curspec(asmstate_t *as) |
409 { | 412 { |