comparison lwasm/input.c @ 392:e3567a9f0d54

Fixed problem with include path handling
author lost@l-w.ca
date Wed, 21 Jul 2010 22:21:35 -0600
parents af5f2c51db76
children
comparison
equal deleted inserted replaced
391:c1d83336e1d1 392:e3567a9f0d54
172 if (!IS -> data) 172 if (!IS -> data)
173 { 173 {
174 lw_error("Cannot open file '%s': %s", s, strerror(errno)); 174 lw_error("Cannot open file '%s': %s", s, strerror(errno));
175 } 175 }
176 input_pushpath(as, s); 176 input_pushpath(as, s);
177 break; 177 return;
178 } 178 }
179 179
180 /* relative path, check relative to "current file" directory */ 180 /* relative path, check relative to "current file" directory */
181 p = lw_stack_top(as -> file_dir); 181 p = lw_stack_top(as -> file_dir);
182 0 == asprintf(&p2, "%s/%s", p, s); 182 0 == asprintf(&p2, "%s/%s", p, s);
184 IS -> data = fopen(p2, "rb"); 184 IS -> data = fopen(p2, "rb");
185 if (IS -> data) 185 if (IS -> data)
186 { 186 {
187 input_pushpath(as, p2); 187 input_pushpath(as, p2);
188 lw_free(p2); 188 lw_free(p2);
189 break; 189 return;
190 } 190 }
191 debug_message(as, 2, "Failed to open: (cd) %s (%s)\n", p2, strerror(errno));
191 lw_free(p2); 192 lw_free(p2);
192 193
193 /* now check relative to entries in the search path */ 194 /* now check relative to entries in the search path */
194 lw_stringlist_reset(as -> include_list); 195 lw_stringlist_reset(as -> include_list);
195 while (p = lw_stringlist_current(as -> include_list)) 196 while (p = lw_stringlist_current(as -> include_list))
201 { 202 {
202 input_pushpath(as, p2); 203 input_pushpath(as, p2);
203 lw_free(p2); 204 lw_free(p2);
204 return; 205 return;
205 } 206 }
207 debug_message(as, 2, "Failed to open: (sp) %s (%s)\n", p2, strerror(errno));
206 lw_free(p2); 208 lw_free(p2);
207 lw_stringlist_next(as -> include_list); 209 lw_stringlist_next(as -> include_list);
208 } 210 }
209 lw_error("Cannot open include file '%s': %s", s, strerror(errno)); 211 lw_error("Cannot open include file '%s': %s", s, strerror(errno));
212 break;
210 213
211 case input_type_file: 214 case input_type_file:
212 debug_message(as, 1, "Opening (reg): %s\n", s); 215 debug_message(as, 1, "Opening (reg): %s\n", s);
213 IS -> data = fopen(s, "rb"); 216 IS -> data = fopen(s, "rb");
214 217