Skip to content

Commit

Permalink
misc: consolidate macro style USAGE_HELP_OPTIONS
Browse files Browse the repository at this point in the history
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
  • Loading branch information
rudimeier committed Jun 29, 2017
1 parent 43c960c commit f45f3ec
Show file tree
Hide file tree
Showing 111 changed files with 204 additions and 206 deletions.
4 changes: 2 additions & 2 deletions Documentation/boilerplate.c
Expand Up @@ -56,8 +56,8 @@ static void __attribute__((__noreturn__)) usage(void)
" consecutive lines are intended by two spaces\n"), out);
fputs(_(" -f, --foobar next option description resets indent\n"), out);
fputs(USAGE_SEPARATOR, out);
print_usage_help_options(25); /* char offset to align option descriptions */
fprintf(out, USAGE_MAN_TAIL("fixme-command-name(1)"));
printf(USAGE_HELP_OPTIONS(25)); /* char offset to align option descriptions */
printf(USAGE_MAN_TAIL("fixme-command-name(1)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions disk-utils/addpart.c
Expand Up @@ -19,8 +19,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Tell the kernel about the existence of a specified partition.\n"), out);

fputs(USAGE_OPTIONS, out);
print_usage_help_options(16);
fprintf(out, USAGE_MAN_TAIL("addpart(8)"));
printf(USAGE_HELP_OPTIONS(16));
printf(USAGE_MAN_TAIL("addpart(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion disk-utils/blockdev.c
Expand Up @@ -197,7 +197,7 @@ static void __attribute__((__noreturn__)) usage(void)
puts( _(" -v verbose mode"));
puts( _(" --report print report for specified (or all) devices"));
fputs(USAGE_SEPARATOR, stdout);
print_usage_help_options(16);
printf(USAGE_HELP_OPTIONS(16));

fputs(USAGE_SEPARATOR, stdout);
puts( _("Available commands:"));
Expand Down
4 changes: 2 additions & 2 deletions disk-utils/cfdisk.c
Expand Up @@ -2559,9 +2559,9 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -z, --zero start with zeroed partition table\n"), out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(26);
printf(USAGE_HELP_OPTIONS(26));

fprintf(out, USAGE_MAN_TAIL("cfdisk(8)"));
printf(USAGE_MAN_TAIL("cfdisk(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions disk-utils/delpart.c
Expand Up @@ -19,8 +19,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Tell the kernel to forget about a specified partition.\n"), out);

fputs(USAGE_OPTIONS, out);
print_usage_help_options(16);
fprintf(out, USAGE_MAN_TAIL("delpart(8)"));
printf(USAGE_HELP_OPTIONS(16));
printf(USAGE_MAN_TAIL("delpart(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions disk-utils/fdformat.c
Expand Up @@ -156,8 +156,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -n, --no-verify disable the verification after the format\n"), out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(19);
fprintf(out, USAGE_MAN_TAIL("fdformat(8)"));
printf(USAGE_HELP_OPTIONS(19));
printf(USAGE_MAN_TAIL("fdformat(8)"));

exit(EXIT_SUCCESS);
}
Expand Down
4 changes: 2 additions & 2 deletions disk-utils/fdisk.c
Expand Up @@ -785,11 +785,11 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -S, --sectors <number> specify the number of sectors per track\n"), out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(31);
printf(USAGE_HELP_OPTIONS(31));

list_available_columns(out);

fprintf(out, USAGE_MAN_TAIL("fdisk(8)"));
printf(USAGE_MAN_TAIL("fdisk(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion disk-utils/fsck.c
Expand Up @@ -1398,7 +1398,7 @@ static void __attribute__((__noreturn__)) usage(void)
printf( " --version %s\n", USAGE_OPTSTR_VERSION);
fputs(USAGE_SEPARATOR, out);
fputs(_("See the specific fsck.* commands for available fs-options."), out);
fprintf(out, USAGE_MAN_TAIL("fsck(8)"));
printf(USAGE_MAN_TAIL("fsck(8)"));
exit(FSCK_EX_OK);
}

Expand Down
2 changes: 1 addition & 1 deletion disk-utils/fsck.cramfs.c
Expand Up @@ -120,7 +120,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -b, --blocksize <size> use this blocksize, defaults to page size\n"), out);
fputs(_(" --extract[=<dir>] test uncompression, optionally extract into <dir>\n"), out);
fputs(USAGE_SEPARATOR, out);
print_usage_help_options(26);
printf(USAGE_HELP_OPTIONS(26));

printf(USAGE_MAN_TAIL("fsck.cramfs(8)"));
exit(FSCK_EX_OK);
Expand Down
4 changes: 2 additions & 2 deletions disk-utils/fsck.minix.c
Expand Up @@ -192,8 +192,8 @@ usage(void) {
fputs(_(" -m, --uncleared activate mode not cleared warnings\n"), out);
fputs(_(" -f, --force force check\n"), out);
fputs(USAGE_SEPARATOR, out);
print_usage_help_options(18);
fprintf(out, USAGE_MAN_TAIL("fsck.minix(8)"));
printf(USAGE_HELP_OPTIONS(18));
printf(USAGE_MAN_TAIL("fsck.minix(8)"));
exit(FSCK_EX_OK);
}

Expand Down
4 changes: 2 additions & 2 deletions disk-utils/isosize.c
Expand Up @@ -141,8 +141,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -d, --divisor=<number> divide the amount of bytes by <number>\n"), out);
fputs(_(" -x, --sectors show sector count and size\n"), out);
fputs(USAGE_SEPARATOR, out);
print_usage_help_options(25);
fprintf(out, USAGE_MAN_TAIL("isosize(8)"));
printf(USAGE_HELP_OPTIONS(25));
printf(USAGE_MAN_TAIL("isosize(8)"));

exit(EXIT_SUCCESS);
}
Expand Down
4 changes: 2 additions & 2 deletions disk-utils/mkfs.bfs.c
Expand Up @@ -85,9 +85,9 @@ static void __attribute__((__noreturn__)) usage(void)
" -c this option is silently ignored\n"
" -l this option is silently ignored\n"
));
print_usage_help_options(21);
printf(USAGE_HELP_OPTIONS(21));

fprintf(out, USAGE_MAN_TAIL("mkfs.bfs(8)"));
printf(USAGE_MAN_TAIL("mkfs.bfs(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions disk-utils/mkfs.c
Expand Up @@ -55,9 +55,9 @@ static void __attribute__((__noreturn__)) usage(void)
fprintf(out, _(" <size> number of blocks to be used on the device\n"));
fprintf(out, _(" -V, --verbose explain what is being done;\n"
" specifying -V more than once will cause a dry-run\n"));
print_usage_help_options(20);
printf(USAGE_HELP_OPTIONS(20));

fprintf(out, USAGE_MAN_TAIL("mkfs(8)"));
printf(USAGE_MAN_TAIL("mkfs(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion disk-utils/mkfs.cramfs.c
Expand Up @@ -143,7 +143,7 @@ static void __attribute__((__noreturn__)) usage(void)
program_invocation_short_name, PAD_SIZE);

fputs(USAGE_SEPARATOR, stdout);
print_usage_help_options(16);
printf(USAGE_HELP_OPTIONS(16));
printf(USAGE_MAN_TAIL("mkfs.cramfs(8)"));
exit(MKFS_EX_OK);
}
Expand Down
4 changes: 2 additions & 2 deletions disk-utils/mkfs.minix.c
Expand Up @@ -145,8 +145,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -c, --check check the device for bad blocks\n"), out);
fputs(_(" -l, --badblocks <file> list of bad blocks from file\n"), out);
fputs(USAGE_SEPARATOR, out);
print_usage_help_options(25);
fprintf(out, USAGE_MAN_TAIL("mkfs.minix(8)"));
printf(USAGE_HELP_OPTIONS(25));
printf(USAGE_MAN_TAIL("mkfs.minix(8)"));
exit(MKFS_EX_OK);
}

Expand Down
2 changes: 1 addition & 1 deletion disk-utils/mkswap.c
Expand Up @@ -161,7 +161,7 @@ static void __attribute__((__noreturn__)) usage(void)
" -v, --swapversion NUM specify swap-space version number\n"
" -U, --uuid UUID specify the uuid to use\n"
));
print_usage_help_options(27);
printf(USAGE_HELP_OPTIONS(27));

printf(USAGE_MAN_TAIL("mkswap(8)"));
exit(EXIT_SUCCESS);
Expand Down
4 changes: 2 additions & 2 deletions disk-utils/partx.c
Expand Up @@ -773,13 +773,13 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -v, --verbose verbose mode\n"), out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(22);
printf(USAGE_HELP_OPTIONS(22));

fputs(USAGE_COLUMNS, out);
for (i = 0; i < NCOLS; i++)
fprintf(out, " %10s %s\n", infos[i].name, _(infos[i].help));

fprintf(out, USAGE_MAN_TAIL("partx(8)"));
printf(USAGE_MAN_TAIL("partx(8)"));

exit(EXIT_SUCCESS);
}
Expand Down
4 changes: 2 additions & 2 deletions disk-utils/raw.c
Expand Up @@ -59,8 +59,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(USAGE_OPTIONS, out);
fputs(_(" -q, --query set query mode\n"), out);
fputs(_(" -a, --all query all raw devices\n"), out);
print_usage_help_options(16);
fprintf(out, USAGE_MAN_TAIL("raw(8)"));
printf(USAGE_HELP_OPTIONS(16));
printf(USAGE_MAN_TAIL("raw(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions disk-utils/resizepart.c
Expand Up @@ -24,8 +24,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Tell the kernel about the new size of a partition.\n"), out);

fputs(USAGE_OPTIONS, out);
print_usage_help_options(16);
fprintf(out, USAGE_MAN_TAIL("resizepart(8)"));
printf(USAGE_HELP_OPTIONS(16));
printf(USAGE_MAN_TAIL("resizepart(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion disk-utils/sfdisk.c
Expand Up @@ -1906,7 +1906,7 @@ static void __attribute__((__noreturn__)) usage(void)

list_available_columns(out);

fprintf(out, USAGE_MAN_TAIL("sfdisk(8)"));
printf(USAGE_MAN_TAIL("sfdisk(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions disk-utils/swaplabel.c
Expand Up @@ -125,8 +125,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -L, --label <label> specify a new label\n"
" -U, --uuid <uuid> specify a new uuid\n"), out);
fputs(USAGE_SEPARATOR, out);
print_usage_help_options(21);
fprintf(out, USAGE_MAN_TAIL("swaplabel(8)"));
printf(USAGE_HELP_OPTIONS(21));
printf(USAGE_MAN_TAIL("swaplabel(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
6 changes: 2 additions & 4 deletions include/c.h
Expand Up @@ -319,13 +319,11 @@ static inline int xusleep(useconds_t usec)
#define USAGE_OPTSTR_HELP _("display this help")
#define USAGE_OPTSTR_VERSION _("print version")

#define print_usage_help_options(marg_dsc) \
printf( \
#define USAGE_HELP_OPTIONS(marg_dsc) \
"%-" #marg_dsc "s%s\n" \
"%-" #marg_dsc "s%s\n" \
, " -h, --help", USAGE_OPTSTR_HELP \
, " -V, --version", USAGE_OPTSTR_VERSION \
)
, " -V, --version", USAGE_OPTSTR_VERSION

#define USAGE_MAN_TAIL(_man) _("\nFor more details see %s.\n"), _man

Expand Down
2 changes: 1 addition & 1 deletion login-utils/chfn.c
Expand Up @@ -106,7 +106,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(USAGE_SEPARATOR, fp);
printf( " -u, --help %s\n", USAGE_OPTSTR_HELP);
printf( " -v, --version %s\n", USAGE_OPTSTR_VERSION);
fprintf(fp, USAGE_MAN_TAIL("chfn(1)"));
printf(USAGE_MAN_TAIL("chfn(1)"));
exit(EXIT_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion login-utils/chsh.c
Expand Up @@ -85,7 +85,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(USAGE_SEPARATOR, fp);
printf( " -u, --help %s\n", USAGE_OPTSTR_HELP);
printf( " -v, --version %s\n", USAGE_OPTSTR_VERSION);
fprintf(fp, USAGE_MAN_TAIL("chsh(1)"));
printf(USAGE_MAN_TAIL("chsh(1)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions login-utils/last.c
Expand Up @@ -589,8 +589,8 @@ static void __attribute__((__noreturn__)) usage(const struct last_control *ctl)
" notime|short|full|iso\n"), out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(22);
fprintf(out, USAGE_MAN_TAIL("last(1)"));
printf(USAGE_HELP_OPTIONS(22));
printf(USAGE_MAN_TAIL("last(1)"));

exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
Expand Down
4 changes: 2 additions & 2 deletions login-utils/lslogins.c
Expand Up @@ -1253,13 +1253,13 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" --wtmp-file <path> set an alternate path for wtmp\n"), out);
fputs(_(" --btmp-file <path> set an alternate path for btmp\n"), out);
fputs(USAGE_SEPARATOR, out);
print_usage_help_options(26);
printf(USAGE_HELP_OPTIONS(26));

fputs(USAGE_COLUMNS, out);
for (i = 0; i < ARRAY_SIZE(coldescs); i++)
fprintf(out, " %14s %s\n", coldescs[i].name, _(coldescs[i].help));

fprintf(out, USAGE_MAN_TAIL("lslogins(1)"));
printf(USAGE_MAN_TAIL("lslogins(1)"));

exit(EXIT_SUCCESS);
}
Expand Down
4 changes: 2 additions & 2 deletions login-utils/newgrp.c
Expand Up @@ -176,8 +176,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Log in to a new group.\n"), out);

fputs(USAGE_OPTIONS, out);
print_usage_help_options(16);
fprintf(out, USAGE_MAN_TAIL("newgrp(1)"));
printf(USAGE_HELP_OPTIONS(16));
printf(USAGE_MAN_TAIL("newgrp(1)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions login-utils/nologin.c
Expand Up @@ -30,9 +30,9 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Politely refuse a login.\n"), out);

fputs(USAGE_OPTIONS, out);
print_usage_help_options(16);
printf(USAGE_HELP_OPTIONS(16));

fprintf(out, USAGE_MAN_TAIL("nologin(8)"));
printf(USAGE_MAN_TAIL("nologin(8)"));
exit(EXIT_FAILURE);
}

Expand Down
2 changes: 1 addition & 1 deletion login-utils/su-common.c
Expand Up @@ -709,7 +709,7 @@ usage(void)
fputs (_(" -s, --shell <shell> run <shell> if /etc/shells allows it\n"), stdout);

fputs(USAGE_SEPARATOR, stdout);
print_usage_help_options(33);
printf(USAGE_HELP_OPTIONS(33));
printf(USAGE_MAN_TAIL(su_mode == SU_MODE ? "su(1)" : "runuser(1)"));
exit(EXIT_SUCCESS);
}
Expand Down
4 changes: 2 additions & 2 deletions login-utils/sulogin.c
Expand Up @@ -812,8 +812,8 @@ static void usage(void)
out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(26);
fprintf(out, USAGE_MAN_TAIL("sulogin(8)"));
printf(USAGE_HELP_OPTIONS(26));
printf(USAGE_MAN_TAIL("sulogin(8)"));
}

int main(int argc, char **argv)
Expand Down
4 changes: 2 additions & 2 deletions login-utils/utmpdump.c
Expand Up @@ -311,9 +311,9 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -f, --follow output appended data as the file grows\n"), out);
fputs(_(" -r, --reverse write back dumped data into utmp file\n"), out);
fputs(_(" -o, --output <file> write to file instead of standard output\n"), out);
print_usage_help_options(22);
printf(USAGE_HELP_OPTIONS(22));

fprintf(out, USAGE_MAN_TAIL("utmpdump(1)"));
printf(USAGE_MAN_TAIL("utmpdump(1)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions login-utils/vipw.c
Expand Up @@ -306,8 +306,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Edit the password or group file.\n"), out);

fputs(USAGE_OPTIONS, out);
print_usage_help_options(16);
fprintf(out, USAGE_MAN_TAIL("vipw(8)"));
printf(USAGE_HELP_OPTIONS(16));
printf(USAGE_MAN_TAIL("vipw(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions misc-utils/blkid.c
Expand Up @@ -103,8 +103,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_( " -n, --match-types <list> filter by filesystem type (e.g. -n vfat,ext3)\n"), out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(28);
fprintf(out, USAGE_MAN_TAIL("blkid(8)"));
printf(USAGE_HELP_OPTIONS(28));
printf(USAGE_MAN_TAIL("blkid(8)"));
exit(EXIT_SUCCESS);
}

Expand Down
4 changes: 2 additions & 2 deletions misc-utils/cal.c
Expand Up @@ -1015,8 +1015,8 @@ static void __attribute__((__noreturn__)) usage(void)
" %s\n", USAGE_COLORS_DEFAULT);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(23);
fprintf(out, USAGE_MAN_TAIL("cal(1)"));
printf(USAGE_HELP_OPTIONS(23));
printf(USAGE_MAN_TAIL("cal(1)"));

exit(EXIT_SUCCESS);
}
4 changes: 2 additions & 2 deletions misc-utils/fincore.c
Expand Up @@ -274,14 +274,14 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -r, --raw use raw output format\n"), out);

fputs(USAGE_SEPARATOR, out);
print_usage_help_options(23);
printf(USAGE_HELP_OPTIONS(23));

fprintf(out, USAGE_COLUMNS);

for (i = 0; i < ARRAY_SIZE(infos); i++)
fprintf(out, " %11s %s\n", infos[i].name, _(infos[i].help));

fprintf(out, USAGE_MAN_TAIL("fincore(1)"));
printf(USAGE_MAN_TAIL("fincore(1)"));

exit(EXIT_SUCCESS);
}
Expand Down

0 comments on commit f45f3ec

Please sign in to comment.