fill unsetenv for windows (#150)

* fill unsetenv

* update usage of read_string_from_wasm

* convert helper to return String

* correct usage of helper fn, cargo fmt, and check in lock file change
This commit is contained in:
Mackenzie Clark
2019-02-07 10:51:19 -08:00
committed by Lachlan Sneff
parent 663de770bf
commit ce03e4464c
3 changed files with 42 additions and 10 deletions

View File

@ -2,6 +2,7 @@ use super::env;
use super::env::get_emscripten_data;
use libc::stat;
use std::ffi::CStr;
use std::ffi::CString;
use std::mem::size_of;
use std::os::raw::c_char;
use std::os::raw::c_int;
@ -158,11 +159,12 @@ pub unsafe fn copy_stat_into_wasm(ctx: &mut Ctx, buf: u32, stat: &stat) {
}
pub fn read_string_from_wasm(memory: &Memory, offset: u32) -> String {
memory.view::<u8>()[(offset as usize)..]
let v: Vec<u8> = memory.view()[(offset as usize)..]
.iter()
.take_while(|cell| cell.get() != 0)
.map(|cell| cell.get() as char)
.collect()
.map(|cell| cell.get())
.take_while(|&byte| byte != 0)
.collect();
String::from_utf8_lossy(&v).to_owned().to_string()
}
#[cfg(test)]