[pacman-dev,v3,3/5] pacman-conf: Make myname and myver into cpp macros MYNAME and MYVER

Message ID 20180211041513.18835-3-iff@escondida.tk
State Rejected, archived
Headers show
Series [pacman-dev,v3,1/5] pacman-conf.c: accept short options | expand

Commit Message

Ivy Foster Feb. 11, 2018, 4:15 a.m. UTC
From: Ivy Foster <iff@escondida.tk>

This allows MYNAME to be used in place of the literal string
"pacman-conf" in usage

Signed-off-by: Ivy Foster <iff@escondida.tk>
---
 src/pacman/pacman-conf.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Patch

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 9136b262..8985b326 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -21,7 +21,8 @@ 
 #include <string.h>
 #include "conf.h"
 
-const char *myname = "pacman-conf", *myver = "1.0.0";
+#define MYNAME "pacman-conf"
+#define MYVER "1.0.0"
 
 alpm_list_t *directives = NULL;
 char sep = '\n', *repo_name = NULL;
@@ -37,9 +38,9 @@  static void cleanup(void)
 static void usage(FILE *stream)
 {
 	static const char help[] =
-		"pacman-conf: query pacman's configuration file\n"
-		"usage: pacman-conf [options] [directive]\n"
-		"       pacman-conf [ { -l, --repo-list } | { -h, --help } | { -V, --version } ]\n"
+		MYNAME ": query pacman's configuration file\n"
+		"usage: " MYNAME " [options] [directive]\n"
+		"       " MYNAME " [ { -l, --repo-list } | { -h, --help } | { -V, --version } ]\n"
 		"options:\n"
 		"    -c, --config=<file>  Read configuration from <file>\n"
 		"    -h, --help           Print help\n"
@@ -90,7 +91,7 @@  static void parse_opts(int argc, char **argv)
 				cleanup();
 				exit(0);
 			case 'V':
-				printf("%s v%s\n", myname, myver);
+				printf("%s v%s\n", MYNAME, MYVER);
 				cleanup();
 				exit(0);
 				break;