perl 5.002beta1h patch: pod/Makefile
[p5sagit/p5-mst-13.2.git] / miniperlmain.c
1 /*
2  * "The Road goes ever on and on, down from the door where it began."
3  */
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 #include "EXTERN.h"
10 #include "perl.h"
11
12 #ifdef __cplusplus
13 }
14 #  define EXTERN_C extern "C"
15 #else
16 #  define EXTERN_C extern
17 #endif
18
19 static void xs_init _((void));
20 static PerlInterpreter *my_perl;
21
22 int
23 i18nl14n()
24 {
25   char * lang = getenv("LANG");
26 #if defined(HAS_SETLOCALE) && defined(LC_CTYPE)
27   {
28     char * lc_ctype = getenv("LC_CTYPE");
29     int i;
30
31     if (setlocale(LC_CTYPE, "") == NULL && (lc_ctype || lang)) {
32       fprintf(stderr,
33               "warning: setlocale(LC_CTYPE, \"\") failed, LC_CTYPE = \"%s\", LANG = \"%s\",\n",
34               lc_ctype ? lc_ctype : "(null)",
35               lang     ? lang     : "(null)"
36               );
37       fprintf(stderr,
38               "warning: falling back to the \"C\" locale.\n");
39       setlocale(LC_CTYPE, "C");
40     }
41
42     for (i = 0; i < 256; i++) {
43       if (isUPPER(i)) fold[i] = toLOWER(i);
44       else if (isLOWER(i)) fold[i] = toUPPER(i);
45       else fold[i] = i;
46     }
47
48   }
49 #endif
50 }
51
52 int
53 #ifndef CAN_PROTOTYPE
54 main(argc, argv, env)
55 int argc;
56 char **argv;
57 char **env;
58 #else  /* def(CAN_PROTOTYPE) */
59 main(int argc, char **argv, char **env)
60 #endif  /* def(CAN_PROTOTYPE) */
61 {
62     int exitstatus;
63
64 #ifdef OS2
65     _response(&argc, &argv);
66     _wildcard(&argc, &argv);
67 #endif
68
69 #ifdef VMS
70     getredirection(&argc,&argv);
71 #endif
72
73 /* here a union of the cpp #if:s inside i18nl14n() */
74 #if (defined(HAS_SETLOCALE) && defined(LC_CTYPE))
75     i18nl14n();
76 #endif
77
78     if (!do_undump) {
79         my_perl = perl_alloc();
80         if (!my_perl)
81             exit(1);
82         perl_construct( my_perl );
83     }
84
85     exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
86     if (exitstatus)
87         exit( exitstatus );
88
89     exitstatus = perl_run( my_perl );
90
91     perl_destruct( my_perl );
92     perl_free( my_perl );
93
94     exit( exitstatus );
95 }
96
97 /* Register any extra external extensions */
98
99 /* Do not delete this line--writemain depends on it */
100
101 static void
102 xs_init()
103 {
104 }