Ruby: main.c Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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#if defined RUBY_DEVEL && !defined RUBY_DEBUG_ENV
27# define RUBY_DEBUG_ENV 1
28#endif
29#if defined RUBY_DEBUG_ENV && !RUBY_DEBUG_ENV
30# undef RUBY_DEBUG_ENV
31#endif
32
33static int
34rb_main(int argc, char **argv)
35{
36 RUBY_INIT_STACK;
37 ruby_init();
38 return ruby_run_node(ruby_options(argc, argv));
39}
40
41#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
42int rb_wasm_rt_start(int (main)(int argc, char **argv), int argc, char **argv);
43#define rb_main(argc, argv) rb_wasm_rt_start(rb_main, argc, argv)
44#endif
45
46int
47main(int argc, char **argv)
48{
49#ifdef RUBY_DEBUG_ENV
50 ruby_set_debug_option(getenv("RUBY_DEBUG"));
51#endif
52#ifdef HAVE_LOCALE_H
53 setlocale(LC_CTYPE, "");
54#endif
55
56 ruby_sysinit(&argc, &argv);
57 return rb_main(argc, argv);
58}
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:2797