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 05/19] sfdisk: clean up usage() functions
Date: Sun,  2 Jun 2013 18:51:11 +0100	[thread overview]
Message-ID: <1370195485-27907-6-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1370195485-27907-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 f64f3cd..cac8252 100644
--- a/fdisks/sfdisk.c
+++ b/fdisks/sfdisk.c
@@ -2370,11 +2370,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"
@@ -2421,27 +2421,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
@@ -2557,7 +2559,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;
 
@@ -2578,8 +2579,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) {
@@ -2742,9 +2741,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


  parent reply	other threads:[~2013-06-02 17:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-02 17:51 [PATCH 00/19] pull: various clean ups and couple bug fixes Sami Kerola
2013-06-02 17:51 ` [PATCH 01/19] lib: remove unused code Sami Kerola
2013-06-02 17:51 ` [PATCH 02/19] lscpu: add max MHz value to make cpu governor effects more visible Sami Kerola
2013-06-02 17:51 ` [PATCH 03/19] docs: add lscpu max mhz to manual and bash completion Sami Kerola
2013-06-02 17:51 ` [PATCH 04/19] sfdisk: use libc error printing function, and symbolic exit values Sami Kerola
2013-06-07 10:20   ` Karel Zak
2013-06-02 17:51 ` Sami Kerola [this message]
2013-06-02 17:51 ` [PATCH 06/19] sfdisk: use program_invocation_short_name to determine program name Sami Kerola
2013-06-02 17:51 ` [PATCH 07/19] docs: correct sfdisk --activate instructions Sami Kerola
2013-06-02 17:51 ` [PATCH 08/19] sfdisk: remove --unhide and related functions Sami Kerola
2013-06-02 17:51 ` [PATCH 09/19] sfdisk: replace my_warn() with warnx() Sami Kerola
2013-06-02 17:51 ` [PATCH 10/19] rev: stop adding new line at the end when input does not have it Sami Kerola
2013-06-02 17:51 ` [PATCH 11/19] rev: simplify new line detection and impossible test Sami Kerola
2013-06-02 17:51 ` [PATCH 12/19] rev: reduce stream checking when closing read-only file descriptor Sami Kerola
2013-06-02 17:51 ` [PATCH 13/19] dmesg: make time format parsing to use enum bit field Sami Kerola
2013-06-03  8:45   ` Karel Zak
2013-06-02 17:51 ` [PATCH 14/19] dmesg: add --time-format option Sami Kerola
2013-06-02 17:51 ` [PATCH 15/19] dmesg: add iso-8601 time format Sami Kerola
2013-06-02 17:51 ` [PATCH 16/19] docs: add --time-format option and ISO-8601 format to manual Sami Kerola
2013-06-02 17:51 ` [PATCH 17/19] dmesg: make usage() a little bit shorter Sami Kerola
2013-06-03  8:56   ` Karel Zak
2013-06-02 17:51 ` [PATCH 18/19] dmesg: more deterministic boot time detection Sami Kerola
2013-06-03  9:35   ` Karel Zak
2013-06-02 17:51 ` [PATCH 19/19] cal: fix few type mismatches Sami Kerola
2013-06-07 10:28 ` [PATCH 00/19] pull: various clean ups and couple bug fixes Karel Zak
2013-06-07 15:45   ` Sami Kerola

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=1370195485-27907-6-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