[PATCH:showfont 3/3] Add -version flag to print program version

Alan Coopersmith alan.coopersmith at oracle.com
Sat Nov 23 09:49:27 PST 2013


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 man/showfont.man |    3 +++
 showfont.c       |   12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/man/showfont.man b/man/showfont.man
index 47d077c..d513bdd 100644
--- a/man/showfont.man
+++ b/man/showfont.man
@@ -73,6 +73,9 @@ where 0 is ImageRectMin, 1 is ImageRectMaxWidth and 2 is ImageRectMax).
 .TP 8
 .B \-noprops
 Do not show the font properties.
+.TP 8
+.B \-version
+Print the program version and exit.
 .SH "SEE ALSO"
 xfs(__appmansuffix__), fslsfonts(__appmansuffix__),
 fstobdf(__appmansuffix__), xlsfonts(__appmansuffix__), X(__miscmansuffix__).
diff --git a/showfont.c b/showfont.c
index cef5f1d..21b665d 100644
--- a/showfont.c
+++ b/showfont.c
@@ -49,6 +49,10 @@ from the X Consortium.
 
 */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include	<stdio.h>
 #include	<stdlib.h>
 #include	<string.h>
@@ -354,8 +358,9 @@ usage(const char *msg)
     fprintf(stderr,
 	    "Usage: %s [-server servername] [-extents_only] [-noprops]\n"
 	    "       [-lsb] [-msb] [-LSB] [-MSB] [-unit #] [-pad #] [-bitmap_pad value]\n"
-	    "       [-start first_char] [-end last_char] -fn fontname\n",
-	    ProgramName);
+	    "       [-start first_char] [-end last_char] -fn fontname\n"
+	    "   or: %s -version\n",
+	    ProgramName, ProgramName);
     exit(1);
 }
 
@@ -424,6 +429,9 @@ main(int argc, char **argv)
 		fontname = argv[i];
 	    else
 		usage("-fn requires an argument");
+	} else if (!strcmp(argv[i], "-version")) {
+	    puts(PACKAGE_STRING);
+	    exit(0);
 	} else {
 	    char msg[128];
 	    snprintf(msg, sizeof(msg), "unrecognized argument: %s", argv[i]);
-- 
1.7.9.2



More information about the xorg-devel mailing list