gnome-panel r11396 - trunk/applets/fish



Author: vuntz
Date: Tue Dec  9 13:15:36 2008
New Revision: 11396
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11396&view=rev

Log:
2008-12-09  Vincent Untz  <vuntz gnome org>

	* fish.c: (get_location): use g_file_read_link() instead of readlink().
	But the code is broken anyway...


Modified:
   trunk/applets/fish/ChangeLog
   trunk/applets/fish/fish.c

Modified: trunk/applets/fish/fish.c
==============================================================================
--- trunk/applets/fish/fish.c	(original)
+++ trunk/applets/fish/fish.c	Tue Dec  9 13:15:36 2008
@@ -1138,7 +1138,7 @@
 get_location (void)
 {
 	static char  location [256];
-	char         buffer [256];
+	char        *buffer;
 	FILE        *zone;
 	int          i, len, count;
 	
@@ -1151,18 +1151,22 @@
 	} 
 
 	/* New method : works for glibc 2.2 */
-	len = readlink ("/etc/localtime", buffer, sizeof (buffer));
-	if (len <= 0)
+	/* FIXME: this is broken for many distros, see the clock code */
+	buffer = g_file_read_link ("/etc/localtime", NULL);
+	if (!buffer)
 		return NULL;
 
 	for (i = len, count = 0; (i > 0) && (count != 2); i--)
 		if (buffer [i] == '/')
 			count++;
 
-	if (count != 2)
+	if (count != 2) {
 		return NULL;
+		g_free (buffer);
+	}
 
 	memcpy (location, &buffer [i + 2], len - i - 2);
+	g_free (buffer);
 
 	return location;
 }



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