diff --git a/array.c b/array.c index 94a4dfb98b..b7be69afd6 100644 --- a/array.c +++ b/array.c @@ -312,22 +312,22 @@ static VALUE rb_ary_replace _((VALUE, VALUE)); * Array.new * Array.new(2) * Array.new(5, "A") - * + * * # only one copy of the object is created * a = Array.new(2, Hash.new) * a[0]['cat'] = 'feline' * a * a[1]['cat'] = 'Felix' * a - * + * * # here multiple copies are created * a = Array.new(2) { Hash.new } * a[0]['cat'] = 'feline' * a - * + * * squares = Array.new(5) {|i| i*i} * squares - * + * * copy = Array.new(squares) */ @@ -388,8 +388,8 @@ rb_ary_initialize(argc, argv, ary) } -/* -* Returns a new array populated with the given objects. +/* +* Returns a new array populated with the given objects. * * Array.[]( 1, 'a', /^A/ ) * Array[ 1, 'a', /^A/ ] @@ -492,7 +492,7 @@ ary_shared_first(argc, argv, ary, last) /* * call-seq: * array << obj -> array - * + * * Append---Pushes the given object on to the end of this array. This * expression returns the array itself, so several appends * may be chained together. @@ -511,16 +511,16 @@ rb_ary_push(ary, item) return ary; } -/* +/* * call-seq: * array.push(obj, ... ) -> array - * + * * Append---Pushes the given object(s) on to the end of this array. This * expression returns the array itself, so several appends * may be chained together. * * a = [ "a", "b", "c" ] - * a.push("d", "e", "f") + * a.push("d", "e", "f") * #=> ["a", "b", "c", "d", "e", "f"] */ @@ -555,13 +555,13 @@ rb_ary_pop(ary) * call-seq: * array.pop -> obj or nil * array.pop(n) -> array - * + * * Removes the last element from self and returns it, or * nil if the array is empty. * * If a number _n_ is given, returns an array of the last n elements * (or less) just like array.slice!(-n, n) does. - * + * * a = [ "a", "b", "c", "d" ] * a.pop #=> "d" * a.pop(2) #=> ["b", "c"] @@ -614,14 +614,14 @@ rb_ary_shift(ary) * call-seq: * array.shift -> obj or nil * array.shift(n) -> array - * + * * Returns the first element of self and removes it (shifting all * other elements down by one). Returns nil if the array * is empty. * * If a number _n_ is given, returns an array of the first n elements * (or less) just like array.slice!(0, n) does. - * + * * args = [ "-m", "-q", "filename" ] * args.shift #=> "-m" * args #=> ["-q", "filename"] @@ -685,10 +685,10 @@ rb_ary_unshift(ary, item) /* * call-seq: * array.unshift(obj, ...) -> array - * + * * Prepends objects to the front of array. * other elements up one. - * + * * a = [ "b", "c", "d" ] * a.unshift("a") #=> ["a", "b", "c", "d"] * a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"] @@ -710,7 +710,7 @@ rb_ary_unshift_m(argc, argv, ary) /* sliding items */ MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len); MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc); - + return ary; } @@ -768,7 +768,7 @@ rb_ary_subseq(ary, beg, len) return ary2; } -/* +/* * call-seq: * array[index] -> obj or nil * array[start, length] -> an_array or nil @@ -843,7 +843,7 @@ rb_ary_aref(argc, argv, ary) return rb_ary_entry(ary, NUM2LONG(arg)); } -/* +/* * call-seq: * array.at(index) -> obj or nil * @@ -899,10 +899,10 @@ rb_ary_first(argc, argv, ary) * call-seq: * array.last -> obj or nil * array.last(n) -> an_array - * + * * Returns the last element(s) of self. If the array is empty, * the first form returns nil. - * + * * [ "w", "x", "y", "z" ].last #=> "z" */ @@ -926,14 +926,14 @@ rb_ary_last(argc, argv, ary) * array.fetch(index) -> obj * array.fetch(index, default ) -> obj * array.fetch(index) {|index| block } -> obj - * + * * Tries to return the element at position index. If the index * lies outside the array, the first form throws an * IndexError exception, the second form returns * default, and the third form returns the value of invoking * the block, passing in the index. Negative values of index * count from the end of the array. - * + * * a = [ 11, 22, 33, 44 ] * a.fetch(1) #=> 22 * a.fetch(-1) #=> 44 @@ -975,12 +975,12 @@ rb_ary_fetch(argc, argv, ary) * call-seq: * array.index(obj) -> int or nil * array.index {|item| block} -> int or nil - * + * * Returns the index of the first object in self such that is * == to obj. If a block is given instead of an * argument, returns first object for which block is true. * Returns nil if no match is found. - * + * * a = [ "a", "b", "c" ] * a.index("b") #=> 1 * a.index("z") #=> nil @@ -1018,12 +1018,12 @@ rb_ary_index(argc, argv, ary) /* * call-seq: * array.rindex(obj) -> int or nil - * + * * Returns the index of the last object in array * == to obj. If a block is given instead of an * argument, returns first object for which block is * true. Returns nil if no match is found. - * + * * a = [ "a", "b", "b", "b", "c" ] * a.rindex("b") #=> 3 * a.rindex("z") #=> nil @@ -1065,7 +1065,7 @@ rb_ary_rindex(argc, argv, ary) * call-seq: * array.indexes( i1, i2, ... iN ) -> an_array * array.indices( i1, i2, ... iN ) -> an_array - * + * * Deprecated; use Array#values_at. */ @@ -1167,7 +1167,7 @@ rb_ary_splice(ary, beg, len, rpl) } } -/* +/* * call-seq: * array[index] = obj -> obj * array[start, length] = obj or an_array or nil -> obj or an_array or nil @@ -1184,7 +1184,7 @@ rb_ary_splice(ary, beg, len, rpl) * deletes elements from _self_. An +IndexError+ is raised if a * negative index points past the beginning of the array. See also * Array#push, and Array#unshift. - * + * * a = Array.new * a[4] = "4"; #=> [nil, nil, nil, nil, "4"] * a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"] @@ -1240,10 +1240,10 @@ fixnum: /* * call-seq: * array.insert(index, obj...) -> array - * + * * Inserts the given values before the element with the given index * (which may be negative). - * + * * a = %w{ a b c d } * a.insert(2, 99) #=> ["a", "b", 99, "c", "d"] * a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"] @@ -1275,15 +1275,15 @@ rb_ary_insert(argc, argv, ary) /* * call-seq: * array.each {|item| block } -> array - * + * * Calls block once for each element in self, passing that * element as a parameter. - * + * * a = [ "a", "b", "c" ] * a.each {|x| print x, " -- " } - * + * * produces: - * + * * a -- b -- c -- */ @@ -1303,15 +1303,15 @@ rb_ary_each(ary) /* * call-seq: * array.each_index {|index| block } -> array - * + * * Same as Array#each, but passes the index of the element * instead of the element itself. - * + * * a = [ "a", "b", "c" ] * a.each_index {|x| print x, " -- " } - * + * * produces: - * + * * 0 -- 1 -- 2 -- */ @@ -1330,16 +1330,16 @@ rb_ary_each_index(ary) /* * call-seq: - * array.reverse_each {|item| block } - * + * array.reverse_each {|item| block } + * * Same as Array#each, but traverses self in reverse * order. - * + * * a = [ "a", "b", "c" ] * a.reverse_each {|x| print x, " " } - * + * * produces: - * + * * c b a */ @@ -1363,9 +1363,9 @@ rb_ary_reverse_each(ary) /* * call-seq: * array.length -> int - * + * * Returns the number of elements in self. May be zero. - * + * * [ 1, 2, 3, 4, 5 ].length #=> 5 */ @@ -1379,9 +1379,9 @@ rb_ary_length(ary) /* * call-seq: * array.empty? -> true or false - * + * * Returns true if self array contains no elements. - * + * * [].empty? #=> true */ @@ -1469,10 +1469,10 @@ rb_ary_join(ary, sep) /* * call-seq: * array.join(sep=$,) -> str - * + * * Returns a string created by converting each element of the array to * a string, separated by sep. - * + * * [ "a", "b", "c" ].join #=> "abc" * [ "a", "b", "c" ].join("-") #=> "a-b-c" */ @@ -1487,16 +1487,16 @@ rb_ary_join_m(argc, argv, ary) rb_scan_args(argc, argv, "01", &sep); if (NIL_P(sep)) sep = rb_output_fs; - + return rb_ary_join(ary, sep); } /* * call-seq: * array.to_s -> string - * + * * Returns _self_.join. - * + * * [ "a", "e", "i", "o" ].to_s #=> "aeio" * */ @@ -1506,7 +1506,7 @@ rb_ary_to_s(ary) VALUE ary; { if (RARRAY(ary)->len == 0) return rb_str_new(0, 0); - + return rb_ary_join(ary, rb_output_fs); } @@ -1631,7 +1631,7 @@ rb_ary_inspect(ary) /* * call-seq: * array.to_a -> array - * + * * Returns _self_. If called on a subclass of Array, converts * the receiver to an Array object. */ @@ -1651,7 +1651,7 @@ rb_ary_to_a(ary) /* * call-seq: * array.to_ary -> array - * + * * Returns _self_. */ @@ -1685,10 +1685,10 @@ rb_ary_reverse(ary) /* * call-seq: - * array.reverse! -> array - * + * array.reverse! -> array + * * Reverses _self_ in place. - * + * * a = [ "a", "b", "c" ] * a.reverse! #=> ["c", "b", "a"] * a #=> ["c", "b", "a"] @@ -1704,9 +1704,9 @@ rb_ary_reverse_bang(ary) /* * call-seq: * array.reverse -> an_array - * + * * Returns a new array containing self's elements in reverse order. - * + * * [ "a", "b", "c" ].reverse #=> ["c", "b", "a"] * [ 1 ].reverse #=> [1] */ @@ -1795,14 +1795,14 @@ sort_unlock(ary) /* * call-seq: * array.sort! -> array - * array.sort! {| a,b | block } -> array - * + * array.sort! {| a,b | block } -> array + * * Sorts _self_. Comparisons for * the sort will be done using the <=> operator or using * an optional code block. The block implements a comparison between * a and b, returning -1, 0, or +1. See also * Enumerable#sort_by. - * + * * a = [ "d", "a", "e", "c", "b" ] * a.sort #=> ["a", "b", "c", "d", "e"] * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] @@ -1822,15 +1822,15 @@ rb_ary_sort_bang(ary) /* * call-seq: - * array.sort -> an_array - * array.sort {| a,b | block } -> an_array - * + * array.sort -> an_array + * array.sort {| a,b | block } -> an_array + * * Returns a new array created by sorting self. Comparisons for * the sort will be done using the <=> operator or using * an optional code block. The block implements a comparison between * a and b, returning -1, 0, or +1. See also * Enumerable#sort_by. - * + * * a = [ "d", "a", "e", "c", "b" ] * a.sort #=> ["a", "b", "c", "d", "e"] * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] @@ -1849,11 +1849,11 @@ rb_ary_sort(ary) * call-seq: * array.collect {|item| block } -> an_array * array.map {|item| block } -> an_array - * - * Invokes block once for each element of self. Creates a + * + * Invokes block once for each element of self. Creates a * new array containing the values returned by the block. * See also Enumerable#collect. - * + * * a = [ "a", "b", "c", "d" ] * a.collect {|x| x + "!" } #=> ["a!", "b!", "c!", "d!"] * a #=> ["a", "b", "c", "d"] @@ -1877,7 +1877,7 @@ rb_ary_collect(ary) return collect; } -/* +/* * call-seq: * array.collect! {|item| block } -> array * array.map! {|item| block } -> array @@ -1885,7 +1885,7 @@ rb_ary_collect(ary) * Invokes the block once for each element of _self_, replacing the * element with the value returned by _block_. * See also Enumerable#collect. - * + * * a = [ "a", "b", "c", "d" ] * a.collect! {|x| x + "!" } * a #=> [ "a!", "b!", "c!", "d!" ] @@ -1938,15 +1938,15 @@ rb_values_at(obj, olen, argc, argv, func) return result; } -/* +/* * call-seq: * array.values_at(selector,... ) -> an_array * * Returns an array containing the elements in * _self_ corresponding to the given selector(s). The selectors - * may be either integer indices or ranges. + * may be either integer indices or ranges. * See also Array#select. - * + * * a = %w{ a b c d e f } * a.values_at(1, 3, 5) * a.values_at(1, 3, 5, 7) @@ -1966,11 +1966,11 @@ rb_ary_values_at(argc, argv, ary) /* * call-seq: * array.select {|item| block } -> an_array - * + * * Invokes the block passing in successive elements from array, * returning an array containing those elements for which the block * returns a true value (equivalent to Enumerable#select). - * + * * a = %w{ a b c d e f } * a.select {|v| v =~ /[aeiou]/} #=> ["a", "e"] */ @@ -1994,14 +1994,14 @@ rb_ary_select(ary) /* * call-seq: - * array.delete(obj) -> obj or nil + * array.delete(obj) -> obj or nil * array.delete(obj) { block } -> obj or nil - * + * * Deletes items from self that are equal to obj. If * the item is not found, returns nil. If the optional * code block is given, returns the result of block if the item * is not found. - * + * * a = [ "a", "b", "b", "b", "c" ] * a.delete("b") #=> "b" * a #=> ["a", "c"] @@ -2072,11 +2072,11 @@ rb_ary_delete_at(ary, pos) /* * call-seq: * array.delete_at(index) -> obj or nil - * + * * Deletes the element at the specified index, returning that element, * or nil if the index is out of range. See also * Array#slice!. - * + * * a = %w( ant bat cat dog ) * a.delete_at(2) #=> "cat" * a #=> ["ant", "bat", "dog"] @@ -2094,18 +2094,18 @@ rb_ary_delete_at_m(ary, pos) * call-seq: * array.slice!(index) -> obj or nil * array.slice!(start, length) -> sub_array or nil - * array.slice!(range) -> sub_array or nil - * + * array.slice!(range) -> sub_array or nil + * * Deletes the element(s) given by an index (optionally with a length) * or by a range. Returns the deleted object, subarray, or * nil if the index is out of range. Equivalent to: - * + * * def slice!(*args) * result = self[*args] * self[*args] = nil * result * end - * + * * a = [ "a", "b", "c" ] * a.slice!(1) #=> "b" * a #=> ["a", "c"] @@ -2166,7 +2166,7 @@ rb_ary_slice_bang(argc, argv, ary) /* * call-seq: * array.reject! {|item| block } -> array or nil - * + * * Equivalent to Array#delete_if, deleting elements from * _self_ for which the block evaluates to true, but returns * nil if no changes were made. Also see @@ -2199,7 +2199,7 @@ rb_ary_reject_bang(ary) /* * call-seq: * array.reject {|item| block } -> an_array - * + * * Returns a new array containing the items in _self_ * for which the block is not true. */ @@ -2217,10 +2217,10 @@ rb_ary_reject(ary) /* * call-seq: * array.delete_if {|item| block } -> array - * + * * Deletes every element of self for which block evaluates * to true. - * + * * a = [ "a", "b", "c" ] * a.delete_if {|x| x >= "b" } #=> ["a"] */ @@ -2238,7 +2238,7 @@ rb_ary_delete_if(ary) * call-seq: * array.zip(arg, ...) -> an_array * array.zip(arg, ...) {| arr | block } -> nil - * + * * Converts any arguments to arrays, then merges elements of * self with corresponding elements from each argument. This * generates a sequence of self.size n-element @@ -2247,10 +2247,10 @@ rb_ary_delete_if(ary) * nil values are supplied. If a block given, it is * invoked for each output array, otherwise an array of arrays is * returned. - * + * * a = [ 4, 5, 6 ] * b = [ 7, 8, 9 ] - * + * * [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] * [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]] * a.zip([1,2],[8]) #=> [[4,1,8], [5,2,nil], [6,nil,nil]] @@ -2298,10 +2298,10 @@ rb_ary_zip(argc, argv, ary) /* * call-seq: * array.transpose -> an_array - * + * * Assumes that self is an array of arrays and transposes the * rows and columns. - * + * * a = [[1,2], [3,4], [5,6]] * a.transpose #=> [[1, 3, 5], [2, 4, 6]] */ @@ -2338,10 +2338,10 @@ rb_ary_transpose(ary) /* * call-seq: * array.replace(other_array) -> array - * + * * Replaces the contents of self with the contents of * other_array, truncating or expanding if necessary. - * + * * a = [ "a", "b", "c", "d", "e" ] * a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"] * a #=> ["x", "y", "z"] @@ -2367,7 +2367,7 @@ rb_ary_replace(copy, orig) return copy; } -/* +/* * call-seq: * array.clear -> array * @@ -2398,14 +2398,14 @@ rb_ary_clear(ary) * array.fill {|index| block } -> array * array.fill(start [, length] ) {|index| block } -> array * array.fill(range) {|index| block } -> array - * + * * The first three forms set the selected elements of self (which * may be the entire array) to obj. A start of * nil is equivalent to zero. A length of * nil is equivalent to self.length. The last three * forms fill the array with the value of the block. The block is * passed the absolute index of each element to be filled. - * + * * a = [ "a", "b", "c", "d" ] * a.fill("x") #=> ["x", "x", "x", "x"] * a.fill("z", 2, 2) #=> ["x", "x", "z", "z"] @@ -2489,13 +2489,13 @@ rb_ary_fill(argc, argv, ary) return ary; } -/* +/* * call-seq: * array + other_array -> an_array * * Concatenation---Returns a new array built by concatenating the * two arrays together to produce a third array. - * + * * [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ] */ @@ -2515,12 +2515,12 @@ rb_ary_plus(x, y) return z; } -/* +/* * call-seq: * array.concat(other_array) -> array * * Appends the elements in other_array to _self_. - * + * * [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ] */ @@ -2537,7 +2537,7 @@ rb_ary_concat(x, y) } -/* +/* * call-seq: * array * int -> an_array * array * str -> a_string @@ -2585,7 +2585,7 @@ rb_ary_times(ary, times) return ary2; } -/* +/* * call-seq: * array.assoc(obj) -> an_array or nil * @@ -2624,12 +2624,12 @@ rb_ary_assoc(ary, key) /* * call-seq: * array.rassoc(key) -> an_array or nil - * + * * Searches through the array whose elements are also arrays. Compares * key with the second element of each contained array using * ==. Returns the first contained array that matches. See * also Array#assoc. - * + * * a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ] * a.rassoc("two") #=> [2, "two"] * a.rassoc("four") #=> nil @@ -2668,7 +2668,7 @@ recursive_equal(ary1, ary2, recur) return Qtrue; } -/* +/* * call-seq: * array == other_array -> bool * @@ -2772,11 +2772,11 @@ rb_ary_hash(ary) /* * call-seq: * array.include?(obj) -> true or false - * + * * Returns true if the given object is present in * self (that is, if any object == anObject), * false otherwise. - * + * * a = [ "a", "b", "c" ] * a.include?("b") #=> true * a.include?("z") #=> false @@ -2788,7 +2788,7 @@ rb_ary_includes(ary, item) VALUE item; { long i; - + for (i=0; ilen; i++) { if (rb_equal(RARRAY(ary)->ptr[i], item)) { return Qtrue; @@ -2821,7 +2821,7 @@ recursive_cmp(ary1, ary2, recur) return Qundef; } -/* +/* * call-seq: * array <=> other_array -> -1, 0, +1 * @@ -2835,7 +2835,7 @@ recursive_cmp(ary1, ary2, recur) * ``equal'' according to Array#<=> if and only if they have * the same length and the value of each element is equal to the * value of the corresponding element in the other array. - * + * * [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1 * [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1 * @@ -2876,7 +2876,7 @@ ary_make_hash(ary1, ary2) return hash; } -/* +/* * call-seq: * array - other_array -> an_array * @@ -2906,7 +2906,7 @@ rb_ary_diff(ary1, ary2) return ary3; } -/* +/* * call-seq: * array & other_array * @@ -2939,7 +2939,7 @@ rb_ary_and(ary1, ary2) return ary3; } -/* +/* * call-seq: * array | other_array -> an_array * @@ -2980,11 +2980,11 @@ rb_ary_or(ary1, ary2) /* * call-seq: * array.uniq! -> array or nil - * + * * Removes duplicate elements from _self_. * Returns nil if no changes are made (that is, no * duplicates are found). - * + * * a = [ "a", "a", "b", "b", "c" ] * a.uniq! #=> ["a", "b", "c"] * b = [ "a", "b", "c" ] @@ -3017,9 +3017,9 @@ rb_ary_uniq_bang(ary) /* * call-seq: * array.uniq -> an_array - * + * * Returns a new array by removing duplicate values in self. - * + * * a = [ "a", "a", "b", "b", "c" ] * a.uniq #=> ["a", "b", "c"] */ @@ -3033,7 +3033,7 @@ rb_ary_uniq(ary) return ary; } -/* +/* * call-seq: * array.compact! -> array or nil * @@ -3053,7 +3053,7 @@ rb_ary_compact_bang(ary) rb_ary_modify(ary); p = t = RARRAY(ary)->ptr; end = p + RARRAY(ary)->len; - + while (t < end) { if (NIL_P(*t)) t++; else *p++ = *t++; @@ -3089,11 +3089,11 @@ rb_ary_compact(ary) /* * call-seq: * array.nitems -> int - * + * * Returns the number of non-nil elements in _self_. * * May be zero. - * + * * [ 1, nil, 3, nil, 5 ].nitems #=> 3 */ @@ -3117,7 +3117,7 @@ rb_ary_nitems(ary) * array.count -> int * array.count(obj) -> int * array.count { |item| block } -> int - * + * * Returns the number of elements. If an argument is given, counts * the number of elements which equals to obj. If a block is * given, counts the number of elements yielding a true value. @@ -3223,12 +3223,12 @@ flatten(ary, level, modified) * call-seq: * array.flatten! -> array or nil * array.flatten!(level) -> array or nil - * + * * Flattens _self_ in place. * Returns nil if no modifications were made (i.e., * array contains no subarrays.) If the optional level * argument determines the level of recursion to flatten. - * + * * a = [ 1, 2, [3, [4, 5] ] ] * a.flatten! #=> [1, 2, 3, 4, 5] * a.flatten! #=> nil @@ -3261,12 +3261,12 @@ rb_ary_flatten_bang(argc, argv, ary) * call-seq: * array.flatten -> an_array * array.flatten(level) -> an_array - * + * * Returns a new array that is a one-dimensional flattening of this * array (recursively). That is, for every element that is an array, * extract its elements into the new array. If the optional * level argument determines the level of recursion to flatten. - * + * * s = [ 1, 2, 3 ] #=> [1, 2, 3] * t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]] * a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10] @@ -3297,7 +3297,7 @@ rb_ary_flatten(argc, argv, ary) /* * call-seq: * array.shuffle! -> array or nil - * + * * Shuffles elements in _self_ in place. */ @@ -3322,9 +3322,9 @@ rb_ary_shuffle_bang(ary) /* * call-seq: * array.shuffle -> an_array - * + * * Returns a new array with elements of this array shuffled. - * + * * a = [ 1, 2, 3 ] #=> [1, 2, 3] * a.shuffle #=> [2, 3, 1] */ @@ -3343,11 +3343,11 @@ rb_ary_shuffle(ary) * call-seq: * array.sample -> obj * array.sample(n) -> an_array - * + * * Choose a random element, or the random +n+ elements, fron the array. * If the array is empty, the first form returns nil, and the * second form returns an empty array. - * + * */ @@ -3360,7 +3360,7 @@ rb_ary_sample(argc, argv, ary) VALUE nv, result; int n, len, i, j; - len = RARRAY_LEN(ary); + len = RARRAY_LEN(ary); if (argc == 0) { if (len == 0) return Qnil; i = rb_genrand_real()*len; @@ -3392,11 +3392,11 @@ rb_ary_sample(argc, argv, ary) /* * call-seq: * array.choice -> obj - * + * * Choose a random element from an array. NOTE: This method will be * deprecated in future. Use #sample instead. */ - + static VALUE rb_ary_choice(ary) VALUE ary; @@ -3416,16 +3416,16 @@ rb_ary_choice(ary) * call-seq: * ary.cycle {|obj| block } * ary.cycle(n) {|obj| block } - * + * * Calls block for each element repeatedly _n_ times or * forever if none or nil is given. If a non-positive number is * given or the array is empty, does nothing. Returns nil if the * loop has finished without getting interrupted. - * + * * a = ["a", "b", "c"] * a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever. * a.cycle(2) {|x| puts x } # print, a, b, c, a, b, c. - * + * */ static VALUE @@ -3461,9 +3461,9 @@ rb_ary_cycle(argc, argv, ary) /* * Recursively compute permutations of r elements of the set [0..n-1]. * When we have a complete permutation of array indexes, copy the values - * at those indexes into a new array and yield that array. + * at those indexes into a new array and yield that array. * - * n: the size of the set + * n: the size of the set * r: the number of elements in each permutation * p: the array (of size r) that we're filling in * index: what index we're filling in now @@ -3483,7 +3483,7 @@ permute0(n, r, p, index, used, values) if (index < r-1) { /* if not done yet */ used[i] = 1; /* mark index used */ permute0(n, r, p, index+1, /* recurse */ - used, values); + used, values); used[i] = 0; /* index unused */ } else { @@ -3508,15 +3508,15 @@ permute0(n, r, p, index, used, values) * ary.permutation -> enumerator * ary.permutation(n) { |p| block } -> array * ary.permutation(n) -> enumerator - * + * * When invoked with a block, yield all permutations of length n * of the elements of ary, then return the array itself. * If n is not specified, yield all permutations of all elements. - * The implementation makes no guarantees about the order in which + * The implementation makes no guarantees about the order in which * the permutations are yielded. * * When invoked without a block, return an enumerator object instead. - * + * * Examples: * * a = [1, 2, 3] @@ -3542,7 +3542,7 @@ rb_ary_permutation(argc, argv, ary) rb_scan_args(argc, argv, "01", &num); r = NIL_P(num) ? n : NUM2LONG(num); /* Permutation size from argument */ - if (r < 0 || n < r) { + if (r < 0 || n < r) { /* no permutations: yield nothing */ } else if (r == 0) { /* exactly one permutation: the zero-length array */ @@ -3594,14 +3594,14 @@ combi_len(n, k) * call-seq: * ary.combination(n) { |c| block } -> ary * ary.combination(n) -> enumerator - * - * When invoked with a block, yields all combinations of length n + * + * When invoked with a block, yields all combinations of length n * of elements from ary and then returns ary itself. - * The implementation makes no guarantees about the order in which + * The implementation makes no guarantees about the order in which * the combinations are yielded. * * When invoked without a block, returns an enumerator object instead. - * + * * Examples: * * a = [1, 2, 3, 4] @@ -3611,7 +3611,7 @@ combi_len(n, k) * a.combination(4).to_a #=> [[1,2,3,4]] * a.combination(0).to_a #=> [[]] # one combination of length 0 * a.combination(5).to_a #=> [] # no combinations of length 5 - * + * */ static VALUE @@ -3663,11 +3663,11 @@ rb_ary_combination(ary, num) /* * call-seq: * ary.product(other_ary, ...) - * + * * Returns an array of all combinations of elements from all arrays. * The length of the returned array is the product of the length * of ary and the argument arrays - * + * * [1,2,3].product([4,5]) # => [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]] * [1,2].product([1,2]) # => [[1,1],[1,2],[2,1],[2,2]] * [1,2].product([3,4],[5,6]) # => [[1,3,5],[1,3,6],[1,4,5],[1,4,6], @@ -3697,7 +3697,7 @@ rb_ary_product(argc, argv, ary) /* initialize the arrays of arrays */ arrays[0] = ary; for (i = 1; i < n; i++) arrays[i] = to_ary(argv[i-1]); - + /* initialize the counters for the arrays */ for (i = 0; i < n; i++) counters[i] = 0; @@ -3743,12 +3743,12 @@ rb_ary_product(argc, argv, ary) /* * call-seq: * ary.take(n) => array - * + * * Returns first n elements from ary. - * + * * a = [1, 2, 3, 4, 5, 0] * a.take(3) # => [1, 2, 3] - * + * */ static VALUE @@ -3767,13 +3767,13 @@ rb_ary_take(obj, n) /* * call-seq: * ary.take_while {|arr| block } => array - * + * * Passes elements to the block until the block returns nil or false, * then stops iterating and returns an array of all prior elements. - * + * * a = [1, 2, 3, 4, 5, 0] * a.take_while {|i| i < 3 } # => [1, 2] - * + * */ static VALUE @@ -3792,13 +3792,13 @@ rb_ary_take_while(ary) /* * call-seq: * ary.drop(n) => array - * + * * Drops first n elements from ary, and returns rest elements * in an array. - * + * * a = [1, 2, 3, 4, 5, 0] * a.drop(3) # => [4, 5, 0] - * + * */ static VALUE @@ -3820,14 +3820,14 @@ rb_ary_drop(ary, n) /* * call-seq: * ary.drop_while {|arr| block } => array - * + * * Drops elements up to, but not including, the first element for * which the block returns nil or false and returns an array * containing the remaining elements. - * + * * a = [1, 2, 3, 4, 5, 0] * a.drop_while {|i| i < 3 } # => [3, 4, 5, 0] - * + * */ static VALUE @@ -3845,11 +3845,11 @@ rb_ary_drop_while(ary) -/* Arrays are ordered, integer-indexed collections of any object. - * Array indexing starts at 0, as in C or Java. A negative index is - * assumed to be relative to the end of the array---that is, an index of -1 - * indicates the last element of the array, -2 is the next to last - * element in the array, and so on. +/* Arrays are ordered, integer-indexed collections of any object. + * Array indexing starts at 0, as in C or Java. A negative index is + * assumed to be relative to the end of the array---that is, an index of -1 + * indicates the last element of the array, -2 is the next to last + * element in the array, and so on. */ void diff --git a/class.c b/class.c index 054be60d53..8956cc551c 100644 --- a/class.c +++ b/class.c @@ -408,7 +408,7 @@ rb_include_module(klass, module) if (!OBJ_TAINTED(klass)) { rb_secure(4); } - + if (TYPE(module) != T_MODULE) { Check_Type(module, T_MODULE); } @@ -447,16 +447,16 @@ rb_include_module(klass, module) /* * call-seq: * mod.included_modules -> array - * + * * Returns the list of modules included in mod. - * + * * module Mixin * end - * + * * module Outer * include Mixin * end - * + * * Mixin.included_modules #=> [] * Outer.included_modules #=> [Mixin] */ @@ -479,10 +479,10 @@ rb_mod_included_modules(mod) /* * call-seq: * mod.include?(module) => true or false - * + * * Returns true if module is included in * mod or one of mod's ancestors. - * + * * module A * end * class B @@ -514,15 +514,15 @@ rb_mod_include_p(mod, mod2) /* * call-seq: * mod.ancestors -> array - * + * * Returns a list of modules included in mod (including * mod itself). - * + * * module Mod * include Math * include Comparable * end - * + * * Mod.ancestors #=> [Mod, Comparable, Math] * Math.ancestors #=> [Math] */ @@ -663,14 +663,14 @@ class_instance_method_list(argc, argv, mod, func) /* * call-seq: * mod.instance_methods(include_super=true) => array - * + * * Returns an array containing the names of public instance methods in * the receiver. For a module, these are the public methods; for a * class, they are the instance (not singleton) methods. With no * argument, or with an argument that is false, the * instance methods in mod are returned, otherwise the methods * in mod and mod's superclasses are returned. - * + * * module A * def method1() end * end @@ -680,7 +680,7 @@ class_instance_method_list(argc, argv, mod, func) * class C < B * def method3() end * end - * + * * A.instance_methods #=> ["method1"] * B.instance_methods(false) #=> ["method2"] * C.instance_methods(false) #=> ["method3"] @@ -699,7 +699,7 @@ rb_class_instance_methods(argc, argv, mod) /* * call-seq: * mod.protected_instance_methods(include_super=true) => array - * + * * Returns a list of the protected instance methods defined in * mod. If the optional parameter is not false, the * methods of any ancestors are included. @@ -717,11 +717,11 @@ rb_class_protected_instance_methods(argc, argv, mod) /* * call-seq: * mod.private_instance_methods(include_super=true) => array - * + * * Returns a list of the private instance methods defined in * mod. If the optional parameter is not false, the * methods of any ancestors are included. - * + * * module Mod * def method1() end * private :method1 @@ -743,7 +743,7 @@ rb_class_private_instance_methods(argc, argv, mod) /* * call-seq: * mod.public_instance_methods(include_super=true) => array - * + * * Returns a list of the public instance methods defined in mod. * If the optional parameter is not false, the methods of * any ancestors are included. @@ -761,30 +761,30 @@ rb_class_public_instance_methods(argc, argv, mod) /* * call-seq: * obj.singleton_methods(all=true) => array - * + * * Returns an array of the names of singleton methods for obj. * If the optional all parameter is true, the list will include * methods in modules included in obj. - * + * * module Other * def three() end * end - * + * * class Single * def Single.four() end * end - * + * * a = Single.new - * + * * def a.one() * end - * + * * class << a * include Other * def two() * end * end - * + * * Single.singleton_methods #=> ["four"] * a.singleton_methods(false) #=> ["two", "one"] * a.singleton_methods #=> ["two", "one", "three"] diff --git a/compar.c b/compar.c index 1488b2c65d..8f3f83e40e 100644 --- a/compar.c +++ b/compar.c @@ -72,7 +72,7 @@ cmp_failed() /* * call-seq: * obj == other => true or false - * + * * Compares two objects based on the receiver's <=> * method, returning true if it returns 0. Also returns true if * _obj_ and _other_ are the same object. @@ -93,7 +93,7 @@ cmp_equal(x, y) /* * call-seq: * obj > other => true or false - * + * * Compares two objects based on the receiver's <=> * method, returning true if it returns 1. */ @@ -112,7 +112,7 @@ cmp_gt(x, y) /* * call-seq: * obj >= other => true or false - * + * * Compares two objects based on the receiver's <=> * method, returning true if it returns 0 or 1. */ @@ -131,7 +131,7 @@ cmp_ge(x, y) /* * call-seq: * obj < other => true or false - * + * * Compares two objects based on the receiver's <=> * method, returning true if it returns -1. */ @@ -151,7 +151,7 @@ cmp_lt(x, y) /* * call-seq: * obj <= other => true or false - * + * * Compares two objects based on the receiver's <=> * method, returning true if it returns -1 or 0. */ @@ -170,16 +170,16 @@ cmp_le(x, y) /* * call-seq: * obj.between?(min, max) => true or false - * + * * Returns false if obj <=> * min is less than zero or if anObject <=> * max is greater than zero, true otherwise. - * + * * 3.between?(1, 5) #=> true * 6.between?(1, 5) #=> false * 'cat'.between?('ant', 'dog') #=> true * 'gnu'.between?('ant', 'dog') #=> false - * + * */ static VALUE @@ -200,7 +200,7 @@ cmp_between(x, min, max) * <=> to implement the conventional comparison operators * (<, <=, ==, >=, * and >) and the method between?. - * + * * class SizeMatters * include Comparable * attr :str @@ -214,18 +214,18 @@ cmp_between(x, min, max) * @str * end * end - * + * * s1 = SizeMatters.new("Z") * s2 = SizeMatters.new("YY") * s3 = SizeMatters.new("XXX") * s4 = SizeMatters.new("WWWW") * s5 = SizeMatters.new("VVVVV") - * + * * s1 < s2 #=> true * s4.between?(s1, s3) #=> false * s4.between?(s3, s5) #=> true * [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV] - * + * */ void diff --git a/dir.c b/dir.c index d166fa4ed2..06b0839024 100644 --- a/dir.c +++ b/dir.c @@ -1679,7 +1679,7 @@ dir_globs(argc, argv, flags) * Dir[ string [, string ...] ] => array * * Equivalent to calling - * Dir.glob(array,0) and + * Dir.glob(array,0) and * Dir.glob([string,...],0). * */ diff --git a/dln.c b/dln.c index aea6e1c3f1..e62870b265 100644 --- a/dln.c +++ b/dln.c @@ -814,7 +814,7 @@ load_1(fd, disp, need_init) } } /* end.. look it up */ else { /* is static */ - switch (R_SYMBOL(rel)) { + switch (R_SYMBOL(rel)) { case N_TEXT: case N_DATA: datum = block; @@ -1226,7 +1226,7 @@ aix_loaderror(const char *pathname) char *message[8], errbuf[1024]; int i,j; - struct errtab { + struct errtab { int errnum; char *errstr; } load_errtab[] = { @@ -1249,7 +1249,7 @@ aix_loaderror(const char *pathname) snprintf(errbuf, 1024, "load failed - %s ", pathname); - if (!loadquery(1, &message[0], sizeof(message))) + if (!loadquery(1, &message[0], sizeof(message))) ERRBUF_APPEND(strerror(errno)); for(i = 0; message[i] && *message[i]; i++) { int nerr = atoi(message[i]); @@ -1257,7 +1257,7 @@ aix_loaderror(const char *pathname) if (nerr == load_errtab[i].errnum && load_errtab[i].errstr) ERRBUF_APPEND(load_errtab[i].errstr); } - while (isdigit(*message[i])) message[i]++; + while (isdigit(*message[i])) message[i]++; ERRBUF_APPEND(message[i]); ERRBUF_APPEND("\n"); } @@ -1416,7 +1416,7 @@ dln_load(file) #define DLN_DEFINED /*---------------------------------------------------- By SHIROYAMA Takayuki Psi@fortune.nest.or.jp - + Special Thanks... Yu tomoak-i@is.aist-nara.ac.jp, Mi hisho@tasihara.nest.or.jp, @@ -1431,9 +1431,9 @@ dln_load(file) char *object_files[2] = {NULL, NULL}; void (*init_fct)(); - + object_files[0] = (char*)file; - + s = NXOpenFile(2,NX_WRITEONLY); /* Load object file, if return value ==0 , load failed*/ @@ -1480,7 +1480,7 @@ dln_load(file) /* lookup the initial function */ if(!NSIsSymbolNameDefined(buf)) { rb_loaderror("Failed to lookup Init function %.200s",file); - } + } init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf)); (*init_fct)(); @@ -1502,7 +1502,7 @@ dln_load(file) rb_loaderror("Failed to load add_on %.200s error_code=%x", file, img_id); } - + /* find symbol for module initialize function. */ /* The Be Book KernelKit Images section described to use B_SYMBOL_TYPE_TEXT for symbol of function, not @@ -1564,7 +1564,7 @@ dln_load(file) /* Load the fragment (or return the connID if it is already loaded */ fragname[0] = 0; - err = GetDiskFragment(&libspec, 0, 0, fragname, + err = GetDiskFragment(&libspec, 0, 0, fragname, kLoadCFrag, &connID, &mainAddr, errMessage); if (err) { @@ -1615,8 +1615,8 @@ dln_load(file) status = lib$find_image_symbol ( &fname_d, - &buf_d, - &init_fct, + &buf_d, + &init_fct, &image_d); lib$establish(0); diff --git a/enum.c b/enum.c index 1502d00aeb..873fd31809 100644 --- a/enum.c +++ b/enum.c @@ -1517,8 +1517,8 @@ enum_each_with_index(obj) /* * call-seq: - * enum.reverse_each {|item| block } - * + * enum.reverse_each {|item| block } + * * Traverses enum in reverse order. */ diff --git a/error.c b/error.c index 3b79ea0fa7..a0186182f6 100644 --- a/error.c +++ b/error.c @@ -340,7 +340,7 @@ rb_exc_new3(etype, str) * call-seq: * Exception.new(msg = nil) => exception * - * Construct a new Exception object, optionally passing in + * Construct a new Exception object, optionally passing in * a message. */ @@ -364,12 +364,12 @@ exc_initialize(argc, argv, exc) * * call-seq: * exc.exception(string) -> an_exception or exc - * + * * With no argument, or if the argument is the same as the receiver, * return the receiver. Otherwise, create a new * exception object of the same class as the receiver, but with a * message equal to string.to_str. - * + * */ static VALUE @@ -457,27 +457,27 @@ exc_inspect(exc) /* * call-seq: * exception.backtrace => array - * + * * Returns any backtrace associated with the exception. The backtrace * is an array of strings, each containing either ``filename:lineNo: in * `method''' or ``filename:lineNo.'' - * + * * def a * raise "boom" * end - * + * * def b * a() * end - * + * * begin * b() * rescue => detail * print detail.backtrace.join("\n") * end - * + * * produces: - * + * * prog.rb:2:in `a' * prog.rb:6:in `b' * prog.rb:10 @@ -519,11 +519,11 @@ rb_check_backtrace(bt) /* * call-seq: * exc.set_backtrace(array) => array - * + * * Sets the backtrace information associated with exc. The * argument must be an array of String objects in the * format described in Exception#backtrace. - * + * */ static VALUE @@ -795,7 +795,7 @@ rb_invalid_str(str, type) rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING(s)->ptr); } -/* +/* * Document-module: Errno * * Ruby exception objects are subclasses of Exception. @@ -805,21 +805,21 @@ rb_invalid_str(str, type) * number generating its own subclass of SystemCallError. * As the subclass is created in module Errno, its name * will start Errno::. - * + * * The names of the Errno:: classes depend on * the environment in which Ruby runs. On a typical Unix or Windows * platform, there are Errno classes such as * Errno::EACCES, Errno::EAGAIN, * Errno::EINTR, and so on. - * + * * The integer operating system error number corresponding to a * particular error is available as the class constant * Errno::error::Errno. - * + * * Errno::EACCES::Errno #=> 13 * Errno::EAGAIN::Errno #=> 11 * Errno::EINTR::Errno #=> 4 - * + * * The full list of operating system errors on your particular platform * are available as the constants of Errno. * @@ -974,7 +974,7 @@ syserr_eqq(self, exc) * statements in begin/end blocks. Exception * objects carry information about the exception---its type (the * exception's class name), an optional descriptive string, and - * optional traceback information. Programs may subclass + * optional traceback information. Programs may subclass * Exception to add additional information. */ @@ -1132,14 +1132,14 @@ rb_sys_warning(fmt, va_alist) char buf[BUFSIZ]; va_list args; int errno_save; - + errno_save = errno; if (!RTEST(ruby_verbose)) return; snprintf(buf, BUFSIZ, "warning: %s", fmt); snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save)); - + va_init_list(args, fmt); warn_print(buf, args); va_end(args); diff --git a/eval.c b/eval.c index ae5cad5265..855e17cbd6 100644 --- a/eval.c +++ b/eval.c @@ -121,7 +121,7 @@ rb_jump_context(env, val) * IA64 register stack and SPARC register window combination problem. * * Assume following code sequence. - * + * * 1. set a register in the register stack/window such as r32/l0. * 2. call getcontext. * 3. use the register. @@ -626,7 +626,7 @@ rb_remove_method(klass, name) /* * call-seq: * remove_method(symbol) => self - * + * * Removes the method identified by _symbol_ from the current * class. For an example, see Module.undef_method. */ @@ -1389,7 +1389,7 @@ void Init_ext _((void)); #ifdef HAVE_NATIVETHREAD static rb_nativethread_t ruby_thid; -int +int is_ruby_native_thread() { return NATIVETHREAD_EQUAL(ruby_thid, NATIVETHREAD_CURRENT()); } @@ -2017,9 +2017,9 @@ cvar_cbase() /* * call-seq: * Module.nesting => array - * + * * Returns the list of +Modules+ nested at the point of call. - * + * * module M1 * module M2 * $a = Module.nesting @@ -2048,14 +2048,14 @@ rb_mod_nesting() /* * call-seq: * Module.constants => array - * + * * Returns an array of the names of all constants defined in the * system. This list includes the names of all modules and classes. - * + * * p Module.constants.sort[1..5] - * + * * produces: - * + * * ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"] */ @@ -2152,12 +2152,12 @@ rb_undef(klass, id) /* * call-seq: * undef_method(symbol) => self - * + * * Prevents the current class from responding to calls to the named * method. Contrast this with remove_method, which deletes * the method from the particular class; Ruby will still search * superclasses and mixed-in modules for a possible receiver. - * + * * class Parent * def hello * puts "In parent" @@ -2168,25 +2168,25 @@ rb_undef(klass, id) * puts "In child" * end * end - * - * + * + * * c = Child.new * c.hello - * - * + * + * * class Child * remove_method :hello # remove from child, still in parent * end * c.hello - * - * + * + * * class Child * undef_method :hello # prevent any calls to 'hello' * end * c.hello - * + * * produces: - * + * * In child * In parent * prog.rb:23: undefined method `hello' for # (NoMethodError) @@ -2265,10 +2265,10 @@ rb_alias(klass, name, def) /* * call-seq: * alias_method(new_name, old_name) => self - * + * * Makes new_name a new copy of the method old_name. This can * be used to retain access to methods that are overridden. - * + * * module Mod * alias_method :orig_exit, :exit * def exit(code=0) @@ -2278,9 +2278,9 @@ rb_alias(klass, name, def) * end * include Mod * exit(99) - * + * * produces: - * + * * Exiting with code 99 */ @@ -2667,7 +2667,7 @@ rb_remove_event_hook(func) * call-seq: * set_trace_func(proc) => proc * set_trace_func(nil) => nil - * + * * Establishes _proc_ as the handler for tracing, or disables * tracing if the parameter is +nil+. _proc_ takes up * to six parameters: an event name, a filename, a line number, an @@ -3454,7 +3454,7 @@ rb_eval(self, n) VALUE beg = rb_eval(self, node->nd_beg); VALUE end = rb_eval(self, node->nd_end); result = rb_range_new(beg, end, nd_type(node) == NODE_DOT3); - } + } break; case NODE_FLIP2: /* like AWK */ @@ -3598,7 +3598,7 @@ rb_eval(self, n) if (argc && DMETHOD_P()) { if (TYPE(RBASIC(ruby_scope)->klass) != T_ARRAY || RARRAY(RBASIC(ruby_scope)->klass)->len != argc) { - rb_raise(rb_eRuntimeError, + rb_raise(rb_eRuntimeError, "super: specify arguments explicitly"); } argv = RARRAY(RBASIC(ruby_scope)->klass)->ptr; @@ -4219,7 +4219,7 @@ rb_eval(self, n) break; case NODE_NEWLINE: - EXEC_EVENT_HOOK(RUBY_EVENT_LINE, node, self, + EXEC_EVENT_HOOK(RUBY_EVENT_LINE, node, self, ruby_frame->last_func, ruby_frame->last_class); node = node->nd_next; @@ -4323,7 +4323,7 @@ rb_respond_to(obj, id) /* * call-seq: * obj.respond_to?(symbol, include_private=false) => true or false - * + * * Returns +true+> if _obj_ responds to the given * method. Private methods are included in the search only if the * optional second parameter evaluates to +true+. @@ -4349,11 +4349,11 @@ obj_respond_to(argc, argv, obj) /* * call-seq: * mod.method_defined?(symbol) => true or false - * + * * Returns +true+ if the named method is defined by * _mod_ (or its included modules and, if _mod_ is a class, * its ancestors). Public and protected methods are matched. - * + * * module A * def method1() end * end @@ -4364,7 +4364,7 @@ obj_respond_to(argc, argv, obj) * include A * def method3() end * end - * + * * A.method_defined? :method1 #=> true * C.method_defined? "method1" #=> true * C.method_defined? "method2" #=> true @@ -4384,11 +4384,11 @@ rb_mod_method_defined(mod, mid) /* * call-seq: * mod.public_method_defined?(symbol) => true or false - * + * * Returns +true+ if the named public method is defined by * _mod_ (or its included modules and, if _mod_ is a class, * its ancestors). - * + * * module A * def method1() end * end @@ -4400,7 +4400,7 @@ rb_mod_method_defined(mod, mid) * include A * def method3() end * end - * + * * A.method_defined? :method1 #=> true * C.public_method_defined? "method1" #=> true * C.public_method_defined? "method2" #=> false @@ -4424,11 +4424,11 @@ rb_mod_public_method_defined(mod, mid) /* * call-seq: * mod.private_method_defined?(symbol) => true or false - * + * * Returns +true+ if the named private method is defined by * _ mod_ (or its included modules and, if _mod_ is a class, * its ancestors). - * + * * module A * def method1() end * end @@ -4440,7 +4440,7 @@ rb_mod_public_method_defined(mod, mid) * include A * def method3() end * end - * + * * A.method_defined? :method1 #=> true * C.private_method_defined? "method1" #=> false * C.private_method_defined? "method2" #=> true @@ -4464,11 +4464,11 @@ rb_mod_private_method_defined(mod, mid) /* * call-seq: * mod.protected_method_defined?(symbol) => true or false - * + * * Returns +true+ if the named protected method is defined * by _mod_ (or its included modules and, if _mod_ is a * class, its ancestors). - * + * * module A * def method1() end * end @@ -4480,7 +4480,7 @@ rb_mod_private_method_defined(mod, mid) * include A * def method3() end * end - * + * * A.method_defined? :method1 #=> true * C.protected_method_defined? "method1" #=> false * C.protected_method_defined? "method2" #=> true @@ -4531,12 +4531,12 @@ rb_exit(status) * exit(integer=0) * Kernel::exit(integer=0) * Process::exit(integer=0) - * + * * Initiates the termination of the Ruby script by raising the * SystemExit exception. This exception may be caught. The * optional parameter is used to return a status code to the invoking * environment. - * + * * begin * exit * puts "never get here" @@ -4544,22 +4544,22 @@ rb_exit(status) * puts "rescued a SystemExit exception" * end * puts "after begin block" - * + * * produces: - * + * * rescued a SystemExit exception * after begin block - * + * * Just prior to termination, Ruby executes any at_exit functions * (see Kernel::at_exit) and runs any object finalizers (see * ObjectSpace::define_finalizer). - * + * * at_exit { puts "at_exit function" } * ObjectSpace.define_finalizer("string", proc { puts "in finalizer" }) * exit - * + * * produces: - * + * * at_exit function * in finalizer */ @@ -4602,7 +4602,7 @@ rb_f_exit(argc, argv) * abort * Kernel::abort * Process::abort - * + * * Terminate execution immediately, effectively by calling * Kernel.exit(1). If _msg_ is given, it is written * to STDERR prior to terminating. @@ -4750,7 +4750,7 @@ rb_interrupt() * fail * fail(string) * fail(exception [, string [, array]]) - * + * * With no arguments, raises the exception in $! or raises * a RuntimeError if $! is +nil+. * With a single +String+ argument, raises a @@ -4761,7 +4761,7 @@ rb_interrupt() * message associated with the exception, and the third parameter is an * array of callback information. Exceptions are caught by the * +rescue+ clause of begin...end blocks. - * + * * raise "Failed to create socket" * raise ArgumentError, "No parameters", caller */ @@ -4860,11 +4860,11 @@ rb_iterator_p() * call-seq: * block_given? => true or false * iterator? => true or false - * + * * Returns true if yield would execute a * block in the current context. The iterator? form * is mildly deprecated. - * + * * def try * if block_given? * yield @@ -5292,10 +5292,10 @@ loop_i() /* * call-seq: - * loop {|| block } - * + * loop {|| block } + * * Repeatedly executes the block. - * + * * loop do * print "Input: " * line = gets @@ -5701,7 +5701,7 @@ static int last_call_status; /* * call-seq: * obj.method_missing(symbol [, *args] ) => result - * + * * Invoked by Ruby when obj is sent a message it cannot handle. * symbol is the symbol for the method called, and args * are any arguments that were passed to it. By default, the interpreter @@ -5711,7 +5711,7 @@ static int last_call_status; * a class Roman, which responds to methods with names * consisting of roman numerals, returning the corresponding integer * values. - * + * * class Roman * def romanToInt(str) * # ... @@ -5721,7 +5721,7 @@ static int last_call_status; * romanToInt(str) * end * end - * + * * r = Roman.new * r.iv #=> 4 * r.xxiii #=> 23 @@ -6127,7 +6127,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags) } else { VALUE v; - + if (argc > 0) { v = rb_ary_new4(argc,argv); i = -i - 1; @@ -6261,11 +6261,11 @@ rb_apply(recv, mid, args) * call-seq: * obj.send(symbol [, args...]) => obj * obj.__send__(symbol [, args...]) => obj - * + * * Invokes the method identified by _symbol_, passing it any * arguments specified. You can use \_\_send__ if the name * +send+ clashes with an existing method in _obj_. - * + * * class Klass * def hello(*args) * "Hello " + args.join(' ') @@ -6472,13 +6472,13 @@ backtrace(lev) /* * call-seq: * caller(start=1) => array - * + * * Returns the current execution stack---an array containing strings in * the form ``file:line'' or ``file:line: in * `method'''. The optional _start_ parameter * determines the number of initial stack entries to omit from the * result. - * + * * def a(skip) * caller(skip) * end @@ -6710,14 +6710,14 @@ eval(self, src, scope, file, line) /* * call-seq: * eval(string [, binding [, filename [,lineno]]]) => obj - * + * * Evaluates the Ruby expression(s) in string. If * binding is given, the evaluation is performed in its * context. The binding may be a Binding object or a * Proc object. If the optional filename and * lineno parameters are present, they will be used when * reporting syntax errors. - * + * * def getBinding(str) * return binding * end @@ -6920,7 +6920,7 @@ specific_eval(argc, argv, klass, self) * call-seq: * obj.instance_eval(string [, filename [, lineno]] ) => obj * obj.instance_eval {| | block } => obj - * + * * Evaluates a string containing Ruby source code, or the given block, * within the context of the receiver (_obj_). In order to set the * context, the variable +self+ is set to _obj_ while @@ -6929,7 +6929,7 @@ specific_eval(argc, argv, klass, self) * that takes a +String+, the optional second and third * parameters supply a filename and starting line number that are used * when reporting compilation errors. - * + * * class Klass * def initialize * @secret = 99 @@ -6995,21 +6995,21 @@ rb_obj_instance_exec(argc, argv, self) * call-seq: * mod.class_eval(string [, filename [, lineno]]) => obj * mod.module_eval {|| block } => obj - * + * * Evaluates the string or block in the context of _mod_. This can * be used to add methods to a class. module_eval returns * the result of evaluating its argument. The optional _filename_ * and _lineno_ parameters set the text for error messages. - * + * * class Thing * end * a = %q{def hello() "Hello there!" end} * Thing.module_eval(a) * puts Thing.new.hello() * Thing.module_eval("invalid code", "dummy", 123) - * + * * produces: - * + * * Hello there! * dummy:123:in `module_eval': undefined local variable * or method `code' for Thing:Class @@ -7181,7 +7181,7 @@ rb_load_protect(fname, wrap, state) /* * call-seq: * load(filename, wrap=false) => true - * + * * Loads and executes the Ruby * program in the file _filename_. If the filename does not * resolve to an absolute path, the file is searched for in the library @@ -7355,7 +7355,7 @@ load_unlock(const char *ftptr) { if (ftptr) { st_data_t key = (st_data_t)ftptr; - + if (st_delete(loading_tbl, &key, 0)) { free((char *)key); } @@ -7365,7 +7365,7 @@ load_unlock(const char *ftptr) /* * call-seq: * require(string) => true or false - * + * * Ruby tries to load the library named _string_, returning * +true+ if successful. If the filename does not resolve to * an absolute path, it will be searched for in the directories listed @@ -7379,7 +7379,7 @@ load_unlock(const char *ftptr) * appears in $". However, the file name is not converted * to an absolute path, so that ``require 'a';require * './a''' will load a.rb twice. - * + * * require "my-library.rb" * require "db-driver" */ @@ -7597,7 +7597,7 @@ set_method_visibility(self, argc, argv, ex) * call-seq: * public => self * public(symbol, ...) => self - * + * * With no arguments, sets the default visibility for subsequently * defined methods to public. With arguments, sets the named methods to * have public visibility. @@ -7623,7 +7623,7 @@ rb_mod_public(argc, argv, module) * call-seq: * protected => self * protected(symbol, ...) => self - * + * * With no arguments, sets the default visibility for subsequently * defined methods to protected. With arguments, sets the named methods * to have protected visibility. @@ -7649,11 +7649,11 @@ rb_mod_protected(argc, argv, module) * call-seq: * private => self * private(symbol, ...) => self - * + * * With no arguments, sets the default visibility for subsequently * defined methods to private. With arguments, sets the named methods * to have private visibility. - * + * * module Mod * def a() end * def b() end @@ -7683,7 +7683,7 @@ rb_mod_private(argc, argv, module) /* * call-seq: * mod.public_class_method(symbol, ...) => mod - * + * * Makes a list of existing class methods public. */ @@ -7700,10 +7700,10 @@ rb_mod_public_method(argc, argv, obj) /* * call-seq: * mod.private_class_method(symbol, ...) => mod - * + * * Makes existing class methods private. Often used to hide the default * constructor new. - * + * * class SimpleSingleton # Not thread safe * private_class_method :new * def SimpleSingleton.create(*args, &block) @@ -7727,7 +7727,7 @@ rb_mod_private_method(argc, argv, obj) * call-seq: * public * public(symbol, ...) - * + * * With no arguments, sets the default visibility for subsequently * defined methods to public. With arguments, sets the named methods to * have public visibility. @@ -7752,7 +7752,7 @@ top_private(argc, argv) /* * call-seq: * module_function(symbol, ...) => self - * + * * Creates module functions for the named methods. These functions may * be called with the module as a receiver, and also become available * as instance methods to classes that mix in the module. Module @@ -7760,7 +7760,7 @@ top_private(argc, argv) * independently. The instance-method versions are made private. If * used with no arguments, subsequently defined methods become module * functions. - * + * * module Mod * def one * "This is one" @@ -7832,7 +7832,7 @@ rb_mod_modfunc(argc, argv, module) /* * call-seq: * append_features(mod) => mod - * + * * When this module is included in another, Ruby calls * append_features in this module, passing it the * receiving module in _mod_. Ruby's default implementation is @@ -7861,7 +7861,7 @@ rb_mod_append_features(module, include) /* * call-seq: * include(module, ...) => self - * + * * Invokes Module.append_features on each parameter in turn. */ @@ -7902,11 +7902,11 @@ rb_extend_object(obj, module) /* * call-seq: * extend_object(obj) => obj - * + * * Extends the specified object by adding this module's constants and * methods (which are added as singleton methods). This is the callback * method used by Object#extend. - * + * * module Picky * def Picky.extend_object(o) * if String === o @@ -7919,9 +7919,9 @@ rb_extend_object(obj, module) * end * (s = Array.new).extend Picky # Call Object.extend * (s = "quick brown fox").extend Picky - * + * * produces: - * + * * Picky added to Array * Can't add Picky to a String */ @@ -7937,22 +7937,22 @@ rb_mod_extend_object(mod, obj) /* * call-seq: * obj.extend(module, ...) => obj - * + * * Adds to _obj_ the instance methods from each module given as a * parameter. - * + * * module Mod * def hello * "Hello from Mod.\n" * end * end - * + * * class Klass * def hello * "Hello from Klass.\n" * end * end - * + * * k = Klass.new * k.hello #=> "Hello from Klass.\n" * k.extend(Mod) #=> # @@ -7981,7 +7981,7 @@ rb_obj_extend(argc, argv, obj) /* * call-seq: * include(module, ...) => self - * + * * Invokes Module.append_features * on each parameter in turn. Effectively adds the methods and constants * in each module to the receiver. @@ -8038,9 +8038,9 @@ errat_setter(val, id, var) /* * call-seq: * local_variables => array - * + * * Returns the names of the current local variables. - * + * * fred = 1 * for i in 1..10 * # ... @@ -8157,21 +8157,21 @@ rb_f_END() /* * call-seq: * at_exit { block } -> proc - * + * * Converts _block_ to a +Proc+ object (and therefore * binds it at the point of call) and registers it for execution when * the program exits. If multiple handlers are registered, they are * executed in reverse order of registration. - * + * * def do_at_exit(str1) * at_exit { print str1 } * end * at_exit { puts "cruel world" } * do_at_exit("goodbye ") * exit - * + * * produces: - * + * * goodbye cruel world */ @@ -8237,17 +8237,17 @@ rb_exec_end_proc() /* * call-seq: * __method__ => symbol - * + * * Returns the name of the current method as a Symbol. * If called from inside of an aliased method it will return the original * nonaliased name. * If called outside of a method, it returns nil. - * + * * def foo * __method__ * end * alias bar foo - * + * * foo # => :foo * bar # => :foo * @@ -8305,7 +8305,7 @@ Init_eval() respond_to = rb_intern("respond_to?"); rb_global_variable((void *)&basic_respond_to); basic_respond_to = rb_method_node(rb_cObject, respond_to); - + rb_define_global_function("raise", rb_f_raise, -1); rb_define_global_function("fail", rb_f_raise, -1); @@ -8375,7 +8375,7 @@ Init_eval() * call-seq: * mod.autoload(name, filename) => nil * - * Registers _filename_ to be loaded (using Kernel::require) + * Registers _filename_ to be loaded (using Kernel::require) * the first time that _name_ (which may be a String or * a symbol) is accessed in the namespace of _mod_. * @@ -8421,11 +8421,11 @@ rb_mod_autoload_p(mod, sym) /* * call-seq: * autoload(module, filename) => nil - * - * Registers _filename_ to be loaded (using Kernel::require) + * + * Registers _filename_ to be loaded (using Kernel::require) * the first time that _module_ (which may be a String or * a symbol) is accessed. - * + * * autoload(:MyModule, "/usr/local/lib/modules/my_module.rb") */ @@ -8672,12 +8672,12 @@ rb_block_dup(self, klass, cref) /* * call-seq: * binding -> a_binding - * + * * Returns a +Binding+ object, describing the variable and * method bindings at the point of call. This object can be used when * calling +eval+ to execute the evaluated command in this * environment. Also see the description of class +Binding+. - * + * * def getBinding(param) * return binding * end @@ -8839,14 +8839,14 @@ proc_alloc(klass, proc) /* * call-seq: - * Proc.new {|...| block } => a_proc - * Proc.new => a_proc - * + * Proc.new {|...| block } => a_proc + * Proc.new => a_proc + * * Creates a new Proc object, bound to the current * context. Proc::new may be called without a block only * within a method with an attached block, in which case that block is * converted to the Proc object. - * + * * def proc_from * Proc.new * end @@ -9005,29 +9005,29 @@ proc_invoke(proc, args, self, klass) * call-seq: * prc.call(params,...) => obj * prc[params,...] => obj - * + * * Invokes the block, setting the block's parameters to the values in * params using something close to method calling semantics. * Generates a warning if multiple values are passed to a proc that * expects just one (previously this silently converted the parameters - * to an array). + * to an array). * - * For procs created using Kernel.proc, generates an + * For procs created using Kernel.proc, generates an * error if the wrong number of parameters * are passed to a proc with multiple parameters. For procs created using * Proc.new, extra parameters are silently discarded. * * Returns the value of the last expression evaluated in the block. See * also Proc#yield. - * + * * a_proc = Proc.new {|a, *b| b.collect {|i| i*a }} * a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] * a_proc[9, 1, 2, 3] #=> [9, 18, 27] * a_proc = Proc.new {|a,b| a} * a_proc.call(1,2,3) - * + * * produces: - * + * * prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError) * from prog.rb:4:in `call' * from prog.rb:5 @@ -9036,7 +9036,7 @@ proc_invoke(proc, args, self, klass) /* * call-seq: * prc === obj => obj - * + * * Invokes the block, with obj as the block's parameter. It is * to allow a proc object to be a target of when clause in the case statement. */ @@ -9054,14 +9054,14 @@ static VALUE method_arity _((VALUE)); /* * call-seq: * prc.arity -> fixnum - * + * * Returns the number of arguments that would not be ignored. If the block * is declared to take no arguments, returns 0. If the block is known * to take exactly n arguments, returns n. If the block has optional * arguments, return -n-1, where n is the number of mandatory * arguments. A proc with no argument declarations * is the same a block declaring || as its arguments. - * + * * Proc.new {}.arity #=> -1 * Proc.new {||}.arity #=> 0 * Proc.new {|a|}.arity #=> 1 @@ -9180,7 +9180,7 @@ proc_to_s(self) /* * call-seq: * prc.to_proc -> prc - * + * * Part of the protocol for converting objects to Proc * objects. Instances of class Proc simply return * themselves. @@ -9196,15 +9196,15 @@ proc_to_self(self) /* * call-seq: * prc.binding => binding - * + * * Returns the binding associated with prc. Note that * Kernel#eval accepts either a Proc or a * Binding object as its second parameter. - * + * * def fred(param) * proc {} * end - * + * * b = fred(99) * eval("param", b.binding) #=> 99 * eval("param", b) #=> 99 @@ -9416,7 +9416,7 @@ mnew(klass, obj, id, mklass) * associated with an iterator. They may also be unbound from one * object (creating an UnboundMethod) and bound to * another. - * + * * class Thing * def square(n) * n*n @@ -9424,10 +9424,10 @@ mnew(klass, obj, id, mklass) * end * thing = Thing.new * meth = thing.method(:square) - * + * * meth.call(9) #=> 81 * [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9] - * + * */ /* @@ -9463,7 +9463,7 @@ method_eq(method, other) /* * call-seq: * meth.unbind => unbound_method - * + * * Dissociates meth from it's current receiver. The resulting * UnboundMethod can subsequently be bound to a new object * of the same class (see UnboundMethod). @@ -9543,13 +9543,13 @@ method_owner(obj) /* * call-seq: * obj.method(sym) => method - * + * * Looks up the named method as a receiver in obj, returning a * Method object (or raising NameError). The * Method object acts as a closure in obj's object * instance, so instance variables and the value of self * remain available. - * + * * class Demo * def initialize(n) * @iv = n @@ -9558,11 +9558,11 @@ method_owner(obj) * "Hello, @iv = #{@iv}" * end * end - * + * * k = Demo.new(99) * m = k.method(:hello) * m.call #=> "Hello, @iv = 99" - * + * * l = Demo.new('Fred') * m = l.method("hello") * m.call #=> "Hello, @iv = Fred" @@ -9579,10 +9579,10 @@ rb_obj_method(obj, vid) /* * call-seq: * mod.instance_method(symbol) => unbound_method - * + * * Returns an +UnboundMethod+ representing the given * instance method in _mod_. - * + * * class Interpreter * def do_a() print "there, "; end * def do_d() print "Hello "; end @@ -9598,13 +9598,13 @@ rb_obj_method(obj, vid) * string.each_byte {|b| Dispatcher[b].bind(self).call } * end * end - * - * + * + * * interpreter = Interpreter.new * interpreter.interpret('dave') - * + * * produces: - * + * * Hello there, Dave! */ @@ -9662,10 +9662,10 @@ rb_method_dup(self, klass, cref) * call-seq: * meth.call(args, ...) => obj * meth[args, ...] => obj - * + * * Invokes the meth with the specified arguments, returning the * method's return value. - * + * * m = 12.method("+") * m.call(3) #=> 15 * m.call(20) #=> 32 @@ -9706,17 +9706,17 @@ method_call(argc, argv, method) * with a particular object: these method objects are bound to that * object. Bound method objects for an object can be created using * Object#method. - * + * * Ruby also supports unbound methods; methods objects that are not * associated with a particular object. These can be created either by * calling Module#instance_method or by calling * unbind on a bound method object. The result of both of * these is an UnboundMethod object. - * + * * Unbound methods can only be called after they are bound to an * object. That object must be be a kind_of? the method's original * class. - * + * * class Square * def area * @side * @side @@ -9725,17 +9725,17 @@ method_call(argc, argv, method) * @side = side * end * end - * + * * area_un = Square.instance_method(:area) - * + * * s = Square.new(12) * area = area_un.bind(s) * area.call #=> 144 - * + * * Unbound methods are a reference to the method at the time it was * objectified: subsequent changes to the underlying class will not * affect the unbound method. - * + * * class Test * def test * :original @@ -9750,17 +9750,17 @@ method_call(argc, argv, method) * t = Test.new * t.test #=> :modified * um.bind(t).call #=> :original - * + * */ /* * call-seq: * umeth.bind(obj) -> method - * + * * Bind umeth to obj. If Klass was the class * from which umeth was obtained, * obj.kind_of?(Klass) must be true. - * + * * class A * def test * puts "In test, class = #{self.class}" @@ -9770,8 +9770,8 @@ method_call(argc, argv, method) * end * class C < B * end - * - * + * + * * um = B.instance_method(:test) * bm = um.bind(C.new) * bm.call @@ -9779,9 +9779,9 @@ method_call(argc, argv, method) * bm.call * bm = um.bind(A.new) * bm.call - * + * * produces: - * + * * In test, class = C * In test, class = B * prog.rb:16:in `bind': bind argument must be an instance of B (TypeError) @@ -9826,14 +9826,14 @@ umethod_bind(method, recv) /* * call-seq: * meth.arity => fixnum - * + * * Returns an indication of the number of arguments accepted by a * method. Returns a nonnegative integer for methods that take a fixed * number of arguments. For Ruby methods that take a variable number of * arguments, returns -n-1, where n is the number of required * arguments. For methods written in C, returns -1 if the call takes a * variable number of arguments. - * + * * class C * def one; end * def two(a); end @@ -9849,7 +9849,7 @@ umethod_bind(method, recv) * c.method(:four).arity #=> 2 * c.method(:five).arity #=> -3 * c.method(:six).arity #=> -3 - * + * * "cat".method(:size).arity #=> 0 * "cat".method(:replace).arity #=> 1 * "cat".method(:squeeze).arity #=> -1 @@ -9999,7 +9999,7 @@ rb_proc_new(func, val) /* * call-seq: * meth.to_proc => prc - * + * * Returns a Proc object corresponding to this method. */ @@ -10035,14 +10035,14 @@ rb_obj_is_method(m) * call-seq: * define_method(symbol, method) => new_method * define_method(symbol) { block } => proc - * + * * Defines an instance method in the receiver. The _method_ * parameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object. * If a block is specified, it is used as the method body. This block * is evaluated using instance_eval, a point that is * tricky to demonstrate because define_method is private. * (This is why we resort to the +send+ hack in this example.) - * + * * class A * def fred * puts "In Fred" @@ -10060,9 +10060,9 @@ rb_obj_is_method(m) * a.wilma * a.create_method(:betty) { p self } * a.betty - * + * * produces: - * + * * In Fred * Charge it! * # @@ -10129,18 +10129,18 @@ rb_mod_define_method(argc, argv, mod) * Proc objects are blocks of code that have been bound to * a set of local variables. Once bound, the code may be called in * different contexts and still access those variables. - * + * * def gen_times(factor) * return Proc.new {|n| n*factor } * end - * + * * times3 = gen_times(3) * times5 = gen_times(5) - * + * * times3.call(12) #=> 36 * times5.call(5) #=> 25 * times3.call(times5.call(4)) #=> 60 - * + * */ void @@ -10214,17 +10214,17 @@ Init_Proc() /* * Objects of class Binding encapsulate the execution - * context at some particular place in the code and retain this context + * context at some particular place in the code and retain this context * for future use. The variables, methods, value of self, * and possibly an iterator block that can be accessed in this context * are all retained. Binding objects can be created using * Kernel#binding, and are made available to the callback * of Kernel#set_trace_func. - * + * * These binding objects can be passed as the second argument of the * Kernel#eval method, establishing an environment for the * evaluation. - * + * * class Demo * def initialize(n) * @secret = n @@ -10233,22 +10233,22 @@ Init_Proc() * return binding() * end * end - * + * * k1 = Demo.new(99) * b1 = k1.getBinding * k2 = Demo.new(-3) * b2 = k2.getBinding - * + * * eval("@secret", b1) #=> 99 * eval("@secret", b2) #=> -3 * eval("@secret") #=> nil - * + * * Binding objects have no class-specific methods. - * + * */ -void -Init_Binding() +void +Init_Binding() { rb_cBinding = rb_define_class("Binding", rb_cObject); rb_undef_alloc_func(rb_cBinding); @@ -10741,7 +10741,7 @@ rb_thread_save_context(th) VALUE *pos; size_t len; static VALUE tval; - + EXEC_EVENT_HOOK(RUBY_EVENT_THREAD_SAVE, th->node, th->thread, 0, RBASIC(th->thread)->klass); @@ -11719,39 +11719,39 @@ rb_thread_set_join(thread, join) * call-seq: * thr.join => thr * thr.join(limit) => thr - * + * * The calling thread will suspend execution and run thr. Does not * return until thr exits or until limit seconds have passed. If * the time limit expires, nil will be returned, otherwise * thr is returned. - * + * * Any threads not joined will be killed when the main program exits. If * thr had previously raised an exception and the * abort_on_exception and $DEBUG flags are not set * (so the exception has not yet been processed) it will be processed at this * time. - * + * * a = Thread.new { print "a"; sleep(10); print "b"; print "c" } * x = Thread.new { print "x"; Thread.pass; print "y"; print "z" } * x.join # Let x thread finish, a will be killed on exit. - * + * * produces: - * + * * axyz - * + * * The following example illustrates the limit parameter. - * + * * y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }} * puts "Waiting" until y.join(0.15) - * + * * produces: - * + * * tick... * Waiting * tick... * Waitingtick... - * - * + * + * * tick... */ @@ -11775,9 +11775,9 @@ rb_thread_join_m(argc, argv, thread) /* * call-seq: * Thread.current => thread - * + * * Returns the currently executing thread. - * + * * Thread.current #=> # */ @@ -11791,9 +11791,9 @@ rb_thread_current() /* * call-seq: * Thread.main => thread - * + * * Returns the main thread for the process. - * + * * Thread.main #=> # */ @@ -11807,17 +11807,17 @@ rb_thread_main() /* * call-seq: * Thread.list => array - * + * * Returns an array of Thread objects for all threads that are * either runnable or stopped. - * + * * Thread.new { sleep(200) } * Thread.new { 1000000.times {|i| i*i } } * Thread.new { Thread.stop } * Thread.list.each {|t| p t} - * + * * produces: - * + * * # * # * # @@ -11849,15 +11849,15 @@ rb_thread_list() /* * call-seq: * thr.wakeup => thr - * + * * Marks thr as eligible for scheduling (it may still remain blocked on * I/O, however). Does not invoke the scheduler (see Thread#run). - * + * * c = Thread.new { Thread.stop; puts "hey!" } * c.wakeup - * + * * produces: - * + * * hey! */ @@ -11887,18 +11887,18 @@ rb_thread_wakeup_alive(thread) /* * call-seq: * thr.run => thr - * + * * Wakes up thr, making it eligible for scheduling. If not in a critical * section, then invokes the scheduler. - * + * * a = Thread.new { puts "a"; Thread.stop; puts "c" } * Thread.pass * puts "Got here" * a.run * a.join - * + * * produces: - * + * * a * Got here * c @@ -11939,7 +11939,7 @@ rb_kill_thread(th, flags) * thr.exit => thr * thr.kill => thr * thr.terminate => thr - * + * * Terminates thr and schedules another thread to be run, returning * the terminated Thread. If this is the main thread, or the * last thread, exits the process. @@ -11961,7 +11961,7 @@ rb_thread_kill(thread) * thr.exit! => thr * thr.kill! => thr * thr.terminate! => thr - * + * * Terminates thr without calling ensure clauses and schedules * another thread to be run, returning the terminated Thread. * If this is the main thread, or the last thread, exits the process. @@ -11981,9 +11981,9 @@ rb_thread_kill_bang(thread) /* * call-seq: * Thread.kill(thread) => thread - * + * * Causes the given thread to exit (see Thread::exit). - * + * * count = 0 * a = Thread.new { loop { count += 1 } } * sleep(0.1) #=> 0 @@ -12003,7 +12003,7 @@ rb_thread_s_kill(obj, th) /* * call-seq: * Thread.exit => thread - * + * * Terminates the currently running thread and schedules another thread to be * run. If this thread is already marked to be killed, exit * returns the Thread. If this is the main thread, or the last @@ -12020,9 +12020,9 @@ rb_thread_exit() /* * call-seq: * Thread.pass => nil - * + * * Invokes the thread scheduler to pass execution to another thread. - * + * * a = Thread.new { print "a"; Thread.pass; * print "b"; Thread.pass; * print "c" } @@ -12031,9 +12031,9 @@ rb_thread_exit() * print "z" } * a.join * b.join - * + * * produces: - * + * * axbycz */ @@ -12048,19 +12048,19 @@ rb_thread_pass() /* * call-seq: * Thread.stop => nil - * + * * Stops execution of the current thread, putting it into a ``sleep'' state, * and schedules execution of another thread. Resets the ``critical'' condition * to false. - * + * * a = Thread.new { print "a"; Thread.stop; print "c" } * Thread.pass * print "b" * a.run * a.join - * + * * produces: - * + * * abc */ @@ -12161,7 +12161,7 @@ rb_thread_priority(thread) * loop { count1 += 1 } * end * a.priority = -1 - * + * * b = Thread.new do * loop { count2 += 1 } * end @@ -12190,10 +12190,10 @@ rb_thread_priority_set(thread, prio) /* * call-seq: * thr.safe_level => integer - * + * * Returns the safe level in effect for thr. Setting thread-local safe * levels can help when implementing sandboxes which run insecure code. - * + * * thr = Thread.new { $SAFE = 3; sleep } * Thread.current.safe_level #=> 0 * thr.safe_level #=> 3 @@ -12219,7 +12219,7 @@ static VALUE thgroup_default; /* * call-seq: * Thread.abort_on_exception => true or false - * + * * Returns the status of the global ``abort on exception'' condition. The * default is false. When set to true, or if the * global $DEBUG flag is true (perhaps because the @@ -12238,10 +12238,10 @@ rb_thread_s_abort_exc() /* * call-seq: * Thread.abort_on_exception= boolean => true or false - * + * * When set to true, all threads will abort if an exception is * raised. Returns the new state. - * + * * Thread.abort_on_exception = true * t1 = Thread.new do * puts "In new thread" @@ -12249,9 +12249,9 @@ rb_thread_s_abort_exc() * end * sleep(1) * puts "not reached" - * + * * produces: - * + * * In new thread * prog.rb:4: Exception from thread (RuntimeError) * from prog.rb:2:in `initialize' @@ -12272,7 +12272,7 @@ rb_thread_s_abort_exc_set(self, val) /* * call-seq: * thr.abort_on_exception => true or false - * + * * Returns the status of the thread-local ``abort on exception'' condition for * thr. The default is false. See also * Thread::abort_on_exception=. @@ -12289,7 +12289,7 @@ rb_thread_abort_exc(thread) /* * call-seq: * thr.abort_on_exception= boolean => true or false - * + * * When set to true, causes all threads (including the main * program) to abort if an exception is raised in thr. The process will * effectively exit(0). @@ -12308,10 +12308,10 @@ rb_thread_abort_exc_set(thread, val) /* * call-seq: * thr.group => thgrp or nil - * + * * Returns the ThreadGroup which contains thr, or nil if * the thread is not a member of any group. - * + * * Thread.main.group #=> # */ @@ -12804,18 +12804,18 @@ rb_thread_yield(arg, th) /* * call-seq: * Thread.new([arg]*) {|args| block } => thread - * + * * Creates and runs a new thread to execute the instructions given in * block. Any arguments passed to Thread::new are passed * into the block. - * + * * x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" } * a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" } * x.join # Let the threads finish before * a.join # main thread exits... - * + * * produces: - * + * * abxyzc */ @@ -12842,18 +12842,18 @@ rb_thread_s_new(argc, argv, klass) /* * call-seq: * Thread.new([arg]*) {|args| block } => thread - * + * * Creates and runs a new thread to execute the instructions given in * block. Any arguments passed to Thread::new are passed * into the block. - * + * * x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" } * a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" } * x.join # Let the threads finish before * a.join # main thread exits... - * + * * produces: - * + * * abxyzc */ @@ -12883,7 +12883,7 @@ rb_thread_initialize(thread, args) * call-seq: * Thread.start([args]*) {|args| block } => thread * Thread.fork([args]*) {|args| block } => thread - * + * * Basically the same as Thread::new. However, if class * Thread is subclassed, then calling start in that * subclass will not invoke the subclass's initialize method. @@ -12903,10 +12903,10 @@ rb_thread_start(klass, args) /* * call-seq: * thr.value => obj - * + * * Waits for thr to complete (via Thread#join) and returns * its value. - * + * * a = Thread.new { 2 + 2 } * a.value #=> 4 */ @@ -12926,13 +12926,13 @@ rb_thread_value(thread) /* * call-seq: * thr.status => string, false or nil - * + * * Returns the status of thr: ``sleep'' if thr is * sleeping or waiting on I/O, ``run'' if thr is executing, * ``aborting'' if thr is aborting, false if * thr terminated normally, and nil if thr * terminated with an exception. - * + * * a = Thread.new { raise("die now") } * b = Thread.new { Thread.stop } * c = Thread.new { Thread.exit } @@ -12965,9 +12965,9 @@ rb_thread_status(thread) /* * call-seq: * thr.alive? => true or false - * + * * Returns true if thr is running or sleeping. - * + * * thr = Thread.new { } * thr.join #=> # * Thread.current.alive? #=> true @@ -12988,9 +12988,9 @@ rb_thread_alive_p(thread) /* * call-seq: * thr.stop? => true or false - * + * * Returns true if thr is dead or sleeping. - * + * * a = Thread.new { Thread.stop } * b = Thread.current * a.stop? #=> true @@ -13059,7 +13059,7 @@ int rb_thread_critical; /* * call-seq: * Thread.critical => true or false - * + * * Returns the status of the global ``thread critical'' condition. */ @@ -13073,7 +13073,7 @@ rb_thread_critical_get() /* * call-seq: * Thread.critical= boolean => true or false - * + * * Sets the status of the global ``thread critical'' condition and returns * it. When set to true, prohibits scheduling of any existing * thread. Does not block new threads from being created and run. Certain @@ -13172,7 +13172,7 @@ rb_thread_signal_exit() return; } } - rb_thread_main_jump(rb_class_new_instance(2, args, rb_eSystemExit), + rb_thread_main_jump(rb_class_new_instance(2, args, rb_eSystemExit), RESTORE_EXIT); } @@ -13213,16 +13213,16 @@ rb_thread_raise(argc, argv, th) /* * call-seq: * thr.raise(exception) - * + * * Raises an exception (see Kernel::raise) from thr. The * caller does not have to be thr. - * + * * Thread.abort_on_exception = true * a = Thread.new { sleep(200) } * a.raise("Gotcha") - * + * * produces: - * + * * prog.rb:3: Gotcha (RuntimeError) * from prog.rb:2:in `initialize' * from prog.rb:2:in `new' @@ -13267,18 +13267,18 @@ rb_thread_local_aref(thread, id) /* * call-seq: * thr[sym] => obj or nil - * + * * Attribute Reference---Returns the value of a thread-local variable, using * either a symbol or a string name. If the specified variable does not exist, * returns nil. - * + * * a = Thread.new { Thread.current["name"] = "A"; Thread.stop } * b = Thread.new { Thread.current[:name] = "B"; Thread.stop } * c = Thread.new { Thread.current["name"] = "C"; Thread.stop } * Thread.list.each {|x| puts "#{x.inspect}: #{x[:name]}" } - * + * * produces: - * + * * #: C * #: B * #: A @@ -13321,7 +13321,7 @@ rb_thread_local_aset(thread, id, val) /* * call-seq: * thr[sym] = obj => obj - * + * * Attribute Assignment---Sets or creates the value of a thread-local variable, * using either a symbol or a string. See also Thread#[]. */ @@ -13337,10 +13337,10 @@ rb_thread_aset(thread, id, val) /* * call-seq: * thr.key?(sym) => true or false - * + * * Returns true if the given string (or symbol) exists as a * thread-local variable. - * + * * me = Thread.current * me[:oliver] = "a" * me.key?(:oliver) #=> true @@ -13372,9 +13372,9 @@ thread_keys_i(key, value, ary) /* * call-seq: * thr.keys => array - * + * * Returns an an array of the names of the thread-local variables (as Symbols). - * + * * thr = Thread.new do * Thread.current[:cat] = 'meow' * Thread.current["dog"] = 'woof' @@ -13482,24 +13482,24 @@ rb_cont_check(data) * Continuations are somewhat analogous to a structured version of C's * setjmp/longjmp (although they contain more state, so * you might consider them closer to threads). - * + * * For instance: - * + * * arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] * callcc{|$cc|} * puts(message = arr.shift) * $cc.call unless message =~ /Max/ - * + * * produces: - * + * * Freddie * Herbie * Ron * Max - * + * * This (somewhat contrived) example allows the inner loop to abandon * processing early: - * + * * callcc {|cont| * for i in 0..4 * print "\n#{i}: " @@ -13510,9 +13510,9 @@ rb_cont_check(data) * end * } * print "\n" - * + * * produces: - * + * * 0: 0 1 2 3 4 * 1: 5 6 7 8 9 * 2: 10 11 12 13 14 @@ -13524,13 +13524,13 @@ VALUE rb_cCont; /* * call-seq: * callcc {|cont| block } => obj - * + * * Generates a Continuation object, which it passes to the * associated block. Performing a cont.call will * cause the callcc to return (as will falling through the * end of the block). The value returned by the callcc is * the value of the block, or the value passed to - * cont.call. See class Continuation + * cont.call. See class Continuation * for more details. Also see Kernel::throw for * an alternative mechanism for unwinding a call stack. */ @@ -13572,15 +13572,15 @@ rb_callcc(self) /* * call-seq: - * cont.call(args, ...) + * cont.call(args, ...) * cont[args, ...] - * + * * Invokes the continuation. The program continues from the end of the * callcc block. If no arguments are given, the original * callcc returns nil. If one argument is * given, callcc returns it. Otherwise, an array * containing args is returned. - * + * * callcc {|cont| cont.call } #=> nil * callcc {|cont| cont.call 1 } #=> 1 * callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3] @@ -13642,7 +13642,7 @@ struct thgroup { * threads as a group. A Thread can belong to only one * ThreadGroup at a time; adding a thread to a new group will * remove it from any previous group. - * + * * Newly created threads belong to the same group as the thread from which they * were created. */ @@ -13666,10 +13666,10 @@ thgroup_s_alloc(klass) /* * call-seq: * thgrp.list => array - * + * * Returns an array of all existing Thread objects that belong to * this group. - * + * * ThreadGroup::Default.list #=> [#] */ @@ -13698,11 +13698,11 @@ thgroup_list(group) /* * call-seq: * thgrp.enclose => thgrp - * + * * Prevents threads from being added to or removed from the receiving * ThreadGroup. New threads can still be started in an enclosed * ThreadGroup. - * + * * ThreadGroup::Default.enclose #=> # * thr = Thread::new { Thread.stop } #=> # * tg = ThreadGroup::new #=> # @@ -13729,7 +13729,7 @@ thgroup_enclose(group) /* * call-seq: * thgrp.enclosed? => true or false - * + * * Returns true if thgrp is enclosed. See also * ThreadGroup#enclose. */ @@ -13749,10 +13749,10 @@ thgroup_enclosed_p(group) /* * call-seq: * thgrp.add(thread) => thgrp - * + * * Adds the given thread to this group, removing it from any other * group to which it may have previously belonged. - * + * * puts "Initial group is #{ThreadGroup::Default.list}" * tg = ThreadGroup.new * t1 = Thread.new { sleep } @@ -13762,9 +13762,9 @@ thgroup_enclosed_p(group) * tg.add(t1) * puts "Initial group now #{ThreadGroup::Default.list}" * puts "tg group now #{tg.list}" - * + * * produces: - * + * * Initial group is # * t1 is # * t2 is # @@ -13912,9 +13912,9 @@ rb_exec_recursive(func, obj, arg) /* * +Thread+ encapsulates the behavior of a thread of * execution, including the main thread of the Ruby script. - * + * * In the descriptions of the methods in this class, the parameter _sym_ - * refers to a symbol, which is either a quoted string or a + * refers to a symbol, which is either a quoted string or a * +Symbol+ (such as :name). */ @@ -13995,7 +13995,7 @@ Init_Thread() /* * call-seq: * catch(symbol) {| | block } > obj - * + * * +catch+ executes its block. If a +throw+ is * executed, Ruby searches up its stack for a +catch+ block * with a tag corresponding to the +throw+'s @@ -14005,18 +14005,18 @@ Init_Thread() * the value of +catch+ is the value of the last expression * evaluated. +catch+ expressions may be nested, and the * +throw+ call need not be in lexical scope. - * + * * def routine(n) * puts n * throw :done if n <= 0 * routine(n-1) * end - * - * + * + * * catch(:done) { routine(3) } - * + * * produces: - * + * * 3 * 2 * 1 @@ -14064,7 +14064,7 @@ rb_catch(tag, func, data) /* * call-seq: * throw(symbol [, obj]) - * + * * Transfers control to the end of the active +catch+ block * waiting for _symbol_. Raises +NameError+ if there * is no +catch+ block for the symbol. The optional second diff --git a/file.c b/file.c index a26ec74cb5..9e36a10386 100644 --- a/file.c +++ b/file.c @@ -133,13 +133,13 @@ apply2files(func, vargs, arg) /* * call-seq: * file.path -> filename - * + * * Returns the pathname used to create file as a string. Does * not normalize the name. - * + * * File.new("testfile").path #=> "testfile" * File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx" - * + * */ static VALUE @@ -188,10 +188,10 @@ get_stat(self) /* * call-seq: * stat <=> other_stat => -1, 0, 1 - * + * * Compares File::Stat objects by comparing their * respective modification times. - * + * * f1 = File.new("f1", "w") * sleep 1 * f2 = File.new("f2", "w") @@ -234,10 +234,10 @@ static VALUE rb_stat_ctime _((VALUE)); /* * call-seq: * stat.dev => fixnum - * + * * Returns an integer representing the device on which stat * resides. - * + * * File.stat("testfile").dev #=> 774 */ @@ -251,10 +251,10 @@ rb_stat_dev(self) /* * call-seq: * stat.dev_major => fixnum - * + * * Returns the major part of File_Stat#dev or * nil. - * + * * File.stat("/dev/fd1").dev_major #=> 2 * File.stat("/dev/tty").dev_major #=> 5 */ @@ -274,10 +274,10 @@ rb_stat_dev_major(self) /* * call-seq: * stat.dev_minor => fixnum - * + * * Returns the minor part of File_Stat#dev or * nil. - * + * * File.stat("/dev/fd1").dev_minor #=> 1 * File.stat("/dev/tty").dev_minor #=> 0 */ @@ -297,11 +297,11 @@ rb_stat_dev_minor(self) /* * call-seq: * stat.ino => fixnum - * + * * Returns the inode number for stat. - * + * * File.stat("testfile").ino #=> 1083669 - * + * */ static VALUE @@ -318,11 +318,11 @@ rb_stat_ino(self) /* * call-seq: * stat.mode => fixnum - * + * * Returns an integer representing the permission bits of * stat. The meaning of the bits is platform dependent; on * Unix systems, see stat(2). - * + * * File.chmod(0644, "testfile") #=> 1 * s = File.stat("testfile") * sprintf("%o", s.mode) #=> "100644" @@ -338,13 +338,13 @@ rb_stat_mode(self) /* * call-seq: * stat.nlink => fixnum - * + * * Returns the number of hard links to stat. - * + * * File.stat("testfile").nlink #=> 1 * File.link("testfile", "testfile.bak") #=> 0 * File.stat("testfile").nlink #=> 2 - * + * */ static VALUE @@ -357,11 +357,11 @@ rb_stat_nlink(self) /* * call-seq: * stat.uid => fixnum - * + * * Returns the numeric user id of the owner of stat. - * + * * File.stat("testfile").uid #=> 501 - * + * */ static VALUE @@ -374,11 +374,11 @@ rb_stat_uid(self) /* * call-seq: * stat.gid => fixnum - * + * * Returns the numeric group id of the owner of stat. - * + * * File.stat("testfile").gid #=> 500 - * + * */ static VALUE @@ -391,11 +391,11 @@ rb_stat_gid(self) /* * call-seq: * stat.rdev => fixnum or nil - * + * * Returns an integer representing the device type on which * stat resides. Returns nil if the operating * system doesn't support this feature. - * + * * File.stat("/dev/fd1").rdev #=> 513 * File.stat("/dev/tty").rdev #=> 1280 */ @@ -414,10 +414,10 @@ rb_stat_rdev(self) /* * call-seq: * stat.rdev_major => fixnum - * + * * Returns the major part of File_Stat#rdev or * nil. - * + * * File.stat("/dev/fd1").rdev_major #=> 2 * File.stat("/dev/tty").rdev_major #=> 5 */ @@ -437,10 +437,10 @@ rb_stat_rdev_major(self) /* * call-seq: * stat.rdev_minor => fixnum - * + * * Returns the minor part of File_Stat#rdev or * nil. - * + * * File.stat("/dev/fd1").rdev_minor #=> 1 * File.stat("/dev/tty").rdev_minor #=> 0 */ @@ -460,9 +460,9 @@ rb_stat_rdev_minor(self) /* * call-seq: * stat.size => fixnum - * + * * Returns the size of stat in bytes. - * + * * File.stat("testfile").size #=> 66 */ @@ -476,12 +476,12 @@ rb_stat_size(self) /* * call-seq: * stat.blksize => integer or nil - * + * * Returns the native file system's block size. Will return nil * on platforms that don't support this information. - * + * * File.stat("testfile").blksize #=> 4096 - * + * */ static VALUE @@ -498,11 +498,11 @@ rb_stat_blksize(self) /* * call-seq: * stat.blocks => integer or nil - * + * * Returns the number of native file system blocks allocated for this - * file, or nil if the operating system doesn't + * file, or nil if the operating system doesn't * support this feature. - * + * * File.stat("testfile").blocks #=> 2 */ @@ -520,12 +520,12 @@ rb_stat_blocks(self) /* * call-seq: * stat.atime => time - * + * * Returns the last access time for this file as an object of class * Time. - * + * * File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 - * + * */ static VALUE @@ -538,11 +538,11 @@ rb_stat_atime(self) /* * call-seq: * stat.mtime -> aTime - * + * * Returns the modification time of stat. - * + * * File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 - * + * */ static VALUE @@ -555,13 +555,13 @@ rb_stat_mtime(self) /* * call-seq: * stat.ctime -> aTime - * + * * Returns the change time for stat (that is, the time * directory information about the file was changed, not the file * itself). - * + * * File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 - * + * */ static VALUE @@ -578,10 +578,10 @@ rb_stat_ctime(self) * Produce a nicely formatted description of stat. * * File.stat("/etc/passwd").inspect - * #=> "# "#" */ @@ -701,12 +701,12 @@ w32_io_info(file, st) /* * call-seq: * File.stat(file_name) => stat - * + * * Returns a File::Stat object for the named file (see * File::Stat). - * + * * File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003 - * + * */ static VALUE @@ -725,16 +725,16 @@ rb_file_s_stat(klass, fname) /* * call-seq: * ios.stat => stat - * + * * Returns status information for ios as an object of type * File::Stat. - * + * * f = File.new("testfile") * s = f.stat * "%o" % s.mode #=> "100644" * s.blksize #=> 4096 * s.atime #=> Wed Apr 09 08:53:54 CDT 2003 - * + * */ static VALUE @@ -754,15 +754,15 @@ rb_io_stat(obj) /* * call-seq: * File.lstat(file_name) => stat - * + * * Same as File::stat, but does not follow the last symbolic * link. Instead, reports on the link itself. - * + * * File.symlink("testfile", "link2test") #=> 0 * File.stat("testfile").size #=> 66 * File.lstat("link2test").size #=> 8 * File.stat("link2test").size #=> 66 - * + * */ static VALUE @@ -785,10 +785,10 @@ rb_file_s_lstat(klass, fname) /* * call-seq: * file.lstat => stat - * + * * Same as IO#stat, but does not follow the last symbolic * link. Instead, reports on the link itself. - * + * * File.symlink("testfile", "link2test") #=> 0 * File.stat("testfile").size #=> 66 * f = File.new("link2test") @@ -908,7 +908,7 @@ eaccess(path, mode) * those used in File::Stat. It exists as a standalone * module, and its methods are also insinuated into the File * class. (Note that this is not done by inclusion: the interpreter cheats). - * + * */ /* @@ -1514,13 +1514,13 @@ rb_file_ftype(st) /* * call-seq: * File.ftype(file_name) => string - * + * * Identifies the type of the named file; the return string is one of * ``file'', ``directory'', * ``characterSpecial'', ``blockSpecial'', * ``fifo'', ``link'', * ``socket'', or ``unknown''. - * + * * File.ftype("testfile") #=> "file" * File.ftype("/dev/tty") #=> "characterSpecial" * File.ftype("/tmp/.X11-unix/X0") #=> "socket" @@ -1543,11 +1543,11 @@ rb_file_s_ftype(klass, fname) /* * call-seq: * File.atime(file_name) => time - * + * * Returns the last access time for the named file as a Time object). - * + * * File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003 - * + * */ static VALUE @@ -1564,12 +1564,12 @@ rb_file_s_atime(klass, fname) /* * call-seq: * file.atime => time - * + * * Returns the last access time (a Time object) * for file, or epoch if file has not been accessed. - * + * * File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 - * + * */ static VALUE @@ -1589,11 +1589,11 @@ rb_file_atime(obj) /* * call-seq: * File.mtime(file_name) => time - * + * * Returns the modification time for the named file as a Time object. - * + * * File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003 - * + * */ static VALUE @@ -1610,11 +1610,11 @@ rb_file_s_mtime(klass, fname) /* * call-seq: * file.mtime -> time - * + * * Returns the modification time for file. - * + * * File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 - * + * */ static VALUE @@ -1634,13 +1634,13 @@ rb_file_mtime(obj) /* * call-seq: * File.ctime(file_name) => time - * + * * Returns the change time for the named file (the time at which * directory information about the file was changed, not the file * itself). - * + * * File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003 - * + * */ static VALUE @@ -1657,12 +1657,12 @@ rb_file_s_ctime(klass, fname) /* * call-seq: * file.ctime -> time - * + * * Returns the change time for file (that is, the time directory * information about the file was changed, not the file itself). - * + * * File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 - * + * */ static VALUE @@ -1692,13 +1692,13 @@ chmod_internal(path, mode) /* * call-seq: * File.chmod(mode_int, file_name, ... ) -> integer - * + * * Changes permission bits on the named file(s) to the bit pattern * represented by mode_int. Actual effects are operating system * dependent (see the beginning of this section). On Unix systems, see * chmod(2) for details. Returns the number of files * processed. - * + * * File.chmod(0644, "testfile", "out") #=> 2 */ @@ -1723,12 +1723,12 @@ rb_file_s_chmod(argc, argv) /* * call-seq: * file.chmod(mode_int) => 0 - * + * * Changes permission bits on file to the bit pattern * represented by mode_int. Actual effects are platform * dependent; on Unix systems, see chmod(2) for details. * Follows symbolic links. Also see File#lchmod. - * + * * f = File.new("out", "w"); * f.chmod(0644) #=> 0 */ @@ -1770,11 +1770,11 @@ lchmod_internal(path, mode) /* * call-seq: * File.lchmod(mode_int, file_name, ...) => integer - * + * * Equivalent to File::chmod, but does not follow symbolic * links (so it will change the permissions associated with the link, * not the file referenced by the link). Often not available. - * + * */ static VALUE @@ -1822,16 +1822,16 @@ chown_internal(path, argp) /* * call-seq: * File.chown(owner_int, group_int, file_name,... ) -> integer - * + * * Changes the owner and group of the named file(s) to the given * numeric owner and group id's. Only a process with superuser * privileges may change the owner of a file. The current owner of a * file may change the file's group to any group to which the owner * belongs. A nil or -1 owner or group id is ignored. * Returns the number of files processed. - * + * * File.chown(nil, 100, "testfile") - * + * */ static VALUE @@ -1865,16 +1865,16 @@ rb_file_s_chown(argc, argv) /* * call-seq: * file.chown(owner_int, group_int ) => 0 - * + * * Changes the owner and group of file to the given numeric * owner and group id's. Only a process with superuser privileges may * change the owner of a file. The current owner of a file may change * the file's group to any group to which the owner belongs. A * nil or -1 owner or group id is ignored. Follows * symbolic links. See also File#lchown. - * + * * File.new("testfile").chown(502, 1000) - * + * */ static VALUE @@ -1915,12 +1915,12 @@ lchown_internal(path, argp) /* * call-seq: * file.lchown(owner_int, group_int, file_name,..) => integer - * + * * Equivalent to File::chown, but does not follow symbolic * links (so it will change the owner associated with the link, not the * file referenced by the link). Often not available. Returns number * of files in the argument list. - * + * */ static VALUE @@ -2069,11 +2069,11 @@ sys_fail2(s1, s2) /* * call-seq: * File.link(old_name, new_name) => 0 - * + * * Creates a new name for an existing file using a hard link. Will not * overwrite new_name if it already exists (raising a subclass * of SystemCallError). Not available on all platforms. - * + * * File.link("testfile", ".testfile") #=> 0 * IO.readlines(".testfile")[0] #=> "This is line one\n" */ @@ -2099,13 +2099,13 @@ rb_file_s_link(klass, from, to) /* * call-seq: * File.symlink(old_name, new_name) => 0 - * + * * Creates a symbolic link called new_name for the existing file * old_name. Raises a NotImplemented exception on * platforms that do not support symbolic links. - * + * * File.symlink("testfile", "link2test") #=> 0 - * + * */ static VALUE @@ -2129,10 +2129,10 @@ rb_file_s_symlink(klass, from, to) /* * call-seq: * File.readlink(link_name) -> file_name - * + * * Returns the name of the file referenced by the given link. * Not available on all platforms. - * + * * File.symlink("testfile", "link2test") #=> 0 * File.readlink("link2test") #=> "testfile" */ @@ -2185,7 +2185,7 @@ unlink_internal(path, arg) * call-seq: * File.delete(file_name, ...) => integer * File.unlink(file_name, ...) => integer - * + * * Deletes the named files, returning the number of names * passed as arguments. Raises an exception on any error. * See also Dir::rmdir. @@ -2205,10 +2205,10 @@ rb_file_s_unlink(klass, args) /* * call-seq: * File.rename(old_name, new_name) => 0 - * + * * Renames the given file to the new name. Raises a * SystemCallError if the file cannot be renamed. - * + * * File.rename("afile", "afile.bak") #=> 0 */ @@ -2248,13 +2248,13 @@ rb_file_s_rename(klass, from, to) * call-seq: * File.umask() => integer * File.umask(integer) => integer - * + * * Returns the current umask value for this process. If the optional * argument is given, set the umask to that value and return the * previous value. Umask values are subtracted from the * default permissions, so a umask of 0222 would make a * file read-only for everyone. - * + * * File.umask(0006) #=> 18 * File.umask #=> 6 */ @@ -2381,7 +2381,7 @@ rb_path_next(s) return (char *)s; } -#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) +#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) #define skipprefix rb_path_skip_prefix #else #define skipprefix(path) (path) @@ -2390,7 +2390,7 @@ char * rb_path_skip_prefix(path) const char *path; { -#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) +#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) #ifdef DOSISH_UNC if (isdirsep(path[0]) && isdirsep(path[1])) { path += 2; @@ -2797,7 +2797,7 @@ rb_file_expand_path(fname, dname) /* * call-seq: * File.expand_path(file_name [, dir_string] ) -> abs_file_name - * + * * Converts a pathname to an absolute pathname. Relative paths are * referenced from the current working directory of the process unless * dir_string is given, in which case it will be used as the @@ -2806,7 +2806,7 @@ rb_file_expand_path(fname, dname) * directory (the environment variable HOME must be set * correctly). ``~user'' expands to the named * user's home directory. - * + * * File.expand_path("~oracle/bin") #=> "/home/oracle/bin" * File.expand_path("../../bin", "/tmp/x") #=> "/bin" */ @@ -2863,13 +2863,13 @@ rmext(p, l1, e) /* * call-seq: * File.basename(file_name [, suffix] ) -> base_name - * + * * Returns the last component of the filename given in file_name, * which must be formed using forward slashes (``/'') * regardless of the separator used on the local file system. If * suffix is given and present at the end of file_name, * it is removed. - * + * * File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb" * File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby" */ @@ -2943,12 +2943,12 @@ rb_file_s_basename(argc, argv) /* * call-seq: * File.dirname(file_name ) -> dir_name - * + * * Returns all components of the filename given in file_name * except the last one. The filename must be formed using forward * slashes (``/'') regardless of the separator used on the * local file system. - * + * * File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work" */ @@ -2994,15 +2994,15 @@ rb_file_s_dirname(klass, fname) /* * call-seq: * File.extname(path) -> string - * + * * Returns the extension (the portion of file name in path * after the period). - * + * * File.extname("test.rb") #=> ".rb" * File.extname("a/b/d/test.rb") #=> ".rb" * File.extname("test") #=> "" * File.extname(".profile") #=> "" - * + * */ static VALUE @@ -3058,11 +3058,11 @@ rb_file_s_extname(klass, fname) /* * call-seq: * File.split(file_name) => array - * + * * Splits the given string into a directory and a file component and * returns them in a two-element array. See also * File::dirname and File::basename. - * + * * File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"] */ @@ -3153,12 +3153,12 @@ rb_file_join(ary, sep) /* * call-seq: * File.join(string, ...) -> path - * + * * Returns a new string formed by joining the strings using * File::SEPARATOR. - * + * * File.join("usr", "mail", "gumby") #=> "usr/mail/gumby" - * + * */ static VALUE @@ -3171,16 +3171,16 @@ rb_file_s_join(klass, args) /* * call-seq: * File.truncate(file_name, integer) => 0 - * + * * Truncates the file file_name to be at most integer * bytes long. Not available on all platforms. - * + * * f = File.new("out", "w") * f.write("1234567890") #=> 10 * f.close #=> nil * File.truncate("out", 5) #=> 0 * File.size("out") #=> 5 - * + * */ static VALUE @@ -3226,10 +3226,10 @@ rb_file_s_truncate(klass, path, len) /* * call-seq: * file.truncate(integer) => 0 - * + * * Truncates file to at most integer bytes. The file * must be opened for writing. Not available on all platforms. - * + * * f = File.new("out", "w") * f.syswrite("1234567890") #=> 10 * f.truncate(5) #=> 0 @@ -3336,13 +3336,13 @@ rb_thread_flock(fd, op, fptr) /* * call-seq: * file.flock (locking_constant ) => 0 or false - * + * * Locks or unlocks a file according to locking_constant (a * logical or of the values in the table below). * Returns false if File::LOCK_NB is * specified and the operation would otherwise have blocked. Not * available on all platforms. - * + * * Locking constants (in class File): * * LOCK_EX | Exclusive lock. Only one process may hold an @@ -3359,7 +3359,7 @@ rb_thread_flock(fd, op, fptr) * Example: * * File.new("testfile").flock(File::LOCK_UN) #=> 0 - * + * */ static VALUE @@ -3426,11 +3426,11 @@ test_check(n, argc, argv) /* * call-seq: * test(int_cmd, file1 [, file2] ) => obj - * + * * Uses the integer aCmd to perform various tests on * file1 (first table below) or on file1 and * file2 (second table). - * + * * File tests on a single file: * * Test Returns Meaning @@ -3448,7 +3448,7 @@ test_check(n, argc, argv) * ?k | boolean | True if file1 exists and has the sticky bit set * ?l | boolean | True if file1 exists and is a symbolic link * ?M | Time | Last modification time for file1 - * ?o | boolean | True if file1 exists and is owned by + * ?o | boolean | True if file1 exists and is owned by * | | the caller's effective uid * ?O | boolean | True if file1 exists and is owned by * | | the caller's real uid @@ -3701,15 +3701,15 @@ rb_stat_init_copy(copy, orig) /* * call-seq: * stat.ftype => string - * + * * Identifies the type of stat. The return string is one of: * ``file'', ``directory'', * ``characterSpecial'', ``blockSpecial'', * ``fifo'', ``link'', * ``socket'', or ``unknown''. - * + * * File.stat("/dev/tty").ftype #=> "characterSpecial" - * + * */ static VALUE @@ -3722,10 +3722,10 @@ rb_stat_ftype(obj) /* * call-seq: * stat.directory? => true or false - * + * * Returns true if stat is a directory, * false otherwise. - * + * * File.stat("testfile").directory? #=> false * File.stat(".").directory? #=> true */ @@ -3741,7 +3741,7 @@ rb_stat_d(obj) /* * call-seq: * stat.pipe? => true or false - * + * * Returns true if the operating system supports pipes and * stat is a pipe; false otherwise. */ @@ -3760,18 +3760,18 @@ rb_stat_p(obj) /* * call-seq: * stat.symlink? => true or false - * + * * Returns true if stat is a symbolic link, * false if it isn't or if the operating system doesn't * support this feature. As File::stat automatically * follows symbolic links, symlink? will always be * false for an object returned by * File::stat. - * + * * File.symlink("testfile", "alink") #=> 0 * File.stat("alink").symlink? #=> false * File.lstat("alink").symlink? #=> true - * + * */ static VALUE @@ -3787,13 +3787,13 @@ rb_stat_l(obj) /* * call-seq: * stat.socket? => true or false - * + * * Returns true if stat is a socket, * false if it isn't or if the operating system doesn't * support this feature. - * + * * File.stat("testfile").socket? #=> false - * + * */ static VALUE @@ -3810,14 +3810,14 @@ rb_stat_S(obj) /* * call-seq: * stat.blockdev? => true or false - * + * * Returns true if the file is a block device, * false if it isn't or if the operating system doesn't * support this feature. - * + * * File.stat("testfile").blockdev? #=> false * File.stat("/dev/hda1").blockdev? #=> true - * + * */ static VALUE @@ -3834,13 +3834,13 @@ rb_stat_b(obj) /* * call-seq: * stat.chardev? => true or false - * + * * Returns true if the file is a character device, * false if it isn't or if the operating system doesn't * support this feature. - * + * * File.stat("/dev/tty").chardev? #=> true - * + * */ static VALUE @@ -3855,13 +3855,13 @@ rb_stat_c(obj) /* * call-seq: * stat.owned? => true or false - * + * * Returns true if the effective user id of the process is * the same as the owner of stat. - * + * * File.stat("testfile").owned? #=> true * File.stat("/etc/passwd").owned? #=> false - * + * */ static VALUE @@ -3883,13 +3883,13 @@ rb_stat_rowned(obj) /* * call-seq: * stat.grpowned? => true or false - * + * * Returns true if the effective group id of the process is the same as * the group id of stat. On Windows NT, returns false. - * + * * File.stat("testfile").grpowned? #=> true * File.stat("/etc/passwd").grpowned? #=> false - * + * */ static VALUE @@ -3905,12 +3905,12 @@ rb_stat_grpowned(obj) /* * call-seq: * stat.readable? => true or false - * + * * Returns true if stat is readable by the * effective user id of this process. - * + * * File.stat("testfile").readable? #=> true - * + * */ static VALUE @@ -3939,12 +3939,12 @@ rb_stat_r(obj) /* * call-seq: * stat.readable_real? -> true or false - * + * * Returns true if stat is readable by the real * user id of this process. - * + * * File.stat("testfile").readable_real? #=> true - * + * */ static VALUE @@ -3973,12 +3973,12 @@ rb_stat_R(obj) /* * call-seq: * stat.writable? -> true or false - * + * * Returns true if stat is writable by the * effective user id of this process. - * + * * File.stat("testfile").writable? #=> true - * + * */ static VALUE @@ -4007,12 +4007,12 @@ rb_stat_w(obj) /* * call-seq: * stat.writable_real? -> true or false - * + * * Returns true if stat is writable by the real * user id of this process. - * + * * File.stat("testfile").writable_real? #=> true - * + * */ static VALUE @@ -4041,14 +4041,14 @@ rb_stat_W(obj) /* * call-seq: * stat.executable? => true or false - * + * * Returns true if stat is executable or if the * operating system doesn't distinguish executable files from * nonexecutable files. The tests are made using the effective owner of * the process. - * + * * File.stat("testfile").executable? #=> false - * + * */ static VALUE @@ -4079,7 +4079,7 @@ rb_stat_x(obj) /* * call-seq: * stat.executable_real? => true or false - * + * * Same as executable?, but tests using the real owner of * the process. */ @@ -4112,12 +4112,12 @@ rb_stat_X(obj) /* * call-seq: * stat.file? => true or false - * + * * Returns true if stat is a regular file (not * a device file, pipe, socket, etc.). - * + * * File.stat("testfile").file? #=> true - * + * */ static VALUE @@ -4131,12 +4131,12 @@ rb_stat_f(obj) /* * call-seq: * stat.zero? => true or false - * + * * Returns true if stat is a zero-length file; * false otherwise. - * + * * File.stat("testfile").zero? #=> false - * + * */ static VALUE @@ -4150,11 +4150,11 @@ rb_stat_z(obj) /* * call-seq: * state.size => integer - * + * * Returns the size of stat in bytes. - * + * * File.stat("testfile").size #=> 66 - * + * */ static VALUE @@ -4170,11 +4170,11 @@ rb_stat_s(obj) /* * call-seq: * stat.setuid? => true or false - * + * * Returns true if stat has the set-user-id * permission bit set, false if it doesn't or if the * operating system doesn't support this feature. - * + * * File.stat("/bin/su").setuid? #=> true */ @@ -4191,13 +4191,13 @@ rb_stat_suid(obj) /* * call-seq: * stat.setgid? => true or false - * + * * Returns true if stat has the set-group-id * permission bit set, false if it doesn't or if the * operating system doesn't support this feature. - * + * * File.stat("/usr/sbin/lpc").setgid? #=> true - * + * */ static VALUE @@ -4213,13 +4213,13 @@ rb_stat_sgid(obj) /* * call-seq: * stat.sticky? => true or false - * + * * Returns true if stat has its sticky bit set, * false if it doesn't or if the operating system doesn't * support this feature. - * + * * File.stat("testfile").sticky? #=> false - * + * */ static VALUE @@ -4540,7 +4540,7 @@ define_filetest_function(name, func, argc) * File includes the methods of module * FileTest as class methods, allowing you to write (for * example) File.exist?("foo"). - * + * * In the description of File methods, * permission bits are a platform-specific * set of bits that indicate permissions of a file. On Unix-based @@ -4548,7 +4548,7 @@ define_filetest_function(name, func, argc) * owner, the group, and the rest of the world. For each of these * entities, permissions may be set to read, write, or execute the * file: - * + * * The permission bits 0644 (in octal) would thus be * interpreted as read/write for owner, and read-only for group and * other. Higher-order bits may also be used to indicate the type of @@ -4556,7 +4556,7 @@ define_filetest_function(name, func, argc) * special features. If the permissions are for a directory, the * meaning of the execute bit changes; when set the directory can be * searched. - * + * * On non-Posix operating systems, there may be only the ability to * make a file read-only or read-write. In this case, the remaining * permission bits will be synthesized to resemble typical values. For diff --git a/gc.c b/gc.c index 748f26072e..b7fc7b150c 100644 --- a/gc.c +++ b/gc.c @@ -436,7 +436,7 @@ add_heap() } #define RANY(o) ((RVALUE*)(o)) -int +int rb_during_gc() { return during_gc; diff --git a/intern.h b/intern.h index 47a385e8cd..96be3e06a1 100644 --- a/intern.h +++ b/intern.h @@ -12,7 +12,7 @@ **********************************************************************/ -/* +/* * Functions and variables that are used by more than one source file of * the kernel. */ diff --git a/io.c b/io.c index ffdaa539d5..d45d448e1b 100644 --- a/io.c +++ b/io.c @@ -550,17 +550,17 @@ rb_io_fwrite(ptr, len, f) /* * call-seq: * ios.write(string) => integer - * + * * Writes the given string to ios. The stream must be opened * for writing. If the argument is not a string, it will be converted * to a string using to_s. Returns the number of bytes * written. - * + * * count = $stdout.write( "This is a test\n" ) * puts "That was #{count} bytes of data" - * + * * produces: - * + * * This is a test * That was 15 bytes of data */ @@ -604,15 +604,15 @@ rb_io_write(io, str) /* * call-seq: * ios << obj => ios - * + * * String Output---Writes obj to ios. * obj will be converted to a string using * to_s. - * + * * $stdout << "Hello " << "world!\n" - * + * * produces: - * + * * Hello world! */ @@ -627,16 +627,16 @@ rb_io_addstr(io, str) /* * call-seq: * ios.flush => ios - * + * * Flushes any buffered data within ios to the underlying * operating system (note that this is Ruby internal buffering only; * the OS may buffer the data as well). - * + * * $stdout.print "no newline" * $stdout.flush - * + * * produces: - * + * * no newline */ @@ -663,9 +663,9 @@ rb_io_flush(io) * call-seq: * ios.pos => integer * ios.tell => integer - * + * * Returns the current offset (in bytes) of ios. - * + * * f = File.new("testfile") * f.pos #=> 0 * f.gets #=> "This is line one\n" @@ -705,19 +705,19 @@ rb_io_seek(io, offset, whence) /* * call-seq: * ios.seek(amount, whence=SEEK_SET) -> 0 - * + * * Seeks to a given offset anInteger in the stream according to * the value of whence: * * IO::SEEK_CUR | Seeks to _amount_ plus current position * --------------+---------------------------------------------------- - * IO::SEEK_END | Seeks to _amount_ plus end of stream (you probably + * IO::SEEK_END | Seeks to _amount_ plus end of stream (you probably * | want a negative value for _amount_) * --------------+---------------------------------------------------- * IO::SEEK_SET | Seeks to the absolute location given by _amount_ * * Example: - * + * * f = File.new("testfile") * f.seek(-13, IO::SEEK_END) #=> 0 * f.readline #=> "And so on...\n" @@ -742,9 +742,9 @@ rb_io_seek_m(argc, argv, io) /* * call-seq: * ios.pos = integer => integer - * + * * Seeks to the given position (in bytes) in ios. - * + * * f = File.new("testfile") * f.pos = 17 * f.gets #=> "This is line two\n" @@ -769,10 +769,10 @@ rb_io_set_pos(io, offset) /* * call-seq: * ios.rewind => 0 - * + * * Positions ios to the beginning of input, resetting * lineno to zero. - * + * * f = File.new("testfile") * f.readline #=> "This is line one\n" * f.rewind #=> 0 @@ -859,12 +859,12 @@ rb_io_eof(io) /* * call-seq: * ios.sync => true or false - * + * * Returns the current ``sync mode'' of ios. When sync mode is * true, all output is immediately flushed to the underlying operating * system and is not buffered by Ruby internally. See also * IO#fsync. - * + * * f = File.new("testfile") * f.sync #=> false */ @@ -882,15 +882,15 @@ rb_io_sync(io) /* * call-seq: * ios.sync = boolean => boolean - * + * * Sets the ``sync mode'' to true or false. * When sync mode is true, all output is immediately flushed to the * underlying operating system and is not buffered internally. Returns * the new state. See also IO#fsync. - * + * * f = File.new("testfile") * f.sync = true - * + * * (produces no output) */ @@ -913,7 +913,7 @@ rb_io_set_sync(io, mode) /* * call-seq: * ios.fsync => 0 or nil - * + * * Immediately writes all buffered data in ios to disk. * Note that fsync differs from * using IO#sync=. The latter ensures that data is flushed @@ -921,7 +921,7 @@ rb_io_set_sync(io, mode) * operating system actually writes it to disk. * * NotImplementedError is raised - * if the underlying operating system does not support fsync(2). + * if the underlying operating system does not support fsync(2). */ static VALUE @@ -949,10 +949,10 @@ rb_io_fsync(io) * call-seq: * ios.fileno => fixnum * ios.to_i => fixnum - * + * * Returns an integer representing the numeric file descriptor for * ios. - * + * * $stdin.fileno #=> 0 * $stdout.fileno #=> 1 */ @@ -972,19 +972,19 @@ rb_io_fileno(io) /* * call-seq: * ios.pid => fixnum - * + * * Returns the process ID of a child process associated with * ios. This will be set by IO::popen. - * + * * pipe = IO.popen("-") * if pipe * $stderr.puts "In parent, child pid is #{pipe.pid}" * else * $stderr.puts "In child, pid is #{$$}" * end - * + * * produces: - * + * * In child, pid is 26209 * In parent, child pid is 26209 */ @@ -1033,7 +1033,7 @@ rb_io_inspect(obj) /* * call-seq: * ios.to_io -> ios - * + * * Returns ios. */ @@ -1328,7 +1328,7 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock) * When readpartial doesn't blocks, it returns or raises immediately. * If the buffer is not empty, it returns the data in the buffer. * Otherwise if the stream has some content, - * it returns the data in the stream. + * it returns the data in the stream. * Otherwise if the stream is reached to EOF, it raises EOFError. * * r, w = IO.pipe # buffer pipe content @@ -1488,7 +1488,7 @@ io_read(argc, argv, io) if (NIL_P(length)) { if (!NIL_P(str)) StringValue(str); GetOpenFile(io, fptr); - rb_io_check_readable(fptr); + rb_io_check_readable(fptr); return read_all(fptr, remain_size(fptr), str); } len = NUM2LONG(length); @@ -1781,7 +1781,7 @@ rb_io_gets(io) /* * call-seq: * ios.gets(sep_string=$/) => string or nil - * + * * Reads the next ``line'' from the I/O stream; lines are separated by * sep_string. A separator of nil reads the entire * contents, and a zero-length separator reads the input a paragraph at @@ -1790,7 +1790,7 @@ rb_io_gets(io) * will be raised. The line read in will be returned and also assigned * to $_. Returns nil if called at end of * file. - * + * * File.new("testfile").gets #=> "This is line one\n" * $_ #=> "This is line one\n" */ @@ -1819,14 +1819,14 @@ rb_io_gets_m(argc, argv, io) /* * call-seq: * ios.lineno => integer - * + * * Returns the current line number in ios. The stream must be * opened for reading. lineno counts the number of times * gets is called, rather than the number of newlines * encountered. The two values will differ if gets is * called with a separator other than newline. See also the * $. variable. - * + * * f = File.new("testfile") * f.lineno #=> 0 * f.gets #=> "This is line one\n" @@ -1849,10 +1849,10 @@ rb_io_lineno(io) /* * call-seq: * ios.lineno = integer => integer - * + * * Manually sets the current line number to the given value. * $. is updated only on the next read. - * + * * f = File.new("testfile") * f.gets #=> "This is line one\n" * $. #=> 1 @@ -1903,7 +1903,7 @@ argf_lineno() /* * call-seq: * ios.readline(sep_string=$/) => string - * + * * Reads a line as with IO#gets, but raises an * EOFError on end of file. */ @@ -1925,14 +1925,14 @@ rb_io_readline(argc, argv, io) /* * call-seq: * ios.readlines(sep_string=$/) => array - * + * * Reads all of the lines in ios, and returns them in * anArray. Lines are separated by the optional * sep_string. If sep_string is nil, the * rest of the stream is returned as a single record. * The stream must be opened for reading or an * IOError will be raised. - * + * * f = File.new("testfile") * f.readlines[0] #=> "This is line one\n" */ @@ -1964,16 +1964,16 @@ rb_io_readlines(argc, argv, io) * call-seq: * ios.each(sep_string=$/) {|line| block } => ios * ios.each_line(sep_string=$/) {|line| block } => ios - * + * * Executes the block for every line in ios, where lines are * separated by sep_string. ios must be opened for * reading or an IOError will be raised. - * + * * f = File.new("testfile") * f.each {|line| puts "#{f.lineno}: #{line}" } - * + * * produces: - * + * * 1: This is line one * 2: This is line two * 3: This is line three @@ -2006,11 +2006,11 @@ rb_io_each_line(argc, argv, io) /* * call-seq: * ios.each_byte {|byte| block } => ios - * + * * Calls the given block once for each byte (0..255) in ios, * passing the byte as an argument. The stream must be opened for * reading or an IOError will be raised. - * + * * f = File.new("testfile") * checksum = 0 * f.each_byte {|x| checksum ^= x } #=> # @@ -2128,7 +2128,7 @@ rb_io_lines(argc, argv, io) * Returns an enumerator that gives each byte (0..255) in ios. * The stream must be opened for reading or an IOError * will be raised. - * + * * f = File.new("testfile") * f.bytes.to_a #=> [104, 101, 108, 108, 111] * f.rewind @@ -2146,12 +2146,12 @@ rb_io_bytes(io) * call-seq: * ios.getbyte => fixnum or nil * ios.getc => fixnum or nil - * + * * Gets the next 8-bit byte (0..255) from ios. Returns * nil if called at end of file. getc() will change and * return a character in 1.9, so if what you exactly mean is a byte, * use getbyte(). - * + * * f = File.new("testfile") * f.getc #=> 84 * f.getc #=> 104 @@ -2209,7 +2209,7 @@ rb_getc(f) * call-seq: * ios.readbyte => fixnum * ios.readchar => fixnum - * + * * Reads a byte as with IO#getc, but raises an * EOFError on end of file. */ @@ -2230,13 +2230,13 @@ rb_io_readchar(io) * call-seq: * ios.ungetbyte(integer) => nil * ios.ungetc(integer) => nil - * + * * Pushes back one byte (passed as a parameter) onto ios, * such that a subsequent buffered read will return it. Only one character * may be pushed back before a subsequent read operation (that is, * you will be able to read only the last of several characters that have been pushed * back). Has no effect with unbuffered reads (such as IO#sysread). - * + * * f = File.new("testfile") #=> # * c = f.getc #=> 84 * f.ungetc(c) #=> nil @@ -2265,10 +2265,10 @@ rb_io_ungetc(io, c) * call-seq: * ios.isatty => true or false * ios.tty? => true or false - * + * * Returns true if ios is associated with a * terminal device (tty), false otherwise. - * + * * File.new("testfile").isatty #=> false * File.new("/dev/tty").isatty #=> true */ @@ -2390,7 +2390,7 @@ rb_io_close(io) /* * call-seq: * ios.close => nil - * + * * Closes ios and flushes any pending writes to the operating * system. The stream is unavailable for any further data operations; * an IOError is raised if such an attempt is made. I/O @@ -2430,11 +2430,11 @@ io_close(io) /* * call-seq: * ios.closed? => true or false - * + * * Returns true if ios is completely closed (for * duplex streams, both reader and writer), false * otherwise. - * + * * f = File.new("testfile") * f.close #=> nil * f.closed? #=> true @@ -2459,17 +2459,17 @@ rb_io_closed(io) /* * call-seq: * ios.close_read => nil - * + * * Closes the read end of a duplex I/O stream (i.e., one that contains * both a read and a write stream, such as a pipe). Will raise an * IOError if the stream is not duplexed. - * + * * f = IO.popen("/bin/sh","r+") * f.close_read * f.readlines - * + * * produces: - * + * * prog.rb:3:in `readlines': not opened for reading (IOError) * from prog.rb:3 */ @@ -2503,17 +2503,17 @@ rb_io_close_read(io) /* * call-seq: * ios.close_write => nil - * + * * Closes the write end of a duplex I/O stream (i.e., one that contains * both a read and a write stream, such as a pipe). Will raise an * IOError if the stream is not duplexed. - * + * * f = IO.popen("/bin/sh","r+") * f.close_write * f.print "nowhere" - * + * * produces: - * + * * prog.rb:3:in `write': not opened for writing (IOError) * from prog.rb:3:in `print' * from prog.rb:3 @@ -2547,11 +2547,11 @@ rb_io_close_write(io) /* * call-seq: * ios.sysseek(offset, whence=SEEK_SET) => integer - * + * * Seeks to a given offset in the stream according to the value * of whence (see IO#seek for values of * whence). Returns the new offset into the file. - * + * * f = File.new("testfile") * f.sysseek(-13, IO::SEEK_END) #=> 53 * f.sysread(10) #=> "And so on." @@ -2589,12 +2589,12 @@ rb_io_sysseek(argc, argv, io) /* * call-seq: * ios.syswrite(string) => integer - * + * * Writes the given string to ios using a low-level write. * Returns the number of bytes written. Do not mix with other methods * that write to ios or you may get unpredictable results. * Raises SystemCallError on error. - * + * * f = File.new("out", "w") * f.syswrite("ABCDEF") #=> 6 */ @@ -2633,13 +2633,13 @@ rb_io_syswrite(io, str) /* * call-seq: * ios.sysread(integer ) => string - * + * * Reads integer bytes from ios using a low-level * read and returns them as a string. Do not mix with other methods * that read from ios or you may get unpredictable results. * Raises SystemCallError on error and * EOFError at end of file. - * + * * f = File.new("testfile") * f.sysread(16) #=> "This is line one" */ @@ -2703,7 +2703,7 @@ rb_io_sysread(argc, argv, io) /* * call-seq: * ios.binmode => ios - * + * * Puts ios into binary mode. This is useful only in * MS-DOS/Windows environments. Once a stream is in binary mode, it * cannot be reset to nonbinary mode. @@ -3193,7 +3193,7 @@ pipe_open(pstr, pname, mode) #if defined(DJGPP) || defined(__human68k__) || defined(__VMS) f = popen(pname, mode); - + if (!f) rb_sys_fail(pname); else { VALUE port = io_alloc(rb_cIO); @@ -3340,7 +3340,7 @@ retry: * call-seq: * IO.popen(cmd_string, mode="r" ) => io * IO.popen(cmd_string, mode="r" ) {|io| block } => obj - * + * * Runs the specified command string as a subprocess; the subprocess's * standard input and output will be connected to the returned * IO object. If cmd_string starts with a @@ -3348,14 +3348,14 @@ retry: * subprocess. The default mode for the new file object is ``r'', but * mode may be set to any of the modes listed in the description * for class IO. - * + * * If a block is given, Ruby will run the command as a child connected * to Ruby with a pipe. Ruby's end of the pipe will be passed as a * parameter to the block. * At the end of block, Ruby close the pipe and sets $?. * In this case IO::popen returns * the value of the block. - * + * * If a block is given with a cmd_string of ``-'', * the block will be run in two separate processes: once in the parent, * and once in a child. The parent process will be passed the pipe @@ -3363,16 +3363,16 @@ retry: * will be passed nil, and the child's standard in and * standard out will be connected to the parent through the pipe. Not * available on all platforms. - * + * * f = IO.popen("uname") * p f.readlines * puts "Parent is #{Process.pid}" * IO.popen ("date") { |f| puts f.gets } * IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f}"} * p $? - * + * * produces: - * + * * ["Linux\n"] * Parent is 26166 * Wed Apr 9 08:53:52 CDT 2003 @@ -3456,13 +3456,13 @@ rb_open_file(argc, argv, io) * call-seq: * IO.open(fd, mode_string="r" ) => io * IO.open(fd, mode_string="r" ) {|io| block } => obj - * + * * With no associated block, open is a synonym for * IO::new. If the optional code block is given, it will * be passed io as an argument, and the IO object will * automatically be closed when the block terminates. In this instance, * IO::open returns the value of the block. - * + * */ static VALUE @@ -3483,12 +3483,12 @@ rb_io_s_open(argc, argv, klass) /* * call-seq: * IO.sysopen(path, [mode, [perm]]) => fixnum - * + * * Opens the given path, returning the underlying file descriptor as a * Fixnum. - * + * * IO.sysopen("testfile") #=> 3 - * + * */ static VALUE @@ -3523,21 +3523,21 @@ rb_io_s_sysopen(argc, argv) * call-seq: * open(path [, mode [, perm]] ) => io or nil * open(path [, mode [, perm]] ) {|io| block } => obj - * + * * Creates an IO object connected to the given stream, * file, or subprocess. - * + * * If path does not start with a pipe character * (``|''), treat it as the name of a file to open using * the specified mode (defaulting to ``r''). (See the table * of valid modes on page 331.) If a file is being created, its initial * permissions may be set using the integer third parameter. - * + * * If a block is specified, it will be invoked with the * File object as a parameter, and the file will be * automatically closed when the block terminates. The call * returns the value of the block. - * + * * If path starts with a pipe character, a subprocess is * created, connected to the caller by a pair of pipes. The returned * IO object may be used to write to the standard input @@ -3553,27 +3553,27 @@ rb_io_s_sysopen(argc, argv) * will be connected to the child's $stdin and * $stdout. The subprocess will be terminated at the end * of the block. - * + * * open("testfile") do |f| * print f.gets * end - * + * * produces: - * + * * This is line one - * + * * Open a subprocess and read its output: - * + * * cmd = open("|date") * print cmd.gets * cmd.close - * + * * produces: - * + * * Wed Apr 9 08:56:31 CDT 2003 - * + * * Open a subprocess running the same Ruby program: - * + * * f = open("|-", "w+") * if f == nil * puts "in Child" @@ -3581,13 +3581,13 @@ rb_io_s_sysopen(argc, argv) * else * puts "Got: #{f.gets}" * end - * + * * produces: - * + * * Got: in Child - * + * * Open a subprocess using a block to receive the I/O object: - * + * * open("|-") do |f| * if f == nil * puts "in Child" @@ -3595,9 +3595,9 @@ rb_io_s_sysopen(argc, argv) * puts "Got: #{f.gets}" * end * end - * + * * produces: - * + * * Got: in Child */ @@ -3781,13 +3781,13 @@ io_reopen(io, nfile) /* * call-seq: - * ios.reopen(other_IO) => ios + * ios.reopen(other_IO) => ios * ios.reopen(path, mode_str) => ios - * + * * Reassociates ios with the I/O stream given in * other_IO or to a new stream opened on path. This may * dynamically change the actual class of this stream. - * + * * f1 = File.new("testfile") * f2 = File.new("testfile") * f2.readlines[0] #=> "This is line one\n" @@ -3921,7 +3921,7 @@ rb_io_init_copy(dest, io) /* * call-seq: * ios.printf(format_string [, obj, ...] ) => nil - * + * * Formats and writes to ios, converting parameters under * control of the format string. See Kernel#sprintf * for details. @@ -3941,7 +3941,7 @@ rb_io_printf(argc, argv, out) * call-seq: * printf(io, string [, obj ... ] ) => nil * printf(string [, obj ... ] ) => nil - * + * * Equivalent to: * io.write(sprintf(string, obj, ...) * or @@ -3973,7 +3973,7 @@ rb_f_printf(argc, argv) * call-seq: * ios.print() => nil * ios.print(obj, ...) => nil - * + * * Writes the given object(s) to ios. The stream must be * opened for writing. If the output record separator ($\\) * is not nil, it will be appended to the output. If no @@ -3981,11 +3981,11 @@ rb_f_printf(argc, argv) * strings will be converted by calling their to_s method. * With no argument, prints the contents of the variable $_. * Returns nil. - * + * * $stdout.print("This is ", 100, " percent.\n") - * + * * produces: - * + * * This is 100 percent. */ @@ -4027,7 +4027,7 @@ rb_io_print(argc, argv, out) /* * call-seq: * print(obj, ...) => nil - * + * * Prints each object in turn to $stdout. If the output * field separator ($,) is not +nil+, its * contents will appear between each field. If the output record @@ -4035,14 +4035,14 @@ rb_io_print(argc, argv, out) * appended to the output. If no arguments are given, prints * $_. Objects that aren't strings will be converted by * calling their to_s method. - * + * * print "cat", [1,2,3], 99, "\n" * $, = ", " * $\ = "\n" * print "cat", [1,2,3], 99 - * + * * produces: - * + * * cat12399 * cat, 1, 2, 3, 99 */ @@ -4059,16 +4059,16 @@ rb_f_print(argc, argv) /* * call-seq: * ios.putc(obj) => obj - * + * * If obj is Numeric, write the character whose * code is obj, otherwise write the first character of the * string representation of obj to ios. - * + * * $stdout.putc "A" * $stdout.putc 65 - * + * * produces: - * + * * AA */ @@ -4085,7 +4085,7 @@ rb_io_putc(io, ch) /* * call-seq: * putc(int) => int - * + * * Equivalent to: * * $stdout.putc(int) @@ -4118,17 +4118,17 @@ io_puts_ary(ary, out) /* * call-seq: * ios.puts(obj, ...) => nil - * + * * Writes the given objects to ios as with * IO#print. Writes a record separator (typically a * newline) after any that do not already end with a newline sequence. * If called with an array argument, writes each element on a new line. * If called without arguments, outputs a single record separator. - * + * * $stdout.puts("this", "is", "a", "test") - * + * * produces: - * + * * this * is * a @@ -4174,8 +4174,8 @@ rb_io_puts(argc, argv, out) /* * call-seq: * puts(obj, ...) => nil - * - * Equivalent to + * + * Equivalent to * * $stdout.puts(obj, ...) */ @@ -4200,17 +4200,17 @@ rb_p(obj) /* for debug print within C code */ /* * call-seq: * p(obj, ...) => nil - * + * * For each object, directly writes * _obj_.+inspect+ followed by the current output * record separator to the program's standard output. - * + * * S = Struct.new(:name, :state) * s = S['dave', 'TX'] * p s - * + * * produces: - * + * * # */ @@ -4233,23 +4233,23 @@ rb_f_p(argc, argv) /* * call-seq: * obj.display(port=$>) => nil - * + * * Prints obj on the given port (default $>). * Equivalent to: - * + * * def display(port=$>) * port.write self * end - * + * * For example: - * + * * 1.display * "cat".display * [ 4, 5, 6 ].display * puts - * + * * produces: - * + * * 1cat456 */ @@ -4365,17 +4365,17 @@ prep_path(io, path) /* * call-seq: * IO.new(fd, mode) => io - * + * * Returns a new IO object (a stream) for the given * integer file descriptor and mode string. See also * IO#fileno and IO::for_fd. - * + * * a = IO.new(2,"w") # '2' is standard error * $stderr.puts "Hello" * a.puts "World" - * + * * produces: - * + * * Hello * World */ @@ -4421,7 +4421,7 @@ rb_io_initialize(argc, argv, io) * call-seq: * File.new(filename, mode="r") => file * File.new(filename [, mode [, perm]]) => file - * + * * Opens the file named by _filename_ according to * _mode_ (default is ``r'') and returns a new @@ -4463,17 +4463,17 @@ rb_file_initialize(argc, argv, io) /* * call-seq: * IO.new(fd, mode_string) => io - * + * * Returns a new IO object (a stream) for the given * integer file descriptor and mode string. See also * IO#fileno and IO::for_fd. - * + * * a = IO.new(2,"w") # '2' is standard error * $stderr.puts "Hello" * a.puts "World" - * + * * produces: - * + * * Hello * World */ @@ -4496,9 +4496,9 @@ rb_io_s_new(argc, argv, klass) /* * call-seq: * IO.for_fd(fd, mode) => io - * + * * Synonym for IO::new. - * + * */ static VALUE @@ -4698,7 +4698,7 @@ argf_getline(argc, argv) /* * call-seq: * gets(separator=$/) => string or nil - * + * * Returns (and assigns to $_) the next line from the list * of files in +ARGV+ (or $*), or from standard * input if no files are present on the command line. Returns @@ -4709,17 +4709,17 @@ argf_getline(argc, argv) * at a time, where paragraphs are divided by two consecutive newlines. * If multiple filenames are present in +ARGV+, * +gets(nil)+ will read the contents one file at a time. - * + * * ARGV << "testfile" * print while gets - * + * * produces: - * + * * This is line one * This is line two * This is line three * And so on... - * + * * The style of programming using $_ as an implicit * parameter is gradually losing favor in the Ruby community. */ @@ -4771,7 +4771,7 @@ rb_gets() /* * call-seq: * readline(separator=$/) => string - * + * * Equivalent to Kernel::gets, except * +readline+ raises +EOFError+ at end of file. */ @@ -4810,7 +4810,7 @@ rb_f_getc() /* * call-seq: * readlines(separator=$/) => array - * + * * Returns an array containing the lines returned by calling * Kernel.gets(separator) until the end of file. */ @@ -4834,11 +4834,11 @@ rb_f_readlines(argc, argv) /* * call-seq: * `cmd` => string - * + * * Returns the standard output of running _cmd_ in a subshell. * The built-in syntax %x{...} uses * this method. Sets $? to the process status. - * + * * `date` #=> "Wed Apr 9 08:56:30 CDT 2003\n" * `ls testdir`.split[1] #=> "main.rb" * `echo oops && exit 99` #=> "oops\n" @@ -4870,11 +4870,11 @@ rb_f_backquote(obj, str) /* * call-seq: - * IO.select(read_array - * [, write_array - * [, error_array + * IO.select(read_array + * [, write_array + * [, error_array * [, timeout]]] ) => array or nil - * + * * See Kernel#select. */ @@ -5128,7 +5128,7 @@ rb_io_ctl(io, req, arg, io_p) /* * call-seq: * ios.ioctl(integer_cmd, arg) => integer - * + * * Provides a mechanism for issuing low-level commands to control or * query I/O devices. Arguments and results are platform dependent. If * arg is a number, its value is passed directly. If it is a @@ -5152,7 +5152,7 @@ rb_io_ioctl(argc, argv, io) /* * call-seq: * ios.fcntl(integer_cmd, arg) => integer - * + * * Provides a mechanism for issuing low-level commands to control or * query file-oriented I/O streams. Arguments and results are platform * dependent. If arg is a number, its value is passed @@ -5182,7 +5182,7 @@ rb_io_fcntl(argc, argv, io) /* * call-seq: * syscall(fixnum [, args...]) => integer - * + * * Calls the operating system function identified by _fixnum_, * passing in the arguments, which must be either +String+ * objects, or +Integer+ objects that ultimately fit within @@ -5190,11 +5190,11 @@ rb_io_fcntl(argc, argv, io) * on the Atari-ST). The function identified by _fixnum_ is system * dependent. On some Unix systems, the numbers may be obtained from a * header file called syscall.h. - * + * * syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box - * + * * produces: - * + * * hello */ @@ -5312,21 +5312,21 @@ io_new_instance(args) /* * call-seq: * IO.pipe -> array - * + * * Creates a pair of pipe endpoints (connected to each other) and * returns them as a two-element array of IO objects: * [ read_file, write_file ]. Not * available on all platforms. - * + * * In the example below, the two processes close the ends of the pipe * that they are not using. This is not just a cosmetic nicety. The * read end of a pipe will not generate an end of file condition if * there are any writers with the pipe still open. In the case of the * parent process, the rd.read will never return if it * does not first issue a wr.close. - * + * * rd, wr = IO.pipe - * + * * if fork * wr.close * puts "Parent got: <#{rd.read}>" @@ -5338,9 +5338,9 @@ io_new_instance(args) * wr.write "Hi Dad" * wr.close * end - * + * * produces: - * + * * Sending message to parent * Parent got: */ @@ -5407,19 +5407,19 @@ io_s_foreach(arg) /* * call-seq: * IO.foreach(name, sep_string=$/) {|line| block } => nil - * + * * Executes the block for every line in the named I/O port, where lines * are separated by sep_string. - * + * * IO.foreach("testfile") {|x| print "GOT ", x } - * + * * produces: - * + * * GOT This is line one * GOT This is line two * GOT This is line three * GOT And so on... - */ + */ static VALUE rb_io_s_foreach(argc, argv, self) @@ -5456,14 +5456,14 @@ io_s_readlines(arg) /* * call-seq: * IO.readlines(name, sep_string=$/) => array - * + * * Reads the entire file specified by name as individual * lines, and returns those lines in an array. Lines are separated by * sep_string. - * + * * a = IO.readlines("testfile") * a[0] #=> "This is line one\n" - * + * */ static VALUE @@ -5494,11 +5494,11 @@ io_s_read(arg) /* * call-seq: * IO.read(name, [length [, offset]] ) => string - * + * * Opens the file, optionally seeks to the given offset, then returns * length bytes (defaulting to the rest of the file). * read ensures the file is closed before returning. - * + * * IO.read("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" * IO.read("testfile", 20) #=> "This is line one\nThi" * IO.read("testfile", 20, 10) #=> "ne one\nThis is line " @@ -5841,38 +5841,38 @@ opt_i_set(val) * Class IO is the basis for all input and output in Ruby. * An I/O stream may be duplexed (that is, bidirectional), and * so may use more than one native operating system stream. - * + * * Many of the examples in this section use class File, * the only standard subclass of IO. The two classes are * closely associated. - * + * * As used in this section, portname may take any of the * following forms. - * + * * * A plain string represents a filename suitable for the underlying * operating system. - * + * * * A string starting with ``|'' indicates a subprocess. * The remainder of the string following the ``|'' is * invoked as a process with appropriate input/output channels * connected to it. - * + * * * A string equal to ``|-'' will create another Ruby * instance as a subprocess. - * + * * Ruby will convert pathnames between different operating system * conventions if possible. For instance, on a Windows system the * filename ``/gumby/ruby/test.rb'' will be opened as * ``\gumby\ruby\test.rb''. When specifying a * Windows-style filename in a Ruby string, remember to escape the * backslashes: - * + * * "c:\\gumby\\ruby\\test.rb" - * + * * Our examples here will use the Unix-style forward slashes; * File::SEPARATOR can be used to get the * platform-specific separator character. - * + * * I/O ports may be opened in any one of several different modes, which * are shown in this section as mode. The mode may * either be a Fixnum or a String. If numeric, it should be @@ -5889,7 +5889,7 @@ opt_i_set(val) * -----+-------------------------------------------------------- * "r+" | Read-write, starts at beginning of file. * -----+-------------------------------------------------------- - * "w" | Write-only, truncates existing file + * "w" | Write-only, truncates existing file * | to zero length or creates a new file for writing. * -----+-------------------------------------------------------- * "w+" | Read-write, truncates existing file to zero length @@ -5899,10 +5899,10 @@ opt_i_set(val) * | otherwise creates a new file for writing. * -----+-------------------------------------------------------- * "a+" | Read-write, starts at end of file if file exists, - * | otherwise creates a new file for reading and + * | otherwise creates a new file for reading and * | writing. * -----+-------------------------------------------------------- - * "b" | (DOS/Windows only) Binary file mode (may appear with + * "b" | (DOS/Windows only) Binary file mode (may appear with * | any of the key letters listed above). * * @@ -5916,7 +5916,7 @@ opt_i_set(val) void Init_IO() { -#ifdef __CYGWIN__ +#ifdef __CYGWIN__ #include static struct __cygwin_perfile pf[] = { diff --git a/marshal.c b/marshal.c index ad29f6a94c..beafff553b 100644 --- a/marshal.c +++ b/marshal.c @@ -1434,7 +1434,7 @@ clear_load_arg(arg) * call-seq: * load( source [, proc] ) => obj * restore( source [, proc] ) => obj - * + * * Returns the result of converting the serialized data in source into a * Ruby object (possibly with associated subordinate objects). source * may be either an instance of IO or an object that responds to diff --git a/math.c b/math.c index d8a0230fc5..abe5f6c164 100644 --- a/math.c +++ b/math.c @@ -46,10 +46,10 @@ domain_check(x, msg) /* * call-seq: * Math.atan2(y, x) => float - * + * * Computes the arc tangent given y and x. Returns * -PI..PI. - * + * */ static VALUE @@ -64,7 +64,7 @@ math_atan2(obj, y, x) /* * call-seq: * Math.cos(x) => float - * + * * Computes the cosine of x (expressed in radians). Returns * -1..1. */ @@ -80,7 +80,7 @@ math_cos(obj, x) /* * call-seq: * Math.sin(x) => float - * + * * Computes the sine of x (expressed in radians). Returns * -1..1. */ @@ -98,7 +98,7 @@ math_sin(obj, x) /* * call-seq: * Math.tan(x) => float - * + * * Returns the tangent of x (expressed in radians). */ @@ -114,7 +114,7 @@ math_tan(obj, x) /* * call-seq: * Math.acos(x) => float - * + * * Computes the arc cosine of x. Returns 0..PI. */ @@ -134,7 +134,7 @@ math_acos(obj, x) /* * call-seq: * Math.asin(x) => float - * + * * Computes the arc sine of x. Returns -{PI/2} .. {PI/2}. */ @@ -154,7 +154,7 @@ math_asin(obj, x) /* * call-seq: * Math.atan(x) => float - * + * * Computes the arc tangent of x. Returns -{PI/2} .. {PI/2}. */ @@ -178,7 +178,7 @@ cosh(x) /* * call-seq: * Math.cosh(x) => float - * + * * Computes the hyperbolic cosine of x (expressed in radians). */ @@ -187,7 +187,7 @@ math_cosh(obj, x) VALUE obj, x; { Need_Float(x); - + return rb_float_new(cosh(RFLOAT(x)->value)); } @@ -203,7 +203,7 @@ sinh(x) /* * call-seq: * Math.sinh(x) => float - * + * * Computes the hyperbolic sine of x (expressed in * radians). */ @@ -228,7 +228,7 @@ tanh(x) /* * call-seq: * Math.tanh() => float - * + * * Computes the hyperbolic tangent of x (expressed in * radians). */ @@ -244,7 +244,7 @@ math_tanh(obj, x) /* * call-seq: * Math.acosh(x) => float - * + * * Computes the inverse hyperbolic cosine of x. */ @@ -264,7 +264,7 @@ math_acosh(obj, x) /* * call-seq: * Math.asinh(x) => float - * + * * Computes the inverse hyperbolic sine of x. */ @@ -279,7 +279,7 @@ math_asinh(obj, x) /* * call-seq: * Math.atanh(x) => float - * + * * Computes the inverse hyperbolic tangent of x. */ @@ -299,7 +299,7 @@ math_atanh(obj, x) /* * call-seq: * Math.exp(x) => float - * + * * Returns e**x. */ @@ -323,7 +323,7 @@ math_exp(obj, x) /* * call-seq: * Math.log(numeric) => float - * + * * Returns the natural logarithm of numeric. */ @@ -343,7 +343,7 @@ math_log(obj, x) /* * call-seq: * Math.log10(numeric) => float - * + * * Returns the base 10 logarithm of numeric. */ @@ -363,7 +363,7 @@ math_log10(obj, x) /* * call-seq: * Math.sqrt(numeric) => float - * + * * Returns the non-negative square root of numeric. */ @@ -383,11 +383,11 @@ math_sqrt(obj, x) /* * call-seq: * Math.frexp(numeric) => [ fraction, exponent ] - * + * * Returns a two-element array containing the normalized fraction (a * Float) and exponent (a Fixnum) of * numeric. - * + * * fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11] * fraction * 2**exponent #=> 1234.0 */ @@ -400,7 +400,7 @@ math_frexp(obj, x) int exp; Need_Float(x); - + d = frexp(RFLOAT(x)->value, &exp); return rb_assoc_new(rb_float_new(d), INT2NUM(exp)); } @@ -408,9 +408,9 @@ math_frexp(obj, x) /* * call-seq: * Math.ldexp(flt, int) -> float - * + * * Returns the value of flt*(2**int). - * + * * fraction, exponent = Math.frexp(1234) * Math.ldexp(fraction, exponent) #=> 1234.0 */ @@ -426,10 +426,10 @@ math_ldexp(obj, x, n) /* * call-seq: * Math.hypot(x, y) => float - * + * * Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle * with sides x and y. - * + * * Math.hypot(3, 4) #=> 5.0 */ @@ -476,7 +476,7 @@ math_erfc(obj, x) * trigonometric and transcendental functions. See class * Float for a list of constants that * define Ruby's floating point accuracy. - */ + */ void diff --git a/numeric.c b/numeric.c index 991fe977f5..0936c6916f 100644 --- a/numeric.c +++ b/numeric.c @@ -2371,7 +2371,7 @@ fix_pow(x, y) if (a == -1) { if (b % 2 == 0) return INT2FIX(1); - else + else return INT2FIX(-1); } if (b > 0) { diff --git a/object.c b/object.c index d053c2fe39..7124c2434f 100644 --- a/object.c +++ b/object.c @@ -36,7 +36,7 @@ static ID id_eq, id_eql, id_inspect, id_init_copy; /* * call-seq: * obj === other => true or false - * + * * Case Equality---For class Object, effectively the same * as calling #==, but typically overridden by descendents * to provide meaningful semantics in case statements. @@ -66,7 +66,7 @@ rb_eql(obj1, obj2) * obj == other => true or false * obj.equal?(other) => true or false * obj.eql?(other) => true or false - * + * * Equality---At the Object level, == returns * true only if obj and other are the * same object. Typically, this method is overridden in descendent @@ -85,7 +85,7 @@ rb_eql(obj1, obj2) * tradition, but there are exceptions. Numeric types, for * example, perform type conversion across ==, but not * across eql?, so: - * + * * 1 == 1.0 #=> true * 1.eql? 1.0 #=> false */ @@ -101,7 +101,7 @@ rb_obj_equal(obj1, obj2) /* * call-seq: * obj.id => fixnum - * + * * Soon-to-be deprecated version of Object#object_id. */ @@ -126,7 +126,7 @@ rb_class_real(cl) /* * call-seq: * obj.type => class - * + * * Deprecated synonym for Object#class. */ @@ -142,13 +142,13 @@ rb_obj_type(obj) /* * call-seq: * obj.class => class - * + * * Returns the class of obj, now preferred over * Object#type, as an object's type in Ruby is only * loosely tied to that object's class. This method must always be * called with an explicit receiver, as class is also a * reserved word in Ruby. - * + * * 1.class #=> Fixnum * self.class #=> Object */ @@ -191,12 +191,12 @@ init_copy(dest, obj) /* * call-seq: * obj.clone -> an_object - * + * * Produces a shallow copy of obj---the instance variables of * obj are copied, but not the objects they reference. Copies * the frozen and tainted state of obj. See also the discussion * under Object#dup. - * + * * class Klass * attr_accessor :str * end @@ -233,7 +233,7 @@ rb_obj_clone(obj) /* * call-seq: * obj.dup -> an_object - * + * * Produces a shallow copy of obj---the instance variables of * obj are copied, but not the objects they reference. * dup copies the tainted state of obj. See also @@ -279,12 +279,12 @@ rb_obj_init_copy(obj, orig) /* * call-seq: * obj.to_a -> anArray - * + * * Returns an array representation of obj. For objects of class * Object and others that don't explicitly override the - * method, the return value is an array containing self. + * method, the return value is an array containing self. * However, this latter behavior will soon be obsolete. - * + * * self.to_a #=> -:1: warning: Object#to_a is deprecated * "hello".to_a #=> ["hello"] * Time.new.to_a #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"] @@ -303,7 +303,7 @@ rb_any_to_a(obj) /* * call-seq: * obj.to_s => string - * + * * Returns a string representing obj. The default * to_s prints the object's class and an encoding of the * object id. As a special case, the top-level object that is the @@ -378,11 +378,11 @@ inspect_obj(obj, str) /* * call-seq: * obj.inspect => string - * + * * Returns a string containing a human-readable representation of * obj. If not overridden, uses the to_s method to * generate the string. - * + * * [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" * Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003" */ @@ -419,7 +419,7 @@ rb_obj_inspect(obj) /* * call-seq: * obj.instance_of?(class) => true or false - * + * * Returns true if obj is an instance of the given * class. See also Object#kind_of?. */ @@ -446,11 +446,11 @@ rb_obj_is_instance_of(obj, c) * call-seq: * obj.is_a?(class) => true or false * obj.kind_of?(class) => true or false - * + * * Returns true if class is the class of * obj, or if class is one of the superclasses of * obj or modules included in obj. - * + * * module M; end * class A * include M @@ -496,7 +496,7 @@ rb_obj_is_kind_of(obj, c) /* * call-seq: * obj.tap{|x|...} => obj - * + * * Yields x to the block, and then returns x. * The primary purpose of this method is to "tap into" a method chain, * in order to perform operations on intermediate results within the chain. @@ -555,10 +555,10 @@ rb_obj_tap(obj) * * call-seq: * singleton_method_added(symbol) - * + * * Invoked as a callback whenever a singleton method is added to the * receiver. - * + * * module Chatty * def Chatty.singleton_method_added(id) * puts "Adding #{id.id2name}" @@ -567,13 +567,13 @@ rb_obj_tap(obj) * def two() end * def Chatty.three() end * end - * + * * produces: - * + * * Adding singleton_method_added * Adding one * Adding three - * + * */ /* @@ -581,10 +581,10 @@ rb_obj_tap(obj) * * call-seq: * singleton_method_removed(symbol) - * + * * Invoked as a callback whenever a singleton method is removed from * the receiver. - * + * * module Chatty * def Chatty.singleton_method_removed(id) * puts "Removing #{id.id2name}" @@ -597,9 +597,9 @@ rb_obj_tap(obj) * remove_method :one * end * end - * + * * produces: - * + * * Removing three * Removing one */ @@ -609,10 +609,10 @@ rb_obj_tap(obj) * * call-seq: * singleton_method_undefined(symbol) - * + * * Invoked as a callback whenever a singleton method is undefined in * the receiver. - * + * * module Chatty * def Chatty.singleton_method_undefined(id) * puts "Undefining #{id.id2name}" @@ -622,9 +622,9 @@ rb_obj_tap(obj) * undef_method(:one) * end * end - * + * * produces: - * + * * Undefining one */ @@ -664,7 +664,7 @@ rb_obj_dummy() /* * call-seq: * obj.tainted? => true or false - * + * * Returns true if the object is tainted. */ @@ -680,7 +680,7 @@ rb_obj_tainted(obj) /* * call-seq: * obj.taint -> obj - * + * * Marks obj as tainted---if the $SAFE level is * set appropriately, many method calls which might alter the running * programs environment will refuse to accept tainted strings. @@ -704,7 +704,7 @@ rb_obj_taint(obj) /* * call-seq: * obj.untaint => obj - * + * * Removes the taint from obj. */ @@ -733,18 +733,18 @@ rb_obj_infect(obj1, obj2) /* * call-seq: * obj.freeze => obj - * + * * Prevents further modifications to obj. A * TypeError will be raised if modification is attempted. * There is no way to unfreeze a frozen object. See also * Object#frozen?. - * + * * a = [ "a", "b", "c" ] * a.freeze * a << "z" - * + * * produces: - * + * * prog.rb:3:in `<<': can't modify frozen array (TypeError) * from prog.rb:3 */ @@ -765,9 +765,9 @@ rb_obj_freeze(obj) /* * call-seq: * obj.frozen? => true or false - * + * * Returns the freeze status of obj. - * + * * a = [ "a", "b", "c" ] * a.freeze #=> ["a", "b", "c"] * a.frozen? #=> true @@ -791,9 +791,9 @@ rb_obj_frozen_p(obj) /* * call-seq: * nil.to_i => 0 - * + * * Always returns zero. - * + * * nil.to_i #=> 0 */ @@ -808,9 +808,9 @@ nil_to_i(obj) /* * call-seq: * nil.to_f => 0.0 - * + * * Always returns zero. - * + * * nil.to_f #=> 0.0 */ @@ -824,9 +824,9 @@ nil_to_f(obj) /* * call-seq: * nil.to_s => "" - * + * * Always returns the empty string. - * + * * nil.to_s #=> "" */ @@ -840,9 +840,9 @@ nil_to_s(obj) /* * call-seq: * nil.to_a => [] - * + * * Always returns an empty array. - * + * * nil.to_a #=> [] */ @@ -903,7 +903,7 @@ true_to_s(obj) /* * call-seq: * true & obj => true or false - * + * * And---Returns false if obj is * nil or false, true otherwise. */ @@ -918,16 +918,16 @@ true_and(obj, obj2) /* * call-seq: * true | obj => true - * + * * Or---Returns true. As anObject is an argument to * a method call, it is always evaluated; there is no short-circuit * evaluation in this case. - * + * * true | puts("or") * true || puts("logical or") - * + * * produces: - * + * * or */ @@ -942,7 +942,7 @@ true_or(obj, obj2) /* * call-seq: * true ^ obj => !obj - * + * * Exclusive Or---Returns true if obj is * nil or false, false * otherwise. @@ -963,7 +963,7 @@ true_xor(obj, obj2) * FalseClass and represents a logically false value in * boolean expressions. The class provides operators allowing * false to participate correctly in logical expressions. - * + * */ /* @@ -984,7 +984,7 @@ false_to_s(obj) * call-seq: * false & obj => false * nil & obj => false - * + * * And---Returns false. obj is always * evaluated as it is the argument to a method call---there is no * short-circuit evaluation in this case. @@ -1002,7 +1002,7 @@ false_and(obj, obj2) * call-seq: * false | obj => true or false * nil | obj => true or false - * + * * Or---Returns false if obj is * nil or false; true otherwise. */ @@ -1020,11 +1020,11 @@ false_or(obj, obj2) * call-seq: * false ^ obj => true or false * nil ^ obj => true or false - * + * * Exclusive Or---If obj is nil or * false, returns false; otherwise, returns * true. - * + * */ static VALUE @@ -1068,7 +1068,7 @@ rb_false(obj) /* * call-seq: * obj =~ other => false - * + * * Pattern Match---Overridden by descendents (notably * Regexp and String) to provide meaningful * pattern-match semantics. @@ -1095,7 +1095,7 @@ rb_obj_pattern_match(obj1, obj2) * one context, a method in another, and a class in a third, the * Symbol :Fred will be the same object in * all three contexts. - * + * * module One * class Fred * end @@ -1111,16 +1111,16 @@ rb_obj_pattern_match(obj1, obj2) * $f1.id #=> 2514190 * $f2.id #=> 2514190 * $f3.id #=> 2514190 - * + * */ /* * call-seq: * sym.to_i => fixnum - * + * * Returns an integer that is unique for each symbol within a * particular execution of a program. - * + * * :fred.to_i #=> 9809 * "fred".to_sym.to_i #=> 9809 */ @@ -1152,9 +1152,9 @@ sym_to_int(sym) /* * call-seq: * sym.inspect => string - * + * * Returns the representation of sym as a symbol literal. - * + * * :fred.inspect #=> ":fred" */ @@ -1182,9 +1182,9 @@ sym_inspect(sym) * call-seq: * sym.id2name => string * sym.to_s => string - * + * * Returns the name or string corresponding to sym. - * + * * :fred.id2name #=> "fred" */ @@ -1256,11 +1256,11 @@ sym_to_proc(sym) * included, module methods do not. Conversely, module methods may be * called without creating an encapsulating object, while instance * methods may not. (See Module#module_function) - * + * * In the descriptions that follow, the parameter syml refers * to a symbol, which is either a quoted string or a * Symbol (such as :name). - * + * * module Mod * include Math * CONST = 1 @@ -1271,7 +1271,7 @@ sym_to_proc(sym) * Mod.class #=> Module * Mod.constants #=> ["E", "PI", "CONST"] * Mod.instance_methods #=> ["meth"] - * + * */ /* @@ -1311,7 +1311,7 @@ rb_mod_to_s(klass) /* * call-seq: * mod.freeze - * + * * Prevents further modifications to mod. */ @@ -1326,7 +1326,7 @@ rb_mod_freeze(mod) /* * call-seq: * mod === obj => true or false - * + * * Case Equality---Returns true if anObject is an * instance of mod or one of mod's descendents. Of * limited use for modules, but can be used in case @@ -1345,9 +1345,9 @@ rb_mod_eqq(mod, arg) * mod <= other => true, false, or nil * * Returns true if mod is a subclass of other or - * is the same as other. Returns - * nil if there's no relationship between the two. - * (Think of the relationship in terms of the class definition: + * is the same as other. Returns + * nil if there's no relationship between the two. + * (Think of the relationship in terms of the class definition: * "class A true, false, or nil * - * Returns true if mod is a subclass of other. Returns - * nil if there's no relationship between the two. - * (Think of the relationship in terms of the class definition: + * Returns true if mod is a subclass of other. Returns + * nil if there's no relationship between the two. + * (Think of the relationship in terms of the class definition: * "class A= other => true, false, or nil * * Returns true if mod is an ancestor of other, or the - * two modules are the same. Returns - * nil if there's no relationship between the two. - * (Think of the relationship in terms of the class definition: + * two modules are the same. Returns + * nil if there's no relationship between the two. + * (Think of the relationship in terms of the class definition: * "class AA"). * */ @@ -1437,9 +1437,9 @@ rb_mod_ge(mod, arg) * call-seq: * mod > other => true, false, or nil * - * Returns true if mod is an ancestor of other. Returns - * nil if there's no relationship between the two. - * (Think of the relationship in terms of the class definition: + * Returns true if mod is an ancestor of other. Returns + * nil if there's no relationship between the two. + * (Think of the relationship in terms of the class definition: * "class AA"). * */ @@ -1455,7 +1455,7 @@ rb_mod_gt(mod, arg) /* * call-seq: * mod <=> other_mod => -1, 0, +1, or nil - * + * * Comparison---Returns -1 if mod includes other_mod, 0 if * mod is the same as other_mod, and +1 if mod is * included by other_mod or if mod has no relationship with @@ -1509,11 +1509,11 @@ rb_class_s_alloc(klass) * call-seq: * Module.new => mod * Module.new {|mod| block } => mod - * + * * Creates a new anonymous module. If a block is given, it is passed * the module object, and the block is evaluated in the context of this * module using module_eval. - * + * * Fred = Module.new do * def meth1 * "hello" @@ -1541,11 +1541,11 @@ rb_mod_initialize(module) /* * call-seq: * Class.new(super_class=Object) => a_class - * + * * Creates a new anonymous (unnamed) class with the given superclass * (or Object if no parameter is given). You can give a * class a name by assigning the class object to a constant. - * + * */ static VALUE @@ -1576,23 +1576,23 @@ rb_class_initialize(argc, argv, klass) /* * call-seq: * class.allocate() => obj - * + * * Allocates space for a new object of class's class and does not * call initialize on the new instance. The returned object must be an * instance of class. - * + * * klass = Class.new do * def initialize(*args) * @initialized = true * end - * + * * def initialized? * @initialized || false * end * end - * + * * klass.allocate.initialized? #=> false - * + * */ VALUE @@ -1627,13 +1627,13 @@ rb_class_allocate_instance(klass) /* * call-seq: * class.new(args, ...) => obj - * + * * Calls allocate to create a new object of * class's class, then invokes that object's * initialize method, passing it args. * This is the method that ends up getting called whenever * an object is constructed using .new. - * + * */ VALUE @@ -1653,9 +1653,9 @@ rb_class_new_instance(argc, argv, klass) /* * call-seq: * class.superclass -> a_super_class or nil - * + * * Returns the superclass of class, or nil. - * + * * File.superclass #=> IO * IO.superclass #=> Object * @@ -1666,7 +1666,7 @@ rb_class_new_instance(argc, argv, klass) * returns nil when the given class hasn't a parent class: * * Object.superclass #=> nil - * + * */ static VALUE @@ -1732,19 +1732,19 @@ rb_to_id(name) /* * call-seq: * attr(symbol, writable=false) => nil - * + * * Defines a named attribute for this module, where the name is * symbol.id2name, creating an instance variable * (@name) and a corresponding access method to read it. * If the optional writable argument is true, also * creates a method called name= to set the attribute. - * + * * module Mod * attr :size, true * end - * + * * is equivalent to: - * + * * module Mod * def size * @size @@ -1771,7 +1771,7 @@ rb_mod_attr(argc, argv, klass) /* * call-seq: * attr_reader(symbol, ...) => nil - * + * * Creates instance variables and corresponding methods that return the * value of each instance variable. Equivalent to calling * ``attr:name'' on each name in turn. @@ -1794,7 +1794,7 @@ rb_mod_attr_reader(argc, argv, klass) /* * call-seq: * attr_writer(symbol, ...) => nil - * + * * Creates an accessor method to allow assignment to the attribute * aSymbol.id2name. */ @@ -1816,10 +1816,10 @@ rb_mod_attr_writer(argc, argv, klass) /* * call-seq: * attr_accessor(symbol, ...) => nil - * + * * Equivalent to calling ``attrsymbol, * true'' on each symbol in turn. - * + * * module Mod * attr_accessor(:one, :two) * end @@ -1843,9 +1843,9 @@ rb_mod_attr_accessor(argc, argv, klass) /* * call-seq: * mod.const_get(sym) => obj - * + * * Returns the value of the named constant in mod. - * + * * Math.const_get(:PI) #=> 3.14159265358979 */ @@ -1864,11 +1864,11 @@ rb_mod_const_get(mod, name) /* * call-seq: * mod.const_set(sym, obj) => obj - * + * * Sets the named constant to the given object, returning that object. * Creates a new constant if no constant with the given name previously * existed. - * + * * Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714 * Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968 */ @@ -1889,10 +1889,10 @@ rb_mod_const_set(mod, name, value) /* * call-seq: * mod.const_defined?(sym) => true or false - * + * * Returns true if a constant with the given name is * defined by mod. - * + * * Math.const_defined? "PI" #=> true */ @@ -1911,17 +1911,17 @@ rb_mod_const_defined(mod, name) /* * call-seq: * obj.methods => array - * + * * Returns a list of the names of methods publicly accessible in * obj. This will include all the methods accessible in * obj's ancestors. - * + * * class Klass * def kMethod() * end * end * k = Klass.new - * k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?", + * k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?", * "class", "instance_variable_set", * "methods", "extend", "__send__", "instance_eval"] * k.methods.length #=> 42 @@ -1955,7 +1955,7 @@ rb_obj_methods(argc, argv, obj) /* * call-seq: * obj.protected_methods(all=true) => array - * + * * Returns the list of protected methods accessible to obj. If * the all parameter is set to false, only those methods * in the receiver will be listed. @@ -1979,7 +1979,7 @@ rb_obj_protected_methods(argc, argv, obj) /* * call-seq: * obj.private_methods(all=true) => array - * + * * Returns the list of private methods accessible to obj. If * the all parameter is set to false, only those methods * in the receiver will be listed. @@ -2003,7 +2003,7 @@ rb_obj_private_methods(argc, argv, obj) /* * call-seq: * obj.public_methods(all=true) => array - * + * * Returns the list of public methods accessible to obj. If * the all parameter is set to false, only those methods * in the receiver will be listed. @@ -2033,7 +2033,7 @@ rb_obj_public_methods(argc, argv, obj) * variable name should be included for regular instance * variables. Throws a NameError exception if the * supplied symbol is not valid as an instance variable name. - * + * * class Fred * def initialize(p1, p2) * @a, @b = p1, p2 @@ -2059,12 +2059,12 @@ rb_obj_ivar_get(obj, iv) /* * call-seq: * obj.instance_variable_set(symbol, obj) => obj - * + * * Sets the instance variable names by symbol to * object, thereby frustrating the efforts of the class's * author to attempt to provide proper encapsulation. The variable * did not have to exist prior to this call. - * + * * class Fred * def initialize(p1, p2) * @a, @b = p1, p2 @@ -2121,11 +2121,11 @@ rb_obj_ivar_defined(obj, iv) /* * call-seq: * mod.class_variable_get(symbol) => obj - * + * * Returns the value of the given class variable (or throws a * NameError exception). The @@ part of the * variable name should be included for regular class variables - * + * * class Fred * @@foo = 99 * end @@ -2150,10 +2150,10 @@ rb_mod_cvar_get(obj, iv) /* * call-seq: * obj.class_variable_set(symbol, obj) => obj - * + * * Sets the class variable names by symbol to * object. - * + * * class Fred * @@foo = 99 * def foo @@ -2222,7 +2222,7 @@ convert_type(val, tname, method, raise) NIL_P(val) ? "nil" : val == Qtrue ? "true" : val == Qfalse ? "false" : - rb_obj_classname(val), + rb_obj_classname(val), tname); } else { @@ -2341,7 +2341,7 @@ rb_Integer(val) /* * call-seq: * Integer(arg) => integer - * + * * Converts arg to a Fixnum or Bignum. * Numeric types are converted directly (with floating point numbers * being truncated). If arg is a String, leading @@ -2349,7 +2349,7 @@ rb_Integer(val) * 0x) are honored. Others are converted using * to_int and to_i. This behavior is * different from that of String#to_i. - * + * * Integer(123.999) #=> 123 * Integer("0x1a") #=> 26 * Integer(Time.new) #=> 1049896590 @@ -2499,11 +2499,11 @@ rb_Float(val) /* * call-seq: * Float(arg) => float - * + * * Returns arg converted to a float. Numeric types are converted * directly, the rest are converted using arg.to_f. As of Ruby * 1.8, converting nil generates a TypeError. - * + * * Float(1) #=> 1.0 * Float("123.456") #=> 123.456 */ @@ -2562,10 +2562,10 @@ rb_String(val) /* * call-seq: * String(arg) => string - * + * * Converts arg to a String by calling its * to_s method. - * + * * String(self) #=> "main" * String(self.class #=> "Object" * String(123456) #=> "123456" @@ -2598,12 +2598,12 @@ rb_Array(val) /* * call-seq: * Array(arg) => array - * + * * Returns arg as an Array. First tries to call * arg.to_ary, then arg.to_a. * If both fail, creates a single element array containing arg * (unless arg is nil). - * + * * Array(1..5) #=> [1, 2, 3, 4, 5] */ @@ -2638,7 +2638,7 @@ VALUE ruby_top_self; * * Classes in Ruby are first-class objects---each is an instance of * class Class. - * + * * When a new class is created (typically using class Name ... * end), an object of type Class is created and * assigned to a global constant (Name in this case). When @@ -2646,7 +2646,7 @@ VALUE ruby_top_self; * new method in Class is run by default. * This can be demonstrated by overriding new in * Class: - * + * * class Class * alias oldNew new * def new(*args) @@ -2654,21 +2654,21 @@ VALUE ruby_top_self; * oldNew(*args) * end * end - * - * + * + * * class Name * end - * - * + * + * * n = Name.new - * + * * produces: - * + * * Creating a new Name - * + * * Classes, modules, and objects are interrelated. In the diagram * that follows, the vertical arrows represent inheritance, and the - * parentheses meta-classes. All metaclasses are instances + * parentheses meta-classes. All metaclasses are instances * of the class `Class'. * * +------------------+ @@ -2695,13 +2695,13 @@ VALUE ruby_top_self; * Object is the parent class of all classes in Ruby. Its * methods are therefore available to all objects unless explicitly * overridden. - * + * * Object mixes in the Kernel module, making * the built-in kernel functions globally accessible. Although the * instance methods of Object are defined by the * Kernel module, we have chosen to document them here for * clarity. - * + * * In the descriptions of Object's methods, the parameter symbol refers * to a symbol, which is either a quoted string or a * Symbol (such as :name). @@ -2735,7 +2735,7 @@ Init_Object() rb_define_method(rb_mKernel, "nil?", rb_false, 0); rb_define_method(rb_mKernel, "==", rb_obj_equal, 1); rb_define_method(rb_mKernel, "equal?", rb_obj_equal, 1); - rb_define_method(rb_mKernel, "===", rb_equal, 1); + rb_define_method(rb_mKernel, "===", rb_equal, 1); rb_define_method(rb_mKernel, "=~", rb_obj_pattern_match, 1); rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1); @@ -2758,13 +2758,13 @@ Init_Object() rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0); rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0); rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1); - rb_define_method(rb_mKernel, "singleton_methods", + rb_define_method(rb_mKernel, "singleton_methods", rb_obj_singleton_methods, -1); /* in class.c */ - rb_define_method(rb_mKernel, "protected_methods", + rb_define_method(rb_mKernel, "protected_methods", rb_obj_protected_methods, -1); rb_define_method(rb_mKernel, "private_methods", rb_obj_private_methods, -1); rb_define_method(rb_mKernel, "public_methods", rb_obj_public_methods, -1); - rb_define_method(rb_mKernel, "instance_variables", + rb_define_method(rb_mKernel, "instance_variables", rb_obj_instance_variables, 0); /* in variable.c */ rb_define_method(rb_mKernel, "instance_variable_get", rb_obj_ivar_get, 1); rb_define_method(rb_mKernel, "instance_variable_set", rb_obj_ivar_set, 2); @@ -2806,7 +2806,7 @@ Init_Object() rb_define_global_const("NIL", Qnil); rb_cSymbol = rb_define_class("Symbol", rb_cObject); - rb_define_singleton_method(rb_cSymbol, "all_symbols", + rb_define_singleton_method(rb_cSymbol, "all_symbols", rb_sym_all_symbols, 0); /* in parse.y */ rb_undef_alloc_func(rb_cSymbol); rb_undef_method(CLASS_OF(rb_cSymbol), "new"); @@ -2818,7 +2818,7 @@ Init_Object() rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0); rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0); rb_define_method(rb_cSymbol, "to_proc", sym_to_proc, 0); - rb_define_method(rb_cSymbol, "===", rb_obj_equal, 1); + rb_define_method(rb_cSymbol, "===", rb_obj_equal, 1); rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0); rb_define_method(rb_cModule, "===", rb_mod_eqq, 1); @@ -2830,7 +2830,7 @@ Init_Object() rb_define_method(rb_cModule, ">=", rb_mod_ge, 1); rb_define_method(rb_cModule, "initialize_copy", rb_mod_init_copy, 1); /* in class.c */ rb_define_method(rb_cModule, "to_s", rb_mod_to_s, 0); - rb_define_method(rb_cModule, "included_modules", + rb_define_method(rb_cModule, "included_modules", rb_mod_included_modules, 0); /* in class.c */ rb_define_method(rb_cModule, "include?", rb_mod_include_p, 1); /* in class.c */ rb_define_method(rb_cModule, "name", rb_mod_name, 0); /* in variable.c */ @@ -2843,13 +2843,13 @@ Init_Object() rb_define_alloc_func(rb_cModule, rb_module_s_alloc); rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0); - rb_define_method(rb_cModule, "instance_methods", + rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */ - rb_define_method(rb_cModule, "public_instance_methods", + rb_define_method(rb_cModule, "public_instance_methods", rb_class_public_instance_methods, -1); /* in class.c */ - rb_define_method(rb_cModule, "protected_instance_methods", + rb_define_method(rb_cModule, "protected_instance_methods", rb_class_protected_instance_methods, -1); /* in class.c */ - rb_define_method(rb_cModule, "private_instance_methods", + rb_define_method(rb_cModule, "private_instance_methods", rb_class_private_instance_methods, -1); /* in class.c */ rb_define_method(rb_cModule, "class_variable_defined?", rb_mod_cvar_defined, 1); @@ -2857,13 +2857,13 @@ Init_Object() rb_define_method(rb_cModule, "const_get", rb_mod_const_get, 1); rb_define_method(rb_cModule, "const_set", rb_mod_const_set, 2); rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, 1); - rb_define_private_method(rb_cModule, "remove_const", + rb_define_private_method(rb_cModule, "remove_const", rb_mod_remove_const, 1); /* in variable.c */ - rb_define_method(rb_cModule, "const_missing", + rb_define_method(rb_cModule, "const_missing", rb_mod_const_missing, 1); /* in variable.c */ - rb_define_method(rb_cModule, "class_variables", + rb_define_method(rb_cModule, "class_variables", rb_mod_class_variables, 0); /* in variable.c */ - rb_define_private_method(rb_cModule, "remove_class_variable", + rb_define_private_method(rb_cModule, "remove_class_variable", rb_mod_remove_cvar, 1); /* in variable.c */ rb_define_private_method(rb_cModule, "class_variable_get", rb_mod_cvar_get, 1); rb_define_private_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2); diff --git a/pack.c b/pack.c index 5af4c44760..74d6d51247 100644 --- a/pack.c +++ b/pack.c @@ -348,13 +348,13 @@ num2i32(x) } #if SIZEOF_LONG == SIZE32 -# define EXTEND32(x) +# define EXTEND32(x) #else /* invariant in modulo 1<<31 */ # define EXTEND32(x) do { if (!natint) {(x) = (((1L<<31)-1-(x))^~(~0L<<31));}} while(0) #endif #if SIZEOF_SHORT == SIZE16 -# define EXTEND16(x) +# define EXTEND16(x) #else # define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15));}} while(0) #endif @@ -374,7 +374,7 @@ static int uv_to_utf8 _((char*,unsigned long)); /* * call-seq: * arr.pack ( aTemplateString ) -> aBinaryString - * + * * Packs the contents of arr into a binary sequence according to * the directives in aTemplateString (see the table below) * Directives ``A,'' ``a,'' and ``Z'' may be followed by a count, @@ -387,13 +387,13 @@ static int uv_to_utf8 _((char*,unsigned long)); * platform's native size for the specified type; otherwise, they use a * platform-independent size. Spaces are ignored in the template * string. See also String#unpack. - * + * * a = [ "a", "b", "c" ] * n = [ 65, 66, 67 ] * a.pack("A3A3A3") #=> "a b c " * a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000" * n.pack("ccc") #=> "ABC" - * + * * Directives for +pack+. * * Directive Meaning @@ -1163,11 +1163,11 @@ infected_str_new(ptr, len, str) OBJ_INFECT(s, str); return s; } - + /* * call-seq: * str.unpack(format) => anArray - * + * * Decodes str (which may contain binary data) according to the * format string, returning an array of each value extracted. The * format string consists of a sequence of single-character directives, @@ -1180,7 +1180,7 @@ infected_str_new(ptr, len, str) * platform's native size for the specified type; otherwise, it uses a * platform-independent consistent size. Spaces are ignored in the * format string. See also Array#pack. - * + * * "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "] * "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"] * "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "] @@ -1192,7 +1192,7 @@ infected_str_new(ptr, len, str) * * This table summarizes the various formats and the Ruby classes * returned by each. - * + * * Format | Returns | Function * -------+---------+----------------------------------------- * A | String | with trailing nulls and spaces removed @@ -1264,17 +1264,17 @@ infected_str_new(ptr, len, str) * p | String | treat sizeof(char *) characters as a * | | pointer to a null-terminated string * -------+---------+----------------------------------------- - * Q | Integer | treat 8 characters as an unsigned + * Q | Integer | treat 8 characters as an unsigned * | | quad word (64 bits) * -------+---------+----------------------------------------- - * q | Integer | treat 8 characters as a signed + * q | Integer | treat 8 characters as a signed * | | quad word (64 bits) * -------+---------+----------------------------------------- * S | Fixnum | treat two (different if _ used) * | | successive characters as an unsigned * | | short in native byte order * -------+---------+----------------------------------------- - * s | Fixnum | Treat two (different if _ used) + * s | Fixnum | Treat two (different if _ used) * | | successive characters as a signed short * | | in native byte order * -------+---------+----------------------------------------- @@ -1297,7 +1297,7 @@ infected_str_new(ptr, len, str) * Z | String | with trailing nulls removed * | | upto first null with * * -------+---------+----------------------------------------- - * @ | --- | skip to the offset given by the + * @ | --- | skip to the offset given by the * | | length argument * -------+---------+----------------------------------------- */ @@ -1663,7 +1663,7 @@ pack_unpack(str, fmt) } PACK_ITEM_ADJUST(); break; - + case 'E': PACK_LENGTH_ADJUST(double,sizeof(double)); while (len-- > 0) { @@ -1677,7 +1677,7 @@ pack_unpack(str, fmt) } PACK_ITEM_ADJUST(); break; - + case 'D': case 'd': PACK_LENGTH_ADJUST(double,sizeof(double)); @@ -1703,7 +1703,7 @@ pack_unpack(str, fmt) } PACK_ITEM_ADJUST(); break; - + case 'G': PACK_LENGTH_ADJUST(double,sizeof(double)); while (len-- > 0) { @@ -1717,7 +1717,7 @@ pack_unpack(str, fmt) } PACK_ITEM_ADJUST(); break; - + case 'U': if (len > send - s) len = send - s; while (len > 0 && s < send) { @@ -1779,7 +1779,7 @@ pack_unpack(str, fmt) else if (s < send && (s+1 == send || s[1] == '\n')) s += 2; /* possible checksum byte */ } - + RSTRING(buf)->ptr[total] = '\0'; RSTRING(buf)->len = total; rb_ary_push(ary, buf); diff --git a/parse.y b/parse.y index 23f2b0f2c3..13cecf4e98 100644 --- a/parse.y +++ b/parse.y @@ -5016,7 +5016,7 @@ new_args(m, o, r, p, b) } return block_append(NEW_ARGS(m, o, r), b); } - + static NODE * evstr2dstr(node) NODE *node; diff --git a/prec.c b/prec.c index 7b215fba09..54c4b1ecdf 100644 --- a/prec.c +++ b/prec.c @@ -22,7 +22,7 @@ static ID prc_pr, prc_if; * num.prec(klass) => a_klass * * Converts _self_ into an instance of _klass_. By default, - * +prec+ invokes + * +prec+ invokes * * klass.induced_from(num) * @@ -42,7 +42,7 @@ prec_prec(x, klass) * call-seq: * num.prec_i => Integer * - * Returns an +Integer+ converted from _num_. It is equivalent + * Returns an +Integer+ converted from _num_. It is equivalent * to prec(Integer). */ @@ -59,7 +59,7 @@ prec_prec_i(x) * call-seq: * num.prec_f => Float * - * Returns a +Float+ converted from _num_. It is equivalent + * Returns a +Float+ converted from _num_. It is equivalent * to prec(Float). */ @@ -75,7 +75,7 @@ prec_prec_f(x) /* * call-seq: * Mod.induced_from(number) => a_mod - * + * * Creates an instance of mod from. This method is overridden * by concrete +Numeric+ classes, so that (for example) * diff --git a/random.c b/random.c index 258b0b2230..c0e8912955 100644 --- a/random.c +++ b/random.c @@ -10,7 +10,7 @@ **********************************************************************/ -/* +/* This is based on trimmed version of MT19937. To get the original version, contact . @@ -21,11 +21,11 @@ The original copyright notice follows. This is a faster version by taking Shawn Cokus's optimization, Matthe Bellew's simplification, Isaku Wada's real version. - Before using, initialize the state by using init_genrand(seed) + Before using, initialize the state by using init_genrand(seed) or init_by_array(init_key, key_length). Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - All rights reserved. + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -38,8 +38,8 @@ The original copyright notice follows. notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -60,7 +60,7 @@ The original copyright notice follows. email: matumoto@math.keio.ac.jp */ -/* Period parameters */ +/* Period parameters */ #define N 624 #define M 397 #define MATRIX_A 0x9908b0dfUL /* constant vector a */ @@ -82,7 +82,7 @@ init_genrand(s) int j; state[0]= s & 0xffffffffUL; for (j=1; j> 30)) + j); + state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j); /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* In the previous versions, MSBs of the seed affect */ /* only MSBs of the array state[]. */ @@ -119,7 +119,7 @@ init_by_array(unsigned long init_key[], int key_length) if (i>=N) { state[0] = state[N-1]; i=1; } } - state[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ + state[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ left = 1; initf = 1; } @@ -135,11 +135,11 @@ next_state() left = N; next = state; - - for (j=N-M+1; --j; p++) + + for (j=N-M+1; --j; p++) *p = p[M] ^ TWIST(p[0], p[1]); - for (j=M; --j; p++) + for (j=M; --j; p++) *p = p[M-N] ^ TWIST(p[0], p[1]); *p = p[M-N] ^ TWIST(p[0], state[0]); @@ -165,11 +165,11 @@ rb_genrand_int32(void) /* generates a random number on [0,1) with 53-bit resolution*/ double -rb_genrand_real(void) -{ - unsigned long a=rb_genrand_int32()>>5, b=rb_genrand_int32()>>6; - return(a*67108864.0+b)*(1.0/9007199254740992.0); -} +rb_genrand_real(void) +{ + unsigned long a=rb_genrand_int32()>>5, b=rb_genrand_int32()>>6; + return(a*67108864.0+b)*(1.0/9007199254740992.0); +} /* These real versions are due to Isaku Wada, 2002/01/09 added */ #undef N @@ -306,7 +306,7 @@ random_seed() /* * call-seq: * srand(number=0) => old_seed - * + * * Seeds the pseudorandom number generator to the value of * number.to_i.abs. If number is omitted, * seeds the generator using a combination of the time, the @@ -334,7 +334,7 @@ rb_f_srand(argc, argv, obj) return old; } -static unsigned long +static unsigned long make_mask(unsigned long x) { x = x | x >> 1; @@ -416,7 +416,7 @@ limited_big_rand(struct RBignum *limit) /* * call-seq: * rand(max=0) => number - * + * * Converts max to an integer using max1 = * max.to_i.abs. If the result is zero, returns a * pseudorandom floating point number greater than or equal to 0.0 and @@ -425,7 +425,7 @@ limited_big_rand(struct RBignum *limit) * may be used to ensure repeatable sequences of random numbers between * different runs of the program. Ruby currently uses a modified * Mersenne Twister with a period of 2**19937-1. - * + * * srand 1234 #=> 0 * [ rand, rand ] #=> [0.191519450163469, 0.49766366626136] * [ rand(10), rand(1000) ] #=> [6, 817] diff --git a/re.c b/re.c index ed03980685..eddb826acc 100644 --- a/re.c +++ b/re.c @@ -222,7 +222,7 @@ rb_kcode_set_option(re) re_mbcinit(MBCTYPE_UTF8); break; } -} +} void rb_kcode_reset_option() @@ -291,7 +291,7 @@ rb_reg_expr_str(str, s, len) rb_str_buf_cat(str, s, len); } else { - p = s; + p = s; while (pptr->options & RE_OPTION_EXTENDED) rb_str_buf_cat2(str, "x"); - + if (FL_TEST(re, KCODE_FIXED)) { switch ((RBASIC(re)->flags & KCODE_MASK)) { case KCODE_NONE: @@ -370,9 +370,9 @@ rb_reg_desc(s, len, re) /* * call-seq: * rxp.source => str - * + * * Returns the original string of the pattern. - * + * * /ab+c/ix.source #=> "ab+c" */ @@ -411,7 +411,7 @@ rb_reg_inspect(re) /* * call-seq: * rxp.to_s => str - * + * * Returns a string containing the regular expression and its options (using the * (?xxx:yyy) notation. This string can be fed back in to * Regexp::new to a regular expression with the same semantics as @@ -419,7 +419,7 @@ rb_reg_inspect(re) * comparing the two, as the source of the regular expression itself may * differ, as the example shows). Regexp#inspect produces a * generally more readable version of rxp. - * + * * r1 = /ab+c/ix #=> /ab+c/ix * s1 = r1.to_s #=> "(?ix-m:ab+c)" * r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/ @@ -538,7 +538,7 @@ rb_reg_raise(s, len, err, re) /* * call-seq: * rxp.casefold? => true or false - * + * * Returns the value of the case-insensitive flag. */ @@ -555,22 +555,22 @@ rb_reg_casefold_p(re) /* * call-seq: * rxp.options => fixnum - * + * * Returns the set of bits corresponding to the options used when creating this * Regexp (see Regexp::new for details. Note that additional bits * may be set in the returned options: these are used internally by the regular * expression code. These extra bits are ignored if the options are passed to * Regexp::new. - * + * * Regexp::IGNORECASE #=> 1 * Regexp::EXTENDED #=> 2 * Regexp::MULTILINE #=> 4 - * + * * /cat/.options #=> 128 * /cat/ix.options #=> 131 * Regexp.new('cat', true).options #=> 129 * Regexp.new('cat', 0, 's').options #=> 384 - * + * * r = /cat/ix * Regexp.new(r.source, r.options) #=> /cat/ix */ @@ -587,7 +587,7 @@ rb_reg_options_m(re) /* * call-seq: * rxp.kcode => str - * + * * Returns the character set code for the regexp. */ @@ -715,9 +715,9 @@ match_init_copy(obj, orig) * call-seq: * mtch.length => integer * mtch.size => integer - * + * * Returns the number of elements in the match array. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.length #=> 5 * m.size #=> 5 @@ -735,10 +735,10 @@ match_size(match) /* * call-seq: * mtch.offset(n) => array - * + * * Returns a two-element array containing the beginning and ending offsets of * the nth match. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.offset(0) #=> [1, 7] * m.offset(4) #=> [6, 7] @@ -765,10 +765,10 @@ match_offset(match, n) /* * call-seq: * mtch.begin(n) => integer - * + * * Returns the offset of the start of the nth element of the match * array in the string. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.begin(0) #=> 1 * m.begin(2) #=> 2 @@ -794,10 +794,10 @@ match_begin(match, n) /* * call-seq: * mtch.end(n) => integer - * + * * Returns the offset of the character immediately following the end of the * nth element of the match array in the string. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.end(0) #=> 7 * m.end(2) #=> 3 @@ -951,7 +951,7 @@ rb_reg_search(re, str, pos, reverse) match = match_alloc(rb_cMatch); } else { - if (rb_safe_level() >= 3) + if (rb_safe_level() >= 3) OBJ_TAINT(match); else FL_UNSET(match, FL_TAINT); @@ -1022,10 +1022,10 @@ rb_reg_last_match(match) /* * call-seq: * mtch.pre_match => str - * + * * Returns the portion of the original string before the current match. * Equivalent to the special variable $`. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.pre_match #=> "T" */ @@ -1048,10 +1048,10 @@ rb_reg_match_pre(match) /* * call-seq: * mtch.post_match => str - * + * * Returns the portion of the original string after the current match. * Equivalent to the special variable $'. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") * m.post_match #=> ": The Movie" */ @@ -1150,18 +1150,18 @@ match_array(match, start) /* * call-seq: * mtch.to_a => anArray - * + * * Returns the array of matches. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.to_a #=> ["HX1138", "H", "X", "113", "8"] - * + * * Because to_a is called when expanding * *variable, there's a useful assignment * shortcut for extracting matched fields. This is slightly slower than * accessing the fields directly (as an intermediate array is * generated). - * + * * all,f1,f2,f3 = *(/(.)(.)(\d+)(\d)/.match("THX1138.")) * all #=> "HX1138" * f1 #=> "H" @@ -1202,13 +1202,13 @@ match_captures(match) * mtch[i] => obj * mtch[start, length] => array * mtch[range] => array - * + * * Match Reference---MatchData acts as an array, and may be * accessed using the normal array indexing techniques. mtch[0] is * equivalent to the special variable $&, and returns the entire * matched string. mtch[1], mtch[2], and so on return the values * of the matched backreferences (portions of the pattern between parentheses). - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m[0] #=> "HX1138" * m[1, 2] #=> ["H", "X"] @@ -1245,10 +1245,10 @@ match_entry(match, n) /* * call-seq: * mtch.values_at([index]*) => array - * + * * Uses each index to access the matching values, returning an array of * the corresponding matches. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") * m.to_a #=> ["HX1138", "H", "X", "113", "8"] * m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"] @@ -1268,10 +1268,10 @@ match_values_at(argc, argv, match) /* * call-seq: * mtch.select{|obj| block} => array - * + * * Returns an array containing match strings for which block * gives true. MatchData#select will be removed from Ruby 1.9. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") * p m.select{|x| /X/ =~ x} #=> ["HX1138", "X"] */ @@ -1312,9 +1312,9 @@ match_select(argc, argv, match) /* * call-seq: * mtch.to_s => str - * + * * Returns the entire matched string. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.to_s #=> "HX1138" */ @@ -1335,9 +1335,9 @@ match_to_s(match) /* * call-seq: * mtch.string => str - * + * * Returns a frozen copy of the string passed in to match. - * + * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.string #=> "THX1138." */ @@ -1545,7 +1545,7 @@ rb_reg_hash(re) hashval = hashval * 33 + *p++; } hashval = hashval + (hashval>>5); - + return INT2FIX(hashval); } @@ -1554,11 +1554,11 @@ rb_reg_hash(re) * call-seq: * rxp == other_rxp => true or false * rxp.eql?(other_rxp) => true or false - * + * * Equality---Two regexps are equal if their patterns are identical, they have * the same character set code, and their casefold? values are the * same. - * + * * /abc/ == /abc/x #=> false * /abc/ == /abc/i #=> false * /abc/u == /abc/n #=> false @@ -1584,11 +1584,11 @@ rb_reg_equal(re1, re2) /* * call-seq: * rxp.match(str) => matchdata or nil - * + * * Returns a MatchData object describing the match, or * nil if there was no match. This is equivalent to retrieving the * value of the special variable $~ following a normal match. - * + * * /(.)(.)(.)/.match("abc")[2] #=> "b" */ @@ -1614,18 +1614,18 @@ rb_reg_match(re, str) /* * call-seq: * rxp === str => true or false - * + * * Case Equality---Synonym for Regexp#=~ used in case statements. - * + * * a = "HELLO" * case a * when /^[a-z]*$/; print "Lower case\n" * when /^[A-Z]*$/; print "Upper case\n" * else; print "Mixed case\n" * end - * + * * produces: - * + * * Upper case */ @@ -1654,10 +1654,10 @@ rb_reg_eqq(re, str) /* * call-seq: * ~ rxp => integer or nil - * + * * Match---Matches rxp against the contents of $_. * Equivalent to rxp =~ $_. - * + * * $_ = "input data" * ~ /at/ #=> 7 */ @@ -1685,11 +1685,11 @@ rb_reg_match2(re) /* * call-seq: * rxp.match(str) => matchdata or nil - * + * * Returns a MatchData object describing the match, or * nil if there was no match. This is equivalent to retrieving the * value of the special variable $~ following a normal match. - * + * * /(.)(.)(.)/.match("abc")[2] #=> "b" */ @@ -1717,7 +1717,7 @@ rb_reg_match_m(re, str) * Regexp.new(regexp) => regexp * Regexp.compile(string [, options [, lang]]) => regexp * Regexp.compile(regexp) => regexp - * + * * Constructs a new regular expression from pattern, which can be either * a String or a Regexp (in which case that regexp's * options are propagated, and new options may not be specified (a change as of @@ -1728,7 +1728,7 @@ rb_reg_match_m(re, str) * nil, the regexp will be case insensitive. The lang * parameter enables multibyte support for the regexp: `n', `N' = none, `e', * `E' = EUC, `s', `S' = SJIS, `u', `U' = UTF-8. - * + * * r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/ * r2 = Regexp.new('cat', true) #=> /cat/i * r3 = Regexp.new('dog', Regexp::EXTENDED) #=> /dog/x @@ -1898,12 +1898,12 @@ rb_reg_quote(str) * call-seq: * Regexp.escape(str) => a_str * Regexp.quote(str) => a_str - * + * * Escapes any characters that would have special meaning in a regular * expression. Returns a new escaped string, or self if no characters are * escaped. For any string, * Regexp.escape(str)=~str will be true. - * + * * Regexp.escape('\\*?{}.') #=> \\\\\*\?\{\}\. */ @@ -2090,12 +2090,12 @@ rb_reg_s_union(self, args0) * call-seq: * Regexp.union(pat1, pat2, ...) => new_regexp * Regexp.union(pats_ary) => new_regexp - * + * * Return a Regexp object that is the union of the given * patterns, i.e., will match any of its parts. The patterns * can be Regexp objects, in which case their options will be preserved, or * Strings. If no patterns are given, returns /(?!)/. - * + * * Regexp.union #=> /(?!)/ * Regexp.union("penzance") #=> /penzance/ * Regexp.union("a+b*c") #=> /a\+b\*c/ @@ -2320,7 +2320,7 @@ match_setter(val) * call-seq: * Regexp.last_match => matchdata * Regexp.last_match(fixnum) => str - * + * * The first form returns the MatchData object generated by the * last successful pattern match. Equivalent to reading the global variable * $~. The second form returns the nth field in this @@ -2328,7 +2328,7 @@ match_setter(val) * * Note that the last_match is local to the scope * of the method that did the pattern match. - * + * * /c(.)t/ =~ 'cat' #=> 0 * Regexp.last_match #=> # * Regexp.last_match(0) #=> "cat" @@ -2352,9 +2352,9 @@ rb_reg_s_last_match(argc, argv) /* * call-seq: * str.ord => integer - * + * * Return the Integer ordinal of a one-character string. - * + * * "a".ord #=> 97 */ diff --git a/regex.c b/regex.c index 693bd6331f..090460dd51 100644 --- a/regex.c +++ b/regex.c @@ -222,12 +222,12 @@ init_syntax_once() memset(re_syntax_table, 0, sizeof re_syntax_table); for (c=0; c<=0x7f; c++) - if (isalnum(c)) + if (isalnum(c)) re_syntax_table[c] = Sword; re_syntax_table['_'] = Sword; for (c=0x80; c<=0xff; c++) - if (isalnum(c)) + if (isalnum(c)) re_syntax_table[c] = Sword2; done = 1; } @@ -320,9 +320,9 @@ enum regexpcode begpos, /* Matches where last scan//gsub left off. */ jump, /* Followed by two bytes giving relative address to jump to. */ jump_past_alt,/* Same as jump, but marks the end of an alternative. */ - on_failure_jump, /* Followed by two bytes giving relative address of + on_failure_jump, /* Followed by two bytes giving relative address of place to resume at in case of failure. */ - finalize_jump, /* Throw away latest failure point and then jump to + finalize_jump, /* Throw away latest failure point and then jump to address. */ maybe_finalize_jump, /* Like jump but finalize if safe to do so. This is used to jump back to the beginning @@ -332,9 +332,9 @@ enum regexpcode we can be sure that there is no use backtracking out of repetitions already completed, then we finalize. */ - dummy_failure_jump, /* Jump, and push a dummy failure point. This - failure point will be thrown away if an attempt - is made to use it for a failure. A + construct + dummy_failure_jump, /* Jump, and push a dummy failure point. This + failure point will be thrown away if an attempt + is made to use it for a failure. A + construct makes this before the first repeat. Also use it as an intermediary kind of jump when compiling an or construct. */ @@ -383,7 +383,7 @@ enum regexpcode pop_and_fail, /* Fail after popping nowidth entry from stack. */ stop_backtrack, /* Restore backtrack stack at the point start_nowidth. */ duplicate, /* Match a duplicate of something remembered. - Followed by one byte containing the index of the memory + Followed by one byte containing the index of the memory register. */ wordchar, /* Matches any word-constituent character. */ notwordchar, /* Matches any char that is not a word-constituent. */ @@ -448,7 +448,7 @@ re_set_syntax(syntax) #define TRANSLATE_P() ((options&RE_OPTION_IGNORECASE) && translate) #define MAY_TRANSLATE() ((bufp->options&(RE_OPTION_IGNORECASE|RE_MAY_IGNORECASE)) && translate) -/* Fetch the next character in the uncompiled pattern---translating it +/* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant string passed to us by the user to an unsigned char that we can use as an array index (in, e.g., `translate'). */ @@ -535,7 +535,7 @@ print_mbc(c) else if (c <= 0xffff) printf("%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 6) & 0x3f), (int)(c & 0x3f)); - else if (c <= 0x1fffff) + else if (c <= 0x1fffff) printf("%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 12) & 0x3f), (int)((c >> 6) & 0x3f), (int)(c & 0x3f)); else if (c <= 0x3ffffff) @@ -732,7 +732,7 @@ is_in_list_sbc(c, b) size = *b++; return ((int)c / BYTEWIDTH < (int)size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH); } - + static int is_in_list_mbc(c, b) unsigned long c; @@ -934,19 +934,19 @@ print_partial_compiled_pattern(start, end) printf("/jump//%d", mcnt); break; - case succeed_n: + case succeed_n: EXTRACT_NUMBER_AND_INCR(mcnt, p); EXTRACT_NUMBER_AND_INCR(mcnt2, p); printf("/succeed_n//%d//%d", mcnt, mcnt2); break; - case jump_n: + case jump_n: EXTRACT_NUMBER_AND_INCR(mcnt, p); EXTRACT_NUMBER_AND_INCR(mcnt2, p); printf("/jump_n//%d//%d", mcnt, mcnt2); break; - case set_number_at: + case set_number_at: EXTRACT_NUMBER_AND_INCR(mcnt, p); EXTRACT_NUMBER_AND_INCR(mcnt2, p); printf("/set_number_at//%d//%d", mcnt, mcnt2); @@ -986,7 +986,7 @@ print_partial_compiled_pattern(start, end) case wordchar: printf("/wordchar"); break; - + case notwordchar: printf("/notwordchar"); break; @@ -1108,7 +1108,7 @@ calculate_must_string(start, end) break; case dummy_failure_jump: - case succeed_n: + case succeed_n: case try_next: case jump: EXTRACT_NUMBER_AND_INCR(mcnt, p); @@ -1124,8 +1124,8 @@ calculate_must_string(start, end) p += 2; break; - case jump_n: - case set_number_at: + case jump_n: + case set_number_at: case finalize_push_n: p += 4; break; @@ -1363,8 +1363,8 @@ re_compile_pattern(pattern, size, bufp) case '*': /* If there is no previous pattern, char not special. */ if (!laststart) { - snprintf(error_msg, ERROR_MSG_MAX_SIZE, - "invalid regular expression; there's no previous pattern, to which '%c' would define cardinality at %ld", + snprintf(error_msg, ERROR_MSG_MAX_SIZE, + "invalid regular expression; there's no previous pattern, to which '%c' would define cardinality at %ld", c, (long)(p-pattern)); FREE_AND_RETURN(stackb, error_msg); } @@ -1391,7 +1391,7 @@ re_compile_pattern(pattern, size, bufp) repeat: /* Star, etc. applied to an empty pattern is equivalent to an empty pattern. */ - if (!laststart) + if (!laststart) break; if (greedy && many_times_ok && *laststart == anychar && b - laststart <= 2) { @@ -1455,7 +1455,7 @@ re_compile_pattern(pattern, size, bufp) laststart = b; if (*p == '^') { - BUFPUSH(charset_not); + BUFPUSH(charset_not); p++; } else @@ -1494,7 +1494,7 @@ re_compile_pattern(pattern, size, bufp) FREE_AND_RETURN(stackb, "invalid regular expression; empty character class"); re_warning("character class has `]' without escape"); } - else + else /* Stop if this isn't merely a ] inside a bracket expression, but rather the end of a bracket expression. */ @@ -1626,7 +1626,7 @@ re_compile_pattern(pattern, size, bufp) c1 = 0; /* If pattern is `[[:'. */ - if (p == pend) + if (p == pend) FREE_AND_RETURN(stackb, "invalid regular expression; re can't end '[[:'"); for (;;) { @@ -1657,7 +1657,7 @@ re_compile_pattern(pattern, size, bufp) char is_xdigit = STREQ(str, "xdigit"); if (!IS_CHAR_CLASS(str)){ - snprintf(error_msg, ERROR_MSG_MAX_SIZE, + snprintf(error_msg, ERROR_MSG_MAX_SIZE, "invalid regular expression; [:%s:] is not a character class", str); FREE_AND_RETURN(stackb, error_msg); } @@ -1665,7 +1665,7 @@ re_compile_pattern(pattern, size, bufp) /* Throw away the ] at the end of the character class. */ PATFETCH(c); - if (p == pend) + if (p == pend) FREE_AND_RETURN(stackb, "invalid regular expression; range doesn't have ending ']' after a character class"); for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { @@ -1688,7 +1688,7 @@ re_compile_pattern(pattern, size, bufp) } else { c1 += 2; - while (c1--) + while (c1--) PATUNFETCH; re_warning("character class has `[' without escape"); c = '['; @@ -1703,11 +1703,11 @@ re_compile_pattern(pattern, size, bufp) range = 0; if (had_mbchar == 0) { if (TRANSLATE_P()) { - for (;last<=c;last++) + for (;last<=c;last++) SET_LIST_BIT(translate[last]); } else { - for (;last<=c;last++) + for (;last<=c;last++) SET_LIST_BIT(last); } } @@ -1740,8 +1740,8 @@ re_compile_pattern(pattern, size, bufp) /* Discard any character set/class bitmap bytes that are all 0 at the end of the map. Decrement the map-length byte too. */ - while ((int)b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; + while ((int)b[-1] > 0 && b[b[-1] - 1] == 0) + b[-1]--; if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH) memmove(&b[(unsigned char)b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH], 2 + EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8); @@ -1857,7 +1857,7 @@ re_compile_pattern(pattern, size, bufp) /* Laststart should point to the start_memory that we are about to push (unless the pattern has RE_NREGS or more ('s). */ /* obsolete: now RE_NREGS is just a default register size. */ - *stackp++ = b - bufp->buffer; + *stackp++ = b - bufp->buffer; *stackp++ = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; *stackp++ = begalt - bufp->buffer; switch (c) { @@ -1911,7 +1911,7 @@ re_compile_pattern(pattern, size, bufp) break; case ')': - if (stackp == stackb) + if (stackp == stackb) FREE_AND_RETURN(stackb, "unmatched )"); pending_exact = 0; @@ -2000,10 +2000,10 @@ re_compile_pattern(pattern, size, bufp) jump (put in below, which in turn will jump to the next (if any) alternative's such jump, etc.). The last such jump jumps to the correct final destination. A picture: - _____ _____ - | | | | - | v | v - a | b | c + _____ _____ + | | | | + | v | v + a | b | c If we are at `b', then fixup_alt_jump right now points to a three-byte space after `a'. We'll put in the jump, set @@ -2027,8 +2027,8 @@ re_compile_pattern(pattern, size, bufp) case '{': /* If there is no previous pattern, this is an invalid pattern. */ if (!laststart) { - snprintf(error_msg, ERROR_MSG_MAX_SIZE, - "invalid regular expression; there's no previous pattern, to which '{' would define cardinality at %ld", + snprintf(error_msg, ERROR_MSG_MAX_SIZE, + "invalid regular expression; there's no previous pattern, to which '{' would define cardinality at %ld", (long)(p-pattern)); FREE_AND_RETURN(stackb, error_msg); } @@ -2089,7 +2089,7 @@ re_compile_pattern(pattern, size, bufp) } } - /* If upper_bound is zero, don't want to succeed at all; + /* If upper_bound is zero, don't want to succeed at all; jump from laststart to b + 3, which will be the end of the buffer after this jump is inserted. */ @@ -2157,11 +2157,11 @@ re_compile_pattern(pattern, size, bufp) attendant `set_number_at' (inserted next), because `re_compile_fastmap' needs to know. Jump to the `jump_n' we might insert below. */ - insert_jump_n(succeed_n, laststart, b + (nbytes/2), + insert_jump_n(succeed_n, laststart, b + (nbytes/2), b, lower_bound); b += 5; /* Just increment for the succeed_n here. */ - /* Code to initialize the lower bound. Insert + /* Code to initialize the lower bound. Insert before the `succeed_n'. The `5' is the last two bytes of this `set_number_at', plus 3 bytes of the following `succeed_n'. */ @@ -2209,7 +2209,7 @@ re_compile_pattern(pattern, size, bufp) beg_interval = 0; /* normal_char and normal_backslash need `c'. */ - PATFETCH(c); + PATFETCH(c); goto normal_char; case '\\': @@ -2254,8 +2254,8 @@ re_compile_pattern(pattern, size, bufp) } } - while ((int)b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; + while ((int)b[-1] > 0 && b[b[-1] - 1] == 0) + b[-1]--; if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH) memmove(&b[(unsigned char)b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH], 2 + EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8); @@ -2537,7 +2537,7 @@ store_jump(from, opcode, to) /* Open up space before char FROM, and insert there a jump to TO. - CURRENT_END gives the end of the storage not in use, so we know + CURRENT_END gives the end of the storage not in use, so we know how much data to copy up. OP is the opcode of the jump to insert. If you call this function, you must zero out pending_exact. */ @@ -2550,7 +2550,7 @@ insert_jump(op, from, to, current_end) register char *pfrom = current_end; /* Copy from here... */ register char *pto = current_end + 3; /* ...to here. */ - while (pfrom != from) + while (pfrom != from) *--pto = *--pfrom; store_jump(from, op, to); } @@ -2593,7 +2593,7 @@ insert_jump_n(op, from, to, current_end, n) register char *pfrom = current_end; /* Copy from here... */ register char *pto = current_end + 5; /* ...to here. */ - while (pfrom != from) + while (pfrom != from) *--pto = *--pfrom; store_jump_n(from, op, to, n); } @@ -2614,7 +2614,7 @@ insert_op(op, there, current_end) register char *pfrom = current_end; /* Copy from here... */ register char *pto = current_end + 1; /* ...to here. */ - while (pfrom != there) + while (pfrom != there) *--pto = *--pfrom; there[0] = (char)op; @@ -2637,7 +2637,7 @@ insert_op_2(op, there, current_end, num_1, num_2) register char *pfrom = current_end; /* Copy from here... */ register char *pto = current_end + 5; /* ...to here. */ - while (pfrom != there) + while (pfrom != there) *--pto = *--pfrom; there[0] = (char)op; @@ -2787,7 +2787,7 @@ bm_search(little, llen, big, blen, skip, translate) that matches the pattern. This fastmap is used by re_search to skip quickly over totally implausible text. - The caller must supply the address of a (1 << BYTEWIDTH)-byte data + The caller must supply the address of a (1 << BYTEWIDTH)-byte data area as bufp->fastmap. The other components of bufp describe the pattern to be used. */ static int @@ -2802,7 +2802,7 @@ re_compile_fastmap0(bufp) register int j, k; unsigned is_a_succeed_n; - + unsigned char *stacka[NFAILURES]; unsigned char **stackb = stacka; unsigned char **stackp = stackb; @@ -2885,7 +2885,7 @@ re_compile_fastmap0(bufp) case finalize_push: case finalize_push_n: EXTRACT_NUMBER_AND_INCR(j, p); - p += j; + p += j; if (j > 0) continue; /* Jump backward reached implies we just went through @@ -2901,7 +2901,7 @@ re_compile_fastmap0(bufp) continue; p++; EXTRACT_NUMBER_AND_INCR(j, p); - p += j; + p += j; if (stackp != stackb && *stackp == p) stackp--; /* pop */ continue; @@ -3358,7 +3358,7 @@ re_search(bufp, string, size, startpos, range, regs) } advance: - if (!range) + if (!range) break; else if (range > 0) { const char *d = string + startpos; @@ -3378,7 +3378,7 @@ re_search(bufp, string, size, startpos, range, regs) s = string; d = string + startpos; for (p = d; p-- > s && ismbchar(*p); ) - /* --p >= s would not work on 80[12]?86. + /* --p >= s would not work on 80[12]?86. (when the offset of s equals 0 other than huge model.) */ ; if (!((d - p) & 1)) { @@ -3640,7 +3640,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) register_info_type *reg_info = bufp->reg_info; /* The following record the register info as found in the above - variables when we find a match better than any we've seen before. + variables when we find a match better than any we've seen before. This happens as we backtrack through the failure points, which in turn happens only if we have not yet matched the entire string. */ @@ -3726,7 +3726,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) best_regend[mcnt] = regend[mcnt]; } } - goto fail; + goto fail; } /* If no failure points, don't restore garbage. */ else if (best_regs_set) { @@ -3741,7 +3741,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) } } - /* If caller wants register contents data back, convert it + /* If caller wants register contents data back, convert it to indices. */ if (regs) { regs->beg[0] = pos; @@ -3829,8 +3829,8 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) /* Compare that many; failure if mismatch, else move past them. */ - if ((options & RE_OPTION_IGNORECASE) - ? memcmp_translate(d, d2, mcnt) + if ((options & RE_OPTION_IGNORECASE) + ? memcmp_translate(d, d2, mcnt) : memcmp((char*)d, (char*)d2, mcnt)) goto fail; d += mcnt, d2 += mcnt; @@ -3986,7 +3986,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) tensioning the jumps is a hassle.) */ /* The start of a stupid repeat has an on_failure_jump that points - past the end of the repeat text. This makes a failure point so + past the end of the repeat text. This makes a failure point so that on failure to match a repetition, matching restarts past as many repetitions have been found with no way to fail and look for another one. */ @@ -4065,7 +4065,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) } p -= 2; /* Point at relative address again. */ if (p[-1] != (unsigned char)finalize_jump) { - p[-1] = (unsigned char)jump; + p[-1] = (unsigned char)jump; goto nofinalize; } /* Note fall through. */ @@ -4074,7 +4074,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) start, where another failure point will be made which will point to after all the repetitions found so far. */ - /* Take off failure points put on by matching on_failure_jump + /* Take off failure points put on by matching on_failure_jump because didn't fail. Also remove the register information put on by the on_failure_jump. */ case finalize_jump: @@ -4083,7 +4083,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) POP_FAILURE_POINT(); continue; } - POP_FAILURE_POINT(); + POP_FAILURE_POINT(); /* Note fall through. */ /* We need this opcode so we can detect where alternatives end @@ -4137,7 +4137,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) /* Have to succeed matching what follows at least n times. Then just handle like an on_failure_jump. */ - case succeed_n: + case succeed_n: EXTRACT_NUMBER(mcnt, p + 2); /* Originally, this is how many times we HAVE to succeed. */ if (mcnt != 0) { @@ -4163,8 +4163,8 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) any failure points. */ } /* If don't have to jump any more, skip over the rest of command. */ - else - p += 4; + else + p += 4; continue; case set_number_at: @@ -4193,7 +4193,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) continue; case finalize_push_n: - EXTRACT_NUMBER(mcnt, p + 2); + EXTRACT_NUMBER(mcnt, p + 2); /* Originally, this is how many times we CAN jump. */ if (mcnt) { int pos, i; @@ -4210,8 +4210,8 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) p += 2; /* skip n */ } /* If don't have to push any more, skip over the rest of command. */ - else - p += 4; + else + p += 4; continue; /* Ignore these. Used to ignore the n of succeed_n's which @@ -4301,7 +4301,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs) PREFETCH; if (*p == 0xff) { - p++; + p++; if (!--mcnt || AT_STRINGS_END(d) || (unsigned char)*d++ != (unsigned char)*p++) diff --git a/regex.h b/regex.h index fe4dbbb9ab..7e68110fec 100644 --- a/regex.h +++ b/regex.h @@ -55,7 +55,7 @@ /* Maximum number of duplicates an interval can allow. */ #ifndef RE_DUP_MAX -#define RE_DUP_MAX ((1 << 15) - 1) +#define RE_DUP_MAX ((1 << 15) - 1) #endif diff --git a/signal.c b/signal.c index fb21fd34fe..4e69970d8d 100644 --- a/signal.c +++ b/signal.c @@ -298,14 +298,14 @@ ruby_default_signal(sig) /* * call-seq: * Process.kill(signal, pid, ...) => fixnum - * + * * Sends the given signal to the specified process id(s), or to the * current process if _pid_ is zero. _signal_ may be an * integer signal number or a POSIX signal name (either with or without * a +SIG+ prefix). If _signal_ is negative (or starts * with a minus sign), kills process groups instead of * processes. Not all signals are available on all platforms. - * + * * pid = fork do * Signal.trap("HUP") { puts "Ouch!"; exit } * # ... do some work ... @@ -313,9 +313,9 @@ ruby_default_signal(sig) * # ... * Process.kill("HUP", pid) * Process.wait - * + * * produces: - * + * * Ouch! */ @@ -965,7 +965,7 @@ install_sighandler(signum, handler) } #if 0 -/* +/* * If you write a handler which works on any native thread * (even if the thread is NOT a ruby's one), please enable * this function and use it to install the handler, instead diff --git a/sprintf.c b/sprintf.c index d39352b922..10565746a4 100644 --- a/sprintf.c +++ b/sprintf.c @@ -29,7 +29,7 @@ remove_sign_bits(str, base) int base; { char *s, *t; - + s = t = str; if (base == 16) { @@ -144,7 +144,7 @@ sign_bits(base, p) * call-seq: * format(format_string [, arguments...] ) => string * sprintf(format_string [, arguments...] ) => string - * + * * Returns the string resulting from applying format_string to * any additional arguments. Within the format string, any characters * other than format sequences are copied to the result. A format @@ -157,7 +157,7 @@ sign_bits(base, p) * * Flag | Applies to | Meaning * ---------+--------------+----------------------------------------- - * space | bdeEfgGiouxX | Leave a space at the start of + * space | bdeEfgGiouxX | Leave a space at the start of * | | positive numbers. * ---------+--------------+----------------------------------------- * (digit)$ | all | Specifies the absolute argument number @@ -166,7 +166,7 @@ sign_bits(base, p) * | | sprintf string. * ---------+--------------+----------------------------------------- * # | beEfgGoxX | Use an alternative format. For the - * | | conversions `o', `x', `X', and `b', + * | | conversions `o', `x', `X', and `b', * | | prefix the result with ``0'', ``0x'', ``0X'', * | | and ``0b'', respectively. For `e', * | | `E', `f', `g', and 'G', force a decimal @@ -179,12 +179,12 @@ sign_bits(base, p) * ---------+--------------+----------------------------------------- * 0 (zero) | bdeEfgGiouxX | Pad with zeros, not spaces. * ---------+--------------+----------------------------------------- - * * | all | Use the next argument as the field width. + * * | all | Use the next argument as the field width. * | | If negative, left-justify the result. If the - * | | asterisk is followed by a number and a dollar + * | | asterisk is followed by a number and a dollar * | | sign, use the indicated argument as the width. * - * + * * The field width is an optional integer, followed optionally by a * period and a precision. The width specifies the minimum number of * characters that will be written to the result for this field. For @@ -203,10 +203,10 @@ sign_bits(base, p) * d | Convert argument as a decimal number. * E | Equivalent to `e', but uses an uppercase E to indicate * | the exponent. - * e | Convert floating point argument into exponential notation + * e | Convert floating point argument into exponential notation * | with one digit before the decimal point. The precision * | determines the number of fractional digits (defaulting to six). - * f | Convert floating point argument as [-]ddd.ddd, + * f | Convert floating point argument as [-]ddd.ddd, * | where the precision determines the number of digits after * | the decimal point. * G | Equivalent to `g', but use an uppercase `E' in exponent form. @@ -233,7 +233,7 @@ sign_bits(base, p) * | Negative numbers will be displayed with two * | leading periods (representing an infinite string of * | leading 'ff's. - * + * * Examples: * * sprintf("%d %04x", 123, 123) #=> "123 007b" diff --git a/string.c b/string.c index d1589bede9..6deb912921 100644 --- a/string.c +++ b/string.c @@ -330,7 +330,7 @@ rb_str_dup(str) /* * call-seq: * String.new(str="") => new_str - * + * * Returns a new string object containing a copy of str. */ @@ -350,7 +350,7 @@ rb_str_init(argc, argv, str) /* * call-seq: * str.length => integer - * + * * Returns the length of str. */ @@ -364,9 +364,9 @@ rb_str_length(str) /* * call-seq: * str.empty? => true or false - * + * * Returns true if str has a length of zero. - * + * * "hello".empty? #=> false * "".empty? #=> true */ @@ -383,10 +383,10 @@ rb_str_empty(str) /* * call-seq: * str + other_str => new_str - * + * * Concatenation---Returns a new String containing * other_str concatenated to str. - * + * * "Hello from " + self.to_s #=> "Hello from main" */ @@ -411,10 +411,10 @@ rb_str_plus(str1, str2) /* * call-seq: * str * integer => new_str - * + * * Copy---Returns a new String containing integer copies of * the receiver. - * + * * "Ho! " * 3 #=> "Ho! Ho! Ho! " */ @@ -449,13 +449,13 @@ rb_str_times(str, times) /* * call-seq: * str % arg => new_str - * + * * Format---Uses str as a format specification, and returns the result * of applying it to arg. If the format specification contains more than * one substitution, then arg must be an Array containing * the values to be substituted. See Kernel::sprintf for details * of the format string. - * + * * "%05d" % 123 #=> "00123" * "%-5s: %08x" % [ "ID", self.id ] #=> "ID : 200e14d6" */ @@ -881,11 +881,11 @@ rb_str_append(str, str2) * str.concat(fixnum) => str * str << obj => str * str.concat(obj) => str - * + * * Append---Concatenates the given object to str. If the object is a * Fixnum between 0 and 255, it is converted to a character before * concatenation. - * + * * a = "hello " * a << "world" #=> "hello world" * a.concat(33) #=> "hello world!" @@ -982,7 +982,7 @@ rb_str_cmp(str1, str2) /* * call-seq: * str == obj => true or false - * + * * Equality---If obj is not a String, returns * false. Otherwise, returns true if str * <=> obj returns zero. @@ -1032,7 +1032,7 @@ rb_str_eql(str1, str2) /* * call-seq: * str <=> other_str => -1, 0, +1 - * + * * Comparison---Returns -1 if other_str is greater than, 0 if * other_str is equal to, and +1 if other_str is less than * str. If the strings are of different lengths, and the strings are @@ -1047,7 +1047,7 @@ rb_str_eql(str1, str2) * <=, >, >=, and between?, * included from module Comparable. The method * String#== does not use Comparable#==. - * + * * "abcdef" <=> "abcde" #=> 1 * "abcdef" <=> "abcdef" #=> 0 * "abcdef" <=> "abcdefg" #=> -1 @@ -1086,9 +1086,9 @@ rb_str_cmp_m(str1, str2) /* * call-seq: * str.casecmp(other_str) => -1, 0, +1 - * + * * Case-insensitive version of String#<=>. - * + * * "abcdef".casecmp("abcde") #=> 1 * "aBcDeF".casecmp("abcdef") #=> 0 * "abcdef".casecmp("abcdefg") #=> -1 @@ -1140,12 +1140,12 @@ rb_str_index(str, sub, offset) * str.index(substring [, offset]) => fixnum or nil * str.index(fixnum [, offset]) => fixnum or nil * str.index(regexp [, offset]) => fixnum or nil - * + * * Returns the index of the first occurrence of the given substring, * character (fixnum), or pattern (regexp) in str. Returns * nil if not found. If the second parameter is present, it * specifies the position in the string to begin the search. - * + * * "hello".index('e') #=> 1 * "hello".index('lo') #=> 3 * "hello".index('a') #=> nil @@ -1252,13 +1252,13 @@ rb_str_rindex(str, sub, pos) * str.rindex(substring [, fixnum]) => fixnum or nil * str.rindex(fixnum [, fixnum]) => fixnum or nil * str.rindex(regexp [, fixnum]) => fixnum or nil - * + * * Returns the index of the last occurrence of the given substring, * character (fixnum), or pattern (regexp) in str. Returns * nil if not found. If the second parameter is present, it * specifies the position in the string to end the search---characters beyond * this point will not be considered. - * + * * "hello".rindex('e') #=> 1 * "hello".rindex('l') #=> 3 * "hello".rindex('a') #=> nil @@ -1340,13 +1340,13 @@ rb_str_rindex_m(argc, argv, str) /* * call-seq: * str =~ obj => fixnum or nil - * + * * Match---If obj is a Regexp, use it as a pattern to match - * against str,and returns the position the match starts, or + * against str,and returns the position the match starts, or * nil if there is no match. Otherwise, invokes * obj.=~, passing str as an argument. The default * =~ in Object returns false. - * + * * "cat o' 9 tails" =~ /\d/ #=> 7 * "cat o' 9 tails" =~ 9 #=> false */ @@ -1374,10 +1374,10 @@ static VALUE get_pat _((VALUE, int)); /* * call-seq: * str.match(pattern) => matchdata or nil - * + * * Converts pattern to a Regexp (if it isn't already one), * then invokes its match method on str. - * + * * 'hello'.match('(.)\1') #=> # * 'hello'.match('(.)\1')[0] #=> "ll" * 'hello'.match(/(.)\1/)[0] #=> "ll" @@ -1421,7 +1421,7 @@ succ_char(s) * call-seq: * str.succ => new_str * str.next => new_str - * + * * Returns the successor to str. The successor is calculated by * incrementing characters starting from the rightmost alphanumeric (or * the rightmost character if there are no alphanumerics) in the @@ -1429,11 +1429,11 @@ succ_char(s) * incrementing a letter results in another letter of the same case. * Incrementing nonalphanumerics uses the underlying character set's * collating sequence. - * + * * If the increment generates a ``carry,'' the character to the left of * it is incremented. This process repeats until there is no carry, * adding an additional character if necessary. - * + * * "abcd".succ #=> "abce" * "THX1138".succ #=> "THX1139" * "<>".succ #=> "<>" @@ -1489,7 +1489,7 @@ rb_str_succ(orig) * call-seq: * str.succ! => str * str.next! => str - * + * * Equivalent to String#succ, but modifies the receiver in * place. */ @@ -1535,20 +1535,20 @@ rb_str_upto(beg, end, excl) /* * call-seq: * str.upto(other_str, exclusive=false) {|s| block } => str - * + * * Iterates through successive values, starting at str and * ending at other_str inclusive, passing each value in turn to * the block. The String#succ method is used to generate * each value. If optional second argument exclusive is omitted or is false, * the last value will be included; otherwise it will be excluded. - * + * * "a8".upto("b6") {|s| print s, ' ' } * for s in "a8".."b6" * print s, ' ' * end - * + * * produces: - * + * * a8 a9 b0 b1 b2 b3 b4 b5 b6 * a8 a9 b0 b1 b2 b3 b4 b5 b6 */ @@ -1643,7 +1643,7 @@ rb_str_aref(str, indx) * str.slice(regexp) => new_str or nil * str.slice(regexp, fixnum) => new_str or nil * str.slice(other_str) => new_str or nil - * + * * Element Reference---If passed a single Fixnum, returns the code * of the character at that position. If passed two Fixnum * objects, returns a substring starting at the offset given by the first, and @@ -1652,14 +1652,14 @@ rb_str_aref(str, indx) * an offset is negative, it is counted from the end of str. Returns * nil if the initial offset falls outside the string, the length * is negative, or the beginning of the range is greater than the end. - * + * * If a Regexp is supplied, the matching portion of str is * returned. If a numeric parameter follows the regular expression, that * component of the MatchData is returned instead. If a * String is given, that string is returned if it occurs in * str. In both cases, nil is returned if there is no * match. - * + * * a = "hello there" * a[1] #=> 101 * a[1,3] #=> "ell" @@ -1852,7 +1852,7 @@ rb_str_aset(str, indx, val) * str[regexp] = new_str * str[regexp, fixnum] = new_str * str[other_str] = new_str - * + * * Element Assignment---Replaces some or all of the content of str. The * portion of the string affected is determined using the same criteria as * String#[]. If the replacement string is not the same length as @@ -1892,13 +1892,13 @@ rb_str_aset_m(argc, argv, str) /* * call-seq: * str.insert(index, other_str) => str - * + * * Inserts other_str before the character at the given * index, modifying str. Negative indices count from the * end of the string, and insert after the given character. * The intent is insert aString so that it starts at the given * index. - * + * * "abcd".insert(0, 'X') #=> "Xabcd" * "abcd".insert(3, 'X') #=> "abcXd" * "abcd".insert(4, 'X') #=> "abcdX" @@ -1929,13 +1929,13 @@ rb_str_insert(str, idx, str2) * str.slice!(range) => new_str or nil * str.slice!(regexp) => new_str or nil * str.slice!(other_str) => new_str or nil - * + * * Deletes the specified portion from str, and returns the portion * deleted. The forms that take a Fixnum will raise an * IndexError if the value is out of range; the Range * form will raise a RangeError, and the Regexp and * String forms will silently ignore the assignment. - * + * * string = "this is a string" * string.slice!(2) #=> 105 * string.slice!(3..6) #=> " is " @@ -2026,7 +2026,7 @@ get_arg_pat(pat) * call-seq: * str.sub!(pattern, replacement) => str or nil * str.sub!(pattern) {|match| block } => str or nil - * + * * Performs the substitutions of String#sub in place, * returning str, or nil if no substitutions were * performed. @@ -2100,27 +2100,27 @@ rb_str_sub_bang(argc, argv, str) * call-seq: * str.sub(pattern, replacement) => new_str * str.sub(pattern) {|match| block } => new_str - * + * * Returns a copy of str with the first occurrence of * pattern replaced with either replacement or the value of the * block. The pattern will typically be a Regexp; if it is * a String then no regular expression metacharacters will be * interpreted (that is /\d/ will match a digit, but * '\d' will match a backslash followed by a 'd'). - * + * * If the method call specifies replacement, special variables such as * $& will not be useful, as substitution into the string occurs * before the pattern match starts. However, the sequences \1, * \2, etc., may be used. - * + * * In the block form, the current match string is passed in as a parameter, and * variables such as $1, $2, $`, * $&, and $' will be set appropriately. The value * returned by the block will be substituted for the match on each call. - * + * * The result inherits any tainting in the original string or any supplied * replacement string. - * + * * "hello".sub(/[aeiou]/, '*') #=> "h*llo" * "hello".sub(/([aeiou])/, '<\1>') #=> "hllo" * "hello".sub(/./) {|s| s[0].to_s + ' ' } #=> "104 ello" @@ -2267,7 +2267,7 @@ str_gsub(argc, argv, str, bang) * call-seq: * str.gsub!(pattern, replacement) => str or nil * str.gsub!(pattern) {|match| block } => str or nil - * + * * Performs the substitutions of String#gsub in place, returning * str, or nil if no substitutions were performed. */ @@ -2286,28 +2286,28 @@ rb_str_gsub_bang(argc, argv, str) * call-seq: * str.gsub(pattern, replacement) => new_str * str.gsub(pattern) {|match| block } => new_str - * + * * Returns a copy of str with all occurrences of pattern * replaced with either replacement or the value of the block. The * pattern will typically be a Regexp; if it is a * String then no regular expression metacharacters will be * interpreted (that is /\d/ will match a digit, but * '\d' will match a backslash followed by a 'd'). - * + * * If a string is used as the replacement, special variables from the match * (such as $& and $1) cannot be substituted into it, * as substitution into the string occurs before the pattern match * starts. However, the sequences \1, \2, and so on * may be used to interpolate successive groups in the match. - * + * * In the block form, the current match string is passed in as a parameter, and * variables such as $1, $2, $`, * $&, and $' will be set appropriately. The value * returned by the block will be substituted for the match on each call. - * + * * The result inherits any tainting in the original string or any supplied * replacement string. - * + * * "hello".gsub(/[aeiou]/, '*') #=> "h*ll*" * "hello".gsub(/([aeiou])/, '<\1>') #=> "hll" * "hello".gsub(/./) {|s| s[0].to_s + ' '} #=> "104 101 108 108 111 " @@ -2326,10 +2326,10 @@ rb_str_gsub(argc, argv, str) /* * call-seq: * str.replace(other_str) => str - * + * * Replaces the contents and taintedness of str with the corresponding * values in other_str. - * + * * s = "hello" #=> "hello" * s.replace "world" #=> "world" */ @@ -2389,7 +2389,7 @@ uscore_get() * call-seq: * sub!(pattern, replacement) => $_ or nil * sub!(pattern) {|...| block } => $_ or nil - * + * * Equivalent to $_.sub!(args). */ @@ -2405,7 +2405,7 @@ rb_f_sub_bang(argc, argv) * call-seq: * sub(pattern, replacement) => $_ * sub(pattern) { block } => $_ - * + * * Equivalent to $_.sub(args), except that * $_ will be updated if substitution occurs. */ @@ -2427,10 +2427,10 @@ rb_f_sub(argc, argv) * call-seq: * gsub!(pattern, replacement) => string or nil * gsub!(pattern) {|...| block } => string or nil - * + * * Equivalent to Kernel::gsub, except nil is * returned if $_ is not modified. - * + * * $_ = "quick brown fox" * gsub! /cat/, '*' #=> nil * $_ #=> "quick brown fox" @@ -2448,10 +2448,10 @@ rb_f_gsub_bang(argc, argv) * call-seq: * gsub(pattern, replacement) => string * gsub(pattern) {|...| block } => string - * + * * Equivalent to $_.gsub..., except that $_ * receives the modified result. - * + * * $_ = "quick brown fox" * gsub /[aeiou]/, '*' #=> "q**ck br*wn f*x" * $_ #=> "q**ck br*wn f*x" @@ -2474,7 +2474,7 @@ rb_f_gsub(argc, argv) /* * call-seq: * str.reverse! => str - * + * * Reverses str in place. */ @@ -2551,9 +2551,9 @@ rb_str_setbyte(str, index, value) /* * call-seq: * str.reverse => new_str - * + * * Returns a new string with the characters from str in reverse order. - * + * * "stressed".reverse #=> "desserts" */ @@ -2583,10 +2583,10 @@ rb_str_reverse(str) * call-seq: * str.include? other_str => true or false * str.include? fixnum => true or false - * + * * Returns true if str contains the given string or * character. - * + * * "hello".include? "lo" #=> true * "hello".include? "ol" #=> false * "hello".include? ?h #=> true @@ -2615,13 +2615,13 @@ rb_str_include(str, arg) /* * call-seq: * str.to_i(base=10) => integer - * + * * Returns the result of interpreting leading characters in str as an * integer base base (between 2 and 36). Extraneous characters past the * end of a valid number are ignored. If there is not a valid number at the * start of str, 0 is returned. This method never raises an * exception. - * + * * "12345".to_i #=> 12345 * "99 red balloons".to_i #=> 99 * "0a".to_i #=> 0 @@ -2656,12 +2656,12 @@ rb_str_to_i(argc, argv, str) /* * call-seq: * str.to_f => float - * + * * Returns the result of interpreting leading characters in str as a * floating point number. Extraneous characters past the end of a valid number * are ignored. If there is not a valid number at the start of str, * 0.0 is returned. This method never raises an exception. - * + * * "123.45e1".to_f #=> 1234.5 * "45.67 degrees".to_f #=> 45.67 * "thx1138".to_f #=> 0.0 @@ -2679,7 +2679,7 @@ rb_str_to_f(str) * call-seq: * str.to_s => str * str.to_str => str - * + * * Returns the receiver. */ @@ -2778,7 +2778,7 @@ rb_str_inspect(str) /* * call-seq: * str.dump => new_str - * + * * Produces a version of str with all nonprinting characters replaced by * \nnn notation and all special characters escaped. */ @@ -2886,7 +2886,7 @@ rb_str_dump(str) /* * call-seq: * str.upcase! => str or nil - * + * * Upcases the contents of str, returning nil if no changes * were made. */ @@ -2919,11 +2919,11 @@ rb_str_upcase_bang(str) /* * call-seq: * str.upcase => new_str - * + * * Returns a copy of str with all lowercase letters replaced with their * uppercase counterparts. The operation is locale insensitive---only * characters ``a'' to ``z'' are affected. - * + * * "hEllO".upcase #=> "HELLO" */ @@ -2940,7 +2940,7 @@ rb_str_upcase(str) /* * call-seq: * str.downcase! => str or nil - * + * * Downcases the contents of str, returning nil if no * changes were made. */ @@ -2973,11 +2973,11 @@ rb_str_downcase_bang(str) /* * call-seq: * str.downcase => new_str - * + * * Returns a copy of str with all uppercase letters replaced with their * lowercase counterparts. The operation is locale insensitive---only * characters ``A'' to ``Z'' are affected. - * + * * "hEllO".downcase #=> "hello" */ @@ -2994,10 +2994,10 @@ rb_str_downcase(str) /* * call-seq: * str.capitalize! => str or nil - * + * * Modifies str by converting the first character to uppercase and the * remainder to lowercase. Returns nil if no changes are made. - * + * * a = "hello" * a.capitalize! #=> "Hello" * a #=> "Hello" @@ -3035,10 +3035,10 @@ rb_str_capitalize_bang(str) /* * call-seq: * str.capitalize => new_str - * + * * Returns a copy of str with the first character converted to uppercase * and the remainder to lowercase. - * + * * "hello".capitalize #=> "Hello" * "HELLO".capitalize #=> "Hello" * "123ABC".capitalize #=> "123abc" @@ -3057,7 +3057,7 @@ rb_str_capitalize(str) /* * call-seq: * str.swapcase! => str or nil - * + * * Equivalent to String#swapcase, but modifies the receiver in * place, returning str, or nil if no changes were made. */ @@ -3094,10 +3094,10 @@ rb_str_swapcase_bang(str) /* * call-seq: * str.swapcase => new_str - * + * * Returns a copy of str with uppercase alphabetic characters converted * to lowercase and lowercase characters converted to uppercase. - * + * * "Hello".swapcase #=> "hELLO" * "cYbEr_PuNk11".swapcase #=> "CyBeR_pUnK11" */ @@ -3253,7 +3253,7 @@ tr_trans(str, src, repl, sflag) /* * call-seq: * str.tr!(from_str, to_str) => str or nil - * + * * Translates str in place, using the same rules as * String#tr. Returns str, or nil if no * changes were made. @@ -3270,14 +3270,14 @@ rb_str_tr_bang(str, src, repl) /* * call-seq: * str.tr(from_str, to_str) => new_str - * + * * Returns a copy of str with the characters in from_str replaced * by the corresponding characters in to_str. If to_str is * shorter than from_str, it is padded with its last character. Both * strings may use the c1--c2 notation to denote ranges of characters, and * from_str may start with a ^, which denotes all * characters except those listed. - * + * * "hello".tr('aeiou', '*') #=> "h*ll*" * "hello".tr('^aeiou', '*') #=> "*e**o" * "hello".tr('el', 'ip') #=> "hippo" @@ -3331,7 +3331,7 @@ tr_setup_table(str, table, init) /* * call-seq: * str.delete!([other_str]+>) => str or nil - * + * * Performs a delete operation in place, returning str, or * nil if str was not modified. */ @@ -3381,11 +3381,11 @@ rb_str_delete_bang(argc, argv, str) /* * call-seq: * str.delete([other_str]+) => new_str - * + * * Returns a copy of str with all characters in the intersection of its * arguments deleted. Uses the same rules for building the set of characters as * String#count. - * + * * "hello".delete "l","lo" #=> "heo" * "hello".delete "lo" #=> "he" * "hello".delete "aeiou", "^e" #=> "hell" @@ -3407,7 +3407,7 @@ rb_str_delete(argc, argv, str) /* * call-seq: * str.squeeze!([other_str]*) => str or nil - * + * * Squeezes str in place, returning either str, or * nil if no changes were made. */ @@ -3464,13 +3464,13 @@ rb_str_squeeze_bang(argc, argv, str) /* * call-seq: * str.squeeze([other_str]*) => new_str - * + * * Builds a set of characters from the other_str parameter(s) using the * procedure described for String#count. Returns a new string * where runs of the same character that occur in this set are replaced by a * single character. If no arguments are given, all runs of identical * characters are replaced by a single character. - * + * * "yellow moon".squeeze #=> "yelow mon" * " now is the".squeeze(" ") #=> " now is the" * "putters shoot balls".squeeze("m-z") #=> "puters shot balls" @@ -3491,7 +3491,7 @@ rb_str_squeeze(argc, argv, str) /* * call-seq: * str.tr_s!(from_str, to_str) => str or nil - * + * * Performs String#tr_s processing on str in place, * returning str, or nil if no changes were made. */ @@ -3507,11 +3507,11 @@ rb_str_tr_s_bang(str, src, repl) /* * call-seq: * str.tr_s(from_str, to_str) => new_str - * + * * Processes a copy of str as described under String#tr, * then removes duplicate characters in regions that were affected by the * translation. - * + * * "hello".tr_s('l', 'r') #=> "hero" * "hello".tr_s('el', '*') #=> "h*o" * "hello".tr_s('el', 'hx') #=> "hhxo" @@ -3530,12 +3530,12 @@ rb_str_tr_s(str, src, repl) /* * call-seq: * str.count([other_str]+) => fixnum - * + * * Each other_str parameter defines a set of characters to count. The * intersection of these sets defines the characters to count in * str. Any other_str that starts with a caret (^) is * negated. The sequence c1--c2 means all characters between c1 and c2. - * + * * a = "hello world" * a.count "lo" #=> 5 * a.count "lo", "o" #=> 2 @@ -3581,30 +3581,30 @@ rb_str_count(argc, argv, str) /* * call-seq: * str.split(pattern=$;, [limit]) => anArray - * + * * Divides str into substrings based on a delimiter, returning an array * of these substrings. - * + * * If pattern is a String, then its contents are used as * the delimiter when splitting str. If pattern is a single * space, str is split on whitespace, with leading whitespace and runs * of contiguous whitespace characters ignored. - * + * * If pattern is a Regexp, str is divided where the * pattern matches. Whenever the pattern matches a zero-length string, * str is split into individual characters. - * + * * If pattern is omitted, the value of $; is used. If * $; is nil (which is the default), str is * split on whitespace as if ` ' were specified. - * + * * If the limit parameter is omitted, trailing null fields are * suppressed. If limit is a positive number, at most that number of * fields will be returned (if limit is 1, the entire * string is returned as the only entry in an array). If negative, there is no * limit to the number of fields returned, and trailing null fields are not * suppressed. - * + * * " now's the time".split #=> ["now's", "the", "time"] * " now's the time".split(' ') #=> ["now's", "the", "time"] * " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"] @@ -3612,7 +3612,7 @@ rb_str_count(argc, argv, str) * "hello".split(//) #=> ["h", "e", "l", "l", "o"] * "hello".split(//, 3) #=> ["h", "e", "llo"] * "hi mom".split(%r{\s*}) #=> ["h", "i", "m", "o", "m"] - * + * * "mellow yellow".split("ello") #=> ["m", "w y", "w"] * "1,2,,3,4,,".split(',') #=> ["1", "2", "", "3", "4"] * "1,2,,3,4,,".split(',', 4) #=> ["1", "2", "", "3,4,,"] @@ -3768,7 +3768,7 @@ rb_str_split(str, sep0) /* * call-seq: * split([pattern [, limit]]) => array - * + * * Equivalent to $_.split(pattern, limit). * See String#split. */ @@ -3786,10 +3786,10 @@ rb_f_split(argc, argv) * call-seq: * str.lines(separator=$/) => anEnumerator * str.lines(separator=$/) {|substr| block } => str - * + * * Returns an enumerator that gives each line in the string. If a block is * given, it iterates over each line in the string. - * + * * "foo\nbar\n".lines.to_a #=> ["foo\n", "bar\n"] * "foo\nb ar".lines.sort #=> ["b ar", "foo\n"] */ @@ -3797,21 +3797,21 @@ rb_f_split(argc, argv) /* * call-seq: * str.each_line(separator=$/) {|substr| block } => str - * + * * Splits str using the supplied parameter as the record separator * ($/ by default), passing each substring in turn to the supplied * block. If a zero-length record separator is supplied, the string is split * into paragraphs delimited by multiple successive newlines. - * + * * print "Example one\n" * "hello\nworld".each {|s| p s} * print "Example two\n" * "hello\nworld".each('l') {|s| p s} * print "Example three\n" * "hello\n\n\nworld".each('') {|s| p s} - * + * * produces: - * + * * Example one * "hello\n" * "world" @@ -3885,7 +3885,7 @@ rb_str_each_line(argc, argv, str) * call-seq: * str.each(separator=$/) {|substr| block } => str * - * + * */ static VALUE rb_str_each(argc, argv, str) @@ -3903,23 +3903,23 @@ rb_str_each(argc, argv, str) * call-seq: * str.bytes => anEnumerator * str.bytes {|fixnum| block } => str - * + * * Returns an enumerator that gives each byte in the string. If a block is * given, it iterates over each byte in the string. - * + * * "hello".bytes.to_a #=> [104, 101, 108, 108, 111] */ /* * call-seq: * str.each_byte {|fixnum| block } => str - * + * * Passes each byte in str to the given block. - * + * * "hello".each_byte {|c| print c, ' ' } - * + * * produces: - * + * * 104 101 108 108 111 */ @@ -3942,10 +3942,10 @@ rb_str_each_byte(str) * call-seq: * str.chars => anEnumerator * str.chars {|substr| block } => str - * + * * Returns an enumerator that gives each character in the string. * If a block is given, it iterates over each character in the string. - * + * * "foo".chars.to_a #=> ["f","o","o"] */ @@ -3953,14 +3953,14 @@ rb_str_each_byte(str) * Document-method: each_char * call-seq: * str.each_char {|cstr| block } => str - * + * * Passes each character in str to the given block. - * + * * "hello".each_char {|c| print c, ' ' } - * + * * produces: - * - * h e l l o + * + * h e l l o */ static VALUE @@ -3985,7 +3985,7 @@ rb_str_each_char(str) /* * call-seq: * str.chop! => str or nil - * + * * Processes str as for String#chop, returning str, * or nil if str is the empty string. See also * String#chomp!. @@ -4014,13 +4014,13 @@ rb_str_chop_bang(str) /* * call-seq: * str.chop => new_str - * + * * Returns a new String with the last character removed. If the * string ends with \r\n, both characters are removed. Applying * chop to an empty string returns an empty * string. String#chomp is often a safer alternative, as it leaves * the string unchanged if it doesn't end in a record separator. - * + * * "string\r\n".chop #=> "string" * "string\n\r".chop #=> "string\n" * "string\n".chop #=> "string" @@ -4041,9 +4041,9 @@ rb_str_chop(str) /* * call-seq: * chop! => $_ or nil - * + * * Equivalent to $_.chop!. - * + * * a = "now\r\n" * $_ = a * chop! #=> "now" @@ -4065,10 +4065,10 @@ rb_f_chop_bang(str) /* * call-seq: * chop => string - * + * * Equivalent to ($_.dup).chop!, except nil * is never returned. See String#chop!. - * + * * a = "now\r\n" * $_ = a * chop #=> "now" @@ -4097,7 +4097,7 @@ rb_f_chop() /* * call-seq: * str.chomp!(separator=$/) => str or nil - * + * * Modifies str in place as described for String#chomp, * returning str, or nil if no modifications were made. */ @@ -4178,13 +4178,13 @@ rb_str_chomp_bang(argc, argv, str) /* * call-seq: * str.chomp(separator=$/) => new_str - * + * * Returns a new String with the given record separator removed * from the end of str (if present). If $/ has not been * changed from the default Ruby record separator, then chomp also * removes carriage return characters (that is it will remove \n, * \r, and \r\n). - * + * * "hello".chomp #=> "hello" * "hello\n".chomp #=> "hello" * "hello\r\n".chomp #=> "hello" @@ -4209,10 +4209,10 @@ rb_str_chomp(argc, argv, str) * call-seq: * chomp! => $_ or nil * chomp!(string) => $_ or nil - * + * * Equivalent to $_.chomp!(string). See * String#chomp! - * + * * $_ = "now\n" * chomp! #=> "now" * $_ #=> "now" @@ -4232,10 +4232,10 @@ rb_f_chomp_bang(argc, argv) * call-seq: * chomp => $_ * chomp(string) => $_ - * + * * Equivalent to $_ = $_.chomp(string). See * String#chomp. - * + * * $_ = "now\n" * chomp #=> "now" * $_ #=> "now" @@ -4263,11 +4263,11 @@ rb_f_chomp(argc, argv) /* * call-seq: * str.lstrip! => self or nil - * + * * Removes leading whitespace from str, returning nil if no * change was made. See also String#rstrip! and * String#strip!. - * + * * " hello ".lstrip #=> "hello " * "hello".lstrip! #=> nil */ @@ -4298,10 +4298,10 @@ rb_str_lstrip_bang(str) /* * call-seq: * str.lstrip => new_str - * + * * Returns a copy of str with leading whitespace removed. See also * String#rstrip and String#strip. - * + * * " hello ".lstrip #=> "hello " * "hello".lstrip #=> "hello" */ @@ -4319,11 +4319,11 @@ rb_str_lstrip(str) /* * call-seq: * str.rstrip! => self or nil - * + * * Removes trailing whitespace from str, returning nil if * no change was made. See also String#lstrip! and * String#strip!. - * + * * " hello ".rstrip #=> " hello" * "hello".rstrip! #=> nil */ @@ -4357,10 +4357,10 @@ rb_str_rstrip_bang(str) /* * call-seq: * str.rstrip => new_str - * + * * Returns a copy of str with trailing whitespace removed. See also * String#lstrip and String#strip. - * + * * " hello ".rstrip #=> " hello" * "hello".rstrip #=> "hello" */ @@ -4378,7 +4378,7 @@ rb_str_rstrip(str) /* * call-seq: * str.strip! => str or nil - * + * * Removes leading and trailing whitespace from str. Returns * nil if str was not altered. */ @@ -4398,9 +4398,9 @@ rb_str_strip_bang(str) /* * call-seq: * str.strip => new_str - * + * * Returns a copy of str with leading and trailing whitespace removed. - * + * * " hello ".strip #=> "hello" * "\tgoodbye\r\n".strip #=> "goodbye" */ @@ -4456,29 +4456,29 @@ scan_once(str, pat, start) * call-seq: * str.scan(pattern) => array * str.scan(pattern) {|match, ...| block } => str - * + * * Both forms iterate through str, matching the pattern (which may be a * Regexp or a String). For each match, a result is * generated and either added to the result array or passed to the block. If * the pattern contains no groups, each individual result consists of the * matched string, $&. If the pattern contains groups, each * individual result is itself an array containing one entry per group. - * + * * a = "cruel world" * a.scan(/\w+/) #=> ["cruel", "world"] * a.scan(/.../) #=> ["cru", "el ", "wor"] * a.scan(/(...)/) #=> [["cru"], ["el "], ["wor"]] * a.scan(/(..)(..)/) #=> [["cr", "ue"], ["l ", "wo"]] - * + * * And the block form: - * + * * a.scan(/\w+/) {|w| print "<<#{w}>> " } * print "\n" * a.scan(/(.)(.)/) {|x,y| print y, x } * print "\n" - * + * * produces: - * + * * <> <> * rceu lowlr */ @@ -4519,7 +4519,7 @@ rb_str_scan(str, pat) * call-seq: * scan(pattern) => array * scan(pattern) {|///| block } => $_ - * + * * Equivalent to calling $_.scan. See * String#scan. */ @@ -4535,11 +4535,11 @@ rb_f_scan(self, pat) /* * call-seq: * str.hex => integer - * + * * Treats leading characters from str as a string of hexadecimal digits * (with an optional sign and an optional 0x) and returns the * corresponding number. Zero is returned on error. - * + * * "0x0a".hex #=> 10 * "-1234".hex #=> -4660 * "0".hex #=> 0 @@ -4557,11 +4557,11 @@ rb_str_hex(str) /* * call-seq: * str.oct => integer - * + * * Treats leading characters of str as a string of octal digits (with an * optional sign) and returns the corresponding number. Returns 0 if the * conversion fails. - * + * * "123".oct #=> 83 * "-377".oct #=> -255 * "bad".oct #=> 0 @@ -4579,7 +4579,7 @@ rb_str_oct(str) /* * call-seq: * str.crypt(other_str) => new_str - * + * * Applies a one-way cryptographic hash to str by invoking the standard * library function crypt. The argument is the salt string, which * should be two characters long, each character drawn from @@ -4611,10 +4611,10 @@ rb_str_crypt(str, salt) * call-seq: * str.intern => symbol * str.to_sym => symbol - * + * * Returns the Symbol corresponding to str, creating the * symbol if it did not previously exist. See Symbol#id2name. - * + * * "Koala".intern #=> :Koala * s = 'cat'.to_sym #=> :cat * s == :cat #=> true @@ -4623,7 +4623,7 @@ rb_str_crypt(str, salt) * * This can also be used to create symbols that cannot be represented using the * :xxx notation. - * + * * 'cat and dog'.to_sym #=> :"cat and dog" */ @@ -4650,7 +4650,7 @@ rb_str_intern(s) /* * call-seq: * str.sum(n=16) => integer - * + * * Returns a basic n-bit checksum of the characters in str, * where n is the optional Fixnum parameter, defaulting * to 16. The result is simply the sum of the binary value of each character in @@ -4783,11 +4783,11 @@ rb_str_justify(argc, argv, str, jflag) /* * call-seq: * str.ljust(integer, padstr=' ') => new_str - * + * * If integer is greater than the length of str, returns a new * String of length integer with str left justified * and padded with padstr; otherwise, returns str. - * + * * "hello".ljust(4) #=> "hello" * "hello".ljust(20) #=> "hello " * "hello".ljust(20, '1234') #=> "hello123412341234123" @@ -4806,11 +4806,11 @@ rb_str_ljust(argc, argv, str) /* * call-seq: * str.rjust(integer, padstr=' ') => new_str - * + * * If integer is greater than the length of str, returns a new * String of length integer with str right justified * and padded with padstr; otherwise, returns str. - * + * * "hello".rjust(4) #=> "hello" * "hello".rjust(20) #=> " hello" * "hello".rjust(20, '1234') #=> "123412341234123hello" @@ -4829,11 +4829,11 @@ rb_str_rjust(argc, argv, str) /* * call-seq: * str.center(integer, padstr) => new_str - * + * * If integer is greater than the length of str, returns a new * String of length integer with str centered and * padded with padstr; otherwise, returns str. - * + * * "hello".center(4) #=> "hello" * "hello".center(20) #=> " hello " * "hello".center(20, '123') #=> "1231231hello12312312" @@ -4851,12 +4851,12 @@ rb_str_center(argc, argv, str) /* * call-seq: * str.partition(sep) => [head, sep, tail] - * + * * Searches the string for sep and returns the part before it, * the sep, and the part after it. If sep is not * found, returns str and two empty strings. If no argument * is given, Enumerable#partition is called. - * + * * "hello".partition("l") #=> ["he", "l", "lo"] * "hello".partition("x") #=> ["hello", "", ""] */ @@ -4898,12 +4898,12 @@ rb_str_partition(argc, argv, str) /* * call-seq: * str.rpartition(sep) => [head, sep, tail] - * + * * Searches sep in the string from the end of the string, and * returns the part before it, the sep, and the part after it. * If sep is not found, returns two empty strings and * str. - * + * * "hello".rpartition("l") #=> ["hel", "l", "o"] * "hello".rpartition("x") #=> ["", "", "hello"] */ @@ -4939,7 +4939,7 @@ rb_str_rpartition(str, sep) /* * call-seq: * str.start_with?([prefix]+) => true or false - * + * * Returns true if str starts with the prefix given. */ @@ -4966,7 +4966,7 @@ rb_str_start_with(argc, argv, str) /* * call-seq: * str.end_with?([suffix]+) => true or false - * + * * Returns true if str ends with the suffix given. */ @@ -5009,13 +5009,13 @@ rb_str_setter(val, id, var) * A String object holds and manipulates an arbitrary sequence of * bytes, typically representing characters. String objects may be created * using String::new or as literals. - * + * * Because of aliasing issues, users of strings should be aware of the methods * that modify the contents of a String object. Typically, * methods with names ending in ``!'' modify their receiver, while those * without a ``!'' return a new String. However, there are * exceptions, such as String#[]=. - * + * */ void diff --git a/struct.c b/struct.c index 72a2d33e43..f5e90fc3fc 100644 --- a/struct.c +++ b/struct.c @@ -83,10 +83,10 @@ rb_struct_s_members_m(klass) /* * call-seq: * struct.members => array - * + * * Returns an array of strings representing the names of the instance * variables. - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) * joe.members #=> ["name", "address", "zip"] @@ -277,7 +277,7 @@ rb_struct_define(name, va_alist) * Structs in the system and should start with a capital * letter. Assigning a structure class to a constant effectively gives * the class the name of the constant. - * + * * Struct::new returns a new Class object, * which can then be used to create specific instances of the new * structure. The number of actual parameters must be @@ -286,12 +286,12 @@ rb_struct_define(name, va_alist) * parameters will raise an \E{ArgumentError}. * * The remaining methods listed in this section (class and instance) - * are defined for this generated class. - * + * are defined for this generated class. + * * # Create a structure with a name in Struct * Struct.new("Customer", :name, :address) #=> Struct::Customer * Struct::Customer.new("Dave", "123 Main") #=> # - * + * * # Create a structure named by its constant * Customer = Struct.new(:name, :address) #=> Customer * Customer.new("Dave", "123 Main") #=> # @@ -413,16 +413,16 @@ rb_struct_new(klass, va_alist) /* * call-seq: * struct.each {|obj| block } => struct - * + * * Calls block once for each instance variable, passing the * value as a parameter. - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) * joe.each {|x| puts(x) } - * + * * produces: - * + * * Joe Smith * 123 Maple, Anytown NC * 12345 @@ -444,16 +444,16 @@ rb_struct_each(s) /* * call-seq: * struct.each_pair {|sym, obj| block } => struct - * + * * Calls block once for each instance variable, passing the name * (as a symbol) and the value as parameters. - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) * joe.each_pair {|name, value| puts("#{name} => #{value}") } - * + * * produces: - * + * * name => Joe Smith * address => 123 Maple, Anytown NC * zip => 12345 @@ -540,9 +540,9 @@ rb_struct_inspect(s) * call-seq: * struct.to_a => array * struct.values => array - * + * * Returns the values for this instance as an array. - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) * joe.to_a[1] #=> "123 Maple, Anytown NC" @@ -595,17 +595,17 @@ rb_struct_aref_id(s, id) /* * call-seq: * struct[symbol] => anObject - * struct[fixnum] => anObject - * + * struct[fixnum] => anObject + * * Attribute Reference---Returns the value of the instance variable * named by symbol, or indexed (0..length-1) by * fixnum. Will raise NameError if the named * variable does not exist, or IndexError if the index is * out of range. - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - * + * * joe["name"] #=> "Joe Smith" * joe[:name] #=> "Joe Smith" * joe[0] #=> "Joe Smith" @@ -660,19 +660,19 @@ rb_struct_aset_id(s, id, val) * call-seq: * struct[symbol] = obj => obj * struct[fixnum] = obj => obj - * + * * Attribute Assignment---Assigns to the instance variable named by * symbol or fixnum the value obj and * returns it. Will raise a NameError if the named * variable does not exist, or an IndexError if the index * is out of range. - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - * + * * joe["name"] = "Luke" * joe[:zip] = "90210" - * + * * joe.name #=> "Luke" * joe.zip #=> "90210" */ @@ -710,15 +710,15 @@ struct_entry(s, n) return rb_struct_aref(s, LONG2NUM(n)); } -/* +/* * call-seq: * struct.values_at(selector,... ) => an_array * * Returns an array containing the elements in * _self_ corresponding to the given selector(s). The selectors - * may be either integer indices or ranges. + * may be either integer indices or ranges. * See also .select. - * + * * a = %w{ a b c d e f } * a.values_at(1, 3, 5) * a.values_at(1, 3, 5, 7) @@ -738,12 +738,12 @@ rb_struct_values_at(argc, argv, s) /* * call-seq: * struct.select {|i| block } => array - * + * * Invokes the block passing in successive elements from * struct, returning an array containing those elements * for which the block returns a true value (equivalent to * Enumerable#select). - * + * * Lots = Struct.new(:a, :b, :c, :d, :e, :f) * l = Lots.new(11, 22, 33, 44, 55, 66) * l.select {|v| (v % 2).zero? } #=> [22, 44, 66] @@ -774,12 +774,12 @@ rb_struct_select(argc, argv, s) /* * call-seq: * struct == other_struct => true or false - * + * * Equality---Returns true if other_struct is * equal to this one: they must be of the same class as generated by * Struct::new, and the values of all instance variables * must be equal (according to Object#==). - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) * joejr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) @@ -861,9 +861,9 @@ rb_struct_eql(s, s2) * call-seq: * struct.length => fixnum * struct.size => fixnum - * + * * Returns the number of instance variables. - * + * * Customer = Struct.new(:name, :address, :zip) * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) * joe.length #=> 3 @@ -880,13 +880,13 @@ rb_struct_size(s) * A Struct is a convenient way to bundle a number of * attributes together, using accessor methods, without having to write * an explicit class. - * + * * The Struct class is a generator of specific classes, * each one of which is defined to hold a set of variables and their * accessors. In these examples, we'll call the generated class * ``CustomerClass,'' and we'll show an example instance of that * class as ``CustomerInst.'' - * + * * In the descriptions that follow, the parameter symbol refers * to a symbol, which is either a quoted string or a * Symbol (such as :name). diff --git a/time.c b/time.c index 3d1f3723d4..df43e2339a 100644 --- a/time.c +++ b/time.c @@ -92,18 +92,18 @@ time_modify(time) * * call-seq: * Time.new -> time - * + * * Returns a Time object initialized to the current system * time. Note: The object created will be created using the * resolution available on your system clock, and so may include * fractional seconds. - * + * * a = Time.new #=> Wed Apr 09 08:56:03 CDT 2003 * b = Time.new #=> Wed Apr 09 08:56:03 CDT 2003 * a == b #=> false * "%.6f" % a.to_f #=> "1049896563.230740" * "%.6f" % b.to_f #=> "1049896563.231466" - * + * */ static VALUE @@ -263,12 +263,12 @@ rb_time_timeval(time) * call-seq: * Time.at( aTime ) => time * Time.at( seconds [, microseconds] ) => time - * + * * Creates a new time object with the value given by aTime, or * the given number of seconds (and optional * microseconds) from epoch. A non-portable feature allows the * offset to be negative on some systems. - * + * * Time.at(0) #=> Wed Dec 31 18:00:00 CST 1969 * Time.at(946702800) #=> Fri Dec 31 23:00:00 CST 1999 * Time.at(-284061600) #=> Sat Dec 31 00:00:00 CST 1960 @@ -592,7 +592,7 @@ search_time_t(tptr, utc_p) To avoid overflow in this assignment, `d' is restricted to less than sqrt(2**31). By this restriction and other reasons, the guess is - not accurate and some error is expected. `range' approximates + not accurate and some error is expected. `range' approximates the maximum error. When these parameters are not suitable, i.e. guess is not within @@ -651,7 +651,7 @@ search_time_t(tptr, utc_p) } if (guess <= guess_lo || guess_hi <= guess) { - /* Precious guess is invalid. try binary search. */ + /* Precious guess is invalid. try binary search. */ guess = guess_lo / 2 + guess_hi / 2; if (guess <= guess_lo) guess = guess_lo + 1; @@ -837,7 +837,7 @@ time_utc_or_local(argc, argv, utc_p, klass) * Time.gm( year [, month, day, hour, min, sec, usec] ) => time * Time.gm( sec, min, hour, day, month, year, wday, yday, isdst, tz * ) => time - * + * * Creates a time based on given values, interpreted as UTC (GMT). The * year must be specified. Other values default to the minimum value * for that field (and may be nil or omitted). Months may @@ -865,10 +865,10 @@ time_s_mkutc(argc, argv, klass) * Time.local( sec, min, hour, day, month, year, wday, yday, isdst, * tz ) => time * Time.mktime( year, month, day, hour, min, sec, usec ) => time - * + * * Same as Time::gm, but interprets the values in the * local time zone. - * + * * Time.local(2000,"jan",1,20,15,1) #=> Sat Jan 01 20:15:01 CST 2000 */ @@ -885,10 +885,10 @@ time_s_mktime(argc, argv, klass) * call-seq: * time.to_i => int * time.tv_sec => int - * + * * Returns the value of time as an integer number of seconds * since epoch. - * + * * t = Time.now * "%10.5f" % t.to_f #=> "1049896564.17839" * t.to_i #=> 1049896564 @@ -907,10 +907,10 @@ time_to_i(time) /* * call-seq: * time.to_f => float - * + * * Returns the value of time as a floating point number of * seconds since epoch. - * + * * t = Time.now * "%10.5f" % t.to_f #=> "1049896564.13654" * t.to_i #=> 1049896564 @@ -930,9 +930,9 @@ time_to_f(time) * call-seq: * time.usec => int * time.tv_usec => int - * + * * Returns just the number of microseconds for time. - * + * * t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003 * "%10.6f" % t.to_f #=> "1049896564.259970" * t.usec #=> 259970 @@ -950,13 +950,13 @@ time_usec(time) /* * call-seq: - * time <=> other_time => -1, 0, +1 + * time <=> other_time => -1, 0, +1 * time <=> numeric => -1, 0, +1 - * + * * Comparison---Compares time with other_time or with * numeric, which is the number of seconds (possibly * fractional) since epoch. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t2 = t + 2592000 #=> Fri May 09 08:56:03 CDT 2003 * t <=> t2 #=> -1 @@ -1014,10 +1014,10 @@ time_eql(time1, time2) * call-seq: * time.utc? => true or false * time.gmt? => true or false - * + * * Returns true if time represents a time in UTC * (GMT). - * + * * t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003 * t.utc? #=> false * t = Time.gm(2000,"jan",1,20,15,1) #=> Sat Jan 01 20:15:01 UTC 2000 @@ -1090,10 +1090,10 @@ time_dup(time) /* * call-seq: * time.localtime => time - * + * * Converts time to local time (using the local time zone in * effect for this process) modifying the receiver. - * + * * t = Time.gm(2000, "jan", 1, 20, 15, 1) * t.gmt? #=> true * t.localtime #=> Sat Jan 01 14:15:01 CST 2000 @@ -1130,9 +1130,9 @@ time_localtime(time) * call-seq: * time.gmtime => time * time.utc => time - * + * * Converts time to UTC (GMT), modifying the receiver. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t.gmt? #=> false * t.gmtime #=> Wed Apr 09 13:56:03 UTC 2003 @@ -1173,10 +1173,10 @@ time_gmtime(time) /* * call-seq: * time.getlocal => new_time - * + * * Returns a new new_time object representing time in * local time (using the local time zone in effect for this process). - * + * * t = Time.gm(2000,1,1,20,15,1) #=> Sat Jan 01 20:15:01 UTC 2000 * t.gmt? #=> true * l = t.getlocal #=> Sat Jan 01 14:15:01 CST 2000 @@ -1195,10 +1195,10 @@ time_getlocaltime(time) * call-seq: * time.getgm => new_time * time.getutc => new_time - * + * * Returns a new new_time object representing time in * UTC. - * + * * t = Time.local(2000,1,1,20,15,1) #=> Sat Jan 01 20:15:01 CST 2000 * t.gmt? #=> false * y = t.getgm #=> Sun Jan 02 02:15:01 UTC 2000 @@ -1226,9 +1226,9 @@ time_get_tm(time, gmt) * call-seq: * time.asctime => string * time.ctime => string - * + * * Returns a canonical string representation of time. - * + * * Time.now.asctime #=> "Wed Apr 9 08:56:03 2003" */ @@ -1253,12 +1253,12 @@ time_asctime(time) * call-seq: * time.inspect => string * time.to_s => string - * + * * Returns a string representing time. Equivalent to calling * Time#strftime with a format string of ``%a * %b %d %H:%M:%S * %Z %Y''. - * + * * Time.now.to_s #=> "Wed Apr 09 08:56:04 CDT 2003" */ @@ -1344,10 +1344,10 @@ time_add(tobj, offset, sign) /* * call-seq: * time + numeric => time - * + * * Addition---Adds some number of seconds (possibly fractional) to * time and returns that value as a new time. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t + (60 * 60 * 24) #=> Thu Apr 10 08:56:03 CDT 2003 */ @@ -1369,11 +1369,11 @@ time_plus(time1, time2) * call-seq: * time - other_time => float * time - numeric => time - * + * * Difference---Returns a new time that represents the difference * between two times, or subtracts the given number of seconds in * numeric from time. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t2 = t + 2592000 #=> Fri May 09 08:56:03 CDT 2003 * t2 - t #=> 2592000.0 @@ -1426,12 +1426,12 @@ time_succ(time) /* * call-seq: * time.sec => fixnum - * + * * Returns the second of the minute (0..60)[Yes, seconds really can * range from zero to 60. This allows the system to inject leap seconds * every now and then to correct for the fact that years are not really * a convenient number of hours long.] for time. - * + * * t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003 * t.sec #=> 4 */ @@ -1452,9 +1452,9 @@ time_sec(time) /* * call-seq: * time.min => fixnum - * + * * Returns the minute of the hour (0..59) for time. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t.min #=> 56 */ @@ -1475,9 +1475,9 @@ time_min(time) /* * call-seq: * time.hour => fixnum - * + * * Returns the hour of the day (0..23) for time. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t.hour #=> 8 */ @@ -1499,9 +1499,9 @@ time_hour(time) * call-seq: * time.day => fixnum * time.mday => fixnum - * + * * Returns the day of the month (1..n) for time. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t.day #=> 9 * t.mday #=> 9 @@ -1524,9 +1524,9 @@ time_mday(time) * call-seq: * time.mon => fixnum * time.month => fixnum - * + * * Returns the month of the year (1..12) for time. - * + * * t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003 * t.mon #=> 4 * t.month #=> 4 @@ -1548,9 +1548,9 @@ time_mon(time) /* * call-seq: * time.year => fixnum - * + * * Returns the year for time (including the century). - * + * * t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003 * t.year #=> 2003 */ @@ -1571,10 +1571,10 @@ time_year(time) /* * call-seq: * time.wday => fixnum - * + * * Returns an integer representing the day of the week, 0..6, with * Sunday == 0. - * + * * t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003 * t.wday #=> 3 */ @@ -1595,9 +1595,9 @@ time_wday(time) /* * call-seq: * time.yday => fixnum - * + * * Returns an integer representing the day of the year, 1..366. - * + * * t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003 * t.yday #=> 99 */ @@ -1619,10 +1619,10 @@ time_yday(time) * call-seq: * time.isdst => true or false * time.dst? => true or false - * + * * Returns true if time occurs during Daylight * Saving Time in its time zone. - * + * * Time.local(2000, 7, 1).isdst #=> true * Time.local(2000, 1, 1).isdst #=> false * Time.local(2000, 7, 1).dst? #=> true @@ -1645,10 +1645,10 @@ time_isdst(time) /* * call-seq: * time.zone => string - * + * * Returns the name of the time zone used for time. As of Ruby * 1.8, returns ``UTC'' rather than ``GMT'' for UTC times. - * + * * t = Time.gm(2000, "jan", 1, 20, 15, 1) * t.zone #=> "UTC" * t = Time.local(2000, "jan", 1, 20, 15, 1) @@ -1664,7 +1664,7 @@ time_zone(time) char buf[64]; int len; #endif - + GetTimeval(time, tobj); if (tobj->tm_got == 0) { time_get_tm(time, tobj->gmt); @@ -1688,10 +1688,10 @@ time_zone(time) * time.gmt_offset => fixnum * time.gmtoff => fixnum * time.utc_offset => fixnum - * + * * Returns the offset in seconds between the timezone of time * and UTC. - * + * * t = Time.gm(2000,1,1,20,15,1) #=> Sat Jan 01 20:15:01 UTC 2000 * t.gmt_offset #=> 0 * l = t.getlocal #=> Sat Jan 01 14:15:01 CST 2000 @@ -1743,14 +1743,14 @@ time_utc_offset(time) /* * call-seq: * time.to_a => array - * + * * Returns a ten-element array of values for time: * {[ sec, min, hour, day, month, year, wday, yday, isdst, zone * ]}. See the individual methods for an explanation of the * valid ranges of each value. The ten elements can be passed directly * to Time::utc or Time::local to create a * new Time. - * + * * now = Time.now #=> Wed Apr 09 08:56:04 CDT 2003 * t = now.to_a #=> [4, 56, 8, 9, 4, 2003, 3, 99, true, "CDT"] */ @@ -1815,7 +1815,7 @@ rb_strftime(buf, format, time) /* * call-seq: * time.strftime( string ) => string - * + * * Formats time according to the directives in the given format * string. Any text not listed as a directive will be passed through * to the output string. @@ -1847,7 +1847,7 @@ rb_strftime(buf, format, time) * %Y - Year with century * %Z - Time zone name * %% - Literal ``%'' character - * + * * t = Time.now * t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003" * t.strftime("at %I:%M%p") #=> "at 08:56AM" @@ -1903,7 +1903,7 @@ time_strftime(time, format) /* * call-seq: * Time.times => struct_tms - * + * * Deprecated in favor of Process::times */ @@ -1976,7 +1976,7 @@ time_dump(argc, argv, time) VALUE str; rb_scan_args(argc, argv, "01", 0); - str = time_mdump(time); + str = time_mdump(time); if (FL_TEST(time, FL_EXIVAR)) { rb_copy_generic_ivar(str, time); FL_SET(str, FL_EXIVAR); @@ -2077,7 +2077,7 @@ time_load(klass, str) * as equivalent. GMT is the older way of referring to these * baseline times but persists in the names of calls on Posix * systems. - * + * * All times are stored with some number of microseconds. Be aware of * this fact when comparing times with each other---times that are * apparently equal when displayed may be different when compared. diff --git a/util.c b/util.c index 961aaba4c7..0f72e31557 100644 --- a/util.c +++ b/util.c @@ -106,11 +106,11 @@ scan_hex(start, len, retlen) * Style 1: The suffix begins with a '.'. The extension is replaced. * If the name matches the original name, use the fallback method. * - * Style 2: The suffix is a single character, not a '.'. Try to add the + * Style 2: The suffix is a single character, not a '.'. Try to add the * suffix to the following places, using the first one that works. - * [1] Append to extension. - * [2] Append to filename, - * [3] Replace end of extension, + * [1] Append to extension. + * [2] Append to filename, + * [3] Replace end of extension, * [4] Replace end of filename. * If the name matches the original name, use the fallback method. * @@ -146,7 +146,7 @@ scan_hex(start, len, retlen) * longname.fil => longname.fi~ * longname.fi~ => longnam~.fi~ * longnam~.fi~ => longnam~.$$$ - * + * */ @@ -206,7 +206,7 @@ ruby_add_suffix(str, suffix) strcpy(p, suffix); } else if (suffix[1] == '\0') { /* Style 2 */ - if (extlen < 4) { + if (extlen < 4) { ext[extlen] = *suffix; ext[++extlen] = '\0'; } @@ -237,7 +237,7 @@ extern int _close(int); extern int _unlink(const char *); #endif -static int +static int valid_filename(char *s) { int fd; diff --git a/variable.c b/variable.c index f037000c59..d39335e7e1 100644 --- a/variable.c +++ b/variable.c @@ -171,7 +171,7 @@ classname(klass) /* * call-seq: * mod.name => string - * + * * Returns the name of the module mod. */ @@ -556,7 +556,7 @@ rb_trace_eval(cmd, val) * call-seq: * trace_var(symbol, cmd ) => nil * trace_var(symbol) {|val| block } => nil - * + * * Controls tracing of assignments to global variables. The parameter * +symbol_ identifies the variable (as either a string name or a * symbol identifier). _cmd_ (which may be a string or a @@ -564,13 +564,13 @@ rb_trace_eval(cmd, val) * is assigned. The block or +Proc+ object receives the * variable's new value as a parameter. Also see * Kernel::untrace_var. - * + * * trace_var :$_, proc {|v| puts "$_ is now '#{v}'" } * $_ = "hello" * $_ = ' there' - * + * * produces: - * + * * $_ is now 'hello' * $_ is now ' there' */ @@ -631,7 +631,7 @@ remove_trace(var) /* * call-seq: * untrace_var(symbol [, cmd] ) => array or nil - * + * * Removes tracing for the specified command on the given global * variable and returns +nil+. If no command is specified, * removes all tracing for that variable and returns an array @@ -781,9 +781,9 @@ gvar_i(key, entry, ary) /* * call-seq: * global_variables => array - * + * * Returns an array of the names of global variables. - * + * * global_variables.grep /std/ #=> ["$stderr", "$stdout", "$stdin"] */ @@ -1118,11 +1118,11 @@ ivar_i(key, entry, ary) /* * call-seq: * obj.instance_variables => array - * + * * Returns an array of instance variable names for the receiver. Note * that simply defining an accessor does not create the corresponding * instance variable. - * + * * class Fred * attr_accessor :a1 * def initialize @@ -1164,10 +1164,10 @@ rb_obj_instance_variables(obj) /* * call-seq: * obj.remove_instance_variable(symbol) => obj - * + * * Removes the named instance variable from obj, returning that * variable's value. - * + * * class Dummy * attr_reader :var * def initialize @@ -1255,7 +1255,7 @@ const_missing(klass, id) * assumed to be in file fred.rb). If found, it returns the * value of the loaded class. It therefore implements a perverse * kind of autoload facility. - * + * * def Object.const_missing(name) * @looked_for ||= {} * str_name = name.to_s @@ -1267,7 +1267,7 @@ const_missing(klass, id) * return klass if klass * raise "Class not found: #{name}" * end - * + * */ VALUE @@ -1468,7 +1468,7 @@ rb_const_get_at(klass, id) /* * call-seq: * remove_const(sym) => obj - * + * * Removes the definition of the given constant, returning that * constant's value. Predefined classes and singleton objects (such as * true) cannot be removed. @@ -1577,7 +1577,7 @@ rb_const_list(data) /* * call-seq: * mod.constants => array - * + * * Returns an array of the names of the constants accessible in * mod. This includes the names of constants in any included * modules (example at start of section). @@ -1876,10 +1876,10 @@ cv_i(key, value, ary) /* * call-seq: * mod.class_variables => array - * + * * Returns an array of the names of class variables in mod and * the ancestors of mod. - * + * * class One * @@var1 = 1 * end @@ -1909,19 +1909,19 @@ rb_mod_class_variables(obj) /* * call-seq: * remove_class_variable(sym) => obj - * + * * Removes the definition of the sym, returning that * constant's value. - * + * * class Dummy * @@var = 99 * puts @@var * remove_class_variable(:@@var) * puts(defined? @@var) * end - * + * * produces: - * + * * 99 * nil */ diff --git a/version.c b/version.c index a02efdc265..a8f99a8c65 100644 --- a/version.c +++ b/version.c @@ -60,7 +60,7 @@ Init_version() RUBY_BIRTH_YEAR, RUBY_RELEASE_YEAR, RUBY_AUTHOR); #endif - + rb_define_global_const("RUBY_VERSION", v); rb_define_global_const("RUBY_RELEASE_DATE", d); rb_define_global_const("RUBY_PLATFORM", p); diff --git a/version.h b/version.h index 9e0d7a0bc7..44b93fd90f 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.8" -#define RUBY_RELEASE_DATE "2009-10-21" +#define RUBY_RELEASE_DATE "2009-10-22" #define RUBY_VERSION_CODE 188 -#define RUBY_RELEASE_CODE 20091021 +#define RUBY_RELEASE_CODE 20091022 #define RUBY_PATCHLEVEL -1 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 8 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; diff --git a/win32/win32.c b/win32/win32.c index 2e9b98da4d..94147a5acf 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1192,7 +1192,7 @@ cmdglob(NtCmdLineElement *patt, NtCmdLineElement **tail) return tail; } -// +// // Check a command string to determine if it has I/O redirection // characters that require it to be executed by a command interpreter // @@ -1246,7 +1246,7 @@ skipspace(char *ptr) return ptr; } -int +int rb_w32_cmdvector(const char *cmd, char ***vec) { int globbing, len; @@ -1274,9 +1274,9 @@ rb_w32_cmdvector(const char *cmd, char ***vec) // // Ok, parse the command line, building a list of CmdLineElements. // When we've finished, and it's an input command (meaning that it's - // the processes argv), we'll do globing and then build the argument + // the processes argv), we'll do globing and then build the argument // vector. - // The outer loop does one interation for each element seen. + // The outer loop does one interation for each element seen. // The inner loop does one interation for each character in the element. // @@ -1313,7 +1313,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec) case '?': case '[': case '{': - // + // // record the fact that this element has a wildcard character // N.B. Don't glob if inside a single quoted string // @@ -1327,7 +1327,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec) case '\"': // // if we're already in a string, see if this is the - // terminating close-quote. If it is, we're finished with + // terminating close-quote. If it is, we're finished with // the string, but not neccessarily with the element. // If we're not already in a string, start one. // @@ -1363,7 +1363,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec) if (done) --len; // - // if it's an input vector element and it's enclosed by quotes, + // if it's an input vector element and it's enclosed by quotes, // we can remove them. // @@ -1425,10 +1425,10 @@ rb_w32_cmdvector(const char *cmd, char ***vec) } // - // Almost done! + // Almost done! // Count up the elements, then allocate space for a vector of pointers // (argv) and a string table for the elements. - // + // for (elements = 0, strsz = 0, curr = cmdhead; curr; curr = curr->next) { elements++; @@ -1448,7 +1448,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec) for (vptr = *vec; *vptr; ++vptr); return vptr - *vec; } - + // // make vptr point to the start of the buffer // and ptr point to the area we'll consider the string table. @@ -1490,7 +1490,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec) // // The idea here is to read all the directory names into a string table // (separated by nulls) and when one of the other dir functions is called -// return the pointer to the current file name. +// return the pointer to the current file name. // #define GetBit(bits, i) ((bits)[(i) / CHAR_BIT] & (1 << (i) % CHAR_BIT)) @@ -1601,7 +1601,7 @@ rb_w32_opendir(const char *filename) // // bump the string table size by enough for the - // new name and it's null terminator + // new name and it's null terminator // newpath = (char *)realloc(p->start, idx + len); @@ -1926,7 +1926,7 @@ is_socket(SOCKET fd) } // -// Since the errors returned by the socket error function +// Since the errors returned by the socket error function // WSAGetLastError() are not known by the library routine strerror // we have to roll our own. // @@ -2010,7 +2010,7 @@ getegid(void) int setuid(rb_uid_t uid) -{ +{ return (uid == ROOT_UID ? 0 : -1); } @@ -2092,7 +2092,7 @@ rb_w32_fdisset(int fd, fd_set *set) // // Networking trampolines -// These are used to avoid socket startup/shutdown overhead in case +// These are used to avoid socket startup/shutdown overhead in case // the socket routines aren't used. // @@ -2120,7 +2120,7 @@ extract_fd(fd_set *dst, fd_set *src, int (*func)(SOCKET)) } memmove( &src->fd_array[s], - &src->fd_array[s+1], + &src->fd_array[s+1], sizeof(src->fd_array[0]) * (--src->fd_count - s)); } else s++; @@ -2261,7 +2261,7 @@ compare(const struct timeval *t1, const struct timeval *t2) } #undef Sleep -long +long rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex, struct timeval *timeout) { @@ -2468,7 +2468,7 @@ rb_w32_accept(int s, struct sockaddr *addr, int *addrlen) #undef bind -int +int rb_w32_bind(int s, struct sockaddr *addr, int addrlen) { int r; @@ -2486,7 +2486,7 @@ rb_w32_bind(int s, struct sockaddr *addr, int addrlen) #undef connect -int +int rb_w32_connect(int s, struct sockaddr *addr, int addrlen) { int r; @@ -2509,7 +2509,7 @@ rb_w32_connect(int s, struct sockaddr *addr, int addrlen) #undef getpeername -int +int rb_w32_getpeername(int s, struct sockaddr *addr, int *addrlen) { int r; @@ -2526,7 +2526,7 @@ rb_w32_getpeername(int s, struct sockaddr *addr, int *addrlen) #undef getsockname -int +int rb_w32_getsockname(int s, struct sockaddr *addr, int *addrlen) { int r; @@ -2541,7 +2541,7 @@ rb_w32_getsockname(int s, struct sockaddr *addr, int *addrlen) return r; } -int +int rb_w32_getsockopt(int s, int level, int optname, char *optval, int *optlen) { int r; @@ -2558,7 +2558,7 @@ rb_w32_getsockopt(int s, int level, int optname, char *optval, int *optlen) #undef ioctlsocket -int +int rb_w32_ioctlsocket(int s, long cmd, u_long *argp) { int r; @@ -2575,7 +2575,7 @@ rb_w32_ioctlsocket(int s, long cmd, u_long *argp) #undef listen -int +int rb_w32_listen(int s, int backlog) { int r; @@ -2592,7 +2592,7 @@ rb_w32_listen(int s, int backlog) #undef recv -int +int rb_w32_recv(int s, char *buf, int len, int flags) { int r; @@ -2609,8 +2609,8 @@ rb_w32_recv(int s, char *buf, int len, int flags) #undef recvfrom -int -rb_w32_recvfrom(int s, char *buf, int len, int flags, +int +rb_w32_recvfrom(int s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen) { int r; @@ -2627,7 +2627,7 @@ rb_w32_recvfrom(int s, char *buf, int len, int flags, #undef send -int +int rb_w32_send(int s, const char *buf, int len, int flags) { int r; @@ -2644,8 +2644,8 @@ rb_w32_send(int s, const char *buf, int len, int flags) #undef sendto -int -rb_w32_sendto(int s, const char *buf, int len, int flags, +int +rb_w32_sendto(int s, const char *buf, int len, int flags, struct sockaddr *to, int tolen) { int r; @@ -2662,7 +2662,7 @@ rb_w32_sendto(int s, const char *buf, int len, int flags, #undef setsockopt -int +int rb_w32_setsockopt(int s, int level, int optname, char *optval, int optlen) { int r; @@ -2676,10 +2676,10 @@ rb_w32_setsockopt(int s, int level, int optname, char *optval, int optlen) }); return r; } - + #undef shutdown -int +int rb_w32_shutdown(int s, int how) { int r; @@ -2749,7 +2749,7 @@ open_ifs_socket(int af, int type, int protocol) #define open_socket(a, t, p) socket(a, t, p) #endif -int +int rb_w32_socket(int af, int type, int protocol) { SOCKET s; @@ -3761,7 +3761,7 @@ rb_w32_getc(FILE* stream) c = (unsigned char)*stream->FILE_READPTR++; rb_trap_immediate = trap_immediate; } - else + else #endif { c = _filbuf(stream); @@ -3786,7 +3786,7 @@ rb_w32_putc(int c, FILE* stream) c = (unsigned char)(*stream->FILE_READPTR++ = (char)c); rb_trap_immediate = trap_immediate; } - else + else #endif { c = _flsbuf(c, stream);