PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/version.c

https://github.com/diabolo/ruby
C | 114 lines | 93 code | 11 blank | 10 comment | 0 complexity | e5dd9bfba2cedf4e739e8fa44f591b9a MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /**********************************************************************
  2. version.c -
  3. $Author$
  4. created at: Thu Sep 30 20:08:01 JST 1993
  5. Copyright (C) 1993-2007 Yukihiro Matsumoto
  6. **********************************************************************/
  7. #include "ruby/ruby.h"
  8. #include "version.h"
  9. #include <stdio.h>
  10. #define PRINT(type) puts(ruby_##type)
  11. #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1))
  12. #ifndef RUBY_ARCH
  13. #define RUBY_ARCH RUBY_PLATFORM
  14. #endif
  15. #ifndef RUBY_SITEARCH
  16. #define RUBY_SITEARCH RUBY_ARCH
  17. #endif
  18. #ifdef RUBY_PLATFORM_CPU
  19. #define RUBY_THINARCH RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
  20. #endif
  21. #ifndef RUBY_LIB_PREFIX
  22. #ifndef RUBY_EXEC_PREFIX
  23. #error RUBY_EXEC_PREFIX must be defined
  24. #endif
  25. #define RUBY_LIB_PREFIX RUBY_EXEC_PREFIX"/lib/ruby"
  26. #endif
  27. #ifndef RUBY_SITE_LIB
  28. #define RUBY_SITE_LIB RUBY_LIB_PREFIX"/site_ruby"
  29. #endif
  30. #ifndef RUBY_VENDOR_LIB
  31. #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby"
  32. #endif
  33. #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION
  34. #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION
  35. #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION
  36. #define RUBY_ARCHLIB RUBY_LIB "/"RUBY_ARCH
  37. #define RUBY_SITE_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_SITEARCH
  38. #define RUBY_VENDOR_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
  39. #ifdef RUBY_THINARCH
  40. #define RUBY_THIN_ARCHLIB RUBY_LIB "/"RUBY_THINARCH
  41. #define RUBY_SITE_THIN_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_THINARCH
  42. #define RUBY_VENDOR_THIN_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_THINARCH
  43. #endif
  44. const char ruby_version[] = RUBY_VERSION;
  45. const char ruby_release_date[] = RUBY_RELEASE_DATE;
  46. const char ruby_platform[] = RUBY_PLATFORM;
  47. const int ruby_patchlevel = RUBY_PATCHLEVEL;
  48. const char ruby_description[] = RUBY_DESCRIPTION;
  49. const char ruby_copyright[] = RUBY_COPYRIGHT;
  50. const char ruby_engine[] = "ruby";
  51. VALUE ruby_engine_name = Qnil;
  52. const char ruby_initial_load_paths[] =
  53. #ifndef NO_INITIAL_LOAD_PATH
  54. #ifdef RUBY_SEARCH_PATH
  55. RUBY_SEARCH_PATH "\0"
  56. #endif
  57. RUBY_SITE_LIB2 "\0"
  58. #ifdef RUBY_SITE_THIN_ARCHLIB
  59. RUBY_SITE_THIN_ARCHLIB "\0"
  60. #endif
  61. RUBY_SITE_ARCHLIB "\0"
  62. RUBY_SITE_LIB "\0"
  63. RUBY_VENDOR_LIB2 "\0"
  64. #ifdef RUBY_VENDOR_THIN_ARCHLIB
  65. RUBY_VENDOR_THIN_ARCHLIB "\0"
  66. #endif
  67. RUBY_VENDOR_ARCHLIB "\0"
  68. RUBY_VENDOR_LIB "\0"
  69. RUBY_LIB "\0"
  70. #ifdef RUBY_THIN_ARCHLIB
  71. RUBY_THIN_ARCHLIB "\0"
  72. #endif
  73. RUBY_ARCHLIB "\0"
  74. #endif
  75. "";
  76. void
  77. Init_version(void)
  78. {
  79. rb_define_global_const("RUBY_VERSION", MKSTR(version));
  80. rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
  81. rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
  82. rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
  83. rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
  84. rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
  85. rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
  86. rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
  87. }
  88. void
  89. ruby_show_version(void)
  90. {
  91. PRINT(description);
  92. fflush(stdout);
  93. }
  94. void
  95. ruby_show_copyright(void)
  96. {
  97. PRINT(copyright);
  98. exit(0);
  99. }