Skip to content

Commit

Permalink
ppgen: Use ostream_joiner
Browse files Browse the repository at this point in the history
This allows for not printing a trailing space, which is better for
copy-pasting.

Bumps version to 1.2
  • Loading branch information
talisein committed Jan 27, 2018
1 parent c208733 commit 784057f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 15 additions & 11 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
project('ppgen', ['cpp'],
version: '1.1',
license: 'GPL3+',
version: '1.2',
license: 'GPL3+',
default_options : ['cpp_std=c++14',
'buildtype=release'])
'buildtype=release'])

if not meson.get_compiler('cpp').has_header_symbol('experimental/iterator', '__cpp_lib_experimental_ostream_joiner')
error('C++ ostream_joiner not available. Use release 1.1')
endif

pcg_cpp_sp = subproject('pcg-cpp')
pcg_cpp_dep = pcg_cpp_sp.get_variable('pcg_cpp_dep')

ppgen = executable('ppgen', join_paths('src', 'ppgen.cpp'),
dependencies: pcg_cpp_dep,
install: true)
ppgen = executable('ppgen', 'src/ppgen.cpp',
dependencies: pcg_cpp_dep,
install: true)

pingen = executable('pingen', join_paths('src', 'pingen.cpp'),
dependencies: pcg_cpp_dep,
install: true)
pingen = executable('pingen', 'src/pingen.cpp',
dependencies: pcg_cpp_dep,
install: true)

install_man(join_paths('man', 'ppgen.1'))
install_man(join_paths('man', 'pingen.1'))
install_man('man/ppgen.1')
install_man('man/pingen.1')
4 changes: 3 additions & 1 deletion src/ppgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cmath>
#include <iostream>
#include <random>
#include <experimental/iterator>
#include "pcg_random.hpp"
#include "diceware_wordlist.h"
#include "eff_wordlist.h"
Expand Down Expand Up @@ -53,8 +54,9 @@ int main(int argc, char** arg_begin)

std::cout << "Choose from one of these 10 passphrases:\n\n";
for (int gen_num = 0; gen_num < 10; ++gen_num) {
auto out = std::experimental::make_ostream_joiner(std::cout, " ");
for (long word = 0; word < num_words; ++word) {
std::cout << wordlist[dis(rng)] << " ";
out = wordlist[dis(rng)];
}
std::cout << std::endl;
}
Expand Down

0 comments on commit 784057f

Please sign in to comment.