-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] Make a separate copy of MRI stdlib again, so we're isolated…
… from JRuby's update to 2.4
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
1 parent
c2d4c15
commit 14f3823
Showing
772 changed files
with
185,782 additions
and
669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,191 @@ | ||
require_relative '../../stdlib/English' | ||
# frozen_string_literal: false | ||
# | ||
# Modified for JRuby | ||
# In JRuby, we define these aliases by default, so this file | ||
# does nothing. | ||
# | ||
# Include the English library file in a Ruby script, and you can | ||
# reference the global variables such as \VAR{\$\_} using less | ||
# cryptic names, listed in the following table.% \vref{tab:english}. | ||
# | ||
# Without 'English': | ||
# | ||
# $\ = ' -- ' | ||
# "waterbuffalo" =~ /buff/ | ||
# print $', $$, "\n" | ||
# | ||
# With English: | ||
# | ||
# require "English" | ||
# | ||
# $OUTPUT_FIELD_SEPARATOR = ' -- ' | ||
# "waterbuffalo" =~ /buff/ | ||
# print $POSTMATCH, $PID, "\n" | ||
# | ||
# Below is a full list of descriptive aliases and their associated global | ||
# variable: | ||
# | ||
# $ERROR_INFO:: $! | ||
# $ERROR_POSITION:: $@ | ||
# $FS:: $; | ||
# $FIELD_SEPARATOR:: $; | ||
# $OFS:: $, | ||
# $OUTPUT_FIELD_SEPARATOR:: $, | ||
# $RS:: $/ | ||
# $INPUT_RECORD_SEPARATOR:: $/ | ||
# $ORS:: $\ | ||
# $OUTPUT_RECORD_SEPARATOR:: $\ | ||
# $INPUT_LINE_NUMBER:: $. | ||
# $NR:: $. | ||
# $LAST_READ_LINE:: $_ | ||
# $DEFAULT_OUTPUT:: $> | ||
# $DEFAULT_INPUT:: $< | ||
# $PID:: $$ | ||
# $PROCESS_ID:: $$ | ||
# $CHILD_STATUS:: $? | ||
# $LAST_MATCH_INFO:: $~ | ||
# $IGNORECASE:: $= | ||
# $ARGV:: $* | ||
# $MATCH:: $& | ||
# $PREMATCH:: $` | ||
# $POSTMATCH:: $' | ||
# $LAST_PAREN_MATCH:: $+ | ||
# | ||
module English end if false | ||
|
||
# The exception object passed to +raise+. | ||
#alias $ERROR_INFO $! | ||
|
||
# The stack backtrace generated by the last | ||
# exception. <tt>See Kernel.caller</tt> for details. Thread local. | ||
#alias $ERROR_POSITION $@ | ||
|
||
# The default separator pattern used by <tt>String.split</tt>. May be | ||
# set from the command line using the <tt>-F</tt> flag. | ||
#alias $FS $; | ||
|
||
# The default separator pattern used by <tt>String.split</tt>. May be | ||
# set from the command line using the <tt>-F</tt> flag. | ||
#alias $FIELD_SEPARATOR $; | ||
|
||
# The separator string output between the parameters to methods such | ||
# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+, | ||
# which adds no text. | ||
#alias $OFS $, | ||
|
||
# The separator string output between the parameters to methods such | ||
# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+, | ||
# which adds no text. | ||
#alias $OUTPUT_FIELD_SEPARATOR $, | ||
|
||
# The input record separator (newline by default). This is the value | ||
# that routines such as <tt>Kernel.gets</tt> use to determine record | ||
# boundaries. If set to +nil+, +gets+ will read the entire file. | ||
#alias $RS $/ | ||
|
||
# The input record separator (newline by default). This is the value | ||
# that routines such as <tt>Kernel.gets</tt> use to determine record | ||
# boundaries. If set to +nil+, +gets+ will read the entire file. | ||
#alias $INPUT_RECORD_SEPARATOR $/ | ||
|
||
# The string appended to the output of every call to methods such as | ||
# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is | ||
# +nil+. | ||
#alias $ORS $\ | ||
|
||
# The string appended to the output of every call to methods such as | ||
# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is | ||
# +nil+. | ||
#alias $OUTPUT_RECORD_SEPARATOR $\ | ||
|
||
# The number of the last line read from the current input file. | ||
#alias $INPUT_LINE_NUMBER $. | ||
|
||
# The number of the last line read from the current input file. | ||
#alias $NR $. | ||
|
||
# The last line read by <tt>Kernel.gets</tt> or | ||
# <tt>Kernel.readline</tt>. Many string-related functions in the | ||
# +Kernel+ module operate on <tt>$_</tt> by default. The variable is | ||
# local to the current scope. Thread local. | ||
#alias $LAST_READ_LINE $_ | ||
|
||
# The destination of output for <tt>Kernel.print</tt> | ||
# and <tt>Kernel.printf</tt>. The default value is | ||
# <tt>$stdout</tt>. | ||
#alias $DEFAULT_OUTPUT $> | ||
|
||
# An object that provides access to the concatenation | ||
# of the contents of all the files | ||
# given as command-line arguments, or <tt>$stdin</tt> | ||
# (in the case where there are no | ||
# arguments). <tt>$<</tt> supports methods similar to a | ||
# +File+ object: | ||
# +inmode+, +close+, | ||
# <tt>closed?</tt>, +each+, | ||
# <tt>each_byte</tt>, <tt>each_line</tt>, | ||
# +eof+, <tt>eof?</tt>, +file+, | ||
# +filename+, +fileno+, | ||
# +getc+, +gets+, +lineno+, | ||
# <tt>lineno=</tt>, +path+, | ||
# +pos+, <tt>pos=</tt>, | ||
# +read+, +readchar+, | ||
# +readline+, +readlines+, | ||
# +rewind+, +seek+, +skip+, | ||
# +tell+, <tt>to_a</tt>, <tt>to_i</tt>, | ||
# <tt>to_io</tt>, <tt>to_s</tt>, along with the | ||
# methods in +Enumerable+. The method +file+ | ||
# returns a +File+ object for the file currently | ||
# being read. This may change as <tt>$<</tt> reads | ||
# through the files on the command line. Read only. | ||
#alias $DEFAULT_INPUT $< | ||
|
||
# The process number of the program being executed. Read only. | ||
#alias $PID $$ | ||
|
||
# The process number of the program being executed. Read only. | ||
#alias $PROCESS_ID $$ | ||
|
||
# The exit status of the last child process to terminate. Read | ||
# only. Thread local. | ||
#alias $CHILD_STATUS $? | ||
|
||
# A +MatchData+ object that encapsulates the results of a successful | ||
# pattern match. The variables <tt>$&</tt>, <tt>$`</tt>, <tt>$'</tt>, | ||
# and <tt>$1</tt> to <tt>$9</tt> are all derived from | ||
# <tt>$~</tt>. Assigning to <tt>$~</tt> changes the values of these | ||
# derived variables. This variable is local to the current | ||
# scope. | ||
#alias $LAST_MATCH_INFO $~ | ||
|
||
# If set to any value apart from +nil+ or +false+, all pattern matches | ||
# will be case insensitive, string comparisons will ignore case, and | ||
# string hash values will be case insensitive. Deprecated | ||
#alias $IGNORECASE $= | ||
|
||
# An array of strings containing the command-line | ||
# options from the invocation of the program. Options | ||
# used by the Ruby interpreter will have been | ||
# removed. Read only. Also known simply as +ARGV+. | ||
#alias $ARGV $* | ||
|
||
# The string matched by the last successful pattern | ||
# match. This variable is local to the current | ||
# scope. Read only. | ||
#alias $MATCH $& | ||
|
||
# The string preceding the match in the last | ||
# successful pattern match. This variable is local to | ||
# the current scope. Read only. | ||
#alias $PREMATCH $` | ||
|
||
# The string following the match in the last | ||
# successful pattern match. This variable is local to | ||
# the current scope. Read only. | ||
#alias $POSTMATCH $' | ||
|
||
# The contents of the highest-numbered group matched in the last | ||
# successful pattern match. Thus, in <tt>"cat" =~ /(c|a)(t|z)/</tt>, | ||
# <tt>$+</tt> will be set to "t". This variable is local to the | ||
# current scope. Read only. | ||
#alias $LAST_PAREN_MATCH $+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,132 @@ | ||
require_relative '../../stdlib/abbrev' | ||
# frozen_string_literal: false | ||
#-- | ||
# Copyright (c) 2001,2003 Akinori MUSHA <knu@iDaemons.org> | ||
# | ||
# All rights reserved. You can redistribute and/or modify it under | ||
# the same terms as Ruby. | ||
# | ||
# $Idaemons: /home/cvs/rb/abbrev.rb,v 1.2 2001/05/30 09:37:45 knu Exp $ | ||
# $RoughId: abbrev.rb,v 1.4 2003/10/14 19:45:42 knu Exp $ | ||
# $Id$ | ||
#++ | ||
|
||
## | ||
# Calculates the set of unambiguous abbreviations for a given set of strings. | ||
# | ||
# require 'abbrev' | ||
# require 'pp' | ||
# | ||
# pp Abbrev.abbrev(['ruby']) | ||
# #=> {"ruby"=>"ruby", "rub"=>"ruby", "ru"=>"ruby", "r"=>"ruby"} | ||
# | ||
# pp Abbrev.abbrev(%w{ ruby rules }) | ||
# | ||
# _Generates:_ | ||
# { "ruby" => "ruby", | ||
# "rub" => "ruby", | ||
# "rules" => "rules", | ||
# "rule" => "rules", | ||
# "rul" => "rules" } | ||
# | ||
# It also provides an array core extension, Array#abbrev. | ||
# | ||
# pp %w{ summer winter }.abbrev | ||
# | ||
# _Generates:_ | ||
# { "summer" => "summer", | ||
# "summe" => "summer", | ||
# "summ" => "summer", | ||
# "sum" => "summer", | ||
# "su" => "summer", | ||
# "s" => "summer", | ||
# "winter" => "winter", | ||
# "winte" => "winter", | ||
# "wint" => "winter", | ||
# "win" => "winter", | ||
# "wi" => "winter", | ||
# "w" => "winter" } | ||
|
||
module Abbrev | ||
|
||
# Given a set of strings, calculate the set of unambiguous abbreviations for | ||
# those strings, and return a hash where the keys are all the possible | ||
# abbreviations and the values are the full strings. | ||
# | ||
# Thus, given +words+ is "car" and "cone", the keys pointing to "car" would | ||
# be "ca" and "car", while those pointing to "cone" would be "co", "con", and | ||
# "cone". | ||
# | ||
# require 'abbrev' | ||
# | ||
# Abbrev.abbrev(%w{ car cone }) | ||
# #=> {"ca"=>"car", "con"=>"cone", "co"=>"cone", "car"=>"car", "cone"=>"cone"} | ||
# | ||
# The optional +pattern+ parameter is a pattern or a string. Only input | ||
# strings that match the pattern or start with the string are included in the | ||
# output hash. | ||
# | ||
# Abbrev.abbrev(%w{car box cone crab}, /b/) | ||
# #=> {"box"=>"box", "bo"=>"box", "b"=>"box", "crab" => "crab"} | ||
# | ||
# Abbrev.abbrev(%w{car box cone}, 'ca') | ||
# #=> {"car"=>"car", "ca"=>"car"} | ||
def abbrev(words, pattern = nil) | ||
table = {} | ||
seen = Hash.new(0) | ||
|
||
if pattern.is_a?(String) | ||
pattern = /\A#{Regexp.quote(pattern)}/ # regard as a prefix | ||
end | ||
|
||
words.each do |word| | ||
next if word.empty? | ||
word.size.downto(1) { |len| | ||
abbrev = word[0...len] | ||
|
||
next if pattern && pattern !~ abbrev | ||
|
||
case seen[abbrev] += 1 | ||
when 1 | ||
table[abbrev] = word | ||
when 2 | ||
table.delete(abbrev) | ||
else | ||
break | ||
end | ||
} | ||
end | ||
|
||
words.each do |word| | ||
next if pattern && pattern !~ word | ||
|
||
table[word] = word | ||
end | ||
|
||
table | ||
end | ||
|
||
module_function :abbrev | ||
end | ||
|
||
class Array | ||
# Calculates the set of unambiguous abbreviations for the strings in +self+. | ||
# | ||
# require 'abbrev' | ||
# %w{ car cone }.abbrev | ||
# #=> {"car"=>"car", "ca"=>"car", "cone"=>"cone", "con"=>"cone", "co"=>"cone"} | ||
# | ||
# The optional +pattern+ parameter is a pattern or a string. Only input | ||
# strings that match the pattern or start with the string are included in the | ||
# output hash. | ||
# | ||
# %w{ fast boat day }.abbrev(/^.a/) | ||
# #=> {"fast"=>"fast", "fas"=>"fast", "fa"=>"fast", "day"=>"day", "da"=>"day"} | ||
# | ||
# Abbrev.abbrev(%w{car box cone}, "ca") | ||
# #=> {"car"=>"car", "ca"=>"car"} | ||
# | ||
# See also Abbrev.abbrev | ||
def abbrev(pattern = nil) | ||
Abbrev::abbrev(self, pattern) | ||
end | ||
end |
Oops, something went wrong.