pidgin: a578934a: Update the Perl plugin loader to work wi...

datallah at pidgin.im datallah at pidgin.im
Sun Jul 27 20:56:51 EDT 2008


-----------------------------------------------------------------
Revision: a578934a35307604b6eeef4b6b4b07a17901afcb
Ancestor: 3606501cd042c19380cd4037e72ebda548b727b8
Author: datallah at pidgin.im
Date: 2008-07-28T00:52:54
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a578934a35307604b6eeef4b6b4b07a17901afcb

Modified files:
        ChangeLog.win32 libpurple/plugins/perl/Makefile.mingw
        libpurple/plugins/perl/common/Makefile.mingw
        libpurple/plugins/perl/perl-common.c
        libpurple/plugins/perl/perl-common.h
        libpurple/plugins/perl/perl.c libpurple/win32/global.mak
        pidgin/plugins/perl/common/Makefile.mingw
        pidgin/win32/nsis/pidgin-installer.nsi
        pidgin/win32/winpidgin.c

ChangeLog: 

Update the Perl plugin loader to work with Perl 5.10.
I don't think this will break compiling with older versions (note that Perl
micro versions are not binary compatible).
Update the win32 build to use (and require and upgrade to Perl 5.10).
Fixes #5137

-------------- next part --------------
============================================================
--- ChangeLog.win32	9e813aec6472cc181150f70c954ae1b32bf44ce3
+++ ChangeLog.win32	2b72cb7558ad521a5053eb22d18fd3c0d4dede65
@@ -1,5 +1,7 @@ version 2.5.0 (??/??/2008):
 version 2.5.0 (??/??/2008):
 	* Don't install the GSSAPI SASL plugin on NT4 to avoid an error popup.
+	* Upgrade to Perl 5.10 (System Perl runtime must be upgraded for Perl
+	  plugins to continue to work).
 
 version 2.4.3 (07/01/2008):
 	* No changes
============================================================
--- libpurple/plugins/perl/Makefile.mingw	23740a27180b2b42d49e8d603591fea1beff967e
+++ libpurple/plugins/perl/Makefile.mingw	58b2d79403a5bc3bb8f1051709bd2c8d917198c6
@@ -47,7 +47,7 @@ LIBS =	\
 			-lws2_32 \
 			-lintl \
 			-lpurple \
-			-lperl58
+			-lperl510
 
 include $(PIDGIN_COMMON_RULES)
 
============================================================
--- libpurple/plugins/perl/common/Makefile.mingw	f748523212e430553c00a46fc38a9c926cf96262
+++ libpurple/plugins/perl/common/Makefile.mingw	c9cf82c7b34294215269cc67ce46719fcc6e1650
@@ -5,6 +5,7 @@ PIDGIN_TREE_TOP := ../../../..
 #
 
 PIDGIN_TREE_TOP := ../../../..
+GCCWARNINGS := -Wno-comment -Waggregate-return -Wcast-align -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wextra -Wno-sign-compare -Wno-unused-parameter -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wundef -Wno-unused
 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
 
 TARGET = Purple
@@ -12,8 +13,6 @@ PERL_PLUGIN_TOP := ..
 EXTUTILS ?= C:/perl/lib/ExtUtils
 PERL_PLUGIN_TOP := ..
 
-CFLAGS += -Wno-comment -Wno-unused
-
 ##
 ## INCLUDE PATHS
 ##
@@ -77,7 +76,7 @@ OBJECTS = $(C_FILES:%.c=%.o)
 ##
 ## LIBRARIES
 ##
-LIBS =			-lperl58 \
+LIBS =			-lperl510 \
 			-lperl \
 			-lpurple \
 			-lglib-2.0
============================================================
--- libpurple/plugins/perl/perl-common.c	6b970966474ea7eb29f3e7fa1a9f8f935176fff7
+++ libpurple/plugins/perl/perl-common.c	c3e097d6a584a3413073f7ea0a45125535b59be2
@@ -32,7 +32,10 @@ static MGVTBL vtbl_free_object =
 
 static MGVTBL vtbl_free_object =
 {
-	NULL, NULL, NULL, NULL, magic_free_object, NULL, NULL
+	0, 0, 0, 0, magic_free_object, 0, 0
+#if PERL_API_REVISION > 5 || (PERL_API_REVISION == 5 && PERL_API_VERSION >= 10)
+	, 0
+#endif
 };
 
 static SV *
============================================================
--- libpurple/plugins/perl/perl-common.h	fe675694322560f37e1f861cacaae9ba7572882f
+++ libpurple/plugins/perl/perl-common.h	5225c7017bdf6dfe6a99c31b5ccec57f27fd3da2
@@ -5,9 +5,9 @@
 #ifdef _WIN32
 #undef pipe
 #endif
+#include <perl.h>
 #include <XSUB.h>
 #include <EXTERN.h>
-#include <perl.h>
 
 /* XXX: perl defines it's own _ but I think it's safe to undef it */
 #undef _
============================================================
--- libpurple/plugins/perl/perl.c	6dbed55fa8823e5c3a2a7b659177c960bc28e6cf
+++ libpurple/plugins/perl/perl.c	c1868472d4e3416131697946cd96ab6411e1cfaa
@@ -67,6 +67,10 @@
 #undef group
 
 /* perl module support */
+#ifdef _WIN32
+EXTERN_C void boot_Win32CORE (pTHX_ CV* cv);
+#endif
+
 #ifdef OLD_PERL
 extern void boot_DynaLoader _((CV * cv));
 #else
@@ -127,10 +131,14 @@ xs_init(pTHX)
 #endif
 {
 	char *file = __FILE__;
+	dXSUB_SYS;
 
 	/* This one allows dynamic loading of perl modules in perl scripts by
 	 * the 'use perlmod;' construction */
 	newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+#ifdef _WIN32
+	newXS("Win32CORE::bootstrap", boot_Win32CORE, file);
+#endif
 }
 
 static void
@@ -240,18 +248,26 @@ probe_perl_plugin(PurplePlugin *plugin)
 static gboolean
 probe_perl_plugin(PurplePlugin *plugin)
 {
-	/* XXX This would be much faster if I didn't create a new
-	 *     PerlInterpreter every time I probed a plugin */
 
-	PerlInterpreter *prober = perl_alloc();
-	char *argv[] = {"", plugin->path };
+	char *args[] = {"", plugin->path };
+	char **argv = args;
+	int argc = 2;
+	PerlInterpreter *prober;
 	gboolean status = TRUE;
 	HV *plugin_info;
+
+	PERL_SYS_INIT(&argc, &argv);
+
+	/* XXX This would be much faster if we didn't create a new
+	 *     PerlInterpreter every time we probe a plugin */
+	prober = perl_alloc();
+
 	PERL_SET_CONTEXT(prober);
+
 	PL_perl_destruct_level = 1;
 	perl_construct(prober);
 
-	perl_parse(prober, xs_init, 2, argv, NULL);
+	perl_parse(prober, xs_init, argc, argv, NULL);
 
 	perl_run(prober);
 
@@ -578,7 +594,7 @@ static PurplePluginLoaderInfo loader_inf
 	load_perl_plugin,                                 /**< load           */
 	unload_perl_plugin,                               /**< unload         */
 	destroy_perl_plugin,                              /**< destroy        */
-	
+
 	/* padding */
 	NULL,
 	NULL,
============================================================
--- libpurple/win32/global.mak	e7a9cceba61381eb7f05b3fffef39b1e046565c6
+++ libpurple/win32/global.mak	4074dd87afde79829c706e91ba1f55db4b00be8e
@@ -19,7 +19,7 @@ NSS_TOP ?= $(WIN32_DEV_TOP)/nss-3.11.4
 MEANWHILE_TOP ?= $(WIN32_DEV_TOP)/meanwhile-1.0.2_daa1
 NSPR_TOP ?= $(WIN32_DEV_TOP)/nspr-4.6.4
 NSS_TOP ?= $(WIN32_DEV_TOP)/nss-3.11.4
-PERL_LIB_TOP ?= $(WIN32_DEV_TOP)/perl58
+PERL_LIB_TOP ?= $(WIN32_DEV_TOP)/perl-5.10.0
 SILC_TOOLKIT ?= $(WIN32_DEV_TOP)/silc-toolkit-1.1.5
 TCL_LIB_TOP ?= $(WIN32_DEV_TOP)/tcl-8.4.5
 GSTREAMER_TOP ?= $(WIN32_DEV_TOP)/gstreamer-0.10.13
@@ -56,7 +56,7 @@ PIDGIN_PORTABLE_EXE := $(PIDGIN_TOP)/pid
 PIDGIN_EXE := $(PIDGIN_TOP)/pidgin.exe
 PIDGIN_PORTABLE_EXE := $(PIDGIN_TOP)/pidgin-portable.exe
 
-GCCWARNINGS := -Waggregate-return -Wcast-align -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wextra -Wno-sign-compare -Wno-unused-parameter -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wundef
+GCCWARNINGS ?= -Waggregate-return -Wcast-align -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wextra -Wno-sign-compare -Wno-unused-parameter -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wundef
 
 # parse the version number from the configure.ac file if it is newer
 #m4_define([purple_major_version], [2])
============================================================
--- pidgin/plugins/perl/common/Makefile.mingw	008a093f381805e4ab8cd11d121a503d3a263df6
+++ pidgin/plugins/perl/common/Makefile.mingw	7bc4d933fdca10f9caa97865a57624a6573ef679
@@ -5,13 +5,12 @@ PIDGIN_TREE_TOP := ../../../..
 #
 
 PIDGIN_TREE_TOP := ../../../..
+GCCWARNINGS := -Wno-comment -Waggregate-return -Wcast-align -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wextra -Wno-sign-compare -Wno-unused-parameter -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wundef -Wno-unused
 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
 
 TARGET = Pidgin
 EXTUTILS ?= C:/perl/lib/ExtUtils
 
-CFLAGS += -Wno-comment -Wno-unused
-
 ##
 ## INCLUDE PATHS
 ##
@@ -72,7 +71,7 @@ OBJECTS = $(C_FILES:%.c=%.o)
 ##
 ## LIBRARIES
 ##
-LIBS =			-lperl58 \
+LIBS =			-lperl510 \
 			-lperl \
 			-lpurple \
 			-lpidgin \
============================================================
--- pidgin/win32/nsis/pidgin-installer.nsi	ffe4ba43d23b91bdce21137cbc96b26b6f782101
+++ pidgin/win32/nsis/pidgin-installer.nsi	5a2f708af90f67e3ee3e088b3f72cc2fb55b26bf
@@ -72,7 +72,7 @@ SetDateSave on
 !define GTK_MIN_VERSION				"2.6.10"
 !define GTK_REG_KEY				"SOFTWARE\GTK\2.0"
 !define PERL_REG_KEY				"SOFTWARE\Perl"
-!define PERL_DLL				"perl58.dll"
+!define PERL_DLL				"perl510.dll"
 !define GTK_DEFAULT_INSTALL_PATH		"$COMMONFILES\GTK\2.0"
 !define GTK_RUNTIME_INSTALLER			"..\..\..\..\gtk_installer\gtk-runtime*.exe"
 
============================================================
--- pidgin/win32/winpidgin.c	8627e53a18f8d22a5822d5e631879c5c173093c2
+++ pidgin/win32/winpidgin.c	1373b3dff229c97a3e48e3167789c1d35c3b376b
@@ -89,9 +89,8 @@ static BOOL read_reg_string(HKEY key, ch
 			const char *err_msg = get_win32_error_message(retv);
 
 			printf("Could not read reg key '%s' subkey '%s' value: '%s'.\nMessage: (%ld) %s\n",
-					((key == HKEY_LOCAL_MACHINE) ? "HKLM" :
-					 (key == HKEY_CURRENT_USER) ? "HKCU" :
-					 "???"),
+					(key == HKEY_LOCAL_MACHINE) ? "HKLM"
+					 : ((key == HKEY_CURRENT_USER) ? "HKCU" : "???"),
 					sub_key, val_name, retv, err_msg);
 		}
 		RegCloseKey(hkey);
@@ -216,13 +215,13 @@ static void portable_mode_dll_prep(const
 
 	/* Set up the settings dir base to be \\path\to
 	 * The actual settings dir will be \\path\to\.purple */
-	snprintf(path2, sizeof(path2), "PURPLEHOME=%s", path);
+	_snprintf(path2, sizeof(path2), "PURPLEHOME=%s", path);
 	printf("Setting settings dir: %s\n", path2);
-	putenv(path2);
+	_putenv(path2);
 
-	snprintf(path2, sizeof(path2), "PIDGIN_ASPELL_DIR=%s\\Aspell\\bin", path);
+	_snprintf(path2, sizeof(path2), "PIDGIN_ASPELL_DIR=%s\\Aspell\\bin", path);
 	printf("%s\n", path2);
-	putenv(path2);
+	_putenv(path2);
 
 	/* set the GTK+ path to be \\path\to\GTK\bin */
 	strcat(path, "\\GTK\\bin");
@@ -437,11 +436,52 @@ static void winpidgin_set_locale() {
 
 	locale = winpidgin_get_locale();
 
-	snprintf(envstr, 25, "LANG=%s", locale);
+	_snprintf(envstr, 25, "LANG=%s", locale);
 	printf("Setting locale: %s\n", envstr);
-	putenv(envstr);
+	_putenv(envstr);
 }
 
+static void winpidgin_add_perl_to_path() {
+	char perl_path[MAX_PATH + 1];
+	DWORD plen = sizeof(perl_path);
+
+	printf("%s", "Looking for Perl... ");
+
+	if (read_reg_string(HKEY_LOCAL_MACHINE, "SOFTWARE\\Perl", "",
+			    (LPBYTE) &perl_path, &plen)) {
+		const char *path = getenv("PATH");
+		/* Enough to add "PATH=" + ";"  + perl_path + "\\bin" + \0 */
+
+		/* We *could* check for perl510.dll, but it seems unnecessary. */
+
+		printf("found in '%s'.\n", perl_path);
+
+		if (perl_path[strlen(perl_path) - 1] != '\\') {
+			strcat(perl_path, "\\");
+		}
+		strcat(perl_path, "bin");
+
+		if (!strstr(path, perl_path)) {
+			int newlen = (path ? strlen(path) : 0) + strlen(perl_path) + 10;
+			char *newpath = malloc(newlen);
+			*newpath = '\0';
+
+			_snprintf(newpath, newlen, "PATH=%s%s%s",
+				  path ? path : "",
+				  path ? ";" : "",
+				  perl_path);
+
+			printf("Adding Perl to PATH: %s\n", newpath);
+
+			_putenv(newpath);
+			free(newpath);
+		} else
+			printf("%s\n", "Perl already in PATH.");
+	} else
+		printf("%s", "not found.\n");
+
+}
+
 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13)
 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14)
 
@@ -598,10 +638,10 @@ WinMain (struct HINSTANCE__ *hInstance, 
 	} else {
 		DWORD dw = GetLastError();
 		const char *err_msg = get_win32_error_message(dw);
-		snprintf(errbuf, 512,
+		_snprintf(errbuf, 512,
 			"Error getting module filename.\nError: (%u) %s",
 			(UINT) dw, err_msg);
-		printf("%s", errbuf);
+		printf("%s\n", errbuf);
 		MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST);
 		pidgin_dir[0] = '\0';
 	}
@@ -631,6 +671,9 @@ WinMain (struct HINSTANCE__ *hInstance, 
 		dll_prep();
 
 	winpidgin_set_locale();
+
+	winpidgin_add_perl_to_path();
+
 	/* If help, version or multiple flag used, do not check Mutex */
 	if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v"))
 		if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && strstr(lpszCmdLine, "-m") == NULL))
@@ -645,11 +688,11 @@ WinMain (struct HINSTANCE__ *hInstance, 
 		BOOL mod_not_found = (dw == ERROR_MOD_NOT_FOUND || dw == ERROR_DLL_NOT_FOUND);
 		const char *err_msg = get_win32_error_message(dw);
 
-		snprintf(errbuf, 512, "Error loading pidgin.dll.\nError: (%u) %s%s%s",
+		_snprintf(errbuf, 512, "Error loading pidgin.dll.\nError: (%u) %s%s%s",
 			(UINT) dw, err_msg,
 			mod_not_found ? "\n" : "",
 			mod_not_found ? "This probably means that GTK+ can't be found." : "");
-		printf("%s", errbuf);
+		printf("%s\n", errbuf);
 		MessageBox(NULL, errbuf, TEXT("Error"), MB_OK | MB_TOPMOST);
 
 		return 0;


More information about the Commits mailing list