public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 03/15] sfdisk: clean up usage() functions
Date: Sun, 16 Jun 2013 19:53:44 +0100	[thread overview]
Message-ID: <1371408836-16663-4-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1371408836-16663-1-git-send-email-kerolasa@iki.fi>

Includes removal of unhide usage function, which was never implemented.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 fdisks/sfdisk.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/fdisks/sfdisk.c b/fdisks/sfdisk.c
index cbbdfd5..96b4de2 100644
--- a/fdisks/sfdisk.c
+++ b/fdisks/sfdisk.c
@@ -2356,11 +2356,11 @@ read_input(char *dev, int interactive, struct disk_desc *z) {
  */
 static void usage(FILE * out)
 {
-	fputs(_("\nUsage:\n"), out);
+	fputs(USAGE_HEADER, out);
 	fprintf(out,
 		_(" %s [options] <device> [...]\n"),  program_invocation_short_name);
 
-	fputs(_("\nOptions:\n"), out);
+	fputs(USAGE_OPTIONS, out);
 	fputs(_(" -s, --show-size           list size of a partition\n"
 		" -c, --id                  change or print partition Id\n"
 		"     --change-id           change Id\n"
@@ -2407,27 +2407,29 @@ static void usage(FILE * out)
 	fputs(_("\nOverride the detected geometry using:\n"
 		" -C, --cylinders <number>  set the number of cylinders to use\n"
 		" -H, --heads <number>      set the number of heads to use\n"
-		" -S, --sectors <number>    set the number of sectors to use\n\n"), out);
+		" -S, --sectors <number>    set the number of sectors to use\n"), out);
 
+	fprintf(out, USAGE_MAN_TAIL("sfdisk(8)"));
 	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
 static void
-activate_usage(char *progn) {
-    puts(_("Usage:"));
-    printf(_("%s device		 list active partitions on device\n"), progn);
-    printf(_("%s device n1 n2 ... activate partitions n1 ..., inactivate the rest\n"),
-	   progn);
-    printf(_("%s -An device	 activate partition n, inactivate the other ones\n"),
-	   program_invocation_short_name);
+activate_usage(void) {
+    char *p;
+    if (!strcmp(program_invocation_short_name, "activate"))
+	p = " ";
+    else
+	p = " --activate=";
+    fputs(USAGE_HEADER, stderr);
+    fputs(USAGE_SEPARATOR, stderr);
+    fprintf(stderr, _(" %s%sdevice            list active partitions on device\n"),
+	   program_invocation_short_name, p);
+    fprintf(stderr, _(" %s%sdevice n1 n2 ...  activate partitions n1 ..., inactivate the rest\n"),
+	   program_invocation_short_name, p);
+    fprintf(stderr, USAGE_MAN_TAIL("sfdisk(8)"));
     exit(EXIT_FAILURE);
 }
 
-static void
-unhide_usage(char *progn __attribute__ ((__unused__))) {
-    exit(1);
-}
-
 static const char short_opts[] = "cdfghilnqsu:vx1A::C:DGH:I:LN:O:RS:TU::V";
 
 #define PRINT_ID 0400
@@ -2543,7 +2545,6 @@ main(int argc, char **argv) {
     int activate = 0;
     int do_id = 0;
     int unhide = 0;
-    int fdisk = 0;
     char *activatearg = 0;
     char *unhidearg = 0;
 
@@ -2564,8 +2565,6 @@ main(int argc, char **argv) {
     else if (!strcmp(progn, "unhide"))
 	unhide = 1;		/* equivalent to `sfdisk -U' */
 #endif
-    else
-	fdisk = 1;
 
     while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
 	switch (c) {
@@ -2728,9 +2727,7 @@ main(int argc, char **argv) {
 
     if (optind == argc) {
 	if (activate)
-	    activate_usage(fdisk ? "sfdisk -A" : progn);
-	else if (unhide)
-	    unhide_usage(fdisk ? "sfdisk -U" : progn);
+	    activate_usage();
 	else
 	    usage(stderr);
     }
-- 
1.8.3.1


  parent reply	other threads:[~2013-06-16 18:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16 18:53 [PATCH 00/15] pull: sfdisk and dmesg resubmission, plus bits and bobs Sami Kerola
2013-06-16 18:53 ` [PATCH 01/15] renice: exit with non-zero value when arguments cause warnings Sami Kerola
2013-06-16 18:53 ` [PATCH 02/15] sfdisk: use libc error printing function, and symbolic exit values Sami Kerola
2013-06-16 18:53 ` Sami Kerola [this message]
2013-06-16 18:53 ` [PATCH 04/15] sfdisk: use program_invocation_short_name to determine program name Sami Kerola
2013-06-16 18:53 ` [PATCH 05/15] docs: correct sfdisk --activate instructions Sami Kerola
2013-06-16 18:53 ` [PATCH 06/15] sfdisk: remove --unhide and related functions Sami Kerola
2013-06-16 18:53 ` [PATCH 07/15] sfdisk: replace my_warn() with warnx() Sami Kerola
2013-06-16 18:53 ` [PATCH 08/15] dmesg: convert time format bitfield to enum Sami Kerola
2013-07-01  9:36   ` Karel Zak
2013-06-16 18:53 ` [PATCH 09/15] dmesg: add --time-format option Sami Kerola
2013-06-16 18:53 ` [PATCH 10/15] dmesg: add iso-8601 time format Sami Kerola
2013-07-01  9:25   ` Karel Zak
2013-07-01 10:54     ` Sami Kerola
2013-06-16 18:53 ` [PATCH 11/15] docs: add --time-format option and ISO-8601 format to manual Sami Kerola
2013-06-16 18:53 ` [PATCH 12/15] dmesg: regroup time related options close to each other Sami Kerola
2013-06-16 18:53 ` [PATCH 13/15] sd-daemon: update files taken from systemd project Sami Kerola
2013-06-16 18:53 ` [PATCH 14/15] hexdump: remove unnecessary global variables Sami Kerola
2013-09-02 23:22   ` Dave Reisner
2013-09-03  7:15     ` Sami Kerola
2013-09-03  8:29       ` Karel Zak
2013-06-16 18:53 ` [PATCH 15/15] hexdump: use simple printing functions when possible Sami Kerola
2013-07-01  9:01   ` Karel Zak
2013-07-01 10:58     ` Sami Kerola
2013-06-17 12:31 ` [PATCH 00/15] pull: sfdisk and dmesg resubmission, plus bits and bobs Karel Zak
2013-06-17 20:14   ` Sami Kerola
2013-07-01  9:39 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371408836-16663-4-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox