Skip to content

Commit 32a0591

Browse files
committed
Move macros from version.h to version.c
Moved the contents of `ruby_description` and `ruby_copyright` which are never used in the other places.
1 parent 2b967cd commit 32a0591

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

version.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@
2020
#define EXIT_SUCCESS 0
2121
#endif
2222

23+
#ifdef RUBY_REVISION
24+
# if RUBY_PATCHLEVEL == -1
25+
# ifndef RUBY_BRANCH_NAME
26+
# define RUBY_BRANCH_NAME "master"
27+
# endif
28+
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
29+
# else
30+
# define RUBY_REVISION_STR " revision "RUBY_REVISION
31+
# endif
32+
#else
33+
# define RUBY_REVISION "HEAD"
34+
# define RUBY_REVISION_STR ""
35+
#endif
36+
#if !defined RUBY_RELEASE_DATETIME || RUBY_PATCHLEVEL != -1
37+
# undef RUBY_RELEASE_DATETIME
38+
# define RUBY_RELEASE_DATETIME RUBY_RELEASE_DATE
39+
#endif
40+
41+
# define RUBY_DESCRIPTION_WITH(opt) \
42+
"ruby " RUBY_VERSION RUBY_PATCHLEVEL_STR " " \
43+
"(" RUBY_RELEASE_DATETIME RUBY_REVISION_STR ")" opt " " \
44+
"[" RUBY_PLATFORM "]"
45+
2346
#define PRINT(type) puts(ruby_##type)
2447
#define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
2548
#define MKINT(name) INT2FIX(ruby_##name)
@@ -44,7 +67,9 @@ const int ruby_patchlevel = RUBY_PATCHLEVEL;
4467
const char ruby_description[] = RUBY_DESCRIPTION_WITH("");
4568
static const char ruby_description_with_mjit[] = RUBY_DESCRIPTION_WITH(" +MJIT");
4669
static const char ruby_description_with_yjit[] = RUBY_DESCRIPTION_WITH(" +YJIT");
47-
const char ruby_copyright[] = RUBY_COPYRIGHT;
70+
const char ruby_copyright[] = "ruby - Copyright (C) "
71+
RUBY_BIRTH_YEAR_STR "-" RUBY_RELEASE_YEAR_STR " "
72+
RUBY_AUTHOR;
4873
const char ruby_engine[] = "ruby";
4974

5075
// Might change after initialization

version.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,34 +65,4 @@
6565
# include "revision.h"
6666
#endif
6767

68-
#ifdef RUBY_REVISION
69-
# if RUBY_PATCHLEVEL == -1
70-
# ifndef RUBY_BRANCH_NAME
71-
# define RUBY_BRANCH_NAME "master"
72-
# endif
73-
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
74-
# else
75-
# define RUBY_REVISION_STR " revision "RUBY_REVISION
76-
# endif
77-
#else
78-
# define RUBY_REVISION "HEAD"
79-
# define RUBY_REVISION_STR ""
80-
#endif
81-
#if !defined RUBY_RELEASE_DATETIME || RUBY_PATCHLEVEL != -1
82-
# undef RUBY_RELEASE_DATETIME
83-
# define RUBY_RELEASE_DATETIME RUBY_RELEASE_DATE
84-
#endif
85-
86-
# define RUBY_DESCRIPTION_WITH(opt) \
87-
"ruby "RUBY_VERSION \
88-
RUBY_PATCHLEVEL_STR \
89-
" ("RUBY_RELEASE_DATETIME \
90-
RUBY_REVISION_STR")"opt" " \
91-
"["RUBY_PLATFORM"]"
92-
# define RUBY_COPYRIGHT \
93-
"ruby - Copyright (C) " \
94-
RUBY_BIRTH_YEAR_STR"-" \
95-
RUBY_RELEASE_YEAR_STR" " \
96-
RUBY_AUTHOR
97-
9868
#endif /* RUBY_TOPLEVEL_VERSION_H */

0 commit comments

Comments
 (0)