From e7c60e496aeae362f74a23787f19e13cc607d3f3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 4 Nov 2016 16:20:35 +0000 Subject: [PATCH] generate: support K/N --- generate.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/generate.c b/generate.c index 75299fe..c9c8cee 100644 --- a/generate.c +++ b/generate.c @@ -1,6 +1,7 @@ #include #include +#include #include static const char charset[]= @@ -13,10 +14,16 @@ static const char charset[]= static char sofar[ML+1]; +static int denomix, denom=1; + static void gen(char *inbuf, int len) { if (!len) { *inbuf = 0; - puts(sofar); + if (!denomix) { + puts(sofar); + } + denomix += (denom-1); + denomix %= denom; return; } const char *cp; @@ -29,6 +36,13 @@ static void gen(char *inbuf, int len) { int main(int argc, char **argv) { int len; int minlen=0, maxlen=ML; + char *slash; + + if (argc>=2 && (slash = strchr(argv[1], '/'))) { + denomix = atoi(argv[1]); + denom = atoi(slash+1); + argv++; argc--; + } if (argc==3) { minlen = atoi(argv[1]); -- 2.30.2