forked from Tordek/cheat
-
Notifications
You must be signed in to change notification settings - Fork 8
/
meta.c
46 lines (37 loc) · 909 Bytes
/
meta.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
static int cheat_print_parameters(size_t const parameters) {
size_t index;
for (index = 0;
index < parameters;
++index) {
if (index != 0)
(void )printf(", ");
(void )printf("x%zu", index + 1);
}
return 0;
}
static int cheat_print_definitions(size_t const parameters) {
size_t index;
for (index = 1;
index < parameters;
++index) {
(void )printf("#define CHEAT_COMMAS_%zu(", index);
(void )cheat_print_parameters(index + 1);
(void )printf(") ");
(void )cheat_print_parameters(index + 1);
(void )printf("\n");
}
return 0;
}
int main(int const count, char** const arguments) {
long int index;
if (count != 2)
return EXIT_FAILURE;
index = strtol(arguments[1], NULL, 10);
if (index < 1 || index == LONG_MAX)
return EXIT_FAILURE;
(void )cheat_print_definitions((size_t )index);
return EXIT_SUCCESS;
}