On Sun, 06 May 2007 07:52:04 -0700 "Paul Cochrane via RT" <[EMAIL PROTECTED]> wrote:
> Matt, > > This patch actually broke stuff and was reverted shortly before > Parrot 0.4.10. It needs to be reapplied, and then checked that it > doesn't break anything (IIRC there were problems on Win32), hence why > the ticket is still open. I've only just returned from 3 weeks > overseas and haven't had time over the past couple of months to > attack the ticket. If you have the tuits, go for it! other than > that, I'll have a go at it hopefully sometime soon (famous last > words...) I noticed that the patch was generated before I had turned off the tabs in my editor. I have rebased the patch against 18443 and double checked it for any tab issues. passed full test harness on i686-pc-gnu-linux. > Paul > > > I'd like to get this ticket (#41908) resolved. The patch was > > applied, so everything is good > > there, but your reply here has left me wondering. If there is more > > to be done, could you open > > another ticket? > > > > It's better to split off new requests/bugs into new tickets rather > > than keep them in the patch > > ticket because it cuts down the amount of reading that needs to be > > done when sorting > > through tickets. The patch itself doesn't seem that relevant that it > > couldn't be a separate > > ticket. > > > Thanks. > > > > -- > > Matt Diephouse > > > > >
--- HEAD/src/library.c 2007-05-06 17:58:47.000000000 -0700
+++ rev-18443/src/library.c 2007-05-06 18:32:18.000000000 -0700
@@ -257,6 +257,78 @@
return join;
}
+#define LOAD_EXT_CODE_LAST 3
+
+static const char* load_ext_code[ LOAD_EXT_CODE_LAST + 1 ] = {
+ ".pbc",
+
+ /* source level files */
+
+ ".pasm",
+ ".past",
+ ".pir",
+};
+
+static STRING*
+try_load_path(Interp *interp, STRING* path) {
+ STRING *final;
+
+ final = string_copy(interp, path);
+
+#if 0
+ printf("path is \"%s\"\n",
+ string_to_cstring(interp, final ));
+#endif
+
+ final = path_finalize(interp, final );
+
+ if (Parrot_stat_info_intval(interp, final , STAT_EXISTS)) {
+ return final;
+ }
+
+ return NULL;
+}
+
+/*
+ guess extensions, so that the user can drop the extensions
+ leaving it up to the build process/install wether or not
+ a .pbc or a .pir file is used.
+ */
+
+static STRING*
+try_bytecode_extensions (Interp *interp, STRING* path )
+{
+ STRING *with_ext, *result;
+
+ int guess;
+
+ /*
+ first try the path without guessing ensure compatability with existing code.
+ */
+
+ with_ext = string_copy(interp, path);
+
+ if ( (result = try_load_path(interp, with_ext) ) )
+ return result;
+
+ /*
+ start guessing now. this version tries to find the lowest form of the
+ code, starting with bytecode and working up to PIR. note the atypical
+ loop control. This is so the array can easily be processed in reverse.
+ */
+
+ for( guess = 0 ; guess <= LOAD_EXT_CODE_LAST ; guess++ ) {
+ with_ext = string_copy(interp, path);
+ with_ext = string_append(interp,
+ with_ext, const_string(interp, load_ext_code[guess]));
+
+ if ( (result = try_load_path(interp, with_ext)) )
+ return result;
+ }
+
+ return NULL;
+}
+
/*
=item C<char* Parrot_locate_runtime_file(Interp *, const char *file_name,
@@ -289,6 +361,11 @@
INTVAL i, n;
PMC *paths;
+#if 0
+ printf("requesting path: \"%s\"\n",
+ string_to_cstring(interp, file ));
+#endif
+
/* if this is an absolute path return it as is */
if (is_abs_path(interp, file))
return file;
@@ -311,18 +388,22 @@
else
full_name = string_copy(interp, path);
- full_name = path_append(interp, full_name , file);
+ full_name = path_append(interp, full_name , file );
- full_name = path_finalize(interp, full_name);
- if (Parrot_stat_info_intval(interp, full_name, STAT_EXISTS)) {
+ full_name = ( type & PARROT_RUNTIME_FT_DYNEXT )
+ ? try_load_path(interp, full_name )
+ : try_bytecode_extensions(interp, full_name );
+
+ if ( full_name )
return full_name;
- }
}
- full_name = path_finalize(interp, file);
- if (Parrot_stat_info_intval(interp, full_name, STAT_EXISTS)) {
- return full_name;
- }
+ full_name = ( type & PARROT_RUNTIME_FT_DYNEXT )
+ ? try_load_path(interp, file )
+ : try_bytecode_extensions(interp, file );
+
+ if ( full_name )
+ return full_name;
return NULL;
}
signature.asc
Description: PGP signature
