[Freeciv-Dev] (PR#10411) [Patch] VERSION_STRING -> freeciv_version_stri
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#10411) [Patch] VERSION_STRING -> freeciv_version_string() |
From: |
"Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx> |
Date: |
Sat, 2 Oct 2004 05:11:05 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10411 >
Call new functions freeciv_version_string() and
freeciv_version_string_long() instead of using macro VERSION_STRING
directly. For now both functions returns exactly same string. _long() is
used only when producing output for commandline parameter '--version'.
This is step towards #4712. Should I change all related macros into
functions in one big patch or should I make separate patches like this one?
- Caz
diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c
--- freeciv/client/civclient.c 2004-10-02 11:13:52.015625000 +0300
+++ freeciv/client/civclient.c 2004-10-02 14:28:33.640625000 +0300
@@ -202,7 +202,7 @@
"\t\t\tTry \"%s -- --help\" for more.\n"), argv[0]);
exit(EXIT_SUCCESS);
} else if (is_option("--version",argv[i])) {
- fprintf(stderr, "%s %s\n", freeciv_name_version(), client_string);
+ fprintf(stderr, "%s %s\n", freeciv_name_version_long(), client_string);
exit(EXIT_SUCCESS);
} else if ((option = get_option("--log",argv,&i,argc))) {
logfile = mystrdup(option); /* never free()d */
diff -Nurd -X.diff_ignore freeciv/client/clinet.c freeciv/client/clinet.c
--- freeciv/client/clinet.c 2004-10-02 11:13:52.140625000 +0300
+++ freeciv/client/clinet.c 2004-10-02 14:21:12.765625000 +0300
@@ -601,7 +601,7 @@
proxy_url ? "" : "/",
urlpath,
proxy_url ? metaserver : "",
- VERSION_STRING,
+ freeciv_version_string(),
client_string,
machine_string,
default_tileset_name);
diff -Nurd -X.diff_ignore freeciv/client/options.c freeciv/client/options.c
--- freeciv/client/options.c 2004-10-02 11:14:05.703125000 +0300
+++ freeciv/client/options.c 2004-10-02 14:21:42.593750000 +0300
@@ -549,7 +549,7 @@
}
section_file_init(&sf);
- secfile_insert_str(&sf, VERSION_STRING, "client.version");
+ secfile_insert_str(&sf, freeciv_version_string(), "client.version");
for (i = 0; i < num_options; i++) {
client_option *o = options + i;
diff -Nurd -X.diff_ignore freeciv/common/version.c freeciv/common/version.c
--- freeciv/common/version.c 2004-10-02 11:14:08.250000000 +0300
+++ freeciv/common/version.c 2004-10-02 14:27:18.015625000 +0300
@@ -21,9 +21,35 @@
#include "version.h"
+#ifndef VERSION_STRING
+#define VER_STRINGIFY1(x) #x
+#define VER_STRINGIFY(x) VER_STRINGIFY1(x)
+#define VERSION_STRING VER_STRINGIFY(MAJOR_VERSION) "." \
+ VER_STRINGIFY(MINOR_VERSION) "." \
+ VER_STRINGIFY(PATCH_VERSION) VERSION_LABEL
+#endif /* VERSION_STRING */
+
+static const char *freeciv_version_text = VERSION_STRING;
/**********************************************************************
- ...
+ Returns version string
+***********************************************************************/
+const char *freeciv_version_string(void)
+{
+ return freeciv_version_text;
+}
+
+/**********************************************************************
+ Returns version string, possibly in more detailed form than
+ plain version_string()
+***********************************************************************/
+const char *freeciv_version_string_long(void)
+{
+ return freeciv_version_text;
+}
+
+/**********************************************************************
+ Returns string with freeciv name and version description.
***********************************************************************/
const char *freeciv_name_version(void)
{
@@ -31,10 +57,28 @@
#if IS_BETA_VERSION
my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s %s"),
- VERSION_STRING, _("(beta version)"));
+ freeciv_version_string(), _("(beta version)"));
#else
my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s"),
- VERSION_STRING);
+ freeciv_version_string());
+#endif
+
+ return msgbuf;
+}
+
+/**********************************************************************
+ Returns string with freeciv name and full version decription.
+***********************************************************************/
+const char *freeciv_name_version_long(void)
+{
+ static char msgbuf[256];
+
+#if IS_BETA_VERSION
+ my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s %s"),
+ freeciv_version_string_long(), _("(beta version)"));
+#else
+ my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s"),
+ freeciv_version_string_long());
#endif
return msgbuf;
diff -Nurd -X.diff_ignore freeciv/common/version.h freeciv/common/version.h
--- freeciv/common/version.h 2004-10-02 11:14:08.265625000 +0300
+++ freeciv/common/version.h 2004-10-02 14:26:53.546875000 +0300
@@ -50,16 +50,11 @@
#define NEXT_RELEASE_MONTH (month[6])
#endif
-#ifndef VERSION_STRING
-#define VER_STRINGIFY1(x) #x
-#define VER_STRINGIFY(x) VER_STRINGIFY1(x)
-#define VERSION_STRING VER_STRINGIFY(MAJOR_VERSION) "." \
- VER_STRINGIFY(MINOR_VERSION) "." \
- VER_STRINGIFY(PATCH_VERSION) VERSION_LABEL
-#endif
-
/* version informational strings */
+const char *freeciv_version_string(void);
+const char *freeciv_version_string_long(void);
const char *freeciv_name_version(void);
+const char *freeciv_name_version_long(void);
const char *word_version(void);
const char *freeciv_motto(void);
diff -Nurd -X.diff_ignore freeciv/manual/civmanual.c freeciv/manual/civmanual.c
--- freeciv/manual/civmanual.c 2004-10-02 11:14:37.921875000 +0300
+++ freeciv/manual/civmanual.c 2004-10-02 14:24:05.015625000 +0300
@@ -125,7 +125,7 @@
switch (manuals) {
case MANUAL_SETTINGS:
- fprintf(doc, "<h1>Freeciv %s server options</h1>\n\n", VERSION_STRING);
+ fprintf(doc, "<h1>Freeciv %s server options</h1>\n\n",
freeciv_version_string());
for (i = 0; settings[i].name; i++) {
struct settings_s *op = &settings[i];
static struct astring abuf = ASTRING_INIT;
@@ -187,7 +187,7 @@
case MANUAL_COMMANDS:
fprintf(doc, "<h1>Freeciv %s server commands</h1>\n\n",
- VERSION_STRING);
+ freeciv_version_string());
for (i = 0; i < CMD_NUM; i++) {
const struct command *cmd = &commands[i];
@@ -216,7 +216,7 @@
case MANUAL_TERRAIN:
fprintf(doc, _("<h1>Freeciv %s terrain help</h1>\n\n"),
- VERSION_STRING);
+ freeciv_version_string());
fprintf(doc, _("<table border=1><tr><th>Terrain</th>"));
fprintf(doc, _("<th>Food/ Shield/ Trade</th>"));
fprintf(doc, _("<th>Special 1</th><th>Food/ Shield/ Trade</th>"));
@@ -294,7 +294,7 @@
break;
case MANUAL_BUILDINGS:
- fprintf(doc, _("<h1>Buildings help for %s</h1>\n\n"), VERSION_STRING);
+ fprintf(doc, _("<h1>Buildings help for %s</h1>\n\n"),
freeciv_version_string());
impr_type_iterate(id) {
struct impr_type *pimpr = get_improvement_type(id);
char buf[64000];
@@ -323,7 +323,7 @@
break;
case MANUAL_WONDERS:
- fprintf(doc, _("<h1>Wonder help for %s</h1>\n\n"), VERSION_STRING);
+ fprintf(doc, _("<h1>Wonder help for %s</h1>\n\n"),
freeciv_version_string());
impr_type_iterate(id) {
struct impr_type *pimpr = get_improvement_type(id);
char buf[64000];
diff -Nurd -X.diff_ignore freeciv/server/civserver.c freeciv/server/civserver.c
--- freeciv/server/civserver.c 2004-10-02 11:14:41.281250000 +0300
+++ freeciv/server/civserver.c 2004-10-02 14:28:02.609375000 +0300
@@ -126,7 +126,7 @@
}
if (showvers && !showhelp) {
- fprintf(stderr, "%s \n", freeciv_name_version());
+ fprintf(stderr, "%s \n", freeciv_name_version_long());
exit(EXIT_SUCCESS);
}
con_write(C_VERSION, _("This is the server for %s"), freeciv_name_version());
diff -Nurd -X.diff_ignore freeciv/server/meta.c freeciv/server/meta.c
--- freeciv/server/meta.c 2004-10-02 11:14:43.093750000 +0300
+++ freeciv/server/meta.c 2004-10-02 14:18:18.031250000 +0300
@@ -265,7 +265,8 @@
desc[0]='\0';
cat_snprintf(desc, sizeof(desc), "Freeciv\n");
- cat_snprintf(desc, sizeof(desc), VERSION_STRING"\n");
+ cat_snprintf(desc, sizeof(desc), freeciv_version_string());
+ cat_snprintf(desc, sizeof(desc), "\n");
/* note: the following strings are not translated here;
we mark them so they may be translated when received by a client */
switch(server_state) {
diff -Nurd -X.diff_ignore freeciv/server/report.c freeciv/server/report.c
--- freeciv/server/report.c 2004-10-02 11:14:43.562500000 +0300
+++ freeciv/server/report.c 2004-10-02 14:18:49.937500000 +0300
@@ -950,7 +950,7 @@
freelog(LOG_ERROR, "Can't open scorelog file for creation!");
goto log_civ_score_disable;
}
- fprintf(fp, "%s%s\n", scorelog_magic, VERSION_STRING);
+ fprintf(fp, "%s%s\n", scorelog_magic, freeciv_version_string());
fprintf(fp,
"\n"
"# For a specification of the format of this see
doc/README.scorelog or \n"
diff -Nurd -X.diff_ignore freeciv/server/stdinhand.c freeciv/server/stdinhand.c
--- freeciv/server/stdinhand.c 2004-10-02 11:14:44.093750000 +0300
+++ freeciv/server/stdinhand.c 2004-10-02 14:19:34.046875000 +0300
@@ -934,7 +934,7 @@
int i;
fprintf(script_file,
- "#FREECIV SERVER COMMAND FILE, version %s\n", VERSION_STRING);
+ "#FREECIV SERVER COMMAND FILE, version %s\n", freeciv_version_string());
fputs("# These are server options saved from a running civserver.\n",
script_file);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#10411) [Patch] VERSION_STRING -> freeciv_version_string(),
Marko Lindqvist <=
|
|