1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/lib/tk.rb (TkCore::chooseDirectory): back up wrongly

removed method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-07-26 15:03:16 +00:00
parent 472efdfeb4
commit f0b77b0cde
5 changed files with 124 additions and 88 deletions

View file

@ -7,6 +7,11 @@ Sat Jul 26 21:25:21 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c: remove some old comments. * win32/win32.c: remove some old comments.
Sat Jul 26 14:26:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/tk/lib/tk.rb (TkCore::chooseDirectory): back up wrongly
removed method.
Sat Jul 26 14:14:12 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net> Sat Jul 26 14:14:12 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* ext/stringio/stringio.c: includes Enumerable as well as IO. * ext/stringio/stringio.c: includes Enumerable as well as IO.

View file

@ -750,7 +750,7 @@ if test "$with_dln_a_out" != yes; then
esac esac
else else
case "$target_os" in case "$target_os" in
hpux*) CCDLFLAGS='+z';; hpux*) CCDLFLAGS='+Z';;
solaris*|irix*) CCDLFLAGS='-KPIC' ;; solaris*|irix*) CCDLFLAGS='-KPIC' ;;
sunos*) CCDLFLAGS='-PIC' ;; sunos*) CCDLFLAGS='-PIC' ;;
esix*|uxpds*) CCDLFLAGS='-KPIC' ;; esix*|uxpds*) CCDLFLAGS='-KPIC' ;;

View file

@ -67,7 +67,7 @@ typedef uint8_t sha2_byte; /* Exactly 1 byte */
typedef uint32_t sha2_word32; /* Exactly 4 bytes */ typedef uint32_t sha2_word32; /* Exactly 4 bytes */
typedef uint64_t sha2_word64; /* Exactly 8 bytes */ typedef uint64_t sha2_word64; /* Exactly 8 bytes */
#if defined(__GNUC__) #if defined(__GNUC__) || defined(_HPUX_SOURCE)
#define ULL(number) number##ULL #define ULL(number) number##ULL
#else #else
#define ULL(number) (uint64_t)(number) #define ULL(number) (uint64_t)(number)

View file

@ -3,15 +3,16 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <readline/readline.h> #include <readline/readline.h>
#include <readline/history.h> #include <readline/history.h>
#include "ruby.h" #include "ruby.h"
#include "rubysig.h" #include "rubysig.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
static VALUE mReadline; static VALUE mReadline;
#define TOLOWER(c) (isupper(c) ? tolower(c) : c) #define TOLOWER(c) (isupper(c) ? tolower(c) : c)

View file

@ -21,7 +21,8 @@
# #
# The following +Math+ module methods are redefined to handle Complex arguments. # The following +Math+ module methods are redefined to handle Complex arguments.
# They will work as normal with non-Complex arguments. # They will work as normal with non-Complex arguments.
# sqrt exp cos sin tan log log10 atan2 # sqrt exp cos sin tan log log10
# cosh sinh tanh acos asin atan atan2 acosh asinh atanh
# #
@ -66,7 +67,6 @@ class Complex < Numeric
Complex(r*Math.cos(theta), r*Math.sin(theta)) Complex(r*Math.cos(theta), r*Math.sin(theta))
end end
private_class_method :new
# #
# Creates a +Complex+ number <tt>a</tt>+<tt>b</tt><i>i</i>. # Creates a +Complex+ number <tt>a</tt>+<tt>b</tt><i>i</i>.
# #
@ -76,7 +76,9 @@ class Complex < Numeric
def initialize(a, b) def initialize(a, b)
raise "non numeric 1st arg `#{a.inspect}'" if !a.kind_of? Numeric raise "non numeric 1st arg `#{a.inspect}'" if !a.kind_of? Numeric
raise "`#{a.inspect}' for 1st arg" if a.kind_of? Complex
raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric
raise "`#{b.inspect}' for 2nd arg" if b.kind_of? Complex
@real = a @real = a
@image = b @image = b
end end
@ -181,7 +183,7 @@ class Complex < Numeric
end end
elsif Complex.generic?(other) elsif Complex.generic?(other)
r, theta = polar r, theta = polar
Complex.polar(r.power!(other), theta * other) Complex.polar(r**other, theta*other)
else else
x, y = other.coerce(self) x, y = other.coerce(self)
x**y x**y
@ -236,8 +238,9 @@ class Complex < Numeric
# Argument (angle from (1,0) on the complex plane). # Argument (angle from (1,0) on the complex plane).
# #
def arg def arg
Math.atan2(@image.to_f, @real.to_f) Math.atan2!(@image, @real)
end end
alias angle arg
# #
# Returns the absolute value _and_ the argument. # Returns the absolute value _and_ the argument.
@ -252,6 +255,7 @@ class Complex < Numeric
def conjugate def conjugate
Complex(@real, -@image) Complex(@real, -@image)
end end
alias conj conjugate
# #
# Compares the absolute values of the two numbers. # Compares the absolute values of the two numbers.
@ -395,6 +399,7 @@ class Numeric
return Math::PI return Math::PI
end end
end end
alias angle arg
# #
# See Complex#polar. # See Complex#polar.
@ -409,46 +414,28 @@ class Numeric
def conjugate def conjugate
self self
end end
alias conj conjugate
end end
class Fixnum
unless defined? 1.power!
alias power! **
end
# Redefined to handle a Complex argument.
def ** (other)
if self < 0
Complex.new!(self, 0) ** other
else
if defined? self.rpower
self.rpower(other)
else
self.power!(other)
end
end
end
end
class Bignum
alias power! **
end
class Float
alias power! **
end
module Math module Math
alias sqrt! sqrt alias sqrt! sqrt
alias exp! exp alias exp! exp
alias log! log
alias log10! log10
alias cos! cos alias cos! cos
alias sin! sin alias sin! sin
alias tan! tan alias tan! tan
alias log! log alias cosh! cosh
alias sinh! sinh
alias tanh! tanh
alias acos! acos
alias asin! asin
alias atan! atan alias atan! atan
alias log10! log10
alias atan2! atan2 alias atan2! atan2
alias acosh! acosh
alias asinh! asinh
alias atanh! atanh
# Redefined to handle a Complex argument. # Redefined to handle a Complex argument.
def sqrt(z) def sqrt(z)
@ -478,20 +465,6 @@ module Math
end end
end end
#
# Hyperbolic cosine.
#
def cosh!(x)
(exp!(x) + exp!(-x))/2.0
end
#
# Hyperbolic sine.
#
def sinh!(x)
(exp!(x) - exp!(-x))/2.0
end
# Redefined to handle a Complex argument. # Redefined to handle a Complex argument.
def cos(z) def cos(z)
if Complex.generic?(z) if Complex.generic?(z)
@ -521,6 +494,30 @@ module Math
end end
end end
def sinh(z)
if Complex.generic?(z)
sinh!(z)
else
Complex( sinh!(z.real)*cos!(z.image), cosh!(z.real)*sin!(z.image) )
end
end
def cosh(z)
if Complex.generic?(z)
cosh!(z)
else
Complex( cosh!(z.real)*cos!(z.image), sinh!(z.real)*sin!(z.image) )
end
end
def tanh(z)
if Complex.generic?(z)
tanh!(z)
else
sinh(z)/cosh(z)
end
end
# Redefined to handle a Complex argument. # Redefined to handle a Complex argument.
def log(z) def log(z)
if Complex.generic?(z) and z >= 0 if Complex.generic?(z) and z >= 0
@ -540,68 +537,101 @@ module Math
end end
end end
# FIXME: I don't know what the point of this is. If you give it Complex def acos(z)
# arguments, it will fail. if Complex.generic?(z)
def atan2(x, y) acos!(z)
if Complex.generic?(x) and Complex.generic?(y)
atan2!(x, y)
else else
fail "Not yet implemented." -1.0.im * log( z + 1.0.im * sqrt(1.0-z*z) )
end end
end end
# def asin(z)
# Hyperbolic arctangent. if Complex.generic?(z)
# asin!(z)
def atanh!(x) else
log((1.0 + x.to_f) / ( 1.0 - x.to_f)) / 2.0 -1.0.im * log( 1.0.im * z + sqrt(1.0-z*z) )
end
end end
# Redefined to handle a Complex argument.
def atan(z) def atan(z)
if Complex.generic?(z) if Complex.generic?(z)
atan2!(z, 1) atan!(z)
elsif z.image == 0
atan2(z.real,1)
else else
a = z.real 1.0.im * log( (1.0.im+z) / (1.0.im-z) ) / 2.0
b = z.image end
end
c = (a*a + b*b - 1.0)
d = (a*a + b*b + 1.0) def atan2(y,x)
if Complex.generic?(y) and Complex.generic?(x)
Complex(atan2!((c + sqrt(c*c + 4.0*a*a)), 2.0*a), atan2!(y,x)
atanh!((-d + sqrt(d*d - 4.0*b*b))/(2.0*b))) else
-1.0.im * log( (x+1.0.im*y) / sqrt(x*x+y*y) )
end
end
def acosh(z)
if Complex.generic?(z)
acosh!(z)
else
log( z + sqrt(z*z-1.0) )
end
end
def asinh(z)
if Complex.generic?(z)
asinh!(z)
else
log( z + sqrt(1.0+z*z) )
end
end
def atanh(z)
if Complex.generic?(z)
atanh!(z)
else
log( (1.0+z) / (1.0-z) ) / 2.0
end end
end end
module_function :sqrt
module_function :sqrt! module_function :sqrt!
module_function :sqrt
module_function :exp! module_function :exp!
module_function :exp module_function :exp
module_function :log!
module_function :log
module_function :log10!
module_function :log10
module_function :cosh! module_function :cosh!
module_function :cosh
module_function :cos! module_function :cos!
module_function :cos module_function :cos
module_function :sinh! module_function :sinh!
module_function :sinh
module_function :sin! module_function :sin!
module_function :sin module_function :sin
module_function :tan! module_function :tan!
module_function :tan module_function :tan
module_function :log! module_function :tanh!
module_function :log module_function :tanh
module_function :log10! module_function :acos!
module_function :log module_function :acos
module_function :asin!
module_function :asin
module_function :atan!
module_function :atan
module_function :atan2! module_function :atan2!
module_function :atan2 module_function :atan2
# module_function :atan! module_function :acosh!
module_function :atan module_function :acosh
module_function :asinh!
module_function :asinh
module_function :atanh! module_function :atanh!
module_function :atanh
end end
# Documentation comments: # Documentation comments:
# - source: original (researched from pickaxe) # - source: original (researched from pickaxe)
# - a couple of fixme's # - a couple of fixme's
# - Math module methods sinh! etc. a bit fuzzy. What exactly is the intention?
# - RDoc output for Bignum etc. is a bit short, with nothing but an # - RDoc output for Bignum etc. is a bit short, with nothing but an
# (undocumented) alias. No big deal. # (undocumented) alias. No big deal.