From 3f0ac58755c385f5fd31ca4b4bd13e9ad60ad7a0 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 12 Jun 2013 17:28:26 +0200 Subject: [PATCH] fdisk: cleanup usage() Signed-off-by: Karel Zak --- fdisks/fdisk.c | 56 +++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 0087c235e4..b160aa0a2e 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -1,14 +1,14 @@ -/* fdisk.c -- Partition table manipulator for Linux. - * +/* * Copyright (C) 1992 A. V. Le Blanc (LeBlanc@mcc.ac.uk) * Copyright (C) 2012 Davidlohr Bueso * + * Copyright (C) 2007-2013 Karel Zak + * * This program is free software. You can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation: either version 1 or * (at your option) any later version. */ - #include #include #include @@ -22,6 +22,7 @@ #include #include +#include "c.h" #include "xalloc.h" #include "nls.h" #include "rpmatch.h" @@ -40,15 +41,38 @@ #include "fdiskbsdlabel.h" #ifdef HAVE_LINUX_COMPILER_H -#include +# include #endif #ifdef HAVE_LINUX_BLKPG_H -#include +# include #endif - int nowarn = 0; /* no warnings for fdisk -l/-s */ +static void __attribute__ ((__noreturn__)) usage(FILE *out) +{ + fputs(USAGE_HEADER, out); + + fprintf(out, + _(" %1$s [options] change partition table\n" + " %1$s [options] -l list partition table(s)\n" + " %1$s -s give partition size(s) in blocks\n"), + program_invocation_short_name); + + fputs(USAGE_OPTIONS, out); + fputs(_(" -b sector size (512, 1024, 2048 or 4096)\n"), out); + fputs(_(" -c[=] compatible mode: 'dos' or 'nondos' (default)\n"), out); + fputs(_(" -h print this help text\n"), out); + fputs(_(" -u[=] display units: 'cylinders' or 'sectors' (default)\n"), out); + fputs(_(" -v print program version\n"), out); + fputs(_(" -C specify the number of cylinders\n"), out); + fputs(_(" -H specify the number of heads\n"), out); + fputs(_(" -S specify the number of sectors per track\n"), out); + + fprintf(out, USAGE_MAN_TAIL("fdisk(8)")); + exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); +} + void toggle_units(struct fdisk_context *cxt) { fdisk_context_set_unit(cxt, @@ -60,26 +84,6 @@ void toggle_units(struct fdisk_context *cxt) fdisk_info(cxt, _("Changing display/entry units to sectors.")); } - -static void __attribute__ ((__noreturn__)) usage(FILE *out) -{ - fprintf(out, _("Usage:\n" - " %1$s [options] change partition table\n" - " %1$s [options] -l list partition table(s)\n" - " %1$s -s give partition size(s) in blocks\n" - "\nOptions:\n" - " -b sector size (512, 1024, 2048 or 4096)\n" - " -c[=] compatible mode: 'dos' or 'nondos' (default)\n" - " -h print this help text\n" - " -u[=] display units: 'cylinders' or 'sectors' (default)\n" - " -v print program version\n" - " -C specify the number of cylinders\n" - " -H specify the number of heads\n" - " -S specify the number of sectors per track\n" - "\n"), program_invocation_short_name); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); -} - struct partition * get_part_table(int i) { return ptes[i].part_table; -- 2.47.2