CI: update FreeBSD, NetBSD, OpenBSD, Solaris actions
[xz.git] / debug / repeat.c
blob4830b13a273dd79499e97fb291433f2d0b154961
1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file repeat.c
6 /// \brief Repeats given string given times
7 ///
8 /// This program can be useful when debugging run-length encoder in
9 /// the Subblock filter, especially the condition when repeat count
10 /// doesn't fit into 28-bit integer.
12 // Author: Lasse Collin
14 ///////////////////////////////////////////////////////////////////////////////
16 #include "sysdefs.h"
17 #include <stdio.h>
20 int
21 main(int argc, char **argv)
23 if (argc != 3) {
24 fprintf(stderr, "Usage: %s COUNT STRING\n", argv[0]);
25 exit(1);
28 unsigned long long count = strtoull(argv[1], NULL, 10);
29 const size_t size = strlen(argv[2]);
31 while (count-- != 0)
32 fwrite(argv[2], 1, size, stdout);
34 return !!(ferror(stdout) || fclose(stdout));