Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14502) Fix for .serv extensions
Home

[Freeciv-Dev] (PR#14502) Fix for .serv extensions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14502) Fix for .serv extensions
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 31 Oct 2005 00:13:00 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14502 >

Currently, if you add ".serv" to your script nn.serv when you try to /read
it, the server will try to find "nn.serv.serv". This is bad. The attached
patch solves this, although there is probably a better way of implementing
it.

  - Per

Index: server/stdinhand.c
===================================================================
--- server/stdinhand.c  (revision 11204)
+++ server/stdinhand.c  (working copy)
@@ -991,8 +991,15 @@
   char tilde_filename[4096];
   char *real_filename;
 
-  my_snprintf(serv_filename, sizeof(serv_filename), "%s%s", 
-              script_filename, extension);
+  /* abuse real_filename to find if we already have a .serv extension */
+  real_filename = script_filename + strlen(script_filename) 
+                  - MIN(strlen(extension), strlen(script_filename));
+  if (strcmp(real_filename, extension) != 0) {
+    my_snprintf(serv_filename, sizeof(serv_filename), "%s%s", 
+                script_filename, extension);
+  } else {
+    sz_strlcpy(serv_filename, script_filename);
+  }
 
   if (is_restricted(caller) && !from_cmdline) {
     if (!is_safe_filename(serv_filename)) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#14502) Fix for .serv extensions, Per I. Mathisen <=