comparison lwasm/input.c @ 356:7166254491ed

Finished pseudo ops
author lost@starbug
date Wed, 31 Mar 2010 18:46:32 -0600
parents 67224d8d1024
children 38b50ce6967a
comparison
equal deleted inserted replaced
355:981e34165e97 356:7166254491ed
211 } 211 }
212 212
213 lw_error("Cannot figure out how to open '%s'.", t -> filespec); 213 lw_error("Cannot figure out how to open '%s'.", t -> filespec);
214 } 214 }
215 215
216 FILE *input_open_standalone(asmstate_t *as, char *s)
217 {
218 char *s2;
219 FILE *fp;
220 char *p, *p2;
221
222 /* first check for absolute path and if so, skip path */
223 if (*s == '/')
224 {
225 /* absolute path */
226 fp = fopen(s, "rb");
227 if (!fp)
228 {
229 return NULL;
230 }
231 return fp;
232 }
233
234 /* relative path, check relative to "current file" directory */
235 p = lw_stack_top(as -> file_dir);
236 0 == asprintf(&p2, "%s/%s", p, s);
237 fp = fopen(p2, "rb");
238 if (fp)
239 {
240 lw_free(p2);
241 return fp;
242 }
243 lw_free(p2);
244
245 /* now check relative to entries in the search path */
246 lw_stringlist_reset(as -> include_list);
247 while (p = lw_stringlist_current(as -> include_list))
248 {
249 0 == asprintf(&p2, "%s/%s", p, s);
250 fp = fopen(p2, "rb");
251 if (fp)
252 {
253 lw_free(p2);
254 return fp;
255 }
256 lw_free(p2);
257 lw_stringlist_next(as -> include_list);
258 }
259
260 return NULL;
261 }
262
216 char *input_readline(asmstate_t *as) 263 char *input_readline(asmstate_t *as)
217 { 264 {
218 char *s; 265 char *s;
219 char linebuff[2049]; 266 char linebuff[2049];
220 int lbloc; 267 int lbloc;