From: Shlomi Fish Date: Thu, 16 Dec 2021 17:35:17 +0000 (+0200) Subject: Wrap C/etc. oneline blocks in {...} X-Git-Tag: fortune-mod-3.12.0~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f0415beca107cf36f4424232c14b5e22657ca8f;p=fortune-mod Wrap C/etc. oneline blocks in {...} See: https://fc-solve.shlomifish.org/docs/distro/HACKING.html#one-line-clauses . --- diff --git a/fortune-mod/util/randstr.c b/fortune-mod/util/randstr.c index 4a49f5a..83ea92f 100644 --- a/fortune-mod/util/randstr.c +++ b/fortune-mod/util/randstr.c @@ -106,6 +106,7 @@ static void getargs(char *argv[]) input_fn_2_data_fn(); } else + { /* { * Don't write out errors here, either; trust in exit codes and sh * fprintf(stderr, "No input file name\n"); @@ -113,7 +114,8 @@ static void getargs(char *argv[]) * [outputfile]\n"); */ exit(1); - /* } */ + /* } */ + } } /* @@ -125,7 +127,9 @@ static void get_pos(STRFILE *fp) { pos = random() % fp->str_numstr; if (++(pos) >= (off_t)(fp->str_numstr)) + { pos -= fp->str_numstr; + } } /* @@ -155,13 +159,19 @@ static void display(FILE *fp, STRFILE table) i++) { if (table.str_flags & STR_ROTATED) + { for (p = line; (ch = *p); ++p) { if (isupper(ch)) + { *p = 'A' + (ch - 'A' + 13) % 26; + } else if (islower(ch)) + { *p = 'a' + (ch - 'a' + 13) % 26; + } } + } fputs(line, stdout); } fflush(stdout); diff --git a/fortune-mod/util/unstr.c b/fortune-mod/util/unstr.c index 52f35ca..94425ae 100644 --- a/fortune-mod/util/unstr.c +++ b/fortune-mod/util/unstr.c @@ -93,6 +93,7 @@ static void getargs(int argc, char *argv[]) int ch; while ((ch = getopt(argc, argv, "c:")) != EOF) + { switch (ch) { case 'c': @@ -109,6 +110,7 @@ static void getargs(int argc, char *argv[]) "Usage:\n\tunstr [-c C] datafile[.ext] [outputfile]\n"); exit(1); } + } argv += optind; @@ -183,7 +185,9 @@ int main(int argc, char **argv) exit(1); } if (*output_filename == '\0') + { Outf = stdout; + } else if (!(Outf = fopen(output_filename, "w+"))) { perror(output_filename); @@ -207,9 +211,13 @@ int main(int argc, char **argv) exit(1); } if (new_delimiter_char) + { delimiter_char = new_delimiter_char; + } else + { delimiter_char = (char)tbl.str_delim; + } order_unstr(&tbl); fclose(Inf); fclose(Dataf);