aboutsummaryrefslogtreecommitdiff
path: root/justify.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-04-30 20:06:48 +0200
committerAdrian Kummerlaender2016-04-30 20:06:48 +0200
commit05c4ee3665445eadf094ccab395518e992c337d4 (patch)
tree67fb9db0c5fece4a7cd18bd6aa46322e2bcbaeff /justify.cc
parent5eb3689c9985f28b46651f547b9b32d55b4a07b5 (diff)
downloadjustify-master.tar
justify-master.tar.gz
justify-master.tar.bz2
justify-master.tar.lz
justify-master.tar.xz
justify-master.tar.zst
justify-master.zip
Implement `--seed` argumentHEADmaster
Enables users to customize the seed used for the pseudorandom number generator.
Diffstat (limited to 'justify.cc')
-rw-r--r--justify.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/justify.cc b/justify.cc
index c417dfd..9115d83 100644
--- a/justify.cc
+++ b/justify.cc
@@ -23,6 +23,11 @@ boost::optional<boost::program_options::variables_map> input(
boost::program_options::value<int>(),
"Number of spaces to be prepended on each line"
)
+ (
+ "seed",
+ boost::program_options::value<std::uint32_t>(),
+ "Seed for pseudorandomly distributing missing spaces"
+ )
;
boost::program_options::variables_map variables;
@@ -51,8 +56,9 @@ bool process(const boost::program_options::variables_map& variables) {
std::cout.sync_with_stdio(false);
std::cin.sync_with_stdio(false);
- std::uint8_t line_length = 60;
- std::uint8_t line_offset = 0;
+ std::uint8_t line_length = 60;
+ std::uint8_t line_offset = 0;
+ std::uint32_t seed = 3473018784;
if ( variables.count("length") ) {
const int user_length = variables["length"].as<int>();
@@ -78,7 +84,11 @@ bool process(const boost::program_options::variables_map& variables) {
}
}
- justify::LineAccumulator acc{line_length, line_offset};
+ if ( variables.count("seed") ) {
+ seed = variables["seed"].as<std::uint32_t>();
+ }
+
+ justify::LineAccumulator acc{line_length, line_offset, seed};
std::string token;
while ( std::cin.good() ) {