Skip to content

Fix argument handling on Redox #38626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/libstd/sys/redox/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ impl DoubleEndedIterator for Args {
mod imp {
use os::unix::prelude::*;
use mem;
use ffi::OsString;
use ffi::{CStr, OsString};
use marker::PhantomData;
use slice;
use str;
use libc;
use super::Args;

use sys_common::mutex::Mutex;
Expand All @@ -64,12 +63,9 @@ mod imp {
static LOCK: Mutex = Mutex::new();

pub unsafe fn init(argc: isize, argv: *const *const u8) {
let mut args: Vec<Vec<u8>> = Vec::new();
for i in 0..argc {
let len = *(argv.offset(i * 2)) as usize;
let ptr = *(argv.offset(i * 2 + 1));
args.push(slice::from_raw_parts(ptr, len).to_vec());
}
let args = (0..argc).map(|i| {
CStr::from_ptr(*argv.offset(i) as *const libc::c_char).to_bytes().to_vec()
}).collect();

LOCK.lock();
let ptr = get_global_ptr();
Expand Down