Author: mdiep
Date: Thu Apr 26 22:11:59 2007
New Revision: 18343

Modified:
   trunk/include/parrot/library.h
   trunk/include/parrot/resources.h
   trunk/runtime/parrot/library/config.pir
   trunk/src/inter_misc.c
   trunk/src/library.c
   trunk/src/ops/core.ops

Log:
#42558: [PATCH] add runtime_prefix for interpinfo and use it in config.pir

Courtesy Yehoshua Sapir <[EMAIL PROTECTED]>.


Modified: trunk/include/parrot/library.h
==============================================================================
--- trunk/include/parrot/library.h      (original)
+++ trunk/include/parrot/library.h      Thu Apr 26 22:11:59 2007
@@ -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);

Modified: trunk/include/parrot/resources.h
==============================================================================
--- trunk/include/parrot/resources.h    (original)
+++ trunk/include/parrot/resources.h    Thu Apr 26 22:11:59 2007
@@ -141,7 +141,8 @@
 
     /* interpinfo_s constants */
     EXECUTABLE_FULLNAME,
-    EXECUTABLE_BASENAME
+    EXECUTABLE_BASENAME,
+    RUNTIME_PREFIX
 } Interpinfo_enum;
 
 /* &end_gen */

Modified: trunk/runtime/parrot/library/config.pir
==============================================================================
--- trunk/runtime/parrot/library/config.pir     (original)
+++ trunk/runtime/parrot/library/config.pir     Thu Apr 26 22:11:59 2007
@@ -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

Modified: trunk/src/inter_misc.c
==============================================================================
--- trunk/src/inter_misc.c      (original)
+++ trunk/src/inter_misc.c      Thu Apr 26 22:11:59 2007
@@ -340,6 +340,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");

Modified: trunk/src/library.c
==============================================================================
--- trunk/src/library.c (original)
+++ trunk/src/library.c Thu Apr 26 22:11:59 2007
@@ -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.  Remember to free the string with
@@ -355,7 +355,7 @@
 
 */
 
-const char*
+char*
 Parrot_get_runtime_prefix(Interp *interp, STRING **prefix_str)
 {
     STRING *s, *key;

Modified: trunk/src/ops/core.ops
==============================================================================
--- trunk/src/ops/core.ops      (original)
+++ trunk/src/ops/core.ops      Thu Apr 26 22:11:59 2007
@@ -881,7 +881,7 @@
 
 =item B<interpinfo>(out STR, in INT)
 
-.EXECUTABLE_FULLNAME, .EXECUTABLE_BASENAME
+.EXECUTABLE_FULLNAME, .EXECUTABLE_BASENAME, .RUNTIME_PREFIX
 
 =back
 

Reply via email to