Skip to content

Commit

Permalink
style: General code formatting
Browse files Browse the repository at this point in the history
- Replace for (;;) with while (1)
- Other stuff
  • Loading branch information
a-random-lemurian committed Dec 31, 2021
1 parent 562ed13 commit 91104a3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/checkoverflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ inline extern int CheckOverflow_cchar(int ignore_int_limit, const char *samplesi
"ignore this with --ignoreintlimit");
exit(errcode);
}

return (int)num;
}

Expand Down
26 changes: 14 additions & 12 deletions src/randascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,32 @@ static int alphanumeric_flag;
static int ignore_int_limit;

void PrintHelp(char **argv) {
printf("Usage: %c [OPTIONS] -l [length]\n\n"

"options:\n"
"-h, --help Print help and exit\n"
"-l, --length Length of ASCII string to print\n"
"--alphanumeric Use alphanumeric characters;\n"
" no punctuation\n",
*argv[0]);
printf(
"Usage: %c [OPTIONS] -l [length]\n\n"

"options:\n"
"-h, --help Print help and exit\n"
"-l, --length Length of ASCII string to print\n"
"--alphanumeric Use alphanumeric characters;\n"
" no punctuation\n",
*argv[0]);
}

int main(int argc, char **argv)
{
CheckArguments(argc, argv);

const char *samplesize = 0;

int c;
int len = 94;
int offset = 0;

char alphanumericAscii[66] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char printableAscii[94] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%%^&*()_+`{}:\"|<>?,./;\'\\[]\'";

for (;;) {
while (1)
{
static struct option longopts[] = {
{"length", required_argument, 0, 'l'},
{"help", no_argument, &help_flag, 1},
Expand Down Expand Up @@ -97,7 +101,5 @@ int main(int argc, char **argv)
return 0;
}

RandomArray_char(len, offset, num_i, printableAscii);

RandomArray_char(len, offset, num_i, printableAscii);
}

18 changes: 10 additions & 8 deletions src/randfromargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ static int help_flag, ignore_int_limit;

void PrintHelp(char **argv) {
printf(
"Usage: %s [OPTIONS] -a [ARRAY] -l [LENGTH]\n\n"
"Usage: %s [OPTIONS] -a [ARRAY] -l [LENGTH]\n\n"

"specify your own strings to choose from randomly\n"
"options:\n"
"-h, --help Print this message and exit\n"
"-a, --array Array (can be a string, does not support {})\n"
"-l, --length Length of characters to print\n",
argv[0]);
"specify your own strings to choose from randomly\n"
"options:\n"
"-h, --help Print this message and exit\n"
"-a, --array Array (can be a string, does not support {})\n"
"-l, --length Length of characters to print\n",
argv[0]);
}


Expand All @@ -48,7 +48,9 @@ int main(int argc, char **argv) {
int c;
char *samplesize = "0";
char *array = " ";
for (;;) {

while (1)
{
static struct option longopts[] = {
{"length", required_argument, 0, 'l'},
{"help", no_argument, &help_flag, 1},
Expand Down
3 changes: 2 additions & 1 deletion src/randhex.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ int main(int argc, char **argv) {
int c;
const char *hexlen = 0;

for (;;) {
while (1)
{
static struct option longopts[] = {
{"length", required_argument, 0, 'l'},
{"help", no_argument, &help_flag, 1},
Expand Down
3 changes: 2 additions & 1 deletion src/randquote.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ int main (int argc, char** argv)
int c;
char* filename = "-";

for (;;) {
while (1)
{
static struct option longopts[] = {
//{"length", required_argument, 0, 'l'},
{"help", no_argument, &help_flag, 1},
Expand Down

0 comments on commit 91104a3

Please sign in to comment.