Ruby
2.0.0p247(2013-06-27revision41674)
|
00001 /********************************************************************** 00002 00003 version.c - 00004 00005 $Author: nobu $ 00006 created at: Thu Sep 30 20:08:01 JST 1993 00007 00008 Copyright (C) 1993-2007 Yukihiro Matsumoto 00009 00010 **********************************************************************/ 00011 00012 #include "verconf.h" 00013 #include "ruby/ruby.h" 00014 #include "version.h" 00015 #include <stdio.h> 00016 00017 #define PRINT(type) puts(ruby_##type) 00018 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1)) 00019 00020 #ifndef RUBY_ARCH 00021 #define RUBY_ARCH RUBY_PLATFORM 00022 #endif 00023 #ifndef RUBY_SITEARCH 00024 #define RUBY_SITEARCH RUBY_ARCH 00025 #endif 00026 #ifdef RUBY_PLATFORM_CPU 00027 #define RUBY_THINARCH RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS 00028 #endif 00029 #ifndef RUBY_LIB_PREFIX 00030 #ifndef RUBY_EXEC_PREFIX 00031 #error RUBY_EXEC_PREFIX must be defined 00032 #endif 00033 #define RUBY_LIB_PREFIX RUBY_EXEC_PREFIX"/lib/ruby" 00034 #endif 00035 #ifndef RUBY_SITE_LIB 00036 #define RUBY_SITE_LIB RUBY_LIB_PREFIX"/site_ruby" 00037 #endif 00038 #ifndef RUBY_VENDOR_LIB 00039 #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby" 00040 #endif 00041 00042 #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION 00043 #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION 00044 #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION 00045 #ifndef RUBY_ARCH_LIB_FOR 00046 #define RUBY_ARCH_LIB_FOR(arch) RUBY_LIB "/"arch 00047 #endif 00048 #ifndef RUBY_SITE_ARCH_LIB_FOR 00049 #define RUBY_SITE_ARCH_LIB_FOR(arch) RUBY_SITE_LIB2 "/"arch 00050 #endif 00051 #ifndef RUBY_VENDOR_ARCH_LIB_FOR 00052 #define RUBY_VENDOR_ARCH_LIB_FOR(arch) RUBY_VENDOR_LIB2 "/"arch 00053 #endif 00054 00055 const int ruby_api_version[] = { 00056 RUBY_API_VERSION_MAJOR, 00057 RUBY_API_VERSION_MINOR, 00058 RUBY_API_VERSION_TEENY, 00059 }; 00060 const char ruby_version[] = RUBY_VERSION; 00061 const char ruby_release_date[] = RUBY_RELEASE_DATE; 00062 const char ruby_platform[] = RUBY_PLATFORM; 00063 const int ruby_patchlevel = RUBY_PATCHLEVEL; 00064 const char ruby_description[] = RUBY_DESCRIPTION; 00065 const char ruby_copyright[] = RUBY_COPYRIGHT; 00066 const char ruby_engine[] = "ruby"; 00067 VALUE ruby_engine_name = Qnil; 00068 00069 const char ruby_initial_load_paths[] = 00070 #ifndef NO_INITIAL_LOAD_PATH 00071 #ifdef RUBY_SEARCH_PATH 00072 RUBY_SEARCH_PATH "\0" 00073 #endif 00074 #ifndef NO_RUBY_SITE_LIB 00075 RUBY_SITE_LIB2 "\0" 00076 #ifdef RUBY_THINARCH 00077 RUBY_SITE_ARCH_LIB_FOR(RUBY_THINARCH) "\0" 00078 #endif 00079 RUBY_SITE_ARCH_LIB_FOR(RUBY_SITEARCH) "\0" 00080 RUBY_SITE_LIB "\0" 00081 #endif 00082 00083 #ifndef NO_RUBY_VENDOR_LIB 00084 RUBY_VENDOR_LIB2 "\0" 00085 #ifdef RUBY_THINARCH 00086 RUBY_VENDOR_ARCH_LIB_FOR(RUBY_THINARCH) "\0" 00087 #endif 00088 RUBY_VENDOR_ARCH_LIB_FOR(RUBY_SITEARCH) "\0" 00089 RUBY_VENDOR_LIB "\0" 00090 #endif 00091 00092 RUBY_LIB "\0" 00093 #ifdef RUBY_THINARCH 00094 RUBY_ARCH_LIB_FOR(RUBY_THINARCH) "\0" 00095 #endif 00096 RUBY_ARCH_LIB_FOR(RUBY_ARCH) "\0" 00097 #endif 00098 ""; 00099 00101 void 00102 Init_version(void) 00103 { 00104 /* 00105 * The running version of ruby 00106 */ 00107 rb_define_global_const("RUBY_VERSION", MKSTR(version)); 00108 /* 00109 * The date this ruby was released 00110 */ 00111 rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date)); 00112 /* 00113 * The platform for this ruby 00114 */ 00115 rb_define_global_const("RUBY_PLATFORM", MKSTR(platform)); 00116 /* 00117 * The patchlevel for this ruby. If this is a development build of ruby 00118 * the patchlevel will be -1 00119 */ 00120 rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL)); 00121 /* 00122 * The SVN revision for this ruby. 00123 */ 00124 rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION)); 00125 /* 00126 * The full ruby version string, like <tt>ruby -v</tt> prints' 00127 */ 00128 rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description)); 00129 /* 00130 * The copyright string for ruby 00131 */ 00132 rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright)); 00133 /* 00134 * The engine or interpreter this ruby uses. 00135 */ 00136 rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine)); 00137 } 00138 00140 void 00141 ruby_show_version(void) 00142 { 00143 PRINT(description); 00144 fflush(stdout); 00145 } 00146 00150 void 00151 ruby_show_copyright(void) 00152 { 00153 PRINT(copyright); 00154 exit(0); 00155 } 00156