Patch from Andreas.
[p5sagit/p5-mst-13.2.git] / miniperlmain.c
CommitLineData
a0d0e21e 1/*
2 * "The Road goes ever on and on, down from the door where it began."
3 */
4
4633a7c4 5#ifdef __cplusplus
6extern "C" {
7#endif
8
ecfc5424 9#include "EXTERN.h"
2304df62 10#include "perl.h"
11
4633a7c4 12#ifdef __cplusplus
13}
14# define EXTERN_C extern "C"
15#else
16# define EXTERN_C extern
17#endif
18
a0d0e21e 19static void xs_init _((void));
20static PerlInterpreter *my_perl;
21
a0d0e21e 22int
28e44ed9 23i18nl14n()
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
52int
4633a7c4 53#ifndef CAN_PROTOTYPE
2304df62 54main(argc, argv, env)
55int argc;
56char **argv;
57char **env;
4633a7c4 58#else /* def(CAN_PROTOTYPE) */
59main(int argc, char **argv, char **env)
60#endif /* def(CAN_PROTOTYPE) */
2304df62 61{
62 int exitstatus;
2304df62 63
4633a7c4 64#ifdef OS2
65 _response(&argc, &argv);
66 _wildcard(&argc, &argv);
67#endif
68
a0d0e21e 69#ifdef VMS
70 getredirection(&argc,&argv);
71#endif
72
28e44ed9 73/* here a union of the cpp #if:s inside i18nl14n() */
74#if (defined(HAS_SETLOCALE) && defined(LC_CTYPE))
75 i18nl14n();
4633a7c4 76#endif
77
a0d0e21e 78 if (!do_undump) {
79 my_perl = perl_alloc();
80 if (!my_perl)
81 exit(1);
82 perl_construct( my_perl );
83 }
2304df62 84
28e44ed9 85 exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
2304df62 86 if (exitstatus)
87 exit( exitstatus );
88
89 exitstatus = perl_run( my_perl );
90
748a9306 91 perl_destruct( my_perl );
2304df62 92 perl_free( my_perl );
93
94 exit( exitstatus );
95}
96
97/* Register any extra external extensions */
98
4633a7c4 99/* Do not delete this line--writemain depends on it */
100
a0d0e21e 101static void
102xs_init()
2304df62 103{
2304df62 104}