changeset 99215:e0e326adf3bc

* emacsclient.c (EXTRA_SPACE): New macro. (get_server_config, set_local_socket): Use it.
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 29 Oct 2008 15:34:06 +0000
parents 91fa9fdc5cb4
children 6969f5202385
files lib-src/ChangeLog lib-src/emacsclient.c
diffstat 2 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ChangeLog	Wed Oct 29 13:09:57 2008 +0000
+++ b/lib-src/ChangeLog	Wed Oct 29 15:34:06 2008 +0000
@@ -1,5 +1,8 @@
 2008-10-29  Juanma Barranquero  <lekktu@gmail.com>
 
+	* emacsclient.c (EXTRA_SPACE): New macro.
+	(get_server_config, set_local_socket): Use it.
+
 	* makefile.w32-in ($(BLD)/sorted-doc.$(O)): Remove spurious backslash.
 	Reported by Guillaume Conjat <gconjat.ext@orange-ftgroup.com>.
 
--- a/lib-src/emacsclient.c	Wed Oct 29 13:09:57 2008 +0000
+++ b/lib-src/emacsclient.c	Wed Oct 29 15:34:06 2008 +0000
@@ -109,6 +109,10 @@
 #ifndef NO_RETURN
 #define NO_RETURN
 #endif
+
+/* Additional space when allocating buffers for filenames, etc.  */
+#define EXTRA_SPACE 100
+
 
 /* Name used to invoke this program.  */
 char *progname;
@@ -316,8 +320,8 @@
 	{
 	  result = (char *) xmalloc (cbData);
 
-	  if ((RegQueryValueEx (hrootkey, key, NULL, type, result, &cbData) != ERROR_SUCCESS) ||
-	      (*result == 0))
+	  if ((RegQueryValueEx (hrootkey, key, NULL, type, result, &cbData) != ERROR_SUCCESS)
+	      || (*result == 0))
 	    {
 	      free (result);
 	      result = NULL;
@@ -893,14 +897,16 @@
 
       if (home)
         {
-          char *path = alloca (32 + strlen (home) + strlen (server_file));
+          char *path = alloca (strlen (home) + strlen (server_file)
+			       + EXTRA_SPACE);
           sprintf (path, "%s/.emacs.d/server/%s", home, server_file);
           config = fopen (path, "rb");
         }
 #ifdef WINDOWSNT
       if (!config && (home = egetenv ("APPDATA")))
         {
-          char *path = alloca (32 + strlen (home) + strlen (server_file));
+          char *path = alloca (strlen (home) + strlen (server_file)
+			       + EXTRA_SPACE);
           sprintf (path, "%s/.emacs.d/server/%s", home, server_file);
           config = fopen (path, "rb");
         }
@@ -1142,7 +1148,8 @@
 	tmpdir = egetenv ("TMPDIR");
 	if (!tmpdir)
 	  tmpdir = "/tmp";
-	socket_name = alloca (32 + strlen (tmpdir) + strlen (server_name));
+	socket_name = alloca (strlen (tmpdir) + strlen (server_name)
+			      + EXTRA_SPACE);
 	sprintf (socket_name, "%s/emacs%d/%s",
 		 tmpdir, (int) geteuid (), server_name);
       }
@@ -1178,8 +1185,8 @@
 	    if (pw && (pw->pw_uid != geteuid ()))
 	      {
 		/* We're running under su, apparently. */
-		socket_name = alloca (32 + strlen (tmpdir)
-				      + strlen (server_name));
+		socket_name = alloca (strlen (tmpdir) + strlen (server_name)
+				      + EXTRA_SPACE);
 		sprintf (socket_name, "%s/emacs%d/%s",
 			 tmpdir, (int) pw->pw_uid, server_name);