Ruby: main.c Source File

Ruby 3.3.4p94 (2024-07-09 revision be1089c8ec5ba40e09b1553e36b3174bf4014d9d)

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#ifdef HAVE_LOCALE_H
24#include <locale.h>
25#endif
26
27#if defined RUBY_DEVEL && !defined RUBY_DEBUG_ENV
28# define RUBY_DEBUG_ENV 1
29#endif
30#if defined RUBY_DEBUG_ENV && !RUBY_DEBUG_ENV
31# undef RUBY_DEBUG_ENV
32#endif
33
34static int
35rb_main(int argc, char **argv)
36{
37 RUBY_INIT_STACK;
38 ruby_init();
39 return ruby_run_node(ruby_options(argc, argv));
40}
41
42#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
43int rb_wasm_rt_start(int (main)(int argc, char **argv), int argc, char **argv);
44#define rb_main(argc, argv) rb_wasm_rt_start(rb_main, argc, argv)
45#endif
46
47int
48main(int argc, char **argv)
49{
50#if defined(RUBY_DEBUG_ENV) || USE_RUBY_DEBUG_LOG
51 ruby_set_debug_option(getenv("RUBY_DEBUG"));
52#endif
53#ifdef HAVE_LOCALE_H
54 setlocale(LC_CTYPE, "");
55#endif
56
57 ruby_sysinit(&argc, &argv);
58 return rb_main(argc, argv);
59}
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:99
ruby_sysinit
void ruby_sysinit(int *argc, char ***argv)
Initializes the process for libruby.
Definition ruby.c:3057