/pidgin/main: cc46ce85dc0d: Win32: don't assume backslashes in p...

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 24 14:28:37 EDT 2014


Changeset: cc46ce85dc0dcaf22543ca838fe8de636c38f507
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-24 20:28 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/cc46ce85dc0d

Description:

Win32: don't assume backslashes in path; don't use %z in printf

diffstat:

 libpurple/dnssrv.c       |  6 ++++--
 pidgin/win32/winpidgin.c |  8 +++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diffs (41 lines):

diff --git a/libpurple/dnssrv.c b/libpurple/dnssrv.c
--- a/libpurple/dnssrv.c
+++ b/libpurple/dnssrv.c
@@ -431,8 +431,10 @@ resolve(int in, int out)
 
 			srvres = g_new0(PurpleSrvResponse, 1);
 			if (strlen(name) > sizeof(srvres->hostname) - 1) {
-				purple_debug_error("dnssrv", "hostname is longer than available buffer ('%s', %zd bytes)!",
-				                   name, strlen(name));
+				purple_debug_error("dnssrv", "hostname is "
+					"longer than available buffer ('%s', %"
+					G_GSIZE_FORMAT " bytes)!",
+					name, strlen(name));
 			}
 			g_strlcpy(srvres->hostname, name, sizeof(srvres->hostname));
 			srvres->pref = pref;
diff --git a/pidgin/win32/winpidgin.c b/pidgin/win32/winpidgin.c
--- a/pidgin/win32/winpidgin.c
+++ b/pidgin/win32/winpidgin.c
@@ -157,6 +157,7 @@ static void common_dll_prep(const wchar_
 	 * MAX_PATH + 1
 	 */
 	wchar_t set_path[MAX_PATH + 24];
+	wchar_t *fslash, *bslash;
 
 	if (!check_for_gtk(path)) {
 		const wchar_t *winpath = _wgetenv(L"PATH");
@@ -194,7 +195,12 @@ static void common_dll_prep(const wchar_
 
 	wcsncpy(tmp_path, path, MAX_PATH);
 	tmp_path[MAX_PATH] = L'\0';
-	wcsrchr(tmp_path, L'\\')[0] = L'\0';
+	bslash = wcsrchr(tmp_path, L'\\');
+	fslash = wcsrchr(tmp_path, L'/');
+	if (bslash && bslash > fslash)
+		bslash[0] = L'\0';
+	else if (fslash && fslash > bslash)
+		fslash[0] = L'\0';
 	/* tmp_path now contains \path\to\Pidgin\Gtk */
 
 	_snwprintf(set_path, sizeof(set_path) / sizeof(wchar_t),



More information about the Commits mailing list