filemorph

Check-in [de77c8d1dc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix serious crash in Windows build
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: de77c8d1dcde7f7d5799f329063ee9ae75ce065e
User & Date: kevin 2015-11-17 01:00:59
Context
2015-11-17
03:37
Add build.pl file check-in: 243ef9b378 user: kevin tags: trunk
01:00
Fix serious crash in Windows build check-in: de77c8d1dc user: kevin tags: trunk
2015-11-15
22:26
Commit of final revisions for 2.6 check-in: ad11b54de7 user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to filemorph.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

42
43






44


45
46


47




48






49
50






51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <Windows.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <tchar.h>

#ifndef CSIDL_APPDATA

#define CSIDL_APPDATA 0x001a 

#endif



static PerlInterpreter *my_perl;  /***    The Perl interpreter    ***/

EXTERN_C void xs_init (pTHX);
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void boot_Win32CORE (pTHX_ CV* cv);
EXTERN_C void

xs_init(pTHX)

{

    static const char file[] = __FILE__;

    dXSUB_SYS;
    PERL_UNUSED_CONTEXT;

    /* DynaLoader is a special case */

    newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
    newXS("Win32CORE::bootstrap", boot_Win32CORE, file);

}

 int main( int argc , char **argv , char **env ) 
{    

	// Get current module's full path







   TCHAR exedir [MAX_PATH] = "";


   GetModuleFileName( 0, exedir, MAX_PATH );



   // Remove file part 




   PathRemoveFileSpec(exedir);






   SetCurrentDirectory(exedir);







    // shift argv and force parameters

    int num_forced_parameters = 4;

    argc += num_forced_parameters;

    int i;

    for(i=argc-1;i>num_forced_parameters;i--){
        argv[i]=argv[i-num_forced_parameters];
    }


    //argv[0] stores the relative path of the executable

    argv[1] = "-Ilib";
	argv[2] = "-Isite/lib";
	argv[3] = "-Ivendor/lib";
	argv[4]= "filemorph.pl";

    PERL_SYS_INIT3( &argc , &argv , &env );
    my_perl = perl_alloc();
    perl_construct( my_perl );
    perl_parse( my_perl , xs_init , argc , argv , (char **)NULL );
    PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
    perl_run( my_perl );
    perl_destruct( my_perl );
    perl_free( my_perl );
    PERL_SYS_TERM();
    return 0;

}












<
<
<
<
<
<
<
<








|
<
<

|

|
|

|

|
|



|
|
>
|
|
>
>
>
>
>
>
|
>
>
|

>
>
|
>
>
>
>
|
>
>
>
>
>
>
|

>
>
>
>
>
>
|

|
<
|
<
|
<
|
|
|


|

|
|
|
|

|
|
|
|
|
|
|
|
|
|







1
2
3
4
5
6
7








8
9
10
11
12
13
14
15
16


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

71

72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <Windows.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <tchar.h>









static PerlInterpreter *my_perl;  /***    The Perl interpreter    ***/

EXTERN_C void xs_init (pTHX);
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void boot_Win32CORE (pTHX_ CV* cv);
EXTERN_C void

xs_init(pTHX)  {



  static const char file[] = __FILE__;

  dXSUB_SYS;
  PERL_UNUSED_CONTEXT;

  /* DynaLoader is a special case */

  newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
  newXS("Win32CORE::bootstrap", boot_Win32CORE, file);

}

int main( int argc , char **argv , char **env ) {    
  
  TCHAR exedir [MAX_PATH];

  
  #if 0 
  GetModuleFileName(NULL, exedir, MAX_PATH);
  _tprintf("%s\n", exedir);
  PathRemoveFileSpec(exedir);
  _tprintf("%s\n", exedir);
  #endif
   
   
  /*Get the module's full path, and set to the current working directory.*/
  if (!GetModuleFileName(NULL, exedir, MAX_PATH)) {

    TCHAR errmsg[512];
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0, GetLastError(),0,errmsg,1024,NULL);

    _tprintf( TEXT("The path is %s, and the error is %s\n"), exedir, errmsg );
  }


  if (!PathRemoveFileSpec(exedir)) {

    TCHAR errmsg[512];
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0, GetLastError(),0,errmsg,1024,NULL);
    _tprintf( TEXT("The target dir is %s, and the error is %s\n"), exedir, errmsg );
  }

  if (!SetCurrentDirectory(exedir)) {

    TCHAR errmsg[512];
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0, GetLastError(),0,errmsg,1024,NULL);
    _tprintf( TEXT("The working dir is %s, and the error is %s\n"), exedir,errmsg );
  }

   
  /* Shift argv and force parameters. */

  int num_forced_parameters = 4;

  argc += num_forced_parameters;

  int i;

  for(i=argc-1;i>num_forced_parameters;i--){
    argv[i]=argv[i-num_forced_parameters];
  }


  /* argv[0] stores the relative path of the executable. */

  argv[1] = "-Ilib";
  argv[2] = "-Isite/lib";
  argv[3] = "-Ivendor/lib";
  argv[4]= "filemorph.pl";

  PERL_SYS_INIT3( &argc , &argv , &env );
  my_perl = perl_alloc();
  perl_construct( my_perl );
  perl_parse( my_perl , xs_init , argc , argv , (char **)NULL );
  PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
  perl_run( my_perl );
  perl_destruct( my_perl );
  perl_free( my_perl );
  PERL_SYS_TERM();
  return 0;

}