Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
0.10.5: UTF-8 Tokenizer Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Jan 18, 2017
1 parent 776dbca commit 28f1bdb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "parallel"
version = "0.10.4"
version = "0.10.5"
authors = ["Michael Aaron Murphy <mmstickman@gmail.com>"]
license = "MIT"
description = "Command-line CPU load balancer for executing jobs in parallel"
Expand All @@ -10,7 +10,7 @@ readme = "README.md"

[dependencies]
itoa = "0.1"
numtoa = "0.0.3"
numtoa = "0.0.5"
num_cpus = "1.2"
permutate = "0.2"
arrayvec = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MIT/Rust Parallel: A Command-line CPU Load Balancer Written in Rust
[![Crates.io](https://img.shields.io/crates/v/parallel.svg)](https://github.com/mmstick/parallel)
[![Crates.io](https://img.shields.io/crates/v/parallel.svg)](https://crates.io/crates/parallel)
[![Tokei SLoC Count](https://tokei.rs/b1/github/mmstick/parallel)](https://github.com/mmstick/parallel)
[![AUR](https://img.shields.io/aur/version/parallel-rust.svg)](https://github.com/mmstick/parallel)
[![AUR](https://img.shields.io/aur/version/parallel-rust.svg)](https://aur.archlinux.org/packages/parallel-rust/)
[![OpenHub Statistics](https://www.openhub.net/p/rust-parallel/widgets/project_thin_badge?format=gif&ref=Thin+badge)](https://www.openhub.net/p/rust-parallel/)

This is an attempt at recreating the functionality of [GNU Parallel](https://www.gnu.org/software/parallel/), a work-stealer for the command-line, in Rust under a MIT license. The end goal will be to support much of the functionality of `GNU Parallel` and then to extend the functionality further for the next generation of command-line utilities written in Rust. While functionality is important, with the application being developed in Rust, the goal is to also be as fast and efficient as possible.
Expand Down
4 changes: 2 additions & 2 deletions src/arguments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl Args {
fn write_stdin_to_disk(max_args: usize, mut unprocessed_path: PathBuf) -> Result<usize, ParseErr> {
println!("parallel: reading inputs from standard input");
unprocessed_path.push("unprocessed");
let disk_buffer = fs::OpenOptions::new().write(true).create(true).open(&unprocessed_path)
let disk_buffer = fs::OpenOptions::new().truncate(true).write(true).create(true).open(&unprocessed_path)
.map_err(|why| ParseErr::File(FileErr::Open(unprocessed_path.clone(), why)))?;
let mut disk_buffer = BufWriter::new(disk_buffer);
let mut number_of_arguments = 0;
Expand Down Expand Up @@ -314,7 +314,7 @@ fn write_inputs_to_disk(lists: Vec<Vec<String>>, current_inputs: Vec<String>, ma
mut unprocessed_path: PathBuf) -> Result<usize, ParseErr>
{
unprocessed_path.push("unprocessed");
let disk_buffer = fs::OpenOptions::new().write(true).create(true).open(&unprocessed_path)
let disk_buffer = fs::OpenOptions::new().truncate(true).write(true).create(true).open(&unprocessed_path)
.map_err(|why| ParseErr::File(FileErr::Open(unprocessed_path.to_owned(), why)))?;
let mut disk_buffer = BufWriter::new(disk_buffer);
let mut number_of_arguments = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/execute/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn receive_messages(input_rx: Receiver<State>, args: Args, base: &str, proce
let processed_file = fs::OpenOptions::new().create(true).write(true).open(processed_path).unwrap();
let mut processed_file = BufWriter::new(processed_file);
// An opened disk buffer pointing to the error file.
let error_file = fs::OpenOptions::new().create(true).write(true).open(errors_path).unwrap();
let error_file = fs::OpenOptions::new().truncate(true).create(true).write(true).open(errors_path).unwrap();
let mut error_file = BufWriter::new(error_file);
// Obtaining the number of digits in the total number of inputs is required for padding purposes.
let mut id_pad_length = args.ninputs.digits();
Expand Down
4 changes: 3 additions & 1 deletion src/tokenizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ pub fn tokenize(tokens: &mut ArrayVec<[Token; 128]>, template: &'static str, pat
// Mark the index where the argument's first character begins.
let mut argument_start = 0;

for (id, character) in template.chars().enumerate() {
let mut id = 0;
for character in template.chars() {
match (character, pattern_matching) {
// This condition initiates the pattern matching
('{', false) => {
Expand Down Expand Up @@ -126,6 +127,7 @@ pub fn tokenize(tokens: &mut ArrayVec<[Token; 128]>, template: &'static str, pat
},
(_, _) => ()
}
id += character.len_utf8();
}

// In the event that there is leftover data that was not matched, this will add the final
Expand Down

0 comments on commit 28f1bdb

Please sign in to comment.