From caaf25432e9db92f9b35e18ae45b41d19910fcc7 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 17 Oct 2007 01:13:35 +0200 Subject: [PATCH] perl plugin: Improved "IncludeDir" configuration option. The "Do not initialize the Perl interpreter until loading a module." commit removed support for adding include directories after the Perl interpreter has been initialized. This patch re-enables it. Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- src/perl.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/perl.c b/src/perl.c index 8c21e45c..c0beabfe 100644 --- a/src/perl.c +++ b/src/perl.c @@ -992,19 +992,27 @@ static int perl_config_includedir (oconfig_item_t *ci) value = ci->values[0].value.string; - perl_argv = (char **)realloc (perl_argv, - (++perl_argc + 1) * sizeof (char *)); + if (NULL == perl) { + perl_argv = (char **)realloc (perl_argv, + (++perl_argc + 1) * sizeof (char *)); - if (NULL == perl_argv) { - log_err ("perl_config: Not enough memory."); - exit (3); - } + if (NULL == perl_argv) { + log_err ("perl_config: Not enough memory."); + exit (3); + } - perl_argv[perl_argc - 1] = (char *)smalloc (strlen (value) + 3); - sstrncpy(perl_argv[perl_argc - 1], "-I", 3); - sstrncpy(perl_argv[perl_argc - 1] + 2, value, strlen (value) + 1); + perl_argv[perl_argc - 1] = (char *)smalloc (strlen (value) + 3); + sstrncpy(perl_argv[perl_argc - 1], "-I", 3); + sstrncpy(perl_argv[perl_argc - 1] + 2, value, strlen (value) + 1); - perl_argv[perl_argc] = NULL; + perl_argv[perl_argc] = NULL; + } + else { + /* prepend the directory to @INC */ + Perl_av_unshift (perl, GvAVn (PL_incgv), 1); + Perl_av_store (perl, GvAVn (PL_incgv), + 0, Perl_newSVpv (perl, value, strlen (value))); + } return 0; } /* static int perl_config_includedir (oconfig_item_it *) */ -- 2.30.2