Anyone mind if I commit this? One thing I'm not sure of, though -- I
try to behave myself and use Parrot_getenv rather than a plain
getenv(), but I'm not convinced the API is complete -- Parrot_getenv
saves back a boolean saying whether to free the returned string or
not, but what should I call to free it? I could call
Parrot_free_memalign, but who said anything about alignment? Perhaps
Parrot_getenv should simply return the string, and we should have a
platform-specific Parrot_freeenv that either frees the string or is a
no-op?

Whatever. For now, I'm just calling free() if Parrot_getenv() tells me
to. Which it probably never will.
Index: src/string.c
===================================================================
RCS file: /cvs/public/parrot/src/string.c,v
retrieving revision 1.202
diff -u -r1.202 string.c
--- src/string.c        25 May 2004 08:34:24 -0000      1.202
+++ src/string.c        30 May 2004 05:55:29 -0000
@@ -243,9 +243,18 @@
 string_init(Parrot_Interp interpreter)
 {
     size_t i;
-/* DEFAULT_ICU_DATA_DIR is configured at build time. Need a way to
-    specify this at runtime as well. */
-    string_set_data_directory(DEFAULT_ICU_DATA_DIR);
+    char *data_dir;
+    int free_data_dir = 0;
+
+    /* DEFAULT_ICU_DATA_DIR is configured at build time, or it may be
+       set through the $ICU_DATA_DIR environment variable. Need a way
+       to specify this via the command line as well. */
+    data_dir = Parrot_getenv("ICU_DATA_DIR", &free_data_dir);
+    if (data_dir == NULL)
+        data_dir = DEFAULT_ICU_DATA_DIR;
+    string_set_data_directory(data_dir);
+    if (free_data_dir)
+        free(data_dir);
 /*
     encoding_init();
     chartype_init();

Reply via email to