Skip to content

Commit

Permalink
Remove automagic fallback behavior where alternate file extensions ar…
Browse files Browse the repository at this point in the history
…e tested if the requested one did not exist
  • Loading branch information
Whiteknight committed Mar 15, 2012
1 parent 3787eed commit 98d1232
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 54 deletions.
55 changes: 2 additions & 53 deletions src/library.c
Expand Up @@ -495,9 +495,8 @@ try_load_path(PARROT_INTERP, ARGIN(STRING* path))
path = cnv_to_win32_filesep(interp, path);
#endif

if (Parrot_file_stat_intval(interp, path, STAT_EXISTS)) {
if (Parrot_file_stat_intval(interp, path, STAT_EXISTS))
return path;
}

return NULL;
}
Expand All @@ -521,64 +520,14 @@ try_bytecode_extensions(PARROT_INTERP, ARGIN(STRING* path))
{
ASSERT_ARGS(try_bytecode_extensions)
STRING *test_path, *result;
STRING * const bytecode_extension = CONST_STRING(interp, ".pbc");
STRING * const pir_extension = CONST_STRING(interp, ".pir");
STRING * const pasm_extension = CONST_STRING(interp, ".pasm");
/* STRING * const bytecode_extension = CONST_STRING(interp, ".pbc"); */

test_path = path;

/* First try the path as given. */
result = try_load_path(interp, test_path);
if (result)
return result;

/*
If the original requested file doesn't exist, try it with a
different extension. A requested PIR or PASM file will check for a
corresponding bytecode file. A requested bytecode file will check
first for a corresponding PIR file, then for a PASM file.
*/

if (!STRING_IS_NULL(test_path)) {
if (STRING_length(test_path) > 4) {
STRING * const orig_ext = STRING_substr(interp, test_path, -4, 4);
/* First try substituting .pbc for the .pir extension */
if (STRING_equal(interp, orig_ext, pir_extension)) {
STRING * const without_ext = Parrot_str_chopn(interp, test_path, 4);
test_path = Parrot_str_concat(interp, without_ext, bytecode_extension);
result = try_load_path(interp, test_path);
if (result)
return result;
}
/* Next try substituting .pir, then .pasm for the .pbc extension */
else if (STRING_equal(interp, orig_ext, bytecode_extension)) {
STRING * const without_ext = Parrot_str_chopn(interp, test_path, 4);
test_path = Parrot_str_concat(interp, without_ext, pir_extension);
result = try_load_path(interp, test_path);
if (result)
return result;

test_path = Parrot_str_concat(interp, without_ext, pasm_extension);
result = try_load_path(interp, test_path);
if (result)
return result;
}

}

/* Finally, try substituting .pbc for the .pasm extension. */
if (STRING_length(test_path) > 5) {
STRING * const orig_ext = STRING_substr(interp, test_path, -5, 5);
if (STRING_equal(interp, orig_ext, pasm_extension)) {
STRING * const without_ext = Parrot_str_chopn(interp, test_path, 5);
test_path = Parrot_str_concat(interp, without_ext, bytecode_extension);
result = try_load_path(interp, test_path);
if (result)
return result;
}
}
}

return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion t/compilers/imcc/syn/errors.t
Expand Up @@ -92,7 +92,7 @@ pir_error_output_like( <<'END_PIR', <<'END_EXPECTED', 'warn about failing .loadl
say "WTF"
.end
END_PIR
/error:imcc:tag('load')lib.*nosuch/
/error:imcc:loadlib.*nosuch/
END_EXPECTED

pir_error_output_like( <<'CODE', <<'OUTPUT', "Multi-stage rethrows produce an informative backtrace");
Expand Down

0 comments on commit 98d1232

Please sign in to comment.