# New Ticket Created by  "Yehoshua Sapir" 
# Please include the string:  [perl #42558]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42558 >


Without this patch, for runtime/parrot/library/config.pir to work, parrot
has to be run in its root directory (in fact, there was an XXX note in there
saying so.)

I changed Parrot_get_runtime_prefix not to return a const value because the
value should be free'd later on.

Also, here's an example PIR file to demonstrate.
Index: runtime/parrot/library/config.pir
===================================================================
--- runtime/parrot/library/config.pir	(revision 18237)
+++ runtime/parrot/library/config.pir	(working copy)
@@ -43,10 +43,13 @@
 
 =cut
 
+.include "interpinfo.pasm"
+
 .pcc_sub _config
     .local pmc CONF
-    # XXX: this works only if parrot is run from its root directory
-    .const string conf_file = "runtime/parrot/include/config.fpmc"
+    .local string conf_file
+    conf_file = interpinfo .INTERPINFO_RUNTIME_PREFIX
+    conf_file .= "/runtime/parrot/include/config.fpmc"
 
     open CONF, conf_file, "<"
     $I0 = defined CONF
Index: src/ops/core.ops
===================================================================
--- src/ops/core.ops	(revision 18237)
+++ src/ops/core.ops	(working copy)
@@ -881,7 +881,7 @@
 
 =item B<interpinfo>(out STR, in INT)
 
-.EXECUTABLE_FULLNAME, .EXECUTABLE_BASENAME
+.EXECUTABLE_FULLNAME, .EXECUTABLE_BASENAME, .RUNTIME_PREFIX
 
 =back
 
Index: src/inter_misc.c
===================================================================
--- src/inter_misc.c	(revision 18237)
+++ src/inter_misc.c	(working copy)
@@ -333,6 +333,12 @@
             mem_sys_free(fullname_c);
             return basename;
 
+        case RUNTIME_PREFIX:
+            fullname_c = Parrot_get_runtime_prefix(interp, NULL);
+            fullname = string_from_cstring(interp, fullname_c, 0);
+            mem_sys_free(fullname_c);
+            return fullname;
+
         default:        /* or a warning only? */
             internal_exception(UNIMPLEMENTED,
                     "illegal argument in interpinfo");
Index: src/library.c
===================================================================
--- src/library.c	(revision 18237)
+++ src/library.c	(working copy)
@@ -345,7 +345,7 @@
 }
 /*
 
-=item C<const char* Parrot_get_runtime_prefix(Interp *, STRING **prefix_str)>
+=item C<char* Parrot_get_runtime_prefix(Interp *, STRING **prefix_str)>
 
 If C<prefix_str> is not NULL, set it to the prefix, else
 return a malloced c-string for the runtime prefix.
@@ -354,7 +354,7 @@
 
 */
 
-const char*
+char*
 Parrot_get_runtime_prefix(Interp *interp, STRING **prefix_str)
 {
     STRING *s, *key;
Index: include/parrot/resources.h
===================================================================
--- include/parrot/resources.h	(revision 18237)
+++ include/parrot/resources.h	(working copy)
@@ -141,7 +141,8 @@
 
     /* interpinfo_s constants */
     EXECUTABLE_FULLNAME,
-    EXECUTABLE_BASENAME
+    EXECUTABLE_BASENAME,
+    RUNTIME_PREFIX
 } Interpinfo_enum;
 
 /* &end_gen */
Index: include/parrot/library.h
===================================================================
--- include/parrot/library.h	(revision 18237)
+++ include/parrot/library.h	(working copy)
@@ -38,7 +38,7 @@
 PARROT_API STRING* Parrot_locate_runtime_file_str(Interp *, STRING *file_name,
         enum_runtime_ft);
 
-PARROT_API const char* Parrot_get_runtime_prefix(Interp *, STRING **prefix);
+PARROT_API char* Parrot_get_runtime_prefix(Interp *, STRING **prefix);
 void parrot_init_library_paths(Interp *);
 STRING * parrot_split_path_ext(Interp* , STRING *in,
         STRING **wo_ext, STRING **ext);

Attachment: test.pir
Description: Binary data

Reply via email to