Skip to content

Commit ba2f697

Browse files
committed
Revert "Extract ruby_api_version_name"
This reverts commit 9b576cd.
1 parent 8de2622 commit ba2f697

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

ruby.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include "ruby/util.h"
6262
#include "ruby/version.h"
6363
#include "ruby/internal/error.h"
64+
#include "version.h"
6465

6566
#define singlebit_only_p(x) !((x) & ((x)-1))
6667
STATIC_ASSERT(Qnil_1bit_from_Qfalse, singlebit_only_p(Qnil^Qfalse));
@@ -305,8 +306,6 @@ ruby_show_usage_line(const char *name, const char *secondary, const char *descri
305306
description, help, highlight, width, columns);
306307
}
307308

308-
RUBY_EXTERN const char ruby_api_version_name[];
309-
310309
static void
311310
usage(const char *name, int help, int highlight, int columns)
312311
{
@@ -409,9 +408,9 @@ usage(const char *name, int help, int highlight, int columns)
409408
unsigned int w = (columns > 80 ? (columns - 79) / 2 : 0) + 16;
410409
#define SHOW(m) show_usage_line(&(m), help, highlight, w, columns)
411410

412-
printf("%sUsage:%s %s [options] [--] [filepath] [arguments]\n", sb, se, name);
413-
printf("\n""Details and examples at https://docs.ruby-lang.org/en/%s/ruby/options_md.html\n",
414-
ruby_api_version_name);
411+
printf("%sUsage:%s %s [options] [--] [filepath] [arguments]\n\n", sb, se, name);
412+
printf("Details and examples at https://docs.ruby-lang.org/en/%s/ruby/options_md.html\n",
413+
RUBY_PATCHLEVEL == -1 ? "master" : STRINGIZE(RUBY_VERSION_MAJOR) "." STRINGIZE(RUBY_VERSION_MINOR));
415414

416415
for (i = 0; i < num; ++i)
417416
SHOW(usage_msg[i]);

test/ruby/test_rubyoptions.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,26 @@ def test_source_file
4747
assert_in_out_err([], "", [], [])
4848
end
4949

50-
version = RUBY_PATCHLEVEL == -1 ? "master" : "#{RUBY_VERSION_MAJOR}.#{RUBY_VERSION_MINOR}"
51-
OPTIONS_LINK = "https://docs.ruby-lang.org/en/#{version}/ruby/options_md.html"
52-
5350
def test_usage
5451
assert_in_out_err(%w(-h)) do |r, e|
55-
_, _, link, *r = r
56-
assert_include(link, OPTIONS_LINK)
57-
assert_operator(r.size, :<=, 24)
58-
longer = r.select {|x| x.size >= 80}
52+
assert_operator(r.size, :<=, 26)
53+
longer = r[3..-1].select {|x| x.size >= 80}
5954
assert_equal([], longer)
6055
assert_equal([], e)
56+
57+
version = RUBY_PATCHLEVEL == -1 ? "master" : "#{RUBY_VERSION_MAJOR}.#{RUBY_VERSION_MINOR}"
58+
assert_include(r, "Details and examples at https://docs.ruby-lang.org/en/#{version}/ruby/options_md.html")
6159
end
6260
end
6361

6462
def test_usage_long
6563
assert_in_out_err(%w(--help)) do |r, e|
66-
_, _, link, *r = r
67-
assert_include(link, OPTIONS_LINK)
68-
longer = r.select {|x| x.size > 80}
64+
longer = r[3..-1].select {|x| x.size > 80}
6965
assert_equal([], longer)
7066
assert_equal([], e)
67+
68+
version = RUBY_PATCHLEVEL == -1 ? "master" : "#{RUBY_VERSION_MAJOR}.#{RUBY_VERSION_MINOR}"
69+
assert_include(r, "Details and examples at https://docs.ruby-lang.org/en/#{version}/ruby/options_md.html")
7170
end
7271
end
7372

version.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525

2626
#ifdef RUBY_REVISION
2727
# if RUBY_PATCHLEVEL == -1
28-
# define RUBY_API_VERSION_NAME "master"
2928
# ifndef RUBY_BRANCH_NAME
30-
# define RUBY_BRANCH_NAME RUBY_API_VERSION_NAME
29+
# define RUBY_BRANCH_NAME "master"
3130
# endif
3231
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
3332
# else
@@ -37,9 +36,6 @@
3736
# define RUBY_REVISION "HEAD"
3837
# define RUBY_REVISION_STR ""
3938
#endif
40-
#ifndef RUBY_API_VERSION_NAME
41-
# define RUBY_API_VERSION_NAME RUBY_API_VERSION_STR
42-
#endif
4339
#if !defined RUBY_RELEASE_DATETIME || RUBY_PATCHLEVEL != -1
4440
# undef RUBY_RELEASE_DATETIME
4541
# define RUBY_RELEASE_DATETIME RUBY_RELEASE_DATE
@@ -49,9 +45,6 @@
4945
#define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
5046
#define MKINT(name) INT2FIX(ruby_##name)
5147

52-
#define RUBY_API_VERSION_STR \
53-
STRINGIZE(RUBY_API_VERSION_MAJOR) "." \
54-
STRINGIZE(RUBY_API_VERSION_MINOR)
5548
const int ruby_api_version[] = {
5649
RUBY_API_VERSION_MAJOR,
5750
RUBY_API_VERSION_MINOR,
@@ -84,7 +77,6 @@ const char ruby_revision[] = RUBY_FULL_REVISION;
8477
const char ruby_release_date[] = RUBY_RELEASE_DATE;
8578
const char ruby_platform[] = RUBY_PLATFORM;
8679
const int ruby_patchlevel = RUBY_PATCHLEVEL;
87-
const char ruby_api_version_name[] = RUBY_API_VERSION_NAME;
8880
const char ruby_description[] =
8981
"ruby " RUBY_VERSION RUBY_PATCHLEVEL_STR " "
9082
"(" RUBY_RELEASE_DATETIME RUBY_REVISION_STR ") "

0 commit comments

Comments
 (0)