removed c-main dep

This commit is contained in:
2023-04-09 22:05:31 -04:00
parent e3e1807656
commit f33c18a2b3
3 changed files with 7 additions and 21 deletions

View File

@@ -16,9 +16,8 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
#![no_main]
use std::{
env::args,
fs::File,
io::Read,
iter::Peekable,
@@ -27,7 +26,6 @@ use std::{
str::FromStr,
};
use c_main::Args;
use toml::Value;
use yacexits::*;
@@ -67,8 +65,8 @@ fn parse_toml(
},
Value::Table(table) => {
if tabkey.peek().is_some() {
root = toml::Value::Table(table.to_owned());
continue;
root = toml::Value::Table(table.to_owned());
continue;
};
},
_ => {
@@ -99,9 +97,8 @@ fn parse_toml(
Ok(out)
}
#[no_mangle]
fn rust_main(args: Args) {
let argv: Vec<&str> = args.into_iter().collect();
fn main() {
let argv: Vec<String> = args().collect();
let usage_info = format!("Usage: {} [table.]key[[index]] [file...]", argv[0]);
if argv.len() <= 1 {
@@ -109,11 +106,11 @@ fn rust_main(args: Args) {
exit(EX_USAGE);
}
let input = argv.get(2).unwrap_or(&"");
let input = argv.get(2).unwrap_or(&"".to_owned()).to_owned();
let mut content = Vec::new();
match input.to_owned() {
match input.as_str() {
"-" | "" => unsafe { File::from_raw_fd(0) },
_ => {
File::open(Path::new(&input)).unwrap_or_else(|_| {