diff options
author | Adrian Kummerlaender | 2016-04-30 20:06:48 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2016-04-30 20:06:48 +0200 |
commit | 05c4ee3665445eadf094ccab395518e992c337d4 (patch) | |
tree | 67fb9db0c5fece4a7cd18bd6aa46322e2bcbaeff /justify.cc | |
parent | 5eb3689c9985f28b46651f547b9b32d55b4a07b5 (diff) | |
download | justify-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 |
Enables users to customize the seed used for the pseudorandom number generator.
Diffstat (limited to 'justify.cc')
-rw-r--r-- | justify.cc | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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() ) { |