getopt.rs(3): formatting
This commit is contained in:
parent
ad92fe27d4
commit
95927ba8c5
@ -29,7 +29,7 @@ pub enum OptError {
|
||||
UnknownOpt,
|
||||
}
|
||||
|
||||
// Function signature
|
||||
/* function signature */
|
||||
pub trait GetOpt {
|
||||
fn getopt(&self, optstring: &str) -> Option<Result<Opt, OptError>>;
|
||||
}
|
||||
@ -43,10 +43,11 @@ impl GetOpt for Vec<String> {
|
||||
.map(Result::unwrap)
|
||||
.collect();
|
||||
|
||||
/* these operations must be separated out into separate operations so
|
||||
* the CStrings can live long enough */
|
||||
let argv: Vec<_> = c_strings.iter().map(|x| x.as_ptr()).collect();
|
||||
let argv_ptr = argv.as_ptr() as *const *mut c_char;
|
||||
let optstring_c = CString::new(optstring).unwrap();
|
||||
let opts = optstring_c.into_raw();
|
||||
let opts = CString::new(optstring).unwrap().into_raw();
|
||||
let len = self.len() as c_int;
|
||||
|
||||
unsafe {
|
||||
@ -67,10 +68,10 @@ impl GetOpt for Vec<String> {
|
||||
*
|
||||
* Otherwise, getopt() shall return -1 when all command line
|
||||
* options are parsed. */
|
||||
58 => { /* ASCII value for ':' */
|
||||
58 => { /* numerical ASCII value for ':' */
|
||||
return Some(Err(OptError::MissingArg));
|
||||
},
|
||||
63 => { /* ASCII value for '?' */
|
||||
63 => { /* numerical ASCII value for '?' */
|
||||
return Some(Err(OptError::UnknownOpt))
|
||||
},
|
||||
/* From getopt(3p):
|
||||
|
Loading…
Reference in New Issue
Block a user