linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guillem Jover <guillem@debian.org>
To: linux-fbdev-devel@lists.sourceforge.net
Subject: [PATCH 3/7] fbset: send usage to stdout and fix its exit code
Date: Mon, 9 Oct 2006 05:40:59 +0300	[thread overview]
Message-ID: <20061009024059.GC9011@zulo.hadrons.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

Hi,

This one makes Usage output to stdout instead of stderr, it also sends
a proper exit code, depending if it has been called due to an error or
the user asking for it via --help.

regards,
guillem

[-- Attachment #2: fbset_03_usage.patch --]
[-- Type: text/plain, Size: 2268 bytes --]

Index: fbset.c
===================================================================
--- fbset.c.orig	2006-10-09 05:29:45.000000000 +0300
+++ fbset.c	2006-10-09 05:33:33.000000000 +0300
@@ -229,7 +229,7 @@ static void ModifyVideoMode(struct Video
 static void DisplayVModeInfo(struct VideoMode *vmode);
 static void DisplayFBInfo(struct fb_fix_screeninfo *fix);
 static int FillScanRates(struct VideoMode *vmode);
-static void Usage(void) __attribute__ ((noreturn));
+static void Usage(int status) __attribute__ ((noreturn));
 int main(int argc, char *argv[]);
 
 
@@ -829,10 +829,12 @@ static int FillScanRates(struct VideoMod
      *  Print the Usage Template and Exit
      */
 
-static void Usage(void)
+static void Usage(int status)
 {
     puts(VERSION);
-    Die("\nUsage: %s [options] [mode]\n\n"
+    printf(
+	"Usage: %s [options] [mode]\n"
+	"\n"
 	"Valid options:\n"
 	"  General options:\n"
 	"    -h, --help         : display this usage information\n"
@@ -887,6 +889,7 @@ static void Usage(void)
 	"    -step <value>      : step increment (in pixels or pixel lines)\n"
 	"                         (default is 8 horizontal, 2 vertical)\n",
 	ProgramName);
+	exit(status);
 }
 
 
@@ -910,7 +913,7 @@ int main(int argc, char *argv[])
     while (--argc > 0) {
 	argv++;
 	if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help"))
-	    Usage();
+	    Usage(0);
 	else if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--verbose"))
 	    Opt_verbose = 1;
 	else if (!strcmp(argv[0], "-V") || !strcmp(argv[0], "--version"))
@@ -937,7 +940,7 @@ int main(int argc, char *argv[])
 		argc -= 5;
 		argv += 5;
 	    } else
-		Usage();
+		Usage(1);
 	} else if (!strcmp(argv[0], "-t") || !strcmp(argv[0], "--timings")) {
 	    if (argc > 7) {
 		Opt_pixclock = argv[1];
@@ -951,7 +954,7 @@ int main(int argc, char *argv[])
 		argc -= 7;
 		argv += 7;
 	    } else
-		Usage();
+		Usage(1);
 	} else if (!strcmp(argv[0], "-match")) {
 	    Opt_matchyres = argv[0];
 	    Opt_change = 1;
@@ -965,12 +968,12 @@ int main(int argc, char *argv[])
 		    Opt_change |= Options[i].change;
 		    argv++;
 		} else
-		    Usage();
+		    Usage(1);
 	    } else if (!Opt_modename) {
 		Opt_modename = argv[0];
 		Opt_change = 1;
 	    } else
-		Usage();
+		Usage(1);
 	}
     }
 

[-- Attachment #3: Type: text/plain, Size: 348 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 182 bytes --]

_______________________________________________
Linux-fbdev-devel mailing list
Linux-fbdev-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel

                 reply	other threads:[~2006-10-09  4:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20061009024059.GC9011@zulo.hadrons.org \
    --to=guillem@debian.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /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;
as well as URLs for NNTP newsgroup(s).