mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Extract ruby_api_version_name
This commit is contained in:
parent
c8233db221
commit
9b576cd625
4 changed files with 23 additions and 16 deletions
2
depend
2
depend
|
@ -14598,7 +14598,6 @@ ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
|
||||||
ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
|
ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
|
||||||
ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
|
ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
|
||||||
ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
|
ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
|
||||||
ruby.$(OBJEXT): $(top_srcdir)/version.h
|
|
||||||
ruby.$(OBJEXT): {$(VPATH)}assert.h
|
ruby.$(OBJEXT): {$(VPATH)}assert.h
|
||||||
ruby.$(OBJEXT): {$(VPATH)}atomic.h
|
ruby.$(OBJEXT): {$(VPATH)}atomic.h
|
||||||
ruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
|
ruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
|
||||||
|
@ -14782,7 +14781,6 @@ ruby.$(OBJEXT): {$(VPATH)}prism/ast.h
|
||||||
ruby.$(OBJEXT): {$(VPATH)}prism/diagnostic.h
|
ruby.$(OBJEXT): {$(VPATH)}prism/diagnostic.h
|
||||||
ruby.$(OBJEXT): {$(VPATH)}prism/version.h
|
ruby.$(OBJEXT): {$(VPATH)}prism/version.h
|
||||||
ruby.$(OBJEXT): {$(VPATH)}prism_compile.h
|
ruby.$(OBJEXT): {$(VPATH)}prism_compile.h
|
||||||
ruby.$(OBJEXT): {$(VPATH)}revision.h
|
|
||||||
ruby.$(OBJEXT): {$(VPATH)}ruby.c
|
ruby.$(OBJEXT): {$(VPATH)}ruby.c
|
||||||
ruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
ruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||||
ruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
ruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||||
|
|
9
ruby.c
9
ruby.c
|
@ -61,7 +61,6 @@
|
||||||
#include "ruby/util.h"
|
#include "ruby/util.h"
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
#include "ruby/internal/error.h"
|
#include "ruby/internal/error.h"
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
#define singlebit_only_p(x) !((x) & ((x)-1))
|
#define singlebit_only_p(x) !((x) & ((x)-1))
|
||||||
STATIC_ASSERT(Qnil_1bit_from_Qfalse, singlebit_only_p(Qnil^Qfalse));
|
STATIC_ASSERT(Qnil_1bit_from_Qfalse, singlebit_only_p(Qnil^Qfalse));
|
||||||
|
@ -302,6 +301,8 @@ ruby_show_usage_line(const char *name, const char *secondary, const char *descri
|
||||||
description, help, highlight, width, columns);
|
description, help, highlight, width, columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUBY_EXTERN const char ruby_api_version_name[];
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(const char *name, int help, int highlight, int columns)
|
usage(const char *name, int help, int highlight, int columns)
|
||||||
{
|
{
|
||||||
|
@ -404,9 +405,9 @@ usage(const char *name, int help, int highlight, int columns)
|
||||||
unsigned int w = (columns > 80 ? (columns - 79) / 2 : 0) + 16;
|
unsigned int w = (columns > 80 ? (columns - 79) / 2 : 0) + 16;
|
||||||
#define SHOW(m) show_usage_line(&(m), help, highlight, w, columns)
|
#define SHOW(m) show_usage_line(&(m), help, highlight, w, columns)
|
||||||
|
|
||||||
printf("%sUsage:%s %s [options] [--] [filepath] [arguments]\n\n", sb, se, name);
|
printf("%sUsage:%s %s [options] [--] [filepath] [arguments]\n", sb, se, name);
|
||||||
printf("Details and examples at https://docs.ruby-lang.org/en/%s/ruby/options_md.html\n",
|
printf("\n""Details and examples at https://docs.ruby-lang.org/en/%s/ruby/options_md.html\n",
|
||||||
RUBY_PATCHLEVEL == -1 ? "master" : STRINGIZE(RUBY_VERSION_MAJOR) "." STRINGIZE(RUBY_VERSION_MINOR));
|
ruby_api_version_name);
|
||||||
|
|
||||||
for (i = 0; i < num; ++i)
|
for (i = 0; i < num; ++i)
|
||||||
SHOW(usage_msg[i]);
|
SHOW(usage_msg[i]);
|
||||||
|
|
|
@ -47,26 +47,27 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||||
assert_in_out_err([], "", [], [])
|
assert_in_out_err([], "", [], [])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
version = RUBY_PATCHLEVEL == -1 ? "master" : "#{RUBY_VERSION_MAJOR}.#{RUBY_VERSION_MINOR}"
|
||||||
|
OPTIONS_LINK = "https://docs.ruby-lang.org/en/#{version}/ruby/options_md.html"
|
||||||
|
|
||||||
def test_usage
|
def test_usage
|
||||||
assert_in_out_err(%w(-h)) do |r, e|
|
assert_in_out_err(%w(-h)) do |r, e|
|
||||||
assert_operator(r.size, :<=, 26)
|
_, _, link, *r = r
|
||||||
longer = r[3..-1].select {|x| x.size >= 80}
|
assert_include(link, OPTIONS_LINK)
|
||||||
|
assert_operator(r.size, :<=, 24)
|
||||||
|
longer = r.select {|x| x.size >= 80}
|
||||||
assert_equal([], longer)
|
assert_equal([], longer)
|
||||||
assert_equal([], e)
|
assert_equal([], e)
|
||||||
|
|
||||||
version = RUBY_PATCHLEVEL == -1 ? "master" : "#{RUBY_VERSION_MAJOR}.#{RUBY_VERSION_MINOR}"
|
|
||||||
assert_include(r, "Details and examples at https://docs.ruby-lang.org/en/#{version}/ruby/options_md.html")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_usage_long
|
def test_usage_long
|
||||||
assert_in_out_err(%w(--help)) do |r, e|
|
assert_in_out_err(%w(--help)) do |r, e|
|
||||||
longer = r[3..-1].select {|x| x.size > 80}
|
_, _, link, *r = r
|
||||||
|
assert_include(link, OPTIONS_LINK)
|
||||||
|
longer = r.select {|x| x.size > 80}
|
||||||
assert_equal([], longer)
|
assert_equal([], longer)
|
||||||
assert_equal([], e)
|
assert_equal([], e)
|
||||||
|
|
||||||
version = RUBY_PATCHLEVEL == -1 ? "master" : "#{RUBY_VERSION_MAJOR}.#{RUBY_VERSION_MINOR}"
|
|
||||||
assert_include(r, "Details and examples at https://docs.ruby-lang.org/en/#{version}/ruby/options_md.html")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,13 @@
|
||||||
|
|
||||||
#ifdef RUBY_REVISION
|
#ifdef RUBY_REVISION
|
||||||
# if RUBY_PATCHLEVEL == -1
|
# if RUBY_PATCHLEVEL == -1
|
||||||
|
# define RUBY_API_VERSION_NAME "master"
|
||||||
# ifndef RUBY_BRANCH_NAME
|
# ifndef RUBY_BRANCH_NAME
|
||||||
# define RUBY_BRANCH_NAME "master"
|
# define RUBY_BRANCH_NAME RUBY_API_VERSION_NAME
|
||||||
# endif
|
# endif
|
||||||
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
|
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
|
||||||
# else
|
# else
|
||||||
|
# define RUBY_API_VERSION_NAME RUBY_API_VERSION_STR
|
||||||
# define RUBY_REVISION_STR " revision "RUBY_REVISION
|
# define RUBY_REVISION_STR " revision "RUBY_REVISION
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
|
@ -44,6 +46,10 @@
|
||||||
#define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
|
#define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
|
||||||
#define MKINT(name) INT2FIX(ruby_##name)
|
#define MKINT(name) INT2FIX(ruby_##name)
|
||||||
|
|
||||||
|
#define RUBY_API_VERSION_STR \
|
||||||
|
STRINGIZE(RUBY_API_VERSION_MAJOR) "." \
|
||||||
|
STRINGIZE(RUBY_API_VERSION_MINOR) "." \
|
||||||
|
""
|
||||||
const int ruby_api_version[] = {
|
const int ruby_api_version[] = {
|
||||||
RUBY_API_VERSION_MAJOR,
|
RUBY_API_VERSION_MAJOR,
|
||||||
RUBY_API_VERSION_MINOR,
|
RUBY_API_VERSION_MINOR,
|
||||||
|
@ -81,6 +87,7 @@ const char ruby_revision[] = RUBY_FULL_REVISION;
|
||||||
const char ruby_release_date[] = RUBY_RELEASE_DATE;
|
const char ruby_release_date[] = RUBY_RELEASE_DATE;
|
||||||
const char ruby_platform[] = RUBY_PLATFORM;
|
const char ruby_platform[] = RUBY_PLATFORM;
|
||||||
const int ruby_patchlevel = RUBY_PATCHLEVEL;
|
const int ruby_patchlevel = RUBY_PATCHLEVEL;
|
||||||
|
const char ruby_api_version_name[] = RUBY_API_VERSION_NAME;
|
||||||
const char ruby_description[] =
|
const char ruby_description[] =
|
||||||
"ruby " RUBY_VERSION RUBY_PATCHLEVEL_STR " "
|
"ruby " RUBY_VERSION RUBY_PATCHLEVEL_STR " "
|
||||||
"(" RUBY_RELEASE_DATETIME RUBY_REVISION_STR ") "
|
"(" RUBY_RELEASE_DATETIME RUBY_REVISION_STR ") "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue