remove superfluous code
This commit is contained in:
		
							parent
							
								
									1e0682390d
								
							
						
					
					
						commit
						bf07460e53
					
				
							
								
								
									
										5
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -34,6 +34,11 @@ name = "coreutils" | |||||||
| version = "0.0.1" | version = "0.0.1" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "arg 0.1.0", |  "arg 0.1.0", | ||||||
|  | <<<<<<< HEAD | ||||||
|  | ======= | ||||||
|  |  "exit-no-std", | ||||||
|  |  "libc", | ||||||
|  | >>>>>>> cc5a4cf (true(1) & false(1): EVEN SMALLER) | ||||||
|  "sysexits", |  "sysexits", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ authors = [ | |||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
|  | libc = { version = "0.2.14", default-features = false } | ||||||
| sysexits = "0.3.4" | sysexits = "0.3.4" | ||||||
| arg = { version = "0.1.0", path = "arg", package = "arg" } | arg = { version = "0.1.0", path = "arg", package = "arg" } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										27
									
								
								src/cat.rs
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								src/cat.rs
									
									
									
									
									
								
							| @ -18,9 +18,10 @@ | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| use std::env; | use std::env; | ||||||
| use std::fs::{File, read_to_string}; | use std::fs::{File, read, read_to_string}; | ||||||
| use std::io; | use std::io; | ||||||
| use std::io::{ Read, Write }; | use std::io::{ Read, Write }; | ||||||
|  | use std::os::unix::io::FromRawFd; | ||||||
| use std::str; | use std::str; | ||||||
| 
 | 
 | ||||||
| use arg::Args; | use arg::Args; | ||||||
| @ -52,17 +53,11 @@ fn main() -> ExitCode { | |||||||
|   for path in args.paths { |   for path in args.paths { | ||||||
|     if path == "-" { |     if path == "-" { | ||||||
|       let mut bytes: Vec<u8> = Vec::new(); |       let mut bytes: Vec<u8> = Vec::new(); | ||||||
|       match io::stdin().lock().read_to_end(&mut bytes) { |       io::stdin().lock().read_to_end(&mut bytes).unwrap(); | ||||||
|         Ok(EOF) => { | 
 | ||||||
|           for byte in &bytes { |       for byte in &bytes { | ||||||
|             output.push_str(str::from_utf8(&[byte.to_owned()]).unwrap()); |         output.push_str(str::from_utf8(&[byte.to_owned()]).unwrap()); | ||||||
|           } |       } | ||||||
|         }, |  | ||||||
|         Err(_) => { |  | ||||||
|           eprintln!("Usage: {} [options...] [files...]", &argv0); |  | ||||||
|           return ExitCode::Usage; |  | ||||||
|         }, |  | ||||||
|       }; |  | ||||||
|     } else { |     } else { | ||||||
|       match read_to_string(&path) { |       match read_to_string(&path) { | ||||||
|         Ok(contents) => { output.push_str(&contents) }, |         Ok(contents) => { output.push_str(&contents) }, | ||||||
| @ -75,11 +70,5 @@ fn main() -> ExitCode { | |||||||
|     print!("{}", output); |     print!("{}", output); | ||||||
|     output.clear(); |     output.clear(); | ||||||
|   } |   } | ||||||
|   match io::stdout().flush() { |   ExitCode::Ok | ||||||
|     Ok(_) => return ExitCode::Ok, |  | ||||||
|     Err(_) => { |  | ||||||
|       eprintln!("{}: Cannot write to stdout", &argv0); |  | ||||||
|       return ExitCode::OsErr; |  | ||||||
|     }, |  | ||||||
|   }; |  | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										35
									
								
								src/false.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/false.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | |||||||
|  | // Copyright (c) 2022 YAC
 | ||||||
|  | // SPDX-License-Identifier: AGPL-3.0-or-later
 | ||||||
|  | 
 | ||||||
|  | /* This file is part of YAC coreutils.
 | ||||||
|  |  * | ||||||
|  |  * YAC coreutils is free software: you can redistribute it and/or modify it | ||||||
|  |  * under the terms of the GNU Affero General Public License as published by the | ||||||
|  |  * Free Software Foundation, either version 3 of the License, or (at your | ||||||
|  |  * option) any later version. | ||||||
|  |  * 
 | ||||||
|  |  * YAC coreutils is distributed in the hope that it will be useful, but WITHOUT | ||||||
|  |  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||
|  |  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||||||
|  |  * details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program. If not, see https://www.gnu.org/licenses/.
 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #![feature(core_intrinsics, lang_items, start)] | ||||||
|  | #![no_main] | ||||||
|  | #![no_std] | ||||||
|  | 
 | ||||||
|  | extern crate libc; | ||||||
|  | 
 | ||||||
|  | #[lang = "eh_personality"] | ||||||
|  | #[no_mangle] | ||||||
|  | fn rust_eh_personality() {} | ||||||
|  | 
 | ||||||
|  | #[lang = "panic_impl"] | ||||||
|  | #[no_mangle] | ||||||
|  | fn panic(_: &core::panic::PanicInfo) -> ! { core::intrinsics::abort() } | ||||||
|  | 
 | ||||||
|  | #[no_mangle] | ||||||
|  | fn main() { exit_no_std::exit(1); } | ||||||
							
								
								
									
										35
									
								
								src/true.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/true.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | |||||||
|  | // Copyright (c) 2022 YAC
 | ||||||
|  | // SPDX-License-Identifier: AGPL-3.0-or-later
 | ||||||
|  | 
 | ||||||
|  | /* This file is part of YAC coreutils.
 | ||||||
|  |  * | ||||||
|  |  * YAC coreutils is free software: you can redistribute it and/or modify it | ||||||
|  |  * under the terms of the GNU Affero General Public License as published by the | ||||||
|  |  * Free Software Foundation, either version 3 of the License, or (at your | ||||||
|  |  * option) any later version. | ||||||
|  |  * 
 | ||||||
|  |  * YAC coreutils is distributed in the hope that it will be useful, but WITHOUT | ||||||
|  |  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||
|  |  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||||||
|  |  * details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program. If not, see https://www.gnu.org/licenses/.
 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #![feature(core_intrinsics, lang_items, start)] | ||||||
|  | #![no_main] | ||||||
|  | #![no_std] | ||||||
|  | 
 | ||||||
|  | extern crate libc; | ||||||
|  | 
 | ||||||
|  | #[lang = "eh_personality"] | ||||||
|  | #[no_mangle] | ||||||
|  | fn rust_eh_personality() {} | ||||||
|  | 
 | ||||||
|  | #[lang = "panic_impl"] | ||||||
|  | #[no_mangle] | ||||||
|  | fn panic(_: &core::panic::PanicInfo) -> ! { core::intrinsics::abort() } | ||||||
|  | 
 | ||||||
|  | #[no_mangle] | ||||||
|  | fn main() { exit_no_std::exit(0); } | ||||||
		Reference in New Issue
	
	Block a user