[Israel.pm] directory changes and embedded perl interpreter on windows

Moshe Kaminsky kaminsky at math.huji.ac.il
Sat Sep 4 22:42:47 PDT 2004


Hi,

Thanks for the code. I don't have a windows system either. I'll try to 
find one with visual studio (or whatever they call their c compiler) and 
check it.

Thanks,
Moshe

* Gaal Yahas <gaal at forum2.org> [02/09/04 23:08]:
> On Thu, Sep 02, 2004 at 10:24:48PM +0300, Moshe Kaminsky wrote:
> > I tried to report it as a vim bug, but the author of vim claims that 
> > determining the current working directory is left entirely to the perl 
> > interpreter. Therefore, it should be a general problem when embedding 
> > perl on windows.
> > Can someone verify it? Is this a known issue? Is there a workaround?
> 
> I can't verify this (I'm not near a Win32 system) but if anyone feels
> like it, this should test the hypothesis that this is a bug in embedded
> perl on Windows (on unix this works correctly). You may have to modify
> my includes; I can't write correct Windows C code off the top of my head.
> 
> On unix, you do this to compile and run it:
> 
>      [roo at sike:~/src 13] > gcc -o perlcd perlcd.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
>      [roo at sike:~/src 14] > ./perlcd ..
>      Changing to '..'.
>      Perl thinks the current path is '/home/roo'.
>      [roo at sike:~/src 15] > 
> 
> #include <EXTERN.h>
> #include <perl.h>
> 
> #ifdef WIN32
> #include <direct.h>
> #else
> #include <unistd.h>
> #endif
> 
> static PerlInterpreter *my_perl;
> 
> main (int argc, char **argv, char **env)
> {   
>     STRLEN n_a;
>     char *embedding[] = { "", "-e", "0" };
> 
>     PERL_SYS_INIT3(&argc,&argv,&env);
>     my_perl = perl_alloc();
>     perl_construct( my_perl );
> 
>     perl_parse(my_perl, NULL, 3, embedding, NULL);
>     PL_exit_flags -= PERL_EXIT_DESTRUCT_END;
>     perl_run(my_perl);
> 
>     if (argc > 1) {
>         printf("Changing to '%s'.\n", argv[1]);
> #ifdef WIN32
>         _chdir(argv[1]);
> #else
>         chdir(argv[1]);
> #endif
>     } else {
>         printf("Run me with a path (e.g., '..') to see if embedded perl "
>                 "notices directory changes\n");
>     }
> 
>     eval_pv("use Cwd; $a = cwd;", TRUE);
>     printf("Perl thinks the current path is '%s'.\n", SvPV(get_sv("a", FALSE), n_a));   
>     perl_destruct(my_perl);
>     perl_free(my_perl);
>     PERL_SYS_TERM();
> }
> 
> 
> -- 
> Gaal Yahas <gaal at forum2.org>
> http://gaal.livejournal.com/
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
> 

-- 
I love deadlines. I like the whooshing sound they make as they fly by. 
                                        -- Douglas Adams
    
    Moshe Kaminsky <kaminsky at math.huji.ac.il>
    Home: 08-9456841
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20040905/80a6e5ed/attachment.pgp 


More information about the Perl mailing list