Ruby: main.c Source File

Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)

main.c
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{
40 RUBY_INIT_STACK;
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}
RUBY_INIT_STACK
#define RUBY_INIT_STACK
A convenience macro to call ruby_init_stack().
Definition interpreter.h:131
ruby_init
void ruby_init(void)
Calls ruby_setup() and check error.
Definition eval.c:98
ruby_sysinit
void ruby_sysinit(int *argc, char ***argv)
Initializes the process for libruby.
Definition ruby.c:3246