about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorJeff Olson <olson.jeffery@gmail.com>2013-02-14 22:16:53 -0800
committerBrian Anderson <banderson@mozilla.com>2013-03-11 15:38:55 -0700
commit53db6c7e2a11764a806e87c7268d31288fa9171d (patch)
treec835cfe8a43f81b6701704a8e6ad95ab2d4ae8d7 /src/rt/rust_builtin.cpp
parent4bc26ce575b4bc6f7254a2cfe9fee0a08de90b49 (diff)
downloadrust-53db6c7e2a11764a806e87c7268d31288fa9171d.tar.gz
rust-53db6c7e2a11764a806e87c7268d31288fa9171d.zip
core: rt/core: impl os::env() in rust ref #4812
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp35
1 files changed, 4 insertions, 31 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 750962b37e8..2c9c4a70681 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -53,44 +53,17 @@ timegm(struct tm *tm)
 #endif
 
 #if defined(__WIN32__)
-extern "C" CDECL rust_vec_box *
+extern "C" CDECL char**
 rust_env_pairs() {
-    rust_task *task = rust_get_current_task();
-    size_t envc = 0;
-    LPTCH ch = GetEnvironmentStringsA();
-    LPTCH c;
-    for (c = ch; *c; c += strlen(c) + 1) {
-        ++envc;
-    }
-    c = ch;
-    rust_vec_box *v = (rust_vec_box *)
-        task->kernel->malloc(vec_size<rust_vec_box*>(envc),
-                       "str vec interior");
-    v->body.fill = v->body.alloc = sizeof(rust_vec*) * envc;
-    for (size_t i = 0; i < envc; ++i) {
-        size_t n = strlen(c);
-        rust_str *str = make_str(task->kernel, c, n, "str");
-        ((rust_str**)&v->body.data)[i] = str;
-        c += n + 1;
-    }
-    if (ch) {
-        FreeEnvironmentStrings(ch);
-    }
-    return v;
+    return 0;
 }
 #else
-extern "C" CDECL rust_vec_box *
+extern "C" CDECL char**
 rust_env_pairs() {
-    rust_task *task = rust_get_current_task();
 #ifdef __APPLE__
     char **environ = *_NSGetEnviron();
 #endif
-    char **e = environ;
-    size_t envc = 0;
-    while (*e) {
-        ++envc; ++e;
-    }
-    return make_str_vec(task->kernel, envc, environ);
+    return environ;
 }
 #endif