g_free(script);
}
-extern void boot_DynaLoader(CV* cv);
+extern void boot_DynaLoader(pTHX_ CV* cv);
#if PERL_STATIC_LIBS == 1
extern void boot_Irssi(CV *cv);
}
#endif
-static void xs_init(void)
+static void xs_init(pTHX)
{
dXSUB_SYS;
/* Unload all perl libraries loaded with dynaloader */
perl_eval_pv("foreach my $lib (@DynaLoader::dl_modules) { if ($lib =~ /^Irssi\\b/) { $lib .= '::deinit();'; eval $lib; } }", TRUE);
- perl_eval_pv("eval { foreach my $lib (@DynaLoader::dl_librefs) { DynaLoader::dl_unload_file($lib); } }", TRUE);
+
+ /* We could unload all libraries .. but this crashes with some
+ libraries, probably because we don't call some deinit function..
+ Anyway, this would free some memory with /SCRIPT RESET, but it
+ leaks memory anyway. */
+ /*perl_eval_pv("eval { foreach my $lib (@DynaLoader::dl_librefs) { DynaLoader::dl_unload_file($lib); } }", TRUE);*/
/* perl interpreter */
perl_destruct(my_perl);
dSP;
char *error;
int retcount;
+ SV *ret;
ENTER;
SAVETMPS;
error = NULL;
if (SvTRUE(ERRSV)) {
- error = SvPV(ERRSV, PL_na);
- } else if (retcount > 0) {
- error = POPp;
- }
+ error = SvPV(ERRSV, PL_na);
- if (error != NULL) {
- if (*error == '\0')
- error = NULL;
- else {
- error = g_strdup(error);
+ if (error != NULL) {
+ error = g_strdup(error);
signal_emit("script error", 2, script, error);
- g_free(error);
+ g_free(error);
}
+ } else if (retcount > 0) {
+ /* if script returns 0, it means the script wanted to die
+ immediately without any error message */
+ ret = POPs;
+ if (ret != &PL_sv_undef && SvIOK(ret) && SvIV(ret) == 0)
+ error = "";
}
PUTBACK;
/* check from SCRIPTDIR */
g_free(path);
path = g_strdup_printf(SCRIPTDIR"/%s", file);
- if (stat(path, &statbuf) != 0)
- path = NULL;
+ if (stat(path, &statbuf) != 0) {
+ g_free(path);
+ path = NULL;
+ }
}
g_free(file);
- return path;
+ return path;
}
/* If core should handle printing script errors */
print_script_errors = 1;
settings_add_str("perl", "perl_use_lib", PERL_USE_LIB);
- PL_perl_destruct_level = 1;
+ /*PL_perl_destruct_level = 1; - this crashes with some people.. */
perl_signals_init();
signal_add_last("script error", (SIGNAL_FUNC) sig_script_error);
void perl_core_deinit(void)
{
- perl_signals_deinit();
perl_scripts_deinit();
+ perl_signals_deinit();
signal_remove("script error", (SIGNAL_FUNC) sig_script_error);
}