logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 2a84b987813114a0e325fd3fed7c178d87103dc4
parent 8d5bac7bf0613b2b14dbe807165908a881778642
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed,  2 Mar 2022 13:52:54 +0100

.clang-format: multi-line case labels

Diffstat:

M.clang-format2+-
Mbin/basename.c16++++++++++++----
Mbin/date.c4+++-
Mbin/env.c4+++-
Mbin/strings.c16++++++++++++----
Mbin/tee.c11+++++++----
6 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/.clang-format b/.clang-format @@ -2,7 +2,7 @@ AlignAfterOpenBracket: true AlignConsecutiveAssignments: true AlignOperands: true AlignTrailingComments: true -AllowShortCaseLabelsOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: true AllowShortIfStatementsOnASingleLine: true AlwaysBreakAfterReturnType: AllDefinitions diff --git a/bin/basename.c b/bin/basename.c @@ -38,10 +38,18 @@ main(int argc, char *argv[]) switch(argc) { - case 1: ret = printf(".\n"); break; - case 2: ret = puts(basename(argv[1])); break; - case 3: ret = puts(suffix_basename(argv[1], argv[2])); break; - default: fprintf(stderr, "usage: basename string [suffix]\n"); return 1; + case 1: + ret = printf(".\n"); + break; + case 2: + ret = puts(basename(argv[1])); + break; + case 3: + ret = puts(suffix_basename(argv[1], argv[2])); + break; + default: + fprintf(stderr, "usage: basename string [suffix]\n"); + return 1; } if(ret < 0) diff --git a/bin/date.c b/bin/date.c @@ -26,7 +26,9 @@ main(int argc, char *argv[]) { switch(c) { - case 'u': /* UTC timezone */ uflag++; break; + case 'u': /* UTC timezone */ + uflag++; + break; } } diff --git a/bin/env.c b/bin/env.c @@ -44,7 +44,9 @@ main(int argc, char *argv[]) { switch(c) { - case 'i': flag_i = true; break; + case 'i': + flag_i = true; + break; case ':': fprintf(stderr, "Error: Missing operand for option: '-%c'\n", optopt); usage(); diff --git a/bin/strings.c b/bin/strings.c @@ -129,10 +129,18 @@ main(int argc, char *argv[]) switch(optarg[0]) { - case 'o': opt_offset_format = "%zo %s\n"; break; - case 'x': opt_offset_format = "%zx %s\n"; break; - case 'd': opt_offset_format = "%zd %s\n"; break; - default: usage(); return 1; + case 'o': + opt_offset_format = "%zo %s\n"; + break; + case 'x': + opt_offset_format = "%zx %s\n"; + break; + case 'd': + opt_offset_format = "%zd %s\n"; + break; + default: + usage(); + return 1; } break; } diff --git a/bin/tee.c b/bin/tee.c @@ -30,8 +30,11 @@ main(int argc, char *argv[]) { switch(c) { - case 'a': mode = "a"; break; - case 'i': /* ignore SIGINT */; break; + case 'a': + mode = "a"; + break; + case 'i': /* ignore SIGINT */; + break; } } @@ -72,7 +75,7 @@ main(int argc, char *argv[]) if(fputc(c, stdout) == EOF) { fprintf(stderr, "Error writing ‘<stdout>’: %s\n", strerror(errno)); - err = 1; + err = 1; errno = 0; } @@ -81,7 +84,7 @@ main(int argc, char *argv[]) if(fputc(c, fds[argi]) == EOF) { fprintf(stderr, "Error writing to argument %d: %s\n", argi, strerror(errno)); - err = 1; + err = 1; errno = 0; } }