forked from bonsai/harakit
		
	getopt.rs(3): better Opt return
This commit is contained in:
		
							parent
							
								
									d1b77d652b
								
							
						
					
					
						commit
						78eacd660a
					
				| @ -21,7 +21,6 @@ use std::ffi::{ c_int, c_char, CString, CStr }; | ||||
| pub struct Opt { | ||||
| 	pub arg: Option<String>, | ||||
| 	pub ind: i32, | ||||
| 	/* opt is set to either the current option or the one that cause an error */ | ||||
| 	pub opt: String, | ||||
| } | ||||
| 
 | ||||
| @ -51,8 +50,8 @@ impl GetOpt for Vec<String> { | ||||
|         let opts = CString::new(optstring).unwrap().into_raw(); | ||||
|         let len = self.len() as c_int; | ||||
| 
 | ||||
|         unsafe { | ||||
|             match getopt(len, argv_ptr, opts) { | ||||
|         unsafe { // TODO: enable optind modification
 | ||||
|             match getopt(len, argv_ptr, opts) { 
 | ||||
| 				/* From getopt(3p):
 | ||||
| 				 * | ||||
| 				 * The getopt() function shall return the next option character | ||||
| @ -95,9 +94,9 @@ impl GetOpt for Vec<String> { | ||||
| 						.into_owned(); | ||||
| 
 | ||||
| 					Some(Ok(Opt { | ||||
| 						arg: Some(arg), | ||||
| 						ind: optind, | ||||
| 						opt: opt.to_string(), | ||||
| 						arg: Some(arg), /* opt argument */ | ||||
| 						ind: optind, /* opt index */ | ||||
| 						opt: opt.to_string(), /* option itself */ | ||||
| 					})) | ||||
| 				}, | ||||
|             } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user