[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Xchat ?



Mike Small wrote:

On Fri, Feb 18, 2005 at 06:42:12PM -0800, Barry deFreese wrote:

@@ -327,12 +328,18 @@ Util_BuildList(char *word[])
static void
Util_Autoload()
{
-    char oldcwd[PATH_MAX];
+    #ifdef HAVE_GET_CURRENT_DIR_NAME
+      char *oldcwd = get_current_dir_name ();
+    #else
+      char oldcwd[PATH_MAX];
+    #endif
   const char *dir_name;
   struct dirent *ent;
   DIR *dir;
-    if (getcwd(oldcwd, PATH_MAX) == NULL)
+    #ifndef HAVE_GET_CURRENT_DIR_NAME
+      if (getcwd(oldcwd, PATH_MAX) == NULL)
       return;
+    #endif
   /* we need local filesystem encoding for chdir, opendir etc */
   dir_name = xchat_get_info(ph, "xchatdirfs");
   /* fallback for pre-2.0.9 xchat */
@@ -350,6 +357,9 @@ Util_Autoload()
   }
   closedir(dir);
   chdir(oldcwd);
+    #ifdef HAVE_GET_CURRENT_DIR_NAME
+      free(oldcwd);
+    #endif
}

What happens if get_current_dir_name returns NULL?

HAVE_GET_CURRENT_DIR_NAME won't get set and it will fall through the getcwd() code.

Michael,

I didn't play with the spacing, I just modified what Chris had already done. If everyone thinks this is OK, I can change that.

Thanks,

--
Barry deFreese
Debian 3.0r1 "Woody"
GNU/Hurd
Registered Linux "Newbie" #302256 - Hurd H4XX0r wannabe

"Programming today is a race between software engineers striving
to build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots. So far, the Universe is
winning." Rich Cook.





Reply to: