linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/7] fbset: send usage to stdout and fix its exit code
@ 2006-10-09  2:40 Guillem Jover
  0 siblings, 0 replies; only message in thread
From: Guillem Jover @ 2006-10-09  2:40 UTC (permalink / raw)
  To: linux-fbdev-devel

[-- 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-10-09  4:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-09  2:40 [PATCH 3/7] fbset: send usage to stdout and fix its exit code Guillem Jover

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).