[PATCH:fstobdf 08/17] Add -version option to print version

Alan Coopersmith alan.coopersmith at oracle.com
Fri Nov 15 18:38:37 PST 2013


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 fstobdf.c       |   14 ++++++++++++--
 man/fstobdf.man |    6 ++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/fstobdf.c b/fstobdf.c
index bcdffbc..5fe4816 100644
--- a/fstobdf.c
+++ b/fstobdf.c
@@ -43,6 +43,10 @@ in this Software without prior written authorization from The Open Group.
  * THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include	<stdio.h>
 #include	<stdlib.h>
 #include        <string.h>
@@ -54,8 +58,10 @@ usage(const char *progName, const char *msg)
 {
     if (msg)
         fprintf(stderr, "%s: %s\n", progName, msg);
-    fprintf(stderr, "Usage: %s [-server <font server>] -fn <font name>\n",
-	    progName);
+    fprintf(stderr,
+	    "Usage: %s [-server <font server>] -fn <font name>\n"
+	    "	or: %s -version\n",
+	    progName, progName);
     exit(0);
 }
 
@@ -99,6 +105,10 @@ main(int argc, char *argv[])
 	    else
 		usage(argv[0], "-fn requires an argument");
 	}
+	else if (!strcmp(argv[i], "-version")) {
+	    printf("%s\n", PACKAGE_STRING);
+	    exit(0);
+	}
     }
 
     if (fontName == NULL)
diff --git a/man/fstobdf.man b/man/fstobdf.man
index 9c1c0eb..729a429 100644
--- a/man/fstobdf.man
+++ b/man/fstobdf.man
@@ -35,6 +35,8 @@ fstobdf \- generate BDF font from X font server
 ]
 .B \-fn
 .I fontname
+.TP
+.B fstobdf \-version
 .SH DESCRIPTION
 The \fIfstobdf\fP program reads a font from a font server and prints a BDF
 file on the standard output that may be used to recreate the font.
@@ -53,6 +55,10 @@ environment variable is used.
 .TP 8
 .B \-fn \fIfontname\fP
 This option specifies the font for which a BDF file should be generated.
+.TP 8
+.B \-version
+This option prints the program version and then exits without generating
+a BDF file.
 .SH ENVIRONMENT
 .TP 8
 .B FONTSERVER
-- 
1.7.9.2



More information about the xorg-devel mailing list