Ruby 3.5.0dev (2025-04-11 revision 0a35c5b4d9add69251590e3902a5d861df49e142)
main.c (0a35c5b4d9add69251590e3902a5d861df49e142)
1/**********************************************************************
2
3 main.c -
4
5 $Author$
6 created at: Fri Aug 19 13:19:58 JST 1994
7
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
9
10**********************************************************************/
11
20#undef RUBY_EXPORT
21#include "ruby.h"
22#include "vm_debug.h"
23#include "internal/sanitizers.h"
24#ifdef HAVE_LOCALE_H
25#include <locale.h>
26#endif
27
28#if defined RUBY_DEVEL && !defined RUBY_DEBUG_ENV
29# define RUBY_DEBUG_ENV 1
30#endif
31#if defined RUBY_DEBUG_ENV && !RUBY_DEBUG_ENV
32# undef RUBY_DEBUG_ENV
33#endif
34
35RUBY_GLOBAL_SETUP
36
37static int
38rb_main(int argc, char **argv)
39{
41 ruby_init();
42 return ruby_run_node(ruby_options(argc, argv));
43}
44
45#ifdef _WIN32
46#define main(argc, argv) w32_main(argc, argv)
47static int main(int argc, char **argv);
48int wmain(void) {return main(0, NULL);}
49#endif
50
51int
52main(int argc, char **argv)
53{
54#if defined(RUBY_DEBUG_ENV) || USE_RUBY_DEBUG_LOG
55 ruby_set_debug_option(getenv("RUBY_DEBUG"));
56#endif
57#ifdef HAVE_LOCALE_H
58 setlocale(LC_CTYPE, "");
59#endif
60
61 ruby_sysinit(&argc, &argv);
62 return ruby_start_main(rb_main, argc, argv);
63}
#define RUBY_INIT_STACK
A convenience macro to call ruby_init_stack().
void ruby_init(void)
Calls ruby_setup() and check error.
Definition eval.c:95
void ruby_sysinit(int *argc, char ***argv)
Initializes the process for libruby.
Definition ruby.c:3180